[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/admin/registration/ -> forms.php (source)

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


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1