From ed4321b2cb30c9ce9bb23f0766e7c8ca1de74c34 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Wed, 26 Apr 2017 13:42:30 +0200 Subject: [PATCH] Minor - format code --- index.php | 4 +- main/admin/sub_language.php | 432 +++++++++++----------- main/document/edit_document.php | 506 +++++++++++++------------- main/inc/lib/myspace.lib.php | 34 +- main/mySpace/current_courses.php | 423 +++++++++++----------- main/user/subscribe_user.php | 595 ++++++++++++++++--------------- 6 files changed, 1000 insertions(+), 994 deletions(-) diff --git a/index.php b/index.php index 7a1716d825..967e0d16f3 100755 --- a/index.php +++ b/index.php @@ -76,7 +76,7 @@ if (!api_get_user_id() && CustomPages::enabled()) { if (!empty($_POST['submitAuth'])) { // The user has been already authenticated, we are now to find the last login of the user. - if (isset ($_user['user_id'])) { + if (isset($_user['user_id'])) { $track_login_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); $sql = "SELECT UNIX_TIMESTAMP(login_date) FROM $track_login_table @@ -122,7 +122,7 @@ $useCookieValidation = api_get_setting('cookie_warning'); if ($useCookieValidation === 'true') { if (isset($_POST['acceptCookies'])) { api_set_site_use_cookie_warning_cookie(); - } else if (!api_site_use_cookie_warning_cookie_exist()) { + } elseif (!api_site_use_cookie_warning_cookie_exist()) { if (Template::isToolBarDisplayedForUser()) { $controller->tpl->assign('toolBarDisplayed', true); } else { diff --git a/main/admin/sub_language.php b/main/admin/sub_language.php index a80c6ae544..f6954016d4 100755 --- a/main/admin/sub_language.php +++ b/main/admin/sub_language.php @@ -13,47 +13,48 @@ $this_section = SECTION_PLATFORM_ADMIN; api_protect_admin_script(); $htmlHeadXtra[] =''; + /** * Main code */ @@ -65,31 +66,31 @@ $interbreadcrumb[] = array ('url' => 'languages.php', 'name' => get_lang('Platfo $sublanguage_folder_error = false; -if (isset($_GET['id']) && $_GET['id']==strval(intval($_GET['id']))) { - $language_name = SubLanguageManager::get_name_of_language_by_id ($_GET['id']); - $sub_language_name = SubLanguageManager::get_name_of_language_by_id ($_GET['sub_language_id']); - $all_data_of_language = SubLanguageManager::get_all_information_of_language($_GET['id']); - $all_data_of_sublanguage = SubLanguageManager::get_all_information_of_language($_GET['sub_language_id']); - $sub_language_file = api_get_path(SYS_LANG_PATH).$all_data_of_sublanguage['dokeos_folder']; +if (isset($_GET['id']) && $_GET['id'] == strval(intval($_GET['id']))) { + $language_name = SubLanguageManager::get_name_of_language_by_id ($_GET['id']); + $sub_language_name = SubLanguageManager::get_name_of_language_by_id ($_GET['sub_language_id']); + $all_data_of_language = SubLanguageManager::get_all_information_of_language($_GET['id']); + $all_data_of_sublanguage = SubLanguageManager::get_all_information_of_language($_GET['sub_language_id']); + $sub_language_file = api_get_path(SYS_LANG_PATH).$all_data_of_sublanguage['dokeos_folder']; - if (!file_exists($sub_language_file) || !is_writable($sub_language_file)) { - $sublanguage_folder_error = $sub_language_file.' '.get_lang('IsNotWritable'); - } - if (SubLanguageManager::check_if_exist_language_by_id($_GET['id'])===true) { - $language_id_exist = true; - } else { - $language_id_exist = false; - } + if (!file_exists($sub_language_file) || !is_writable($sub_language_file)) { + $sublanguage_folder_error = $sub_language_file.' '.get_lang('IsNotWritable'); + } + if (SubLanguageManager::check_if_exist_language_by_id($_GET['id'])===true) { + $language_id_exist = true; + } else { + $language_id_exist = false; + } } else { - $language_name=''; - $language_id_exist=false; + $language_name=''; + $language_id_exist=false; } $intro = sprintf(get_lang('RegisterTermsOfSubLanguageForX'), strtolower($sub_language_name)); $path_folder = api_get_path(SYS_LANG_PATH).$all_data_of_language['dokeos_folder']; if (!is_dir($path_folder) || strlen($all_data_of_language['dokeos_folder'])==0) { - api_not_allowed(true); + api_not_allowed(true); } Display :: display_header($language_name); @@ -114,7 +115,7 @@ $html.=''; echo $html; echo '


'; if (!empty($sublanguage_folder_error)) { - Display::display_warning_message($sublanguage_folder_error); + Display::display_warning_message($sublanguage_folder_error); } echo '
 
'; @@ -128,195 +129,196 @@ echo '
 
'; * @return array */ function search_language_term( - $term, - $search_in_variable = true, - $search_in_english = true, - $search_in_parent = true, - $search_in_sub_language = true + $term, + $search_in_variable = true, + $search_in_english = true, + $search_in_parent = true, + $search_in_sub_language = true ) { - //These the $_REQUEST['id'] and the $_REQUEST['sub_language_id'] variables are process in global.inc.php (LOAD LANGUAGE FILES SECTION) - /* - These 4 arrays are set in global.inc.php with the condition that will be load from sub_language.php or sub_language_ajax.inc.php - $english_language_array - $parent_language_array - $sub_language_array - $language_files_to_load - */ - global $language_files_to_load, $sub_language_array, $english_language_array, $parent_language_array; - $language_files_to_load_keys = array_flip($language_files_to_load); - $array_to_search = $parent_language_array; - $list_info = array(); - $term='/'.Security::remove_XSS(trim($_REQUEST['txt_search_word'])).'/i'; - //@todo optimize this foreach - foreach ($language_files_to_load as $lang_file) { - //searching in parent language of the sub language - if ($search_in_parent) { - $variables = $parent_language_array[$lang_file]; - foreach ($variables as $parent_name_variable =>$parent_variable_value) { - //arrays are avoided - if (is_array($parent_variable_value)) { - continue; - } - $founded = false; - // searching the item in the parent tool - if (preg_match($term,$parent_variable_value)!==0) { - $founded = true; - } - if ($founded) { - //loading variable from the english array - $sub_language_name_variable = $sub_language_array[$lang_file][$parent_name_variable]; - //loading variable from the english array - $english_name_variable = $english_language_array[$lang_file][$parent_name_variable]; + //These the $_REQUEST['id'] and the $_REQUEST['sub_language_id'] variables are process in global.inc.php (LOAD LANGUAGE FILES SECTION) + /* + These 4 arrays are set in global.inc.php with the condition that will be load from sub_language.php or sub_language_ajax.inc.php + $english_language_array + $parent_language_array + $sub_language_array + $language_files_to_load + */ + global $language_files_to_load, $sub_language_array, $english_language_array, $parent_language_array; + $language_files_to_load_keys = array_flip($language_files_to_load); + $array_to_search = $parent_language_array; + $list_info = array(); + $term='/'.Security::remove_XSS(trim($_REQUEST['txt_search_word'])).'/i'; + //@todo optimize this foreach + foreach ($language_files_to_load as $lang_file) { + //searching in parent language of the sub language + if ($search_in_parent) { + $variables = $parent_language_array[$lang_file]; + foreach ($variables as $parent_name_variable => $parent_variable_value) { + //arrays are avoided + if (is_array($parent_variable_value)) { + continue; + } + $founded = false; + // searching the item in the parent tool + if (preg_match($term, $parent_variable_value) !== 0) { + $founded = true; + } + if ($founded) { + //loading variable from the english array + $sub_language_name_variable = $sub_language_array[$lang_file][$parent_name_variable]; + //loading variable from the english array + $english_name_variable = $english_language_array[$lang_file][$parent_name_variable]; - //config buttons - /*if (strlen($english_name_variable)>1500) { - $size =20; - } else { - $size =4; - }*/ + //config buttons + /*if (strlen($english_name_variable)>1500) { + $size =20; + } else { + $size =4; + }*/ - $obj_text=''; - $obj_button=''; + $obj_text=''; + $obj_button=''; - $list_info[] = array( - $lang_file . '.inc.php', - $parent_name_variable, - $english_name_variable, - $parent_variable_value, - $obj_text, - $obj_button - ); - } - } - } + $list_info[] = array( + $lang_file . '.inc.php', + $parent_name_variable, + $english_name_variable, + $parent_variable_value, + $obj_text, + $obj_button + ); + } + } + } - //search in english - if ($search_in_english || $search_in_variable) { - $variables = $english_language_array[$lang_file]; - foreach ($variables as $name_variable =>$variable_value) { - if (is_array($variable_value)) { - continue; - } + //search in english + if ($search_in_english || $search_in_variable) { + $variables = $english_language_array[$lang_file]; + foreach ($variables as $name_variable => $variable_value) { + if (is_array($variable_value)) { + continue; + } - if (is_array($variable_value)) - echo $lang_file; - $founded = false; - if ($search_in_english && $search_in_variable) { - // searching the item in the parent tool - if (preg_match($term,$variable_value)!==0 || preg_match($term,$name_variable)!==0 ) { - $founded = true; - } - } else { - if ($search_in_english) { - if (preg_match($term,$variable_value)!==0) { - $founded = true; - } - } else { - if (preg_match($term,$name_variable)!==0) { - $founded = true; - } - } - } + if (is_array($variable_value)) { + echo $lang_file; + } + $founded = false; + if ($search_in_english && $search_in_variable) { + // searching the item in the parent tool + if (preg_match($term, $variable_value) !== 0 || preg_match($term, $name_variable) !== 0) { + $founded = true; + } + } else { + if ($search_in_english) { + if (preg_match($term, $variable_value) !== 0) { + $founded = true; + } + } else { + if (preg_match($term, $name_variable) !== 0) { + $founded = true; + } + } + } - if ($founded) { - //loading variable from the english array - $sub_language_name_variable = null; - if (isset($sub_language_array[$lang_file][$name_variable])) { - $sub_language_name_variable = $sub_language_array[$lang_file][$name_variable]; - } - $parent_variable_value = null; - if (isset($parent_language_array[$lang_file][$name_variable])) { - $parent_variable_value = $parent_language_array[$lang_file][$name_variable]; - } - //config buttons - $obj_text=''; - $obj_button=''; + if ($founded) { + //loading variable from the english array + $sub_language_name_variable = null; + if (isset($sub_language_array[$lang_file][$name_variable])) { + $sub_language_name_variable = $sub_language_array[$lang_file][$name_variable]; + } + $parent_variable_value = null; + if (isset($parent_language_array[$lang_file][$name_variable])) { + $parent_variable_value = $parent_language_array[$lang_file][$name_variable]; + } + //config buttons + $obj_text=''; + $obj_button=''; - //loading variable from the english array - $english_name_variable = $english_language_array[$lang_file][$name_variable]; + //loading variable from the english array + $english_name_variable = $english_language_array[$lang_file][$name_variable]; - $list_info[] = array( - $lang_file . '.inc.php', - $name_variable, - $english_name_variable, - $parent_variable_value, - $obj_text, - $obj_button - ); - } - } - } + $list_info[] = array( + $lang_file . '.inc.php', + $name_variable, + $english_name_variable, + $parent_variable_value, + $obj_text, + $obj_button + ); + } + } + } - // Search in sub language - if ($search_in_sub_language) { - $variables = $sub_language_array[$lang_file]; - foreach ($variables as $name_variable =>$variable_value) { - if (is_array($parent_variable_value)) { - continue; - } + // Search in sub language + if ($search_in_sub_language) { + $variables = $sub_language_array[$lang_file]; + foreach ($variables as $name_variable => $variable_value) { + if (is_array($parent_variable_value)) { + continue; + } - if (is_array($variable_value)) { - continue; - } + if (is_array($variable_value)) { + continue; + } - $founded = false; - // searching the item in the parent tool - if (preg_match($term,$variable_value)!==0) { - $founded = true; - } - if ($founded) { - //loading variable from the english array - $sub_language_name_variable = $sub_language_array[$lang_file][$name_variable]; - $parent_variable_value = $parent_language_array[$lang_file][$name_variable]; - //config buttons - $obj_text=''; - $obj_button=''; + $founded = false; + // searching the item in the parent tool + if (preg_match($term, $variable_value) !== 0) { + $founded = true; + } + if ($founded) { + //loading variable from the english array + $sub_language_name_variable = $sub_language_array[$lang_file][$name_variable]; + $parent_variable_value = $parent_language_array[$lang_file][$name_variable]; + //config buttons + $obj_text=''; + $obj_button=''; - //loading variable from the english array - $english_name_variable = $english_language_array[$lang_file][$name_variable]; - $list_info[]=array($lang_file.'.inc.php', - $name_variable, - $english_name_variable, - $parent_variable_value,$obj_text,$obj_button); - } - } - } - } + //loading variable from the english array + $english_name_variable = $english_language_array[$lang_file][$name_variable]; + $list_info[]=array($lang_file.'.inc.php', + $name_variable, + $english_name_variable, + $parent_variable_value,$obj_text,$obj_button); + } + } + } + } - $list_info = array_unique_dimensional($list_info); - return $list_info; + $list_info = array_unique_dimensional($list_info); + return $list_info; } // Allow see data in sort table $list_info = array(); if (isset($_REQUEST['txt_search_word'])) { - //@todo fix to accept a char with 1 char - if (strlen(trim($_REQUEST['txt_search_word']))>2) { - $list_info = search_language_term( - $_REQUEST['txt_search_word'], - true, - true, - true, - true - ); - } + //@todo fix to accept a char with 1 char + if (strlen(trim($_REQUEST['txt_search_word']))>2) { + $list_info = search_language_term( + $_REQUEST['txt_search_word'], + true, + true, + true, + true + ); + } } $parameters = array( - 'id' => intval($_GET['id']), - 'sub_language_id' => intval($_GET['sub_language_id']), - 'txt_search_word' => $txt_search_word + 'id' => intval($_GET['id']), + 'sub_language_id' => intval($_GET['sub_language_id']), + 'txt_search_word' => $txt_search_word ); -$table = new SortableTableFromArrayConfig($list_info, 1,20,'data_info'); +$table = new SortableTableFromArrayConfig($list_info, 1, 20, 'data_info'); $table->set_additional_parameters($parameters); $table->set_header(0, get_lang('LanguageFile')); $table->set_header(1, get_lang('LanguageVariable')); $table->set_header(2, get_lang('EnglishName')); $table->set_header(3, get_lang('OriginalName')); -$table->set_header(4, get_lang('Translation'),false); -$table->set_header(5, get_lang('Action'),false); +$table->set_header(4, get_lang('Translation'), false); +$table->set_header(5, get_lang('Action'), false); $table->display(); Display :: display_footer(); diff --git a/main/document/edit_document.php b/main/document/edit_document.php index 35aa5721ac..55ec9b9bc7 100755 --- a/main/document/edit_document.php +++ b/main/document/edit_document.php @@ -61,7 +61,7 @@ $group_id = api_get_group_id(); $sessionId = api_get_session_id(); if (api_is_in_group()) { - $group_properties = GroupManager::get_group_properties($group_id); + $group_properties = GroupManager::get_group_properties($group_id); } $dir = '/'; @@ -73,7 +73,7 @@ if (isset($_GET['id'])) { $_GET['id'], api_get_course_id(), true, - 0 + 0 ); if (!empty($sessionId) && empty($document_data)) { @@ -85,13 +85,13 @@ if (isset($_GET['id'])) { ); } - $document_id = $document_data['id']; - $file = $document_data['path']; - $parent_id = DocumentManager::get_document_id($course_info, dirname($file)); - $dir = dirname($document_data['path']); - $dir_original = $dir; - $doc = basename($file); - $readonly = $document_data['readonly']; + $document_id = $document_data['id']; + $file = $document_data['path']; + $parent_id = DocumentManager::get_document_id($course_info, dirname($file)); + $dir = dirname($document_data['path']); + $dir_original = $dir; + $doc = basename($file); + $readonly = $document_data['readonly']; } if (empty($document_data)) { @@ -113,7 +113,7 @@ $count_dir = count($doc_tree) - 2; // "2" because at the begin and end there are // Level correction for group documents. if (!empty($group_properties['directory'])) { - $count_dir = $count_dir > 0 ? $count_dir - 1 : 0; + $count_dir = $count_dir > 0 ? $count_dir - 1 : 0; } $relative_url = ''; for ($i = 0; $i < ($count_dir); $i++) { @@ -135,13 +135,13 @@ $editorConfig = array( ); if ($is_certificate_mode) { - $editorConfig['CreateDocumentDir'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/'; - $editorConfig['CreateDocumentWebDir'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/'; - $editorConfig['BaseHref'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir; + $editorConfig['CreateDocumentDir'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/'; + $editorConfig['CreateDocumentWebDir'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/'; + $editorConfig['BaseHref'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir; } $is_allowed_to_edit = api_is_allowed_to_edit(null, true) || $groupRights || - DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $sessionId); + DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $sessionId); $noPHP_SELF = true; /* Other initialization code */ @@ -154,8 +154,8 @@ if (!empty($group_id)) { 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(), 'name' => get_lang('GroupSpace'), ); - $group_document = true; - $noPHP_SELF = true; + $group_document = true; + $noPHP_SELF = true; } if (!$is_certificate_mode) { @@ -189,9 +189,9 @@ Event::event_access_tool(TOOL_DOCUMENT); //TODO:check the below code and his funcionality if (!api_is_allowed_to_edit()) { - if (DocumentManager::check_readonly($course_info, $user_id, $file)) { - api_not_allowed(); - } + if (DocumentManager::check_readonly($course_info, $user_id, $file)) { + api_not_allowed(); + } } /* MAIN TOOL CODE */ @@ -199,18 +199,18 @@ if (!api_is_allowed_to_edit()) { /* Code to change the comment */ if (isset($_POST['comment'])) { - // Fixing the path if it is wrong - $comment = trim($_POST['comment']); - $title = trim($_POST['title']); + // Fixing the path if it is wrong + $comment = trim($_POST['comment']); + $title = trim($_POST['title']); // Just in case see BT#3525 if (empty($title)) { - $title = $document_data['title']; - } + $title = $document_data['title']; + } - if (empty($title)) { - $title = get_document_title($_POST['filename']); - } + if (empty($title)) { + $title = get_document_title($_POST['filename']); + } if (!empty($document_id)) { $params = [ @@ -222,158 +222,156 @@ if (isset($_POST['comment'])) { $params, ['c_id = ? AND id = ?' => [$course_id, $document_id]] ); - Display::addFlash(Display::return_message(get_lang('fileModified'))); + Display::addFlash(Display::return_message(get_lang('fileModified'))); } } /* WYSIWYG HTML EDITOR - Program Logic */ if ($is_allowed_to_edit) { - if (isset($_POST['formSent']) && $_POST['formSent'] == 1) { - - $filename = stripslashes($_POST['filename']); + if (isset($_POST['formSent']) && $_POST['formSent'] == 1) { + $filename = stripslashes($_POST['filename']); $extension = $_POST['extension']; - $content = isset($_POST['content']) ? trim(str_replace(array("\r", "\n"), '', stripslashes($_POST['content']))) : null; - $content = Security::remove_XSS($content, COURSEMANAGERLOWSECURITY); + $content = isset($_POST['content']) ? trim(str_replace(array("\r", "\n"), '', stripslashes($_POST['content']))) : null; + $content = Security::remove_XSS($content, COURSEMANAGERLOWSECURITY); if ($dir == '/') { $dir = ''; } - $file = $dir.'/'.$filename.'.'.$extension; - $read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null; - $read_only_flag = empty($read_only_flag) ? 0 : 1; + $file = $dir.'/'.$filename.'.'.$extension; + $read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null; + $read_only_flag = empty($read_only_flag) ? 0 : 1; - if (empty($filename)) { + if (empty($filename)) { Display::addFlash(Display::return_message(get_lang('NoFileName'), 'warning')); - } else { + } else { + $file_size = filesize($document_data['absolute_path']); - $file_size = filesize($document_data['absolute_path']); - - if ($read_only_flag == 0) { - if (!empty($content)) { - if ($fp = @fopen($document_data['absolute_path'], 'w')) { - // For flv player, change absolute path temporarily to prevent from erasing it in the following lines - $content = str_replace(array('flv=h', 'flv=/'), array('flv=h|', 'flv=/|'), $content); - fputs($fp, $content); - fclose($fp); + if ($read_only_flag == 0) { + if (!empty($content)) { + if ($fp = @fopen($document_data['absolute_path'], 'w')) { + // For flv player, change absolute path temporarily to prevent from erasing it in the following lines + $content = str_replace(array('flv=h', 'flv=/'), array('flv=h|', 'flv=/|'), $content); + fputs($fp, $content); + fclose($fp); $filepath = $document_data['absolute_parent_path']; - /* - if (!is_dir($filepath.'css')) { - mkdir($filepath.'css', api_get_permissions_for_new_directories()); - $doc_id = add_document($_course, $dir.'css', 'folder', 0, 'css'); - api_item_property_update( - $_course, - TOOL_DOCUMENT, - $doc_id, - 'FolderCreated', - api_get_user_id(), - null, - null, - null, - null, - $sessionId - ); - api_item_property_update( - $_course, - TOOL_DOCUMENT, - $doc_id, - 'invisible', - api_get_user_id(), - null, - null, - null, - null, - $sessionId - ); - }*/ - - /*if (!is_file($filepath.'css/frames.css')) { - $platform_theme = api_get_setting('stylesheets'); - if (file_exists(api_get_path(SYS_CODE_PATH).'css/'.$platform_theme.'/frames.css')) { - copy(api_get_path(SYS_CODE_PATH).'css/'.$platform_theme.'/frames.css', $filepath.'css/frames.css'); - $doc_id = add_document( - $_course, - $dir . 'css/frames.css', - 'file', - filesize($filepath . 'css/frames.css'), - 'frames.css' - ); - api_item_property_update( - $_course, - TOOL_DOCUMENT, - $doc_id, - 'DocumentAdded', - api_get_user_id(), - null, - null, - null, - null, - $sessionId - ); - api_item_property_update( - $_course, - TOOL_DOCUMENT, - $doc_id, - 'invisible', - api_get_user_id(), - null, - null, - null, - null, - $sessionId - ); - } - }*/ - - // "WHAT'S NEW" notification: update table item_property - $document_id = DocumentManager::get_document_id($_course, $file); - - if ($document_id) { - update_existing_document( - $_course, - $document_id, - $file_size, - $read_only_flag - ); - api_item_property_update( - $_course, - TOOL_DOCUMENT, - $document_id, - 'DocumentUpdated', - api_get_user_id(), - null, - null, - null, - null, - $sessionId - ); - // Update parent folders - item_property_update_on_folder( - $_course, - $dir, - api_get_user_id() - ); - header('Location: document.php?id='.$document_data['parent_id'].'&'.api_get_cidreq().($is_certificate_mode ? '&curdirpath=/certificates&selectcat=1' : '')); - exit; - } else { + /* + if (!is_dir($filepath.'css')) { + mkdir($filepath.'css', api_get_permissions_for_new_directories()); + $doc_id = add_document($_course, $dir.'css', 'folder', 0, 'css'); + api_item_property_update( + $_course, + TOOL_DOCUMENT, + $doc_id, + 'FolderCreated', + api_get_user_id(), + null, + null, + null, + null, + $sessionId + ); + api_item_property_update( + $_course, + TOOL_DOCUMENT, + $doc_id, + 'invisible', + api_get_user_id(), + null, + null, + null, + null, + $sessionId + ); + }*/ + + /*if (!is_file($filepath.'css/frames.css')) { + $platform_theme = api_get_setting('stylesheets'); + if (file_exists(api_get_path(SYS_CODE_PATH).'css/'.$platform_theme.'/frames.css')) { + copy(api_get_path(SYS_CODE_PATH).'css/'.$platform_theme.'/frames.css', $filepath.'css/frames.css'); + $doc_id = add_document( + $_course, + $dir . 'css/frames.css', + 'file', + filesize($filepath . 'css/frames.css'), + 'frames.css' + ); + api_item_property_update( + $_course, + TOOL_DOCUMENT, + $doc_id, + 'DocumentAdded', + api_get_user_id(), + null, + null, + null, + null, + $sessionId + ); + api_item_property_update( + $_course, + TOOL_DOCUMENT, + $doc_id, + 'invisible', + api_get_user_id(), + null, + null, + null, + null, + $sessionId + ); + } + }*/ + + // "WHAT'S NEW" notification: update table item_property + $document_id = DocumentManager::get_document_id($_course, $file); + + if ($document_id) { + update_existing_document( + $_course, + $document_id, + $file_size, + $read_only_flag + ); + api_item_property_update( + $_course, + TOOL_DOCUMENT, + $document_id, + 'DocumentUpdated', + api_get_user_id(), + null, + null, + null, + null, + $sessionId + ); + // Update parent folders + item_property_update_on_folder( + $_course, + $dir, + api_get_user_id() + ); + header('Location: document.php?id='.$document_data['parent_id'].'&'.api_get_cidreq().($is_certificate_mode ? '&curdirpath=/certificates&selectcat=1' : '')); + exit; + } else { Display::addFlash(Display::return_message(get_lang('Impossible'), 'warning')); - } - } else { + } + } else { Display::addFlash(Display::return_message(get_lang('Impossible'), 'warning')); - } - } else { - if ($document_id) { + } + } else { + if ($document_id) { update_existing_document($_course, $document_id, $file_size, $read_only_flag); - } - } - } else { + } + } + } else { if ($document_id) { update_existing_document($_course, $document_id, $file_size, $read_only_flag); } - } - } - } + } + } + } } // Replace relative paths by absolute web paths (e.g. './' => 'http://www.chamilo.org/courses/ABC/document/') @@ -428,35 +426,35 @@ if ($owner_id == api_get_user_id() || $groupInfo ) ) { - $action = api_get_self().'?id='.$document_data['id'].'&'.api_get_cidreq(); + $action = api_get_self().'?id='.$document_data['id'].'&'.api_get_cidreq(); if ($is_certificate_mode) { $action .= '&curdirpath=/certificates&selectcat=1'; } - $form = new FormValidator('formEdit', 'post', $action, null, array('class' => 'form-vertical')); - - // Form title - $form->addElement('header', $nameTools); - $form->addElement('hidden', 'filename'); - $form->addElement('hidden', 'extension'); - $form->addElement('hidden', 'file_path'); - $form->addElement('hidden', 'commentPath'); - $form->addElement('hidden', 'showedit'); - $form->addElement('hidden', 'origin'); - $form->addElement('hidden', 'origin_opt'); + $form = new FormValidator('formEdit', 'post', $action, null, array('class' => 'form-vertical')); + + // Form title + $form->addElement('header', $nameTools); + $form->addElement('hidden', 'filename'); + $form->addElement('hidden', 'extension'); + $form->addElement('hidden', 'file_path'); + $form->addElement('hidden', 'commentPath'); + $form->addElement('hidden', 'showedit'); + $form->addElement('hidden', 'origin'); + $form->addElement('hidden', 'origin_opt'); $form->addText('title', get_lang('Title'), true, array('cols-size' => [2, 10, 0], 'autofocus')); - $defaults['title'] = $document_data['title']; + $defaults['title'] = $document_data['title']; - $form->addElement('hidden', 'formSent'); - $defaults['formSent'] = 1; + $form->addElement('hidden', 'formSent'); + $defaults['formSent'] = 1; - $read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null; + $read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null; - // Desactivation of IE proprietary commenting tags inside the text before loading it on the online editor. - // This fix has been proposed by Hubert Borderiou, see Bug #573, http://support.chamilo.org/issues/573 - $defaults['content'] = str_replace('