started UI api-key management
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -595,27 +595,31 @@ class Admins extends ApiCommand implements ResourceEntity
|
||||
standard_error('youcantdeleteyourself', '', true);
|
||||
}
|
||||
|
||||
// delete admin
|
||||
$del_stmt = Database::prepare("
|
||||
DELETE FROM `" . TABLE_PANEL_ADMINS . "` WHERE `adminid` = :adminid
|
||||
");
|
||||
Database::pexecute($del_stmt, array(
|
||||
'adminid' => $id
|
||||
), true, true);
|
||||
|
||||
|
||||
// delete the traffic-usage
|
||||
$del_stmt = Database::prepare("
|
||||
DELETE FROM `" . TABLE_PANEL_TRAFFIC_ADMINS . "` WHERE `adminid` = :adminid
|
||||
");
|
||||
Database::pexecute($del_stmt, array(
|
||||
'adminid' => $id
|
||||
), true, true);
|
||||
|
||||
|
||||
// delete the diskspace usage
|
||||
$del_stmt = Database::prepare("
|
||||
DELETE FROM `" . TABLE_PANEL_DISKSPACE_ADMINS . "` WHERE `adminid` = :adminid
|
||||
");
|
||||
Database::pexecute($del_stmt, array(
|
||||
'adminid' => $id
|
||||
), true, true);
|
||||
|
||||
|
||||
// set admin-id of the old admin's customer to current admins
|
||||
$upd_stmt = Database::prepare("
|
||||
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET
|
||||
`adminid` = :userid WHERE `adminid` = :adminid
|
||||
@@ -624,7 +628,8 @@ class Admins extends ApiCommand implements ResourceEntity
|
||||
'userid' => $this->getUserDetail('adminid'),
|
||||
'adminid' => $id
|
||||
), true, true);
|
||||
|
||||
|
||||
// set admin-id of the old admin's domains to current admins
|
||||
$upd_stmt = Database::prepare("
|
||||
UPDATE `" . TABLE_PANEL_DOMAINS . "` SET
|
||||
`adminid` = :userid WHERE `adminid` = :adminid
|
||||
@@ -633,7 +638,26 @@ class Admins extends ApiCommand implements ResourceEntity
|
||||
'userid' => $this->getUserDetail('adminid'),
|
||||
'adminid' => $id
|
||||
), true, true);
|
||||
|
||||
|
||||
// delete old admin's api keys if exists (no customer keys)
|
||||
$upd_stmt = Database::prepare("
|
||||
DELETE FROM `" . TABLE_API_KEYS . "` WHERE
|
||||
`adminid` = :userid AND `customerid` = '0'
|
||||
");
|
||||
Database::pexecute($upd_stmt, array(
|
||||
'adminid' => $id
|
||||
), true, true);
|
||||
|
||||
// set admin-id of the old admin's api-keys to current admins
|
||||
$upd_stmt = Database::prepare("
|
||||
UPDATE `" . TABLE_API_KEYS . "` SET
|
||||
`adminid` = :userid WHERE `adminid` = :adminid
|
||||
");
|
||||
Database::pexecute($upd_stmt, array(
|
||||
'userid' => $this->getUserDetail('adminid'),
|
||||
'adminid' => $id
|
||||
), true, true);
|
||||
|
||||
$this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] deleted admin '" . $result['loginname'] . "'");
|
||||
updateCounters();
|
||||
return $this->response(200, "successfull", $result);
|
||||
|
||||
@@ -857,9 +857,9 @@ class Customers extends ApiCommand implements ResourceEntity
|
||||
// activate/deactivate customer services
|
||||
if ($deactivated != $result['deactivated']) {
|
||||
|
||||
$yesno = (($deactivated) ? 'N' : 'Y');
|
||||
$pop3 = (($deactivated) ? '0' : (int) $result['pop3']);
|
||||
$imap = (($deactivated) ? '0' : (int) $result['imap']);
|
||||
$yesno = ($deactivated ? 'N' : 'Y');
|
||||
$pop3 = ($deactivated ? '0' : (int) $result['pop3']);
|
||||
$imap = ($deactivated ? '0' : (int) $result['imap']);
|
||||
|
||||
$upd_stmt = Database::prepare("
|
||||
UPDATE `" . TABLE_MAIL_USERS . "` SET `postfix`= :yesno, `pop3` = :pop3, `imap` = :imap WHERE `customerid` = :customerid
|
||||
@@ -923,8 +923,16 @@ class Customers extends ApiCommand implements ResourceEntity
|
||||
// At last flush the new privileges
|
||||
$dbm->getManager()->flushPrivileges();
|
||||
Database::needRoot(false);
|
||||
|
||||
$this->logger()->logAction(ADM_ACTION, LOG_INFO, "[API] deactivated user '" . $result['loginname'] . "'");
|
||||
|
||||
// reactivate/deactivate api-keys
|
||||
$valid_until = $deactivated ? 0 : - 1;
|
||||
$stmt = Database::prepare("UPDATE `" . TABLE_API_KEYS . "` SET `valid_until` = :vu WHERE `customerid` = :id");
|
||||
Database::pexecute($stmt, array(
|
||||
'id' => $id,
|
||||
'vu' => $valid_until
|
||||
), true, true);
|
||||
|
||||
$this->logger()->logAction(ADM_ACTION, LOG_INFO, "[API] " . ($deactivated ? 'deactivated' : 'reactivated') . " user '" . $result['loginname'] . "'");
|
||||
inserttask('1');
|
||||
}
|
||||
|
||||
@@ -1323,6 +1331,12 @@ class Customers extends ApiCommand implements ResourceEntity
|
||||
'id' => $id
|
||||
), true, true);
|
||||
|
||||
// remove api-keys
|
||||
$stmt = Database::prepare("DELETE FROM `" . TABLE_API_KEYS . "` WHERE `customerid` = :id");
|
||||
Database::pexecute($stmt, array(
|
||||
'id' => $id
|
||||
), true, true);
|
||||
|
||||
// Delete all waiting "create user" -tasks for this user, #276
|
||||
// Note: the WHERE selects part of a serialized array, but it should be safe this way
|
||||
$del_stmt = Database::prepare("
|
||||
|
||||
Reference in New Issue
Block a user