Example #1
0
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->id_empresa = Yii::app()->user->model->id_empresa;
     }
     return parent::beforeSave();
 }
Example #2
0
 public function beforeSave()
 {
     parent::beforeSave();
     $picture = CUploadedFile::getInstance($this, 'image');
     if ($picture) {
         $imagename = $picture->getTempName();
         $image = Yii::app()->image->load($imagename);
         if ($image) {
             if ($this->avatar) {
                 unlink($_SERVER['DOCUMENT_ROOT'] . $this->avatar_folder . '/' . $this->avatar);
             }
             if ($image->width >= $image->height) {
                 $image->resize(20000, 93)->rotate(0)->quality(90)->sharpen(20);
             } else {
                 $image->resize(93, 20000)->rotate(0)->quality(90)->sharpen(20);
             }
             $image->crop(93, 93);
             $file_name = rand() . '.' . $picture->extensionName;
             $savename = $_SERVER['DOCUMENT_ROOT'] . $this->avatar_folder . '/' . $file_name;
             $image->save($savename);
             $this->avatar = $file_name;
         }
     }
     return true;
 }
Example #3
0
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->datahora_insercao = new CDbExpression('NOW()');
     }
     return parent::beforeSave();
 }
Example #4
0
 protected function beforeSave()
 {
     if (substr($this->url, 0, strlen('http')) !== 'http') {
         $this->url = "http://" . $this->url;
     }
     return parent::beforeSave();
 }
Example #5
0
 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         $this->userId = Yii::app()->user->userId;
     }
     return true;
 }
Example #6
0
 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         if ($this->album_id == 0) {
             $this->album_id = null;
         }
         if ($this->isNewRecord) {
             $this->click = 0;
             $this->add_uid = Yii::app()->user->id;
             $this->add_time = time();
             if ($this->url == "") {
                 if ($this->musicfile) {
                     $name = $this->musicfile->name;
                     $this->url = $name;
                 }
             }
         } else {
             if ($this->musicfile) {
                 $name = $this->musicfile->name;
                 $this->url = $name;
             }
         }
         return true;
     } else {
         return false;
     }
 }
Example #7
0
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->position = count(Components::model()->findAll("projectId = {$this->projectId}")) + 1;
     }
     return parent::beforeSave();
 }
Example #8
0
 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         $this->spotNum++;
     }
     return true;
 }
Example #9
0
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->created = date('Y/m/d H:i:s');
     }
     return parent::beforeSave();
 }
Example #10
0
 protected function beforeSave()
 {
     if (!parent::beforeSave()) {
         return false;
     }
     if (($this->scenario == 'insert' || $this->scenario == 'update') && ($this->icon = CUploadedFile::getInstance($this, 'icon'))) {
         // Если обновляем запись, то удаляем прошлую фотографию
         if ($this->scenario == 'update') {
             $file = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->getBaseUrl() . '/Image/Project/' . $this->img;
             $fileMini = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->getBaseUrl() . '/Image/Project/mini-' . $this->img;
             if (file_exists($file) and $this->img != '') {
                 unlink($file);
             }
             if (file_exists($fileMini) and $this->img != '') {
                 unlink($fileMini);
             }
         }
         $fileName = mktime(date("i")) . '.jpg';
         $this->img = $fileName;
         $file = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->getBaseUrl() . '/Image/Project/' . $fileName;
         $this->icon->saveAs($file);
         //Делаем ресайз только что загруженному изображению
         $Image = Image::factory("./Image/Project/" . $fileName);
         if ($Image->width >= $Image->height) {
             $Image->resize(375, 410, Image::WIDTH)->crop(375, 410, "top", "center");
             $Image->save($_SERVER['DOCUMENT_ROOT'] . Yii::app()->getBaseUrl() . '/Image/Project/mini-' . $fileName);
         } else {
             $Image->resize(235, 314, Image::HEIGHT)->crop(235, 314, "top", "center");
             $Image->save($_SERVER['DOCUMENT_ROOT'] . Yii::app()->getBaseUrl() . '/Image/Project/mini-' . $fileName);
         }
     }
     return true;
 }
Example #11
0
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->created = time();
     }
     return parent::beforeSave();
 }
Example #12
0
 public function beforeSave()
 {
     if (isset($_POST['items'])) {
         $this->modulos = join(',', $_POST['items']);
     }
     return parent::beforeSave();
 }
Example #13
0
 public function beforeSave()
 {
     //if (strpos($this->nombre,'@')!==false){
     $this->nombre = '@' . strtolower(trim($this->nombre, '@'));
     //}
     return parent::beforeSave();
 }
