Permalink
Browse files

MDL-17548 MNET: Fix email links for sites with path component in wwwroot

Where Moodle sites have 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.

Slightly tweaked from HEAD to support PHP4
  • Loading branch information...
1 parent 62cf1ae commit 2b11b765dd9c08fe657f0de418a70284735d1c4e jonathanharker committed Dec 14, 2008
Showing with 9 additions and 1 deletion.
  1. +9 −1 mnet/lib.php
View
@@ -564,12 +564,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
+ $wwwrootparts = parse_url($CFG->wwwroot);
+ if (!empty($wwwrootparts['path']) and strpos($path, $wwwrootparts['path']) === 0) {
+ $path = substr($path, strlen($wwwrootparts['path']));
+ }
+ $localpart .= $path;
}
if (isset($urlparts['query'])) {
$localpart .= '?'.$urlparts['query'];

0 comments on commit 2b11b76

Please sign in to comment.