From: Mikael Nordfeldth Date: Mon, 23 Nov 2015 13:40:59 +0000 (+0100) Subject: Events listing, but the stream will change soon X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=fbe0e68617483c5ff277626806fb9ecb9b06db7a;p=quix0rs-gnu-social.git Events listing, but the stream will change soon --- diff --git a/plugins/Event/EventPlugin.php b/plugins/Event/EventPlugin.php index 7f2712b148..0c520ddb7a 100644 --- a/plugins/Event/EventPlugin.php +++ b/plugins/Event/EventPlugin.php @@ -90,6 +90,10 @@ class EventPlugin extends MicroAppPlugin array('id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}')); $m->connect('main/event/updatetimes', array('action' => 'timelist')); + + $m->connect(':nickname/events', + array('action' => 'events'), + array('nickname' => Nickname::DISPLAY_FMT)); return true; } @@ -516,4 +520,14 @@ class EventPlugin extends MicroAppPlugin $out->raw($rsvp->asHTML()); $out->elementEnd('div'); } + + function onEndPersonalGroupNav(Menu $menu, Profile $target, Profile $scoped=null) + { + $menu->menuItem(common_local_url('events', array('nickname' => $target->getNickname())), + // TRANS: Menu item in sample plugin. + _m('Happenings'), + // TRANS: Menu item title in sample plugin. + _m('A list of your events'), false, 'nav_timeline_events'); + return true; + } } diff --git a/plugins/Event/actions/events.php b/plugins/Event/actions/events.php new file mode 100644 index 0000000000..1de46a786d --- /dev/null +++ b/plugins/Event/actions/events.php @@ -0,0 +1,56 @@ +target, $this->scoped); + return $stream; + } + + function title() + { + // TRANS: Page title for sample plugin. %s is a user nickname. + return sprintf(_m('%s\'s happenings'), $this->target->getNickname()); + } + + function getFeeds() + { + return array( + ); + } + + function showEmptyList() { + $message = sprintf(_('This is %1$s\'s event stream, but %1$s hasn\'t received any events yet.'), $this->target->getNickname()) . ' '; + + $this->elementStart('div', 'guide'); + $this->raw(common_markup_to_html($message)); + $this->elementEnd('div'); + } + + /** + * Return true if read only. + * + * Some actions only read from the database; others read and write. + * The simple database load-balancer built into StatusNet will + * direct read-only actions to database mirrors (if they are configured), + * and read-write actions to the master database. + * + * This defaults to false to avoid data integrity issues, but you + * should make sure to overload it for performance gains. + * + * @param array $args other arguments, if RO/RW status depends on them. + * + * @return boolean is read only action? + */ + function isReadOnly($args) + { + return true; + } +} diff --git a/plugins/Event/lib/eventsnoticestream.php b/plugins/Event/lib/eventsnoticestream.php new file mode 100644 index 0000000000..1e8c4fe692 --- /dev/null +++ b/plugins/Event/lib/eventsnoticestream.php @@ -0,0 +1,63 @@ +target = $target; + } + + function getNoticeIds($offset, $limit, $since_id, $max_id) + { + $notice = new Notice(); + $qry = null; + + $qry = 'SELECT notice.* FROM notice '; + $qry .= 'INNER JOIN happening ON happening.uri = notice.uri '; + $qry .= 'WHERE happening.profile_id = ' . $this->target->getID() . ' '; + $qry .= 'AND notice.is_local != ' . Notice::GATEWAY . ' '; + + if ($since_id != 0) { + $qry .= 'AND notice.id > ' . $since_id . ' '; + } + + if ($max_id != 0) { + $qry .= 'AND notice.id <= ' . $max_id . ' '; + } + + // NOTE: we sort by bookmark time, not by notice time! + $qry .= 'ORDER BY created DESC '; + if (!is_null($offset)) { + $qry .= "LIMIT $limit OFFSET $offset"; + } + + $notice->query($qry); + $ids = array(); + while ($notice->fetch()) { + $ids[] = $notice->id; + } + + $notice->free(); + unset($notice); + return $ids; + } +} + +class EventsNoticeStream extends ScopingNoticeStream +{ + function __construct(Profile $target, Profile $scoped=null) + { + $stream = new RawEventsNoticeStream($target); + + if ($target->sameAs($scoped)) { + $key = 'bookmark:ids_by_user_own:'.$target->getID(); + } else { + $key = 'bookmark:ids_by_user:'.$target->getID(); + } + + parent::__construct(new CachingNoticeStream($stream, $key), $scoped); + } +}