on demand release 2.5beta+
[moodle.git] / admin / registration / forms.php
CommitLineData
07ab0c80 1<?php
2c9bb9c3 2
07ab0c80 3///////////////////////////////////////////////////////////////////////////
4// //
5// This file is part of Moodle - http://moodle.org/ //
6// Moodle - Modular Object-Oriented Dynamic Learning Environment //
7// //
8// Moodle is free software: you can redistribute it and/or modify //
9// it under the terms of the GNU General Public License as published by //
10// the Free Software Foundation, either version 3 of the License, or //
11// (at your option) any later version. //
12// //
13// Moodle is distributed in the hope that it will be useful, //
14// but WITHOUT ANY WARRANTY; without even the implied warranty of //
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
16// GNU General Public License for more details. //
17// //
18// You should have received a copy of the GNU General Public License //
19// along with Moodle. If not, see <http://www.gnu.org/licenses/>. //
20// //
21///////////////////////////////////////////////////////////////////////////
22
23/*
24 * @package moodle
25 * @subpackage registration
26 * @author Jerome Mouneyrac <jerome@mouneyrac.com>
27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL
28 * @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
29 *
30 * The forms needed by registration pages.
2c9bb9c3 31 */
07ab0c80 32
33
a8e174cc 34require_once($CFG->libdir . '/formslib.php');
35require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
07ab0c80 36
f57c4047 37/**
38 * This form display a unregistration form.
39 */
40class site_unregistration_form extends moodleform {
41
42 public function definition() {
43 $mform = & $this->_form;
44 $mform->addElement('header', 'site', get_string('unregister', 'hub'));
45
46 $huburl = $this->_customdata['huburl'];
47 $hubname = $this->_customdata['hubname'];
48
49 $unregisterlabel = get_string('unregister', 'hub');
50 $mform->addElement('checkbox', 'unpublishalladvertisedcourses', '',
51 ' ' . get_string('unpublishalladvertisedcourses', 'hub'));
52 $mform->addElement('checkbox', 'unpublishalluploadedcourses', '',
53 ' ' . get_string('unpublishalluploadedcourses', 'hub'));
54
55 $mform->addElement('hidden', 'confirm', 1);
f8758d68 56 $mform->setType('confirm', PARAM_INT);
f57c4047 57 $mform->addElement('hidden', 'unregistration', 1);
f8758d68 58 $mform->setType('unregistration', PARAM_INT);
f57c4047 59 $mform->addElement('hidden', 'huburl', $huburl);
f8758d68 60 $mform->setType('huburl', PARAM_URL);
f57c4047 61 $mform->addElement('hidden', 'hubname', $hubname);
f8758d68 62 $mform->setType('hubname', PARAM_TEXT);
f57c4047 63
64 $this->add_action_buttons(true, $unregisterlabel);
65 }
66
67}
68
69/**
70 * This form display a clean registration data form.
71 */
72class site_clean_registration_data_form extends moodleform {
73
74 public function definition() {
75 $mform = & $this->_form;
76 $mform->addElement('header', 'site', get_string('unregister', 'hub'));
77
78 $huburl = $this->_customdata['huburl'];
79 $hubname = $this->_customdata['hubname'];
80
81
82 $unregisterlabel = get_string('forceunregister', 'hub');
83 $mform->addElement('static', '', get_string('warning', 'hub'), get_string('forceunregisterconfirmation', 'hub', $hubname));
84
85
86 $mform->addElement('hidden', 'confirm', 1);
f8758d68 87 $mform->setType('confirm', PARAM_INT);
f57c4047 88 $mform->addElement('hidden', 'unregistration', 1);
f8758d68 89 $mform->setType('unregistration', PARAM_INT);
f57c4047 90 $mform->addElement('hidden', 'cleanregdata', 1);
f8758d68 91 $mform->setType('cleanregdata', PARAM_INT);
f57c4047 92 $mform->addElement('hidden', 'huburl', $huburl);
f8758d68 93 $mform->setType('huburl', PARAM_URL);
f57c4047 94 $mform->addElement('hidden', 'hubname', $hubname);
f8758d68 95 $mform->setType('hubname', PARAM_TEXT);
f57c4047 96
97 $this->add_action_buttons(true, $unregisterlabel);
98 }
99
100}
101
07ab0c80 102/**
103 * This form display a hub selector.
104 * The hub list is retrieved from Moodle.org hub directory.
105 * Also displayed, a text field to enter private hub url + its password
106 */
107class hub_selector_form extends moodleform {
108
109 public function definition() {
2c9bb9c3 110 global $CFG, $OUTPUT;
111 $mform = & $this->_form;
07ab0c80 112 $mform->addElement('header', 'site', get_string('selecthub', 'hub'));
113
114 //retrieve the hub list on the hub directory by web service
115 $function = 'hubdirectory_get_hubs';
116 $params = array();
2c9bb9c3 117 $serverurl = HUB_HUBDIRECTORYURL . "/local/hubdirectory/webservice/webservices.php";
118 require_once($CFG->dirroot . "/webservice/xmlrpc/lib.php");
001251f2 119 $xmlrpcclient = new webservice_xmlrpc_client($serverurl, 'publichubdirectory');
2c9bb9c3 120 try {
001251f2 121 $hubs = $xmlrpcclient->call($function, $params);
2c9bb9c3 122 } catch (Exception $e) {
123 $error = $OUTPUT->notification(get_string('errorhublisting', 'hub', $e->getMessage()));
124 $mform->addElement('static', 'errorhub', '', $error);
125 $hubs = array();
126 }
07ab0c80 127
a33cc71f 128 //remove moodle.org from the hub list
129 foreach ($hubs as $key => $hub) {
06d4578c 130 if ($hub['url'] == HUB_MOODLEORGHUBURL) {
a33cc71f 131 unset($hubs[$key]);
132 }
133 }
134
07ab0c80 135 //Public hub list
136 $options = array();
137 foreach ($hubs as $hub) {
138 //to not display a name longer than 100 character (too big)
138c7678
PS
139 if (textlib::strlen($hub['name']) > 100) {
140 $hubname = textlib::substr($hub['name'], 0, 100);
2c9bb9c3 141 $hubname = $hubname . "...";
07ab0c80 142 } else {
143 $hubname = $hub['name'];
144 }
145 $options[$hub['url']] = $hubname;
146 $mform->addElement('hidden', clean_param($hub['url'], PARAM_ALPHANUMEXT), $hubname);
f8758d68 147 $mform->setType(clean_param($hub['url'], PARAM_ALPHANUMEXT), PARAM_ALPHANUMEXT);
07ab0c80 148 }
2c9bb9c3 149 if (!empty($hubs)) {
150 $mform->addElement('select', 'publichub', get_string('publichub', 'hub'),
151 $options, array("size" => 15));
152 }
07ab0c80 153
2c9bb9c3 154 $mform->addElement('static', 'or', '', get_string('orenterprivatehub', 'hub'));
07ab0c80 155
156 //Private hub
20e033bd 157 $mform->addElement('text', 'unlistedurl', get_string('privatehuburl', 'hub'),
158 array('class' => 'registration_textfield'));
159 $mform->addElement('text', 'password', get_string('password'),
160 array('class' => 'registration_textfield'));
07ab0c80 161
162 $this->add_action_buttons(false, get_string('selecthub', 'hub'));
163 }
164
165 /**
166 * Check the unlisted URL is a URL
167 */
168 function validation($data, $files) {
169 global $CFG;
170 $errors = parent::validation($data, $files);
171
172 $unlistedurl = $this->_form->_submitValues['unlistedurl'];
173
174 if (!empty($unlistedurl)) {
175 $unlistedurltotest = clean_param($unlistedurl, PARAM_URL);
176 if (empty($unlistedurltotest)) {
177 $errors['unlistedurl'] = get_string('badurlformat', 'hub');
178 }
179 }
180
181 return $errors;
182 }
183
184}
185
07ab0c80 186/**
187 * The site registration form. Information will be sent to a given hub.
188 */
189class site_registration_form extends moodleform {
190
191 public function definition() {
192 global $CFG, $DB;
193
194 $strrequired = get_string('required');
2c9bb9c3 195 $mform = & $this->_form;
07ab0c80 196 $huburl = $this->_customdata['huburl'];
197 $hubname = $this->_customdata['hubname'];
4b1acb3a 198 $password = $this->_customdata['password'];
07ab0c80 199 $admin = get_admin();
200 $site = get_site();
201
202 //retrieve config for this hub and set default if they don't exist
203 $cleanhuburl = clean_param($huburl, PARAM_ALPHANUMEXT);
2c9bb9c3 204 $sitename = get_config('hub', 'site_name_' . $cleanhuburl);
07ab0c80 205 if ($sitename === false) {
bf006d2c 206 $sitename = format_string($site->fullname, true, array('context' => context_course::instance(SITEID)));
07ab0c80 207 }
2c9bb9c3 208 $sitedescription = get_config('hub', 'site_description_' . $cleanhuburl);
07ab0c80 209 if ($sitedescription === false) {
210 $sitedescription = $site->summary;
211 }
2c9bb9c3 212 $contactname = get_config('hub', 'site_contactname_' . $cleanhuburl);
07ab0c80 213 if ($contactname === false) {
214 $contactname = fullname($admin, true);
215 }
2c9bb9c3 216 $contactemail = get_config('hub', 'site_contactemail_' . $cleanhuburl);
07ab0c80 217 if ($contactemail === false) {
218 $contactemail = $admin->email;
219 }
2c9bb9c3 220 $contactphone = get_config('hub', 'site_contactphone_' . $cleanhuburl);
07ab0c80 221 if ($contactphone === false) {
222 $contactphone = $admin->phone1;
223 }
2c9bb9c3 224 $imageurl = get_config('hub', 'site_imageurl_' . $cleanhuburl);
225 $privacy = get_config('hub', 'site_privacy_' . $cleanhuburl);
226 $address = get_config('hub', 'site_address_' . $cleanhuburl);
227 $region = get_config('hub', 'site_region_' . $cleanhuburl);
228 $country = get_config('hub', 'site_country_' . $cleanhuburl);
07ab0c80 229 if ($country === false) {
2c9bb9c3 230 $country = $admin->country;
07ab0c80 231 }
daff57fb 232 $language = get_config('hub', 'site_language_' . $cleanhuburl);
233 if ($language === false) {
234 $language = current_language();
235 }
2c9bb9c3 236 $geolocation = get_config('hub', 'site_geolocation_' . $cleanhuburl);
237 $contactable = get_config('hub', 'site_contactable_' . $cleanhuburl);
238 $emailalert = get_config('hub', 'site_emailalert_' . $cleanhuburl);
b3245b75 239 $emailalert = ($emailalert === 0) ? 0 : 1;
2c9bb9c3 240 $coursesnumber = get_config('hub', 'site_coursesnumber_' . $cleanhuburl);
241 $usersnumber = get_config('hub', 'site_usersnumber_' . $cleanhuburl);
242 $roleassignmentsnumber = get_config('hub', 'site_roleassignmentsnumber_' . $cleanhuburl);
243 $postsnumber = get_config('hub', 'site_postsnumber_' . $cleanhuburl);
244 $questionsnumber = get_config('hub', 'site_questionsnumber_' . $cleanhuburl);
245 $resourcesnumber = get_config('hub', 'site_resourcesnumber_' . $cleanhuburl);
27806552
YB
246 $badges = get_config('hub', 'site_badges_' . $cleanhuburl);
247 $issuedbadges = get_config('hub', 'site_issuedbadges_' . $cleanhuburl);
2c9bb9c3 248 $mediancoursesize = get_config('hub', 'site_mediancoursesize_' . $cleanhuburl);
07ab0c80 249
250 //hidden parameters
251 $mform->addElement('hidden', 'huburl', $huburl);
f8758d68 252 $mform->setType('huburl', PARAM_URL);
07ab0c80 253 $mform->addElement('hidden', 'hubname', $hubname);
f8758d68 254 $mform->setType('hubname', PARAM_TEXT);
4b1acb3a 255 $mform->addElement('hidden', 'password', $password);
f8758d68 256 $mform->setType('password', PARAM_RAW);
07ab0c80 257
258 //the input parameters
259 $mform->addElement('header', 'moodle', get_string('registrationinfo', 'hub'));
260
2c9bb9c3 261 $mform->addElement('text', 'name', get_string('sitename', 'hub'),
139978e5 262 array('class' => 'registration_textfield'));
07ab0c80 263 $mform->addRule('name', $strrequired, 'required', null, 'client');
264 $mform->setType('name', PARAM_TEXT);
265 $mform->setDefault('name', $sitename);
139978e5 266 $mform->addHelpButton('name', 'sitename', 'hub');
07ab0c80 267
268 $options = array();
94788de2 269 $registrationmanager = new registration_manager();
270 $options[HUB_SITENOTPUBLISHED] = $registrationmanager->get_site_privacy_string(HUB_SITENOTPUBLISHED);
271 $options[HUB_SITENAMEPUBLISHED] = $registrationmanager->get_site_privacy_string(HUB_SITENAMEPUBLISHED);
272 $options[HUB_SITELINKPUBLISHED] = $registrationmanager->get_site_privacy_string(HUB_SITELINKPUBLISHED);
07ab0c80 273 $mform->addElement('select', 'privacy', get_string('siteprivacy', 'hub'), $options);
274 $mform->setDefault('privacy', $privacy);
4032415e 275 $mform->addHelpButton('privacy', 'privacy', 'hub');
07ab0c80 276 unset($options);
277
139978e5 278 $mform->addElement('textarea', 'description', get_string('sitedesc', 'hub'),
2c9bb9c3 279 array('rows' => 8, 'cols' => 41));
07ab0c80 280 $mform->addRule('description', $strrequired, 'required', null, 'client');
281 $mform->setDefault('description', $sitedescription);
282 $mform->setType('description', PARAM_TEXT);
139978e5 283 $mform->addHelpButton('description', 'sitedesc', 'hub');
07ab0c80 284
07ab0c80 285 $languages = get_string_manager()->get_list_of_languages();
d609d962 286 collatorlib::asort($languages);
daff57fb 287 $mform->addElement('select', 'language', get_string('sitelang', 'hub'),
288 $languages);
f8758d68 289 $mform->setType('language', PARAM_ALPHANUMEXT);
daff57fb 290 $mform->addHelpButton('language', 'sitelang', 'hub');
291 $mform->setDefault('language', $language);
07ab0c80 292
2c9bb9c3 293 $mform->addElement('textarea', 'address', get_string('postaladdress', 'hub'),
294 array('rows' => 4, 'cols' => 41));
07ab0c80 295 $mform->setType('address', PARAM_TEXT);
296 $mform->setDefault('address', $address);
139978e5 297 $mform->addHelpButton('address', 'postaladdress', 'hub');
07ab0c80 298
299 //TODO: use the region array I generated
4032415e 300// $mform->addElement('select', 'region', get_string('selectaregion'), array('-' => '-'));
301// $mform->setDefault('region', $region);
302 $mform->addElement('hidden', 'regioncode', '-');
f8758d68 303 $mform->setType('regioncode', PARAM_ALPHANUMEXT);
07ab0c80 304
305 $countries = get_string_manager()->get_list_of_countries();
139978e5 306 $mform->addElement('select', 'countrycode', get_string('sitecountry', 'hub'), $countries);
4032415e 307 $mform->setDefault('countrycode', $country);
139978e5 308 $mform->addHelpButton('countrycode', 'sitecountry', 'hub');
07ab0c80 309
2c9bb9c3 310 $mform->addElement('text', 'geolocation', get_string('sitegeolocation', 'hub'),
139978e5 311 array('class' => 'registration_textfield'));
07ab0c80 312 $mform->setDefault('geolocation', $geolocation);
139978e5 313 $mform->addHelpButton('geolocation', 'sitegeolocation', 'hub');
07ab0c80 314
139978e5 315 $mform->addElement('text', 'contactname', get_string('siteadmin', 'hub'),
316 array('class' => 'registration_textfield'));
07ab0c80 317 $mform->addRule('contactname', $strrequired, 'required', null, 'client');
318 $mform->setType('contactname', PARAM_TEXT);
319 $mform->setDefault('contactname', $contactname);
139978e5 320 $mform->addHelpButton('contactname', 'siteadmin', 'hub');
07ab0c80 321
2c9bb9c3 322 $mform->addElement('text', 'contactphone', get_string('sitephone', 'hub'),
139978e5 323 array('class' => 'registration_textfield'));
07ab0c80 324 $mform->setType('contactphone', PARAM_TEXT);
139978e5 325 $mform->addHelpButton('contactphone', 'sitephone', 'hub');
07ab0c80 326
139978e5 327 $mform->addElement('text', 'contactemail', get_string('siteemail', 'hub'),
328 array('class' => 'registration_textfield'));
07ab0c80 329 $mform->addRule('contactemail', $strrequired, 'required', null, 'client');
330 $mform->setType('contactemail', PARAM_TEXT);
331 $mform->setDefault('contactemail', $contactemail);
139978e5 332 $mform->addHelpButton('contactemail', 'siteemail', 'hub');
07ab0c80 333
334 $options = array();
335 $options[0] = get_string("registrationcontactno");
336 $options[1] = get_string("registrationcontactyes");
139978e5 337 $mform->addElement('select', 'contactable', get_string('siteregistrationcontact', 'hub'), $options);
07ab0c80 338 $mform->setDefault('contactable', $contactable);
139978e5 339 $mform->addHelpButton('contactable', 'siteregistrationcontact', 'hub');
07ab0c80 340 unset($options);
341
342 $options = array();
343 $options[0] = get_string("registrationno");
344 $options[1] = get_string("registrationyes");
139978e5 345 $mform->addElement('select', 'emailalert', get_string('siteregistrationemail', 'hub'), $options);
07ab0c80 346 $mform->setDefault('emailalert', $emailalert);
139978e5 347 $mform->addHelpButton('emailalert', 'siteregistrationemail', 'hub');
07ab0c80 348 unset($options);
349
139978e5 350 //TODO site logo
e275f25e 351 $mform->addElement('hidden', 'imageurl', ''); //TODO: temporary
f8758d68 352 $mform->setType('imageurl', PARAM_URL);
b3245b75
DP
353
354 $mform->addElement('static', 'urlstring', get_string('siteurl', 'hub'), $CFG->wwwroot);
355 $mform->addHelpButton('urlstring', 'siteurl', 'hub');
356
357 $mform->addElement('static', 'versionstring', get_string('siteversion', 'hub'), $CFG->version);
358 $mform->addElement('hidden', 'moodleversion', $CFG->version);
359 $mform->setType('moodleversion', PARAM_INT);
360 $mform->addHelpButton('versionstring', 'siteversion', 'hub');
361
362 $mform->addElement('static', 'releasestring', get_string('siterelease', 'hub'), $CFG->release);
363 $mform->addElement('hidden', 'moodlerelease', $CFG->release);
364 $mform->setType('moodlerelease', PARAM_TEXT);
365 $mform->addHelpButton('releasestring', 'siterelease', 'hub');
366
07ab0c80 367 /// Display statistic that are going to be retrieve by the hub
2c9bb9c3 368 $coursecount = $DB->count_records('course') - 1;
369 $usercount = $DB->count_records('user', array('deleted' => 0));
07ab0c80 370 $roleassigncount = $DB->count_records('role_assignments');
371 $postcount = $DB->count_records('forum_posts');
372 $questioncount = $DB->count_records('question');
373 $resourcecount = $DB->count_records('resource');
2c9bb9c3 374 require_once($CFG->dirroot . "/course/lib.php");
ceac2af3 375 $participantnumberaverage = number_format(average_number_of_participants(), 2);
376 $modulenumberaverage = number_format(average_number_of_courses_modules(), 2);
27806552
YB
377 require_once($CFG->libdir . '/badgeslib.php');
378 $badges = $DB->count_records_select('badge', 'status <> ' . BADGE_STATUS_ARCHIVED);
379 $issuedbadges = $DB->count_records('badge_issued');
07ab0c80 380
06d4578c 381 if (HUB_MOODLEORGHUBURL != $huburl) {
2c9bb9c3 382 $mform->addElement('checkbox', 'courses', get_string('sendfollowinginfo', 'hub'),
383 " " . get_string('coursesnumber', 'hub', $coursecount));
07ab0c80 384 $mform->setDefault('courses', true);
139978e5 385 $mform->addHelpButton('courses', 'sendfollowinginfo', 'hub');
07ab0c80 386
387 $mform->addElement('checkbox', 'users', '',
2c9bb9c3 388 " " . get_string('usersnumber', 'hub', $usercount));
07ab0c80 389 $mform->setDefault('users', true);
390
391 $mform->addElement('checkbox', 'roleassignments', '',
2c9bb9c3 392 " " . get_string('roleassignmentsnumber', 'hub', $roleassigncount));
07ab0c80 393 $mform->setDefault('roleassignments', true);
394
395 $mform->addElement('checkbox', 'posts', '',
2c9bb9c3 396 " " . get_string('postsnumber', 'hub', $postcount));
07ab0c80 397 $mform->setDefault('posts', true);
398
399 $mform->addElement('checkbox', 'questions', '',
2c9bb9c3 400 " " . get_string('questionsnumber', 'hub', $questioncount));
07ab0c80 401 $mform->setDefault('questions', true);
402
403 $mform->addElement('checkbox', 'resources', '',
2c9bb9c3 404 " " . get_string('resourcesnumber', 'hub', $resourcecount));
07ab0c80 405 $mform->setDefault('resources', true);
406
27806552
YB
407 $mform->addElement('checkbox', 'badges', '',
408 " " . get_string('badgesnumber', 'hub', $badges));
409 $mform->setDefault('badges', true);
410
411 $mform->addElement('checkbox', 'issuedbadges', '',
412 " " . get_string('issuedbadgesnumber', 'hub', $issuedbadges));
413 $mform->setDefault('issuedbadges', true);
414
07ab0c80 415 $mform->addElement('checkbox', 'participantnumberaverage', '',
ceac2af3 416 " " . get_string('participantnumberaverage', 'hub', $participantnumberaverage));
07ab0c80 417 $mform->setDefault('participantnumberaverage', true);
418
419 $mform->addElement('checkbox', 'modulenumberaverage', '',
ceac2af3 420 " " . get_string('modulenumberaverage', 'hub', $modulenumberaverage));
07ab0c80 421 $mform->setDefault('modulenumberaverage', true);
422 } else {
2c9bb9c3 423 $mform->addElement('static', 'courseslabel', get_string('sendfollowinginfo', 'hub'),
424 " " . get_string('coursesnumber', 'hub', $coursecount));
07ab0c80 425 $mform->addElement('hidden', 'courses', true);
f8758d68 426 $mform->setType('courses', PARAM_FLOAT);
2c9bb9c3 427 $mform->addHelpButton('courseslabel', 'sendfollowinginfo', 'hub');
07ab0c80 428
429 $mform->addElement('static', 'userslabel', '',
2c9bb9c3 430 " " . get_string('usersnumber', 'hub', $usercount));
07ab0c80 431 $mform->addElement('hidden', 'users', true);
f8758d68 432 $mform->setType('users', PARAM_FLOAT);
07ab0c80 433
434 $mform->addElement('static', 'roleassignmentslabel', '',
2c9bb9c3 435 " " . get_string('roleassignmentsnumber', 'hub', $roleassigncount));
07ab0c80 436 $mform->addElement('hidden', 'roleassignments', true);
f8758d68 437 $mform->setType('roleassignments', PARAM_FLOAT);
07ab0c80 438
439 $mform->addElement('static', 'postslabel', '',
2c9bb9c3 440 " " . get_string('postsnumber', 'hub', $postcount));
07ab0c80 441 $mform->addElement('hidden', 'posts', true);
f8758d68 442 $mform->setType('posts', PARAM_FLOAT);
07ab0c80 443
444 $mform->addElement('static', 'questionslabel', '',
2c9bb9c3 445 " " . get_string('questionsnumber', 'hub', $questioncount));
07ab0c80 446 $mform->addElement('hidden', 'questions', true);
f8758d68 447 $mform->setType('questions', PARAM_FLOAT);
07ab0c80 448
449 $mform->addElement('static', 'resourceslabel', '',
2c9bb9c3 450 " " . get_string('resourcesnumber', 'hub', $resourcecount));
07ab0c80 451 $mform->addElement('hidden', 'resources', true);
f8758d68 452 $mform->setType('resources', PARAM_FLOAT);
07ab0c80 453
27806552
YB
454 $mform->addElement('static', 'badgeslabel', '',
455 " " . get_string('badgesnumber', 'hub', $badges));
456 $mform->addElement('hidden', 'badges', true);
457 $mform->setType('badges', PARAM_INT);
458
459 $mform->addElement('static', 'issuedbadgeslabel', '',
460 " " . get_string('issuedbadgesnumber', 'hub', $issuedbadges));
461 $mform->addElement('hidden', 'issuedbadges', true);
462 $mform->setType('issuedbadges', PARAM_INT);
463
07ab0c80 464 $mform->addElement('static', 'participantnumberaveragelabel', '',
2c9bb9c3 465 " " . get_string('participantnumberaverage', 'hub', $participantnumberaverage));
07ab0c80 466 $mform->addElement('hidden', 'participantnumberaverage', true);
f8758d68 467 $mform->setType('participantnumberaverage', PARAM_FLOAT);
07ab0c80 468
469 $mform->addElement('static', 'modulenumberaveragelabel', '',
2c9bb9c3 470 " " . get_string('modulenumberaverage', 'hub', $modulenumberaverage));
07ab0c80 471 $mform->addElement('hidden', 'modulenumberaverage', true);
f8758d68 472 $mform->setType('modulenumberaverage', PARAM_FLOAT);
07ab0c80 473 }
474
475 //check if it's a first registration or update
94788de2 476 $hubregistered = $registrationmanager->get_registeredhub($huburl);
07ab0c80 477
478 if (!empty($hubregistered)) {
479 $buttonlabel = get_string('updatesite', 'hub',
2c9bb9c3 480 !empty($hubname) ? $hubname : $huburl);
07ab0c80 481 $mform->addElement('hidden', 'update', true);
f8758d68 482 $mform->setType('update', PARAM_BOOL);
07ab0c80 483 } else {
484 $buttonlabel = get_string('registersite', 'hub',
2c9bb9c3 485 !empty($hubname) ? $hubname : $huburl);
07ab0c80 486 }
487
488 $this->add_action_buttons(false, $buttonlabel);
489 }
490
07ab0c80 491}
492