class BananaMBox implements BananaProtocoleInterface
{
- private $boxname;
-
private $file = null;
private $filesize = null;
private $current_id = null;
/** Build a protocole handler plugged on the given box
*/
- public function __construct($box = null)
+ public function __construct()
{
- $this->boxname = $box;
- $filename = $this->getFileName($box);
+ $filename = $this->getFileName(Banana::$group);
if (is_null($filename)) {
return;
}
*/
public function isValid()
{
- return is_null($this->boxname) || !is_null($this->file);
+ return !Banana::$group || $this->file;
}
- /** Indicate last error n°
+ /** Indicate last error n°
*/
public function lastErrNo()
{
*/
public function getBoxList($mode = Banana::BOXES_ALL, $since = 0, $withstats = false)
{
- return array($this->boxname => array('desc' => '', 'msgnum' => 0, 'unread' => 0));
+ return array(Banana::$group => array('desc' => '', 'msgnum' => 0, 'unread' => 0));
}
/** Return a message
* @param id Id of the emssage (can be either an Message-id or a message index)
- * @param msg_headers Headers to process
- * @param is_msgid If is set, $id is en Message-Id
* @return A BananaMessage or null if the given id can't be retreived
*/
- public function getMessage($id, array $msg_headers = array(), $is_msgid = false)
+ public function &getMessage($id)
{
- if ($is_msgid || !is_numeric($id)) {
- if (is_null(Banana::$spool)) {
- return null;
+ $message = null;
+ if (!is_numeric($id)) {
+ if (!Banana::$spool) {
+ return $message;
}
$id = Banana::$spool->ids[$id];
}
$message = $this->readMessages(array($id));
if (empty($message)) {
- return null;
+ $message = null;
+ return $message;
}
- $msg = new BananaMessage($message[$id]['message']);
- return $msg;
+ return new BananaMessage($message[$id]['message']);
}
+ /** Return the sources of the given message
+ */
+ public function getMessageSource($id)
+ {
+ $message = null;
+ if (!is_numeric($id)) {
+ if (!Banana::$spool) {
+ return $message;
+ }
+ $id = Banana::$spool->ids[$id];
+ }
+ $message = $this->readMessages(array($id));
+ return implode("\n", $message[$id]['message']);
+ }
+
+ /** Compute the number of messages of the box
+ */
private function getCount()
{
$this->count = count(Banana::$spool->overview);
$headers[$id] = array('beginning' => $message['beginning'], 'end' => $message['end']);
}
if ($header == 'date') {
- $headers[$id][$header] = strtotime($message['message'][$header]);
+ $headers[$id][$header] = @strtotime($message['message'][$header]);
} else {
- $headers[$id][$header] = $message['message'][$header];
+ $headers[$id][$header] = @$message['message'][$header];
}
}
}
return 'MBOX';
}
+ /** Return the spool filename
+ */
+ public function filename()
+ {
+ @list($mail, $domain) = explode('@', Banana::$group);
+ $file = "";
+ if (isset($domain)) {
+ $file = $domain . '_';
+ }
+ return $file . $mail;
+ }
+
#######
# Filesystem functions
#######
return null;
}
@list($mail, $domain) = explode('@', $box);
- if ($mail == 'staff') {
- return '/home/x2003bruneau/staff.polytechnique.org_innovation.mbox';
- } else {
- return '/var/mail/' . $mail;
- }
+ return Banana::$mbox_path . '/' . $mail;
}
#######
*/
private function &readMessages(array $ids, $strip = false, $from = false)
{
- if (!is_null($this->messages)) {
+ if ($this->messages) {
return $this->messages;
}
sort($ids);
}
}
-// vim:set et sw=4 sts=4 ts=4:
+// vim:set et sw=4 sts=4 ts=4 enc=utf-8:
?>