if (!Banana::$spool || Banana::$spool->group != $this->group) {
return false;
}
- if (!Banana::$spool->ids) {
+ if (empty(Banana::$spool->overview)) {
$spool_indexes = array();
} else {
- $spool_indexes = Banana::$spool->ids;
+ $spool_indexes = array_keys(Banana::$spool->overview);
sort($spool_indexes, SORT_NUMERIC);
$spool_indexes = array_slice($spool_indexes, -Banana::$feed_size, Banana::$feed_size);
- }
+ }
$feed_indexes = array_keys($this->messages);
$old = array_diff($feed_indexes, $spool_indexes);
foreach ($old as $key) {
$new = array_diff($spool_indexes, $feed_indexes);
foreach ($new as $key) {
$message =& Banana::$protocole->getMessage($key);
+ if (is_null($message)) {
+ return;
+ }
$array = array();
$array['author'] = $message->getAuthorName();
$array['date'] = $message->getHeaderValue('Date');
private $_lasterrno = 0;
private $_lasterror = null;
-
+
public function __construct()
{
$this->debug = Banana::$debug_mbox;
}
-
+
public function isValid()
{
return true;
//!Banana::$group || $this->file;
}
-
+
/** Indicate last error n°
*/
public function lastErrNo()
{
return $this->_lasterrno;;
}
-
+
/** Indicate last error text
*/
public function lastError()
{
$message = null;
if (!is_numeric($id)) {
- if (!Banana::$spool) {
+ if (!Banana::$spool) {
return $message;
}
- $id = Banana::$spool->ids[$id];
+ $id = Banana::$spool->ids[$id]->id;
}
$options = array ('-m ' . $id);
$this->getMBoxPosition($options, $id);
$messages =& $this->getRawMessage($id);
if ($messages) {
$messages = new BananaMessage($messages);
+ } else {
+ $messages = null;
}
- return $messages;
+ return $messages;
}
/** Return the sources of the given message
*/
public function getMessageSource($id)
- {
+ {
$message =& $this->getRawMessage($id);
if ($message) {
- $message = implode("\n", $message);
+ $message = implode("\n", $message);
}
return $message;
- }
+ }
/** Compute the number of messages of the box
*/
private function getCount()
{
$options = array();
- if (@filesize($this->getFileName()) == Banana::$spool->storage['size']) {
- return max(Banana::$spool->ids) + 1;
- }
+ if (@filesize($this->getFileName()) == @Banana::$spool->storage['size']) {
+ return max(array_keys(Banana::$spool->overview)) + 1;
+ }
$this->getMBoxPosition($options);
$val =& $this->callHelper('-c', $options);
if (!$val) {
return array();
}
if (is_null($this->new_messages)) {
- $this->getCount();
+ $this->getCount();
}
return range($this->count - $this->new_messages, $this->count - 1);
}
foreach ($headers as $key=>$value) {
if (!empty($value)) {
$hdrs .= "$key: $value\r\n";
- }
+ }
}
$body = $message->get(false);
return mail($to, $subject, $body, $hdrs);
#######
# MBox parser
#######
-
+
/** Add the '-p' optioin for callHelper
*/
private function getMBoxPosition(array &$options, $id = null)
if (!is_null($id) && isset(Banana::$spool->overview[$id])) {
$key = $id;
} else {
- $key = max(Banana::$spool->ids);
+ $key = max(array_keys(Banana::$spool->overview));
if (!is_null($id) && $key >= $id) {
return;
}
}
- if (isset(Banana::$spool->overview[$key]->storage['offset'])) {
+ if (isset(Banana::$spool->overview[$key]->storage['offset'])) {
$options[] = '-p ' . $key . ':' . Banana::$spool->overview[$key]->storage['offset'];
}
}
public function __construct($id, array &$message)
{
$this->id = $id;
- $this->msgid = $message['message-id'];
+ $this->msgid = @$message['message-id'];
$this->date = $message['date'];
- $this->subject = $message['subject'];
+ $this->subject = @$message['subject'];
$this->from = $message['from'];
$this->color = sprintf('#%06x', abs(crc32($this->from) % 0xffffff));
$this->desc = 1;
$msg =& $this->overview[$id];
$parents =& $this->getReferences($message);
while (!empty($parents) && ($msg->parent === $msg || is_null($msg->parent))) {
- $msg->parent =& array_pop($parents);
+ @$msg->parent =& array_pop($parents);
}
if (!is_null($msg->parent)) {