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.
This commit is contained in:
parent
d7e24b2494
commit
e58dc726c5
@ -321,6 +321,7 @@ class Channel extends \Zotlabs\Web\Controller {
|
|||||||
'$static' => $static,
|
'$static' => $static,
|
||||||
'$page' => ((\App::$pager['page'] != 1) ? \App::$pager['page'] : 1),
|
'$page' => ((\App::$pager['page'] != 1) ? \App::$pager['page'] : 1),
|
||||||
'$search' => '',
|
'$search' => '',
|
||||||
|
'$xchan' => '',
|
||||||
'$order' => '',
|
'$order' => '',
|
||||||
'$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0),
|
'$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0),
|
||||||
'$file' => '',
|
'$file' => '',
|
||||||
|
@ -165,6 +165,7 @@ class Display extends \Zotlabs\Web\Controller {
|
|||||||
'$page' => ((\App::$pager['page'] != 1) ? \App::$pager['page'] : 1),
|
'$page' => ((\App::$pager['page'] != 1) ? \App::$pager['page'] : 1),
|
||||||
'$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0),
|
'$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0),
|
||||||
'$search' => '',
|
'$search' => '',
|
||||||
|
'$xchan' => '',
|
||||||
'$order' => '',
|
'$order' => '',
|
||||||
'$file' => '',
|
'$file' => '',
|
||||||
'$cats' => '',
|
'$cats' => '',
|
||||||
|
@ -118,7 +118,7 @@ class Network extends \Zotlabs\Web\Controller {
|
|||||||
$cmax = ((x($_GET,'cmax')) ? intval($_GET['cmax']) : 99);
|
$cmax = ((x($_GET,'cmax')) ? intval($_GET['cmax']) : 99);
|
||||||
$firehose = ((x($_GET,'fh')) ? intval($_GET['fh']) : 0);
|
$firehose = ((x($_GET,'fh')) ? intval($_GET['fh']) : 0);
|
||||||
$file = ((x($_GET,'file')) ? $_GET['file'] : '');
|
$file = ((x($_GET,'file')) ? $_GET['file'] : '');
|
||||||
|
$xchan = ((x($_GET,'xchan')) ? $_GET['xchan'] : '');
|
||||||
|
|
||||||
$deftag = '';
|
$deftag = '';
|
||||||
|
|
||||||
@ -257,6 +257,26 @@ class Network extends \Zotlabs\Web\Controller {
|
|||||||
goaway(z_root() . '/network');
|
goaway(z_root() . '/network');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elseif($xchan) {
|
||||||
|
$r = q("select * from xchan where xchan_hash = '%s'",
|
||||||
|
dbesc($xchan)
|
||||||
|
);
|
||||||
|
if($r) {
|
||||||
|
$sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($xchan) . "' or owner_xchan = '" . dbesc($xchan) . "' ) $item_normal ) ";
|
||||||
|
$title = replace_macros(get_markup_template("section_title.tpl"),array(
|
||||||
|
'$title' => '<a href="' . zid($r[0]['xchan_url']) . '" ><img src="' . zid($r[0]['xchan_photo_s']) . '" alt="' . urlencode($r[0]['xchan_name']) . '" /></a> <a href="' . zid($r[0]['xchan_url']) . '" >' . $r[0]['xchan_name'] . '</a>'
|
||||||
|
));
|
||||||
|
$o = $tabs;
|
||||||
|
$o .= $title;
|
||||||
|
$o .= $status_editor;
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
notice( t('Invalid channel.') . EOL);
|
||||||
|
goaway(z_root() . '/network');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if(x($category)) {
|
if(x($category)) {
|
||||||
$sql_extra .= protect_sprintf(term_query('item', $category, TERM_CATEGORY));
|
$sql_extra .= protect_sprintf(term_query('item', $category, TERM_CATEGORY));
|
||||||
@ -302,6 +322,7 @@ class Network extends \Zotlabs\Web\Controller {
|
|||||||
'$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0),
|
'$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0),
|
||||||
'$page' => ((\App::$pager['page'] != 1) ? \App::$pager['page'] : 1),
|
'$page' => ((\App::$pager['page'] != 1) ? \App::$pager['page'] : 1),
|
||||||
'$search' => (($search) ? $search : ''),
|
'$search' => (($search) ? $search : ''),
|
||||||
|
'$xchan' => $xchan,
|
||||||
'$order' => $order,
|
'$order' => $order,
|
||||||
'$file' => $file,
|
'$file' => $file,
|
||||||
'$cats' => $category,
|
'$cats' => $category,
|
||||||
|
@ -57,6 +57,7 @@ class Pubstream extends \Zotlabs\Web\Controller {
|
|||||||
'$static' => $static,
|
'$static' => $static,
|
||||||
'$page' => ((\App::$pager['page'] != 1) ? \App::$pager['page'] : 1),
|
'$page' => ((\App::$pager['page'] != 1) ? \App::$pager['page'] : 1),
|
||||||
'$search' => '',
|
'$search' => '',
|
||||||
|
'$xchan' => '',
|
||||||
'$order' => 'comment',
|
'$order' => 'comment',
|
||||||
'$file' => '',
|
'$file' => '',
|
||||||
'$cats' => '',
|
'$cats' => '',
|
||||||
|
@ -130,6 +130,7 @@ class Search extends \Zotlabs\Web\Controller {
|
|||||||
'$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0),
|
'$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0),
|
||||||
'$page' => ((\App::$pager['page'] != 1) ? \App::$pager['page'] : 1),
|
'$page' => ((\App::$pager['page'] != 1) ? \App::$pager['page'] : 1),
|
||||||
'$search' => (($tag) ? urlencode('#') : '') . $search,
|
'$search' => (($tag) ? urlencode('#') : '') . $search,
|
||||||
|
'$xchan' => '',
|
||||||
'$order' => '',
|
'$order' => '',
|
||||||
'$file' => '',
|
'$file' => '',
|
||||||
'$cats' => '',
|
'$cats' => '',
|
||||||
|
@ -277,8 +277,8 @@ class Channel {
|
|||||||
if($email_changed && \App::$config['system']['register_policy'] == REGISTER_VERIFY) {
|
if($email_changed && \App::$config['system']['register_policy'] == REGISTER_VERIFY) {
|
||||||
|
|
||||||
// FIXME - set to un-verified, blocked and redirect to logout
|
// FIXME - set to un-verified, blocked and redirect to logout
|
||||||
// Why? Are we verifying people or email addresses?
|
// Q: Why? Are we verifying people or email addresses?
|
||||||
|
// A: the policy is to verify email addresses
|
||||||
}
|
}
|
||||||
|
|
||||||
goaway(z_root() . '/settings' );
|
goaway(z_root() . '/settings' );
|
||||||
|
@ -854,6 +854,11 @@ function tag_sort_length($a,$b) {
|
|||||||
return((mb_strlen($b) < mb_strlen($a)) ? (-1) : 1);
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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) {
|
function widget_tasklist($arr) {
|
||||||
|
|
||||||
if (! local_channel())
|
if (! local_channel())
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
var bParam_static = {{$static}};
|
var bParam_static = {{$static}};
|
||||||
|
|
||||||
var bParam_search = "{{$search}}";
|
var bParam_search = "{{$search}}";
|
||||||
|
var bParam_xchan = "{{$xchan}}";
|
||||||
var bParam_order = "{{$order}}";
|
var bParam_order = "{{$order}}";
|
||||||
var bParam_file = "{{$file}}";
|
var bParam_file = "{{$file}}";
|
||||||
var bParam_cats = "{{$cats}}";
|
var bParam_cats = "{{$cats}}";
|
||||||
@ -47,6 +48,7 @@
|
|||||||
if(bParam_list != 0) bCmd = bCmd + "&list=" + bParam_list;
|
if(bParam_list != 0) bCmd = bCmd + "&list=" + bParam_list;
|
||||||
if(bParam_fh != 0) bCmd = bCmd + "&fh=" + bParam_fh;
|
if(bParam_fh != 0) bCmd = bCmd + "&fh=" + bParam_fh;
|
||||||
if(bParam_search != "") bCmd = bCmd + "&search=" + bParam_search;
|
if(bParam_search != "") bCmd = bCmd + "&search=" + bParam_search;
|
||||||
|
if(bParam_xchan != "") bCmd = bCmd + "&xchan=" + bParam_xchan;
|
||||||
if(bParam_order != "") bCmd = bCmd + "&order=" + bParam_order;
|
if(bParam_order != "") bCmd = bCmd + "&order=" + bParam_order;
|
||||||
if(bParam_file != "") bCmd = bCmd + "&file=" + bParam_file;
|
if(bParam_file != "") bCmd = bCmd + "&file=" + bParam_file;
|
||||||
if(bParam_cats != "") bCmd = bCmd + "&cat=" + bParam_cats;
|
if(bParam_cats != "") bCmd = bCmd + "&cat=" + bParam_cats;
|
||||||
|
Reference in New Issue
Block a user