Browse files

MDL-37822 Moodle send site information to a hub even though it's unch…

…ecked
  • Loading branch information...
1 parent 919a8db commit 669dee58048b18d9034a7b2367b97a50b498b0e0 @mouneyrac mouneyrac committed with stronk7 May 7, 2013
Showing with 41 additions and 13 deletions.
  1. +14 −12 admin/registration/forms.php
  2. +27 −1 admin/registration/register.php
View
26 admin/registration/forms.php
@@ -244,9 +244,11 @@ public function definition() {
$postsnumber = get_config('hub', 'site_postsnumber_' . $cleanhuburl);
$questionsnumber = get_config('hub', 'site_questionsnumber_' . $cleanhuburl);
$resourcesnumber = get_config('hub', 'site_resourcesnumber_' . $cleanhuburl);
- $badges = get_config('hub', 'site_badges_' . $cleanhuburl);
- $issuedbadges = get_config('hub', 'site_issuedbadges_' . $cleanhuburl);
+ $badgesnumber = get_config('hub', 'site_badges_' . $cleanhuburl);
+ $issuedbadgesnumber = get_config('hub', 'site_issuedbadges_' . $cleanhuburl);
$mediancoursesize = get_config('hub', 'site_mediancoursesize_' . $cleanhuburl);
+ $participantnumberaveragecfg = get_config('hub', 'site_participantnumberaverage_' . $cleanhuburl);
+ $modulenumberaveragecfg = get_config('hub', 'site_modulenumberaverage_' . $cleanhuburl);
//hidden parameters
$mform->addElement('hidden', 'huburl', $huburl);
@@ -387,53 +389,53 @@ public function definition() {
if (HUB_MOODLEORGHUBURL != $huburl) {
$mform->addElement('checkbox', 'courses', get_string('sendfollowinginfo', 'hub'),
" " . get_string('coursesnumber', 'hub', $coursecount));
- $mform->setDefault('courses', 1);
+ $mform->setDefault('courses', $coursesnumber != -1);
$mform->setType('courses', PARAM_INT);
$mform->addHelpButton('courses', 'sendfollowinginfo', 'hub');
$mform->addElement('checkbox', 'users', '',
" " . get_string('usersnumber', 'hub', $usercount));
- $mform->setDefault('users', 1);
+ $mform->setDefault('users', $usersnumber != -1);
$mform->setType('users', PARAM_INT);
$mform->addElement('checkbox', 'roleassignments', '',
" " . get_string('roleassignmentsnumber', 'hub', $roleassigncount));
- $mform->setDefault('roleassignments', 1);
+ $mform->setDefault('roleassignments', $roleassignmentsnumber != -1);
$mform->setType('roleassignments', PARAM_INT);
$mform->addElement('checkbox', 'posts', '',
" " . get_string('postsnumber', 'hub', $postcount));
- $mform->setDefault('posts', 1);
+ $mform->setDefault('posts', $postsnumber != -1);
$mform->setType('posts', PARAM_INT);
$mform->addElement('checkbox', 'questions', '',
" " . get_string('questionsnumber', 'hub', $questioncount));
- $mform->setDefault('questions', 1);
+ $mform->setDefault('questions', $questionsnumber != -1);
$mform->setType('questions', PARAM_INT);
$mform->addElement('checkbox', 'resources', '',
" " . get_string('resourcesnumber', 'hub', $resourcecount));
- $mform->setDefault('resources', 1);
+ $mform->setDefault('resources', $resourcesnumber != -1);
$mform->setType('resources', PARAM_INT);
$mform->addElement('checkbox', 'badges', '',
" " . get_string('badgesnumber', 'hub', $badges));
- $mform->setDefault('badges', 1);
+ $mform->setDefault('badges', $badgesnumber != -1);
$mform->setType('resources', PARAM_INT);
$mform->addElement('checkbox', 'issuedbadges', '',
" " . get_string('issuedbadgesnumber', 'hub', $issuedbadges));
- $mform->setDefault('issuedbadges', 1);
+ $mform->setDefault('issuedbadges', $issuedbadgesnumber != -1);
$mform->setType('resources', PARAM_INT);
$mform->addElement('checkbox', 'participantnumberaverage', '',
" " . get_string('participantnumberaverage', 'hub', $participantnumberaverage));
- $mform->setDefault('participantnumberaverage', 1);
+ $mform->setDefault('participantnumberaverage', $participantnumberaveragecfg != -1);
$mform->setType('participantnumberaverage', PARAM_FLOAT);
$mform->addElement('checkbox', 'modulenumberaverage', '',
" " . get_string('modulenumberaverage', 'hub', $modulenumberaverage));
- $mform->setDefault('modulenumberaverage', 1);
+ $mform->setDefault('modulenumberaverage', $modulenumberaveragecfg != -1);
$mform->setType('modulenumberaverage', PARAM_FLOAT);
} else {
$mform->addElement('static', 'courseslabel', get_string('sendfollowinginfo', 'hub'),
View
28 admin/registration/register.php
@@ -62,7 +62,18 @@
$fromform = $siteregistrationform->get_data();
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',
+ 'badges', 'issuedbadges', 'modulenumberaverage', 'participantnumberaverage');
+ foreach ($inputnames as $inputname) {
+ if (empty($fromform->{$inputname})) {
+ $fromform->{$inputname} = -1;
+ }
+ }
+
+ // Save the settings.
$cleanhuburl = clean_param($huburl, PARAM_ALPHANUMEXT);
set_config('site_name_' . $cleanhuburl, $fromform->name, 'hub');
set_config('site_description_' . $cleanhuburl, $fromform->description, 'hub');
@@ -115,6 +126,21 @@
if (!empty($fromform) and empty($update) and confirm_sesskey()) {
if (!empty($fromform) and confirm_sesskey()) { // if the register button has been clicked
+
+ // Retrieve the optional info (specially course number, user number, module number average...).
+ $siteinfo = $registrationmanager->get_site_info($huburl);
+ $fromform->courses = $siteinfo['courses'];
+ $fromform->users = $siteinfo['users'];
+ $fromform->enrolments = $siteinfo['enrolments'];
+ $fromform->posts = $siteinfo['posts'];
+ $fromform->questions = $siteinfo['questions'];
+ $fromform->resources = $siteinfo['resources'];
+ $fromform->badges = $siteinfo['badges'];
+ $fromform->issuedbadges = $siteinfo['issuedbadges'];
+ $fromform->modulenumberaverage = $siteinfo['modulenumberaverage'];
+ $fromform->participantnumberaverage = $siteinfo['participantnumberaverage'];
+ $fromform->street = $siteinfo['street'];
+
$params = (array) $fromform; //we are using the form input as the redirection parameters (token, url and name)
$unconfirmedhub = $registrationmanager->get_unconfirmedhub($huburl);

0 comments on commit 669dee5

Please sign in to comment.