- Ajout de la gestion des droits (A étendre et debugger)

- Propagation des possibilités de l'interface
This commit is contained in:
Benjamin Renard 2008-02-08 17:39:24 +00:00
parent 61ba918a42
commit 7d2e3baf8b
33 changed files with 2560 additions and 1706 deletions

View file

@ -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
)

View file

@ -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

View file

@ -23,7 +23,6 @@
$GLOBALS['LSobjects']['LSeepeople'] = array (
'objectclass' => array(
'top',
'lspeople',
'posixAccount',
'sambaSamAccount',
),
@ -32,6 +31,7 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
'before_save' => 'valid',
'after_save' => 'valid',
'select_display_attrs' => '%{cn}',
'label' => _('Utilisateurs'),
// Attributes
'attrs' => array (
'uid' => array (
@ -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,
@ -218,10 +228,10 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
'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
'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
@ -275,10 +289,11 @@ $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'
),
'view' => 1,
'form' => array (
'test' => 1,
)
@ -293,16 +308,18 @@ $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 (
@ -310,10 +327,11 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
'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
'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,
)
@ -369,9 +392,9 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
'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
'rights' => array(
'self' => 'w',
'admin' => 'w'
),
'dependAttrs' => array(
'sambaLMPassword',
@ -387,22 +410,14 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
'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
)
'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
)
'generate_function' => 'generate_sambaNTPassword'
)
)
);

View file

@ -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'
);
?>

View file

@ -234,6 +234,10 @@ $GLOBALS['LSerror_code'] = array (
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'
)
);
?>

View file

@ -25,6 +25,7 @@ $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',
'cacheLSrights' => true,
'ldap_servers' => array (
array (
'name' => 'Ldap 1',
@ -40,6 +41,16 @@ $GLOBALS['LSconfig'] = 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'
),
@ -65,7 +76,7 @@ $GLOBALS['LSconfig'] = array(
);
//Debug
$GLOBALS['LSdebug']['active'] = true;
$GLOBALS['LSdebug']['active'] = false;
// Définitions des locales
$textdomain = 'ldapsaisie';

View file

@ -81,6 +81,13 @@ class LSattr_html {
$GLOBALS['LSerror'] -> addErrorCode(101,$this -> name);
}
function __sleep() {
return ( array_keys( get_object_vars( &$this ) ) );
}
function __wakeup() {
return true;
}
}
?>

View file

@ -73,6 +73,13 @@ class LSattr_ldap {
return $data;
}
function __sleep() {
return ( array_keys( get_object_vars( &$this ) ) );
}
function __wakeup() {
return true;
}
}
?>

View file

@ -41,6 +41,7 @@ class LSattribute {
var $updateData=false;
var $is_validate=false;
var $_finalUpdateData=false;
var $_myRights=NULL;
/**
* Constructeur
@ -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();
}
@ -204,10 +208,10 @@ class LSattribute {
$form -> setRequired($this -> name);
}
if($this -> config['form'][$idForm]==0) {
if (($this -> config['form'][$idForm]==0) || ($this -> myRights() == 'r')) {
$element -> freeze();
}
else {
if(isset($this -> config['check_data'])) {
if(is_array($this -> config['check_data'])) {
foreach ($this -> config['check_data'] as $rule => $rule_infos) {
@ -227,6 +231,66 @@ class LSattribute {
}
}
}
}
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;
}
@ -274,7 +338,6 @@ class LSattribute {
function setUpdateData($data) {
if($this -> getFormVal() != $data) {
$this -> updateData=$data;
debug($this -> name.' is updated (o = '.$this -> getFormVal().' | n = '.$data.')');
}
}
@ -420,6 +483,14 @@ class LSattribute {
function getDependsAttrs() {
return $this -> config['dependAttrs'];
}
function __sleep() {
return ( array_keys( get_object_vars( &$this ) ) );
}
function __wakeup() {
return true;
}
}
?>

View file

@ -70,11 +70,24 @@ class LSform {
* @retval void
*/
function display(){
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";
$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();
@ -90,6 +103,28 @@ class LSform {
}
}
/**
* 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
*
@ -373,9 +408,10 @@ class LSform {
if ($element) {
return $element -> getEmptyField();
}
else
else {
return;
}
}
}

View file

@ -64,13 +64,8 @@ class LSformElement_select extends LSformElement {
}
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>";
}
foreach ($this -> values as $value) {
$return['html'].="<li class='LSform'>".$this -> params['text_possible_values'][$value]."</strong></li>";
}
$return['html'].="</ul>\n";
}

View file

@ -48,8 +48,8 @@ class LSformElement_text extends LSformElement {
$return['html'] .= "<li>".$this -> getEmptyField()."</li>\n";
}
else {
$multiple = $this -> getMultipleData();
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";
}

View file

@ -42,32 +42,30 @@ class LSformElement_textarea extends LSformElement {
function getDisplay(){
$return = $this -> getLabelInfos();
// value
$return['html'] = "<ul class='LSform'>\n";
if (!$this -> isFreeze()) {
$return['html'] = "<ul class='LSform'>\n";
if (empty($this -> values)) {
$return['html'] = "<li>".$this -> getEmptyField()."</li>\n";
$return['html'] .= "<li class='LSform'>".$this -> getEmptyField()."</li>\n";
}
else {
foreach($this -> values as $value) {
$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'].="<li class='LSform'><textarea name='".$this -> name."[]' id='".$id."' class='LSform'>".$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";
$return['html'].="<li class='LSform'>"._('Aucunes valeur definie')."</li>\n";
}
else {
foreach ($this -> values as $value) {
$return['html'].="<li>".$value."</li>\n";
$return['html'].="<li class='LSform'>".$value."</li>\n";
}
}
}
$return['html'] .= "</ul>\n";
}
return $return;
}
@ -78,7 +76,7 @@ class LSformElement_textarea extends LSformElement {
*/
function getEmptyField() {
$multiple = $this -> getMultipleData();
return "<textarea name='".$this -> name."[]' id='LSform".$this -> name."_".rand()."'></textarea>\n".$multiple;
return "<textarea name='".$this -> name."[]' id='LSform".$this -> name."_".rand()."' class='LSform'></textarea>\n".$multiple;
}
}

