directory entry reporting handler

This commit is contained in:
zotlabs 2019-05-05 18:44:33 -07:00
parent c607876e36
commit 687eb93153
4 changed files with 101 additions and 33 deletions

View file

@ -0,0 +1,54 @@
<?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);
$val = 0;
}
q("update xchan set xchan_censored = $val where xchan_hash = '%s'",
dbesc($xchan)
);
if( $val) {
info( t('Entry censored') . EOL);
}
else {
info( t('Entry censored') . EOL);
}
return;
}
}

View file

@ -154,14 +154,20 @@ class Directory extends Controller {
$tpl = get_markup_template('directory_header.tpl');
$dirmode = intval(get_config('system','directory_mode'));
if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) {
$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) {
if (! $url) {
$directory = Libzotdir::find_upstream_directory($dirmode);
if((! $directory) || (! array_key_exists('url',$directory)) || (! $directory['url']))
if ((! $directory) || (! array_key_exists('url',$directory)) || (! $directory['url'])) {
logger('CRITICAL: No directory server URL');
}
$url = $directory['url'] . '/dirsearch';
}
@ -220,7 +226,7 @@ class Directory extends Controller {
$query .= '&order=' . urlencode($sort_order);
if(App::$pager['page'] != 1)
$query .= '&p=' . \App::$pager['page'];
$query .= '&p=' . App::$pager['page'];
logger('mod_directory: query: ' . $query);
@ -362,6 +368,8 @@ class Directory extends 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' => (($safe_mode) ? $homepageurl : linkify($homepageurl)),
@ -407,7 +415,7 @@ class Directory extends 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);

View file

@ -1,14 +1,15 @@
<?php
namespace Zotlabs\Module;
use App;
use Zotlabs\Web\Controller;
class Dirsearch extends \Zotlabs\Web\Controller {
class Dirsearch extends Controller {
function init() {
\App::set_pager_itemspage(60);
App::set_pager_itemspage(60);
}
function get() {
@ -24,7 +25,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');
@ -283,28 +285,29 @@ class Dirsearch extends \Zotlabs\Web\Controller {
else
$entry['total_ratings'] = 0;
$entry['name'] = $rr['xchan_name'];
$entry['hash'] = $rr['xchan_hash'];
$entry['type'] = $rr['xchan_type'];
$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['name'] = $rr['xchan_name'];
$entry['hash'] = $rr['xchan_hash'];
$entry['censored'] = $rr['xchan_censored'];
$entry['selfcensored'] = $rr['xchan_selfcensored'];
$entry['type'] = $rr['xchan_type'];
$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;

View file

@ -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}}