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


PHP CController::beforeAction方法代码示例

本文整理汇总了PHP中CController::beforeAction方法的典型用法代码示例。如果您正苦于以下问题:PHP CController::beforeAction方法的具体用法?PHP CController::beforeAction怎么用?PHP CController::beforeAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CController的用法示例。


在下文中一共展示了CController::beforeAction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: beforeAction

 protected function beforeAction($action)
 {
     if (Yii::app()->request->isAjaxRequest) {
         $this->layout = false;
     }
     return parent::beforeAction($action);
 }
开发者ID:apa-narola,项目名称:yiimoduledemo,代码行数:7,代码来源:Controller.php

示例2: beforeAction

 public function beforeAction($action)
 {
     $dynamicTheme = "dark";
     if (isset($_POST['change'])) {
         $dynamicTheme = $_POST['change'];
         if (isset(Yii::app()->request->cookies['dynamicTheme']->value)) {
             if (Yii::app()->request->cookies['dynamicTheme']->value != $dynamicTheme) {
                 Yii::app()->request->cookies['dynamicTheme']->value = $dynamicTheme;
             }
             // if
         }
         // if
         $cookie = new CHttpCookie("dynamicTheme", $dynamicTheme);
         $cookie->expire = time() + 60 * 60 * 24 * 180;
         Yii::app()->request->cookies['dynamicTheme'] = $cookie;
         unset($_POST['change']);
     }
     // if isset $_POST['change']
     if (isset(Yii::app()->request->cookies['dynamicTheme']->value)) {
         $dynamicTheme = Yii::app()->request->cookies['dynamicTheme']->value;
     } else {
         $cookie = new CHttpCookie("dynamicTheme", $dynamicTheme);
         $cookie->expire = time() + 60 * 60 * 24 * 180;
         Yii::app()->request->cookies['dynamicTheme'] = $cookie;
     }
     // else
     return parent::beforeAction($action);
 }
开发者ID:noktigula,项目名称:Photo,代码行数:28,代码来源:Controller.php

示例3: beforeAction

 public function beforeAction($action)
 {
     $controller = ucfirst(strtolower($this->getId()));
     $action = ucfirst(strtolower($this->getAction()->getId()));
     $module = '';
     if (isset($this->module->id)) {
         $module = ucfirst($this->module->id);
     }
     $operation = $module . $controller . $action;
     /*if(false){//*/
     if (!Yii::app()->adminUser->checkAccess($operation)) {
         if (Yii::app()->request->isAjaxRequest) {
             Yii::app()->user->setFlash('error', 'Not Authorized Action.');
             throw new CHttpException(401, 'Unauthorized request.');
             Yii::app()->end();
             $content_type_arr = Yii::app()->request->getAcceptTypes();
             $index = preg_match("/application\\/json/", $content_type_arr) || preg_match("/application\\/jsonp/", $content_type_arr);
         } else {
             if (Yii::app()->adminUser->isGuest) {
                 $this->redirect(array('/admin/user/login'));
             } else {
                 $this->redirect(array('/admin/accessdenied'));
             }
         }
     } else {
         /*$unreadmessage = ContactMessage::model()->getUnreadCount();
         		
         		Yii::app()->params['unread_message'] = $unreadmessage;*/
     }
     return parent::beforeAction($this->getAction());
 }
开发者ID:jayant06,项目名称:lukurug,代码行数:31,代码来源:Controller.php

示例4: beforeAction

 protected function beforeAction($action)
 {
     parent::beforeAction($action);
     if (Yii::app()->user->isGuest) {
         if (isset(Yii::app()->request->cookies['prefLang'])) {
             $sChosenLanguage = Yii::app()->request->cookies['prefLang']->value;
         } else {
             $sPrefferedLang = Yii::app()->request->getPreferredLanguage();
             if ($sPrefferedLang !== false && strpos($sPrefferedLang, "ru") !== false) {
                 $sChosenLanguage = "ru";
             } else {
                 $sChosenLanguage = "uk_ua";
             }
             $cookie = new CHttpCookie('prefLangId', $sChosenLanguage);
             $cookie->expire = time() + 86400 * 7;
             Yii::app()->request->cookies['prefLang'] = $cookie;
         }
     } else {
         $sChosenLanguage = Yii::app()->user->getLanguage();
     }
     switch ($sChosenLanguage) {
         case "ru":
             Yii::app()->language = "ru";
             break;
         default:
             Yii::app()->language = "uk_ua";
     }
     return true;
 }
开发者ID:snipesn,项目名称:UkrYama-2,代码行数:29,代码来源:Controller.php

