fix lng availability; add returncode for not-found messages
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -29,16 +29,18 @@ abstract class ApiCommand
|
||||
throw new Exception("Invalid user data", 500);
|
||||
}
|
||||
$this->logger = FroxlorLogger::getInstanceOf($this->user_data);
|
||||
if ($this->debug) {
|
||||
$this->logger()->logAction(LOG_ERROR, LOG_DEBUG, json_encode($params, JSON_UNESCAPED_SLASHES));
|
||||
}
|
||||
|
||||
$this->initLang();
|
||||
$this->initMail();
|
||||
|
||||
if ($this->debug) {
|
||||
$this->logger()->logAction(LOG_ERROR, LOG_DEBUG, "[API] ".get_called_class().": ".json_encode($params, JSON_UNESCAPED_SLASHES));
|
||||
}
|
||||
}
|
||||
|
||||
private function initLang()
|
||||
{
|
||||
global $lng;
|
||||
// query the whole table
|
||||
$result_stmt = Database::query("SELECT * FROM `" . TABLE_PANEL_LANGUAGE . "`");
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ class Customers extends ApiCommand
|
||||
if ($result) {
|
||||
return $this->response(200, "successfull", $result);
|
||||
}
|
||||
throw new Exception("Customer with id #" . $id . " could not be found");
|
||||
throw new Exception("Customer with id #" . $id . " could not be found", 404);
|
||||
}
|
||||
throw new Exception("Not allowed to execute given command.", 403);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class Domains extends ApiCommand
|
||||
if ($result) {
|
||||
return $this->response(200, "successfull", $result);
|
||||
}
|
||||
throw new Exception("Domain with id #" . $id . " could not be found");
|
||||
throw new Exception("Domain with id #" . $id . " could not be found", 404);
|
||||
}
|
||||
throw new Exception("Not allowed to execute given command.", 403);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class IpsAndPorts extends ApiCommand
|
||||
if ($result) {
|
||||
return $this->response(200, "successfull", $result);
|
||||
}
|
||||
throw new Exception("IP/port with id #" . $id . " could not be found");
|
||||
throw new Exception("IP/port with id #" . $id . " could not be found", 404);
|
||||
}
|
||||
throw new Exception("Not allowed to execute given command.", 403);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user