Skip to content

Commit ad24a14

Browse files
author
Florian Schaal
committed
changed hard-coded conversion to formatBytes for mail-traffic stats
1 parent e7bb410 commit ad24a14

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

interface/web/mail/mail_user_stats.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
//* Check permissions for module
1616
$app->auth->check_module_permissions('mail');
1717

18+
$app->uses('functions');
19+
1820
$app->load('listform_actions');
1921

2022
class list_action extends listform_actions {
@@ -33,22 +35,30 @@ function prepareDataRow($rec)
3335
//** Traffic of the current month
3436
$tmp_date = date('Y-m');
3537
$tmp_rec = $app->db->queryOneRecord("SELECT traffic as t FROM mail_traffic WHERE mailuser_id = ".$app->functions->intval($rec['mailuser_id'])." AND month = '$tmp_date'");
36-
$rec['this_month'] = number_format($app->functions->intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
38+
// $rec['this_month'] = number_format($app->functions->intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
39+
$rec['this_month'] = $app->functions->formatBytes($tmp_rec['t']);
40+
if ($rec['this_month'] == 'NAN') $rec['this_month'] = '0 KB';
3741

3842
//** Traffic of the current year
3943
$tmp_date = date('Y');
4044
$tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic) as t FROM mail_traffic WHERE mailuser_id = ".$app->functions->intval($rec['mailuser_id'])." AND month like '$tmp_date%'");
41-
$rec['this_year'] = number_format($app->functions->intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
45+
// $rec['this_year'] = number_format($app->functions->intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
46+
$rec['this_year'] = $app->functions->formatBytes($tmp_rec['t']);
47+
if ($rec['this_year'] == 'NAN') $rec['this_year'] = '0 KB';
4248

4349
//** Traffic of the last month
4450
$tmp_date = date('Y-m', mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
4551
$tmp_rec = $app->db->queryOneRecord("SELECT traffic as t FROM mail_traffic WHERE mailuser_id = ".$app->functions->intval($rec['mailuser_id'])." AND month = '$tmp_date'");
46-
$rec['last_month'] = number_format($app->functions->intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
52+
// $rec['last_month'] = number_format($app->functions->intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
53+
$rec['last_month'] = $app->functions->formatBytes($tmp_rec['t']);
54+
if ($rec['last_month'] == 'NAN') $rec['last_month'] = '0 KB';
4755

4856
//** Traffic of the last year
4957
$tmp_date = date('Y', mktime(0, 0, 0, date("m"), date("d"), date("Y")-1));
5058
$tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic) as t FROM mail_traffic WHERE mailuser_id = ".$app->functions->intval($rec['mailuser_id'])." AND month like '$tmp_date%'");
51-
$rec['last_year'] = number_format($app->functions->intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
59+
// $rec['last_year'] = number_format($app->functions->intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
60+
$rec['last_year'] = $app->functions->formatBytes($tmp_rec['t']);
61+
if ($rec['last_year'] == 'NAN') $rec['last_year'] = '0 KB';
5262

5363
//* The variable "id" contains always the index variable
5464
$rec['id'] = $rec[$this->idx_key];

interface/web/mail/templates/mail_user_stats_list.htm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ <h2><tmpl_var name="list_head_txt"></h2>
3030
<tmpl_loop name="records">
3131
<tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
3232
<td class="tbl_col_email"><a href="#" onclick="loadContent('mail/mail_user_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="email"}</a></td>
33-
<td class="tbl_col_this_month"><a href="#" onclick="loadContent('mail/mail_user_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="this_month"} MB</a></td>
34-
<td class="tbl_col_last_month"><a href="#" onclick="loadContent('mail/mail_user_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="last_month"} MB</a></td>
35-
<td class="tbl_col_this_year"><a href="#" onclick="loadContent('mail/mail_user_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="this_year"} MB</a></td>
36-
<td class="tbl_col_last_year"><a href="#" onclick="loadContent('mail/mail_user_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="last_year"} MB</a></td>
33+
<td class="tbl_col_this_month"><a href="#" onclick="loadContent('mail/mail_user_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="this_month"}</a></td>
34+
<td class="tbl_col_last_month"><a href="#" onclick="loadContent('mail/mail_user_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="last_month"}</a></td>
35+
<td class="tbl_col_this_year"><a href="#" onclick="loadContent('mail/mail_user_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="this_year"}</a></td>
36+
<td class="tbl_col_last_year"><a href="#" onclick="loadContent('mail/mail_user_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="last_year"}</a></td>
3737
<td class="tbl_col_buttons"></td>
3838
</tr>
3939
</tmpl_loop>
@@ -53,4 +53,4 @@ <h2><tmpl_var name="list_head_txt"></h2>
5353
</fieldset>
5454
</div>
5555

56-
</div>
56+
</div>

0 commit comments

Comments
 (0)