From 0c23843b615742af6d43514ca6211750567cf07b Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 11 Aug 2015 17:39:29 -0700 Subject: untested forum widget --- include/widgets.php | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/widgets.php b/include/widgets.php index 36671e719..fe3b47353 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -980,10 +980,48 @@ function widget_rating($arr) { } // used by site ratings pages to provide a return link -function widget_pubsites() { +function widget_pubsites($arr) { if(get_app()->poi) return; return '
'; } +function widget_forums($arr) { + + $a = get_app(); + + if(! local_channel()) + return ''; + + if(! count($a->contacts)) + load_contact_links(local_channel()); + + $o = ''; + + if(is_array($arr) && array_key_exists('limit',$arr)) + $limit = " limit " . intval($limit) . " "; + else + $limit = " limit 12 "; + + $perms_sql = item_permissions_sql(local_channel()) . item_normal(); + + $r = q("select count(item_unseen) as unseen, owner_xchan, xchan.* from item left join xchan on owner_xchan = xchan_hash group by owner_xchan order by unseen desc limit item from xchan where xchan_pubforum = 1 and uid = %d $perms_sql group by owner_xchan $limit ", + intval(local_channel()) + ); + if($r) { + $o .= '
'; + $o .= '

' . t('Forums') . '

'; + + foreach($r as $rr) { + if($a->contacts && array_key_exists($rr['owner_xchan'],$a->contacts)) + $contact = $a->contacts[$rr['owner_xchan']]; + if($contact) + $o .= '
'; + } + return $o; + +} + -- cgit v1.2.3