Пример #1
3
 public function init()
 {
     parent::init();
     $model = new Category();
     $map = ['status' => 1];
     $model->getList($map);
 }
Пример #2
1
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (empty($this->modelTitleForms)) {
         $this->modelTitleForms = PhpMorphy::getNeededForms($this->modelTitle);
     }
 }
Пример #3
1
 /**
  * Creates inherited user account.
  */
 public function init()
 {
     parent::init();
     if (!Yii::$app->user->isGuest) {
         if (PodiumModule::getInstance()->userComponent == PodiumModule::USER_INHERIT) {
             $user = User::findMe();
             if (empty($user)) {
                 $new = new User();
                 $new->setScenario('installation');
                 $new->inherited_id = Yii::$app->user->id;
                 $new->status = User::STATUS_ACTIVE;
                 $new->role = User::ROLE_MEMBER;
                 $new->timezone = User::DEFAULT_TIMEZONE;
                 if ($new->save()) {
                     $this->success(Yii::t('podium/flash', 'Hey! Your new forum account has just been automatically created! Go to {link} to complement it.', ['link' => Html::a(Yii::t('podium/view', 'Profile'))]));
                     Cache::clearAfterActivate();
                     Log::info('Inherited account created', $new->id, __METHOD__);
                 } else {
                     throw new Exception(Yii::t('podium/view', 'There was an error while creating inherited user account. Podium can not run with the current configuration. Please contact administrator about this problem.'));
                 }
             } elseif ($user->status == User::STATUS_BANNED) {
                 return $this->redirect(['default/ban']);
             }
         } else {
             $user = Yii::$app->user->identity;
         }
         if ($user && !empty($user->timezone)) {
             Yii::$app->formatter->timeZone = $user->timezone;
         }
     }
 }
Пример #4
0
 public function init()
 {
     parent::init();
     if ($user = Yii::$app->getUser()) {
         $this->auth_user = $user->identity;
     }
 }
Пример #5
0
 public function init()
 {
     parent::init();
     $this->titleMeta = Yii::$app->name;
     $this->siteNameMeta = Yii::$app->name;
     $this->descriptionMeta = Yii::t('app', 'Free classifieds from all over the world !!!');
 }
Пример #6
0
 public function init()
 {
     parent::init();
     //CSRF 基于 POST 验证,UEditor 无法添加自定义 POST 数据,同时由于这里不会产生安全问题,故简单粗暴地取消 CSRF 验证。
     //如需 CSRF 防御,可以使用 server_param 方法,然后在这里将 Get 的 CSRF 添加到 POST 的数组中。。。
     Yii::$app->request->enableCsrfValidation = false;
     //当客户使用低版本IE时,会使用swf上传插件,维持认证状态可以参考文档UEditor「自定义请求参数」部分。
     //http://fex.baidu.com/ueditor/#server-server_param
     //保留UE默认的配置引入方式
     if (file_exists(__DIR__ . '/config.json')) {
         $CONFIG = json_decode(preg_replace("/\\/\\*[\\s\\S]+?\\*\\//", '', file_get_contents(__DIR__ . '/config.json')), true);
     } else {
         $CONFIG = [];
     }
     if (!is_array($this->config)) {
         $this->config = [];
     }
     if (!is_array($CONFIG)) {
         $CONFIG = [];
     }
     $default = ['imagePathFormat' => '/upload/image/{yyyy}{mm}{dd}/{time}{rand:8}', 'scrawlPathFormat' => '/upload/image/{yyyy}{mm}{dd}/{time}{rand:8}', 'snapscreenPathFormat' => '/upload/image/{yyyy}{mm}{dd}/{time}{rand:8}', 'catcherPathFormat' => '/upload/image/{yyyy}{mm}{dd}/{time}{rand:8}', 'videoPathFormat' => '/upload/video/{yyyy}{mm}{dd}/{time}{rand:8}', 'filePathFormat' => '/upload/file/{yyyy}{mm}{dd}/{rand:8}_{filename}', 'imageManagerListPath' => '/upload/image/', 'fileManagerListPath' => '/upload/file/'];
     $this->config = $this->config + $default + $CONFIG;
     $this->webroot = Yii::getAlias('@webroot');
     if (!is_array($this->thumbnail)) {
         $this->thumbnail = false;
     }
 }
