garding againts data set in egw object by reference from an other window, causing data to be inaccessible in IE after window closes

This commit is contained in:
Ralf Becker 2015-02-02 19:49:18 +00:00
parent 5a09fc60c1
commit 6bbf3661b2
10 changed files with 40 additions and 25 deletions

View File

@ -41,8 +41,8 @@ if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $
common::egw_exit(); common::egw_exit();
} }
$content = 'egw.set_configs('.$config.");\n"; $content = 'egw.set_configs('.$config.", egw && egw.window !== window);\n";
$content .= 'egw.set_link_registry('.$link_registry.");\n"; $content .= 'egw.set_link_registry('.$link_registry.", undefined, egw && egw.window !== window);\n";
// we run our own gzip compression, to set a correct Content-Length of the encoded content // we run our own gzip compression, to set a correct Content-Length of the encoded content
if (in_array('gzip', explode(',',$_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode')) if (in_array('gzip', explode(',',$_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode'))

View File

@ -41,7 +41,7 @@ if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $
common::egw_exit(); common::egw_exit();
} }
$content = 'egw.set_images('.$content.");\n"; $content = 'egw.set_images('.$content.", egw && egw.window !== window);\n";
// we run our own gzip compression, to set a correct Content-Length of the encoded content // we run our own gzip compression, to set a correct Content-Length of the encoded content
if (in_array('gzip', explode(',',$_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode')) if (in_array('gzip', explode(',',$_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode'))

View File

@ -29,8 +29,8 @@ egw.extend('config', egw.MODULE_GLOBAL, function() {
/** /**
* Query clientside config * Query clientside config
* *
* @param string _name name of config variable * @param {string} _name name of config variable
* @param string _app default "phpgwapi" * @param {string} _app default "phpgwapi"
* @return mixed * @return mixed
*/ */
config: function (_name, _app) config: function (_name, _app)
@ -45,11 +45,13 @@ egw.extend('config', egw.MODULE_GLOBAL, function() {
/** /**
* Set clientside configuration for all apps * Set clientside configuration for all apps
* *
* @param array/object * @param {object} _configs
* @param {boolean} _need_clone _configs need to be cloned, as it is from different window context
* and therefore will be inaccessible in IE, after that window is closed
*/ */
set_configs: function(_configs) set_configs: function(_configs, _need_clone)
{ {
configs = _configs; configs = _need_clone ? jQuery.extend(true, {}, _configs) : _configs;
} }
}; };
}); });

View File

