Commit | Line | Data |
---|---|---|
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 | 34 | require_once($CFG->libdir . '/formslib.php'); |
35 | require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php'); | |
07ab0c80 | 36 | |
f57c4047 | 37 | /** |
38 | * This form display a unregistration form. | |
39 | */ | |
40 | class 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 | */ | |
72 | class 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 | */ | |
107 | class 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 | */ | |
189 | class 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); | |
246 | $mediancoursesize = get_config('hub', 'site_mediancoursesize_' . $cleanhuburl); | |
07ab0c80 | 247 | |
248 | //hidden parameters | |
249 | $mform->addElement('hidden', 'huburl', $huburl); | |
f8758d68 | 250 | $mform->setType('huburl', PARAM_URL); |
07ab0c80 | 251 | $mform->addElement('hidden', 'hubname', $hubname); |
f8758d68 | 252 | $mform->setType('hubname', PARAM_TEXT); |
4b1acb3a | 253 | $mform->addElement('hidden', 'password', $password); |
f8758d68 | 254 | $mform->setType('password', PARAM_RAW); |
07ab0c80 | 255 | |
256 | //the input parameters | |
257 | $mform->addElement('header', 'moodle', get_string('registrationinfo', 'hub')); | |
258 | ||
2c9bb9c3 | 259 | $mform->addElement('text', 'name', get_string('sitename', 'hub'), |
139978e5 | 260 | array('class' => 'registration_textfield')); |
07ab0c80 | 261 | $mform->addRule('name', $strrequired, 'required', null, 'client'); |
262 | $mform->setType('name', PARAM_TEXT); | |
263 | $mform->setDefault('name', $sitename); | |
139978e5 | 264 | $mform->addHelpButton('name', 'sitename', 'hub'); |
07ab0c80 | 265 | |
266 | $options = array(); | |
94788de2 | 267 | $registrationmanager = new registration_manager(); |
268 | $options[HUB_SITENOTPUBLISHED] = $registrationmanager->get_site_privacy_string(HUB_SITENOTPUBLISHED); | |
269 | $options[HUB_SITENAMEPUBLISHED] = $registrationmanager->get_site_privacy_string(HUB_SITENAMEPUBLISHED); | |
270 | $options[HUB_SITELINKPUBLISHED] = $registrationmanager->get_site_privacy_string(HUB_SITELINKPUBLISHED); | |
07ab0c80 | 271 | $mform->addElement('select', 'privacy', get_string('siteprivacy', 'hub'), $options); |
272 | $mform->setDefault('privacy', $privacy); | |
4032415e | 273 | $mform->addHelpButton('privacy', 'privacy', 'hub'); |
07ab0c80 | 274 | unset($options); |
275 | ||
139978e5 | 276 | $mform->addElement('textarea', 'description', get_string('sitedesc', 'hub'), |
2c9bb9c3 | 277 | array('rows' => 8, 'cols' => 41)); |
07ab0c80 | 278 | $mform->addRule('description', $strrequired, 'required', null, 'client'); |
279 | $mform->setDefault('description', $sitedescription); | |
280 | $mform->setType('description', PARAM_TEXT); | |
139978e5 | 281 | $mform->addHelpButton('description', 'sitedesc', 'hub'); |
07ab0c80 | 282 | |
07ab0c80 | 283 | $languages = get_string_manager()->get_list_of_languages(); |
d609d962 | 284 | collatorlib::asort($languages); |
daff57fb | 285 | $mform->addElement('select', 'language', get_string('sitelang', 'hub'), |
286 | $languages); | |
f8758d68 | 287 | $mform->setType('language', PARAM_ALPHANUMEXT); |
daff57fb | 288 | $mform->addHelpButton('language', 'sitelang', 'hub'); |
289 | $mform->setDefault('language', $language); | |
07ab0c80 | 290 | |
2c9bb9c3 | 291 | $mform->addElement('textarea', 'address', get_string('postaladdress', 'hub'), |
292 | array('rows' => 4, 'cols' => 41)); | |
07ab0c80 | 293 | $mform->setType('address', PARAM_TEXT); |
294 | $mform->setDefault('address', $address); | |
139978e5 | 295 | $mform->addHelpButton('address', 'postaladdress', 'hub'); |
07ab0c80 | 296 | |
297 | //TODO: use the region array I generated | |
4032415e | 298 | // $mform->addElement('select', 'region', get_string('selectaregion'), array('-' => '-')); |
299 | // $mform->setDefault('region', $region); | |
300 | $mform->addElement('hidden', 'regioncode', '-'); | |
f8758d68 | 301 | $mform->setType('regioncode', PARAM_ALPHANUMEXT); |
07ab0c80 | 302 | |
303 | $countries = get_string_manager()->get_list_of_countries(); | |
139978e5 | 304 | $mform->addElement('select', 'countrycode', get_string('sitecountry', 'hub'), $countries); |
4032415e | 305 | $mform->setDefault('countrycode', $country); |
139978e5 | 306 | $mform->addHelpButton('countrycode', 'sitecountry', 'hub'); |
07ab0c80 | 307 | |
2c9bb9c3 | 308 | $mform->addElement('text', 'geolocation', get_string('sitegeolocation', 'hub'), |
139978e5 | 309 | array('class' => 'registration_textfield')); |
07ab0c80 | 310 | $mform->setDefault('geolocation', $geolocation); |
139978e5 | 311 | $mform->addHelpButton('geolocation', 'sitegeolocation', 'hub'); |
07ab0c80 | 312 | |
139978e5 | 313 | $mform->addElement('text', 'contactname', get_string('siteadmin', 'hub'), |
314 | array('class' => 'registration_textfield')); | |
07ab0c80 | 315 | $mform->addRule('contactname', $strrequired, 'required', null, 'client'); |
316 | $mform->setType('contactname', PARAM_TEXT); | |
317 | $mform->setDefault('contactname', $contactname); | |
139978e5 | 318 | $mform->addHelpButton('contactname', 'siteadmin', 'hub'); |
07ab0c80 | 319 | |
2c9bb9c3 | 320 | $mform->addElement('text', 'contactphone', get_string('sitephone', 'hub'), |
139978e5 | 321 | array('class' => 'registration_textfield')); |
07ab0c80 | 322 | $mform->setType('contactphone', PARAM_TEXT); |
139978e5 | 323 | $mform->addHelpButton('contactphone', 'sitephone', 'hub'); |
07ab0c80 | 324 | |
139978e5 | 325 | $mform->addElement('text', 'contactemail', get_string('siteemail', 'hub'), |
326 | array('class' => 'registration_textfield')); | |
07ab0c80 | 327 | $mform->addRule('contactemail', $strrequired, 'required', null, 'client'); |
328 | $mform->setType('contactemail', PARAM_TEXT); | |
329 | $mform->setDefault('contactemail', $contactemail); | |
139978e5 | 330 | $mform->addHelpButton('contactemail', 'siteemail', 'hub'); |
07ab0c80 | 331 | |
332 | $options = array(); | |
333 | $options[0] = get_string("registrationcontactno"); | |
334 | $options[1] = get_string("registrationcontactyes"); | |
139978e5 | 335 | $mform->addElement('select', 'contactable', get_string('siteregistrationcontact', 'hub'), $options); |
07ab0c80 | 336 | $mform->setDefault('contactable', $contactable); |
139978e5 | 337 | $mform->addHelpButton('contactable', 'siteregistrationcontact', 'hub'); |
07ab0c80 | 338 | unset($options); |
339 | ||
340 | $options = array(); | |
341 | $options[0] = get_string("registrationno"); | |
342 | $options[1] = get_string("registrationyes"); | |
139978e5 | 343 | $mform->addElement('select', 'emailalert', get_string('siteregistrationemail', 'hub'), $options); |
07ab0c80 | 344 | $mform->setDefault('emailalert', $emailalert); |
139978e5 | 345 | $mform->addHelpButton('emailalert', 'siteregistrationemail', 'hub'); |
07ab0c80 | 346 | unset($options); |
347 | ||
139978e5 | 348 | //TODO site logo |
e275f25e | 349 | $mform->addElement('hidden', 'imageurl', ''); //TODO: temporary |
f8758d68 | 350 | $mform->setType('imageurl', PARAM_URL); |
b3245b75 DP |
351 | |
352 | $mform->addElement('static', 'urlstring', get_string('siteurl', 'hub'), $CFG->wwwroot); | |
353 | $mform->addHelpButton('urlstring', 'siteurl', 'hub'); | |
354 | ||
355 | $mform->addElement('static', 'versionstring', get_string('siteversion', 'hub'), $CFG->version); | |
356 | $mform->addElement('hidden', 'moodleversion', $CFG->version); | |
357 | $mform->setType('moodleversion', PARAM_INT); | |
358 | $mform->addHelpButton('versionstring', 'siteversion', 'hub'); | |
359 | ||
360 | $mform->addElement('static', 'releasestring', get_string('siterelease', 'hub'), $CFG->release); | |
361 | $mform->addElement('hidden', 'moodlerelease', $CFG->release); | |
362 | $mform->setType('moodlerelease', PARAM_TEXT); | |
363 | $mform->addHelpButton('releasestring', 'siterelease', 'hub'); | |
364 | ||
07ab0c80 | 365 | /// Display statistic that are going to be retrieve by the hub |
2c9bb9c3 | 366 | $coursecount = $DB->count_records('course') - 1; |
367 | $usercount = $DB->count_records('user', array('deleted' => 0)); | |
07ab0c80 | 368 | $roleassigncount = $DB->count_records('role_assignments'); |
369 | $postcount = $DB->count_records('forum_posts'); | |
370 | $questioncount = $DB->count_records('question'); | |
371 | $resourcecount = $DB->count_records('resource'); | |
2c9bb9c3 | 372 | require_once($CFG->dirroot . "/course/lib.php"); |
ceac2af3 | 373 | $participantnumberaverage = number_format(average_number_of_participants(), 2); |
374 | $modulenumberaverage = number_format(average_number_of_courses_modules(), 2); | |
07ab0c80 | 375 | |
06d4578c | 376 | if (HUB_MOODLEORGHUBURL != $huburl) { |
2c9bb9c3 | 377 | $mform->addElement('checkbox', 'courses', get_string('sendfollowinginfo', 'hub'), |
378 | " " . get_string('coursesnumber', 'hub', $coursecount)); | |
07ab0c80 | 379 | $mform->setDefault('courses', true); |
139978e5 | 380 | $mform->addHelpButton('courses', 'sendfollowinginfo', 'hub'); |
07ab0c80 | 381 | |
382 | $mform->addElement('checkbox', 'users', '', | |
2c9bb9c3 | 383 | " " . get_string('usersnumber', 'hub', $usercount)); |
07ab0c80 | 384 | $mform->setDefault('users', true); |
385 | ||
386 | $mform->addElement('checkbox', 'roleassignments', '', | |
2c9bb9c3 | 387 | " " . get_string('roleassignmentsnumber', 'hub', $roleassigncount)); |
07ab0c80 | 388 | $mform->setDefault('roleassignments', true); |
389 | ||
390 | $mform->addElement('checkbox', 'posts', '', | |
2c9bb9c3 | 391 | " " . get_string('postsnumber', 'hub', $postcount)); |
07ab0c80 | 392 | $mform->setDefault('posts', true); |
393 | ||
394 | $mform->addElement('checkbox', 'questions', '', | |
2c9bb9c3 | 395 | " " . get_string('questionsnumber', 'hub', $questioncount)); |
07ab0c80 | 396 | $mform->setDefault('questions', true); |
397 | ||
398 | $mform->addElement('checkbox', 'resources', '', | |
2c9bb9c3 | 399 | " " . get_string('resourcesnumber', 'hub', $resourcecount)); |
07ab0c80 | 400 | $mform->setDefault('resources', true); |
401 | ||
402 | $mform->addElement('checkbox', 'participantnumberaverage', '', | |
ceac2af3 | 403 | " " . get_string('participantnumberaverage', 'hub', $participantnumberaverage)); |
07ab0c80 | 404 | $mform->setDefault('participantnumberaverage', true); |
405 | ||
406 | $mform->addElement('checkbox', 'modulenumberaverage', '', | |
ceac2af3 | 407 | " " . get_string('modulenumberaverage', 'hub', $modulenumberaverage)); |
07ab0c80 | 408 | $mform->setDefault('modulenumberaverage', true); |
409 | } else { | |
2c9bb9c3 | 410 | $mform->addElement('static', 'courseslabel', get_string('sendfollowinginfo', 'hub'), |
411 | " " . get_string('coursesnumber', 'hub', $coursecount)); | |
07ab0c80 | 412 | $mform->addElement('hidden', 'courses', true); |
f8758d68 | 413 | $mform->setType('courses', PARAM_FLOAT); |
2c9bb9c3 | 414 | $mform->addHelpButton('courseslabel', 'sendfollowinginfo', 'hub'); |
07ab0c80 | 415 | |
416 | $mform->addElement('static', 'userslabel', '', | |
2c9bb9c3 | 417 | " " . get_string('usersnumber', 'hub', $usercount)); |
07ab0c80 | 418 | $mform->addElement('hidden', 'users', true); |
f8758d68 | 419 | $mform->setType('users', PARAM_FLOAT); |
07ab0c80 | 420 | |
421 | $mform->addElement('static', 'roleassignmentslabel', '', | |
2c9bb9c3 | 422 | " " . get_string('roleassignmentsnumber', 'hub', $roleassigncount)); |
07ab0c80 | 423 | $mform->addElement('hidden', 'roleassignments', true); |
f8758d68 | 424 | $mform->setType('roleassignments', PARAM_FLOAT); |
07ab0c80 | 425 | |
426 | $mform->addElement('static', 'postslabel', '', | |
2c9bb9c3 | 427 | " " . get_string('postsnumber', 'hub', $postcount)); |
07ab0c80 | 428 | $mform->addElement('hidden', 'posts', true); |
f8758d68 | 429 | $mform->setType('posts', PARAM_FLOAT); |
07ab0c80 | 430 | |
431 | $mform->addElement('static', 'questionslabel', '', | |
2c9bb9c3 | 432 | " " . get_string('questionsnumber', 'hub', $questioncount)); |
07ab0c80 | 433 | $mform->addElement('hidden', 'questions', true); |
f8758d68 | 434 | $mform->setType('questions', PARAM_FLOAT); |
07ab0c80 | 435 | |
436 | $mform->addElement('static', 'resourceslabel', '', | |
2c9bb9c3 | 437 | " " . get_string('resourcesnumber', 'hub', $resourcecount)); |
07ab0c80 | 438 | $mform->addElement('hidden', 'resources', true); |
f8758d68 | 439 | $mform->setType('resources', PARAM_FLOAT); |
07ab0c80 | 440 | |
441 | $mform->addElement('static', 'participantnumberaveragelabel', '', | |
2c9bb9c3 | 442 | " " . get_string('participantnumberaverage', 'hub', $participantnumberaverage)); |
07ab0c80 | 443 | $mform->addElement('hidden', 'participantnumberaverage', true); |
f8758d68 | 444 | $mform->setType('participantnumberaverage', PARAM_FLOAT); |
07ab0c80 | 445 | |
446 | $mform->addElement('static', 'modulenumberaveragelabel', '', | |
2c9bb9c3 | 447 | " " . get_string('modulenumberaverage', 'hub', $modulenumberaverage)); |
07ab0c80 | 448 | $mform->addElement('hidden', 'modulenumberaverage', true); |
f8758d68 | 449 | $mform->setType('modulenumberaverage', PARAM_FLOAT); |
07ab0c80 | 450 | } |
451 | ||
452 | //check if it's a first registration or update | |
94788de2 | 453 | $hubregistered = $registrationmanager->get_registeredhub($huburl); |
07ab0c80 | 454 | |
455 | if (!empty($hubregistered)) { | |
456 | $buttonlabel = get_string('updatesite', 'hub', | |
2c9bb9c3 | 457 | !empty($hubname) ? $hubname : $huburl); |
07ab0c80 | 458 | $mform->addElement('hidden', 'update', true); |
f8758d68 | 459 | $mform->setType('update', PARAM_BOOL); |
07ab0c80 | 460 | } else { |
461 | $buttonlabel = get_string('registersite', 'hub', | |
2c9bb9c3 | 462 | !empty($hubname) ? $hubname : $huburl); |
07ab0c80 | 463 | } |
464 | ||
465 | $this->add_action_buttons(false, $buttonlabel); | |
466 | } | |
467 | ||
07ab0c80 | 468 | } |
469 |