re-use directory safemode setting for public stream tag filtering since a handful of well-known tags skews the results wildly. Added 'bot' to the list just because it's noisy. A site can customise or nullify this feature if they desire.
This commit is contained in:
parent
a806c68713
commit
6903dbcc0d
@ -28,12 +28,13 @@ class Pubtagcloud {
|
|||||||
$site_firehose = false;
|
$site_firehose = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$safemode = get_xconfig(get_observer_hash(),'directory','safemode',1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$limit = ((array_key_exists('limit', $arr)) ? intval($arr['limit']) : 75);
|
$limit = ((array_key_exists('limit', $arr)) ? intval($arr['limit']) : 75);
|
||||||
|
|
||||||
return pubtagblock($net_firehose,$site_firehose, $limit, $trending);
|
return pubtagblock($net_firehose,$site_firehose, $limit, $trending, $safemode);
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -312,10 +312,10 @@ function article_tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function pubtagblock($net,$site,$limit,$recent = 0,$type = TERM_HASHTAG) {
|
function pubtagblock($net,$site,$limit,$recent = 0,$safemode = 1, $type = TERM_HASHTAG) {
|
||||||
$o = '';
|
$o = '';
|
||||||
|
|
||||||
$r = pub_tagadelic($net,$site,$limit,$since,$type);
|
$r = pub_tagadelic($net,$site,$limit,$since,$safemode,$type);
|
||||||
$link = z_root() . '/pubstream';
|
$link = z_root() . '/pubstream';
|
||||||
|
|
||||||
if($r) {
|
if($r) {
|
||||||
@ -329,13 +329,12 @@ function pubtagblock($net,$site,$limit,$recent = 0,$type = TERM_HASHTAG) {
|
|||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
function pub_tagadelic($net,$site,$limit,$recent,$type) {
|
function pub_tagadelic($net,$site,$limit,$recent,$safemode,$type) {
|
||||||
|
|
||||||
|
|
||||||
$item_normal = item_normal();
|
$item_normal = item_normal();
|
||||||
$count = intval($limit);
|
$count = intval($limit);
|
||||||
|
|
||||||
|
|
||||||
if($site) {
|
if($site) {
|
||||||
$uids = " and item.uid in ( " . stream_perms_api_uids(PERMS_PUBLIC) . " ) and item_private = 0 and item_wall = 1 ";
|
$uids = " and item.uid in ( " . stream_perms_api_uids(PERMS_PUBLIC) . " ) and item_private = 0 and item_wall = 1 ";
|
||||||
}
|
}
|
||||||
@ -348,6 +347,16 @@ function pub_tagadelic($net,$site,$limit,$recent,$type) {
|
|||||||
if($recent)
|
if($recent)
|
||||||
$sql_extra .= " and item.created > '" . datetime_convert('UTC','UTC', 'now - ' . intval($recent) . ' days ') . "' ";
|
$sql_extra .= " and item.created > '" . datetime_convert('UTC','UTC', 'now - ' . intval($recent) . ' days ') . "' ";
|
||||||
|
|
||||||
|
|
||||||
|
if($safemode) {
|
||||||
|
$unsafetags = get_config('system','unsafepubtags', [ 'boobs', 'bot', 'girl','girls', 'nsfw', 'sexy', 'nude' ]);
|
||||||
|
if($unsafetags) {
|
||||||
|
stringify_array_elms($unsafetags,true);
|
||||||
|
$sql_extra .= " and not term.term in ( " . implode(",",$unsafetags) . ") ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Fetch tags
|
// Fetch tags
|
||||||
$r = q("select term, count(term) as total from term left join item on term.oid = item.id
|
$r = q("select term, count(term) as total from term left join item on term.oid = item.id
|
||||||
where term.ttype = %d
|
where term.ttype = %d
|
||||||
|
Reference in New Issue
Block a user