]> git.mjollnir.org Git - moodle.git/commitdiff
- Case sensitive search when click on a letter, fixed.
authorwillcast <willcast>
Wed, 19 Nov 2003 17:47:40 +0000 (17:47 +0000)
committerwillcast <willcast>
Wed, 19 Nov 2003 17:47:40 +0000 (17:47 +0000)
- 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.

17 files changed:
lang/en/glossary.php
mod/glossary/TODO.txt
mod/glossary/config.html
mod/glossary/db/mysql.php
mod/glossary/db/mysql.sql
mod/glossary/dynalink.php
mod/glossary/edit.php
mod/glossary/formats.php [new file with mode: 0644]
mod/glossary/formats/2.php
mod/glossary/formats/3.php
mod/glossary/formats/6.php
mod/glossary/lib.php
mod/glossary/mod.html
mod/glossary/print.php
mod/glossary/sql.php
mod/glossary/version.php
mod/glossary/view.php

index 51b326aef7d43c7b4d582274d4ed92aebf3fc93f..2c23cc4f5fbf73230b2fc9f0ef5a678a3b7cec38 100644 (file)
@@ -35,6 +35,12 @@ $string['cnffullmatch'] = 'Define if an entry, when linked, should match the cas
 $string['cnflinkentry'] = 'Define if an entry should be automatically linked by default';
 $string['cnflinkglossaries'] = 'Define if a glossary should be automatically linked by default';
 $string['cnfstudentcanpost'] = 'Define if the students can or cannot post entries by default';
+$string['cnfrelatedview'] = 'Select the display format to be used for automatic linking and entry view.';
+$string['cnfdefaultmode'] = 'Select the default frame to show when the glossary is first viewed.';
+$string['cnfdefaulthook'] = 'Select the default selection to show when the glossary is first viewed';
+$string['cnfsortkey']     = 'Select the sorting key by default.';
+$string['cnfsortorder']   = 'Select the sorting order by default.';
+$string['cnfshowgroup']   = 'Specify if the group break should be shown or not.';
 $string['comment'] = 'Comment';
 $string['commentdeleted'] = 'The comment has been deleted.';
 $string['comments'] = 'Comments';
@@ -53,6 +59,7 @@ $string['deletingnoneemptycategory'] = 'Deleting this category will not delete t
 $string['descending'] = '(descending)';
 $string['destination'] = 'Destination';
 $string['displayformat'] = 'Display format';
+$string['displayformats'] = 'Display formats';
 $string['displayformat2'] = 'Full with author';
 $string['displayformat3'] = 'Encyclopedia';
 $string['displayformat4'] = 'FAQ';
index 38ede943e678664b1efbee2da34ce372003c7c36..e05b3d7f18942a129c27a5bb7d47cc43f49b3830 100644 (file)
@@ -6,6 +6,7 @@ Things that are in the inkpot yet:
     * Default view
        * Default Order
        * Show (or do not) the group breaks.
+        * Default view for automatic links, entry view, etc.
        * What else? Post in http://moodle.org/mod/forum/view.php?id=742
 
 - Allow grading of entries
index 60bcf6cd8d98cc73da4719e5cf293b5e7223ec96..e8d96a10c3a3a6040763a0aa80205b423799b8ba 100644 (file)
     <?php print_string("cnffullmatch", "glossary") ?>
     </td>
 </tr>
+<tr valign=top>
+    <td colspan = 3 align=center><a name=formats><strong>Display Formats Setup</strong></td>
+</tr>
+<tr>
+    <td colspan=3 align=center>
+<?php
+    if ( !$displayformat = get_record("glossary_displayformats","fid",0) ) {
+        unset($displayformat);
+        $displayformat->fid = 0;
+        $displayformat->relatedview = 0;
+        $displayformat->visible = 1;
+        $displayformat->id = insert_record("glossary_displayformats",$displayformat);
+    }
+    if ( !$displayformat = get_record("glossary_displayformats","fid",1) ) {
+        unset($displayformat);
+        $displayformat->fid = 1;
+        $displayformat->relatedview = 1;
+        $displayformat->visible = 1;
+        $displayformat->id = insert_record("glossary_displayformats",$displayformat);
+    }
+
+    $formats = array();
+    $formats[0] = get_string("displayformatdefault", "glossary");
+    $formats[1] = get_string("displayformatcontinuous", "glossary");
+
+    $basedir = opendir("$CFG->dirroot/mod/glossary/formats");
+    while ($dir = readdir($basedir)) {
+        $firstchar = substr($dir, 0, 1);
+        if ($firstchar == "." or $dir == "CVS" or $dir == "_vti_cnf") {
+            continue;
+        }
+        if (filetype("$CFG->dirroot/mod/glossary/formats/$dir") == "dir") {
+            continue;
+        }
+        if ( $pos = strpos($dir, ".") ) {
+            $dir = substr($dir, 0, $pos );
+            if ($dir != 0 and $dir != 1) {  // excluding basic formats
+                if ( !$displayformat = get_record("glossary_displayformats","fid",$dir) ) {
+                    unset($displayformat);
+                    $displayformat->fid = $dir;
+                    $displayformat->relatedview = $dir;
+                    $displayformat->visible = 1;
+                    $displayformat->id = insert_record("glossary_displayformats",$displayformat);
+                }
+                $formats[$dir] = get_string("displayformat$dir", "glossary");
+            }
+        }
+    }
+    asort($formats);
+
+    echo '<table cellpadding="5" bgcolor="#FFFFFF" class="generaltab" width="40%" align="center" style="border-style: solid; border-width: 1px;">';
+    for ($i = 0; $i <= count($formats); $i++) {
+        if ( $formats[$i] ) {
+            $format = get_record("glossary_displayformats","fid",$i);
+            echo '<tr>';
+                echo '<td>' . $formats[$i] . '</td>';
+                $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>";
+                if ( $format->visible ) {
+                    $vtitle = get_string("hide");
+                    $vicon = "hide.gif";
+                } else {
+                    $vtitle = get_string("show");
+                    $vicon = "show.gif";
+                }
+                $vicon = "<a title=\"" . $vtitle . "\" href=\"$CFG->wwwroot/mod/glossary/formats.php?id=$i&mode=visible\"><img border=\"0\" src=\"../pix/t/" . $vicon . "\"></a>";
+
+                echo '<td align="center"> ' . $eicon . '&nbsp;&nbsp;' . $vicon . '</td>';
+            echo '</tr>';
+        }
+    }
+    echo '</table>';
+
+?>
+
+       </td>
+</tr>
 <tr>
     <td colspan=3 align=center>
