]> git.mjollnir.org Git - moodle.git/commitdiff
- Exported entries are now linked instead of copied to the main glossary.
authorwillcast <willcast>
Mon, 29 Sep 2003 03:06:30 +0000 (03:06 +0000)
committerwillcast <willcast>
Mon, 29 Sep 2003 03:06:30 +0000 (03:06 +0000)
- Short tags are gone.
- Little changes in ES language.

23 files changed:
lang/en/glossary.php
lang/en/help/glossary/mainglossary.html
lang/en/help/glossary/studentcanpost.html
lang/es/glossary.php
lang/es/help/glossary/mainglossary.html
lang/es/help/glossary/studentcanpost.html
mod/glossary/backuplib.php
mod/glossary/db/mysql.php
mod/glossary/db/mysql.sql
mod/glossary/db/oci8po.sql
mod/glossary/db/postgres7.sql
mod/glossary/deleteentry.php
mod/glossary/edit.html
mod/glossary/edit.php
mod/glossary/editcategories.html
mod/glossary/editcategories.php
mod/glossary/exportentry.php
mod/glossary/lib.php
mod/glossary/minus.gif [new file with mode: 0644]
mod/glossary/mod.html
mod/glossary/restorelib.php
mod/glossary/version.php
mod/glossary/view.php

index 03f63c30f058bc443c0494052b434daec9123f0e..567c79edd10c040f65d83d781cf3642c81fe6908 100644 (file)
@@ -34,6 +34,7 @@ $string['entryexported'] = "Entry succesfully exported.";
 $string['explainspecial'] = "<b>Special</b> will show all concepts that do not begin with a letter.<br>";
 $string['explainalphabet'] = "Select the letter you want to look for.<p>";
 $string['explainall'] = "<b>ALL</b> will show all entries in one page.";
+$string['exportedentry'] = "Exported entry";
 $string['exporttomainglossary'] = "Export to main glossary";
 $string['glossarytype'] = "Glossary Type";
 $string['mainglossary'] = "Main glossary";
@@ -45,13 +46,14 @@ $string['noentries'] = "No entries found in this section";
 $string['noentry'] = "No entry found.";
 $string['searchconcept'] = "Search:";
 $string['searchindefinition'] = "Search in concept AND definitions?";
-$string['secundaryglossary'] = "Secondary glossary";
+$string['secondaryglossary'] = "Secondary glossary";
 $string['showspecial'] = "Show 'Special' link";
 $string['showalphabet'] = "Show alphabet";
 $string['showall'] = "Show 'ALL' link";
 $string['special'] = "Special";
 $string['standardview'] = "Standard View";
 $string['studentcanpost'] = "Students can add entries";
+$string['warningstudentcapost'] = "(This apply only if the glossary is not the main one)";
 $string['writtenby'] = "By";
 
 ?>
index 3bd1afcce3718145a287438a2a29c11a05c5c20b..de29e62db55a5fe83cd737b53522864422f44052 100644 (file)
@@ -2,4 +2,4 @@
 
 <P>The system allows to export entries from any secondary glossary to the main one of the course.
 <p>In order to do this, you should specify which glossary is the main one.
-<p>Note: You can have only one main glossary per course.
+<p>Note: You can have only one main glossary per course and its entries could be updated or deleted by teachers only.
index 6d7af75445f79809042a05534f4b68600a631881..957d3eaf5d838bd9595ac64391a4f089abab1232 100644 (file)
@@ -1,4 +1,5 @@
 <P ALIGN=CENTER><B>Students can post entries</B></P>
 
-<P>You can specify whether a user can or cannot add, edit or delete his/her own entries in this glossary.
-<p><b>Note:</b> A teacher can edit or delete any entry at any time.
\ No newline at end of file
+<P>You can specify whether a user can or cannot add, edit or delete his/her own entries.
+Entries exported to a main glossary can be updated or deleted by teachers only.
+<p><b>Note:</b> A teacher can edit or delete any entry at any time. This variable is not used if the glossary is the main one.
index 83b3c32f8e9fea463ca126da6d9ccd4d027809fa..947a4963e77788df9521ab8130bf936044926ec3 100644 (file)
@@ -1,58 +1,58 @@
 <?PHP // $Id$ 
       // glossary.php - created with Moodle 1.1 (2003082800)
-
-
 $string['addentry'] = "Agregar entrada";
-$string['allcategories'] = "Todas las categorías";
 $string['allentries'] = "TODAS";
+$string['allcategories'] = "Todas las categorías";
 $string['allowduplicatedentries'] = "Permitir entradas duplicadas";
-$string['alphabet'] = "A|B|C|CH|D|E|F|G|H|I|J|K|L|LL|M|N|Ñ|O|P|Q|R|S|T|U|V|W|X|Y|Z";
-$string['areyousuredelete'] = "¿Está seguro que desea borrar esta entrada?";
+$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 borrarla?";
 $string['attachment'] = "Adjunto";
-$string['back'] = "Atrás";
+$string['back'] = "Volver";
 $string['categories'] = "Categorías";
+$string['categoryview'] = "Vista por Categoría";
 $string['category'] = "Categoría";
-$string['categorydeleted'] = "Categoría borrada";
-$string['categoryview'] = "Por 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'] = "Borrar una categoría no borrará las entradas. Si desea borrar las entradas tendrá que hacerlo manualmente.";
-$string['displayformat'] = "¿Formato de muestra?";
-$string['displayformat1'] = "Completo con autor.";
-$string['displayformat2'] = "Completo sin autor.";
+$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['editcategories'] = "Editar categorías";
+$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ías";
+$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.";
-$string['explainall'] = "<b>Todas</b> mostrará todas las entradas en una página.";
-$string['explainalphabet'] = "Seleccione la letra inicial que usted desea buscar.<p> ";
-$string['explainspecial'] = "<b>Especial</b> mostrará todos los conceptos que no comienzan con una letra.<br>";
-$string['exporttomainglossary'] = "Exportar todo el glosario";
+$string['explainspecial'] = "<b>Especial</b> mostrará todos los conceptos que comiencen con símbolos.<br>";
+$string['explainalphabet'] = "Seleccione la letra que desea buscar.<p>";
+$string['explainall'] = "<b>TODAS</b> mostrará todas las entradas en una página.";
+$string['exporttomainglossary'] = "Exportar al glosario principal";
+$string['exportedentry'] = "Entrada exportada";
 $string['glossarytype'] = "Tipo de glosario";
 $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 encontraron entradas en esta sección";
