public function validate() { if (!isset($this->id) || $this->id == '') { $this->errors[] = "Account is not defined!"; return false; } if (!isset($this->bandate)) { $this->errors[] = "Ban-Date is not defined!"; return false; } if (!isset($this->bannedby) || $this->bannedby == '') { $this->errors[] = "Banning Account is not defined!"; return false; } if ($this->new && $this->unbandate < time() && $this->unbandate != 0){ $this->errors[] = "Unbandate is in the past"; return false; } $banned_check = AccountBan::find()->where(array('id' => $this->id, 'active' => '1'))->first(); if($this->active == 1 && $banned_check){ $this->errors[] = "Account already banned!"; return false; } elseif( $this->active == 0 && !$banned_check) { $this->errors[] = "Account is not banned!"; return false; } return true; }
public function get_banned() { $ban = AccountBan::find() ->where(array('id' => $this->id, 'active' => 1)) ->first(); return !empty($ban); }
function delete($params){ if(isset($params['id']) && !empty($params['id'])){ $ban = AccountBan::find()->where(array('id' => $params['id'], 'active' => '1'))->first(); if($ban){ $ban->active = 0; if($ban->save()){ $this->flash('success', 'Successfully unbanned'); Event::trigger(Event::TYPE_ACCOUNT_UNBAN, User::$current->account, $ban->account); } else { $this->flash('error', 'Error! ' . $ban->errors[0]); } } else { $this->flash('error', 'No Ban found!'); } } else { $this->flash('error', 'No ID!'); } $this->redirect_back(); }