diff --git a/main/document/edit_document.php b/main/document/edit_document.php index e7b5adec39..5389ee17c2 100755 --- a/main/document/edit_document.php +++ b/main/document/edit_document.php @@ -155,7 +155,7 @@ $course_id = api_get_course_int_id(); if (!empty($group_id)) { $interbreadcrumb[] = array( - 'url' => '../group/group_space.php?'.api_get_cidreq(), + 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(), 'name' => get_lang('GroupSpace'), ); $group_document = true; @@ -164,14 +164,13 @@ if (!empty($group_id)) { if (!$is_certificate_mode) { $interbreadcrumb[] = array( - "url" => "./document.php?curdirpath=".urlencode($currentDirPath).'&'.api_get_cidreq(), + "url" => api_get_path(WEB_CODE_PATH)."document/document.php?curdirpath=".urlencode($currentDirPath).'&'.api_get_cidreq(), "name" => get_lang('Documents'), ); } else { $interbreadcrumb[]= array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook')); } -// Interbreadcrumb for the current directory root path if (empty($document_data['parents'])) { $interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']); } else { diff --git a/main/document/edit_draw.php b/main/document/edit_draw.php index 5b2cf1aa56..1955f7e83b 100755 --- a/main/document/edit_draw.php +++ b/main/document/edit_draw.php @@ -80,7 +80,7 @@ if (!is_dir($filepath)) { //groups //TODO:clean if (!empty($group_id)) { $req_gid = '&gidReq='.$group_id; - $interbreadcrumb[] = array ('url' => '../group/group_space.php?gidReq='.$group_id, 'name' => get_lang('GroupSpace')); + $interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?gidReq='.$group_id, 'name' => get_lang('GroupSpace')); $group_document = true; $noPHP_SELF = true; } diff --git a/main/document/edit_paint.php b/main/document/edit_paint.php index b30ef70831..8f4c99ad22 100755 --- a/main/document/edit_paint.php +++ b/main/document/edit_paint.php @@ -85,12 +85,14 @@ if (!is_dir($filepath)) { //groups //TODO:clean if (!empty($groupId)) { - $interbreadcrumb[] = array ('url' => '../group/group_space.php?'.api_get_cidreq(), 'name' => get_lang('GroupSpace')); + $interbreadcrumb[] = array( + 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(), + 'name' => get_lang('GroupSpace'), + ); $group_document = true; $noPHP_SELF = true; } - $is_certificate_mode = DocumentManager::is_certificate_mode($dir); if (!$is_certificate_mode) diff --git a/main/document/showinframes.php b/main/document/showinframes.php index 6aa314d7c8..fbe934e733 100755 --- a/main/document/showinframes.php +++ b/main/document/showinframes.php @@ -118,15 +118,15 @@ $current_group_name = $current_group['name']; if (isset($group_id) && $group_id != '') { $interbreadcrumb[] = array( - 'url' => '../group/group.php?'.api_get_cidreq(), + 'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(), 'name' => get_lang('Groups'), ); $interbreadcrumb[] = array( - 'url' => '../group/group_space.php?'.api_get_cidreq(), + 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(), 'name' => get_lang('GroupSpace').' '.$current_group_name, ); $name_to_show = explode('/', $name_to_show); - unset ($name_to_show[1]); + unset($name_to_show[1]); $name_to_show = implode('/', $name_to_show); } diff --git a/main/forum/editpost.php b/main/forum/editpost.php index 87b2c2ff22..e98cb1f475 100755 --- a/main/forum/editpost.php +++ b/main/forum/editpost.php @@ -75,15 +75,15 @@ if (!empty($gradebook) && $gradebook == 'view') { if ($origin == 'group') { $_clean['toolgroup'] = api_get_group_id(); $group_properties = GroupManager::get_group_properties($_clean['toolgroup']); - $interbreadcrumb[] = array('url' => '../group/group.php?'.api_get_cidreq(), 'name' => get_lang('Groups')); - $interbreadcrumb[] = array('url' => '../group/group_space.php?'.api_get_cidreq(), 'name' => get_lang('GroupSpace').' '.$group_properties['name']); - $interbreadcrumb[] = array('url' => 'viewforum.php?origin='.$origin.'&'.api_get_cidreq().'&forum='.intval($_GET['forum']), 'name' => prepare4display($current_forum['forum_title'])); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(), 'name' => get_lang('Groups')); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(), 'name' => get_lang('GroupSpace').' '.$group_properties['name']); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'forum/viewforum.php?origin='.$origin.'&'.api_get_cidreq().'&forum='.intval($_GET['forum']), 'name' => prepare4display($current_forum['forum_title'])); $interbreadcrumb[] = array('url' => 'javascript: void (0);', 'name' => get_lang('EditPost')); } else { - $interbreadcrumb[] = array('url' => 'index.php?'.api_get_cidreq(), 'name' => $nameTools); - $interbreadcrumb[] = array('url' => 'viewforumcategory.php?forumcategory='.$current_forum_category['cat_id'], 'name' => prepare4display($current_forum_category['cat_title'])); - $interbreadcrumb[] = array('url' => 'viewforum.php?origin='.$origin.'&forum='.intval($_GET['forum']), 'name' => prepare4display($current_forum['forum_title'])); - $interbreadcrumb[] = array('url' => 'viewthread.php?'.api_get_cidreq().'&origin='.$origin.'&forum='.intval($_GET['forum']).'&thread='.intval($_GET['thread']), 'name' => prepare4display($current_thread['thread_title'])); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'forum/index.php?'.api_get_cidreq(), 'name' => $nameTools); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'forum/viewforumcategory.php?forumcategory='.$current_forum_category['cat_id'], 'name' => prepare4display($current_forum_category['cat_title'])); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'forum/viewforum.php?origin='.$origin.'&forum='.intval($_GET['forum']), 'name' => prepare4display($current_forum['forum_title'])); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'forum/viewthread.php?'.api_get_cidreq().'&origin='.$origin.'&forum='.intval($_GET['forum']).'&thread='.intval($_GET['thread']), 'name' => prepare4display($current_thread['thread_title'])); $interbreadcrumb[] = array('url' => 'javascript: void (0);', 'name' => get_lang('EditPost')); } diff --git a/main/forum/editthread.php b/main/forum/editthread.php index 7c5beaf24e..b8ec8fcd63 100644 --- a/main/forum/editthread.php +++ b/main/forum/editthread.php @@ -104,14 +104,14 @@ if (api_is_invitee()) { $groupId = api_get_group_id(); if (!empty($groupId)) { $groupProperties = GroupManager :: get_group_properties($groupId); - $interbreadcrumb[] = array('url' => '../group/group.php?'.$cidreq, 'name' => get_lang('Groups')); - $interbreadcrumb[] = array('url' => '../group/group_space.php?'.$cidreq, 'name' => get_lang('GroupSpace').' '.$groupProperties['name']); - $interbreadcrumb[] = array('url' => 'viewforum.php?'.$cidreq.'&forum='.intval($_GET['forum']), 'name' => $currentForum['forum_title']); - $interbreadcrumb[] = array('url' => 'newthread.php?'.$cidreq.'&forum='.intval($_GET['forum']),'name' => get_lang('EditThread')); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.$cidreq, 'name' => get_lang('Groups')); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.$cidreq, 'name' => get_lang('GroupSpace').' '.$groupProperties['name']); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'forum/viewforum.php?'.$cidreq.'&forum='.intval($_GET['forum']), 'name' => $currentForum['forum_title']); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'forum/newthread.php?'.$cidreq.'&forum='.intval($_GET['forum']),'name' => get_lang('EditThread')); } else { - $interbreadcrumb[] = array('url' => 'index.php?'.$cidreq, 'name' => $nameTools); - $interbreadcrumb[] = array('url' => 'viewforumcategory.php?'.$cidreq.'&forumcategory='.$currentForumCategory['cat_id'], 'name' => $currentForumCategory['cat_title']); - $interbreadcrumb[] = array('url' => 'viewforum.php?'.$cidreq.'&forum='.intval($_GET['forum']), 'name' => $currentForum['forum_title']); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'forum/index.php?'.$cidreq, 'name' => $nameTools); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'forum/viewforumcategory.php?'.$cidreq.'&forumcategory='.$currentForumCategory['cat_id'], 'name' => $currentForumCategory['cat_title']); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'forum/viewforum.php?'.$cidreq.'&forum='.intval($_GET['forum']), 'name' => $currentForum['forum_title']); $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('EditThread')); } diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index 50156dbf09..62c7634a22 100755 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -231,9 +231,7 @@ function show_add_forumcategory_form($inputvalues = array(), $lp_id) function show_add_forum_form($inputvalues = array(), $lp_id) { $_course = api_get_course_info(); - $gradebook = Security::remove_XSS($_GET['gradebook']); - // Initialize the object. $form = new FormValidator('forumcategory', 'post', 'index.php?gradebook='.$gradebook.'&'.api_get_cidreq()); // The header for the form @@ -634,6 +632,7 @@ function store_forum($values, $courseInfo = array(), $returnId = false) if (!empty($_POST['remove_picture'])) { delete_forum_image($values['forum_id']); } + $new_file_name = ''; if (isset($upload_ok)) { if ($has_attachment) { @@ -641,7 +640,10 @@ function store_forum($values, $courseInfo = array(), $returnId = false) $sys_course_path = api_get_path(SYS_COURSE_PATH); $updir = $sys_course_path.$course_dir; // Try to add an extension to the file if it hasn't one. - $new_file_name = add_ext_on_mime(Database::escape_string($_FILES['picture']['name']), $_FILES['picture']['type']); + $new_file_name = add_ext_on_mime( + Database::escape_string($_FILES['picture']['name']), + $_FILES['picture']['type'] + ); if (!filter_extension($new_file_name)) { //Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); $image_moved = false; @@ -908,10 +910,12 @@ function delete_post($post_id) if (is_array($last_post_of_thread)) { // Decreasing the number of replies for this thread and also changing the last post information. - $sql = "UPDATE $table_threads SET thread_replies=thread_replies-1, + $sql = "UPDATE $table_threads + SET + thread_replies=thread_replies-1, thread_last_post = ".intval($last_post_of_thread['post_id']).", thread_date='".Database::escape_string($last_post_of_thread['post_date'])."' - WHERE c_id = $course_id AND thread_id = ".intval($_GET['thread']).""; + WHERE c_id = $course_id AND thread_id = ".intval($_GET['thread']); Database::query($sql); return 'PostDeleted'; @@ -919,7 +923,7 @@ function delete_post($post_id) if (!$last_post_of_thread) { // We deleted the very single post of the thread so we need to delete the entry in the thread table also. $sql = "DELETE FROM $table_threads - WHERE c_id = $course_id AND thread_id = ".intval($_GET['thread']).""; + WHERE c_id = $course_id AND thread_id = ".intval($_GET['thread']); Database::query($sql); return 'PostDeletedSpecial'; @@ -958,6 +962,8 @@ function check_if_last_post_of_thread($thread_id) * @param $content what is it that we want to make (in)visible: forum category, forum, thread, post * @param $id the id of the content we want to make invisible * @param $current_visibility_status what is the current status of the visibility (0 = invisible, 1 = visible) + * @param array $additional_url_parameters + * * @return string HTML */ function return_visible_invisible_icon($content, $id, $current_visibility_status, $additional_url_parameters = '') @@ -987,6 +993,13 @@ function return_visible_invisible_icon($content, $id, $current_visibility_status return $html; } +/** + * @param $content + * @param $id + * @param $current_lock_status + * @param string $additional_url_parameters + * @return string + */ function return_lock_unlock_icon($content, $id, $current_lock_status, $additional_url_parameters = '') { $html = ''; @@ -1750,9 +1763,9 @@ function get_threads($forum_id, $course_code = null) // because we also have thread.* in it. This is because thread has a field locked and post also has the same field // since we are merging these we would have the post.locked value but in fact we want the thread.locked value // This is why it is added to the end of the field selection - $groupCondition = api_get_group_id() != 0 ? " AND item_properties.to_group_id = '$groupId' AND item_properties.c_id = '$course_id'" : ""; + $groupCondition = api_get_group_id() != 0 ? " AND item_properties.to_group_id = '$groupId' " : ""; - $sql = "SELECT + $sql = "SELECT DISTINCT thread.*, item_properties.*, users.firstname, @@ -1775,7 +1788,7 @@ function get_threads($forum_id, $course_code = null) if (api_is_allowed_to_edit()) { - $sql = "SELECT + $sql = "SELECT DISTINCT thread.*, item_properties.*, users.firstname, @@ -1788,7 +1801,8 @@ function get_threads($forum_id, $course_code = null) thread.thread_id = item_properties.ref AND item_properties.c_id = $course_id AND thread.c_id = $course_id AND - item_properties.tool = '".TABLE_FORUM_THREAD."' $groupCondition + item_properties.tool = '".TABLE_FORUM_THREAD."' + $groupCondition LEFT JOIN $table_users users ON thread.thread_poster_id=users.user_id WHERE @@ -1796,13 +1810,19 @@ function get_threads($forum_id, $course_code = null) thread.forum_id = ".intval($forum_id)." ORDER BY thread.thread_sticky DESC, thread.thread_date DESC"; } + $result = Database::query($sql); - $thread_list = array(); + $list = array(); + $alreadyAdded = array(); while ($row = Database::fetch_array($result, 'ASSOC')) { - $thread_list[] = $row; + if (in_array($row['thread_id'], $alreadyAdded)) { + continue; + } + $list[] = $row; + $alreadyAdded[] = $row['thread_id']; } - return $thread_list; + return $list; } /** @@ -4107,10 +4127,13 @@ function send_mail($user_info = array(), $thread_information = array()) function move_thread_form() { $gradebook = Security::remove_XSS($_GET['gradebook']); - // Initialize the object. - $form = new FormValidator('movepost', 'post', api_get_self().'?forum='.Security::remove_XSS($_GET['forum']).'&gradebook='.$gradebook.'&thread='.Security::remove_XSS($_GET['thread']).'&action='.Security::remove_XSS($_GET['action']).'&'.api_get_cidreq()); + $form = new FormValidator( + 'movepost', + 'post', + api_get_self().'?forum='.intval($_GET['forum']).'&gradebook='.$gradebook.'&thread='.intval($_GET['thread']).'&action='.Security::remove_XSS($_GET['action']).'&'.api_get_cidreq() + ); // The header for the form - $form->addElement('header', '', get_lang('MoveThread')); + $form->addElement('header', get_lang('MoveThread')); // Invisible form: the thread_id $form->addElement('hidden', 'thread_id', intval($_GET['thread'])); // the fora @@ -4126,8 +4149,10 @@ function move_thread_form() foreach ($forum_categories as $key => $category) { $htmlcontent .= ''; foreach ($forums as $key => $forum) { - if ($forum['forum_category'] == $category['cat_id']) { - $htmlcontent .= ''; + if (isset($forum['forum_category'])) { + if ($forum['forum_category'] == $category['cat_id']) { + $htmlcontent .= ''; + } } } $htmlcontent .= ''; @@ -4328,20 +4353,56 @@ function store_move_post($values) */ function store_move_thread($values) { - $table_threads = Database :: get_course_table(TABLE_FORUM_THREAD); - $table_posts = Database :: get_course_table(TABLE_FORUM_POST); + $table_threads = Database:: get_course_table(TABLE_FORUM_THREAD); + $table_posts = Database:: get_course_table(TABLE_FORUM_POST); - $course_id = api_get_course_int_id(); + $courseId = api_get_course_int_id(); + $sessionId = api_get_session_id(); + + $forumId = intval($_POST['forum']); + $threadId = intval($_POST['thread_id']); + $forumInfo = get_forums($forumId); // Change the thread table: Setting the forum_id to the new forum. - $sql = "UPDATE $table_threads SET forum_id='".Database::escape_string($_POST['forum'])."' - WHERE c_id = $course_id AND thread_id='".Database::escape_string($_POST['thread_id'])."'"; + $sql = "UPDATE $table_threads SET forum_id = $forumId + WHERE c_id = $courseId AND thread_id = $threadId"; Database::query($sql); // Changing all the posts of the thread: setting the forum_id to the new forum. - $sql = "UPDATE $table_posts SET forum_id='".Database::escape_string($_POST['forum'])."' - WHERE c_id = $course_id AND thread_id='".Database::escape_string($_POST['thread_id'])."'"; + $sql = "UPDATE $table_posts SET forum_id = $forumId + WHERE c_id = $courseId AND thread_id= $threadId"; Database::query($sql); + // Fix group id, if forum is moved to a different group + if (!empty($forumInfo['to_group_id'])) { + $groupId = $forumInfo['to_group_id']; + $item = api_get_item_property_info($courseId, TABLE_FORUM_THREAD, $threadId, $sessionId, $groupId); + $table = Database:: get_course_table(TABLE_ITEM_PROPERTY); + $sessionCondition = api_get_session_condition($sessionId); + + if (!empty($item)) { + if ($item['to_group_id'] != $groupId) { + $sql = "UPDATE $table + SET to_group_id = $groupId + WHERE + tool = '".TABLE_FORUM_THREAD."' AND + c_id = $courseId AND + ref = ".$item['ref']." + $sessionCondition + "; + Database::query($sql); + } + } else { + $sql = "UPDATE $table + SET to_group_id = $groupId + WHERE + tool = '".TABLE_FORUM_THREAD."' AND + c_id = $courseId AND + ref = ".$threadId." + $sessionCondition + "; + Database::query($sql); + } + } return get_lang('ThreadMoved'); } diff --git a/main/forum/forumsearch.php b/main/forum/forumsearch.php index 2c75b7b596..9910b7366b 100755 --- a/main/forum/forumsearch.php +++ b/main/forum/forumsearch.php @@ -63,12 +63,12 @@ $groupId = api_get_group_id(); if ($origin == 'group') { $group_properties = GroupManager :: get_group_properties($groupId); - $interbreadcrumb[] = array('url' => '../group/group.php?'.api_get_cidreq(), 'name' => get_lang('Groups')); - $interbreadcrumb[] = array('url' => '../group/group_space.php?'.api_get_cidreq(), 'name' => get_lang('GroupSpace').' ('.$group_properties['name'].')'); - $interbreadcrumb[] = array('url' => 'viewforum.php?origin='.$origin.'&forum='.intval($_GET['forum']).'&'.api_get_cidreq(), 'name' => prepare4display($current_forum['forum_title'])); - $interbreadcrumb[] = array('url' => 'forumsearch.php?'.api_get_cidreq(),'name' => get_lang('ForumSearch')); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(), 'name' => get_lang('Groups')); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(), 'name' => get_lang('GroupSpace').' ('.$group_properties['name'].')'); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'forum/viewforum.php?origin='.$origin.'&forum='.intval($_GET['forum']).'&'.api_get_cidreq(), 'name' => prepare4display($current_forum['forum_title'])); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'forum/forumsearch.php?'.api_get_cidreq(),'name' => get_lang('ForumSearch')); } else { - $interbreadcrumb[] = array('url' => 'index.php?'.api_get_cidreq(), 'name' => $nameTools); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'forum/index.php?'.api_get_cidreq(), 'name' => $nameTools); $nameTools = get_lang('ForumSearch'); } diff --git a/main/forum/newthread.php b/main/forum/newthread.php index 96e7eccd9b..ab266611a8 100755 --- a/main/forum/newthread.php +++ b/main/forum/newthread.php @@ -114,19 +114,18 @@ if (api_is_invitee()) { $groupId = api_get_group_id(); if (!empty($groupId)) { $groupProperties = GroupManager :: get_group_properties($groupId); - $interbreadcrumb[] = array('url' => '../group/group.php?'.$cidreq, 'name' => get_lang('Groups')); - $interbreadcrumb[] = array('url' => '../group/group_space.php?'.$cidreq, 'name' => get_lang('GroupSpace').' '.$groupProperties['name']); - $interbreadcrumb[] = array('url' => 'viewforum.php?'.$cidreq.'&forum='.intval($_GET['forum']), 'name' => $current_forum['forum_title']); - $interbreadcrumb[] = array('url' => 'newthread.php?'.$cidreq.'&forum='.intval($_GET['forum']),'name' => get_lang('NewTopic')); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.$cidreq, 'name' => get_lang('Groups')); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.$cidreq, 'name' => get_lang('GroupSpace').' '.$groupProperties['name']); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'forum/viewforum.php?'.$cidreq.'&forum='.intval($_GET['forum']), 'name' => $current_forum['forum_title']); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'forum/newthread.php?'.$cidreq.'&forum='.intval($_GET['forum']),'name' => get_lang('NewTopic')); } else { - $interbreadcrumb[] = array('url' => 'index.php?'.$cidreq, 'name' => $nameTools); - $interbreadcrumb[] = array('url' => 'viewforumcategory.php?'.$cidreq.'&forumcategory='.$current_forum_category['cat_id'], 'name' => $current_forum_category['cat_title']); - $interbreadcrumb[] = array('url' => 'viewforum.php?'.$cidreq.'&forum='.intval($_GET['forum']), 'name' => $current_forum['forum_title']); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'forum/index.php?'.$cidreq, 'name' => $nameTools); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'forum/viewforumcategory.php?'.$cidreq.'&forumcategory='.$current_forum_category['cat_id'], 'name' => $current_forum_category['cat_title']); + $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'forum/viewforum.php?'.$cidreq.'&forum='.intval($_GET['forum']), 'name' => $current_forum['forum_title']); $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('NewTopic')); } /* Resource Linker */ - if (isset($_POST['add_resources']) AND $_POST['add_resources'] == get_lang('Resources')) { $_SESSION['formelements'] = $_POST; $_SESSION['origin'] = $_SERVER['REQUEST_URI']; @@ -135,8 +134,6 @@ if (isset($_POST['add_resources']) AND $_POST['add_resources'] == get_lang('Reso exit; } -/* Header */ - $htmlHeadXtra[] = << $(document).on('ready', function() { @@ -165,7 +162,7 @@ handle_forum_and_forumcategories(); echo '
'; echo ''.search_link().''; echo ''. - Display::return_icon('back.png',get_lang('BackToForum'),'',ICON_SIZE_MEDIUM).''; + Display::return_icon('back.png', get_lang('BackToForum'), '', ICON_SIZE_MEDIUM).''; echo '
'; // Set forum attachment data into $_SESSION @@ -183,7 +180,7 @@ if (!empty($values) && isset($values['SubmitPost'])) { store_thread($current_forum, $values); } -if ($origin == 'learnpath') { +if (isset($origin) && $origin == 'learnpath') { Display::display_reduced_footer(); } else { Display::display_footer(); diff --git a/main/forum/reply.php b/main/forum/reply.php index 0b323330e6..0300ea9e08 100755 --- a/main/forum/reply.php +++ b/main/forum/reply.php @@ -95,19 +95,19 @@ if ($origin == 'group') { $_clean['toolgroup'] = api_get_group_id(); $group_properties = GroupManager :: get_group_properties($_clean['toolgroup']); $interbreadcrumb[] = array( - 'url' => '../group/group.php?'.api_get_cidreq(), + 'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(), 'name' => get_lang('Groups'), ); $interbreadcrumb[] = array( - 'url' => '../group/group_space.php?'.api_get_cidreq(), + 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(), 'name' => get_lang('GroupSpace').' '.$group_properties['name'], ); $interbreadcrumb[] = array( - 'url' => 'viewforum.php?origin='.$origin.'&forum='.intval($_GET['forum']).'&'.api_get_cidreq(), + 'url' => api_get_path(WEB_CODE_PATH).'forum/viewforum.php?origin='.$origin.'&forum='.intval($_GET['forum']).'&'.api_get_cidreq(), 'name' => $current_forum['forum_title'], ); $interbreadcrumb[] = array( - 'url' => 'viewthread.php?origin='.$origin.'&gradebook='.$gradebook.'&forum='.intval($_GET['forum']).'&thread='.intval($_GET['thread']).'&'.api_get_cidreq(), + 'url' => api_get_path(WEB_CODE_PATH).'forum/viewthread.php?origin='.$origin.'&gradebook='.$gradebook.'&forum='.intval($_GET['forum']).'&thread='.intval($_GET['thread']).'&'.api_get_cidreq(), 'name' => $current_thread['thread_title'], ); $interbreadcrumb[] = array( @@ -120,22 +120,21 @@ if ($origin == 'group') { 'name' => $nameTools, ); $interbreadcrumb[] = array( - 'url' => 'viewforumcategory.php?forumcategory='.$current_forum_category['cat_id'].'&'.api_get_cidreq(), + 'url' => api_get_path(WEB_CODE_PATH).'forum/viewforumcategory.php?forumcategory='.$current_forum_category['cat_id'].'&'.api_get_cidreq(), 'name' => $current_forum_category['cat_title'], ); $interbreadcrumb[] = array( - 'url' => 'viewforum.php?origin='.$origin.'&forum='.intval($_GET['forum']).'&'.api_get_cidreq(), + 'url' => api_get_path(WEB_CODE_PATH).'forum/viewforum.php?origin='.$origin.'&forum='.intval($_GET['forum']).'&'.api_get_cidreq(), 'name' => $current_forum['forum_title'], ); $interbreadcrumb[] = array( - 'url' => 'viewthread.php?origin='.$origin.'&gradebook='.$gradebook.'&forum='.intval($_GET['forum']).'&thread='.intval($_GET['thread']).'&'.api_get_cidreq(), + 'url' => api_get_path(WEB_CODE_PATH).'forum/viewthread.php?origin='.$origin.'&gradebook='.$gradebook.'&forum='.intval($_GET['forum']).'&thread='.intval($_GET['thread']).'&'.api_get_cidreq(), 'name' => $current_thread['thread_title'], ); $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Reply')); } /* Resource Linker */ - if (isset($_POST['add_resources']) && $_POST['add_resources'] == get_lang('Resources')) { $_SESSION['formelements'] = $_POST; $_SESSION['origin'] = $_SERVER['REQUEST_URI']; @@ -145,7 +144,6 @@ if (isset($_POST['add_resources']) && $_POST['add_resources'] == get_lang('Resou } /* Header */ - $htmlHeadXtra[] = << $(document).on('ready', function() { diff --git a/main/forum/viewthread.php b/main/forum/viewthread.php index 1f8e89818e..2cecdca898 100755 --- a/main/forum/viewthread.php +++ b/main/forum/viewthread.php @@ -61,16 +61,15 @@ $sessionId = api_get_session_id(); if ($origin == 'group') { $group_properties = GroupManager::get_group_properties($groupId); $interbreadcrumb[] = array( - 'url' => '../group/group.php', + 'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(), 'name' => get_lang('Groups') ); $interbreadcrumb[] = array( - 'url' => '../group/group_space.php?' . api_get_cidreq(), + 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?' . api_get_cidreq(), 'name' => get_lang('GroupSpace') . ' ' . $group_properties['name'] ); $interbreadcrumb[] = array( - 'url' => 'viewforum.php?forum=' . intval($_GET['forum']) . '&' . api_get_cidreq() - . "&origin=$origin&search=" . Security::remove_XSS(urlencode($my_search)), + 'url' => api_get_path(WEB_CODE_PATH).'forum/viewforum.php?forum='.intval($_GET['forum']).'&'.api_get_cidreq(). "&origin=$origin&search=" . Security::remove_XSS(urlencode($my_search)), 'name' => Security::remove_XSS($current_forum['forum_title']) ); $interbreadcrumb[] = array( @@ -85,20 +84,20 @@ if ($origin == 'group') { Display::display_reduced_header(); } else { $interbreadcrumb[] = array( - 'url' => 'index.php?' + 'url' => api_get_path(WEB_CODE_PATH).'forum/index.php?' . (isset($gradebook) ? "gradebook=$gradebook&" : '') . 'search=' . Security::remove_XSS(urlencode($my_search)), 'name' => $nameTools ); $interbreadcrumb[] = array( - 'url' => 'viewforumcategory.php?forumcategory=' + 'url' => api_get_path(WEB_CODE_PATH).'forum/viewforumcategory.php?forumcategory=' . $current_forum_category['cat_id'] . "&origin=$origin&search=" . Security::remove_XSS(urlencode($my_search)), 'name' => Security::remove_XSS($current_forum_category['cat_title']) ); $interbreadcrumb[] = array( - 'url' => 'viewforum.php?forum=' . intval($_GET['forum']) + 'url' => api_get_path(WEB_CODE_PATH).'forum/viewforum.php?forum=' . intval($_GET['forum']) . "&origin=$origin&search=" . Security::remove_XSS(urlencode($my_search)), 'name' => Security::remove_XSS($current_forum['forum_title']) @@ -152,7 +151,6 @@ if ($my_action == 'move' && isset($_GET['post'])) { } /* Display the action messages */ - $my_message = isset($message) ? $message : ''; if ($my_message) { Display::display_confirmation_message(get_lang($my_message)); @@ -164,7 +162,6 @@ if ($my_message != 'PostDeletedSpecial') { increase_thread_view($_GET['thread']); /* Action Links */ - if ($origin == 'learnpath') { echo '
 
'; } @@ -186,7 +183,7 @@ if ($my_message != 'PostDeletedSpecial') { api_is_allowed_to_edit(false, true) ) { // The link should only appear when the user is logged in or when anonymous posts are allowed. - if ($_user['user_id'] OR ($current_forum['allow_anonymous'] == 1 && !$_user['user_id'])) { + if ($_user['user_id'] || ($current_forum['allow_anonymous'] == 1 && !$_user['user_id'])) { // reply link if (!api_is_anonymous() && api_is_allowed_to_session_edit(false, true)) { echo ' 0) { @@ -4151,7 +4158,8 @@ function api_get_item_property_info($course_id, $tool, $ref, $session_id = 0) * @return string */ -function api_get_languages_combo($name = 'language') { +function api_get_languages_combo($name = 'language') +{ $ret = ''; $platformLanguage = api_get_setting('platformLanguage'); diff --git a/main/inc/lib/groupmanager.lib.php b/main/inc/lib/groupmanager.lib.php index 998049fc57..375272898d 100755 --- a/main/inc/lib/groupmanager.lib.php +++ b/main/inc/lib/groupmanager.lib.php @@ -252,14 +252,18 @@ class GroupManager require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php'; $forum_categories = get_forum_categories(); + if (empty($forum_categories)) { + $categoryParam = array( + 'forum_category_title' => get_lang('GroupForums'), + ); + store_forumcategory($categoryParam); - $values = array(); - $values['forum_title'] = $name; - $values['group_id'] = $lastId; + $forum_categories = get_forum_categories(); + } $counter = 0; - foreach ($forum_categories as $key=>$value) { - if ($counter==0) { + foreach ($forum_categories as $key => $value) { + if ($counter == 0) { $forum_category_id = $key; } $counter++; @@ -268,6 +272,10 @@ class GroupManager if (empty($forum_category_id)) { $forum_category_id = 0; } + + $values = array(); + $values['forum_title'] = $name; + $values['group_id'] = $lastId; $values['forum_category'] = $forum_category_id; $values['allow_anonymous_group']['allow_anonymous'] = 0; $values['students_can_edit_group']['students_can_edit'] = 0;