From 6f52489a59fd941376acdef26a8be24c2c096804 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Wed, 21 Jan 2009 17:08:09 +0000 Subject: [PATCH] =?UTF-8?q?-=20Deplacement=20du=20require=20de=20functions?= =?UTF-8?q?.php=20dans=20le=20fichier=20de=20classe=20de=20LSsession=20=20?= =?UTF-8?q?=20pour=20ne=20pas=20obliger=20sa=20recopie.=20-=20LSlog=20:=20?= =?UTF-8?q?D=C3=A9but=20d'ecriture=20d'une=20possibilit=C3=A9=20de=20fichi?= =?UTF-8?q?ers=20de=20logs=20-=20Ajout=20d'une=20fonction=20de=20test=20va?= =?UTF-8?q?lidPas()=20retournant=20false=20-=20LSformElement=20:=20Ajout?= =?UTF-8?q?=20d'un=20type=20de=20LSformElement=20g=C3=A9rant=20les=20attri?= =?UTF-8?q?buts=20maildir.=20=20=20Il=20fonctionne=20en=20frontend=20du=20?= =?UTF-8?q?LSaddon=20Maildir.=20-=20LSsession=20:=20=20=20->=20Ajout=20de?= =?UTF-8?q?=20la=20m=C3=A9thode=20statique=20includeFile()=20utilis=C3=A9?= =?UTF-8?q?=20=C3=A0=20la=20place=20de=20la=20fonction=20=20=20=20=20=20ph?= =?UTF-8?q?p=20include=5Fonce()=20=20=20->=20displayAjaxReturn()=20:=20Ges?= =?UTF-8?q?tion=20du=20LSredirect=20=20=20->=20Ajout=20d'un=20require=5Fon?= =?UTF-8?q?ce()=20sur=20functions.php=20-=20LSaddon::FTP=20:=20Ajout=20de?= =?UTF-8?q?=20la=20fonction=20renameDirByFTP()=20-=20LSaddon::Maildir=20:?= =?UTF-8?q?=20=20=20->=20Ajout=20de=20la=20fonction=20renameMaildirByFTP()?= =?UTF-8?q?=20=20=20->=20Modification=20des=20fonctions=20createMaildirByF?= =?UTF-8?q?TP()=20et=20removeMaildirByFTP()=20pour=20=20=20=20=20=20pour?= =?UTF-8?q?=20pouvoir=20leur=20pass=C3=A9=20en=20deuxi=C3=A8me=20param?= =?UTF-8?q?=C3=A8tre=20le=20chemin=20de=20la=20maildir=20=C3=A0=20utlis?= =?UTF-8?q?=C3=A9=20-=20LSdefault=20:=20=20=20->=20LSdebugHidde()=20devien?= =?UTF-8?q?t=20hideLSdebug()=20=20=20->=20Ajout=20de=20la=20m=C3=A9thode?= =?UTF-8?q?=20hideLSerror()=20accroch=C3=A9=20sur=20l'=C3=A9v=C3=A9nement?= =?UTF-8?q?=20double-clique=20de=20la=20=20=20=20=20=20LSerrorsBox=20=20?= =?UTF-8?q?=20->=20displayErrorBox()=20:=20plus=20de=20timeout=20d'afficha?= =?UTF-8?q?ge=20des=20erreurs=20=20=20->=20checkAjaxReturn()=20:=20Gestion?= =?UTF-8?q?=20des=20LSredirect=20-=20LSform=20:=20=20=20->=20plus=20de=20L?= =?UTF-8?q?SformRedirect=20:=20utilisation=20de=20LSdefault::LSredirect=20?= =?UTF-8?q?-=20modify.php=20et=20create.php=20:=20Utilisation=20des=20LSde?= =?UTF-8?q?fault::LSredirect=20et=20affichages=20des=20=20=20erreurs=20non?= =?UTF-8?q?-bloquant=20sur=20la=20page=20suivante.=20-=20LSerror=20:=20=20?= =?UTF-8?q?=20->=20Utilisation=20d'une=20variable=20de=20session=20pour=20?= =?UTF-8?q?stock=C3=A9=20les=20erreurs=20=20=20->=20Ajout=20de=20la=20m?= =?UTF-8?q?=C3=A9thode=20resetError()=20ex=C3=A9cut=C3=A9e=20=C3=A0=20chaq?= =?UTF-8?q?ue=20ex=C3=A9cution=20de=20=20=20=20=20=20LSerror::getErrors()?= =?UTF-8?q?=20-=20LSldapObject=20:=20=20=20->=20Correction=20de=20la=20ges?= =?UTF-8?q?tion=20des=20binding=20=20=20=20=20->=20Event=20before=5Fmodify?= =?UTF-8?q?=20:=20bloquant=20en=20cas=20d'=C3=A9chec=20=20=20=20=20->=20Ev?= =?UTF-8?q?ent=20after=5Fmodify=20:=20non-bloquant=20en=20cas=20d'=C3=A9ch?= =?UTF-8?q?ec?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trunk/conf/config.inc.php | 4 + trunk/create.php | 5 +- trunk/images/default/maildir_do.png | Bin 0 -> 824 bytes trunk/images/default/maildir_nodo.png | Bin 0 -> 845 bytes trunk/includes/addons/LSaddons.ftp.php | 42 ++++- trunk/includes/addons/LSaddons.mail.php | 2 +- trunk/includes/addons/LSaddons.maildir.php | 49 ++++-- trunk/includes/addons/LSaddons.samba.php | 2 +- .../class/class.LSattr_html_maildir.php | 34 +++++ trunk/includes/class/class.LSerror.php | 35 ++--- .../class/class.LSformElement_maildir.php | 144 ++++++++++++++++++ trunk/includes/class/class.LSldapObject.php | 6 +- trunk/includes/class/class.LSsession.php | 38 ++++- trunk/includes/functions.php | 16 +- trunk/includes/js/LSdefault.js | 17 ++- trunk/includes/js/LSform.js | 7 +- trunk/includes/js/LSformElement_maildir.js | 17 +++ .../js/LSformElement_maildir_field.js | 50 ++++++ trunk/index.php | 1 - trunk/index_ajax.php | 1 - trunk/modify.php | 6 +- trunk/remove.php | 1 - trunk/select.php | 1 - .../default/LSformElement_maildir_field.tpl | 5 + trunk/view.php | 1 - 25 files changed, 421 insertions(+), 63 deletions(-) create mode 100644 trunk/images/default/maildir_do.png create mode 100644 trunk/images/default/maildir_nodo.png create mode 100644 trunk/includes/class/class.LSattr_html_maildir.php create mode 100644 trunk/includes/class/class.LSformElement_maildir.php create mode 100644 trunk/includes/js/LSformElement_maildir.js create mode 100644 trunk/includes/js/LSformElement_maildir_field.js create mode 100644 trunk/templates/default/LSformElement_maildir_field.tpl diff --git a/trunk/conf/config.inc.php b/trunk/conf/config.inc.php index 00cf7373..cceb0114 100644 --- a/trunk/conf/config.inc.php +++ b/trunk/conf/config.inc.php @@ -171,6 +171,10 @@ define('LS_CSS_DIR', 'css/'.LS_THEME); //Debug $GLOBALS['LSdebug']['active'] = true; +// Logs +$GLOBALS['LSlog']['filename'] = 'tmp/LS.log'; +$GLOBALS['LSlog']['enable'] = true; + define('NB_LSOBJECT_LIST',20); define('NB_LSOBJECT_LIST_SELECT',11); diff --git a/trunk/create.php b/trunk/create.php index 2afd42fd..c0381e88 100644 --- a/trunk/create.php +++ b/trunk/create.php @@ -20,7 +20,6 @@ ******************************************************************************/ -require_once 'includes/functions.php'; require_once 'includes/class/class.LSsession.php'; $GLOBALS['LSsession'] = new LSsession(); @@ -55,13 +54,13 @@ if($LSsession -> startLSsession()) { if (isset($_REQUEST['ajax'])) { $GLOBALS['LSsession'] -> displayAjaxReturn ( array( - 'LSformRedirect' => 'view.php?LSobject='.$LSobject.'&dn='.$object -> getDn() + 'LSredirect' => 'view.php?LSobject='.$LSobject.'&dn='.$object -> getDn() ) ); exit(); } else { - if ((!LSdebugDefined()) && !$GLOBALS['LSerror']->errorsDefined()) { + if (!LSdebugDefined()) { $GLOBALS['LSsession'] -> redirect('view.php?LSobject='.$LSobject.'&dn='.$object -> getDn()); } } diff --git a/trunk/images/default/maildir_do.png b/trunk/images/default/maildir_do.png new file mode 100644 index 0000000000000000000000000000000000000000..35498f68ceec5b05aaef80853bda0746b7b39681 GIT binary patch literal 824 zcmV-81IPS{P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iXA= z2{r?n?ajsj00Ov4L_t(I%f*w;Yg}a*#eeUed*|NF%$;P?PC88|G@a5$K@h_r=*EKJ z)`bfZ{{WY9B?wZ88^u4tb&9ynW{M!A;36BvMe0XMifKC`Gr7&=e$3pj_rpcpSajV3 zhjY&6@GPDKFB;;rulI&t&3`S3%X*SYOB>J_ls0H%P{yG3MgE5dp~`X|22cJtII!ET z#kG&#z1_@9BRseA@Al`txX?70l{8nYAAFf-_9T+MLTYhuc)~mV6_$O6ATbCumL*VG zOpydACAoaLO(7b5^WzEcz1gz-_S#KrmMh^p7T2ye`R?Zl=Sj)3S0IxKYJP^yVq6<+ zp?P{d=KfE=(QzlZl>$K6^GpKJ>ogDszW?Qfw>B&qRS2ViD2iy*Ym{Zl(c>|z;fUL-9!4vgeuMdZ4!}n58hM^G8jT2}7^OSdv-IKu zAwZUrrWGT-DtW1pMat=Ez~dle!Sm=WIn)+h9H&Ziagj?;0<3wiFhEgA#%D1tJL1NQ zgV7~rS#p{{_g0^mUwxgDDoQCF+hWPDb6r2ep6AjiZN%hR%v#%Lau{QbMk$F9f^KJt zl`9Q21`C5yiZsj6Ny2n`hCMqQ{goH;`b*sf(O9rV*1AMEo#Hwbj4?PuF&#ZXDTz&i z)`BES7>&=>@8^xFT_mSRZ-0Eh<@)uy?N)^E!5dd&>&`1}t0JIYtC8n9f(oARlcp)Q zntOYD z-yRCAluv98(|oJ7{~Epx7+RZ`~AC76fqbKJ}-*m>1;N;DW$wO7!3Xt|F^QO ztu0SVS=Q_IJ3@$0<2WV=f-kDo>JL#AIlH^N8NlCLfNd={y6j>A0000Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iXA= z2{#*)nq<)c00PZPL_t(I%cagwXq$B$$MN^`FMUj!HD=J+znPgR-CA(YlNUV+9=v$i zNl-y3EeJ*CVX~FwG(9*NoF3!frqvd-;&*Oc5gWa4lWO@h6=yFU3`i}9< z?F##?4oNp4Y*nz9e&)pFd$@=2-q0z2`Y3~O<~abvZu=ns>1Vnz1it%ihgV-PNo=l@ zn4G{Z6dvLFaEknuX-=LU;cg+1BMQ^=6#%vc>Hcn#JuZKJ`zwiwqqv<;vvch;tkDt5 zDmU5|cm&Q%!&L2l`K9eCxr3lKaC>3H8 zptV7()uOz+uh#avYv$9HjqQ7Hyd}>1V_fMUX6;Ibb~;Tg8pXCuY|A1Zk7HRDw$nwf zxa;rSckeWaj@_nPxaAsy^e1Lxe XNdnTTiJ&q?00000NkvXXu0mjfwB(vR literal 0 HcmV?d00001 diff --git a/trunk/includes/addons/LSaddons.ftp.php b/trunk/includes/addons/LSaddons.ftp.php index 798ae1de..e00efd9d 100644 --- a/trunk/includes/addons/LSaddons.ftp.php +++ b/trunk/includes/addons/LSaddons.ftp.php @@ -56,6 +56,10 @@ $GLOBALS['LSerror_code']['FTP_04']= array ( 'msg' => _("FTP Support : Impossible de modifier les droits du dossier %{dir} sur le serveur distant."), 'level' => 'c' ); +$GLOBALS['LSerror_code']['FTP_05']= array ( + 'msg' => _("FTP Support : Impossible de renomer le dossier %{old} en %{new} sur le serveur distant."), + 'level' => 'c' +); /** * Verification du support FTP par ldapSaisie @@ -72,7 +76,7 @@ $GLOBALS['LSerror_code']['FTP_04']= array ( if (!defined('NET_FTP')) { $GLOBALS['LSerror'] -> addErrorCode('FTP_SUPPORT_02','NET_FTP'); $retval=false; - } else if(!@include(NET_FTP)) { + } else if(!LSsession::includeFile(NET_FTP)) { $GLOBALS['LSerror'] -> addErrorCode('FTP_SUPPORT_01'); $retval=false; } @@ -158,6 +162,14 @@ $GLOBALS['LSerror_code']['FTP_04']= array ( /** * Suppression d'un ou plusieurs dossiers via FTP * + * Note : Attention : suppression récursive. Cela veut dire que les sous-dossiers + * lister par un LS FTP seront supprimé d'abord. Attention : Si votre serveur + * FTP est configuré pour caché certains fichiers ou dossiers (dont le nom + * commence par un '.' par exempl), ces fichiers ne seront pas supprimés et la + * suppression du dossier parent échoura. + * + * Pour VsFTPd : Ajouter force_dot_files=1 dans la configuration. + * * @author Benjamin Renard * * @param[in] $host string Le nom ou l'IP du serveur FTP @@ -189,3 +201,31 @@ $GLOBALS['LSerror_code']['FTP_04']= array ( } return true; } + + /** + * Renomage d'un dossier 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] $old string Le dossier à renomer + * @param[in] $new string Le nouveau nom du dossier à renomer + * + * @retval string True ou false si il y a un problème durant le renomage du/des dossier(s) + */ + function renameDirByFTP($host,$port,$user,$pwd,$old,$new) { + $cnx = connectToFTP($host,$port,$user,$pwd); + if (! $cnx){ + return; + } + $do = $cnx -> rename($old,$new); + if ($do instanceof PEAR_Error) { + $GLOBALS['LSerror'] -> addErrorCode('FTP_05',array('old' => $old,'new' => $new)); + $GLOBALS['LSerror'] -> addErrorCode('FTP_00',$do -> getMessage()); + return; + } + return true; + } diff --git a/trunk/includes/addons/LSaddons.mail.php b/trunk/includes/addons/LSaddons.mail.php index ccd56ca7..81fc91fc 100644 --- a/trunk/includes/addons/LSaddons.mail.php +++ b/trunk/includes/addons/LSaddons.mail.php @@ -51,7 +51,7 @@ $GLOBALS['LSerror_code']['MAIL_01']= array ( // Dependance de librairie if (!class_exists('Mail')) { - if(!@include(PEAR_MAIL)) { + if(!LSsession::includeFile(PEAR_MAIL)) { $GLOBALS['LSerror'] -> addErrorCode('MAIL_SUPPORT_01'); $retval=false; } diff --git a/trunk/includes/addons/LSaddons.maildir.php b/trunk/includes/addons/LSaddons.maildir.php index 800a14a0..e68e427c 100644 --- a/trunk/includes/addons/LSaddons.maildir.php +++ b/trunk/includes/addons/LSaddons.maildir.php @@ -24,22 +24,21 @@ // Support $GLOBALS['LSerror_code']['MAILDIR_SUPPORT_01']= array ( - 'msg' => _("MAILDIR Support : Impossible de charger LSaddons::FTP."), - 'level' => 'c' + 'msg' => _("MAILDIR Support : Impossible de charger LSaddons::FTP.") ); $GLOBALS['LSerror_code']['MAILDIR_SUPPORT_02']= array ( - 'msg' => _("MAILDIR Support : La constante %{const} n'est pas définie."), - 'level' => 'c' + 'msg' => _("MAILDIR Support : La constante %{const} n'est pas définie.") ); // Autres erreurs $GLOBALS['LSerror_code']['MAILDIR_01']= array ( - 'msg' => _("MAILDIR Support : Erreur durant la création de la maildir sur le serveur distant."), - 'level' => 'c' + 'msg' => _("MAILDIR Support : Erreur durant la création de la maildir sur le serveur distant.") ); $GLOBALS['LSerror_code']['MAILDIR_02']= array ( - 'msg' => _("MAILDIR Support : Erreur durant la création de la maildir sur le serveur distant."), - 'level' => 'c' + 'msg' => _("MAILDIR Support : Erreur durant la suppression de la maildir sur le serveur distant.") +); +$GLOBALS['LSerror_code']['MAILDIR_03']= array ( + 'msg' => _("MAILDIR Support : Erreur durant le renomage de la maildir sur le serveur distant.") ); /** @@ -81,11 +80,15 @@ $retval=true; * @author Benjamin Renard * * @param[in] $ldapObject L'objet ldap + * @param[in] $dir Le chemin de la maildir. Si défini, la valeur ne sera pas + * récupérée dans le ldapObject * * @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'); + function createMaildirByFTP($ldapObject,$dir=null) { + if (!$dir) { + $dir = getFData(LS_MAILDIR_FTP_MAILDIR_PATH,$ldapObject,'getValue'); + } $dirs = array( $dir.'/cur', $dir.'/new', @@ -104,14 +107,36 @@ $retval=true; * @author Benjamin Renard * * @param[in] $ldapObject L'objet ldap + * @param[in] $dir Le chemin de la maildir. Si défini, la valeur ne sera pas + * récupérée dans le ldapObject * * @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'); + function removeMaildirByFTP($ldapObject,$dir=null) { + if (!$dir) { + $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; + } + + /** + * Rename Maildir via FTP + * + * @author Benjamin Renard + * + * @param[in] $old L'ancien chemin de la maildir + * @param[in] $new Le nouveau chemin de la maildir + * + * @retval string True ou false si il y a un problème durant le renomage de la Maildir + */ + function renameMaildirByFTP($old,$new) { + if (!renameDirByFTP(LS_MAILDIR_FTP_HOST,LS_MAILDIR_FTP_PORT,LS_MAILDIR_FTP_USER,LS_MAILDIR_FTP_PWD,$old,$new)) { + $GLOBALS['LSerror'] -> addErrorCode('MAILDIR_03'); + return; + } + return true; } diff --git a/trunk/includes/addons/LSaddons.samba.php b/trunk/includes/addons/LSaddons.samba.php index 44776d72..c2b00253 100644 --- a/trunk/includes/addons/LSaddons.samba.php +++ b/trunk/includes/addons/LSaddons.samba.php @@ -56,7 +56,7 @@ $GLOBALS['LSerror_code']['SAMBA_01']= array ( // Dependance de librairie if ( !class_exists('smbHash') ) { - if ( ! @include_once(LS_LIB_DIR . 'class.smbHash.php') ) { + if ( !LSsession::includeFile(LS_LIB_DIR . 'class.smbHash.php') ) { $GLOBALS['LSerror'] -> addErrorCode('SAMBA_SUPPORT_01'); $retval=false; } diff --git a/trunk/includes/class/class.LSattr_html_maildir.php b/trunk/includes/class/class.LSattr_html_maildir.php new file mode 100644 index 00000000..03444eef --- /dev/null +++ b/trunk/includes/class/class.LSattr_html_maildir.php @@ -0,0 +1,34 @@ + + */ +class LSattr_html_maildir extends LSattr_html { + + var $LSformElement_type = 'maildir'; + +} + +?> diff --git a/trunk/includes/class/class.LSerror.php b/trunk/includes/class/class.LSerror.php index 87036a09..c26292e5 100644 --- a/trunk/includes/class/class.LSerror.php +++ b/trunk/includes/class/class.LSerror.php @@ -29,18 +29,6 @@ */ class LSerror { - var $errors; - /** - * Constructeur - * - * @author Benjamin Renard - * - * @retval void - */ - function LSerror() { - $errors = array(); - } - /** * Ajoute une erreur * @@ -55,7 +43,7 @@ class LSerror { * @retval void */ function addErrorCode($code=-1,$msg='') { - $this -> errors[]=array($code,$msg); + $_SESSION['LSerror'][] = array($code,$msg); } /** @@ -88,7 +76,7 @@ class LSerror { * @retval void */ function stop($code=-1,$msg='') { - if(!empty($this -> errors)) { + if(!empty($_SESSION['LSerror'])) { print "

