From 944d82d4d369d20d1f2088683f7e26bd6d9e0241 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Sat, 28 Aug 2004 18:34:10 +0000 Subject: [PATCH] - students cannot add/edit/delete comments if it isn't allowed - students can view comments if they exist - teachers bypass the commentsallowed field always (this can be useful to create glossaries with public comments from the teacher). - buttons are showed correctly. Bug 1814 (http://moodle.org/bugs/bug.php?op=show&bugid=1814) Merged from MOODLE_14_STABLE --- mod/glossary/comment.php | 23 +++++++++++++++++------ mod/glossary/comments.php | 2 +- mod/glossary/lib.php | 6 +++--- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/mod/glossary/comment.php b/mod/glossary/comment.php index b8be1fd1c2..eef56e110d 100644 --- a/mod/glossary/comment.php +++ b/mod/glossary/comment.php @@ -8,7 +8,7 @@ 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); @@ -57,8 +57,8 @@ $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"); @@ -78,6 +78,9 @@ 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); @@ -111,12 +114,20 @@ 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; diff --git a/mod/glossary/comments.php b/mod/glossary/comments.php index d69eb54b85..554478f4f0 100644 --- a/mod/glossary/comments.php +++ b/mod/glossary/comments.php @@ -59,7 +59,7 @@ print_heading(get_string('commentson','glossary')." \"$entry->concept\""); - if ($glossary->allowcomments) { + if ($glossary->allowcomments || isteacher($glossary->course)) { print_heading("id&eid=$entry->id\">$straddcomment "); } diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index 7df5125c11..4b1b417b55 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -686,7 +686,7 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry,$mode="",$ho $return .= " "; - if ( $glossary->allowcomments and !isguest()) { + if ( ($glossary->allowcomments && !isguest()) || isteacher($glossary->course)) { $return .= " id&eid=$entry->id\"> "; } @@ -1557,11 +1557,11 @@ function glossary_print_comment($course, $cm, $glossary, $entry, $comment) { echo "

"; $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 "id&eid=$entry->id&cid=$comment->id&action=edit\">\""pixpath/t/edit.gif\" height=11 width=11 border=0> "; } - if ( $USER->id == $comment->userid or isteacher($course->id) ) { + if ( ($glossary->allowcomments && $USER->id == $comment->userid) || isteacher($course->id) ) { echo "id&eid=$entry->id&cid=$comment->id&action=delete\">\""pixpath/t/delete.gif\" height=11 width=11 border=0>"; } -- 2.39.5