添加backend/components/filters/AccessControl.php
Showing
4 changed files
with
49 additions
and
24 deletions
backend/components/filters/AccessControl.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace backend\components\filters; | ||
4 | + | ||
5 | +use Yii; | ||
6 | +use yii\base\ActionFilter; | ||
7 | + | ||
8 | +/** | ||
9 | + * | ||
10 | + * @author wuxiao | ||
11 | + */ | ||
12 | +class AccessControl extends \yii\filters\AccessControl | ||
13 | +//class AccessControl extends ActionFilter | ||
14 | +{ | ||
15 | + | ||
16 | + public function init() | ||
17 | + { | ||
18 | + parent::init(); | ||
19 | + } | ||
20 | + | ||
21 | + public function beforeAction($action) | ||
22 | + { | ||
23 | + return parent::beforeAction($action); | ||
24 | + } | ||
25 | +} |
@@ -3,6 +3,8 @@ namespace backend\controllers; | @@ -3,6 +3,8 @@ namespace backend\controllers; | ||
3 | 3 | ||
4 | use Yii; | 4 | use Yii; |
5 | use yii\web\Controller; | 5 | use yii\web\Controller; |
6 | +use yii\helpers\ArrayHelper; | ||
7 | +use backend\components\filters\AccessControl; | ||
6 | 8 | ||
7 | /** | 9 | /** |
8 | * Site controller | 10 | * Site controller |
@@ -26,6 +28,25 @@ class BaseController extends Controller | @@ -26,6 +28,25 @@ class BaseController extends Controller | ||
26 | parent::init(); | 28 | parent::init(); |
27 | } | 29 | } |
28 | 30 | ||
31 | + /** | ||
32 | + * @inheritdoc | ||
33 | + */ | ||
34 | + public function behaviors() | ||
35 | + { | ||
36 | + return []; | ||
37 | + return ArrayHelper::merge(parent::behaviors(), [ | ||
38 | + [ | ||
39 | + 'class' => AccessControl::className(), | ||
40 | + 'rules' => [ | ||
41 | + [ | ||
42 | + 'allow' => true, | ||
43 | + 'roles' => ['@'], | ||
44 | + ], | ||
45 | + ], | ||
46 | + ], | ||
47 | + ]); | ||
48 | + } | ||
49 | + | ||
29 | public function beforeAction($action) { | 50 | public function beforeAction($action) { |
30 | Yii::setAlias('@web', Yii::getAlias('@admin')); | 51 | Yii::setAlias('@web', Yii::getAlias('@admin')); |
31 | Yii::$app->setHomeUrl(Yii::getAlias('@web')); | 52 | Yii::$app->setHomeUrl(Yii::getAlias('@web')); |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | <img class="img-circle" src="/images/photos/profile.png" alt=""> | 4 | <img class="img-circle" src="/images/photos/profile.png" alt=""> |
5 | </a> | 5 | </a> |
6 | <div class="media-body"> | 6 | <div class="media-body"> |
7 | - <h4 class="media-heading"><?=Yii::$app->user->getIdentity()->username?></h4> | 7 | + <h4 class="media-heading"><?=Yii::$app->user->isGuest ? 'Guest' : Yii::$app->user->getIdentity()->username?></h4> |
8 | <small class="text-muted">超级管理员</small> | 8 | <small class="text-muted">超级管理员</small> |
9 | </div> | 9 | </div> |
10 | </div><!-- media --> | 10 | </div><!-- media --> |
@@ -22,28 +22,6 @@ class LivingController extends BaseController | @@ -22,28 +22,6 @@ class LivingController extends BaseController | ||
22 | return parent::beforeAction($action); | 22 | return parent::beforeAction($action); |
23 | } | 23 | } |
24 | 24 | ||
25 | - public function behaviors() | ||
26 | - { | ||
27 | - return []; | ||
28 | - return [ | ||
29 | - [ | ||
30 | - 'class' => 'yii\filters\PageCache', | ||
31 | - 'only' => ['detail'], | ||
32 | - 'duration' => 3600, | ||
33 | - 'cache' => 'pageCache', | ||
34 | - 'variations' => [ | ||
35 | - $this->requests('room_id',0), | ||
36 | - $this->requests('video_id',0), | ||
37 | - ], | ||
38 | - /*'dependency' => [ | ||
39 | - 'class' => 'yii\caching\DbDependency', | ||
40 | - 'sql' => 'SELECT COUNT(*) FROM post', | ||
41 | - 'sql' => 'SELECT MAX(updated_at) FROM post', | ||
42 | - ],*/ | ||
43 | - ], | ||
44 | - ]; | ||
45 | - } | ||
46 | - | ||
47 | /** | 25 | /** |
48 | * 精选房间 | 26 | * 精选房间 |
49 | */ | 27 | */ |
@@ -299,13 +277,14 @@ class LivingController extends BaseController | @@ -299,13 +277,14 @@ class LivingController extends BaseController | ||
299 | $this->renderJson(Yii::$app->params['success_code'],'',$ret); | 277 | $this->renderJson(Yii::$app->params['success_code'],'',$ret); |
300 | }elseif ($video_id = $this->requests('video_id')) | 278 | }elseif ($video_id = $this->requests('video_id')) |
301 | {//重播视频详情 | 279 | {//重播视频详情 |
302 | - $key = __CLASS__.__FUNCTION__.'video_id'.$room_id; | 280 | + $key = __CLASS__.__FUNCTION__.'video_id'.$video_id; |
303 | if (!$ret = $this->cache->get($key)){ | 281 | if (!$ret = $this->cache->get($key)){ |
304 | if (!$model = Video::findOne(['id'=>$video_id])){ | 282 | if (!$model = Video::findOne(['id'=>$video_id])){ |
305 | $this->renderJson(Yii::$app->params['failed_code'],'找不到该回放'); | 283 | $this->renderJson(Yii::$app->params['failed_code'],'找不到该回放'); |
306 | } | 284 | } |
307 | 285 | ||
308 | $ret = [ | 286 | $ret = [ |
287 | + 'video_id'=>$model->id, | ||
309 | 'master_pic'=>'', | 288 | 'master_pic'=>'', |
310 | 'master_name'=>'', | 289 | 'master_name'=>'', |
311 | 'master_meta'=>'', | 290 | 'master_meta'=>'', |
-
Please register or login to post a comment