From 04267ed34dde27070e82efb20f9b9a0e2c998612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20St=C3=B6ckel?= Date: Fri, 11 Jun 2010 08:08:07 +0000 Subject: [PATCH] Added handling for global redirect and handling of ?cd=10 in redirect url, which should trigger the url to be loaded inside the top window --- phpgwapi/inc/class.egw_json.inc.php | 12 +++++++++--- phpgwapi/js/egw_json.js | 16 ++++++++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/phpgwapi/inc/class.egw_json.inc.php b/phpgwapi/inc/class.egw_json.inc.php index b2d0b3e747..f740927730 100644 --- a/phpgwapi/inc/class.egw_json.inc.php +++ b/phpgwapi/inc/class.egw_json.inc.php @@ -323,10 +323,16 @@ class egw_json_response * * @param string $url */ - public function redirect($url) + public function redirect($url, $global = false) { - //self::script("location.href = '$url';"); - $this->addGeneric('redirect', $url); + if (is_string($url) && is_bool($global)) + { + //self::script("location.href = '$url';"); + $this->addGeneric('redirect', array( + 'url' => $url, + 'global' => $global, + )); + } } /** diff --git a/phpgwapi/js/egw_json.js b/phpgwapi/js/egw_json.js index d57434e5d0..5b6eea961c 100644 --- a/phpgwapi/js/egw_json.js +++ b/phpgwapi/js/egw_json.js @@ -229,9 +229,21 @@ egw_json_request.prototype.handleResponse = function(data, textStatus, XMLHttpRe } break; case 'redirect': - if (typeof res.data == 'string') + if (typeof res.data.url == 'string' && + typeof res.data.global == 'boolean') { - window.location.href = res.data; + //Special handling for framework reload + if (res.data.url.indexOf("?cd=10") > 0) + res.data.global = true; + + if (res.data.global) + { + egw_topWindow().location.href = res.data.url; + } + else + { + window.location.href = res.data.url; + } } break; }