diff --git a/bureau/admin/adm_defquotas.php b/bureau/admin/adm_defquotas.php index ad0ff2ca..cb5cacb1 100644 --- a/bureau/admin/adm_defquotas.php +++ b/bureau/admin/adm_defquotas.php @@ -35,6 +35,10 @@ if (!$admin->enabled) { __("This page is restricted to authorized staff"); exit(); } +$fields = array ( + "synchronise" => array ("get", "integer", "0"), +); +getFields($fields); include_once ("head.php"); @@ -43,10 +47,14 @@ include_once ("head.php");

$error

"; - } +if ($synchronise==true) { + $quota->synchronise_user_profile(); + echo "

";__("User's quotas synchronised");echo "

"; +} +if (isset($error) && $error) { + echo "

$error

"; +} ?>

@@ -78,6 +86,7 @@ foreach($quota->listtype() as $type) {

+
diff --git a/bureau/class/m_quota.php b/bureau/class/m_quota.php index b01599a3..53f2da2a 100644 --- a/bureau/class/m_quota.php +++ b/bureau/class/m_quota.php @@ -83,6 +83,22 @@ class m_quota { return $qlist; } + + /** + * Synchronise the quotas of the users with the quota of the + * user's profile. + * If the user have a greater quota than the profile, no change. + * If the quota entry doesn't exist for the user, create it with + * the defaults value. + */ + function synchronise_user_profile() { + global $db,$err; + $err->log("quota","apply_greater_quota"); + $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);"; + $db->query($q); + return true; + } + /* ----------------------------------------------------------------- */ /** Return a ressource usage (u) and total quota (t) * @param string $ressource ressource to get quota of