From 6a9b574e542cf990c30c9a41ea4e42475d1f6497 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 23 May 2011 13:22:01 +0200 Subject: [PATCH] Fixing hotpotatoes course quota bug see #3469 --- main/exercice/hotpotatoes.php | 8 +++----- main/inc/lib/document.lib.php | 16 +++++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/main/exercice/hotpotatoes.php b/main/exercice/hotpotatoes.php index 66be35ac26..a38e33e9b2 100755 --- a/main/exercice/hotpotatoes.php +++ b/main/exercice/hotpotatoes.php @@ -83,9 +83,7 @@ if ((api_is_allowed_to_edit(null, true)) && (($finish == 0) || ($finish == 2))) // This should be updated to "upload" here and on the button, and it would be better to // check something else than a string displayd on a button. if (strcmp($_POST['submit'], get_lang('Send')) === 0) { - - //@todo: this value should be moved to the platform admin section - $maxFilledSpace = 100000000; + $max_filled_space = DocumentManager::get_course_quota(); //initialise $finish if (!isset($finish)) { $finish = 0; } @@ -121,9 +119,9 @@ if ((api_is_allowed_to_edit(null, true)) && (($finish == 0) || ($finish == 2))) $filename = $_FILES['userFile']['name']; } - /*if (treat_uploaded_file($_FILES['userFile'], $document_sys_path, $uploadPath."/".$fld, $maxFilledSpace, $unzip))*/ + /*if (treat_uploaded_file($_FILES['userFile'], $document_sys_path, $uploadPath."/".$fld, $max_filled_space, $unzip))*/ $allow_output_on_success = false; - if (handle_uploaded_document($_course, $_FILES['userFile'], $document_sys_path, $uploadPath.'/'.$fld, api_get_user_id(), null, null, $maxFilledSpace, $unzip, '', $allow_output_on_success)) { + if (handle_uploaded_document($_course, $_FILES['userFile'], $document_sys_path, $uploadPath.'/'.$fld, api_get_user_id(), null, null, $max_filled_space, $unzip, '', $allow_output_on_success)) { if ($finish == 2) { $imgparams = $_POST['imgparams']; diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index f471e5ccc2..ed30ea878a 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -30,21 +30,23 @@ class DocumentManager { * @todo eliminate globals */ public static function get_course_quota() { - global $_course, $maxFilledSpace; + global $_course; if (empty($_course['sysCode'])) { return DEFAULT_DOCUMENT_QUOTA; } - $course_code = Database::escape_string($_course['sysCode']); + $course_code = Database::escape_string($_course['sysCode']); $course_table = Database::get_main_table(TABLE_MAIN_COURSE); - $sql_query = "SELECT ".DISK_QUOTA_FIELD." FROM $course_table WHERE code = '$course_code'"; - $sql_result = Database::query($sql_query); - $result = Database::fetch_array($sql_result); - $course_quota = $result[DISK_QUOTA_FIELD]; + $sql_query = "SELECT ".DISK_QUOTA_FIELD." FROM $course_table WHERE code = '$course_code'"; + $sql_result = Database::query($sql_query); + $course_quota = null; + if (Database::num_rows($sql_result)) { + $result = Database::fetch_array($sql_result); + $course_quota = $result[DISK_QUOTA_FIELD]; + } if (is_null($course_quota)) { // Course table entry for quota was null, then use default value $course_quota = DEFAULT_DOCUMENT_QUOTA; } - return $course_quota; }