From f455036905d83a7983998835b24bfcaf1bed1045 Mon Sep 17 00:00:00 2001 From: marijus Date: Wed, 28 Jan 2015 09:49:36 +0100 Subject: show shared button only to local user --- include/RedDAV/RedBrowser.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/RedDAV/RedBrowser.php b/include/RedDAV/RedBrowser.php index e893d6ebd..8093aebc9 100644 --- a/include/RedDAV/RedBrowser.php +++ b/include/RedDAV/RedBrowser.php @@ -252,7 +252,8 @@ class RedBrowser extends DAV\Browser\Plugin { '$actionspanel' => $output, '$shared' => t('Shared'), '$create' => t('Create'), - 'upload' => t('Upload') + '$upload' => t('Upload'), + '$is_owner' => $is_owner )); $html .= replace_macros(get_markup_template('cloud_directory.tpl'), array( -- cgit v1.2.3 From 9feb300f47eaff46ea78ef66379de654d3365dae Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 28 Jan 2015 01:06:56 -0800 Subject: more minor tweaks to the route mismatch algorithm after watching it all day. --- include/zot.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 43a7ad6ba..f12d1a8a8 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1524,7 +1524,7 @@ function process_delivery($sender,$arr,$deliveries,$relay,$public = false,$reque // sent it to us originally. Ignore it if it came from another source // (with potentially different permissions). // only compare the last hop since it could have arrived at the last location any number of ways. - // Always accept empty routes. + // Always accept empty routes and firehose items (route contains 'undefined') . $existing_route = explode(',', $r[0]['route']); $routes = count($existing_route); @@ -1536,10 +1536,13 @@ function process_delivery($sender,$arr,$deliveries,$relay,$public = false,$reque $last_hop = ''; $last_prior_route = ''; } + + if($last_hop == 'undefined' || $sender['hash'] == 'undefined') + $last_hop = ''; $current_route = (($arr['route']) ? $arr['route'] . ',' : '') . $sender['hash']; - if($last_hop && $last_hop != $sender['hash'] && $sender['hash'] != 'undefined') { + if($last_hop && $last_hop != $sender['hash']) { logger('comment route mismatch: parent route = ' . $r[0]['route'] . ' expected = ' . $current_route, LOGGER_DEBUG); logger('comment route mismatch: parent msg = ' . $r[0]['id'],LOGGER_DEBUG); $result[] = array($d['hash'],'comment route mismatch',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']); -- cgit v1.2.3 From 6c7269be94c7524cce4d5d14f0b330f36ed6d9a4 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 28 Jan 2015 01:13:32 -0800 Subject: add yet another firehose check --- 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 f12d1a8a8..33ac16abf 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1537,7 +1537,7 @@ function process_delivery($sender,$arr,$deliveries,$relay,$public = false,$reque $last_prior_route = ''; } - if($last_hop == 'undefined' || $sender['hash'] == 'undefined') + if(in_array('undefined',$existing_route) || $last_hop == 'undefined' || $sender['hash'] == 'undefined') $last_hop = ''; $current_route = (($arr['route']) ? $arr['route'] . ',' : '') . $sender['hash']; -- cgit v1.2.3 From db1998e0c8f3050c4d93c26a5af69773a55c17d2 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 28 Jan 2015 14:22:52 -0800 Subject: limit the number of forums that can be tagged in a single post - default is 2. The reason is simple - count how many posts would be in transit simultaneously if this was unlimited and somebody tagged 40-50 forums. In practice when used legitimately - we've rarely seen more than two, in fact I don't recall seeing more than two ever. Typically it is one and occasionally two. Changing the default is tricky - a client system cannot do it, but the site hosting a forum can choose to. Since not all sites that host forums will choose to do so, the ordering of the mentions would then be important. --- include/items.php | 54 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 70802404a..756625d85 100755 --- a/include/items.php +++ b/include/items.php @@ -2852,12 +2852,27 @@ function tag_deliver($uid,$item_id) { if(preg_match($pattern,$body,$matches)) $tagged = true; - $pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($term['term'] . '+','/') . '\[\/zrl\]/'; - if(preg_match($pattern,$body,$matches)) - $plustagged = true; + $pattern = '/@\!?\[zrl\=(.*?)\](.*?)\+\[\/zrl\]/'; + + if(preg_match_all($pattern,$body,$matches,PREG_SET_ORDER)) { + $max_forums = get_config('system','max_tagged_forums'); + if(! $max_forums) + $max_forums = 2; + $matched_forums = 0; + foreach($matches as $match) { + $matched_forums ++; + if($term['url'] === $match[1] && $term['term'] === $match[2]) { + if($matched_forums <= $max_forums) { + $plustagged = true; + break; + } + logger('forum ' . $term['term'] . ' exceeded max_tagged_forums - ignoring'); + } + } + } if(! ($tagged || $plustagged)) { - logger('tag_deliver: mention was in a reshare - ignoring'); + logger('tag_deliver: mention was in a reshare or exceeded max_tagged_forums - ignoring'); return; } @@ -2974,6 +2989,7 @@ function tgroup_check($uid,$item) { } } + if($mention) { logger('tgroup_check: mention found for ' . $u[0]['channel_name']); } @@ -2982,6 +2998,7 @@ function tgroup_check($uid,$item) { // 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 + // note: $term has been set to the matching term $body = $item['body']; @@ -2993,14 +3010,35 @@ function tgroup_check($uid,$item) { $body = preg_replace('/\[share(.*?)\[\/share\]/','',$body); - $pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($term['term'] . '+','/') . '\[\/zrl\]/'; + +// $pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($term['term'] . '+','/') . '\[\/zrl\]/'; + + $pattern = '/@\!?\[zrl\=(.*?)\](.*?)\+\[\/zrl\]/'; + + $found = false; + + if(preg_match_all($pattern,$body,$matches,PREG_SET_ORDER)) { + $max_forums = get_config('system','max_tagged_forums'); + if(! $max_forums) + $max_forums = 2; + $matched_forums = 0; + foreach($matches as $match) { + $matched_forums ++; + if($term['url'] === $match[1] && $term['term'] === $match[2]) { + if($matched_forums <= $max_forums) { + $found = true; + break; + } + logger('forum ' . $term['term'] . ' exceeded max_tagged_forums - ignoring'); + } + } + } - if(! preg_match($pattern,$body,$matches)) { - logger('tgroup_check: mention was in a reshare - ignoring'); + if(! $found) { + logger('tgroup_check: mention was in a reshare or exceeded max_tagged_forums - ignoring'); return false; } - return true; } -- cgit v1.2.3 From 2c02f1184cc576eaced4b72ae7ec6fd54c347ea7 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 28 Jan 2015 15:23:00 -0800 Subject: allow diaspora posts to be delivered to the discover channel unless prohibited from doing so. --- include/diaspora.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/diaspora.php b/include/diaspora.php index e494aac0f..655f5750a 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -15,8 +15,10 @@ function diaspora_dispatch_public($msg) { return; } - // find everybody following or allowing this author + $sys_disabled = get_config('system','disable_diaspora_discover_tab'); + $sys = (($sys_disabled) ? null : get_sys_channel()); + // find everybody following or allowing this author $r = q("SELECT * from channel where channel_id in ( SELECT abook_channel from abook left join xchan on abook_xchan = xchan_hash WHERE xchan_network like '%%diaspora%%' and xchan_addr = '%s' )", dbesc($msg['author']) @@ -29,6 +31,8 @@ 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'); -- cgit v1.2.3 From 54fd8b21db2d8f3841cf590f88611a1d4f44ce48 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 28 Jan 2015 15:27:58 -0800 Subject: make sure we honour the disable_discover_tab pref --- include/diaspora.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/diaspora.php b/include/diaspora.php index 655f5750a..767758164 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -15,7 +15,11 @@ function diaspora_dispatch_public($msg) { return; } - $sys_disabled = get_config('system','disable_diaspora_discover_tab'); + $sys_disabled = true; + + if(! get_config('system','disable_discover_tab')) { + $sys_disabled = get_config('system','disable_diaspora_discover_tab'); + } $sys = (($sys_disabled) ? null : get_sys_channel()); // find everybody following or allowing this author -- cgit v1.2.3 From 435509f6092e55c7f1d96be23519f67c4db511ad Mon Sep 17 00:00:00 2001 From: Habeas Codice Date: Wed, 28 Jan 2015 17:36:24 -0800 Subject: fix improper group by usage --- include/chat.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/chat.php b/include/chat.php index 533c03dde..b19d495bb 100644 --- a/include/chat.php +++ b/include/chat.php @@ -185,7 +185,7 @@ function chatroom_list($uid) { require_once('include/security.php'); $sql_extra = permissions_sql($uid); - $r = q("select cr_name, cr_id, count(cp_id) as cr_inroom from chatroom left join chatpresence on cr_id = cp_room where cr_uid = %d $sql_extra group by cr_name order by cr_name", + $r = q("select cr_name, cr_id, count(cp_id) as cr_inroom from chatroom left join chatpresence on cr_id = cp_room where cr_uid = %d $sql_extra group by cr_name, cr_id order by cr_name", intval($uid) ); -- cgit v1.2.3 From 1a537888333afb052e9eb4954091fd163f5b78d1 Mon Sep 17 00:00:00 2001 From: Habeas Codice Date: Wed, 28 Jan 2015 17:37:34 -0800 Subject: bookmarkedchats: remove extraneous group by, dupes removed on insert suggestedchats: normalize to standard SQL --- include/widgets.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/widgets.php b/include/widgets.php index 9f9268055..3533e2cea 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -642,7 +642,7 @@ function widget_bookmarkedchats($arr) { $h = get_observer_hash(); if(! $h) return; - $r = q("select * from xchat where xchat_xchan = '%s' group by xchat_url order by xchat_desc", + $r = q("select xchat_url, xchat_desc from xchat where xchat_xchan = '%s' order by xchat_desc", dbesc($h) ); if($r) { @@ -664,7 +664,7 @@ function widget_suggestedchats($arr) { $h = get_observer_hash(); if(! $h) return; - $r = q("select *, count(xchat_url) as total from xchat group by xchat_url order by total desc, xchat_desc limit 24"); + $r = q("select xchat_url, xchat_desc, count(xchat_xchan) as total from xchat group by xchat_url, xchat_desc order by total desc, xchat_desc limit 24"); if($r) { for($x = 0; $x < count($r); $x ++) { $r[$x]['xchat_url'] = zid($r[$x]['xchat_url']); -- cgit v1.2.3 From a4960360669daa0a0c842427185ce1ada3b4ab97 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 28 Jan 2015 20:56:04 -0800 Subject: local_user => local_channel --- include/Contact.php | 6 ++--- include/ConversationObject.php | 4 ++-- include/ItemObject.php | 20 ++++++++-------- include/RedDAV/RedBrowser.php | 2 +- include/account.php | 4 ++-- include/acl_selectors.php | 6 ++--- include/activities.php | 6 ++--- include/api.php | 4 ++-- include/apps.php | 24 +++++++++---------- include/attach.php | 2 +- include/auth.php | 2 +- include/comanche.php | 6 ++--- include/config.php | 2 +- include/contact_widgets.php | 12 +++++----- include/conversation.php | 52 ++++++++++++++++++++-------------------- include/follow.php | 2 +- include/group.php | 8 +++---- include/identity.php | 40 +++++++++++++++---------------- include/items.php | 10 ++++---- include/menu.php | 4 ++-- include/message.php | 8 +++---- include/nav.php | 22 ++++++++--------- include/security.php | 18 +++++++------- include/socgraph.php | 2 +- include/text.php | 20 ++++++++-------- include/widgets.php | 54 +++++++++++++++++++++--------------------- include/zot.php | 2 +- 27 files changed, 171 insertions(+), 171 deletions(-) (limited to 'include') diff --git a/include/Contact.php b/include/Contact.php index 4c80f5d6a..66062c279 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -98,10 +98,10 @@ function vcard_from_xchan($xchan, $observer = null, $mode = '') { // FIXME - show connect button to observer if appropriate $connect = false; - if(local_user()) { + if(local_channel()) { $r = q("select * from abook where abook_xchan = '%s' and abook_channel = %d limit 1", dbesc($xchan['xchan_hash']), - intval(local_user()) + intval(local_channel()) ); if(! $r) $connect = t('Connect'); @@ -351,7 +351,7 @@ function channel_remove($channel_id, $local = true, $unset_session=true) { proc_run('php','include/directory.php',$channel_id); - if($channel_id == local_user() && $unset_session) { + if($channel_id == local_channel() && $unset_session) { unset($_SESSION['authenticated']); unset($_SESSION['uid']); goaway($a->get_baseurl()); diff --git a/include/ConversationObject.php b/include/ConversationObject.php index 7dc4c8c19..af0bb8d2c 100644 --- a/include/ConversationObject.php +++ b/include/ConversationObject.php @@ -33,7 +33,7 @@ class Conversation extends BaseObject { $this->set_mode($mode); $this->preview = $preview; $this->prepared_item = $prepared_item; - $c = ((local_user()) ? get_pconfig(local_user(),'system','default_cipher') : ''); + $c = ((local_channel()) ? get_pconfig(local_channel(),'system','default_cipher') : ''); if($c) $this->cipher = $c; } @@ -57,7 +57,7 @@ class Conversation extends BaseObject { // $this->writable = false; // } // else { - $this->profile_owner = local_user(); + $this->profile_owner = local_channel(); $this->writable = true; // } break; diff --git a/include/ItemObject.php b/include/ItemObject.php index 82a321732..344664fd2 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -84,11 +84,11 @@ class Item extends BaseObject { $conv = $this->get_conversation(); $observer = $conv->get_observer(); - $lock = ((($item['item_private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) + $lock = ((($item['item_private'] == 1) || (($item['uid'] == local_channel()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])))) ? t('Private Message') : false); - $shareable = ((($conv->get_profile_owner() == local_user() && local_user()) && ($item['item_private'] != 1)) ? true : false); + $shareable = ((($conv->get_profile_owner() == local_channel() && local_channel()) && ($item['item_private'] != 1)) ? true : false); // allow an exemption for sharing stuff from your private feeds if($item['author']['xchan_network'] === 'rss') @@ -96,7 +96,7 @@ class Item extends BaseObject { $mode = $conv->get_mode(); - if(local_user() && $observer['xchan_hash'] === $item['author_xchan']) + if(local_channel() && $observer['xchan_hash'] === $item['author_xchan']) $edpost = array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit")); else $edpost = false; @@ -104,7 +104,7 @@ class Item extends BaseObject { if($observer['xchan_hash'] == $this->get_data_value('author_xchan') || $observer['xchan_hash'] == $this->get_data_value('owner_xchan') - || $this->get_data_value('uid') == local_user()) + || $this->get_data_value('uid') == local_channel()) $dropping = true; @@ -127,7 +127,7 @@ class Item extends BaseObject { ); } - $filer = ((($conv->get_profile_owner() == local_user()) && (! array_key_exists('real_uid',$item))) ? t("Save to Folder") : false); + $filer = ((($conv->get_profile_owner() == local_channel()) && (! array_key_exists('real_uid',$item))) ? t("Save to Folder") : false); $profile_avatar = $item['author']['xchan_photo_m']; $profile_link = chanlink_url($item['author']['xchan_url']); @@ -171,7 +171,7 @@ class Item extends BaseObject { if($this->is_toplevel()) { // FIXME check this permission - if(($conv->get_profile_owner() == local_user()) && (! array_key_exists('real_uid',$item))) { + if(($conv->get_profile_owner() == local_channel()) && (! array_key_exists('real_uid',$item))) { // FIXME we don't need all this stuff, some can be done in the template @@ -198,7 +198,7 @@ class Item extends BaseObject { // FIXME - check this permission - if($conv->get_profile_owner() == local_user()) { + if($conv->get_profile_owner() == local_channel()) { $tagger = array( 'tagit' => t("Add Tag"), 'classtagger' => "", @@ -214,7 +214,7 @@ class Item extends BaseObject { } $has_event = false; - if(($item['obj_type'] === ACTIVITY_OBJ_EVENT) && $conv->get_profile_owner() == local_user()) + if(($item['obj_type'] === ACTIVITY_OBJ_EVENT) && $conv->get_profile_owner() == local_channel()) $has_event = true; if($this->is_commentable()) { @@ -296,7 +296,7 @@ class Item extends BaseObject { 'star' => ((feature_enabled($conv->get_profile_owner(),'star_posts')) ? $star : ''), 'tagger' => ((feature_enabled($conv->get_profile_owner(),'commtag')) ? $tagger : ''), 'filer' => ((feature_enabled($conv->get_profile_owner(),'filing')) ? $filer : ''), - 'bookmark' => (($conv->get_profile_owner() == local_user() && local_user() && $has_bookmarks) ? t('Save Bookmarks') : ''), + 'bookmark' => (($conv->get_profile_owner() == local_channel() && local_channel() && $has_bookmarks) ? t('Save Bookmarks') : ''), 'addtocal' => (($has_event) ? t('Add to Calendar') : ''), 'drop' => $drop, 'multidrop' => ((feature_enabled($conv->get_profile_owner(),'multi_delete')) ? $multidrop : ''), @@ -610,7 +610,7 @@ class Item extends BaseObject { $a = $this->get_app(); $observer = $conv->get_observer(); - $qc = ((local_user()) ? get_pconfig(local_user(),'system','qcomment') : null); + $qc = ((local_channel()) ? get_pconfig(local_channel(),'system','qcomment') : null); $qcomment = (($qc) ? explode("\n",$qc) : null); $comment_box = replace_macros($template,array( diff --git a/include/RedDAV/RedBrowser.php b/include/RedDAV/RedBrowser.php index 8093aebc9..e651562ec 100644 --- a/include/RedDAV/RedBrowser.php +++ b/include/RedDAV/RedBrowser.php @@ -76,7 +76,7 @@ class RedBrowser extends DAV\Browser\Plugin { */ public function generateDirectoryIndex($path) { // (owner_id = channel_id) is visitor owner of this directory? - $is_owner = ((local_user() && $this->auth->owner_id == local_user()) ? true : false); + $is_owner = ((local_channel() && $this->auth->owner_id == local_channel()) ? true : false); if ($this->auth->getTimezone()) date_default_timezone_set($this->auth->getTimezone()); diff --git a/include/account.php b/include/account.php index 88036e2ef..19c13d5bd 100644 --- a/include/account.php +++ b/include/account.php @@ -561,7 +561,7 @@ function downgrade_accounts() { function service_class_allows($uid,$property,$usage = false) { $a = get_app(); - if($uid == local_user()) { + if($uid == local_channel()) { $service_class = $a->account['account_service_class']; } else { @@ -619,7 +619,7 @@ function account_service_class_allows($aid,$property,$usage = false) { function service_class_fetch($uid,$property) { $a = get_app(); - if($uid == local_user()) { + if($uid == local_channel()) { $service_class = $a->account['account_service_class']; } else { diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 243e7a549..ae740b281 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -15,7 +15,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) { $o .= "