Minor - format code

1.9.x
Julio Montoya 12 years ago
parent 5f4c961ce2
commit 70c2f2dc3a
  1. 6
      main/inc/lib/document.lib.php
  2. 58
      main/inc/lib/fileUpload.lib.php

@ -521,6 +521,7 @@ class DocumentManager {
if ($result !== false && Database::num_rows($result) != 0) {
while ($row = Database::fetch_array($result, 'ASSOC')) {
if (api_is_coach()) {
//Looking for course items that are invisible to hide it in the session
if (in_array($row['id'], array_keys($doc_list))) {
@ -553,7 +554,8 @@ class DocumentManager {
$document_data[$row['id']] = $row;
}
//Only for the student we filter the results see BT#1652
// Only for the student we filter the results see BT#1652
if (!api_is_coach() && !$is_allowed_to_edit) {
$ids_to_remove = array();
$my_repeat_ids = $temp = array();
@ -579,7 +581,6 @@ class DocumentManager {
}
}
}
foreach ($doc_list as $key => $row) {
if (in_array($row['visibility'], array('0', '2')) && !in_array($row['id'], $my_repeat_ids)) {
$ids_to_remove[] = $row['id'];
@ -2249,6 +2250,7 @@ class DocumentManager {
if (isset($files['file'])) {
$upload_ok = process_uploaded_file($files['file'], $show_output);
if ($upload_ok) {
// File got on the server without problems, now process it
$new_path = handle_uploaded_document($course_info, $files['file'], $base_work_dir, $path, api_get_user_id(), api_get_group_id(), null, $unzip, $if_exists, $show_output);

@ -89,34 +89,36 @@ function get_document_title($name) {
*/
function process_uploaded_file($uploaded_file, $show_output = true) {
// Checking the error code sent with the file upload.
switch ($uploaded_file['error']) {
case 1:
// The uploaded file exceeds the upload_max_filesize directive in php.ini.
if ($show_output)
Display::display_error_message(get_lang('UplExceedMaxServerUpload').ini_get('upload_max_filesize'));
return false;
case 2:
// The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
// Not used at the moment, but could be handy if we want to limit the size of an upload (e.g. image upload in html editor).
$max_file_size = intval($_POST['MAX_FILE_SIZE']);
if ($show_output) {
Display::display_error_message(get_lang('UplExceedMaxPostSize'). format_file_size($max_file_size));
}
return false;
case 3:
// The uploaded file was only partially uploaded.
if ($show_output) {
Display::display_error_message(get_lang('UplPartialUpload').' '.get_lang('PleaseTryAgain'));
}
return false;
case 4:
// No file was uploaded.
if ($show_output) {
Display::display_error_message(get_lang('UplNoFileUploaded').' '. get_lang('UplSelectFileFirst'));
}
return false;
}
if (isset($uploaded_file['error'])) {
switch ($uploaded_file['error']) {
case 1:
// The uploaded file exceeds the upload_max_filesize directive in php.ini.
if ($show_output) {
Display::display_error_message(get_lang('UplExceedMaxServerUpload').ini_get('upload_max_filesize'));
}
return false;
case 2:
// The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
// Not used at the moment, but could be handy if we want to limit the size of an upload (e.g. image upload in html editor).
$max_file_size = intval($_POST['MAX_FILE_SIZE']);
if ($show_output) {
Display::display_error_message(get_lang('UplExceedMaxPostSize'). format_file_size($max_file_size));
}
return false;
case 3:
// The uploaded file was only partially uploaded.
if ($show_output) {
Display::display_error_message(get_lang('UplPartialUpload').' '.get_lang('PleaseTryAgain'));
}
return false;
case 4:
// No file was uploaded.
if ($show_output) {
Display::display_error_message(get_lang('UplNoFileUploaded').' '. get_lang('UplSelectFileFirst'));
}
return false;
}
}
if (!file_exists($uploaded_file['tmp_name'])) {
// No file was uploaded.

Loading…
Cancel
Save