# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: moodle/lib/ajax/ajaxlib.php
--- moodle/lib/ajax/ajaxlib.php Base (1.40.6.4)
+++ moodle/lib/ajax/ajaxlib.php Locally Modified (Based On 1.40.6.4)
@@ -10,7 +10,7 @@
  */
 function ajax_get_lib($libname) {
 
-    global $CFG;
+    global $CFG, $HTTPSPAGEREQUIRED;
     $libpath = '';
 
     $translatelist = array(
@@ -58,12 +58,18 @@
             );
 
     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.');
     }
Index: moodle/lib/filelib.php
--- moodle/lib/filelib.php Base (1.50.2.20)
+++ moodle/lib/filelib.php Locally Modified (Based On 1.50.2.20)
@@ -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 @@
             $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";
Index: moodle/lib/weblib.php
--- moodle/lib/weblib.php Base (1.970.2.111)
+++ moodle/lib/weblib.php Locally Modified (Based On 1.970.2.111)
@@ -4346,7 +4346,7 @@
  * @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 @@
         $file = 'f2';
     }
     $class = "userpicture";
-    if (!empty($HTTPSPAGEREQUIRED)) {
-        $wwwroot = $CFG->httpswwwroot;
-    } else {
-        $wwwroot = $CFG->wwwroot;
-    }
 
     if (is_null($picture)) {
         $picture = $user->picture;
