]> git.mjollnir.org Git - moodle.git/commitdiff
Now print-view availability for students can be configured by glossary.
authorstronk7 <stronk7>
Wed, 12 Jan 2005 00:55:38 +0000 (00:55 +0000)
committerstronk7 <stronk7>
Wed, 12 Jan 2005 00:55:38 +0000 (00:55 +0000)
Bug 2080 (http://moodle.org/bugs/bug.php?op=show&bugid=2080)

13 files changed:
lang/en/glossary.php
lang/en/help/glossary/allowprintview.html [new file with mode: 0644]
mod/glossary/backuplib.php
mod/glossary/db/mysql.php
mod/glossary/db/mysql.sql
mod/glossary/db/postgres7.php
mod/glossary/db/postgres7.sql
mod/glossary/filter.php
mod/glossary/mod.html
mod/glossary/print.php
mod/glossary/restorelib.php
mod/glossary/version.php
mod/glossary/view.php

index c30c58134d50302294469e88cc5b3130eef34775..40df7c58c6d19a50b1d08196c53c8cf7e5bdd8c0 100644 (file)
@@ -10,6 +10,7 @@ $string['allcategories'] = 'All Categories';
 $string['allentries'] = 'ALL';
 $string['allowcomments'] = 'Allow comments on entries';
 $string['allowduplicatedentries'] = 'Duplicated entries allowed';
+$string['allowprintview'] = 'Allow print view';
 $string['allowratings'] = 'Allow entries to be rated?';
 $string['answer'] = 'Answer';
 $string['approve'] = 'Approve';
@@ -130,6 +131,7 @@ $string['notcategorised'] = 'Not categorised';
 $string['numberofentries'] = 'Number of entries';
 $string['onebyline'] = '(one per line)';
 $string['printerfriendly'] = 'Printer-friendly version';
+$string['printviewnotallowed'] = 'Print view isn\'t allowed';
 $string['question'] = 'Question';
 $string['rate'] = 'Rate';
 $string['rating'] = 'Rating';
diff --git a/lang/en/help/glossary/allowprintview.html b/lang/en/help/glossary/allowprintview.html
new file mode 100644 (file)
index 0000000..05d900f
--- /dev/null
@@ -0,0 +1,7 @@
+<p align="center"><b>Allow print view</b></p>
+
+<p>Students can be allowed to use the print view of the glossary.</p>
+
+<p>You can choose whether this feature is enabled or disabled.</p>
+
+<p>Teachers always can use the print view.</p>
index d34a7f2e05e6020abb6e003c73c78385bf445273..195e988b68cfecfca2c6cf2b0c2d8f82c0853551 100644 (file)
@@ -53,6 +53,7 @@
                 fwrite ($bf,full_tag("SHOWALPHABET",4,false,$glossary->showalphabet));
                 fwrite ($bf,full_tag("SHOWALL",4,false,$glossary->showall));
                 fwrite ($bf,full_tag("ALLOWCOMMENTS",4,false,$glossary->allowcomments));
+                fwrite ($bf,full_tag("ALLOWPRINTVIEW",4,false,$glossary->allowprintview));
                 fwrite ($bf,full_tag("USEDYNALINK",4,false,$glossary->usedynalink));
                 fwrite ($bf,full_tag("DEFAULTAPPROVAL",4,false,$glossary->defaultapproval));
                 fwrite ($bf,full_tag("GLOBALGLOSSARY",4,false,$glossary->globalglossary));
index a292eb2ab2569d9179a6ecaa307cd5ba9c24d173..ea76c8816add095a5745ff11756eb732ec7e021d 100644 (file)
@@ -386,6 +386,17 @@ function glossary_upgrade($oldversion) {
           }
       }
   }
+
+  //Allowprintview flag
+  if ($oldversion < 2005011200) {
+      table_column('glossary','','allowprintview','tinyint','2', 'unsigned', '1', '', 'allowcomments');
+      $glossaries = get_records('glossary', '', '', '', 'id, name');
+      if ($glossaries) {
+          foreach ($glossaries as $glossary) { 
+              set_field('glossary', 'allowprintview', '1', 'id', "$glossary->id");
+          }
+      }
+  }
     
   return true;
 }
