2 /*******************************************************************************
3 * Copyright (C) 2007 Easter-eggs
4 * http://ldapsaisie.labs.libre-entreprise.org
6 * Author: See AUTHORS file in top-level directory.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 ******************************************************************************/
23 LSsession :: loadLSaddon('maildir');
26 * Type d'attribut HTML maildir
28 * @author Benjamin Renard <brenard@easter-eggs.com>
30 class LSattr_html_maildir extends LSattr_html {
32 var $LSformElement_type = 'maildir';
35 function LSattr_html_maildir ($name,$config,&$attribute) {
36 $attribute -> addObjectEvent('before_delete',$this,'beforeDelete');
37 $attribute -> addObjectEvent('after_delete',$this,'deleteMaildirByFTP');
38 return parent :: LSattr_html($name,$config,&$attribute);
41 public function doOnModify($action,$cur,$new) {
42 $this -> _toDo = array (
47 $this -> attribute -> addObjectEvent('after_modify',$this,'toDo');
51 if (is_array($this -> _toDo)) {
52 switch($this -> _toDo['action']) {
54 return $this -> deleteMaildirByFTP();
57 if (renameMaildirByFTP($this -> _toDo['old'],$this -> _toDo['new'])) {
58 LSsession :: addInfo(_("The mailbox has been moved."));
64 if (createMaildirByFTP(null,$this -> _toDo['new'])) {
65 LSsession :: addInfo(_("The mailbox has been created."));
71 LSdebug($this -> name.' - LSformElement_maildir->toDo() : Unknown action.');
74 LSdebug($this -> name.' - LSformElement_maildir->toDo() : Nothing to do.');
78 public function deleteMaildirByFTP() {
79 if ($this -> config['html_options']['archiveNameFormat']) {
80 LSdebug('LSformElement_maildir : archive');
81 $newname=getFData($this -> config['html_options']['archiveNameFormat'],$this -> _toDo['old']);
83 if (renameMaildirByFTP($this -> _toDo['old'],$newname)) {
84 LSsession :: addInfo(_("The mailbox has been archived successfully."));
89 LSdebug($this -> name." - LSformElement_maildir->toDo() : Incorrect archive name.");
93 LSdebug('LSformElement_maildir : delete');
94 if (removeMaildirByFTP(null,$this -> _toDo['old'])) {
95 LSsession :: addInfo(_("The mailbox has been deleted."));
102 public function beforeDelete() {
103 $this -> _toDo = array (
104 'action' => 'delete',
105 'old' => $this -> getRemoteRootPathRegex(),
110 public function getRemoteRootPathRegex($val='LS') {
112 $val = $this -> attribute -> getValue();
115 if ($this -> config['html_options']['remoteRootPathRegex']) {
117 ereg($this -> config['html_options']['remoteRootPathRegex'],$val,$r)
125 LSdebug('Pbl remoteRootPathRegex');