mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-18 00:09:06 +01:00
Gros commit avec principalement la suppression de HTML_QuickForm (qui s'est révélé trop peu
souple) remplacé par la classes LSform qui réimplemente pas mal de fonctionnalités de HTML_QuickForm en gérant nativement que tout les champs soit à valeurs multiples. Dans l'état actuel, la modification et la création d'objet sont gérés. B.Renard
This commit is contained in:
parent
684e7fac8d
commit
337be06f1f
45 changed files with 3973 additions and 416 deletions
|
@ -25,10 +25,12 @@ $GLOBALS['LSobjects']['LSeegroup'] = array (
|
|||
'ostgroup',
|
||||
'posixGroup'
|
||||
),
|
||||
'rdn' => 'cn',
|
||||
'container_dn' => 'ou=groups',
|
||||
'select_display_attrs' => '%{cn}',
|
||||
'attrs' => array (
|
||||
'cn' => array (
|
||||
'label' => 'Nom',
|
||||
'label' => _('Nom'),
|
||||
'ldap_type' => 'ascii',
|
||||
'html_type' => 'text',
|
||||
'required' => 1,
|
||||
|
@ -42,12 +44,16 @@ $GLOBALS['LSobjects']['LSeegroup'] = array (
|
|||
'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',
|
||||
'label' => _('Identifiant'),
|
||||
'ldap_type' => 'numeric',
|
||||
'html_type' => 'text',
|
||||
'required' => 1,
|
||||
|
@ -58,7 +64,7 @@ $GLOBALS['LSobjects']['LSeegroup'] = array (
|
|||
'result' => 0
|
||||
)
|
||||
),
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'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
|
||||
),
|
||||
|
@ -67,7 +73,7 @@ $GLOBALS['LSobjects']['LSeegroup'] = array (
|
|||
)
|
||||
),
|
||||
'uniqueMember' => array (
|
||||
'label' => 'Membres',
|
||||
'label' => _('Membres'),
|
||||
'ldap_type' => 'ascii',
|
||||
'html_type' => 'select_list',
|
||||
'required' => 0,
|
||||
|
@ -77,7 +83,7 @@ $GLOBALS['LSobjects']['LSeegroup'] = array (
|
|||
'result' => 1
|
||||
)
|
||||
),
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'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
|
||||
),
|
||||
|
@ -85,17 +91,17 @@ $GLOBALS['LSobjects']['LSeegroup'] = array (
|
|||
'test' => 1
|
||||
),
|
||||
'possible_values' => array(
|
||||
'aucun' => '-- Selectionner --',
|
||||
'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
|
||||
'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
|
||||
'value_attribute' => '%{dn}', // Spécifie le attributs dont la valeur sera retournée par
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -22,21 +22,26 @@
|
|||
|
||||
$GLOBALS['LSobjects']['LSeepeople'] = array (
|
||||
'objectclass' => array(
|
||||
'top',
|
||||
'ostpeople',
|
||||
'posixAccount'
|
||||
'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',
|
||||
'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."
|
||||
'msg' => _("L'identifiant ne doit comporter que des lettres et des chiffres.")
|
||||
),
|
||||
),
|
||||
'validation' => array (
|
||||
|
@ -44,10 +49,10 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
'basedn' => 'o=ost',
|
||||
'filter' => 'uid=%{val}',
|
||||
'result' => 0,
|
||||
//~ 'msg' => 'Cet identifiant est déjà utilisé.'
|
||||
'msg' => _('Cet identifiant est déjà utilisé.')
|
||||
)
|
||||
),
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'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
|
||||
),
|
||||
|
@ -57,13 +62,14 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
)
|
||||
),
|
||||
'uidNumber' => array (
|
||||
'label' => 'Identifiant (numérique)',
|
||||
'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."
|
||||
'msg' => _("L'identifiant unique doit être un entier.")
|
||||
),
|
||||
),
|
||||
'validation' => array (
|
||||
|
@ -71,25 +77,25 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
'basedn' => 'o=ost',
|
||||
'filter' => 'uidNumber=%{val}',
|
||||
'result' => 0,
|
||||
//~ 'msg' => 'Cet identifiant est déjà utilisé.'
|
||||
'msg' => _('Cet uid est déjà utilisé.')
|
||||
)
|
||||
),
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'self' => 'w', // définition des droits de l'utilisateur sur lui même
|
||||
'users' => 'r' // définition des droits de tout les utilisateurs
|
||||
),
|
||||
'form' => array (
|
||||
'test' => 0,
|
||||
'add' => 1
|
||||
)
|
||||
),
|
||||
'cn' => array (
|
||||
'label' => 'Nom complet',
|
||||
'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)
|
||||
'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
|
||||
),
|
||||
|
@ -99,24 +105,17 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
)
|
||||
),
|
||||
'givenName' => array (
|
||||
'label' => 'Prenom',
|
||||
'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.'
|
||||
'msg' => _('Le prenom ne doit comporter que des lettres et des chiffres.')
|
||||
),
|
||||
),
|
||||
//~ 'validation' => array (
|
||||
//~ array (
|
||||
//~ 'basedn' => 'o=ost',
|
||||
//~ 'filter' => 'uid=%{uid}',
|
||||
//~ 'result' => 0
|
||||
//~ )
|
||||
//~ ),
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'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
|
||||
),
|
||||
|
@ -127,23 +126,11 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
'onDisplay' => 'return_data'
|
||||
),
|
||||
'sn' => array (
|
||||
'label' => 'Nom',
|
||||
'label' => _('Nom'),
|
||||
'ldap_type' => 'ascii',
|
||||
'html_type' => 'text',
|
||||
'required' => 1,
|
||||
'check_data' => array (
|
||||
'alphanumeric' => array(
|
||||
'msg' => 'Le nom ne doit comporter que des lettres et des chiffres.'
|
||||
),
|
||||
),
|
||||
//~ 'validation' => array (
|
||||
//~ array (
|
||||
//~ 'basedn' => 'o=ost',
|
||||
//~ 'filter' => 'uid=%{uid}',
|
||||
//~ 'result' => 0
|
||||
//~ )
|
||||
//~ ),
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'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
|
||||
),
|
||||
|
@ -153,19 +140,19 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
)
|
||||
),
|
||||
'gidNumber' => array (
|
||||
'label' => 'Groupe principal',
|
||||
'label' => _('Groupe principal'),
|
||||
'ldap_type' => 'numeric',
|
||||
'html_type' => 'select_list',
|
||||
'required' => 1,
|
||||
'validation' => array (
|
||||
array (
|
||||
'object_type' => 'LSeegroup', // 'object_type' : Permet definir le type d'objet recherchés
|
||||
'basedn' => 'o=ost', // et d'utiliser les objectClass définis dans le fichier de configuration
|
||||
'filter' => '(gidNumber=%{val})', // pour la recherche
|
||||
'basedn' => 'o=ost', // et d'utiliser les objectClass définis dans le fichier de configuration
|
||||
'filter' => '(gidNumber=%{val})', // pour la recherche
|
||||
'result' => 1
|
||||
)
|
||||
),
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'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
|
||||
),
|
||||
|
@ -174,35 +161,249 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
'add' => 1
|
||||
),
|
||||
'possible_values' => array(
|
||||
'aucun' => '-- Selectionner --',
|
||||
'' => '-- Selectionner --',
|
||||
'OTHER_OBJECT' => array(
|
||||
'object_type' => 'LSeegroup', // Nom de l'objet à lister
|
||||
'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
|
||||
// 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
|
||||
'value_attribute' => 'gidNumber', // Spécifie le attributs dont la valeur sera retournée par
|
||||
'filter' => // le formulaire spécifie les filtres de recherche pour
|
||||
array ( // l'établissement de la liste d'objets :
|
||||
array( // Premier filtre
|
||||
'filter' => 'cn=*a*',
|
||||
'basedn' => 'o=ost',
|
||||
'scope' => 'sub',
|
||||
//~ 'attr' => '[attribut]', // Si 'attr' est définis, on effectura pour chacune des
|
||||
// valeurs de l'attribut correspants une recherche avec
|
||||
// le filtre suivant composé avec la valeur de cette attribut
|
||||
)
|
||||
//~ array(
|
||||
//~ 'filter' => '[format sprintf]',
|
||||
//~ 'basedn' => '[basedn]',
|
||||
//~ ),
|
||||
//~ ...
|
||||
)
|
||||
//~ 'basedn' =>
|
||||
//~ '[basedn]'
|
||||
)
|
||||
)
|
||||
),
|
||||
'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' => 1,
|
||||
)
|
||||
),
|
||||
'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',
|
||||
'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éponce 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.obs-ost.fr' => 'Oui',
|
||||
'' => 'Non'
|
||||
)
|
||||
),
|
||||
'vacationInfo' => array (
|
||||
'label' => _('Message en reponse'),
|
||||
'ldap_type' => 'ascii',
|
||||
'html_type' => 'textarea',
|
||||
'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
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -23,16 +23,14 @@
|
|||
// Configuration LDAP Saisie :
|
||||
$GLOBALS['LSconfig'] = array(
|
||||
'NetLDAP' => '/usr/share/php/Net/LDAP.php',
|
||||
'QuickForm' => '/usr/share/php/QuickForm.php',
|
||||
'check_data_place' => 'server',
|
||||
'ldap_config'=> array(
|
||||
'host' => 'localhost',
|
||||
'port' => 389,
|
||||
'version' => 3,
|
||||
'starttls' => false,
|
||||
'binddn' => 'uid=eeggs,ou=people,o=com',
|
||||
'binddn' => 'uid=eeggs,ou=people,o=lsexample',
|
||||
'bindpw' => 'toto',
|
||||
'basedn' => 'o=ost',
|
||||
'basedn' => 'o=lsexample',
|
||||
'options' => array(),
|
||||
'filter' => '(objectClass=*)',
|
||||
'scope' => 'sub'
|
||||
|
|
|
@ -22,97 +22,176 @@
|
|||
|
||||
$GLOBALS['error_code'] = array (
|
||||
'-1' => array (
|
||||
'msg' => 'Erreur inconnue!',
|
||||
'msg' => _("Erreur inconnue!"),
|
||||
'level' => 'c'
|
||||
),
|
||||
// LSldap
|
||||
1 => array (
|
||||
'msg' => 'LSldap : Erreur durant la connexion au serveur LDAP (%{msg}).',
|
||||
'msg' => _("LSldap : Erreur durant la connexion au serveur LDAP (%{msg})."),
|
||||
'level' => 'c'
|
||||
),
|
||||
2 => array (
|
||||
'msg' => 'LSldap : Erreur durant la recherche LDAP (%{msg}).',
|
||||
'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.",
|
||||
'msg' => _("LSldapObject : Type d'objet inconnu."),
|
||||
'level' => 'c'
|
||||
),
|
||||
22 => array (
|
||||
'msg' => "LSldapObject : Formulaire de mise jour inconnu par l'objet %{msg}.",
|
||||
'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}.",
|
||||
'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.",
|
||||
'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}.",
|
||||
'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}.",
|
||||
'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.",
|
||||
'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.",
|
||||
'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.",
|
||||
'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.",
|
||||
'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 : Type d'attribut (ldap // html) inconnu (ldap = %{ldap} | html = %{html}).",
|
||||
'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.",
|
||||
'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.",
|
||||
'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.",
|
||||
'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.",
|
||||
'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.",
|
||||
'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}.",
|
||||
'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.",
|
||||
'msg' => _("Functions 'getFData' : La methode %{meth} de l'objet %{obj} n'existe pas."),
|
||||
'level' => 'c'
|
||||
),
|
||||
);
|
||||
?>
|
||||
?>
|
||||
|
|
171
trunk/includes/addons/LSaddons.posix.php
Normal file
171
trunk/includes/addons/LSaddons.posix.php
Normal file
|
@ -0,0 +1,171 @@
|
|||
<?php
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2007 Easter-eggs
|
||||
* http://ldapsaisie.labs.libre-entreprise.org
|
||||
*
|
||||
* Author: See AUTHORS file in top-level directory.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
* Données de configuration pour le support POSIX
|
||||
*/
|
||||
|
||||
// Nom de l'attribut LDAP uid
|
||||
define('LS_POSIX_UID_ATTR','uid');
|
||||
|
||||
// Nom de l'attribut LDAP uidNumber
|
||||
define('LS_POSIX_UIDNUMBER_ATTR','uidNumber');
|
||||
|
||||
// Valeur minimum d'un uidNumber
|
||||
define('LS_POSIX_UIDNUMBER_MIN_VAL','100000');
|
||||
|
||||
// Nom de l'attribut LDAP gidNumber
|
||||
define('LS_POSIX_GIDNUMBER_ATTR','gidNumber');
|
||||
|
||||
// Valeur minimum d'un gidNumber
|
||||
define('LS_POSIX_GIDNUMBER_MIN_VAL','100000');
|
||||
|
||||
// Dossier contenant les homes des utilisateurs (defaut: /home/)
|
||||
define('LS_POSIX_HOMEDIRECTORY','/home/');
|
||||
|
||||
|
||||
|
||||
// -- Message d'erreur --
|
||||
// Support
|
||||
$GLOBALS['error_code']['POSIX_SUPPORT_01']= array (
|
||||
'msg' => _("POSIX Support : La constante %{const} n'est pas définie."),
|
||||
'level' => 'c'
|
||||
);
|
||||
|
||||
// Autres erreurs
|
||||
$GLOBALS['error_code']['POSIX_01']= array (
|
||||
'msg' => _("POSIX : L'attribut %{dependency} est introuvable. Impossible de générer l'attribut %{attr}."),
|
||||
'level' => 'c'
|
||||
);
|
||||
|
||||
/*
|
||||
* Fin des données de configuration
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Verification du support POSIX par ldapSaisie
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval boolean true si Samba est pleinement supporté, false sinon
|
||||
*/
|
||||
function LSaddon_posix_support() {
|
||||
|
||||
$retval=true;
|
||||
|
||||
$MUST_DEFINE_CONST= array(
|
||||
'LS_POSIX_UID_ATTR',
|
||||
'LS_POSIX_UIDNUMBER_ATTR',
|
||||
'LS_POSIX_GIDNUMBER_ATTR',
|
||||
'LS_POSIX_UIDNUMBER_MIN_VAL',
|
||||
'LS_POSIX_GIDNUMBER_MIN_VAL',
|
||||
'LS_POSIX_HOMEDIRECTORY'
|
||||
);
|
||||
|
||||
foreach($MUST_DEFINE_CONST as $const) {
|
||||
if ( constant($const) == '' ) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode('POSIX_SUPPORT_O1',$const);
|
||||
$retval=false;
|
||||
}
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generation de uidNumber
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $ldapObject L'objet ldap
|
||||
*
|
||||
* @retval integer uidNumber ou false si il y a un problème durant la génération
|
||||
*/
|
||||
function generate_uidNumber($ldapObject) {
|
||||
|
||||
$objects = $GLOBALS['LSldap'] -> search (LS_POSIX_UIDNUMBER_ATTR.'=*');
|
||||
$uidNumber = LS_POSIX_UIDNUMBER_MIN_VAL;
|
||||
|
||||
if (!is_array($objects))
|
||||
return;
|
||||
|
||||
foreach($objects as $object) {
|
||||
if($object['attrs'][LS_POSIX_UIDNUMBER_ATTR] > $uidNumber)
|
||||
$uidNumber = $object['attrs'][LS_POSIX_UIDNUMBER_ATTR];
|
||||
}
|
||||
|
||||
$uidNumber++;
|
||||
return $uidNumber;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Generation de gidNumber
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $ldapObject L'objet ldap
|
||||
*
|
||||
* @retval integer gidNumber ou false si il y a un problème durant la génération
|
||||
*/
|
||||
function generate_gidNumber($ldapObject) {
|
||||
|
||||
$objects = $GLOBALS['LSldap'] -> search (LS_POSIX_GIDNUMBER_ATTR.'=*');
|
||||
$gidNumber = LS_POSIX_GIDNUMBER_MIN_VAL;
|
||||
|
||||
if (!is_array($objects))
|
||||
return;
|
||||
|
||||
foreach($objects as $object) {
|
||||
if($object['attrs'][LS_POSIX_GIDNUMBER_ATTR] > $gidNumber)
|
||||
$gidNumber = $object['attrs'][LS_POSIX_GIDNUMBER_ATTR];
|
||||
}
|
||||
|
||||
$gidNumber++;
|
||||
return $gidNumber;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Generation de homeDirectory
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $ldapObject L'objet ldap
|
||||
*
|
||||
* @retval string homeDirectory ou false si il y a un problème durant la génération
|
||||
*/
|
||||
function generate_homeDirectory($ldapObject) {
|
||||
if ( get_class($ldapObject -> attrs[ LS_POSIX_UID_ATTR ]) != 'LSattribute' ) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode('POSIX_01',array('dependency' => 'uid', 'attr' => 'homeDirectory'));
|
||||
return;
|
||||
}
|
||||
|
||||
$uid = $ldapObject -> attrs[ LS_POSIX_UID_ATTR ] -> getValue();
|
||||
$home = LS_POSIX_HOMEDIRECTORY . $uid[0];
|
||||
return $home;
|
||||
|
||||
}
|
||||
|
||||
?>
|
221
trunk/includes/addons/LSaddons.samba.php
Normal file
221
trunk/includes/addons/LSaddons.samba.php
Normal file
|
@ -0,0 +1,221 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
* Données de configuration pour le support SAMBA
|
||||
*/
|
||||
|
||||
// SID du domaine Samba géré
|
||||
define('LS_SAMBA_DOMAIN_SID','S-1-5-21-2421470416-3566881284-3047381809');
|
||||
|
||||
// Nombre de base pour le calcul des sambaSID Utilisateur
|
||||
define('LS_SAMBA_SID_BASE_USER',1000);
|
||||
|
||||
// Nombre de base pour le calcul des sambaSID Groupe
|
||||
define('LS_SAMBA_SID_BASE_GROUP',1001);
|
||||
|
||||
/*
|
||||
* NB : C'est deux nombres doivent être pour l'un paire et pour l'autre impaire
|
||||
* pour conserver l'unicité des SID
|
||||
*/
|
||||
|
||||
// Nom de l'attribut LDAP uidNumber
|
||||
define('LS_SAMBA_UIDNUMBER_ATTR','uidNumber');
|
||||
|
||||
// Nom de l'attribut LDAP gidNumber
|
||||
define('LS_SAMBA_GIDNUMBER_ATTR','gidNumber');
|
||||
|
||||
// Nom de l'attribut LDAP userPassword
|
||||
define('LS_SAMBA_USERPASSWORD_ATTR','userPassword');
|
||||
|
||||
// Message d'erreur
|
||||
|
||||
$GLOBALS['error_code']['SAMBA_SUPPORT_01']= array (
|
||||
'msg' => _("SAMBA Support : la classe smHash ne peut pas être chargée."),
|
||||
'level' => 'c'
|
||||
);
|
||||
$GLOBALS['error_code']['SAMBA_SUPPORT_02']= array (
|
||||
'msg' => _("SAMBA Support : La constante %{const} n'est pas définie."),
|
||||
'level' => 'c'
|
||||
);
|
||||
|
||||
$GLOBALS['error_code']['SAMBA_SUPPORT_03']= array (
|
||||
'msg' => _("SAMBA Support : Les constantes LS_SAMBA_SID_BASE_USER et LS_SAMBA_SID_BASE_GROUP ne doivent pas avoir la même parité pour l'unicité des sambaSID."),
|
||||
'level' => 'c'
|
||||
);
|
||||
|
||||
|
||||
$GLOBALS['error_code']['SAMBA_01']= array (
|
||||
'msg' => _("SAMBA Support : L'attribut %{dependency} est introuvable. Impossible de générer l'attribut %{attr}."),
|
||||
'level' => 'c'
|
||||
);
|
||||
|
||||
/*
|
||||
* Fin des données de configuration
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Verification du support Samba par ldapSaisie
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval boolean true si Samba est pleinement supporté, false sinon
|
||||
*/
|
||||
function LSaddon_samba_support() {
|
||||
|
||||
$retval=true;
|
||||
|
||||
// Dependance de librairie
|
||||
if ( !class_exists('smbHash') ) {
|
||||
if ( ! @include_once(LS_LIB_DIR . 'class.smbHash.php') ) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode('SAMBA_SUPPORT_O1');
|
||||
$retval=false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$MUST_DEFINE_CONST= array(
|
||||
'LS_SAMBA_DOMAIN_SID',
|
||||
'LS_SAMBA_SID_BASE_USER',
|
||||
'LS_SAMBA_SID_BASE_GROUP',
|
||||
'LS_SAMBA_UIDNUMBER_ATTR',
|
||||
'LS_SAMBA_GIDNUMBER_ATTR',
|
||||
'LS_SAMBA_USERPASSWORD_ATTR'
|
||||
);
|
||||
|
||||
foreach($MUST_DEFINE_CONST as $const) {
|
||||
if ( constant($const) == '' ) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode('SAMBA_SUPPORT_O2',$const);
|
||||
$retval=false;
|
||||
}
|
||||
}
|
||||
|
||||
// Pour l'intégrité des SID
|
||||
if ( (LS_SAMBA_SID_BASE_USER % 2) == (LS_SAMBA_SID_BASE_GROUP % 2) ) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode('SAMBA_SUPPORT_O3');
|
||||
$retval=false;
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generation de sambaSID
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* Number = LS_SAMBA_UIDNUMBER_ATTR * 2 + LS_SAMBA_SID_BASE_USER
|
||||
* sambaSID = LS_SAMBA_DOMAIN_SID-Number
|
||||
*
|
||||
* @param[in] $ldapObject L'objet ldap
|
||||
*
|
||||
* @retval string SambaSID ou false si il y a un problème durant la génération
|
||||
*/
|
||||
function generate_sambaSID($ldapObject) {
|
||||
if ( get_class($ldapObject -> attrs[ LS_SAMBA_UIDNUMBER_ATTR ]) != 'LSattribute' ) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode('SAMBA_01',array('dependency' => LS_SAMBA_UIDNUMBER_ATTR, 'attr' => 'sambaSID'));
|
||||
return;
|
||||
}
|
||||
|
||||
$uidNumber = $ldapObject -> attrs[ LS_SAMBA_UIDNUMBER_ATTR ] -> getValue() * 2 + LS_SAMBA_SID_BASE_USER;
|
||||
$sambaSID = LS_SAMBA_DOMAIN_SID . '-' . $uidNumber;
|
||||
|
||||
return ($sambaSID);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generation de sambaPrimaryGroupSID
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* Number = LS_SAMBA_GIDNUMBER_ATTR * 2 + LS_SAMBA_SID_BASE_GROUP
|
||||
* sambaSID = LS_SAMBA_DOMAIN_SID-Number
|
||||
*
|
||||
* @param[in] $ldapObject L'objet ldap
|
||||
*
|
||||
* @retval string sambaPrimaryGroupSID ou false si il y a un problème durant la génération
|
||||
*/
|
||||
function generate_sambaPrimaryGroupSID($ldapObject) {
|
||||
if ( get_class($ldapObject -> attrs[ LS_SAMBA_GIDNUMBER_ATTR ]) != 'LSattribute' ) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode('SAMBA_02',array('dependency' => LS_SAMBA_GIDNUMBER_ATTR, 'attr' => 'sambaPrimaryGroupSID'));
|
||||
return;
|
||||
}
|
||||
|
||||
$gidNumber = $ldapObject -> attrs[ LS_SAMBA_GIDNUMBER_ATTR ] -> getValue() * 2 + LS_SAMBA_SID_BASE_GROUP;
|
||||
$sambaPrimaryGroupSID = LS_SAMBA_DOMAIN_SID . '-' . $gidNumber;
|
||||
|
||||
return ($sambaPrimaryGroupSID);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generation de sambaNTPassword
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $ldapObject L'objet ldap
|
||||
*
|
||||
* @retval string sambaNTPassword ou false si il y a un problème durant la génération
|
||||
*/
|
||||
function generate_sambaNTPassword($ldapObject) {
|
||||
if ( get_class($ldapObject -> attrs[ LS_SAMBA_USERPASSWORD_ATTR ]) != 'LSattribute' ) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode('SAMBA_03',array('dependency' => LS_SAMBA_USERPASSWORD_ATTR, 'attr' => 'sambaNTPassword'));
|
||||
return;
|
||||
}
|
||||
|
||||
$password = $ldapObject -> attrs[ LS_SAMBA_USERPASSWORD_ATTR ] -> ldap -> getClearPassword();
|
||||
$sambapassword = new smbHash;
|
||||
$sambaNTPassword = $sambapassword -> nthash($password);
|
||||
|
||||
if($sambaNTPassword == '') {
|
||||
return;
|
||||
}
|
||||
return $sambaNTPassword;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generation de sambaLMPassword
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $ldapObject L'objet ldap
|
||||
*
|
||||
* @retval string sambaLMPassword ou false si il y a un problème durant la génération
|
||||
*/
|
||||
function generate_sambaLMPassword($ldapObject) {
|
||||
if ( get_class($ldapObject -> attrs[ LS_SAMBA_USERPASSWORD_ATTR ]) != 'LSattribute' ) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode('SAMBA_04',array('dependency' => LS_SAMBA_USERPASSWORD_ATTR, 'attr' => 'sambaLMPassword'));
|
||||
return;
|
||||
}
|
||||
|
||||
$password = $ldapObject -> attrs[ LS_SAMBA_USERPASSWORD_ATTR ] -> ldap -> getClearPassword();
|
||||
$sambapassword = new smbHash;
|
||||
$sambaLMPassword = $sambapassword -> lmhash($password);
|
||||
|
||||
if($sambaLMPassword == '') {
|
||||
return;
|
||||
}
|
||||
return $sambaLMPassword;
|
||||
}
|
||||
|
||||
?>
|
|
@ -29,21 +29,58 @@ class LSattr_html {
|
|||
|
||||
var $name;
|
||||
var $config;
|
||||
|
||||
function LSattr_html ($name,$config) {
|
||||
var $attribute;
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
*
|
||||
* Cette methode construit l'objet et définis la configuration.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $name string Nom de l'attribut ldap
|
||||
* @param[in] $config array Configuration de l'objet
|
||||
* @param[in] &$attribute LSattribute L'objet LSattribut parent
|
||||
*
|
||||
* @retval boolean Retourne true.
|
||||
*/
|
||||
function LSattr_html ($name,$config,&$attribute) {
|
||||
$this -> name = $name;
|
||||
$this -> config = $config;
|
||||
$this -> attribute = $attribute;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le label de l'attribut
|
||||
*
|
||||
* Retourne le label de l'attribut ou son nom si aucun label n'est défini
|
||||
* dans la configuration.
|
||||
*
|
||||
* @retval string Le label de l'attribut.
|
||||
*/
|
||||
function getLabel() {
|
||||
return $this -> config['label'];
|
||||
if ( $this -> config['label'] != '' ) {
|
||||
return $this -> config['label'];
|
||||
}
|
||||
else {
|
||||
return $this -> name;
|
||||
}
|
||||
}
|
||||
|
||||
function addToForm (&$form,$idForm) {
|
||||
/**
|
||||
* Ajoute l'attribut au formualaire passer en paramètre
|
||||
*
|
||||
* @param[in] &$form LSform Le formulaire
|
||||
* @param[in] $idForm L'identifiant du formulaire
|
||||
* @param[in] $data Valeur du champs du formulaire
|
||||
*
|
||||
* @retval LSformElement L'element du formulaire ajouté
|
||||
*/
|
||||
function addToForm (&$form,$idForm,$data=NULL) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(101,$this -> name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
58
trunk/includes/class/class.LSattr_html_password.php
Normal file
58
trunk/includes/class/class.LSattr_html_password.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2007 Easter-eggs
|
||||
* http://ldapsaisie.labs.libre-entreprise.org
|
||||
*
|
||||
* Author: See AUTHORS file in top-level directory.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Type d'attribut HTML password
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSattr_html_password extends LSattr_html {
|
||||
|
||||
/**
|
||||
* Ajoute l'attribut au formualaire passer en paramètre
|
||||
*
|
||||
* @param[in] &$form LSform Le formulaire
|
||||
* @param[in] $idForm L'identifiant du formulaire
|
||||
* @param[in] $data Valeur du champs du formulaire
|
||||
*
|
||||
* @retval LSformElement L'element du formulaire ajouté
|
||||
*/
|
||||
function addToForm (&$form,$idForm,$data=NULL) {
|
||||
$element=$form -> addElement('password', $this -> name, $this -> config['label'], $this -> config);
|
||||
if(!$element) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(206,$this -> name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_array($data)) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(103,'password');
|
||||
return;
|
||||
}
|
||||
if ($data) {
|
||||
$element -> setValue($data);
|
||||
}
|
||||
return $element;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -26,9 +26,45 @@
|
|||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSattr_html_select_list extends LSattr_html{
|
||||
|
||||
function addToForm (&$form,$idForm) {
|
||||
return $form -> addElement('select', $this -> name, $this -> config['label'],$this -> getPossibleValues());
|
||||
|
||||
/**
|
||||
* Ajoute l'attribut au formualaire passer en paramètre
|
||||
*
|
||||
* @param[in] &$form LSform Le formulaire
|
||||
* @param[in] $idForm L'identifiant du formulaire
|
||||
* @param[in] $data Valeur du champs du formulaire
|
||||
*
|
||||
* @retval LSformElement L'element du formulaire ajouté
|
||||
*/
|
||||
function addToForm (&$form,$idForm,$data=NULL) {
|
||||
if (is_array($data)) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(103,'select_list');
|
||||
return;
|
||||
}
|
||||
$possible_values=$this -> getPossibleValues();
|
||||
$this -> config['text_possible_values'] = $possible_values;
|
||||
$element=$form -> addElement('select', $this -> name, $this -> config['label'],$this -> config);
|
||||
if(!$element) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(206,$this -> name);
|
||||
return;
|
||||
}
|
||||
if ($data) {
|
||||
$element -> setValue($data);
|
||||
}
|
||||
|
||||
// Mise en place de la regle de verification des donnees
|
||||
$regex_check_data='/';
|
||||
foreach ($possible_values as $val => $text) {
|
||||
if($regex_check_data=='/')
|
||||
$regex_check_data.='^'.preg_quote($val,'/').'$';
|
||||
else
|
||||
$regex_check_data.='|^'.preg_quote($val,'/').'$';
|
||||
}
|
||||
$regex_check_data.='/';
|
||||
debug($this -> name.' : < '.$regex_check_data." ><br/>",$GLOBALS['debug_stat']);
|
||||
$form -> addRule($this -> name, 'regex', array('msg'=> 'Valeur incorrect','params' => array('regex' => $regex_check_data)) );
|
||||
// On retourne un pointeur vers l'element ajouter
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,6 +105,8 @@ class LSattr_html_select_list extends LSattr_html{
|
|||
}
|
||||
}
|
||||
else {
|
||||
$val_name=$this->attribute->ldapObject->getFData($val_name);
|
||||
$val=$this->attribute->ldapObject->getFData($val);
|
||||
$retInfos[$val_name]=$val;
|
||||
}
|
||||
}
|
||||
|
@ -78,4 +116,4 @@ class LSattr_html_select_list extends LSattr_html{
|
|||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -26,11 +26,28 @@
|
|||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSattr_html_text extends LSattr_html {
|
||||
|
||||
function addToForm (&$form,$idForm) {
|
||||
return $form -> addElement('text', $this -> name, $this -> config['label']);
|
||||
|
||||
/**
|
||||
* Ajoute l'attribut au formualaire passer en paramètre
|
||||
*
|
||||
* @param[in] &$form LSform Le formulaire
|
||||
* @param[in] $idForm L'identifiant du formulaire
|
||||
* @param[in] $data Valeur du champs du formulaire
|
||||
*
|
||||
* @retval LSformElement L'element du formulaire ajouté
|
||||
*/
|
||||
function addToForm (&$form,$idForm,$data=NULL) {
|
||||
$element=$form -> addElement('text', $this -> name, $this -> config['label'],$this -> config);
|
||||
if(!$element) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(206,$this -> name);
|
||||
return;
|
||||
}
|
||||
if ($data) {
|
||||
$element -> setValue($data);
|
||||
}
|
||||
return $element;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
58
trunk/includes/class/class.LSattr_html_textarea.php
Normal file
58
trunk/includes/class/class.LSattr_html_textarea.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2007 Easter-eggs
|
||||
* http://ldapsaisie.labs.libre-entreprise.org
|
||||
*
|
||||
* Author: See AUTHORS file in top-level directory.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Type d'attribut HTML textarea
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSattr_html_textarea extends LSattr_html {
|
||||
|
||||
/**
|
||||
* Ajoute l'attribut au formualaire passer en paramètre
|
||||
*
|
||||
* @param[in] &$form LSform Le formulaire
|
||||
* @param[in] $idForm L'identifiant du formulaire
|
||||
* @param[in] $data Valeur du champs du formulaire
|
||||
*
|
||||
* @retval LSformElement L'element du formulaire ajouté
|
||||
*/
|
||||
function addToForm (&$form,$idForm,$data=NULL) {
|
||||
$element=$form -> addElement('textarea', $this -> name, $this -> config['label'], $this -> config);
|
||||
if(!$element) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(206,$this -> name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_array($data)) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(103,'textarea');
|
||||
return;
|
||||
}
|
||||
if ($data) {
|
||||
$element -> setValue($data);
|
||||
}
|
||||
return $element;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -29,21 +29,50 @@ class LSattr_ldap {
|
|||
|
||||
var $name;
|
||||
var $config;
|
||||
|
||||
function LSattr_ldap ($name,$config) {
|
||||
var $attribute;
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
*
|
||||
* Cette methode construit l'objet et définis la configuration.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $name string Nom de l'attribut ldap
|
||||
* @param[in] $config array Configuration de l'objet
|
||||
* @param[in] &$attribute LSattribute L'objet LSattribut parent
|
||||
*
|
||||
* @retval boolean Retourne true.
|
||||
*/
|
||||
function LSattr_ldap ($name,$config,&$attribute) {
|
||||
$this -> name = $name;
|
||||
$this -> config = $config;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retourne la valeur de l'attribut après traitement lié à son type ldap
|
||||
*
|
||||
* @param[in] $data mixed La valeur de l'attribut
|
||||
*
|
||||
* @retval mixed La valeur traitée de l'attribut
|
||||
*/
|
||||
function getUpdateData($data) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retourne la valeur d'affichage de l'attribut après traitement lié à son type ldap
|
||||
*
|
||||
* @param[in] $data mixed La valeur de l'attribut
|
||||
*
|
||||
* @retval mixed La valeur d'affichage de l'attribut
|
||||
*/
|
||||
|
||||
function getDisplayValue($data) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -21,12 +21,12 @@
|
|||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Type d'attribut Ldap numeric
|
||||
* Type d'attribut Ldap ascii
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSattr_ldap_ascii extends LSattr_ldap {
|
||||
//\\
|
||||
// \\
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
81
trunk/includes/class/class.LSattr_ldap_password.php
Normal file
81
trunk/includes/class/class.LSattr_ldap_password.php
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2007 Easter-eggs
|
||||
* http://ldapsaisie.labs.libre-entreprise.org
|
||||
*
|
||||
* Author: See AUTHORS file in top-level directory.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Type d'attribut Ldap password
|
||||
*
|
||||
*/
|
||||
class LSattr_ldap_password extends LSattr_ldap {
|
||||
|
||||
var $clearPassword = NULL;
|
||||
|
||||
/**
|
||||
* Retourne la valeur d'affichage de l'attribut après traitement lié à son type ldap
|
||||
*
|
||||
* @param[in] $data mixed La valeur de l'attribut
|
||||
*
|
||||
* @retval mixed La valeur d'affichage de l'attribut
|
||||
*/
|
||||
function getDisplayValue($data) {
|
||||
return '********';
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne la valeur de l'attribut après traitement lié à son type ldap
|
||||
*
|
||||
* @param[in] $data mixed La valeur de l'attribut
|
||||
*
|
||||
* @retval mixed La valeur traitée de l'attribut
|
||||
*/
|
||||
function getUpdateData($data) {
|
||||
$this -> clearPassord = $data[0];
|
||||
return '{CRYPT}'.crypt($data[0],'$1$'.$this -> getSalt().'$');
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne une salt (chaine de caractère aléatoire) de la longueur passée en paramètre
|
||||
*
|
||||
* @param[in] integer La longueur de la salt (par defaut : 8)
|
||||
*
|
||||
* @retval string La salt
|
||||
*/
|
||||
function getSalt($length=8) {
|
||||
$pattern = "1234567890abcdefghijklmnopqrstuvwxyz";
|
||||
$key = $pattern{rand(0,35)};
|
||||
for($i=1;$i<$length;$i++)
|
||||
{
|
||||
$key .= $pattern{rand(0,35)};
|
||||
}
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le mot de passe en texte clair
|
||||
*
|
||||
* @retval string Le mot de passe en texte clair
|
||||
*/
|
||||
function getClearPassword() {
|
||||
return $this -> clearPassword;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -31,11 +31,13 @@ class LSattribute {
|
|||
|
||||
var $name;
|
||||
var $config;
|
||||
var $ldapObject;
|
||||
var $ldap;
|
||||
var $html;
|
||||
var $data;
|
||||
var $updateData=false;
|
||||
var $is_validate=false;
|
||||
var $_finalUpdateData=false;
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
|
@ -48,20 +50,23 @@ class LSattribute {
|
|||
*
|
||||
* @param[in] $name string Nom de l'attribut ldap
|
||||
* @param[in] $config array Configuration de l'objet
|
||||
* @param[in] &$ldapObject LSldapObject L'objet ldap parent
|
||||
*
|
||||
* @retval boolean Retourne true si la création a réussi, false sinon.
|
||||
*/
|
||||
function LSattribute ($name,$config) {
|
||||
function LSattribute ($name,$config,&$ldapObject) {
|
||||
$this -> name = $name;
|
||||
$this -> config = $config;
|
||||
$this -> ldapObject = $ldapObject;
|
||||
|
||||
$html_type = "LSattr_html_".$config['html_type'];
|
||||
$ldap_type = "LSattr_ldap_".$config['ldap_type'];
|
||||
if((class_exists($html_type))&&(class_exists($ldap_type))) {
|
||||
$this -> html = new $html_type($name,$config);
|
||||
$this -> ldap = new $ldap_type($name,$config);
|
||||
$this -> html = new $html_type($name,$config,$this);
|
||||
$this -> ldap = new $ldap_type($name,$config,$this);
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(41,array('html'=>$config['html_type'],'ldap'=>$config['ldap_type']));
|
||||
$GLOBALS['LSerror'] -> addErrorCode(41,array('attr' => $name,'html'=>$config['html_type'],'ldap'=>$config['ldap_type']));
|
||||
return;
|
||||
}
|
||||
return true;
|
||||
|
@ -95,25 +100,36 @@ class LSattribute {
|
|||
}
|
||||
|
||||
/**
|
||||
* DEBIG : affiche la valeur de l'attribut
|
||||
* Redéfini la valeur de l'attribut
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval void
|
||||
* @retval boolean true
|
||||
*/
|
||||
function debug_printValue() {
|
||||
print $this -> data;
|
||||
function reloadData($attr_data) {
|
||||
$this -> data = $attr_data;
|
||||
$this -> updateData=false;
|
||||
$this -> is_validate=false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne la valeur de l'attribut
|
||||
*
|
||||
* Retourne la valeur nouvelle si elle existe, sinon la valeur passé.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval mixed La valeur de l'attribut
|
||||
*/
|
||||
function getValue() {
|
||||
return $this -> data;
|
||||
$updateData=$this -> getUpdateData();
|
||||
if (empty($updateData)) {
|
||||
return $this -> data;
|
||||
}
|
||||
else {
|
||||
return $updateData;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -160,23 +176,34 @@ class LSattribute {
|
|||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] object LSform Le formulaire dans lequel doit être ajouté l'attribut
|
||||
* @param[in] string L'identifiant du formulaire
|
||||
* @param[in] object $form Le formulaire dans lequel doit être ajouté l'attribut
|
||||
* @param[in] string $idForm L'identifiant du formulaire
|
||||
* @param[in] objet &$obj Objet utilisable pour la génération de la valeur de l'attribut
|
||||
*
|
||||
* @retval boolean true si l'ajout a fonctionner ou qu'il n'est pas nécessaire, false sinon
|
||||
*/
|
||||
function addToForm(&$form,$idForm) {
|
||||
function addToForm(&$form,$idForm,&$obj=NULL) {
|
||||
if(isset($this -> config['form'][$idForm])) {
|
||||
$element = $this -> html -> addToForm($form,$idForm);
|
||||
if($this -> config['required']==1)
|
||||
$form->addRule($this -> name, "Le champ '".$this -> config['label']."' est obligatoire.",'required', null, 'client');
|
||||
/// !!!!! A CHANGER !!!!!!! \\\\ => utiliser une fonction de traitement de donnée
|
||||
if($this -> data !='')
|
||||
$element -> setValue($this -> getFormVal());
|
||||
else if (isset($this -> config['default_value']))
|
||||
$element -> setValue($this -> config['default_value']);
|
||||
if($this -> config['form'][$idForm]==0)
|
||||
if($this -> data !='') {
|
||||
$data=$this -> getFormVal();
|
||||
}
|
||||
else if (isset($this -> config['default_value'])) {
|
||||
$data=$obj -> getFData($this -> config['default_value']);
|
||||
}
|
||||
|
||||
$element = $this -> html -> addToForm($form,$idForm,$data);
|
||||
if(!$element) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(206,$this -> name);
|
||||
}
|
||||
|
||||
if($this -> config['required']==1) {
|
||||
$form -> setRequired($this -> name);
|
||||
}
|
||||
|
||||
if($this -> config['form'][$idForm]==0) {
|
||||
$element -> freeze();
|
||||
}
|
||||
|
||||
if(isset($this -> config['check_data'])) {
|
||||
if(is_array($this -> config['check_data'])) {
|
||||
foreach ($this -> config['check_data'] as $rule => $rule_infos) {
|
||||
|
@ -185,10 +212,10 @@ class LSattribute {
|
|||
return;
|
||||
}
|
||||
if(!isset($rule_infos['msg']))
|
||||
$rule_infos['msg']='La valeur du champs '.$this -> config['label'].' est invalide.';
|
||||
$rule_infos['msg']=getFData(_('La valeur du champs %{label} est invalide.'),$this -> config['label']);
|
||||
if(!isset($rule_infos['param']))
|
||||
$rule_infos['param']=NULL;
|
||||
$form -> addRule($this -> name,$rule_infos['msg'],$rule,$rule_infos['param'],$GLOBALS['LSconfig']['check_data_place']);
|
||||
$form -> addRule($this -> name,$rule,array('msg' => $rule_infos['msg'], 'param' => $rule_infos['param']));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -199,6 +226,30 @@ class LSattribute {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rafraichis la valeur de l'attribut dans un formualaire
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] object &$form LSform Le formulaire dans lequel doit être ajouté l'attribut
|
||||
* @param[in] string $idForm L'identifiant du formulaire
|
||||
*
|
||||
* @retval boolean true si la valeur a été rafraichie ou que ce n'est pas nécessaire, false sinon
|
||||
*/
|
||||
function refreshForm(&$form,$idForm) {
|
||||
if(isset($this -> config['form'][$idForm])) {
|
||||
//~ 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 true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne la valeur a afficher dans le formulaire
|
||||
*
|
||||
|
@ -210,6 +261,15 @@ class LSattribute {
|
|||
return $this -> getDisplayValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Définis les données de mises à jour si un changement a eut lieu
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] string $data Les données de mise à jour.
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
function setUpdateData($data) {
|
||||
if($this -> getFormVal() != $data)
|
||||
$this -> updateData=$data;
|
||||
|
@ -223,7 +283,7 @@ class LSattribute {
|
|||
* @retval boolean true si l'attribut a été validé, false sinon
|
||||
*/
|
||||
function isValidate() {
|
||||
return ((!isset($this -> config['validation'])) || ($this -> is_validate));
|
||||
return $this -> is_validate;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -248,15 +308,64 @@ class LSattribute {
|
|||
return ($this -> updateData)?true:false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifie si l'attribut est obligatoire
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval boolean true si l'attribut est obligatoire, false sinon
|
||||
*/
|
||||
function isRequired() {
|
||||
return $this -> config['required'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifie si la valeur de l'attribut peut être générée
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval boolean true si la valeur de l'attribut peut être générée, false sinon
|
||||
*/
|
||||
function canBeGenerated() {
|
||||
return (function_exists($this -> config['generate_function']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Génere la valeur de l'attribut à partir de la fonction de génération
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval boolean true si la valeur à put être générée, false sinon
|
||||
*/
|
||||
function generateValue() {
|
||||
if ( ! $this -> canBeGenerated() ) {
|
||||
return;
|
||||
}
|
||||
$value=call_user_func($this -> config['generate_function'],$this -> ldapObject);
|
||||
if (!empty($value)) {
|
||||
//$this -> setValue($value); // pas nécéssaire ??
|
||||
$this -> updateData=$value;
|
||||
return true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne la valeur de l'attribut pour son enregistrement dans l'annuaire
|
||||
* si l'attribut à été modifié.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval mixed La valeur de l'attribut pour son enregistrement dans l'annuaire
|
||||
*/
|
||||
function getUpdateData() {
|
||||
$data=($this ->isUpdate())?$this -> updateData:$this -> data;
|
||||
if (!$this -> isUpdate()) {
|
||||
return;
|
||||
}
|
||||
if ( $this -> _finalUpdateData ) {
|
||||
return $this -> _finalUpdateData;
|
||||
}
|
||||
$data=$this -> updateData;
|
||||
if ($this -> config['onSave']) {
|
||||
if (is_array($this -> config['onSave'])) {
|
||||
$result=$data;
|
||||
|
@ -269,11 +378,10 @@ class LSattribute {
|
|||
return;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
else {
|
||||
if (function_exists($this -> config['onSave'])) {
|
||||
return $this -> config['onSave']($data);
|
||||
$result = $this -> config['onSave']($data);
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(45,array('attr' => $this->name,'func' => $this -> config['onSave']));
|
||||
|
@ -281,11 +389,15 @@ class LSattribute {
|
|||
}
|
||||
}
|
||||
}
|
||||
return $this -> ldap -> getUpdateData($data);
|
||||
else {
|
||||
$result = $this -> ldap -> getUpdateData($data);
|
||||
}
|
||||
$this -> _finalUpdateData = $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retourne la configuration de validation de l'annuaire
|
||||
* Retourne la configuration de validation de l'attribut
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
|
@ -294,7 +406,17 @@ class LSattribute {
|
|||
function getValidateConfig() {
|
||||
return $this -> config['validation'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retourne les attributs dépendants de celui-ci
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval array les noms des attributs dépendants
|
||||
*/
|
||||
function getDependsAttrs() {
|
||||
return $this -> config['dependAttrs'];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -37,10 +37,12 @@ class LSeegroup extends LSldapObject {
|
|||
* @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);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -37,10 +37,12 @@ class LSeepeople extends LSldapObject {
|
|||
* @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);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -79,7 +79,7 @@ class LSerror {
|
|||
*/
|
||||
function display() {
|
||||
if(!empty($this -> errors)) {
|
||||
print "<h3>Erreurs</h3>\n";
|
||||
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";
|
||||
}
|
||||
|
@ -87,4 +87,4 @@ class LSerror {
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -24,23 +24,29 @@
|
|||
/**
|
||||
* Formulaire pour LdapSaisie
|
||||
*
|
||||
* Cette classe gère les formulaires en se basant sur PEAR::HTML_QuickForm
|
||||
* Cette classe gère les formulaires
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
|
||||
class LSform {
|
||||
|
||||
var $quickform;
|
||||
var $ldapObject;
|
||||
var $idForm;
|
||||
var $can_validate=true;
|
||||
|
||||
/**
|
||||
var $can_validate = true;
|
||||
var $elements = array();
|
||||
var $_rules = array();
|
||||
|
||||
var $_postData = array();
|
||||
|
||||
var $_elementsErrors = array();
|
||||
var $_isValidate = false;
|
||||
|
||||
var $_notUpdate = array();
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
*
|
||||
* Cette methode construit l'objet et définis la configuration.
|
||||
* Elle lance la construction de l'objet HTML_QuickForm et définis les élements
|
||||
* de base à communiquer de page en page par le formulaire.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
|
@ -49,11 +55,10 @@ class LSform {
|
|||
*
|
||||
* @retval void
|
||||
*/
|
||||
function LSform ($idForm,$submit="Envoyer"){
|
||||
function LSform (&$ldapObject,$idForm,$submit="Envoyer"){
|
||||
$this -> idForm = $idForm;
|
||||
$this -> submit = $submit;
|
||||
$this -> quickform = new HTML_QuickForm($idForm);
|
||||
$this -> quickform -> addElement('hidden',"LSdata['idForm']",$idForm);
|
||||
$this -> ldapObject = $ldapObject;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -64,10 +69,26 @@ class LSform {
|
|||
* @retval void
|
||||
*/
|
||||
function display(){
|
||||
if($this -> can_validate) {
|
||||
$this -> quickform -> addElement('submit', null, $this -> submit);
|
||||
}
|
||||
$this -> quickform -> 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";
|
||||
foreach($this -> elements as $element) {
|
||||
$element -> display();
|
||||
if (isset($this -> _elementsErrors[$element -> name])) {
|
||||
foreach ($this -> _elementsErrors[$element -> name] as $error) {
|
||||
echo "<tr><td></td><td>$error</td></tr>";
|
||||
}
|
||||
}
|
||||
}
|
||||
if($this -> can_validate) {
|
||||
echo "\t<tr>\n";
|
||||
echo "\t\t<td> </td>\n";
|
||||
echo "\t\t<td><input type='submit' value=\"".$this -> submit."\"/></td>\n";
|
||||
echo "\t</tr>\n";
|
||||
}
|
||||
echo "</table>\n";
|
||||
echo "</form>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,14 +104,13 @@ class LSform {
|
|||
* @retval void
|
||||
*/
|
||||
function setElementError($attr,$msg=NULL) {
|
||||
//~ print 'erreur<br />';
|
||||
if($msg!='') {
|
||||
$msg_error=getFData($msg,$attr->getLabel());
|
||||
}
|
||||
else {
|
||||
$msg_error="Les données pour l'attribut ".$attr->getLabel()." ne sont pas valides.";
|
||||
$msg_error=getFData(_("Les données pour l'attribut %{label} ne sont pas valides."),$attr->getLabel());
|
||||
}
|
||||
$this -> quickform -> setElementError($attr->name,$msg_error);
|
||||
$this -> _elementsErrors[$attr->name][]=$msg_error;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,9 +121,241 @@ class LSform {
|
|||
* @retval boolean true si le formulaire a été validé et que les données ont été validées, false sinon
|
||||
*/
|
||||
function validate(){
|
||||
return (($this -> can_validate)&&($this -> quickform -> validate()));
|
||||
if(!$this -> can_validate)
|
||||
return;
|
||||
if ($this -> isSubmit()) {
|
||||
if (!$this -> getPostData()) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(201);
|
||||
return;
|
||||
}
|
||||
//Validation des données ici !!! ///
|
||||
if (!$this -> checkData()) {
|
||||
$this -> setValuesFromPostData();
|
||||
return;
|
||||
}
|
||||
debug("les données sont checkées");
|
||||
$this -> _isValidate = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Vérifier les données du formulaire à partir des régles définis sur les champs
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval boolean true si toutes la saisie est OK, false sinon
|
||||
*/
|
||||
function checkData() {
|
||||
$retval=true;
|
||||
foreach ($this -> _postData as $element => $values) {
|
||||
if(!is_array($values)) {
|
||||
$values=array($values);
|
||||
}
|
||||
if ($this -> elements[$element] -> isRequired()) {
|
||||
if (!$this -> checkRequired($values)) {
|
||||
$this -> setElementError($this -> elements[$element],_("Champ obligatoire"));
|
||||
$retval=false;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($values as $value) {
|
||||
if (empty($value)) {
|
||||
continue;
|
||||
}
|
||||
if (!is_array($this -> _rules[$element]))
|
||||
continue;
|
||||
foreach($this -> _rules[$element] as $rule) {
|
||||
if (! call_user_func(array( "LSformRule_".$rule['name'],'validate') , $value, $rule['options'])) {
|
||||
$retval=false;
|
||||
$this -> setElementError($this -> elements[$element],$rule['options']['msg']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifie si au moins une valeur est présente dans le tableau
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $data array tableau de valeurs
|
||||
*
|
||||
* @retval boolean true si au moins une valeur est présente, false sinon
|
||||
*/
|
||||
function checkRequired($data) {
|
||||
foreach($data as $val) {
|
||||
if (!empty($val))
|
||||
return true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifie si la saisie du formulaire est présente en POST
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval boolean true si la saisie du formulaire est présente en POST, false sinon
|
||||
*/
|
||||
function isSubmit() {
|
||||
if( (isset($_POST['validate']) && ($_POST['validate']=='LSform')) && (isset($_POST['idForm']) && ($_POST['idForm'] == $this -> idForm)) )
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère les valeurs postées dans le formulaire
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval boolean true si les valeurs ont bien été récupérées, false sinon.
|
||||
*/
|
||||
function getPostData() {
|
||||
foreach($this -> elements as $element_name => $element) {
|
||||
if( !($element -> getPostData($this -> _postData)) ) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(202,$element_name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ajoute un élément au formulaire
|
||||
*
|
||||
* Ajoute un élément au formulaire et définis les informations le concernant.
|
||||
*
|
||||
* @param[in] $type string Le type de l'élément
|
||||
* @param[in] $name string Le nom de l'élément
|
||||
* @param[in] $label string Le label de l'élément
|
||||
* @param[in] $param mixed Paramètres supplémentaires
|
||||
*
|
||||
* @retval LSformElement
|
||||
*/
|
||||
function addElement($type,$name,$label,$params=array()) {
|
||||
$elementType='LSformElement_'.$type;
|
||||
if (!class_exists($elementType)) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(205,array('type' => $type));
|
||||
return;
|
||||
}
|
||||
$element=$this -> elements[$name] = new $elementType($this,$name,$label,$params);
|
||||
if ($element) {
|
||||
return $element;
|
||||
}
|
||||
else {
|
||||
unset ($this -> elements[$name]);
|
||||
$GLOBALS['LSerror'] -> addErrorCode(206,array('element' => $name));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Ajoute une règle sur un élément du formulaire
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $element string Le nom de l'élément conserné
|
||||
* @param[in] $rule string Le nom de la règle à ajouter
|
||||
* @param[in] $options array Options (facultative)
|
||||
*
|
||||
* @retval boolean
|
||||
*/
|
||||
function addRule($element, $rule, $options=array()) {
|
||||
if ( isset($this ->elements[$element]) ) {
|
||||
if ($this -> isRuleRegistered($rule)) {
|
||||
$this -> _rules[$element][]=array(
|
||||
'name' => $rule,
|
||||
'options' => $options
|
||||
);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(43,array('attr' => $element,'rule'=>$rule));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(204,array('element' => $element));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Définis comme requis un élément
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $element string Le nom de l'élément conserné
|
||||
*
|
||||
* @retval boolean
|
||||
*/
|
||||
function setRequired($element) {
|
||||
if (isset( $this -> elements[$element] ) )
|
||||
return $this -> elements[$element] -> setRequired();
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Détermine la valider de la règle
|
||||
*
|
||||
* Devra déterminer si la règle passez en paramètre est correcte
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $element string Le nom de l'élément conserné
|
||||
*/
|
||||
function isRuleRegistered($rule) {
|
||||
return class_exists('LSformRule_'.$rule);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne les valeurs validés du formulaire
|
||||
*
|
||||
* @retval mixed Les valeurs validés du formulaire, ou false si elles ne le sont pas
|
||||
*/
|
||||
function exportValues() {
|
||||
if ($this -> _isValidate) {
|
||||
return $this -> _postData;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourn un élement du formulaire
|
||||
*
|
||||
* @param[in] string $element Nom de l'élement voulu
|
||||
*
|
||||
* @retval LSformElement L'élement du formulaire voulu
|
||||
*/
|
||||
function getElement($element) {
|
||||
return $this -> elements[$element];
|
||||
}
|
||||
|
||||
/**
|
||||
* Défini les valeurs des élements à partir des valeurs postées
|
||||
*
|
||||
* @retval boolean True si les valeurs ont été définies, false sinon.
|
||||
*/
|
||||
function setValuesFromPostData() {
|
||||
if (empty($this -> _postData)) {
|
||||
return;
|
||||
}
|
||||
foreach($this -> _postData as $element => $values) {
|
||||
$this -> elements[$element] -> setValue($values);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
211
trunk/includes/class/class.LSformElement.php
Normal file
211
trunk/includes/class/class.LSformElement.php
Normal file
|
@ -0,0 +1,211 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* Element d'un formulaire pour LdapSaisie
|
||||
*
|
||||
* Cette classe gère les éléments des formulaires.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
|
||||
class LSformElement {
|
||||
|
||||
var $name;
|
||||
var $label;
|
||||
var $params;
|
||||
var $values = array();
|
||||
var $_required = false;
|
||||
var $_freeze = false;
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
*
|
||||
* Cette methode construit l'objet et définis sa configuration de base.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] &$form [<b>required</b>] LSform L'objet LSform parent
|
||||
* @param[in] $name [<b>required</b>] string Le nom de référence de l'élément
|
||||
* @param[in] $label [<b>required</b>] string Le label de l'élément
|
||||
* @param[in] $params mixed Paramètres supplémentaires
|
||||
*
|
||||
* @retval true
|
||||
*/
|
||||
function LSformElement (&$form, $name, $label, $params){
|
||||
$this -> name = $name;
|
||||
$this -> label = $label;
|
||||
$this -> params = $params;
|
||||
$this -> form = $form;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Définis la valeur de l'élément
|
||||
*
|
||||
* Cette méthode définis la valeur de l'élément
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] [<b>required</b>] string or array La futur valeur de l'élément
|
||||
*
|
||||
* @retval boolean Retourne True
|
||||
*/
|
||||
function setValue($data) {
|
||||
if (!is_array($data)) {
|
||||
$data=array($data);
|
||||
}
|
||||
|
||||
$this -> values = $data;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajoute une valeur à l'élément
|
||||
*
|
||||
* Cette méthode ajoute une valeur à l'élément
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] [<b>required</b>] string or array La futur valeur de l'élément
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
function addValue($data) {
|
||||
if (is_array($data)) {
|
||||
$this -> values = array_merge($this -> values, $data);
|
||||
}
|
||||
else {
|
||||
$this -> values[] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test si l'élément est éditable
|
||||
*
|
||||
* Cette méthode test si l'élément est éditable
|
||||
*
|
||||
* @retval boolean
|
||||
*/
|
||||
function isFreeze(){
|
||||
return $this -> _freeze;
|
||||
}
|
||||
|
||||
/*
|
||||
* Freeze l'élément
|
||||
*
|
||||
* Rend l'élément non-editable
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
function freeze() {
|
||||
$this -> _freeze = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Défini la propriété required de l'élément.
|
||||
*
|
||||
* param[in] $isRequired boolean true si l'élément est requis, false sinon
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
function setRequired($isRequired=true) {
|
||||
$this -> _required = $isRequired;
|
||||
}
|
||||
|
||||
/*
|
||||
* Test si l'élément est requis
|
||||
*
|
||||
* Cette méthode test si l'élément est requis
|
||||
*
|
||||
* @retval boolean
|
||||
*/
|
||||
function isRequired(){
|
||||
return $this -> _required;
|
||||
}
|
||||
|
||||
/**
|
||||
* Affiche le label de l'élement
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
function displayLabel() {
|
||||
if ($this -> isRequired()) {
|
||||
$required=" <span class='required_elements'>*</span>";
|
||||
}
|
||||
else {
|
||||
$required="";
|
||||
}
|
||||
echo "\t\t<td>".$this -> getLabel()."$required</td>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Recupère la valeur de l'élement passée en POST
|
||||
*
|
||||
* Cette méthode vérifie la présence en POST de la valeur de l'élément et la récupère
|
||||
* pour la mettre dans le tableau passer en paramètre avec en clef le nom de l'élément
|
||||
*
|
||||
* @param[] array Pointeur sur le tableau qui recupèrera la valeur.
|
||||
*
|
||||
* @retval boolean true si la valeur est présente en POST, false sinon
|
||||
*/
|
||||
function getPostData(&$return) {
|
||||
if($this -> params['form'][$this -> form -> idForm] != 1) {
|
||||
return true;
|
||||
}
|
||||
if (isset($_POST[$this -> name])) {
|
||||
if(!is_array($_POST[$this -> name])) {
|
||||
$_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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le label de l'élement
|
||||
*
|
||||
* Retourne $this -> label, ou $this -> params['label'], ou $this -> name
|
||||
*
|
||||
* @retval string Le label de l'élément
|
||||
*/
|
||||
function getLabel() {
|
||||
if ($this -> label != "") {
|
||||
return $this -> label;
|
||||
}
|
||||
else if ($this -> params['label']) {
|
||||
return $this -> params['label'];
|
||||
}
|
||||
else {
|
||||
return $this -> name;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
109
trunk/includes/class/class.LSformElement_password.php
Normal file
109
trunk/includes/class/class.LSformElement_password.php
Normal file
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2007 Easter-eggs
|
||||
* http://ldapsaisie.labs.libre-entreprise.org
|
||||
*
|
||||
* Author: See AUTHORS file in top-level directory.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* Element password d'un formulaire pour LdapSaisie
|
||||
*
|
||||
* Cette classe définis les éléments password des formulaires.
|
||||
* Elle étant la classe basic LSformElement.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
|
||||
class LSformElement_password extends LSformElement {
|
||||
|
||||
/**
|
||||
* Recupère la valeur de l'élement passée en POST
|
||||
*
|
||||
* Cette méthode vérifie la présence en POST de la valeur de l'élément et la récupère
|
||||
* pour la mettre dans le tableau passer en paramètre avec en clef le nom de l'élément
|
||||
*
|
||||
* @param[] array Pointeur sur le tableau qui recupèrera la valeur.
|
||||
*
|
||||
* @retval boolean true si la valeur est présente en POST, false sinon
|
||||
*/
|
||||
function getPostData(&$return) {
|
||||
// Récupère la valeur dans _POST, et les vérifie avec la fonction générale
|
||||
$retval = parent :: getPostData($return);
|
||||
// Si une valeur est recupérée
|
||||
if ($retval) {
|
||||
$val = $this -> form -> ldapObject -> attrs[$this -> name] -> getValue();
|
||||
if( (empty($return[$this -> name][0]) ) && ( ! empty( $val ) ) ) {
|
||||
unset($return[$this -> name]);
|
||||
$this -> form -> _notUpdate[$this -> name] == true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/*
|
||||
* Affiche l'élément
|
||||
*
|
||||
* Cette méthode affiche l'élement
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
function display(){
|
||||
echo "\t<tr>\n";
|
||||
$this -> displayLabel();
|
||||
// value
|
||||
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";
|
||||
}
|
||||
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";
|
||||
}
|
||||
else {
|
||||
foreach ($this -> values as $value) {
|
||||
echo "\t\t\t\t<li>".$value."</li>\n";
|
||||
}
|
||||
}
|
||||
|
||||
echo "\t\t\t</ul>\n";
|
||||
echo "\t\t</td>\n";
|
||||
}
|
||||
echo "\t</tr>\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
80
trunk/includes/class/class.LSformElement_select.php
Normal file
80
trunk/includes/class/class.LSformElement_select.php
Normal file
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2007 Easter-eggs
|
||||
* http://ldapsaisie.labs.libre-entreprise.org
|
||||
*
|
||||
* Author: See AUTHORS file in top-level directory.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* Element select d'un formulaire pour LdapSaisie
|
||||
*
|
||||
* Cette classe définis les éléments select des formulaires.
|
||||
* Elle étant la classe basic LSformElement.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
|
||||
class LSformElement_select extends LSformElement {
|
||||
|
||||
/*
|
||||
* Affiche l'élément
|
||||
*
|
||||
* Cette méthode affiche l'élement
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
function display(){
|
||||
echo "\t<tr>\n";
|
||||
$this -> displayLabel();
|
||||
// value
|
||||
if (!$this -> isFreeze()) {
|
||||
echo "\t\t<td>\n";
|
||||
echo "\t\t\t<select name='".$this -> name."' multiple>\n";
|
||||
foreach ($this -> params['text_possible_values'] as $choice_value => $choice_text) {
|
||||
if (in_array($choice_value, $this -> values)) {
|
||||
$selected=' selected';
|
||||
}
|
||||
else {
|
||||
$selected='';
|
||||
}
|
||||
echo "\t\t\t\t<option value=\"".$choice_value."\"$selected>$choice_text</option>\n";
|
||||
}
|
||||
echo "\t\t\t</select>\n";
|
||||
echo "\t\t</td>\n";
|
||||
}
|
||||
else {
|
||||
echo "\t\t<td>\n";
|
||||
echo "\t\t\t<ul>\n";
|
||||
foreach ($params['possible_values'] as $choice_value => $choice_text) {
|
||||
if (in_array($choice_value, $this -> value)) {
|
||||
echo "<li><strong>$choice_text</strong></li>";
|
||||
}
|
||||
else {
|
||||
echo "<li>$choice_text</li>";
|
||||
}
|
||||
}
|
||||
echo "\t\t\t</ul>\n";
|
||||
echo "\t\t</td>\n";
|
||||
}
|
||||
echo "\t</tr>\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
81
trunk/includes/class/class.LSformElement_text.php
Normal file
81
trunk/includes/class/class.LSformElement_text.php
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2007 Easter-eggs
|
||||
* http://ldapsaisie.labs.libre-entreprise.org
|
||||
*
|
||||
* Author: See AUTHORS file in top-level directory.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* Element texte d'un formulaire pour LdapSaisie
|
||||
*
|
||||
* Cette classe définis les éléments textes des formulaires.
|
||||
* Elle étant la classe basic LSformElement.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
|
||||
class LSformElement_text extends LSformElement {
|
||||
|
||||
/*
|
||||
* Affiche l'élément
|
||||
*
|
||||
* Cette méthode affiche l'élement
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
function display(){
|
||||
echo "\t<tr>\n";
|
||||
$this -> displayLabel();
|
||||
// value
|
||||
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='text' name='".$this -> name."[]' \"></li>\n";
|
||||
}
|
||||
else {
|
||||
foreach ($this -> values as $value) {
|
||||
echo "\t\t\t\t<li><input type='text' name='".$this -> name."[]' value=\"".$value."\"></li>\n";
|
||||
}
|
||||
}
|
||||
echo "\t\t\t</ul>\n";
|
||||
echo "\t\t</td>\n";
|
||||
}
|
||||
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";
|
||||
}
|
||||
else {
|
||||
foreach ($this -> values as $value) {
|
||||
echo "\t\t\t\t<li>".$value."</li>\n";
|
||||
}
|
||||
}
|
||||
|
||||
echo "\t\t\t</ul>\n";
|
||||
echo "\t\t</td>\n";
|
||||
}
|
||||
echo "\t</tr>\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
79
trunk/includes/class/class.LSformElement_textarea.php
Normal file
79
trunk/includes/class/class.LSformElement_textarea.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* Element textarea d'un formulaire pour LdapSaisie
|
||||
*
|
||||
* Cette classe définis les éléments textarea des formulaires.
|
||||
* Elle étant la classe basic LSformElement.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
|
||||
class LSformElement_textarea extends LSformElement {
|
||||
|
||||
/*
|
||||
* Affiche l'élément
|
||||
*
|
||||
* Cette méthode affiche l'élement
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
function display(){
|
||||
echo "\t<tr>\n";
|
||||
$this -> displayLabel();
|
||||
// value
|
||||
if (!$this -> isFreeze()) {
|
||||
echo "\t\t<td>\n";
|
||||
|
||||
if (empty($this -> values)) {
|
||||
echo "\t\t\t<textarea name='".$this -> name."[]'></textarea>\n";
|
||||
}
|
||||
else {
|
||||
foreach($this -> values as $value) {
|
||||
echo "\t\t\t<textarea name='".$this -> name."[]'>".$value."</textarea>\n";
|
||||
}
|
||||
}
|
||||
|
||||
echo "\t\t</td>\n";
|
||||
}
|
||||
else {
|
||||
echo "\t\t<td>\n";
|
||||
|
||||
if (empty($this -> values)) {
|
||||
echo "\t\t\t\t<li>"._('Aucunes valeur definie')."</li>\n";
|
||||
}
|
||||
else {
|
||||
foreach ($this -> values as $value) {
|
||||
echo "\t\t\t\t<li>".$value."</li>\n";
|
||||
}
|
||||
}
|
||||
|
||||
echo "\t\t</td>\n";
|
||||
}
|
||||
echo "\t</tr>\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
52
trunk/includes/class/class.LSformRule.php
Normal file
52
trunk/includes/class/class.LSformRule.php
Normal file
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2007 Easter-eggs
|
||||
* http://ldapsaisie.labs.libre-entreprise.org
|
||||
*
|
||||
* Author: See AUTHORS file in top-level directory.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Base d'une règle de validation de données
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSformRule {
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>*
|
||||
*/
|
||||
function LSformRule () {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation de données
|
||||
*
|
||||
* @param mixed $value Données à valider
|
||||
* @param array $options Options de validation
|
||||
*
|
||||
* @return boolean True si les données sont valide, False sinon.
|
||||
*/
|
||||
function validate($value,$options=NULL) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
45
trunk/includes/class/class.LSformRule_alphanumeric.php
Normal file
45
trunk/includes/class/class.LSformRule_alphanumeric.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Règle de validation d'une valeur alpha-numérique.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSformRule_alphanumeric extends LSformRule {
|
||||
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $value Value à vérifier
|
||||
* @param array $options Options de validation (inutile ici)
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options=array()) {
|
||||
$regex = '/^[a-zA-Z0-9]+$/';
|
||||
return LSformRule_regex :: validate($value,$regex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
86
trunk/includes/class/class.LSformRule_compare.php
Normal file
86
trunk/includes/class/class.LSformRule_compare.php
Normal file
|
@ -0,0 +1,86 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Règle de validation par comparaison de valeurs.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSformRule_compare extends LSformRule {
|
||||
|
||||
/**
|
||||
* Retourne l'operateur de comparaison.
|
||||
*
|
||||
* @access private
|
||||
* @param string Nom de l'operateur
|
||||
*
|
||||
* @return string Operateur à utiliser
|
||||
*/
|
||||
function _findOperator($operator_name) {
|
||||
|
||||
$_operators = array(
|
||||
'eq' => '==',
|
||||
'neq' => '!=',
|
||||
'gt' => '>',
|
||||
'gte' => '>=',
|
||||
'lt' => '<',
|
||||
'lte' => '<='
|
||||
);
|
||||
|
||||
if (empty($operator_name)) {
|
||||
return '==';
|
||||
} elseif (isset($this->_operators[$operator_name])) {
|
||||
return $this->_operators[$operator_name];
|
||||
} elseif (in_array($operator_name, $this->_operators)) {
|
||||
return $operator_name;
|
||||
} else {
|
||||
return '==';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérification des valeurs.
|
||||
*
|
||||
* @param string $values Valeurs à vérifier
|
||||
* @param array $options Options de validation :
|
||||
* - Operateur : $options['params']['operator']
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($values,$options=array()) {
|
||||
if (!isset($options['params']['operator'])) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(303);
|
||||
return;
|
||||
}
|
||||
$operator = LSformRule_compare :: _findOperator($options['params']['operator']);
|
||||
if ('==' != $operator && '!=' != $operator) {
|
||||
$compareFn = create_function('$a, $b', 'return floatval($a) ' . $operator . ' floatval($b);');
|
||||
}
|
||||
else {
|
||||
$compareFn = create_function('$a, $b', 'return $a ' . $operator . ' $b;');
|
||||
}
|
||||
return $compareFn($values[0], $values[1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
58
trunk/includes/class/class.LSformRule_email.php
Normal file
58
trunk/includes/class/class.LSformRule_email.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Règle de validation d'un email.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSformRule_email extends LSformRule {
|
||||
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $value Valeur à vérifier
|
||||
* @param array $options Options de validation :
|
||||
* - Check domain : $option['params']['checkDomain']
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate($value,$option=array()) {
|
||||
$regex = '/^((\"[^\"\f\n\r\t\v\b]+\")|([\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+(\.[\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))$/';
|
||||
|
||||
if (!preg_match($regex, $value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($option['params']['checkDomain'] && function_exists('checkdnsrr')) {
|
||||
$tokens = explode('@', $email);
|
||||
if (!(checkdnsrr($tokens[1], 'MX') || checkdnsrr($tokens[1], 'A'))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
45
trunk/includes/class/class.LSformRule_lettersonly.php
Normal file
45
trunk/includes/class/class.LSformRule_lettersonly.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Règle de validation d'une valeur ne contenant que des lettres.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSformRule_lettersonly extends LSformRule {
|
||||
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $value Value à vérifier
|
||||
* @param array $options Options de validation (inutile ici)
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options=array()) {
|
||||
$regex = '/^[a-zA-Z]+$/';
|
||||
return LSformRule_regex :: validate($value,$regex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
49
trunk/includes/class/class.LSformRule_maxlength.php
Normal file
49
trunk/includes/class/class.LSformRule_maxlength.php
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2007 Easter-eggs
|
||||
* http://ldapsaisie.labs.libre-entreprise.org
|
||||
*
|
||||
* Author: See AUTHORS file in top-level directory.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Règle de validation : longueur maximale de la valeur.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSformRule_maxlength extends LSformRule {
|
||||
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $values Valeur à vérifier
|
||||
* @param array $options Options de validation :
|
||||
* - Longueur max : $options['params']['limit']
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options) {
|
||||
if(!isset($options['params']['limit'])) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(302);
|
||||
return;
|
||||
}
|
||||
return (strlen($value)<=$options['params']['limit']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
49
trunk/includes/class/class.LSformRule_minlength.php
Normal file
49
trunk/includes/class/class.LSformRule_minlength.php
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2007 Easter-eggs
|
||||
* http://ldapsaisie.labs.libre-entreprise.org
|
||||
*
|
||||
* Author: See AUTHORS file in top-level directory.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Règle de validation : longueur minimale de la valeur.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSformRule_minlength extends LSformRule {
|
||||
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $values Valeur à vérifier
|
||||
* @param array $options Options de validation :
|
||||
* - Longueur min : $options['params']['limit']
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options) {
|
||||
if(!isset($options['params']['limit'])) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(302);
|
||||
return;
|
||||
}
|
||||
return (strlen($value)>=$options['params']['limit']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
45
trunk/includes/class/class.LSformRule_nonzero.php
Normal file
45
trunk/includes/class/class.LSformRule_nonzero.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Règle de validation d'une valeur non nulle.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSformRule_nonzero extends LSformRule {
|
||||
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $values Valeur à vérifier
|
||||
* @param array $options Options de validation (inutile ici)
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options) {
|
||||
$regex = '/^-?[1-9][0-9]*/';
|
||||
return LSformRule_regex :: validate($value,$regex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
45
trunk/includes/class/class.LSformRule_nopunctuation.php
Normal file
45
trunk/includes/class/class.LSformRule_nopunctuation.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Règle de validation d'une chaine sans caractère de ponctuation.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSformRule_nopunctuation extends LSformRule {
|
||||
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $values Valeur à vérifier
|
||||
* @param array $options Options de validation (inutile ici)
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options=array()) {
|
||||
$regex = '/^[^().\/\*\^\?#!@$%+=,\"\'><~\[\]{}]+$/';
|
||||
return LSformRule_regex :: validate($value,$regex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
45
trunk/includes/class/class.LSformRule_numeric.php
Normal file
45
trunk/includes/class/class.LSformRule_numeric.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Règle de validation d'une valeur numérique.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSformRule_numeric extends LSformRule{
|
||||
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $values Valeur à vérifier
|
||||
* @param array $options Options de validation (inutile ici)
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options=array()) {
|
||||
$regex = '/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/';
|
||||
return LSformRule_regex :: validate($value,$regex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
51
trunk/includes/class/class.LSformRule_rangelength.php
Normal file
51
trunk/includes/class/class.LSformRule_rangelength.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Règle de validation : longueur maximale et minimale de la valeur.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSformRule_rangelength extends LSformRule {
|
||||
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $values Valeur à vérifier
|
||||
* @param array $options Options de validation :
|
||||
* - Longueur min : $options['params']['limits'][0]
|
||||
* - Longueur max : $options['params']['limits'][1]
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$options=array()) {
|
||||
if(!isset($options['params']['limits'])) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(302);
|
||||
return;
|
||||
}
|
||||
$len=strlen($value);
|
||||
return ($len >= $$options['params']['limits'][0] && $len <= $$options['params']['limits'][1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
61
trunk/includes/class/class.LSformRule_regex.php
Normal file
61
trunk/includes/class/class.LSformRule_regex.php
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Règle de validation d'expression régulière.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSformRule_regex extends LSformRule {
|
||||
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $values Valeur à vérifier
|
||||
* @param array $options Options de validation :
|
||||
* - Regex : $option['params']['regex'] ou $option
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate($value,$option) {
|
||||
if (is_array($option)) {
|
||||
if (isset($option['params']['regex'])) {
|
||||
$regex=$option['params']['regex'];
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(301);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$regex=$option;
|
||||
}
|
||||
debug("\n$value : $regex\n");
|
||||
if (!preg_match($regex, $value)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
44
trunk/includes/class/class.LSformRule_required.php
Normal file
44
trunk/includes/class/class.LSformRule_required.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Règle de validation de données requises
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSformRule_required extends LSformRule {
|
||||
|
||||
/**
|
||||
* Vérification de la valeur.
|
||||
*
|
||||
* @param string $value Value à vérifier
|
||||
* @param array $options Options de validation (inutile ici)
|
||||
*
|
||||
* @return boolean true si la valeur est valide, false sinon
|
||||
*/
|
||||
function validate ($value,$option=NULL) {
|
||||
return ((string)$value != '');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -64,6 +64,7 @@ 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;
|
||||
}
|
||||
|
@ -102,7 +103,7 @@ class LSldap {
|
|||
* - ['attrs'] : tableau associatif contenant les attributs (clé)
|
||||
* et leur valeur (valeur).
|
||||
*/
|
||||
function search ($filter,$basedn=NULL,$params = array() ) {
|
||||
function search ($filter,$basedn=NULL,$params = array()) {
|
||||
$ret = $this -> cnx -> search($basedn,$filter,$params);
|
||||
if (Net_LDAP::isError($ret)) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(2,$ret -> getMessage());
|
||||
|
@ -166,6 +167,69 @@ class LSldap {
|
|||
$return=$this -> search($infos[0],$basedn);
|
||||
return $return[0]['attrs'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne une entrée existante ou nouvelle
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $object_type string Type de l'objet Ldap
|
||||
* @param[in] $dn string DN de l'entré Ldap
|
||||
*
|
||||
* @retval ldapentry Un objet ldapentry (PEAR::Net_LDAP)
|
||||
*/
|
||||
function getEntry($object_type,$dn) {
|
||||
if(isset($GLOBALS['LSobjects'][$object_type])){
|
||||
$obj_conf=$GLOBALS['LSobjects'][$object_type];
|
||||
$entry = $this -> cnx -> getEntry($dn);
|
||||
if (Net_Ldap::isError($entry)) {
|
||||
$newentry = new Net_Ldap_Entry(&$this -> cnx);
|
||||
$newentry -> dn($dn);
|
||||
$newentry -> add(array('objectclass' => $obj_conf['objectclass']));
|
||||
foreach($obj_conf['attrs'] as $attr_name => $attr_conf) {
|
||||
$newentry->add(array($attr_name => $attr_conf['default_value']));
|
||||
}
|
||||
return $newentry;
|
||||
}
|
||||
else {
|
||||
return $entry;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(3);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Met à jour une entrée dans l'annuaire
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $object_type string Type de l'objet Ldap
|
||||
* @param[in] $dn string DN de l'entré Ldap
|
||||
* @param[in] $change array Tableau des modifications à apporter
|
||||
*
|
||||
* @retval boolean true si l'objet a bien été mis à jour, false sinon
|
||||
*/
|
||||
function update($object_type,$dn,$change) {
|
||||
debug($change);
|
||||
if($entry=$this -> getEntry($object_type,$dn)) {
|
||||
$entry -> replace($change);
|
||||
$ret = $entry -> update();
|
||||
if (Net_Ldap::isError($ret)) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(5,$dn);
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(4);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -36,6 +36,7 @@ class LSldapObject {
|
|||
var $forms;
|
||||
var $dn=false;
|
||||
var $other_values=array();
|
||||
var $submitError=true;
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
|
@ -50,10 +51,10 @@ 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') {
|
||||
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 {
|
||||
|
@ -62,8 +63,9 @@ class LSldapObject {
|
|||
}
|
||||
}
|
||||
foreach($this -> config['attrs'] as $attr_name => $attr_config) {
|
||||
if(!$this -> attrs[$attr_name]=new LSattribute($attr_name,$attr_config))
|
||||
if(!$this -> attrs[$attr_name]=new LSattribute($attr_name,$attr_config,$this)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -90,6 +92,22 @@ class LSldapObject {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recharge les données de l'objet
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval boolean true si la rechargement a réussi, false sinon.
|
||||
*/
|
||||
function reloadData() {
|
||||
$data = $GLOBALS['LSldap'] -> getAttrs($this -> dn);
|
||||
foreach($this -> attrs as $attr_name => $attr) {
|
||||
if(!$this -> attrs[$attr_name] -> reloadData($data[$attr_name]))
|
||||
return;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le format d'affichage de l'objet
|
||||
*
|
||||
|
@ -137,21 +155,6 @@ class LSldapObject {
|
|||
return $format;
|
||||
}
|
||||
|
||||
/**
|
||||
* DEBUG : Affiche le nom et la valeur de chaque attribut
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
function debug_printAttrsValues() {
|
||||
foreach($this -> attrs as $attr_name => $attr) {
|
||||
print $attr_name.' : ';
|
||||
$attr -> debug_printValue();
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construit un formulaire de l'objet
|
||||
*
|
||||
|
@ -159,22 +162,44 @@ class LSldapObject {
|
|||
* et de chaque attribut.
|
||||
*
|
||||
* @param[in] $idForm [<b>required</b>] Identifiant du formulaire a créer
|
||||
* @param[in] $config Configuration spécifique pour le formulaire
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval LSform Le formulaire crée
|
||||
*/
|
||||
function getForm($idForm,$config=array()) {
|
||||
$LSform = new LSform($idForm);
|
||||
$LSform = new LSform($this,$idForm);
|
||||
$this -> forms[$idForm] = array($LSform,$config);
|
||||
foreach($this -> attrs as $attr_name => $attr) {
|
||||
if(!$this -> attrs[$attr_name] -> addToForm($LSform -> quickform,$idForm)) {
|
||||
if(!$this -> attrs[$attr_name] -> addToForm($LSform,$idForm,$this)) {
|
||||
$LSform -> can_validate = false;
|
||||
}
|
||||
}
|
||||
return $LSform;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rafraichis le formulaire de l'objet
|
||||
*
|
||||
* Cette méthode recharge les données d'un formulaire LSform.
|
||||
*
|
||||
* @param[in] $idForm [<b>required</b>] Identifiant du formulaire a créer
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval boolean true sile formulaire a été rafraichis, false sinon
|
||||
*/
|
||||
function refreshForm($idForm) {
|
||||
$LSform = $this -> forms[$idForm][0];
|
||||
foreach($this -> attrs as $attr_name => $attr) {
|
||||
if(!$this -> attrs[$attr_name] -> refreshForm($LSform,$idForm)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Met à jour les données de l'objet et de l'entré de l'annuaire
|
||||
*
|
||||
|
@ -211,13 +236,14 @@ class LSldapObject {
|
|||
$GLOBALS['LSerror'] -> stop();
|
||||
}
|
||||
}
|
||||
$new_data = $LSform -> quickform -> exportValues();
|
||||
$new_data = $LSform -> exportValues();
|
||||
foreach($new_data as $attr_name => $attr_val) {
|
||||
if(isset($this -> attrs[$attr_name])) {
|
||||
$this -> attrs[$attr_name] -> setUpdateData($attr_val);
|
||||
}
|
||||
}
|
||||
if($this -> validateAttrsData($idForm)) {
|
||||
debug("les données sont validées");
|
||||
if(isset($this -> config['before_save'])) {
|
||||
if(function_exists($this -> config['before_save'])) {
|
||||
if(!$this -> config['before_save']($this)) {
|
||||
|
@ -230,8 +256,13 @@ class LSldapObject {
|
|||
$GLOBALS['LSerror'] -> stop();
|
||||
}
|
||||
}
|
||||
$this -> submitChange($idForm);
|
||||
if(isset($this -> config['after_save'])) {
|
||||
if ($this -> submitChange($idForm)) {
|
||||
debug('Les modifications sont submitées');
|
||||
$this -> submitError = false;
|
||||
$this -> reloadData();
|
||||
$this -> refreshForm($idForm);
|
||||
}
|
||||
if((isset($this -> config['after_save']))&&(!$this -> submitError)) {
|
||||
if(function_exists($this -> config['after_save'])) {
|
||||
if(!$this -> config['after_save']($this)) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(30,$this -> config['after_save']);
|
||||
|
@ -256,76 +287,145 @@ class LSldapObject {
|
|||
function validateAttrsData($idForm) {
|
||||
$LSform=$this -> forms[$idForm][0];
|
||||
foreach($this -> attrs as $attr) {
|
||||
if(($attr -> isUpdate())&&(!$attr -> isValidate())) {
|
||||
//~ echo 'NAME : '.$attr -> name.' Val : '.$attr -> getUpdateData();
|
||||
$vconfig=$attr -> getValidateConfig();
|
||||
if(is_array($vconfig)) {
|
||||
foreach($vconfig as $test) {
|
||||
$data=$attr -> getUpdateData();
|
||||
if(!is_array($data))
|
||||
$data=array($data);
|
||||
foreach($data as $val) {
|
||||
// validation par check LDAP
|
||||
if((isset($test['filter'])||isset($test['basedn']))&&(isset($test['result']))) {
|
||||
$sparams=(isset($test['scope']))?array('scope' => $test['scope']):array();
|
||||
$this -> other_values['val']=$val;
|
||||
$sfilter_user=(isset($test['basedn']))?getFData($test['filter'],$this,'getValue'):NULL;
|
||||
//~ echo $sfilter_user;
|
||||
if(isset($test['object_type'])) {
|
||||
$test_obj = new $test['object_type']('auto');
|
||||
$sfilter=$test_obj->getObjectFilter();
|
||||
$sfilter='(&'.$sfilter;
|
||||
if($sfilter_user[0]=='(')
|
||||
$sfilter=$sfilter.$sfilter_user.')';
|
||||
else
|
||||
$sfilter=$sfilter.'('.$sfilter_user.'))';
|
||||
}
|
||||
else {
|
||||
$sfilter=$sfilter_user;
|
||||
}
|
||||
$sbasedn=(isset($test['basedn']))?getFData($test['basedn'],$this,'getValue'):NULL;
|
||||
$ret=$GLOBALS['LSldap'] -> getNumberResult ($sfilter,$sbasedn,$sparams);
|
||||
//~ echo 'Basedn : "'.$sbasedn.'" Filter : "'.$sfilter.'" NAME : '.$attr -> name.' Nb : '.$ret."<br />\n";
|
||||
if($test['result']==0) {
|
||||
if($ret!=0) {
|
||||
$LSform -> setElementError($attr,$test['msg']);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if($ret<=0) {
|
||||
$LSform -> setElementError($attr,$msg_error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Validation par fonction externe
|
||||
else if(isset($test['function'])) {
|
||||
if (function_exists($test['function'])) {
|
||||
if(!$test['function']($this)) {
|
||||
$LSform -> setElementError($attr,$msg_error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(24,array('attr' => $attr->name,'obj' => $this->type_name,'func' => $test['function']));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(25,array('attr' => $attr->name,'obj' => $this->type_name));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$attr -> validate();
|
||||
}
|
||||
}
|
||||
unset($this -> other_values['val']);
|
||||
if (!$attr -> isValidate()) {
|
||||
if($attr -> isUpdate()) {
|
||||
if (!$this -> validateAttrData($LSform, $attr)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if( ($attr -> getValue() == '') && ($attr -> isRequired()) ) {
|
||||
if ( $attr -> canBeGenerated()) {
|
||||
if ($attr -> generateValue()) {
|
||||
if (!$this -> validateAttrData($LSform, $attr)) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(48,$attr -> getLabel());
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(47,$attr -> getLabel());
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(46,$attr -> getLabel());
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Valide les données d'un attribut
|
||||
*
|
||||
* @param[in] $LSForm Formulaire d'origine
|
||||
* @param[in] &$attr Attribut à valider
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval boolean true si les données sont valides, false sinon
|
||||
*/
|
||||
function validateAttrData(&$LSform,&$attr) {
|
||||
$vconfig=$attr -> getValidateConfig();
|
||||
|
||||
$data=$attr -> getUpdateData();
|
||||
if(!is_array($data)) {
|
||||
$data=array($data);
|
||||
}
|
||||
|
||||
// Validation des valeurs de l'attribut
|
||||
if(is_array($vconfig)) {
|
||||
foreach($vconfig as $test) {
|
||||
// Définition du message d'erreur
|
||||
if (!empty($test['msg'])) {
|
||||
$msg_error=getFData($test['msg'],$this,'getValue');
|
||||
}
|
||||
else {
|
||||
$msg_error=getFData(_("L'attribut %{attr} n'est pas valide."),$attr -> getLabel());
|
||||
}
|
||||
foreach($data as $val) {
|
||||
// validation par check LDAP
|
||||
if((isset($test['filter'])||isset($test['basedn']))&&(isset($test['result']))) {
|
||||
$sparams=(isset($test['scope']))?array('scope' => $test['scope']):array();
|
||||
$this -> other_values['val']=$val;
|
||||
$sfilter_user=(isset($test['basedn']))?getFData($test['filter'],$this,'getValue'):NULL;
|
||||
if(isset($test['object_type'])) {
|
||||
$test_obj = new $test['object_type']('auto');
|
||||
$sfilter=$test_obj->getObjectFilter();
|
||||
$sfilter='(&'.$sfilter;
|
||||
if($sfilter_user[0]=='(') {
|
||||
$sfilter=$sfilter.$sfilter_user.')';
|
||||
}
|
||||
else {
|
||||
$sfilter=$sfilter.'('.$sfilter_user.'))';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$sfilter=$sfilter_user;
|
||||
}
|
||||
$sbasedn=(isset($test['basedn']))?getFData($test['basedn'],$this,'getValue'):NULL;
|
||||
$ret=$GLOBALS['LSldap'] -> getNumberResult ($sfilter,$sbasedn,$sparams);
|
||||
if($test['result']==0) {
|
||||
if($ret!=0) {
|
||||
$LSform -> setElementError($attr,$msg_error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if($ret<=0) {
|
||||
$LSform -> setElementError($attr,$msg_error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Validation par fonction externe
|
||||
else if(isset($test['function'])) {
|
||||
if (function_exists($test['function'])) {
|
||||
if(!$test['function']($this)) {
|
||||
$LSform -> setElementError($attr,$msg_error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(24,array('attr' => $attr->name,'obj' => $this->type_name,'func' => $test['function']));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(25,array('attr' => $attr->name,'obj' => $this->type_name));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Génération des valeurs des attributs dépendants
|
||||
$dependsAttrs=$attr->getDependsAttrs();
|
||||
if (!empty($dependsAttrs)) {
|
||||
foreach($dependsAttrs as $dependAttr) {
|
||||
if(!isset($this -> attrs[$dependAttr])){
|
||||
$GLOBALS['LSerror'] -> addErrorCode(34,array('attr_depend' => $dependAttr, 'attr' => $attr -> getLabel()));
|
||||
continue;
|
||||
}
|
||||
if($this -> attrs[$dependAttr] -> canBeGenerated()) {
|
||||
if (!$this -> attrs[$dependAttr] -> generateValue()) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(47,$this -> attrs[$dependAttr] -> getLabel());
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(46,$this -> attrs[$dependAttr] -> getLabel());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$attr -> validate();
|
||||
unset($this -> other_values['val']);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Met à jour les données modifiés dans l'annuaire
|
||||
*
|
||||
|
@ -336,13 +436,22 @@ class LSldapObject {
|
|||
* @retval boolean true si la mise à jour a réussi, false sinon
|
||||
*/
|
||||
function submitChange($idForm) {
|
||||
$submit_data=array();
|
||||
$submitData=array();
|
||||
foreach($this -> attrs as $attr) {
|
||||
if(($attr -> isUpdate())&&($attr -> isValidate())) {
|
||||
$submit_data[$attr -> name] = $attr -> getUpdateData();
|
||||
$submitData[$attr -> name] = $attr -> getUpdateData();
|
||||
}
|
||||
}
|
||||
if(!empty($submitData)) {
|
||||
$dn=$this -> getDn();
|
||||
if($dn) {
|
||||
return $GLOBALS['LSldap'] -> update($this -> type_name,$dn, $submitData);
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(33);
|
||||
return;
|
||||
}
|
||||
}
|
||||
print_r($submit_data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -555,22 +664,15 @@ class LSldapObject {
|
|||
}
|
||||
|
||||
// Vérification de la compatibilité du basedn de la recherche et du basedn générale
|
||||
//~ if ($this -> isCompatibleDNs($filter[$i]['basedn'],$basedn)) {
|
||||
//~ $sbasedn=$this -> sumDn($filter[$i]['basedn'],$basedn);
|
||||
//~ }
|
||||
// Finalisation du filtre
|
||||
$sfilter_for.=$sfilter_end;
|
||||
|
||||
//~ print 'filter1 : '.$sfilter_for." | basedn : ".$sbasedn."\n";
|
||||
|
||||
// Execution de la recherche
|
||||
$ret=$GLOBALS['LSldap'] -> search ($sfilter_for,$sbasedn,$sparams);
|
||||
|
||||
//~ print('Nb resultat : '.count($ret));
|
||||
|
||||
// Si il y un retour
|
||||
if(isset($ret[0])) {
|
||||
//~ print_r($ret);
|
||||
// si il ya une suite (recherche intermédiaire)
|
||||
if($filter[$i]['attr']){
|
||||
for($iii=0;$iii<count($ret);$iii++) {
|
||||
|
@ -628,14 +730,9 @@ class LSldapObject {
|
|||
// fermeture du filtre
|
||||
$sfilter.=$sfilter_end;
|
||||
|
||||
//~ print 'filter2 : '.$sfilter."\n";
|
||||
//~ print_r($sparams);
|
||||
|
||||
// Lancement de la recherche
|
||||
$ret=$GLOBALS['LSldap'] -> search ($sfilter,$sbasedn,$sparams);
|
||||
|
||||
//~ print('Nb resultat : '.count($ret));
|
||||
|
||||
//Si filtre multiple => on recupère une liste d'attributs
|
||||
if(isset($filter[$i]['attr'])) {
|
||||
for($ii=0;$ii<count($ret);$ii++) {
|
||||
|
@ -670,18 +767,15 @@ class LSldapObject {
|
|||
break;
|
||||
}
|
||||
}
|
||||
//~ print_r($attrs);
|
||||
}
|
||||
|
||||
// Création d'un tableau d'objet correspondant au valeur retourné
|
||||
for($i=0;$i<count($ret);$i++) {
|
||||
$retInfos[$i] = new $this -> type_name($this -> config);
|
||||
$retInfos[$i] -> loadData($ret[$i]);
|
||||
//~ echo $ret[$i]['dn']."\n";
|
||||
}
|
||||
|
||||
return $retInfos;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -697,7 +791,7 @@ class LSldapObject {
|
|||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $val string nom de la valeur demandée
|
||||
* @param[in] $val string Le nom de la valeur demandée
|
||||
*
|
||||
* @retval mixed la valeur demandé ou ' ' si celle-ci est inconnue.
|
||||
*/
|
||||
|
@ -719,6 +813,40 @@ class LSldapObject {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le DN de l'objet
|
||||
*
|
||||
* Cette methode retourne le DN de l'objet. Si celui-ci n'existe pas, il le construit à partir de la
|
||||
* configuration de l'objet et la valeur de son attribut rdn.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval string Le DN de l'objet
|
||||
*/
|
||||
function getDn() {
|
||||
if($this -> dn) {
|
||||
return $this -> dn;
|
||||
}
|
||||
else {
|
||||
$rdn_attr=$this -> config['rdn'];
|
||||
if( (isset($this -> config['rdn'])) && (isset($this -> attrs[$rdn_attr])) && (isset($this -> config['container_dn'])) && (isset($GLOBALS['LSsession']['topDn'])) ) {
|
||||
debug('RDN : '.$rdn_attr);
|
||||
$rdn_val=$this -> attrs[$rdn_attr] -> getUpdateData();
|
||||
if (!empty($rdn_val)) {
|
||||
return $rdn_attr.'='.$rdn_val[0].','.$this -> config['container_dn'].','.$GLOBALS['LSsession']['topDn'];
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(32,$this -> config['rdn']);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(31,$this -> type_name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -38,40 +38,50 @@
|
|||
* @retval string La chaine formatée
|
||||
*/
|
||||
function getFData($format,$data,$meth=NULL) {
|
||||
if(is_array($data)) {
|
||||
if ($meth==NULL) {
|
||||
while (ereg("%{([A-Za-z0-9]+)}",$format,$ch)) {
|
||||
$format=ereg_replace($ch[0],$data[$ch[1]],$format);
|
||||
$unique=false;
|
||||
if(!is_array($format)) {
|
||||
$format=array($format);
|
||||
$unique=true;
|
||||
}
|
||||
for($i=0;$i<count($format);$i++) {
|
||||
if(is_array($data)) {
|
||||
if ($meth==NULL) {
|
||||
while (ereg("%{([A-Za-z0-9]+)}",$format[$i],$ch)) {
|
||||
$format[$i]=ereg_replace($ch[0],$data[$ch[1]],$format[$i]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
while (ereg("%{([A-Za-z0-9]+)}",$format[$i],$ch)) {
|
||||
if (method_exists($data[$ch[1]],$meth)) {
|
||||
$format[$i]=ereg_replace($ch[0],$data[$ch[1]] -> $meth(),$format[$i]);
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(901,array('meth' => $meth,'obj' => $ch[1]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
while (ereg("%{([A-Za-z0-9]+)}",$format,$ch)) {
|
||||
if (method_exists($data[$ch[1]],$meth)) {
|
||||
$format=ereg_replace($ch[0],$data[$ch[1]] -> $meth(),$format);
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(901,array('meth' => $meth,'obj' => $ch[1]));
|
||||
break;
|
||||
if ($meth==NULL) {
|
||||
while (ereg("%{([A-Za-z0-9]+)}",$format[$i],$ch))
|
||||
$format[$i]=ereg_replace($ch[0],$data,$format[$i]);
|
||||
}
|
||||
else {
|
||||
while (ereg("%{([A-Za-z0-9]+)}",$format[$i],$ch)) {
|
||||
if (method_exists($data,$meth)) {
|
||||
$format[$i]=ereg_replace($ch[0],$data -> $meth($ch[1]),$format[$i]);
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(901,array('meth' => $meth,'obj' => get_class($data)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($meth==NULL) {
|
||||
while (ereg("%{([A-Za-z0-9]+)}",$format,$ch))
|
||||
$format=ereg_replace($ch[0],$data,$format);
|
||||
}
|
||||
else {
|
||||
while (ereg("%{([A-Za-z0-9]+)}",$format,$ch)) {
|
||||
if (method_exists($data,$meth)) {
|
||||
$format=ereg_replace($ch[0],$data -> $meth($ch[1]),$format);
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(901,array('meth' => $meth,'obj' => get_class($data)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($unique) {
|
||||
return $format[0];
|
||||
}
|
||||
return $format;
|
||||
}
|
||||
|
@ -85,4 +95,22 @@ function return_data($data) {
|
|||
return $data;
|
||||
}
|
||||
|
||||
?>
|
||||
function debug($data,$get=true) {
|
||||
if ($get) {
|
||||
if (is_array($data)) {
|
||||
$GLOBALS['LSdebug'][]=$data;
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSdebug'][]="[$data]";
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function debug_print() {
|
||||
echo "<fieldset><legend>Debug</legend><pre>";
|
||||
print_r( $GLOBALS['LSdebug']);
|
||||
echo "</pre></fieldset>";
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
541
trunk/includes/libs/class.smbHash.php
Normal file
541
trunk/includes/libs/class.smbHash.php
Normal file
|
@ -0,0 +1,541 @@
|
|||
<?php
|
||||
/*
|
||||
|
||||
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
|
||||
Copyright (C) 2004 Roland Gruber
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
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
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides functions to calculate Samba NT and LM hashes.
|
||||
*
|
||||
* The code is a conversion from createntlm.pl (Benjamin Kuit) and smbdes.c/md4.c (Andrew Tridgell).
|
||||
*
|
||||
* @author Roland Gruber
|
||||
*
|
||||
* @package modules
|
||||
*/
|
||||
|
||||
/**
|
||||
* Calculates NT and LM hashes.
|
||||
*
|
||||
* The important functions are lmhash($password) and nthash($password).
|
||||
*
|
||||
* @package modules
|
||||
*/
|
||||
class smbHash {
|
||||
|
||||
# Contants used in lanlam hash calculations
|
||||
# Ported from SAMBA/source/libsmb/smbdes.c:perm1[56]
|
||||
var $perm1 = array(57, 49, 41, 33, 25, 17, 9,
|
||||
1, 58, 50, 42, 34, 26, 18,
|
||||
10, 2, 59, 51, 43, 35, 27,
|
||||
19, 11, 3, 60, 52, 44, 36,
|
||||
63, 55, 47, 39, 31, 23, 15,
|
||||
7, 62, 54, 46, 38, 30, 22,
|
||||
14, 6, 61, 53, 45, 37, 29,
|
||||
21, 13, 5, 28, 20, 12, 4);
|
||||
# Ported from SAMBA/source/libsmb/smbdes.c:perm2[48]
|
||||
var $perm2 = array(14, 17, 11, 24, 1, 5,
|
||||
3, 28, 15, 6, 21, 10,
|
||||
23, 19, 12, 4, 26, 8,
|
||||
16, 7, 27, 20, 13, 2,
|
||||
41, 52, 31, 37, 47, 55,
|
||||
30, 40, 51, 45, 33, 48,
|
||||
44, 49, 39, 56, 34, 53,
|
||||
46, 42, 50, 36, 29, 32);
|
||||
# Ported from SAMBA/source/libsmb/smbdes.c:perm3[64]
|
||||
var $perm3 = array(58, 50, 42, 34, 26, 18, 10, 2,
|
||||
60, 52, 44, 36, 28, 20, 12, 4,
|
||||
62, 54, 46, 38, 30, 22, 14, 6,
|
||||
64, 56, 48, 40, 32, 24, 16, 8,
|
||||
57, 49, 41, 33, 25, 17, 9, 1,
|
||||
59, 51, 43, 35, 27, 19, 11, 3,
|
||||
61, 53, 45, 37, 29, 21, 13, 5,
|
||||
63, 55, 47, 39, 31, 23, 15, 7);
|
||||
# Ported from SAMBA/source/libsmb/smbdes.c:perm4[48]
|
||||
var $perm4 = array(32, 1, 2, 3, 4, 5,
|
||||
4, 5, 6, 7, 8, 9,
|
||||
8, 9, 10, 11, 12, 13,
|
||||
12, 13, 14, 15, 16, 17,
|
||||
16, 17, 18, 19, 20, 21,
|
||||
20, 21, 22, 23, 24, 25,
|
||||
24, 25, 26, 27, 28, 29,
|
||||
28, 29, 30, 31, 32, 1);
|
||||
# Ported from SAMBA/source/libsmb/smbdes.c:perm5[32]
|
||||
var $perm5 = array(16, 7, 20, 21,
|
||||
29, 12, 28, 17,
|
||||
1, 15, 23, 26,
|
||||
5, 18, 31, 10,
|
||||
2, 8, 24, 14,
|
||||
32, 27, 3, 9,
|
||||
19, 13, 30, 6,
|
||||
22, 11, 4, 25);
|
||||
# Ported from SAMBA/source/libsmb/smbdes.c:perm6[64]
|
||||
var $perm6 = array(40, 8, 48, 16, 56, 24, 64, 32,
|
||||
39, 7, 47, 15, 55, 23, 63, 31,
|
||||
38, 6, 46, 14, 54, 22, 62, 30,
|
||||
37, 5, 45, 13, 53, 21, 61, 29,
|
||||
36, 4, 44, 12, 52, 20, 60, 28,
|
||||
35, 3, 43, 11, 51, 19, 59, 27,
|
||||
34, 2, 42, 10, 50, 18, 58, 26,
|
||||
33, 1, 41, 9, 49, 17, 57, 25);
|
||||
# Ported from SAMBA/source/libsmb/smbdes.c:sc[16]
|
||||
var $sc = array(1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1);
|
||||
# Ported from SAMBA/source/libsmb/smbdes.c:sbox[8][4][16]
|
||||
# Side note, I used cut and paste for all these numbers, I did NOT
|
||||
# type them all in =)
|
||||
var $sbox = array(array(array(14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7),
|
||||
array( 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8),
|
||||
array( 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0),
|
||||
array(15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13)),
|
||||
array(array(15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10),
|
||||
array( 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5),
|
||||
array( 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15),
|
||||
array(13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9)),
|
||||
array(array(10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8),
|
||||
array(13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1),
|
||||
array(13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7),
|
||||
array( 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12)),
|
||||
array(array( 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15),
|
||||
array(13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9),
|
||||
array(10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4),
|
||||
array( 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14)),
|
||||
array(array( 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9),
|
||||
array(14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6),
|
||||
array( 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14),
|
||||
array(11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3)),
|
||||
array(array(12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11),
|
||||
array(10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8),
|
||||
array( 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6),
|
||||
array( 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13)),
|
||||
array(array( 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1),
|
||||
array(13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6),
|
||||
array( 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2),
|
||||
array( 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12)),
|
||||
array(array(13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7),
|
||||
array( 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2),
|
||||
array( 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8),
|
||||
array( 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11)));
|
||||
|
||||
/**
|
||||
* Fixes too large numbers
|
||||
*/
|
||||
function x($i) {
|
||||
if ($i < 0) return 4294967296 - $i;
|
||||
else return $i;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer count
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
function lshift($count, $data) {
|
||||
$ret = array();
|
||||
for ($i = 0; $i < sizeof($data); $i++) {
|
||||
$ret[$i] = $data[($i + $count)%sizeof($data)];
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array in input data
|
||||
* @param array p permutation
|
||||
* @return array
|
||||
*/
|
||||
function permute($in, $p, $n) {
|
||||
$ret = array();
|
||||
for ($i = 0; $i < $n; $i++) {
|
||||
$ret[$i] = $in[$p[$i] - 1]?1:0;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $in1
|
||||
* @param array $in2
|
||||
* @return array
|
||||
*/
|
||||
function mxor($in1, $in2) {
|
||||
$ret = array();
|
||||
for ($i = 0; $i < sizeof($in1); $i++) {
|
||||
$ret[$i] = $in1[$i] ^ $in2[$i];
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $in
|
||||
* @param array $key
|
||||
* @param boolean $forw
|
||||
* @return array
|
||||
*/
|
||||
function doHash($in, $key, $forw) {
|
||||
$ki = array();
|
||||
|
||||
$pk1 = $this->permute($key, $this->perm1, 56);
|
||||
|
||||
$c = array();
|
||||
$d = array();
|
||||
for ($i = 0; $i < 28; $i++) {
|
||||
$c[$i] = $pk1[$i];
|
||||
$d[$i] = $pk1[28 + $i];
|
||||
}
|
||||
|
||||
for ($i = 0; $i < 16; $i++) {
|
||||
$c = $this->lshift($this->sc[$i], $c);
|
||||
$d = $this->lshift($this->sc[$i], $d);
|
||||
|
||||
$cd = $c;
|
||||
for ($k = 0; $k < sizeof($d); $k++) $cd[] = $d[$k];
|
||||
$ki[$i] = $this->permute($cd, $this->perm2, 48);
|
||||
}
|
||||
|
||||
$pd1 = $this->permute($in, $this->perm3, 64);
|
||||
|
||||
$l = array();
|
||||
$r = array();
|
||||
for ($i = 0; $i < 32; $i++) {
|
||||
$l[$i] = $pd1[$i];
|
||||
$r[$i] = $pd1[32 + $i];
|
||||
}
|
||||
|
||||
for ($i = 0; $i < 16; $i++) {
|
||||
$er = $this->permute($r, $this->perm4, 48);
|
||||
if ($forw) $erk = $this->mxor($er, $ki[$i]);
|
||||
else $erk = $this->mxor($er, $ki[15 - $i]);
|
||||
|
||||
for ($j = 0; $j < 8; $j++) {
|
||||
for ($k = 0; $k < 6; $k++) {
|
||||
$b[$j][$k] = $erk[($j * 6) + $k];
|
||||
}
|
||||
}
|
||||
for ($j = 0; $j < 8; $j++) {
|
||||
$m = array();
|
||||
$n = array();
|
||||
$m = ($b[$j][0] << 1) | $b[$j][5];
|
||||
$n = ($b[$j][1] << 3) | ($b[$j][2] << 2) | ($b[$j][3] << 1) | $b[$j][4];
|
||||
|
||||
for ($k = 0; $k < 4; $k++) {
|
||||
$b[$j][$k]=($this->sbox[$j][$m][$n] & (1 << (3-$k)))?1:0;
|
||||
}
|
||||
}
|
||||
|
||||
for ($j = 0; $j < 8; $j++) {
|
||||
for ($k = 0; $k < 4; $k++) {
|
||||
$cb[($j * 4) + $k] = $b[$j][$k];
|
||||
}
|
||||
}
|
||||
$pcb = $this->permute($cb, $this->perm5, 32);
|
||||
$r2 = $this->mxor($l, $pcb);
|
||||
for ($k = 0; $k < 32; $k++) $l[$k] = $r[$k];
|
||||
for ($k = 0; $k < 32; $k++) $r[$k] = $r2[$k];
|
||||
}
|
||||
$rl = $r;
|
||||
for ($i = 0; $i < sizeof($l); $i++) $rl[] = $l[$i];
|
||||
return $this->permute($rl, $this->perm6, 64);
|
||||
}
|
||||
|
||||
function str_to_key($str) {
|
||||
$key[0] = $this->unsigned_shift_r($str[0], 1);
|
||||
$key[1] = (($str[0]&0x01)<<6) | $this->unsigned_shift_r($str[1], 2);
|
||||
$key[2] = (($str[1]&0x03)<<5) | $this->unsigned_shift_r($str[2], 3);
|
||||
$key[3] = (($str[2]&0x07)<<4) | $this->unsigned_shift_r($str[3], 4);
|
||||
$key[4] = (($str[3]&0x0F)<<3) | $this->unsigned_shift_r($str[4], 5);
|
||||
$key[5] = (($str[4]&0x1F)<<2) | $this->unsigned_shift_r($str[5], 6);
|
||||
$key[6] = (($str[5]&0x3F)<<1) | $this->unsigned_shift_r($str[6], 7);
|
||||
$key[7] = $str[6]&0x7F;
|
||||
for ($i = 0; $i < 8; $i++) {
|
||||
$key[$i] = ($key[$i] << 1);
|
||||
}
|
||||
return $key;
|
||||
}
|
||||
|
||||
function smb_hash($in, $key, $forw){
|
||||
$key2 = $this->str_to_key($key);
|
||||
|
||||
for ($i = 0; $i < 64; $i++) {
|
||||
$inb[$i] = ($in[$i/8] & (1<<(7-($i%8)))) ? 1:0;
|
||||
$keyb[$i] = ($key2[$i/8] & (1<<(7-($i%8)))) ? 1:0;
|
||||
$outb[$i] = 0;
|
||||
}
|
||||
$outb = $this->dohash($inb, $keyb, $forw);
|
||||
for ($i = 0; $i < 8; $i++) {
|
||||
$out[$i] = 0;
|
||||
}
|
||||
for ($i = 0; $i < 65; $i++) {
|
||||
if ( isset($outb[$i]) && $outb[$i] ) {
|
||||
$out[$i/8] |= (1<<(7-($i%8)));
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
function E_P16($in) {
|
||||
$p14 = array_values(unpack("C*",$in));
|
||||
$sp8 = array(0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25);
|
||||
$p14_1 = array();
|
||||
$p14_2 = array();
|
||||
for ($i = 0; $i < 7; $i++) {
|
||||
$p14_1[$i] = $p14[$i];
|
||||
$p14_2[$i] = $p14[$i + 7];
|
||||
}
|
||||
$p16_1 = $this->smb_hash($sp8, $p14_1, true);
|
||||
$p16_2 = $this->smb_hash($sp8, $p14_2, true);
|
||||
$p16 = $p16_1;
|
||||
for ($i = 0; $i < sizeof($p16_2); $i++) {
|
||||
$p16[] = $p16_2[$i];
|
||||
}
|
||||
return $p16;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the LM hash of a given password.
|
||||
*
|
||||
* @param string $password password
|
||||
* @return string hash value
|
||||
*/
|
||||
function lmhash($password = "") {
|
||||
$password = strtoupper($password);
|
||||
$password = substr($password,0,14);
|
||||
$password = str_pad($password, 14, chr(0));
|
||||
$p16 = $this->E_P16($password);
|
||||
for ($i = 0; $i < sizeof($p16); $i++) {
|
||||
$p16[$i] = sprintf("%02X", $p16[$i]);
|
||||
}
|
||||
return join("", $p16);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the NT hash of a given password.
|
||||
*
|
||||
* @param string $password password
|
||||
* @return string hash value
|
||||
*/
|
||||
function nthash($password = "") {
|
||||
$password = substr($password,0,128);
|
||||
$password2 = "";
|
||||
for ($i = 0; $i < strlen($password); $i++) $password2 .= $password[$i] . chr(0);
|
||||
$password = $password2;
|
||||
$hex = $this->mdfour($password);
|
||||
for ($i = 0; $i < sizeof($hex); $i++) {
|
||||
$hex[$i] = sprintf("%02X", $hex[$i]);
|
||||
}
|
||||
return join("", $hex);
|
||||
}
|
||||
|
||||
# Support functions
|
||||
# Ported from SAMBA/source/lib/md4.c:F,G and H respectfully
|
||||
function F($X, $Y, $Z) {
|
||||
$ret = (($X&$Y) | ((~((int)$X))&$Z));
|
||||
if ($this->x($ret) > 4294967296) {
|
||||
$ret = (2*4294967296) - $this->x($ret);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function G($X, $Y, $Z) {
|
||||
return ($X&$Y) | ($X&$Z) | ($Y&$Z);
|
||||
}
|
||||
|
||||
function H($X, $Y, $Z) {
|
||||
return $X^$Y^$Z;
|
||||
}
|
||||
|
||||
# Ported from SAMBA/source/lib/md4.c:mdfour
|
||||
function mdfour($in) {
|
||||
$in = unpack("C*",$in);
|
||||
$in = array_values($in);
|
||||
$b = sizeof($in) * 8;
|
||||
$A = array(0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476);
|
||||
while (sizeof($in) > 64 ) {
|
||||
$M = $this->copy64($in);
|
||||
$this->mdfour64($A[0], $A[1], $A[2], $A[3], $M);
|
||||
$new_in = array();
|
||||
for ($i = 64; $i < sizeof($in); $i++) $new_in[] = $in[$i];
|
||||
$in = $new_in;
|
||||
}
|
||||
$buf = $in;
|
||||
$buf[] = 0x80;
|
||||
for ($i = sizeof($buf) - 1; $i < 127; $i++) $buf[] = 0;
|
||||
if ( sizeof($in) <= 55 ) {
|
||||
$temp = $this->copy4($b);
|
||||
$buf[56] = $temp[0];
|
||||
$buf[57] = $temp[1];
|
||||
$buf[58] = $temp[2];
|
||||
$buf[59] = $temp[3];
|
||||
$M = $this->copy64($buf);
|
||||
$this->mdfour64($A[0], $A[1], $A[2], $A[3], $M);
|
||||
}
|
||||
else {
|
||||
$temp = $this->copy4($b);
|
||||
$buf[120] = $temp[0];
|
||||
$buf[121] = $temp[1];
|
||||
$buf[122] = $temp[2];
|
||||
$buf[123] = $temp[3];
|
||||
$M = $this->copy64($buf);
|
||||
$this->mdfour64($A[0], $A[1], $A[2], $A[3], $M);
|
||||
$temp = array();
|
||||
for ($i = 64; $i < sizeof($buf); $i++) $temp[] = $buf[$i];
|
||||
$M = $this->copy64($temp);
|
||||
$this->mdfour64($A[0], $A[1], $A[2], $A[3], $M);
|
||||
}
|
||||
$out = array();
|
||||
$temp = $this->copy4($A[0]);
|
||||
for ($i = 0; $i < 4; $i++) $out[] = $temp[$i];
|
||||
$temp = $this->copy4($A[1]);
|
||||
for ($i = 0; $i < 4; $i++) $out[] = $temp[$i];
|
||||
$temp = $this->copy4($A[2]);
|
||||
for ($i = 0; $i < 4; $i++) $out[] = $temp[$i];
|
||||
$temp = $this->copy4($A[3]);
|
||||
for ($i = 0; $i < 4; $i++) $out[] = $temp[$i];
|
||||
return $out;
|
||||
}
|
||||
|
||||
# Ported from SAMBA/source/lib/md4.c:copy4
|
||||
function copy4($x) {
|
||||
$out = array();
|
||||
$out[0] = $x&0xFF;
|
||||
$out[1] = $this->unsigned_shift_r($x, 8)&0xFF;
|
||||
$out[2] = $this->unsigned_shift_r($x, 16)&0xFF;
|
||||
$out[3] = $this->unsigned_shift_r($x, 24)&0xFF;
|
||||
return $out;
|
||||
}
|
||||
|
||||
# Ported from SAMBA/source/lib/md4.c:copy64
|
||||
function copy64($in) {
|
||||
for ($i = 0; $i < 16; $i++) {
|
||||
$M[$i] = ($in[$i*4+3]<<24) | ($in[$i*4+2]<<16) | ($in[$i*4+1]<<8) | ($in[$i*4+0]<<0);
|
||||
}
|
||||
return $M;
|
||||
}
|
||||
|
||||
# Ported from SAMBA/source/lib/md4.c:mdfour64
|
||||
function mdfour64(&$A, &$B, &$C, &$D, $M) {
|
||||
$X = array();
|
||||
for ($i = 0; $i < 16; $i++) $X[] = $M[$i];
|
||||
$AA=$A;
|
||||
$BB=$B;
|
||||
$CC=$C;
|
||||
$DD=$D;
|
||||
$this->ROUND1($A,$B,$C,$D, 0, 3, $X);
|
||||
$this->ROUND1($D,$A,$B,$C, 1, 7, $X);
|
||||
$this->ROUND1($C,$D,$A,$B, 2, 11, $X);
|
||||
$this->ROUND1($B,$C,$D,$A, 3, 19, $X);
|
||||
$this->ROUND1($A,$B,$C,$D, 4, 3, $X); $this->ROUND1($D,$A,$B,$C, 5, 7, $X);
|
||||
$this->ROUND1($C,$D,$A,$B, 6, 11, $X); $this->ROUND1($B,$C,$D,$A, 7, 19, $X);
|
||||
$this->ROUND1($A,$B,$C,$D, 8, 3, $X); $this->ROUND1($D,$A,$B,$C, 9, 7, $X);
|
||||
$this->ROUND1($C,$D,$A,$B, 10, 11, $X); $this->ROUND1($B,$C,$D,$A, 11, 19, $X);
|
||||
$this->ROUND1($A,$B,$C,$D, 12, 3, $X); $this->ROUND1($D,$A,$B,$C, 13, 7, $X);
|
||||
$this->ROUND1($C,$D,$A,$B, 14, 11, $X); $this->ROUND1($B,$C,$D,$A, 15, 19, $X);
|
||||
$this->ROUND2($A,$B,$C,$D, 0, 3, $X); $this->ROUND2($D,$A,$B,$C, 4, 5, $X);
|
||||
$this->ROUND2($C,$D,$A,$B, 8, 9, $X); $this->ROUND2($B,$C,$D,$A, 12, 13, $X);
|
||||
$this->ROUND2($A,$B,$C,$D, 1, 3, $X); $this->ROUND2($D,$A,$B,$C, 5, 5, $X);
|
||||
$this->ROUND2($C,$D,$A,$B, 9, 9, $X); $this->ROUND2($B,$C,$D,$A, 13, 13, $X);
|
||||
$this->ROUND2($A,$B,$C,$D, 2, 3, $X); $this->ROUND2($D,$A,$B,$C, 6, 5, $X);
|
||||
$this->ROUND2($C,$D,$A,$B, 10, 9, $X); $this->ROUND2($B,$C,$D,$A, 14, 13, $X);
|
||||
$this->ROUND2($A,$B,$C,$D, 3, 3, $X); $this->ROUND2($D,$A,$B,$C, 7, 5, $X);
|
||||
$this->ROUND2($C,$D,$A,$B, 11, 9, $X); $this->ROUND2($B,$C,$D,$A, 15, 13, $X);
|
||||
$this->ROUND3($A,$B,$C,$D, 0, 3, $X); $this->ROUND3($D,$A,$B,$C, 8, 9, $X);
|
||||
$this->ROUND3($C,$D,$A,$B, 4, 11, $X); $this->ROUND3($B,$C,$D,$A, 12, 15, $X);
|
||||
$this->ROUND3($A,$B,$C,$D, 2, 3, $X); $this->ROUND3($D,$A,$B,$C, 10, 9, $X);
|
||||
$this->ROUND3($C,$D,$A,$B, 6, 11, $X); $this->ROUND3($B,$C,$D,$A, 14, 15, $X);
|
||||
$this->ROUND3($A,$B,$C,$D, 1, 3, $X); $this->ROUND3($D,$A,$B,$C, 9, 9, $X);
|
||||
$this->ROUND3($C,$D,$A,$B, 5, 11, $X); $this->ROUND3($B,$C,$D,$A, 13, 15, $X);
|
||||
$this->ROUND3($A,$B,$C,$D, 3, 3, $X); $this->ROUND3($D,$A,$B,$C, 11, 9, $X);
|
||||
$this->ROUND3($C,$D,$A,$B, 7, 11, $X); $this->ROUND3($B,$C,$D,$A, 15, 15, $X);
|
||||
|
||||
$A = $this->add32(array($A, $AA)); $B = $this->add32(array($B, $BB));
|
||||
$C = $this->add32(array($C, $CC)); $D = $this->add32(array($D, $DD));
|
||||
}
|
||||
|
||||
# Needed? because perl seems to choke on overflowing when doing bitwise
|
||||
# operations on numbers larger than 32 bits. Well, it did on my machine =)
|
||||
function add32($v) {
|
||||
$sum = array();
|
||||
for ($i = 0; $i < sizeof($v); $i++) {
|
||||
$v[$i] = array($this->unsigned_shift_r(($v[$i]&0xffff0000), 16), ($v[$i]&0xffff));
|
||||
}
|
||||
for ($i = 0; $i < sizeof($v); $i++) {
|
||||
@$sum[0] += $v[$i][0];
|
||||
@$sum[1] += $v[$i][1];
|
||||
}
|
||||
$sum[0] += ($sum[1]&0xffff0000)>>16;
|
||||
$sum[1] &= 0xffff;
|
||||
$sum[0] &= 0xffff;
|
||||
$ret = ($sum[0]<<16) | $sum[1];
|
||||
if ($this->x($ret) > 4294967296) {
|
||||
$ret = (2*4294967296) - $this->x($ret);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
# Ported from SAMBA/source/lib/md4.c:ROUND1
|
||||
function ROUND1(&$a,$b,$c,$d,$k,$s,$X) {
|
||||
$a = $this->md4lshift($this->add32(array($a, $this->F($b,$c,$d), $X[$k])), $s);
|
||||
return $a;
|
||||
}
|
||||
|
||||
# Ported from SAMBA/source/lib/md4.c:ROUND2
|
||||
function ROUND2(&$a,$b,$c,$d,$k,$s,$X) {
|
||||
$a = $this->md4lshift($this->add32(array($a, $this->G($b,$c,$d), $X[$k] + 0x5A827999)), $s);
|
||||
return $a;
|
||||
}
|
||||
|
||||
# Ported from SAMBA/source/lib/md4.c:ROUND3
|
||||
function ROUND3(&$a,$b,$c,$d,$k,$s,$X) {
|
||||
$a = $this->md4lshift($this->add32(array($a + $this->H($b,$c,$d) + $X[$k] + 0x6ED9EBA1)), $s);
|
||||
return $a;
|
||||
}
|
||||
|
||||
# Ported from SAMBA/source/lib/md4.c:lshift
|
||||
# Renamed to prevent clash with SAMBA/source/libsmb/smbdes.c:lshift
|
||||
function md4lshift($x, $s) {
|
||||
$x &= 0xFFFFFFFF;
|
||||
if ($this->x($x) > 4294967296) {
|
||||
$x = (2*4294967296) - $this->x($x);
|
||||
}
|
||||
$ret = ((($x<<$s)&0xFFFFFFFF) | $this->unsigned_shift_r($x, (32-$s)));
|
||||
if ($this->x($ret) > 4294967296) {
|
||||
$ret = (2*4294967296) - $this->x($ret);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsigned shift operation for 32bit values.
|
||||
*
|
||||
* PHP 4 only supports signed shifts by default.
|
||||
*/
|
||||
function unsigned_shift_r($a, $b) {
|
||||
$z = 0x80000000;
|
||||
if ($z & $a) {
|
||||
$a = ($a >> 1);
|
||||
$a &= (~$z);
|
||||
$a |= 0x40000000;
|
||||
$a = ($a >> ($b - 1));
|
||||
}
|
||||
else {
|
||||
$a = ($a >> $b);
|
||||
}
|
||||
return $a;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,3 +1,4 @@
|
|||
<pre>
|
||||
<?php
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2007 Easter-eggs
|
||||
|
@ -20,33 +21,65 @@
|
|||
|
||||
******************************************************************************/
|
||||
|
||||
$conf_dir='conf/';
|
||||
require_once $conf_dir.'config.php';
|
||||
require_once $conf_dir.'error_code.php';
|
||||
require_once $conf_dir.'config.LSeepeople.php';
|
||||
require_once $conf_dir.'config.LSeegroup.php';
|
||||
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 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'];
|
||||
require_once $GLOBALS['LSconfig']['QuickForm'];
|
||||
|
||||
$include_dir='includes/';
|
||||
require_once $include_dir.'functions.php';
|
||||
$class_dir=$include_dir.'class/';
|
||||
require_once $class_dir.'class.LSerror.php';
|
||||
require_once $class_dir.'class.LSldap.php';
|
||||
require_once $class_dir.'class.LSldapObject.php';
|
||||
require_once $class_dir.'class.LSattribute.php';
|
||||
require_once $class_dir.'class.LSattr_ldap.php';
|
||||
require_once $class_dir.'class.LSattr_ldap_ascii.php';
|
||||
require_once $class_dir.'class.LSattr_ldap_numeric.php';
|
||||
require_once $class_dir.'class.LSattr_html.php';
|
||||
require_once $class_dir.'class.LSattr_html_text.php';
|
||||
require_once $class_dir.'class.LSattr_html_select_list.php';
|
||||
require_once LS_INCLUDE_DIR .'functions.php';
|
||||
|
||||
require_once $class_dir.'class.LSeepeople.php';
|
||||
require_once $class_dir.'class.LSeegroup.php';
|
||||
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';
|
||||
|
||||
require_once LS_CLASS_DIR .'class.LSeepeople.php';
|
||||
require_once LS_CLASS_DIR .'class.LSeegroup.php';
|
||||
|
||||
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';
|
||||
|
||||
require_once $class_dir.'class.LSform.php';
|
||||
echo "<pre>";
|
||||
|
||||
// "Activation" de la gestion des erreurs
|
||||
$LSerror = new LSerror();
|
||||
|
@ -57,10 +90,9 @@ $LSldap = new LSldap($GLOBALS['LSconfig']['ldap_config']);
|
|||
// ---- les objets LDAP
|
||||
// Création d'un LSeepeople
|
||||
$eepeople = new LSeepeople($GLOBALS['LSobjects']['LSeepeople']);
|
||||
$eegroup = new LSeegroup($GLOBALS['LSobjects']['LSeegroup']);
|
||||
|
||||
// Chargement des données de l'objet depuis l'annuaire et à partir de son DN
|
||||
$eepeople-> loadData('uid=eeggs,ou=people,o=ost');
|
||||
$eegroup-> loadData('cn=adminldap,ou=groups,o=ost');
|
||||
$eepeople-> loadData('uid=eeggs,ou=people,o=lsexample');
|
||||
|
||||
// Création d'un formulaire à partir pour notre objet LDAP
|
||||
$form=$eepeople -> getForm('test');
|
||||
|
@ -76,5 +108,6 @@ $form -> display();
|
|||
|
||||
// Affichage des retours d'erreurs
|
||||
$LSerror -> display();
|
||||
echo "</pre>";
|
||||
?>
|
||||
?>
|
||||
</pre>
|
||||
<?php debug_print(); ?>
|
||||
|
|
111
trunk/index_new.php
Normal file
111
trunk/index_new.php
Normal file
|
@ -0,0 +1,111 @@
|
|||
<pre>
|
||||
<?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_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 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'];
|
||||
|
||||
require_once LS_INCLUDE_DIR .'functions.php';
|
||||
|
||||
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';
|
||||
|
||||
require_once LS_CLASS_DIR .'class.LSeepeople.php';
|
||||
require_once LS_CLASS_DIR .'class.LSeegroup.php';
|
||||
|
||||
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']);
|
||||
|
||||
// Création d'un formulaire à partir pour notre objet LDAP
|
||||
$form=$eepeople -> getForm('add');
|
||||
|
||||
// Gestion de sa validation
|
||||
if ($form->validate()) {
|
||||
// MàJ des données de l'objet LDAP
|
||||
$eepeople -> updateData();
|
||||
}
|
||||
// Affichage du formulaire
|
||||
$form -> display();
|
||||
|
||||
|
||||
// Affichage des retours d'erreurs
|
||||
$LSerror -> display();
|
||||
?>
|
||||
</pre>
|
||||
<?php debug_print(); ?>
|
116
trunk/test.php
Normal file
116
trunk/test.php
Normal file
|
@ -0,0 +1,116 @@
|
|||
<pre>
|
||||
<?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_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 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'];
|
||||
|
||||
require_once LS_INCLUDE_DIR .'functions.php';
|
||||
|
||||
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';
|
||||
|
||||
require_once LS_CLASS_DIR .'class.LSeepeople.php';
|
||||
require_once LS_CLASS_DIR .'class.LSeegroup.php';
|
||||
|
||||
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';
|
||||
|
||||
|
||||
// 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=lsexemple');
|
||||
|
||||
if (LSaddon_samba_support()) {
|
||||
echo "SambaSID : ".generate_sambaSID($eepeople)."<br/>";
|
||||
echo "SambaPrimaryGroupSID : ".generate_sambaPrimaryGroupSID($eepeople)."<br/>";
|
||||
echo "sambaNTPassword : ".generate_sambaNTPassword($eepeople)."<br/>";
|
||||
echo "sambaLMPassword : ".generate_sambaLMPassword($eepeople)."<br/>";
|
||||
}
|
||||
else {
|
||||
echo "Bug !!!";
|
||||
}
|
||||
|
||||
|
||||
// =========================================================
|
||||
|
||||
// Affichage des retours d'erreurs
|
||||
$LSerror -> display();
|
||||
?>
|
||||
</pre>
|
||||
<?php debug_print(); ?>
|
|
@ -1,71 +0,0 @@
|
|||
<?php
|
||||
|
||||
// filtre unique
|
||||
$filter['unique']=array(
|
||||
array(
|
||||
'filter' => 'uid=a*',
|
||||
'object_type' => 'LSeepeople',
|
||||
)
|
||||
);
|
||||
|
||||
// UniqueMember group
|
||||
$filter['uniqueMember']=array(
|
||||
array(
|
||||
'filter' => 'cn=admin*',
|
||||
'object_type' => 'LSeegroup',
|
||||
'attr' => 'uniqueMember',
|
||||
'basedn' => 'o=ost'
|
||||
),
|
||||
array(
|
||||
'basedn' => '%{dn}'
|
||||
)
|
||||
);
|
||||
|
||||
// memberUid
|
||||
$filter['memberUid']=array(
|
||||
array(
|
||||
'filter' => 'objectClass=posixGroup',
|
||||
'attr' => 'memberUid',
|
||||
'basedn' => 'o=ost'
|
||||
),
|
||||
array(
|
||||
'filter' => 'uid=%{dn}',
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
- On liste les memberUid
|
||||
- on forme avec des DN et on recupère leur Groupe Principale
|
||||
- on recupère tout les membres de ces groupes
|
||||
- on ne garde que les ostpeople
|
||||
*/
|
||||
$filter['complexe']=array(
|
||||
array(
|
||||
'filter' => 'objectClass=posixGroup',
|
||||
'attr' => 'memberUid',
|
||||
'basedn' => 'o=ost'
|
||||
),
|
||||
array(
|
||||
'filter' => 'uid=%{dn}',
|
||||
'basedn' => 'uid=%{dn},ou=people,o=ost',
|
||||
'attr' => 'gidNumber',
|
||||
),
|
||||
array(
|
||||
'filter' => 'gidNumber=%{dn}',
|
||||
'object_type' => 'LSeegroup',
|
||||
'attr' => 'uniqueMember'
|
||||
),
|
||||
array(
|
||||
'basedn' => "%{dn}",
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
|
||||
foreach($eepeople -> listObjects($filter['complexe'],'o=ost') as $obj){
|
||||
echo "DN : ".$obj -> dn."\n<br />";
|
||||
$obj -> debug_printAttrsValues();
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in a new issue