From 1337f77b87bfe96883adffc649b4b260c5861acd Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Tue, 3 Nov 2015 16:08:10 +0000 Subject: [PATCH] MDL-51988 report_particiption: do not allow messaging when disabled Previously the option to send messages when presented regardless of the site setting. --- report/participation/index.php | 61 +++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/report/participation/index.php b/report/participation/index.php index 7cb63b7973d..07f2b997634 100644 --- a/report/participation/index.php +++ b/report/participation/index.php @@ -173,8 +173,15 @@ if (!empty($instanceid) && !empty($roleid)) { $table = new flexible_table('course-participation-'.$course->id.'-'.$cm->id.'-'.$roleid); $table->course = $course; - $table->define_columns(array('fullname','count','select')); - $table->define_headers(array(get_string('user'),((!empty($action)) ? get_string($action) : get_string('allactions')),get_string('select'))); + $actionheader = !empty($action) ? get_string($action) : get_string('allactions'); + + if (empty($CFG->messaging)) { + $table->define_columns(array('fullname', 'count')); + $table->define_headers(array(get_string('user'), $actionheader)); + } else { + $table->define_columns(array('fullname', 'count', 'select')); + $table->define_headers(array(get_string('user'), $actionheader, get_string('select'))); + } $table->define_baseurl($baseurl); $table->set_attribute('cellpadding','5'); @@ -336,10 +343,14 @@ if (!empty($instanceid) && !empty($roleid)) { echo ''."\n"; foreach ($users as $u) { - $data = array(''.fullname($u,true).''."\n", - ((!empty($u->count)) ? get_string('yes').' ('.$u->count.') ' : get_string('no')), - ''."\n", - ); + $data = array(); + $data[] = html_writer::link(new moodle_url('/user/view.php', array('id' => $u->userid, 'course' => $course->id)), + fullname($u, true)); + $data[] = !empty($u->count) ? get_string('yes').' ('.$u->count.') ' : get_string('no'); + + if (!empty($CFG->messaging)) { + $data[] = ''; + } $table->add_data($data); } @@ -357,25 +368,27 @@ if (!empty($instanceid) && !empty($roleid)) { echo html_writer::end_div(); } - echo '
'; - echo ' '."\n"; - echo ' '."\n"; - if ($perpage >= $matchcount) { - echo ''."\n"; - } - echo '
'; - echo '
'; - echo html_writer::label(get_string('withselectedusers'), 'formactionselect'); - $displaylist['messageselect.php'] = get_string('messageselectadd'); - echo html_writer::select($displaylist, 'formaction', '', array(''=>'choosedots'), array('id'=>'formactionselect')); - echo $OUTPUT->help_icon('withselectedusers'); - echo ''."\n"; - echo '
'; - echo ''."\n"; - echo ''."\n"; - echo ''."\n"; + if (!empty($CFG->messaging)) { + echo '
'; + echo ' '."\n"; + echo ' '."\n"; + if ($perpage >= $matchcount) { + echo ''."\n"; + } + echo '
'; + echo '
'; + echo html_writer::label(get_string('withselectedusers'), 'formactionselect'); + $displaylist['messageselect.php'] = get_string('messageselectadd'); + echo html_writer::select($displaylist, 'formaction', '', array('' => 'choosedots'), array('id' => 'formactionselect')); + echo $OUTPUT->help_icon('withselectedusers'); + echo ''."\n"; + echo '
'; + echo ''."\n"; + echo ''."\n"; + echo ''."\n"; - $PAGE->requires->js_init_call('M.report_participation.init'); + $PAGE->requires->js_init_call('M.report_participation.init'); + } } echo $OUTPUT->footer();