Added delete-ability to posting...

git-svn-id: file:///svn/phpbb/trunk@3582 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2003-03-02 13:32:53 +00:00
parent bc18f53071
commit beb17ef6f2
5 changed files with 316 additions and 59 deletions

View file

@ -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);
}
?>

View file

@ -83,7 +83,7 @@ class parse_message
$warn_msg .= (($warn_msg != '') ? '<br />' : '') . $this->html($message, $html);
$warn_msg .= (($warn_msg != '') ? '<br />' : '') . $this->bbcode($message, $bbcode, $uid);
$warn_msg .= (($warn_msg != '') ? '<br />' : '') . $this->emoticons($message, $smilies);
$warn_msg .= (($warn_msg != '') ? '<br />' : '') . $this->magic_url($message, trim($url));
$warn_msg .= (($warn_msg != '') ? '<br />' : '') . $this->magic_url($message, $url);
$warn_msg .= (($warn_msg != '') ? '<br />' : '') . $this->attach($_FILE);
return $warn_msg;
@ -207,7 +207,7 @@ class parse_message
$message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$censors['match'], \$censors['replace'], '\\0')", '>' . $message . '<'), 1, -1));
}
$message = nl2br($message);
$message = str_replace("\n", "<br />", $message);
/* Signature
$user_sig = ($sig && $signature != '' && $config['allow_sig']) ? $row['user_sig'] : '';
@ -240,7 +240,7 @@ class parse_message
}
// Submit Post
function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_uid, $poll, $misc_info)
function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_uid, $poll, $post_data)
{
global $db, $auth, $user, $config, $phpEx, $SID, $template;
@ -250,15 +250,15 @@ class parse_message
$db->sql_transaction();
// Initial Topic table info
if ( ($mode == 'post') || ($mode == 'edit' && $misc_info['topic_first_post_id'] == $misc_info['post_id']))
if ( ($mode == 'post') || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_data['post_id']))
{
$topic_sql = array(
'forum_id' => $misc_info['forum_id'],
'forum_id' => $post_data['forum_id'],
'topic_title' => stripslashes($subject),
'topic_time' => $current_time,
'topic_type' => $topic_type,
'topic_approved' => (($misc_info['enable_moderate']) && !$auth->acl_gets('f_ignorequeue', 'm_', 'a_', $misc_info['forum_id'])) ? 0 : 1,
'icon_id' => $misc_info['icon_id'],
'topic_approved' => (($post_data['enable_moderate']) && !$auth->acl_gets('f_ignorequeue', 'm_', 'a_', $post_data['forum_id'])) ? 0 : 1,
'icon_id' => $post_data['icon_id'],
'topic_poster' => intval($user->data['user_id']),
'topic_first_poster_name' => ($username != '') ? stripslashes($username) : (($user->data['user_id'] == ANONYMOUS) ? '' : stripslashes($user->data['username'])),
);
@ -271,44 +271,44 @@ class parse_message
'poll_length' => $poll['poll_length'] * 3600
));
}
$sql = ($mode == 'post') ? 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $topic_sql) : 'UPDATE ' . TOPICS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $topic_sql) . ' WHERE topic_id = ' . $misc_info['topic_id'];
$sql = ($mode == 'post') ? 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $topic_sql) : 'UPDATE ' . TOPICS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $topic_sql) . ' WHERE topic_id = ' . $post_data['topic_id'];
$db->sql_query($sql);
$misc_info['topic_id'] = ($mode == 'post') ? $db->sql_nextid() : $misc_info['topic_id'];
$post_data['topic_id'] = ($mode == 'post') ? $db->sql_nextid() : $post_data['topic_id'];
}
// Post table info
$post_sql = array(
'topic_id' => $misc_info['topic_id'],
'forum_id' => $misc_info['forum_id'],
'poster_id' => ($mode == 'edit') ? $misc_info['poster_id'] : intval($user->data['user_id']),
'topic_id' => $post_data['topic_id'],
'forum_id' => $post_data['forum_id'],
'poster_id' => ($mode == 'edit') ? $post_data['poster_id'] : intval($user->data['user_id']),
'post_username' => ($username != '') ? stripslashes($username) : '',
'post_subject' => stripslashes($subject),
'icon_id' => $misc_info['icon_id'],
'icon_id' => $post_data['icon_id'],
'poster_ip' => $user->ip,
'post_time' => $current_time,
'post_approved' => ($misc_info['enable_moderate'] && !$auth->acl_gets('f_ignorequeue', 'm_', 'a_', $misc_info['forum_id'])) ? 0 : 1,
'post_edit_time' => ($mode == 'edit' && $misc_info['poster_id'] == $user->data['user_id']) ? $current_time : 0,
'enable_sig' => $misc_info['enable_html'],
'enable_bbcode' => $misc_info['enable_bbcode'],
'enable_html' => $misc_info['enable_html'],
'enable_smilies' => $misc_info['enable_smilies'],
'enable_magic_url' => $misc_info['enable_urls'],
'post_approved' => ($post_data['enable_moderate'] && !$auth->acl_gets('f_ignorequeue', 'm_', 'a_', $post_data['forum_id'])) ? 0 : 1,
'post_edit_time' => ($mode == 'edit' && $post_data['poster_id'] == $user->data['user_id']) ? $current_time : 0,
'enable_sig' => $post_data['enable_html'],
'enable_bbcode' => $post_data['enable_bbcode'],
'enable_html' => $post_data['enable_html'],
'enable_smilies' => $post_data['enable_smilies'],
'enable_magic_url' => $post_data['enable_urls'],
'bbcode_uid' => $bbcode_uid,
);
if ($mode != 'edit' || $misc_info['message_md5'] != $misc_info['post_checksum'])
if ($mode != 'edit' || $post_data['message_md5'] != $post_data['post_checksum'])
{
$post_sql = array_merge($post_sql, array(
'post_checksum' => $misc_info['message_md5'],
'post_checksum' => $post_data['message_md5'],
'post_text' => stripslashes($message),
'post_encoding' => $user->lang['ENCODING']
));
}
$sql = ($mode == 'edit' && $misc_info['poster_id'] == intval($user->data['user_id'])) ? 'UPDATE ' . POSTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $post_sql) . ' , post_edit_count = post_edit_count + 1 WHERE post_id = ' . $misc_info['post_id'] : 'INSERT INTO ' . POSTS_TABLE . ' ' . $db->sql_build_array('INSERT', $post_sql);
$sql = ($mode == 'edit' && $post_data['poster_id'] == intval($user->data['user_id'])) ? 'UPDATE ' . POSTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $post_sql) . ' , post_edit_count = post_edit_count + 1 WHERE post_id = ' . $post_data['post_id'] : 'INSERT INTO ' . POSTS_TABLE . ' ' . $db->sql_build_array('INSERT', $post_sql);
$db->sql_query($sql);
$misc_info['post_id'] = ($mode == 'edit') ? $misc_info['post_id'] : $db->sql_nextid();
$post_data['post_id'] = ($mode == 'edit') ? $post_data['post_id'] : $db->sql_nextid();
// poll options
if (!empty($poll['poll_options']))
@ -317,7 +317,7 @@ class parse_message
if (!empty($poll['poll_start']) && $mode == 'edit')
{
$sql = "SELECT * FROM " . POLL_OPTIONS_TABLE . "
WHERE topic_id = " . $misc_info['topic_id'] . "
WHERE topic_id = " . $post_data['topic_id'] . "
ORDER BY poll_option_id";
$result = $db->sql_query($sql);
@ -332,7 +332,7 @@ class parse_message
if (empty($cur_poll_options[$i]))
{
$sql = "INSERT INTO " . POLL_OPTIONS_TABLE . " (topic_id, poll_option_text)
VALUES (" . $misc_info['topic_id'] . ", '" . $db->sql_escape($poll['poll_options'][$i]) . "')";
VALUES (" . $post_data['topic_id'] . ", '" . $db->sql_escape($poll['poll_options'][$i]) . "')";
$db->sql_query($sql);
}
else if ($poll['poll_options'][$i] != $cur_poll_options[$i])
@ -347,9 +347,9 @@ class parse_message
}
// Fulltext parse
if ($mode != 'edit' || $misc_info['message_md5'] != $misc_info['post_checksum'])
if ($mode != 'edit' || $post_data['message_md5'] != $post_data['post_checksum'])
{
$result = $search->add($mode, $misc_info['post_id'], $message, $subject);
$result = $search->add($mode, $post_data['post_id'], $message, $subject);
}
// Sync forums, topics and users ...
@ -357,11 +357,11 @@ class parse_message
{
// Update forums: last post info, topics, posts ... we need to update
// each parent too ...
$forum_ids = $misc_info['forum_id'];
if (!empty($misc_info['forum_parents']))
$forum_ids = $post_data['forum_id'];
if (!empty($post_data['forum_parents']))
{
$misc_info['forum_parents'] = unserialize($misc_info['forum_parents']);
foreach ($misc_info['forum_parents'] as $parent_forum_id => $parent_name)
$post_data['forum_parents'] = unserialize($post_data['forum_parents']);
foreach ($post_data['forum_parents'] as $parent_forum_id => $parent_name)
{
$forum_ids .= ', ' . $parent_forum_id;
}
@ -369,7 +369,7 @@ class parse_message
$forum_topics_sql = ($mode == 'post') ? ', forum_topics = forum_topics + 1' : '';
$forum_sql = array(
'forum_last_post_id' => $misc_info['post_id'],
'forum_last_post_id' => $post_data['post_id'],
'forum_last_post_time' => $current_time,
'forum_last_poster_id' => intval($user->data['user_id']),
'forum_last_poster_name'=> ($user->data['user_id'] == ANONYMOUS) ? stripslashes($username) : $user->data['username'],
@ -380,7 +380,7 @@ class parse_message
// Update topic: first/last post info, replies
$topic_sql = array(
'topic_last_post_id' => $misc_info['post_id'],
'topic_last_post_id' => $post_data['post_id'],
'topic_last_post_time' => $current_time,
'topic_last_poster_id' => intval($user->data['user_id']),
'topic_last_poster_name'=> ($username != '') ? stripslashes($username) : (($user->data['user_id'] == ANONYMOUS) ? '' : stripslashes($user->data['username'])),
@ -389,16 +389,16 @@ class parse_message
if ($mode == 'post')
{
$topic_sql = array_merge($topic_sql, array(
'topic_first_post_id' => $misc_info['post_id'],
'topic_first_post_id' => $post_data['post_id'],
));
}
$topic_replies_sql = ($mode == 'reply') ? ', topic_replies = topic_replies + 1' : '';
$sql = 'UPDATE ' . TOPICS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $topic_sql) . $topic_replies_sql . ' WHERE topic_id = ' . $misc_info['topic_id'];
$sql = 'UPDATE ' . TOPICS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $topic_sql) . $topic_replies_sql . ' WHERE topic_id = ' . $post_data['topic_id'];
$db->sql_query($sql);
// Update user post count ... if appropriate
if (!empty($misc_info['enable_post_count']) && $user->data['user_id'] != ANONYMOUS)
if (!empty($post_data['enable_post_count']) && $user->data['user_id'] != ANONYMOUS)
{
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_posts = user_posts + 1
@ -416,34 +416,163 @@ class parse_message
}
// Topic Notification
if ((!$misc_info['notify_set']) && ($misc_info['notify']))
if ((!$post_data['notify_set']) && ($post_data['notify']))
{
$sql = "INSERT INTO " . TOPICS_WATCH_TABLE . " (user_id, topic_id)
VALUES (" . $user->data['user_id'] . ", " . $misc_info['topic_id'] . ")";
VALUES (" . $user->data['user_id'] . ", " . $post_data['topic_id'] . ")";
$db->sql_query($sql);
}
else if (($misc_info['notify_set']) && (!$misc_info['notify']))
else if (($post_data['notify_set']) && (!$post_data['notify']))
{
$sql = "DELETE FROM " . TOPICS_WATCH_TABLE . "
WHERE user_id = " . $user->data['user_id'] . "
AND topic_id = " . $misc_info['topic_id'];
AND topic_id = " . $post_data['topic_id'];
$db->sql_query($sql);
}
// Mark this topic as read and posted to.
$mark_mode = ($mode == 'reply' || $mode == 'quote') ? 'post' : 'topic';
markread($mark_mode, $misc_info['forum_id'], $misc_info['topic_id'], $misc_info['post_id']);
markread($mark_mode, $post_data['forum_id'], $post_data['topic_id'], $post_data['post_id']);
$db->sql_transaction('commit');
$template->assign_vars(array(
'META' => '<meta http-equiv="refresh" content="5; url=viewtopic.' . $phpEx . $SID . '&amp;f=' . $misc_info['forum_id'] . '&amp;p=' . $misc_info['post_id'] . '#' . $misc_info['post_id'] . '">')
'META' => '<meta http-equiv="refresh" content="5; url=viewtopic.' . $phpEx . $SID . '&amp;f=' . $post_data['forum_id'] . '&amp;p=' . $post_data['post_id'] . '#' . $post_data['post_id'] . '">')
);
$message = (!empty($misc_info['enable_moderate'])) ? 'POST_STORED_MOD' : 'POST_STORED';
$message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['VIEW_MESSAGE'], '<a href="viewtopic.' . $phpEx . $SID .'&p=' . $misc_info['post_id'] . '#' . $misc_info['post_id'] . '">', '</a>') . '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="viewforum.' . $phpEx . $SID .'&amp;f=' . $misc_info['forum_id'] . '">', '</a>');
$message = (!empty($post_data['enable_moderate'])) ? 'POST_STORED_MOD' : 'POST_STORED';
$message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['VIEW_MESSAGE'], '<a href="viewtopic.' . $phpEx . $SID .'&p=' . $post_data['post_id'] . '#' . $post_data['post_id'] . '">', '</a>') . '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="viewforum.' . $phpEx . $SID .'&amp;f=' . $post_data['forum_id'] . '">', '</a>');
trigger_error($message);
}
// Delete Post. Please be sure user have the correct Permissions before calling this function
function delete_post($mode, $post_id, $topic_id, $forum_id, $post_data)
{
global $db, $template, $user, $phpEx, $SID;
$search = new fulltext_search();
$sql = "DELETE FROM " . POSTS_TABLE . "
WHERE post_id = " . $post_id;
$db->sql_query($sql);
// User tries to delete the post twice ? Exit... we do not want the topics table screwed up.
if ($db->sql_affectedrows() == 0)
{
return ($user->lang['ALREADY_DELETED']);
}
$forum_sql = array();
$topic_sql = array();
$user_sql = array();
$forum_update_sql = '';
$user_update_sql = '';
$topic_update_sql = 'topic_replies = topic_replies - 1';
// Only one post... delete topic
if ($post_data['topic_first_post_id'] == $post_data['topic_last_post_id'])
{
$sql = "DELETE FROM " . TOPICS_TABLE . "
WHERE topic_id = " . $topic_id . "
OR topic_moved_id = " . $topic_id;
$db->sql_query($sql);
$sql = "DELETE FROM " . TOPICS_WATCH_TABLE . "
WHERE topic_id = " . $topic_id;
$db->sql_query($sql);
$forum_update_sql .= ($forum_update_sql != '') ? ', ' : '';
$forum_update_sql .= 'forum_topics = forum_topics - 1';
}
// Update Post Statistics
if ($post_data['enable_post_count'])
{
$forum_update_sql .= ($forum_update_sql != '') ? ', ' : '';
$forum_update_sql .= 'forum_posts = forum_posts - 1';
$user_update_sql .= ($user_update_sql != '') ? ', ' : '';
$user_update_sql .= 'user_posts = user_posts - 1';
}
// TODO: delete common words... maybe just call search_tidy ?
// $search->del_words($post_id);
$sql = "SELECT p.post_id, p.poster_id, p.post_username, u.username FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u
WHERE p.topic_id = " . $topic_id . " AND p.poster_id = u.user_id AND p.post_approved = 1
ORDER BY p.post_time DESC LIMIT 1";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
// If Post is first post, but not the only post... make next post the topic starter one. ;)
if (($post_data['topic_first_post_id'] != $post_data['topic_last_post_id']) && ($post_id == $post_data['topic_first_post_id']))
{
$topic_sql = array(
'topic_first_post_id' => intval($row['post_id']),
'topic_first_poster_name' => ( intval($row['poster_id']) == ANONYMOUS) ? trim($row['post_username']) : trim($row['username'])
);
}
$post_data['next_post_id'] = intval($row['post_id']);
// Update Forum, Topic and User with the gathered Informations
if (($forum_update_sql != '') || (count($forum_sql) > 0))
{
$sql = 'UPDATE ' . FORUMS_TABLE . ' SET ' . ( (count($forum_sql) > 0) ? $db->sql_build_array('UPDATE', $forum_sql) : '') .
( ($forum_update_sql != '') ? ((count($forum_sql) > 0) ? ', ' . $forum_update_sql : $forum_update_sql) : '') . '
WHERE forum_id = ' . $forum_id;
$db->sql_query($sql);
}
if (($topic_update_sql != '') || (count($topic_sql) > 0))
{
$sql = 'UPDATE ' . TOPICS_TABLE . ' SET ' . ( (count($topic_sql) > 0) ? $db->sql_build_array('UPDATE', $topic_sql) : '') .
( ($topic_update_sql != '') ? ((count($topic_sql) > 0) ? ', ' . $topic_update_sql : $topic_update_sql) : '') . '
WHERE topic_id = ' . $topic_id;
$db->sql_query($sql);
}
if (($user_update_sql != '') || (count($user_sql) > 0))
{
$sql = 'UPDATE ' . USERS_TABLE . ' SET ' . ( (count($user_sql) > 0) ? $db->sql_build_array('UPDATE', $user_sql) : '') .
( ($user_update_sql != '') ? ((count($user_sql) > 0) ? ', ' . $user_update_sql : $user_update_sql) : '') . '
WHERE user_id = ' . $post_data['user_id'];
$db->sql_query($sql);
}
// Update Forum stats...
if ($post_data['topic_first_post_id'] != $post_data['topic_last_post_id'])
{
update_last_post_information('topic', $topic_id);
}
update_last_post_information('forum', $forum_id);
if ($post_data['topic_first_post_id'] == $post_data['topic_last_post_id'])
{
$meta_info = '<meta http-equiv="refresh" content="5; url=viewforum.' . $phpEx . $SID . '&amp;f=' . $forum_id . '">';
$message = $user->lang['DELETED'];
}
else
{
$meta_info = '<meta http-equiv="refresh" content="5; url=viewtopic.' . $phpEx . $SID . '&amp;f=' . $forum_id . '&amp;t=' . $topic_id . '&amp;p=' . $post_data['next_post_id'] . '#' . $post_data['next_post_id'] . '">';
$message = $user->lang['DELETED'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="viewtopic.' . $phpEx . $SID . '&amp;f=' . $forum_id . '&amp;t=' . $topic_id . '&amp;p=' . $post_data['next_post_id'] . '#' . $post_data['next_post_id'] . '">', '</a>');
}
$template->assign_vars(array(
'META' => $meta_info)
);
$message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="viewforum.' . $phpEx . $SID . '&amp;f=' . $forum_id . '">', '</a>');
trigger_error($message);
return;
}
}
// Parses a given message and updates/maintains the fulltext tables

View file

@ -342,7 +342,8 @@ $lang = array_merge($lang, array(
'CANNOT_DELETE_POLL' => 'Sorry but you cannot delete an active poll',
'EDIT_OWN_POSTS' => 'Sorry but you can only edit your own posts',
'DELETE_OWN_POSTS' => 'Sorry but you can only delete your own posts',
'ALREADY_DELETED' => 'Sorry but this message is already deleted',
'No_such_post' => 'There is no such post, please return and try again',
'Empty_poll_title' => 'You must enter a title for your poll',
'TOO_FEW_POLL_OPTIONS' => 'You must enter at least two poll options',
@ -384,7 +385,7 @@ $lang = array_merge($lang, array(
'SAVE' => 'Save',
'POST_STORED' => 'Your message has been posted successfully',
'POST_STORED_MOD' => 'Your message has been saved but requires approval',
'Deleted' => 'Your message has been deleted successfully',
'DELETED' => 'Your message has been deleted successfully',
'Poll_delete' => 'Your poll has been deleted successfully',
'Vote_cast' => 'Your vote has been cast',
'BBCODE_B_HELP' => 'Bold text: [b]text[/b] (alt+b)',
@ -446,7 +447,7 @@ $lang = array_merge($lang, array(
'Delete_all' => 'Delete All',
'Save_marked' => 'Save Marked',
'Save_message' => 'Save Message',
'Delete_message' => 'Delete Message',
'DELETE_MESSAGE' => 'Delete Message',
'Display_messages' => 'Display messages from previous',
'All_Messages' => 'All Messages',
'No_messages_folder' => 'You have no messages in this folder',

View file

@ -57,6 +57,7 @@ $submit = (isset($_POST['post'])) ? true : false;
$preview = (isset($_POST['preview'])) ? true : false;
$save = (isset($_POST['save'])) ? true : false;
$cancel = (isset($_POST['cancel'])) ? true : false;
$confirm = (isset($_POST['confirm'])) ? true : false;
// Was cancel pressed? If so then redirect to the appropriate page
if ($cancel)
@ -73,7 +74,7 @@ $post_validate = false;
$forum_fields = array('f.forum_id', 'f.forum_name', 'f.parent_id', 'f.forum_parents', 'f.forum_status', 'f.forum_postable', 'f.enable_icons', 'f.enable_post_count', 'f.enable_moderate');
$topic_fields = array('t.topic_id', 't.topic_status', 't.topic_first_post_id', 't.topic_last_post_id', 't.topic_type', 't.topic_title');
$post_fields = array('p.post_id', 'p.post_time', 'p.poster_id', 'p.post_username', 'p.post_text', 'p.post_checksum', 'p.bbcode_uid');
$post_fields = array('p.post_id', 'p.post_time', 'p.poster_id', 'p.post_username', 'p.post_text', 'p.post_checksum', 'p.bbcode_uid', 'p.enable_magic_url');
switch ($mode)
{
@ -182,6 +183,8 @@ if ($sql != '')
$post_text = ($post_validate) ? trim($post_text) : '';
$post_checksum = ($post_validate) ? trim($post_checksum) : '';
$bbcode_uid = ($post_validate) ? trim($bbcode_uid) : '';
$enable_urls = ($post_validate) ? intval($enable_magic_url) : true;
$enable_magic_url = false;
}
// Notify user checkbox
@ -241,9 +244,66 @@ if ( ($mode == 'edit') && (!$perm['m_edit']) && ($user->data['user_id'] != $post
trigger_error($user->lang['USER_CANNOT_EDIT']);
}
// PERMISSION CHECKS
$message_handler = new parse_message(0); // <- TODO: add constant (MSG_POST/MSG_PM)
$parse_msg = new parse_message(0); // <- TODO: add constant (MSG_POST/MSG_PM)
// Delete triggered ?
if ( ($mode == 'delete') && ((($poster_id == $user->data['user_id']) && ($perm['u_delete']) && ($post_id == $topic_last_post_id)) || ($perm['m_delete'])) )
{
// Do we need to confirm ?
if ($confirm)
{
$post_data = array(
'topic_first_post_id' => $topic_first_post_id,
'topic_last_post_id' => $topic_last_post_id,
'enable_post_count' => $enable_post_count,
'user_id' => $poster_id
);
$msg = $message_handler->delete_post($mode, $post_id, $topic_id, $forum_id, $post_data);
// We have a problem...
trigger_error($msg);
}
else
{
$s_hidden_fields = '<input type="hidden" name="p" value="' . $post_id . '" /><input type="hidden" name="mode" value="delete" />';
$page_title = $user->lang['DELETE_MESSAGE'];
include($phpbb_root_path . 'includes/page_header.' . $phpEx);
$template->set_filenames(array(
'body' => 'confirm_body.html')
);
$template->assign_vars(array(
'MESSAGE_TITLE' => $user->lang['DELETE_MESSAGE'],
'MESSAGE_TEXT' => $user->lang['CONFIRM_DELETE'],
'L_YES' => $user->lang['YES'],
'L_NO' => $user->lang['NO'],
'S_CONFIRM_ACTION' => $phpbb_root_path . 'posting.' . $phpEx . $SID,
'S_HIDDEN_FIELDS' => $s_hidden_fields)
);
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
}
}
if ( ($mode == 'delete') && ( ($poster_id != $user->data['user_id']) && (!$perm['u_delete'])) )
{
trigger_error($user->lang['DELETE_OWN_POSTS']);
}
if ( ($mode == 'delete') && ( ($poster_id == $user->data['user_id']) && ($perm['u_delete'])) && ($post_id != $topic_last_post_id))
{
trigger_error($user->lang['CANNOT_DELETE_REPLIED']);
}
if ($mode == 'delete')
{
trigger_error('USER_CANNOT_DELETE');
}
if (($submit) || ($preview))
{
@ -257,7 +317,7 @@ if (($submit) || ($preview))
$enable_html = (!intval($config['allow_html'])) ? 0 : ((!empty($_POST['disable_html'])) ? 0 : 1);
$enable_bbcode = (!intval($config['allow_bbcode'])) ? 0 : ((!empty($_POST['disable_bbcode'])) ? 0 : 1);
$enable_smilies = (!intval($config['allow_smilies'])) ? 0 : ((!empty($_POST['disable_smilies'])) ? 0 : 1);
$enable_urls = (!empty($_POST['disable_magic_url'])) ? 0 : 1;
$enable_urls = (isset($_POST['disable_magic_url'])) ? 0 : 1;
$enable_sig = (empty($_POST['attach_sig'])) ? 1 : 0;
$notify = (!empty($_POST['notify'])) ? 1 : 0;
@ -279,7 +339,7 @@ if (($submit) || ($preview))
if ($mode != 'edit' || $message_md5 != $post_checksum)
{
// Parse message
if (($result = $parse_msg->parse($message, $enable_html, $enable_bbcode, $bbcode_uid, $enable_urls, $enable_smilies)) != '')
if (($result = $message_handler->parse($message, $enable_html, $enable_bbcode, $bbcode_uid, $enable_urls, $enable_smilies)) != '')
{
$err_msg .= ((!empty($err_msg)) ? '<br />' : '') . $result;
}
@ -320,7 +380,7 @@ if (($submit) || ($preview))
}
$poll = array();
// $poll = $parse_msg->parse_poll();
// $poll = $message_handler->parse_poll();
// Check topic type
if ($topic_type != POST_NORMAL)
@ -348,7 +408,7 @@ if (($submit) || ($preview))
// Store message, sync counters
if (($err_msg == '') && ($submit))
{
$misc_info = array(
$post_data = array(
'topic_first_post_id' => $topic_first_post_id,
'post_id' => $post_id,
'topic_id' => $topic_id,
@ -369,7 +429,7 @@ if (($submit) || ($preview))
'notify_set' => $notify_set
);
$parse_msg->submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_uid, $poll, $misc_info);
$message_handler->submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_uid, $poll, $post_data);
}
$post_text = stripslashes($message);
@ -390,7 +450,7 @@ if ($preview)
}
$post_time = $current_time;
$preview_message = $parse_msg->format_display(stripslashes($message), $enable_html, $enable_bbcode, $bbcode_uid, $enable_urls, $enable_smilies, $enable_sig);
$preview_message = $message_handler->format_display(stripslashes($message), $enable_html, $enable_bbcode, $bbcode_uid, $enable_urls, $enable_smilies, $enable_sig);
if (sizeof($censors))
{

View file

@ -2,7 +2,7 @@
<table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
<tr>
<td class="nav" align="left"><a class="nav" href="{U_INDEX}">{L_INDEX}</a></td>
<td class="nav" align="left"><a href="{U_INDEX}">{L_INDEX}</a></td>
</tr>
</table>