MDL-11082 Improved groups upgrade performance 1.8x -> 1.9; thanks Eloy for telling...
[moodle-pu.git] / mod / glossary / tabs.php
blobae0144a0bd8c7d4e0534638e4b129b483676360e
1 <?php // $Id$
2 if (!isset($sortorder)) {
3 $sortorder = '';
4 }
5 if (!isset($sortkey)) {
6 $sortkey = '';
9 //make sure variables are properly cleaned
10 $sortkey = clean_param($sortkey, PARAM_ALPHA);// Sorted view: CREATION | UPDATE | FIRSTNAME | LASTNAME...
11 $sortorder = clean_param($sortorder, PARAM_ALPHA); // it defines the order of the sorting (ASC or DESC)
13 $toolsrow = array();
14 $browserow = array();
15 $inactive = array();
16 $activated = array();
18 if (!has_capability('mod/glossary:approve', $context) && $tab == GLOSSARY_APPROVAL_VIEW) {
19 /// Non-teachers going to approval view go to defaulttab
20 $tab = $defaulttab;
24 $browserow[] = new tabobject(GLOSSARY_STANDARD_VIEW,
25 $CFG->wwwroot.'/mod/glossary/view.php?id='.$id.'&amp;mode=letter',
26 get_string('standardview', 'glossary'));
28 $browserow[] = new tabobject(GLOSSARY_CATEGORY_VIEW,
29 $CFG->wwwroot.'/mod/glossary/view.php?id='.$id.'&amp;mode=cat',
30 get_string('categoryview', 'glossary'));
32 $browserow[] = new tabobject(GLOSSARY_DATE_VIEW,
33 $CFG->wwwroot.'/mod/glossary/view.php?id='.$id.'&amp;mode=date',
34 get_string('dateview', 'glossary'));
36 $browserow[] = new tabobject(GLOSSARY_AUTHOR_VIEW,
37 $CFG->wwwroot.'/mod/glossary/view.php?id='.$id.'&amp;mode=author',
38 get_string('authorview', 'glossary'));
40 if ($tab < GLOSSARY_STANDARD_VIEW || $tab > GLOSSARY_AUTHOR_VIEW) { // We are on second row
41 $inactive = array('edit');
42 $activated = array('edit');
44 $browserow[] = new tabobject('edit', '#', get_string('edit'));
47 /// Put all this info together
49 $tabrows = array();
50 $tabrows[] = $browserow; // Always put these at the top
51 if ($toolsrow) {
52 $tabrows[] = $toolsrow;
57 <div class="glossarydisplay">
60 <?php if ($showcommonelements) { print_tabs($tabrows, $tab, $inactive, $activated); } ?>
62 <div class="entrybox">
64 <?php
66 if (!isset($category)) {
67 $category = "";
71 switch ($tab) {
72 case GLOSSARY_CATEGORY_VIEW:
73 glossary_print_categories_menu($cm, $glossary, $hook, $category);
74 break;
75 case GLOSSARY_APPROVAL_VIEW:
76 glossary_print_approval_menu($cm, $glossary, $mode, $hook, $sortkey, $sortorder);
77 break;
78 case GLOSSARY_AUTHOR_VIEW:
79 $search = "";
80 glossary_print_author_menu($cm, $glossary, "author", $hook, $sortkey, $sortorder, 'print');
81 break;
82 case GLOSSARY_IMPORT_VIEW:
83 $search = "";
84 $l = "";
85 glossary_print_import_menu($cm, $glossary, 'import', $hook, $sortkey, $sortorder);
86 break;
87 case GLOSSARY_EXPORT_VIEW:
88 $search = "";
89 $l = "";
90 glossary_print_export_menu($cm, $glossary, 'export', $hook, $sortkey, $sortorder);
91 break;
92 case GLOSSARY_DATE_VIEW:
93 if (!$sortkey) {
94 $sortkey = 'UPDATE';
96 if (!$sortorder) {
97 $sortorder = 'desc';
99 glossary_print_alphabet_menu($cm, $glossary, "date", $hook, $sortkey, $sortorder);
100 break;
101 case GLOSSARY_STANDARD_VIEW:
102 default:
103 glossary_print_alphabet_menu($cm, $glossary, "letter", $hook, $sortkey, $sortorder);
104 if ($mode == 'search' and $hook) {
105 echo "<h3>$strsearch: $hook</h3>";
107 break;
109 echo '<hr />';