Skip to content

Commit 2f07ae7

Browse files
committed
Added mailbox traffic statistics to the interface.
1 parent ace9ddc commit 2f07ae7

File tree

6 files changed

+188
-3
lines changed

6 files changed

+188
-3
lines changed

interface/lib/classes/listform_actions.inc.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
class listform_actions {
3939

4040
private $id;
41-
private $idx_key;
42-
private $DataRowColor;
41+
public $idx_key;
42+
public $DataRowColor;
4343
public $SQLExtWhere = '';
4444
public $SQLOrderBy = '';
4545

@@ -82,7 +82,7 @@ public function onLoad()
8282

8383
}
8484

85-
private function prepareDataRow($rec)
85+
public function prepareDataRow($rec)
8686
{
8787
global $app;
8888

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
$wb["list_head_txt"] = 'Mail traffic statistic';
3+
$wb["email_txt"] = 'Email';
4+
$wb["this_month_txt"] = 'This month';
5+
$wb["last_month_txt"] = 'Last month';
6+
$wb["this_year_txt"] = 'This year';
7+
$wb["last_year_txt"] = 'Last year';
8+
$wb["page_txt"] = 'Page';
9+
$wb["page_of_txt"] = 'of';
10+
$wb["page_next_txt"] = 'Next';
11+
$wb["page_back_txt"] = 'Back';
12+
$wb["delete_txt"] = 'Delete';
13+
$wb["filter_txt"] = 'Filter';
14+
?>

interface/web/mail/lib/module.conf.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,19 @@
8080
'open' => 1,
8181
'items' => $items);
8282

83+
//**** Statistics menu
84+
$items = array();
85+
86+
$items[] = array( 'title' => 'Mailboxes',
87+
'target' => 'content',
88+
'link' => 'mail/mail_user_stats.php');
8389

