public function validate() {
        if (!isset($this->account_id) || $this->account_id == '') {
            $this->errors[] = "Account is not defined!";
            return false;
        }
        if (!isset($this->partner_id) || $this->partner_id == '') {
            $this->errors[] = "Partner is not defined!";
            return false;
        }
        if ($this->partner_id == $this->account_id){
            $this->errors[] = "Selflinking is a bit weired! ... isn't is?";
            return false;
        }
        if($this->new && isset($this->until) && $this->until < time()){
            $this->errors[] = "Until-Date can't be in the past";
            return false;
        }
        
        $double_check = AccountPartner::find()->where(array('(account_id = :account_id AND partner_id = :partner_id) OR (account_id = :partner_id AND partner_id = :account_id)', 'account_id' => $this->account_id, 'partner_id' => $this->partner_id))->first();
        if($double_check && (is_null($double_check->until) || $double_check->until > time()) ){
            $this->errors[] = "Account-Partner Relation already exists";
            return false;
        }

        return true;
    }
 function delete($params){
     if(isset($params['id']) && !empty($params['id'])){
         $id = $params['id'];
         $partner = AccountPartner::find($id);
         $partner_account = $partner->partner;
         if($partner){
             if($partner->destroy()){
                 $this->flash('success', 'Partner deleted');
                 Event::trigger(Event::TYPE_ACCOUNT_PARTNER_REMOVE, User::$current, $partner->account, $partner->partner->username);
             } else {
                 $this->flash('error', 'Deletion failed');
             }
         } else {
             $this->flash('error', 'Partner-Account not found!');
         }
     } else {
         $this->flash('error', 'No ID!');
     }
     $this->redirect_back();
 }
 function get_partners(){
     $partners = AccountPartner::find()->where(array('(account_id = :account_id OR partner_id = :account_id) AND (until IS NULL OR until > :now)','account_id' => $this->id, 'now' => time()))->all();
     return $partners;
 }