Skip to content

Commit

Permalink
MDL-37822 move the default code above the set_config to not make the …
Browse files Browse the repository at this point in the history
…code less confusing
  • Loading branch information
mouneyrac authored and stronk7 committed May 9, 2013
1 parent 667eaec commit 1fc34e3
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions admin/registration/register.php
Expand Up @@ -62,7 +62,18 @@
$fromform = $siteregistrationform->get_data(); $fromform = $siteregistrationform->get_data();


if (!empty($fromform) and confirm_sesskey()) { if (!empty($fromform) and confirm_sesskey()) {
//save the settings
// Set to -1 all optional data marked as "don't send" by the admin.
// The function get_site_info() will not calculate the optional data if config is set to -1.
$inputnames = array('courses', 'users', 'roleassignments', 'posts', 'questions', 'resources',
'modulenumberaverage', 'participantnumberaverage');
foreach ($inputnames as $inputname) {
if (empty($fromform->{$inputname})) {
$fromform->{$inputname} = -1;
}
}

// Save the settings.
$cleanhuburl = clean_param($huburl, PARAM_ALPHANUMEXT); $cleanhuburl = clean_param($huburl, PARAM_ALPHANUMEXT);
set_config('site_name_' . $cleanhuburl, $fromform->name, 'hub'); set_config('site_name_' . $cleanhuburl, $fromform->name, 'hub');
set_config('site_description_' . $cleanhuburl, $fromform->description, 'hub'); set_config('site_description_' . $cleanhuburl, $fromform->description, 'hub');
Expand All @@ -78,16 +89,6 @@
set_config('site_geolocation_' . $cleanhuburl, $fromform->geolocation, 'hub'); set_config('site_geolocation_' . $cleanhuburl, $fromform->geolocation, 'hub');
set_config('site_contactable_' . $cleanhuburl, $fromform->contactable, 'hub'); set_config('site_contactable_' . $cleanhuburl, $fromform->contactable, 'hub');
set_config('site_emailalert_' . $cleanhuburl, $fromform->emailalert, 'hub'); set_config('site_emailalert_' . $cleanhuburl, $fromform->emailalert, 'hub');

// Set to -1 all optional data marked as "don't send" by the admin.
// The function get_site_info() will not calculate the optional data if config is set to -1.
$inputnames = array('courses', 'users', 'roleassignments', 'posts', 'questions', 'resources',
'modulenumberaverage', 'participantnumberaverage');
foreach ($inputnames as $inputname) {
if (empty($fromform->{$inputname})) {
$fromform->{$inputname} = -1;
}
}
set_config('site_coursesnumber_' . $cleanhuburl, $fromform->courses, 'hub'); set_config('site_coursesnumber_' . $cleanhuburl, $fromform->courses, 'hub');
set_config('site_usersnumber_' . $cleanhuburl, $fromform->users, 'hub'); set_config('site_usersnumber_' . $cleanhuburl, $fromform->users, 'hub');
set_config('site_roleassignmentsnumber_' . $cleanhuburl, $fromform->roleassignments, 'hub'); set_config('site_roleassignmentsnumber_' . $cleanhuburl, $fromform->roleassignments, 'hub');
Expand Down

0 comments on commit 1fc34e3

Please sign in to comment.