@@ -8,6 +8,11 @@ function show() {
88 $ limits = array ();
99
1010 /* Limits to be shown*/
11+
12+ $ limits [] = array ('field ' => 'limit_mailquota ' ,
13+ 'db_table ' => 'mail_user ' ,
14+ 'db_where ' => 'quota > 0 ' , /* Count only posive value of quota, negative value -1 is unlimited */
15+ 'q_type ' => 'quota ' );
1116
1217 $ limits [] = array ('field ' => 'limit_maildomain ' ,
1318 'db_table ' => 'mail_domain ' ,
@@ -61,6 +66,11 @@ function show() {
6166 'db_table ' => 'spamfilter_policy ' ,
6267 'db_where ' => "" );
6368
69+ $ limits [] = array ('field ' => 'limit_web_quota ' ,
70+ 'db_table ' => 'web_domain ' ,
71+ 'db_where ' => 'hd_quota > 0 ' , /* Count only posive value of quota, negative value -1 is unlimited */
72+ 'q_type ' => 'hd_quota ' );
73+
6474 $ limits [] = array ('field ' => 'limit_web_domain ' ,
6575 'db_table ' => 'web_domain ' ,
6676 'db_where ' => "type = 'vhost' " );
@@ -93,6 +103,11 @@ function show() {
93103 'db_table ' => 'dns_rr ' ,
94104 'db_where ' => "" );
95105
106+ $ limits [] = array ('field ' => 'limit_database_quota ' ,
107+ 'db_table ' => 'web_database ' ,
108+ 'db_where ' => 'database_quota > 0 ' , /* Count only posive value of quota, negative value -1 is unlimited */
109+ 'q_type ' => 'database_quota ' );
110+
96111 $ limits [] = array ('field ' => 'limit_database ' ,
97112 'db_table ' => 'web_database ' ,
98113 'db_where ' => "" );
@@ -143,7 +158,11 @@ function show() {
143158 }
144159 if ($ value != 0 || $ value == $ wb ['unlimited_txt ' ]) {
145160 $ value_formatted = ($ value == '-1 ' )?$ wb ['unlimited_txt ' ]:$ value ;
146- $ usage = $ this ->_get_limit_usage ($ limit );
161+ if ($ limit ['q_type ' ]!='' ){
162+ $ usage = $ this ->_get_assigned_quota ($ limit ) . " MB " ;
163+ $ value_formatted = ($ value == '-1 ' )?$ wb ['unlimited_txt ' ]:$ value . " MB " ;
164+ }
165+ else $ usage = $ this ->_get_limit_usage ($ limit );
147166 $ percentage = ($ value == '-1 ' || $ value == 0 ? 0 : round (100 * $ usage / $ value ));
148167 $ rows [] = array ('field ' => $ field ,
149168 'field_txt ' => $ wb [$ field .'_txt ' ],
@@ -172,6 +191,19 @@ function _get_limit_usage($limit) {
172191 return $ rec ['number ' ];
173192
174193 }
194+
195+ function _get_assigned_quota ($ limit ) {
196+ global $ app ;
197+
198+ $ sql = "SELECT sum(??) as number FROM ?? WHERE " ;
199+ if ($ limit ['db_where ' ] != '' ) $ sql .= $ limit ['db_where ' ]." AND " ;
200+ $ sql .= $ app ->tform ->getAuthSQL ('r ' );
201+ $ rec = $ app ->db ->queryOneRecord ($ sql , $ limit ['q_type ' ], $ limit ['db_table ' ]);
202+ if ($ limit ['db_table ' ]=='mail_user ' ) $ quotaMB = $ rec ['number ' ] / 1048576 ; // Mail quota is in bytes, must be converted to MB
203+ else $ quotaMB = $ rec ['number ' ];
204+ return $ quotaMB ;
205+
206+ }
175207
176208}
177209
0 commit comments