From 812d904c98d6fb3a4124f6e2415de5a139f954ce Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 22 Oct 2017 18:23:37 -0700 Subject: bring back the markdown post feature (after investing some effort to make it work) --- Zotlabs/Module/Item.php | 46 +++++++++------------------------------------- 1 file changed, 9 insertions(+), 37 deletions(-) (limited to 'Zotlabs/Module/Item.php') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 9e5dcfaff..b54de0fb9 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -511,48 +511,20 @@ class Item extends \Zotlabs\Web\Controller { require_once('include/text.php'); - // Markdown doesn't work correctly. Do not re-enable unless you're willing to fix it and support it. - - // Sample that will probably give you grief - you must preserve the linebreaks - // and provide the correct markdown interpretation and you cannot allow unfiltered HTML - - // Markdown - // ======== - // - // **bold** abcde - // fghijkl - // *italic* - // - - // if($uid && $uid == $profile_uid && feature_enabled($uid,'markdown')) { - // require_once('include/markdown.php'); - // $body = escape_tags(trim($body)); - // $body = str_replace("\n",'
', $body); - // $body = preg_replace_callback('/\[share(.*?)\]/ism','\share_shield',$body); - // $body = markdown_to_bb($body,true); - // $body = preg_replace_callback('/\[share(.*?)\]/ism','\share_unshield',$body); - // } + if($uid && $uid == $profile_uid && feature_enabled($uid,'markdown')) { + require_once('include/markdown.php'); + $body = preg_replace_callback('/\[share(.*?)\]/ism','\share_shield',$body); + $body = markdown_to_bb($body,true,['preserve_lf' => true]); + $body = preg_replace_callback('/\[share(.*?)\]/ism','\share_unshield',$body); + + } // BBCODE alert: the following functions assume bbcode input // and will require alternatives for alternative content-types (text/html, text/markdown, text/plain, etc.) // we may need virtual or template classes to implement the possible alternatives - - // Work around doubled linefeeds in Tinymce 3.5b2 - // First figure out if it's a status post that would've been - // created using tinymce. Otherwise leave it alone. - - $plaintext = true; - - // $plaintext = ((feature_enabled($profile_uid,'richtext')) ? false : true); - // if((! $parent) && (! $api_source) && (! $plaintext)) { - // $body = fix_mce_lf($body); - // } - - - + // If we're sending a private top-level message with a single @-taggable channel as a recipient, @-tag it, if our pconfig is set. - - + if((! $parent) && (get_pconfig($profile_uid,'system','tagifonlyrecip')) && (substr_count($str_contact_allow,'<') == 1) && ($str_group_allow == '') && ($str_contact_deny == '') && ($str_group_deny == '')) { $x = q("select abook_id, abconfig.v from abook left join abconfig on abook_xchan = abconfig.xchan and abook_channel = abconfig.chan and cat= 'their_perms' and abconfig.k = 'tag_deliver' and abconfig.v = 1 and abook_xchan = '%s' and abook_channel = %d limit 1", dbesc(str_replace(array('<','>'),array('',''),$str_contact_allow)), -- cgit v1.2.3 From 458f2e748de22448206ce12c9961e9cce80c796d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 12 Nov 2017 14:14:20 -0800 Subject: cleanup of upload_to_comments test; we actually don't care about the profile owner. We only care that we're logged in locally and our storage is public by default. --- Zotlabs/Module/Item.php | 9 --------- 1 file changed, 9 deletions(-) (limited to 'Zotlabs/Module/Item.php') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index b54de0fb9..f2b850ffc 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -577,15 +577,6 @@ class Item extends \Zotlabs\Web\Controller { * so we'll set the permissions regardless and realise that the media may not be * referenced in the post. * - * What is preventing us from being able to upload photos into comments is dealing with - * the photo and attachment permissions, since we don't always know who was in the - * distribution for the top level post. - * - * We might be able to provide this functionality with a lot of fiddling: - * - if the top level post is public (make the photo public) - * - if the top level post was written by us or a wall post that belongs to us (match the top level post) - * - if the top level post has privacy mentions, add those to the permissions. - * - otherwise disallow the photo *or* make the photo public. This is the part that gets messy. */ if(! $preview) { -- cgit v1.2.3 From 6c178d44858bbdfd582d09eb4568d32292c0b2c2 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 22 Nov 2017 15:39:06 -0800 Subject: article feature --- Zotlabs/Module/Item.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Zotlabs/Module/Item.php') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index f2b850ffc..ecbefa1c2 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -629,6 +629,9 @@ class Item extends \Zotlabs\Web\Controller { if($webpage == ITEM_TYPE_CARD) { $catlink = z_root() . '/cards/' . $channel['channel_address'] . '?f=&cat=' . urlencode(trim($cat)); } + elseif($webpage == ITEM_TYPE_ARTICLE) { + $catlink = z_root() . '/articles/' . $channel['channel_address'] . '?f=&cat=' . urlencode(trim($cat)); + } else { $catlink = $owner_xchan['xchan_url'] . '?f=&cat=' . urlencode(trim($cat)); } @@ -733,6 +736,18 @@ class Item extends \Zotlabs\Web\Controller { } } + if($webpage == ITEM_TYPE_ARTICLE) { + $plink = z_root() . '/articles/' . $channel['channel_address'] . '/' . (($pagetitle) ? $pagetitle : substr($mid,0,16)); + } + if(($parent_item) && ($parent_item['item_type'] == ITEM_TYPE_ARTICLE)) { + $r = q("select v from iconfig where iconfig.cat = 'system' and iconfig.k = 'ARTICLE' and iconfig.iid = %d limit 1", + intval($parent_item['id']) + ); + if($r) { + $plink = z_root() . '/articles/' . $channel['channel_address'] . '/' . $r[0]['v']; + } + } + if ((! $plink) && ($item_thread_top)) { $plink = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $mid; } -- cgit v1.2.3 From 0e91810ed6764fbbee54e918711bfb45a1d9fd72 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 26 Nov 2017 18:29:24 -0800 Subject: pubstream comments and a few other bugfixes that were discovered along the way --- Zotlabs/Module/Item.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'Zotlabs/Module/Item.php') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index ecbefa1c2..2528645f3 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -59,6 +59,7 @@ class Item extends \Zotlabs\Web\Controller { $profile_uid = ((x($_REQUEST,'profile_uid')) ? intval($_REQUEST['profile_uid']) : 0); require_once('include/channel.php'); + $sys = get_sys_channel(); if($sys && $profile_uid && ($sys['channel_id'] == $profile_uid) && is_site_admin()) { $uid = intval($sys['channel_id']); @@ -171,7 +172,7 @@ class Item extends \Zotlabs\Web\Controller { ); } // if this isn't the real parent of the conversation, find it - if($r !== false && count($r)) { + if($r) { $parid = $r[0]['parent']; $parent_mid = $r[0]['mid']; if($r[0]['id'] != $r[0]['parent']) { @@ -179,9 +180,16 @@ class Item extends \Zotlabs\Web\Controller { intval($parid) ); } + + // if interacting with a pubstream item, + // create a copy of the parent in your stream + + if($r[0]['uid'] === $sys['channel_id'] && local_channel()) { + $r = [ copy_of_pubitem(\App::get_channel(), $r[0]['mid']) ]; + } } - - if(($r === false) || (! count($r))) { + + if(! $r) { notice( t('Unable to locate original post.') . EOL); if($api_source) return ( [ 'success' => false, 'message' => 'invalid post id' ] ); @@ -189,15 +197,12 @@ class Item extends \Zotlabs\Web\Controller { goaway(z_root() . "/" . $return_path ); killme(); } - - // can_comment_on_post() needs info from the following xchan_query - // This may be from the discover tab which means we need to correct the effective uid - xchan_query($r,true,(($r[0]['uid'] == local_channel()) ? 0 : local_channel())); - + xchan_query($r,true); + $parent_item = $r[0]; $parent = $r[0]['id']; - + // multi-level threading - preserve the info but re-parent to our single level threading $thr_parent = $parent_mid; -- cgit v1.2.3 From d4bb6c17d1a8d9d9179136790142a53f1898f12c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 10 Dec 2017 16:41:03 -0800 Subject: auto promote beginner (techlevel 0) accounts to level 1 after they show signs of active participation. --- Zotlabs/Module/Item.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Module/Item.php') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 2528645f3..37a3a3a85 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -1139,7 +1139,29 @@ class Item extends \Zotlabs\Web\Controller { $ret['message'] = t('Unable to obtain post information from database.'); return $ret; } - + + // auto-upgrade beginner (techlevel 0) accounts - if they have at least two friends and ten posts + // and have uploaded something (like a profile photo), promote them to level 1. + + $a = q("select account_id, account_level from account where account_id = (select channel_account_id from channel where channel_id = %d limit 1)", + intval($channel_id) + ); + if((! intval($a[0]['account_level'])) && intval($r[0]['total']) > 10) { + $x = q("select count(abook_id) as total from abook where abook_channel = %d", + intval($channel_id) + ); + if($x && intval($x[0]['total']) > 2) { + $y = q("select count(id) as total from attach where uid = %d", + intval($channel_id) + ); + if($y && intval($y[0]['total']) > 1) { + q("update account set account_level = 1 where account_id = %d limit 1", + intval($a[0]['account_id']) + ); + } + } + } + if (!$iswebpage) { $max = engr_units_to_bytes(service_class_fetch($channel_id,'total_items')); if(! service_class_allows($channel_id,'total_items',$r[0]['total'])) { -- cgit v1.2.3 From 66991a0778f99dcd08f597d24bd72cec1334e404 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 14 Dec 2017 22:41:11 +0100 Subject: fix another PHP7.2 warningg --- Zotlabs/Module/Item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Module/Item.php') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 37a3a3a85..6365230f8 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -156,7 +156,7 @@ class Item extends \Zotlabs\Web\Controller { if(! x($_REQUEST,'type')) $_REQUEST['type'] = 'net-comment'; - if($obj_type == ACTIVITY_OBJ_POST) + if($obj_type == ACTIVITY_OBJ_NOTE) $obj_type = ACTIVITY_OBJ_COMMENT; if($parent) { -- cgit v1.2.3