Now students cannot add/edit/delete entries if glossary->studentcanpost = 0
authorstronk7 <stronk7>
Sat, 28 Aug 2004 19:15:52 +0000 (19:15 +0000)
committerstronk7 <stronk7>
Sat, 28 Aug 2004 19:15:52 +0000 (19:15 +0000)
using manual URLs.

Merged from MOODLE_14_STABLE

mod/glossary/comment.php
mod/glossary/deleteentry.php
mod/glossary/edit.php
mod/glossary/lib.php

index eef56e110defc0d382fa25a21200b8567b1c229a..2d91df2e4bd3ce12e62b2b0aa2b734867826c872 100644 (file)
         }
     } else {
         if (!$glossary->allowcomments && !isteacher($glossary->course)) {
-            error("You can't add/edit comments in this glossary!");
+            error("You can't add/edit comments to this glossary!");
         }
         if ( $action == "edit" ) {
             if (!isset($comment->timemodified)) {
index 4cca03d52e06a26fae302a03a2f95a08667de48c..15a860554e421b0b8f1ebf45c95a895cb7b6a3b2 100644 (file)
         error("Course is misconfigured");
     }
 
+    if (! $entry = get_record("glossary_entries","id", $entry)) {
+        error("Entry ID was incorrect");
+    }
+
     require_login($course->id);
 
     if (isguest()) {
@@ -37,7 +41,6 @@
         error("You are not allowed to edit or delete entries");
     }
 
-    $entryfields = get_record("glossary_entries", "id", $entry);
     $strareyousuredelete = get_string("areyousuredelete","glossary");
 
     print_header_simple("$glossary->name", "",
                   "", "", true, update_module_button($cm->id, $course->id, $strglossary), 
                   navmenu($course, $cm));
 
-    $entry = get_record("glossary_entries","id", $entry);
 
-    if (($entry->userid <> $USER->id) and !isteacher($course->id)) {
+    if (($entry->userid != $USER->id) and !isteacher($course->id)) {
         error("You can't delete other people's entries!");
     }
+    $ineditperiod = ((time() - $entry->timecreated <  $CFG->maxeditingtime) || $glossary->editalways);
+    if (!$ineditperiod and !isteacher($course->id)) {
+        error("You can't delete this. Time expired!");
+    }
 
 /// If data submitted, then process and store.
     
@@ -78,8 +84,8 @@
 
     } else {        // the operation has not been confirmed yet so ask the user to do so
 
-        notice_yesno("<b>$entryfields->concept</b><p>$strareyousuredelete</p>",
-                      "deleteentry.php?id=$cm->id&mode=delete&confirm=1&entry=".s($entry->concept)."&prevmode=$prevmode&hook=$hook",
+        notice_yesno("<b>$entry->concept</b><p>$strareyousuredelete</p>",
+                      "deleteentry.php?id=$cm->id&mode=delete&confirm=1&entry=".s($entry->id)."&prevmode=$prevmode&hook=$hook",
                       "view.php?id=$cm->id&mode=$prevmode&hook=$hook");
 
     }
index 55b3d31df57aff36622d717640c1156618ab7eae..39e48b1eb550a6f5f3eac9046189bcbea8719416 100644 (file)
@@ -29,6 +29,10 @@ if ( isguest() ) {
 if (! $glossary = get_record("glossary", "id", $cm->instance)) {
     error("Course module is incorrect");
 }
+
+if (!$glossary->studentcanpost && !isteacher($glossary->course)) {
+    error("You can't add/edit entries to this glossary!");
+}
 if ( $confirm ) {
     $form = data_submitted();
     if ( !isset($form->usedynalink) ) {
index 4b1b417b55dd727f41b3232aa757dccd5910ad5d..d676416931817a25785ecb66c55aefdac696d49a 100644 (file)
@@ -690,7 +690,7 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry,$mode="",$ho
         $return .= " <a title=\"" . get_string("addcomment","glossary") . "\" href=\"comment.php?id=$cm->id&eid=$entry->id\"><img src=\"comment.gif\" height=11 width=11 border=0></a> ";
     }
 
-    if ($isteacher or $glossary->studentcanpost and $entry->userid == $USER->id) {
+    if ($isteacher or ($glossary->studentcanpost and $entry->userid == $USER->id)) {
         // only teachers can export entries so check it out
         if ($isteacher and !$ismainglossary and !$importedentry) {
             $mainglossary = get_record("glossary","mainglossary",1,"course",$course->id);