当前位置: 首页>>代码示例>>PHP>>正文


PHP User::loggedId方法代码示例

本文整理汇总了PHP中bizley\podium\models\User::loggedId方法的典型用法代码示例。如果您正苦于以下问题:PHP User::loggedId方法的具体用法?PHP User::loggedId怎么用?PHP User::loggedId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bizley\podium\models\User的用法示例。


在下文中一共展示了User::loggedId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: blame

 /**
  * Returns ID of user responsible for logged action.
  * @return integer|null
  */
 public static function blame()
 {
     if (Yii::$app instanceof Application && !Yii::$app->user->isGuest) {
         return User::loggedId();
     }
     return null;
 }
开发者ID:Avenger1,项目名称:yii2-podium,代码行数:11,代码来源:Log.php

示例2: search

 /**
  * Searches for subscription
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = self::find()->where(['user_id' => User::loggedId()]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['defaultPageSize' => 10, 'forcePageParam' => false]]);
     $dataProvider->sort->defaultOrder = ['post_seen' => SORT_ASC, 'id' => SORT_DESC];
     $dataProvider->pagination->pageSize = Yii::$app->session->get('per-page', 20);
     return $dataProvider;
 }
开发者ID:gitter-badger,项目名称:yii2-podium,代码行数:13,代码来源:Subscription.php

示例3: search

 /**
  * Searches for threads with unread posts.
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search()
 {
     $loggedId = User::loggedId();
     $query = Thread::find()->joinWith('threadView')->where(['or', ['and', ['user_id' => $loggedId], new Expression('`new_last_seen` < `new_post_at`')], ['and', ['user_id' => $loggedId], new Expression('`edited_last_seen` < `edited_post_at`')], ['user_id' => null]]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['defaultPageSize' => 10, 'forcePageParam' => false]]);
     $dataProvider->sort->defaultOrder = ['edited_post_at' => SORT_ASC, 'id' => SORT_ASC];
     $dataProvider->pagination->pageSize = Yii::$app->session->get('per-page', 20);
     return $dataProvider;
 }
开发者ID:gitter-badger,项目名称:yii2-podium,代码行数:14,代码来源:ThreadView.php

示例4: search

 /**
  * Searches for subscription
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = self::find()->where(['user_id' => User::loggedId()]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['defaultPageSize' => 10, 'forcePageParam' => false]]);
     $dataProvider->sort->defaultOrder = ['post_seen' => SORT_ASC, 'id' => SORT_DESC];
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     return $dataProvider;
 }
开发者ID:Avenger1,项目名称:yii2-podium,代码行数:15,代码来源:Subscription.php

示例5: searchDeleted

 /**
  * Searches for deleted messages.
  * @param array $params
  * @return ActiveDataProvider
  */
 public function searchDeleted($params)
 {
     $dataProvider = $this->search();
     $dataProvider->query->where(['or', ['and', ['sender_id' => User::loggedId()], ['sender_status' => Message::getDeletedStatuses()]], ['and', ['receiver_id' => User::loggedId()], ['receiver_status' => Message::getDeletedStatuses()]]]);
     if (!($this->load($params) && $this->validate())) {
         $dataProvider->query->joinWith(['receiverUser' => function ($q) {
             $q->from(User::tableName() . ' pdu_receiver');
         }, 'senderUser' => function ($q) {
             $q->from(User::tableName() . ' pdu_sender');
         }]);
         return $dataProvider;
     }
     $dataProvider->query->andFilterWhere(['like', 'topic', $this->topic]);
     $dataProvider->query->joinWith(['receiverUser' => function ($q) {
         $q->from(User::tableName() . ' pdu_receiver')->where(['like', 'pdu_receiver.username', $this->receiverName]);
     }, 'senderUser' => function ($q) {
         $q->from(User::tableName() . ' pdu_sender')->where(['like', 'pdu_sender.username', $this->senderName]);
     }]);
     return $dataProvider;
 }
开发者ID:Avenger1,项目名称:yii2-podium,代码行数:25,代码来源:MessageSearch.php

