aboutsummaryrefslogtreecommitdiffstats
path: root/include/widgets.php
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-08-11 22:23:20 -0700
committerredmatrix <redmatrix@redmatrix.me>2015-08-11 22:23:20 -0700
commit0e8991fec2bc27f0bfab308cc9b04406e42c6dd8 (patch)
tree349c79fdb95266cfe442db7489ba433e5daa006f /include/widgets.php
parentb651604e8bc8895483fa388448cb5bbd8bcd35f9 (diff)
downloadvolse-hubzilla-0e8991fec2bc27f0bfab308cc9b04406e42c6dd8.tar.gz
volse-hubzilla-0e8991fec2bc27f0bfab308cc9b04406e42c6dd8.tar.bz2
volse-hubzilla-0e8991fec2bc27f0bfab308cc9b04406e42c6dd8.zip
more consistent output on forum widget
Diffstat (limited to 'include/widgets.php')
-rw-r--r--include/widgets.php32
1 files changed, 27 insertions, 5 deletions
diff --git a/include/widgets.php b/include/widgets.php
index 49470287e..e735f5b2f 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -1001,17 +1001,39 @@ function widget_forums($arr) {
else
$limit = '';
+ $unseen = 0;
+ if(is_array($arr) && array_key_exists('unseen',$arr) && intval($arr['unseen']))
+ $unseen = 1;
+
$perms_sql = item_permissions_sql(local_channel()) . item_normal();
-
- $r = q("select sum(item_unseen) as unseen, owner_xchan, abook_id, xchan.* from xchan left join item on owner_xchan = xchan_hash left join abook on abook_xchan = xchan_hash where xchan_pubforum = 1 and uid = %d and abook_channel = %d $perms_sql group by owner_xchan order by xchan_name $limit ",
- intval(local_channel()),
+
+ $r1 = q("select * from abook left join xchan on abook_xchan = xchan_hash where xchan_pubforum = 1 and abook_channel = %d order by xchan_name $limit ",
intval(local_channel())
);
- if($r) {
+ if(! $r1)
+ return $o;
+
+ $str = '';
+
+ // Trying to cram all this into a single query with joins and the proper group by's is tough.
+ // There also should be a way to update this via ajax.
+
+ for($x = 0; $x < count($r1); $x ++) {
+ $r = q("select sum(item_unseen) as unseen from item where owner_xchan = '%s' and uid = %d $perms_sql ",
+ dbesc($r1[$x]['xchan_hash']),
+ intval(local_channel())
+ );
+ if($r)
+ $r1[$x]['unseen'] = $r[0]['unseen'];
+ }
+
+ if($r1) {
$o .= '<div class="widget">';
$o .= '<h3>' . t('Forums') . '</h3><ul class="nav nav-pills nav-stacked">';
- foreach($r as $rr) {
+ foreach($r1 as $rr) {
+ if($unseen && (! intval($rr['unseen'])))
+ continue;
$o .= '<li><span class="pull-right">' . ((intval($rr['unseen'])) ? intval($rr['unseen']) : '') . '</span><a href="network?f=&cid=' . $rr['abook_id'] . '" ><img src="' . $rr['xchan_photo_s'] . '" style="width: 16px; height: 16px;" /> ' . $rr['xchan_name'] . '</a></li>';
}
$o .= '</ul></div>';