diff options
author | zotlabs <mike@macgirvin.com> | 2017-03-02 17:32:43 -0800 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2017-03-02 17:32:43 -0800 |
commit | e58dc726c5e40ff30942739f86d2329fb29f763c (patch) | |
tree | 385c384fb9ad3837779b64a5ee5b19abf1dae2ee /include | |
parent | d7e24b24945a909f2bf2825200234db622a8e9fb (diff) | |
download | volse-hubzilla-e58dc726c5e40ff30942739f86d2329fb29f763c.tar.gz volse-hubzilla-e58dc726c5e40ff30942739f86d2329fb29f763c.tar.bz2 volse-hubzilla-e58dc726c5e40ff30942739f86d2329fb29f763c.zip |
activity widget - like the forum widget but represents unseen activity by author. Still experimental until it can be tested with diaspora xchans, which may require additional urlencoding.
Diffstat (limited to 'include')
-rw-r--r-- | include/text.php | 5 | ||||
-rw-r--r-- | include/widgets.php | 61 |
2 files changed, 66 insertions, 0 deletions
diff --git a/include/text.php b/include/text.php index 63248a0a6..1abed81bf 100644 --- a/include/text.php +++ b/include/text.php @@ -854,6 +854,11 @@ function tag_sort_length($a,$b) { return((mb_strlen($b) < mb_strlen($a)) ? (-1) : 1); } +function total_sort($a,$b) { + if($a['total'] == $b['total']) + return 0; + return(($b['total'] < $a['total']) ? 1 : (-1)); +} /** diff --git a/include/widgets.php b/include/widgets.php index 14345cf2f..a659101b9 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -1494,6 +1494,67 @@ function widget_forums($arr) { } +function widget_activity($arr) { + + if(! local_channel()) + return ''; + + $o = ''; + + if(is_array($arr) && array_key_exists('limit',$arr)) + $limit = " limit " . intval($limit) . " "; + else + $limit = ''; + + $perms_sql = item_permissions_sql(local_channel()) . item_normal(); + + $r = q("select owner_xchan, author_xchan from item where item_unseen = 1 and uid = %d $perms_sql", + intval(local_channel()) + ); + + $contributors = []; + $arr = []; + + if($r) { + foreach($r as $rv) { + if(array_key_exists($rv['owner_xchan'],$contributors)) + $contributors[$rv['owner_xchan']] ++; + else + $contributors[$rv['owner_xchan']] = 1; + if($rv['owner_xchan'] === $rv['author_xchan']) + continue; + if(array_key_exists($rv['author_xchan'],$contributors)) + $contributors[$rv['author_xchan']] ++; + else + $contributors[$rv['author_xchan']] = 1; + } + foreach($contributors as $k => $v) { + $arr[] = [ 'author_xchan' => $k, 'total' => $v ]; + } + usort($arr,'total_sort'); + xchan_query($arr); + } + + $x = [ 'entries' => $arr ]; + call_hooks('activity_widget',$x); + $arr = $x['entries']; + + if($arr) { + $o .= '<div class="widget">'; + $o .= '<h3>' . t('Activity','widget') . '</h3><ul class="nav nav-pills nav-stacked">'; + + foreach($arr as $rv) { + $o .= '<li><a href="network?f=&xchan=' . urlencode($rv['author_xchan']) . '" ><span class="badge pull-right">' . ((intval($rv['total'])) ? intval($rv['total']) : '') . '</span><img src="' . $rv['author']['xchan_photo_s'] . '" style="width: 16px; height: 16px;" /> ' . $rv['author']['xchan_name'] . '</a></li>'; + } + $o .= '</ul></div>'; + } + return $o; + +} + + + + function widget_tasklist($arr) { if (! local_channel()) |