2010-05-01 05:05:55 +00:00
|
|
|
<?php
|
2010-06-25 11:36:52 +00:00
|
|
|
|
2010-05-01 05:05:55 +00:00
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2017-09-12 15:20:03 +08:00
|
|
|
/**
|
2010-05-01 05:05:55 +00:00
|
|
|
* @package moodle
|
|
|
|
* @subpackage registration
|
|
|
|
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
|
|
|
|
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
|
|
|
|
*
|
2019-10-01 22:50:34 +02:00
|
|
|
* This page displays the site registration form.
|
2017-09-12 15:20:03 +08:00
|
|
|
* It handles redirection to the hub to continue the registration workflow process.
|
|
|
|
* It also handles update operation by web service.
|
2010-06-25 11:36:52 +00:00
|
|
|
*/
|
2010-05-01 05:05:55 +00:00
|
|
|
|
2017-09-12 15:20:03 +08:00
|
|
|
require_once('../../config.php');
|
2010-06-25 11:36:52 +00:00
|
|
|
require_once($CFG->libdir . '/adminlib.php');
|
2010-05-01 05:05:55 +00:00
|
|
|
|
2017-09-12 15:20:03 +08:00
|
|
|
admin_externalpage_setup('registrationmoodleorg');
|
2010-05-01 05:05:55 +00:00
|
|
|
|
2019-10-02 21:57:01 +02:00
|
|
|
$unregistration = optional_param('unregistration', false, PARAM_BOOL);
|
|
|
|
$confirm = optional_param('confirm', false, PARAM_BOOL);
|
2010-06-25 11:36:52 +00:00
|
|
|
|
2017-09-12 15:20:03 +08:00
|
|
|
if ($unregistration && \core\hub\registration::is_registered()) {
|
2019-10-02 21:57:01 +02:00
|
|
|
if ($confirm) {
|
|
|
|
require_sesskey();
|
|
|
|
\core\hub\registration::unregister(false, false);
|
2010-06-25 11:36:52 +00:00
|
|
|
|
2018-06-06 12:54:50 +08:00
|
|
|
if (!\core\hub\registration::is_registered()) {
|
2017-09-12 15:20:03 +08:00
|
|
|
redirect(new moodle_url('/admin/registration/index.php'));
|
2010-06-25 11:36:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-12 15:20:03 +08:00
|
|
|
echo $OUTPUT->header();
|
2019-10-02 21:57:01 +02:00
|
|
|
echo $OUTPUT->confirm(
|
|
|
|
get_string('registerwithmoodleorgremove', 'core_hub'),
|
|
|
|
new moodle_url(new moodle_url('/admin/registration/index.php', ['unregistration' => 1, 'confirm' => 1])),
|
|
|
|
new moodle_url(new moodle_url('/admin/registration/index.php'))
|
|
|
|
);
|
2017-09-12 15:20:03 +08:00
|
|
|
echo $OUTPUT->footer();
|
|
|
|
exit;
|
2010-06-25 11:36:52 +00:00
|
|
|
}
|
|
|
|
|
2017-09-22 13:16:57 +08:00
|
|
|
$isinitialregistration = \core\hub\registration::show_after_install(true);
|
|
|
|
if (!$returnurl = optional_param('returnurl', null, PARAM_LOCALURL)) {
|
|
|
|
$returnurl = $isinitialregistration ? '/admin/index.php' : '/admin/registration/index.php';
|
|
|
|
}
|
|
|
|
|
2017-09-12 15:20:03 +08:00
|
|
|
$siteregistrationform = new \core\hub\site_registration_form();
|
2017-09-22 13:16:57 +08:00
|
|
|
$siteregistrationform->set_data(['returnurl' => $returnurl]);
|
2017-09-12 15:20:03 +08:00
|
|
|
if ($fromform = $siteregistrationform->get_data()) {
|
2012-06-04 19:22:06 +08:00
|
|
|
|
2017-09-12 15:20:03 +08:00
|
|
|
// Save the settings.
|
|
|
|
\core\hub\registration::save_site_info($fromform);
|
2012-06-04 19:22:06 +08:00
|
|
|
|
2017-09-12 15:20:03 +08:00
|
|
|
if (\core\hub\registration::is_registered()) {
|
2017-09-22 13:16:57 +08:00
|
|
|
if (\core\hub\registration::update_manual()) {
|
|
|
|
redirect(new moodle_url($returnurl));
|
|
|
|
}
|
|
|
|
redirect(new moodle_url('/admin/registration/index.php', ['returnurl' => $returnurl]));
|
2010-06-25 11:36:52 +00:00
|
|
|
} else {
|
2017-09-22 13:16:57 +08:00
|
|
|
\core\hub\registration::register($returnurl);
|
2017-09-12 15:20:03 +08:00
|
|
|
// This method will redirect away.
|
2010-06-25 11:36:52 +00:00
|
|
|
}
|
2012-06-04 19:22:06 +08:00
|
|
|
|
2017-09-12 15:20:03 +08:00
|
|
|
}
|
2012-06-04 19:22:06 +08:00
|
|
|
|
2017-09-12 15:20:03 +08:00
|
|
|
// OUTPUT SECTION.
|
2012-06-04 19:22:06 +08:00
|
|
|
|
2017-09-12 15:20:03 +08:00
|
|
|
echo $OUTPUT->header();
|
2012-06-04 19:22:06 +08:00
|
|
|
|
2019-10-01 22:50:34 +02:00
|
|
|
// Current status of registration.
|
2012-06-04 19:22:06 +08:00
|
|
|
|
2017-09-12 15:20:03 +08:00
|
|
|
$notificationtype = \core\output\notification::NOTIFY_ERROR;
|
|
|
|
if (\core\hub\registration::is_registered()) {
|
|
|
|
$lastupdated = \core\hub\registration::get_last_updated();
|
|
|
|
if ($lastupdated == 0) {
|
|
|
|
$registrationmessage = get_string('pleaserefreshregistrationunknown', 'admin');
|
2017-09-22 13:16:57 +08:00
|
|
|
} else if (\core\hub\registration::get_new_registration_fields()) {
|
|
|
|
$registrationmessage = get_string('pleaserefreshregistrationnewdata', 'admin');
|
2017-09-12 15:20:03 +08:00
|
|
|
} else {
|
|
|
|
$lastupdated = userdate($lastupdated, get_string('strftimedate', 'langconfig'));
|
|
|
|
$registrationmessage = get_string('pleaserefreshregistration', 'admin', $lastupdated);
|
|
|
|
$notificationtype = \core\output\notification::NOTIFY_INFO;
|
2012-06-04 19:22:06 +08:00
|
|
|
}
|
2017-09-12 15:20:03 +08:00
|
|
|
echo $OUTPUT->notification($registrationmessage, $notificationtype);
|
2017-09-22 13:16:57 +08:00
|
|
|
} else if (!$isinitialregistration) {
|
2017-09-12 15:20:03 +08:00
|
|
|
$registrationmessage = get_string('registrationwarning', 'admin');
|
|
|
|
echo $OUTPUT->notification($registrationmessage, $notificationtype);
|
|
|
|
}
|
2012-06-04 19:22:06 +08:00
|
|
|
|
2017-09-12 15:20:03 +08:00
|
|
|
// Heading.
|
|
|
|
if (\core\hub\registration::is_registered()) {
|
2019-10-01 22:50:34 +02:00
|
|
|
echo $OUTPUT->heading(get_string('registerwithmoodleorgupdate', 'core_hub'));
|
2017-09-22 13:16:57 +08:00
|
|
|
} else if ($isinitialregistration) {
|
2019-10-01 22:50:34 +02:00
|
|
|
echo $OUTPUT->heading(get_string('registerwithmoodleorgcomplete', 'core_hub'));
|
2017-09-12 15:20:03 +08:00
|
|
|
} else {
|
2019-10-01 22:50:34 +02:00
|
|
|
echo $OUTPUT->heading(get_string('registerwithmoodleorg', 'core_hub'));
|
2017-09-12 15:20:03 +08:00
|
|
|
}
|
2012-06-04 19:22:06 +08:00
|
|
|
|
2018-05-02 23:22:13 +08:00
|
|
|
$renderer = $PAGE->get_renderer('core', 'admin');
|
2017-09-12 15:20:03 +08:00
|
|
|
echo $renderer->moodleorg_registration_message();
|
2010-07-02 03:40:12 +00:00
|
|
|
|
2017-09-12 15:20:03 +08:00
|
|
|
$siteregistrationform->display();
|
|
|
|
|
|
|
|
if (\core\hub\registration::is_registered()) {
|
|
|
|
// Unregister link.
|
|
|
|
$unregisterhuburl = new moodle_url("/admin/registration/index.php", ['unregistration' => 1]);
|
2019-10-02 21:57:01 +02:00
|
|
|
echo html_writer::div(html_writer::link($unregisterhuburl, get_string('unregister', 'hub')), 'unregister mt-2');
|
2017-09-22 13:16:57 +08:00
|
|
|
} else if ($isinitialregistration) {
|
2019-10-02 21:57:01 +02:00
|
|
|
echo html_writer::div(html_writer::link(new moodle_url($returnurl), get_string('skipregistration', 'hub')),
|
|
|
|
'skipregistration mt-2');
|
2010-06-25 11:36:52 +00:00
|
|
|
}
|
2010-05-04 13:04:35 +00:00
|
|
|
echo $OUTPUT->footer();
|