Example #1
0
 public function beforeValidate()
 {
     parent::beforeValidate();
     $this->usuario_id = Yii::app()->user->id;
     $this->data_cadastro = date('dd/mm/yy');
     return true;
 }
Example #2
0
 public function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->product_last_update = new CDbExpression('NOW()');
     }
     return parent::beforeValidate();
 }
Example #3
0
 public function beforeValidate()
 {
     if (Yii::app()->language == 'de') {
         $this->price = str_replace(',', '.', $this->price);
     }
     return parent::beforeValidate();
 }
Example #4
0
 protected function beforeValidate()
 {
     if (parent::beforeValidate()) {
         $this->date = time();
     }
     return true;
 }
Example #5
0
 /**
  * Prepares create_time, create_user_id, update_time and
  * update_user_ id attributes before performing validation.
  */
 protected function beforeValidate()
 {
     if ($this->isNewRecord) {
         // set the create date, last updated date
         // and the user doing the creating
         if ($this->id == null) {
             $this->id = $this->createUUID();
         }
         $this->created_time = $this->updated_time = new CDbExpression('NOW()');
         if ($this->created_by == null) {
             $this->created_by = Yii::app()->user->id;
         }
         if ($this->updated_by == null) {
             $this->updated_by = Yii::app()->user->id;
         }
     } else {
         //not a new record, so just set the last updated time
         //and last updated user id
         $this->updated_time = new CDbExpression('NOW()');
         //$this->updated_by = Yii::app()->user->id;
         if ($this->updated_by == null) {
             $this->updated_by = Yii::app()->user->id;
         }
     }
     return parent::beforeValidate();
 }
 /**
  * Prepares id, status, date_entered, created_by, date_modified and 
  * modified_user_id,deleted attributes before performing validation.
  */
 protected function beforeValidate()
 {
     if ($this->isNewRecord) {
         // set the create date, last updated date and the user doing the creating
         if (create_guid()) {
             $this->id = create_guid();
             $this->date_entered = date("Y-m-d H:i:s");
             if (frontUserId()) {
                 $this->created_by = frontUserId();
                 $this->modified_by = frontUserId();
             } else {
                 $this->created_by = $this->id;
                 $this->modified_by = $this->id;
             }
             $this->deleted = 0;
             //$this->status = 0;
             $this->date_modified = date("Y-m-d H:i:s");
         }
     } else {
         //not a new record, so just set the last updated time and last updated user id
         $this->date_modified = date("Y-m-d H:i:s");
         if (frontUserId()) {
             $this->modified_by = frontUserId();
         } else {
             $this->modified_by = Yii::app()->user->id;
         }
     }
     return parent::beforeValidate();
 }
Example #7
0
 public function beforeValidate()
 {
     if ($this->getScenario() == 'insert') {
         $this->sal = uniqid();
     }
     return parent::beforeValidate();
 }
Example #8
0
 public function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->ordering_date = $this->convertDate($this->ordering_date);
     }
     return parent::beforeValidate();
 }
Example #9
0
 public function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->ordering = $this->getNextOrdering();
     }
     return parent::beforeValidate();
 }
Example #10
0
 protected function beforeValidate()
 {
     if (!parent::beforeValidate()) {
         return false;
     }
     if ($this->scenario == "fromAdmin") {
         if ($this->teacher_path_file == NULL) {
             $this->addError("teacher_avatar", "teacher_avatar is required");
             return false;
         }
         if (!$this->teacher_path_file->checkExt(array('jpg', 'jpeg', 'png', 'JPG', 'JPEG', 'PNG'))) {
             return FALSE;
         }
         $ext = $this->teacher_path_file->getExtension();
         $name = StringHelper::unicode_str_filter($this->teacher_path_file->name);
         $storeFolder = Yii::getPathOfAlias('webroot') . '/uploads/teacher/';
         $targetPath = $storeFolder;
         //4
         $teacher_ava = Yii::app()->createAbsoluteUrl('uploads') . '/teacher/' . $name;
         if ($ext == "gif" || $ext == "jpg" || $ext == "jpeg" || $ext == "pjepg" || $ext == "png" || $ext == "x-png" || $ext == "GIF" || $ext == "JPG" || $ext == "JPEG" || $ext == "PJEPG" || $ext == "PNG" || $ext == "X_PNG") {
             $this->teacher_path_file->save($targetPath, $name);
             $this->teacher_avatar = $teacher_ava;
         }
     }
     return TRUE;
 }
