示例#1
0
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->create_time = new CDbExpression('NOW()');
     }
     return parent::beforeSave();
 }
示例#2
0
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->date = new CDbExpression('now()');
     }
     return parent::beforeSave();
 }
示例#3
0
 public function beforeSave()
 {
     if ($this->getIsNewRecord()) {
         $this->date = (new DateTime('now'))->getTimestamp();
     }
     return parent::beforeSave();
 }
示例#4
0
 /**
  * Метод выполняемый перед сохранением:
  * 
  * @return void
  */
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->user_id = Yii::app()->getUser()->getId();
     }
     return parent::beforeSave();
 }
示例#5
0
 public function beforeSave()
 {
     $this->change_date = new CDbExpression('now()');
     if ($this->isNewRecord) {
         $this->creation_date = $this->change_date;
     }
     return parent::beforeSave();
 }
示例#6
0
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->creation_date = new CDbExpression('NOW()');
         $this->ip = Yii::app()->request->getUserHostAddress();
     }
     return parent::beforeSave();
 }
示例#7
0
 /**
  * Метод выполняемый перед сохранением:
  * 
  * @return void
  */
 public function beforeSave()
 {
     if (parent::beforeSave()) {
         $this->phone = preg_replace("/[^0-9]/", "", $this->phone);
         return true;
     } else {
         return false;
     }
 }
示例#8
0
 /**
  * Метод выполняемый перед сохранением:
  * 
  * @return void
  */
 public function beforeSave()
 {
     if (parent::beforeSave()) {
         $this->birth_date = $this->birth_date ? date('Y-m-d', strtotime($this->birth_date)) : null;
         return true;
     } else {
         return false;
     }
 }
 protected function beforeSave()
 {
     $this->initType();
     // связи без типа в базу не пройдут!
     if (!$this->entity_name) {
         return false;
     }
     $this->_isNew = $this->isNewRecord;
     return parent::beforeSave();
 }
示例#10
0
 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         Yii::app()->cache->delete("ContentBlock{$this->code}" . Yii::app()->language);
         if ($this->type == self::SIMPLE_TEXT) {
             $this->content = strip_tags($this->content);
         }
         return true;
     }
     return false;
 }
 protected function beforeSave()
 {
     parent::beforeSave();
     if ($this->role_id == 1) {
         if (!array_intersect(Yii::app()->user->role, ['1'])) {
             throw new CHttpException(403, 'Ошибка прав доступа.');
         } else {
             return true;
         }
     } else {
         return true;
     }
 }
 public function beforeSave()
 {
     if (parent::beforeSave()) {
         $this->hash = $this->generateHash();
         // Генерация кода результата
         if (isset($this->data['A']['attribute']['code']) && ($this->isNewRecord || $this->data['A']['attribute']['code'] != $this->_oldAttributeCode)) {
             $attributeCode = $this->data['A']['attribute']['code'];
             $code = $this->getResultCode($attributeCode);
             $this->code = $code;
         }
         return true;
     } else {
         return false;
     }
 }
示例#13
0
文件: News.php 项目: sepaker/yupe
 public function beforeSave()
 {
     $this->change_date = new CDbExpression('NOW()');
     $this->date = date('Y-m-d', strtotime($this->date));
     if ($this->isNewRecord) {
         $this->creation_date = $this->change_date;
         $this->user_id = Yii::app()->user->getId();
     }
     return parent::beforeSave();
 }
