Merge branch 'w15_MDL-32263_m23_enroladmin' of git://github.com/skodak/moodle
authorSam Hemelryk <sam@moodle.com>
Mon, 9 Apr 2012 22:48:34 +0000 (10:48 +1200)
committerSam Hemelryk <sam@moodle.com>
Mon, 9 Apr 2012 22:48:34 +0000 (10:48 +1200)
lib/enrollib.php
lib/moodlelib.php
lib/outputlib.php
lib/upgradelib.php

index ada83dd..c90139d 100644 (file)
@@ -261,8 +261,8 @@ function enrol_sharing_course($user1, $user2) {
 function enrol_get_shared_courses($user1, $user2, $preloadcontexts = false, $checkexistsonly = false) {
     global $DB, $CFG;
 
-    $user1 = !empty($user1->id) ? $user1->id : $user1;
-    $user2 = !empty($user2->id) ? $user2->id : $user2;
+    $user1 = isset($user1->id) ? $user1->id : $user1;
+    $user2 = isset($user2->id) ? $user2->id : $user2;
 
     if (empty($user1) or empty($user2)) {
         return false;
index 60def99..43c3e57 100644 (file)
@@ -8734,47 +8734,6 @@ function moodle_major_version($fromdisk = false) {
     }
 }
 
-/**
- * Sets maximum expected time needed for upgrade task.
- * Please always make sure that upgrade will not run longer!
- *
- * The script may be automatically aborted if upgrade times out.
- *
- * @category upgrade
- * @param int $max_execution_time in seconds (can not be less than 60 s)
- * @todo MDL-32293 - Move this function to lib/upgradelib.php
- */
-function upgrade_set_timeout($max_execution_time=300) {
-    global $CFG;
-
-    if (!isset($CFG->upgraderunning) or $CFG->upgraderunning < time()) {
-        $upgraderunning = get_config(null, 'upgraderunning');
-    } else {
-        $upgraderunning = $CFG->upgraderunning;
-    }
-
-    if (!$upgraderunning) {
-        // upgrade not running or aborted
-        print_error('upgradetimedout', 'admin', "$CFG->wwwroot/$CFG->admin/");
-        die;
-    }
-
-    if ($max_execution_time < 60) {
-        // protection against 0 here
-        $max_execution_time = 60;
-    }
-
-    $expected_end = time() + $max_execution_time;
-
-    if ($expected_end < $upgraderunning + 10 and $expected_end > $upgraderunning - 10) {
-        // no need to store new end, it is nearly the same ;-)
-        return;
-    }
-
-    set_time_limit($max_execution_time);
-    set_config('upgraderunning', $expected_end); // keep upgrade locked until this time
-}
-
 /// MISCELLANEOUS ////////////////////////////////////////////////////////////////////
 
 /**
index a862c42..280e19f 100644 (file)
@@ -941,6 +941,9 @@ class theme_config {
                     return $imagefile;
                 }
             }
+            if ($imagefile = $this->image_exists("$CFG->dataroot/pix/$image")) {
+                return $imagefile;
+            }
             if ($imagefile = $this->image_exists("$CFG->dirroot/pix/$image")) {
                 return $imagefile;
             }
@@ -974,6 +977,9 @@ class theme_config {
                     return $imagefile;
                 }
             }
+            if ($imagefile = $this->image_exists("$CFG->dataroot/pix_plugins/$type/$plugin/$image")) {
+                return $imagefile;
+            }
             $dir = get_plugin_directory($type, $plugin);
             if ($imagefile = $this->image_exists("$dir/pix/$image")) {
                 return $imagefile;
index 6db4216..a7c540e 100644 (file)
@@ -97,6 +97,46 @@ class plugin_defective_exception extends moodle_exception {
     }
 }
 
+/**
+ * Sets maximum expected time needed for upgrade task.
+ * Please always make sure that upgrade will not run longer!
+ *
+ * The script may be automatically aborted if upgrade times out.
+ *
+ * @category upgrade
+ * @param int $max_execution_time in seconds (can not be less than 60 s)
+ */
+function upgrade_set_timeout($max_execution_time=300) {
+    global $CFG;
+
+    if (!isset($CFG->upgraderunning) or $CFG->upgraderunning < time()) {
+        $upgraderunning = get_config(null, 'upgraderunning');
+    } else {
+        $upgraderunning = $CFG->upgraderunning;
+    }
+
+    if (!$upgraderunning) {
+        // upgrade not running or aborted
+        print_error('upgradetimedout', 'admin', "$CFG->wwwroot/$CFG->admin/");
+        die;
+    }
+
+    if ($max_execution_time < 60) {
+        // protection against 0 here
+        $max_execution_time = 60;
+    }
+
+    $expected_end = time() + $max_execution_time;
+
+    if ($expected_end < $upgraderunning + 10 and $expected_end > $upgraderunning - 10) {
+        // no need to store new end, it is nearly the same ;-)
+        return;
+    }
+
+    set_time_limit($max_execution_time);
+    set_config('upgraderunning', $expected_end); // keep upgrade locked until this time
+}
+
 /**
  * Upgrade savepoint, marks end of each upgrade block.
  * It stores new main version, resets upgrade timeout