/** * @inheritdoc */ public function afterSave($insert, $changedAttributes) { if ($insert) { if ($this->group !== null && $this->group->space !== null) { $this->group->space->addMember($this->user->id); } } parent::afterSave($insert, $changedAttributes); }
public function afterSave($insert, $changedAttributes) { if ($insert) { $notification = new \humhub\modules\tasks\notifications\Assigned(); $notification->source = $this->task; $notification->originator = Yii::$app->user->getIdentity(); $notification->send($this->user); } return parent::afterSave($insert, $changedAttributes); }
/** * @inheritdoc */ public function afterSave($insert, $changedAttributes) { $mentionedSource = $this->getPolymorphicRelation(); // Send mentioned notification $notification = new \humhub\modules\user\notifications\Mentioned(); $notification->source = $mentionedSource; if ($mentionedSource instanceof ContentActiveRecord) { $notification->originator = $mentionedSource->content->user; } elseif ($mentionedSource instanceof ContentAddonActiveRecord) { $notification->originator = $mentionedSource->user; } else { throw new \yii\base\Exception("Invalid polymorphic relation!"); } $notification->send($this->user); return parent::afterSave($insert, $changedAttributes); }
public function afterSave($insert, $changedAttributes) { $activity = null; if ($this->participation_state == self::PARTICIPATION_STATE_ACCEPTED) { $activity = new \humhub\modules\calendar\activities\ResponseAttend(); } elseif ($this->participation_state == self::PARTICIPATION_STATE_MAYBE) { $activity = new \humhub\modules\calendar\activities\ResponseMaybe(); } elseif ($this->participation_state == self::PARTICIPATION_STATE_DECLINED) { $activity = new \humhub\modules\calendar\activities\ResponseDeclined(); } else { throw new \yii\base\Exception("Invalid participation state!"); } $activity->source = $this->calendarEntry; $activity->originator = $this->user; $activity->create(); return parent::afterSave($insert, $changedAttributes); }
/** * After saving content addon, mark underlying content as updated. * * @return boolean */ public function afterSave($insert, $changedAttributes) { // Auto follow the content which this addon belongs to $this->content->getPolymorphicRelation()->follow($this->created_by); if ($this->updateContentStreamSort) { $this->getSource()->content->updateStreamSortTime(); } return parent::afterSave($insert, $changedAttributes); }
public function afterSave($insert, $changedAttributes) { // Loop over each eall entry and make sure its update_at / update_by // will also updated. (Sorting wall against update) foreach ($this->getWallEntries() as $wallEntry) { $wallEntry->save(); } if ($insert) { foreach ($this->notifyUsersOfNewContent as $user) { $this->getPolymorphicRelation()->follow($user->id); } $notification = new \humhub\modules\content\notifications\ContentCreated(); $notification->source = $this->getPolymorphicRelation(); $notification->originator = $this->user; $notification->sendBulk($this->notifyUsersOfNewContent); if (!$this->getPolymorphicRelation() instanceof \humhub\modules\activity\models\Activity) { $activity = new \humhub\modules\content\activities\ContentCreated(); $activity->source = $this->getPolymorphicRelation(); $activity->create(); } } \humhub\modules\file\models\File::attachPrecreated($this->getPolymorphicRelation(), $this->attachFileGuidsAfterSave); return parent::afterSave($insert, $changedAttributes); }
/** * After saving content addon, mark underlying content as updated. * * @return boolean */ public function afterSave($insert, $changedAttributes) { // Auto follow the content which this addon belongs to $this->content->getPolymorphicRelation()->follow($this->created_by); return parent::afterSave($insert, $changedAttributes); }
/** * @inheritdoc */ public function afterSave($insert, $changedAttributes) { if ($insert) { // Check if this is an request (friend has no entry in table) $state = self::getStateForUser($this->user, $this->friendUser); if ($state === self::STATE_REQUEST_SENT) { // Send Request Notification $notification = new \humhub\modules\friendship\notifications\Request(); $notification->originator = $this->user; $notification->source = $this; $notification->send($this->friendUser); } elseif ($state === self::STATE_FRIENDS) { // Remove request notification $notification = new \humhub\modules\friendship\notifications\Request(); $notification->originator = $this->friendUser; $notification->delete($this->user); // User approved friends request notification $notification = new \humhub\modules\friendship\notifications\RequestApproved(); $notification->originator = $this->user; $notification->source = $this; $notification->send($this->friendUser); } } return parent::afterSave($insert, $changedAttributes); }
public function afterSave($insert, $changedAttributes) { // Set new uploaded file if ($this->uploadedFile !== null && $this->uploadedFile instanceof UploadedFile) { $newFilename = $this->getStoredFilePath(); if (is_uploaded_file($this->uploadedFile->tempName)) { move_uploaded_file($this->uploadedFile->tempName, $newFilename); @chmod($newFilename, 0744); } /** * For uploaded jpeg files convert them again - to handle special * exif attributes (e.g. orientation) */ if ($this->uploadedFile->type == 'image/jpeg') { ImageConverter::TransformToJpeg($newFilename, $newFilename); } } // Set file by given contents if ($this->newFileContent != null) { $newFilename = $this->getStoredFilePath(); file_put_contents($newFilename, $this->newFileContent); @chmod($newFilename, 0744); } return parent::afterSave($insert, $changedAttributes); }
/** * @inheritdoc */ public function afterSave($insert, $changedAttributes) { if ($insert) { $wall = new Wall(); $wall->object_model = $this->className(); $wall->object_id = $this->id; $wall->save(); $this->wall_id = $wall->id; $this->update(false, ['wall_id']); $contentContainer = new ContentContainer(); $contentContainer->guid = $this->guid; $contentContainer->class = $this->className(); $contentContainer->pk = $this->getPrimaryKey(); $contentContainer->wall_id = $this->wall_id; if ($this instanceof User) { $contentContainer->owner_user_id = $this->id; } elseif ($this->hasAttribute('created_by')) { $contentContainer->owner_user_id = $this->created_by; } $contentContainer->save(); $this->contentcontainer_id = $contentContainer->id; $this->update(false, ['contentcontainer_id']); } parent::afterSave($insert, $changedAttributes); }
/** * @inheritdoc */ public function afterSave($insert, $changedAttributes) { // Auto follow this content if ($this->className() != \humhub\modules\activity\models\Activity::className()) { $this->follow($this->content->user_id); } // Set polymorphic relation if ($insert) { $this->content->object_model = $this->className(); $this->content->object_id = $this->getPrimaryKey(); } // Always save content $this->content->save(); parent::afterSave($insert, $changedAttributes); if ($insert && $this->autoAddToWall && $this->wallEntryClass != "") { $this->content->addToWall(); } // When Space Content, update also last visit if ($this->content->space_id) { $membership = $this->content->space->getMembership(); if ($membership) { $membership->updateLastVisit(); } } }
/** * @inheritdoc */ public function afterSave($insert, $changedAttributes) { // Auto follow this content if ($this->className() != \humhub\modules\activity\models\Activity::className()) { $this->follow($this->content->created_by); } // Set polymorphic relation if ($insert) { $this->content->object_model = $this->className(); $this->content->object_id = $this->getPrimaryKey(); } // Always save content $this->content->save(); parent::afterSave($insert, $changedAttributes); if ($insert && $this->autoAddToWall && $this->wallEntryClass != "") { $this->content->addToWall(); } }
/** * @inheritdoc */ public function afterSave($insert, $changedAttributes) { WikiPageRevision::updateAll(['is_latest' => 0], 'wiki_page_id=:wikiPageId AND id!=:selfId', [':wikiPageId' => $this->wiki_page_id, ':selfId' => $this->id]); return parent::afterSave($insert, $changedAttributes); }
public function afterSave($insert, $changedAttributes) { // Set new uploaded file if ($this->uploadedFile !== null && $this->uploadedFile instanceof UploadedFile) { $newFilename = $this->getPath() . DIRECTORY_SEPARATOR . $this->getFilename(); if (is_uploaded_file($this->uploadedFile->tempName)) { move_uploaded_file($this->uploadedFile->tempName, $newFilename); @chmod($newFilename, 0744); } } // Set file by given contents if ($this->newFileContent != null) { $newFilename = $this->getPath() . DIRECTORY_SEPARATOR . $this->getFilename(); file_put_contents($newFilename, $this->newFileContent); @chmod($newFilename, 0744); } return parent::afterSave($insert, $changedAttributes); }