/** * Load attributes based on database arguments * * Loads all the DB stuff * * @param array $args $_REQUEST array * * @return success flag */ protected function prepare(array $args = array()) { parent::prepare($args); if ($this->boolean('ajax')) { GNUsocial::setApi(true); } $this->notice = $this->getNotice(); if (!$this->notice->inScope($this->scoped)) { // TRANS: Client exception thrown when trying a view a notice the user has no access to. throw new ClientException(_('Access restricted.'), 403); } $this->profile = $this->notice->getProfile(); if (!$this->profile instanceof Profile) { // TRANS: Server error displayed trying to show a notice without a connected profile. $this->serverError(_('Notice has no profile.'), 500); } try { $this->user = $this->profile->getUser(); } catch (NoSuchUserException $e) { // FIXME: deprecate $this->user stuff in extended classes $this->user = null; } try { $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE); } catch (Exception $e) { $this->avatar = null; } return true; }
protected function prepare(array $args = array()) { if (!isset($args['format'])) { $args['format'] = $this->defaultformat; } parent::prepare($args); $this->xrd = new XML_XRD(); return true; }
/** * Initialization. * * @param array $args Web and URL arguments * * @return boolean false if id not passed in */ protected function prepare(array $args = array()) { parent::prepare($args); $convId = $this->int('id'); $this->conv = Conversation::getKV('id', $convId); if (!$this->conv instanceof Conversation) { throw new ClientException('Could not find specified conversation'); } return true; }
protected function prepare(array $args = array()) { parent::prepare($args); $args = $this->returnToArgs(); $this->photoid = $args[1]['photoid']; $this->photo = GNUsocialPhoto::getKV('id', $this->photoid); $this->notice = Notice::getKV('id', $this->photo->notice_id); $this->user = Profile::getKV('id', $this->notice->profile_id); $this->conv = $this->notice->getConversation(); return true; }
/** * Load attributes based on database arguments * * Loads all the DB stuff * * @param array $args $_REQUEST array * * @return success flag */ protected function prepare(array $args = array()) { parent::prepare($args); if ($id = $this->trimmed('attachment')) { $this->attachment = File::getKV($id); } if (!$this->attachment instanceof File) { // TRANS: Client error displayed trying to get a non-existing attachment. $this->clientError(_('No such attachment.'), 404); } return true; }
protected function prepare(array $args = array()) { // this will call ->doPreparation() which child classes use to set $this->target parent::prepare($args); if ($this->target->hasRole(Profile_role::SILENCED) && (!$this->scoped instanceof Profile || !$this->scoped->hasRight(Right::SILENCEUSER))) { throw new ClientException(_('This profile has been silenced by site moderators'), 403); } $this->tag = $this->trimmed('tag'); $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1; common_set_returnto($this->selfUrl()); return true; }
protected function prepare(array $args = array()) { parent::prepare($args); $this->form = $this->form ?: $this->action; $this->args['form'] = $this->form; $this->type = !is_null($this->type) ? $this->type : $this->trimmed('type'); $this->args['context'] = $this->trimmed('action'); // reply for notice for example if (!$this->type) { $this->type = null; } return true; }
protected function prepare(array $args = array()) { parent::prepare($args); $taginput = $this->trimmed('tag'); $this->tag = common_canonical_tag($taginput); if (empty($this->tag)) { common_redirect(common_local_url('publictagcloud'), 301); } // after common_canonical_tag we have a lowercase, no-specials tag string if ($this->tag !== $taginput) { common_redirect(common_local_url('tag', array('tag' => $this->tag)), 301); } $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1; common_set_returnto($this->selfUrl()); $this->notice = Notice_tag::getStream($this->tag)->getNotices(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); if ($this->page > 1 && $this->notice->N == 0) { // TRANS: Client error when page not found (404). $this->clientError(_('No such page.'), 404); } return true; }