public function afterDelete() { foreach ($this->items as $item) { $item->delete(); } parent::afterDelete(); }
public function afterSave() { parent::afterSave(); if ($this->isNewRecord) { $activity = Activity::CreateForContent($this); $activity->type = "DocumentCreated"; $activity->module = "documents"; $activity->save(); $activity->fire(); } return true; }
/** * After Save Addons * * @return type */ public function afterSave() { parent::afterSave(); if ($this->isNewRecord) { $activity = Activity::CreateForContent($this); $activity->type = "QuestionCreated"; $activity->module = "questionanswer"; $activity->save(); $activity->fire(); } HSearch::getInstance()->addModel($this); return true; }
/** * Loads Content Addon * We also validates that the content addon corresponds to the loaded content. * * @param string $className * @param int $pk */ public function loadContentAddon($className, $pk) { if (!\humhub\libs\Helpers::CheckClassType($className, ContentAddonActiveRecord::className())) { throw new \yii\base\Exception("Given className is not a content addon model!"); } $target = $className::findOne(['id' => $pk]); if ($target === null) { throw new HttpException(500, 'Could not find content addon record!'); } if ($target->object_model != get_class($this->parentContent) && $target->object_id != $this->parentContent->getPrimaryKey()) { throw new HttpException(500, 'Content addon not belongs to given content record!'); } $this->contentAddon = $target; }
/** * Before Save Addons * * @return type */ public function afterSave() { parent::afterSave(); if ($this->isNewRecord) { $activity = Activity::CreateForContent($this); $activity->type = "PostCreated"; $activity->module = "post"; $activity->save(); $activity->fire(); } // Handle mentioned users UserMentioning::parse($this, $this->message); return true; }
/** * Loads Content Addon * We also validates that the content addon corresponds to the loaded content. * * @param string $className * @param int $pk */ public function loadContentAddon($className, $pk) { if (!Helpers::CheckClassType($className, 'HActiveRecordContentAddon')) { throw new CException("Given className is not a content addon model!"); } $model = call_user_func(array($className, 'model')); $target = $model->findByPk($pk); if ($target === null) { throw new CHttpException(500, 'Could not find content addon record!'); } if ($target->object_model != get_class($this->parentContent) && $target->object_id != $this->parentContent->getPrimaryKey()) { throw new CHttpException(500, 'Content addon not belongs to given content record!'); } $this->contentAddon = $target; }
/** * Cleanup AlbumImage */ public function beforeDelete() { $cover = $this->cover; if ($cover != null) { $cover->delete(); } foreach ($this->getImages() as $image) { $image->delete(); } /** * Remove notifications. */ Notification::remove('Album', $this->id); return parent::beforeDelete(); }
/** * Returns the static model of the specified AR class. * @param string $className active record class name. * @return Activity the static model class */ public static function model($className = __CLASS__) { return parent::model($className); }
public function beforeDelete() { foreach ($this->revisions as $revision) { $revision->delete(); } return parent::beforeDelete(); }