public function beforeAction($action) { if ($action->id == 'view') { $this->enableCsrfValidation = false; } return parent::beforeAction($action); }
public function init() { if ($this->model && \Yii::$app->cmsToolbar) { $controller = \Yii::$app->createController('cms/admin-tree')[0]; $adminControllerRoute = ['cms/admin-tree/update', $controller->requestPkParamName => $this->model->{$controller->modelPkAttribute}]; $urlEditModel = UrlHelper::construct($adminControllerRoute)->enableAdmin()->setSystemParam(\skeeks\cms\modules\admin\Module::SYSTEM_QUERY_EMPTY_LAYOUT, 'true')->toString(); \Yii::$app->cmsToolbar->editUrl = $urlEditModel; } parent::init(); }
public function behaviors() { return ArrayHelper::merge(parent::behaviors(), ['viewAccess' => ['class' => CmsAccessControl::className(), 'only' => ['view'], 'rules' => [['allow' => true, 'matchCallback' => function ($rule, $action) { if ($this->model->cmsContent && $this->model->cmsContent->access_check_element == 'Y') { //Если такая привилегия заведена, нужно ее проверять. if ($permission = \Yii::$app->authManager->getPermission($this->model->permissionName)) { if (!\Yii::$app->user->can($permission->name)) { return false; } } } return true; }]]]]); }
/** * @return array */ public function behaviors() { return ArrayHelper::merge(parent::behaviors(), ['accessToView' => ['class' => CmsAccessControl::className(), 'only' => ['view'], 'rules' => [['allow' => true, 'matchCallback' => function ($rule, $action) { $id = \Yii::$app->request->get('id'); $shopOrder = V3toysOrder::findOne($id); if (\Yii::$app->user->isGuest) { return false; } if ($shopOrder->user_id == \Yii::$app->user->identity->id) { return true; } return false; }]]], 'accessToList' => ['class' => CmsAccessControl::className(), 'only' => ['list'], 'rules' => [['allow' => true, 'roles' => ['@']]]]]); }
/** * @return array */ public function behaviors() { return ArrayHelper::merge(parent::behaviors(), ['verbs' => ['class' => VerbFilter::className(), 'actions' => ['shop-person-type-validate' => ['post'], 'shop-person-type-submit' => ['post']]]]); }
public function init() { parent::init(); self::onceInit(); if (!$this->name) { $this->name = \Yii::t('app', 'The name of the controller'); //Inflector::humanize($this->id); } $this->layout = \Yii::$app->cms->moduleAdmin()->layout; \Yii::$app->trigger(self::EVENT_INIT, new AdminInitEvent(['name' => self::EVENT_INIT, 'controller' => $this])); }
public function init() { parent::init(); }