registration MDL-22964 check if xmlrpc is enabled on the registration pages, publication pages and community block page.

This commit is contained in:
jerome mouneyrac 2010-07-02 03:40:12 +00:00
parent 195827d35b
commit 5cbbcc1ae6
6 changed files with 76 additions and 32 deletions

View File

@ -1,4 +1,5 @@
<?php
///////////////////////////////////////////////////////////////////////////
// //
// This file is part of Moodle - http://moodle.org/ //
@ -31,24 +32,24 @@
* should be using the same browser during all the registration process.
* This page save the token that the hub gave us, in order to call the hub
* directory later by web service.
*/
*/
require('../../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->dirroot.'/admin/registration/lib.php');
require_once($CFG->libdir . '/adminlib.php');
require_once($CFG->dirroot . '/admin/registration/lib.php');
$newtoken = optional_param('newtoken', '', PARAM_ALPHANUM);
$url = optional_param('url', '', PARAM_URL);
$hubname = optional_param('hubname', '', PARAM_TEXT);
$token = optional_param('token', '', PARAM_ALPHANUM);
$error = optional_param('error', '', PARAM_ALPHANUM);
$newtoken = optional_param('newtoken', '', PARAM_ALPHANUM);
$url = optional_param('url', '', PARAM_URL);
$hubname = optional_param('hubname', '', PARAM_TEXT);
$token = optional_param('token', '', PARAM_ALPHANUM);
$error = optional_param('error', '', PARAM_ALPHANUM);
admin_externalpage_setup('siteregistrationconfirmed');
//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) {
if (!empty($registeredhub) and $registeredhub->token == $token) {
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('registrationconfirmed', 'hub'), 3, 'main');
@ -61,15 +62,22 @@ if (!empty($registeredhub) and $registeredhub->token == $token) {
$registeredhub->confirmed = 1;
$registeredhub->huname = $hubname;
$registrationmanager->update_registeredhub($registeredhub);
$notificationmessage = $OUTPUT->notification(get_string('registrationconfirmedon', 'hub', $hublink), 'notifysuccess');
}
echo $notificationmessage;
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.'/admin/registration/index.php');
throw new moodle_exception('wrongtoken', 'hub', $CFG->wwwroot . '/admin/registration/index.php');
}

View File

@ -146,10 +146,18 @@ if (empty($cancel) and $unregistration and !$confirm) {
} else {
echo $OUTPUT->heading(get_string('registeron', 'hub'), 3, 'main');
echo $renderer->registrationselector();
$hubs = $registrationmanager->get_registered_on_hubs();
if (!empty($hubs)) {
echo $OUTPUT->heading(get_string('registeredon', 'hub'), 3, 'main');
echo $renderer->registeredonhublisting($hubs);
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);
}
}
echo $OUTPUT->footer();

View File

@ -47,9 +47,15 @@ $search = optional_param('search', null, PARAM_TEXT);
$usercansearch = has_capability('moodle/community:add', get_context_instance(CONTEXT_USER, $USER->id));
$usercandownload = has_capability('moodle/community:download', get_context_instance(CONTEXT_USER, $USER->id));
if (empty($usercansearch)) {
$notificationerror = get_string('cannotsearchcommunity', 'hub');
} else if (!extension_loaded('xmlrpc')) {
$notificationerror = $OUTPUT->doc_link('admin/environment/php_extension/xmlrpc', '');
$notificationerror .= get_string('xmlrpcdisabledcommunity', 'hub');
}
if (!empty($notificationerror) ) {
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('searchcommunitycourse', 'block_community'), 3, 'main');
echo $OUTPUT->notification(get_string('cannotsearchcommunity', 'hub'));
echo $OUTPUT->notification($notificationerror);
echo $OUTPUT->footer();
die();
}

View File

@ -38,6 +38,22 @@ $course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
require_login($course);
$PAGE->set_url('/course/publish/index.php', array('id' => $course->id));
$PAGE->set_pagelayout('course');
$PAGE->set_title(get_string('course') . ': ' . $course->fullname);
$PAGE->set_heading($course->fullname);
//check that the PHP xmlrpc extension is enabled
if (!extension_loaded('xmlrpc')) {
$notificationerror = $OUTPUT->doc_link('admin/environment/php_extension/xmlrpc', '');
$notificationerror .= get_string('xmlrpcdisabledpublish', 'hub');
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('publishcourse', 'hub', $course->shortname), 3, 'main');
echo $OUTPUT->notification($notificationerror);
echo $OUTPUT->footer();
die();
}
if (has_capability('moodle/course:publish', get_context_instance(CONTEXT_COURSE, $id))) {
$publicationmanager = new course_publish_manager();
@ -78,12 +94,6 @@ if (has_capability('moodle/course:publish', get_context_instance(CONTEXT_COURSE,
}
}
$PAGE->set_url('/course/publish/index.php', array('id' => $course->id));
$PAGE->set_pagelayout('course');
$PAGE->set_title(get_string('course') . ': ' . $course->fullname);
$PAGE->set_heading($course->fullname);
//if the site os registered on no hub display an error page
$registrationmanager = new registration_manager();
$registeredhubs = $registrationmanager->get_registered_on_hubs();
@ -96,8 +106,7 @@ if (has_capability('moodle/course:publish', get_context_instance(CONTEXT_COURSE,
}
$renderer = $PAGE->get_renderer('core', 'publish');
/// UNPUBLISH
$cancel = optional_param('cancel', 0, PARAM_BOOL);
if (!empty($cancel) and confirm_sesskey()) {

View File

@ -47,13 +47,24 @@ if (empty($id)) {
$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
require_login($course);
if (has_capability('moodle/course:publish', get_context_instance(CONTEXT_COURSE, $id))) {
//page settings
$PAGE->set_url('/course/publish/metadata.php', array('id' => $course->id));
$PAGE->set_pagelayout('course');
$PAGE->set_title(get_string('course') . ': ' . $course->fullname);
$PAGE->set_heading($course->fullname);
//page settings
$PAGE->set_url('/course/publish/metadata.php', array('id' => $course->id));
$PAGE->set_pagelayout('course');
$PAGE->set_title(get_string('course') . ': ' . $course->fullname);
$PAGE->set_heading($course->fullname);
//check that the PHP xmlrpc extension is enabled
if (!extension_loaded('xmlrpc')) {
$errornotification = $OUTPUT->doc_link('admin/environment/php_extension/xmlrpc', '');
$errornotification .= get_string('xmlrpcdisabledpublish', 'hub');
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('publishcourse', 'hub', $course->shortname), 3, 'main');
echo $OUTPUT->notification($errornotification);
echo $OUTPUT->footer();
die();
}
if (has_capability('moodle/course:publish', get_context_instance(CONTEXT_COURSE, $id))) {
//retrieve hub name and hub url
$huburl = optional_param('huburl', '', PARAM_URL);

View File

@ -260,4 +260,6 @@ $string['usersnumber'] = 'Number of users ({$a})';
$string['warning'] = 'WARNING';
$string['wrongtoken'] = 'The registration failed for some unknown reason (network?). Please try again.';
$string['wrongurlformat'] = 'Bad URL format';
$string['xmlrpcdisabledcommunity'] = 'The XML-RPC extension is not enabled on the server. You can not search and download courses.';
$string['xmlrpcdisabledpublish'] = 'The XML-RPC extension is not enabled on the server. You can not publish courses or manage published courses.';
$string['xmlrpcdisabledregistration'] = 'The XML-RPC extension is not enabled on the server. You will not be able to unregister or update your registration until you enable it.';