latham
2011-05-05 7cd9971f543f12a5fb60b67631190712d0d9788e
First upload of the email quota reporting.
All parts are disabled at the moment. Please help update
the language files.

http://bugtracker.ispconfig.org/index.php?do=details&task_id=1242&project=3&pagenum=2


25 files added
4 files modified
446 ■■■■■ changed files
install/tpl/debian6_dovecot.conf.master 11 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/ar_user_quota_stats_list.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/bg_user_quota_stats_list.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/br_user_quota_stats_list.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/cz_user_quota_stats_list.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/de_user_quota_stats_list.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/el_user_quota_stats_list.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/en_user_quota_stats_list.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/es_user_quota_stats_list.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/fi_user_quota_stats_list.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/fr_user_quota_stats_list.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/hu_user_quota_stats_list.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/id_user_quota_stats_list.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/it_user_quota_stats_list.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/ja_user_quota_stats_list.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/nl_user_quota_stats_list.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/pl_user_quota_stats_list.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/pt_user_quota_stats_list.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/ro_user_quota_stats_list.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/ru_user_quota_stats_list.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/se_user_quota_stats_list.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/sk_user_quota_stats_list.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/tr_user_quota_stats_list.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/module.conf.php 8 ●●●●● patch | view | raw | blame | history
interface/web/mail/list/user_quota_stats.list.php 76 ●●●●● patch | view | raw | blame | history
interface/web/mail/templates/user_quota_stats_list.htm 48 ●●●●● patch | view | raw | blame | history
interface/web/mail/user_quota_stats.php 70 ●●●●● patch | view | raw | blame | history
server/lib/classes/monitor_tools.inc.php 76 ●●●●● patch | view | raw | blame | history
server/mods-available/monitor_core_module.inc.php 3 ●●●● patch | view | raw | blame | history
install/tpl/debian6_dovecot.conf.master
@@ -1,3 +1,7 @@
## ISPConfig3 Template file.
## This file was installed by ISPConfig3
## It will be replaced if ISPConfig3 is updated.
## Dovecot configuration file
base_dir = /var/run/dovecot/
@@ -45,6 +49,13 @@
## Plugin settings
plugin {
  quota = maildir
  # Disabled user quota reporting for the first upload
  # quota = dict:user::file:/var/vmail/%n_%d_quota
  # Because the mail quota is called in the user query
  # the maildir quota does not need to be set.
  # You do not need: quota = maildir
  sieve=/var/vmail/%d/%n/.sieve
}
interface/web/mail/lib/lang/ar_user_quota_stats_list.lng
New file
@@ -0,0 +1,7 @@
<?php
$wb["list_head_txt"] = 'Mailbox quota';
$wb["quota_txt"] = 'Quota';
$wb["name_txt"] = 'Name';
$wb["email_txt"] = 'Email Address';
$wb["used_txt"] = 'Used space';
?>
interface/web/mail/lib/lang/bg_user_quota_stats_list.lng
New file
@@ -0,0 +1,7 @@
<?php
$wb["list_head_txt"] = 'Mailbox quota';
$wb["quota_txt"] = 'Quota';
$wb["name_txt"] = 'Name';
$wb["email_txt"] = 'Email Address';
$wb["used_txt"] = 'Used space';
?>
interface/web/mail/lib/lang/br_user_quota_stats_list.lng
New file
@@ -0,0 +1,7 @@
<?php
$wb["list_head_txt"] = 'Mailbox quota';
$wb["quota_txt"] = 'Quota';
$wb["name_txt"] = 'Name';
$wb["email_txt"] = 'Email Address';
$wb["used_txt"] = 'Used space';
?>
interface/web/mail/lib/lang/cz_user_quota_stats_list.lng
New file
@@ -0,0 +1,7 @@
<?php
$wb["list_head_txt"] = 'Mailbox quota';
$wb["quota_txt"] = 'Quota';
$wb["name_txt"] = 'Name';
$wb["email_txt"] = 'Email Address';
$wb["used_txt"] = 'Used space';
?>
interface/web/mail/lib/lang/de_user_quota_stats_list.lng
New file
@@ -0,0 +1,7 @@
<?php
$wb["list_head_txt"] = 'Mailbox quota';
$wb["quota_txt"] = 'Quota';
$wb["name_txt"] = 'Name';
$wb["email_txt"] = 'Email Address';
$wb["used_txt"] = 'Used space';
?>
interface/web/mail/lib/lang/el_user_quota_stats_list.lng
New file
@@ -0,0 +1,7 @@
<?php
$wb["list_head_txt"] = 'Mailbox quota';
$wb["quota_txt"] = 'Quota';
$wb["name_txt"] = 'Name';
$wb["email_txt"] = 'Email Address';
$wb["used_txt"] = 'Used space';
?>
interface/web/mail/lib/lang/en_user_quota_stats_list.lng
New file
@@ -0,0 +1,7 @@
<?php
$wb["list_head_txt"] = 'Mailbox quota';
$wb["quota_txt"] = 'Quota';
$wb["name_txt"] = 'Name';
$wb["email_txt"] = 'Email Address';
$wb["used_txt"] = 'Used space';
?>
interface/web/mail/lib/lang/es_user_quota_stats_list.lng
New file
@@ -0,0 +1,7 @@
<?php
$wb["list_head_txt"] = 'Cuota de Correo';
$wb["quota_txt"] = 'Cuota';
$wb["name_txt"] = 'Nombre';
$wb["email_txt"] = 'Correo';
$wb["used_txt"] = 'Usado';
?>
interface/web/mail/lib/lang/fi_user_quota_stats_list.lng
New file
@@ -0,0 +1,7 @@
<?php
$wb["list_head_txt"] = 'Mailbox quota';
$wb["quota_txt"] = 'Quota';
$wb["name_txt"] = 'Name';
$wb["email_txt"] = 'Email Address';
$wb["used_txt"] = 'Used space';
?>
interface/web/mail/lib/lang/fr_user_quota_stats_list.lng
New file
@@ -0,0 +1,7 @@
<?php
$wb["list_head_txt"] = 'Mailbox quota';
$wb["quota_txt"] = 'Quota';
$wb["name_txt"] = 'Name';
$wb["email_txt"] = 'Email Address';
$wb["used_txt"] = 'Used space';
?>
interface/web/mail/lib/lang/hu_user_quota_stats_list.lng
New file
@@ -0,0 +1,7 @@
<?php
$wb["list_head_txt"] = 'Mailbox quota';
$wb["quota_txt"] = 'Quota';
$wb["name_txt"] = 'Name';
$wb["email_txt"] = 'Email Address';
$wb["used_txt"] = 'Used space';
?>
interface/web/mail/lib/lang/id_user_quota_stats_list.lng
New file
@@ -0,0 +1,7 @@
<?php
$wb["list_head_txt"] = 'Mailbox quota';
$wb["quota_txt"] = 'Quota';
$wb["name_txt"] = 'Name';
$wb["email_txt"] = 'Email Address';
$wb["used_txt"] = 'Used space';
?>
interface/web/mail/lib/lang/it_user_quota_stats_list.lng
New file
@@ -0,0 +1,7 @@
<?php
$wb["list_head_txt"] = 'Mailbox quota';
$wb["quota_txt"] = 'Quota';
$wb["name_txt"] = 'Name';
$wb["email_txt"] = 'Email Address';
$wb["used_txt"] = 'Used space';
?>
interface/web/mail/lib/lang/ja_user_quota_stats_list.lng
New file
@@ -0,0 +1,7 @@
<?php
$wb["list_head_txt"] = 'Mailbox quota';
$wb["quota_txt"] = 'Quota';
$wb["name_txt"] = 'Name';
$wb["email_txt"] = 'Email Address';
$wb["used_txt"] = 'Used space';
?>
interface/web/mail/lib/lang/nl_user_quota_stats_list.lng
New file
@@ -0,0 +1,7 @@
<?php
$wb["list_head_txt"] = 'Mailbox quota';
$wb["quota_txt"] = 'Quota';
$wb["name_txt"] = 'Name';
$wb["email_txt"] = 'Email Address';
$wb["used_txt"] = 'Used space';
?>
interface/web/mail/lib/lang/pl_user_quota_stats_list.lng
New file
@@ -0,0 +1,7 @@
<?php
$wb["list_head_txt"] = 'Mailbox quota';
$wb["quota_txt"] = 'Quota';
$wb["name_txt"] = 'Name';
$wb["email_txt"] = 'Email Address';
$wb["used_txt"] = 'Used space';
?>
interface/web/mail/lib/lang/pt_user_quota_stats_list.lng
New file
@@ -0,0 +1,7 @@
<?php
$wb["list_head_txt"] = 'Mailbox quota';
$wb["quota_txt"] = 'Quota';
$wb["name_txt"] = 'Name';
$wb["email_txt"] = 'Email Address';
$wb["used_txt"] = 'Used space';
?>
interface/web/mail/lib/lang/ro_user_quota_stats_list.lng
New file
@@ -0,0 +1,7 @@
<?php
$wb["list_head_txt"] = 'Mailbox quota';
$wb["quota_txt"] = 'Quota';
$wb["name_txt"] = 'Name';
$wb["email_txt"] = 'Email Address';
$wb["used_txt"] = 'Used space';
?>
interface/web/mail/lib/lang/ru_user_quota_stats_list.lng
New file
@@ -0,0 +1,7 @@
<?php
$wb["list_head_txt"] = 'Mailbox quota';
$wb["quota_txt"] = 'Quota';
$wb["name_txt"] = 'Name';
$wb["email_txt"] = 'Email Address';
$wb["used_txt"] = 'Used space';
?>
interface/web/mail/lib/lang/se_user_quota_stats_list.lng
New file
@@ -0,0 +1,7 @@
<?php
$wb["list_head_txt"] = 'Mailbox quota';
$wb["quota_txt"] = 'Quota';
$wb["name_txt"] = 'Name';
$wb["email_txt"] = 'Email Address';
$wb["used_txt"] = 'Used space';
?>
interface/web/mail/lib/lang/sk_user_quota_stats_list.lng
New file
@@ -0,0 +1,7 @@
<?php
$wb["list_head_txt"] = 'Mailbox quota';
$wb["quota_txt"] = 'Quota';
$wb["name_txt"] = 'Name';
$wb["email_txt"] = 'Email Address';
$wb["used_txt"] = 'Used space';
?>
interface/web/mail/lib/lang/tr_user_quota_stats_list.lng
New file
@@ -0,0 +1,7 @@
<?php
$wb["list_head_txt"] = 'Mailbox quota';
$wb["quota_txt"] = 'Quota';
$wb["name_txt"] = 'Name';
$wb["email_txt"] = 'Email Address';
$wb["used_txt"] = 'Used space';
?>
interface/web/mail/lib/module.conf.php
@@ -153,6 +153,14 @@
//**** Statistics menu
$items = array();
/*
//** Email Quotas
$items[] = array( 'title'   => 'Mailbox quota',
                  'target'  => 'content',
                  'link'    => 'mail/user_quota_stats.php',
                  'html_id' => 'user_quota_stats');
*/
$items[] = array( 'title'     => 'Mailbox traffic',
                  'target'     => 'content',
                  'link'    => 'mail/mail_user_stats.php',
interface/web/mail/list/user_quota_stats.list.php
New file
@@ -0,0 +1,76 @@
<?php
/*
    Datatypes:
    - INTEGER
    - DOUBLE
    - CURRENCY
    - VARCHAR
    - TEXT
    - DATE
*/
// Name of the list
$liste["name"]                 = "user_quota_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"]                = "user_quota_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'     => "");
$liste["item"][] = array(   'field'     => "name",
                            'datatype'  => "VARCHAR",
                            'formtype'  => "TEXT",
                            'op'        => "like",
                            'prefix'    => "%",
                            'suffix'    => "%",
                            'width'     => "",
                            'value'     => "");
