コード例 #1
0
 public function beforeDelete()
 {
     if (parent::beforeDelete()) {
         //delete: Messages(to/from), Ban History, UpVotes, LogTopic
         YBoardMessage::deleteAll(['or', 'sendfrom' => $this->id, 'sendto' => $this->id]);
         // Post(Polls and Votes)
         YBoardVote::deleteAll(['user_id' => $this->id]);
         YBoardUpvoted::deleteAll(['member_id' => $this->id]);
         YBoardPoll::deleteAll(['user_id' => $this->id]);
         YBoardPost::deleteAll(['user_id' => $this->id]);
         //log topic
         YBoardLogTopic::deleteAll(['member_id' => $this->id]);
         //ban
         YBoardBan::deleteAll(['user_id' => $this->id]);
         return true;
     } else {
         return false;
     }
 }
コード例 #2
0
 public function beforeDelete()
 {
     if (parent::beforeDelete()) {
         //delete all upvotes and polls
         YBoardPost::deleteAll(['topic_id' => $this->id]);
         YBoardLogTopic::deleteAll(['topic_id' => $this->id]);
         return true;
     } else {
         return false;
     }
 }
コード例 #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getLogTopics()
 {
     return $this->hasMany(YBoardLogTopic::className(), ['forum_id' => 'id']);
 }
コード例 #4
0
 public function actionMarkAllRead()
 {
     if (!Yii::$app->user->can('app.forum.forum.mark-all-read')) {
         throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));
     }
     $topics = YBoardTopic::find()->all();
     foreach ($topics as $topic) {
         $topicLog = YBoardLogTopic::findOne(['member_id' => Yii::$app->user->id, 'topic_id' => $topic->id]);
         if ($topicLog === null) {
             $topicLog = new YBoardLogTopic();
             $topicLog->member_id = Yii::$app->user->id;
             $topicLog->topic_id = $topic->id;
             $topicLog->forum_id = $topic->forum_id;
         }
         $topicLog->last_post_id = $topic->last_post_id;
         $topicLog->save();
     }
     $this->redirect(['index']);
 }