Skip to content

Commit

Permalink
MDL-43916 - Email addresses incorrectly displayed
Browse files Browse the repository at this point in the history
When capabilities and settings do not allow it.
  • Loading branch information
maria-torres authored and danpoltawski committed Mar 3, 2014
1 parent 6b25f55 commit db4e2c4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 10 additions & 1 deletion mod/forum/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,26 @@ 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;
$table->cellspacing = 5;
$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);
}
Expand Down
7 changes: 6 additions & 1 deletion mod/quiz/override_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit db4e2c4

Please sign in to comment.