From 72115c0ae453082effb6a10fd40b9d7649634001 Mon Sep 17 00:00:00 2001 From: Christian Binder Date: Tue, 7 Oct 2008 08:57:09 +0000 Subject: [PATCH] added saving states to user prefs in calendar. the only saved state until now is owner, but this can be simply extended in future. --- calendar/inc/class.calendar_ui.inc.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/calendar/inc/class.calendar_ui.inc.php b/calendar/inc/class.calendar_ui.inc.php index f153822aa1..f24d3f2d03 100644 --- a/calendar/inc/class.calendar_ui.inc.php +++ b/calendar/inc/class.calendar_ui.inc.php @@ -119,6 +119,11 @@ class calendar_ui * @var int $last last day of the shown view */ var $last; + + /** + * @var array $states_to_save all states that will be saved to the user prefs + */ + var $states_to_save = array('owner'); /** * Constructor @@ -247,6 +252,12 @@ class calendar_ui function manage_states($set_states=NULL) { $states = $states_session = $GLOBALS['egw']->session->appsession('session_data','calendar'); + + // retrieve saved states from prefs + if(!$states) + { + $states = unserialize($this->bo->cal_prefs['saved_states']); + } if (is_null($set_states)) { @@ -367,6 +378,13 @@ class calendar_ui if ($this->debug > 0 || $this->debug == 'manage_states') $this->bo->debug_message('uical::manage_states(%1) session was %2, states now %3',True,$set_states,$states_session,$states); // save the states in the session $GLOBALS['egw']->session->appsession('session_data','calendar',$states); + // save defined states into the user-prefs + if(!empty($states) && is_array($states)) + { + $saved_states = array_intersect_key($states,array_flip($this->states_to_save)); + $GLOBALS['egw']->preferences->add('calendar','saved_states',serialize($saved_states)); + $GLOBALS['egw']->preferences->save_repository(false,'user',false); + } } /**