示例5: beforeAction

 public function beforeAction($action)
 {
     if (!parent::beforeAction($action)) {
         return false;
     }
     if (isset(Yii::app()->user->usIdent)) {
         // Obtiene la clasificación de los equipos
         $clasificacion = Clasificacion::model()->with('equipos')->findAll(array('order' => 'posicion ASC'));
         Yii::app()->setParams(array('clasificacion' => $clasificacion));
         // Obtiene la información del usuario
         $usuario = Usuarios::model()->with('recursos')->findByPK(Yii::app()->user->usIdent);
         Yii::app()->setParams(array('usuario' => $usuario));
         // Obtiene la información de la mensajeria
         //Saca la lista de los emails recibidos por el usuario y que ademas no los haya leido
         $mensajeria = Emails::model()->findAllByAttributes(array('id_usuario_to' => Yii::app()->user->usIdent, 'leido' => 0));
         $countmens = count($mensajeria);
         Yii::app()->setParams(array('countmens' => $countmens));
         // Obtiene la información de las notificaciones
         //Saca la lista de las notinicaciones recibidas por el usuario y que ademas no haya leido
         $notificaciones = Usrnotif::model()->findAllByAttributes(array('usuarios_id_usuario' => Yii::app()->user->usIdent, 'leido' => 0));
         $countnot = count($notificaciones);
         Yii::app()->setParams(array('countnot' => $countnot));
     }
     Yii::app()->setParams(array('bgclass' => 'bg-estadio-fuera'));
     return true;
 }
开发者ID:rMarinf,项目名称:JugadorNum12,代码行数:26,代码来源:Controller.php

示例6: beforeAction

 public function beforeAction($action)
 {
     if (Yum::module()->enableOnlineStatus && !Yii::app()->user->isGuest) {
         Yii::app()->user->data()->setLastAction();
     }
     return parent::beforeAction($action);
 }
开发者ID:bhaveshsoni,项目名称:yii-user-management,代码行数:7,代码来源:YumController.php

示例7: beforeAction

 public function beforeAction($action)
 {
     if (Yii::app()->user->isGuest && $action->controller != 'SiteController' && $action->id != 'login') {
         $this->redirect(Yii::app()->user->loginUrl);
     }
     return parent::beforeAction($action);
 }
开发者ID:seekermain,项目名称:forms,代码行数:7,代码来源:Controller.php

示例8: beforeAction

 /**
  * Register any values that needed on beforeAction
  * @param CAction $action action
  * @return boolean whether the action is allowed ?
  */
 public function beforeAction($action)
 {
     $this->registers();
     $this->notifications();
     $this->renderJS(array('baseURL' => Yii::app()->baseUrl), array());
     return parent::beforeAction($action);
 }
开发者ID:andryluthfi,项目名称:annotation-tools,代码行数:12,代码来源:ControllerBase.php

示例9: beforeAction

 /**
  * Set the base before action functions for the application
  **/
 public function beforeAction($action)
 {
     // Set the page class
     $this->pageClass = Yii::app()->controller->id . '-' . Yii::app()->controller->action->id;
     // Return parent before action for rules
     return parent::beforeAction($action);
 }
开发者ID:PTZ2002,项目名称:decoram,代码行数:10,代码来源:ApplicationController.php

示例10: beforeAction

 protected function beforeAction($action)
 {
     if (oreInstall::isInstalled()) {
         throw404();
     }
     $this->setLangInstall();
     return parent::beforeAction($action);
 }
开发者ID:barricade86,项目名称:raui,代码行数:8,代码来源:MainController.php

示例11: beforeAction

 protected function beforeAction($action)
 {
     if (YII_DEBUG) {
         Yii::app()->assetManager->forceCopy = true;
     }
     Yii::app()->assetManager->publish(Yii::getPathOfAlias('bootstrap.assets'), false, -1, YII_DEBUG);
     return parent::beforeAction($action);
 }
开发者ID:EurekaSolutions,项目名称:proyectoestudio,代码行数:8,代码来源:Controller.php

示例12: beforeAction

 protected function beforeAction($action)
 {
     //	var_dump( $action);
     //	var_dump(Yii::app()->admin->loginUrl);
     if (Yii::app()->admin->isGuest && $action->getId() != 'login') {
         $this->redirect(Yii::app()->admin->loginUrl);
     }
     return parent::beforeAction($action);
 }
开发者ID:rocketyang,项目名称:yii2,代码行数:9,代码来源:AdminController.php

示例13: beforeAction

	public function beforeAction($action) {

		if(!Yum::module()->enableRESTapi) 
			throw new CHttpException(404);	
		else if($this->_checkAuth()) 
			return parent::beforeAction($action);
		else
			throw new CHttpException(403);	
	}
开发者ID:richardh68,项目名称:yii-user-management,代码行数:9,代码来源:YumRestController.php

示例14: beforeAction

    public function beforeAction($action)
    {
        if (Yii::app()->user->isGuest && ($action->id != 'login'))
        {
            $this->redirect(array('/users/user/login', 'redirect' => urlencode($_SERVER['REQUEST_URI'])));
        }

        return parent::beforeAction($action);
    }
开发者ID:nizsheanez,项目名称:kur.ru,代码行数:9,代码来源:Controller.php

示例15: beforeAction

 public function beforeAction($action)
 {
     Yii::import('application.vendors.*');
     require_once 'MyFunctions.php';
     $myFunc = new MyFunctions();
     $myFunc->counter();
     return parent::beforeAction($action);
     //return true;
 }
开发者ID:Romerohub,项目名称:Yii-blog,代码行数:9,代码来源:Controller.php


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