From 7744905ba83ebc49e73e31b6a0a2934eb1a1daf5 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Fri, 30 Aug 2013 12:57:51 +0000 Subject: [PATCH] try to resolve a use-session-stored-data related problem; make sure account_id and prefs are restored after send_notification --- etemplate/inc/class.bo_tracking.inc.php | 24 +++++++++++++++++------- phpgwapi/inc/class.send.inc.php | 8 +++++--- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/etemplate/inc/class.bo_tracking.inc.php b/etemplate/inc/class.bo_tracking.inc.php index 8f8758929e..09e5f43e60 100644 --- a/etemplate/inc/class.bo_tracking.inc.php +++ b/etemplate/inc/class.bo_tracking.inc.php @@ -690,25 +690,31 @@ abstract class bo_tracking if (!$email) return false; if (!$this->save_prefs) $this->save_prefs = $GLOBALS['egw_info']['user']; - + $save_account_id = $GLOBALS['egw_info']['user']['account_id']; if (is_numeric($user_or_lang)) // user --> read everything from his prefs { $GLOBALS['egw_info']['user']['account_id'] = $user_or_lang; $GLOBALS['egw']->preferences->__construct($user_or_lang); $GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository(false); // no session prefs! - + $returnfalsenow = false; if ($check && $this->check2pref) $check = $this->check2pref[$check]; if ($check && !$GLOBALS['egw_info']['user']['preferences'][$this->app][$check]) { - return false; // no notification requested + $returnfalsenow = true;//return false; // no notification requested } - if ($check && $GLOBALS['egw_info']['user']['preferences'][$this->app][$check] === 'assignment' && !$assignment_changed) + if (!$returnfalsenow && $check && $GLOBALS['egw_info']['user']['preferences'][$this->app][$check] === 'assignment' && !$assignment_changed) { - return false; // only notification about changed assignment requested + $returnfalsenow = true;//return false; // only notification about changed assignment requested } - if($this->user == $user_or_lang && !$this->notify_current_user) + if(!$returnfalsenow && $this->user == $user_or_lang && !$this->notify_current_user) { - return false; // no popup for own actions + $returnfalsenow = true;//return false; // no popup for own actions + } + if ($returnfalsenow) + { + $GLOBALS['egw_info']['user']['account_id'] = $save_account_id; + $GLOBALS['egw_info']['user'] = $this->save_prefs; + return false; } } else @@ -762,6 +768,8 @@ abstract class bo_tracking } catch (Exception $exception) { + $GLOBALS['egw_info']['user']['account_id'] = $save_account_id; + $GLOBALS['egw_info']['user'] = $this->save_prefs; $this->errors[] = $exception->getMessage(); return false; } @@ -769,6 +777,8 @@ abstract class bo_tracking error_log('tracking: cannot send any notifications because notifications is not installed'); } + $GLOBALS['egw_info']['user']['account_id'] = $save_account_id; + $GLOBALS['egw_info']['user'] = $this->save_prefs; return true; } diff --git a/phpgwapi/inc/class.send.inc.php b/phpgwapi/inc/class.send.inc.php index 4263ab6bc1..03ac68032d 100644 --- a/phpgwapi/inc/class.send.inc.php +++ b/phpgwapi/inc/class.send.inc.php @@ -27,8 +27,9 @@ class send extends egw_mailer * * To be able to call PHPMailer's Send function, we check if a subject, body or address is set and call it in that case, * else we do our constructors work. + * @param string $_app the app that is responsible for the sending itself, if available an appspecific profile is fetched/merged */ - function send() + function send($_app='felamimail') { if ($this->debug && is_numeric($this->debug)) $this->SMTPDebug = $this->debug; if ($this->Subject || $this->Body || count($this->to)) @@ -40,7 +41,7 @@ class send extends egw_mailer $this->CharSet = translation::charset(); $this->IsSmtp(); - $restoreSession = $getUserDefinedProfiles = true; + $restoreSession = $getUserDefinedProfiles = false; // no caching for profiles used for notification any more // if dontUseUserDefinedProfiles is set to yes/true/1 dont restore the session AND dont retrieve UserdefinedAccount settings $notification_config = config::read('notifications'); if ($notification_config['dontUseUserDefinedProfiles']) $restoreSession = $getUserDefinedProfiles = false; @@ -55,7 +56,8 @@ class send extends egw_mailer if ($bopreferences) { if ($this->debug) error_log(__METHOD__." using felamimail preferences for mailing."); // if dontUseUserDefinedProfiles is set to yes/true/1 dont retrieve UserdefinedAccount settings - $preferences = $bopreferences->getPreferences($getUserDefinedProfiles); + $preferences = $bopreferences->getPreferences($getUserDefinedProfiles,0,$_app); + if ($this->debug) error_log(__METHOD__.__LINE__.' Preferences fetched:'.array2string($preferences)); if ($preferences) { $ogServer = $preferences->getOutgoingServer(0); if ($ogServer) {