Skip to content

Commit

Permalink
bug fix: remove old references to unknown 'bw_web' quota values linki…
Browse files Browse the repository at this point in the history
…ng 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)
  • Loading branch information
innoticFR committed Jul 15, 2016
1 parent e32e883 commit 0c840f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 1 addition & 3 deletions bureau/admin/quota_show.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@
echo _($val);
if ($q[$key]["u"] >= $q[$key]["t"]) echo "</font>";

if ($key == 'bw_web') {
echo "&nbsp;</td><td>". format_size($q[$key]["u"]) ."&nbsp;</td><td>". format_size($q[$key]["t"]) ."&nbsp;</td>";
} elseif ($key == 'web') {
if (($key == 'web')||(isset($q[$key]['type'])&&($q[$key]['type']=='size'))) {
echo "&nbsp;</td><td>". format_size($q[$key]["u"] * 1024) . "&nbsp;</td><td>". format_size($q[$key]["t"] * 1024) ."&nbsp;</td>";
} else {
echo "&nbsp;</td><td>".$q[$key]["u"]."&nbsp;</td><td>".$q[$key]["t"]."&nbsp;</td>";
Expand Down
18 changes: 10 additions & 8 deletions bureau/class/m_quota.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,16 @@ function hook_menu() {

$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;
Expand Down

0 comments on commit 0c840f9

Please sign in to comment.