Example #11
0
 public function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->member_created_date = new CDbExpression("NOW()");
     }
     return parent::beforeValidate();
 }
Example #12
0
 public function beforeValidate()
 {
     if (!Yii::app()->getModule('messaging')->hasGroup($this->grp)) {
         $this->addError('grp', 'You are not part of this group.');
     }
     return parent::beforeValidate();
 }
Example #13
0
 public function beforeValidate()
 {
     if ($this->isNewRecord && $this->keyword === null) {
         $this->keyword = AdminHelper::generateUrlStr($this->alias, $this, 'keyword');
     }
     return parent::beforeValidate();
 }
Example #14
0
 protected function beforeValidate()
 {
     if (empty($this->user_id)) {
         $this->user_id = Yii::app()->user->id;
     }
     return parent::beforeValidate();
 }
Example #15
0
 public function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->hash = Yii::app()->functions->makeHash(6);
     }
     return parent::beforeValidate();
 }
Example #16
0
 /**
  * prepares create_time attribute before performing validation
  */
 protected function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->create_date = new CDbExpression('NOW()');
     }
     return parent::beforeValidate();
 }
Example #17
0
 protected function beforeValidate()
 {
     foreach ($this->aImageSize as $fieldName => $aSize) {
         $this->{$fieldName} = CUploadedFile::getInstance($this, $fieldName);
     }
     return parent::beforeValidate();
 }
	public function beforeValidate() {
		if($this->isNewRecord)
			$this->createtime = time();

		return parent::beforeValidate();

	}
Example #19
0
 /**
  * Prepares create_at, create_by, update_at and update_by attributes before performing validation.
  */
 protected function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->created_at = date(CommonService::DATE_FORMAT);
         $this->updated_at = $this->created_at;
         if (isset(Yii::app()->user->id)) {
             $this->created_by = Yii::app()->user->id;
             $this->updated_by = $this->created_by;
         } else {
             if (!isset($this->created_by)) {
                 $this->created_by = 0;
             }
             if (!isset($this->updated_by)) {
                 $this->updated_by = 0;
             }
         }
     } else {
         $this->updated_at = date(CommonService::DATE_FORMAT);
         if (isset(Yii::app()->user->id)) {
             $this->updated_by = Yii::app()->user->id;
         } else {
             $this->updated_by = 0;
         }
     }
     if ($this->isNewRecord) {
         $this->lock_version = 1;
     } else {
         $dbInfo = $this->model()->findByPk($this->id);
         if (self::LOCK_VERSION_SPECIAL != $this->lock_version && $this->lock_version != $dbInfo->lock_version) {
             $this->addError('lock_version', Yii::t('Common', self::ERROR_LOCK_VERSION));
         }
     }
     return parent::beforeValidate();
 }
 public function beforeValidate()
 {
     if (!empty($this->frete)) {
         $this->frete = str_replace(',', '.', $this->frete);
     }
     return parent::beforeValidate();
 }
Example #21
0
	public function beforeValidate()
	{
	    if (parent::beforeValidate()) {

	        $validator = CValidator::createValidator('unique', $this, 'district_name', array(
	            'criteria' => array(
	                'condition'=>'city_id=:city_id',
	                'params'=>array(
	                    ':city_id'=>$this->city_id
	                )
	            )
	        ));
	        $validator2 = CValidator::createValidator('unique', $this, 'url', array(
	            'criteria' => array(
	                'condition'=>'city_id=:city_id',
	                'params'=>array(
	                    ':city_id'=>$this->city_id
	                )
	            )
	        ));
	        $this->getValidatorList()->insertAt(0, $validator); 
	        $this->getValidatorList()->insertAt(0, $validator2);

	        return true;
	    }
	    return false;
	}
Example #22
0
 public function beforeValidate()
 {
     if(parent::beforeValidate()) {
         if($this->isNewRecord)
             $this->date = date('Y-m-d H:i:s');
     }
     return true;
 }
Example #23
0
 public function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->group_product_created_date = new CDbExpression("NOW()");
         $this->group_product_last_update = new CDbExpression("NOW()");
     }
     return parent::beforeValidate();
 }
Example #24
0
 public function beforeValidate()
 {
     parent::beforeValidate();
     if ($this->birthday && $this->birthday != '0000-00-00') {
         $this->birthday = date('Y-m-d', CDateTimeParser::parse($this->birthday, 'dd.MM.yyyy'));
     }
     return true;
 }
