From 558e3f804247b14448969d8a0c8cf83b6c0fe4d7 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 24 Mar 2018 02:22:24 -0700 Subject: code optimisations and de-duplication on updating parent commented timestamp --- Zotlabs/Module/Moderate.php | 17 +++++--------- include/items.php | 56 +++++++++++++++++++++++++-------------------- 2 files changed, 37 insertions(+), 36 deletions(-) diff --git a/Zotlabs/Module/Moderate.php b/Zotlabs/Module/Moderate.php index b4709f3bd..10c8ab8f2 100644 --- a/Zotlabs/Module/Moderate.php +++ b/Zotlabs/Module/Moderate.php @@ -47,24 +47,17 @@ class Moderate extends \Zotlabs\Web\Controller { ); if($r) { + $item = $r[0]; + if($action === 'approve') { q("update item set item_blocked = 0 where uid = %d and id = %d", intval(local_channel()), intval($post_id) ); - // update the parent's commented timestamp + $item['item_blocked'] = 0; - $z = q("select max(created) as commented from item where parent_mid = '%s' and uid = %d and item_delayed = 0 ", - dbesc($r[0]['parent_mid']), - intval(local_channel()) - ); - - q("UPDATE item set commented = '%s', changed = '%s' WHERE id = %d", - dbesc(($z) ? $z[0]['commented'] : (datetime_convert())), - dbesc(datetime_convert()), - intval($r[0]['parent']) - ); + item_update_parent_commented($item); notice( t('Comment approved') . EOL); } @@ -72,6 +65,8 @@ class Moderate extends \Zotlabs\Web\Controller { drop_item($post_id,false); notice( t('Comment deleted') . EOL); } + + // refetch the item after changes have been made $r = q("select * from item where id = %d", intval($post_id) diff --git a/include/items.php b/include/items.php index a2068868a..d1625e944 100755 --- a/include/items.php +++ b/include/items.php @@ -1977,31 +1977,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) { */ call_hooks('post_remote_end', $arr); - $update_parent = true; - - // update the commented timestamp on the parent - unless this is a moderated comment or a potential clone of an older item - // which we don't wish to bring to the surface. As the queue only holds deliveries for 3 days, it's - // suspected of being an older cloned item if the creation time is older than that. - - if(intval($arr['item_blocked']) === ITEM_MODERATED) - $update_parent = false; - - if($arr['created'] < datetime_convert('','','now - 4 days')) - $update_parent = false; - - if($update_parent) { - $z = q("select max(created) as commented from item where parent_mid = '%s' and uid = %d and item_delayed = 0 ", - dbesc($arr['parent_mid']), - intval($arr['uid']) - ); - - q("UPDATE item set commented = '%s', changed = '%s' WHERE id = %d", - dbesc(($z) ? $z[0]['commented'] : (datetime_convert())), - dbesc(datetime_convert()), - intval($parent_id) - ); - } - + item_update_parent_commented($arr); // If _creating_ a deleted item, don't propagate it further or send out notifications. // We need to store the item details just in case the delete came in before the original post, @@ -2332,6 +2308,36 @@ function item_store_update($arr, $allow_exec = false, $deliver = true) { return $ret; } +function item_update_parent_commented($item) { + + + $update_parent = true; + + // update the commented timestamp on the parent + // - unless this is a moderated comment or a potential clone of an older item + // which we don't wish to bring to the surface. As the queue only holds deliveries + // for 3 days, it's suspected of being an older cloned item if the creation time + //is older than that. + + if(intval($item['item_blocked']) === ITEM_MODERATED) + $update_parent = false; + + if($item['created'] < datetime_convert('','','now - 4 days')) + $update_parent = false; + + if($update_parent) { + $z = q("select max(created) as commented from item where parent_mid = '%s' and uid = %d and item_delayed = 0 ", + dbesc($item['parent_mid']), + intval($item['uid']) + ); + + q("UPDATE item set commented = '%s', changed = '%s' WHERE id = %d", + dbesc(($z) ? $z[0]['commented'] : datetime_convert()), + dbesc(datetime_convert()), + intval($item['parent']) + ); + } +} function send_status_notifications($post_id,$item) { -- cgit v1.2.3 From d4e91d5d9b6f71b20382a6fdc941337cb67b5a5b Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 24 Mar 2018 15:13:19 -0700 Subject: app sellpage not being stored --- Zotlabs/Lib/Apps.php | 1 + Zotlabs/Module/Appman.php | 1 + 2 files changed, 2 insertions(+) diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index f91dc8e49..950a82aca 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -785,6 +785,7 @@ class Apps { dbesc($darray['app_plugin']), intval($darray['app_deleted']) ); + if($r) { $ret['success'] = true; $ret['app_id'] = $darray['app_id']; diff --git a/Zotlabs/Module/Appman.php b/Zotlabs/Module/Appman.php index 64d4628ae..3ebafafa4 100644 --- a/Zotlabs/Module/Appman.php +++ b/Zotlabs/Module/Appman.php @@ -25,6 +25,7 @@ class Appman extends \Zotlabs\Web\Controller { 'photo' => escape_tags($_REQUEST['photo']), 'version' => escape_tags($_REQUEST['version']), 'price' => escape_tags($_REQUEST['price']), + 'page' => escape_tags($_REQUEST['page']), 'requires' => escape_tags($_REQUEST['requires']), 'system' => intval($_REQUEST['system']), 'plugin' => escape_tags($_REQUEST['plugin']), -- cgit v1.2.3 From bb4f9eecbe88c5d6ead654cefefcd3c57f23c1fe Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 24 Mar 2018 21:17:15 -0700 Subject: preserve existing categories when updating an app from an embed source --- Zotlabs/Lib/Apps.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 950a82aca..24cb4a626 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -872,6 +872,12 @@ class Apps { dbesc($darray['app_id']), intval($darray['app_channel']) ); + + // if updating an embed app, don't mess with any existing categories. + + if(array_key_exists('embed',$arr) && intval($arr['embed'])) + return $ret; + if($x) { q("delete from term where otype = %d and oid = %d", intval(TERM_OBJ_APP), -- cgit v1.2.3