Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

- Case sensitive search when click on a letter, fixed.

- Adding a display format manager. It controls the behavior of the display format when the user enter the glossary and when an auto-link is shown.
- Adding support to the new fullname function.
  • Loading branch information...
commit b6862360af8412253b3cfa2f8b8751467aea0461 1 parent 0dafa92
authored November 19, 2003
7  lang/en/glossary.php
@@ -35,6 +35,12 @@
35 35
 $string['cnflinkentry'] = 'Define if an entry should be automatically linked by default';
36 36
 $string['cnflinkglossaries'] = 'Define if a glossary should be automatically linked by default';
37 37
 $string['cnfstudentcanpost'] = 'Define if the students can or cannot post entries by default';
  38
+$string['cnfrelatedview'] = 'Select the display format to be used for automatic linking and entry view.';
  39
+$string['cnfdefaultmode'] = 'Select the default frame to show when the glossary is first viewed.';
  40
+$string['cnfdefaulthook'] = 'Select the default selection to show when the glossary is first viewed';
  41
+$string['cnfsortkey']     = 'Select the sorting key by default.';
  42
+$string['cnfsortorder']   = 'Select the sorting order by default.';
  43
+$string['cnfshowgroup']   = 'Specify if the group break should be shown or not.';
38 44
 $string['comment'] = 'Comment';
39 45
 $string['commentdeleted'] = 'The comment has been deleted.';
40 46
 $string['comments'] = 'Comments';
@@ -53,6 +59,7 @@
53 59
 $string['descending'] = '(descending)';
54 60
 $string['destination'] = 'Destination';
55 61
 $string['displayformat'] = 'Display format';
  62
+$string['displayformats'] = 'Display formats';
56 63
 $string['displayformat2'] = 'Full with author';
57 64
 $string['displayformat3'] = 'Encyclopedia';
58 65
 $string['displayformat4'] = 'FAQ';
1  mod/glossary/TODO.txt
@@ -6,6 +6,7 @@ Things that are in the inkpot yet:
6 6
     * Default view
7 7
 	* Default Order
8 8
 	* Show (or do not) the group breaks.
  9
+        * Default view for automatic links, entry view, etc.
9 10
 	* What else? Post in http://moodle.org/mod/forum/view.php?id=742
10 11
 
11 12
 - Allow grading of entries
78  mod/glossary/config.html
@@ -188,9 +188,85 @@
188 188
     <?php print_string("cnffullmatch", "glossary") ?>
189 189
     </td>
190 190
 </tr>
  191
+<tr valign=top>
  192
+    <td colspan = 3 align=center><a name=formats><strong>Display Formats Setup</strong></td>
  193
+</tr>
  194
+<tr>
  195
+    <td colspan=3 align=center>
  196
+<?php
  197
+    if ( !$displayformat = get_record("glossary_displayformats","fid",0) ) {
  198
+        unset($displayformat);
  199
+        $displayformat->fid = 0;
  200
+        $displayformat->relatedview = 0;
  201
+        $displayformat->visible = 1;
  202
+        $displayformat->id = insert_record("glossary_displayformats",$displayformat);
  203
+    }
  204
+    if ( !$displayformat = get_record("glossary_displayformats","fid",1) ) {
  205
+        unset($displayformat);
  206
+        $displayformat->fid = 1;
  207
+        $displayformat->relatedview = 1;
  208
+        $displayformat->visible = 1;
  209
+        $displayformat->id = insert_record("glossary_displayformats",$displayformat);
  210
+    }
  211
+
  212
+    $formats = array();
  213
+    $formats[0] = get_string("displayformatdefault", "glossary");
  214
+    $formats[1] = get_string("displayformatcontinuous", "glossary");
  215
+
  216
+    $basedir = opendir("$CFG->dirroot/mod/glossary/formats");
  217
+    while ($dir = readdir($basedir)) {
  218
+        $firstchar = substr($dir, 0, 1);
  219
+        if ($firstchar == "." or $dir == "CVS" or $dir == "_vti_cnf") {
  220
+            continue;
  221
+        }
  222
+        if (filetype("$CFG->dirroot/mod/glossary/formats/$dir") == "dir") {
  223
+            continue;
  224
+        }
  225
+        if ( $pos = strpos($dir, ".") ) {
  226
+            $dir = substr($dir, 0, $pos );
  227
+            if ($dir != 0 and $dir != 1) {  // excluding basic formats
  228
+                if ( !$displayformat = get_record("glossary_displayformats","fid",$dir) ) {
  229
+                    unset($displayformat);
  230
+                    $displayformat->fid = $dir;
  231
+                    $displayformat->relatedview = $dir;
  232
+                    $displayformat->visible = 1;
  233
+                    $displayformat->id = insert_record("glossary_displayformats",$displayformat);
  234
+                }
  235
+                $formats[$dir] = get_string("displayformat$dir", "glossary");
  236
+            }
  237
+        }
  238
+    }
  239
+    asort($formats);
  240
+
  241
+    echo '<table cellpadding="5" bgcolor="#FFFFFF" class="generaltab" width="40%" align="center" style="border-style: solid; border-width: 1px;">';
  242