Example #25
0
 public function beforeValidate()
 {
     // need now as the unsubscribed time?
     if ($this->isNewRecord && is_null($this->date)) {
         $this->date = date("Y-m-d H:i:s");
     }
     return parent::beforeValidate();
 }
Example #26
0
 /**
  * (non-PHPdoc)
  * @see yii/base/CModel#beforeValidate()
  */
 public function beforeValidate()
 {
     // if model a new record set userId
     if ($this->isNewRecord) {
         $this->userId = Yii::app()->user->id;
     }
     return parent::beforeValidate();
 }
Example #27
0
 protected function beforeValidate()
 {
     if ($this->getIsNewRecord()) {
         $this->date_create = new CDbExpression('now()');
     }
     $this->date_update = new CDbExpression('now()');
     return parent::beforeValidate();
 }
Example #28
0
 /**
  * Prepares create_at, create_by, update_at and update_by attributes before performing validation.
  */
 protected function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->created_at = date(CommonService::DATE_FORMAT);
         $this->created_by = Yii::app()->user->id;
     }
     return parent::beforeValidate();
 }
Example #29
0
File: User.php Project: newga/newga
 public function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->created = date('Y-m-d H:i:s');
     }
     $this->updated = date('Y-m-d H:i:s');
     return parent::beforeValidate();
 }
Example #30
0
 protected function beforeValidate()
 {
     if (!parent::beforeValidate()) {
         return false;
     }
     if ($this->scenario == "fromAdmin") {
         if ($this->doc_path_file == NULL) {
             $this->addError("doc_path", "doc_path is required");
             return false;
         }
         if (!$this->doc_path_file->checkExt(array('pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'jpg', 'jpeg', 'png'))) {
             return FALSE;
         }
         $api_key = "24cxjtv3vw69wu5p7pqd9";
         $secret = "sec-b2rlvg8kxwwpkz9fo3i02mo9vo";
         $scribd = new Scribd($api_key, $secret);
         $ext = $this->doc_path_file->getExtension();
         $name = StringHelper::unicode_str_filter($this->doc_path_file->name);
         $storeFolder = Yii::getPathOfAlias('webroot') . '/uploads/document/user_id_' . $this->doc_author;
         //2
         $targetPath = $storeFolder;
         //4
         $doc_path = Yii::app()->createAbsoluteUrl('uploads') . '/document/user_id_' . $this->doc_author . '/' . $name;
         $targetFile = $targetPath . "/" . $name;
         //5
         // move_uploaded_file($tempFile, $targetFile); //6
         if (!file_exists($storeFolder)) {
             mkdir($storeFolder, 0777, true);
         }
         if ($ext == "gif" || $ext == "jpg" || $ext == "jpeg" || $ext == "pjepg" || $ext == "png" || $ext == "x-png" || $ext == "GIF" || $ext == "JPG" || $ext == "JPEG" || $ext == "PJEPG" || $ext == "PNG" || $ext == "X_PNG") {
             $this->doc_path_file->save($targetPath, $name);
             $this->doc_url = $targetFile;
             $this->doc_path = $doc_path;
             $this->doc_type = 1;
         } else {
             if ($ext == "doc" || $ext == "docx" || $ext == "ppt" || $ext == "pptx" || $ext == "xls" || $ext == "xlsx" || $ext == 'txt' || $ext == 'pdf') {
                 $this->doc_path_file->save($targetPath, $name);
                 $upload_scribd = @$scribd->upload($targetFile);
                 //                var_dump($targetFile);
                 //                die();
                 $thumbnail_info = array('doc_id' => $upload_scribd["doc_id"], 'method' => NULL, 'session_key' => NULL, 'my_user_id' => NULL, 'width' => '220', 'height' => '250');
                 $get_thumbnail = @$scribd->postRequest('thumbnail.get', $thumbnail_info);
                 $this->doc_scribd_id = @$upload_scribd["doc_id"];
                 $this->doc_url = @$get_thumbnail["thumbnail_url"];
                 $this->doc_path = $doc_path;
                 $this->doc_type = 2;
             } else {
                 $this->doc_path_file->save($targetPath, $name);
                 $url_file_image = Yii::app()->theme->baseUrl . '/assets/img/document.png';
                 $this->doc_url = $url_file_image;
                 $this->doc_path = $doc_path;
                 $this->doc_type = 3;
             }
         }
     }
     return TRUE;
 }