]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-17548 MNET: Fix email links for sites with path component in wwwroot
authorjonathanharker <jonathanharker>
Sun, 14 Dec 2008 22:50:22 +0000 (22:50 +0000)
committerjonathanharker <jonathanharker>
Sun, 14 Dec 2008 22:50:22 +0000 (22:50 +0000)
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

index 39be23ed743afe524a3ba489f1e1051d1ebfcec1..7539d0fda64c81ff0e96beb7f6fcb553775b7d00 100644 (file)
@@ -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'];