aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2023-04-26 12:50:37 +0200
committerMario Vavti <mario@mariovavti.com>2023-04-26 12:50:37 +0200
commitf851c272fa5cc95f11bfaa0b5399028c6d91247e (patch)
treee345f95a8e4dae0650ebd606722227ab59ef7421 /Zotlabs
parent09fde2f83904b3cff477bfedb466c894f06b2f32 (diff)
downloadvolse-hubzilla-f851c272fa5cc95f11bfaa0b5399028c6d91247e.tar.gz
volse-hubzilla-f851c272fa5cc95f11bfaa0b5399028c6d91247e.tar.bz2
volse-hubzilla-f851c272fa5cc95f11bfaa0b5399028c6d91247e.zip
enable dir admins to flag or hide entries
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Module/Dircensor.php17
-rw-r--r--Zotlabs/Module/Directory.php15
-rw-r--r--Zotlabs/Module/Dirsearch.php16
3 files changed, 33 insertions, 15 deletions
diff --git a/Zotlabs/Module/Dircensor.php b/Zotlabs/Module/Dircensor.php
index 0fa65e948..bf676ef91 100644
--- a/Zotlabs/Module/Dircensor.php
+++ b/Zotlabs/Module/Dircensor.php
@@ -15,7 +15,7 @@ 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;
}
@@ -32,9 +32,18 @@ class Dircensor extends Controller {
return;
}
- $val = (($r[0]['xchan_censored']) ? 0 : 1);
+ $severity = intval($_REQUEST['severity'] ?? 0);
- q("update xchan set xchan_censored = $val where xchan_hash = '%s'",
+ if ($severity < 0) {
+ $severity = 0;
+ }
+
+ if ($severity > 2) {
+ $severity = 2;
+ }
+
+ q("update xchan set xchan_censored = %d where xchan_hash = '%s'",
+ intval($severity),
dbesc($xchan)
);
@@ -44,7 +53,7 @@ class Dircensor extends Controller {
else {
info( t('Entry uncensored') . EOL);
}
-
+
goaway(z_root() . '/directory');
}
diff --git a/Zotlabs/Module/Directory.php b/Zotlabs/Module/Directory.php
index 2958e80dc..4ce19c3a8 100644
--- a/Zotlabs/Module/Directory.php
+++ b/Zotlabs/Module/Directory.php
@@ -151,7 +151,7 @@ class Directory extends Controller {
$url = '';
- if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) {
+ if(in_array($dirmode, [DIRECTORY_MODE_PRIMARY, DIRECTORY_MODE_SECONDARY, DIRECTORY_MODE_STANDALONE])) {
$url = z_root() . '/dirsearch';
if (is_site_admin()) {
$directory_admin = true;
@@ -191,7 +191,10 @@ class Directory extends Controller {
if(get_config('system','disable_directory_keywords'))
$kw = 0;
- $query = $url . '?f=&kw=' . $kw . (($safe_mode != 1) ? '&safe=' . $safe_mode : '');
+ if (intval($safe_mode) === 0 && $directory_admin)
+ $safe_mode = -1;
+
+ $query = $url . '?f=&kw=' . $kw . (($safe_mode < 1) ? '&safe=' . $safe_mode : '');
if($token)
$query .= '&t=' . $token;
@@ -351,8 +354,12 @@ class Directory extends Controller {
'gender' => $gender,
'pdesc' => $pdesc,
'pdesc_label' => t('Description:'),
- 'censor' => (($directory_admin) ? 'dircensor/' . $rr['hash'] : ''),
- 'censor_label' => (($rr['censored']) ? t('Uncensor') : t('Censor')),
+ 'censor' => (($directory_admin && intval($rr['censored']) < 2) ? 'dircensor/' . $rr['hash'] . '?severity=' . ((intval($rr['censored']) > 0) ? 0 : 1) : ''),
+ 'censor_label' => ((intval($rr['censored']) === 1) ? t('Flag safe') : t('Flag unsafe')),
+ 'censor_class' => ((intval($rr['censored']) === 1) ? '' : '-outline'),
+ 'censor_2' => (($directory_admin) ? 'dircensor/' . $rr['hash'] . '?severity=' . ((intval($rr['censored']) > 1) ? 0 : 2) : ''),
+ 'censor_2_label' => ((intval($rr['censored']) > 1) ? t('Show') : t('Hide')),
+ 'censor_2_class' => ((intval($rr['censored']) > 1) ? '' : '-outline'),
'marital' => $marital,
'homepage' => $homepage,
'homepageurl' => (($safe_mode) ? $homepageurl : linkify($homepageurl)),
diff --git a/Zotlabs/Module/Dirsearch.php b/Zotlabs/Module/Dirsearch.php
index 45cb48c11..62bf99b67 100644
--- a/Zotlabs/Module/Dirsearch.php
+++ b/Zotlabs/Module/Dirsearch.php
@@ -25,7 +25,6 @@ class Dirsearch extends Controller {
json_return_and_die($ret);
}
-
$access_token = $_REQUEST['t'] ?? '';
$token = get_config('system','realm_token');
@@ -42,7 +41,6 @@ class Dirsearch extends Controller {
$sql_extra = '';
-
$tables = array('name','address','locale','region','postcode','country','gender','marital','sexual','keywords');
if(isset($_REQUEST['query']) && $_REQUEST['query']) {
@@ -85,9 +83,7 @@ class Dirsearch extends Controller {
// by default use a safe search
- $safe = ((x($_REQUEST,'safe'))); // ? intval($_REQUEST['safe']) : 1 );
- if ($safe === false)
- $safe = 1;
+ $safe = $_REQUEST['safe'] ?? 1;
if(array_key_exists('sync',$_REQUEST)) {
if($_REQUEST['sync'])
@@ -177,9 +173,15 @@ class Dirsearch extends Controller {
$sql_extra .= " and xchan_addr like '%%" . \App::get_hostname() . "' ";
}
- $safesql = (($safe > 0) ? " and xchan_censored = 0 and xchan_selfcensored = 0 " : '');
+ $safesql = '';
+ if($safe > 0)
+ $safesql = " and xchan_censored = 0 and xchan_selfcensored = 0 ";
+
+ if($safe < 1)
+ $safesql = " and xchan_censored < 2 and xchan_selfcensored < 2 ";
+
if($safe < 0)
- $safesql = " and ( xchan_censored = 1 OR xchan_selfcensored = 1 ) ";
+ $safesql = " and xchan_censored < 3 and xchan_selfcensored < 2 ";
if($forums)
$safesql .= " and xchan_pubforum = " . ((intval($forums)) ? '1 ' : '0 ');