Ejemplo n.º 1
0
 public function validate()
 {
     if (parent::validate()) {
         if (!$this->date_start) {
             $this->datetime_start = null;
         } else {
             $this->datetime_start = date('Y-m-d', strtotime($this->date_start));
             $timestart = $this->time_start != '' ? date('H:i:s', strtotime($this->time_start)) : '00:00:00';
             $this->datetime_start .= ' ' . $timestart;
         }
         if (!$this->date_end) {
             $this->datetime_end = null;
         } else {
             $this->datetime_end = date('Y-m-d', strtotime($this->date_end));
             $timeend = $this->time_end != '' ? date('H:i:s', strtotime($this->time_end)) : '00:00:00';
             $this->datetime_end .= ' ' . $timeend;
         }
         if ($this->datetime_start !== null && $this->datetime_end !== null) {
             $timestampStart = strtotime($this->datetime_start);
             $timestampEnd = strtotime($this->datetime_end);
             if ($timestampStart > 0 && $timestampEnd > 0 && $timestampEnd <= $timestampStart) {
                 $this->addError('date_end', 'Дата и время окончания срока действия промо-кода должны быть больше, чем дата его начала');
             }
         }
     }
     return !$this->hasErrors();
 }
Ejemplo n.º 2
0
 public function afterFind()
 {
     parent::afterFind();
     if ($this->date != null) {
         $this->date = Yii::app()->dateFormatter->format("dd.MM.yyyy", $this->date);
     }
 }
Ejemplo n.º 3
0
 public function afterDelete()
 {
     if (Yii::app()->hasModule('delivery')) {
         $this->clearDeliveryMethods();
     }
     parent::afterDelete();
 }
Ejemplo n.º 4
0
 /**
  * Метод выполняемый перед сохранением:
  * 
  * @return void
  */
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->user_id = Yii::app()->getUser()->getId();
     }
     return parent::beforeSave();
 }
Ejemplo n.º 5
0
 /**
  * Метод выполняемый перед удалением:
  * 
  * @return void
  */
 public function beforeDelete()
 {
     foreach ($this->packages as $package) {
         $package->delete();
     }
     return parent::beforeDelete();
 }
Ejemplo n.º 6
0
 public function beforeValidate()
 {
     if (!$this->alias) {
         $this->alias = yupe\helpers\YText::translit($this->title);
     }
     return parent::beforeValidate();
 }
 /**
  * Метод выполняемый перед удалением:
  * 
  * @return void
  */
 public function beforeDelete()
 {
     // Удаляем изображения
     foreach ($this->images as $image) {
         $image->delete();
     }
     return parent::beforeDelete();
 }
Ejemplo n.º 8
0
 public function beforeSave()
 {
     $this->update_date = new CDbExpression('NOW()');
     if ($this->isNewRecord) {
         $this->creation_date = $this->update_date;
     }
     return parent::beforeSave();
 }
Ejemplo n.º 9
0
 /**
  * beforeValidate
  *
  * @return parent::beforeValidate()
  **/
 public function beforeValidate()
 {
     // Проверяем наличие установленного хозяина галереи
     if (isset($this->owner) && empty($this->owner)) {
         $this->owner = Yii::app()->user->getId();
     }
     return parent::beforeValidate();
 }
Ejemplo n.º 10
0
 /**
  * Метод выполняемый перед удалением:
  * 
  * @return void
  */
 public function beforeDelete()
 {
     // Удаляем значения
     foreach ($this->dictionaryData as $item) {
         $item->delete();
     }
     return parent::beforeDelete();
 }
Ejemplo n.º 11
0
 /**
  * @return bool
  */
 public function beforeDelete()
 {
     if ($this->is_system) {
         $this->addError('statuses', Yii::t('OrderModule.order', 'You can not delete a system status.'));
         return false;
     }
     return parent::beforeDelete();
 }
Ejemplo n.º 12
0
 /**
  * Метод выполняемый перед удалением:
  *
  * @return void
  */
 public function beforeDelete()
 {
     // Обнуляем категории у сообщений
     foreach ($this->messages as $item) {
         $item->category_id = null;
         $item->update(['category_id']);
     }
     return parent::beforeDelete();
 }
Ejemplo n.º 13
0
 /**
  * Метод выполняемый перед удалением:
  * 
  * @return void
  */
 public function beforeDelete()
 {
     // Обнуляем категорию у атрибутов
     foreach ($this->attrs as $attr) {
         $attr->category_id = null;
         $attr->save(false, array('category_id'));
     }
     return parent::beforeDelete();
 }
