blog_plugins::plugin_do('reply_add_after_preview'); // handles the basic data we need to output for posting handle_basic_posting_data(false, 'reply'); // Assign some variables to the template parser $template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'MESSAGE' => $reply_text, 'SUBJECT' => $reply_subject, 'L_MESSAGE_BODY_EXPLAIN' => intval($config['max_post_chars']) ? sprintf($user->lang['MESSAGE_BODY_EXPLAIN'], intval($config['max_post_chars'])) : '', 'L_POST_A' => $user->lang['POST_A_NEW_REPLY'])); $template->set_filenames(array('body' => 'blog/blog_posting_layout.html')); } else { // insert array, not all of these really need to be inserted, since some are what the fields are as default, but I want it this way. :P $sql_data = array('blog_id' => $blog_id, 'user_id' => $user->data['user_id'], 'user_ip' => $user->data['user_ip'], 'reply_time' => time(), 'reply_subject' => $reply_subject, 'reply_text' => $message_parser->message, 'reply_checksum' => md5($message_parser->message), 'reply_approved' => $auth->acl_get('u_blogreplynoapprove') ? 1 : 0, 'enable_bbcode' => $post_options->enable_bbcode, 'enable_smilies' => $post_options->enable_smilies, 'enable_magic_url' => $post_options->enable_magic_url, 'bbcode_bitfield' => $message_parser->bbcode_bitfield, 'bbcode_uid' => $message_parser->bbcode_uid, 'reply_edit_reason' => '', 'reply_attachment' => sizeof($blog_attachment->attachment_data) ? 1 : 0); blog_plugins::plugin_do_ref('reply_add_sql', $sql_data); $sql = 'INSERT INTO ' . BLOGS_REPLY_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data); $db->sql_query($sql); $reply_id = $db->sql_nextid(); $blog_search->index('add', $blog_id, $reply_id, $message_parser->message, $reply_subject, $user->data['user_id']); // update the URLS to include the new reply_id generate_blog_urls(); $blog_attachment->update_attachment_data(false, $reply_id); blog_plugins::plugin_do_arg('reply_add_after_sql', $reply_id); // Handle the subscriptions add_blog_subscriptions($blog_id, 'subscription_'); handle_blog_cache('add_reply', $user_id); // update the reply count for the blog if ($sql_data['reply_approved']) { $sql = 'UPDATE ' . BLOGS_TABLE . ' SET blog_reply_count = blog_reply_count + 1, blog_real_reply_count = blog_real_reply_count + 1 WHERE blog_id = ' . intval($blog_id); $db->sql_query($sql); set_config('num_blog_replies', ++$config['num_blog_replies'], true); handle_subscription('new_reply', censor_text($reply_subject), 0, $blog_id, $reply_id); } else { $sql = 'UPDATE ' . BLOGS_TABLE . ' SET blog_real_reply_count = blog_real_reply_count + 1 WHERE blog_id = ' . intval($blog_id); $db->sql_query($sql); inform_approve_report('reply_approve', $reply_id);
function main($id, $mode) { global $auth, $db, $user, $template; global $config, $phpbb_root_path, $phpEx, $action; global $blog_data, $blog_plugins, $blog_urls; $user->add_lang(array('mods/blog/common', 'mods/blog/mcp')); // include some files include $phpbb_root_path . 'includes/functions_display.' . $phpEx; include $phpbb_root_path . 'blog/functions.' . $phpEx; // set some initial variables that we will use $blog_data = new blog_data(); blog_plugins::plugin_do('mcp_start'); $blog = strpos($mode, 'blogs') ? true : false; $start = request_var('start', 0); $limit = request_var('limit', 10); $sort_days = request_var('st', !empty($user->data['user_post_show_days']) ? $user->data['user_post_show_days'] : 0); $sort_key = request_var('sk', 't'); $sort_dir = request_var('sd', 'd'); $limit_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; $order_dir = $sort_dir == 'a' ? 'ASC' : 'DESC'; if ($blog) { $sort_by_text = array('t' => $user->lang['POST_TIME']); $sort_by_sql = array('t' => 'blog_time'); } else { $sort_by_text = array('t' => $user->lang['POST_TIME']); $sort_by_sql = array('t' => 'reply_time'); } generate_blog_urls(); $this->tpl_name = 'blog/mcp_blog'; $this->page_title = $user->lang['MCP_BLOG_' . strtoupper($mode)]; $template->assign_vars(array('L_TITLE' => $user->lang['MCP_BLOG_' . strtoupper($mode)], 'L_EXPLAIN' => $user->lang['MCP_BLOG_' . strtoupper($mode) . '_EXPLAIN'], 'S_BLOGS' => $blog, 'S_REPLIES' => !$blog)); $extra_data = array('start' => $start, 'limit' => $limit, 'order_by' => $sort_by_sql[$sort_key], 'order_dir' => $order_dir, 'sort_days' => $sort_days); switch ($mode) { // Need to add counts here... case 'reported_blogs': $ids = $blog_data->get_blog_data('reported', false, $extra_data); break; case 'reported_replies': $ids = $blog_data->get_reply_data('reported', false, $extra_data); break; case 'disapproved_blogs': $ids = $blog_data->get_blog_data('disapproved', false, $extra_data); break; case 'disapproved_replies': $ids = $blog_data->get_reply_data('disapproved', false, $extra_data); break; default: blog_plugins::plugin_do_arg('mcp_default', $mode); } if ($blog) { $cnt_sql = 'SELECT count(blog_id) AS total FROM ' . BLOGS_TABLE . ' WHERE blog_' . (strpos($mode, 'reported') !== false ? 'reported = 1' : 'approved = 0'); } else { $cnt_sql = 'SELECT count(reply_id) AS total FROM ' . BLOGS_REPLY_TABLE . ' WHERE ' . 'reply_' . (strpos($mode, 'reported') !== false ? 'reported = 1' : 'approved = 0'); } $result = $db->sql_query($cnt_sql); $row = $db->sql_fetchrow($result); if ($row) { $count = $row['total']; } $db->sql_freeresult($result); unset($row, $cnt_sql); if ($ids === false) { $ids = array(); } $blog_data->get_user_data(false, true); if ($blog) { $total_posts = $count == 1 ? $user->lang['ONE_BLOG'] : sprintf($user->lang['CNT_BLOGS'], $count); foreach ($ids as $id) { $user_id = blog_data::$blog[$id]['user_id']; $template->assign_block_vars('postrow', array('U_VIEW' => blog_url($user_id, $id), 'SUBJECT' => blog_data::$blog[$id]['blog_subject'], 'AUTHOR' => blog_data::$user[$user_id]['username_full'], 'TIME' => $user->format_date(blog_data::$blog[$id]['blog_time']))); } } else { $total_posts = $count == 1 ? $user->lang['ONE_REPLY'] : sprintf($user->lang['CNT_REPLIES'], $count); foreach ($ids as $id) { $user_id = blog_data::$reply[$id]['user_id']; $blog_id = blog_data::$reply[$id]['blog_id']; $template->assign_block_vars('postrow', array('U_VIEW' => blog_url($user_id, $blog_id, $id), 'SUBJECT' => blog_data::$reply[$id]['reply_subject'], 'AUTHOR' => blog_data::$user[$user_id]['username_full'], 'TIME' => $user->format_date(blog_data::$reply[$id]['reply_time']))); } } gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); $pagination = generate_pagination($this->u_action . "&limit={$limit}&st={$sort_days}&sk={$sort_key}&sd={$sort_dir}", $count, $limit, $start, false); $template->assign_vars(array('PAGINATION' => $pagination, 'PAGE_NUMBER' => on_page($count, $limit, $start), 'TOTAL_POSTS' => $total_posts, 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days)); blog_plugins::plugin_do('mcp_end'); }