diff options
author | zotlabs <mike@macgirvin.com> | 2017-06-20 18:34:17 -0700 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2017-06-20 18:34:17 -0700 |
commit | 08c0729f5ff8ac97c27db08ae2dde1a052c71e25 (patch) | |
tree | 9ce2ee515601a79156e89e5158fc3b8047f6e90a /Zotlabs/Module/Moderate.php | |
parent | 234c64574b4ee5ca22b85ae2fecc301286423068 (diff) | |
parent | 76e98091690cf5f2726bf7cefea217d49b23a5b4 (diff) | |
download | volse-hubzilla-08c0729f5ff8ac97c27db08ae2dde1a052c71e25.tar.gz volse-hubzilla-08c0729f5ff8ac97c27db08ae2dde1a052c71e25.tar.bz2 volse-hubzilla-08c0729f5ff8ac97c27db08ae2dde1a052c71e25.zip |
Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge
Diffstat (limited to 'Zotlabs/Module/Moderate.php')
-rw-r--r-- | Zotlabs/Module/Moderate.php | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/Zotlabs/Module/Moderate.php b/Zotlabs/Module/Moderate.php new file mode 100644 index 000000000..92df58858 --- /dev/null +++ b/Zotlabs/Module/Moderate.php @@ -0,0 +1,77 @@ +<?php + +namespace Zotlabs\Module; + +require_once('include/conversation.php'); + + +class Moderate extends \Zotlabs\Web\Controller { + + + function get() { + if(! local_channel()) { + notice( t('Permission denied.') . EOL); + return; + } + + + if(argc() > 2) { + $post_id = intval(argv(1)); + if(! $post_id) + goaway(z_root() . '/moderate'); + + $action = argv(2); + + $r = q("select * from item where uid = %d and id = %d and item_blocked = %d limit 1", + intval(local_channel()), + intval($post_id), + intval(ITEM_MODERATED) + ); + + if($r) { + if($action === 'approve') { + q("update item set item_blocked = 0 where uid = %d and id = %d", + intval(local_channel()), + intval($post_id) + ); + notice( t('Comment approved') . EOL); + } + elseif($action === 'drop') { + drop_item($post_id,false); + notice( t('Comment deleted') . EOL); + } + + $r = q("select * from item where id = %d", + intval($post_id) + ); + if($r) { + xchan_query($r); + $sync_item = fetch_post_tags($r); + build_sync_packet(local_channel(),array('item' => array(encode_item($sync_item[0],true)))); + } + if($action === 'approve') { + \Zotlabs\Daemon\Master::Summon(array('Notifier', 'comment-new', $post_id)); + } + goaway(z_root() . '/moderate'); + } + } + $r = q("select item.id as item_id, item.* from item where item.uid = %d and item_blocked = %d and item_deleted = 0 order by created desc limit 60", + intval(local_channel()), + intval(ITEM_MODERATED) + ); + + if($r) { + xchan_query($r); + $items = fetch_post_tags($r,true); + } + else { + $items = array(); + } + + $o = conversation($a,$items,'moderate',false,'traditional'); + + return $o; + + } + +}
\ No newline at end of file |