示例6: search

 /**
  * Searches for sent messages.
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     // not very proud of this query - slow for sure
     // let me know if it can be done better.
     $subquery = (new Query())->select(['m2.replyto'])->from(['m1' => Message::tableName()])->leftJoin(['m2' => Message::tableName()], '`m1`.`replyto` = `m2`.`id`')->where(['is not', 'm2.replyto', null]);
     $query = self::find()->where(['and', ['sender_id' => User::loggedId(), 'sender_status' => Message::getSentStatuses()], ['not in', Message::tableName() . '.id', $subquery]]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['attributes' => ['id', 'topic', 'created_at']]]);
     $dataProvider->sort->defaultOrder = ['id' => SORT_DESC];
     $dataProvider->pagination->pageSize = Yii::$app->session->get('per-page', 20);
     if (!($this->load($params) && $this->validate())) {
         $dataProvider->query->joinWith(['messageReceivers' => function ($q) {
             $q->joinWith(['receiver']);
         }]);
         return $dataProvider;
     }
     $dataProvider->query->andFilterWhere(['like', 'topic', $this->topic]);
     if (preg_match('/^(forum|orum|rum|um|m)?#([0-9]+)$/', strtolower($this->receiverName), $matches)) {
         $dataProvider->query->joinWith(['messageReceivers' => function ($q) use($matches) {
             $q->joinWith(['receiver' => function ($q) use($matches) {
                 $q->andFilterWhere(['username' => ['', null], User::tableName() . '.id' => $matches[2]]);
             }]);
         }]);
     } elseif (preg_match('/^([0-9]+)$/', $this->receiverName, $matches)) {
         $dataProvider->query->joinWith(['messageReceivers' => function ($q) use($matches) {
             $q->joinWith(['receiver' => function ($q) use($matches) {
                 $q->andFilterWhere(['or', ['like', 'username', $this->receiverName], ['username' => ['', null], 'id' => $matches[1]]]);
             }]);
         }]);
     } else {
         $dataProvider->query->joinWith(['messageReceivers' => function ($q) {
             $q->joinWith(['receiver' => function ($q) {
                 $q->andFilterWhere(['like', User::tableName() . '.username', $this->receiverName]);
             }]);
         }]);
     }
     return $dataProvider;
 }
开发者ID:gitter-badger,项目名称:yii2-podium,代码行数:42,代码来源:MessageSearch.php

示例7: updateFriend

 /**
  * Updates friend status for the user.
  * @return boolean
  * @since 0.2
  */
 public function updateFriend()
 {
     try {
         if ($this->isBefriendedBy(User::loggedId())) {
             Yii::$app->db->createCommand()->delete('{{%podium_user_friend}}', 'user_id = :uid AND friend_id = :iid', [':uid' => User::loggedId(), ':iid' => $this->id])->execute();
             Log::info('User unfriended', $this->id, __METHOD__);
         } else {
             Yii::$app->db->createCommand()->insert('{{%podium_user_friend}}', ['user_id' => User::loggedId(), 'friend_id' => $this->id])->execute();
             Log::info('User befriended', $this->id, __METHOD__);
         }
         Cache::getInstance()->deleteElement('user.friends', $this->id);
         return true;
     } catch (Exception $e) {
         Log::error($e->getMessage(), null, __METHOD__);
     }
     return false;
 }
开发者ID:pezisc,项目名称:yii2-podium,代码行数:22,代码来源:User.php

示例8: actionDelete

 /**
  * Deleting the user of given ID.
  * @param integer $id
  * @return \yii\web\Response
  */
 public function actionDelete($id = null)
 {
     if (User::can(Rbac::PERM_DELETE_USER)) {
         $model = User::findOne((int) $id);
         if (empty($model)) {
             $this->error(Yii::t('podium/flash', 'Sorry! We can not find Member with this ID.'));
         } elseif ($model->id == User::loggedId()) {
             $this->error(Yii::t('podium/flash', 'Sorry! You can not delete your own account.'));
         } else {
             if ($model->delete()) {
                 Cache::getInstance()->delete('members.fieldlist');
                 Cache::getInstance()->delete('forum.memberscount');
                 Activity::deleteUser($model->id);
                 Log::info('User deleted', $model->id, __METHOD__);
                 $this->success(Yii::t('podium/flash', 'User has been deleted.'));
             } else {
                 Log::error('Error while deleting user', $model->id, __METHOD__);
                 $this->error(Yii::t('podium/flash', 'Sorry! There was some error while deleting the user.'));
             }
         }
     } else {
         $this->error(Yii::t('podium/flash', 'You are not allowed to perform this action.'));
     }
     return $this->redirect(['admin/members']);
 }
