ldapsaisie/trunk/index_ajax.php
Benjamin Renard 7d2e3baf8b - Ajout de la gestion des droits (A étendre et debugger)
- Propagation des possibilités de l'interface
2008-02-08 17:39:24 +00:00

70 lines
2.2 KiB
PHP

<?php
require_once 'includes/functions.php';
require_once 'includes/class/class.LSsession.php';
$GLOBALS['LSsession'] = new LSsession();
$GLOBALS['LSsession'] -> loadLSobjects();
if ($_REQUEST['template'] != 'login') {
if ( !$GLOBALS['LSsession'] -> startLSsession() ) {
echo json_encode(array('LSerror' => 'LSsession : Impossible d\'initialiser la LSsession.' ));
}
}
switch($_REQUEST['template']) {
case 'login':
switch($_REQUEST['action']) {
case 'onLdapServerChanged':
if ( isset($_REQUEST['server']) ) {
$GLOBALS['LSsession'] -> setLdapServer($_REQUEST['server']);
if ( $GLOBALS['LSsession'] -> LSldapConnect() ) {
$list = $GLOBALS['LSsession'] -> getSubDnLdapServerOptions();
if (is_string($list)) {
$list="<select name='LSsession_topDn' id='LSsession_topDn'>".$list."</select>";
$data = array('list_topDn' => $list);
}
else if (is_array($list)){
$data = array('LSerror' => $GLOBALS['LSerror']->getErrors());
}
else {
$data = null;
}
}
else {
$data = array('LSerror' => $GLOBALS['LSerror']->getErrors());
}
}
else {
$data=NULL;
}
break;
}
break;
case 'LSform':
switch($_REQUEST['action']) {
case 'onAddFieldBtnClick':
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['objectdn'])) && (isset($_REQUEST['idform'])) && (isset($_REQUEST['img'])) ) {
$object = new $_REQUEST['objecttype']();
$object -> loadData($_REQUEST['objectdn']);
$form = $object -> getForm($_REQUEST['idform']);
$emptyField=$form -> getEmptyField($_REQUEST['attribute']);
if ( $emptyField ) {
$data = array(
'html' => $form -> getEmptyField($_REQUEST['attribute']),
'img' => $_REQUEST['img'],
);
}
else {
$data = array('LSerror' => $GLOBALS['LSerror']->getErrors());
}
}
else {
$data=NULL;
}
break;
}
break;
}
echo json_encode($data);
?>