Skip to content

Commit

Permalink
MDL-59496 registration: display unregistered warning consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed Jul 31, 2017
1 parent d509f80 commit 505bbe7
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 17 deletions.
9 changes: 2 additions & 7 deletions admin/registration/index.php
Expand Up @@ -181,13 +181,8 @@
echo $OUTPUT->header();

//check if the site is registered on Moodle.org and display a message about registering on MOOCH
$registered = $DB->count_records('registration_hubs', array('huburl' => HUB_MOODLEORGHUBURL, 'confirmed' => 1));
if (empty($registered)) {
$warningmsg = get_string('registermoochtips', 'hub');
$warningmsg .= $renderer->single_button(new moodle_url('register.php', array('huburl' => HUB_MOODLEORGHUBURL
, 'hubname' => 'Moodle.org')), get_string('register', 'admin'));
echo $renderer->box($warningmsg, 'buttons mdl-align generalbox adminwarning');
}
$adminrenderer = $PAGE->get_renderer('core', 'admin');
echo $adminrenderer->warn_if_not_registered();

//do not check sesskey if confirm = false because this script is linked into email message
if (!empty($errormessage)) {
Expand Down
4 changes: 3 additions & 1 deletion admin/registration/register.php
Expand Up @@ -189,17 +189,19 @@

// Some Moodle.org registration explanation.
if ($huburl == HUB_MOODLEORGHUBURL) {
$notificationtype = \core\output\notification::NOTIFY_ERROR;
if (!empty($registeredhub->token)) {
if ($registeredhub->timemodified == 0) {
$registrationmessage = get_string('pleaserefreshregistrationunknown', 'admin');
} else {
$lastupdated = userdate($registeredhub->timemodified, get_string('strftimedate', 'langconfig'));
$registrationmessage = get_string('pleaserefreshregistration', 'admin', $lastupdated);
$notificationtype = \core\output\notification::NOTIFY_INFO;
}
} else {
$registrationmessage = get_string('registrationwarning', 'admin');
}
echo $OUTPUT->notification($registrationmessage);
echo $OUTPUT->notification($registrationmessage, $notificationtype);

echo $OUTPUT->heading(get_string('registerwithmoodleorg', 'admin'));
$renderer = $PAGE->get_renderer('core', 'register');
Expand Down
25 changes: 22 additions & 3 deletions admin/renderer.php
Expand Up @@ -782,17 +782,36 @@ protected function registration_warning($registered) {

if (!$registered) {

$registerbutton = $this->single_button(new moodle_url('/admin/registration/register.php',
if (has_capability('moodle/site:config', context_system::instance())) {
$registerbutton = $this->single_button(new moodle_url('/admin/registration/register.php',
array('huburl' => HUB_MOODLEORGHUBURL, 'hubname' => 'Moodle.org')),
get_string('register', 'admin'));
$str = 'registrationwarning';
} else {
$registerbutton = '';
$str = 'registrationwarningcontactadmin';
}

return $this->warning( get_string('registrationwarning', 'admin')
. ' ' . $this->help_icon('registration', 'admin') . $registerbutton );
return $this->warning( get_string($str, 'admin')
. ' ' . $this->help_icon('registration', 'admin') . $registerbutton ,
'error alert alert-danger');
}

return '';
}

/**
* Return an admin page warning if site is not registered with moodle.org
*
* @return string
*/
public function warn_if_not_registered() {
global $CFG;
require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
$registrationmanager = new registration_manager();
return $this->registration_warning($registrationmanager->get_registeredhub(HUB_MOODLEORGHUBURL) ? true : false);
}

/**
* Helper method to render the information about the available Moodle update
*
Expand Down
6 changes: 6 additions & 0 deletions admin/search.php
Expand Up @@ -38,6 +38,12 @@
// to modify them
echo $OUTPUT->header($focus);

// Display a warning if site is not registered.
if (empty($query)) {
$adminrenderer = $PAGE->get_renderer('core', 'admin');
echo $adminrenderer->warn_if_not_registered();
}

echo $OUTPUT->heading(get_string('administrationsite'));

if ($errormsg !== '') {
Expand Down
1 change: 1 addition & 0 deletions lang/en/admin.php
Expand Up @@ -944,6 +944,7 @@
$string['registration'] = 'Registration';
$string['registration_help'] = 'It is recommended that you register your site in order to receive security alerts and access to Moodle.net, our course sharing platform.';
$string['registrationwarning'] = 'Your site is not yet registered.';
$string['registrationwarningcontactadmin'] = 'Your site is not yet registered. Please notify your administrator.';
$string['releasenoteslink'] = 'For information about this version of Moodle, please see the online <a target="_blank" href="{$a}">Release Notes</a>';
$string['rememberusername'] = 'Remember username';
$string['rememberusername_desc'] = 'Enable if you want to store permanent cookies with usernames during user login. Permanent cookies may be considered a privacy issue if used without consent.';
Expand Down
1 change: 1 addition & 0 deletions lang/en/deprecated.txt
Expand Up @@ -60,3 +60,4 @@ error:badjson,core_badges
error:backpackloginfailed,core_badges
signinwithyouremail,core_badges
sectionusedefaultname,core
registermoochtips,core_hub
4 changes: 3 additions & 1 deletion lang/en/hub.php
Expand Up @@ -164,7 +164,6 @@
$string['registeredon'] = 'Where your site is registered';
$string['registereduserdevices'] = 'Number of users with registered mobile devices ({$a})';
$string['registeredactiveuserdevices'] = 'Number of active users with registered mobile devices which are receiving notifications ({$a})';
$string['registermoochtips'] = 'Register your site with Moodle to get security alerts and access to Moodle.net, our course sharing platform.';
$string['registersite'] = 'Register with {$a}';
$string['registerwith'] = 'Register with a hub';
$string['registrationconfirmed'] = 'Site registration confirmed';
Expand Down Expand Up @@ -268,3 +267,6 @@
$string['xmlrpcdisabledcommunity'] = 'The XML-RPC extension is not enabled on the server. You can not search and download courses.';
$string['xmlrpcdisabledpublish'] = 'The XML-RPC extension is not enabled on the server. You can not publish courses or manage published courses.';
$string['xmlrpcdisabledregistration'] = 'The XML-RPC extension is not enabled on the server. You will not be able to unregister or update your registration until you enable it.';

// Deprecated since Moodle 3.4.
$string['registermoochtips'] = 'Register your site with Moodle to get security alerts and access to Moodle.net, our course sharing platform.';
9 changes: 4 additions & 5 deletions message/output/airnotifier/requestaccesskey.php
Expand Up @@ -23,7 +23,6 @@
*/

require('../../../config.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');

define('AIRNOTIFIER_PUBLICURL', 'https://messages.moodle.net');

Expand All @@ -50,10 +49,10 @@
// If we are requesting a key to the official message system, verify first that this site is registered.
// This check is also done in Airnotifier.
if (strpos($CFG->airnotifierurl, AIRNOTIFIER_PUBLICURL) !== false ) {
$registrationmanager = new registration_manager();
if (!$registrationmanager->get_registeredhub(HUB_MOODLEORGHUBURL)) {
$msg = get_string('sitemustberegistered', 'message_airnotifier');
$msg .= $OUTPUT->continue_button($returl);
$adminrenderer = $PAGE->get_renderer('core', 'admin');
$msg = $adminrenderer->warn_if_not_registered();
if ($msg) {
$msg .= html_writer::div(get_string('sitemustberegistered', 'message_airnotifier'));

echo $OUTPUT->header();
echo $OUTPUT->box($msg, 'generalbox');
Expand Down

0 comments on commit 505bbe7

Please sign in to comment.