mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-18 00:09:06 +01:00
- Ajout de la gestion des droits (A étendre et debugger)
- Propagation des possibilités de l'interface
This commit is contained in:
parent
61ba918a42
commit
7d2e3baf8b
33 changed files with 2560 additions and 1706 deletions
|
@ -22,11 +22,12 @@
|
|||
|
||||
$GLOBALS['LSobjects']['LSeecompany'] = array (
|
||||
'objectclass' => array(
|
||||
'lscompany',
|
||||
'lscompany'
|
||||
),
|
||||
'rdn' => 'o',
|
||||
'container_dn' => 'ou=companies',
|
||||
'select_display_attrs' => '%{dc}',
|
||||
'label' => _('Sociétés'),
|
||||
'attrs' => array (
|
||||
'o' => array (
|
||||
'label' => _('Nom'),
|
||||
|
@ -36,9 +37,10 @@ $GLOBALS['LSobjects']['LSeecompany'] = array (
|
|||
'check_data' => array (
|
||||
'alphanumeric'
|
||||
),
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'self' => 'w', // définition des droits de l'utilisateur sur lui même
|
||||
'users' => 'r' // définition des droits de tout les utilisateurs
|
||||
'view' => 1,
|
||||
'rights' => array(
|
||||
'user' => 'r',
|
||||
'admin' => 'w'
|
||||
),
|
||||
'form' => array (
|
||||
'test' => 1
|
||||
|
@ -49,10 +51,11 @@ $GLOBALS['LSobjects']['LSeecompany'] = array (
|
|||
'ldap_type' => 'ascii',
|
||||
'html_type' => 'text',
|
||||
'required' => 1,
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'self' => 'w', // définition des droits de l'utilisateur sur lui même
|
||||
'users' => 'r' // définition des droits de tout les utilisateurs
|
||||
'rights' => array(
|
||||
'user' => 'r',
|
||||
'admin' => 'w'
|
||||
),
|
||||
'view' => 1,
|
||||
'form' => array (
|
||||
'test' => 1
|
||||
)
|
||||
|
|
|
@ -22,12 +22,12 @@
|
|||
|
||||
$GLOBALS['LSobjects']['LSeegroup'] = array (
|
||||
'objectclass' => array(
|
||||
'lsgroup',
|
||||
'posixGroup'
|
||||
),
|
||||
'rdn' => 'cn',
|
||||
'container_dn' => 'ou=groups',
|
||||
'select_display_attrs' => '%{cn}',
|
||||
'label' => _('Groupes'),
|
||||
'attrs' => array (
|
||||
'cn' => array (
|
||||
'label' => _('Nom'),
|
||||
|
@ -35,7 +35,9 @@ $GLOBALS['LSobjects']['LSeegroup'] = array (
|
|||
'html_type' => 'text',
|
||||
'required' => 1,
|
||||
'check_data' => array (
|
||||
'alphanumeric'
|
||||
'alphanumeric' => array(
|
||||
'msg' => _('Le nom ne doit comporter que des lettres et des chiffres.')
|
||||
),
|
||||
),
|
||||
'validation' => array (
|
||||
array (
|
||||
|
@ -43,9 +45,10 @@ $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
|
||||
'view' => 1,
|
||||
'rights' => array(
|
||||
'user' => 'r',
|
||||
'admin' => 'w'
|
||||
),
|
||||
'form' => array (
|
||||
'test' => 1
|
||||
|
@ -62,9 +65,10 @@ $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
|
||||
'view' => 1,
|
||||
'rights' => array(
|
||||
'user' => 'r',
|
||||
'admin' => 'w'
|
||||
),
|
||||
'form' => array (
|
||||
'test' => 1
|
||||
|
@ -75,15 +79,16 @@ $GLOBALS['LSobjects']['LSeegroup'] = array (
|
|||
'ldap_type' => 'ascii',
|
||||
'html_type' => 'select_list',
|
||||
'required' => 0,
|
||||
'multiple' => 1,
|
||||
'validation' => array (
|
||||
array (
|
||||
'basedn' => '%{val}',
|
||||
'result' => 1
|
||||
)
|
||||
),
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'self' => 'w', // définition des droits de l'utilisateur sur lui même
|
||||
'users' => 'r' // définition des droits de tout les utilisateurs
|
||||
'view' => 1,
|
||||
'rights' => array(
|
||||
'admin' => 'w'
|
||||
),
|
||||
'form' => array (
|
||||
'test' => 1
|
||||
|
@ -91,10 +96,10 @@ $GLOBALS['LSobjects']['LSeegroup'] = array (
|
|||
'possible_values' => array(
|
||||
'aucun' => _('-- Selectionner --'),
|
||||
'OTHER_OBJECT' => array(
|
||||
'object_type' => 'LSeepeople', // Nom de l'objet à lister
|
||||
'display_attribute' => '%{cn} (%{uidNumber})', // Spécifie le attributs à lister pour le choix,
|
||||
// si non définie => utilisation du 'select_display_attrs'
|
||||
// de la définition de l'objet
|
||||
'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
|
||||
)
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
$GLOBALS['LSobjects']['LSeepeople'] = array (
|
||||
'objectclass' => array(
|
||||
'top',
|
||||
'lspeople',
|
||||
'posixAccount',
|
||||
'sambaSamAccount',
|
||||
),
|
||||
|
@ -32,7 +31,8 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
'before_save' => 'valid',
|
||||
'after_save' => 'valid',
|
||||
'select_display_attrs' => '%{cn}',
|
||||
// Attributes
|
||||
'label' => _('Utilisateurs'),
|
||||
// Attributes
|
||||
'attrs' => array (
|
||||
'uid' => array (
|
||||
'label' => _('Identifiant'),
|
||||
|
@ -51,10 +51,12 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
'msg' => _('Cet identifiant est déjà utilisé.')
|
||||
)
|
||||
),
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'self' => 'w', // définition des droits de l'utilisateur sur lui même
|
||||
'users' => 'r' // définition des droits de tout les utilisateurs
|
||||
'rights' => array(
|
||||
'self' => 'r',
|
||||
'user' => 'r',
|
||||
'admin' => 'w'
|
||||
),
|
||||
'view' => 1,
|
||||
'form' => array (
|
||||
'test' => 0,
|
||||
'add' => 1
|
||||
|
@ -78,10 +80,11 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
'msg' => _('Cet uid est déjà utilisé.')
|
||||
)
|
||||
),
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'self' => 'w', // définition des droits de l'utilisateur sur lui même
|
||||
'users' => 'r' // définition des droits de tout les utilisateurs
|
||||
'rights' => array(
|
||||
'self' => 'r',
|
||||
'admin' => 'w'
|
||||
),
|
||||
'view' => 1,
|
||||
'form' => array (
|
||||
'test' => 0,
|
||||
)
|
||||
|
@ -93,10 +96,12 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
'required' => 1,
|
||||
'default_value' => 'titi',
|
||||
'validation' => 'valid',
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'self' => 'w', // définition des droits de l'utilisateur sur lui même
|
||||
'users' => 'r' // définition des droits de tout les utilisateurs
|
||||
'rights' => array(
|
||||
'self' => 'w',
|
||||
'user' => 'r',
|
||||
'admin' => 'w'
|
||||
),
|
||||
'view' => 1,
|
||||
'form' => array (
|
||||
'test' => 1,
|
||||
'add' => 1
|
||||
|
@ -113,10 +118,12 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
'msg' => _('Le prenom ne doit comporter que des lettres et des chiffres.')
|
||||
),
|
||||
),
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'self' => 'w', // définition des droits de l'utilisateur sur lui même
|
||||
'users' => 'r' // définition des droits de tout les utilisateurs
|
||||
'rights' => array(
|
||||
'self' => 'w',
|
||||
'users' => 'r',
|
||||
'admin' => 'w'
|
||||
),
|
||||
'view' => 1,
|
||||
'form' => array (
|
||||
'test' => 1,
|
||||
'add' => 1
|
||||
|
@ -130,8 +137,10 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
'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
|
||||
'user' => 'r', // définition des droits de tout les utilisateurs
|
||||
'admin' => 'w'
|
||||
),
|
||||
'view' => 1,
|
||||
'form' => array (
|
||||
'test' => 1,
|
||||
'add' => 1
|
||||
|
@ -141,7 +150,7 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
'label' => _('Groupe principal'),
|
||||
'ldap_type' => 'numeric',
|
||||
'html_type' => 'select_list',
|
||||
'multiple' => true,
|
||||
'multiple' => false,
|
||||
'required' => 1,
|
||||
'validation' => array (
|
||||
array (
|
||||
|
@ -151,10 +160,11 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
'result' => 1
|
||||
)
|
||||
),
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'self' => 'w', // définition des droits de l'utilisateur sur lui même
|
||||
'users' => 'r' // définition des droits de tout les utilisateurs
|
||||
'rights' => array(
|
||||
'self' => 'r',
|
||||
'admin' => 'w'
|
||||
),
|
||||
'view' => 1,
|
||||
'form' => array (
|
||||
'test' => 1,
|
||||
'add' => 1
|
||||
|
@ -167,14 +177,14 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
// de la définition de l'objet
|
||||
|
||||
'value_attribute' => 'gidNumber', // Spécifie le attributs dont la valeur sera retournée par
|
||||
'filter' => // le formulaire spécifie les filtres de recherche pour
|
||||
/*'filter' => // le formulaire spécifie les filtres de recherche pour
|
||||
array ( // l'établissement de la liste d'objets :
|
||||
array( // Premier filtre
|
||||
'filter' => 'cn=*a*',
|
||||
//'basedn' => 'o=company',
|
||||
'scope' => 'sub',
|
||||
)
|
||||
)
|
||||
)*/
|
||||
)
|
||||
)
|
||||
),
|
||||
|
@ -184,10 +194,11 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
'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
|
||||
'rights' => array(
|
||||
'self' => 'r',
|
||||
'admin' => 'w'
|
||||
),
|
||||
'view' => 1,
|
||||
'form' => array (
|
||||
'test' => 1,
|
||||
'add' => 1
|
||||
|
@ -203,9 +214,8 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
'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
|
||||
'rights' => array(
|
||||
'admin' => 'r'
|
||||
),
|
||||
'form' => array (
|
||||
//'test' => 0,
|
||||
|
@ -217,11 +227,11 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
'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
|
||||
'generate_function' => 'generate_homeDirectory',
|
||||
'rights' => array(
|
||||
'self' => 'r'
|
||||
),
|
||||
'view' => 1,
|
||||
'form' => array (
|
||||
'test' => 1,
|
||||
)
|
||||
|
@ -236,10 +246,12 @@ $GLOBALS['LSobjects']['LSeepeople'] = 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
|
||||
'rights' => array(
|
||||
'self' => 'r',
|
||||
'user' => 'r',
|
||||
'admin' => 'w'
|
||||
),
|
||||
'view' => 1,
|
||||
'form' => array (
|
||||
'test' => 1,
|
||||
'add' => 1
|
||||
|
@ -251,10 +263,12 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
'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
|
||||
'rights' => array(
|
||||
'self' => 'w',
|
||||
'user' => 'r',
|
||||
'admin' => 'w'
|
||||
),
|
||||
'view' => 1,
|
||||
'form' => array (
|
||||
'test' => 1,
|
||||
'add' => 1
|
||||
|
@ -269,16 +283,17 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
'label' => _('Mail indésirable'),
|
||||
'ldap_type' => 'ascii',
|
||||
'html_type' => 'text',
|
||||
'multiple' => true,
|
||||
'multiple' => true,
|
||||
'check_data' => array (
|
||||
'email' => array(
|
||||
'msg' => _("L'adresse e-mail entrée n'est pas valide.")
|
||||
),
|
||||
),
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'self' => 'w', // définition des droits de l'utilisateur sur lui même
|
||||
'users' => 'r' // définition des droits de tout les utilisateurs
|
||||
'rights' => array(
|
||||
'self' => 'w',
|
||||
'admin' => 'w'
|
||||
),
|
||||
'view' => 1,
|
||||
'form' => array (
|
||||
'test' => 1,
|
||||
)
|
||||
|
@ -293,27 +308,30 @@ $GLOBALS['LSobjects']['LSeepeople'] = 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
|
||||
'rights' => array(
|
||||
'self' => 'w',
|
||||
'admin' => 'w',
|
||||
'user' => 'r'
|
||||
),
|
||||
'view' => 1,
|
||||
'form' => array (
|
||||
'test' => 1,
|
||||
),
|
||||
'possible_values' => array(
|
||||
'%{uid}@autoreponse.example.fr' => 'Oui',
|
||||
'' => 'Non'
|
||||
'' => 'Non',
|
||||
'%{uid}@autoreponse.example.fr' => 'Oui'
|
||||
)
|
||||
),
|
||||
'vacationInfo' => array (
|
||||
'label' => _('Message en reponse'),
|
||||
'ldap_type' => 'ascii',
|
||||
'html_type' => 'textarea',
|
||||
'multiple' => true,
|
||||
'rights' => array( // Définition de droits : 'r' => lecture / 'w' => modification / '' => aucun (par defaut)
|
||||
'self' => 'w', // définition des droits de l'utilisateur sur lui même
|
||||
'users' => 'r' // définition des droits de tout les utilisateurs
|
||||
'multiple' => true,
|
||||
'rights' => array(
|
||||
'self' => 'w',
|
||||
'admin' => 'w'
|
||||
),
|
||||
'view' => 1,
|
||||
'form' => array (
|
||||
'test' => 1,
|
||||
)
|
||||
|
@ -327,10 +345,12 @@ $GLOBALS['LSobjects']['LSeepeople'] = 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
|
||||
'rights' => array(
|
||||
'self' => 'w',
|
||||
'user' => 'r',
|
||||
'admin' => 'w'
|
||||
),
|
||||
'view' => 1,
|
||||
'form' => array (
|
||||
'test' => 1,
|
||||
)
|
||||
|
@ -344,10 +364,11 @@ $GLOBALS['LSobjects']['LSeepeople'] = 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
|
||||
'rights' => array(
|
||||
'self' => 'r',
|
||||
'admin' => 'w'
|
||||
),
|
||||
'view' => 1,
|
||||
'form' => array (
|
||||
'test' => 1,
|
||||
)
|
||||
|
@ -356,10 +377,12 @@ $GLOBALS['LSobjects']['LSeepeople'] = 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
|
||||
'rights' => array(
|
||||
'self' => 'w',
|
||||
'user' => 'r',
|
||||
'admin' => 'w'
|
||||
),
|
||||
'view' => 1,
|
||||
'form' => array (
|
||||
'test' => 1,
|
||||
)
|
||||
|
@ -368,15 +391,15 @@ $GLOBALS['LSobjects']['LSeepeople'] = 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
|
||||
'required' => 1,
|
||||
'rights' => array(
|
||||
'self' => 'w',
|
||||
'admin' => 'w'
|
||||
),
|
||||
'dependAttrs' => array(
|
||||
'sambaLMPassword',
|
||||
'sambaNTPassword'
|
||||
),
|
||||
'dependAttrs' => array(
|
||||
'sambaLMPassword',
|
||||
'sambaNTPassword'
|
||||
),
|
||||
'form' => array (
|
||||
'test' => 1,
|
||||
'add' => 1
|
||||
|
@ -386,24 +409,16 @@ $GLOBALS['LSobjects']['LSeepeople'] = 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
|
||||
)
|
||||
),
|
||||
'required' => 1,
|
||||
'generate_function' => 'generate_sambaLMPassword'
|
||||
),
|
||||
'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
|
||||
)
|
||||
'required' => 1,
|
||||
'generate_function' => 'generate_sambaNTPassword'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
?>
|
||||
|
|
|
@ -22,8 +22,10 @@
|
|||
|
||||
define('LS_OBJECTS_DIR', LS_CONF_DIR . 'LSobjects/');
|
||||
|
||||
$GLOBALS['LSobjects']['loads'] = array (
|
||||
'LSeepeople', 'LSeegroup'
|
||||
$GLOBALS['LSobjects_loads'] = array (
|
||||
'LSeepeople',
|
||||
'LSeegroup',
|
||||
'LSeecompany'
|
||||
);
|
||||
|
||||
?>
|
||||
|
|
|
@ -100,10 +100,10 @@ $GLOBALS['LSerror_code'] = 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'
|
||||
),
|
||||
34 => array (
|
||||
'msg' => _("LSldapObject : L'attribut %{attr_depend} dépendant de l'attribut %{attr} n'existe pas."),
|
||||
'level' => 'w'
|
||||
),
|
||||
|
||||
// LSldapObject
|
||||
41 => array (
|
||||
|
@ -130,11 +130,11 @@ $GLOBALS['LSerror_code'] = array (
|
|||
'msg' => _("LSattribute : La valeur de l'attribut %{attr} ne peut pas être générée."),
|
||||
'level' => 'c'
|
||||
),
|
||||
47 => array (
|
||||
47 => array (
|
||||
'msg' => _("LSattribute : La valeur de l'attribut %{attr} n'a pas put être générée."),
|
||||
'level' => 'c'
|
||||
),
|
||||
48 => array (
|
||||
48 => array (
|
||||
'msg' => _("LSattribute : La génération de l'attribut %{attr} n'a pas retourné une valeur correcte."),
|
||||
'level' => 'c'
|
||||
),
|
||||
|
@ -153,40 +153,40 @@ $GLOBALS['LSerror_code'] = array (
|
|||
'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'
|
||||
),
|
||||
// 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'
|
||||
),
|
||||
301 => array(
|
||||
'msg' => _("LSformRule : Aucune regex n'a été fournis pour la validation des données."),
|
||||
'level' => 'w'
|
||||
),
|
||||
|
||||
// functions
|
||||
901 => array (
|
||||
|
@ -194,46 +194,50 @@ $GLOBALS['LSerror_code'] = array (
|
|||
'level' => 'c'
|
||||
),
|
||||
|
||||
// LSsession
|
||||
1001 => array (
|
||||
'msg' => _("LSsession : La constante %{const} n'est pas définie."),
|
||||
'level' => 'c'
|
||||
),
|
||||
1002 => array (
|
||||
'msg' => _("LSsession : Le support %{addon} n'est pas assuré. Vérifier la compatibilité du système et la configuration de l'addon"),
|
||||
'level' => 'c'
|
||||
),
|
||||
1003 => array (
|
||||
'msg' => _("LSsession : Données de configuration du serveur LDAP invalide. Impossible d'établir une connexion."),
|
||||
'level' => 'c'
|
||||
),
|
||||
1004 => array (
|
||||
'msg' => _("LSsession : Impossible de charger l'objets de type %{type} : type inconnu."),
|
||||
'level' => 'c'
|
||||
),
|
||||
1005 => array (
|
||||
'msg' => _("LSsession : Impossible d'effecture l'authentification : Type d'objet d'authentification inconnu (%{type})."),
|
||||
'level' => 'c'
|
||||
),
|
||||
1006 => array (
|
||||
'msg' => _("LSsession : Identifiant ou mot de passe incorrect."),
|
||||
'level' => 'c'
|
||||
),
|
||||
1007 => array (
|
||||
'msg' => _("LSsession : Impossible de vous identifier : Duplication d'authentité."),
|
||||
'level' => 'c'
|
||||
),
|
||||
1008 => array (
|
||||
'msg' => _("LSsession : Impossible d'inclure le moteur de rendu Smarty."),
|
||||
'level' => 'c'
|
||||
),
|
||||
1009 => array (
|
||||
'msg' => _("LSsession : Impossible de se connecter au Serveur LDAP."),
|
||||
'level' => 'c'
|
||||
),
|
||||
1010 => array (
|
||||
'msg' => _("LSsession : Impossible de charger la classe des objets d'authentification."),
|
||||
'level' => 'c'
|
||||
)
|
||||
// LSsession
|
||||
1001 => array (
|
||||
'msg' => _("LSsession : La constante %{const} n'est pas définie."),
|
||||
'level' => 'c'
|
||||
),
|
||||
1002 => array (
|
||||
'msg' => _("LSsession : Le support %{addon} n'est pas assuré. Vérifier la compatibilité du système et la configuration de l'addon"),
|
||||
'level' => 'c'
|
||||
),
|
||||
1003 => array (
|
||||
'msg' => _("LSsession : Données de configuration du serveur LDAP invalide. Impossible d'établir une connexion."),
|
||||
'level' => 'c'
|
||||
),
|
||||
1004 => array (
|
||||
'msg' => _("LSsession : Impossible de charger l'objets de type %{type} : type inconnu."),
|
||||
'level' => 'c'
|
||||
),
|
||||
1005 => array (
|
||||
'msg' => _("LSsession : Impossible d'effecture l'authentification : Type d'objet d'authentification inconnu (%{type})."),
|
||||
'level' => 'c'
|
||||
),
|
||||
1006 => array (
|
||||
'msg' => _("LSsession : Identifiant ou mot de passe incorrect."),
|
||||
'level' => 'c'
|
||||
),
|
||||
1007 => array (
|
||||
'msg' => _("LSsession : Impossible de vous identifier : Duplication d'authentité."),
|
||||
'level' => 'c'
|
||||
),
|
||||
1008 => array (
|
||||
'msg' => _("LSsession : Impossible d'inclure le moteur de rendu Smarty."),
|
||||
'level' => 'c'
|
||||
),
|
||||
1009 => array (
|
||||
'msg' => _("LSsession : Impossible de se connecter au Serveur LDAP."),
|
||||
'level' => 'c'
|
||||
),
|
||||
1010 => array (
|
||||
'msg' => _("LSsession : Impossible de charger la classe des objets d'authentification."),
|
||||
'level' => 'c'
|
||||
),
|
||||
1011 => array (
|
||||
'msg' => _("LSsession : Vous n'êtes pas authorisé à effectuer cette action."),
|
||||
'level' => 'c'
|
||||
)
|
||||
);
|
||||
?>
|
||||
|
|
|
@ -24,48 +24,59 @@
|
|||
$GLOBALS['LSconfig'] = array(
|
||||
'NetLDAP' => '/usr/share/php/Net/LDAP.php',
|
||||
'Smarty' => '/var/www/tmp/Smarty-2.6.18/libs/Smarty.class.php',
|
||||
'lang' => 'fr_FR.UTF8',
|
||||
'ldap_servers' => array (
|
||||
array (
|
||||
'name' => 'Ldap 1',
|
||||
'ldap_config'=> array(
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 389,
|
||||
'version' => 3,
|
||||
'starttls' => false,
|
||||
'binddn' => 'uid=toto,ou=people,o=ls',
|
||||
'bindpw' => 'toto',
|
||||
'basedn' => 'o=ls',
|
||||
'options' => array(),
|
||||
'filter' => '(objectClass=*)',
|
||||
'scope' => 'sub'
|
||||
),
|
||||
'authobject' => 'LSeepeople',
|
||||
'authobject_pwdattr' => 'userPassword'
|
||||
),
|
||||
array (
|
||||
'name' => 'Ldap 2',
|
||||
'ldap_config'=> array(
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 389,
|
||||
'version' => 3,
|
||||
'starttls' => false,
|
||||
'binddn' => 'uid=toto,ou=people,o=com',
|
||||
'bindpw' => 'toto',
|
||||
'basedn' => 'o=com',
|
||||
'options' => array(),
|
||||
'filter' => '(objectClass=*)',
|
||||
'scope' => 'sub'
|
||||
),
|
||||
'subdnobject' => 'LSeecompany',
|
||||
'authobject' => 'LSeepeople',
|
||||
'authobject_pwdattr' => 'userPassword'
|
||||
)
|
||||
)
|
||||
'lang' => 'fr_FR.UTF8',
|
||||
'cacheLSrights' => true,
|
||||
'ldap_servers' => array (
|
||||
array (
|
||||
'name' => 'Ldap 1',
|
||||
'ldap_config'=> array(
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 389,
|
||||
'version' => 3,
|
||||
'starttls' => false,
|
||||
'binddn' => 'uid=toto,ou=people,o=ls',
|
||||
'bindpw' => 'toto',
|
||||
'basedn' => 'o=ls',
|
||||
'options' => array(),
|
||||
'filter' => '(objectClass=*)',
|
||||
'scope' => 'sub'
|
||||
),
|
||||
'LSadmins' => array (
|
||||
'o=ost' => array (
|
||||
'uid=toto,ou=people,o=ls' => NULL,
|
||||
'cn=adminldap,ou=groups,o=ost' => array (
|
||||
'attr' => 'uniqueMember',
|
||||
'LSobject' => 'LSeegroup'
|
||||
)
|
||||
)
|
||||
),
|
||||
'cacheLSrights' => false,
|
||||
'authobject' => 'LSeepeople',
|
||||
'authobject_pwdattr' => 'userPassword'
|
||||
),
|
||||
array (
|
||||
'name' => 'Ldap 2',
|
||||
'ldap_config'=> array(
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 389,
|
||||
'version' => 3,
|
||||
'starttls' => false,
|
||||
'binddn' => 'uid=toto,ou=people,o=com',
|
||||
'bindpw' => 'toto',
|
||||
'basedn' => 'o=com',
|
||||
'options' => array(),
|
||||
'filter' => '(objectClass=*)',
|
||||
'scope' => 'sub'
|
||||
),
|
||||
'subdnobject' => 'LSeecompany',
|
||||
'authobject' => 'LSeepeople',
|
||||
'authobject_pwdattr' => 'userPassword'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
//Debug
|
||||
$GLOBALS['LSdebug']['active'] = true;
|
||||
$GLOBALS['LSdebug']['active'] = false;
|
||||
|
||||
// Définitions des locales
|
||||
$textdomain = 'ldapsaisie';
|
||||
|
@ -83,9 +94,9 @@ define('LS_JS_DIR', LS_INCLUDE_DIR .'js/');
|
|||
|
||||
// Javascript
|
||||
$GLOBALS['defaultJSscipts']=array(
|
||||
'mootools.js',
|
||||
'LSdefault.js',
|
||||
'Debugger.js'
|
||||
'mootools.js',
|
||||
'LSdefault.js',
|
||||
'Debugger.js'
|
||||
);
|
||||
|
||||
?>
|
||||
|
|
|
@ -40,7 +40,7 @@ class LSattr_html {
|
|||
*
|
||||
* @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
|
||||
* @param[in] &$attribute LSattribute L'objet LSattribut parent
|
||||
*
|
||||
* @retval boolean Retourne true.
|
||||
*/
|
||||
|
@ -51,36 +51,43 @@ class LSattr_html {
|
|||
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.
|
||||
*/
|
||||
/**
|
||||
* 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() {
|
||||
if ( $this -> config['label'] != '' ) {
|
||||
return $this -> config['label'];
|
||||
}
|
||||
else {
|
||||
return $this -> name;
|
||||
}
|
||||
if ( $this -> config['label'] != '' ) {
|
||||
return $this -> config['label'];
|
||||
}
|
||||
else {
|
||||
return $this -> name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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é
|
||||
*/
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
function __sleep() {
|
||||
return ( array_keys( get_object_vars( &$this ) ) );
|
||||
}
|
||||
|
||||
function __wakeup() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -40,7 +40,7 @@ class LSattr_ldap {
|
|||
*
|
||||
* @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
|
||||
* @param[in] &$attribute LSattribute L'objet LSattribut parent
|
||||
*
|
||||
* @retval boolean Retourne true.
|
||||
*/
|
||||
|
@ -50,29 +50,36 @@ class LSattr_ldap {
|
|||
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
|
||||
*/
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
function __sleep() {
|
||||
return ( array_keys( get_object_vars( &$this ) ) );
|
||||
}
|
||||
|
||||
function __wakeup() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -40,7 +40,8 @@ class LSattribute {
|
|||
var $data;
|
||||
var $updateData=false;
|
||||
var $is_validate=false;
|
||||
var $_finalUpdateData=false;
|
||||
var $_finalUpdateData=false;
|
||||
var $_myRights=NULL;
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
|
@ -56,15 +57,15 @@ class LSattribute {
|
|||
* @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,&$ldapObject) {
|
||||
$this -> name = $name;
|
||||
$this -> config = $config;
|
||||
$this -> ldapObject = $ldapObject;
|
||||
$this -> ldapObject = $ldapObject;
|
||||
$html_type = "LSattr_html_".$config['html_type'];
|
||||
$ldap_type = "LSattr_ldap_".$config['ldap_type'];
|
||||
$GLOBALS['LSsession'] -> loadLSclass($html_type);
|
||||
$GLOBALS['LSsession'] -> loadLSclass($ldap_type);
|
||||
$GLOBALS['LSsession'] -> loadLSclass($html_type);
|
||||
$GLOBALS['LSsession'] -> loadLSclass($ldap_type);
|
||||
if((class_exists($html_type))&&(class_exists($ldap_type))) {
|
||||
$this -> html = new $html_type($name,$config,$this);
|
||||
$this -> ldap = new $ldap_type($name,$config,$this);
|
||||
|
@ -85,7 +86,7 @@ class LSattribute {
|
|||
* @retval string Le label de l'attribut
|
||||
*
|
||||
* @see LSattr_html::getLabel()
|
||||
*/
|
||||
*/
|
||||
|
||||
function getLabel() {
|
||||
return $this -> html -> getLabel();
|
||||
|
@ -119,21 +120,21 @@ class LSattribute {
|
|||
|
||||
/**
|
||||
* Retourne la valeur de l'attribut
|
||||
*
|
||||
* Retourne la valeur nouvelle si elle existe, sinon la valeur passé.
|
||||
*
|
||||
* 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() {
|
||||
$updateData=$this -> getUpdateData();
|
||||
if (empty($updateData)) {
|
||||
return $this -> data;
|
||||
}
|
||||
else {
|
||||
return $updateData;
|
||||
}
|
||||
$updateData=$this -> getUpdateData();
|
||||
if (empty($updateData)) {
|
||||
return $this -> data;
|
||||
}
|
||||
else {
|
||||
return $updateData;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -188,6 +189,9 @@ class LSattribute {
|
|||
*/
|
||||
function addToForm(&$form,$idForm,&$obj=NULL) {
|
||||
if(isset($this -> config['form'][$idForm])) {
|
||||
if($this -> myRights() == 'n') {
|
||||
return true;
|
||||
}
|
||||
if($this -> data !='') {
|
||||
$data=$this -> getFormVal();
|
||||
}
|
||||
|
@ -196,36 +200,96 @@ class LSattribute {
|
|||
}
|
||||
|
||||
$element = $this -> html -> addToForm($form,$idForm,$data);
|
||||
if(!$element) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(206,$this -> name);
|
||||
}
|
||||
if(!$element) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(206,$this -> name);
|
||||
}
|
||||
|
||||
if($this -> config['required']==1) {
|
||||
$form -> setRequired($this -> name);
|
||||
}
|
||||
|
||||
if($this -> config['form'][$idForm]==0) {
|
||||
if (($this -> config['form'][$idForm]==0) || ($this -> myRights() == 'r')) {
|
||||
$element -> freeze();
|
||||
}
|
||||
|
||||
if(isset($this -> config['check_data'])) {
|
||||
if(is_array($this -> config['check_data'])) {
|
||||
foreach ($this -> config['check_data'] as $rule => $rule_infos) {
|
||||
if((!$form -> isRuleRegistered($rule))&&($rule!='')) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(43,array('attr' => $this->name,'rule' => $rule));
|
||||
return;
|
||||
else {
|
||||
if(isset($this -> config['check_data'])) {
|
||||
if(is_array($this -> config['check_data'])) {
|
||||
foreach ($this -> config['check_data'] as $rule => $rule_infos) {
|
||||
if((!$form -> isRuleRegistered($rule))&&($rule!='')) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(43,array('attr' => $this->name,'rule' => $rule));
|
||||
return;
|
||||
}
|
||||
if(!isset($rule_infos['msg']))
|
||||
$rule_infos['msg']=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,array('msg' => $rule_infos['msg'], 'param' => $rule_infos['param']));
|
||||
}
|
||||
if(!isset($rule_infos['msg']))
|
||||
$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,array('msg' => $rule_infos['msg'], 'param' => $rule_infos['param']));
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(44,$this->name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(44,$this->name);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function myRights() {
|
||||
// cache
|
||||
if ($this -> _myRights != NULL) {
|
||||
return $this -> _myRights;
|
||||
}
|
||||
$return='n';
|
||||
switch ($this -> ldapObject -> whoami()) {
|
||||
case 'admin':
|
||||
if($this -> config['rights']['admin']=='w') {
|
||||
$return='w';
|
||||
}
|
||||
else {
|
||||
$return='r';
|
||||
}
|
||||
break;
|
||||
case 'self':
|
||||
if (($this -> config['rights']['self'] == 'w') || ($this -> config['rights']['self'] == 'r')) {
|
||||
$return=$this -> config['self'];
|
||||
}
|
||||
break;
|
||||
default: //user
|
||||
if (($this -> config['rights']['user'] == 'w') || ($this -> config['rights']['user'] == 'r')) {
|
||||
$return=$this -> config['user'];
|
||||
}
|
||||
break;
|
||||
}
|
||||
$this -> _myRights = $return;
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajoute l'attribut au formualaire de vue
|
||||
*
|
||||
* Cette méthode ajoute l'attribut au formulaire $form de vue si il doit l'être
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] object $form Le formulaire dans lequel doit être ajouté l'attribut
|
||||
*
|
||||
* @retval boolean true si l'ajout a fonctionner ou qu'il n'est pas nécessaire, false sinon
|
||||
*/
|
||||
function addToView(&$form) {
|
||||
if((isset($this -> config['view'])) && ($this -> myRights() != 'n')) {
|
||||
if($this -> data !='') {
|
||||
$data=$this -> getFormVal();
|
||||
}
|
||||
else {
|
||||
$data='';
|
||||
}
|
||||
$element = $this -> html -> addToForm($form,'view',$data);
|
||||
if(!$element) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(206,$this -> name);
|
||||
}
|
||||
$element -> freeze();
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -256,9 +320,9 @@ class LSattribute {
|
|||
* @retval string La valeur a afficher dans le formulaire.
|
||||
*/
|
||||
function getFormVal() {
|
||||
$data=$this -> getDisplayValue();
|
||||
if(!is_array($data))
|
||||
$data=array($data);
|
||||
$data=$this -> getDisplayValue();
|
||||
if(!is_array($data))
|
||||
$data=array($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -274,8 +338,7 @@ class LSattribute {
|
|||
function setUpdateData($data) {
|
||||
if($this -> getFormVal() != $data) {
|
||||
$this -> updateData=$data;
|
||||
debug($this -> name.' is updated (o = '.$this -> getFormVal().' | n = '.$data.')');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -333,41 +396,41 @@ class LSattribute {
|
|||
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;
|
||||
}
|
||||
/**
|
||||
* 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é.
|
||||
* 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() {
|
||||
if (!$this -> isUpdate()) {
|
||||
return;
|
||||
}
|
||||
if ( $this -> _finalUpdateData ) {
|
||||
return $this -> _finalUpdateData;
|
||||
}
|
||||
if (!$this -> isUpdate()) {
|
||||
return;
|
||||
}
|
||||
if ( $this -> _finalUpdateData ) {
|
||||
return $this -> _finalUpdateData;
|
||||
}
|
||||
$data=$this -> updateData;
|
||||
if ($this -> config['onSave']) {
|
||||
if (is_array($this -> config['onSave'])) {
|
||||
|
@ -395,7 +458,7 @@ class LSattribute {
|
|||
else {
|
||||
$result = $this -> ldap -> getUpdateData($data);
|
||||
}
|
||||
$this -> _finalUpdateData = $result;
|
||||
$this -> _finalUpdateData = $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
@ -419,7 +482,15 @@ class LSattribute {
|
|||
*/
|
||||
function getDependsAttrs() {
|
||||
return $this -> config['dependAttrs'];
|
||||
}
|
||||
}
|
||||
|
||||
function __sleep() {
|
||||
return ( array_keys( get_object_vars( &$this ) ) );
|
||||
}
|
||||
|
||||
function __wakeup() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -36,14 +36,14 @@ class LSform {
|
|||
var $elements = array();
|
||||
var $_rules = array();
|
||||
|
||||
var $_postData = array();
|
||||
var $_postData = array();
|
||||
|
||||
var $_elementsErrors = array();
|
||||
var $_isValidate = false;
|
||||
var $_elementsErrors = array();
|
||||
var $_isValidate = false;
|
||||
|
||||
var $_notUpdate = array();
|
||||
var $_notUpdate = array();
|
||||
|
||||
/**
|
||||
/**
|
||||
* Constructeur
|
||||
*
|
||||
* Cette methode construit l'objet et définis la configuration.
|
||||
|
@ -54,12 +54,12 @@ class LSform {
|
|||
* @param[in] $submit string La valeur du bouton submit
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
*/
|
||||
function LSform (&$ldapObject,$idForm,$submit="Envoyer"){
|
||||
$this -> idForm = $idForm;
|
||||
$this -> submit = $submit;
|
||||
$this -> ldapObject = $ldapObject;
|
||||
$GLOBALS['LSsession'] -> loadLSclass('LSformElement');
|
||||
$this -> ldapObject = $ldapObject;
|
||||
$GLOBALS['LSsession'] -> loadLSclass('LSformElement');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,28 +68,63 @@ class LSform {
|
|||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
*/
|
||||
function display(){
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSform.js');
|
||||
$GLOBALS['LSsession'] -> addCssFile('LSform.css');
|
||||
$GLOBALS['Smarty'] -> assign('LSform_action',$_SERVER['PHP_SELF']);
|
||||
$LSform_header = "\t<input type='hidden' name='validate' value='LSform'/>\n\t<input type='hidden' name='idForm' id='LSform_idform' value='".$this -> idForm."'/>\n\t<input type='hidden' name='LSform_objecttype' id='LSform_objecttype' value='".$this -> ldapObject -> getType()."'/>\n";
|
||||
$GLOBALS['Smarty'] -> assign('LSform_header',$LSform_header);
|
||||
$fields = array();
|
||||
foreach($this -> elements as $element) {
|
||||
$field = array();
|
||||
$field = $element -> getDisplay();
|
||||
if (isset($this -> _elementsErrors[$element -> name])) {
|
||||
$field['errors']= $this -> _elementsErrors[$element -> name];
|
||||
}
|
||||
$fields[] = $field;
|
||||
}
|
||||
$GLOBALS['Smarty'] -> assign('LSform_fields',$fields);
|
||||
if($this -> can_validate) {
|
||||
$GLOBALS['Smarty'] -> assign('LSform_submittxt',$this -> submit);
|
||||
}
|
||||
if ($this -> idForm == 'view') {
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSview.js');
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSform.js');
|
||||
}
|
||||
$GLOBALS['LSsession'] -> addCssFile('LSform.css');
|
||||
$GLOBALS['Smarty'] -> assign('LSform_action',$_SERVER['PHP_SELF']);
|
||||
$LSform_header = "\t<input type='hidden' name='validate' value='LSform'/>\n
|
||||
\t<input type='hidden' name='idForm' id='LSform_idform' value='".$this -> idForm."'/>\n
|
||||
\t<input type='hidden' name='LSform_objecttype' id='LSform_objecttype' value='".$this -> ldapObject -> getType()."'/>\n
|
||||
\t<input type='hidden' name='LSform_objectdn' id='LSform_objectdn' value='".$this -> ldapObject -> getValue('dn')."'/>";
|
||||
$GLOBALS['Smarty'] -> assign('LSform_header',$LSform_header);
|
||||
$LSform_object = array(
|
||||
'type' => $this -> ldapObject -> getType(),
|
||||
'dn' => $this -> ldapObject -> getDn()
|
||||
);
|
||||
$GLOBALS['Smarty'] -> assign('LSform_object',$LSform_object);
|
||||
$fields = array();
|
||||
foreach($this -> elements as $element) {
|
||||
$field = array();
|
||||
$field = $element -> getDisplay();
|
||||
if (isset($this -> _elementsErrors[$element -> name])) {
|
||||
$field['errors']= $this -> _elementsErrors[$element -> name];
|
||||
}
|
||||
$fields[] = $field;
|
||||
}
|
||||
$GLOBALS['Smarty'] -> assign('LSform_fields',$fields);
|
||||
if($this -> can_validate) {
|
||||
$GLOBALS['Smarty'] -> assign('LSform_submittxt',$this -> submit);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Affiche la vue
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
function displayView(){
|
||||
$GLOBALS['LSsession'] -> addCssFile('LSform.css');
|
||||
$LSform_object = array(
|
||||
'type' => $this -> ldapObject -> getType(),
|
||||
'dn' => $this -> ldapObject -> getDn()
|
||||
);
|
||||
$GLOBALS['Smarty'] -> assign('LSform_object',$LSform_object);
|
||||
$fields = array();
|
||||
foreach($this -> elements as $element) {
|
||||
$field = $element -> getDisplay();
|
||||
$fields[] = $field;
|
||||
}
|
||||
$GLOBALS['Smarty'] -> assign('LSform_fields',$fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Défini l'erreur sur un champ
|
||||
*
|
||||
|
@ -101,7 +136,7 @@ class LSform {
|
|||
* du champs concerné.
|
||||
*
|
||||
* @retval void
|
||||
*/
|
||||
*/
|
||||
function setElementError($attr,$msg=NULL) {
|
||||
if($msg!='') {
|
||||
$msg_error=getFData($msg,$attr->getLabel());
|
||||
|
@ -118,264 +153,265 @@ class LSform {
|
|||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval boolean true si le formulaire a été validé et que les données ont été validées, false sinon
|
||||
*/
|
||||
*/
|
||||
function validate(){
|
||||
if(!$this -> can_validate)
|
||||
return;
|
||||
if ($this -> isSubmit()) {
|
||||
if (!$this -> getPostData()) {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(201);
|
||||
return;
|
||||
}
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
$GLOBALS['LSsession'] -> loadLSclass('LSformRule');
|
||||
foreach($this -> _rules[$element] as $rule) {
|
||||
$ruleType="LSformRule_".$rule['name'];
|
||||
$GLOBALS['LSsession'] -> loadLSclass($ruleType);
|
||||
if (! call_user_func(array( $ruleType,'validate') , $value, $rule['options'])) {
|
||||
$retval=false;
|
||||
$this -> setElementError($this -> elements[$element],$rule['options']['msg']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
foreach($values as $value) {
|
||||
if (empty($value)) {
|
||||
continue;
|
||||
}
|
||||
if (!is_array($this -> _rules[$element]))
|
||||
continue;
|
||||
$GLOBALS['LSsession'] -> loadLSclass('LSformRule');
|
||||
foreach($this -> _rules[$element] as $rule) {
|
||||
$ruleType="LSformRule_".$rule['name'];
|
||||
$GLOBALS['LSsession'] -> loadLSclass($ruleType);
|
||||
if (! call_user_func(array( $ruleType,'validate') , $value, $rule['options'])) {
|
||||
$retval=false;
|
||||
$this -> setElementError($this -> elements[$element],$rule['options']['msg']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
* 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;
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
$GLOBALS['LSsession'] -> loadLSclass($elementType);
|
||||
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 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;
|
||||
$GLOBALS['LSsession'] -> loadLSclass($elementType);
|
||||
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;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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é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) {
|
||||
$GLOBALS['LSsession'] -> loadLSclass('LSformRule');
|
||||
$GLOBALS['LSsession'] -> loadLSclass('LSformRule_'.$rule);
|
||||
return class_exists('LSformRule_'.$rule);
|
||||
}
|
||||
/*
|
||||
* 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) {
|
||||
$GLOBALS['LSsession'] -> loadLSclass('LSformRule');
|
||||
$GLOBALS['LSsession'] -> loadLSclass('LSformRule_'.$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;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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];
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le code HTML d'un champ vide.
|
||||
*
|
||||
* @param[in] string Le nom du champ du formulaire
|
||||
*
|
||||
* @retval string Le code HTML du champ vide.
|
||||
*/
|
||||
function getEmptyField($element) {
|
||||
$element = $this -> getElement($element);
|
||||
if ($element) {
|
||||
return $element -> getEmptyField();
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Retourne le code HTML d'un champ vide.
|
||||
*
|
||||
* @param[in] string Le nom du champ du formulaire
|
||||
*
|
||||
* @retval string Le code HTML du champ vide.
|
||||
*/
|
||||
function getEmptyField($element) {
|
||||
$element = $this -> getElement($element);
|
||||
if ($element) {
|
||||
return $element -> getEmptyField();
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -40,42 +40,37 @@ class LSformElement_select extends LSformElement {
|
|||
* @retval array
|
||||
*/
|
||||
function getDisplay(){
|
||||
$return = $this -> getLabelInfos();
|
||||
// value
|
||||
if (!$this -> isFreeze()) {
|
||||
if ($this -> params['multiple']==0) {
|
||||
$multiple_tag='';
|
||||
}
|
||||
else {
|
||||
$multiple_tag='multiple';
|
||||
}
|
||||
|
||||
$return['html'] = "<select name='".$this -> name."' $multiple_tag class='LSform'>\n";
|
||||
foreach ($this -> params['text_possible_values'] as $choice_value => $choice_text) {
|
||||
if (in_array($choice_value, $this -> values)) {
|
||||
$selected=' selected';
|
||||
}
|
||||
else {
|
||||
$selected='';
|
||||
}
|
||||
$return['html'].="<option value=\"".$choice_value."\"$selected>$choice_text</option>\n";
|
||||
}
|
||||
$return['html'].="</select>\n";
|
||||
}
|
||||
else {
|
||||
$return['html']="<ul class='LSform'>\n";
|
||||
foreach ($params['possible_values'] as $choice_value => $choice_text) {
|
||||
if (in_array($choice_value, $this -> value)) {
|
||||
$return['html'].="<li class='LSform'><strong>$choice_text</strong></li>";
|
||||
}
|
||||
else {
|
||||
$return['html'].="<li class='LSform'>$choice_text</li>";
|
||||
}
|
||||
}
|
||||
$return['html'].="</ul>\n";
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
$return = $this -> getLabelInfos();
|
||||
// value
|
||||
if (!$this -> isFreeze()) {
|
||||
if ($this -> params['multiple']==0) {
|
||||
$multiple_tag='';
|
||||
}
|
||||
else {
|
||||
$multiple_tag='multiple';
|
||||
}
|
||||
|
||||
$return['html'] = "<select name='".$this -> name."' $multiple_tag class='LSform'>\n";
|
||||
foreach ($this -> params['text_possible_values'] as $choice_value => $choice_text) {
|
||||
if (in_array($choice_value, $this -> values)) {
|
||||
$selected=' selected';
|
||||
}
|
||||
else {
|
||||
$selected='';
|
||||
}
|
||||
$return['html'].="<option value=\"".$choice_value."\"$selected>$choice_text</option>\n";
|
||||
}
|
||||
$return['html'].="</select>\n";
|
||||
}
|
||||
else {
|
||||
$return['html']="<ul class='LSform'>\n";
|
||||
foreach ($this -> values as $value) {
|
||||
$return['html'].="<li class='LSform'>".$this -> params['text_possible_values'][$value]."</strong></li>";
|
||||
}
|
||||
$return['html'].="</ul>\n";
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -40,46 +40,46 @@ class LSformElement_text extends LSformElement {
|
|||
* @retval array
|
||||
*/
|
||||
function getDisplay(){
|
||||
$return = $this -> getLabelInfos();
|
||||
// value
|
||||
if (!$this -> isFreeze()) {
|
||||
$return['html'] = "<ul class='LSform'>\n";
|
||||
if (empty($this -> values)) {
|
||||
$return['html'] .= "<li>".$this -> getEmptyField()."</li>\n";
|
||||
}
|
||||
else {
|
||||
$multiple = $this -> getMultipleData();
|
||||
foreach ($this -> values as $value) {
|
||||
$id = "LSform_".$this -> name."_".rand();
|
||||
$return['html'] .= "<li><input type='text' name='".$this -> name."[]' value=\"".$value."\" id='".$id."'>".$multiple."</li>\n";
|
||||
}
|
||||
}
|
||||
$return['html'] .= "</ul>\n";
|
||||
}
|
||||
else {
|
||||
$return['html'] = "<ul class='LSform'>\n";
|
||||
if (empty($this -> values)) {
|
||||
$return['html'] .= "<li>"._('Aucunes valeur definie')."</li>\n";
|
||||
}
|
||||
else {
|
||||
foreach ($this -> values as $value) {
|
||||
$return['html'] .= "<li>".$value."</li>\n";
|
||||
}
|
||||
}
|
||||
$return['html'] .= "</ul>\n";
|
||||
}
|
||||
return $return;
|
||||
$return = $this -> getLabelInfos();
|
||||
// value
|
||||
if (!$this -> isFreeze()) {
|
||||
$return['html'] = "<ul class='LSform'>\n";
|
||||
if (empty($this -> values)) {
|
||||
$return['html'] .= "<li>".$this -> getEmptyField()."</li>\n";
|
||||
}
|
||||
else {
|
||||
foreach ($this -> values as $value) {
|
||||
$multiple = $this -> getMultipleData();
|
||||
$id = "LSform_".$this -> name."_".rand();
|
||||
$return['html'] .= "<li><input type='text' name='".$this -> name."[]' value=\"".$value."\" id='".$id."'>".$multiple."</li>\n";
|
||||
}
|
||||
}
|
||||
$return['html'] .= "</ul>\n";
|
||||
}
|
||||
else {
|
||||
$return['html'] = "<ul class='LSform'>\n";
|
||||
if (empty($this -> values)) {
|
||||
$return['html'] .= "<li>"._('Aucunes valeur definie')."</li>\n";
|
||||
}
|
||||
else {
|
||||
foreach ($this -> values as $value) {
|
||||
$return['html'] .= "<li>".$value."</li>\n";
|
||||
}
|
||||
}
|
||||
$return['html'] .= "</ul>\n";
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Retourne le code HTML d'un champ vide
|
||||
*
|
||||
* @retval string Code HTML d'un champ vide.
|
||||
*/
|
||||
function getEmptyField() {
|
||||
$multiple = $this -> getMultipleData();
|
||||
return "<input type='text' name='".$this -> name."[]' id='LSform_".$this -> name."_".rand()."'>".$multiple;
|
||||
}
|
||||
* Retourne le code HTML d'un champ vide
|
||||
*
|
||||
* @retval string Code HTML d'un champ vide.
|
||||
*/
|
||||
function getEmptyField() {
|
||||
$multiple = $this -> getMultipleData();
|
||||
return "<input type='text' name='".$this -> name."[]' id='LSform_".$this -> name."_".rand()."'>".$multiple;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -40,45 +40,43 @@ class LSformElement_textarea extends LSformElement {
|
|||
* @retval array
|
||||
*/
|
||||
function getDisplay(){
|
||||
$return = $this -> getLabelInfos();
|
||||
// value
|
||||
if (!$this -> isFreeze()) {
|
||||
$return['html'] = "<ul class='LSform'>\n";
|
||||
if (empty($this -> values)) {
|
||||
$return['html'] = "<li>".$this -> getEmptyField()."</li>\n";
|
||||
}
|
||||
else {
|
||||
$multiple = $this -> getMultipleData();
|
||||
foreach($this -> values as $value) {
|
||||
$id = "LSform_".$this -> name."_".rand();
|
||||
$return['html'].="<li><textarea name='".$this -> name."[]' id='".$id."'>".$value."</textarea>\n".$multiple."</li>";
|
||||
}
|
||||
}
|
||||
$return['html'] .= "</ul>\n";
|
||||
}
|
||||
else {
|
||||
$return['html'] = "<ul class='LSform'>\n";
|
||||
if (empty($this -> values)) {
|
||||
$return['html'].="<li>"._('Aucunes valeur definie')."</li>\n";
|
||||
}
|
||||
else {
|
||||
foreach ($this -> values as $value) {
|
||||
$return['html'].="<li>".$value."</li>\n";
|
||||
}
|
||||
}
|
||||
$return['html'] .= "</ul>\n";
|
||||
}
|
||||
return $return;
|
||||
$return = $this -> getLabelInfos();
|
||||
// value
|
||||
$return['html'] = "<ul class='LSform'>\n";
|
||||
if (!$this -> isFreeze()) {
|
||||
if (empty($this -> values)) {
|
||||
$return['html'] .= "<li class='LSform'>".$this -> getEmptyField()."</li>\n";
|
||||
}
|
||||
else {
|
||||
foreach($this -> values as $value) {
|
||||
$multiple = $this -> getMultipleData();
|
||||
$id = "LSform_".$this -> name."_".rand();
|
||||
$return['html'].="<li class='LSform'><textarea name='".$this -> name."[]' id='".$id."' class='LSform'>".$value."</textarea>\n".$multiple."</li>";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (empty($this -> values)) {
|
||||
$return['html'].="<li class='LSform'>"._('Aucunes valeur definie')."</li>\n";
|
||||
}
|
||||
else {
|
||||
foreach ($this -> values as $value) {
|
||||
$return['html'].="<li class='LSform'>".$value."</li>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$return['html'] .= "</ul>\n";
|
||||
return $return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Retourne le code HTML d'un champ vide
|
||||
*
|
||||
* @retval string Code HTML d'un champ vide.
|
||||
*/
|
||||
function getEmptyField() {
|
||||
$multiple = $this -> getMultipleData();
|
||||
return "<textarea name='".$this -> name."[]' id='LSform".$this -> name."_".rand()."'></textarea>\n".$multiple;
|
||||
* Retourne le code HTML d'un champ vide
|
||||
*
|
||||
* @retval string Code HTML d'un champ vide.
|
||||
*/
|
||||
function getEmptyField() {
|
||||
$multiple = $this -> getMultipleData();
|
||||
return "<textarea name='".$this -> name."[]' id='LSform".$this -> name."_".rand()."' class='LSform'></textarea>\n".$multiple;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,14 +30,16 @@ $GLOBALS['LSsession'] -> loadLSclass('LSattribute');
|
|||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
class LSldapObject {
|
||||
|
||||
var $config;
|
||||
var $type_name;
|
||||
var $attrs;
|
||||
|
||||
var $config;
|
||||
var $type_name;
|
||||
var $attrs;
|
||||
var $forms;
|
||||
var $view;
|
||||
var $dn=false;
|
||||
var $other_values=array();
|
||||
var $submitError=true;
|
||||
var $_whoami=NULL;
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
|
@ -51,27 +53,27 @@ class LSldapObject {
|
|||
* @param[in] $config array La configuration de l'objet
|
||||
*
|
||||
* @retval boolean true si l'objet a été construit, false sinon.
|
||||
*/
|
||||
function LSldapObject($type_name,$config='auto') {
|
||||
$this -> type_name = $type_name;
|
||||
*/
|
||||
function LSldapObject($type_name,$config='auto') {
|
||||
$this -> type_name = $type_name;
|
||||
$this -> config = $config;
|
||||
if($config=='auto') {
|
||||
if(isset($GLOBALS['LSobjects'][$type_name])) {
|
||||
$this -> config = $GLOBALS['LSobjects'][$type_name];
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(21);
|
||||
return;
|
||||
}
|
||||
}
|
||||
foreach($this -> config['attrs'] as $attr_name => $attr_config) {
|
||||
if(!$this -> attrs[$attr_name]=new LSattribute($attr_name,$attr_config,$this)) {
|
||||
if(isset($GLOBALS['LSobjects'][$type_name])) {
|
||||
$this -> config = $GLOBALS['LSobjects'][$type_name];
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(21);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach($this -> config['attrs'] as $attr_name => $attr_config) {
|
||||
if(!$this -> attrs[$attr_name]=new LSattribute($attr_name,$attr_config,$this)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Charge les données de l'objet
|
||||
*
|
||||
|
@ -83,15 +85,15 @@ class LSldapObject {
|
|||
* @param[in] $dn string Le DN de l'objet.
|
||||
*
|
||||
* @retval boolean true si la chargement a réussi, false sinon.
|
||||
*/
|
||||
*/
|
||||
function loadData($dn) {
|
||||
$this -> dn = $dn;
|
||||
$data = $GLOBALS['LSldap'] -> getAttrs($dn);
|
||||
foreach($this -> attrs as $attr_name => $attr) {
|
||||
if(!$this -> attrs[$attr_name] -> loadData($data[$attr_name]))
|
||||
return;
|
||||
}
|
||||
return true;
|
||||
$this -> dn = $dn;
|
||||
$data = $GLOBALS['LSldap'] -> getAttrs($dn);
|
||||
foreach($this -> attrs as $attr_name => $attr) {
|
||||
if(!$this -> attrs[$attr_name] -> loadData($data[$attr_name]))
|
||||
return;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -100,7 +102,7 @@ class LSldapObject {
|
|||
* @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) {
|
||||
|
@ -116,10 +118,10 @@ class LSldapObject {
|
|||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval string Format d'affichage de l'objet.
|
||||
*/
|
||||
function getDisplayAttributes() {
|
||||
return $this -> config['select_display_attrs'];
|
||||
}
|
||||
*/
|
||||
function getDisplayAttributes() {
|
||||
return $this -> config['select_display_attrs'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne la valeur descriptive d'affichage de l'objet
|
||||
|
@ -132,7 +134,7 @@ class LSldapObject {
|
|||
* @param[in] $spe [<i>optionnel</i>] string Format d'affichage de l'objet
|
||||
*
|
||||
* @retval string Valeur descriptive d'affichage de l'objet
|
||||
*/
|
||||
*/
|
||||
function getDisplayValue($spe='') {
|
||||
if ($spe=='') {
|
||||
$spe = $this -> getDisplayAttributes();
|
||||
|
@ -151,7 +153,7 @@ class LSldapObject {
|
|||
* @param[in] $format string Format de la chaine
|
||||
*
|
||||
* @retval string Valeur d'une chaine formatée
|
||||
*/
|
||||
*/
|
||||
function getFData($format) {
|
||||
$format=getFData($format,$this,'getValue');
|
||||
return $format;
|
||||
|
@ -169,9 +171,9 @@ class LSldapObject {
|
|||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval LSform Le formulaire crée
|
||||
*/
|
||||
*/
|
||||
function getForm($idForm,$config=array()) {
|
||||
$GLOBALS['LSsession'] -> loadLSclass('LSform');
|
||||
$GLOBALS['LSsession'] -> loadLSclass('LSform');
|
||||
$LSform = new LSform($this,$idForm);
|
||||
$this -> forms[$idForm] = array($LSform,$config);
|
||||
foreach($this -> attrs as $attr_name => $attr) {
|
||||
|
@ -182,6 +184,29 @@ class LSldapObject {
|
|||
return $LSform;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construit un formulaire de l'objet
|
||||
*
|
||||
* Cette méthode construit un formulaire LSform à partir de la configuration de l'objet
|
||||
* et de chaque attribut.
|
||||
*
|
||||
* @param[in] $idForm [<b>required</b>] Identifiant du formulaire a créer
|
||||
* @param[in] $config Configuration spécifique pour le formulaire
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval LSform Le formulaire crée
|
||||
*/
|
||||
function getView() {
|
||||
$GLOBALS['LSsession'] -> loadLSclass('LSform');
|
||||
$this -> view = new LSform($this,'view');
|
||||
foreach($this -> attrs as $attr_name => $attr) {
|
||||
$this -> attrs[$attr_name] -> addToView($this -> view);
|
||||
}
|
||||
$this -> view -> can_validate = false;
|
||||
return $this -> view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rafraichis le formulaire de l'objet
|
||||
*
|
||||
|
@ -192,7 +217,7 @@ class LSldapObject {
|
|||
* @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) {
|
||||
|
@ -216,7 +241,7 @@ class LSldapObject {
|
|||
*
|
||||
* @see validateAttrsData()
|
||||
* @see submitChange()
|
||||
*/
|
||||
*/
|
||||
function updateData($idForm=NULL) {
|
||||
if($idForm!=NULL) {
|
||||
if(isset($this -> forms[$idForm]))
|
||||
|
@ -246,7 +271,7 @@ class LSldapObject {
|
|||
}
|
||||
}
|
||||
if($this -> validateAttrsData($idForm)) {
|
||||
debug("les données sont validées");
|
||||
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)) {
|
||||
|
@ -260,7 +285,7 @@ class LSldapObject {
|
|||
}
|
||||
}
|
||||
if ($this -> submitChange($idForm)) {
|
||||
debug('Les modifications sont submitées');
|
||||
debug('Les modifications sont submitées');
|
||||
$this -> submitError = false;
|
||||
$this -> reloadData();
|
||||
$this -> refreshForm($idForm);
|
||||
|
@ -286,37 +311,37 @@ class LSldapObject {
|
|||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval boolean true si les données sont valides, false sinon
|
||||
*/
|
||||
*/
|
||||
function validateAttrsData($idForm) {
|
||||
$LSform=$this -> forms[$idForm][0];
|
||||
foreach($this -> attrs as $attr) {
|
||||
if (!$attr -> 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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -330,109 +355,109 @@ class LSldapObject {
|
|||
*
|
||||
* @retval boolean true si les données sont valides, false sinon
|
||||
*/
|
||||
function validateAttrData(&$LSform,&$attr) {
|
||||
$vconfig=$attr -> getValidateConfig();
|
||||
function validateAttrData(&$LSform,&$attr) {
|
||||
$vconfig=$attr -> getValidateConfig();
|
||||
|
||||
$data=$attr -> getUpdateData();
|
||||
if(!is_array($data)) {
|
||||
$data=array($data);
|
||||
}
|
||||
$data=$attr -> getUpdateData();
|
||||
if(!is_array($data)) {
|
||||
$data=array($data);
|
||||
}
|
||||
|
||||
// Validation des valeurs de l'attribut
|
||||
// Validation des valeurs de l'attribut
|
||||
if(is_array($vconfig)) {
|
||||
foreach($vconfig as $test) {
|
||||
// Définition du basedn par défaut
|
||||
if (!isset($test['basedn'])) {
|
||||
$test['basedn']=$GLOBALS['LSsession']->topDn;
|
||||
}
|
||||
foreach($vconfig as $test) {
|
||||
// Définition du basedn par défaut
|
||||
if (!isset($test['basedn'])) {
|
||||
$test['basedn']=$GLOBALS['LSsession']->topDn;
|
||||
}
|
||||
|
||||
// Définition du message d'erreur
|
||||
if (!empty($test['msg'])) {
|
||||
$msg_error=getFData($test['msg'],$this,'getValue');
|
||||
}
|
||||
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']();
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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']();
|
||||
$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();
|
||||
$attr -> validate();
|
||||
unset($this -> other_values['val']);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Met à jour les données modifiés dans l'annuaire
|
||||
|
@ -442,7 +467,7 @@ class LSldapObject {
|
|||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval boolean true si la mise à jour a réussi, false sinon
|
||||
*/
|
||||
*/
|
||||
function submitChange($idForm) {
|
||||
$submitData=array();
|
||||
foreach($this -> attrs as $attr) {
|
||||
|
@ -453,12 +478,12 @@ class LSldapObject {
|
|||
if(!empty($submitData)) {
|
||||
$dn=$this -> getDn();
|
||||
if($dn) {
|
||||
debug($submitData);
|
||||
debug($submitData);
|
||||
return $GLOBALS['LSldap'] -> update($this -> type_name,$dn, $submitData);
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(33);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -473,7 +498,7 @@ class LSldapObject {
|
|||
* @retval array Tableau :
|
||||
* - [0] : le premier paramètre
|
||||
* - [1] : les paramètres suivants
|
||||
*/
|
||||
*/
|
||||
function getDnInfos($dn) {
|
||||
$infos=ldap_explode_dn($dn,0);
|
||||
if(!$infos)
|
||||
|
@ -489,95 +514,13 @@ class LSldapObject {
|
|||
return array($infos[0],$basedn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fait la somme de DN
|
||||
*
|
||||
* Retourne un DN qui correspond au point de séparation des DN si les DN
|
||||
* ne sont pas dans la meme dans la meme branche ou le dn le plus long sinon.
|
||||
*
|
||||
* @param[in] $dn Un premier DN.
|
||||
* @param[in] $dn Un deuxième DN.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval string Un DN (ou false si les DN ne sont pas valide)
|
||||
*/
|
||||
function sumDn($dn1,$dn2) {
|
||||
$infos1=ldap_explode_dn($dn1,0);
|
||||
if(!$infos1)
|
||||
return;
|
||||
$infos2=ldap_explode_dn($dn2,0);
|
||||
if(!$infos2)
|
||||
return;
|
||||
if($infos2['count']>$infos1['count']) {
|
||||
$tmp=$infos1;
|
||||
$infos1=$infos2;
|
||||
$infos2=$tmp;
|
||||
}
|
||||
$infos1=array_reverse($infos1);
|
||||
$infos2=array_reverse($infos2);
|
||||
|
||||
$first=true;
|
||||
$basedn='';
|
||||
for($i=0;$i<$infos1['count'];$i++) {
|
||||
if(($infos1[$i]==$infos2[$i])||(!isset($infos2[$i]))) {
|
||||
if($first) {
|
||||
$basedn=$infos1[$i];
|
||||
$first=false;
|
||||
}
|
||||
else
|
||||
$basedn=$infos1[$i].','.$basedn;
|
||||
}
|
||||
else {
|
||||
return $basedn;
|
||||
}
|
||||
}
|
||||
return $basedn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifie la compatibilite des DN
|
||||
*
|
||||
* Vérifie que les DNs sont dans la même branche de l'annuaire.
|
||||
*
|
||||
* @param[in] $dn Un premier DN.
|
||||
* @param[in] $dn Un deuxième DN.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval boolean true si les DN sont compatibles, false sinon.
|
||||
*/
|
||||
function isCompatibleDNs($dn1,$dn2) {
|
||||
$infos1=ldap_explode_dn($dn1,0);
|
||||
if(!$infos1)
|
||||
return;
|
||||
$infos2=ldap_explode_dn($dn2,0);
|
||||
if(!$infos2)
|
||||
return;
|
||||
if($infos2['count']>$infos1['count']) {
|
||||
$tmp=$infos1;
|
||||
$infos1=$infos2;
|
||||
$infos2=$tmp;
|
||||
}
|
||||
$infos1=array_reverse($infos1);
|
||||
$infos2=array_reverse($infos2);
|
||||
|
||||
for($i=0;$i<$infos1['count'];$i++) {
|
||||
if(($infos1[$i]==$infos2[$i])||(!isset($infos2[$i])))
|
||||
continue;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le filtre correpondants aux objetcClass de l'objet
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval string le filtre ldap correspondant au type de l'objet
|
||||
*/
|
||||
*/
|
||||
function getObjectFilter() {
|
||||
if(!isset($this -> config['objectclass'])) return;
|
||||
foreach ($this -> config['objectclass'] as $class)
|
||||
|
@ -598,7 +541,7 @@ class LSldapObject {
|
|||
* @param[in] $params array Paramètres de recherche au format Net_LDAP::search()
|
||||
*
|
||||
* @retval array Tableau d'objet correspondant au resultat de la recherche
|
||||
*/
|
||||
*/
|
||||
function listObjects($filter='',$basedn=NULL,$params=array()) {
|
||||
$retInfos=array();
|
||||
$attrs=false;
|
||||
|
@ -787,10 +730,10 @@ class LSldapObject {
|
|||
return $retInfos;
|
||||
}
|
||||
|
||||
function searchObject($name,$basedn=NULL) {
|
||||
$filter = $this -> config['rdn'].'='.$name;
|
||||
return $this -> listObjects($filter,$basedn);
|
||||
}
|
||||
function searchObject($name,$basedn=NULL) {
|
||||
$filter = $this -> config['rdn'].'='.$name;
|
||||
return $this -> listObjects($filter,$basedn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne une valeur de l'objet
|
||||
|
@ -808,14 +751,14 @@ class LSldapObject {
|
|||
* @param[in] $val string Le nom de la valeur demandée
|
||||
*
|
||||
* @retval mixed la valeur demandé ou ' ' si celle-ci est inconnue.
|
||||
*/
|
||||
*/
|
||||
function getValue($val) {
|
||||
if(($val=='dn')||($val=='%{dn}')) {
|
||||
return $this -> dn;
|
||||
}
|
||||
else if(($val=='rdn')||($val=='%{rdn}')) {
|
||||
return $this -> attrs[ $this -> config['rdn'] ] -> getValue();
|
||||
}
|
||||
else if(($val=='rdn')||($val=='%{rdn}')) {
|
||||
return $this -> attrs[ $this -> config['rdn'] ] -> getValue();
|
||||
}
|
||||
else if(isset($this -> attrs[$val])){
|
||||
if (method_exists($this -> attrs[$val],'getValue'))
|
||||
return $this -> attrs[$val] -> getValue();
|
||||
|
@ -830,38 +773,38 @@ class LSldapObject {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourn une liste d'option pour un select d'un objet du même type
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval string HTML code
|
||||
*/
|
||||
function getSelectOptions() {
|
||||
$list = $this -> listObjects();
|
||||
$display='';
|
||||
foreach($list as $object) {
|
||||
$display.="<option value=\"".$object -> getDn()."\">".$object -> getDisplayValue()."</option>\n";
|
||||
}
|
||||
return $display;
|
||||
}
|
||||
/**
|
||||
* Retourn une liste d'option pour un select d'un objet du même type
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval string HTML code
|
||||
*/
|
||||
function getSelectOptions() {
|
||||
$list = $this -> listObjects();
|
||||
$display='';
|
||||
foreach($list as $object) {
|
||||
$display.="<option value=\"".$object -> getDn()."\">".$object -> getDisplayValue()."</option>\n";
|
||||
}
|
||||
return $display;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourn un tableau pour un select d'un objet du même type
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval array['dn','display']
|
||||
*/
|
||||
function getSelectArray() {
|
||||
$list = $this -> listObjects();
|
||||
$return=array();
|
||||
foreach($list as $object) {
|
||||
$return['dn'][] = $object -> getDn();
|
||||
$return['display'][] = $object -> getDisplayValue();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
/**
|
||||
* Retourn un tableau pour un select d'un objet du même type
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval array['dn','display']
|
||||
*/
|
||||
function getSelectArray() {
|
||||
$list = $this -> listObjects();
|
||||
$return=array();
|
||||
foreach($list as $object) {
|
||||
$return['dn'][] = $object -> getDn();
|
||||
$return['display'][] = $object -> getDisplayValue();
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le DN de l'objet
|
||||
|
@ -872,7 +815,7 @@ class LSldapObject {
|
|||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval string Le DN de l'objet
|
||||
*/
|
||||
*/
|
||||
function getDn() {
|
||||
if($this -> dn) {
|
||||
return $this -> dn;
|
||||
|
@ -896,14 +839,32 @@ class LSldapObject {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le type de l'objet
|
||||
*
|
||||
* @retval string Le type de l'objet ($this -> type_name)
|
||||
*/
|
||||
function getType() {
|
||||
return $this -> type_name;
|
||||
}
|
||||
/**
|
||||
* Retourne le type de l'objet
|
||||
*
|
||||
* @retval string Le type de l'objet ($this -> type_name)
|
||||
*/
|
||||
function getType() {
|
||||
return $this -> type_name;
|
||||
}
|
||||
|
||||
function whoami() {
|
||||
if (!$this -> _whoami)
|
||||
$this -> _whoami = $GLOBALS['LSsession'] -> whoami($this -> dn);
|
||||
return $this -> _whoami;
|
||||
}
|
||||
|
||||
function getLabel() {
|
||||
return $this -> config['label'];
|
||||
}
|
||||
|
||||
function __sleep() {
|
||||
return ( array_keys( get_object_vars( &$this ) ) );
|
||||
}
|
||||
|
||||
function __wakeup() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -87,17 +87,17 @@ function getFData($format,$data,$meth=NULL) {
|
|||
}
|
||||
|
||||
function loadDir($dir,$regexpr='^.*\.php$') {
|
||||
if ($handle = opendir($dir)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if (ereg($regexpr,$file)) {
|
||||
require_once($dir.'/'.$file);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
die(_('Dossier introuvable ('.$dir.').'));
|
||||
}
|
||||
return true;
|
||||
if ($handle = opendir($dir)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if (ereg($regexpr,$file)) {
|
||||
require_once($dir.'/'.$file);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
die(_('Dossier introuvable ('.$dir.').'));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,26 +111,113 @@ function return_data($data) {
|
|||
}
|
||||
|
||||
function debug($data,$get=true) {
|
||||
if ($get) {
|
||||
if (is_array($data)) {
|
||||
$GLOBALS['LSdebug']['fields'][]=$data;
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSdebug']['fields'][]="[$data]";
|
||||
}
|
||||
}
|
||||
return true;
|
||||
if ($get) {
|
||||
if (is_array($data)) {
|
||||
$GLOBALS['LSdebug']['fields'][]=$data;
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSdebug']['fields'][]="[$data]";
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function debug_print() {
|
||||
if (( $GLOBALS['LSdebug']['fields'] ) && ( $GLOBALS['LSdebug']['active'] )) {
|
||||
$txt='<ul>';
|
||||
foreach($GLOBALS['LSdebug']['fields'] as $debug) {
|
||||
$txt.='<li>'.$debug.'</li>';
|
||||
}
|
||||
$txt.='</ul>';
|
||||
$GLOBALS['Smarty'] -> assign('LSdebug',$txt);
|
||||
}
|
||||
if (( $GLOBALS['LSdebug']['fields'] ) && ( $GLOBALS['LSdebug']['active'] )) {
|
||||
$txt='<ul>';
|
||||
foreach($GLOBALS['LSdebug']['fields'] as $debug) {
|
||||
if (is_array($debug)) {
|
||||
$txt.='<li><pre>'.print_r($debug,true).'</pre></li>';
|
||||
}
|
||||
else {
|
||||
$txt.='<li>'.$debug.'</li>';
|
||||
}
|
||||
}
|
||||
$txt.='</ul>';
|
||||
$GLOBALS['Smarty'] -> assign('LSdebug',$txt);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifie la compatibilite des DN
|
||||
*
|
||||
* Vérifie que les DNs sont dans la même branche de l'annuaire.
|
||||
*
|
||||
* @param[in] $dn Un premier DN.
|
||||
* @param[in] $dn Un deuxième DN.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval boolean true si les DN sont compatibles, false sinon.
|
||||
*/
|
||||
function isCompatibleDNs($dn1,$dn2) {
|
||||
$infos1=ldap_explode_dn($dn1,0);
|
||||
if(!$infos1)
|
||||
return;
|
||||
$infos2=ldap_explode_dn($dn2,0);
|
||||
if(!$infos2)
|
||||
return;
|
||||
if($infos2['count']>$infos1['count']) {
|
||||
$tmp=$infos1;
|
||||
$infos1=$infos2;
|
||||
$infos2=$tmp;
|
||||
}
|
||||
$infos1=array_reverse($infos1);
|
||||
$infos2=array_reverse($infos2);
|
||||
|
||||
for($i=0;$i<$infos1['count'];$i++) {
|
||||
if(($infos1[$i]==$infos2[$i])||(!isset($infos2[$i])))
|
||||
continue;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fait la somme de DN
|
||||
*
|
||||
* Retourne un DN qui correspond au point de séparation des DN si les DN
|
||||
* ne sont pas dans la meme dans la meme branche ou le dn le plus long sinon.
|
||||
*
|
||||
* @param[in] $dn Un premier DN.
|
||||
* @param[in] $dn Un deuxième DN.
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @retval string Un DN (ou false si les DN ne sont pas valide)
|
||||
*/
|
||||
function sumDn($dn1,$dn2) {
|
||||
$infos1=ldap_explode_dn($dn1,0);
|
||||
if(!$infos1)
|
||||
return;
|
||||
$infos2=ldap_explode_dn($dn2,0);
|
||||
if(!$infos2)
|
||||
return;
|
||||
if($infos2['count']>$infos1['count']) {
|
||||
$tmp=$infos1;
|
||||
$infos1=$infos2;
|
||||
$infos2=$tmp;
|
||||
}
|
||||
$infos1=array_reverse($infos1);
|
||||
$infos2=array_reverse($infos2);
|
||||
|
||||
$first=true;
|
||||
$basedn='';
|
||||
for($i=0;$i<$infos1['count'];$i++) {
|
||||
if(($infos1[$i]==$infos2[$i])||(!isset($infos2[$i]))) {
|
||||
if($first) {
|
||||
$basedn=$infos1[$i];
|
||||
$first=false;
|
||||
}
|
||||
else
|
||||
$basedn=$infos1[$i].','.$basedn;
|
||||
}
|
||||
else {
|
||||
return $basedn;
|
||||
}
|
||||
}
|
||||
return $basedn;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -1,54 +1,55 @@
|
|||
var LSdefault = new Class({
|
||||
initialize: function(){
|
||||
LSdebug('toto');
|
||||
this.LSdebug = $('LSdebug');
|
||||
this.LSdebugInfos = $('LSdebug_infos');
|
||||
this.LSdebug.setOpacity(0);
|
||||
if (this.LSdebugInfos.innerHTML != '') {
|
||||
this.displayDebugBox();
|
||||
}
|
||||
LSdebug('toto');
|
||||
this.LSdebug = $('LSdebug');
|
||||
this.LSdebugInfos = $('LSdebug_infos');
|
||||
this.LSdebug.setOpacity(0);
|
||||
if (this.LSdebugInfos.innerHTML != '') {
|
||||
this.displayDebugBox();
|
||||
}
|
||||
|
||||
this.LSdebugHidden = $('LSdebug_hidden');
|
||||
this.LSdebugHidden.addEvent('click',this.onLSdebugHiddenClick.bind(this));
|
||||
this.LSerror = $('LSerror');
|
||||
this.LSerror.setOpacity(0);
|
||||
if (this.LSerror.innerHTML != '') {
|
||||
this.displayLSerror();
|
||||
}
|
||||
this.LSdebugHidden = $('LSdebug_hidden');
|
||||
this.LSdebugHidden.addEvent('click',this.onLSdebugHiddenClick.bindWithEvent(this));
|
||||
this.LSerror = $('LSerror');
|
||||
this.LSerror.setOpacity(0);
|
||||
if (this.LSerror.innerHTML != '') {
|
||||
this.displayLSerror();
|
||||
}
|
||||
},
|
||||
|
||||
onLSdebugHiddenClick: function(){
|
||||
new Fx.Style(this.LSdebug,'opacity',{duration:500}).start(1,0);
|
||||
},
|
||||
onLSdebugHiddenClick: function(event){
|
||||
new Event(event).stop();
|
||||
new Fx.Style(this.LSdebug,'opacity',{duration:500}).start(1,0);
|
||||
},
|
||||
|
||||
displayDebugBox: function() {
|
||||
new Fx.Style(this.LSdebug,'opacity',{duration:500}).start(0,0.8);
|
||||
},
|
||||
displayDebugBox: function() {
|
||||
new Fx.Style(this.LSdebug,'opacity',{duration:500}).start(0,0.8);
|
||||
},
|
||||
|
||||
displayError: function(html) {
|
||||
this.LSerror.empty();
|
||||
this.LSerror.setHTML(html);
|
||||
this.displayLSerror();
|
||||
},
|
||||
displayError: function(html) {
|
||||
this.LSerror.empty();
|
||||
this.LSerror.setHTML(html);
|
||||
this.displayLSerror();
|
||||
},
|
||||
|
||||
displayLSerror: function() {
|
||||
new Fx.Style(this.LSerror,'opacity',{duration:500}).start(0,0.8);
|
||||
(function(){new Fx.Style(this.LSerror,'opacity',{duration:500}).start(0.8,0);}).delay(5000, this);
|
||||
},
|
||||
displayLSerror: function() {
|
||||
new Fx.Style(this.LSerror,'opacity',{duration:500}).start(0,0.8);
|
||||
(function(){new Fx.Style(this.LSerror,'opacity',{duration:500}).start(0.8,0);}).delay(5000, this);
|
||||
},
|
||||
|
||||
loadingImgDisplay: function(el) {
|
||||
this.loading_img = new Element('img');
|
||||
this.loading_img.src='templates/images/ajax-loader.gif';
|
||||
this.loading_img.injectAfter(el);
|
||||
},
|
||||
loadingImgDisplay: function(el) {
|
||||
this.loading_img = new Element('img');
|
||||
this.loading_img.src='templates/images/ajax-loader.gif';
|
||||
this.loading_img.injectAfter(el);
|
||||
},
|
||||
|
||||
loadingImgHide: function() {
|
||||
this.loading_img.remove();
|
||||
}
|
||||
loadingImgHide: function() {
|
||||
this.loading_img.remove();
|
||||
}
|
||||
|
||||
});
|
||||
window.addEvent(window.ie ? 'load' : 'domready', function() {
|
||||
varLSdefault = new LSdefault();
|
||||
varLSdefault = new LSdefault();
|
||||
});
|
||||
|
||||
LSdebug_active = 1;
|
||||
|
|
|
@ -1,70 +1,68 @@
|
|||
var LSform = new Class({
|
||||
initialize: function(){
|
||||
this.objecttype = $('LSform_objecttype').value;
|
||||
this.idform = $('LSform_idform').value;
|
||||
$$('img.LSform-add-field-btn').each(function(el) {
|
||||
el.addEvent('click',this.onAddFieldBtnClick.bind(this,el));
|
||||
}, this);
|
||||
|
||||
$$('img.LSform-add-field-btn').each(function(el) {
|
||||
el.addEvent('click',this.onAddFieldBtnClick.bind(this,el));
|
||||
}, this);
|
||||
|
||||
$$('img.LSform-remove-field-btn').each(function(el) {
|
||||
el.addEvent('click',this.onRemoveFieldBtnClick.bind(this,el));
|
||||
}, this);
|
||||
$$('img.LSform-remove-field-btn').each(function(el) {
|
||||
el.addEvent('click',this.onRemoveFieldBtnClick.bind(this,el));
|
||||
}, this);
|
||||
},
|
||||
|
||||
onAddFieldBtnClick: function(img){
|
||||
|
||||
var getAttrName = /LSform_add_field_btn_(.*)_.*/
|
||||
var attrName = getAttrName.exec(img.id)[1];
|
||||
LSdebug(attrName);
|
||||
onAddFieldBtnClick: function(img){
|
||||
|
||||
var getAttrName = /LSform_add_field_btn_(.*)_.*/
|
||||
var attrName = getAttrName.exec(img.id)[1];
|
||||
LSdebug(attrName);
|
||||
|
||||
var data = {
|
||||
template: 'LSform',
|
||||
action: 'onAddFieldBtnClick',
|
||||
attribute: attrName,
|
||||
objecttype: this.objecttype,
|
||||
idform: this.idform,
|
||||
img: img.id
|
||||
};
|
||||
LSdebug(data);
|
||||
varLSdefault.loadingImgDisplay(img);
|
||||
new Ajax('index_ajax.php', {data: data, onComplete: this.onAddFieldBtnClickComplete.bind(this)}).request();
|
||||
},
|
||||
var data = {
|
||||
template: 'LSform',
|
||||
action: 'onAddFieldBtnClick',
|
||||
attribute: attrName,
|
||||
objecttype: $('LSform_objecttype').value,
|
||||
objectdn: $('LSform_objectdn').value,
|
||||
idform: $('LSform_idform').value,
|
||||
img: img.id
|
||||
};
|
||||
LSdebug(data);
|
||||
varLSdefault.loadingImgDisplay(img);
|
||||
new Ajax('index_ajax.php', {data: data, onComplete: this.onAddFieldBtnClickComplete.bind(this)}).request();
|
||||
},
|
||||
|
||||
onAddFieldBtnClickComplete: function(responseText, responseXML) {
|
||||
varLSdefault.loadingImgHide();
|
||||
var data = Json.evaluate(responseText);
|
||||
LSdebug(data);
|
||||
if ( data ) {
|
||||
if ( typeof(data.LSerror) != "undefined" ) {
|
||||
varLSdefault.displayError(data.LSerror);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
var li = new Element('li');
|
||||
var img = $(data.img);
|
||||
li.setHTML(data.html);
|
||||
li.injectAfter(img.getParent());
|
||||
li.getElements('img[class=LSform-add-field-btn]').each(function(el) {
|
||||
el.addEvent('click',this.onAddFieldBtnClick.bind(this,el));
|
||||
}, this);
|
||||
li.getElements('img[class=LSform-remove-field-btn]').each(function(el) {
|
||||
el.addEvent('click',this.onRemoveFieldBtnClick.bind(this,el));
|
||||
}, this);
|
||||
}
|
||||
}
|
||||
},
|
||||
onAddFieldBtnClickComplete: function(responseText, responseXML) {
|
||||
varLSdefault.loadingImgHide();
|
||||
var data = Json.evaluate(responseText);
|
||||
LSdebug(data);
|
||||
if ( data ) {
|
||||
if ( typeof(data.LSerror) != "undefined" ) {
|
||||
varLSdefault.displayError(data.LSerror);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
var li = new Element('li');
|
||||
var img = $(data.img);
|
||||
li.setHTML(data.html);
|
||||
li.injectAfter(img.getParent());
|
||||
li.getElements('img[class=LSform-add-field-btn]').each(function(el) {
|
||||
el.addEvent('click',this.onAddFieldBtnClick.bind(this,el));
|
||||
}, this);
|
||||
li.getElements('img[class=LSform-remove-field-btn]').each(function(el) {
|
||||
el.addEvent('click',this.onRemoveFieldBtnClick.bind(this,el));
|
||||
}, this);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onRemoveFieldBtnClick: function(img) {
|
||||
if (img.getParent().getParent().getChildren().length == 1) {
|
||||
img.getPrevious().getPrevious().value='';
|
||||
}
|
||||
else {
|
||||
img.getParent().remove();
|
||||
}
|
||||
}
|
||||
onRemoveFieldBtnClick: function(img) {
|
||||
if (img.getParent().getParent().getChildren().length == 1) {
|
||||
img.getPrevious().getPrevious().value='';
|
||||
}
|
||||
else {
|
||||
img.getParent().remove();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
window.addEvent(window.ie ? 'load' : 'domready', function() {
|
||||
varLSform = new LSform();
|
||||
varLSform = new LSform();
|
||||
});
|
||||
|
|
31
trunk/includes/js/LSview.js
Normal file
31
trunk/includes/js/LSview.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
var LSview = new Class({
|
||||
initialize: function(){
|
||||
$$('td.LSobject-list-names').each(function(el) {
|
||||
el.addEvent('click',this.onTdLSobjectListNamesClick.bind(this,el));
|
||||
}, this);
|
||||
$$('td.LSobject-list-names').each(function(el) {
|
||||
el.addEvent('mouseenter',this.onTdLSobjectListNamesOver.bind(this,el));
|
||||
}, this);
|
||||
$$('td.LSobject-list-names').each(function(el) {
|
||||
el.addEvent('mouseleave',this.onTdLSobjectListNamesOut.bind(this,el));
|
||||
}, this);
|
||||
},
|
||||
|
||||
onTdLSobjectListNamesClick: function(td) {
|
||||
window.location=td.getFirst().href;
|
||||
},
|
||||
|
||||
onTdLSobjectListNamesOver: function(td){
|
||||
td.imgEdit = new Element('img');
|
||||
td.imgEdit.src = 'templates/images/view.png';
|
||||
td.imgEdit.injectInside(td);
|
||||
},
|
||||
|
||||
onTdLSobjectListNamesOut: function(td) {
|
||||
td.imgEdit.remove();
|
||||
}
|
||||
|
||||
});
|
||||
window.addEvent(window.ie ? 'load' : 'domready', function() {
|
||||
varLSview = new LSview();
|
||||
});
|
|
@ -27,32 +27,14 @@ $GLOBALS['LSsession'] = new LSsession();
|
|||
|
||||
if($LSsession -> startLSsession()) {
|
||||
|
||||
// Définition du Titre de la page
|
||||
$GLOBALS['Smarty'] -> assign('pagetitle',_('Mon compte'));
|
||||
// Définition du Titre de la page
|
||||
$GLOBALS['Smarty'] -> assign('pagetitle',_('Accueil'));
|
||||
|
||||
// ---- les objets LDAP
|
||||
// Création d'un LSeepeople
|
||||
$eepeople = new LSeepeople();
|
||||
|
||||
// Chargement des données de l'objet depuis l'annuaire et à partir de son DN
|
||||
$eepeople-> loadData($GLOBALS['LSsession']->dn);
|
||||
|
||||
// Création d'un formulaire à partir pour notre objet LDAP
|
||||
$form=$eepeople -> getForm('test');
|
||||
|
||||
// Gestion de sa validation
|
||||
if ($form->validate()) {
|
||||
// MàJ des données de l'objet LDAP
|
||||
$eepeople -> updateData('test');
|
||||
}
|
||||
// Affichage du formulaire
|
||||
$form -> display();
|
||||
|
||||
// Template
|
||||
$GLOBALS['LSsession'] -> setTemplate('base.tpl');
|
||||
// Template
|
||||
$GLOBALS['LSsession'] -> setTemplate('accueil.tpl');
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSsession'] -> setTemplate('login.tpl');
|
||||
$GLOBALS['LSsession'] -> setTemplate('login.tpl');
|
||||
}
|
||||
|
||||
// Affichage des retours d'erreurs
|
||||
|
|
|
@ -7,62 +7,63 @@ $GLOBALS['LSsession'] = new LSsession();
|
|||
$GLOBALS['LSsession'] -> loadLSobjects();
|
||||
|
||||
if ($_REQUEST['template'] != 'login') {
|
||||
if ( !$GLOBALS['LSsession'] -> startLSsession() ) {
|
||||
echo json_encode(array('LSerror' => 'LSsession : Impossible d\'initialiser la LSsession.' ));
|
||||
}
|
||||
if ( !$GLOBALS['LSsession'] -> startLSsession() ) {
|
||||
echo json_encode(array('LSerror' => 'LSsession : Impossible d\'initialiser la LSsession.' ));
|
||||
}
|
||||
}
|
||||
switch($_REQUEST['template']) {
|
||||
case 'login':
|
||||
switch($_REQUEST['action']) {
|
||||
case 'onLdapServerChanged':
|
||||
if ( isset($_REQUEST['server']) ) {
|
||||
$GLOBALS['LSsession'] -> setLdapServer($_REQUEST['server']);
|
||||
if ( $GLOBALS['LSsession'] -> LSldapConnect() ) {
|
||||
$list = $GLOBALS['LSsession'] -> getSubDnLdapServerOptions();
|
||||
if (is_string($list)) {
|
||||
$list="<select name='LSsession_topDn' id='LSsession_topDn'>".$list."</select>";
|
||||
$data = array('list_topDn' => $list);
|
||||
}
|
||||
else if (is_array($list)){
|
||||
$data = array('LSerror' => $GLOBALS['LSerror']->getErrors());
|
||||
}
|
||||
else {
|
||||
$data = null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$data = array('LSerror' => $GLOBALS['LSerror']->getErrors());
|
||||
}
|
||||
}
|
||||
else {
|
||||
$data=NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'LSform':
|
||||
switch($_REQUEST['action']) {
|
||||
case 'onAddFieldBtnClick':
|
||||
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['idform'])) && (isset($_REQUEST['img'])) ) {
|
||||
$object = new $_REQUEST['objecttype']();
|
||||
$form = $object -> getForm($_REQUEST['idform']);
|
||||
$emptyField=$form -> getEmptyField($_REQUEST['attribute']);
|
||||
if ( $emptyField ) {
|
||||
$data = array(
|
||||
'html' => $form -> getEmptyField($_REQUEST['attribute']),
|
||||
'img' => $_REQUEST['img'],
|
||||
);
|
||||
}
|
||||
else {
|
||||
$data = array('LSerror' => $GLOBALS['LSerror']->getErrors());
|
||||
}
|
||||
}
|
||||
else {
|
||||
$data=NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'login':
|
||||
switch($_REQUEST['action']) {
|
||||
case 'onLdapServerChanged':
|
||||
if ( isset($_REQUEST['server']) ) {
|
||||
$GLOBALS['LSsession'] -> setLdapServer($_REQUEST['server']);
|
||||
if ( $GLOBALS['LSsession'] -> LSldapConnect() ) {
|
||||
$list = $GLOBALS['LSsession'] -> getSubDnLdapServerOptions();
|
||||
if (is_string($list)) {
|
||||
$list="<select name='LSsession_topDn' id='LSsession_topDn'>".$list."</select>";
|
||||
$data = array('list_topDn' => $list);
|
||||
}
|
||||
else if (is_array($list)){
|
||||
$data = array('LSerror' => $GLOBALS['LSerror']->getErrors());
|
||||
}
|
||||
else {
|
||||
$data = null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$data = array('LSerror' => $GLOBALS['LSerror']->getErrors());
|
||||
}
|
||||
}
|
||||
else {
|
||||
$data=NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'LSform':
|
||||
switch($_REQUEST['action']) {
|
||||
case 'onAddFieldBtnClick':
|
||||
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['objectdn'])) && (isset($_REQUEST['idform'])) && (isset($_REQUEST['img'])) ) {
|
||||
$object = new $_REQUEST['objecttype']();
|
||||
$object -> loadData($_REQUEST['objectdn']);
|
||||
$form = $object -> getForm($_REQUEST['idform']);
|
||||
$emptyField=$form -> getEmptyField($_REQUEST['attribute']);
|
||||
if ( $emptyField ) {
|
||||
$data = array(
|
||||
'html' => $form -> getEmptyField($_REQUEST['attribute']),
|
||||
'img' => $_REQUEST['img'],
|
||||
);
|
||||
}
|
||||
else {
|
||||
$data = array('LSerror' => $GLOBALS['LSerror']->getErrors());
|
||||
}
|
||||
}
|
||||
else {
|
||||
$data=NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
echo json_encode($data);
|
||||
|
|
65
trunk/modify.php
Normal file
65
trunk/modify.php
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?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.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
require_once 'includes/functions.php';
|
||||
require_once 'includes/class/class.LSsession.php';
|
||||
|
||||
$GLOBALS['LSsession'] = new LSsession();
|
||||
|
||||
if($LSsession -> startLSsession()) {
|
||||
|
||||
// Définition du Titre de la page
|
||||
$GLOBALS['Smarty'] -> assign('pagetitle',_('Modifier'));
|
||||
|
||||
// Création d'un LSobject
|
||||
if (class_exists($_GET['LSobject'])) {
|
||||
debug('me : '.$GLOBALS['LSsession'] -> whoami($_GET['dn']));
|
||||
if ( $GLOBALS['LSsession'] -> whoami($_GET['dn']) != 'user' ) {
|
||||
$object = new $_GET['LSobject']();
|
||||
if ($object -> loadData($_GET['dn'])) {
|
||||
$form = $object -> getForm('test');
|
||||
if ($form->validate()) {
|
||||
// MàJ des données de l'objet LDAP
|
||||
$object -> updateData('test');
|
||||
}
|
||||
$form -> display();
|
||||
}
|
||||
else debug('erreur durant le chargement du dn');
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1011);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(21);
|
||||
}
|
||||
|
||||
// Template
|
||||
$GLOBALS['LSsession'] -> setTemplate('modify.tpl');
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSsession'] -> setTemplate('login.tpl');
|
||||
}
|
||||
|
||||
// Affichage des retours d'erreurs
|
||||
$GLOBALS['LSsession'] -> displayTemplate();
|
||||
?>
|
39
trunk/templates/accueil.tpl
Normal file
39
trunk/templates/accueil.tpl
Normal file
|
@ -0,0 +1,39 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if}</title>
|
||||
<link rel="stylesheet" type="text/css" href="templates/css/base.css" media="screen" title="Normal" />
|
||||
{$LSsession_css}
|
||||
{$LSsession_js}
|
||||
</head>
|
||||
<body>
|
||||
<div id='LSerror'>
|
||||
{$LSerrors}
|
||||
</div>
|
||||
<div id='LSdebug'>
|
||||
<a href='#' id='LSdebug_hidden'>X</a>
|
||||
<div id='LSdebug_infos'>{if $LSdebug != ''}{$LSdebug}{/if}</div>
|
||||
</div>
|
||||
|
||||
<div id='main'>
|
||||
|
||||
<div id='left'>
|
||||
<img src='templates/images/logo.png' alt='Logo' id='logo'/>
|
||||
<ul class='menu'>
|
||||
{foreach from=$LSaccess item=item key=LSobject}
|
||||
<li class='menu'><a href='view.php?LSobject={$LSobject}' class='menu'>{$item.label}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id='right'>
|
||||
<p id='status'>Connecté en tant que <span id='user_name'>{$LSsession_username}</span></b> <a href='index.php?LSsession_logout'><img src='templates/images/logout.png' alt='Logout' title='Logout' /></a></p>
|
||||
|
||||
{if $pagetitle != ''}<h1>{$pagetitle}</h1>{/if}
|
||||
|
||||
</div>
|
||||
<hr class='spacer' />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,49 +1,49 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if}</title>
|
||||
<link rel="stylesheet" type="text/css" href="templates/css/base.css" media="screen" title="Normal" />
|
||||
{$LSsession_css}
|
||||
{$LSsession_js}
|
||||
</head>
|
||||
<head>
|
||||
<title>LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if}</title>
|
||||
<link rel="stylesheet" type="text/css" href="templates/css/base.css" media="screen" title="Normal" />
|
||||
{$LSsession_css}
|
||||
{$LSsession_js}
|
||||
</head>
|
||||
<body>
|
||||
<div id='LSerror'>
|
||||
{$LSerrors}
|
||||
</div>
|
||||
<div id='LSdebug'>
|
||||
<a href='#' id='LSdebug_hidden'>X</a>
|
||||
<div id='LSdebug_infos'>{if $LSdebug != ''}{$LSdebug}{/if}</div>
|
||||
<a href='#' id='LSdebug_hidden'>X</a>
|
||||
<div id='LSdebug_infos'>{if $LSdebug != ''}{$LSdebug}{/if}</div>
|
||||
</div>
|
||||
|
||||
<div id='main'>
|
||||
<div id='left'>
|
||||
<img src='templates/images/logo.png' alt='Logo' id='logo'/>
|
||||
<ul class='menu'>
|
||||
<li class='menu'><a href='index.php' class='menu'>Mon compte</a></li>
|
||||
<li class='menu'><a href='mon_compte.php' class='menu'>Utilisateurs</a></li>
|
||||
<li class='menu'><a href='mon_compte.php' class='menu'>Groupes</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id='right'>
|
||||
<p id='status'>Connecté en tant que <span id='user_name'>{$LSsession_username}</span></b> <a href='index.php?LSsession_logout'><img src='templates/images/logout.png' alt='Logout' title='Logout' /></a></p>
|
||||
<h1>Mon compte</h1>
|
||||
<form action='{$LSform_action}' method='post' class='LSform'>
|
||||
{$LSform_header}
|
||||
<dl class='LSform'>
|
||||
{foreach from=$LSform_fields item=field}
|
||||
<dt class='LSform'>{$field.label}</dt>
|
||||
<dd class='LSform'>{$field.html}{if $field.add != ''} <span class='LSform-addfield'>+ Ajouter un champ</span>{/if}</dd>
|
||||
{if $field.errors != ''}
|
||||
{foreach from=$field.errors item=error}
|
||||
<dd class='LSform LSform-errors'>{$error}</dd>
|
||||
{/foreach}
|
||||
{/if}
|
||||
{/foreach}
|
||||
<dd class='LSform'><input type='submit' value='{$LSform_submittxt}' class='LSform' /></dd>
|
||||
</dl>
|
||||
</div>
|
||||
<hr class='spacer' />
|
||||
<div id='left'>
|
||||
<img src='templates/images/logo.png' alt='Logo' id='logo'/>
|
||||
<ul class='menu'>
|
||||
{foreach from=$LSaccess item=item key=LSobject}
|
||||
<li class='menu'><a href='view.php?LSobject={$LSobject}' class='menu'>{$item.label}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
<div id='right'>
|
||||
<p id='status'>Connecté en tant que <span id='user_name'>{$LSsession_username}</span></b> <a href='index.php?LSsession_logout'><img src='templates/images/logout.png' alt='Logout' title='Logout' /></a></p>
|
||||
{if $pagetitle != ''}<h1>{$pagetitle}</h1>{/if}
|
||||
<form action='{$LSform_action}' method='post' class='LSform'>
|
||||
{$LSform_header}
|
||||
<dl class='LSform'>
|
||||
{foreach from=$LSform_fields item=field}
|
||||
<dt class='LSform'>{$field.label}</dt>
|
||||
<dd class='LSform'>{$field.html}{if $field.add != ''} <span class='LSform-addfield'>+ Ajouter un champ</span>{/if}</dd>
|
||||
{if $field.errors != ''}
|
||||
{foreach from=$field.errors item=error}
|
||||
<dd class='LSform LSform-errors'>{$error}</dd>
|
||||
{/foreach}
|
||||
{/if}
|
||||
{/foreach}
|
||||
<dd class='LSform'><input type='submit' value='{$LSform_submittxt}' class='LSform' /></dd>
|
||||
</dl>
|
||||
</div>
|
||||
<hr class='spacer' />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,51 +1,65 @@
|
|||
form.LSform {
|
||||
margin-left: 2em;
|
||||
p.LSform-view-actions {
|
||||
text-align: right;
|
||||
font-size: 0.8em;
|
||||
margin: 0.2em;
|
||||
margin-right: 3em;
|
||||
color: #0072b8;
|
||||
}
|
||||
|
||||
a.LSform-view-actions {
|
||||
text-decoration: none;
|
||||
color: #0072b8;
|
||||
}
|
||||
|
||||
a.LSform-view-actions:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
dl.LSform {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
margin-left: 2em;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.LSform dt {
|
||||
position: relative;
|
||||
left: 0.2em;
|
||||
top: 1.2em;
|
||||
width: 12em;
|
||||
font-weight: bold;
|
||||
font-size: 0.9em;
|
||||
color: #0072b8;
|
||||
position: relative;
|
||||
left: 0.2em;
|
||||
top: 1.2em;
|
||||
width: 12em;
|
||||
font-weight: bold;
|
||||
font-size: 0.9em;
|
||||
color: #0072b8;
|
||||
}
|
||||
|
||||
dd.LSform {
|
||||
margin-left: 13em;
|
||||
padding: 0;
|
||||
margin-left: 13em;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.LSform input, .LSform select, .LSform textarea {
|
||||
border: 1px inset #ccc;
|
||||
width: 20em;
|
||||
background-color: #b5e4f6;
|
||||
border: 1px inset #ccc;
|
||||
width: 20em;
|
||||
background-color: #b5e4f6;
|
||||
}
|
||||
|
||||
input[type='submit'].LSform {
|
||||
border: 1px outset #ccc;
|
||||
margin-top: 1em;
|
||||
margin-left: 6em;
|
||||
width: 8em;
|
||||
border: 1px outset #ccc;
|
||||
margin-top: 1em;
|
||||
margin-left: 6em;
|
||||
width: 8em;
|
||||
}
|
||||
|
||||
ul.LSform {
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.LSform-errors {
|
||||
color: #fff;
|
||||
background-color: #f59a67;
|
||||
color: #fff;
|
||||
background-color: #f59a67;
|
||||
}
|
||||
|
||||
img.LSform-add-field-btn, img.LSform-remove-field-btn {
|
||||
cursor: pointer;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
|
|
@ -1,80 +1,134 @@
|
|||
body {
|
||||
font-family: sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
img {
|
||||
vertical-align: bottom;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0.5em;
|
||||
border-bottom: 1px solid #0072b8;
|
||||
color: #0072b8;
|
||||
margin: 0.5em;
|
||||
border-bottom: 1px solid #0072b8;
|
||||
color: #0072b8;
|
||||
}
|
||||
|
||||
a img {
|
||||
border: none;
|
||||
border: none;
|
||||
}
|
||||
|
||||
hr {
|
||||
visibility: hidden;
|
||||
clear: both;
|
||||
height: 0px;
|
||||
visibility: hidden;
|
||||
clear: both;
|
||||
height: 0px;
|
||||
}
|
||||
|
||||
#main {
|
||||
width: 1000px;
|
||||
margin: auto;
|
||||
border: 1px solid #52bce5;
|
||||
background: #fff url(../images/fd_menu.png) repeat-y scroll left top;
|
||||
width: 1000px;
|
||||
margin: auto;
|
||||
border: 1px solid #52bce5;
|
||||
background: #fff url(../images/fd_menu.png) repeat-y scroll left top;
|
||||
}
|
||||
|
||||
#left {
|
||||
float: left;
|
||||
width: 160px;
|
||||
float: left;
|
||||
width: 160px;
|
||||
}
|
||||
|
||||
#right {
|
||||
margin: 0;
|
||||
float: left;
|
||||
width: 840px;
|
||||
margin: 0;
|
||||
float: left;
|
||||
width: 840px;
|
||||
}
|
||||
|
||||
#logo {
|
||||
margin: auto;
|
||||
width: 142px;
|
||||
margin-left: 9px;
|
||||
margin: auto;
|
||||
width: 142px;
|
||||
margin-left: 9px;
|
||||
}
|
||||
|
||||
#status {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 0.7em;
|
||||
color: #fff;
|
||||
text-align: right;
|
||||
background-color: #52bce5;
|
||||
padding: 0.3em;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 0.7em;
|
||||
color: #fff;
|
||||
text-align: right;
|
||||
background-color: #52bce5;
|
||||
padding: 0.3em;
|
||||
}
|
||||
|
||||
#user_name {
|
||||
font-weight: bold;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
ul.menu {
|
||||
list-style-image: url(../images/puce.png);
|
||||
list-style-image: url(../images/puce.png);
|
||||
}
|
||||
|
||||
li.menu {
|
||||
color: #fff;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
a.menu {
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
table.LSobject-list {
|
||||
margin-left: 1em;
|
||||
border: 1px solid #52bce5;
|
||||
width: 30em;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
td.LSobject-list {
|
||||
border: 1px solid #52bce5;
|
||||
padding: 0.1em;
|
||||
}
|
||||
|
||||
th.LSobject-list {
|
||||
background-color: #52bce5;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
a.LSobject-list {
|
||||
color: #000;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.LSobject-list-actions {
|
||||
color: #0072b8;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.LSobject-list-actions:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
td.LSobject-list-actions {
|
||||
width: 7em;
|
||||
}
|
||||
|
||||
p.LSobject-list-page {
|
||||
text-align: center;
|
||||
margin: 0.5em;
|
||||
width: 30em;
|
||||
}
|
||||
|
||||
a.LSobject-list-page {
|
||||
color: #52bce5;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.LSobject-list-page:hover {
|
||||
color: #0072b8;
|
||||
}
|
||||
|
||||
strong.LSobject-list-page {
|
||||
color: #0072b8;
|
||||
}
|
||||
|
|
34
trunk/templates/empty.tpl
Normal file
34
trunk/templates/empty.tpl
Normal file
|
@ -0,0 +1,34 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if}</title>
|
||||
<link rel="stylesheet" type="text/css" href="templates/css/base.css" media="screen" title="Normal" />
|
||||
{$LSsession_css}
|
||||
{$LSsession_js}
|
||||
</head>
|
||||
<body>
|
||||
<div id='LSerror'>
|
||||
{$LSerrors}
|
||||
</div>
|
||||
<div id='LSdebug'>
|
||||
<a href='#' id='LSdebug_hidden'>X</a>
|
||||
<div id='LSdebug_infos'>{if $LSdebug != ''}{$LSdebug}{/if}</div>
|
||||
</div>
|
||||
|
||||
<div id='main'>
|
||||
<div id='left'>
|
||||
<img src='templates/images/logo.png' alt='Logo' id='logo'/>
|
||||
<ul class='menu'>
|
||||
{foreach from=$LSaccess item=item key=LSobject}
|
||||
<li class='menu'><a href='view.php?LSobject={$LSobject}' class='menu'>{$item.label}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
<div id='right'>
|
||||
<p id='status'>Connecté en tant que <span id='user_name'>{$LSsession_username}</span></b> <a href='index.php?LSsession_logout'><img src='templates/images/logout.png' alt='Logout' title='Logout' /></a></p>
|
||||
</div>
|
||||
<hr class='spacer' />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
BIN
trunk/templates/images/edit.png
Normal file
BIN
trunk/templates/images/edit.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 498 B |
BIN
trunk/templates/images/view.png
Normal file
BIN
trunk/templates/images/view.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 617 B |
53
trunk/templates/modify.tpl
Normal file
53
trunk/templates/modify.tpl
Normal file
|
@ -0,0 +1,53 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if}</title>
|
||||
<link rel="stylesheet" type="text/css" href="templates/css/base.css" media="screen" title="Normal" />
|
||||
{$LSsession_css}
|
||||
{$LSsession_js}
|
||||
</head>
|
||||
<body>
|
||||
<div id='LSerror'>
|
||||
{$LSerrors}
|
||||
</div>
|
||||
<div id='LSdebug'>
|
||||
<a href='#' id='LSdebug_hidden'>X</a>
|
||||
<div id='LSdebug_infos'>{if $LSdebug != ''}{$LSdebug}{/if}</div>
|
||||
</div>
|
||||
|
||||
<div id='main'>
|
||||
<div id='left'>
|
||||
<img src='templates/images/logo.png' alt='Logo' id='logo'/>
|
||||
<ul class='menu'>
|
||||
{foreach from=$LSaccess item=item key=LSobject}
|
||||
<li class='menu'><a href='view.php?LSobject={$LSobject}' class='menu'>{$item.label}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
<div id='right'>
|
||||
<p id='status'>Connecté en tant que <span id='user_name'>{$LSsession_username}</span></b> <a href='index.php?LSsession_logout'><img src='templates/images/logout.png' alt='Logout' title='Logout' /></a></p>
|
||||
|
||||
{if $pagetitle != ''}<h1>{$pagetitle}</h1>{/if}
|
||||
<p class='LSform-view-actions'><a href='view.php?LSobject={$LSform_object.type}&dn={$LSform_object.dn}' class='LSform-view-actions'>Voir</a></p>
|
||||
|
||||
<form action='{$LSform_action}' method='post' class='LSform'>
|
||||
{$LSform_header}
|
||||
<dl class='LSform'>
|
||||
{foreach from=$LSform_fields item=field}
|
||||
<dt class='LSform'>{$field.label}</dt>
|
||||
<dd class='LSform'>{$field.html}{if $field.add != ''} <span class='LSform-addfield'>+ Ajouter un champ</span>{/if}</dd>
|
||||
{if $field.errors != ''}
|
||||
{foreach from=$field.errors item=error}
|
||||
<dd class='LSform LSform-errors'>{$error}</dd>
|
||||
{/foreach}
|
||||
{/if}
|
||||
{/foreach}
|
||||
<dd class='LSform'><input type='submit' value='{$LSform_submittxt}' class='LSform' /></dd>
|
||||
</dl>
|
||||
</form>
|
||||
</div>
|
||||
<hr class='spacer' />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
42
trunk/templates/view.tpl
Normal file
42
trunk/templates/view.tpl
Normal file
|
@ -0,0 +1,42 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if}</title>
|
||||
<link rel="stylesheet" type="text/css" href="templates/css/base.css" media="screen" title="Normal" />
|
||||
{$LSsession_css}
|
||||
{$LSsession_js}
|
||||
</head>
|
||||
<body>
|
||||
<div id='LSerror'>
|
||||
{$LSerrors}
|
||||
</div>
|
||||
<div id='LSdebug'>
|
||||
<a href='#' id='LSdebug_hidden'>X</a>
|
||||
<div id='LSdebug_infos'>{if $LSdebug != ''}{$LSdebug}{/if}</div>
|
||||
</div>
|
||||
|
||||
<div id='main'>
|
||||
<div id='left'>
|
||||
<img src='templates/images/logo.png' alt='Logo' id='logo'/>
|
||||
<ul class='menu'>
|
||||
{foreach from=$LSaccess item=item key=LSobject_type}
|
||||
<li class='menu'><a href='view.php?LSobject={$LSobject_type}' class='menu'>{$item.label}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
<div id='right'>
|
||||
<p id='status'>Connecté en tant que <span id='user_name'>{$LSsession_username}</span></b> <a href='index.php?LSsession_logout'><img src='templates/images/logout.png' alt='Logout' title='Logout' /></a></p>
|
||||
{if $pagetitle != ''}<h1>{$pagetitle}</h1>{/if}
|
||||
{if $LSform_canEdit == 'true'}<p class='LSform-view-actions'><a href='modify.php?LSobject={$LSform_object.type}&dn={$LSform_object.dn}' class='LSform-view-actions'>Modifier</a></p>{/if}
|
||||
<dl class='LSform'>
|
||||
{foreach from=$LSform_fields item=field}
|
||||
<dt class='LSform'>{$field.label}</dt>
|
||||
<dd class='LSform'>{$field.html}</dd>
|
||||
{/foreach}
|
||||
</dl>
|
||||
</div>
|
||||
<hr class='spacer' />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
58
trunk/templates/viewList.tpl
Normal file
58
trunk/templates/viewList.tpl
Normal file
|
@ -0,0 +1,58 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>LdapSaisie{if $pagetitle != ''} - {$pagetitle}{/if}</title>
|
||||
<link rel="stylesheet" type="text/css" href="templates/css/base.css" media="screen" title="Normal" />
|
||||
{$LSsession_css}
|
||||
{$LSsession_js}
|
||||
</head>
|
||||
<body>
|
||||
<div id='LSerror'>
|
||||
{$LSerrors}
|
||||
</div>
|
||||
<div id='LSdebug'>
|
||||
<a href='#' id='LSdebug_hidden'>X</a>
|
||||
<div id='LSdebug_infos'>{if $LSdebug != ''}{$LSdebug}{/if}</div>
|
||||
</div>
|
||||
|
||||
<div id='main'>
|
||||
<div id='left'>
|
||||
<img src='templates/images/logo.png' alt='Logo' id='logo'/>
|
||||
<ul class='menu'>
|
||||
{foreach from=$LSaccess item=item key=LSobject_type}
|
||||
<li class='menu'><a href='view.php?LSobject={$LSobject_type}' class='menu'>{$item.label}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
<div id='right'>
|
||||
<p id='status'>Connecté en tant que <span id='user_name'>{$LSsession_username}</span></b> <a href='index.php?LSsession_logout'><img src='templates/images/logout.png' alt='Logout' title='Logout' /></a></p>
|
||||
{if $pagetitle != ''}<h1>{$pagetitle}</h1>{/if}
|
||||
<table class='LSobject-list'>
|
||||
<tr class='LSobject-list'>
|
||||
<th class='LSobject-list'>{$LSobject_list_objectname}</th>
|
||||
<th class='LSobject-list'>{$_Actions}</th>
|
||||
</tr>
|
||||
{foreach from=$LSobject_list item=object}
|
||||
<tr class='LSobject-list'>
|
||||
<td class='LSobject-list LSobject-list-names'><a href='view.php?LSobject={$LSobject_list_objecttype}&dn={$object.dn}' class='LSobject-list'>{$object.displayValue}</a> </td>
|
||||
<td class='LSobject-list LSobject-list-actions'>{if $object.canEdit}<a href='modify.php?LSobject={$LSobject_list_objecttype}&dn={$object.dn}' class='LSobject-list-actions'><img src='templates/images/edit.png' alt='{$_Modifier}' title='{$_Modifier}'/></a>{/if}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
{if $LSobject_list_nbpage}
|
||||
<p class='LSobject-list-page'>
|
||||
{section name=listpage loop=$LSobject_list_nbpage step=1}
|
||||
{if $LSobject_list_currentpage == $smarty.section.listpage.index}
|
||||
<strong class='LSobject-list-page'>{$LSobject_list_currentpage}</strong>
|
||||
{else}
|
||||
<a href='view.php?LSobject={$LSobject_list_objecttype}&page={$smarty.section.listpage.index}' class='LSobject-list-page'>{$smarty.section.listpage.index}</a>
|
||||
{/if}
|
||||
{/section}
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
<hr class='spacer' />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
115
trunk/view.php
Normal file
115
trunk/view.php
Normal file
|
@ -0,0 +1,115 @@
|
|||
<?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('NB_LSOBJECT_LIST',20);
|
||||
|
||||
require_once 'includes/functions.php';
|
||||
require_once 'includes/class/class.LSsession.php';
|
||||
|
||||
$GLOBALS['LSsession'] = new LSsession();
|
||||
|
||||
if($LSsession -> startLSsession()) {
|
||||
$LSobject = $_GET['LSobject'];
|
||||
|
||||
if ( $LSobject == 'SELF' ) {
|
||||
if ($GLOBALS['LSsession'] -> canAccess($GLOBALS['LSsession']-> LSuserObject -> getType(),$GLOBALS['LSsession']-> LSuserObject -> getValue('dn'))) {
|
||||
if ( $GLOBALS['LSsession'] -> canEdit($GLOBALS['LSsession']-> LSuserObject -> getType(),$GLOBALS['LSsession']-> LSuserObject -> getValue('dn'))) {
|
||||
$GLOBALS['Smarty'] -> assign('LSform_canEdit',true);
|
||||
}
|
||||
$GLOBALS['Smarty'] -> assign('pagetitle',_('Mon compte'));
|
||||
$form = $GLOBALS['LSsession']-> LSuserObject -> getView();
|
||||
$form -> displayView();
|
||||
$GLOBALS['LSsession'] -> setTemplate('view.tpl');
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1004,$_GET['LSobject']);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( $GLOBALS['LSsession'] -> loadLSobject($_GET['LSobject']) ) {
|
||||
if ( isset($_GET['dn']) ) {
|
||||
if ($GLOBALS['LSsession'] -> canAccess($_GET['LSobject'],$_GET['dn'])) {
|
||||
if ( $GLOBALS['LSsession'] -> canEdit($_GET['LSobject'],$_GET['dn']) ) {
|
||||
$GLOBALS['Smarty'] -> assign('LSform_canEdit','true');
|
||||
}
|
||||
$object = new $_GET['LSobject']();
|
||||
$object -> loadData($_GET['dn']);
|
||||
$view = $object -> getView();
|
||||
$view -> displayView();
|
||||
$GLOBALS['LSsession'] -> setTemplate('view.tpl');
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1011);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$objectList=array();
|
||||
$object = new $_GET['LSobject']();
|
||||
$GLOBALS['Smarty']->assign('pagetitle',$object -> getLabel());
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_objectname',$object -> getLabel());
|
||||
$list=$object -> listObjects();
|
||||
$nbObjects=count($list);
|
||||
if ($nbObjects > NB_LSOBJECT_LIST) {
|
||||
if (isset($_GET['page'])) {
|
||||
$list = array_slice($list, ($_GET['page']) * NB_LSOBJECT_LIST, NB_LSOBJECT_LIST);
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_currentpage',$_GET['page']);
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_nbpage',ceil($nbObjects / NB_LSOBJECT_LIST));
|
||||
}
|
||||
else {
|
||||
$list = array_slice($list, 0, NB_LSOBJECT_LIST);
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_currentpage',0);
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_nbpage',ceil($nbObjects / NB_LSOBJECT_LIST));
|
||||
}
|
||||
}
|
||||
foreach($list as $thisObject) {
|
||||
if ($GLOBALS['LSsession'] -> canAccess($_GET['LSobject'],$thisObject->getValue('dn'))) {
|
||||
$objectList[]=array(
|
||||
'dn' => $thisObject->getValue('dn'),
|
||||
'displayValue' => $thisObject->getDisplayValue(),
|
||||
'canEdit' => $GLOBALS['LSsession'] -> canEdit($_GET['LSobject'],$thisObject->getValue('dn'))
|
||||
);
|
||||
}
|
||||
else {
|
||||
debug($thisObject->getValue('dn'));
|
||||
}
|
||||
}
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSview.js');
|
||||
|
||||
$GLOBALS['Smarty']->assign('_Actions',_('Actions'));
|
||||
$GLOBALS['Smarty']->assign('_Modifier',_('Modifier'));
|
||||
$GLOBALS['Smarty']->assign('LSobject_list',$objectList);
|
||||
$GLOBALS['Smarty']->assign('LSobject_list_objecttype',$_GET['LSobject']);
|
||||
$GLOBALS['LSsession'] -> setTemplate('viewList.tpl');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSerror'] -> addErrorCode(1004,$_GET['LSobject']);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSsession'] -> setTemplate('login.tpl');
|
||||
}
|
||||
|
||||
// Affichage des retours d'erreurs
|
||||
$GLOBALS['LSsession'] -> displayTemplate();
|
||||
?>
|
Loading…
Reference in a new issue