开发者ID:aekkapun,项目名称:yii2-podium,代码行数:30,代码来源:AdminController.php

示例9: remove

 /**
  * Removes message.
  * @param integer $perm Permanent removal flag
  * @return boolean
  */
 public function remove($perm = 0)
 {
     $clearCache = false;
     if ($this->receiver_status == self::STATUS_NEW) {
         $clearCache = true;
     }
     if ($this->receiver_id == User::loggedId()) {
         $this->receiver_status = $perm ? self::STATUS_REMOVED : self::STATUS_DELETED;
     }
     if ($this->sender_id == User::loggedId()) {
         $this->sender_status = $perm ? self::STATUS_REMOVED : self::STATUS_DELETED;
     }
     if ($this->receiver_status == self::STATUS_REMOVED && $this->sender_status == self::STATUS_REMOVED) {
         if ($this->delete()) {
             if ($clearCache) {
                 Cache::getInstance()->deleteElement('user.newmessages', User::loggedId());
             }
             return true;
         } else {
             return false;
         }
     }
     if ($this->save()) {
         if ($clearCache) {
             Cache::getInstance()->deleteElement('user.newmessages', User::loggedId());
         }
         return true;
     } else {
         return false;
     }
 }
开发者ID:Avenger1,项目名称:yii2-podium,代码行数:36,代码来源:Message.php

示例10: actionView

 /**
  * Viewing the message of given ID.
  * @param integer $id
  * @return string|\yii\web\Response
  */
 public function actionView($id = null)
 {
     $model = Message::find()->where(['and', ['id' => $id], ['or', 'receiver_id' => User::loggedId(), 'sender_id' => User::loggedId()]])->limit(1)->one();
     if ($model) {
         if ($model->receiver_id == User::loggedId() && $model->receiver_status == Message::STATUS_NEW) {
             $model->receiver_status = Message::STATUS_READ;
             if ($model->save()) {
                 Cache::getInstance()->deleteElement('user.newmessages', User::loggedId());
             }
         }
         return $this->render('view', ['model' => $model]);
     } else {
         $this->error(Yii::t('podium/flash', 'Sorry! We can not find the message with the given ID.'));
         return $this->redirect(['messages/inbox']);
     }
 }
开发者ID:Avenger1,项目名称:yii2-podium,代码行数:21,代码来源:MessagesController.php

