PageRenderTime 49ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/admin/registration/forms.php

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