"._('Errors')."

\n"; print $this -> display(true); } @@ -104,10 +92,11 @@ class LSerror { * @retvat string Le texte des erreurs */ function getErrors() { - if(!empty($this -> errors)) { - foreach ($this -> errors as $error) { + if(!empty($_SESSION['LSerror'])) { + foreach ($_SESSION['LSerror'] as $error) { $txt.=$this -> getError($error); } + $this -> resetError(); return $txt; } return; @@ -132,7 +121,19 @@ class LSerror { * @retvat boolean */ function errorsDefined() { - return !empty($this -> errors); + return !empty($_SESSION['LSerror']); + } + + /** + * Efface les erreurs sotckés + * + * @author Benjamin Renard + * + * @retvat void + */ + function resetError() { + LSlog('reset'); + unset ($_SESSION['LSerror']); } } diff --git a/trunk/includes/class/class.LSformElement_maildir.php b/trunk/includes/class/class.LSformElement_maildir.php new file mode 100644 index 00000000..6f94af23 --- /dev/null +++ b/trunk/includes/class/class.LSformElement_maildir.php @@ -0,0 +1,144 @@ + loadLSclass('LSformElement_text'); +$GLOBALS['LSsession'] -> loadLSaddon('maildir'); + +/** + * Element maildir d'un formulaire pour LdapSaisie + * + * Cette classe définis les éléments maildir des formulaires. + * Elle étant la classe LSformElement_text. + * + * @author Benjamin Renard + */ + +class LSformElement_maildir extends LSformElement_text { + + var $_toDo=null; + + var $JSscripts = array( + 'LSformElement_maildir_field.js', + 'LSformElement_maildir.js' + ); + + var $fieldTemplate = 'LSformElement_maildir_field.tpl'; + + function getDisplay() { + $GLOBALS['LSsession'] -> addHelpInfos ( + 'LSformElement_maildir', + array( + 'do' => _("La création ou modification de la maildir en même temps que l'utilisateur est activée. Cliquer sur ce bouton pour la désactiver."), + 'nodo' => _("Cliquer sur ce bouton pour activer la création/modification de la maildir en même temps que l'utilisateur.") + ) + ); + return parent :: getDisplay($return); + } + + /** + * Recupère la valeur de l'élement passée en POST + * + * Cette méthode vérifie la présence en POST de la valeur de l'élément et la récupère + * pour la mettre dans le tableau passer en paramètre avec en clef le nom de l'élément + * + * @param[] array Pointeur sur le tableau qui recupèrera la valeur. + * + * @retval boolean true si la valeur est présente en POST, false sinon + */ + function getPostData(&$return) { + // Récupère la valeur dans _POST, et les vérifie avec la fonction générale + $retval = parent :: getPostData($return); + + // Si une valeur est recupérée + if ($retval&&$_POST['LSformElement_maildir_description_do']) { + $cur = $this -> form -> ldapObject -> attrs[$this -> name] -> getValue(); + $cur=$cur[0]; + $new = $return[$this -> name][0]; + $action=null; + + if ( $new != $cur ) { + if( ($new=="") && ( $cur!="" ) ) { + $action='delete'; + } + else if ( ($new!="") && ( $cur!="" ) ) { + $action='modify'; + } + else { + $action='create'; + } + + if ($action) { + if ($this -> params['html_options']['remoteRootPathRegex']) { + if ( + (ereg($this -> params['html_options']['remoteRootPathRegex'],$new,$r_new) ||empty($new)) + && + (ereg($this -> params['html_options']['remoteRootPathRegex'],$cur,$r_cur)||empty($cur)) + ) + { + $new = $r_new[1]; + $cur = $r_cur[1]; + } + else { + LSdebug('Pbl remoteRootPathRegex'); + } + } + $this -> _toDo = array ( + 'action' => $action, + 'old' => $cur, + 'new' => $new + ); + $this -> attr_html -> attribute -> addObjectEvent('after_modify',$this,'toDo'); + } + } + } + return $retval; + } + + function toDo() { + if (is_array($this -> _toDo)) { + switch($this -> _toDo['action']) { + case 'delete': + if ($this -> params['html_options']['archiveNameFormat']) { + $newname=getFData($this -> params['html_options']['archiveNameFormat'],$this -> _toDo['old']); + if ($newname) { + return renameMaildirByFTP($this -> _toDo['old'],$newname); + } + LSdebug($this -> name." - LSformElement_maildir->toDo() : Nom d'archivage incorrect."); + return; + } + break; + case 'modify': + return renameMaildirByFTP($this -> _toDo['old'],$this -> _toDo['new']); + break; + case 'create': + return createMaildirByFTP(null,$this -> _toDo['new']); + break; + default: + LSdebug($this -> name.' - LSformElement_maildir->toDo() : Action inconnu.'); + } + } + LSdebug($this -> name.' - LSformElement_maildir->toDo() : Rien à faire.'); + return true; + } +} + +?> diff --git a/trunk/includes/class/class.LSldapObject.php b/trunk/includes/class/class.LSldapObject.php index ff35eaac..77b78a01 100644 --- a/trunk/includes/class/class.LSldapObject.php +++ b/trunk/includes/class/class.LSldapObject.php @@ -318,7 +318,9 @@ class LSldapObject { } // $this -> attrs[*] => before_modify foreach($new_data as $attr_name => $attr_val) { - $this -> attrs[$attr_name] -> fireEvent('before_modify'); + if (!$this -> attrs[$attr_name] -> fireEvent('before_modify')) { + return; + } } if ($this -> submitChange($idForm)) { @@ -334,12 +336,10 @@ class LSldapObject { if(function_exists($this -> config['after_modify'])) { if(!$this -> config['after_modify']($this)) { $GLOBALS['LSerror'] -> addErrorCode('LSldapObject_10',$this -> config['after_modify']); - return; } } else { $GLOBALS['LSerror'] -> addErrorCode('LSldapObject_09',$this -> config['after_modify']); - return; } } diff --git a/trunk/includes/class/class.LSsession.php b/trunk/includes/class/class.LSsession.php index 44a7429e..172e6a2b 100644 --- a/trunk/includes/class/class.LSsession.php +++ b/trunk/includes/class/class.LSsession.php @@ -21,6 +21,7 @@ ******************************************************************************/ define('LS_DEFAULT_CONF_DIR','conf'); +require_once 'includes/functions.php'; /** * Gestion des sessions @@ -65,6 +66,26 @@ class LSsession { } } + /** + * Include un fichier PHP + * + * @author Benjamin Renard + * + * @retval true si tout c'est bien passé, false sinon + */ + function includeFile($file) { + if (!file_exists($file)) { + return; + } + if ($GLOBALS['LSdebug']['active']) { + return include_once($file); + } + else { + return @include_once($file); + } + return; + } + /** * Chargement de la configuration * @@ -76,7 +97,7 @@ class LSsession { */ function loadConfig() { if (loadDir($this -> confDir, '^config\..*\.php$')) { - if ( include_once $GLOBALS['LSconfig']['Smarty'] ) { + if ( self::includeFile($GLOBALS['LSconfig']['Smarty']) ) { $GLOBALS['Smarty'] = new Smarty(); $GLOBALS['Smarty'] -> template_dir = LS_TEMPLATES_DIR; $GLOBALS['Smarty'] -> compile_dir = LS_TMP_DIR; @@ -131,7 +152,7 @@ class LSsession { return true; if($type!='') $type=$type.'.'; - return @include_once LS_CLASS_DIR .'class.'.$type.$class.'.php'; + return self::includeFile(LS_CLASS_DIR .'class.'.$type.$class.'.php'); } /** @@ -147,7 +168,7 @@ class LSsession { if (!$this -> loadLSclass($object,'LSobjects')) { $error = 1; } - if (!include_once( LS_OBJECTS_DIR . 'config.LSobjects.'.$object.'.php' )) { + if (!self::includeFile( LS_OBJECTS_DIR . 'config.LSobjects.'.$object.'.php' )) { $error = 1; } if ($error) { @@ -167,8 +188,8 @@ class LSsession { * @retval boolean true si le chargement a réussi, false sinon. */ function loadLSaddon($addon) { - if(include_once LS_ADDONS_DIR .'LSaddons.'.$addon.'.php') { - @include_once(LS_CONF_DIR."LSaddons/config.LSaddons.".$addon.".php"); + if(self::includeFile(LS_ADDONS_DIR .'LSaddons.'.$addon.'.php')) { + self::includeFile(LS_CONF_DIR."LSaddons/config.LSaddons.".$addon.".php"); if (!call_user_func('LSaddon_'. $addon .'_support')) { $GLOBALS['LSerror'] -> addErrorCode('LSsession_02',$addon); return; @@ -562,7 +583,7 @@ class LSsession { */ function LSldapConnect() { if ($this -> ldapServer) { - @include_once($GLOBALS['LSconfig']['NetLDAP2']); + self::includeFile($GLOBALS['LSconfig']['NetLDAP2']); if (!$this -> loadLSclass('LSldap')) { return; } @@ -965,6 +986,11 @@ class LSsession { * @retval void */ function displayAjaxReturn($data=array()) { + if (isset($data['LSredirect']) && (!LSdebugDefined()) ) { + echo json_encode($data); + return; + } + $data['LSjsConfig'] = $this -> _JSconfigParams; // Infos diff --git a/trunk/includes/functions.php b/trunk/includes/functions.php index 12e32b21..1a533908 100644 --- a/trunk/includes/functions.php +++ b/trunk/includes/functions.php @@ -185,6 +185,11 @@ function valid($obj) { return true; } +function validPas($obj=null) { + LSdebug('Validation : nok'); + return false; +} + function return_data($data) { return $data; } @@ -400,5 +405,14 @@ function LSdebugDefined() { else return 1; } - + + function LSlog($msg) { + if ($GLOBALS['LSlog']['enable']) { + global $LSlogFile; + if (!$LSlogFile) { + $LSlogFile=fopen($GLOBALS['LSlog']['filename'],'a'); + } + fwrite($LSlogFile,$_SERVER['REQUEST_URI']." : ".$msg."\n"); + } + } ?> diff --git a/trunk/includes/js/LSdefault.js b/trunk/includes/js/LSdefault.js index da02513f..b4890af8 100644 --- a/trunk/includes/js/LSdefault.js +++ b/trunk/includes/js/LSdefault.js @@ -1,15 +1,16 @@ var LSdefault = new Class({ initialize: function(){ this.LSdebug = $('LSdebug'); - this.LSdebug.addEvent('dblclick',this.LSdebugHidde.bind(this)); + this.LSdebug.addEvent('dblclick',this.hideLSdebug.bind(this)); this.LSdebugInfos = $('LSdebug_infos'); this.LSdebug.setOpacity(0); this.LSdebugHidden = $('LSdebug_hidden'); - this.LSdebugHidden.addEvent('click',this.LSdebugHidde.bind(this)); + this.LSdebugHidden.addEvent('click',this.hideLSdebug.bind(this)); this.LSerror = $('LSerror'); this.LSerror.setOpacity(0); + this.LSerror.addEvent('dblclick',this.hideLSerror.bind(this)); this.LSinfos = $('LSinfos'); @@ -71,12 +72,21 @@ var LSdefault = new Class({ $('LSsession_topDn_form').submit(); }, - LSdebugHidde: function(){ + hideLSdebug: function(){ this.fx.LSdebug.start(0.8,0); }, + + hideLSerror: function(){ + this.fx.LSerror.start(0.9,0); + }, checkAjaxReturn: function(data) { if ($type(data) == 'object') { + if (($type(data.LSredirect)) && (!$type(data.LSdebug)) ) { + document.location = data.LSredirect; + return true; + } + if ($type(data.imgload)) { this.loadingImgHide(data.imgload); } @@ -124,7 +134,6 @@ var LSdefault = new Class({ displayErrorBox: function() { this.LSerror.setStyle('top',getScrollTop()+10); this.fx.LSerror.start(0,0.8); - (function(){this.fx.LSerror.start(0.8,0);}).delay(10000, this); }, displayInfosBox: function() { diff --git a/trunk/includes/js/LSform.js b/trunk/includes/js/LSform.js index a2c11d69..71c63cac 100644 --- a/trunk/includes/js/LSform.js +++ b/trunk/includes/js/LSform.js @@ -176,12 +176,7 @@ var LSform = new Class({ onAjaxSubmitComplete: function(responseText, responseXML) { var data = JSON.decode(responseText); if ( varLSdefault.checkAjaxReturn(data) ) { - if ($type(data.LSformRedirect)) { - if (!$type(data.LSdebug)) { - (function(addr){document.location = addr;}).delay(1000,this,data.LSformRedirect); - } - } - else if ($type(data.LSformErrors) == 'object') { + if ($type(data.LSformErrors) == 'object') { data.LSformErrors = new Hash(data.LSformErrors); data.LSformErrors.each(this.addError,this); } diff --git a/trunk/includes/js/LSformElement_maildir.js b/trunk/includes/js/LSformElement_maildir.js new file mode 100644 index 00000000..a2f9c0aa --- /dev/null +++ b/trunk/includes/js/LSformElement_maildir.js @@ -0,0 +1,17 @@ +var LSformElement_maildir = new Class({ + initialize: function(){ + this.fields=new Hash(); + this.initialiseLSformElement_maildir(); + }, + + initialiseLSformElement_maildir: function() { + var getName = /^(.*)\[\]$/ + $$('input.LSformElement_maildir').each(function(input) { + var name = getName.exec(input.name)[1]; + this.fields[name] = new LSformElement_maildir_field(name,input); + }, this); + } +}); +window.addEvent(window.ie ? 'load' : 'domready', function() { + varLSformElement_maildir = new LSformElement_maildir(); +}); diff --git a/trunk/includes/js/LSformElement_maildir_field.js b/trunk/includes/js/LSformElement_maildir_field.js new file mode 100644 index 00000000..45f14ba7 --- /dev/null +++ b/trunk/includes/js/LSformElement_maildir_field.js @@ -0,0 +1,50 @@ +var LSformElement_maildir_field = new Class({ + initialize: function(name,input){ + this.name = name; + this.input = input; + this.params = varLSdefault.getParams(this.name); + this.initialiseLSformElement_maildir_field(); + }, + + initialiseLSformElement_maildir_field: function() { + if (!$type(varLSform.idform)) { + return true; + } + if ($type(this.params.LSform[varLSform.idform])) { + this.doBtn = new Element('img'); + this.doBtn.addClass('btn'); + this.doBtn.addEvent('click',this.onDoBtnClick.bind(this)); + this.doInput = new Element('input'); + this.doInput.setProperties({ + name: 'LSformElement_maildir_' + this.name + '_do', + type: 'hidden' + }); + if (this.params.LSform[varLSform.idform]) { + this.doInput.value = 1; + this.doBtn.src = varLSdefault.imagePath('maildir_do.png'); + varLSdefault.addHelpInfo(this.doBtn,'LSformElement_maildir','do'); + } + else { + this.doInput.value = 0; + this.doBtn.src = varLSdefault.imagePath('maildir_nodo.png'); + varLSdefault.addHelpInfo(this.doBtn,'LSformElement_maildir','nodo'); + } + this.doBtn.injectAfter(this.input); + this.doInput.injectAfter(this.doBtn); + } + }, + + onDoBtnClick: function() { + if (this.doInput.value==0) { + this.doInput.value = 1; + this.doBtn.src = varLSdefault.imagePath('maildir_do.png'); + varLSdefault.setHelpInfo(this.doBtn,'LSformElement_maildir','do'); + } + else { + this.doInput.value = 0; + this.doBtn.src = varLSdefault.imagePath('maildir_nodo.png'); + varLSdefault.setHelpInfo(this.doBtn,'LSformElement_maildir','nodo'); + } + } + +}); diff --git a/trunk/index.php b/trunk/index.php index d5125a6c..6341c49f 100644 --- a/trunk/index.php +++ b/trunk/index.php @@ -20,7 +20,6 @@ ******************************************************************************/ -require_once 'includes/functions.php'; require_once 'includes/class/class.LSsession.php'; $GLOBALS['LSsession'] = new LSsession(); diff --git a/trunk/index_ajax.php b/trunk/index_ajax.php index 797ea77a..e403529c 100644 --- a/trunk/index_ajax.php +++ b/trunk/index_ajax.php @@ -1,6 +1,5 @@ startLSsession()) { if (isset($_REQUEST['ajax'])) { $GLOBALS['LSsession'] -> displayAjaxReturn ( array( - 'LSformRedirect' => 'view.php?LSobject='.$LSobject.'&dn='.$object -> getDn() + 'LSredirect' => 'view.php?LSobject='.$LSobject.'&dn='.$object -> getDn() ) ); + exit(); } else { - if ((!LSdebugDefined()) && !$GLOBALS['LSerror']->errorsDefined()) { + if (!LSdebugDefined()) { $GLOBALS['LSsession'] -> redirect('view.php?LSobject='.$LSobject.'&dn='.$object -> getDn()); } else { diff --git a/trunk/remove.php b/trunk/remove.php index d55d12d7..46319c2c 100644 --- a/trunk/remove.php +++ b/trunk/remove.php @@ -20,7 +20,6 @@ ******************************************************************************/ -require_once 'includes/functions.php'; require_once 'includes/class/class.LSsession.php'; $GLOBALS['LSsession'] = new LSsession(); diff --git a/trunk/select.php b/trunk/select.php index 324f5f72..d75ffc4b 100644 --- a/trunk/select.php +++ b/trunk/select.php @@ -20,7 +20,6 @@ ******************************************************************************/ -require_once 'includes/functions.php'; require_once 'includes/class/class.LSsession.php'; $GLOBALS['LSsession'] = new LSsession(); diff --git a/trunk/templates/default/LSformElement_maildir_field.tpl b/trunk/templates/default/LSformElement_maildir_field.tpl new file mode 100644 index 00000000..15404914 --- /dev/null +++ b/trunk/templates/default/LSformElement_maildir_field.tpl @@ -0,0 +1,5 @@ +{if $freeze} +{if $value}{$value}{else}{$noValueTxt}{/if} +{else} + +{/if} diff --git a/trunk/view.php b/trunk/view.php index 9c35cb42..51bb5109 100644 --- a/trunk/view.php +++ b/trunk/view.php @@ -20,7 +20,6 @@ ******************************************************************************/ -require_once 'includes/functions.php'; require_once 'includes/class/class.LSsession.php'; $GLOBALS['LSsession'] = new LSsession();