Got remote applications in the jdots template finally working as they should - this unfortunately required a lot of 'dirty' hacks, as egroupware had not been designed to do this. So e.g. there had to be a litte bit code added to the login page, which prevented it from redirecting to a page with a full framework rebuild.

This commit is contained in:
Andreas Stöckel 2011-01-20 14:11:47 +00:00
parent 1abcbb12fc
commit 0f0e57f398
5 changed files with 93 additions and 19 deletions

View File

@ -336,7 +336,10 @@ else
else
{
list($forward,$extra_vars) = explode('?',$forward,2);
$extra_vars .= ($extra_vars ? '&' : '').'cd=yes';
if (!isset($_GET['suppress_cd']))
{
$extra_vars .= ($extra_vars ? '&' : '').'cd=yes';
}
}
if(strpos($_SERVER['HTTP_REFERER'], $_SERVER['REQUEST_URI']) === false) {

View File

@ -338,7 +338,21 @@ class egw extends egw_minimal
if ($relpath) $redirect .= 'phpgw_forward='.urlencode($relpath.(!empty($query) ? '?'.$query : ''));
//Header('Location: '.$GLOBALS['egw_info']['server']['webserver_url'].$redirect);
// do NOT redirect, but set top.location, as this works in framed template too
echo "<html>\n<head>\n<script type='text/javascript'>top.location='{$GLOBALS['egw_info']['server']['webserver_url']}$redirect';\n</script></head>\n";
$redirect = $GLOBALS['egw_info']['server']['webserver_url'].$redirect;
echo "<html>\n<head>\n<script type='text/javascript'>
if (typeof window.frameElement != 'undefined' &&
window.frameElement &&
typeof window.frameElement.egw_app != 'undefined' &&
typeof window.frameElement.egw_app.isRemote != 'undefined')
{
window.location='$redirect';
}
else
{
top.location='$redirect';
}
</script>\n</head>\n";
exit;
}
}

View File

@ -166,14 +166,15 @@ function _egw_json_plugin_handle(_type, _response) {
}
/** The constructor of the egw_json_request class.
* @param string _menuaction the menuaction function which should be called and which handles the actual request
*
* @param string _menuaction the menuaction function which should be called and
* which handles the actual request. If the menuaction is a full featured
* url, this one will be used instead.
* @param array _parameters which should be passed to the menuaction function.
* @param object _context is the context which will be used for the callback function
*/
function egw_json_request(_menuaction, _parameters, _context)
{
//Copy the supplied parameters
this.menuaction = _menuaction;
this.context = window.document;
if (typeof _context != 'undefined')
this.context = _context;
@ -187,15 +188,18 @@ function egw_json_request(_menuaction, _parameters, _context)
this.parameters = new Array;
}
var url = window.egw_webserverUrl;
// Search up to parent if the current window is in a frame
if(typeof url == "undefined")
// Check whether the supplied menuaction parameter is a full featured url
// or just a menuaction
if (_menuaction.match(/json.php\?menuaction=[a-z_0-9]*\.[a-z_0-9]*\.[a-z_0-9]*/i))
{
url = top.egw_webserverUrl;
// Menuaction is a full featured url
this.url = _menuaction
}
else
{
// We only got a menu action, assemble the url manually.
this.url = this._assembleAjaxUrl(_menuaction);
}
this.url = url + '/json.php';
this.request = null;
this.sender = null;
@ -210,7 +214,24 @@ function egw_json_request(_menuaction, _parameters, _context)
}
}
/* Sends the AJAX JSON request.
egw_json_request.prototype._assembleAjaxUrl = function(_menuaction)
{
// Retrieve the webserver url
var webserver_url = egw_topWindow().egw_webserverUrl;
// Check whether the webserver_url is really set
if (!webserver_url)
{
throw "Internal JS error, top window not found, webserver url could not be retrieved.";
}
// Add the ajax relevant parts
return webserver_url + '/json.php?menuaction=' + _menuaction;
}
/**
* Sends the AJAX JSON request.
*
* @param boolean _async specifies whether the request should be handeled asynchronously (true, the sendRequest function immediately returns to the caller) or asynchronously (false, the sendRequest function waits until the request is received)
* @param _callback is an additional callback function which should be called upon a "data" response is received
* @param _sender is the reference object the callback function should get
@ -238,14 +259,14 @@ egw_json_request.prototype.sendRequest = function(_async, _callback, _sender)
};
//Send the request via the jquery AJAX interface to the server
this.request = $.ajax({url: this.url + '?menuaction=' + this.menuaction,
this.request = $.ajax({url: this.url,
async: is_async,
context: this,
data: request_obj,
dataType: 'json',
type: 'POST',
success: this.handleResponse,
error: function(_xmlhttp,_err) { alert('Ajax request to '+this.url+'?menuaction='+this.menuaction+' failed: '+_err); }
error: function(_xmlhttp,_err) { alert('Ajax request to ' + this.url + ' failed: ' + _err); }
});
}
@ -367,8 +388,7 @@ egw_json_request.prototype.handleResponse = function(data, textStatus, XMLHttpRe
typeof res.data.global == 'boolean')
{
//Special handling for framework reload
if (res.data.url.indexOf("?cd=10") > 0)
res.data.global = true;
res.data.global |= (res.data.url.indexOf("?cd=10") > 0);
if (res.data.global)
{

View File

@ -114,6 +114,27 @@ function egw_appWindow(_app)
return window;
}
/**
* Returns the current egw application
* @param string _name is only used for fallback, if an onlder version of jdots is used.
*/
function egw_getApp(_name)
{
var napp = null;
if (typeof window.frameElement != "undefined" &&
window.frameElement != null &&
typeof window.frameElement.egw_app != "undefined")
{
napp = window.frameElement.egw_app;
}
else
{
napp = window.parent.framework.getApplicationByName(_name);
}
return napp;
}
/**
* Refresh given application _app display of entry _id, incl. outputting _msg
*

View File

@ -6,7 +6,7 @@
<div id="centerBox">
<div id="loginScreenMessage">{lang_message}</div>
<div id="loginCdMessage">{cd}</div>
<form name="login_form" method="post" action="{login_url}">
<form name="login_form" id="login_form" method="post" action="{login_url}">
<table class="divLoginbox divSideboxEntry" cellspacing="0" cellpadding="2" border="0" align="center">
<tr class="divLoginboxHeader">
<td colspan="3">{website_title}</td>
@ -63,5 +63,21 @@
<!-- END registration -->
</table>
</form>
<script type="text/javascript">
//Check whether the loginpage is displayed from within the jdots framework
//if yes, supress the "cd=yes" being appended to the page loaded
if (typeof window.frameElement != 'undefined' &&
window.frameElement &&
typeof window.frameElement.egw_app != 'undefined' &&
typeof window.frameElement.egw_app.isRemote != 'undefined' &&
window.frameElement.egw_app.isRemote())
{
loginForm = document.getElementById('login_form');
if (loginForm && loginForm.action.indexOf('phpgw_forward') > 0)
{
loginForm.action += '&suppress_cd=1';
}
}
</script>
</div>
</div>