diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2003-03-02 13:32:53 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2003-03-02 13:32:53 +0000 |
commit | beb17ef6f27d06e1001ee243e6b69b4cc0332aaf (patch) | |
tree | 1c49541d469afb5353017c5ad7f4af39f891cffc /phpBB/includes/functions_posting.php | |
parent | bc18f53071018bd1c273d8e923819fdf388eec5f (diff) | |
download | forums-beb17ef6f27d06e1001ee243e6b69b4cc0332aaf.tar forums-beb17ef6f27d06e1001ee243e6b69b4cc0332aaf.tar.gz forums-beb17ef6f27d06e1001ee243e6b69b4cc0332aaf.tar.bz2 forums-beb17ef6f27d06e1001ee243e6b69b4cc0332aaf.tar.xz forums-beb17ef6f27d06e1001ee243e6b69b4cc0332aaf.zip |
Added delete-ability to posting...
git-svn-id: file:///svn/phpbb/trunk@3582 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_posting.php')
-rw-r--r-- | phpBB/includes/functions_posting.php | 69 |
1 files changed, 68 insertions, 1 deletions
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 30350513cb..8e4acd8d13 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -167,7 +167,7 @@ function decode_text(&$message) } // Quote Text -function quote_text(&$message, $username = '') +function quote_text($message, $username = '') { $message = ' [quote' . ( (empty($username)) ? ']' : '="' . addslashes(trim($username)) . '"]') . trim($message) . '[/quote] '; } @@ -298,4 +298,71 @@ function topic_review($topic_id, $is_inline_review = false) } } +// Update Last Post Informations +function update_last_post_information($type, $id) +{ + global $db; + + switch ($type) + { + case 'forum': + $sql_select_add = ', f.forum_parents'; + $sql_table_add = ', ' . FORUMS_TABLE . ' f'; + $sql_where_add = 'AND t.forum_id = f.forum_id AND f.forum_id = ' . $id; + $sql_update_table = FORUMS_TABLE; + break; + + case 'topic': + $sql_select_add = ''; + $sql_table_add = ''; + $sql_where_add = 'AND t.topic_id = ' . $id; + $sql_update_table = TOPICS_TABLE; + break; + default: + return; + } + + $sql = "SELECT p.post_id, p.poster_id, p.post_time, u.username, p.post_username " . $sql_select_add . " + FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . TOPICS_TABLE . " t" . $sql_table_add . " + WHERE p.post_approved = 1 AND t.topic_approved = 1 AND p.poster_id = u.user_id AND t.topic_id = p.topic_id " . $sql_where_add . " + ORDER BY p.post_time DESC LIMIT 1"; + + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + + if ($type == 'forum') + { + // Update forums: last post info, topics, posts ... we need to update + // each parent too ... + $forum_ids = $id; + $forum_parents = trim($row['forum_parents']); + + if ($forum_parents != '') + { + $forum_parents = unserialize($forum_parents); + foreach ($forum_parents as $parent_forum_id => $parent_name) + { + $forum_ids .= ', ' . $parent_forum_id; + } + } + + $where_clause = 'forum_id IN (' . $forum_ids . ')'; + } + else if ($type == 'topic') + { + $where_clause = 'topic_id = ' . $id; + } + + $update_sql = array( + $type . '_last_post_id' => intval($row['post_id']), + $type . '_last_post_time' => intval($row['post_time']), + $type . '_last_poster_id' => intval($row['poster_id']), + $type . '_last_poster_name' => (intval($row['poster_id']) == ANONYMOUS) ? trim($row['post_username']) : trim($row['username']) + ); + + + $sql = 'UPDATE ' . $sql_update_table . ' SET ' . $db->sql_build_array('UPDATE', $update_sql) . ' WHERE ' . $where_clause; + $db->sql_query($sql); +} + ?>
\ No newline at end of file |