diff options
author | Mario Vavti <mario@mariovavti.com> | 2023-04-26 12:50:37 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2023-04-26 12:50:37 +0200 |
commit | f851c272fa5cc95f11bfaa0b5399028c6d91247e (patch) | |
tree | e345f95a8e4dae0650ebd606722227ab59ef7421 | |
parent | 09fde2f83904b3cff477bfedb466c894f06b2f32 (diff) | |
download | volse-hubzilla-f851c272fa5cc95f11bfaa0b5399028c6d91247e.tar.gz volse-hubzilla-f851c272fa5cc95f11bfaa0b5399028c6d91247e.tar.bz2 volse-hubzilla-f851c272fa5cc95f11bfaa0b5399028c6d91247e.zip |
enable dir admins to flag or hide entries
-rw-r--r-- | Zotlabs/Module/Dircensor.php | 17 | ||||
-rw-r--r-- | Zotlabs/Module/Directory.php | 15 | ||||
-rw-r--r-- | Zotlabs/Module/Dirsearch.php | 16 | ||||
-rw-r--r-- | view/tpl/direntry.tpl | 8 |
4 files changed, 37 insertions, 19 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 '); diff --git a/view/tpl/direntry.tpl b/view/tpl/direntry.tpl index 5a8e19d12..61dbbcc37 100644 --- a/view/tpl/direntry.tpl +++ b/view/tpl/direntry.tpl @@ -1,14 +1,14 @@ <div class="directory-item{{if $entry.safe}} safe{{/if}}" id="directory-item-{{$entry.hash}}" > <div class="section-subtitle-wrapper clearfix"> <div class="float-end"> - {{if $entry.viewrate}} - {{if $entry.total_ratings}}<a href="ratings/{{$entry.hash}}" id="dir-rating-{{$entry.hash}}" class="btn btn-outline-secondary btn-sm">{{$entry.total_ratings}}</a>{{/if}} - {{/if}} {{if $entry.ignlink}} <a class="directory-ignore btn btn-warning btn-sm" href="{{$entry.ignlink}}"> {{$entry.ignore_label}}</a> {{/if}} + {{if $entry.censor_2}} + <a class="directory-censor btn btn{{$entry.censor_2_class}}-danger btn-sm" href="{{$entry.censor_2}}"> {{$entry.censor_2_label}}</a> + {{/if}} {{if $entry.censor}} - <a class="directory-censor btn btn-danger btn-sm" href="{{$entry.censor}}"> {{$entry.censor_label}}</a> + <a class="directory-censor btn btn{{$entry.censor_class}}-warning btn-sm" href="{{$entry.censor}}"> {{$entry.censor_label}}</a> {{/if}} {{if $entry.connect}} <a class="btn btn-success btn-sm" href="{{$entry.connect}}"><i class="fa fa-plus connect-icon"></i> {{$entry.conn_label}}</a> |