Skip to content

Commit

Permalink
MDL-42834 admin: Remove wwwroot if used with moodle_url
Browse files Browse the repository at this point in the history
  • Loading branch information
xow authored and mdjnelson committed Oct 23, 2017
1 parent 672f483 commit 7eb50b3
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 41 deletions.
4 changes: 2 additions & 2 deletions admin/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@
if (has_capability('moodle/user:update', $sitecontext)) {
// prevent editing of admins by non-admins
if (is_siteadmin($USER) or !is_siteadmin($user)) {
$url = new moodle_url($CFG->wwwroot.'/user/editadvanced.php', array('id'=>$user->id, 'course'=>$site->id));
$url = new moodle_url('/user/editadvanced.php', array('id'=>$user->id, 'course'=>$site->id));
$buttons[] = html_writer::link($url, $OUTPUT->pix_icon('t/edit', $stredit));
}
}
Expand Down Expand Up @@ -392,7 +392,7 @@
echo $OUTPUT->paging_bar($usercount, $page, $perpage, $baseurl);
}
if (has_capability('moodle/user:create', $sitecontext)) {
$url = new moodle_url($CFG->wwwroot . '/user/editadvanced.php', array('id' => -1));
$url = new moodle_url('/user/editadvanced.php', array('id' => -1));
echo $OUTPUT->single_button($url, get_string('addnewuser'), 'get');
}

