summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoruckelman <uckelman@nomic.net>2010-04-11 15:10:56 +0000
committeruckelman <uckelman@nomic.net>2010-04-11 15:10:56 +0000
commit6e40453542d82944122a71a050254c646b77aaaf (patch)
tree06d61454340c7e0db7e3316e055689a417943a14 /src
parent13763c5e23ed553fcde7a72a4ceb5022a0624f31 (diff)
Working on postMessage().
git-svn-id: https://vassalengine.svn.sourceforge.net/svnroot/vassalengine/site-src/trunk@6651 67b53d14-2c14-4ace-a08f-0dab2b34000c
Diffstat (limited to 'src')
-rw-r--r--src/PhpBB3.php48
1 files changed, 29 insertions, 19 deletions
diff --git a/src/PhpBB3.php b/src/PhpBB3.php
index 7fb0f80..51d4bbe 100644
--- a/src/PhpBB3.php
+++ b/src/PhpBB3.php
@@ -82,29 +82,21 @@ class PhpBB3 {
}
public function postMessage($postType, $forumId, $topicId, $msg) {
- if ($postType === null) {
- trigger_error('post type is null', E_USER_ERROR);
+ if ($postType != 'post' && $postType != 'reply') {
+ trigger_error('bad post type: ' . $postType, E_USER_ERROR);
}
- if (!is_int($forumId)) {
- trigger_error('forum id is not an integer', E_USER_ERROR);
- }
-
- if ($forumId < 0) {
- trigger_error('forum id is negative', E_USER_ERROR);
+ if (!is_int($forumId) || $forumId < 0) {
+ trigger_error('bad forum id: ' . $forumId, E_USER_ERROR);
}
if (!$this->forumExists($forumId)) {
trigger_error('forum does not exist: ' . $forumId, E_USER_ERROR);
}
- if ($topicId != null) {
- if (!is_int($topicId)) {
- trigger_error('topic id is not an integer', E_USER_ERROR);
- }
-
- if ($topicId < 0) {
- trigger_error('topic id is negative', E_USER_ERROR);
+ if ($topicId !== null) {
+ if (!is_int($topicId) || $topicId < 0) {
+ trigger_error('bad topic id: ' . $topicId, E_USER_ERROR);
}
}
@@ -115,11 +107,27 @@ class PhpBB3 {
$subject = $msg->getSubject();
$message = 'foo'; # FIXME: fill in with acutal message contents
- $userId = $phpbb->getUserId($msg->getFrom());
- $userName = $phpbb->getUserName($userId);
+ $userId = $this->getUserId($msg->getFrom());
+ $userName = $this->getUserName($userId);
+
+ # authenticate ourselves
+ global $phpEx, $phpbb_root_path, $user, $auth;
+ $user->session_create($userId);
+ $auth->acl($user->data);
+
+ $subject = utf8_normalize_nfc($subject);
+ $message = utf8_normalize_nfc($message);
+
+ $uid = $bitfield = $options = '';
+
+ generate_text_for_storage(
+ $subject, $uid, $bitfield, $options, false, false, false
+ );
+
+ generate_text_for_storage(
+ $message, $uid, $bitfield, $options, true, true, true
+ );
- $poll = $uid = $bitfield = '';
- $topicId = -1;
$postId = null;
$data = array(
@@ -148,6 +156,8 @@ class PhpBB3 {
'enable_indexing' => true,
);
+ $poll = '';
+
submit_post($postType, $subject, $userName, POST_NORMAL, $poll, $data);
return $postId;