summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Uckelman <uckelman@nomic.net>2012-02-27 06:19:32 +0100
committerJoel Uckelman <uckelman@nomic.net>2012-02-27 06:19:32 +0100
commit9fd68c047d293e98f7b3ff51e5fe5eb8c0fd2738 (patch)
treea72fa701ba9fb045c21029bfb95f61cf68ad3732
parent538192afeccfada79de6e699ecc460a830f98d66 (diff)
Strip Re and tags from Subject of incoming mail.
-rw-r--r--src/PhpBB3.php2
-rw-r--r--src/PhpBB3Impl.php22
2 files changed, 22 insertions, 2 deletions
diff --git a/src/PhpBB3.php b/src/PhpBB3.php
index fbd3a20..36f54b6 100644
--- a/src/PhpBB3.php
+++ b/src/PhpBB3.php
@@ -27,6 +27,8 @@ interface PhpBB3 {
public function forumExists($forumId);
+ public function getForumName($forumId);
+
public function topicStatus($topicId);
public function getPostTime($postId);
diff --git a/src/PhpBB3Impl.php b/src/PhpBB3Impl.php
index f6d6706..59f052f 100644
--- a/src/PhpBB3Impl.php
+++ b/src/PhpBB3Impl.php
@@ -20,6 +20,7 @@
require_once(__DIR__ . '/PhpBB3.php');
require_once(__DIR__ . '/Util.php');
+require_once(__DIR__ . '/build_post.php');
# phpBB setup
define('IN_PHPBB', true);
@@ -106,6 +107,18 @@ class PhpBB3Impl implements PhpBB3 {
}
}
+ public function getForumName($forumId) {
+ throw_if_null($forumId);
+
+ global $db;
+
+ $sql = 'SELECT forum_name FROM ' . FORUMS_TABLE . ' ' .
+ 'WHERE forum_id = ' . $forumId;
+
+ $row = $this->get_exactly_one_row($sql);
+ return $row ? $row['forum_name'] : false;
+ }
+
public function topicStatus($topicId) {
throw_if_null($topicId);
@@ -188,7 +201,13 @@ class PhpBB3Impl implements PhpBB3 {
throw new Exception('unrecognized user id: ' . $userId);
}
- $subject = $msg->getSubject();
+ $subject = $msg->getSubject();
+// FIXME: list tag should not be hard-coded
+ $listTag = '[messages]';
+ $forumName = $this->getForumName($forumId);
+ $forumTag = '[' . html_entity_decode($forumName, ENT_QUOTES) . ']';
+ $subject = build_post_subject($listTag, $forumTag, $subject);
+
list($message, $attachments) = $msg->getFlattenedParts();
# FIXME: extract the footer pattern into a config file?
@@ -214,7 +233,6 @@ class PhpBB3Impl implements PhpBB3 {
$user->session_create($userId);
$auth->acl($user->data);
-# FIXME: strip list and forum tag from subject
$subject = utf8_normalize_nfc($subject);
$message = utf8_normalize_nfc($message);