Browse files

MDL-30544 message: prevented the temporarily disable notifications ch…

…eckbox from erasing your messaging preferences
  • Loading branch information...
1 parent a5b5881 commit f6ce2eb25a95c0e17ccf3a1dc7b88344cda012ad @andyjdavis andyjdavis committed Dec 1, 2011
Showing with 20 additions and 16 deletions.
  1. +20 −16 message/edit.php
View
36 message/edit.php
@@ -107,25 +107,29 @@
$DB->set_field('user', 'emailstop', $user->emailstop, array("id"=>$user->id));
}
-
- foreach ($providers as $provider) {
- $componentproviderbase = $provider->component.'_'.$provider->name;
- foreach (array('loggedin', 'loggedoff') as $state) {
- $linepref = '';
- $componentproviderstate = $componentproviderbase.'_'.$state;
- if (array_key_exists($componentproviderstate, $form)) {
- foreach (array_keys($form->{$componentproviderstate}) as $process) {
- if ($linepref == ''){
- $linepref = $process;
- } else {
- $linepref .= ','.$process;
+ // Turning on emailstop disables the preference checkboxes in the browser.
+ // Disabled checkboxes may not be submitted with the form making them look (incorrectly) like they've been unchecked.
+ // Only alter the messaging preferences if emailstop is turned off
+ if (!$user->emailstop) {
+ foreach ($providers as $provider) {
+ $componentproviderbase = $provider->component.'_'.$provider->name;
+ foreach (array('loggedin', 'loggedoff') as $state) {
+ $linepref = '';
+ $componentproviderstate = $componentproviderbase.'_'.$state;
+ if (array_key_exists($componentproviderstate, $form)) {
+ foreach (array_keys($form->{$componentproviderstate}) as $process) {
+ if ($linepref == ''){
+ $linepref = $process;
+ } else {
+ $linepref .= ','.$process;
+ }
}
}
+ if (empty($linepref)) {
+ $linepref = 'none';
+ }
+ $preferences['message_provider_'.$provider->component.'_'.$provider->name.'_'.$state] = $linepref;
}
- if (empty($linepref)) {
- $linepref = 'none';
- }
- $preferences['message_provider_'.$provider->component.'_'.$provider->name.'_'.$state] = $linepref;
}
}

0 comments on commit f6ce2eb

Please sign in to comment.