Requests::delete PHP Method

delete() public method

public delete ( $reqId, $reason )
    public function delete($reqId, $reason)
    {
        $request = $this->get($reqId);
        if ($request["user"]["id"] != $this->user->getId() && $this->user->getClass() < User::CLASS_ADMIN && $this->user->getId() !== 1) {
            throw new Exception(L::get("PERMISSION_DENIED"), 401);
        }
        $votes = $this->getVotes($reqId);
        $this->log->log(3, L::get("REQUEST_DELETED_SITE_LOG", [$request["request"], $reason], Config::DEFAULT_LANGUAGE), $this->user->getId(), false);
        foreach ($votes as $vote) {
            $message = L::get("REQUEST_DELETED_PM_BODY", [$request["request"], $this->user->getUsername(), $reason]);
            if ($vote["reward"] > 0) {
                $message .= "\n\n " . L::get("REQUEST_DELETED_PM_REWARD", [$vote["reward"]]);
                $this->user->bonusLog($vote["reward"], L::get("REQUEST_REWARD_PAYBACK_BONUS_LOG", [$request["request"]]), $vote["user"]["id"]);
            }
            if ($vote["user"]["id"] != $this->user->getId()) {
                $this->mailbox->sendSystemMessage($vote["user"]["id"], L::get("REQUEST_DELETED_PM_SUBJECT"), $message);
            }
        }
        $this->purge($request["id"]);
    }

Usage Example

Ejemplo n.º 1
1
 function doDelete($url)
 {
     $response = Requests::delete($this->apiUrl . $url, $this->header);
     return json_decode($response->body);
 }
All Usage Examples Of Requests::delete