diff --git a/admin.php b/admin.php index 6b43828e4..638c444ea 100644 --- a/admin.php +++ b/admin.php @@ -129,6 +129,10 @@ function save_pref( $prefs, $src) { $GLOBALS['FONTS'] = $s['FONTS']; $GLOBALS['MYEVENTS'] = $s['MYEVENTS']; +//determine if we can set timezones, if not don't display any options +$can_set_timezone = set_env ( "TZ", $s['SERVER_TIMEZONE'] ); + + $BodyX = 'onload="public_handler(); eu_handler(); sr_handler(); attach_handler(); comment_handler(); email_handler();'; $BodyX .= ( ! empty ( $currenttab ) ? "showTab( '". $currenttab . "' );\"" : '"' ); $INC = array('js/admin.php','js/visible.php'); @@ -199,6 +203,17 @@ function save_pref( $prefs, $src) { + + "> + + + +   @@ -329,20 +344,6 @@ function save_pref( $prefs, $src) {   - "> - : -   -    - - "> - -    - " onclick="window.open('load_tz_data.php','_blank','dependent,height=200,width=400,outerHeight=220,outerWidth=420');" name="" /> - "> :   @@ -729,12 +730,6 @@ function save_pref( $prefs, $src) { - - "> - : -   - - "> @@ -918,7 +913,7 @@ function save_pref( $prefs, $src) { +echo date_to_str ( date ("Ymd"), $DATE_FORMAT_MY, false );?>
diff --git a/datesel.php b/datesel.php index acbfcd935..187870555 100644 --- a/datesel.php +++ b/datesel.php @@ -52,17 +52,15 @@ if ( $WEEK_START == 1 ) echo "" . weekday_short_name ( 0 ) . "\n"; echo "\n"; -if ( $WEEK_START == "1" ) - $wkstart = get_monday_before ( $thisyear, $thismonth, 1 ); -else - $wkstart = get_sunday_before ( $thisyear, $thismonth, 1 ); +$wkstart = get_weekday_before ( $thisyear, $thismonth, 1 ); + $monthstart = mktime ( 0, 0, 0, $thismonth, 1, $thisyear ); $monthend = mktime ( 0, 0, 0, $thismonth + 1, 0, $thisyear ); for ( $i = $wkstart; date ( "Ymd", $i ) <= date ( "Ymd", $monthend ); - $i += ( 24 * 3600 * 7 ) ) { + $i += ( ONE_DAY * 7 ) ) { echo "\n"; for ( $j = 0; $j < 7; $j++ ) { - $date = $i + ( $j * 24 * 3600 ); + $date = $i + ( $j * ONE_DAY ); if ( ( date ( "Ymd", $date ) >= date ( "Ymd", $monthstart ) && date ( "Ymd", $date ) <= date ( "Ymd", $monthend ) ) || ( ! empty ( $DISPLAY_ALL_DAYS_IN_MONTH ) && diff --git a/day.php b/day.php index af4fc1a05..92993d31c 100644 --- a/day.php +++ b/day.php @@ -31,8 +31,8 @@ $boldDays = false; } -$startdate = sprintf ( "%04d%02d01", $thisyear, $thismonth ); -$enddate = sprintf ( "%04d%02d31", $thisyear, $thismonth ); +$startdate = mktime ( 0, 0, 0, $thismonth, 1, $thisyear ); +$enddate = mktime ( 0, 0, 0, $thismonth +1 , 0, $thisyear ); $HeadX = ''; if ( $AUTO_REFRESH == "Y" && ! empty ( $AUTO_REFRESH_TIME ) ) { diff --git a/del_entry.php b/del_entry.php index 19b1d5f30..6264246b2 100644 --- a/del_entry.php +++ b/del_entry.php @@ -135,10 +135,12 @@ if ( $res ) { $row = dbi_fetch_row ( $res ); $name = $row[0]; - $eventdate = $row[1]; - $eventtime = $row[2]; + $fmtdate = $row[1]; + $time = $row[2]; dbi_free_result ( $res ); } + + $eventstart = date_to_epoch ( $fmtdate . $time ); $TIME_FORMAT=24; for ( $i = 0; $i < count ( $partlogin ); $i++ ) { // Log the deletion @@ -153,6 +155,7 @@ $htmlmail = get_pref_setting ( $partlogin[$i], "EMAIL_HTML" ); $t_format = get_pref_setting ( $partlogin[$i], "TIME_FORMAT" ); $user_TIMEZONE = get_pref_setting ( $partlogin[$i], "TIMEZONE" ); + set_env ( "TZ", $user_TIMEZONE ); $user_language = get_pref_setting ( $partlogin[$i], "LANGUAGE" ); user_load_variables ( $partlogin[$i], "temp" ); if ( ! $is_nonuser_admin && $partlogin[$i] != $login && $do_send == "Y" && @@ -168,9 +171,10 @@ " " . $login_fullname . ".\n" . translate("The subject was") . " \"" . $name . "\"\n" . translate("Date") . ": " . date_to_str ($thisdate) . "\n"; - if ( $eventtime != '-1' ) $msg .= translate("Time") . ": " . + if ( ! empty ( $eventtime ) && $eventtime != '-1' ) + $msg .= translate("Time") . ": " . // Apply user's GMT offset and display their TZID - display_time ( $eventdate . $eventtime, 2, '', $user_TIMEZONE, $t_format ); + display_time ( '', 2, $eventstart, $t_format ); $msg .= "\n\n"; $msg = stripslashes ( $msg ); //use WebCalMailer class @@ -278,6 +282,8 @@ $url = get_preferred_view ( "", empty ( $user ) ? "" : "user=$user" ); } +//return to login TIMEZONE +set_env ( "TZ", $TIMEZONE ); if ( empty ( $error ) ) { do_redirect ( $url ); exit; diff --git a/edit_entry.php b/edit_entry.php index fbb52c9ae..36f8dc372 100644 --- a/edit_entry.php +++ b/edit_entry.php @@ -100,20 +100,18 @@ $due_date = $row[13]; $due_time = $row[14]; - $adjusted_start = get_datetime_add_tz ( $cal_date, $cal_time ); - $adjusted_due = get_datetime_add_tz ( $due_date, $due_time ); - + $calTS = date_to_epoch ( $cal_date . $cal_time ); //Don't adjust for All Day entries - //this could probably replace the code below at line 160 if ( $cal_time > 0 || ( $cal_time == 0 && $row[5] != 1440 ) ) { - $cal_date = date ( "Ymd",$adjusted_start ); - $cal_time = date ( "His", $adjusted_start ); + $cal_date = date ( "Ymd", $calTS ); + $cal_time = date ( "His", $calTS ); } $hour = floor($cal_time / 10000); $minute = ( $cal_time / 100 ) % 100; - $due_date = date ( "Ymd",$adjusted_due ); - $due_time = date ( "His", $adjusted_due ); + $dueTS = date_to_epoch ( $due_date . $due_time ); + $due_date = date ( "Ymd", $dueTS ); + $due_time = date ( "His", $dueTS ); $due_hour = floor($due_time / 10000); $due_minute = ( $due_time / 100 ) % 100; @@ -149,32 +147,8 @@ $month = ( $cal_date / 100 ) % 100; $day = $cal_date % 100; $time = $row[2]; - - $tz_offset = get_tz_offset ( $TIMEZONE, mktime ( 0, 0, 0, $month, $day, $year ) ); - // test for AllDay event, if so, don't adjust time - if ( $time > 0 || ( $time == 0 && $row[5] != 1440 ) ) { /* -1 = no time specified */ - $time = get_time_add_tz ( $time, $tz_offset[0] ); - if ( $time > 240000 ) { - $time -= 240000; - $gmt = mktime ( 0, 0, 0, $month, $day, $year ); - $gmt += ONE_DAY; - $month = date ( "m", $gmt ); - $day = date ( "d", $gmt ); - $year = date ( "Y", $gmt ); - } else if ( $time < 0 ) { - $time += 240000; - $gmt = mktime ( 0, 0, 0, $month, $day, $year ); - $gmt -= ONE_DAY; - $month = date ( "m", $gmt ); - $day = date ( "d", $gmt ); - $year = date ( "Y", $gmt ); - } - // Set alterted date - // $cal_date = sprintf("%04d%02d%02d",$year,$month,$day); - } + if ( $time >= 0 ) { - $hour = floor($time / 10000); - $minute = ( $time / 100 ) % 100; $duration = $row[5]; } else { $duration = ""; @@ -206,12 +180,13 @@ if ( $row = dbi_fetch_row ( $res ) ) { $rpt_type = $row[1]; if ( $row[2] > 0 ) - $rpt_end = get_datetime_add_tz( $row[2], $row[3] ); + $rpt_end = date_to_epoch( $row[2] . $row[3] ); else $rpt_end = 0; if ( ! empty ( $row[2] ) ) { - $rpt_end_date = date( "Ymd", get_datetime_add_tz( $row[2], $row[3] ) ); - $rpt_end_time = date( "His", get_datetime_add_tz( $row[2], $row[3] ) ); + $rpt_endTS = date_to_epoch( $row[2] . $row[3] ); + $rpt_end_date = date( "Ymd", $rpt_endTS ); + $rpt_end_time = date( "His", $rpt_endTS ); } else { $rpt_end_date = $cal_date; $rpt_end_time = $cal_time; @@ -305,8 +280,8 @@ } //get reminders - $reminder = getReminders ( $id, $tz_offset[0] ); - $reminder_offset = ( isset ($reminder['offset'] ) ? $reminder['offset']:0); + $reminder = getReminders ( $id ); + $reminder_offset = $reminder['offset']; //get participants $sql = "SELECT cal_login FROM webcal_entry_user WHERE cal_id = ? AND " . @@ -339,10 +314,14 @@ //reminder settings $reminder_offset = ($REMINDER_WITH_DATE =='N' ? $REMINDER_OFFSET:0); + + if ( $eType == 'task' ) { + $hour = $WORK_DAY_START_HOUR; + } // Anything other then testing for strlen breaks either hour=0 or no hour in URL if ( strlen ( $hour ) ) { - $time = $hour * 100; - } else { + $time = $hour * 100; + } else { $time = -1; $hour = -1; } @@ -375,7 +354,7 @@ $hour = -1; if ( empty ( $duration ) ) $duration = 0; -if ( $duration == ( 24 * 60 ) && $hour == 0 ) { +if ( $duration == ONE_DAY && $hour == 0 ) { $hour = $minute = $duration = ""; $allday = "Y"; } else @@ -421,15 +400,16 @@ $due_date = $thisdate; //Setup to display user's timezone difference if Admin or Assistane -//Even thought event is stored in GMT, an Assistant may need to know that +//Even though event is stored in GMT, an Assistant may need to know that //the boss is in a different Timezone -if ( $is_assistant || $is_admin && ! empty ( $user ) ) { - $tz_offset = get_tz_offset ( $TIMEZONE, '', $cal_date ); +if ( $is_assistant || $is_admin && ! empty ( $user ) ) { + $tz_offset = date ( "Z", $calTS ); $user_TIMEZONE = get_pref_setting ( $user, "TIMEZONE" ); - $user_TZ = get_tz_offset ( $user_TIMEZONE, '', $cal_date ); - if ( $tz_offset[0] != $user_TZ[0] ) { //Different TZ_Offset + set_env ( "TZ", $user_TIMEZONE ); + $user_tz_offset = date ( "Z", $calTS ); + if ( $tz_offset != $user_tz_offset ) { //Different TZ_Offset user_load_variables ( $user, "temp" ); - $tz_diff = $user_TZ[0] - $tz_offset[0]; + $tz_diff = $user_tz_offset - $tz_offset; $tz_value = ( $tz_diff > 0? translate ("hours ahead of you") : translate ("hours behind you") ); $TZ_notice = "(" . $tempfullname . " " . @@ -438,6 +418,8 @@ $TZ_notice .= abs ( $tz_diff ) . " " . $tz_value . ".
 "; $TZ_notice .= translate ("Time entered here is based on your Timezone") . ".)"; } + //return to $login TIMEZONE + set_env ( "TZ", $TIMEZONE ); } if ( $ALLOW_HTML_DESCRIPTION == "Y" ){ // Allow HTML in description @@ -751,8 +733,7 @@ } if ( $cal_time < 0 ) $h12 = ""; ?> - :" maxlength="2" /> @@ -1276,7 +1257,7 @@ ?> onclick="toggle_rem_when()" />