PATH:
home
/
letacommog
/
letaweb
/
admin
/
models
/
subsite_models
/
forms
<?php class DomainForm extends CFormModel { public $id; public $name; public $creator_id; public $last_modified_by; public function rules() { return array( array('id', 'numerical'), array('name', 'required'), array('name', 'undefined'), array('creator_id,last_modified_by','safe'), ); } protected function preProcess() { $this->creator_id = Yii::app()->user->id; $this->last_modified_by = Yii::app()->user->id; } public function save($item = null) { $this->preProcess(); $now = date('Y-m-d H:i:s'); if ($this->validate()) { if ($this->scenario === 'create' || !isset($this->id) || $this->id == 0) { $domain = new Page_Domain(); $domain->setIsNewRecord(true); $domain->creator_id = $this->creator_id; $domain->last_modified_by = $this->last_modified_by; $domain->date_added = $now; } else { $domain = Page_Domain::model()->findByPk($this->id); $domain->setIsNewRecord(false); $domain->last_modified_by = $this->last_modified_by; } $domain->site_id = Yii::app()->site->model->id; $domain->name = $this->name; $domain->date_modified = $now; if ($domain->save()) { return $domain; } else { return false; } } else { return false; } } public function undefined($attribute) { //test predefined domain $predefined_domain = Yii::app()->hosting->predefined_domain; $predefined_domains = explode(',', $predefined_domain); foreach ($predefined_domains as $domain) { $domain = trim($domain); if ($this->$attribute == $domain) { $this->addError($attribute, 'This domain already taken!'); return; } } //test domain can be added to hosting $rs = Yii::app()->hosting->addDomain($this->$attribute); if ($rs != 1) { $this->addError($attribute, 'This domain can\'t be added! '.$rs); } } }
[+]
..
[-] ColorForm.php
[edit]
[-] ProfileResetPassForm.php
[edit]
[-] NewsCommentForm.php
[edit]
[-] SkinForm.php
[edit]
[-] PageForm.php
[edit]
[-] BLoginForm.php
[edit]
[-] UserResetPassForm.php
[edit]
[-] ModuleForm.php
[edit]
[-] NewsForm.php
[edit]
[-] ContributorForm.php
[edit]
[-] News_CategoriesForm.php
[edit]
[-] InviteForm.php
[edit]
[-] NewsTagForm.php
[edit]
[-] DomainForm.php
[edit]