MDL-30544 message: prevented the temporarily disable notifications checkbox from erasing your messaging preferences

This commit is contained in:
Andrew Davis
2011-12-01 17:00:01 +08:00
parent 50ce778ad8
commit dcae2f3a6a
+20 -16
View File
@@ -107,25 +107,29 @@ if (($form = data_submitted()) && confirm_sesskey()) {
$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;
}
}