]> git.mjollnir.org Git - moodle.git/commitdiff
- Now the entries could be categorized.
authorwillcast <willcast>
Sun, 21 Sep 2003 17:08:41 +0000 (17:08 +0000)
committerwillcast <willcast>
Sun, 21 Sep 2003 17:08:41 +0000 (17:08 +0000)
- Any entry could belongs to many categories
- Improved main page and add entry look.
- Added PostgreSQL7 squema (Thanks Janne Mikkonen!)
- Deleting entries also delete its attachments if any.

18 files changed:
lang/en/glossary.php
lang/es/glossary.php
mod/glossary/db/mysql.php
mod/glossary/db/mysql.sql
mod/glossary/db/postgres7.php [new file with mode: 0644]
mod/glossary/db/postgres7.sql [new file with mode: 0644]
mod/glossary/deleteentry.html
mod/glossary/deleteentry.php
mod/glossary/edit.html
mod/glossary/edit.php
mod/glossary/editcategories.html [new file with mode: 0644]
mod/glossary/editcategories.php [new file with mode: 0644]
mod/glossary/exportentry.php
mod/glossary/formats/1.php
mod/glossary/formats/2.php
mod/glossary/lib.php
mod/glossary/version.php
mod/glossary/view.php

index 5a818631a1ad82eaca1bd5824de8da47a47cf964..10130e3da49e62bfdd9e1a020c41bbf82d0e6971 100644 (file)
@@ -3,21 +3,31 @@
 
 $string['addentry'] = "Add entry";
 $string['allentries'] = "ALL";
+$string['allcategories'] = "All Categories";
 $string['allowduplicatedentries'] = "Duplicated entries allowed";
 $string['alphabet'] = "A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z";
-$string['areyousuredelete'] = "Are you sure you want to delete this entry?";
+$string['areyousuredelete'] = "Are you sure you want to delete it?";
 $string['attachment'] = "Attachment";
-$string['categoryview'] = "By Category";
+$string['back'] = "Back";
+$string['categories'] = "Categories";
+$string['categoryview'] = "By category";
+$string['category'] = "Category";
+$string['categorydeleted'] = "Category deleted";
 $string['concept'] = "Concept";
 $string['concepts'] = "Concepts";
 $string['definition'] = "Definition";
 $string['definitions'] = "Definitions";
 $string['deleteentry'] = "Delete entry";
+$string['deletingnoneemptycategory'] = "If a non empty category is deleted, its relations with their entries will also be deleted. If you wish to delete the entries, you will have to do so manually.";
 $string['displayformat'] = "Display format";
 $string['displayformatdefault'] = "Simple, dictionary style";
 $string['displayformat1'] = "Full without author.";
 $string['displayformat2']  = "Full with author.";
+$string['entries'] = "Entries";
+$string['entrieswithoutcategory'] = "Entries without category";
+$string['entry'] = "Entry";
 $string['editentry'] = "Edit entry";
+$string['editcategories'] = "Edit categories";
 $string['entryalreadyexist'] = "Entry already exist.";
 $string['entrydeleted'] = "Entry deleted.";
 $string['entryexported'] = "Entry succesfully exported.";
@@ -27,6 +37,7 @@ $string['mainglossary'] = "Main glossary";
 $string['modulename'] = "Glossary";
 $string['modulenameplural'] = "Glossaries";
 $string['newglossaryentries'] = "New glossary entries:";
+$string['nocategorized'] = "No categorized";
 $string['noentries'] = "No entries found in this section";
 $string['noentry'] = "No entry found.";
 $string['searchconcept'] = "Search:";
index 26c9fed983519b65197e017c9ef4d6560a447516..81ca2d6b1d669aa6eeef89a7aa12ef1451689465 100644 (file)
@@ -3,21 +3,31 @@
 
 $string['addentry'] = "Agregar entrada";
 $string['allentries'] = "TODAS";
+$string['allcategories'] = "Todas las categorías";
 $string['allowduplicatedentries'] = "Permitir entradas duplicadas";
 $string['alphabet'] = "A|B|C|D|E|F|G|H|I|J|K|L|M|N|Ñ|O|P|Q|R|S|T|U|V|W|X|Y|Z";
-$string['areyousuredelete'] = "¿Está seguro que desea borrar esta entrada?";
+$string['areyousuredelete'] = "¿Está seguro que desea borrarla?";
 $string['attachment'] = "Adjunto";
+$string['back'] = "Volver";
+$string['categories'] = "Categorías";
 $string['categoryview'] = "Vista por Categoría";
+$string['category'] = "Categoría";
+$string['categorydeleted'] = "Categoría eliminada";
 $string['concept'] = "Concepto";
 $string['concepts'] = "Conceptos";
 $string['definition'] = "Definición";
 $string['definitions'] = "Definiciones";
 $string['deleteentry'] = "Borrar entrada";
+$string['deletingnoneemptycategory'] = "Si una categoría es eliminada por consiguiente su relación con las entradas también lo será. Si desea eliminar las entradas, tendrá que hacerlo manualmente.";
 $string['displayformat'] = "Formato de muestra de entradas";
 $string['displayformatdefault'] = "Simple, estilo diccionario";
 $string['displayformat1'] = "Completo sin autor.";
 $string['displayformat2'] = "Completo con autor.";
 $string['editentry'] = "Editar entrada";
+$string['editcategories'] = "Editar categorías";
+$string['entries'] = "Entradas";
+$string['entrieswithoutcategory'] = "Entradas sin categoría";
+$string['entry'] = "Entrada";
 $string['entryalreadyexist'] = "Esta entrada ya existe.";
 $string['entrydeleted'] = "Entrada borrada.";
 $string['entryexported'] = "Entrada exportada con éxito.";
@@ -27,6 +37,7 @@ $string['mainglossary'] = "Glosario principal";
 $string['modulename'] = "Glosario";
 $string['modulenameplural'] = "Glosarios";
 $string['newglossaryentries'] = "Nuevas entradas en el glosario:";
