Skip to content

Commit

Permalink
Merge branch 'MD-31803' of git://github.com/mouneyrac/moodle
Browse files Browse the repository at this point in the history
Conflicts:
	admin/index.php
	admin/renderer.php
	version.php
  • Loading branch information
danpoltawski committed Jun 4, 2012
1 parent a301675 commit b3245b7
Show file tree
Hide file tree
Showing 14 changed files with 154 additions and 171 deletions.
5 changes: 4 additions & 1 deletion admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@
$availableupdatesfetch = $updateschecker->get_last_timefetched();

$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));

admin_externalpage_setup('adminnotifications');

Expand All @@ -441,4 +443,5 @@

$output = $PAGE->get_renderer('core', 'admin');
echo $output->admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed,
$cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch, $buggyiconvnomb);
$cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch, $buggyiconvnomb,
$registered);
2 changes: 1 addition & 1 deletion admin/registration/confirmregistration.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
$token = optional_param('token', '', PARAM_TEXT);
$error = optional_param('error', '', PARAM_ALPHANUM);

admin_externalpage_setup('registrationindex');
admin_externalpage_setup('registrationhubs');

if (!empty($error) and $error == 'urlalreadyexist') {
throw new moodle_exception('urlalreadyregistered', 'hub',
Expand Down
28 changes: 15 additions & 13 deletions admin/registration/forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ public function definition() {
$geolocation = get_config('hub', 'site_geolocation_' . $cleanhuburl);
$contactable = get_config('hub', 'site_contactable_' . $cleanhuburl);
$emailalert = get_config('hub', 'site_emailalert_' . $cleanhuburl);
$emailalert = ($emailalert === 0) ? 0 : 1;
$coursesnumber = get_config('hub', 'site_coursesnumber_' . $cleanhuburl);
$usersnumber = get_config('hub', 'site_usersnumber_' . $cleanhuburl);
$roleassignmentsnumber = get_config('hub', 'site_roleassignmentsnumber_' . $cleanhuburl);
Expand Down Expand Up @@ -279,9 +280,6 @@ public function definition() {
$mform->setType('description', PARAM_TEXT);
$mform->addHelpButton('description', 'sitedesc', 'hub');

$mform->addElement('static', 'urlstring', get_string('siteurl', 'hub'), $CFG->wwwroot);
$mform->addHelpButton('urlstring', 'siteurl', 'hub');

$languages = get_string_manager()->get_list_of_languages();
collatorlib::asort($languages);
$mform->addElement('select', 'language', get_string('sitelang', 'hub'),
Expand All @@ -290,16 +288,6 @@ public function definition() {
$mform->addHelpButton('language', 'sitelang', 'hub');
$mform->setDefault('language', $language);

$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');

$mform->addElement('textarea', 'address', get_string('postaladdress', 'hub'),
array('rows' => 4, 'cols' => 41));
$mform->setType('address', PARAM_TEXT);
Expand Down Expand Up @@ -360,6 +348,20 @@ public function definition() {
//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));
Expand Down
68 changes: 0 additions & 68 deletions admin/registration/hubselector.php

This file was deleted.

67 changes: 56 additions & 11 deletions admin/registration/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
*
* On this page the administrator select if he wants to register on Moodle.org or
* a specific hub
* On this page the administrator selects which hub he wants to register,
* except for MOOCH. Admins can register with MOOCH with the top admin menu "Registration" link.
* On this page the administrator can also unregister from any hubs, including MOOCH.
*/

require('../../config.php');
Expand All @@ -34,7 +35,7 @@
require_once($CFG->dirroot . '/course/publish/lib.php');
require_once($CFG->dirroot . "/webservice/xmlrpc/lib.php");

admin_externalpage_setup('registrationindex');
admin_externalpage_setup('registrationhubs');

$renderer = $PAGE->get_renderer('core', 'register');

Expand Down Expand Up @@ -126,13 +127,15 @@
}
}

echo $OUTPUT->header();

//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));
}
if (empty($cancel) and $unregistration and !$confirm) {

echo $OUTPUT->header();

//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));
}

$hub = $registrationmanager->get_registeredhub($huburl);
echo $OUTPUT->heading(get_string('unregisterfrom', 'hub', $hub->hubname), 3, 'main');
if ($cleanregdata) {
Expand All @@ -142,6 +145,7 @@
$siteunregistrationform = new site_unregistration_form('',
array('huburl' => $huburl, 'hubname' => $hub->hubname));
}

$siteunregistrationform->display();
} else {
$registeredonmoodleorg = false;
Expand All @@ -150,8 +154,49 @@
$registeredonmoodleorg = true;
}

echo $OUTPUT->heading(get_string('registeron', 'hub'), 3, 'main');
echo $renderer->registrationselector($registeredonmoodleorg);
// 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);

if (!empty($unlistedhuburl)) {
if (clean_param($unlistedhuburl, PARAM_URL) !== '') {
$huburl = $unlistedhuburl;
}
} else if (!empty($selectedhuburl)) {
$huburl = $selectedhuburl;
}

// a hub has been selected, redirect to the hub registration page
if (empty($cancel) and !empty($huburl) and confirm_sesskey()) {
$hubname = optional_param(clean_param($huburl, PARAM_ALPHANUMEXT), '', PARAM_TEXT);
$params = array('sesskey' => sesskey(), 'huburl' => $huburl,
'password' => $password, 'hubname' => $hubname);
redirect(new moodle_url($CFG->wwwroot . "/" . $CFG->admin . "/registration/register.php",
$params));
}

echo $OUTPUT->header();

//check if the site is registered on Moodle.org and display a message about registering on MOOCH
$registered = $DB->count_records('registration_hubs', array('huburl' => HUB_MOODLEORGHUBURL, 'confirmed' => 1));
if (empty($registered)) {
$warningmsg = get_string('registermoochtips', 'hub');
$warningmsg .= $renderer->single_button(new moodle_url('register.php', array('huburl' => HUB_MOODLEORGHUBURL
, 'hubname' => 'Moodle.org')), get_string('register', 'admin'));
echo $renderer->box($warningmsg, 'buttons mdl-align generalbox adminwarning');
}

//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));
}

echo $OUTPUT->heading(get_string('registerwith', 'hub'));

$hubselectorform->display();

if (extension_loaded('xmlrpc')) {
$hubs = $registrationmanager->get_registered_on_hubs();
Expand Down
21 changes: 15 additions & 6 deletions admin/registration/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
*
* This page displays the site registration form.
* This page displays the site registration form for Moodle.org/MOOCH or for a different hub.
* It handles redirection to the hub to continue the registration workflow process.
* It also handles update operation by web service.
*/
Expand All @@ -39,15 +39,17 @@
require_once($CFG->dirroot . '/webservice/lib.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');

admin_externalpage_setup('registrationindex');

$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);
if (!confirm_sesskey()) {
throw new moodle_exception('missingparameter');
}

$registrationmanager = new registration_manager();

Expand Down Expand Up @@ -145,5 +147,12 @@
echo $error;
}

//some Moodle.org resitration explanation
if ($huburl == HUB_MOODLEORGHUBURL) {
echo $OUTPUT->heading(get_string('registerwithmoodleorg', 'admin'));
$renderer = $PAGE->get_renderer('core', 'register');
echo $renderer->moodleorg_registration_message();
}

$siteregistrationform->display();
echo $OUTPUT->footer();
68 changes: 17 additions & 51 deletions admin/registration/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,23 @@
*/
class core_register_renderer extends plugin_renderer_base {

/**
* Display Moodle.org registration message about benefit to register on Moodle.org
*
* @return string
*/
public function moodleorg_registration_message() {
$moodleorgurl = html_writer::link('http://moodle.org', 'Moodle.org');
$moodleorgstatsurl = html_writer::link('http://moodle.org/stats', get_string('statsmoodleorg', 'admin'));
$moochurl = html_writer::link(HUB_MOODLEORGHUBURL, 'MOOCH');
$moodleorgregmsg = get_string('registermoodleorg', 'admin', $moodleorgurl);
$items = array(get_string('registermoodleorgli1', 'admin'),
get_string('registermoodleorgli2', 'admin', $moodleorgstatsurl),
get_string('registermoodleorgli3', 'admin', $moochurl));
$moodleorgregmsg .= html_writer::alist($items);
return $moodleorgregmsg;
}

/**
* Display a box message confirming a site registration (add or update)
* @param string $confirmationmessage
Expand All @@ -42,57 +59,6 @@ public function registration_confirmation($confirmationmessage) {
return $this->output->box($message);
}

/**
* Display the page to register on Moodle.org or on a specific hub
*/
public function registrationselector($updatemoodleorg = false) {
global $CFG;
$table = new html_table();
$table->head = array(get_string('moodleorg', 'hub'), get_string('specifichub', 'hub'));
$table->size = array('50%', '50%');
//$table->attributes['class'] = 'registerindextable';
//Moodle.org information cell
$moodleorgcell = get_string('moodleorgregistrationdetail', 'hub');
$moodleorgcell .= html_writer::empty_tag('br') . html_writer::empty_tag('br');
$moodleorgcell = html_writer::tag('div', $moodleorgcell, array('class' => 'justifytext'));

//Specific hub information cell
$specifichubcell = get_string('specifichubregistrationdetail', 'hub');
$specifichubcell .= html_writer::empty_tag('br') . html_writer::empty_tag('br');
$specifichubcell = html_writer::tag('div', $specifichubcell, array('class' => 'justifytext'));

//add information cells
$cells = array($moodleorgcell, $specifichubcell);
$row = new html_table_row($cells);
$table->data[] = $row;

//Moodle.org button cell
$registeronmoodleorgurl = new moodle_url("/" . $CFG->admin . "/registration/register.php",
array('sesskey' => sesskey(), 'huburl' => HUB_MOODLEORGHUBURL
, 'hubname' => 'Moodle.org'));
$registeronmoodleorgbutton = new single_button($registeronmoodleorgurl,
$updatemoodleorg ? get_string('updatesite', 'hub', 'Moodle.org') : get_string('registeronmoodleorg', 'hub'));
$registeronmoodleorgbutton->class = 'centeredbutton';
$registeronmoodleorgbuttonhtml = $this->output->render($registeronmoodleorgbutton);
$moodleorgcell = $registeronmoodleorgbuttonhtml;

//Specific hub button cell
$registeronspecifichuburl = new moodle_url("/" . $CFG->admin . "/registration/hubselector.php",
array('sesskey' => sesskey()));
$registeronspecifichubbutton = new single_button($registeronspecifichuburl,
get_string('registeronspecifichub', 'hub'));
$registeronspecifichubbutton->class = 'centeredbutton';
$registeronspecifichubbuttonhtml = $this->output->render($registeronspecifichubbutton);
$specifichubcell = $registeronspecifichubbuttonhtml;

//add button cells
$cells = array($moodleorgcell, $specifichubcell);
$row = new html_table_row($cells);
$table->data[] = $row;

return html_writer::table($table);
}

/**
* Display the listing of registered on hub
*/
Expand Down
2 changes: 1 addition & 1 deletion admin/registration/renewregistration.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
$hubname = optional_param('hubname', '', PARAM_TEXT);
$token = optional_param('token', '', PARAM_TEXT);

admin_externalpage_setup('registrationindex');
admin_externalpage_setup('registrationhubs');

//check that we are waiting a confirmation from this hub, and check that the token is correct
$registrationmanager = new registration_manager();
Expand Down
Loading

0 comments on commit b3245b7

Please sign in to comment.