Skip to content

Commit

Permalink
MDL-21233 moodle_url improvemewnts, code simplification, more diagnos…
Browse files Browse the repository at this point in the history
…tics; fixed several regressions
  • Loading branch information
skodak committed Jan 16, 2010
1 parent 5192a21 commit a685593
Show file tree
Hide file tree
Showing 424 changed files with 950 additions and 901 deletions.
4 changes: 2 additions & 2 deletions admin/dbperformance.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
$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);
Expand Down
2 changes: 1 addition & 1 deletion admin/generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,7 @@ function definition_after_data() {
$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();
Expand Down
2 changes: 1 addition & 1 deletion admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

// 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>';

Expand Down
2 changes: 1 addition & 1 deletion admin/mnet/access_control.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
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);
}
Expand Down
6 changes: 3 additions & 3 deletions admin/mnet/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion admin/mnet/mnet_review.html
Original file line number Diff line number Diff line change
Expand Up @@ -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();
?>
Expand Down
2 changes: 1 addition & 1 deletion admin/mnet/mnet_review_allhosts.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?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();
?>
Expand Down
2 changes: 1 addition & 1 deletion admin/mnet/mnet_services.html
Original file line number Diff line number Diff line change
Expand Up @@ -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();

?>
Expand Down
2 changes: 1 addition & 1 deletion admin/mnet/mnet_themes.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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();
Expand Down
2 changes: 1 addition & 1 deletion admin/report/courseoverview/reportsgraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
4 changes: 2 additions & 2 deletions admin/roles/assign.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions admin/roles/check.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion admin/roles/explain.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
$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);
Expand Down
4 changes: 2 additions & 2 deletions admin/roles/override.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions admin/roles/tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
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);
Expand All @@ -73,8 +73,8 @@
$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");
Expand Down
2 changes: 1 addition & 1 deletion admin/roles/usersroles.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
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);
Expand Down
2 changes: 1 addition & 1 deletion admin/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/// 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();
Expand Down
2 changes: 1 addition & 1 deletion admin/timezone.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion admin/webservice/protocols.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
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();
Expand Down
8 changes: 4 additions & 4 deletions admin/webservice/service.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
$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');

Expand All @@ -57,7 +57,7 @@
$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);
}

Expand All @@ -76,11 +76,11 @@
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);
Expand Down
2 changes: 1 addition & 1 deletion admin/webservice/service_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
$action = optional_param('action', '', PARAM_ACTION);
$confirm = optional_param('confirm', 0, PARAM_BOOL);

$PAGE->set_url('admin/websevice/service_functions.php', array('id'=>$id));
$PAGE->set_url('/admin/websevice/service_functions.php', array('id'=>$id));

admin_externalpage_setup('externalservicefunctions');

Expand Down
2 changes: 1 addition & 1 deletion admin/webservice/service_users.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

$id = required_param('id', PARAM_INT);

$PAGE->set_url('admin/webservice/service_users.php', array('id'=>$id));
$PAGE->set_url('/admin/webservice/service_users.php', array('id'=>$id));
$PAGE->requires->js($CFG->admin.'/webservice/script.js');

admin_externalpage_setup('externalserviceusers');
Expand Down
2 changes: 1 addition & 1 deletion admin/webservice/tokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
require_once($CFG->libdir.'/adminlib.php');
require_once('forms.php');

$PAGE->set_url('/admin/webservice/tokens.php', array());
$PAGE->set_url('/admin/webservice/tokens.php');

admin_externalpage_setup('addwebservicetoken');

Expand Down
2 changes: 1 addition & 1 deletion auth/ldap/ntlmsso_attempt.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//HTTPS is potentially required in this page
httpsrequired();

$PAGE->set_url(new moodle_url($CFG->wwwroot.'/auth/ldap/ntlmsso_attempt.php'));
$PAGE->set_url('/auth/ldap/ntlmsso_attempt.php');

/// Define variables used in page
$site = get_site();
Expand Down
2 changes: 1 addition & 1 deletion auth/ldap/ntlmsso_finish.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//HTTPS is potentially required in this page
httpsrequired();

$PAGE->set_url(new moodle_url($CFG->wwwroot.'/auth/ldap/ntlmsso_finish.php'));
$PAGE->set_url('/auth/ldap/ntlmsso_finish.php');

/// Define variables used in page
$site = get_site();
Expand Down
2 changes: 1 addition & 1 deletion auth/mnet/jump.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
$hostwwwroot = optional_param('hostwwwroot', '', PARAM_URL);
$wantsurl = optional_param('wantsurl', '', PARAM_RAW);

$url = new moodle_url($CFG->wwwroot.'/auth/mnet/jump.php');
$url = new moodle_url('/auth/mnet/jump.php');
if ($hostid !== '0') $url->param('hostid', $hostid);
if ($hostwwwroot !== '') $url->param('hostwwwroot', $hostwwwroot);
if ($wantsurl !== '') $url->param('wantsurl', $wantsurl);
Expand Down
2 changes: 1 addition & 1 deletion auth/mnet/land.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
$wantsurl = required_param('wantsurl', PARAM_LOCALURL);
$wantsremoteurl = optional_param('remoteurl', false, PARAM_BOOL);