+$string['nocategorized'] = "Sin categoría";
 $string['noentries'] = "No se encontraro entradas en esta sección";
 $string['noentry'] = "No se econtró ninguna entrada.";
 $string['searchconcept'] = "Buscar:";
index f80af4a5d39ce714004d84fd1fe7b66c9fcec32d..2fcaae6ba7f9754e7be4dbb440b48d5024fbdd4f 100644 (file)
@@ -49,18 +49,10 @@ function glossary_upgrade($oldversion) {
                     `entryid` INT(10) UNSIGNED NOT NULL default '0',
                     PRIMARY KEY  (`categoryid`, `entryid`)
                     ) TYPE=MyISAM COMMENT='categories of each glossary entry'");
-                    
-          // creating a default category for every glossary
-        execute_sql("INSERT INTO `{$CFG->prefix}glossary_categories` (`glossaryid`, `name`)
-                    SELECT `id`, '" . get_string("main","glossary") . "' FROM `{$CFG->prefix}glossary`");
-                    
-
-          // setting the default category for every entry.
-        execute_sql("INSERT INTO `{$CFG->prefix}glossary_entries_categories` (`categoryid`, `entryid`)
-                    SELECT c.id, e.id
-                    FROM `{$CFG->prefix}glossary_entries` e, `{$CFG->prefix}glossary_categories` c
-                    WHERE e.glossaryid = c.glossaryid");
-
+     }
+     
+     if ( $oldversion < 2003092100 ) {
+          execute_sql("ALTER TABLE `{$CFG->prefix}glossary_entries_categories` CHANGE `categoryid` `categoryid` INT( 10 ) UNSIGNED DEFAULT '0' NOT NULL ");
      }
 
     return true;
index 9c8cc9ea27370f293a41173b37b93fd99e3fe13e..c72df48210dc67945b806e74039d22c631983277 100644 (file)
@@ -58,7 +58,7 @@ CREATE TABLE prefix_glossary_categories (
 #
 
 CREATE TABLE prefix_glossary_entries_categories (
-     categoryid int(10) unsigned NOT NULL default '1',
+     categoryid int(10) unsigned NOT NULL default '0',
      entryid int(10) unsigned NOT NULL default '0',
      PRIMARY KEY  (categoryid, entryid)
 ) TYPE=MyISAM COMMENT='categories of each glossary entry';
diff --git a/mod/glossary/db/postgres7.php b/mod/glossary/db/postgres7.php
new file mode 100644 (file)
index 0000000..1ede63b
--- /dev/null
@@ -0,0 +1,13 @@
+<?php
+
+function glossary_upgrade($oldversion) {
+/// This function does anything necessary to upgrade 
+/// older versions to match current functionality 
+
+    global $CFG;
+
+
+    return true;
+}
+
+?>
\ No newline at end of file
diff --git a/mod/glossary/db/postgres7.sql b/mod/glossary/db/postgres7.sql
new file mode 100644 (file)
index 0000000..92fc5cf
--- /dev/null
@@ -0,0 +1,79 @@
+# This file contains a complete database schema for all the 
+# tables used by this module, written in SQL
+
+# It may also contain INSERT statements for particular data 
+# that may be used, especially new entries in the table log_display
+
+#
+# Table structure for table `glossary`
+#
+
+CREATE TABLE prefix_glossary (
+     id SERIAL,
+     course int4 NOT NULL default '0',
+     name varchar(255) NOT NULL default '',
+     studentcanpost int2 NOT NULL default '0',
+     allowduplicatedentries int2 NOT NULL default '0',
+     displayformat int2 NOT NULL default '0',
+     mainglossary int2 NOT NULL default '0',
+     showspecial int2 NOT NULL default '1',
+     showalphabet int2 NOT NULL default '1',
+     showall int2 NOT NULL default '1',
+     timecreated int4 NOT NULL default '0',
+     timemodified int4 NOT NULL default '0',
+     PRIMARY KEY  (id)
+);
+
+#
+# Table structure for table `glossary_entries`
+#
+
+CREATE TABLE prefix_glossary_entries (
+     id SERIAL,
+     glossaryid int4 NOT NULL default '0',
+     userid int4 NOT NULL default '0',
+     concept varchar(255) NOT NULL default '',
+     definition text NOT NULL,
+     format int2 NOT NULL default '0',
+     attachment VARCHAR(100) NOT NULL default '',
+     timecreated int4 NOT NULL default '0',
+     timemodified int4 NOT NULL default '0',
+     teacherentry int2 NOT NULL default '0',
+     PRIMARY KEY(id)
+);
+
+#
+# Table structure for table `glossary_cageories`
+#
+
+CREATE TABLE prefix_glossary_categories (
+     id SERIAL,
+     glossaryid int4 NOT NULL default '0',
+     name varchar(255) NOT NULL default '',
+     PRIMARY KEY  (id)
+);
+
+#
+# Table structure for table `glossary_entries_category`
+#
+
+CREATE TABLE prefix_glossary_entries_categories (
+     categoryid int4 NOT NULL default '0',
+     entryid int4 NOT NULL default '0',
+     PRIMARY KEY  (categoryid, entryid)
+);
+
+#
+# Dumping data for table `log_display`
+#
+
+INSERT INTO prefix_log_display VALUES ('glossary', 'add', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'update', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'view', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'view all', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'add entry', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'update entry', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'add category', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'update category', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'delete category', 'glossary', 'name');
+
index 3b77ab110a6eee565e2f2eb69a8735cecfa8a336..e7721b139ac42a670c6cfdb73cc7a9b53fb57e60 100644 (file)
@@ -4,6 +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="submit" value=" <?php print_string("yes")?> "> 
 <input type=button value=" <?php print_string("no")?> " onclick="javascript:history.go(-1);">
index 7f5be1af6fec916936557e2572899d392a0fd2e9..43082b142996699a2ffea68fd2f803bd4610e87e 100644 (file)
        if ( isteacher($cm->id) or $glossary->studentcanpost ) {
                if ($go) {      // the operation was confirmed.
                        if ( $mode == "delete") {
+                               glossary_delete_old_attachments($entry);
                                delete_records("glossary_entries","id", $entry);                                
                                print_simple_box_start("center","40%", "#FFBBBB");
                                echo "<center>$entrydeleted"; //CAMBIAR
                                echo "</center>";
                                print_simple_box_end();
-                       } elseif ($mode == "edit") {
                        }
                        print_footer($course);
-                  add_to_log($course->id, "glossary", "delete entry", "view.php?id=$cm->id", $entry);
-                       redirect("view.php?id=$cm->id");
+                  add_to_log($course->id, "glossary", "delete entry", "view.php?id=$cm->id&currentview=$currentview&cat=$cat", $entry);
+                       redirect("view.php?id=$cm->id&currentview=$currentview&cat=$cat");
                } 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");
-                               echo "<center><b>$entryfields->concept</b><br>$strareyousuredelete"; //CAMBIAR
-                               include("deleteentry.html");
-                               echo "</center>";
+                               echo "<center><b>$entryfields->concept</b><br>$strareyousuredelete";
+                               
+                               ?>
+                    <form name="form" method="post" action="deleteentry.php">
+
+                    <input type="hidden" name=id                  value="<?php p($cm->id) ?>">
+                    <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=currentview value=<? p($currentview) ?>>
+                    <input type="hidden" name=cat=<? p($cat) ?>>
+
+                    <input type="submit" value=" <?php print_string("yes")?> ">
+                    <input type=button value=" <?php print_string("no")?> " onclick="javascript:history.go(-1);">
+
+                    </form>
+                       </center>
+                       <?
                                print_simple_box_end();
-                       } elseif ($mode == "edit") {
                        }
                } 
        } else {
index 34cb5af4f46af57525e0d1d1bfd1e6dd8b5195ab..a96c03f9f5d6bd3956e9d936d558e67ca879585f 100644 (file)
         <INPUT type="text" name="concept" size=30 value="<? p($form->concept) ?>">
     </td>
 </tr>
+<tr valign=top>
+    <td align=right><p><b><?php echo get_string("categories","glossary") ?>:</b></p></td>
+    <td>       
+       <?
+               $categories = get_records("glossary_categories","glossaryid",$glossary->id);
+               echo "<select size=\"";
+               if ( count($categories) > 7 ) {
+                       echo 7;
+               }else {
+                       echo count($categories);
+               }
+               echo "\" name=\"categories[]\" multiple=\"yes\">";
+
+               foreach ( $categories as $category ) {
+                       echo "  <option ";
+
+                       if ( record_exists("glossary_entries_categories","entryid",$entry->id,"categoryid",$category->id) ) {
+                               echo "selected " ;
+                       }
+                       echo "value=\"$category->id\">$category->name</option>\n";
+               }
+       ?>
+       </select>
+    </td>
+</tr>
 <tr valign=top>
     <td align=right><p><b><? echo get_string("definition","glossary") ?>:</b></p>
     <font size="1">
@@ -37,9 +62,6 @@
            $form->format = $defaultformat;
        }
        choose_from_menu(format_text_menu(), "format", $entry->format, ""); 
