From daa0ce25f3c440c6b86baa534dbfc2da663f0863 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 17 Jul 2014 14:02:31 +0000 Subject: [PATCH] fixed statistic submit to show, but ignore, tree --- admin/inc/class.admin_hooks.inc.php | 4 ---- admin/inc/class.admin_statistics.inc.php | 20 ++++++++++++-------- admin/inc/class.admin_ui.inc.php | 6 ++++-- admin/js/app.js | 12 ++++++++---- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/admin/inc/class.admin_hooks.inc.php b/admin/inc/class.admin_hooks.inc.php index 4e91ede371..63e40e52d0 100644 --- a/admin/inc/class.admin_hooks.inc.php +++ b/admin/inc/class.admin_hooks.inc.php @@ -33,10 +33,6 @@ class admin_hooks { unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']); - if (!isset($_GET['menuaction']) && substr($_SERVER['PHP_SELF'],-16) == '/admin/index.php') - { - admin_statistics::check(); - } $appname = 'admin'; $location = is_array($args) ? $args['location'] : $args; diff --git a/admin/inc/class.admin_statistics.inc.php b/admin/inc/class.admin_statistics.inc.php index 65da1fa6b5..e267c754cc 100644 --- a/admin/inc/class.admin_statistics.inc.php +++ b/admin/inc/class.admin_statistics.inc.php @@ -52,7 +52,7 @@ class admin_statistics config::save_value(self::CONFIG_POSTPONE_SUBMIT,time()+$content['postpone'],self::CONFIG_APP); $what = 'postpone'; } - elseif(!$content['canceled']) + elseif(!$content['cancel']) { config::save_value(self::CONFIG_LAST_SUBMIT,time(),self::CONFIG_APP); config::save_value(self::CONFIG_SUBMIT_ID,empty($content['submit_id']) ? '***none***' : $content['submit_id'],self::CONFIG_APP); @@ -280,21 +280,25 @@ class admin_statistics /** * Check if next submission is due, in which case we call submit and NOT return to the admin hook * + * @param boolean $redirect should we redirect or return true + * @return boolean true if statistic submission is due */ - public static function check() + public static function check($redirect=true) { - if (isset($_GET['statistics'])) - { - return; - } $config = config::read(self::CONFIG_APP); if (isset($config[self::CONFIG_POSTPONE_SUBMIT]) && $config[self::CONFIG_POSTPONE_SUBMIT] > time() || isset($config[self::CONFIG_LAST_SUBMIT ]) && $config[self::CONFIG_LAST_SUBMIT ] > time()-self::SUBMISION_RATE) { - return; + return false; } + if (!$redirect) return true; + //die('Due for new statistics submission: last_submit='.$config[self::CONFIG_LAST_SUBMIT ].', postpone='.$config[self::CONFIG_POSTPONE_SUBMIT].', '.function_backtrace()); - egw::redirect_link('/index.php',array('menuaction'=>'admin.admin_statistics.submit')); + egw::redirect_link('/index.php',array( + 'menuaction' => 'admin.admin_ui.index', + 'ajax' => 'true', + 'load' => 'admin.admin_statistics.submit', + )); } } diff --git a/admin/inc/class.admin_ui.inc.php b/admin/inc/class.admin_ui.inc.php index dacb8d9f31..13375eded1 100644 --- a/admin/inc/class.admin_ui.inc.php +++ b/admin/inc/class.admin_ui.inc.php @@ -37,8 +37,10 @@ class admin_ui */ public function index(array $content=null) { - admin_statistics::check(); - + if (admin_statistics::check(false)) + { + $_GET['load'] = 'admin.admin_statistics.submit'; + } $tpl = new etemplate_new('admin.index'); $content = array(); diff --git a/admin/js/app.js b/admin/js/app.js index b6cd96589d..9d3ecf95a0 100644 --- a/admin/js/app.js +++ b/admin/js/app.js @@ -113,6 +113,10 @@ app.classes.admin = AppJS.extend( */ load: function(_url) { + if (this.iframe && this.iframe.getDOMNode().contentDocument.location.href.match(/menuaction=admin.admin_statistics.submit/)) + { + return; // do not allow to leave statistics submit + } if (_url) { this.iframe.set_src(_url); @@ -172,7 +176,7 @@ app.classes.admin = AppJS.extend( var nm = this.et2.getWidgetById('nm'); nm.applyFilters(activeFilters); } - + } var refreshTree = this.et2.getWidgetById('tree'); if (refreshTree) refreshTree.refreshItem('/groups'); @@ -768,10 +772,10 @@ app.classes.admin = AppJS.extend( return true; }, - + /** * Delete confirmation dialog - * + * * @param {egw action} _action */ delete_category: function (_action) @@ -801,7 +805,7 @@ app.classes.admin = AppJS.extend( action.id = 'delete_sub'; nm_action(action); } - } + } } else {