本文整理汇总了PHP中common_set_returnto函数的典型用法代码示例。如果您正苦于以下问题:PHP common_set_returnto函数的具体用法?PHP common_set_returnto怎么用?PHP common_set_returnto使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了common_set_returnto函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onEndShowHTML
function onEndShowHTML($action)
{
if (!common_logged_in()) {
// Set a place to return to when submitting forms
common_set_returnto($action->selfUrl());
}
}
示例2: prepare
function prepare($args)
{
parent::prepare($args);
if (!common_logged_in()) {
common_set_returnto($_SERVER['REQUEST_URI']);
if (Event::handle('RedirectToLogin', array($this, null))) {
common_redirect(common_local_url('login'), 303);
}
}
$id = $this->trimmed('id');
if (!$id) {
$this->profile = false;
} else {
$this->profile = Profile::staticGet('id', $id);
if (!$this->profile) {
// TRANS: Client error displayed when referring to non-existing profile ID.
$this->clientError(_('No profile with that ID.'));
return false;
}
}
$current = common_current_user()->getProfile();
if ($this->profile && !$current->canTag($this->profile)) {
// TRANS: Client error displayed when trying to tag a user that cannot be tagged.
$this->clientError(_('You cannot tag this user.'));
}
return true;
}
示例3: prepare
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;
}
示例4: prepare
/**
* 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;
}
示例5: prepare
/**
* Read and validate arguments
*
* @param array $args URL parameters
*
* @return boolean success value
*/
function prepare($args)
{
parent::prepare($args);
$this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
common_set_returnto($this->selfUrl());
return true;
}
示例6: prepare
/**
* 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;
}
示例7: prepare
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;
}
示例8: prepare
/**
* 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_logged_in()) {
// TRANS: Error message displayed when trying to perform an action that requires a logged in user.
$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 {
$this->user = common_current_user();
$sdate = !isset($_REQUEST['sdate']) ? new DateTime('first day of this month') : new DateTime($_REQUEST['sdate']);
$edate = !isset($_REQUEST['edate']) ? new DateTime('last day of this month') : new DateTime($_REQUEST['edate']);
// Custom date range
$this->sa = Social_analytics::init($this->user->id, $sdate, $edate);
}
}
return true;
}
示例9: prepare
/**
* Read and validate arguments
*
* @param array $args URL parameters
*
* @return boolean success value
*/
function prepare($args)
{
parent::prepare($args);
$this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
if ($this->page > MAX_PUBLIC_PAGE) {
// TRANS: Client error displayed when requesting a public timeline page beyond the page limit.
// TRANS: %s is the page limit.
$this->clientError(sprintf(_('Beyond the page limit (%s).'), MAX_PUBLIC_PAGE));
}
common_set_returnto($this->selfUrl());
$this->userProfile = Profile::current();
$user = common_current_user();
if (!empty($user) && $user->streamModeOnly()) {
$stream = new PublicNoticeStream($this->userProfile);
} else {
$stream = new ThreadingPublicNoticeStream($this->userProfile);
}
$this->notice = $stream->getNotices(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
if (!$this->notice) {
// TRANS: Server error displayed when a public timeline cannot be retrieved.
$this->serverError(_('Could not retrieve public timeline.'));
return;
}
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;
}
示例10: prepare
/**
* 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;
}
示例11: prepare
/**
* Prepare the object
*
* Check the input values and initialize the object.
* Shows an error page on bad input.
*
* @param array $args $_REQUEST data
*
* @return boolean success flag
*/
function prepare($args)
{
parent::prepare($args);
$nickname = common_canonical_nickname($this->arg('nickname'));
$this->user = User::staticGet('nickname', $nickname);
if (!$this->user) {
// TRANS: Client error displayed when trying to reply to a non-exsting user.
$this->clientError(_('No such user.'));
return false;
}
$profile = $this->user->getProfile();
if (!$profile) {
// TRANS: Error message displayed when referring to a user without a profile.
$this->serverError(_('User has no profile.'));
return false;
}
$this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
common_set_returnto($this->selfUrl());
$stream = new ReplyNoticeStream($this->user->id, Profile::current());
$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;
}
示例12: handle
/**
* 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();
}
}
}
}
示例13: doPost
/**
* Check the login data
*
* Determines if the login data is valid. If so, logs the user
* in, and redirects to the 'with friends' page, or to the stored
* return-to URL.
*
* @return void
*/
protected function doPost()
{
// XXX: login throttle
$nickname = $this->trimmed('nickname');
$password = $this->arg('password');
$user = common_check_user($nickname, $password);
if (!$user instanceof User) {
// TRANS: Form validation error displayed when trying to log in with incorrect credentials.
throw new ServerException(_('Incorrect username or password.'));
}
// success!
if (!common_set_user($user)) {
// TRANS: Server error displayed when during login a server error occurs.
throw new ServerException(_('Error setting user. You are probably not authorized.'));
}
common_real_login(true);
$this->updateScopedProfile();
if ($this->boolean('rememberme')) {
common_rememberme($user);
}
$url = common_get_returnto();
if ($url) {
// We don't have to return to it again
common_set_returnto(null);
$url = common_inject_session($url);
} else {
$url = common_local_url('all', array('nickname' => $this->scoped->nickname));
}
common_redirect($url, 303);
}
示例14: prepare
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;
}
示例15: prepare
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;
}