Skip to content

Commit c48d0ca

Browse files
committed
Move clientid_to_groups_list function to more generic location
1 parent 90f8128 commit c48d0ca

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

interface/lib/classes/functions.inc.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,22 @@ public function func_client_cancel($client_id,$cancel) {
674674
return $result;
675675
}
676676

677+
/**
678+
* Lookup a client's group + all groups he is reselling.
679+
*
680+
* @return string Comma separated list of groupid's
681+
*/
682+
function clientid_to_groups_list($client_id) {
683+
global $app;
684+
685+
if ($client_id != null) {
686+
// Get the clients groupid, and incase it's a reseller the groupid's of it's clients.
687+
$group = $app->db->queryOneRecord("SELECT GROUP_CONCAT(groupid) AS groups FROM `sys_group` WHERE client_id IN (SELECT client_id FROM `client` WHERE client_id=? OR parent_client_id=?)", $client_id, $client_id);
688+
return $group['groups'];
689+
}
690+
return null;
691+
}
692+
677693
}
678694

679695
?>

interface/web/dashboard/dashlets/limits.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public function _get_limit_usage($limit, $limit_to_client_id)
202202
if ($limit['db_where'] != '') {
203203
$sql .= $limit['db_where']." AND ";
204204
}
205-
$sql .= $app->tform->getAuthSQL('r', '', '', $this->clientid_to_groups_list($limit_to_client_id));
205+
$sql .= $app->tform->getAuthSQL('r', '', '', $app->functions->clientid_to_groups_list($limit_to_client_id));
206206

207207
$rec = $app->db->queryOneRecord($sql, $limit['db_table']);
208208
return $rec['number'];
@@ -216,7 +216,7 @@ public function _get_assigned_quota($limit, $limit_to_client_id)
216216
if ($limit['db_where'] != '') {
217217
$sql .= $limit['db_where']." AND ";
218218
}
219-
$sql .= $app->tform->getAuthSQL('r', '', '', $this->clientid_to_groups_list($limit_to_client_id));
219+
$sql .= $app->tform->getAuthSQL('r', '', '', $app->functions->clientid_to_groups_list($limit_to_client_id));
220220
$rec = $app->db->queryOneRecord($sql, $limit['q_type'], $limit['db_table']);
221221
if ($limit['db_table'] == 'mail_user') {
222222
$quotaMB = $rec['number'] / 1048576;

0 commit comments

Comments
 (0)