aboutsummaryrefslogtreecommitdiffstats
path: root/mod/manage.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-08-03 21:41:34 -0700
committerfriendica <info@friendica.com>2014-08-03 21:41:34 -0700
commit18cb9a1f55c721d51575c821d59536c2f5f2e794 (patch)
tree371a74b2a2f7b1c3a01d69dc8d7768e333782a6a /mod/manage.php
parente0d338f102d72a4ea34c08ce2c7b3ab5244f3e4e (diff)
downloadvolse-hubzilla-18cb9a1f55c721d51575c821d59536c2f5f2e794.tar.gz
volse-hubzilla-18cb9a1f55c721d51575c821d59536c2f5f2e794.tar.bz2
volse-hubzilla-18cb9a1f55c721d51575c821d59536c2f5f2e794.zip
add some notification counts to the structure passed to the "channel select" template (mod/manage). All it takes is to create an appropriate template to turn this page into a list with tallies of various notifications attached to each channel.
Diffstat (limited to 'mod/manage.php')
-rw-r--r--mod/manage.php73
1 files changed, 72 insertions, 1 deletions
diff --git a/mod/manage.php b/mod/manage.php
index 0772e2d61..1920967e6 100644
--- a/mod/manage.php
+++ b/mod/manage.php
@@ -52,6 +52,78 @@ function manage_content(&$a) {
$selected_channel = $channels[$x];
$channels[$x]['default'] = (($channels[$x]['channel_id'] == $account['account_default_channel']) ? "1" : '');
$channels[$x]['default_links'] = '1';
+
+
+ $c = q("SELECT id, item_restrict, item_flags FROM item
+ WHERE (item_restrict = %d) and ( item_flags & %d ) and uid = %d",
+ intval(ITEM_VISIBLE),
+ intval(ITEM_UNSEEN),
+ intval($channels[$x]['channel_id'])
+ );
+
+ if($c) {
+ foreach ($c as $it) {
+ if($it['item_flags'] & ITEM_WALL)
+ $channels[$x]['home'] ++;
+ else
+ $channels[$x]['network'] ++;
+ }
+ }
+
+
+ $intr = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d) and not ((abook_flags & %d) or (xchan_flags & %d))",
+ intval($channels[$x]['channel_id']),
+ intval(ABOOK_FLAG_PENDING),
+ intval(ABOOK_FLAG_SELF|ABOOK_FLAG_IGNORED),
+ intval(XCHAN_FLAGS_DELETED|XCHAN_FLAGS_ORPHAN)
+ );
+
+ if($intr)
+ $channels[$x]['intros'] = intval($intr[0]['total']);
+
+
+ $mails = q("SELECT count(id) as total from mail WHERE channel_id = %d AND not (mail_flags & %d) and from_xchan != '%s' ",
+ intval($channels[$x]['channel_id']),
+ intval(MAIL_SEEN),
+ dbesc($channels[$x]['channel_hash'])
+ );
+
+ if($mails)
+ $channels[$x]['mail'] = intval($mails[0]['total']);
+
+
+ $events = q("SELECT type, start, adjust FROM `event`
+ WHERE `event`.`uid` = %d AND start < '%s' AND start > '%s' and `ignore` = 0
+ ORDER BY `start` ASC ",
+ intval($channels[$x]['channel_id']),
+ dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + 7 days')),
+ dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days'))
+ );
+
+ if($events) {
+ $channels[$x]['all_events'] = count($events);
+
+ if($channels[$x]['all_events']) {
+ $str_now = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y-m-d');
+ foreach($events as $e) {
+ $bd = false;
+ if($e['type'] === 'birthday') {
+ $channels[$x]['birthdays'] ++;
+ $bd = true;
+ }
+ else {
+ $channels[$x]['events'] ++;
+ }
+ if(datetime_convert('UTC', ((intval($e['adjust'])) ? date_default_timezone_get() : 'UTC'), $e['start'], 'Y-m-d') === $str_now) {
+ $channels[$x]['all_events_today'] ++;
+ if($bd)
+ $channels[$x]['birthdays_today'] ++;
+ else
+ $channels[$x]['events_today'] ++;
+ }
+ }
+ }
+ }
}
}
@@ -72,7 +144,6 @@ function manage_content(&$a) {
array( 'new_channel', t('Create a new channel'), t('Create a new channel'))
);
-
$o = replace_macros(get_markup_template('channels.tpl'), array(
'$header' => t('Channel Manager'),
'$msg_selected' => t('Current Channel'),