forked from extern/egroupware
notify server about closed windows, so we can destroy no longer eT needed session/requests and so keep cache small
This commit is contained in:
parent
32701f01fc
commit
205794f4a7
@ -309,6 +309,21 @@ class etemplate_new extends etemplate_widget_template
|
|||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify server that eT session/request is no longer needed, because user closed window
|
||||||
|
*
|
||||||
|
* @param string $_exec_id
|
||||||
|
*/
|
||||||
|
static public function ajax_destroy_session($_exec_id)
|
||||||
|
{
|
||||||
|
//error_log(__METHOD__."('$_exec_id')");
|
||||||
|
if (($request = etemplate_request::read($_exec_id)))
|
||||||
|
{
|
||||||
|
$request->remove_if_not_modified();
|
||||||
|
unset($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process via POST submitted content
|
* Process via POST submitted content
|
||||||
*/
|
*/
|
||||||
|
@ -190,11 +190,43 @@ etemplate2.prototype._createArrayManagers = function(_data)
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bind our unload handler to notify server that eT session/request no longer needed
|
||||||
|
*/
|
||||||
|
etemplate2.prototype.bind_unload = function()
|
||||||
|
{
|
||||||
|
if (!window.onbeforeunload)
|
||||||
|
{
|
||||||
|
window.onbeforeunload = this.destroy_session = jQuery.proxy(function(ev)
|
||||||
|
{
|
||||||
|
var request = egw.json(self.egw().getAppName()+".etemplate_new.ajax_destroy_session.etemplate",
|
||||||
|
[this.etemplate_exec_id], null, null, false);
|
||||||
|
request.sendRequest();
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unbind our unload handler
|
||||||
|
*/
|
||||||
|
etemplate2.prototype.unbind_unload = function()
|
||||||
|
{
|
||||||
|
if (window.onbeforeunload === this.destroy_session)
|
||||||
|
{
|
||||||
|
window.onbeforeunload = null;
|
||||||
|
delete this.destroy_session;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the template from the given URL and sets the data object
|
* Loads the template from the given URL and sets the data object
|
||||||
*/
|
*/
|
||||||
etemplate2.prototype.load = function(_name, _url, _data, _callback)
|
etemplate2.prototype.load = function(_name, _url, _data, _callback)
|
||||||
{
|
{
|
||||||
|
if (_data.etemplate_exec_id)
|
||||||
|
{
|
||||||
|
this.bind_unload();
|
||||||
|
}
|
||||||
egw().debug("info", "Loaded data", _data);
|
egw().debug("info", "Loaded data", _data);
|
||||||
var currentapp = _data.currentapp || window.egw_appName;
|
var currentapp = _data.currentapp || window.egw_appName;
|
||||||
|
|
||||||
@ -468,6 +500,9 @@ etemplate2.prototype.submit = function(button, async)
|
|||||||
// Create the request object
|
// Create the request object
|
||||||
if (this.menuaction)
|
if (this.menuaction)
|
||||||
{
|
{
|
||||||
|
// unbind our session-destroy handler, as we are submitting
|
||||||
|
this.unbind_unload();
|
||||||
|
|
||||||
var api = this.widgetContainer.egw();
|
var api = this.widgetContainer.egw();
|
||||||
var request = api.json(this.menuaction, [this.etemplate_exec_id,values], null, this, async);
|
var request = api.json(this.menuaction, [this.etemplate_exec_id,values], null, this, async);
|
||||||
request.sendRequest();
|
request.sendRequest();
|
||||||
@ -500,6 +535,9 @@ etemplate2.prototype.postSubmit = function()
|
|||||||
|
|
||||||
if (canSubmit)
|
if (canSubmit)
|
||||||
{
|
{
|
||||||
|
// unbind our session-destroy handler, as we are submitting
|
||||||
|
this.unbind_unload();
|
||||||
|
|
||||||
var form = jQuery("<form id='form' action='"+egw().webserverUrl +
|
var form = jQuery("<form id='form' action='"+egw().webserverUrl +
|
||||||
"/etemplate/process_exec.php?menuaction=" + this.widgetContainer.egw().getAppName()+ "&ajax=true' method='POST'>");
|
"/etemplate/process_exec.php?menuaction=" + this.widgetContainer.egw().getAppName()+ "&ajax=true' method='POST'>");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user