diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index 144dafbb30..92a455ce26 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -458,7 +458,7 @@ class bbcode $code = str_replace("\t", '   ', $code); $code = str_replace(' ', '  ', $code); $code = str_replace(' ', '  ', $code); - $code = preg_replace('##', '#&(\#[0-9]+;)#'), array('\1', '&\1'), $code); } $code = $this->bbcode_tpl('code_open') . $code . $this->bbcode_tpl('code_close'); diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 067f463325..0507d68c40 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2149,6 +2149,84 @@ if (class_exists('auth')) } } +// Update Post Informations (First/Last Post in topic/forum) +// Should be used instead of sync() if only the last post informations are out of sync... faster +function update_post_information($type, $ids) +{ + global $db; + if (!is_array($ids)) + { + $ids = array($ids); + } + + $update_sql = $empty_forums = array(); + + $sql = 'SELECT ' . $type . '_id, MAX(post_id) as last_post_id + FROM ' . POSTS_TABLE . " + WHERE post_approved = 1 + AND {$type}_id IN (" . implode(', ', $ids) . ") + GROUP BY {$type}_id"; + $result = $db->sql_query($sql); + + $last_post_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + if ($type == 'forum') + { + $empty_forums[] = $row['forum_id']; + } + + $last_post_ids[] = $row['last_post_id']; + } + $db->sql_freeresult($result); + + if ($type == 'forum') + { + $empty_forums = array_diff($ids, $empty_forums); + + foreach ($empty_forums as $void => $forum_id) + { + $update_sql[$forum_id][] = 'forum_last_post_id = 0'; + $update_sql[$forum_id][] = 'forum_last_post_time = 0'; + $update_sql[$forum_id][] = 'forum_last_poster_id = 0'; + $update_sql[$forum_id][] = "forum_last_poster_name = ''"; + } + } + + if (sizeof($last_post_ids)) + { + $sql = 'SELECT p.' . $type . '_id, p.post_id, p.post_time, p.poster_id, p.post_username, u.user_id, u.username + FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u + WHERE p.poster_id = u.user_id + AND p.post_id IN (' . implode(', ', $last_post_ids) . ')'; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $update_sql[$row["{$type}_id"]][] = $type . '_last_post_id = ' . (int) $row['post_id']; + $update_sql[$row["{$type}_id"]][] = $type . '_last_post_time = ' . (int) $row['post_time']; + $update_sql[$row["{$type}_id"]][] = $type . '_last_poster_id = ' . (int) $row['poster_id']; + $update_sql[$row["{$type}_id"]][] = "{$type}_last_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "'"; + } + $db->sql_freeresult($result); + } + unset($empty_forums, $ids, $last_post_ids); + + if (!sizeof($update_sql)) + { + return; + } + + $table = ($type == 'forum') ? FORUMS_TABLE : TOPICS_TABLE; + + foreach ($update_sql as $update_id => $update_sql_ary) + { + $sql = "UPDATE $table + SET " . implode(', ', $update_sql_ary) . " + WHERE {$type}_id = $update_id"; + $db->sql_query($sql); + } +} ?> \ No newline at end of file diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index d793e66586..4ab2a13157 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1013,4 +1013,224 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id return true; } +// User Notification +function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id, $topic_id, $post_id) +{ + global $db, $user, $config, $phpbb_root_path, $phpEx, $auth; + + $topic_notification = ($mode == 'reply' || $mode == 'quote'); + $forum_notification = ($mode == 'post'); + + if (!$topic_notification && !$forum_notification) + { + trigger_error('WRONG_NOTIFICATION_MODE'); + } + + $topic_title = ($topic_notification) ? $topic_title : $subject; + decode_text($topic_title); + $topic_title = censor_text($topic_title); + + // Get banned User ID's + $sql = 'SELECT ban_userid + FROM ' . BANLIST_TABLE; + $result = $db->sql_query($sql); + + $sql_ignore_users = ANONYMOUS . ', ' . $user->data['user_id']; + while ($row = $db->sql_fetchrow($result)) + { + if (isset($row['ban_userid'])) + { + $sql_ignore_users .= ', ' . $row['ban_userid']; + } + } + $db->sql_freeresult($result); + + $notify_rows = array(); + + // -- get forum_userids || topic_userids + $sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber + FROM ' . (($topic_notification) ? TOPICS_WATCH_TABLE : FORUMS_WATCH_TABLE) . ' w, ' . USERS_TABLE . ' u + WHERE w.' . (($topic_notification) ? 'topic_id' : 'forum_id') . ' = ' . (($topic_notification) ? $topic_id : $forum_id) . " + AND w.user_id NOT IN ($sql_ignore_users) + AND w.notify_status = 0 + AND u.user_id = w.user_id"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $notify_rows[$row['user_id']] = array( + 'user_id' => $row['user_id'], + 'username' => $row['username'], + 'user_email' => $row['user_email'], + 'user_jabber' => $row['user_jabber'], + 'user_lang' => $row['user_lang'], + 'notify_type' => ($topic_notification) ? 'topic' : 'forum', + 'template' => ($topic_notification) ? 'topic_notify' : 'newtopic_notify', + 'method' => $row['user_notify_type'], + 'allowed' => false + ); + } + $db->sql_freeresult($result); + + // forum notification is sent to those not receiving post notification + if ($topic_notification) + { + if (sizeof($notify_rows)) + { + $sql_ignore_users .= ', ' . implode(', ', array_keys($notify_rows)); + } + + $sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber + FROM ' . FORUMS_WATCH_TABLE . ' fw, ' . USERS_TABLE . " u + WHERE fw.forum_id = $forum_id + AND fw.user_id NOT IN ($sql_ignore_users) + AND fw.notify_status = 0 + AND u.user_id = fw.user_id"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $notify_rows[$row['user_id']] = array( + 'user_id' => $row['user_id'], + 'username' => $row['username'], + 'user_email' => $row['user_email'], + 'user_jabber' => $row['user_jabber'], + 'user_lang' => $row['user_lang'], + 'notify_type' => 'forum', + 'template' => 'forum_notify', + 'method' => $row['user_notify_type'], + 'allowed' => false + ); + } + $db->sql_freeresult($result); + } + + if (!sizeof($notify_rows)) + { + return; + } + + foreach ($auth->acl_get_list(array_keys($notify_rows), 'f_read', $forum_id) as $forum_id => $forum_ary) + { + foreach ($forum_ary as $auth_option => $user_ary) + { + foreach ($user_ary as $user_id) + { + $notify_rows[$user_id]['allowed'] = true; + } + } + } + + + // Now, we have to do a little step before really sending, we need to distinguish our users a little bit. ;) + $msg_users = $delete_ids = $update_notification = array(); + foreach ($notify_rows as $user_id => $row) + { + if (!$row['allowed'] || !trim($row['user_email'])) + { + $delete_ids[$row['notify_type']][] = $row['user_id']; + } + else + { + $msg_users[] = $row; + $update_notification[$row['notify_type']][] = $row['user_id']; + } + } + unset($notify_rows); + + // Now, we are able to really send out notifications + if (sizeof($msg_users)) + { + include_once($phpbb_root_path . 'includes/functions_messenger.'.$phpEx); + $messenger = new messenger(); + + $email_sig = str_replace('
', "\n", "-- \n" . $config['board_email_sig']); + + $msg_list_ary = array(); + foreach ($msg_users as $row) + { + $pos = sizeof($msg_list_ary[$row['template']]); + + $msg_list_ary[$row['template']][$pos]['method'] = $row['method']; + $msg_list_ary[$row['template']][$pos]['email'] = $row['user_email']; + $msg_list_ary[$row['template']][$pos]['jabber'] = $row['user_jabber']; + $msg_list_ary[$row['template']][$pos]['name'] = $row['username']; + $msg_list_ary[$row['template']][$pos]['lang'] = $row['user_lang']; + } + unset($msg_users); + + foreach ($msg_list_ary as $email_template => $email_list) + { + foreach ($email_list as $addr) + { + $messenger->template($email_template, $addr['lang']); + + $messenger->replyto($config['board_email']); + $messenger->to($addr['email'], $addr['name']); + $messenger->im($addr['jabber'], $addr['name']); + + $messenger->assign_vars(array( + 'EMAIL_SIG' => $email_sig, + 'SITENAME' => $config['sitename'], + 'USERNAME' => $addr['name'], + 'TOPIC_TITLE' => $topic_title, + 'FORUM_NAME' => $forum_name, + + 'U_FORUM' => generate_board_url() . "/viewforum.$phpEx?f=$forum_id&e=0", + 'U_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t=$topic_id&e=0", + 'U_NEWEST_POST' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t=$topic_id&p=$post_id&e=$post_id", + 'U_STOP_WATCHING_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t=$topic_id&unwatch=topic", + 'U_STOP_WATCHING_FORUM' => generate_board_url() . "/viewforum.$phpEx?f=$forum_id&unwatch=forum", + )); + + $messenger->send($addr['method']); + $messenger->reset(); + } + } + unset($msg_list_ary); + + if ($messenger->queue) + { + $messenger->queue->save(); + } + } + + // Handle the DB updates + $db->sql_transaction(); + + if (sizeof($update_notification['topic'])) + { + $db->sql_query('UPDATE ' . TOPICS_WATCH_TABLE . " + SET notify_status = 1 + WHERE topic_id = $topic_id + AND user_id IN (" . implode(', ', $update_notification['topic']) . ")"); + } + + if (sizeof($update_notification['forum'])) + { + $db->sql_query('UPDATE ' . FORUMS_WATCH_TABLE . " + SET notify_status = 1 + WHERE forum_id = $forum_id + AND user_id IN (" . implode(', ', $update_notification['forum']) . ")"); + } + + // Now delete the user_ids not authorized to receive notifications on this topic/forum + if (sizeof($delete_ids['topic'])) + { + $db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . " + WHERE topic_id = $topic_id + AND user_id IN (" . implode(', ', $delete_ids['topic']) . ")"); + } + + if (sizeof($delete_ids['forum'])) + { + $db->sql_query('DELETE FROM ' . FORUMS_WATCH_TABLE . " + WHERE forum_id = $forum_id + AND user_id IN (" . implode(', ', $delete_ids['forum']) . ")"); + } + + $db->sql_transaction('commit'); + +} + ?> \ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index 07f80a87f0..7de44547e3 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -176,11 +176,11 @@ function mcp_forum_view($id, $mode, $action, $url, $forum_info) $topic_title = censor_text($row['topic_title']); $template->assign_block_vars('topicrow', array( - 'U_VIEW_TOPIC' => "mcp.$phpEx$SID&t=" . $row['topic_id'] . '&mode=topic_view', + 'U_VIEW_TOPIC' => "mcp.$phpEx$SID&f=$forum_id&t={$row['topic_id']}&mode=topic_view", 'S_SELECT_TOPIC' => ($action == 'merge_select' && $row['topic_id'] != $topic_id) ? true : false, 'U_SELECT_TOPIC' => $url . '&mode=topic_view&action=merge&to_topic_id=' . $row['topic_id'] . $selected_ids, - 'U_MCP_QUEUE' => $url . '&i=queue&mode=approve&t=' . $row['topic_id'], + 'U_MCP_QUEUE' => $url . '&i=queue&mode=approve_details&t=' . $row['topic_id'], 'U_MCP_REPORT' => "mcp.$phpEx$SID&i=main&mode=topic_view&t={$row['topic_id']}&action=reports", 'ATTACH_ICON_IMG' => ($auth->acl_gets('f_download', 'u_download', $row['forum_id']) && $row['topic_attachment']) ? $user->img('icon_attach', sprintf($user->lang['TOTAL_ATTACHMENTS'], $row['topic_attachment'])) : '', diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index c593e6ae90..b8d6c12b27 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -62,22 +62,19 @@ function mcp_front_view($id, $mode, $action, $url) while ($row = $db->sql_fetchrow($result)) { - if ($row['poster_id'] == ANONYMOUS) - { - $author = ($row['post_username']) ? $row['post_username'] : $user->lang['GUEST']; - } - else - { - $author = '' . $row['username'] . ''; - } - $template->assign_block_vars('unapproved', array( - 'U_POST_DETAILS' => $url . '&mode=post_details', - 'FORUM' => (!empty($row['forum_id'])) ? '' . $row['forum_name'] . '' : $user->lang['POST_GLOBAL'], - 'TOPIC' => '' . $row['topic_title'] . '', - 'AUTHOR' => $author, - 'SUBJECT' => '' . (($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT']) . '', - 'POST_TIME' => $user->format_date($row['post_time'])) + 'U_POST_DETAILS'=> $url . '&p=' . $row['post_id'] . '&mode=post_details', + 'U_MCP_FORUM' => ($row['forum_id']) ? $url . '&f=' . $row['forum_id'] . '&mode=forum_view' : '', + 'U_MCP_TOPIC' => $url . '&t=' . $row['topic_id'] . '&mode=topic_view', + 'U_FORUM' => ($row['forum_id']) ? 'viewforum.' . $phpEx . $SID . '&f=' . $row['forum_id'] : '', + 'U_TOPIC' => 'viewtopic.' . $phpEx . $SID . '&f=' . $row['forum_id'] . '&t=' . $row['topic_id'], + 'U_AUTHOR' => ($row['poster_id'] == ANONYMOUS) ? '' : 'memberlist.' . $phpEx . $SID . '&mode=viewprofile&u=' . $row['poster_id'], + + 'FORUM_NAME' => ($row['forum_id']) ? $row['forum_name'] : $user->lang['POST_GLOBAL'], + 'TOPIC_TITLE' => $row['topic_title'], + 'AUTHOR' => ($row['poster_id'] == ANONYMOUS) ? (($row['post_username']) ? $row['post_username'] : $user->lang['GUEST']) : $row['username'], + 'SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'], + 'POST_TIME' => $user->format_date($row['post_time'])) ); } } @@ -128,12 +125,18 @@ function mcp_front_view($id, $mode, $action, $url) while ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('report', array( - 'U_POST_DETAILS' => $url . '&mode=post_details', - 'FORUM' => (!empty($row['forum_id'])) ? '' . $row['forum_name'] . '' : $user->lang['POST_GLOBAL'], - 'TOPIC' => '' . $row['topic_title'] . '', - 'REPORTER' => ($row['user_id'] == ANONYMOUS) ? $user->lang['GUEST'] : '' . $row['username'] . '', - 'SUBJECT' => '' . (($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT']) . '', - 'REPORT_TIME' => $user->format_date($row['report_time'])) + 'U_POST_DETAILS'=> $url . '&p=' . $row['post_id'] . '&mode=post_details', + 'U_MCP_FORUM' => ($row['forum_id']) ? $url . '&f=' . $row['forum_id'] . '&mode=forum_view' : '', + 'U_MCP_TOPIC' => $url . '&t=' . $row['topic_id'] . '&mode=topic_view', + 'U_FORUM' => ($row['forum_id']) ? 'viewforum.' . $phpEx . $SID . '&f=' . $row['forum_id'] : '', + 'U_TOPIC' => 'viewtopic.' . $phpEx . $SID . '&f=' . $row['forum_id'] . '&t=' . $row['topic_id'], + 'U_REPORTER' => ($row['user_id'] == ANONYMOUS) ? '' : 'memberlist.' . $phpEx . $SID . '&mode=viewprofile&u=' . $row['user_id'], + + 'FORUM_NAME' => ($row['forum_id']) ? $row['forum_name'] : $user->lang['POST_GLOBAL'], + 'TOPIC_TITLE' => $row['topic_title'], + 'REPORTER' => ($row['user_id'] == ANONYMOUS) ? $user->lang['GUEST'] : $row['username'], + 'SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'], + 'REPORT_TIME' => $user->format_date($row['report_time'])) ); } } diff --git a/phpBB/includes/mcp/mcp_post.php b/phpBB/includes/mcp/mcp_post.php index 00a1abd96d..68cceebc66 100644 --- a/phpBB/includes/mcp/mcp_post.php +++ b/phpBB/includes/mcp/mcp_post.php @@ -143,18 +143,21 @@ function mcp_post_details($id, $mode, $action, $url) 'U_VIEW_PROFILE' => "memberlist.$phpEx$SID&mode=viewprofile&u=" . $post_info['user_id'], 'U_MCP_USERNOTES' => "mcp.$phpEx$SID&i=notes&mode=user_notes&u=" . $post_info['user_id'], 'U_MCP_WARNINGS' => "mcp.$phpEx$SID&i=warnings&mode=view_user&u=" . $post_info['user_id'], + 'U_EDIT' => ($auth->acl_get('m_edit', $post_info['forum_id'])) ? "{$phpbb_root_path}posting.$phpEx$SID&mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}" : '', 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], "", ''), 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], "", ''), 'REPORTED_IMG' => $user->img('icon_reported', $user->lang['POST_REPORTED']), 'UNAPPROVED_IMG' => $user->img('icon_unapproved', $user->lang['POST_UNAPPROVED']), + 'EDIT_IMG' => $user->img('btn_edit', $user->lang['EDIT_POST']), 'POSTER_NAME' => $poster, 'POST_PREVIEW' => $message, 'POST_SUBJECT' => $post_info['post_subject'], 'POST_DATE' => $user->format_date($post_info['post_time']), 'POST_IP' => $post_info['poster_ip'], - 'POST_IPADDR' => @gethostbyaddr($post_info['poster_ip'])) + 'POST_IPADDR' => @gethostbyaddr($post_info['poster_ip']), + 'POST_ID' => $post_info['post_id']) ); // Get Reports diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 0106f8c6e2..171751219f 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -26,6 +26,24 @@ class mcp_queue extends module { case 'approve': case 'disapprove': + include_once($phpbb_root_path . 'includes/functions_messenger.'.$phpEx); + include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); + + $post_id_list = get_array('post_id_list', 0); + + if (!$post_id_list) + { + trigger_error('NO_POST_SELECTED'); + } + + if ($mode == 'approve') + { + approve_post($post_id_list); + } + else + { + disapprove_post($post_id_list); + } break; @@ -35,6 +53,14 @@ class mcp_queue extends module include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); $post_id = request_var('p', 0); + $topic_id = request_var('t', 0); + + if ($topic_id) + { + $topic_info = get_topic_data(array($topic_id), 'm_approve'); + $post_id = (int) $topic_info[$topic_id]['topic_first_post_id']; + } + $post_info = get_post_data(array($post_id), 'm_approve'); if (!sizeof($post_info)) @@ -66,6 +92,7 @@ class mcp_queue extends module $message = smilie_text($message); $template->assign_vars(array( + 'S_MCP_QUEUE' => true, 'S_APPROVE_ACTION' => "mcp.$phpEx$SID&i=queue&p=$post_id&f=$forum_id", 'S_CAN_VIEWIP' => $auth->acl_get('m_ip', $post_info['forum_id']), @@ -78,19 +105,22 @@ class mcp_queue extends module 'U_VIEW_PROFILE' => "memberlist.$phpEx$SID&mode=viewprofile&u=" . $post_info['user_id'], 'U_MCP_USERNOTES' => "mcp.$phpEx$SID&i=notes&mode=user_notes&u=" . $post_info['user_id'], 'U_MCP_WARNINGS' => "mcp.$phpEx$SID&i=warnings&mode=view_user&u=" . $post_info['user_id'], + 'U_EDIT' => ($auth->acl_get('m_edit', $post_info['forum_id'])) ? "{$phpbb_root_path}posting.$phpEx$SID&mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}" : '', 'REPORTED_IMG' => $user->img('icon_reported', $user->lang['POST_REPORTED']), 'UNAPPROVED_IMG' => $user->img('icon_unapproved', $user->lang['POST_UNAPPROVED']), + 'EDIT_IMG' => $user->img('btn_edit', $user->lang['EDIT_POST']), 'POSTER_NAME' => $poster, 'POST_PREVIEW' => $message, 'POST_SUBJECT' => $post_info['post_subject'], 'POST_DATE' => $user->format_date($post_info['post_time']), 'POST_IP' => $post_info['poster_ip'], - 'POST_IPADDR' => @gethostbyaddr($post_info['poster_ip'])) + 'POST_IPADDR' => @gethostbyaddr($post_info['poster_ip']), + 'POST_ID' => $post_info['post_id']) ); - $this->display($user->lang['MCP_QUEUE'], 'mcp_approve.html'); + $this->display($user->lang['MCP_QUEUE'], 'mcp_post.html'); break; @@ -221,7 +251,7 @@ class mcp_queue extends module $poster = $row['username']; } - $s_checkbox = ($mode == 'unapproved_posts') ? '' : ''; + $s_checkbox = ''; $template->assign_block_vars('postrow', array( 'U_VIEWFORUM' => "viewforum.$phpEx$SID&f=" . $row['forum_id'], @@ -272,4 +302,441 @@ class mcp_queue extends module } } +// Approve Post/Topic +function approve_post($post_id_list) +{ + global $db, $template, $user, $config; + global $_REQUEST, $phpEx, $phpbb_root_path, $SID; + + if (!($forum_id = check_ids($post_id_list, POSTS_TABLE, 'post_id', 'm_approve'))) + { + trigger_error('NOT_AUTHORIZED'); + } + + $redirect = request_var('redirect', $user->data['session_page']); + $success_msg = ''; + + $s_hidden_fields = build_hidden_fields(array( + 'post_id_list' => $post_id_list, + 'f' => $forum_id, + 'mode' => 'approve', + 'redirect' => $redirect) + ); + + if (confirm_box(true)) + { + $notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false; + + $post_info = get_post_data($post_id_list, 'm_approve'); + + // If Topic -> total_topics = total_topics+1, total_posts = total_posts+1, forum_topics = forum_topics+1, forum_posts = forum_posts+1 + // If Post -> total_posts = total_posts+1, forum_posts = forum_posts+1, topic_replies = topic_replies+1 + + $total_topics = $total_posts = $forum_topics = $forum_posts = 0; + $topic_approve_sql = $topic_replies_sql = $post_approve_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']) + { + $total_topics++; + $forum_topics++; + } + + $topic_approve_sql[] = $post_data['topic_id']; + } + else + { + if (!isset($topic_replies_sql[$post_data['topic_id']])) + { + $topic_replies_sql[$post_data['topic_id']] = 1; + } + else + { + $topic_replies_sql[$post_data['topic_id']]++; + } + } + + if ($post_data['forum_id']) + { + $total_posts++; + $forum_posts++; + } + + $post_approve_sql[] = $post_id; + } + + if (sizeof($topic_approve_sql)) + { + $sql = 'UPDATE ' . TOPICS_TABLE . ' + SET topic_approved = 1 + WHERE topic_id IN (' . implode(', ', $topic_approve_sql) . ')'; + $db->sql_query($sql); + } + + if (sizeof($post_approve_sql)) + { + $sql = 'UPDATE ' . POSTS_TABLE . ' + SET post_approved = 1 + WHERE post_id IN (' . implode(', ', $post_approve_sql) . ')'; + $db->sql_query($sql); + } + + if (sizeof($topic_replies_sql)) + { + foreach ($topic_replies_sql as $topic_id => $num_replies) + { + $sql = 'UPDATE ' . TOPICS_TABLE . " + SET topic_replies = topic_replies + $num_replies + WHERE topic_id = $topic_id"; + $db->sql_query($sql); + } + } + + if ($forum_topics || $forum_posts) + { + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET '; + $sql .= ($forum_topics) ? "forum_topics = forum_topics + $forum_topics" : ''; + $sql .= ($forum_topics && $forum_posts) ? ', ' : ''; + $sql .= ($forum_posts) ? "forum_posts = forum_posts + $forum_posts" : ''; + $sql .= " WHERE forum_id = $forum_id"; + + $db->sql_query($sql); + } + + if ($total_topics) + { + set_config('num_topics', $config['num_topics'] + $total_topics, true); + } + + if ($total_posts) + { + set_config('num_posts', $config['num_posts'] + $total_posts, true); + } + unset($topic_approve_sql, $topic_replies_sql, $post_approve_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('
', "\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_approved' : 'post_approved'; + + $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' => $post_data['username'], + 'POST_SUBJECT' => censor_text($post_data['post_subject']), + 'TOPIC_TITLE' => censor_text($post_data['topic_title']), + + 'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t={$post_data['topic_id']}&e=0", + 'U_VIEW_POST' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t={$post_data['topic_id']}&p=$post_id&e=$post_id") + ); + + $messenger->send($post_data['user_notify_type']); + $messenger->reset(); + + if ($messenger->queue) + { + $messenger->queue->save(); + } + } + } + + // Send out normal user notifications + $email_sig = str_replace('
', "\n", "-- \n" . $config['board_email_sig']); + + foreach ($post_info as $post_id => $post_data) + { + if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id']) + { + // Forum Notifications + user_notification('post', $post_data['topic_title'], $post_data['topic_title'], $post_data['forum_name'], $forum_id, $post_data['topic_id'], $post_id); + } + else + { + // Topic Notifications + user_notification('reply', $post_data['post_subject'], $post_data['topic_title'], $post_data['forum_name'], $forum_id, $post_data['topic_id'], $post_id); + } + } + unset($post_info); + + if ($forum_topics) + { + $success_msg = ($forum_topics == 1) ? 'TOPIC_APPROVED_SUCCESS' : 'TOPICS_APPROVED_SUCCESS'; + } + else + { + $success_msg = (sizeof($post_id_list) == 1) ? 'POST_APPROVED_SUCCESS' : 'POSTS_APPROVED_SUCCESS'; + } + } + else + { + $template->assign_vars(array( + 'S_NOTIFY_POSTER' => true, + 'S_APPROVE' => true) + ); + + confirm_box(false, 'APPROVE_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); + } + + $redirect = request_var('redirect', "index.$phpEx$SID"); + + if (strpos($redirect, '?') === false) + { + $redirect = substr_replace($redirect, ".$phpEx$SID&", strpos($redirect, '&'), 1); + } + + if (!$success_msg) + { + redirect($redirect); + } + else + { + meta_refresh(3, $redirect); + trigger_error($user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], '', '') . '

' . sprintf($user->lang['RETURN_FORUM'], '', '')); + } +} + +// Disapprove Post/Topic +function disapprove_post($post_id_list) +{ + global $db, $template, $user, $config; + global $_REQUEST, $_POST, $phpEx, $phpbb_root_path, $SID; + + if (!($forum_id = check_ids($post_id_list, POSTS_TABLE, 'post_id', 'm_approve'))) + { + trigger_error('NOT_AUTHORIZED'); + } + + $redirect = request_var('redirect', $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 . " + WHERE reason_id = $reason_id"; + $result = $db->sql_query($sql); + + if (!($row = $db->sql_fetchrow($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') ? $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_name'])] : ''; + $disapprove_reason .= ($reason) ? "\n\n" . $_REQUEST['reason'] : ''; + unset($reason); + } + $db->sql_freeresult($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 . " + SET forum_topics_real = forum_topics_real - $forum_topics_real + WHERE 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 . " + SET topic_replies_real = topic_replies_real - $num_replies + WHERE topic_id = $topic_id"; + $db->sql_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('
', "\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' => $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(); + + if ($messenger->queue) + { + $messenger->queue->save(); + } + } + } + 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 = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $row['reason_name'] = strtoupper($row['reason_name']); + + $reason_title = (!empty($user->lang['report_reasons']['TITLE'][$row['reason_name']])) ? $user->lang['report_reasons']['TITLE'][$row['reason_name']] : ucwords(str_replace('_', ' ', $row['reason_name'])); + + $reason_desc = (!empty($user->lang['report_reasons']['DESCRIPTION'][$row['reason_name']])) ? $user->lang['report_reasons']['DESCRIPTION'][$row['reason_name']] : $row['reason_desc']; + + $template->assign_block_vars('reason', array( + 'ID' => $row['reason_id'], + 'NAME' => htmlspecialchars($reason_title), + 'DESCRIPTION' => htmlspecialchars($reason_desc), + 'S_SELECTED' => ($row['reason_id'] == $reason_id) ? true : false) + ); + } + $db->sql_freeresult($result); + + $template->assign_vars(array( + 'S_NOTIFY_POSTER' => true, + 'S_APPROVE' => false, + 'REASON' => $reason, + 'ADDITIONAL_MSG' => $additional_msg) + ); + + confirm_box(false, 'APPROVE_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html'); + } + + $redirect = request_var('redirect', "index.$phpEx$SID"); + + if (strpos($redirect, '?') === false) + { + $redirect = substr_replace($redirect, ".$phpEx$SID&", strpos($redirect, '&'), 1); + } + + if (!$success_msg) + { + redirect($redirect); + } + else + { + meta_refresh(3, "viewforum.$phpEx$SID&f=$forum_id"); + trigger_error($user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_FORUM'], '', '')); + } +} + ?> \ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index 7d1cb201e4..2004e51874 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -144,7 +144,7 @@ function mcp_topic_view($id, $mode, $action, $url) 'S_POST_UNAPPROVED' => ($row['post_approved']) ? false : true, 'U_POST_DETAILS' => "$url&p={$row['post_id']}&mode=post_details", - 'U_MCP_APPROVE' => "mcp.$phpEx$SID&i=queue&mode=approve&p=" . $row['post_id']) + 'U_MCP_APPROVE' => "mcp.$phpEx$SID&i=queue&mode=approve&post_id_list[]=" . $row['post_id']) ); unset($rowset[$i]); diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 5d5519a7c9..cda58dc804 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -212,6 +212,7 @@ $lang += array( 'MESSAGE' => 'Message', 'MESSAGE_BODY' => 'Message body', 'MINUTES' => 'Minutes', + 'MODERATE' => 'Moderate', 'MODERATOR' => 'Moderator', 'MODERATORS' => 'Moderators', 'MONTH' => 'Month', diff --git a/phpBB/language/en/email/post_approved.txt b/phpBB/language/en/email/post_approved.txt new file mode 100644 index 0000000000..3d7c4902c5 --- /dev/null +++ b/phpBB/language/en/email/post_approved.txt @@ -0,0 +1,15 @@ +Subject: Post Approved - {POST_SUBJECT} +Charset: iso-8859-1 + +Hello {USERNAME}, + +You are receiving this email because your post "{POST_SUBJECT}" at {SITENAME} was approved by a moderator or admin. + +If you want to view the post click the following link: +{U_VIEW_POST} + +If you want to view the topic, click the following link: +{U_VIEW_TOPIC} + + +{EMAIL_SIG} \ No newline at end of file diff --git a/phpBB/language/en/email/post_disapproved.txt b/phpBB/language/en/email/post_disapproved.txt new file mode 100644 index 0000000000..c6055cb28e --- /dev/null +++ b/phpBB/language/en/email/post_disapproved.txt @@ -0,0 +1,13 @@ +Subject: Post Disapproved - {POST_SUBJECT} +Charset: iso-8859-1 + +Hello {USERNAME}, + +You are receiving this email because your post "{POST_SUBJECT}" at {SITENAME} was disapproved by a moderator or admin. + +The following reason was given for the disapproval: + +{REASON} + + +{EMAIL_SIG} \ No newline at end of file diff --git a/phpBB/language/en/email/topic_approved.txt b/phpBB/language/en/email/topic_approved.txt new file mode 100644 index 0000000000..28927b5a29 --- /dev/null +++ b/phpBB/language/en/email/topic_approved.txt @@ -0,0 +1,12 @@ +Subject: Topic Approved - {TOPIC_TITLE} +Charset: iso-8859-1 + +Hello {USERNAME}, + +You are receiving this email because your topic "{TOPIC_TITLE}" at {SITENAME} was approved by a moderator or admin. + +If you want to view the topic, click the following link: +{U_VIEW_TOPIC} + + +{EMAIL_SIG} \ No newline at end of file diff --git a/phpBB/language/en/email/topic_disapproved.txt b/phpBB/language/en/email/topic_disapproved.txt new file mode 100644 index 0000000000..52c1578861 --- /dev/null +++ b/phpBB/language/en/email/topic_disapproved.txt @@ -0,0 +1,13 @@ +Subject: Topic Disapproved - {TOPIC_TITLE} +Charset: iso-8859-1 + +Hello {USERNAME}, + +You are receiving this email because your topic "{TOPIC_TITLE}" at {SITENAME} was disapproved by a moderator or admin. + +The following reason was given for the disapproval: + +{REASON} + + +{EMAIL_SIG} \ No newline at end of file diff --git a/phpBB/language/en/mcp.php b/phpBB/language/en/mcp.php index 16e35a9cc8..49deed20c3 100644 --- a/phpBB/language/en/mcp.php +++ b/phpBB/language/en/mcp.php @@ -32,7 +32,10 @@ $lang += array( 'ALL_ENTRIES' => 'All entries', 'ALREADY_REPORTED' => 'This post has already been reported', 'APPROVE' => 'Approve', + 'APPROVE_POST' => 'Approve Post', + 'APPROVE_POST_CONFIRM' => 'Are you sure you want to approve this post?', 'APPROVE_POSTS' => 'Approve Posts', + 'APPROVE_POSTS_CONFIRM' => 'Are you sure you want to approve the selected posts?', 'CANNOT_MOVE_SAME_FORUM'=> 'You cannot move a topic to the forum it\'s already in', 'CAN_LEAVE_BLANK' => 'This can be left blank.', @@ -138,6 +141,8 @@ $lang += array( 'MOVE_TOPICS' => 'Move selected topics', 'MOVE_TOPICS_CONFIRM' => 'Are you sure you want to move the selected topics into a new forum?', + 'NOTIFY_POSTER_APPROVAL'=> 'Notify poster about approval?', + 'NOTIFY_POSTER_DISAPPROVAL' => 'Notify poster about disapproval?', 'NOT_MODERATOR' => 'You are not a moderator of this forum', 'NO_DESTINATION_FORUM' => 'Please select a forum for destination', 'NO_ENTRIES' => 'No log entries for this period', diff --git a/phpBB/mcp.php b/phpBB/mcp.php index c5e975d9ae..5a066de76f 100644 --- a/phpBB/mcp.php +++ b/phpBB/mcp.php @@ -245,14 +245,22 @@ class module // Add Item to Submodule Title function add_menu_item($module_name, $mode) { - global $db, $user; + global $db, $user, $auth; if ($module_name != 'queue') { return ''; } - $forum_list = get_forum_list('m_approve'); + $forum_id = request_var('f', 0); + if ($forum_id && $auth->acl_get('m_approve', $forum_id)) + { + $forum_list = array($forum_id); + } + else + { + $forum_list = get_forum_list('m_approve'); + } switch ($mode) { @@ -327,6 +335,11 @@ $mode = request_var('mode', ''); $mode2 = (isset($_REQUEST['quick'])) ? request_var('mode2', '') : ''; $module = request_var('i', ''); +if (is_array($mode)) +{ + list($mode, ) = each($mode); +} + if ($mode2) { $mode = $mode2; diff --git a/phpBB/posting.php b/phpBB/posting.php index a9de09ddbe..8368584767 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -415,6 +415,7 @@ if ($save && $user->data['user_id'] != ANONYMOUS && $auth->acl_get('u_savedrafts $subject = (!$subject && $mode != 'post') ? $topic_title : $subject; $message = (isset($_POST['message'])) ? htmlspecialchars(trim(str_replace(array('\\\'', '\\"', '\\0', '\\\\'), array('\'', '"', '\0', '\\'), $_POST['message']))) : ''; $message = preg_replace('#&(\#[0-9]+;)#', '&\1', $message); +// $message = request_var('message', '', true, true); if ($subject && $message) { @@ -473,17 +474,19 @@ if ($load && $drafts) if ($submit || $preview || $refresh) { $topic_cur_post_id = request_var('topic_cur_post_id', 0); + $subject = request_var('subject', ''); +// $subject = request_var('subject', '', false, true); if (strcmp($subject, strtoupper($subject)) == 0 && $subject) { $subject = phpbb_strtolower($subject); } - $subject = preg_replace('#&(\#[0-9]+;)#', '&\1', $subject); - $message_parser->message = (isset($_POST['message'])) ? htmlspecialchars(str_replace(array('\\\'', '\\"', '\\0', '\\\\'), array('\'', '"', '\0', '\\'), $_POST['message'])) : ''; $message_parser->message = preg_replace('#&(\#[0-9]+;)#', '&\1', $message_parser->message); +// $message_parser->message = request_var('message', '', true, true); + $username = (isset($_POST['username'])) ? request_var('username', '') : $username; $post_edit_reason = (isset($_POST['edit_reason']) && !empty($_POST['edit_reason']) && $mode == 'edit' && $user->data['user_id'] != $poster_id) ? request_var('edit_reason', '') : ''; @@ -790,7 +793,7 @@ if (!sizeof($error) && $preview) format_display($preview_message, $preview_signature, $message_parser->bbcode_uid, $preview_signature_uid, $enable_html, $enable_bbcode, $enable_urls, $enable_smilies, $enable_sig); // Poll Preview - if (($mode == 'post' || ($mode == 'edit' && $post_id == $topic_first_post_id && !$poll_last_vote)) && ($auth->acl_get('f_poll', $forum_id) || $auth->acl_get('m_edit', $forum_id))) + if (($mode == 'post' || ($mode == 'edit' && $post_id == $topic_first_post_id && !$poll_last_vote)) && ($auth->acl_get('f_poll', $forum_id) || $auth->acl_get('m_edit', $forum_id)) && $poll_title) { decode_text($poll_title, $message_parser->bbcode_uid); $preview_poll_title = format_display($poll_title, $null, $message_parser->bbcode_uid, false, $enable_html, $enable_bbcode, $enable_urls, $enable_smilies, false, false); @@ -1050,227 +1053,6 @@ page_footer(); // FUNCTIONS // - -// User Notification -function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id, $topic_id, $post_id) -{ - global $db, $user, $config, $phpbb_root_path, $phpEx, $auth; - - $topic_notification = ($mode == 'reply' || $mode == 'quote'); - $forum_notification = ($mode == 'post'); - - if (!$topic_notification && !$forum_notification) - { - trigger_error('WRONG_NOTIFICATION_MODE'); - } - - $topic_title = ($topic_notification) ? $topic_title : $subject; - decode_text($topic_title); - $topic_title = censor_text($topic_title); - - // Get banned User ID's - $sql = 'SELECT ban_userid - FROM ' . BANLIST_TABLE; - $result = $db->sql_query($sql); - - $sql_ignore_users = ANONYMOUS . ', ' . $user->data['user_id']; - while ($row = $db->sql_fetchrow($result)) - { - if (isset($row['ban_userid'])) - { - $sql_ignore_users .= ', ' . $row['ban_userid']; - } - } - $db->sql_freeresult($result); - - $notify_rows = array(); - - // -- get forum_userids || topic_userids - $sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber - FROM ' . (($topic_notification) ? TOPICS_WATCH_TABLE : FORUMS_WATCH_TABLE) . ' w, ' . USERS_TABLE . ' u - WHERE w.' . (($topic_notification) ? 'topic_id' : 'forum_id') . ' = ' . (($topic_notification) ? $topic_id : $forum_id) . " - AND w.user_id NOT IN ($sql_ignore_users) - AND w.notify_status = 0 - AND u.user_id = w.user_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $notify_rows[$row['user_id']] = array( - 'user_id' => $row['user_id'], - 'username' => $row['username'], - 'user_email' => $row['user_email'], - 'user_jabber' => $row['user_jabber'], - 'user_lang' => $row['user_lang'], - 'notify_type' => ($topic_notification) ? 'topic' : 'forum', - 'template' => ($topic_notification) ? 'topic_notify' : 'newtopic_notify', - 'method' => $row['user_notify_type'], - 'allowed' => false - ); - } - $db->sql_freeresult($result); - - // forum notification is sent to those not receiving post notification - if ($topic_notification) - { - if (sizeof($notify_rows)) - { - $sql_ignore_users .= ', ' . implode(', ', array_keys($notify_rows)); - } - - $sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber - FROM ' . FORUMS_WATCH_TABLE . ' fw, ' . USERS_TABLE . " u - WHERE fw.forum_id = $forum_id - AND fw.user_id NOT IN ($sql_ignore_users) - AND fw.notify_status = 0 - AND u.user_id = fw.user_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $notify_rows[$row['user_id']] = array( - 'user_id' => $row['user_id'], - 'username' => $row['username'], - 'user_email' => $row['user_email'], - 'user_jabber' => $row['user_jabber'], - 'user_lang' => $row['user_lang'], - 'notify_type' => 'forum', - 'template' => 'forum_notify', - 'method' => $row['user_notify_type'], - 'allowed' => false - ); - } - $db->sql_freeresult($result); - } - - if (!sizeof($notify_rows)) - { - return; - } - - foreach ($auth->acl_get_list(array_keys($notify_rows), 'f_read', $forum_id) as $forum_id => $forum_ary) - { - foreach ($forum_ary as $auth_option => $user_ary) - { - foreach ($user_ary as $user_id) - { - $notify_rows[$user_id]['allowed'] = true; - } - } - } - - - // Now, we have to do a little step before really sending, we need to distinguish our users a little bit. ;) - $msg_users = $delete_ids = $update_notification = array(); - foreach ($notify_rows as $user_id => $row) - { - if (!$row['allowed'] || !trim($row['user_email'])) - { - $delete_ids[$row['notify_type']][] = $row['user_id']; - } - else - { - $msg_users[] = $row; - $update_notification[$row['notify_type']][] = $row['user_id']; - } - } - unset($notify_rows); - - // Now, we are able to really send out notifications - if (sizeof($msg_users)) - { - include_once($phpbb_root_path . 'includes/functions_messenger.'.$phpEx); - $messenger = new messenger(); - - $email_sig = str_replace('
', "\n", "-- \n" . $config['board_email_sig']); - - $msg_list_ary = array(); - foreach ($msg_users as $row) - { - $pos = sizeof($msg_list_ary[$row['template']]); - - $msg_list_ary[$row['template']][$pos]['method'] = $row['method']; - $msg_list_ary[$row['template']][$pos]['email'] = $row['user_email']; - $msg_list_ary[$row['template']][$pos]['jabber'] = $row['user_jabber']; - $msg_list_ary[$row['template']][$pos]['name'] = $row['username']; - $msg_list_ary[$row['template']][$pos]['lang'] = $row['user_lang']; - } - unset($msg_users); - - foreach ($msg_list_ary as $email_template => $email_list) - { - foreach ($email_list as $addr) - { - $messenger->template($email_template, $addr['lang']); - - $messenger->replyto($config['board_email']); - $messenger->to($addr['email'], $addr['name']); - $messenger->im($addr['jabber'], $addr['name']); - - $messenger->assign_vars(array( - 'EMAIL_SIG' => $email_sig, - 'SITENAME' => $config['sitename'], - 'USERNAME' => $addr['name'], - 'TOPIC_TITLE' => $topic_title, - 'FORUM_NAME' => $forum_name, - - 'U_FORUM' => generate_board_url() . "/viewforum.$phpEx?f=$forum_id&e=0", - 'U_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t=$topic_id&e=0", - 'U_NEWEST_POST' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t=$topic_id&p=$post_id&e=$post_id", - 'U_STOP_WATCHING_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t=$topic_id&unwatch=topic", - 'U_STOP_WATCHING_FORUM' => generate_board_url() . "/viewforum.$phpEx?f=$forum_id&unwatch=forum", - )); - - $messenger->send($addr['method']); - $messenger->reset(); - } - } - unset($msg_list_ary); - - if ($messenger->queue) - { - $messenger->queue->save(); - } - } - - // Handle the DB updates - $db->sql_transaction(); - - if (sizeof($update_notification['topic'])) - { - $db->sql_query('UPDATE ' . TOPICS_WATCH_TABLE . " - SET notify_status = 1 - WHERE topic_id = $topic_id - AND user_id IN (" . implode(', ', $update_notification['topic']) . ")"); - } - - if (sizeof($update_notification['forum'])) - { - $db->sql_query('UPDATE ' . FORUMS_WATCH_TABLE . " - SET notify_status = 1 - WHERE forum_id = $forum_id - AND user_id IN (" . implode(', ', $update_notification['forum']) . ")"); - } - - // Now delete the user_ids not authorized to receive notifications on this topic/forum - if (sizeof($delete_ids['topic'])) - { - $db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . " - WHERE topic_id = $topic_id - AND user_id IN (" . implode(', ', $delete_ids['topic']) . ")"); - } - - if (sizeof($delete_ids['forum'])) - { - $db->sql_query('DELETE FROM ' . FORUMS_WATCH_TABLE . " - WHERE forum_id = $forum_id - AND user_id IN (" . implode(', ', $delete_ids['forum']) . ")"); - } - - $db->sql_transaction('commit'); - -} - // Delete Post function delete_post($mode, $post_id, $topic_id, $forum_id, $data) { diff --git a/phpBB/styles/subSilver/template/mcp_approve.html b/phpBB/styles/subSilver/template/mcp_approve.html index 55f878609f..e825a83acf 100644 --- a/phpBB/styles/subSilver/template/mcp_approve.html +++ b/phpBB/styles/subSilver/template/mcp_approve.html @@ -1,46 +1,56 @@ - + + - +
+ + + +
- + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_POST_DETAILS}{MESSAGE_TITLE}
{RETURN_QUEUE} + + {ADDITIONAL_MSG}
+ + + {L_NOTIFY_POSTER_APPROVAL}{L_NOTIFY_POSTER_DISAPPROVAL}
+ + +
+ + + + + + + + + +
{L_DISAPPROVE_REASON}:
{L_MORE_INFO}:
{L_CAN_LEAVE_BLANK}
+
+ +
{S_HIDDEN_FIELDS}{MESSAGE_TEXT}

+    +
{L_POST_SUBJECT}: {POST_SUBJECT}
{L_POSTER}: {POSTER_NAME}   [ {L_READ_PROFILE} ] [ {L_READ_USERNOTES} ] [ {L_READ_WARNINGS} ]
{L_THIS_POST_IP}: {POST_IP} [ {POST_IPADDR} ]
{L_POSTED}: {POST_DATE}
{L_PREVIEW}
{POST_PREVIEW}
 
+ + + +
- + + + + +
+ +

{S_TIMEZONE}

+
- \ No newline at end of file +
+ + diff --git a/phpBB/styles/subSilver/template/mcp_front.html b/phpBB/styles/subSilver/template/mcp_front.html index 0717fdb470..5796d1312a 100644 --- a/phpBB/styles/subSilver/template/mcp_front.html +++ b/phpBB/styles/subSilver/template/mcp_front.html @@ -3,7 +3,7 @@ - +
@@ -15,30 +15,30 @@ - - - - - - - + + + + + + + - - - + + + - - - + + + -
{L_LATEST_UNAPPROVED}
 {L_POST_TIME} 
{unapproved.FORUM}{unapproved.TOPIC}{unapproved.SUBJECT}{unapproved.AUTHOR}{unapproved.POST_TIME}
{unapproved.FORUM_NAME}{unapproved.FORUM_NAME}
[ {L_MODERATE} ]
{unapproved.TOPIC_TITLE}
[ {L_MODERATE} ]
{unapproved.SUBJECT}
[ {L_VIEW_DETAILS} ]
{unapproved.AUTHOR}{unapproved.AUTHOR}{unapproved.POST_TIME}
{L_UNAPPROVED_POSTS_ZERO_TOTAL}
{L_UNAPPROVED_POSTS_ZERO_TOTAL}
{L_UNAPPROVED_TOTAL}
{L_UNAPPROVED_TOTAL}
+ -

+

- +
@@ -50,26 +50,26 @@ - - - - - - - + + + + + + + - - - + + + - - - + + + -
{L_LATEST_REPORTED}
 {L_REPORT_TIME} 
{report.FORUM}{report.TOPIC}{report.SUBJECT}{report.REPORTER}{report.REPORT_TIME}
{report.FORUM_NAME}{report.FORUM_NAME}
[ {L_MODERATE} ]
{report.TOPIC_TITLE}
[ {L_MODERATE} ]
{report.SUBJECT}
[ {L_VIEW_DETAILS} ]
{report.REPORTER}{report.REPORTER}{report.REPORT_TIME}
{L_REPORTS_ZERO_TOTAL}
{L_REPORTS_ZERO_TOTAL}
{L_REPORTS_TOTAL}
{L_REPORTS_TOTAL}
+ -

+

@@ -88,7 +88,7 @@ {log.USERNAME} {log.IP} - {log.ACTION} + {log.ACTION} {L_VIEW_TOPIC} | {L_VIEW_TOPIC_LOGS} {log.TIME} diff --git a/phpBB/styles/subSilver/template/mcp_post.html b/phpBB/styles/subSilver/template/mcp_post.html index 87d2bcedbd..aba3f5edd0 100644 --- a/phpBB/styles/subSilver/template/mcp_post.html +++ b/phpBB/styles/subSilver/template/mcp_post.html @@ -1,138 +1,151 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + - -
{L_POST_DETAILS}
{RETURN_TOPIC}
{L_POST_SUBJECT}: {POST_SUBJECT}
{L_POSTER}: {POSTER_NAME}   [ {L_READ_PROFILE} ] [ {L_READ_USERNOTES} ] [ {L_READ_WARNINGS} ]
{L_POST_DETAILS}
{RETURN_QUEUE}{RETURN_TOPIC}
{L_POST_SUBJECT}: {POST_SUBJECT}
{L_POSTER}: {POSTER_NAME}   [ {L_READ_PROFILE} ] [ {L_READ_USERNOTES} ] [ {L_READ_WARNINGS} ]
{L_THIS_POST_IP}: {POST_IP} [ {POST_IPADDR} ]
{L_POSTED}: {POST_DATE}
{L_PREVIEW}
{POST_PREVIEW}
{L_POSTED}: {POST_DATE}
{L_PREVIEW}
{POST_PREVIEW}
 
- - -
- - - - - - - - - - - - - - - - - - - - - - - - -
{L_REPORTS}
{reports.REPORT_TIME}{reports.REASON_TITLE} » {reports.REASON_DESC}
{L_REPORTER}: {reports.REPORTER}{reports.REPORTER}
{L_MORE_INFO}: {reports.REPORT_TEXT}
+ - - -
- - - - - - - - - - - - - - - - -
{L_MOD_OPTIONS}
{L_CHANGE_POSTER}
{L_MOD_OPTIONS}
- + - -
+ +
- - - - - - - - - - - - + + + + +
+ +
{L_IP_INFO}
{L_OTHER_USERS}
+ + + + + + + + + + + + + + + + + + + + + + +
{L_REPORTS}
{reports.REPORT_TIME}{reports.REASON_TITLE} » {reports.REASON_DESC}
{L_REPORTER}: {reports.REPORTER}{reports.REPORTER}
{L_MORE_INFO}: {reports.REPORT_TEXT}
- {userrow.USERNAME} [ {userrow.NUM_POSTS} {userrow.L_POST_S} ] - {SEARCH_IMG} - - - - {L_NO_MATCHES_FOUND} - - - - {L_OTHER_IPS} - [ {L_LOOKUP_ALL} ] - - - - - - + + +
+ + + + + + + + + + + + + + + + + + + + + +
{L_MOD_OPTIONS}
{L_CHANGE_POSTER}
{L_MOD_OPTIONS}
- {iprow.HOSTNAME} ({iprow.IP}){iprow.IP} [ {iprow.NUM_POSTS} {iprow.L_POST_S} ] - [ {L_LOOKUP_IP} ] - - - - {L_NO_MATCHES_FOUND} - - - + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{L_IP_INFO}
{L_OTHER_USERS}
{userrow.USERNAME} [ {userrow.NUM_POSTS} {userrow.L_POST_S} ]{SEARCH_IMG}
{L_NO_MATCHES_FOUND}
{L_OTHER_IPS}[ {L_LOOKUP_ALL} ]
{iprow.HOSTNAME} ({iprow.IP}){iprow.IP} [ {iprow.NUM_POSTS} {iprow.L_POST_S} ][ {L_LOOKUP_IP} ]
{L_NO_MATCHES_FOUND}
+ + \ No newline at end of file diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 03b6dec26d..3ab5393cd9 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -572,7 +572,7 @@ if ($forum_data['forum_type'] == FORUM_POST || ($forum_data['forum_flags'] & 16) 'U_LAST_POST_AUTHOR'=> ($row['topic_last_poster_id'] != ANONYMOUS && $row['topic_last_poster_id']) ? "memberlist.$phpEx$SID&mode=viewprofile&u={$row['topic_last_poster_id']}" : '', 'U_VIEW_TOPIC' => $view_topic_url, 'U_MCP_REPORT' => "mcp.$phpEx?sid={$user->session_id}&mode=reports&t=$topic_id", - 'U_MCP_QUEUE' => "mcp.$phpEx?sid={$user->session_id}&mode=mod_queue&t=$topic_id") + 'U_MCP_QUEUE' => "mcp.$phpEx?sid={$user->session_id}&i=queue&mode=approve_details&t=$topic_id") ); $s_type_switch = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0; diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 4181b8ac24..b9f1408518 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1262,7 +1262,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'U_RATE_BAD' => "viewtopic.$phpEx$SID&rate=bad&p=" . $row['post_id'], 'U_REPORT' => "report.$phpEx$SID&p=" . $row['post_id'], 'U_MCP_REPORT' => ($auth->acl_gets('m_', 'a_', 'f_report', $forum_id)) ? "mcp.$phpEx$SID&mode=post_details&p=" . $row['post_id'] : '', - 'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $forum_id)) ? "mcp.$phpEx$SID&i=queue&mode=approve&p=" . $row['post_id'] : '', + 'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $forum_id)) ? "mcp.$phpEx$SID&i=queue&mode=approve&post_id_list[]=" . $row['post_id'] : '', 'U_MCP_DETAILS' => ($auth->acl_get('m_', $forum_id)) ? "mcp.$phpEx$SID&mode=post_details&p=" . $row['post_id'] : '', 'U_MINI_POST' => "viewtopic.$phpEx$SID&p=" . $row['post_id'] . '#' . $row['post_id'], 'U_POST_ID' => ($unread_post_id == $row['post_id']) ? 'unread' : $row['post_id'],