-    <input type="submit" value="<?php print_string("savechanges") ?>"></td>
+       <input type="submit" value="<?php print_string("savechanges") ?>"></td>
 </tr>
 </table>
 
index 71fba487b160ace86294724d9ea5cb4faf1daa54..130941f6f480a11425aab88a5af3c8bb1a69d864 100644 (file)
@@ -173,6 +173,51 @@ function glossary_upgrade($oldversion) {
         execute_sql( "ALTER TABLE `{$CFG->prefix}glossary`
                      ADD `entbypage`  TINYINT(3) UNSIGNED NOT NULL DEFAULT '10' AFTER `globalglossary`" );
                      
+    }
+
+    if ( $oldversion < 2003111800 ) {
+        execute_sql("CREATE TABLE `{$CFG->prefix}glossary_displayformats` (
+                    `id` INT(10) unsigned NOT NULL auto_increment,
+                    `fid` INT(10) UNSIGNED NOT NULL default '0',
+                    `visible` TINYINT(2) UNSIGNED NOT NULL default '1',
+                    `relatedview` TINYINT(3) NOT NULL default '-1',
+                    `showgroup` TINYINT(2) UNSIGNED NOT NULL default '1',
+                    `defaultmode` VARCHAR(50) NOT NULL default '',
+                    `defaulthook` VARCHAR(50) NOT NULL default '',
+                    `sortkey` VARCHAR(50) NOT NULL default '',
+                    `sortorder` VARCHAR(50) NOT NULL default '',
+                    PRIMARY KEY  (`id`)
+                    ) TYPE=MyISAM COMMENT='Setting of the display formats'");
+
+        // Default format
+        execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats 
+                      (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
+                      VALUES (0,0,'letter','ALL','CREATION','asc',1,1)");
+        // Continuous format
+        execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats 
+                      (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
+                      VALUES (1,1,'date','ALL','CREATION','asc',0,1)");
+        // Full w/author View
+        execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats 
+                      (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
+                      VALUES (2,2,'letter','ALL','CREATION','asc',1,1)");
+        // Encyclopedia
+        execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats 
+                      (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
+                      VALUES (3,3,'letter','ALL','CREATION','asc',1,1)");
+        // FAQ View
+        execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats 
+                      (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
+                      VALUES (4,4,'date','ALL','CREATION','asc',0,1)");
+        // Full w/o author View
+        execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats 
+                      (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
+                      VALUES (5,5,'letter','ALL','CREATION','asc',1,1)");
+        // Entry list
+        execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats 
+                      (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible)
+                      VALUES (6,0,'letter','ALL','CREATION','asc',1,1)");
+
     }
     return true;
 }
index 84b547f51931298ffa2ad1173feb19ea0d00fc71..16f8c17184af18452a59bd390a37763661c5285c 100644 (file)
@@ -98,6 +98,23 @@ CREATE TABLE prefix_glossary_comments (
      PRIMARY KEY  (id)
 ) TYPE=MyISAM COMMENT='comments on glossary entries';
 
+CREATE TABLE prefix_glossary_displayformats (
+     id int(10) unsigned NOT NULL auto_increment,
+     fid int(10) unsigned NOT NULL default '0',
+     visible tinyint(2) unsigned NOT NULL default '1',
+
+     relatedview tinyint(3) NOT NULL default '-1',
+     showgroup tinyint(2) unsigned NOT NULL default '1',
+
+     defaultmode varchar(50) NOT NULL default '',
+     defaulthook varchar(50) NOT NULL default '',
+        
+     sortkey varchar(50) NOT NULL default '',
+     sortorder varchar(50) NOT NULL default '',
+        
+     PRIMARY KEY  (id)
+) TYPE=MyISAM COMMENT='Setting of the display formats';
+
 #
 # Dumping data for table `log_display`
 #
index ea7a89fc4dfc5611ca0b0f406804b072febddb30..40eb8944b44e6f6e501088d6231f3bffa6877cd2 100644 (file)
@@ -12,7 +12,6 @@
         $GLOSSARY_CONCEPT_IS_ENTRY = 0;
         $GLOSSARY_CONCEPT_IS_CATEGORY = 1;
 
-//        $glossarieslist = get_records_select("glossary", "usedynalink != 0 and (course = $courseid or global != 0)","id");
         $glossarieslist = get_records_select("glossary", "usedynalink != 0 and (course = $courseid or globalglossary != 0)","globalglossary, id");
         if ( $glossarieslist ) {
             $glossaries = "";
@@ -35,7 +34,7 @@
             }
             
             $entries = get_records_select("glossary_entries", "glossaryid IN ($glossaries) AND usedynalink != 0 and approved != 0 and concept != ''","$ebylenght glossaryid","id,glossaryid,concept,casesensitive,$GLOSSARY_CONCEPT_IS_ENTRY category,fullmatch");
-            $categories  = get_records_select("glossary_categories", "glossaryid IN ($glossaries) AND usedynalink != 0", "$cbylenght glossaryid,id","id,glossaryid,name concept, 1 casesensitive,$GLOSSARY_CONCEPT_IS_CATEGORY category, 1 fullmatch");
+            $categories  = get_records_select("glossary_categories", "glossaryid IN ($glossaries) AND usedynalink != 0", "$cbylenght glossaryid","id,glossaryid,name concept, 1 casesensitive,$GLOSSARY_CONCEPT_IS_CATEGORY category, 1 fullmatch");
             if ( $entries and $categories ) {
                 $concepts = array_merge($entries, $categories);
                 usort($concepts,'glossary_sort_entries_by_lenght');
                 $lastglossary = 0;
                 $lastcategory = 0;                
                 foreach ( $concepts as $concept ) {
-                    if ( $lastglossary != $concept->glossaryid ) {
-                        $glossary = get_record("glossary","id",$concept->glossaryid);
-                        $lastglossary = $glossary->id;
-                    }
                     if ( $concept->category ) {
                         if ( $lastcategory != $concept->id ) {
                             $category = get_record("glossary_categories","id",$concept->id);
                             $lastcategory = $concept->id;
+                            if ( $cm->instance != $category->glossaryid  ) {
+                                $cm = get_coursemodule_from_instance("glossary", $category->glossaryid, $courseid);
+                            }
                         }
-                        $cm = get_coursemodule_from_instance("glossary", $glossary->id, $courseid);                                            
+
                         $title = strip_tags("$glossary->name: " . get_string("category","glossary"). " $category->name");
                         $href_tag_begin = "<a class=\"autolink\" title=\"$title\" href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&mode=cat&hook=$concept->id\">";
                     } else {
+                        if ( $lastglossary != $concept->glossaryid ) {
+                            $glossary = get_record("glossary","id",$concept->glossaryid);
+                            $lastglossary = $glossary->id;
+                        }
+
                         $concepttitle = urlencode($concept->concept);
                         $title = strip_tags("$glossary->name: $concepttitle");
                         $href_tag_begin = "<a target=\"entry\" class=\"autolink\" title=\"$title\" href=\"$CFG->wwwroot/mod/glossary/showentry.php?courseid=$courseid&concept=$concepttitle\" ".
                     $currentconcept = str_replace("*", "\*", $currentconcept);
                     if ( $currentconcept = trim(strip_tags($currentconcept)) ) {
                         if ( !$concept->category ) {
-                            if ( $aliases = get_records("glossary_alias","entryid",$concept->id) ) {
+                            if ( $aliases = get_records("glossary_alias","entryid",$concept->id, "alias") ) {
                                 foreach ($aliases as $alias) {
-                                    $currentconcept .= "|" . trim(strip_tags(str_replace("|", "\|", $alias->alias)));
+                                    $currentalias = str_replace("|", "\|", $alias->alias);
+                                    $currentalias = str_replace("'", "\'", $currentalias);
+                                    $currentalias = str_replace("*", "\*", $currentalias);
+                                    $currentconcept .= "|" . trim($currentalias);
                                 }
                             }
                         }
         if ($list_of_words_cp{strlen($list_of_words_cp)-1}=="|") {
             $list_of_words_cp{strlen($list_of_words_cp)-1}="";
         }
+
         $list_of_words_cp = trim($list_of_words_cp);
         if ($fullmatch) {
             $invalidprefixs = "([a-zA-Z0-9])";
         } else {
             $text = eregi_replace("$list_of_words_cp", "$href_tag_begin"."\\1"."$href_tag_end", $text);
         }
-        $text = str_replace(array_keys($final),$final,$text);
+
+        if ( $final ) {
+            $text = str_replace(array_keys($final),$final,$text);
+        }
         if ( $links ) {
             $text = str_replace(array_keys($links),$links,$text);
         }
         if ( $excludes ) {
             $text = str_replace(array_keys($excludes),$excludes,$text);
         }
-        if ( $fullmatch ) {
-            if ( isset($words) ) {
-                if ($words) {
-                    $text = str_replace(array_keys($words),$words,$text);
-                }
+        if ( $fullmatch and isset($words) ) {
+            if ($words) {
+                $text = str_replace(array_keys($words),$words,$text);
             }
         }
         return $text;
index 289c9d8453944b2778024ea55048e5c684958234..513e995c54bd06deadbed624487e19a1659048d7 100644 (file)
@@ -52,6 +52,7 @@ if ( $confirm ) {
     $newentry->casesensitive = $form->casesensitive;
     $newentry->fullmatch = $form->fullmatch;
     $newentry->timemodified = $timenow;                
+    $newentry->approved = $glossary->defaultapproval or isteacher($course->id);
 
     if ($form->concept == '' or trim($form->text) == '' ) {
         $errors = get_string('fillfields','glossary');
@@ -108,7 +109,7 @@ if ( $confirm ) {
             if (! update_record("glossary_entries", $newentry)) {
                 error("Could not update your glossary");
             } else {
-                add_to_log($course->id, "glossary", "update entry", "view.php?id=$cm->id&mode=entry&hook=$newentry->id", "$newentry->id");
+                add_to_log($course->id, "glossary", "update entry", "view.php?id=$cm->id&mode=entry&hook=$newentry->id", $newentry->id);
                }
         } else {
             error("Could not update this glossary entry because this concept already exist.");
@@ -117,7 +118,6 @@ if ( $confirm ) {
         $newentry->userid = $USER->id;
         $newentry->timecreated = $timenow;
         $newentry->sourceglossaryid = 0;
-        $newentry->approved = $glossary->defaultapproval or isteacher($course->id);
         $newentry->teacherentry = isteacher($course->id);
 
         $permissiongranted = 1;
@@ -137,7 +137,7 @@ if ( $confirm ) {
                      unset($newentry->attachment);
                 }
                 set_field("glossary_entries", "attachment", $newfilename, "id", $newentry->id);
-                add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id&mode=entry&hook=$newentry->id", "$newentry->id");
+                add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id&mode=entry&hook=$newentry->id", $newentry->id);
             }
         } else {
             error("Could not insert this glossary entry because this concept already exist.");
diff --git a/mod/glossary/formats.php b/mod/glossary/formats.php
new file mode 100644 (file)
index 0000000..323a00b
--- /dev/null
@@ -0,0 +1,295 @@
+<?PHP  
+    /// This file allows to manage the default behave of the display formats
+    
+    require_once("../../config.php");
+    require_once("lib.php");
+    global $CFG, $THEME;
+        
+    require_variable($id);    
+    optional_variable($mode); 
+       
+    require_login();
+    if ( !isadmin() ) {
+        error("You must be an admin to use this page.");
+    }
+    if (!$site = get_site()) {
+        error("Site isn't defined!");
+    }
+    
+    if ( !$displayformat = get_record("glossary_displayformats","fid",$id) ) {
+        unset($displayformat);
+        $displayformat->fid = $id;
+        $displayformat->id = insert_record("glossary_displayformats",$displayformat);
+    }
+
+    $form = data_submitted();
+    if ( $mode == 'visible' ) {
+        if ( $displayformat ) {
+            if ( $displayformat->visible ) {
+                $displayformat->visible = 0;
+            } else {
+                $displayformat->visible = 1;
+            }
+            update_record("glossary_displayformats",$displayformat);
+        }
+        redirect($_SERVER["HTTP_REFERER"]);
+        die;
+    } elseif ( $mode == 'edit' and $form) {
+        
+        $displayformat->relatedview = $form->relatedview;
+        $displayformat->showgroup   = $form->showgroup;
+        $displayformat->defaultmode = $form->defaultmode;
+        $displayformat->defaulthook = $form->defaulthook;
+        $displayformat->sortkey     = $form->sortkey;
+        $displayformat->sortorder   = $form->sortorder;
+        
+        update_record("glossary_displayformats",$displayformat);
+        redirect("../../admin/module.php?module=glossary#formats");
+        die;
+    }
+    
+    $stradmin = get_string("administration");
+    $strconfiguration = get_string("configuration");
+    $strmanagemodules = get_string("managemodules");
+    $strmodulename = get_string("modulename", "glossary");
+    $strdisplayformats = get_string("displayformats","glossary");
+
+    print_header("$site->shortname: $strmodulename: $strconfiguration", $site->fullname,
+                  "<a href=\"../../admin/index.php\">$stradmin</a> -> ".
+                  "<a href=\"../../admin/configure.php\">$strconfiguration</a> -> ".
+                  "<a href=\"../../admin/modules.php\">$strmanagemodules</a> -> <a href=\"../../admin/module.php?module=glossary\">$strmodulename</a> -> $strdisplayformats");
+
+    print_heading($strmodulename . ': ' . get_string("displayformats","glossary"));
+
+    echo '<table width="90%" align="center" bgcolor="#FFFFFF" class="generaltab" style="border-color: #000000; border-style: solid; border-width: 1px;">';
+    echo '<tr><td align=center>';
+    echo get_string("configwarning");
+    echo '</td></tr></table>';
+
+    $yes = get_string("yes");
+    $no  = get_string("no");
+
+    echo '<form method="post" action="formats.php" name="form">';
+    echo '<table width="90%" align="center" bgcolor="' . $THEME->cellheading . '" class="generalbox">';
+    ?>
+       <tr>
+           <td colspan=3 align=center><strong>
+               <?php 
+        switch ( $id ) {
+        case 0: 
+            echo get_string('displayformatdefault',"glossary");
+        break;
+        
+        case 1: 
+            echo get_string('displayformatcontinuous',"glossary");
+        break;
+        default:
+            echo get_string('displayformat'.$id,"glossary");
+        break;
+        }
+        ?>
+        </strong></td>
+       </tr>
+    <tr valign=top>
+        <td align="right" width="20%">    
+                       <p>Related Display Format:</td>
+        <td>
+        <SELECT size=1 name=relatedview>
+        <OPTION value=0 <?php if ( $displayformat->relatedview == 0 ) {
+                                  echo " SELECTED ";
+                              }
+                        ?>><?php p(get_string("displayformatdefault","glossary"))?></OPTION>
+        <OPTION value=1 <?php if ( $displayformat->relatedview == 1 ) {
+                                  echo " SELECTED ";
+                              }
+                        ?>><?php p(get_string("displayformatcontinuous","glossary"))?></OPTION>
+     <?PHP
+        $i = 2;        
+        $dpname = get_string("displayformat".$i,"glossary");
+        $file = "$CFG->dirroot/mod/glossary/formats/$i.php";        
+        while ( file_exists($file) ) {
+            echo '<OPTION value="' . $i . '"';
+            if ( $displayformat->relatedview == $i ) {
+                echo " SELECTED ";
+            }
+            echo '> ' . get_string("displayformat".$i,"glossary") . '</OPTION>';
+            $i++;
+            $file = "$CFG->dirroot/mod/glossary/formats/$i.php";
+        }
+     ?>
+        </SELECT>
+        </td>
+        <td width="60%">
+        <?php print_string("cnfrelatedview", "glossary") ?><br \><br \>
+        </td>
+    </tr>
+    <tr valign=top>
+        <td align="right" width="20%"><p>Default Mode:</td>
+        <td>
+        <SELECT size=1 name=defaultmode>
+    <?php 
+        $sletter = '';
+        $scat = '';
+        $sauthor = '';
+        $sdate = '';
+        switch ( strtolower($displayformat->defaultmode) ) {
+        case 'letter': 
+            $sletter = ' SELECTED ';
+        break;
+        
+        case 'cat': 
+            $scat = ' SELECTED ';
+        break;
+        
+        case 'date': 
+            $sdate = ' SELECTED ';
+        break;
+
+        case 'author': 
+            $sauthor = ' SELECTED ';
+        break;
+        }
+    ?>
+        <OPTION value="letter" <?PHP p($sletter)?>>letter</OPTION>
+        <OPTION value="cat" <?PHP p($scat)?>>cat</OPTION>
+        <OPTION value="date" <?PHP p($sdate)?>>date</OPTION>
+        <OPTION value="author" <?PHP p($sauthor)?>>author</OPTION>
+        </SELECT>
+        </td>
+        <td width="60%">
+        <?php print_string("cnfdefaultmode", "glossary") ?><br \><br \>
+        </td>
+    </tr>
+    <tr valign=top>
+        <td align="right" width="20%"><p>Default Hook:</td>
+        <td>
+        <SELECT size=1 name=defaulthook>
+    <?php 
+        $sall = '';
+        $sspecial = '';
+        $sallcategories = '';
+        $snocategorised = '';
+        switch ( strtolower($displayformat->defaulthook) ) {
+        case 'all': 
+            $sall = ' SELECTED ';
+        break;
+        
+        case 'special': 
+            $sspecial = ' SELECTED ';
+        break;
+        
+        case '0': 
+            $sallcategories = ' SELECTED ';
+        break;
+
+        case '-1': 
+            $snocategorised = ' SELECTED ';
+        break;
+        }
+    ?>
+        <OPTION value="ALL" <?PHP p($sall)?>><?PHP p(get_string("allentries","glossary"))?></OPTION>
+        <OPTION value="SPECIAL" <?PHP p($sspecial)?>><?PHP p(get_string("special","glossary"))?></OPTION>
+        <OPTION value="0" <?PHP p($sallcategories)?>><?PHP p(get_string("allcategories","glossary"))?></OPTION>
+        <OPTION value="-1" <?PHP p($snocategorised)?>><?PHP p(get_string("notcategorised","glossary"))?></OPTION>
+        </SELECT>
+        </td>
+        <td width="60%">
+        <?php print_string("cnfdefaulthook", "glossary") ?><br \><br \>
+        </td>
+    </tr>
+    <tr valign=top>
+        <td align="right" width="20%"><p>Default Sort Key:</td>
+        <td>
+        <SELECT size=1 name=sortkey>
+    <?php 
+        $sfname = '';
+        $slname = '';
+        $supdate = '';
+        $screation = '';
+        switch ( strtolower($displayformat->sortkey) ) {
+        case 'firstname': 
+            $sfname = ' SELECTED ';
+        break;
+        
+        case 'lastname': 
+            $slname = ' SELECTED ';
+        break;
+        
+        case 'creation': 
+            $screation = ' SELECTED ';
+        break;
+
+        case 'update': 
+            $supdate = ' SELECTED ';
+        break;
+        }
+    ?>
+        <OPTION value="CREATION" <?PHP p($screation)?>><?PHP p(get_string("sortbycreation","glossary"))?></OPTION>
+        <OPTION value="UPDATE" <?PHP p($supdate)?>><?PHP p(get_string("sortbylastupdate","glossary"))?></OPTION>
+        <OPTION value="FIRSTNAME" <?PHP p($sfname)?>><?PHP p(get_string("firstname"))?></OPTION>
+        <OPTION value="LASTNAME" <?PHP p($slname)?>><?PHP p(get_string("lastname"))?></OPTION>
+        </SELECT>
+        </td>
+        <td width="60%">
+        <?php print_string("cnfsortkey", "glossary") ?><br \><br \>
+        </td>
+    </tr>
+    <tr valign=top>
+        <td align="right" width="20%"><p>Default Sort Order:</td>
+        <td>
+        <SELECT size=1 name=sortorder>
+    <?php 
+        $sasc = '';
+        $sdesc = '';
+        switch ( strtolower($displayformat->sortorder) ) {
+        case 'asc': 
+            $sasc = ' SELECTED ';
+        break;
+        
+        case 'desc': 
+            $sdesc = ' SELECTED ';
+        break;
+        }
+    ?>
+        <OPTION value="asc" <?PHP p($sasc)?>><?PHP p(get_string("ascending","glossary"))?></OPTION>
+        <OPTION value="desc" <?PHP p($sdesc)?>><?PHP p(get_string("descending","glossary"))?></OPTION>
+        </SELECT>
+        </td>
+        <td width="60%">
+        <?php print_string("cnfsortorder", "glossary") ?><br \><br \>
+        </td>
+    </tr>
+    <tr valign=top>
+        <td align="right" width="20%"><p>Include Group Breaks:</td>
+        <td>
+        <SELECT size=1 name=showgroup>
+    <?php 
+        $yselected = "";
+        $nselected = "";
+        if ($displayformat->showgroup) {
+            $yselected = " SELECTED ";
+        } else {
+            $nselected = " SELECTED ";
+        }
+    ?>
+        <OPTION value=1 <?php p($yselected) ?>><?php p($yes)?></OPTION>
+        <OPTION value=0 <?php p($nselected) ?>><?php p($no)?></OPTION>
+        </SELECT>
+        </td>
+        <td width="60%">
+        <?php print_string("cnfshowgroup", "glossary") ?><br \><br \>
+        </td>
+    </tr>
+       <tr>
+           <td colspan=3 align=center>
+               <input type="submit" value="<?php print_string("savechanges") ?>"></td>
+       </tr>
+    <input type="hidden" name=id    value="<?php p($id) ?>">
+    <input type="hidden" name=mode    value="edit">
+       <?PHP
+       
+    print_simple_box_end();    
+    echo '</form>';
+
+    print_footer();
+?>
index b8a825b39f7f171310ddf9d2de05a846c5348006..884ad2b2e914a5d1157962c28ce2fffe6dbdd65d 100644 (file)
@@ -25,7 +25,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $mode="
         glossary_print_entry_concept($entry);
                echo "</b><br />";
 
-        echo "<font size=\"2\">$strby $user->firstname $user->lastname</font>";
+        echo "<font size=\"2\">$strby " . fullname($user, isteacher($course->id)) . "</font>";
         echo "&nbsp;&nbsp;<font size=1>(".get_string("lastedited").": ".
              userdate($entry->timemodified).")</font>";
         echo "</tr>";
index d3c582d3304674db3d0c96b5266a6102248543ba..6ff8ef69f425a7e2d14b15a45063e9966f596276 100644 (file)
@@ -20,7 +20,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $mode="
         echo "<b>";
         glossary_print_entry_concept($entry);
                echo "</b><br />";
-        echo "<font size=\"2\">$strby $user->firstname $user->lastname</font>";
+        echo "<font size=\"2\">$strby " . fullname($user, isteacher($course->id)) . "</font>";
         echo "&nbsp;&nbsp;<font size=1>(".get_string("lastedited").": ".
              userdate($entry->timemodified).")</font>";
         echo "</tr>";
index 315c4707e1ca254fcd1299307e1b98d1816dc0f8..19b53e94b3000f697203ea1d6260087dc59dd7ba 100644 (file)
@@ -10,7 +10,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$mode=""
     echo "\n<tr>";
     echo "<td width=100% bgcolor=\"$colour\">";
     if ($entry) {
-        echo "<b><a href=\"view.php?id=$cm->id&mode=entry&hook=$entry->id&displayformat=2\">";
+        echo "<b><a href=\"view.php?id=$cm->id&mode=entry&hook=$entry->id\">";
 
         glossary_print_entry_concept($entry);
         echo '</a></b> ';
index de6db255060d2537829ebae5203d247a7140f145..cb989f16ba2ea99fb1dffb22653c342c0ba18f17 100644 (file)
@@ -879,7 +879,7 @@ for ($row = 0; $row < $numrows; $row++) {
                          $currentcolor = $tabcolor;
                          $currentstyle = 'generaltab';
                     }
-                    echo "<td class=\"$currentstyle\" width=\"$tabwidth%\" bgcolor=\"$currentcolor\" align=\"center\"><b>";
+                    echo "<td class=\"$currentstyle\" width=\"$tabwidth%\" bgcolor=\"$currentcolor\" align=\"center\" style=\"border-color: #000000; border-style: solid; border-width: 1px;\"><b>";
                     if ($tabproccessed != $currenttab and $data[$tabproccessed]->link) {
                         echo "<a href=\"" . $data[$tabproccessed]->link . "\">";
                     }
@@ -925,7 +925,7 @@ for ($row = 0; $row < $numrows; $row++) {
                          $currentcolor = $tabcolor;
                          $currentstyle = 'generaltab';
                     }
-                    echo "<td class=\"$currentstyle\" width=\"$tabwidth%\" bgcolor=\"$currentcolor\" align=\"center\"><b>";
+                    echo "<td class=\"$currentstyle\" width=\"$tabwidth%\" bgcolor=\"$currentcolor\" align=\"center\" style=\"border-color: #000000; border-style: solid; border-width: 1px;\"><b>";
                     if ($tabproccessed != $currenttab and $data[$tabproccessed]->link) {
                         echo "<a href=\"" . $data[$tabproccessed]->link . "\">";
                     }
@@ -1289,8 +1289,10 @@ function glossary_print_dynaentry($courseid, $entries, $displayformat = -1) {
             }
             $dp = $displayformat;
             // Hard-coded until the Display formats manager is done.
-            if ( $dp == -1 and $glossary->displayformat == 6 ) {
-                $dp = 2;
+            if ( $dprecord = get_record("glossary_displayformats","fid", $glossary->displayformat) ) {
+                if ( $dprecord->relatedview >= 0 ) {
+                    $dp = $dprecord->relatedview;
+                }
             }
             glossary_print_entry($course, $cm, $glossary, $entry, "","",0,$dp);
         }
index d979d4640492c8e8b6324abb7fe57b32b543f1e9..35e2a4bf0ac202b864fdc6d7c1bfc8ff8f3e6087 100644 (file)
@@ -250,7 +250,10 @@ if (!$mainglossary or $mainglossary->id == $form->instance ) {
         if ( $pos = strpos($dir, ".") ) {
             $dir = substr($dir, 0, $pos );
             if ($dir != 0 and $dir != 1) {  // excluding basic formats
-                $formats[$dir] = get_string("displayformat$dir", "glossary");
+                $dp = get_record("glossary_displayformats","fid",$dir);
+                if ( !$dp or $dp->visible ) {
+                    $formats[$dir] = get_string("displayformat$dir", "glossary");
+                }
             }
         }
     }
index ad2ee87d5e9ad3d32ae6ee969bdc1795913ae47a..69c600e8a7c780b3136ff332a9310cef7b228a6d 100644 (file)
     break;
     }  
 
+    switch ( $sortkey ) {    
+    case "CREATION": 
+        $sortkey = "timecreated";
+    break;
+    
+    case "UPDATE": 
+        $sortkey = "timemodified";
+    default:
+    break;
+    }
+
     include_once("sql.php");
     
     $entriesshown = 0;
     echo '<strong>' . $site->fullname . '</strong><br>';
     echo get_string("course") . ': <strong>' . $course->fullname . '</strong><br \>';
     echo get_string("modulename","glossary") . ': <strong>' . $glossary->name . '</strong><p>';
+    if ( $allentries ) {
+        foreach ($allentries as $entry) {
+        /// Setting the pivot for the current entry
+            $pivot = $entry->pivot;
+            if ( !$fullpivot ) {
+                $pivot = $pivot[0];
+            }            
+            
+        /// 
+        /// Validating special cases not covered by the SQL statement
+        /// 
     
-    foreach ($allentries as $entry) {
-    /// Setting the pivot for the current entry
-        $pivot = $entry->pivot;
-        if ( !$fullpivot ) {
-            $pivot = $pivot[0];
-        }            
-        
-    /// 
-    /// Validating special cases not covered by the SQL statement
-    /// 
-
-    /// if we're browsing by alphabet and the current concept does not begin with
-    ///     the letter we are look for.
-        $showentry = 1;
-        if ( $mode == 'letter' and $hook != 'SPECIAL' and $hook != 'ALL' ) {
-            if ( substr($entry->concept, 0, strlen($hook)) != $hook ) {
-                $showentry = 0;
-            }
-        } 
-        
-    /// if we're browsing for letter, looking for special characters not covered
-    ///     in the alphabet 
-        if ( $showentry and $hook == 'SPECIAL' ) {
-            $initial = $entry->concept[0];
-            for ($i = 0; $i < count($alphabet); $i++) {
-                $curletter = $alphabet[$i];
-                if ( $curletter == $initial ) {
-
+        /// if we're browsing by alphabet and the current concept does not begin with
+        ///     the letter we are look for.
+            $showentry = 1;
+            if ( $mode == 'letter' and $hook != 'SPECIAL' and $hook != 'ALL' ) {
+                if ( substr($entry->concept, 0, strlen($hook)) != $hook ) {
                     $showentry = 0;
-                    break;
                 }
-            }
-        } 
-
-    /// if we're browsing categories, looking for entries not categorised.
-        if ( $showentry and $mode == 'cat' and $hook == GLOSSARY_SHOW_NOT_CATEGORISED ) {
-            if ( record_exists("glossary_entries_categories", "entryid", $entry->id)) {
-                $showentry = 0;
             } 
-        }
-
-    /// if the entry is not approved, deal with it based on the current view and
-    ///     user.
-        if ( $showentry and $mode != 'approval' ) {
-            if ( !$entry->approved and isteacher($course->id, $entry->userid) ) {
-                $showentry = 0;
-            }            
-        }
-
-        /// ok, if it's a valid entry.. Print it.
-        if ( $showentry ) {
-
-            if ( $currentpivot != strtoupper($pivot) ) {  
-
-                // print the group break if apply
-                if ( $printpivot )  {
-                    $currentpivot = strtoupper($pivot);
-                    if ( !$tableisopen ) {
-                        echo '<table align="center" width="95%" bgcolor="#FFFFFF" style="border-style: solid; border-width: 1px;">';
-                        $tableisopen = 1;
-                    }
-
-                    echo '<tr>';
-                    $pivottoshow = $currentpivot;
-                    if ( isset($entry->uid) ) {
-                    // printing the user icon if defined (only when browsing authors)
-                        echo '<td colspan="2" align="left" style="border-style: solid; border-width: 1px;">';
-                        $pivottoshow = $entry->uname;
-                    } else {
-                        echo '<td colspan="2" align="center" style="border-style: solid; border-width: 1px;">';
+            
+        /// if we're browsing for letter, looking for special characters not covered
+        ///     in the alphabet 
+            if ( $showentry and $hook == 'SPECIAL' ) {
+                $initial = $entry->concept[0];
+                for ($i = 0; $i < count($alphabet); $i++) {
+                    $curletter = $alphabet[$i];
+                    if ( $curletter == $initial ) {
+    
+                        $showentry = 0;
+                        break;
                     }
-
-                    echo "<strong><i>$pivottoshow</i></strong>" ;
-                    echo '</td>';
-                    echo '</tr>';
                 }
+            } 
+    
+        /// if we're browsing categories, looking for entries not categorised.
+            if ( $showentry and $mode == 'cat' and $hook == GLOSSARY_SHOW_NOT_CATEGORISED ) {
+                if ( record_exists("glossary_entries_categories", "entryid", $entry->id)) {
+                    $showentry = 0;
+                } 
             }
-
-            echo '<tr>';
-            echo '<td width="25%" align="right" valign="top"><b>'. $entry->concept . ': </b></td>';
-            echo '<td width="75%" style="border-style: solid; border-width: 1px;">';
     
-            if ( $entry->attachment) {
-                glossary_print_entry_attachment($entry);
+        /// if the entry is not approved, deal with it based on the current view and
+        ///     user.
+            if ( $showentry and $mode != 'approval' ) {
+                if ( !$entry->approved and isteacher($course->id, $entry->userid) ) {
+                    $showentry = 0;
+                }            
             }
-            echo strip_tags($entry->definition);
     
-            echo '<br><br></tr>';
+            /// ok, if it's a valid entry.. Print it.
+            if ( $showentry ) {
+    
+                if ( !$tableisopen ) {
+                    echo '<table align="center" width="95%" bgcolor="#FFFFFF" style="border-style: solid; border-width: 1px;">';
+                    $tableisopen = 1;
+                }
+                if ( $currentpivot != strtoupper($pivot) ) {  
+                    // print the group break if apply
+                    if ( $printpivot )  {
+                        $currentpivot = strtoupper($pivot);
+    
+                        echo '<tr>';
+                        $pivottoshow = $currentpivot;
+                        if ( isset($entry->uid) ) {
+                        // printing the user icon if defined (only when browsing authors)
+                            echo '<td colspan="2" align="left" style="border-style: solid; border-width: 1px;">';
+                            $user = get_record("user","id",$entry->uid);
+                            $pivottoshow = fullname($user, isteacher($course->id));
+                        } else {
+                            echo '<td colspan="2" align="center" style="border-style: solid; border-width: 1px;">';
+                        }
+    
+                        echo "<strong><i>$pivottoshow</i></strong>" ;
+                        echo '</td>';
+                        echo '</tr>';
+                    }
+                }
+    
+                echo '<tr>';
+                echo '<td width="25%" align="right" valign="top"><b>'. $entry->concept . ': </b></td>';
+                echo '<td width="75%" style="border-style: solid; border-width: 1px;">';
+        
+                if ( $entry->attachment) {
+                    glossary_print_entry_attachment($entry);
+                }
+                echo strip_tags($entry->definition);
+        
+                echo '<br><br></tr>';
+            }
         }
     }
     if ($tableisopen) {
index 030029b0099a8c9c1a6fbcedafb7dc478fa655de..5b7ff5bc773c5668710eee62d86e8959aa12b63d 100644 (file)
@@ -14,7 +14,6 @@
 /// fullpivot indicate if the whole pivot should be compared agasint the db or just the first letter
 /// printpivot indicate if the pivot should be printed or not
     $fullpivot = 1;
-    $printpivot = 1;
 
     $userid = '';
     if ( $USER->id ) {
@@ -77,7 +76,6 @@
             $where = "AND substr(ucase($usernamefield),1," .  strlen($hook) . ") = '" . strtoupper($hook) . "'";
         break;
         case 'mysql':
-            $usernametoshow = "CONCAT(CONCAT(u.firstname,' '), u.lastname)";
             if ( $sortkey == 'FIRSTNAME' ) {
                 $usernamefield = "CONCAT(CONCAT(u.firstname,' '), u.lastname)";
             } else {
@@ -90,7 +88,7 @@
             $where = '';
         }
 
-        $sqlselect  = "SELECT ge.id, $usernamefield pivot, $usernametoshow uname, u.id uid, ge.*";
+        $sqlselect  = "SELECT ge.id, $usernamefield pivot, u.id uid, ge.*";
         $sqlfrom    = "FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}user u";
         $sqlwhere   = "WHERE ge.userid = u.id  AND
                              (ge.approved != 0 $userid)
                     $where = 'AND substr(ucase(concept),1,' .  strlen($hook) . ') = \'' . strtoupper($hook) . '\'';
                 break;
                 case 'mysql':
-                    $where = 'AND left(ucase(concept),' .  strlen($hook) . ") = '$hook'";
+                    $where = 'AND left(ucase(concept),' .  strlen($hook) . ") = '" . strtoupper($hook) . "'";
                 break;
                 }
             }
index 8ef1e439b714aede223e92e21a40cb39a243137b..27014bd401bc5eec05f520e2d7616d33c3366665 100644 (file)
@@ -5,7 +5,7 @@
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 /////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2003111500;  // The current module version (Date: YYYYMMDDXX)
+$module->version  = 2003111800;  // The current module version (Date: YYYYMMDDXX)
 $module->cron     = 0;           // Period for cron to check this module (secs)
 
 $release = "0.5 development";   // User-friendly version number
index ec29dcff7c1dd3dbc1059fcc132e6153cc55d69b..adc93a6f3e1d32eeff951b6a5ea489898caf416a 100644 (file)
         }
     } else {
         $printpivot = 1;
+        if ( $mode == '' and $hook == '' and $show == '') {
+            $mode = 'letter';
+            $hook = 'ALL';
+        }
     }
 
     if ( $displayformat == -1 ) {