Ejemplo n.º 14
0
 /**
  * Метод выполняемый перед удалением:
  * 
  * @return void
  */
 public function beforeDelete()
 {
     // Обнуляем группу у результатов
     foreach ($this->results as $result) {
         $result->group_id = null;
         $result->save(false, array('group_id'));
     }
     return parent::beforeDelete();
 }
Ejemplo n.º 15
0
 /**
  * Метод выполняемый перед сохранением:
  * 
  * @return void
  */
 public function beforeSave()
 {
     if (parent::beforeSave()) {
         $this->phone = preg_replace("/[^0-9]/", "", $this->phone);
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 16
0
 public function beforeValidate()
 {
     if (!$this->alias) {
         $this->alias = yupe\helpers\YText::translit($this->name);
     }
     if (!$this->lang) {
         $this->lang = Yii::app()->language;
     }
     return parent::beforeValidate();
 }
Ejemplo n.º 17
0
 protected function beforeSave()
 {
     $this->initType();
     // связи без типа в базу не пройдут!
     if (!$this->entity_name) {
         return false;
     }
     $this->_isNew = $this->isNewRecord;
     return parent::beforeSave();
 }
Ejemplo n.º 18
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;
 }
Ejemplo n.º 19
0
 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;
     }
 }
Ejemplo n.º 20
0
 /**
  * Метод перед удалением:
  *
  * @return bool
  */
 public function beforeDelete()
 {
     if ($this->_oldAccess_level == self::ACCESS_LEVEL_ADMIN && $this->admin()->count() == 1) {
         $this->addError('access_level', Yii::t('UserModule.default', 'You can\'t make this changes!'));
         return false;
     }
     return parent::beforeDelete();
 }
Ejemplo n.º 21
0
 /**
  * Returns the static model of the specified AR class.
  * @return DictionaryData the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
Ejemplo n.º 22
0
 public function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->creation_date = new CDbExpression('NOW()');
         $this->user_id = Yii::app()->user->getId();
     }
     return parent::beforeValidate();
 }
Ejemplo n.º 23
0
 /**
  * Метод выполняемый перед удалением:
  * 
  * @return void
  */
 public function beforeDelete()
 {
     // Удаляем дочерние блоки
     foreach ($this->children as $subblock) {
         $subblock->delete();
     }
     return parent::beforeDelete();
 }
Ejemplo n.º 24
0
 /**
  * Метод перед удалением:
  * 
  * @return void
  */
 public function beforeDelete()
 {
     // Удаляем шаблоны
     foreach ($this->templates as $template) {
         $template->delete();
     }
     return parent::beforeDelete();
 }
Ejemplo n.º 25
0
 public function beforeSave()
 {
     $this->start_time = $this->start_time ?: null;
     $this->end_time = $this->end_time ?: null;
     return parent::beforeSave();
 }
Ejemplo n.º 26
0
 protected function afterDelete()
 {
     Yii::app()->getCache()->clear($this->menu->code);
     return parent::afterDelete();
 }
Ejemplo n.º 27
0
 public function beforeDelete()
 {
     Yii::app()->cache->delete("Blog::Blog::members::{$this->user_id}");
     return parent::beforeDelete();
 }
Ejemplo n.º 28
0
 /**
  * Обновляем дату изменения. Если новая запись
  * обновляем необходимые поля:
  * 
  * @return void
  */
 public function beforeValidate()
 {
     $this->change_date = new CDbExpression('NOW()');
     if ($this->isNewRecord) {
         $this->creation_date = $this->change_date;
         $this->ip = Yii::app()->getRequest()->userHostAddress;
         if (!$this->type) {
             $this->type = self::TYPE_DEFAULT;
         }
     }
     return parent::beforeValidate();
 }
Ejemplo n.º 29
0
 /**
  * Метод выполняемый перед удалением:
  * 
  * @return void
  */
 public function beforeDelete()
 {
     // Удаляем описания
     foreach ($this->descriptions as $description) {
         $description->delete();
     }
     return parent::beforeDelete();
 }
Ejemplo n.º 30
0
 public function __construct($scenario = 'insert')
 {
     Yii::app()->setImport(['application.modules.dictionary.models.*']);
     parent::__construct($scenario);
 }