/** * Get notices * * @return array notices */ function getNotices() { $notices = array(); $stream = new PeopletagNoticeStream($this->list); $notice = $stream->getNotices(($this->page - 1) * $this->count, $this->count, $this->since_id, $this->max_id); $notices = $notice->fetchAll(); NoticeList::prefill($notices); return $notices; }
function prepare($args) { parent::prepare($args); if (common_config('singleuser', 'enabled')) { $tagger_arg = User::singleUserNickname(); } else { $tagger_arg = $this->arg('tagger'); } $tag_arg = $this->arg('tag'); $tagger = common_canonical_nickname($tagger_arg); $tag = common_canonical_tag($tag_arg); // Permanent redirect on non-canonical nickname if ($tagger_arg != $tagger || $tag_arg != $tag) { $args = array('tagger' => $nickname, 'tag' => $tag); if ($this->page != 1) { $args['page'] = $this->page; } common_redirect(common_local_url('showprofiletag', $args), 301); return false; } if (!$tagger) { // TRANS: Client error displayed when a tagger is expected but not provided. $this->clientError(_('No tagger.'), 404); return false; } $user = User::staticGet('nickname', $tagger); if (!$user) { // TRANS: Client error displayed trying to perform an action related to a non-existing user. $this->clientError(_('No such user.'), 404); return false; } $this->tagger = $user->getProfile(); $this->peopletag = Profile_list::pkeyGet(array('tagger' => $user->id, 'tag' => $tag)); $current = common_current_user(); $can_see = !empty($this->peopletag) && (!$this->peopletag->private || $this->peopletag->private && $this->peopletag->tagger === $current->id); if (!$can_see) { // TRANS: Client error displayed trying to reference a non-existing list. $this->clientError(_('No such list.'), 404); return false; } $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1; $this->userProfile = Profile::current(); $stream = new PeopletagNoticeStream($this->peopletag, $this->userProfile); $this->notice = $stream->getNotices(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); if ($this->page > 1 && $this->notice->N == 0) { // TRANS: Server error when page not found (404). $this->serverError(_('No such page.'), $code = 404); } return true; }
/** * Query notices by users associated with this tag, * but first check the cache before hitting the DB. * * @param integer $offset offset * @param integer $limit maximum no of results * @param integer $since_id=null since this id * @param integer $max_id=null maximum id in result * * @return Notice the query */ function getNotices($offset, $limit, $since_id = null, $max_id = null) { $stream = new PeopletagNoticeStream($this); return $stream->getNotices($offset, $limit, $since_id, $max_id); }