Browse Source

Add option to hide group's forum in main forum tool -ref #6724

baelmyhu 11 years ago
parent
commit
0d2f85daa3

+ 8 - 1
main/forum/forumfunction.inc.php

@@ -1219,7 +1219,7 @@ function get_forums_in_category($cat_id)
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  * @version february 2006, dokeos 1.8
  */
-function get_forums($id = '', $course_code = '')
+function get_forums($id = '', $course_code = '', $includeGroupsForum = true)
 {
     $course_info = api_get_course_info($course_code);
 
@@ -1237,6 +1237,11 @@ function get_forums($id = '', $course_code = '')
 
     $forum_list = array();
 
+    $includeGroupsForumSelect = "";
+    if (!$includeGroupsForum) {
+        $includeGroupsForumSelect = " AND forum_of_group = 0 ";
+    }
+
     if ($id == '') {
         // Student
         // Select all the forum information of all forums (that are visible to students).
@@ -1248,6 +1253,7 @@ function get_forums($id = '', $course_code = '')
                     $condition_session AND
                     forum.c_id = $course_id AND
                     item_properties.c_id = $course_id
+                    $includeGroupsForumSelect
                 ORDER BY forum.forum_order ASC";
 
         // Select the number of threads of the forums (only the threads that are visible).
@@ -1286,6 +1292,7 @@ function get_forums($id = '', $course_code = '')
                         $condition_session AND
                         forum.c_id = $course_id AND
                         item_properties.c_id = $course_id
+                        $includeGroupsForumSelect
                     ORDER BY forum_order ASC";
 
             // Select the number of threads of the forums (only the threads that are not deleted).

+ 3 - 2
main/forum/index.php

@@ -147,7 +147,8 @@ event_access_tool(TOOL_FORUM);
 $forumCategories = get_forum_categories();
 
 // Step 2: We find all the forums (only the visible ones if it is a student).
-$forum_list	= get_forums();
+// display group forum in general forum tool depending to configuration option
+$forum_list	= get_forums('', '', api_get_display_groups_forum_in_general_tool());
 $user_id = api_get_user_id();
 
 /* RETRIEVING ALL GROUPS AND THOSE OF THE USER */
@@ -227,7 +228,7 @@ if (is_array($forumCategories)) {
         }
 
         if (empty($forumCategory['cat_title'])) {
-            $forumCategory['cat_title'] = get_lang('NoCategory');
+            $forumCategory['cat_title'] = get_lang('WithoutCategory');
         }
 
         echo '<table class="forum_table">';

+ 15 - 0
main/inc/lib/main_api.lib.php

@@ -764,6 +764,21 @@ function api_is_facebook_auth_activated() {
 }
 
 
+/**
+ * Return the $_configuration of displaying group forum in the general forum tool of a course or not
+ * is true by default
+ * @return bool
+ * @todo : in 1.10 replace this with a platform parameter in the database
+ */
+function api_get_display_groups_forum_in_general_tool() {
+    global $_configuration;
+
+    if (isset($_configuration['display_groups_forum_in_general_tool'])) {
+        return $_configuration['display_groups_forum_in_general_tool'];
+    }
+    return true;
+}
+
 /**
  * This function checks whether a given path points inside the system.
  * @param string $path      The path to be tesed. It should be full path, web-absolute (WEB), semi-absolute (REL) or system-absolyte (SYS).

+ 2 - 0
main/install/configuration.dist.php

@@ -186,3 +186,5 @@ $_configuration['system_stable']     = NEW_VERSION_STABLE;
 //$_configuration['captcha_time_to_block'] = 5;//minutes
 // Allow DRH role to access all content and users from the sessions he follows
 //$_configuration['drh_can_access_all_session_content'] = true;
+// Display group's forum in general forum tool
+//$_configuration['display_groups_forum_in_general_tool'] = true;