Пример #1
0
 public function beforeAction($action)
 {
     if ($action->id == "create-img-ajax" || $action->id == "filemanager" || $action->id == "crop-ajax") {
         $this->enableCsrfValidation = false;
     }
     return parent::beforeAction($action);
 }
Пример #2
0
 /**
  * @param \yii\base\Action $action
  * @return bool
  */
 public function beforeAction($action)
 {
     parent::beforeAction($action);
     if (\Yii::$app->user->identity->role != User::ROLE_ADMIN) {
         throw new \Exception('非管理员不能操作:(');
     }
     return true;
 }
Пример #3
0
 /**
  * @param \yii\base\Action $action
  * @return bool
  */
 public function beforeAction($action)
 {
     parent::beforeAction($action);
     if (!GlobalHelper::isValidAdmin()) {
         throw new \Exception(yii::t('conf', 'you are not active'));
     }
     return true;
 }
Пример #4
0
 /**
  * @param \yii\base\Action $action
  * @return bool
  */
 public function beforeAction($action)
 {
     parent::beforeAction($action);
     if (!GlobalHelper::isValidAdmin()) {
         throw new \Exception('项目管理员尚未通过其它项目管理员的审核,无操作项目权限:)');
     }
     return true;
 }
Пример #5
0
 public function beforeAction($action)
 {
     Yii::$app->response->is_backend = true;
     $headers = Yii::$app->response->getHeaders();
     $headers->set('X-Robots-Tag', 'none');
     $headers->set('X-Frame-Options', 'SAMEORIGIN');
     $headers->set('X-Content-Type-Options', 'nosniff');
     return parent::beforeAction($action);
 }
Пример #6
0
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         // change layout for error action
         if ($action->id == 'error') {
             $this->layout = '//_clear';
         }
         return true;
     } else {
         return false;
     }
 }
Пример #7
0
 /**
  * Install handlers
  */
 public static function installHandlers(ActionEvent $event)
 {
     $currency = \Yii::$app->getModule('seo')->analytics['ecYandex']['currency'];
     if (AnalyticsHandler::CURRENCY_MAIN === intval($currency)) {
         static::$currency = CurrencyHelper::getMainCurrency();
     } elseif (AnalyticsHandler::CURRENCY_USER === intval($currency)) {
         static::$currency = CurrencyHelper::getUserCurrency();
     } else {
         static::$currency = CurrencyHelper::findCurrencyByIso($currency);
     }
     $route = implode('/', [$event->action->controller->module->id, $event->action->controller->id, $event->action->id]);
     Event::on(CartController::className(), CartController::EVENT_ACTION_ADD, [self::className(), 'handleCartAdd'], false);
     Event::on(CartController::className(), CartController::EVENT_ACTION_REMOVE, [self::className(), 'handleRemoveFromCart'], false);
     Event::on(CartController::className(), CartController::EVENT_ACTION_QUANTITY, [self::className(), 'handleChangeQuantity'], false);
     Event::on(CartController::className(), CartController::EVENT_ACTION_CLEAR, [self::className(), 'handleClearCart'], false);
     Event::on(Controller::className(), Controller::EVENT_PRE_DECORATOR, [self::className(), 'handleProductShow']);
     if ('shop/cart/index' === $route) {
         self::handleCartIndex();
     }
     YandexAnalyticsAssets::register(\Yii::$app->getView());
 }
Пример #8
0
 /**
  * Fill $app->controllerMap property for auto run action classes
  */
 private function fillControllerMap()
 {
     $modulesPath = \Yii::getAlias("@app/modules");
     $modulesDir = new \DirectoryIterator($modulesPath);
     foreach ($modulesDir as $moduleDir) {
         if ($moduleDir->isDir() && !$moduleDir->isDot()) {
             $moduleId = $moduleDir->getBasename();
             $controllersPath = $modulesPath . '/' . $moduleId . '/controllers';
             $controllersDir = new \DirectoryIterator($controllersPath);
             foreach ($controllersDir as $controllerDir) {
                 if ($controllerDir->isDir() && !$controllerDir->isDot()) {
                     $controllerId = $controllerDir->getBasename();
                     $pathOfDefinedController = $controllersPath . '/' . ucfirst($controllerId) . 'Controller';
                     $namespaceOfDefinedController = "app\\modules\\{$moduleId}\\controllers\\" . ucfirst($controllerId) . 'Controller';
                     $modulesConfig = $this->application->modules;
                     $modulesConfig[$moduleId]['controllerMap'][$controllerId] = file_exists($pathOfDefinedController) ? $namespaceOfDefinedController : Controller::className();
                     $this->application->modules = $modulesConfig;
                 }
             }
         }
     }
 }
Пример #9
0
 /**
  * Updates the link when changing action to also add section id in case that is not the default one
  * @param string $action
  * @param array $params
  * @return bool
  */
 public function goToAction($action, $params = [])
 {
     if ($this->sectionId && 'get' == Config::value('FORUM_SECTION_ID_SOURCE')) {
         $params[Config::value('FORUM_SECTION_ID_KEY')] = $this->sectionId;
     }
     return parent::goToAction($action, $params);
 }
Пример #10
0
 public function init()
 {
     //MultiLanguageHelper::catchLanguage();
     parent::init();
     $this->layout = $this->module->getCustomLayout('user');
 }
Пример #11
0
 public function init()
 {
     parent::init();
     $this->checkAdmin();
 }
 public function beforeAction($action)
 {
     Yii::$app->session["_last_game"] = Yii::$app->request->absoluteUrl;
     return parent::beforeAction($action);
 }
Пример #13
0
 public function actions()
 {
     return array_merge(parent::actions(), ['all' => ['class' => actions\ActionAll::className()], 'view' => ['class' => actions\ActionView::className()], 'update' => ['class' => actions\ActionUpdate::className()], 'create' => ['class' => actions\ActionCreate::className()], 'delete' => ['class' => actions\ActionDelete::className()]]);
 }
Пример #14
0
 /**
  * @param \yii\base\Action $action
  * @return bool
  */
 public function beforeAction($action)
 {
     return parent::beforeAction($action);
 }