checkQuota() now takes the user as an argument

This commit is contained in:
Uwe Steinmann 2014-05-20 06:31:12 +02:00
parent 1f5b44a654
commit 6e8af30e17
3 changed files with 18 additions and 9 deletions

View File

@ -404,15 +404,20 @@ function checkFormKey($formid='', $method='POST') { /* {{{ */
* @return boolean/integer true if no quota is set, number of bytes until * @return boolean/integer true if no quota is set, number of bytes until
* quota is reached. Negative values indicate a disk usage above quota. * quota is reached. Negative values indicate a disk usage above quota.
*/ */
function checkQuota() { /* {{{ */ function checkQuota($user) { /* {{{ */
global $settings, $dms, $user; global $settings, $dms;
/* check if quota is turn off system wide */
if($settings->_quota == 0)
return true;
$quota = 0; $quota = 0;
$uquota = $user->getQuota(); $uquota = $user->getQuota();
if($uquota > 0) if($uquota > 0)
$quota = $uquota; $quota = $uquota;
elseif($settings->_quota > 0) elseif($settings->_quota > 0) {
$quota = $settings->_quota; $quota = $settings->_quota;
}
if($quota == 0) if($quota == 0)
return true; return true;

View File

@ -38,9 +38,11 @@ if ($folder->getAccessMode($user) < M_READWRITE) {
UI::exitError(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName()))),getMLText("access_denied")); UI::exitError(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName()))),getMLText("access_denied"));
} }
$remain = checkQuota(); if($settings->_quota > 0) {
if ($remain < 0) { $remain = checkQuota($user);
UI::exitError(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName()))),getMLText("quota_exceeded", array('bytes'=>SeedDMS_Core_File::format_filesize(abs($remain))))); if ($remain < 0) {
UI::exitError(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName()))),getMLText("quota_exceeded", array('bytes'=>SeedDMS_Core_File::format_filesize(abs($remain)))));
}
} }
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); $tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));

View File

@ -38,9 +38,11 @@ if ($document->getAccessMode($user) < M_READWRITE) {
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("access_denied")); UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("access_denied"));
} }
$remain = checkQuota(); if($settings->_quota > 0) {
if ($remain < 0) { $remain = checkQuota($user);
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("quota_exceeded", array('bytes'=>SeedDMS_Core_File::format_filesize(abs($remain))))); if ($remain < 0) {
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("quota_exceeded", array('bytes'=>SeedDMS_Core_File::format_filesize(abs($remain)))));
}
} }
$folder = $document->getFolder(); $folder = $document->getFolder();