Beispiel #1
0
 /**
  * After Save, delete LikeCount (Cache) for target object
  */
 public function afterSave($insert, $changedAttributes)
 {
     Yii::$app->cache->delete('likes_' . $this->object_model . "_" . $this->object_id);
     $activity = new \humhub\modules\like\activities\Liked();
     $activity->source = $this;
     $activity->create();
     $notification = new \humhub\modules\like\notifications\NewLike();
     $notification->source = $this;
     $notification->originator = $this->user;
     $notification->sendBulk($this->content->getPolymorphicRelation()->getFollowers(null, true, true));
     return parent::afterSave($insert, $changedAttributes);
 }
Beispiel #2
0
 /**
  * After Save, delete LikeCount (Cache) for target object
  */
 public function afterSave($insert, $changedAttributes)
 {
     Yii::$app->cache->delete('likes_' . $this->object_model . "_" . $this->object_id);
     $activity = new \humhub\modules\like\activities\Liked();
     $activity->source = $this;
     $activity->create();
     if ($this->getSource()->createdBy !== null) {
         $notification = new \humhub\modules\like\notifications\NewLike();
         $notification->source = $this;
         $notification->originator = $this->user;
         $notification->send($this->getSource()->createdBy);
     }
     return parent::afterSave($insert, $changedAttributes);
 }
 public function afterSave($insert, $changedAttributes)
 {
     if ($insert) {
         if ($this->content->space !== null) {
             $query = User::find()->leftJoin('space_membership', 'space_membership.user_id=user.id AND space_membership.space_id=:spaceId AND space_membership.admin_role=1', [':spaceId' => $this->content->space->id])->where(['IS NOT', 'space_membership.space_id', new \yii\db\Expression('NULL')]);
         } else {
             $query = User::find()->where(['super_admin' => 1]);
         }
         $notification = new \humhub\modules\reportcontent\notifications\NewReportAdmin();
         $notification->source = $this;
         $notification->originator = Yii::$app->user->getIdentity();
         $notification->sendBulk($query);
     }
     return parent::afterSave($insert, $changedAttributes);
 }
Beispiel #4
0
 /**
  * After Saving of comments, fire an activity
  *
  * @return type
  */
 public function afterSave($insert, $changedAttributes)
 {
     // flush the cache
     $this->flushCache();
     $activity = new \humhub\modules\comment\activities\NewComment();
     $activity->source = $this;
     $activity->create();
     // Handle mentioned users
     // Execute before NewCommentNotification to avoid double notification when mentioned.
     \humhub\modules\user\models\Mentioning::parse($this, $this->message);
     if ($insert) {
         $notification = new \humhub\modules\comment\notifications\NewComment();
         $notification->source = $this;
         $notification->originator = $this->user;
         $notification->sendBulk($this->content->getPolymorphicRelation()->getFollowers(null, true, true));
     }
     $this->updateContentSearch();
     return parent::afterSave($insert, $changedAttributes);
 }