From 078c1134bfb47a4b99c275b00ee781658fb36450 Mon Sep 17 00:00:00 2001 From: jonathanharker Date: Sun, 14 Dec 2008 22:50:22 +0000 Subject: [PATCH] MDL-17548 MNET: Fix email links for sites with path component in wwwroot Where Moodle sites had a path in their wwwroot, the MNET function that forced remote users to go via their identity provider (to make sure they were logged in) previously directed the user back to a URL like contentprovider.com/moodle/moodle/mod/forum/view.php?f=7 where there should only be one /moodle in the middle of the URL. --- mnet/lib.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mnet/lib.php b/mnet/lib.php index 39be23ed743af..7539d0fda64c8 100644 --- a/mnet/lib.php +++ b/mnet/lib.php @@ -626,12 +626,20 @@ function mnet_get_peer_host ($mnethostid) { */ function mnet_sso_apply_indirection ($url) { global $MNETIDPJUMPURL; + global $CFG; $localpart=''; $urlparts = parse_url($url[1]); if($urlparts) { if (isset($urlparts['path'])) { - $localpart .= $urlparts['path']; + $path = $urlparts['path']; + // if our wwwroot has a path component, need to strip that path from beginning of the + // 'localpart' to make it relative to moodle's wwwroot + $wwwrootpath = parse_url($CFG->wwwroot, PHP_URL_PATH); + if (!empty($wwwrootpath) and strpos($path, $wwwrootpath) === 0) { + $path = substr($path, strlen($wwwrootpath)); + } + $localpart .= $path; } if (isset($urlparts['query'])) { $localpart .= '?'.$urlparts['query'];