index e4091ec770bdbfd306ff4aa57abe923969cb4b95..d553f0cefe177280654df0b7b672105b6e6a4f00 100644 (file)
@@ -21,6 +21,7 @@ CREATE TABLE prefix_glossary (
      showalphabet tinyint(2) unsigned NOT NULL default '1',
      showall tinyint(2) unsigned NOT NULL default '1',
      allowcomments tinyint(2) unsigned NOT NULL default '0',
+     allowprintview tinyint(2) unsigned NOT NULL default '1',
      usedynalink tinyint(2) unsigned NOT NULL default '1',
      defaultapproval tinyint(2) unsigned NOT NULL default '1',
      globalglossary tinyint(2) unsigned NOT NULL default '0',
index f3a6130ac4085674e9fd172d52bd897c5cebf1e9..905d10e3bd7374a7104b3164cedd80b33ee7a9b7 100644 (file)
@@ -147,6 +147,17 @@ function glossary_upgrade($oldversion) {
       }
   }
 
+  //Allowprintview flag
+  if ($oldversion < 2005011200) {
+      table_column('glossary','','allowprintview','integer','2', 'unsigned', '1', '', 'allowcomments');
+      $glossaries = get_records('glossary', '', '', '', 'id, name');
+      if ($glossaries) {
+          foreach ($glossaries as $glossary) {
+              set_field('glossary', 'allowprintview', '1', 'id', "$glossary->id");
+          }
+      }
+  }
+
   return true;
 }
 
