fix issues with forum handling in mod network and ping. also some code cleanup.
This commit is contained in:
@@ -635,20 +635,25 @@ class Ping extends \Zotlabs\Web\Controller {
|
||||
$forums = get_forum_channels(local_channel());
|
||||
|
||||
if($forums) {
|
||||
$perms_sql = item_permissions_sql(local_channel()) . item_normal();
|
||||
$perms_sql = item_permissions_sql(local_channel());
|
||||
$item_normal = item_normal();
|
||||
$fcount = count($forums);
|
||||
$forums['total'] = 0;
|
||||
|
||||
for($x = 0; $x < $fcount; $x ++) {
|
||||
$ttype = TERM_FORUM;
|
||||
$p = q("SELECT oid AS parent FROM term WHERE uid = " . intval(local_channel()) . " AND ttype = $ttype AND term = '" . dbesc($forums[$x]['xchan_name']) . "'");
|
||||
$p = ids_to_querystr($p, 'parent');
|
||||
$p = q("SELECT oid AS parent FROM term WHERE uid = %d AND ttype = %d AND term = '%s'",
|
||||
intval(local_channel()),
|
||||
intval(TERM_FORUM),
|
||||
dbesc($forums[$x]['xchan_hash'])
|
||||
);
|
||||
|
||||
$pquery = (($p) ? "OR parent IN ( $p )" : '');
|
||||
$p_str = ids_to_querystr($p, 'parent');
|
||||
$p_sql = (($p_str) ? "OR parent IN ( $p_str )" : '');
|
||||
|
||||
$r = q("select sum(item_unseen) as unseen from item
|
||||
where uid = %d and ( owner_xchan = '%s' $pquery ) and item_unseen = 1 $perms_sql ",
|
||||
where uid = %d and ( owner_xchan = '%s' OR author_xchan = '%s' $p_sql ) and item_unseen = 1 $perms_sql $item_normal",
|
||||
intval(local_channel()),
|
||||
dbesc($forums[$x]['xchan_hash']),
|
||||
dbesc($forums[$x]['xchan_hash'])
|
||||
);
|
||||
if($r[0]['unseen']) {
|
||||
|
||||
Reference in New Issue
Block a user