aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Dircensor.php
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Module/Dircensor.php')
-rw-r--r--Zotlabs/Module/Dircensor.php38
1 files changed, 32 insertions, 6 deletions
diff --git a/Zotlabs/Module/Dircensor.php b/Zotlabs/Module/Dircensor.php
index 0fa65e948..4ce3a81c4 100644
--- a/Zotlabs/Module/Dircensor.php
+++ b/Zotlabs/Module/Dircensor.php
@@ -4,6 +4,7 @@ namespace Zotlabs\Module;
use App;
use Zotlabs\Web\Controller;
+use Zotlabs\Lib\Libzotdir;
class Dircensor extends Controller {
@@ -15,11 +16,12 @@ class Dircensor extends Controller {
$dirmode = intval(get_config('system','directory_mode'));
- if (! ($dirmode == DIRECTORY_MODE_PRIMARY || $dirmode == DIRECTORY_MODE_STANDALONE)) {
+ if(!in_array($dirmode, [DIRECTORY_MODE_PRIMARY, DIRECTORY_MODE_SECONDARY, DIRECTORY_MODE_STANDALONE])) {
return;
}
$xchan = argv(1);
+
if(! $xchan) {
return;
}
@@ -32,19 +34,43 @@ class Dircensor extends Controller {
return;
}
- $val = (($r[0]['xchan_censored']) ? 0 : 1);
+ $severity = intval($_REQUEST['severity'] ?? 0);
+ $flag = DIRECTORY_FLAG_OK;
+
+ if ($severity === 1) {
+ $flag = DIRECTORY_FLAG_UNSAFE;
+ }
+
+ if ($severity === 2) {
+ $flag = DIRECTORY_FLAG_HIDDEN;
+ }
+
+ Libzotdir::update($xchan, $r[0]['xchan_url'], true, $flag);
- q("update xchan set xchan_censored = $val where xchan_hash = '%s'",
+ q("UPDATE xchan SET xchan_censored = %d WHERE xchan_hash = '%s'",
+ intval($flag),
dbesc($xchan)
);
- if($val) {
+ q("UPDATE xtag SET xtag_flags = %d WHERE xtag_hash = '%s'",
+ intval($flag),
+ dbesc($xchan)
+ );
+
+ if($flag) {
info( t('Entry censored') . EOL);
}
else {
- info( t('Entry uncensored') . EOL);
+ info( t('Entry OK') . EOL);
}
-
+
+ if (isset($_REQUEST['aj'])) {
+ json_return_and_die([
+ 'success' => 1,
+ 'flag' => $flag
+ ]);
+ }
+
goaway(z_root() . '/directory');
}