Now editalways is working in glossaries.
authorstronk7 <stronk7>
Mon, 9 Aug 2004 15:04:36 +0000 (15:04 +0000)
committerstronk7 <stronk7>
Mon, 9 Aug 2004 15:04:36 +0000 (15:04 +0000)
Decide if an entry is editable:
-It isn't a imported entry (so nobody can edit a imported (from secondary to main) entry)) and
-The user is teacher or he is a student with time permissions (edit period or editalways defined).

Bug 1445
(http://moodle.org/bugs/bug.php?op=show&bugid=1445)

mod/glossary/backuplib.php
mod/glossary/db/mysql.php
mod/glossary/db/mysql.sql
mod/glossary/db/oci8po.sql
mod/glossary/db/postgres7.php
mod/glossary/db/postgres7.sql
mod/glossary/lib.php
mod/glossary/mod.html
mod/glossary/restorelib.php
mod/glossary/version.php

index 2ffb33a8ba44ea2bbbe44c3b6eb443640278ec1d..31a8bc51a848269ba680744067c7ff5459eb291b 100644 (file)
@@ -57,6 +57,7 @@
                 fwrite ($bf,full_tag("DEFAULTAPPROVAL",4,false,$glossary->defaultapproval));
                 fwrite ($bf,full_tag("GLOBALGLOSSARY",4,false,$glossary->globalglossary));
                 fwrite ($bf,full_tag("ENTBYPAGE",4,false,$glossary->entbypage));
+                fwrite ($bf,full_tag("EDITALWAYS",4,false,$glossary->editalways));
                 fwrite ($bf,full_tag("RSSTYPE",4,false,$glossary->rsstype));
                 fwrite ($bf,full_tag("RSSARTICLES",4,false,$glossary->rssarticles));
                 fwrite ($bf,full_tag("TIMECREATED",4,false,$glossary->timecreated));
index 9475154bae5047d0dfa21c5a6fd17922c07065da..f6761302458e18fd5b223b294da82c01297305cd 100644 (file)
@@ -335,6 +335,10 @@ function glossary_upgrade($oldversion) {
           }
       }
   }
+
+  if ( $oldversion < 2004080800) {
+      table_column("glossary","","editalways","tinyint","2", "unsigned", "0", "", "entbypage");
+  }
     
   return true;
 }
index b55b314fa1872b07dcfe4513ad6bef213341b76d..404a51b2209b3ed3ef3931676c9140a5111863a6 100644 (file)
@@ -25,6 +25,7 @@ CREATE TABLE prefix_glossary (
      defaultapproval tinyint(2) unsigned NOT NULL default '1',
      globalglossary tinyint(2) unsigned NOT NULL default '0',
      entbypage tinyint(3) unsigned NOT NULL default '10',
+     editalways tinyint(2) unsigned NOT NULL default '0',
      rsstype tinyint(2) unsigned NOT NULL default '0',
      rssarticles tinyint(2) unsigned NOT NULL default '0',
      assessed int(10) unsigned NOT NULL default '0',
index 092dadd9b3c8dd50727df0d425220b2e9569586c..a1cff108891bb58d424a4af4398cc685789fd636 100755 (executable)
@@ -21,6 +21,7 @@ CREATE TABLE prefix_glossary (
   showspecial number(2) default '1' not null,
   showall number(2) default '1' not null,
   showalphabet number(2) default '1' not null,
+  editalways number(2) default '0' NOT NULL,
   rsstype number(2) default '0' NOT NULL,
   rssarticles number(2) default '0' NOT NULL,
   timecreated number(10) default '0' not null,
index 0f654484c2c81ab21f81a14370378c1852c74bd4..2a4b458b2586daa238a6f156fe45d4c67e2d9514 100644 (file)
@@ -97,6 +97,10 @@ function glossary_upgrade($oldversion) {
       }
   }
 
+  if ( $oldversion < 2004080800) {
+      table_column("glossary","","editalways","integer","2", "unsigned", "0", "", "entbypage");
+  }
+
   return true;
 }
 
index 5d1f637e52ac46f15fdd36857d54181ad106d162..3840cef6d3314fcf30ada01503842ad2e302b51d 100644 (file)
@@ -25,6 +25,7 @@ CREATE TABLE prefix_glossary (
      defaultapproval int2 NOT NULL default '1',
      globalglossary int2 NOT NULL default '0',
      entbypage int NOT NULL default '10',
+     editalways integer NOT NULL default '0',
      rsstype integer NOT NULL default '0',
      rssarticles integer NOT NULL default '0',
      assessed int4 NOT NULL default '0',
index bc700bc736f52c572859ee74311aff5604fcfe0e..0b5b8c5bad8e1052b8b2073d00c8fb4a56b7efc6 100644 (file)
@@ -621,8 +621,11 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry,$mode="",$ho
             $icon = "$CFG->pixpath/t/delete.gif";
         }
 
