Commit 236a608c8a3acd7aa3cd3f4d96d5fe0e4a85babb
1 parent
e82beebc
test
Showing
3 changed files
with
51 additions
and
14 deletions
Show diff stats
common/models/User.php
| @@ -101,7 +101,7 @@ | @@ -101,7 +101,7 @@ | ||
| 101 | { | 101 | { |
| 102 | return [ | 102 | return [ |
| 103 | [ | 103 | [ |
| 104 | - ['firstname'], | 104 | + [ 'firstname' ], |
| 105 | 'required', | 105 | 'required', |
| 106 | ], | 106 | ], |
| 107 | [ | 107 | [ |
| @@ -839,11 +839,42 @@ | @@ -839,11 +839,42 @@ | ||
| 839 | ->scalar(); | 839 | ->scalar(); |
| 840 | } | 840 | } |
| 841 | 841 | ||
| 842 | + public function getNewMessagesCount() | ||
| 843 | + { | ||
| 844 | + $chats = Chat::find() | ||
| 845 | + ->select([ 'chat_id' ]) | ||
| 846 | + ->where([ | ||
| 847 | + 'or', | ||
| 848 | + [ 'from_user' => $this->id ], | ||
| 849 | + [ 'to_user' => $this->id ], | ||
| 850 | + ]) | ||
| 851 | + ->column(); | ||
| 852 | + return Message::find()->select(['chat_id'])->distinct()->where(['chat_id' => $chats, 'status' => Message::NEW_MESSAGE])->andWhere(['not', ['user_id' => $this->id]])->count(); | ||
| 853 | + } | ||
| 854 | + | ||
| 842 | public function getCommentProjects() | 855 | public function getCommentProjects() |
| 843 | { | 856 | { |
| 844 | return $this->hasMany(CommentProject::className(), [ 'user_id' => 'id' ]); | 857 | return $this->hasMany(CommentProject::className(), [ 'user_id' => 'id' ]); |
| 845 | } | 858 | } |
| 846 | 859 | ||
| 860 | + public function getCommentProjectsActive() | ||
| 861 | + { | ||
| 862 | + return $this->getCommentProjects() | ||
| 863 | + ->where([ | ||
| 864 | + 'between', | ||
| 865 | + 'state', | ||
| 866 | + CommentProject::STATE_NEW, | ||
| 867 | + CommentProject::STATE_PERFORMER, | ||
| 868 | + ]) | ||
| 869 | + ->andWhere([ | ||
| 870 | + 'status' => [ | ||
| 871 | + CommentProject::STATUS_ACTIVE, | ||
| 872 | + CommentProject::STATUS_ANONYMOUS, | ||
| 873 | + CommentProject::STATUS_PERSONAL, | ||
| 874 | + ], | ||
| 875 | + ]); | ||
| 876 | + } | ||
| 877 | + | ||
| 847 | public function getChat($user_id) | 878 | public function getChat($user_id) |
| 848 | { | 879 | { |
| 849 | return Chat::find() | 880 | return Chat::find() |
frontend/views/accounts/_portfolio_form.php
| @@ -288,12 +288,11 @@ $form->end(); | @@ -288,12 +288,11 @@ $form->end(); | ||
| 288 | $.post( | 288 | $.post( |
| 289 | "/accounts/gallery-cover", {gallery_id : gallery_id}, function(data) | 289 | "/accounts/gallery-cover", {gallery_id : gallery_id}, function(data) |
| 290 | { | 290 | { |
| 291 | - if(!($('#cover_old_img').val().length) && !($('#portfolio-cover').val().length)) | 291 | + if(data.length && !($('#cover_old_img').val().length) && !($('#portfolio-cover').val().length)) |
| 292 | { | 292 | { |
| 293 | $('#portfolio-cover').val(data); | 293 | $('#portfolio-cover').val(data); |
| 294 | var newimg = document.createElement("img"); | 294 | var newimg = document.createElement("img"); |
| 295 | newimg.setAttribute("src", data); | 295 | newimg.setAttribute("src", data); |
| 296 | - | ||
| 297 | $('#cover_img_block .admin-avatar-pattern').append(newimg); | 296 | $('#cover_img_block .admin-avatar-pattern').append(newimg); |
| 298 | } | 297 | } |
| 299 | } | 298 | } |
frontend/views/layouts/main.php
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | /* @var $this \yii\web\View */ | 3 | /* @var $this \yii\web\View */ |
| 4 | /* @var $content string */ | 4 | /* @var $content string */ |
| 5 | 5 | ||
| 6 | + use common\modules\comment\models\CommentProject; | ||
| 6 | use yii\helpers\Html; | 7 | use yii\helpers\Html; |
| 7 | use yii\helpers\Url; | 8 | use yii\helpers\Url; |
| 8 | use yii\widgets\Menu; | 9 | use yii\widgets\Menu; |
| @@ -141,7 +142,7 @@ | @@ -141,7 +142,7 @@ | ||
| 141 | </ul> | 142 | </ul> |
| 142 | 143 | ||
| 143 | <div class="search-main-menu"> | 144 | <div class="search-main-menu"> |
| 144 | - <form action="<?=Url::to(['search/common'])?>" method="get"> | 145 | + <form action="<?= Url::to([ 'search/common' ]) ?>" method="get"> |
| 145 | <input value="" name="query" type="text"/> | 146 | <input value="" name="query" type="text"/> |
| 146 | <input type="hidden" value="1" name="action"/> | 147 | <input type="hidden" value="1" name="action"/> |
| 147 | <button type="submit" value=""></button> | 148 | <button type="submit" value=""></button> |
| @@ -168,11 +169,11 @@ | @@ -168,11 +169,11 @@ | ||
| 168 | 'items' => [ | 169 | 'items' => [ |
| 169 | [ | 170 | [ |
| 170 | 'url' => [ '/projects' ], | 171 | 'url' => [ '/projects' ], |
| 171 | - 'template' => '<a href="{url}" class="main-menu-icons-home"><span>' . count(\Yii::$app->user->identity->commentProjects) . '</span></a>', | 172 | + 'template' => '<a href="{url}" class="main-menu-icons-home"><span>' . count(\Yii::$app->user->identity->commentProjectsActive) . '</span></a>', |
| 172 | ], | 173 | ], |
| 173 | [ | 174 | [ |
| 174 | 'url' => [ 'chat/list' ], | 175 | 'url' => [ 'chat/list' ], |
| 175 | - 'template' => '<a href="{url}" class="main-menu-icons-edit"><span>' . \Yii::$app->user->identity->chatCount . '</span></a>', | 176 | + 'template' => '<a href="{url}" class="main-menu-icons-edit"><span>' . \Yii::$app->user->identity->newMessagesCount . '</span></a>', |
| 176 | ], | 177 | ], |
| 177 | [ | 178 | [ |
| 178 | 'url' => [ '/bookmarks' ], | 179 | 'url' => [ '/bookmarks' ], |
| @@ -223,9 +224,9 @@ | @@ -223,9 +224,9 @@ | ||
| 223 | 'options' => [ | 224 | 'options' => [ |
| 224 | 'class' => 'footer-menu', | 225 | 'class' => 'footer-menu', |
| 225 | ], | 226 | ], |
| 226 | - 'items' => $items | 227 | + 'items' => $items, |
| 227 | ]); | 228 | ]); |
| 228 | - unset($items); | 229 | + unset( $items ); |
| 229 | ?> | 230 | ?> |
| 230 | </div> | 231 | </div> |
| 231 | 232 | ||
| @@ -234,8 +235,11 @@ | @@ -234,8 +235,11 @@ | ||
| 234 | $items = [ | 235 | $items = [ |
| 235 | [ | 236 | [ |
| 236 | 'label' => 'Рейтинг компаний', | 237 | 'label' => 'Рейтинг компаний', |
| 237 | - 'url' => [ 'search/performer', 'SearchPerformerForm[type]' => 2 ], | ||
| 238 | - ] | 238 | + 'url' => [ |
| 239 | + 'search/performer', | ||
| 240 | + 'SearchPerformerForm[type]' => 2, | ||
| 241 | + ], | ||
| 242 | + ], | ||
| 239 | ]; | 243 | ]; |
| 240 | if(empty( \Yii::$app->user->id )) { | 244 | if(empty( \Yii::$app->user->id )) { |
| 241 | array_unshift($items, [ | 245 | array_unshift($items, [ |
| @@ -249,7 +253,7 @@ | @@ -249,7 +253,7 @@ | ||
| 249 | ], | 253 | ], |
| 250 | 'items' => $items, | 254 | 'items' => $items, |
| 251 | ]); | 255 | ]); |
| 252 | - unset($items); | 256 | + unset( $items ); |
| 253 | ?> | 257 | ?> |
| 254 | <div class="footer-menu-project"> | 258 | <div class="footer-menu-project"> |
| 255 | <?php | 259 | <?php |
| @@ -284,7 +288,10 @@ | @@ -284,7 +288,10 @@ | ||
| 284 | $items = [ | 288 | $items = [ |
| 285 | [ | 289 | [ |
| 286 | 'label' => 'Рейтинг компаний', | 290 | 'label' => 'Рейтинг компаний', |
| 287 | - 'url' => [ 'search/performer', 'SearchPerformerForm[type]' => 2 ], | 291 | + 'url' => [ |
| 292 | + 'search/performer', | ||
| 293 | + 'SearchPerformerForm[type]' => 2, | ||
| 294 | + ], | ||
| 288 | ], | 295 | ], |
| 289 | ]; | 296 | ]; |
| 290 | if(empty( \Yii::$app->user->id )) { | 297 | if(empty( \Yii::$app->user->id )) { |
| @@ -297,9 +304,9 @@ | @@ -297,9 +304,9 @@ | ||
| 297 | 'options' => [ | 304 | 'options' => [ |
| 298 | 'class' => 'footer-menu', | 305 | 'class' => 'footer-menu', |
| 299 | ], | 306 | ], |
| 300 | - 'items' => $items | 307 | + 'items' => $items, |
| 301 | ]); | 308 | ]); |
| 302 | - unset($items); | 309 | + unset( $items ); |
| 303 | ?> | 310 | ?> |
| 304 | <div class="footer-menu-project-two"> | 311 | <div class="footer-menu-project-two"> |
| 305 | <?php | 312 | <?php |