forked from extern/egroupware
fix redirects in a popup and new egw_exception_redirect to be used in hooks/callbacks like for addressbook.edit to redirect to a different location
This commit is contained in:
parent
628b1369f7
commit
424b4c451c
@ -1791,6 +1791,10 @@ window.egw_LAB.wait(function() {
|
|||||||
$content['msg'] .= ', '.$success_msg;
|
$content['msg'] .= ', '.$success_msg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch(egw_exception_redirect $r)
|
||||||
|
{
|
||||||
|
// catch it to continue execution and rethrow it later
|
||||||
|
}
|
||||||
catch (Exception $ex) {
|
catch (Exception $ex) {
|
||||||
$content['msg'] .= ', '.$ex->getMessage();
|
$content['msg'] .= ', '.$ex->getMessage();
|
||||||
$button = 'apply'; // do not close dialog
|
$button = 'apply'; // do not close dialog
|
||||||
@ -1837,6 +1841,12 @@ window.egw_LAB.wait(function() {
|
|||||||
}
|
}
|
||||||
egw_framework::refresh_opener($content['msg'], 'addressbook', $content['id'], $content['id'] ? 'update' : 'add',
|
egw_framework::refresh_opener($content['msg'], 'addressbook', $content['id'], $content['id'] ? 'update' : 'add',
|
||||||
null, null, null, $this->error ? 'error' : 'success');
|
null, null, null, $this->error ? 'error' : 'success');
|
||||||
|
|
||||||
|
// re-throw redirect exception, if there's no error
|
||||||
|
if (!$this->error && isset($r))
|
||||||
|
{
|
||||||
|
throw $r;
|
||||||
|
}
|
||||||
if ($button == 'save')
|
if ($button == 'save')
|
||||||
{
|
{
|
||||||
egw_framework::window_close();
|
egw_framework::window_close();
|
||||||
|
5
json.php
5
json.php
@ -35,6 +35,11 @@ function login_redirect(&$anon_account)
|
|||||||
*/
|
*/
|
||||||
function ajax_exception_handler(Exception $e)
|
function ajax_exception_handler(Exception $e)
|
||||||
{
|
{
|
||||||
|
// handle redirects without logging
|
||||||
|
if (is_a($e, 'egw_exception_redirect'))
|
||||||
|
{
|
||||||
|
egw::redirect($e->url, $e->app);
|
||||||
|
}
|
||||||
// logging all exceptions to the error_log
|
// logging all exceptions to the error_log
|
||||||
$message = null;
|
$message = null;
|
||||||
if (function_exists('_egw_log_exception'))
|
if (function_exists('_egw_log_exception'))
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
class egw_exception extends Exception
|
class egw_exception extends Exception
|
||||||
{
|
{
|
||||||
// nothing fancy yet
|
// nothing fancy yet
|
||||||
|
function __construct($msg=null,$code=100,Exception $previous=null)
|
||||||
|
{
|
||||||
|
return parent::__construct($msg, $code, $previous);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,8 +42,8 @@ class egw_exception_no_permission extends egw_exception
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param string $msg=null message, default "Permission denied!"
|
* @param string $msg =null message, default "Permission denied!"
|
||||||
* @param int $code=100 numerical code, default 100
|
* @param int $code =100 numerical code, default 100
|
||||||
*/
|
*/
|
||||||
function __construct($msg=null,$code=100)
|
function __construct($msg=null,$code=100)
|
||||||
{
|
{
|
||||||
@ -106,8 +110,8 @@ class egw_exception_not_found extends egw_exception
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param string $msg=null message, default "Entry not found!"
|
* @param string $msg =null message, default "Entry not found!"
|
||||||
* @param int $code=99 numerical code, default 2
|
* @param int $code =99 numerical code, default 2
|
||||||
*/
|
*/
|
||||||
function __construct($msg=null,$code=2)
|
function __construct($msg=null,$code=2)
|
||||||
{
|
{
|
||||||
@ -145,8 +149,8 @@ class egw_exception_db extends egw_exception
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param string $msg=null message, default "Database error!"
|
* @param string $msg =null message, default "Database error!"
|
||||||
* @param int $code=100
|
* @param int $code =100
|
||||||
*/
|
*/
|
||||||
function __construct($msg=null,$code=100)
|
function __construct($msg=null,$code=100)
|
||||||
{
|
{
|
||||||
@ -180,3 +184,30 @@ class egw_exception_db_invalid_sql extends egw_exception_db { }
|
|||||||
* EGroupware not (fully) installed, visit setup
|
* EGroupware not (fully) installed, visit setup
|
||||||
*/
|
*/
|
||||||
class egw_exception_db_setup extends egw_exception_db { }
|
class egw_exception_db_setup extends egw_exception_db { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow callbacks to request a redirect
|
||||||
|
*
|
||||||
|
* Can be caught be applications and is otherwise handled by global exception handler.
|
||||||
|
*/
|
||||||
|
class egw_exception_redirect extends egw_exception
|
||||||
|
{
|
||||||
|
public $url;
|
||||||
|
public $app;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param string $url
|
||||||
|
* @param string $app
|
||||||
|
* @param string $msg
|
||||||
|
* @param int $code
|
||||||
|
*/
|
||||||
|
function __construct($url,$app=null,$msg=null,$code=301)
|
||||||
|
{
|
||||||
|
$this->url = $url;
|
||||||
|
$this->app = $app;
|
||||||
|
|
||||||
|
parent::__construct($msg, $code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1709,6 +1709,11 @@ function _egw_log_exception(Exception $e,&$headline=null)
|
|||||||
*/
|
*/
|
||||||
function egw_exception_handler(Exception $e)
|
function egw_exception_handler(Exception $e)
|
||||||
{
|
{
|
||||||
|
// handle redirects without logging
|
||||||
|
if (is_a($e, 'egw_exception_redirect'))
|
||||||
|
{
|
||||||
|
egw::redirect($e->url, $e->app);
|
||||||
|
}
|
||||||
// logging all exceptions to the error_log (if not cli) and get headline
|
// logging all exceptions to the error_log (if not cli) and get headline
|
||||||
$headline = null;
|
$headline = null;
|
||||||
_egw_log_exception($e,$headline);
|
_egw_log_exception($e,$headline);
|
||||||
|
@ -406,6 +406,12 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) {
|
|||||||
{
|
{
|
||||||
egw_topWindow().location.href = res.data.url;
|
egw_topWindow().location.href = res.data.url;
|
||||||
}
|
}
|
||||||
|
// json request was originating from a different window --> redirect that one
|
||||||
|
else if(this.DOMContainer && this.DOMContainer.ownerDocument.defaultView != window)
|
||||||
|
{
|
||||||
|
this.DOMContainer.ownerDocument.location.href = res.data.url;
|
||||||
|
}
|
||||||
|
// main window, open url in respective tab
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
egw_appWindowOpen(res.data.app, res.data.url);
|
egw_appWindowOpen(res.data.app, res.data.url);
|
||||||
|
Loading…
Reference in New Issue
Block a user