-        if ($entry->id) {
-               echo "<input type=\"hidden\" name=entry value=\"$entry->id\">";
-        }
        echo "</p>";
     ?>
     </td>
 <tr>
 <td colspan=2>
        <p align=center>
+       <? if ($entry->id) {
+               echo "<input type=\"hidden\" name=entry value=\"$entry->id\">";
+        }
+       ?>
        <input type="hidden" name=id value="<?=$cm->id ?>">
+       <input type="hidden" name=currentview value="<?=$currentview ?>">
+       <input type="hidden" name=cat value="<?=$cat ?>">
+
        <input type="submit" value="<? print_string("savechanges") ?>">
        <input type="reset" value="<? print_string("revert") ?>">
        </P>
index 969e7c9c844f953f90dfa860380283e86a3add3a..74578c0c7a55ebb4d2d31daa28bf05ce5ff572db 100644 (file)
@@ -7,6 +7,9 @@ require_once("lib.php");
 require_variable($id);    // Course Module ID
 optional_variable($e);    // EntryID
 
+optional_variable($currentview);   // categories if by category?
+optional_variable($cat);    // CategoryID
+
 if (! $cm = get_record("course_modules", "id", $id)) {
     error("Course Module ID was incorrect");
 }
@@ -110,14 +113,23 @@ if ($e) {
                               }
                               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", "$newentry->id");
+                              add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id&eid=$newentry->id&currentview=$currentview&cat=$cat", "$newentry->id");
                        }
                 } else {
                     error("Could not insert this glossary entry because this concept already exist.");
                 }
           }
 
-          redirect("view.php?id=$cm->id&eid=$newentry->id");
+           delete_records("glossary_entries_categories","entryid",$entry);
+
+           if ( $categories ) {
+                $newcategory->entryid = $newentry->id;
+                foreach ($categories as $category) {
+                    $newcategory->categoryid =$category;
+                    insert_record("glossary_entries_categories",$newcategory);
+                }
+           }
+          redirect("view.php?id=$cm->id&eid=$newentry->id&currentview=$currentview&cat=$cat");
           die;
      }
 }
