public function definition() { global $CFG, $DB, $SITE; $hub = new local_hub(); $mform =& $this->_form; $mform->addElement('header', 'moodle', get_string('hubdetails', 'local_hub')); $hubname = get_config('local_hub', 'name'); $hubdescription = get_config('local_hub', 'description'); $contactname = get_config('local_hub', 'contactname'); $contactemail = get_config('local_hub', 'contactemail'); $hublogo = get_config('local_hub', 'hublogo'); $privacy = get_config('local_hub', 'privacy'); $hublanguage = get_config('local_hub', 'language'); if (empty($hubname) or empty($privacy) or empty($hubdescription)) { $mform->addElement('static', 'missinghubsetup', '', get_string('settingsinvalid', 'local_hub')); return; } $mform->addElement('static', 'comment', '', get_string('hubregistrationcomment', 'local_hub')); $mform->addElement('hidden', 'url', $CFG->wwwroot); $mform->setType('url', PARAM_URL); $languages = get_string_manager()->get_list_of_languages(); $mform->addElement('static', 'hubnamestring', get_string('name', 'local_hub'), $hubname); $mform->addElement('hidden', 'name', $hubname); $mform->setType('name', PARAM_TEXT); $mform->addElement('static', 'hubprivacystring', get_string('privacy', 'local_hub'), $hub->get_privacy_string($privacy)); $mform->addElement('hidden', 'privacy', $privacy); $mform->setType('privacy', PARAM_ALPHA); // A string like 'public' or 'private'. $mform->addElement('static', 'languagestring', get_string('language'), $languages[$hublanguage]); $mform->addElement('hidden', 'language', $hublanguage); $mform->setType('language', PARAM_LANG); $mform->addElement('static', 'hubdescriptionstring', get_string('description', 'local_hub'), format_text($hubdescription)); $mform->addElement('hidden', 'description', $hubdescription); $mform->setType('description', PARAM_TEXT); $mform->addElement('static', 'contactnamestring', get_string('contactname', 'local_hub'), $contactname); $mform->addElement('hidden', 'contactname', $contactname); $mform->setType('contactname', PARAM_TEXT); $mform->addElement('static', 'contactemailstring', get_string('contactemail', 'local_hub'), $contactemail); $mform->addElement('hidden', 'contactemail', $contactemail); $mform->setType('contactemail', PARAM_EMAIL); if (!empty($hublogo)) { $params = array('filetype' => HUB_HUBSCREENSHOT_FILE_TYPE, 'time' => time()); $imageurl = new moodle_url($CFG->wwwroot . "/local/hub/webservice/download.php", $params); $imagetag = html_writer::empty_tag('img', array('src' => $imageurl, 'alt' => $hubname)); $mform->addElement('static', 'logourlstring', get_string('image', 'local_hub'), $imagetag); } else { $hublogo = 0; } $mform->addElement('hidden', 'hublogo', $hublogo); $mform->setType('hublogo', PARAM_INT); $mform->addElement('static', 'urlstring', get_string('url', 'local_hub'), $CFG->wwwroot); $hubinfo = $hub->get_info(); $mform->addElement('static', 'sitesstring', get_string('registeredsites', 'local_hub'), $hubinfo['sites']); $mform->addElement('hidden', 'sites', $hubinfo['sites']); $mform->setType('sites', PARAM_INT); $mform->addElement('static', 'coursesstring', get_string('registeredcourses', 'local_hub'), $hubinfo['courses']); $mform->addElement('hidden', 'courses', $hubinfo['courses']); $mform->setType('courses', PARAM_INT); $mform->addElement('static', 'enrollablecoursesstring', get_string('enrollablecourses', 'local_hub'), $hubinfo['enrollablecourses']); $mform->addElement('hidden', 'enrollablecourses', $hubinfo['enrollablecourses']); $mform->setType('enrollablecourses', PARAM_INT); $mform->addElement('static', 'downloadablecoursesstring', get_string('downloadablecourses', 'local_hub'), $hubinfo['downloadablecourses']); $mform->addElement('hidden', 'downloadablecourses', $hubinfo['downloadablecourses']); $mform->setType('downloadablecourses', PARAM_INT); //if the hub is private do not display the register button if ($privacy != HUBPRIVATE and empty($this->_customdata['alreadyregistered'])) { $buttonlabel = get_string('hubregister', 'local_hub'); $this->add_action_buttons(false, $buttonlabel); } }