Skip to content

Commit eee2d24

Browse files
committed
Support reseller in dashboard
1 parent 4c2c339 commit eee2d24

File tree

3 files changed

+30
-13
lines changed

3 files changed

+30
-13
lines changed

interface/lib/classes/quota_lib.inc.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ public function get_quota_data($clientid = null, $readable = true) {
1414
//print_r($monitor_data);
1515

1616
// select all websites or websites belonging to client
17-
$sites = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE active = 'y' AND type = 'vhost'".(($clientid != null)?" AND sys_groupid = (SELECT default_group FROM sys_user WHERE client_id=?)":'') . " ORDER BY domain", $clientid);
17+
$q = " SELECT * FROM web_domain
18+
WHERE active = 'y' AND type = 'vhost'"
19+
. 'AND sys_groupid ' . (($clientid != null) ? "= (SELECT default_group FROM sys_user WHERE client_id=?)"
20+
: " IN (" . $_SESSION["s"]["user"]["groups"] . ")")
21+
. " ORDER BY domain";
22+
$sites = $app->db->queryAllRecords($q, $clientid);
1823

1924
//print_r($sites);
2025
if(is_array($sites) && !empty($sites)){
@@ -209,7 +214,11 @@ public function get_mailquota_data($clientid = null, $readable = true) {
209214
//print_r($monitor_data);
210215

211216
// select all email accounts or email accounts belonging to client
212-
$emails = $app->db->queryAllRecords("SELECT * FROM mail_user".(($clientid != null)? " WHERE sys_groupid = (SELECT default_group FROM sys_user WHERE client_id=?)" : '') . " ORDER BY email", $clientid);
217+
$q = " SELECT * FROM mail_user"
218+
. " WHERE sys_groupid " . (($clientid != null) ? "= (SELECT default_group FROM sys_user WHERE client_id=?)"
219+
: " IN (" . $_SESSION["s"]["user"]["groups"] . ")")
220+
. " ORDER BY email";
221+
$emails = $app->db->queryAllRecords($q, $clientid);
213222

214223
//print_r($emails);
215224
if(is_array($emails) && !empty($emails)) {
@@ -265,7 +274,11 @@ public function get_databasequota_data($clientid = null, $readable = true) {
265274
//print_r($monitor_data);
266275

267276
// select all databases belonging to client
268-
$databases = $app->db->queryAllRecords("SELECT * FROM web_database".(($clientid != null)? " WHERE sys_groupid = (SELECT default_group FROM sys_user WHERE client_id=?)" : '') . " ORDER BY database_name", $clientid);
277+
$q = "SELECT * FROM web_database"
278+
. " WHERE sys_groupid " . (($clientid != null) ? "= (SELECT default_group FROM sys_user WHERE client_id=?)"
279+
: " IN (" . $_SESSION["s"]["user"]["groups"] . ")")
280+
. " ORDER BY database_name";
281+
$databases = $app->db->queryAllRecords($q, $clientid);
269282

270283
//print_r($databases);
271284
if(is_array($databases) && !empty($databases)){

interface/web/dashboard/dashboard.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,18 @@
214214
}
215215
}
216216

217+
if ($app->auth->is_admin() || $app->auth->is_reseller()) {
218+
$limit_to_client_id = null;
219+
}
220+
else {
221+
$limit_to_client_id = $_SESSION['s']['user']['client_id'];
222+
}
217223

218224
/* Fill the left column */
219225
$leftcol = array();
220226
foreach($leftcol_dashlets as $name) {
221227
if(isset($dashlet_list[$name])) {
222-
$leftcol[]['content'] = $dashlet_list[$name]->show($_SESSION['s']['user']['client_id']);
228+
$leftcol[]['content'] = $dashlet_list[$name]->show($limit_to_client_id);
223229
}
224230
}
225231
$app->tpl->setloop('leftcol', $leftcol);
@@ -228,7 +234,7 @@
228234
$rightcol = array();
229235
foreach($rightcol_dashlets as $name) {
230236
if(isset($dashlet_list[$name])) {
231-
$rightcol[]['content'] = $dashlet_list[$name]->show();
237+
$rightcol[]['content'] = $dashlet_list[$name]->show($limit_to_client_id);
232238
}
233239
}
234240
$app->tpl->setloop('rightcol', $rightcol);

interface/web/dashboard/dashlets/limits.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,13 @@ public function show($limit_to_client_id = 0)
146146
include $lng_file;
147147
}
148148
$tpl->setVar($wb);
149-
if ($app->auth->is_admin()) {
150-
$client_id = $limit_to_client_id;
151-
} else {
152-
$client_id = $_SESSION['s']['user']['client_id'];
153-
}
154-
155-
// $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
156-
$client = $app->db->queryOneRecord("SELECT * FROM client WHERE client_id = ?", $client_id);
157149

150+
if ($limit_to_client_id != null) {
151+
$client = $app->db->queryOneRecord("SELECT * FROM client WHERE client_id = ?", $limit_to_client_id);
152+
}
153+
elseif ($limit_to_client_id == null && $app->auth->is_reseller()) {
154+
$client = $app->db->queryOneRecord("SELECT * FROM client WHERE client_id = ?", $_SESSION['s']['user']['client_id']);
155+
}
158156

159157
$rows = array();
160158
foreach ($limits as $limit) {

0 commit comments

Comments
 (0)