reduce mysql-usage counter for admins too when deleting a mysql-database
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -379,10 +379,6 @@ class Mysqls extends ApiCommand implements ResourceEntity
|
|||||||
throw new ErrorException("Database server with index #" . $dbserver . " is unknown", 404);
|
throw new ErrorException("Database server with index #" . $dbserver . " is unknown", 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sendinfomail != 1) {
|
|
||||||
$sendinfomail = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get needed customer info to reduce the mysql-usage-counter by one
|
// get needed customer info to reduce the mysql-usage-counter by one
|
||||||
if ($this->isAdmin()) {
|
if ($this->isAdmin()) {
|
||||||
// get customer id
|
// get customer id
|
||||||
@@ -436,6 +432,7 @@ class Mysqls extends ApiCommand implements ResourceEntity
|
|||||||
"id" => $id
|
"id" => $id
|
||||||
);
|
);
|
||||||
Database::pexecute($stmt, $params, true, true);
|
Database::pexecute($stmt, $params, true, true);
|
||||||
|
|
||||||
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_WARNING, "[API] updated mysql-database '" . $result['databasename'] . "'");
|
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_WARNING, "[API] updated mysql-database '" . $result['databasename'] . "'");
|
||||||
return $this->response(200, "successfull", $params);
|
return $this->response(200, "successfull", $params);
|
||||||
}
|
}
|
||||||
@@ -607,6 +604,16 @@ class Mysqls extends ApiCommand implements ResourceEntity
|
|||||||
Database::pexecute($stmt, array(
|
Database::pexecute($stmt, array(
|
||||||
"customerid" => $customer_id
|
"customerid" => $customer_id
|
||||||
), true, true);
|
), true, true);
|
||||||
|
// update admin usage
|
||||||
|
$stmt = Database::prepare("
|
||||||
|
UPDATE `" . TABLE_PANEL_ADMINS . "`
|
||||||
|
SET `mysqls_used` = `mysqls_used` - 1
|
||||||
|
WHERE `adminid` = :adminid
|
||||||
|
");
|
||||||
|
Database::pexecute($stmt, array(
|
||||||
|
"adminid" => ($this->isAdmin() ? $customer['adminid'] : $this->getUserDetail('adminid')),
|
||||||
|
), true, true);
|
||||||
|
|
||||||
return $this->response(200, "successfull", $result);
|
return $this->response(200, "successfull", $result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user