From: willcast Date: Mon, 29 Sep 2003 03:06:30 +0000 (+0000) Subject: - Exported entries are now linked instead of copied to the main glossary. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=ad58adac109d37179ed223c926d4e740b7ad17a8;p=moodle.git - Exported entries are now linked instead of copied to the main glossary. - Short tags are gone. - Little changes in ES language. --- diff --git a/lang/en/glossary.php b/lang/en/glossary.php index 03f63c30f0..567c79edd1 100644 --- a/lang/en/glossary.php +++ b/lang/en/glossary.php @@ -34,6 +34,7 @@ $string['entryexported'] = "Entry succesfully exported."; $string['explainspecial'] = "Special will show all concepts that do not begin with a letter.
"; $string['explainalphabet'] = "Select the letter you want to look for.

"; $string['explainall'] = "ALL 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"; ?> diff --git a/lang/en/help/glossary/mainglossary.html b/lang/en/help/glossary/mainglossary.html index 3bd1afcce3..de29e62db5 100644 --- a/lang/en/help/glossary/mainglossary.html +++ b/lang/en/help/glossary/mainglossary.html @@ -2,4 +2,4 @@

The system allows to export entries from any secondary glossary to the main one of the course.

In order to do this, you should specify which glossary is the main one. -

Note: You can have only one main glossary per course. +

Note: You can have only one main glossary per course and its entries could be updated or deleted by teachers only. diff --git a/lang/en/help/glossary/studentcanpost.html b/lang/en/help/glossary/studentcanpost.html index 6d7af75445..957d3eaf5d 100644 --- a/lang/en/help/glossary/studentcanpost.html +++ b/lang/en/help/glossary/studentcanpost.html @@ -1,4 +1,5 @@

Students can post entries

-

You can specify whether a user can or cannot add, edit or delete his/her own entries in this glossary. -

Note: A teacher can edit or delete any entry at any time. \ No newline at end of file +

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. +

Note: A teacher can edit or delete any entry at any time. This variable is not used if the glossary is the main one. diff --git a/lang/es/glossary.php b/lang/es/glossary.php index 83b3c32f8e..947a4963e7 100644 --- a/lang/es/glossary.php +++ b/lang/es/glossary.php @@ -1,58 +1,58 @@ Todas mostrará todas las entradas en una página."; -$string['explainalphabet'] = "Seleccione la letra inicial que usted desea buscar.

"; -$string['explainspecial'] = "Especial mostrará todos los conceptos que no comienzan con una letra.
"; -$string['exporttomainglossary'] = "Exportar todo el glosario"; +$string['explainspecial'] = "Especial mostrará todos los conceptos que comiencen con símbolos.
"; +$string['explainalphabet'] = "Seleccione la letra que desea buscar.

"; +$string['explainall'] = "TODAS 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"; ?> diff --git a/lang/es/help/glossary/mainglossary.html b/lang/es/help/glossary/mainglossary.html index e0606fbb3d..4b68b18c86 100644 --- a/lang/es/help/glossary/mainglossary.html +++ b/lang/es/help/glossary/mainglossary.html @@ -1,4 +1,5 @@ -

Es este el glosario principal del curso?

- -

El sistema permite exportar definiciones de los glosarios secundarios al glosario principal del sistema. -

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 +

Es este el glosario principal del curso?

+ +

El sistema permite exportar definiciones de los glosarios secundarios al glosario principal del sistema. +

Para hacer esto, usted debe especificar cual de los glosarios es el principal. +

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. diff --git a/lang/es/help/glossary/studentcanpost.html b/lang/es/help/glossary/studentcanpost.html index b913616e99..4cbbe22e65 100644 --- a/lang/es/help/glossary/studentcanpost.html +++ b/lang/es/help/glossary/studentcanpost.html @@ -1,5 +1,7 @@ -

Los estudiantes podrán agregar definiciones?

- -

Indique si desea que los estudiantes puedan o no agregar definiciones al glosario. - -

Si seleccionan que en efecto pueden hacerlo, el sistema le permitirá, además, modificar y eliminar sus propias definiciones. +

