Automaticaly create entry for new quota (auto-detect their name in the class) in

all the existing quota profil
This commit is contained in:
Alan Garcia 2012-10-16 15:12:54 +00:00
parent 9d61c62740
commit fa51d51a81
2 changed files with 21 additions and 1 deletions

View File

@ -52,6 +52,8 @@ if ($synchronise==true) {
echo "<p class=\"error\">";__("User's quotas synchronised");echo "</p>";
}
$quota->create_missing_quota_profile();
if (isset($error) && $error) {
echo "<p class=\"error\">$error</p>";
}

View File

@ -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