index 580a3b8a7b0f38a78c73972f0f389b04c0ac069d..5c53ba8b8974d2e7cd9d2ac5ce9cd1a5da3a8e1e 100644 (file)
@@ -21,6 +21,7 @@ CREATE TABLE prefix_glossary (
      showalphabet int2 NOT NULL default '1',
      showall int2 NOT NULL default '1',
      allowcomments int2 NOT NULL default '0',
+     allowprintview int2 NOT NULL default '1',
      usedynalink int2 NOT NULL default '1',
      defaultapproval int2 NOT NULL default '1',
      globalglossary int2 NOT NULL default '0',
index f3900a9172b7e84aa4832028aad5d6caf2877c9c..77882c8e0babde04210e9097ed8f5565bb4c1242 100644 (file)
@@ -59,7 +59,7 @@
                         if ( $lastcategory != $concept->id ) {
                             $category = get_record("glossary_categories","id",$concept->id);
                             $lastcategory = $concept->id;
-                            if ( $cm->instance != $category->glossaryid  ) {
+                            if ( empty($cm->instance) || $cm->instance != $category->glossaryid  ) {
                                 $gcat = get_record("glossary","id",$category->glossaryid);
                                 if ( !$cm = get_coursemodule_from_instance("glossary", $category->glossaryid, $gcat->course) ) {
                                     $cm->id = 1;
index 73571b2a3e333080a24e0f5173177b2c38cca5d4..1bf1609c8f8f8827486bbbe6b3e3c7794a3cf941 100644 (file)
@@ -11,6 +11,9 @@ if (!isset($form->allowduplicatedentries)) {
 if (!isset($form->allowcomments)) {
     $form->allowcomments = $CFG->glossary_allowcomments;
 }
+if (!isset($form->allowprintview)) {
+    $form->allowprintview = 1;
+}
 if (!isset($form->usedynalink)) {
     $form->usedynalink = $CFG->glossary_linkbydefault;
 }
@@ -207,6 +210,25 @@ if (!$mainglossary or $mainglossary->id == $form->instance ) {
   </select> <?php helpbutton("allowcomments", get_string("allowcomments", "glossary"), "glossary") ?>
     </td>
 </tr>
+<tr valign="top">
+    <td align="right"><b><?php echo get_string("allowprintview", "glossary") ?>:</b></td>
+    <td align="left">
+  <select size="1" name="allowprintview">
+  <option value="1" <?php
+   if ( $form->allowprintview ) {
+      echo "selected=\"selected\"";
+   }
+   ?>
+   ><?php echo get_string("yes") ?></option>
+  <option value="0" <?php
+   if ( !$form->allowprintview ) {
+      echo "selected=\"selected\"";
+   }
+   ?>><?php echo get_string("no") ?>
+  </option>
+  </select> <?php helpbutton("allowprintview", get_string("allowprintview", "glossary"), "glossary") ?>
+    </td>
+</tr>
 <tr valign="top">
     <td align="right"><b><?php echo get_string("usedynalink", "glossary") ?>:</b></td>
     <td align="left">
index a241253e0138303f0e6d047fcf081d322b77b887..6c40b7b0a9a7f3976ea6606e3bb6b2f44adad6a6 100644 (file)
         notice(get_string("activityiscurrentlyhidden"));
     }
 
+    if (!isteacher($course->id) and !$glossary->allowprintview) {
+        notice(get_string('printviewnotallowed', 'glossary'));
+    }
+
 /// setting the default values for the display mode of the current glossary
 /// only if the glossary is viewed by the first time
     if ( $dp = get_record('glossary_formats','name', addslashes($glossary->displayformat)) ) {
index cd4bc08352071d5c2c5562e46aa0441717d76653..0aa14209316ba23c8aec467761aa3096c493f712 100644 (file)
@@ -57,6 +57,7 @@
             $glossary->showalphabet = backup_todb($info['MOD']['#']['SHOWALPHABET']['0']['#']);
             $glossary->showall = backup_todb($info['MOD']['#']['SHOWALL']['0']['#']);
             $glossary->allowcomments = backup_todb($info['MOD']['#']['ALLOWCOMMENTS']['0']['#']);
+            $glossary->allowprintview = backup_todb($info['MOD']['#']['ALLOWPRINTVIEW']['0']['#']);
             $glossary->usedynalink = backup_todb($info['MOD']['#']['USEDYNALINK']['0']['#']);
             $glossary->defaultapproval = backup_todb($info['MOD']['#']['DEFAULTAPPROVAL']['0']['#']);
             $glossary->globalglossary = backup_todb($info['MOD']['#']['GLOBALGLOSSARY']['0']['#']);
index 78079afcc98c78e120a7c5b75d5c8ef6566ca729..08ee97a2f9a483585a9979b3933538bc47a04189 100644 (file)
@@ -5,7 +5,7 @@
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 /////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2005011100;
+$module->version  = 2005011200;
 $module->requires = 2004112300;  // Requires this Moodle version
 $module->cron     = 0;           // Period for cron to check this module (secs)
 
index 3c147ea4282487be30e35e810b21884be5baafae..1ab77b0b3278006ef6b26e883ed45598e22211e6 100644 (file)
     echo '<p align="center"><font size="3"><b>' . stripslashes_safe($glossary->name);
     if ( $isuserframe and $mode != 'search') {
     /// the "Print" icon
-        echo " <a title =\"". get_string("printerfriendly","glossary") . "\" target=\"printview\" href=\"print.php?id=$cm->id&amp;mode=$mode&amp;hook=$hook&amp;sortkey=$sortkey&amp;sortorder=$sortorder&amp;offset=$offset\">\n";
-        echo '<img border="0" src="print.gif" alt="" /></a>';
+        if (isteacher($course->id) or $glossary->allowprintview) {
+            echo " <a title =\"". get_string("printerfriendly","glossary") . "\" target=\"printview\" href=\"print.php?id=$cm->id&amp;mode=$mode&amp;hook=$hook&amp;sortkey=$sortkey&amp;sortorder=$sortorder&amp;offset=$offset\">\n";
+            echo '<img border="0" src="print.gif" alt="" /></a>';
+        }
     }
     echo '</b></font></p>';