aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-01-13 18:35:12 -0800
committerfriendica <info@friendica.com>2013-01-13 18:35:12 -0800
commit5182d6d820ee67404a84114f5c4074c3ae55bf84 (patch)
tree49ad2dc9ccbfab03f9f6197aa8ee6681b7cc9ff1 /include
parent83ca9dfc2396cdb3134bc8f7b6a02c80f7c5b537 (diff)
downloadvolse-hubzilla-5182d6d820ee67404a84114f5c4074c3ae55bf84.tar.gz
volse-hubzilla-5182d6d820ee67404a84114f5c4074c3ae55bf84.tar.bz2
volse-hubzilla-5182d6d820ee67404a84114f5c4074c3ae55bf84.zip
this should make tag delivery (e.g. forums) work - but not yet fully tested
Diffstat (limited to 'include')
-rwxr-xr-xinclude/items.php71
-rw-r--r--include/notifier.php21
-rw-r--r--include/permissions.php12
3 files changed, 62 insertions, 42 deletions
diff --git a/include/items.php b/include/items.php
index a4894bb80..0217884fd 100755
--- a/include/items.php
+++ b/include/items.php
@@ -4,7 +4,7 @@ require_once('include/bbcode.php');
require_once('include/oembed.php');
require_once('include/crypto.php');
require_once('include/Photo.php');
-
+require_once('include/permissions.php');
function collect_recipients($item,&$private) {
@@ -31,13 +31,19 @@ function collect_recipients($item,&$private) {
);
if($r) {
foreach($r as $rr) {
- // FIXME check permissions of each
$recipients[] = $rr['abook_xchan'];
}
}
$private = false;
}
+
+ // This is a somewhat expensive operation but important.
+ // Don't send this item to anybody who isn't allowed to see it
+
+ $recipients = check_list_permissions($item['uid'],$recipients,'view_stream');
+
return $recipients;
+
}
@@ -1510,14 +1516,7 @@ function tag_deliver($uid,$item_id) {
);
if(! count($u))
return;
-
-
- // fixme - look for permissions allowing tag delivery
- $community_page = (($u[0]['page-flags'] == PAGE_COMMUNITY) ? true : false);
- $prvgroup = (($u[0]['page-flags'] == PAGE_PRVGROUP) ? true : false);
-
-
$i = q("select * from item where id = %d and uid = %d limit 1",
intval($item_id),
intval($uid)
@@ -1552,8 +1551,8 @@ function tag_deliver($uid,$item_id) {
else
return;
-
- // Now let's check for a reshare so we don't spam a forum
+ // At this point we've determined that the person receiving this post was mentioned in it.
+ // Now let's check if this mention was inside a reshare so we don't spam a forum
$body = preg_replace('/\[share(.*?)\[\/share\]/','',$item['body']);
@@ -1563,7 +1562,8 @@ function tag_deliver($uid,$item_id) {
}
- // send a notification
+ // All good.
+ // Send a notification
require_once('include/enotify.php');
notification(array(
@@ -1587,39 +1587,34 @@ function tag_deliver($uid,$item_id) {
// FIXME
-// if(($item['wall']) || ($item['origin']) || ($item['id'] != $item['parent']))
-// return;
-
- // now change this copy of the post to a forum head message and deliver to all the tgroup members
+ if(($item['item_flags'] & ITEM_WALL) || ($item['item_flags'] & ITEM_ORIGIN) || ($item['item_flags'] & ITEM_THREAD_TOP) || ($item['id'] != $item['parent']))
+ return;
-// $c = q("select name, url, thumb from contact where self = 1 and uid = %d limit 1",
-// intval($u[0]['uid'])
-// );
-// if(! count($c))
-// return;
+ // now change this copy of the post to a forum head message and deliver to all the tgroup members
// also reset all the privacy bits to the forum default permissions
$private = ($u[0]['allow_cid'] || $u[0]['allow_gid'] || $u[0]['deny_cid'] || $u[0]['deny_gid']) ? 1 : 0;
-// $forum_mode = (($prvgroup) ? 2 : 1);
-
-// q("update item set wall = 1, origin = 1, forum_mode = %d, `owner-name` = '%s', `owner-link` = '%s', `owner-avatar` = '%s',
-// `private` = %d, `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' where id = %d limit 1",
-// intval($forum_mode),
-// dbesc($c[0]['name']),
-// dbesc($c[0]['url']),
-// dbesc($c[0]['thumb']),
-// intval($private),
-// dbesc($u[0]['allow_cid']),
-// dbesc($u[0]['allow_gid']),
-// dbesc($u[0]['deny_cid']),
-// dbesc($u[0]['deny_gid']),
-// intval($item_id)
-// );
-
-// proc_run('php','include/notifier.php','tgroup',$item_id);
+ $flag_bits = ITEM_WALL|ITEM_ORIGIN|ITEM_UPLINK;
+ if($private)
+ $flag_bits = $flag_bits | ITEM_PRIVATE;
+
+ $r = q("update item set item_flags = ( $item_flags | %d ), owner_xchan = '%s', allow_cid = '%s', allow_gid = '%s',
+ deny_cid = '%s', deny_gid = '%s' where id = %d limit 1",
+ intval($flag_bits),
+ dbesc($u[0]['channel_hash']),
+ dbesc($u[0]['allow_cid']),
+ dbesc($u[0]['allow_gid']),
+ dbesc($u[0]['deny_cid']),
+ dbesc($u[0]['deny_gid']),
+ intval($item_id)
+ );
+ if($r)
+ proc_run('php','include/notifier.php','tgroup',$item_id);
+ else
+ logger('tag_deliver: failed to update item');
}
diff --git a/include/notifier.php b/include/notifier.php
index feb1c693c..74da8f2f8 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -234,19 +234,25 @@ function notifier_run($argv, $argc){
$encoded_item = encode_item($target_item);
-
$relay_to_owner = (((! $top_level_post) && ($target_item['item_flags'] & ITEM_ORIGIN)) ? true : false);
+ $uplink = false;
+
// $cmd === 'relay' indicates the owner is sending it to the original recipients
// don't allow the item in the relay command to relay to owner under any circumstances, it will loop
logger('notifier: relay_to_owner: ' . (($relay_to_owner) ? 'true' : 'false'));
logger('notifier: top_level_post: ' . (($top_level_post) ? 'true' : 'false'));
logger('notifier: target_item_flags: ' . $target_item['item_flags'] . ' ' . (($target_item['item_flags'] & ITEM_ORIGIN ) ? 'true' : 'false'));
+ // tag_deliver'd post which needs to be sent back to the original author
- if(($relay_to_owner) && ($cmd !== 'relay')) {
+ if(($cmd === 'uplink') && ($parent_item['item_flags'] & ITEM_UPLINK) && (! $top_level_post)) {
+ $uplink = true;
+ }
+
+ if(($relay_to_owner || $uplink) && ($cmd !== 'relay')) {
logger('notifier: followup relay', LOGGER_DEBUG);
- $recipients = array($parent_item['owner_xchan']);
+ $recipients = array(($uplink) ? $parent_item['author_xchan'] : $parent_item['owner_xchan']);
$private = true;
if(! $encoded_item['flags'])
$encoded_item['flags'] = array();
@@ -256,6 +262,15 @@ function notifier_run($argv, $argc){
logger('notifier: normal distribution', LOGGER_DEBUG);
if($cmd === 'relay')
logger('notifier: owner relay');
+
+ // if our parent is a tag_delivery recipient, uplink to the original author causing
+ // a delivery fork.
+
+ if(($parent_item['item_flags'] & ITEM_UPLINK) && (! $top_level_post) && ($cmd !== 'uplink')) {
+ logger('notifier: uplinking this item');
+ proc_run('php','include/notifier.php','uplink',$item_id);
+ }
+
$private = false;
$recipients = collect_recipients($parent_item,$private);
diff --git a/include/permissions.php b/include/permissions.php
index e74486a06..e3578b311 100644
--- a/include/permissions.php
+++ b/include/permissions.php
@@ -278,5 +278,15 @@ function perm_is_allowed($uid,$observer,$permission) {
}
-
+// Check a simple array of observers against a permissions
+// return a simple array of those with permission
+
+function check_list_permissions($uid,$arr,$perm) {
+ $result = array();
+ if($arr)
+ foreach($arr as $x)
+ if($perm_is_allowed($uid,$x,$perm))
+ $result[] = $x;
+ return($result);
+}