- Ecriture du LSsession

- Mise en place des templates Smarty
- Adaptation du code au templates Smarty
- index_ajax.php -> Code php des réponses Ajax de l'interface
- includes/js -> Partie JavaScript (Mootools) de l'interface
This commit is contained in:
Benjamin Renard 2008-02-05 16:11:21 +00:00
parent 337be06f1f
commit c943289169
53 changed files with 10013 additions and 238 deletions

View file

@ -0,0 +1,62 @@
<?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']['LSeecompany'] = array (
'objectclass' => array(
'lscompany',
),
'rdn' => 'o',
'container_dn' => 'ou=companies',
'select_display_attrs' => '%{dc}',
'attrs' => array (
'o' => array (
'label' => _('Nom'),
'ldap_type' => 'ascii',
'html_type' => 'text',
'required' => 1,
'check_data' => array (
'alphanumeric'
),
'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
)
),
'dc' => array (
'label' => _('Domaine'),
'ldap_type' => 'ascii',
'html_type' => 'text',
'required' => 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
)
)
)
);
?>

View file

@ -0,0 +1,105 @@
<?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(
'lsgroup',
'posixGroup'
),
'rdn' => 'cn',
'container_dn' => 'ou=groups',
'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 (
'filter' => 'cn=%{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
)
),
'gidNumber' => array (
'label' => _('Identifiant'),
'ldap_type' => 'numeric',
'html_type' => 'text',
'required' => 1,
'validation' => array (
array (
'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
)
)
)
)
);
?>

View file

@ -0,0 +1,409 @@
<?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(
'top',
'lspeople',
'posixAccount',
'sambaSamAccount',
),
'rdn' => 'uid',
'container_dn' => 'ou=people',
'before_save' => 'valid',
'after_save' => 'valid',
'select_display_attrs' => '%{cn}',
// Attributes
'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 (
'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,
'generate_function' => 'generate_uidNumber',
'check_data' => array (
'numeric' => array(
'msg' => _("L'identifiant unique doit être un entier.")
),
),
'validation' => array (
array (
'filter' => 'uidNumber=%{val}',
'result' => 0,
'msg' => _('Cet uid 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,
)
),
'cn' => array (
'label' => _('Nom complet'),
'ldap_type' => 'ascii',
'html_type' => 'text',
'required' => 1,
'default_value' => 'titi',
'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.')
),
),
'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,
'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',
'multiple' => true,
'required' => 1,
'validation' => array (
array (
'object_type' => 'LSeegroup', // 'object_type' : Permet definir le type d'objet recherchés
//'basedn' => 'o=company', // 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(
'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=company',
'scope' => 'sub',
)
)
)
)
),
'loginShell' => array (
'label' => _('Interpreteur de commande'),
'ldap_type' => 'ascii',
'html_type' => 'select_list',
'required' => 1,
'default_value' => '/bin/false',
'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(
'/bin/false' => _('Aucun'),
'/bin/bash' => 'Bash',
)
),
'sambaSID' => array (
'label' => _('Identifiant Samba'),
'ldap_type' => 'ascii',
'html_type' => 'text',
'required' => 1,
'generate_function' => 'generate_sambaSID',
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
'self' => 'r', // 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,
)
),
'homeDirectory' => array (
'label' => _('Répertoire personnel'),
'ldap_type' => 'ascii',
'html_type' => 'text',
'required' => 1,
'default_value' => '/home/%{uid}',
'generate_function' => 'generate_homeDirectory',
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
'self' => 'r', // 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,
)
),
'mail' => array (
'label' => _('Adresse e-mail'),
'ldap_type' => 'ascii',
'html_type' => 'text',
'required' => 1,
'check_data' => array (
'email' => array(
'msg' => _("L'adresse e-mail entrée n'est pas valide.")
),
),
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
'self' => 'r', // 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
)
),
'personalTitle' => array (
'label' => _('Titre'),
'ldap_type' => 'ascii',
'html_type' => 'select_list',
'required' => 1,
'default_value' => 'M.',
'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(
'M.' => 'M.',
'Mme' => 'Mme',
'Mlle' => 'Mlle'
)
),
'maildrop' => array (
'label' => _('Mail indésirable'),
'ldap_type' => 'ascii',
'html_type' => 'text',
'multiple' => true,
'check_data' => array (
'email' => array(
'msg' => _("L'adresse e-mail entrée n'est pas valide.")
),
),
'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,
)
),
'vacationActive' => array (
'label' => _('Réponse automatique'),
'ldap_type' => 'ascii',
'html_type' => 'select_list',
'default_value' => '',
'check_data' => array (
'email' => array(
'msg' => _("L'adresse e-mail entrée n'est pas valide.")
),
),
'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(
'%{uid}@autoreponse.example.fr' => 'Oui',
'' => 'Non'
)
),
'vacationInfo' => array (
'label' => _('Message en reponse'),
'ldap_type' => 'ascii',
'html_type' => 'textarea',
'multiple' => true,
'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,
)
),
'vacationForward' => array (
'label' => _('Transfert de mail'),
'ldap_type' => 'ascii',
'html_type' => 'text',
'check_data' => array (
'email' => array(
'msg' => _("L'adresse e-mail entrée n'est pas valide.")
),
),
'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,
)
),
'mailQuota' => array (
'label' => _('Quota boite mail'),
'ldap_type' => 'ascii',
'html_type' => 'text',
'check_data' => array (
'numeric' => array(
'msg' => _("Le quota de l'adresse mail entrée n'est pas valide.")
),
),
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
'self' => 'r', // 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,
)
),
'description' => array (
'label' => _('Description'),
'ldap_type' => 'ascii',
'html_type' => 'text',
'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,
)
),
'userPassword' => array (
'label' => _('Mot de passe'),
'ldap_type' => 'password',
'html_type' => 'password',
'required' => 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
),
'dependAttrs' => array(
'sambaLMPassword',
'sambaNTPassword'
),
'form' => array (
'test' => 1,
'add' => 1
)
),
'sambaLMPassword' => array (
'label' => _('Mot de passe Samba (LM)'),
'ldap_type' => 'ascii',
'html_type' => 'password',
'required' => 1,
'generate_function' => 'generate_sambaLMPassword',
'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' => '' // définition des droits de tout les utilisateurs
)
),
'sambaNTPassword' => array (
'label' => _('Mot de passe Samba (NT)'),
'ldap_type' => 'ascii',
'html_type' => 'password',
'required' => 1,
'generate_function' => 'generate_sambaNTPassword',
'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' => '' // définition des droits de tout les utilisateurs
)
)
)
);
?>

View file

@ -0,0 +1,27 @@
<?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['LSaddons']['loads'] = array (
'samba', 'posix'
);
?>

View file

