]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-8490 Glossary student not being able to edit entries
authorskodak <skodak>
Tue, 13 Feb 2007 19:25:04 +0000 (19:25 +0000)
committerskodak <skodak>
Tue, 13 Feb 2007 19:25:04 +0000 (19:25 +0000)
mod/glossary/edit.php

index 66054d158b3bb6c46b42d68e48a06b7622a9cd91..e2656ad14bbfdc01c1c5a176e89bb2cbb8cc79f6 100644 (file)
@@ -33,8 +33,16 @@ if (! $glossary = get_record("glossary", "id", $cm->instance)) {
     error("Course module is incorrect");
 }
 
+
 if ($e) { // if entry is specified
-    require_capability('mod/glossary:manageentries', $context);
+    if (!$entry  = get_record("glossary_entries", "id", $e)) {
+        error("Incorrect entry id");
+    }
+    $ineditperiod = ((time() - $entry->timecreated <  $CFG->maxeditingtime) || $glossary->editalways);
+    if (!has_capability('mod/glossary:manageentries', $context) and !($entry->userid == $USER->id and ($ineditperiod and has_capability('mod/glossary:write', $context)))) {
+        //expired edit time is the most probable cause here
+        error(get_string('erredittimeexpired', 'glossary'), "view.php?id=$cm->id&amp;mode=entry&amp;hook=$e");
+    }
 } else { // new entry
     require_capability('mod/glossary:write', $context);
 }