aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Moderate.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-06-18 22:25:41 -0700
committerMario Vavti <mario@mariovavti.com>2017-06-19 16:09:07 +0200
commit1472f85b162ea6f1ab9e19e94b86fc4a8ef074be (patch)
tree5bcfc4803bb4305790d7cce894cc96a072e86840 /Zotlabs/Module/Moderate.php
parent3d6255ae24310a935caf4e74729aa7165f94aeda (diff)
downloadvolse-hubzilla-1472f85b162ea6f1ab9e19e94b86fc4a8ef074be.tar.gz
volse-hubzilla-1472f85b162ea6f1ab9e19e94b86fc4a8ef074be.tar.bz2
volse-hubzilla-1472f85b162ea6f1ab9e19e94b86fc4a8ef074be.zip
allow moderated comments like wordpress if permissions are compatible
Diffstat (limited to 'Zotlabs/Module/Moderate.php')
-rw-r--r--Zotlabs/Module/Moderate.php77
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..b7f05e4b2
--- /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))));
+ }
+ 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