/**
  * Url: /
  * @return mixed Content
  */
 public function actionIndex()
 {
     return $this->render('@frontend/views/site/index', ['templateType' => 'col3', 'title' => 'Dynamomania.com. Сайт болельщиков Динамо Киев', 'columnFirst' => ['top3News' => SiteBlock::getTop3News(), 'top6News' => SiteBlock::getTop6News(), 'subscribing' => SiteBlock::getSubscribingForm(), 'banner1' => SiteBlock::getBanner(Banner::REGION_FIRST_COLUMN), 'blog_column' => SiteBlock::getBlogPosts()], 'columnSecond' => ['slider_matches' => SiteBlock::getMatchesSlider(), 'short_news' => SiteBlock::getshortNews(50, false)], 'columnThird' => ['questionBlock' => SiteBlock::getQuestionBlock(), 'banner1' => SiteBlock::getBanner(Banner::REGION_THIRD_COLUMN), 'tournament' => SiteBlock::getTournamentTable(), 'reviewNews' => SiteBlock::getPhotoVideoNews(), 'banner2' => SiteBlock::getBanner(Banner::REGION_THIRD_COLUMN), 'top200tags' => SiteBlock::getTop200Tags(), 'banner3' => SiteBlock::getBanner(Banner::REGION_THIRD_COLUMN)]]);
 }
 /**
  * Reset password
  */
 public function actionReset($key)
 {
     /** @var \common\modules\user\models\User    $user */
     /** @var \common\modules\user\models\UserKey $userKey */
     // check for valid userKey
     $userKey = Yii::$app->getModule("user")->model("UserKey");
     $userKey = $userKey::findActiveByKey($key, $userKey::TYPE_PASSWORD_RESET);
     if (!$userKey) {
         return $this->render('reset', ["invalidKey" => true]);
     }
     // get user and set "reset" scenario
     $success = false;
     $user = Yii::$app->getModule("user")->model("User");
     $user = $user::findOne($userKey->user_id);
     $user->setScenario("reset");
     // load post data and reset user password
     if ($user->load(Yii::$app->request->post()) && $user->save()) {
         // consume userKey and set success = true
         $userKey->consume();
         $success = true;
     }
     // render
     // return $this->render('reset', compact("user", "success"));
     return $this->render('@frontend/views/site/index', ['templateType' => 'col3', 'title' => Yii::t('user', 'Вход'), 'columnFirst' => ['top3News' => SiteBlock::getTop3News(), 'top6News' => SiteBlock::getTop6News(), 'subscribing' => SiteBlock::getSubscribingForm(), 'blog_column' => SiteBlock::getBlogPosts()], 'columnSecond' => ['forgot_block' => ['view' => 'reset', 'data' => compact('user', 'success')], 'short_news' => SiteBlock::getShortNews()], 'columnThird' => ['reviewNews' => SiteBlock::getPhotoVideoNews(), 'questionBlock' => SiteBlock::getQuestionBlock(), 'tournament' => SiteBlock::getTournamentTable()]]);
 }
Beispiel #3
0
 /**
  * After save and before delete update cache of blocks
  */
 public function updateCacheBlocks($changedAttributes)
 {
     $newsPosts50 = Post::find()->where(['is_public' => 1, 'content_category_id' => Post::CATEGORY_NEWS])->orderBy(['created_at' => SORT_DESC])->limit(50)->all();
     $newsPosts20 = array_slice($newsPosts50, 0, 20);
     $cacheBlocksData = CacheBlock::find()->all();
     $cacheBlocks = [];
     foreach ($cacheBlocksData as $block) {
         $cacheBlocks[$block->machine_name] = $block;
     }
     $cacheStatus = false;
     if (isset($changedAttributes['content_category_id']) && $changedAttributes['content_category_id'] == self::CATEGORY_NEWS && $this->content_category_id != self::CATEGORY_NEWS || $this->content_category_id == self::CATEGORY_NEWS) {
         $machineName = 'shortNews50';
         $enableBanners = false;
         if (!isset($cacheBlocks[$machineName])) {
             $cacheBlock = new CacheBlock();
             $cacheBlock->machine_name = $machineName;
         } else {
             $cacheBlock = $cacheBlocks[$machineName];
         }
         $cacheBlock->content = SiteBlock::getShortNews(50, $enableBanners, $cacheStatus, $newsPosts50);
         $cacheBlock->save();
         $machineName = 'shortNews50banners';
         $enableBanners = true;
         SiteBlock::$postedBannerIds = [];
         if (!isset($cacheBlocks[$machineName])) {
             $cacheBlock = new CacheBlock();
             $cacheBlock->machine_name = $machineName;
         } else {
             $cacheBlock = $cacheBlocks[$machineName];
         }
         $cacheBlock->content = SiteBlock::getShortNews(50, $enableBanners, $cacheStatus, $newsPosts50);
         $cacheBlock->save();
     }
     if (isset($changedAttributes['is_index']) && $this->is_index != $changedAttributes['is_index'] || isset($changedAttributes['is_top']) && $this->is_top != $changedAttributes['is_top'] || $this->is_top || $this->is_index) {
         $machineName = 'top3News';
         if (!isset($cacheBlocks[$machineName])) {
             $cacheBlock = new CacheBlock();
             $cacheBlock->machine_name = $machineName;
         } else {
             $cacheBlock = $cacheBlocks[$machineName];
         }
         $cacheBlock->content = SiteBlock::getTop3News($cacheStatus);
         $cacheBlock->save();
         $machineName = 'top6News';
         if (!isset($cacheBlocks[$machineName])) {
             $cacheBlock = new CacheBlock();
             $cacheBlock->machine_name = $machineName;
         } else {
             $cacheBlock = $cacheBlocks[$machineName];
         }
         $cacheBlock->content = SiteBlock::getTop6News($cacheStatus);
         $cacheBlock->save();
     }
     if ($this->content_category_id == self::CATEGORY_BLOG) {
         $machineName = 'lastBlogPosts';
         if (!isset($cacheBlocks[$machineName])) {
             $cacheBlock = new CacheBlock();
             $cacheBlock->machine_name = $machineName;
         } else {
             $cacheBlock = $cacheBlocks[$machineName];
         }
         $cacheBlock->content = SiteBlock::getBlogPosts($cacheStatus);
         $cacheBlock->save();
         $machineName = 'blogPostsByRating';
         if (!isset($cacheBlocks[$machineName])) {
             $cacheBlock = new CacheBlock();
             $cacheBlock->machine_name = $machineName;
         } else {
             $cacheBlock = $cacheBlocks[$machineName];
         }
         $cacheBlock->content = SiteBlock::getBlogPostsByRating($cacheStatus);
         $cacheBlock->save();
     }
 }