Example #14
0
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->status = self::STATUS_OK;
     }
     return parent::beforeSave();
 }
 public function beforeSave()
 {
     if ($this->isNewRecord)
         $this->creation_date = new CDbExpression('NOW()');
     
     return parent::beforeSave();
 }
Example #16
0
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->data_cadastro = date('Y-m-d H:i:s');
     }
     return parent::beforeSave();
 }
Example #17
0
    /**
     * On save event
     * @return bool
     */
    protected function beforeSave() {
        if (isset($this->PO_Dists_Amount) && $this->PO_Dists_Amount == '') {
            $this->PO_Dists_Amount = 0;
        }

        return parent::beforeSave();
    }
 public function beforeSave()
 {
     $roles = Rights::getAssignedRoles(Yii::app()->user->Id);
     // check for single role
     foreach ($roles as $role) {
         if ($role->name == 'Editor' or $role->name == 'Administrator' or $role->name == 'Superadmin') {
             $this->post_editor = Yii::app()->user->id;
         } else {
             $this->post_author = Yii::app()->user->id;
         }
     }
     if ($this->isNewRecord) {
         // jika record baru jalankan
         $this->post_created = date('Y-m-d H:i:s');
     }
     if ($this->post_name == '') {
         $this->post_name = 'No Title';
     }
     if ($this->post_link == '') {
         $this->post_link = $this->post_name;
     }
     if ($this->post_title == '') {
         $this->post_title = $this->post_name;
     }
     $this->post_type = $this->_type;
     $this->post_image = str_replace(Helper::rootImg('content'), '', $this->post_image);
     return parent::beforeSave();
 }
 protected function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->created_on = date('Y-m-d H:i:s');
     }
     return parent::beforeSave();
 }
Example #20
0
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->_wasNewRecord = true;
     }
     return parent::beforeSave();
 }
Example #21
0
 protected function beforeSave()
 {
     if ($this->hasAttribute('modified')) {
         $this->modified = date('Y-m-d H:i:s');
     }
     return parent::beforeSave();
 }
Example #22
0
 public function beforeSave()
 {
     if (!$this->activo == '1') {
         $this->activo == '0';
     }
     return parent::beforeSave();
 }
Example #23
0
 public function beforeSave()
 {
     if (!empty($this->_profileCache)) {
         $this->profile_cache = serialize((array) $this->_profileCache);
     }
     return parent::beforeSave();
 }
Example #24
0
 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         if ($this->isNewRecord) {
             $this->create_date = new CDbExpression("NOW()");
             if (!empty($this->passwordSave) && !empty($this->repeatPassword) && $this->passwordSave === $this->repeatPassword) {
                 $password = $this->passwordSave;
             } else {
                 $password = rand(9999, 999999);
             }
             $this->password = $this->hashPassword($password);
             $this->status = 0;
             $this->password_expiry_date = new CDbExpression("DATE_ADD(NOW(), INTERVAL " . self::PASSWORD_EXPIRY . " DAY) ");
             $this->activate = $this->hashPassword(rand(9999, 999999));
         } else {
             if (!empty($this->passwordSave) && !empty($this->repeatPassword) && $this->passwordSave === $this->repeatPassword) {
                 $this->password = $this->hashPassword($password);
                 $this->password_expiry_date = new CDbExpression("DATE_ADD(NOW(), INTERVAL " . self::PASSWORD_EXPIRY . " DAY) ");
             }
         }
         $this->last_login_time = new CDbExpression("NOW()");
         return true;
     } else {
         return false;
     }
 }
Example #25
0
 protected function beforeSave()
 {
     if ($this->pickup_date != '') {
         $this->pickup_date = date('Y-m-d', strtotime($this->pickup_date));
     }
     return parent::beforeSave();
 }
Example #26
0
 protected function beforeSave()
 {
     if (!$this->order_num) {
         $this->order_num = Yii::app()->db->createCommand("SELECT MAX(order_num) FROM " . $this->tableName() . "")->queryScalar() + 1;
     }
     return parent::beforeSave();
 }
Example #27
0
 public function beforeSave()
 {
     if ($this->isNewRecord && !$this->time) {
         $this->time = new CDbExpression('UTC_TIMESTAMP()');
     }
     return parent::beforeSave();
 }
Example #28
0
 protected function beforeSave()
 {
     if (!empty($this->params)) {
         $this->params = json_encode($this->params);
     }
     return parent::beforeSave();
 }
Example #29
0
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->iduser = yii::app()->user->id;
     }
     return parent::beforeSave();
 }
Example #30
0
 protected function beforeSave()
 {
     if ($this->isNewRecord && null === $this->creation_time) {
         $this->creation_time = new CDbExpression('UTC_TIMESTAMP()');
     }
     return parent::beforeSave();
 }