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 00000000..35498f68 Binary files /dev/null and b/trunk/images/default/maildir_do.png differ diff --git a/trunk/images/default/maildir_nodo.png b/trunk/images/default/maildir_nodo.png new file mode 100644 index 00000000..c00302ea Binary files /dev/null and b/trunk/images/default/maildir_nodo.png differ 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();