PATH:
home
/
letacommog
/
letaweb
/
admin
/
models
/
subsite_models
/
forms
<?php class InviteForm extends CFormModel { public $id; public $name; public $email; public $permission; public $code; public $creator_id; public $last_modified_by; public function rules() { return array( array('id', 'numerical'), array('name', 'required'), array('email', 'required','on' => 'create'), array('email', 'email'), //array('name', 'undefined'), array('id,code,email,permission,creator_id,last_modified_by','safe'), ); } protected function createInviteCode($l) { $chars = 'abcdefghijkmnopqrstuvwxyz023456789'; srand((double) microtime() * 1000000); $i = 0; $pass = ''; while ($i <= $l) { $num = rand() % 33; $tmp = substr($chars, $num, 1); $pass = $pass.$tmp; ++$i; } return $pass; } 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) { $invite = new BContributor_Invites(); $invite->setIsNewRecord(true); $invite->creator_id = $this->creator_id; $invite->last_modified_by = $this->last_modified_by; $invite->email = $this->email; $invite->code = $this->createInviteCode(20); } else { $invite = BContributor_Invites::model()->findByPk($this->id); $invite->setIsNewRecord(false); $invite->last_modified_by = $this->last_modified_by; } $invite->name = $this->name; $invite->permission = $this->permission; $invite->name = $this->name; if ($invite->save()) { return $invite; } else { return false; } } else { return false; } } }
[+]
..
[-] 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]