Browse Source

Fix php warning when no first post + format code

jmontoyaa 8 years ago
parent
commit
021de899f6
2 changed files with 20 additions and 26 deletions
  1. 12 5
      main/forum/forumfunction.inc.php
  2. 8 21
      main/forum/viewforumcategory.php

+ 12 - 5
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'];

+ 8 - 21
main/forum/viewforumcategory.php

@@ -243,28 +243,12 @@ if ($action_forums != 'add') {
     );
 
 
-    if ($descriptionCategory != '' && trim($descriptionCategory)!= ' ')
-    {
+    if ($descriptionCategory != '' && trim($descriptionCategory)!= ' ') {
         $html .= '<div class="forum-description">'.$descriptionCategory.'</div>';
     }
-    /* echo '<tr><th class="forum_head" '.(api_is_allowed_to_edit(null, true) ? 'colspan="5"' : 'colspan="6"').'>'; */
-
-
-    // Step 3: The interim headers (for the forum).
-    /*
-    echo '<tr class="forum_header">';
-    echo '<td colspan="2">'.get_lang('Forum').'</td>';
-    echo '<td>'.get_lang('ForumThreads').'</td>';
-    echo '<td>'.get_lang('Posts').'</td>';
-    echo '<td>'.get_lang('LastPosts').'</td>';
-    echo '<td>'.get_lang('Actions').'</td>';
-    echo '</tr>';
-    echo '</thead>';
-    */
 
     $html .= '</div>';
     echo $html;
-
     echo '<div class="forum_display">';
     // 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 .= '<div class="col-md-2">';
                 $html .= $newPost . '</div>';
 
+                $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 .= '<div class="col-md-6">';
                 if (!empty($forum['last_post_id'])) {