From ce6e81c68221a9f462af886626dc02fdfc26f8aa Mon Sep 17 00:00:00 2001 From: redmatrix Date: Mon, 3 Oct 2016 21:48:53 -0700 Subject: more backticks --- Zotlabs/Module/Ping.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Zotlabs/Module/Ping.php') diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index e01c3b49a..b145bd2ed 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -173,7 +173,7 @@ class Ping extends \Zotlabs\Web\Controller { ); break; case 'all_events': - $r = q("update event set `dismissed` = 1 where `dismissed` = 0 and uid = %d AND dtstart < '%s' AND dtstart > '%s' ", + $r = q("update event set dismissed = 1 where dismissed = 0 and uid = %d AND dtstart < '%s' AND dtstart > '%s' ", intval(local_channel()), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + ' . intval($evdays) . ' days')), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days')) @@ -325,9 +325,9 @@ class Ping extends \Zotlabs\Web\Controller { $result = array(); $r = q("SELECT * FROM event left join xchan on event_xchan = xchan_hash - WHERE `event`.`uid` = %d AND dtstart < '%s' AND dtstart > '%s' and `dismissed` = 0 + WHERE event.uid = %d AND dtstart < '%s' AND dtstart > '%s' and dismissed = 0 and etype in ( 'event', 'birthday' ) - ORDER BY `dtstart` DESC LIMIT 1000", + ORDER BY dtstart DESC LIMIT 1000", intval(local_channel()), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + ' . intval($evdays) . ' days')), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days')) @@ -443,10 +443,10 @@ class Ping extends \Zotlabs\Web\Controller { $t5 = dba_timer(); if($vnotify & (VNOTIFY_EVENT|VNOTIFY_EVENTTODAY|VNOTIFY_BIRTHDAY)) { - $events = q("SELECT etype, dtstart, adjust FROM `event` - WHERE `event`.`uid` = %d AND dtstart < '%s' AND dtstart > '%s' and `dismissed` = 0 + $events = q("SELECT etype, dtstart, adjust FROM event + WHERE event.uid = %d AND dtstart < '%s' AND dtstart > '%s' and dismissed = 0 and etype in ( 'event', 'birthday' ) - ORDER BY `dtstart` ASC ", + ORDER BY dtstart ASC ", intval(local_channel()), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + ' . intval($evdays) . ' days')), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days')) -- cgit v1.2.3 From 7b41839ea8f2aad020444c42f2cba89040ca28b8 Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Sun, 2 Oct 2016 00:41:25 +0200 Subject: [TASK] Update Doxyfile and fix Doxygen errors. Updated Doxyfile to include new folders. Add a list for @hooks tags. Fixed some parsing problems for Doxygen. --- Zotlabs/Module/Ping.php | 207 ++++++++++++++++++++++-------------------------- 1 file changed, 95 insertions(+), 112 deletions(-) (limited to 'Zotlabs/Module/Ping.php') diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index b145bd2ed..c385201ce 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -1,32 +1,27 @@ $m); @@ -96,17 +91,16 @@ class Ping extends \Zotlabs\Web\Controller { $result['info'] = array(); if(! ($vnotify & VNOTIFY_ALERT)) $result['notice'] = array(); - - + if(\App::$install) { echo json_encode($result); killme(); } - + /** * Update chat presence indication (if applicable) */ - + if(get_observer_hash() && (! $result['invalid'])) { $r = q("select cp_id, cp_room from chatpresence where cp_xchan = '%s' and cp_client = '%s' and cp_room = 0 limit 1", dbesc(get_observer_hash()), @@ -114,7 +108,7 @@ class Ping extends \Zotlabs\Web\Controller { ); $basic_presence = false; if($r) { - $basic_presence = true; + $basic_presence = true; q("update chatpresence set cp_last = '%s' where cp_id = %d", dbesc(datetime_convert()), intval($r[0]['cp_id']) @@ -130,40 +124,39 @@ class Ping extends \Zotlabs\Web\Controller { ); } } - + /** * Chatpresence continued... if somebody hasn't pinged recently, they've most likely left the page * and shouldn't count as online anymore. We allow an expection for bots. */ - + q("delete from chatpresence where cp_last < %s - INTERVAL %s and cp_client != 'auto' ", db_utcnow(), db_quoteinterval('3 MINUTE') - ); - + ); + if((! local_channel()) || ($result['invalid'])) { echo json_encode($result); killme(); } - + /** * Everything following is only permitted under the context of a locally authenticated site member. */ - - + /** * Handle "mark all xyz notifications read" requests. */ - + // mark all items read if(x($_REQUEST, 'markRead') && local_channel()) { switch($_REQUEST['markRead']) { case 'network': - $r = q("update item set item_unseen = 0 where item_unseen = 1 and uid = %d", + $r = q("update item set item_unseen = 0 where item_unseen = 1 and uid = %d", intval(local_channel()) ); break; case 'home': - $r = q("update item set item_unseen = 0 where item_unseen = 1 and item_wall = 1 and uid = %d", + $r = q("update item set item_unseen = 0 where item_unseen = 1 and item_wall = 1 and uid = %d", intval(local_channel()) ); break; @@ -188,21 +181,18 @@ class Ping extends \Zotlabs\Web\Controller { break; } } - + if(x($_REQUEST, 'markItemRead') && local_channel()) { - $r = q("update item set item_unseen = 0 where parent = %d and uid = %d", + $r = q("update item set item_unseen = 0 where parent = %d and uid = %d", intval($_REQUEST['markItemRead']), intval(local_channel()) ); } - - - + /** * URL ping/something will return detail for "something", e.g. a json list with which to populate a notification * dropdown menu. */ - if(argc() > 1 && argv(1) === 'notify') { $t = q("select count(*) as total from notify where uid = %d and seen = 0", intval(local_channel()) @@ -212,8 +202,7 @@ class Ping extends \Zotlabs\Web\Controller { and seen = 0 order by created desc limit 50", intval(local_channel()) ); - } - else { + } else { $z1 = q("select * from notify where uid = %d and seen = 0 order by created desc limit 50", intval(local_channel()) @@ -225,62 +214,62 @@ class Ping extends \Zotlabs\Web\Controller { ); $z = array_merge($z1,$z2); } - + if(count($z)) { foreach($z as $zz) { $notifs[] = array( - 'notify_link' => z_root() . '/notify/view/' . $zz['id'], + 'notify_link' => z_root() . '/notify/view/' . $zz['id'], 'name' => $zz['xname'], 'url' => $zz['url'], 'photo' => $zz['photo'], - 'when' => relative_date($zz['created']), - 'hclass' => (($zz['seen']) ? 'notify-seen' : 'notify-unseen'), + 'when' => relative_date($zz['created']), + 'hclass' => (($zz['seen']) ? 'notify-seen' : 'notify-unseen'), 'message' => strip_tags(bbcode($zz['msg'])) ); } } - + echo json_encode(array('notify' => $notifs)); killme(); } - + if(argc() > 1 && argv(1) === 'messages') { $channel = \App::get_channel(); - $t = q("select mail.*, xchan.* from mail left join xchan on xchan_hash = from_xchan - where channel_id = %d and mail_seen = 0 and mail_deleted = 0 + $t = q("select mail.*, xchan.* from mail left join xchan on xchan_hash = from_xchan + where channel_id = %d and mail_seen = 0 and mail_deleted = 0 and from_xchan != '%s' order by created desc limit 50", intval(local_channel()), dbesc($channel['channel_hash']) ); - + if($t) { foreach($t as $zz) { $notifs[] = array( - 'notify_link' => z_root() . '/mail/' . $zz['id'], + 'notify_link' => z_root() . '/mail/' . $zz['id'], 'name' => $zz['xchan_name'], 'url' => $zz['xchan_url'], 'photo' => $zz['xchan_photo_s'], - 'when' => relative_date($zz['created']), - 'hclass' => (intval($zz['mail_seen']) ? 'notify-seen' : 'notify-unseen'), + 'when' => relative_date($zz['created']), + 'hclass' => (intval($zz['mail_seen']) ? 'notify-seen' : 'notify-unseen'), 'message' => t('sent you a private message'), ); } } - + echo json_encode(array('notify' => $notifs)); killme(); } - + if(argc() > 1 && (argv(1) === 'network' || argv(1) === 'home')) { $result = array(); - + $r = q("SELECT * FROM item WHERE item_unseen = 1 and uid = %d $item_normal and author_xchan != '%s' ORDER BY created DESC limit 300", intval(local_channel()), dbesc($ob_hash) ); - + if($r) { xchan_query($r); foreach($r as $item) { @@ -289,18 +278,18 @@ class Ping extends \Zotlabs\Web\Controller { $result[] = \Zotlabs\Lib\Enotify::format($item); } } - // logger('ping (network||home): ' . print_r($result, true), LOGGER_DATA); +// logger('ping (network||home): ' . print_r($result, true), LOGGER_DATA); echo json_encode(array('notify' => $result)); killme(); } - + if(argc() > 1 && (argv(1) === 'intros')) { $result = array(); - + $r = q("SELECT * FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and abook_pending = 1 and abook_self = 0 and abook_ignored = 0 and xchan_deleted = 0 and xchan_orphan = 0 ORDER BY abook_created DESC LIMIT 50", intval(local_channel()) ); - + if($r) { foreach($r as $rr) { $result[] = array( @@ -308,8 +297,8 @@ class Ping extends \Zotlabs\Web\Controller { 'name' => $rr['xchan_name'], 'url' => $rr['xchan_url'], 'photo' => $rr['xchan_photo_s'], - 'when' => relative_date($rr['abook_created']), - 'hclass' => ('notify-unseen'), + 'when' => relative_date($rr['abook_created']), + 'hclass' => ('notify-unseen'), 'message' => t('added your channel') ); } @@ -318,12 +307,12 @@ class Ping extends \Zotlabs\Web\Controller { echo json_encode(array('notify' => $result)); killme(); } - + if(argc() > 1 && (argv(1) === 'all_events')) { $bd_format = t('g A l F d') ; // 8 AM Friday January 18 - + $result = array(); - + $r = q("SELECT * FROM event left join xchan on event_xchan = xchan_hash WHERE event.uid = %d AND dtstart < '%s' AND dtstart > '%s' and dismissed = 0 and etype in ( 'event', 'birthday' ) @@ -332,26 +321,25 @@ class Ping extends \Zotlabs\Web\Controller { dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + ' . intval($evdays) . ' days')), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days')) ); - + if($r) { foreach($r as $rr) { if($rr['adjust']) $md = datetime_convert('UTC', date_default_timezone_get(), $rr['dtstart'], 'Y/m'); else $md = datetime_convert('UTC', 'UTC', $rr['dtstart'], 'Y/m'); - + $strt = datetime_convert('UTC', (($rr['adjust']) ? date_default_timezone_get() : 'UTC'), $rr['dtstart']); $today = ((substr($strt, 0, 10) === datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y-m-d')) ? true : false); - $when = day_translate(datetime_convert('UTC', (($rr['adjust']) ? date_default_timezone_get() : 'UTC'), $rr['dtstart'], $bd_format)) . (($today) ? ' ' . t('[today]') : ''); - + $result[] = array( - 'notify_link' => z_root() . '/events', // FIXME this takes you to an edit page and it may not be yours, we really want to just view the single event --> '/events/event/' . $rr['event_hash'], + 'notify_link' => z_root() . '/events', /// @FIXME this takes you to an edit page and it may not be yours, we really want to just view the single event --> '/events/event/' . $rr['event_hash'], 'name' => $rr['xchan_name'], 'url' => $rr['xchan_url'], 'photo' => $rr['xchan_photo_s'], 'when' => $when, - 'hclass' => ('notify-unseen'), + 'hclass' => ('notify-unseen'), 'message' => t('posted an event') ); } @@ -360,13 +348,10 @@ class Ping extends \Zotlabs\Web\Controller { echo json_encode(array('notify' => $result)); killme(); } - - - + /** * Normal ping - just the counts, no detail */ - if($vnotify & VNOTIFY_SYSTEM) { $t = q("select count(*) as total from notify where uid = %d and seen = 0", intval(local_channel()) @@ -374,9 +359,9 @@ class Ping extends \Zotlabs\Web\Controller { if($t) $result['notify'] = intval($t[0]['total']); } - + $t1 = dba_timer(); - + if($vnotify & (VNOTIFY_NETWORK|VNOTIFY_CHANNEL)) { $r = q("SELECT id, item_wall FROM item WHERE item_unseen = 1 and uid = %d @@ -385,11 +370,11 @@ class Ping extends \Zotlabs\Web\Controller { intval(local_channel()), dbesc($ob_hash) ); - - if($r) { + + if($r) { $arr = array('items' => $r); call_hooks('network_ping', $arr); - + foreach ($r as $it) { if(intval($it['item_wall'])) $result['home'] ++; @@ -402,24 +387,23 @@ class Ping extends \Zotlabs\Web\Controller { $result['network'] = 0; if(! ($vnotify & VNOTIFY_CHANNEL)) $result['home'] = 0; - - + $t2 = dba_timer(); - + if($vnotify & VNOTIFY_INTRO) { $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_pending = 1 and abook_self = 0 and abook_ignored = 0 and xchan_deleted = 0 and xchan_orphan = 0 ", intval(local_channel()) ); - + $t3 = dba_timer(); - + if($intr) $result['intros'] = intval($intr[0]['total']); } - + $t4 = dba_timer(); $channel = \App::get_channel(); - + if($vnotify & VNOTIFY_MAIL) { $mails = q("SELECT count(id) as total from mail WHERE channel_id = %d AND mail_seen = 0 and from_xchan != '%s' ", @@ -429,7 +413,7 @@ class Ping extends \Zotlabs\Web\Controller { if($mails) $result['mail'] = intval($mails[0]['total']); } - + if($vnotify & VNOTIFY_REGISTER) { if (\App::$config['system']['register_policy'] == REGISTER_APPROVE && is_site_admin()) { $regs = q("SELECT count(account_id) as total from account where (account_flags & %d) > 0", @@ -438,10 +422,10 @@ class Ping extends \Zotlabs\Web\Controller { if($regs) $result['register'] = intval($regs[0]['total']); } - } - + } + $t5 = dba_timer(); - + if($vnotify & (VNOTIFY_EVENT|VNOTIFY_EVENTTODAY|VNOTIFY_BIRTHDAY)) { $events = q("SELECT etype, dtstart, adjust FROM event WHERE event.uid = %d AND dtstart < '%s' AND dtstart > '%s' and dismissed = 0 @@ -451,10 +435,10 @@ class Ping extends \Zotlabs\Web\Controller { dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + ' . intval($evdays) . ' days')), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days')) ); - + if($events) { $result['all_events'] = count($events); - + if($result['all_events']) { $str_now = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y-m-d'); foreach($events as $x) { @@ -483,16 +467,15 @@ class Ping extends \Zotlabs\Web\Controller { $result['all_events_today'] = $result['events_today'] = 0; if(! ($vnotify & VNOTIFY_BIRTHDAY)) $result['birthdays'] = 0; - - + $x = json_encode($result); - + $t6 = dba_timer(); - - // logger('ping timer: ' . sprintf('%01.4f %01.4f %01.4f %01.4f %01.4f %01.4f',$t6 - $t5, $t5 - $t4, $t4 - $t3, $t3 - $t2, $t2 - $t1, $t1 - $t0)); - + +// logger('ping timer: ' . sprintf('%01.4f %01.4f %01.4f %01.4f %01.4f %01.4f',$t6 - $t5, $t5 - $t4, $t4 - $t3, $t3 - $t2, $t2 - $t1, $t1 - $t0)); + echo $x; killme(); } - + } -- cgit v1.2.3 From 8811ca9e9efc8e177a49702066402fae819bdf5b Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 5 Nov 2016 03:31:50 -0700 Subject: provide /locs link on settings page if there is more than one hubloc for this channnel *that isn't deleted*. --- Zotlabs/Module/Ping.php | 4 ---- 1 file changed, 4 deletions(-) (limited to 'Zotlabs/Module/Ping.php') diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index c385201ce..bf2fa5cc9 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -324,10 +324,6 @@ class Ping extends \Zotlabs\Web\Controller { if($r) { foreach($r as $rr) { - if($rr['adjust']) - $md = datetime_convert('UTC', date_default_timezone_get(), $rr['dtstart'], 'Y/m'); - else - $md = datetime_convert('UTC', 'UTC', $rr['dtstart'], 'Y/m'); $strt = datetime_convert('UTC', (($rr['adjust']) ? date_default_timezone_get() : 'UTC'), $rr['dtstart']); $today = ((substr($strt, 0, 10) === datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y-m-d')) ? true : false); -- cgit v1.2.3