private group tests, cont.

This commit is contained in:
friendica 2012-05-29 22:57:15 -07:00
parent b6fe837a64
commit 88a0d6a1d5
8 changed files with 54 additions and 24 deletions

View File

@ -11,7 +11,7 @@ require_once('include/cache.php');
define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_PLATFORM', 'Friendica');
define ( 'FRIENDICA_VERSION', '3.0.1358' ); define ( 'FRIENDICA_VERSION', '3.0.1358' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
define ( 'DB_UPDATE_VERSION', 1144 ); define ( 'DB_UPDATE_VERSION', 1145 );
define ( 'EOL', "<br />\r\n" ); define ( 'EOL', "<br />\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );

View File

@ -173,6 +173,7 @@ CREATE TABLE IF NOT EXISTS `contact` (
`readonly` tinyint(1) NOT NULL DEFAULT '0', `readonly` tinyint(1) NOT NULL DEFAULT '0',
`writable` tinyint(1) NOT NULL DEFAULT '0', `writable` tinyint(1) NOT NULL DEFAULT '0',
`forum` tinyint(1) NOT NULL DEFAULT '0', `forum` tinyint(1) NOT NULL DEFAULT '0',
`prv` tinyint(1) NOT NULL DEFAULT '0',
`hidden` tinyint(1) NOT NULL DEFAULT '0', `hidden` tinyint(1) NOT NULL DEFAULT '0',
`archive` tinyint(1) NOT NULL DEFAULT '0', `archive` tinyint(1) NOT NULL DEFAULT '0',
`pending` tinyint(1) NOT NULL DEFAULT '1', `pending` tinyint(1) NOT NULL DEFAULT '1',

View File

@ -1063,9 +1063,6 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
$a = get_app(); $a = get_app();
// if((! strlen($contact['issued-id'])) && (! $contact['duplex']) && (! ($owner['page-flags'] == PAGE_COMMUNITY)))
// return 3;
$idtosend = $orig_id = (($contact['dfrn-id']) ? $contact['dfrn-id'] : $contact['issued-id']); $idtosend = $orig_id = (($contact['dfrn-id']) ? $contact['dfrn-id'] : $contact['issued-id']);
if($contact['duplex'] && $contact['dfrn-id']) if($contact['duplex'] && $contact['dfrn-id'])
@ -1130,6 +1127,9 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
$rino_allowed = ((intval($res->rino) === 1) ? 1 : 0); $rino_allowed = ((intval($res->rino) === 1) ? 1 : 0);
$page = (($owner['page-flags'] == PAGE_COMMUNITY) ? 1 : 0); $page = (($owner['page-flags'] == PAGE_COMMUNITY) ? 1 : 0);
if($owner['page-flags'] == PAGE_PRVGROUP)
$page = 2;
$final_dfrn_id = ''; $final_dfrn_id = '';
if($perm) { if($perm) {
@ -1183,7 +1183,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
$postvars['ssl_policy'] = $ssl_policy; $postvars['ssl_policy'] = $ssl_policy;
if($page) if($page)
$postvars['page'] = '1'; $postvars['page'] = $page;
if($rino && $rino_allowed && (! $dissolve)) { if($rino && $rino_allowed && (! $dissolve)) {
$key = substr(random_string(),0,16); $key = substr(random_string(),0,16);

View File

@ -202,6 +202,8 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
if($user[0]['page-flags'] == PAGE_COMMUNITY) if($user[0]['page-flags'] == PAGE_COMMUNITY)
$params['page'] = 1; $params['page'] = 1;
if($user[0]['page-flags'] == PAGE_PRVGROUP)
$params['page'] = 2;
logger('dfrn_confirm: Confirm: posting data to ' . $dfrn_confirm . ': ' . print_r($params,true), LOGGER_DATA); logger('dfrn_confirm: Confirm: posting data to ' . $dfrn_confirm . ': ' . print_r($params,true), LOGGER_DATA);
@ -537,6 +539,9 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
$page = ((x($_POST,'page')) ? intval($_POST['page']) : 0 ); $page = ((x($_POST,'page')) ? intval($_POST['page']) : 0 );
$version_id = ((x($_POST,'dfrn_version')) ? (float) $_POST['dfrn_version'] : 2.0); $version_id = ((x($_POST,'dfrn_version')) ? (float) $_POST['dfrn_version'] : 2.0);
$forum = (($page == 1) ? 1 : 0);
$prv = (($page == 2) ? 1 : 0);
logger('dfrn_confirm: requestee contacted: ' . $node); logger('dfrn_confirm: requestee contacted: ' . $node);
logger('dfrn_confirm: request: POST=' . print_r($_POST,true), LOGGER_DATA); logger('dfrn_confirm: request: POST=' . print_r($_POST,true), LOGGER_DATA);
@ -691,6 +696,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
`pending` = 0, `pending` = 0,
`duplex` = %d, `duplex` = %d,
`forum` = %d, `forum` = %d,
`prv` = %d,
`network` = '%s' WHERE `id` = %d LIMIT 1 `network` = '%s' WHERE `id` = %d LIMIT 1
", ",
dbesc($photos[0]), dbesc($photos[0]),
@ -701,7 +707,8 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
dbesc(datetime_convert()), dbesc(datetime_convert()),
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($duplex), intval($duplex),
intval($page), intval($forum),
intval($prv),
dbesc(NETWORK_DFRN), dbesc(NETWORK_DFRN),
intval($dfrn_record) intval($dfrn_record)
); );

View File

@ -17,6 +17,9 @@ function dfrn_notify_post(&$a) {
$ssl_policy = ((x($_POST,'ssl_policy')) ? notags(trim($_POST['ssl_policy'])): 'none'); $ssl_policy = ((x($_POST,'ssl_policy')) ? notags(trim($_POST['ssl_policy'])): 'none');
$page = ((x($_POST,'page')) ? intval($_POST['page']) : 0); $page = ((x($_POST,'page')) ? intval($_POST['page']) : 0);
$forum = (($page == 1) ? 1 : 0);
$prv = (($page == 2) ? 1 : 0);
$writable = (-1); $writable = (-1);
if($dfrn_version >= 2.21) { if($dfrn_version >= 2.21) {
$writable = (($perm === 'rw') ? 1 : 0); $writable = (($perm === 'rw') ? 1 : 0);
@ -88,10 +91,11 @@ function dfrn_notify_post(&$a) {
$importer = $r[0]; $importer = $r[0];
if((($writable != (-1)) && ($writable != $importer['writable'])) || ($importer['forum'] != $page)) { if((($writable != (-1)) && ($writable != $importer['writable'])) || ($importer['forum'] != $forum) || ($importer['prv'] != $prv)) {
q("UPDATE `contact` SET `writable` = %d, forum = %d WHERE `id` = %d LIMIT 1", q("UPDATE `contact` SET `writable` = %d, forum = %d, prv = %d WHERE `id` = %d LIMIT 1",
intval(($writable == (-1)) ? $importer['writable'] : $writable), intval(($writable == (-1)) ? $importer['writable'] : $writable),
intval($page), intval($forum),
intval($prv),
intval($importer['id']) intval($importer['id'])
); );
if($writable != (-1)) if($writable != (-1))

View File

@ -262,17 +262,17 @@ function item_post(&$a) {
} }
} }
if(strlen($categories)) { if(strlen($categories)) {
// get the "fileas" tags for this post // get the "fileas" tags for this post
$filedas = file_tag_file_to_list($categories, 'file'); $filedas = file_tag_file_to_list($categories, 'file');
} }
// save old and new categories, so we can determine what needs to be deleted from pconfig // save old and new categories, so we can determine what needs to be deleted from pconfig
$categories_old = $categories; $categories_old = $categories;
$categories = file_tag_list_to_file(trim($_REQUEST['category']), 'category'); $categories = file_tag_list_to_file(trim($_REQUEST['category']), 'category');
$categories_new = $categories; $categories_new = $categories;
if(strlen($filedas)) { if(strlen($filedas)) {
// append the fileas stuff to the new categories list // append the fileas stuff to the new categories list
$categories .= file_tag_list_to_file($filedas, 'file'); $categories .= file_tag_list_to_file($filedas, 'file');
} }
// Work around doubled linefeeds in Tinymce 3.5b2 // Work around doubled linefeeds in Tinymce 3.5b2
@ -453,6 +453,7 @@ function item_post(&$a) {
$tagged = array(); $tagged = array();
$private_forum = false;
if(count($tags)) { if(count($tags)) {
foreach($tags as $tag) { foreach($tags as $tag) {
@ -471,11 +472,22 @@ function item_post(&$a) {
continue; continue;
$success = handle_tag($a, $body, $inform, $str_tags, (local_user()) ? local_user() : $profile_uid , $tag); $success = handle_tag($a, $body, $inform, $str_tags, (local_user()) ? local_user() : $profile_uid , $tag);
if($success) if($success['replaced'])
$tagged[] = $tag; $tagged[] = $tag;
if(is_array($success['contact']) && intval($success['contact']['prv'])) {
$private_forum = true;
$private_id = $success['contact']['id'];
}
} }
} }
if(($private_forum) && (! $parent) && (! $private)) {
// we tagged a private forum in a top level post and the message was public.
// Restrict it.
$private = 1;
$str_contact_allow = '<' . $private_id . '>';
}
$attachments = ''; $attachments = '';
$match = false; $match = false;
@ -893,6 +905,7 @@ function item_content(&$a) {
function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) { function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) {
$replaced = false; $replaced = false;
$r = null;
//is it a hash tag? //is it a hash tag?
if(strpos($tag,'#') === 0) { if(strpos($tag,'#') === 0) {
@ -1023,5 +1036,5 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) {
} }
} }
return $replaced; return array('replaced' => $replaced, 'contact' => $r[0]);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
define( 'UPDATE_VERSION' , 1144 ); define( 'UPDATE_VERSION' , 1145 );
/** /**
* *
@ -1253,5 +1253,9 @@ function update_1143() {
return UPDATE_SUCCESS ; return UPDATE_SUCCESS ;
} }
function update_1144() {
$r = q("alter table contact add prv tinyint(1) not null default '0' after forum");
if(! $r)
return UPDATE_FAILED ;
return UPDATE_SUCCESS ;
}

View File

@ -80,6 +80,7 @@ blockquote {
.heart { .heart {
color: #FF0000; color: #FF0000;
font-size: 100%; font-size: 100%;
margin-right: 5px;
} }