/** * BeforeValidate * @see CActiveRecord::beforeValidate */ public function beforeValidate() { // If this is a new record and we don't have a created data pre-populated // Failing to check the $this->created results in posts losing their original creation date if ($this->isNewRecord && $this->created == NULL) { $this->comment_count = 0; } // Allow publication times to be set automatically if ($this->published == NULL) { $this->published = new CDbExpression('UTC_TIMESTAMP()'); } if (strlen($this->extract) == 0) { $this->extract = $this->myTruncate($this->content, 250, '.', ''); } return parent::beforeValidate(); }
/** * BeforeValidate * @see CActiveRecord::beforeValidate */ public function beforeValidate() { // Allow publication times to be set automatically if (empty($this->published)) { $this->published = time(); } if (strlen($this->excerpt) == 0) { $this->excerpt = $this->myTruncate($this->content, 250, '.', ''); } return parent::beforeValidate(); }
/** * Sets some default values for the user record. * TODO: This should have been moved to CiiModel * @see CActiveRecord::beforeValidate() **/ public function beforeValidate() { // If the password is nulled, or unchanged if ($this->password == NULL || $this->password == Cii::get($this->_oldAttributes, 'password', false)) { if (!$this->isNewRecord) { $this->password = $this->_oldAttributes['password']; } } else { $this->password = password_hash($this->password, PASSWORD_BCRYPT, array('cost' => Cii::getBcryptCost())); if (!$this->isNewRecord) { $emailSettings = new EmailSettings(); $emailSettings->send($this, Yii::t('ciims.models.Users', 'CiiMS Password Change Notification'), 'webroot.themes.' . Cii::getConfig('theme', 'default') . '.views.email.passwordchange', array('user' => $this)); } } return parent::beforeValidate(); }
public function beforeValidate() { $this->event_data = CJSON::encode($this->event_data); return parent::beforeValidate(); }
/** * Verifies the slug before validating the model */ public function beforeValidate() { $this->slug = $this->verifySlug($this->slug, $this->name); return parent::beforeValidate(); }
/** * Sets some default values for the user record. * TODO: This should have been moved to CiiModel * @see CActiveRecord::beforeValidate() **/ public function beforeValidate() { if ($this->about == NULL || $this->about == '') { $this->about = ' '; } return parent::beforeValidate(); }