@ -0,0 +1,29 @@
<?php
/*******************************************************************************
* Copyright (C) 2007 Easter-eggs
* http://ldapsaisie.labs.libre-entreprise.org
*
* Author: See AUTHORS file in top-level directory.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
define('LS_OBJECTS_DIR', LS_CONF_DIR . 'LSobjects/');
$GLOBALS['LSobjects']['loads'] = array (
'LSeepeople', 'LSeegroup'
);
?>

View file

@ -0,0 +1,239 @@
<?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['LSerror_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'
),
3 => array (
'msg' => _("LSldap : Type d'objet inconnu."),
'level' => 'c'
),
4 => array (
'msg' => _("LSldap : Erreur durant la récupération de l'entrée Ldap."),
'level' => 'c'
),
5 => array (
'msg' => _("LSldap : Erreur durant la mise à jour de l'entrée Ldap (DN : %{dn})."),
'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'
),
31 => array (
'msg' => _("LSldapObject : Il manque des informations de configuration du type d'objet %{obj} pour la création du nouveau DN."),
'level' => 'c'
),
32 => array (
'msg' => _("LSldapObject : L'attribut %{attr} de l'objet n'est pas encore définis. Il est impossible de generer un nouveau DN."),
'level' => 'c'
),
33 => array (
'msg' => _("LSldapObject : Sans DN, l'objet n'a put être modifié."),
'level' => 'c'
),
34 => array (
'msg' => _("LSldapObject : L'attribut %{attr_depend} dépendant de l'attribut %{attr} n'existe pas."),
'level' => 'w'
),
// LSldapObject
41 => array (
'msg' => _("LSattribute : Attribut %{attr} : 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'
),
46 => array (
'msg' => _("LSattribute : La valeur de l'attribut %{attr} ne peut pas être générée."),
'level' => 'c'
),
47 => array (
'msg' => _("LSattribute : La valeur de l'attribut %{attr} n'a pas put être générée."),
'level' => 'c'
),
48 => array (
'msg' => _("LSattribute : La génération de l'attribut %{attr} n'a pas retourné une valeur correcte."),
'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'
),
103 => array (
'msg' => _("LSattr_html_%{type} : Les données multiples ne sont pas gérés pour ce type d'attribut."),
'level' => 'c'
),
// LSform
201 => array(
'msg' => _("LSform : Erreur durant la recupération des valeurs du formulaire."),
'level' => 'c'
),
202 => array(
'msg' => _("LSform : Erreur durant la récupération de la valeur du formulaire du champ '%{element}'."),
'level' => 'c'
),
203 => array(
'msg' => _("LSform : Les données du champ %{element} ne sont pas valides."),
'level' => 'c'
),
204 => array(
'msg' => _("LSform : Le champ %{element} n'existe pas."),
'level' => 'c'
),
205 => array(
'msg' => _("LSfom : Type de champ inconnu (%{type})."),
'level' => 'c'
),
206 => array(
'msg' => _("LSform : Erreur durant la création de l'élement '%{element}'."),
'level' => 'c'
),
207 => array(
'msg' => _("LSform : Aucune valeur de rentrée pour le champs '%{element}'."),
'level' => 'c'
),
301 => array(
'msg' => _("LSformRule : Aucune regex n'a été fournis pour la validation des données."),
'level' => 'w'
),
// functions
901 => array (
'msg' => _("Functions 'getFData' : La methode %{meth} de l'objet %{obj} n'existe pas."),
'level' => 'c'
),
// LSsession
1001 => array (
'msg' => _("LSsession : La constante %{const} n'est pas définie."),
'level' => 'c'
),
1002 => array (
'msg' => _("LSsession : Le support %{addon} n'est pas assuré. Vérifier la compatibilité du système et la configuration de l'addon"),
'level' => 'c'
),
1003 => array (
'msg' => _("LSsession : Données de configuration du serveur LDAP invalide. Impossible d'établir une connexion."),
'level' => 'c'
),
1004 => array (
'msg' => _("LSsession : Impossible de charger l'objets de type %{type} : type inconnu."),
'level' => 'c'
),
1005 => array (
'msg' => _("LSsession : Impossible d'effecture l'authentification : Type d'objet d'authentification inconnu (%{type})."),
'level' => 'c'
),
1006 => array (
'msg' => _("LSsession : Identifiant ou mot de passe incorrect."),
'level' => 'c'
),
1007 => array (
'msg' => _("LSsession : Impossible de vous identifier : Duplication d'authentité."),
'level' => 'c'
),
1008 => array (
'msg' => _("LSsession : Impossible d'inclure le moteur de rendu Smarty."),
'level' => 'c'
),
1009 => array (
'msg' => _("LSsession : Impossible de se connecter au Serveur LDAP."),
'level' => 'c'
),
1010 => array (
'msg' => _("LSsession : Impossible de charger la classe des objets d'authentification."),
'level' => 'c'
)
);
?>

91
trunk/conf/config.inc.php Normal file
View file

@ -0,0 +1,91 @@
<?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',
'Smarty' => '/var/www/tmp/Smarty-2.6.18/libs/Smarty.class.php',
'lang' => 'fr_FR.UTF8',
'ldap_servers' => array (
array (
'name' => 'Ldap 1',
'ldap_config'=> array(
'host' => '127.0.0.1',
'port' => 389,
'version' => 3,
'starttls' => false,
'binddn' => 'uid=toto,ou=people,o=ls',
'bindpw' => 'toto',
'basedn' => 'o=ls',
'options' => array(),
'filter' => '(objectClass=*)',
'scope' => 'sub'
),
'authobject' => 'LSeepeople',
'authobject_pwdattr' => 'userPassword'
),
array (
'name' => 'Ldap 2',
'ldap_config'=> array(
'host' => '127.0.0.1',
'port' => 389,
'version' => 3,
'starttls' => false,
'binddn' => 'uid=toto,ou=people,o=com',
'bindpw' => 'toto',
'basedn' => 'o=com',
'options' => array(),
'filter' => '(objectClass=*)',
'scope' => 'sub'
),
'subdnobject' => 'LSeecompany',
'authobject' => 'LSeepeople',
'authobject_pwdattr' => 'userPassword'
)
)
);
//Debug
$GLOBALS['LSdebug']['active'] = true;
// Définitions des locales
$textdomain = 'ldapsaisie';
bindtextdomain($textdomain, '/var/www/ldapsaisie/trunk/l10n');
textdomain($textdomain);
setlocale(LC_ALL, $GLOBALS['LSconfig']['lang']);
// Définitions des dossiers d'inclusions
define('LS_CONF_DIR','conf/');
define('LS_INCLUDE_DIR','includes/');
define('LS_CLASS_DIR', LS_INCLUDE_DIR .'class/');
define('LS_LIB_DIR', LS_INCLUDE_DIR .'libs/');
define('LS_ADDONS_DIR', LS_INCLUDE_DIR .'addons/');
define('LS_JS_DIR', LS_INCLUDE_DIR .'js/');
// Javascript
$GLOBALS['defaultJSscipts']=array(
'mootools.js',
'LSdefault.js',
'Debugger.js'
);
?>

View file

@ -43,7 +43,7 @@ class LSattr_html_password extends LSattr_html {
return;
}
if (is_array($data)) {
if (count($data)>1) {
$GLOBALS['LSerror'] -> addErrorCode(103,'password');
return;
}

View file

@ -37,7 +37,7 @@ class LSattr_html_select_list extends LSattr_html{
* @retval LSformElement L'element du formulaire ajouté
*/
function addToForm (&$form,$idForm,$data=NULL) {
if (is_array($data)) {
if (count($data)>1) {
$GLOBALS['LSerror'] -> addErrorCode(103,'select_list');
return;
}
@ -80,7 +80,6 @@ class LSattr_html_select_list extends LSattr_html{
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;

View file

@ -43,7 +43,7 @@ class LSattr_html_textarea extends LSattr_html {
return;
}
if (is_array($data)) {
if (count($data)>1) {
$GLOBALS['LSerror'] -> addErrorCode(103,'textarea');
return;
}

View file

@ -20,6 +20,9 @@
******************************************************************************/
$GLOBALS['LSsession'] -> loadLSclass('LSattr_ldap');
$GLOBALS['LSsession'] -> loadLSclass('LSattr_html');
/**
* Attribut Ldap
*
@ -58,9 +61,10 @@ class LSattribute {
$this -> name = $name;
$this -> config = $config;
$this -> ldapObject = $ldapObject;
$html_type = "LSattr_html_".$config['html_type'];
$ldap_type = "LSattr_ldap_".$config['ldap_type'];
$GLOBALS['LSsession'] -> loadLSclass($html_type);
$GLOBALS['LSsession'] -> loadLSclass($ldap_type);
if((class_exists($html_type))&&(class_exists($ldap_type))) {
$this -> html = new $html_type($name,$config,$this);
$this -> ldap = new $ldap_type($name,$config,$this);
@ -238,14 +242,8 @@ class LSattribute {
*/
function refreshForm(&$form,$idForm) {
if(isset($this -> config['form'][$idForm])) {
//~ echo 'Attr : '.$this -> name.'| Val : '.$this -> data."<br />\n";
$form_element = &$form -> getElement($this -> name);
if(!empty($this -> data)) {
return $form_element -> setValue($this -> getFormVal());
}
else if (isset($this -> config['default_value'])) {
return $form_element -> setValue($this -> config['default_value']);
}
return $form_element -> setValue($this -> getFormVal());
}
return true;
}
@ -258,7 +256,10 @@ class LSattribute {
* @retval string La valeur a afficher dans le formulaire.
*/
function getFormVal() {
return $this -> getDisplayValue();
$data=$this -> getDisplayValue();
if(!is_array($data))
$data=array($data);
return $data;
}
/**
@ -271,8 +272,10 @@ class LSattribute {
* @retval void
*/
function setUpdateData($data) {
if($this -> getFormVal() != $data)
if($this -> getFormVal() != $data) {
$this -> updateData=$data;
debug($this -> name.' is updated (o = '.$this -> getFormVal().' | n = '.$data.')');
}
}
/**

View file

@ -78,13 +78,34 @@ class LSerror {
* @retval void
*/
function display() {
if(!empty($this -> errors)) {
$errors = $this -> getErrors();
if ($errors) {
$GLOBALS['Smarty'] -> assign('LSerrors',$errors);
}
/*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";
echo "(Code ".$error[0].") ".getFData($GLOBALS['LSerror_code'][$error[0]]['msg'],$error[1])."<br />\n";
}
}
}*/
}
/**
* Retourne le texte des erreurs
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @retvat string Le texte des erreurs
*/
function getErrors() {
if(!empty($this -> errors)) {
foreach ($this -> errors as $error) {
$txt.="(Code ".$error[0].") ".getFData($GLOBALS['LSerror_code'][$error[0]]['msg'],$error[1])."<br />\n";
}
return $txt;
}
return;
}
}
?>

View file

@ -59,6 +59,7 @@ class LSform {
$this -> idForm = $idForm;
$this -> submit = $submit;
$this -> ldapObject = $ldapObject;
$GLOBALS['LSsession'] -> loadLSclass('LSformElement');
}
/**
@ -69,26 +70,24 @@ class LSform {
* @retval void
*/
function display(){
echo "<form method='post' action='".$_SERVER['PHP_SELF']."'>\n";
echo "\t<input type='hidden' name='validate' value='LSform'/>\n";
echo "\t<input type='hidden' name='idForm' value='".$this -> idForm."'/>\n";
echo "<table>\n";
$GLOBALS['LSsession'] -> addJSscript('LSform.js');
$GLOBALS['LSsession'] -> addCssFile('LSform.css');
$GLOBALS['Smarty'] -> assign('LSform_action',$_SERVER['PHP_SELF']);
$LSform_header = "\t<input type='hidden' name='validate' value='LSform'/>\n\t<input type='hidden' name='idForm' id='LSform_idform' value='".$this -> idForm."'/>\n\t<input type='hidden' name='LSform_objecttype' id='LSform_objecttype' value='".$this -> ldapObject -> getType()."'/>\n";
$GLOBALS['Smarty'] -> assign('LSform_header',$LSform_header);
$fields = array();
foreach($this -> elements as $element) {
$element -> display();
$field = array();
$field = $element -> getDisplay();
if (isset($this -> _elementsErrors[$element -> name])) {
foreach ($this -> _elementsErrors[$element -> name] as $error) {
echo "<tr><td></td><td>$error</td></tr>";
}
$field['errors']= $this -> _elementsErrors[$element -> name];
}
$fields[] = $field;
}
$GLOBALS['Smarty'] -> assign('LSform_fields',$fields);
if($this -> can_validate) {
echo "\t<tr>\n";
echo "\t\t<td>&nbsp;</td>\n";
echo "\t\t<td><input type='submit' value=\"".$this -> submit."\"/></td>\n";
echo "\t</tr>\n";
$GLOBALS['Smarty'] -> assign('LSform_submittxt',$this -> submit);
}
echo "</table>\n";
echo "</form>\n";
}
/**
@ -166,8 +165,11 @@ class LSform {
}
if (!is_array($this -> _rules[$element]))
continue;
$GLOBALS['LSsession'] -> loadLSclass('LSformRule');
foreach($this -> _rules[$element] as $rule) {
if (! call_user_func(array( "LSformRule_".$rule['name'],'validate') , $value, $rule['options'])) {
$ruleType="LSformRule_".$rule['name'];
$GLOBALS['LSsession'] -> loadLSclass($ruleType);
if (! call_user_func(array( $ruleType,'validate') , $value, $rule['options'])) {
$retval=false;
$this -> setElementError($this -> elements[$element],$rule['options']['msg']);
}
@ -238,6 +240,7 @@ class LSform {
*/
function addElement($type,$name,$label,$params=array()) {
$elementType='LSformElement_'.$type;
$GLOBALS['LSsession'] -> loadLSclass($elementType);
if (!class_exists($elementType)) {
$GLOBALS['LSerror'] -> addErrorCode(205,array('type' => $type));
return;
@ -313,6 +316,8 @@ class LSform {
* @param[in] $element string Le nom de l'élément conserné
*/
function isRuleRegistered($rule) {
$GLOBALS['LSsession'] -> loadLSclass('LSformRule');
$GLOBALS['LSsession'] -> loadLSclass('LSformRule_'.$rule);
return class_exists('LSformRule_'.$rule);
}
@ -356,6 +361,22 @@ class LSform {
return true;
}
/**
* Retourne le code HTML d'un champ vide.
*
* @param[in] string Le nom du champ du formulaire
*
* @retval string Le code HTML du champ vide.
*/
function getEmptyField($element) {
$element = $this -> getElement($element);
if ($element) {
return $element -> getEmptyField();
}
else
return;
}
}
?>

View file

@ -159,6 +159,19 @@ class LSformElement {
echo "\t\t<td>".$this -> getLabel()."$required</td>\n";
}
/**
* Retourne le label de l'élement
*
* @retval void
*/
function getLabelInfos() {
if ($this -> isRequired()) {
$return['required']=true;
}
$return['label'] = $this -> getLabel();
return $return;
}
/**
* Recupère la valeur de l'élement passée en POST
*
@ -178,13 +191,14 @@ class LSformElement {
$_POST[$this -> name] = array($_POST[$this -> name]);
}
foreach($_POST[$this -> name] as $key => $val) {
if (!empty($val)) {
$return[$this -> name][$key] = $val;
}
}
return true;
}
return;
else {
$return[$this -> name] = array();
return true;
}
}
/**
@ -206,6 +220,19 @@ class LSformElement {
}
}
/**
* Retourne l'HTML pour les boutons d'ajout et de suppression de champs du formulaire LSform
*
* @retval string Le code HTML des boutons
*/
function getMultipleData() {
if ($this -> params['multiple'] == true ) {
return "<img src='templates/images/add.png' id='LSform_add_field_btn_".$this -> name."_".rand()."' class='LSform-add-field-btn' alt='"._('Ajouter')."'/><img src='templates/images/remove.png' class='LSform-remove-field-btn' alt='"._('Supprimer')."'/>";
}
else {
return '';
}
}
}
?>

View file

@ -58,52 +58,28 @@ class LSformElement_password extends LSformElement {
}
/*
* Affiche l'élément
* Retourne les infos d'affichage de l'élément
*
* Cette méthode affiche l'élement
* Cette méthode retourne les informations d'affichage de l'élement
*
* @retval void
* @retval array
*/
function display(){
echo "\t<tr>\n";
$this -> displayLabel();
// value
function getDisplay(){
$return = $this -> getLabelInfos();
if (!$this -> isFreeze()) {
echo "\t\t<td>\n";
echo "\t\t\t<ul>\n";
if (empty($this -> values)) {
echo "\t\t\t\t<li><input type='password' name='".$this -> name."[]' \"></li>\n";
}
else {
foreach ($this -> values as $value) {
echo "\t\t\t\t<li><input type='password' name='".$this -> name."[]'/></li>\n";
}
}
echo "\t\t\t</ul>\n";
echo "\t\t\t* "._('Modification uniquement').".";
echo "\t\t</td>\n";
$return['html'] = "<input type='password' name='".$this -> name."[]' />\n* "._('Modification uniquement').".";
}
else {
echo "\t\t<td>\n";
echo "\t\t\t<ul>\n";
if (empty($this -> values)) {
echo "\t\t\t\t<li>"._('Aucunes valeur definie')."</li>\n";
$return['html'] = _('Aucunes valeur definie');
}
else {
foreach ($this -> values as $value) {
echo "\t\t\t\t<li>".$value."</li>\n";
}
$return['html'] = "********";
}
echo "\t\t\t</ul>\n";
echo "\t\t</td>\n";
}
echo "\t</tr>\n";
return $return;
}
}
?>

View file

@ -33,19 +33,24 @@
class LSformElement_select extends LSformElement {
/*
* Affiche l'élément
* Retourn les infos d'affichage de l'élément
*
* Cette méthode affiche l'élement
* Cette méthode retourne les informations d'affichage de l'élement
*
* @retval void
* @retval array
*/
function display(){
echo "\t<tr>\n";
$this -> displayLabel();
function getDisplay(){
$return = $this -> getLabelInfos();
// value
if (!$this -> isFreeze()) {
echo "\t\t<td>\n";
echo "\t\t\t<select name='".$this -> name."' multiple>\n";
if ($this -> params['multiple']==0) {
$multiple_tag='';
}
else {
$multiple_tag='multiple';
}
$return['html'] = "<select name='".$this -> name."' $multiple_tag class='LSform'>\n";
foreach ($this -> params['text_possible_values'] as $choice_value => $choice_text) {
if (in_array($choice_value, $this -> values)) {
$selected=' selected';
@ -53,28 +58,25 @@ class LSformElement_select extends LSformElement {
else {
$selected='';
}
echo "\t\t\t\t<option value=\"".$choice_value."\"$selected>$choice_text</option>\n";
$return['html'].="<option value=\"".$choice_value."\"$selected>$choice_text</option>\n";
}
echo "\t\t\t</select>\n";
echo "\t\t</td>\n";
$return['html'].="</select>\n";
}
else {
echo "\t\t<td>\n";
echo "\t\t\t<ul>\n";
$return['html']="<ul class='LSform'>\n";
foreach ($params['possible_values'] as $choice_value => $choice_text) {
if (in_array($choice_value, $this -> value)) {
echo "<li><strong>$choice_text</strong></li>";
$return['html'].="<li class='LSform'><strong>$choice_text</strong></li>";
}
else {
echo "<li>$choice_text</li>";
$return['html'].="<li class='LSform'>$choice_text</li>";
}
}
echo "\t\t\t</ul>\n";
echo "\t\t</td>\n";
$return['html'].="</ul>\n";
}
echo "\t</tr>\n";
return $return;
}
}
?>

View file

@ -33,49 +33,53 @@
class LSformElement_text extends LSformElement {
/*
* Affiche l'élément
* Retourne les infos d'affichage de l'élément
*
* Cette méthode affiche l'élement
* Cette méthode retourne les informations d'affichage de l'élement
*
* @retval void
* @retval array
*/
function display(){
echo "\t<tr>\n";
$this -> displayLabel();
function getDisplay(){
$return = $this -> getLabelInfos();
// value
if (!$this -> isFreeze()) {
echo "\t\t<td>\n";
echo "\t\t\t<ul>\n";
$return['html'] = "<ul class='LSform'>\n";
if (empty($this -> values)) {
echo "\t\t\t\t<li><input type='text' name='".$this -> name."[]' \"></li>\n";
$return['html'] .= "<li>".$this -> getEmptyField()."</li>\n";
}
else {
$multiple = $this -> getMultipleData();
foreach ($this -> values as $value) {
echo "\t\t\t\t<li><input type='text' name='".$this -> name."[]' value=\"".$value."\"></li>\n";
$id = "LSform_".$this -> name."_".rand();
$return['html'] .= "<li><input type='text' name='".$this -> name."[]' value=\"".$value."\" id='".$id."'>".$multiple."</li>\n";
}
}
echo "\t\t\t</ul>\n";
echo "\t\t</td>\n";
$return['html'] .= "</ul>\n";
}
else {
echo "\t\t<td>\n";
echo "\t\t\t<ul>\n";
$return['html'] = "<ul class='LSform'>\n";
if (empty($this -> values)) {
echo "\t\t\t\t<li>"._('Aucunes valeur definie')."</li>\n";
$return['html'] .= "<li>"._('Aucunes valeur definie')."</li>\n";
}
else {
foreach ($this -> values as $value) {
echo "\t\t\t\t<li>".$value."</li>\n";
$return['html'] .= "<li>".$value."</li>\n";
}
}
echo "\t\t\t</ul>\n";
echo "\t\t</td>\n";
$return['html'] .= "</ul>\n";
}
echo "\t</tr>\n";
return $return;
}
/*
* Retourne le code HTML d'un champ vide
*
* @retval string Code HTML d'un champ vide.
*/
function getEmptyField() {
$multiple = $this -> getMultipleData();
return "<input type='text' name='".$this -> name."[]' id='LSform_".$this -> name."_".rand()."'>".$multiple;
}
}
?>

View file

@ -33,47 +33,54 @@
class LSformElement_textarea extends LSformElement {
/*
* Affiche l'élément
* Retourne les infos d'affichage de l'élément
*
* Cette méthode affiche l'élement
* Cette méthode retourne les informations d'affichage de l'élement
*
* @retval void
* @retval array
*/
function display(){
echo "\t<tr>\n";
$this -> displayLabel();
function getDisplay(){
$return = $this -> getLabelInfos();
// value
if (!$this -> isFreeze()) {
echo "\t\t<td>\n";
$return['html'] = "<ul class='LSform'>\n";
if (empty($this -> values)) {
echo "\t\t\t<textarea name='".$this -> name."[]'></textarea>\n";
$return['html'] = "<li>".$this -> getEmptyField()."</li>\n";
}
else {
$multiple = $this -> getMultipleData();
foreach($this -> values as $value) {
echo "\t\t\t<textarea name='".$this -> name."[]'>".$value."</textarea>\n";
$id = "LSform_".$this -> name."_".rand();
$return['html'].="<li><textarea name='".$this -> name."[]' id='".$id."'>".$value."</textarea>\n".$multiple."</li>";
}
}
echo "\t\t</td>\n";
$return['html'] .= "</ul>\n";
}
else {
echo "\t\t<td>\n";
$return['html'] = "<ul class='LSform'>\n";
if (empty($this -> values)) {
echo "\t\t\t\t<li>"._('Aucunes valeur definie')."</li>\n";
$return['html'].="<li>"._('Aucunes valeur definie')."</li>\n";
}
else {
foreach ($this -> values as $value) {
echo "\t\t\t\t<li>".$value."</li>\n";
$return['html'].="<li>".$value."</li>\n";
}
}
echo "\t\t</td>\n";
$return['html'] .= "</ul>\n";
}
echo "\t</tr>\n";
return $return;
}
/*
* Retourne le code HTML d'un champ vide
*
* @retval string Code HTML d'un champ vide.
*/
function getEmptyField() {
$multiple = $this -> getMultipleData();
return "<textarea name='".$this -> name."[]' id='LSform".$this -> name."_".rand()."'></textarea>\n".$multiple;
}
}
?>

View file

@ -37,6 +37,7 @@ class LSformRule_alphanumeric extends LSformRule {
*/
function validate ($value,$options=array()) {
$regex = '/^[a-zA-Z0-9]+$/';
$GLOBALS['LSsession'] -> loadLSclass('LSformRule_regex');
return LSformRule_regex :: validate($value,$regex);
}

View file

@ -37,6 +37,7 @@ class LSformRule_lettersonly extends LSformRule {
*/
function validate ($value,$options=array()) {
$regex = '/^[a-zA-Z]+$/';
$GLOBALS['LSsession'] -> loadLSclass('LSformRule_regex');
return LSformRule_regex :: validate($value,$regex);
}

View file

@ -37,6 +37,7 @@ class LSformRule_nonzero extends LSformRule {
*/
function validate ($value,$options) {
$regex = '/^-?[1-9][0-9]*/';
$GLOBALS['LSsession'] -> loadLSclass('LSformRule_regex');
return LSformRule_regex :: validate($value,$regex);
}

View file

@ -37,6 +37,7 @@ class LSformRule_nopunctuation extends LSformRule {
*/
function validate ($value,$options=array()) {
$regex = '/^[^().\/\*\^\?#!@$%+=,\"\'><~\[\]{}]+$/';
$GLOBALS['LSsession'] -> loadLSclass('LSformRule_regex');
return LSformRule_regex :: validate($value,$regex);
}

View file

@ -37,6 +37,7 @@ class LSformRule_numeric extends LSformRule{
*/
function validate ($value,$options=array()) {
$regex = '/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/';
$GLOBALS['LSsession'] -> loadLSclass('LSformRule_regex');
return LSformRule_regex :: validate($value,$regex);
}

View file

@ -49,7 +49,6 @@ class LSformRule_regex extends LSformRule {
else {
$regex=$option;
}
debug("\n$value : $regex\n");
if (!preg_match($regex, $value)) {
return false;
}

View file

@ -64,7 +64,6 @@ class LSldap {
$this -> cnx = Net_LDAP::connect($this -> config);
if (Net_LDAP::isError($this -> cnx)) {
$GLOBALS['LSerror'] -> addErrorCode(1,$this -> cnx -> getMessage());
$GLOBALS['LSerror'] -> stop();
$this -> cnx = NULL;
return;
}
@ -219,6 +218,7 @@ class LSldap {
$ret = $entry -> update();
if (Net_Ldap::isError($ret)) {
$GLOBALS['LSerror'] -> addErrorCode(5,$dn);
debug('NetLdap-Error : '.$ret->getMessage());
}
else {
return true;
@ -229,7 +229,37 @@ class LSldap {
return;
}
}
/**
* Test de bind
*
* Cette methode établie une connexion à l'annuaire Ldap et test un bind
* avec un login et un mot de passe passé en paramètre
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @retval boolean true si la connection à réussi, false sinon
*/
function checkBind($dn,$pwd) {
$config = $this -> config;
$config['binddn'] = $dn;
$config['bindpw'] = $pwd;
$cnx = Net_LDAP::connect($config);
if (Net_LDAP::isError($cnx)) {
return;
}
return true;
}
/**
* Retourne l'état de la connexion Ldap
*
* @retval boolean True si le serveur est connecté, false sinon.
*/
function isConnected() {
return ($this -> cnx == NULL)?false:true;
}
}
?>

View file

@ -20,6 +20,7 @@
******************************************************************************/
$GLOBALS['LSsession'] -> loadLSclass('LSattribute');
/**
* Base d'un objet ldap
@ -51,16 +52,17 @@ class LSldapObject {
*
* @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;
}
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,$this)) {
@ -131,7 +133,7 @@ class LSldapObject {
*
* @retval string Valeur descriptive d'affichage de l'objet
*/
function getDisplayValue($spe) {
function getDisplayValue($spe='') {
if ($spe=='') {
$spe = $this -> getDisplayAttributes();
}
@ -169,6 +171,7 @@ class LSldapObject {
* @retval LSform Le formulaire crée
*/
function getForm($idForm,$config=array()) {
$GLOBALS['LSsession'] -> loadLSclass('LSform');
$LSform = new LSform($this,$idForm);
$this -> forms[$idForm] = array($LSform,$config);
foreach($this -> attrs as $attr_name => $attr) {
@ -338,6 +341,11 @@ class LSldapObject {
// Validation des valeurs de l'attribut
if(is_array($vconfig)) {
foreach($vconfig as $test) {
// Définition du basedn par défaut
if (!isset($test['basedn'])) {
$test['basedn']=$GLOBALS['LSsession']->topDn;
}
// Définition du message d'erreur
if (!empty($test['msg'])) {
$msg_error=getFData($test['msg'],$this,'getValue');
@ -352,7 +360,7 @@ class LSldapObject {
$this -> other_values['val']=$val;
$sfilter_user=(isset($test['basedn']))?getFData($test['filter'],$this,'getValue'):NULL;
if(isset($test['object_type'])) {
$test_obj = new $test['object_type']('auto');
$test_obj = new $test['object_type']();
$sfilter=$test_obj->getObjectFilter();
$sfilter='(&'.$sfilter;
if($sfilter_user[0]=='(') {
@ -445,6 +453,7 @@ class LSldapObject {
if(!empty($submitData)) {
$dn=$this -> getDn();
if($dn) {
debug($submitData);
return $GLOBALS['LSldap'] -> update($this -> type_name,$dn, $submitData);
}
else {
@ -777,7 +786,12 @@ class LSldapObject {
return $retInfos;
}
function searchObject($name,$basedn=NULL) {
$filter = $this -> config['rdn'].'='.$name;
return $this -> listObjects($filter,$basedn);
}
/**
* Retourne une valeur de l'objet
*
@ -799,6 +813,9 @@ class LSldapObject {
if(($val=='dn')||($val=='%{dn}')) {
return $this -> dn;
}
else if(($val=='rdn')||($val=='%{rdn}')) {
return $this -> attrs[ $this -> config['rdn'] ] -> getValue();
}
else if(isset($this -> attrs[$val])){
if (method_exists($this -> attrs[$val],'getValue'))
return $this -> attrs[$val] -> getValue();
@ -812,7 +829,40 @@ class LSldapObject {
return ' ';
}
}
/**
* Retourn une liste d'option pour un select d'un objet du même type
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @retval string HTML code
*/
function getSelectOptions() {
$list = $this -> listObjects();
$display='';
foreach($list as $object) {
$display.="<option value=\"".$object -> getDn()."\">".$object -> getDisplayValue()."</option>\n";
}
return $display;
}
/**
* Retourn un tableau pour un select d'un objet du même type
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @retval array['dn','display']
*/
function getSelectArray() {
$list = $this -> listObjects();
$return=array();
foreach($list as $object) {
$return['dn'][] = $object -> getDn();
$return['display'][] = $object -> getDisplayValue();
}
return $return;
}
/**
* Retourne le DN de l'objet
*
@ -829,11 +879,10 @@ class LSldapObject {
}
else {
$rdn_attr=$this -> config['rdn'];
if( (isset($this -> config['rdn'])) && (isset($this -> attrs[$rdn_attr])) && (isset($this -> config['container_dn'])) && (isset($GLOBALS['LSsession']['topDn'])) ) {
debug('RDN : '.$rdn_attr);
if( (isset($this -> config['rdn'])) && (isset($this -> attrs[$rdn_attr])) && (isset($this -> config['container_dn'])) && (isset($GLOBALS['LSsession']->topDn)) ) {
$rdn_val=$this -> attrs[$rdn_attr] -> getUpdateData();
if (!empty($rdn_val)) {
return $rdn_attr.'='.$rdn_val[0].','.$this -> config['container_dn'].','.$GLOBALS['LSsession']['topDn'];
return $rdn_attr.'='.$rdn_val[0].','.$this -> config['container_dn'].','.$GLOBALS['LSsession']->topDn;
}
else {
$GLOBALS['LSerror'] -> addErrorCode(32,$this -> config['rdn']);
@ -846,7 +895,16 @@ class LSldapObject {
}
}
}
/**
* Retourne le type de l'objet
*
* @retval string Le type de l'objet ($this -> type_name)
*/
function getType() {
return $this -> type_name;
}
}
?>

View file

@ -0,0 +1,48 @@
<?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 eecompany
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*/
class LSeecompany 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.
*
* @see LSldapObject::LSldapObject()
*/
function LSeecompany ($config='auto') {
$this -> LSldapObject('LSeecompany',$config);
}
}
?>

View file

@ -0,0 +1,48 @@
<?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.
*
* @see LSldapObject::LSldapObject()
*/
function LSeegroup ($config='auto') {
$this -> LSldapObject('LSeegroup',$config);
}
}
?>

View file

@ -0,0 +1,48 @@
<?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.
*
* @see LSldapObject::LSldapObject()
*/
function LSeepeople ($config='auto') {
return $this -> LSldapObject('LSeepeople',$config);
}
}
?>

View file

@ -0,0 +1,511 @@
<?php
/*******************************************************************************
* Copyright (C) 2007 Easter-eggs
* http://ldapsaisie.labs.libre-entreprise.org
*
* Author: See AUTHORS file in top-level directory.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
define('LS_DEFAULT_CONF_DIR','conf');
/**
* Gestion des sessions
*
* Cette classe gère les sessions d'utilisateurs.
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*/
class LSsession {
var $confDir = NULL;
var $ldapServer = NULL;
var $topDn = NULL;
var $LSuserObject = NULL;
var $dn = NULL;
var $rdn = NULL;
var $JSscripts = array();
var $CssFiles = array();
var $template = NULL;
/**
* Constructeur
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @retval void
*/
function LSsession ($configDir=LS_DEFAULT_CONF_DIR) {
$this -> confDir = $configDir;
if ($this -> loadConfig()) {
$this -> startLSerror();
}
else {
return;
}
}
/*
* Chargement de la configuration
*
* Chargement des fichiers de configuration et création de l'objet Smarty.
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @retval true si tout c'est bien passé, false sinon
*/
function loadConfig() {
if (loadDir($this -> confDir, '^config\..*\.php$')) {
if ( @include_once $GLOBALS['LSconfig']['Smarty'] ) {
$GLOBALS['Smarty'] = new Smarty();
return true;
}
else {
$GLOBALS['LSerror'] -> addErrorCode(1008);
return;
}
return true;
}
else {
return;
}
}
/*
* Initialisation de la gestion des erreurs
*
* Création de l'objet LSerror
*
* @author Benjamin Renard <brenard@easter-eggs.com
*
* @retval boolean true si l'initialisation a réussi, false sinon.
*/
function startLSerror() {
if(!$this -> loadLSclass('LSerror'))
return;
$GLOBALS['LSerror'] = new LSerror();
return true;
}
/*
* Chargement d'une classe d'LdapSaisie
*
* @param[in] $class Nom de la classe à charger (Exemple : LSeepeople)
* @param[in] $type (Optionnel) Type de classe à charger (Exemple : LSobjects)
*
* @author Benjamin Renard <brenard@easter-eggs.com
*
* @retval boolean true si le chargement a réussi, false sinon.
*/
function loadLSclass($class,$type='') {
if (class_exists($class))
return true;
if($type!='')
$type=$type.'.';
return @include_once LS_CLASS_DIR .'class.'.$type.$class.'.php';
}
/*
* Chargement d'un object LdapSaisie
*
* @param[in] $object Nom de l'objet à charger
*
* @retval boolean true si le chargement a réussi, false sinon.
*/
function loadLSobject($object) {
if (!$this -> loadLSclass($object,'LSobjects'))
return;
if (!require_once( LS_OBJECTS_DIR . 'config.LSobjects.'.$object.'.php' ))
return;
return true;
}
/*
* Chargement des objects LdapSaisie
*
* Chargement des LSobjects contenue dans la variable
* $GLOBALS['LSobjects']['loads']
*
* @retval boolean true si le chargement a réussi, false sinon.
*/
function loadLSobjects() {
$this -> loadLSclass('LSldapObject');
if(!is_array($GLOBALS['LSobjects']['loads'])) {
$GLOBALS['LSerror'] -> addErrorCode(1001,"LSobjects['loads']");
return;
}
foreach ($GLOBALS['LSobjects']['loads'] as $object) {
if ( !$this -> loadLSobject($object) )
return;
}
return true;
}
/*
* Chargement d'un addons d'LdapSaisie
*
* @param[in] $addon Nom de l'addon à charger (Exemple : samba)
*
* @author Benjamin Renard <brenard@easter-eggs.com
*
* @retval boolean true si le chargement a réussi, false sinon.
*/
function loadLSaddon($addon) {
return require_once LS_ADDONS_DIR .'LSaddons.'.$addon.'.php';
}
/*
* Chargement des addons LdapSaisie
*
* Chargement des LSaddons contenue dans la variable
* $GLOBALS['LSaddons']['loads']
*
* @retval boolean true si le chargement a réussi, false sinon.
*/
function loadLSaddons() {
if(!is_array($GLOBALS['LSaddons']['loads'])) {
$GLOBALS['LSerror'] -> addErrorCode(1001,"LSaddons['loads']");
return;
}
foreach ($GLOBALS['LSaddons']['loads'] as $addon) {
$this -> loadLSaddon($addon);
if (!call_user_func('LSaddon_'. $addon .'_support')) {
$GLOBALS['LSerror'] -> addErrorCode(1002,$addon);
}
}
return true;
}
/*
* Initialisation de la session LdapSaisie
*
* Initialisation d'une LSsession :
* - Authentification et activation du mécanisme de session de LdapSaisie
* - ou Chargement des paramètres de la session à partir de la variable
* $_SESSION['LSsession'].
* - ou Destruction de la session en cas de $_GET['LSsession_logout'].
*
* @retval boolean True si l'initialisation à réussi (utilisateur authentifié), false sinon.
*/
function startLSsession() {
$this -> loadLSobjects();
$this -> loadLSaddons();
session_start();
// Déconnexion
if (isset($_GET['LSsession_logout'])) {
session_destroy();
unset($_SESSION['LSsession']);
}
if(isset($_SESSION['LSsession'])) {
// Session existante
$this -> confDir = $_SESSION['LSsession'] -> confDir;
$this -> ldapServer = $_SESSION['LSsession'] -> ldapServer;
$this -> topDn = $_SESSION['LSsession'] -> topDn;
$this -> LSuserObject = $_SESSION['LSsession'] -> LSuserObject;
$this -> dn = $_SESSION['LSsession'] -> dn;
$this -> rdn = $_SESSION['LSsession'] -> rdn;
$GLOBALS['Smarty'] -> assign('LSsession_username',$this -> LSuserObject -> getDisplayValue());
return $this -> LSldapConnect();
}
else {
// Session inexistante
if (isset($_POST['LSsession_user'])) {
if (isset($_POST['LSsession_ldapserver'])) {
$this -> setLdapServer($_POST['LSsession_ldapserver']);
}
else {
$this -> setLdapServer(0);
}
// Connexion au serveur LDAP
if ($this -> LSldapConnect()) {
// topDn
if ( $_POST['LSsession_topDn'] != '' ){
$this -> topDn = $_POST['LSsession_topDn'];
}
else {
$this -> topDn = $this -> ldapServer['ldap_config']['basedn'];
}
if ( $this -> loadLSobject($this -> ldapServer['authobject']) ) {
$authobject = new $this -> ldapServer['authobject']();
$result = $authobject -> searchObject($_POST['LSsession_user'],$_POST['LSsession_topDn']);
$nbresult=count($result);
if ($nbresult==0) {
// identifiant incorrect
debug('identifiant incorrect');
$GLOBALS['LSerror'] -> addErrorCode(1006);
}
else if ($nbresult>1) {
// duplication d'authentité
$GLOBALS['LSerror'] -> addErrorCode(1007);
}
else {
if ( $this -> checkUserPwd($result[0],$_POST['LSsession_pwd']) ) {
// Authentification réussi
$this -> LSuserObject = $result[0];
$this -> dn = $result[0]->getValue('dn');
$this -> rdn = $_POST['LSsession_user'];
$this -> topDn = $_POST['LSsession_topDn'];
$GLOBALS['Smarty'] -> assign('LSsession_username',$this -> LSuserObject -> getDisplayValue());
$_SESSION['LSsession']=$this;
return true;
}
else {
$GLOBALS['LSerror'] -> addErrorCode(1006);
debug('mdp incorrect');
}
}
}
else {
$GLOBALS['LSerror'] -> addErrorCode(1010);
}
}
else {
$GLOBALS['LSerror'] -> addErrorCode(1009);
}
}
$this -> displayLoginForm();
return;
}
}
/*
* Définition du serveur Ldap de la session
*
* Définition du serveur Ldap de la session à partir de son ID dans
* le tableau $GLOBALS['LSconfig']['ldap_servers'].
*
* @param[in] integer Index du serveur Ldap
*
* @retval boolean True sinon false.
*/
function setLdapServer($id) {
if ( isset($GLOBALS['LSconfig']['ldap_servers'][$id]) ) {
$this -> ldapServer=$GLOBALS['LSconfig']['ldap_servers'][$id];
return true;
}
else {
return;
}
}
/*
* Connexion au serveur Ldap
*
* @retval boolean True sinon false.
*/
function LSldapConnect() {
if ($this -> ldapServer) {
include_once($GLOBALS['LSconfig']['NetLDAP']);
if (!$this -> loadLSclass('LSldap'))
return;
$GLOBALS['LSldap'] = new LSldap($this -> ldapServer['ldap_config']);
if ($GLOBALS['LSldap'] -> isConnected())
return true;
else
return;
return $GLOBALS['LSldap'] = new LSldap($this -> ldapServer['ldap_config']);
}
else {
$GLOBALS['LSerror'] -> addErrorCode(1003);
return;
}
}
function getSubDnLdapServer() {
if ( isset($this ->ldapServer['subdnobject']) ) {
if( $this -> loadLSobject($this ->ldapServer['subdnobject']) ) {
if ($subdnobject = new $this ->ldapServer['subdnobject']()) {
return $subdnobject -> getSelectArray();
}
else {
return;
}
}
else {
$GLOBALS['LSerror'] -> addErrorCode(1004,$this ->ldapServer['subdnobject']);
return;
}
}
else {
return;
}
}
/*
* Retourne les options d'une liste déroulante pour le choix du topDn
* de connexion au serveur Ldap
*
* Liste les subdnobject ($this ->ldapServer['subdnobject'])
*
* @retval string Les options (<option>) pour la sélection du topDn.
*/
function getSubDnLdapServerOptions() {
if ( isset($this ->ldapServer['subdnobject']) ) {
if( $this -> loadLSobject($this ->ldapServer['subdnobject']) ) {
if ($subdnobject = new $this ->ldapServer['subdnobject']()) {
return $subdnobject -> getSelectOptions();
}
else {
return;
}
}
else {
$GLOBALS['LSerror'] -> addErrorCode(1004,$this ->ldapServer['subdnobject']);
return;
}
}
else {
return;
}
}
/*
* Test un couple LSobject/pwd
*
* Test un bind sur le serveur avec le dn de l'objet et le mot de passe fourni.
*
* @param[in] LSobject L'object "user" pour l'authentification
* @param[in] string Le mot de passe à tester
*
* @retval boolean True si l'authentification à réussi, false sinon.
*/
function checkUserPwd($object,$pwd) {
return $GLOBALS['LSldap'] -> checkBind($object -> getValue('dn'),$pwd);
}
/*
* Affiche le formulaire de login
*
* Défini les informations pour le template Smarty du formulaire de login.
*
* @retval void
*/
function displayLoginForm() {
$GLOBALS['Smarty'] -> assign('pagetitle',_('Connexion'));
$GLOBALS['Smarty'] -> assign('loginform_action',$_SERVER['PHP_SELF']);
if (count($GLOBALS['LSconfig']['ldap_servers'])==1) {
$GLOBALS['Smarty'] -> assign('loginform_ldapserver_style','style="display: none"');
}
$GLOBALS['Smarty'] -> assign('loginform_label_ldapserver',_('Serveur LDAP'));
$ldapservers_name=array();
$ldapservers_index=array();
foreach($GLOBALS['LSconfig']['ldap_servers'] as $id => $infos) {
$ldapservers_index[]=$id;
$ldapservers_name[]=$infos['name'];
}
$GLOBALS['Smarty'] -> assign('loginform_ldapservers_name',$ldapservers_name);
$GLOBALS['Smarty'] -> assign('loginform_ldapservers_index',$ldapservers_index);
$this -> setLdapServer(0);
if ( $this -> LSldapConnect() ) {
$topDn_array = $this -> getSubDnLdapServer();
if ( $topDn_array ) {
$GLOBALS['Smarty'] -> assign('loginform_topdn_name',$topDn_array['display']);
$GLOBALS['Smarty'] -> assign('loginform_topdn_index',$topDn_array['dn']);
}
}
$GLOBALS['Smarty'] -> assign('loginform_label_level',_('Niveau'));
$GLOBALS['Smarty'] -> assign('loginform_label_user',_('Identifiant'));
$GLOBALS['Smarty'] -> assign('loginform_label_pwd',_('Mot de passe'));
$GLOBALS['Smarty'] -> assign('loginform_label_submit',_('Connexion'));
$this -> addJSscript('LSsession_login.js');
}
/*
* Défini le template Smarty à utiliser
*
* Remarque : les fichiers de templates doivent se trouver dans le dossier
* templates/.
*
* @param[in] string Le nom du fichier de template
*
* @retval void
*/
function setTemplate($template) {
$this -> template = $template;
}
/*
* Ajoute un script JS au chargement de la page
*
* Remarque : les scripts doivents être dans le dossier LS_JS_DIR.
*
* @param[in] $script Le nom du fichier de script à charger.
*
* @retval void
*/
function addJSscript($script) {
$this -> JSscripts[]=$script;
}
/*
* Ajoute une feuille de style au chargement de la page
*
* Remarque : les scripts doivents être dans le dossiers templates/css/.
*
* @param[in] $script Le nom du fichier css à charger.
*
* @retval void
*/
function addCssFile($file) {
$this -> CssFiles[]=$file;
}
/*
* Affiche le template Smarty
*
* Charge les dépendances et affiche le template Smarty
*
* @retval void
*/
function displayTemplate() {
// JS
$JSscript_txt='';
foreach ($GLOBALS['defaultJSscipts'] as $script) {
$JSscript_txt.="<script src='".LS_JS_DIR.$script."' type='text/javascript'></script>\n";
}
foreach ($this -> JSscripts as $script) {
$JSscript_txt.="<script src='".LS_JS_DIR.$script."' type='text/javascript'></script>\n";
}
$GLOBALS['Smarty'] -> assign('LSsession_js',$JSscript_txt);
// Css
$Css_txt="<link rel='stylesheet' type='text/css' href='templates/css/LSdefault.css' media='screen' />\n";
foreach ($this -> CssFiles as $file) {
$Css_txt.="<link rel='stylesheet' type='text/css' href='templates/css/$file' media='screen' />\n";
}
$GLOBALS['Smarty'] -> assign('LSsession_css',$Css_txt);
$GLOBALS['LSerror'] -> display();
debug_print();
$GLOBALS['Smarty'] -> display($this -> template);
}
}
?>

View file

@ -86,8 +86,23 @@ function getFData($format,$data,$meth=NULL) {
return $format;
}
function loadDir($dir,$regexpr='^.*\.php$') {
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if (ereg($regexpr,$file)) {
require_once($dir.'/'.$file);
}
}
}
else {
die(_('Dossier introuvable ('.$dir.').'));
}
return true;
}
function valid($obj) {
echo 'ok';
debug('Validation : ok');
return true;
}
@ -98,19 +113,24 @@ function return_data($data) {
function debug($data,$get=true) {
if ($get) {
if (is_array($data)) {
$GLOBALS['LSdebug'][]=$data;
$GLOBALS['LSdebug']['fields'][]=$data;
}
else {
$GLOBALS['LSdebug'][]="[$data]";
$GLOBALS['LSdebug']['fields'][]="[$data]";
}
}
return true;
}
function debug_print() {
echo "<fieldset><legend>Debug</legend><pre>";
print_r( $GLOBALS['LSdebug']);
echo "</pre></fieldset>";
if (( $GLOBALS['LSdebug']['fields'] ) && ( $GLOBALS['LSdebug']['active'] )) {
$txt='<ul>';
foreach($GLOBALS['LSdebug']['fields'] as $debug) {
$txt.='<li>'.$debug.'</li>';
}
$txt.='</ul>';
$GLOBALS['Smarty'] -> assign('LSdebug',$txt);
}
}
?>

View file

@ -0,0 +1,395 @@
/*
Script: Debugger.js
Creates Firebug <http://www.getfirebug.com> style debugger for browsers without Firebug.
License:
MIT-style license.
*/
var debug = {
timers: {},
pre: function(content, color, bgcolor){
if (debug.disabled) return;
if (!debug._body) debug.create();
var pre = new Element('pre').setStyles({
'padding': '3px 5px',
'margin': '0',
'font': '11px Andale Mono, Monaco, Courier New',
'border-bottom': '1px solid #eee',
'color': color || '#222',
'background-color': bgcolor || '#fff'
});
if ($type(content) == "string") pre.appendText(content);
else pre.adopt(content);
pre.injectInside(debug._contents);
debug._scroll.toBottom();
},
error: function(error){
debug.pre(error.name + ': ' + error.message, '#c92f2f', '#fffef0');
},
register: function(text){
debug.messages.remove(text);
debug.messages.push(text);
debug.idx = debug.messages.length;
var toCookie = debug.messages.join('-:-:-').replace(/;/g, '%%%');
Cookie.set('mootools-debugger-history', toCookie, {duration: {days: 2}});
},
result: function(args, spacer){
spacer = $type(spacer) ? spacer : ' ';
var chunks = [];
$each(args, function(argument){
var type = $type(argument);
if (type){
if ((type != 'string') && (type != 'element')){
try {
argument = Json.toString(argument);
} catch(e) {
argument = 'object not compatible with Json parser';
}
}
chunks.push({'type': type, 'message': argument});
}
});
var holder = new Element('div');
if (!chunks.length) return;
chunks.each(function(chunk){
var color = '#222';
switch(chunk.type){
case 'object': color = '#612fc9'; break;
case 'string': color = '#85b23e'; break;
case 'element':
color = '#3e72b2';
chunk.message = this.makeElementMsg(chunk.message);
break;
case 'boolean': color = '#ff3300'; break;
case 'array': color = '#953eb2'; break;
}
switch(chunk.type){
case 'element':
chunk.message.setStyle('color', color).injectInside(holder);
holder.appendText(spacer);
break;
case 'string':
new Element('span').appendText(chunk.message + spacer).setStyle('color', color).injectInside(holder);
break;
default:
new Element('span').setHTML(chunk.message + spacer).setStyle('color', color).injectInside(holder);
}
}, this);
debug.pre(holder);
},
makeElementMsg: function(el){
var a = new Element('a').addEvent('click', function(e){
new Fx.Style(el, 'opacity').start(0,1);
e.stop();
}.bindWithEvent()).setStyles({'cursor': 'pointer', 'text-decoration': 'none'}).setProperty('href', 'javascript:void(0)');
var htm = ['&lt;' + el.tagName.toLowerCase()];
['id', 'className', 'name', 'href', 'title', 'rel', 'type'].each(function(attr){
if (el[attr]) htm.push(attr + '="' + el[attr] + '"');
});
a.innerHTML = htm.join(' ') + '&gt;';
return a;
},
/*
Property: log
sends a message to the debugger.
Arguments:
messages - any number of strings, objects, etc. to print out
Note:
The debugger will allow firebug style log messages:
%s - String
%d, %i - Integer (numeric formatting is not yet supported)
%f - Floating point number (numeric formatting is not yet supported)
%o - Object hyperlink
Example:
>console.log("the value of x is %s and this paragraph is %o", x, $('id'));
> the value of x is <some value> and this paragraph is <p>
*/
log: function(){
var args = $A(arguments);
var spacer = ' ';
if ($type(args[0]) == 'string'){
spacer = '';
var logCollection = [], lastIndex = 0;
var regexp = /%[sdifo]/gi;
for (var i = 1; (i < args.length) && (token = regexp.exec(args[0])); i++){
logCollection.push(args[0].substring(lastIndex, token.index), args[i]);
lastIndex = regexp.lastIndex;
}
regexp.lastIndex = 0;
if (!lastIndex) return debug.result(args);
logCollection.push(args[0].substring(lastIndex));
args = logCollection;
}
return debug.result(args, spacer);
},
/*
Property: assert
Tests that an expression is true. If not, logs a message and throws an error.
Arguments:
condition - a boolean expression. If false, message will be logged and an error will be thrown.
messages - optional, any number of strings, objects, etc. to print out when thruth is false.
Example:
>console.assert((value > 0) && (value <= max), "value (%i) was not properly initialized", value);
*/
assert: function(condition){
if (!condition){
var args = $A(arguments, 1);
debug.log.apply(debug, args.length ? args : ["Assertion Failure"]);
throw new Error("Assertion Failure");
}
},
/*
Property: time
Starts a timer.
Argument:
name - the name of the timer
*/
time: function(name){
debug.timers[name] = new Date().getTime();
},
/*
Property: timeEnd
Ends a timer and logs that value to the console.
Argument:
name - the name of the timer
*/
timeEnd: function(name){
if (debug.timers[name]) debug.log('%s: %s', name, new Date().getTime() - debug.timers[name]);
else debug.log('no such timer: %s', name);
},
/*
Property: create
Displays the console area.
*/
create: function(){
//main element
debug._body = new Element('div').setStyles({
'position': window.ie6 ? 'absolute' : 'fixed',
'background': '#fff',
'font': '11px Andale Mono, Monaco, Courier New',
'z-index': '996'
}).injectInside(document.body);
//links
debug._actions = new Element('div').setStyles({
'text-align': 'right',
'background-color': '#f5f5f5',
'border-bottom': '1px solid #ddd',
'border-top': '1px solid #ddd',
'padding': '2px 10px',
'margin': '0px',
'font-size': '10px'
}).injectInside(debug._body);
new Element('span').setHTML('CLEAR').injectInside(debug._actions).addEvent('click', function(){
debug._contents.setHTML('');
}).setStyle('cursor', 'pointer');
new Element('span').setHTML('&nbsp;|&nbsp;').injectInside(debug._actions);
debug._minLink = new Element('span').setHTML('MIN').injectInside(debug._actions).addEvent('click', function(){
debug.minmax();
}).setStyle('cursor', 'pointer');
debug._maxLink = new Element('span').setHTML('MAX').injectInside(debug._actions).addEvent('click', function(){
debug.minmax(true);
}).setStyle('cursor', 'pointer');
var debuggerStatus = Cookie.get('mootools-debugger-status');
((debuggerStatus && (debuggerStatus.toInt() < 50)) ? debug._minLink : debug._maxLink).setStyle('display', 'none');
new Element('span').setHTML('&nbsp;|&nbsp;').injectInside(debug._actions);
new Element('span').setHTML('CLOSE').injectInside(debug._actions).addEvent('click', function(){
window.removeEvent('resize', debug.resize);
debug._body.remove();
debug._body = false;
}).setStyle('cursor', 'pointer');
//messages container
debug._contents = new Element('div').setStyles({
'position': 'relative',
'z-index': '9997',
'height': debuggerStatus || '112px',
'border-bottom': '1px solid #ddd',
'overflow': 'auto',
'background': '#fff'
}).injectInside(debug._body);
if (window.ie6) debug._contents.setStyle('width', '100%');
//input box
debug._input = new Element('input').setProperty('type', 'text').setStyles({
'z-index': '9996',
'width': '98%',
'background': '#fff',
'color': '#222',
'font': '12px Andale Mono, Monaco, Courier New',
'height': '16px',
'border': '0',
'padding': '2px 2px 2px 31px',
'position': 'relative',
'margin-top': '-1px'
}).injectInside(debug._body);
//>>>
debug._gts = new Element('div').setHTML("&gt;&gt;&gt;").setStyles({
'color': '#3e72b2',
'padding': '2px 5px',
'background': '#fff',
'z-index': '9999',
'position': 'absolute',
'left': '0'
}).injectInside(debug._body);
if (window.webkit){
debug._input.setStyles({
'margin-top': '-2px',
'margin-left': '29px',
'font-size': '12px',
'opacity': '0.99'
});
};
debug._scroll = new Fx.Scroll(debug._contents, {duration: 300, wait: false});
debug.resetHeight();
window.addEvent('resize', debug.resize);
if (window.ie6) window.addEvent('scroll', debug.resetHeight);
debug._input.onkeydown = debug.parseKey.bindWithEvent(debug);
},
resetHeight: function(){
debug._hgt = debug._body.offsetHeight;
if (!window.webkit) debug._hgt -= 3;
else debug._hgt -= 1;
debug._gts.setStyle('top', (debug._hgt - debug._gts.offsetHeight - 1));
debug.resize();
debug._scroll.toBottom();
},
resize: function(){
if (window.ie6){
debug._body.setStyles({
'top': (window.getScrollTop() + window.getHeight() - debug._hgt - 5),
'width': (window.getWidth() - 16)
});
} else {
debug._body.setStyles({
'top': (window.getHeight() - debug._hgt + 1),
'width': (window.getWidth())
});
}
},
minmax: function(maximize){
debug._maxLink.setStyle('display', maximize ? 'none' : '');
debug._minLink.setStyle('display', maximize ? '' : 'none');
var size = maximize ? '112px' : '18px';
debug._contents.style.height = size;
Cookie.set('mootools-debugger-status', size);
debug.resetHeight();
},
parseKey: function(e){
var value = debug._input.value;
switch(e.key){
case 'enter':
if (!value) return;
debug._input.value = '';
switch(value){
case 'exit': debug._body.remove(); debug._body = false; return;
case 'clear':
case 'clr': debug._contents.setHTML(''); return;
case 'max': this.minmax(true); return;
case 'min': this.minmax(); return;
}
debug.pre('>>> ' + value, '#3e72b2');
try {
var evaluation = eval(value);
if (evaluation !== undefined) debug.result([evaluation]);
} catch (err){
debug.error(err);
}
debug.register(value);
break;
case 'up':
e.stop();
var i = debug.idx - 1;
if (debug.messages[i]){
debug._input.value = debug.messages[i];
debug.idx = i;
}
break;
case 'down':
e.stop();
var i = debug.idx + 1;
if (debug.messages[i]){
debug._input.value = debug.messages[i];
debug.idx = i;
} else {
debug._input.value = '';
debug.idx = debug.messages.length;
}
}
}
};
debug.messages = Cookie.get('mootools-debugger-history');
debug.messages = debug.messages ? debug.messages.replace(/%%%/g, ';').split('-:-:-') : [];
debug.idx = debug.messages.length;
if ((typeof console == 'undefined') || !console.warn){
var console = debug;
window.onerror = function(msg, url, line){
console.error({
'message': msg + '\n >>>>> ' + url + ' (' + line + ')',
'name': 'Run Time Error'
});
};
if (typeof Ajax != 'undefined'){
Ajax = Ajax.extend({
onStateChange: function(){
this.parent();
this.log();
},
log: function(){
if (this.transport.readyState == 4){
try {
if (debug._body){
var txt = this.transport.responseText;
if ($chk(txt)){
if (txt.length > 100) txt = txt.substring(0, 100) + " ...";
} else {
txt = 'undefined';
}
debug.log("%s: %s"+"\n"+"status: %s"+"\n"+"responseText: %s", this.options.method, this.url, this.transport.status, txt);
}
} catch(e){}
}
}
});
}
}

View file

@ -0,0 +1,60 @@
var LSdefault = new Class({
initialize: function(){
LSdebug('toto');
this.LSdebug = $('LSdebug');
this.LSdebugInfos = $('LSdebug_infos');
this.LSdebug.setOpacity(0);
if (this.LSdebugInfos.innerHTML != '') {
this.displayDebugBox();
}
this.LSdebugHidden = $('LSdebug_hidden');
this.LSdebugHidden.addEvent('click',this.onLSdebugHiddenClick.bind(this));
this.LSerror = $('LSerror');
this.LSerror.setOpacity(0);
if (this.LSerror.innerHTML != '') {
this.displayLSerror();
}
},
onLSdebugHiddenClick: function(){
new Fx.Style(this.LSdebug,'opacity',{duration:500}).start(1,0);
},
displayDebugBox: function() {
new Fx.Style(this.LSdebug,'opacity',{duration:500}).start(0,0.8);
},
displayError: function(html) {
this.LSerror.empty();
this.LSerror.setHTML(html);
this.displayLSerror();
},
displayLSerror: function() {
new Fx.Style(this.LSerror,'opacity',{duration:500}).start(0,0.8);
(function(){new Fx.Style(this.LSerror,'opacity',{duration:500}).start(0.8,0);}).delay(5000, this);
},
loadingImgDisplay: function(el) {
this.loading_img = new Element('img');
this.loading_img.src='templates/images/ajax-loader.gif';
this.loading_img.injectAfter(el);
},
loadingImgHide: function() {
this.loading_img.remove();
}
});
window.addEvent(window.ie ? 'load' : 'domready', function() {
varLSdefault = new LSdefault();
});
LSdebug_active = 1;
function LSdebug() {
if (LSdebug_active != 1) return;
if (typeof console == 'undefined') return;
console.log.apply(this, arguments);
}

View file

@ -0,0 +1,70 @@
var LSform = new Class({
initialize: function(){
this.objecttype = $('LSform_objecttype').value;
this.idform = $('LSform_idform').value;
$$('img.LSform-add-field-btn').each(function(el) {
el.addEvent('click',this.onAddFieldBtnClick.bind(this,el));
}, this);
$$('img.LSform-remove-field-btn').each(function(el) {
el.addEvent('click',this.onRemoveFieldBtnClick.bind(this,el));
}, this);
},
onAddFieldBtnClick: function(img){
var getAttrName = /LSform_add_field_btn_(.*)_.*/
var attrName = getAttrName.exec(img.id)[1];
LSdebug(attrName);
var data = {
template: 'LSform',
action: 'onAddFieldBtnClick',
attribute: attrName,
objecttype: this.objecttype,
idform: this.idform,
img: img.id
};
LSdebug(data);
varLSdefault.loadingImgDisplay(img);
new Ajax('index_ajax.php', {data: data, onComplete: this.onAddFieldBtnClickComplete.bind(this)}).request();
},
onAddFieldBtnClickComplete: function(responseText, responseXML) {
varLSdefault.loadingImgHide();
var data = Json.evaluate(responseText);
LSdebug(data);
if ( data ) {
if ( typeof(data.LSerror) != "undefined" ) {
varLSdefault.displayError(data.LSerror);
return;
}
else {
var li = new Element('li');
var img = $(data.img);
li.setHTML(data.html);
li.injectAfter(img.getParent());
li.getElements('img[class=LSform-add-field-btn]').each(function(el) {
el.addEvent('click',this.onAddFieldBtnClick.bind(this,el));
}, this);
li.getElements('img[class=LSform-remove-field-btn]').each(function(el) {
el.addEvent('click',this.onRemoveFieldBtnClick.bind(this,el));
}, this);
}
}
},
onRemoveFieldBtnClick: function(img) {
if (img.getParent().getParent().getChildren().length == 1) {
img.getPrevious().getPrevious().value='';
}
else {
img.getParent().remove();
}
}
});
window.addEvent(window.ie ? 'load' : 'domready', function() {
varLSform = new LSform();
});

View file

@ -0,0 +1,47 @@
var LSsession_login = new Class({
initialize: function(){
this.select_ldapserver = $('LSsession_ldapserver');
if ( ! this.select_ldapserver )
return;
this.select_ldapserver.addEvent('change',this.onLdapServerChanged.bind(this));
},
onLdapServerChanged: function(){
varLSdefault.loadingImgDisplay(this.select_ldapserver);
var server = this.select_ldapserver.value;
var data = {
template: 'login',
action: 'onLdapServerChanged',
server: server
};
new Ajax('index_ajax.php', {data: data, onComplete: this.onLdapServerChangedComplete.bind(this)}).request();
},
onLdapServerChangedComplete: function(responseText, responseXML){
varLSdefault.loadingImgHide();
var data = Json.evaluate(responseText);
LSdebug(data);
if ( data ) {
if (data.LSerror) {
varLSdefault.displayError(data.LSerror);
return;
}
else {
$('LSsession_topDn').getParent().setHTML(data.list_topDn);
LSdebug($('LSsession_topDn').innerHTML);
$$('.loginform-level').each(function(el) {
el.setStyle('display','block');
});
}
}
else {
$$('.loginform-level').each(function(el) {
el.setStyle('display','none');
});
$('LSsession_topDn').empty();
}
}
});
window.addEvent(window.ie ? 'load' : 'domready', function() {
varLSsession_login = new LSsession_login();
});

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,3 @@
<pre>
<?php
/*******************************************************************************
* Copyright (C) 2007 Easter-eggs
@ -21,93 +20,41 @@
******************************************************************************/
define('LS_CONF_DIR','conf/');
define('LS_INCLUDE_DIR','includes/');
define('LS_CLASS_DIR', LS_INCLUDE_DIR .'class/');
define('LS_LIB_DIR', LS_INCLUDE_DIR .'libs/');
define('LS_ADDONS_DIR', LS_INCLUDE_DIR .'addons/');
require_once 'includes/functions.php';
require_once 'includes/class/class.LSsession.php';
require_once LS_CONF_DIR .'config.php';
require_once LS_CONF_DIR .'error_code.php';
require_once LS_CONF_DIR .'config.LSeepeople.php';
require_once LS_CONF_DIR .'config.LSeegroup.php';
require_once $GLOBALS['LSconfig']['NetLDAP'];
$GLOBALS['LSsession'] = new LSsession();
require_once LS_INCLUDE_DIR .'functions.php';
if($LSsession -> startLSsession()) {
require_once LS_CLASS_DIR .'class.LSerror.php';
require_once LS_CLASS_DIR .'class.LSldap.php';
require_once LS_CLASS_DIR .'class.LSldapObject.php';
require_once LS_CLASS_DIR .'class.LSattribute.php';
require_once LS_CLASS_DIR .'class.LSattr_ldap.php';
require_once LS_CLASS_DIR .'class.LSattr_ldap_ascii.php';
require_once LS_CLASS_DIR .'class.LSattr_ldap_password.php';
require_once LS_CLASS_DIR .'class.LSattr_ldap_numeric.php';
require_once LS_CLASS_DIR .'class.LSattr_html.php';
require_once LS_CLASS_DIR .'class.LSattr_html_text.php';
require_once LS_CLASS_DIR .'class.LSattr_html_textarea.php';
require_once LS_CLASS_DIR .'class.LSattr_html_password.php';
require_once LS_CLASS_DIR .'class.LSattr_html_select_list.php';
// Définition du Titre de la page
$GLOBALS['Smarty'] -> assign('pagetitle',_('Mon compte'));
require_once LS_CLASS_DIR .'class.LSeepeople.php';
require_once LS_CLASS_DIR .'class.LSeegroup.php';
// ---- les objets LDAP
// Création d'un LSeepeople
$eepeople = new LSeepeople();
// Chargement des données de l'objet depuis l'annuaire et à partir de son DN
$eepeople-> loadData($GLOBALS['LSsession']->dn);
// 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();
require_once LS_CLASS_DIR .'class.LSform.php';
require_once LS_CLASS_DIR .'class.LSformElement.php';
require_once LS_CLASS_DIR .'class.LSformElement_text.php';
require_once LS_CLASS_DIR .'class.LSformElement_textarea.php';
require_once LS_CLASS_DIR .'class.LSformElement_select.php';
require_once LS_CLASS_DIR .'class.LSformElement_password.php';
require_once LS_CLASS_DIR .'class.LSformRule.php';
require_once LS_CLASS_DIR .'class.LSformRule_regex.php';
require_once LS_CLASS_DIR .'class.LSformRule_alphanumeric.php';
require_once LS_CLASS_DIR .'class.LSformRule_compare.php';
require_once LS_CLASS_DIR .'class.LSformRule_email.php';
require_once LS_CLASS_DIR .'class.LSformRule_lettersonly.php';
require_once LS_CLASS_DIR .'class.LSformRule_maxlength.php';
require_once LS_CLASS_DIR .'class.LSformRule_minlength.php';
require_once LS_CLASS_DIR .'class.LSformRule_nonzero.php';
require_once LS_CLASS_DIR .'class.LSformRule_nopunctuation.php';
require_once LS_CLASS_DIR .'class.LSformRule_numeric.php';
require_once LS_CLASS_DIR .'class.LSformRule_rangelength.php';
require_once LS_ADDONS_DIR .'LSaddons.samba.php';
LSaddon_samba_support();
require_once LS_ADDONS_DIR .'LSaddons.posix.php';
LSaddon_posix_support();
// Simulation d'une LSsession
$GLOBALS['LSsession']['topDn']='o=lsexample';
// "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']);
// Chargement des données de l'objet depuis l'annuaire et à partir de son DN
$eepeople-> loadData('uid=eeggs,ou=people,o=lsexample');
// 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');
// Template
$GLOBALS['LSsession'] -> setTemplate('base.tpl');
}
else {
$GLOBALS['LSsession'] -> setTemplate('login.tpl');
}
// Affichage du formulaire
$form -> display();
// Affichage des retours d'erreurs
$LSerror -> display();
$GLOBALS['LSsession'] -> displayTemplate();
?>
</pre>
<?php debug_print(); ?>

69
trunk/index_ajax.php Normal file
View file

@ -0,0 +1,69 @@
<?php
require_once 'includes/functions.php';
require_once 'includes/class/class.LSsession.php';
$GLOBALS['LSsession'] = new LSsession();
$GLOBALS['LSsession'] -> loadLSobjects();
if ($_REQUEST['template'] != 'login') {
if ( !$GLOBALS['LSsession'] -> startLSsession() ) {
echo json_encode(array('LSerror' => 'LSsession : Impossible d\'initialiser la LSsession.' ));
}
}
switch($_REQUEST['template']) {
case 'login':
switch($_REQUEST['action']) {
case 'onLdapServerChanged':
if ( isset($_REQUEST['server']) ) {
$GLOBALS['LSsession'] -> setLdapServer($_REQUEST['server']);
if ( $GLOBALS['LSsession'] -> LSldapConnect() ) {
$list = $GLOBALS['LSsession'] -> getSubDnLdapServerOptions();
if (is_string($list)) {
$list="<select name='LSsession_topDn' id='LSsession_topDn'>".$list."</select>";
$data = array('list_topDn' => $list);
}
else if (is_array($list)){
$data = array('LSerror' => $GLOBALS['LSerror']->getErrors());
}
else {
$data = null;
}
}
else {
$data = array('LSerror' => $GLOBALS['LSerror']->getErrors());
}
}
else {
$data=NULL;
}
break;
}
break;
case 'LSform':
switch($_REQUEST['action']) {
case 'onAddFieldBtnClick':
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['idform'])) && (isset($_REQUEST['img'])) ) {
$object = new $_REQUEST['objecttype']();
$form = $object -> getForm($_REQUEST['idform']);
$emptyField=$form -> getEmptyField($_REQUEST['attribute']);
if ( $emptyField ) {
$data = array(
'html' => $form -> getEmptyField($_REQUEST['attribute']),
'img' => $_REQUEST['img'],
);
}
else {
$data = array('LSerror' => $GLOBALS['LSerror']->getErrors());
}
}
else {
$data=NULL;
}
break;
}
break;
}
echo json_encode($data);
?>

Binary file not shown.

49
trunk/templates/base.tpl Normal file
View file

@ -0,0 +1,49 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if}</title>
<link rel="stylesheet" type="text/css" href="templates/css/base.css" media="screen" title="Normal" />
{$LSsession_css}
{$LSsession_js}
</head>
<body>
<div id='LSerror'>
{$LSerrors}
</div>
<div id='LSdebug'>
<a href='#' id='LSdebug_hidden'>X</a>
<div id='LSdebug_infos'>{if $LSdebug != ''}{$LSdebug}{/if}</div>
</div>
<div id='main'>
<div id='left'>
<img src='templates/images/logo.png' alt='Logo' id='logo'/>
<ul class='menu'>
<li class='menu'><a href='index.php' class='menu'>Mon compte</a></li>
<li class='menu'><a href='mon_compte.php' class='menu'>Utilisateurs</a></li>
<li class='menu'><a href='mon_compte.php' class='menu'>Groupes</a></li>
</ul>
</div>
<div id='right'>
<p id='status'>Connecté en tant que <span id='user_name'>{$LSsession_username}</span></b> <a href='index.php?LSsession_logout'><img src='templates/images/logout.png' alt='Logout' title='Logout' /></a></p>
<h1>Mon compte</h1>
<form action='{$LSform_action}' method='post' class='LSform'>
{$LSform_header}
<dl class='LSform'>
{foreach from=$LSform_fields item=field}
<dt class='LSform'>{$field.label}</dt>
<dd class='LSform'>{$field.html}{if $field.add != ''} <span class='LSform-addfield'>+ Ajouter un champ</span>{/if}</dd>
{if $field.errors != ''}
{foreach from=$field.errors item=error}
<dd class='LSform LSform-errors'>{$error}</dd>
{/foreach}
{/if}
{/foreach}
</dl>
<input type='submit' value='{$LSform_submittxt}' class='LSform' />
</div>
<hr class='spacer' />
</div>
</body>
</html>

View file

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

View file

@ -0,0 +1,51 @@
form.LSform {
margin-left: 2em;
}
dl.LSform {
margin: 0;
padding: 0;
}
.LSform dt {
position: relative;
left: 0.2em;
top: 1.2em;
width: 12em;
font-weight: bold;
font-size: 0.9em;
color: #0072b8;
}
dd.LSform {
margin: 0 0 0 13em;
padding: 0 0 0em 0em;
}
.LSform input, .LSform select, .LSform textarea {
border: 1px inset #ccc;
width: 20em;
background-color: #b5e4f6;
}
input[type='submit'].LSform {
border: 1px outset #ccc;
margin-left: 20em;
margin-top: 1em;
width: 8em;
}
ul.LSform {
list-style-type: none;
padding: 0;
margin: 0;
}
.LSform-errors {
color: #fff;
background-color: #f59a67;
}
img.LSform-add-field-btn, img.LSform-remove-field-btn {
cursor: pointer;
}

View file

@ -0,0 +1,80 @@
body {
font-family: sans-serif;
margin: 0;
padding: 0;
}
img {
vertical-align: bottom;
}
a:hover {
text-decoration: underline;
}
h1 {
margin: 0.5em;
border-bottom: 1px solid #0072b8;
color: #0072b8;
}
a img {
border: none;
}
hr {
visibility: hidden;
clear: both;
height: 0px;
}
#main {
width: 1000px;
margin: auto;
border: 1px solid #52bce5;
background: #fff url(../images/fd_menu.png) repeat-y scroll left top;
}
#left {
float: left;
width: 160px;
}
#right {
margin: 0;
float: left;
width: 840px;
}
#logo {
margin: auto;
width: 142px;
margin-left: 9px;
}
#status {
margin: 0;
padding: 0;
font-size: 0.7em;
color: #fff;
text-align: right;
background-color: #52bce5;
padding: 0.3em;
}
#user_name {
font-weight: bold;
}
ul.menu {
list-style-image: url(../images/puce.png);
}
li.menu {
color: #fff;
}
a.menu {
color: #fff;
text-decoration: none;
}

View file

@ -0,0 +1,51 @@
#loginform-logo {
float: left;
}
div.loginform {
margin: auto;
margin-top: 10%;
border: 1px solid #69c;
padding: 1em;
width: 30em;
background: transparent url(../images/login_fd.png) no-repeat scroll 98% 98%;
}
dl.loginform {
margin: 0;
padding: 0;
}
.loginform dt {
position: relative;
left: 0;
top: 1.1em;
width: 8em;
font-weight: bold;
font-size: 0.9em;
}
.loginform dd {
margin: 0 0 0 9em;
padding: 0 0 0em 0em;
}
.loginform-level{
display: none;
}
.loginform-id {
visibility: hidden;
}
.loginform input, .loginform select {
border: 1px inset #ccc;
width: 13em;
}
.loginform input[type='submit'] {
border: 1px outset #ccc;
margin-left: 30em;
margin-top: 1em;
width: 8em;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 323 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 805 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 300 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

37
trunk/templates/login.tpl Normal file
View file

@ -0,0 +1,37 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if}</title>
<link rel="stylesheet" type="text/css" href="templates/css/login.css" media="screen" title="Normal" />
{$LSsession_css}
{$LSsession_js}
</head>
<body>
<div id='LSerror'>
{$LSerrors}
</div>
<div id='LSdebug'>
<a href='#' id='LSdebug_hidden'>X</a>
<div id='LSdebug_infos'>{if $LSdebug != ''}{$LSdebug}{/if}</div>
</div>
<div class='loginform'>
<img src='templates/images/logo.png' alt='Logo' id='loginform_logo' />
<form action='{$loginform_action}' method='post'>
<dl class='loginform'>
<dt {$loginform_ldapserver_style}>{$loginform_label_ldapserver}</dt>
<dd {$loginform_ldapserver_style}>
<select name='LSsession_ldapserver' id='LSsession_ldapserver'>{html_options values=$loginform_ldapservers_index output=$loginform_ldapservers_name}</select>
</dd>
<dt class='loginform-level' {$loginform_ldapserver_style}>{$loginform_label_level}</dt>
<dd class='loginform-level' {$loginform_ldapserver_style}><select name='LSsession_topDn' id='LSsession_topDn'>{html_options values=$loginform_topdn_index output=$loginform_topdn_name}</select></dd>
<dt>{$loginform_label_user}</dt>
<dd><input type='text' name='LSsession_user' /></dd>
<dt>{$loginform_label_pwd}</dt>
<dd><input type='password' name='LSsession_pwd' /></dd>
</dl>
<input type='submit' value='{$loginform_label_submit}' />
</form>
</div>
</body>
</html>