示例11: actionThumb

 /**
  * Voting on the post.
  * @return string|\yii\web\Response
  */
 public function actionThumb()
 {
     if (Yii::$app->request->isAjax) {
         $data = ['error' => 1, 'msg' => Html::tag('span', Html::tag('span', '', ['class' => 'glyphicon glyphicon-warning-sign']) . ' ' . Yii::t('podium/view', 'Error while voting on this post!'), ['class' => 'text-danger'])];
         if (!Yii::$app->user->isGuest) {
             $postId = Yii::$app->request->post('post');
             $thumb = Yii::$app->request->post('thumb');
             if (is_numeric($postId) && $postId > 0 && in_array($thumb, ['up', 'down'])) {
                 $post = Post::findOne((int) $postId);
                 if ($post) {
                     if ($post->thread->locked) {
                         $data = ['error' => 1, 'msg' => Html::tag('span', Html::tag('span', '', ['class' => 'glyphicon glyphicon-warning-sign']) . ' ' . Yii::t('podium/view', 'This thread is locked.'), ['class' => 'text-info'])];
                     } else {
                         if ($post->author_id == User::loggedId()) {
                             return Json::encode(['error' => 1, 'msg' => Html::tag('span', Html::tag('span', '', ['class' => 'glyphicon glyphicon-warning-sign']) . ' ' . Yii::t('podium/view', 'You can not vote on your own post!'), ['class' => 'text-info'])]);
                         }
                         $count = 0;
                         $votes = Cache::getInstance()->get('user.votes.' . User::loggedId());
                         if ($votes !== false) {
                             if ($votes['expire'] < time()) {
                                 $votes = false;
                             } elseif ($votes['count'] >= 10) {
                                 return Json::encode(['error' => 1, 'msg' => Html::tag('span', Html::tag('span', '', ['class' => 'glyphicon glyphicon-warning-sign']) . ' ' . Yii::t('podium/view', '10 votes per hour limit reached!'), ['class' => 'text-danger'])]);
                             } else {
                                 $count = $votes['count'];
                             }
                         }
                         if ($post->thumb) {
                             if ($post->thumb->thumb == 1 && $thumb == 'down') {
                                 $post->thumb->thumb = -1;
                                 if ($post->thumb->save()) {
                                     $post->updateCounters(['likes' => -1, 'dislikes' => 1]);
                                 }
                             } elseif ($post->thumb->thumb == -1 && $thumb == 'up') {
                                 $post->thumb->thumb = 1;
                                 if ($post->thumb->save()) {
                                     $post->updateCounters(['likes' => 1, 'dislikes' => -1]);
                                 }
                             }
                         } else {
                             $postThumb = new PostThumb();
                             $postThumb->post_id = $post->id;
                             $postThumb->user_id = User::loggedId();
                             $postThumb->thumb = $thumb == 'up' ? 1 : -1;
                             if ($postThumb->save()) {
                                 if ($thumb == 'up') {
                                     $post->updateCounters(['likes' => 1]);
                                 } else {
                                     $post->updateCounters(['dislikes' => 1]);
                                 }
                             }
                         }
                         $data = ['error' => 0, 'likes' => '+' . $post->likes, 'dislikes' => '-' . $post->dislikes, 'summ' => $post->likes - $post->dislikes, 'msg' => Html::tag('span', Html::tag('span', '', ['class' => 'glyphicon glyphicon-ok-circle']) . ' ' . Yii::t('podium/view', 'Your vote has been saved!'), ['class' => 'text-success'])];
                         if ($count == 0) {
                             Cache::getInstance()->set('user.votes.' . User::loggedId(), ['count' => 1, 'expire' => time() + 3600]);
                         } else {
                             Cache::getInstance()->setElement('user.votes.' . User::loggedId(), 'count', $count + 1);
                         }
                     }
                 }
             }
         } else {
             $data = ['error' => 1, 'msg' => Html::tag('span', Html::tag('span', '', ['class' => 'glyphicon glyphicon-warning-sign']) . ' ' . Yii::t('podium/view', 'Please sign in to vote on this post'), ['class' => 'text-info'])];
         }
         return Json::encode($data);
     } else {
         return $this->redirect(['default/index']);
     }
 }
开发者ID:Avenger1,项目名称:yii2-podium,代码行数:73,代码来源:DefaultController.php

示例12: actionMarkSeen

 /**
  * Marking all unread posts as seen.
  * @return string|\yii\web\Response
  */
 public function actionMarkSeen()
 {
     if (Yii::$app->user->isGuest) {
         $this->info(Yii::t('podium/flash', 'This action is available for registered users only.'));
         return $this->redirect(['account/login']);
     }
     try {
         $loggedId = User::loggedId();
         $batch = [];
         $threadsPrevMarked = Thread::find()->joinWith('threadView')->where(['and', ['user_id' => User::loggedId()], ['or', new Expression('`new_last_seen` < `new_post_at`'), new Expression('`edited_last_seen` < `edited_post_at`')]]);
         $time = time();
         foreach ($threadsPrevMarked->each() as $thread) {
             $batch[] = $thread->id;
         }
         if (!empty($batch)) {
             Yii::$app->db->createCommand()->update(ThreadView::tableName(), ['new_last_seen' => $time, 'edited_last_seen' => $time], ['thread_id' => $batch, 'user_id' => $loggedId])->execute();
         }
         $batch = [];
         $threadsNew = Thread::find()->joinWith('threadView')->where(['user_id' => null]);
         foreach ($threadsNew->each() as $thread) {
             $batch[] = [$loggedId, $thread->id, $time, $time];
         }
         if (!empty($batch)) {
             Yii::$app->db->createCommand()->batchInsert(ThreadView::tableName(), ['user_id', 'thread_id', 'new_last_seen', 'edited_last_seen'], $batch)->execute();
         }
         $this->success(Yii::t('podium/flash', 'All unread threads have been marked as seen.'));
         return $this->redirect(['default/index']);
     } catch (Exception $e) {
         Log::error($e->getMessage(), null, __METHOD__);
         $this->error(Yii::t('podium/flash', 'Sorry! There was an error while marking threads as seen. Contact administrator about this problem.'));
         return $this->redirect(['default/unread-posts']);
     }
 }
