/**
  * Draws the Upload Button output.
  */
 public function run()
 {
     $objectModel = "";
     $objectId = "";
     if ($this->object !== null) {
         $objectModel = $this->object->className();
         $objectId = $this->object->getPrimaryKey();
     }
     return $this->render('embeddedMediaUploadButton', array('fileListFieldName' => $this->fileListFieldName, 'uploaderId' => $this->uploaderId, 'objectModel' => $objectModel, 'objectId' => $objectId));
 }
示例#2
0
 /**
  * Draws the Upload Button output.
  */
 public function run()
 {
     $objectModel = "";
     $objectId = "";
     if ($this->object !== null) {
         $objectModel = get_class($this->object);
         $objectId = $this->object->getPrimaryKey();
     }
     $this->render('videoUploadButton', array('fileListFieldName' => $this->fileListFieldName, 'uploaderId' => $this->uploaderId, 'objectModel' => $objectModel, 'objectId' => $objectId));
 }
示例#3
0
 /**
  * Insert or Update this wall entry
  *
  * @return type
  */
 public function save($runValidation = true, $attributes = NULL)
 {
     $ret = parent::save($runValidation, $attributes);
     $cacheId = "wallEntryCount_" . $this->wall_id;
     Yii::app()->cache->delete($cacheId);
     return $ret;
 }
示例#4
0
 public function beforeDelete()
 {
     if ($this->is_system) {
         return false;
     }
     return parent::beforeDelete();
 }
示例#5
0
 public function afterFind()
 {
     if ($this->type == self::TYPE_IFRAME || $this->type == self::TYPE_LINK) {
         $this->url = $this->content;
     }
     return parent::afterFind();
 }
示例#6
0
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         // Updates the updated_at attribute
         $this->message->save();
     }
     return parent::beforeSave();
 }
示例#7
0
文件: Follow.php 项目: ahdail/humhub
 protected function beforeDelete()
 {
     // ToDo: Handle this via event of User Module
     if ($this->object_model == 'User') {
         $user = User::model()->findByPk($this->user_id);
         $activity = Activity::model()->contentContainer($user)->findByAttributes(array('type' => "ActivityUserFollowsUser", 'object_id' => $this->object_id));
         if ($activity !== null) {
             $activity->delete();
         }
     }
     return parent::beforeDelete();
 }
 /**
  * Returns the static model of the specified AR class.
  * Please note that you should have this exact method in all your CActiveRecord descendants!
  * @param string $className active record class name.
  * @return KarmaUser the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
示例#9
0
 public function beforeSave()
 {
     // When on edit form scenario, save also defaultSpaceGuid/adminGuids
     if ($this->scenario == 'edit') {
         if ($this->defaultSpaceGuid == "") {
             $this->space_id = "";
         } else {
             $space = Space::model()->findByAttributes(array('guid' => rtrim($this->defaultSpaceGuid, ',')));
             if ($space !== null) {
                 $this->space_id = $space->id;
             }
         }
     }
     return parent::beforeSave();
 }
示例#10
0
 /**
  * Before saving an new record, cleanup all old user passwords
  */
 public function afterSave()
 {
     UserPassword::model()->deleteAllByAttributes(array('user_id' => $this->user_id), 'id != :id ', array(':id' => $this->id));
     return parent::afterSave();
 }
 /**
  * Attaches a given list of files to an record (HActiveRecord).
  * This is used when uploading files before the record is created yet.
  *
  * @param HActiveRecord $object is a HActiveRecord
  * @param string $files is a comma seperated list of newly uploaded file guids
  */
 public static function attachPrecreated($object, $files)
 {
     if (!$object instanceof \yii\db\ActiveRecord) {
         throw new Exception("Invalid object given - require instance of HActiveRecord!");
     }
     // Attach Files
     foreach (explode(",", $files) as $fileGuid) {
         $file = self::findOne(['guid' => trim($fileGuid)]);
         if ($file != null && $file->object_model == "") {
             $file->object_model = $object->className();
             $file->object_id = $object->getPrimaryKey();
             if (!$file->save()) {
                 throw new Exception("Could not save precreated file!");
             }
         }
     }
 }
 public function afterSave()
 {
     WikiPageRevision::model()->updateAll(array('is_latest' => 0), 'wiki_page_id=:wikiPageId AND id!=:selfId', array(':wikiPageId' => $this->wiki_page_id, ':selfId' => $this->id));
     return parent::afterSave();
 }
示例#13
0
文件: File.php 项目: Wikom/humhub
 protected function afterSave()
 {
     // Set new uploaded file
     if ($this->cUploadedFile !== null && $this->cUploadedFile instanceof CUploadedFile) {
         $newFilename = $this->getPath() . DIRECTORY_SEPARATOR . $this->getFilename();
         if (is_uploaded_file($this->cUploadedFile->getTempName())) {
             move_uploaded_file($this->cUploadedFile->getTempName(), $newFilename);
             @chmod($newFilename, 0744);
         }
         /**
          * For uploaded jpeg files convert them again - to handle special
          * exif attributes (e.g. orientation)
          */
         if ($this->cUploadedFile->getType() == 'image/jpeg') {
             ImageConverter::TransformToJpeg($newFilename, $newFilename);
         }
     }
     // 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();
 }