-        // Exported entries can be updated/deleted only by teachers in the main glossary
-        if ( !$importedentry and ($isteacher or !$ismainglossary) ) {
+        //Decide if an entry is editable:
+        // -It isn't a imported entry (so nobody can edit a imported (from secondary to main) entry)) and
+        // -The user is teacher or he is a student with time permissions (edit period or editalways defined).
+        $ineditperiod = (time() - $entry->timemodified <  $CFG->maxeditingtime);
+        if ( !$importedentry and ($isteacher or ($entry->userid == $USER->id and ($glossary->editalways or $ineditperiod)))) {
             $return .= " <a title=\"" . get_string("delete") . "\" href=\"deleteentry.php?id=$cm->id&mode=delete&entry=$entry->id&prevmode=$mode&hook=$hook\"><img src=\"";
             $return .= $icon;
             $return .= "\" height=11 width=11 border=0></a> ";
index 49f2a4099d63a4c290132a187acc978c754e48ba..99f086ffbacdc0089e17f61e3ac05801ef828893 100644 (file)
@@ -44,12 +44,15 @@ if (!isset($form->showalphabet)) {
 if (!isset($form->showspecial)) {
     $form->showspecial = 1;
 }
-    if (!isset($form->rsstype)) {
-        $form->rsstype = 0;
-    }
-    if (!isset($form->rssarticles)) {
-        $form->rssarticles = 0;
-    }
+if (!isset($form->editalways)) {
+    $form->editalways = 0;
+}
+if (!isset($form->rsstype)) {
+    $form->rsstype = 0;
+}
+if (!isset($form->rssarticles)) {
+    $form->rssarticles = 0;
+}
 ?>
 <FORM name="form" method="post" action="<?php p($ME) ?>">
 <CENTER>
@@ -318,6 +321,25 @@ if (!$mainglossary or $mainglossary->id == $form->instance ) {
   </select> <?php helpbutton("shows", get_string("showall", "glossary"), "glossary") ?>
     </TD>
 </TR>
+<TR valign=top>
+    <TD align=right><P><B><?php echo get_string("editalways", "glossary") ?>:</B></P></TD>
+    <TD>
+  <select size="1" name="editalways">
+  <option value="1" <?php
+   if ( $form->editalways ) {
+      echo "selected";
+   }
+   ?>
+   ><?php echo get_string("yes") ?></option>
+  <option value="0" <?php
+   if ( !$form->editalways ) {
+      echo "selected";
+   }
+   ?>><?php echo get_string("no") ?>
+  </option>
+  </select> <?php helpbutton("editalways", get_string("editalways", "glossary"), "glossary") ?>
+    </TD>
+</TR>
 <?php
     //Only show rss parameters if rss is activated at site and glossary levels
     if (isset($CFG->enablerssfeeds) && isset($CFG->glossary_enablerssfeeds) &&
index 244dd3334629502018c28d353c6ec0ca256aa135..130b031c2dc29cb0337acae6848510181c405532 100644 (file)
@@ -61,6 +61,7 @@
             $glossary->defaultapproval = backup_todb($info['MOD']['#']['DEFAULTAPPROVAL']['0']['#']);
             $glossary->globalglossary = backup_todb($info['MOD']['#']['GLOBALGLOSSARY']['0']['#']);
             $glossary->entbypage = backup_todb($info['MOD']['#']['ENTBYPAGE']['0']['#']);
+            $glossary->editalways = backup_todb($info['MOD']['#']['EDITALWAYS']['0']['#']);
             $glossary->rsstype = backup_todb($info['MOD']['#']['RSSTYPE']['0']['#']);
             $glossary->rssarticles = backup_todb($info['MOD']['#']['RSSARTICLES']['0']['#']);
             $glossary->timecreated = backup_todb($info['MOD']['#']['TIMECREATED']['0']['#']);
index 5d4b605712d39e95f2546abecca9626a7d4e8e19..89df5f8abeb0471047a13339464036a20f95a2db 100644 (file)
@@ -5,8 +5,8 @@
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 /////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2004072700;  // The current module version (Date: YYYYMMDDXX)
-$module->requires = 2004052501;  // Requires this Moodle version
+$module->version  = 2004080800;  // The current module version (Date: YYYYMMDDXX)
+$module->requires = 2004080300;  // Requires this Moodle version
 $module->cron     = 0;           // Period for cron to check this module (secs)
 
 $release = "1.4 development";   // User-friendly version number