diff --git a/phpgwapi/inc/class.asyncservice.inc.php b/phpgwapi/inc/class.asyncservice.inc.php index add36583ff..0f876498f9 100644 --- a/phpgwapi/inc/class.asyncservice.inc.php +++ b/phpgwapi/inc/class.asyncservice.inc.php @@ -393,7 +393,7 @@ class asyncservice { return False; // cant obtain semaphore } - if ($jobs = $this->read()) + if (($jobs = $this->read())) { foreach($jobs as $id => $job) { @@ -401,6 +401,8 @@ class asyncservice // if ($GLOBALS['egw_info']['user']['account_id'] != $job['account_id']) { + // run notifications, before changing account_id of enviroment + egw_link::run_notifies(); // unset all objects in $GLOBALS, which are created and used by ExecMethod, as they can contain user-data foreach($GLOBALS as $name => $value) { @@ -410,7 +412,7 @@ class asyncservice $lang = $GLOBALS['egw_info']['user']['preferences']['common']['lang']; unset($GLOBALS['egw_info']['user']); - if ($GLOBALS['egw']->session->account_id = $job['account_id']) + if (($GLOBALS['egw']->session->account_id = $job['account_id'])) { $GLOBALS['egw']->session->account_lid = $GLOBALS['egw']->accounts->id2name($job['account_id']); $GLOBALS['egw']->session->account_domain = $domain; diff --git a/phpgwapi/inc/class.egw_link.inc.php b/phpgwapi/inc/class.egw_link.inc.php index 24018ca34e..c318b5fe75 100644 --- a/phpgwapi/inc/class.egw_link.inc.php +++ b/phpgwapi/inc/class.egw_link.inc.php @@ -251,14 +251,18 @@ class egw_link extends solink } /** - * Called by egw::egw_final to store the title-cache in the session + * Called by egw::shutdown to store the title-cache in session and run notifications * + * Would probably better called shutdown as well. */ static function save_session_cache() { //error_log(__METHOD__.'() items in title-cache: '.count(self::$title_cache).' file-access-cache: '.count(self::$file_access_cache)); $GLOBALS['egw']->session->appsession('link_title_cache','phpgwapi',self::$title_cache); $GLOBALS['egw']->session->appsession('link_file_access_cache','phpgwapi',self::$file_access_cache); + + // send out notifications about added, changed or removed links + self::run_notifies(); } /** @@ -1342,6 +1346,13 @@ class egw_link extends solink self::delete_cache($app,$id); } + /** + * Stores notifications to run after regular processing is done + * + * @var array + */ + private static $notifies = array(); + /** * notify an application about a new or deleted links to own entries or updates in the content of the linked entry * @@ -1359,17 +1370,33 @@ class egw_link extends solink { if ($link_id && isset(self::$app_register[$notify_app]) && isset(self::$app_register[$notify_app]['notify'])) { - ExecMethod(self::$app_register[$notify_app]['notify'],array( + self::$notifies[] = array( + 'method' => self::$app_register[$notify_app]['notify'], 'type' => $type, 'id' => $notify_id, 'target_app' => $target_app, 'target_id' => $target_id, 'link_id' => $link_id, 'data' => $data, - )); + ); } } + /** + * Run notifications called by egw_link::save_session_cache from egw::shutdown, after regular processing is finished + */ + static public function run_notifies() + { + foreach(self::$notifies as $args) + { + $method = $args['method']; + unset($args['method']); + //error_log(__METHOD__."() calling $method(".array2string($args).')'); + ExecMethod($method, $args); + } + self::$notifies = array(); + } + /** * notifies about unlinked links *