Пример #7
0
 public function init()
 {
     parent::init();
     $extJsSrcDir = Yii::getAlias($this->extJsDir);
     $extJsSrcExtendDir = Yii::getAlias($this->extJsExtendDir);
     $dstDir = Yii::getAlias($this->dstPath);
     $extJsDstDir = $dstDir . DIRECTORY_SEPARATOR . 'extjs';
     $extJsExtendDstDir = $dstDir . DIRECTORY_SEPARATOR . 'extjs-extend';
     if (!is_dir($dstDir)) {
         if (!is_dir($dstDir)) {
             FileHelper::createDirectory($dstDir);
         }
     }
     if (!is_dir($extJsDstDir)) {
         symlink($extJsSrcDir, $extJsDstDir);
     }
     if (!is_dir($extJsExtendDstDir)) {
         symlink($extJsSrcExtendDir, $extJsExtendDstDir);
     }
     $data = DpConfig::find()->all();
     $config = [];
     foreach ($data as $item) {
         $config[$item['name']] = $item['value'];
     }
     $this->config = $config;
     $this->identity = Yii::$app->user->identity;
 }
Пример #8
0
 public function init()
 {
     $this->setRequestParams(Yii::$app->request);
     $this->setPageParams($this->requestParams);
     $this->setSortParams($this->requestParams);
     parent::init();
 }
Пример #9
0
 /**
  * Creates inherited user account.
  */
 public function init()
 {
     parent::init();
     if (!Yii::$app->user->isGuest) {
         if (PodiumModule::getInstance()->userComponent == PodiumModule::USER_INHERIT) {
             $user = User::findMe();
             if (empty($user)) {
                 $new = new User();
                 $new->setScenario('installation');
                 $new->inherited_id = Yii::$app->user->id;
                 $new->status = User::STATUS_ACTIVE;
                 $new->role = User::ROLE_MEMBER;
                 $new->timezone = User::DEFAULT_TIMEZONE;
                 if ($new->save()) {
                     $this->success(Yii::t('podium/flash', Messages::ACCOUNT_INHERITED, ['link' => Html::a(Yii::t('podium/layout', 'Profile'))]));
                     Cache::clearAfterActivate();
                     Log::info('Inherited account created', $new->id, __METHOD__);
                 } else {
                     throw new Exception(Yii::t('podium/view', Messages::ACCOUNT_INHERITED_ERROR));
                 }
             } elseif ($user->status == User::STATUS_BANNED) {
                 return $this->redirect(['default/ban']);
             }
         } else {
             $user = Yii::$app->user->identity;
         }
         if ($user && !empty($user->timezone)) {
             Yii::$app->formatter->timeZone = $user->timezone;
         }
     }
 }
Пример #10
0
 /**
  * Initializes the object.
  * This method is invoked at the end of the constructor after the object is initialized with the
  * given configuration.
  */
 public function init()
 {
     $response = \Yii::$app->response;
     $response->format = \yii\web\Response::FORMAT_JSON;
     parent::init();
     // TODO: Change the autogenerated stub
 }
Пример #11
0
 /**
  * Init function
  */
 public function init()
 {
     parent::init();
     if ($this->userClassName === null) {
         $this->userClassName = Yii::$app->getUser()->identityClass;
     }
 }
Пример #12
0
 public function init()
 {
     if (Yii::$app->user->isGuest || Yii::$app->user->id > 5) {
         die("Доступ закрыт! Вы не являетесь админом.");
     }
     parent::init();
 }
Пример #13
0
 public function init()
 {
     parent::init();
     Yii::$app->language = Yii::$app->user->isGuest ? "en-US" : Yii::$app->user->getIdentity()->language;
     Yii::$app->formatter->datetimeFormat = Yii::$app->user->isGuest ? "dd/MM/yyyy HH:mm" : Yii::$app->user->getIdentity()->date_format . " " . Yii::$app->user->getIdentity()->time_format;
     Yii::$app->formatter->timeZone = Yii::$app->user->isGuest ? 'America/Sao_Paulo' : Yii::$app->user->getIdentity()->time_zone;
 }
Пример #14
0
 public function init()
 {
     parent::init();
     $this->modularityService = LuLu::getService('modularity');
     $this->rbacService = LuLu::getService('rbac');
     $this->taxonomyService = LuLu::getService('taxonomy');
 }
Пример #15
0
 /**
  * 初始化
  * @see \yii\base\Object::init()
  */
 public function init()
 {
     parent::init();
     //初始化web目录下的资源路径
     $this->baseUrl = Yii::getAlias('@web');
     $this->layout = '@app/views/layouts/adminlte_main';
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $this->user_id = $this->module->userId;
     $this->notificationClass = $this->module->notificationClass;
     parent::init();
 }
Пример #17
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->modelClass === null) {
         throw new InvalidConfigException('The "modelClass" property must be set.');
     }
 }
 /**
  *
  */
 public function init()
 {
     parent::init();
     if ($this->modelClass === null) {
         $this->modelClass = Category::className();
     }
 }
Пример #19
0
 public function init()
 {
     $this->get = \Yii::$app->request->get();
     $this->post = \Yii::$app->request->post();
     $this->title = '嘉瑞百合缘';
     parent::init();
 }
