]> git.mjollnir.org Git - moodle.git/commitdiff
Some defaults applied to paramenters was preventing defaults based
authorstronk7 <stronk7>
Sun, 9 Apr 2006 10:45:14 +0000 (10:45 +0000)
committerstronk7 <stronk7>
Sun, 9 Apr 2006 10:45:14 +0000 (10:45 +0000)
on formats to work properly.

mod/glossary/tabs.html
mod/glossary/view.php

index 06ebfc53c6d16304a6708ac23274a25039ab417a..66292b2800fdd9daf173ed8a1e5ec38101b94b83 100644 (file)
         $hiddenentries = get_records_select("glossary_entries","glossaryid  = $glossary->id and approved = 0");
         if ($hiddenentries) {
             $data[GLOSSARY_APPROVAL_VIEW]->caption .= " (" . count($hiddenentries) . " " . get_string("entries","glossary") . ")";
-            $data[GLOSSARY_APPROVAL_VIEW]->link = "view.php?id=$id&amp;tab=".GLOSSARY_APPROVAL_VIEW;
-
             $data[GLOSSARY_APPROVAL_VIEW]->link = "view.php?id=$id&amp;mode=approval";
 
-        } elseif ( $tab == GLOSSARY_APPROVAL_VIEW ) {
-            $tab = $framebydefault;
+        } elseif ( $tab == GLOSSARY_APPROVAL_VIEW ) {  //Teachers going to approval view and without entries->go to defaulttab
+            $tab = $defaulttab;
         }
-    } elseif ( $tab == GLOSSARY_APPROVAL_VIEW ) {
-        $tab = $framebydefault;
+    } elseif ( $tab == GLOSSARY_APPROVAL_VIEW ) { //Non-teachers going to approval view go to defaulttab
+        $tab = $defaulttab;
     }
 
 /// printing header of the current tab
index 08b1102d4d2c9deff78f9f13a2a1182d2e712d1a..bd88ef1c33311f74c80d51af7ce718e3e2fe0082 100644 (file)
@@ -10,8 +10,8 @@
     $tab  = optional_param('tab', GLOSSARY_NO_VIEW, PARAM_ALPHA);    // browsing entries by categories?
     $displayformat = optional_param('displayformat',-1, PARAM_INT);  // override of the glossary display format
 
-    $mode       = optional_param('mode', 'approval', PARAM_ALPHA);   // term entry cat date letter search author approval
-    $hook       = optional_param('hook', 'ALL', PARAM_CLEAN);        // the term, entry, cat, etc... to look for based on mode
+    $mode       = optional_param('mode', '', PARAM_ALPHA);           // term entry cat date letter search author approval
+    $hook       = optional_param('hook', '', PARAM_CLEAN);           // the term, entry, cat, etc... to look for based on mode
     $fullsearch = optional_param('fullsearch', 0,PARAM_INT);         // full search (concept and definition) when searching?
     $sortkey    = optional_param('sortkey', 'CREATION', PARAM_ALPHA);// Sorted view: CREATION | UPDATE | FIRSTNAME | LASTNAME...
     $sortorder  = optional_param('sortorder', 'ASC', PARAM_ALPHA);   // it defines the order of the sorting (ASC or DESC)
 /// setting the default values for the display mode of the current glossary
 /// only if the glossary is viewed by the first time
     if ( $dp = get_record('glossary_formats','name', addslashes($glossary->displayformat)) ) {
+    /// Based on format->defaultmode, we build the defaulttab to be showed sometimes
+        switch ($dp->defaultmode) {
+            case 'cat':
+                $defaulttab = GLOSSARY_CATEGORY_VIEW;
+                break;
+            case 'date':
+                $defaulttab = GLOSSARY_DATE_VIEW;
+                break;
+            case 'author':
+                $defaulttab = GLOSSARY_AUTHOR_VIEW;
+                break;
+            default:
+                $defaulttab = GLOSSARY_STANDARD_VIEW;
+        }
+    /// Fetch the rest of variables
         $printpivot = $dp->showgroup;
         if ( $mode == '' and $hook == '' and $show == '') {
             $mode      = $dp->defaultmode;
@@ -78,6 +93,7 @@
             $sortorder = $dp->sortorder;
         }
     } else {
+        $defaulttab = GLOSSARY_STANDARD_VIEW;
         $printpivot = 1;
         if ( $mode == '' and $hook == '' and $show == '') {
             $mode = 'letter';