aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Lib/Libzotdir.php18
-rw-r--r--Zotlabs/Module/Dircensor.php14
-rw-r--r--Zotlabs/Module/Directory.php13
-rw-r--r--Zotlabs/Module/Dirsearch.php17
-rw-r--r--view/tpl/directory_header.tpl63
-rw-r--r--view/tpl/direntry.tpl6
6 files changed, 112 insertions, 19 deletions
diff --git a/Zotlabs/Lib/Libzotdir.php b/Zotlabs/Lib/Libzotdir.php
index e30ccc43c..58138850c 100644
--- a/Zotlabs/Lib/Libzotdir.php
+++ b/Zotlabs/Lib/Libzotdir.php
@@ -521,7 +521,12 @@ class Libzotdir {
$clean = array();
if (array_key_exists('keywords', $profile) and is_array($profile['keywords'])) {
self::import_directory_keywords($hash,$profile['keywords']);
+
foreach ($profile['keywords'] as $kw) {
+ if (in_array($kw, $clean)) {
+ continue;
+ }
+
$kw = trim(htmlspecialchars($kw,ENT_COMPAT, 'UTF-8', false));
$kw = trim($kw, ',');
$clean[] = $kw;
@@ -645,6 +650,10 @@ class Libzotdir {
dbesc($hash)
);
+ $xchan = q("select xchan_censored from xchan where xchan_hash = '%s'",
+ dbesc($hash)
+ );
+
if($r) {
foreach($r as $rr)
$existing[] = $rr['xtag_term'];
@@ -652,6 +661,10 @@ class Libzotdir {
$clean = array();
foreach($keywords as $kw) {
+ if (in_array($kw, $clean)) {
+ continue;
+ }
+
$kw = trim(htmlspecialchars($kw,ENT_COMPAT, 'UTF-8', false));
$kw = trim($kw, ',');
$clean[] = $kw;
@@ -666,9 +679,10 @@ class Libzotdir {
}
foreach($clean as $x) {
if(! in_array($x, $existing)) {
- $r = q("insert into xtag ( xtag_hash, xtag_term, xtag_flags) values ( '%s' ,'%s', 0 )",
+ $r = q("insert into xtag ( xtag_hash, xtag_term, xtag_flags) values ( '%s' ,'%s', %d )",
dbesc($hash),
- dbesc($x)
+ dbesc($x),
+ intval($xchan[0]['xchan_censored'])
);
}
}
diff --git a/Zotlabs/Module/Dircensor.php b/Zotlabs/Module/Dircensor.php
index 44c9148e8..4ce3a81c4 100644
--- a/Zotlabs/Module/Dircensor.php
+++ b/Zotlabs/Module/Dircensor.php
@@ -47,7 +47,12 @@ class Dircensor extends Controller {
Libzotdir::update($xchan, $r[0]['xchan_url'], true, $flag);
- q("update xchan set xchan_censored = %d where xchan_hash = '%s'",
+ q("UPDATE xchan SET xchan_censored = %d WHERE xchan_hash = '%s'",
+ intval($flag),
+ dbesc($xchan)
+ );
+
+ q("UPDATE xtag SET xtag_flags = %d WHERE xtag_hash = '%s'",
intval($flag),
dbesc($xchan)
);
@@ -59,6 +64,13 @@ class Dircensor extends Controller {
info( t('Entry OK') . EOL);
}
+ if (isset($_REQUEST['aj'])) {
+ json_return_and_die([
+ 'success' => 1,
+ 'flag' => $flag
+ ]);
+ }
+
goaway(z_root() . '/directory');
}
diff --git a/Zotlabs/Module/Directory.php b/Zotlabs/Module/Directory.php
index c463c544b..34d55a8fe 100644
--- a/Zotlabs/Module/Directory.php
+++ b/Zotlabs/Module/Directory.php
@@ -355,12 +355,12 @@ class Directory extends Controller {
'gender' => $gender,
'pdesc' => $pdesc,
'pdesc_label' => t('Description:'),
- 'censor' => (($directory_admin && intval($rr['censored']) < 2) ? 'dircensor/' . $rr['hash'] . '?severity=' . ((intval($rr['censored']) > 0) ? 0 : 1) : ''),
- 'censor_label' => ((intval($rr['censored']) === 1) ? t('Safe') : t('Unsafe')),
- 'censor_class' => ((intval($rr['censored']) === 1) ? '' : '-outline'),
+ 'censor' => (($directory_admin) ? 'dircensor/' . $rr['hash'] . '?severity=' . ((intval($rr['censored']) > 0) ? 0 : 1) : ''),
+ 'censor_label' => t('Unsafe'),
+ 'censor_class' => ((intval($rr['censored']) === 1) ? 'active' : ''),
'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'),
+ 'censor_2_label' => t('Hidden'),
+ 'censor_2_class' => ((intval($rr['censored']) > 1) ? 'active' : ''),
'marital' => $marital,
'homepage' => $homepage,
'homepageurl' => (($safe_mode > 0) ? $homepageurl : linkify($homepageurl)),
@@ -444,7 +444,8 @@ class Directory extends Controller {
'$reverse' => t('Reverse Alphabetic'),
'$date' => t('Newest to Oldest'),
'$reversedate' => t('Oldest to Newest'),
- '$suggest' => $suggest ? '&suggest=1' : ''
+ '$suggest' => $suggest ? '&suggest=1' : '',
+ '$directory_admin' => $directory_admin
));
diff --git a/Zotlabs/Module/Dirsearch.php b/Zotlabs/Module/Dirsearch.php
index acf1b64e4..7380a551e 100644
--- a/Zotlabs/Module/Dirsearch.php
+++ b/Zotlabs/Module/Dirsearch.php
@@ -40,6 +40,8 @@ class Dirsearch extends Controller {
}
$sql_extra = '';
+ $keywords_query = '';
+ $hub_query = '';
$tables = array('name','address','locale','region','postcode','country','gender','marital','sexual','keywords');
@@ -98,10 +100,10 @@ class Dirsearch extends Controller {
$hub = \App::get_hostname();
}
- if($hub)
+ if($hub) {
$hub_query = " and xchan_hash in (select hubloc_hash from hubloc where hubloc_host = '" . protect_sprintf(dbesc($hub)) . "') ";
- else
- $hub_query = '';
+ }
+
$sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : '');
@@ -127,9 +129,12 @@ class Dirsearch extends Controller {
$sql_extra .= $this->dir_query_build($joiner,'xprof_marital',$marital);
if($sexual)
$sql_extra .= $this->dir_query_build($joiner,'xprof_sexual',$sexual);
- if($keywords)
- $sql_extra .= $this->dir_query_build($joiner,'xprof_keywords',$keywords);
+ if($keywords) {
+ $keywords_arr = explode(',', $keywords);
+ stringify_array_elms($keywords_arr, true);
+ $keywords_query = " AND xchan_hash IN (SELECT xtag_hash FROM xtag WHERE xtag_term IN (" . protect_sprintf(implode(',', $keywords_arr)) . ")) ";
+ }
// we only support an age range currently. You must set both agege
// (greater than or equal) and agele (less than or equal)
@@ -265,7 +270,7 @@ class Dirsearch extends Controller {
xprof.xprof_hometown as hometown,
xprof.xprof_keywords as keywords
from xchan left join xprof on xchan_hash = xprof_hash left join hubloc on (hubloc_id_url = xchan_url and hubloc_hash = xchan_hash)
- where hubloc_primary = 1 and hubloc_updated > %s - INTERVAL %s and ( $logic $sql_extra ) $hub_query and xchan_network = 'zot6' and xchan_system = 0 and xchan_hidden = 0 and xchan_orphan = 0 and xchan_deleted = 0
+ where hubloc_primary = 1 and hubloc_updated > %s - INTERVAL %s and ( $logic $sql_extra ) $hub_query $keywords_query and xchan_network = 'zot6' and xchan_system = 0 and xchan_hidden = 0 and xchan_orphan = 0 and xchan_deleted = 0
$safesql $order $qlimit",
db_utcnow(),
db_quoteinterval('30 DAY')
diff --git a/view/tpl/directory_header.tpl b/view/tpl/directory_header.tpl
index f5ce7ce0a..a261762ac 100644
--- a/view/tpl/directory_header.tpl
+++ b/view/tpl/directory_header.tpl
@@ -19,7 +19,68 @@
{{** make sure this element is at the bottom - we rely on that in endless scroll **}}
<div id="page-end" class="float-start w-100"></div>
</div>
-<script>$(document).ready(function() { loadingPage = false;});</script>
<div id="page-spinner" class="spinner-wrapper">
<div class="spinner m"></div>
</div>
+<script>
+ $(document).ready(function() {
+ loadingPage = false;
+ {{if $directory_admin}}
+ $(document).on('click', '.directory-censor', function (e) {
+ e.preventDefault();
+
+ let that = this;
+ let url;
+ let path;
+ let severity;
+ let parent = this.closest('.directory-actions');
+ let el;
+
+ url = new URL(that.href)
+
+ severity = url.searchParams.get('severity');
+ path = url.pathname;
+
+ console.log(url.searchParams.get('severity'));
+
+ $.get(
+ path,
+ {
+ aj: 1,
+ severity : severity
+ },
+ function(data) {
+ console.log(data)
+ if (data.success) {
+
+ if (that.classList.contains('directory-censor-unsafe')) {
+ severity = data.flag ? 0 : 1;
+ el = parent.getElementsByClassName('directory-censor-hide')[0];
+ if (el.classList.contains('active')) {
+ el.classList.toggle('active');
+ url.searchParams.set('severity', 2);
+ el.href = url.toString();
+ }
+ }
+
+ if (that.classList.contains('directory-censor-hide')) {
+ severity = data.flag ? 0 : 2;
+ el = parent.getElementsByClassName('directory-censor-unsafe')[0];
+ if (el.classList.contains('active')) {
+ el.classList.toggle('active');
+ url.searchParams.set('severity', 1);
+ el.href = url.toString();
+ }
+ }
+
+ url.searchParams.set('severity', severity);
+ that.href = url.toString();
+ that.classList.toggle('active');
+
+ }
+ }
+ );
+ });
+ {{/if}}
+ });
+</script>
diff --git a/view/tpl/direntry.tpl b/view/tpl/direntry.tpl
index 50714c072..16df987f4 100644
--- a/view/tpl/direntry.tpl
+++ b/view/tpl/direntry.tpl
@@ -1,11 +1,11 @@
<div class="directory-item{{if $entry.safe}} safe{{/if}}" id="directory-item-{{$entry.hash}}" >
<div class="section-subtitle-wrapper clearfix">
- <div class="float-end">
+ <div class="directory-actions float-end">
{{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>
+ <a class="directory-censor directory-censor-hide btn btn-outline-danger btn-sm {{$entry.censor_2_class}}" href="{{$entry.censor_2}}"> {{$entry.censor_2_label}}</a>
{{/if}}
{{if $entry.censor}}
- <a class="directory-censor btn btn{{$entry.censor_class}}-warning btn-sm" href="{{$entry.censor}}"> {{$entry.censor_label}}</a>
+ <a class="directory-censor directory-censor-unsafe btn btn-outline-warning btn-sm {{$entry.censor_class}}" href="{{$entry.censor}}"> {{$entry.censor_label}}</a>
{{/if}}
{{if $entry.ignlink}}
<a class="directory-ignore btn btn-info btn-sm" href="{{$entry.ignlink}}"> {{$entry.ignore_label}}</a>