* Admin: fixed user statistic submit to work in 14.1

This commit is contained in:
Ralf Becker 2014-07-02 16:47:38 +00:00
parent 4c5e36500a
commit 2b01b2aa50
2 changed files with 45 additions and 39 deletions

View File

@ -128,45 +128,7 @@ class admin_statistics
if (!isset($config[self::CONFIG_LAST_SUBMIT]) || $config[self::CONFIG_LAST_SUBMIT ] <= time()-self::SUBMISION_RATE) 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 // 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?'))."');"; $content['onclick'] = "return app.admin.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'] = "<script type=\"text/javascript\">
var own_action;
var own_exec_id;
function submit_statistic(form,submit_url,confirm_msg)
{
if (submit_url) {
if (!confirm(confirm_msg)) return false;
own_action = form.action;
own_exec_id = form['etemplate_exec_id'].value;
// submit to own webserver
window.setTimeout(function() {
submit_statistic(form);
},100);
// submit to egroupware.org
form.action=submit_url;
form['etemplate_exec_id'].value='';
form.target='_blank';
} else {
// submit to own webserver
form.action = own_action;
form['etemplate_exec_id'].value=own_exec_id;
form.target='';
form.submit();
}
return true;
}
</script>
";
} }
else // we are not due --> tell it the user else // we are not due --> tell it the user
{ {

View File

@ -699,5 +699,49 @@ app.classes.admin = AppJS.extend(
params.account_id = _senders[0].id.split('::').pop(); // get last :: separated part params.account_id = _senders[0].id.split('::').pop(); // get last :: separated part
} }
this.egw.open_link(this.egw.link('/index.php', params), 'admin', popup); 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;
} }
}); });