Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…ecked
  • Loading branch information...
commit 60c468bcb3b6f867a70f2f30427b52e0362e93d1 1 parent f9e27e8
@mouneyrac mouneyrac authored stronk7 committed
Showing with 23 additions and 0 deletions.
  1. +23 −0 admin/registration/register.php
View
23 admin/registration/register.php
@@ -76,6 +76,16 @@
set_config('site_geolocation_' . $cleanhuburl, $fromform->geolocation, 'hub');
set_config('site_contactable_' . $cleanhuburl, $fromform->contactable, '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_usersnumber_' . $cleanhuburl, $fromform->users, 'hub');
set_config('site_roleassignmentsnumber_' . $cleanhuburl, $fromform->roleassignments, 'hub');
@@ -111,6 +121,19 @@
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->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);
Please sign in to comment.
Something went wrong with that request. Please try again.