}
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))) {
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))) {
echo '<br />';
}
- if (!isloggedin() or isguest()) {
+ if (!isloggedin() or isguest() or !$cancomment) {
return;
}