- 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:
Benjamin Renard 2008-04-25 13:48:12 +00:00
parent 1e2316d76f
commit 748c9d3ec3
24 changed files with 338 additions and 200 deletions

6
trunk/INSTALL Normal file
View 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

View file

@ -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'
);
?>

View file

@ -258,7 +258,14 @@ $GLOBALS['LSerror_code'] = array (
1015 => array (
'msg' => _("LSrelations : Une erreur s'est produite durant la mise a jour de la relation %{relation}."),
'level' => 'c'
),
1016 => array (
'msg' => _("LSrelations : L'objet %{LSobject} de la relation %{relation} est inconnu."),
'level' => 'w'
),
1017 => array (
'msg' => _("LSsession : Impossible de cr&eacute;er correctement la liste des niveaux. V&eacute;rifier la configuration."),
'level' => 'c'
)
);
?>

View file

@ -22,10 +22,10 @@
// Configuration LDAP Saisie :
$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',
'lang' => 'fr_FR.UTF8',
'cacheLSrights' => true,
'cacheLSrights' => false,
'ldap_servers' => array (
array (
'name' => 'LSexample',
@ -54,25 +54,12 @@ $GLOBALS['LSconfig'] = array(
),
'cacheLSrights' => false,
'authobject' => 'LSeepeople',
'authobject_pwdattr' => 'userPassword'
),
array (
'name' => 'Ldap 2',
'ldap_config'=> array(
'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'
'authobject_pwdattr' => 'userPassword',
'LSobjects' => array (
'LSeepeople',
'LSeegroup',
'LSeecompany'
)
)
)
);
@ -80,7 +67,8 @@ $GLOBALS['LSconfig'] = array(
//Debug
$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);
@ -92,6 +80,7 @@ setlocale(LC_ALL, $GLOBALS['LSconfig']['lang']);
// Définitions des dossiers d'inclusions
define('LS_CONF_DIR','conf/');
define('LS_OBJECTS_DIR', LS_CONF_DIR . 'LSobjects/');
define('LS_INCLUDE_DIR','includes/');
define('LS_CLASS_DIR', LS_INCLUDE_DIR .'class/');
define('LS_LIB_DIR', LS_INCLUDE_DIR .'libs/');

View file

