mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-12-18 14:33:49 +01:00
- Modifications diverses suite à plusieurs mise en production :
- Correction de bugs - Passage à Net_LDAP2 - Ajout du changement de niveau de l'annuaire durant la navigation
This commit is contained in:
parent
1e2316d76f
commit
748c9d3ec3
24 changed files with 338 additions and 200 deletions
6
trunk/INSTALL
Normal file
6
trunk/INSTALL
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
Pré-requis :
|
||||||
|
- Php 5 : magic_quotes_gpc = off
|
||||||
|
- php5-mhash
|
||||||
|
- Net_LDAP2 (http://pear.php.net/package/Net_LDAP2)
|
||||||
|
- Smarty (http://www.smarty.net/)
|
||||||
|
- tmp/ et template_c/ en ecriture
|
|
@ -1,31 +0,0 @@
|
||||||
<?php
|
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (C) 2007 Easter-eggs
|
|
||||||
* http://ldapsaisie.labs.libre-entreprise.org
|
|
||||||
*
|
|
||||||
* Author: See AUTHORS file in top-level directory.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License version 2
|
|
||||||
* as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
define('LS_OBJECTS_DIR', LS_CONF_DIR . 'LSobjects/');
|
|
||||||
|
|
||||||
$GLOBALS['LSobjects_loads'] = array (
|
|
||||||
'LSeepeople',
|
|
||||||
'LSeegroup',
|
|
||||||
'LSeecompany'
|
|
||||||
);
|
|
||||||
|
|
||||||
?>
|
|
|
@ -258,7 +258,14 @@ $GLOBALS['LSerror_code'] = array (
|
||||||
1015 => array (
|
1015 => array (
|
||||||
'msg' => _("LSrelations : Une erreur s'est produite durant la mise a jour de la relation %{relation}."),
|
'msg' => _("LSrelations : Une erreur s'est produite durant la mise a jour de la relation %{relation}."),
|
||||||
'level' => 'c'
|
'level' => 'c'
|
||||||
|
),
|
||||||
|
1016 => array (
|
||||||
|
'msg' => _("LSrelations : L'objet %{LSobject} de la relation %{relation} est inconnu."),
|
||||||
|
'level' => 'w'
|
||||||
|
),
|
||||||
|
1017 => array (
|
||||||
|
'msg' => _("LSsession : Impossible de créer correctement la liste des niveaux. Vérifier la configuration."),
|
||||||
|
'level' => 'c'
|
||||||
)
|
)
|
||||||
|
|
||||||
);
|
);
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -22,10 +22,10 @@
|
||||||
|
|
||||||
// Configuration LDAP Saisie :
|
// Configuration LDAP Saisie :
|
||||||
$GLOBALS['LSconfig'] = array(
|
$GLOBALS['LSconfig'] = array(
|
||||||
'NetLDAP' => '/usr/share/php/Net/LDAP.php',
|
'NetLDAP2' => '/usr/share/php/Net/LDAP2.php',
|
||||||
'Smarty' => '/var/www/tmp/Smarty-2.6.18/libs/Smarty.class.php',
|
'Smarty' => '/var/www/tmp/Smarty-2.6.18/libs/Smarty.class.php',
|
||||||
'lang' => 'fr_FR.UTF8',
|
'lang' => 'fr_FR.UTF8',
|
||||||
'cacheLSrights' => true,
|
'cacheLSrights' => false,
|
||||||
'ldap_servers' => array (
|
'ldap_servers' => array (
|
||||||
array (
|
array (
|
||||||
'name' => 'LSexample',
|
'name' => 'LSexample',
|
||||||
|
@ -54,25 +54,12 @@ $GLOBALS['LSconfig'] = array(
|
||||||
),
|
),
|
||||||
'cacheLSrights' => false,
|
'cacheLSrights' => false,
|
||||||
'authobject' => 'LSeepeople',
|
'authobject' => 'LSeepeople',
|
||||||
'authobject_pwdattr' => 'userPassword'
|
'authobject_pwdattr' => 'userPassword',
|
||||||
),
|
'LSobjects' => array (
|
||||||
array (
|
'LSeepeople',
|
||||||
'name' => 'Ldap 2',
|
'LSeegroup',
|
||||||
'ldap_config'=> array(
|
'LSeecompany'
|
||||||
'host' => '127.0.0.1',
|
)
|
||||||
'port' => 389,
|
|
||||||
'version' => 3,
|
|
||||||
'starttls' => false,
|
|
||||||
'binddn' => 'uid=toto,ou=people,o=com',
|
|
||||||
'bindpw' => 'toto',
|
|
||||||
'basedn' => 'o=com',
|
|
||||||
'options' => array(),
|
|
||||||
'filter' => '(objectClass=*)',
|
|
||||||
'scope' => 'sub'
|
|
||||||
),
|
|
||||||
'subdnobject' => 'LSeecompany',
|
|
||||||
'authobject' => 'LSeepeople',
|
|
||||||
'authobject_pwdattr' => 'userPassword'
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -80,7 +67,8 @@ $GLOBALS['LSconfig'] = array(
|
||||||
//Debug
|
//Debug
|
||||||
$GLOBALS['LSdebug']['active'] = true;
|
$GLOBALS['LSdebug']['active'] = true;
|
||||||
|
|
||||||
define('NB_LSOBJECT_LIST',2);
|
define('NB_LSOBJECT_LIST',20);
|
||||||
|
define('NB_LSOBJECT_LIST_SELECT',11);
|
||||||
|
|
||||||
define('MAX_SEND_FILE_SIZE',2000000);
|
define('MAX_SEND_FILE_SIZE',2000000);
|
||||||
|
|
||||||
|
@ -92,6 +80,7 @@ setlocale(LC_ALL, $GLOBALS['LSconfig']['lang']);
|
||||||
|
|
||||||
// Définitions des dossiers d'inclusions
|
// Définitions des dossiers d'inclusions
|
||||||
define('LS_CONF_DIR','conf/');
|
define('LS_CONF_DIR','conf/');
|
||||||
|
define('LS_OBJECTS_DIR', LS_CONF_DIR . 'LSobjects/');
|
||||||
define('LS_INCLUDE_DIR','includes/');
|
define('LS_INCLUDE_DIR','includes/');
|
||||||
define('LS_CLASS_DIR', LS_INCLUDE_DIR .'class/');
|
define('LS_CLASS_DIR', LS_INCLUDE_DIR .'class/');
|
||||||
define('LS_LIB_DIR', LS_INCLUDE_DIR .'libs/');
|
define('LS_LIB_DIR', LS_INCLUDE_DIR .'libs/');
|
||||||
|
|
|
@ -84,6 +84,10 @@ class LSattr_html_select_list extends LSattr_html{
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(102,$this -> name);
|
$GLOBALS['LSerror'] -> addErrorCode(102,$this -> name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (!$GLOBALS['LSsession'] -> loadLSobject($val['object_type'])) {
|
||||||
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$val['object_type']);
|
||||||
|
return;
|
||||||
|
}
|
||||||
$obj = new $val['object_type']();
|
$obj = new $val['object_type']();
|
||||||
if($val['scope']) {
|
if($val['scope']) {
|
||||||
$param=array('scope' => $this -> config['possible_values']['scope']);
|
$param=array('scope' => $this -> config['possible_values']['scope']);
|
||||||
|
|
|
@ -261,12 +261,12 @@ class LSattribute {
|
||||||
break;
|
break;
|
||||||
case 'self':
|
case 'self':
|
||||||
if (($this -> config['rights']['self'] == 'w') || ($this -> config['rights']['self'] == 'r')) {
|
if (($this -> config['rights']['self'] == 'w') || ($this -> config['rights']['self'] == 'r')) {
|
||||||
$return=$this -> config['self'];
|
$return=$this -> config['rights']['self'];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default: //user
|
default: //user
|
||||||
if (($this -> config['rights']['user'] == 'w') || ($this -> config['rights']['user'] == 'r')) {
|
if (($this -> config['rights']['user'] == 'w') || ($this -> config['rights']['user'] == 'r')) {
|
||||||
$return=$this -> config['user'];
|
$return=$this -> config['rights']['user'];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -314,8 +314,8 @@ class LSattribute {
|
||||||
* @retval boolean true si la valeur a été rafraichie ou que ce n'est pas nécessaire, false sinon
|
* @retval boolean true si la valeur a été rafraichie ou que ce n'est pas nécessaire, false sinon
|
||||||
*/
|
*/
|
||||||
function refreshForm(&$form,$idForm) {
|
function refreshForm(&$form,$idForm) {
|
||||||
if(isset($this -> config['form'][$idForm])) {
|
if(isset($this -> config['form'][$idForm]) && ($this -> myRights()=='w')) {
|
||||||
$form_element = &$form -> getElement($this -> name);
|
$form_element = $form -> getElement($this -> name);
|
||||||
$values = $this -> html -> refreshForm($this -> getFormVal());
|
$values = $this -> html -> refreshForm($this -> getFormVal());
|
||||||
return $form_element -> setValue($values);
|
return $form_element -> setValue($values);
|
||||||
}
|
}
|
||||||
|
@ -420,7 +420,7 @@ class LSattribute {
|
||||||
$value=call_user_func($this -> config['generate_function'],$this -> ldapObject);
|
$value=call_user_func($this -> config['generate_function'],$this -> ldapObject);
|
||||||
if (!empty($value)) {
|
if (!empty($value)) {
|
||||||
//$this -> setValue($value); // pas nécéssaire ??
|
//$this -> setValue($value); // pas nécéssaire ??
|
||||||
$this -> updateData=$value;
|
$this -> updateData=array($value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -65,7 +65,7 @@ class LSformElement_select_object extends LSformElement {
|
||||||
$return['html']="<ul class='LSform ".$class."' id='LSformElement_select_object_".$this -> name."_$id'>\n";
|
$return['html']="<ul class='LSform ".$class."' id='LSformElement_select_object_".$this -> name."_$id'>\n";
|
||||||
$return['html'].=$addBtn;
|
$return['html'].=$addBtn;
|
||||||
foreach ($this -> values as $value => $txt) {
|
foreach ($this -> values as $value => $txt) {
|
||||||
$return['html'].="<li class='LSform ".$class."'>".$txt."<input type='hidden' class='LSformElement_select_object' name='".$this -> name."[]' value='".$value."' />$delete</li>";
|
$return['html'].="<li class='LSform ".$class."'>".$txt."<input type='hidden' class='LSformElement_select_object' name='".$this -> name."[]' value='".$value."' />$delete</li>\n";
|
||||||
}
|
}
|
||||||
$return['html'].="</ul>\n";
|
$return['html'].="</ul>\n";
|
||||||
if (!$this -> isFreeze()) {
|
if (!$this -> isFreeze()) {
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
/**
|
/**
|
||||||
* Gestion de l'accès à l'annaire Ldap
|
* Gestion de l'accès à l'annaire Ldap
|
||||||
*
|
*
|
||||||
* Cette classe gère l'accès à l'annuaire ldap en s'appuyant sur PEAR :: Net_LDAP
|
* Cette classe gère l'accès à l'annuaire ldap en s'appuyant sur PEAR :: Net_LDAP2
|
||||||
*
|
*
|
||||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||||
*/
|
*/
|
||||||
|
@ -40,11 +40,11 @@ class LSldap {
|
||||||
*
|
*
|
||||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||||
*
|
*
|
||||||
* @param[in] $config array Tableau de configuration au formar Net_LDAP
|
* @param[in] $config array Tableau de configuration au formar Net_LDAP2
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
*
|
*
|
||||||
* @see Net_LDAP::connect()
|
* @see Net_LDAP2::connect()
|
||||||
*/
|
*/
|
||||||
function LSldap ($config) {
|
function LSldap ($config) {
|
||||||
$this -> config = $config;
|
$this -> config = $config;
|
||||||
|
@ -61,8 +61,8 @@ class LSldap {
|
||||||
* @retval boolean true si la connection est établie, false sinon
|
* @retval boolean true si la connection est établie, false sinon
|
||||||
*/
|
*/
|
||||||
function connect() {
|
function connect() {
|
||||||
$this -> cnx = Net_LDAP::connect($this -> config);
|
$this -> cnx = Net_LDAP2::connect($this -> config);
|
||||||
if (Net_LDAP::isError($this -> cnx)) {
|
if (Net_LDAP2::isError($this -> cnx)) {
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1,$this -> cnx -> getMessage());
|
$GLOBALS['LSerror'] -> addErrorCode(1,$this -> cnx -> getMessage());
|
||||||
$this -> cnx = NULL;
|
$this -> cnx = NULL;
|
||||||
return;
|
return;
|
||||||
|
@ -93,9 +93,9 @@ class LSldap {
|
||||||
*
|
*
|
||||||
* @param[in] $filter [<b>required</b>] string Filtre de recherche Ldap
|
* @param[in] $filter [<b>required</b>] string Filtre de recherche Ldap
|
||||||
* @param[in] $basedn string DN de base pour la recherche
|
* @param[in] $basedn string DN de base pour la recherche
|
||||||
* @param[in] $params array Paramètres de recherche au format Net_LDAP::search()
|
* @param[in] $params array Paramètres de recherche au format Net_LDAP2::search()
|
||||||
*
|
*
|
||||||
* @see Net_LDAP::search()
|
* @see Net_LDAP2::search()
|
||||||
*
|
*
|
||||||
* @retval array Retourne un tableau associatif contenant :
|
* @retval array Retourne un tableau associatif contenant :
|
||||||
* - ['dn'] : le DN de l'entré
|
* - ['dn'] : le DN de l'entré
|
||||||
|
@ -104,7 +104,7 @@ class LSldap {
|
||||||
*/
|
*/
|
||||||
function search ($filter,$basedn=NULL,$params = array()) {
|
function search ($filter,$basedn=NULL,$params = array()) {
|
||||||
$ret = $this -> cnx -> search($basedn,$filter,$params);
|
$ret = $this -> cnx -> search($basedn,$filter,$params);
|
||||||
if (Net_LDAP::isError($ret)) {
|
if (Net_LDAP2::isError($ret)) {
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(2,$ret -> getMessage());
|
$GLOBALS['LSerror'] -> addErrorCode(2,$ret -> getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -125,9 +125,9 @@ class LSldap {
|
||||||
*
|
*
|
||||||
* @param[in] $filter [<b>required</b>] string Filtre de recherche Ldap
|
* @param[in] $filter [<b>required</b>] string Filtre de recherche Ldap
|
||||||
* @param[in] $basedn string DN de base pour la recherche
|
* @param[in] $basedn string DN de base pour la recherche
|
||||||
* @param[in] $params array Paramètres de recherche au format Net_LDAP::search()
|
* @param[in] $params array Paramètres de recherche au format Net_LDAP2::search()
|
||||||
*
|
*
|
||||||
* @see Net_LDAP::search()
|
* @see Net_LDAP2::search()
|
||||||
*
|
*
|
||||||
* @retval numeric Le nombre d'entré trouvées
|
* @retval numeric Le nombre d'entré trouvées
|
||||||
*/
|
*/
|
||||||
|
@ -135,7 +135,7 @@ class LSldap {
|
||||||
if (empty($filter))
|
if (empty($filter))
|
||||||
$filter=NULL;
|
$filter=NULL;
|
||||||
$ret = $this -> cnx -> search($basedn,$filter,$params);
|
$ret = $this -> cnx -> search($basedn,$filter,$params);
|
||||||
if (Net_LDAP::isError($ret)) {
|
if (Net_LDAP2::isError($ret)) {
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(2,$ret -> getMessage());
|
$GLOBALS['LSerror'] -> addErrorCode(2,$ret -> getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -175,14 +175,14 @@ class LSldap {
|
||||||
* @param[in] $object_type string Type de l'objet Ldap
|
* @param[in] $object_type string Type de l'objet Ldap
|
||||||
* @param[in] $dn string DN de l'entré Ldap
|
* @param[in] $dn string DN de l'entré Ldap
|
||||||
*
|
*
|
||||||
* @retval ldapentry Un objet ldapentry (PEAR::Net_LDAP)
|
* @retval ldapentry Un objet ldapentry (PEAR::Net_LDAP2)
|
||||||
*/
|
*/
|
||||||
function getEntry($object_type,$dn) {
|
function getEntry($object_type,$dn) {
|
||||||
if(isset($GLOBALS['LSobjects'][$object_type])){
|
if(isset($GLOBALS['LSobjects'][$object_type])){
|
||||||
$obj_conf=$GLOBALS['LSobjects'][$object_type];
|
$obj_conf=$GLOBALS['LSobjects'][$object_type];
|
||||||
$entry = $this -> cnx -> getEntry($dn);
|
$entry = $this -> cnx -> getEntry($dn);
|
||||||
if (Net_Ldap::isError($entry)) {
|
if (Net_LDAP2::isError($entry)) {
|
||||||
$newentry = new Net_Ldap_Entry(&$this -> cnx);
|
$newentry = new Net_LDAP2_Entry(&$this -> cnx);
|
||||||
$newentry -> dn($dn);
|
$newentry -> dn($dn);
|
||||||
$newentry -> add(array('objectclass' => $obj_conf['objectclass']));
|
$newentry -> add(array('objectclass' => $obj_conf['objectclass']));
|
||||||
foreach($obj_conf['attrs'] as $attr_name => $attr_conf) {
|
foreach($obj_conf['attrs'] as $attr_name => $attr_conf) {
|
||||||
|
@ -227,6 +227,12 @@ class LSldap {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if (!empty($attrVal)) {
|
||||||
|
$drop = false;
|
||||||
|
$changeData[$attrName][]=$attrVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
if($drop) {
|
if($drop) {
|
||||||
$dropAttr[] = $attrName;
|
$dropAttr[] = $attrName;
|
||||||
}
|
}
|
||||||
|
@ -234,13 +240,14 @@ class LSldap {
|
||||||
$entry -> replace($changeData);
|
$entry -> replace($changeData);
|
||||||
debug('change : '.print_r($changeData,true));
|
debug('change : '.print_r($changeData,true));
|
||||||
debug('drop : '.print_r($dropAttr,true));
|
debug('drop : '.print_r($dropAttr,true));
|
||||||
|
|
||||||
|
$ret = $entry -> update();
|
||||||
if (!empty($dropAttr)) {
|
if (!empty($dropAttr)) {
|
||||||
foreach($dropAttr as $attr) {
|
foreach($dropAttr as $attr) {
|
||||||
$entry -> delete($attr);
|
$entry -> delete($attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$ret = $entry -> update();
|
if (Net_LDAP2::isError($ret)) {
|
||||||
if (Net_Ldap::isError($ret)) {
|
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(5,$dn);
|
$GLOBALS['LSerror'] -> addErrorCode(5,$dn);
|
||||||
debug('NetLdap-Error : '.$ret->getMessage());
|
debug('NetLdap-Error : '.$ret->getMessage());
|
||||||
}
|
}
|
||||||
|
@ -268,8 +275,8 @@ class LSldap {
|
||||||
$config = $this -> config;
|
$config = $this -> config;
|
||||||
$config['binddn'] = $dn;
|
$config['binddn'] = $dn;
|
||||||
$config['bindpw'] = $pwd;
|
$config['bindpw'] = $pwd;
|
||||||
$cnx = Net_LDAP::connect($config);
|
$cnx = Net_LDAP2::connect($config);
|
||||||
if (Net_LDAP::isError($cnx)) {
|
if (Net_LDAP2::isError($cnx)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -31,9 +31,9 @@ $GLOBALS['LSsession'] -> loadLSclass('LSattribute');
|
||||||
*/
|
*/
|
||||||
class LSldapObject {
|
class LSldapObject {
|
||||||
|
|
||||||
var $config;
|
var $config = array();
|
||||||
var $type_name;
|
var $type_name;
|
||||||
var $attrs;
|
var $attrs = array();
|
||||||
var $forms;
|
var $forms;
|
||||||
var $view;
|
var $view;
|
||||||
var $dn=false;
|
var $dn=false;
|
||||||
|
@ -572,7 +572,7 @@ class LSldapObject {
|
||||||
*
|
*
|
||||||
* @param[in] $filter array (ou string) Filtre de recherche Ldap / Tableau de filtres de recherche
|
* @param[in] $filter array (ou string) Filtre de recherche Ldap / Tableau de filtres de recherche
|
||||||
* @param[in] $basedn string DN de base pour la recherche
|
* @param[in] $basedn string DN de base pour la recherche
|
||||||
* @param[in] $params array Paramètres de recherche au format Net_LDAP::search()
|
* @param[in] $params array Paramètres de recherche au format Net_LDAP2::search()
|
||||||
*
|
*
|
||||||
* @retval array Tableau d'objet correspondant au resultat de la recherche
|
* @retval array Tableau d'objet correspondant au resultat de la recherche
|
||||||
*/
|
*/
|
||||||
|
@ -807,35 +807,18 @@ class LSldapObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retourn une liste d'option pour un select d'un objet du même type
|
|
||||||
*
|
|
||||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
||||||
*
|
|
||||||
* @retval string HTML code
|
|
||||||
*/
|
|
||||||
function getSelectOptions() {
|
|
||||||
$list = $this -> listObjects();
|
|
||||||
$display='';
|
|
||||||
foreach($list as $object) {
|
|
||||||
$display.="<option value=\"".$object -> getDn()."\">".$object -> getDisplayValue()."</option>\n";
|
|
||||||
}
|
|
||||||
return $display;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retourn un tableau pour un select d'un objet du même type
|
* Retourn un tableau pour un select d'un objet du même type
|
||||||
*
|
*
|
||||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||||
*
|
*
|
||||||
* @retval array['dn','display']
|
* @retval array('dn' => 'display')
|
||||||
*/
|
*/
|
||||||
function getSelectArray() {
|
function getSelectArray($topDn=NULL) {
|
||||||
$list = $this -> listObjects();
|
$list = $this -> listObjects(NULL,$topDn);
|
||||||
$return=array();
|
$return=array();
|
||||||
foreach($list as $object) {
|
foreach($list as $object) {
|
||||||
$return['dn'][] = $object -> getDn();
|
$return[$object -> getDn()] = $object -> getDisplayValue();
|
||||||
$return['display'][] = $object -> getDisplayValue();
|
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,12 +75,12 @@ class LSsession {
|
||||||
*/
|
*/
|
||||||
function loadConfig() {
|
function loadConfig() {
|
||||||
if (loadDir($this -> confDir, '^config\..*\.php$')) {
|
if (loadDir($this -> confDir, '^config\..*\.php$')) {
|
||||||
if ( @include_once $GLOBALS['LSconfig']['Smarty'] ) {
|
if ( include_once $GLOBALS['LSconfig']['Smarty'] ) {
|
||||||
$GLOBALS['Smarty'] = new Smarty();
|
$GLOBALS['Smarty'] = new Smarty();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1008);
|
die($GLOBALS['LSerror_code'][1008]['msg']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -121,7 +121,7 @@ class LSsession {
|
||||||
return true;
|
return true;
|
||||||
if($type!='')
|
if($type!='')
|
||||||
$type=$type.'.';
|
$type=$type.'.';
|
||||||
return @include_once LS_CLASS_DIR .'class.'.$type.$class.'.php';
|
return include_once LS_CLASS_DIR .'class.'.$type.$class.'.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -132,10 +132,13 @@ class LSsession {
|
||||||
* @retval boolean true si le chargement a réussi, false sinon.
|
* @retval boolean true si le chargement a réussi, false sinon.
|
||||||
*/
|
*/
|
||||||
function loadLSobject($object) {
|
function loadLSobject($object) {
|
||||||
if (!$this -> loadLSclass($object,'LSobjects'))
|
$this -> loadLSclass('LSldapObject');
|
||||||
|
if (!$this -> loadLSclass($object,'LSobjects')) {
|
||||||
return;
|
return;
|
||||||
if (!require_once( LS_OBJECTS_DIR . 'config.LSobjects.'.$object.'.php' ))
|
}
|
||||||
|
if (!require_once( LS_OBJECTS_DIR . 'config.LSobjects.'.$object.'.php' )) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +146,7 @@ class LSsession {
|
||||||
* Chargement des objects LdapSaisie
|
* Chargement des objects LdapSaisie
|
||||||
*
|
*
|
||||||
* Chargement des LSobjects contenue dans la variable
|
* Chargement des LSobjects contenue dans la variable
|
||||||
* $GLOBALS['LSobjects_loads']
|
* $this -> ldapServer['LSobjects']
|
||||||
*
|
*
|
||||||
* @retval boolean true si le chargement a réussi, false sinon.
|
* @retval boolean true si le chargement a réussi, false sinon.
|
||||||
*/
|
*/
|
||||||
|
@ -151,12 +154,12 @@ class LSsession {
|
||||||
|
|
||||||
$this -> loadLSclass('LSldapObject');
|
$this -> loadLSclass('LSldapObject');
|
||||||
|
|
||||||
if(!is_array($GLOBALS['LSobjects_loads'])) {
|
if(!is_array($this -> ldapServer['LSobjects'])) {
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1001,"LSobjects['loads']");
|
$GLOBALS['LSerror'] -> addErrorCode(1001,"LSobjects['loads']");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($GLOBALS['LSobjects_loads'] as $object) {
|
foreach ($this -> ldapServer['LSobjects'] as $object) {
|
||||||
if ( !$this -> loadLSobject($object) )
|
if ( !$this -> loadLSobject($object) )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -211,7 +214,6 @@ class LSsession {
|
||||||
* @retval boolean True si l'initialisation à réussi (utilisateur authentifié), false sinon.
|
* @retval boolean True si l'initialisation à réussi (utilisateur authentifié), false sinon.
|
||||||
*/
|
*/
|
||||||
function startLSsession() {
|
function startLSsession() {
|
||||||
$this -> loadLSobjects();
|
|
||||||
$this -> loadLSaddons();
|
$this -> loadLSaddons();
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
|
@ -235,23 +237,35 @@ class LSsession {
|
||||||
$this -> rdn = $_SESSION['LSsession']['rdn'];
|
$this -> rdn = $_SESSION['LSsession']['rdn'];
|
||||||
$this -> ldapServerId = $_SESSION['LSsession']['ldapServerId'];
|
$this -> ldapServerId = $_SESSION['LSsession']['ldapServerId'];
|
||||||
$this -> tmp_file = $_SESSION['LSsession']['tmp_file'];
|
$this -> tmp_file = $_SESSION['LSsession']['tmp_file'];
|
||||||
|
|
||||||
if ( ($GLOBALS['LSconfig']['cacheLSrights']) || ($this -> ldapServer['cacheLSrights']) ) {
|
if ( ($GLOBALS['LSconfig']['cacheLSrights']) || ($this -> ldapServer['cacheLSrights']) ) {
|
||||||
$this -> ldapServer = $_SESSION['LSsession']['ldapServer'];
|
$this -> ldapServer = $_SESSION['LSsession']['ldapServer'];
|
||||||
$this -> LSrights = $_SESSION['LSsession']['LSrights'];
|
$this -> LSrights = $_SESSION['LSsession']['LSrights'];
|
||||||
$this -> LSaccess = $_SESSION['LSsession']['LSaccess'];
|
$this -> LSaccess = $_SESSION['LSsession']['LSaccess'];
|
||||||
if (!$this -> LSldapConnect())
|
if (!$this -> LSldapConnect())
|
||||||
return;
|
return;
|
||||||
|
$this -> loadLSobjects();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$this -> setLdapServer($this -> ldapServerId);
|
$this -> setLdapServer($this -> ldapServerId);
|
||||||
if (!$this -> LSldapConnect())
|
if (!$this -> LSldapConnect())
|
||||||
return;
|
return;
|
||||||
|
$this -> loadLSobjects();
|
||||||
$this -> loadLSrights();
|
$this -> loadLSrights();
|
||||||
}
|
}
|
||||||
|
$this -> loadLSobject($this -> ldapServer['authobject']);
|
||||||
$this -> LSuserObject = new $this -> ldapServer['authobject']();
|
$this -> LSuserObject = new $this -> ldapServer['authobject']();
|
||||||
$this -> LSuserObject -> loadData($this -> dn);
|
$this -> LSuserObject -> loadData($this -> dn);
|
||||||
$this -> loadLSaccess();
|
$this -> loadLSaccess();
|
||||||
$GLOBALS['Smarty'] -> assign('LSsession_username',$this -> LSuserObject -> getDisplayValue());
|
$GLOBALS['Smarty'] -> assign('LSsession_username',$this -> LSuserObject -> getDisplayValue());
|
||||||
|
|
||||||
|
if ($_POST['LSsession_topDn']) {
|
||||||
|
if ($this -> validSubDnLdapServer($_POST['LSsession_topDn'])) {
|
||||||
|
$this -> topDn = $_POST['LSsession_topDn'];
|
||||||
|
$_SESSION['LSsession']['topDn'] = $_POST['LSsession_topDn'];
|
||||||
|
} // end if
|
||||||
|
} // end if
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -268,6 +282,7 @@ class LSsession {
|
||||||
|
|
||||||
// Connexion au serveur LDAP
|
// Connexion au serveur LDAP
|
||||||
if ($this -> LSldapConnect()) {
|
if ($this -> LSldapConnect()) {
|
||||||
|
|
||||||
// topDn
|
// topDn
|
||||||
if ( $_POST['LSsession_topDn'] != '' ){
|
if ( $_POST['LSsession_topDn'] != '' ){
|
||||||
$this -> topDn = $_POST['LSsession_topDn'];
|
$this -> topDn = $_POST['LSsession_topDn'];
|
||||||
|
@ -275,6 +290,7 @@ class LSsession {
|
||||||
else {
|
else {
|
||||||
$this -> topDn = $this -> ldapServer['ldap_config']['basedn'];
|
$this -> topDn = $this -> ldapServer['ldap_config']['basedn'];
|
||||||
}
|
}
|
||||||
|
$_SESSION['LSsession_topDn']=$this -> topDn;
|
||||||
|
|
||||||
if ( $this -> loadLSobject($this -> ldapServer['authobject']) ) {
|
if ( $this -> loadLSobject($this -> ldapServer['authobject']) ) {
|
||||||
$authobject = new $this -> ldapServer['authobject']();
|
$authobject = new $this -> ldapServer['authobject']();
|
||||||
|
@ -315,6 +331,10 @@ class LSsession {
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1009);
|
$GLOBALS['LSerror'] -> addErrorCode(1009);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($this -> ldapServerId) {
|
||||||
|
$GLOBALS['Smarty'] -> assign('ldapServerId',$this -> ldapServerId);
|
||||||
|
}
|
||||||
|
$GLOBALS['Smarty'] -> assign('topDn',$this -> topDn);
|
||||||
$this -> displayLoginForm();
|
$this -> displayLoginForm();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -348,7 +368,7 @@ class LSsession {
|
||||||
*/
|
*/
|
||||||
function LSldapConnect() {
|
function LSldapConnect() {
|
||||||
if ($this -> ldapServer) {
|
if ($this -> ldapServer) {
|
||||||
include_once($GLOBALS['LSconfig']['NetLDAP']);
|
include_once($GLOBALS['LSconfig']['NetLDAP2']);
|
||||||
if (!$this -> loadLSclass('LSldap'))
|
if (!$this -> loadLSclass('LSldap'))
|
||||||
return;
|
return;
|
||||||
$GLOBALS['LSldap'] = new LSldap($this -> ldapServer['ldap_config']);
|
$GLOBALS['LSldap'] = new LSldap($this -> ldapServer['ldap_config']);
|
||||||
|
@ -370,19 +390,46 @@ class LSsession {
|
||||||
* @retval mixed Tableau des subDn, false si une erreur est survenue.
|
* @retval mixed Tableau des subDn, false si une erreur est survenue.
|
||||||
*/
|
*/
|
||||||
function getSubDnLdapServer() {
|
function getSubDnLdapServer() {
|
||||||
if ( isset($this ->ldapServer['subdnobject']) ) {
|
if ( is_array($this ->ldapServer['subDn']) ) {
|
||||||
if( $this -> loadLSobject($this ->ldapServer['subdnobject']) ) {
|
$return=array();
|
||||||
if ($subdnobject = new $this ->ldapServer['subdnobject']()) {
|
foreach($this ->ldapServer['subDn'] as $subDn_name => $subDn_config) {
|
||||||
return $subdnobject -> getSelectArray();
|
if ($subDn_name == 'LSobject') {
|
||||||
|
if (is_array($subDn_config)) {
|
||||||
|
foreach($subDn_config as $LSobject_name => $LSoject_topDn) {
|
||||||
|
if ($LSoject_topDn) {
|
||||||
|
$topDn = $LSoject_topDn;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$topDn = NULL;
|
||||||
|
}
|
||||||
|
if( $this -> loadLSobject($LSobject_name) ) {
|
||||||
|
if ($subdnobject = new $LSobject_name()) {
|
||||||
|
$tbl_return = $subdnobject -> getSelectArray($topDn);
|
||||||
|
if (is_array($tbl_return)) {
|
||||||
|
$return=array_merge($return,$tbl_return);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$GLOBALS['LSerror'] -> addErrorCode(1017);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$GLOBALS['LSerror'] -> addErrorCode(1017);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$LSobject_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$GLOBALS['LSerror'] -> addErrorCode(1017);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return;
|
$return[$subDn_config] = $subDn_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
return $return;
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1004,$this ->ldapServer['subdnobject']);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return;
|
return;
|
||||||
|
@ -393,29 +440,38 @@ class LSsession {
|
||||||
* Retourne les options d'une liste déroulante pour le choix du topDn
|
* Retourne les options d'une liste déroulante pour le choix du topDn
|
||||||
* de connexion au serveur Ldap
|
* de connexion au serveur Ldap
|
||||||
*
|
*
|
||||||
* Liste les subdnobject ($this ->ldapServer['subdnobject'])
|
* Liste les subdn ($this ->ldapServer['subDn'])
|
||||||
*
|
*
|
||||||
* @retval string Les options (<option>) pour la sélection du topDn.
|
* @retval string Les options (<option>) pour la sélection du topDn.
|
||||||
*/
|
*/
|
||||||
function getSubDnLdapServerOptions() {
|
function getSubDnLdapServerOptions($selected=NULL) {
|
||||||
if ( isset($this ->ldapServer['subdnobject']) ) {
|
$list = $this -> getSubDnLdapServer();
|
||||||
|
if ($list) {
|
||||||
if( $this -> loadLSobject($this ->ldapServer['subdnobject']) ) {
|
$display='';
|
||||||
if ($subdnobject = new $this ->ldapServer['subdnobject']()) {
|
foreach($list as $dn => $txt) {
|
||||||
return $subdnobject -> getSelectOptions();
|
if ($selected && ($selected==$dn)) {
|
||||||
|
$selected_txt = ' selected';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return;
|
$selected_txt = '';
|
||||||
}
|
}
|
||||||
|
$display.="<option value=\"".$dn."\"$selected_txt>".$txt."</option>\n";
|
||||||
}
|
}
|
||||||
else {
|
return $display;
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1004,$this ->ldapServer['subdnobject']);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
function validSubDnLdapServer($subDn) {
|
||||||
|
$listTopDn = $this -> getSubDnLdapServer();
|
||||||
|
if(is_array($listTopDn)) {
|
||||||
|
foreach($listTopDn as $dn => $txt) {
|
||||||
|
if ($subDn==$dn) {
|
||||||
|
return true;
|
||||||
|
} // end if
|
||||||
|
} // end foreach
|
||||||
|
} // end if
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -455,15 +511,6 @@ class LSsession {
|
||||||
$GLOBALS['Smarty'] -> assign('loginform_ldapservers_name',$ldapservers_name);
|
$GLOBALS['Smarty'] -> assign('loginform_ldapservers_name',$ldapservers_name);
|
||||||
$GLOBALS['Smarty'] -> assign('loginform_ldapservers_index',$ldapservers_index);
|
$GLOBALS['Smarty'] -> assign('loginform_ldapservers_index',$ldapservers_index);
|
||||||
|
|
||||||
$this -> setLdapServer(0);
|
|
||||||
if ( $this -> LSldapConnect() ) {
|
|
||||||
$topDn_array = $this -> getSubDnLdapServer();
|
|
||||||
if ( $topDn_array ) {
|
|
||||||
$GLOBALS['Smarty'] -> assign('loginform_topdn_name',$topDn_array['display']);
|
|
||||||
$GLOBALS['Smarty'] -> assign('loginform_topdn_index',$topDn_array['dn']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$GLOBALS['Smarty'] -> assign('loginform_label_level',_('Niveau'));
|
$GLOBALS['Smarty'] -> assign('loginform_label_level',_('Niveau'));
|
||||||
$GLOBALS['Smarty'] -> assign('loginform_label_user',_('Identifiant'));
|
$GLOBALS['Smarty'] -> assign('loginform_label_user',_('Identifiant'));
|
||||||
$GLOBALS['Smarty'] -> assign('loginform_label_pwd',_('Mot de passe'));
|
$GLOBALS['Smarty'] -> assign('loginform_label_pwd',_('Mot de passe'));
|
||||||
|
@ -551,6 +598,21 @@ class LSsession {
|
||||||
|
|
||||||
$GLOBALS['Smarty'] -> assign('LSaccess',$this -> LSaccess);
|
$GLOBALS['Smarty'] -> assign('LSaccess',$this -> LSaccess);
|
||||||
|
|
||||||
|
// Niveau
|
||||||
|
$listTopDn = $this -> getSubDnLdapServer();
|
||||||
|
if (is_array($listTopDn)) {
|
||||||
|
$GLOBALS['Smarty'] -> assign('label_level',_('Niveau'));
|
||||||
|
$LSsession_topDn_index = array();
|
||||||
|
$LSsession_topDn_name = array();
|
||||||
|
foreach($listTopDn as $index => $name) {
|
||||||
|
$LSsession_topDn_index[] = $index;
|
||||||
|
$LSsession_topDn_name[] = $name;
|
||||||
|
}
|
||||||
|
$GLOBALS['Smarty'] -> assign('LSsession_topDn_index',$LSsession_topDn_index);
|
||||||
|
$GLOBALS['Smarty'] -> assign('LSsession_topDn_name',$LSsession_topDn_name);
|
||||||
|
$GLOBALS['Smarty'] -> assign('LSsession_topDn',$this -> topDn);
|
||||||
|
}
|
||||||
|
|
||||||
$GLOBALS['LSerror'] -> display();
|
$GLOBALS['LSerror'] -> display();
|
||||||
debug_print();
|
debug_print();
|
||||||
if (!$this -> template)
|
if (!$this -> template)
|
||||||
|
|
|
@ -122,7 +122,7 @@ function debug($data,$get=true) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function debug_print() {
|
function debug_print($return=false) {
|
||||||
if (( $GLOBALS['LSdebug']['fields'] ) && ( $GLOBALS['LSdebug']['active'] )) {
|
if (( $GLOBALS['LSdebug']['fields'] ) && ( $GLOBALS['LSdebug']['active'] )) {
|
||||||
$txt='<ul>';
|
$txt='<ul>';
|
||||||
foreach($GLOBALS['LSdebug']['fields'] as $debug) {
|
foreach($GLOBALS['LSdebug']['fields'] as $debug) {
|
||||||
|
@ -135,7 +135,11 @@ function debug_print() {
|
||||||
}
|
}
|
||||||
$txt.='</ul>';
|
$txt.='</ul>';
|
||||||
$GLOBALS['Smarty'] -> assign('LSdebug',$txt);
|
$GLOBALS['Smarty'] -> assign('LSdebug',$txt);
|
||||||
|
if ($return) {
|
||||||
|
return $txt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,6 +18,15 @@ var LSdefault = new Class({
|
||||||
this.loading_img=[];
|
this.loading_img=[];
|
||||||
LSdebug(this.loading_img);
|
LSdebug(this.loading_img);
|
||||||
this.loading_img_id=-1;
|
this.loading_img_id=-1;
|
||||||
|
|
||||||
|
this.LSsession_topDn = $('LSsession_topDn');
|
||||||
|
if (this.LSsession_topDn) {
|
||||||
|
this.LSsession_topDn.addEvent('change',this.onLSsession_topDnChange.bind(this));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onLSsession_topDnChange: function() {
|
||||||
|
$('LSsession_topDn_form').submit();
|
||||||
},
|
},
|
||||||
|
|
||||||
onLSdebugHiddenClick: function(event){
|
onLSdebugHiddenClick: function(event){
|
||||||
|
@ -36,6 +45,12 @@ var LSdefault = new Class({
|
||||||
this.displayLSerror();
|
this.displayLSerror();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
displayDebug: function(html) {
|
||||||
|
this.LSdebug.empty();
|
||||||
|
this.LSdebug.setHTML(html);
|
||||||
|
this.displayDebugBox();
|
||||||
|
},
|
||||||
|
|
||||||
displayLSerror: function() {
|
displayLSerror: function() {
|
||||||
this.LSerror.setStyle('top',getScrollTop()+10);
|
this.LSerror.setStyle('top',getScrollTop()+10);
|
||||||
new Fx.Style(this.LSerror,'opacity',{duration:500}).start(0,0.8);
|
new Fx.Style(this.LSerror,'opacity',{duration:500}).start(0,0.8);
|
||||||
|
|
|
@ -10,6 +10,8 @@ var LSselect = new Class({
|
||||||
el.addEvent('submit',this.onSubmitSearchForm.bindWithEvent(this,el));
|
el.addEvent('submit',this.onSubmitSearchForm.bindWithEvent(this,el));
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
this.LSselect_topDn = $('LSselect_topDn');
|
||||||
|
this.LSselect_topDn.addEvent('change',this.onChangeLSselect_topDn.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
initializeContent: function() {
|
initializeContent: function() {
|
||||||
|
@ -66,8 +68,17 @@ var LSselect = new Class({
|
||||||
this.initializeContent();
|
this.initializeContent();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onChangeLSselect_topDn: function() {
|
||||||
|
form = this.LSselect_topDn.getParent().getParent();
|
||||||
|
this.submitSearchForm(form);
|
||||||
|
},
|
||||||
|
|
||||||
onSubmitSearchForm: function(event, form) {
|
onSubmitSearchForm: function(event, form) {
|
||||||
new Event(event).stop();
|
new Event(event).stop();
|
||||||
|
this.submitSearchForm(form);
|
||||||
|
},
|
||||||
|
|
||||||
|
submitSearchForm: function(form) {
|
||||||
var imgload = varLSdefault.loadingImgDisplay($('title'),'inside');
|
var imgload = varLSdefault.loadingImgDisplay($('title'),'inside');
|
||||||
form.send({
|
form.send({
|
||||||
update: $('content'),
|
update: $('content'),
|
||||||
|
|
|
@ -4,6 +4,7 @@ var LSsession_login = new Class({
|
||||||
if ( ! this.select_ldapserver )
|
if ( ! this.select_ldapserver )
|
||||||
return;
|
return;
|
||||||
this.select_ldapserver.addEvent('change',this.onLdapServerChanged.bind(this));
|
this.select_ldapserver.addEvent('change',this.onLdapServerChanged.bind(this));
|
||||||
|
this.onLdapServerChanged();
|
||||||
},
|
},
|
||||||
|
|
||||||
onLdapServerChanged: function(){
|
onLdapServerChanged: function(){
|
||||||
|
@ -23,11 +24,14 @@ var LSsession_login = new Class({
|
||||||
var data = Json.evaluate(responseText);
|
var data = Json.evaluate(responseText);
|
||||||
LSdebug(data);
|
LSdebug(data);
|
||||||
if ( data ) {
|
if ( data ) {
|
||||||
|
if (data.LSdebug) {
|
||||||
|
varLSdefault.displayDebug(data.LSdebug);
|
||||||
|
}
|
||||||
if (data.LSerror) {
|
if (data.LSerror) {
|
||||||
varLSdefault.displayError(data.LSerror);
|
varLSdefault.displayError(data.LSerror);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
if (data.list_topDn) {
|
||||||
$('LSsession_topDn').getParent().setHTML(data.list_topDn);
|
$('LSsession_topDn').getParent().setHTML(data.list_topDn);
|
||||||
LSdebug($('LSsession_topDn').innerHTML);
|
LSdebug($('LSsession_topDn').innerHTML);
|
||||||
$$('.loginform-level').each(function(el) {
|
$$('.loginform-level').each(function(el) {
|
||||||
|
|
|
@ -4,7 +4,6 @@ require_once 'includes/functions.php';
|
||||||
require_once 'includes/class/class.LSsession.php';
|
require_once 'includes/class/class.LSsession.php';
|
||||||
|
|
||||||
$GLOBALS['LSsession'] = new LSsession();
|
$GLOBALS['LSsession'] = new LSsession();
|
||||||
$GLOBALS['LSsession'] -> loadLSobjects();
|
|
||||||
|
|
||||||
if ($_REQUEST['template'] != 'login') {
|
if ($_REQUEST['template'] != 'login') {
|
||||||
if ( !$GLOBALS['LSsession'] -> startLSsession() ) {
|
if ( !$GLOBALS['LSsession'] -> startLSsession() ) {
|
||||||
|
@ -19,7 +18,9 @@ switch($_REQUEST['template']) {
|
||||||
if ( isset($_REQUEST['server']) ) {
|
if ( isset($_REQUEST['server']) ) {
|
||||||
$GLOBALS['LSsession'] -> setLdapServer($_REQUEST['server']);
|
$GLOBALS['LSsession'] -> setLdapServer($_REQUEST['server']);
|
||||||
if ( $GLOBALS['LSsession'] -> LSldapConnect() ) {
|
if ( $GLOBALS['LSsession'] -> LSldapConnect() ) {
|
||||||
$list = $GLOBALS['LSsession'] -> getSubDnLdapServerOptions();
|
session_start();
|
||||||
|
$GLOBALS['LSsession'] -> loadLSobjects();
|
||||||
|
$list = $GLOBALS['LSsession'] -> getSubDnLdapServerOptions($_SESSION['LSsession_topDn']);
|
||||||
if (is_string($list)) {
|
if (is_string($list)) {
|
||||||
$list="<select name='LSsession_topDn' id='LSsession_topDn'>".$list."</select>";
|
$list="<select name='LSsession_topDn' id='LSsession_topDn'>".$list."</select>";
|
||||||
$data = array('list_topDn' => $list, 'imgload' => $_REQUEST['imgload']);
|
$data = array('list_topDn' => $list, 'imgload' => $_REQUEST['imgload']);
|
||||||
|
@ -300,5 +301,10 @@ if ($GLOBALS['LSerror']->errorsDefined()) {
|
||||||
$data['LSerror'] = $GLOBALS['LSerror']->getErrors();
|
$data['LSerror'] = $GLOBALS['LSerror']->getErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$debug_txt = debug_print(true);
|
||||||
|
if ($debug_txt != "") {
|
||||||
|
$data['LSdebug'] = $debug_txt;
|
||||||
|
}
|
||||||
|
|
||||||
echo json_encode($data);
|
echo json_encode($data);
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -58,19 +58,26 @@ if($LSsession -> startLSsession()) {
|
||||||
$GLOBALS['Smarty']->assign('LSobject_list_filter','');
|
$GLOBALS['Smarty']->assign('LSobject_list_filter','');
|
||||||
}
|
}
|
||||||
|
|
||||||
$list=$object -> listObjects($filter);
|
$topDn = $object -> config['container_dn'].','.$GLOBALS['LSsession'] -> topDn;
|
||||||
|
if(isset($_REQUEST['LSselect_topDn'])) {
|
||||||
|
if ($GLOBALS['LSsession'] -> validSubDnLdapServer($_REQUEST['LSselect_topDn'])) {
|
||||||
|
$topDn = $object -> config['container_dn'].','.$_REQUEST['LSselect_topDn'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$list=$object -> listObjects($filter,$topDn);
|
||||||
$nbObjects=count($list);
|
$nbObjects=count($list);
|
||||||
|
|
||||||
if ($nbObjects > NB_LSOBJECT_LIST) {
|
if ($nbObjects > NB_LSOBJECT_LIST_SELECT) {
|
||||||
if (isset($_GET['page'])) {
|
if (isset($_GET['page'])) {
|
||||||
$list = array_slice($list, ($_GET['page']) * NB_LSOBJECT_LIST, NB_LSOBJECT_LIST);
|
$list = array_slice($list, ($_GET['page']) * NB_LSOBJECT_LIST_SELECT, NB_LSOBJECT_LIST_SELECT);
|
||||||
$GLOBALS['Smarty']->assign('LSobject_list_currentpage',$_GET['page']);
|
$GLOBALS['Smarty']->assign('LSobject_list_currentpage',$_GET['page']);
|
||||||
$GLOBALS['Smarty']->assign('LSobject_list_nbpage',ceil($nbObjects / NB_LSOBJECT_LIST));
|
$GLOBALS['Smarty']->assign('LSobject_list_nbpage',ceil($nbObjects / NB_LSOBJECT_LIST_SELECT));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$list = array_slice($list, 0, NB_LSOBJECT_LIST);
|
$list = array_slice($list, 0, NB_LSOBJECT_LIST_SELECT);
|
||||||
$GLOBALS['Smarty']->assign('LSobject_list_currentpage',0);
|
$GLOBALS['Smarty']->assign('LSobject_list_currentpage',0);
|
||||||
$GLOBALS['Smarty']->assign('LSobject_list_nbpage',ceil($nbObjects / NB_LSOBJECT_LIST));
|
$GLOBALS['Smarty']->assign('LSobject_list_nbpage',ceil($nbObjects / NB_LSOBJECT_LIST_SELECT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$c=0;
|
$c=0;
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
#LSerror {
|
#LSerror {
|
||||||
width: 50%;
|
width: 50%;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 10px;
|
top: 10px;
|
||||||
left: 10px;
|
left: 10px;
|
||||||
background-color: #f00;
|
background-color: #f00;
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
#LSdebug {
|
#LSdebug {
|
||||||
width: 50%;
|
width: 50%;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 10px;
|
top: 10px;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
background-color: #84ff6a;
|
background-color: #84ff6a;
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
#LSdebug_hidden {
|
#LSdebug_hidden {
|
||||||
float: right;
|
float: right;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,10 @@ ul.LSform {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
li.LSform {
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
.LSform-errors {
|
.LSform-errors {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
background-color: #f59a67;
|
background-color: #f59a67;
|
||||||
|
|
|
@ -26,3 +26,7 @@
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
font-size: 100%;
|
font-size: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#frame-LSsmoothbox {
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
|
@ -65,6 +65,18 @@ hr {
|
||||||
padding: 0.3em;
|
padding: 0.3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#LSsession_topDn {
|
||||||
|
height: 1.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#LSsession_topDn_form {
|
||||||
|
float: left;
|
||||||
|
font-size: 0.7em;
|
||||||
|
color: #fff;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#user_name {
|
#user_name {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
@ -213,6 +225,14 @@ form.LSview_search {
|
||||||
margin-right: 2em;
|
margin-right: 2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
form.LSselect_search {
|
||||||
|
float: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.LSselect_search {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
label.LSview_search {
|
label.LSview_search {
|
||||||
font-size: 0.6em;
|
font-size: 0.6em;
|
||||||
display: block;
|
display: block;
|
||||||
|
@ -242,6 +262,13 @@ div.LSobject-select {
|
||||||
width: 10px;
|
width: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#LSselect_topDn_label {
|
||||||
|
float: left;
|
||||||
|
font-size: 0.8em;
|
||||||
|
margin-left: 1em;
|
||||||
|
margin-top: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
form.LSselect_search {
|
form.LSselect_search {
|
||||||
margin-top: 0.5em;
|
margin-top: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,10 +21,10 @@
|
||||||
<dl class='loginform'>
|
<dl class='loginform'>
|
||||||
<dt {$loginform_ldapserver_style}>{$loginform_label_ldapserver}</dt>
|
<dt {$loginform_ldapserver_style}>{$loginform_label_ldapserver}</dt>
|
||||||
<dd {$loginform_ldapserver_style}>
|
<dd {$loginform_ldapserver_style}>
|
||||||
<select name='LSsession_ldapserver' id='LSsession_ldapserver'>{html_options values=$loginform_ldapservers_index output=$loginform_ldapservers_name}</select>
|
<select name='LSsession_ldapserver' id='LSsession_ldapserver'>{html_options values=$loginform_ldapservers_index output=$loginform_ldapservers_name selected=$ldapServerId}</select>
|
||||||
</dd>
|
</dd>
|
||||||
<dt class='loginform-level' {$loginform_ldapserver_style}>{$loginform_label_level}</dt>
|
<dt class='loginform-level' {$loginform_ldapserver_style}>{$loginform_label_level}</dt>
|
||||||
<dd class='loginform-level' {$loginform_ldapserver_style}><select name='LSsession_topDn' id='LSsession_topDn'>{html_options values=$loginform_topdn_index output=$loginform_topdn_name}</select></dd>
|
<dd class='loginform-level' {$loginform_ldapserver_style}><select name='LSsession_topDn' id='LSsession_topDn'>{html_options values=$loginform_topdn_index output=$loginform_topdn_name selected=$topDn}</select></dd>
|
||||||
<dt>{$loginform_label_user}</dt>
|
<dt>{$loginform_label_user}</dt>
|
||||||
<dd><input type='text' name='LSsession_user' /></dd>
|
<dd><input type='text' name='LSsession_user' /></dd>
|
||||||
<dt>{$loginform_label_pwd}</dt>
|
<dt>{$loginform_label_pwd}</dt>
|
||||||
|
|
|
@ -1,13 +1,23 @@
|
||||||
<div class='LSobject-select'>
|
<div class='LSobject-select'>
|
||||||
<form action='{$LSview_search.action}' method='post' class='LSview_search LSselect_search'>
|
|
||||||
<input type='hidden' name='LSobject' value='{$LSview_search.LSobject}' />
|
|
||||||
<input type='text' name='LSview_pattern' class='LSview_search' />
|
|
||||||
<input type='submit' value='{$LSview_search.submit}' class='LSview_search' />
|
|
||||||
<label class='LSview_search'>Recherche approximative : <input type='checkbox' name='LSview_approx' class='LSview_search' /></label>
|
|
||||||
</form>
|
|
||||||
<h1 id='title'>
|
<h1 id='title'>
|
||||||
{$pagetitle}
|
{$pagetitle}
|
||||||
</h1>
|
</h1>
|
||||||
|
<form action='{$LSview_search.action}' method='post' class='LSview_search LSselect_search'>
|
||||||
|
<input type='hidden' name='LSobject' value='{$LSview_search.LSobject}' />
|
||||||
|
|
||||||
|
{if $LSsession_topDn!=""}
|
||||||
|
<label id='LSselect_topDn_label'>{$label_level}
|
||||||
|
<select name='LSselect_topDn' id='LSselect_topDn'>
|
||||||
|
{html_options values=$LSsession_topDn_index output=$LSsession_topDn_name selected=$LSsession_topDn}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
{/if}
|
||||||
|
<div class='LSselect_search'>
|
||||||
|
<input type='text' name='LSview_pattern' class='LSview_search' />
|
||||||
|
<input type='submit' value='{$LSview_search.submit}' class='LSview_search' />
|
||||||
|
<label class='LSview_search'>Recherche approximative : <input type='checkbox' name='LSview_approx' class='LSview_search' /></label>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
<div id='content'>
|
<div id='content'>
|
||||||
{include file='select_table.tpl'}
|
{include file='select_table.tpl'}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -27,4 +27,17 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div id='right'>
|
<div id='right'>
|
||||||
<p id='status'>Connecté en tant que <span id='user_name'>{$LSsession_username}</span></b> <a href='index.php?LSsession_logout'><img src='templates/images/logout.png' alt='Logout' title='Logout' /></a></p>
|
|
||||||
|
|
||||||
|
{if $LSsession_topDn!=""}
|
||||||
|
<form action="{$PHP_SELF}" method='post' id='LSsession_topDn_form'>
|
||||||
|
<label>{$label_level}
|
||||||
|
<select name='LSsession_topDn' id='LSsession_topDn'>
|
||||||
|
{html_options values=$LSsession_topDn_index output=$LSsession_topDn_name selected=$LSsession_topDn}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</form>
|
||||||
|
{/if}
|
||||||
|
<p id='status'>
|
||||||
|
Connecté en tant que <span id='user_name'>{$LSsession_username}</span></b> <a href='index.php?LSsession_logout'><img src='templates/images/logout.png' alt='Logout' title='Logout' /></a>
|
||||||
|
</p>
|
||||||
|
|
|
@ -99,23 +99,27 @@ if($LSsession -> startLSsession()) {
|
||||||
$GLOBALS['LSsession'] -> addJSscript('LSsmoothbox.js');
|
$GLOBALS['LSsession'] -> addJSscript('LSsmoothbox.js');
|
||||||
$GLOBALS['LSsession'] -> addCssFile('LSsmoothbox.css');
|
$GLOBALS['LSsession'] -> addCssFile('LSsmoothbox.css');
|
||||||
$GLOBALS['LSsession'] -> addJSscript('LSrelation.js');
|
$GLOBALS['LSsession'] -> addJSscript('LSrelation.js');
|
||||||
|
if($GLOBALS['LSsession'] -> loadLSobject($relationConf['LSobject'])) {
|
||||||
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
|
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
|
||||||
$objRel = new $relationConf['LSobject']();
|
$objRel = new $relationConf['LSobject']();
|
||||||
$list = $objRel -> $relationConf['list_function']($object);
|
$list = $objRel -> $relationConf['list_function']($object);
|
||||||
if (is_array($list)) {
|
if (is_array($list)) {
|
||||||
foreach($list as $o) {
|
foreach($list as $o) {
|
||||||
$return['objectList'][] = $o -> getDisplayValue();
|
$return['objectList'][] = $o -> getDisplayValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$return['objectList']=array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$return['objectList']=array();
|
$GLOBALS['LSerror'] -> addErrorCode(1013,$relationName);
|
||||||
}
|
}
|
||||||
|
$LSrelations[]=$return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1013,$relationName);
|
$GLOBALS['LSerror'] -> addErrorCode(1016,array('relation' => $relationName,'LSobject' => $relationConf['LSobject']));
|
||||||
}
|
}
|
||||||
$LSrelations[]=$return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$GLOBALS['Smarty'] -> assign('LSrelations',$LSrelations);
|
$GLOBALS['Smarty'] -> assign('LSrelations',$LSrelations);
|
||||||
|
@ -169,7 +173,9 @@ if($LSsession -> startLSsession()) {
|
||||||
$GLOBALS['Smarty']->assign('LSobject_list_filter','');
|
$GLOBALS['Smarty']->assign('LSobject_list_filter','');
|
||||||
}
|
}
|
||||||
|
|
||||||
$list=$object -> listObjects($filter);
|
$topDn = $object -> config['container_dn'].','.$GLOBALS['LSsession'] -> topDn;
|
||||||
|
|
||||||
|
$list=$object -> listObjects($filter,$topDn);
|
||||||
$nbObjects=count($list);
|
$nbObjects=count($list);
|
||||||
$GLOBALS['Smarty']->assign('LSobject_list_nbresult',$nbObjects);
|
$GLOBALS['Smarty']->assign('LSobject_list_nbresult',$nbObjects);
|
||||||
if ($nbObjects > NB_LSOBJECT_LIST) {
|
if ($nbObjects > NB_LSOBJECT_LIST) {
|
||||||
|
@ -211,7 +217,7 @@ if($LSsession -> startLSsession()) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($GLOBALS['LSsession'] -> canRemove($thisObject -> getType(),$GLOBALS['LSsession']-> LSuserObject -> getValue('dn'))) {
|
if ($GLOBALS['LSsession'] -> canRemove($thisObject -> getType(),$thisObject -> getValue('dn'))) {
|
||||||
$actions[] = array (
|
$actions[] = array (
|
||||||
'label' => _('Supprimer'),
|
'label' => _('Supprimer'),
|
||||||
'url' => 'remove.php?LSobject='.$_REQUEST['LSobject'].'&dn='.$thisObject -> getValue('dn'),
|
'url' => 'remove.php?LSobject='.$_REQUEST['LSobject'].'&dn='.$thisObject -> getValue('dn'),
|
||||||
|
|
Loading…
Reference in a new issue