Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

- Global glossaries now available. All current rules apply to its ent…

…ries.
  • Loading branch information...
commit 0de786f7da671e489587f9d660acead98ef3e1bd 1 parent 68e16a6
authored October 29, 2003
2  lang/en/glossary.php
@@ -59,8 +59,10 @@
59 59
 $string['explainall'] = "Shows ALL entries on one page";
60 60
 $string['exportedentry'] = "Exported entry";
61 61
 $string['exporttomainglossary'] = "Export to main glossary";
  62
+$string['fillfields'] = "Concept and definition are mandatory fields.";
62 63
 $string['fullmatch'] = "Match whole words only<br><small>(when automatically linked)</small>";
63 64
 $string['glossarytype'] = "Glossary Type";
  65
+$string['isglobal'] = "Is this glossary global?";
64 66
 $string['mainglossary'] = "Main glossary";
65 67
 $string['modulename'] = "Glossary";
66 68
 $string['modulenameplural'] = "Glossaries";
5  mod/glossary/db/mysql.php
@@ -118,6 +118,11 @@ function glossary_upgrade($oldversion) {
118 118
 
119 119
         execute_sql(" INSERT INTO {$CFG->prefix}log_display VALUES ('glossary', 'approve entry', 'glossary', 'name') ");
120 120
     }
  121
+
  122
+    if ( $oldversion < 2003102800 ) {
  123
+        execute_sql( "ALTER TABLE `{$CFG->prefix}glossary`" .
  124
+                     " ADD `globalglossary` TINYINT(2) UNSIGNED NOT NULL default '0' AFTER `defaultapproval`");
  125
+    }
121 126
     return true;
122 127
 }
123 128
 