Los estudiantes podrán agregar definiciones?

+ +

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. +

Un profesor puede modificar o borrar cualquier entrada. +

Esta variable no tiene efecto si el glosario es principal. + diff --git a/mod/glossary/backuplib.php b/mod/glossary/backuplib.php index 39b7b55fd8..0b0fe07552 100644 --- a/mod/glossary/backuplib.php +++ b/mod/glossary/backuplib.php @@ -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) { @@ -129,6 +129,7 @@ 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)); diff --git a/mod/glossary/db/mysql.php b/mod/glossary/db/mysql.php index 10e386dbd4..2fb33b28b9 100644 --- a/mod/glossary/db/mysql.php +++ b/mod/glossary/db/mysql.php @@ -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; } diff --git a/mod/glossary/db/mysql.sql b/mod/glossary/db/mysql.sql index e6803406de..06e34348fb 100644 --- a/mod/glossary/db/mysql.sql +++ b/mod/glossary/db/mysql.sql @@ -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'; diff --git a/mod/glossary/db/oci8po.sql b/mod/glossary/db/oci8po.sql index 2da8a15d77..b9738b92db 100755 --- a/mod/glossary/db/oci8po.sql +++ b/mod/glossary/db/oci8po.sql @@ -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'); diff --git a/mod/glossary/db/postgres7.sql b/mod/glossary/db/postgres7.sql index 24035e989e..81631aaeee 100644 --- a/mod/glossary/db/postgres7.sql +++ b/mod/glossary/db/postgres7.sql @@ -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) ); diff --git a/mod/glossary/deleteentry.php b/mod/glossary/deleteentry.php index 4d4e334040..ef773ecb7c 100644 --- a/mod/glossary/deleteentry.php +++ b/mod/glossary/deleteentry.php @@ -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"); @@ -47,48 +47,58 @@ /// If data submitted, then process and store. if ($mode == "edit" or $mode == "delete" ) { - echo "

"; - 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 "

$entrydeleted"; //CAMBIAR - echo "
"; - print_simple_box_end(); - } - print_footer($course); - add_to_log($course->id, "glossary", "delete entry", "view.php?id=$cm->id¤tview=$currentview&cat=$cat", $entry); - redirect("view.php?id=$cm->id¤tview=$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 "
$entryfields->concept
$strareyousuredelete"; - - ?> -
- - - - - - > - > - - "> - " onclick="javascript:history.go(-1);"> - -
-
- "; + 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 "
$entrydeleted"; //CAMBIAR + echo "
"; + print_simple_box_end(); + } + print_footer($course); + add_to_log($course->id, "glossary", "delete entry", "view.php?id=$cm->id¤tview=$currentview&cat=$cat", $entry); + redirect("view.php?id=$cm->id¤tview=$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 "
$entryfields->concept
$strareyousuredelete"; + + ?> +
+ + + + + + > + > + + "> + " onclick="javascript:history.go(-1);"> + +
+
+ diff --git a/mod/glossary/edit.html b/mod/glossary/edit.html index 5482caf73c..c173ac0f07 100644 --- a/mod/glossary/edit.html +++ b/mod/glossary/edit.html @@ -1,37 +1,39 @@ -
action="edit.php" enctype="multipart/form-data"> - +
- diff --git a/mod/glossary/edit.php b/mod/glossary/edit.php index 99467bcc7f..63d4ec9a7b 100644 --- a/mod/glossary/edit.php +++ b/mod/glossary/edit.php @@ -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; } diff --git a/mod/glossary/editcategories.html b/mod/glossary/editcategories.html index fdfc0d156e..278776cfd3 100644 --- a/mod/glossary/editcategories.html +++ b/mod/glossary/editcategories.html @@ -1,11 +1,11 @@ - action="editcategories.php"> -

:

- +

:

- id); echo "

:

+

:

- id) { + id) { echo "id\">"; } ?> @@ -83,8 +85,8 @@ - "> - "> + "> + ">

+
diff --git a/mod/glossary/editcategories.php b/mod/glossary/editcategories.php index bf2260e66b..37fda34aec 100644 --- a/mod/glossary/editcategories.php +++ b/mod/glossary/editcategories.php @@ -56,11 +56,11 @@ $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 "

" . get_string("edit"). " " . get_string("category","glossary") . ""; @@ -72,26 +72,26 @@ } 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 "

" . get_string("categorydeleted","glossary") ."
"; - echo ""; - print_simple_box_end(); + print_simple_box_start("center","40%", "#FFBBBB"); + echo "
" . get_string("categorydeleted","glossary") ."
"; + echo ""; + 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 "

" . get_string("delete"). " " . get_string("category","glossary") . ""; - print_simple_box_start("center","40%", "#FFBBBB"); - echo "

$category->name
"; + print_simple_box_start("center","40%", "#FFBBBB"); + echo "
$category->name
"; - $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"); } @@ -109,29 +109,29 @@ ">

:

@@ -17,9 +17,9 @@ - > - "> - " onclick="javascript:history.go(-1);"> + > + "> + " onclick="javascript:history.go(-1);">

- $id); print_single_button("editcategories.php", $options, get_string("no") ); echo "
"; - echo ""; - print_simple_box_end(); + echo ""; + 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 "

" . get_string("add"). " " . get_string("category","glossary") . ""; - print_simple_box_start("center","40%", "#FFBBBB"); - echo "

" . get_string("duplicatedcategory","glossary") ."
"; - echo ""; - print_simple_box_end(); + print_simple_box_start("center","40%", "#FFBBBB"); + echo "
" . get_string("duplicatedcategory","glossary") ."
"; + echo ""; + 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 = ""; @@ -139,11 +139,11 @@ $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 { @@ -154,7 +154,6 @@ } if ( $action ) { - print_footer(); die; } @@ -162,41 +161,41 @@ ?> -

+

action="editcategories.php"> - +
+ + -
- -
+
-id,"name ASC"); if ( $categories ) { foreach ($categories as $category) { $num_entries = count_records("glossary_entries_categories","categoryid",$category->id); ?> - + - @@ -204,8 +203,8 @@ -
- $category->name ($num_entries " . get_string("entries","glossary") . ")"; ?> - id&action=delete&cat=$category->id\">\"" "; echo "id&action=edit&cat=$category->id\">\"""; ?>
- cellheading2)?>"> + id; $options['action'] = "add"; @@ -230,4 +229,4 @@ - + diff --git a/mod/glossary/exportentry.php b/mod/glossary/exportentry.php index 35ea5ad9fe..85d6f8b785 100644 --- a/mod/glossary/exportentry.php +++ b/mod/glossary/exportentry.php @@ -1,4 +1,4 @@ -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 "

$entryexported

"; - if ($newentry->attachment) { - $entry->course = $cm->course; - $newentry->course = $cm->course; - if ( !glossary_copy_attachments($entry, $newentry) ) { - echo "

However, the attachment couldn't be exported."; - } - } - - add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id¤tview=$currentview&cat=$cat&eid=".$entry->id, "$newentry->id"); - - print_continue("view.php?id=$cm->id¤tview=$currentview&cat=$cat&eid=".$entry->id); - print_simple_box_end(); - - print_footer(); - - redirect("view.php?id=$cm->id¤tview=$currentview&cat=$cat&eid=".$entry->id); - die; + print_simple_box_start("center", "60%", "$THEME->cellheading"); + echo "

$entryexported

"; + + 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 "

$entryalreadyexist

"; echo "

"; - print_continue("view.php?id=$cm->id¤tview=$currentview&cat=$cat&eid=".$entry->id); + print_continue("view.php?id=$cm->id&eid=".$entry->id); print_simple_box_end(); } @@ -113,7 +98,7 @@ print_simple_box_start("center", "60%", "#FFBBBB"); echo "

A weird error was found while trying to export this entry. Operation cancelled.

"; - print_continue("view.php?id=$cm->id¤tview=$currentview&cat=$cat&eid=".$entry->id); + print_continue("view.php?id=$cm->id&eid=".$entry->id); print_simple_box_end(); } diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index 11ecadd34a..91f07af166 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -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 "

"; - 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 "id&entry=$entry->id¤tview=$currentview&cat=$cat\">\"" "; + if ( $mainglossary ) { // if there is a main glossary defined, allow to export the current entry + + echo "id&entry=$entry->id¤tview=$currentview&cat=$cat\">\"" "; } } - echo "id&mode=delete&entry=$entry->id¤tview=$currentview&cat=$cat\">\"" "; - echo "id&e=$entry->id¤tview=$currentview&cat=$cat\">\"""; - } + + 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 "id&mode=delete&entry=$entry->id¤tview=$currentview&cat=$cat\">\"" "; + + echo "id&e=$entry->id¤tview=$currentview&cat=$cat\">\"""; + } elseif ( $ImportedEntry ) { + echo "" . get_string("exportedentry","glossary") . ""; + } + } } 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; ?>

- +
"; echo "
-\n"; if ( $row != $CurrentRow ) { for ($col = 0; $col < $TabsPerRow; $col++) { if ( $TabProccessed < $Tabs ) { + if ( $col == 0 ) { + echo ""; + } 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 ""; + } if ($TabProccessed == $CurrentTab) { $CurrentColor = $CurrentTabColor; } else { @@ -607,15 +633,15 @@ for ($row = 0; $row < $NumRows; $row++) { - + -
  


+
-

"; } @@ -722,4 +748,15 @@ global $CFG, $THEME; echo "

"; } + +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 index 0000000000..3561016ec9 Binary files /dev/null and b/mod/glossary/minus.gif differ diff --git a/mod/glossary/mod.html b/mod/glossary/mod.html index 98c9f829d3..951173a9fa 100644 --- a/mod/glossary/mod.html +++ b/mod/glossary/mod.html @@ -5,87 +5,92 @@
- + +course); +if (!$mainglossary or $mainglossary->id == $form->instance ) { +?> - + +"; +} +?> - + -course); -if (!$mainglossary or $mainglossary->id == $form->instance ) { -?> - + -"; -} -?> - + + + + - + - + - +

