diff --git a/message/classes/output/preferences/notification_list.php b/message/classes/output/preferences/notification_list.php index 2dfe7ba43b4..6ed09f88e1b 100644 --- a/message/classes/output/preferences/notification_list.php +++ b/message/classes/output/preferences/notification_list.php @@ -27,6 +27,7 @@ namespace core_message\output\preferences; use renderable; use templatable; +use context_user; /** * Class to create context for the list of notifications on the message @@ -78,6 +79,7 @@ class notification_list implements templatable, renderable { $providers = $this->providers; $preferences = $this->preferences; $user = $this->user; + $usercontext = context_user::instance($user->id); foreach($providers as $provider) { if($provider->component != 'moodle') { @@ -91,7 +93,20 @@ class notification_list implements templatable, renderable { array_unshift($components, 'moodle'); // pop it in front! phew! asort($providers); - $context = []; + $context = [ + 'userid' => $user->id, + 'disableall' => $user->emailstop, + 'processors' => [], + ]; + + foreach ($processors as $processor) { + $context['processors'][] = [ + 'displayname' => get_string('pluginname', 'message_'.$processor->name), + 'name' => $processor->name, + 'hassettings' => !empty($processor->object->config_form($preferences)), + 'contextid' => $usercontext->id, + ]; + } foreach ($components as $component) { $notificationcomponent = new \core_message\output\preferences\notification_list_component( @@ -99,9 +114,6 @@ class notification_list implements templatable, renderable { $context['components'][] = $notificationcomponent->export_for_template($output); } - $context['userid'] = $user->id; - $context['disableall'] = $user->emailstop; - return $context; } } diff --git a/message/classes/output/preferences/notification_list_component.php b/message/classes/output/preferences/notification_list_component.php index f6d22651928..224eba875e3 100644 --- a/message/classes/output/preferences/notification_list_component.php +++ b/message/classes/output/preferences/notification_list_component.php @@ -29,7 +29,6 @@ require_once($CFG->dirroot . '/message/lib.php'); use renderable; use templatable; -use context_user; /** * Class to create context for a notification component on the message @@ -108,7 +107,6 @@ class notification_list_component implements templatable, renderable { $preferences = $this->preferences; $component = $this->component; $defaultpreferences = get_message_output_default_preferences(); - $usercontext = context_user::instance($this->user->id); if ($component != 'moodle') { $componentname = get_string('pluginname', $component); @@ -118,19 +116,9 @@ class notification_list_component implements templatable, renderable { $context = [ 'displayname' => $componentname, - 'processors' => [], 'notifications' => [], ]; - foreach ($processors as $processor) { - $context['processors'][] = [ - 'displayname' => get_string('pluginname', 'message_'.$processor->name), - 'name' => $processor->name, - 'hassettings' => !empty($processor->object->config_form($preferences)), - 'contextid' => $usercontext->id, - ]; - } - foreach ($providers as $provider) { $preferencebase = $this->get_preference_base($provider); // If provider component is not same or provider disabled then don't show. diff --git a/message/templates/preferences_notifications_list.mustache b/message/templates/preferences_notifications_list.mustache index 4e446b2c6c0..64dc980a667 100644 --- a/message/templates/preferences_notifications_list.mustache +++ b/message/templates/preferences_notifications_list.mustache @@ -77,30 +77,34 @@ }}
| {{displayname}} | + {{#processors}} ++ {{#hassettings}} + + {{displayname}} {{#pix}} i/settings {{/pix}} + + {{/hassettings}} + {{^hassettings}} + {{displayname}} + {{/hassettings}} + | + {{/processors}} +|
|---|---|---|
| {{displayname}} | - {{#processors}} -- {{#hassettings}} - - {{displayname}} {{#pix}} i/settings {{/pix}} - - {{/hassettings}} - {{^hassettings}} - {{displayname}} - {{/hassettings}} - | - {{/processors}} + {{#processors}}{{/processors}} |
| @@ -156,9 +160,9 @@ {{/processors}} |