开发者ID:gitter-badger,项目名称:yii2-podium,代码行数:37,代码来源:DefaultController.php

示例13: function

Pjax::begin();
echo PageSizer::widget();
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'filterSelector' => 'select#per-page', 'tableOptions' => ['class' => 'table table-striped table-hover'], 'columns' => [['attribute' => 'username', 'label' => Yii::t('podium/view', 'Username') . Helper::sortOrder('username'), 'encodeLabel' => false, 'format' => 'raw', 'value' => function ($model) {
    return Html::a($model->podiumName, ['members/view', 'id' => $model->id, 'slug' => $model->podiumSlug], ['data-pjax' => '0']);
}], ['attribute' => 'role', 'label' => Yii::t('podium/view', 'Role') . Helper::sortOrder('role'), 'encodeLabel' => false, 'format' => 'raw', 'filter' => User::getRoles(), 'value' => function ($model) {
    return Helper::roleLabel($model->role);
}], ['attribute' => 'created_at', 'label' => Yii::t('podium/view', 'Joined') . Helper::sortOrder('created_at'), 'encodeLabel' => false, 'value' => function ($model) {
    return Yii::$app->formatter->asDatetime($model->created_at);
}], ['attribute' => 'threads_count', 'label' => Yii::t('podium/view', 'Threads'), 'encodeLabel' => false, 'value' => function ($model) {
    return $model->threadsCount;
}], ['attribute' => 'posts_count', 'label' => Yii::t('podium/view', 'Posts'), 'encodeLabel' => false, 'value' => function ($model) {
    return $model->postsCount;
}], ['class' => ActionColumn::className(), 'header' => Yii::t('podium/view', 'Actions'), 'contentOptions' => ['class' => 'text-right'], 'headerOptions' => ['class' => 'text-right'], 'template' => '{view}' . (!Yii::$app->user->isGuest ? ' {pm}' : ''), 'buttons' => ['view' => function ($url, $model) {
    return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', ['members/view', 'id' => $model->id, 'slug' => $model->podiumSlug], ['class' => 'btn btn-default btn-xs', 'data-pjax' => '0', 'data-toggle' => 'tooltip', 'data-placement' => 'top', 'title' => Yii::t('podium/view', 'View Member')]);
}, 'pm' => function ($url, $model) {
    if ($model->id !== User::loggedId()) {
        return Html::a('<span class="glyphicon glyphicon-envelope"></span>', ['messages/new', 'user' => $model->id], ['class' => 'btn btn-default btn-xs', 'data-pjax' => '0', 'data-toggle' => 'tooltip', 'data-placement' => 'top', 'title' => Yii::t('podium/view', 'Send Message')]);
    } else {
        return Html::a('<span class="glyphicon glyphicon-envelope"></span>', '#', ['class' => 'btn btn-xs disabled text-muted']);
    }
}]]]]);
Pjax::end();
?>
<div class="panel panel-default">
    <div class="panel-body small">
        <ul class="list-inline pull-right">
            <li><a href="<?php 
echo Url::to(['default/index']);
?>
" data-toggle="tooltip" data-placement="top" title="<?php 
echo Yii::t('podium/view', 'Go to the main page');
开发者ID:gitter-badger,项目名称:yii2-podium,代码行数:31,代码来源:index.php