Пример #20
0
 public function init()
 {
     parent::init();
     if (Yii::$app->request->isPjax) {
         $this->layout = false;
     }
 }
 public function init()
 {
     parent::init();
     // If there is a post-request, redirect the application to the provided url of the selected lang
     if (isset($_POST['lang'])) {
         $lang = $_POST['lang'];
         $MultilangReturnUrl = $_POST[$lang];
         $this->redirect($MultilangReturnUrl);
     }
     // Set the application lang if provided by GET, session or cookie
     if (isset($_GET['lang'])) {
         Yii::$app->language = $_GET['lang'];
         Yii::$app->session->set('lang', $_GET['lang']);
         $cookie = new \yii\web\Cookie(['name' => 'lang', 'value' => $_GET['lang']]);
         $cookie->expire = time() + 60 * 60 * 24 * 365;
         // (1 year)
         Yii::$app->response->cookies->add($cookie);
     } else {
         if (Yii::$app->session->has('lang')) {
             Yii::$app->language = Yii::$app->session->get('lang');
         } else {
             if (isset(Yii::$app->request->cookies['lang'])) {
                 Yii::$app->language = Yii::$app->request->cookies['lang']->value;
             }
         }
     }
 }
Пример #22
0
 public function init()
 {
     parent::init();
     // Init routes
     $routesLocal = is_array($this->routes) ? $this->routes : [];
     $routesParams = isset(Yii::$app->params['mediaRoutes']) && is_array(Yii::$app->params['mediaRoutes']) ? Yii::$app->params['mediaRoutes'] : [];
     $this->routes = ArrayHelper::merge($routesParams, $routesLocal);
     if (!isset($this->routes['baseUrl'])) {
         $this->routes['baseUrl'] = '';
     }
     if (!isset($this->routes['basePath'])) {
         $this->routes['basePath'] = '@frontend/web';
     }
     if (!isset($this->routes['uploadPath'])) {
         $this->routes['uploadPath'] = 'uploads';
     }
     $thumbsLocal = is_array($this->thumbs) ? $this->thumbs : [];
     $thumbsParams = isset(Yii::$app->params['mediaThumbs']) && is_array(Yii::$app->params['mediaThumbs']) ? Yii::$app->params['mediaThumbs'] : [];
     $this->thumbs = ArrayHelper::merge($thumbsParams, $thumbsLocal);
     //Init thumbs sizes
     if (empty($this->thumbs)) {
         $this->thumbs = ['small' => ['name' => 'Small size', 'size' => [120, 80]], 'medium' => ['name' => 'Medium size', 'size' => [400, 300]], 'large' => ['name' => 'Large size', 'size' => [800, 600]]];
     }
     //Set up defaukt album ID
     if (isset(Yii::$app->params['uploaderAlbumId'])) {
         $this->defaultAlbumId = (int) Yii::$app->params['uploaderAlbumId'];
     }
 }
