本文整理汇总了PHP中Controller::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::redirect方法的具体用法?PHP Controller::redirect怎么用?PHP Controller::redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controller
的用法示例。
在下文中一共展示了Controller::redirect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: startup
/**
* startup
* called after Controller::beforeFilter()
*
* @param object $controller instance of controller
* @return void
* @access public
*/
public function startup(Controller $controller)
{
// Maintenance mode OFF but on offline page -> redirect to root url
if (!$this->isOn() && strpos($controller->here, Configure::read('Maintenance.site_offline_url')) !== false) {
$controller->redirect(Router::url('/', true));
return;
}
// Maintenance mode ON user logoout allowed
if ($this->isOn() && strpos($controller->here, 'users/logout') !== false) {
return;
}
// Maintenance mode ON but not in offline page requested - > redirect to offline page
if ($this->isOn() && strpos($controller->here, Configure::read('Maintenance.site_offline_url')) === false) {
// All users auto logged off if setting is true
if (Configure::read('Maintenance.offline_destroy_session')) {
$this->Session->destroy();
}
$controller->redirect(Router::url(Configure::read('Maintenance.site_offline_url'), true));
return;
}
// Maintenance mode scheduled show message!!
if ($this->hasSchedule()) {
$this->Flash->maintenance(__('This application will be on maintenance mode at %s ', Configure::read('Maintenance.start')));
}
}
示例2: onLaunch
function onLaunch()
{
// Check the user has an appropriate role
if ($this->user->isLearner() || $this->user->isStaff()) {
$user_id = $this->user->getId();
$consumer_key = $this->consumer->getKey();
// Initialise the user session
$model = new LTILoginer();
$model->consumer_key = $consumer_key;
$model->user_id = $user_id;
// validate user and redirect if valid
if ($model->validate() && $model->login()) {
$returnUrl = Yii::app()->user->returnUrl;
if (!is_null($returnUrl)) {
$returnUrl = array('site/index');
}
$this->controller->redirect($returnUrl);
} else {
// TODO: some error message
}
/*$_SESSION['consumer_key'] = $this->consumer->getKey();
$_SESSION['resource_id'] = $this->resource_link->getId();
$_SESSION['user_consumer_key'] = $this->user->getResourceLink()
->getConsumer()
->getKey();
$_SESSION['user_id'] = $this->user->getId();
$_SESSION['isStudent'] = $this->user->isLearner();
$_SESSION['isContentItem'] = FALSE;*/
// Redirect the user to display the list of items for the resource link
/*$this->redirectURL = getAppUrl();*/
} else {
$this->reason = 'Invalid role.';
$this->isOK = FALSE;
}
}
示例3: _validateSelection
/**
* Convenience method to check for selection count and redirect request
*
* @param bool $condition True will redirect request to $options['redirect']
* @param array $options Options array as passed to process()
* @return bool True if selection is valid
*/
protected function _validateSelection($condition, $options, $messageName)
{
$messageMap = $options['messageMap'];
$message = $messageMap[$messageName];
if ($condition === true) {
$this->Session->setFlash($message, 'flash', array('class' => 'error'));
$this->_controller->redirect($options['redirect']);
}
return !$condition;
}
示例4: login
/**
* Login
*
* @return void
*/
public function login()
{
if ($this->Controller->request->is('post')) {
$user_id = $this->Controller->request->data['User']['id'];
$result = $this->Controller->User->find('first', array('conditions' => array('User.id' => $user_id), 'recursive' => -1));
if ($result) {
$this->Auth->login($result['User']);
$this->Controller->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash(__('User does not exist'));
}
}
}
示例5: redirect
/**
* Redirect to url stored in Data.referer or default $url
*
* @param mixed the url to redirect to
* @param integer http status code, default is null
* @param boolean calling php exit or not after redirect, default is true
* @return mixed
*/
public function redirect($url, $status = null, $exit = true)
{
if (isset($this->Controller->data['Data']['referer'])) {
$referer = $this->Controller->request->data['Data']['referer'];
} else {
$referer = $this->Controller->request->referer();
}
if (strlen($referer) == 0 || $referer == '/') {
$this->Controller->redirect($url, $status, $exit);
} else {
$this->Controller->redirect($referer, $status, $exit);
}
}
示例6: checkPermissionForProtectedHomeDirs
public static function checkPermissionForProtectedHomeDirs($strFile)
{
$strUuid = \Config::get('protectedHomeDirRoot');
if (!$strFile) {
return;
}
if ($strUuid && ($strProtectedHomeDirRootPath = \HeimrichHannot\HastePlus\Files::getPathFromUuid($strUuid)) !== null) {
// check only if path inside the protected root dir
if (StringUtil::startsWith($strFile, $strProtectedHomeDirRootPath)) {
if (FE_USER_LOGGED_IN) {
if (($objFrontendUser = \FrontendUser::getInstance()) !== null) {
if (\Config::get('allowAccessByMemberId') && $objFrontendUser->assignProtectedDir && $objFrontendUser->protectedHomeDir) {
$strProtectedHomeDirMemberRootPath = Files::getPathFromUuid($objFrontendUser->protectedHomeDir);
// fe user id = dir owner member id
if (StringUtil::startsWith($strFile, $strProtectedHomeDirMemberRootPath)) {
return;
}
}
if (\Config::get('allowAccessByMemberGroups')) {
$arrAllowedGroups = deserialize(\Config::get('allowedMemberGroups'), true);
if (array_intersect(deserialize($objFrontendUser->groups, true), $arrAllowedGroups)) {
return;
}
}
}
}
$intNoAccessPage = \Config::get('jumpToNoAccess');
if ($intNoAccessPage && ($objPageJumpTo = \PageModel::findByPk($intNoAccessPage)) !== null) {
\Controller::redirect(\Controller::generateFrontendUrl($objPageJumpTo->row()));
} else {
die($GLOBALS['TL_LANG']['MSC']['noAccessDownload']);
}
}
}
}
示例7: deletePosition
public function deletePosition($params){
//Check session user
parent::userInfoAndSession();
if($this->db->deletePosition($params)) parent::redirect('cms'.DS.'carriere'.DS.'position', 'success');
else parent::redirect('cms'.DS.'carriere'.DS.'position', 'error');
}
示例8: checkPermission
/**
* Check permissions to edit table.
*/
public function checkPermission()
{
if (!\BackendUser::getInstance()->isAdmin) {
\System::log('Not enough permissions to access leads export ID "' . \Input::get('id') . '"', __METHOD__, TL_ERROR);
\Controller::redirect('contao/main.php?act=error');
}
}
示例9: runAction
protected function runAction()
{
global $objPage;
switch (\Input::get('act')) {
case WATCHLIST_ACT_DELETE:
Watchlist::getInstance()->deleteItem(\Input::get('id'));
break;
case WATCHLIST_ACT_ADD:
$objItem = new WatchlistItemModel();
$objItem->pid = Watchlist::getInstance()->getId();
$objItem->uuid = \Input::get('id');
$objItem->pageID = $objPage->id;
$objItem->cid = \Input::get('cid');
$objItem->type = \Input::get('type');
$objItem->title = \Input::get('title');
$objItem->tstamp = time();
Watchlist::getInstance()->addItem($objItem);
break;
case WATCHLIST_ACT_DELETE_ALL:
Watchlist::getInstance()->deleteAll();
break;
case WATCHLIST_ACT_DOWNLOAD_ALL:
Watchlist::getInstance()->downloadAll();
break;
}
// if ajax -> return the content of the watchlist
if (\Environment::get('isAjaxRequest')) {
die(json_encode(array('action' => \Input::get('act'), 'watchlist' => Watchlist::getInstance()->generate(), 'notification' => Watchlist::getInstance()->generateNotifications(), 'count' => Watchlist::getInstance()->count(), 'cssClass' => Watchlist::getInstance()->count() > 0 ? 'not-empty' : 'empty')));
}
// no js support -- redirect and remove GET parameters
\Controller::redirect(\Controller::generateFrontendUrl($objPage->row()));
}
示例10: redirect
public function redirect($url, $status = null, $exit = true)
{
if (!isset($url['language']) && $this->Session->check('Config.language')) {
$url['language'] = $this->Session->read('Config.language');
}
parent::redirect($url, $status, $exit);
}
示例11: startup
public function startup(Controller $controller)
{
if (isset($controller->request->params['prefix']) && $controller->request->params['prefix'] == 'admin' && !$this->isLoggedIn()) {
$this->Session->setFlash(__d('micro_auth', 'You need to login to access this page'));
$controller->redirect($this->config['loginAction']);
}
}
示例12: getValidationErrorResponse
/**
* Returns the appropriate response up the controller chain
* if {@link validate()} fails (which is checked prior to executing any form actions).
* By default, returns different views for ajax/non-ajax request, and
* handles 'application/json' requests with a JSON object containing the error messages.
* Behaviour can be influenced by setting {@link $redirectToFormOnValidationError}.
*
* @return SS_HTTPResponse|string
*/
protected function getValidationErrorResponse()
{
$request = $this->getRequest();
if ($request->isAjax()) {
// Special case for legacy Validator.js implementation
// (assumes eval'ed javascript collected through FormResponse)
$acceptType = $request->getHeader('Accept');
if (strpos($acceptType, 'application/json') !== FALSE) {
// Send validation errors back as JSON with a flag at the start
$response = new SS_HTTPResponse(Convert::array2json($this->validator->getErrors()));
$response->addHeader('Content-Type', 'application/json');
} else {
$this->setupFormErrors();
// Send the newly rendered form tag as HTML
$response = new SS_HTTPResponse($this->forTemplate());
$response->addHeader('Content-Type', 'text/html');
}
return $response;
} else {
if ($this->getRedirectToFormOnValidationError()) {
if ($pageURL = $request->getHeader('Referer')) {
if (Director::is_site_url($pageURL)) {
// Remove existing pragmas
$pageURL = preg_replace('/(#.*)/', '', $pageURL);
$pageURL = Director::absoluteURL($pageURL, true);
return $this->controller->redirect($pageURL . '#' . $this->FormName());
}
}
}
return $this->controller->redirectBack();
}
}
示例13: init
function init()
{
parent::init();
if ($this->Children()->Count()) {
Controller::redirect($this->Children()->First()->AbsoluteLink());
}
}
示例14: action_authorized
public function action_authorized()
{
$auth_t = array_key_exists('OAuthAuthToken', $_SESSION) ? $_SESSION['OAuthAuthToken'] : false;
if ($auth_t) {
$access_t = $this->oauth->getAccessToken($auth_t);
if ($access_t) {
Backend::addSuccess('Sucessfully logged into Twitter');
$data = array('screen_name' => $access_t['screen_name'], 'twitter_id' => $access_t['user_id'], 'oauth_token' => $access_t['oauth_token'], 'oauth_secret' => $access_t['oauth_token_secret'], 'active' => 1);
$twit = new TwitterObj();
if ($twit->replace($data)) {
} else {
Backend::addError('Could not record Twitter Auth information');
}
if (!empty($_SESSION['TwitterRedirect'])) {
$url = $_SESSION['TwitterRedirect'];
unset($_SESSION['TwitterRedirect']);
Controller::redirect($url);
}
} else {
Backend::addError('Could not get Access Token');
}
} else {
Backend::addError('No Authentication Token');
}
return true;
}
示例15: update
public function update($id)
{
if (parent::auth()) {
if ($_SESSION['id'] == $id) {
$user = User::find($id);
if ($_POST) {
if ($_FILES['picture']) {
parent::uploadImage($_FILES['picture'], 'user');
}
try {
$user->update_attributes($_POST);
$_SESSION['username'] = $_POST['username'];
parent::redirect('site/index');
} catch (Exception $e) {
if (strstr($e->getMessage(), 'Duplicate entry') == true) {
$error = 'Username or Email Has Been Previously Registered';
}
}
}
parent::setHeader('default');
parent::render('user/update', array('user' => $user, 'error' => isset($error) ? $error : ''));
parent::setFooter('default');
} else {
parent::redirect('site/index');
}
} else {
parent::redirect('site/index');
}
}