90+
91+
$module['nav'][] = array( 'title' => 'Statistics',
92+
'open' => 1,
93+
'items' => $items);
94+
95+
8496
//**** Global filters menu
8597
$items = array();
8698
if($_SESSION['s']['user']['typ'] == 'admin') {
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
/*
4+
Datatypes:
5+
- INTEGER
6+
- DOUBLE
7+
- CURRENCY
8+
- VARCHAR
9+
- TEXT
10+
- DATE
11+
*/
12+
13+
14+
15+
// Name of the list
16+
$liste["name"] = "mail_user_stats";
17+
18+
// Database table
19+
$liste["table"] = "mail_user";
20+
21+
// Index index field of the database table
22+
$liste["table_idx"] = "mailuser_id";
23+
24+
// Search Field Prefix
25+
$liste["search_prefix"] = "search_";
26+
27+
// Records per page
28+
$liste["records_per_page"] = 15;
29+
30+
// Script File of the list
31+
$liste["file"] = "mail_user_stats.php";
32+
33+
// Script file of the edit form
34+
$liste["edit_file"] = "mail_user_edit.php";
35+
36+
// Script File of the delete script
37+
$liste["delete_file"] = "mail_user_del.php";
38+
39+
// Paging Template
40+
$liste["paging_tpl"] = "templates/paging.tpl.htm";
41+
42+
// Enable auth
43+
$liste["auth"] = "yes";
44+
45+
46+
/*****************************************************
47+
* Suchfelder
48+
*****************************************************/
49+
50+
$liste["item"][] = array( 'field' => "email",
51+
'datatype' => "VARCHAR",
52+
'formtype' => "TEXT",
53+
'op' => "like",
54+
'prefix' => "%",
55+
'suffix' => "%",
56+
'width' => "",
57+
'value' => "");
58+
59+
60+
?>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
require_once('../../lib/config.inc.php');
3+
require_once('../../lib/app.inc.php');
4+
5+
/******************************************
6+
* Begin Form configuration
7+
******************************************/
8+
9+
$list_def_file = "list/mail_user_stats.list.php";
10+
11+
/******************************************
12+
* End Form configuration
13+
******************************************/
14+
15+
// Checking module permissions
16+
if(!stristr($_SESSION["s"]["user"]["modules"],'mail')) {
17+
header("Location: ../index.php");
18+
exit;
19+
}
20+
21+
$app->load('listform_actions');
22+
23+
class list_action extends listform_actions {
24+
25+
function prepareDataRow($rec)
26+
{
27+
global $app;
28+
29+
$rec = $app->listform->decode($rec);
30+
31+
//* Alternating datarow colors
32+
$this->DataRowColor = ($this->DataRowColor == '#FFFFFF') ? '#EEEEEE' : '#FFFFFF';
33+
$rec['bgcolor'] = $this->DataRowColor;
34+
35+
//* Set the statistics colums
36+
//** Traffic of the current month
37+
$tmp_date = date('Y-m');
38+
$tmp_rec = $app->db->queryOneRecord("SELECT traffic as t FROM mail_traffic WHERE mailuser_id = ".$rec['mailuser_id']." AND month = '$tmp_date'");
39+
$rec['this_month'] = number_format(intval($tmp_rec['t'])/1024, 0, '.', ' ');
40+
41+
//** Traffic of the current year
42+
$tmp_date = date('Y');
43+
$tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic) as t FROM mail_traffic WHERE mailuser_id = ".$rec['mailuser_id']." AND month like '$tmp_date%'");
44+
$rec['this_year'] = number_format(intval($tmp_rec['t'])/1024, 0, '.', ' ');
45+
46+
//** Traffic of the last month
47+
$tmp_date = date('Y-m',mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
48+
$tmp_rec = $app->db->queryOneRecord("SELECT traffic as t FROM mail_traffic WHERE mailuser_id = ".$rec['mailuser_id']." AND month = '$tmp_date'");
49+
$rec['last_month'] = number_format(intval($tmp_rec['t'])/1024, 0, '.', ' ');
50+
51+
//** Traffic of the last year
52+
$tmp_date = date('Y',mktime(0, 0, 0, date("m"), date("d"), date("Y")-1));
53+
$tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic) as t FROM mail_traffic WHERE mailuser_id = ".$rec['mailuser_id']." AND month like '$tmp_date%'");
54+
$rec['last_year'] = number_format(intval($tmp_rec['t'])/1024, 0, '.', ' ');
55+
56+
//* The variable "id" contains always the index variable
57+
$rec['id'] = $rec[$this->idx_key];
58+
return $rec;
59+
}
60+
}
61+
62+
$list = new list_action;
63+
$list->onLoad();
64+
65+
66+
?>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<div class="frmTextHead"><tmpl_var name="list_head_txt"></div><br />
2+
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="listTable">
3+
<tr>
4+
<td class="tblHead"><tmpl_var name="email_txt"></td>
5+
<td class="tblHead"><tmpl_var name="this_month_txt"></td>
6+
<td class="tblHead"><tmpl_var name="last_month_txt"></td>
7+
<td class="tblHead"><tmpl_var name="this_year_txt"></td>
8+
<td class="tblHead"><tmpl_var name="last_year_txt"></td>
9+
<td class="tblHead">&nbsp;</td>
10+
</tr>
11+
<tr>
12+
<td class="frmText11"><input type="text" name="search_email" value="{tmpl_var name='search_email'}" class="text" /></td>
13+
<td class="frmText11">&nbsp;</td>
14+
<td class="frmText11">&nbsp;</td>
15+
<td class="frmText11">&nbsp;</td>
16+
<td class="frmText11">&nbsp;</td>
17+
<td class="frmText11" align="right"><input name="Filter" type="button" id="Filter" value="{tmpl_var name="filter_txt"}" class="button" onClick="submitForm('pageForm','mail/mail_user_stats.php');"><div class="buttonEnding"></div></td>
18+
</tr>
19+
<tmpl_loop name="records">
20+
<tr bgcolor="{tmpl_var name="bgcolor"}">
21+
<td class="frmText11"><a href="#" onClick="loadContent('mail/mail_user_edit.php?id={tmpl_var name='id'}');" class="frmText11">{tmpl_var name="email"}</a></td>
22+
<td class="frmText11"><a href="#" onClick="loadContent('mail/mail_user_edit.php?id={tmpl_var name='id'}');" class="frmText11">{tmpl_var name="this_month"} KB</a></td>
23+
<td class="frmText11"><a href="#" onClick="loadContent('mail/mail_user_edit.php?id={tmpl_var name='id'}');" class="frmText11">{tmpl_var name="last_month"} KB</a></td>
24+
<td class="frmText11"><a href="#" onClick="loadContent('mail/mail_user_edit.php?id={tmpl_var name='id'}');" class="frmText11">{tmpl_var name="this_year"} KB</a></td>
25+
<td class="frmText11"><a href="#" onClick="loadContent('mail/mail_user_edit.php?id={tmpl_var name='id'}');" class="frmText11">{tmpl_var name="last_year"} KB</a></td>
26+
<td class="frmText11" align="right">&nbsp;</td>
27+
</tr>
28+
</tmpl_loop>
29+
30+
<tr>
31+
<td colspan="6" height="40" align="center" class="tblFooter"><tmpl_var name="paging"></td>
32+
</tr>
33+
</table>

0 commit comments

Comments
 (0)