function prepare($args) { parent::prepare($args); $nickname_arg = $this->arg('nickname'); $nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname if ($nickname_arg != $nickname) { $args = array('nickname' => $nickname); if ($this->arg('page') && $this->arg('page') != 1) { $args['page'] = $this->arg['page']; } common_redirect(common_local_url($this->trimmed('action'), $args), 301); return false; } $this->user = User::staticGet('nickname', $nickname); if (!$this->user) { // TRANS: Client error displayed when calling a profile action without specifying a user. $this->clientError(_('No such user.'), 404); return false; } $this->profile = $this->user->getProfile(); if (!$this->profile) { // TRANS: Server error displayed when calling a profile action while the specified user does not have a profile. $this->serverError(_('User has no profile.')); return false; } $this->tag = $this->trimmed('tag'); $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1; common_set_returnto($this->selfUrl()); return true; }
function prepare($args) { parent::prepare($args); $nickname_arg = $this->arg('nickname'); $nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname if ($nickname_arg != $nickname) { $args = array('nickname' => $nickname); if ($this->arg('page') && $this->arg('page') != 1) { $args['page'] = $this->arg['page']; } common_redirect(common_local_url($this->trimmed('action'), $args), 301); return false; } $this->user = User::staticGet('nickname', $nickname); if (!$this->user) { $this->clientError(_('No such user.'), 404); return false; } $this->profile = $this->user->getProfile(); if (!$this->profile) { $this->serverError(_('User has no profile.')); return false; } $this->tag = $this->trimmed('tag'); $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1; common_set_returnto($this->selfUrl()); return true; }
/** * Handle the request * * On GET, show the form. On POST, try to save the app. * * @param array $args unused * * @return void */ function handle($args) { parent::handle($args); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->handlePost($args); } else { $this->showForm(); } }
function handle($args) { parent::handle($args); # Post from the tag dropdown; redirect to a GET if ($_SERVER['REQUEST_METHOD'] == 'POST') { common_redirect($this->selfUrl(), 303); return; } $this->showPage(); }
function prepare($args) { OwnerDesignAction::prepare($args); $this->id = $this->trimmed('id'); $this->vid = Video::getKV('id', $this->id); if (empty($this->vid)) { throw new ClientException(_('No such video.'), 404); } $this->notice = $this->vid->getNotice(); if (empty($this->notice)) { throw new ClientException(_('No such video'), 404); } $this->user = User::getKV('id', $this->vid->profile_id); if (empty($this->user)) { throw new ClientException(_('No such user.'), 404); } $this->profile = $this->user->getProfile(); if (empty($this->profile)) { throw new ServerException(_('User without a profile.')); } return true; }
function prepare($args) { OwnerDesignAction::prepare($args); // skip the ProfileAction code and replace it... $id = $this->arg('id'); $this->user = false; $this->profile = Profile::staticGet('id', $id); if (!$this->profile) { $this->serverError(_('User has no profile.')); return false; } $user = User::staticGet('id', $this->profile->id); if ($user) { // This is a local user -- send to their regular profile. $url = common_local_url('showstream', array('nickname' => $user->nickname)); common_redirect($url); return false; } $this->tag = $this->trimmed('tag'); $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1; common_set_returnto($this->selfUrl()); return true; }
/** * For initializing members of the class. * * @param array $argarray misc. arguments * * @return boolean true */ function prepare($argarray) { OwnerDesignAction::prepare($argarray); $this->id = $this->trimmed('id'); $this->bookmark = Bookmark::staticGet('id', $this->id); if (empty($this->bookmark)) { throw new ClientException(_('No such bookmark.'), 404); } $this->notice = Notice::staticGet('uri', $this->bookmark->uri); if (empty($this->notice)) { // Did we used to have it, and it got deleted? throw new ClientException(_('No such bookmark.'), 404); } $this->user = User::staticGet('id', $this->bookmark->profile_id); if (empty($this->user)) { throw new ClientException(_('No such user.'), 404); } $this->profile = $this->user->getProfile(); if (empty($this->profile)) { throw new ServerException(_('User without a profile.')); } $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE); return true; }
/** * Hook for adding extra JavaScript * * @param Action $action Action object for the page * * @return boolean event handler return */ function showScripts() { parent::showScripts(); $jsonArray = array(); while ($this->notice->fetch()) { if (!empty($this->notice->lat) && !empty($this->notice->lon)) { $jsonNotice = $this->noticeAsJson($this->notice); $jsonArray[] = $jsonNotice; } } $this->inlineScript('$(document).ready(function() { ' . ' var _notices = ' . json_encode($jsonArray) . '; ' . 'showMapstraction($("#map_canvas"), _notices); });'); return true; }
/** * Add a confirm script for Consumer key/secret reset * * @return void */ function showScripts() { parent::showScripts(); $msg = _('Are you sure you want to reset your consumer key and secret?'); $js = 'function confirmReset() { '; $js .= ' var agree = confirm("' . $msg . '"); '; $js .= ' return agree;'; $js .= '}'; $this->inlineScript($js); }
/** * Handle input * * Only handles get, so just show the page. * * @param array $args $_REQUEST data (unused) * * @return void */ function handle($args) { parent::handle($args); if ($this->notice->is_local == Notice::REMOTE_OMB) { if (!empty($this->notice->url)) { $target = $this->notice->url; } else { if (!empty($this->notice->uri) && preg_match('/^https?:/', $this->notice->uri)) { // Old OMB posts saved the remote URL only into the URI field. $target = $this->notice->uri; } else { // Shouldn't happen. $target = false; } } if ($target && $target != $this->selfUrl()) { common_redirect($target, 301); return false; } } $this->showPage(); }
/** * Handle a request * * Just show the page. All args already handled. * * @param array $args $_REQUEST data * * @return void */ function handle($args) { parent::handle($args); $this->showPage(); }