+$string['noentries'] = "No se encontraro entradas en esta sección";
 $string['noentry'] = "No se econtró ninguna entrada.";
 $string['searchconcept'] = "Buscar:";
-$string['searchindefinition'] = "¿Buscar en conceptos Y definiciones?";
-$string['secundaryglossary'] = "Glosario secundario";
-$string['showall'] = "Mostrar el enlace 'Todas'";
-$string['showalphabet'] = "Mostrar el alfabeto";
-$string['showspecial'] = "Mostrar el enlace 'Especial'";
+$string['searchindefinition'] = "¿Buscar en conceptos y definiciones?";
+$string['secondaryglossary'] = "Glosario secundario";
+$string['showspecial'] = "Mostrar enlace 'Especial'";
+$string['showalphabet'] = "Mostrar alfabeto";
+$string['showall'] = "Mostrar enlace 'TODAS'";
 $string['special'] = "Especial";
-$string['standardview'] = "Visualización estándar";
+$string['standardview'] = "Vista Normal";
 $string['studentcanpost'] = "Los estudiantes pueden agregar entradas";
+$string['warningstudentcapost'] = "(Esto sólo aplica si el glosario no es principal)";
 $string['writtenby'] = "Por";
 
 ?>
index e0606fbb3dbebe52b7426b5ab781d434e766345f..4b68b18c8661281d41a8106059b56f8cfd434b7d 100644 (file)
@@ -1,4 +1,5 @@
-<P ALIGN=CENTER><B>Es este el glosario principal del curso?</B></P>\r
-\r
-<P>El sistema permite exportar definiciones de los glosarios secundarios al glosario principal del sistema.\r
-<p>Para hacer esto, usted debe especificar cual de los glosarios es el principal. Note que sólo puede tener un glosario principal por curso.
\ No newline at end of file
+<P ALIGN=CENTER><B>Es este el glosario principal del curso?</B></P>
+
+<P>El sistema permite exportar definiciones de los glosarios secundarios al glosario principal del sistema.
+<p>Para hacer esto, usted debe especificar cual de los glosarios es el principal.
+<p>Note que sólo puede tener un glosario principal por curso y sus entradas sólo podrán ser editadas o borradas por un profesor.
index b913616e99d0b27bbeed494c391e6c544e93caab..4cbbe22e65efae84064d134b1f363877b7a81b0b 100644 (file)
@@ -1,5 +1,7 @@
-<P ALIGN=CENTER><B>Los estudiantes podrán agregar definiciones?</B></P>\r
-\r
-<P>Indique si desea que los estudiantes puedan o no agregar definiciones al glosario.\r
-\r
-<p>Si seleccionan que en efecto pueden hacerlo, el sistema le permitirá, además, modificar y eliminar sus propias definiciones.\r
+<P ALIGN=CENTER><B>Los estudiantes podrán agregar definiciones?</B></P>
+
+<P>Puede especificar si los estudiantes pueden o no agregar, modificar y eliminar sus propias definiciones al glosario.
+Las entradas exportadas a un glosario principal, sólo podrán ser editadas o borradas por un profesor.
+<p>Un profesor puede modificar o borrar cualquier entrada.
+<p>Esta variable no tiene efecto si el glosario es principal.
+
index 39b7b55fd8e21c2fb84dabc591f0016613d22153..0b0fe07552259ce7755f9c2bd35ecc53dda5284f 100644 (file)
@@ -28,7 +28,7 @@
         $status = true;
 
         //Iterate over glossary table
