]> git.mjollnir.org Git - moodle.git/commitdiff
"DATA MOD/MDL-18079, respect mod/data:comment capability when adding comments, merged...
authordongsheng <dongsheng>
Mon, 23 Feb 2009 07:30:02 +0000 (07:30 +0000)
committerdongsheng <dongsheng>
Mon, 23 Feb 2009 07:30:02 +0000 (07:30 +0000)
mod/data/comment.php
mod/data/lib.php

index 571efbfa6367d5ec98b05fe6714f7ba28240496a..413957e1528e1985e0d425802e6010383657b1ba 100755 (executable)
@@ -28,8 +28,8 @@
     }
 
     require_login($course->id, false, $cm);
-
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+    require_capability('mod/data:comment', $context);
 
     if ($commentid) {
         if (! $comment = $DB->get_record('data_comments', array('id'=>$commentid))) {
index 0bfbfb40c43c3c6fc39a69fc609f4ef08452a456..1c4833c5d6481bf40d00e8daf714535d8d7511ea 100755 (executable)
@@ -1433,6 +1433,9 @@ function data_get_ratings($recordid, $sort="u.firstname ASC") {
 function data_print_comments($data, $record, $page=0, $mform=false) {
     global $CFG, $DB;
 
+    $cm = get_coursemodule_from_instance('data', $data->id);
+    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+    $cancomment = has_capability('mod/data:comment', $context);
     echo '<a name="comments"></a>';
 
     if ($comments = $DB->get_records('data_comments', array('recordid'=>$record->id))) {
@@ -1442,7 +1445,7 @@ function data_print_comments($data, $record, $page=0, $mform=false) {
         echo '<br />';
     }
 
-    if (!isloggedin() or isguest()) {
+    if (!isloggedin() or isguest() or !$cancomment) {
         return;
     }