Commit a6855934 authored by Petr Skoda's avatar Petr Skoda
Browse files

MDL-21233 moodle_url improvemewnts, code simplification, more diagnostics;...

MDL-21233 moodle_url improvemewnts, code simplification, more diagnostics; fixed several regressions
parent 5192a212
......@@ -22,8 +22,8 @@ error('TODO: rewrite db perf code'); // TODO: rewrite
$site = get_site();
if (!empty($topframe)) {
$PAGE->set_url(new moodle_url($CFG->wwwroot.'/admin/dbperformance.php'));
$PAGE->navbar->add($stradministration, new moodle_url($CFG->wwwroot.'/admin/index.php'));
$PAGE->set_url('/admin/dbperformance.php');
$PAGE->navbar->add($stradministration, new moodle_url('/admin/index.php'));
$PAGE->navbar->add($strdatabaseperformance);
$PAGE->set_title("$site->shortname: $strdatabaseperformance");
$PAGE->set_heading($site->fullname);
......
......@@ -1333,7 +1333,7 @@ if (CLI_SCRIPT) {
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
require_capability('moodle/site:config', $systemcontext);
$PAGE->set_url($CFG->wwwroot.'/admin/generator.php');
$PAGE->set_url('/admin/generator.php');
$PAGE->set_pagelayout('base');
$generator = new generator_web();
$generator->setup();
......
......@@ -54,7 +54,7 @@ $agreelicense = optional_param('agreelicense', 0, PARAM_BOOL);
// Check some PHP server settings
$PAGE->set_url($CFG->admin . '/index.php');
$PAGE->set_url('/admin/index.php');
$documentationlink = '<a href="http://docs.moodle.org/en/Installation">Installation docs</a>';
......
......@@ -186,7 +186,7 @@ if (!$acl) {
if (!empty($table)) {
echo $OUTPUT->table($table);
echo '<p>&nbsp;</p>';
$baseurl = new moodle_url(null, array('sort' => $sort, 'dir' => $dir, 'perpage' => $perpage));
$baseurl = new moodle_url('/admin/mnet/access_control.php', array('sort' => $sort, 'dir' => $dir, 'perpage' => $perpage));
$pagingbar = moodle_paging_bar::make($aclcount, $page, $perpage, $baseurl);
echo $OUTPUT->paging_bar($pagingbar);
}
......
......@@ -38,9 +38,9 @@
if ($live_users > 0) {
$warn[] = get_string('usersareonline', 'mnet', $live_users);
}
$PAGE->set_url(new moodle_url($CFG->wwwroot.'/admin/mnet/delete.php'));
$PAGE->navbar->add($stradministration, new moodle_url($CFG->wwwroot.'/'.$CFG->admin.'/index.php'));
$PAGE->navbar->add(get_string('mnetsettings', 'mnet'), new moodle_url($CFG->wwwroot.'/'.$CFG->admin.'/mnet/index.php'));
$PAGE->set_url('/admin/mnet/delete.php');
$PAGE->navbar->add($stradministration, new moodle_url('/admin/index.php'));
$PAGE->navbar->add(get_string('mnetsettings', 'mnet'), new moodle_url('/admin/mnet/index.php'));
$PAGE->navbar->add(get_string('deletehost', 'mnet'));
$PAGE->set_title("$site->shortname: $strmnetsettings");
......
......@@ -3,7 +3,7 @@
admin_externalpage_print_header();
$currenttab = 'mnetdetails';
require_once($CFG->dirroot .'/admin/mnet/tabs.php');
require_once($CFG->dirroot .'/'.$CFG->admin.'/mnet/tabs.php');
echo $OUTPUT->box_start();
?>
......
<?php
admin_externalpage_print_header();
$currenttab = 'mnetdetails';
require_once($CFG->dirroot .'/admin/mnet/tabs.php');
require_once($CFG->dirroot .'/'.$CFG->admin.'/mnet/tabs.php');
echo $OUTPUT->box_start();
?>
......
......@@ -2,7 +2,7 @@
admin_externalpage_print_header();
$currenttab = 'mnetservices';
require_once($CFG->dirroot .'/admin/mnet/tabs.php');
require_once($CFG->dirroot .'/'.$CFG->admin.'/mnet/tabs.php');
echo $OUTPUT->box_start();
?>
......
......@@ -6,7 +6,7 @@ admin_externalpage_print_header();
echo $OUTPUT->heading(get_string('themes'));
$original_theme = fullclone($THEME);
$currenttab = 'mnetthemes';
require_once($CFG->dirroot .'/admin/mnet/tabs.php');
require_once($CFG->dirroot .'/'.$CFG->admin.'/mnet/tabs.php');
$themes = get_list_of_plugins("theme");
$sesskey = sesskey();
......
......@@ -30,7 +30,7 @@
$courses = $DB->get_records_sql($sql, $param->$params, 0, $numcourses);
if (empty($courses)) {
$PAGE->set_url(new moodle_url($CFG->wwwroot.'/'.$CFG->admin.'/report/courseoverview/index.php'));
$PAGE->set_url('/admin/report/courseoverview/index.php');
print_error('statsnodata', 'error', $PAGE->url->out());
}
......
......@@ -54,7 +54,7 @@
if ($returnurl) {
$urlparams['returnurl'] = $returnurl;
}
$PAGE->set_url($CFG->admin . '/roles/assign.php', $urlparams);
$PAGE->set_url('/admin/roles/assign.php', $urlparams);
$baseurl = $PAGE->url->out();
if (! $context = get_context_instance_by_id($contextid)) {
......@@ -266,7 +266,7 @@
$PAGE->set_title($title);
if ($courseid != SITEID) {
if (has_capability('moodle/course:viewparticipants', get_context_instance(CONTEXT_COURSE, $courseid))) {
$PAGE->navbar->add(get_string('participants'), new moodle_url($CFG->wwwroot.'/user/index.php', array('id'=>$courseid)));
$PAGE->navbar->add(get_string('participants'), new moodle_url('/user/index.php', array('id'=>$courseid)));
}
$PAGE->set_heading($fullname);
} else {
......
......@@ -48,7 +48,7 @@
if ($returnurl) {
$urlparams['returnurl'] = $returnurl;
}
$PAGE->set_url($CFG->admin . '/roles/check.php', $urlparams);
$PAGE->set_url('/admin/roles/check.php', $urlparams);
if (! $context = get_context_instance_by_id($contextid)) {
print_error('wrongcontextid', 'error');
......@@ -108,7 +108,7 @@
$PAGE->set_title($title);
if ($courseid != SITEID) {
if (has_capability('moodle/course:viewparticipants', get_context_instance(CONTEXT_COURSE, $courseid))) {
$PAGE->navbar->add(get_string('participants'), new moodle_url($CFG->wwwroot.'/user/index.php', array('id'=>$courseid)));
$PAGE->navbar->add(get_string('participants'), new moodle_url('/user/index.php', array('id'=>$courseid)));
}
$PAGE->set_heading($fullname);
} else {
......
......@@ -37,7 +37,7 @@ $userid = required_param('user', PARAM_INTEGER); // We use 0 here to mean not-lo
$contextid = required_param('contextid', PARAM_INTEGER);
$capability = required_param('capability', PARAM_CAPABILITY);
$PAGE->set_url(new moodle_url($CFG->wwwroot.'/admin/roles/explain.php', array('user'=>$userid, 'contextid'=>$contextid, 'capability'=>$capability)));
$PAGE->set_url('/admin/roles/explain.php', array('user'=>$userid, 'contextid'=>$contextid, 'capability'=>$capability));
// Get the context and its parents.
$context = get_context_instance_by_id($contextid);
......
......@@ -50,7 +50,7 @@
if ($returnurl) {
$urlparams['returnurl'] = $returnurl;
}
$PAGE->set_url($CFG->admin . '/roles/override.php', $urlparams);
$PAGE->set_url('/admin/roles/override.php', $urlparams);
$baseurl = $PAGE->url->out();
/// Validate the contextid parameter.
......@@ -151,7 +151,7 @@
$PAGE->set_title($title);
if ($courseid != SITEID) {
if (has_capability('moodle/course:viewparticipants', get_context_instance(CONTEXT_COURSE, $course->id))) {
$PAGE->navbar->add(get_string('participants'), new moodle_url($CFG->wwwroot.'/user/index.php', array('id'=>$course->id)));
$PAGE->navbar->add(get_string('participants'), new moodle_url('/user/index.php', array('id'=>$course->id)));
}
$PAGE->set_heading($fullname);
} else {
......
......@@ -52,7 +52,7 @@ if ($currenttab != 'update') {
if (empty($title)) {
$title = $SITE->fullname;
}
$PAGE->navbar->add($stradministration, new moodle_url($CFG->wwwroot.'/admin/'), navigation_node::TYPE_SETTING);
$PAGE->navbar->add($stradministration, new moodle_url('/admin/'), navigation_node::TYPE_SETTING);
$PAGE->navbar->add($straction);
$PAGE->set_title($title);
$PAGE->set_heading($SITE->fullname);
......@@ -73,8 +73,8 @@ if ($currenttab != 'update') {
$title = "$SITE->shortname: $category->name";
}
$PAGE->navbar->add($strcategories, new moodle_url($CFG->wwwroot.'/course/index.php'), navigation_node::TYPE_SETTING);
$PAGE->navbar->add($category->name, new moodle_url($CFG->wwwroot.'/course/category.php', array('id'=>$category->id)), navigation_node::TYPE_SETTING);
$PAGE->navbar->add($strcategories, new moodle_url('/course/index.php'), navigation_node::TYPE_SETTING);
$PAGE->navbar->add($category->name, new moodle_url('/course/category.php', array('id'=>$category->id)), navigation_node::TYPE_SETTING);
$PAGE->navbar->add(get_string("roles"));
$PAGE->set_title($title);
$PAGE->set_heading("$SITE->fullname: $strcourses");
......
......@@ -126,7 +126,7 @@ $PAGE->set_title($title);
if ($courseid != SITEID) {
$PAGE->set_heading($fullname);
if (has_capability('moodle/course:viewparticipants', $coursecontext)) {
$PAGE->navbar->add(get_string('participants'),new moodle_url($CFG->wwwroot.'/user/index.php', array('id'=>$courseid)));
$PAGE->navbar->add(get_string('participants'),new moodle_url('/user/index.php', array('id'=>$courseid)));
}
} else {
$PAGE->set_heading($course->fullname);
......
......@@ -10,7 +10,7 @@ $adminediting = optional_param('adminedit', -1, PARAM_BOOL);
/// no guest autologin
require_login(0, false);
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
$PAGE->set_url($CFG->admin . '/settings.php', array('section' => $section));
$PAGE->set_url('/admin/settings.php', array('section' => $section));
$PAGE->set_pagetype('admin-setting-' . $section);
$PAGE->set_pagelayout('admin');
$PAGE->navigation->clear_cache();
......
......@@ -18,7 +18,7 @@
$strusers = get_string("users");
$strall = get_string("all");
$PAGE->set_url(new moodle_url($CFG->wwwroot.'/admin/timezone.php'));
$PAGE->set_url('/admin/timezone.php');
$PAGE->set_title($strtimezone);
$PAGE->set_heading($strtimezone);
$PAGE->navbar->add($strtimezone);
......
......@@ -27,7 +27,7 @@ require_once('../../config.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php');
$PAGE->set_url('/admin/webservice/protocols.php', array());
$PAGE->set_url('/admin/webservice/protocols.php');
//TODO: disable the blocks here or better make the page layout default to no blocks!
require_login();
......
......@@ -31,7 +31,7 @@ $id = required_param('id', PARAM_INT);
$action = optional_param('action', '', PARAM_ACTION);
$confirm = optional_param('confirm', 0, PARAM_BOOL);
$PAGE->set_url('admin/external_service.php', array('id'=>$id));
$PAGE->set_url('/admin/external_service.php', array('id'=>$id));
admin_externalpage_setup('externalservice');
......@@ -57,7 +57,7 @@ if ($action == 'delete' and confirm_sesskey() and $service and empty($service->c
$DB->delete_records('external_services_users', array('externalserviceid'=>$service->id));
$DB->delete_records('external_services_functions', array('externalserviceid'=>$service->id));
$DB->delete_records('external_services', array('id'=>$service->id));
add_to_log(1, 'webservice', 'delete', $CFG->wwwroot."/admin/settings.php?section=externalservices", get_string('deleteservice', 'webservice', $service));
add_to_log(1, 'webservice', 'delete', $CFG->wwwroot."/$CFG->admin/settings.php?section=externalservices", get_string('deleteservice', 'webservice', $service));
redirect($returnurl);
}
......@@ -76,11 +76,11 @@ if ($mform->is_cancelled()) {
if (empty($data->id)) {
$data->timecreated = mktime();
$data->id = $DB->insert_record('external_services', $data);
add_to_log(1, 'webservice', 'add', $CFG->wwwroot."/admin/settings.php?section=externalservices", get_string('addservice', 'webservice', $data));
add_to_log(1, 'webservice', 'add', $CFG->wwwroot."/$CFG->admin/settings.php?section=externalservices", get_string('addservice', 'webservice', $data));
} else {
$data->timemodified = mktime();
$DB->update_record('external_services', $data);
add_to_log(1, 'webservice', 'edit', $CFG->wwwroot."/admin/settings.php?section=externalservices", get_string('editservice', 'webservice', $data));
add_to_log(1, 'webservice', 'edit', $CFG->wwwroot."/$CFG->admin/settings.php?section=externalservices", get_string('editservice', 'webservice', $data));
}
redirect($returnurl);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment