From a99ebd42ec47ea531496f8ca5c07bf2868e21467 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 23 Nov 2017 15:21:50 -0800 Subject: change to bbcode calling parameters: important: will require pulling addons; also some extra checking of server headers in upload functions --- include/bbcode.php | 8 +++++--- include/markdown.php | 2 +- include/text.php | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index 7ebc8d37c..fd476766e 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -707,10 +707,12 @@ function parseIdentityAwareHTML($Text) { return $Text; } - // BBcode 2 HTML was written by WAY2WEB.net - // extended to work with Mistpark/Friendica/Redmatrix/Hubzilla - Mike Macgirvin -function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) { +function bbcode($Text, $options = []) { + + $preserve_nl = ((array_key_exists('preserve_nl',$options)) ? $options['preserve_nl'] : false); + $tryoembed = ((array_key_exists('tryomebed',$options)) ? $options['tryoembed'] : true); + $cache = ((array_key_exists('cache',$options)) ? $options['cache'] : false); call_hooks('bbcode_filter', $Text); diff --git a/include/markdown.php b/include/markdown.php index f398d279e..e4a35e3c3 100644 --- a/include/markdown.php +++ b/include/markdown.php @@ -204,7 +204,7 @@ function bb_to_markdown($Text, $options = []) { $Text = $x['bbcode']; // Convert it to HTML - don't try oembed - $Text = bbcode($Text, $preserve_nl, false); + $Text = bbcode($Text, [ 'tryoembed' => false ]); // Markdownify does not preserve previously escaped html entities such as <> and &. $Text = str_replace(array('<','>','&'),array('&_lt_;','&_gt_;','&_amp_;'),$Text); diff --git a/include/text.php b/include/text.php index 343e3f00b..f3d522e04 100644 --- a/include/text.php +++ b/include/text.php @@ -1679,9 +1679,9 @@ function prepare_text($text, $content_type = 'text/bbcode', $cache = false) { require_once('include/bbcode.php'); if(stristr($text,'[nosmile]')) - $s = bbcode($text,false,true,$cache); + $s = bbcode($text, [ 'cache' => $cache ]); else - $s = smilies(bbcode($text,false,true,$cache)); + $s = smilies(bbcode($text, [ 'cache' => $cache ])); $s = zidify_links($s); -- cgit v1.2.3 From 3bb0efd2cb393decf71fc717ef7e431a9f65d374 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 23 Nov 2017 20:35:34 -0800 Subject: remove deprecated $a argument from advanced_profile() --- include/channel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index 708e74176..16afd8209 100644 --- a/include/channel.php +++ b/include/channel.php @@ -1490,7 +1490,7 @@ function gender_icon($gender) { } -function advanced_profile(&$a) { +function advanced_profile() { require_once('include/text.php'); if(! perm_is_allowed(App::$profile['profile_uid'],get_observer_hash(),'view_profile')) return ''; -- cgit v1.2.3 From fda5231a719025c0e2d7cc3954ebbab5b0d53586 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 24 Nov 2017 14:55:39 -0800 Subject: default profile assign --- include/follow.php | 3 +++ include/zot.php | 2 ++ 2 files changed, 5 insertions(+) (limited to 'include') diff --git a/include/follow.php b/include/follow.php index 56d8294c5..0843802c5 100644 --- a/include/follow.php +++ b/include/follow.php @@ -226,6 +226,8 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) } + $profile_assign = get_pconfig($uid,'system','profile_assign',''); + $r = q("select abook_id, abook_xchan, abook_pending, abook_instance from abook where abook_xchan = '%s' and abook_channel = %d limit 1", @@ -265,6 +267,7 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) 'abook_channel' => intval($uid), 'abook_closeness' => intval($closeness), 'abook_xchan' => $xchan_hash, + 'abook_profile' => $profile_assign, 'abook_feed' => intval(($xchan['xchan_network'] === 'rss') ? 1 : 0), 'abook_created' => datetime_convert(), 'abook_updated' => datetime_convert(), diff --git a/include/zot.php b/include/zot.php index 40e303bf1..d60494d94 100644 --- a/include/zot.php +++ b/include/zot.php @@ -394,6 +394,7 @@ function zot_refresh($them, $channel = null, $force = false) { $next_birthday = NULL_DATE; } + $profile_assign = get_pconfig($channel['channel_id'],'system','profile_assign',''); // Keep original perms to check if we need to notify them $previous_perms = get_all_perms($channel['channel_id'],$x['hash']); @@ -455,6 +456,7 @@ function zot_refresh($them, $channel = null, $force = false) { 'abook_channel' => intval($channel['channel_id']), 'abook_closeness' => intval($closeness), 'abook_xchan' => $x['hash'], + 'abook_profile' => $profile_assign, 'abook_created' => datetime_convert(), 'abook_updated' => datetime_convert(), 'abook_dob' => $next_birthday, -- cgit v1.2.3 From 9dd545f4205a0f543a883422135e560c4ec74ad1 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 24 Nov 2017 15:39:00 -0800 Subject: don't include invisible "update activities" in category widget --- include/contact_widgets.php | 61 +++++++++++++++++++++++---------------------- include/taxonomy.php | 10 +++++--- 2 files changed, 37 insertions(+), 34 deletions(-) (limited to 'include') diff --git a/include/contact_widgets.php b/include/contact_widgets.php index b36471924..a105bca19 100644 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -72,21 +72,22 @@ function categories_widget($baseurl,$selected = '') { $item_normal = item_normal(); $terms = array(); - $r = q("select distinct(term.term) - from term join item on term.oid = item.id - where item.uid = %d - and term.uid = item.uid - and term.ttype = %d - and term.otype = %d - and item.owner_xchan = '%s' - and item.item_wall = 1 - $item_normal - $sql_extra - order by term.term asc", + $r = q("select distinct(term.term) from term join item on term.oid = item.id + where item.uid = %d + and term.uid = item.uid + and term.ttype = %d + and term.otype = %d + and item.owner_xchan = '%s' + and item.item_wall = 1 + and item.verb != '%s' + $item_normal + $sql_extra + order by term.term asc", intval(App::$profile['profile_uid']), - intval(TERM_CATEGORY), - intval(TERM_OBJ_POST), - dbesc(App::$profile['channel_hash']) + intval(TERM_CATEGORY), + intval(TERM_OBJ_POST), + dbesc(App::$profile['channel_hash']), + dbesc(ACTIVITY_UPDATE) ); if($r && count($r)) { foreach($r as $rr) @@ -118,19 +119,19 @@ function cardcategories_widget($baseurl,$selected = '') { $terms = array(); $r = q("select distinct(term.term) - from term join item on term.oid = item.id - where item.uid = %d - and term.uid = item.uid - and term.ttype = %d + from term join item on term.oid = item.id + where item.uid = %d + and term.uid = item.uid + and term.ttype = %d and term.otype = %d - and item.owner_xchan = '%s' + and item.owner_xchan = '%s' $item_normal $sql_extra - order by term.term asc", + order by term.term asc", intval(App::$profile['profile_uid']), - intval(TERM_CATEGORY), + intval(TERM_CATEGORY), intval(TERM_OBJ_POST), - dbesc(App::$profile['channel_hash']) + dbesc(App::$profile['channel_hash']) ); if($r && count($r)) { foreach($r as $rr) @@ -163,19 +164,19 @@ function articlecategories_widget($baseurl,$selected = '') { $terms = array(); $r = q("select distinct(term.term) - from term join item on term.oid = item.id - where item.uid = %d - and term.uid = item.uid - and term.ttype = %d + from term join item on term.oid = item.id + where item.uid = %d + and term.uid = item.uid + and term.ttype = %d and term.otype = %d - and item.owner_xchan = '%s' + and item.owner_xchan = '%s' $item_normal $sql_extra - order by term.term asc", + order by term.term asc", intval(App::$profile['profile_uid']), - intval(TERM_CATEGORY), + intval(TERM_CATEGORY), intval(TERM_OBJ_POST), - dbesc(App::$profile['channel_hash']) + dbesc(App::$profile['channel_hash']) ); if($r && count($r)) { foreach($r as $rr) diff --git a/include/taxonomy.php b/include/taxonomy.php index fbd2a18db..a13a9cf77 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -55,18 +55,20 @@ function term_item_parent_query($uid,$table,$s,$type = TERM_UNKNOWN, $type2 = '' $s = str_replace('*','%',$s); if($type2) { - $r = q("select parent from item left join term on term.oid = item.id where term.ttype in (%d, %d) and term.term like '%s' and term.uid = %d and term.otype = 1", + $r = q("select parent from item left join term on term.oid = item.id where term.ttype in (%d, %d) and term.term like '%s' and term.uid = %d and term.otype = 1 and item.verb != '%s'", intval($type), intval($type2), dbesc($s), - intval($uid) + intval($uid), + dbesc(ACTIVITY_UPDATE) ); } else { - $r = q("select parent from item left join term on term.oid = item.id where term.ttype = %d and term.term like '%s' and term.uid = %d and term.otype = 1", + $r = q("select parent from item left join term on term.oid = item.id where term.ttype = %d and term.term like '%s' and term.uid = %d and term.otype = 1 and item.verb != '%s'", intval($type), dbesc($s), - intval($uid) + intval($uid), + dbesc(ACTIVITY_UPDATE) ); } -- cgit v1.2.3 From 08900b730bd39c00e399696472d904c1d5e4ef0b Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 24 Nov 2017 18:23:53 -0800 Subject: this may fix pubstream comments/likes --- include/items.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include') diff --git a/include/items.php b/include/items.php index 654cc5de3..042deed1b 100755 --- a/include/items.php +++ b/include/items.php @@ -1749,6 +1749,22 @@ function item_store($arr, $allow_exec = false, $deliver = true) { intval($arr['uid']) ); + // perhaps the system channel owns the post and it's a pubstream item + + if(! $r) { + $s = q("select channel_id from channel where channel_system = 1 limit 1"); + if($s) { + $r = q("SELECT * FROM item WHERE mid = '%s' AND uid = %d ORDER BY id ASC LIMIT 1", + dbesc($arr['parent_mid']), + intval($s[0]['channel_id']) + ); + } + if($r) { + $arr['uid'] = $r[0]['uid']; + $arr['aid'] = 0; + } + } + if($r) { // in case item_store was killed before the parent's parent attribute got set, -- cgit v1.2.3