From 0dd18fa6f616b6595a586ceb10ae5ead09714057 Mon Sep 17 00:00:00 2001 From: jerome Date: Tue, 7 Oct 2008 02:09:51 +0000 Subject: [PATCH] MDL-15800: clean filelib.php, fix https image link into the edit profil page (weblib.php), and also into the YUI integration (ajaxlib.php) --- lib/ajax/ajaxlib.php | 12 +++++++++--- lib/filelib.php | 10 ++++++++-- lib/weblib.php | 7 +------ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/ajax/ajaxlib.php b/lib/ajax/ajaxlib.php index d32dc16346d..b4d9e5af19a 100644 --- a/lib/ajax/ajaxlib.php +++ b/lib/ajax/ajaxlib.php @@ -10,7 +10,7 @@ */ function ajax_get_lib($libname) { - global $CFG; + global $CFG, $HTTPSPAGEREQUIRED; $libpath = ''; $translatelist = array( @@ -58,12 +58,18 @@ function ajax_get_lib($libname) { ); if (array_key_exists($libname, $translatelist)) { - $libpath = $CFG->wwwroot . $translatelist[$libname]; + if (!empty($HTTPSPAGEREQUIRED)) { + $wwwroot = $CFG->httpswwwroot; + } + else { + $wwwroot = $CFG->wwwroot; + } + $libpath = $wwwroot . $translatelist[$libname]; } else { $libpath = $libname; } - $testpath = str_replace($CFG->wwwroot, $CFG->dirroot, $libpath); + $testpath = str_replace($wwwroot, $CFG->dirroot, $libpath); if (!file_exists($testpath)) { error('require_js: '.$libpath.' - file not found.'); } diff --git a/lib/filelib.php b/lib/filelib.php index d7e381dfc3f..f5d10b65cc6 100644 --- a/lib/filelib.php +++ b/lib/filelib.php @@ -3,7 +3,7 @@ define('BYTESERVING_BOUNDARY', 's1k2o3d4a5k6s7'); //unique string constant function get_file_url($path, $options=null, $type='coursefile') { - global $CFG; + global $CFG, $HTTPSPAGEREQUIRED; $path = str_replace('//', '/', $path); $path = trim($path, '/'); // no leading and trailing slashes @@ -17,7 +17,13 @@ function get_file_url($path, $options=null, $type='coursefile') { $url = $CFG->wwwroot."/rss/file.php"; break; case 'user': - $url = $CFG->wwwroot."/user/pix.php"; + if (!empty($HTTPSPAGEREQUIRED)) { + $wwwroot = $CFG->httpswwwroot; + } + else { + $wwwroot = $CFG->wwwroot; + } + $url = $wwwroot."/user/pix.php"; break; case 'usergroup': $url = $CFG->wwwroot."/user/pixgroup.php"; diff --git a/lib/weblib.php b/lib/weblib.php index 2a7e0796b57..fe228a61b93 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -4346,7 +4346,7 @@ function print_file_picture($path, $courseid=0, $height='', $width='', $link='', * @todo Finish documenting this function */ function print_user_picture($user, $courseid, $picture=NULL, $size=0, $return=false, $link=true, $target='', $alttext=true) { - global $CFG, $HTTPSPAGEREQUIRED; + global $CFG; $needrec = false; // only touch the DB if we are missing data... @@ -4401,11 +4401,6 @@ function print_user_picture($user, $courseid, $picture=NULL, $size=0, $return=fa $file = 'f2'; } $class = "userpicture"; - if (!empty($HTTPSPAGEREQUIRED)) { - $wwwroot = $CFG->httpswwwroot; - } else { - $wwwroot = $CFG->wwwroot; - } if (is_null($picture)) { $picture = $user->picture;