From bc4362c22e194d09135d5ed23cfde00aa45493f4 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 2 May 2016 20:22:47 +0000 Subject: [PATCH] remove old phpgwapi datetime class from calendar, as it is no longer in api --- calendar/inc/class.calendar_bo.inc.php | 9 +----- calendar/inc/class.calendar_ui.inc.php | 7 ----- calendar/inc/class.calendar_uilist.inc.php | 5 ++-- calendar/inc/class.calendar_uiviews.inc.php | 31 +++++++++++---------- 4 files changed, 21 insertions(+), 31 deletions(-) diff --git a/calendar/inc/class.calendar_bo.inc.php b/calendar/inc/class.calendar_bo.inc.php index 46e3a8eccf..cec93c440f 100644 --- a/calendar/inc/class.calendar_bo.inc.php +++ b/calendar/inc/class.calendar_bo.inc.php @@ -194,12 +194,6 @@ class calendar_bo * @var calendar_so */ var $so; - /** - * Instance of the datetime class - * - * @var egw_datetime - */ - var $datetime; /** * Instance of the categories class * @@ -229,7 +223,6 @@ class calendar_bo if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started',True); $this->so = new calendar_so(); - $this->datetime = $GLOBALS['egw']->datetime; $this->common_prefs =& $GLOBALS['egw_info']['user']['preferences']['common']; $this->cal_prefs =& $GLOBALS['egw_info']['user']['preferences']['calendar']; @@ -1835,7 +1828,7 @@ class calendar_bo * @param type $event * @return array array of selected calendar fields */ - function get_link_options ($event = array()) + public static function get_link_options ($event = array()) { unset($event); // not used, but required by function signature $options = array ( diff --git a/calendar/inc/class.calendar_ui.inc.php b/calendar/inc/class.calendar_ui.inc.php index 842888fe45..3d40658fff 100644 --- a/calendar/inc/class.calendar_ui.inc.php +++ b/calendar/inc/class.calendar_ui.inc.php @@ -46,12 +46,6 @@ class calendar_ui * @var jscalendar */ var $jscal; - /** - * Reference to global datetime class - * - * @var egw_datetime - */ - var $datetime; /** * Instance of Api\Categories class * @@ -151,7 +145,6 @@ class calendar_ui { $this->bo = new calendar_bo(); } - $this->datetime = $GLOBALS['egw']->datetime; $this->categories = new Api\Categories($this->user,'calendar'); diff --git a/calendar/inc/class.calendar_uilist.inc.php b/calendar/inc/class.calendar_uilist.inc.php index e15cc1eabd..536717702e 100644 --- a/calendar/inc/class.calendar_uilist.inc.php +++ b/calendar/inc/class.calendar_uilist.inc.php @@ -324,8 +324,9 @@ class calendar_uilist extends calendar_ui $this->last = $search_params['end'] = $today->format('ts'); break; case 'week': - $start = $this->bo->date2array($params['date'] ? $params['date'] : $this->date); - $this->first = $this->datetime->get_weekday_start($start['year'],$start['month'],$start['day']); + $start = new Api\DateTime($params['date'] ? $params['date'] : $this->date); + $start->setWeekstart(); + $this->first = $start->format('ts'); $this->last = $this->bo->date2array($this->first); $this->last['day'] += ($params['weekend'] == 'true' ? 7 : 5) - 1; $this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59; diff --git a/calendar/inc/class.calendar_uiviews.inc.php b/calendar/inc/class.calendar_uiviews.inc.php index 093b110450..c3046ddbc5 100644 --- a/calendar/inc/class.calendar_uiviews.inc.php +++ b/calendar/inc/class.calendar_uiviews.inc.php @@ -438,7 +438,9 @@ class calendar_uiviews extends calendar_ui } elseif ($this->planner_view == 'week' || $this->planner_view == 'weekN') // weeekview { - $this->first = $this->datetime->get_weekday_start($this->year,$this->month,$this->day); + $start = new Api\DateTime($this->date); + $start->setWeekstart(); + $this->first = $start->format('ts'); $this->last = $this->bo->date2array($this->first); $this->last['day'] += ($this->planner_view == 'week' ? 7 : 7 * $this->cal_prefs['multiple_weeks'])-1; $this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59; @@ -527,7 +529,9 @@ class calendar_uiviews extends calendar_ui if ($weeks) { - $this->first = $this->datetime->get_weekday_start($this->year,$this->month,$this->day); + $start = new Api\DateTime($this->date); + $start->setWeekstart(); + $this->first = $start->format('ts'); $this->last = strtotime("+$weeks weeks",$this->first) - 1; $weekNavH = "$weeks weeks"; $navHeader = lang('Week').' '.$this->week_number($this->first).' - '.$this->week_number($this->last).': '. @@ -579,19 +583,16 @@ class calendar_uiviews extends calendar_ui */ function _week_align_month(&$first,&$last,$day=1) { - $first = $this->datetime->get_weekday_start($this->year,$this->month,$this->day=$day); - if ($day == 1) - { - $last = $this->datetime->get_weekday_start($this->year,$this->month, - $this->datetime->days_in_month($this->month,$this->year)); - } - else - { - $last = $this->datetime->get_weekday_start($this->year,$this->month+1,$day); - } + $start = new Api\DateTime($this->date); + $start->setDate($this->year,$this->month,$this->day=$day); + $start->setWeekstart(); + $first = $start->format('ts'); + $start->setDate($this->year,$this->month+1,$day); + if ($day == 1) $start->add('-1day'); + $start->setWeekstart(); // now we need to calculate the end of the last day of that week // as simple $last += WEEK_s - 1; does NOT work, if daylight saving changes in that week!!! - $arr = $this->bo->date2array($last); + $arr = $start->format('array'); $arr['day'] += 6; $arr['hour'] = 23; $arr['min'] = $arr['sec'] = 59; @@ -628,7 +629,9 @@ class calendar_uiviews extends calendar_ui } else { - $wd_start = $this->first = $this->datetime->get_weekday_start($this->year,$this->month,$this->day); + $start = new Api\DateTime($this->date); + $start->setWeekstart(); + $wd_start = $this->first = $start->format('ts'); if ($days <= 5) // no weekend-days { switch($this->cal_prefs['weekdaystarts'])