diff --git a/calendar/day.php b/calendar/day.php index 9ef7c0eb31..3dfe01812c 100644 --- a/calendar/day.php +++ b/calendar/day.php @@ -70,8 +70,8 @@ } } - $now = $phpgw->calendar->makegmttime(0, 0, 0, $thismonth, $thisday, $thisyear); - $now['raw'] += $phpgw->calendar->tz_offset; + $now = $phpgw->calendar->datetime->makegmttime(0, 0, 0, $thismonth, $thisday, $thisyear); + $now['raw'] += $phpgw->calendar->datetime->tz_offset; $m = mktime(0,0,0,$thismonth,1,$thisyear); $var = Array( @@ -87,7 +87,7 @@ $p->set_var($var); $p->pparse('out','day_t'); - if(!isset($friendly) || $friendly == False) + if(!isset($friendly) || !$friendly) { $phpgw->common->phpgw_footer(); } diff --git a/calendar/inc/class.calendar.inc.php b/calendar/inc/class.calendar.inc.php index 26d301348b..6fe2a93e9c 100755 --- a/calendar/inc/class.calendar.inc.php +++ b/calendar/inc/class.calendar.inc.php @@ -24,7 +24,7 @@ if(isset($phpgw_info['server']['calendar_type']) && // The following line can be removed when vCalendar is implemented.... $phpgw_info['server']['calendar_type'] = 'sql'; //CreateObject('calendar.vCalendar'); -CreateObject('calendar.calendar__'); +$temp = CreateObject('calendar.calendar__'); include(PHPGW_INCLUDE_ROOT.'/calendar/inc/class.calendar_'.$phpgw_info['server']['calendar_type'].'.inc.php'); class calendar extends calendar_ @@ -44,7 +44,6 @@ class calendar extends calendar_ var $sorted_events_matching = 0; var $end_repeat_day = 0; var $weekstarttime; - var $days = Array(); var $tz_offset; @@ -89,11 +88,13 @@ class calendar extends calendar_ $this->template_dir = $phpgw->common->get_tpl_dir('calendar'); $this->phpgwapi_template_dir = PHPGW_IMAGES_DIR; $this->image_dir = $phpgw->common->get_image_path('calendar'); - $this->today = $this->localdates(time()); - $this->open('',intval($this->owner)); + $this->calendar__(); + + $this->today = $this->datetime->localdates(time()); + + $this->open('INBOX',intval($this->owner)); $this->set_filter(); - $this->tz_offset = ((60 * 60) * intval($phpgw_info['user']['preferences']['common']['tz_offset'])); if ($phpgw_info['user']['preferences']['common']['timeformat'] == '12') { @@ -110,23 +111,6 @@ class calendar extends calendar_ // Generic functions that are derived from mcal functions. // NOT PART OF THE ORIGINAL MCAL SPECS. - function time_compare($a_hour,$a_minute,$a_second,$b_hour,$b_minute,$b_second) - { - $a_time = mktime(intval($a_hour),intval($a_minute),intval($a_second),0,0,70); - $b_time = mktime(intval($b_hour),intval($b_minute),intval($b_second),0,0,70); - if($a_time == $b_time) - { - return 0; - } - elseif($a_time > $b_time) - { - return 1; - } - elseif($a_time < $b_time) - { - return -1; - } - } function set_filter() { @@ -171,7 +155,7 @@ class calendar extends calendar_ $fullname = $db->f('account_lid'); if($db->f('account_lastname') && $db->f('account_firstname')) { -+ $fullname = $db->f('account_lastname').', '.$db->f('account_firstname'); + $fullname = $db->f('account_lastname').', '.$db->f('account_firstname'); } return $fullname; } @@ -215,78 +199,6 @@ class calendar extends calendar_ } } - function get_weekday_start($year,$month,$day) - { - global $phpgw_info; - - $weekday = $this->day_of_week($year,$month,$day); - switch($phpgw_info['user']['preferences']['calendar']['weekdaystarts']) - { - case 'Monday': - $days = Array( - 0 => 'Mon', - 1 => 'Tue', - 2 => 'Wed', - 3 => 'Thu', - 4 => 'Fri', - 5 => 'Sat', - 6 => 'Sun' - ); - switch($weekday) - { - case 0: - $sday = mktime(2,0,0,$month,$day - 6,$year); - break; - case 1: - $sday = mktime(2,0,0,$month,$day,$year); - break; - default: - $sday = mktime(2,0,0,$month,$day - ($weekday - 1),$year); - break; - } - break; - case 'Sunday': - $days = Array( - 0 => 'Sun', - 1 => 'Mon', - 2 => 'Tue', - 3 => 'Wed', - 4 => 'Thu', - 5 => 'Fri', - 6 => 'Sat' - ); - $sday = mktime(2,0,0,$month,$day - $weekday,$year); - break; -// The following is for Arabic support..... - case 'Saturday': - $days = Array( - 0 => 'Sat', - 1 => 'Sun', - 2 => 'Mon', - 3 => 'Tue', - 4 => 'Wed', - 5 => 'Thu', - 6 => 'Fri' - ); - switch($weekday) - { - case 0: - $sday = mktime(2,0,0,$month,$day - 1,$year); - break; - case 6: - $sday = mktime(2,0,0,$month,$day,$year); - break; - default: - $sday = mktime(2,0,0,$month,$day - ($weekday + 1),$year); - break; - } - break; - } - - $this->days = $days; - return $sday; - } - function link_to_entry($event,$month,$day,$year) { global $phpgw, $phpgw_info; @@ -307,11 +219,11 @@ class calendar extends calendar_ $p->set_block('link_picture','link_text','link_text'); $description = $this->get_short_field($event,$is_private,'description'); - $starttime = mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year) - $this->tz_offset; - $endtime = mktime($event->end->hour,$event->end->min,$event->end->sec,$event->end->month,$event->end->mday,$event->end->year) - $this->tz_offset; + $starttime = mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year) - $this->datetime->tz_offset; + $endtime = mktime($event->end->hour,$event->end->min,$event->end->sec,$event->end->month,$event->end->mday,$event->end->year) - $this->datetime->tz_offset; $rawdate = mktime(0,0,0,$month,$day,$year); - $rawdate_offset = $rawdate - $this->tz_offset; - $nextday = mktime(0,0,0,$month,$day + 1,$year) - $this->tz_offset; + $rawdate_offset = $rawdate - $this->datetime->tz_offset; + $nextday = mktime(0,0,0,$month,$day + 1,$year) - $this->datetime->tz_offset; if (intval($phpgw->common->show_date($starttime,'Hi')) && $starttime == $endtime) { $time = $phpgw->common->show_date($starttime,'Hi'); @@ -333,7 +245,7 @@ class calendar extends calendar_ if($endtime >= ($rawdate_offset + 86400)) { - $end_time = $phpgw->common->show_date(mktime(23,59,59,$month,$day,$year) - $this->tz_offset,$this->users_timeformat); + $end_time = $phpgw->common->show_date(mktime(23,59,59,$month,$day,$year) - $this->datetime->tz_offset,$this->users_timeformat); } else { @@ -518,7 +430,7 @@ class calendar extends calendar_ $c_events = count($events); for($i=0;$i<$c_events;$i++) { - $this->repeating_events[] = $this->fetch_event($this->stream,$events[$i]); + $this->repeating_events[] = $this->fetch_event($events[$i]); } } } @@ -716,7 +628,7 @@ class calendar extends calendar_ { for($i=0;$i<$this->sorted_events_matching;$i++) { - $events[] = $this->fetch_event($this->stream,$event[$i]); + $events[] = $this->fetch_event($event[$i]); } if($this->sorted_events_matching == 1) @@ -781,13 +693,13 @@ class calendar extends calendar_ { global $phpgw, $phpgw_info, $view; - $date = $this->makegmttime(0,0,0,$month,$day,$year); + $date = $this->datetime->makegmttime(0,0,0,$month,$day,$year); $month_ago = intval(date('Ymd',mktime(0,0,0,$month - 1,$day,$year))); $month_ahead = intval(date('Ymd',mktime(0,0,0,$month + 1,$day,$year))); $monthstart = intval(date('Ymd',mktime(0,0,0,$month,1,$year))); $monthend = intval(date('Ymd',mktime(0,0,0,$month + 1,0,$year))); - $weekstarttime = $this->get_weekday_start($year,$month,1); + $weekstarttime = $this->datetime->get_weekday_start($year,$month,1); $p = CreateObject('phpgwapi.Template',$this->template_dir); $p->set_unknowns('remove'); @@ -850,7 +762,7 @@ class calendar extends calendar_ for($i=0;$i<7;$i++) { - $p->set_var('dayname','' . substr(lang($this->days[$i]),0,2) . ''); + $p->set_var('dayname','' . substr(lang($this->datetime->days[$i]),0,2) . ''); $p->parse('daynames','mini_day',True); } for($i=$weekstarttime;date('Ymd',$i)<=$monthend;$i += (24 * 3600 * 7)) @@ -858,8 +770,8 @@ class calendar extends calendar_ for($j=0;$j<7;$j++) { $str = ''; - $cal = $this->gmtdate($i + ($j * 24 * 3600)); - $cal = $this->makegmttime(0,0,0,$cal['month'],$cal['day'],$cal['year']); + $cal = $this->datetime->gmtdate($i + ($j * 24 * 3600)); + $cal = $this->datetime->makegmttime(0,0,0,$cal['month'],$cal['day'],$cal['year']); if($cal['full'] >= $monthstart && $cal['full'] <= $monthend) { $day_image = ''; @@ -945,7 +857,7 @@ class calendar extends calendar_ $p->set_var('monthweek_day',''); } - $return_value = $p->finish($p->parse('out','mini_cal')); + $return_value = $p->fp('out','mini_cal'); unset($p); return $return_value; } @@ -957,8 +869,8 @@ class calendar extends calendar_ $retval = Array(); $ok = False; - $starttime -= $this->tz_offset; - $endtime -= $this->tz_offset; + $starttime -= $this->datetime->tz_offset; + $endtime -= $this->datetime->tz_offset; if($starttime == $endtime) { @@ -1034,7 +946,7 @@ class calendar extends calendar_ { global $phpgw_info; - $this->weekstarttime = $this->get_weekday_start($year,$month,1); + $this->weekstarttime = $this->datetime->get_weekday_start($year,$month,1); $p = CreateObject('phpgwapi.Template',$this->template_dir); $p->set_unknowns('remove'); @@ -1061,11 +973,11 @@ class calendar extends calendar_ for($i=0;$i<7;$i++) { - $p->set_var('col_title',lang($this->days[$i])); + $p->set_var('col_title',lang($this->datetime->days[$i])); $p->parse('column_header','column_title',True); } - return $p->finish($p->parse('out','monthly_header')); + return $p->fp('out','monthly_header'); } function display_week($startdate,$weekly,$cellcolor,$display_name = False,$owner=0,$monthstart=0,$monthend=0) @@ -1106,7 +1018,7 @@ class calendar extends calendar_ } for ($j=0;$j<7;$j++) { - $date = $this->gmtdate($startdate + ($j * 86400)); + $date = $this->datetime->gmtdate($startdate + ($j * 86400)); $var = Array( 'column_data' => '', 'extra' => '' @@ -1116,7 +1028,7 @@ class calendar extends calendar_ $day = $phpgw->common->show_date($date['raw'],'d'); $month = $phpgw->common->show_date($date['raw'],'m'); $year = $phpgw->common->show_date($date['raw'],'Y'); - $date = $this->gmtdate(mktime(0,0,0,$date['month'],$date['day'],$date['year'])); + $date = $this->datetime->gmtdate(mktime(0,0,0,$date['month'],$date['day'],$date['year'])); if ($weekly || ($date['full'] >= $monthstart && $date['full'] <= $monthend)) { @@ -1246,7 +1158,7 @@ class calendar extends calendar_ $p->set_block('week','m_w_table','m_w_table'); $p->set_block('week','event','event'); - $start = $this->get_weekday_start($year, $month, $day); + $start = $this->datetime->get_weekday_start($year, $month, $day); $this->end_repeat_day = $start + 604800; @@ -1298,7 +1210,7 @@ class calendar extends calendar_ $this->end_repeat_day = $monthend; - $start = $this->get_weekday_start($year, $month, 1); + $start = $this->datetime->get_weekday_start($year, $month, 1); $this->repeated_events = Null; $this->repeating_events = Null; @@ -1443,7 +1355,7 @@ class calendar extends calendar_ $time = Array(); - $date = $this->localdates($date['raw'] - $this->tz_offset); + $date = $this->datetime->localdates($date['raw'] - $this->datetime->tz_offset); // echo 'Searching for events on : '.$phpgw->common->show_date($date['raw'])."
\n"; @@ -1664,18 +1576,16 @@ class calendar extends calendar_ $p->parse('row','list',True); } - $start = mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year) - $this->tz_offset; $var = Array( 'field' => lang('Start Date/Time'), - 'data' => $phpgw->common->show_date($start) + 'data' => $phpgw->common->show_date(mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year) - $this->datetime->tz_offset) ); $p->set_var($var); $p->parse('row','list',True); - $end = mktime($event->end->hour,$event->end->min,$event->end->sec,$event->end->month,$event->end->mday,$event->end->year) - $this->tz_offset; $var = Array( 'field' => lang('End Date/Time'), - 'data' => $phpgw->common->show_date($end) + 'data' => $phpgw->common->show_date(mktime($event->end->hour,$event->end->min,$event->end->sec,$event->end->month,$event->end->mday,$event->end->year) - $this->datetime->tz_offset) ); $p->set_var($var); $p->parse('row','list',True); @@ -1784,7 +1694,7 @@ class calendar extends calendar_ $recur_end = mktime($event->recur_enddate->hour,$event->recur_enddate->min,$event->recur_enddate->sec,$event->recur_enddate->month,$event->recur_enddate->mday,$event->recur_enddate->year); if($recur_end != 0) { - $recur_end -= $this->tz_offset; + $recur_end -= $this->datetime->tz_offset; $str .= lang('ends').': '.lang($phpgw->common->show_date($recur_end,'l')); $str .= ', '.lang($phpgw->common->show_date($recur_end,'F')); $str .= ' '.$phpgw->common->show_date($recur_end,'d, Y').' '; @@ -1873,7 +1783,7 @@ class calendar extends calendar_ 'action_extra_field' => '' ); $p->set_var($var); - $str .= ''.$p->finish($p->parse('out','form_button')).''."\n"; + $str .= ''.$p->fp('out','form_button').''."\n"; $var = Array( 'action_url_button' => $phpgw->link('/calendar/action.php','id='.$this->event->id.'&action='.REJECTED), @@ -1882,7 +1792,7 @@ class calendar extends calendar_ 'action_extra_field' => '' ); $p->set_var($var); - $str .= ''.$p->finish($p->parse('out','form_button')).''."\n"; + $str .= ''.$p->fp('out','form_button').''."\n"; $var = Array( 'action_url_button' => $phpgw->link('/calendar/action.php','id='.$this->event->id.'&action='.TENTATIVE), @@ -1891,7 +1801,7 @@ class calendar extends calendar_ 'action_extra_field' => '' ); $p->set_var($var); - $str .= ''.$p->finish($p->parse('out','form_button')).''."\n"; + $str .= ''.$p->fp('out','form_button').''."\n"; $var = Array( 'action_url_button' => $phpgw->link('/calendar/action.php','id='.$this->event->id.'&action='.NO_RESPONSE), @@ -1900,7 +1810,7 @@ class calendar extends calendar_ 'action_extra_field' => '' ); $p->set_var($var); - $str .= ''.$p->finish($p->parse('out','form_button')).''."\n"; + $str .= ''.$p->fp('out','form_button').''."\n"; $str .= ''; @@ -1995,8 +1905,8 @@ class calendar extends calendar_ for($k=0;$k<$this->sorted_events_matching;$k++) { $event = $events[$k]; - $eventstart = $this->localdates($event->datetime); - $eventend = $this->localdates($event->edatetime); + $eventstart = $this->datetime->localdates($event->datetime); + $eventend = $this->datetime->localdates($event->edatetime); $start = ($eventstart['hour'] * 10000) + ($eventstart['minute'] * 100); $starttemp = $this->splittime("$start",False); $subminute = 0; diff --git a/calendar/inc/class.calendar__.inc.php b/calendar/inc/class.calendar__.inc.php index 82d580a7a3..72dfc3a28d 100755 --- a/calendar/inc/class.calendar__.inc.php +++ b/calendar/inc/class.calendar__.inc.php @@ -59,6 +59,12 @@ class calendar__ var $modified; var $deleted; var $added; + var $datetime; + + function calendar__() + { + $this->datetime = CreateObject('phpgwapi.datetime'); + } function send_update($msg_type,$participants,$old_event=False,$new_event=False) { @@ -144,12 +150,12 @@ class calendar__ if($old_event != False) { - $old_event_datetime = $t_old_start_time - $tz_offset; + $old_event_datetime = $t_old_start_time - $this->datetime->tz_offset; } if($new_event != False) { - $new_event_datetime = mktime($new_event->start->hour,$new_event->start->min,$new_event->start->sec,$new_event->start->month,$new_event->start->mday,$new_event->start->year) - $tz_offset; + $new_event_datetime = mktime($new_event->start->hour,$new_event->start->min,$new_event->start->sec,$new_event->start->month,$new_event->start->mday,$new_event->start->year) - $this->datetime->tz_offset; } for($i=0;$idatetime = CreateObject('phpgwapi.datetime'); $this->db = $phpgw->db; $this->users['user'] = $phpgw_info['user']['preferences']['calendar']['locale']; $owner_id = get_account_id($owner); @@ -150,14 +151,14 @@ class calendar_holiday { if($holiday['occurence'] != 99) { - $dow = $phpgw->calendar->day_of_week($this->year,$holiday['month'],1); + $dow = $this->datetime->day_of_week($this->year,$holiday['month'],1); $day = (7 * $holiday['occurence'] - 6 + ($holiday['dow'] - $dow) % 7); $day += ($day < 1 ? 7 : 0); } else { - $ld = $phpgw->calendar->days_in_month($holiday['month'],$this->year); - $dow = $phpgw->calendar->day_of_week($this->year,$holiday['month'],$ld); + $ld = $this->datetime->days_in_month($holiday['month'],$this->year); + $dow = $this->datetime->day_of_week($this->year,$holiday['month'],$ld); $day = $ld - ($dow - $holiday['dow']) % 7 ; } } @@ -166,7 +167,7 @@ class calendar_holiday $day = $holiday['day']; if($holiday['observance_rule'] == True) { - $dow = $phpgw->calendar->day_of_week($this->year,$holiday['month'],$day); + $dow = $this->datetime->day_of_week($this->year,$holiday['month'],$day); // This now calulates Observed holidays and creates a new entry for them. if($dow == 0) { @@ -177,7 +178,7 @@ class calendar_holiday $this->holidays[$i]['month'] = $holiday['month']; $this->holidays[$i]['occurence'] = $holiday['occurence']; $this->holidays[$i]['dow'] = $holiday['dow']; - $this->holidays[$i]['date'] = mktime(0,0,0,$holiday['month'],$day+1,$this->year) - $this->tz_offset; + $this->holidays[$i]['date'] = mktime(0,0,0,$holiday['month'],$day+1,$this->year) - $this->datetime->tz_offset; $this->holidays[$i]['obervance_rule'] = 0; // echo 'Calculating for year('.$this->year.') month('.$this->holidays[$i]['month'].') dow('.$this->holidays[$i]['dow'].') occurence('.$this->holidays[$i]['occurence'].') datetime('.$this->holidays[$i]['date'].') DATE('.date('Y.m.d H:i:s',$this->holidays[$i]['date']).')
'."\n"; } @@ -190,13 +191,13 @@ class calendar_holiday $this->holidays[$i]['month'] = $holiday['month']; $this->holidays[$i]['occurence'] = $holiday['occurence']; $this->holidays[$i]['dow'] = $holiday['dow']; - $this->holidays[$i]['date'] = mktime(0,0,0,$holiday['month'],$day-1,$this->year) - $this->tz_offset; + $this->holidays[$i]['date'] = mktime(0,0,0,$holiday['month'],$day-1,$this->year) - $this->datetime->tz_offset; $this->holidays[$i]['obervance_rule'] = 0; // echo 'Calculating for year('.$this->year.') month('.$this->holidays[$i]['month'].') dow('.$this->holidays[$i]['dow'].') occurence('.$this->holidays[$i]['occurence'].') datetime('.$this->holidays[$i]['date'].') DATE('.date('Y.m.d H:i:s',$this->holidays[$i]['date']).')
'."\n"; } } } - $datetime = mktime(0,0,0,$holiday['month'],$day,$this->year) - $this->tz_offset; + $datetime = mktime(0,0,0,$holiday['month'],$day,$this->year) - $this->datetime->tz_offset; // echo 'Calculating for year('.$this->year.') month('.$holiday['month'].') dow('.$holiday['dow'].') occurence('.$holiday['occurence'].') datetime('.$datetime.') DATE('.date('Y.m.d H:i:s',$datetime).')
'."\n"; return $datetime; } @@ -206,7 +207,6 @@ class calendar_holiday global $phpgw; $this->year = intval($phpgw->calendar->tempyear); - $this->tz_offset = intval($phpgw->calendar->tz_offset); $sql = $this->build_holiday_query(); $this->holidays = Null; diff --git a/calendar/inc/class.calendar_icap.inc.php b/calendar/inc/class.calendar_icap.inc.php index fc1c1e9f9d..4ad281c989 100755 --- a/calendar/inc/class.calendar_icap.inc.php +++ b/calendar/inc/class.calendar_icap.inc.php @@ -46,8 +46,6 @@ class calendar_ extends calendar__ { $this->stream = mcal_open('{'.$phpgw_info['server']['icap_server'].'/'.$phpgw_info['server']['icap_type'].'}'.$calendar,$this->user,$passwd); } - - return $this->stream; } function popen($calendar='',$user='',$passwd='',$options='') @@ -74,8 +72,6 @@ class calendar_ extends calendar__ { $this->stream = mcal_popen('{'.$phpgw_info['server']['icap_server'].'/'.$phpgw_info['server']['icap_type'].'}'.$calendar,$this->user,$passwd); } - - return $this->stream; } function reopen($calendar,$options='') @@ -88,38 +84,36 @@ class calendar_ extends calendar__ { $this->stream = mcal_reopen($calendar); } - - return $this->stream; } - function close($mcal_stream,$options='') + function close($options='') { if($options != '') { - return mcal_close($mcal_stream,$options); + return mcal_close($this->stream,$options); } else { - return mcal_close($mcal_stream); + return mcal_close($this->stream); } } - function create_calendar($stream,$calendar) + function create_calendar($calendar) { - return mcal_create_calendar($stream,$calendar); + return mcal_create_calendar($this->stream,$calendar); } - function rename_calendar($stream,$old_name,$new_name) + function rename_calendar($old_name,$new_name) { - return mcal_rename_calendar($stream,$old_name,$new_name); + return mcal_rename_calendar($this->stream,$old_name,$new_name); } - function delete_calendar($stream,$calendar) + function delete_calendar($calendar) { - return mcal_delete_calendar($stream,$calendar); + return mcal_delete_calendar($this->stream,$calendar); } - function fetch_event($mcal_stream,$event_id,$options='') + function fetch_event($event_id,$options='') { if(!isset($this->stream)) { @@ -130,11 +124,11 @@ class calendar_ extends calendar__ if($options != '') { - $this->event = mcal_fetch_event($mcal_stream,$event_id,$options); + $this->event = mcal_fetch_event($this->stream,$event_id,$options); } else { - $this->event = mcal_fetch_event($mcal_stream,$event_id); + $this->event = mcal_fetch_event($this->stream,$event_id); } // Need to load the $this->event variable with the $event structure from @@ -145,41 +139,41 @@ class calendar_ extends calendar__ return $this->event; } - function list_events($mcal_stream,$startYear,$startMonth,$startDay,$endYear='',$endMonth='',$endYear='') + function list_events($startYear,$startMonth,$startDay,$endYear='',$endMonth='',$endYear='') { if($endYear != '' && $endMonth != '' && $endDay != '') { - $events = mcal_list_events($mcal_stream,$startYear,$startMonth,$startDay,$endYear,$endMonth,$endYear); + $events = mcal_list_events($this->stream,$startYear,$startMonth,$startDay,$endYear,$endMonth,$endYear); } else { - $events = mcal_list_events($mcal_stream,$startYear,$startMonth,$startDay); + $events = mcal_list_events($this->stream,$startYear,$startMonth,$startDay); } - return $events; + return $events; } - function append_event($mcal_stream) + function append_event() { - return mcal_append_event($mcal_stream); + return mcal_append_event($this->stream); } - function store_event($mcal_stream) + function store_event() { - return mcal_store_event($mcal_stream); + return mcal_store_event($this->stream); } - function delete_event($mcal_stream,$event_id) + function delete_event($event_id) { - return mcal_delete_event($mcal_stream,$event_id); + return mcal_delete_event($this->stream,$event_id); } - function snooze($mcal_stream,$event_id) + function snooze($event_id) { - return mcal_snooze($mcal_stream,$event_id); + return mcal_snooze($this->stream,$event_id); } - function list_alarms($mcal_stream,$begin_year='',$begin_month='',$begin_day='',$end_year='',$end_month='',$end_day='') + function list_alarms($begin_year='',$begin_month='',$begin_day='',$end_year='',$end_month='',$end_day='') { if($end_day == '') { @@ -193,64 +187,64 @@ class calendar_ extends calendar__ { if($begin_year == '') { - return mcal_list_alarms($mcal_stream); + return mcal_list_alarms($this->stream); } else { - return mcal_list_alarms($mcal_stream,$begin_year); + return mcal_list_alarms($this->stream,$begin_year); } } else { - return mcal_list_alarms($mcal_stream,$begin_year,$begin_month); + return mcal_list_alarms($this->stream,$begin_year,$begin_month); } } else { - return mcal_list_alarms($mcal_stream,$begin_year,$begin_month,$begin_day); + return mcal_list_alarms($this->stream,$begin_year,$begin_month,$begin_day); } } else { - return mcal_list_alarms($mcal_stream,$begin_year,$begin_month,$begin_day,$end_year); + return mcal_list_alarms($this->stream,$begin_year,$begin_month,$begin_day,$end_year); } } else { - return mcal_list_alarms($mcal_stream,$begin_year,$begin_month,$begin_day,$end_year,$end_month); + return mcal_list_alarms($this->stream,$begin_year,$begin_month,$begin_day,$end_year,$end_month); } } else { - return mcal_list_alarms($mcal_stream,$begin_year,$begin_month,$begin_day,$end_year,$end_month,$end_day); + return mcal_list_alarms($this->stream,$begin_year,$begin_month,$begin_day,$end_year,$end_month,$end_day); } } - function event_init($stream) + function event_init() { $this->event = CreateObject('calendar.calendar_item'); - return mcal_event_init($stream); + return mcal_event_init($this->stream); } - function event_set_category($stream,$category='') + function event_set_category($category='') { $this->event->category = $category; - return mcal_event_set_category($stream,$this->event->category); + return mcal_event_set_category($this->stream,$this->event->category); } - function event_set_title($stream,$title='') + function event_set_title($title='') { $this->event->title = $title; - return mcal_event_set_title($stream,$this->event->title); + return mcal_event_set_title($this->stream,$this->event->title); } - function event_set_description($stream,$description='') + function event_set_description($description='') { $this->event->description = $description; - return mcal_event_set_description($stream,$this->event->description); + return mcal_event_set_description($this->stream,$this->event->description); } - function event_set_start($stream,$year,$month,$day=0,$hour=0,$min=0,$sec=0) + function event_set_start($year,$month,$day=0,$hour=0,$min=0,$sec=0) { // Legacy Support $this->event->year = $year; @@ -276,30 +270,30 @@ class calendar_ extends calendar__ { if($day == 0) { - return mcal_event_set_start($stream,$year,$month); + return mcal_event_set_start($this->stream,$year,$month); } else { - return mcal_event_set_start($stream,$year,$month,$day); + return mcal_event_set_start($this->stream,$year,$month,$day); } } else { - return mcal_event_set_start($stream,$year,$month,$day,$hour); + return mcal_event_set_start($this->stream,$year,$month,$day,$hour); } } else { - return mcal_event_set_start($stream,$year,$month,$day,$hour,$min); + return mcal_event_set_start($this->stream,$year,$month,$day,$hour,$min); } } else { - return mcal_event_set_start($stream,$year,$month,$day,$hour,$min,$sec); + return mcal_event_set_start($this->stream,$year,$month,$day,$hour,$min,$sec); } } - function event_set_end($stream,$year,$month,$day=0,$hour=0,$min=0,$sec=0) + function event_set_end($year,$month,$day=0,$hour=0,$min=0,$sec=0) { // Legacy Support $this->event->end_year = $year; @@ -327,38 +321,38 @@ class calendar_ extends calendar__ { if($day == 0) { - return mcal_event_set_end($stream,$year,$month); + return mcal_event_set_end($this->stream,$year,$month); } else { - return mcal_event_set_end($stream,$year,$month,$day); + return mcal_event_set_end($this->stream,$year,$month,$day); } } else { - return mcal_event_set_end($stream,$year,$month,$day,$hour); + return mcal_event_set_end($this->stream,$year,$month,$day,$hour); } } else { - return mcal_event_set_end($stream,$year,$month,$day,$hour,$min); + return mcal_event_set_end($this->stream,$year,$month,$day,$hour,$min); } } else { - return mcal_event_set_end($stream,$year,$month,$day,$hour,$min,$sec); + return mcal_event_set_end($this->stream,$year,$month,$day,$hour,$min,$sec); } } - function event_set_alarm($stream,$alarm) + function event_set_alarm($alarm) { - return mcal_event_set_alarm ($stream,$alarm); + return mcal_event_set_alarm ($this->stream,$alarm); } - function event_set_class($stream,$class) + function event_set_class($class) { $this->event->public = $class; - return mcal_event_set_class($stream,$class); + return mcal_event_set_class($this->stream,$class); } function is_leap_year($year) @@ -398,59 +392,59 @@ class calendar_ extends calendar__ // The function definition doesn't look correct... // Need more information for this function - function next_recurrence($stream,$weekstart,$next) + function next_recurrence($weekstart,$next) { - return mcal_next_recurrence($stream,$weekstart,$next); + return mcal_next_recurrence($this->stream,$weekstart,$next); } - function event_set_recur_none($stream) + function event_set_recur_none() { - return mcal_event_set_recur_none($stream); + return mcal_event_set_recur_none($this->stream); } - function event_set_recur_daily($stream,$year,$month,$day,$interval) + function event_set_recur_daily($year,$month,$day,$interval) { - return mcal_event_set_recur_daily($stream,$year,$month,$day,$interval); + return mcal_event_set_recur_daily($this->stream,$year,$month,$day,$interval); } - function event_set_recur_weekly($stream,$year,$month,$day,$interval,$weekdays) + function event_set_recur_weekly($year,$month,$day,$interval,$weekdays) { - return mcal_event_set_recur_weekly($stream,$year,$month,$day,$interval,$weekdays); + return mcal_event_set_recur_weekly($this->stream,$year,$month,$day,$interval,$weekdays); } - function event_set_recur_monthly_mday($stream,$year,$month,$day,$interval) + function event_set_recur_monthly_mday($year,$month,$day,$interval) { - return mcal_event_set_recur_monthly_mday($stream,$year,$month,$day,$interval); + return mcal_event_set_recur_monthly_mday($this->stream,$year,$month,$day,$interval); } - function event_set_recur_monthly_wday($stream,$year,$month,$day,$interval) + function event_set_recur_monthly_wday($year,$month,$day,$interval) { - return mcal_event_set_recur_monthly_wday($stream,$year,$month,$day,$interval); + return mcal_event_set_recur_monthly_wday($this->stream,$year,$month,$day,$interval); } - function event_set_recur_yearly($stream,$year,$month,$day,$interval) + function event_set_recur_yearly($year,$month,$day,$interval) { - return mcal_event_set_recur_yearly($stream,$year,$month,$day,$interval); + return mcal_event_set_recur_yearly($this->stream,$year,$month,$day,$interval); } - function fetch_current_stream_event($stream) + function fetch_current_stream_event() { - return mcal_fetch_current_stream_event($stream); + return mcal_fetch_current_stream_event($this->stream); } - function event_add_attribute($stream,$attribute,$value) + function event_add_attribute($attribute,$value) { - mcal_event_add_attribute($stream,$attribute,$value); + mcal_event_add_attribute($this->stream,$attribute,$value); } - function expunge($stream) + function expunge() { - return mcal_expunge($stream); + return mcal_expunge($this->stream); } /**************** Local functions for ICAL based Calendar *****************/ - function event_set_participants($stream,$participants) + function event_set_participants($participants) { $this->event->participants = Array(); reset($participants); diff --git a/calendar/inc/class.calendar_sql.inc.php b/calendar/inc/class.calendar_sql.inc.php index e698b50116..999548275a 100755 --- a/calendar/inc/class.calendar_sql.inc.php +++ b/calendar/inc/class.calendar_sql.inc.php @@ -14,8 +14,7 @@ /* $Id$ */ -if (isset($phpgw_info['flags']['included_classes']['calendar_']) && - $phpgw_info['flags']['included_classes']['calendar_'] == True) +if (@$phpgw_info['flags']['included_classes']['calendar_']) { return; } @@ -61,31 +60,31 @@ class calendar_ extends calendar__ return $this->stream; } - function close($mcal_stream,$options='') + function close($options='') { return True; } - function create_calendar($stream='',$calendar='') + function create_calendar($calendar='') { return $calendar; } - function rename_calendar($stream='',$old_name='',$new_name='') + function rename_calendar($old_name='',$new_name='') { return $new_name; } - function delete_calendar($stream='',$calendar='') + function delete_calendar($calendar='') { $this->stream->query('SELECT cal_id FROM phpgw_cal WHERE owner='.intval($calendar),__LINE__,__FILE__); if($this->stream->num_rows()) { while($this->stream->next_record()) { - $this->delete_event($stream,intval($this->stream->f('cal_id'))); + $this->delete_event(intval($this->stream->f('cal_id'))); } - $this->expunge($stream); + $this->expunge(); } $this->stream->lock(array('phpgw_cal_user')); $this->stream->query('DELETE FROM phpgw_cal_user WHERE cal_login='.intval($calendar),__LINE__,__FILE__); @@ -94,7 +93,7 @@ class calendar_ extends calendar__ return $calendar; } - function fetch_event($mcal_stream,$event_id,$options='') + function fetch_event($event_id,$options='') { global $phpgw; @@ -133,7 +132,7 @@ class calendar_ extends calendar__ $this->event->alarm = 0; $this->event->datetime = $this->stream->f('datetime'); - $datetime = $this->localdates($this->stream->f('datetime')); + $datetime = $this->datetime->localdates($this->stream->f('datetime')); $this->event->start->year = $datetime['year']; $this->event->start->month = $datetime['month']; $this->event->start->mday = $datetime['day']; @@ -143,7 +142,7 @@ class calendar_ extends calendar__ $this->event->start->alarm = 0; $this->event->mdatetime = $this->stream->f('mdatetime'); - $datetime = $this->localdates($this->stream->f('mdatetime')); + $datetime = $this->datetime->localdates($this->stream->f('mdatetime')); $this->event->mod->year = $datetime['year']; $this->event->mod->month = $datetime['month']; $this->event->mod->mday = $datetime['day']; @@ -153,7 +152,7 @@ class calendar_ extends calendar__ $this->event->mod->alarm = 0; $this->event->edatetime = $this->stream->f('edatetime'); - $datetime = $this->localdates($this->stream->f('edatetime')); + $datetime = $this->datetime->localdates($this->stream->f('edatetime')); $this->event->end->year = $datetime['year']; $this->event->end->month = $datetime['month']; $this->event->end->mday = $datetime['day']; @@ -183,7 +182,7 @@ class calendar_ extends calendar__ $enddate = $this->stream->f('recur_enddate'); if($enddate != 0 && $enddate != Null) { - $datetime = $this->localdates($enddate); + $datetime = $this->datetime->localdates($enddate); $this->event->recur_enddate->year = $datetime['year']; $this->event->recur_enddate->month = $datetime['month']; $this->event->recur_enddate->mday = $datetime['day']; @@ -230,19 +229,19 @@ class calendar_ extends calendar__ return $this->event; } - function list_events($mcal_stream,$startYear,$startMonth,$startDay,$endYear='',$endMonth='',$endYear='') + function list_events($startYear,$startMonth,$startDay,$endYear='',$endMonth='',$endYear='') { if(!isset($this->stream)) { return False; } - $datetime = $this->makegmttime(0,0,0,$startMonth,$startDay,$startYear); + $datetime = $this->datetime->makegmttime(0,0,0,$startMonth,$startDay,$startYear); $startDate = ' AND (phpgw_cal.datetime >= '.$datetime.') '; if($endYear != '' && $endMonth != '' && $endDay != '') { - $edatetime = $this->makegmttime(23,59,59,intval($endMonth),intval($endDay),intval($endYear)); + $edatetime = $this->datetime->makegmttime(23,59,59,intval($endMonth),intval($endDay),intval($endYear)); $endDate = 'AND (phpgw_cal.edatetime <= '.$edatetime.') '; } else @@ -253,19 +252,19 @@ class calendar_ extends calendar__ return $this->get_event_ids(False,$startDate.$endDate); } - function append_event($mcal_stream) + function append_event() { $this->save_event($this->event); $this->send_update(MSG_ADDED,$this->event->participants,'',$this->event); return $this->event->id; } - function store_event($mcal_stream) + function store_event() { if($this->event->id != 0) { $new_event = $this->event; - $old_event = $this->fetch_event($this->stream,$new_event->id); + $old_event = $this->fetch_event($new_event->id); $this->prepare_recipients($new_event,$old_event); $this->event = $new_event; } @@ -281,57 +280,50 @@ class calendar_ extends calendar__ return $this->save_event($this->event); } - function delete_event($mcal_stream,$event_id) + function delete_event($event_id) { $this->deleted_events[] = $event_id; } - function snooze($mcal_stream,$event_id) + function snooze($event_id) { //Turn off an alarm for an event //Returns true. } - function list_alarms($mcal_stream,$begin_year='',$begin_month='',$begin_day='',$end_year='',$end_month='',$end_day='') + function list_alarms($begin_year='',$begin_month='',$begin_day='',$end_year='',$end_month='',$end_day='') { //Return a list of events that has an alarm triggered at the given datetime //Returns an array of event ID's } - function event_init($stream) + function event_init() { $this->event = CreateObject('calendar.calendar_item'); $this->event->owner = $this->user; -// echo 'Initializing Calendar Event
'."\n"; -// echo 'Setting Owner = '.$this->event->owner."
\n"; return True; } - function event_set_category($stream,$category='') + function set_category($stream,$category='') { $this->event->category = $category; -// echo 'Setting Calendar Category = '.$this->event->category.'
'."\n"; return True; } - function event_set_title($stream,$title='') + function set_title($title='') { $this->event->title = $title; -// echo 'Setting Calendar Title = '.$this->event->title.'
'."\n"; return True; } - function event_set_description($stream,$description='') + function set_description($description='') { $this->event->description = $description; -// echo 'Setting Calendar Description = '.$this->event->description.'
'."\n"; return True; } - function event_set_start($stream,$year,$month,$day=0,$hour=0,$min=0,$sec=0) + function set_start($year,$month,$day=0,$hour=0,$min=0,$sec=0) { - global $phpgw_info; - $this->event->start->year = intval($year); $this->event->start->month = intval($month); $this->event->start->mday = intval($day); @@ -339,15 +331,11 @@ class calendar_ extends calendar__ $this->event->start->min = intval($min); $this->event->start->sec = intval($sec); $this->event->start->alarm = 0; - -// echo 'Setting Calendar Start = '.$this->event->start->year.$this->event->start->month.$this->event->start->mday.':'.$this->event->start->hour.$this->event->start->min.$this->event->start->sec.'
'."\n"; return True; } - function event_set_end($stream,$year,$month,$day=0,$hour=0,$min=0,$sec=0) + function set_end($year,$month,$day=0,$hour=0,$min=0,$sec=0) { - global $phpgw_info; - $this->event->end->year = intval($year); $this->event->end->month = intval($month); $this->event->end->mday = intval($day); @@ -355,119 +343,21 @@ class calendar_ extends calendar__ $this->event->end->min = intval($min); $this->event->end->sec = intval($sec); $this->event->end->alarm = 0; - -// echo 'Setting Calendar End = '.$this->event->end->year.$this->event->end->month.$this->event->end->mday.':'.$this->event->end->hour.$this->event->end->min.$this->event->end->sec.'
'."\n"; return True; } - function event_set_alarm($stream,$alarm) + function set_alarm($alarm) { $this->event->alarm = intval($alarm); return True; } - function event_set_class($stream,$class) + function set_class($class) { $this->event->public = $class; return True; } - function is_leap_year($year) - { - if ((intval($year) % 4 == 0) && (intval($year) % 100 != 0) || (intval($year) % 400 == 0)) - return 1; - else - return 0; - } - - function days_in_month($month,$year) - { - $days = Array( - 1 => 31, - 2 => 28 + $this->is_leap_year(intval($year)), - 3 => 31, - 4 => 30, - 5 => 31, - 6 => 30, - 7 => 31, - 8 => 31, - 9 => 30, - 10 => 31, - 11 => 30, - 12 => 31 - ); - return $days[intval($month)]; - } - - function date_valid($year,$month,$day) - { - return checkdate(intval($month),intval($day),intval($year)); - } - - function time_valid($hour,$minutes,$seconds) - { - if(intval($hour) < 0 || intval($hour) > 24) - { - return False; - } - if(intval($minutes) < 0 || intval($minutes) > 59) - { - return False; - } - if(intval($seconds) < 0 || intval($seconds) > 59) - { - return False; - } - - return True; - } - - function day_of_week($year,$month,$day) - { - if($month > 2) - { - $month -= 2; - } - else - { - $month += 10; - $year--; - } - $day = (floor((13 * $month - 1) / 5) + $day + ($year % 100) + floor(($year % 100) / 4) + floor(($year / 100) / 4) - 2 * floor($year / 100) + 77); - return (($day - 7 * floor($day / 7))); - } - - function day_of_year($year,$month,$day) - { - $days = array(0,31,59,90,120,151,181,212,243,273,304,334); - - $julian = ($days[$month - 1] + $day); - - if($month > 2 && $this->is_leap_year($year)) - { - $julian++; - } - return($julian); - } - - function date_compare($a_year,$a_month,$a_day,$b_year,$b_month,$b_day) - { - $a_date = mktime(0,0,0,intval($a_month),intval($a_day),intval($a_year)); - $b_date = mktime(0,0,0,intval($b_month),intval($b_day),intval($b_year)); - if($a_date == $b_date) - { - return 0; - } - elseif($a_date > $b_date) - { - return 1; - } - elseif($a_date < $b_date) - { - return -1; - } - } - // The function definition doesn't look correct... // Need more information for this function function next_recurrence($stream,$weekstart,$next) @@ -623,10 +513,9 @@ class calendar_ extends calendar__ $event->id = $this->stream->f('cal_id'); } - $tz_offset = ((60 * 60) * intval($phpgw_info['user']['preferences']['common']['tz_offset'])); - $date = mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year) - $tz_offset; - $enddate = mktime($event->end->hour,$event->end->min,$event->end->sec,$event->end->month,$event->end->mday,$event->end->year) - $tz_offset; - $today = time() - $tz_offset; + $date = mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year) - $this->datetime->tz_offset; + $enddate = mktime($event->end->hour,$event->end->min,$event->end->sec,$event->end->month,$event->end->mday,$event->end->year) - $this->datetime->tz_offset; + $today = time() - $this->datetime->tz_offset; if($event->recur_type != RECUR_NONE) { @@ -679,7 +568,7 @@ class calendar_ extends calendar__ { if($event->recur_enddate->month != 0 && $event->recur_enddate->mday != 0 && $event->recur_enddate->year != 0) { - $end = mktime($event->recur_enddate->hour,$event->recur_enddate->min,$event->recur_enddate->sec,$event->recur_enddate->month,$event->recur_enddate->mday,$event->recur_enddate->year) - $tz_offset; + $end = mktime($event->recur_enddate->hour,$event->recur_enddate->min,$event->recur_enddate->sec,$event->recur_enddate->month,$event->recur_enddate->mday,$event->recur_enddate->year) - $this->datetime->tz_offset; } else { @@ -834,42 +723,6 @@ class calendar_ extends calendar__ return $temp; } - function makegmttime($hour,$minute,$second,$month,$day,$year) - { - global $phpgw, $phpgw_info; - - return $this->gmtdate(mktime($hour, $minute, $second, $month, $day, $year)); - } - - function localdates($localtime) - { - global $phpgw, $phpgw_info; - - $date = Array('raw','day','month','year','full','dow','dm','bd'); - $date['raw'] = $localtime; - $date['year'] = intval($phpgw->common->show_date($date['raw'],'Y')); - $date['month'] = intval($phpgw->common->show_date($date['raw'],'m')); - $date['day'] = intval($phpgw->common->show_date($date['raw'],'d')); - $date['full'] = intval($phpgw->common->show_date($date['raw'],'Ymd')); - $date['bd'] = mktime(0,0,0,$date['month'],$date['day'],$date['year']); - $date['dm'] = intval($phpgw->common->show_date($date['raw'],'dm')); - $date['dow'] = $this->day_of_week($date['year'],$date['month'],$date['day']); - $date['hour'] = intval($phpgw->common->show_date($date['raw'],'H')); - $date['minute'] = intval($phpgw->common->show_date($date['raw'],'i')); - $date['second'] = intval($phpgw->common->show_date($date['raw'],'s')); - - return $date; - } - - function gmtdate($localtime) - { - global $phpgw_info; - - $localtime -= ((60 * 60) * intval($phpgw_info['user']['preferences']['common']['tz_offset'])); - - return $this->localdates($localtime); - } - function date_to_epoch($d) { return $this->localdates(mktime(0,0,0,intval(substr($d,4,2)),intval(substr($d,6,2)),intval(substr($d,0,4)))); diff --git a/calendar/inc/footer.inc.php b/calendar/inc/footer.inc.php index c34b163f0a..a50f0f560a 100644 --- a/calendar/inc/footer.inc.php +++ b/calendar/inc/footer.inc.php @@ -130,8 +130,8 @@ // } unset($thisdate); - $thisdate = $phpgw->calendar->makegmttime(0,0,0,$m,$d,$y); - $sun = $phpgw->calendar->get_weekday_start($y,$m,$d) - $phpgw->calendar->tz_offset - 7200; + $thisdate = $phpgw->calendar->datetime->makegmttime(0,0,0,$m,$d,$y); + $sun = $phpgw->calendar->datetime->get_weekday_start($y,$m,$d) - $phpgw->calendar->datetime->tz_offset - 7200; $str = ''; diff --git a/calendar/week.php b/calendar/week.php index ff486cbdee..0144ae03ed 100755 --- a/calendar/week.php +++ b/calendar/week.php @@ -39,14 +39,14 @@ $phpgw_info['flags'] = $phpgw_flags; include('../header.inc.php'); - $next = $phpgw->calendar->makegmttime(0,0,0,$thismonth,$thisday + 7,$thisyear); - $prev = $phpgw->calendar->makegmttime(0,0,0,$thismonth,$thisday - 7,$thisyear); + $next = $phpgw->calendar->datetime->makegmttime(0,0,0,$thismonth,$thisday + 7,$thisyear); + $prev = $phpgw->calendar->datetime->makegmttime(0,0,0,$thismonth,$thisday - 7,$thisyear); - $nextmonth = $phpgw->calendar->makegmttime(0,0,0,$thismonth + 1,1,$thisyear); - $prevmonth = $phpgw->calendar->makegmttime(0,0,0,$thismonth - 1,1,$thisyear); + $nextmonth = $phpgw->calendar->datetime->makegmttime(0,0,0,$thismonth + 1,1,$thisyear); + $prevmonth = $phpgw->calendar->datetime->makegmttime(0,0,0,$thismonth - 1,1,$thisyear); - $first = $phpgw->calendar->gmtdate($phpgw->calendar->get_weekday_start($thisyear, $thismonth, $thisday)); - $last = $phpgw->calendar->gmtdate($first['raw'] + 518400); + $first = $phpgw->calendar->datetime->gmtdate($phpgw->calendar->datetime->get_weekday_start($thisyear, $thismonth, $thisday)); + $last = $phpgw->calendar->datetime->gmtdate($first['raw'] + 518400); // Week Label $week_id = lang(strftime("%B",$first['raw'])).' '.$first['day'];