public function addRole(Moonlake_Auth_Role $role) { $mb = $this->model->getBackend(); $model = new Moonlake_Auth_UsersRolesModel($mb); $cond = new Moonlake_Model_Condition(); $cond->is('user', $this->userid); $cond->is('role', $role->getId()); if (!count($model->getEntriesByCondition($cond))) { $model->createEntry(array("user" => $this->userid, "role" => $role->getId())); } else { throw new Moonlake_Exception_Auth("The user '{$this->getLogin()}' has allready the role '{$role->getName()}'."); } }