From c28d3016da8664a6ff75b469c320509fd9abc392 Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Mon, 15 Jan 2007 09:57:02 +0000 Subject: [PATCH] Unfound mbox is now handled as if it was empty git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@171 9869982d-c50d-0410-be91-f2a2ec7c7c7b --- banana/mbox.inc.php | 32 ++++++++++++++++++++++-------- banana/spool.inc.php | 3 +++ banana/templates/banana-newmessage.inc.tpl | 8 ++++---- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/banana/mbox.inc.php b/banana/mbox.inc.php index 7d6196b..c124041 100644 --- a/banana/mbox.inc.php +++ b/banana/mbox.inc.php @@ -30,16 +30,16 @@ class BananaMBox implements BananaProtocoleInterface */ public function __construct() { - $filename = $this->getFileName(Banana::$group); + $filename = $this->getFileName(); if (is_null($filename)) { return; } - $this->filesize = filesize($filename); $this->file = @fopen($filename, 'r'); if (!$this->file) { - $this->_lasterrno = 1; - $this->_lasterror = _b_('Can\'t open file'); $this->file = null; + $this->filesize = 0; + } else { + $this->filesize = filesize($filename); } $this->current_id = 0; $this->at_beginning = true; @@ -58,7 +58,8 @@ class BananaMBox implements BananaProtocoleInterface */ public function isValid() { - return !Banana::$group || $this->file; + return true; + //!Banana::$group || $this->file; } /** Indicate last error n° @@ -100,6 +101,9 @@ class BananaMBox implements BananaProtocoleInterface public function &getMessage($id) { $message = null; + if (is_null($this->file)) { + return $message; + } if (!is_numeric($id)) { if (!Banana::$spool) { return $message; @@ -118,6 +122,9 @@ class BananaMBox implements BananaProtocoleInterface public function getMessageSource($id) { $message = null; + if (is_null($this->file)) { + return $message; + } if (!is_numeric($id)) { if (!Banana::$spool) { return $message; @@ -147,6 +154,9 @@ class BananaMBox implements BananaProtocoleInterface */ public function getIndexes() { + if (is_null($this->file)) { + return array(0, 0, 0); + } if (is_null($this->count)) { $this->getCount(); } @@ -162,6 +172,9 @@ class BananaMBox implements BananaProtocoleInterface $messages =& $this->readMessages(range($firstid, $lastid), true); $msg_headers = array_map('strtolower', $msg_headers); $headers = array(); + if (is_null($this->file)) { + return $headers; + } foreach ($msg_headers as $header) { foreach ($messages as $id=>&$message) { if (!isset($headers[$id])) { @@ -196,6 +209,9 @@ class BananaMBox implements BananaProtocoleInterface */ public function getNewIndexes($since) { + if (is_null($this->file)) { + return array(); + } if (is_null($this->new_messages)) { $this->getCount(); } @@ -278,12 +294,12 @@ class BananaMBox implements BananaProtocoleInterface # Filesystem functions ####### - protected function getFileName($box) + protected function getFileName() { - if (is_null($box)) { + if (is_null(Banana::$group)) { return null; } - @list($mail, $domain) = explode('@', $box); + @list($mail, $domain) = explode('@', Banana::$group); return Banana::$mbox_path . '/' . $mail; } diff --git a/banana/spool.inc.php b/banana/spool.inc.php index d6bc579..4ed8ab6 100644 --- a/banana/spool.inc.php +++ b/banana/spool.inc.php @@ -303,6 +303,9 @@ class BananaSpool if (is_null($array)) { $array =& $this->roots; } + if (!is_array($this->roots)) { + return; + } foreach ($array as $id) { if (!$this->overview[$id]->isread) { $this->markAsRead($id); diff --git a/banana/templates/banana-newmessage.inc.tpl b/banana/templates/banana-newmessage.inc.tpl index 5ad87f4..853e785 100644 --- a/banana/templates/banana-newmessage.inc.tpl +++ b/banana/templates/banana-newmessage.inc.tpl @@ -4,7 +4,7 @@ {"Composer un nouveau message"|b} {foreach from=$headers key=header item=values} - + {$values.name} {if $values.fixed} @@ -15,13 +15,13 @@ {/foreach} - + {if $can_attach} - + {"Fichier joint"|b} {if $maxfilesize} @@ -31,7 +31,7 @@ {/if} - + -- 2.1.4