public function beforeValidate() { if (parent::beforeValidate()) { $cams = array_map('trim', explode(',', $this->hcams)); $c = count($cams); foreach ($cams as $cam) { $this->camBuff[] = Cams::model()->findByPK(Cams::model()->getRealId($cam)); } $this->camBuff = array_filter($this->camBuff); if (empty($this->camBuff) || count($this->camBuff) != $c) { $this->addError('cams', $c > 1 ? Yii::t('errors', 'One of cam is wrong') : Yii::t('errors', 'There is no such cam')); return false; } if (!is_array($this->emails)) { $emails = array_map('trim', explode(',', $this->emails)); } else { $emails = array_map('trim', $this->emails); } $c = count($emails); $this->emailBuff = Users::model()->findAllByAttributes(array('email' => $emails)); if (empty($this->emailBuff) || count($this->emailBuff) != $c) { $this->addError('emails', $c > 1 ? Yii::t('errors', 'One of user is wrong') : Yii::t('errors', 'There is no such user')); return false; } return true; } return false; }
public function beforeValidate() { $this->db = Yii::app()->db; // Категория $category_id = $this->db->createCommand(' SELECT id FROM yupe_store_category WHERE id_1c = ' . $this->category_id)->queryRow(); if (empty($category_id)) { // категории нет в базе $this->category_id = '449'; } else { // категория присутствует в базе, возвращаем ее идентификатор $this->category_id = $category_id['id']; } // Товар $product = $this->db->createCommand()->select('id, alias')->from('{{store_product}}')->where('id_1c=:id', [':id' => $this->id_1c])->queryRow(); if (empty($product)) { // товар в базе не существует # code... } else { // товар существует $this->id = $product['id']; $this->alias = $product['alias']; } // Даты $this->create_time = date('Y-m-d h:m:s', time()); $this->update_time = date('Y-m-d h:m:s', time()); return parent::beforeValidate(); }
protected function beforeValidate() { $this->message = strip_tags($this->message); $this->name = strip_tags($this->name); $this->telephone = strip_tags($this->telephone); return parent::beforeValidate(); }
public function beforeValidate() { if (parent::beforeValidate()) { return true; } return false; }
public function beforeValidate() { if (parent::beforeValidate()) { $this->username = strtolower($this->username); return true; } return false; }
public function beforeValidate() { if (empty($this->gender)) { $this->gender = self::GENDER_FEMALE; } $this->notime = !(isset($this->hour) && isset($this->minute) && $this->hour >= 0 && $this->hour <= 23 && $this->minute >= 0 && $this->minute <= 59); return parent::beforeValidate(); }
/** * Метод выполняется перед валидацией * * @return bool */ public function beforeValidate() { $module = Yii::app()->getModule('user'); if ($module->generateNickName) { $this->nick_name = 'user' . time(); } return parent::beforeValidate(); }
protected function beforeValidate() { $this->show = (int) $this->show; foreach (array("show_user", "to", "tt") as $k) { $this->{$k} = trim($this->{$k}); } $this->to_esc = preg_quote($this->to); $this->tt_esc = preg_quote($this->tt); return parent::beforeValidate(); }
/** * Change our filename to match our own naming convention * @return bool */ public function beforeValidate() { //(optional) Generate a random name for our file to work on preventing // malicious users from determining / deleting other users' files if ($this->secureFileNames) { $this->filename = sha1(Yii::app()->user->id . microtime() . $this->name); $this->filename .= "." . $this->file->getExtensionName(); } return parent::beforeValidate(); }
/** * @return bool */ public function beforeValidate() { /** @var AccountModule $account */ $account = Yii::app()->getModule('account'); if ($account->reCaptcha) { Yii::import('account.components.AccountReCaptchaValidator'); $validator = new AccountReCaptchaValidator(); $validator->attributes = array('captcha'); $validator->validate($this); if ($this->hasErrors('captcha')) { return false; } } return parent::beforeValidate(); }
public function beforeValidate() { parent::beforeValidate(); return true; }
public function beforeValidate() { parent::beforeValidate(); $this->todayCount = $this->todaySended; if (Yii::app()->user->email) { $this->email = Yii::app()->user->email; } return true; }
public function beforeValidate() { $this->validateSubForm(); return parent::beforeValidate(); }
protected function beforeValidate() { $this->value = trim($this->value); $exists = false; foreach ($this->getVisibleSearchParameters() as $searchParam) { if ($searchParam->parameter->getIdParameter() == $this->parameter) { $exists = true; break; } } if (!$exists) { return false; } if ($objParameter = $this->getSearchObjectParamter()) { if ($objParameter->getType() == DataType::TIMESTAMP && !$this->parseTimestamp()) { return false; } } return parent::beforeValidate(); }
/** * Loads the user model * @return boolean whether validation should continue */ protected function beforeValidate() { $this->_user = User::model()->findCurrent(); return parent::beforeValidate(); }
public function beforeValidate() { parent::beforeValidate(); $this->user_email = Yii::app()->user->email; return true; }
public function beforeValidate() { $this->watermarkFile = CUploadedFile::getInstance($this, 'watermarkFile'); return parent::beforeValidate(); }
public function beforeValidate() { $this->birthday = sprintf('%04d-%02d-%02d', $this->birthday_year, $this->birthday_month, $this->birthday_day); if (empty($this->city_id)) { $this->city_id = 11101; /*по умолчанию город Москва*/ } return parent::beforeValidate(); }
/** * Since Validate tests to make sure certain fields have values, populate requirements here such as the modified timestamp * @return boolean from parent */ protected function beforeValidate() { $this->email = strtolower($this->email); if ($this->getScenario() === '') { $this->setScenario('Existing'); } return parent::beforeValidate(); }
public function beforeValidate() { $this->category_id = self::REALTY_CATEGORY_ID; parent::beforeValidate(); }