]> git.mjollnir.org Git - moodle.git/commitdiff
- Rewrite of the internal API in order to, hopefully, create an easy way to handle...
authorwillcast <willcast>
Sat, 15 Nov 2003 15:55:47 +0000 (15:55 +0000)
committerwillcast <willcast>
Sat, 15 Nov 2003 15:55:47 +0000 (15:55 +0000)
- Adding a new frame: Browse by Author
- A new, friendly way to show entries (asked by Martin): view?id=cm&mode=term&hook=[concept | alias ]
- Handling user activies, outline and complete.
- Properly showing new entries in recent activity box.
- Adding a flag to categories to specify if a category should or should not be automatically linked.
- Adding some missing strings and files as well.
- Adding a field to each glossary that specify how many entries by pages it should show.

36 files changed:
lang/en/glossary.php
lang/en/help/glossary/destination.html [new file with mode: 0644]
lang/en/help/glossary/entbypage.html [new file with mode: 0644]
lang/en/help/glossary/filetoimport.html [new file with mode: 0644]
lang/en/help/glossary/importcategories.html [new file with mode: 0644]
lang/en/help/glossary/index.html
lang/en/help/glossary/linkcategory.html [new file with mode: 0644]
mod/glossary/approve.php
mod/glossary/backuplib.php
mod/glossary/comment.php
mod/glossary/config.html
mod/glossary/db/mysql.php
mod/glossary/db/mysql.sql
mod/glossary/db/postgres7.sql
mod/glossary/deleteentry.html
mod/glossary/deleteentry.php
mod/glossary/dynalink.php
mod/glossary/edit.html
mod/glossary/edit.php
mod/glossary/editcategories.html
mod/glossary/editcategories.php
mod/glossary/export.php
mod/glossary/exportentry.php
mod/glossary/formats/2.php
mod/glossary/formats/3.php
mod/glossary/formats/4.php
mod/glossary/formats/5.php
mod/glossary/import.php
mod/glossary/lib.php
mod/glossary/mod.html
mod/glossary/print.php
mod/glossary/restorelib.php
mod/glossary/showentry.php
mod/glossary/tabs.html
mod/glossary/version.php
mod/glossary/view.php

index 8e1d5aa32ff5602fae048a443ac55cf9160f1339..17b815524b7b539cb3ec5af2c0b1e0bce0c73c61 100644 (file)
@@ -3,15 +3,18 @@
 
 $string['addcomment'] = "Add comment";
 $string['addentry'] = "Add a new entry";
-$string['approve'] = "Approve";
+$string['addingcomment'] = "Add a comment";
 $string['aliases'] = "Alias(es)";
 $string['allentries'] = "ALL";
 $string['allcategories'] = "All Categories";
 $string['allowcomments'] = "Allow comments on entries";
 $string['allowduplicatedentries'] = "Duplicated entries allowed";
 $string['answer'] = "Answer";
+$string['approve'] = "Approve";
+$string['authorview'] = "Browse by Author";
 $string['areyousuredelete'] = "Are you sure you want to delete this entry?";
 $string['areyousuredeletecomment'] = "Are you sure you want to delete this comment?";
+$string['areyousureexport'] = "Are you sure you want to export this entry to";
 $string['ascending'] = "(ascending)";
 $string['attachment'] = "Attachment";
 $string['back'] = "Back";
@@ -62,6 +65,7 @@ $string['editentry'] = "Edit entry";
 $string['editingcomment'] = "Editing comment";
 $string['entries'] = "Entries";
 $string['importedentries'] = "Imported entries";
+$string['entbypage'] = "Entries shown by page";
 $string['entrieswithoutcategory'] = "Entries without category";
 $string['entry'] = "Entry";
 $string['entryalreadyexist'] = "Entry already exists";
@@ -88,11 +92,13 @@ $string['glossarytype'] = "Glossary Type";
 $string['glosssaryexported'] = "Glossary exported.";
 $string['importcategories'] = "Import categories";
 $string['isglobal'] = "Is this glossary global?";
+$string['linkcategory'] = "Automatically link this category";
 $string['mainglossary'] = "Main glossary";
 $string['modulename'] = "Glossary";
 $string['modulenameplural'] = "Glossaries";
 $string['maxtimehaspassed'] = "Sorry, but the maximum time for editing this comment (\$a) has passed!";
 $string['newglossary'] = "New glossary";
+$string['newentries'] = "New glossary entries";
 $string['newglossaryentries'] = "New glossary entries:";
 $string['newglossarycreated'] = "New glossary created.";
 $string['notcategorised'] = "Not categorised";
@@ -101,6 +107,7 @@ $string['noconceptfound'] = "No concept or definition found.";
 $string['nocomments'] = "(No comments found on this entry)";
 $string['noentries'] = "No entries found in this section";
 $string['noentry'] = "No entry found.";
+$string['numberofentries'] = "Number of entries";
 $string['onebyline'] = "(one by line)";
 $string['printerfriendly'] = "Printer-friendly version";
 $string['question'] = "Question";
diff --git a/lang/en/help/glossary/destination.html b/lang/en/help/glossary/destination.html
new file mode 100644 (file)
index 0000000..c7d59c2
--- /dev/null
@@ -0,0 +1,7 @@
+<P ALIGN=CENTER><B>Definition destination of imported entries</B></P>
+
+<P>You can specify where do you want to import the entries:</p>
+<ul>
+<li><strong>Current Glossary:</strong> Will append the imported entries to the current glossary.</li>
+<li><strong>New Glossary:</strong> Will create a new glossary based on the information found in the XML file selected and will insert the new entries on it.</li>
+</ul>
diff --git a/lang/en/help/glossary/entbypage.html b/lang/en/help/glossary/entbypage.html
new file mode 100644 (file)
index 0000000..b2fac23
--- /dev/null
@@ -0,0 +1,7 @@
+<P ALIGN=CENTER><B>Defining number of entries shown by page</B></P>
+
+<P>You can specify the number of entries shown by page. This number depends on the configuration of the glossary.</p>
+
+<p>The more automatically linked entries you have, the lower this number should be in order to avoid long answer time from the application.</p>
+
+<p>Note: If you get a timout error when browsing a glossary, it probable needs to have a lower number of entries shown by page.</p>
diff --git a/lang/en/help/glossary/filetoimport.html b/lang/en/help/glossary/filetoimport.html
new file mode 100644 (file)
index 0000000..e1f1141
--- /dev/null
@@ -0,0 +1,3 @@
+<P ALIGN=CENTER><B>File to import</B></P>
+
+<P>Select the XML file which contains the entries to import.</p>
diff --git a/lang/en/help/glossary/importcategories.html b/lang/en/help/glossary/importcategories.html
new file mode 100644 (file)
index 0000000..146e622
--- /dev/null
@@ -0,0 +1,3 @@
+<P ALIGN=CENTER><B>Importing categories</B></P>
+
+<P>By default, all the entries will be imported. You can specify if you want the categories to be imported as well (it will import the relationship between the imported categories and the imported entries also).</p>
index 1fce87c84da869d755a1bab514bcd8f94985b9ff..1ca4d3faa17c86e2f8a5b0f9254e5950b26e5182 100644 (file)
@@ -11,7 +11,12 @@ Glossary level help files:
   <li><a href="help.php?module=glossary&file=studentcanpost.html">Students can post entries</a>
   <li><a href="help.php?module=glossary&file=allowcomments.html">Comments on entries</a>
   <li><a href="help.php?module=glossary&file=displayformat.html">Display formats for entries</a>
+  <li><a href="help.php?module=glossary&file=entbypage.html">Number of entries shown by page</a>
   <li><a href="help.php?module=glossary&file=shows.html">Browsing options in Alphabet View frame</a>
+  <li><a href="help.php?module=glossary&file=linkcategories.html">Automatically linking categories</a>
+  <li><a href="help.php?module=glossary&file=filetoimport.html">Importing entries</a>
+  <li><a href="help.php?module=glossary&file=importcategories.html">Importing categories</a>
+  <li><a href="help.php?module=glossary&file=destination.html">Destination of the entries to import</a>
 </ul>
 </blockquote>
 
diff --git a/lang/en/help/glossary/linkcategory.html b/lang/en/help/glossary/linkcategory.html
new file mode 100644 (file)
index 0000000..da55df4
--- /dev/null
@@ -0,0 +1,5 @@
+<P ALIGN=CENTER><B>Automatically linking categories</B></P>
+
+<P>You can specify if you want the categories to be automatically linked or not.</p>
+
+<p>Note: Categories are linked based on a case sensitive, full whole match.</p>
index 711d55145f90519ff53d4207452cd60cbcdc2c37..1d9166f37840aa5d72ceb87301fb390d56e0232d 100644 (file)
@@ -6,8 +6,8 @@
     require_variable($id);           // Course Module ID
     optional_variable($eid);         // Entry ID
 
-    optional_variable($tab,GLOSSARY_APPROVAL_VIEW);
-    optional_variable($l,"ALL");
+    optional_variable($mode,"approval");
+    optional_variable($hook,"ALL");
 
     if (! $cm = get_record("course_modules", "id", $id)) {
         error("Course Module ID was incorrect");
@@ -33,6 +33,6 @@
     } else {
         add_to_log($course->id, "glossary", "approve entry", "showentry.php?id=$cm->id&eid=$eid", "$eid");
     }
-    redirect("view.php?id=$cm->id&tab=$tab&l=$l",get_string("entryapproved","glossary"),1);
+    redirect("view.php?id=$cm->id&mode=$mode&hook=$hook",get_string("entryapproved","glossary"),1);
     die;
 ?>
\ No newline at end of file
index 834c9cc71900634ca11695f328178fd864c95927..2adcfa57be867806ef8713d980bcf5115facfd8f 100644 (file)
@@ -90,6 +90,7 @@
                 fwrite ($bf,full_tag("ID",6,false,$glo_cat->id));
                 fwrite ($bf,full_tag("GLOSSARYID",6,false,$glo_cat->glossaryid));
                 fwrite ($bf,full_tag("NAME",6,false,$glo_cat->name));
+                fwrite ($bf,full_tag("USEDYNALINK",6,false,$glo_cat->usedynalink));
 
                 $status = backup_glossary_entries_categories ($bf,$preferences,$glo_cat->id);
 
index 8bdda5c2651f9e116d5a726524057cf54a48601d..67a14bbe8eaae4e23c7b4df54549f5e11e17054b 100644 (file)
         echo "<br />";
     }
 
-    glossary_print_entry($course, $cm, $glossary, $entry);
+    echo "<p align=center>";
+    echo "<table class=\"generalbox\" width=\"70%\" align=\"center\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\">";
+       echo "<tr bgcolor=$THEME->cellheading2><td align=center>";
+           echo "<table border=0 width=100%><tr><td width=33%></td><td width=33% align=center>";
+           echo get_string("commentson","glossary") . " <b>$entry->concept</b></td>";
+           echo "<td width=33% align=right>";  
+           echo "</td></tr></table>";
+                       
+       echo "</td></tr>";
+    echo "<tr><TD WIDTH=100% BGCOLOR=\"#FFFFFF\">";
+    if ($entry->attachment) {
+          $entry->course = $course->id;
+          echo "<table border=0 align=right><tr><td>";
+          echo glossary_print_attachments($entry,"html");
+          echo "</td></tr></table>";
+    }
+    echo "<b>$entry->concept</b>: ";
+    echo format_text($entry->definition, $entry->format);
+    echo "</td>";
+    echo "</TR></table>";
 
+    
     echo "<center>";
     echo "<br />";
 
index d515b3d6eabd0e0baaca5b9151b953be6bc74441..60bcf6cd8d98cc73da4719e5cf293b5e7223ec96 100644 (file)
 <tr valign=top>
     <td align=right><p>glossary_entbypage:</td>
     <td>
-    <input name=glossary_entbypage type=text size=5 value="<?php p($CFG->glossary_entbypage) ?>">
+    <input name=glossary_entbypage type=text size=3 value="<?php p($CFG->glossary_entbypage) ?>">
     </td>
     <td>
     <?php print_string("entbypage", "glossary") ?>
     </td>
 </tr>
 <tr valign=top>
-    <td align=right><p>students_can_post_entries:</td>
+    <td align=right><p>glossary_studentspost:</td>
     <td>
-    <SELECT size=1 name=cnfstudentcanpost>
+    <SELECT size=1 name=glossary_studentspost>
 <?php 
     $yselected = "";
     $nselected = "";
