diff options
author | uckelman <uckelman@nomic.net> | 2010-04-22 20:40:59 +0000 |
---|---|---|
committer | uckelman <uckelman@nomic.net> | 2010-04-22 20:40:59 +0000 |
commit | 09fb03a4fb46bc43abdf31835f65ee868c08a697 (patch) | |
tree | 99874828a64705da8481de620648c5d3a302d864 /src | |
parent | 2ebfb781447380ccfd895c2ba7a77fc22e360d97 (diff) |
Handle quote mode.
git-svn-id: https://vassalengine.svn.sourceforge.net/svnroot/vassalengine/site-src/trunk@6727 67b53d14-2c14-4ace-a08f-0dab2b34000c
Diffstat (limited to 'src')
-rw-r--r-- | src/F2M.php | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/src/F2M.php b/src/F2M.php index 4c5c904..510cfa4 100644 --- a/src/F2M.php +++ b/src/F2M.php @@ -14,6 +14,19 @@ function send_to_lists($config, $user, $mode, $data, $post_data) { var_dump($post_data); print '</p>'; + # Check the mode + switch ($mode) { + case 'post': + case 'reply': + case 'quote': + break; # Mail this post + case 'edit': # TODO + case 'delete': # TODO + return; + default: + throw new Exception('unrecognized mode: ' . $mode); + } + require_once('Mail.php'); require_once(__DIR__ . '/Bridge.php'); @@ -52,16 +65,19 @@ function send_to_lists($config, $user, $mode, $data, $post_data) { $inReplyTo = null; $references = null; - if ($mode == 'reply') { - $firstId = $data['topic_first_post_id']; + if ($mode == 'reply' || $mode == 'quote') { + $firstId = $data['topic_first_post_id']; $firstMessageId = $bridge->getMessageId($firstId); if ($firstMessageId === false) { throw new Exception('unrecognized post id: ' . $firstId); } -# FIXME: try to build better References by matching, maybe? +# TODO: try to build better References by matching, maybe? $inReplyTo = $references = $firstMessageId; } + else if ($mode == 'edit') { + $inReplyTo = $bridge->getMessageId($postId); + } $forumURL = 'http://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER['SCRIPT_NAME']); @@ -90,6 +106,18 @@ function send_to_lists($config, $user, $mode, $data, $post_data) { $text = htmlspecialchars_decode($text); $text = wordwrap($text, 72); + if ($mode == 'edit') { + $edit_notice = <<<EOF +[This message has been edited.] + +EOF; + + $edit_header = 'Edit: '; + + $text = $edit_notice . $text; + $headers['Subject'] = $edit_header . $headers['Subject']; + } + # TODO: BBCode to Markdown (?) # Build the bridge footer @@ -171,6 +199,8 @@ EOF; $mailer = Mail::factory('sendmail'); +# FIXME: edited messages break the bijection between post and message ids! + # Register the message $seen = !$bridge->registerMessage($postId, $messageId, $inReplyTo, $references); |