/** * Take arguments for running * * This method is called first, and it lets the action class get * all its arguments and validate them. It's also the time * to fetch any relevant data from the database. * * Action classes should run parent::prepare($args) as the first * line of this method to make sure the default argument-processing * happens. * * @param array $args $_REQUEST args * * @return boolean success flag */ function prepare($args) { parent::prepare($args); if (common_config('singleuser', 'enabled')) { $nickname = User::singleUserNickname(); } else { // PHP 5.4 // $nickname = $this->returnToArgs()[1]['nickname']; // PHP < 5.4 $nickname = $this->returnToArgs(); $nickname = $nickname[1]['nickname']; } $this->user = User::staticGet('nickname', $nickname); if (!$this->user) { // TRANS: Client error displayed when trying to display bookmarks for a non-existing user. $this->clientError(_('No such user.')); return false; } $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1; $stream = new BookmarksNoticeStream($this->user->id, true); $this->notices = $stream->getNotices(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); if ($this->page > 1 && $this->notices->N == 0) { throw new ClientException(_('No such page.'), 404); } return true; }
protected function getNotices() { $stream = new BookmarksNoticeStream($this->target->getID(), true); return $stream->getNotices(0, $this->limit)->fetchAll(); }