mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 10:26:40 +02:00
MDL-43916 - Email addresses incorrectly displayed
When capabilities and settings do not allow it.
This commit is contained in:
parent
6b25f55ec9
commit
db4e2c4cd4
2 changed files with 16 additions and 2 deletions
|
@ -83,9 +83,14 @@ class mod_forum_renderer extends plugin_renderer_base {
|
||||||
*/
|
*/
|
||||||
public function subscriber_overview($users, $forum , $course) {
|
public function subscriber_overview($users, $forum , $course) {
|
||||||
$output = '';
|
$output = '';
|
||||||
|
$modinfo = get_fast_modinfo($course);
|
||||||
if (!$users || !is_array($users) || count($users)===0) {
|
if (!$users || !is_array($users) || count($users)===0) {
|
||||||
$output .= $this->output->heading(get_string("nosubscribers", "forum"));
|
$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 {
|
} 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)."'"));
|
$output .= $this->output->heading(get_string("subscribersto","forum", "'".format_string($forum->name)."'"));
|
||||||
$table = new html_table();
|
$table = new html_table();
|
||||||
$table->cellpadding = 5;
|
$table->cellpadding = 5;
|
||||||
|
@ -93,7 +98,11 @@ class mod_forum_renderer extends plugin_renderer_base {
|
||||||
$table->tablealign = 'center';
|
$table->tablealign = 'center';
|
||||||
$table->data = array();
|
$table->data = array();
|
||||||
foreach ($users as $user) {
|
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);
|
$output .= html_writer::table($table);
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,10 +157,15 @@ class quiz_override_form extends moodleform {
|
||||||
}
|
}
|
||||||
|
|
||||||
$userchoices = array();
|
$userchoices = array();
|
||||||
|
$canviewemail = in_array('email', get_extra_user_fields($this->context));
|
||||||
foreach ($users as $id => $user) {
|
foreach ($users as $id => $user) {
|
||||||
if (empty($invalidusers[$id]) || (!empty($override) &&
|
if (empty($invalidusers[$id]) || (!empty($override) &&
|
||||||
$id == $override->userid)) {
|
$id == $override->userid)) {
|
||||||
$userchoices[$id] = fullname($user) . ', ' . $user->email;
|
if ($canviewemail) {
|
||||||
|
$userchoices[$id] = fullname($user) . ', ' . $user->email;
|
||||||
|
} else {
|
||||||
|
$userchoices[$id] = fullname($user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($users);
|
unset($users);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue