public function afterDelete()
 {
     foreach ($this->items as $item) {
         $item->delete();
     }
     parent::afterDelete();
 }
예제 #2
0
 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;
 }
예제 #5
0
파일: Post.php 프로젝트: alefernie/intranet
 /**
  * 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;
 }
예제 #6
0
 /**
  * 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;
 }
예제 #7
0
 /**
  * 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();
 }
예제 #8
0
파일: Activity.php 프로젝트: ahdail/humhub
 /**
  * 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);
 }
예제 #9
0
 public function beforeDelete()
 {
     foreach ($this->revisions as $revision) {
         $revision->delete();
     }
     return parent::beforeDelete();
 }