]> git.mjollnir.org Git - moodle.git/commitdiff
Fix for the fix: Turns out that next() returns false if an array element's
authordefacer <defacer>
Thu, 1 Apr 2004 11:29:25 +0000 (11:29 +0000)
committerdefacer <defacer>
Thu, 1 Apr 2004 11:29:25 +0000 (11:29 +0000)
value is 0 (the php docs speak only about the key... :/). Good thing that my
test user's timezone is set to GMT+0. This should work no matter what.

lib/moodlelib.php

index d59f61a83e87ed6a76aaa271bab85adbd1f23149..44a6820d1ed59cd3123d87077502e3be029a6562 100644 (file)
@@ -167,12 +167,11 @@ function make_timestamp($year, $month=1, $day=1, $hour=0, $minute=0, $second=0,
 
     // Work out the best timezone to use, in order of precedence
     $timezones = array(
-        99, // this is a placeholder that gets skipped in the first next() call
         isset($USER->timezone) ? $USER->timezone : 99,
         isset($CFG->timezone) ? $CFG->timezone : 99,
         );
-    while($timezone == 99 && $next = next($timezones)) {
-        $timezone = (float)$next;
+    while($timezone == 99 && $next = each($timezones)) {
+        $timezone = (float)$next['value'];
     }
 
     /*
@@ -263,12 +262,11 @@ function userdate($date, $format="", $timezone=99, $fixday = true) {
 
     // Work out the best timezone to use, in order of precedence
     $timezones = array(
-        99, // this is a placeholder that gets skipped in the first next() call
         isset($USER->timezone) ? $USER->timezone : 99,
         isset($CFG->timezone) ? $CFG->timezone : 99,
         );
-    while($timezone == 99 && $next = next($timezones)) {
-        $timezone = (float)$next;
+    while($timezone == 99 && $next = each($timezones)) {
+        $timezone = (float)$next['value'];
     }
 
     /*
@@ -342,12 +340,11 @@ function usertime($date, $timezone=99) {
 
     // Work out the best timezone to use, in order of precedence
     $timezones = array(
-        99, // this is a placeholder that gets skipped in the first next() call
         isset($USER->timezone) ? $USER->timezone : 99,
         isset($CFG->timezone) ? $CFG->timezone : 99,
         );
-    while($timezone == 99 && $next = next($timezones)) {
-        $timezone = (float)$next;
+    while($timezone == 99 && $next = each($timezones)) {
+        $timezone = (float)$next['value'];
     }
 
     /*
@@ -372,12 +369,11 @@ function usergetmidnight($date, $timezone=99) {
 
     // Work out the best timezone to use, in order of precedence
     $timezones = array(
-        99, // this is a placeholder that gets skipped in the first next() call
         isset($USER->timezone) ? $USER->timezone : 99,
         isset($CFG->timezone) ? $CFG->timezone : 99,
         );
-    while($timezone == 99 && $next = next($timezones)) {
-        $timezone = (float)$next;
+    while($timezone == 99 && $next = each($timezones)) {
+        $timezone = (float)$next['value'];
     }
     /*
     if ($timezone == 99) {                    // Work out the best timezone to use
@@ -405,12 +401,11 @@ function usertimezone($timezone=99) {
 
     // Work out the best timezone to use, in order of precedence
     $timezones = array(
-        99, // this is a placeholder that gets skipped in the first next() call
         isset($USER->timezone) ? $USER->timezone : 99,
         isset($CFG->timezone) ? $CFG->timezone : 99,
         );
-    while($timezone == 99 && $next = next($timezones)) {
-        $timezone = (float)$next;
+    while($timezone == 99 && $next = each($timezones)) {
+        $timezone = (float)$next['value'];
     }
     /*
     if ($timezone == 99) {                    // Work out the best timezone to use