Esempio n. 1
0
$this->respond(['GET', 'POST'], '/get-current', function ($request, $response, $service, $app) {
    $agent = Agents::getCurrentAgent();
    if (!empty($agent)) {
        $response->json(Result::success('', $agent));
    } else {
        $response->json(Result::error('Agent not found'));
    }
});
$this->respond(['GET', 'POST'], '/get/[i:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    // Access only for Current Agent
    if (!Agents::isAdmin() && !Agents::isCurrentAgent($id)) {
        $response->json(Result::error('Access is denied'));
    } else {
        $AgentResult = Agents::getAgentForEdit($id);
        $LogsResult = Logs::getAgentLogs($id);
        $result = array("AgentData" => $AgentResult, "AgentLogs" => $LogsResult);
        if ($AgentResult) {
            $response->json(Result::success('', $result));
        } else {
            $response->json(Result::error('Agent not found'));
        }
    }
});
$this->respond(['GET', 'POST'], '/edit/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $data = json_decode($request->body(), true);
    // Access only for Current Agent
    if (!Agents::isAdmin() && !Agents::isCurrentAgent($id)) {
        $response->json(Result::error('Access is denied'));
    } else {
Esempio n. 2
0
 public static function deleteAgentLogs($agentID)
 {
     $logs = Logs::getAgentLogs($agentID);
     foreach ($logs as $log) {
         Logs::deleteLog($log['id']);
     }
     return;
 }