diff --git a/lang/en/glossary.php b/lang/en/glossary.php
index 7d0cf649997..8bf6356ed14 100644
--- a/lang/en/glossary.php
+++ b/lang/en/glossary.php
@@ -59,8 +59,10 @@ $string['explainalphabet'] = "Browse the glossary using this index";
$string['explainall'] = "Shows ALL entries on one page";
$string['exportedentry'] = "Exported entry";
$string['exporttomainglossary'] = "Export to main glossary";
+$string['fillfields'] = "Concept and definition are mandatory fields.";
$string['fullmatch'] = "Match whole words only
(when automatically linked)";
$string['glossarytype'] = "Glossary Type";
+$string['isglobal'] = "Is this glossary global?";
$string['mainglossary'] = "Main glossary";
$string['modulename'] = "Glossary";
$string['modulenameplural'] = "Glossaries";
diff --git a/mod/glossary/db/mysql.php b/mod/glossary/db/mysql.php
index 20b5483844f..e996b6ba9bc 100644
--- a/mod/glossary/db/mysql.php
+++ b/mod/glossary/db/mysql.php
@@ -118,6 +118,11 @@ function glossary_upgrade($oldversion) {
execute_sql(" INSERT INTO {$CFG->prefix}log_display VALUES ('glossary', 'approve entry', 'glossary', 'name') ");
}
+
+ if ( $oldversion < 2003102800 ) {
+ execute_sql( "ALTER TABLE `{$CFG->prefix}glossary`" .
+ " ADD `globalglossary` TINYINT(2) UNSIGNED NOT NULL default '0' AFTER `defaultapproval`");
+ }
return true;
}
diff --git a/mod/glossary/db/mysql.sql b/mod/glossary/db/mysql.sql
index 99276273fd7..1c19299bcb5 100644
--- a/mod/glossary/db/mysql.sql
+++ b/mod/glossary/db/mysql.sql
@@ -23,6 +23,7 @@ CREATE TABLE prefix_glossary (
allowcomments tinyint(2) unsigned NOT NULL default '0',
usedynalink tinyint(2) unsigned NOT NULL default '1',
defaultapproval tinyint(2) unsigned NOT NULL default '1',
+ globalglossary tinyint(2) unsigned NOT NULL default '0',
timecreated int(10) unsigned NOT NULL default '0',
timemodified int(10) unsigned NOT NULL default '0',
PRIMARY KEY (id)
diff --git a/mod/glossary/db/postgres7.sql b/mod/glossary/db/postgres7.sql
index 0f45bdd21c7..cf6cfd2072f 100644
--- a/mod/glossary/db/postgres7.sql
+++ b/mod/glossary/db/postgres7.sql
@@ -22,6 +22,7 @@ CREATE TABLE prefix_glossary (
showall int2 NOT NULL default '1',
allowcomments int2 NOT NULL default '0',
usedynalink int2 NOT NULL default '1',
+ globalglossary int2 NOT NULL default '0',
timecreated int4 NOT NULL default '0',
timemodified int4 NOT NULL default '0',
PRIMARY KEY (id)
diff --git a/mod/glossary/dynalink.php b/mod/glossary/dynalink.php
index 21504fbc2b2..7762b41ee09 100644
--- a/mod/glossary/dynalink.php
+++ b/mod/glossary/dynalink.php
@@ -12,14 +12,14 @@
$GLOSSARY_CONCEPT_IS_ENTRY = 0;
$GLOSSARY_CONCEPT_IS_CATEGORY = 1;
- $glossarieslist = get_records_select("glossary", "usedynalink != 0 and course = $courseid","id");
+// $glossarieslist = get_records_select("glossary", "usedynalink != 0 and (course = $courseid or global != 0)","id");
+ $glossarieslist = get_records_select("glossary", "usedynalink != 0 and (course = $courseid or globalglossary != 0)","globalglossary, id");
if ( $glossarieslist ) {
$glossaries = "";
foreach ( $glossarieslist as $glossary ) {
$glossaries .= "$glossary->id,";
}
$glossaries=substr($glossaries,0,-1);
-
/// sorting by the lenght of the concept in order to assure that large concepts
/// could be linked first, if they exist in the text to parse
switch ($CFG->dbtype) {
@@ -34,7 +34,7 @@
break;
}
- $entries = get_records_select("glossary_entries", "glossaryid IN ($glossaries) AND usedynalink != 0 and approved != 0","$ebylenght glossaryid","id,glossaryid,concept,casesensitive,$GLOSSARY_CONCEPT_IS_ENTRY category,fullmatch");
+ $entries = get_records_select("glossary_entries", "glossaryid IN ($glossaries) AND usedynalink != 0 and approved != 0 and concept != ''","$ebylenght glossaryid","id,glossaryid,concept,casesensitive,$GLOSSARY_CONCEPT_IS_ENTRY category,fullmatch");
$categories = get_records_select("glossary_categories", "glossaryid IN ($glossaries)", "$cbylenght glossaryid,id","id,glossaryid,name concept, 1 casesensitive,$GLOSSARY_CONCEPT_IS_CATEGORY category, 1 fullmatch");
if ( $entries and $categories ) {
$concepts = array_merge($entries, $categories);
@@ -53,7 +53,6 @@
$glossary = get_record("glossary","id",$concept->glossaryid);
$lastglossary = $glossary->id;
}
-
if ( $concept->category ) {
if ( $lastcategory != $concept->id ) {
$category = get_record("glossary_categories","id",$concept->id);
@@ -128,9 +127,9 @@
}
// getting ride of all other tags
$final = array();
- preg_match_all('/<(.+?)>/is',$text,$list_of_words);
+ preg_match_all('/<(.+?)>/is',$text,$list_of_tags);
- foreach (array_unique($list_of_words[0]) as $key=>$value) {
+ foreach (array_unique($list_of_tags[0]) as $key=>$value) {
$final['<|'.$key.'|>'] = $value;
}
@@ -149,9 +148,11 @@
if ( $excludes ) {
$text = str_replace(array_keys($excludes),$excludes,$text);
}
- if ( isset($words) and $fullmatch ) {
- if ($words) {
- $text = str_replace(array_keys($words),$words,$text);
+ if ( $fullmatch ) {
+ if ( isset($words) ) {
+ if ($words) {
+ $text = str_replace(array_keys($words),$words,$text);
+ }
}
}
return stripslashes($text);
diff --git a/mod/glossary/edit.html b/mod/glossary/edit.html
index a2b17d7b465..86f381042b6 100644
--- a/mod/glossary/edit.html
+++ b/mod/glossary/edit.html
@@ -1,6 +1,16 @@