aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Widget/Activity.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-03-16 17:11:48 -0700
committerMario Vavti <mario@mariovavti.com>2017-03-29 12:02:09 +0200
commit0bad26e116499d9b656c28f64c81275df4bbecb6 (patch)
treea5a30a33e97db03bb7fdeb156045ba41205546e8 /Zotlabs/Widget/Activity.php
parentcd57483ed9069a26b52ae8d7d74fdc537da89946 (diff)
downloadvolse-hubzilla-0bad26e116499d9b656c28f64c81275df4bbecb6.tar.gz
volse-hubzilla-0bad26e116499d9b656c28f64c81275df4bbecb6.tar.bz2
volse-hubzilla-0bad26e116499d9b656c28f64c81275df4bbecb6.zip
the rest of the standard widgets converted
Diffstat (limited to 'Zotlabs/Widget/Activity.php')
-rw-r--r--Zotlabs/Widget/Activity.php61
1 files changed, 61 insertions, 0 deletions
diff --git a/Zotlabs/Widget/Activity.php b/Zotlabs/Widget/Activity.php
new file mode 100644
index 000000000..72a27bdf1
--- /dev/null
+++ b/Zotlabs/Widget/Activity.php
@@ -0,0 +1,61 @@
+<?php
+
+namespace Zotlabs\Widget;
+
+class Activity {
+
+ function widget($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 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['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;
+ }
+
+}
+