From a52393dc79fb7acbcbf14b5de75f6b45b83b16ce Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Mon, 20 Apr 2020 21:05:11 +0200 Subject: [PATCH] fixed issue when no quotas are found --- lam/lib/modules/quota.inc | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/lam/lib/modules/quota.inc b/lam/lib/modules/quota.inc index 8b63e55a..56cba488 100644 --- a/lam/lib/modules/quota.inc +++ b/lam/lib/modules/quota.inc @@ -666,41 +666,37 @@ class quota extends baseModule { if (empty($dirs)) { continue; } - for ($i = 0; $i < sizeof($dirs); $i++) { - if (strpos($dirs[$i], self::$QUOTA_PREFIX) !== 0) { - unset($dirs[$i]); - $i--; + $quotaDirs = array(); + foreach ($dirs as $dirString) { + if (strpos($dirString, self::$QUOTA_PREFIX) !== 0) { continue; } - $dirs[$i] = substr($dirs[$i], strlen(self::$QUOTA_PREFIX)); - $dirs[$i] = explode(",", $dirs[$i]); - $dirs[$i] = $dirs[$i][0]; + $dirData = explode(",", substr($dirString, strlen(self::$QUOTA_PREFIX))); + $quotaDirs[] = $dirData[0]; } - $dirs = array_values($dirs); - for ($i = 0; $i < sizeof($dirs); $i++) { - if (!empty($options["quota_softblock_" . $id . "_" . $dirs[$i]][0]) && !get_preg($options["quota_softblock_" . $id . "_" . $dirs[$i]][0], 'quotaNumber')) { + foreach ($quotaDirs as $dirName) { + if (!empty($options["quota_softblock_" . $id . "_" . $dirName][0]) && !get_preg($options["quota_softblock_" . $id . "_" . $dirName][0], 'quotaNumber')) { $return[] = $this->messages['softblock'][0]; } - if (!empty($options["quota_hardblock_" . $id . "_" . $dirs[$i]][0]) && !get_preg($options["quota_hardblock_" . $id . "_" . $dirs[$i]][0], 'quotaNumber')) { + if (!empty($options["quota_hardblock_" . $id . "_" . $dirName][0]) && !get_preg($options["quota_hardblock_" . $id . "_" . $dirName][0], 'quotaNumber')) { $return[] = $this->messages['hardblock'][0]; } - if (!empty($options["quota_softinode_" . $id . "_" . $dirs[$i]][0]) && !get_preg($options["quota_softinode_" . $id . "_" . $dirs[$i]][0], 'quotaNumber')) { + if (!empty($options["quota_softinode_" . $id . "_" . $dirName][0]) && !get_preg($options["quota_softinode_" . $id . "_" . $dirName][0], 'quotaNumber')) { $return[] = $this->messages['softinode'][0]; } - if (!empty($options["quota_hardinode_" . $id . "_" . $dirs[$i]][0]) && !get_preg($options["quota_hardinode_" . $id . "_" . $dirs[$i]][0], 'quotaNumber')) { + if (!empty($options["quota_hardinode_" . $id . "_" . $dirName][0]) && !get_preg($options["quota_hardinode_" . $id . "_" . $dirName][0], 'quotaNumber')) { $return[] = $this->messages['hardinode'][0]; } - if (!empty($options["quota_softblock_" . $id . "_" . $dirs[$i]][0]) - && !empty($options["quota_hardblock_" . $id . "_" . $dirs[$i]][0]) - && ($this->getQuotaNumber($options["quota_softblock_" . $id . "_" . $dirs[$i]][0]) > $this->getQuotaNumber($options["quota_hardblock_" . $id . "_" . $dirs[$i]][0]))) { + if (!empty($options["quota_softblock_" . $id . "_" . $dirName][0]) + && !empty($options["quota_hardblock_" . $id . "_" . $dirName][0]) + && ($this->getQuotaNumber($options["quota_softblock_" . $id . "_" . $dirName][0]) > $this->getQuotaNumber($options["quota_hardblock_" . $id . "_" . $dirName][0]))) { $return[] = $this->messages['block_cmp'][0]; } - if (!empty($options["quota_softinode_" . $id . "_" . $dirs[$i]][0]) - && !empty($options["quota_hardinode_" . $id . "_" . $dirs[$i]][0]) - && ($this->getQuotaNumber($options["quota_softinode_" . $id . "_" . $dirs[$i]][0]) > $this->getQuotaNumber($options["quota_hardinode_" . $id . "_" . $dirs[$i]][0]))) { + if (!empty($options["quota_softinode_" . $id . "_" . $dirName][0]) + && !empty($options["quota_hardinode_" . $id . "_" . $dirName][0]) + && ($this->getQuotaNumber($options["quota_softinode_" . $id . "_" . $dirName][0]) > $this->getQuotaNumber($options["quota_hardinode_" . $id . "_" . $dirName][0]))) { $return[] = $this->messages['inode_cmp'][0]; } - $i++; } } return $return;