From 0c840f9f2e63375c44bd2cdd6fc217e091fb24ad Mon Sep 17 00:00:00 2001 From: Remi Date: Fri, 15 Jul 2016 18:40:29 +0200 Subject: [PATCH] bug fix: remove old references to unknown 'bw_web' quota values linking to not existing stats_show_per_month.php page and menu gadget (anyone aiming to display custom menu gadget or size based quota could return in_menu=1 and type=size array values in hook_quota_get() function) --- bureau/admin/quota_show.php | 4 +--- bureau/class/m_quota.php | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bureau/admin/quota_show.php b/bureau/admin/quota_show.php index 2e046392..d58b55bc 100644 --- a/bureau/admin/quota_show.php +++ b/bureau/admin/quota_show.php @@ -54,9 +54,7 @@ reset($qlist); echo _($val); if ($q[$key]["u"] >= $q[$key]["t"]) echo ""; - if ($key == 'bw_web') { - echo " ". format_size($q[$key]["u"]) ." ". format_size($q[$key]["t"]) ." "; - } elseif ($key == 'web') { + if (($key == 'web')||(isset($q[$key]['type'])&&($q[$key]['type']=='size'))) { echo " ". format_size($q[$key]["u"] * 1024) . " ". format_size($q[$key]["t"] * 1024) ." "; } else { echo " ".$q[$key]["u"]." ".$q[$key]["t"]." "; diff --git a/bureau/class/m_quota.php b/bureau/class/m_quota.php index d088ba2f..5bff8225 100644 --- a/bureau/class/m_quota.php +++ b/bureau/class/m_quota.php @@ -71,14 +71,16 @@ class m_quota { $q = $this->getquota(); - foreach (array('web', 'bw_web') as $key) { - if (!isset($q[$key]["u"]) || empty($q[$key]["t"])) { - continue; - } - $usage_percent = (int) ($q[$key]["u"] / $q[$key]["t"] * 100); - $obj['links'][] = array('txt' => _("quota_" . $key) . " " . sprintf(_("%s%% of %s"), $usage_percent, format_size($q[$key]["t"] * 1024)), 'url' => ($key == 'bw_web' ? 'stats_show_per_month.php' : 'quota_show.php')); - $obj['links'][] = array('txt' => 'progressbar', 'total' => $q[$key]["t"], 'used' => $q[$key]["u"]); - } + foreach ($q as $key=>$value) + if (($key=="web")||(isset($value['in_menu'])&&$value['in_menu'])) { + if (!isset($q[$key]["u"]) || empty($q[$key]["t"])) { + continue; + } + + $usage_percent = (int) ($q[$key]["u"] / $q[$key]["t"] * 100); + $obj['links'][] = array('txt' => _("quota_" . $key) . " " . sprintf(_("%s%% of %s"), $usage_percent, format_size($q[$key]["t"] * 1024)), 'url' => 'quota_show.php'); + $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;