From 66be33480a0b891106ab3e8a75420843f36f6665 Mon Sep 17 00:00:00 2001 From: uckelman Date: Sun, 11 Apr 2010 15:26:56 +0000 Subject: Added more code. git-svn-id: https://vassalengine.svn.sourceforge.net/svnroot/vassalengine/site-src/trunk@6654 67b53d14-2c14-4ace-a08f-0dab2b34000c --- src/M2F.php | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'src/M2F.php') diff --git a/src/M2F.php b/src/M2F.php index 7dd56b0..fd2901f 100644 --- a/src/M2F.php +++ b/src/M2F.php @@ -3,7 +3,7 @@ require_once(__DIR__ . '/Bridge.php'); require_once(__DIR__ . '/MailmanLib.php'); require_once(__DIR__ . '/MailmanMessage.php'); -require_once(__DIR__ . '/PhpBB3Lib.php'); +require_once(__DIR__ . '/PhpBB3.php'); # Read the message from STDIN $url = 'php://stdin'; @@ -11,24 +11,41 @@ $url = 'php://stdin'; $input = read_raw_message($url); $msg = new MailmanMessage($input); -$user = get_user_id($msg->getFrom()); -$userName = get_user_name($userId); - $bridge = new Bridge(); +$seen = $bridge->registerMessage($msg->getMessageId(), + $msg->getInReplyTo(), + $msg->getReferences()); + +if ($seen) { + # This message has already been processed. + exit; +} + +$phpbb = new PhpBB3(); + $inReplyTo = $msg->getInReplyTo(); +$forumId = $topicId = -1; +$postType = null; + if ($inReplyTo) { - # Is this a reply? + # A reply to an existing topic # FIXME: we don't want exceptions here? $parentId = $bridge->getPostId($inReplyTo); - $topicId = get_topic_id($parentId); + $ids = $phpbb->getTopicAndForumIds($parentId); + $forumId = $ids['forum_id']; + $topicId = $ids['topic_id']; + $postType = 'reply'; } else { - # a new message - + # A message starting a new topic + $forumId = $bridge->getDefaultForumId($msg->getSource()); + $postType = 'post'; } -#$forumId = get_default_forum_id($msg->getSource()); +# Post the message to the forum +$phpbb->postMessage($postType, $forumId, $topicId, $msg); +$bridge->setPostId($messageId, $postId); ?> -- cgit v1.2.3