Пример #1
0
 public function validate() {
     if (!isset($this->id) || $this->id == '') {
         $this->errors[] = "Account is not defined!";
         return false;
     }
     if (!isset($this->realmid) || $this->realmid == '') {
         $this->errors[] = "Realm is not defined!";
         return false;
     }
     if (!isset($this->gmlevel) || $this->gmlevel == '') {
         $this->errors[] = "GM-Level is not defined!";
         return false;
     }
     if($this->new){
         $doup_check = AccountAccess::find()->where(array('id' => $this->id, 'realmid' => $this->realmid))->first();
         if(!empty($doup_check)){
             $this->errors[] = "Can't give multible AccessLevels to the same User on the same Realm";
             return false;
         }
     }
     
     return true;
 }
Пример #2
0
 function get_highest_gm_level() {
     $access_level = AccountAccess::find()
             ->where(array('id' => $this->id))
             ->order('gmlevel DESC')
             ->first();
     if(!is_object($access_level))
         return 0;
     else
         return $access_level->gmlevel;
 }
Пример #3
0
 function get_acl(){
     return AccountAccess::find()->where(array('realmid' => $this->id))->order('gmlevel DESC')->all();
 }
 function delete($params){
     $account_access = AccountAccess::find()->where($params)->first();
     if (!empty($account_access)) {
         if (User::$current->account->highest_gm_level > $account_access->account->highest_gm_level) {
             if($account_access->destroy()){
                 $this->flash('success', 'Deleted');
             } else {
                 $this->flash('error', 'Can\'t delete!');
             }
         } else {
             $this->flash('error', 'Your GM-Level have to be highter then the target account\'s level');
         }
     } else {
         $this->flash('error', 'AccountAccess not found!');
     }
     $this->redirect_back();
 }