diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index b52a08f6ce..2e949ce70a 100755 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -4,6 +4,7 @@ use ChamiloSession as Session; use Doctrine\Common\Collections\Criteria; use Chamilo\CourseBundle\Entity\CForumPost; +use Chamilo\CourseBundle\Entity\CForumThread; /** * These files are a complete rework of the forum. The database structure is @@ -544,6 +545,7 @@ function store_forumcategory($values, $courseInfo = array(), $showMessage = true 'cat_title' => $clean_cat_title, 'cat_comment' => isset($values['forum_category_comment']) ? $values['forum_category_comment'] : '', ]; + Database::update( $table_categories, $params, @@ -633,7 +635,7 @@ function store_forum($values, $courseInfo = array(), $returnId = false) $new_max = null; } else { $sql = "SELECT MAX(forum_order) as sort_max - FROM ".$table_forums." + FROM $table_forums WHERE c_id = $course_id AND forum_category='".Database::escape_string($values['forum_category'])."'"; @@ -644,6 +646,7 @@ function store_forum($values, $courseInfo = array(), $returnId = false) // Forum images $image_moved = false; + $has_attachment = false; if (!empty($_FILES['picture']['name'])) { $upload_ok = process_uploaded_file($_FILES['picture']); $has_attachment = true; @@ -784,7 +787,6 @@ function store_forum($values, $courseInfo = array(), $returnId = false) } $return_message = get_lang('ForumAdded'); if ($returnId) { - return $last_id; } } @@ -951,7 +953,7 @@ function delete_post($post_id) // 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, + 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']); @@ -1071,6 +1073,7 @@ function return_lock_unlock_icon($content, $id, $current_lock_status, $additiona $html .= 'action=lock&content=' . $content . '&id=' . $id . '">' . Display::return_icon('unlock.png', get_lang('Lock'), array(), ICON_SIZE_SMALL) . ''; } + return $html; } @@ -1795,7 +1798,7 @@ function get_last_post_information($forum_id, $show_invisibles = false, $course_ * @param int $forum_id * @param int|null $courseId Optional If is null then it is considered the current course * @param int|null $sessionId Optional. If is null then it is considered the current session - * @return an array containing all the information about the threads + * @return array containing all the information about the threads * * @author Patrick Cool , Ghent University * @version february 2006, dokeos 1.8 @@ -1803,12 +1806,12 @@ function get_last_post_information($forum_id, $show_invisibles = false, $course_ function get_threads($forum_id, $courseId = null, $sessionId = null) { $groupId = api_get_group_id(); - $sessionId = $sessionId !== NULL ? intval($sessionId) : api_get_session_id(); + $sessionId = $sessionId !== null ? intval($sessionId) : api_get_session_id(); $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); $table_threads = Database :: get_course_table(TABLE_FORUM_THREAD); $table_users = Database :: get_main_table(TABLE_MAIN_USER); - $courseId = $courseId !== NULL ? intval($courseId) : api_get_course_int_id(); + $courseId = $courseId !== null ? intval($courseId) : api_get_course_int_id(); $groupInfo = GroupManager::get_group_properties($groupId); $groupCondition = ''; if (!empty($groupInfo)) { @@ -1822,8 +1825,6 @@ function get_threads($forum_id, $courseId = null, $sessionId = 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 - - $sql = "SELECT DISTINCT item_properties.*, users.firstname, @@ -2510,7 +2511,7 @@ function store_thread($current_forum, $values, $courseInfo = array(), $showMessa // We first store an entry in the forum_thread table because the thread_id is used in the forum_post table. - $lastThread = new \Chamilo\CourseBundle\Entity\CForumThread(); + $lastThread = new CForumThread(); $lastThread ->setCId($course_id) ->setThreadTitle($clean_post_title) @@ -2852,8 +2853,6 @@ function showUpdateThreadForm($currentForum, $forumSetting, $formValues = '') $token = Security::get_token(); $form->addElement('hidden', 'sec_token'); $form->setConstants(array('sec_token' => $token)); - - $form->display(); } } @@ -2956,10 +2955,8 @@ function show_add_post_form($current_forum, $forum_setting, $action, $id = '', $ } $form->addElement('html', '