2007-03-29 18:10:14 +02:00
|
|
|
|
<?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.
|
|
|
|
|
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
2008-02-05 17:11:21 +01:00
|
|
|
|
$GLOBALS['LSsession'] -> loadLSclass('LSattribute');
|
2007-03-29 18:10:14 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Base d'un objet ldap
|
|
|
|
|
*
|
|
|
|
|
* Cette classe d<EFBFBD>finis la base de tout objet ldap g<EFBFBD>r<EFBFBD> par LdapSaisie
|
|
|
|
|
*
|
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
|
*/
|
|
|
|
|
class LSldapObject {
|
|
|
|
|
|
|
|
|
|
var $config;
|
|
|
|
|
var $type_name;
|
|
|
|
|
var $attrs;
|
|
|
|
|
var $forms;
|
|
|
|
|
var $dn=false;
|
|
|
|
|
var $other_values=array();
|
2007-11-15 19:07:24 +01:00
|
|
|
|
var $submitError=true;
|
2007-03-29 18:10:14 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructeur
|
|
|
|
|
*
|
|
|
|
|
* Cette methode construit l'objet et d<EFBFBD>finis la configuration.
|
|
|
|
|
* Elle lance la construction du tableau d'attributs repr<EFBFBD>sent<EFBFBD>s par un objet LSattribute.
|
|
|
|
|
*
|
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
|
*
|
|
|
|
|
* @param[in] $type_name [<b>required</b>] string Le nom du type de l'objet
|
|
|
|
|
* @param[in] $config array La configuration de l'objet
|
|
|
|
|
*
|
|
|
|
|
* @retval boolean true si l'objet a <EFBFBD>t<EFBFBD> construit, false sinon.
|
|
|
|
|
*/
|
2008-02-05 17:11:21 +01:00
|
|
|
|
function LSldapObject($type_name,$config='auto') {
|
|
|
|
|
$this -> type_name = $type_name;
|
|
|
|
|
$this -> config = $config;
|
|
|
|
|
if($config=='auto') {
|
|
|
|
|
if(isset($GLOBALS['LSobjects'][$type_name])) {
|
|
|
|
|
$this -> config = $GLOBALS['LSobjects'][$type_name];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(21);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2007-03-29 18:10:14 +02:00
|
|
|
|
}
|
|
|
|
|
foreach($this -> config['attrs'] as $attr_name => $attr_config) {
|
2007-11-15 19:07:24 +01:00
|
|
|
|
if(!$this -> attrs[$attr_name]=new LSattribute($attr_name,$attr_config,$this)) {
|
2007-03-29 18:10:14 +02:00
|
|
|
|
return;
|
2007-11-15 19:07:24 +01:00
|
|
|
|
}
|
2007-03-29 18:10:14 +02:00
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Charge les donn<EFBFBD>es de l'objet
|
|
|
|
|
*
|
|
|
|
|
* Cette methode d<EFBFBD>finis le DN de l'objet et charge les valeurs de attributs de l'objet
|
|
|
|
|
* <EFBFBD> partir de l'annuaire.
|
|
|
|
|
*
|
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
|
*
|
|
|
|
|
* @param[in] $dn string Le DN de l'objet.
|
|
|
|
|
*
|
|
|
|
|
* @retval boolean true si la chargement a r<EFBFBD>ussi, false sinon.
|
|
|
|
|
*/
|
|
|
|
|
function loadData($dn) {
|
|
|
|
|
$this -> dn = $dn;
|
|
|
|
|
$data = $GLOBALS['LSldap'] -> getAttrs($dn);
|
|
|
|
|
foreach($this -> attrs as $attr_name => $attr) {
|
|
|
|
|
if(!$this -> attrs[$attr_name] -> loadData($data[$attr_name]))
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-15 19:07:24 +01:00
|
|
|
|
/**
|
|
|
|
|
* Recharge les donn<EFBFBD>es de l'objet
|
|
|
|
|
*
|
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
|
*
|
|
|
|
|
* @retval boolean true si la rechargement a r<EFBFBD>ussi, false sinon.
|
|
|
|
|
*/
|
|
|
|
|
function reloadData() {
|
|
|
|
|
$data = $GLOBALS['LSldap'] -> getAttrs($this -> dn);
|
|
|
|
|
foreach($this -> attrs as $attr_name => $attr) {
|
|
|
|
|
if(!$this -> attrs[$attr_name] -> reloadData($data[$attr_name]))
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-29 18:10:14 +02:00
|
|
|
|
/**
|
|
|
|
|
* Retourne le format d'affichage de l'objet
|
|
|
|
|
*
|
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
|
*
|
|
|
|
|
* @retval string Format d'affichage de l'objet.
|
|
|
|
|
*/
|
|
|
|
|
function getDisplayAttributes() {
|
|
|
|
|
return $this -> config['select_display_attrs'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retourne la valeur descriptive d'affichage de l'objet
|
|
|
|
|
*
|
|
|
|
|
* Cette fonction retourne la valeur descriptive d'affichage de l'objet en fonction
|
|
|
|
|
* du format d<EFBFBD>fini dans la configuration de l'objet ou sp<EFBFBD>cifi<EFBFBD> en param<EFBFBD>tre.
|
|
|
|
|
*
|
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
|
*
|
|
|
|
|
* @param[in] $spe [<i>optionnel</i>] string Format d'affichage de l'objet
|
|
|
|
|
*
|
|
|
|
|
* @retval string Valeur descriptive d'affichage de l'objet
|
|
|
|
|
*/
|
2008-02-05 17:11:21 +01:00
|
|
|
|
function getDisplayValue($spe='') {
|
2007-03-29 18:10:14 +02:00
|
|
|
|
if ($spe=='') {
|
|
|
|
|
$spe = $this -> getDisplayAttributes();
|
|
|
|
|
}
|
|
|
|
|
return $this -> getFData($spe,&$this -> attrs,'getDisplayValue');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Chaine format<EFBFBD>e
|
|
|
|
|
*
|
|
|
|
|
* Cette fonction retourne la valeur d'une chaine format<EFBFBD>e en prennant les valeurs
|
|
|
|
|
* de l'objet.
|
|
|
|
|
*
|
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
|
*
|
|
|
|
|
* @param[in] $format string Format de la chaine
|
|
|
|
|
*
|
|
|
|
|
* @retval string Valeur d'une chaine format<EFBFBD>e
|
|
|
|
|
*/
|
|
|
|
|
function getFData($format) {
|
|
|
|
|
$format=getFData($format,$this,'getValue');
|
|
|
|
|
return $format;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Construit un formulaire de l'objet
|
|
|
|
|
*
|
|
|
|
|
* Cette m<EFBFBD>thode construit un formulaire LSform <EFBFBD> partir de la configuration de l'objet
|
|
|
|
|
* et de chaque attribut.
|
|
|
|
|
*
|
|
|
|
|
* @param[in] $idForm [<b>required</b>] Identifiant du formulaire a cr<EFBFBD>er
|
2007-11-15 19:07:24 +01:00
|
|
|
|
* @param[in] $config Configuration sp<EFBFBD>cifique pour le formulaire
|
2007-03-29 18:10:14 +02:00
|
|
|
|
*
|
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
|
*
|
|
|
|
|
* @retval LSform Le formulaire cr<EFBFBD>e
|
|
|
|
|
*/
|
|
|
|
|
function getForm($idForm,$config=array()) {
|
2008-02-05 17:11:21 +01:00
|
|
|
|
$GLOBALS['LSsession'] -> loadLSclass('LSform');
|
2007-11-15 19:07:24 +01:00
|
|
|
|
$LSform = new LSform($this,$idForm);
|
2007-03-29 18:10:14 +02:00
|
|
|
|
$this -> forms[$idForm] = array($LSform,$config);
|
|
|
|
|
foreach($this -> attrs as $attr_name => $attr) {
|
2007-11-15 19:07:24 +01:00
|
|
|
|
if(!$this -> attrs[$attr_name] -> addToForm($LSform,$idForm,$this)) {
|
2007-03-29 18:10:14 +02:00
|
|
|
|
$LSform -> can_validate = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $LSform;
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-15 19:07:24 +01:00
|
|
|
|
/**
|
|
|
|
|
* Rafraichis le formulaire de l'objet
|
|
|
|
|
*
|
|
|
|
|
* Cette m<EFBFBD>thode recharge les donn<EFBFBD>es d'un formulaire LSform.
|
|
|
|
|
*
|
|
|
|
|
* @param[in] $idForm [<b>required</b>] Identifiant du formulaire a cr<EFBFBD>er
|
|
|
|
|
*
|
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
|
*
|
|
|
|
|
* @retval boolean true sile formulaire a <EFBFBD>t<EFBFBD> rafraichis, false sinon
|
|
|
|
|
*/
|
|
|
|
|
function refreshForm($idForm) {
|
|
|
|
|
$LSform = $this -> forms[$idForm][0];
|
|
|
|
|
foreach($this -> attrs as $attr_name => $attr) {
|
|
|
|
|
if(!$this -> attrs[$attr_name] -> refreshForm($LSform,$idForm)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-29 18:10:14 +02:00
|
|
|
|
/**
|
|
|
|
|
* Met <EFBFBD> jour les donn<EFBFBD>es de l'objet et de l'entr<EFBFBD> de l'annuaire
|
|
|
|
|
*
|
|
|
|
|
* Met <EFBFBD> jour les donn<EFBFBD>es de l'objet <20> partir d'un retour d'un formulaire.
|
|
|
|
|
*
|
|
|
|
|
* @param[in] $idForm Identifiant du formulaire d'origine
|
|
|
|
|
*
|
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
|
*
|
|
|
|
|
* @retval boolean true si la mise <EFBFBD> jour a r<EFBFBD>ussi, false sinon
|
|
|
|
|
*
|
|
|
|
|
* @see validateAttrsData()
|
|
|
|
|
* @see submitChange()
|
|
|
|
|
*/
|
|
|
|
|
function updateData($idForm=NULL) {
|
|
|
|
|
if($idForm!=NULL) {
|
|
|
|
|
if(isset($this -> forms[$idForm]))
|
|
|
|
|
$LSform = $this -> forms[$idForm][0];
|
|
|
|
|
else {
|
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(22,$this -> type_name);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if(count($this -> forms) > 0) {
|
|
|
|
|
reset($this -> forms);
|
|
|
|
|
$idForm = key($this -> forms);
|
|
|
|
|
$LSform = current($this -> forms);
|
|
|
|
|
$config = $LSform[1];
|
|
|
|
|
$LSform = $LSform[0];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(23,$this -> type_name);
|
|
|
|
|
$GLOBALS['LSerror'] -> stop();
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-11-15 19:07:24 +01:00
|
|
|
|
$new_data = $LSform -> exportValues();
|
2007-03-29 18:10:14 +02:00
|
|
|
|
foreach($new_data as $attr_name => $attr_val) {
|
|
|
|
|
if(isset($this -> attrs[$attr_name])) {
|
|
|
|
|
$this -> attrs[$attr_name] -> setUpdateData($attr_val);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if($this -> validateAttrsData($idForm)) {
|
2007-11-15 19:07:24 +01:00
|
|
|
|
debug("les donn<6E>es sont valid<69>es");
|
2007-03-29 18:10:14 +02:00
|
|
|
|
if(isset($this -> config['before_save'])) {
|
|
|
|
|
if(function_exists($this -> config['before_save'])) {
|
|
|
|
|
if(!$this -> config['before_save']($this)) {
|
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(28,$this -> config['before_save']);
|
|
|
|
|
$GLOBALS['LSerror'] -> stop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(27,$this -> config['before_save']);
|
|
|
|
|
$GLOBALS['LSerror'] -> stop();
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-11-15 19:07:24 +01:00
|
|
|
|
if ($this -> submitChange($idForm)) {
|
|
|
|
|
debug('Les modifications sont submit<69>es');
|
|
|
|
|
$this -> submitError = false;
|
|
|
|
|
$this -> reloadData();
|
|
|
|
|
$this -> refreshForm($idForm);
|
|
|
|
|
}
|
|
|
|
|
if((isset($this -> config['after_save']))&&(!$this -> submitError)) {
|
2007-03-29 18:10:14 +02:00
|
|
|
|
if(function_exists($this -> config['after_save'])) {
|
|
|
|
|
if(!$this -> config['after_save']($this)) {
|
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(30,$this -> config['after_save']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(29,$this -> config['after_save']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Valide les donn<EFBFBD>es retourn<EFBFBD>es par un formulaire
|
|
|
|
|
*
|
|
|
|
|
* @param[in] $idForm Identifiant du formulaire d'origine
|
|
|
|
|
*
|
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
|
*
|
|
|
|
|
* @retval boolean true si les donn<EFBFBD>es sont valides, false sinon
|
|
|
|
|
*/
|
|
|
|
|
function validateAttrsData($idForm) {
|
|
|
|
|
$LSform=$this -> forms[$idForm][0];
|
|
|
|
|
foreach($this -> attrs as $attr) {
|
2007-11-15 19:07:24 +01:00
|
|
|
|
if (!$attr -> isValidate()) {
|
|
|
|
|
if($attr -> isUpdate()) {
|
|
|
|
|
if (!$this -> validateAttrData($LSform, $attr)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if( ($attr -> getValue() == '') && ($attr -> isRequired()) ) {
|
|
|
|
|
if ( $attr -> canBeGenerated()) {
|
|
|
|
|
if ($attr -> generateValue()) {
|
|
|
|
|
if (!$this -> validateAttrData($LSform, $attr)) {
|
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(48,$attr -> getLabel());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(47,$attr -> getLabel());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(46,$attr -> getLabel());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-03-29 18:10:14 +02:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2007-11-15 19:07:24 +01:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Valide les donn<EFBFBD>es d'un attribut
|
|
|
|
|
*
|
|
|
|
|
* @param[in] $LSForm Formulaire d'origine
|
|
|
|
|
* @param[in] &$attr Attribut <EFBFBD> valider
|
|
|
|
|
*
|
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
|
*
|
|
|
|
|
* @retval boolean true si les donn<EFBFBD>es sont valides, false sinon
|
|
|
|
|
*/
|
|
|
|
|
function validateAttrData(&$LSform,&$attr) {
|
|
|
|
|
$vconfig=$attr -> getValidateConfig();
|
|
|
|
|
|
|
|
|
|
$data=$attr -> getUpdateData();
|
|
|
|
|
if(!is_array($data)) {
|
|
|
|
|
$data=array($data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Validation des valeurs de l'attribut
|
|
|
|
|
if(is_array($vconfig)) {
|
|
|
|
|
foreach($vconfig as $test) {
|
2008-02-05 17:11:21 +01:00
|
|
|
|
// D<>finition du basedn par d<>faut
|
|
|
|
|
if (!isset($test['basedn'])) {
|
|
|
|
|
$test['basedn']=$GLOBALS['LSsession']->topDn;
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-15 19:07:24 +01:00
|
|
|
|
// D<>finition du message d'erreur
|
|
|
|
|
if (!empty($test['msg'])) {
|
|
|
|
|
$msg_error=getFData($test['msg'],$this,'getValue');
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$msg_error=getFData(_("L'attribut %{attr} n'est pas valide."),$attr -> getLabel());
|
|
|
|
|
}
|
|
|
|
|
foreach($data as $val) {
|
|
|
|
|
// validation par check LDAP
|
|
|
|
|
if((isset($test['filter'])||isset($test['basedn']))&&(isset($test['result']))) {
|
|
|
|
|
$sparams=(isset($test['scope']))?array('scope' => $test['scope']):array();
|
|
|
|
|
$this -> other_values['val']=$val;
|
|
|
|
|
$sfilter_user=(isset($test['basedn']))?getFData($test['filter'],$this,'getValue'):NULL;
|
|
|
|
|
if(isset($test['object_type'])) {
|
2008-02-05 17:11:21 +01:00
|
|
|
|
$test_obj = new $test['object_type']();
|
2007-11-15 19:07:24 +01:00
|
|
|
|
$sfilter=$test_obj->getObjectFilter();
|
|
|
|
|
$sfilter='(&'.$sfilter;
|
|
|
|
|
if($sfilter_user[0]=='(') {
|
|
|
|
|
$sfilter=$sfilter.$sfilter_user.')';
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$sfilter=$sfilter.'('.$sfilter_user.'))';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$sfilter=$sfilter_user;
|
|
|
|
|
}
|
|
|
|
|
$sbasedn=(isset($test['basedn']))?getFData($test['basedn'],$this,'getValue'):NULL;
|
|
|
|
|
$ret=$GLOBALS['LSldap'] -> getNumberResult ($sfilter,$sbasedn,$sparams);
|
|
|
|
|
if($test['result']==0) {
|
|
|
|
|
if($ret!=0) {
|
|
|
|
|
$LSform -> setElementError($attr,$msg_error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if($ret<=0) {
|
|
|
|
|
$LSform -> setElementError($attr,$msg_error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Validation par fonction externe
|
|
|
|
|
else if(isset($test['function'])) {
|
|
|
|
|
if (function_exists($test['function'])) {
|
|
|
|
|
if(!$test['function']($this)) {
|
|
|
|
|
$LSform -> setElementError($attr,$msg_error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(24,array('attr' => $attr->name,'obj' => $this->type_name,'func' => $test['function']));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(25,array('attr' => $attr->name,'obj' => $this->type_name));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// G<>n<EFBFBD>ration des valeurs des attributs d<>pendants
|
|
|
|
|
$dependsAttrs=$attr->getDependsAttrs();
|
|
|
|
|
if (!empty($dependsAttrs)) {
|
|
|
|
|
foreach($dependsAttrs as $dependAttr) {
|
|
|
|
|
if(!isset($this -> attrs[$dependAttr])){
|
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(34,array('attr_depend' => $dependAttr, 'attr' => $attr -> getLabel()));
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if($this -> attrs[$dependAttr] -> canBeGenerated()) {
|
|
|
|
|
if (!$this -> attrs[$dependAttr] -> generateValue()) {
|
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(47,$this -> attrs[$dependAttr] -> getLabel());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(46,$this -> attrs[$dependAttr] -> getLabel());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$attr -> validate();
|
|
|
|
|
unset($this -> other_values['val']);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-29 18:10:14 +02:00
|
|
|
|
/**
|
|
|
|
|
* Met <EFBFBD> jour les donn<EFBFBD>es modifi<EFBFBD>s dans l'annuaire
|
|
|
|
|
*
|
|
|
|
|
* @param[in] $idForm Identifiant du formulaire d'origine
|
|
|
|
|
*
|
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
|
*
|
|
|
|
|
* @retval boolean true si la mise <EFBFBD> jour a r<EFBFBD>ussi, false sinon
|
|
|
|
|
*/
|
|
|
|
|
function submitChange($idForm) {
|
2007-11-15 19:07:24 +01:00
|
|
|
|
$submitData=array();
|
2007-03-29 18:10:14 +02:00
|
|
|
|
foreach($this -> attrs as $attr) {
|
|
|
|
|
if(($attr -> isUpdate())&&($attr -> isValidate())) {
|
2007-11-15 19:07:24 +01:00
|
|
|
|
$submitData[$attr -> name] = $attr -> getUpdateData();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!empty($submitData)) {
|
|
|
|
|
$dn=$this -> getDn();
|
|
|
|
|
if($dn) {
|
2008-02-05 17:11:21 +01:00
|
|
|
|
debug($submitData);
|
2007-11-15 19:07:24 +01:00
|
|
|
|
return $GLOBALS['LSldap'] -> update($this -> type_name,$dn, $submitData);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(33);
|
|
|
|
|
return;
|
2007-03-29 18:10:14 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retourne les informations issus d'un DN
|
|
|
|
|
*
|
|
|
|
|
* @param[in] $dn Un DN.
|
|
|
|
|
*
|
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
|
*
|
|
|
|
|
* @retval array Tableau :
|
|
|
|
|
* - [0] : le premier param<EFBFBD>tre
|
|
|
|
|
* - [1] : les param<EFBFBD>tres suivants
|
|
|
|
|
*/
|
|
|
|
|
function getDnInfos($dn) {
|
|
|
|
|
$infos=ldap_explode_dn($dn,0);
|
|
|
|
|
if(!$infos)
|
|
|
|
|
return;
|
|
|
|
|
$first=true;
|
|
|
|
|
for($i=1;$i<$infos['count'];$i++)
|
|
|
|
|
if($first) {
|
|
|
|
|
$basedn.=$infos[$i];
|
|
|
|
|
$first=false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
$basedn.=','.$infos[$i];
|
|
|
|
|
return array($infos[0],$basedn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Fait la somme de DN
|
|
|
|
|
*
|
|
|
|
|
* Retourne un DN qui correspond au point de s<EFBFBD>paration des DN si les DN
|
|
|
|
|
* ne sont pas dans la meme dans la meme branche ou le dn le plus long sinon.
|
|
|
|
|
*
|
|
|
|
|
* @param[in] $dn Un premier DN.
|
|
|
|
|
* @param[in] $dn Un deuxi<EFBFBD>me DN.
|
|
|
|
|
*
|
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
|
*
|
|
|
|
|
* @retval string Un DN (ou false si les DN ne sont pas valide)
|
|
|
|
|
*/
|
|
|
|
|
function sumDn($dn1,$dn2) {
|
|
|
|
|
$infos1=ldap_explode_dn($dn1,0);
|
|
|
|
|
if(!$infos1)
|
|
|
|
|
return;
|
|
|
|
|
$infos2=ldap_explode_dn($dn2,0);
|
|
|
|
|
if(!$infos2)
|
|
|
|
|
return;
|
|
|
|
|
if($infos2['count']>$infos1['count']) {
|
|
|
|
|
$tmp=$infos1;
|
|
|
|
|
$infos1=$infos2;
|
|
|
|
|
$infos2=$tmp;
|
|
|
|
|
}
|
|
|
|
|
$infos1=array_reverse($infos1);
|
|
|
|
|
$infos2=array_reverse($infos2);
|
|
|
|
|
|
|
|
|
|
$first=true;
|
|
|
|
|
$basedn='';
|
|
|
|
|
for($i=0;$i<$infos1['count'];$i++) {
|
|
|
|
|
if(($infos1[$i]==$infos2[$i])||(!isset($infos2[$i]))) {
|
|
|
|
|
if($first) {
|
|
|
|
|
$basedn=$infos1[$i];
|
|
|
|
|
$first=false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
$basedn=$infos1[$i].','.$basedn;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return $basedn;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $basedn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* V<EFBFBD>rifie la compatibilite des DN
|
|
|
|
|
*
|
|
|
|
|
* V<EFBFBD>rifie que les DNs sont dans la m<EFBFBD>me branche de l'annuaire.
|
|
|
|
|
*
|
|
|
|
|
* @param[in] $dn Un premier DN.
|
|
|
|
|
* @param[in] $dn Un deuxi<EFBFBD>me DN.
|
|
|
|
|
*
|
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
|
*
|
|
|
|
|
* @retval boolean true si les DN sont compatibles, false sinon.
|
|
|
|
|
*/
|
|
|
|
|
function isCompatibleDNs($dn1,$dn2) {
|
|
|
|
|
$infos1=ldap_explode_dn($dn1,0);
|
|
|
|
|
if(!$infos1)
|
|
|
|
|
return;
|
|
|
|
|
$infos2=ldap_explode_dn($dn2,0);
|
|
|
|
|
if(!$infos2)
|
|
|
|
|
return;
|
|
|
|
|
if($infos2['count']>$infos1['count']) {
|
|
|
|
|
$tmp=$infos1;
|
|
|
|
|
$infos1=$infos2;
|
|
|
|
|
$infos2=$tmp;
|
|
|
|
|
}
|
|
|
|
|
$infos1=array_reverse($infos1);
|
|
|
|
|
$infos2=array_reverse($infos2);
|
|
|
|
|
|
|
|
|
|
for($i=0;$i<$infos1['count'];$i++) {
|
|
|
|
|
if(($infos1[$i]==$infos2[$i])||(!isset($infos2[$i])))
|
|
|
|
|
continue;
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retourne le filtre correpondants aux objetcClass de l'objet
|
|
|
|
|
*
|
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
|
*
|
|
|
|
|
* @retval string le filtre ldap correspondant au type de l'objet
|
|
|
|
|
*/
|
|
|
|
|
function getObjectFilter() {
|
|
|
|
|
if(!isset($this -> config['objectclass'])) return;
|
|
|
|
|
foreach ($this -> config['objectclass'] as $class)
|
|
|
|
|
$filter.='(objectClass='.$class.')';
|
|
|
|
|
return $filter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retourne une liste d'objet du m<EFBFBD>me type.
|
|
|
|
|
*
|
|
|
|
|
* Effectue une recherche en fonction des param<EFBFBD>tres pass<EFBFBD> et retourne un
|
|
|
|
|
* tableau d'objet correspond au resultat de la recherche.
|
|
|
|
|
*
|
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
|
*
|
|
|
|
|
* @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<EFBFBD>tres de recherche au format Net_LDAP::search()
|
|
|
|
|
*
|
|
|
|
|
* @retval array Tableau d'objet correspondant au resultat de la recherche
|
|
|
|
|
*/
|
|
|
|
|
function listObjects($filter='',$basedn=NULL,$params=array()) {
|
|
|
|
|
$retInfos=array();
|
|
|
|
|
$attrs=false;
|
|
|
|
|
$check_final_dn=false;
|
|
|
|
|
|
|
|
|
|
if(!is_array($filter))
|
|
|
|
|
$filter=array(array('filter' => $filter));
|
|
|
|
|
|
|
|
|
|
$nbFilter=count($filter);
|
|
|
|
|
|
|
|
|
|
for($i=0;$i<$nbFilter;$i++) {
|
|
|
|
|
$new_attrs=array();
|
|
|
|
|
// D<>fintion des param<61>tres de base pour la recherche
|
|
|
|
|
$sbasedn=$basedn;
|
|
|
|
|
$sparams=$params;
|
|
|
|
|
$ret=array();
|
|
|
|
|
if (isset($filter[$i]['scope']))
|
|
|
|
|
$sparams["scope"]=$filter[$i]['scope'];
|
|
|
|
|
|
|
|
|
|
// Definition des crit<69>res de recherche correspondant au type d'objet <20> lister
|
|
|
|
|
if(($nbFilter==1)||(!isset($filter[$i]['attr']))) {
|
|
|
|
|
// Filtre sur l'objet souhait<69>
|
|
|
|
|
$sfilter='(&';
|
|
|
|
|
$sfilter.=$this -> getObjectFilter();
|
|
|
|
|
$sfilter_end=')';
|
|
|
|
|
$check_final_dn=true;
|
|
|
|
|
}
|
|
|
|
|
// Initialisation des crit<69>res d'une recherche interm<72>diaire
|
|
|
|
|
else {
|
|
|
|
|
if(isset($filter[$i]['object_type'])) {
|
|
|
|
|
$obj_tmp=new $filter[$i]['object_type']();
|
|
|
|
|
$obj_filter=$obj_tmp->getObjectFilter();
|
|
|
|
|
$sfilter='(&'.$obj_filter;
|
|
|
|
|
$sfilter_end=')';
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$sfilter='';
|
|
|
|
|
$sfilter_end='';
|
|
|
|
|
}
|
|
|
|
|
if(isset($filter[$i]['scope'])) {
|
|
|
|
|
$sparams['scope']=$filter[$i]['scope'];
|
|
|
|
|
}
|
|
|
|
|
if(isset($filter[$i]['basedn'])) {
|
|
|
|
|
$sbasedn=$filter[$i]['basedn'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Dans le cas d'une recherche interm<72>diaire ou finale
|
|
|
|
|
if($attrs!=false) {
|
|
|
|
|
// Initialisation des variables
|
|
|
|
|
$ret_gen=array();
|
|
|
|
|
$new_attrs=array();
|
|
|
|
|
|
|
|
|
|
// Pour tout les attributs retourn<72>s
|
|
|
|
|
for($ii=0;$ii<count($attrs);$ii++) {
|
|
|
|
|
$sfilter_for='';
|
|
|
|
|
// D<>finition du filtre de recherche <20> partir des param<61>tres utilisateurs et
|
|
|
|
|
// des param<61>tres de recherche de l'objet <20> list<73> (dans le cas d'une recherche finale
|
|
|
|
|
if((isset($filter[$i]['filter']))&&(!empty($filter[$i]['filter']))) {
|
|
|
|
|
$sfilter_user=getFData($filter[$i]['filter'],$attrs[$ii]);
|
|
|
|
|
if($sfilter_user[0]=='(')
|
|
|
|
|
$sfilter_for=$sfilter.$sfilter_user;
|
|
|
|
|
else
|
|
|
|
|
$sfilter_for=$sfilter.'('.$sfilter_user.')';
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$sfilter_for=$sfilter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(isset($filter[$i]['basedn'])) {
|
|
|
|
|
$sbasedn=getFData($filter[$i]['basedn'],$attrs[$ii]);
|
|
|
|
|
if ((!$this -> isCompatibleDNs($sbasedn,$basedn))&&($check_final_dn)) continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// V<>rification de la compatibilit<69> du basedn de la recherche et du basedn g<>n<EFBFBD>rale
|
|
|
|
|
// Finalisation du filtre
|
|
|
|
|
$sfilter_for.=$sfilter_end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Execution de la recherche
|
|
|
|
|
$ret=$GLOBALS['LSldap'] -> search ($sfilter_for,$sbasedn,$sparams);
|
|
|
|
|
|
|
|
|
|
// Si il y un retour
|
|
|
|
|
if(isset($ret[0])) {
|
|
|
|
|
// si il ya une suite (recherche interm<72>diaire)
|
|
|
|
|
if($filter[$i]['attr']){
|
|
|
|
|
for($iii=0;$iii<count($ret);$iii++) {
|
|
|
|
|
if(isset($ret[$iii]['attrs'][$filter[$i]['attr']])) {
|
|
|
|
|
// cas de valeur multiple
|
|
|
|
|
if(is_array($ret[$iii]['attrs'][$filter[$i]['attr']])) {
|
|
|
|
|
foreach($ret[$iii]['attrs'][$filter[$i]['attr']] as $val_attr) {
|
|
|
|
|
$new_attrs[]=$val_attr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// cas de valeur unique
|
|
|
|
|
else {
|
|
|
|
|
$new_attrs[]=$ret[$iii]['attrs'][$filter[$i]['attr']];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// v<>rification de la compatibilit<69> de la compatibilit<69> du DN resultant
|
|
|
|
|
// et du basedn de recherche
|
|
|
|
|
if (!$this -> isCompatibleDNs($ret[0]['dn'],$basedn))
|
|
|
|
|
continue;
|
|
|
|
|
// ajout du DN au resultat finale
|
|
|
|
|
$ret_gen[]=$ret[0]['dn'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// cas du dernier filtre
|
|
|
|
|
if(!empty($ret_gen)) {
|
|
|
|
|
// on quitte la boucle des filtres de la conf
|
|
|
|
|
$ret=$ret_gen;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
// dans le cas d'une suite pr<70>vu mais d'un retour nul de la pr<70>c<EFBFBD>dente recherche
|
|
|
|
|
else if(empty($new_attrs)) {
|
|
|
|
|
// retour vide et arr<72>t de la recherche
|
|
|
|
|
$ret=array();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$attrs=$new_attrs;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Dans le cas de la recherche initiale
|
|
|
|
|
else {
|
|
|
|
|
// D<>claration du filtre de recherche
|
|
|
|
|
if((isset($filter[$i]['filter']))&&(!empty($filter[$i]['filter']))) {
|
|
|
|
|
if($filter[$i]['filter'][0]=='(') {
|
|
|
|
|
$sfilter.=$filter[$i]['filter'];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$sfilter.='('.$filter[$i]['filter'].')';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// fermeture du filtre
|
|
|
|
|
$sfilter.=$sfilter_end;
|
|
|
|
|
|
|
|
|
|
// Lancement de la recherche
|
|
|
|
|
$ret=$GLOBALS['LSldap'] -> search ($sfilter,$sbasedn,$sparams);
|
|
|
|
|
|
|
|
|
|
//Si filtre multiple => on recup<75>re une liste d'attributs
|
|
|
|
|
if(isset($filter[$i]['attr'])) {
|
|
|
|
|
for($ii=0;$ii<count($ret);$ii++) {
|
|
|
|
|
if(isset($ret[$ii]['attrs'][$filter[$i]['attr']])) {
|
|
|
|
|
// cas de valeur multiple
|
|
|
|
|
if(is_array($ret[$ii]['attrs'][$filter[$i]['attr']])) {
|
|
|
|
|
foreach($ret[$ii]['attrs'][$filter[$i]['attr']] as $val_attr) {
|
|
|
|
|
$attrs[]=$val_attr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// cas de valeur unique
|
|
|
|
|
else {
|
|
|
|
|
$attrs[]=$ret[$ii]['attrs'][$filter[$i]['attr']];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Si aucunne valeur n'est retourn<72>es
|
|
|
|
|
if(empty($attrs)){
|
|
|
|
|
// arr<72>t et retour <20> z<>ro
|
|
|
|
|
$ret=array();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Si recherche unique
|
|
|
|
|
else {
|
|
|
|
|
// pr<70>paration du retour finale
|
|
|
|
|
$ret_final=array();
|
|
|
|
|
foreach($ret as $obj)
|
|
|
|
|
$ret_final[]=$obj['dn'];
|
|
|
|
|
$ret=$ret_final;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Cr<43>ation d'un tableau d'objet correspondant au valeur retourn<72>
|
|
|
|
|
for($i=0;$i<count($ret);$i++) {
|
|
|
|
|
$retInfos[$i] = new $this -> type_name($this -> config);
|
|
|
|
|
$retInfos[$i] -> loadData($ret[$i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $retInfos;
|
|
|
|
|
}
|
2008-02-05 17:11:21 +01:00
|
|
|
|
|
|
|
|
|
function searchObject($name,$basedn=NULL) {
|
|
|
|
|
$filter = $this -> config['rdn'].'='.$name;
|
|
|
|
|
return $this -> listObjects($filter,$basedn);
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-29 18:10:14 +02:00
|
|
|
|
/**
|
|
|
|
|
* Retourne une valeur de l'objet
|
|
|
|
|
*
|
|
|
|
|
* Retourne une valeur en fonction du param<EFBFBD>tre. Si la valeur est inconnue, la valeur retourn<EFBFBD> est ' '.
|
|
|
|
|
* tableau d'objet correspond au resultat de la recherche.
|
|
|
|
|
*
|
|
|
|
|
* Valeurs possibles :
|
|
|
|
|
* - 'dn' ou '%{dn} : DN de l'objet
|
|
|
|
|
* - [nom d'un attribut] : valeur de l'attribut
|
|
|
|
|
* - [clef de $this -> other_values] : valeur de $this -> other_values
|
|
|
|
|
*
|
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
|
*
|
2007-11-15 19:07:24 +01:00
|
|
|
|
* @param[in] $val string Le nom de la valeur demand<EFBFBD>e
|
2007-03-29 18:10:14 +02:00
|
|
|
|
*
|
|
|
|
|
* @retval mixed la valeur demand<EFBFBD> ou ' ' si celle-ci est inconnue.
|
|
|
|
|
*/
|
|
|
|
|
function getValue($val) {
|
|
|
|
|
if(($val=='dn')||($val=='%{dn}')) {
|
|
|
|
|
return $this -> dn;
|
|
|
|
|
}
|
2008-02-05 17:11:21 +01:00
|
|
|
|
else if(($val=='rdn')||($val=='%{rdn}')) {
|
|
|
|
|
return $this -> attrs[ $this -> config['rdn'] ] -> getValue();
|
|
|
|
|
}
|
2007-03-29 18:10:14 +02:00
|
|
|
|
else if(isset($this -> attrs[$val])){
|
|
|
|
|
if (method_exists($this -> attrs[$val],'getValue'))
|
|
|
|
|
return $this -> attrs[$val] -> getValue();
|
|
|
|
|
else
|
|
|
|
|
return ' ';
|
|
|
|
|
}
|
|
|
|
|
else if(isset($this -> other_values[$val])){
|
|
|
|
|
return $this -> other_values[$val];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return ' ';
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-02-05 17:11:21 +01:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retourn une liste d'option pour un select d'un objet du m<EFBFBD>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<EFBFBD>me type
|
|
|
|
|
*
|
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
|
*
|
|
|
|
|
* @retval array['dn','display']
|
|
|
|
|
*/
|
|
|
|
|
function getSelectArray() {
|
|
|
|
|
$list = $this -> listObjects();
|
|
|
|
|
$return=array();
|
|
|
|
|
foreach($list as $object) {
|
|
|
|
|
$return['dn'][] = $object -> getDn();
|
|
|
|
|
$return['display'][] = $object -> getDisplayValue();
|
|
|
|
|
}
|
|
|
|
|
return $return;
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-15 19:07:24 +01:00
|
|
|
|
/**
|
|
|
|
|
* Retourne le DN de l'objet
|
|
|
|
|
*
|
|
|
|
|
* Cette methode retourne le DN de l'objet. Si celui-ci n'existe pas, il le construit <EFBFBD> partir de la
|
|
|
|
|
* configuration de l'objet et la valeur de son attribut rdn.
|
|
|
|
|
*
|
|
|
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
|
|
|
*
|
|
|
|
|
* @retval string Le DN de l'objet
|
|
|
|
|
*/
|
|
|
|
|
function getDn() {
|
|
|
|
|
if($this -> dn) {
|
|
|
|
|
return $this -> dn;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$rdn_attr=$this -> config['rdn'];
|
2008-02-05 17:11:21 +01:00
|
|
|
|
if( (isset($this -> config['rdn'])) && (isset($this -> attrs[$rdn_attr])) && (isset($this -> config['container_dn'])) && (isset($GLOBALS['LSsession']->topDn)) ) {
|
2007-11-15 19:07:24 +01:00
|
|
|
|
$rdn_val=$this -> attrs[$rdn_attr] -> getUpdateData();
|
|
|
|
|
if (!empty($rdn_val)) {
|
2008-02-05 17:11:21 +01:00
|
|
|
|
return $rdn_attr.'='.$rdn_val[0].','.$this -> config['container_dn'].','.$GLOBALS['LSsession']->topDn;
|
2007-11-15 19:07:24 +01:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(32,$this -> config['rdn']);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$GLOBALS['LSerror'] -> addErrorCode(31,$this -> type_name);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-02-05 17:11:21 +01:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Retourne le type de l'objet
|
|
|
|
|
*
|
|
|
|
|
* @retval string Le type de l'objet ($this -> type_name)
|
|
|
|
|
*/
|
|
|
|
|
function getType() {
|
|
|
|
|
return $this -> type_name;
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-29 18:10:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
2007-11-15 19:07:24 +01:00
|
|
|
|
?>
|