MDL-44342 airnotifier: Change default Airnotifier url to use SSL
authorJuan Leyva <juanleyvadelgado@gmail.com>
Wed, 9 Apr 2014 09:47:45 +0000 (11:47 +0200)
committerDamyon Wiese <damyon@moodle.com>
Thu, 10 Apr 2014 01:25:32 +0000 (09:25 +0800)
This commit include also a fix for checking forced settings

message/output/airnotifier/classes/manager.php
message/output/airnotifier/externallib.php
message/output/airnotifier/requestaccesskey.php
message/output/airnotifier/settings.php

index e08b5cf..f395c28 100755 (executable)
@@ -43,10 +43,6 @@ class message_airnotifier_manager {
     public function include_device_ajax() {
         global $PAGE, $CFG;
 
-        if (!$CFG->enableajax) {
-            return false;
-        }
-
         $config = new stdClass();
         $config->resturl = '/message/output/airnotifier/rest.php';
         $config->pageparams = array();
index dbe89d5..56a23a9 100755 (executable)
@@ -150,24 +150,26 @@ class message_airnotifier_external extends external_api {
                     }
 
                     foreach (array('loggedin', 'loggedoff') as $state) {
-                        if ($configured) {
-                            break;
-                        }
 
+                        $prefstocheck = array();
                         $prefname = 'message_provider_'.$provider->component.'_'.$provider->name.'_'.$state;
-                        $linepref = get_user_preferences($prefname, '', $user->id);
-                        if ($linepref == '') {
-                            continue;
+
+                        // First get forced settings.
+                        if ($forcedpref = get_config('message', $prefname)) {
+                            $prefstocheck = explode(',', $forcedpref);
+                        }
+
+                        // Then get user settings.
+                        if ($userpref = get_user_preferences($prefname, '', $user->id)) {
+                            $prefstocheck += explode(',', $userpref);
                         }
-                        $lineprefarray = explode(',', $linepref);
-
-                        foreach ($lineprefarray as $pref) {
-                            if ($pref == 'airnotifier') {
-                                $preferences['configured'] = 1;
-                                $configured = true;
-                                break;
-                            }
+
+                        if (in_array('airnotifier', $prefstocheck)) {
+                            $preferences['configured'] = 1;
+                            $configured = true;
+                            break;
                         }
+
                     }
                 }
 
index 457832d..0b5ff28 100755 (executable)
@@ -25,7 +25,7 @@
 require('../../../config.php');
 require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
 
-define('AIRNOTIFIER_PUBLICURL', 'http://messages.moodle.net');
+define('AIRNOTIFIER_PUBLICURL', 'https://messages.moodle.net');
 
 $PAGE->set_url(new moodle_url('/message/output/airnotifier/requestaccesskey.php'));
 $PAGE->set_context(context_system::instance());
index d788f75..5eaed4a 100755 (executable)
@@ -27,7 +27,7 @@ if ($ADMIN->fulltree) {
     // The processor should be enabled by the same enable mobile setting.
     $settings->add(new admin_setting_configtext('airnotifierurl',
                     get_string('airnotifierurl', 'message_airnotifier'),
-                    get_string('configairnotifierurl', 'message_airnotifier'), 'http://messages.moodle.net', PARAM_URL));
+                    get_string('configairnotifierurl', 'message_airnotifier'), 'https://messages.moodle.net', PARAM_URL));
     $settings->add(new admin_setting_configtext('airnotifierport',
                     get_string('airnotifierport', 'message_airnotifier'),
                     get_string('configairnotifierport', 'message_airnotifier'), '80', PARAM_INT));