From 1c049f6bc60f290487e12dc2430f2a69d68cdde0 Mon Sep 17 00:00:00 2001
From: Remi
Date: Wed, 24 Feb 2016 14:49:33 +0100
Subject: [PATCH] bug fix: quota summary was inserted directly on main page
without calling the appropriate hook.
---
bureau/admin/main.php | 17 +++++++++++------
bureau/admin/quotas_oneuser.php | 2 +-
bureau/class/m_quota.php | 12 ++++++++++++
3 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/bureau/admin/main.php b/bureau/admin/main.php
index 9f1c9a4b..615d9c62 100644
--- a/bureau/admin/main.php
+++ b/bureau/admin/main.php
@@ -106,12 +106,17 @@ if($admin->enabled) {
echo "
";
} // if $admin->enabled
-$c = $admin->get($cuid);
-
-define("QUOTASONE","1");
-echo "
";
-require_once("quotas_oneuser.php");
-
+$blocks=$hooks->invoke("hook_homepageblock");
+uasort($blocks, function($a, $b) {return $a->order<$b->order ? -1 : 1;});
+foreach ($blocks as $v) {
+ if (property_exists($v, "call")) {
+ $func=$v->call;
+ $func();
+ }
+ if (property_exists($v, "include")) {
+ include $v->include;
+ }
+}
?>
diff --git a/bureau/admin/quotas_oneuser.php b/bureau/admin/quotas_oneuser.php
index e30cfa48..90876120 100644
--- a/bureau/admin/quotas_oneuser.php
+++ b/bureau/admin/quotas_oneuser.php
@@ -151,7 +151,7 @@ if (!isset($mode)) { # when included from adm_login, mode is not set
get_size_mailman_sum_user($c["uid"]);
+ $totallist = $quota->get_size_mailman_sum_user($mem->user["uid"]);
if ($totallist) {
// $totalweb is in KB, so we call get_size_unit() with it in Bytes
$t=$quota->get_size_unit($totallist * 1024);
diff --git a/bureau/class/m_quota.php b/bureau/class/m_quota.php
index 8554cf91..616bcca9 100644
--- a/bureau/class/m_quota.php
+++ b/bureau/class/m_quota.php
@@ -80,9 +80,21 @@ class m_quota {
$obj['links'][] = array('txt' => 'progressbar', 'total' => $q[$key]["t"], 'used' => $q[$key]["u"]);
}
+ // do not return menu item if there is no quota
+ if (!count($obj['links'])) return false;
return $obj;
}
+ function hook_homepageblock() {
+ return (object)Array(
+ 'pos' => 20,
+ 'call'=> function() {
+ define("QUOTASONE","1");
+ },
+ 'include' => "quotas_oneuser.php"
+ );
+ }
+
/* ----------------------------------------------------------------- */
/** Check if a user can use a ressource.