require_variable($eid); // Entry ID
optional_variable($cid,0); // Comment ID
- optional_variable($action,"edit"); // Action to perform
+ optional_variable($action,"add"); // Action to perform
optional_variable($confirm,0); // Confirm the action
$action = strtolower($action);
$straction = get_string("deletingcomment","glossary");
break;
default:
- $action = "edit";
- $straction = get_string("editingcomment","glossary");
+ $action = "add";
+ $straction = get_string("addingcomment","glossary");
break;
}
$strglossaries = get_string("modulenameplural", "glossary");
if (($comment->userid <> $USER->id) and !isteacher($glossary->course)) {
error("You can't delete other people's comments!");
}
+ if (!$glossary->allowcomments && !isteacher($glossary->course)) {
+ error("You can't delete comments in this glossary!");
+ }
if ( $confirm ) {
delete_records("glossary_comments","id", $cid);
print_simple_box_end();
}
} else {
+ if (!$glossary->allowcomments && !isteacher($glossary->course)) {
+ error("You can't add/edit comments in this glossary!");
+ }
if ( $action == "edit" ) {
- $ineditperiod = ((time() - $comment->timemodified < $CFG->maxeditingtime) || $glossary->editalways);
- if ( (!$ineditperiod || $USER->id != $comment->userid) and !isteacher($course->id) ) {
+ if (!isset($comment->timemodified)) {
+ $timetocheck = 0;
+ } else {
+ $timetocheck = $comment->timemodified;
+ }
+ $ineditperiod = ((time() - $timetocheck < $CFG->maxeditingtime) || $glossary->editalways);
+ if ( (!$ineditperiod || $USER->id != $comment->userid) and !isteacher($course->id) and $cid) {
if ( $USER->id != $comment->userid ) {
error("You can't edit other people's comments!");
- } elseif (time() - $comment->timemodified >= $CFG->maxeditingtime ) {
+ } elseif (!$ineditperiod) {
error("You can't edit this. Time expired!");
}
die;
$return .= "</font> ";
- if ( $glossary->allowcomments and !isguest()) {
+ if ( ($glossary->allowcomments && !isguest()) || isteacher($glossary->course)) {
$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> ";
}
echo "<div align=right><p align=right>";
$ineditperiod = ((time() - $comment->timemodified < $CFG->maxeditingtime) || $glossary->editalways);
- if ( ($ineditperiod && $USER->id == $comment->userid) or isteacher($course->id) ) {
+ if ( ($glossary->allowcomments && $ineditperiod && $USER->id == $comment->userid) || isteacher($course->id) ) {
echo "<a href=\"comment.php?id=$cm->id&eid=$entry->id&cid=$comment->id&action=edit\"><img
alt=\"" . get_string("edit") . "\" src=\"$CFG->pixpath/t/edit.gif\" height=11 width=11 border=0></a> ";
}
- if ( $USER->id == $comment->userid or isteacher($course->id) ) {
+ if ( ($glossary->allowcomments && $USER->id == $comment->userid) || isteacher($course->id) ) {
echo "<a href=\"comment.php?id=$cm->id&eid=$entry->id&cid=$comment->id&action=delete\"><img
alt=\"" . get_string("delete") . "\" src=\"$CFG->pixpath/t/delete.gif\" height=11 width=11 border=0></a>";
}