$liste["item"][] = array(   'field'     => "quota",
                            'datatype'  => "VARCHAR",
                            'formtype'  => "TEXT",
                            'op'        => "like",
                            'prefix'    => "%",
                            'suffix'    => "%",
                            'width'     => "",
                            'value'     => "");
?>
interface/web/mail/templates/user_quota_stats_list.htm
New file
@@ -0,0 +1,48 @@
<h2><tmpl_var name="list_head_txt"></h2>
<div class="panel panel_list_user_quota_stats">
  <div class="pnl_listarea">
    <fieldset><legend><tmpl_var name="list_head_txt"></legend>
      <table class="list">
        <thead>
          <tr>
            <th class="tbl_col_email" scope="col"><tmpl_var name="email_txt"></th>
            <th class="tbl_col_name" scope="col"><tmpl_var name="name_txt"></th>
            <th class="tbl_col_system_user" scope="col" style="text-align:right;"><tmpl_var name="used_txt"></th>
            <th class="tbl_col_system_user" scope="col" style="text-align:right;"><tmpl_var name="quota_txt"></th>
            <th class="tbl_col_buttons" scope="col">&nbsp;</th>
          </tr>
          <tr>
            <td class="tbl_col_domain"><input type="text" name="search_email" value="{tmpl_var name='search_email'}" /></td>
            <td class="tbl_col_system_user"><input type="text" name="search_system_user" value="{tmpl_var name='search_name'}" /></td>
            <td class="tbl_col_system_user">&nbsp;</td>
            <td class="tbl_col_system_user">&nbsp;</td>
            <td class="tbl_col_buttons"><div class="buttons"><button type="button" class="icons16 icoFilter" name="Filter" id="Filter" value="{tmpl_var name="filter_txt"}" onClick="submitForm('pageForm','mail/user_quota_stats.php');"><span>{tmpl_var name="filter_txt"}</span></button></div></td>
          </tr>
        </thead>
        <tbody>
          <tmpl_loop name="records">
          <tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
            <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>
            <td class="tbl_col_name"><a href="#" onClick="loadContent('mail/mail_user_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="name"}</a></td>
            <td class="tbl_col_used" style="text-align:right;"><a href="#" onClick="loadContent('mail/mail_user_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="used"}</a></td>
            <td class="tbl_col_limit" style="text-align:right;"><a href="#" onClick="loadContent('mail/mail_user_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="quota"}</a></td>
            <td class="tbl_col_buttons">
              <div class="buttons icons16">
                &nbsp;
              </div>
            </td>
          </tr>
          </tmpl_loop>
        </tbody>
        <tfoot>
          <tr>
            <td class="tbl_footer tbl_paging" colspan="5"><tmpl_var name="paging"></td>
          </tr>
        </tfoot>
      </table>
    </fieldset>
  </div>
