Alternc  latest
Alternc logiel libre pour l'hébergement
m_quota.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  ----------------------------------------------------------------------
5  LICENSE
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License (GPL)
9  as published by the Free Software Foundation; either version 2
10  of the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  To read the license please visit http://www.gnu.org/copyleft/gpl.html
18  ----------------------------------------------------------------------
19 */
20 
21 /**
22  * Class for hosting quotas management
23  *
24  * This class manages services' quotas for each user of AlternC.
25  * The available quotas for each service is stored in the system.quotas
26  * mysql table. The used value is computed by the class using a
27  * callback function <code>alternc_quota_check($uid)</code> that
28  * may by exported by each service class.<br>
29  * each class may also export a function <code>alternc_quota_names()</code>
30  * that returns an array with the quotas names managed by this class.
31  *
32  * @copyright AlternC-Team 2000-2017 https://alternc.com/
33  */
34 class m_quota {
35 
36  var $disk = Array(); /* disk resource for which we will manage quotas */
39  var $quotas;
40  var $clquota; // Which class manage which quota.
41 
42 
43  /**
44  * Constructor
45  */
46  function m_quota() {
47  $this->disk_quota_enable = variable_get('disk_quota_enable', 1, 'Are disk quota enabled for this server', array('desc' => 'Enabled', 'type' => 'boolean'));
48  if ($this->disk_quota_enable) {
49  $this->disk = Array("web" => "web");
50 
51  $this->disk_quota_not_blocking = variable_get('disk_quota_not_blocking', 1, "0 - Block data when quota are exceeded (you need a working quota system) | 1 - Just show quota but don't block anything", array('desc' => 'Enabled', 'type' => 'boolean'));
52  }
53  }
54 
55 
56  private function dummy_for_translation() {
57  _("quota_web");
58  }
59 
60 
61  function hook_menu() {
62  global $cuid, $mem, $quota;
63 
64  $obj = array(
65  'title' => _("Show my quotas"),
66  'ico' => 'images/quota.png',
67  'link' => 'toggle',
68  'pos' => 5,
69  'divclass' => 'menu-quota',
70  'links' => array(),
71  );
72 
73  $q = $this->getquota();
74 
75  foreach ($q as $key=>$value)
76  if (($key=="web")||(isset($value['in_menu'])&&$value['in_menu'])) {
77  if (!isset($q[$key]["u"]) || empty($q[$key]["t"])) {
78  continue;
79  }
80 
81  $totalsize_used = $quota->get_size_web_sum_user($cuid) + $quota->get_size_mailman_sum_user($cuid) + ($quota->get_size_db_sum_user($mem->user["login"]) + $quota->get_size_mail_sum_user($cuid))/1024;
82  $usage_percent = (int) ($totalsize_used / $q[$key]["t"] * 100);
83  $obj['links'][] = array('txt' => _("quota_" . $key) . " " . sprintf(_("%s%% of %s"), $usage_percent, format_size($q[$key]["t"] * 1024)), 'url' => 'quota_show.php');
84  $obj['links'][] = array('txt' => 'progressbar', 'total' => $q[$key]["t"], 'used' => $totalsize_used);
85  }
86 
87  // do not return menu item if there is no quota
88  if (!count($obj['links'])) return false;
89  return $obj;
90  }
91 
92 
93  function hook_homepageblock() {
94  return (object)Array(
95  'pos' => 20,
96  'call'=> function() {
97  define("QUOTASONE","1");
98  },
99  'include' => "quotas_oneuser.php"
100  );
101  }
102 
103 
104  /** Check if a user can use a ressource.
105  * @param string $ressource the ressource name (a named quota)
106  * @Return TRUE if the user can create a ressource (= is there any quota left ?)
107  * @return boolean
108  */
109  function cancreate($ressource = "") {
110  $t = $this->getquota($ressource);
111  return $t["u"] < $t["t"];
112  }
113 
114 
115  /** List the quota-managed services in the server
116  * @Return array the quota names and description (translated)
117  */
118  function qlist() {
119  $qlist = array();
120  reset($this->disk);
121  while (list($key, $val) = each($this->disk)) {
122  $qlist[$key] = _("quota_" . $key); // those are specific disks quotas.
123  }
124 
125  foreach ($this->getquota() as $qq) {
126  if (isset($qq['name'])) {
127  $qlist[$qq['name']] = $qq['description'];
128  }
129  }
130  return $qlist;
131  }
132 
133 
134  /**
135  * Synchronise the quotas of the users with the quota of the
136  * user's profile.
137  * If the user have a greater quota than the profile, no change.
138  * If the quota entry doesn't exist for the user, create it with
139  * the defaults value.
140  */
142  global $db, $msg;
143  $msg->log("quota", "synchronise_user_profile");
144  $q = "INSERT INTO quotas SELECT m.uid AS uid, d.quota AS name, d.value AS total FROM membres m, defquotas d LEFT JOIN quotas q ON q.name=d.quota WHERE m.type=d.type ON DUPLICATE KEY UPDATE total = greatest(d.value, quotas.total);";
145  if (!$db->query($q)) {
146  return false;
147  }
148  return true;
149  }
150 
151 
152  /*
153  * Create default quota in the profile
154  * when a new quota appear
155  */
157  global $db, $quota, $msg;
158  $msg->log("quota", "create_missing_quota_profile");
159  $qt = $quota->getquota('', true);
160  $type = $quota->listtype();
161  foreach ($type as $t) {
162  foreach ($qt as $q => $vv) {
163  $db->query("INSERT IGNORE defquotas (value,quota,type) VALUES (0, ?, ?);", array($q, $t));
164  }
165  }
166  return true;
167  }
168 
169 
170  /** Return a ressource usage (u) and total quota (t)
171  * @param string $ressource ressource to get quota of
172  * @Return array the quota used and total for this ressource (or for all ressource if unspecified)
173  */
174  function getquota($ressource = "", $recheck = false) {
175  global $db, $msg, $cuid, $get_quota_cache, $hooks, $mem;
176  $msg->debug("quota", "getquota", $ressource);
177  if ($recheck) { // rebuilding quota
178  $get_quota_cache = null;
179  $this->quotas = array();
180  }
181  if (!empty($get_quota_cache[$cuid])) {
182  // This function is called many time each webpage, so I cache the result
183  $this->quotas = $get_quota_cache[$cuid];
184  } else {
185  $res = $hooks->invoke("hook_quota_get");
186  foreach ($res as $r) {
187  $this->quotas[$r['name']] = $r;
188  $this->quotas[$r['name']]['u'] = $r['used']; // retrocompatibility
189  if (isset($r['sizeondisk']))
190  $this->quotas[$r['name']]['s'] = $r['sizeondisk'];
191  $this->quotas[$r['name']]['t'] = 0; // Default quota = 0
192  }
193  reset($this->disk);
194 
195  if (!empty($this->disk)) { // Check if there are some disk quota to check
196  // Look if there are some cached value
197  $disk_cached = $mem->session_tempo_params_get('quota_cache_disk');
198 
199  while (list($key, $val) = each($this->disk)) {
200  $a = array();
201  if (
202  isset($disk_cached[$val]) && !empty($disk_cached[$val]) && $disk_cached[$val]['uid'] == $cuid && $disk_cached[$val]['timestamp'] > ( time() - (90) ) // Cache, en seconde
203  ) {
204  // If there is a cached value
205  $a = $disk_cached[$val];
206  } else {
207  if ($this->disk_quota_not_blocking) {
208  $a['u'] = $this->get_size_web_sum_user($cuid);
209  $a['t'] = $this->get_quota_user_cat($cuid, 'web');
210  } else {
211  exec("/usr/lib/alternc/quota_get " . intval($cuid), $ak);
212  $a['u'] = intval($ak[0]);
213  $a['t'] = @intval($ak[1]);
214  }
215  $a['sizeondisk'] = $a['u'];
216  $a['timestamp'] = time();
217  $a['uid'] = $cuid;
218  $disk_cached = $mem->session_tempo_params_set('quota_cache_disk', array($val => $a));
219  }
220  $this->quotas[$val] = array("name" => "$val", 'description' => _("Web disk space"), "s" => $a['sizeondisk'], "t" => $a['t'], "u" => $a['u']);
221  }
222  }
223 
224  // Get the allowed quota from database.
225  $db->query("select name, total from quotas where uid= ? ;", array($cuid));
226  while ($db->next_record()) {
227  $this->quotas[$db->f('name')]['t'] = $db->f('total');
228  }
229 
230  $get_quota_cache[$cuid] = $this->quotas;
231  }
232 
233  if ($ressource) {
234  if (isset($this->quotas[$ressource])) {
235  return $this->quotas[$ressource];
236  } else {
237  return 0;
238  }
239  } else {
240  return $this->quotas;
241  }
242  }
243 
244 
245  /** Set the quota for a user (and for a ressource)
246  * @param string $ressource ressource to set quota of
247  * @param integer size of the quota (available or used)
248  */
249  function setquota($ressource, $size) {
250  global $msg, $db, $cuid;
251  $msg->log("quota", "setquota", $ressource . "/" . $size);
252  if (floatval($size) == 0) {
253  $size = "0";
254  }
255  if (!$this->disk_quota_not_blocking && isset($this->disk[$ressource])) {
256  // It's a disk resource, update it with shell command
257  exec("sudo /usr/lib/alternc/quota_edit " . intval($cuid) . " " . intval($size) . " &> /dev/null &");
258  // Now we check that the value has been written properly :
259  $a = array();
260  exec("sudo /usr/lib/alternc/quota_get " . intval($cuid) . " &> /dev/null &", $a);
261  if (!isset($a[1]) || $size != $a[1]) {
262  $msg->raise("ERROR", "quota", _("Error writing the quota entry!"));
263  return false;
264  }
265  }
266  // We check that this ressource exists for this client :
267  $db->query("SELECT * FROM quotas WHERE uid= ? AND name= ? ", array($cuid, $ressource));
268  if ($db->num_rows()) {
269  $db->query("UPDATE quotas SET total= ? WHERE uid= ? AND name= ?;", array($size, $cuid, $ressource));
270  } else {
271  $db->query("INSERT INTO quotas (uid,name,total) VALUES (?, ?, ?);", array($cuid, $ressource, $size));
272  }
273  return true;
274  }
275 
276 
277  /**
278  * Erase all quota information about the user.
279  */
280  function delquotas() {
281  global $db, $msg, $cuid;
282  $msg->log("quota", "delquota");
283  $db->query("DELETE FROM quotas WHERE uid= ?;", array($cuid));
284  return true;
285  }
286 
287 
288  /**
289  * Get the default quotas as an associative array
290  * @return array the array of the default quotas
291  */
292  function getdefaults() {
293  global $db;
294  $c = array();
295 
296  $db->query("SELECT type,quota FROM defquotas WHERE type='default'");
297  if (!$db->next_record()) {
298  $this->addtype('default');
299  }
300  $db->query("SELECT value,quota,type FROM defquotas ORDER BY type,quota");
301  while ($db->next_record()) {
302  $type = $db->f("type");
303  $c[$type][$db->f("quota")] = $db->f("value");
304  }
305  return $c;
306  }
307 
308 
309  /**
310  * Set the default quotas
311  * @param array associative array of quota (key=>val)
312  */
313  function setdefaults($newq) {
314  global $db;
315  $qlist = $this->qlist();
316 
317  foreach ($newq as $type => $quotas) {
318  foreach ($quotas as $qname => $value) {
319  if (array_key_exists($qname, $qlist)) {
320  if (!$db->query("REPLACE INTO defquotas (value,quota,type) VALUES ( ?, ?, ?); ", array($value, $qname, $type))) {
321  return false;
322  }
323  }
324  }
325  }
326  return true;
327  }
328 
329 
330  /**
331  * Add an account type for quotas
332  * @param string $type account type to be added
333  * @return boolean true if all went ok
334  */
335  function addtype($type) {
336  global $db, $msg;
337  $qlist = $this->qlist();
338  if (empty($type)) {
339  return false;
340  }
341  $type = strtolower($type);
342  if (!preg_match("#^[a-z0-9]*$#", $type)) {
343  $msg->raise("ERROR", "quota", _("Type can only contains characters a-z and 0-9"));
344  return false;
345  }
346  while (list($key, $val) = each($qlist)) {
347  if (!$db->query("INSERT IGNORE INTO defquotas (quota,type) VALUES(?, ?);", array($key, $type)) || $db->affected_rows() == 0) {
348  return false;
349  }
350  }
351  return true;
352  }
353 
354 
355  /**
356  * List types of quotas
357  * @return array
358  */
359  function listtype() {
360  global $db;
361  $db->query("SELECT distinct(type) FROM defquotas ORDER by type");
362  $t = array();
363  while ($db->next_record()) {
364  $t[] = $db->f("type");
365  }
366  return $t;
367  }
368 
369 
370  /** Delete an account type for quotas
371  * @param string $type account type to be deleted
372  * @return boolean true if all went ok
373  */
374  function deltype($type) {
375  global $db;
376 
377  if ($db->query("UPDATE membres SET type='default' WHERE type= ? ;", array($type)) &&
378  $db->query("DELETE FROM defquotas WHERE type= ?;", array($type))) {
379  return true;
380  } else {
381  return false;
382  }
383  }
384 
385 
386  /** Create default quotas entries for a new user.
387  * The user we are talking about is in the global $cuid.
388  */
389  function addquotas() {
390  global $db, $msg, $cuid;
391  $msg->log("quota", "addquota");
392  $ql = $this->qlist();
393  reset($ql);
394 
395  $db->query("SELECT type,quota FROM defquotas WHERE type='default'");
396  if (!$db->next_record()) {
397  $this->addtype('default');
398  }
399  $db->query("SELECT type FROM membres WHERE uid= ?;", array($cuid));
400  $db->next_record();
401  $t = $db->f("type");
402 
403  foreach ($ql as $res => $val) {
404  $db->query("SELECT value FROM defquotas WHERE quota= ? AND type= ? ;", array($res, $t));
405  $q = $db->next_record() ? $db->f("value") : 0;
406  $this->setquota($res, $q);
407  }
408  return true;
409  }
410 
411 
412  /** Return a quota value with its unit (when it is a space quota)
413  * in MB, GB, TB ...
414  * @param string $type The quota type
415  * @param integer $value The quota value
416  * @return string a quota value with its unit.
417  */
418  function display_val($type, $value) {
419  switch ($type) {
420  case 'bw_web':
421  return format_size($value);
422  case 'web':
423  return format_size($value * 1024);
424  default:
425  return $value;
426  }
427  }
428 
429 
430  /* get size_xx function (filled by spoolsize.php) */
431  function _get_sum_sql($sql) {
432  global $db;
433  $db->query($sql);
434  if ($db->num_rows() == 0) {
435  return -1;
436  } else {
437  $db->next_record();
438  $r = $db->Record;
439  return $r['sum'];
440  }
441  }
442 
443 
444  function _get_count_sql($sql) {
445  global $db;
446  $db->query($sql);
447  if ($db->num_rows() == 0) {
448  return 0;
449  } else {
450  $db->next_record();
451  $r = $db->Record;
452  return $r['count'];
453  }
454  }
455 
456 
457  function _get_size_and_record_sql($sql) {
458  global $db;
459  $db->query($sql);
460  if ($db->num_rows() == 0) {
461  return array();
462  } else {
463  $ret = array();
464  while ($db->next_record()) {
465  $ret[] = $db->Record;
466  }
467  return $ret;
468  }
469  }
470 
471 
472  /* get the quota from one user for a cat */
473  function get_quota_user_cat($uid, $name) {
474  return $this->_get_sum_sql("SELECT SUM(total) AS sum FROM quotas WHERE uid='$uid' AND name='$name';");
475  }
476 
477 
478  /* sum of websites sizes from all users */
479  function get_size_web_sum_all() {
480  return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_web;");
481  }
482 
483 
484  /* sum of websites sizes from one user */
485  function get_size_web_sum_user($u) {
486  return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_web WHERE uid='$u';");
487  }
488 
489 
490  /* sum of mailbox sizes from all domains */
492  return $this->_get_sum_sql("SELECT SUM(quota_dovecot) AS sum FROM dovecot_quota ;");
493  }
494 
495 
496  /* sum of mailbox sizes for one domain */
498  global $mail;
499  return $mail->get_total_size_for_domain($dom);
500  }
501 
502 
503  /* sum of mailbox size for ine user */
504  function get_size_mail_sum_user($u) {
505  return $this->_get_sum_sql("SELECT SUM(quota_dovecot) as sum FROM dovecot_quota WHERE user IN (SELECT CONCAT(a.address, '@', d.domaine) as mail FROM `address` as a INNER JOIN domaines as d ON a.domain_id = d.id WHERE d.compte = '$u' AND a.type ='')");
506  }
507 
508 
509  /* count of mailbox sizes from all domains */
511  return $this->_get_count_sql("SELECT COUNT(*) AS count FROM dovecot_quota;");
512  }
513 
514 
515  /* count of mailbox for one domain */
517  return $this->_get_count_sql("SELECT COUNT(*) AS count FROM dovecot_quota WHERE user LIKE '%@{$dom}'");
518  }
519 
520 
521  /* get list of mailbox alias and size for one domain */
523  return $this->_get_size_and_record_sql("SELECT user as alias,quota_dovecot as size FROM dovecot_quota WHERE user LIKE '%@{$dom}' ORDER BY alias;");
524  }
525 
526 
527  /* sum of mailman lists sizes from all domains */
529  return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mailman;");
530  }
531 
532 
533  /* sum of mailman lists sizes for one domain */
535  return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mailman s INNER JOIN mailman m ON s.list = m.list AND s.uid = m.uid WHERE m.domain = '$dom'");
536  }
537 
538 
539  /* sum of mailman lists for one user */
541  return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mailman WHERE uid = '{$u}'");
542  }
543 
544 
545  /* count of mailman lists sizes from all domains */
547  return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_mailman;");
548  }
549 
550 
551  /* count of mailman lists for one user */
553  return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_mailman WHERE uid = '{$u}'");
554  }
555 
556 
557  /* get list of mailman list and size for one user */
559  return $this->_get_size_and_record_sql("SELECT s.size,CONCAT(m.list,'@',m.domain) as list FROM size_mailman s LEFT JOIN mailman m ON s.list=m.name WHERE s.uid='{$u}' ORDER BY s.list ASC");
560  }
561 
562 
563  /* sum of databases sizes from all users */
564  function get_size_db_sum_all() {
565  return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_db;");
566  }
567 
568 
569  /* sum of databases sizes for one user */
570  function get_size_db_sum_user($u) {
571  return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_db WHERE db = '{$u}' OR db LIKE '{$u}\_%'");
572  }
573 
574 
575  /* count of databases from all users */
577  return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_db;");
578  }
579 
580 
581  /* count of databases for one user */
582  function get_size_db_count_user($u) {
583  return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_db WHERE db = '{$u}' OR db LIKE '{$u}\_%'");
584  }
585 
586 
587  /* get list of databases name and size for one user */
589  return $this->_get_size_and_record_sql("SELECT db,size FROM size_db WHERE db='{$u}' OR db LIKE '{$u}\_%';");
590  }
591 
592 
593  /* Return appropriate value and unit of a size given in Bytes (e.g. 1024 Bytes -> return 1 KB) */
594  function get_size_unit($size) {
595  $units = array(1073741824 => _("GB"), 1048576 => _("MB"), 1024 => _("KB"), 0 => _("B"));
596  foreach ($units as $value => $unit) {
597  if ($size >= $value) {
598  $size=$size/($value?$value:1);
599  return array('size' => $size, 'unit' => $unit);
600  }
601  }
602  }
603 
604  /**
605  * show a progress-bar
606  * color_type :
607  * 0 = No colo change
608  * 1 = Progress from green to red depending on percentage
609  * 2 = Progress from red to green depending on percentage
610  */
611  function quota_displaybar($usage, $color_type = 1) {
612  if ($color_type == 1) {
613  $csscolor = " background-color:" . PercentToColor($usage);
614  } elseif ($color_type == 2) {
615  $csscolor = " background-color:" . PercentToColor(100 - $usage);
616  } else {
617  $csscolor = "";
618  }
619 
620  echo '<div class="progress-bar">';
621  echo '<div class="barre" style="width:' . $usage . '%;' . $csscolor . '" ></div>';
622  echo '<div class="txt">' . $usage . '%</div>';
623  echo '</div>';
624  }
625 
626 
627  /* ==== Hook functions ==== */
628 
629 
630  /** Hook function call when a user is deleted
631  * AlternC's standard function called when a user is deleted
632  * globals $cuid is the appropriate user
633  */
635  $this->delquotas();
636  }
637 
638 
639  /** Hook function called when a user is created
640  * This function initialize the user's quotas.
641  * globals $cuid is the appropriate user
642  */
644  global $msg;
645  $msg->log("quota", "hook_admin_add_member");
646  $this->addquotas();
647  $this->getquota('', true); // actualise quota
648  }
649 
650 
651  /** Exports all the quota related information for an account.
652  * @access private
653  * EXPERIMENTAL function ;)
654  */
655  function alternc_export_conf() {
656  global $msg;
657  $msg->log("quota", "export");
658  $str = " <quota>";
659 
660  $q = $this->getquota();
661  foreach ($q as $k => $v) {
662  $str.=" <$k>\n";
663  $str.=" <used>" . ($v["u"]) . "</used>\n";
664  $str.=" <total>" . ($v["t"]) . "</total>\n";
665  $str.=" </$k>\n";
666  }
667  $str.="</quota>\n";
668  return $str;
669  }
670 
671 }
672 
673 /* Class m_quota */
674 
$qlist
$hooks
Definition: bootstrap.php:74
global $db
Definition: bootstrap.php:26
$mem
Definition: bootstrap.php:71
$msg
Definition: bootstrap.php:75
$c
Definition: bootstrap.php:47
$cuid
Definition: bootstrap.php:43
$r
Definition: aws_add.php:75
$res
Definition: index.php:111
variable_get($name, $default=null, $createit_comment=null)
Return a persistent variable.
Definition: variables.php:85
Class for hosting quotas management.
Definition: m_quota.php:34
addquotas()
Create default quotas entries for a new user.
Definition: m_quota.php:389
get_size_mailman_count_all()
Definition: m_quota.php:546
get_size_unit($size)
Definition: m_quota.php:594
m_quota()
Constructor.
Definition: m_quota.php:46
_get_sum_sql($sql)
Definition: m_quota.php:431
getdefaults()
Get the default quotas as an associative array.
Definition: m_quota.php:292
$disk_quota_enable
Definition: m_quota.php:37
get_size_db_count_user($u)
Definition: m_quota.php:582
get_size_web_sum_all()
Definition: m_quota.php:479
get_size_mailman_count_user($u)
Definition: m_quota.php:552
synchronise_user_profile()
Synchronise the quotas of the users with the quota of the user's profile.
Definition: m_quota.php:141
get_quota_user_cat($uid, $name)
Definition: m_quota.php:473
get_size_mail_details_domain($dom)
Definition: m_quota.php:522
get_size_db_sum_user($u)
Definition: m_quota.php:570
hook_admin_del_member()
Hook function call when a user is deleted AlternC's standard function called when a user is deleted g...
Definition: m_quota.php:634
addtype($type)
Add an account type for quotas.
Definition: m_quota.php:335
qlist()
List the quota-managed services in the server @Return array the quota names and description (translat...
Definition: m_quota.php:118
get_size_mailman_sum_all()
Definition: m_quota.php:528
$clquota
Definition: m_quota.php:40
get_size_mailman_sum_user($u)
Definition: m_quota.php:540
get_size_db_sum_all()
Definition: m_quota.php:564
create_missing_quota_profile()
Definition: m_quota.php:156
delquotas()
Erase all quota information about the user.
Definition: m_quota.php:280
display_val($type, $value)
Return a quota value with its unit (when it is a space quota) in MB, GB, TB ...
Definition: m_quota.php:418
get_size_mail_sum_all()
Definition: m_quota.php:491
listtype()
List types of quotas.
Definition: m_quota.php:359
_get_size_and_record_sql($sql)
Definition: m_quota.php:457
setdefaults($newq)
Set the default quotas.
Definition: m_quota.php:313
get_size_mailman_sum_domain($dom)
Definition: m_quota.php:534
hook_homepageblock()
Definition: m_quota.php:93
quota_displaybar($usage, $color_type=1)
show a progress-bar color_type : 0 = No colo change 1 = Progress from green to red depending on perce...
Definition: m_quota.php:611
cancreate($ressource="")
Check if a user can use a ressource.
Definition: m_quota.php:109
get_size_db_details_user($u)
Definition: m_quota.php:588
alternc_export_conf()
Exports all the quota related information for an account.
Definition: m_quota.php:655
dummy_for_translation()
Definition: m_quota.php:56
deltype($type)
Delete an account type for quotas.
Definition: m_quota.php:374
get_size_db_count_all()
Definition: m_quota.php:576
hook_menu()
Definition: m_quota.php:61
get_size_mail_sum_user($u)
Definition: m_quota.php:504
$disk_quota_not_blocking
Definition: m_quota.php:38
get_size_mail_count_all()
Definition: m_quota.php:510
setquota($ressource, $size)
Set the quota for a user (and for a ressource)
Definition: m_quota.php:249
get_size_mailman_details_user($u)
Definition: m_quota.php:558
get_size_mail_sum_domain($dom)
Definition: m_quota.php:497
hook_admin_add_member()
Hook function called when a user is created This function initialize the user's quotas.
Definition: m_quota.php:643
getquota($ressource="", $recheck=false)
Return a ressource usage (u) and total quota (t)
Definition: m_quota.php:174
_get_count_sql($sql)
Definition: m_quota.php:444
get_size_mail_count_domain($dom)
Definition: m_quota.php:516
get_size_web_sum_user($u)
Definition: m_quota.php:485
$value
format_size($size, $html=0)
Definition: functions.php:430
PercentToColor($p=0)
Definition: functions.php:1096
$uid
$q
Definition: menu_aws.php:32
if(empty($site_name)) elseif($piwik->site_add( $site_name, $site_urls))
foreach($domaines_user as $domaine) $t
$units
$val
Definition: tempovars.php:15
if(empty($_POST['key'])||empty($_POST['val'])) $key
Definition: tempovars.php:14
$dom
Definition: whois_test.php:10