From f7b97c9efdf5aeee868bd84cf5e51c7487470291 Mon Sep 17 00:00:00 2001 From: Yarik Date: Tue, 19 Apr 2016 17:22:52 +0300 Subject: [PATCH] test --- common/components/UserCheck.php | 52 ++++++++++++++++++++++++++-------------------------- frontend/assets/AppAsset.php | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------- frontend/controllers/CompanyController.php | 9 +++++++++ frontend/controllers/PerformerController.php | 9 +++++++++ 4 files changed, 99 insertions(+), 73 deletions(-) diff --git a/common/components/UserCheck.php b/common/components/UserCheck.php index 693f49e..041b5ad 100644 --- a/common/components/UserCheck.php +++ b/common/components/UserCheck.php @@ -1,32 +1,32 @@ on(\yii\base\Application::EVENT_BEFORE_REQUEST, function($event) { + if(\Yii::$app->user->identity instanceof User) { + $userInfo = \Yii::$app->user->identity->userInfo; + if($userInfo instanceof UserInfo) { + $expression = new Expression('NOW()'); + $userInfo->date_visit = (new \yii\db\Query)->select($expression) + ->scalar(); + $userInfo->save(); + } -use common\models\User; -use common\models\UserInfo; -use Yii; -use yii\base\BootstrapInterface; -use yii\db\Expression; - - -class UserCheck implements BootstrapInterface -{ - public function bootstrap($app){ - \Yii::$app->on(\yii\base\Application::EVENT_BEFORE_REQUEST, function ($event) { - - if(\Yii::$app->user->identity instanceof User){ - $userInfo = \Yii::$app->user->identity->userInfo; - if($userInfo instanceof UserInfo){ - $expression = new Expression('NOW()'); - $userInfo->date_visit = (new \yii\db\Query)->select($expression)->scalar(); - $userInfo->save(); } + }); + return $app; + } - } - - }); - return $app; - } - -} \ No newline at end of file + } \ No newline at end of file diff --git a/frontend/assets/AppAsset.php b/frontend/assets/AppAsset.php index c28d4f1..2c56efd 100755 --- a/frontend/assets/AppAsset.php +++ b/frontend/assets/AppAsset.php @@ -1,48 +1,56 @@ - * @since 2.0 - */ -class AppAsset extends AssetBundle -{ - public $basePath = '@webroot'; - public $baseUrl = '@web'; - public $css = [ - '/css/style.css', - '/admin/css/flags32.css', - 'https://fonts.googleapis.com/css?family=Roboto:400,700&subset=cyrillic,latin', - '/css/owl.carousel.css' - ]; - public $js = [ - '/js/script.js', - //'http://maps.google.com/maps/api/js?sensor=false', - '/js/markerclusterer.js', - '/js/jquery.scrollbox.min.js', - '/js/slider.js', - '/js/jquery.rating.js', - '/admin/js/option.js', -// '/js/jmousewhell.js', - '/js/autoresize.jquery.js', - '/js/jquery.MultiFile.js', - '/js/myGallery_min.js', - '/js/fieldWidget.js', - '/js/owl.carousel.min.js', - ]; - public $depends = [ - 'yii\web\YiiAsset', - 'yii\web\JqueryAsset', - 'frontend\assets\FancyboxAsset', - ]; - public $jsOptions = array( - 'position' => \yii\web\View::POS_HEAD - ); -} + /** + * @link http://www.yiiframework.com/ + * @copyright Copyright (c) 2008 Yii Software LLC + * @license http://www.yiiframework.com/license/ + */ + + namespace frontend\assets; + + use yii\web\AssetBundle; + + /** + * @author Qiang Xue + * @since 2.0 + */ + class AppAsset extends AssetBundle + { + + public $basePath = '@webroot'; + + public $baseUrl = '@web'; + + public $css = [ + '/css/style.css', + '/admin/css/flags32.css', + 'https://fonts.googleapis.com/css?family=Roboto:400,700&subset=cyrillic,latin', + '/css/owl.carousel.css', + ]; + + public $js = [ + '/js/script.js', + //'http://maps.google.com/maps/api/js?sensor=false', + '/js/markerclusterer.js', + '/js/jquery.scrollbox.min.js', + '/js/slider.js', + '/js/jquery.rating.js', + '/admin/js/option.js', + '/js/forms.js', + // '/js/jmousewhell.js', + '/js/autoresize.jquery.js', + '/js/jquery.MultiFile.js', + '/js/myGallery_min.js', + '/js/fieldWidget.js', + '/js/owl.carousel.min.js', + ]; + + public $depends = [ + 'yii\web\YiiAsset', + 'yii\web\JqueryAsset', + 'frontend\assets\FancyboxAsset', + ]; + + public $jsOptions = array( + 'position' => \yii\web\View::POS_HEAD, + ); + } diff --git a/frontend/controllers/CompanyController.php b/frontend/controllers/CompanyController.php index ae5c266..03134f1 100755 --- a/frontend/controllers/CompanyController.php +++ b/frontend/controllers/CompanyController.php @@ -418,6 +418,15 @@ if(!empty(\Yii::$app->request->get('type'))) { $action->controller->view->params['type'] = \Yii::$app->request->get('type'); } + if(!empty(\Yii::$app->request->get('company_id'))) { + $user = User::findOne(\Yii::$app->request->get('company_id')); + if(!empty($user) && $user->type == 1) { + $queryParams = \Yii::$app->request->queryParams; + unset($queryParams['company_id']); + $queryParams['performer_id'] = $user->id; + return $this->redirect(array_merge(['performer/'.$action->id], $queryParams)); + } + } return parent::beforeAction($action); } } diff --git a/frontend/controllers/PerformerController.php b/frontend/controllers/PerformerController.php index b5a1c1f..30c6db6 100755 --- a/frontend/controllers/PerformerController.php +++ b/frontend/controllers/PerformerController.php @@ -331,6 +331,15 @@ if(!empty( \Yii::$app->request->get('type') )) { $action->controller->view->params[ 'type' ] = \Yii::$app->request->get('type'); } + if(!empty(\Yii::$app->request->get('performer_id'))) { + $user = User::findOne(\Yii::$app->request->get('performer_id')); + if(!empty($user) && $user->type == 2) { + $queryParams = \Yii::$app->request->queryParams; + unset($queryParams['performer_id']); + $queryParams['company_id'] = $user->id; + return $this->redirect(array_merge(['company/'.$action->id], $queryParams)); + } + } return parent::beforeAction($action); } } -- libgit2 0.21.4