Browse Source

Add "default_glossary_view" setting see BT#13077

jmontoyaa 7 years ago
parent
commit
5c57c02c6b
2 changed files with 23 additions and 7 deletions
  1. 20 7
      main/inc/lib/glossary.lib.php
  2. 3 0
      main/install/configuration.dist.php

+ 20 - 7
main/inc/lib/glossary.lib.php

@@ -354,22 +354,35 @@ class GlossaryManager
         return true;
     }
 
+    /**
+     * @return string
+     */
+    public static function getGlossaryView()
+    {
+        $view = Session::read('glossary_view');
+        if (empty($view)) {
+            $defaultView = api_get_configuration_value('default_glossary_view');
+            if (empty($defaultView)) {
+                $defaultView = 'table';
+            }
+            return $defaultView;
+        } else {
+            return $view;
+        }
+    }
+
     /**
      * This is the main function that displays the list or the table with all
      * the glossary terms
-     * @param  string  View ('table' or 'list'). Optional parameter.
      * Defaults to 'table' and prefers glossary_view from the session by default.
      *
      * @return string
      */
-    public static function display_glossary($view = 'table')
+    public static function display_glossary()
     {
         // This function should always be called with the corresponding
         // parameter for view type. Meanwhile, use this cheap trick.
-        $view = Session::read('glossary_view');
-        if (empty($view)) {
-            Session::write('glossary_view', $view);
-        }
+        $view = self::getGlossaryView();
         // action links
         //echo '<div class="actions">';
         $actionsLeft = '';
@@ -515,7 +528,7 @@ class GlossaryManager
         $direction
     ) {
         $_user = api_get_user_info();
-        $view = Session::read('glossary_view');
+        $view = self::getGlossaryView();
 
         // Database table definition
         $t_glossary = Database::get_course_table(TABLE_GLOSSARY);

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

@@ -621,6 +621,9 @@ $_configuration['gradebook_badge_sidebar'] = [
 // Disable delete all announcements button
 //$_configuration['disable_delete_all_announcements'] = false;
 
+// Default glossary view "table" or "list"
+//$_configuration['default_glossary_view'] = 'table';
+
 // Allow or block user subcriptions to a lp/lp category
 /*$_configuration['lp_subscription_settings'] = [
     'options' => [