当前位置: 首页>>代码示例>>PHP>>正文


PHP Controller::redirect方法代码示例

本文整理汇总了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')));
     }
 }
开发者ID:felix-koehler,项目名称:phkapa,代码行数:33,代码来源:MaintenanceComponent.php

示例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;
     }
 }
开发者ID:andreykin,项目名称:yii-lti,代码行数:35,代码来源:Portfolio_LTI_Tool_Provider.php

示例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;
 }
开发者ID:saydulk,项目名称:croogo,代码行数:17,代码来源:BulkProcessComponent.php

示例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'));
         }
     }
 }
开发者ID:sanyaade-machine-learning,项目名称:Catool,代码行数:18,代码来源:DemoAuthServiceComponent.php

示例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);
     }
 }
开发者ID:tetsuo111,项目名称:cakephp,代码行数:21,代码来源:RefererComponent.php

示例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']);
             }
         }
     }
 }
开发者ID:heimrichhannot,项目名称:contao-protected_homedirs,代码行数:35,代码来源:ProtectedHomeDirs.php

示例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');
	}
开发者ID:ndusan,项目名称:belvi,代码行数:7,代码来源:cms_carriereController.class.php

示例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');
     }
 }
开发者ID:terminal42,项目名称:contao-leads,代码行数:10,代码来源:tl_lead_export.php

示例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()));
 }
开发者ID:heimrichhannot,项目名称:contao-watchlist,代码行数:32,代码来源:ModuleWatchlist.php

示例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);
 }
开发者ID:basantk,项目名称:cakephp-user-login-basic-2.x,代码行数:7,代码来源:AppController.php

示例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']);
     }
 }
开发者ID:Onasusweb,项目名称:MicroAuth,代码行数:7,代码来源:MicroAuthComponent.php

示例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();
     }
 }
开发者ID:rasstislav,项目名称:silverstripe-framework,代码行数:41,代码来源:Form.php

示例13: init

 function init()
 {
     parent::init();
     if ($this->Children()->Count()) {
         Controller::redirect($this->Children()->First()->AbsoluteLink());
     }
 }
开发者ID:helpfulrobot,项目名称:purplespider-mypswd-tweaks,代码行数:7,代码来源:FirstChildRedirect.php

示例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;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:26,代码来源:Twitter.obj.php

示例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');
     }
 }
开发者ID:onuraltinsoy,项目名称:crescendo,代码行数:29,代码来源:UserController.php


注:本文中的Controller::redirect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。