Skip to content

Commit

Permalink
MDL-17548 MNET: Fix email links for sites with path component in wwwroot
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jonathanharker committed Dec 14, 2008
1 parent e6e1328 commit 078c113
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion mnet/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down

0 comments on commit 078c113

Please sign in to comment.