From 28b45639bedb4f05e49de6cfa5913a0783b10dd2 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 26 May 2014 13:29:35 +0000 Subject: [PATCH] to give observer method of other apps more information about what to refresh, server-side adds now links to refresh-opener and therefore observer calls --- phpgwapi/inc/class.egw_framework.inc.php | 22 +++++++++++++++++++++- phpgwapi/js/jsapi/app_base.js | 5 +++-- phpgwapi/js/jsapi/egw_message.js | 6 ++++-- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/phpgwapi/inc/class.egw_framework.inc.php b/phpgwapi/inc/class.egw_framework.inc.php index 95d409e955..194a059e87 100644 --- a/phpgwapi/inc/class.egw_framework.inc.php +++ b/phpgwapi/inc/class.egw_framework.inc.php @@ -251,6 +251,10 @@ abstract class egw_framework * * Calling egw_refresh and egw_message on opener in a content security save way * + * To provide more information about necessary refresh an automatic 9th parameter is added + * containing an object with application-name as attributes containing an array of linked ids + * (adding happens in get_extras to give apps time to link new entries!). + * * @param string $msg message (already translated) to show, eg. 'Entry deleted' * @param string $app application name * @param string|int $id=null id of entry to refresh @@ -346,6 +350,22 @@ abstract class egw_framework */ public static function get_extra() { + // adding links of refreshed entry, to give others apps more information about necessity to refresh + if (isset(self::$extra['refresh-opener']) && count(self::$extra['refresh-opener']) <= 8 && // do not run twice + !empty(self::$extra['refresh-opener'][1]) && !empty(self::$extra['refresh-opener'][2])) // app/id given + { + $links = egw_link::get_links(self::$extra['refresh-opener'][1], self::$extra['refresh-opener'][2]); + $apps = array(); + foreach($links as $link) + { + $apps[$link['app']][] = $link['id']; + } + while (count(self::$extra['refresh-opener']) < 8) + { + self::$extra['refresh-opener'][] = null; + } + self::$extra['refresh-opener'][] = $apps; + } return self::$extra; } @@ -2014,7 +2034,7 @@ if ($app == 'home') continue; $accounts[] = array('value' => $account_id, 'label' => $name); } } - + egw_json_response::get()->data($list); return $list; } diff --git a/phpgwapi/js/jsapi/app_base.js b/phpgwapi/js/jsapi/app_base.js index e5d83e1718..c18e9b9992 100644 --- a/phpgwapi/js/jsapi/app_base.js +++ b/phpgwapi/js/jsapi/app_base.js @@ -157,10 +157,11 @@ var AppJS = Class.extend( * - delete: just delete the given rows clientside (no server interaction neccessary) * - add: requires full reload for proper sorting * @param {string} _msg_type 'error', 'warning' or 'success' (default) - * @param {string} _targetapp which app's window should be refreshed, default current + * @param {object|null} _links app => array of ids of linked entries + * or null, if not triggered on server-side, which adds that info * @return {false|*} false to stop regular refresh, thought all observers are run */ - observer: function(_msg, _app, _id, _type, _msg_type, _targetapp) + observer: function(_msg, _app, _id, _type, _msg_type, _links) { }, diff --git a/phpgwapi/js/jsapi/egw_message.js b/phpgwapi/js/jsapi/egw_message.js index a3be7fabd7..3715af60d9 100644 --- a/phpgwapi/js/jsapi/egw_message.js +++ b/phpgwapi/js/jsapi/egw_message.js @@ -207,8 +207,10 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd) * @param {(string|RegExp)} _replace regular expression to replace in url * @param {string} _with * @param {string} _msg_type 'error', 'warning' or 'success' (default) + * @param {object|null} _links app => array of ids of linked entries + * or null, if not triggered on server-side, which adds that info */ - refresh: function(_msg, _app, _id, _type, _targetapp, _replace, _with, _msg_type) + refresh: function(_msg, _app, _id, _type, _targetapp, _replace, _with, _msg_type, _links) { // Log for debugging purposes this.debug("log", "egw_refresh(%s, %s, %s, %o, %s, %s)", _msg, _app, _id, _type, _targetapp, _replace, _with, _msg_type); @@ -224,7 +226,7 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd) { var app_obj = _wnd.egw.window.app[app]; if (typeof app_obj.observer == 'function' && - app_obj.observer(_msg, _app, _id, _type, _msg_type, _targetapp) === false && app === _app) + app_obj.observer(_msg, _app, _id, _type, _msg_type, _links) === false && app === _app) { no_regular_refresh = true; }