diff --git a/public_html/includes/js/LSdefault.js b/public_html/includes/js/LSdefault.js
index f5707c38..5098ad6c 100644
--- a/public_html/includes/js/LSdefault.js
+++ b/public_html/includes/js/LSdefault.js
@@ -263,7 +263,7 @@ var LSdefault = new Class({
keepLSsession: function() {
LSdebug('Keep LSsession');
- new Request({url: 'index_ajax.php', data: {}, onSuccess: this.keepLSsessionComplete.bind(this)}).send();
+ new Request({url: 'ajax/keepLSsession', data: {}, onSuccess: this.keepLSsessionComplete.bind(this)}).send();
},
keepLSsessionComplete: function() {
diff --git a/public_html/includes/js/LSformElement.js b/public_html/includes/js/LSformElement.js
index ca065fe7..68de834b 100644
--- a/public_html/includes/js/LSformElement.js
+++ b/public_html/includes/js/LSformElement.js
@@ -23,8 +23,6 @@ var LSformElement = new Class({
onAddFieldBtnClick: function(field){
var data = {
- template: 'LSform',
- action: 'onAddFieldBtnClick',
attribute: this.name,
objecttype: this.LSform.objecttype,
objectdn: this.LSform.objectdn,
@@ -33,7 +31,7 @@ var LSformElement = new Class({
};
LSdebug(data);
data.imgload = varLSdefault.loadingImgDisplay(field.li,'inside');
- new Request({url: 'index_ajax.php', data: data, onSuccess: this.onAddFieldBtnClickComplete.bind(this)}).send();
+ new Request({url: 'ajax/class/LSform/onAddFieldBtnClick', data: data, onSuccess: this.onAddFieldBtnClickComplete.bind(this)}).send();
},
onAddFieldBtnClickComplete: function(responseText, responseXML) {
diff --git a/public_html/includes/js/LSformElement_mail_field.js b/public_html/includes/js/LSformElement_mail_field.js
index 7579e833..16880ced 100644
--- a/public_html/includes/js/LSformElement_mail_field.js
+++ b/public_html/includes/js/LSformElement_mail_field.js
@@ -52,15 +52,13 @@ var LSformElement_mail_field = new Class({
this.input.set('disabled', 'disabled');
this.lastAutocompletePattern=pattern;
var data = {
- template: 'LSformElement_mail',
- action: 'autocomplete',
attribute: this.name,
objecttype: varLSform.objecttype,
idform: varLSform.idform,
pattern: pattern
};
data.imgload=varLSdefault.loadingImgDisplay(this.input);
- new Request({url: 'index_ajax.php', data: data, onSuccess: this.onAutocompleteComplete.bind(this)}).send();
+ new Request({url: 'ajax/class/LSformElement_mail/autocomplete', data: data, onSuccess: this.onAutocompleteComplete.bind(this)}).send();
},
onAutocompleteComplete: function(responseText, responseXML) {
diff --git a/public_html/includes/js/LSformElement_password_field.js b/public_html/includes/js/LSformElement_password_field.js
index a497d5b6..97ed68cb 100644
--- a/public_html/includes/js/LSformElement_password_field.js
+++ b/public_html/includes/js/LSformElement_password_field.js
@@ -160,15 +160,13 @@ var LSformElement_password_field = new Class({
onGenerateBtnClick: function() {
var data = {
- template: 'LSformElement_password',
- action: 'generatePassword',
attribute: this.name,
objecttype: varLSform.objecttype,
objectdn: varLSform.objectdn,
idform: varLSform.idform
};
data.imgload=varLSdefault.loadingImgDisplay(this.generateBtn);
- new Request({url: 'index_ajax.php', data: data, onSuccess: this.onGenerateBtnClickComplete.bind(this)}).send();
+ new Request({url: 'ajax/class/LSformElement_password/generatePassword', data: data, onSuccess: this.onGenerateBtnClickComplete.bind(this)}).send();
},
onGenerateBtnClickComplete: function(responseText, responseXML) {
@@ -207,8 +205,6 @@ var LSformElement_password_field = new Class({
onVerifyBtnClick: function() {
var data = {
- template: 'LSformElement_password',
- action: 'verifyPassword',
attribute: this.name,
objecttype: varLSform.objecttype,
idform: varLSform.idform,
@@ -217,7 +213,7 @@ var LSformElement_password_field = new Class({
};
LSdebug(data);
data.imgload=varLSdefault.loadingImgDisplay(this.verifyBtn);
- new Request({url: 'index_ajax.php', data: data, onSuccess: this.onVerifyBtnClickComplete.bind(this)}).send();
+ new Request({url: 'ajax/class/LSformElement_password/verifyPassword', data: data, onSuccess: this.onVerifyBtnClickComplete.bind(this)}).send();
},
onVerifyBtnClickComplete: function(responseText, responseXML) {
@@ -237,14 +233,12 @@ var LSformElement_password_field = new Class({
onViewHashBtnClick: function() {
var data = {
- template: 'LSformElement_password',
- action: 'viewHash',
attribute: this.name,
objecttype: varLSform.objecttype,
objectdn: varLSform.objectdn
};
data.imgload=varLSdefault.loadingImgDisplay(this.viewHashBtn);
- new Request({url: 'index_ajax.php', data: data, onSuccess: this.onViewHashBtnClickComplete.bind(this)}).send();
+ new Request({url: 'ajax/class/LSformElement_password/viewHash', data: data, onSuccess: this.onViewHashBtnClickComplete.bind(this)}).send();
},
onViewHashBtnClickComplete: function(responseText, responseXML) {
diff --git a/public_html/includes/js/LSformElement_select_object_field.js b/public_html/includes/js/LSformElement_select_object_field.js
index 261d4017..e710f394 100644
--- a/public_html/includes/js/LSformElement_select_object_field.js
+++ b/public_html/includes/js/LSformElement_select_object_field.js
@@ -132,14 +132,12 @@ var LSformElement_select_object_field = new Class({
}, this);
var data = {
- template: 'LSselect',
- action: 'refreshSession',
objecttype: this.params['object_type'],
values: JSON.encode(values)
};
data.imgload=varLSdefault.loadingImgDisplay(this.addBtn,'inside');
- new Request({url: 'index_ajax.php', data: data, onSuccess: this.onAddBtnClickComplete.bind(this)}).send();
+ new Request({url: 'ajax/class/LSselect/refreshSession', data: data, onSuccess: this.onAddBtnClickComplete.bind(this)}).send();
},
onAddBtnClickComplete: function(responseText, responseXML) {
@@ -165,15 +163,13 @@ var LSformElement_select_object_field = new Class({
onLSsmoothboxValid: function() {
var data = {
- template: 'LSformElement_select_object',
- action: 'refresh',
attribute: this.name,
objecttype: varLSform.objecttype,
objectdn: varLSform.objectdn,
idform: varLSform.idform
};
data.imgload=varLSdefault.loadingImgDisplay(this.addBtn);
- new Request({url: 'index_ajax.php', data: data, onSuccess: this.onLSsmoothboxValidComplete.bind(this)}).send();
+ new Request({url: 'ajax/class/LSformElement_select_object/refresh', data: data, onSuccess: this.onLSsmoothboxValidComplete.bind(this)}).send();
},
onLSsmoothboxValidComplete: function(responseText, responseXML) {
@@ -373,15 +369,13 @@ var LSformElement_select_object_field = new Class({
if (this._lastSearch!=this.searchAddInput.value) {
this._lastSearch=this.searchAddInput.value;
var data = {
- template: 'LSformElement_select_object',
- action: 'searchAdd',
attribute: this.name,
objecttype: varLSform.objecttype,
idform: varLSform.idform,
pattern: this.searchAddInput.value
};
data.imgload=varLSdefault.loadingImgDisplay(this.searchAddInput);
- new Request({url: 'index_ajax.php', data: data, onSuccess: this.onSearchAddComplete.bind(this)}).send();
+ new Request({url: 'ajax/class/LSformElement_select_object/searchAdd', data: data, onSuccess: this.onSearchAddComplete.bind(this)}).send();
}
},
diff --git a/public_html/includes/js/LSformElement_supannCompositeAttribute_field_value_component.js b/public_html/includes/js/LSformElement_supannCompositeAttribute_field_value_component.js
index 8e1983eb..846b1182 100644
--- a/public_html/includes/js/LSformElement_supannCompositeAttribute_field_value_component.js
+++ b/public_html/includes/js/LSformElement_supannCompositeAttribute_field_value_component.js
@@ -69,8 +69,6 @@ var LSformElement_supannCompositeAttribute_field_value_component = new Class({
this.hidePossibleValues();
this._lastSearch=this.inputSearch.value;
var data = {
- template: 'LSformElement_supannCompositeAttribute',
- action: 'searchComponentPossibleValues',
attribute: this.field_name,
objecttype: varLSform.objecttype,
idform: varLSform.idform,
@@ -78,7 +76,7 @@ var LSformElement_supannCompositeAttribute_field_value_component = new Class({
pattern: this.inputSearch.value
};
data.imgload=varLSdefault.loadingImgDisplay(this.inputSearch);
- new Request({url: 'index_ajax.php', data: data, onSuccess: this.onSearchComplete.bind(this)}).send();
+ new Request({url: 'ajax/class/LSformElement_supannCompositeAttribute/searchComponentPossibleValues', data: data, onSuccess: this.onSearchComplete.bind(this)}).send();
},
onSearchComplete: function(responseText, responseXML) {
diff --git a/public_html/includes/js/LSformElement_supannLabeledValue_field_value.js b/public_html/includes/js/LSformElement_supannLabeledValue_field_value.js
index ccc980e2..b23f9c4a 100644
--- a/public_html/includes/js/LSformElement_supannLabeledValue_field_value.js
+++ b/public_html/includes/js/LSformElement_supannLabeledValue_field_value.js
@@ -67,15 +67,13 @@ var LSformElement_supannLabeledValue_field_value = new Class({
this.hidePossibleValues();
this._lastSearch=this.inputSearch.value;
var data = {
- template: 'LSformElement_supannLabeledValue',
- action: 'searchPossibleValues',
attribute: this.name,
objecttype: varLSform.objecttype,
idform: varLSform.idform,
pattern: this.inputSearch.value
};
data.imgload=varLSdefault.loadingImgDisplay(this.inputSearch);
- new Request({url: 'index_ajax.php', data: data, onSuccess: this.onSearchComplete.bind(this)}).send();
+ new Request({url: 'ajax/class/LSformElement_supannLabeledValue/searchPossibleValues', data: data, onSuccess: this.onSearchComplete.bind(this)}).send();
},
onSearchComplete: function(responseText, responseXML) {
diff --git a/public_html/includes/js/LSmail.js b/public_html/includes/js/LSmail.js
index 5f47fdeb..6f3b05f4 100644
--- a/public_html/includes/js/LSmail.js
+++ b/public_html/includes/js/LSmail.js
@@ -69,8 +69,6 @@ var LSmail = new Class({
open: function(startElement) {
if (this.opened==0) {
var data = {
- template: 'LSmail',
- action: 'display',
object: this.object,
mails: this.mails,
msg: this.msg,
@@ -83,7 +81,7 @@ var LSmail = new Class({
data.imgload=varLSdefault.loadingImgDisplay(startElement);
}
- new Request({url: 'index_ajax.php', data: data, onSuccess: this.onOpenGetHtmlComplete.bind(this)}).send();
+ new Request({url: 'ajax/class/LSmail/display', data: data, onSuccess: this.onOpenGetHtmlComplete.bind(this)}).send();
}
},
@@ -116,12 +114,10 @@ var LSmail = new Class({
send: function() {
if ($type(this.sendInfos)) {
var data = {
- template: 'LSmail',
- action: 'send',
infos: this.sendInfos
};
data.imgload=varLSdefault.loadingImgDisplay(this.startElement);
- new Request({url: 'index_ajax.php', data: data, onSuccess: this.onSendComplete.bind(this)}).send();
+ new Request({url: 'ajax/class/LSmail/send', data: data, onSuccess: this.onSendComplete.bind(this)}).send();
}
},
diff --git a/public_html/includes/js/LSrelation.js b/public_html/includes/js/LSrelation.js
index fb86a149..35e90b9c 100644
--- a/public_html/includes/js/LSrelation.js
+++ b/public_html/includes/js/LSrelation.js
@@ -66,13 +66,11 @@ var LSrelation = new Class({
var id = getId.exec(ul.id)[1];
var data = {
- template: 'LSrelation',
- action: 'deleteByDn',
id: id,
dn: this.a2dn(a)
};
data.imgload=varLSdefault.loadingImgDisplay(li,'inside');
- new Request({url: 'index_ajax.php', data: data, onSuccess: this.deleteFromImgComplete.bind(this)}).send();
+ new Request({url: 'ajax/class/LSrelation/deleteByDn', data: data, onSuccess: this.deleteFromImgComplete.bind(this)}).send();
},
deleteFromImgComplete: function(responseText, responseXML) {
@@ -102,8 +100,6 @@ var LSrelation = new Class({
new Event(event).stop();
var data = {
- template: 'LSrelation',
- action: 'refreshSession',
id: a.id,
href: a.href
};
@@ -111,7 +107,7 @@ var LSrelation = new Class({
LSdebug(data);
this.refreshRelation=a.id;
data.imgload=varLSdefault.loadingImgDisplay('LSrelation_title_'+a.id,'inside');
- new Request({url: 'index_ajax.php', data: data, onSuccess: this.onLSrelationModifyBtnClickComplete.bind(this)}).send();
+ new Request({url: 'ajax/class/LSrelation/refreshSession', data: data, onSuccess: this.onLSrelationModifyBtnClickComplete.bind(this)}).send();
},
onLSrelationModifyBtnClickComplete: function(responseText, responseXML) {
@@ -125,14 +121,12 @@ var LSrelation = new Class({
onLSsmoothboxValid: function() {
var data = {
- template: 'LSrelation',
- action: 'refreshList',
id: this.refreshRelation
};
LSdebug(data);
data.imgload=varLSdefault.loadingImgDisplay('LSrelation_title_'+this.refreshRelation,'inside');
- new Request({url: 'index_ajax.php', data: data, onSuccess: this.onLSsmoothboxValidComplete.bind(this)}).send();
+ new Request({url: 'ajax/class/LSrelation/refreshList', data: data, onSuccess: this.onLSsmoothboxValidComplete.bind(this)}).send();
},
onLSsmoothboxValidComplete: function(responseText, responseXML) {
diff --git a/public_html/includes/js/LSselect.js b/public_html/includes/js/LSselect.js
index d819a74c..ff0752c8 100644
--- a/public_html/includes/js/LSselect.js
+++ b/public_html/includes/js/LSselect.js
@@ -50,25 +50,23 @@ var LSselect = new Class({
oncheckboxChange: function(checkbox){
if (checkbox.checked) {
+ var url = 'ajax/class/LSselect/addItem';
var data = {
- template: 'LSselect',
- action: 'addItem',
objectdn: checkbox.value,
objecttype: $('LSselect-object').getProperties('caption').caption,
multiple: this.multiple
};
}
else {
+ var url = 'ajax/class/LSselect/dropItem';
var data = {
- template: 'LSselect',
- action: 'dropItem',
objectdn: checkbox.value,
objecttype: $('LSselect-object').getProperties('caption').caption,
multiple: this.multiple
};
}
data.imgload=varLSdefault.loadingImgDisplay(checkbox.getParent().getNext(),'inside');
- new Request({url: 'index_ajax.php', data: data, onSuccess: this.oncheckboxChangeComplete.bind(this)}).send();
+ new Request({url: url, data: data, onSuccess: this.oncheckboxChangeComplete.bind(this)}).send();
},
oncheckboxChangeComplete: function(responseText, responseXML) {
diff --git a/public_html/includes/js/LSsession_login.js b/public_html/includes/js/LSsession_login.js
index c0dd28af..fdcf4726 100644
--- a/public_html/includes/js/LSsession_login.js
+++ b/public_html/includes/js/LSsession_login.js
@@ -27,12 +27,10 @@ var LSsession_login = new Class({
var server = this.select_ldapserver.value;
var data = {
noLSsession: 1,
- template: 'LSsession',
- action: 'onLdapServerChangedLogin',
server: server,
imgload: imgload
};
- new Request({url: 'index_ajax.php', data: data, onSuccess: this.onLdapServerChangedComplete.bind(this)}).send();
+ new Request({url: 'ajax/class/LSsession/onLdapServerChangedLogin', data: data, onSuccess: this.onLdapServerChangedComplete.bind(this)}).send();
},
onLdapServerChangedComplete: function(responseText, responseXML){
diff --git a/public_html/includes/js/LSsession_recoverPassword.js b/public_html/includes/js/LSsession_recoverPassword.js
index 56681075..d41a9ce6 100644
--- a/public_html/includes/js/LSsession_recoverPassword.js
+++ b/public_html/includes/js/LSsession_recoverPassword.js
@@ -26,12 +26,10 @@ var LSsession_recoverPassword = new Class({
var server = this.select_ldapserver.value;
var data = {
noLSsession: 1,
- template: 'LSsession',
- action: 'onLdapServerChangedRecoverPassword',
server: server,
imgload: imgload
};
- new Request({url: 'index_ajax.php', data: data, onSuccess: this.onLdapServerChangedComplete.bind(this)}).send();
+ new Request({url: 'ajax/class/LSsession/onLdapServerChangedRecoverPassword', data: data, onSuccess: this.onLdapServerChangedComplete.bind(this)}).send();
},
onLdapServerChangedComplete: function(responseText, responseXML){
diff --git a/public_html/includes/routes.php b/public_html/includes/routes.php
index 098f4e0c..37a557f0 100644
--- a/public_html/includes/routes.php
+++ b/public_html/includes/routes.php
@@ -46,6 +46,74 @@ function handle_index($request) {
}
LSurl :: add_handler('#^(index\.php)?$#', 'handle_index', true);
+/*
+ * Handle ajax keepLSsession request
+ *
+ * @param[in] $request LSurlRequest The request
+ *
+ * @retval void
+ **/
+function handle_ajax_keepLSsession($request) {
+ LSsession :: displayAjaxReturn(null);
+}
+LSurl :: add_handler('#^ajax/keepLSsession/?$#', 'handle_ajax_keepLSsession', true);
+
+/*
+ * Handle ajax request
+ *
+ * @param[in] $request LSurlRequest The request
+ *
+ * @retval void
+ **/
+function handle_ajax($request) {
+ $data = null;
+ switch ($request -> type) {
+ case 'class':
+ $class = $request -> type_value;
+ if (LSsession :: loadLSclass($class)) {
+ $meth = 'ajax_'.$request -> action;
+ if (method_exists($class, $meth)) {
+ $class :: $meth($data);
+ }
+ }
+ break;
+ case 'addon':
+ $addon = $request -> type_value;
+ if (LSsession :: loadLSaddon($addon)) {
+ $func = 'ajax_'.$request -> action;
+ if (function_exists($func)) {
+ $func = new ReflectionFunction($func);
+ if (basename($func->getFileName()) == "LSaddons.$addon.php") {
+ $func->invokeArgs(array(&$data));
+ }
+ else {
+ LSerror :: addErrorCode('LSsession_21',array('func' => $func -> getName(),'addon' => $addon));
+ }
+ }
+ }
+ break;
+ default:
+ LSlog :: fatal('Unsupported AJAX request type !');
+ exit();
+ }
+ LSsession :: displayAjaxReturn($data);
+}
+// TODO : find a proper solution for noLSsession URL parameter
+LSurl :: add_handler('#^ajax/(?Pclass|addon)/(?P[^/]+)/(?P[^/]+)/?$#', 'handle_ajax', (!isset($_REQUEST['noLSsession'])));
+
+/*
+ * Handle old index_ajax.php request for retro-compatibility
+ *
+ * @param[in] $request LSurlRequest The request
+ *
+ * @retval void
+ **/
+function handle_old_index_ajax_php($request) {
+ LSerror :: addErrorCode('LSsession_26', 'index_ajax.php');
+ LSsession :: displayAjaxReturn(null);
+}
+LSurl :: add_handler('#^index_ajax\.php#', 'handle_old_index_ajax_php');
+
/*
* Handle global seearch request
*
diff --git a/public_html/index_ajax.php b/public_html/index_ajax.php
deleted file mode 100644
index d4a4f953..00000000
--- a/public_html/index_ajax.php
+++ /dev/null
@@ -1,43 +0,0 @@
-getFileName())=="LSaddons.$addon.php") {
- $func->invokeArgs(array(&$data));
- }
- else {
- LSerror :: addErrorCode('LSsession_21',array('func' => $func -> getName(),'addon' => $addon));
- }
- }
- }
- }
-}
-
-LSsession :: displayAjaxReturn($data);