本文整理匯總了PHP中phpbb_get_post_data函數的典型用法代碼示例。如果您正苦於以下問題:PHP phpbb_get_post_data函數的具體用法?PHP phpbb_get_post_data怎麽用?PHP phpbb_get_post_data使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了phpbb_get_post_data函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: mcp_delete_post
/**
* Delete Posts
*/
function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '', $action = 'delete_post')
{
global $auth, $user, $db, $phpEx, $phpbb_root_path, $request, $phpbb_container, $phpbb_log;
$check_permission = $is_soft ? 'm_softdelete' : 'm_delete';
if (!phpbb_check_ids($post_ids, POSTS_TABLE, 'post_id', array($check_permission))) {
return;
}
$redirect = $request->variable('redirect', build_url(array('action', 'quickmod')));
$forum_id = $request->variable('f', 0);
$s_hidden_fields = array('post_id_list' => $post_ids, 'f' => $forum_id, 'action' => $action, 'redirect' => $redirect);
$success_msg = '';
if (confirm_box(true) && $is_soft) {
$post_info = phpbb_get_post_data($post_ids);
$topic_info = $approve_log = array();
// Group the posts by topic_id
foreach ($post_info as $post_id => $post_data) {
if ($post_data['post_visibility'] != ITEM_APPROVED) {
continue;
}
$topic_id = (int) $post_data['topic_id'];
$topic_info[$topic_id]['posts'][] = (int) $post_id;
$topic_info[$topic_id]['forum_id'] = (int) $post_data['forum_id'];
if ($post_id == $post_data['topic_first_post_id']) {
$topic_info[$topic_id]['first_post'] = true;
}
if ($post_id == $post_data['topic_last_post_id']) {
$topic_info[$topic_id]['last_post'] = true;
}
$approve_log[] = array('forum_id' => $post_data['forum_id'], 'topic_id' => $post_data['topic_id'], 'post_subject' => $post_data['post_subject'], 'poster_id' => $post_data['poster_id'], 'post_username' => $post_data['post_username'], 'username' => $post_data['username']);
}
/* @var $phpbb_content_visibility \phpbb\content_visibility */
$phpbb_content_visibility = $phpbb_container->get('content.visibility');
foreach ($topic_info as $topic_id => $topic_data) {
$phpbb_content_visibility->set_post_visibility(ITEM_DELETED, $topic_data['posts'], $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), $soft_delete_reason, isset($topic_data['first_post']), isset($topic_data['last_post']));
}
$affected_topics = sizeof($topic_info);
// None of the topics is really deleted, so a redirect won't hurt much.
$deleted_topics = 0;
$success_msg = sizeof($post_info) == 1 ? $user->lang['POST_DELETED_SUCCESS'] : $user->lang['POSTS_DELETED_SUCCESS'];
foreach ($approve_log as $row) {
$post_username = $row['poster_id'] == ANONYMOUS && !empty($row['post_username']) ? $row['post_username'] : $row['username'];
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_SOFTDELETE_POST', false, array('forum_id' => $row['forum_id'], 'topic_id' => $row['topic_id'], 'post_id' => $row['post_id'], $row['post_subject'], $post_username, $soft_delete_reason));
}
$topic_id = $request->variable('t', 0);
// Return links
$return_link = array();
if ($affected_topics == 1 && $topic_id) {
$return_link[] = sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&t={$topic_id}") . '">', '</a>');
}
$return_link[] = sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $forum_id) . '">', '</a>');
} else {
if (confirm_box(true)) {
if (!function_exists('delete_posts')) {
include $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
}
// Count the number of topics that are affected
// I did not use COUNT(DISTINCT ...) because I remember having problems
// with it on older versions of MySQL -- Ashe
$sql = 'SELECT DISTINCT topic_id
FROM ' . POSTS_TABLE . '
WHERE ' . $db->sql_in_set('post_id', $post_ids);
$result = $db->sql_query($sql);
$topic_id_list = array();
while ($row = $db->sql_fetchrow($result)) {
$topic_id_list[] = $row['topic_id'];
}
$affected_topics = sizeof($topic_id_list);
$db->sql_freeresult($result);
$post_data = phpbb_get_post_data($post_ids);
foreach ($post_data as $id => $row) {
$post_username = $row['poster_id'] == ANONYMOUS && !empty($row['post_username']) ? $row['post_username'] : $row['username'];
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_DELETE_POST', false, array('forum_id' => $row['forum_id'], 'topic_id' => $row['topic_id'], 'post_id' => $row['post_id'], $row['post_subject'], $post_username, $soft_delete_reason));
}
// Now delete the posts, topics and forums are automatically resync'ed
delete_posts('post_id', $post_ids);
$sql = 'SELECT COUNT(topic_id) AS topics_left
FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $topic_id_list);
$result = $db->sql_query_limit($sql, 1);
$deleted_topics = ($row = $db->sql_fetchrow($result)) ? $affected_topics - $row['topics_left'] : $affected_topics;
$db->sql_freeresult($result);
$topic_id = $request->variable('t', 0);
// Return links
$return_link = array();
if ($affected_topics == 1 && !$deleted_topics && $topic_id) {
$return_link[] = sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&t={$topic_id}") . '">', '</a>');
}
$return_link[] = sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $forum_id) . '">', '</a>');
if (sizeof($post_ids) == 1) {
if ($deleted_topics) {
// We deleted the only post of a topic, which in turn has
// been removed from the database
$success_msg = $user->lang['TOPIC_DELETED_SUCCESS'];
} else {
$success_msg = $user->lang['POST_DELETED_SUCCESS'];
}
} else {
//.........這裏部分代碼省略.........
示例2: main
function main($id, $mode)
{
global $auth, $db, $user, $template, $cache;
global $config, $phpbb_root_path, $phpEx, $action, $phpbb_container, $phpbb_dispatcher;
include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx;
$forum_id = request_var('f', 0);
$start = request_var('start', 0);
$this->page_title = 'MCP_REPORTS';
switch ($action) {
case 'close':
case 'delete':
include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
$report_id_list = request_var('report_id_list', array(0));
if (!sizeof($report_id_list)) {
trigger_error('NO_REPORT_SELECTED');
}
close_report($report_id_list, $mode, $action);
break;
}
switch ($mode) {
case 'report_details':
$user->add_lang(array('posting', 'viewforum', 'viewtopic'));
$post_id = request_var('p', 0);
// closed reports are accessed by report id
$report_id = request_var('r', 0);
$sql = 'SELECT r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, r.reported_post_text, r.reported_post_uid, r.reported_post_bitfield, r.reported_post_enable_magic_url, r.reported_post_enable_smilies, r.reported_post_enable_bbcode, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour
FROM ' . REPORTS_TABLE . ' r, ' . REPORTS_REASONS_TABLE . ' rr, ' . USERS_TABLE . ' u
WHERE ' . ($report_id ? 'r.report_id = ' . $report_id : "r.post_id = {$post_id}") . '
AND rr.reason_id = r.reason_id
AND r.user_id = u.user_id
AND r.pm_id = 0
ORDER BY report_closed ASC';
$result = $db->sql_query_limit($sql, 1);
$report = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$report) {
trigger_error('NO_REPORT');
}
$phpbb_notifications = $phpbb_container->get('notification_manager');
$phpbb_notifications->mark_notifications_read('notification.type.report_post', $post_id, $user->data['user_id']);
if (!$report_id && $report['report_closed']) {
trigger_error('REPORT_CLOSED');
}
$post_id = $report['post_id'];
$report_id = $report['report_id'];
$parse_post_flags = $report['reported_post_enable_bbcode'] ? OPTION_FLAG_BBCODE : 0;
$parse_post_flags += $report['reported_post_enable_smilies'] ? OPTION_FLAG_SMILIES : 0;
$parse_post_flags += $report['reported_post_enable_magic_url'] ? OPTION_FLAG_LINKS : 0;
$post_info = phpbb_get_post_data(array($post_id), 'm_report', true);
if (!sizeof($post_info)) {
trigger_error('NO_REPORT_SELECTED');
}
$post_info = $post_info[$post_id];
$reason = array('title' => $report['reason_title'], 'description' => $report['reason_description']);
if (isset($user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])])) {
$reason['description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])];
$reason['title'] = $user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])];
}
if (topic_review($post_info['topic_id'], $post_info['forum_id'], 'topic_review', 0, false)) {
$template->assign_vars(array('S_TOPIC_REVIEW' => true, 'S_BBCODE_ALLOWED' => $post_info['enable_bbcode'], 'TOPIC_TITLE' => $post_info['topic_title'], 'REPORTED_POST_ID' => $post_id));
}
$topic_tracking_info = $extensions = $attachments = array();
// Get topic tracking info
if ($config['load_db_lastread']) {
$tmp_topic_data = array($post_info['topic_id'] => $post_info);
$topic_tracking_info = get_topic_tracking($post_info['forum_id'], $post_info['topic_id'], $tmp_topic_data, array($post_info['forum_id'] => $post_info['forum_mark_time']));
unset($tmp_topic_data);
} else {
$topic_tracking_info = get_complete_topic_tracking($post_info['forum_id'], $post_info['topic_id']);
}
$post_unread = isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']] ? true : false;
$message = generate_text_for_display($report['reported_post_text'], $report['reported_post_uid'], $report['reported_post_bitfield'], $parse_post_flags, false);
$report['report_text'] = make_clickable(bbcode_nl2br($report['report_text']));
if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) {
$sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . '
WHERE post_msg_id = ' . $post_id . '
AND in_message = 0
AND filetime <= ' . (int) $report['report_time'] . '
ORDER BY filetime DESC';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$attachments[] = $row;
}
$db->sql_freeresult($result);
if (sizeof($attachments)) {
$update_count = array();
parse_attachments($post_info['forum_id'], $message, $attachments, $update_count);
}
// Display not already displayed Attachments for this post, we already parsed them. ;)
if (!empty($attachments)) {
$template->assign_var('S_HAS_ATTACHMENTS', true);
foreach ($attachments as $attachment) {
$template->assign_block_vars('attachment', array('DISPLAY_ATTACHMENT' => $attachment));
}
}
}
$template->assign_vars(array('S_MCP_REPORT' => true, 'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'], 'S_POST_UNAPPROVED' => $post_info['post_visibility'] == ITEM_UNAPPROVED || $post_info['post_visibility'] == ITEM_REAPPROVE, 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_REPORT_CLOSED' => $report['report_closed'], 'S_USER_NOTES' => true, 'U_EDIT' => $auth->acl_get('m_edit', $post_info['forum_id']) ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '', 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_REPORTER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&mode=user_notes&u=' . $report['user_id']), 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&mode=user_notes&u=' . $post_info['user_id']), 'U_MCP_WARN_REPORTER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&mode=warn_user&u=' . $report['user_id']) : '', 'U_MCP_WARN_USER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&mode=warn_user&u=' . $post_info['user_id']) : '', 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $post_info['forum_id']), 'U_VIEW_POST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']), 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']), 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']), 'MINI_POST_IMG' => $post_unread ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']), 'RETURN_REPORTS' => sprintf($user->lang['RETURN_REPORTS'], '<a href="' . append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports' . ($post_info['post_reported'] ? '&mode=reports' : '&mode=reports_closed') . '&start=' . $start . '&f=' . $post_info['forum_id']) . '">', '</a>'), 'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']), 'REPORT_DATE' => $user->format_date($report['report_time']), 'REPORT_ID' => $report_id, 'REPORT_REASON_TITLE' => $reason['title'], 'REPORT_REASON_DESCRIPTION' => $reason['description'], 'REPORT_TEXT' => $report['report_text'], 'POST_AUTHOR_FULL' => get_username_string('full', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_AUTHOR' => get_username_string('username', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'REPORTER_FULL' => get_username_string('full', $report['user_id'], $report['username'], $report['user_colour']), 'REPORTER_COLOUR' => get_username_string('colour', $report['user_id'], $report['username'], $report['user_colour']), 'REPORTER_NAME' => get_username_string('username', $report['user_id'], $report['username'], $report['user_colour']), 'U_VIEW_REPORTER_PROFILE' => get_username_string('profile', $report['user_id'], $report['username'], $report['user_colour']), 'POST_PREVIEW' => $message, 'POST_SUBJECT' => $post_info['post_subject'] ? $post_info['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_DATE' => $user->format_date($post_info['post_time']), 'POST_IP' => $post_info['poster_ip'], 'POST_IPADDR' => $auth->acl_get('m_info', $post_info['forum_id']) && request_var('lookup', '') ? @gethostbyaddr($post_info['poster_ip']) : '', 'POST_ID' => $post_info['post_id'], 'U_LOOKUP_IP' => $auth->acl_get('m_info', $post_info['forum_id']) ? $this->u_action . '&r=' . $report_id . '&p=' . $post_id . '&f=' . $forum_id . '&lookup=' . $post_info['poster_ip'] . '#ip' : ''));
$this->tpl_name = 'mcp_post';
break;
//.........這裏部分代碼省略.........
示例3: main
//.........這裏部分代碼省略.........
$hidden_fields = array('mode' => $mode, 'ban' => $ban, 'bansubmit' => true, 'banlength' => $ban_length, 'banlengthother' => $ban_length_other, 'banexclude' => $ban_exclude, 'banreason' => $ban_reason, 'bangivereason' => $ban_give_reason);
/**
* Use this event to pass data from the ban form to the confirmation screen
*
* @event core.mcp_ban_confirm
* @var array hidden_fields Hidden fields that are passed through the confirm screen
* @since 3.1.0-RC5
*/
$vars = array('hidden_fields');
extract($phpbb_dispatcher->trigger_event('core.mcp_ban_confirm', compact($vars)));
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($hidden_fields));
}
}
} else {
if ($unbansubmit) {
$ban = $request->variable('unban', array(''));
if ($ban) {
if (confirm_box(true)) {
user_unban($mode, $ban);
trigger_error($user->lang['BAN_UPDATE_SUCCESSFUL'] . '<br /><br /><a href="' . $this->u_action . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>');
} else {
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('mode' => $mode, 'unbansubmit' => true, 'unban' => $ban)));
}
}
}
}
// Ban length options
$ban_end_text = array(0 => $user->lang['PERMANENT'], 30 => $user->lang['30_MINS'], 60 => $user->lang['1_HOUR'], 360 => $user->lang['6_HOURS'], 1440 => $user->lang['1_DAY'], 10080 => $user->lang['7_DAYS'], 20160 => $user->lang['2_WEEKS'], 40320 => $user->lang['1_MONTH'], -1 => $user->lang['UNTIL'] . ' -> ');
$ban_end_options = '';
foreach ($ban_end_text as $length => $text) {
$ban_end_options .= '<option value="' . $length . '">' . $text . '</option>';
}
// Define language vars
$this->page_title = $user->lang[strtoupper($mode) . '_BAN'];
$l_ban_explain = $user->lang[strtoupper($mode) . '_BAN_EXPLAIN'];
$l_ban_exclude_explain = $user->lang[strtoupper($mode) . '_BAN_EXCLUDE_EXPLAIN'];
$l_unban_title = $user->lang[strtoupper($mode) . '_UNBAN'];
$l_unban_explain = $user->lang[strtoupper($mode) . '_UNBAN_EXPLAIN'];
$l_no_ban_cell = $user->lang[strtoupper($mode) . '_NO_BANNED'];
switch ($mode) {
case 'user':
$l_ban_cell = $user->lang['USERNAME'];
break;
case 'ip':
$l_ban_cell = $user->lang['IP_HOSTNAME'];
break;
case 'email':
$l_ban_cell = $user->lang['EMAIL_ADDRESS'];
break;
}
acp_ban::display_ban_options($mode);
$template->assign_vars(array('L_TITLE' => $this->page_title, 'L_EXPLAIN' => $l_ban_explain, 'L_UNBAN_TITLE' => $l_unban_title, 'L_UNBAN_EXPLAIN' => $l_unban_explain, 'L_BAN_CELL' => $l_ban_cell, 'L_BAN_EXCLUDE_EXPLAIN' => $l_ban_exclude_explain, 'L_NO_BAN_CELL' => $l_no_ban_cell, 'S_USERNAME_BAN' => $mode == 'user' ? true : false, 'U_ACTION' => $this->u_action, 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=searchuser&form=mcp_ban&field=ban')));
if ($mode === 'email' && !$auth->acl_get('a_user')) {
return;
}
// As a "service" we will check if any post id is specified and populate the username of the poster id if given
$post_id = $request->variable('p', 0);
$user_id = $request->variable('u', 0);
$pre_fill = false;
if ($user_id && $user_id != ANONYMOUS) {
$sql = 'SELECT username, user_email, user_ip
FROM ' . USERS_TABLE . '
WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql);
switch ($mode) {
case 'user':
$pre_fill = (string) $db->sql_fetchfield('username');
break;
case 'ip':
$pre_fill = (string) $db->sql_fetchfield('user_ip');
break;
case 'email':
$pre_fill = (string) $db->sql_fetchfield('user_email');
break;
}
$db->sql_freeresult($result);
} else {
if ($post_id) {
$post_info = phpbb_get_post_data($post_id, 'm_ban');
if (sizeof($post_info) && !empty($post_info[$post_id])) {
switch ($mode) {
case 'user':
$pre_fill = $post_info[$post_id]['username'];
break;
case 'ip':
$pre_fill = $post_info[$post_id]['poster_ip'];
break;
case 'email':
$pre_fill = $post_info[$post_id]['user_email'];
break;
}
}
}
}
if ($pre_fill) {
// left for legacy template compatibility
$template->assign_var('USERNAMES', $pre_fill);
$template->assign_var('BAN_QUANTIFIER', $pre_fill);
}
}
示例4: change_poster
/**
* Change a post's poster
*/
function change_poster(&$post_info, $userdata)
{
global $auth, $db, $config, $phpbb_root_path, $phpEx, $user, $phpbb_dispatcher;
if (empty($userdata) || $userdata['user_id'] == $post_info['user_id']) {
return;
}
$post_id = $post_info['post_id'];
$sql = 'UPDATE ' . POSTS_TABLE . "\n\t\tSET poster_id = {$userdata['user_id']}\n\t\tWHERE post_id = {$post_id}";
$db->sql_query($sql);
// Resync topic/forum if needed
if ($post_info['topic_last_post_id'] == $post_id || $post_info['forum_last_post_id'] == $post_id || $post_info['topic_first_post_id'] == $post_id) {
sync('topic', 'topic_id', $post_info['topic_id'], false, false);
sync('forum', 'forum_id', $post_info['forum_id'], false, false);
}
// Adjust post counts... only if the post is approved (else, it was not added the users post count anyway)
if ($post_info['post_postcount'] && $post_info['post_visibility'] == ITEM_APPROVED) {
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_posts = user_posts - 1
WHERE user_id = ' . $post_info['user_id'] . '
AND user_posts > 0';
$db->sql_query($sql);
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_posts = user_posts + 1
WHERE user_id = ' . $userdata['user_id'];
$db->sql_query($sql);
}
// Add posted to information for this topic for the new user
markread('post', $post_info['forum_id'], $post_info['topic_id'], time(), $userdata['user_id']);
// Remove the dotted topic option if the old user has no more posts within this topic
if ($config['load_db_track'] && $post_info['user_id'] != ANONYMOUS) {
$sql = 'SELECT topic_id
FROM ' . POSTS_TABLE . '
WHERE topic_id = ' . $post_info['topic_id'] . '
AND poster_id = ' . $post_info['user_id'];
$result = $db->sql_query_limit($sql, 1);
$topic_id = (int) $db->sql_fetchfield('topic_id');
$db->sql_freeresult($result);
if (!$topic_id) {
$sql = 'DELETE FROM ' . TOPICS_POSTED_TABLE . '
WHERE user_id = ' . $post_info['user_id'] . '
AND topic_id = ' . $post_info['topic_id'];
$db->sql_query($sql);
}
}
// change the poster_id within the attachments table, else the data becomes out of sync and errors displayed because of wrong ownership
if ($post_info['post_attachment']) {
$sql = 'UPDATE ' . ATTACHMENTS_TABLE . '
SET poster_id = ' . $userdata['user_id'] . '
WHERE poster_id = ' . $post_info['user_id'] . '
AND post_msg_id = ' . $post_info['post_id'] . '
AND topic_id = ' . $post_info['topic_id'];
$db->sql_query($sql);
}
// refresh search cache of this post
$search_type = $config['search_type'];
if (class_exists($search_type)) {
// We do some additional checks in the module to ensure it can actually be utilised
$error = false;
$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);
if (!$error && method_exists($search, 'destroy_cache')) {
$search->destroy_cache(array(), array($post_info['user_id'], $userdata['user_id']));
}
}
$from_username = $post_info['username'];
$to_username = $userdata['username'];
/**
* This event allows you to perform additional tasks after changing a post's poster
*
* @event core.mcp_change_poster_after
* @var array userdata Information on a post's new poster
* @var array post_info Information on the affected post
* @since 3.1.6-RC1
* @changed 3.1.7-RC1 Change location to prevent post_info from being set to the new post information
*/
$vars = array('userdata', 'post_info');
extract($phpbb_dispatcher->trigger_event('core.mcp_change_poster_after', compact($vars)));
// Renew post info
$post_info = phpbb_get_post_data(array($post_id), false, true);
if (!sizeof($post_info)) {
trigger_error('POST_NOT_EXIST');
}
$post_info = $post_info[$post_id];
// Now add log entry
add_log('mod', $post_info['forum_id'], $post_info['topic_id'], 'LOG_MCP_CHANGE_POSTER', $post_info['topic_title'], $from_username, $to_username);
}
示例5: split_topic
/**
* Split topic
*/
function split_topic($action, $topic_id, $to_forum_id, $subject)
{
global $db, $template, $user, $phpEx, $phpbb_root_path, $auth, $config;
$post_id_list = request_var('post_id_list', array(0));
$forum_id = request_var('forum_id', 0);
$start = request_var('start', 0);
if (!sizeof($post_id_list)) {
$template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']);
return;
}
if (!phpbb_check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_split'))) {
return;
}
$post_id = $post_id_list[0];
$post_info = phpbb_get_post_data(array($post_id));
if (!sizeof($post_info)) {
$template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']);
return;
}
$post_info = $post_info[$post_id];
$subject = trim($subject);
// Make some tests
if (!$subject) {
$template->assign_var('MESSAGE', $user->lang['EMPTY_SUBJECT']);
return;
}
if ($to_forum_id <= 0) {
$template->assign_var('MESSAGE', $user->lang['NO_DESTINATION_FORUM']);
return;
}
$forum_info = phpbb_get_forum_data(array($to_forum_id), 'f_post');
if (!sizeof($forum_info)) {
$template->assign_var('MESSAGE', $user->lang['USER_CANNOT_POST']);
return;
}
$forum_info = $forum_info[$to_forum_id];
if ($forum_info['forum_type'] != FORUM_POST) {
$template->assign_var('MESSAGE', $user->lang['FORUM_NOT_POSTABLE']);
return;
}
$redirect = request_var('redirect', build_url(array('quickmod')));
$s_hidden_fields = build_hidden_fields(array('i' => 'main', 'post_id_list' => $post_id_list, 'f' => $forum_id, 'mode' => 'topic_view', 'start' => $start, 'action' => $action, 't' => $topic_id, 'redirect' => $redirect, 'subject' => $subject, 'to_forum_id' => $to_forum_id, 'icon' => request_var('icon', 0)));
$success_msg = $return_link = '';
if (confirm_box(true)) {
if ($action == 'split_beyond') {
$sort_days = $total = 0;
$sort_key = $sort_dir = '';
$sort_by_sql = $sort_order_sql = array();
phpbb_mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id);
$limit_time_sql = $sort_days ? 'AND t.topic_last_post_time >= ' . (time() - $sort_days * 86400) : '';
if ($sort_order_sql[0] == 'u') {
$sql = 'SELECT p.post_id, p.forum_id, p.post_visibility
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u\n\t\t\t\t\tWHERE p.topic_id = {$topic_id}\n\t\t\t\t\t\tAND p.poster_id = u.user_id\n\t\t\t\t\t\t{$limit_time_sql}\n\t\t\t\t\tORDER BY {$sort_order_sql}";
} else {
$sql = 'SELECT p.post_id, p.forum_id, p.post_visibility
FROM ' . POSTS_TABLE . " p\n\t\t\t\t\tWHERE p.topic_id = {$topic_id}\n\t\t\t\t\t\t{$limit_time_sql}\n\t\t\t\t\tORDER BY {$sort_order_sql}";
}
$result = $db->sql_query_limit($sql, 0, $start);
$store = false;
$post_id_list = array();
while ($row = $db->sql_fetchrow($result)) {
// If split from selected post (split_beyond), we split the unapproved items too.
if (($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) && !$auth->acl_get('m_approve', $row['forum_id'])) {
// continue;
}
// Start to store post_ids as soon as we see the first post that was selected
if ($row['post_id'] == $post_id) {
$store = true;
}
if ($store) {
$post_id_list[] = $row['post_id'];
}
}
$db->sql_freeresult($result);
}
if (!sizeof($post_id_list)) {
trigger_error('NO_POST_SELECTED');
}
$icon_id = request_var('icon', 0);
$sql_ary = array('forum_id' => $to_forum_id, 'topic_title' => $subject, 'icon_id' => $icon_id, 'topic_visibility' => 1);
$sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
$to_topic_id = $db->sql_nextid();
move_posts($post_id_list, $to_topic_id);
$topic_info = phpbb_get_topic_data(array($topic_id));
$topic_info = $topic_info[$topic_id];
add_log('mod', $to_forum_id, $to_topic_id, 'LOG_SPLIT_DESTINATION', $subject);
add_log('mod', $forum_id, $topic_id, 'LOG_SPLIT_SOURCE', $topic_info['topic_title']);
// Change topic title of first post
$sql = 'UPDATE ' . POSTS_TABLE . "\n\t\t\tSET post_subject = '" . $db->sql_escape($subject) . "'\n\t\t\tWHERE post_id = {$post_id_list[0]}";
$db->sql_query($sql);
// Copy topic subscriptions to new topic
$sql = 'SELECT user_id, notify_status
FROM ' . TOPICS_WATCH_TABLE . '
WHERE topic_id = ' . $topic_id;
$result = $db->sql_query($sql);
$sql_ary = array();
//.........這裏部分代碼省略.........
示例6: disapprove_posts
/**
* Disapprove Post
*
* @param $post_id_list array IDs of the posts to disapprove/delete
* @param $id mixed Category of the current active module
* @param $mode string Active module
* @return null
*/
public static function disapprove_posts($post_id_list, $id, $mode)
{
global $db, $template, $user, $config, $phpbb_container, $phpbb_dispatcher;
global $phpEx, $phpbb_root_path, $request, $phpbb_log;
if (!phpbb_check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve'))) {
trigger_error('NOT_AUTHORISED');
}
$redirect = $request->variable('redirect', build_url(array('t', 'mode', 'quickmod')) . "&mode={$mode}");
$redirect = reapply_sid($redirect);
$reason = $request->variable('reason', '', true);
$reason_id = $request->variable('reason_id', 0);
$success_msg = $additional_msg = '';
$s_hidden_fields = build_hidden_fields(array('i' => $id, 'mode' => $mode, 'post_id_list' => $post_id_list, 'action' => 'disapprove', 'redirect' => $redirect));
$notify_poster = $request->is_set('notify_poster');
$disapprove_reason = '';
if ($reason_id) {
$sql = 'SELECT reason_title, reason_description
FROM ' . REPORTS_REASONS_TABLE . "\n\t\t\t\tWHERE reason_id = {$reason_id}";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$row || !$reason && strtolower($row['reason_title']) == 'other') {
$additional_msg = $user->lang['NO_REASON_DISAPPROVAL'];
$request->overwrite('confirm', null, \phpbb\request\request_interface::POST);
$request->overwrite('confirm_key', null, \phpbb\request\request_interface::POST);
$request->overwrite('confirm_key', null, \phpbb\request\request_interface::REQUEST);
} else {
// If the reason is defined within the language file, we will use the localized version, else just use the database entry...
$disapprove_reason = strtolower($row['reason_title']) != 'other' ? isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]) ? $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])] : $row['reason_description'] : '';
$disapprove_reason .= $reason ? "\n\n" . $reason : '';
if (isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])])) {
$disapprove_reason_lang = strtoupper($row['reason_title']);
}
}
}
$post_info = phpbb_get_post_data($post_id_list, 'm_approve');
$is_disapproving = false;
foreach ($post_info as $post_id => $post_data) {
if ($post_data['post_visibility'] == ITEM_DELETED) {
continue;
}
$is_disapproving = true;
}
if (confirm_box(true)) {
$disapprove_log = $disapprove_log_topics = $disapprove_log_posts = array();
$topic_posts_unapproved = $post_disapprove_list = $topic_information = array();
// Build a list of posts to be disapproved and get the related topics real replies count
foreach ($post_info as $post_id => $post_data) {
$post_disapprove_list[$post_id] = $post_data['topic_id'];
if (!isset($topic_posts_unapproved[$post_data['topic_id']])) {
$topic_information[$post_data['topic_id']] = $post_data;
$topic_posts_unapproved[$post_data['topic_id']] = 0;
}
$topic_posts_unapproved[$post_data['topic_id']]++;
}
// Now we build the log array
foreach ($post_disapprove_list as $post_id => $topic_id) {
// If the count of disapproved posts for the topic is equal
// to the number of unapproved posts in the topic, and there are no different
// posts, we disapprove the hole topic
if ($topic_information[$topic_id]['topic_posts_approved'] == 0 && $topic_information[$topic_id]['topic_posts_softdeleted'] == 0 && $topic_information[$topic_id]['topic_posts_unapproved'] == $topic_posts_unapproved[$topic_id]) {
// Don't write the log more than once for every topic
if (!isset($disapprove_log_topics[$topic_id])) {
// Build disapproved topics log
$disapprove_log_topics[$topic_id] = array('type' => 'topic', 'post_subject' => $post_info[$post_id]['topic_title'], 'forum_id' => $post_info[$post_id]['forum_id'], 'topic_id' => 0, 'post_username' => $post_info[$post_id]['poster_id'] == ANONYMOUS && !empty($post_info[$post_id]['post_username']) ? $post_info[$post_id]['post_username'] : $post_info[$post_id]['username']);
}
} else {
// Build disapproved posts log
$disapprove_log_posts[] = array('type' => 'post', 'post_subject' => $post_info[$post_id]['post_subject'], 'forum_id' => $post_info[$post_id]['forum_id'], 'topic_id' => $post_info[$post_id]['topic_id'], 'post_username' => $post_info[$post_id]['poster_id'] == ANONYMOUS && !empty($post_info[$post_id]['post_username']) ? $post_info[$post_id]['post_username'] : $post_info[$post_id]['username']);
}
}
// Get disapproved posts/topics counts separately
$num_disapproved_topics = sizeof($disapprove_log_topics);
$num_disapproved_posts = sizeof($disapprove_log_posts);
// Build the whole log
$disapprove_log = array_merge($disapprove_log_topics, $disapprove_log_posts);
// Unset unneeded arrays
unset($post_data, $disapprove_log_topics, $disapprove_log_posts);
// Let's do the job - delete disapproved posts
if (sizeof($post_disapprove_list)) {
if (!function_exists('delete_posts')) {
include $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
}
// We do not check for permissions here, because the moderator allowed approval/disapproval should be allowed to delete the disapproved posts
// Note: function delete_posts triggers related forums/topics sync,
// so we don't need to call update_post_information later and to adjust real topic replies or forum topics count manually
delete_posts('post_id', array_keys($post_disapprove_list));
foreach ($disapprove_log as $log_data) {
if ($is_disapproving) {
$l_log_message = $log_data['type'] == 'topic' ? 'LOG_TOPIC_DISAPPROVED' : 'LOG_POST_DISAPPROVED';
$phpbb_log->add('mod', $user->data['user_id'], $user->ip, $l_log_message, false, array('forum_id' => $log_data['forum_id'], 'topic_id' => $log_data['topic_id'], $log_data['post_subject'], $disapprove_reason, $log_data['post_username']));
} else {
//.........這裏部分代碼省略.........
示例7: mcp_post_chg_post_time_action
/**
* Validates input and effectively changes posting date and time of the corresponding post
*
* @param object $event The event object
* @return void
*/
public function mcp_post_chg_post_time_action($event)
{
// We only deal with Change Post Time action
if ($event['action'] !== 'chgposttime') {
return;
}
$post_info = $event['post_info'];
$post_id = $post_info['post_id'];
// Check permissions
if (!$this->auth->acl_get('m_chgposttime', $post_info['forum_id'])) {
trigger_error('NOT_AUTHORISED');
}
$from_oldtime = $this->user->format_date($post_info['post_time']);
$year = $this->request->variable('jx_year', 0);
$month = $this->request->variable('jx_month', 0);
$day = $this->request->variable('jx_day', 0);
$hour = $this->request->variable('jx_hour', -1);
$minute = $this->request->variable('jx_minute', -1);
$from_time_ary = getdate($post_info['post_time']);
$year = $year ? $year : $from_time_ary['year'];
$month = $month ? $month : $from_time_ary['mon'];
$day = $day ? $day : $from_time_ary['mday'];
$hour = $hour >= 0 ? $hour : $from_time_ary['hours'];
$minute = $minute >= 0 ? $minute : $from_time_ary['minutes'];
$second = 0;
// Use mktime() function to create UNIX timestamp
$update_time = mktime($hour, $minute, $second, $month, $day, $year);
// Update post_time in database
$sql = 'UPDATE ' . POSTS_TABLE . ' SET post_time = ' . (int) $update_time . ' WHERE post_id = ' . (int) $post_id;
$this->db->sql_query($sql);
include_once $this->root_path . 'includes/functions_admin.' . $this->php_ext;
include_once $this->root_path . 'includes/functions_mcp.' . $this->php_ext;
sync('topic', 'topic_id', $post_info['topic_id'], true);
sync('forum', 'forum_id', $post_info['forum_id'], true);
// Renew post info
$post_info = phpbb_get_post_data(array($post_id), false, true);
if (!sizeof($post_info)) {
trigger_error('POST_NOT_EXIST');
}
$post_info = $post_info[$post_id];
$to_newtime = $this->user->format_date($update_time);
// Now add log entry
$phpbb_log = $this->container->get('log');
$phpbb_log->add('mod', $this->user->data['user_id'], $this->user->ip, 'LOG_MCP_JX_CHANGE_POSTTIME', false, array('forum_id' => (int) $post_info['forum_id'], 'topic_id' => (int) $post_info['topic_id'], $post_info['topic_title'], $from_oldtime, $to_newtime, (int) $post_id));
$event['post_info'] = $post_info;
}