add 'adminname' to result in Customers.get; fix Customers.move and return customer-data there instead of just true
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -74,8 +74,9 @@ class Customers extends ApiCommand implements ResourceEntity
|
|||||||
|
|
||||||
if ($this->isAdmin()) {
|
if ($this->isAdmin()) {
|
||||||
$result_stmt = Database::prepare("
|
$result_stmt = Database::prepare("
|
||||||
SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "`
|
SELECT `c`.*, `a`.`loginname` AS `adminname`
|
||||||
WHERE " . ($id > 0 ? "`customerid` = :idln" : "`loginname` = :idln") . ($this->getUserDetail('customers_see_all') ? '' : " AND `adminid` = :adminid"));
|
FROM `" . TABLE_PANEL_CUSTOMERS . "` `c`, `" . TABLE_PANEL_ADMINS . "` `a`
|
||||||
|
WHERE " . ($id > 0 ? "`c`.`customerid` = :idln" : "`c`.`loginname` = :idln") . ($this->getUserDetail('customers_see_all') ? '' : " AND `c`.`adminid` = :adminid"). " AND `c`.`adminid` = `a`.`adminid`");
|
||||||
$params = array(
|
$params = array(
|
||||||
'idln' => ($id <= 0 ? $loginname : $id)
|
'idln' => ($id <= 0 ? $loginname : $id)
|
||||||
);
|
);
|
||||||
@@ -1480,19 +1481,22 @@ class Customers extends ApiCommand implements ResourceEntity
|
|||||||
*
|
*
|
||||||
* @access admin
|
* @access admin
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @return bool true on success, error-message on failure
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function move()
|
public function move()
|
||||||
{
|
{
|
||||||
if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) {
|
if ($this->isAdmin() && $this->getUserDetail('change_serversettings') == 1) {
|
||||||
$id = $this->getParam('id');
|
|
||||||
$adminid = $this->getParam('adminid');
|
$adminid = $this->getParam('adminid');
|
||||||
|
$id = $this->getParam('id', true, 0);
|
||||||
|
$ln_optional = ($id <= 0 ? false : true);
|
||||||
|
$loginname = $this->getParam('loginname', $ln_optional, '');
|
||||||
|
|
||||||
// get customer
|
$json_result = Customers::getLocal($this->getUserData(), array(
|
||||||
$json_result = Admins::getLocal($this->getUserData(), array(
|
'id' => $id,
|
||||||
'id' => $id
|
'loginname' => $loginname
|
||||||
))->get();
|
))->get();
|
||||||
$c_result = json_decode($json_result, true)['data'];
|
$c_result = json_decode($json_result, true)['data'];
|
||||||
|
$id = $c_result['customerid'];
|
||||||
|
|
||||||
// check if target-admin is the current admin
|
// check if target-admin is the current admin
|
||||||
if ($adminid == $c_result['adminid']) {
|
if ($adminid == $c_result['adminid']) {
|
||||||
@@ -1500,7 +1504,7 @@ class Customers extends ApiCommand implements ResourceEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get target admin
|
// get target admin
|
||||||
$json_result = Customers::getLocal($this->getUserData(), array(
|
$json_result = Admins::getLocal($this->getUserData(), array(
|
||||||
'id' => $adminid
|
'id' => $adminid
|
||||||
))->get();
|
))->get();
|
||||||
$a_result = json_decode($json_result, true)['data'];
|
$a_result = json_decode($json_result, true)['data'];
|
||||||
@@ -1535,8 +1539,12 @@ class Customers extends ApiCommand implements ResourceEntity
|
|||||||
// now, recalculate the resource-usage for the old and the new admin
|
// now, recalculate the resource-usage for the old and the new admin
|
||||||
updateCounters(false);
|
updateCounters(false);
|
||||||
|
|
||||||
$log->logAction(ADM_ACTION, LOG_INFO, "[API] moved user '" . $c_result['loginname'] . "' from admin/reseller '" . $c_result['adminname'] . " to admin/reseller '" . $a_result['loginname'] . "'");
|
$this->logger()->logAction(ADM_ACTION, LOG_INFO, "[API] moved user '" . $c_result['loginname'] . "' from admin/reseller '" . $c_result['adminname'] . " to admin/reseller '" . $a_result['loginname'] . "'");
|
||||||
return $this->response(200, "successfull", true);
|
$json_result = Customers::getLocal($this->getUserData(), array(
|
||||||
|
'id' => $c_result['customerid']
|
||||||
|
))->get();
|
||||||
|
$result = json_decode($json_result, true)['data'];
|
||||||
|
return $this->response(200, "successfull", $result);
|
||||||
}
|
}
|
||||||
throw new Exception("Not allowed to execute given command.", 403);
|
throw new Exception("Not allowed to execute given command.", 403);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user