From 4fef26e9261f64781b5ec4b1771820d7d1bdefb1 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 14 Jun 2011 18:46:03 +0000 Subject: [PATCH] * Calendar: warning if user tries to move horizont further then default 1000 days and NOT start moving horizont, to allow adding events after the horizont --- calendar/inc/class.calendar_bo.inc.php | 25 +++++++++++++++++-------- calendar/inc/class.calendar_ui.inc.php | 15 ++++++++------- calendar/lang/egw_de.lang | 1 + calendar/lang/egw_en.lang | 1 + 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/calendar/inc/class.calendar_bo.inc.php b/calendar/inc/class.calendar_bo.inc.php index c91b37ba6e..b6a5969f9d 100644 --- a/calendar/inc/class.calendar_bo.inc.php +++ b/calendar/inc/class.calendar_bo.inc.php @@ -187,6 +187,13 @@ class calendar_bo */ public $calview_no_consolidate = 5; + /** + * Warnings to show in regular UI + * + * @var array + */ + var $warnings = array(); + /** * Constructor */ @@ -648,13 +655,13 @@ class calendar_bo { if ((int) $this->debug >= 2 || $this->debug == 'check_move_horizont') { - $this->debug_message('bocal::check_move_horizont(%1) horizont=%2',true,$new_horizont,$this->config['horizont']); + $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2',true,$new_horizont,(int)$this->config['horizont']); } $new_horizont = $this->date2ts($new_horizont,true); // now we are in server-time, where this function operates if ($new_horizont <= $this->config['horizont']) // no move necessary { - if ($this->debug == 'check_move_horizont') $this->debug_message('bocal::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do',true,$new_horizont,$this->config['horizont']); + if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do',true,$new_horizont,(int)$this->config['horizont']); return; } if (!empty($GLOBALS['egw_info']['server']['calendar_horizont'])) @@ -664,8 +671,9 @@ class calendar_bo if (empty($maxdays)) $maxdays = 1000; // old default if ($new_horizont > time()+$maxdays*DAY_s) // some user tries to "look" more then the maximum number of days in the future { - if ($this->debug == 'check_move_horizont') $this->debug_message('bocal::check_move_horizont(%1) horizont=%2 new horizont more then 1000 days from now --> ignoring it',true,$new_horizont,$this->config['horizont']); - $new_horizont = time()+$maxdays*DAY_s; + if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it',true,$new_horizont,(int)$this->config['horizont'],$maxdays); + $this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', egw_time::to($new_horizont,true), $maxdays); + return; } if ($new_horizont < time()+31*DAY_s) { @@ -677,6 +685,7 @@ class calendar_bo // create further recurrences for all recurring and not yet (at the old horizont) ended events if (($recuring = $this->so->unfinished_recuring($old_horizont))) { + @set_time_limit(0); // disable time-limit, in case it takes longer to calculate the recurrences foreach($this->read(array_keys($recuring)) as $cal_id => $event) { if ($this->debug == 'check_move_horizont') @@ -688,10 +697,9 @@ class calendar_bo } } // update the horizont - $config = CreateObject('phpgwapi.config','calendar'); - $config->save_value('horizont',$this->config['horizont'],'calendar'); + config::save_value('horizont',$this->config['horizont'],'calendar'); - if ($this->debug == 'check_move_horizont') $this->debug_message('bocal::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,$this->config['horizont']); + if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']); } /** @@ -942,7 +950,8 @@ class calendar_bo if (!$event['recur_enddate'] || $this->date2ts($event['recur_enddate']) > $this->date2ts($end)) { //echo "

recur_enddate={$event['recur_enddate']}=".egw_time::to($event['recur_enddate'])." > end=$end=".egw_time::to($end)." --> using end instead of recur_enddate

\n"; - $event['recur_enddate'] = $end; + // insert at least the event itself, if it's behind the horizont + $event['recur_enddate'] = $this->date2ts($end) < $this->date2ts($event['end']) ? $event['end'] : $end; } // loop over all recurrences and insert them, if they are after $start $rrule = calendar_rrule::event2rrule($event, true); // true = we operate in usertime, like the rest of calendar_bo diff --git a/calendar/inc/class.calendar_ui.inc.php b/calendar/inc/class.calendar_ui.inc.php index 4c01209a27..b4bfcf30c5 100644 --- a/calendar/inc/class.calendar_ui.inc.php +++ b/calendar/inc/class.calendar_ui.inc.php @@ -202,17 +202,17 @@ class calendar_ui { return $msg; } - $GLOBALS['egw']->common->egw_header(); + common::egw_header(); if ($GLOBALS['egw_info']['flags']['nonavbar']) parse_navbar(); echo $msg; - $GLOBALS['egw']->common->egw_footer(); - $GLOBALS['egw']->common->egw_exit(); + common::egw_footer(); + common::egw_exit(); } if (count($no_access_group)) { - $this->group_warning = lang('Groupmember(s) %1 not included, because you have no access.',implode(', ',$no_access_group)); + $this->bo->warnings['groupmembers'] = lang('Groupmember(s) %1 not included, because you have no access.',implode(', ',$no_access_group)); } return false; } @@ -223,11 +223,11 @@ class calendar_ui function do_header() { $GLOBALS['egw_info']['flags']['include_xajax'] = true; - $GLOBALS['egw']->common->egw_header(); + common::egw_header(); if ($_GET['msg']) echo '

'.html::htmlspecialchars($_GET['msg'])."

\n"; - if ($this->group_warning) echo '

'.$this->group_warning."

\n"; + if ($this->bo->warnings) echo '

'.implode('
',$this->bo->warnings)."

\n"; } /** @@ -717,7 +717,8 @@ class calendar_ui // Add in deleted for admins $config = config::read('phpgwapi'); - if($config['calendar_delete_history'] && $GLOBALS['egw_info']['user']['apps']['admin']) { + if($config['calendar_delete_history']) + { $options .= '