示例#14
0
 /**
  * Метод выполняемый перед сохранением:
  * 
  * @return void
  */
 public function beforeSave()
 {
     // Дата создания
     if ($this->isNewRecord) {
         $this->created_at = new CDbExpression('NOW()');
         if ($this->type == self::TYPE_FULL) {
             $this->order_num = $this->_generateOrderNum();
         }
         if ($this->type == self::TYPE_TRIAL) {
             $this->activated_at = $this->created_at;
         }
     }
     // При активации подписки админом, выставляем дату активации, определяем сроки действия подписки и обновляем стоимость
     if ($this->type == self::TYPE_FULL && $this->_isActivateByAdmin()) {
         // Определяем сроки действия подписки
         $this->_activationDetectTerms();
         if (empty($this->coupon_id)) {
             $this->total_cost = $this->courseType->price;
         }
     }
     // При деактивации подписки админом производим все необходимые действия
     if ($this->_isDeactivateByAdmin()) {
         $this->_deactivate();
     }
     return parent::beforeSave();
 }
示例#15
0
 /**
  * Перед сохранением необходимо:
  * - если новая запись указать время создания
  * - если обновляется запись, то выставить время обновления
  *
  * @return void
  */
 public function beforeSave()
 {
     if ($this->getIsNewRecord()) {
         $this->create_time = new CDbExpression('NOW()');
     }
     $this->update_time = new CDbExpression('NOW()');
     return parent::beforeSave();
 }
示例#16
0
 public function beforeSave()
 {
     $this->update_user_id = Yii::app()->user->getId();
     if ($this->isNewRecord) {
         $this->create_user_id = $this->update_user_id;
     }
     return parent::beforeSave();
 }
示例#17
0
 public function beforeSave()
 {
     $this->publish_date = strtotime($this->publish_date);
     $this->update_user_id = Yii::app()->user->getId();
     if ($this->isNewRecord) {
         $this->create_user_id = $this->update_user_id;
         $this->create_user_ip = Yii::app()->getRequest()->userHostAddress;
     }
     return parent::beforeSave();
 }
示例#18
0
文件: Page.php 项目: alextravin/yupe
 public function beforeSave()
 {
     $this->change_user_id = Yii::app()->getUser()->getId();
     if ($this->getIsNewRecord()) {
         $this->user_id = $this->change_user_id;
     }
     return parent::beforeSave();
 }
示例#19
0
 public function beforeSave()
 {
     if (parent::beforeSave()) {
         // Если объект разметки - ячейки
         /*
                     if($this->markup_object == self::MARKUP_OBJECT_CELL)
                     {
            $this->cells = CJSON::encode($this->cellsArray);
                     }
         * 
         */
         if ($this->markup_object == self::MARKUP_OBJECT_SIGN) {
             $this->places = !empty($this->placesArray) ? CJSON::encode($this->placesArray) : null;
             $this->attributes = !empty($this->attributesArray) ? CJSON::encode($this->attributesArray) : null;
             // Если выбран тип разметки - простой
             if ($this->markup_type == self::MARKUP_TYPE_SIMPLE) {
                 $this->finish_places = null;
                 $this->finish_attributes = null;
                 $this->view_relation = 0;
             }
             // Если выбран тип разметки - связка
             if ($this->markup_type == self::MARKUP_TYPE_RELATION) {
                 $this->finish_places = !empty($this->finishPlacesArray) ? CJSON::encode($this->finishPlacesArray) : null;
                 $this->finish_attributes = !empty($this->finishAttributesArray) ? CJSON::encode($this->finishAttributesArray) : null;
             }
         }
         return true;
     } else {
         return false;
     }
 }
示例#20
0
 /**
  * Метод выполняемый перед сохранением:
  * 
  * @return void
  */
 public function beforeSave()
 {
     if ($this->getIsNewRecord()) {
         $this->registration_date = new CDbExpression('NOW()');
     } else {
         // Запрещаем действия, при которых администратор
         // может быть заблокирован или сайт останется без
         // администратора:
         if ($this->admin()->count() == 1 && $this->_oldAccess_level === self::ACCESS_LEVEL_ADMIN && ((int) $this->access_level === self::ACCESS_LEVEL_USER || (int) $this->status !== self::STATUS_ACTIVE)) {
             $this->addError('access_level', Yii::t('UserModule.user', 'You can\'t make this changes!'));
             return false;
         }
     }
     if (!$this->birth_date) {
         $this->birth_date = null;
     }
     // Меняем дату изменения профиля:
     $this->change_date = new CDbExpression('NOW()');
     return parent::beforeSave();
 }