diff --git a/mod/glossary/editcategories.html b/mod/glossary/editcategories.html
new file mode 100644 (file)
index 0000000..fdfc0d1
--- /dev/null
@@ -0,0 +1,30 @@
+<?
+       global $CFG, $THEME;
+       require_once("../../config.php");
+
+?>
+
+<FORM name="form" method="post" <?=$onsubmit ?> action="editcategories.php">
+<table  class=generalbox cellpadding=5 bgcolor="<? p($THEME->cellheading)?>">
+<tr valign=top>
+    <td align=right><p><b><?php echo get_string("name") ?>:</b></p></td>
+    <td>
+        <INPUT type="text" name="name" size=30 value="<?=$name ?>">
+    </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=<? p($cat) ?>>
+       <input type="submit" value="<? print_string("savechanges") ?>">
+       <input type="reset" value="<? print_string("back","glossary") ?>"  onclick="javascript:history.go(-1);">
+       </P>
+</td>
+</tr>
+</table>
+</p>
+
+
+</form>
diff --git a/mod/glossary/editcategories.php b/mod/glossary/editcategories.php
new file mode 100644 (file)
index 0000000..bf2260e
--- /dev/null
@@ -0,0 +1,233 @@
+<?PHP  // $Id$
+
+/// This page allows to edit entries categories for a particular instance of glossary
+
+    require_once("../../config.php");
+    require_once("lib.php");
+
+     require_variable($id);    // Course Module ID, or
+     optional_variable($cat);  // category ID
+     optional_variable($action);  // what to do
+     optional_variable($confirm);  // confirm the action
+
+     optional_variable($name);  // confirm the action
+
+     $action = strtolower($action);
+       
+    if (! $cm = get_record("course_modules", "id", $id)) {
+        error("Course Module ID was incorrect");
+    }
+
+    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");
+    }
+
+    require_login($course->id);
+
+     if ( !isteacher($course->id) ) {
+        error("You must be a teacher to use this page.");
+     }
+
+//    add_to_log($course->id, "glossary", "edit categories", "view.php?id=$cm->id", "$glossary->id");
+
+    if ($course->category) {
+        $navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
+    }
+
+    $strglossaries   = get_string("modulenameplural", "glossary");
+    $strglossary     = get_string("modulename", "glossary");
+
+    print_header("$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),
+                  navmenu($course, $cm));
+
+     if ( $cat ) {
+          $category = get_record("glossary_categories","id",$cat);
+
+          if ( $action == "edit" ) {
+               if ( $confirm ) {
+                    $action = "";
+                    $CategoryObject->id = $cat;
+                    $CategoryObject->name = $name;
+
+                    if ( !update_record("glossary_categories", $CategoryObject) ) {
+                               error("Weird error. The category was not updated.");
+                               
+                               redirect("editcategories.php?id=$cm->id");
+                    }
+                    
+               } else {
+                    echo "<p align=\"center\">" . get_string("edit"). " " . get_string("category","glossary") . "<font size=\"3\">";
+
+                    $name = $category->name;
+                    require "editcategories.html";
+                    print_footer();
+                    die;
+               }
+          } elseif ( $action == "delete" ) {
+               if ( $confirm ) {
+               
+                               delete_records("glossary_entries_categories","categoryid", $cat);
+                    delete_records("glossary_categories","id", $cat);
+                               
+                               print_simple_box_start("center","40%", "#FFBBBB");
+                               echo "<center>" . get_string("categorydeleted","glossary") ."</center>";
+                               echo "</center>";
+                               print_simple_box_end();
+                               
+                               print_footer($course);
+
+                    add_to_log($course->id, "glossary", "delete category", "editcategories.php?id=$cm->id", $cat);
+                    
+                       redirect("editcategories.php?id=$cm->id");
+               } else {
+                    echo "<p align=\"center\">" . get_string("delete"). " " . get_string("category","glossary") . "<font size=\"3\">";
+
+                       print_simple_box_start("center","40%", "#FFBBBB");
+                       echo "<center><b>$category->name</b><br>";
+                       
+                       $num_entries = count_records("glossary_entries_categories","categoryid",$category->id);
+                    if ( $num_entries ) {
+                         print_string("deletingnoneemptycategory","glossary");
+                    }
+                    echo "<p>";
+                    print_string("areyousuredelete","glossary");
+                    
+                    ?>
+                    <form name="form" method="post" action="editcategories.php">
+
+                    <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 ?>">
+                    <table border=0 widTH=100><tr><td align=right width=50%>
+                    <input type="submit" value=" <?php print_string("yes")?> ">
+                    </form>
+                    </td><td align=left width=50%>
+                    <?
+                    unset($options);
+                    $options = array ("id" => $id);
+                    print_single_button("editcategories.php", $options, get_string("no") );
+                    echo "</td></tr></table>";
+                       echo "</center>";
+                       print_simple_box_end();
+               }
+          }
+     } elseif ( $action == "add" ) {
+          if ( $confirm ) {
+               $dupcategory = get_record("glossary_categories","lcase(name)",strtolower($name));
+               if ( $dupcategory ) {
+                    echo "<p align=\"center\">" . get_string("add"). " " . get_string("category","glossary") . "<font size=\"3\">";
+                    
+                               print_simple_box_start("center","40%", "#FFBBBB");
+                               echo "<center>" . get_string("duplicatedcategory","glossary") ."</center>";
+                               echo "</center>";
+                               print_simple_box_end();
+                               
+                               print_footer($course);
+
+                       redirect("editcategories.php?id=$cm->id&action=add&&name=$name");
+
+               } else {
+                    $action = "";
+                    $CategoryObject->name = $name;
+                    $CategoryObject->glossaryid = $glossary->id;
+
+                    if ( ! $CategoryObject->id = insert_record("glossary_categories", $CategoryObject) ) {
+                               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", $cat);
+                    }
+             }
+          } else {
+               echo "<p align=\"center\">" . get_string("add"). " " . get_string("category","glossary") . "<font size=\"3\">";
+               $name="";
+               require "editcategories.html";
+          }
+     }
+     
+     if ( $action ) {
+
+          print_footer();
+          die;
+     }
+
+?>
+
+
+<p align="center"><? p(get_string("edit")) ?> <? p(get_string("categories","glossary")) ?><font size="3">
+
+<FORM name="theform" method="post" <?=$onsubmit ?> action="editcategories.php">
+<table width="40%" class=generalbox cellpadding=5 bgcolor="<? p($THEME->cellheading)?>">
+        <tr>
+          <td width="90%" align="center"><b>
+          <? p(get_string("categories","glossary")) ?></b></td>
+          <td width="10%" align="center"><b>
+          <? p(get_string("action")) ?></b></td>
+        </tr>
+        <tr><td width=100% colspan=2  bgcolor="<? p($THEME->cellheading2)?>">
+        
+        <table width=100%>
+<?
+     $categories = get_records("glossary_categories","glossaryid",$glossary->id,"name ASC");
+
+     if ( $categories ) {
+          foreach ($categories as $category) {
+               $num_entries = count_records("glossary_entries_categories","categoryid",$category->id);
+             ?>
+             <tr bgcolor="<? p($THEME->cellheading2)?>">
+               <td width="90%" align="left">
+               <?
+                    echo "<b>$category->name</b> <font size=-1>($num_entries " . get_string("entries","glossary") . ")</font>";
+               ?>
+               </td>
+               <td width="10%" align="center"><b>
+               <?
+                       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>";
+               ?>
+               </b></td>
+             </tr>
+             
+             <?
+          }
+     }
+?>
+        </table>
+        
+        </td>
+        <tr>
+        <td width=100% colspan=2  align=center bgcolor="<? p($THEME->cellheading2)?>">
+            <?
+            
+             $options['id'] = $cm->id;
+             $options['action'] = "add";
+             
+             echo "<table border=0><tr><td align=right>";
+             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";
+             echo print_single_button("view.php", $options, get_string("back","glossary") );
+             echo "</td></tr>";
+             echo "</tablee>";
+
+            ?>
+        </td>
+        </tr>
+        </table>
+
+</table>
+</p>
+
+
+</form>
+
+<? print_footer() ?>
index 32b8ea1c644034bb4d1da75b8752904a943baad7..35ea5ad9fe1170c246de5ee504c1ce19fb58b961 100644 (file)
@@ -5,6 +5,9 @@
        require_variable($id);    // course module ID
        require_variable($entry);    // Entry ID
        optional_variable($confirm);     // confirmation