Expand Down
4 changes: 2 additions & 2 deletions auth/classes/output/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ public function __construct(array $authsequence, $username = '') {
$this->autofocusform = !empty($CFG->loginpageautofocus);
$this->rememberusername = isset($CFG->rememberusername) and $CFG->rememberusername == 2;

$this->forgotpasswordurl = new moodle_url($CFG->wwwroot . '/login/forgot_password.php');
$this->loginurl = new moodle_url($CFG->wwwroot . '/login/index.php');
$this->forgotpasswordurl = new moodle_url('/login/forgot_password.php');
$this->loginurl = new moodle_url('/login/index.php');
$this->signupurl = new moodle_url('/login/signup.php');

// Authentication instructions.
Expand Down
18 changes: 8 additions & 10 deletions auth/oauth2/classes/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ public function complete_login(client $client, $redirecturl) {
$errormsg = get_string('loginerror_nouserinfo', 'auth_oauth2');
$SESSION->loginerrormsg = $errormsg;
$client->log_out();
redirect(new moodle_url($CFG->wwwroot . '/login/index.php'));
redirect(new moodle_url('/login/index.php'));
}
if (empty($userinfo['username']) || empty($userinfo['email'])) {
// Trigger login failed event.
Expand All @@ -375,7 +375,7 @@ public function complete_login(client $client, $redirecturl) {
$errormsg = get_string('loginerror_userincomplete', 'auth_oauth2');
$SESSION->loginerrormsg = $errormsg;
$client->log_out();
redirect(new moodle_url($CFG->wwwroot . '/login/index.php'));
redirect(new moodle_url('/login/index.php'));
}

$userinfo['username'] = trim(core_text::strtolower($userinfo['username']));
Expand Down Expand Up @@ -416,7 +416,7 @@ public function complete_login(client $client, $redirecturl) {
$errormsg = get_string('confirmationpending', 'auth_oauth2');
$SESSION->loginerrormsg = $errormsg;
$client->log_out();
redirect(new moodle_url($CFG->wwwroot . '/login/index.php'));
redirect(new moodle_url('/login/index.php'));
}
} else if (!empty($linkedlogin)) {
// Trigger login failed event.
Expand All @@ -428,7 +428,7 @@ public function complete_login(client $client, $redirecturl) {
$errormsg = get_string('confirmationpending', 'auth_oauth2');
$SESSION->loginerrormsg = $errormsg;
$client->log_out();
redirect(new moodle_url($CFG->wwwroot . '/login/index.php'));
redirect(new moodle_url('/login/index.php'));
}

$issuer = $client->get_issuer();
Expand All @@ -442,7 +442,7 @@ public function complete_login(client $client, $redirecturl) {
$errormsg = get_string('notloggedindebug', 'auth_oauth2', get_string('loginerror_invaliddomain', 'auth_oauth2'));
$SESSION->loginerrormsg = $errormsg;
$client->log_out();
redirect(new moodle_url($CFG->wwwroot . '/login/index.php'));
redirect(new moodle_url('/login/index.php'));
}

if (!$userwasmapped) {
Expand Down Expand Up @@ -481,7 +481,7 @@ public function complete_login(client $client, $redirecturl) {
$errormsg = get_string('accountexists', 'auth_oauth2');
$SESSION->loginerrormsg = $errormsg;
$client->log_out();
redirect(new moodle_url($CFG->wwwroot . '/login/index.php'));
redirect(new moodle_url('/login/index.php'));
}

if (email_is_not_allowed($userinfo['email'])) {
Expand All @@ -495,7 +495,7 @@ public function complete_login(client $client, $redirecturl) {
$errormsg = get_string('notloggedindebug', 'auth_oauth2', $reason);
$SESSION->loginerrormsg = $errormsg;
$client->log_out();
redirect(new moodle_url($CFG->wwwroot . '/login/index.php'));
redirect(new moodle_url('/login/index.php'));
}

if (!empty($CFG->authpreventaccountcreation)) {
Expand All @@ -509,7 +509,7 @@ public function complete_login(client $client, $redirecturl) {
$errormsg = get_string('notloggedindebug', 'auth_oauth2', $reason);
$SESSION->loginerrormsg = $errormsg;
$client->log_out();
redirect(new moodle_url($CFG->wwwroot . '/login/index.php'));
redirect(new moodle_url('/login/index.php'));
}

if ($issuer->get('requireconfirmation')) {
Expand Down Expand Up @@ -542,5 +542,3 @@ public function complete_login(client $client, $redirecturl) {
redirect($redirecturl);
}
}


6 changes: 3 additions & 3 deletions lib/editor/tinymce/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ public function use_editor($elementid, array $options=null, $fpoptions=null) {
global $PAGE, $CFG;
// Note: use full moodle_url instance to prevent standard JS loader, make sure we are using https on profile page if required.
if ($CFG->debugdeveloper) {
$PAGE->requires->js(new moodle_url($CFG->wwwroot.'/lib/editor/tinymce/tiny_mce/'.$this->version.'/tiny_mce_src.js'));
$PAGE->requires->js(new moodle_url('/lib/editor/tinymce/tiny_mce/'.$this->version.'/tiny_mce_src.js'));
} else {
$PAGE->requires->js(new moodle_url($CFG->wwwroot.'/lib/editor/tinymce/tiny_mce/'.$this->version.'/tiny_mce.js'));
$PAGE->requires->js(new moodle_url('/lib/editor/tinymce/tiny_mce/'.$this->version.'/tiny_mce.js'));
}
$PAGE->requires->js_init_call('M.editor_tinymce.init_editor', array($elementid, $this->get_init_params($elementid, $options)), true);
if ($fpoptions) {
Expand Down Expand Up @@ -257,7 +257,7 @@ public function get_plugin($plugin) {
*/
public function get_tinymce_base_url() {
global $CFG;
return new moodle_url("$CFG->wwwroot/lib/editor/tinymce/tiny_mce/$this->version/");
return new moodle_url("/lib/editor/tinymce/tiny_mce/$this->version/");
}

}
2 changes: 1 addition & 1 deletion lib/outputcomponents.php
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ public function export_for_template(renderer_base $output) {
$data->icon = (new pix_icon('help', $alt, 'core', ['class' => 'iconhelp']))->export_for_template($output);
$data->linktext = $this->linktext;
$data->title = get_string('helpprefix2', '', trim($title, ". \t"));
$data->url = (new moodle_url($CFG->wwwroot . '/help.php', [
$data->url = (new moodle_url('/help.php', [
'component' => $this->component,
'identifier' => $this->identifier,
'lang' => current_language()
Expand Down
16 changes: 8 additions & 8 deletions lib/outputlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -894,15 +894,15 @@ public function editor_css_url($encoded=true) {
global $CFG;
$rev = theme_get_revision();
if ($rev > -1) {
$url = new moodle_url("$CFG->wwwroot/theme/styles.php");
$url = new moodle_url("/theme/styles.php");
if (!empty($CFG->slasharguments)) {
$url->set_slashargument('/'.$this->name.'/'.$rev.'/editor', 'noparam', true);
} else {
$url->params(array('theme'=>$this->name,'rev'=>$rev, 'type'=>'editor'));
}
} else {
$params = array('theme'=>$this->name, 'type'=>'editor');
$url = new moodle_url($CFG->wwwroot.'/theme/styles_debug.php', $params);
$url = new moodle_url('/theme/styles_debug.php', $params);
}
return $url;
}
Expand Down Expand Up @@ -966,7 +966,7 @@ public function css_urls(moodle_page $page) {

if ($rev > -1) {
$filename = right_to_left() ? 'all-rtl' : 'all';
$url = new moodle_url("$CFG->wwwroot/theme/styles.php");
$url = new moodle_url("/theme/styles.php");
$themesubrevision = theme_get_sub_revision_for_theme($this->name);

// Provide the sub revision to allow us to invalidate cached theme CSS
Expand Down Expand Up @@ -1002,7 +1002,7 @@ public function css_urls(moodle_page $page) {
$urls[] = $url;

} else {
$baseurl = new moodle_url($CFG->wwwroot.'/theme/styles_debug.php');
$baseurl = new moodle_url('/theme/styles_debug.php');

$css = $this->get_css_files(true);
if (!$svg) {
Expand Down Expand Up @@ -1686,11 +1686,11 @@ public function javascript_url($inhead) {
}

if (!empty($CFG->slasharguments) and $rev > 0) {
$url = new moodle_url("$CFG->wwwroot/theme/javascript.php");
$url = new moodle_url("/theme/javascript.php");
$url->set_slashargument('/'.$this->name.'/'.$rev.'/'.$params['type'], 'noparam', true);
return $url;
} else {
return new moodle_url($CFG->wwwroot.'/theme/javascript.php', $params);
return new moodle_url('/theme/javascript.php', $params);
}
}

Expand Down Expand Up @@ -1922,7 +1922,7 @@ public function image_url($imagename, $component) {

$params['image'] = $imagename;

$url = new moodle_url("$CFG->wwwroot/theme/image.php");
$url = new moodle_url("/theme/image.php");
if (!empty($CFG->slasharguments) and $rev > 0) {
$path = '/'.$params['theme'].'/'.$params['component'].'/'.$params['rev'].'/'.$params['image'];
if (!$svg) {
Expand Down Expand Up @@ -1968,7 +1968,7 @@ public function font_url($font, $component) {

$params['font'] = $font;

$url = new moodle_url("$CFG->wwwroot/theme/font.php");
$url = new moodle_url("/theme/font.php");
if (!empty($CFG->slasharguments) and $rev > 0) {
$path = '/'.$params['theme'].'/'.$params['component'].'/'.$params['rev'].'/'.$params['font'];
$url->set_slashargument($path, 'noparam', true);
Expand Down
14 changes: 7 additions & 7 deletions lib/outputrequirementslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ public function jquery_plugin($plugin, $component = 'core') {
continue;
}
if (!empty($CFG->slasharguments)) {
$url = new moodle_url("$CFG->wwwroot/theme/jquery.php");
$url = new moodle_url("/theme/jquery.php");
$url->set_slashargument("/$component/$file");

} else {
Expand Down Expand Up @@ -705,14 +705,14 @@ protected function js_fix_url($url) {
if (substr($url, -3) === '.js') {
$jsrev = $this->get_jsrev();
if (empty($CFG->slasharguments)) {
return new moodle_url($CFG->wwwroot.'/lib/javascript.php', array('rev'=>$jsrev, 'jsfile'=>$url));
return new moodle_url('/lib/javascript.php', array('rev'=>$jsrev, 'jsfile'=>$url));
} else {
$returnurl = new moodle_url($CFG->wwwroot.'/lib/javascript.php');
$returnurl = new moodle_url('/lib/javascript.php');
$returnurl->set_slashargument('/'.$jsrev.$url);
return $returnurl;
}
} else {
return new moodle_url($CFG->wwwroot.$url);
return new moodle_url($url);
}
} else {
throw new coding_exception('Invalid JS url, it has to be shortened url starting with / or moodle_url instance.', $url);
Expand Down Expand Up @@ -911,7 +911,7 @@ public function css($stylesheet) {
if ($stylesheet instanceof moodle_url) {
// ok
} else if (strpos($stylesheet, '/') === 0) {
$stylesheet = new moodle_url($CFG->wwwroot.$stylesheet);
$stylesheet = new moodle_url($stylesheet);
} else {
throw new coding_exception('Invalid stylesheet parameter.', $stylesheet);
}
Expand Down Expand Up @@ -1315,9 +1315,9 @@ protected function get_amd_footercode() {
$output = '';
$jsrev = $this->get_jsrev();

$jsloader = new moodle_url($CFG->wwwroot . '/lib/javascript.php');
$jsloader = new moodle_url('/lib/javascript.php');
$jsloader->set_slashargument('/' . $jsrev . '/');
$requirejsloader = new moodle_url($CFG->wwwroot . '/lib/requirejs.php');
$requirejsloader = new moodle_url('/lib/requirejs.php');
$requirejsloader->set_slashargument('/' . $jsrev . '/');

$requirejsconfig = file_get_contents($CFG->dirroot . '/lib/requirejs/moodle-config.js');
Expand Down
4 changes: 2 additions & 2 deletions login/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@
if ($errormsg) {
$SESSION->loginerrormsg = $errormsg;
}
redirect(new moodle_url($CFG->wwwroot . '/login/index.php'));
redirect(new moodle_url('/login/index.php'));
}

$PAGE->set_title("$site->fullname: $loginsite");
Expand All @@ -339,7 +339,7 @@
if (isloggedin() and !isguestuser()) {
// prevent logging when already logged in, we do not want them to relogin by accident because sesskey would be changed
echo $OUTPUT->box_start();
$logout = new single_button(new moodle_url($CFG->wwwroot.'/login/logout.php', array('sesskey'=>sesskey(),'loginpage'=>1)), get_string('logout'), 'post');
$logout = new single_button(new moodle_url('/login/logout.php', array('sesskey'=>sesskey(),'loginpage'=>1)), get_string('logout'), 'post');
$continue = new single_button(new moodle_url('/'), get_string('cancel'), 'get');
echo $OUTPUT->confirm(get_string('alreadyloggedin', 'error', fullname($USER)), $logout, $continue);
echo $OUTPUT->box_end();
Expand Down
2 changes: 1 addition & 1 deletion login/signup.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
// Prevent signing up when already logged in.
echo $OUTPUT->header();
echo $OUTPUT->box_start();
$logout = new single_button(new moodle_url($CFG->wwwroot . '/login/logout.php',
$logout = new single_button(new moodle_url('/login/logout.php',
array('sesskey' => sesskey(), 'loginpage' => 1)), get_string('logout'), 'post');
$continue = new single_button(new moodle_url('/'), get_string('cancel'), 'get');
echo $OUTPUT->confirm(get_string('cannotsignup', 'error', fullname($USER)), $logout, $continue);
Expand Down
2 changes: 1 addition & 1 deletion repository/draftfiles_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

$params = array('ctx_id' => $contextid, 'itemid' => $itemid, 'env' => $env, 'course'=>$courseid, 'maxbytes'=>$maxbytes, 'areamaxbytes'=>$areamaxbytes, 'maxfiles'=>$maxfiles, 'subdirs'=>$subdirs, 'sesskey'=>sesskey());
$PAGE->set_url('/repository/draftfiles_manager.php', $params);
$filepicker_url = new moodle_url($CFG->wwwroot."/repository/filepicker.php", $params);
$filepicker_url = new moodle_url("/repository/filepicker.php", $params);

$params['action'] = 'browse';
$home_url = new moodle_url('/repository/draftfiles_manager.php', $params);
Expand Down
2 changes: 1 addition & 1 deletion repository/dropbox/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ public function get_option($config = '') {
public static function get_oauth2callbackurl() {
global $CFG;

return new moodle_url($CFG->wwwroot . '/admin/oauth2callback.php');
return new moodle_url('/admin/oauth2callback.php');
}

/**
Expand Down
4 changes: 2 additions & 2 deletions repository/filepicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@

$params['savepath'] = $savepath;
$params['repo_id'] = $repo_id;
$url = new moodle_url($CFG->wwwroot."/repository/filepicker.php", $params);
$url = new moodle_url("/repository/filepicker.php", $params);
$PAGE->set_url('/repository/filepicker.php', $params);

switch ($action) {
Expand Down Expand Up @@ -212,7 +212,7 @@
// TODO MDL-28482: need a better solution
// paging_bar is not a good option because it starts page numbering from 0 and
// repositories number pages starting from 1.
$pagingurl = new moodle_url("$CFG->wwwroot/repository/filepicker.php?action=list&itemid=$itemid&ctx_id=$contextid&repo_id=$repo_id&course=$courseid&sesskey=". sesskey());
$pagingurl = new moodle_url("/repository/filepicker.php?action=list&itemid=$itemid&ctx_id=$contextid&repo_id=$repo_id&course=$courseid&sesskey=". sesskey());
if (!isset($list['perpage']) && !isset($list['total'])) {
$list['perpage'] = 10; // instead of setting perpage&total we use number of pages, the result is the same
}
Expand Down
2 changes: 1 addition & 1 deletion theme/styles_debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
css_send_uncached_css($csscontent);
}

$chunkurl = new moodle_url($CFG->wwwroot . '/theme/styles_debug.php', array('theme' => $themename,
$chunkurl = new moodle_url('/theme/styles_debug.php', array('theme' => $themename,
'type' => $type, 'subtype' => $subtype, 'sheet' => $sheet, 'usesvg' => $usesvg, 'rtl' => $rtl));

// We need some kind of caching here because otherwise the page navigation becomes
Expand Down

0 comments on commit 7eb50b3

Please sign in to comment.