Minor - format code, fixing PHP warnings.

1.9.x
Julio Montoya 12 years ago
parent 6841a5d962
commit c006ab8842
  1. 2
      main/document/document_slideshow.inc.php
  2. 6
      main/document/show_content.php
  3. 1
      main/document/upload.php
  4. 4
      main/inc/ajax/document.ajax.php
  5. 4
      main/inc/lib/document.lib.php
  6. 21
      main/inc/lib/fileUpload.lib.php

@ -36,7 +36,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'exit_slideshow') {
// We check if there are images in this folder by searching the extensions for .jpg, .gif, .png
// grabbing the list of all the documents of this folder
//$all_files = $fileList['name'];
$array_to_search = is_array($docs_and_folders) ? $docs_and_folders : array();
$array_to_search = !empty($docs_and_folders) && is_array($docs_and_folders) ? $docs_and_folders : array();
if (count($array_to_search) > 0) {
while (list($key) = each($array_to_search)) {

@ -17,7 +17,7 @@ require_once '../inc/global.inc.php';
api_protect_course_script();
$noPHP_SELF = true;
$header_file = Security::remove_XSS($_GET['file']);
$header_file = isset($_GET['file']) ? Security::remove_XSS($_GET['file']) : null;
$document_id = intval($_GET['id']);
$course_info = api_get_course_info();
@ -28,7 +28,7 @@ if (empty($course_info)) {
api_not_allowed(true);
}
//Generate path
// Generate path
if (!$document_id) {
$document_id = DocumentManager::get_document_id($course_info, $header_file);
}
@ -92,9 +92,7 @@ header('Last-Modified: Wed, 01 Jan 2100 00:00:00 GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
$browser_display_title = 'Documents - '.Security::remove_XSS($_GET['cidReq']).' - '.$file;
$file_url_web = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$header_file.'?'.api_get_cidreq();
$pathinfo = pathinfo($header_file);
if ($pathinfo['extension']=='wav' && preg_match('/_chnano_.wav/i', $file_url_web) && api_get_setting('enable_nanogong') == 'true'){

@ -161,6 +161,7 @@ if ($is_certificate_array[0] == 'certificates') {
}
// Title of the tool
$add_group_to_title = null;
if ($to_group_id != 0) { // Add group name after for group documents
$add_group_to_title = ' ('.$group_properties['name'].')';
}

@ -24,6 +24,8 @@ switch($action) {
exit;
}
$ifExists = isset($_POST['if_exists']) ? $_POST['if_exists'] : null;
if (!empty($_FILES)) {
require_once api_get_path(LIBRARY_PATH).'fileDisplay.lib.php';
$file = $_FILES['file'];
@ -33,7 +35,7 @@ switch($action) {
$file['name'],
null,
0,
$_POST['if_exists'],
$ifExists,
false,
false
);

@ -2483,7 +2483,7 @@ class DocumentManager
* @param string $title
* @param string $comment
* @param int $unzip unzip or not the file
* @param int $if_exists if_exists overwrite, rename or warn if exists (default)
* @param string $if_exists overwrite, rename or warn (default)
* @param bool $index_document index document (search xapian module)
* @param bool $show_output print html messages
* @return array|bool
@ -2533,7 +2533,7 @@ class DocumentManager
if (!empty($title)) {
$params['title'] = get_document_title($title);
} else {
if (isset($if_exists) && $if_exists == 'rename') {
if ($if_exists == 'rename') {
$new_path = basename($new_path);
$params['title'] = get_document_title($new_path);
} else {

@ -264,13 +264,13 @@ function handle_uploaded_document(
$file_size = $uploaded_file['size'];
$files_perm = api_get_permissions_for_new_files();
$doc_path = '/'.$clean_name;
$docId = DocumentManager :: get_document_id($_course, $doc_path, $current_session_id);
// What to do if the target file exists
$doc_path = '/'.$clean_name;
$docId = DocumentManager :: get_document_id($_course, $doc_path, $current_session_id);
// What to do if the target file exists
switch ($what_if_file_exists) {
// Overwrite the file if it exists
case 'overwrite':
// Check if the target file exists, so we can give another message
// Check if the target file exists, so we can give another message
$file_exists = file_exists($store_path);
if (moveUploadedFile($uploaded_file, $store_path)) {
chmod($store_path, $files_perm);
@ -335,11 +335,11 @@ function handle_uploaded_document(
// Rename the file if it exists
case 'rename':
if ($docId) {
$new_name = unique_name($where_to_save, $clean_name);
} else {
$new_name = $clean_name;
}
if ($docId) {
$new_name = unique_name($where_to_save, $clean_name);
} else {
$new_name = $clean_name;
}
$store_path = $where_to_save.$new_name;
$new_file_path = $upload_path.$new_name;
@ -390,6 +390,7 @@ function handle_uploaded_document(
// Redo visibility
api_set_default_visibility(TOOL_DOCUMENT, $document_id);
}
// If the file is in a folder, we need to update all parent folders
item_property_update_on_folder($_course,$upload_path,$user_id);
@ -399,7 +400,7 @@ function handle_uploaded_document(
}
return $file_path;
} else {
if ($output){
if ($output) {
Display::display_error_message(get_lang('UplUnableToSaveFile'));
}
return false;

Loading…
Cancel
Save