Skip to content
Browse files

MDL-27171 messages: $defaultpreferences is an object, use isset instead.

Signed-off-by: Ruslan Kabalin <ruslan.kabalin@luns.net.uk>
  • Loading branch information...
1 parent b46ca3d commit e8fc7940a832d47ca315ec1207e3f8084bdee639 Ruslan Kabalin committed
Showing with 9 additions and 9 deletions.
  1. +2 −2 lib/db/upgradelib.php
  2. +4 −4 lib/messagelib.php
  3. +1 −1 message/lib.php
  4. +2 −2 message/renderer.php
View
4 lib/db/upgradelib.php
@@ -668,7 +668,7 @@ function upgrade_populate_default_messaging_prefs() {
// (providers) and outputs (processors)
foreach ($processors as $processor) {
$preferencename = $processor->name.'_provider_'.$componentproviderbase.'_permitted';
- if (!array_key_exists($preferencename, $defaultpreferences)) {
+ if (!isset($defaultpreferences->{$preferencename})) {
$setting->name = $preferencename;
$setting->value = 'permitted';
$DB->insert_record('config_plugins', $setting);
@@ -677,7 +677,7 @@ function upgrade_populate_default_messaging_prefs() {
// for email output we also have to set MESSAGE_DEFAULT_OFFLINE + MESSAGE_DEFAULT_ONLINE
foreach(array('loggedin', 'loggedoff') as $state) {
$preferencename = 'message_provider_'.$componentproviderbase.'_'.$state;
- if (!array_key_exists($preferencename, $defaultpreferences)) {
+ if (!isset($defaultpreferences->{$preferencename})) {
$setting->name = $preferencename;
$setting->value = 'email';
// except instant message where default for popup should be
View
8 lib/messagelib.php
@@ -121,7 +121,7 @@ function message_send($eventdata) {
foreach ($processors as $processor) {
// First find out permissions
$defaultpreference = $processor->name.'_provider_'.$preferencebase.'_permitted';
- if (array_key_exists($defaultpreference, $defaultpreferences)) {
+ if (isset($defaultpreferences->{$defaultpreference})) {
$permitted = $defaultpreferences->{$defaultpreference};
} else {
//MDL-25114 They supplied an $eventdata->component $eventdata->name combination which doesn't
@@ -143,13 +143,13 @@ function message_send($eventdata) {
// We force messages for this processor, so use this processor unconditionally if user has configured it
$processorlist[] = $processor->name;
} else if ($permitted == 'permitted' && $userisconfigured) {
- // User settings are permitted, see if user set any, othervice use site default ones
+ // User settings are permitted, see if user set any, otherwise use site default ones
$userpreferencename = 'message_provider_'.$preferencebase.'_'.$userstate;
if ($userpreference = get_user_preferences($userpreferencename, null, $eventdata->userto->id)) {
if (in_array($processor->name, explode(',', $userpreference))) {
$processorlist[] = $processor->name;
}
- } else if (array_key_exists($userpreferencename, $defaultpreferences)) {
+ } else if (isset($defaultpreferences->{$userpreferencename})) {
if (in_array($processor->name, explode(',', $defaultpreferences->{$userpreferencename}))) {
$processorlist[] = $processor->name;
}
@@ -270,7 +270,7 @@ function message_set_default_message_preference($component, $messagename, $filep
foreach ($processors as $processor) {
$preferencename = $processor->name.'_provider_'.$componentproviderbase.'_permitted';
// if we do not have this setting yet, set it
- if (!array_key_exists($preferencename, $defaultpreferences)) {
+ if (!isset($defaultpreferences->{$preferencename})) {
// determine plugin default settings
$plugindefault = 0;
if (isset($fileprovider['defaults'][$processor->name])) {
View
2 message/lib.php
@@ -2301,7 +2301,7 @@ function get_message_processors($ready = false) {
function get_message_output_default_preferences() {
$preferences = get_config('message');
if (!$preferences) {
- $preferences = (object) array();
+ $preferences = new stdClass();
}
return $preferences;
}
View
4 message/renderer.php
@@ -257,7 +257,7 @@ public function manage_messagingoptions($processors, $providers, $preferences, $
// determine the default setting
$permitted = MESSAGE_DEFAULT_PERMITTED;
$defaultpreference = $processor->name.'_provider_'.$preferencebase.'_permitted';
- if (array_key_exists($defaultpreference, $defaultpreferences)) {
+ if (isset($defaultpreferences->{$defaultpreference})) {
$permitted = $defaultpreferences->{$defaultpreference};
}
// If settings are disallowed, just display the message that
@@ -288,7 +288,7 @@ public function manage_messagingoptions($processors, $providers, $preferences, $
} else {
// User has not set this preference yet, using site default preferences set by admin
$defaultpreference = 'message_provider_'.$preferencebase.'_'.$state;
- if (array_key_exists($defaultpreference, $defaultpreferences)) {
+ if (isset($defaultpreferences->{$defaultpreference})) {
$checked = (int)in_array($processor->name, explode(',', $defaultpreferences->{$defaultpreference}));
}
}

0 comments on commit e8fc794

Please sign in to comment.
Something went wrong with that request. Please try again.