From 721eddd92ff159ce01742c3c351c7936bbfc2776 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Tue, 9 Sep 2008 15:48:07 +0000 Subject: [PATCH] =?UTF-8?q?-=20LSsession=20:=20=20=20->=20Ajout=20de=20la?= =?UTF-8?q?=20methode=20redirect()=20=20=20->=20Ajout=20d'une=20possibilit?= =?UTF-8?q?=C3=A9=20d'affichage=20d'infos=20=C3=A0=20au=20chargement=20de?= =?UTF-8?q?=20la=20page=20=20=20=20=20->=20methode=20addInfo()=20=20=20=20?= =?UTF-8?q?=20->=20modification=20de=20la=20methode=20displayTemplate()=20?= =?UTF-8?q?en=20cons=C3=A9quence=20=20=20=20=20->=20modification=20de=20LS?= =?UTF-8?q?default.js=20et=20LSdefault.css=20en=20cons=C3=A9quence=20-=20r?= =?UTF-8?q?emove.php=20=20=20->=20Redirection=20vers=20la=20liste=20des=20?= =?UTF-8?q?objets=20du=20m=C3=AAme=20type=20que=20l'objet=20supprim=C3=A9?= =?UTF-8?q?=20=20=20=20=20=20apr=C3=A8s=20sa=20suppression=20avec=20une=20?= =?UTF-8?q?demande=20de=20rafraichissement.=20-=20modify.php=20=20=20->=20?= =?UTF-8?q?Redirection=20vers=20la=20fiche=20de=20l'objet=20apr=C3=A8s=20s?= =?UTF-8?q?a=20modification=20avec=20affichage=20=20=20=20=20=20d'un=20mes?= =?UTF-8?q?sage.=20(Feature=20Request=20#1702)=20-=20LSaddons=20:=20=20=20?= =?UTF-8?q?->=20FTP=20:=20support=20FTP=20a=20travers=20la=20librairie=20P?= =?UTF-8?q?EAR=20::=20Net=5FFTP=20=20=20->=20Maildir=20:=20Pour=20la=20cr?= =?UTF-8?q?=C3=A9ation=20et=20la=20suppresion=20de=20la=20Maildir=20d'un?= =?UTF-8?q?=20utilisateur=20=20=20->=20Posix=20:=20Ajout=20de=20la=20m?= =?UTF-8?q?=C3=A9thode=20createHomeDirectoryByFTP()=20et=20correction=20d'?= =?UTF-8?q?un=20=20=20=20=20=20bug=20dans=20l'affichage=20des=20erreurs=20?= =?UTF-8?q?=20=20->=20Samba=20:=20Correction=20d'un=20bug=20dans=20l'affic?= =?UTF-8?q?hage=20des=20erreurs=20-=20LSldapObject=20:=20=20=20->=20Ajout?= =?UTF-8?q?=20d'une=20possibilit=C3=A9=20de=20trigger=20personnalis=C3=A9?= =?UTF-8?q?=20=C3=A0=20travers=20la=20configuration=20=20=20=20=20=20d'un?= =?UTF-8?q?=20LSobjet=20:=20=20=20=20=20=20=20->=20after=5Fcreate=20=20=20?= =?UTF-8?q?=20=20=20=20->=20after=5Fdelete=20=20=20->=20Renomage=20du=20tr?= =?UTF-8?q?igger=20before=5Fsave=20et=20after=5Fsave=20en=20before=5Fmodif?= =?UTF-8?q?y=20et=20=20=20=20=20=20after=5Fmodify.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LSobjects/config.LSobjects.LSeepeople.php | 6 +- trunk/conf/config.LSaddons.php | 5 +- trunk/conf/config.error_code.php | 26 ++- trunk/includes/addons/LSaddons.ftp.php | 183 ++++++++++++++++++ trunk/includes/addons/LSaddons.maildir.php | 139 +++++++++++++ trunk/includes/addons/LSaddons.posix.php | 58 +++++- trunk/includes/addons/LSaddons.samba.php | 14 +- trunk/includes/class/class.LSldapObject.php | 66 +++++-- trunk/includes/class/class.LSsession.php | 38 ++++ trunk/includes/js/LSdefault.js | 15 +- trunk/modify.php | 3 +- trunk/remove.php | 3 +- trunk/templates/css/LSdefault.css | 13 ++ trunk/templates/css/base.css | 3 +- trunk/templates/redirect.tpl | 11 ++ trunk/templates/top.tpl | 1 + 16 files changed, 550 insertions(+), 34 deletions(-) create mode 100644 trunk/includes/addons/LSaddons.ftp.php create mode 100644 trunk/includes/addons/LSaddons.maildir.php create mode 100644 trunk/templates/redirect.tpl diff --git a/trunk/conf/LSobjects/config.LSobjects.LSeepeople.php b/trunk/conf/LSobjects/config.LSobjects.LSeepeople.php index 112b1b82..db6f6178 100644 --- a/trunk/conf/LSobjects/config.LSobjects.LSeepeople.php +++ b/trunk/conf/LSobjects/config.LSobjects.LSeepeople.php @@ -38,8 +38,10 @@ $GLOBALS['LSobjects']['LSeepeople'] = array ( 'ou' => 'people' ) ), - 'before_save' => 'valid', - 'after_save' => 'valid', + 'before_modify' => 'valid', + 'after_modify' => 'valid', + 'after_create' => 'createMaildirByFTP', + 'after_delete' => 'removeMaildirByFTP', 'select_display_attrs' => '%{cn}', 'label' => _('Utilisateurs'), 'relations' => array( diff --git a/trunk/conf/config.LSaddons.php b/trunk/conf/config.LSaddons.php index f01df4a4..a161c6a3 100644 --- a/trunk/conf/config.LSaddons.php +++ b/trunk/conf/config.LSaddons.php @@ -21,7 +21,10 @@ ******************************************************************************/ $GLOBALS['LSaddons']['loads'] = array ( - 'samba', 'posix' + 'samba', + 'posix', + 'ftp', + 'maildir' ); ?> diff --git a/trunk/conf/config.error_code.php b/trunk/conf/config.error_code.php index 4d781d9c..89de02eb 100644 --- a/trunk/conf/config.error_code.php +++ b/trunk/conf/config.error_code.php @@ -85,19 +85,19 @@ $GLOBALS['LSerror_code'] = array ( 'level' => 'c' ), 27 => array ( - 'msg' => _("LSldapObject : La fonction %{func} devant être executée avant l'enregistrement n'existe pas."), + 'msg' => _("LSldapObject : La fonction %{func} devant être executée avant la modification n'existe pas."), 'level' => 'c' ), 28 => array ( - 'msg' => _("LSldapObject : L'execution de la fonction %{func} devant être executée avant l'enregistrement a échouée."), + 'msg' => _("LSldapObject : L'execution de la fonction %{func} devant être executée avant la modification a échouée."), 'level' => 'c' ), 29 => array ( - 'msg' => _("LSldapObject : La fonction %{func} devant être executée après l'enregistrement n'existe pas."), + 'msg' => _("LSldapObject : La fonction %{func} devant être executée après la modification n'existe pas."), 'level' => 'c' ), 30 => array ( - 'msg' => _("LSldapObject : L'execution de la fonction %{func} devant être executée après l'enregistrement a échouée."), + 'msg' => _("LSldapObject : L'execution de la fonction %{func} devant être executée après la modification a échouée."), 'level' => 'c' ), 31 => array ( @@ -136,10 +136,26 @@ $GLOBALS['LSerror_code'] = array ( 'msg' => _("LSldapObject : Erreur durant les actions après suppresion."), 'level' => 'c' ), - 40 => array ( + 301 => array ( 'msg' => _("LSldapObject : Erreur durant les actions après la création. L'objet est pour autant créé."), 'level' => 'c' ), + 302 => array ( + 'msg' => _("LSldapObject : La fonction %{fonction} devant être éxecutée après la création de l'objet n'existe pas."), + 'level' => 'c' + ), + 303 => array ( + 'msg' => _("LSldapObject : Erreur durant l'exection de la fonction %{fonction} devant être éxecutée après la création de l'objet."), + 'level' => 'c' + ), + 304 => array ( + 'msg' => _("LSldapObject : La fonction %{fonction} devant être éxecutée après la suppression de l'objet n'existe pas."), + 'level' => 'c' + ), + 305 => array ( + 'msg' => _("LSldapObject : Erreur durant l'exection de la fonction %{fonction} devant être éxecutée après la suppression de l'objet."), + 'level' => 'c' + ), // LSattribute 41 => array ( diff --git a/trunk/includes/addons/LSaddons.ftp.php b/trunk/includes/addons/LSaddons.ftp.php new file mode 100644 index 00000000..091d8859 --- /dev/null +++ b/trunk/includes/addons/LSaddons.ftp.php @@ -0,0 +1,183 @@ + _("FTP Support : Pear::Net_FTP est introuvable."), + 'level' => 'c' + ); + + $GLOBALS['LSerror_code']['FTP_00']= array ( + 'msg' => _("Net_FTP Error : %{msg}"), + 'level' => 'c' + ); + + $GLOBALS['LSerror_code']['FTP_01']= array ( + 'msg' => _("FTP Support : Impossible de se connecter au serveur FTP (Etape : %{etape})."), + 'level' => 'c' + ); + $GLOBALS['LSerror_code']['FTP_02']= array ( + 'msg' => _("FTP Support : Impossible de créer le dossier %{dir} sur le serveur distant."), + 'level' => 'c' + ); + $GLOBALS['LSerror_code']['FTP_03']= array ( + 'msg' => _("FTP Support : Impossible de supprimer le dossier %{dir} sur le serveur distant."), + 'level' => 'c' + ); + + + /** + * Fin des données de configuration + */ + + + /** + * Verification du support FTP par ldapSaisie + * + * @author Benjamin Renard + * + * @retval boolean true si FTP est pleinement supporté, false sinon + */ + function LSaddon_ftp_support() { + $retval=true; + + // Dependance de librairie + if (!class_exists('Net_FTP')) { + if(!@include(NET_FTP)) { + $GLOBALS['LSerror'] -> addErrorCode('FTP_SUPPORT_01'); + $retval=false; + } + } + + return $retval; + } + + + + /** + * Connexion a un serveur FTP + * + * @author Benjamin Renard + * + * @param[in] $host string Le nom ou l'IP du serveur FTP + * @param[in] $port string Le port de connexion au serveur ftp + * @param[in] $user string Le nom d'utilidateur de connexion + * @param[in] $pwd string Le mot de passe de connexion + * + * @retval mixed Net_FTP object en cas de succès, false sinon + */ + function connectToFTP($host,$port,$user,$pwd) { + $cnx = new Net_FTP(); + $do = $cnx -> connect($host,$port); + if (! $do instanceof PEAR_Error){ + $do = $cnx -> login($user,$pwd); + if (! $do instanceof PEAR_Error) { + return $cnx; + } + else { + $GLOBALS['LSerror'] -> addErrorCode('FTP_01',"2"); + $GLOBALS['LSerror'] -> addErrorCode('FTP_00',$do -> getMessage()); + return; + } + } + else { + $GLOBALS['LSerror'] -> addErrorCode('FTP_01',"1"); + $GLOBALS['LSerror'] -> addErrorCode('FTP_00',$do -> getMessage()); + return; + } + } + + /** + * Creation d'un ou plusieurs dossiers via FTP + * + * @author Benjamin Renard + * + * @param[in] $host string Le nom ou l'IP du serveur FTP + * @param[in] $port string Le port de connexion au serveur ftp + * @param[in] $user string Le nom d'utilidateur de connexion + * @param[in] $pwd string Le mot de passe de connexion + * @param[in] $dirs array ou string Le(s) dossier(s) à ajouter + * + * @retval string True ou false si il y a un problème durant la création du/des dossier(s) + */ + function createDirsByFTP($host,$port,$user,$pwd,$dirs) { + $cnx = connectToFTP($host,$port,$user,$pwd); + if (! $cnx){ + return; + } + if (!is_array($dirs)) { + $dirs = array($dirs); + } + foreach($dirs as $dir) { + $do = $cnx -> mkdir($dir,true); + if ($do instanceof PEAR_Error) { + $GLOBALS['LSerror'] -> addErrorCode('FTP_02',$dir); + $GLOBALS['LSerror'] -> addErrorCode('FTP_00',$do -> getMessage()); + return; + } + } + return true; + } + + /** + * Suppression d'un ou plusieurs dossiers via FTP + * + * @author Benjamin Renard + * + * @param[in] $host string Le nom ou l'IP du serveur FTP + * @param[in] $port string Le port de connexion au serveur ftp + * @param[in] $user string Le nom d'utilidateur de connexion + * @param[in] $pwd string Le mot de passe de connexion + * @param[in] $dirs array ou string Le(s) dossier(s) à supprimer + * + * @retval string True ou false si il y a un problème durant la suppression du/des dossier(s) + */ + function removeDirsByFTP($host,$port,$user,$pwd,$dirs) { + $cnx = connectToFTP($host,$port,$user,$pwd); + if (! $cnx){ + return; + } + if (!is_array($dirs)) { + $dirs = array($dirs); + } + foreach($dirs as $dir) { + if ($dir[strlen($dir)-1]!='/') { + $dir.='/'; + } + $do = $cnx -> rm($dir,true); + if ($do instanceof PEAR_Error) { + $GLOBALS['LSerror'] -> addErrorCode('FTP_03',$dir); + $GLOBALS['LSerror'] -> addErrorCode('FTP_00',$do -> getMessage()); + return; + } + } + return true; + } diff --git a/trunk/includes/addons/LSaddons.maildir.php b/trunk/includes/addons/LSaddons.maildir.php new file mode 100644 index 00000000..9e5af6fb --- /dev/null +++ b/trunk/includes/addons/LSaddons.maildir.php @@ -0,0 +1,139 @@ + _("MAILDIR Support : Impossible de charger LSaddons::FTP."), + 'level' => 'c' + ); + $GLOBALS['LSerror_code']['MAILDIR_SUPPORT_02']= array ( + 'msg' => _("MAILDIR Support : La constante %{const} n'est pas définie."), + 'level' => 'c' + ); + $GLOBALS['LSerror_code']['MAILDIR_01']= array ( + 'msg' => _("MAILDIR Support : Erreur durant la création de la maildir sur le serveur distant."), + 'level' => 'c' + ); + $GLOBALS['LSerror_code']['MAILDIR_02']= array ( + 'msg' => _("MAILDIR Support : Erreur durant la création de la maildir sur le serveur distant."), + 'level' => 'c' + ); + + /** + * Fin des données de configuration + */ + + + /** + * Verification du support Maildir par ldapSaisie + * + * @author Benjamin Renard + * + * @retval boolean true si Maildir est pleinement supporté, false sinon + */ + function LSaddon_maildir_support() { +$retval=true; + + // Dependance de librairie + if (!function_exists('createDirsByFTP')) { + if(!$GLOBALS['LSsession'] -> loadLSaddon('ftp')) { + $GLOBALS['LSerror'] -> addErrorCode('MAILDIR_SUPPORT_01'); + $retval=false; + } + } + + $MUST_DEFINE_CONST= array( + 'LS_MAILDIR_FTP_HOST', + 'LS_MAILDIR_FTP_USER', + 'LS_MAILDIR_FTP_MAILDIR_PATH' + ); + + foreach($MUST_DEFINE_CONST as $const) { + if ( constant($const) == '' ) { + $GLOBALS['LSerror'] -> addErrorCode('MAILDIR_SUPPORT_02',$const); + $retval=false; + } + } + return $retval; + } + + /** + * Creation d'une Maildir via FTP + * + * @author Benjamin Renard + * + * @param[in] $ldapObject L'objet ldap + * + * @retval string True ou false si il y a un problème durant la création de la Maildir + */ + function createMaildirByFTP($ldapObject) { + $dir = getFData(LS_MAILDIR_FTP_MAILDIR_PATH,$ldapObject,'getValue'); + $dirs = array( + $dir.'/cur', + $dir.'/new', + $dir.'/tmp' + ); + if (!createDirsByFTP(LS_MAILDIR_FTP_HOST,LS_MAILDIR_FTP_PORT,LS_MAILDIR_FTP_USER,LS_MAILDIR_FTP_PWD,$dirs)) { + $GLOBALS['LSerror'] -> addErrorCode('MAILDIR_01'); + return; + } + return true; + } + + /** + * Suppression d'une Maildir via FTP + * + * @author Benjamin Renard + * + * @param[in] $ldapObject L'objet ldap + * + * @retval string True ou false si il y a un problème durant la suppression de la Maildir + */ + function removeMaildirByFTP($ldapObject) { + $dir = getFData(LS_MAILDIR_FTP_MAILDIR_PATH,$ldapObject,'getValue'); + if (!removeDirsByFTP(LS_MAILDIR_FTP_HOST,LS_MAILDIR_FTP_PORT,LS_MAILDIR_FTP_USER,LS_MAILDIR_FTP_PWD,$dir)) { + $GLOBALS['LSerror'] -> addErrorCode('MAILDIR_02'); + return; + } + return true; + } diff --git a/trunk/includes/addons/LSaddons.posix.php b/trunk/includes/addons/LSaddons.posix.php index ff8cba91..002cd2c3 100644 --- a/trunk/includes/addons/LSaddons.posix.php +++ b/trunk/includes/addons/LSaddons.posix.php @@ -42,18 +42,37 @@ // Dossier contenant les homes des utilisateurs (defaut: /home/) define('LS_POSIX_HOMEDIRECTORY','/home/'); - + + // Create homeDirectory by FTP - Host + define('LS_POSIX_HOMEDIRECTORY_FTP_HOST','127.0.0.1'); + + // Create homeDirectory by FTP - Port + define('LS_POSIX_HOMEDIRECTORY_FTP_PORT',21); + + // Create homeDirectory by FTP - User + define('LS_POSIX_HOMEDIRECTORY_FTP_USER','admin'); + + // Create homeDirectory by FTP - Password + define('LS_POSIX_HOMEDIRECTORY_FTP_PWD','password'); + + // Create homeDirectory by FTP - Path + define('LS_POSIX_HOMEDIRECTORY_FTP_PATH','%{homeDirectory}'); // -- Message d'erreur -- // Support - $GLOBALS['error_code']['POSIX_SUPPORT_01']= array ( + $GLOBALS['LSerror_code']['POSIX_SUPPORT_01']= array ( 'msg' => _("POSIX Support : La constante %{const} n'est pas définie."), 'level' => 'c' ); + + $GLOBALS['LSerror_code']['POSIX_SUPPORT_02']= array ( + 'msg' => _("POSIX Support : Impossible de charger LSaddons::FTP."), + 'level' => 'c' + ); // Autres erreurs - $GLOBALS['error_code']['POSIX_01']= array ( + $GLOBALS['LSerror_code']['POSIX_01']= array ( 'msg' => _("POSIX : L'attribut %{dependency} est introuvable. Impossible de générer l'attribut %{attr}."), 'level' => 'c' ); @@ -73,6 +92,14 @@ function LSaddon_posix_support() { $retval=true; + + // Dependance de librairie + if (!function_exists('createDirsByFTP')) { + if(!$GLOBALS['LSsession'] -> loadLSaddon('ftp')) { + $GLOBALS['LSerror'] -> addErrorCode('POSIX_SUPPORT_02'); + $retval=false; + } + } $MUST_DEFINE_CONST= array( 'LS_POSIX_UID_ATTR', @@ -80,7 +107,12 @@ 'LS_POSIX_GIDNUMBER_ATTR', 'LS_POSIX_UIDNUMBER_MIN_VAL', 'LS_POSIX_GIDNUMBER_MIN_VAL', - 'LS_POSIX_HOMEDIRECTORY' + 'LS_POSIX_HOMEDIRECTORY', + 'LS_POSIX_HOMEDIRECTORY_FTP_HOST', + 'LS_POSIX_HOMEDIRECTORY_FTP_PORT', + 'LS_POSIX_HOMEDIRECTORY_FTP_USER', + 'LS_POSIX_HOMEDIRECTORY_FTP_PWD', + 'LS_POSIX_HOMEDIRECTORY_FTP_PATH' ); foreach($MUST_DEFINE_CONST as $const) { @@ -167,5 +199,23 @@ return $home; } + + /** + * Generation de homeDirectory + * + * @author Benjamin Renard + * + * @param[in] $ldapObject L'objet ldap + * + * @retval string homeDirectory ou false si il y a un problème durant la génération + */ + function createHomeDirectoryByFTP($ldapObject) { + $dir = getFData(LS_POSIX_HOMEDIRECTORY_FTP_PATH,$ldapObject,'getValue'); + if (!createDirsByFTP(LS_POSIX_HOMEDIRECTORY_FTP_HOST,LS_POSIX_HOMEDIRECTORY_FTP_PORT,LS_POSIX_HOMEDIRECTORY_FTP_USER,LS_POSIX_HOMEDIRECTORY_FTP_PWD,$dir)) { + $GLOBALS['LSerror'] -> addErrorCode('POSIX_02'); + return; + } + return true; + } ?> diff --git a/trunk/includes/addons/LSaddons.samba.php b/trunk/includes/addons/LSaddons.samba.php index e7244070..769c1392 100644 --- a/trunk/includes/addons/LSaddons.samba.php +++ b/trunk/includes/addons/LSaddons.samba.php @@ -50,22 +50,22 @@ // Message d'erreur - $GLOBALS['error_code']['SAMBA_SUPPORT_01']= array ( + $GLOBALS['LSerror_code']['SAMBA_SUPPORT_01']= array ( 'msg' => _("SAMBA Support : la classe smHash ne peut pas être chargée."), 'level' => 'c' ); - $GLOBALS['error_code']['SAMBA_SUPPORT_02']= array ( + $GLOBALS['LSerror_code']['SAMBA_SUPPORT_02']= array ( 'msg' => _("SAMBA Support : La constante %{const} n'est pas définie."), 'level' => 'c' ); - $GLOBALS['error_code']['SAMBA_SUPPORT_03']= array ( + $GLOBALS['LSerror_code']['SAMBA_SUPPORT_03']= array ( 'msg' => _("SAMBA Support : Les constantes LS_SAMBA_SID_BASE_USER et LS_SAMBA_SID_BASE_GROUP ne doivent pas avoir la même parité pour l'unicité des sambaSID."), 'level' => 'c' ); - $GLOBALS['error_code']['SAMBA_01']= array ( + $GLOBALS['LSerror_code']['SAMBA_01']= array ( 'msg' => _("SAMBA Support : L'attribut %{dependency} est introuvable. Impossible de générer l'attribut %{attr}."), 'level' => 'c' ); @@ -89,7 +89,7 @@ // Dependance de librairie if ( !class_exists('smbHash') ) { if ( ! @include_once(LS_LIB_DIR . 'class.smbHash.php') ) { - $GLOBALS['LSerror'] -> addErrorCode('SAMBA_SUPPORT_O1'); + $GLOBALS['LSerror'] -> addErrorCode('SAMBA_SUPPORT_01'); $retval=false; } } @@ -106,14 +106,14 @@ foreach($MUST_DEFINE_CONST as $const) { if ( constant($const) == '' ) { - $GLOBALS['LSerror'] -> addErrorCode('SAMBA_SUPPORT_O2',$const); + $GLOBALS['LSerror'] -> addErrorCode('SAMBA_SUPPORT_02',$const); $retval=false; } } // Pour l'intégrité des SID if ( (LS_SAMBA_SID_BASE_USER % 2) == (LS_SAMBA_SID_BASE_GROUP % 2) ) { - $GLOBALS['LSerror'] -> addErrorCode('SAMBA_SUPPORT_O3'); + $GLOBALS['LSerror'] -> addErrorCode('SAMBA_SUPPORT_03'); $retval=false; } diff --git a/trunk/includes/class/class.LSldapObject.php b/trunk/includes/class/class.LSldapObject.php index 8552c372..f15acb04 100644 --- a/trunk/includes/class/class.LSldapObject.php +++ b/trunk/includes/class/class.LSldapObject.php @@ -304,15 +304,15 @@ class LSldapObject { } if($this -> validateAttrsData($idForm)) { debug("les données sont validées"); - if(isset($this -> config['before_save'])) { - if(function_exists($this -> config['before_save'])) { - if(!$this -> config['before_save']($this)) { - $GLOBALS['LSerror'] -> addErrorCode(28,$this -> config['before_save']); + if(isset($this -> config['before_modify'])) { + if(function_exists($this -> config['before_modify'])) { + if(!$this -> config['before_modify']($this)) { + $GLOBALS['LSerror'] -> addErrorCode(28,$this -> config['before_modify']); return; } } else { - $GLOBALS['LSerror'] -> addErrorCode(27,$this -> config['before_save']); + $GLOBALS['LSerror'] -> addErrorCode(27,$this -> config['before_modify']); return; } } @@ -325,15 +325,15 @@ class LSldapObject { else { return; } - if((isset($this -> config['after_save']))&&(!$this -> submitError)) { - if(function_exists($this -> config['after_save'])) { - if(!$this -> config['after_save']($this)) { - $GLOBALS['LSerror'] -> addErrorCode(30,$this -> config['after_save']); + if((isset($this -> config['after_modify']))&&(!$this -> submitError)) { + if(function_exists($this -> config['after_modify'])) { + if(!$this -> config['after_modify']($this)) { + $GLOBALS['LSerror'] -> addErrorCode(30,$this -> config['after_modify']); return; } } else { - $GLOBALS['LSerror'] -> addErrorCode(29,$this -> config['after_save']); + $GLOBALS['LSerror'] -> addErrorCode(29,$this -> config['after_modify']); return; } } @@ -553,7 +553,7 @@ class LSldapObject { } if ($new) { if (!$this -> afterCreate()) { - $GLOBALS['LSerror'] -> addErrorCode(40); + $GLOBALS['LSerror'] -> addErrorCode(301); return; } } @@ -1149,6 +1149,28 @@ class LSldapObject { } } } + + if (isset($this -> config['after_delete'])) { + if (is_array($this -> config['after_delete'])) { + $config = $this -> config['after_delete']; + } + else { + $config = array($this -> config['after_delete']); + } + foreach($config as $action) { + if(function_exists($action)) { + if(!$action($this)) { + $GLOBALS['LSerror'] -> addErrorCode(305,$action); + $error=true; + } + } + else { + $GLOBALS['LSerror'] -> addErrorCode(304,$action); + $error=true; + } + } + } + return !$error; } @@ -1189,6 +1211,28 @@ class LSldapObject { } } } + + if (isset($this -> config['after_create'])) { + if (is_array($this -> config['after_create'])) { + $config = $this -> config['after_create']; + } + else { + $config = array($this -> config['after_create']); + } + foreach($config as $action) { + if(function_exists($action)) { + if(!$action($this)) { + $GLOBALS['LSerror'] -> addErrorCode(303,$action); + $error=true; + } + } + else { + $GLOBALS['LSerror'] -> addErrorCode(302,$action); + $error=true; + } + } + } + return !$error; } diff --git a/trunk/includes/class/class.LSsession.php b/trunk/includes/class/class.LSsession.php index c059ad48..5a6a3464 100644 --- a/trunk/includes/class/class.LSsession.php +++ b/trunk/includes/class/class.LSsession.php @@ -909,6 +909,17 @@ class LSsession { $GLOBALS['Smarty'] -> assign('LSsession_subDn',$this -> topDn); $GLOBALS['Smarty'] -> assign('LSsession_subDnName',$this -> getSubDnName()); } + + // Infos + if((!empty($_SESSION['LSsession_infos']))&&(is_array($_SESSION['LSsession_infos']))) { + $txt_infos="
    \n"; + foreach($_SESSION['LSsession_infos'] as $info) { + $txt_infos.="
  • $info
  • \n"; + } + $txt_infos.="
\n"; + $GLOBALS['Smarty'] -> assign('LSinfos',$txt_infos); + $_SESSION['LSsession_infos']=array(); + } if ($this -> ajaxDisplay) { $GLOBALS['Smarty'] -> assign('LSerror_txt',$GLOBALS['LSerror']->getErrors()); @@ -1444,6 +1455,33 @@ class LSsession { function haveSubDn() { return (is_array($this -> ldapServer['subDn'])); } + + /** + * Ajoute une information à afficher + * + * @param[in] $msg string Le message à afficher + * + * @retval void + */ + function addInfo($msg) { + $_SESSION['LSsession_infos'][]=$msg; + } + + /** + * Redirection de l'utilisateur vers une autre URL + * + * @param[in] $url string L'URL + * @param[in] $exit boolean Si true, l'execution script s'arrête après la redirection + * + * @retval void + */ + function redirect($url,$exit=true) { + $GLOBALS['Smarty'] -> assign('url',$url); + $GLOBALS['Smarty'] -> display('redirect.tpl'); + if ($exit) { + exit(); + } + } } ?> diff --git a/trunk/includes/js/LSdefault.js b/trunk/includes/js/LSdefault.js index 305c9e94..07ce0c4d 100644 --- a/trunk/includes/js/LSdefault.js +++ b/trunk/includes/js/LSdefault.js @@ -9,6 +9,8 @@ var LSdefault = new Class({ this.LSerror = $('LSerror'); this.LSerror.setOpacity(0); + + this.LSinfos = $('LSinfos'); this.LSjsConfigEl = $('LSjsConfig'); if ($type(this.LSjsConfigEl)) { @@ -28,7 +30,8 @@ var LSdefault = new Class({ this.fx = { LSdebug: new Fx.Tween(this.LSdebug,{property: 'opacity',duration:600}), - LSerror: new Fx.Tween(this.LSerror,{property: 'opacity',duration:500}) + LSerror: new Fx.Tween(this.LSerror,{property: 'opacity',duration:500}), + LSinfos: new Fx.Tween(this.LSinfos,{property: 'opacity',duration:500}) }; if (this.LSdebugInfos.innerHTML != '') { @@ -38,6 +41,10 @@ var LSdefault = new Class({ if (this.LSerror.innerHTML != '') { this.displayErrorBox(); } + + if (this.LSinfos.innerHTML != '') { + this.displayInfosBox(); + } }, onLSsession_topDnChange: function() { @@ -92,6 +99,12 @@ var LSdefault = new Class({ (function(){this.fx.LSerror.start(0.8,0);}).delay(10000, this); }, + displayInfosBox: function() { + this.LSinfos.setStyle('top',getScrollTop()+10); + this.fx.LSinfos.start(0,0.9); + (function(){this.fx.LSinfos.start(0.9,0);}).delay(5000, this); + }, + displayDebugBox: function() { this.LSdebug.setStyle('top',getScrollTop()+10); this.fx.LSdebug.start(0,0.8); diff --git a/trunk/modify.php b/trunk/modify.php index fc64f78c..23be94b4 100644 --- a/trunk/modify.php +++ b/trunk/modify.php @@ -53,7 +53,8 @@ if($LSsession -> startLSsession()) { if ($form->validate()) { // MàJ des données de l'objet LDAP if ($object -> updateData('modify')) { - debug('ok'); + $GLOBALS['LSsession'] -> addInfo(_("L'objet a bien été modifié.")); + $GLOBALS['LSsession'] -> redirect('view.php?LSobject='.$LSobject.'&dn='.$object -> getDn()); } } diff --git a/trunk/remove.php b/trunk/remove.php index 4a09acfc..0e2f3b8b 100644 --- a/trunk/remove.php +++ b/trunk/remove.php @@ -37,7 +37,8 @@ if($LSsession -> startLSsession()) { $objectname=$object -> getDisplayValue(); $GLOBALS['Smarty'] -> assign('pagetitle',_('Suppression').' : '.$objectname); if ($object -> remove()) { - $GLOBALS['Smarty'] -> assign('question',$objectname.' '._('a bien été supprimé').'.'); + $GLOBALS['LSsession'] -> addInfo($objectname.' '._('a bien été supprimé').'.'); + $GLOBALS['LSsession'] -> redirect('view.php?LSobject='.$_GET['LSobject'].'&refresh'); } else { $GLOBALS['LSerror'] -> addErrorCode(35,$objectname); diff --git a/trunk/templates/css/LSdefault.css b/trunk/templates/css/LSdefault.css index 9c0611ec..c126356c 100644 --- a/trunk/templates/css/LSdefault.css +++ b/trunk/templates/css/LSdefault.css @@ -38,3 +38,16 @@ text-decoration: none; font-weight: bold; } + +#LSinfos { + position: absolute; + width: 50%; + left: 25%; + background-color: #bee2f0; + border: 1px solid #4096b8; + visibility: hidden; + color: #4096b8; + z-index: 100; + top: 10px; + font-weight: bold; +} diff --git a/trunk/templates/css/base.css b/trunk/templates/css/base.css index b9acf97e..3737cee1 100644 --- a/trunk/templates/css/base.css +++ b/trunk/templates/css/base.css @@ -182,7 +182,8 @@ a.LSobject-list-actions:hover { } td.LSobject-list-actions { - width: 5em; + text-align: center; + width: 7em; } /* Name */ diff --git a/trunk/templates/redirect.tpl b/trunk/templates/redirect.tpl new file mode 100644 index 00000000..f3801eda --- /dev/null +++ b/trunk/templates/redirect.tpl @@ -0,0 +1,11 @@ + + + + + + LdapSaisie - Redirection + + + + diff --git a/trunk/templates/top.tpl b/trunk/templates/top.tpl index eb4e96dc..964854f2 100644 --- a/trunk/templates/top.tpl +++ b/trunk/templates/top.tpl @@ -13,6 +13,7 @@
{$LSjsConfig}
+
{$LSinfos}
{$LSerrors}