+    for ($i = 0; $i <= count($formats); $i++) {
  243
+        if ( $formats[$i] ) {
  244
+            $format = get_record("glossary_displayformats","fid",$i);
  245
+            echo '<tr>';
  246
+                echo '<td>' . $formats[$i] . '</td>';
  247
+                $eicon = "<a title=\"" . get_string("edit") . "\" href=\"$CFG->wwwroot/mod/glossary/formats.php?id=$i&mode=edit\"><img border=\"0\" src=\"../pix/t/edit.gif\"></a>";
  248
+                if ( $format->visible ) {
  249
+                    $vtitle = get_string("hide");
  250
+                    $vicon = "hide.gif";
  251
+                } else {
  252
+                    $vtitle = get_string("show");
  253
+                    $vicon = "show.gif";
  254
+                }
  255
+                $vicon = "<a title=\"" . $vtitle . "\" href=\"$CFG->wwwroot/mod/glossary/formats.php?id=$i&mode=visible\"><img border=\"0\" src=\"../pix/t/" . $vicon . "\"></a>";
  256
+
  257
+                echo '<td align="center"> ' . $eicon . '&nbsp;&nbsp;' . $vicon . '</td>';
  258
+            echo '</tr>';
  259
+        }
  260
+    }
  261
+    echo '</table>';
  262
+
  263
+?>
  264
+
  265
+	</td>
  266
+</tr>
191 267
 <tr>
192 268
     <td colspan=3 align=center>
193  
-    <input type="submit" value="<?php print_string("savechanges") ?>"></td>
  269
+	<input type="submit" value="<?php print_string("savechanges") ?>"></td>
194 270
 </tr>
195 271
 </table>
196 272
 
45  mod/glossary/db/mysql.php
@@ -174,6 +174,51 @@ function glossary_upgrade($oldversion) {
174 174
                      ADD `entbypage`  TINYINT(3) UNSIGNED NOT NULL DEFAULT '10' AFTER `globalglossary`" );
175 175
                      
176 176
     }
  177
+
  178