-        $glossaries = get_records ("glossary","course",$preferences->backup_course,"id");
+        $glossaries = get_records ("glossary","course",$preferences->backup_course,"mainglossary");
         if ($glossaries) {
             foreach ($glossaries as $glossary) {
                 //Start mod
@@ -80,7 +80,7 @@
                 fwrite ($bf,full_tag("GLOSSARYID",6,false,$glo_cat->glossaryid));
                 fwrite ($bf,full_tag("NAME",6,false,$glo_cat->name));
 
-                $entries = get_records("glossary_entries_categories","categoryid",$glo_cat->id,"entryid");
+                $entries = get_records("glossary_entries_categories","categoryid",$glo_cat->id,"mainglossary");
                 if ($entries) {
                     $status =fwrite ($bf,start_tag("ENTRIES",6,true));
                     foreach ($entries as $entry) {
                     fwrite ($bf,full_tag("DEFINITION",6,false,$glo_ent->definition));
                     fwrite ($bf,full_tag("FORMAT",6,false,$glo_ent->format));
                     fwrite ($bf,full_tag("ATTACHMENT",6,false,$glo_ent->attachment));
+                    fwrite ($bf,full_tag("SOURCEGLOSSARYID",6,false,$glo_ent->sourceglossaryid));
                     fwrite ($bf,full_tag("TIMECREATED",6,false,$glo_ent->timecreated));
                     fwrite ($bf,full_tag("TIMEMODIFIED",6,false,$glo_ent->timemodified));
                     fwrite ($bf,full_tag("TEACHERENTRY",6,false,$glo_ent->teacherentry));
index 10e386dbd44c4c4820b75e7c95c04ff969e0f730..2fb33b28b9a22a540e15bbce33aac8189247946b 100644 (file)
@@ -59,6 +59,12 @@ function glossary_upgrade($oldversion) {
         execute_sql("ALTER TABLE `{$CFG->prefix}glossary_entries_categories` DROP PRIMARY KEY ");
         execute_sql("ALTER TABLE `{$CFG->prefix}glossary_entries_categories` ADD `id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST");
     }
+    
+    if ( $oldversion < 2003092400 ) {
+        execute_sql( "ALTER TABLE `{$CFG->prefix}glossary_entries` " .
+                    "ADD `sourceglossaryid` INT(10) unsigned NOT NULL DEFAULT '0' AFTER `attachment` " );
+
+    }
 
     return true;
 }
index e6803406dec46cc38a1c948c52e55654d2bb7c76..06e34348fb9ceec9adc853a9a7255d8e6896d77d 100644 (file)
@@ -39,6 +39,7 @@ CREATE TABLE prefix_glossary_entries (
      timecreated int(10) unsigned NOT NULL default '0',
      timemodified int(10) unsigned NOT NULL default '0',
      teacherentry tinyint(2) unsigned NOT NULL default '0',
+     sourceglossaryid int(10) unsigned NOT NULL '0',
      PRIMARY KEY  (id)
 ) TYPE=MyISAM COMMENT='all glossary entries';
 
index 2da8a15d775bbeb06640f7b5990416d5aee62253..b9738b92dbf09ef3cf4ec31b11a37e86386695ed 100755 (executable)
@@ -61,7 +61,8 @@ CREATE TABLE prefix_glossary_entries (
   attachment varchar2(100) default '' not null,
   timecreated number(10) default '0' not null,
   timemodified number(10) default '0' not null,
-  teacherentry number(2) default '0' not null
+  teacherentry number(2) default '0' not null,
+  sourceglossaryid number(10) default '0' not null
 );
 
 COMMENT on table prefix_glossary_entries is 'all glossary entries';
@@ -155,9 +156,15 @@ rem
 
 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', 'delete', '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', 'delete 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 24035e989e058b87a5f3881bcb0eafa45828a26c..81631aaeee29248f4f97319528410d860bcf288b 100644 (file)
@@ -39,6 +39,7 @@ CREATE TABLE prefix_glossary_entries (
      timecreated int4 NOT NULL default '0',
      timemodified int4 NOT NULL default '0',
      teacherentry int2 NOT NULL default '0',
+     sourceglossaryid int4 NOT NULL default '0',
      PRIMARY KEY(id)
 );
 
index 4d4e334040ec056d7be75d4a2cafb357ea25a21d..ef773ecb7cc69da07fd562790b02880d6d94723a 100644 (file)
@@ -6,7 +6,7 @@
     require_variable($id);    // course module ID
     require_variable($mode);  // edit or delete
     optional_variable($go);  // commit the operation?
-    optional_variable($entry);  // edit or delete
+    optional_variable($entry);  // entry id
 
     $strglossary = get_string("modulename", "glossary");
     $strglossaries = get_string("modulenameplural", "glossary");
 /// If data submitted, then process and store.
     
     if ($mode == "edit" or $mode == "delete" ) {
-       echo "<p>";
-       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();
-                       }
-                       print_footer($course);
-                  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";
-                               
-                               ?>
-                    <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();
-                       }
-               } 
-       } else {
-               error("You are not allowed to edit or delete entries");
-       }
-    } else {
+       echo "<p>";
+       if ( isteacher($cm->id) or $glossary->studentcanpost ) {
+               if ($go) {      // the operation was confirmed.
+                       if ( $mode == "delete") {
+                           // if it is an imported entry, just delete the relation
+                           $entry = get_record("glossary_entries","id", $entry);
+                           if ( $entry->sourceglossaryid ) {
+                               $entry->glossaryid = $entry->sourceglossaryid;
+                               $entry->sourceglossaryid = 0;
+                        if (! update_record("glossary_entries", $entry)) {
+                               error("Could not update your glossary");
+                               }
+                           } else {
+                                   glossary_delete_old_attachments($entry->id);
+                                   delete_records("glossary_entries","id", $entry->id);                                
+                           }
+                       
+                    print_simple_box_start("center","40%", "#FFBBBB");
+                               echo "<center>$entrydeleted"; //CAMBIAR
+                               echo "</center>";
+                               print_simple_box_end();
+                       }
+                               print_footer($course);
+                      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";
+                               
+                               ?>
+                        <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=<?php p($currentview) ?>>
+                        <input type="hidden" name=cat=<?php 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>
+                       <?php
+                               print_simple_box_end();
+                       }
+               }
+       } else {
+               error("You are not allowed to edit or delete entries");
+       }
     }
     print_footer($course);
 ?>
index 5482caf73ce34cf12d0ced8ac9c01309080b0c54..c173ac0f0724176168904b339932a789dc176bd5 100644 (file)
@@ -1,37 +1,39 @@
-<?
+<?php
        global $CFG, $THEME;
        require_once("../../config.php");
 ?>
 <FORM name="theform" method="post" <?=$onsubmit ?> action="edit.php" enctype="multipart/form-data">
-<table  class=generalbox cellpadding=5 bgcolor="<? p($THEME->cellheading)?>">
+<table  class=generalbox cellpadding=5 bgcolor="<?php p($THEME->cellheading)?>">
 <tr valign=top>
     <td align=right><p><b><?php echo get_string("concept","glossary") ?>:</b></p></td>
     <td>
-        <INPUT type="text" name="concept" size=30 value="<? p($form->concept) ?>">
+        <INPUT type="text" name="concept" size=30 value="<?php p($form->concept) ?>">
     </td>
 </tr>
 <tr valign=top>
     <td align=right><p><b><?php echo get_string("categories","glossary") ?>:</b></p></td>
     <td>       
-       <?
+       <?php
                $categories = get_records("glossary_categories","glossaryid",$glossary->id);
                echo "<select size=\"6\" name=\"categories[]\" multiple=\"yes\">";
                echo "<option value=0>" . get_string("nocategorized","glossary") . "</optioon>";
 