1  mod/glossary/db/mysql.sql
@@ -23,6 +23,7 @@ CREATE TABLE prefix_glossary (
23 23
      allowcomments tinyint(2) unsigned NOT NULL default '0',
24 24
      usedynalink tinyint(2) unsigned NOT NULL default '1',
25 25
      defaultapproval tinyint(2) unsigned NOT NULL default '1',
  26
+     globalglossary tinyint(2) unsigned NOT NULL default '0',
26 27
      timecreated int(10) unsigned NOT NULL default '0',
27 28
      timemodified int(10) unsigned NOT NULL default '0',
28 29
      PRIMARY KEY  (id)
1  mod/glossary/db/postgres7.sql
@@ -22,6 +22,7 @@ CREATE TABLE prefix_glossary (
22 22
      showall int2 NOT NULL default '1',
23 23
      allowcomments int2 NOT NULL default '0',
24 24
      usedynalink int2 NOT NULL default '1',
  25
+     globalglossary int2 NOT NULL default '0',
25 26
      timecreated int4 NOT NULL default '0',
26 27
      timemodified int4 NOT NULL default '0',
27 28
      PRIMARY KEY  (id)
19  mod/glossary/dynalink.php
@@ -12,14 +12,14 @@ function glossary_dynamic_link($courseid, $text) {
@@ -34,7 +34,7 @@ function glossary_dynamic_link($courseid, $text) {
@@ -53,7 +53,6 @@ function glossary_dynamic_link($courseid, $text) {
@@ -128,9 +127,9 @@ function glossary_link_concepts($text,$concept,$href_tag_begin,$href_tag_end = "
@@ -149,9 +148,11 @@ function glossary_link_concepts($text,$concept,$href_tag_begin,$href_tag_end = "
10  mod/glossary/edit.html
... ...
@@ -1,6 +1,16 @@
1 1
 <center>
2 2
 <form name="form" method="post" <?=$onsubmit ?> action="edit.php" enctype="multipart/form-data">
3 3
 <table  class=generalbox cellpadding=5 bgcolor="<?php p($THEME->cellheading)?>">
  4
+<?PHP
  5
+if (isset($errors)) {
  6
+?>
  7
+    <tr valign=top>
  8
+        <td colspan=2 align=center><strong><font color=red><?PHP p($errors) ?></font></strong>
  9
+        </td>
  10
+    </tr>
  11
+<?PHP
  12
+}
  13
+?>
4 14
 <tr valign=top>
5 15
     <td align=right><p><b><?php echo get_string("concept","glossary") ?>:</b></p></td>
6 16
     <td>
36  mod/glossary/edit.php
@@ -21,7 +21,7 @@
21 21
 
22 22
 require_login($course->id);
23 23
 
24  
-if (isguest()) {
  24
+if ( isguest() ) {
25 25
     error("Guests are not allowed to edit glossaries", $_SERVER["HTTP_REFERER"]);
26 26
 }
27 27
 
@@ -47,6 +47,34 @@
47 47
     $newentry->fullmatch = $form->fullmatch;
48 48
     $newentry->timemodified = $timenow;		
49 49
 
  50
+    if ($form->concept == '' or trim($form->text) == '' ) {
  51
+        $errors = get_string('fillfields','glossary');
  52
+        $strglossary = get_string("modulename", "glossary");
  53
+        $strglossaries = get_string("modulenameplural", "glossary");
  54
+        $stredit = get_string("edit");
  55
+
  56
+        if ($usehtmleditor = can_use_richtext_editor()) {
  57
+            $defaultformat = FORMAT_HTML;
  58
+            $onsubmit = "onsubmit=\"copyrichtext(form.text);\"";
  59
+        } else {
  60
+            $defaultformat = FORMAT_MOODLE;
  61
+            $onsubmit = "";
  62
+        }
  63
+
  64
+        print_header(strip_tags("$course->shortname: $glossary->name"), "$course->fullname",
  65
+             "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> -> 
  66
+              <A HREF=\"index.php?id=$course->id\">$strglossaries</A> -> 
  67
+              <A HREF=\"view.php?id=$cm->id\">$glossary->name</A> -> $stredit", "form.text",
  68
+              "", true, "", navmenu($course, $cm));
  69
+
  70
+        print_heading($glossary->name);
  71
+
  72
+        include("edit.html");
  73
+
  74
+        print_footer($course);
  75
+        die;
  76
+    }
  77
+
50 78
     if ($e) {
51 79
         $newentry->id = $e;
52 80
     
@@ -123,7 +151,7 @@
123 151
             }
124 152
         }
125 153
     }
126  
-    redirect("view.php?id=$cm->id&eid=$newentry->id");
  154
+    redirect("view.php?id=$cm->id&eid=$newentry->id&tab=$tab&cat=$cat");
127 155
     die;
128 156
 } else {
129 157
     if ($e) {
@@ -154,7 +182,7 @@
154 182
 
155 183
 if ($usehtmleditor = can_use_richtext_editor()) {
156 184
     $defaultformat = FORMAT_HTML;
157  
-    $onsubmit = "onsubmit=\"copyrichtext(theform.text);\"";
  185
+    $onsubmit = "onsubmit=\"copyrichtext(form.text);\"";
158 186
 } else {
159 187
     $defaultformat = FORMAT_MOODLE;
160 188
     $onsubmit = "";
@@ -163,7 +191,7 @@
163 191
 print_header(strip_tags("$course->shortname: $glossary->name"), "$course->fullname",
164 192
              "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> -> 
165 193
               <A HREF=\"index.php?id=$course->id\">$strglossaries</A> -> 
166  
-              <A HREF=\"view.php?id=$cm->id\">$glossary->name</A> -> $stredit", "theform.text",
  194
+              <A HREF=\"view.php?id=$cm->id\">$glossary->name</A> -> $stredit", "form.text",
167 195
               "", true, "", navmenu($course, $cm));
168 196
 
169 197
 print_heading($glossary->name);
12  mod/glossary/lib.php
@@ -22,6 +22,12 @@ function glossary_add_instance($glossary) {
22 22
 /// will create a new instance and return the id number
23 23
 /// of the new instance.
24 24
 
  25
+    if ( !isset($glossary->globalglossary) ) {
  26
+        $glossary->globalglossary = 0;
  27
+    } elseif ( !isadmin() ) {
  28
+        $glossary->globalglossary = 0;
  29
+    }
  30
+
25 31
     $glossary->timecreated = time();
26 32
     $glossary->timemodified = $glossary->timecreated;
27 33
 
@@ -36,6 +42,10 @@ function glossary_update_instance($glossary) {
36 42
 /// (defined by the form in mod.html) this function
37 43
 /// will update an existing instance with new data.
38 44
 
  45
+    if ( !isadmin() ) {
  46
+        unset($glossary->globalglossary);
  47
+    }
  48
+
39 49
     $glossary->timemodified = time();
40 50
     $glossary->id = $glossary->instance;
41 51
 
@@ -1022,7 +1032,7 @@ function glossary_print_dynaentry($courseid, $entries) {
1022 1032
             if (! $course = get_record("course", "id", $glossary->course)) {
1023 1033
                 error("Glossary is misconfigured - don't know what course it's from");
1024 1034
             }
1025  
-            if (!$cm = get_coursemodule_from_instance("glossary", $entry->glossaryid, $courseid) ) {
  1035
+            if (!$cm = get_coursemodule_from_instance("glossary", $entry->glossaryid, $glossary->course) ) {
1026 1036
                 error("Glossary is misconfigured - don't know what course module it is ");
1027 1037
             }
1028 1038
             glossary_print_entry($course, $cm, $glossary, $entry);
28  mod/glossary/mod.html
@@ -38,6 +38,9 @@
38 38
 if (!isset($form->usedynalink)) {
39 39
     $form->usedynalink = 1;
40 40
 }
  41
+if ( !isset($form->globalglossary) ) {
  42
+    $form->globalglossary = 0;
  43
+}
41 44
 ?>
42 45
 <FORM name="form" method="post" action="<?=$ME ?>">
43 46
 <CENTER>
@@ -67,6 +70,28 @@
67 70
 </tr>
68 71
 <!-- More rows go in here... -->
69 72
 <?php
  73
+if (isadmin() ) {
  74
+?>
  75
+<TR valign=top>
  76
+    <TD align=right><P><B><?php echo get_string("isglobal", "glossary") ?>:</B></P></TD>
  77
+    <TD>
  78
+<?php
  79
+    $selected = "";
  80
+    if ( isset($form->globalglossary) ) {
  81
+        if ($form->globalglossary) {
  82
+            $selected = "checked";
  83
+        }
  84
+    }
  85
+?> 
  86
+  <input type="checkbox" name="globalglossary" value=1 <?PHP p($selected)?>> <?php helpbutton("globalglossary", get_string("globallossary", "glossary"), "glossary") ?>
  87
+    </TD>
  88
+</TR>
  89
+<?php
  90
+} else {
  91
+   echo '<INPUT type="hidden" name=globalglossary value="' . $form->globalglossary . '">';
  92
+}
  93
+?>
  94
+<?php
70 95
 $mainglossary = get_record("glossary","mainglossary",1,"course",$form->course);
71 96
 if (!$mainglossary or $mainglossary->id == $form->instance ) {
72 97
 ?>
@@ -78,7 +103,8 @@
78 103
    if ( $form->mainglossary ) {
79 104
       echo "selected";
80 105
    }
81  
-   ?>><?php echo get_string("mainglossary", "glossary") ?></option>
  106
+?>>
  107
+<?php echo get_string("mainglossary", "glossary") ?></option>
82 108
   <option value="0" <?php
83 109
    if ( !$form->mainglossary ) {
84 110
       echo "selected";
2  mod/glossary/showentry.php
@@ -10,7 +10,7 @@
10 10
                                   " where e.glossaryid = g.id and".
11 11
                                       " (e.casesensitive != 0 and ucase(concept) = '" . strtoupper(trim($concept)). "' or".
12 12
                                       " e.casesensitive = 0 and concept = '$concept') and".
13  
-                                      " g.course = $courseid and".
  13
+                                      " (g.course = $courseid or g.globalglossary) and".
14 14
                                       " e.usedynalink != 0 and g.usedynalink != 0");
15 15
     
16 16
     glossary_print_dynaentry($courseid, $entries);
2  mod/glossary/version.php
@@ -5,7 +5,7 @@
5 5
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
6 6
 /////////////////////////////////////////////////////////////////////////////////
7 7
 
8  
-$module->version  = 2003102000;  // The current module version (Date: YYYYMMDDXX)
  8
+$module->version  = 2003102800;  // The current module version (Date: YYYYMMDDXX)
9 9
 $module->cron     = 0;           // Period for cron to check this module (secs)
10 10
 
11 11
 $release = "0.5 development";   // User-friendly version number

0 notes on commit 0de786f

Please sign in to comment.
Something went wrong with that request. Please try again.