示例#21
0
 /**
  * @return bool
  */
 public function beforeSave()
 {
     $this->publish_time = strtotime($this->publish_time);
     $this->update_user_id = Yii::app()->user->getId();
     if ($this->getIsNewRecord()) {
         $this->create_user_id = $this->update_user_id;
         $this->create_user_ip = Yii::app()->getRequest()->userHostAddress;
     }
     $this->setTags($this->tags);
     return parent::beforeSave();
 }
示例#22
0
 protected function beforeSave()
 {
     if ($this->block instanceof PageBlock) {
         $this->course_type_id = $this->block->entity->day->package->type->id;
     }
     return parent::beforeSave();
 }
示例#23
0
 /**
  * @return bool
  */
 protected function beforeSave()
 {
     Yii::app()->getCache()->delete("ContentBlock{$this->code}" . Yii::app()->language);
     return parent::beforeSave();
 }
示例#24
0
 /**
  * Метод выполняемый перед сохранением:
  * 
  * @return void
  */
 public function beforeSave()
 {
     $this->date = !empty($this->date) ? date('Y-m-d', strtotime($this->date)) : null;
     return parent::beforeSave();
 }
示例#25
0
 protected function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->sort = Yii::app()->db->createCommand()->select('MAX(sort) + 1')->from($this->tableName())->queryScalar();
     }
     return parent::beforeSave();
 }
示例#26
0
 /**
  * @return bool
  * @TODO вынести всю логику в saveData
  */
 public function beforeSave()
 {
     $this->total_price = $this->getProductsCost();
     if ($this->getIsNewRecord()) {
         $this->url = md5(uniqid(time(), true));
         $this->ip = Yii::app()->getRequest()->userHostAddress;
         if ($this->getScenario() === self::SCENARIO_USER) {
             $this->delivery_price = $this->delivery ? $this->delivery->getCost($this->total_price) : 0;
             $this->separate_delivery = $this->delivery ? $this->delivery->separate_payment : null;
         }
     }
     $this->delivery_price = $this->getDeliveryCost();
     return parent::beforeSave();
 }
示例#27
0
 public function beforeSave()
 {
     $this->start_time = $this->start_time ?: null;
     $this->end_time = $this->end_time ?: null;
     return parent::beforeSave();
 }
示例#28
0
 public function beforeSave()
 {
     $this->update_user_id = Yii::app()->user->getId();
     $this->update_date = new CDbExpression('NOW()');
     if ($this->isNewRecord) {
         $this->create_user_id = $this->update_user_id;
         $this->creation_date = $this->update_date;
     }
     return parent::beforeSave();
 }
示例#29
0
 /**
  * Метод выполняемый перед сохранением:
  *
  * @return bool
  */
 public function beforeSave()
 {
     $this->nick_name = $this->email;
     if (!$this->getIsNewRecord() && $this->_oldAccess_level === self::ACCESS_LEVEL_ADMIN) {
         // Запрещаем действия, при которых администратор
         // может быть заблокирован или сайт останется без
         // администратора:
         if ($this->admin()->count() == 1 && ((int) $this->access_level === self::ACCESS_LEVEL_USER || (int) $this->status !== self::STATUS_ACTIVE)) {
             $this->addError('access_level', Yii::t('UserModule.default', 'You can\'t make this changes!'));
             return false;
         }
     }
     return parent::beforeSave();
 }
示例#30
0
 protected function beforeSave()
 {
     $this->initType();
     // комментарии без типа в базу не пройдут!
     if (!$this->type) {
         return false;
     }
     $this->_isNew = $this->isNewRecord;
     return parent::beforeSave();
 }