/** This function changes the name of a certain file. It needs no global variables, it takes all info from parameters. It returns nothing. @todo check if this function is used */ function change_name($base_work_dir, $source_file, $rename_to, $dir, $doc) { $file_name_for_change = $base_work_dir . $dir . $source_file; //api_display_debug_info("call FileManager::my_rename: params $file_name_for_change, $rename_to"); $rename_to = FileManager::disable_dangerous_file($rename_to); // Avoid renaming to .htaccess file $rename_to = FileManager::my_rename($file_name_for_change, stripslashes($rename_to)); // fileManage API if ($rename_to) { if (isset($dir) && $dir != '') { $source_file = $dir . $source_file; $new_full_file_name = dirname($source_file) . '/' . $rename_to; } else { $source_file = '/' . $source_file; $new_full_file_name = '/' . $rename_to; } FileManager::update_db_info('update', $source_file, $new_full_file_name); // fileManage API $name_changed = get_lang('ElRen'); $info_message = get_lang('fileModified'); $GLOBALS['file_name'] = $rename_to; $GLOBALS['doc'] = $rename_to; return $info_message; } else { $dialogBox = get_lang('FileExists'); // TODO: This variable is not used. /* Return to step 1 */ $rename = $source_file; unset($source_file); } }
api_not_allowed(); } } $document_to_move = DocumentManager::get_document_data_by_id($_POST['move_file'], api_get_course_id()); // Security fix: make sure they can't move files that are not in the document table if (!empty($document_to_move)) { $real_path_target = $base_work_dir . $_POST['move_to'] . '/' . basename($document_to_move['path']); $fileExist = false; if (file_exists($real_path_target)) { $fileExist = true; } if (FileManager::move($base_work_dir . $document_to_move['path'], $base_work_dir . $_POST['move_to'])) { //if (1) { //$contents = DocumentManager::replace_urls_inside_content_html_when_moving_file(basename($document_to_move['path']), $base_work_dir.dirname($document_to_move['path']), $base_work_dir.$_POST['move_to']); //exit; FileManager::update_db_info('update', $document_to_move['path'], $_POST['move_to'] . '/' . basename($document_to_move['path'])); //update database item property $doc_id = $_POST['move_file']; if (is_dir($real_path_target)) { api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderMoved', api_get_user_id(), $to_group_id, null, null, null, $session_id); Display::display_confirmation_message(get_lang('DirMv')); } elseif (is_file($real_path_target)) { api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentMoved', api_get_user_id(), $to_group_id, null, null, null, $session_id); Display::display_confirmation_message(get_lang('DocMv')); } // Set the current path $curdirpath = $_POST['move_to']; $curdirpathurl = urlencode($_POST['move_to']); } else { if ($fileExist) { if (is_dir($real_path_target)) {
Security::clear_token(); } if (!empty($hpchoice)) { switch ($hpchoice) { case 'delete': // deletes an exercise $imgparams = array(); $imgcount = 0; GetImgParams($file, $documentPath, $imgparams, $imgcount); $fld = GetFolderName($file); for ($i = 0; $i < $imgcount; $i++) { FileManager::my_delete($documentPath . $uploadPath . "/" . $fld . "/" . $imgparams[$i]); FileManager::update_db_info("delete", $uploadPath . "/" . $fld . "/" . $imgparams[$i]); } if (FileManager::my_delete($documentPath . $file)) { FileManager::update_db_info("delete", $file); } // hotpotatoes folder may contains several tests so don't delete folder if not empty : #2165 if (!(strstr($uploadPath, DIR_HOTPOTATOES) && !FileManager::folder_is_empty($documentPath . $uploadPath . "/" . $fld . "/"))) { FileManager::my_delete($documentPath . $uploadPath . "/" . $fld . "/"); } break; case 'enable': // enables an exercise $newVisibilityStatus = "1"; //"visible" $query = "SELECT id FROM {$TBL_DOCUMENT} WHERE c_id = {$course_id} AND path='" . Database::escape_string($file) . "'"; $res = Database::query($query); $row = Database::fetch_array($res, 'ASSOC'); api_item_property_update($_course, TOOL_DOCUMENT, $row['id'], 'visible', $_user['user_id']); break;
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderCreated', api_get_user_id()); } else { // It is not the first step... get the filename directly from the system params. $filename = $_FILES['userFile']['name']; } $allow_output_on_success = false; if (FileManager::handle_uploaded_document($_course, $_FILES['userFile'], $document_sys_path, $uploadPath . '/' . $fld, api_get_user_id(), null, null, $unzip, '', $allow_output_on_success)) { if ($finish == 2) { $imgparams = $_POST['imgparams']; $checked = CheckImageName($imgparams, $filename); if ($checked) { $imgcount = $imgcount - 1; } else { $dialogBox .= $filename . ' ' . get_lang('NameNotEqual'); FileManager::my_delete($document_sys_path . $uploadPath . '/' . $fld . '/' . $filename); FileManager::update_db_info('delete', $uploadPath . '/' . $fld . '/' . $filename); } if ($imgcount == 0) { // all image uploaded $finish = 1; } } else { // If we are (still) on the first step of the upload process. if ($finish == 0) { $finish = 2; // Get number and name of images from the files contents. GetImgParams('/' . $filename, $document_sys_path . $uploadPath . '/' . $fld, $imgparams, $imgcount); if ($imgcount == 0) { $finish = 1; } else { $dialogBox .= get_lang('DownloadEnd');