示例#14
0
 protected function beforeSave()
 {
     if ($this->isNewRecord) {
         if ($this->seen == "") {
             $this->seen = 0;
         }
     }
     $userOnline = UserHttpSession::model()->exists('user_id = ' . $this->user_id);
     if (!$userOnline) {
         $this->desktop_notified = 1;
     }
     return parent::beforeSave();
 }
示例#15
0
 /**
  * After saving content addon, mark underlying content as updated.
  * 
  * @return boolean
  */
 protected function afterSave()
 {
     // Workaround for files, which have no object_model / id on uploading
     if ($this->object_model != "" && $this->object_id != "") {
         $this->content->save();
     }
     return parent::afterSave();
 }
示例#16
0
 /**
  * Phương thức beforeSave() dùng để thiết lập các thông tin mặc định khi tạo user
  */
 public function beforeSave()
 {
     parent::beforeSave();
     if ($this->getIsNewRecord()) {
         $this->createtime = time();
         $this->superuser = User::NONSUPERUSER;
         $this->status = User::STATUS_NOACTIVE;
     }
     return true;
 }
 /**
  * Cleanup image.
  */
 public function afterDelete()
 {
     $this->image->delete();
     parent::afterDelete();
 }
示例#18
0
 /**
  * After saving check if its required to rewrite the configuration file.
  * 
  * @todo Find better way to detect when we need to rewrite the local config
  */
 public function afterSave()
 {
     parent::afterSave();
     // Only rewrite static configuration file when necessary
     if ($this->module_id != 'mailing' && $this->module_id != 'cache' && $this->name != 'name' && $this->name != 'defaultLanguage' && $this->name != 'theme') {
         return;
     }
     self::rewriteConfiguration();
 }
示例#19
0
 public function beforeSave()
 {
     foreach ($this->attributes as $key => $value) {
         if ($value == "") {
             $this->{$key} = NULL;
         }
     }
     return parent::beforeSave();
 }
示例#20
0
 protected function beforeSave()
 {
     if ($this->isNewRecord) {
         if ($this->seen == "") {
             $this->seen = 0;
         }
     }
     return parent::beforeSave();
 }
示例#21
0
 protected function afterSave()
 {
     // Set new uploaded file
     if ($this->cUploadedFile !== null && $this->cUploadedFile instanceof CUploadedFile) {
         $newFilename = $this->getPath() . DIRECTORY_SEPARATOR . $this->getFilename();
         if (is_uploaded_file($this->cUploadedFile->getTempName())) {
             move_uploaded_file($this->cUploadedFile->getTempName(), $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();
 }
示例#22
0
文件: Message.php 项目: skapl/design
 /**
  * Deletes a message, including all dependencies.
  */
 public function delete()
 {
     foreach (MessageEntry::model()->findAllByAttributes(array('message_id' => $this->id)) as $messageEntry) {
         $messageEntry->delete();
     }
     foreach (UserMessage::model()->findAllByAttributes(array('message_id' => $this->id)) as $userMessage) {
         $userMessage->delete();
     }
     parent::delete();
 }
示例#23
0
 public function afterSave()
 {
     parent::afterSave();
     LiveCategoryItem::model()->deleteAllByAttributes(array('item_id' => $this->id));
     $arrCat = explode(",", $this->categories);
     foreach ($arrCat as $cat) {
         $model = new LiveCategoryItem();
         $model->category_id = $cat;
         $model->item_id = $this->id;
         $model->save();
     }
 }
示例#24
0
 /**
  * After Save, also saving the underlying Field Type
  */
 public function afterSave()
 {
     # Cause Endless
     #$this->fieldType->save();
     return parent::afterSave();
 }
示例#25
0
 public function beforeDelete()
 {
     Yii::app()->cache->delete($this->getCacheId());
     RuntimeCache::Remove($this->getCacheId());
     return parent::beforeDelete();
 }
示例#26
0
 /**
  * After saving content addon, mark underlying content as updated.
  * 
  * @return boolean
  */
 protected function afterSave()
 {
     // Auto follow the content which this addon belongs to
     $this->getContent()->getUnderlyingObject()->follow($this->created_by);
     return parent::afterSave();
 }
示例#27
0
 public function afterSave()
 {
     $this->sendNotification();
     return parent::afterSave();
 }
示例#28
0
 /**
  * Before delete record
  *
  * @return type
  */
 protected function beforeDelete()
 {
     Yii::app()->cache->delete('userSpaces_' . $this->user_id);
     return parent::beforeDelete();
 }
示例#29
0
 public function hasErrors($attribute = null)
 {
     if ($attribute != null) {
         return parent::hasErrors($attribute);
     }
     return parent::hasErrors() || $this->content->hasErrors();
 }
 public function beforeDelete()
 {
     Yii::app()->cache->delete(self::STATES_CACHE_ID_PREFIX . $this->room_id);
     return parent::beforeDelete();
 }