/** * deletes the user from the database. * * @return boolean */ public function deleteUser() { if (!isset($this->userId) || $this->userId == 0) { $this->errors[] = self::ERROR_USER_NO_USERID; return false; } if (!isset($this->login) || strlen($this->login) == 0) { $this->errors[] = self::ERROR_USER_LOGIN_INVALID; return false; } if (isset($this->allowedStatus[$this->status]) && $this->allowedStatus[$this->status] == self::STATUS_USER_PROTECTED) { $this->errors[] = self::ERROR_USER_CANNOT_DELETE_USER . self::STATUS_USER_PROTECTED; return false; } $this->perm->refuseAllUserRights($this->userId); $delete = sprintf("\n DELETE FROM\n %sfaquser\n WHERE\n user_id = %d", PMF_Db::getTablePrefix(), $this->userId); $res = $this->config->getDb()->query($delete); if (!$res) { $this->errors[] = self::ERROR_USER_CANNOT_DELETE_USER . 'error(): ' . $this->config->getDb()->error(); return false; } if (!$this->userdata instanceof PMF_User_UserData) { $this->userdata = new PMF_User_UserData($this->config); } $data = $this->userdata->delete($this->getUserId()); if (!$data) { $this->errors[] = self::ERROR_USER_CANNOT_DELETE_USERDATA; return false; } $readOnly = 0; $authCount = 0; $delete = []; foreach ($this->authContainer as $auth) { $authCount++; if ($auth->setReadOnly()) { $readOnly++; continue; } $delete[] = $auth->delete($this->login); } if ($readOnly == $authCount) { $this->errors[] = self::ERROR_USER_NO_AUTH_WRITABLE; } if (!in_array(true, $delete)) { return false; } return true; }
/** * Constructor * * @param PMF_Configuration $config * * @return PMF_Perm_Medium */ public function __construct(PMF_Configuration $config) { parent::__construct($config); }