-               foreach ( $categories as $category ) {
-                       echo "  <option ";
+               if ( $categories ) {
+            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";
+                           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>
+    <td align=right><p><b><?php echo get_string("definition","glossary") ?>:</b></p>
     <font size="1">
      <?php
         helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
@@ -75,7 +77,7 @@
 <tr>
 <td colspan=2>
        <p align=center>
-       <? if ($entry->id) {
+       <?php if ($entry->id) {
                echo "<input type=\"hidden\" name=entry value=\"$entry->id\">";
         }
        ?>
@@ -83,8 +85,8 @@
        <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") ?>">
+       <input type="submit" value="<?php print_string("savechanges") ?>">
+       <input type="reset" value="<?php print_string("revert") ?>">
        </P>
 </td>
 </tr>
index 99467bcc7f7646c5a590baa50be94a2cee146a2d..63d4ec9a7b07a2598d1bc12d0d1cf1e4142b29aa 100644 (file)
@@ -95,10 +95,11 @@ if ($e) {
                 $newentry->timecreated = time();
                 $newentry->timemodified = time();
                 $newentry->teacherentry = isteacher($course->id,$USER->id);
+                $newentry->sourceglossaryid = 0;
 
                 $PermissionGranted = 1;
                 if ( !$glossary->allowduplicatedentries ) {
-                       $dupentries = get_record("glossary_entries","UCASE(concept)", strtoupper($newentry->concept));
+                       $dupentries = get_record("glossary_entries","UCASE(concept)", strtoupper($newentry->concept), "glossaryid", $glossary->id);
                        if ($dupentries) {
                               $PermissionGranted = 0;
                        }
index fdfc0d156eb379f198234e83df9c72bf2517a616..278776cfd3257fc63be0150aa5c3cb23e2299808 100644 (file)
@@ -1,11 +1,11 @@
-<?
+<?PHP
        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)?>">
+<table  class=generalbox cellpadding=5 bgcolor="<?php p($THEME->cellheading)?>">
 <tr valign=top>
     <td align=right><p><b><?php echo get_string("name") ?>:</b></p></td>
     <td>
@@ -17,9 +17,9 @@
        <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);">
+       <input type="hidden" name=cat value=<?php p($cat) ?>>
+       <input type="submit" value="<?php print_string("savechanges") ?>">
+       <input type="reset" value="<?php print_string("back","glossary") ?>"  onclick="javascript:history.go(-1);">
        </P>
 </td>
 </tr>
index bf2260e66b34dd6d044a71fc3f8fefd6f7e9d714..37fda34aec2598aaa72a870ed754917f5a1331e5 100644 (file)
                     $CategoryObject->name = $name;
 
                     if ( !update_record("glossary_categories", $CategoryObject) ) {
-                               error("Weird error. The category was not updated.");
-                               
-                               redirect("editcategories.php?id=$cm->id");
+                                   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);
                     }
-                    
                } else {
                     echo "<p align=\"center\">" . get_string("edit"). " " . get_string("category","glossary") . "<font size=\"3\">";
 
           } elseif ( $action == "delete" ) {
                if ( $confirm ) {
                
-                               delete_records("glossary_entries_categories","categoryid", $cat);
+                                   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_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");
+                           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>";
+                           print_simple_box_start("center","40%", "#FFBBBB");
+                           echo "<center><b>$category->name</b><br>";
                        
-                       $num_entries = count_records("glossary_entries_categories","categoryid",$category->id);
+                           $num_entries = count_records("glossary_entries_categories","categoryid",$category->id);
                     if ( $num_entries ) {
                          print_string("deletingnoneemptycategory","glossary");
                     }
                     <input type="submit" value=" <?php print_string("yes")?> ">
                     </form>
                     </td><td align=left width=50%>
-                    <?
+                    <?php
                     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();
+                           echo "</center>";
+                           print_simple_box_end();
                }
           }
      } elseif ( $action == "add" ) {
           if ( $confirm ) {
-               $dupcategory = get_record("glossary_categories","lcase(name)",strtolower($name));
+               $dupcategory = get_record("glossary_categories","lcase(name)",strtolower($name),"glossaryid",$glossary->id);
                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_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");
+                           redirect("editcategories.php?id=$cm->id&action=add&&name=$name");
 
                } else {
                     $action = "";
                     $CategoryObject->glossaryid = $glossary->id;
 
                     if ( ! $CategoryObject->id = insert_record("glossary_categories", $CategoryObject) ) {
-                               error("Weird error. The category was not inserted.");
+                                   error("Weird error. The category was not inserted.");
                                
-                               redirect("editcategories.php?id=$cm->id");
+                                   redirect("editcategories.php?id=$cm->id");
                     } else {
-                         add_to_log($course->id, "glossary", "add category", "editcategories.php?id=$cm->id", $cat);
+                        add_to_log($course->id, "glossary", "add category", "editcategories.php?id=$cm->id", $CategoryObject->id);
                     }
              }
           } else {
      }
      
      if ( $action ) {
-
           print_footer();
           die;
      }
 ?>
 
 
-<p align="center"><? p(get_string("edit")) ?> <? p(get_string("categories","glossary")) ?><font size="3">
+<p align="center"><?php p(get_string("edit")) ?> <?php 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)?>">
+<table width="40%" class=generalbox cellpadding=5 bgcolor="<?php p($THEME->cellheading)?>">
         <tr>
           <td width="90%" align="center"><b>
-          <? p(get_string("categories","glossary")) ?></b></td>
+          <?php p(get_string("categories","glossary")) ?></b></td>
           <td width="10%" align="center"><b>
-          <? p(get_string("action")) ?></b></td>
+          <?php p(get_string("action")) ?></b></td>
         </tr>
-        <tr><td width=100% colspan=2  bgcolor="<? p($THEME->cellheading2)?>">
+        <tr><td width=100% colspan=2  bgcolor="<?php p($THEME->cellheading2)?>">
         
         <table width=100%>
-<?
+<?php
      $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)?>">
+             <tr bgcolor="<?php p($THEME->cellheading2)?>">
                <td width="90%" align="left">
-               <?
+               <?php
                     echo "<b>$category->name</b> <font size=-1>($num_entries " . get_string("entries","glossary") . ")</font>";
                ?>
                </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>";
                ?>
                </b></td>
              </tr>
              
-             <?
+             <?php
           }
      }
 ?>
         
         </td>
         <tr>
-        <td width=100% colspan=2  align=center bgcolor="<? p($THEME->cellheading2)?>">
-            <?
+        <td width=100% colspan=2  align=center bgcolor="<?php p($THEME->cellheading2)?>">
+            <?php
             
              $options['id'] = $cm->id;
              $options['action'] = "add";
 
 </form>
 
