mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-18 00:09:06 +01:00
Initial import
This commit is contained in:
parent
d5762b1ec2
commit
684e7fac8d
21 changed files with 2480 additions and 0 deletions
7
trunk/AUTHORS
Normal file
7
trunk/AUTHORS
Normal file
|
@ -0,0 +1,7 @@
|
|||
* Conception :
|
||||
- Benjamin Renard - brenard@easter-eggs.com
|
||||
- Emmanuel Lacour - elacour@easter-eggs.com
|
||||
- Michaël Parienti - mparienti@easter-eggs.com
|
||||
|
||||
* Développement :
|
||||
- Benjamin Renard - brenard@easter-eggs.com
|
101
trunk/conf/config.LSeegroup.php
Normal file
101
trunk/conf/config.LSeegroup.php
Normal file
|
@ -0,0 +1,101 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
$GLOBALS['LSobjects']['LSeegroup'] = array (
|
||||
'objectclass' => array(
|
||||
'ostgroup',
|
||||
'posixGroup'
|
||||
),
|
||||
'select_display_attrs' => '%{cn}',
|
||||
'attrs' => array (
|
||||
'cn' => array (
|
||||
'label' => 'Nom',
|
||||
'ldap_type' => 'ascii',
|
||||
'html_type' => 'text',
|
||||
'required' => 1,
|
||||
'check_data' => array (
|
||||
'alphanumeric'
|
||||
),
|
||||
'validation' => array (
|
||||
array (
|
||||
'basedn' => 'o=ost',
|
||||
'filter' => 'cn=%{val}',
|
||||
'result' => 0
|
||||
)
|
||||
),
|
||||
'form' => array (
|
||||
'test' => 1
|
||||
)
|
||||
),
|
||||
'gidNumber' => array (
|
||||
'label' => 'Identifiant',
|
||||
'ldap_type' => 'numeric',
|
||||
'html_type' => 'text',
|
||||
'required' => 1,
|
||||
'validation' => array (
|
||||
array (
|
||||
'basedn' => 'o=ost',
|
||||
'filter' => 'gidNumber=%{val}',
|
||||
'result' => 0
|
||||
)
|
||||
),
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'self' => 'w', // définition des droits de l'utilisateur sur lui même
|
||||
'users' => 'r' // définition des droits de tout les utilisateurs
|
||||
),
|
||||
'form' => array (
|
||||
'test' => 1
|
||||
)
|
||||
),
|
||||
'uniqueMember' => array (
|
||||
'label' => 'Membres',
|
||||
'ldap_type' => 'ascii',
|
||||
'html_type' => 'select_list',
|
||||
'required' => 0,
|
||||
'validation' => array (
|
||||
array (
|
||||
'basedn' => '%{val}',
|
||||
'result' => 1
|
||||
)
|
||||
),
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'self' => 'w', // définition des droits de l'utilisateur sur lui même
|
||||
'users' => 'r' // définition des droits de tout les utilisateurs
|
||||
),
|
||||
'form' => array (
|
||||
'test' => 1
|
||||
),
|
||||
'possible_values' => array(
|
||||
'aucun' => '-- Selectionner --',
|
||||
'OTHER_OBJECT' => array(
|
||||
'object_type' => 'LSeepeople', // Nom de l'objet à lister
|
||||
'display_attribute' => '%{cn} (%{uidNumber})', // Spécifie le attributs à lister pour le choix,
|
||||
// si non définie => utilisation du 'select_display_attrs'
|
||||
// de la définition de l'objet
|
||||
|
||||
'value_attribute' => '%{dn}', // Spécifie le attributs dont la valeur sera retournée par
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
?>
|
208
trunk/conf/config.LSeepeople.php
Normal file
208
trunk/conf/config.LSeepeople.php
Normal file
|
@ -0,0 +1,208 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
$GLOBALS['LSobjects']['LSeepeople'] = array (
|
||||
'objectclass' => array(
|
||||
'ostpeople',
|
||||
'posixAccount'
|
||||
),
|
||||
'before_save' => 'valid',
|
||||
'after_save' => 'valid',
|
||||
'select_display_attrs' => '%{cn]',
|
||||
'attrs' => array (
|
||||
'uid' => array (
|
||||
'label' => 'Identifiant',
|
||||
'ldap_type' => 'ascii',
|
||||
'html_type' => 'text',
|
||||
'required' => 1,
|
||||
'check_data' => array (
|
||||
'alphanumeric' => array(
|
||||
'msg' => "L'identifiant ne doit comporter que des lettres et des chiffres."
|
||||
),
|
||||
),
|
||||
'validation' => array (
|
||||
array (
|
||||
'basedn' => 'o=ost',
|
||||
'filter' => 'uid=%{val}',
|
||||
'result' => 0,
|
||||
//~ 'msg' => 'Cet identifiant est déjà utilisé.'
|
||||
)
|
||||
),
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'self' => 'w', // définition des droits de l'utilisateur sur lui même
|
||||
'users' => 'r' // définition des droits de tout les utilisateurs
|
||||
),
|
||||
'form' => array (
|
||||
'test' => 0,
|
||||
'add' => 1
|
||||
)
|
||||
),
|
||||
'uidNumber' => array (
|
||||
'label' => 'Identifiant (numérique)',
|
||||
'ldap_type' => 'numeric',
|
||||
'html_type' => 'text',
|
||||
'required' => 1,
|
||||
'check_data' => array (
|
||||
'numeric' => array(
|
||||
'msg' => "L'identifiant unique doit être un entier."
|
||||
),
|
||||
),
|
||||
'validation' => array (
|
||||
array (
|
||||
'basedn' => 'o=ost',
|
||||
'filter' => 'uidNumber=%{val}',
|
||||
'result' => 0,
|
||||
//~ 'msg' => 'Cet identifiant est déjà utilisé.'
|
||||
)
|
||||
),
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'self' => 'w', // définition des droits de l'utilisateur sur lui même
|
||||
'users' => 'r' // définition des droits de tout les utilisateurs
|
||||
),
|
||||
'form' => array (
|
||||
'test' => 0,
|
||||
'add' => 1
|
||||
)
|
||||
),
|
||||
'cn' => array (
|
||||
'label' => 'Nom complet',
|
||||
'ldap_type' => 'ascii',
|
||||
'html_type' => 'text',
|
||||
'required' => 1,
|
||||
'validation' => 'valid',
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'self' => 'w', // définition des droits de l'utilisateur sur lui même
|
||||
'users' => 'r' // définition des droits de tout les utilisateurs
|
||||
),
|
||||
'form' => array (
|
||||
'test' => 1,
|
||||
'add' => 1
|
||||
)
|
||||
),
|
||||
'givenName' => array (
|
||||
'label' => 'Prenom',
|
||||
'ldap_type' => 'ascii',
|
||||
'html_type' => 'text',
|
||||
'required' => 1,
|
||||
'default_value' => 'toto',
|
||||
'check_data' => array (
|
||||
'alphanumeric' => array(
|
||||
'msg' => 'Le prenom ne doit comporter que des lettres et des chiffres.'
|
||||
),
|
||||
),
|
||||
//~ 'validation' => array (
|
||||
//~ array (
|
||||
//~ 'basedn' => 'o=ost',
|
||||
//~ 'filter' => 'uid=%{uid}',
|
||||
//~ 'result' => 0
|
||||
//~ )
|
||||
//~ ),
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'self' => 'w', // définition des droits de l'utilisateur sur lui même
|
||||
'users' => 'r' // définition des droits de tout les utilisateurs
|
||||
),
|
||||
'form' => array (
|
||||
'test' => 1,
|
||||
'add' => 1
|
||||
),
|
||||
'onDisplay' => 'return_data'
|
||||
),
|
||||
'sn' => array (
|
||||
'label' => 'Nom',
|
||||
'ldap_type' => 'ascii',
|
||||
'html_type' => 'text',
|
||||
'required' => 1,
|
||||
'check_data' => array (
|
||||
'alphanumeric' => array(
|
||||
'msg' => 'Le nom ne doit comporter que des lettres et des chiffres.'
|
||||
),
|
||||
),
|
||||
//~ 'validation' => array (
|
||||
//~ array (
|
||||
//~ 'basedn' => 'o=ost',
|
||||
//~ 'filter' => 'uid=%{uid}',
|
||||
//~ 'result' => 0
|
||||
//~ )
|
||||
//~ ),
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'self' => 'w', // définition des droits de l'utilisateur sur lui même
|
||||
'users' => 'r' // définition des droits de tout les utilisateurs
|
||||
),
|
||||
'form' => array (
|
||||
'test' => 1,
|
||||
'add' => 1
|
||||
)
|
||||
),
|
||||
'gidNumber' => array (
|
||||
'label' => 'Groupe principal',
|
||||
'ldap_type' => 'numeric',
|
||||
'html_type' => 'select_list',
|
||||
'required' => 1,
|
||||
'validation' => array (
|
||||
array (
|
||||
'object_type' => 'LSeegroup', // 'object_type' : Permet definir le type d'objet recherchés
|
||||
'basedn' => 'o=ost', // et d'utiliser les objectClass définis dans le fichier de configuration
|
||||
'filter' => '(gidNumber=%{val})', // pour la recherche
|
||||
'result' => 1
|
||||
)
|
||||
),
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'self' => 'w', // définition des droits de l'utilisateur sur lui même
|
||||
'users' => 'r' // définition des droits de tout les utilisateurs
|
||||
),
|
||||
'form' => array (
|
||||
'test' => 1,
|
||||
'add' => 1
|
||||
),
|
||||
'possible_values' => array(
|
||||
'aucun' => '-- Selectionner --',
|
||||
'OTHER_OBJECT' => array(
|
||||
'object_type' => 'LSeegroup', // Nom de l'objet à lister
|
||||
'display_attribute' => '%{cn} (%{gidNumber})', // Spécifie le attributs à lister pour le choix,
|
||||
// si non définie => utilisation du 'select_display_attrs'
|
||||
// de la définition de l'objet
|
||||
|
||||
'value_attribute' => 'gidNumber', // Spécifie le attributs dont la valeur sera retournée par
|
||||
'filter' => // le formulaire spécifie les filtres de recherche pour
|
||||
array ( // l'établissement de la liste d'objets :
|
||||
array( // Premier filtre
|
||||
'filter' => 'cn=*a*',
|
||||
'basedn' => 'o=ost',
|
||||
'scope' => 'sub',
|
||||
//~ 'attr' => '[attribut]', // Si 'attr' est définis, on effectura pour chacune des
|
||||
// valeurs de l'attribut correspants une recherche avec
|
||||
// le filtre suivant composé avec la valeur de cette attribut
|
||||
)
|
||||
//~ array(
|
||||
//~ 'filter' => '[format sprintf]',
|
||||
//~ 'basedn' => '[basedn]',
|
||||
//~ ),
|
||||
//~ ...
|
||||
)
|
||||
//~ 'basedn' =>
|
||||
//~ '[basedn]'
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
?>
|
42
trunk/conf/config.php
Normal file
42
trunk/conf/config.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
// Configuration LDAP Saisie :
|
||||
$GLOBALS['LSconfig'] = array(
|
||||
'NetLDAP' => '/usr/share/php/Net/LDAP.php',
|
||||
'QuickForm' => '/usr/share/php/QuickForm.php',
|
||||
'check_data_place' => 'server',
|
||||
'ldap_config'=> array(
|
||||
'host' => 'localhost',
|
||||
'port' => 389,
|
||||
'version' => 3,
|
||||
'starttls' => false,
|
||||
'binddn' => 'uid=eeggs,ou=people,o=com',
|
||||
'bindpw' => 'toto',
|
||||
'basedn' => 'o=ost',
|
||||
'options' => array(),
|
||||
'filter' => '(objectClass=*)',
|
||||
'scope' => 'sub'
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
118
trunk/conf/error_code.php
Normal file
118
trunk/conf/error_code.php
Normal file
|
@ -0,0 +1,118 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
$GLOBALS['error_code'] = array (
|
||||
'-1' => array (
|
||||
'msg' => 'Erreur inconnue!',
|
||||
'level' => 'c'
|
||||
),
|
||||
// LSldap
|
||||
1 => array (
|
||||
'msg' => 'LSldap : Erreur durant la connexion au serveur LDAP (%{msg}).',
|
||||
'level' => 'c'
|
||||
),
|
||||
2 => array (
|
||||
'msg' => 'LSldap : Erreur durant la recherche LDAP (%{msg}).',
|
||||
'level' => 'c'
|
||||
),
|
||||
|
||||
// LSldapObject
|
||||
21 => array (
|
||||
'msg' => "LSldapObject : Type d'objet inconnu.",
|
||||
'level' => 'c'
|
||||
),
|
||||
22 => array (
|
||||
'msg' => "LSldapObject : Formulaire de mise jour inconnu par l'objet %{msg}.",
|
||||
'level' => 'c'
|
||||
),
|
||||
23 => array (
|
||||
'msg' => "LSldapObject : Aucun formulaire n'existe dans l'objet %{msg}.",
|
||||
'level' => 'c'
|
||||
),
|
||||
24 => array (
|
||||
'msg' => "LSldapObject : La fonction %{func} pour valider l'attribut %{attr} de l'objet %{obj} est inconnue.",
|
||||
'level' => 'c'
|
||||
),
|
||||
25 => array (
|
||||
'msg' => "LSldapObject : Des données de configuration sont manquant pour la validation de l'attribut %{attr} de l'objet %{obj}.",
|
||||
'level' => 'c'
|
||||
),
|
||||
26 => array (
|
||||
'msg' => "LSldapObject : Erreur de configuration : L'objet %{obj} ne possède pas d'attribut %{attr}.",
|
||||
'level' => 'c'
|
||||
),
|
||||
27 => array (
|
||||
'msg' => "LSldapObject : La fonction %{func} devant être executée avant l'enregistrement n'existe pas.",
|
||||
'level' => 'c'
|
||||
),
|
||||
28 => array (
|
||||
'msg' => "LSldapObject : L'execution de la fonction %{func} devant être executée avant l'enregistrement a échouée.",
|
||||
'level' => 'c'
|
||||
),
|
||||
29 => array (
|
||||
'msg' => "LSldapObject : La fonction %{func} devant être executée après l'enregistrement n'existe pas.",
|
||||
'level' => 'c'
|
||||
),
|
||||
30 => array (
|
||||
'msg' => "LSldapObject : L'execution de la fonction %{func} devant être executée après l'enregistrement a échouée.",
|
||||
'level' => 'c'
|
||||
),
|
||||
|
||||
// LSldapObject
|
||||
41 => array (
|
||||
'msg' => "LSattribute : Type d'attribut (ldap // html) inconnu (ldap = %{ldap} | html = %{html}).",
|
||||
'level' => 'c'
|
||||
),
|
||||
42 => array (
|
||||
'msg' => "LSattribute : La fonction %{func} pour afficher l'attribut %{attr} est inconnue.",
|
||||
'level' => 'c'
|
||||
),
|
||||
43 => array (
|
||||
'msg' => "LSattribute : La règle %{rule} pour valider l'attribut %{attr} est inconnue.",
|
||||
'level' => 'c'
|
||||
),
|
||||
44 => array (
|
||||
'msg' => "LSattribute : Les données de configuration pour vérifié l'attribut %{attr} sont incorrects.",
|
||||
'level' => 'c'
|
||||
),
|
||||
45 => array (
|
||||
'msg' => "LSattribute : La fonction %{func} pour sauver l'attribut %{attr} est inconnue.",
|
||||
'level' => 'c'
|
||||
),
|
||||
|
||||
// LSattr_html
|
||||
101 => array (
|
||||
'msg' => "LSattr_html : La fonction addToForm() du type html de l'attribut %{attr} n'est pas définie.",
|
||||
'level' => 'c'
|
||||
),
|
||||
102 => array (
|
||||
'msg' => "LSattr_html_select_list : Des données de configuration sont manquante pour la génération de la liste deroulante de l'attribut %{attr}.",
|
||||
'level' => 'c'
|
||||
),
|
||||
|
||||
// functions
|
||||
901 => array (
|
||||
'msg' => "Functions 'getFData' : La methode %{meth} de l'objet %{obj} n'existe pas.",
|
||||
'level' => 'c'
|
||||
),
|
||||
);
|
||||
?>
|
49
trunk/includes/class/class.LSattr_html.php
Normal file
49
trunk/includes/class/class.LSattr_html.php
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Base d'un type d'attribut HTML
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSattr_html {
|
||||
|
||||
var $name;
|
||||
var $config;
|
||||
|
||||
function LSattr_html ($name,$config) {
|
||||
$this -> name = $name;
|
||||
$this -> config = $config;
|
||||
return true;
|
||||
}
|
||||
|
||||
function getLabel() {
|
||||
return $this -> config['label'];
|
||||
}
|
||||
|
||||
function addToForm (&$form,$idForm) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(101,$this -> name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
81
trunk/includes/class/class.LSattr_html_select_list.php
Normal file
81
trunk/includes/class/class.LSattr_html_select_list.php
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Type d'attribut HTML select_list
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSattr_html_select_list extends LSattr_html{
|
||||
|
||||
function addToForm (&$form,$idForm) {
|
||||
return $form -> addElement('select', $this -> name, $this -> config['label'],$this -> getPossibleValues());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne un tableau des valeurs possibles de la liste
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval array Tableau associatif des valeurs possible de la liste avec en clé
|
||||
* la valeur des balises option et en valeur ce qui sera affiché.
|
||||
*/
|
||||
function getPossibleValues() {
|
||||
$retInfos = array();
|
||||
if (isset($this -> config['possible_values'])) {
|
||||
foreach($this -> config['possible_values'] as $val_name => $val) {
|
||||
if($val_name=='OTHER_OBJECT') {
|
||||
//~ print_r($val);
|
||||
if ((!isset($val['object_type'])) || (!isset($val['value_attribute']))) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(102,$this -> name);
|
||||
break;
|
||||
}
|
||||
$obj = new $val['object_type']();
|
||||
if($val['scope']) {
|
||||
$param=array('scope' => $this -> config['possible_values']['scope']);
|
||||
}
|
||||
else {
|
||||
$param=array();
|
||||
}
|
||||
$list = $obj -> listObjects($val['filter'],$this -> config['possible_values']['basedn'],$param);
|
||||
if(($val['value_attribute']=='dn')||($val['value_attribute']=='%{dn}')) {
|
||||
for($i=0;$i<count($list);$i++) {
|
||||
$retInfos[$list[$i] -> dn]=$list[$i] -> getDisplayValue($val['display_attribute']);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for($i=0;$i<count($list);$i++) {
|
||||
$retInfos[$list[$i] -> attrs[$val['value_attribute']] -> getValue()]=$list[$i] -> getDisplayValue($val['display_attribute']);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$retInfos[$val_name]=$val;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $retInfos;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
36
trunk/includes/class/class.LSattr_html_text.php
Normal file
36
trunk/includes/class/class.LSattr_html_text.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Type d'attribut HTML text
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSattr_html_text extends LSattr_html {
|
||||
|
||||
function addToForm (&$form,$idForm) {
|
||||
return $form -> addElement('text', $this -> name, $this -> config['label']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
49
trunk/includes/class/class.LSattr_ldap.php
Normal file
49
trunk/includes/class/class.LSattr_ldap.php
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Base d'un type d'attribut Ldap
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSattr_ldap {
|
||||
|
||||
var $name;
|
||||
var $config;
|
||||
|
||||
function LSattr_ldap ($name,$config) {
|
||||
$this -> name = $name;
|
||||
$this -> config = $config;
|
||||
return true;
|
||||
}
|
||||
|
||||
function getUpdateData($data) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
function getDisplayValue($data) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
32
trunk/includes/class/class.LSattr_ldap_ascii.php
Normal file
32
trunk/includes/class/class.LSattr_ldap_ascii.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Type d'attribut Ldap numeric
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSattr_ldap_ascii extends LSattr_ldap {
|
||||
//\\
|
||||
}
|
||||
|
||||
?>
|
32
trunk/includes/class/class.LSattr_ldap_numeric.php
Normal file
32
trunk/includes/class/class.LSattr_ldap_numeric.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Type d'attribut Ldap numeric
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSattr_ldap_numeric extends LSattr_ldap {
|
||||
// \\
|
||||
}
|
||||
|
||||
?>
|
300
trunk/includes/class/class.LSattribute.php
Normal file
300
trunk/includes/class/class.LSattribute.php
Normal file
|
@ -0,0 +1,300 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Attribut Ldap
|
||||
*
|
||||
* Cette classe modélise un attribut Ldap
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSattribute {
|
||||
|
||||
var $name;
|
||||
var $config;
|
||||
var $ldap;
|
||||
var $html;
|
||||
var $data;
|
||||
var $updateData=false;
|
||||
var $is_validate=false;
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
*
|
||||
* Cette methode construit l'objet et définis la configuration.
|
||||
* Elle lance la construction des objets LSattr_html et LSattr_ldap correspondant
|
||||
* à ses types définis définis dans sa configuration
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $name string Nom de l'attribut ldap
|
||||
* @param[in] $config array Configuration de l'objet
|
||||
*
|
||||
* @retval boolean Retourne true si la création a réussi, false sinon.
|
||||
*/
|
||||
function LSattribute ($name,$config) {
|
||||
$this -> name = $name;
|
||||
$this -> config = $config;
|
||||
$html_type = "LSattr_html_".$config['html_type'];
|
||||
$ldap_type = "LSattr_ldap_".$config['ldap_type'];
|
||||
if((class_exists($html_type))&&(class_exists($ldap_type))) {
|
||||
$this -> html = new $html_type($name,$config);
|
||||
$this -> ldap = new $ldap_type($name,$config);
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(41,array('html'=>$config['html_type'],'ldap'=>$config['ldap_type']));
|
||||
return;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retourne la valeur du label de l'attribut
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval string Le label de l'attribut
|
||||
*
|
||||
* @see LSattr_html::getLabel()
|
||||
*/
|
||||
|
||||
function getLabel() {
|
||||
return $this -> html -> getLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Défini la valeur de l'attribut
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval boolean true
|
||||
*/
|
||||
function loadData($attr_data) {
|
||||
$this -> data = $attr_data;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* DEBIG : affiche la valeur de l'attribut
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
function debug_printValue() {
|
||||
print $this -> data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne la valeur de l'attribut
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval mixed La valeur de l'attribut
|
||||
*/
|
||||
function getValue() {
|
||||
return $this -> data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne la valeur d'affichage de l'attribut
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval string La valeur d'affichage de l'attribut
|
||||
*/
|
||||
function getDisplayValue() {
|
||||
$data = $this -> ldap -> getDisplayValue($this -> data);
|
||||
if ($this -> config['onDisplay']) {
|
||||
if (is_array($this -> config['onDisplay'])) {
|
||||
$result=$data;
|
||||
foreach($this -> config['onDisplay'] as $func) {
|
||||
if (function_exists($func)) {
|
||||
$result=$func($result);
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(42,array('attr' => $this->name,'func' => $func));
|
||||
return;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
else {
|
||||
if (function_exists($this -> config['onDisplay'])) {
|
||||
return $this -> config['onDisplay']($data);
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(42,array('attr' => $this->name,'func' => $this -> config['onDisplay']));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajoute l'attribut au formualaire
|
||||
*
|
||||
* Cette méthode ajoute l'attribut au formulaire $form si l'identifiant de celui-ci
|
||||
* ($idForm) est connu dans la configuration de l'objet.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] object LSform Le formulaire dans lequel doit être ajouté l'attribut
|
||||
* @param[in] string L'identifiant du formulaire
|
||||
*
|
||||
* @retval boolean true si l'ajout a fonctionner ou qu'il n'est pas nécessaire, false sinon
|
||||
*/
|
||||
function addToForm(&$form,$idForm) {
|
||||
if(isset($this -> config['form'][$idForm])) {
|
||||
$element = $this -> html -> addToForm($form,$idForm);
|
||||
if($this -> config['required']==1)
|
||||
$form->addRule($this -> name, "Le champ '".$this -> config['label']."' est obligatoire.",'required', null, 'client');
|
||||
/// !!!!! A CHANGER !!!!!!! \\\\ => utiliser une fonction de traitement de donnée
|
||||
if($this -> data !='')
|
||||
$element -> setValue($this -> getFormVal());
|
||||
else if (isset($this -> config['default_value']))
|
||||
$element -> setValue($this -> config['default_value']);
|
||||
if($this -> config['form'][$idForm]==0)
|
||||
$element -> freeze();
|
||||
if(isset($this -> config['check_data'])) {
|
||||
if(is_array($this -> config['check_data'])) {
|
||||
foreach ($this -> config['check_data'] as $rule => $rule_infos) {
|
||||
if((!$form -> isRuleRegistered($rule))&&($rule!='')) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(43,array('attr' => $this->name,'rule' => $rule));
|
||||
return;
|
||||
}
|
||||
if(!isset($rule_infos['msg']))
|
||||
$rule_infos['msg']='La valeur du champs '.$this -> config['label'].' est invalide.';
|
||||
if(!isset($rule_infos['param']))
|
||||
$rule_infos['param']=NULL;
|
||||
$form -> addRule($this -> name,$rule_infos['msg'],$rule,$rule_infos['param'],$GLOBALS['LSconfig']['check_data_place']);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(44,$this->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne la valeur a afficher dans le formulaire
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval string La valeur a afficher dans le formulaire.
|
||||
*/
|
||||
function getFormVal() {
|
||||
return $this -> getDisplayValue();
|
||||
}
|
||||
|
||||
function setUpdateData($data) {
|
||||
if($this -> getFormVal() != $data)
|
||||
$this -> updateData=$data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifie si l'attribut a été validé
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval boolean true si l'attribut a été validé, false sinon
|
||||
*/
|
||||
function isValidate() {
|
||||
return ((!isset($this -> config['validation'])) || ($this -> is_validate));
|
||||
}
|
||||
|
||||
/**
|
||||
* Valide le champs
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
function validate() {
|
||||
$this -> is_validate=true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifie si l'attribut a été mise à jour
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval boolean true si l'attribut a été mis à jour, false sinon
|
||||
*/
|
||||
function isUpdate() {
|
||||
return ($this -> updateData)?true:false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne la valeur de l'attribut pour son enregistrement dans l'annuaire
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval mixed La valeur de l'attribut pour son enregistrement dans l'annuaire
|
||||
*/
|
||||
function getUpdateData() {
|
||||
$data=($this ->isUpdate())?$this -> updateData:$this -> data;
|
||||
if ($this -> config['onSave']) {
|
||||
if (is_array($this -> config['onSave'])) {
|
||||
$result=$data;
|
||||
foreach($this -> config['onSave'] as $func) {
|
||||
if (function_exists($func)) {
|
||||
$result=$func($result);
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(45,array('attr' => $this->name,'func' => $func));
|
||||
return;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
else {
|
||||
if (function_exists($this -> config['onSave'])) {
|
||||
return $this -> config['onSave']($data);
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(45,array('attr' => $this->name,'func' => $this -> config['onSave']));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this -> ldap -> getUpdateData($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne la configuration de validation de l'annuaire
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval mixed La configuration de validation de l'attribut
|
||||
*/
|
||||
function getValidateConfig() {
|
||||
return $this -> config['validation'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
46
trunk/includes/class/class.LSeegroup.php
Normal file
46
trunk/includes/class/class.LSeegroup.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Objet Ldap eegroup
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSeegroup extends LSldapObject {
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
*
|
||||
* Cette methode construit l'objet et définis la configuration.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $config array La configuration de l'objet
|
||||
*
|
||||
* @retval boolean true si l'objet a été construit, false sinon.
|
||||
*/
|
||||
function LSeegroup ($config='auto') {
|
||||
$this -> LSldapObject('LSeegroup',$config);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
46
trunk/includes/class/class.LSeepeople.php
Normal file
46
trunk/includes/class/class.LSeepeople.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Objet Ldap eepeople
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSeepeople extends LSldapObject {
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
*
|
||||
* Cette methode construit l'objet et définis la configuration.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $config array La configuration de l'objet
|
||||
*
|
||||
* @retval boolean true si l'objet a été construit, false sinon.
|
||||
*/
|
||||
function LSeepeople ($config='auto') {
|
||||
return $this -> LSldapObject('LSeepeople',$config);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
90
trunk/includes/class/class.LSerror.php
Normal file
90
trunk/includes/class/class.LSerror.php
Normal file
|
@ -0,0 +1,90 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Gestion des erreurs pour LdapSaisie
|
||||
*
|
||||
* Cette classe gère les retours d'erreurs.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSerror {
|
||||
|
||||
var $errors;
|
||||
/**
|
||||
* Constructeur
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
function LSerror() {
|
||||
$errors = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajoute une erreur
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $code numeric Le code de l'erreur
|
||||
* @param[in] $msg mixed Un tableau ou une chaine pour la construction du message d'erreur
|
||||
* Tableau : '[clef]' => 'valeur'
|
||||
* La clef sera utilisé dans le format de message d'erreur
|
||||
* dans le fichier 'error_code.php'.
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
function addErrorCode($code=-1,$msg='') {
|
||||
$this -> errors[]=array($code,$msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Affiche les erreurs et arrête l'execution du code
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
function stop(){
|
||||
$this -> display();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Affiche les erreurs
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
function display() {
|
||||
if(!empty($this -> errors)) {
|
||||
print "<h3>Erreurs</h3>\n";
|
||||
foreach ($this -> errors as $error) {
|
||||
echo "(Code ".$error[0].") ".getFData($GLOBALS['error_code'][$error[0]]['msg'],$error[1])."<br />\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
109
trunk/includes/class/class.LSform.php
Normal file
109
trunk/includes/class/class.LSform.php
Normal file
|
@ -0,0 +1,109 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* Formulaire pour LdapSaisie
|
||||
*
|
||||
* Cette classe gère les formulaires en se basant sur PEAR::HTML_QuickForm
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
|
||||
class LSform {
|
||||
|
||||
var $quickform;
|
||||
var $idForm;
|
||||
var $can_validate=true;
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
*
|
||||
* Cette methode construit l'objet et définis la configuration.
|
||||
* Elle lance la construction de l'objet HTML_QuickForm et définis les élements
|
||||
* de base à communiquer de page en page par le formulaire.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $idForm [<b>required</b>] string L'identifiant du formulaire
|
||||
* @param[in] $submit string La valeur du bouton submit
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
function LSform ($idForm,$submit="Envoyer"){
|
||||
$this -> idForm = $idForm;
|
||||
$this -> submit = $submit;
|
||||
$this -> quickform = new HTML_QuickForm($idForm);
|
||||
$this -> quickform -> addElement('hidden',"LSdata['idForm']",$idForm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Affiche le formualaire
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
function display(){
|
||||
if($this -> can_validate) {
|
||||
$this -> quickform -> addElement('submit', null, $this -> submit);
|
||||
}
|
||||
$this -> quickform -> display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Défini l'erreur sur un champ
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $attr [<b>required</b>] string Le nom du champ
|
||||
* @param[in] $msg Le format du message d'erreur à afficher (pouvant comporter
|
||||
* des valeurs %{[n'importe quoi]} qui seront remplacé par le label
|
||||
* du champs concerné.
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
function setElementError($attr,$msg=NULL) {
|
||||
//~ print 'erreur<br />';
|
||||
if($msg!='') {
|
||||
$msg_error=getFData($msg,$attr->getLabel());
|
||||
}
|
||||
else {
|
||||
$msg_error="Les données pour l'attribut ".$attr->getLabel()." ne sont pas valides.";
|
||||
}
|
||||
$this -> quickform -> setElementError($attr->name,$msg_error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifie si le formulaire a été validé et que les données sont valides.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval boolean true si le formulaire a été validé et que les données ont été validées, false sinon
|
||||
*/
|
||||
function validate(){
|
||||
return (($this -> can_validate)&&($this -> quickform -> validate()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
171
trunk/includes/class/class.LSldap.php
Normal file
171
trunk/includes/class/class.LSldap.php
Normal file
|
@ -0,0 +1,171 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSldap {
|
||||
|
||||
var $config;
|
||||
var $cnx = NULL;
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
*
|
||||
* Cette methode définis la configuration de l'accès à l'annuaire
|
||||
* et établie la connexion.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $config array Tableau de configuration au formar Net_LDAP
|
||||
*
|
||||
* @retval void
|
||||
*
|
||||
* @see Net_LDAP::connect()
|
||||
*/
|
||||
function LSldap ($config) {
|
||||
$this -> config = $config;
|
||||
$this -> connect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Connection
|
||||
*
|
||||
* Cette methode établie la connexion à l'annuaire Ldap
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @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)) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1,$this -> cnx -> getMessage());
|
||||
$this -> cnx = NULL;
|
||||
return;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Déconnection
|
||||
*
|
||||
* Cette methode clos la connexion à l'annuaire Ldap
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
function close() {
|
||||
$this -> cnx -> done();
|
||||
}
|
||||
|
||||
/**
|
||||
* Recherche dans l'annuaire
|
||||
*
|
||||
* Cette methode effectue une recherche dans l'annuaire et retourne le resultat
|
||||
* de celle-ci sous la forme d'un tableau.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @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()
|
||||
*
|
||||
* @see Net_LDAP::search()
|
||||
*
|
||||
* @retval array Retourne un tableau associatif contenant :
|
||||
* - ['dn'] : le DN de l'entré
|
||||
* - ['attrs'] : tableau associatif contenant les attributs (clé)
|
||||
* et leur valeur (valeur).
|
||||
*/
|
||||
function search ($filter,$basedn=NULL,$params = array() ) {
|
||||
$ret = $this -> cnx -> search($basedn,$filter,$params);
|
||||
if (Net_LDAP::isError($ret)) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(2,$ret -> getMessage());
|
||||
return;
|
||||
}
|
||||
$retInfos=array();
|
||||
foreach($ret -> entries() as $entry) {
|
||||
$retInfos[]=array('dn' => $entry -> dn(), 'attrs' => $entry -> getValues());
|
||||
}
|
||||
return $retInfos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compte le nombre de retour d'une recherche dans l'annuaire
|
||||
*
|
||||
* Cette methode effectue une recherche dans l'annuaire et retourne le nombre
|
||||
* d'entrés trouvées.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @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()
|
||||
*
|
||||
* @see Net_LDAP::search()
|
||||
*
|
||||
* @retval numeric Le nombre d'entré trouvées
|
||||
*/
|
||||
function getNumberResult ($filter,$basedn=NULL,$params = array() ) {
|
||||
if (empty($filter))
|
||||
$filter=NULL;
|
||||
$ret = $this -> cnx -> search($basedn,$filter,$params);
|
||||
if (Net_LDAP::isError($ret)) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(2,$ret -> getMessage());
|
||||
return;
|
||||
}
|
||||
return $ret -> count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Charge les valeurs des attributs d'une entré de l'annuaire
|
||||
*
|
||||
* Cette methode recupère les valeurs des attributs d'une entrée de l'annaire
|
||||
* et les retournes sous la forme d'un tableau.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $dn string DN de l'entré Ldap
|
||||
*
|
||||
* @retval array Tableau associatif des valeurs des attributs avec en clef, le nom de l'attribut.
|
||||
*/
|
||||
function getAttrs($dn) {
|
||||
$infos = ldap_explode_dn($dn,0);
|
||||
if((!$infos)||($infos['count']==0))
|
||||
return;
|
||||
$basedn='';
|
||||
for ($i=1;$i<$infos['count'];$i++) {
|
||||
$sep=($basedn=='')?'':',';
|
||||
$basedn.=$sep.$infos[$i];
|
||||
}
|
||||
$return=$this -> search($infos[0],$basedn);
|
||||
return $return[0]['attrs'];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
724
trunk/includes/class/class.LSldapObject.php
Normal file
724
trunk/includes/class/class.LSldapObject.php
Normal file
|
@ -0,0 +1,724 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* Base d'un objet ldap
|
||||
*
|
||||
* Cette classe définis la base de tout objet ldap géré 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();
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
*
|
||||
* Cette methode construit l'objet et définis la configuration.
|
||||
* Elle lance la construction du tableau d'attributs représenté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 été construit, false sinon.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
foreach($this -> config['attrs'] as $attr_name => $attr_config) {
|
||||
if(!$this -> attrs[$attr_name]=new LSattribute($attr_name,$attr_config))
|
||||
return;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Charge les données de l'objet
|
||||
*
|
||||
* Cette methode définis le DN de l'objet et charge les valeurs de attributs de l'objet
|
||||
* à 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é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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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éfini dans la configuration de l'objet ou spécifié en paramè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
|
||||
*/
|
||||
function getDisplayValue($spe) {
|
||||
if ($spe=='') {
|
||||
$spe = $this -> getDisplayAttributes();
|
||||
}
|
||||
return $this -> getFData($spe,&$this -> attrs,'getDisplayValue');
|
||||
}
|
||||
|
||||
/**
|
||||
* Chaine formatée
|
||||
*
|
||||
* Cette fonction retourne la valeur d'une chaine formaté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ée
|
||||
*/
|
||||
function getFData($format) {
|
||||
$format=getFData($format,$this,'getValue');
|
||||
return $format;
|
||||
}
|
||||
|
||||
/**
|
||||
* DEBUG : Affiche le nom et la valeur de chaque attribut
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
function debug_printAttrsValues() {
|
||||
foreach($this -> attrs as $attr_name => $attr) {
|
||||
print $attr_name.' : ';
|
||||
$attr -> debug_printValue();
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construit un formulaire de l'objet
|
||||
*
|
||||
* Cette méthode construit un formulaire LSform à partir de la configuration de l'objet
|
||||
* et de chaque attribut.
|
||||
*
|
||||
* @param[in] $idForm [<b>required</b>] Identifiant du formulaire a créer
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval LSform Le formulaire crée
|
||||
*/
|
||||
function getForm($idForm,$config=array()) {
|
||||
$LSform = new LSform($idForm);
|
||||
$this -> forms[$idForm] = array($LSform,$config);
|
||||
foreach($this -> attrs as $attr_name => $attr) {
|
||||
if(!$this -> attrs[$attr_name] -> addToForm($LSform -> quickform,$idForm)) {
|
||||
$LSform -> can_validate = false;
|
||||
}
|
||||
}
|
||||
return $LSform;
|
||||
}
|
||||
|
||||
/**
|
||||
* Met à jour les données de l'objet et de l'entré de l'annuaire
|
||||
*
|
||||
* Met à jour les données de l'objet à 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 à jour a ré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();
|
||||
}
|
||||
}
|
||||
$new_data = $LSform -> quickform -> exportValues();
|
||||
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)) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
$this -> submitChange($idForm);
|
||||
if(isset($this -> config['after_save'])) {
|
||||
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ées retourné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ées sont valides, false sinon
|
||||
*/
|
||||
function validateAttrsData($idForm) {
|
||||
$LSform=$this -> forms[$idForm][0];
|
||||
foreach($this -> attrs as $attr) {
|
||||
if(($attr -> isUpdate())&&(!$attr -> isValidate())) {
|
||||
//~ echo 'NAME : '.$attr -> name.' Val : '.$attr -> getUpdateData();
|
||||
$vconfig=$attr -> getValidateConfig();
|
||||
if(is_array($vconfig)) {
|
||||
foreach($vconfig as $test) {
|
||||
$data=$attr -> getUpdateData();
|
||||
if(!is_array($data))
|
||||
$data=array($data);
|
||||
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;
|
||||
//~ echo $sfilter_user;
|
||||
if(isset($test['object_type'])) {
|
||||
$test_obj = new $test['object_type']('auto');
|
||||
$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);
|
||||
//~ echo 'Basedn : "'.$sbasedn.'" Filter : "'.$sfilter.'" NAME : '.$attr -> name.' Nb : '.$ret."<br />\n";
|
||||
if($test['result']==0) {
|
||||
if($ret!=0) {
|
||||
$LSform -> setElementError($attr,$test['msg']);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$attr -> validate();
|
||||
}
|
||||
}
|
||||
unset($this -> other_values['val']);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Met à jour les données modifié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 à jour a réussi, false sinon
|
||||
*/
|
||||
function submitChange($idForm) {
|
||||
$submit_data=array();
|
||||
foreach($this -> attrs as $attr) {
|
||||
if(($attr -> isUpdate())&&($attr -> isValidate())) {
|
||||
$submit_data[$attr -> name] = $attr -> getUpdateData();
|
||||
}
|
||||
}
|
||||
print_r($submit_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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ètre
|
||||
* - [1] : les paramè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é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è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érifie la compatibilite des DN
|
||||
*
|
||||
* Vérifie que les DNs sont dans la même branche de l'annuaire.
|
||||
*
|
||||
* @param[in] $dn Un premier DN.
|
||||
* @param[in] $dn Un deuxiè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ême type.
|
||||
*
|
||||
* Effectue une recherche en fonction des paramètres passé 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è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è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ères de recherche correspondant au type d'objet à lister
|
||||
if(($nbFilter==1)||(!isset($filter[$i]['attr']))) {
|
||||
// Filtre sur l'objet souhaité
|
||||
$sfilter='(&';
|
||||
$sfilter.=$this -> getObjectFilter();
|
||||
$sfilter_end=')';
|
||||
$check_final_dn=true;
|
||||
}
|
||||
// Initialisation des critères d'une recherche intermé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édiaire ou finale
|
||||
if($attrs!=false) {
|
||||
// Initialisation des variables
|
||||
$ret_gen=array();
|
||||
$new_attrs=array();
|
||||
|
||||
// Pour tout les attributs retournés
|
||||
for($ii=0;$ii<count($attrs);$ii++) {
|
||||
$sfilter_for='';
|
||||
// Définition du filtre de recherche à partir des paramètres utilisateurs et
|
||||
// des paramètres de recherche de l'objet à listé (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é du basedn de la recherche et du basedn générale
|
||||
//~ if ($this -> isCompatibleDNs($filter[$i]['basedn'],$basedn)) {
|
||||
//~ $sbasedn=$this -> sumDn($filter[$i]['basedn'],$basedn);
|
||||
//~ }
|
||||
// Finalisation du filtre
|
||||
$sfilter_for.=$sfilter_end;
|
||||
|
||||
//~ print 'filter1 : '.$sfilter_for." | basedn : ".$sbasedn."\n";
|
||||
|
||||
// Execution de la recherche
|
||||
$ret=$GLOBALS['LSldap'] -> search ($sfilter_for,$sbasedn,$sparams);
|
||||
|
||||
//~ print('Nb resultat : '.count($ret));
|
||||
|
||||
// Si il y un retour
|
||||
if(isset($ret[0])) {
|
||||
//~ print_r($ret);
|
||||
// si il ya une suite (recherche intermé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é de la compatibilité 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évu mais d'un retour nul de la précédente recherche
|
||||
else if(empty($new_attrs)) {
|
||||
// retour vide et arrê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;
|
||||
|
||||
//~ print 'filter2 : '.$sfilter."\n";
|
||||
//~ print_r($sparams);
|
||||
|
||||
// Lancement de la recherche
|
||||
$ret=$GLOBALS['LSldap'] -> search ($sfilter,$sbasedn,$sparams);
|
||||
|
||||
//~ print('Nb resultat : '.count($ret));
|
||||
|
||||
//Si filtre multiple => on recupè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ées
|
||||
if(empty($attrs)){
|
||||
// arrêt et retour à zéro
|
||||
$ret=array();
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Si recherche unique
|
||||
else {
|
||||
// préparation du retour finale
|
||||
$ret_final=array();
|
||||
foreach($ret as $obj)
|
||||
$ret_final[]=$obj['dn'];
|
||||
$ret=$ret_final;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//~ print_r($attrs);
|
||||
}
|
||||
|
||||
// Création d'un tableau d'objet correspondant au valeur retourné
|
||||
for($i=0;$i<count($ret);$i++) {
|
||||
$retInfos[$i] = new $this -> type_name($this -> config);
|
||||
$retInfos[$i] -> loadData($ret[$i]);
|
||||
//~ echo $ret[$i]['dn']."\n";
|
||||
}
|
||||
|
||||
return $retInfos;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne une valeur de l'objet
|
||||
*
|
||||
* Retourne une valeur en fonction du paramètre. Si la valeur est inconnue, la valeur retourné 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>
|
||||
*
|
||||
* @param[in] $val string nom de la valeur demandée
|
||||
*
|
||||
* @retval mixed la valeur demandé ou ' ' si celle-ci est inconnue.
|
||||
*/
|
||||
function getValue($val) {
|
||||
if(($val=='dn')||($val=='%{dn}')) {
|
||||
return $this -> dn;
|
||||
}
|
||||
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 ' ';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
88
trunk/includes/functions.php
Normal file
88
trunk/includes/functions.php
Normal file
|
@ -0,0 +1,88 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Construction d'une chaine formatée
|
||||
*
|
||||
* Cette fonction retourne la valeur d'une chaine formatée selon le format
|
||||
* et les données passés en paramètre.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $format string Format de la chaine
|
||||
* @param[in] $data mixed Les données pour composés la chaine
|
||||
* Ce paramètre peut être un tableau de string, une string,
|
||||
* une tableau d'objet ou un objet.
|
||||
* @param[in] $meth string Le nom de la methode de/des objet(s) à appeler pour
|
||||
* obtenir la valeur de remplacement dans la chaine formatée.
|
||||
*
|
||||
* @retval string La chaine formatée
|
||||
*/
|
||||
function getFData($format,$data,$meth=NULL) {
|
||||
if(is_array($data)) {
|
||||
if ($meth==NULL) {
|
||||
while (ereg("%{([A-Za-z0-9]+)}",$format,$ch)) {
|
||||
$format=ereg_replace($ch[0],$data[$ch[1]],$format);
|
||||
}
|
||||
}
|
||||
else {
|
||||
while (ereg("%{([A-Za-z0-9]+)}",$format,$ch)) {
|
||||
if (method_exists($data[$ch[1]],$meth)) {
|
||||
$format=ereg_replace($ch[0],$data[$ch[1]] -> $meth(),$format);
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(901,array('meth' => $meth,'obj' => $ch[1]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($meth==NULL) {
|
||||
while (ereg("%{([A-Za-z0-9]+)}",$format,$ch))
|
||||
$format=ereg_replace($ch[0],$data,$format);
|
||||
}
|
||||
else {
|
||||
while (ereg("%{([A-Za-z0-9]+)}",$format,$ch)) {
|
||||
if (method_exists($data,$meth)) {
|
||||
$format=ereg_replace($ch[0],$data -> $meth($ch[1]),$format);
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(901,array('meth' => $meth,'obj' => get_class($data)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $format;
|
||||
}
|
||||
|
||||
function valid($obj) {
|
||||
echo 'ok';
|
||||
return true;
|
||||
}
|
||||
|
||||
function return_data($data) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
?>
|
80
trunk/index.php
Normal file
80
trunk/index.php
Normal file
|
@ -0,0 +1,80 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
$conf_dir='conf/';
|
||||
require_once $conf_dir.'config.php';
|
||||
require_once $conf_dir.'error_code.php';
|
||||
require_once $conf_dir.'config.LSeepeople.php';
|
||||
require_once $conf_dir.'config.LSeegroup.php';
|
||||
require_once $GLOBALS['LSconfig']['NetLDAP'];
|
||||
require_once $GLOBALS['LSconfig']['QuickForm'];
|
||||
|
||||
$include_dir='includes/';
|
||||
require_once $include_dir.'functions.php';
|
||||
$class_dir=$include_dir.'class/';
|
||||
require_once $class_dir.'class.LSerror.php';
|
||||
require_once $class_dir.'class.LSldap.php';
|
||||
require_once $class_dir.'class.LSldapObject.php';
|
||||
require_once $class_dir.'class.LSattribute.php';
|
||||
require_once $class_dir.'class.LSattr_ldap.php';
|
||||
require_once $class_dir.'class.LSattr_ldap_ascii.php';
|
||||
require_once $class_dir.'class.LSattr_ldap_numeric.php';
|
||||
require_once $class_dir.'class.LSattr_html.php';
|
||||
require_once $class_dir.'class.LSattr_html_text.php';
|
||||
require_once $class_dir.'class.LSattr_html_select_list.php';
|
||||
|
||||
require_once $class_dir.'class.LSeepeople.php';
|
||||
require_once $class_dir.'class.LSeegroup.php';
|
||||
|
||||
require_once $class_dir.'class.LSform.php';
|
||||
echo "<pre>";
|
||||
|
||||
// "Activation" de la gestion des erreurs
|
||||
$LSerror = new LSerror();
|
||||
|
||||
// Connexion à l'annuaire
|
||||
$LSldap = new LSldap($GLOBALS['LSconfig']['ldap_config']);
|
||||
|
||||
// ---- les objets LDAP
|
||||
// Création d'un LSeepeople
|
||||
$eepeople = new LSeepeople($GLOBALS['LSobjects']['LSeepeople']);
|
||||
$eegroup = new LSeegroup($GLOBALS['LSobjects']['LSeegroup']);
|
||||
// Chargement des données de l'objet depuis l'annuaire et à partir de son DN
|
||||
$eepeople-> loadData('uid=eeggs,ou=people,o=ost');
|
||||
$eegroup-> loadData('cn=adminldap,ou=groups,o=ost');
|
||||
|
||||
// Création d'un formulaire à partir pour notre objet LDAP
|
||||
$form=$eepeople -> getForm('test');
|
||||
|
||||
// Gestion de sa validation
|
||||
if ($form->validate()) {
|
||||
// MàJ des données de l'objet LDAP
|
||||
$eepeople -> updateData('test');
|
||||
}
|
||||
// Affichage du formulaire
|
||||
$form -> display();
|
||||
|
||||
|
||||
// Affichage des retours d'erreurs
|
||||
$LSerror -> display();
|
||||
echo "</pre>";
|
||||
?>
|
71
trunk/test_group.php
Normal file
71
trunk/test_group.php
Normal file
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
// filtre unique
|
||||
$filter['unique']=array(
|
||||
array(
|
||||
'filter' => 'uid=a*',
|
||||
'object_type' => 'LSeepeople',
|
||||
)
|
||||
);
|
||||
|
||||
// UniqueMember group
|
||||
$filter['uniqueMember']=array(
|
||||
array(
|
||||
'filter' => 'cn=admin*',
|
||||
'object_type' => 'LSeegroup',
|
||||
'attr' => 'uniqueMember',
|
||||
'basedn' => 'o=ost'
|
||||
),
|
||||
array(
|
||||
'basedn' => '%{dn}'
|
||||
)
|
||||
);
|
||||
|
||||
// memberUid
|
||||
$filter['memberUid']=array(
|
||||
array(
|
||||
'filter' => 'objectClass=posixGroup',
|
||||
'attr' => 'memberUid',
|
||||
'basedn' => 'o=ost'
|
||||
),
|
||||
array(
|
||||
'filter' => 'uid=%{dn}',
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
- On liste les memberUid
|
||||
- on forme avec des DN et on recupère leur Groupe Principale
|
||||
- on recupère tout les membres de ces groupes
|
||||
- on ne garde que les ostpeople
|
||||
*/
|
||||
$filter['complexe']=array(
|
||||
array(
|
||||
'filter' => 'objectClass=posixGroup',
|
||||
'attr' => 'memberUid',
|
||||
'basedn' => 'o=ost'
|
||||
),
|
||||
array(
|
||||
'filter' => 'uid=%{dn}',
|
||||
'basedn' => 'uid=%{dn},ou=people,o=ost',
|
||||
'attr' => 'gidNumber',
|
||||
),
|
||||
array(
|
||||
'filter' => 'gidNumber=%{dn}',
|
||||
'object_type' => 'LSeegroup',
|
||||
'attr' => 'uniqueMember'
|
||||
),
|
||||
array(
|
||||
'basedn' => "%{dn}",
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
|
||||
foreach($eepeople -> listObjects($filter['complexe'],'o=ost') as $obj){
|
||||
echo "DN : ".$obj -> dn."\n<br />";
|
||||
$obj -> debug_printAttrsValues();
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in a new issue