From 021de899f6114410893302efceaf2a900169062c Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Wed, 19 Oct 2016 09:38:39 +0200 Subject: [PATCH] Fix php warning when no first post + format code --- main/forum/forumfunction.inc.php | 17 ++++++++++++----- main/forum/viewforumcategory.php | 29 ++++++++--------------------- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index c2701cdc94..a0e1d23646 100755 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -139,7 +139,7 @@ function handle_forum_and_forumcategories($lp_id = null) $link_info = GradebookUtils::isResourceInCourseGradebook( api_get_course_id(), 5, - intval($list_threads[$i]['thread_id']), + $list_threads[$i]['thread_id'], api_get_session_id() ); if ($link_info !== false) { @@ -841,7 +841,7 @@ function deleteForumCategoryThread($content, $id) $return_message = get_lang('ForumCategoryDeleted'); if (!empty($forum_list)) { - $sql = "SELECT forum_id FROM ".$table_forums." + $sql = "SELECT forum_id FROM $table_forums WHERE c_id = $course_id AND forum_category='".$id."'"; $result = Database::query($sql); $row = Database::fetch_array($result); @@ -863,13 +863,19 @@ function deleteForumCategoryThread($content, $id) $return_message = get_lang('ForumDeleted'); if (!empty($number_threads)) { - $sql = "SELECT thread_id FROM".$table_forum_thread." - WHERE c_id = $course_id AND forum_id='".$id."'"; + $sql = "SELECT thread_id FROM $table_forum_thread + WHERE c_id = $course_id AND forum_id = $id "; $result = Database::query($sql); $row = Database::fetch_array($result); foreach ($row as $arr_forum) { $forum_id = $arr_forum['thread_id']; - api_item_property_update($_course, 'forum_thread', $forum_id, 'delete', api_get_user_id()); + api_item_property_update( + $_course, + 'forum_thread', + $forum_id, + 'delete', + api_get_user_id() + ); } } } @@ -1616,6 +1622,7 @@ function get_forums( api_is_allowed_to_edit(), $course_id ); + if ($last_post_info_of_forum) { $forum_list[$key]['last_post_id'] = $last_post_info_of_forum['last_post_id']; $forum_list[$key]['last_poster_id'] = $last_post_info_of_forum['last_poster_id']; diff --git a/main/forum/viewforumcategory.php b/main/forum/viewforumcategory.php index b758c76d4a..3c2ac565a1 100755 --- a/main/forum/viewforumcategory.php +++ b/main/forum/viewforumcategory.php @@ -243,28 +243,12 @@ if ($action_forums != 'add') { ); - if ($descriptionCategory != '' && trim($descriptionCategory)!= ' ') - { + if ($descriptionCategory != '' && trim($descriptionCategory)!= ' ') { $html .= '
'.$descriptionCategory.'
'; } - /* echo ''; */ - - - // Step 3: The interim headers (for the forum). - /* - echo ''; - echo ''.get_lang('Forum').''; - echo ''.get_lang('ForumThreads').''; - echo ''.get_lang('Posts').''; - echo ''.get_lang('LastPosts').''; - echo ''.get_lang('Actions').''; - echo ''; - echo ''; - */ $html .= ''; echo $html; - echo '
'; // The forums in this category. $forums_in_category = get_forums_in_category($forum_category['cat_id']); @@ -431,13 +415,16 @@ if ($action_forums != 'add') { $html .= '
'; $html .= $newPost . '
'; + $poster_id = 0; + $name = ''; // the last post in the forum - if ($forum['last_poster_name'] != '') { + if (isset($forum['last_poster_name']) && $forum['last_poster_name'] != '') { $name = $forum['last_poster_name']; - $poster_id = 0; } else { - $name = api_get_person_name($forum['last_poster_firstname'], $forum['last_poster_lastname']); - $poster_id = $forum['last_poster_id']; + if (isset($forum['last_poster_lastname'])) { + $name = api_get_person_name($forum['last_poster_firstname'], $forum['last_poster_lastname']); + $poster_id = $forum['last_poster_id']; + } } $html .= '
'; if (!empty($forum['last_post_id'])) {