public function afterSave($insert, $changedAttributes) { if ($insert === true) { (new History(['user_id' => $this->topic->user_id, 'action' => History::ACTION_ADD_TOPIC, 'action_time' => $this->topic->created_at, 'target' => $this->topic_id]))->save(false); Siteinfo::updateCounterInfo('addTopic'); UserInfo::updateCounterInfo('addTopic', $this->topic->user_id); Node::updateCounterInfo('addTopic', $this->topic->node_id); Notice::afterTopicInsert($this); Tag::afterTopicInsert($this); } return parent::afterSave($insert, $changedAttributes); }
public function afterDelete() { (new History(['user_id' => $this->user_id, 'action' => History::ACTION_DELETE_TOPIC, 'target' => $this->id]))->save(false); TopicContent::deleteAll(['topic_id' => $this->id]); Node::updateCounterInfo('deleteTopic', $this->node_id); UserInfo::updateCounterInfo('deleteTopic', $this->user_id); $count = Comment::afterTopicDelete($this->id); Siteinfo::updateCountersInfo(['topics' => -1, 'comments' => -$count]); Favorite::afterTopicDelete($this->id); Notice::afterTopicDelete($this->id); return parent::afterDelete(); }
public function afterDelete() { if ($this->type === self::TYPE_NODE) { $action = 'unfollowNode'; Node::updateCounterInfo($action, $this->target_id); } else { if ($this->type === self::TYPE_TOPIC) { $action = 'unfollowTopic'; Topic::updateCounterInfo($action, $this->target_id); } else { if ($this->type === self::TYPE_USER) { $action = 'unfollowUser'; UserInfo::updateCounterInfo('unfollowed', $this->target_id); } } } UserInfo::updateCounterInfo($action, Yii::$app->getUser()->getId()); return parent::afterDelete(); }