+       optional_variable($currentview);
+       optional_variable($cat);
+       
        global $THEME, $USER, $CFG;
 
        $PermissionGranted = 1;
@@ -52,8 +55,8 @@
                        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&entry=$entry->id&confirm=1",
-                               "view.php?id=$cm->id&eid=".$entry->id );
+                               "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 );
 
                } else {
                        if ( ! $mainglossary->allowduplicatedentries ) {
                               }
                          }
                          
-                         add_to_log($course->id, "glossary", "add entry",
-                         "view.php?id=$cm->id&eid=".$entry->id, "$newentry->id");
+                         add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id&currentview=$currentview&cat=$cat&eid=".$entry->id, "$newentry->id");
 
-                         print_continue("view.php?id=$cm->id&eid=".$entry->id);
+                         print_continue("view.php?id=$cm->id&currentview=$currentview&cat=$cat&eid=".$entry->id);
                          print_simple_box_end();
 
                                        print_footer();
 
-                       redirect("view.php?id=$cm->id&eid=".$entry->id);
+                       redirect("view.php?id=$cm->id&currentview=$currentview&cat=$cat&eid=".$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&currentview=$currentview&cat=$cat&eid=".$entry->id);
 
                            print_simple_box_end();
                        }
                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>";
 
-                       print_continue("view.php?id=$cm->id&eid=".$entry->id);
+                       print_continue("view.php?id=$cm->id&currentview=$currentview&cat=$cat&eid=".$entry->id);
 
                print_simple_box_end();
        }
index 2dc657689bb64a4e3b4b807b3125a003cd907aff..25efe73f463c7c547a75c6459f6fbff713554658 100644 (file)
@@ -1,6 +1,6 @@
 <?PHP  // $Id$
 