View file

@ -35,9 +35,11 @@ class LSldapObject {
var $type_name;
var $attrs;
var $forms;
var $view;
var $dn=false;
var $other_values=array();
var $submitError=true;
var $_whoami=NULL;
/**
* Constructeur
@ -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
*
@ -489,88 +514,6 @@ 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
*
@ -905,6 +848,24 @@ class LSldapObject {
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;
}
}
?>

View file

@ -33,6 +33,7 @@ class LSsession {
var $confDir = NULL;
var $ldapServer = NULL;
var $ldapServerId = NULL;
var $topDn = NULL;
var $LSuserObject = NULL;
var $dn = NULL;
@ -40,6 +41,10 @@ class LSsession {
var $JSscripts = array();
var $CssFiles = array();
var $template = NULL;
var $LSrights = array (
'topDn_admin' => array ()
);
var $LSaccess = array();
/**
* Constructeur
@ -137,7 +142,7 @@ class LSsession {
* Chargement des objects LdapSaisie
*
* Chargement des LSobjects contenue dans la variable
* $GLOBALS['LSobjects']['loads']
* $GLOBALS['LSobjects_loads']
*
* @retval boolean true si le chargement a réussi, false sinon.
*/
@ -145,12 +150,12 @@ class LSsession {
$this -> loadLSclass('LSldapObject');
if(!is_array($GLOBALS['LSobjects']['loads'])) {
if(!is_array($GLOBALS['LSobjects_loads'])) {
$GLOBALS['LSerror'] -> addErrorCode(1001,"LSobjects['loads']");
return;
}
foreach ($GLOBALS['LSobjects']['loads'] as $object) {
foreach ($GLOBALS['LSobjects_loads'] as $object) {
if ( !$this -> loadLSobject($object) )
return;
}
@ -218,13 +223,30 @@ class LSsession {
if(isset($_SESSION['LSsession'])) {
// Session existante
$this -> confDir = $_SESSION['LSsession'] -> confDir;
$this -> ldapServer = $_SESSION['LSsession'] -> ldapServer;
$this -> topDn = $_SESSION['LSsession'] -> topDn;
$this -> LSuserObject = $_SESSION['LSsession'] -> LSuserObject;
//$this -> LSuserObject = $_SESSION['LSsession'] -> LSuserObject;
$this -> dn = $_SESSION['LSsession'] -> dn;
$this -> rdn = $_SESSION['LSsession'] -> rdn;
$this -> ldapServerId = $_SESSION['LSsession'] -> ldapServerId;
if ( ($GLOBALS['LSconfig']['cacheLSrights']) || ($this -> ldapServer['cacheLSrights']) ) {
$this -> ldapServer = $_SESSION['LSsession'] -> ldapServer;
$this -> LSrights = $_SESSION['LSsession'] -> LSrights;
$this -> LSaccess = $_SESSION['LSsession'] -> LSaccess;
if (!$this -> LSldapConnect())
return;
}
else {
$this -> setLdapServer($this -> ldapServerId);
if (!$this -> LSldapConnect())
return;
$this -> loadLSrights();
$this -> loadLSaccess();
}
$this -> LSuserObject = new $this -> ldapServer['authobject']();
$this -> LSuserObject -> loadData($this -> dn);
$GLOBALS['Smarty'] -> assign('LSsession_username',$this -> LSuserObject -> getDisplayValue());
return $this -> LSldapConnect();
return true;
}
else {
// Session inexistante
@ -249,7 +271,7 @@ class LSsession {
if ( $this -> loadLSobject($this -> ldapServer['authobject']) ) {
$authobject = new $this -> ldapServer['authobject']();
$result = $authobject -> searchObject($_POST['LSsession_user'],$_POST['LSsession_topDn']);
$result = $authobject -> searchObject($_POST['LSsession_user'],$this -> topDn);
$nbresult=count($result);
if ($nbresult==0) {
// identifiant incorrect
@ -266,7 +288,8 @@ class LSsession {
$this -> LSuserObject = $result[0];
$this -> dn = $result[0]->getValue('dn');
$this -> rdn = $_POST['LSsession_user'];
$this -> topDn = $_POST['LSsession_topDn'];
$this -> loadLSrights();
$this -> loadLSaccess();
$GLOBALS['Smarty'] -> assign('LSsession_username',$this -> LSuserObject -> getDisplayValue());
$_SESSION['LSsession']=$this;
return true;
@ -302,6 +325,7 @@ class LSsession {
*/
function setLdapServer($id) {
if ( isset($GLOBALS['LSconfig']['ldap_servers'][$id]) ) {
$this -> ldapServerId = $id;
$this -> ldapServer=$GLOBALS['LSconfig']['ldap_servers'][$id];
return true;
}
@ -502,10 +526,151 @@ class LSsession {
}
$GLOBALS['Smarty'] -> assign('LSsession_css',$Css_txt);
$GLOBALS['Smarty'] -> assign('LSaccess',$this -> LSaccess);
$GLOBALS['LSerror'] -> display();
debug_print();
if (!$this -> template)
$this -> setTemplate('empty.tpl');
$GLOBALS['Smarty'] -> display($this -> template);
}
/**
* Charge les droits LS de l'utilisateur
*
* @retval boolean True si le chargement à réussi, false sinon.
**/
function loadLSrights() {
if (is_array($this -> ldapServer['LSadmins'])) {
foreach ($this -> ldapServer['LSadmins'] as $topDn => $adminsInfos) {
if (is_array($adminsInfos)) {
foreach($adminsInfos as $dn => $conf) {
if ((isset($conf['attr'])) && (isset($conf['LSobject']))) {
if( $this -> loadLSobject($conf['LSobject']) ) {
if ($object = new $conf['LSobject']()) {
if ($object -> loadData($dn)) {
$listDns=$object -> getValue($conf['attr']);
if (is_array($listDns)) {
if (in_array($this -> dn,$listDns)) {
$this -> LSrights['topDn_admin'][] = $topDn;
}
}
}
else {
debug('Impossible de chargé le dn : '.$dn);
}
}
else {
debug('Impossible de créer l\'objet de type : '.$conf['LSobject']);
}
}
else {
$GLOBALS['LSerror'] -> addErrorCode(1004,$conf['LSobject']);
}
}
else {
if ($this -> dn == $dn) {
$this -> LSrights['topDn_admin'][] = $topDn;
}
}
}
}
else {
if ( $this -> dn == $adminsInfos ) {
$this -> LSrights['topDn_admin'][] = $topDn;
}
}
}
debug($this -> LSrights['topDn_admin']);
return true;
}
else {
return;
}
}
function loadLSaccess() {
$LSaccess = array(
'SELF' => array(
'label' => _('Mon compte'),
'DNs' => $this -> dn
)
);
foreach ($GLOBALS['LSobjects'] as $objecttype => $objectconf) {
$objectdn = $objectconf['container_dn'].','.$this -> topDn;
if ($this -> isAdmin($objectdn) ) {
$LSaccess[$objecttype] = array (
'label' => $objectconf['label'],
'Dns' => 'All'
);
}
}
$this -> LSaccess = $LSaccess;
}
function isAdmin($dn) {
foreach($this -> LSrights['topDn_admin'] as $topDn_admin) {
if($dn == $topDn_admin) {
return true;
}
else if ( isCompatibleDNs($dn,$topDn_admin) ) {
return true;
}
}
return;
}
function whoami($dn) {
if ($this -> isAdmin($dn)) {
return 'admin';
}
if ($this -> dn == $dn) {
return 'self';
}
return 'user';
}
function canAccess($LSobject,$dn=NULL,$right=NULL) {
if (!$this -> loadLSobject($LSobject))
return;
if ($dn) {
$whoami = $this -> whoami($dn);
}
else {
$whoami = 'user';
}
if (is_array($GLOBALS['LSobjects'][$LSobject]['attrs'])) {
if (($right=='r')||($right=='w')) {
foreach ($GLOBALS['LSobjects'][$LSobject]['attrs'] as $attr_name => $attr_config) {
if ($attr_config['rights'][$whoami]==$right) {
return true;
}
}
}
else {
foreach ($GLOBALS['LSobjects'][$LSobject]['attrs'] as $attr_name => $attr_config) {
if ( ($attr_config['rights'][$whoami]=='r') || ($attr_config['rights'][$whoami]=='w') ) {
return true;
}
}
}
}
return;
}
function canEdit($LSobject,$dn=NULL) {
return $this -> canAccess($LSobject,$dn,'w');
}
function __sleep() {
return ( array_keys( get_object_vars( &$this ) ) );
}
function __wakeup() {
return true;
}
}
?>

View file

@ -126,11 +126,98 @@ function debug_print() {
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;
}
?>

View file

@ -9,7 +9,7 @@ var LSdefault = new Class({
}
this.LSdebugHidden = $('LSdebug_hidden');
this.LSdebugHidden.addEvent('click',this.onLSdebugHiddenClick.bind(this));
this.LSdebugHidden.addEvent('click',this.onLSdebugHiddenClick.bindWithEvent(this));
this.LSerror = $('LSerror');
this.LSerror.setOpacity(0);
if (this.LSerror.innerHTML != '') {
@ -17,7 +17,8 @@ var LSdefault = new Class({
}
},
onLSdebugHiddenClick: function(){
onLSdebugHiddenClick: function(event){
new Event(event).stop();
new Fx.Style(this.LSdebug,'opacity',{duration:500}).start(1,0);
},

View file

@ -1,8 +1,5 @@
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);
@ -22,8 +19,9 @@ var LSform = new Class({
template: 'LSform',
action: 'onAddFieldBtnClick',
attribute: attrName,
objecttype: this.objecttype,
idform: this.idform,
objecttype: $('LSform_objecttype').value,
objectdn: $('LSform_objectdn').value,
idform: $('LSform_idform').value,
img: img.id
};
LSdebug(data);

View 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();
});

View file

@ -28,28 +28,10 @@ $GLOBALS['LSsession'] = new LSsession();
if($LSsession -> startLSsession()) {
// Définition du Titre de la page
$GLOBALS['Smarty'] -> assign('pagetitle',_('Mon compte'));
// ---- 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();
$GLOBALS['Smarty'] -> assign('pagetitle',_('Accueil'));
// Template
$GLOBALS['LSsession'] -> setTemplate('base.tpl');
$GLOBALS['LSsession'] -> setTemplate('accueil.tpl');
}
else {
$GLOBALS['LSsession'] -> setTemplate('login.tpl');

View file

@ -43,8 +43,9 @@ switch($_REQUEST['template']) {
case 'LSform':
switch($_REQUEST['action']) {
case 'onAddFieldBtnClick':
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['idform'])) && (isset($_REQUEST['img'])) ) {
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 ) {

65
trunk/modify.php Normal file
View 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();
?>

View 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>

View file

@ -20,14 +20,14 @@
<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>
{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>
<h1>Mon compte</h1>
{if $pagetitle != ''}<h1>{$pagetitle}</h1>{/if}
<form action='{$LSform_action}' method='post' class='LSform'>
{$LSform_header}
<dl class='LSform'>

View file

@ -1,9 +1,23 @@
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;
margin-left: 2em;
padding: 0;
}

View file

@ -78,3 +78,57 @@ a.menu {
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
View 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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 498 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 617 B

View 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}&amp;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
View 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}&amp;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>

View 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}&amp;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}&amp;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}&amp;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
View 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();
?>