fix lng availability; add returncode for not-found messages

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2018-02-16 15:39:59 +01:00
parent 60defd3cdf
commit 7c96164770
5 changed files with 17 additions and 16 deletions

View File

@@ -343,22 +343,21 @@ if ($page == 'customers'
&& $id != 0 && $id != 0
) { ) {
$result_data = array('id' => $id); try {
$result_stmt = Database::prepare(" $json_result = Customers::getLocal($userinfo, array(
SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "` 'id' => $id
WHERE `customerid` = :id" . ($userinfo['customers_see_all'] ? '' : " AND `adminid` = :adminid") ))->get();
); } catch (Exception $e) {
if ($userinfo['customers_see_all'] == '0') { dynamic_error($e->getMessage());
$result_data['adminid'] = $userinfo['adminid'];
} }
$result = Database::pexecute_first($result_stmt, $result_data); $result = json_decode($json_result, true)['data'];
/* /*
* information for moving customer * information for moving customer
*/ */
$available_admins_stmt = Database::prepare(" $available_admins_stmt = Database::prepare("
SELECT * FROM `" . TABLE_PANEL_ADMINS . "` SELECT * FROM `" . TABLE_PANEL_ADMINS . "`
WHERE (`customers` = '-1' OR `customers` > `customers_used`)" WHERE (`customers` = '-1' OR `customers` > `customers_used`)"
); );
Database::pexecute($available_admins_stmt); Database::pexecute($available_admins_stmt);
$admin_select = makeoption("-----", 0, true, true, true); $admin_select = makeoption("-----", 0, true, true, true);

View File

@@ -29,16 +29,18 @@ abstract class ApiCommand
throw new Exception("Invalid user data", 500); throw new Exception("Invalid user data", 500);
} }
$this->logger = FroxlorLogger::getInstanceOf($this->user_data); $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->initLang();
$this->initMail(); $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() private function initLang()
{ {
global $lng;
// query the whole table // query the whole table
$result_stmt = Database::query("SELECT * FROM `" . TABLE_PANEL_LANGUAGE . "`"); $result_stmt = Database::query("SELECT * FROM `" . TABLE_PANEL_LANGUAGE . "`");

View File

@@ -50,7 +50,7 @@ class Customers extends ApiCommand
if ($result) { if ($result) {
return $this->response(200, "successfull", $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); throw new Exception("Not allowed to execute given command.", 403);
} }

View File

@@ -54,7 +54,7 @@ class Domains extends ApiCommand
if ($result) { if ($result) {
return $this->response(200, "successfull", $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); throw new Exception("Not allowed to execute given command.", 403);
} }

View File

@@ -37,7 +37,7 @@ class IpsAndPorts extends ApiCommand
if ($result) { if ($result) {
return $this->response(200, "successfull", $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); throw new Exception("Not allowed to execute given command.", 403);
} }