$url = new moodle_url($CFG->wwwroot.'/auth/mnet/jump.php', array('token'=>$token, 'idp'=>$remotewwwroot, 'wantsurl'=>$wantsurl));
$url = new moodle_url('/auth/mnet/jump.php', array('token'=>$token, 'idp'=>$remotewwwroot, 'wantsurl'=>$wantsurl));
if ($wantsremoteurl !== false) $url->param('remoteurl', $wantsremoteurl);
$PAGE->set_url($url);

Expand Down
2 changes: 1 addition & 1 deletion auth/shibboleth/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

require('../../config.php');

$PAGE->set_url(new moodle_url($CFG->wwwroot.'/auth/shibboleth/index.php'));
$PAGE->set_url('/auth/shibboleth/index.php');

if (isloggedin() && $USER->username != 'guest') { // Nothing to do
if (isset($SESSION->wantsurl) and (strpos($SESSION->wantsurl, $CFG->wwwroot) === 0)) {
Expand Down
2 changes: 1 addition & 1 deletion auth/shibboleth/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

$loginsite = get_string("loginsite");

$PAGE->set_url(new moodle_url($CFG->wwwroot.'/auth/shibboleth/login.php'));
$PAGE->set_url('/auth/shibboleth/login.php');
$PAGE->navbar->add($loginsite);
$PAGE->set_title("$site->fullname: $loginsite");
$PAGE->set_heading($site->fullname);
Expand Down
10 changes: 5 additions & 5 deletions backup/backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
$cancel = optional_param('cancel', '', PARAM_RAW);
$launch = optional_param('launch', '', PARAM_ACTION);

$url = new moodle_url();
$url = new moodle_url('/backup/backup.php');
if ($id !== 0) {
$url->param('id', $id);
}
Expand Down Expand Up @@ -75,7 +75,7 @@
$PAGE->set_title("$site->shortname: $strcoursebackup");
$PAGE->set_heading($site->fullname);
if (!$id) {
$PAGE->navbar->add($stradministration, new moodle_url($CFG->wwwroot.'/'.$CFG->admin.'/index.php'));
$PAGE->navbar->add($stradministration, new moodle_url('/admin/index.php'));
$PAGE->navbar->add($strcoursebackup);
echo $OUTPUT->header();
if ($courses = get_courses('all','c.shortname','c.id,c.shortname,c.fullname')) {
Expand All @@ -100,12 +100,12 @@

//Print header
if (has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM))) {
$PAGE->navbar->add($stradministration, new moodle_url($CFG->wwwroot.'/'.$CFG->admin.'/index.php'));
$PAGE->navbar->add($strcoursebackup, new moodle_url($CFG->wwwroot.'/backup/backup.php'));
$PAGE->navbar->add($stradministration, new moodle_url('/admin/index.php'));
$PAGE->navbar->add($strcoursebackup, new moodle_url('/backup/backup.php'));
$PAGE->navbar->add("$course->fullname ($course->shortname)");
echo $OUTPUT->header();
} else {
$PAGE->navbar->add($course->fullname, new moodle_url($CFG->wwwroot.'/course/view.php', array('id'=>$course->id)));
$PAGE->navbar->add($course->fullname, new moodle_url('/course/view.php', array('id'=>$course->id)));
$PAGE->navbar->add($strcoursebackup);
echo $OUTPUT->header();
}
Expand Down
8 changes: 4 additions & 4 deletions backup/restore.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
$method = optional_param('method', '', PARAM_ACTION);
$backup_unique_code = optional_param('backup_unique_code',0,PARAM_INT);

$url = new moodle_url($CFG->wwwroot.'/backup/restore.php');
$url = new moodle_url('/backup/restore.php');
if ($id !== 0) {
$url->param('id', $id);
}
Expand Down Expand Up @@ -109,7 +109,7 @@
$PAGE->set_title("$site->shortname: $strcourserestore");
$PAGE->set_heading($site->fullname);
if (!$file) {
$PAGE->navbar->add($stradministration, new moodle_url($CFG->wwwroot.'/'.$CFG->admin.'/index.php'));
$PAGE->navbar->add($stradministration, new moodle_url('/admin/index.php'));
$PAGE->navbar->add($strcourserestore);
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string("nofilesselected"));
Expand All @@ -120,7 +120,7 @@

//If cancel has been selected, inform and end
if ($cancel) {
$PAGE->navbar->add($stradministration, new moodle_url($CFG->wwwroot.'/'.$CFG->admin.'/index.php'));
$PAGE->navbar->add($stradministration, new moodle_url('/admin/index.php'));
$PAGE->navbar->add($strcourserestore);
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string("restorecancelled"));
Expand All @@ -141,7 +141,7 @@
$PAGE->navbar->add(basename($file));
echo $OUTPUT->header();
} else {
$PAGE->navbar->add($course->shortname, new moodle_url($CFG->wwwroot.'/course/view.php', array('id'=>$course->id)));
$PAGE->navbar->add($course->shortname, new moodle_url('/course/view.php', array('id'=>$course->id)));
$PAGE->navbar->add($strcourserestore);
echo $OUTPUT->header();
}
Expand Down
Loading

0 comments on commit a685593

Please sign in to comment.