diff --git a/lang/en/glossary.php b/lang/en/glossary.php index 5a818631a1a..10130e3da49 100644 --- a/lang/en/glossary.php +++ b/lang/en/glossary.php @@ -3,21 +3,31 @@ $string['addentry'] = "Add entry"; $string['allentries'] = "ALL"; +$string['allcategories'] = "All Categories"; $string['allowduplicatedentries'] = "Duplicated entries allowed"; $string['alphabet'] = "A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z"; -$string['areyousuredelete'] = "Are you sure you want to delete this entry?"; +$string['areyousuredelete'] = "Are you sure you want to delete it?"; $string['attachment'] = "Attachment"; -$string['categoryview'] = "By Category"; +$string['back'] = "Back"; +$string['categories'] = "Categories"; +$string['categoryview'] = "By category"; +$string['category'] = "Category"; +$string['categorydeleted'] = "Category deleted"; $string['concept'] = "Concept"; $string['concepts'] = "Concepts"; $string['definition'] = "Definition"; $string['definitions'] = "Definitions"; $string['deleteentry'] = "Delete entry"; +$string['deletingnoneemptycategory'] = "If a non empty category is deleted, its relations with their entries will also be deleted. If you wish to delete the entries, you will have to do so manually."; $string['displayformat'] = "Display format"; $string['displayformatdefault'] = "Simple, dictionary style"; $string['displayformat1'] = "Full without author."; $string['displayformat2'] = "Full with author."; +$string['entries'] = "Entries"; +$string['entrieswithoutcategory'] = "Entries without category"; +$string['entry'] = "Entry"; $string['editentry'] = "Edit entry"; +$string['editcategories'] = "Edit categories"; $string['entryalreadyexist'] = "Entry already exist."; $string['entrydeleted'] = "Entry deleted."; $string['entryexported'] = "Entry succesfully exported."; @@ -27,6 +37,7 @@ $string['mainglossary'] = "Main glossary"; $string['modulename'] = "Glossary"; $string['modulenameplural'] = "Glossaries"; $string['newglossaryentries'] = "New glossary entries:"; +$string['nocategorized'] = "No categorized"; $string['noentries'] = "No entries found in this section"; $string['noentry'] = "No entry found."; $string['searchconcept'] = "Search:"; diff --git a/lang/es/glossary.php b/lang/es/glossary.php index 26c9fed9835..81ca2d6b1d6 100644 --- a/lang/es/glossary.php +++ b/lang/es/glossary.php @@ -3,21 +3,31 @@ $string['addentry'] = "Agregar entrada"; $string['allentries'] = "TODAS"; +$string['allcategories'] = "Todas las categorías"; $string['allowduplicatedentries'] = "Permitir entradas duplicadas"; $string['alphabet'] = "A|B|C|D|E|F|G|H|I|J|K|L|M|N|Ñ|O|P|Q|R|S|T|U|V|W|X|Y|Z"; -$string['areyousuredelete'] = "¿Está seguro que desea borrar esta entrada?"; +$string['areyousuredelete'] = "¿Está seguro que desea borrarla?"; $string['attachment'] = "Adjunto"; +$string['back'] = "Volver"; +$string['categories'] = "Categorías"; $string['categoryview'] = "Vista por Categoría"; +$string['category'] = "Categoría"; +$string['categorydeleted'] = "Categoría eliminada"; $string['concept'] = "Concepto"; $string['concepts'] = "Conceptos"; $string['definition'] = "Definición"; $string['definitions'] = "Definiciones"; $string['deleteentry'] = "Borrar entrada"; +$string['deletingnoneemptycategory'] = "Si una categoría es eliminada por consiguiente su relación con las entradas también lo será. Si desea eliminar las entradas, tendrá que hacerlo manualmente."; $string['displayformat'] = "Formato de muestra de entradas"; $string['displayformatdefault'] = "Simple, estilo diccionario"; $string['displayformat1'] = "Completo sin autor."; $string['displayformat2'] = "Completo con autor."; $string['editentry'] = "Editar entrada"; +$string['editcategories'] = "Editar categorías"; +$string['entries'] = "Entradas"; +$string['entrieswithoutcategory'] = "Entradas sin categoría"; +$string['entry'] = "Entrada"; $string['entryalreadyexist'] = "Esta entrada ya existe."; $string['entrydeleted'] = "Entrada borrada."; $string['entryexported'] = "Entrada exportada con éxito."; @@ -27,6 +37,7 @@ $string['mainglossary'] = "Glosario principal"; $string['modulename'] = "Glosario"; $string['modulenameplural'] = "Glosarios"; $string['newglossaryentries'] = "Nuevas entradas en el glosario:"; +$string['nocategorized'] = "Sin categoría"; $string['noentries'] = "No se encontraro entradas en esta sección"; $string['noentry'] = "No se econtró ninguna entrada."; $string['searchconcept'] = "Buscar:"; diff --git a/mod/glossary/db/mysql.php b/mod/glossary/db/mysql.php index f80af4a5d39..2fcaae6ba7f 100644 --- a/mod/glossary/db/mysql.php +++ b/mod/glossary/db/mysql.php @@ -49,18 +49,10 @@ function glossary_upgrade($oldversion) { `entryid` INT(10) UNSIGNED NOT NULL default '0', PRIMARY KEY (`categoryid`, `entryid`) ) TYPE=MyISAM COMMENT='categories of each glossary entry'"); - - // creating a default category for every glossary - execute_sql("INSERT INTO `{$CFG->prefix}glossary_categories` (`glossaryid`, `name`) - SELECT `id`, '" . get_string("main","glossary") . "' FROM `{$CFG->prefix}glossary`"); - - - // setting the default category for every entry. - execute_sql("INSERT INTO `{$CFG->prefix}glossary_entries_categories` (`categoryid`, `entryid`) - SELECT c.id, e.id - FROM `{$CFG->prefix}glossary_entries` e, `{$CFG->prefix}glossary_categories` c - WHERE e.glossaryid = c.glossaryid"); - + } + + if ( $oldversion < 2003092100 ) { + execute_sql("ALTER TABLE `{$CFG->prefix}glossary_entries_categories` CHANGE `categoryid` `categoryid` INT( 10 ) UNSIGNED DEFAULT '0' NOT NULL "); } return true; diff --git a/mod/glossary/db/mysql.sql b/mod/glossary/db/mysql.sql index 9c8cc9ea273..c72df48210d 100644 --- a/mod/glossary/db/mysql.sql +++ b/mod/glossary/db/mysql.sql @@ -58,7 +58,7 @@ CREATE TABLE prefix_glossary_categories ( # CREATE TABLE prefix_glossary_entries_categories ( - categoryid int(10) unsigned NOT NULL default '1', + categoryid int(10) unsigned NOT NULL default '0', entryid int(10) unsigned NOT NULL default '0', PRIMARY KEY (categoryid, entryid) ) TYPE=MyISAM COMMENT='categories of each glossary entry'; diff --git a/mod/glossary/db/postgres7.php b/mod/glossary/db/postgres7.php new file mode 100644 index 00000000000..1ede63bea4a --- /dev/null +++ b/mod/glossary/db/postgres7.php @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/mod/glossary/db/postgres7.sql b/mod/glossary/db/postgres7.sql new file mode 100644 index 00000000000..92fc5cf5c7e --- /dev/null +++ b/mod/glossary/db/postgres7.sql @@ -0,0 +1,79 @@ +# This file contains a complete database schema for all the +# tables used by this module, written in SQL + +# It may also contain INSERT statements for particular data +# that may be used, especially new entries in the table log_display + +# +# Table structure for table `glossary` +# + +CREATE TABLE prefix_glossary ( + id SERIAL, + course int4 NOT NULL default '0', + name varchar(255) NOT NULL default '', + studentcanpost int2 NOT NULL default '0', + allowduplicatedentries int2 NOT NULL default '0', + displayformat int2 NOT NULL default '0', + mainglossary int2 NOT NULL default '0', + showspecial int2 NOT NULL default '1', + showalphabet int2 NOT NULL default '1', + showall int2 NOT NULL default '1', + timecreated int4 NOT NULL default '0', + timemodified int4 NOT NULL default '0', + PRIMARY KEY (id) +); + +# +# Table structure for table `glossary_entries` +# + +CREATE TABLE prefix_glossary_entries ( + id SERIAL, + glossaryid int4 NOT NULL default '0', + userid int4 NOT NULL default '0', + concept varchar(255) NOT NULL default '', + definition text NOT NULL, + format int2 NOT NULL default '0', + attachment VARCHAR(100) NOT NULL default '', + timecreated int4 NOT NULL default '0', + timemodified int4 NOT NULL default '0', + teacherentry int2 NOT NULL default '0', + PRIMARY KEY(id) +); + +# +# Table structure for table `glossary_cageories` +# + +CREATE TABLE prefix_glossary_categories ( + id SERIAL, + glossaryid int4 NOT NULL default '0', + name varchar(255) NOT NULL default '', + PRIMARY KEY (id) +); + +# +# Table structure for table `glossary_entries_category` +# + +CREATE TABLE prefix_glossary_entries_categories ( + categoryid int4 NOT NULL default '0', + entryid int4 NOT NULL default '0', + PRIMARY KEY (categoryid, entryid) +); + +# +# Dumping data for table `log_display` +# + +INSERT INTO prefix_log_display VALUES ('glossary', 'add', 'glossary', 'name'); +INSERT INTO prefix_log_display VALUES ('glossary', 'update', 'glossary', 'name'); +INSERT INTO prefix_log_display VALUES ('glossary', 'view', 'glossary', 'name'); +INSERT INTO prefix_log_display VALUES ('glossary', 'view all', 'glossary', 'name'); +INSERT INTO prefix_log_display VALUES ('glossary', 'add entry', 'glossary', 'name'); +INSERT INTO prefix_log_display VALUES ('glossary', 'update entry', 'glossary', 'name'); +INSERT INTO prefix_log_display VALUES ('glossary', 'add category', 'glossary', 'name'); +INSERT INTO prefix_log_display VALUES ('glossary', 'update category', 'glossary', 'name'); +INSERT INTO prefix_log_display VALUES ('glossary', 'delete category', 'glossary', 'name'); + diff --git a/mod/glossary/deleteentry.html b/mod/glossary/deleteentry.html index 3b77ab110a6..e7721b139ac 100644 --- a/mod/glossary/deleteentry.html +++ b/mod/glossary/deleteentry.html @@ -4,6 +4,8 @@ + + "> " onclick="javascript:history.go(-1);"> diff --git a/mod/glossary/deleteentry.php b/mod/glossary/deleteentry.php index 7f5be1af6fe..43082b14299 100644 --- a/mod/glossary/deleteentry.php +++ b/mod/glossary/deleteentry.php @@ -50,24 +50,38 @@ 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 "
:
echo get_string("definition","glossary") ?>:
@@ -37,9 +62,6 @@ $form->format = $defaultformat; } choose_from_menu(format_text_menu(), "format", $entry->format, ""); - if ($entry->id) { - echo "id\">"; - } echo ""; ?>+ if ($entry->id) { + echo "id\">"; + } + ?> + + + "> ">
diff --git a/mod/glossary/edit.php b/mod/glossary/edit.php index 969e7c9c844..74578c0c7a5 100644 --- a/mod/glossary/edit.php +++ b/mod/glossary/edit.php @@ -7,6 +7,9 @@ require_once("lib.php"); require_variable($id); // Course Module ID optional_variable($e); // EntryID +optional_variable($currentview); // categories if by category? +optional_variable($cat); // CategoryID + if (! $cm = get_record("course_modules", "id", $id)) { error("Course Module ID was incorrect"); } @@ -110,14 +113,23 @@ if ($e) { } set_field("glossary_entries", "attachment", $newfilename, "id", $newentry->id); - add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id&eid=$newentry->id", "$newentry->id"); + add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id&eid=$newentry->id¤tview=$currentview&cat=$cat", "$newentry->id"); } } else { error("Could not insert this glossary entry because this concept already exist."); } } - redirect("view.php?id=$cm->id&eid=$newentry->id"); + delete_records("glossary_entries_categories","entryid",$entry); + + if ( $categories ) { + $newcategory->entryid = $newentry->id; + foreach ($categories as $category) { + $newcategory->categoryid =$category; + insert_record("glossary_entries_categories",$newcategory); + } + } + redirect("view.php?id=$cm->id&eid=$newentry->id¤tview=$currentview&cat=$cat"); die; } } diff --git a/mod/glossary/editcategories.html b/mod/glossary/editcategories.html new file mode 100644 index 00000000000..fdfc0d156eb --- /dev/null +++ b/mod/glossary/editcategories.html @@ -0,0 +1,30 @@ + + global $CFG, $THEME; + require_once("../../config.php"); + +?> + + diff --git a/mod/glossary/editcategories.php b/mod/glossary/editcategories.php new file mode 100644 index 00000000000..bf2260e66b3 --- /dev/null +++ b/mod/glossary/editcategories.php @@ -0,0 +1,233 @@ +course)) { + error("Course is misconfigured"); + } + + if (! $glossary = get_record("glossary", "id", $cm->instance)) { + error("Course module is incorrect"); + } + + require_login($course->id); + + if ( !isteacher($course->id) ) { + error("You must be a teacher to use this page."); + } + +// add_to_log($course->id, "glossary", "edit categories", "view.php?id=$cm->id", "$glossary->id"); + + if ($course->category) { + $navigation = "id\">$course->shortname ->"; + } + + $strglossaries = get_string("modulenameplural", "glossary"); + $strglossary = get_string("modulename", "glossary"); + + print_header("$course->shortname: $glossary->name", "$course->fullname", + "$navigation id>$strglossaries -> $glossary->name", + "", "", true, update_module_button($cm->id, $course->id, $strglossary), + navmenu($course, $cm)); + + if ( $cat ) { + $category = get_record("glossary_categories","id",$cat); + + if ( $action == "edit" ) { + if ( $confirm ) { + $action = ""; + $CategoryObject->id = $cat; + $CategoryObject->name = $name; + + if ( !update_record("glossary_categories", $CategoryObject) ) { + error("Weird error. The category was not updated."); + + redirect("editcategories.php?id=$cm->id"); + } + + } else { + echo "" . get_string("edit"). " " . get_string("category","glossary") . ""; + + $name = $category->name; + require "editcategories.html"; + print_footer(); + die; + } + } elseif ( $action == "delete" ) { + if ( $confirm ) { + + delete_records("glossary_entries_categories","categoryid", $cat); + delete_records("glossary_categories","id", $cat); + + print_simple_box_start("center","40%", "#FFBBBB"); + echo "
" . get_string("delete"). " " . get_string("category","glossary") . ""; + + print_simple_box_start("center","40%", "#FFBBBB"); + echo "
"; + print_string("areyousuredelete","glossary"); + + ?> +
" . get_string("add"). " " . get_string("category","glossary") . ""; + + print_simple_box_start("center","40%", "#FFBBBB"); + echo "
" . get_string("add"). " " . get_string("category","glossary") . "";
+ $name="";
+ require "editcategories.html";
+ }
+ }
+
+ if ( $action ) {
+
+ print_footer();
+ die;
+ }
+
+?>
+
+
+ p(get_string("edit")) ?> p(get_string("categories","glossary")) ?>
+
+
Seguro que desea agregar esta entrada a
$mainglossary->name?",
- "exportentry.php?id=$id&entry=$entry->id&confirm=1",
- "view.php?id=$cm->id&eid=".$entry->id );
+ "exportentry.php?id=$id¤tview=$currentview&cat=$cat&entry=$entry->id&confirm=1",
+ "view.php?id=$cm->id¤tview=$currentview&cat=$cat&eid=".$entry->id );
} else {
if ( ! $mainglossary->allowduplicatedentries ) {
@@ -86,15 +89,14 @@
}
}
- add_to_log($course->id, "glossary", "add entry",
- "view.php?id=$cm->id&eid=".$entry->id, "$newentry->id");
+ add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id¤tview=$currentview&cat=$cat&eid=".$entry->id, "$newentry->id");
- print_continue("view.php?id=$cm->id&eid=".$entry->id);
+ print_continue("view.php?id=$cm->id¤tview=$currentview&cat=$cat&eid=".$entry->id);
print_simple_box_end();
print_footer();
- redirect("view.php?id=$cm->id&eid=".$entry->id);
+ redirect("view.php?id=$cm->id¤tview=$currentview&cat=$cat&eid=".$entry->id);
die;
}
} else {
@@ -102,7 +104,7 @@
echo "
$entryalreadyexist
"; echo ""; - print_continue("view.php?id=$cm->id&eid=".$entry->id); + print_continue("view.php?id=$cm->id¤tview=$currentview&cat=$cat&eid=".$entry->id); print_simple_box_end(); } @@ -111,7 +113,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&eid=".$entry->id); + print_continue("view.php?id=$cm->id¤tview=$currentview&cat=$cat&eid=".$entry->id); print_simple_box_end(); } diff --git a/mod/glossary/formats/1.php b/mod/glossary/formats/1.php index 2dc657689bb..25efe73f463 100644 --- a/mod/glossary/formats/1.php +++ b/mod/glossary/formats/1.php @@ -1,6 +1,6 @@ timemarked < $entry->modified) { @@ -30,7 +30,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry) { if ($entry) { echo format_text($entry->definition, $entry->format); - glossary_print_entry_icons($course, $cm, $glossary, $entry); + glossary_print_entry_icons($course, $cm, $glossary, $entry,$currentview,$cat); } else { echo ""; } +function glossary_print_alphabet_menu($cm, $glossary, $l) { +global $CFG, $THEME; + $strselectletter = get_string("selectletter", "glossary"); + $strspecial = get_string("special", "glossary"); + $strallentries = get_string("allentries", "glossary"); + + echo "
$strspecial | "; + } else { + echo "
wwwroot/mod/glossary/view.php?id=$cm->id&l=SPECIAL\">$strspecial | ";
+ }
+ }
+
+ if ( $glossary->showalphabet ) {
+ $alphabet = explode("|", get_string("alphabet","glossary"));
+ $letters_by_line = 14;
+ for ($i = 0; $i < count($alphabet); $i++) {
+ if ( $l == $alphabet[$i] ) {
+ echo "$alphabet[$i]";
+ } else {
+ echo "wwwroot/mod/glossary/view.php?id=$cm->id&l=$alphabet[$i]\">$alphabet[$i]";
+ }
+ if ((int) ($i % $letters_by_line) != 0 or $i == 0) {
+ echo " | ";
+ } else {
+ echo "
";
+ }
+ }
+ }
+
+ if ( $glossary->showall ) {
+ if ( $l == "ALL" ) {
+ echo "$strallentries
"; + if ( isteacher($course->id) ) { + $options['id'] = $cm->id; + $options['cat'] = $cat; + echo print_single_button("editcategories.php", $options, get_string("editcategories","glossary"), "get"); + } + echo " | "; + + echo ""; + echo ""; + if ( $category ) { + echo $category->name; + } else { + echo get_string("entrieswithoutcategory","glossary"); + } + echo " | "; + echo ""; + $menu[0] = get_string("nocategorized","glossary"); + + $categories = get_records("glossary_categories", "glossaryid", $glossary->id, "name ASC"); + if ( $categories ) { + foreach ($categories as $currentcategory) { + $url = $currentcategory->id; + if ($currentcategory->id == $category->id) { + $selected = $url; + } + $menu[$url] = $currentcategory->name; + } + } + + echo popup_form("$CFG->wwwroot/mod/glossary/view.php?id=$cm->id¤tview=categories&cat=", $menu, "catmenu", $selected, get_string("jumpto"), + "", "", false); + + echo " | "; + echo "
" ; - if ( !$course->visible ) { - notice(get_string("activityiscurrentlyhidden")); - } - print_simple_box_start("center", "70%"); - echo "
wwwroot/mod/glossary/view.php?id=$id&l=SPECIAL\">$strspecial | ";
- }
-
- if ( $glossary->showalphabet ) {
- $alphabet = explode("|", get_string("alphabet","glossary"));
- $letters_by_line = 14;
- for ($i = 0; $i < count($alphabet); $i++) {
- echo "wwwroot/mod/glossary/view.php?id=$id&l=$alphabet[$i]\">$alphabet[$i]";
- if ((int) ($i % $letters_by_line) != 0 or $i == 0) {
- echo " | ";
- } else {
- echo "
";
- }
+ echo "
"; + ?> + + + echo " | ";
+ if (isteacher($course->id) or $glossary->studentcanpost) {
+ $options = array ("id" => "$cm->id");
+ print_single_button("edit.php", $options, $straddentry );
}
- }
-
- if ( $glossary->showall ) {
- echo "wwwroot/mod/glossary/view.php?id=$id&l=ALL\">$strallentries";
- }
-
- if (isteacher($course->id) or $glossary->studentcanpost) {
- $options = array ("id" => "$cm->id");
- echo " |
"; - if ($l) { - $CurrentLetter = ""; - if ($l == "ALL" or $l == "SPECIAL") { - if ( $l == "ALL" ) { - echo "
"; - } elseif ($l == "SPECIAL") { - echo "
"; - } - } - } elseif( $search ) { - echo get_string("search") . ": $search"; - } - - $data[0]->link = "view.php?id=$id&l=$l&eid=$eid&search=$search&includedefinition=$includedefinition"; + $data[0]->link = "view.php?id=$id"; $data[0]->caption = get_string("standardview","glossary"); - $data[1]->link = "view.php?id=$id&l=$l&eid=$eid&search=$search&includedefinition=$includedefinition¤tview=categories&cat=$cat"; + $data[1]->link = "view.php?id=$id¤tview=categories"; $data[1]->caption = get_string("categoryview","glossary"); - - $tCFG->TabTableBGColor = $THEME->cellcontent2; - $tCFG->TabTableWidth = "70%"; - $tCFG->ActiveTabColor = $THEME->cellcontent2; - $tCFG->InactiveTabColor = $THEME->cellheading2; - $tCFG->TabsPerRow = 5; - $tCFG->TabSeparation = 4; - - if ( $cat ) { + + if ( $currentview ) { $CurrentTab = 1; } else { $CurrentTab = 0; } print_tabbed_table_start($data, $CurrentTab, $tCFG); echo "
cellheading2\">"; } - echo "$CurrentLetter"; + if ( $l == "ALL" ) { + echo "$CurrentLetter"; + } if ( $glossary->displayformat == 0 ) { echo "\n |
";