</div>
interface/web/mail/user_quota_stats.php
New file
@@ -0,0 +1,70 @@
<?php
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/user_quota_stats.list.php";
/******************************************
* End Form configuration
******************************************/
//* Check permissions for module
$app->auth->check_module_permissions('mail');
$app->load('listform_actions');
// $tmp_rec = $app->db->queryOneRecord("SELECT data from monitor_data WHERE type = 'harddisk_quota' ORDER BY created DESC");
// $monitor_data = unserialize($app->db->unquote($tmp_rec['data']));
$tmp_rec =  $app->db->queryAllRecords("SELECT data from monitor_data WHERE type = 'email_quota' ORDER BY created DESC");
$monitor_data = array();
if(is_array($tmp_rec)) {
    foreach ($tmp_rec as $tmp_mon) {
        $monitor_data = array_merge_recursive($monitor_data,unserialize($app->db->unquote($tmp_mon['data'])));
    }
}
class list_action extends listform_actions {
    function prepareDataRow($rec)
    {
        global $app,$monitor_data;
        $rec = $app->listform->decode($rec);
        //* Alternating datarow colors
        $this->DataRowColor = ($this->DataRowColor == '#FFFFFF') ? '#EEEEEE' : '#FFFFFF';
        $rec['bgcolor'] = $this->DataRowColor;
        $email = $rec['email'];
        $rec['used'] = $monitor_data[$email]['used'];
        if (!is_numeric($rec['used'])) $rec['used']=$rec['used'][1];
        $rec['quota'] = round($rec['quota'] / 1048576,2).' MB';
        if($rec['quota'] == "0 MB") $rec['quota'] = $app->lng('unlimited');
        if($rec['used'] < 1544000) {
            $rec['used'] = round($rec['used'] / 1024,2).' KB';
        } else {
            $rec['used'] = round($rec['used'] / 1048576,2).' MB';
        }
        //* The variable "id" contains always the index variable
        $rec['id'] = $rec[$this->idx_key];
        return $rec;
    }
}
$list = new list_action;
$list->SQLExtWhere = "";
$list->onLoad();
?>
server/lib/classes/monitor_tools.inc.php
@@ -149,35 +149,69 @@
        return array('name' => $distname, 'version' => $distver, 'id' => $distid, 'baseid' => $distbaseid);
    }