Пример #23
0
 public function init()
 {
     parent::init();
     $n_sr = false;
     $n_ar = false;
     $n_s = false;
     $n_a = false;
     //poka 4to zdes' delaem zada4i controllera no porom nado srochno pereexat'
     if (!Yii::$app->user->isGuest) {
         if (Yii::$app->user->identity->getStageReportNotification()) {
             $n_sr = Yii::$app->user->identity->getStageReportNotification();
         }
         if (Yii::$app->user->identity->getAssignmentReportNotification()) {
             $n_ar = Yii::$app->user->identity->getAssignmentReportNotification();
         }
         if (Yii::$app->user->identity->getStageNotification()) {
             $n_s = Yii::$app->user->identity->getStageNotification();
         }
         if (Yii::$app->user->identity->getAssignmentNotification()) {
             $n_a = Yii::$app->user->identity->getAssignmentNotification();
         }
     }
     Yii::$app->view->params['n_sr'] = $n_sr;
     Yii::$app->view->params['n_ar'] = $n_ar;
     Yii::$app->view->params['n_s'] = $n_s;
     Yii::$app->view->params['n_a'] = $n_a;
 }
 public function init()
 {
     parent::init();
     //Check post request
     if (isset($_POST['lang'])) {
         $lang = $_POST['lang'];
         $mutilLanguageReturnUrl = $_POST['lang'];
         $this->redirect($mutilLanguageReturnUrl);
     }
     //Set the application language if provided GET, session, or cookie
     if (isset($_GET['lang'])) {
         Yii::$app->language = $_GET['lang'];
         Yii::$app->session->set('lang', $_GET['lang']);
         $cookie = new Cookie(['name' => 'lang', 'value' => $_GET['lang']]);
         $cookie->expire = time() + 31536000;
         //1year
         Yii::$app->response->cookies->add($cookie);
     } elseif (Yii::$app->session->get('lang')) {
         Yii::$app->language = Yii::$app->session->get('lang');
     } elseif (Yii::$app->request->cookies->get('lang')) {
         Yii::$app->language = Yii::$app->request->cookies['lang']->value;
     } else {
         //default ngôn ngữ vi
         Yii::$app->language = 'vi';
         Yii::$app->session->set('lang', 'vi');
         $cookie = new Cookie(['name' => 'lang', 'value' => 'vi']);
         $cookie->expire = time() + 31536000;
         //1year
         Yii::$app->response->cookies->add($cookie);
     }
 }
 public function init()
 {
     //check for abonnement permission
     $user = Yii::$app->getModule("user")->model("User");
     if (($user = $user::findOne(Yii::$app->user->userid)) !== null) {
         if ($user->abonnement->active == 0) {
             throw new ForbiddenHttpException('
              <div class="text-center">
              <h3>
              <p class="bg-danger">
              <br>Uw abonnement is (nog) niet actief of inmiddels verlopen!<br><br>
              </p>
              </h3>
              <br><br>
              </div>
              <div class="text-center">
              <a href="http://werkmetspoor.nl/index.php/contact/" class="btn btn-danger" role="button">Neem contact met ons op</a>
              </div>
              ');
         }
     }
     // indien igelogged maar geen contactpersoon
     if (!empty(Yii::$app->user) && !Yii::$app->user->can("contactpersoon")) {
         throw new ForbiddenHttpException('Geen toegang');
     }
     parent::init();
 }
Пример #26
0
 public function init()
 {
     $session = Yii::$app->session;
     $session->open();
     $this->mySite = str_replace(array(" ", "-", "_"), "", $this->id);
     if (isset($session['session.user']) && $session['session.user']['login']) {
         $model = new Module();
         //$this->baseModule = Module::find()->where(["name"=>$this->mySite])->asArray()->one();
         $this->baseModule = $model->findModuleByName($this->mySite);
         if ($this->baseModule) {
             if (!isset($session['session.user']['hak_akses'][$this->baseModule['id']]) && empty($session['session.user']['hak_akses'][$this->baseModule['id']])) {
                 echo "you are not allowed access this module";
                 die;
             } else {
                 $this->myModule = $session['session.user']['hak_akses'][$this->baseModule['id']];
             }
         } else {
             if ($this->mySite != "site") {
                 echo "there is no module with name " . $this->mySite;
                 die;
             }
         }
     }
     $session->close();
     parent::init();
 }
Пример #27
0
 public function init()
 {
     parent::init();
     if (Yii::$app->user->identity->id != 1) {
         die('Illegal operation');
     }
 }
Пример #28
-1
 /**
  * @inheritdoc
  */
 public function init()
 {
     if (!empty(Yii::$app->user) && !Yii::$app->user->can("contactpersoon")) {
         throw new ForbiddenHttpException('Je hebt geen toegang');
     }
     parent::init();
 }
Пример #29
-1
 public function init()
 {
     if ($this->module->customAdminLayout != '') {
         $this->layout = $this->module->customAdminLayout;
     }
     parent::init();
 }
Пример #30
-1
 public function init()
 {
     parent::init();
     unset(Yii::$app->view->params['blocks']);
     unset(Yii::$app->view->params['categoryColumn1']);
     unset(Yii::$app->view->params['categoryColumn2']);
     Yii::$app->view->params['blocks'] = BlocksSearch::find()->where(['active' => 1])->orderBy('sortOrder ASC')->all();
     $allCategoryCounts = PostsSearch::find()->published()->count();
     if (Yii::$app->params['showNullCategory']) {
         $categories = CategoriesSearch::find()->active()->orderBy('title ASC')->all();
     } else {
         $categories = CategoriesSearch::find()->active()->innerJoin("{{%sources}}", "[[sources.categories_id]]=[[categories.id]]")->innerJoin("{{%posts}}", "[[posts.sources_id]] = [[sources.id]]")->orderBy('title ASC')->groupBy("[[categories.title]]")->all();
     }
     if (is_array($categories)) {
         $i = 1;
         $halfCountCategories = ceil(count($categories) / 2);
         Yii::$app->view->params['categoryColumn1'][] = ['url' => '/', 'title' => Yii::t('app/categories', 'All Categories ({0})', [$allCategoryCounts])];
         foreach ($categories as $category) {
             $countPostInCategory = $category->countPosts;
             $url = Yii::$app->request->get('category') != $category->slugUrl ? $category->url : NULL;
             $title = $category->title;
             if ($i <= $halfCountCategories) {
                 Yii::$app->view->params['categoryColumn1'][] = ['url' => $url, 'title' => $title . " ({$countPostInCategory})"];
             } else {
                 Yii::$app->view->params['categoryColumn2'][] = ['url' => $url, 'title' => $title . " ({$countPostInCategory})"];
             }
             $i++;
         }
     }
 }