示例14: actionThumb

 /**
  * Voting on the post.
  * @return string|\yii\web\Response
  */
 public function actionThumb()
 {
     if (!Yii::$app->request->isAjax) {
         return $this->redirect(['default/index']);
     }
     $data = ['error' => 1, 'msg' => Html::tag('span', Html::tag('span', '', ['class' => 'glyphicon glyphicon-warning-sign']) . ' ' . Yii::t('podium/view', 'Error while voting on this post!'), ['class' => 'text-danger'])];
     if (!Yii::$app->user->isGuest) {
         $data['msg'] = Html::tag('span', Html::tag('span', '', ['class' => 'glyphicon glyphicon-warning-sign']) . ' ' . Yii::t('podium/view', 'Please sign in to vote on this post'), ['class' => 'text-info']);
         return Json::encode($data);
     }
     $postId = Yii::$app->request->post('post');
     $thumb = Yii::$app->request->post('thumb');
     if (is_numeric($postId) && $postId > 0 && in_array($thumb, ['up', 'down'])) {
         $post = Post::find()->where(['id' => $postId])->limit(1)->one();
         if ($post) {
             if ($post->thread->locked) {
                 $data['msg'] = Html::tag('span', Html::tag('span', '', ['class' => 'glyphicon glyphicon-warning-sign']) . ' ' . Yii::t('podium/view', 'This thread is locked.'), ['class' => 'text-info']);
                 return Json::encode($data);
             }
             if ($post->author_id == User::loggedId()) {
                 $data['msg'] = Html::tag('span', Html::tag('span', '', ['class' => 'glyphicon glyphicon-warning-sign']) . ' ' . Yii::t('podium/view', 'You can not vote on your own post!'), ['class' => 'text-info']);
                 return Json::encode($data);
             }
             $count = 0;
             $votes = Cache::getInstance()->get('user.votes.' . User::loggedId());
             if ($votes !== false) {
                 if ($votes['expire'] < time()) {
                     $votes = false;
                 } elseif ($votes['count'] >= 10) {
                     $data['msg'] = Html::tag('span', Html::tag('span', '', ['class' => 'glyphicon glyphicon-warning-sign']) . ' ' . Yii::t('podium/view', '{max} votes per hour limit reached!', ['max' => 10]), ['class' => 'text-danger']);
                     return Json::encode($data);
                 } else {
                     $count = $votes['count'];
                 }
             }
             if ($post->podiumThumb($thumb == 'up', $count)) {
                 $data = ['error' => 0, 'likes' => '+' . $post->likes, 'dislikes' => '-' . $post->dislikes, 'summ' => $post->likes - $post->dislikes, 'msg' => Html::tag('span', Html::tag('span', '', ['class' => 'glyphicon glyphicon-ok-circle']) . ' ' . Yii::t('podium/view', 'Your vote has been saved!'), ['class' => 'text-success'])];
             }
         }
     }
     return Json::encode($data);
 }
开发者ID:pezisc,项目名称:yii2-podium,代码行数:46,代码来源:DefaultController.php

示例15: markSeen

 /**
  * Marks post as seen by current user.
  */
 public function markSeen()
 {
     if (!Yii::$app->user->isGuest) {
         $threadView = ThreadView::findOne(['user_id' => User::loggedId(), 'thread_id' => $this->thread_id]);
         if (!$threadView) {
             $threadView = new ThreadView();
             $threadView->user_id = User::loggedId();
             $threadView->thread_id = $this->thread_id;
             $threadView->new_last_seen = $this->created_at;
             $threadView->edited_last_seen = !empty($this->edited_at) ? $this->edited_at : $this->created_at;
             $threadView->save();
             $this->thread->updateCounters(['views' => 1]);
         } else {
             if ($this->edited) {
                 if ($threadView->edited_last_seen < $this->edited_at) {
                     $threadView->edited_last_seen = $this->edited_at;
                     $threadView->save();
                     $this->thread->updateCounters(['views' => 1]);
                 }
             } else {
                 $save = false;
                 if ($threadView->new_last_seen < $this->created_at) {
                     $threadView->new_last_seen = $this->created_at;
                     $save = true;
                 }
                 if ($threadView->edited_last_seen < max($this->created_at, $this->edited_at)) {
                     $threadView->edited_last_seen = max($this->created_at, $this->edited_at);
                     $save = true;
                 }
                 if ($save) {
                     $threadView->save();
                     $this->thread->updateCounters(['views' => 1]);
                 }
             }
         }
         if ($this->thread->subscription) {
             if ($this->thread->subscription->post_seen == Subscription::POST_NEW) {
                 $this->thread->subscription->post_seen = Subscription::POST_SEEN;
                 $this->thread->subscription->save();
             }
         }
     }
 }
开发者ID:aekkapun,项目名称:yii2-podium,代码行数:46,代码来源:Post.php


注:本文中的bizley\podium\models\User::loggedId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。