protected function action_showMessage($group, $artid, $partid = 'text')
{
Banana::$page->setPage('message');
- if ($partid == 'text') {
+ $istext = $partid == 'text' || $partid == 'source'
+ || preg_match("/[-a-z0-9_]+\/[-a-z0-9_]+/", $partid);
+ if ($istext) {
$this->loadSpool($group);
}
$msg =& $this->loadMessage($group, $artid);
if ($partid == 'xface') {
$msg->getXFace();
exit;
- } elseif ($partid != 'text') {
+ } elseif (!$istext) {
$part = $msg->getPartById($partid);
if (!is_null($part)) {
$part->send(true);
$part->send();
}
exit;
+ } elseif ($partid == 'text') {
+ Banana::$page->assign('body', $msg->getFormattedBody());
+ } elseif ($partid == 'source') {
+ Banana::$page->assign('body',
+ '<pre>' . banana_htmlentities(Banana::$protocole->getMessageSource($artid)) . '</pre>');
+ } else {
+ Banana::$page->assign('body', $msg->getFormattedBody($partid));
}
+
if (Banana::$profile['autoup']) {
Banana::$spool->markAsRead($artid);
}
/** 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)) {
+ if (!is_numeric($id)) {
+ if (!Banana::$spool) {
return null;
}
$id = Banana::$spool->ids[$id];
return $msg;
}
+ /** Return the sources of the given message
+ */
+ public function getMessageSource($id)
+ {
+ if (!is_numeric($id)) {
+ if (!Banana::$spool) {
+ return null;
+ }
+ $id = Banana::$spool->ids[$id];
+ }
+ $message = $this->readMessages(array($id));
+ return implode("\n", $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];
}
}
}
*/
private function &readMessages(array $ids, $strip = false, $from = false)
{
- if (!is_null($this->messages)) {
+ if ($this->messages) {
return $this->messages;
}
sort($ids);
/** 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 && Banana::$group != $this->ingroup) {
+ if (is_numeric($id) && Banana::$group != $this->ingroup) {
if (is_null(Banana::$spool)) {
$this->group(Banana::$group);
$this->ingroup = Banana::$group;
return null;
}
+ /** Return the sources of the message
+ */
+ public function getMessageSource($id)
+ {
+ if (is_numeric($id) && Banana::$group != $this->ingroup) {
+ if (is_null(Banana::$spool)) {
+ $this->group(Banana::$group);
+ $this->ingroup = Banana::$group;
+ } else {
+ $id = array_search($id, Banana::$spool->ids);
+ }
+ }
+ $data = $this->article($id);
+ if ($data !== false) {
+ return implode("\n", $data);
+ }
+ return null;
+ }
+
/** Return the indexes of the messages presents in the Box
* @return Array(number of messages, MSGNUM of the first message, MSGNUM of the last message)
*/
/** 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);
+
+ /** Return the sources of a message
+ * @param id Id of the emssage (can be either an Message-id or a message index)
+ * @return The sources of the message (or null)
+ */
+ public function getMessageSource($id);
/** Return the indexes of the messages presents in the Box
* @return Array(number of messages, MSGNUM of the first message, MSGNUM of the last message)
{/if}
<tr>
<td colspan="3" class="body">
- {$message->getFormattedBody()}
+ {$body}
</td>
</tr>
</table>