@ -84,6 +84,10 @@ class LSattr_html_select_list extends LSattr_html{
$GLOBALS['LSerror'] -> addErrorCode(102,$this -> name);
break;
}
if (!$GLOBALS['LSsession'] -> loadLSobject($val['object_type'])) {
$GLOBALS['LSerror'] -> addErrorCode(1004,$val['object_type']);
return;
}
$obj = new $val['object_type']();
if($val['scope']) {
$param=array('scope' => $this -> config['possible_values']['scope']);

View file

@ -261,12 +261,12 @@ class LSattribute {
break;
case 'self':
if (($this -> config['rights']['self'] == 'w') || ($this -> config['rights']['self'] == 'r')) {
$return=$this -> config['self'];
$return=$this -> config['rights']['self'];
}
break;
default: //user
if (($this -> config['rights']['user'] == 'w') || ($this -> config['rights']['user'] == 'r')) {
$return=$this -> config['user'];
$return=$this -> config['rights']['user'];
}
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
*/
function refreshForm(&$form,$idForm) {
if(isset($this -> config['form'][$idForm])) {
$form_element = &$form -> getElement($this -> name);
if(isset($this -> config['form'][$idForm]) && ($this -> myRights()=='w')) {
$form_element = $form -> getElement($this -> name);
$values = $this -> html -> refreshForm($this -> getFormVal());
return $form_element -> setValue($values);
}
@ -420,7 +420,7 @@ class LSattribute {
$value=call_user_func($this -> config['generate_function'],$this -> ldapObject);
if (!empty($value)) {
//$this -> setValue($value); // pas nécéssaire ??
$this -> updateData=$value;
$this -> updateData=array($value);
return true;
}
return;

View file

@ -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'].=$addBtn;
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";
if (!$this -> isFreeze()) {

View file

@ -23,7 +23,7 @@
/**
* 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>
*/
@ -40,11 +40,11 @@ class LSldap {
*
* @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
*
* @see Net_LDAP::connect()
* @see Net_LDAP2::connect()
*/
function LSldap ($config) {
$this -> config = $config;
@ -61,8 +61,8 @@ class LSldap {
* @retval boolean true si la connection est établie, false sinon
*/
function connect() {
$this -> cnx = Net_LDAP::connect($this -> config);
if (Net_LDAP::isError($this -> cnx)) {
$this -> cnx = Net_LDAP2::connect($this -> config);
if (Net_LDAP2::isError($this -> cnx)) {
$GLOBALS['LSerror'] -> addErrorCode(1,$this -> cnx -> getMessage());
$this -> cnx = NULL;
return;
@ -93,9 +93,9 @@ class LSldap {
*
* @param[in] $filter [<b>required</b>] string Filtre de recherche Ldap
* @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 :
* - ['dn'] : le DN de l'entré
@ -104,7 +104,7 @@ class LSldap {
*/
function search ($filter,$basedn=NULL,$params = array()) {
$ret = $this -> cnx -> search($basedn,$filter,$params);
if (Net_LDAP::isError($ret)) {
if (Net_LDAP2::isError($ret)) {
$GLOBALS['LSerror'] -> addErrorCode(2,$ret -> getMessage());
return;
}
@ -125,9 +125,9 @@ class LSldap {
*
* @param[in] $filter [<b>required</b>] string Filtre de recherche Ldap
* @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
*/
@ -135,7 +135,7 @@ class LSldap {
if (empty($filter))
$filter=NULL;
$ret = $this -> cnx -> search($basedn,$filter,$params);
if (Net_LDAP::isError($ret)) {
if (Net_LDAP2::isError($ret)) {
$GLOBALS['LSerror'] -> addErrorCode(2,$ret -> getMessage());
return;
}
@ -175,14 +175,14 @@ class LSldap {
* @param[in] $object_type string Type de l'objet 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) {
if(isset($GLOBALS['LSobjects'][$object_type])){
$obj_conf=$GLOBALS['LSobjects'][$object_type];
$entry = $this -> cnx -> getEntry($dn);
if (Net_Ldap::isError($entry)) {
$newentry = new Net_Ldap_Entry(&$this -> cnx);
if (Net_LDAP2::isError($entry)) {
$newentry = new Net_LDAP2_Entry(&$this -> cnx);
$newentry -> dn($dn);
$newentry -> add(array('objectclass' => $obj_conf['objectclass']));
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) {
$dropAttr[] = $attrName;
}
@ -234,13 +240,14 @@ class LSldap {
$entry -> replace($changeData);
debug('change : '.print_r($changeData,true));
debug('drop : '.print_r($dropAttr,true));
$ret = $entry -> update();
if (!empty($dropAttr)) {
foreach($dropAttr as $attr) {
$entry -> delete($attr);
}
}
$ret = $entry -> update();
if (Net_Ldap::isError($ret)) {
if (Net_LDAP2::isError($ret)) {
$GLOBALS['LSerror'] -> addErrorCode(5,$dn);
debug('NetLdap-Error : '.$ret->getMessage());
}
@ -268,8 +275,8 @@ class LSldap {
$config = $this -> config;
$config['binddn'] = $dn;
$config['bindpw'] = $pwd;
$cnx = Net_LDAP::connect($config);
if (Net_LDAP::isError($cnx)) {
$cnx = Net_LDAP2::connect($config);
if (Net_LDAP2::isError($cnx)) {
return;
}
return true;

View file

@ -31,9 +31,9 @@ $GLOBALS['LSsession'] -> loadLSclass('LSattribute');
*/
class LSldapObject {
var $config;
var $config = array();
var $type_name;
var $attrs;
var $attrs = array();
var $forms;
var $view;
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] $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
*/
@ -806,36 +806,19 @@ class LSldapObject {
return ' ';
}
}
/**
* 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
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @retval array['dn','display']
* @retval array('dn' => 'display')
*/
function getSelectArray() {
$list = $this -> listObjects();
function getSelectArray($topDn=NULL) {
$list = $this -> listObjects(NULL,$topDn);
$return=array();
foreach($list as $object) {
$return['dn'][] = $object -> getDn();
$return['display'][] = $object -> getDisplayValue();
$return[$object -> getDn()] = $object -> getDisplayValue();
}
return $return;
}

View file

@ -75,12 +75,12 @@ class LSsession {
*/
function loadConfig() {
if (loadDir($this -> confDir, '^config\..*\.php$')) {
if ( @include_once $GLOBALS['LSconfig']['Smarty'] ) {
if ( include_once $GLOBALS['LSconfig']['Smarty'] ) {
$GLOBALS['Smarty'] = new Smarty();
return true;
}
else {
$GLOBALS['LSerror'] -> addErrorCode(1008);
die($GLOBALS['LSerror_code'][1008]['msg']);
return;
}
return true;
@ -121,7 +121,7 @@ class LSsession {
return true;
if($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.
*/
function loadLSobject($object) {
if (!$this -> loadLSclass($object,'LSobjects'))
$this -> loadLSclass('LSldapObject');
if (!$this -> loadLSclass($object,'LSobjects')) {
return;
if (!require_once( LS_OBJECTS_DIR . 'config.LSobjects.'.$object.'.php' ))
}
if (!require_once( LS_OBJECTS_DIR . 'config.LSobjects.'.$object.'.php' )) {
return;
}
return true;
}
@ -143,7 +146,7 @@ class LSsession {
* Chargement des objects LdapSaisie
*
* Chargement des LSobjects contenue dans la variable
* $GLOBALS['LSobjects_loads']
* $this -> ldapServer['LSobjects']
*
* @retval boolean true si le chargement a réussi, false sinon.
*/
@ -151,12 +154,12 @@ class LSsession {
$this -> loadLSclass('LSldapObject');
if(!is_array($GLOBALS['LSobjects_loads'])) {
if(!is_array($this -> ldapServer['LSobjects'])) {
$GLOBALS['LSerror'] -> addErrorCode(1001,"LSobjects['loads']");
return;
}
foreach ($GLOBALS['LSobjects_loads'] as $object) {
foreach ($this -> ldapServer['LSobjects'] as $object) {
if ( !$this -> loadLSobject($object) )
return;
}
@ -211,7 +214,6 @@ class LSsession {
* @retval boolean True si l'initialisation à réussi (utilisateur authentifié), false sinon.
*/
function startLSsession() {
$this -> loadLSobjects();
$this -> loadLSaddons();
session_start();
@ -235,23 +237,35 @@ class LSsession {
$this -> rdn = $_SESSION['LSsession']['rdn'];
$this -> ldapServerId = $_SESSION['LSsession']['ldapServerId'];
$this -> tmp_file = $_SESSION['LSsession']['tmp_file'];
if ( ($GLOBALS['LSconfig']['cacheLSrights']) || ($this -> ldapServer['cacheLSrights']) ) {
$this -> ldapServer = $_SESSION['LSsession']['ldapServer'];
$this -> LSrights = $_SESSION['LSsession']['LSrights'];
$this -> LSaccess = $_SESSION['LSsession']['LSaccess'];
if (!$this -> LSldapConnect())
return;
$this -> loadLSobjects();
}
else {
$this -> setLdapServer($this -> ldapServerId);
if (!$this -> LSldapConnect())
return;
$this -> loadLSobjects();
$this -> loadLSrights();
}
$this -> loadLSobject($this -> ldapServer['authobject']);
$this -> LSuserObject = new $this -> ldapServer['authobject']();
$this -> LSuserObject -> loadData($this -> dn);
$this -> loadLSaccess();
$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;
}
@ -268,6 +282,7 @@ class LSsession {
// Connexion au serveur LDAP
if ($this -> LSldapConnect()) {
// topDn
if ( $_POST['LSsession_topDn'] != '' ){
$this -> topDn = $_POST['LSsession_topDn'];
@ -275,6 +290,7 @@ class LSsession {
else {
$this -> topDn = $this -> ldapServer['ldap_config']['basedn'];
}
$_SESSION['LSsession_topDn']=$this -> topDn;
if ( $this -> loadLSobject($this -> ldapServer['authobject']) ) {
$authobject = new $this -> ldapServer['authobject']();
@ -315,6 +331,10 @@ class LSsession {
$GLOBALS['LSerror'] -> addErrorCode(1009);
}
}
if ($this -> ldapServerId) {
$GLOBALS['Smarty'] -> assign('ldapServerId',$this -> ldapServerId);
}
$GLOBALS['Smarty'] -> assign('topDn',$this -> topDn);
$this -> displayLoginForm();
return;
}
@ -348,7 +368,7 @@ class LSsession {
*/
function LSldapConnect() {
if ($this -> ldapServer) {
include_once($GLOBALS['LSconfig']['NetLDAP']);
include_once($GLOBALS['LSconfig']['NetLDAP2']);
if (!$this -> loadLSclass('LSldap'))
return;
$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.
*/
function getSubDnLdapServer() {
if ( isset($this ->ldapServer['subdnobject']) ) {
if( $this -> loadLSobject($this ->ldapServer['subdnobject']) ) {
if ($subdnobject = new $this ->ldapServer['subdnobject']()) {
return $subdnobject -> getSelectArray();
if ( is_array($this ->ldapServer['subDn']) ) {
$return=array();
foreach($this ->ldapServer['subDn'] as $subDn_name => $subDn_config) {
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 {
return;
$return[$subDn_config] = $subDn_name;
}
}
else {
$GLOBALS['LSerror'] -> addErrorCode(1004,$this ->ldapServer['subdnobject']);
return;
}
return $return;
}
else {
return;
@ -393,29 +440,38 @@ class LSsession {
* Retourne les options d'une liste déroulante pour le choix du topDn
* 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.
*/
function getSubDnLdapServerOptions() {
if ( isset($this ->ldapServer['subdnobject']) ) {
if( $this -> loadLSobject($this ->ldapServer['subdnobject']) ) {
if ($subdnobject = new $this ->ldapServer['subdnobject']()) {
return $subdnobject -> getSelectOptions();
function getSubDnLdapServerOptions($selected=NULL) {
$list = $this -> getSubDnLdapServer();
if ($list) {
$display='';
foreach($list as $dn => $txt) {
if ($selected && ($selected==$dn)) {
$selected_txt = ' selected';
}
else {
return;
$selected_txt = '';
}
$display.="<option value=\"".$dn."\"$selected_txt>".$txt."</option>\n";
}
else {
$GLOBALS['LSerror'] -> addErrorCode(1004,$this ->ldapServer['subdnobject']);
return;
}
}
else {
return;
return $display;
}
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_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_user',_('Identifiant'));
$GLOBALS['Smarty'] -> assign('loginform_label_pwd',_('Mot de passe'));
@ -550,7 +597,22 @@ class LSsession {
$GLOBALS['Smarty'] -> assign('LSsession_css',$Css_txt);
$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();
debug_print();
if (!$this -> template)
@ -791,7 +853,7 @@ class LSsession {
if (!isset($GLOBALS['LSobjects'][$LSobject]['relations'][$relationName]))
return;
$whoami = $this -> whoami($dn);
if (($right=='w') || ($right=='r')) {
if ($GLOBALS['LSobjects'][$LSobject]['relations'][$relationName]['rights'][$whoami] == $right) {
return true;

View file

@ -122,7 +122,7 @@ function debug($data,$get=true) {
return true;
}
function debug_print() {
function debug_print($return=false) {
if (( $GLOBALS['LSdebug']['fields'] ) && ( $GLOBALS['LSdebug']['active'] )) {
$txt='<ul>';
foreach($GLOBALS['LSdebug']['fields'] as $debug) {
@ -135,7 +135,11 @@ function debug_print() {
}
$txt.='</ul>';
$GLOBALS['Smarty'] -> assign('LSdebug',$txt);
if ($return) {
return $txt;
}
}
return;
}
/**

View file

@ -18,6 +18,15 @@ var LSdefault = new Class({
this.loading_img=[];
LSdebug(this.loading_img);
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){
@ -36,6 +45,12 @@ var LSdefault = new Class({
this.displayLSerror();
},
displayDebug: function(html) {
this.LSdebug.empty();
this.LSdebug.setHTML(html);
this.displayDebugBox();
},
displayLSerror: function() {
this.LSerror.setStyle('top',getScrollTop()+10);
new Fx.Style(this.LSerror,'opacity',{duration:500}).start(0,0.8);

View file

@ -10,6 +10,8 @@ var LSselect = new Class({
el.addEvent('submit',this.onSubmitSearchForm.bindWithEvent(this,el));
}, this);
this.LSselect_topDn = $('LSselect_topDn');
this.LSselect_topDn.addEvent('change',this.onChangeLSselect_topDn.bind(this));
},
initializeContent: function() {
@ -66,8 +68,17 @@ var LSselect = new Class({
this.initializeContent();
},
onChangeLSselect_topDn: function() {
form = this.LSselect_topDn.getParent().getParent();
this.submitSearchForm(form);
},
onSubmitSearchForm: function(event, form) {
new Event(event).stop();
this.submitSearchForm(form);
},
submitSearchForm: function(form) {
var imgload = varLSdefault.loadingImgDisplay($('title'),'inside');
form.send({
update: $('content'),

View file

@ -4,6 +4,7 @@ var LSsession_login = new Class({
if ( ! this.select_ldapserver )
return;
this.select_ldapserver.addEvent('change',this.onLdapServerChanged.bind(this));
this.onLdapServerChanged();
},
onLdapServerChanged: function(){
@ -23,11 +24,14 @@ var LSsession_login = new Class({
var data = Json.evaluate(responseText);
LSdebug(data);
if ( data ) {
if (data.LSdebug) {
varLSdefault.displayDebug(data.LSdebug);
}
if (data.LSerror) {
varLSdefault.displayError(data.LSerror);
return;
}
else {
if (data.list_topDn) {
$('LSsession_topDn').getParent().setHTML(data.list_topDn);
LSdebug($('LSsession_topDn').innerHTML);
$$('.loginform-level').each(function(el) {

View file

@ -4,7 +4,6 @@ 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() ) {
@ -19,7 +18,9 @@ switch($_REQUEST['template']) {
if ( isset($_REQUEST['server']) ) {
$GLOBALS['LSsession'] -> setLdapServer($_REQUEST['server']);
if ( $GLOBALS['LSsession'] -> LSldapConnect() ) {
$list = $GLOBALS['LSsession'] -> getSubDnLdapServerOptions();
session_start();
$GLOBALS['LSsession'] -> loadLSobjects();
$list = $GLOBALS['LSsession'] -> getSubDnLdapServerOptions($_SESSION['LSsession_topDn']);
if (is_string($list)) {
$list="<select name='LSsession_topDn' id='LSsession_topDn'>".$list."</select>";
$data = array('list_topDn' => $list, 'imgload' => $_REQUEST['imgload']);
@ -300,5 +301,10 @@ if ($GLOBALS['LSerror']->errorsDefined()) {
$data['LSerror'] = $GLOBALS['LSerror']->getErrors();
}
$debug_txt = debug_print(true);
if ($debug_txt != "") {
$data['LSdebug'] = $debug_txt;
}
echo json_encode($data);
?>

View file

@ -57,20 +57,27 @@ if($LSsession -> startLSsession()) {
$filter=NULL;
$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);
if ($nbObjects > NB_LSOBJECT_LIST) {
if ($nbObjects > NB_LSOBJECT_LIST_SELECT) {
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_nbpage',ceil($nbObjects / NB_LSOBJECT_LIST));
$GLOBALS['Smarty']->assign('LSobject_list_nbpage',ceil($nbObjects / NB_LSOBJECT_LIST_SELECT));
}
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_nbpage',ceil($nbObjects / NB_LSOBJECT_LIST));
$GLOBALS['Smarty']->assign('LSobject_list_nbpage',ceil($nbObjects / NB_LSOBJECT_LIST_SELECT));
}
}
$c=0;

View file

@ -1,28 +1,28 @@
#LSerror {
width: 50%;
position: absolute;
top: 10px;
left: 10px;
background-color: #f00;
visibility: hidden;
color: #fff;
z-index: 100;
width: 50%;
position: absolute;
top: 10px;
left: 10px;
background-color: #f00;
visibility: hidden;
color: #fff;
z-index: 100;
}
#LSdebug {
width: 50%;
position: absolute;
top: 10px;
left: 50%;
background-color: #84ff6a;
visibility: hidden;
color: #fff;
z-index: 100;
width: 50%;
position: absolute;
top: 10px;
left: 50%;
background-color: #84ff6a;
visibility: hidden;
color: #fff;
z-index: 100;
}
#LSdebug_hidden {
float: right;
color: #fff;
text-decoration: none;
font-weight: bold;
float: right;
color: #fff;
text-decoration: none;
font-weight: bold;
}

View file

@ -38,6 +38,10 @@ ul.LSform {
margin: 0;
}
li.LSform {
overflow: auto;
}
.LSform-errors {
color: #fff;
background-color: #f59a67;

View file

@ -26,3 +26,7 @@
margin-bottom: 0;
font-size: 100%;
}
#frame-LSsmoothbox {
overflow: auto;
}

View file

@ -65,6 +65,18 @@ hr {
padding: 0.3em;
}
#LSsession_topDn {
height: 1.5em;
}
#LSsession_topDn_form {
float: left;
font-size: 0.7em;
color: #fff;
}
#user_name {
font-weight: bold;
}
@ -213,6 +225,14 @@ form.LSview_search {
margin-right: 2em;
}
form.LSselect_search {
float: none;
}
div.LSselect_search {
float: right;
}
label.LSview_search {
font-size: 0.6em;
display: block;
@ -242,6 +262,13 @@ div.LSobject-select {
width: 10px;
}
#LSselect_topDn_label {
float: left;
font-size: 0.8em;
margin-left: 1em;
margin-top: 0.5em;
}
form.LSselect_search {
margin-top: 0.5em;
}

View file

@ -21,10 +21,10 @@
<dl class='loginform'>
<dt {$loginform_ldapserver_style}>{$loginform_label_ldapserver}</dt>
<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>
<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>
<dd><input type='text' name='LSsession_user' /></dd>
<dt>{$loginform_label_pwd}</dt>

View file

@ -1,13 +1,23 @@
<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'>
{$pagetitle}
</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'>
{include file='select_table.tpl'}
</div>

View file

@ -27,4 +27,17 @@
</ul>
</div>
<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>

View file

@ -99,23 +99,27 @@ if($LSsession -> startLSsession()) {
$GLOBALS['LSsession'] -> addJSscript('LSsmoothbox.js');
$GLOBALS['LSsession'] -> addCssFile('LSsmoothbox.css');
$GLOBALS['LSsession'] -> addJSscript('LSrelation.js');
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
$objRel = new $relationConf['LSobject']();
$list = $objRel -> $relationConf['list_function']($object);
if (is_array($list)) {
foreach($list as $o) {
$return['objectList'][] = $o -> getDisplayValue();
if($GLOBALS['LSsession'] -> loadLSobject($relationConf['LSobject'])) {
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
$objRel = new $relationConf['LSobject']();
$list = $objRel -> $relationConf['list_function']($object);
if (is_array($list)) {
foreach($list as $o) {
$return['objectList'][] = $o -> getDisplayValue();
}
}
else {
$return['objectList']=array();
}
}
else {
$return['objectList']=array();
$GLOBALS['LSerror'] -> addErrorCode(1013,$relationName);
}
$LSrelations[]=$return;
}
else {
$GLOBALS['LSerror'] -> addErrorCode(1013,$relationName);
$GLOBALS['LSerror'] -> addErrorCode(1016,array('relation' => $relationName,'LSobject' => $relationConf['LSobject']));
}
$LSrelations[]=$return;
}
}
$GLOBALS['Smarty'] -> assign('LSrelations',$LSrelations);
@ -168,8 +172,10 @@ if($LSsession -> startLSsession()) {
$filter=NULL;
$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);
$GLOBALS['Smarty']->assign('LSobject_list_nbresult',$nbObjects);
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 (
'label' => _('Supprimer'),
'url' => 'remove.php?LSobject='.$_REQUEST['LSobject'].'&amp;dn='.$thisObject -> getValue('dn'),