Fixing hotpotatoes course quota bug see #3469

skala
Julio Montoya 14 years ago
parent 554b6a1942
commit 6a9b574e54
  1. 8
      main/exercice/hotpotatoes.php
  2. 16
      main/inc/lib/document.lib.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'];

@ -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;
}

Loading…
Cancel
Save