From c29483b88cda69beb51f00ee8f2d262bc6784a24 Mon Sep 17 00:00:00 2001 From: marijus Date: Mon, 2 Feb 2015 15:18:44 +0100 Subject: respect parent dir permissions --- include/attach.php | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index 155ddbc96..c38301e01 100644 --- a/include/attach.php +++ b/include/attach.php @@ -966,6 +966,35 @@ function pipe_streams($in, $out) { function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $verb, $no_activity) { + //if we got no object something went wrong + if(!$object) + return; + + $is_dir = (($object['flags'] & ATTACH_FLAG_DIR) ? true : false); + + //do not send activity for folders for now + if($is_dir) + return; + + //check for recursive perms if we are in a folder + if($object['folder']) { + + $folder_hash = $object['folder']; + + $r_perms = check_recursive_perms($allow_cid, $allow_gid, $deny_cid, $deny_gid, $folder_hash); + + $allow_cid = $r_perms['allow_cid']; + $allow_gid = $r_perms['allow_gid']; + $deny_cid = $r_perms['deny_cid']; + $deny_gid = $r_perms['deny_gid']; + + if(!$allow_gid && !$allow_cid) { + notice( t('Allowed permissions for this file are not recursive. None of your allowed contacts will have access to this file.') . EOL); + $verb = 'update'; + } + + } + require_once('include/items.php'); $poster = get_app()->get_observer(); @@ -1124,3 +1153,48 @@ function get_file_activity_object($channel_id, $hash, $cloudpath) { return $object; } + +function check_recursive_perms($allow_cid, $allow_gid, $deny_cid, $deny_gid, $folder_hash) { + + $arr_allow_cid = expand_acl($allow_cid); + $arr_allow_gid = expand_acl($allow_gid); + $arr_deny_cid = expand_acl($deny_cid); + $arr_deny_gid = expand_acl($deny_gid); + + while($folder_hash) { + $x = q("SELECT * FROM attach WHERE hash = '%s'", + dbesc($folder_hash) + ); + + $parents_arr_allow_cid[] = expand_acl($x[0]['allow_cid']); + $parents_arr_allow_gid[] = expand_acl($x[0]['allow_gid']); + $parents_arr_deny_cid[] = expand_acl($x[0]['deny_cid']); + $parents_arr_deny_gid[] = expand_acl($x[0]['deny_gid']); + + $folder_hash = $x[0]['folder']; + } + + foreach($parents_arr_allow_gid as $folder_arr_allow_gid) { + $arr_allow_gid = array_intersect($arr_allow_gid, $folder_arr_allow_gid); + } + + foreach($parents_arr_allow_cid as $folder_arr_allow_cid) { + $arr_allow_cid = array_intersect($arr_allow_cid, $folder_arr_allow_cid); + } + + foreach($parents_arr_deny_gid as $folder_arr_deny_gid) { + $arr_deny_gid = array_merge($arr_deny_gid, $folder_arr_deny_gid); + } + + foreach($parents_arr_deny_cid as $folder_arr_deny_cid) { + $arr_deny_cid = array_merge($arr_deny_cid, $folder_arr_deny_cid); + } + + $ret['allow_gid'] = perms2str($arr_allow_gid); + $ret['allow_cid'] = perms2str($arr_allow_cid); + $ret['deny_gid'] = perms2str(array_unique($arr_deny_gid)); + $ret['deny_cid'] = perms2str(array_unique($arr_deny_cid)); + + return $ret; + +} -- cgit v1.2.3 From e0bc01a7f60668c35f677fbc52ba2e8aec70683a Mon Sep 17 00:00:00 2001 From: marijus Date: Mon, 2 Feb 2015 15:25:30 +0100 Subject: just select perms --- include/attach.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index c38301e01..07f31761d 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1162,7 +1162,7 @@ function check_recursive_perms($allow_cid, $allow_gid, $deny_cid, $deny_gid, $fo $arr_deny_gid = expand_acl($deny_gid); while($folder_hash) { - $x = q("SELECT * FROM attach WHERE hash = '%s'", + $x = q("SELECT allow_cid, allow_gid, deny_cid, deny_gid, FROM attach WHERE hash = '%s'", dbesc($folder_hash) ); -- cgit v1.2.3 From 1b30e43c45100fc8f1a9f558237068ce24130264 Mon Sep 17 00:00:00 2001 From: marijus Date: Mon, 2 Feb 2015 15:26:35 +0100 Subject: typo --- include/attach.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index 07f31761d..12144d380 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1162,7 +1162,7 @@ function check_recursive_perms($allow_cid, $allow_gid, $deny_cid, $deny_gid, $fo $arr_deny_gid = expand_acl($deny_gid); while($folder_hash) { - $x = q("SELECT allow_cid, allow_gid, deny_cid, deny_gid, FROM attach WHERE hash = '%s'", + $x = q("SELECT allow_cid, allow_gid, deny_cid, deny_gid FROM attach WHERE hash = '%s'", dbesc($folder_hash) ); -- cgit v1.2.3 From 74da8f2e87e863d6cde2598d6929fa035499fddd Mon Sep 17 00:00:00 2001 From: marijus Date: Mon, 2 Feb 2015 15:31:51 +0100 Subject: we also need folder here --- include/attach.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index 12144d380..23cfca0d0 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1162,7 +1162,7 @@ function check_recursive_perms($allow_cid, $allow_gid, $deny_cid, $deny_gid, $fo $arr_deny_gid = expand_acl($deny_gid); while($folder_hash) { - $x = q("SELECT allow_cid, allow_gid, deny_cid, deny_gid FROM attach WHERE hash = '%s'", + $x = q("SELECT allow_cid, allow_gid, deny_cid, deny_gid, folder FROM attach WHERE hash = '%s'", dbesc($folder_hash) ); -- cgit v1.2.3 From 2546b0a5255b4e7031a94b3a59deb1687a68e350 Mon Sep 17 00:00:00 2001 From: marijus Date: Mon, 2 Feb 2015 16:48:49 +0100 Subject: one important line missing --- include/attach.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index 23cfca0d0..d99d8d89e 100644 --- a/include/attach.php +++ b/include/attach.php @@ -991,6 +991,7 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, if(!$allow_gid && !$allow_cid) { notice( t('Allowed permissions for this file are not recursive. None of your allowed contacts will have access to this file.') . EOL); $verb = 'update'; + $update = true; } } -- cgit v1.2.3 From ed3b5f8251fa1534c967e756529aa397cc78fb3a Mon Sep 17 00:00:00 2001 From: marijus Date: Mon, 2 Feb 2015 17:12:13 +0100 Subject: comment this out for now - it is not always true --- include/attach.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index d99d8d89e..5f9d38115 100644 --- a/include/attach.php +++ b/include/attach.php @@ -987,13 +987,13 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $allow_gid = $r_perms['allow_gid']; $deny_cid = $r_perms['deny_cid']; $deny_gid = $r_perms['deny_gid']; - +/* if(!$allow_gid && !$allow_cid) { notice( t('Allowed permissions for this file are not recursive. None of your allowed contacts will have access to this file.') . EOL); $verb = 'update'; $update = true; } - +*/ } require_once('include/items.php'); -- cgit v1.2.3 From a80057fec7980c54df73626be9af3e08f03f5ce7 Mon Sep 17 00:00:00 2001 From: marijus Date: Mon, 2 Feb 2015 17:45:30 +0100 Subject: comment out latest changes - needs more testing --- include/attach.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index 5f9d38115..7ebc4489d 100644 --- a/include/attach.php +++ b/include/attach.php @@ -975,7 +975,7 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, //do not send activity for folders for now if($is_dir) return; - +/* //check for recursive perms if we are in a folder if($object['folder']) { @@ -987,15 +987,15 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $allow_gid = $r_perms['allow_gid']; $deny_cid = $r_perms['deny_cid']; $deny_gid = $r_perms['deny_gid']; -/* + if(!$allow_gid && !$allow_cid) { notice( t('Allowed permissions for this file are not recursive. None of your allowed contacts will have access to this file.') . EOL); $verb = 'update'; $update = true; } -*/ - } + } +*/ require_once('include/items.php'); $poster = get_app()->get_observer(); -- cgit v1.2.3 From 043ff33e437451f6109e8d4cb5a2ce85cabcddec Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 2 Feb 2015 14:59:01 -0800 Subject: issue #889 private tags for forums no longer recognised after tag refactor a few weeks back. This solution is not optimal as it also leaves you in the privacy ACL in some cases and not in others but it restores the previous functionality --- include/items.php | 1 + include/text.php | 3 +++ 2 files changed, 4 insertions(+) (limited to 'include') diff --git a/include/items.php b/include/items.php index c34e694ac..0b2106572 100755 --- a/include/items.php +++ b/include/items.php @@ -4751,6 +4751,7 @@ function item_remove_cid($xchan_hash,$mid,$uid) { // Set item permissions based on results obtained from linkify_tags() function set_linkified_perms($linkified, &$str_contact_allow, &$str_group_allow, $profile_uid, $parent_item = false) { $first_access_tag = true; + foreach($linkified as $x) { $access_tag = $x['access_tag']; if(($access_tag) && (! $parent_item)) { diff --git a/include/text.php b/include/text.php index 13f3f2fdf..d19519779 100644 --- a/include/text.php +++ b/include/text.php @@ -2297,6 +2297,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag) { } } else { + // check for a group/collection exclusion tag // note that we aren't setting $replaced even though we're replacing text. @@ -2357,6 +2358,8 @@ function linkify_tags($a, &$body, $uid) { $tags = get_tags($body); if(count($tags)) { foreach($tags as $tag) { + $access_tag = ''; + // If we already tagged 'Robert Johnson', don't try and tag 'Robert'. // Robert Johnson should be first in the $tags array -- cgit v1.2.3 From 1807db6cb0cc297aff32750b371a4e2e6539ad31 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 2 Feb 2015 20:13:07 -0800 Subject: send rating information to directories --- include/notifier.php | 14 ------ include/ratenotif.php | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/zot.php | 39 ++++++++++++---- 3 files changed, 153 insertions(+), 24 deletions(-) create mode 100644 include/ratenotif.php (limited to 'include') diff --git a/include/notifier.php b/include/notifier.php index edb2f1946..fe6ac33c0 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -297,15 +297,6 @@ function notifier_run($argv, $argc){ $private = false; $packet_type = 'purge'; } - elseif($cmd === 'rating') { - $r = q("select * from xlink where xlink_id = %d and xlink_static = 1 limit 1", - intval($item_id) - ); - if($r) { - logger('rating message: ' . print_r($r[0],true)); - return; - } - } else { // Normal items @@ -483,11 +474,6 @@ function notifier_run($argv, $argc){ // Now we have collected recipients (except for external mentions, FIXME) // Let's reduce this to a set of hubs. - - // for public posts always include our own hub -// this shouldn't be needed any more. collect_recipients should take care of it. -// $sql_extra = (($private) ? "" : " or hubloc_url = '" . dbesc(z_root()) . "' "); - logger('notifier: hub choice: ' . intval($relay_to_owner) . ' ' . intval($private) . ' ' . $cmd, LOGGER_DEBUG); if($relay_to_owner && (! $private) && ($cmd !== 'relay')) { diff --git a/include/ratenotif.php b/include/ratenotif.php new file mode 100644 index 000000000..4fa0077a6 --- /dev/null +++ b/include/ratenotif.php @@ -0,0 +1,124 @@ + 'rating', + 'encoding' => 'zot', + 'target' => $r[0]['xlink_link'], + 'rating' => intval($r[0]['xlink_rating']), + 'rating_text' => $r[0]['xlink_rating_text'], + 'signature' => $r[0]['xlink_sig'], + 'edited' => $r[0]['xlink_updated'] + ); + } + + $channel = channelx_by_hash($r[0]['xlink_xchan']); + if(! $channel) { + logger('no channel'); + return; + } + + + $primary = get_directory_primary(); + + if(! $primary) + return; + + + $interval = ((get_config('system','delivery_interval') !== false) + ? intval(get_config('system','delivery_interval')) : 2 ); + + $deliveries_per_process = intval(get_config('system','delivery_batch_count')); + + if($deliveries_per_process <= 0) + $deliveries_per_process = 1; + + $deliver = array(); + + $x = z_fetch_url($primary . '/regdir'); + if($x['success']) { + $j = json_decode($x['body'],true); + if($j && $j['success'] && is_array($j['directories'])) { + + foreach($j['directories'] as $h) { +// if($h == z_root()) +// continue; + + $hash = random_string(); + $n = zot_build_packet($channel,'notify',null,null,$hash); + + q("insert into outq ( outq_hash, outq_account, outq_channel, outq_driver, outq_posturl, outq_async, outq_created, outq_updated, outq_notify, outq_msg ) values ( '%s', %d, %d, '%s', '%s', %d, '%s', '%s', '%s', '%s' )", + dbesc($hash), + intval($channel['channel_account_id']), + intval($channel['channel_id']), + dbesc('zot'), + dbesc($h . '/post'), + intval(1), + dbesc(datetime_convert()), + dbesc(datetime_convert()), + dbesc($n), + dbesc(json_encode($encoded_item)) + ); + } + $deliver[] = $hash; + + if(count($deliver) >= $deliveries_per_process) { + proc_run('php','include/deliver.php',$deliver); + $deliver = array(); + if($interval) + @time_sleep_until(microtime(true) + (float) $interval); + } + + + // catch any stragglers + + if(count($deliver)) { + proc_run('php','include/deliver.php',$deliver); + } + } + } + + logger('ratenotif: complete.'); + return; + +} + +if (array_search(__file__,get_included_files())===0){ + ratenotif_run($argv,$argc); + killme(); +} diff --git a/include/zot.php b/include/zot.php index 04b6806c2..1e9577dc6 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1108,7 +1108,8 @@ function zot_import($arr, $sender_url) { if(array_key_exists('message',$i) && array_key_exists('type',$i['message']) && $i['message']['type'] === 'rating') { // rating messages are processed only by directory servers logger('Rating received: ' . print_r($arr,true), LOGGER_DATA); - $result = process_rating_delivery($i['notify']['sender'],$arr); + $result = process_rating_delivery($i['notify']['sender'],$i['message']); + continue; } if(array_key_exists('recipients',$i['notify']) && count($i['notify']['recipients'])) { @@ -1813,34 +1814,52 @@ function process_mail_delivery($sender,$arr,$deliveries) { function process_rating_delivery($sender,$arr) { - $dirmode = intval(get_config('system','directory_mode')); - if($dirmode == DIRECTORY_MODE_NORMAL) - return; + logger('process_rating_delivery: ' . print_r($arr,true)); if(! $arr['target']) return; - $r = q("select * from xlink where xlink_xchan = '%s' and xlink_target = '%s' limit 1", + $z = q("select xchan_pubkey from xchan where xchan_hash = '%s' limit 1", + dbesc($sender['hash']) + ); + + + if((! $z) || (! rsa_verify($arr['target'] . '.' . $arr['rating'] . '.' . $arr['rating_text'], base64url_decode($arr['signature']),$z[0]['xchan_pubkey']))) { + logger('failed to verify rating'); + return; + } + + $r = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1 limit 1", dbesc($sender['hash']), dbesc($arr['target']) - ); + ); + if($r) { - $x = q("update xlink set xlink_rating = %d, xlink_rating_text = '%s', xlink_updated = '%s' where xlink_id = %d", + if($r[0]['xlink_updated'] >= $arr['edited']) { + logger('rating message duplicate'); + return; + } + + $x = q("update xlink set xlink_rating = %d, xlink_rating_text = '%s', xlink_sig = '%s', xlink_updated = '%s' where xlink_id = %d", intval($arr['rating']), - intval($arr['rating_text']), + dbesc($arr['rating_text']), + dbesc($arr['signature']), dbesc(datetime_convert()), intval($r[0]['xlink_id']) ); + logger('rating updated'); } else { - $x = q("insert into xlink ( xlink_xchan, xlink_link, xlink_rating, xlink_rating_text, xlink_updated, xlink_static ) + $x = q("insert into xlink ( xlink_xchan, xlink_link, xlink_rating, xlink_rating_text, xlink_sig, xlink_updated, xlink_static ) values( '%s', '%s', %d, '%s', '%s', 1 ) ", dbesc($sender['hash']), dbesc($arr['target']), intval($arr['rating']), - intval($arr['rating_text']), + dbesc($arr['rating_text']), + dbesc($arr['signature']), dbesc(datetime_convert()) ); + logger('rating created'); } return; } -- cgit v1.2.3 From 3f50313862f5c2ca9d7118b234b2f154c7fb736a Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Feb 2015 16:03:05 -0800 Subject: garbage in garbage out --- include/text.php | 4 ++-- include/zot.php | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index d19519779..ef2fc2371 100644 --- a/include/text.php +++ b/include/text.php @@ -1946,9 +1946,9 @@ function find_xchan_in_array($xchan,$arr) { } function get_rel_link($j,$rel) { - if(count($j)) + if(is_array($j) && ($j)) foreach($j as $l) - if($l['rel'] === $rel) + if(array_key_exists('rel',$j) && $l['rel'] === $rel && array_key_exists('href',$l)) return $l['href']; return ''; diff --git a/include/zot.php b/include/zot.php index 04b6806c2..7002fee0a 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1084,6 +1084,11 @@ function zot_import($arr, $sender_url) { if(is_array($incoming)) { foreach($incoming as $i) { + if(! is_array($i)) { + logger('incoming is not an array'); + continue; + } + $result = null; if(array_key_exists('iv',$i['notify'])) { -- cgit v1.2.3 From 17ffe122b309610208d769f0e2b41f53fcf9d254 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Feb 2015 18:10:55 -0800 Subject: ratings - mopping up, most everything but directory sync implemented --- include/js_strings.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/js_strings.php b/include/js_strings.php index f4c0a631d..14293c5ce 100644 --- a/include/js_strings.php +++ b/include/js_strings.php @@ -16,6 +16,9 @@ function js_strings() { '$permschange' => t('Notice: Permissions have changed but have not yet been submitted.'), '$closeAll' => t('close all'), '$nothingnew' => t('Nothing new here'), + '$rating_desc' => t('Rate This Channel (this is public)'), + '$rating_val' => t('Rating'), + '$rating_text' => t('Describe (optional)'), '$t01' => ((t('timeago.prefixAgo') != 'timeago.prefixAgo') ? t('timeago.prefixAgo') : ''), '$t02' => ((t('timeago.prefixFromNow') != 'timeago.prefixFromNow') ? t('timeago.prefixFromNow') : ''), -- cgit v1.2.3 From 86771547e6d04d046d3beeabb8e4486a59a7fcc6 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Feb 2015 18:35:54 -0800 Subject: finish off the sync functions --- include/dir_fns.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'include') diff --git a/include/dir_fns.php b/include/dir_fns.php index 6d06fddd1..8c0161ff1 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -216,6 +216,49 @@ function sync_directories($dirmode) { ); } } + if(count($j['ratings'])) { + foreach($j['ratings'] as $rr) { + $x = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1", + dbesc($rr['channel']), + dbesc($rr['target']) + ); + if($x && $x[0]['xlink_updated'] >= $rr['edited']) + continue; + $y = q("select xchan_pubkey from xchan where xchan_hash = '%s' limit 1", + dbesc($rr['channel']) + ); + if(! $y) { + logger('key unavailable on this site for ' . $rr['channel']); + continue; + } + if(! rsa_verify($rr['target'] . '.' . $rr['rating'] . '.' . $rr['rating_text'], base64url_decode($rr['signature']),$y[0]['xchan_pubkey'])) { + logger('failed to verify rating'); + continue; + } + + if($x) { + $z = q("update xlink set xlink_rating = %d, xlink_rating_text = '%s', xlink_sig = '%s', xlink_updated = '%s' where xlink_id = %d", + intval($rr['rating']), + dbesc($rr['rating_text']), + dbesc($rr['signature']), + dbesc(datetime_convert()), + intval($x[0]['xlink_id']) + ); + logger('rating updated'); + } + else { + $z = q("insert into xlink ( xlink_xchan, xlink_link, xlink_rating, xlink_rating_text, xlink_sig, xlink_updated, xlink_static ) values( '%s', '%s', %d, '%s', '%s', 1 ) ", + dbesc($rr['channel']), + dbesc($rr['target']), + intval($rr['rating']), + dbesc($rr['rating_text']), + dbesc($rr['signature']), + dbesc(datetime_convert()) + ); + logger('rating created'); + } + } + } } } -- cgit v1.2.3 From 4ead2cd79d3c7e5c29a11785a3ceefef6d3ba93f Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Feb 2015 21:19:29 -0800 Subject: final cleanup on ratings feature --- include/js_strings.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/js_strings.php b/include/js_strings.php index 14293c5ce..56ffa9536 100644 --- a/include/js_strings.php +++ b/include/js_strings.php @@ -19,6 +19,7 @@ function js_strings() { '$rating_desc' => t('Rate This Channel (this is public)'), '$rating_val' => t('Rating'), '$rating_text' => t('Describe (optional)'), + '$submit' => t('Submit'), '$t01' => ((t('timeago.prefixAgo') != 'timeago.prefixAgo') ? t('timeago.prefixAgo') : ''), '$t02' => ((t('timeago.prefixFromNow') != 'timeago.prefixFromNow') ? t('timeago.prefixFromNow') : ''), -- cgit v1.2.3 From 0cc29af6d0c305efa35fbe3b0c7bc314f21b4166 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Feb 2015 22:55:01 -0800 Subject: order ratings friends first --- include/conversation.php | 4 ---- 1 file changed, 4 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 9429af754..952d7d322 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -619,10 +619,6 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ $profile_link = zid($profile_link); $normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']); - if(x($a->contacts,$normalised)) - $profile_avatar = $a->contacts[$normalised]['thumb']; - else - $profile_avatar = ((strlen($item['author-avatar'])) ? $a->get_cached_avatar_image($item['author-avatar']) : $item['thumb']); $profile_name = $item['author']['xchan_name']; $profile_link = $item['author']['xchan_url']; -- cgit v1.2.3 From e5849f9432c76697c1db7758e5c1b31a788052a4 Mon Sep 17 00:00:00 2001 From: marijus Date: Wed, 4 Feb 2015 22:55:22 +0100 Subject: not quite there yet but getting closer a little --- include/attach.php | 88 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 28 deletions(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index 7ebc4489d..a300e34b0 100644 --- a/include/attach.php +++ b/include/attach.php @@ -966,6 +966,10 @@ function pipe_streams($in, $out) { function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $verb, $no_activity) { + require_once('include/items.php'); + + $poster = get_app()->get_observer(); + //if we got no object something went wrong if(!$object) return; @@ -975,6 +979,7 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, //do not send activity for folders for now if($is_dir) return; + /* //check for recursive perms if we are in a folder if($object['folder']) { @@ -983,22 +988,14 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $r_perms = check_recursive_perms($allow_cid, $allow_gid, $deny_cid, $deny_gid, $folder_hash); - $allow_cid = $r_perms['allow_cid']; - $allow_gid = $r_perms['allow_gid']; - $deny_cid = $r_perms['deny_cid']; - $deny_gid = $r_perms['deny_gid']; - - if(!$allow_gid && !$allow_cid) { - notice( t('Allowed permissions for this file are not recursive. None of your allowed contacts will have access to this file.') . EOL); - $verb = 'update'; - $update = true; - } + $allow_cid = perms2str($r_perms['allow_cid']); + $allow_gid = perms2str($r_perms['allow_gid']); + $deny_cid = perms2str($r_perms['deny_cid']); + $deny_gid = perms2str($r_perms['deny_gid']); } */ - require_once('include/items.php'); - $poster = get_app()->get_observer(); $mid = item_message_id(); @@ -1162,40 +1159,75 @@ function check_recursive_perms($allow_cid, $allow_gid, $deny_cid, $deny_gid, $fo $arr_deny_cid = expand_acl($deny_cid); $arr_deny_gid = expand_acl($deny_gid); + $count = 0; while($folder_hash) { - $x = q("SELECT allow_cid, allow_gid, deny_cid, deny_gid, folder FROM attach WHERE hash = '%s'", + $x = q("SELECT allow_cid, allow_gid, deny_cid, deny_gid, folder FROM attach WHERE hash = '%s' LIMIT 1", dbesc($folder_hash) ); - $parents_arr_allow_cid[] = expand_acl($x[0]['allow_cid']); - $parents_arr_allow_gid[] = expand_acl($x[0]['allow_gid']); - $parents_arr_deny_cid[] = expand_acl($x[0]['deny_cid']); - $parents_arr_deny_gid[] = expand_acl($x[0]['deny_gid']); + //only process private folders + if($x[0]['allow_cid'] || $x[0]['allow_gid'] || $x[0]['deny_cid'] || $x[0]['deny_gid']) { + + $parent_arr['allow_cid'][] = expand_acl($x[0]['allow_cid']); + $parent_arr['allow_gid'][] = expand_acl($x[0]['allow_gid']); + $parent_arr['deny_cid'][] = expand_acl($x[0]['deny_cid']); + $parent_arr['deny_gid'][] = expand_acl($x[0]['deny_gid']); + + $parents_arr = $parent_arr; + + $count++; + + } $folder_hash = $x[0]['folder']; + } - foreach($parents_arr_allow_gid as $folder_arr_allow_gid) { - $arr_allow_gid = array_intersect($arr_allow_gid, $folder_arr_allow_gid); + //if there are no perms on the file we get them from the first parent folder + if(!$arr_allow_cid && !$arr_allow_gid && !$arr_deny_cid && !$arr_deny_gid) { + $arr_allow_cid = $parent_arr['allow_cid'][0]; + $arr_allow_gid = $parent_arr['allow_gid'][0]; + $arr_deny_cid = $parent_arr['deny_cid'][0]; + $arr_deny_gid = $parent_arr['deny_gid'][0]; } - foreach($parents_arr_allow_cid as $folder_arr_allow_cid) { - $arr_allow_cid = array_intersect($arr_allow_cid, $folder_arr_allow_cid); + //allow_cid + foreach ($parents_arr['allow_cid'] as $folder_arr_allow_cid) { + foreach ($folder_arr_allow_cid as $ac_hash) { + $count_values[$ac_hash]++; + } + } + foreach ($arr_allow_cid as $fac_hash) { + if(($count_values[$fac_hash]) && ($count_values[$fac_hash] == $count)) + $r_arr_allow_cid[] = $fac_hash; } - foreach($parents_arr_deny_gid as $folder_arr_deny_gid) { + + //allow_gid + foreach ($parents_arr['allow_gid'] as $folder_arr_allow_gid) { + foreach ($folder_arr_allow_gid as $ag_hash) { + $count_values[$ag_hash]++; + } + } + foreach ($arr_allow_gid as $fag_hash) { + if(($count_values[$fag_hash]) && ($count_values[$fag_hash] == $count)) + $r_arr_allow_gid[] = $fag_hash; + } + + //deny_gid + foreach($parents_arr['deny_gid'] as $folder_arr_deny_gid) { $arr_deny_gid = array_merge($arr_deny_gid, $folder_arr_deny_gid); } - foreach($parents_arr_deny_cid as $folder_arr_deny_cid) { + //deny_cid + foreach($parents_arr['deny_cid'] as $folder_arr_deny_cid) { $arr_deny_cid = array_merge($arr_deny_cid, $folder_arr_deny_cid); } - $ret['allow_gid'] = perms2str($arr_allow_gid); - $ret['allow_cid'] = perms2str($arr_allow_cid); - $ret['deny_gid'] = perms2str(array_unique($arr_deny_gid)); - $ret['deny_cid'] = perms2str(array_unique($arr_deny_cid)); + $ret['allow_gid'] = $r_arr_allow_gid; + $ret['allow_cid'] = $r_arr_allow_cid; + $ret['deny_gid'] = array_unique($r_arr_deny_gid); + $ret['deny_cid'] = array_unique($r_arr_deny_cid); return $ret; - } -- cgit v1.2.3 From 398894851628ccb99090e9d70b92a9a909ef7015 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Feb 2015 15:48:39 -0800 Subject: first cut at rating widget. The flaw is that it is limited because it requires local_channel() (formerly local_user()). We need to extend this to take you home like rpost does if you're logged in as remote_channel() - and/or we need zot to send the rating message to the source channel and target in addition to the directories. --- include/identity.php | 6 ++++++ include/widgets.php | 27 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) (limited to 'include') diff --git a/include/identity.php b/include/identity.php index 2fc183368..aef6471e5 100644 --- a/include/identity.php +++ b/include/identity.php @@ -943,6 +943,11 @@ logger('online: ' . $profile['online']); $tpl = get_markup_template('profile_vcard.tpl'); +// This isn't ideal here because it requires local_channel(). +// We need the rating widget to recognise and take you home if you're remote. +// require_once('include/widgets.php'); +// $z = widget_rating(array('target' => $profile['channel_hash'])); + $o .= replace_macros($tpl, array( '$profile' => $profile, '$connect' => $connect, @@ -954,6 +959,7 @@ logger('online: ' . $profile['online']); '$homepage' => $homepage, '$chanmenu' => $channel_menu, '$diaspora' => $diaspora, + '$rating' => $z, '$contact_block' => $contact_block, )); diff --git a/include/widgets.php b/include/widgets.php index 523318850..71407ad3d 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -903,3 +903,30 @@ function widget_random_block($arr) { return $o; } + + +function widget_rating($arr) { + $a = get_app(); + if(! local_channel()) + return; + + $channel = $a->get_channel(); + + if($arr['target']) + $hash = $arr['target']; + else + $hash = $a->poi['xchan_hash']; + + if(! $hash) + return; + + if($hash == $channel['channel_hash']) + return; + + head_add_js('ratings.js'); + + $o = '
'; + $o .= '
'; + return $o; + +} \ No newline at end of file -- cgit v1.2.3 From 561bab4ece9fa5844a0cb00f3cbd75e0855b2796 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Feb 2015 17:32:29 -0800 Subject: remote rating and addition of rate-me to channel profile sidebar --- include/identity.php | 6 ++---- include/widgets.php | 38 ++++++++++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/identity.php b/include/identity.php index aef6471e5..415e85f2f 100644 --- a/include/identity.php +++ b/include/identity.php @@ -943,10 +943,8 @@ logger('online: ' . $profile['online']); $tpl = get_markup_template('profile_vcard.tpl'); -// This isn't ideal here because it requires local_channel(). -// We need the rating widget to recognise and take you home if you're remote. -// require_once('include/widgets.php'); -// $z = widget_rating(array('target' => $profile['channel_hash'])); + require_once('include/widgets.php'); + $z = widget_rating(array('target' => $profile['channel_hash'])); $o .= replace_macros($tpl, array( '$profile' => $profile, diff --git a/include/widgets.php b/include/widgets.php index 71407ad3d..7d2aaeb99 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -907,10 +907,6 @@ function widget_random_block($arr) { function widget_rating($arr) { $a = get_app(); - if(! local_channel()) - return; - - $channel = $a->get_channel(); if($arr['target']) $hash = $arr['target']; @@ -920,13 +916,39 @@ function widget_rating($arr) { if(! $hash) return; - if($hash == $channel['channel_hash']) - return; + $url = ''; + $remote = false; + + if(remote_channel() && ! local_channel()) { + $ob = $a->get_observer(); + if($ob && $ob['xchan_url']) { + $p = parse_url($ob['xchan_url']); + if($p) { + $url = $p['scheme'] . '://' . $p['host'] . (($p['port']) ? ':' . $p['port'] : ''); + $url .= '/rate?f=&target=' . urlencode($hash); + } + $remote = true; + } + } - head_add_js('ratings.js'); + if(local_channel()) { + $channel = $a->get_channel(); + + if($hash == $channel['channel_hash']) + return; + + head_add_js('ratings.js'); + + } + + if((! $remote) && (! local_channel())) + return; $o = '
'; - $o .= '
'; + if($remote) + $o .= ' ' . t('Rate Me') . ''; + else + $o .= ''; return $o; } \ No newline at end of file -- cgit v1.2.3 From 24b198a50c54736ad137a342c30814033b27eff7 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Feb 2015 17:34:53 -0800 Subject: honour the rating enable setting (which we really do need to rename since it isn't poco any more) --- include/widgets.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/widgets.php b/include/widgets.php index 7d2aaeb99..5eda9008b 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -908,6 +908,11 @@ function widget_random_block($arr) { function widget_rating($arr) { $a = get_app(); + $poco_rating = get_config('system','poco_rating_enable'); + if((! $poco_rating) && ($poco_rating !== false)) { + return; + } + if($arr['target']) $hash = $arr['target']; else -- cgit v1.2.3 From 6e84dbe493a660b391c519c331aaa79878adf933 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Feb 2015 18:18:04 -0800 Subject: add 'view ratings' to the widget. It's actually two stacked widgets rather than a widget with two entries. That's the only way we can keep the theming consistent with the rconnect button. --- include/widgets.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/widgets.php b/include/widgets.php index 5eda9008b..a94bf03dc 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -951,9 +951,13 @@ function widget_rating($arr) { $o = '
'; if($remote) - $o .= ' ' . t('Rate Me') . '
'; + $o .= ' ' . t('Rate Me') . ''; else - $o .= ''; + $o .= ''; + + $o .= ''; + return $o; } \ No newline at end of file -- cgit v1.2.3 From 24355430a8ca8420aa0c1d42e9c38932d1cd54f7 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Feb 2015 18:26:59 -0800 Subject: allow anybody to view ratings - including oneself. Only allow authenticated folks to edit them. --- include/widgets.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/widgets.php b/include/widgets.php index a94bf03dc..e995b213f 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -946,16 +946,16 @@ function widget_rating($arr) { } - if((! $remote) && (! local_channel())) - return; - - $o = '
'; - if($remote) - $o .= ' ' . t('Rate Me') . ''; - else - $o .= ''; + if(($remote) || (local_channel())) { + $o = '
'; + if($remote) + $o .= ' ' . t('Rate Me') . ''; + else + $o .= ''; + $o .= '
'; + } - $o .= '
' . t('View Ratings') . ''; + $o .= ''; return $o; -- cgit v1.2.3 From 5a0ccbfcf375acad49a0f7e818fe5611c2f858cc Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Feb 2015 18:31:12 -0800 Subject: forgot to add the self exclusion --- include/widgets.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/widgets.php b/include/widgets.php index e995b213f..d457db07d 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -936,17 +936,19 @@ function widget_rating($arr) { } } + $self = false; + if(local_channel()) { $channel = $a->get_channel(); if($hash == $channel['channel_hash']) - return; + $self = true; head_add_js('ratings.js'); } - if(($remote) || (local_channel())) { + if((($remote) || (local_channel())) && (! $self)) { $o = '
'; if($remote) $o .= ' ' . t('Rate Me') . ''; -- cgit v1.2.3 From 646a874390be8f92736866118d7215e8cb80fb8a Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Feb 2015 20:28:36 -0800 Subject: diaspora public posts not delivering to sys channel if there were no other subscribers --- include/diaspora.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/diaspora.php b/include/diaspora.php index ada90e476..8047d0e64 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -35,11 +35,16 @@ function diaspora_dispatch_public($msg) { logger('diaspora_public: delivering to: ' . $rr['channel_name'] . ' (' . $rr['channel_address'] . ') '); diaspora_dispatch($rr,$msg); } - if($sys) - diaspora_dispatch($sys,$msg); } - else - logger('diaspora_public: no subscribers'); + else { + if(! $sys) + logger('diaspora_public: no subscribers'); + } + + if($sys) { + logger('diaspora_public: delivering to sys.'); + diaspora_dispatch($sys,$msg); + } } -- cgit v1.2.3 From 88488fdfbb58aa04b450af1691aba7cea1bce8ab Mon Sep 17 00:00:00 2001 From: Habeas Codice Date: Thu, 5 Feb 2015 09:15:26 -0800 Subject: escape dates --- include/zot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 04b6806c2..5faabd5ec 100644 --- a/include/zot.php +++ b/include/zot.php @@ -420,7 +420,7 @@ function zot_refresh($them,$channel = null, $force = false) { where abook_xchan = '%s' and abook_channel = %d and not (abook_flags & %d) > 0 ", intval($their_perms), - dbesc($next_birthday), + dbescdate($next_birthday), dbesc($x['hash']), intval($channel['channel_id']), intval(ABOOK_FLAG_SELF) -- cgit v1.2.3 From be0e6ed6d7467991b51f40266ad9a149cdcda247 Mon Sep 17 00:00:00 2001 From: marijus Date: Thu, 5 Feb 2015 21:16:21 +0100 Subject: make file activity respect parent dir permissions work --- include/attach.php | 88 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 66 insertions(+), 22 deletions(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index a300e34b0..38fe3173b 100644 --- a/include/attach.php +++ b/include/attach.php @@ -980,13 +980,14 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, if($is_dir) return; -/* //check for recursive perms if we are in a folder if($object['folder']) { $folder_hash = $object['folder']; - $r_perms = check_recursive_perms($allow_cid, $allow_gid, $deny_cid, $deny_gid, $folder_hash); + $r_perms = recursive_activity_recipients($allow_cid, $allow_gid, $deny_cid, $deny_gid, $folder_hash); + + print_r($r_perms); killme(); $allow_cid = perms2str($r_perms['allow_cid']); $allow_gid = perms2str($r_perms['allow_gid']); @@ -994,8 +995,6 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $deny_gid = perms2str($r_perms['deny_gid']); } -*/ - $mid = item_message_id(); @@ -1147,12 +1146,13 @@ function get_file_activity_object($channel_id, $hash, $cloudpath) { 'created' => $x[0]['created'], 'edited' => $x[0]['edited'] ); - return $object; } -function check_recursive_perms($allow_cid, $allow_gid, $deny_cid, $deny_gid, $folder_hash) { +function recursive_activity_recipients($allow_cid, $allow_gid, $deny_cid, $deny_gid, $folder_hash) { + + $poster = get_app()->get_observer(); $arr_allow_cid = expand_acl($allow_cid); $arr_allow_gid = expand_acl($allow_gid); @@ -1170,11 +1170,19 @@ function check_recursive_perms($allow_cid, $allow_gid, $deny_cid, $deny_gid, $fo $parent_arr['allow_cid'][] = expand_acl($x[0]['allow_cid']); $parent_arr['allow_gid'][] = expand_acl($x[0]['allow_gid']); + + //TODO: should find a much better solution for the allow_cid <-> allow_gid problem. + //Do not use allow_gid for now. Instead lookup the members of the group directly and add them to allow_cid. + if($parent_arr['allow_gid']) { + foreach($parent_arr['allow_gid'][$count] as $gid) { + $in_group = in_group($gid); + $parent_arr['allow_cid'][$count] = array_unique(array_merge($parent_arr['allow_cid'][$count], $in_group)); + } + } + $parent_arr['deny_cid'][] = expand_acl($x[0]['deny_cid']); $parent_arr['deny_gid'][] = expand_acl($x[0]['deny_gid']); - $parents_arr = $parent_arr; - $count++; } @@ -1183,6 +1191,16 @@ function check_recursive_perms($allow_cid, $allow_gid, $deny_cid, $deny_gid, $fo } + //if none of the parent folders is private just return file perms + if(!$parent_arr['allow_cid'] && !$parent_arr['allow_gid'] && !$parent_arr['deny_cid'] && !$parent_arr['deny_gid']) { + $ret['allow_gid'] = $arr_allow_gid; + $ret['allow_cid'] = $arr_allow_cid; + $ret['deny_gid'] = $arr_deny_gid; + $ret['deny_cid'] = $arr_deny_cid; + + return $ret; + } + //if there are no perms on the file we get them from the first parent folder if(!$arr_allow_cid && !$arr_allow_gid && !$arr_deny_cid && !$arr_deny_gid) { $arr_allow_cid = $parent_arr['allow_cid'][0]; @@ -1192,42 +1210,68 @@ function check_recursive_perms($allow_cid, $allow_gid, $deny_cid, $deny_gid, $fo } //allow_cid - foreach ($parents_arr['allow_cid'] as $folder_arr_allow_cid) { + $r_arr_allow_cid = false; + foreach ($parent_arr['allow_cid'] as $folder_arr_allow_cid) { foreach ($folder_arr_allow_cid as $ac_hash) { $count_values[$ac_hash]++; } } foreach ($arr_allow_cid as $fac_hash) { - if(($count_values[$fac_hash]) && ($count_values[$fac_hash] == $count)) + if($count_values[$fac_hash] == $count) $r_arr_allow_cid[] = $fac_hash; } - //allow_gid - foreach ($parents_arr['allow_gid'] as $folder_arr_allow_gid) { + $r_arr_allow_gid = false; + foreach ($parent_arr['allow_gid'] as $folder_arr_allow_gid) { foreach ($folder_arr_allow_gid as $ag_hash) { $count_values[$ag_hash]++; } } foreach ($arr_allow_gid as $fag_hash) { - if(($count_values[$fag_hash]) && ($count_values[$fag_hash] == $count)) + if($count_values[$fag_hash] == $count) $r_arr_allow_gid[] = $fag_hash; } //deny_gid - foreach($parents_arr['deny_gid'] as $folder_arr_deny_gid) { - $arr_deny_gid = array_merge($arr_deny_gid, $folder_arr_deny_gid); + foreach($parent_arr['deny_gid'] as $folder_arr_deny_gid) { + $r_arr_deny_gid = array_merge($arr_deny_gid, $folder_arr_deny_gid); } + $r_arr_deny_gid = array_unique($r_arr_deny_gid); //deny_cid - foreach($parents_arr['deny_cid'] as $folder_arr_deny_cid) { - $arr_deny_cid = array_merge($arr_deny_cid, $folder_arr_deny_cid); + foreach($parent_arr['deny_cid'] as $folder_arr_deny_cid) { + $r_arr_deny_cid = array_merge($arr_deny_cid, $folder_arr_deny_cid); + } + $r_arr_deny_cid = array_unique($r_arr_deny_cid); + + //if none is allowed restrict to self + if(($r_arr_allow_gid === false) && ($r_arr_allow_gid === false)) { + $ret['allow_cid'] = $poster['xchan_hash']; + } else { + $ret['allow_gid'] = $r_arr_allow_gid; + $ret['allow_cid'] = $r_arr_allow_cid; + $ret['deny_gid'] = $r_arr_deny_gid; + $ret['deny_cid'] = $r_arr_deny_cid; } - - $ret['allow_gid'] = $r_arr_allow_gid; - $ret['allow_cid'] = $r_arr_allow_cid; - $ret['deny_gid'] = array_unique($r_arr_deny_gid); - $ret['deny_cid'] = array_unique($r_arr_deny_cid); return $ret; + +} + +function in_group($group_id) { + //TODO: make these two queries one with a join. + $x = q("SELECT id FROM groups WHERE hash = '%s'", + dbesc($group_id) + ); + + $r = q("SELECT xchan FROM group_member WHERE gid = %d", + intval($x[0]['id']) + ); + + foreach($r as $ig) { + $group_members[] = $ig['xchan']; + } + + return $group_members; } -- cgit v1.2.3 From 1d5321798af534368a6f902a109f8efd3c53bd6b Mon Sep 17 00:00:00 2001 From: marijus Date: Thu, 5 Feb 2015 21:31:05 +0100 Subject: forgot to remove some debug stuff --- include/attach.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index 38fe3173b..1b89480b3 100644 --- a/include/attach.php +++ b/include/attach.php @@ -987,8 +987,6 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $r_perms = recursive_activity_recipients($allow_cid, $allow_gid, $deny_cid, $deny_gid, $folder_hash); - print_r($r_perms); killme(); - $allow_cid = perms2str($r_perms['allow_cid']); $allow_gid = perms2str($r_perms['allow_gid']); $deny_cid = perms2str($r_perms['deny_cid']); -- cgit v1.2.3 From 1abb17c88050264168b6e6ff493e73ecd12706c1 Mon Sep 17 00:00:00 2001 From: marijus Date: Thu, 5 Feb 2015 21:46:46 +0100 Subject: typo --- include/attach.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index 1b89480b3..f61fea9a5 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1244,7 +1244,7 @@ function recursive_activity_recipients($allow_cid, $allow_gid, $deny_cid, $deny_ $r_arr_deny_cid = array_unique($r_arr_deny_cid); //if none is allowed restrict to self - if(($r_arr_allow_gid === false) && ($r_arr_allow_gid === false)) { + if(($r_arr_allow_gid === false) && ($r_arr_allow_cid === false)) { $ret['allow_cid'] = $poster['xchan_hash']; } else { $ret['allow_gid'] = $r_arr_allow_gid; -- cgit v1.2.3 From 331c72b3be4e6b2c469d14be2bd4d057e7de1dec Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 5 Feb 2015 14:46:08 -0800 Subject: author profile photo in reshare wasn't linked --- include/bbcode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index 7067fcd39..8f2b5bd38 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -216,7 +216,7 @@ function bb_ShareAttributes($match) { $headline = '
'; if ($avatar != "") - $headline .= '' . $author . ''; + $headline .= '' . $author . ''; // Bob Smith wrote the following post 2 hours ago -- cgit v1.2.3 From 153719a20a88b8d4e9c562b185f94e1af72de1de Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 5 Feb 2015 16:13:26 -0800 Subject: another issue with diaspora postings to sys channel - sys has no connections, hence no abook records. --- include/diaspora.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/diaspora.php b/include/diaspora.php index 8047d0e64..0e275a079 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -272,8 +272,6 @@ function diaspora_process_outbound($arr) { } - - function diaspora_handle_from_contact($contact_hash) { logger("diaspora_handle_from_contact: contact id is " . $contact_hash, LOGGER_DEBUG); @@ -291,11 +289,21 @@ function diaspora_get_contact_by_handle($uid,$handle) { if(diaspora_is_blacklisted($handle)) return false; + require_once('include/identity.php'); + + $sys = get_sys_channel(); + if(($sys) && ($sys['channel_id'] == $uid)) { + $r = q("SELECT * FROM xchan where xchan_addr = '%s' limit 1", + dbesc($handle) + ); + } + else { + $r = q("SELECT * FROM abook left join xchan on xchan_hash = abook_xchan where xchan_addr = '%s' and abook_channel = %d limit 1", + dbesc($handle), + intval($uid) + ); + } - $r = q("SELECT * FROM abook left join xchan on xchan_hash = abook_xchan where xchan_addr = '%s' and abook_channel = %d limit 1", - dbesc($handle), - intval($uid) - ); return (($r) ? $r[0] : false); } -- cgit v1.2.3 From fe8a08a47482dabe1a406ca41a02dc058f25f92a Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 5 Feb 2015 17:29:35 -0800 Subject: over-ride permissions for sys channel delivery from diaspora --- include/diaspora.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/diaspora.php b/include/diaspora.php index 0e275a079..736be4f08 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -42,6 +42,7 @@ function diaspora_dispatch_public($msg) { } if($sys) { + $sys['system'] = true; logger('diaspora_public: delivering to sys.'); diaspora_dispatch($sys,$msg); } @@ -49,10 +50,13 @@ function diaspora_dispatch_public($msg) { -function diaspora_dispatch($importer,$msg,$attempt=1) { +function diaspora_dispatch($importer,$msg) { $ret = 0; + if(! array_key_exists('system',$importer)) + $importer['system'] = false; + $enabled = intval(get_config('system','diaspora_enabled')); if(! $enabled) { logger('mod-diaspora: disabled'); @@ -105,7 +109,7 @@ function diaspora_dispatch($importer,$msg,$attempt=1) { $ret = diaspora_signed_retraction($importer,$xmlbase->relayable_retraction,$msg); } elseif($xmlbase->photo) { - $ret = diaspora_photo($importer,$xmlbase->photo,$msg,$attempt); + $ret = diaspora_photo($importer,$xmlbase->photo,$msg); } elseif($xmlbase->conversation) { $ret = diaspora_conversation($importer,$xmlbase->conversation,$msg); @@ -796,7 +800,7 @@ function diaspora_post($importer,$xml,$msg) { } - if(! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'send_stream')) { + if((! $importer['system']) && (! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'send_stream'))) { logger('diaspora_post: Ignoring this author.'); return 202; } @@ -983,7 +987,7 @@ function diaspora_reshare($importer,$xml,$msg) { if(! $contact) return; - if(! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'send_stream')) { + if((! $importer['system']) && (! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'send_stream'))) { logger('diaspora_reshare: Ignoring this author: ' . $diaspora_handle . ' ' . print_r($xml,true)); return 202; } @@ -1150,7 +1154,7 @@ function diaspora_asphoto($importer,$xml,$msg) { if(! $contact) return; - if(! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'send_stream')) { + if((! $importer['system']) && (! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'send_stream'))) { logger('diaspora_asphoto: Ignoring this author.'); return 202; } @@ -1255,7 +1259,7 @@ function diaspora_comment($importer,$xml,$msg) { return; } - if(! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'post_comments')) { + if((! $importer['system']) && (! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'post_comments'))) { logger('diaspora_comment: Ignoring this author.'); return 202; } @@ -1732,7 +1736,7 @@ function diaspora_message($importer,$xml,$msg) { } -function diaspora_photo($importer,$xml,$msg,$attempt=1) { +function diaspora_photo($importer,$xml,$msg) { $a = get_app(); @@ -1760,7 +1764,7 @@ function diaspora_photo($importer,$xml,$msg,$attempt=1) { return; } - if(! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'send_stream')) { + if((! $importer['system']) && (! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'send_stream'))) { logger('diaspora_photo: Ignoring this author.'); return 202; } @@ -1819,7 +1823,7 @@ function diaspora_like($importer,$xml,$msg) { } - if(! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'post_comments')) { + if((! $importer['system']) && (! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'post_comments'))) { logger('diaspora_like: Ignoring this author.'); return 202; } -- cgit v1.2.3 From b948fbaeda84f4358722222b4a2d5555ef10b82e Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 5 Feb 2015 19:09:42 -0800 Subject: allow post expiration to be set from a config (and therefore a plugin/addon) --- include/conversation.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 952d7d322..27b52ba6e 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1134,6 +1134,9 @@ function status_editor($a,$x,$popup=false) { if(x($x,'nopreview')) $preview = ''; + $defexpire = ((($z = get_pconfig($x['profile_uid'],'system','default_post_expire')) && (! $webpage)) ? $z : ''); + + $cipher = get_pconfig($x['profile_uid'],'system','default_cipher'); if(! $cipher) $cipher = 'aes256'; @@ -1191,7 +1194,7 @@ function status_editor($a,$x,$popup=false) { '$preview' => $preview, '$source' => ((x($x,'source')) ? $x['source'] : ''), '$jotplugins' => $jotplugins, - '$defexpire' => '', + '$defexpire' => $defexpire, '$feature_expire' => ((feature_enabled($x['profile_uid'],'content_expire') && (! $webpage)) ? true : false), '$expires' => t('Set expiration date'), '$feature_encrypt' => ((feature_enabled($x['profile_uid'],'content_encrypt') && (! $webpage)) ? true : false), -- cgit v1.2.3