Reply composition support pre-filled answers.
[banana.git] / banana / banana.inc.php.in
index 1311029..4bbd578 100644 (file)
@@ -37,6 +37,10 @@ class Banana
     static public $spool_tmax    = 10;
     static public $spool_boxlist = true;
 
+### Tree options ###
+    static public $tree_read  = 'dg';
+    static public $tree_unread = 'b';
+
 ### Message processing ###
     static public $msgparse_headers = array('content-disposition', 'content-transfer-encoding',
                                        'content-type', 'content-id', 'date', 'followup-to',
@@ -476,6 +480,9 @@ class Banana
             $groups    = Banana::$protocole->getBoxList(Banana::BOXES_SUB, Banana::$profile['lastnews'], true);
             Banana::$page->assign('groups', $groups);
         }
+        if (function_exists('hook_markAsRead')) {
+            hook_markAsRead($group, $artid, $msg);
+        }
         Banana::$page->assign_by_ref('message', $msg);
         Banana::$page->assign('extimages', Banana::$msgshow_hasextimages);
         Banana::$page->assign('headers', Banana::$msgshow_headers);
@@ -505,7 +512,7 @@ class Banana
                     $hdr_values[$header] = utf8_encode($hdr_values[$header]);
                 }
             }
-            $values = split('[,; ]', $hdr_values[$hdrs['dest']]);
+            $values = preg_split('/[,; ]/', $hdr_values[$hdrs['dest']]);
             $hdr_values[$hdrs['dest']] = preg_replace('/,+/', ',', implode(',', $values));
             if (!is_null($artid)) {
                 $old =& $this->loadMessage($group, $artid);
@@ -541,7 +548,20 @@ class Banana
         } else {
             if (!is_null($artid)) {
                 $msg    =& $this->loadMessage($group, $artid);
-                $body    = $msg->getSender() . _b_(' a écrit :') . "\n" . $msg->quote();
+                $body    = $msg->quote();
+
+                if (isset($_POST['reply'])) {
+                    $body = explode("\n", $body);
+                    $replies = $_POST['reply'];
+                    krsort($replies);
+                    foreach ($replies as $line => $text) {
+                        $text = explode("\n", "\n" . $text . "\n");
+                        array_splice($body, $line + 1, 0, $text);
+                    }
+                    $body = implode("\n", $body);
+                }
+                $body = $msg->getSender() . _b_(' a écrit :') . "\n" . $body;
+
                 $subject = $msg->getHeaderValue('subject');
                 $headers['Subject']['user'] = 'Re: ' . preg_replace("/^re\s*:\s*/i", '', $subject);
                 $target  = $msg->getHeaderValue($hdrs['reply']);