@ -47,10 +47,12 @@ egw.extend('images', egw.MODULE_GLOBAL, function() {
* Set imagemap, called from /phpgwapi/images.php * Set imagemap, called from /phpgwapi/images.php
* *
* @param {array|object} _images * @param {array|object} _images
* @param {boolean} _need_clone _images need to be cloned, as it is from different window context
* and therefore will be inaccessible in IE, after that window is closed
*/ */
set_images: function (_images) set_images: function (_images, _need_clone)
{ {
images = _images; images = _need_clone ? jQuery.extend(true, {}, _images) : _images;
}, },
/** /**

View File

@ -37,13 +37,16 @@ egw.extend('lang', egw.MODULE_GLOBAL, function() {
* *
* @param {string} _app * @param {string} _app
* @param {object} _messages message => translation pairs * @param {object} _messages message => translation pairs
* @param {boolean} _need_clone _messages need to be cloned, as it is from different window context
* and therefore will be inaccessible in IE, after that window is closed
* @memberOf egw * @memberOf egw
*/ */
set_lang_arr: function(_app, _messages) set_lang_arr: function(_app, _messages, _need_clone)
{ {
if(!jQuery.isArray(_messages)) if(!jQuery.isArray(_messages))
{ {
lang_arr[_app] = _messages; // no deep clone jQuery.extend(true,...) neccessary, as _messages contains only string values
lang_arr[_app] = _need_clone ? jQuery.extend({}, _messages) : _messages;
} }
}, },

View File

@ -220,16 +220,18 @@ egw.extend('links', egw.MODULE_GLOBAL, function()
* *
* @param {object} _registry whole registry or entries for just one app * @param {object} _registry whole registry or entries for just one app
* @param {string} _app * @param {string} _app
* @param {boolean} _need_clone _images need to be cloned, as it is from different window context
* and therefore will be inaccessible in IE, after that window is closed
*/ */
set_link_registry: function (_registry, _app) set_link_registry: function (_registry, _app, _need_clone)
{ {
if (typeof _app == 'undefined') if (typeof _app == 'undefined')
{ {
link_registry = _registry; link_registry = _need_clone ? jQuery.extend(true, {}, _registry) : _registry;
} }
else else
{ {
link_registry[_app] = _registry; link_registry[_app] = _need_clone ? jQuery.extend(true, {}, _registry) : _registry;
} }
}, },

View File

@ -33,16 +33,18 @@ egw.extend('preferences', egw.MODULE_GLOBAL, function() {
* *
* @param {object} _data object with name: value pairs to set * @param {object} _data object with name: value pairs to set
* @param {string} _app application name, 'common' or undefined to prefes of all apps at once * @param {string} _app application name, 'common' or undefined to prefes of all apps at once
* @param {boolean} _need_clone _data need to be cloned, as it is from different window context
* and therefore will be inaccessible in IE, after that window is closed
*/ */
set_preferences: function(_data, _app) set_preferences: function(_data, _app, _need_clone)
{ {
if (typeof _app == 'undefined') if (typeof _app == 'undefined')
{ {
prefs = _data; prefs = _need_clone ? jQuery.extend(true, {}, _data) : _data;
} }
else else
{ {
prefs[_app] = jQuery.extend({}, _data); prefs[_app] = jQuery.extend(true, {}, _data); // we always clone here, as call can come from this.preferences!
} }
}, },

View File

@ -41,10 +41,12 @@ egw.extend('user', egw.MODULE_GLOBAL, function()
* Set data of current user * Set data of current user
* *
* @param {object} _data * @param {object} _data
* @param {boolean} _need_clone _data need to be cloned, as it is from different window context
* and therefore will be inaccessible in IE, after that window is closed
*/ */
set_user: function(_data) set_user: function(_data, _need_clone)
{ {
userData = _data; userData = _need_clone ? jQuery.extend(true, {}, _data) : _data;
}, },
/** /**
@ -92,7 +94,9 @@ egw.extend('user', egw.MODULE_GLOBAL, function()
{ {
// Synchronous // Synchronous
egw.json('home.egw_framework.ajax_user_list.template',[], egw.json('home.egw_framework.ajax_user_list.template',[],
function(data) {accountStore = data||{};} function(data) {
accountStore = jQuery.extend(true, {}, data||{});
}
).sendRequest(); ).sendRequest();
} }
if(type == 'both') if(type == 'both')

View File

@ -59,7 +59,7 @@ if (!count(translation::$lang_arr))
} }
// fix for phrases containing \n // fix for phrases containing \n
$content = 'egw.set_lang_arr("'.$_GET['app'].'", '.str_replace('\\\\n', '\\n', json_encode(translation::$lang_arr)).');'; $content = 'egw.set_lang_arr("'.$_GET['app'].'", '.str_replace('\\\\n', '\\n', json_encode(translation::$lang_arr)).', egw && egw.window !== window);';
// we run our own gzip compression, to set a correct Content-Length of the encoded content // we run our own gzip compression, to set a correct Content-Length of the encoded content
if (in_array('gzip', explode(',',$_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode')) if (in_array('gzip', explode(',',$_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode'))

View File

@ -42,9 +42,9 @@ if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $
common::egw_exit(); common::egw_exit();
} }
$content = 'egw.set_preferences('.$preferences.", 'common');\n"; $content = 'egw.set_preferences('.$preferences.", 'common', egw && egw.window !== window);\n";
$content .= 'egw.set_preferences('.$ab_preferences.", 'addressbook');\n"; $content .= 'egw.set_preferences('.$ab_preferences.", 'addressbook', egw && egw.window !== window);\n";
$content .= 'egw.set_user('.$user.");\n"; $content .= 'egw.set_user('.$user.", egw && egw.window !== window);\n";
// we run our own gzip compression, to set a correct Content-Length of the encoded content // we run our own gzip compression, to set a correct Content-Length of the encoded content
if (in_array('gzip', explode(',',$_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode')) if (in_array('gzip', explode(',',$_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode'))