-<? print_footer() ?>
+<?php print_footer() ?>
index 35ea5ad9fe1170c246de5ee504c1ce19fb58b961..85d6f8b785475c694fe5f7cefd4169b9d6fa9dc4 100644 (file)
@@ -1,4 +1,4 @@
-<?
+<?PHP
        require_once("../../config.php");
        require_once("lib.php");
 
                                }
                        }
                        if ( $PermissionGranted ) {
-                       $newentry->userid = $entry->userid;
-               $newentry->glossaryid = $mainglossary->id;
-                       $newentry->concept = $entry->concept;
-                       $newentry->definition = $entry->definition;
-               $newentry->format = $entry->format;
-                               $newentry->timecreated = $entry->timecreated;
-                               $newentry->timemodified = $entry->timemodified;
-                               $newentry->teacherentry = $entry->teacherentry;
-                               $newentry->attachment = $entry->attachment;
-
-                               if (! $newentry->id = insert_record("glossary_entries", $newentry) ) {
+                       
+                $entry->glossaryid       = $mainglossary->id;
+                $entry->sourceglossaryid = $glossary->id;
+                
+                if (! update_record("glossary_entries", $entry)) {
                                        error("Could not export the entry to the main glossary");
                                } else {
-                         print_simple_box_start("center", "60%", "$THEME->cellheading");
-                         echo "<p align=center><font size=3>$entryexported</font></p></font>";
-                         if ($newentry->attachment) {
-                              $entry->course = $cm->course;
-                                 $newentry->course = $cm->course;
-                              if ( !glossary_copy_attachments($entry, $newentry) ) {
-                                   echo "<p align=\"center\">However, the attachment couldn't be exported.";
-                              }
-                         }
-                         
-                         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&currentview=$currentview&cat=$cat&eid=".$entry->id);
-                         print_simple_box_end();
-
-                                       print_footer();
-
-                       redirect("view.php?id=$cm->id&currentview=$currentview&cat=$cat&eid=".$entry->id);
-                       die;
+                    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_simple_box_end();
+
+                               print_footer();
+
+                   redirect("view.php?id=$cm->id&eid=".$entry->id);
+                   die;
                                }
                        } else {
                            print_simple_box_start("center", "60%", "#FFBBBB");
                            echo "<p align=center><font size=3>$entryalreadyexist</font></p></font>";
                                echo "<p align=center>";
 
-                               print_continue("view.php?id=$cm->id&currentview=$currentview&cat=$cat&eid=".$entry->id);
+                               print_continue("view.php?id=$cm->id&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&currentview=$currentview&cat=$cat&eid=".$entry->id);
+                       print_continue("view.php?id=$cm->id&eid=".$entry->id);
 
                print_simple_box_end();
        }
index 11ecadd34a4e173b0b021e8f9f1be06f35c58e34..91f07af166f9687fdcc011a69a595179954a5cb0 100644 (file)
@@ -217,19 +217,39 @@ function glossary_print_entry_by_default($course, $cm, $glossary, $entry,$curren
 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) {
+    $ImportedEntry = ($entry->sourceglossaryid == $glossary->id);
+    $IsTeacher = isteacher($course->id);
+    $IsMainGlossary = $glossary->mainglossary;
+    
+       if ($IsTeacher or $glossary->studentcanpost and $entry->userid == $USER->id) {
                echo "<p align=right>";
-               if (isteacher($course->id) and !$glossary->mainglossary) {
+               // only teachers can export entries so check it out
+               if ($IsTeacher and !$IsMainGlossary and !$ImportedEntry) {
                        $mainglossary = get_record("glossary","mainglossary",1,"course",$course->id);
-                       if ( $mainglossary ) {
-
-                               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> ";
+                       if ( $mainglossary ) {  // if there is a main glossary defined, allow to export the current entry
+                               
+                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&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>";
-         }
+               
+        if ( $entry->sourceglossaryid ) {
+            $icon = "minus.gif";   // graphical metaphor (minus) for deleting an imported entry
+        } else {
+            $icon = "../../pix/t/delete.gif";
+        }
+
+               // Exported entries can be updated/deleted only by teachers in the main glossary
+        if ( !$ImportedEntry and ($IsTeacher or !$IsMainGlossary) ) {
+            echo "<a href=\"deleteentry.php?id=$cm->id&mode=delete&entry=$entry->id&currentview=$currentview&cat=$cat\"><img  alt=\"" . get_string("delete") . "\"src=\"";
+            echo $icon;
+            echo "\" 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>";
+        } elseif ( $ImportedEntry ) {
+            echo "<font size=-1>" . get_string("exportedentry","glossary") . "</font>";
+        }
+       }
 }
 
 function glossary_search_entries($searchterms, $glossary, $includedefinition) {
@@ -298,7 +318,7 @@ function glossary_search_entries($searchterms, $glossary, $includedefinition) {
     $selectsql = "{$CFG->prefix}glossary_entries e,
                   {$CFG->prefix}glossary g $onlyvisibletable
              WHERE ($conceptsearch OR $definitionsearch)
-               AND e.glossaryid = g.id $onlyvisible
+               AND (e.glossaryid = g.id or e.sourceglossaryid = g.id) $onlyvisible
                   AND g.id = $glossary->id";
 
     $totalcount = count_records_sql("SELECT COUNT(*) FROM $selectsql");
@@ -499,7 +519,7 @@ function glossary_print_attachments($entry, $return=NULL) {
     return $imagereturn;
 }
 
-function print_tabbed_table_start($data, $CurrentTab, $tTHEME = NULL) {
+function glossary_print_tabbed_table_start($data, $CurrentTab, $tTHEME = NULL) {
 
 if ( !$tTHEME ) {
      global $THEME;
@@ -522,19 +542,22 @@ $NumRows              = (int) ( $Tabs / $TabsPerRow ) + 1;
 
 ?>
   <center>
-  <table border="0" cellpadding="0" cellspacing="0" width="<? p($TableWidth) ?>">
+  <table border="0" cellpadding="0" cellspacing="0" width="<?php p($TableWidth) ?>">
     <tr>
       <td width="100%">
 
       <table border="0" cellpadding="0" cellspacing="0" width="100%">
 
-<?
+<?php
 $TabProccessed = 0;
 for ($row = 0; $row < $NumRows; $row++) {
      echo "<tr>\n";
      if ( $row != $CurrentRow ) {
           for ($col = 0; $col < $TabsPerRow; $col++) {
                if ( $TabProccessed < $Tabs ) {
+                    if ( $col == 0 ) {
+                        echo "<td width=\"$TabSeparation\" align=\"center\">&nbsp;</td>";
+                    }
                     if ($TabProccessed == $CurrentTab) {
                          $CurrentColor = $CurrentTabColor;
                     } else {
@@ -569,6 +592,9 @@ for ($row = 0; $row < $NumRows; $row++) {
           $TabProccessed = $FirstTabInCurrentRow;
           for ($col = 0; $col < $TabsPerRow; $col++) {
                if ( $TabProccessed < $Tabs ) {
+                    if ( $col == 0 ) {
+                        echo "<td width=\"$TabSeparation\" align=\"center\">&nbsp;</td>";
+                    }
                     if ($TabProccessed == $CurrentTab) {
                          $CurrentColor = $CurrentTabColor;
                     } else {
@@ -607,15 +633,15 @@ for ($row = 0; $row < $NumRows; $row++) {
       </td>
     </tr>
     <tr>
-      <td width="100%" bgcolor="<? p($TableColor) ?>"><hr></td>
+      <td width="100%" bgcolor="<?php p($TableColor) ?>"><hr></td>
     </tr>
     <tr>
-      <td width="100%" bgcolor="<? p($TableColor) ?>">
+      <td width="100%" bgcolor="<?php p($TableColor) ?>">
           <center>
-<?
+<?php
 }
 
-function print_tabbed_table_end() {
+function glossary_print_tabbed_table_end() {
      echo "</center><p></td></tr></table></center>";
 }
 
@@ -722,4 +748,15 @@ global $CFG, $THEME;
      echo "<tr><td colspan=3><hr></td></tr>";
      echo "</table>";
 }
+
+function glossary_sort_entries ( $entry0, $entry1 ) {
+    if ( strtolower(ltrim($entry0->concept)) < strtolower(ltrim($entry1->concept)) ) {
+        return -1;
+    } elseif ( strtolower(ltrim($entry0->concept)) > strtolower(ltrim($entry1->concept)) ) {
+        return 1;
+    } else {
+        return 0;
+    }
+}
+
 ?>
diff --git a/mod/glossary/minus.gif b/mod/glossary/minus.gif
new file mode 100644 (file)
index 0000000..3561016
Binary files /dev/null and b/mod/glossary/minus.gif differ
index 98c9f829d3055e4666fb4c20ef48c4552dffac72..951173a9fa325481276ed52a41973009df09364a 100644 (file)
@@ -5,87 +5,92 @@
 <CENTER>
 <TABLE cellpadding=5>
 <TR valign=top>
-    <TD align=right><P><B><? print_string("name") ?>:</B></P></TD>
+    <TD align=right><P><B><?php print_string("name") ?>:</B></P></TD>
     <TD>
-        <INPUT type="text" name="name" size=30 value="<? p($form->name) ?>">
+        <INPUT type="text" name="name" size=30 value="<?php p($form->name) ?>">
     </TD>
 </TR>
 <!-- More rows go in here... -->
+<?php
+$mainglossary = get_record("glossary","mainglossary",1,"course",$form->course);
+if (!$mainglossary or $mainglossary->id == $form->instance ) {
+?>
 <TR valign=top>
-    <TD align=right><P><B><? echo get_string("studentcanpost", "glossary") ?>:</B></P></TD>
+    <TD align=right><P><B><?php echo get_string("glossarytype", "glossary") ?>:</B></P></TD>
     <TD>
-  <select size="1" name="studentcanpost">
-  <option value="1" <? 
-   if ( $form->studentcanpost ) {
+  <select size="1" name="mainglossary">
+  <option value="1" <?php
+   if ( $form->mainglossary ) {
       echo "selected";
    }
-   ?>><? echo get_string("yes") ?></option>
-  <option value="0" <? 
-   if ( !$form->studentcanpost ) {
+   ?>><?php echo get_string("mainglossary", "glossary") ?></option>
+  <option value="0" <?php
+   if ( !$form->mainglossary ) {
       echo "selected";
    }
-   ?>><? echo get_string("no") ?>
+   ?>><?php echo get_string("secondaryglossary", "glossary") ?>
   </option>
-  </select> <? helpbutton("studentcanpost", get_string("studentcanpost", "glossary"), "glossary") ?>
+  </select> <?php helpbutton("mainglossary", get_string("mainglossary", "glossary"), "glossary") ?>
     </TD>
 </TR>
+<?php
+} else {
+       echo "<INPUT type=\"hidden\" name=mainglossary value=\"0\">";
+}
+?>
 <TR valign=top>
-    <TD align=right><P><B><? echo get_string("allowduplicatedentries", "glossary") ?>:</B></P></TD>
+    <TD align=right><P><B><?php p(get_string("studentcanpost", "glossary")) ?>:</B><br>
+    <font size=1><?php p(get_string("warningstudentcapost","glossary")) ?></font></P></TD>
     <TD>
-  <select size="1" name="allowduplicatedentries">
-  <option value="1" <? 
-   if ( $form->allowduplicatedentries ) {
+  <select size="1" name="studentcanpost">
+  <option value="1" <?php
+   if ( $form->studentcanpost ) {
       echo "selected";
    }
-   ?> 
-   ><? echo get_string("yes") ?></option>
-  <option value="0" <? 
-   if ( !$form->allowduplicatedentries ) {
+   ?>><?php echo get_string("yes") ?></option>
+  <option value="0" <?php
+   if ( !$form->studentcanpost ) {
       echo "selected";
    }
-   ?>><? echo get_string("no") ?>
+   ?>><?php echo get_string("no") ?>
   </option>
-  </select> <? helpbutton("allowduplicatedentries", get_string("allowduplicatedentries", "glossary"), "glossary") ?>
+  </select> <?php helpbutton("studentcanpost", get_string("studentcanpost", "glossary"), "glossary") ?>
     </TD>
 </TR>
-<?
-$mainglossary = get_record("glossary","mainglossary",1,"course",$form->course);
-if (!$mainglossary or $mainglossary->id == $form->instance ) {
-?>
 <TR valign=top>
-    <TD align=right><P><B><? echo get_string("glossarytype", "glossary") ?>:</B></P></TD>
+    <TD align=right><P><B><?php echo get_string("allowduplicatedentries", "glossary") ?>:</B></P></TD>
     <TD>
-  <select size="1" name="mainglossary">
-  <option value="1" <? 
-   if ( $form->mainglossary ) {
+  <select size="1" name="allowduplicatedentries">
+  <option value="1" <?php
+   if ( $form->allowduplicatedentries ) {
       echo "selected";
    }
-   ?>><? echo get_string("mainglossary", "glossary") ?></option>
-  <option value="0" <? 
-   if ( !$form->mainglossary ) {
+   ?> 
+   ><?php echo get_string("yes") ?></option>
+  <option value="0" <?php
+   if ( !$form->allowduplicatedentries ) {
       echo "selected";
    }
-   ?>><? echo get_string("secundaryglossary", "glossary") ?>
+   ?>><?php echo get_string("no") ?>
   </option>
-  </select> <? helpbutton("mainglossary", get_string("mainglossary", "glossary"), "glossary") ?>
+  </select> <?php helpbutton("allowduplicatedentries", get_string("allowduplicatedentries", "glossary"), "glossary") ?>
     </TD>
 </TR>
-<?
-} else {
-       echo "<INPUT type=\"hidden\" name=mainglossary value=\"0\">";
-}
-?>
 <TR valign=top>
-    <TD align=right><P><B><? echo get_string("displayformat", "glossary") ?>:</B></P></TD>
+<td colspan=2><hr>
+</tr>
+</tr>
+<TR valign=top>
+    <TD align=right><P><B><?php echo get_string("displayformat", "glossary") ?>:</B></P></TD>
     <TD>
   <select size="1" name="displayformat">
-  <option value="0" <? 
+  <option value="0" <?php
    if ( $form->displayformat == 0) {
       echo "selected";
    }
-  ?>><? echo get_string("displayformatdefault", "glossary") ?></option>
+  ?>><?php echo get_string("displayformatdefault", "glossary") ?></option>
 
-<?
+<?php
     global $CFG;
 
     $basedir = opendir("$CFG->dirroot/mod/glossary/formats");
@@ -112,75 +117,75 @@ if (!$mainglossary or $mainglossary->id == $form->instance ) {
        
 ?>
 
-    </select> <? helpbutton("displayformat", get_string("displayformat", "glossary"), "glossary") ?>
+    </select> <?php helpbutton("displayformat", get_string("displayformat", "glossary"), "glossary") ?>
     </TD>
 </TR>
 <TR valign=top>
-    <TD align=right><P><B><? echo get_string("showspecial", "glossary") ?>:</B></P></TD>
+    <TD align=right><P><B><?php echo get_string("showspecial", "glossary") ?>:</B></P></TD>
     <TD>
   <select size="1" name="showspecial">
-  <option value="1" <? 
+  <option value="1" <?php
    if ( $form->showspecial ) {
       echo "selected";
    }
    ?> 
-   ><? echo get_string("yes") ?></option>
-  <option value="0" <? 
+   ><?php echo get_string("yes") ?></option>
+  <option value="0" <?php
    if ( !$form->showspecial ) {
       echo "selected";
    }
-   ?>><? echo get_string("no") ?>
+   ?>><?php echo get_string("no") ?>
   </option>
-  </select> <? helpbutton("shows", get_string("showspecial", "glossary"), "glossary") ?>
+  </select> <?php helpbutton("shows", get_string("showspecial", "glossary"), "glossary") ?>
     </TD>
 </TR>
 <TR valign=top>
-    <TD align=right><P><B><? echo get_string("showalphabet", "glossary") ?>:</B></P></TD>
+    <TD align=right><P><B><?php echo get_string("showalphabet", "glossary") ?>:</B></P></TD>
     <TD>
   <select size="1" name="showalphabet">
-  <option value="1" <? 
+  <option value="1" <?php
    if ( $form->showalphabet ) {
       echo "selected";
    }
    ?> 
-   ><? echo get_string("yes") ?></option>
-  <option value="0" <? 
+   ><?php echo get_string("yes") ?></option>
+  <option value="0" <?php
    if ( !$form->showalphabet ) {
       echo "selected";
    }
-   ?>><? echo get_string("no") ?>
+   ?>><?php echo get_string("no") ?>
   </option>
-  </select> <? helpbutton("shows", get_string("showalphabet", "glossary"), "glossary") ?>
+  </select> <?php helpbutton("shows", get_string("showalphabet", "glossary"), "glossary") ?>
     </TD>
 </TR>
 <TR valign=top>
-    <TD align=right><P><B><? echo get_string("showall", "glossary") ?>:</B></P></TD>
+    <TD align=right><P><B><?php echo get_string("showall", "glossary") ?>:</B></P></TD>
     <TD>
   <select size="1" name="showall">
-  <option value="1" <? 
+  <option value="1" <?php
    if ( $form->showall ) {
       echo "selected";
    }
    ?> 
-   ><? echo get_string("yes") ?></option>
-  <option value="0" <? 
+   ><?php echo get_string("yes") ?></option>
+  <option value="0" <?php
    if ( !$form->showall ) {
       echo "selected";
    }
-   ?>><? echo get_string("no") ?>
+   ?>><?php echo get_string("no") ?>
   </option>
-  </select> <? helpbutton("shows", get_string("showall", "glossary"), "glossary") ?>
+  </select> <?php helpbutton("shows", get_string("showall", "glossary"), "glossary") ?>
     </TD>
 </TR>
 </TABLE>
 <!-- These hidden variables are always the same -->
-<INPUT type="hidden" name=course        value="<? p($form->course) ?>">
-<INPUT type="hidden" name=coursemodule  value="<? p($form->coursemodule) ?>">
-<INPUT type="hidden" name=section       value="<? p($form->section) ?>">
-<INPUT type="hidden" name=module        value="<? p($form->module) ?>">
-<INPUT type="hidden" name=modulename    value="<? p($form->modulename) ?>">
-<INPUT type="hidden" name=instance      value="<? p($form->instance) ?>">
-<INPUT type="hidden" name=mode          value="<? p($form->mode) ?>">
-<INPUT type="submit" value="<? print_string("savechanges") ?>">
+<INPUT type="hidden" name=course        value="<?php p($form->course) ?>">
+<INPUT type="hidden" name=coursemodule  value="<?php p($form->coursemodule) ?>">
+<INPUT type="hidden" name=section       value="<?php p($form->section) ?>">
+<INPUT type="hidden" name=module        value="<?php p($form->module) ?>">
+<INPUT type="hidden" name=modulename    value="<?php p($form->modulename) ?>">
+<INPUT type="hidden" name=instance      value="<?php p($form->instance) ?>">
+<INPUT type="hidden" name=mode          value="<?php p($form->mode) ?>">
+<INPUT type="submit" value="<?php print_string("savechanges") ?>">
 </CENTER>
 </FORM>
index c1309cb963163577644400f10a1d775886a85f86..ba812beb444871fba8250a6eea633d00b257fc57 100644 (file)
             $entry->definition = backup_todb($ent_info['#']['DEFINITION']['0']['#']);
             $entry->format = backup_todb($ent_info['#']['FORMAT']['0']['#']);
             $entry->attachment = backup_todb($ent_info['#']['ATTACHMENT']['0']['#']);
+            $entry->sourceglossaryid = backup_todb($ent_info['#']['SOURCEGLOSSARYID']['0']['#']);
             $entry->timecreated = backup_todb($ent_info['#']['TIMECREATED']['0']['#']);
             $entry->timemodified = backup_todb($ent_info['#']['TIMEMODIFIED']['0']['#']);
             $entry->teacherentry = backup_todb($ent_info['#']['TEACHERENTRY']['0']['#']);
 
+
             //We have to recode the userid field
             $user = backup_getid($restore->backup_unique_code,"user",$entry->userid);
             if ($user) {
                 $entry->userid = $user->new_id;
-             }
+            }
+            //We have to recode the sourceglossaryid field
+            $source = backup_getid($restore->backup_unique_code,"glossary",$entry->sourceglossaryid);
+            if ($source) {
+                $entry->sourceglossaryid = $source->new_id;
+            }
             //If it's a teacher entry or userinfo was selected, restore the entry
             if ($entry->teacherentry or $restore->mods['glossary']->userinfo) {
                 //The structure is equal to the db, so insert the glossary_entries
index 243607b010d546847be84e2ab976496364df93cc..75cec4a16dc15f1f49b20d31379ae7e58d6981f7 100644 (file)
@@ -5,9 +5,9 @@
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 /////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2003092102;  // The current module version (Date: YYYYMMDDXX)
+$module->version  = 2003092400;  // The current module version (Date: YYYYMMDDXX)
 $module->cron     = 0;           // Period for cron to check this module (secs)
 
-$release = "0.3.2 development";   // User-friendly version number
+$release = "0.4 development";   // User-friendly version number
 
 ?>
index 2ab900ec3be4602c5ba5c9d019b74fa937d79bad..10bf3d280bb3121f498d322ddda1626544d19a32 100644 (file)
         $navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
     }
 
-     $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",
+    $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(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),
                   navmenu($course, $cm));
           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) ?>">
+         <?php p(get_string("searchconcept","glossary")) ?> <input type="text" name="search" size="20" value=""> <br><?php p(get_string("searchindefinition","glossary")) ?> <input type="checkbox" name="includedefinition" value="1">
+         <input type="submit" value="<?php p(get_string("search")) ?>" name="searchbutton">
+         <input type="hidden" name="id" value="<?php p($cm->id) ?>">
        </form>
-       <?
+       <?php
           echo "</td><td valign=top align=right width=50%>";
            if (isteacher($course->id) or ($glossary->studentcanpost) and !isguest($course->id)) {
               $options = array ("id" => "$cm->id");
      } else {
           $CurrentTab = 0;
      }
-     print_tabbed_table_start($data, $CurrentTab, $tCFG);
+     glossary_print_tabbed_table_start($data, $CurrentTab, $tCFG);
      echo "<center>";
      if ( $currentview ) {
          glossary_print_categories_menu($course, $cm, $glossary, $cat, $category);
                $allentries = get_records("glossary_entries", "id", $eid);
        } elseif ( $currentview and $cat == 0 ) {   // Browsing all categories
         $sql = "SELECT gec.id gecid, gc.name, gc.id CID, ge.*
-            FROM {$CFG->prefix}glossary_entries ge,
-                {$CFG->prefix}glossary_entries_categories gec,
-                {$CFG->prefix}glossary_categories gc
-            WHERE ge.glossaryid = '$glossary->id' AND
-                gec.entryid = ge.id AND
-                gc.id = gec.categoryid
-            ORDER BY gc.name, ge.concept";
+                FROM {$CFG->prefix}glossary_entries ge,
+                    {$CFG->prefix}glossary_entries_categories gec,
+                    {$CFG->prefix}glossary_categories gc
+                WHERE (ge.glossaryid = '$glossary->id' or ge.sourceglossaryid = '$glossary->id') AND
+                    gec.entryid = ge.id AND
+                    gc.id = gec.categoryid
+                ORDER BY gc.name, ge.concept";
            $allentries = get_records_sql( $sql );
        } else {                        // looking for terms that begin with a specify letter or entries with no category associated
-               $allentries = get_records("glossary_entries", "glossaryid", $glossary->id,"concept ASC");
+               $ownentries = get_records("glossary_entries", "glossaryid", $glossary->id,"concept ASC");
+               $importedentries = get_records("glossary_entries", "sourceglossaryid", $glossary->id,"concept ASC");
+               
+               if ( $ownentries and $importedentries ) {
+                   $allentries = array_merge($ownentries, $importedentries);
+                   usort($allentries, glossary_sort_entries);          
+               } elseif ( $importedentries ) {
+                   $allentries = $importedentries;
+               } elseif ( $ownentries ) {
+                   $allentries = $ownentries;
+               }
        }
 
     if ( $allentries ) {
        }
 
      echo "</center>";
-     print_tabbed_table_end();
+     glossary_print_tabbed_table_end();
 
 /// Finish the page
     print_footer($course);