Marius Cramer
2015-08-06 37b29231e47a0c4458dc1c15d98588f16f07e1e2
commit | author | age
7cd997 1 <?php
b1a6a5 2 require_once '../../lib/config.inc.php';
MC 3 require_once '../../lib/app.inc.php';
7cd997 4
L 5 /******************************************
6 * Begin Form configuration
7 ******************************************/
8
9 $list_def_file = "list/user_quota_stats.list.php";
10
11 /******************************************
12 * End Form configuration
13 ******************************************/
14
15 //* Check permissions for module
16 $app->auth->check_module_permissions('mail');
17
3319b4 18 $app->uses('functions');
FS 19
7cd997 20 $app->load('listform_actions');
L 21
22 $tmp_rec =  $app->db->queryAllRecords("SELECT data from monitor_data WHERE type = 'email_quota' ORDER BY created DESC");
23 $monitor_data = array();
24 if(is_array($tmp_rec)) {
25     foreach ($tmp_rec as $tmp_mon) {
a00888 26         //$monitor_data = array_merge_recursive($monitor_data,unserialize($app->db->unquote($tmp_mon['data'])));
T 27         $tmp_array = unserialize($app->db->unquote($tmp_mon['data']));
28         if(is_array($tmp_array)) {
29             foreach($tmp_array as $username => $data) {
cc6568 30                 if(!$monitor_data[$username]['used']) $monitor_data[$username]['used'] = $data['used'];
a00888 31             }
T 32         }
7cd997 33     }
L 34 }
35
36
37 class list_action extends listform_actions {
b1a6a5 38
7cd997 39     function prepareDataRow($rec)
b1a6a5 40     {
MC 41         global $app, $monitor_data;
42
7cd997 43         $rec = $app->listform->decode($rec);
L 44
45         //* Alternating datarow colors
46         $this->DataRowColor = ($this->DataRowColor == '#FFFFFF') ? '#EEEEEE' : '#FFFFFF';
47         $rec['bgcolor'] = $this->DataRowColor;
48         $email = $rec['email'];
b1a6a5 49
a8b07f 50         $rec['used'] = isset($monitor_data[$email]['used']) ? $monitor_data[$email]['used'] : array(1 => 0);
b1a6a5 51
7cd997 52         if (!is_numeric($rec['used'])) $rec['used']=$rec['used'][1];
b1a6a5 53
615a0a 54         if($rec['quota'] == 0){
T 55             $rec['quota'] = $app->lng('unlimited');
b1a6a5 56             $rec['percentage'] = '';
MC 57             $rec['percentage_sort'] = 0;
615a0a 58         } else {
b1a6a5 59             $rec['percentage'] = round(100 * $rec['used'] / $rec['quota']) . '%';
615a0a 60             $rec['percentage_sort'] = round(100 * $rec['used'] / $rec['quota']);
b1a6a5 61             $rec['quota'] = round($rec['quota'] / 1048576, 4).' MB';
615a0a 62         }
7cd997 63
L 64
b1a6a5 65         $rec['used_sort'] = $rec['used'];
3319b4 66 /*
b1a6a5 67         if($rec['used'] < 1544000) {
MC 68             $rec['used'] = round($rec['used'] / 1024, 4).' KB';
69         } else {
70             $rec['used'] = round($rec['used'] / 1048576, 4).' MB';
71         }
3319b4 72 */
FS 73         $rec['used']=$app->functions->formatBytes($rec['used']);
74         if ($rec['used'] == 'NAN') $rec['used']='0 KB';
7cd997 75
L 76         //* The variable "id" contains always the index variable
77         $rec['id'] = $rec[$this->idx_key];
78         return $rec;
79     }
b1a6a5 80
7cd997 81 }
L 82
83 $list = new list_action;
84 $list->SQLExtWhere = "";
85
86 $list->onLoad();
87
88
b1a6a5 89 ?>