mirror of
https://framagit.org/hubzilla/core.git
synced 2026-06-21 00:52:33 -04:00
fix issues with pubstream tagcloud
This commit is contained in:
@@ -161,10 +161,12 @@ class Pubstream extends \Zotlabs\Web\Controller {
|
||||
$uids = " and item.uid = " . intval($sys['channel_id']) . " ";
|
||||
$abook_uids = " and abook.abook_channel = " . intval($sys['channel_id']) . " ";
|
||||
$sql_extra = item_permissions_sql($sys['channel_id']);
|
||||
$sql_extra_order = '';
|
||||
$site_firehose_sql = '';
|
||||
$thread_top = " and item.item_thread_top = 1 ";
|
||||
|
||||
if($site_firehose) {
|
||||
$site_firehose_sql = " and author_xchan in (select channel_hash from channel where channel_system = 0 and channel_removed = 0) ";
|
||||
$site_firehose_sql = " and owner_xchan in (select channel_hash from channel where channel_system = 0 and channel_removed = 0) ";
|
||||
}
|
||||
|
||||
if(get_config('system','public_list_mode'))
|
||||
@@ -175,6 +177,8 @@ class Pubstream extends \Zotlabs\Web\Controller {
|
||||
|
||||
if(x($hashtags)) {
|
||||
$sql_extra .= protect_sprintf(term_query('item', $hashtags, TERM_HASHTAG, TERM_COMMUNITYTAG));
|
||||
$sql_extra_order = " ORDER BY item.created DESC ";
|
||||
$thread_top = '';
|
||||
}
|
||||
|
||||
$net_query = (($net) ? " left join xchan on xchan_hash = author_xchan " : '');
|
||||
@@ -209,7 +213,7 @@ class Pubstream extends \Zotlabs\Web\Controller {
|
||||
$r = dbq("SELECT parent AS item_id FROM item
|
||||
left join abook on ( item.author_xchan = abook.abook_xchan $abook_uids )
|
||||
$net_query
|
||||
WHERE item.item_private = 0 and item.item_thread_top = 1
|
||||
WHERE item.item_private = 0 $thread_top
|
||||
$uids $site_firehose_sql
|
||||
$item_normal
|
||||
and (abook.abook_blocked = 0 or abook.abook_flags is null)
|
||||
@@ -234,7 +238,7 @@ class Pubstream extends \Zotlabs\Web\Controller {
|
||||
$r = dbq("SELECT parent AS item_id FROM item
|
||||
left join abook on item.author_xchan = abook.abook_xchan
|
||||
$net_query
|
||||
WHERE item.item_private = 0 and item.item_thread_top = 1
|
||||
WHERE item.item_private = 0 $thread_top
|
||||
$uids $site_firehose_sql $item_normal_update
|
||||
$simple_update
|
||||
and (abook.abook_blocked = 0 or abook.abook_flags is null)
|
||||
@@ -253,15 +257,22 @@ class Pubstream extends \Zotlabs\Web\Controller {
|
||||
$items = dbq("SELECT item.*, item.id AS item_id FROM item
|
||||
WHERE true $uids $item_normal
|
||||
AND item.parent IN ( $parents_str )
|
||||
$sql_extra"
|
||||
$sql_extra $sql_extra_order"
|
||||
);
|
||||
|
||||
|
||||
|
||||
// use effective_uid param of xchan_query to help sort out comment permission
|
||||
// for sys_channel owned items.
|
||||
|
||||
xchan_query($items, true, local_channel());
|
||||
$items = fetch_post_tags($items,true);
|
||||
$items = conv_sort($items,$ordering);
|
||||
|
||||
if (!$hashtags) {
|
||||
$items = conv_sort($items, $ordering);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,24 +22,19 @@ class Pubtagcloud {
|
||||
}
|
||||
}
|
||||
|
||||
$site_firehose = ((intval(get_config('system','site_firehose',0))) ? true : false);
|
||||
$net_firehose = ((get_config('system','disable_discover_tab',1)) ? false : true);
|
||||
$net_firehose = ((get_config('system','disable_discover_tab',1)) ? false : true);
|
||||
|
||||
if(! ($site_firehose || $net_firehose)) {
|
||||
return EMPTY_STR;
|
||||
}
|
||||
if(!$net_firehose) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if($net_firehose) {
|
||||
$site_firehose = false;
|
||||
}
|
||||
$site_firehose = ((intval(get_config('system','site_firehose',0))) ? true : false);
|
||||
|
||||
$safemode = get_xconfig(get_observer_hash(),'directory','safemode',1);
|
||||
|
||||
|
||||
|
||||
$limit = ((array_key_exists('limit', $arr)) ? intval($arr['limit']) : 75);
|
||||
|
||||
return pubtagblock($net_firehose,$site_firehose, $limit, $trending, $safemode);
|
||||
return pubtagblock($net_firehose, $site_firehose, $limit, $trending, $safemode);
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ function pubtagblock($net,$site,$limit,$recent = 0,$safemode = 1, $type = TERM_H
|
||||
if($r) {
|
||||
$o = '<div class="tagblock widget"><h3>' . (($recent) ? t('Trending') : t('Tags')) . '</h3><div class="tags" align="center">';
|
||||
foreach($r as $rr) {
|
||||
$o .= '<span class="tag'.$rr[2].'">#</span><a href="'.$link .'/' . '?f=&tag=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
|
||||
$o .= '<span class="tag'.$rr[2].'">#</span><a href="'.$link . '?tag=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
|
||||
}
|
||||
$o .= '</div></div>';
|
||||
}
|
||||
@@ -335,53 +335,55 @@ function pub_tagadelic($net, $site, $limit, $recent, $safemode, $type) {
|
||||
|
||||
$item_normal = item_normal();
|
||||
$count = intval($limit);
|
||||
$sql_extra = "";
|
||||
if($site)
|
||||
$uids = " and item.uid in ( " . stream_perms_api_uids(PERMS_PUBLIC) . " ) and item_private = 0 and item_wall = 1 ";
|
||||
else {
|
||||
$sys = get_sys_channel();
|
||||
$uids = " and item.uid = " . intval($sys['channel_id']) . " ";
|
||||
$sql_extra = " and item_private = 0 ";
|
||||
}
|
||||
$sys = get_sys_channel();
|
||||
$uids = " and item.uid = " . intval($sys['channel_id']) . " ";
|
||||
$sql_extra = item_permissions_sql($sys['channel_id']);
|
||||
|
||||
if($recent)
|
||||
$sql_extra .= " and item.created > NOW() - INTERVAL " . db_quoteinterval(intval($recent) . ' DAY') . " ";
|
||||
$site_firehose_sql = '';
|
||||
|
||||
if ($site) {
|
||||
$site_firehose_sql = " and author_xchan in (select channel_hash from channel where channel_system = 0 and channel_removed = 0) ";
|
||||
}
|
||||
|
||||
if($safemode) {
|
||||
$unsafetags = get_config('system','unsafepubtags', [ 'boobs', 'bot', 'rss', 'girl','girls', 'nsfw', 'sexy', 'nude' ]);
|
||||
if($unsafetags) {
|
||||
$sql_extra .= " and not term.term in ( " . stringify_array($unsafetags,true) . ") ";
|
||||
}
|
||||
}
|
||||
if($recent) {
|
||||
$sql_extra .= " and item.created > NOW() - INTERVAL " . db_quoteinterval(intval($recent) . ' DAY') . " ";
|
||||
}
|
||||
|
||||
$key = __FUNCTION__ . "-" . md5($site . $recent . $safemode . $limit . $type);
|
||||
|
||||
$content = Cache::get($key, '5 MINUTE');
|
||||
if(! $content) {
|
||||
|
||||
$content = Cache::get($key, '1 MONTH');
|
||||
$arr = [
|
||||
"SELECT term, count(term) AS total FROM term LEFT JOIN item ON term.oid = item.id
|
||||
WHERE term.ttype = %d
|
||||
AND otype = %d
|
||||
AND item_type = %d
|
||||
$sql_extra $uids $item_normal
|
||||
GROUP BY term ORDER BY total DESC %s",
|
||||
intval($type),
|
||||
intval(TERM_OBJ_POST),
|
||||
intval(ITEM_TYPE_POST),
|
||||
(intval($count) ? "LIMIT $count" : '')
|
||||
];
|
||||
|
||||
\Zotlabs\Daemon\Master::Summon([ 'Cache_query', $key, base64_encode(json_encode($arr)) ]);
|
||||
if($safemode) {
|
||||
$unsafetags = get_config('system','unsafepubtags', [ 'boobs', 'bot', 'rss', 'girl','girls', 'nsfw', 'sexy', 'nude' ]);
|
||||
if($unsafetags) {
|
||||
$sql_extra .= " and not term.term in ( " . stringify_array($unsafetags,true) . ") ";
|
||||
}
|
||||
}
|
||||
|
||||
$r = unserialize($content);
|
||||
if(! $r)
|
||||
return [];
|
||||
$key = __FUNCTION__ . "-" . md5($site . $recent . $safemode . $limit . $type);
|
||||
|
||||
return Zotlabs\Text\Tagadelic::calc($r);
|
||||
$content = Cache::get($key, '5 MINUTE');
|
||||
if(! $content) {
|
||||
|
||||
$content = Cache::get($key, '1 MONTH');
|
||||
$arr = [
|
||||
"SELECT term, count(term) AS total FROM term LEFT JOIN item ON term.oid = item.id
|
||||
WHERE term.ttype = %d
|
||||
AND otype = %d
|
||||
AND item_type = %d
|
||||
AND item_private = 0
|
||||
$uids $item_normal $site_firehose_sql $sql_extra
|
||||
GROUP BY term ORDER BY total DESC %s",
|
||||
intval($type),
|
||||
intval(TERM_OBJ_POST),
|
||||
intval(ITEM_TYPE_POST),
|
||||
(intval($count) ? "LIMIT $count" : '')
|
||||
];
|
||||
|
||||
\Zotlabs\Daemon\Master::Summon([ 'Cache_query', $key, base64_encode(json_encode($arr)) ]);
|
||||
}
|
||||
|
||||
$r = unserialize($content);
|
||||
if(! $r)
|
||||
return [];
|
||||
|
||||
return Zotlabs\Text\Tagadelic::calc($r);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user