From 2f07ae7b851106a634c3fb0923e4bb7f3eaf32e4 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Wed, 28 May 2008 14:57:35 -0400
Subject: [PATCH] Added mailbox traffic statistics to the interface.
---
interface/web/mail/lib/module.conf.php | 12 +++
interface/web/mail/list/mail_user_stats.list.php | 60 +++++++++++++++
interface/lib/classes/listform_actions.inc.php | 6
interface/web/mail/lib/lang/en_mail_user_stats_list.lng | 14 +++
interface/web/mail/templates/mail_user_stats_list.htm | 33 ++++++++
interface/web/mail/mail_user_stats.php | 66 ++++++++++++++++
6 files changed, 188 insertions(+), 3 deletions(-)
diff --git a/interface/lib/classes/listform_actions.inc.php b/interface/lib/classes/listform_actions.inc.php
index 7e02066..6df910c 100644
--- a/interface/lib/classes/listform_actions.inc.php
+++ b/interface/lib/classes/listform_actions.inc.php
@@ -38,8 +38,8 @@
class listform_actions {
private $id;
- private $idx_key;
- private $DataRowColor;
+ public $idx_key;
+ public $DataRowColor;
public $SQLExtWhere = '';
public $SQLOrderBy = '';
@@ -82,7 +82,7 @@
}
- private function prepareDataRow($rec)
+ public function prepareDataRow($rec)
{
global $app;
diff --git a/interface/web/mail/lib/lang/en_mail_user_stats_list.lng b/interface/web/mail/lib/lang/en_mail_user_stats_list.lng
new file mode 100644
index 0000000..75cca6d
--- /dev/null
+++ b/interface/web/mail/lib/lang/en_mail_user_stats_list.lng
@@ -0,0 +1,14 @@
+<?php
+$wb["list_head_txt"] = 'Mail traffic statistic';
+$wb["email_txt"] = 'Email';
+$wb["this_month_txt"] = 'This month';
+$wb["last_month_txt"] = 'Last month';
+$wb["this_year_txt"] = 'This year';
+$wb["last_year_txt"] = 'Last year';
+$wb["page_txt"] = 'Page';
+$wb["page_of_txt"] = 'of';
+$wb["page_next_txt"] = 'Next';
+$wb["page_back_txt"] = 'Back';
+$wb["delete_txt"] = 'Delete';
+$wb["filter_txt"] = 'Filter';
+?>
\ No newline at end of file
diff --git a/interface/web/mail/lib/module.conf.php b/interface/web/mail/lib/module.conf.php
index 6e57cbd..de55cba 100644
--- a/interface/web/mail/lib/module.conf.php
+++ b/interface/web/mail/lib/module.conf.php
@@ -80,7 +80,19 @@
'open' => 1,
'items' => $items);
+//**** Statistics menu
+$items = array();
+$items[] = array( 'title' => 'Mailboxes',
+ 'target' => 'content',
+ 'link' => 'mail/mail_user_stats.php');
+
+
+$module['nav'][] = array( 'title' => 'Statistics',
+ 'open' => 1,
+ 'items' => $items);
+
+
//**** Global filters menu
$items = array();
if($_SESSION['s']['user']['typ'] == 'admin') {
diff --git a/interface/web/mail/list/mail_user_stats.list.php b/interface/web/mail/list/mail_user_stats.list.php
new file mode 100644
index 0000000..3193041
--- /dev/null
+++ b/interface/web/mail/list/mail_user_stats.list.php
@@ -0,0 +1,60 @@
+<?php
+
+/*
+ Datatypes:
+ - INTEGER
+ - DOUBLE
+ - CURRENCY
+ - VARCHAR
+ - TEXT
+ - DATE
+*/
+
+
+
+// Name of the list
+$liste["name"] = "mail_user_stats";
+
+// Database table
+$liste["table"] = "mail_user";
+
+// Index index field of the database table
+$liste["table_idx"] = "mailuser_id";
+
+// Search Field Prefix
+$liste["search_prefix"] = "search_";
+
+// Records per page
+$liste["records_per_page"] = 15;
+
+// Script File of the list
+$liste["file"] = "mail_user_stats.php";
+
+// Script file of the edit form
+$liste["edit_file"] = "mail_user_edit.php";
+
+// Script File of the delete script
+$liste["delete_file"] = "mail_user_del.php";
+
+// Paging Template
+$liste["paging_tpl"] = "templates/paging.tpl.htm";
+
+// Enable auth
+$liste["auth"] = "yes";
+
+
+/*****************************************************
+* Suchfelder
+*****************************************************/
+
+$liste["item"][] = array( 'field' => "email",
+ 'datatype' => "VARCHAR",
+ 'formtype' => "TEXT",
+ 'op' => "like",
+ 'prefix' => "%",
+ 'suffix' => "%",
+ 'width' => "",
+ 'value' => "");
+
+
+?>
\ No newline at end of file
diff --git a/interface/web/mail/mail_user_stats.php b/interface/web/mail/mail_user_stats.php
new file mode 100644
index 0000000..ad431e9
--- /dev/null
+++ b/interface/web/mail/mail_user_stats.php
@@ -0,0 +1,66 @@
+<?php
+require_once('../../lib/config.inc.php');
+require_once('../../lib/app.inc.php');
+
+/******************************************
+* Begin Form configuration
+******************************************/
+
+$list_def_file = "list/mail_user_stats.list.php";
+
+/******************************************
+* End Form configuration
+******************************************/
+
+// Checking module permissions
+if(!stristr($_SESSION["s"]["user"]["modules"],'mail')) {
+ header("Location: ../index.php");
+ exit;
+}
+
+$app->load('listform_actions');
+
+class list_action extends listform_actions {
+
+ function prepareDataRow($rec)
+ {
+ global $app;
+
+ $rec = $app->listform->decode($rec);
+
+ //* Alternating datarow colors
+ $this->DataRowColor = ($this->DataRowColor == '#FFFFFF') ? '#EEEEEE' : '#FFFFFF';
+ $rec['bgcolor'] = $this->DataRowColor;
+
+ //* Set the statistics colums
+ //** Traffic of the current month
+ $tmp_date = date('Y-m');
+ $tmp_rec = $app->db->queryOneRecord("SELECT traffic as t FROM mail_traffic WHERE mailuser_id = ".$rec['mailuser_id']." AND month = '$tmp_date'");
+ $rec['this_month'] = number_format(intval($tmp_rec['t'])/1024, 0, '.', ' ');
+
+ //** Traffic of the current year
+ $tmp_date = date('Y');
+ $tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic) as t FROM mail_traffic WHERE mailuser_id = ".$rec['mailuser_id']." AND month like '$tmp_date%'");
+ $rec['this_year'] = number_format(intval($tmp_rec['t'])/1024, 0, '.', ' ');
+
+ //** Traffic of the last month
+ $tmp_date = date('Y-m',mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
+ $tmp_rec = $app->db->queryOneRecord("SELECT traffic as t FROM mail_traffic WHERE mailuser_id = ".$rec['mailuser_id']." AND month = '$tmp_date'");
+ $rec['last_month'] = number_format(intval($tmp_rec['t'])/1024, 0, '.', ' ');
+
+ //** Traffic of the last year
+ $tmp_date = date('Y',mktime(0, 0, 0, date("m"), date("d"), date("Y")-1));
+ $tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic) as t FROM mail_traffic WHERE mailuser_id = ".$rec['mailuser_id']." AND month like '$tmp_date%'");
+ $rec['last_year'] = number_format(intval($tmp_rec['t'])/1024, 0, '.', ' ');
+
+ //* The variable "id" contains always the index variable
+ $rec['id'] = $rec[$this->idx_key];
+ return $rec;
+ }
+}
+
+$list = new list_action;
+$list->onLoad();
+
+
+?>
\ No newline at end of file
diff --git a/interface/web/mail/templates/mail_user_stats_list.htm b/interface/web/mail/templates/mail_user_stats_list.htm
new file mode 100644
index 0000000..a6e4aaf
--- /dev/null
+++ b/interface/web/mail/templates/mail_user_stats_list.htm
@@ -0,0 +1,33 @@
+<div class="frmTextHead"><tmpl_var name="list_head_txt"></div><br />
+<table width="100%" border="0" cellspacing="0" cellpadding="4" class="listTable">
+ <tr>
+ <td class="tblHead"><tmpl_var name="email_txt"></td>
+ <td class="tblHead"><tmpl_var name="this_month_txt"></td>
+ <td class="tblHead"><tmpl_var name="last_month_txt"></td>
+ <td class="tblHead"><tmpl_var name="this_year_txt"></td>
+ <td class="tblHead"><tmpl_var name="last_year_txt"></td>
+ <td class="tblHead"> </td>
+ </tr>
+ <tr>
+ <td class="frmText11"><input type="text" name="search_email" value="{tmpl_var name='search_email'}" class="text" /></td>
+ <td class="frmText11"> </td>
+ <td class="frmText11"> </td>
+ <td class="frmText11"> </td>
+ <td class="frmText11"> </td>
+ <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>
+ </tr>
+ <tmpl_loop name="records">
+ <tr bgcolor="{tmpl_var name="bgcolor"}">
+ <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>
+ <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>
+ <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>
+ <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>
+ <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>
+ <td class="frmText11" align="right"> </td>
+ </tr>
+ </tmpl_loop>
+
+ <tr>
+ <td colspan="6" height="40" align="center" class="tblFooter"><tmpl_var name="paging"></td>
+ </tr>
+</table>
\ No newline at end of file
--
Gitblit v1.9.1