/*
    //** Email Quota
    public function monitorEmailQuota() {
        global $conf;
        //* Initialize data array
        $data = array();
        //* the id of the server as int
        $server_id = intval($conf['server_id']);
        //* The type of the data
        $type = 'email_quota';
        //* The state of the email_quota.
        $state = 'ok';
        //* Dovecot quota check Courier in progress lathama@gmail.com
        if($dir = opendir("/var/vmail")){
            while (($quotafiles = readdir($dir)) !== false){
                if(preg_match('/.\_quota$/', $quotafiles)){
                    $quotafile = (file("/var/vmail/" . $quotafiles));
                    $emailaddress = preg_replace('/_quota/',"", $quotafiles);
                    $emailaddress = preg_replace('/_/',"@", $emailaddress);
                    $data[$emailaddress]['used'] = trim($quotafile['1']);
                }
            }
            closedir($dir);
        }
        $res['server_id'] = $server_id;
        $res['type'] = $type;
        $res['data'] = $data;
        $res['state'] = $state;
        return $res;
    }
*/
    //** Filesystem Quota
    public function monitorHDQuota() {
        global $conf;
        /* Initialize data array */
        //* Initialize data array
        $data = array();
        /* the id of the server as int */
        //* the id of the server as int
        $server_id = intval($conf['server_id']);
        /** The type of the data */
        //* The type of the data
        $type = 'harddisk_quota';
        /** The state of the harddisk_quota. */
        //* The state of the harddisk_quota.
        $state = 'ok';
        /** Fetch the data for all users */
        //* Fetch the data for all users
        $dfData = shell_exec('repquota -au');
        // split into array
        //* Split into array
        $df = explode("\n", $dfData);
        /*
         * ignore the first 5 lines, process the rest
         */
        //* ignore the first 5 lines, process the rest
        for ($i = 5; $i <= sizeof($df); $i++) {
            if ($df[$i] != '') {
                /*
                 * Make a array of the data
                 */
                //* Make a array of the data
                $s = preg_split('/[\s]+/', $df[$i]);
                $username = $s[0];
                if (substr($username, 0, 3) == 'web') {
@@ -194,20 +228,16 @@
            }
        }
        /** Fetch the data for all users */
        //** Fetch the data for all users
        $dfData = shell_exec('repquota -ag');
        // split into array
        //* split into array
        $df = explode("\n", $dfData);
        /*
         * ignore the first 5 lines, process the rest
         */
        //* ignore the first 5 lines, process the rest
        for ($i = 5; $i <= sizeof($df); $i++) {
            if ($df[$i] != '') {
                /*
                 * Make a array of the data
                 */
                //* Make a array of the data
                $s = preg_split('/[\s]+/', $df[$i]);
                $groupname = $s[0];
                if (substr($groupname, 0, 6) == 'client') {
@@ -224,9 +254,7 @@
            }
        }
        /*
         * Return the Result
         */
        //* Return the Result
        $res['server_id'] = $server_id;
        $res['type'] = $type;
        $res['data'] = $data;
@@ -1670,4 +1698,4 @@
}
?>
?>
server/mods-available/monitor_core_module.inc.php
@@ -86,6 +86,7 @@
        /*
         * Calls the single Monitoring steps 
         */
        //*  $this->_monitorEmailQuota(); in process
        $this->_monitorHDQuota();
        $this->_monitorServer();
        $this->_monitorOsVer();
@@ -763,4 +764,4 @@
}
?>
?>