Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-43916 - Email addresses incorrectly displayed

When capabilities and settings do not allow it.
  • Loading branch information...
commit db4e2c4cd47d48ebf06424d942bf603a8fa94d97 1 parent 6b25f55
@maria-torres maria-torres authored danpoltawski committed
Showing with 16 additions and 2 deletions.
  1. +10 −1 mod/forum/renderer.php
  2. +6 −1 mod/quiz/override_form.php
View
11 mod/forum/renderer.php
@@ -83,9 +83,14 @@ public function subscriber_selection_form(user_selector_base $existinguc, user_s
*/
public function subscriber_overview($users, $forum , $course) {
$output = '';
+ $modinfo = get_fast_modinfo($course);
if (!$users || !is_array($users) || count($users)===0) {
$output .= $this->output->heading(get_string("nosubscribers", "forum"));
+ } else if (!isset($modinfo->instances['forum'][$forum->id])) {
+ $output .= $this->output->heading(get_string("invalidmodule", "error"));
} else {
+ $cm = $modinfo->instances['forum'][$forum->id];
+ $canviewemail = in_array('email', get_extra_user_fields(context_module::instance($cm->id)));
$output .= $this->output->heading(get_string("subscribersto","forum", "'".format_string($forum->name)."'"));
$table = new html_table();
$table->cellpadding = 5;
@@ -93,7 +98,11 @@ public function subscriber_overview($users, $forum , $course) {
$table->tablealign = 'center';
$table->data = array();
foreach ($users as $user) {
- $table->data[] = array($this->output->user_picture($user, array('courseid'=>$course->id)), fullname($user), $user->email);
+ $info = array($this->output->user_picture($user, array('courseid'=>$course->id)), fullname($user));
+ if ($canviewemail) {
+ array_push($info, $user->email);
+ }
+ $table->data[] = $info;
}
$output .= html_writer::table($table);
}
View
7 mod/quiz/override_form.php
@@ -157,10 +157,15 @@ protected function definition() {
}
$userchoices = array();
+ $canviewemail = in_array('email', get_extra_user_fields($this->context));
foreach ($users as $id => $user) {
if (empty($invalidusers[$id]) || (!empty($override) &&
$id == $override->userid)) {
- $userchoices[$id] = fullname($user) . ', ' . $user->email;
+ if ($canviewemail) {
+ $userchoices[$id] = fullname($user) . ', ' . $user->email;
+ } else {
+ $userchoices[$id] = fullname($user);
+ }
}
}
unset($users);
Please sign in to comment.
Something went wrong with that request. Please try again.