:

:

- +

:

:

- + - + - +

:

:
+

- + - + - +

:

:

- + - + - +

:


+

:

+

:

:

+

:

:

+

:

:

+
- - - - - - - -"> + + + + + + + +">
diff --git a/mod/glossary/restorelib.php b/mod/glossary/restorelib.php index c1309cb963..ba812beb44 100644 --- a/mod/glossary/restorelib.php +++ b/mod/glossary/restorelib.php @@ -109,15 +109,22 @@ $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 diff --git a/mod/glossary/version.php b/mod/glossary/version.php index 243607b010..75cec4a16d 100644 --- a/mod/glossary/version.php +++ b/mod/glossary/version.php @@ -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 ?> diff --git a/mod/glossary/view.php b/mod/glossary/view.php index 2ab900ec3b..10bf3d280b 100644 --- a/mod/glossary/view.php +++ b/mod/glossary/view.php @@ -72,13 +72,12 @@ $navigation = "id\">$course->shortname ->"; } - $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 id>$strglossaries -> $glossary->name", "", "", true, update_module_button($cm->id, $course->id, $strglossary), navmenu($course, $cm)); @@ -91,11 +90,11 @@ echo "
"; ?>
-
- - +
+ " name="searchbutton"> +
-
"; if (isteacher($course->id) or ($glossary->studentcanpost) and !isguest($course->id)) { $options = array ("id" => "$cm->id"); @@ -116,7 +115,7 @@ } else { $CurrentTab = 0; } - print_tabbed_table_start($data, $CurrentTab, $tCFG); + glossary_print_tabbed_table_start($data, $CurrentTab, $tCFG); echo "
"; if ( $currentview ) { glossary_print_categories_menu($course, $cm, $glossary, $cat, $category); @@ -140,16 +139,26 @@ $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 ) { @@ -261,7 +270,7 @@ } echo "
"; - print_tabbed_table_end(); + glossary_print_tabbed_table_end(); /// Finish the page print_footer($course);