2008-02-05 17:11:21 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once 'includes/functions.php';
|
|
|
|
require_once 'includes/class/class.LSsession.php';
|
|
|
|
|
|
|
|
$GLOBALS['LSsession'] = new LSsession();
|
|
|
|
|
2008-10-14 19:02:18 +02:00
|
|
|
if (($_REQUEST['template'] != 'login')&&($_REQUEST['template'] != 'recoverPassword')) {
|
2008-02-08 18:39:24 +01:00
|
|
|
if ( !$GLOBALS['LSsession'] -> startLSsession() ) {
|
2008-05-14 11:05:06 +02:00
|
|
|
$_ERRORS = 'LSsession : Impossible d\'initialiser la LSsession.';
|
2008-02-08 18:39:24 +01:00
|
|
|
}
|
2008-02-05 17:11:21 +01:00
|
|
|
}
|
2008-02-26 18:40:05 +01:00
|
|
|
$data=NULL;
|
2008-05-14 11:05:06 +02:00
|
|
|
if (!isset($_ERRORS)) {
|
|
|
|
switch($_REQUEST['template']) {
|
|
|
|
case 'login':
|
|
|
|
switch($_REQUEST['action']) {
|
|
|
|
case 'onLdapServerChanged':
|
|
|
|
if ( isset($_REQUEST['server']) ) {
|
|
|
|
$GLOBALS['LSsession'] -> setLdapServer($_REQUEST['server']);
|
2008-10-14 19:02:18 +02:00
|
|
|
$data = array();
|
2008-05-14 11:05:06 +02:00
|
|
|
if ( $GLOBALS['LSsession'] -> LSldapConnect() ) {
|
|
|
|
session_start();
|
|
|
|
$list = $GLOBALS['LSsession'] -> getSubDnLdapServerOptions($_SESSION['LSsession_topDn']);
|
|
|
|
if (is_string($list)) {
|
2008-10-14 19:02:18 +02:00
|
|
|
$data['list_topDn'] = "<select name='LSsession_topDn' id='LSsession_topDn'>".$list."</select>";
|
|
|
|
$data['levelLabel'] = $GLOBALS['LSsession'] -> getLevelLabel();
|
2008-05-14 11:05:06 +02:00
|
|
|
}
|
2008-02-08 18:39:24 +01:00
|
|
|
}
|
2008-10-14 19:02:18 +02:00
|
|
|
$data['recoverPassword'] = isset($GLOBALS['LSsession'] -> ldapServer['recoverPassword']);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'recoverPassword':
|
|
|
|
switch($_REQUEST['action']) {
|
|
|
|
case 'onLdapServerChanged':
|
|
|
|
if ( isset($_REQUEST['server']) ) {
|
|
|
|
$GLOBALS['LSsession'] -> setLdapServer($_REQUEST['server']);
|
|
|
|
$data=array('recoverPassword' => isset($GLOBALS['LSsession'] -> ldapServer['recoverPassword']));
|
2008-05-14 11:05:06 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'LSform':
|
|
|
|
switch($_REQUEST['action']) {
|
|
|
|
case 'onAddFieldBtnClick':
|
2008-10-15 19:40:04 +02:00
|
|
|
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['objectdn'])) && (isset($_REQUEST['idform'])) && (isset($_REQUEST['fieldId'])) ) {
|
2008-06-21 18:16:15 +02:00
|
|
|
if ($GLOBALS['LSsession'] -> loadLSobject($_REQUEST['objecttype'])) {
|
|
|
|
$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']),
|
2008-10-15 19:40:04 +02:00
|
|
|
'fieldId' => $_REQUEST['fieldId'],
|
2008-07-15 18:24:35 +02:00
|
|
|
'fieldtype' => get_class($form -> getElement($_REQUEST['attribute']))
|
2008-06-21 18:16:15 +02:00
|
|
|
);
|
|
|
|
}
|
2008-05-14 11:05:06 +02:00
|
|
|
}
|
2008-02-08 18:39:24 +01:00
|
|
|
else {
|
2008-06-21 18:16:15 +02:00
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$_REQUEST['objecttype']);
|
2008-02-08 18:39:24 +01:00
|
|
|
}
|
|
|
|
}
|
2008-05-14 11:05:06 +02:00
|
|
|
break;
|
|
|
|
case 'refreshField':
|
|
|
|
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['objectdn'])) && (isset($_REQUEST['idform'])) ) {
|
2008-06-21 18:16:15 +02:00
|
|
|
if ($GLOBALS['LSsession'] -> loadLSobject($_REQUEST['objecttype'])) {
|
|
|
|
$object = new $_REQUEST['objecttype']();
|
|
|
|
$form = $object -> getForm($_REQUEST['idform']);
|
|
|
|
$field=$form -> getElement($_REQUEST['attribute']);
|
|
|
|
$val = $field -> getDisplay(true);
|
|
|
|
if ( $val ) {
|
|
|
|
$data = array(
|
|
|
|
'html' => $val['html']
|
|
|
|
);
|
|
|
|
}
|
2008-05-14 11:05:06 +02:00
|
|
|
}
|
|
|
|
else {
|
2008-06-21 18:16:15 +02:00
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$_REQUEST['objecttype']);
|
2008-05-14 11:05:06 +02:00
|
|
|
}
|
2008-05-07 16:09:47 +02:00
|
|
|
}
|
2008-05-14 11:05:06 +02:00
|
|
|
break;
|
|
|
|
case 'generatePassword':
|
2008-10-16 14:01:26 +02:00
|
|
|
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['idform'])) ) {
|
2008-06-21 18:16:15 +02:00
|
|
|
if ($GLOBALS['LSsession'] -> loadLSobject($_REQUEST['objecttype'])) {
|
|
|
|
$object = new $_REQUEST['objecttype']();
|
|
|
|
$form = $object -> getForm($_REQUEST['idform']);
|
|
|
|
$field=$form -> getElement($_REQUEST['attribute']);
|
|
|
|
$val = $field -> generatePassword();
|
|
|
|
if ( $val ) {
|
|
|
|
$data = array(
|
2008-10-16 14:01:26 +02:00
|
|
|
'generatePassword' => $val
|
2008-06-21 18:16:15 +02:00
|
|
|
);
|
|
|
|
}
|
2008-05-14 11:05:06 +02:00
|
|
|
}
|
|
|
|
else {
|
2008-06-21 18:16:15 +02:00
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$_REQUEST['objecttype']);
|
2008-05-14 11:05:06 +02:00
|
|
|
}
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
2008-05-14 11:05:06 +02:00
|
|
|
break;
|
2008-06-19 16:07:57 +02:00
|
|
|
case 'verifyPassword':
|
2008-10-16 14:01:26 +02:00
|
|
|
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['fieldValue'])) && (isset($_REQUEST['idform'])) && (isset($_REQUEST['objectdn'])) ) {
|
2008-06-21 18:16:15 +02:00
|
|
|
if ($GLOBALS['LSsession'] -> loadLSobject($_REQUEST['objecttype'])) {
|
|
|
|
$object = new $_REQUEST['objecttype']();
|
|
|
|
$form = $object -> getForm($_REQUEST['idform']);
|
|
|
|
$object -> loadData($_REQUEST['objectdn']);
|
|
|
|
$field=$form -> getElement($_REQUEST['attribute']);
|
|
|
|
$val = $field -> verifyPassword($_REQUEST['fieldValue']);
|
|
|
|
$data = array(
|
2008-10-16 14:01:26 +02:00
|
|
|
'verifyPassword' => $val
|
2008-06-21 18:16:15 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$_REQUEST['objecttype']);
|
|
|
|
}
|
2008-06-19 16:07:57 +02:00
|
|
|
}
|
|
|
|
break;
|
2008-05-14 11:05:06 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'LSrelation':
|
|
|
|
switch($_REQUEST['action']) {
|
|
|
|
case 'refreshSession':
|
|
|
|
if ((isset($_REQUEST['id'])) && (isset($_REQUEST['href'])) ) {
|
|
|
|
if (isset($_SESSION['LSrelation'][$_REQUEST['id']])) {
|
|
|
|
$conf = $_SESSION['LSrelation'][$_REQUEST['id']];
|
|
|
|
if ($GLOBALS['LSsession']->loadLSobject($conf['objectType'])) {
|
|
|
|
$object = new $conf['objectType']();
|
|
|
|
if (($object -> loadData($conf['objectDn'])) && (isset($object->config['relations'][$conf['relationName']]))) {
|
|
|
|
$relationConf = $object->config['relations'][$conf['relationName']];
|
2008-06-21 18:16:15 +02:00
|
|
|
if ($GLOBALS['LSsession'] -> loadLSobject($relationConf['LSobject'])) {
|
2008-10-08 16:50:48 +02:00
|
|
|
if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$object -> getType(),$conf['relationName'])) {
|
2008-06-21 18:16:15 +02:00
|
|
|
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
|
|
|
|
$objRel = new $relationConf['LSobject']();
|
|
|
|
$list = $objRel -> $relationConf['list_function']($object);
|
|
|
|
$_SESSION['LSselect'][$relationConf['LSobject']]=array();
|
|
|
|
if (is_array($list)) {
|
|
|
|
foreach($list as $o) {
|
|
|
|
$_SESSION['LSselect'][$relationConf['LSobject']][] = $o -> getDn();
|
|
|
|
}
|
2008-05-14 11:05:06 +02:00
|
|
|
}
|
2008-06-21 18:16:15 +02:00
|
|
|
$data = array(
|
|
|
|
'href' => $_REQUEST['href'],
|
|
|
|
'id' => $_REQUEST['id']
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1013,$relationName);
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
2008-05-14 11:05:06 +02:00
|
|
|
}
|
|
|
|
else {
|
2008-06-21 18:16:15 +02:00
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1011);
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2008-06-21 18:16:15 +02:00
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$relationConf['LSobject']);
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2008-05-14 11:05:06 +02:00
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
|
|
|
}
|
|
|
|
}
|
2008-05-14 11:05:06 +02:00
|
|
|
break;
|
|
|
|
case 'refreshList':
|
|
|
|
if (isset($_REQUEST['id'])) {
|
|
|
|
if (isset($_SESSION['LSrelation'][$_REQUEST['id']])) {
|
|
|
|
$conf = $_SESSION['LSrelation'][$_REQUEST['id']];
|
|
|
|
if ($GLOBALS['LSsession']->loadLSobject($conf['objectType'])) {
|
|
|
|
$object = new $conf['objectType']();
|
|
|
|
if (($object -> loadData($conf['objectDn'])) && (isset($object->config['relations'][$conf['relationName']]))) {
|
|
|
|
$relationConf = $object->config['relations'][$conf['relationName']];
|
2008-06-21 18:16:15 +02:00
|
|
|
if ($GLOBALS['LSsession'] -> loadLSobject($relationConf['LSobject'])) {
|
2008-10-08 16:50:48 +02:00
|
|
|
if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$object -> getType(),$conf['relationName'])) {
|
2008-06-21 18:16:15 +02:00
|
|
|
if (is_array($_SESSION['LSselect'][$relationConf['LSobject']])) {
|
|
|
|
if (method_exists($relationConf['LSobject'],$relationConf['update_function'])) {
|
|
|
|
$objRel = new $relationConf['LSobject']();
|
|
|
|
if($objRel -> $relationConf['update_function']($object,$_SESSION['LSselect'][$relationConf['LSobject']])) {
|
|
|
|
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
|
|
|
|
$list = $objRel -> $relationConf['list_function']($object);
|
2008-10-08 17:34:36 +02:00
|
|
|
if (is_array($list)&&(!empty($list))) {
|
2008-06-21 18:16:15 +02:00
|
|
|
foreach($list as $o) {
|
2008-10-08 17:34:36 +02:00
|
|
|
$data['html'].= "<li class='LSrelation'><a href='view.php?LSobject=".$relationConf['LSobject']."&dn=".$o -> getDn()."' class='LSrelation' id='".$o -> getDn()."'>".$o -> getDisplayValue(NULL,true)."</a></li>\n";
|
2008-06-21 18:16:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2008-10-08 17:34:36 +02:00
|
|
|
if (isset($relationConf['emptyText'])) {
|
|
|
|
$data['html'] = "<li>".$relationConf['emptyText']."</li>\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$data['html'] = "<li>"._('Aucun objet en relation.')."</li>\n";
|
|
|
|
}
|
2008-05-14 11:05:06 +02:00
|
|
|
}
|
2008-06-21 18:16:15 +02:00
|
|
|
$data['id'] = $_REQUEST['id'];
|
2008-05-14 11:05:06 +02:00
|
|
|
}
|
|
|
|
else {
|
2008-06-21 18:16:15 +02:00
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1013,$relationName);
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2008-06-21 18:16:15 +02:00
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1015,$relationName);
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2008-06-21 18:16:15 +02:00
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1014,$relationName);
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
}
|
2008-06-21 18:16:15 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1011);
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
2008-05-14 11:05:06 +02:00
|
|
|
}
|
|
|
|
else {
|
2008-06-21 18:16:15 +02:00
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$relationConf['LSobject']);
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2008-05-14 11:05:06 +02:00
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
|
|
|
}
|
|
|
|
}
|
2008-05-14 11:05:06 +02:00
|
|
|
break;
|
2008-07-05 22:28:49 +02:00
|
|
|
case 'deleteByDn':
|
|
|
|
if ((isset($_REQUEST['id'])) && (isset($_REQUEST['dn']))) {
|
2008-05-14 11:05:06 +02:00
|
|
|
if (isset($_SESSION['LSrelation'][$_REQUEST['id']])) {
|
|
|
|
$conf = $_SESSION['LSrelation'][$_REQUEST['id']];
|
|
|
|
if ($GLOBALS['LSsession']->loadLSobject($conf['objectType'])) {
|
|
|
|
$object = new $conf['objectType']();
|
|
|
|
if (($object -> loadData($conf['objectDn'])) && (isset($object->config['relations'][$conf['relationName']]))) {
|
|
|
|
$relationConf = $object->config['relations'][$conf['relationName']];
|
2008-06-21 18:16:15 +02:00
|
|
|
if ($GLOBALS['LSsession'] -> loadLSobject($relationConf['LSobject'])) {
|
2008-10-08 16:50:48 +02:00
|
|
|
if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$object -> getType(),$conf['relationName'])) {
|
2008-06-21 18:16:15 +02:00
|
|
|
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
|
|
|
|
$objRel = new $relationConf['LSobject']();
|
|
|
|
$list = $objRel -> $relationConf['list_function']($object);
|
|
|
|
if (is_array($list)) {
|
|
|
|
$ok=false;
|
|
|
|
foreach($list as $o) {
|
2008-07-05 22:28:49 +02:00
|
|
|
if($o -> getDn() == $_REQUEST['dn']) {
|
2008-07-29 15:45:02 +02:00
|
|
|
if (!$o -> $relationConf['remove_function']($object)) {
|
2008-06-21 18:16:15 +02:00
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1015,$conf['relationName']);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$ok = true;
|
|
|
|
}
|
2008-05-14 11:05:06 +02:00
|
|
|
}
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
2008-06-21 18:16:15 +02:00
|
|
|
if (!$ok) {
|
2008-09-26 20:03:56 +02:00
|
|
|
LSdebug($_REQUEST['value']." introuvé parmi la liste");
|
2008-06-21 18:16:15 +02:00
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1015,$conf['relationName']);
|
|
|
|
}
|
2008-07-05 22:28:49 +02:00
|
|
|
else {
|
|
|
|
$data=array(
|
|
|
|
'dn' => $_REQUEST['dn']
|
|
|
|
);
|
|
|
|
}
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
2008-06-21 18:16:15 +02:00
|
|
|
else {
|
2008-05-14 11:05:06 +02:00
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1015,$conf['relationName']);
|
2008-06-21 18:16:15 +02:00
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1);
|
2008-05-14 11:05:06 +02:00
|
|
|
}
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
2008-05-14 11:05:06 +02:00
|
|
|
else {
|
2008-06-21 18:16:15 +02:00
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1013,$conf['relationName']);
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2008-06-21 18:16:15 +02:00
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1011);
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2008-06-21 18:16:15 +02:00
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$relationConf['LSobject']);
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2008-05-14 11:05:06 +02:00
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
|
|
|
}
|
|
|
|
}
|
2008-05-14 11:05:06 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'LSselect':
|
|
|
|
switch($_REQUEST['action']) {
|
|
|
|
case 'addLSselectobject-item':
|
2008-09-28 13:05:02 +02:00
|
|
|
if ((isset($_REQUEST['objecttype'])) && (isset($_REQUEST['objectdn'])) && (isset($_REQUEST['multiple']))) {
|
|
|
|
if (!$_REQUEST['multiple']) {
|
|
|
|
$_SESSION['LSselect'][$_REQUEST['objecttype']]=array($_REQUEST['objectdn']);
|
|
|
|
}
|
|
|
|
else if (is_array($_SESSION['LSselect'][$_REQUEST['objecttype']])) {
|
2008-05-14 11:05:06 +02:00
|
|
|
if (!in_array($_REQUEST['objectdn'],$_SESSION['LSselect'][$_REQUEST['objecttype']])) {
|
|
|
|
$_SESSION['LSselect'][$_REQUEST['objecttype']][]=$_REQUEST['objectdn'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2008-02-26 18:40:05 +01:00
|
|
|
$_SESSION['LSselect'][$_REQUEST['objecttype']][]=$_REQUEST['objectdn'];
|
|
|
|
}
|
|
|
|
}
|
2008-05-14 11:05:06 +02:00
|
|
|
break;
|
|
|
|
case 'dropLSselectobject-item':
|
|
|
|
if ((isset($_REQUEST['objecttype'])) && (isset($_REQUEST['objectdn']))) {
|
|
|
|
if (is_array($_SESSION['LSselect'][$_REQUEST['objecttype']])) {
|
|
|
|
$result=array();
|
|
|
|
foreach ($_SESSION['LSselect'][$_REQUEST['objecttype']] as $val) {
|
|
|
|
if ($val!=$_REQUEST['objectdn']) {
|
|
|
|
$result[]=$val;
|
|
|
|
}
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
2008-05-14 11:05:06 +02:00
|
|
|
$_SESSION['LSselect'][$_REQUEST['objecttype']]=$result;
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
|
|
|
}
|
2008-05-14 11:05:06 +02:00
|
|
|
break;
|
|
|
|
case 'refreshSession':
|
2008-09-28 13:05:02 +02:00
|
|
|
if ((isset($_REQUEST['objecttype'])) && (isset($_REQUEST['values'])) ) {
|
2008-05-14 11:05:06 +02:00
|
|
|
$_SESSION['LSselect'][$_REQUEST['objecttype']]=array();
|
|
|
|
$values=json_decode($_REQUEST['values'],false);
|
|
|
|
if (is_array($values)) {
|
|
|
|
foreach($values as $val) {
|
|
|
|
$_SESSION['LSselect'][$_REQUEST['objecttype']][]=$val;
|
|
|
|
}
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
2008-05-14 11:05:06 +02:00
|
|
|
$data=array(
|
|
|
|
'values' => $values
|
|
|
|
);
|
2008-02-26 18:40:05 +01:00
|
|
|
}
|
2008-05-14 11:05:06 +02:00
|
|
|
else {
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2008-09-25 17:15:33 +02:00
|
|
|
case 'LSmail':
|
|
|
|
switch($_REQUEST['action']) {
|
|
|
|
case 'display':
|
2008-10-31 13:12:31 +01:00
|
|
|
if (isset($_REQUEST['object']['type']) && isset($_REQUEST['object']['dn'])) {
|
|
|
|
if ($GLOBALS['LSsession']->loadLSobject($_REQUEST['object']['type'])) {
|
|
|
|
$obj = new $_REQUEST['object']['type']();
|
|
|
|
$obj -> loadData($_REQUEST['object']['dn']);
|
|
|
|
$msg = $obj -> getFData($_REQUEST['msg']);
|
|
|
|
$subject = $obj -> getFData($_REQUEST['subject']);
|
2008-09-25 17:15:33 +02:00
|
|
|
}
|
|
|
|
else {
|
2008-10-31 13:12:31 +01:00
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$_REQUEST['object']['type']);
|
2008-09-25 17:15:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2008-10-31 13:12:31 +01:00
|
|
|
$msg = $_REQUEST['msg'];
|
|
|
|
$subject = $_REQUEST['subject'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$GLOBALS['Smarty'] -> assign('LSmail_msg',$msg);
|
|
|
|
$GLOBALS['Smarty'] -> assign('LSmail_subject',$subject);
|
|
|
|
if (is_array($_REQUEST['mails'])) {
|
|
|
|
$GLOBALS['Smarty'] -> assign('LSmail_mails',$_REQUEST['mails']);
|
|
|
|
}
|
|
|
|
else if(empty($_REQUEST['mails'])) {
|
|
|
|
$GLOBALS['Smarty'] -> assign('LSmail_mails',array($_REQUEST['mails']));
|
|
|
|
}
|
|
|
|
$GLOBALS['Smarty'] -> assign('LSmail_mail_label',_('E-mail'));
|
|
|
|
$GLOBALS['Smarty'] -> assign('LSmail_subject_label',_('Sujet'));
|
|
|
|
$GLOBALS['Smarty'] -> assign('LSmail_msg_label',_('Message'));
|
|
|
|
|
|
|
|
$data = array(
|
|
|
|
'html' => $GLOBALS['Smarty'] -> fetch('LSmail.tpl')
|
|
|
|
);
|
2008-09-25 17:15:33 +02:00
|
|
|
break;
|
|
|
|
case 'send':
|
|
|
|
if (isset($_REQUEST['infos'])) {
|
|
|
|
if ($GLOBALS['LSsession'] -> loadLSaddon('mail')) {
|
|
|
|
if(sendMail($_REQUEST['infos']['mail'],$_REQUEST['infos']['subject'],$_REQUEST['infos']['msg'])) {
|
|
|
|
$data = array(
|
|
|
|
'msgok' => _("Votre message a bien été envoyé.")
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2008-05-14 11:05:06 +02:00
|
|
|
}
|
2008-02-05 17:11:21 +01:00
|
|
|
}
|
|
|
|
|
2008-02-26 18:40:05 +01:00
|
|
|
if ($GLOBALS['LSerror']->errorsDefined()) {
|
|
|
|
$data['LSerror'] = $GLOBALS['LSerror']->getErrors();
|
|
|
|
}
|
2008-05-14 11:05:06 +02:00
|
|
|
else if (isset($_ERRORS)) {
|
|
|
|
$data['LSerror'] = $_ERRORS;
|
|
|
|
}
|
2008-02-26 18:40:05 +01:00
|
|
|
|
2008-05-07 16:09:47 +02:00
|
|
|
if (isset($_REQUEST['imgload'])) {
|
|
|
|
$data['imgload'] = $_REQUEST['imgload'];
|
|
|
|
}
|
|
|
|
|
2008-10-13 12:58:48 +02:00
|
|
|
if (LSdebugDefined()) {
|
|
|
|
$data['LSdebug'] = LSdebug_print(true);
|
2008-04-25 15:48:12 +02:00
|
|
|
}
|
|
|
|
|
2008-02-05 17:11:21 +01:00
|
|
|
echo json_encode($data);
|
|
|
|
?>
|