mirror of
https://github.com/moodle/moodle.git
synced 2025-04-25 10:26:17 +02:00
community hub MDL-24215 change the site secret key for get_site_identifier in the registration process => increase the DB field size + change the confirmation form to the get_site_identifier TEXT format
This commit is contained in:
parent
58d89c2467
commit
56c6138029
@ -41,7 +41,7 @@ require_once($CFG->dirroot . '/admin/registration/lib.php');
|
||||
$newtoken = optional_param('newtoken', '', PARAM_ALPHANUM);
|
||||
$url = optional_param('url', '', PARAM_URL);
|
||||
$hubname = optional_param('hubname', '', PARAM_TEXT);
|
||||
$token = optional_param('token', '', PARAM_ALPHANUM);
|
||||
$token = optional_param('token', '', PARAM_TEXT);
|
||||
$error = optional_param('error', '', PARAM_ALPHANUM);
|
||||
|
||||
$PAGE->navbar->ignore_active(true);
|
||||
@ -52,6 +52,10 @@ $PAGE->navbar->add(get_string('registrationconfirmed', 'hub'));
|
||||
|
||||
admin_externalpage_setup('siteregistrationconfirmed');
|
||||
|
||||
if (!empty($error) and $error == 'urlalreadyexist') {
|
||||
throw new moodle_exception('urlalreadyregistered', 'hub', $CFG->wwwroot . '/admin/registration/index.php');
|
||||
}
|
||||
|
||||
//check that we are waiting a confirmation from this hub, and check that the token is correct
|
||||
$registrationmanager = new registration_manager();
|
||||
$registeredhub = $registrationmanager->get_unconfirmedhub($url);
|
||||
@ -61,16 +65,12 @@ if (!empty($registeredhub) and $registeredhub->token == $token) {
|
||||
echo $OUTPUT->heading(get_string('registrationconfirmed', 'hub'), 3, 'main');
|
||||
$hublink = html_writer::tag('a', $hubname, array('href' => $url));
|
||||
|
||||
if (!empty($error) and $error == 'urlalreadyexist') {
|
||||
$notificationmessage = $OUTPUT->notification(get_string('urlalreadyregistered', 'hub', $hublink));
|
||||
} else {
|
||||
$registeredhub->token = $newtoken;
|
||||
$registeredhub->confirmed = 1;
|
||||
$registeredhub->hubname = $hubname;
|
||||
$registrationmanager->update_registeredhub($registeredhub);
|
||||
$registeredhub->token = $newtoken;
|
||||
$registeredhub->confirmed = 1;
|
||||
$registeredhub->hubname = $hubname;
|
||||
$registrationmanager->update_registeredhub($registeredhub);
|
||||
|
||||
$notificationmessage = $OUTPUT->notification(get_string('registrationconfirmedon', 'hub', $hublink), 'notifysuccess');
|
||||
}
|
||||
$notificationmessage = $OUTPUT->notification(get_string('registrationconfirmedon', 'hub', $hublink), 'notifysuccess');
|
||||
|
||||
echo $notificationmessage;
|
||||
|
||||
|
@ -133,7 +133,7 @@ if (!empty($fromform) and empty($update) and confirm_sesskey()) {
|
||||
if (empty($unconfirmedhub)) {
|
||||
//we save the token into the communication table in order to have a reference
|
||||
$unconfirmedhub = new stdClass();
|
||||
$unconfirmedhub->token = md5(uniqid(rand(), 1));
|
||||
$unconfirmedhub->token = get_site_identifier();
|
||||
$unconfirmedhub->huburl = $huburl;
|
||||
$unconfirmedhub->hubname = $hubname;
|
||||
$unconfirmedhub->confirmed = 0;
|
||||
|
@ -260,7 +260,7 @@ $string['updatesite'] = 'Update registration on {$a}';
|
||||
$string['updatestatus'] = 'Check it now.';
|
||||
$string['uploaded'] = 'Uploaded';
|
||||
$string['url'] = 'hub URL';
|
||||
$string['urlalreadyregistered'] = 'Your site seems to be already registered on {$a}, which means something has gone wrong. Please contact the hub administrator to reset your registration so you can try again.';
|
||||
$string['urlalreadyregistered'] = 'Your site seems to be already registered on this hub, which means something has gone wrong. Please contact the hub administrator to reset your registration so you can try again.';
|
||||
$string['usersnumber'] = 'Number of users ({$a})';
|
||||
$string['warning'] = 'WARNING';
|
||||
$string['wrongtoken'] = 'The registration failed for some unknown reason (network?). Please try again.';
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="lib/db" VERSION="20100806" COMMENT="XMLDB file for core Moodle tables"
|
||||
<XMLDB PATH="lib/db" VERSION="20100915" COMMENT="XMLDB file for core Moodle tables"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
@ -2608,7 +2608,7 @@
|
||||
<TABLE NAME="registration_hubs" COMMENT="hub where the site is registered on with their associated token" PREVIOUS="license" NEXT="backup_controllers">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="token"/>
|
||||
<FIELD NAME="token" TYPE="char" LENGTH="40" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="hubname"/>
|
||||
<FIELD NAME="token" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="hubname"/>
|
||||
<FIELD NAME="hubname" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="token" NEXT="huburl"/>
|
||||
<FIELD NAME="huburl" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="hubname" NEXT="confirmed"/>
|
||||
<FIELD NAME="confirmed" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="huburl"/>
|
||||
@ -2713,4 +2713,4 @@
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</XMLDB>
|
||||
</XMLDB>
|
@ -5144,6 +5144,18 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
upgrade_main_savepoint(true, 2010091303);
|
||||
}
|
||||
|
||||
if ($oldversion < 2010091500) {
|
||||
|
||||
// Changing precision of field token on table registration_hubs to (255)
|
||||
$table = new xmldb_table('registration_hubs');
|
||||
$field = new xmldb_field('token', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'id');
|
||||
|
||||
// Launch change of precision for field token
|
||||
$dbman->change_field_precision($table, $field);
|
||||
|
||||
// Main savepoint reached
|
||||
upgrade_main_savepoint(true, 2010091500);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2010091303; // YYYYMMDD = date of the last version bump
|
||||
$version = 2010091500; // YYYYMMDD = date of the last version bump
|
||||
// XX = daily increments
|
||||
|
||||
$release = '2.0 Preview 4+ (Build: 20100915)'; // Human-friendly version name
|
||||
|
Loading…
x
Reference in New Issue
Block a user