media/player/videojs/amd/src/video-lazy.js
media/player/videojs/amd/src/Youtube-lazy.js
media/player/videojs/videojs/
+media/player/videojs/amd/src/videojs-flash-lazy.js
+media/player/videojs/videojs/video-js.swf
mod/assign/feedback/editpdf/fpdi/
repository/s3/S3.php
theme/boost/scss/bootstrap/
media/player/videojs/amd/src/video-lazy.js
media/player/videojs/amd/src/Youtube-lazy.js
media/player/videojs/videojs/
+media/player/videojs/amd/src/videojs-flash-lazy.js
+media/player/videojs/videojs/video-js.swf
mod/assign/feedback/editpdf/fpdi/
repository/s3/S3.php
theme/boost/scss/bootstrap/
$buggyiconvnomb = (!function_exists('mb_convert_encoding') and @iconv('UTF-8', 'UTF-8//IGNORE', '100'.chr(130).'€') !== '100€');
//check if the site is registered on Moodle.org
-$registered = $DB->count_records('registration_hubs', array('huburl' => HUB_MOODLEORGHUBURL, 'confirmed' => 1));
+$registered = \core\hub\registration::is_registered();
// Check if there are any cache warnings.
$cachewarnings = cache_helper::warnings();
// Check if there are events 1 API handlers.
$eventshandlers = $DB->get_records_sql('SELECT DISTINCT component FROM {events_handlers}');
$themedesignermode = !empty($CFG->themedesignermode);
+$mobileconfigured = !empty($CFG->enablemobilewebservice);
// Check if a directory with development libraries exists.
-if (is_dir($CFG->dirroot.'/vendor') || is_dir($CFG->dirroot.'/node_modules')) {
+if (empty($CFG->disabledevlibdirscheck) && (is_dir($CFG->dirroot.'/vendor') || is_dir($CFG->dirroot.'/node_modules'))) {
$devlibdir = true;
} else {
$devlibdir = false;
echo $output->admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed, $cronoverdue, $dbproblems,
$maintenancemode, $availableupdates, $availableupdatesfetch, $buggyiconvnomb,
- $registered, $cachewarnings, $eventshandlers, $themedesignermode, $devlibdir);
+ $registered, $cachewarnings, $eventshandlers, $themedesignermode, $devlibdir,
+ $mobileconfigured);
// //
///////////////////////////////////////////////////////////////////////////
-/*
+/**
* @package moodle
* @subpackage registration
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
require('../../config.php');
require_once($CFG->libdir . '/adminlib.php');
-require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
$newtoken = optional_param('newtoken', '', PARAM_ALPHANUM);
$url = optional_param('url', '', PARAM_URL);
$token = optional_param('token', '', PARAM_TEXT);
$error = optional_param('error', '', PARAM_ALPHANUM);
-admin_externalpage_setup('registrationhubs');
+admin_externalpage_setup('registrationmoodleorg');
+
+if ($url !== HUB_MOODLEORGHUBURL) {
+ throw new moodle_exception('errorotherhubsnotsupported', 'hub');
+}
if (!empty($error) and $error == 'urlalreadyexist') {
throw new moodle_exception('urlalreadyregistered', 'hub',
}
//check that we are waiting a confirmation from this hub, and check that the token is correct
-$registrationmanager = new registration_manager();
-$registeredhub = $registrationmanager->get_unconfirmedhub($url);
-if (!empty($registeredhub) and $registeredhub->token == $token) {
-
- echo $OUTPUT->header();
- echo $OUTPUT->heading(get_string('registrationconfirmed', 'hub'), 3, 'main');
+core\hub\registration::confirm_registration($token, $newtoken, $hubname);
- $registeredhub->token = $newtoken;
- $registeredhub->confirmed = 1;
- $registeredhub->hubname = $hubname;
- $registrationmanager->update_registeredhub($registeredhub);
+echo $OUTPUT->header();
+echo $OUTPUT->heading(get_string('registrationconfirmed', 'hub'), 3, 'main');
- // Display notification message.
- echo $OUTPUT->notification(get_string('registrationconfirmedon', 'hub'), 'notifysuccess');
+// Display notification message.
+echo $OUTPUT->notification(get_string('registrationconfirmedon', 'hub'), 'notifysuccess');
- //display continue button
- $registrationpage = new moodle_url('/admin/registration/index.php');
- $continuebutton = $OUTPUT->render(new single_button($registrationpage, get_string('continue', 'hub')));
- $continuebutton = html_writer::tag('div', $continuebutton, array('class' => 'mdl-align'));
- echo $continuebutton;
+// Display continue button.
+$registrationpage = new moodle_url('/admin/registration/index.php');
+$continuebutton = $OUTPUT->render(new single_button($registrationpage, get_string('continue')));
+$continuebutton = html_writer::tag('div', $continuebutton, array('class' => 'mdl-align'));
+echo $continuebutton;
- if (!extension_loaded('xmlrpc')) {
- //display notice about xmlrpc
- $xmlrpcnotification = $OUTPUT->doc_link('admin/environment/php_extension/xmlrpc', '');
- $xmlrpcnotification .= get_string('xmlrpcdisabledregistration', 'hub');
- echo $OUTPUT->notification($xmlrpcnotification);
- }
-
- echo $OUTPUT->footer();
-} else {
- throw new moodle_exception('wrongtoken', 'hub',
- $CFG->wwwroot . '/' . $CFG->admin . '/registration/index.php');
-}
+echo $OUTPUT->footer();
// //
///////////////////////////////////////////////////////////////////////////
-/*
+/**
* @package moodle
* @subpackage registration
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
* The forms needed by registration pages.
*/
+defined('MOODLE_INTERNAL') || die();
-require_once($CFG->libdir . '/formslib.php');
-require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
-
-/**
- * This form display a unregistration form.
- */
-class site_unregistration_form extends moodleform {
-
- public function definition() {
- $mform = & $this->_form;
- $mform->addElement('header', 'site', get_string('unregister', 'hub'));
-
- $huburl = $this->_customdata['huburl'];
- $hubname = $this->_customdata['hubname'];
-
- $unregisterlabel = get_string('unregister', 'hub');
- $mform->addElement('checkbox', 'unpublishalladvertisedcourses', '',
- ' ' . get_string('unpublishalladvertisedcourses', 'hub'));
- $mform->setType('unpublishalladvertisedcourses', PARAM_INT);
- $mform->addElement('checkbox', 'unpublishalluploadedcourses', '',
- ' ' . get_string('unpublishalluploadedcourses', 'hub'));
- $mform->setType('unpublishalluploadedcourses', PARAM_INT);
-
- $mform->addElement('hidden', 'confirm', 1);
- $mform->setType('confirm', PARAM_INT);
- $mform->addElement('hidden', 'unregistration', 1);
- $mform->setType('unregistration', PARAM_INT);
- $mform->addElement('hidden', 'huburl', $huburl);
- $mform->setType('huburl', PARAM_URL);
- $mform->addElement('hidden', 'hubname', $hubname);
- $mform->setType('hubname', PARAM_TEXT);
-
- $this->add_action_buttons(true, $unregisterlabel);
- }
-
-}
-
-/**
- * This form display a clean registration data form.
- */
-class site_clean_registration_data_form extends moodleform {
-
- public function definition() {
- $mform = & $this->_form;
- $mform->addElement('header', 'site', get_string('unregister', 'hub'));
-
- $huburl = $this->_customdata['huburl'];
- $hubname = $this->_customdata['hubname'];
-
-
- $unregisterlabel = get_string('forceunregister', 'hub');
- $mform->addElement('static', '', get_string('warning', 'hub'), get_string('forceunregisterconfirmation', 'hub', $hubname));
-
- $mform->addElement('hidden', 'confirm', 1);
- $mform->setType('confirm', PARAM_INT);
- $mform->addElement('hidden', 'unregistration', 1);
- $mform->setType('unregistration', PARAM_INT);
- $mform->addElement('hidden', 'cleanregdata', 1);
- $mform->setType('cleanregdata', PARAM_INT);
- $mform->addElement('hidden', 'huburl', $huburl);
- $mform->setType('huburl', PARAM_URL);
- $mform->addElement('hidden', 'hubname', $hubname);
- $mform->setType('hubname', PARAM_TEXT);
-
- $this->add_action_buttons(true, $unregisterlabel);
- }
-
-}
-
-/**
- * This form display a hub selector.
- * The hub list is retrieved from Moodle.org hub directory.
- * Also displayed, a text field to enter private hub url + its password
- */
-class hub_selector_form extends moodleform {
-
- public function definition() {
- global $CFG, $OUTPUT;
- $mform = & $this->_form;
- $mform->addElement('header', 'site', get_string('selecthub', 'hub'));
-
- //retrieve the hub list on the hub directory by web service
- $function = 'hubdirectory_get_hubs';
- $params = array();
- $serverurl = HUB_HUBDIRECTORYURL . "/local/hubdirectory/webservice/webservices.php";
- require_once($CFG->dirroot . "/webservice/xmlrpc/lib.php");
- $xmlrpcclient = new webservice_xmlrpc_client($serverurl, 'publichubdirectory');
- try {
- $hubs = $xmlrpcclient->call($function, $params);
- } catch (Exception $e) {
- $error = $OUTPUT->notification(get_string('errorhublisting', 'hub', $e->getMessage()));
- $mform->addElement('static', 'errorhub', '', $error);
- $hubs = array();
- }
-
- //remove moodle.org from the hub list
- foreach ($hubs as $key => $hub) {
- if ($hub['url'] == HUB_MOODLEORGHUBURL || $hub['url'] == HUB_OLDMOODLEORGHUBURL) {
- unset($hubs[$key]);
- }
- }
-
- //Public hub list
- $options = array();
- foreach ($hubs as $hub) {
- //to not display a name longer than 100 character (too big)
- if (core_text::strlen($hub['name']) > 100) {
- $hubname = core_text::substr($hub['name'], 0, 100);
- $hubname = $hubname . "...";
- } else {
- $hubname = $hub['name'];
- }
- $options[$hub['url']] = $hubname;
- $mform->addElement('hidden', clean_param($hub['url'], PARAM_ALPHANUMEXT), $hubname);
- $mform->setType(clean_param($hub['url'], PARAM_ALPHANUMEXT), PARAM_ALPHANUMEXT);
- }
- if (!empty($hubs)) {
- $mform->addElement('select', 'publichub', get_string('publichub', 'hub'),
- $options, array("size" => 15));
- $mform->setType('publichub', PARAM_URL);
- }
-
- $mform->addElement('static', 'or', '', get_string('orenterprivatehub', 'hub'));
-
- //Private hub
- $mform->addElement('text', 'unlistedurl', get_string('privatehuburl', 'hub'),
- array('class' => 'registration_textfield'));
- $mform->setType('unlistedurl', PARAM_URL);
- $mform->addElement('text', 'password', get_string('password'),
- array('class' => 'registration_textfield'));
- $mform->setType('password', PARAM_RAW);
-
- $this->add_action_buttons(false, get_string('selecthub', 'hub'));
- }
-
- /**
- * Check the unlisted URL is a URL
- */
- function validation($data, $files) {
- global $CFG;
- $errors = parent::validation($data, $files);
-
- $unlistedurl = $this->_form->_submitValues['unlistedurl'];
-
- if (empty($unlistedurl)) {
- $errors['unlistedurl'] = get_string('badurlformat', 'hub');
- }
-
- return $errors;
- }
-
-}
-
-/**
- * The site registration form. Information will be sent to a given hub.
- */
-class site_registration_form extends moodleform {
-
- public function definition() {
- global $CFG, $DB;
-
- $strrequired = get_string('required');
- $mform = & $this->_form;
- $huburl = $this->_customdata['huburl'];
- $hubname = $this->_customdata['hubname'];
- $password = $this->_customdata['password'];
- $admin = get_admin();
- $site = get_site();
-
- //retrieve config for this hub and set default if they don't exist
- $cleanhuburl = clean_param($huburl, PARAM_ALPHANUMEXT);
- $sitename = get_config('hub', 'site_name_' . $cleanhuburl);
- if ($sitename === false) {
- $sitename = format_string($site->fullname, true, array('context' => context_course::instance(SITEID)));
- }
- $sitedescription = get_config('hub', 'site_description_' . $cleanhuburl);
- if ($sitedescription === false) {
- $sitedescription = $site->summary;
- }
- $contactname = get_config('hub', 'site_contactname_' . $cleanhuburl);
- if ($contactname === false) {
- $contactname = fullname($admin, true);
- }
- $contactemail = get_config('hub', 'site_contactemail_' . $cleanhuburl);
- if ($contactemail === false) {
- $contactemail = $admin->email;
- }
- $contactphone = get_config('hub', 'site_contactphone_' . $cleanhuburl);
- if ($contactphone === false) {
- $contactphone = $admin->phone1;
- }
- $imageurl = get_config('hub', 'site_imageurl_' . $cleanhuburl);
- $privacy = get_config('hub', 'site_privacy_' . $cleanhuburl);
- $address = get_config('hub', 'site_address_' . $cleanhuburl);
- if ($address === false) {
- $address = '';
- }
- $region = get_config('hub', 'site_region_' . $cleanhuburl);
- $country = get_config('hub', 'site_country_' . $cleanhuburl);
- if (empty($country)) {
- $country = $admin->country ?: $CFG->country;
- }
- $language = get_config('hub', 'site_language_' . $cleanhuburl);
- if ($language === false) {
- $language = explode('_', current_language())[0];
- }
- $geolocation = get_config('hub', 'site_geolocation_' . $cleanhuburl);
- if ($geolocation === false) {
- $geolocation = '';
- }
- $contactable = get_config('hub', 'site_contactable_' . $cleanhuburl);
- $emailalert = get_config('hub', 'site_emailalert_' . $cleanhuburl);
- $emailalert = ($emailalert === false || $emailalert) ? 1 : 0;
- $coursesnumber = get_config('hub', 'site_coursesnumber_' . $cleanhuburl);
- $usersnumber = get_config('hub', 'site_usersnumber_' . $cleanhuburl);
- $roleassignmentsnumber = get_config('hub', 'site_roleassignmentsnumber_' . $cleanhuburl);
- $postsnumber = get_config('hub', 'site_postsnumber_' . $cleanhuburl);
- $questionsnumber = get_config('hub', 'site_questionsnumber_' . $cleanhuburl);
- $resourcesnumber = get_config('hub', 'site_resourcesnumber_' . $cleanhuburl);
- $badgesnumber = get_config('hub', 'site_badges_' . $cleanhuburl);
- $issuedbadgesnumber = get_config('hub', 'site_issuedbadges_' . $cleanhuburl);
- $mediancoursesize = get_config('hub', 'site_mediancoursesize_' . $cleanhuburl);
- $participantnumberaveragecfg = get_config('hub', 'site_participantnumberaverage_' . $cleanhuburl);
- $modulenumberaveragecfg = get_config('hub', 'site_modulenumberaverage_' . $cleanhuburl);
- // Mobile related information.
- $mobileservicesenabled = get_config('hub', 'site_mobileservicesenabled_' . $cleanhuburl);
- $mobilenotificationsenabled = get_config('hub', 'site_mobilenotificationsenabled_' . $cleanhuburl);
- $registereduserdevices = get_config('hub', 'site_registereduserdevices_' . $cleanhuburl);
- $registeredactiveuserdevices = get_config('hub', 'site_registeredactiveuserdevices_' . $cleanhuburl);
-
- //hidden parameters
- $mform->addElement('hidden', 'huburl', $huburl);
- $mform->setType('huburl', PARAM_URL);
- $mform->addElement('hidden', 'hubname', $hubname);
- $mform->setType('hubname', PARAM_TEXT);
- $mform->addElement('hidden', 'password', $password);
- $mform->setType('password', PARAM_RAW);
-
- //the input parameters
- $mform->addElement('header', 'moodle', get_string('registrationinfo', 'hub'));
-
- $mform->addElement('text', 'name', get_string('sitename', 'hub'),
- array('class' => 'registration_textfield'));
- $mform->addRule('name', $strrequired, 'required', null, 'client');
- $mform->setType('name', PARAM_TEXT);
- $mform->setDefault('name', $sitename);
- $mform->addHelpButton('name', 'sitename', 'hub');
-
- $options = array();
- $registrationmanager = new registration_manager();
- $options[HUB_SITENOTPUBLISHED] = $registrationmanager->get_site_privacy_string(HUB_SITENOTPUBLISHED);
- $options[HUB_SITENAMEPUBLISHED] = $registrationmanager->get_site_privacy_string(HUB_SITENAMEPUBLISHED);
- $options[HUB_SITELINKPUBLISHED] = $registrationmanager->get_site_privacy_string(HUB_SITELINKPUBLISHED);
- $mform->addElement('select', 'privacy', get_string('siteprivacy', 'hub'), $options);
- $mform->setDefault('privacy', $privacy);
- $mform->setType('privacy', PARAM_ALPHA);
- $mform->addHelpButton('privacy', 'privacy', 'hub');
- unset($options);
-
- $mform->addElement('textarea', 'description', get_string('sitedesc', 'hub'),
- array('rows' => 8, 'cols' => 41));
- $mform->addRule('description', $strrequired, 'required', null, 'client');
- $mform->setDefault('description', $sitedescription);
- $mform->setType('description', PARAM_TEXT);
- $mform->addHelpButton('description', 'sitedesc', 'hub');
-
- $languages = get_string_manager()->get_list_of_languages();
- core_collator::asort($languages);
- $mform->addElement('select', 'language', get_string('sitelang', 'hub'),
- $languages);
- $mform->setType('language', PARAM_ALPHANUMEXT);
- $mform->addHelpButton('language', 'sitelang', 'hub');
- $mform->setDefault('language', $language);
-
- $mform->addElement('textarea', 'address', get_string('postaladdress', 'hub'),
- array('rows' => 4, 'cols' => 41));
- $mform->setType('address', PARAM_TEXT);
- $mform->setDefault('address', $address);
- $mform->addHelpButton('address', 'postaladdress', 'hub');
-
- //TODO: use the region array I generated
-// $mform->addElement('select', 'region', get_string('selectaregion'), array('-' => '-'));
-// $mform->setDefault('region', $region);
- $mform->addElement('hidden', 'regioncode', '-');
- $mform->setType('regioncode', PARAM_ALPHANUMEXT);
-
- $countries = ['' => ''] + get_string_manager()->get_list_of_countries();
- $mform->addElement('select', 'countrycode', get_string('sitecountry', 'hub'), $countries);
- $mform->setDefault('countrycode', $country);
- $mform->setType('countrycode', PARAM_ALPHANUMEXT);
- $mform->addHelpButton('countrycode', 'sitecountry', 'hub');
- $mform->addRule('countrycode', $strrequired, 'required', null, 'client');
-
- $mform->addElement('text', 'geolocation', get_string('sitegeolocation', 'hub'),
- array('class' => 'registration_textfield'));
- $mform->setDefault('geolocation', $geolocation);
- $mform->setType('geolocation', PARAM_RAW);
- $mform->addHelpButton('geolocation', 'sitegeolocation', 'hub');
-
- $mform->addElement('text', 'contactname', get_string('siteadmin', 'hub'),
- array('class' => 'registration_textfield'));
- $mform->addRule('contactname', $strrequired, 'required', null, 'client');
- $mform->setType('contactname', PARAM_TEXT);
- $mform->setDefault('contactname', $contactname);
- $mform->addHelpButton('contactname', 'siteadmin', 'hub');
-
- $mform->addElement('text', 'contactphone', get_string('sitephone', 'hub'),
- array('class' => 'registration_textfield'));
- $mform->setType('contactphone', PARAM_TEXT);
- $mform->setDefault('contactphone', $contactphone);
- $mform->addHelpButton('contactphone', 'sitephone', 'hub');
- $mform->setForceLtr('contactphone');
-
- $mform->addElement('text', 'contactemail', get_string('siteemail', 'hub'),
- array('class' => 'registration_textfield'));
- $mform->addRule('contactemail', $strrequired, 'required', null, 'client');
- $mform->setType('contactemail', PARAM_EMAIL);
- $mform->setDefault('contactemail', $contactemail);
- $mform->addHelpButton('contactemail', 'siteemail', 'hub');
-
- $options = array();
- $options[0] = get_string("registrationcontactno");
- $options[1] = get_string("registrationcontactyes");
- $mform->addElement('select', 'contactable', get_string('siteregistrationcontact', 'hub'), $options);
- $mform->setDefault('contactable', $contactable);
- $mform->setType('contactable', PARAM_INT);
- $mform->addHelpButton('contactable', 'siteregistrationcontact', 'hub');
- unset($options);
-
- $options = array();
- $options[0] = get_string("registrationno");
- $options[1] = get_string("registrationyes");
- $mform->addElement('select', 'emailalert', get_string('siteregistrationemail', 'hub'), $options);
- $mform->setDefault('emailalert', $emailalert);
- $mform->setType('emailalert', PARAM_INT);
- $mform->addHelpButton('emailalert', 'siteregistrationemail', 'hub');
- unset($options);
-
- //TODO site logo
- $mform->addElement('hidden', 'imageurl', ''); //TODO: temporary
- $mform->setType('imageurl', PARAM_URL);
-
- $mform->addElement('static', 'urlstring', get_string('siteurl', 'hub'), $CFG->wwwroot);
- $mform->addHelpButton('urlstring', 'siteurl', 'hub');
-
- $mform->addElement('static', 'versionstring', get_string('siteversion', 'hub'), $CFG->version);
- $mform->addElement('hidden', 'moodleversion', $CFG->version);
- $mform->setType('moodleversion', PARAM_INT);
- $mform->addHelpButton('versionstring', 'siteversion', 'hub');
-
- $mform->addElement('static', 'releasestring', get_string('siterelease', 'hub'), $CFG->release);
- $mform->addElement('hidden', 'moodlerelease', $CFG->release);
- $mform->setType('moodlerelease', PARAM_TEXT);
- $mform->addHelpButton('releasestring', 'siterelease', 'hub');
-
- /// Display statistic that are going to be retrieve by the hub
- $coursecount = $DB->count_records('course') - 1;
- $usercount = $DB->count_records('user', array('deleted' => 0));
- $roleassigncount = $DB->count_records('role_assignments');
- $postcount = $DB->count_records('forum_posts');
- $questioncount = $DB->count_records('question');
- $resourcecount = $DB->count_records('resource');
- require_once($CFG->dirroot . "/course/lib.php");
- $participantnumberaverage = number_format(average_number_of_participants(), 2);
- $modulenumberaverage = number_format(average_number_of_courses_modules(), 2);
- require_once($CFG->libdir . '/badgeslib.php');
- $badges = $DB->count_records_select('badge', 'status <> ' . BADGE_STATUS_ARCHIVED);
- $issuedbadges = $DB->count_records('badge_issued');
- // Mobile related information.
- $ismobileenabled = false;
- $aremobilenotificationsenabled = false;
- $registereduserdevicescount = 0;
- $registeredactiveuserdevicescount = 0;
- if (!empty($CFG->enablewebservices) && !empty($CFG->enablemobilewebservice)) {
- $ismobileenabled = true;
- $registereduserdevicescount = $DB->count_records('user_devices');
- $airnotifierextpath = $CFG->dirroot . '/message/output/airnotifier/externallib.php';
- if (file_exists($airnotifierextpath)) { // Maybe some one uninstalled the plugin.
- require_once($airnotifierextpath);
- $aremobilenotificationsenabled = (bool) message_airnotifier_external::is_system_configured();
- $registeredactiveuserdevicescount = $DB->count_records('message_airnotifier_devices', array('enable' => 1));
- }
- }
-
- if (HUB_MOODLEORGHUBURL != $huburl) {
- $mform->addElement('checkbox', 'courses', get_string('sendfollowinginfo', 'hub'),
- " " . get_string('coursesnumber', 'hub', $coursecount));
- $mform->setDefault('courses', $coursesnumber != -1);
- $mform->setType('courses', PARAM_INT);
- $mform->addHelpButton('courses', 'sendfollowinginfo', 'hub');
-
- $mform->addElement('checkbox', 'users', '',
- " " . get_string('usersnumber', 'hub', $usercount));
- $mform->setDefault('users', $usersnumber != -1);
- $mform->setType('users', PARAM_INT);
-
- $mform->addElement('checkbox', 'roleassignments', '',
- " " . get_string('roleassignmentsnumber', 'hub', $roleassigncount));
- $mform->setDefault('roleassignments', $roleassignmentsnumber != -1);
- $mform->setType('roleassignments', PARAM_INT);
-
- $mform->addElement('checkbox', 'posts', '',
- " " . get_string('postsnumber', 'hub', $postcount));
- $mform->setDefault('posts', $postsnumber != -1);
- $mform->setType('posts', PARAM_INT);
-
- $mform->addElement('checkbox', 'questions', '',
- " " . get_string('questionsnumber', 'hub', $questioncount));
- $mform->setDefault('questions', $questionsnumber != -1);
- $mform->setType('questions', PARAM_INT);
-
- $mform->addElement('checkbox', 'resources', '',
- " " . get_string('resourcesnumber', 'hub', $resourcecount));
- $mform->setDefault('resources', $resourcesnumber != -1);
- $mform->setType('resources', PARAM_INT);
-
- $mform->addElement('checkbox', 'badges', '',
- " " . get_string('badgesnumber', 'hub', $badges));
- $mform->setDefault('badges', $badgesnumber != -1);
- $mform->setType('badges', PARAM_INT);
-
- $mform->addElement('checkbox', 'issuedbadges', '',
- " " . get_string('issuedbadgesnumber', 'hub', $issuedbadges));
- $mform->setDefault('issuedbadges', $issuedbadgesnumber != -1);
- $mform->setType('issuedbadges', PARAM_INT);
-
- $mform->addElement('checkbox', 'participantnumberaverage', '',
- " " . get_string('participantnumberaverage', 'hub', $participantnumberaverage));
- $mform->setDefault('participantnumberaverage', $participantnumberaveragecfg != -1);
- $mform->setType('participantnumberaverage', PARAM_FLOAT);
-
- $mform->addElement('checkbox', 'modulenumberaverage', '',
- " " . get_string('modulenumberaverage', 'hub', $modulenumberaverage));
- $mform->setDefault('modulenumberaverage', $modulenumberaveragecfg != -1);
- $mform->setType('modulenumberaverage', PARAM_FLOAT);
-
- $mobileservicestatus = $ismobileenabled ? 'yes' : 'no';
- $mform->addElement('checkbox', 'mobileservicesenabled', '',
- " " . get_string('mobileservicesenabled', 'hub', $mobileservicestatus));
- $mform->setDefault('mobileservicesenabled', $mobileservicesenabled != -1);
- $mform->setType('mobileservicesenabled', PARAM_INT);
-
- $mobilenotificationsstatus = $aremobilenotificationsenabled ? 'yes' : 'no';
- $mform->addElement('checkbox', 'mobilenotificationsenabled', '',
- " " . get_string('mobilenotificationsenabled', 'hub', $mobilenotificationsstatus));
- $mform->setDefault('mobilenotificationsenabled', $mobilenotificationsenabled != -1);
- $mform->setType('mobilenotificationsenabled', PARAM_INT);
-
- $mform->addElement('checkbox', 'registereduserdevices', '',
- " " . get_string('registereduserdevices', 'hub', $registereduserdevicescount));
- $mform->setDefault('registereduserdevices', $registereduserdevices != -1);
- $mform->setType('registereduserdevices', PARAM_INT);
-
- $mform->addElement('checkbox', 'registeredactiveuserdevices', '',
- " " . get_string('registeredactiveuserdevices', 'hub', $registeredactiveuserdevicescount));
- $mform->setDefault('registeredactiveuserdevices', $registeredactiveuserdevices != -1);
- $mform->setType('registeredactiveuserdevices', PARAM_INT);
- } else {
- $mform->addElement('static', 'courseslabel', get_string('sendfollowinginfo', 'hub'),
- " " . get_string('coursesnumber', 'hub', $coursecount));
- $mform->addElement('hidden', 'courses', 1);
- $mform->setType('courses', PARAM_INT);
- $mform->addHelpButton('courseslabel', 'sendfollowinginfo', 'hub');
-
- $mform->addElement('static', 'userslabel', '',
- " " . get_string('usersnumber', 'hub', $usercount));
- $mform->addElement('hidden', 'users', 1);
- $mform->setType('users', PARAM_INT);
-
- $mform->addElement('static', 'roleassignmentslabel', '',
- " " . get_string('roleassignmentsnumber', 'hub', $roleassigncount));
- $mform->addElement('hidden', 'roleassignments', 1);
- $mform->setType('roleassignments', PARAM_INT);
-
- $mform->addElement('static', 'postslabel', '',
- " " . get_string('postsnumber', 'hub', $postcount));
- $mform->addElement('hidden', 'posts', 1);
- $mform->setType('posts', PARAM_INT);
-
- $mform->addElement('static', 'questionslabel', '',
- " " . get_string('questionsnumber', 'hub', $questioncount));
- $mform->addElement('hidden', 'questions', 1);
- $mform->setType('questions', PARAM_INT);
-
- $mform->addElement('static', 'resourceslabel', '',
- " " . get_string('resourcesnumber', 'hub', $resourcecount));
- $mform->addElement('hidden', 'resources', 1);
- $mform->setType('resources', PARAM_INT);
-
- $mform->addElement('static', 'badgeslabel', '',
- " " . get_string('badgesnumber', 'hub', $badges));
- $mform->addElement('hidden', 'badges', 1);
- $mform->setType('badges', PARAM_INT);
-
- $mform->addElement('static', 'issuedbadgeslabel', '',
- " " . get_string('issuedbadgesnumber', 'hub', $issuedbadges));
- $mform->addElement('hidden', 'issuedbadges', true);
- $mform->setType('issuedbadges', PARAM_INT);
-
- $mform->addElement('static', 'participantnumberaveragelabel', '',
- " " . get_string('participantnumberaverage', 'hub', $participantnumberaverage));
- $mform->addElement('hidden', 'participantnumberaverage', 1);
- $mform->setType('participantnumberaverage', PARAM_FLOAT);
-
- $mform->addElement('static', 'modulenumberaveragelabel', '',
- " " . get_string('modulenumberaverage', 'hub', $modulenumberaverage));
- $mform->addElement('hidden', 'modulenumberaverage', 1);
- $mform->setType('modulenumberaverage', PARAM_FLOAT);
-
- $mobileservicestatus = $ismobileenabled ? 'yes' : 'no';
- $mform->addElement('static', 'mobileservicesenabledlabel', '',
- " " . get_string('mobileservicesenabled', 'hub', $mobileservicestatus));
- $mform->addElement('hidden', 'mobileservicesenabled', 1);
- $mform->setType('mobileservicesenabled', PARAM_INT);
-
- $mobilenotificationsstatus = $aremobilenotificationsenabled ? 'yes' : 'no';
- $mform->addElement('static', 'mobilenotificationsenabledlabel', '',
- " " . get_string('mobilenotificationsenabled', 'hub', $mobilenotificationsstatus));
- $mform->addElement('hidden', 'mobilenotificationsenabled', 1);
- $mform->setType('mobilenotificationsenabled', PARAM_INT);
-
- $mform->addElement('static', 'registereduserdeviceslabel', '',
- " " . get_string('registereduserdevices', 'hub', $registereduserdevicescount));
- $mform->addElement('hidden', 'registereduserdevices', 1);
- $mform->setType('registereduserdevices', PARAM_INT);
-
- $mform->addElement('static', 'registeredactiveuserdeviceslabel', '',
- " " . get_string('registeredactiveuserdevices', 'hub', $registeredactiveuserdevicescount));
- $mform->addElement('hidden', 'registeredactiveuserdevices', 1);
- $mform->setType('registeredactiveuserdevices', PARAM_INT);
- }
-
- //check if it's a first registration or update
- $hubregistered = $registrationmanager->get_registeredhub($huburl);
-
- if (!empty($hubregistered)) {
- $buttonlabel = get_string('updatesite', 'hub',
- !empty($hubname) ? $hubname : $huburl);
- $mform->addElement('hidden', 'update', true);
- $mform->setType('update', PARAM_BOOL);
- } else {
- $buttonlabel = get_string('registersite', 'hub',
- !empty($hubname) ? $hubname : $huburl);
- }
-
- $this->add_action_buttons(false, $buttonlabel);
- }
-
-}
-
+debugging('Support for alternative hubs has been removed from Moodle in 3.4. For communication with moodle.net ' .
+ 'see lib/classes/hub/ .', DEBUG_DEVELOPER);
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
-/*
+/**
* @package moodle
* @subpackage registration
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
*
- * On this page the administrator selects which hub he wants to register (except for moodle.net)
- * Admins can register with moodle.net via the site admin menu "Registration" link.
- * On this page the administrator can also unregister from any hubs including moodle.net.
+ * This page displays the site registration form for Moodle.net.
+ * It handles redirection to the hub to continue the registration workflow process.
+ * It also handles update operation by web service.
*/
-require('../../config.php');
-
+require_once('../../config.php');
require_once($CFG->libdir . '/adminlib.php');
-require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
-require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/forms.php');
-require_once($CFG->dirroot . '/course/publish/lib.php');
-require_once($CFG->dirroot . "/webservice/xmlrpc/lib.php");
-
-admin_externalpage_setup('registrationhubs');
-$renderer = $PAGE->get_renderer('core', 'register');
+admin_externalpage_setup('registrationmoodleorg');
$unregistration = optional_param('unregistration', 0, PARAM_INT);
-$cleanregdata = optional_param('cleanregdata', 0, PARAM_BOOL);
-$confirm = optional_param('confirm', 0, PARAM_INT);
-$huburl = optional_param('huburl', '', PARAM_URL);
-$cancel = optional_param('cancel', null, PARAM_ALPHA);
-
-$registrationmanager = new registration_manager();
-$publicationmanager = new course_publish_manager();
-$errormessage = '';
-if (empty($cancel) and $unregistration and $confirm and confirm_sesskey()) {
-
- $hub = $registrationmanager->get_registeredhub($huburl);
-
- //unpublish course and unregister the site by web service
- if (!$cleanregdata) {
-
- //check if we need to unpublish courses
- //enrollable courses
- $unpublishalladvertisedcourses = optional_param('unpublishalladvertisedcourses', 0, PARAM_INT);
- $hubcourseids = array();
- if ($unpublishalladvertisedcourses) {
- $enrollablecourses = $publicationmanager->get_publications($huburl, null, 1);
- if (!empty($enrollablecourses)) {
- foreach ($enrollablecourses as $enrollablecourse) {
- $hubcourseids[] = $enrollablecourse->hubcourseid;
- }
- }
- }
- //downloadable courses
- $unpublishalluploadedcourses = optional_param('unpublishalluploadedcourses', 0, PARAM_INT);
- if ($unpublishalluploadedcourses) {
- $downloadablecourses = $publicationmanager->get_publications($huburl, null, 0);
- if (!empty($downloadablecourses)) {
- foreach ($downloadablecourses as $downloadablecourse) {
- $hubcourseids[] = $downloadablecourse->hubcourseid;
- }
- }
- }
- //unpublish the courses by web service
- if (!empty($hubcourseids)) {
- $function = 'hub_unregister_courses';
- $params = array('courseids' => $hubcourseids);
- $serverurl = $huburl . "/local/hub/webservice/webservices.php";
- $xmlrpcclient = new webservice_xmlrpc_client($serverurl, $hub->token);
- try {
- $result = $xmlrpcclient->call($function, $params);
- //delete the published courses
- if (!empty($enrollablecourses)) {
- $publicationmanager->delete_hub_publications($huburl, 1);
- }
- if (!empty($downloadablecourses)) {
- $publicationmanager->delete_hub_publications($huburl, 0);
- }
- } catch (Exception $e) {
- $errormessage = $e->getMessage();
- $errormessage .= html_writer::empty_tag('br') .
- get_string('errorunpublishcourses', 'hub');
- $confirm = false;
- $cleanregdata = 1;
- }
- }
- }
+if ($unregistration && \core\hub\registration::is_registered()) {
+ $siteunregistrationform = new \core\hub\site_unregistration_form();
- //course unpublish went ok, unregister the site now
- if ($confirm) {
- $function = 'hub_unregister_site';
- $params = array();
- $serverurl = $huburl . "/local/hub/webservice/webservices.php";
- $xmlrpcclient = new webservice_xmlrpc_client($serverurl, $hub->token);
- try {
- $result = $xmlrpcclient->call($function, $params);
- } catch (Exception $e) {
- if (!$cleanregdata) {
- $errormessage = $e->getMessage();
- $confirm = false;
- $cleanregdata = 1;
- }
+ if ($siteunregistrationform->is_cancelled()) {
+ redirect(new moodle_url('/admin/registration/index.php'));
+ } else if ($data = $siteunregistrationform->get_data()) {
+ if (\core\hub\registration::unregister($data->unpublishalladvertisedcourses,
+ $data->unpublishalluploadedcourses)) {
+ redirect(new moodle_url('/admin/registration/index.php'));
}
}
- //check that we are still processing the unregistration,
- //it could have been unset if an exception were previsouly catched
- if ($confirm) {
- $registrationmanager->delete_registeredhub($huburl);
- }
+ echo $OUTPUT->header();
+ echo $OUTPUT->heading(get_string('unregisterfrom', 'hub', 'Moodle.net'), 3, 'main');
+ $siteunregistrationform->display();
+ echo $OUTPUT->footer();
+ exit;
}
-if (empty($cancel) and $unregistration and !$confirm) {
-
- echo $OUTPUT->header();
+$siteregistrationform = new \core\hub\site_registration_form();
+if ($fromform = $siteregistrationform->get_data()) {
- //do not check sesskey if confirm = false because this script is linked into email message
- if (!empty($errormessage)) {
- echo $OUTPUT->notification(get_string('unregistrationerror', 'hub', $errormessage));
- }
+ // Save the settings.
+ \core\hub\registration::save_site_info($fromform);
- $hub = $registrationmanager->get_registeredhub($huburl);
- echo $OUTPUT->heading(get_string('unregisterfrom', 'hub', $hub->hubname), 3, 'main');
- if ($cleanregdata) {
- $siteunregistrationform = new site_clean_registration_data_form('',
- array('huburl' => $huburl, 'hubname' => $hub->hubname));
+ if (\core\hub\registration::is_registered()) {
+ \core\hub\registration::update_manual();
+ redirect(new moodle_url('/admin/registration/index.php'));
} else {
- $siteunregistrationform = new site_unregistration_form('',
- array('huburl' => $huburl, 'hubname' => $hub->hubname));
+ \core\hub\registration::register();
+ // This method will redirect away.
}
- $siteunregistrationform->display();
-} else {
- $registeredonmoodleorg = false;
- $moodleorghub = $registrationmanager->get_registeredhub(HUB_MOODLEORGHUBURL);
- if (!empty($moodleorghub)) {
- $registeredonmoodleorg = true;
- }
-
- // load the hub selector form
- $hubselectorform = new hub_selector_form();
- $fromform = $hubselectorform->get_data();
- $selectedhuburl = optional_param('publichub', false, PARAM_URL);
- $unlistedhuburl = optional_param('unlistedurl', false, PARAM_TEXT);
- $password = optional_param('password', '', PARAM_RAW);
- $registeringhuburl = null;
- if (!empty($unlistedhuburl)) {
- if (clean_param($unlistedhuburl, PARAM_URL) !== '') {
- $registeringhuburl = $unlistedhuburl;
- }
- } else if (!empty($selectedhuburl)) {
- $registeringhuburl = $selectedhuburl;
- }
+}
- // a hub has been selected, redirect to the hub registration page
- if (empty($cancel) and !empty($registeringhuburl) and confirm_sesskey()) {
- $hubname = optional_param(clean_param($registeringhuburl, PARAM_ALPHANUMEXT), '', PARAM_TEXT);
- $params = array('sesskey' => sesskey(), 'huburl' => $registeringhuburl,
- 'password' => $password, 'hubname' => $hubname);
- redirect(new moodle_url($CFG->wwwroot . "/" . $CFG->admin . "/registration/register.php",
- $params));
- }
+// OUTPUT SECTION.
- echo $OUTPUT->header();
+echo $OUTPUT->header();
- //check if the site is registered on Moodle.org and display a message about registering on MOOCH
- $adminrenderer = $PAGE->get_renderer('core', 'admin');
- echo $adminrenderer->warn_if_not_registered();
+// Current status of registration on Moodle.net.
- //do not check sesskey if confirm = false because this script is linked into email message
- if (!empty($errormessage)) {
- echo $OUTPUT->notification(get_string('unregistrationerror', 'hub', $errormessage));
+$notificationtype = \core\output\notification::NOTIFY_ERROR;
+if (\core\hub\registration::is_registered()) {
+ $lastupdated = \core\hub\registration::get_last_updated();
+ if ($lastupdated == 0) {
+ $registrationmessage = get_string('pleaserefreshregistrationunknown', 'admin');
+ } else {
+ $lastupdated = userdate($lastupdated, get_string('strftimedate', 'langconfig'));
+ $registrationmessage = get_string('pleaserefreshregistration', 'admin', $lastupdated);
+ $notificationtype = \core\output\notification::NOTIFY_INFO;
}
+ echo $OUTPUT->notification($registrationmessage, $notificationtype);
+} else {
+ $registrationmessage = get_string('registrationwarning', 'admin');
+ echo $OUTPUT->notification($registrationmessage, $notificationtype);
+}
- echo $OUTPUT->heading(get_string('registerwith', 'hub'));
+// Heading.
+if (\core\hub\registration::is_registered()) {
+ echo $OUTPUT->heading(get_string('updatesite', 'hub', 'Moodle.net'));
+} else {
+ echo $OUTPUT->heading(get_string('registerwithmoodleorg', 'admin'));
+}
- $hubselectorform->display();
+$renderer = $PAGE->get_renderer('core', 'register');
+echo $renderer->moodleorg_registration_message();
- if (extension_loaded('xmlrpc')) {
- $hubs = $registrationmanager->get_registered_on_hubs();
- if (!empty($hubs)) {
- echo $OUTPUT->heading(get_string('registeredon', 'hub'), 3, 'main');
- echo $renderer->registeredonhublisting($hubs);
- }
- } else { //display notice about xmlrpc
- $xmlrpcnotification = $OUTPUT->doc_link('admin/environment/php_extension/xmlrpc', '');
- $xmlrpcnotification .= get_string('xmlrpcdisabledregistration', 'hub');
- echo $OUTPUT->notification($xmlrpcnotification);
- }
+$siteregistrationform->display();
+
+if (\core\hub\registration::is_registered()) {
+ // Unregister link.
+ $unregisterhuburl = new moodle_url("/admin/registration/index.php", ['unregistration' => 1]);
+ echo html_writer::div(html_writer::link($unregisterhuburl, get_string('unregister', 'hub')), 'unregister');
}
echo $OUTPUT->footer();
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
-
-
-
-//// SITE PRIVACY /////
-
-/**
- * Site privacy: private
- */
-define('HUB_SITENOTPUBLISHED', 'notdisplayed');
-
-/**
- * Site privacy: public
- */
-define('HUB_SITENAMEPUBLISHED', 'named');
-
-/**
- * Site privacy: public and global
- */
-define('HUB_SITELINKPUBLISHED', 'linked');
-
-/**
- *
- * Site registration library
- *
- * @package course
- * @copyright 2010 Moodle Pty Ltd (http://moodle.com)
- * @author Jerome Mouneyrac
- * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class registration_manager {
-
- /**
- * Automatically update the registration on all hubs
- */
- public function cron() {
- global $CFG;
- if (extension_loaded('xmlrpc')) {
- $function = 'hub_update_site_info';
- require_once($CFG->dirroot . "/webservice/xmlrpc/lib.php");
-
- // Update all hubs where the site is registered.
- $hubs = $this->get_registered_on_hubs();
- if (empty($hubs)) {
- mtrace(get_string('registrationwarning', 'admin'));
- }
- foreach ($hubs as $hub) {
- // Update the registration.
- $siteinfo = $this->get_site_info($hub->huburl);
- $params = array('siteinfo' => $siteinfo);
- $serverurl = $hub->huburl . "/local/hub/webservice/webservices.php";
- $xmlrpcclient = new webservice_xmlrpc_client($serverurl, $hub->token);
- try {
- $result = $xmlrpcclient->call($function, $params);
- $this->update_registeredhub($hub); // To update timemodified.
- mtrace(get_string('siteupdatedcron', 'hub', $hub->hubname));
- } catch (Exception $e) {
- $errorparam = new stdClass();
- $errorparam->errormessage = $e->getMessage();
- $errorparam->hubname = $hub->hubname;
- mtrace(get_string('errorcron', 'hub', $errorparam));
- }
- }
- } else {
- mtrace(get_string('errorcronnoxmlrpc', 'hub'));
- }
- }
-
- /**
- * Return the site secret for a given hub
- * site identifier is assigned to Mooch
- * each hub has a unique and personal site secret.
- * @param string $huburl
- * @return string site secret
- */
- public function get_site_secret_for_hub($huburl) {
- global $DB;
-
- $existingregistration = $DB->get_record('registration_hubs',
- array('huburl' => $huburl));
-
- if (!empty($existingregistration)) {
- return $existingregistration->secret;
- }
-
- if ($huburl == HUB_MOODLEORGHUBURL) {
- $siteidentifier = get_site_identifier();
- } else {
- $siteidentifier = random_string(32) . $_SERVER['HTTP_HOST'];
- }
-
- return $siteidentifier;
-
- }
-
- /**
- * When the site register on a hub, he must call this function
- * @param object $hub where the site is registered on
- * @return integer id of the record
- */
- public function add_registeredhub($hub) {
- global $DB;
- $hub->timemodified = time();
- $id = $DB->insert_record('registration_hubs', $hub);
- return $id;
- }
-
- /**
- * When a site unregister from a hub, he must call this function
- * @param string $huburl the huburl to delete
- */
- public function delete_registeredhub($huburl) {
- global $DB;
- $DB->delete_records('registration_hubs', array('huburl' => $huburl));
- }
-
- /**
- * Get a hub on which the site is registered for a given url or token
- * Mostly use to check if the site is registered on a specific hub
- * @param string $huburl
- * @param string $token
- * @return object the hub
- */
- public function get_registeredhub($huburl = null, $token = null) {
- global $DB;
-
- $params = array();
- if (!empty($huburl)) {
- $params['huburl'] = $huburl;
- }
- if (!empty($token)) {
- $params['token'] = $token;
- }
- $params['confirmed'] = 1;
- $token = $DB->get_record('registration_hubs', $params);
- return $token;
- }
-
- /**
- * Get the hub which has not confirmed that the site is registered on,
- * but for which a request has been sent
- * @param string $huburl
- * @return object the hub
- */
- public function get_unconfirmedhub($huburl) {
- global $DB;
-
- $params = array();
- $params['huburl'] = $huburl;
- $params['confirmed'] = 0;
- $token = $DB->get_record('registration_hubs', $params);
- return $token;
- }
-
- /**
- * Update a registered hub (mostly use to update the confirmation status)
- * @param object $hub the hub
- */
- public function update_registeredhub($hub) {
- global $DB;
- $hub->timemodified = time();
- $DB->update_record('registration_hubs', $hub);
- }
-
- /**
- * Return all hubs where the site is registered
- */
- public function get_registered_on_hubs() {
- global $DB;
- $hubs = $DB->get_records('registration_hubs', array('confirmed' => 1));
- return $hubs;
- }
-
- /**
- * Return site information for a specific hub
- * @param string $huburl
- * @return array site info
- */
- public function get_site_info($huburl) {
- global $CFG, $DB;
-
- $siteinfo = array();
- $cleanhuburl = clean_param($huburl, PARAM_ALPHANUMEXT);
- $siteinfo['name'] = get_config('hub', 'site_name_' . $cleanhuburl);
- $siteinfo['description'] = get_config('hub', 'site_description_' . $cleanhuburl);
- $siteinfo['contactname'] = get_config('hub', 'site_contactname_' . $cleanhuburl);
- $siteinfo['contactemail'] = get_config('hub', 'site_contactemail_' . $cleanhuburl);
- $siteinfo['contactphone'] = get_config('hub', 'site_contactphone_' . $cleanhuburl);
- $siteinfo['imageurl'] = get_config('hub', 'site_imageurl_' . $cleanhuburl);
- $siteinfo['privacy'] = get_config('hub', 'site_privacy_' . $cleanhuburl);
- $siteinfo['street'] = get_config('hub', 'site_address_' . $cleanhuburl);
- $siteinfo['regioncode'] = get_config('hub', 'site_region_' . $cleanhuburl);
- $siteinfo['countrycode'] = get_config('hub', 'site_country_' . $cleanhuburl);
- $siteinfo['geolocation'] = get_config('hub', 'site_geolocation_' . $cleanhuburl);
- $siteinfo['contactable'] = get_config('hub', 'site_contactable_' . $cleanhuburl);
- $siteinfo['emailalert'] = get_config('hub', 'site_emailalert_' . $cleanhuburl);
- if (get_config('hub', 'site_coursesnumber_' . $cleanhuburl) == -1) {
- $coursecount = -1;
- } else {
- $coursecount = $DB->count_records('course') - 1;
- }
- $siteinfo['courses'] = $coursecount;
- if (get_config('hub', 'site_usersnumber_' . $cleanhuburl) == -1) {
- $usercount = -1;
- } else {
- $usercount = $DB->count_records('user', array('deleted' => 0));
- }
- $siteinfo['users'] = $usercount;
-
- if (get_config('hub', 'site_roleassignmentsnumber_' . $cleanhuburl) == -1) {
- $roleassigncount = -1;
- } else {
- $roleassigncount = $DB->count_records('role_assignments');
- }
- $siteinfo['enrolments'] = $roleassigncount;
- if (get_config('hub', 'site_postsnumber_' . $cleanhuburl) == -1) {
- $postcount = -1;
- } else {
- $postcount = $DB->count_records('forum_posts');
- }
- $siteinfo['posts'] = $postcount;
- if (get_config('hub', 'site_questionsnumber_' . $cleanhuburl) == -1) {
- $questioncount = -1;
- } else {
- $questioncount = $DB->count_records('question');
- }
- $siteinfo['questions'] = $questioncount;
- if (get_config('hub', 'site_resourcesnumber_' . $cleanhuburl) == -1) {
- $resourcecount = -1;
- } else {
- $resourcecount = $DB->count_records('resource');
- }
- $siteinfo['resources'] = $resourcecount;
- // Badge statistics.
- require_once($CFG->libdir . '/badgeslib.php');
- if (get_config('hub', 'site_badges_' . $cleanhuburl) == -1) {
- $badges = -1;
- } else {
- $badges = $DB->count_records_select('badge', 'status <> ' . BADGE_STATUS_ARCHIVED);
- }
- $siteinfo['badges'] = $badges;
- if (get_config('hub', 'site_issuedbadges_' . $cleanhuburl) == -1) {
- $issuedbadges = -1;
- } else {
- $issuedbadges = $DB->count_records('badge_issued');
- }
- $siteinfo['issuedbadges'] = $issuedbadges;
- //TODO
- require_once($CFG->dirroot . "/course/lib.php");
- if (get_config('hub', 'site_participantnumberaverage_' . $cleanhuburl) == -1) {
- $participantnumberaverage = -1;
- } else {
- $participantnumberaverage = average_number_of_participants();
- }
- $siteinfo['participantnumberaverage'] = $participantnumberaverage;
- if (get_config('hub', 'site_modulenumberaverage_' . $cleanhuburl) == -1) {
- $modulenumberaverage = -1;
- } else {
- $modulenumberaverage = average_number_of_courses_modules();
- }
- $siteinfo['modulenumberaverage'] = $modulenumberaverage;
- $siteinfo['language'] = get_config('hub', 'site_language_' . $cleanhuburl);
- $siteinfo['moodleversion'] = $CFG->version;
- $siteinfo['moodlerelease'] = $CFG->release;
- $siteinfo['url'] = $CFG->wwwroot;
- // Mobile related information.
- $siteinfo['mobileservicesenabled'] = 0;
- $siteinfo['mobilenotificationsenabled'] = 0;
- $siteinfo['registereduserdevices'] = 0;
- $siteinfo['registeredactiveuserdevices'] = 0;
- if (!empty($CFG->enablewebservices) && !empty($CFG->enablemobilewebservice)) {
- $siteinfo['mobileservicesenabled'] = 1;
- $siteinfo['registereduserdevices'] = $DB->count_records('user_devices');
- $airnotifierextpath = $CFG->dirroot . '/message/output/airnotifier/externallib.php';
- if (file_exists($airnotifierextpath)) { // Maybe some one uninstalled the plugin.
- require_once($airnotifierextpath);
- $siteinfo['mobilenotificationsenabled'] = message_airnotifier_external::is_system_configured();
- $siteinfo['registeredactiveuserdevices'] = $DB->count_records('message_airnotifier_devices', array('enable' => 1));
- }
- }
-
- return $siteinfo;
- }
-
- /**
- * Retrieve the site privacy string matching the define value
- * @param string $privacy must match the define into moodlelib.php
- * @return string
- */
- public function get_site_privacy_string($privacy) {
- switch ($privacy) {
- case HUB_SITENOTPUBLISHED:
- $privacystring = get_string('siteprivacynotpublished', 'hub');
- break;
- case HUB_SITENAMEPUBLISHED:
- $privacystring = get_string('siteprivacypublished', 'hub');
- break;
- case HUB_SITELINKPUBLISHED:
- $privacystring = get_string('siteprivacylinked', 'hub');
- break;
- }
- if (empty($privacystring)) {
- throw new moodle_exception('unknownprivacy');
- }
- return $privacystring;
- }
-
-}
-?>
+defined('MOODLE_INTERNAL') || die();
// //
///////////////////////////////////////////////////////////////////////////
-/*
+/**
* @package moodle
* @subpackage registration
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
require_once('../../config.php');
-require_once($CFG->libdir . '/adminlib.php');
-require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/forms.php');
-require_once($CFG->dirroot . '/webservice/lib.php');
-require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
-require_sesskey();
-
-$huburl = required_param('huburl', PARAM_URL);
-$huburl = rtrim($huburl, "/");
-
-if ($huburl == HUB_MOODLEORGHUBURL) { // register to Moodle.org
- admin_externalpage_setup('registrationmoodleorg');
-} else { //register to a hub
- admin_externalpage_setup('registrationhub');
-}
-
-$password = optional_param('password', '', PARAM_TEXT);
-$hubname = optional_param('hubname', '', PARAM_TEXT);
-
-$registrationmanager = new registration_manager();
-
-$registeredhub = $registrationmanager->get_registeredhub($huburl);
-
-$siteregistrationform = new site_registration_form('',
- array('alreadyregistered' => !empty($registeredhub->token),
- 'huburl' => $huburl, 'hubname' => $hubname,
- 'password' => $password));
-$fromform = $siteregistrationform->get_data();
-
-if (!empty($fromform) and confirm_sesskey()) {
-
- // Set to -1 all optional data marked as "don't send" by the admin.
- // The function get_site_info() will not calculate the optional data if config is set to -1.
- $inputnames = array('courses', 'users', 'roleassignments', 'posts', 'questions', 'resources',
- 'badges', 'issuedbadges', 'modulenumberaverage', 'participantnumberaverage',
- 'mobileservicesenabled', 'mobilenotificationsenabled', 'registereduserdevices', 'registeredactiveuserdevices');
- foreach ($inputnames as $inputname) {
- if (empty($fromform->{$inputname})) {
- $fromform->{$inputname} = -1;
- }
- }
-
- // Save the settings.
- $cleanhuburl = clean_param($huburl, PARAM_ALPHANUMEXT);
- set_config('site_name_' . $cleanhuburl, $fromform->name, 'hub');
- set_config('site_description_' . $cleanhuburl, $fromform->description, 'hub');
- set_config('site_contactname_' . $cleanhuburl, $fromform->contactname, 'hub');
- set_config('site_contactemail_' . $cleanhuburl, $fromform->contactemail, 'hub');
- set_config('site_contactphone_' . $cleanhuburl, $fromform->contactphone, 'hub');
- set_config('site_imageurl_' . $cleanhuburl, $fromform->imageurl, 'hub');
- set_config('site_privacy_' . $cleanhuburl, $fromform->privacy, 'hub');
- set_config('site_address_' . $cleanhuburl, $fromform->address, 'hub');
- set_config('site_region_' . $cleanhuburl, $fromform->regioncode, 'hub');
- set_config('site_country_' . $cleanhuburl, $fromform->countrycode, 'hub');
- set_config('site_language_' . $cleanhuburl, $fromform->language, 'hub');
- set_config('site_geolocation_' . $cleanhuburl, $fromform->geolocation, 'hub');
- set_config('site_contactable_' . $cleanhuburl, $fromform->contactable, 'hub');
- set_config('site_emailalert_' . $cleanhuburl, $fromform->emailalert, 'hub');
- set_config('site_coursesnumber_' . $cleanhuburl, $fromform->courses, 'hub');
- set_config('site_usersnumber_' . $cleanhuburl, $fromform->users, 'hub');
- set_config('site_roleassignmentsnumber_' . $cleanhuburl, $fromform->roleassignments, 'hub');
- set_config('site_postsnumber_' . $cleanhuburl, $fromform->posts, 'hub');
- set_config('site_questionsnumber_' . $cleanhuburl, $fromform->questions, 'hub');
- set_config('site_resourcesnumber_' . $cleanhuburl, $fromform->resources, 'hub');
- set_config('site_badges_' . $cleanhuburl, $fromform->badges, 'hub');
- set_config('site_issuedbadges_' . $cleanhuburl, $fromform->issuedbadges, 'hub');
- set_config('site_modulenumberaverage_' . $cleanhuburl, $fromform->modulenumberaverage, 'hub');
- set_config('site_participantnumberaverage_' . $cleanhuburl, $fromform->participantnumberaverage, 'hub');
- set_config('site_mobileservicesenabled_' . $cleanhuburl, $fromform->mobileservicesenabled, 'hub');
- set_config('site_mobilenotificationsenabled_' . $cleanhuburl, $fromform->mobilenotificationsenabled, 'hub');
- set_config('site_registereduserdevices_' . $cleanhuburl, $fromform->registereduserdevices, 'hub');
- set_config('site_registeredactiveuserdevices_' . $cleanhuburl, $fromform->registeredactiveuserdevices, 'hub');
-}
-
-/////// UPDATE ACTION ////////
-
-// update the hub registration
-$update = optional_param('update', 0, PARAM_INT);
-if ($update and confirm_sesskey()) {
-
- //update the registration
- $function = 'hub_update_site_info';
- $siteinfo = $registrationmanager->get_site_info($huburl);
- $params = array('siteinfo' => $siteinfo);
- $serverurl = $huburl . "/local/hub/webservice/webservices.php";
- require_once($CFG->dirroot . "/webservice/xmlrpc/lib.php");
- $xmlrpcclient = new webservice_xmlrpc_client($serverurl, $registeredhub->token);
- try {
- $result = $xmlrpcclient->call($function, $params);
- $registrationmanager->update_registeredhub($registeredhub); // To update timemodified.
- } catch (Exception $e) {
- $error = $OUTPUT->notification(get_string('errorregistration', 'hub', $e->getMessage()));
- }
-}
-
-/////// FORM REGISTRATION ACTION //////
-
-if (!empty($fromform) and empty($update) and confirm_sesskey()) {
-
- if (!empty($fromform) and confirm_sesskey()) { // if the register button has been clicked
-
- // Retrieve the optional info (specially course number, user number, module number average...).
- $siteinfo = $registrationmanager->get_site_info($huburl);
- $fromform->courses = $siteinfo['courses'];
- $fromform->users = $siteinfo['users'];
- $fromform->enrolments = $siteinfo['enrolments'];
- $fromform->posts = $siteinfo['posts'];
- $fromform->questions = $siteinfo['questions'];
- $fromform->resources = $siteinfo['resources'];
- $fromform->badges = $siteinfo['badges'];
- $fromform->issuedbadges = $siteinfo['issuedbadges'];
- $fromform->modulenumberaverage = $siteinfo['modulenumberaverage'];
- $fromform->participantnumberaverage = $siteinfo['participantnumberaverage'];
- $fromform->street = $siteinfo['street'];
- $fromform->mobileservicesenabled = $siteinfo['mobileservicesenabled'];
- $fromform->mobilenotificationsenabled = $siteinfo['mobilenotificationsenabled'];
- $fromform->registereduserdevices = $siteinfo['registereduserdevices'];
- $fromform->registeredactiveuserdevices = $siteinfo['registeredactiveuserdevices'];
-
- $params = (array) $fromform; //we are using the form input as the redirection parameters (token, url and name)
-
- $unconfirmedhub = $registrationmanager->get_unconfirmedhub($huburl);
- if (empty($unconfirmedhub)) {
- //we save the token into the communication table in order to have a reference
- $unconfirmedhub = new stdClass();
- $unconfirmedhub->token = $registrationmanager->get_site_secret_for_hub($huburl);
- $unconfirmedhub->secret = $unconfirmedhub->token;
- $unconfirmedhub->huburl = $huburl;
- $unconfirmedhub->hubname = $hubname;
- $unconfirmedhub->confirmed = 0;
- $unconfirmedhub->id = $registrationmanager->add_registeredhub($unconfirmedhub);
- }
-
- $params['token'] = $unconfirmedhub->token;
- $params['url'] = $CFG->wwwroot;
- redirect(new moodle_url($huburl . '/local/hub/siteregistration.php', $params));
- }
-}
-
-/////// OUTPUT SECTION /////////////
-
-echo $OUTPUT->header();
-//Display update notification result
-if (!empty($registeredhub->confirmed)) {
- if (!empty($result)) {
- echo $OUTPUT->notification(get_string('siteregistrationupdated', 'hub'), 'notifysuccess');
- }
-}
-
-if (!empty($error)) {
- echo $error;
-}
-
-// Some Moodle.org registration explanation.
-if ($huburl == HUB_MOODLEORGHUBURL) {
- $notificationtype = \core\output\notification::NOTIFY_ERROR;
- if (!empty($registeredhub->token)) {
- if ($registeredhub->timemodified == 0) {
- $registrationmessage = get_string('pleaserefreshregistrationunknown', 'admin');
- } else {
- $lastupdated = userdate($registeredhub->timemodified, get_string('strftimedate', 'langconfig'));
- $registrationmessage = get_string('pleaserefreshregistration', 'admin', $lastupdated);
- $notificationtype = \core\output\notification::NOTIFY_INFO;
- }
- } else {
- $registrationmessage = get_string('registrationwarning', 'admin');
- }
- echo $OUTPUT->notification($registrationmessage, $notificationtype);
-
- echo $OUTPUT->heading(get_string('registerwithmoodleorg', 'admin'));
- $renderer = $PAGE->get_renderer('core', 'register');
- echo $renderer->moodleorg_registration_message();
-}
-
-$siteregistrationform->display();
-echo $OUTPUT->footer();
+redirect(new moodle_url('/admin/registration/index.php'));
\ No newline at end of file
$moodleorgregmsg .= html_writer::alist($items);
return $moodleorgregmsg;
}
-
- /**
- * Display a box message confirming a site registration (add or update)
- * @param string $confirmationmessage
- * @return string
- */
- public function registration_confirmation($confirmationmessage) {
- $linktositelist = html_writer::tag('a', get_string('sitelist', 'hub'),
- array('href' => new moodle_url('/local/hub/index.php')));
- $message = $confirmationmessage . html_writer::empty_tag('br') . $linktositelist;
- return $this->output->box($message);
- }
-
- /**
- * Display the listing of registered on hub
- */
- public function registeredonhublisting($hubs) {
- global $CFG;
- $table = new html_table();
- $table->head = array(get_string('hub', 'hub'), get_string('operation', 'hub'));
- $table->size = array('80%', '20%');
-
- foreach ($hubs as $hub) {
- if ($hub->huburl == HUB_MOODLEORGHUBURL) {
- $hub->hubname = get_string('registeredmoodleorg', 'hub', $hub->hubname);
- }
- $hublink = html_writer::tag('a', $hub->hubname, array('href' => $hub->huburl));
- $hublinkcell = html_writer::tag('div', $hublink, array('class' => 'registeredhubrow'));
-
- $unregisterhuburl = new moodle_url("/" . $CFG->admin . "/registration/index.php",
- array('sesskey' => sesskey(), 'huburl' => $hub->huburl,
- 'unregistration' => 1));
- $unregisterbutton = new single_button($unregisterhuburl,
- get_string('unregister', 'hub'));
- $unregisterbutton->class = 'centeredbutton';
- $unregisterbuttonhtml = $this->output->render($unregisterbutton);
-
- //add button cells
- $cells = array($hublinkcell, $unregisterbuttonhtml);
- $row = new html_table_row($cells);
- $table->data[] = $row;
- }
-
- return html_writer::table($table);
- }
-
}
// //
///////////////////////////////////////////////////////////////////////////
-/*
+/**
* @package moodle
* @subpackage registration
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
require('../../config.php');
require_once($CFG->libdir . '/adminlib.php');
-require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
$url = optional_param('url', '', PARAM_URL);
-$hubname = optional_param('hubname', '', PARAM_TEXT);
$token = optional_param('token', '', PARAM_TEXT);
-admin_externalpage_setup('registrationhubs');
+admin_externalpage_setup('registrationmoodleorg');
-//check that we are waiting a confirmation from this hub, and check that the token is correct
-$registrationmanager = new registration_manager();
-$registeredhub = $registrationmanager->get_unconfirmedhub($url);
-if (!empty($registeredhub) and $registeredhub->token == $token) {
-
- echo $OUTPUT->header();
- echo $OUTPUT->heading(get_string('renewregistration', 'hub'), 3, 'main');
- $hublink = html_writer::tag('a', $hubname, array('href' => $url));
+if ($url !== HUB_MOODLEORGHUBURL) {
+ throw new moodle_exception('errorotherhubsnotsupported', 'hub');
+}
- $registrationmanager->delete_registeredhub($url);
+// Check that we are waiting a confirmation from this hub, and check that the token is correct.
+\core\hub\registration::reset_site_identifier($token);
- //Mooch case, need to recreate the siteidentifier
- if ($url == HUB_MOODLEORGHUBURL) {
- $CFG->siteidentifier = null;
- get_site_identifier();
- }
+echo $OUTPUT->header();
+echo $OUTPUT->heading(get_string('renewregistration', 'hub'), 3, 'main');
+$hublink = html_writer::tag('a', 'Moodle.net', array('href' => HUB_MOODLEORGHUBURL));
- $deletedregmsg = get_string('previousregistrationdeleted', 'hub', $hublink);
+$deletedregmsg = get_string('previousregistrationdeleted', 'hub', $hublink);
- $button = new single_button(new moodle_url('/admin/registration/index.php'),
- get_string('restartregistration', 'hub'));
- $button->class = 'restartregbutton';
+$button = new single_button(new moodle_url('/admin/registration/index.php'),
+ get_string('restartregistration', 'hub'));
+$button->class = 'restartregbutton';
- echo html_writer::tag('div', $deletedregmsg . $OUTPUT->render($button),
- array('class' => 'mdl-align'));
+echo html_writer::tag('div', $deletedregmsg . $OUTPUT->render($button),
+ array('class' => 'mdl-align'));
- echo $OUTPUT->footer();
-} else {
- throw new moodle_exception('wrongtoken', 'hub',
- $CFG->wwwroot . '/' . $CFG->admin . '/registration/index.php');
-}
+echo $OUTPUT->footer();
* @param array $eventshandlers Events 1 API handlers.
* @param bool $themedesignermode Warn about the theme designer mode.
* @param bool $devlibdir Warn about development libs directory presence.
+ * @param bool $mobileconfigured Whether the mobile web services have been enabled
*
* @return string HTML to output.
*/
public function admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed,
$cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch,
$buggyiconvnomb, $registered, array $cachewarnings = array(), $eventshandlers = 0,
- $themedesignermode = false, $devlibdir = false) {
+ $themedesignermode = false, $devlibdir = false, $mobileconfigured = false) {
global $CFG;
$output = '';
$output .= $this->cache_warnings($cachewarnings);
$output .= $this->events_handlers($eventshandlers);
$output .= $this->registration_warning($registered);
+ $output .= $this->mobile_configuration_warning($mobileconfigured);
//////////////////////////////////////////////////////////////////////////////////////////////////
//// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
if (!$registered) {
if (has_capability('moodle/site:config', context_system::instance())) {
- $registerbutton = $this->single_button(new moodle_url('/admin/registration/register.php',
- array('huburl' => HUB_MOODLEORGHUBURL, 'hubname' => 'Moodle.net')),
+ $registerbutton = $this->single_button(new moodle_url('/admin/registration/index.php'),
get_string('register', 'admin'));
$str = 'registrationwarning';
} else {
* @return string
*/
public function warn_if_not_registered() {
- global $CFG;
- require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
- $registrationmanager = new registration_manager();
- return $this->registration_warning($registrationmanager->get_registeredhub(HUB_MOODLEORGHUBURL) ? true : false);
+ return $this->registration_warning(\core\hub\registration::is_registered());
+ }
+
+ /**
+ * Display a warning about the Mobile Web Services being disabled.
+ *
+ * @param boolean $mobileconfigured true if mobile web services are enabled
+ * @return string HTML to output.
+ */
+ protected function mobile_configuration_warning($mobileconfigured) {
+ $output = '';
+ if (!$mobileconfigured) {
+ $settingslink = new moodle_url('/admin/settings.php', ['section' => 'mobilesettings']);
+ $configurebutton = $this->single_button($settingslink, get_string('enablemobilewebservice', 'admin'));
+ $output .= $this->warning(get_string('mobilenotconfiguredwarning', 'admin') . ' ' . $configurebutton);
+ }
+
+ return $output;
}
/**
require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php');
+redirect_if_major_upgrade_required();
+
$query = trim(optional_param('query', '', PARAM_NOTAGS)); // Search string
$context = context_system::instance();
$PAGE->set_context($context);
+$hassiteconfig = has_capability('moodle/site:config', $context);
+
+if ($hassiteconfig && moodle_needs_upgrading()) {
+ redirect(new moodle_url('/admin/index.php'));
+}
+
admin_externalpage_setup('search', '', array('query' => $query)); // now hidden page
$adminroot = admin_get_root(); // need all settings here
$showsettingslinks = true;
-if (has_capability('moodle/site:config', $context)) {
+if ($hassiteconfig) {
require_once("admin_settings_search_form.php");
$form = new admin_settings_search_form();
$form->display();
// Disable web interface evaluation and get predictions.
$settings->add(new admin_setting_configcheckbox('analytics/onlycli', new lang_string('onlycli', 'analytics'),
new lang_string('onlycliinfo', 'analytics'), 1));
+
+ // Training and prediction time limit per model.
+ $settings->add(new admin_setting_configduration('analytics/modeltimelimit', new lang_string('modeltimelimit', 'analytics'),
+ new lang_string('modeltimelimitinfo', 'analytics'), 20 * MINSECS));
+
}
}
$temp->add(new admin_setting_heading('searchengineheading', new lang_string('searchengine', 'admin'), ''));
$temp->add(new admin_setting_configselect('searchengine',
new lang_string('selectsearchengine', 'admin'), '', 'solr', $engines));
- $temp->add(new admin_setting_heading('searchindexingheading', new lang_string('searchoptions', 'admin'), ''));
+ $temp->add(new admin_setting_heading('searchoptionsheading', new lang_string('searchoptions', 'admin'), ''));
$temp->add(new admin_setting_configcheckbox('searchindexwhendisabled',
new lang_string('searchindexwhendisabled', 'admin'), new lang_string('searchindexwhendisabled_desc', 'admin'),
0));
$temp->add(new admin_setting_configduration('searchindextime',
new lang_string('searchindextime', 'admin'), new lang_string('searchindextime_desc', 'admin'),
600));
+ $options = [
+ 0 => new lang_string('searchallavailablecourses_off', 'admin'),
+ 1 => new lang_string('searchallavailablecourses_on', 'admin')
+ ];
+ $temp->add(new admin_setting_configselect('searchallavailablecourses',
+ new lang_string('searchallavailablecourses', 'admin'),
+ new lang_string('searchallavailablecourses_desc', 'admin'),
+ 0, $options));
$ADMIN->add('searchplugins', $temp);
$ADMIN->add('searchplugins', new admin_externalpage('searchareas', new lang_string('searchareas', 'admin'),
$ADMIN->add('server', $temp);
-$ADMIN->add('server', new admin_externalpage('adminregistration', new lang_string('hubs', 'admin'),
- "$CFG->wwwroot/$CFG->admin/registration/index.php"));
-
// E-mail settings.
$ADMIN->add('server', new admin_category('email', new lang_string('categoryemail', 'admin')));
$ADMIN->add('root', new admin_externalpage('adminnotifications', new lang_string('notifications'), "$CFG->wwwroot/$CFG->admin/index.php"));
$ADMIN->add('root', new admin_externalpage('registrationmoodleorg', new lang_string('registration', 'admin'),
- "$CFG->wwwroot/$CFG->admin/registration/register.php?huburl=" . HUB_MOODLEORGHUBURL . "&hubname=Moodle.net&sesskey=" . sesskey()));
-$ADMIN->add('root', new admin_externalpage('registrationhub', new lang_string('registerwith', 'hub'),
- "$CFG->wwwroot/$CFG->admin/registration/register.php", 'moodle/site:config', true));
-$ADMIN->add('root', new admin_externalpage('registrationhubs', new lang_string('hubs', 'admin'),
- "$CFG->wwwroot/$CFG->admin/registration/index.php", 'moodle/site:config', true));
-$ADMIN->add('root', new admin_externalpage('siteregistrationconfirmed',
- new lang_string('registrationconfirmed', 'hub'),
- $CFG->wwwroot."/".$CFG->admin."/registration/confirmregistration.php", 'moodle/site:config', true));
+ new moodle_url("/admin/registration/index.php")));
// hidden upgrade script
$ADMIN->add('root', new admin_externalpage('upgradesettings', new lang_string('upgradesettings', 'admin'), "$CFG->wwwroot/$CFG->admin/upgradesettings.php", 'moodle/site:config', true));
--- /dev/null
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * AMD module for model actions confirmation.
+ *
+ * @module tool_analytics/model
+ * @copyright 2017 David Monllao
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+define(['jquery', 'core/str', 'core/log', 'core/notification', 'core/modal_factory', 'core/modal_events'],
+ function($, Str, log, Notification, ModalFactory, ModalEvents) {
+
+ /**
+ * List of actions that require confirmation and confirmation message.
+ */
+ var actionsList = {
+ clear: {
+ title: {
+ key: 'clearpredictions',
+ component: 'tool_analytics'
+ }, body: {
+ key: 'clearmodelpredictions',
+ component: 'tool_analytics'
+ }
+
+ }
+ };
+
+ /**
+ * Returns the model name.
+ *
+ * @param {Object} actionItem The action item DOM node.
+ * @return {String}
+ */
+ var getModelName = function(actionItem) {
+ return $(actionItem.closest('tr')[0]).find('span.target-name').text();
+ };
+
+ /** @alias module:tool_analytics/model */
+ return {
+
+ /**
+ * Displays a confirm modal window before executing the action.
+ *
+ * @param {String} actionId
+ * @param {String} actionType
+ */
+ confirmAction: function(actionId, actionType) {
+ $('[data-action-id="' + actionId + '"]').on('click', function(ev) {
+ ev.preventDefault();
+
+ var a = $(ev.currentTarget);
+
+ if (typeof actionsList[actionType] === "undefined") {
+ log.error('Action "' + actionType + '" is not allowed.');
+ return;
+ }
+
+ var reqStrings = [
+ actionsList[actionType].title,
+ actionsList[actionType].body
+ ];
+ reqStrings[1].param = getModelName(a);
+
+ var stringsPromise = Str.get_strings(reqStrings);
+ var modalPromise = ModalFactory.create({type: ModalFactory.types.SAVE_CANCEL});
+
+ $.when(stringsPromise, modalPromise).then(function(strings, modal) {
+ modal.setTitle(strings[0]);
+ modal.setBody(strings[1]);
+ modal.setSaveButtonText(strings[0]);
+ modal.getRoot().on(ModalEvents.save, function() {
+ window.location.href = a.attr('href');
+ });
+ modal.show();
+ return modal;
+ }).fail(Notification.exception);
+ });
+ }
+ };
+});
$mform = $this->_form;
- if ($this->_customdata['model']->get_model_obj()->trained == 1) {
+ if ($this->_customdata['model']->is_trained()) {
$message = get_string('edittrainedwarning', 'tool_analytics');
$mform->addElement('html', $OUTPUT->notification($message, \core\output\notification::NOTIFY_WARNING));
}
* @return \stdClass
*/
public function export_for_template(\renderer_base $output) {
+ global $PAGE;
$data = new \stdClass();
}
}
+ // Has this model generated predictions?.
+ $predictioncontexts = $model->get_predictions_contexts();
+
// Model predictions list.
if (!$model->is_enabled()) {
$modeldata->noinsights = get_string('disabledmodel', 'analytics');
} else if ($model->uses_insights()) {
- $predictioncontexts = $model->get_predictions_contexts();
if ($predictioncontexts) {
foreach ($predictioncontexts as $contextid => $unused) {
$actionsmenu->set_owner_selector('model-actions-' . $model->get_id());
$actionsmenu->set_alignment(\action_menu::TL, \action_menu::BL);
+ $urlparams = ['id' => $model->get_id(), 'sesskey' => sesskey()];
+
+ // Get predictions.
+ if (!$onlycli && $modeldata->enabled && !empty($modeldata->timesplitting)) {
+ $urlparams['action'] = 'getpredictions';
+ $url = new \moodle_url('model.php', $urlparams);
+ $icon = new \action_menu_link_secondary($url, new \pix_icon('i/notificat