error("Course is misconfigured");
}
+ if (! $entry = get_record("glossary_entries","id", $entry)) {
+ error("Entry ID was incorrect");
+ }
+
require_login($course->id);
if (isguest()) {
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.
} 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");
}
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) ) {
$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);