aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kostikov <max@kostikov.co>2019-12-09 18:47:55 +0100
committerMax Kostikov <max@kostikov.co>2019-12-09 18:47:55 +0100
commit298acb96450e6282247fafecef49ffbb0174f5ea (patch)
treedeb91b84cff545a6af46cf9dc44f18273e23ae04
parent258a4e5627caf8fd1b3d89596fada2bea1490c7a (diff)
parentc4f4edd743b79ec3f3bebecf786cbb6da8921ce9 (diff)
downloadvolse-hubzilla-298acb96450e6282247fafecef49ffbb0174f5ea.tar.gz
volse-hubzilla-298acb96450e6282247fafecef49ffbb0174f5ea.tar.bz2
volse-hubzilla-298acb96450e6282247fafecef49ffbb0174f5ea.zip
Merge branch 'dev' into 'dev'
directory: port censoring from zap and disable oembed in profile about See merge request hubzilla/core!1805
-rw-r--r--Zotlabs/Module/Dircensor.php52
-rw-r--r--Zotlabs/Module/Directory.php43
-rw-r--r--Zotlabs/Module/Dirsearch.php54
-rwxr-xr-xview/tpl/direntry.tpl3
4 files changed, 113 insertions, 39 deletions
diff --git a/Zotlabs/Module/Dircensor.php b/Zotlabs/Module/Dircensor.php
new file mode 100644
index 000000000..0fa65e948
--- /dev/null
+++ b/Zotlabs/Module/Dircensor.php
@@ -0,0 +1,52 @@
+<?php
+
+namespace Zotlabs\Module;
+
+use App;
+use Zotlabs\Web\Controller;
+
+
+class Dircensor extends Controller {
+
+ function get() {
+ if(! is_site_admin()) {
+ return;
+ }
+
+ $dirmode = intval(get_config('system','directory_mode'));
+
+ if (! ($dirmode == DIRECTORY_MODE_PRIMARY || $dirmode == DIRECTORY_MODE_STANDALONE)) {
+ return;
+ }
+
+ $xchan = argv(1);
+ if(! $xchan) {
+ return;
+ }
+
+ $r = q("select * from xchan where xchan_hash = '%s'",
+ dbesc($xchan)
+ );
+
+ if(! $r) {
+ return;
+ }
+
+ $val = (($r[0]['xchan_censored']) ? 0 : 1);
+
+ q("update xchan set xchan_censored = $val where xchan_hash = '%s'",
+ dbesc($xchan)
+ );
+
+ if($val) {
+ info( t('Entry censored') . EOL);
+ }
+ else {
+ info( t('Entry uncensored') . EOL);
+ }
+
+ goaway(z_root() . '/directory');
+
+ }
+
+}
diff --git a/Zotlabs/Module/Directory.php b/Zotlabs/Module/Directory.php
index dee22721d..3eafd9f71 100644
--- a/Zotlabs/Module/Directory.php
+++ b/Zotlabs/Module/Directory.php
@@ -2,15 +2,19 @@
namespace Zotlabs\Module;
+use App;
+use Zotlabs\Web\Controller;
+
require_once('include/socgraph.php');
require_once('include/dir_fns.php');
require_once('include/bbcode.php');
+require_once('include/html2plain.php');
-class Directory extends \Zotlabs\Web\Controller {
+class Directory extends Controller {
function init() {
- \App::set_pager_itemspage(60);
+ App::set_pager_itemspage(60);
if(local_channel() && x($_GET,'ignore')) {
q("insert into xign ( uid, xchan ) values ( %d, '%s' ) ",
@@ -21,7 +25,7 @@ class Directory extends \Zotlabs\Web\Controller {
}
if(local_channel())
- \App::$profile_uid = local_channel();
+ App::$profile_uid = local_channel();
$observer = get_observer_hash();
$global_changed = false;
@@ -140,9 +144,15 @@ class Directory extends \Zotlabs\Web\Controller {
$dirmode = intval(get_config('system','directory_mode'));
+ $directory_admin = false;
+
if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) {
$url = z_root() . '/dirsearch';
- }
+ if (is_site_admin()) {
+ $directory_admin = true;
+ }
+ }
+
if(! $url) {
$directory = find_upstream_directory($dirmode);
if((! $directory) || (! array_key_exists('url',$directory)) || (! $directory['url']))
@@ -182,7 +192,7 @@ class Directory extends \Zotlabs\Web\Controller {
$query .= '&t=' . $token;
if(! $globaldir)
- $query .= '&hub=' . \App::get_hostname();
+ $query .= '&hub=' . App::get_hostname();
if($search)
$query .= '&name=' . urlencode($search) . '&keywords=' . urlencode($search);
@@ -204,8 +214,8 @@ class Directory extends \Zotlabs\Web\Controller {
if($sort_order)
$query .= '&order=' . urlencode($sort_order);
- if(\App::$pager['page'] != 1)
- $query .= '&p=' . \App::$pager['page'];
+ if(App::$pager['page'] != 1)
+ $query .= '&p=' . App::$pager['page'];
logger('mod_directory: query: ' . $query);
@@ -283,12 +293,15 @@ class Directory extends \Zotlabs\Web\Controller {
$marital = ((x($profile,'marital') == 1) ? t('Status: ') . $profile['marital']: False);
$homepage = ((x($profile,'homepage') == 1) ? t('Homepage: ') : False);
- $homepageurl = ((x($profile,'homepage') == 1) ? $profile['homepage'] : '');
-
- $hometown = ((x($profile,'hometown') == 1) ? $profile['hometown'] : False);
+ $homepageurl = ((x($profile,'homepage') == 1) ? html2plain($profile['homepage']) : '');
- $about = ((x($profile,'about') == 1) ? zidify_links(bbcode($profile['about'])) : False);
+ $hometown = ((x($profile,'hometown') == 1) ? html2plain($profile['hometown']) : False);
+ $about = ((x($profile,'about') == 1) ? zidify_links(bbcode($profile['about'], ['tryoembed' => false])) : False);
+ if ($about && $safe_mode) {
+ $about = html2plain($about);
+ }
+
$keywords = ((x($profile,'keywords')) ? $profile['keywords'] : '');
@@ -343,9 +356,11 @@ class Directory extends \Zotlabs\Web\Controller {
'canrate' => (($rating_enabled && local_channel()) ? true : false),
'pdesc' => $pdesc,
'pdesc_label' => t('Description:'),
+ 'censor' => (($directory_admin) ? 'dircensor/' . $rr['hash'] : ''),
+ 'censor_label' => (($rr['censored']) ? t('Uncensor') : t('Censor')),
'marital' => $marital,
'homepage' => $homepage,
- 'homepageurl' => linkify($homepageurl, true),
+ 'homepageurl' => (($safe_mode) ? $homepageurl : linkify($homepageurl)),
'hometown' => $hometown,
'hometown_label' => t('Hometown:'),
'about' => $about,
@@ -387,7 +402,7 @@ class Directory extends \Zotlabs\Web\Controller {
ksort($entries); // Sort array by key so that foreach-constructs work as expected
if($j['keywords']) {
- \App::$data['directory_keywords'] = $j['keywords'];
+ App::$data['directory_keywords'] = $j['keywords'];
}
logger('mod_directory: entries: ' . print_r($entries,true), LOGGER_DATA);
@@ -438,7 +453,7 @@ class Directory extends \Zotlabs\Web\Controller {
echo $o;
killme();
}
- if(\App::$pager['page'] == 1 && $j['records'] == 0 && strpos($search,'@')) {
+ if(App::$pager['page'] == 1 && $j['records'] == 0 && strpos($search,'@')) {
goaway(z_root() . '/chanview/?f=&address=' . $search);
}
info( t("No entries (some entries may be hidden).") . EOL);
diff --git a/Zotlabs/Module/Dirsearch.php b/Zotlabs/Module/Dirsearch.php
index 92b33df0c..62af75f4c 100644
--- a/Zotlabs/Module/Dirsearch.php
+++ b/Zotlabs/Module/Dirsearch.php
@@ -1,14 +1,17 @@
<?php
namespace Zotlabs\Module;
+use App;
+use Zotlabs\Web\Controller;
+
require_once('include/dir_fns.php');
-class Dirsearch extends \Zotlabs\Web\Controller {
+class Dirsearch extends Controller {
function init() {
- \App::set_pager_itemspage(60);
+ App::set_pager_itemspage(60);
}
@@ -25,7 +28,8 @@ class Dirsearch extends \Zotlabs\Web\Controller {
$ret['message'] = t('This site is not a directory server');
json_return_and_die($ret);
}
-
+
+
$access_token = $_REQUEST['t'];
$token = get_config('system','realm_token');
@@ -286,29 +290,29 @@ class Dirsearch extends \Zotlabs\Web\Controller {
else
$entry['total_ratings'] = 0;
- $entry['name'] = $rr['xchan_name'];
- $entry['hash'] = $rr['xchan_hash'];
-
+ $entry['name'] = $rr['xchan_name'];
+ $entry['hash'] = $rr['xchan_hash'];
+ $entry['censored'] = $rr['xchan_censored'];
+ $entry['selfcensored'] = $rr['xchan_selfcensored'];
$entry['public_forum'] = (intval($rr['xchan_pubforum']) ? true : false);
-
- $entry['url'] = $rr['xchan_url'];
- $entry['photo_l'] = $rr['xchan_photo_l'];
- $entry['photo'] = $rr['xchan_photo_m'];
- $entry['address'] = $rr['xchan_addr'];
- $entry['description'] = $rr['xprof_desc'];
- $entry['locale'] = $rr['xprof_locale'];
- $entry['region'] = $rr['xprof_region'];
- $entry['postcode'] = $rr['xprof_postcode'];
- $entry['country'] = $rr['xprof_country'];
- $entry['birthday'] = $rr['xprof_dob'];
- $entry['age'] = $rr['xprof_age'];
- $entry['gender'] = $rr['xprof_gender'];
- $entry['marital'] = $rr['xprof_marital'];
- $entry['sexual'] = $rr['xprof_sexual'];
- $entry['about'] = $rr['xprof_about'];
- $entry['homepage'] = $rr['xprof_homepage'];
- $entry['hometown'] = $rr['xprof_hometown'];
- $entry['keywords'] = $rr['xprof_keywords'];
+ $entry['url'] = $rr['xchan_url'];
+ $entry['photo_l'] = $rr['xchan_photo_l'];
+ $entry['photo'] = $rr['xchan_photo_m'];
+ $entry['address'] = $rr['xchan_addr'];
+ $entry['description'] = $rr['xprof_desc'];
+ $entry['locale'] = $rr['xprof_locale'];
+ $entry['region'] = $rr['xprof_region'];
+ $entry['postcode'] = $rr['xprof_postcode'];
+ $entry['country'] = $rr['xprof_country'];
+ $entry['birthday'] = $rr['xprof_dob'];
+ $entry['age'] = $rr['xprof_age'];
+ $entry['gender'] = $rr['xprof_gender'];
+ $entry['marital'] = $rr['xprof_marital'];
+ $entry['sexual'] = $rr['xprof_sexual'];
+ $entry['about'] = $rr['xprof_about'];
+ $entry['homepage'] = $rr['xprof_homepage'];
+ $entry['hometown'] = $rr['xprof_hometown'];
+ $entry['keywords'] = $rr['xprof_keywords'];
$entries[] = $entry;
diff --git a/view/tpl/direntry.tpl b/view/tpl/direntry.tpl
index f7ec7db23..175d813c5 100755
--- a/view/tpl/direntry.tpl
+++ b/view/tpl/direntry.tpl
@@ -7,6 +7,9 @@
{{if $entry.ignlink}}
<a class="directory-ignore btn btn-warning btn-sm" href="{{$entry.ignlink}}"> {{$entry.ignore_label}}</a>
{{/if}}
+ {{if $entry.censor}}
+ <a class="directory-censor btn btn-danger 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>
{{/if}}