PATH:
home
/
letacommog
/
letaweb
/
protected
/
modules
/
admin
/
models
<?php class UserForm extends CFormModel { public $id; public $name; public $email; public $password; public $is_active; public $is_admin; public function rules() { return array( array('id', 'numerical'), array('name', 'required'), array('email', 'required', 'on' => 'create'), array('password', 'required', 'on' => 'create'), array('name', 'length', 'max' => 255), array('password', 'length', 'min' => 6, 'on' => 'create'), array('email', 'unique'), array('email', 'email'), array('id, name, email, password, is_active,is_admin', 'safe'), ); } public function save($item = null) { if ($this->validate()) { if ($this->scenario === 'create' || !isset($this->id)) { $user = new User(); $user->password = crypt($this->password, Randomness::blowfishSalt()); $user->email = $this->email; } else { $user = User::model()->findByPk($this->id); } $user->name = $this->name; $user->is_active = $this->is_active; $user->is_admin = $this->is_admin; if ($user->save()) { return true; } else { $errors = $user->getErrors(); $mess = ''; foreach ($errors as $error) { foreach ($error as $err) { $mess .= $err.' '; } } throw new Exception($mess); } } else { return false; } } public function unique() { if ($this->scenario === 'create' || !isset($this->id)) { $user = User::model()->find("LOWER(email) = '".$this->email."'"); if ($user == null) { return true; } $this->addError('email', Yii::t('RbamModule.validation', 'The email "{email}" is already used by another user.', array('{email}' => $this->email))); } elseif ($this->scenario === 'update' && isset($this->id)) { $user = User::model()->find('id = '.$this->id." and LOWER(email) = '".$this->email."'"); if ($user != null) { return true; } $user = User::model()->find("LOWER(email) = '".$this->email."'"); if ($user == null) { return true; } $this->addError('email', Yii::t('RbamModule.validation', 'The email "{email}" is already used by another user.', array('{email}' => $this->email))); } return true; } }
[+]
..
[-] DBPageForm.php
[edit]
[-] PlanDescriptionForm.php
[edit]
[-] HostingConfigurationForm.php
[edit]
[-] MailConfigurationForm.php
[edit]
[-] TemplateForm.php
[edit]
[-] ModuleForm.php
[edit]
[-] PageForm.php
[edit]
[-] PaymentConfigurationForm.php
[edit]
[-] CategoryForm.php
[edit]
[-] TermForm.php
[edit]
[-] DbListForm.php
[edit]
[-] ModuleDataForm.php
[edit]
[-] UploadTemplateForm.php
[edit]
[-] PlanConditionForm.php
[edit]
[-] ChangeDomainForm.php
[edit]
[-] LanguageForm.php
[edit]
[-] SkinPresetForm.php
[edit]
[-] PlanForm.php
[edit]
[-] UpgradePageForm.php
[edit]
[-] MailTemplateForm.php
[edit]
[-] ColorForm.php
[edit]
[-] MakeTempleteFromSiteForm.php
[edit]
[-] ResetPassForm.php
[edit]
[-] InterfaceForm.php
[edit]
[-] ContentForm.php
[edit]
[-] UserForm.php
[edit]
[-] ExtendPageForm.php
[edit]
[-] ConfigurationForm.php
[edit]
[-] ModuleCategoryForm.php
[edit]
[-] SocialShareButtonForm.php
[edit]