+ if ($clean || $update) {
+ $this->saveToFile();
+ }
+ }
+
+ private function clean(&$first, &$last, $msgnum)
+ {
+ $do_save = false;
+ if (!empty($this->overview)) {
+ $mids = array_keys($this->overview);
+ foreach ($mids as $id) {
+ if (($first <= $last && ($id < $first || $id > $last))
+ || ($first > $last && $id < $first && $id > $last)) {
+ $this->delid($id, false);
+ $do_save = true;
+ }
+ }
+ if (!empty($this->overview)) {
+ $first = max(array_keys($this->overview))+1;
+ }
+ }
+ return $do_save;
+ }
+
+ private function update(&$first, &$last, $msgnum)
+ {
+ if ($first > $last || !$msgnum) {
+ return false;
+ }
+
+ $messages =& Banana::$protocole->getMessageHeaders($first, $last,
+ array('Date', 'Subject', 'From', 'Message-ID', 'References', 'In-Reply-To'));
+
+ // Build all the new Spool Heads
+ $time = time();
+ foreach ($messages as $id=>&$message) {
+ if (!isset($this->overview[$id])) {
+ $this->overview[$id] = new BananaSpoolHead($id, $message);
+ $head =& $this->overview[$id];
+ $this->ids[$head->msgid] =& $head;
+ $head->time = $time;
+ }