本文整理汇总了PHP中update_post_information函数的典型用法代码示例。如果您正苦于以下问题:PHP update_post_information函数的具体用法?PHP update_post_information怎么用?PHP update_post_information使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update_post_information函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submit_post_end
public function submit_post_end($event)
{
if ($event['mode'] == 'edit') {
// we need to ensure that what we are resetting is appropriate
// do we care about when someone edits the first post of a topic?
// $event['data']['topic_first_post_id'] == $event['data']['post_id'] $post_mode = 'edit_first_post'
$ext_post_mode = '';
if ($event['data']['topic_posts_approved'] + $event['data']['topic_posts_unapproved'] + $event['data']['topic_posts_softdeleted'] == 1) {
$ext_post_mode = 'edit_topic';
} else {
if ($event['data']['topic_last_post_id'] == $event['data']['post_id']) {
$ext_post_mode = 'edit_last_post';
}
}
if ($ext_post_mode == 'edit_last_post' || $ext_post_mode == 'edit_topic') {
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_time = ' . time() . '
WHERE post_id = ' . $event['data']['post_id'] . '
AND topic_id = ' . $event['data']['topic_id'];
$this->db->sql_query($sql);
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_last_post_time = ' . time() . '
WHERE topic_id = ' . $event['data']['topic_id'];
$this->db->sql_query($sql);
if (!function_exists('update_post_information')) {
include $this->root_path . 'includes/functions_posting.' . $this->php_ext;
}
update_post_information('forum', $event['data']['forum_id']);
markread('post', $event['data']['forum_id'], $event['data']['topic_id'], $event['data']['post_time']);
}
}
}
示例2: delete_post
/**
* Delete Post
*/
function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $softdelete_reason = '')
{
global $db, $user, $auth, $phpbb_container;
global $config, $phpEx, $phpbb_root_path;
// Specify our post mode
$post_mode = 'delete';
if ($data['topic_first_post_id'] === $data['topic_last_post_id'] && $data['topic_posts_approved'] + $data['topic_posts_unapproved'] + $data['topic_posts_softdeleted'] == 1) {
$post_mode = 'delete_topic';
} else {
if ($data['topic_first_post_id'] == $post_id) {
$post_mode = 'delete_first_post';
} else {
if ($data['topic_last_post_id'] == $post_id) {
$post_mode = 'delete_last_post';
}
}
}
$sql_data = array();
$next_post_id = false;
include_once $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
$db->sql_transaction('begin');
// we must make sure to update forums that contain the shadow'd topic
if ($post_mode == 'delete_topic') {
$shadow_forum_ids = array();
$sql = 'SELECT forum_id
FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_moved_id', $topic_id);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
if (!isset($shadow_forum_ids[(int) $row['forum_id']])) {
$shadow_forum_ids[(int) $row['forum_id']] = 1;
} else {
$shadow_forum_ids[(int) $row['forum_id']]++;
}
}
$db->sql_freeresult($result);
}
/* @var $phpbb_content_visibility \phpbb\content_visibility */
$phpbb_content_visibility = $phpbb_container->get('content.visibility');
// (Soft) delete the post
if ($is_soft && $post_mode != 'delete_topic') {
$phpbb_content_visibility->set_post_visibility(ITEM_DELETED, $post_id, $topic_id, $forum_id, $user->data['user_id'], time(), $softdelete_reason, $data['topic_first_post_id'] == $post_id, $data['topic_last_post_id'] == $post_id);
} else {
if (!$is_soft) {
if (!delete_posts('post_id', array($post_id), false, false, false)) {
// Try to delete topic, we may had an previous error causing inconsistency
if ($post_mode == 'delete_topic') {
delete_topics('topic_id', array($topic_id), false);
}
trigger_error('ALREADY_DELETED');
}
}
}
$db->sql_transaction('commit');
// Collect the necessary information for updating the tables
$sql_data[FORUMS_TABLE] = $sql_data[TOPICS_TABLE] = '';
switch ($post_mode) {
case 'delete_topic':
foreach ($shadow_forum_ids as $updated_forum => $topic_count) {
// counting is fun! we only have to do sizeof($forum_ids) number of queries,
// even if the topic is moved back to where its shadow lives (we count how many times it is in a forum)
$sql = 'UPDATE ' . FORUMS_TABLE . '
SET forum_topics_approved = forum_topics_approved - ' . $topic_count . '
WHERE forum_id = ' . $updated_forum;
$db->sql_query($sql);
update_post_information('forum', $updated_forum);
}
if ($is_soft) {
$topic_row = array();
$phpbb_content_visibility->set_topic_visibility(ITEM_DELETED, $topic_id, $forum_id, $user->data['user_id'], time(), $softdelete_reason);
} else {
delete_topics('topic_id', array($topic_id), false);
$phpbb_content_visibility->remove_topic_from_statistic($data, $sql_data);
$update_sql = update_post_information('forum', $forum_id, true);
if (sizeof($update_sql)) {
$sql_data[FORUMS_TABLE] .= $sql_data[FORUMS_TABLE] ? ', ' : '';
$sql_data[FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]);
}
}
break;
case 'delete_first_post':
$sql = 'SELECT p.post_id, p.poster_id, p.post_time, p.post_username, u.username, u.user_colour
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u\n\t\t\t\tWHERE p.topic_id = {$topic_id}\n\t\t\t\t\tAND p.poster_id = u.user_id\n\t\t\t\t\tAND p.post_visibility = " . ITEM_APPROVED . '
ORDER BY p.post_time ASC, p.post_id ASC';
$result = $db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$row) {
// No approved post, so the first is a not-approved post (unapproved or soft deleted)
$sql = 'SELECT p.post_id, p.poster_id, p.post_time, p.post_username, u.username, u.user_colour
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\tORDER BY p.post_time ASC, p.post_id ASC";
$result = $db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
}
$next_post_id = (int) $row['post_id'];
$sql_data[TOPICS_TABLE] = $db->sql_build_array('UPDATE', array('topic_poster' => (int) $row['poster_id'], 'topic_first_post_id' => (int) $row['post_id'], 'topic_first_poster_colour' => $row['user_colour'], 'topic_first_poster_name' => $row['poster_id'] == ANONYMOUS ? $row['post_username'] : $row['username'], 'topic_time' => (int) $row['post_time']));
//.........这里部分代码省略.........
示例3: disapprove_post
/**
* Disapprove Post/Topic
*/
function disapprove_post($post_id_list, $id, $mode)
{
global $db, $template, $user, $config;
global $phpEx, $phpbb_root_path;
if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve'))) {
trigger_error('NOT_AUTHORISED');
}
$redirect = request_var('redirect', build_url(array('t', 'mode', 'quickmod')) . "&mode={$mode}");
$reason = utf8_normalize_nfc(request_var('reason', '', true));
$reason_id = request_var('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 = isset($_REQUEST['notify_poster']) ? true : false;
$disapprove_reason = '';
if ($reason_id) {
$sql = 'SELECT reason_title, reason_description
FROM ' . REPORTS_REASONS_TABLE . "\n\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'];
unset($_POST['confirm']);
} 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']);
}
$email_disapprove_reason = $disapprove_reason;
}
}
$post_info = get_post_data($post_id_list, 'm_approve');
if (confirm_box(true)) {
// If Topic -> forum_topics_real -= 1
// If Post -> topic_replies_real -= 1
$num_disapproved = 0;
$forum_topics_real = $topic_id_list = $forum_id_list = $topic_replies_real_sql = $post_disapprove_sql = $disapprove_log = array();
foreach ($post_info as $post_id => $post_data) {
$topic_id_list[$post_data['topic_id']] = 1;
if ($post_data['forum_id']) {
$forum_id_list[$post_data['forum_id']] = 1;
}
// Topic or Post. ;)
/**
* @todo this probably is a different method than the one used by delete_posts, does this cause counter inconsistency?
*/
if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_last_post_id'] == $post_id) {
if ($post_data['forum_id']) {
if (!isset($forum_topics_real[$post_data['forum_id']])) {
$forum_topics_real[$post_data['forum_id']] = 0;
}
$forum_topics_real[$post_data['forum_id']]++;
$num_disapproved++;
}
$disapprove_log[] = array('type' => 'topic', 'post_subject' => $post_data['post_subject'], 'forum_id' => $post_data['forum_id'], 'topic_id' => 0);
} else {
if (!isset($topic_replies_real_sql[$post_data['topic_id']])) {
$topic_replies_real_sql[$post_data['topic_id']] = 0;
}
$topic_replies_real_sql[$post_data['topic_id']]++;
$disapprove_log[] = array('type' => 'post', 'post_subject' => $post_data['post_subject'], 'forum_id' => $post_data['forum_id'], 'topic_id' => $post_data['topic_id']);
}
$post_disapprove_sql[] = $post_id;
}
unset($post_data);
if (sizeof($forum_topics_real)) {
foreach ($forum_topics_real as $forum_id => $topics_real) {
$sql = 'UPDATE ' . FORUMS_TABLE . "\n\t\t\t\t\tSET forum_topics_real = forum_topics_real - {$topics_real}\n\t\t\t\t\tWHERE forum_id = {$forum_id}";
$db->sql_query($sql);
}
}
if (sizeof($topic_replies_real_sql)) {
foreach ($topic_replies_real_sql as $topic_id => $num_replies) {
$sql = 'UPDATE ' . TOPICS_TABLE . "\n\t\t\t\t\tSET topic_replies_real = topic_replies_real - {$num_replies}\n\t\t\t\t\tWHERE topic_id = {$topic_id}";
$db->sql_query($sql);
}
}
if (sizeof($post_disapprove_sql)) {
if (!function_exists('delete_posts')) {
include_once $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
delete_posts('post_id', $post_disapprove_sql);
foreach ($disapprove_log as $log_data) {
add_log('mod', $log_data['forum_id'], $log_data['topic_id'], $log_data['type'] == 'topic' ? 'LOG_TOPIC_DISAPPROVED' : 'LOG_POST_DISAPPROVED', $log_data['post_subject'], $disapprove_reason);
}
}
unset($post_disapprove_sql, $topic_replies_real_sql);
update_post_information('topic', array_keys($topic_id_list));
if (sizeof($forum_id_list)) {
update_post_information('forum', array_keys($forum_id_list));
}
unset($topic_id_list, $forum_id_list);
$messenger = new messenger();
// Notify Poster?
//.........这里部分代码省略.........
示例4: delete_post
/**
* Delete Post
*/
function delete_post($forum_id, $topic_id, $post_id, &$data)
{
global $db, $user, $auth;
global $config, $phpEx, $phpbb_root_path;
// Specify our post mode
$post_mode = 'delete';
if ($data['topic_first_post_id'] === $data['topic_last_post_id'] && $data['topic_replies_real'] == 0) {
$post_mode = 'delete_topic';
} else {
if ($data['topic_first_post_id'] == $post_id) {
$post_mode = 'delete_first_post';
} else {
if ($data['topic_last_post_id'] == $post_id) {
$post_mode = 'delete_last_post';
}
}
}
$sql_data = array();
$next_post_id = false;
include_once $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
$db->sql_transaction('begin');
// we must make sure to update forums that contain the shadow'd topic
if ($post_mode == 'delete_topic') {
$shadow_forum_ids = array();
$sql = 'SELECT forum_id
FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_moved_id', $topic_id);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
if (!isset($shadow_forum_ids[(int) $row['forum_id']])) {
$shadow_forum_ids[(int) $row['forum_id']] = 1;
} else {
$shadow_forum_ids[(int) $row['forum_id']]++;
}
}
$db->sql_freeresult($result);
}
if (!delete_posts('post_id', array($post_id), false, false)) {
// Try to delete topic, we may had an previous error causing inconsistency
if ($post_mode == 'delete_topic') {
delete_topics('topic_id', array($topic_id), false);
}
trigger_error('ALREADY_DELETED');
}
$db->sql_transaction('commit');
// Collect the necessary information for updating the tables
$sql_data[FORUMS_TABLE] = '';
switch ($post_mode) {
case 'delete_topic':
foreach ($shadow_forum_ids as $updated_forum => $topic_count) {
// counting is fun! we only have to do sizeof($forum_ids) number of queries,
// even if the topic is moved back to where its shadow lives (we count how many times it is in a forum)
$db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_topics_real = forum_topics_real - ' . $topic_count . ', forum_topics = forum_topics - ' . $topic_count . ' WHERE forum_id = ' . $updated_forum);
update_post_information('forum', $updated_forum);
}
delete_topics('topic_id', array($topic_id), false);
if ($data['topic_type'] != POST_GLOBAL) {
$sql_data[FORUMS_TABLE] .= 'forum_topics_real = forum_topics_real - 1';
$sql_data[FORUMS_TABLE] .= $data['topic_approved'] ? ', forum_posts = forum_posts - 1, forum_topics = forum_topics - 1' : '';
}
$update_sql = update_post_information('forum', $forum_id, true);
if (sizeof($update_sql)) {
$sql_data[FORUMS_TABLE] .= $sql_data[FORUMS_TABLE] ? ', ' : '';
$sql_data[FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]);
}
break;
case 'delete_first_post':
$sql = 'SELECT p.post_id, p.poster_id, p.post_time, p.post_username, u.username, u.user_colour
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u\n\t\t\t\tWHERE p.topic_id = {$topic_id}\n\t\t\t\t\tAND p.poster_id = u.user_id\n\t\t\t\tORDER BY p.post_time ASC";
$result = $db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($data['topic_type'] != POST_GLOBAL) {
$sql_data[FORUMS_TABLE] = $data['post_approved'] ? 'forum_posts = forum_posts - 1' : '';
}
$sql_data[TOPICS_TABLE] = 'topic_poster = ' . intval($row['poster_id']) . ', topic_first_post_id = ' . intval($row['post_id']) . ", topic_first_poster_colour = '" . $db->sql_escape($row['user_colour']) . "', topic_first_poster_name = '" . ($row['poster_id'] == ANONYMOUS ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "', topic_time = " . (int) $row['post_time'];
// Decrementing topic_replies here is fine because this case only happens if there is more than one post within the topic - basically removing one "reply"
$sql_data[TOPICS_TABLE] .= ', topic_replies_real = topic_replies_real - 1' . ($data['post_approved'] ? ', topic_replies = topic_replies - 1' : '');
$next_post_id = (int) $row['post_id'];
break;
case 'delete_last_post':
if ($data['topic_type'] != POST_GLOBAL) {
$sql_data[FORUMS_TABLE] = $data['post_approved'] ? 'forum_posts = forum_posts - 1' : '';
}
$update_sql = update_post_information('forum', $forum_id, true);
if (sizeof($update_sql)) {
$sql_data[FORUMS_TABLE] .= $sql_data[FORUMS_TABLE] ? ', ' : '';
$sql_data[FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]);
}
$sql_data[TOPICS_TABLE] = 'topic_bumped = 0, topic_bumper = 0, topic_replies_real = topic_replies_real - 1' . ($data['post_approved'] ? ', topic_replies = topic_replies - 1' : '');
$update_sql = update_post_information('topic', $topic_id, true);
if (sizeof($update_sql)) {
$sql_data[TOPICS_TABLE] .= ', ' . implode(', ', $update_sql[$topic_id]);
$next_post_id = (int) str_replace('topic_last_post_id = ', '', $update_sql[$topic_id][0]);
} else {
$sql = 'SELECT MAX(post_id) as last_post_id
FROM ' . POSTS_TABLE . "\n\t\t\t\t\tWHERE topic_id = {$topic_id} " . (!$auth->acl_get('m_approve', $forum_id) ? 'AND post_approved = 1' : '');
//.........这里部分代码省略.........
示例5: disapprove_post
/**
* Disapprove Post/Topic
*/
function disapprove_post($post_id_list, $mode)
{
global $db, $template, $user, $config;
global $phpEx, $phpbb_root_path;
if (!($forum_id = check_ids($post_id_list, POSTS_TABLE, 'post_id', 'm_approve'))) {
trigger_error('NOT_AUTHORIZED');
}
$redirect = request_var('redirect', build_url(array('t', 'mode')) . '&mode=unapproved_topics');
$reason = request_var('reason', '', true);
$reason_id = request_var('reason_id', 0);
$success_msg = $additional_msg = '';
$s_hidden_fields = build_hidden_fields(array('i' => 'queue', 'mode' => $mode, 'post_id_list' => $post_id_list, 'f' => $forum_id, 'action' => 'disapprove', 'redirect' => $redirect));
$notify_poster = isset($_REQUEST['notify_poster']) ? true : false;
$disapprove_reason = '';
if ($reason_id) {
$sql = 'SELECT reason_title, reason_description
FROM ' . REPORTS_REASONS_TABLE . "\n\t\t\tWHERE reason_id = {$reason_id}";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$row || !$reason && $row['reason_title'] == 'other') {
$additional_msg = $user->lang['NO_REASON_DISAPPROVAL'];
unset($_POST['confirm']);
} else {
// If the reason is defined within the language file, we will use the localized version, else just use the database entry...
$disapprove_reason = $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 (confirm_box(true)) {
$post_info = get_post_data($post_id_list, 'm_approve');
// If Topic -> forum_topics_real -= 1
// If Post -> topic_replies_real -= 1
$forum_topics_real = 0;
$topic_replies_real_sql = $post_disapprove_sql = $topic_id_list = array();
foreach ($post_info as $post_id => $post_data) {
$topic_id_list[$post_data['topic_id']] = 1;
// Topic or Post. ;)
if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_last_post_id'] == $post_id) {
if ($post_data['forum_id']) {
$forum_topics_real++;
}
} else {
if (!isset($topic_replies_real_sql[$post_data['topic_id']])) {
$topic_replies_real_sql[$post_data['topic_id']] = 1;
} else {
$topic_replies_real_sql[$post_data['topic_id']]++;
}
}
$post_disapprove_sql[] = $post_id;
}
if ($forum_topics_real) {
$sql = 'UPDATE ' . FORUMS_TABLE . "\n\t\t\t\tSET forum_topics_real = forum_topics_real - {$forum_topics_real}\n\t\t\t\tWHERE forum_id = {$forum_id}";
$db->sql_query($sql);
}
if (sizeof($topic_replies_real_sql)) {
foreach ($topic_replies_real_sql as $topic_id => $num_replies) {
$sql = 'UPDATE ' . TOPICS_TABLE . "\n\t\t\t\t\tSET topic_replies_real = topic_replies_real - {$num_replies}\n\t\t\t\t\tWHERE topic_id = {$topic_id}";
$db->sql_query($sql);
}
}
if (sizeof($post_disapprove_sql)) {
if (!function_exists('delete_posts')) {
include_once $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
delete_posts('post_id', $post_disapprove_sql);
}
unset($post_disapprove_sql, $topic_replies_real_sql);
update_post_information('topic', array_keys($topic_id_list));
update_post_information('forum', $forum_id);
unset($topic_id_list);
$messenger = new messenger();
// Notify Poster?
if ($notify_poster) {
$email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
foreach ($post_info as $post_id => $post_data) {
if ($post_data['poster_id'] == ANONYMOUS) {
continue;
}
$email_template = $post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id'] ? 'topic_disapproved' : 'post_disapproved';
$messenger->template($email_template, $post_data['user_lang']);
$messenger->replyto($config['board_email']);
$messenger->to($post_data['user_email'], $post_data['username']);
$messenger->im($post_data['user_jabber'], $post_data['username']);
$messenger->assign_vars(array('EMAIL_SIG' => $email_sig, 'SITENAME' => $config['sitename'], 'USERNAME' => html_entity_decode($post_data['username']), 'REASON' => html_entity_decode($disapprove_reason), 'POST_SUBJECT' => html_entity_decode(censor_text($post_data['post_subject'])), 'TOPIC_TITLE' => html_entity_decode(censor_text($post_data['topic_title']))));
$messenger->send($post_data['user_notify_type']);
$messenger->reset();
}
$messenger->save_queue();
}
unset($post_info, $disapprove_reason);
if ($forum_topics_real) {
$success_msg = $forum_topics_real == 1 ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS';
} else {
$success_msg = sizeof($post_id_list) == 1 ? 'POST_DISAPPROVED_SUCCESS' : 'POSTS_DISAPPROVED_SUCCESS';
}
//.........这里部分代码省略.........
示例6: update_first_last_post
function update_first_last_post()
{
global $db;
//topic_first_post
$this->topic_first_post = array_unique($this->topic_first_post);
foreach ($this->topic_first_post as $topic_id) {
$sql = 'SELECT p.post_id, p.post_visibility, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
WHERE p.topic_id=' . $topic_id . '
AND u.user_id = p.poster_id
ORDER BY post_time ASC';
$result = $db->sql_query_limit($sql, 1);
if ($row = $db->sql_fetchrow($result)) {
$this->set('topic', $topic_id, array('topic_time' => $row['post_time'], 'topic_poster' => $row['poster_id'], 'topic_visibility' => $row['post_visibility'], 'topic_first_post_id' => $row['post_id'], 'topic_first_poster_name' => $row['poster_id'] == ANONYMOUS ? $row['post_username'] : $row['username'], 'topic_first_poster_colour' => $row['user_colour']));
}
}
//topic_last_post
if (count($this->topic_last_post)) {
$update_sql = update_post_information('topic', $this->topic_last_post, true);
foreach ($update_sql as $topic_id => $sql) {
$this->init('topic', $topic_id);
$this->data['topic'][$topic_id]['sql'] += $sql;
}
}
//forum_last_post
if (count($this->forum_last_post)) {
$update_sql = update_post_information('forum', $this->forum_last_post, true);
foreach ($update_sql as $forum_id => $sql) {
$this->init('forum', $forum_id);
$this->data['forum'][$forum_id]['sql'] += $sql;
}
}
}
示例7:
$db->sql_transaction('begin');
$sql = 'UPDATE ' . POSTS_TABLE . "
SET post_time = $current_time
WHERE post_id = {$post_data['topic_last_post_id']}
AND topic_id = $topic_id";
$db->sql_query($sql);
$sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_last_post_time = $current_time,
topic_bumped = 1,
topic_bumper = " . $user->data['user_id'] . "
WHERE topic_id = $topic_id";
$db->sql_query($sql);
update_post_information('forum', $forum_id);
$sql = 'UPDATE ' . USERS_TABLE . "
SET user_lastpost_time = $current_time
WHERE user_id = " . $user->data['user_id'];
$db->sql_query($sql);
$db->sql_transaction('commit');
markread('post', $forum_id, $topic_id, $current_time);
add_log('mod', $forum_id, $topic_id, 'LOG_BUMP_TOPIC', $post_data['topic_title']);
$meta_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&p={$post_data['topic_last_post_id']}") . "#p{$post_data['topic_last_post_id']}";
meta_refresh(3, $meta_url);
示例8: disapprove_post
function disapprove_post($post_id_list)
{
global $_CLASS, $_CORE_CONFIG, $config;
if (!($forum_id = check_ids($post_id_list, POSTS_TABLE, 'post_id', 'm_approve'))) {
trigger_error('NOT_AUTHORIZED');
}
$redirect = request_var('redirect', $_CLASS['core_user']->data['session_page']);
$reason = request_var('reason', '');
$reason_id = request_var('reason_id', 0);
$success_msg = $additional_msg = '';
$s_hidden_fields = build_hidden_fields(array('post_id_list' => $post_id_list, 'f' => $forum_id, 'mode' => 'disapprove', 'redirect' => $redirect));
$notify_poster = isset($_REQUEST['notify_poster']) ? true : false;
if ($reason_id) {
$sql = 'SELECT reason_name
FROM ' . REASONS_TABLE . " \n\t\t\tWHERE reason_id = {$reason_id}";
$result = $_CLASS['core_db']->query($sql);
if (!($row = $_CLASS['core_db']->fetch_row_assoc($result)) || !$reason && $row['reason_name'] == 'other') {
$additional_msg = 'Please give an appropiate reason for disapproval';
unset($_POST['confirm']);
} else {
$disapprove_reason = $row['reason_name'] != 'other' ? $_CLASS['core_user']->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_name'])] : '';
$disapprove_reason .= $reason ? "\n\n" . $_REQUEST['reason'] : '';
unset($reason);
}
$_CLASS['core_db']->free_result($result);
}
if (confirm_box(true)) {
$post_info = get_post_data($post_id_list, 'm_approve');
// If Topic -> forum_topics_real -= 1
// If Post -> topic_replies_real -= 1
$forum_topics_real = 0;
$topic_replies_real_sql = $post_disapprove_sql = $topic_id_list = array();
foreach ($post_info as $post_id => $post_data) {
$topic_id_list[$post_data['topic_id']] = 1;
// Topic or Post. ;)
if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_last_post_id'] == $post_id) {
if ($post_data['forum_id']) {
$forum_topics_real++;
}
} else {
if (!isset($topic_replies_real_sql[$post_data['topic_id']])) {
$topic_replies_real_sql[$post_data['topic_id']] = 1;
} else {
$topic_replies_real_sql[$post_data['topic_id']]++;
}
}
$post_disapprove_sql[] = $post_id;
}
if ($forum_topics_real) {
$sql = 'UPDATE ' . FORUMS_TABLE . "\n\t\t\t\tSET forum_topics_real = forum_topics_real - {$forum_topics_real}\n\t\t\t\tWHERE forum_id = {$forum_id}";
$_CLASS['core_db']->query($sql);
}
if (sizeof($topic_replies_real_sql)) {
foreach ($topic_replies_real_sql as $topic_id => $num_replies) {
$sql = 'UPDATE ' . TOPICS_TABLE . "\n\t\t\t\t\tSET topic_replies_real = topic_replies_real - {$num_replies}\n\t\t\t\t\tWHERE topic_id = {$topic_id}";
$_CLASS['core_db']->query($sql);
}
}
if (sizeof($post_disapprove_sql)) {
// We do not check for permissions here, because the moderator allowed approval/disapproval should be allowed to delete the disapproved posts
delete_posts('post_id', $post_disapprove_sql);
}
unset($post_disapprove_sql, $topic_replies_real_sql);
update_post_information('topic', array_keys($topic_id_list));
update_post_information('forum', $forum_id);
unset($topic_id_list);
$messenger = new messenger();
// Notify Poster?
if ($notify_poster) {
$email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
foreach ($post_info as $post_id => $post_data) {
if ($post_data['poster_id'] == ANONYMOUS) {
continue;
}
$email_template = $post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id'] ? 'topic_disapproved' : 'post_disapproved';
$messenger->template($email_template, $post_data['user_lang']);
$messenger->replyto($config['board_email']);
$messenger->to($post_data['user_email'], $post_data['username']);
$messenger->im($post_data['user_jabber'], $post_data['username']);
$messenger->assign_vars(array('EMAIL_SIG' => $email_sig, 'SITENAME' => $_CORE_CONFIG['global']['sitename'], 'USERNAME' => $post_data['username'], 'REASON' => stripslashes($disapprove_reason), 'POST_SUBJECT' => censor_text($post_data['post_subject']), 'TOPIC_TITLE' => censor_text($post_data['topic_title'])));
$messenger->send($post_data['user_notify_type']);
$messenger->reset();
}
$messenger->save_queue();
}
unset($post_info, $disapprove_reason);
if ($forum_topics_real) {
$success_msg = $forum_topics_real == 1 ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS';
} else {
$success_msg = sizeof($post_id_list) == 1 ? 'POST_DISAPPROVED_SUCCESS' : 'POSTS_DISAPPROVED_SUCCESS';
}
} else {
$sql = 'SELECT *
FROM ' . REASONS_TABLE . '
ORDER BY reason_priority ASC';
$result = $_CLASS['core_db']->query($sql);
while ($row = $_CLASS['core_db']->fetch_row_assoc($result)) {
$row['reason_name'] = strtoupper($row['reason_name']);
$reason_title = !empty($_CLASS['core_user']->lang['report_reasons']['TITLE'][$row['reason_name']]) ? $_CLASS['core_user']->lang['report_reasons']['TITLE'][$row['reason_name']] : ucwords(str_replace('_', ' ', $row['reason_name']));
$reason_desc = !empty($_CLASS['core_user']->lang['report_reasons']['DESCRIPTION'][$row['reason_name']]) ? $_CLASS['core_user']->lang['report_reasons']['DESCRIPTION'][$row['reason_name']] : $row['reason_desc'];
//.........这里部分代码省略.........
示例9: submit_post
//.........这里部分代码省略.........
}
foreach ($data['attachment_data'] as $pos => $attach_row) {
if ($attach_row['is_orphan'] && !in_array($attach_row['attach_id'], array_keys($orphan_rows))) {
continue;
}
if (!$attach_row['is_orphan']) {
// update entry in db if attachment already stored in db and filespace
$sql = 'UPDATE ' . FORUMS_ATTACHMENTS_TABLE . "\r\n\t\t\t\t\tSET attach_comment = '" . $_CLASS['core_db']->escape($attach_row['attach_comment']) . "'\r\n\t\t\t\t\tWHERE attach_id = " . (int) $attach_row['attach_id'] . '
AND is_orphan = 0';
$_CLASS['core_db']->query($sql);
} else {
// insert attachment into db
if (!@file_exists(SITE_FILE_ROOT . $config['upload_path'] . '/' . basename($orphan_rows[$attach_row['attach_id']]['physical_filename']))) {
continue;
}
$space_taken += $orphan_rows[$attach_row['attach_id']]['filesize'];
$files_added++;
$attach_sql = array('post_msg_id' => $data['post_id'], 'topic_id' => $data['topic_id'], 'is_orphan' => 0, 'poster_id' => $poster_id, 'attach_comment' => $attach_row['attach_comment']);
$sql = 'UPDATE ' . FORUMS_ATTACHMENTS_TABLE . ' SET ' . $_CLASS['core_db']->sql_build_array('UPDATE', $attach_sql) . '
WHERE attach_id = ' . $attach_row['attach_id'] . '
AND is_orphan = 1
AND poster_id = ' . $user->data['user_id'];
$_CLASS['core_db']->query($sql);
}
}
if ($files_updated || $files_added) {
set_config('upload_dir_size', $config['upload_dir_size'] + $space_taken, true);
set_config('num_files', $config['num_files'] + $files_added, true);
}
}
$_CLASS['core_db']->transaction('commit');
if ($post_mode === 'post' || $post_mode === 'reply' || $post_mode === 'edit_last_post') {
if ($topic_type != POST_GLOBAL) {
$update_sql = update_post_information('forum', $data['forum_id'], true);
if (sizeof($update_sql)) {
$sql_data[FORUMS_FORUMS_TABLE]['stat'][] = implode(', ', $update_sql[$data['forum_id']]);
}
}
$update_sql = update_post_information('topic', $data['topic_id'], true);
if (sizeof($update_sql)) {
$sql_data[FORUMS_TOPICS_TABLE]['stat'][] = implode(', ', $update_sql[$data['topic_id']]);
}
}
if ($make_global) {
$update_sql = update_post_information('forum', $data['forum_id'], true);
if (sizeof($update_sql)) {
$sql_data[FORUMS_FORUMS_TABLE]['stat'][] = implode(', ', $update_sql[$data['forum_id']]);
}
}
if ($post_mode === 'edit_topic') {
$update_sql = update_post_information('topic', $data['topic_id'], true);
if (sizeof($update_sql)) {
$sql_data[FORUMS_TOPICS_TABLE]['stat'][] = implode(', ', $update_sql[$data['topic_id']]);
}
}
// Update total post count, do not consider moderated posts/topics
if ($_CLASS['forums_auth']->acl_get('f_noapprove', $data['forum_id']) || $_CLASS['forums_auth']->acl_get('m_approve', $data['forum_id'])) {
if ($post_mode === 'post') {
set_config('num_topics', $config['num_topics'] + 1, true);
set_config('num_posts', $config['num_posts'] + 1, true);
}
if ($post_mode === 'reply') {
set_config('num_posts', $config['num_posts'] + 1, true);
}
}
// Update forum stats
示例10: disapprove_post
/**
* Disapprove Post/Topic
*/
function disapprove_post($post_id_list, $mode)
{
global $_CLASS, $_CORE_CONFIG, $config;
$forum_id = request_var('f', 0);
if (!check_ids($post_id_list, FORUMS_POSTS_TABLE, 'post_id', 'm_approve')) {
trigger_error('NOT_AUTHORIZED');
}
$redirect = request_var('redirect', $_CLASS['core_user']->data['session_page']);
$reason = request_var('reason', '', true);
$reason_id = request_var('reason_id', 0);
$success_msg = $additional_msg = '';
$s_hidden_fields = build_hidden_fields(array('i' => 'queue', 'f' => $forum_id, 'mode' => $mode, 'post_id_list' => $post_id_list, 'mode' => 'disapprove', 'redirect' => $redirect));
$notify_poster = isset($_REQUEST['notify_poster']);
$disapprove_reason = '';
if ($reason_id) {
$sql = 'SELECT reason_title, reason_description
FROM ' . FORUMS_REPORTS_REASONS_TABLE . " \n\t\t\tWHERE reason_id = {$reason_id}";
$result = $_CLASS['core_db']->query($sql);
$row = $_CLASS['core_db']->fetch_row_assoc($result);
$_CLASS['core_db']->free_result($result);
if (!$row || !$reason && $row['reason_name'] === 'other') {
$additional_msg = $_CLASS['core_user']->lang['NO_REASON_DISAPPROVAL'];
unset($_POST['confirm']);
} else {
$disapprove_reason = $row['reason_title'] != 'other' ? isset($_CLASS['core_user']->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]) ? $_CLASS['core_user']->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])] : $row['reason_description'] : '';
$disapprove_reason .= $reason ? "\n\n" . $reason : '';
unset($reason);
}
}
require_once SITE_FILE_ROOT . 'includes/forums/functions_display.php';
$reason = display_reasons($reason_id);
$_CLASS['core_template']->assign_array(array('S_NOTIFY_POSTER' => true, 'S_APPROVE' => false, 'REASON' => $reason, 'ADDITIONAL_MSG' => $additional_msg));
if (display_confirmation($_CLASS['core_user']->get_lang('DISAPPROVE_POST' . (sizeof($post_id_list) == 1 ? '' : 'S')), $s_hidden_fields, 'modules/forums/mcp_approve.html')) {
$post_info = get_post_data($post_id_list, 'm_approve');
// If Topic -> forum_topics_real -= 1
// If Post -> topic_replies_real -= 1
$forum_topics_real = 0;
$topic_replies_real_sql = $post_disapprove_sql = $topic_id_list = array();
foreach ($post_info as $post_id => $post_data) {
$topic_id_list[$post_data['topic_id']] = 1;
// Topic or Post. ;)
if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_last_post_id'] == $post_id) {
if ($post_data['forum_id']) {
$forum_topics_real++;
}
} else {
if (!isset($topic_replies_real_sql[$post_data['topic_id']])) {
$topic_replies_real_sql[$post_data['topic_id']] = 1;
} else {
$topic_replies_real_sql[$post_data['topic_id']]++;
}
}
$post_disapprove_sql[] = $post_id;
}
if ($forum_topics_real) {
$sql = 'UPDATE ' . FORUMS_FORUMS_TABLE . "\n\t\t\t\tSET forum_topics_real = forum_topics_real - {$forum_topics_real}\n\t\t\t\tWHERE forum_id = {$forum_id}";
$_CLASS['core_db']->query($sql);
}
if (!empty($topic_replies_real_sql)) {
foreach ($topic_replies_real_sql as $topic_id => $num_replies) {
$sql = 'UPDATE ' . FORUMS_TOPICS_TABLE . "\n\t\t\t\t\tSET topic_replies_real = topic_replies_real - {$num_replies}\n\t\t\t\t\tWHERE topic_id = {$topic_id}";
$_CLASS['core_db']->query($sql);
}
}
if (sizeof($post_disapprove_sql)) {
if (!function_exists('delete_posts')) {
require_once SITE_FILE_ROOT . 'includes/forums/functions_admin.php';
}
// We do not check for permissions here, because the moderator allowed approval/disapproval should be allowed to delete the disapproved posts
delete_posts('post_id', $post_disapprove_sql);
}
unset($post_disapprove_sql, $topic_replies_real_sql);
update_post_information('topic', array_keys($topic_id_list));
update_post_information('forum', $forum_id);
unset($topic_id_list);
// Notify Poster?
if ($notify_poster) {
require_once SITE_FILE_ROOT . 'includes/mailer.php';
$mailer = new core_mailer();
foreach ($post_info as $post_id => $post_data) {
if ($post_data['poster_id'] == ANONYMOUS) {
continue;
}
$post_data['post_subject'] = censor_text($post_data['post_subject'], true);
$post_data['topic_title'] = censor_text($post_data['topic_title'], true);
if ($post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id']) {
$email_template = 'topic_disapproved.txt';
$subject = 'Topic Disapproved - ' . $post_data['topic_title'];
} else {
$email_template = 'post_disapproved.txt';
$subject = 'Post Disapproved - ' . $post_data['post_subject'];
}
$mailer->to($post_data['user_email'], $post_data['username']);
//$mailer->reply_to($_CORE_CONFIG['email']['site_email']);
$mailer->subject($subject);
//$messenger->im($post_data['user_jabber'], $post_data['username']);
$_CLASS['core_template']->assign_array(array('SITENAME' => $_CORE_CONFIG['global']['site_name'], 'USERNAME' => $post_data['username'], 'REASON' => stripslashes($disapprove_reason), 'POST_SUBJECT' => $post_data['post_subject'], 'TOPIC_TITLE' => $post_data['topic_title']));
//.........这里部分代码省略.........
示例11: bump
/**
* bumps the topic
*
* @param
*/
function bump($user_id = 0)
{
global $db, $user;
$current_time = time();
if ($user_id == 0) {
$user_id = $user->data['user_id'];
}
$db->sql_transaction('begin');
$sql = 'UPDATE ' . POSTS_TABLE . "\n\t\tSET post_time = {$current_time}\n\t\tWHERE post_id = {$this->topic_last_post_id}\n\t\tAND topic_id = {$this->topic_id}";
$db->sql_query($sql);
$this->topic_bumped = 1;
$this->topic_bumper = $user_id;
$this->topic_last_post_time = $current_time;
$sql = 'UPDATE ' . TOPICS_TABLE . "\n\t\tSET topic_last_post_time = {$current_time},\n\t\ttopic_bumped = 1,\n\t\ttopic_bumper = {$user_id}\n\t\tWHERE topic_id = {$topic_id}";
$db->sql_query($sql);
update_post_information('forum', $this->forum_id);
$sql = 'UPDATE ' . USERS_TABLE . "\n\t\tSET user_lastpost_time = {$current_time}\n\t\tWHERE user_id = {$user_id}";
$db->sql_query($sql);
$db->sql_transaction('commit');
markread('post', $this->forum_id, $this->topic_id, $current_time, $user_id);
add_log('mod', $this->forum_id, $this->topic_id, 'LOG_BUMP_TOPIC', $this->topic_title);
}