+    if ( $oldversion < 2003111800 ) {
  179
+        execute_sql("CREATE TABLE `{$CFG->prefix}glossary_displayformats` (
  180
+                    `id` INT(10) unsigned NOT NULL auto_increment,
  181
+                    `fid` INT(10) UNSIGNED NOT NULL default '0',
  182
+                    `visible` TINYINT(2) UNSIGNED NOT NULL default '1',
  183
+                    `relatedview` TINYINT(3) NOT NULL default '-1',
  184
+                    `showgroup` TINYINT(2) UNSIGNED NOT NULL default '1',
  185
+                    `defaultmode` VARCHAR(50) NOT NULL default '',
  186
+                    `defaulthook` VARCHAR(50) NOT NULL default '',
  187
+                    `sortkey` VARCHAR(50) NOT NULL default '',
  188
+                    `sortorder` VARCHAR(50) NOT NULL default '',
  189
+                    PRIMARY KEY  (`id`)
  190
+                    ) TYPE=MyISAM COMMENT='Setting of the display formats'");
  191
+
  192
+        // Default format
  193
+        execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats 
  194
+                      (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
  195
+                      VALUES (0,0,'letter','ALL','CREATION','asc',1,1)");
  196
+        // Continuous format
  197
+        execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats 
  198
+                      (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
  199
+                      VALUES (1,1,'date','ALL','CREATION','asc',0,1)");
  200
+        // Full w/author View
  201
+        execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats 
  202
+                      (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
  203
+                      VALUES (2,2,'letter','ALL','CREATION','asc',1,1)");
  204
+        // Encyclopedia
  205
+        execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats 
  206
+                      (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
  207
+                      VALUES (3,3,'letter','ALL','CREATION','asc',1,1)");
  208
+        // FAQ View
  209
+        execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats 
  210
+                      (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
  211
+                      VALUES (4,4,'date','ALL','CREATION','asc',0,1)");
  212
+        // Full w/o author View
  213
+        execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats 
  214
+                      (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
  215
+                      VALUES (5,5,'letter','ALL','CREATION','asc',1,1)");
  216
+        // Entry list
  217
+        execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats 
  218
+                      (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
  219
+                      VALUES (6,0,'letter','ALL','CREATION','asc',1,1)");
  220
+
  221
+    }
177 222
     return true;
178 223
 }
179 224
 
17  mod/glossary/db/mysql.sql
@@ -98,6 +98,23 @@ CREATE TABLE prefix_glossary_comments (
98 98
      PRIMARY KEY  (id)
99 99
 ) TYPE=MyISAM COMMENT='comments on glossary entries';
100 100
 
  101
+CREATE TABLE prefix_glossary_displayformats (
  102
+     id int(10) unsigned NOT NULL auto_increment,
  103
+     fid int(10) unsigned NOT NULL default '0',
  104
+     visible tinyint(2) unsigned NOT NULL default '1',
  105
+
  106
+     relatedview tinyint(3) NOT NULL default '-1',
  107
+     showgroup tinyint(2) unsigned NOT NULL default '1',
  108
+
  109
+     defaultmode varchar(50) NOT NULL default '',
  110
+     defaulthook varchar(50) NOT NULL default '',
  111
+	 
  112
+     sortkey varchar(50) NOT NULL default '',
  113
+     sortorder varchar(50) NOT NULL default '',
  114
+	 
  115
+     PRIMARY KEY  (id)
  116
+) TYPE=MyISAM COMMENT='Setting of the display formats';
  117
+
101 118
 #
102 119
 # Dumping data for table `log_display`
103 120
 #
38  mod/glossary/dynalink.php
@@ -12,7 +12,6 @@ function glossary_dynamic_link($courseid, $text) {
@@ -35,7 +34,7 @@ function glossary_dynamic_link($courseid, $text) {
@@ -49,19 +48,23 @@ function glossary_dynamic_link($courseid, $text) {
@@ -73,9 +76,12 @@ function glossary_dynamic_link($courseid, $text) {
@@ -97,6 +103,7 @@ function glossary_link_concepts($text,$concept,$href_tag_begin,$href_tag_end = "
@@ -153,18 +160,19 @@ function glossary_link_concepts($text,$concept,$href_tag_begin,$href_tag_end = "
6  mod/glossary/edit.php
@@ -52,6 +52,7 @@
52 52
     $newentry->casesensitive = $form->casesensitive;
53 53
     $newentry->fullmatch = $form->fullmatch;
54 54
     $newentry->timemodified = $timenow;		
  55
+    $newentry->approved = $glossary->defaultapproval or isteacher($course->id);
55 56
 
56 57
     if ($form->concept == '' or trim($form->text) == '' ) {
57 58
         $errors = get_string('fillfields','glossary');
@@ -108,7 +109,7 @@
108 109
             if (! update_record("glossary_entries", $newentry)) {
109 110
                 error("Could not update your glossary");
110 111
             } else {
111  
-                add_to_log($course->id, "glossary", "update entry", "view.php?id=$cm->id&mode=entry&hook=$newentry->id", "$newentry->id");
  112
+                add_to_log($course->id, "glossary", "update entry", "view.php?id=$cm->id&mode=entry&hook=$newentry->id", $newentry->id);
112 113
            	}
113 114
         } else {
114 115
             error("Could not update this glossary entry because this concept already exist.");
@@ -117,7 +118,6 @@
117 118
         $newentry->userid = $USER->id;
118 119
         $newentry->timecreated = $timenow;
119 120
         $newentry->sourceglossaryid = 0;
120  
-        $newentry->approved = $glossary->defaultapproval or isteacher($course->id);
121 121
         $newentry->teacherentry = isteacher($course->id);
122 122
 
123 123
         $permissiongranted = 1;
@@ -137,7 +137,7 @@
137 137
                      unset($newentry->attachment);
138 138
                 }
139 139
                 set_field("glossary_entries", "attachment", $newfilename, "id", $newentry->id);
140  
-                add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id&mode=entry&hook=$newentry->id", "$newentry->id");
  140
+                add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id&mode=entry&hook=$newentry->id", $newentry->id);
141 141
             }
142 142
         } else {
143 143
             error("Could not insert this glossary entry because this concept already exist.");
295  mod/glossary/formats.php
... ...
@@ -0,0 +1,295 @@
  1
+<?PHP  
  2
+    /// This file allows to manage the default behave of the display formats
  3
+    
  4
+    require_once("../../config.php");
  5
+    require_once("lib.php");
  6
+    global $CFG, $THEME;
  7
+        
  8
+    require_variable($id);    
  9
+    optional_variable($mode); 
  10
+    	
  11
+    require_login();
  12
+    if ( !isadmin() ) {
  13
+        error("You must be an admin to use this page.");
  14
+    }
  15
+    if (!$site = get_site()) {
  16
+        error("Site isn't defined!");
  17
+    }
  18
+    
  19
+    if ( !$displayformat = get_record("glossary_displayformats","fid",$id) ) {
  20
+        unset($displayformat);
  21
+        $displayformat->fid = $id;
  22
+        $displayformat->id = insert_record("glossary_displayformats",$displayformat);
  23
+    }
  24
+
  25
+    $form = data_submitted();
  26
+    if ( $mode == 'visible' ) {
  27
+        if ( $displayformat ) {
  28
+            if ( $displayformat->visible ) {
  29
+                $displayformat->visible = 0;
  30
+            } else {
  31
+                $displayformat->visible = 1;
  32
+            }
  33
+            update_record("glossary_displayformats",$displayformat);
  34
+        }
  35
+        redirect($_SERVER["HTTP_REFERER"]);
  36
+        die;
  37
+    } elseif ( $mode == 'edit' and $form) {
  38
+        
  39
+        $displayformat->relatedview = $form->relatedview;
  40
+        $displayformat->showgroup   = $form->showgroup;
  41
+        $displayformat->defaultmode = $form->defaultmode;
  42
+        $displayformat->defaulthook = $form->defaulthook;
  43
+        $displayformat->sortkey     = $form->sortkey;
  44
+        $displayformat->sortorder   = $form->sortorder;
  45
+        
  46
+        update_record("glossary_displayformats",$displayformat);
  47
+        redirect("../../admin/module.php?module=glossary#formats");
  48
+        die;
  49
+    }
  50
+    
  51
+    $stradmin = get_string("administration");
  52
+    $strconfiguration = get_string("configuration");
  53
+    $strmanagemodules = get_string("managemodules");
  54
+    $strmodulename = get_string("modulename", "glossary");
  55
+    $strdisplayformats = get_string("displayformats","glossary");
  56
+
  57
+    print_header("$site->shortname: $strmodulename: $strconfiguration", $site->fullname,
  58
+                  "<a href=\"../../admin/index.php\">$stradmin</a> -> ".
  59
+                  "<a href=\"../../admin/configure.php\">$strconfiguration</a> -> ".
  60
+                  "<a href=\"../../admin/modules.php\">$strmanagemodules</a> -> <a href=\"../../admin/module.php?module=glossary\">$strmodulename</a> -> $strdisplayformats");
  61
+
  62
+    print_heading($strmodulename . ': ' . get_string("displayformats","glossary"));
  63
+
  64
+    echo '<table width="90%" align="center" bgcolor="#FFFFFF" class="generaltab" style="border-color: #000000; border-style: solid; border-width: 1px;">';
  65
+    echo '<tr><td align=center>';
  66
+    echo get_string("configwarning");
  67
+    echo '</td></tr></table>';
  68
+
  69
+    $yes = get_string("yes");
  70
+    $no  = get_string("no");
  71
+
  72
+    echo '<form method="post" action="formats.php" name="form">';
  73
+    echo '<table width="90%" align="center" bgcolor="' . $THEME->cellheading . '" class="generalbox">';
  74
+    ?>
  75
+	<tr>
  76
+	    <td colspan=3 align=center><strong>
  77
+		<?php 
  78
+        switch ( $id ) {
  79
+        case 0: 
  80
+            echo get_string('displayformatdefault',"glossary");
  81
+        break;
  82
+        
  83
+        case 1: 
  84
+            echo get_string('displayformatcontinuous',"glossary");
  85
+        break;
  86
+        default:
  87
+            echo get_string('displayformat'.$id,"glossary");
  88
+        break;
  89
+        }
  90
+        ?>
  91
+        </strong></td>
  92
+	</tr>
  93
+    <tr valign=top>
  94
+        <td align="right" width="20%">    
  95
+			<p>Related Display Format:</td>
  96
+        <td>
  97
+        <SELECT size=1 name=relatedview>
  98
+        <OPTION value=0 <?php if ( $displayformat->relatedview == 0 ) {
  99
+                                  echo " SELECTED ";
  100
+                              }
  101
+                        ?>><?php p(get_string("displayformatdefault","glossary"))?></OPTION>
  102
+        <OPTION value=1 <?php if ( $displayformat->relatedview == 1 ) {
  103
+                                  echo " SELECTED ";
  104
+                              }
  105
+                        ?>><?php p(get_string("displayformatcontinuous","glossary"))?></OPTION>
  106
+     <?PHP
  107
+        $i = 2;        
  108
+        $dpname = get_string("displayformat".$i,"glossary");
  109
+        $file = "$CFG->dirroot/mod/glossary/formats/$i.php";        
  110
+        while ( file_exists($file) ) {
  111
+            echo '<OPTION value="' . $i . '"';
  112
+            if ( $displayformat->relatedview == $i ) {
  113
+                echo " SELECTED ";
  114
+            }
  115
+            echo '> ' . get_string("displayformat".$i,"glossary") . '</OPTION>';
  116
+            $i++;
  117
+            $file = "$CFG->dirroot/mod/glossary/formats/$i.php";
  118
+        }
  119
+     ?>
  120
+        </SELECT>
  121
+        </td>
  122
+        <td width="60%">
  123
+        <?php print_string("cnfrelatedview", "glossary") ?><br \><br \>
  124
+        </td>
  125
+    </tr>
  126
+    <tr valign=top>
  127
+        <td align="right" width="20%"><p>Default Mode:</td>
  128
+        <td>
  129
+        <SELECT size=1 name=defaultmode>
  130
+    <?php 
  131
+        $sletter = '';
  132
+        $scat = '';
  133
+        $sauthor = '';
  134
+        $sdate = '';
  135
+        switch ( strtolower($displayformat->defaultmode) ) {
  136
+        case 'letter': 
  137
+            $sletter = ' SELECTED ';
  138
+        break;
  139
+        
  140
+        case 'cat': 
  141
+            $scat = ' SELECTED ';
  142
+        break;
  143
+        
  144
+        case 'date': 
  145
+            $sdate = ' SELECTED ';
  146
+        break;
  147
+
  148
+        case 'author': 
  149
+            $sauthor = ' SELECTED ';
  150
+        break;
  151
+        }
  152
+    ?>
  153
+        <OPTION value="letter" <?PHP p($sletter)?>>letter</OPTION>
  154
+        <OPTION value="cat" <?PHP p($scat)?>>cat</OPTION>
  155
+        <OPTION value="date" <?PHP p($sdate)?>>date</OPTION>
  156
+        <OPTION value="author" <?PHP p($sauthor)?>>author</OPTION>
  157
+        </SELECT>
  158
+        </td>
  159
+        <td width="60%">
  160
+        <?php print_string("cnfdefaultmode", "glossary") ?><br \><br \>
  161
+        </td>
  162
+    </tr>
  163
+    <tr valign=top>
  164
+        <td align="right" width="20%"><p>Default Hook:</td>
  165
+        <td>
  166
+        <SELECT size=1 name=defaulthook>
  167
+    <?php 
  168
+        $sall = '';
  169
+        $sspecial = '';
  170
+        $sallcategories = '';
  171
+        $snocategorised = '';
  172
+        switch ( strtolower($displayformat->defaulthook) ) {
  173
+        case 'all': 
  174
+            $sall = ' SELECTED ';
  175
+        break;
  176
+        
  177
+        case 'special': 
  178
+            $sspecial = ' SELECTED ';
  179
+        break;
  180
+        
  181
+        case '0': 
  182
+            $sallcategories = ' SELECTED ';
  183
+        break;
  184
+
  185
+        case '-1': 
  186
+            $snocategorised = ' SELECTED ';
  187
+        break;
  188
+        }
  189
+    ?>
  190
+        <OPTION value="ALL" <?PHP p($sall)?>><?PHP p(get_string("allentries","glossary"))?></OPTION>
  191
+        <OPTION value="SPECIAL" <?PHP p($sspecial)?>><?PHP p(get_string("special","glossary"))?></OPTION>
  192
+        <OPTION value="0" <?PHP p($sallcategories)?>><?PHP p(get_string("allcategories","glossary"))?></OPTION>
  193
+        <OPTION value="-1" <?PHP p($snocategorised)?>><?PHP p(get_string("notcategorised","glossary"))?></OPTION>
  194
+        </SELECT>
  195
+        </td>
  196
+        <td width="60%">
  197
+        <?php print_string("cnfdefaulthook", "glossary") ?><br \><br \>
  198
+        </td>
  199
+    </tr>
  200
+    <tr valign=top>
  201
+        <td align="right" width="20%"><p>Default Sort Key:</td>
  202
+        <td>
  203
+        <SELECT size=1 name=sortkey>
  204
+    <?php 
  205
+        $sfname = '';
  206
+        $slname = '';
  207
+        $supdate = '';
  208
+        $screation = '';
  209
+        switch ( strtolower($displayformat->sortkey) ) {
  210
+        case 'firstname': 
  211
+            $sfname = ' SELECTED ';
  212
+        break;
  213
+        
  214
+        case 'lastname': 
  215
+            $slname = ' SELECTED ';
  216
+        break;
  217
+        
  218
+        case 'creation': 
  219
+            $screation = ' SELECTED ';
  220
+        break;
  221
+
  222
+        case 'update': 
  223
+            $supdate = ' SELECTED ';
  224
+        break;
  225
+        }
  226
+    ?>
  227
+        <OPTION value="CREATION" <?PHP p($screation)?>><?PHP p(get_string("sortbycreation","glossary"))?></OPTION>
  228
+        <OPTION value="UPDATE" <?PHP p($supdate)?>><?PHP p(get_string("sortbylastupdate","glossary"))?></OPTION>
  229
+        <OPTION value="FIRSTNAME" <?PHP p($sfname)?>><?PHP p(get_string("firstname"))?></OPTION>
  230
+        <OPTION value="LASTNAME" <?PHP p($slname)?>><?PHP p(get_string("lastname"))?></OPTION>
  231
+        </SELECT>
  232
+        </td>
  233
+        <td width="60%">
  234
+        <?php print_string("cnfsortkey", "glossary") ?><br \><br \>
  235
+        </td>
  236
+    </tr>
  237
+    <tr valign=top>
  238
+        <td align="right" width="20%"><p>Default Sort Order:</td>
  239
+        <td>
  240
+        <SELECT size=1 name=sortorder>
  241
+    <?php 
  242
+        $sasc = '';
  243
+        $sdesc = '';
  244
+        switch ( strtolower($displayformat->sortorder) ) {
  245
+        case 'asc': 
  246
+            $sasc = ' SELECTED ';
  247
+        break;
  248
+        
  249
+        case 'desc': 
  250
+            $sdesc = ' SELECTED ';
  251
+        break;
  252
+        }
  253
+    ?>
  254
+        <OPTION value="asc" <?PHP p($sasc)?>><?PHP p(get_string("ascending","glossary"))?></OPTION>
  255
+        <OPTION value="desc" <?PHP p($sdesc)?>><?PHP p(get_string("descending","glossary"))?></OPTION>
  256
+        </SELECT>
  257
+        </td>
  258
+        <td width="60%">
  259
+        <?php print_string("cnfsortorder", "glossary") ?><br \><br \>
  260
+        </td>
  261
+    </tr>
  262
+    <tr valign=top>
  263
+        <td align="right" width="20%"><p>Include Group Breaks:</td>
  264
+        <td>
  265
+        <SELECT size=1 name=showgroup>
  266
+    <?php 
  267
+        $yselected = "";
  268
+        $nselected = "";
  269
+        if ($displayformat->showgroup) {
  270
+            $yselected = " SELECTED ";
  271
+        } else {
  272
+            $nselected = " SELECTED ";
  273
+        }
  274
+    ?>
  275
+        <OPTION value=1 <?php p($yselected) ?>><?php p($yes)?></OPTION>
  276
+        <OPTION value=0 <?php p($nselected) ?>><?php p($no)?></OPTION>
  277
+        </SELECT>
  278
+        </td>
  279
+        <td width="60%">
  280
+        <?php print_string("cnfshowgroup", "glossary") ?><br \><br \>
  281
+        </td>
  282
+    </tr>
  283
+	<tr>
  284
+	    <td colspan=3 align=center>
  285
+		<input type="submit" value="<?php print_string("savechanges") ?>"></td>
  286
+	</tr>
  287
+    <input type="hidden" name=id    value="<?php p($id) ?>">
  288
+    <input type="hidden" name=mode    value="edit">
  289
+	<?PHP
  290
+	
  291
+    print_simple_box_end();    
  292
+    echo '</form>';
  293
+
  294
+    print_footer();
  295
+?>
2  mod/glossary/formats/2.php
@@ -25,7 +25,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $mode="
25 25
         glossary_print_entry_concept($entry);
26 26
 		echo "</b><br />";
27 27
 
28  
-        echo "<font size=\"2\">$strby $user->firstname $user->lastname</font>";
  28
+        echo "<font size=\"2\">$strby " . fullname($user, isteacher($course->id)) . "</font>";
29 29
         echo "&nbsp;&nbsp;<font size=1>(".get_string("lastedited").": ".
30 30
              userdate($entry->timemodified).")</font>";
31 31
         echo "</tr>";
2  mod/glossary/formats/3.php
@@ -20,7 +20,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $mode="
20 20
         echo "<b>";
21 21
         glossary_print_entry_concept($entry);
22 22
 		echo "</b><br />";
23  
-        echo "<font size=\"2\">$strby $user->firstname $user->lastname</font>";
  23
+        echo "<font size=\"2\">$strby " . fullname($user, isteacher($course->id)) . "</font>";
24 24
         echo "&nbsp;&nbsp;<font size=1>(".get_string("lastedited").": ".
25 25
              userdate($entry->timemodified).")</font>";
26 26
         echo "</tr>";
2  mod/glossary/formats/6.php
@@ -10,7 +10,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$mode=""
10 10
     echo "\n<tr>";
11 11
     echo "<td width=100% bgcolor=\"$colour\">";
12 12
     if ($entry) {
13  
-        echo "<b><a href=\"view.php?id=$cm->id&mode=entry&hook=$entry->id&displayformat=2\">";
  13
+        echo "<b><a href=\"view.php?id=$cm->id&mode=entry&hook=$entry->id\">";
14 14
 
15 15
         glossary_print_entry_concept($entry);
16 16
         echo '</a></b> ';
10  mod/glossary/lib.php
@@ -879,7 +879,7 @@ function glossary_print_tabbed_table_start($data, $currenttab, $tTHEME = NULL) {
879 879
                          $currentcolor = $tabcolor;
880 880
                          $currentstyle = 'generaltab';
881 881
                     }
882  
-                    echo "<td class=\"$currentstyle\" width=\"$tabwidth%\" bgcolor=\"$currentcolor\" align=\"center\"><b>";
  882
+                    echo "<td class=\"$currentstyle\" width=\"$tabwidth%\" bgcolor=\"$currentcolor\" align=\"center\" style=\"border-color: #000000; border-style: solid; border-width: 1px;\"><b>";
883 883
                     if ($tabproccessed != $currenttab and $data[$tabproccessed]->link) {
884 884
                         echo "<a href=\"" . $data[$tabproccessed]->link . "\">";
885 885
                     }
@@ -925,7 +925,7 @@ function glossary_print_tabbed_table_start($data, $currenttab, $tTHEME = NULL) {
925 925
                          $currentcolor = $tabcolor;
926 926
                          $currentstyle = 'generaltab';
927 927
                     }
928  
-                    echo "<td class=\"$currentstyle\" width=\"$tabwidth%\" bgcolor=\"$currentcolor\" align=\"center\"><b>";
  928
+                    echo "<td class=\"$currentstyle\" width=\"$tabwidth%\" bgcolor=\"$currentcolor\" align=\"center\" style=\"border-color: #000000; border-style: solid; border-width: 1px;\"><b>";
929 929
                     if ($tabproccessed != $currenttab and $data[$tabproccessed]->link) {
930 930
                         echo "<a href=\"" . $data[$tabproccessed]->link . "\">";
931 931
                     }
@@ -1289,8 +1289,10 @@ function glossary_print_dynaentry($courseid, $entries, $displayformat = -1) {
1289 1289
             }
1290 1290
             $dp = $displayformat;
1291 1291
             // Hard-coded until the Display formats manager is done.
1292  
-            if ( $dp == -1 and $glossary->displayformat == 6 ) {
1293  
-                $dp = 2;
  1292
+            if ( $dprecord = get_record("glossary_displayformats","fid", $glossary->displayformat) ) {
  1293
+                if ( $dprecord->relatedview >= 0 ) {
  1294
+                    $dp = $dprecord->relatedview;
  1295
+                }
1294 1296
             }
1295 1297
             glossary_print_entry($course, $cm, $glossary, $entry, "","",0,$dp);
1296 1298
         }
5  mod/glossary/mod.html
@@ -250,7 +250,10 @@
250 250
         if ( $pos = strpos($dir, ".") ) {
251 251
             $dir = substr($dir, 0, $pos );
252 252
             if ($dir != 0 and $dir != 1) {  // excluding basic formats
253  
-                $formats[$dir] = get_string("displayformat$dir", "glossary");
  253
+                $dp = get_record("glossary_displayformats","fid",$dir);
  254
+                if ( !$dp or $dp->visible ) {
  255
+                    $formats[$dir] = get_string("displayformat$dir", "glossary");
  256
+                }
254 257
             }
255 258
         }
256 259
     }
170  mod/glossary/print.php
@@ -105,6 +105,17 @@
105 105
     break;
106 106
     }  
107 107
 
  108
+    switch ( $sortkey ) {    
  109
+    case "CREATION": 
  110
+        $sortkey = "timecreated";
  111
+    break;
  112
+    
  113
+    case "UPDATE": 
  114
+        $sortkey = "timemodified";
  115
+    default:
  116
+    break;
  117
+    }
  118
+
108 119
     include_once("sql.php");
109 120
     
110 121
     $entriesshown = 0;
@@ -119,95 +130,96 @@
119 130
     echo '<strong>' . $site->fullname . '</strong><br>';
120 131
     echo get_string("course") . ': <strong>' . $course->fullname . '</strong><br \>';
121 132
     echo get_string("modulename","glossary") . ': <strong>' . $glossary->name . '</strong><p>';
  133
+    if ( $allentries ) {
  134
+        foreach ($allentries as $entry) {
  135
+        /// Setting the pivot for the current entry
  136
+            $pivot = $entry->pivot;
  137
+            if ( !$fullpivot ) {
  138
+                $pivot = $pivot[0];
  139
+            }            
  140
+            
  141
+        /// 
  142
+        /// Validating special cases not covered by the SQL statement
  143
+        /// 
122 144
     
123  
-    foreach ($allentries as $entry) {
124  
-    /// Setting the pivot for the current entry
125  
-        $pivot = $entry->pivot;
126  
-        if ( !$fullpivot ) {
127  
-            $pivot = $pivot[0];
128  
-        }            
129  
-        
130  
-    /// 
131  
-    /// Validating special cases not covered by the SQL statement
132  
-    /// 
133  
-
134  
-    /// if we're browsing by alphabet and the current concept does not begin with
135  
-    ///     the letter we are look for.
136  
-        $showentry = 1;
137  
-        if ( $mode == 'letter' and $hook != 'SPECIAL' and $hook != 'ALL' ) {
138  
-            if ( substr($entry->concept, 0, strlen($hook)) != $hook ) {
139  
-                $showentry = 0;
140  
-            }
141  
-        } 
142  
-        
143  
-    /// if we're browsing for letter, looking for special characters not covered
144  
-    ///     in the alphabet 
145  
-        if ( $showentry and $hook == 'SPECIAL' ) {
146  
-            $initial = $entry->concept[0];
147  
-            for ($i = 0; $i < count($alphabet); $i++) {
148  
-                $curletter = $alphabet[$i];
149  
-                if ( $curletter == $initial ) {
150  
-
  145
+        /// if we're browsing by alphabet and the current concept does not begin with
  146
+        ///     the letter we are look for.
  147
+            $showentry = 1;
  148
+            if ( $mode == 'letter' and $hook != 'SPECIAL' and $hook != 'ALL' ) {
  149
+                if ( substr($entry->concept, 0, strlen($hook)) != $hook ) {
151 150
                     $showentry = 0;
152  
-                    break;
153 151
                 }
154  
-            }
155  
-        } 
156  
-
157  
-    /// if we're browsing categories, looking for entries not categorised.
158  
-        if ( $showentry and $mode == 'cat' and $hook == GLOSSARY_SHOW_NOT_CATEGORISED ) {
159  
-            if ( record_exists("glossary_entries_categories", "entryid", $entry->id)) {
160  
-                $showentry = 0;
161 152
             } 
162  
-        }
163  
-
164  
-    /// if the entry is not approved, deal with it based on the current view and
165  
-    ///     user.
166  
-        if ( $showentry and $mode != 'approval' ) {
167  
-            if ( !$entry->approved and isteacher($course->id, $entry->userid) ) {
168  
-                $showentry = 0;
169  
-            }            
170  
-        }
171  
-
172  
-        /// ok, if it's a valid entry.. Print it.
173  
-        if ( $showentry ) {
174  
-
175  
-            if ( $currentpivot != strtoupper($pivot) ) {  
176  
-
177  
-                // print the group break if apply
178  
-                if ( $printpivot )  {
179  
-                    $currentpivot = strtoupper($pivot);
180  
-                    if ( !$tableisopen ) {
181  
-                        echo '<table align="center" width="95%" bgcolor="#FFFFFF" style="border-style: solid; border-width: 1px;">';
182  
-                        $tableisopen = 1;
183  
-                    }
184  
-
185  
-                    echo '<tr>';
186  
-                    $pivottoshow = $currentpivot;
187  
-                    if ( isset($entry->uid) ) {
188  
-                    // printing the user icon if defined (only when browsing authors)
189  
-                        echo '<td colspan="2" align="left" style="border-style: solid; border-width: 1px;">';
190  
-                        $pivottoshow = $entry->uname;
191  
-                    } else {
192  
-                        echo '<td colspan="2" align="center" style="border-style: solid; border-width: 1px;">';
  153
+            
  154
+        /// if we're browsing for letter, looking for special characters not covered
  155
+        ///     in the alphabet 
  156
+            if ( $showentry and $hook == 'SPECIAL' ) {
  157
+                $initial = $entry->concept[0];
  158
+                for ($i = 0; $i < count($alphabet); $i++) {
  159
+                    $curletter = $alphabet[$i];
  160
+                    if ( $curletter == $initial ) {
  161
+    
  162
+                        $showentry = 0;
  163
+                        break;
193 164
                     }
194  
-
195  
-                    echo "<strong><i>$pivottoshow</i></strong>" ;
196  
-                    echo '</td>';
197  
-                    echo '</tr>';
198 165
                 }
  166
+            } 
  167
+    
  168
+        /// if we're browsing categories, looking for entries not categorised.
  169
+            if ( $showentry and $mode == 'cat' and $hook == GLOSSARY_SHOW_NOT_CATEGORISED ) {
  170
+                if ( record_exists("glossary_entries_categories", "entryid", $entry->id)) {
  171
+                    $showentry = 0;
  172
+                } 
199 173
             }
200  
-
201  
-            echo '<tr>';
202  
-            echo '<td width="25%" align="right" valign="top"><b>'. $entry->concept . ': </b></td>';
203  
-            echo '<td width="75%" style="border-style: solid; border-width: 1px;">';
204 174
     
205  
-            if ( $entry->attachment) {
206  
-                glossary_print_entry_attachment($entry);
  175
+        /// if the entry is not approved, deal with it based on the current view and
  176
+        ///     user.
  177
+            if ( $showentry and $mode != 'approval' ) {
  178
+                if ( !$entry->approved and isteacher($course->id, $entry->userid) ) {
  179
+                    $showentry = 0;
  180
+                }            
207 181
             }
208  
-            echo strip_tags($entry->definition);
209 182
     
210  
-            echo '<br><br></tr>';
  183
+            /// ok, if it's a valid entry.. Print it.
  184
+            if ( $showentry ) {
  185
+    
  186
+                if ( !$tableisopen ) {
  187
+                    echo '<table align="center" width="95%" bgcolor="#FFFFFF" style="border-style: solid; border-width: 1px;">';
  188
+                    $tableisopen = 1;
  189
+                }
  190
+                if ( $currentpivot != strtoupper($pivot) ) {  
  191
+                    // print the group break if apply
  192
+                    if ( $printpivot )  {
  193
+                        $currentpivot = strtoupper($pivot);
  194
+    
  195
+                        echo '<tr>';
  196
+                        $pivottoshow = $currentpivot;
  197
+                        if ( isset($entry->uid) ) {
  198
+                        // printing the user icon if defined (only when browsing authors)
  199
+                            echo '<td colspan="2" align="left" style="border-style: solid; border-width: 1px;">';
  200
+                            $user = get_record("user","id",$entry->uid);
  201
+                            $pivottoshow = fullname($user, isteacher($course->id));
  202
+                        } else {
  203
+                            echo '<td colspan="2" align="center" style="border-style: solid; border-width: 1px;">';
  204
+                        }
  205
+    
  206
+                        echo "<strong><i>$pivottoshow</i></strong>" ;
  207
+                        echo '</td>';
  208
+                        echo '</tr>';
  209
+                    }
  210
+                }
  211
+    
  212
+                echo '<tr>';
  213
+                echo '<td width="25%" align="right" valign="top"><b>'. $entry->concept . ': </b></td>';
  214
+                echo '<td width="75%" style="border-style: solid; border-width: 1px;">';
  215
+        
  216
+                if ( $entry->attachment) {
  217
+                    glossary_print_entry_attachment($entry);
  218
+                }
  219
+                echo strip_tags($entry->definition);
  220
+        
  221
+                echo '<br><br></tr>';
  222
+            }
211 223
         }
212 224
     }
213 225
     if ($tableisopen) {
6  mod/glossary/sql.php
@@ -14,7 +14,6 @@
14 14
 /// fullpivot indicate if the whole pivot should be compared agasint the db or just the first letter
15 15
 /// printpivot indicate if the pivot should be printed or not
16 16
     $fullpivot = 1;
17  
-    $printpivot = 1;
18 17
 
19 18
     $userid = '';
20 19
     if ( $USER->id ) {
@@ -77,7 +76,6 @@
77 76
             $where = "AND substr(ucase($usernamefield),1," .  strlen($hook) . ") = '" . strtoupper($hook) . "'";
78 77
         break;
79 78
         case 'mysql':
80  
-            $usernametoshow = "CONCAT(CONCAT(u.firstname,' '), u.lastname)";
81 79
             if ( $sortkey == 'FIRSTNAME' ) {
82 80
                 $usernamefield = "CONCAT(CONCAT(u.firstname,' '), u.lastname)";
83 81
             } else {
@@ -90,7 +88,7 @@
90 88
             $where = '';
91 89
         }
92 90
 
93  
-        $sqlselect  = "SELECT ge.id, $usernamefield pivot, $usernametoshow uname, u.id uid, ge.*";
  91
+        $sqlselect  = "SELECT ge.id, $usernamefield pivot, u.id uid, ge.*";
94 92
         $sqlfrom    = "FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}user u";
95 93
         $sqlwhere   = "WHERE ge.userid = u.id  AND
96 94
                              (ge.approved != 0 $userid)
@@ -170,7 +168,7 @@
170 168
                     $where = 'AND substr(ucase(concept),1,' .  strlen($hook) . ') = \'' . strtoupper($hook) . '\'';
171 169
                 break;
172 170
                 case 'mysql':
173  
-                    $where = 'AND left(ucase(concept),' .  strlen($hook) . ") = '$hook'";
  171
+                    $where = 'AND left(ucase(concept),' .  strlen($hook) . ") = '" . strtoupper($hook) . "'";
174 172
                 break;
175 173
                 }
176 174
             }
2  mod/glossary/version.php
@@ -5,7 +5,7 @@
5 5
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
6 6
 /////////////////////////////////////////////////////////////////////////////////
7 7
 
8  
-$module->version  = 2003111500;  // The current module version (Date: YYYYMMDDXX)
  8
+$module->version  = 2003111800;  // The current module version (Date: YYYYMMDDXX)
9 9
 $module->cron     = 0;           // Period for cron to check this module (secs)
10 10
 
11 11
 $release = "0.5 development";   // User-friendly version number
4  mod/glossary/view.php
@@ -58,6 +58,10 @@
58 58
         }
59 59
     } else {
60 60
         $printpivot = 1;
  61
+        if ( $mode == '' and $hook == '' and $show == '') {
  62
+            $mode = 'letter';
  63
+            $hook = 'ALL';
  64
+        }
61 65
     }
62 66
 
63 67
     if ( $displayformat == -1 ) {

0 notes on commit b686236

Please sign in to comment.
Something went wrong with that request. Please try again.