-    if ($CFG->cnfstudentcanpost) {
+    if ($CFG->glossary_studentspost) {
         $yselected = " SELECTED ";
     } else {
         $nselected = " SELECTED ";
     </td>
 </tr>
 <tr valign=top>
-    <td align=right><p>allow_duplicated_entries:</td>
+    <td align=right><p>glossary_dupentries:</td>
     <td>
-    <SELECT size=1 name=cnfallowdupentries>
+    <SELECT size=1 name=glossary_dupentries>
 <?php 
     $yselected = "";
     $nselected = "";
-    if ($CFG->cnfallowdupentries) {
+    if ($CFG->glossary_dupentries) {
         $yselected = " SELECTED ";
     } else {
         $nselected = " SELECTED ";
     </td>
 </tr>
 <tr valign=top>
-    <td align=right><p>allow_comments:</td>
+    <td align=right><p>glossary_allowcomments:</td>
     <td>
-    <SELECT size=1 name=cngallowcomments>
+    <SELECT size=1 name=glossary_allowcomments>
 <?php 
     $yselected = "";
     $nselected = "";
-    if ($CFG->cngallowcomments) {
+    if ($CFG->glossary_allowcomments) {
         $yselected = " SELECTED ";
     } else {
         $nselected = " SELECTED ";
     </SELECT>
     </td>
     <td>
-    <?php print_string("cngallowcomments", "glossary") ?>
+    <?php print_string("cnfallowcomments", "glossary") ?>
     </td>
 </tr>
 <tr valign=top>
-    <td align=right><p>automatically_link_glossaries:</td>
+    <td align=right><p>glossary_linkbydefault:</td>
     <td>
-    <SELECT size=1 name=cnflinkglossaries>
+    <SELECT size=1 name=glossary_linkbydefault>
 <?php 
     $yselected = "";
     $nselected = "";
-    if ($CFG->cnflinkglossaries) {
+    if ($CFG->glossary_linkbydefault) {
         $yselected = " SELECTED ";
     } else {
         $nselected = " SELECTED ";
     </td>
 </tr>
 <tr valign=top>
-    <td align=right><p>default_approval_status:</td>
+    <td align=right><p>glossary_defaultapproval:</td>
     <td>
-    <SELECT size=1 name=cnfapprovalstatus>
+    <SELECT size=1 name=glossary_defaultapproval>
 <?php 
     $yselected = "";
     $nselected = "";
-    if ($CFG->cnfapprovalstatus) {
+    if ($CFG->glossary_defaultapproval) {
         $yselected = " SELECTED ";
     } else {
         $nselected = " SELECTED ";
     <td colspan = 3 align=center><strong>Entry Level Default Settings</strong></td>
 </tr>
 <tr valign=top>
-    <td align=right><p>automatically_link_entry:</td>
+    <td align=right><p>glossary_linkentries:</td>
     <td>
-    <SELECT size=1 name=cnflinkentry>
+    <SELECT size=1 name=glossary_linkentries>
 <?php 
     $yselected = "";
     $nselected = "";
-    if ($CFG->cnflinkentry) {
+    if ($CFG->glossary_linkentries) {
         $yselected = " SELECTED ";
     } else {
         $nselected = " SELECTED ";
     </td>
 </tr>
 <tr valign=top>
-    <td align=right><p>case_sensitive:</td>
+    <td align=right><p>glossary_casesensitive:</td>
     <td>
-    <SELECT size=1 name=cnfcasesensitive>
+    <SELECT size=1 name=glossary_casesensitive>
 <?php 
     $yselected = "";
     $nselected = "";
-    if ($CFG->cnfcasesensitive) {
+    if ($CFG->glossary_casesensitive) {
         $yselected = " SELECTED ";
     } else {
         $nselected = " SELECTED ";
     </td>
 </tr>
 <tr valign=top>
-    <td align=right><p>match_whole_words:</td>
+    <td align=right><p>glossary_fullmatch:</td>
     <td>
-    <SELECT size=1 name=cnffullmatch>
+    <SELECT size=1 name=glossary_fullmatch>
 <?php 
     $yselected = "";
     $nselected = "";
-    if ($CFG->cnffullmatch) {
+    if ($CFG->glossary_fullmatch) {
         $yselected = " SELECTED ";
     } else {
         $nselected = " SELECTED ";
index ca3b52a11b0968eb6e9a322638e352d9695a9c6a..71fba487b160ace86294724d9ea5cb4faf1daa54 100644 (file)
@@ -165,6 +165,15 @@ function glossary_upgrade($oldversion) {
                     PRIMARY KEY  (`id`)
                     ) TYPE=MyISAM COMMENT='entries alias'");
     }
+    
+    if ( $oldversion < 2003111500 ) {
+        execute_sql( "ALTER TABLE `{$CFG->prefix}glossary_categories`
+                     ADD `usedynalink`  TINYINT(2) UNSIGNED NOT NULL DEFAULT '1' AFTER `name`" );
+                     
+        execute_sql( "ALTER TABLE `{$CFG->prefix}glossary`
+                     ADD `entbypage`  TINYINT(3) UNSIGNED NOT NULL DEFAULT '10' AFTER `globalglossary`" );
+                     
+    }
     return true;
 }
 
index 2948f7765454cecee8a6d387efebe945b3ab7a71..84b547f51931298ffa2ad1173feb19ea0d00fc71 100644 (file)
@@ -24,6 +24,7 @@ CREATE TABLE prefix_glossary (
      usedynalink tinyint(2) unsigned NOT NULL default '1',
      defaultapproval tinyint(2) unsigned NOT NULL default '1',
      globalglossary tinyint(2) unsigned NOT NULL default '0',
+     entbypage tinyint(3) unsigned NOT NULL default '10',
      timecreated int(10) unsigned NOT NULL default '0',
      timemodified int(10) unsigned NOT NULL default '0',
      PRIMARY KEY  (id)
@@ -71,6 +72,7 @@ CREATE TABLE prefix_glossary_categories (
      id int(10) unsigned NOT NULL auto_increment,
      glossaryid int(10) unsigned NOT NULL default '0',
      name varchar(255) NOT NULL default '',
+     usedynalink tinyint(2) unsigned NOT NULL default '1',
      PRIMARY KEY  (id)
 ) TYPE=MyISAM COMMENT='all categories for glossary entries';
 
index 6c737d867478fc3ebe526a833add21249ee935b7..06e11a4d1eb349c4a3702eab8d3485a550ee4d27 100644 (file)
@@ -23,6 +23,7 @@ CREATE TABLE prefix_glossary (
      allowcomments int2 NOT NULL default '0',
      usedynalink int2 NOT NULL default '1',
      globalglossary int2 NOT NULL default '0',
+     entbypage int NOT NULL default '10',
      timecreated int4 NOT NULL default '0',
      timemodified int4 NOT NULL default '0',
      PRIMARY KEY  (id)
@@ -58,6 +59,7 @@ CREATE TABLE prefix_glossary_categories (
      id SERIAL,
      glossaryid int4 NOT NULL default '0',
      name varchar(255) NOT NULL default '',
+     usedynalink int2 NOT NULL default '1',
      PRIMARY KEY  (id)
 );
 
index 0629aa0f4767bf8d6296e58c0e8dc2fcbd00355f..23a524f525bd44dd5a055a549e0e993aac3227e4 100644 (file)
@@ -4,8 +4,8 @@
 <input type="hidden" name=mode         value="delete">
 <input type="hidden" name=go       value="1">
 <input type="hidden" name=entry         value="<?php echo $entry ?>">
-<input type="hidden" name=currentview value="<?=$currentview ?>">
-<input type="hidden" name=cat value="<?=$cat ?>">
+<input type="hidden" name=mode value="<?=$mode ?>">
+<input type="hidden" name=hook value="<?=$hook ?>">
 
 <input type="submit" value=" <?php print_string("yes")?> "> 
 <input type=button value=" <?php print_string("no")?> " onclick="javascript:history.go(-1);">
index eda4582fc9feb5add370457cb88934b05cbc6560..4dffa32ea5b047a26f991d082a78e792e60639ed 100644 (file)
@@ -7,8 +7,8 @@
     require_variable($mode);  // edit or delete
     optional_variable($go);  // commit the operation?
     optional_variable($entry);  // entry id
-    optional_variable($tab); // browsing entries by categories?
-    optional_variable($cat);         // categoryID
+    require_variable($prevmode);  //  current frame
+    optional_variable($hook);         // pivot id 
 
     $strglossary = get_string("modulename", "glossary");
     $strglossaries = get_string("modulenameplural", "glossary");
@@ -50,7 +50,7 @@
     
     if ($mode == "edit" or $mode == "delete" ) {
         echo "<p>";
-        if ( isteacher($cm->id) or $glossary->studentcanpost ) {
+        if ( isteacher($course->id) or $glossary->studentcanpost ) {
             if ($go) { // the operation was confirmed.
                 if ( $mode == "delete") {
                     // if it is an imported entry, just delete the relation
@@ -74,8 +74,8 @@
                     print_simple_box_end();
                 }
                 print_footer($course);
-                add_to_log($course->id, "glossary", "delete entry", "view.php?id=$cm->id&tab=$tab&cat=$cat", $entry);
-                redirect("view.php?id=$cm->id&tab=$tab&cat=$cat");
+                add_to_log($course->id, "glossary", "delete entry", "view.php?id=$cm->id&mode=$prevmode&hook=$hook", $entry);
+                redirect("view.php?id=$cm->id&mode=$prevmode&hook=$hook");
             } else {        // the operation has not been confirmed yet so ask the user to do so
                 if ( $mode == "delete") {                              
                     print_simple_box_start("center","40%", "#FFBBBB");
@@ -88,8 +88,8 @@
                         <input type="hidden" name=mode         value="delete">
                         <input type="hidden" name=go       value="1">
                         <input type="hidden" name=entry         value="<?php p($entry) ?>">
-                        <input type="hidden" name=tab value=<?php p($tab) ?>>
-                        <input type="hidden" name=cat=<?php p($cat) ?>>
+                        <input type="hidden" name=prevmode value=<?php p($prevmode) ?>>
+                        <input type="hidden" name=hook     value=<?php p($hook) ?>>
 
                         <input type="submit" value=" <?php print_string("yes")?> ">
                         <input type=button value=" <?php print_string("no")?> " onclick="javascript:history.go(-1);">
index d146706fe7a09cd6d0883b0475751cdfa24cd154..ea7a89fc4dfc5611ca0b0f406804b072febddb30 100644 (file)
@@ -35,7 +35,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)", "$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","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');
@@ -60,7 +60,7 @@
                         }
                         $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&tab=1&cat=$concept->id\">";
+                        $href_tag_begin = "<a class=\"autolink\" title=\"$title\" href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&mode=cat&hook=$concept->id\">";
                     } else {
                         $concepttitle = urlencode($concept->concept);
                         $title = strip_tags("$glossary->name: $concepttitle");
@@ -70,6 +70,7 @@
 
                     $currentconcept = str_replace("|", "\|", $concept->concept);
                     $currentconcept = str_replace("'", "\'", $currentconcept);
+                    $currentconcept = str_replace("*", "\*", $currentconcept);
                     if ( $currentconcept = trim(strip_tags($currentconcept)) ) {
                         if ( !$concept->category ) {
                             if ( $aliases = get_records("glossary_alias","entryid",$concept->id) ) {
index aafc2679cff94802fb718d1bdeb28d07971a50fa..e953d456b36d25e5f168be1d10ea237ef1419604 100644 (file)
@@ -49,7 +49,13 @@ if (isset($errors)) {
     <table border=0>
         <tr>
         <td align=center width=58%>
-
+<?PHP 
+    if ( !$glossary->usedynalink ) {
+       echo '<input type="hidden" name=usedynalink value="0">';
+       echo '<input type="hidden" name=casesensitive value="0">';
+       echo '<input type="hidden" name=fullmatch value="0">';
+    } else {
+?>
     <table border=0 width=100%>
         <tr><td align=right width=80%><small><?php echo get_string("entryusedynalink","glossary") ?>:</small></td><td width=20%>
     <script>
@@ -94,6 +100,9 @@ if (isset($errors)) {
     <input type="checkbox" name="fullmatch" value=1 <?php p($selected) ?>> <?php helpbutton("fullmatch", strip_tags(get_string("fullmatch", "glossary")), "glossary") ?>
         </td></tr>
     </table>
+<?PHP 
+    }  // end-if !$usedynalink
+?>
 
         </td>
         <td align=center width=42% valign=top>
@@ -164,8 +173,8 @@ if (isset($errors)) {
        <input type="hidden" name=hfullmatch value="1">
 
        <input type="hidden" name=id value="<?=$cm->id ?>">
-       <input type="hidden" name=tab value="<?=$tab ?>">
-       <input type="hidden" name=cat value="<?=$cat ?>">
+       <input type="hidden" name=mode value="<?=$mode ?>">
+       <input type="hidden" name=hook value="<?=$hook ?>">
        <input type="hidden" name=confirm value="1">
 
        <input type="submit" value="<?php print_string("savechanges") ?>">
index b59d71e84573e26be3269504ba6f980522acd7e3..289c9d8453944b2778024ea55048e5c684958234 100644 (file)
@@ -8,8 +8,8 @@ require_variable($id);    // Course Module ID
 optional_variable($e);    // EntryID
 optional_variable($confirm,0);    // proceed. Edit the edtry
 
-optional_variable($tab);   // categories if by category?
-optional_variable($cat);    // CategoryID
+optional_variable($mode);   // categories if by category?
+optional_variable($hook);    // CategoryID
 
 if (! $cm = get_record("course_modules", "id", $id)) {
     error("Course Module ID was incorrect");
@@ -33,6 +33,12 @@ if ( $confirm ) {
     if ( !isset($form->usedynalink) ) {
         $form->usedynalink = 0;
     }
+    if ( !isset($form->casesensitive) ) {
+        $form->casesensitive = 0;
+    }
+    if ( !isset($form->fullmatch) ) {
+        $form->fullmatch = 0;
+    }
     $timenow = time();
     $form->text = clean_text($form->text, $form->format);
 
@@ -102,7 +108,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&eid=$newentry->id&tab=$tab&cat=$cat", "$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.");
@@ -131,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&eid=$newentry->id&tab=$tab&cat=$cat", "$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.");
@@ -165,7 +171,7 @@ if ( $confirm ) {
         }
     }
 
-    redirect("view.php?id=$cm->id&eid=$newentry->id&tab=$tab&cat=$cat");
+    redirect("view.php?id=$cm->id&mode=entry&hook=$newentry->id");
     die;
 } else {
     if ($e) {
index e97a4beb068f863d63d58d277bea2c4f5a7d047f..df7f2a240dd761b7dd9511ee1594cf49885c9046 100644 (file)
         <INPUT type="text" name="name" size=30 value="<?=$name ?>">
     </td>
 </tr>
+<tr valign=top>
+    <td align=right><p><b><?php echo get_string("linkcategory","glossary") ?>:</b></p></td>
+    <td>
+      <select size="1" name="usedynalink">
+      <option value="1" <?php
+       if ( $usedynalink ) {
+          echo "selected";
+       }
+       ?>><?php echo get_string("yes") ?></option>
+      <option value="0" <?php
+       if ( !$usedynalink ) {
+          echo "selected";
+       }
+       ?>><?php echo get_string("no") ?>
+      </option>
+      </select> <?php helpbutton("linkcategory", get_string("linkcategory", "glossary"), "glossary") ?>
+    </td>
+</tr>
 <td colspan=2>
        <p align=center>
        <input type="hidden" name=id value="<?=$cm->id ?>">
        <input type="hidden" name=action value="<?=$action?>">
        <input type="hidden" name=confirm value=1>
-       <input type="hidden" name=cat value=<?php p($cat) ?>>
+       <input type="hidden" name=mode value='cat'>
+       <input type="hidden" name=hook value="<?=$hook?>">
        <input type="submit" value="<?php print_string("savechanges") ?>">
        <input type="reset" value="<?php print_string("back","glossary") ?>"  onclick="javascript:history.go(-1);">
        </P>
index 8be8e6b12f593d17ec89eaf328f9251d2353ff87..c6b015211c87fa922576fb4953a8ae45b6db0744 100644 (file)
@@ -6,8 +6,10 @@
     require_once("lib.php");
 
      require_variable($id);    // Course Module ID, or
-     optional_variable($cat);  // category ID
+     optional_variable($mode);  // cat
+     optional_variable($hook);  // category ID
      optional_variable($action);  // what to do
+     optional_variable($usedynalink);  // category ID
      optional_variable($confirm);  // confirm the action
 
      optional_variable($name);  // confirm the action
                   "", "", true, update_module_button($cm->id, $course->id, $strglossary),
                   navmenu($course, $cm));
 
-     if ( $cat ) {
-          $category = get_record("glossary_categories","id",$cat);
+     if ( $hook ) {
+          $category = get_record("glossary_categories","id",$hook);
 
           if ( $action == "edit" ) {
                if ( $confirm ) {
                     $action = "";
-                    $CategoryObject->id = $cat;
-                    $CategoryObject->name = $name;
+                    $cat->id = $hook;
+                    $cat->name = $name;
+                    $cat->usedynalink = $usedynalink;
 
-                    if ( !update_record("glossary_categories", $CategoryObject) ) {
+                    if ( !update_record("glossary_categories", $cat) ) {
                                    error("Weird error. The category was not updated.");
                                    redirect("editcategories.php?id=$cm->id");
                     } else {
-                        add_to_log($course->id, "glossary", "edit category", "editcategories.php?id=$cm->id", $cat);
+                        add_to_log($course->id, "glossary", "edit category", "editcategories.php?id=$cm->id", $hook);
                     }
                } else {
                     echo "<p align=\"center\">" . get_string("edit"). " " . get_string("category","glossary") . "<font size=\"3\">";
 
                     $name = $category->name;
+                    $usedynalink = $category->usedynalink;
                     require "editcategories.html";
                     print_footer();
                     die;
@@ -72,8 +76,8 @@
           } elseif ( $action == "delete" ) {
                if ( $confirm ) {
                
-                                   delete_records("glossary_entries_categories","categoryid", $cat);
-                    delete_records("glossary_categories","id", $cat);
+                                   delete_records("glossary_entries_categories","categoryid", $hook);
+                    delete_records("glossary_categories","id", $hook);
                                
                                    print_simple_box_start("center","40%", "#FFBBBB");
                                    echo "<center>" . get_string("categorydeleted","glossary") ."</center>";
@@ -82,7 +86,7 @@
                                
                                print_footer($course);
 
-                    add_to_log($course->id, "glossary", "delete category", "editcategories.php?id=$cm->id", $cat);
+                    add_to_log($course->id, "glossary", "delete category", "editcategories.php?id=$cm->id", $hook);
                     
                            redirect("editcategories.php?id=$cm->id");
                } else {
                     <input type="hidden" name=id                  value="<?php p($cm->id) ?>">
                     <input type="hidden" name=action      value="delete">
                     <input type="hidden" name=confirm     value="1">
-                    <input type="hidden" name=cat         value="<?php echo $cat ?>">
+                    <input type="hidden" name=mode         value="<?php echo $mode ?>">
+                    <input type="hidden" name=hook         value="<?php echo $hook ?>">
                     <table border=0 widTH=100><tr><td align=right width=50%>
                     <input type="submit" value=" <?php print_string("yes")?> ">
                     </form>
 
                } else {
                     $action = "";
-                    $CategoryObject->name = $name;
-                    $CategoryObject->glossaryid = $glossary->id;
+                    $cat->name = $name;
+                    $cat->usedynalink = $usedynalink;
+                    $cat->glossaryid = $glossary->id;
 
-                    if ( ! $CategoryObject->id = insert_record("glossary_categories", $CategoryObject) ) {
+                    if ( ! $cat->id = insert_record("glossary_categories", $cat) ) {
                                    error("Weird error. The category was not inserted.");
                                
                                    redirect("editcategories.php?id=$cm->id");
                     } else {
-                        add_to_log($course->id, "glossary", "add category", "editcategories.php?id=$cm->id", $CategoryObject->id);
+                        add_to_log($course->id, "glossary", "add category", "editcategories.php?id=$cm->id", $cat->id);
                     }
              }
           } else {
                </td>
                <td width="10%" align="center"><b>
                <?php
-                       echo "<a href=\"editcategories.php?id=$cm->id&action=delete&cat=$category->id\"><img  alt=\"" . get_string("delete") . "\"src=\"../../pix/t/delete.gif\" height=11 width=11 border=0></a> ";
-                       echo "<a href=\"editcategories.php?id=$cm->id&action=edit&cat=$category->id\"><img  alt=\"" . get_string("edit") . "\" src=\"../../pix/t/edit.gif\" height=11 width=11 border=0></a>";
+                       echo "<a href=\"editcategories.php?id=$cm->id&action=delete&mode=cat&hook=$category->id\"><img  alt=\"" . get_string("delete") . "\"src=\"../../pix/t/delete.gif\" height=11 width=11 border=0></a> ";
+                       echo "<a href=\"editcategories.php?id=$cm->id&action=edit&mode=cat&hook=$category->id\"><img  alt=\"" . get_string("edit") . "\" src=\"../../pix/t/edit.gif\" height=11 width=11 border=0></a>";
                ?>
                </b></td>
              </tr>
              echo print_single_button("editcategories.php", $options, get_string("add") . " " . get_string("category","glossary"), "get");
              echo "</td><td align=left>";
              unset($options['action']);
-             $options['currentview'] = "categories";
+             $options['mode'] = 'cat';
+             $options['hook'] = $hook;
              echo print_single_button("view.php", $options, get_string("back","glossary") );
              echo "</td></tr>";
              echo "</tablee>";
index 5585bb90abebb5fe703b1a2702f26ff7c23cd4aa..cff6cf316888efafcdb3a323a4f132117df2eef8 100644 (file)
     $strsearchindefinition = get_string("searchindefinition", "glossary");
     $strsearch = get_string("search");
     
+    $navigation = "";
+    if ($course->category) {
+        $navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
+        require_login($course->id);
+    }
+
     print_header(strip_tags("$course->shortname: $glossary->name"), "$course->fullname",
         "$navigation <A HREF=index.php?id=$course->id>$strglossaries</A> -> $glossary->name",
         "", "", true, update_module_button($cm->id, $course->id, $strglossary),
index 85d6f8b785475c694fe5f7cefd4169b9d6fa9dc4..8e7abff00a63b6721932b5a97f3d08c7fda3b9bc 100644 (file)
@@ -5,8 +5,8 @@
        require_variable($id);    // course module ID
        require_variable($entry);    // Entry ID
        optional_variable($confirm);     // confirmation
-       optional_variable($currentview);
-       optional_variable($cat);
+       optional_variable($mode);
+       optional_variable($hook);
        
        global $THEME, $USER, $CFG;
 
 
                if ( !$confirm ) {
                        echo "<center>";
-
-                       notice_yesno ("<center><h2>$entry->concept</h2><p align=center>Seguro que desea agregar esta entrada a<br><b>$mainglossary->name</b>?",
-                               "exportentry.php?id=$id&currentview=$currentview&cat=$cat&entry=$entry->id&confirm=1",
-                               "view.php?id=$cm->id&currentview=$currentview&cat=$cat&eid=".$entry->id );
+            $areyousure = get_string("areyousureexport","glossary");
+                       notice_yesno ("<center><h2>$entry->concept</h2><p align=center>$areyousure<br><b>$mainglossary->name</b>?",
+                               "exportentry.php?id=$id&mode=$mode&hook=$hook&entry=$entry->id&confirm=1",
+                               "view.php?id=$cm->id&mode=$mode&hook=$hook" );
 
                } else {
                        if ( ! $mainglossary->allowduplicatedentries ) {
                     print_simple_box_start("center", "60%", "$THEME->cellheading");
                     echo "<p align=center><font size=3>$entryexported</font></p></font>";
 
-                    print_continue("view.php?id=$cm->id&eid=".$entry->id);
+                    print_continue("view.php?id=$cm->id&mode=entry&hook=".$entry->id);
                     print_simple_box_end();
 
                                print_footer();
 
-                   redirect("view.php?id=$cm->id&eid=".$entry->id);
+                   redirect("view.php?id=$cm->id&mode=entry&hook=".$entry->id);
                    die;
                                }
                        } else {
                            echo "<p align=center><font size=3>$entryalreadyexist</font></p></font>";
                                echo "<p align=center>";
 
-                               print_continue("view.php?id=$cm->id&eid=".$entry->id);
+                               print_continue("view.php?id=$cm->id&mode=entry&hook=".$entry->id);
 
                            print_simple_box_end();
                        }
                }
        } else {
                print_simple_box_start("center", "60%", "#FFBBBB");
-               echo "<p align=center><font size=3>A weird error was found while trying to export this entry. Operation cancelled.</font></p></font>";
+               notice("A weird error was found while trying to export this entry. Operation cancelled.");
 
-                       print_continue("view.php?id=$cm->id&eid=".$entry->id);
+                       print_continue("view.php?id=$cm->id&mode=entry&hook=".$entry->id);
 
                print_simple_box_end();
        }
index c9d35a342bcef7f39ca0f897b4a8034ba6de7e47..b8a825b39f7f171310ddf9d2de05a846c5348006 100644 (file)
@@ -1,6 +1,6 @@
 <?PHP  // $Id$
 
-function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $tab="",$cat="") {
+function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons=1) {
     global $THEME, $CFG, $USER;
 
     $colour = $THEME->cellheading2;
@@ -18,7 +18,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $tab=""
         echo "</td>";
         echo "<td nowrap valign=\"top\" width=100% bgcolor=\"$THEME->cellheading\" class=\"forumpostheader\">";
 
-        glossary_print_entry_approval($cm, $entry, $tab);
+        glossary_print_entry_approval($cm, $entry, $mode);
         glossary_print_entry_attachment($entry,"html","right");
 
         echo "<b>";
@@ -35,7 +35,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $tab=""
         echo "\n<td width=100% bgcolor=\"$THEME->cellcontent\" class=\"forumpostmessage\">";
 
         glossary_print_entry_definition($entry);
-        glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$tab,$cat);
+        glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons);
 
     } else {
         echo "<center>";
index 3ad238b9760b3f189bd570d97a414e77b4b05281..d3c582d3304674db3d0c96b5266a6102248543ba 100644 (file)
@@ -1,6 +1,6 @@
 <?PHP  // $Id$
 
-function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $tab="",$cat="") {
+function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons=1) {
     global $THEME, $CFG, $USER;
 
     $colour = $THEME->cellheading2;
@@ -16,7 +16,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $tab=""
         print_user_picture($user->id, $course->id, $user->picture);
         echo "</td>";
         echo "<td align=\"top\" nowrap width=100% bgcolor=\"$THEME->cellheading\" class=\"forumpostheader\">";
-        glossary_print_entry_approval($cm, $entry, $tab);
+        glossary_print_entry_approval($cm, $entry, $mode);
         echo "<b>";
         glossary_print_entry_concept($entry);
                echo "</b><br />";
@@ -40,7 +40,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $tab=""
         }
         glossary_print_entry_definition($entry);
 
-        glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$tab,$cat);
+        glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons);
 
     } else {
         echo "<center>";
index 388c7e5d7116c18f7cabeb80854e7547d714d075..f8f1bc27b7206d50e98920c6d485e53cae25fc3c 100644 (file)
@@ -1,6 +1,6 @@
 <?PHP  // $Id$
 
-function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$tab="",$cat="") {
+function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$mode="",$hook="",$printicons=1) {
     global $THEME, $USER;
 
     if ( $entry ) {
@@ -11,7 +11,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$tab="",
         echo '<tr>';
         echo "<td width=100% bgcolor=\"$colour\">";
         $entry->course = $course->id;
-        glossary_print_entry_approval($cm, $entry, $tab);
+        glossary_print_entry_approval($cm, $entry, $mode);
         glossary_print_entry_attachment($entry,"html","right");
 
         echo '<b>' . get_string("question","glossary") . ':</b> ';
@@ -22,7 +22,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$tab="",
         echo glossary_print_entry_definition($entry);
 
 
-        glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $tab, $cat);
+        glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook,$printicons);
         echo '</td></tr></table>';
 
     } else {
index 94a099f78b55a2a539e29a045491b66fbebb221e..9d8e80686c4a1c64daae532e10b0c751b6771e7a 100644 (file)
@@ -1,6 +1,6 @@
 <?PHP  // $Id$
 
-function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$tab="",$cat="") {
+function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$mode="",$hook="",$printicons=1) {
     global $THEME, $USER;
 
     $colour = $THEME->cellheading2;
@@ -9,7 +9,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$tab="",
 
     echo "\n<tr>";
     echo "<td width=100% bgcolor=\"$colour\">";
-    glossary_print_entry_approval($cm, $entry, $tab);
+    glossary_print_entry_approval($cm, $entry, $mode);
     if ($entry) {
         glossary_print_entry_attachment($entry,"html","right");
         echo "<b>";
@@ -20,7 +20,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$tab="",
         echo "\n<tr><td width=100% bgcolor=\"$THEME->cellcontent\">";
                
         glossary_print_entry_definition($entry);
-        glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $tab, $cat);
+        glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook,$printicons);
     } else {
         echo "<center>";
         print_string("noentry", "glossary");
index 4b0123936133bda17fe2199697472e3a37a2adc3..a273d945795381eac5db29027225b97c97ee4661 100644 (file)
@@ -11,8 +11,8 @@
     optional_variable($file);             // file to import
     optional_variable($catsincl,0);       // Import Categories too?
 
-    optional_variable($lasttab,GLOSSARY_STANDARD_VIEW);
-    optional_variable($l,"ALL");
+    optional_variable($mode,'letter');
+    optional_variable($hook,"ALL");
 
     if (! $cm = get_record("course_modules", "id", $id)) {
         error("Course Module ID was incorrect");
@@ -93,6 +93,7 @@
                 $glossary->name                   = addslashes(utf8_decode($xmlglossary['NAME'][0]['#']));
                        $glossary->course                 = $course->id;
                 $glossary->globalglossary         = $xmlglossary['GLOBALGLOSSARY'][0]['#'];
+                $glossary->entbypage              = $xmlglossary['ENTBYPAGE'][0]['#'];
                        $glossary->intro                  = addslashes(utf8_decode($xmlglossary['INTRO'][0]['#']));
                 $glossary->showspecial            = $xmlglossary['SHOWSPECIAL'][0]['#'];
                 $glossary->showalphabet           = $xmlglossary['SHOWALPHABET'][0]['#'];
                             unset($newcat);
         
                             $newcat->name = $xmlcat['#']['NAME'][0]['#'];
+                            $newcat->usedynalink = $xmlcat['#']['USEDYNALINK'][0]['#'];
                             if ( !$category = get_record("glossary_categories","glossaryid",$glossary->id,"name",$newcat->name) ) {
                                 // Create the category if it does not exist
                                 unset($category);
index 2643d44a97ee48d09e885a45b61a9095b0cb2c88..5867e9ca39330980d9bcf58c2f41187c9e7f6497 100644 (file)
@@ -8,13 +8,15 @@ require_once("$CFG->dirroot/files/mimetypes.php");
 define("GLOSSARY_SHOW_ALL_CATEGORIES", 0);
 define("GLOSSARY_SHOW_NOT_CATEGORISED", -1);
 
+define("GLOSSARY_NO_VIEW", -1);
 define("GLOSSARY_STANDARD_VIEW", 0);
 define("GLOSSARY_CATEGORY_VIEW", 1);
 define("GLOSSARY_DATE_VIEW", 2);
-define("GLOSSARY_ADDENTRY_VIEW", 3);
-define("GLOSSARY_IMPORT_VIEW", 4);
-define("GLOSSARY_EXPORT_VIEW", 5);
-define("GLOSSARY_APPROVAL_VIEW", 6);
+define("GLOSSARY_AUTHOR_VIEW", 3);
+define("GLOSSARY_ADDENTRY_VIEW", 4);
+define("GLOSSARY_IMPORT_VIEW", 5);
+define("GLOSSARY_EXPORT_VIEW", 6);
+define("GLOSSARY_APPROVAL_VIEW", 7);
 
 define("GLOSSARY_FORMAT_SIMPLE", 0);
 define("GLOSSARY_FORMAT_CONTINUOUS", 1);
@@ -79,7 +81,7 @@ function glossary_delete_instance($id) {
     } else {
         if ($categories = get_records("glossary_categories","glossaryid",$glossary->id)) {
             $cats = "";
-            foreach ( $categories as $cat ) {
+            foreach ( $categories as $hook ) {
                 $cats .= "$cat->id,";
             }
             $cats = substr($cats,0,-1);
@@ -112,14 +114,55 @@ function glossary_user_outline($course, $user, $mod, $glossary) {
 /// $return->time = the time they did it
 /// $return->info = a short text description
 
-    return $return;
+    if ($entries = glossary_get_user_entries($glossary->id, $user->id)) {
+        $result->info = count($entries) . ' ' . get_string("entries", "glossary");
+
+        $lastpost = array_pop($entries);
+        $result->time = $lastpost->timemodified;
+        return $result;
+    }
+    return NULL;
+}
+
+function glossary_get_user_entries($glossaryid, $userid) {
+/// Get all the entries for a user in a glossary
+    global $CFG;
+
+    return get_records_sql("SELECT e.*, u.firstname, u.lastname, u.email, u.picture
+                              FROM {$CFG->prefix}glossary g, 
+                                   {$CFG->prefix}glossary_entries e, 
+                                   {$CFG->prefix}user u 
+                             WHERE g.id = '$glossaryid' 
+                               AND e.glossaryid = g.id 
+                               AND e.userid = '$userid' 
+                               AND e.userid = u.id
+                          ORDER BY e.timemodified ASC");
 }
 
 function glossary_user_complete($course, $user, $mod, $glossary) {
 /// Print a detailed representation of what a  user has done with
 /// a given particular instance of this module, for user activity reports.
+    global $CFG;
 
-    return true;
+    if ($entries = glossary_get_user_entries($glossary->id, $user->id)) {
+        if ( $glossary->displayformat == GLOSSARY_FORMAT_SIMPLE or
+             $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
+            print_simple_box_start("center","70%");
+        } else {
+            echo '<table width="95%" boder="0"><tr><td>';
+        }
+        foreach ($entries as $entry) {
+            $cm = get_coursemodule_from_instance("glossary", $glossary->id, $course->id);
+            glossary_print_entry($course, $cm, $glossary, $entry,"","",0);
+            echo '<p>';
+        }
+        if ( $glossary->displayformat == GLOSSARY_FORMAT_SIMPLE or
+             $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
+            print_simple_box_end();
+        } else {
+            echo '</td></tr></table>';
+        }
+    }
 }
 
 function glossary_print_recent_activity($course, $isteacher, $timestart) {
@@ -132,15 +175,16 @@ function glossary_print_recent_activity($course, $isteacher, $timestart) {
     if (!$logs = get_records_select("log", "time > '$timestart' AND ".
                                            "course = '$course->id' AND ".
                                            "module = 'glossary' AND ".
-                                           "action = 'add %' ", "time ASC")) {
+                                           "action = 'add entry'", "time ASC")) {
         return false;
     }
 
     foreach ($logs as $log) {
         //Create a temp valid module structure (course,id)
-        $tempmod->course = $log->course;
-        $tempmod->id = $log->info;
-        //Obtain the visible property from the instance
+        $tempmod->course = $log->course;        
+        $entry           = get_record("glossary_entries","id",$log->info);
+        $tempmod->id = $entry->glossaryid;
+        //Obtain the visible property from the instance        
         $modvisible = instance_is_visible($log->module,$tempmod);
 
         //Only if the mod is visible
@@ -168,6 +212,16 @@ function glossary_print_recent_activity($course, $isteacher, $timestart) {
     return $content;
 }
 
+function glossary_log_info($log) {
+    global $CFG;
+
+    return get_record_sql("SELECT e.*, u.firstname, u.lastname
+                             FROM {$CFG->prefix}glossary_entries e,
+                                  {$CFG->prefix}user u
+                            WHERE e.id = '$log->info'
+                              AND u.id = '$log->userid'");
+}
+
 function glossary_cron () {
 /// Function to be run periodically according to the moodle cron
 /// This function searches for things that need to be done, such
@@ -209,13 +263,13 @@ function glossary_get_participants($glossaryid) {
 /// Any other glossary functions go here.  Each of them must have a name that
 /// starts with glossary_
 
-function glossary_log_info($log) {
-    global $CFG;
-    return get_record_sql("SELECT g.*, u.firstname, u.lastname
-                             FROM {$CFG->prefix}glossary_entries g,
-                                  {$CFG->prefix}user u
-                            WHERE g.glossaryid = '$log->info'
-                              AND u.id = '$log->userid'");
+function glossary_debug($debug,$text,$br=1) {
+    if ( $debug ) {
+        echo '<font color=red>' . $text . '</font>';
+        if ( $br ) {
+            echo '<br>';
+        }
+    }
 }
 
 function glossary_get_entries($glossaryid, $entrylist, $pivot = "") {
@@ -245,7 +299,7 @@ global $CFG;
                                  WHERE (glossaryid = $glossary->id or sourceglossaryid = $glossary->id) $where $orderby");
 }
 
-function glossary_get_entries_by_category($glossary, $cat, $where="", $orderby="", $pivot = "") {
+function glossary_get_entries_by_category($glossary, $hook, $where="", $orderby="", $pivot = "") {
 global $CFG;
     if ($where) {
        $where = " and $where";
@@ -258,14 +312,14 @@ global $CFG;
     }
     return      get_records_sql("SELECT $pivot ge.*
                                  FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories c
-                                 WHERE (ge.id = c.entryid and c.categoryid = $cat) and
+                                 WHERE (ge.id = c.entryid and c.categoryid = $hook) and
                                              (ge.glossaryid = $glossary->id or ge.sourceglossaryid = $glossary->id) $where $orderby");
 }
 
-function glossary_print_entry($course, $cm, $glossary, $entry, $tab="",$cat="") {
+function glossary_print_entry($course, $cm, $glossary, $entry, $mode="",$hook="",$printicons = 1) {
     global $THEME, $USER, $CFG;
 
-    if ($entry->approved or ($USER->id == $entry->userid and !isteacher($course->id)) or $tab == GLOSSARY_APPROVAL_VIEW) {
+    if ($entry->approved or ($USER->id == $entry->userid and !isteacher($course->id)) or $mode == 'approval') {
         $permissiongranted = 0;
         $formatfile = "$CFG->dirroot/mod/glossary/formats/$glossary->displayformat.php";
         $functionname = "glossary_print_entry_by_format";
@@ -284,15 +338,15 @@ function glossary_print_entry($course, $cm, $glossary, $entry, $tab="",$cat="")
         }
     
         if ( !$basicformat and $permissiongranted ) {
-            glossary_print_entry_by_format($course, $cm, $glossary, $entry,$tab,$cat);
+            glossary_print_entry_by_format($course, $cm, $glossary, $entry,$mode,$hook,$printicons);
         } else {
             switch ( $glossary->displayformat ) {
-                case GLOSSARY_FORMAT_SIMPLE:
-                    glossary_print_entry_by_default($course, $cm, $glossary, $entry,$tab,$cat);
-                break;
-                case GLOSSARY_FORMAT_CONTINUOUS:
-                    glossary_print_entry_continuous($course, $cm, $glossary, $entry,$tab,$cat);
-                    break;
+            case GLOSSARY_FORMAT_SIMPLE:
+                glossary_print_entry_by_default($course, $cm, $glossary, $entry,$mode,$hook,$printicons);
+            break;
+            case GLOSSARY_FORMAT_CONTINUOUS:
+                glossary_print_entry_continuous($course, $cm, $glossary, $entry,$mode,$hook,$printicons);
+            break;
             }
         }
     }
@@ -306,7 +360,7 @@ function glossary_print_entry_definition($entry) {
     echo format_text($definition, $entry->format);
 }
 
-function  glossary_print_entry_aliases($course, $cm, $glossary, $entry,$tab="",$cat="", $mode = 'print') {
+function  glossary_print_entry_aliases($course, $cm, $glossary, $entry,$mode="",$hook="", $type = 'print') {
     $return = '';
     if ( $aliases = get_records("glossary_alias","entryid",$entry->id) ) {
         foreach ($aliases as $alias) {
@@ -322,14 +376,14 @@ function  glossary_print_entry_aliases($course, $cm, $glossary, $entry,$tab="",$
 //            $return = "<table border=0 align=$align><tr><td>$return</td></tr></table>";
         }
     } 
-    if ($mode == 'print') {
+    if ($type == 'print') {
         echo $return;
     } else {
         return $return;
     }
 }
 
-function glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab="",$cat="", $mode = 'print') {
+function glossary_print_entry_icons($course, $cm, $glossary, $entry,$mode="",$hook="", $type = 'print') {
     global $THEME, $USER;
 
     $importedentry = ($entry->sourceglossaryid == $glossary->id);
@@ -362,7 +416,7 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab="",$cat
             $mainglossary = get_record("glossary","mainglossary",1,"course",$course->id);
             if ( $mainglossary ) {  // if there is a main glossary defined, allow to export the current entry
 
-                $return .= " <a title=\"" . get_string("exporttomainglossary","glossary") . "\" href=\"exportentry.php?id=$cm->id&entry=$entry->id&tab=$tab&cat=$cat\"><img src=\"export.gif\" height=11 width=11 border=0></a> ";
+                $return .= " <a title=\"" . get_string("exporttomainglossary","glossary") . "\" href=\"exportentry.php?id=$cm->id&entry=$entry->id&mode=$mode&hook=$hook\"><img src=\"export.gif\" height=11 width=11 border=0></a> ";
 
             }
         }
@@ -375,27 +429,30 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab="",$cat
 
         // Exported entries can be updated/deleted only by teachers in the main glossary
         if ( !$importedentry and ($isteacher or !$ismainglossary) ) {
-            $return .= " <a title=\"" . get_string("delete") . "\" href=\"deleteentry.php?id=$cm->id&mode=delete&entry=$entry->id&tab=$tab&cat=$cat\"><img src=\"";
+            $return .= " <a title=\"" . get_string("delete") . "\" href=\"deleteentry.php?id=$cm->id&mode=delete&entry=$entry->id&prevmode=$mode&hook=$hook\"><img src=\"";
             $return .= $icon;
             $return .= "\" height=11 width=11 border=0></a> ";
             
-            $return .= " <a title=\"" . get_string("edit") . "\" href=\"edit.php?id=$cm->id&e=$entry->id&tab=$tab&cat=$cat\"><img src=\"../../pix/t/edit.gif\" height=11 width=11 border=0></a>";
+            $return .= " <a title=\"" . get_string("edit") . "\" href=\"edit.php?id=$cm->id&e=$entry->id&mode=$mode&hook=$hook\"><img src=\"../../pix/t/edit.gif\" height=11 width=11 border=0></a>";
         } elseif ( $importedentry ) {
             $return .= " <font size=-1>" . get_string("exportedentry","glossary") . "</font>";
         }
     }
     $return .= "&nbsp;&nbsp;"; // just to make up a little the output in Mozilla ;)
-    if ($mode == 'print') {
+    if ($type == 'print') {
         echo $return;
     } else {
         return $return;
     }
 }
 
-function  glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $tab, $cat) {
+function  glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook,$printicons) {
 
-    $aliases = glossary_print_entry_aliases($course, $cm, $glossary, $entry, $tab, $cat,"html");
-    $icons   = glossary_print_entry_icons($course, $cm, $glossary, $entry, $tab, $cat,"html");
+    $aliases = glossary_print_entry_aliases($course, $cm, $glossary, $entry, $mode, $hook,"html");
+    $icons   = "";
+    if ( $printicons ) {
+        $icons   = glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode, $hook,"html");
+    }
     if ( $aliases ) {
         echo '<table border="0" width="100%" align="center"><tr>' .
               '<td align="right" width="50%" valign=top><font size=1>' .
@@ -421,39 +478,43 @@ function glossary_print_entry_attachment($entry,$format=NULL,$align="right") {
     }
 }
 
-function  glossary_print_entry_approval($cm, $entry, $tab) {
-    if ( $tab == GLOSSARY_APPROVAL_VIEW ) {
-        echo "<a title=\"" . get_string("approve","glossary"). "\" href=\"approve.php?id=$cm->id&eid=$entry->id&tab=$tab\"><IMG align=\"right\" src=\"check.gif\" border=0 width=\"34\" height=\"34\"></a>";
+function  glossary_print_entry_approval($cm, $entry, $mode) {
+    if ( $mode == 'approval' and !$entry->approved ) {
+        echo "<a title=\"" . get_string("approve","glossary"). "\" href=\"approve.php?id=$cm->id&eid=$entry->id&mode=$mode\"><IMG align=\"right\" src=\"check.gif\" border=0 width=\"34\" height=\"34\"></a>";
     }
 }
 
-function glossary_print_entry_by_default($course, $cm, $glossary, $entry,$tab="",$cat="") {
+function glossary_print_entry_by_default($course, $cm, $glossary, $entry,$mode="",$hook="",$printicons=1) {
     global $THEME, $USER;
 
     $colour = $THEME->cellheading2;
 
     echo "\n<TR>";
     echo "<TD WIDTH=100% class=\"generalbox\" valign=\"top\" BGCOLOR=\"#FFFFFF\">";
-        glossary_print_entry_approval($cm, $entry, $tab);
+        glossary_print_entry_approval($cm, $entry, $mode);
         glossary_print_entry_attachment($entry,"html","right");
         echo "<b>";
         glossary_print_entry_concept($entry);
         echo ":</b> ";
         glossary_print_entry_definition($entry);
-        glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$tab,$cat);
+        glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$mode,$hook,$printicons);
     echo "</td>";
     echo "</TR>";
 }
 
-function glossary_print_entry_continuous($course, $cm, $glossary, $entry,$tab="",$cat="") {
+function glossary_print_entry_continuous($course, $cm, $glossary, $entry,$mode="",$hook="",$printicons=1) {
     global $THEME, $USER;
     if ($entry) {
-        glossary_print_entry_approval($cm, $entry, $tab);
+        glossary_print_entry_approval($cm, $entry, $mode);
         glossary_print_entry_attachment($entry,"html","right");
         glossary_print_entry_concept($entry);
         echo " ";
+        
         glossary_print_entry_definition($entry);
-        glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $tab, $cat);
+        if ( $printicons ) {
+            $icons   = glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode, $hook,"html");        
+            echo "($icons)";
+        }
     }
 }
 
@@ -853,48 +914,58 @@ function glossary_print_tabbed_table_end() {
      echo "</center><p></td></tr></table></center>";
 }
 
-function glossary_print_approval_menu($cm, $glossary, $l, $sortkey, $sortorder = "",$tab=GLOSSARY_STANDARD_VIEW) {
+function glossary_print_approval_menu($cm, $glossary,$mode, $hook, $sortkey = '', $sortorder = '') {
     if ($glossary->showalphabet and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) {
         echo '<center>' . get_string("explainalphabet","glossary") . '<p>';
     }
-    glossary_print_special_links($cm, $glossary,$l, $tab);
+    glossary_print_special_links($cm, $glossary, $mode, $hook);
 
-    glossary_print_alphabet_links($cm, $glossary,$l, $tab);
+    glossary_print_alphabet_links($cm, $glossary, $mode, $hook);
 
-    glossary_print_all_links($cm, $glossary,$l, $tab);
+    glossary_print_all_links($cm, $glossary, $mode, $hook);
         
-    glossary_print_sorting_links($cm, $sortkey,$sortorder, $tab);
+    glossary_print_sorting_links($cm, $mode, $sortkey, $sortorder);
 }
 
-function glossary_print_addentry_menu($cm, $glossary, $l, $sortkey, $sortorder = "", $tab=GLOSSARY_STANDARD_VIEW) {
+function glossary_print_addentry_menu($cm, $glossary, $mode, $hook, $sortkey='', $sortorder = '') {
     echo '<center>' . get_string("explainaddentry","glossary") . '<p>';
 }
 
-function glossary_print_import_menu($cm, $glossary, $l, $sortkey, $sortorder = "", $tab=GLOSSARY_STANDARD_VIEW) {
+function glossary_print_import_menu($cm, $glossary, $mode, $hook, $sortkey='', $sortorder = '') {
     echo '<center>' . get_string("explainimport","glossary") . '<p>';
 }
 
-function glossary_print_export_menu($cm, $glossary, $l, $sortkey, $sortorder = "", $tab=GLOSSARY_STANDARD_VIEW) {
+function glossary_print_export_menu($cm, $glossary, $mode, $hook, $sortkey='', $sortorder = '') {
     echo '<center>' . get_string("explainexport","glossary") . '<p>';
 }
 
-function glossary_print_alphabet_menu($cm, $glossary, $l, $sortkey, $sortorder = "", $tab=GLOSSARY_STANDARD_VIEW) {
-    if ( $tab != GLOSSARY_DATE_VIEW ) {
+function glossary_print_alphabet_menu($cm, $glossary, $mode, $hook, $sortkey='', $sortorder = '') {
+    if ( $mode != 'date' ) {
         if ($glossary->showalphabet and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) {
             echo '<center>' . get_string("explainalphabet","glossary") . '<p>';
         }
 
-        glossary_print_special_links($cm, $glossary,$l, $tab);
+        glossary_print_special_links($cm, $glossary, $mode, $hook);
 
-        glossary_print_alphabet_links($cm, $glossary,$l, $tab);
+        glossary_print_alphabet_links($cm, $glossary, $mode, $hook);
 
-        glossary_print_all_links($cm, $glossary,$l, $tab);
+        glossary_print_all_links($cm, $glossary, $mode, $hook);
     } else {
-        glossary_print_sorting_links($cm, $sortkey,$sortorder, $tab);
+        glossary_print_sorting_links($cm, $mode, $sortkey,$sortorder);
+    }
+}
+
+function glossary_print_author_menu($cm, $glossary,$mode, $hook, $sortkey = '', $sortorder = '') {
+    if ($glossary->showalphabet and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) {
+        echo '<center>' . get_string("explainalphabet","glossary") . '<p>';
     }
+
+    glossary_print_alphabet_links($cm, $glossary, $mode, $hook);
+    echo "<br />";
+    glossary_print_all_links($cm, $glossary, $mode, $hook);
 }
 
-function glossary_print_categories_menu($course, $cm, $glossary, $cat, $category) {
+function glossary_print_categories_menu($cm, $glossary, $hook, $category) {
 global $CFG, $THEME;
      echo '<table border=0 width=100%>';
      echo '<tr>';
@@ -902,7 +973,8 @@ global $CFG, $THEME;
      echo '<td align=center width=20%>';
      if ( isteacher($course->id) ) {
              $options['id'] = $cm->id;
-             $options['cat'] = $cat;
+             $options['mode'] = 'cat';
+             $options['hook'] = $hook;
              echo print_single_button("editcategories.php", $options, get_string("editcategories","glossary"), "get");
      }
      echo '</td>';
@@ -933,12 +1005,12 @@ global $CFG, $THEME;
      if ( $category ) {
         echo $category->name;
      } else {
-        if ( $cat == GLOSSARY_SHOW_NOT_CATEGORISED ) {
+        if ( $hook == GLOSSARY_SHOW_NOT_CATEGORISED ) {
 
             echo get_string("entrieswithoutcategory","glossary");
             $selected = GLOSSARY_SHOW_NOT_CATEGORISED;
 
-        } elseif ( $cat == GLOSSARY_SHOW_ALL_CATEGORIES ) {
+        } elseif ( $hook == GLOSSARY_SHOW_ALL_CATEGORIES ) {
 
             echo get_string("allcategories","glossary");
             $selected = GLOSSARY_SHOW_ALL_CATEGORIES;
@@ -948,7 +1020,7 @@ global $CFG, $THEME;
      echo '</b></td>';
      echo '<td align=center width=20%>';
 
-     echo popup_form("$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&tab=" . GLOSSARY_CATEGORY_VIEW . "&cat=", $menu, "catmenu", $selected, "",
+     echo popup_form("$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&mode=cat&hook=", $menu, "catmenu", $selected, "",
                       "", "", false);
 
      echo '</td>';
@@ -957,42 +1029,42 @@ global $CFG, $THEME;
      echo '</table>';
 }
 
-function glossary_print_all_links($cm, $glossary, $l, $tab) {
+function glossary_print_all_links($cm, $glossary, $mode, $hook) {
 global $CFG;  
      if ( $glossary->showall and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) {
          $strallentries       = get_string("allentries", "glossary");
-         if ( $l == 'ALL' ) {
+         if ( $hook == 'ALL' ) {
               echo "<b>$strallentries</b>";
          } else {
               $strexplainall = strip_tags(get_string("explainall","glossary"));
-              echo "<a title=\"$strexplainall\" href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&l=ALL&tab=$tab\">$strallentries</a>";
+              echo "<a title=\"$strexplainall\" href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&mode=$mode&hook=ALL\">$strallentries</a>";
          }
      }
 }
 
-function glossary_print_special_links($cm, $glossary, $l, $tab) {
+function glossary_print_special_links($cm, $glossary, $mode, $hook) {
 global $CFG;
      if ( $glossary->showspecial and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS ) {
          $strspecial          = get_string("special", "glossary");
-         if ( $l == 'SPECIAL' ) {
+         if ( $hook == 'SPECIAL' ) {
               echo "<b>$strspecial</b> | ";
          } else {
               $strexplainspecial = strip_tags(get_string("explainspecial","glossary"));
-              echo "<a title=\"$strexplainspecial\" href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&l=SPECIAL&tab=$tab\">$strspecial</a> | ";
+              echo "<a title=\"$strexplainspecial\" href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&mode=$mode&hook=SPECIAL\">$strspecial</a> | ";
          }
      }
 }
 
-function glossary_print_alphabet_links($cm, $glossary,$l, $tab) {
+function glossary_print_alphabet_links($cm, $glossary, $mode, $hook) {
 global $CFG;
      if ( $glossary->showalphabet and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS ) {
           $alphabet = explode(",", get_string("alphabet"));
           $letters_by_line = 14;
           for ($i = 0; $i < count($alphabet); $i++) {
-              if ( $l == $alphabet[$i] and $l) {
+              if ( $hook == $alphabet[$i] and $hook) {
                    echo "<b>$alphabet[$i]</b>";
               } else {
-                   echo "<a href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&l=$alphabet[$i]&tab=$tab\">$alphabet[$i]</a>";
+                   echo "<a href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&mode=$mode&hook=$alphabet[$i]\">$alphabet[$i]</a>";
               }
               if ((int) ($i % $letters_by_line) != 0 or $i == 0) {
                    echo ' | ';
@@ -1003,7 +1075,7 @@ global $CFG;
      }
 }
 
-function glossary_print_sorting_links($cm, $sortkey,$sortorder, $tab) {
+function glossary_print_sorting_links($cm, $mode, $sortkey = '',$sortorder = '') {
 global $CFG;
     $strsort             = get_string("sortchronogically", "glossary");
     $strsortbycreation   = get_string("sortbycreation", "glossary");
@@ -1057,8 +1129,8 @@ global $CFG;
          $cordertitle = get_string("ascending","glossary");
          $uordertitle = get_string("ascending","glossary");
      }
-     echo "<br>$strsort: $ubtag<a title=\"$strsortbylastupdate $uordertitle\" href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&sortkey=UPDATE$uneworder&tab=$tab\">$strsortbylastupdate$uicon</a>$uendbtag | ".
-                          "$cbtag<a title=\"$strsortbycreation $cordertitle\" href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&sortkey=CREATION$cneworder&tab=$tab\">$strsortbycreation$cicon</a>$cendbtag</p>";
+     echo "<br>$strsort: $ubtag<a title=\"$strsortbylastupdate $uordertitle\" href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&sortkey=UPDATE$uneworder&mode=$mode\">$strsortbylastupdate$uicon</a>$uendbtag | ".
+                          "$cbtag<a title=\"$strsortbycreation $cordertitle\" href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&sortkey=CREATION$cneworder&mode=$mode\">$strsortbycreation$cicon</a>$cendbtag</p>";
 }
 
 function glossary_sort_entries ( $entry0, $entry1 ) {
@@ -1137,7 +1209,7 @@ function glossary_print_dynaentry($courseid, $entries) {
     echo "</tr></table></center>";
 }
 
-function glossary_generate_export_file($glossary, $l = "", $cat = 0) {
+function glossary_generate_export_file($glossary, $hook = "", $hook = 0) {
 global $CFG;
     glossary_check_moddata_dir($glossary);
     $h = glossary_open_xml($glossary);
@@ -1154,30 +1226,31 @@ global $CFG;
         fwrite ($h,glossary_full_tag("USEDYNALINK",2,false,$glossary->usedynalink));
         fwrite ($h,glossary_full_tag("DEFAULTAPPROVAL",2,false,$glossary->defaultapproval));
         fwrite ($h,glossary_full_tag("GLOBALGLOSSARY",2,false,$glossary->globalglossary));
+        fwrite ($h,glossary_full_tag("ENTBYPAGE",2,false,$glossary->entbypage));
 
         if ( $entries = get_records("glossary_entries","glossaryid",$glossary->id) ) {
             $status = fwrite ($h,glossary_start_tag("ENTRIES",2,true));
             foreach ($entries as $entry) {
                 $permissiongranted = 1;
-                if ( $l ) {
-                    switch ( $l ) {
+                if ( $hook ) {
+                    switch ( $hook ) {
                     case "ALL":
                     case "SPECIAL":
                     break;
                     default:
-                        $permissiongranted = ($entry->concept[ strlen($l)-1 ] == $l);
+                        $permissiongranted = ($entry->concept[ strlen($hook)-1 ] == $hook);
                     break;
                     }
                 }
-                if ( $cat ) {
-                    switch ( $cat ) {
+                if ( $hook ) {
+                    switch ( $hook ) {
                     case GLOSSARY_SHOW_ALL_CATEGORIES:
                     break;
                     case GLOSSARY_SHOW_NOT_CATEGORISED:
                         $permissiongranted = !record_exists("glossary_entries_categories","entryid",$entry->id);
                     break;
                     default:
-                        $permissiongranted = record_exists("glossary_entries_categories","entryid",$entry->id, "categoryid",$cat);
+                        $permissiongranted = record_exists("glossary_entries_categories","entryid",$entry->id, "categoryid",$hook);
                     break;
                     }
                 }
@@ -1207,6 +1280,7 @@ global $CFG;
 
                             $status = fwrite ($h,glossary_start_tag("CATEGORY",5,true));
                                 fwrite($h,glossary_full_tag("NAME",6,false,$category->name));
+                                fwrite($h,glossary_full_tag("USEDYNALINK",6,false,$category->usedynalink));
                             $status = fwrite($h,glossary_end_tag("CATEGORY",5,true));
                         }
                         $status = fwrite($h,glossary_end_tag("CATEGORIES",4,true));
@@ -1336,4 +1410,4 @@ function glossary_check_dir_exists($dir,$create=false) {
     }
     return $status;
 }
-?>
+?>
\ No newline at end of file
index b78c0bedfcc4899971fe596a1458a6f04c2ecd63..d979d4640492c8e8b6324abb7fe57b32b543f1e9 100644 (file)
@@ -5,19 +5,22 @@
 global $CFG;
 
 if (!isset($form->studentcanpost)) {
-    $form->studentcanpost = $CFG->cnfstudentcanpost;
+    $form->studentcanpost = $CFG->glossary_studentspost;
 }
 if (!isset($form->allowduplicatedentries)) {
-    $form->allowduplicatedentries = $CFG->cnfallowdupentries;
+    $form->allowduplicatedentries = $CFG->glossary_dupentries;
 }
 if (!isset($form->allowcomments)) {
-    $form->allowcomments = $CFG->cnfallowcomments;
+    $form->allowcomments = $CFG->glossary_allowcomments;
 }
 if (!isset($form->usedynalink)) {
-    $form->usedynalink = $CFG->cnflinkglossaries;
+    $form->usedynalink = $CFG->glossary_linkbydefault;
 }
 if (!isset($form->defaultapproval)) {
-    $form->defaultapproval = $CFG->cnfapprovalstatus;
+    $form->defaultapproval = $CFG->glossary_defaultapproval;
+}
+if (!isset($form->entbypage)) {
+    $form->entbypage = $CFG->glossary_entbypage;
 }
 if (!isset($form->mainglossary)) {
     $form->mainglossary = 0;
@@ -70,6 +73,13 @@ if (!isset($form->showspecial)) {
         <textarea name="intro" rows=5 cols=50 wrap="virtual"><?php p($form->intro) ?></textarea>
     </td>
 </tr>
+<TR valign=top>
+    <TD align=right><P><B><?php echo get_string("entbypage", "glossary") ?>:</B></P></TD>
+    <TD>
+               <input name=entbypage type=text size=2 value="<?php p($form->entbypage) ?>"> <?php helpbutton("entbypage", get_string("entbypage", "glossary"), "glossary") ?>
+    </TD>
+</TR>
+
 <!-- More rows go in here... -->
 <?php
 if (isadmin() ) {
index 5a97381ebb6c5025891fad8e7a739aa58747a301..11ddc74909707e6cc1710b6a5b7da05b04665daf 100644 (file)
@@ -5,13 +5,12 @@
     global $CFG;
     
     require_variable($id);                         // Course Module ID
-    require_variable($tab,GLOSSARY_STANDARD_VIEW); // format to show the entries
+    require_variable($mode,"letter"); // format to show the entries
     optional_variable($sortkey,"UPDATE");          // Sorting key if TAB = GLOSSARY_DATE_VIEW
     optional_variable($sortorder,"asc");           // Sorting order if TAB = GLOSSARY_DATE_VIEW
-    optional_variable($l,"ALL");          
+    optional_variable($hook,"ALL");          
     optional_variable($eid);          
     optional_variable($search);
-    optional_variable($cat,GLOSSARY_SHOW_ALL_CATEGORIES);          
 
     if (! $cm = get_record("course_modules", "id", $id)) {
         error("Course Module ID was incorrect");
     }
 
     if ( $eid ) {
-        $l = '';
-        $tab = GLOSSARY_STANDARD_VIEW;
+        $mode = 'entry';
     }
 /// Generating the SQL based on the format to show
-    switch ($tab) {
-    case GLOSSARY_CATEGORY_VIEW:
+    switch ($mode) {
+    case "cat":
         $where = '';
-        if ($cat) {
-            if ( $cat != GLOSSARY_SHOW_ALL_CATEGORIES and $cat != GLOSSARY_SHOW_NOT_CATEGORISED ) {
-                    $where = 'and c.id = ' . $cat;
+        if ($hook) {
+            if ( $hook != GLOSSARY_SHOW_ALL_CATEGORIES and $hook != GLOSSARY_SHOW_NOT_CATEGORISED ) {
+                    $where = 'and c.id = ' . $hook;
             }
         }
-        $entries = get_records_sql("SELECT c.name pivot, e.*
+        $entries = get_records_sql("SELECT ec.id, c.name pivot, e.*
                                     FROM {$CFG->prefix}glossary_entries e,
                                          {$CFG->prefix}glossary_entries_categories ec,
                                          {$CFG->prefix}glossary_categories as c
@@ -56,7 +54,7 @@
 
     break;
 
-    case GLOSSARY_DATE_VIEW:
+    case "date":
     //// Valid sorting values
         switch ($sortkey) {
         case 'CREATION':
@@ -79,7 +77,7 @@
                                     ORDER BY e.$sortkey $sortorder");
 
     break;
-    case GLOSSARY_STANDARD_VIEW:
+    case "letter":
     default:
         switch ($CFG->dbtype) {
         case "postgres7":
         break;
         }
 
-        if ( $l ) {
-            if ($l != 'ALL' and $l != 'SPECIAL') {
+        if ( $hook ) {
+            if ($hook != 'ALL' and $hook != 'SPECIAL') {
                 switch ($CFG->dbtype) {
                 case 'postgres7':
-                    $where = 'and substr(ucase(concept),1,' .  strlen($l) . ') = \'' . strtoupper($l) . '\'';
+                    $where = 'and substr(ucase(concept),1,' .  strlen($hook) . ') = \'' . strtoupper($hook) . '\'';
                 break;
                 case 'mysql':
-                    $where = 'and left(ucase(concept),' .  strlen($l) . ") = '$l'";
+                    $where = 'and left(ucase(concept),' .  strlen($hook) . ") = '" . strtoupper($hook) . "'";
                 break;
                 default:
                     $where = '';
             $where = " and e.id = $eid";
         }
 
-        $entries = get_records_sql("SELECT $pivot pivot, e.*
+        $entries = get_records_sql("SELECT e.id, $pivot pivot, e.*
                                     FROM {$CFG->prefix}glossary_entries e
                                     WHERE (e.glossaryid = $glossary->id or e.sourceglossaryid = $glossary->id)
                                           AND e.approved != 0 $where
         echo get_string("noentries","glossary");
         exit;
     }
+                                    
     $groupheader = '';
     $tableisopen = 0;
     foreach ($entries as $entry) {
         $pivot = $entry->pivot;
-        if ( $CFG->dbtype != "postgres7" and $CFG->dbtype != "mysql" and $tab != GLOSSARY_CATEGORY_VIEW) {
+        if ( $CFG->dbtype != "postgres7" and $CFG->dbtype != "mysql" and $mode != "cat") {
             $pivot = $pivot[0];
         }
         
-        if ($tab != GLOSSARY_DATE_VIEW) {
-            if ($groupheader != $pivot) {
+        if ($mode != "date") {
+            if (strtoupper($groupheader) != strtoupper($pivot)) {
             /// Printing th eheader of the group
 
                 if ($tableisopen) {
index c40d65268598de7218f59eb160225ba5cef6c4ed..1b05b0fdf6713a28a55198ba8c4abf2a72f01894 100644 (file)
             //Now, build the GLOSSARY_CATEGORIES record structure
             $category->glossaryid = $new_glossary_id;
             $category->name = backup_todb($cat_info['#']['NAME']['0']['#']);
+            $category->usedynalink = backup_todb($cat_info['#']['USEDYNALINK']['0']['#']);
 
             $newid = insert_record ("glossary_categories",$category);
 
index 743774069fbae276f430055566171f22f62f9f4d..c7fd7c3dd3b02a759274eb40592018779da0f24d 100644 (file)
@@ -2,18 +2,25 @@
     require_once("../../config.php");
     require_once("lib.php");
 
-    require_variable($concept);
+    optional_variable($concept);
     optional_variable($courseid,0);
+    optional_variable($eid,0);
 
     print_header();
-    $entries = get_records_sql("select e.* from {$CFG->prefix}glossary_entries e, {$CFG->prefix}glossary g".
+    if ( $eid ) {
+        $entries = get_records_sql("select e.* from {$CFG->prefix}glossary_entries e, {$CFG->prefix}glossary g".
+                                  " where (e.id = $eid)");
+    } elseif ( $concept ) {
+        $entries = get_records_sql("select e.* from {$CFG->prefix}glossary_entries e, {$CFG->prefix}glossary g".
                                   " where e.glossaryid = g.id and".
                                       " (e.casesensitive != 0 and ucase(concept) = '" . strtoupper(trim($concept)). "' or".
                                       " e.casesensitive = 0 and concept = '$concept') and".
                                       " (g.course = $courseid or g.globalglossary) and".
                                       " e.usedynalink != 0 and g.usedynalink != 0");
-    
-    glossary_print_dynaentry($courseid, $entries);
+    } 
+    if ( $entries ) {
+        glossary_print_dynaentry($courseid, $entries);
+    }    
     
     close_window_button();
 ?>
index db3d0b93aab554300590fa452429b34ca3911bd9..be9b0c479c9b6da35d145ba0e7697b949a639565 100644 (file)
@@ -12,6 +12,7 @@
     $data[GLOSSARY_STANDARD_VIEW]->caption = get_string("standardview", "glossary");
     $data[GLOSSARY_CATEGORY_VIEW]->caption = get_string("categoryview", "glossary");
     $data[GLOSSARY_DATE_VIEW]->caption = get_string("dateview", "glossary");
+    $data[GLOSSARY_AUTHOR_VIEW]->caption = get_string("authorview","glossary");
     if (!isguest()) {
         if ( isteacher($course->id) or $glossary->studentcanpost  ) {
             $data[GLOSSARY_ADDENTRY_VIEW]->caption = get_string("addentry", "glossary");
         $data[GLOSSARY_EXPORT_VIEW]->caption = "Export Entries";
 
         $data[GLOSSARY_IMPORT_VIEW]->link = "import.php?id=$cm->id";
-        $data[GLOSSARY_EXPORT_VIEW]->link = "export.php?id=$cm->id&l=$l&cat=$cat&tab=".GLOSSARY_CATEGORY_VIEW;
+        $data[GLOSSARY_EXPORT_VIEW]->link = "export.php?id=$cm->id&tab=".GLOSSARY_CATEGORY_VIEW;
+
+        $data[GLOSSARY_IMPORT_VIEW]->link = "import.php?id=$cm->id";
+        $data[GLOSSARY_EXPORT_VIEW]->link = "export.php?id=$cm->id&mode=$mode&hook=$hook";
+
     }
 
-    $data[GLOSSARY_DATE_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_DATE_VIEW;
+//    $data[GLOSSARY_DATE_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_DATE_VIEW;
+
+    $data[GLOSSARY_DATE_VIEW]->link = "view.php?id=$id&mode=date";
+
     if ( $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS ) {
         $data[GLOSSARY_STANDARD_VIEW]->link = "view.php?id=$id";
         $data[GLOSSARY_CATEGORY_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_CATEGORY_VIEW;
-    }
 
+        $data[GLOSSARY_STANDARD_VIEW]->link = "view.php?id=$id";
+        $data[GLOSSARY_CATEGORY_VIEW]->link = "view.php?id=$id&mode=cat";
+        $data[GLOSSARY_AUTHOR_VIEW]->link = "view.php?id=$id&mode=author";
 
+    }
 
     if (isteacher($course->id)) {
         $data[GLOSSARY_APPROVAL_VIEW]->caption = get_string("waitingapproval", "glossary");
@@ -43,6 +54,9 @@
         if ($hiddenentries) {
             $data[GLOSSARY_APPROVAL_VIEW]->caption .= "<br><font size=1>(" . count($hiddenentries) . " " . get_string("entries","glossary") . ")</font>";
             $data[GLOSSARY_APPROVAL_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_APPROVAL_VIEW;
+
+            $data[GLOSSARY_APPROVAL_VIEW]->link = "view.php?id=$id&mode=approval";
+
         } elseif ( $tab == GLOSSARY_APPROVAL_VIEW ) {
             $tab = $framebydefault;
         }
 /// printing header of the current tab
     echo '<center>';
     glossary_print_tabbed_table_start($data, $tab, $glossary_tCFG);
+    
     switch ($tab) {
         case GLOSSARY_CATEGORY_VIEW:
-            glossary_print_categories_menu($course, $cm, $glossary, $cat, $category);
+            glossary_print_categories_menu($cm, $glossary, $hook, $category);
         break;
         case GLOSSARY_APPROVAL_VIEW:
-            glossary_print_approval_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab);
+            glossary_print_approval_menu($cm, $glossary, $mode, $hook, $sortkey, $sortorder);
         break;
         case GLOSSARY_ADDENTRY_VIEW:
             $search = "";
             $l = "";
-            glossary_print_addentry_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab);
+            glossary_print_addentry_menu($cm, $glossary, $mode, $hook, $sortkey, $sortorder);
+        break;
+        case GLOSSARY_AUTHOR_VIEW:
+            $search = "";
+            glossary_print_author_menu($cm, $glossary, "author", $hook, $sortkey, $sortorder, 'print');
         break;
         case GLOSSARY_IMPORT_VIEW:
             $search = "";
             $l = "";
-            glossary_print_import_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab);
+            glossary_print_import_menu($cm, $glossary, 'import', $hook, $sortkey, $sortorder);
         break;
         case GLOSSARY_EXPORT_VIEW:
             $search = "";
             $l = "";
-            glossary_print_export_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab);
+            glossary_print_export_menu($cm, $glossary, 'export', $hook, $sortkey, $sortorder);
         break;
         case GLOSSARY_DATE_VIEW:
             if (!$sortkey) {
             if (!$sortorder) {
                 $sortorder = 'desc';
             }
+            glossary_print_alphabet_menu($cm, $glossary, "date", $hook, $sortkey, $sortorder);
+        break;
         case GLOSSARY_STANDARD_VIEW:
         default:
-            glossary_print_alphabet_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab);
+            glossary_print_alphabet_menu($cm, $glossary, "letter", $hook, $sortkey, $sortorder);
             if ($search) {
                 echo "<h3>$strsearch: $search</h3>";
             } 
index 0b9394600744ad239c2311b9cf8c86d4608f1665..8ef1e439b714aede223e92e21a40cb39a243137b 100644 (file)
@@ -5,7 +5,7 @@
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 /////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2003110400;  // The current module version (Date: YYYYMMDDXX)
+$module->version  = 2003111500;  // 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 27d7f0bb66749c3917275df4aa5c6278e9674328..f7725a4c271007e56d7bc2509d887afb9eaf2f4d 100644 (file)
@@ -1,65 +1,66 @@
-<?php // $Id$
-
+<?php
 /// This page prints a particular instance of glossary
     require_once("../../config.php");
     require_once("lib.php");
-    
+    $debug = 0;
+        
     require_variable($id);           // Course Module ID
-    optional_variable($l,"");        // letter to look for
-    optional_variable($offset,0);    // entries to bypass (paging purpouses)
-    optional_variable($eid);         // Entry ID
-    optional_variable($search, "");  // search string
-    optional_variable($includedefinition); // include definition in search function?
-    
-    optional_variable($tab); // browsing entries by categories?
-    optional_variable($cat);         // categoryID
+    optional_variable($tab,GLOSSARY_NO_VIEW); // browsing entries by categories?
 
-    optional_variable($sortkey,"");  // Sorted view: CREATION or UPDATE
-    optional_variable($sortorder,"");  // it define the order of the sorting (ASC or DESC)
+    optional_variable($mode,"letter");  // [ "term"   | "entry"  | "cat"     | "date" | 
+                                        //   "letter" | "search" | "author"  | "approval" ]
+    optional_variable($hook,"");  // the term, entry, cat, etc... to look for based on mode
 
-    global $CFG;
-    $entriesbypage = $CFG->glossary_entbypage;
+    optional_variable($fullsearch,0); // full search (concept and definition) when searching?
+
+    optional_variable($sortkey,"");    // Sorted view: 
+                                       //    [ CREATION | UPDATE | concept | timecreated | ... ]
+    optional_variable($sortorder,"");  // it defines the order of the sorting (ASC or DESC)
+
+    optional_variable($offset,0);    // entries to bypass (for paging purpouses)
 
-    if (!$entriesbypage) {
-        $entriesbypage = 10;
-    }
     if (! $cm = get_record("course_modules", "id", $id)) {
         error("Course Module ID was incorrect");
-    } 
-    
-    if ($tab == GLOSSARY_ADDENTRY_VIEW and !$eid) {
-        redirect("edit.php?id=$cm->id&tab=$tab");
-    }
-
+    }     
     if (! $course = get_record("course", "id", $cm->course)) {
         error("Course is misconfigured");
-    } 
-    
+    }     
     if (! $glossary = get_record("glossary", "id", $cm->instance)) {
         error("Course module is incorrect");
     } 
     
+/// redirecting if adding a new entry
+    if ($tab == GLOSSARY_ADDENTRY_VIEW ) {
+        redirect("edit.php?id=$cm->id&mode=$mode");
+    }
+
+/// setting the defaut number of entries per page if not set
+    global $CFG, $THEME, $USER;
+    
+    if ( !$entriesbypage = $glossary->entbypage ) {
+        $entriesbypage = 10;
+    }
+
+/// setting the right fram for a "Continuous" glossary
+    if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
+        $mode = 'date';
+    }
+
+/// Processing standard security processes
+    $navigation = "";
     if ($course->category) {
+        $navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
         require_login($course->id);
     }
     if (!$cm->visible and !isteacher($course->id)) {
         notice(get_string("activityiscurrentlyhidden"));
     } 
     add_to_log($course->id, "glossary", "view", "view.php?id=$cm->id&tab=$tab", "$glossary->id");
-    
-/// stablishing default tab
-    $framebydefault = GLOSSARY_STANDARD_VIEW;
-    if ($glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS) {
-        $framebydefault = GLOSSARY_DATE_VIEW;
-    }
 
-/// checking for valid values for sortorder and sortkey
+/// stablishing flag variables
     if ( $sortorder = strtolower($sortorder) ) {
         if ($sortorder != 'asc' and $sortorder != 'desc') {
             $sortorder = '';
-        } else {
-            $l = ''; /// if we are sorting by date, reset the searching by terms or letters
-            $search = '';
         }
     }
     if ( $sortkey = strtoupper($sortkey) ) {
             $sortkey = '';
         }
     }
-/// in this point:
-///       $sortkey   = CREATION | UPDATE | ''
-///       $sortorder = asc | desc | ''
 
-    if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
-        $tab = $framebydefault;
-
-        if ( !$sortkey ) {
-            $sortkey = 'CREATION';
-        } 
-        if ( !$sortorder ) {
-            $sortorder = 'asc';
-        }
-    } else {
-        if ( !$sortkey ) {
-            $sortkey = 'concept';
-        } 
-        if ( !$sortorder ) {
-            $sortorder = 'asc';
-        }
-    }
+    switch ( $mode = strtolower($mode) ) {
+    case 'search': /// looking for terms containing certain word(s)
+        $tab = GLOSSARY_STANDARD_VIEW;
 
-// creating matrix of words to search if apply
-    $search = trim(strip_tags($search));
-    if ($search and !$eid) {   /// searching terms
-        $l = '';
-        $searchterms = explode(' ', $search); // Search for words independently
+        $searchterms = explode(' ', $hook); // Search for words independently
         foreach ($searchterms as $key => $searchterm) {
             if (strlen($searchterm) < 2) {
                 unset($searchterms[$key]);
             } 
         } 
-        $search = trim(implode(' ', $searchterms));
-        $tab = $framebydefault;
-    } elseif ($eid) {   /// searching a specify entry
+        $hook = trim(implode(' ', $searchterms));
+    break;
+    
+    case 'entry':  /// Looking for a certain entry id
         $tab = GLOSSARY_STANDARD_VIEW;
-        $search = '';
-    } 
+    break;
+    
+    case 'cat':    /// Looking for a certain cat
+        $tab = GLOSSARY_CATEGORY_VIEW;
+        if ( $hook > 0 ) {
+            $category = get_record("glossary_categories","id",$hook);
+        }
+    break;
 
-    $alphabet = explode(',', get_string("alphabet"));
-    if ($l == '' and $search == '' and !$eid) {
-        // if the user is just entering the glossary...
-        if ($tab != GLOSSARY_APPROVAL_VIEW) {
-            $l = $alphabet[0];
-        } else {
-            $l = 'ALL';  /// show ALL by default in the waiting approval frame
+    case 'approval':    /// Looking for entries waiting for approval
+        $tab = GLOSSARY_APPROVAL_VIEW;
+        if ( !$hook and !$sortkey and !$sortorder) {
+            $hook = 'ALL';
         }
-    } elseif ($eid) {
-        $l = '';
-    } 
-    
-    $category = '';
-    if ($tab == GLOSSARY_CATEGORY_VIEW) {
-        $l = '';
-        if ($cat > 0) {
-            $category = get_record("glossary_categories", "id", $cat);
-            if (!$category) {
-                $cat = '';
-            } 
+    break;
+
+    case 'term':   /// Looking for entries that include certain term in its concept, definition or aliases
+        $tab = GLOSSARY_STANDARD_VIEW;
+    break;
+
+    case 'date':
+        $tab = GLOSSARY_DATE_VIEW;
+        if ( !$sortkey ) {
+            $sortkey = 'UPDATE';
         } 
-    } 
+        if ( !$sortorder ) {
+            $sortorder = 'desc';
+        }
+    break;
     
-/// Printing the page header
-    if ($course->category) {
-        $navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
-    } 
+    case 'author':  /// Looking for entries, browsed by author
+        $tab = GLOSSARY_AUTHOR_VIEW;
+        if ( !$hook ) {
+            $hook = 'ALL';
+        } 
+    break;
+
+    case 'letter':  /// Looking for entries that begin with a certain letter, ALL or SPECIAL characters
+    default:
+        $tab = GLOSSARY_STANDARD_VIEW;
+        if ( !$hook ) {
+            $hook = 'ALL';  
+        } 
+    break;
+    }  
+
+    switch ( $tab ) {
+    case GLOSSARY_IMPORT_VIEW: 
+    case GLOSSARY_EXPORT_VIEW: 
+    case GLOSSARY_APPROVAL_VIEW:
+        $isuserframe = 0;
+    break;
     
+    default:
+        $isuserframe = 1;
+    break;
+    }
+
+/// Printing the heading
     $strglossaries = get_string("modulenameplural", "glossary");
     $strglossary = get_string("modulename", "glossary");
     $strallcategories = get_string("allcategories", "glossary");
         navmenu($course, $cm));
     
     echo '<p align="center"><font size="3"><b>' . stripslashes_safe($glossary->name);
-    if ($tab == GLOSSARY_CATEGORY_VIEW | $tab == GLOSSARY_STANDARD_VIEW |
-        $tab == GLOSSARY_DATE_VIEW) {
+    if ($isuserframe ) {
     /// the "Print" icon
-        echo " <a title =\"". get_string("printerfriendly","glossary") . "\" target=\"_blank\" href=\"print.php?id=$cm->id&tab=$tab&cat=$cat&l=$l&eid=$eid&sortkey=$sortkey&sortorder=$sortorder\">";
+        echo " <a title =\"". get_string("printerfriendly","glossary") . "\" target=\"_blank\" href=\"print.php?id=$cm->id&tab=$tab&mode=$mode&hook=$hook&sortkey=$sortkey&sortorder=$sortorder\">";
         echo '<img border=0 src="print.gif"/></a>';
     }
     echo '</b></font></p>';
 
 /// Info box
-
     if ( $glossary->intro ) {
         print_simple_box_start('center','70%');
         echo format_text($glossary->intro);
     }
 
 /// Search box
-
     echo '<p>';
     print_simple_box_start("center", "", $THEME->cellheading);
     echo '<p>';
     echo '<form method="POST" action="view.php">';
     echo '<input type="submit" value="'.$strsearch.'" name="searchbutton"> ';
-    echo '<input type="text" name="search" size="20" value=""> ';
-    echo '<input type="checkbox" name="includedefinition" value="1">';
-    echo $strsearchindefinition;
+    echo '<input type="text" name="hook" size="20" value=""> ';
+    echo '<input type="checkbox" name="fullsearch" value="1">';
+    echo '<input type="hidden" name="mode" value="search">';
     echo '<input type="hidden" name="id" value="'.$cm->id.'">';
+    echo $strsearchindefinition;
     echo '</form>';
     echo '</p>';
-    print_simple_box_end();
-
+    print_simple_box_end();    
 
-/// Tabbed browsing sections
     include("tabs.html");
-    
-/// Printing the entries
 
-    switch ($sortkey) {
-        case 'CREATION':
-            $orderby = "timecreated $sortorder";
-        break;
-        case 'UPDATE':
-            $orderby = "timemodified $sortorder";
-        break;
-               default:
-            $orderby .= "$sortkey $sortorder";
+    switch ( $sortkey ) {    
+    case "CREATION": 
+        $sortkey = "timecreated";
+    break;
+    
+    case "UPDATE": 
+        $sortkey = "timemodified";
+    default:
+    break;
     }
     
+/// Creating the SQL statements
+
+/// Pivot is the field that set the break by groups (category, initial, author name, etc)
+
+/// 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;
+
+//    global $db;
+//    $db->debug = true;
+
     switch ($tab) {
-        case GLOSSARY_CATEGORY_VIEW:
-            if ($cat == GLOSSARY_SHOW_ALL_CATEGORIES) { 
-                $sqlselect = "SELECT gec.id gecid, gc.name, gc.id CID, ge.*";
-                $sqlfrom   = "FROM {$CFG->prefix}glossary_entries ge,
-                             {$CFG->prefix}glossary_entries_categories gec,
-                             {$CFG->prefix}glossary_categories gc";
-                $sqlwhere  = "WHERE (ge.glossaryid = '$glossary->id' or ge.sourceglossaryid = '$glossary->id') AND
-                              gec.entryid = ge.id AND
-                              gc.id = gec.categoryid";
-
-                if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
-                    $sqlorderby = ' ORDER BY gc.name, ge.timecreated';
-                } else {
-                    $sqlorderby = ' ORDER BY gc.name, ge.concept';
-                }
-                $count = count_records_sql("select count(*) $sqlfrom $sqlwhere");
-                $sqllimit = " LIMIT $offset, $entriesbypage";
+    case GLOSSARY_CATEGORY_VIEW:
+        if ($hook == GLOSSARY_SHOW_ALL_CATEGORIES  ) { 
+
+            $sqlselect = "SELECT gec.id, gc.name pivot, ge.*";
+            $sqlfrom   = "FROM {$CFG->prefix}glossary_entries ge,
+                         {$CFG->prefix}glossary_entries_categories gec,
+                         {$CFG->prefix}glossary_categories gc";
+            $sqlwhere  = "WHERE (ge.glossaryid = '$glossary->id' OR ge.sourceglossaryid = '$glossary->id') AND
+                          ge.id = gec.entryid AND gc.id = gec.categoryid AND
+                          (ge.approved != 0 OR ge.userid = $USER->id)";
 
-                $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit");
+            if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
+                $sqlorderby = ' ORDER BY gc.name, ge.timecreated';
             } else {
-                if ( $cat == GLOSSARY_SHOW_NOT_CATEGORISED ) {
-                    $sqlselect  = "SELECT *";
-                    $sqlfrom    = "FROM {$CFG->prefix}glossary_entries";
-                    $sqlwhere   = "WHERE (glossaryid = $glossary->id or sourceglossaryid = $glossary->id)";
-                    $sqlorderby = "ORDER BY $orderby";
-
-                    $count = count_records_sql("select count(*) $sqlfrom $sqlwhere");
-                    $sqllimit   = " LIMIT $offset, $entriesbypage";
-                    $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit");
-                } else {
-                    $sqlselect  = "SELECT *";
-                    $sqlfrom    = "FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories c";
-                    $sqlwhere   = "WHERE (ge.id = c.entryid and c.categoryid = $cat) and
-                                  (ge.glossaryid = $glossary->id or ge.sourceglossaryid = $glossary->id)";
-                    $sqlorderby = "ORDER BY $orderby";
-
-                    $count = count_records_sql("select count(*) $sqlfrom $sqlwhere");
-                    $sqllimit   = " LIMIT $offset, $entriesbypage";
-                    $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit");
-                }
+                $sqlorderby = ' ORDER BY gc.name, ge.concept';
+            }
+
+        } elseif ($hook == GLOSSARY_SHOW_NOT_CATEGORISED ) { 
+
+            $printpivot = 0;
+            $sqlselect = "SELECT concept pivot, ge.*";
+            $sqlfrom   = "FROM {$CFG->prefix}glossary_entries ge";
+            $sqlwhere  = "WHERE (glossaryid = '$glossary->id' OR sourceglossaryid = '$glossary->id') AND
+                          (ge.approved != 0 OR ge.userid = $USER->id)";
+
+
+            $sqlorderby = ' ORDER BY concept';
+
+        } else {
+
+            $printpivot = 0;
+            $sqlselect  = "SELECT ce.id, c.name pivot, ge.*";
+            $sqlfrom    = "FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories ce, {$CFG->prefix}glossary_categories c";
+            $sqlwhere   = "WHERE ge.id = ce.entryid AND ce.categoryid = $hook AND
+                                 ce.categoryid = c.id AND ge.approved != 0 AND
+                                 (ge.glossaryid = $glossary->id OR ge.sourceglossaryid = $glossary->id) AND
+                          (ge.approved != 0 OR ge.userid = $USER->id)";
+
+            $sqlorderby = ' ORDER BY c.name, ge.concept';
+
+        }
+        $count = count_records_sql("select count(*) $sqlfrom $sqlwhere");
+        $sqllimit = " LIMIT $offset, $entriesbypage";
+        $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit");
+    break;
+    case GLOSSARY_AUTHOR_VIEW:
+
+        $where = '';
+        switch ($CFG->dbtype) {
+        case 'postgres7':
+            $usernamefield = "u.firstname || ' ' || u.lastname";
+            $where = "AND substr(ucase($usernamefield),1," .  strlen($hook) . ") = '" . strtoupper($hook) . "'";
+        break;
+        case 'mysql':
+            $usernamefield = "CONCAT(CONCAT(u.firstname,' '), u.lastname)";
+            $where = "AND left(ucase($usernamefield)," .  strlen($hook) . ") = '$hook'";
+        break;
+        }
+        if ( $hook == 'ALL' ) {
+            $where = '';
+        }
+
+        $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
+                             $where AND 
+                             (ge.glossaryid = $glossary->id OR ge.sourceglossaryid = $glossary->id)";
+        $sqlorderby = "ORDER BY $usernamefield, ge.concept";
+
+        $count = count_records_sql("select count(*) $sqlfrom $sqlwhere");
+        $sqllimit = " LIMIT $offset, $entriesbypage";
+        $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit");
+    break;
+    case GLOSSARY_APPROVAL_VIEW:
+        $fullpivot = 0;
+        $printpivot = 0;
+
+        $where = '';
+        if ($hook != 'ALL' and $hook != 'SPECIAL') {
+            switch ($CFG->dbtype) {
+            case 'postgres7':
+                $where = 'AND substr(ucase(concept),1,' .  strlen($hook) . ') = \'' . strtoupper($hook) . '\'';
+            break;
+            case 'mysql':
+                $where = 'AND left(ucase(concept),' .  strlen($hook) . ") = '$hook'";
+            break;
+            }
+        }
+
+        $sqlselect  = "SELECT ge.concept pivot, ge.*";
+        $sqlfrom    = "FROM {$CFG->prefix}glossary_entries ge";
+        $sqlwhere   = "WHERE (ge.glossaryid = $glossary->id OR ge.sourceglossaryid = $glossary->id) AND
+                             ge.approved = 0 $where";
+                             
+        if ( $sortkey ) {
+            $sqlorderby = "ORDER BY $sortkey $sortorder";
+        } else {
+            $sqlorderby = "ORDER BY ge.concept";
+        }
+        
+        $count = count_records_sql("select count(*) $sqlfrom $sqlwhere");
+        $sqllimit   = " LIMIT $offset, $entriesbypage";
+        $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit");
+    break;
+    case GLOSSARY_DATE_VIEW:
+    case GLOSSARY_STANDARD_VIEW:
+    default:
+        $sqlselect  = "SELECT ge.concept pivot, ge.*";
+        $sqlfrom    = "FROM {$CFG->prefix}glossary_entries ge";
+
+        $where = '';
+        $fullpivot = 0;
+        if ($CFG->dbtype == "postgres7") {
+            $LIKE = "ILIKE";   // case-insensitive
+        } else {
+            $LIKE = "LIKE";
+        }
+
+        switch ( $mode ) {
+        case 'search': 
+            $printpivot = 0;
+            $where = "AND ( ge.concept $LIKE '%$hook%'";
+            if ( $fullsearch ) {
+                $where .= "OR ge.definition $LIKE '%$hook%')";
+            } else {
+                $where .= ")";
             }
-            $currentcategory = "";
         break;
-        case GLOSSARY_APPROVAL_VIEW:
-            $allentries = glossary_get_entries_sorted($glossary, 'approved = 0',$orderby);
-            $currentletter = '';
+        
+        case 'term': 
+            $printpivot = 0;
+            $sqlfrom .= ", {$CFG->prefix}glossary_alias ga";
+            $where = "AND ge.id = ga.entryid AND ( ge.concept = '$hook' OR ga.alias = '$hook' )";
         break;
-        case GLOSSARY_DATE_VIEW:
-            $l = 'ALL';
-        case GLOSSARY_STANDARD_VIEW:
-        default:
-            if ($search) { // looking for a term
-                $allentries = glossary_search_entries($searchterms, $glossary, $includedefinition);
-            } elseif ($eid) { // looking for an entry
-                $allentries = get_records_select("glossary_entries", "id = $eid");
-            } elseif ( $l or $sortkey ) {
-                $where = '';
-                if ($l != 'ALL' and $l != 'SPECIAL') {
-                    switch ($CFG->dbtype) {
-                        case 'postgres7':
-                            $where = 'and substr(ucase(concept),1,' .  strlen($l) . ') = \'' . strtoupper($l) . '\'';
-                        break;
-                        case 'mysql':
-                            $where = 'and left(ucase(concept),' .  strlen($l) . ") = '$l'";
-                        break;
-                        default:
-                            $where = '';
-                    }
+
+        case 'entry': 
+            $printpivot = 0;
+            $where = "AND ge.id = $hook";
+        break;
+
+        case 'letter': 
+            if ($hook != 'ALL' and $hook != 'SPECIAL') {
+                switch ($CFG->dbtype) {
+                case 'postgres7':
+                    $where = 'AND substr(ucase(concept),1,' .  strlen($hook) . ') = \'' . strtoupper($hook) . '\'';
+                break;
+                case 'mysql':
+                    $where = 'AND left(ucase(concept),' .  strlen($hook) . ") = '$hook'";
+                break;
                 }
-                $sqlselect  = "SELECT *";
-                $sqlfrom    = "FROM {$CFG->prefix}glossary_entries ge";
-                $sqlwhere   = "WHERE (ge.glossaryid = $glossary->id or ge.sourceglossaryid = $glossary->id) $where";
-                $sqlorderby = "ORDER BY $orderby";
-                $count = count_records_sql("select count(*) $sqlfrom $sqlwhere");
-                $sqllimit   = " LIMIT $offset, $entriesbypage";
-                $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit");
             }
-            $currentletter = '';
         break;
+        }
+        
+        $sqlwhere   = "WHERE (ge.glossaryid = $glossary->id or ge.sourceglossaryid = $glossary->id) AND
+                             (ge.approved != 0 OR ge.userid = $USER->id)
+                              $where";
+        switch ( $tab ) {
+        case GLOSSARY_DATE_VIEW: 
+            $sqlorderby = "ORDER BY $sortkey $sortorder";
+        break;
+        
+        case GLOSSARY_STANDARD_VIEW: 
+            $sqlorderby = "ORDER BY ge.concept";
+        default:
+        break;
+        }
+
+        $count = count_records_sql("select count(*) $sqlfrom $sqlwhere");
+        $sqllimit   = " LIMIT $offset, $entriesbypage";
+        $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit");
+
+    break;
     } 
-    
-    $dumpeddefinitions = 0;
+/*    
+    print_simple_box_start("center","85%");
+    print_object($allentries);
+    print_simple_box_end();
+    $db->debug=false;
+*/
+
+/// printing the entries
+
+    $entriesshown = 0;
+    $currentpivot = '';
+    if ( $hook == 'SPECIAL' ) {
+        $alphabet = explode(",", get_string("alphabet"));
+    }
     if ($allentries) {
+        /// printing the paging links
         $paging = '';
         if ($count > $entriesbypage ) {
             for ($i = 0; ($i*$entriesbypage) < $count  ; $i++   ) {
                 if ($offset / $entriesbypage == $i) {
                     $paging .= '<strong>' . ($i + 1 ) . '</strong>';
                 } else {
-                    $paging .= "<a href=\"view.php?id=$id&l=$l&search=$search&tab=$tab&cat=$cat&includedefinition=$includedefinition&sortkey=$sortkey&sortored=$sortorder&offset=" . ($i*$entriesbypage) . "\">" . ($i+1) . '</a>';
+                    $paging .= "<a href=\"view.php?id=$id&mode=$mode&hook=$hook&offset=" . ($i*$entriesbypage) . "\">" . ($i+1) . '</a>';
                 }
             }
             $paging  = "<font size=1><center>" . get_string ("jumpto") . " $paging</center></font>";
         }
-        echo "$paging<p>";
+        echo "$paging";
+        glossary_debug($debug,'<div align=right><font size=1>SELECT normal:' . count($allentries) . '</font></div>',0);
+        glossary_debug($debug,'<div align=right><font size=1>SELECT count(*):' . $count . '</font></div>',0);
+
         if ($glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS) {
-            echo '<table border=0 cellspacing=0 width=95% valign=top cellpadding=5><tr><td align=left bgcolor="#FFFFFF">';
+            $printpivot = 0;
         }
+        
         foreach ($allentries as $entry) {
-            $dumptoscreen = 0;
-            $firstletter = strtoupper(substr(ltrim($entry->concept), 0, strlen($l)));
-            if ($l) {
-                if ($l == 'ALL' or $sortkey == 'CREATION' or $sortkey == 'UPDATE' or $firstletter == $l) {
-                    if ($currentletter != $firstletter[0]) {
-                        if ($entry->approved or ($USER->id == $entry->userid and !isteacher($course->id)) or $tab == GLOSSARY_APPROVAL_VIEW) {
-                            $currentletter = $firstletter[0];
-    
-                            if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) {
-                                if ($dumpeddefinitions > 0) {
-                                    echo '</table></center><p>';
-                                } 
-                                echo "\n<center><table border=0 cellspacing=0 width=95% valign=top cellpadding=5><tr><td align=center bgcolor=\"$THEME->cellheading2\">";
-                            }
-                            if ($l == 'ALL' and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) {
-                                if ($tab != GLOSSARY_DATE_VIEW) {
-                                    echo "<b>$currentletter</b>";
-                                } 
-                            } 
-    
-                            if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) {
-                                echo '</center></td></tr></table></center>';
-                                    if ($dumpeddefinitions > 0) {
-                                        echo '<center><table border=0 cellspacing=0 width=95% valign=top cellpadding=5>';
-                                } 
-                            } 
-                        } 
+//glossary_debug($debug,"<b>$entry->concept</b>");
+            $pivot = $entry->pivot;
+            if ( !$fullpivot ) {
+                $pivot = $pivot[0];
+            }            
+            
+            /// Validating special cases not covered by the SQL statement
+            $showentry = 1;
+            if ( $mode == 'letter' and $hook != 'SPECIAL' and $hook != 'ALL' ) {
+                if ( substr($entry->concept, 0, strlen($hook)) != $hook ) {
+                    $showentry = 0;
+                }
+            } 
+$num=0;
+//glossary_debug($debug,(++$num) . ": $showentry");
+            if ( $hook == 'SPECIAL' ) {
+                $initial = $entry->concept[0];
+                for ($i = 0; $i < count($alphabet); $i++) {
+                    $curletter = $alphabet[$i];
+                    if ( $curletter == $initial ) {
+
+                        $showentry = 0;
+                        break;
                     }
-                    $dumptoscreen = 1;
-                } elseif ($l == 'SPECIAL' and ord($firstletter) != ord('Ñ') and 
-                         (ord($firstletter) < ord('A') or ord($firstletter) > ord('Z'))) {
-                    $dumptoscreen = 1;
-                } 
-            } else {
-                if ($tab == GLOSSARY_CATEGORY_VIEW) {
-                    if ($category) {   // if we are browsing a category
-                            $dumptoscreen = 1;
-                    } else { 
-                        if ($cat == GLOSSARY_SHOW_NOT_CATEGORISED) { // Not categorized
-                            if (! record_exists("glossary_entries_categories", "entryid", $entry->id)) {
-                                $dumptoscreen = 1;
-                            } 
-                        } else { // All categories
-                            if ($currentcategory != $entry->CID) {
-                                if ($entry->approved or ($USER->id == $entry->userid and !isteacher($course->id)) or $tab == GLOSSARY_APPROVAL_VIEW) {
-                                    $currentcategory = $entry->CID;
-                                    if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) {
-                                        if ($dumpeddefinitions > 0) {
-                                            echo '</table></center><p>';
-                                        } 
-                                        echo "\n<center><table border=0 cellspacing=0 width=95% valign=top cellpadding=10><tr><td align=center bgcolor=\"$THEME->cellheading2\">";
-                                    } 
-                                    if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
-                                        echo '<center>';
-                                    }
-                                    echo "<b>$entry->name</b>";
-                                    if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
-                                        echo '</center><p>';
-                                    }
-                                }
-                            } 
-                            $dumptoscreen = 1;
-    
-                            if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) {
-                                echo '</center></td></tr></table></center>';
-                                if ($dumpeddefinitions > 0) {
-                                    echo '<center><table border=1 cellspacing=0 width=95% valign=top cellpadding=10>';
-                                } 
-                            } 
-    
-                            $dumptoscreen = 1;
-                        } 
-                    } 
-                } else {
-                    $dumptoscreen = 1;
-                } 
+                }
             } 
-    
-            if ($dumptoscreen) {
-                $dumpeddefinitions++;
-    
+//glossary_debug($debug,(++$num) . ": $showentry");
+            if ( $mode == 'cat' and $hook == GLOSSARY_SHOW_NOT_CATEGORISED ) {
+                if ( record_exists("glossary_entries_categories", "entryid", $entry->id)) {
+                    $showentry = 0;
+                } 
+            }
+//glossary_debug($debug,(++$num) . ": $showentry");
+            if ( $mode != 'approval' ) {
+                if ( !$entry->approved and isteacher($course->id, $entry->userid) ) {
+                    $showentry = 0;
+                }            
+            }
+//glossary_debug($debug,(++$num) . ": $showentry");
+            /// ok, if it's a valid entry.. Print it.
+            if ( $showentry ) {
+            
+                /// if there's a group break
+                if ( $currentpivot != $pivot ) {  
+
+                    // print the group break if apply and necessary
+                    if ( $printpivot )  {
+                        if ( $tableisopen ) {
+                            print_simple_box_end();
+                            $tableisopen = 0;
+                        }
+                        $currentpivot = $pivot;
+
+                        echo '<p>';
+                        echo '<table width="95%" border="0" class="generaltabselected" bgcolor="' . $THEME->cellheading2 . '">';
+
+                        echo '<tr>';
+                        if ( isset($entry->uid) ) {
+                        // printing the user icon if defined (only when browsing authors)
+                            echo '<td align="left">';
+                            
+                            $user = get_record("user","id",$entry->uid);
+                            print_user_picture($user->id, $course->id, $user->picture);
+                        } else {
+                            echo '<td align="center">';
+                        }
+
+                        echo "<strong> $currentpivot</strong>" ;
+                        echo '</td></tr></table>';
+
+                        if ($glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS OR 
+                            $glossary->displayformat == GLOSSARY_FORMAT_SIMPLE ) {
+                            print_simple_box_start("center","95%","#ffffff","5","generalbox");
+                            $tableisopen = 1;
+                        }
+                    }
+                }
+                
+                if ( !$tableisopen ) {
+                    if ($glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS OR 
+                        $glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) {
+                        print_simple_box_start("center","95%","#ffffff","5","generalbox");
+                        $tableisopen = 1;
+                    }
+                }
+
                 $concept = $entry->concept;
                 $definition = $entry->definition;
     
-                if ($dumpeddefinitions == 1) {
-                    if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) {
-                        echo '<center><table border=1 cellspacing=0 width=95% valign=top cellpadding=10>';
-                    } 
+                /// highligh the term if necessary
+                if ($mode == 'search') {
+                    $entry->concept = highlight($hook, $concept);
+                    $entry->definition = highlight($hook, $definition);
                 } 
-                if ($search) {
-                    $entry->concept = highlight($search, $concept);
-                    $entry->definition = highlight($search, $definition);
-                } 
-    
-                glossary_print_entry($course, $cm, $glossary, $entry, $tab, $cat);
-                if ($glossary->displayformat != GLOSSARY_FORMAT_SIMPLE) {
-                    echo '<p>';
-                } 
-            } 
-        } 
-    } 
-    if (! $dumpeddefinitions) {
-        print_simple_box_start("center", "70%", "$THEME->cellheading2");
-        if (!$search) {
-            echo "<center>$strnoentries</center>";
-        } else {
-            echo '<center>';
-            print_string("searchhelp");
-            echo '</center>';
-        } 
-        print_simple_box_end();
-    } else {
-        if ( $paging ) {
-            echo "<table border=0><tr><td>$paging</td></tr></table>";
+
+                /// and finally print the entry.
+                glossary_print_entry($course, $cm, $glossary, $entry, $mode, $hook);
+                $entriesshown++;
+//                echo '<p>';
+            }
         }
-        switch ($glossary->displayformat) {
-            case GLOSSARY_FORMAT_CONTINUOUS:
-                echo '</td></tr></table><p>';
-            break;
-            case GLOSSARY_FORMAT_SIMPLE:
-                echo '</table></center><p>';
-            break;
-        } 
-    } 
-    
+        if ( $tableisopen ) {
+            if ($glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS OR 
+                $glossary->displayformat == GLOSSARY_FORMAT_SIMPLE ) {
+                print_simple_box_end();
+                $tableisopen = 0;
+            }
+        }
+    }
+    if ( !$entriesshown ) {
+        print_simple_box('<center>' . get_string("noentries","glossary") . '</center>',"center","95%");
+    }
+
     echo '</center>';
     glossary_print_tabbed_table_end();
+    if ( $debug ) {
+        echo '<p>';
+        print_simple_box("$sqlselect<br> $sqlfrom<br> $sqlwhere<br> $sqlorderby<br> $sqllimit","center","85%");
+    }
 
 /// Finish the page
     print_footer($course);
-    
-?>
+?>
\ No newline at end of file