From 6c61f671f5bc9417b63bdba49381f3d5dd6c35e3 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Wed, 1 Apr 2009 15:55:13 +0000 Subject: [PATCH] =?UTF-8?q?-=20LSattr=5Fhtml=5Fmaildir=20&=20LSformElement?= =?UTF-8?q?=5Fmaildir=20:=20=09->=20Refonte=20pour=20passer=20la=20gestion?= =?UTF-8?q?=20des=20bindings=20depuis=20l'attribut=20HTML=20=09=09=20et=20?= =?UTF-8?q?ainsi=20pouvoir=20g=C3=A9rer=20la=20suppression/archivage=20de?= =?UTF-8?q?=20la=20boite=20mail=20lors=20=09=09=20de=20la=20suppression=20?= =?UTF-8?q?d'un=20objet=20(hors=20LSform=20et=20donc=20sans=20LSformElemen?= =?UTF-8?q?t)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../class/class.LSattr_html_maildir.php | 100 ++++++++++++++++++ .../class/class.LSformElement_maildir.php | 71 +------------ 2 files changed, 104 insertions(+), 67 deletions(-) diff --git a/trunk/includes/class/class.LSattr_html_maildir.php b/trunk/includes/class/class.LSattr_html_maildir.php index 03444eef..4c57699a 100644 --- a/trunk/includes/class/class.LSattr_html_maildir.php +++ b/trunk/includes/class/class.LSattr_html_maildir.php @@ -20,6 +20,8 @@ ******************************************************************************/ +LSsession :: loadLSaddon('maildir'); + /** * Type d'attribut HTML maildir * @@ -28,6 +30,104 @@ class LSattr_html_maildir extends LSattr_html { var $LSformElement_type = 'maildir'; + var $_toDo = array(); + + function LSattr_html_maildir ($name,$config,&$attribute) { + $attribute -> addObjectEvent('before_delete',$this,'beforeDelete'); + $attribute -> addObjectEvent('after_delete',$this,'deleteMaildirByFTP'); + return parent :: LSattr_html($name,$config,&$attribute); + } + + public function doOnModify($action,$cur,$new) { + $this -> _toDo = array ( + 'action' => $action, + 'old' => $cur, + 'new' => $new + ); + $this -> attribute -> addObjectEvent('after_modify',$this,'toDo'); + } + + function toDo() { + if (is_array($this -> _toDo)) { + switch($this -> _toDo['action']) { + case 'delete': + return $this -> deleteMaildirByFTP(); + break; + case 'modify': + if (renameMaildirByFTP($this -> _toDo['old'],$this -> _toDo['new'])) { + LSsession :: addInfo(_("The mailbox has been moved.")); + return true; + } + return; + break; + case 'create': + if (createMaildirByFTP(null,$this -> _toDo['new'])) { + LSsession :: addInfo(_("The mailbox has been created.")); + return true; + } + return; + break; + default: + LSdebug($this -> name.' - LSformElement_maildir->toDo() : Unknown action.'); + } + } + LSdebug($this -> name.' - LSformElement_maildir->toDo() : Nothing to do.'); + return true; + } + + public function deleteMaildirByFTP() { + if ($this -> config['html_options']['archiveNameFormat']) { + LSdebug('LSformElement_maildir : archive'); + $newname=getFData($this -> config['html_options']['archiveNameFormat'],$this -> _toDo['old']); + if ($newname) { + if (renameMaildirByFTP($this -> _toDo['old'],$newname)) { + LSsession :: addInfo(_("The mailbox has been archived successfully.")); + return true; + } + return; + } + LSdebug($this -> name." - LSformElement_maildir->toDo() : Incorrect archive name."); + return; + } + else { + LSdebug('LSformElement_maildir : delete'); + if (removeMaildirByFTP(null,$this -> _toDo['old'])) { + LSsession :: addInfo(_("The mailbox has been deleted.")); + return true; + } + return; + } + } + + public function beforeDelete() { + $this -> _toDo = array ( + 'action' => 'delete', + 'old' => $this -> getRemoteRootPathRegex(), + 'new' => '' + ); + } + + public function getRemoteRootPathRegex($val='LS') { + if ($val=='LS') { + $val = $this -> attribute -> getValue(); + $val=$val[0]; + } + LSdebug($this -> config['html_options']['remoteRootPathRegex']); + if ($this -> config['html_options']['remoteRootPathRegex']) { + if ( + ereg($this -> config['html_options']['remoteRootPathRegex'],$val,$r) + || + empty($val) + ) + { + $val = $r[1]; + } + else { + LSdebug('Pbl remoteRootPathRegex'); + } + } + return $val; + } } diff --git a/trunk/includes/class/class.LSformElement_maildir.php b/trunk/includes/class/class.LSformElement_maildir.php index f74a25af..adeb174e 100644 --- a/trunk/includes/class/class.LSformElement_maildir.php +++ b/trunk/includes/class/class.LSformElement_maildir.php @@ -21,7 +21,6 @@ ******************************************************************************/ LSsession :: loadLSclass('LSformElement_text'); -LSsession :: loadLSaddon('maildir'); /** * Element maildir d'un formulaire pour LdapSaisie @@ -106,77 +105,15 @@ class LSformElement_maildir extends LSformElement_text { } 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'); + $new = $this -> attr_html -> getRemoteRootPathRegex($new); + $cur = $this -> attr_html -> getRemoteRootPathRegex($cur); + $this -> attr_html -> doOnModify($action,$cur,$new); } } } 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) { - if (renameMaildirByFTP($this -> _toDo['old'],$newname)) { - LSsession :: addInfo(_("The mailbox has been archived successfully.")); - return true; - } - return; - } - LSdebug($this -> name." - LSformElement_maildir->toDo() : Incorrect archive name."); - return; - } - else { - if (removeMaildirByFTP(null,$this -> _toDo['old'])) { - LSsession :: addInfo(_("The mailbox has been deleted.")); - return true; - } - return; - } - break; - case 'modify': - if (renameMaildirByFTP($this -> _toDo['old'],$this -> _toDo['new'])) { - LSsession :: addInfo(_("The mailbox has been moved.")); - return true; - } - return; - break; - case 'create': - if (createMaildirByFTP(null,$this -> _toDo['new'])) { - LSsession :: addInfo(_("The mailbox has been created.")); - return true; - } - return; - break; - default: - LSdebug($this -> name.' - LSformElement_maildir->toDo() : Unknown action.'); - } - } - LSdebug($this -> name.' - LSformElement_maildir->toDo() : Nothing to do.'); - return true; - } + } ?>