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('usergroups', $args), 301); return false; } $this->user = User::staticGet('nickname', $nickname); if (!$this->user) { $this->clientError(_('用户不存在'), 404); return false; } $this->profile = $this->user->getProfile(); if (!$this->profile) { $this->serverError(_('无该用户资料')); return false; } $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1; return true; }
function prepare($args) { parent::prepare($args); if (common_config('singleuser', 'enabled')) { $nickname_arg = User::singleUserNickname(); } else { $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('peopletagsforuser', $args), 301); } $this->user = User::getKV('nickname', $nickname); if (!$this->user) { // TRANS: Client error displayed trying to perform an action related to a non-existing user. $this->clientError(_('No such user.'), 404); } $this->tagged = $this->user->getProfile(); if (!$this->tagged) { // TRANS: Error message displayed when referring to a user without a profile. $this->serverError(_('User has no profile.')); } $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1; 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(_m('No such user.'), 404); return false; } $this->profile = $this->user->getProfile(); if (!$this->profile) { $this->serverError(_m('User has no profile.')); return false; } $page = $this->trimmed('page'); if (!empty($page) && Validate::number($page)) { $this->page = $page + 0; } else { $this->page = 1; } $this->notices = empty($this->tag) ? $this->user->getNotices(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1) : $this->user->getTaggedNotices($this->tag, ($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, 0, 0, null); return true; }
function prepare($args) { parent::prepare($args); $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1; $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->page != 1) { $args['page'] = $this->page; } common_redirect(common_local_url('groupmembers', $args), 301); return false; } if (!$nickname) { // TRANS: Client error displayed when trying to view group members without providing a group nickname. $this->clientError(_('No nickname.'), 404); return false; } $local = Local_group::staticGet('nickname', $nickname); if (!$local) { // TRANS: Client error displayed when trying to view group members for a non-existing group. $this->clientError(_('No such group.'), 404); return false; } $this->group = User_group::staticGet('id', $local->group_id); if (!$this->group) { // TRANS: Client error displayed when trying to view group members for an object that is not a group. $this->clientError(_('No such group.'), 404); return false; } return true; }
function prepare($args) { parent::prepare($args); $nickname_arg = $this->arg('nickname'); if (empty($nickname_arg)) { $this->clientError(_('No such group.'), 404); return false; } $this->nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname if ($nickname_arg != $this->nickname) { common_redirect(common_local_url('foafgroup', array('nickname' => $this->nickname)), 301); return false; } $local = Local_group::staticGet('nickname', $this->nickname); if (!$local) { $this->clientError(_('No such group.'), 404); return false; } $this->group = User_group::staticGet('id', $local->group_id); if (!$this->group) { $this->clientError(_('No such group.'), 404); return false; } common_set_returnto($this->selfUrl()); return true; }
protected function doPost() { try { $request = Subscription_queue::pkeyGet(array('subscriber' => $this->scoped->id, 'subscribed' => $this->target->id)); if ($request instanceof Subscription_queue) { $request->abort(); } } catch (AlreadyFulfilledException $e) { common_debug('Tried to cancel a non-existing pending subscription'); } if (GNUsocial::isAjax()) { $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); // TRANS: Title after unsubscribing from a group. $this->element('title', null, _m('TITLE', 'Unsubscribed')); $this->elementEnd('head'); $this->elementStart('body'); $subscribe = new SubscribeForm($this, $this->target); $subscribe->show(); $this->elementEnd('body'); $this->endHTML(); exit; } common_redirect(common_local_url('subscriptions', array('nickname' => $this->scoped->getNickname())), 303); }
function prepare($args) { parent::prepare($args); $nickname_arg = $this->arg('nickname'); if (empty($nickname_arg)) { // TRANS: Client error displayed when requesting Friends of a Friend feed without providing a user nickname. $this->clientError(_('No such user.'), 404); return false; } $this->nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname if ($nickname_arg != $this->nickname) { common_redirect(common_local_url('foaf', array('nickname' => $this->nickname)), 301); return false; } $this->user = User::staticGet('nickname', $this->nickname); if (!$this->user) { // TRANS: Client error displayed when requesting Friends of a Friend feed for an object that is not a user. $this->clientError(_('No such user.'), 404); return false; } $this->profile = $this->user->getProfile(); if (!$this->profile) { // TRANS: Error message displayed when referring to a user without a profile. $this->serverError(_('User has no profile.'), 500); return false; } return true; }
protected function doPreparation() { // showstream requires a nickname $nickname_arg = $this->trimmed('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->getActionName(), $args), 301); } try { $user = User::getByNickname($nickname); } catch (NoSuchUserException $e) { $group = Local_group::getKV('nickname', $nickname); if ($group instanceof Local_group) { common_redirect($group->getProfile()->getUrl()); } // No user nor group found, throw the NoSuchUserException again throw $e; } $this->target = $user->getProfile(); }
function prepare($args) { parent::prepare($args); $nickname_arg = $this->arg('nickname'); if (empty($nickname_arg)) { $this->clientError(_('用户不存在'), 404); return false; } $this->nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname if ($nickname_arg != $this->nickname) { common_redirect(common_local_url('foaf', array('nickname' => $this->nickname)), 301); return false; } $this->user = User::staticGet('nickname', $this->nickname); if (!$this->user) { $this->clientError(_('用户不存在'), 404); return false; } $this->profile = $this->user->getProfile(); if (!$this->profile) { $this->serverError(_('无该用户资料'), 500); return false; } return true; }
/** * For initializing members of the class. * * @param array $argarray misc. arguments * * @return boolean true */ function prepare($argarray) { parent::prepare($argarray); $cur = common_current_user(); if (empty($cur)) { throw new ClientException(_('Only for logged-in users'), 403); } $nicknameArg = $this->trimmed('nickname'); $nickname = common_canonical_nickname($nicknameArg); if ($nickname != $nicknameArg) { $url = common_local_url('groupinbox', array('nickname' => $nickname)); common_redirect($url); return false; } $localGroup = Local_group::staticGet('nickname', $nickname); if (empty($localGroup)) { throw new ClientException(_('No such group'), 404); } $this->group = User_group::staticGet('id', $localGroup->group_id); if (empty($this->group)) { throw new ClientException(_('No such group'), 404); } if (!$cur->isMember($this->group)) { throw new ClientException(_('Only for members'), 403); } $this->page = $this->trimmed('page'); if (!$this->page) { $this->page = 1; } $this->gm = Group_message::forGroup($this->group, ($this->page - 1) * MESSAGES_PER_PAGE, MESSAGES_PER_PAGE + 1); return true; }
function handlePost($args) { /* // Workaround for PHP returning empty $_POST and $_FILES when POST // length > post_max_size in php.ini if (empty($_FILES) && empty($_POST) && ($_SERVER['CONTENT_LENGTH'] > 0) ) { $msg = _('The server was unable to handle that much POST ' . 'data (%s bytes) due to its current configuration.'); $this->showForm(sprintf($msg, $_SERVER['CONTENT_LENGTH'])); return; } */ $profile = $this->user->getProfile(); $options = array(); ToSelector::fillOptions($this, $options); try { $this->handleUpload(); } catch (Exception $e) { $this->showForm($e->getMessage()); return; } common_redirect($photo->uri, 303); }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag */ function prepare($args) { parent::prepare($args); $this->checkSessionToken(); if (!common_logged_in()) { if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->clientError(_('Not logged in.')); } else { // Redirect to login. common_set_returnto($this->selfUrl()); $user = common_current_user(); if (Event::handle('RedirectToLogin', array($this, $user))) { common_redirect(common_local_url('login'), 303); } } return false; } $id = $this->trimmed('profileid'); if (!$id) { $this->clientError(_('No profile specified.')); return false; } $this->profile = Profile::staticGet('id', $id); if (!$this->profile) { $this->clientError(_('No profile with that ID.')); return false; } return true; }
/** * Prepare for the action * * We check to see that the user is logged in, has * authenticated in this session, and has the right * to configure the site. * * @param array $args Array of arguments from Web driver * * @return boolean success flag */ function prepare($args) { parent::prepare($args); // User must be logged in. if (!common_logged_in()) { // TRANS: Error message displayed when trying to perform an action that requires a logged in user. $this->clientError(_('Not logged in.')); } $user = common_current_user(); // ...because they're logged in assert(!empty($user)); // It must be a "real" login, not saved cookie login if (!common_is_real_login()) { // Cookie theft is too easy; we require automatic // logins to re-authenticate before admining the site common_set_returnto($this->selfUrl()); if (Event::handle('RedirectToLogin', array($this, $user))) { common_redirect(common_local_url('login'), 303); } } // User must have the right to change admin settings if (!$user->hasRight(Right::CONFIGURESITE)) { // TRANS: Client error message thrown when a user tries to change admin settings but has no access rights. $this->clientError(_('You cannot make changes to this site.')); } // This panel must be enabled $name = $this->trimmed('action'); $name = mb_substr($name, 0, -10); if (!self::canAdmin($name)) { // TRANS: Client error message throw when a certain panel's settings cannot be changed. $this->clientError(_('Changes to that panel are not allowed.'), 403); } 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) { // 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: Error message displayed when referring to a user without 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; }
/** * Prepare page to run * * * @param $args * @return string title */ function prepare($args) { parent::prepare($args); $this->code = $this->trimmed('code'); // @todo this check should really be in index.php for all sensitive actions $ssl = common_config('site', 'ssl'); if (empty($_SERVER['HTTPS']) && ($ssl == 'always' || $ssl == 'sometimes')) { common_redirect(common_local_url('register')); // exit } if (empty($this->code)) { common_ensure_session(); if (array_key_exists('invitecode', $_SESSION)) { $this->code = $_SESSION['invitecode']; } } if (common_config('site', 'inviteonly') && empty($this->code)) { $this->clientError(_('Sorry, only invited people can register.')); return false; } if (!empty($this->code)) { $this->invite = Invitation::staticGet('code', $this->code); if (empty($this->invite)) { $this->clientError(_('Sorry, invalid invitation code.')); return false; } // Store this in case we need it common_ensure_session(); $_SESSION['invitecode'] = $this->code; } 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); common_redirect(common_local_url('hcard', $args), 301); return false; } $this->user = User::staticGet('nickname', $nickname); if (!$this->user) { // TRANS: Client error displayed when trying to get a user hCard for a non-existing user. $this->clientError(_('No such user.'), 404); return false; } $this->profile = $this->user->getProfile(); if (!$this->profile) { // TRANS: Server error displayed when trying to get a user hCard for a user without a profile. $this->serverError(_('User has no profile.')); return false; } return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag */ function prepare($args) { parent::prepare($args); $user = common_current_user(); // User must be logged in. if (!common_logged_in()) { $this->clientError(_('Not logged in.')); return; } $user = common_current_user(); // ...because they're logged in assert(!empty($user)); // It must be a "real" login, not saved cookie login if (!common_is_real_login()) { // Cookie theft is too easy; we require automatic // logins to re-authenticate before admining the site common_set_returnto($this->selfUrl()); if (Event::handle('RedirectToLogin', array($this, $user))) { common_redirect(common_local_url('login'), 303); } } // User must have the right to review flags if (!$user->hasRight(UserFlagPlugin::REVIEWFLAGS)) { $this->clientError(_('You cannot review profile flags.')); return false; } $this->page = $this->trimmed('page'); if (empty($this->page)) { $this->page = 1; } $this->profiles = $this->getProfiles(); return true; }
function prepare($args) { Action::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) { // TRANS: Error message displayed when referring to a user without a profile. $this->serverError(_m('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()); $p = Profile::current(); if (empty($this->tag)) { $stream = new ProfileNoticeStream($this->profile, $p); } else { $stream = new TaggedProfileNoticeStream($this->profile, $this->tag, $p); } $this->notice = $stream->getNotices(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); 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) { // 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: Error message displayed when referring to a user without a profile. $this->serverError(_('User has no profile.')); return false; } $user = common_current_user(); if ($this->profile->hasRole(Profile_role::SILENCED) && (empty($user) || !$user->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; }
/** * Prepare the action * * Reads and validates arguments and instantiates the attributes. * * @param array $args $_REQUEST args * * @return boolean success flag */ 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); common_redirect(common_local_url('showgroup', $args), 301); return false; } if (!$nickname) { // TRANS: Client error displayed when requesting a group RSS feed without providing a group nickname. $this->clientError(_('No nickname.'), 404); return false; } $local = Local_group::staticGet('nickname', $nickname); if (!$local) { // TRANS: Client error displayed when requesting a group RSS feed for group that does not exist. $this->clientError(_('No such group.'), 404); return false; } $this->group = User_group::staticGet('id', $local->group_id); if (!$this->group) { // TRANS: Client error displayed when requesting a group RSS feed for an object that is not a group. $this->clientError(_('No such group.'), 404); return false; } $this->notices = $this->getNotices($this->limit); return true; }
/** * Handle input and output a page * * @param array $args $_REQUEST arguments * * @return void */ function handle($args) { parent::handle($args); if (!common_logged_in()) { $this->clientError(_('Not logged in.')); return; } else { if (!common_is_real_login()) { // Cookie theft means that automatic logins can't // change important settings or see private info, and // _all_ our settings are important common_set_returnto($this->selfUrl()); $user = common_current_user(); if (Event::handle('RedirectToLogin', array($this, $user))) { common_redirect(common_local_url('login'), 303); } } else { if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->handlePost(); } else { $this->showForm(); } } } }
/** * For initializing members of the class. * * @param array $argarray misc. arguments * * @return boolean true */ function prepare($argarray) { parent::prepare($argarray); $cur = common_current_user(); if (empty($cur)) { // TRANS: Client exception thrown when trying to view group inbox while not logged in. throw new ClientException(_m('Only for logged-in users.'), 403); } $nicknameArg = $this->trimmed('nickname'); $nickname = common_canonical_nickname($nicknameArg); if ($nickname != $nicknameArg) { $url = common_local_url('groupinbox', array('nickname' => $nickname)); common_redirect($url); } $localGroup = Local_group::getKV('nickname', $nickname); if (empty($localGroup)) { // TRANS: Client exception thrown when trying to view group inbox for non-existing group. throw new ClientException(_m('No such group.'), 404); } $this->group = User_group::getKV('id', $localGroup->group_id); if (empty($this->group)) { // TRANS: Client exception thrown when trying to view group inbox for non-existing group. throw new ClientException(_m('No such group.'), 404); } if (!$cur->isMember($this->group)) { // TRANS: Client exception thrown when trying to view group inbox while not a member. throw new ClientException(_m('Only for members.'), 403); } $this->page = $this->trimmed('page'); if (!$this->page) { $this->page = 1; } $this->gm = Group_message::forGroup($this->group, ($this->page - 1) * MESSAGES_PER_PAGE, MESSAGES_PER_PAGE + 1); return true; }
/** * Class handler. * * @param array $args query arguments * * @return boolean false if nickname or user isn't found */ protected function handle() { parent::handle(); $nickname = $this->trimmed('nickname'); if (!$nickname) { // TRANS: Client error displayed trying to get an avatar without providing a nickname. $this->clientError(_('No nickname.')); } $size = $this->trimmed('size') ?: 'original'; $user = User::getKV('nickname', $nickname); if (!$user) { // TRANS: Client error displayed trying to get an avatar for a non-existing user. $this->clientError(_('No such user.')); } $profile = $user->getProfile(); if (!$profile) { // TRANS: Error message displayed when referring to a user without a profile. $this->clientError(_('User has no profile.')); } if ($size === 'original') { try { $avatar = Avatar::getUploaded($profile); $url = $avatar->displayUrl(); } catch (NoAvatarException $e) { $url = Avatar::defaultImage(AVATAR_PROFILE_SIZE); } } else { $url = $profile->avatarUrl($size); } common_redirect($url, 302); }
/** * Prepare the action * * Reads and validates arguments and instantiates the attributes. * * @param array $args $_REQUEST args * * @return boolean success flag */ 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); common_redirect(common_local_url('showgroup', $args), 301); return false; } if (!$nickname) { $this->clientError(_('No nickname.'), 404); return false; } $local = Local_group::staticGet('nickname', $nickname); if (!$local) { $this->clientError(_('No such group.'), 404); return false; } $this->group = User_group::staticGet('id', $local->group_id); if (!$this->group) { $this->clientError(_('No such group.'), 404); return false; } $this->notices = $this->getNotices($this->limit); return true; }
function prepare($args) { parent::prepare($args); $nickname_arg = $this->arg('nickname'); if (empty($nickname_arg)) { // TRANS: Client error displayed when requesting Friends of a Friend feed without providing a group nickname. $this->clientError(_('No such group.'), 404); } $this->nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname if ($nickname_arg != $this->nickname) { common_redirect(common_local_url('foafgroup', array('nickname' => $this->nickname)), 301); return false; } $local = Local_group::getKV('nickname', $this->nickname); if (!$local) { // TRANS: Client error displayed when requesting Friends of a Friend feed for a non-local group. $this->clientError(_('No such group.'), 404); } $this->group = User_group::getKV('id', $local->group_id); if (!$this->group) { // TRANS: Client error displayed when requesting Friends of a Friend feed for a nickname that is not a group. $this->clientError(_('No such group.'), 404); } common_set_returnto($this->selfUrl()); return true; }
function prepare($args) { parent::prepare($args); $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1; $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->page != 1) { $args['page'] = $this->page; } common_redirect(common_local_url('groupmembers', $args), 301); return false; } if (!$nickname) { $this->clientError(_('No nickname.'), 404); return false; } $local = Local_group::staticGet('nickname', $nickname); if (!$local) { $this->clientError(_('No such group.'), 404); return false; } $this->group = User_group::staticGet('id', $local->group_id); if (!$this->group) { $this->clientError(_('No such group.'), 404); return false; } 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('showstream', $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->page = $this->arg('page') ? $this->arg('page') + 0 : 1; common_set_returnto($this->selfUrl()); return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag */ function prepare($args) { parent::prepare($args); $this->checkSessionToken(); if (!common_logged_in()) { if ($_SERVER['REQUEST_METHOD'] == 'POST') { // TRANS: Error message displayed when trying to perform an action that requires a logged in user. $this->clientError(_('Not logged in.')); } else { // Redirect to login. common_set_returnto($this->selfUrl()); $user = common_current_user(); if (Event::handle('RedirectToLogin', array($this, $user))) { common_redirect(common_local_url('login'), 303); } } return false; } $id = $this->trimmed('profileid'); if (!$id) { // TRANS: Client error displayed when trying to change user options without specifying a user to work on. $this->clientError(_('No profile specified.')); return false; } $this->profile = Profile::staticGet('id', $id); if (!$this->profile) { // TRANS: Client error displayed when trying to change user options without specifying an existing user to work on. $this->clientError(_('No profile with that ID.')); return false; } return true; }
function prepare($args) { parent::prepare($args); common_debug('IndexAction -> redirect -> ' . $this->lang); common_redirect(common_get_route('home', array('lang' => $this->lang)), 303); return true; }
protected function prepare(array $args = array()) { parent::prepare($args); $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1; $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->page != 1) { $args['page'] = $this->page; } common_redirect(common_local_url('groupqueue', $args), 301); } if (!$nickname) { // TRANS: Client error displayed when trying to view group members without providing a group nickname. $this->clientError(_('No nickname.'), 404); } $local = Local_group::getKV('nickname', $nickname); if (!$local) { // TRANS: Client error displayed when trying to view group members for a non-existing group. $this->clientError(_('No such group.'), 404); } $this->group = User_group::getKV('id', $local->group_id); if (!$this->group) { // TRANS: Client error displayed when trying to view group members for an object that is not a group. $this->clientError(_('No such group.'), 404); } $cur = common_current_user(); if (!$cur || !$cur->isAdmin($this->group)) { // TRANS: Client error displayed when trying to approve group applicants without being a group administrator. $this->clientError(_('Only the group admin may approve users.')); } return true; }