Merge branch 'MDL-67907-master' of git://github.com/dpalou/moodle

This commit is contained in:
Adrian Greeve 2020-03-17 16:01:26 +08:00
commit 1f0639ed04
2 changed files with 40 additions and 2 deletions

View File

@ -35,6 +35,7 @@ $string['configairnotifiermobileappname'] = 'The Mobile app unique identifier (u
$string['deletecheckdevicename'] = 'Delete your device: {$a->name}';
$string['deletedevice'] = 'Delete the device. Note that an app can register the device again. If the device keeps reappearing, disable it.';
$string['devicetoken'] = 'Device token';
$string['enableprocessor'] = 'Enable Mobile notifications.';
$string['errorretrievingkey'] = 'An error occurred while retrieving the access key. Your site must be registered to use this service. If your site is already registered, please try updating your registration.';
$string['keyretrievedsuccessfully'] = 'Key retrieved successfully';
$string['nodevices'] = 'No registered devices. Devices will automatically appear after you install the Moodle app and add this site.';

View File

@ -62,12 +62,49 @@ if (strpos($CFG->airnotifierurl, AIRNOTIFIER_PUBLICURL) !== false ) {
}
$manager = new message_airnotifier_manager();
$warnings = [];
if ($key = $manager->request_accesskey()) {
set_config('airnotifieraccesskey', $key);
$msg = get_string('keyretrievedsuccessfully', 'message_airnotifier');
$msg = $OUTPUT->box(get_string('keyretrievedsuccessfully', 'message_airnotifier'), 'generalbox alert alert-success');
// Check mobile notifications.
$processors = get_message_processors();
$enabled = false;
foreach ($processors as $processor => $status) {
if ($processor == 'airnotifier' && $status->enabled) {
$enabled = true;
}
}
if (!$enabled) {
// Airnotifier processor isn't enabled. Warn the user.
$warnings[] = [
'msg' => get_string('mobilenotificationsdisabledwarning', 'tool_mobile'),
'linkmsg' => get_string('enableprocessor', 'message_airnotifier'),
'linkurl' => new moodle_url('/admin/message.php'),
];
}
if (empty($CFG->enablemobilewebservice)) {
// Mobile web services not enabled. Warn the user.
$warnings[] = [
'msg' => get_string('mobilenotconfiguredwarning', 'admin'),
'linkmsg' => get_string('enablemobilewebservice', 'admin'),
'linkurl' => new moodle_url('/admin/settings.php', ['section' => 'mobilesettings']),
];
}
} else {
$msg = get_string('errorretrievingkey', 'message_airnotifier');
$msg = $OUTPUT->box(get_string('errorretrievingkey', 'message_airnotifier'), 'generalbox alert alert-danger');
}
// Display the warnings.
foreach ($warnings as $warning) {
if (!empty($warning['linkurl'])) {
$warning['msg'] = $warning['msg'] . ' ' . html_writer::tag('a', $warning['linkmsg'], ['href' => $warning['linkurl']]);
}
$msg .= $OUTPUT->box($warning['msg'], 'generalbox alert alert-warning');
}
$msg .= $OUTPUT->continue_button($returl);