From 2b01b2aa502ff532ccd662459399288d4e1643c2 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 2 Jul 2014 16:47:38 +0000 Subject: [PATCH] * Admin: fixed user statistic submit to work in 14.1 --- admin/inc/class.admin_statistics.inc.php | 40 +-------------------- admin/js/app.js | 44 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 39 deletions(-) diff --git a/admin/inc/class.admin_statistics.inc.php b/admin/inc/class.admin_statistics.inc.php index 8e8aa5e67c..65da1fa6b5 100644 --- a/admin/inc/class.admin_statistics.inc.php +++ b/admin/inc/class.admin_statistics.inc.php @@ -128,45 +128,7 @@ class admin_statistics if (!isset($config[self::CONFIG_LAST_SUBMIT]) || $config[self::CONFIG_LAST_SUBMIT ] <= time()-self::SUBMISION_RATE) { // clear etemplate_exec_id and replace form.action, before submitting the form - $content['onclick'] = "return submit_statistic(this.form,'$content[submit_url]','".addslashes(lang('Submit displayed information?'))."');"; - - // Webkit browsers (Chrome, Safari, ...) do NOT allow to call form.submit() from within onclick of a submit button. - // Therefor we first store our own form action, replace it with egroupware.org submit url and set a timeout calling - // submit_statistic again with just the form, to do the second submit to our own webserver - $GLOBALS['egw_info']['flags']['java_script'] = " -"; + $content['onclick'] = "return app.admin.submit_statistic(this.form,'$content[submit_url]','".addslashes(lang('Submit displayed information?'))."');"; } else // we are not due --> tell it the user { diff --git a/admin/js/app.js b/admin/js/app.js index e102395bcb..b64ed2a845 100644 --- a/admin/js/app.js +++ b/admin/js/app.js @@ -699,5 +699,49 @@ app.classes.admin = AppJS.extend( params.account_id = _senders[0].id.split('::').pop(); // get last :: separated part } this.egw.open_link(this.egw.link('/index.php', params), 'admin', popup); + }, + + /** + * Submit statistic + * + * Webkit browsers (Chrome, Safari, ...) do NOT allow to call form.submit() from within onclick of a submit button. + * Therefor we first store our own form action, replace it with egroupware.org submit url and set a timeout calling + * submit_statistic again with just the form, to do the second submit to our own webserver + * + * @param {DOM} form + * @param {string} submit_url + * @param {string} confirm_msg + * @param {string} action own action, if called via window_set_timeout + * @param {string} exec_id own exec_id + * @return {boolean} + */ + submit_statistic: function(form,submit_url,confirm_msg,action,exec_id) + { + if (submit_url) { + if (!confirm(confirm_msg)) return false; + + var own_action = form.action; + var own_exec_id = form['etemplate_exec_id'].value; + var that = this; + + // submit to own webserver + window.setTimeout(function() { + that.submit_statistic.call(this, form, '', '', own_action, own_exec_id); + },100); + + // submit to egroupware.org + form.action=submit_url; + form['etemplate_exec_id'].value=''; + form.target='_blank'; + } else { + // submit to own webserver + form.action = action; + form['etemplate_exec_id'].value=exec_id; + form.target=''; + + form.submit(); + } + + return true; } });