-function glossary_print_entry_by_format($course, $cm, $glossary, $entry) {
+function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$currentview="",$cat="") {
     global $THEME, $USER;
 
 //    if ($entry->timemarked < $entry->modified) {
@@ -30,7 +30,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry) {
     if ($entry) {
          echo format_text($entry->definition, $entry->format);
 
-         glossary_print_entry_icons($course, $cm, $glossary, $entry);
+         glossary_print_entry_icons($course, $cm, $glossary, $entry,$currentview,$cat);
 
     } else {
          echo "<center>";
index 70dd0c2079efb6f4077ee19dd0f0bf8e323be69b..23231c0032c7c0a4246303d1d396b13bfa28c804 100644 (file)
@@ -1,7 +1,7 @@
 <?PHP  // $Id$
 require_once("lib.php");
 
-function glossary_print_entry_by_format($course, $cm, $glossary, $entry) {
+function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$currentview="",$cat="") {
     global $THEME, $CFG, $USER;
 
 //    if ($entry->timemarked < $entry->modified) {
@@ -40,7 +40,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry) {
     if ($entry) {
          echo format_text($entry->definition, $entry->format);
 
-         glossary_print_entry_icons($course, $cm, $glossary, $entry);
+         glossary_print_entry_icons($course, $cm, $glossary, $entry,$currentview,$cat);
 
     } else {
          echo "<center>";
index e9d7f357be7aef0e52431145ff0cc64bd87912ce..8137f5dd3a04a5dd1cd0ddc101d57f0f02b94cf1 100644 (file)
@@ -5,6 +5,13 @@
 
 require_once("$CFG->dirroot/files/mimetypes.php");
 
+$tCFG->TabTableBGColor = $THEME->cellcontent2;
+$tCFG->TabTableWidth = "70%";
+$tCFG->ActiveTabColor = $THEME->cellcontent2;
+$tCFG->InactiveTabColor = $THEME->cellheading2;
+$tCFG->TabsPerRow = 5;
+$tCFG->TabSeparation = 4;
+
 function glossary_add_instance($glossary) {
 /// Given an object containing all the necessary data,
 /// (defined by the form in mod.html) this function
@@ -161,7 +168,7 @@ function glossary_get_entries($glossaryid, $entrylist) {
                             AND id IN ($entrylist)");
 }
 
-function glossary_print_entry($course, $cm, $glossary, $entry) {
+function glossary_print_entry($course, $cm, $glossary, $entry,$currentview="",$cat="") {
     global $THEME, $USET, $CFG;
     
     $PermissionGranted = 0;
@@ -180,14 +187,14 @@ function glossary_print_entry($course, $cm, $glossary, $entry) {
     }
     
     if ( $glossary->displayformat > 0 and $PermissionGranted ) {
-        glossary_print_entry_by_format($course, $cm, $glossary, $entry);
+        glossary_print_entry_by_format($course, $cm, $glossary, $entry,$currentview,$cat);
     } else {
-        glossary_print_entry_by_default($course, $cm, $glossary, $entry);
+        glossary_print_entry_by_default($course, $cm, $glossary, $entry,$currentview,$cat);
     }
 
 }
 
-function glossary_print_entry_by_default($course, $cm, $glossary, $entry) {
+function glossary_print_entry_by_default($course, $cm, $glossary, $entry,$currentview="",$cat="") {
     global $THEME, $USER;
 
     $colour = $THEME->cellheading2;
@@ -202,12 +209,12 @@ function glossary_print_entry_by_default($course, $cm, $glossary, $entry) {
     }
     echo "<b>$entry->concept</b>: ";
     echo format_text($entry->definition, $entry->format);
-    glossary_print_entry_icons($course, $cm, $glossary, $entry);
+    glossary_print_entry_icons($course, $cm, $glossary, $entry,$currentview,$cat);
     echo "</td>";
     echo "</TR>";
 }
 
-function glossary_print_entry_icons($course, $cm, $glossary, $entry) {
+function glossary_print_entry_icons($course, $cm, $glossary, $entry,$currentview="",$cat="") {
     global $THEME, $USER;
 
          if (isteacher($course->id) or $glossary->studentcanpost and $entry->userid == $USER->id) {
@@ -216,12 +223,12 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry) {
                        $mainglossary = get_record("glossary","mainglossary",1,"course",$course->id);
                        if ( $mainglossary ) {
 
-                               echo "<a href=\"exportentry.php?id=$cm->id&entry=$entry->id\"><img  alt=\"" . get_string("exporttomainglossary","glossary") . "\"src=\"export.gif\" height=11 width=11 border=0></a> ";
+                               echo "<a href=\"exportentry.php?id=$cm->id&entry=$entry->id&currentview=$currentview&cat=$cat\"><img  alt=\"" . get_string("exporttomainglossary","glossary") . "\"src=\"export.gif\" height=11 width=11 border=0></a> ";
 
                        }
                }
-               echo "<a href=\"deleteentry.php?id=$cm->id&mode=delete&entry=$entry->id\"><img  alt=\"" . get_string("delete") . "\"src=\"../../pix/t/delete.gif\" height=11 width=11 border=0></a> ";
-               echo "<a href=\"edit.php?id=$cm->id&e=$entry->id\"><img  alt=\"" . get_string("edit") . "\" src=\"../../pix/t/edit.gif\" height=11 width=11 border=0></a>";
+               echo "<a href=\"deleteentry.php?id=$cm->id&mode=delete&entry=$entry->id&currentview=$currentview&cat=$cat\"><img  alt=\"" . get_string("delete") . "\"src=\"../../pix/t/delete.gif\" height=11 width=11 border=0></a> ";
+               echo "<a href=\"edit.php?id=$cm->id&e=$entry->id&currentview=$currentview&cat=$cat\"><img  alt=\"" . get_string("edit") . "\" src=\"../../pix/t/edit.gif\" height=11 width=11 border=0></a>";
          }
 }
 
@@ -597,4 +604,89 @@ function print_tabbed_table_end() {
      echo "</center><p></td></tr></table></center>";
 }
 
+function glossary_print_alphabet_menu($cm, $glossary, $l) {
+global $CFG, $THEME;
+     $strselectletter = get_string("selectletter", "glossary");
+     $strspecial      = get_string("special", "glossary");
+     $strallentries   = get_string("allentries", "glossary");
+
+     echo "<CENTER>$strselectletter";
+
+      if ( $glossary->showspecial ) {
+          if ( $l == "SPECIAL" ) {
+               echo "<p><b>$strspecial</b> | ";
+          } else {
+               echo "<p><a href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&l=SPECIAL\">$strspecial</a> | ";
+          }
+      }
+
+      if ( $glossary->showalphabet ) {
+           $alphabet = explode("|", get_string("alphabet","glossary"));
+           $letters_by_line = 14;
+           for ($i = 0; $i < count($alphabet); $i++) {
+               if ( $l == $alphabet[$i] ) {
+                    echo "<b>$alphabet[$i]</b>";
+               } else {
+                    echo "<a href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&l=$alphabet[$i]\">$alphabet[$i]</a>";
+               }
+               if ((int) ($i % $letters_by_line) != 0 or $i == 0) {
+                    echo " | ";
+               } else {
+                    echo "<br>";
+               }
+           }
+      }
+
+      if ( $glossary->showall ) {
+          if ( $l == "ALL" ) {
+               echo "<b>$strallentries</b></p>";
+          } else {
+               echo "<a href=\"$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&l=ALL\">$strallentries</a></p>";
+          }
+      }
+}
+function glossary_print_categories_menu($course, $cm, $glossary, $category) {
+global $CFG, $THEME;
+     echo "<table border=0 width=100%>";
+     echo "<tr>";
+
+     echo "<td align=center width=20%>";
+     if ( isteacher($course->id) ) {
+             $options['id'] = $cm->id;
+             $options['cat'] = $cat;
+             echo print_single_button("editcategories.php", $options, get_string("editcategories","glossary"), "get");
+     }
+     echo "</td>";
+
+     echo "<td align=center width=60%>";
+     echo "<b>";
+     if ( $category ) {
+        echo $category->name;
+     } else {
+        echo get_string("entrieswithoutcategory","glossary");
+     }
+     echo "</b></td>";
+     echo "<td align=center width=20%>";
+     $menu[0] = get_string("nocategorized","glossary");
+
+     $categories = get_records("glossary_categories", "glossaryid", $glossary->id, "name ASC");
+     if ( $categories ) {
+          foreach ($categories as $currentcategory) {
+                 $url = $currentcategory->id;
+                 if ($currentcategory->id == $category->id) {
+                     $selected = $url;
+                 }
+                 $menu[$url] = $currentcategory->name;
+          }
+     }
+
+     echo popup_form("$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&currentview=categories&cat=", $menu, "catmenu", $selected, get_string("jumpto"),
+                      "", "", false);
+
+     echo "</td>";
+     echo "</tr>";
+
+     echo "<tr><td colspan=3><hr></td></tr>";
+     echo "</table>";
+}
 ?>
index 73533470a47100d6577e4e593d0fe79d822c2690..aaf3e9b12bf5dc66f94704b874106a9eed9bc759 100644 (file)
@@ -5,7 +5,7 @@
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 /////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2003091800;  // The current module version (Date: YYYYMMDDXX)
+$module->version  = 2003092100;  // The current module version (Date: YYYYMMDDXX)
 $module->cron     = 0;           // Period for cron to check this module (secs)
 
 $release = "0.3.1 development";   // User-friendly version number
index 2b5119dda49552fa16aec31bd5b1fc149e8491aa..b3c31c138ae0e27fd2b40b9420f1f459d60910a5 100644 (file)
     optional_variable($currentview);  // browsing entries by categories?
     optional_variable($cat);  // categoryID
 
-    if ($l == "" and $search == "" and $eid == "") {
-               $l = "A";
+    if (! $cm = get_record("course_modules", "id", $id)) {
+        error("Course Module ID was incorrect");
     }
-    
-    if ( $currentview ) {
-          $currentview = strtolower($currentview);
-          if ( !$currentview ) {
-               $currentview = "";
-          } else {
-               if ( !$cat ) {
-                    $cat = 1;
-               }
-               $category = get_record("glossary_categories","id",$cat);
-          }
+
+    if (! $course = get_record("course", "id", $cm->course)) {
+        error("Course is misconfigured");
     }
 
-    $search = trim(strip_tags($search));
+    if (! $glossary = get_record("glossary", "id", $cm->instance)) {
+        error("Course module is incorrect");
+    }
+
+    require_login($course->id);
+    if ( !$course->visible ) {
+        notice(get_string("activityiscurrentlyhidden"));
+    }
 
+    add_to_log($course->id, "glossary", "view", "view.php?id=$cm->id", "$glossary->id");
+
+    $search = trim(strip_tags($search));
     if ($search and !$entryid ) {
          $l = "";
         $searchterms = explode(" ", $search);    // Search for words independently
             }
         }
         $search = trim(implode(" ", $searchterms));
+        $currentview = "";
     } elseif ( $eid ) {
-         $search = "";
+         $search = "";
     }
-
-    if (! $cm = get_record("course_modules", "id", $id)) {
-        error("Course Module ID was incorrect");
-    }
-
-    if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
+    if ($l == "" and $search == "" and ($eid == "" or $eid == 0) ) {
+               $l = "A";
+    } elseif ( $eid ) {
+          $l = "";
     }
-
-    if (! $glossary = get_record("glossary", "id", $cm->instance)) {
-        error("Course module is incorrect");
+    if ( $currentview ) {
+          $l = "";
+          $currentview = strtolower($currentview);
+          if ( $currentview ) {
+               if ( $cat ) {
+                    $category = get_record("glossary_categories","id",$cat);
+               }
+               if ( !$category ) {
+                    $cat = "";
+               }
+          }
     }
 
-    require_login($course->id);
-
-    add_to_log($course->id, "glossary", "view", "view.php?id=$cm->id", "$glossary->id");
-
-/// Print the page header
+/// Printing the page header
 
     if ($course->category) {
         $navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
     }
 
-    $strglossaries   = get_string("modulenameplural", "glossary");
-    $strglossary     = get_string("modulename", "glossary");
-    $strselectletter = get_string("selectletter", "glossary");
-    $strspecial      = get_string("special", "glossary");
-    $strallentries   = get_string("allentries", "glossary");
-    $strnoentries    = get_string("noentries", "glossary");
-    $straddentry     = get_string("addentry", "glossary");
-    $streditentry    = get_string("editentry", "glossary");
-    $strdeleteentry  = get_string("deleteentry", "glossary");
+     $strglossaries   = get_string("modulenameplural", "glossary");
+     $strglossary     = get_string("modulename", "glossary");
+     $strallcategories= get_string("allcategories", "glossary");
+     $straddentry     = get_string("addentry", "glossary");
+     $strnoentries    = get_string("noentries", "glossary");
 
     print_header("$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),
                   navmenu($course, $cm));
 
-/// Print the main part of the page
-
-/// Printing the navigation links (letters to look for)
+/// Printing the header of the glossary
 
     echo "<p><center><b>$glossary->name<p>" ;
 
-    if ( !$course->visible ) {
-        notice(get_string("activityiscurrentlyhidden"));
-    }
-
     print_simple_box_start("center", "70%");
-      echo "<CENTER>$strselectletter";
-
-       ?>
-       <form method="POST" action="view.php">
-         <? p(get_string("searchconcept","glossary")) ?> <input type="text" name="search" size="20" value=""> <br><? p(get_string("searchindefinition","glossary")) ?> <input type="checkbox" name="includedefinition" value="1">
-         <input type="submit" value="Search" name="searchbutton">
-         <input type="hidden" name="id" value="<? p($cm->id) ?>">
-       </form>
-       <?
-
-      if ( $glossary->showspecial ) {
-          echo "<p><a href=\"$CFG->wwwroot/mod/glossary/view.php?id=$id&l=SPECIAL\">$strspecial</a> | ";
-      }
-
-      if ( $glossary->showalphabet ) {
-           $alphabet = explode("|", get_string("alphabet","glossary"));
-           $letters_by_line = 14;
-           for ($i = 0; $i < count($alphabet); $i++) {
-               echo "<a href=\"$CFG->wwwroot/mod/glossary/view.php?id=$id&l=$alphabet[$i]\">$alphabet[$i]</a>";
-               if ((int) ($i % $letters_by_line) != 0 or $i == 0) {
-                    echo " | ";
-               } else {
-                    echo "<br>";
-               }
+          echo "<table width=100% border=0><tr><td width=50% align=right>";
+       ?>
+       <form method="POST" action="view.php">
+         <? p(get_string("searchconcept","glossary")) ?> <input type="text" name="search" size="20" value=""> <br><? p(get_string("searchindefinition","glossary")) ?> <input type="checkbox" name="includedefinition" value="1">
+         <input type="submit" value="Search" name="searchbutton">
+         <input type="hidden" name="id" value="<? p($cm->id) ?>">
+       </form>
+       <?
+          echo "</td><td valign=top align=right width=50%>";
+           if (isteacher($course->id) or $glossary->studentcanpost) {
+              $options = array ("id" => "$cm->id");
+              print_single_button("edit.php", $options, $straddentry );
            }
-      }
-      
-      if ( $glossary->showall ) {
-          echo "<a href=\"$CFG->wwwroot/mod/glossary/view.php?id=$id&l=ALL\">$strallentries</a></p>";
-      }
-      
-      if (isteacher($course->id) or $glossary->studentcanpost) {
-         $options = array ("id" => "$cm->id");
-         echo "<CENTER>";
-         print_single_button("edit.php", $options, $straddentry );
-         echo "</CENTER>";
-      }
-
+           echo "</td></tr></table>";
     print_simple_box_end();
 
     echo "<p align=center>";
-    if ($l) {
-               $CurrentLetter = "";
-               if ($l == "ALL" or $l == "SPECIAL") {
-                       if ( $l == "ALL" ) {
-                               echo "<h2>$strallentries</h2><p>";
-                       } elseif ($l == "SPECIAL") {
-                               echo "<h2>$strspecial</h2><p>";
-                       }
-               }
-       } elseif( $search ) {
-               echo get_string("search") . ": $search";
-       }
-
-     $data[0]->link = "view.php?id=$id&l=$l&eid=$eid&search=$search&includedefinition=$includedefinition";
+     $data[0]->link = "view.php?id=$id";
      $data[0]->caption = get_string("standardview","glossary");
      
-     $data[1]->link = "view.php?id=$id&l=$l&eid=$eid&search=$search&includedefinition=$includedefinition&currentview=categories&cat=$cat";
+     $data[1]->link = "view.php?id=$id&currentview=categories";
      $data[1]->caption = get_string("categoryview","glossary");
-     
-     $tCFG->TabTableBGColor = $THEME->cellcontent2;
-     $tCFG->TabTableWidth = "70%";
-     $tCFG->ActiveTabColor = $THEME->cellcontent2;
-     $tCFG->InactiveTabColor = $THEME->cellheading2;
-     $tCFG->TabsPerRow = 5;
-     $tCFG->TabSeparation = 4;
-     
-     if ( $cat ) {
+
+     if ( $currentview ) {
           $CurrentTab = 1;
      } else {
           $CurrentTab = 0;
      }
      print_tabbed_table_start($data, $CurrentTab, $tCFG);
      echo "<center>";
-     if ( $cat ) {
-          echo "<b>$category->name</b><hr>";
+     if ( $currentview ) {
+         glossary_print_categories_menu($course, $cm, $glossary, $category);
+     } else {
+         glossary_print_alphabet_menu($cm, $glossary, $l);
+     
+         if ($l) {
+               $CurrentLetter = "";
+       } elseif( $search ) {
+               echo "<h3>" . get_string("search") . ": $search</h3>";
+       }
+
+          echo "<hr>";
      }
 /// Printing the entries
 
         $DumpedDefinitions= 0;
         foreach ($allentries as $entry) {
             $DumpToScreen = 0;
-            $FirstLetter = strtoupper( ltrim( $entry->concept[0] ) );
+            $FirstLetter = strtoupper( substr(ltrim($entry->concept),0,strlen($l) ) );
             if ( $l ) {
                 if ( $l == "ALL" or $FirstLetter == $l) {
-                    if ( $CurrentLetter != $FirstLetter ) {
-                         $CurrentLetter = $FirstLetter;
+                    if ( $CurrentLetter != $FirstLetter[0] ) {
+                         $CurrentLetter = $FirstLetter[0];
 
                            if ( $glossary->displayformat == 0 ) {
                                if ( $DumpedDefinitions > 0) {
                                }
                                echo "\n<center><TABLE BORDER=0 CELLSPACING=0 width=95% valign=top cellpadding=10><tr><td align=center BGCOLOR=\"$THEME->cellheading2\">";
                            }
-                           echo "<b>$CurrentLetter</b>";
+                           if ( $l == "ALL" ) {
+                              echo "<b>$CurrentLetter</b>";
+                         }
 
                            if ( $glossary->displayformat == 0 ) {
                                echo "\n</center></td></tr></TABLE></center>";
                    $DumpToScreen = 1;
                 }
             } else {
-                $DumpToScreen = 1;
+                if ( $currentview ) {
+                    if ( $category ) {
+                         if ( record_exists("glossary_entries_categories","entryid",$entry->id, "categoryid",$category->id) ) {
+                              $DumpToScreen = 1;
+                         }
+                    } else {
+                         if ( ! record_exists("glossary_entries_categories","entryid",$entry->id) ) {
+                              $DumpToScreen = 1;
+                         }
+                    }
+                } else {
+                    $DumpToScreen = 1;
+                }
             }
 
             if ( $DumpToScreen ) {
                        $entry->concept = highlight($search,$concept);
                        $entry->definition = highlight($search,$definition);
                  }
-                    glossary_print_entry($course, $cm, $glossary, $entry);
+                    glossary_print_entry($course, $cm, $glossary, $entry,$currentview,$cat);
 
                  if ( $glossary->displayformat != 0 ) {
                        echo "<p>";