diff --git a/bureau/admin/adm_defquotas.php b/bureau/admin/adm_defquotas.php index 8d2733a5..a8f3c728 100644 --- a/bureau/admin/adm_defquotas.php +++ b/bureau/admin/adm_defquotas.php @@ -52,6 +52,8 @@ if ($synchronise==true) { echo "
";__("User's quotas synchronised");echo "
"; } +$quota->create_missing_quota_profile(); + if (isset($error) && $error) { echo "$error
"; } diff --git a/bureau/class/m_quota.php b/bureau/class/m_quota.php index 2d63a396..1693cf89 100644 --- a/bureau/class/m_quota.php +++ b/bureau/class/m_quota.php @@ -93,12 +93,30 @@ class m_quota { */ function synchronise_user_profile() { global $db,$err; - $err->log("quota","apply_greater_quota"); + $err->log("quota","synchronise_user_profile"); $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);"; if (!$db->query($q)) return false; return true; } + /* + * Create default quota in the profile + * when a new quota appear + * + */ + function create_missing_quota_profile() { + global $db,$quota,$err; + $err->log("quota","create_missing_quota_profile"); + $qt=$quota->getquota('',true); + $type=$quota->listtype(); + foreach($type as $t) { + foreach($qt as $q=>$vv) { + $db->query("INSERT IGNORE defquotas (value,quota,type) VALUES (0,'$q','$t');"); + } + } + return true; + } + /* ----------------------------------------------------------------- */ /** Return a ressource usage (u) and total quota (t) * @param string $ressource ressource to get quota of