function get_inbox_stat_func() { global $db, $user, $config, $auth, $mobiquo_config; $user->setup('ucp'); if (!$user->data['is_registered']) { trigger_error('LOGIN_EXPLAIN_UCP'); } // get unread number of subscribed topic $forbidden_forums = $auth->acl_getf('!f_read', true); $forbidden_forums = array_unique(array_keys($forbidden_forums)); if (isset($mobiquo_config['hide_forum_id'])) { $forbidden_forums = array_unique(array_merge($forbidden_forums, $mobiquo_config['hide_forum_id'])); } $sql = 'SELECT t.topic_id, t.forum_id, t.topic_last_post_time FROM ' . TOPICS_WATCH_TABLE . ' tw LEFT JOIN ' . TOPICS_TABLE . ' t ON tw.topic_id=t.topic_id WHERE tw.user_id = ' . $user->data['user_id'] . ' AND ' . $db->sql_in_set('t.forum_id', $forbidden_forum_ary, true, true) . ' AND t.topic_last_post_time > ' . $user->data['user_lastvisit']; $result = $db->sql_query($sql); $subscribed_topic_unread_count = 0; while ($row = $db->sql_fetchrow($result)) { $topic_id = $row['topic_id']; $forum_id = $row['forum_id']; $topic_tracking = get_complete_topic_tracking($forum_id, $topic_id); if ($topic_tracking[$topic_id] < $row['topic_last_post_time']) { $subscribed_topic_unread_count++; } } $db->sql_freeresult($result); $inbox_unread_count = $user->data['user_unread_privmsg'] ? $user->data['user_unread_privmsg'] : 0; $result = new xmlrpcval(array('inbox_unread_count' => new xmlrpcval($inbox_unread_count, 'int'), 'subscribed_topic_unread_count' => new xmlrpcval($subscribed_topic_unread_count, 'int')), 'struct'); return new xmlrpcresp($result); }
function get_subscribed_topic_func() { global $config, $db, $user, $auth, $mobiquo_config; // Only registered users can go beyond this point if (!$user->data['is_registered']) { return get_error(9); } $topic_list = array(); if ($config['allow_topic_notify']) { $forbidden_forums = $auth->acl_getf('!f_read', true); $forbidden_forums = array_unique(array_keys($forbidden_forums)); if (isset($mobiquo_config['hide_forum_id'])) { $forbidden_forums = array_unique(array_merge($forbidden_forums, $mobiquo_config['hide_forum_id'])); } $sql_array = array('SELECT' => 't.*, f.forum_name, u.user_avatar, u.user_avatar_type', 'FROM' => array(TOPICS_WATCH_TABLE => 'tw', TOPICS_TABLE => 't', USERS_TABLE => 'u'), 'WHERE' => 'tw.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tw.topic_id AND u.user_id = t.topic_last_poster_id AND ' . $db->sql_in_set('t.forum_id', $forbidden_forum_ary, true, true), 'ORDER_BY' => 't.topic_last_post_time DESC'); $sql_array['LEFT_JOIN'] = array(); $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 't.forum_id = f.forum_id'); if ($config['allow_bookmarks']) { $sql_array['SELECT'] .= ', bm.topic_id as bookmarked'; $sql_array['LEFT_JOIN'][] = array('FROM' => array(BOOKMARKS_TABLE => 'bm'), 'ON' => 'bm.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = bm.topic_id'); } $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query_limit($sql, 20); $topic_list = array(); while ($row = $db->sql_fetchrow($result)) { $forum_id = $row['forum_id']; $topic_id = isset($row['b_topic_id']) ? $row['b_topic_id'] : $row['topic_id']; // Replies $replies = $auth->acl_get('m_approve', $forum_id) ? $row['topic_replies_real'] : $row['topic_replies']; if ($row['topic_status'] == ITEM_MOVED && !empty($row['topic_moved_id'])) { $topic_id = $row['topic_moved_id']; } // Get folder img, topic status/type related information $folder_img = $folder_alt = $topic_type = ''; topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type); $short_content = get_short_content($row['topic_last_post_id']); if ($forum_id) { $topic_tracking = get_complete_topic_tracking($forum_id, $topic_id); $new_post = $topic_tracking[$topic_id] < $row['topic_last_post_time'] ? true : false; } else { $new_post = false; } $user_avatar_url = get_user_avatar_url($row['user_avatar'], $row['user_avatar_type']); $allow_change_type = $auth->acl_get('m_', $forum_id) || $user->data['is_registered'] && $user->data['user_id'] == $row['topic_poster'] ? true : false; $xmlrpc_topic = new xmlrpcval(array('forum_id' => new xmlrpcval($forum_id), 'forum_name' => new xmlrpcval(html_entity_decode($row['forum_name']), 'base64'), 'topic_id' => new xmlrpcval($topic_id), 'topic_title' => new xmlrpcval(html_entity_decode(strip_tags(censor_text($row['topic_title']))), 'base64'), 'reply_number' => new xmlrpcval(intval($replies), 'int'), 'view_number' => new xmlrpcval(intval($row['topic_views']), 'int'), 'short_content' => new xmlrpcval($short_content, 'base64'), 'post_author_id' => new xmlrpcval($row['topic_last_poster_id']), 'post_author_name' => new xmlrpcval(html_entity_decode($row['topic_last_poster_name']), 'base64'), 'new_post' => new xmlrpcval($new_post, 'boolean'), 'post_time' => new xmlrpcval(mobiquo_iso8601_encode($row['topic_last_post_time']), 'dateTime.iso8601'), 'icon_url' => new xmlrpcval($user_avatar_url), 'can_delete' => new xmlrpcval($auth->acl_get('m_delete', $forum_id), 'boolean'), 'can_bookmark' => new xmlrpcval($user->data['is_registered'] && $config['allow_bookmarks'], 'boolean'), 'isbookmarked' => new xmlrpcval($row['bookmarked'] ? true : false, 'boolean'), 'can_close' => new xmlrpcval($auth->acl_get('m_lock', $forum_id) || $auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $row['topic_poster'], 'boolean'), 'is_closed' => new xmlrpcval($row['topic_status'] == ITEM_LOCKED, 'boolean'), 'can_stick' => new xmlrpcval($allow_change_type && $auth->acl_get('f_sticky', $forum_id) && $row['topic_type'] != POST_STICKY, 'boolean')), 'struct'); $topic_list[] = $xmlrpc_topic; } $db->sql_freeresult($result); } $topic_num = count($topic_list); $response = new xmlrpcval(array('total_topic_num' => new xmlrpcval($topic_num, 'int'), 'topics' => new xmlrpcval($topic_list, 'array')), 'struct'); return new xmlrpcresp($response); }
public function display_recent_topics($tpl_loopname = 'recent_topics', $spec_forum_id = 0, $include_subforums = true) { $this->user->add_lang_ext('paybas/recenttopics', 'recenttopics'); /** * Set some internal needed variables */ $topics_per_page = $this->config['rt_number']; $num_pages = $this->config['rt_page_number']; $min_topic_level = $this->config['rt_min_topic_level']; $excluded_topics = $this->config['rt_anti_topics']; $display_parent_forums = $this->config['rt_parents']; $unread_only = $this->config['rt_unreadonly']; $sort_topics = $this->config['rt_sort_start_time'] ? 'topic_time' : 'topic_last_post_time'; $persistent_display = $this->config['rt_persistent_display']; if ($persistent_display) { $this->template->assign_vars(array(strtoupper($tpl_loopname) . '_DISPLAY' => true)); } $start = $this->request->variable($tpl_loopname . '_start', 0); $excluded_topic_ids = explode(', ', $excluded_topics); $total_limit = $topics_per_page * $num_pages; if (!function_exists('display_forums')) { include $this->root_path . 'includes/functions_display.' . $this->phpEx; } /** * Get the forums we take our topics from */ // Get the allowed forums $forum_ary = array(); $forum_read_ary = $this->auth->acl_getf('f_read'); foreach ($forum_read_ary as $forum_id => $allowed) { if ($allowed['f_read']) { $forum_ary[] = (int) $forum_id; } } $forum_ids = array_unique($forum_ary); if (!sizeof($forum_ids)) { // No forums with f_read return; } $spec_forum_ary = array(); if ($spec_forum_id) { // Only take a special-forum if (!$include_subforums) { if (!in_array($spec_forum_id, $forum_ids)) { return; } $forum_ids = array(); $sql = 'SELECT 1 as display_forum FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . intval($spec_forum_id) . ' AND forum_recent_topics = 1'; $result = $this->db->sql_query_limit($sql, 1); $display_forum = (bool) $this->db->sql_fetchfield('display_forum'); $this->db->sql_freeresult($result); if ($display_forum) { $forum_ids = array($spec_forum_id); } } else { // ... and it's subforums $sql = 'SELECT f2.forum_id FROM ' . FORUMS_TABLE . ' f1 LEFT JOIN ' . FORUMS_TABLE . " f2\n\t\t\t\t\t\tON (f2.left_id BETWEEN f1.left_id AND f1.right_id\n\t\t\t\t\t\t\tAND f2.forum_recent_topics = 1)\n\t\t\t\t\tWHERE f1.forum_id = {$spec_forum_id}\n\t\t\t\t\t\tAND f1.forum_recent_topics = 1\n\t\t\t\t\tORDER BY f2.left_id DESC"; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $spec_forum_ary[] = $row['forum_id']; } $this->db->sql_freeresult($result); $forum_ids = array_intersect($forum_ids, $spec_forum_ary); if (!sizeof($forum_ids)) { return; } } } else { $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' WHERE ' . $this->db->sql_in_set('forum_id', $forum_ids) . ' AND forum_recent_topics = 1'; $result = $this->db->sql_query($sql); $forum_ids = array(); while ($row = $this->db->sql_fetchrow($result)) { $forum_ids[] = $row['forum_id']; } $this->db->sql_freeresult($result); } // No forums with f_read or recent topics enabled if (!sizeof($forum_ids)) { return; } // Remove duplicated ids $forum_ids = array_unique($forum_ids); $forums = $topic_list = array(); $topics_count = 0; $obtain_icons = false; // Either use the phpBB core function to get unread topics, or the custom function for default behavior if ($unread_only && $this->user->data['user_id'] != ANONYMOUS) { // Get unread topics $sql_extra = ' AND ' . $this->db->sql_in_set('t.topic_id', $excluded_topic_ids, true); $sql_extra .= ' AND ' . $this->content_visibility->get_forums_visibility_sql('topic', $forum_ids, $table_alias = 't.'); $unread_topics = get_unread_topics(false, $sql_extra, '', $total_limit); foreach ($unread_topics as $topic_id => $mark_time) { $topics_count++; if ($topics_count > $start && $topics_count <= $start + $topics_per_page) { $topic_list[] = $topic_id; } } } else { // Get the allowed topics $sql_array = array('SELECT' => 't.forum_id, t.topic_id, t.topic_type, t.icon_id, tt.mark_time, ft.mark_time as f_mark_time', 'FROM' => array(TOPICS_TABLE => 't'), 'LEFT_JOIN' => array(array('FROM' => array(TOPICS_TRACK_TABLE => 'tt'), 'ON' => 'tt.topic_id = t.topic_id AND tt.user_id = ' . $this->user->data['user_id']), array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.forum_id = t.forum_id AND ft.user_id = ' . $this->user->data['user_id'])), 'WHERE' => $this->db->sql_in_set('t.topic_id', $excluded_topic_ids, true) . ' AND t.topic_status <> ' . ITEM_MOVED . ' AND ' . $this->content_visibility->get_forums_visibility_sql('topic', $forum_ids, $table_alias = 't.'), 'ORDER_BY' => 't.' . $sort_topics . ' DESC'); // Check if we want all topics, or only stickies/announcements/globals if ($min_topic_level > 0) { $sql_array['WHERE'] .= ' AND t.topic_type >= ' . $min_topic_level; } /** * Event to modify the SQL query before the allowed topics list data is retrieved * * @event paybas.recenttopics.sql_pull_topics_list * @var array sql_array The SQL array * @since 2.0.4 */ $vars = array('sql_array'); extract($this->dispatcher->trigger_event('paybas.recenttopics.sql_pull_topics_list', compact($vars))); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query_limit($sql, $total_limit); while ($row = $this->db->sql_fetchrow($result)) { $topics_count++; if ($topics_count > $start && $topics_count <= $start + $topics_per_page) { $topic_list[] = $row['topic_id']; $rowset[$row['topic_id']] = $row; if (!isset($forums[$row['forum_id']]) && $this->user->data['is_registered'] && $this->config['load_db_lastread']) { $forums[$row['forum_id']]['mark_time'] = $row['f_mark_time']; } $forums[$row['forum_id']]['topic_list'][] = $row['topic_id']; $forums[$row['forum_id']]['rowset'][$row['topic_id']] =& $rowset[$row['topic_id']]; if ($row['icon_id'] && $this->auth->acl_get('f_icons', $row['forum_id'])) { $obtain_icons = true; } } } $this->db->sql_freeresult($result); } // No topics to display if (!sizeof($topic_list)) { return; } // Grab icons if ($obtain_icons) { $icons = $this->cache->obtain_icons(); } else { $icons = array(); } // Borrowed from search.php foreach ($forums as $forum_id => $forum) { if ($this->user->data['is_registered'] && $this->config['load_db_lastread']) { $topic_tracking_info[$forum_id] = get_topic_tracking($forum_id, $forum['topic_list'], $forum['rowset'], array($forum_id => $forum['mark_time']), $forum_id ? false : $forum['topic_list']); } else { if ($this->config['load_anon_lastread'] || $this->user->data['is_registered']) { $tracking_topics = $this->request->variable($this->config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE); $tracking_topics = $tracking_topics ? tracking_unserialize($tracking_topics) : array(); $topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $forum['topic_list'], $forum_id ? false : $forum['topic_list']); if (!$this->user->data['is_registered']) { $this->user->data['user_lastmark'] = isset($tracking_topics['l']) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $this->config['board_startdate']) : 0; } } } } // Now only pull the data of the requested topics $sql_array = array('SELECT' => 't.*, tp.topic_posted, f.forum_name', 'FROM' => array(TOPICS_TABLE => 't'), 'LEFT_JOIN' => array(array('FROM' => array(TOPICS_POSTED_TABLE => 'tp'), 'ON' => 't.topic_id = tp.topic_id AND tp.user_id = ' . $this->user->data['user_id']), array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = t.forum_id')), 'WHERE' => $this->db->sql_in_set('t.topic_id', $topic_list), 'ORDER_BY' => 't.' . $sort_topics . ' DESC'); if ($display_parent_forums) { $sql_array['SELECT'] .= ', f.parent_id, f.forum_parents, f.left_id, f.right_id'; } /** * Event to modify the SQL query before the topics data is retrieved * * @event paybas.recenttopics.sql_pull_topics_data * @var array sql_array The SQL array * @since 2.0.0 */ $vars = array('sql_array'); extract($this->dispatcher->trigger_event('paybas.recenttopics.sql_pull_topics_data', compact($vars))); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query_limit($sql, $topics_per_page); $rowset = $topic_icons = array(); while ($row = $this->db->sql_fetchrow($result)) { $rowset[] = $row; } $this->db->sql_freeresult($result); // No topics returned by the DB if (!sizeof($rowset)) { return; } /** * Event to modify the topics list data before we start the display loop * * @event paybas.recenttopics.modify_topics_list * @var array topic_list Array of all the topic IDs * @var array rowset The full topics list array * @since 2.0.1 */ $vars = array('topic_list', 'rowset'); extract($this->dispatcher->trigger_event('paybas.recenttopics.modify_topics_list', compact($vars))); foreach ($rowset as $row) { $topic_id = $row['topic_id']; $forum_id = $row['forum_id']; $s_type_switch_test = $row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL ? 1 : 0; //$replies = ($this->auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies']; $replies = $this->content_visibility->get_count('topic_posts', $row, $forum_id) - 1; if ($unread_only) { topic_status($row, $replies, true, $folder_img, $folder_alt, $topic_type); $unread_topic = true; } else { topic_status($row, $replies, isset($topic_tracking_info[$forum_id][$row['topic_id']]) && $row['topic_last_post_time'] > $topic_tracking_info[$forum_id][$row['topic_id']] ? true : false, $folder_img, $folder_alt, $topic_type); $unread_topic = isset($topic_tracking_info[$forum_id][$row['topic_id']]) && $row['topic_last_post_time'] > $topic_tracking_info[$forum_id][$row['topic_id']] ? true : false; } $view_topic_url = append_sid("{$this->root_path}viewtopic.{$this->phpEx}", 'f=' . $forum_id . '&t=' . $topic_id); $view_forum_url = append_sid("{$this->root_path}viewforum.{$this->phpEx}", 'f=' . $forum_id); $topic_unapproved = $row['topic_visibility'] == ITEM_UNAPPROVED && $this->auth->acl_get('m_approve', $forum_id); $posts_unapproved = $row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $this->auth->acl_get('m_approve', $forum_id); $u_mcp_queue = $topic_unapproved || $posts_unapproved ? append_sid("{$this->root_path}mcp.{$this->phpEx}", 'i=queue&mode=' . ($topic_unapproved ? 'approve_details' : 'unapproved_posts') . "&t={$topic_id}", true, $this->user->session_id) : ''; $s_type_switch = $row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL ? 1 : 0; if (!empty($icons[$row['icon_id']])) { $topic_icons[] = $topic_id; } // Get folder img, topic status/type related information $folder_img = $folder_alt = $topic_type = ''; topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type); $tpl_ary = array('FORUM_ID' => $forum_id, 'TOPIC_ID' => $topic_id, 'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'FIRST_POST_TIME' => $this->user->format_date($row['topic_time']), 'LAST_POST_SUBJECT' => censor_text($row['topic_last_post_subject']), 'LAST_POST_TIME' => $this->user->format_date($row['topic_last_post_time']), 'LAST_VIEW_TIME' => $this->user->format_date($row['topic_last_view_time']), 'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'REPLIES' => $replies, 'VIEWS' => $row['topic_views'], 'TOPIC_TITLE' => censor_text($row['topic_title']), 'FORUM_NAME' => $row['forum_name'], 'TOPIC_TYPE' => $topic_type, 'TOPIC_IMG_STYLE' => $folder_img, 'TOPIC_FOLDER_IMG' => $this->user->img($folder_img, $folder_alt), 'TOPIC_FOLDER_IMG_ALT' => $this->user->lang[$folder_alt], 'TOPIC_ICON_IMG' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['img'] : '', 'TOPIC_ICON_IMG_WIDTH' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['width'] : '', 'TOPIC_ICON_IMG_HEIGHT' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['height'] : '', 'ATTACH_ICON_IMG' => $this->auth->acl_get('u_download') && $this->auth->acl_get('f_download', $forum_id) && $row['topic_attachment'] ? $this->user->img('icon_topic_attach', $this->user->lang['TOTAL_ATTACHMENTS']) : '', 'UNAPPROVED_IMG' => $topic_unapproved || $posts_unapproved ? $this->user->img('icon_topic_unapproved', $topic_unapproved ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', 'REPORTED_IMG' => $row['topic_reported'] && $this->auth->acl_get('m_report', $forum_id) ? $this->user->img('icon_topic_reported', 'TOPIC_REPORTED') : '', 'S_HAS_POLL' => $row['poll_start'] ? true : false, 'S_TOPIC_TYPE' => $row['topic_type'], 'S_USER_POSTED' => isset($row['topic_posted']) && $row['topic_posted'] ? true : false, 'S_UNREAD_TOPIC' => $unread_topic, 'S_TOPIC_REPORTED' => $row['topic_reported'] && $this->auth->acl_get('m_report', $forum_id) ? true : false, 'S_TOPIC_UNAPPROVED' => $topic_unapproved, 'S_POSTS_UNAPPROVED' => $posts_unapproved, 'S_POST_ANNOUNCE' => $row['topic_type'] == POST_ANNOUNCE ? true : false, 'S_POST_GLOBAL' => $row['topic_type'] == POST_GLOBAL ? true : false, 'S_POST_STICKY' => $row['topic_type'] == POST_STICKY ? true : false, 'S_TOPIC_LOCKED' => $row['topic_status'] == ITEM_LOCKED ? true : false, 'S_TOPIC_MOVED' => $row['topic_status'] == ITEM_MOVED ? true : false, 'S_TOPIC_TYPE_SWITCH' => $s_type_switch == $s_type_switch_test ? -1 : $s_type_switch_test, 'U_NEWEST_POST' => $view_topic_url . '&view=unread#unread', 'U_LAST_POST' => $view_topic_url . '&p=' . $row['topic_last_post_id'] . '#p' . $row['topic_last_post_id'], 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'U_VIEW_TOPIC' => $view_topic_url, 'U_VIEW_FORUM' => $view_forum_url, 'U_MCP_REPORT' => append_sid("{$this->root_path}mcp.{$this->phpEx}", 'i=reports&mode=reports&f=' . $forum_id . '&t=' . $topic_id, true, $this->user->session_id), 'U_MCP_QUEUE' => $u_mcp_queue); /** * Modify the topic data before it is assigned to the template * * @event paybas.recenttopics.modify_tpl_ary * @var array row Array with topic data * @var array tpl_ary Template block array with topic data * @since 2.0.0 */ $vars = array('row', 'tpl_ary'); extract($this->dispatcher->trigger_event('paybas.recenttopics.modify_tpl_ary', compact($vars))); $this->template->assign_block_vars($tpl_loopname, $tpl_ary); $this->pagination->generate_template_pagination($view_topic_url, $tpl_loopname . '.pagination', 'start', $replies + 1, $this->config['posts_per_page'], 1, true, true); if ($display_parent_forums) { $forum_parents = get_forum_parents($row); foreach ($forum_parents as $parent_id => $data) { $this->template->assign_block_vars($tpl_loopname . '.parent_forums', array('FORUM_ID' => $parent_id, 'FORUM_NAME' => $data[0], 'U_VIEW_FORUM' => append_sid("{$this->root_path}viewforum.{$this->phpEx}", 'f=' . $parent_id))); } } } // Get URL-parameters for pagination $url_params = explode('&', $this->user->page['query_string']); $append_params = false; foreach ($url_params as $param) { if (!$param) { continue; } if (strpos($param, '=') === false) { // Fix MSSTI Advanced BBCode MOD $append_params[$param] = '1'; continue; } list($name, $value) = explode('=', $param); if ($name != $tpl_loopname . '_start') { $append_params[$name] = $value; } } $pagination_url = append_sid($this->root_path . $this->user->page['page_name'], $append_params); $this->pagination->generate_template_pagination($pagination_url, 'rt_pagination', $tpl_loopname . '_start', $topics_count, $topics_per_page, $start); $this->template->assign_vars(array('RT_SORT_START_TIME' => $sort_topics === 'topic_time' ? true : false, 'S_TOPIC_ICONS' => sizeof($topic_icons) ? true : false, 'NEWEST_POST_IMG' => $this->user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), 'LAST_POST_IMG' => $this->user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'POLL_IMG' => $this->user->img('icon_topic_poll', 'TOPIC_POLL'), strtoupper($tpl_loopname) . '_DISPLAY' => true)); }
function global_announcements() { global $db, $auth, $user, $template; global $phpbb_root_path, $phpEx, $config; global $cache, $topic_id; //need to know what page we are on.... $page = str_replace('.' . $phpEx, '', $user->page['page_name']); if ($page == 'index' && $config['load_global_announcements_home'] || $page == 'viewtopic' && $config['load_global_announcements_topic']) { //this template varible is only used to see if we should include forumlist_body on viewtopic_body (.html) $template->assign_var('S_HAS_GLOBAL', true); //so we are on the index or viewtopic page and we are enabled lets get the global announcements $sql = 'SELECT * FROM ' . TOPICS_TABLE . ' WHERE forum_id = ' . FORUM_CAT . ' AND topic_type = ' . POST_GLOBAL; if ($user->page['page_name'] == 'viewtopic.' . $phpEx) { //exclude the current topic, say if we are viewing it... $sql .= ' AND topic_id != ' . $topic_id; } $sql .= ' ORDER BY topic_time DESC'; //order by original creation user topic_last_post_time for last commente $result = $db->sql_query($sql); $first_time_flag = 0; $topic_list = $global_announce_list = array(); //generate items for tracking while ($row = $db->sql_fetchrow($result)) { $topic_list[] = $row['topic_id']; $global_announce_list[$row['topic_id']] = '1'; } $db->sql_freeresult($result); //tracking setup //sql hack to bypass the no f=0 topics... if (sizeof($topic_list)) { $topic_tracking_info = get_complete_topic_tracking(0, $topic_list, $global_announce_list); } //regen $result = $db->sql_query($sql); $s_category = TRUE; while ($row = $db->sql_fetchrow($result)) { //is this the first time thru? if so we need a category... //genny a catergory :-) //highway of live mod no work, always gennys cats (under prosilver anyway) if ($s_category) { $template->assign_block_vars('forumrow', array('S_IS_CAT' => $s_category, 'FORUM_ID' => '0', 'FORUM_NAME' => $user->lang['GLOBAL_ANNOUNCEMENT'], 'U_VIEWFORUM' => '')); } $s_category = FALSE; // Grab topic icons stolen form cache.php $icons = $cache->obtain_icons(); // Get folder img, topic status/type related information and tracking/read/unread $unread_topic = isset($topic_tracking_info[$row['topic_id']]) && $row['topic_last_post_time'] > $topic_tracking_info[$row['topic_id']] ? true : false; $folder_img = $folder_alt = ''; //topic_posted hack...for showing _mine images if ($row['topic_first_poster_name'] == $user->data['username']) { $row['topic_posted'] = true; } topic_status($row, $row['topic_replies'], $unread_topic, $folder_img, $folder_alt, $row['topic_type']); //doing first time here... so near to last time... $first_post_time = $user->format_date($row['topic_time']); // Create last post link information, if appropriate if ($row['topic_last_post_id']) { $last_post_subject = $row['topic_last_post_subject']; $last_post_time = $user->format_date($row['topic_last_post_time']); $last_post_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id']; } else { $last_post_subject = $last_post_time = $last_post_url = ''; } //most of the block varibles used forum var names but topic equiv to save mods to forumlist_body.html $template->assign_block_vars('forumrow', array('S_IS_CAT' => false, 'S_NO_CAT' => false, 'S_IS_LINK' => false, 'S_UNREAD_FORUM' => true, 'S_LOCKED_FORUM' => false, 'S_SUBFORUMS' => false, 'FORUM_ID' => $row['forum_id'], 'FORUM_NAME' => $row['topic_title'], 'FORUM_DESC' => $user->lang['POST_BY_AUTHOR'] . ' ' . get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']) . ' ' . $user->lang['POSTED_ON_DATE'] . ' ' . $first_post_time, 'TOPICS' => $row['topic_replies'], 'POSTS' => $row['topic_views'], 'FORUM_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 'FORUM_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'), 'LAST_POST_SUBJECT' => censor_text($last_post_subject), 'LAST_POST_TIME' => $last_post_time, 'LAST_POSTER' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'LAST_POSTER_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'LAST_POSTER_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']), 'U_LAST_POSTER' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'U_LAST_POST' => $last_post_url, 'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'FIRST_POST_TIME' => $user->format_date($row['topic_time']), 'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt], 'TOPIC_ICON_IMG' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['img'] : '', 'TOPIC_ICON_IMG_WIDTH' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['width'] : '', 'TOPIC_ICON_IMG_HEIGHT' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['height'] : '', 'ATTACH_ICON_IMG' => $auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['topic_attachment'] ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '')); } $db->sql_freeresult($result); } return; }
/** * Build and assign topiclist for bookmarks/subscribed topics */ function assign_topiclist($mode = 'subscribed', $forbidden_forum_ary = array()) { global $user, $db, $template, $config, $cache, $auth, $phpbb_root_path, $phpEx; $table = $mode == 'subscribed' ? TOPICS_WATCH_TABLE : BOOKMARKS_TABLE; $start = request_var('start', 0); // Grab icons $icons = $cache->obtain_icons(); $sql_array = array('SELECT' => 'COUNT(t.topic_id) as topics_count', 'FROM' => array($table => 'i', TOPICS_TABLE => 't'), 'WHERE' => 'i.topic_id = t.topic_id AND i.user_id = ' . $user->data['user_id'] . ' AND ' . $db->sql_in_set('t.forum_id', $forbidden_forum_ary, true, true)); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $topics_count = (int) $db->sql_fetchfield('topics_count'); $db->sql_freeresult($result); if ($topics_count) { $template->assign_vars(array('PAGINATION' => generate_pagination($this->u_action, $topics_count, $config['topics_per_page'], $start), 'PAGE_NUMBER' => on_page($topics_count, $config['topics_per_page'], $start), 'TOTAL_TOPICS' => $topics_count == 1 ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $topics_count))); } if ($mode == 'subscribed') { $sql_array = array('SELECT' => 't.*, f.forum_name, f.forum_solve_text, f.forum_solve_color, f.forum_allow_solve', 'FROM' => array(TOPICS_WATCH_TABLE => 'tw', TOPICS_TABLE => 't'), 'WHERE' => 'tw.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tw.topic_id AND ' . $db->sql_in_set('t.forum_id', $forbidden_forum_ary, true, true), 'ORDER_BY' => 't.topic_last_post_time DESC'); $sql_array['LEFT_JOIN'] = array(); } else { $sql_array = array('SELECT' => 't.*, f.forum_name, f.forum_solve_text, f.forum_solve_color, f.forum_allow_solve, b.topic_id as b_topic_id', 'FROM' => array(BOOKMARKS_TABLE => 'b'), 'WHERE' => 'b.user_id = ' . $user->data['user_id'] . ' AND ' . $db->sql_in_set('f.forum_id', $forbidden_forum_ary, true, true), 'ORDER_BY' => 't.topic_last_post_time DESC'); $sql_array['LEFT_JOIN'] = array(); $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TABLE => 't'), 'ON' => 'b.topic_id = t.topic_id'); } $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 't.forum_id = f.forum_id'); if ($config['load_db_lastread']) { $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.forum_id = t.forum_id AND ft.user_id = ' . $user->data['user_id']); $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TRACK_TABLE => 'tt'), 'ON' => 'tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id']); $sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time AS forum_mark_time'; } if ($config['load_db_track']) { $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_POSTED_TABLE => 'tp'), 'ON' => 'tp.topic_id = t.topic_id AND tp.user_id = ' . $user->data['user_id']); $sql_array['SELECT'] .= ', tp.topic_posted'; } $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); $topic_list = $topic_forum_list = $global_announce_list = $rowset = array(); while ($row = $db->sql_fetchrow($result)) { $topic_id = isset($row['b_topic_id']) ? $row['b_topic_id'] : $row['topic_id']; $topic_list[] = $topic_id; $rowset[$topic_id] = $row; $topic_forum_list[$row['forum_id']]['forum_mark_time'] = $config['load_db_lastread'] ? $row['forum_mark_time'] : 0; $topic_forum_list[$row['forum_id']]['topics'][] = $topic_id; if ($row['topic_type'] == POST_GLOBAL) { $global_announce_list[] = $topic_id; } } $db->sql_freeresult($result); $topic_tracking_info = array(); if ($config['load_db_lastread']) { foreach ($topic_forum_list as $f_id => $topic_row) { $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time']), $f_id == 0 ? $global_announce_list : false); } } else { foreach ($topic_forum_list as $f_id => $topic_row) { $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics'], $global_announce_list); } } foreach ($topic_list as $topic_id) { $row =& $rowset[$topic_id]; $forum_id = $row['forum_id']; $topic_id = isset($row['b_topic_id']) ? $row['b_topic_id'] : $row['topic_id']; $unread_topic = isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id] ? true : false; // Replies $replies = $auth->acl_get('m_approve', $forum_id) ? $row['topic_replies_real'] : $row['topic_replies']; if ($row['topic_status'] == ITEM_MOVED && !empty($row['topic_moved_id'])) { $topic_id = $row['topic_moved_id']; } // Get folder img, topic status/type related information $folder_img = $folder_alt = $topic_type = ''; topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type); $view_topic_url_params = "f={$forum_id}&t={$topic_id}"; $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", $view_topic_url_params); // Send vars to template $template->assign_block_vars('topicrow', array('FORUM_ID' => $forum_id, 'TOPIC_ID' => $topic_id, 'FIRST_POST_TIME' => $user->format_date($row['topic_time']), 'LAST_POST_SUBJECT' => $row['topic_last_post_subject'], 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), 'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']), 'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'S_DELETED_TOPIC' => !$row['topic_id'] ? true : false, 'S_GLOBAL_TOPIC' => !$forum_id ? true : false, 'PAGINATION' => topic_generate_pagination($replies, append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . ($row['forum_id'] ? $row['forum_id'] : $forum_id) . "&t={$topic_id}")), 'REPLIES' => $replies, 'VIEWS' => $row['topic_views'], 'TOPIC_TITLE' => censor_text($row['topic_title']), 'TOPIC_TYPE' => $topic_type, 'FORUM_NAME' => $row['forum_name'], 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'), 'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt], 'TOPIC_ICON_IMG' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['img'] : '', 'TOPIC_ICON_IMG_WIDTH' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['width'] : '', 'TOPIC_ICON_IMG_HEIGHT' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['height'] : '', 'ATTACH_ICON_IMG' => $auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment'] ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 'S_TOPIC_TYPE' => $row['topic_type'], 'S_USER_POSTED' => !empty($row['topic_posted']) ? true : false, 'S_UNREAD_TOPIC' => $unread_topic, 'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", $view_topic_url_params . '&view=unread') . '#unread', 'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", $view_topic_url_params . '&p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'], 'U_VIEW_TOPIC' => $view_topic_url, 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $forum_id), 'SOLVED_TOPIC' => $row['topic_solved'] && $row['forum_allow_solve'] ? $row['forum_solve_text'] ? $row['forum_solve_text'] : $user->img('icon_topic_solved_list', 'TOPIC_SOLVED') : '', 'U_SOLVED_TOPIC' => $row['topic_solved'] && $row['forum_allow_solve'] ? append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'p=' . $row['topic_solved'] . '#p' . $row['topic_solved']) : '', 'SOLVED_STYLE' => $row['forum_solve_color'] ? ' style="color: #' . $row['forum_solve_color'] . '"' : '')); } }
/** * View topic in MCP */ function mcp_topic_view($id, $mode, $action) { global $phpEx, $phpbb_root_path, $config; global $template, $db, $user, $auth, $cache; $url = append_sid("{$phpbb_root_path}mcp.{$phpEx}?" . extra_url()); $user->add_lang('viewtopic'); $topic_id = request_var('t', 0); $topic_info = get_topic_data(array($topic_id), false, true); if (!sizeof($topic_info)) { trigger_error('TOPIC_NOT_EXIST'); } $topic_info = $topic_info[$topic_id]; // Set up some vars $icon_id = request_var('icon', 0); $subject = utf8_normalize_nfc(request_var('subject', '', true)); $start = request_var('start', 0); $sort_days_old = request_var('st_old', 0); $forum_id = request_var('f', 0); $to_topic_id = request_var('to_topic_id', 0); $to_forum_id = request_var('to_forum_id', 0); $sort = isset($_POST['sort']) ? true : false; $submitted_id_list = request_var('post_ids', array(0)); $checked_ids = $post_id_list = request_var('post_id_list', array(0)); // Resync Topic? if ($action == 'resync') { if (!function_exists('mcp_resync_topics')) { include $phpbb_root_path . 'includes/mcp/mcp_forum.' . $phpEx; } mcp_resync_topics(array($topic_id)); } // Split Topic? if ($action == 'split_all' || $action == 'split_beyond') { if (!$sort) { split_topic($action, $topic_id, $to_forum_id, $subject); } $action = 'split'; } // Merge Posts? if ($action == 'merge_posts') { if (!$sort) { merge_posts($topic_id, $to_topic_id); } $action = 'merge'; } if ($action == 'split' && !$subject) { $subject = $topic_info['topic_title']; } // Approve posts? if ($action == 'approve' && $auth->acl_get('m_approve', $topic_info['forum_id'])) { include $phpbb_root_path . 'includes/mcp/mcp_queue.' . $phpEx; include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx; include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx; if (!sizeof($post_id_list)) { trigger_error('NO_POST_SELECTED'); } if (!$sort) { approve_post($post_id_list, $id, $mode); } } // Jumpbox, sort selects and that kind of things make_jumpbox($url . "&i={$id}&mode=forum_view", $topic_info['forum_id'], false, 'm_', true); $where_sql = $action == 'reports' ? 'WHERE post_reported = 1 AND ' : 'WHERE'; $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $topic_info['forum_id'], $topic_id, $where_sql); $limit_time_sql = $sort_days ? 'AND p.post_time >= ' . (time() - $sort_days * 86400) : ''; if ($total == -1) { if ($auth->acl_get('m_approve', $topic_info['forum_id'])) { $total = $topic_info['topic_replies_real'] + 1; } else { $total = $topic_info['topic_replies'] + 1; } } $posts_per_page = max(0, request_var('posts_per_page', intval($config['posts_per_page']))); if ($posts_per_page == 0) { $posts_per_page = $total; } if (!empty($sort_days_old) && $sort_days_old != $sort_days || $total <= $posts_per_page) { $start = 0; } // Make sure $start is set to the last page if it exceeds the amount if ($start < 0 || $start >= $total) { $start = $start < 0 ? 0 : floor(($total - 1) / $posts_per_page) * $posts_per_page; } $sql = 'SELECT u.username, u.username_clean, u.user_colour, p.* FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE ' . ($action == 'reports' ? 'p.post_reported = 1 AND ' : '') . ' p.topic_id = ' . $topic_id . ' ' . (!$auth->acl_get('m_approve', $topic_info['forum_id']) ? ' AND p.post_approved = 1 ' : '') . ' AND p.poster_id = u.user_id ' . $limit_time_sql . ' ORDER BY ' . $sort_order_sql; $result = $db->sql_query_limit($sql, $posts_per_page, $start); $rowset = $post_id_list = array(); $bbcode_bitfield = ''; while ($row = $db->sql_fetchrow($result)) { $rowset[] = $row; $post_id_list[] = $row['post_id']; $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']); } $db->sql_freeresult($result); if ($bbcode_bitfield !== '') { include_once $phpbb_root_path . 'includes/bbcode.' . $phpEx; $bbcode = new bbcode(base64_encode($bbcode_bitfield)); } $topic_tracking_info = array(); // Get topic tracking info if ($config['load_db_lastread']) { $tmp_topic_data = array($topic_id => $topic_info); $topic_tracking_info = get_topic_tracking($topic_info['forum_id'], $topic_id, $tmp_topic_data, array($topic_info['forum_id'] => $topic_info['forum_mark_time'])); unset($tmp_topic_data); } else { $topic_tracking_info = get_complete_topic_tracking($topic_info['forum_id'], $topic_id); } $has_unapproved_posts = false; // Grab extensions $extensions = $attachments = array(); if ($topic_info['topic_attachment'] && sizeof($post_id_list)) { $extensions = $cache->obtain_attach_extensions($topic_info['forum_id']); // Get attachments... if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_info['forum_id'])) { $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE ' . $db->sql_in_set('post_msg_id', $post_id_list) . ' AND in_message = 0 ORDER BY filetime DESC, post_msg_id ASC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $attachments[$row['post_msg_id']][] = $row; } $db->sql_freeresult($result); } } foreach ($rowset as $i => $row) { $message = $row['post_text']; $post_subject = $row['post_subject'] != '' ? $row['post_subject'] : $topic_info['topic_title']; if ($row['bbcode_bitfield']) { $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); } $message = bbcode_nl2br($message); $message = smiley_text($message); if (!empty($attachments[$row['post_id']])) { $update_count = array(); parse_attachments($topic_info['forum_id'], $message, $attachments[$row['post_id']], $update_count); } if (!$row['post_approved']) { $has_unapproved_posts = true; } $post_unread = isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id] ? true : false; $template->assign_block_vars('postrow', array('POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_DATE' => $user->format_date($row['post_time']), 'POST_SUBJECT' => $post_subject, 'MESSAGE' => $message, 'POST_ID' => $row['post_id'], 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 't=' . $topic_id) . '">', '</a>'), 'MINI_POST_IMG' => $post_unread ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'S_POST_REPORTED' => $row['post_reported'] && $auth->acl_get('m_report', $topic_info['forum_id']), 'S_POST_UNAPPROVED' => !$row['post_approved'] && $auth->acl_get('m_approve', $topic_info['forum_id']), 'S_CHECKED' => $submitted_id_list && !in_array(intval($row['post_id']), $submitted_id_list) || in_array(intval($row['post_id']), $checked_ids) ? true : false, 'S_HAS_ATTACHMENTS' => !empty($attachments[$row['post_id']]) ? true : false, 'U_POST_DETAILS' => "{$url}&i={$id}&p={$row['post_id']}&mode=post_details" . ($forum_id ? "&f={$forum_id}" : ''), 'U_MCP_APPROVE' => $auth->acl_get('m_approve', $topic_info['forum_id']) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&mode=approve_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : '', 'U_MCP_REPORT' => $auth->acl_get('m_report', $topic_info['forum_id']) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&mode=report_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : '')); // Display not already displayed Attachments for this post, we already parsed them. ;) if (!empty($attachments[$row['post_id']])) { foreach ($attachments[$row['post_id']] as $attachment) { $template->assign_block_vars('postrow.attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } } unset($rowset[$i]); } // Display topic icons for split topic $s_topic_icons = false; if ($auth->acl_gets('m_split', 'm_merge', (int) $topic_info['forum_id'])) { include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx; $s_topic_icons = posting_gen_topic_icons('', $icon_id); // Has the user selected a topic for merge? if ($to_topic_id) { $to_topic_info = get_topic_data(array($to_topic_id), 'm_merge'); if (!sizeof($to_topic_info)) { $to_topic_id = 0; } else { $to_topic_info = $to_topic_info[$to_topic_id]; if (!$to_topic_info['enable_icons'] || $auth->acl_get('!f_icons', $topic_info['forum_id'])) { $s_topic_icons = false; } } } } $s_hidden_fields = build_hidden_fields(array('st_old' => $sort_days, 'post_ids' => $post_id_list)); $template->assign_vars(array('TOPIC_TITLE' => $topic_info['topic_title'], 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $topic_info['forum_id'] . '&t=' . $topic_info['topic_id']), 'TO_TOPIC_ID' => $to_topic_id, 'TO_TOPIC_INFO' => $to_topic_id ? sprintf($user->lang['YOU_SELECTED_TOPIC'], $to_topic_id, '<a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $to_topic_info['forum_id'] . '&t=' . $to_topic_id) . '">' . $to_topic_info['topic_title'] . '</a>') : '', 'SPLIT_SUBJECT' => $subject, 'POSTS_PER_PAGE' => $posts_per_page, 'ACTION' => $action, 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'), 'S_MCP_ACTION' => "{$url}&i={$id}&mode={$mode}&action={$action}&start={$start}", 'S_FORUM_SELECT' => $to_forum_id ? make_forum_select($to_forum_id, false, false, true, true, true) : make_forum_select($topic_info['forum_id'], false, false, true, true, true), 'S_CAN_SPLIT' => $auth->acl_get('m_split', $topic_info['forum_id']) ? true : false, 'S_CAN_MERGE' => $auth->acl_get('m_merge', $topic_info['forum_id']) ? true : false, 'S_CAN_DELETE' => $auth->acl_get('m_delete', $topic_info['forum_id']) ? true : false, 'S_CAN_APPROVE' => $has_unapproved_posts && $auth->acl_get('m_approve', $topic_info['forum_id']) ? true : false, 'S_CAN_LOCK' => $auth->acl_get('m_lock', $topic_info['forum_id']) ? true : false, 'S_CAN_REPORT' => $auth->acl_get('m_report', $topic_info['forum_id']) ? true : false, 'S_CAN_SYNC' => $auth->acl_get('m_', $topic_info['forum_id']), 'S_REPORT_VIEW' => $action == 'reports' ? true : false, 'S_MERGE_VIEW' => $action == 'merge' ? true : false, 'S_SPLIT_VIEW' => $action == 'split' ? true : false, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, 'S_TOPIC_ICON' => $icon_id, 'U_SELECT_TOPIC' => "{$url}&i={$id}&mode=forum_view&action=merge_select" . ($forum_id ? "&f={$forum_id}" : ''), 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$topic_info['forum_id']}&t={$topic_info['topic_id']}&start={$start}") . '">', '</a>'), 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.{$phpEx}", "f={$topic_info['forum_id']}&start={$start}") . '">', '</a>'), 'PAGE_NUMBER' => on_page($total, $posts_per_page, $start), 'PAGINATION' => !$posts_per_page ? '' : generate_pagination(append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&t={$topic_info['topic_id']}&mode={$mode}&action={$action}&to_topic_id={$to_topic_id}&posts_per_page={$posts_per_page}&st={$sort_days}&sk={$sort_key}&sd={$sort_dir}"), $total, $posts_per_page, $start), 'TOTAL_POSTS' => $total == 1 ? $user->lang['VIEW_TOPIC_POST'] : sprintf($user->lang['VIEW_TOPIC_POSTS'], $total))); }
} // What is start equal to? if ($post_id) { $start = floor($topic_data['prev_posts'] / $config['posts_per_page']) * $config['posts_per_page']; } // Get topic tracking info if (!isset($topic_tracking_info)) { $topic_tracking_info = array(); // Get topic tracking info if ($config['load_db_lastread'] && $user->data['is_registered']) { $tmp_topic_data = array($topic_id => $topic_data); $topic_tracking_info = get_topic_tracking($forum_id, $topic_id, $tmp_topic_data, array($forum_id => $topic_data['forum_mark_time'])); unset($tmp_topic_data); } else { if ($config['load_anon_lastread'] || $user->data['is_registered']) { $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id); } } } // Post ordering options $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']); $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); $sort_by_sql = array('a' => array('u.username_clean', 'p.post_id'), 't' => array('p.post_time', 'p.post_id'), 's' => array('p.post_subject', 'p.post_id')); $join_user_sql = array('a' => true, 't' => false, 's' => false); $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; 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, $default_sort_days, $default_sort_key, $default_sort_dir); // Obtain correct post count and ordering SQL if user has // requested anything different if ($sort_days) { $min_post_time = time() - $sort_days * 86400; $sql = 'SELECT COUNT(post_id) AS num_posts
/** * Handling actions in post details screen */ function mcp_post_details($id, $mode, $action) { global $phpEx, $phpbb_root_path, $config; global $template, $db, $user, $auth, $cache; $user->add_lang('posting'); $post_id = request_var('p', 0); $start = request_var('start', 0); // Get post data $post_info = get_post_data(array($post_id), false, true); add_form_key('mcp_post_details'); if (!sizeof($post_info)) { trigger_error('POST_NOT_EXIST'); } $post_info = $post_info[$post_id]; $url = append_sid("{$phpbb_root_path}mcp.{$phpEx}?" . extra_url()); switch ($action) { case 'whois': if ($auth->acl_get('m_info', $post_info['forum_id'])) { $ip = request_var('ip', ''); include $phpbb_root_path . 'includes/functions_user.' . $phpEx; $template->assign_vars(array('RETURN_POST' => sprintf($user->lang['RETURN_POST'], '<a href="' . append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&mode={$mode}&p={$post_id}") . '">', '</a>'), 'U_RETURN_POST' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&mode={$mode}&p={$post_id}"), 'L_RETURN_POST' => sprintf($user->lang['RETURN_POST'], '', ''), 'WHOIS' => user_ipwhois($ip))); } // We're done with the whois page so return return; break; case 'chgposter': case 'chgposter_ip': if ($action == 'chgposter') { $username = request_var('username', '', true); $sql_where = "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; } else { $new_user_id = request_var('u', 0); $sql_where = 'user_id = ' . $new_user_id; } $sql = 'SELECT * FROM ' . USERS_TABLE . ' WHERE ' . $sql_where; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$row) { trigger_error('NO_USER'); } if ($auth->acl_get('m_chgposter', $post_info['forum_id'])) { if (check_form_key('mcp_post_details')) { change_poster($post_info, $row); } else { trigger_error('FORM_INVALID'); } } break; } // Set some vars $users_ary = $usernames_ary = array(); $attachments = $extensions = array(); $post_id = $post_info['post_id']; $topic_tracking_info = array(); // Get topic tracking info if ($config['load_db_lastread']) { $tmp_topic_data = array($post_info['topic_id'] => $post_info); $topic_tracking_info = get_topic_tracking($post_info['forum_id'], $post_info['topic_id'], $tmp_topic_data, array($post_info['forum_id'] => $post_info['forum_mark_time'])); unset($tmp_topic_data); } else { $topic_tracking_info = get_complete_topic_tracking($post_info['forum_id'], $post_info['topic_id']); } $post_unread = isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']] ? true : false; // Process message, leave it uncensored $message = $post_info['post_text']; if ($post_info['bbcode_bitfield']) { include_once $phpbb_root_path . 'includes/bbcode.' . $phpEx; $bbcode = new bbcode($post_info['bbcode_bitfield']); $bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']); } $message = bbcode_nl2br($message); $message = smiley_text($message); if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) { $extensions = $cache->obtain_attach_extensions($post_info['forum_id']); $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE post_msg_id = ' . $post_id . ' AND in_message = 0 ORDER BY filetime DESC, post_msg_id ASC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $attachments[] = $row; } $db->sql_freeresult($result); if (sizeof($attachments)) { $update_count = array(); parse_attachments($post_info['forum_id'], $message, $attachments, $update_count); } // Display not already displayed Attachments for this post, we already parsed them. ;) if (!empty($attachments)) { $template->assign_var('S_HAS_ATTACHMENTS', true); foreach ($attachments as $attachment) { $template->assign_block_vars('attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } } } $template->assign_vars(array('U_MCP_ACTION' => "{$url}&i=main&quickmod=1&mode=post_details", 'U_POST_ACTION' => "{$url}&i={$id}&mode=post_details", 'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=queue&p={$post_id}&f={$post_info['forum_id']}"), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_CAN_CHGPOSTER' => $auth->acl_get('m_chgposter', $post_info['forum_id']), 'S_CAN_LOCK_POST' => $auth->acl_get('m_lock', $post_info['forum_id']), 'S_CAN_DELETE_POST' => $auth->acl_get('m_delete', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'] ? true : false, 'S_POST_UNAPPROVED' => !$post_info['post_approved'] ? true : false, 'S_POST_LOCKED' => $post_info['post_edit_locked'] ? true : false, 'S_USER_NOTES' => true, 'S_CLEAR_ALLOWED' => $auth->acl_get('a_clearlogs') ? true : false, 'U_EDIT' => $auth->acl_get('m_edit', $post_info['forum_id']) ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '', 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=searchuser&form=mcp_chgposter&field=username&select_single=true'), 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&mode=user_notes&u=' . $post_info['user_id']), 'U_MCP_WARN_USER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&mode=warn_user&u=' . $post_info['user_id']) : '', 'U_VIEW_POST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']), 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']), 'MINI_POST_IMG' => $post_unread ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$post_info['forum_id']}&p={$post_id}") . "#p{$post_id}\">", '</a>'), 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.{$phpEx}", "f={$post_info['forum_id']}&start={$start}") . '">', '</a>'), 'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']), 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']), 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), 'POST_AUTHOR_FULL' => get_username_string('full', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_AUTHOR' => get_username_string('username', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), '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' => $auth->acl_get('m_info', $post_info['forum_id']) && request_var('lookup', '') ? @gethostbyaddr($post_info['poster_ip']) : '', 'POST_ID' => $post_info['post_id'], 'U_LOOKUP_IP' => $auth->acl_get('m_info', $post_info['forum_id']) ? "{$url}&i={$id}&mode={$mode}&lookup={$post_info['poster_ip']}#ip" : '', 'U_WHOIS' => $auth->acl_get('m_info', $post_info['forum_id']) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&mode={$mode}&action=whois&p={$post_id}&ip={$post_info['poster_ip']}") : '')); // Get User Notes $log_data = array(); $log_count = false; view_log('user', $log_data, $log_count, $config['posts_per_page'], 0, 0, 0, $post_info['user_id']); if (!empty($log_data)) { $template->assign_var('S_USER_NOTES', true); foreach ($log_data as $row) { $template->assign_block_vars('usernotes', array('REPORT_BY' => $row['username_full'], 'REPORT_AT' => $user->format_date($row['time']), 'ACTION' => $row['action'], 'ID' => $row['id'])); } } // Get Reports if ($auth->acl_get('m_report', $post_info['forum_id'])) { $sql = 'SELECT r.*, re.*, u.user_id, u.username FROM ' . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u, ' . REPORTS_REASONS_TABLE . " re\n\t\t\tWHERE r.post_id = {$post_id}\n\t\t\t\tAND r.reason_id = re.reason_id\n\t\t\t\tAND u.user_id = r.user_id\n\t\t\tORDER BY r.report_time DESC"; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { $template->assign_var('S_SHOW_REPORTS', true); do { // If the reason is defined within the language file, we will use the localized version, else just use the database entry... if (isset($user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])])) { $row['reson_description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]; $row['reason_title'] = $user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])]; } $template->assign_block_vars('reports', array('REPORT_ID' => $row['report_id'], 'REASON_TITLE' => $row['reason_title'], 'REASON_DESC' => $row['reason_description'], 'REPORTER' => $row['user_id'] != ANONYMOUS ? $row['username'] : $user->lang['GUEST'], 'U_REPORTER' => $row['user_id'] != ANONYMOUS ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=viewprofile&u=' . $row['user_id']) : '', 'USER_NOTIFY' => $row['user_notify'] ? true : false, 'REPORT_TIME' => $user->format_date($row['report_time']), 'REPORT_TEXT' => bbcode_nl2br(trim($row['report_text'])))); } while ($row = $db->sql_fetchrow($result)); } $db->sql_freeresult($result); } // Get IP if ($auth->acl_get('m_info', $post_info['forum_id'])) { $rdns_ip_num = request_var('rdns', ''); if ($rdns_ip_num != 'all') { $template->assign_vars(array('U_LOOKUP_ALL' => "{$url}&i=main&mode=post_details&rdns=all")); } // Get other users who've posted under this IP $sql = 'SELECT poster_id, COUNT(poster_id) as postings FROM ' . POSTS_TABLE . "\n\t\t\tWHERE poster_ip = '" . $db->sql_escape($post_info['poster_ip']) . "'\n\t\t\tGROUP BY poster_id\n\t\t\tORDER BY postings DESC"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { // Fill the user select list with users who have posted under this IP if ($row['poster_id'] != $post_info['poster_id']) { $users_ary[$row['poster_id']] = $row; } } $db->sql_freeresult($result); if (sizeof($users_ary)) { // Get the usernames $sql = 'SELECT user_id, username FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', array_keys($users_ary)); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $users_ary[$row['user_id']]['username'] = $row['username']; $usernames_ary[utf8_clean_string($row['username'])] = $users_ary[$row['user_id']]; } $db->sql_freeresult($result); foreach ($users_ary as $user_id => $user_row) { $template->assign_block_vars('userrow', array('USERNAME' => $user_id == ANONYMOUS ? $user->lang['GUEST'] : $user_row['username'], 'NUM_POSTS' => $user_row['postings'], 'L_POST_S' => $user_row['postings'] == 1 ? $user->lang['POST'] : $user->lang['POSTS'], 'U_PROFILE' => $user_id == ANONYMOUS ? '' : append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=viewprofile&u=' . $user_id), 'U_SEARCHPOSTS' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'author_id=' . $user_id . '&sr=topics'))); } } // Get other IP's this user has posted under // A compound index on poster_id, poster_ip (posts table) would help speed up this query a lot, // but the extra size is only valuable if there are persons having more than a thousands posts. // This is better left to the really really big forums. $sql = 'SELECT poster_ip, COUNT(poster_ip) AS postings FROM ' . POSTS_TABLE . ' WHERE poster_id = ' . $post_info['poster_id'] . "\n\t\t\tGROUP BY poster_ip\n\t\t\tORDER BY postings DESC"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $hostname = ($rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all') && $row['poster_ip'] ? @gethostbyaddr($row['poster_ip']) : ''; $template->assign_block_vars('iprow', array('IP' => $row['poster_ip'], 'HOSTNAME' => $hostname, 'NUM_POSTS' => $row['postings'], 'L_POST_S' => $row['postings'] == 1 ? $user->lang['POST'] : $user->lang['POSTS'], 'U_LOOKUP_IP' => $rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all' ? '' : "{$url}&i={$id}&mode=post_details&rdns={$row['poster_ip']}#ip", 'U_WHOIS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&mode={$mode}&action=whois&p={$post_id}&ip={$row['poster_ip']}"))); } $db->sql_freeresult($result); $user_select = ''; if (sizeof($usernames_ary)) { ksort($usernames_ary); foreach ($usernames_ary as $row) { $user_select .= '<option value="' . $row['poster_id'] . '">' . $row['username'] . "</option>\n"; } } $template->assign_var('S_USER_SELECT', $user_select); } }
function main($id, $mode) { global $auth, $db, $user, $template, $cache; global $config, $phpbb_root_path, $phpEx, $action; include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx; $forum_id = request_var('f', 0); $start = request_var('start', 0); $this->page_title = 'MCP_QUEUE'; switch ($action) { case 'approve': case 'disapprove': include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx; $post_id_list = request_var('post_id_list', array(0)); if (!sizeof($post_id_list)) { trigger_error('NO_POST_SELECTED'); } if ($action == 'approve') { approve_post($post_id_list, 'queue', $mode); } else { disapprove_post($post_id_list, 'queue', $mode); } break; } switch ($mode) { case 'approve_details': $this->tpl_name = 'mcp_post'; $user->add_lang(array('posting', 'viewtopic')); $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'); if (isset($topic_info[$topic_id]['topic_first_post_id'])) { $post_id = (int) $topic_info[$topic_id]['topic_first_post_id']; } else { $topic_id = 0; } } $post_info = get_post_data(array($post_id), 'm_approve', true); if (!sizeof($post_info)) { trigger_error('NO_POST_SELECTED'); } $post_info = $post_info[$post_id]; if ($post_info['topic_first_post_id'] != $post_id && topic_review($post_info['topic_id'], $post_info['forum_id'], 'topic_review', 0, false)) { $template->assign_vars(array('S_TOPIC_REVIEW' => true, 'TOPIC_TITLE' => $post_info['topic_title'])); } $extensions = $attachments = $topic_tracking_info = array(); // Get topic tracking info if ($config['load_db_lastread']) { $tmp_topic_data = array($post_info['topic_id'] => $post_info); $topic_tracking_info = get_topic_tracking($post_info['forum_id'], $post_info['topic_id'], $tmp_topic_data, array($post_info['forum_id'] => $post_info['forum_mark_time'])); unset($tmp_topic_data); } else { $topic_tracking_info = get_complete_topic_tracking($post_info['forum_id'], $post_info['topic_id']); } $post_unread = isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']] ? true : false; // Process message, leave it uncensored $message = $post_info['post_text']; if ($post_info['bbcode_bitfield']) { include_once $phpbb_root_path . 'includes/bbcode.' . $phpEx; $bbcode = new bbcode($post_info['bbcode_bitfield']); $bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']); } $message = bbcode_nl2br($message); $message = smiley_text($message); if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) { $extensions = $cache->obtain_attach_extensions($post_info['forum_id']); $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE post_msg_id = ' . $post_id . ' AND in_message = 0 ORDER BY filetime DESC, post_msg_id ASC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $attachments[] = $row; } $db->sql_freeresult($result); if (sizeof($attachments)) { $update_count = array(); parse_attachments($post_info['forum_id'], $message, $attachments, $update_count); } // Display not already displayed Attachments for this post, we already parsed them. ;) if (!empty($attachments)) { $template->assign_var('S_HAS_ATTACHMENTS', true); foreach ($attachments as $attachment) { $template->assign_block_vars('attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } } } $post_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']); $topic_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']); $template->assign_vars(array('S_MCP_QUEUE' => true, 'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=queue&p={$post_id}&f={$forum_id}"), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'], 'S_POST_UNAPPROVED' => !$post_info['post_approved'], 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_USER_NOTES' => true, 'U_EDIT' => $auth->acl_get('m_edit', $post_info['forum_id']) ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '', 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&mode=user_notes&u=' . $post_info['user_id']), 'U_MCP_WARN_USER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&mode=warn_user&u=' . $post_info['user_id']) : '', 'U_VIEW_POST' => $post_url, 'U_VIEW_TOPIC' => $topic_url, 'MINI_POST_IMG' => $post_unread ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'), 'RETURN_QUEUE' => sprintf($user->lang['RETURN_QUEUE'], '<a href="' . append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue' . ($topic_id ? '&mode=unapproved_topics' : '&mode=unapproved_posts')) . "&start={$start}\">", '</a>'), 'RETURN_POST' => sprintf($user->lang['RETURN_POST'], '<a href="' . $post_url . '">', '</a>'), 'RETURN_TOPIC_SIMPLE' => sprintf($user->lang['RETURN_TOPIC_SIMPLE'], '<a href="' . $topic_url . '">', '</a>'), 'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']), 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']), 'POST_AUTHOR_FULL' => get_username_string('full', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_AUTHOR' => get_username_string('username', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), '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' => $auth->acl_get('m_info', $post_info['forum_id']) && request_var('lookup', '') ? @gethostbyaddr($post_info['poster_ip']) : '', 'POST_ID' => $post_info['post_id'], 'U_LOOKUP_IP' => $auth->acl_get('m_info', $post_info['forum_id']) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id . '&lookup=' . $post_info['poster_ip']) . '#ip' : '')); break; case 'unapproved_topics': case 'unapproved_posts': $user->add_lang(array('viewtopic', 'viewforum')); $topic_id = request_var('t', 0); $forum_info = array(); if ($topic_id) { $topic_info = get_topic_data(array($topic_id)); if (!sizeof($topic_info)) { trigger_error('TOPIC_NOT_EXIST'); } $topic_info = $topic_info[$topic_id]; $forum_id = $topic_info['forum_id']; } $forum_list_approve = get_forum_list('m_approve', false, true); $forum_list_read = array_flip(get_forum_list('f_read', true, true)); // Flipped so we can isset() the forum IDs // Remove forums we cannot read foreach ($forum_list_approve as $k => $forum_data) { if (!isset($forum_list_read[$forum_data['forum_id']])) { unset($forum_list_approve[$k]); } } unset($forum_list_read); if (!$forum_id) { $forum_list = array(); foreach ($forum_list_approve as $row) { $forum_list[] = $row['forum_id']; } if (!sizeof($forum_list)) { trigger_error('NOT_MODERATOR'); } $global_id = $forum_list[0]; $forum_list = implode(', ', $forum_list); $sql = 'SELECT SUM(forum_topics) as sum_forum_topics FROM ' . FORUMS_TABLE . "\n\t\t\t\t\t\tWHERE forum_id IN (0, {$forum_list})"; $result = $db->sql_query($sql); $forum_info['forum_topics'] = (int) $db->sql_fetchfield('sum_forum_topics'); $db->sql_freeresult($result); } else { $forum_info = get_forum_data(array($forum_id), 'm_approve'); if (!sizeof($forum_info)) { trigger_error('NOT_MODERATOR'); } $forum_info = $forum_info[$forum_id]; $forum_list = $forum_id; $global_id = $forum_id; } $forum_options = '<option value="0"' . ($forum_id == 0 ? ' selected="selected"' : '') . '>' . $user->lang['ALL_FORUMS'] . '</option>'; foreach ($forum_list_approve as $row) { $forum_options .= '<option value="' . $row['forum_id'] . '"' . ($forum_id == $row['forum_id'] ? ' selected="selected"' : '') . '>' . str_repeat(' ', $row['padding']) . $row['forum_name'] . '</option>'; } $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id); $forum_topics = $total == -1 ? $forum_info['forum_topics'] : $total; $limit_time_sql = $sort_days ? 'AND t.topic_last_post_time >= ' . (time() - $sort_days * 86400) : ''; $forum_names = array(); if ($mode == 'unapproved_posts') { $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . ($sort_order_sql[0] == 'u' ? ', ' . USERS_TABLE . ' u' : '') . "\n\t\t\t\t\t\tWHERE p.forum_id IN (0, {$forum_list})\n\t\t\t\t\t\t\tAND p.post_approved = 0\n\t\t\t\t\t\t\t" . ($sort_order_sql[0] == 'u' ? 'AND u.user_id = p.poster_id' : '') . ' ' . ($topic_id ? 'AND p.topic_id = ' . $topic_id : '') . "\n\t\t\t\t\t\t\tAND t.topic_id = p.topic_id\n\t\t\t\t\t\t\tAND t.topic_first_post_id <> p.post_id\n\t\t\t\t\t\t\t{$limit_time_sql}\n\t\t\t\t\t\tORDER BY {$sort_order_sql}"; $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); $i = 0; $post_ids = array(); while ($row = $db->sql_fetchrow($result)) { $post_ids[] = $row['post_id']; $row_num[$row['post_id']] = $i++; } $db->sql_freeresult($result); if (sizeof($post_ids)) { $sql = 'SELECT t.topic_id, t.topic_title, t.forum_id, p.post_id, p.post_subject, p.post_username, p.poster_id, p.post_time, u.username, u.username_clean, u.user_colour FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u WHERE ' . $db->sql_in_set('p.post_id', $post_ids) . ' AND t.topic_id = p.topic_id AND u.user_id = p.poster_id ORDER BY ' . $sort_order_sql; $result = $db->sql_query($sql); $post_data = $rowset = array(); while ($row = $db->sql_fetchrow($result)) { if ($row['forum_id']) { $forum_names[] = $row['forum_id']; } $post_data[$row['post_id']] = $row; } $db->sql_freeresult($result); foreach ($post_ids as $post_id) { $rowset[] = $post_data[$post_id]; } unset($post_data, $post_ids); } else { $rowset = array(); } } else { $sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, t.topic_title AS post_subject, t.topic_time AS post_time, t.topic_poster AS poster_id, t.topic_first_post_id AS post_id, t.topic_first_poster_name AS username, t.topic_first_poster_colour AS user_colour FROM ' . TOPICS_TABLE . " t\n\t\t\t\t\t\tWHERE forum_id IN (0, {$forum_list})\n\t\t\t\t\t\t\tAND topic_approved = 0\n\t\t\t\t\t\t\t{$limit_time_sql}\n\t\t\t\t\t\tORDER BY {$sort_order_sql}"; $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); $rowset = array(); while ($row = $db->sql_fetchrow($result)) { if ($row['forum_id']) { $forum_names[] = $row['forum_id']; } $rowset[] = $row; } $db->sql_freeresult($result); } if (sizeof($forum_names)) { // Select the names for the forum_ids $sql = 'SELECT forum_id, forum_name FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_names); $result = $db->sql_query($sql, 3600); $forum_names = array(); while ($row = $db->sql_fetchrow($result)) { $forum_names[$row['forum_id']] = $row['forum_name']; } $db->sql_freeresult($result); } foreach ($rowset as $row) { $global_topic = $row['forum_id'] ? false : true; if ($global_topic) { $row['forum_id'] = $global_id; } if (empty($row['post_username'])) { $row['post_username'] = $user->lang['GUEST']; } $template->assign_block_vars('postrow', array('U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']), 'U_VIEWFORUM' => !$global_topic ? append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']) : '', 'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&p=' . $row['post_id']) . ($mode == 'unapproved_posts' ? '#p' . $row['post_id'] : ''), 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=queue&start={$start}&mode=approve_details&f={$row['forum_id']}&p={$row['post_id']}" . ($mode == 'unapproved_topics' ? "&t={$row['topic_id']}" : '')), 'POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_ID' => $row['post_id'], 'FORUM_NAME' => !$global_topic ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'], 'POST_SUBJECT' => $row['post_subject'], 'TOPIC_TITLE' => $row['topic_title'], 'POST_TIME' => $user->format_date($row['post_time']))); } unset($rowset, $forum_names); // Now display the page $template->assign_vars(array('L_DISPLAY_ITEMS' => $mode == 'unapproved_posts' ? $user->lang['DISPLAY_POSTS'] : $user->lang['DISPLAY_TOPICS'], 'L_EXPLAIN' => $mode == 'unapproved_posts' ? $user->lang['MCP_QUEUE_UNAPPROVED_POSTS_EXPLAIN'] : $user->lang['MCP_QUEUE_UNAPPROVED_TOPICS_EXPLAIN'], 'L_TITLE' => $mode == 'unapproved_posts' ? $user->lang['MCP_QUEUE_UNAPPROVED_POSTS'] : $user->lang['MCP_QUEUE_UNAPPROVED_TOPICS'], 'L_ONLY_TOPIC' => $topic_id ? sprintf($user->lang['ONLY_TOPIC'], $topic_info['topic_title']) : '', 'S_FORUM_OPTIONS' => $forum_options, 'S_MCP_ACTION' => build_url(array('t', 'f', 'sd', 'st', 'sk')), 'S_TOPICS' => $mode == 'unapproved_posts' ? false : true, 'PAGINATION' => generate_pagination($this->u_action . "&f={$forum_id}&st={$sort_days}&sk={$sort_key}&sd={$sort_dir}", $total, $config['topics_per_page'], $start), 'PAGE_NUMBER' => on_page($total, $config['topics_per_page'], $start), 'TOPIC_ID' => $topic_id, 'TOTAL' => $total == 1 ? $mode == 'unapproved_posts' ? $user->lang['VIEW_TOPIC_POST'] : $user->lang['VIEW_FORUM_TOPIC'] : sprintf($mode == 'unapproved_posts' ? $user->lang['VIEW_TOPIC_POSTS'] : $user->lang['VIEW_FORUM_TOPICS'], $total))); $this->tpl_name = 'mcp_queue'; break; } }
function main($id, $mode) { global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx; switch ($mode) { case 'front': $user->add_lang('memberlist'); $sql_from = TOPICS_TABLE . ' t '; $sql_select = ''; if ($config['load_db_track']) { $sql_from .= ' LEFT JOIN ' . TOPICS_POSTED_TABLE . ' tp ON (tp.topic_id = t.topic_id AND tp.user_id = ' . $user->data['user_id'] . ')'; $sql_select .= ', tp.topic_posted'; } if ($config['load_db_lastread']) { $sql_from .= ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id'] . ')'; $sql_select .= ', tt.mark_time'; } $topic_type = $user->lang['VIEW_TOPIC_ANNOUNCEMENT']; $folder = 'folder_announce'; $folder_new = $folder . '_new'; // Get cleaned up list... return only those forums not having the f_read permission $forum_ary = $auth->acl_getf('!f_read', true); $forum_ary = array_unique(array_keys($forum_ary)); // Determine first forum the user is able to read into - for global announcement link $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' WHERE forum_type = ' . FORUM_POST; if (sizeof($forum_ary)) { $sql .= ' AND forum_id NOT IN ( ' . implode(', ', $forum_ary) . ')'; } $result = $db->sql_query_limit($sql, 1); $g_forum_id = (int) $db->sql_fetchfield('forum_id'); $db->sql_freeresult($result); $sql = "SELECT t.* {$sql_select} \n\t\t\t\t\tFROM {$sql_from}\n\t\t\t\t\tWHERE t.forum_id = 0\n\t\t\t\t\t\tAND t.topic_type = " . POST_GLOBAL . ' ORDER BY t.topic_last_post_time DESC'; $result = $db->sql_query($sql); $topic_list = $rowset = array(); while ($row = $db->sql_fetchrow($result)) { $topic_list[] = $row['topic_id']; $rowset[$row['topic_id']] = $row; } $db->sql_freeresult($result); $topic_tracking_info = array(); if ($config['load_db_lastread']) { $topic_tracking_info = get_topic_tracking(0, $topic_list, $rowset, false, $topic_list); } else { $topic_tracking_info = get_complete_topic_tracking(0, $topic_list, $topic_list); } foreach ($topic_list as $topic_id) { $row =& $rowset[$topic_id]; $forum_id = $row['forum_id']; $topic_id = $row['topic_id']; $unread_topic = isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id] ? true : false; if ($row['topic_status'] == ITEM_LOCKED) { $topic_type = $user->lang['VIEW_TOPIC_LOCKED']; $folder = 'folder_locked'; $folder_new = 'folder_locked_new'; } $folder_img = $unread_topic ? $folder_new : $folder; $folder_alt = $unread_topic ? 'NEW_POSTS' : ($row['topic_status'] == ITEM_LOCKED ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS'); // Posted image? if (!empty($row['topic_posted']) && $row['topic_posted']) { $folder_img .= '_posted'; } $template->assign_block_vars('topicrow', array('FORUM_ID' => $forum_id, 'TOPIC_ID' => $topic_id, 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), 'LAST_POST_AUTHOR' => $row['topic_last_poster_id'] == ANONYMOUS ? $row['topic_last_poster_name'] != '' ? $row['topic_last_poster_name'] . ' ' : $user->lang['GUEST'] . ' ' : $row['topic_last_poster_name'], 'TOPIC_TITLE' => censor_text($row['topic_title']), 'TOPIC_TYPE' => $topic_type, 'LAST_POST_IMG' => $user->img('icon_post_latest', 'VIEW_LATEST_POST'), 'NEWEST_POST_IMG' => $user->img('icon_post_newest', 'VIEW_NEWEST_POST'), 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'), 'ATTACH_ICON_IMG' => $auth->acl_gets('f_download', 'u_download', $forum_id) && $row['topic_attachment'] ? $user->img('icon_attach', '') : '', 'S_USER_POSTED' => !empty($row['topic_posted']) && $row['topic_posted'] ? true : false, 'S_UNREAD' => $unread_topic, 'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$g_forum_id}&t={$topic_id}&p=" . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'], 'U_LAST_POST_AUTHOR' => $row['topic_last_poster_id'] != ANONYMOUS ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=viewprofile&u=' . $row['topic_last_poster_id']) : '', 'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$g_forum_id}&t={$topic_id}&view=unread") . '#unread', 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$g_forum_id}&t={$topic_id}"))); } if ($config['load_user_activity']) { if (!function_exists('display_user_activity')) { include_once $phpbb_root_path . 'includes/functions_display.' . $phpEx; } display_user_activity($user->data); } // Do the relevant calculations $memberdays = max(1, round((time() - $user->data['user_regdate']) / 86400)); $posts_per_day = $user->data['user_posts'] / $memberdays; $percentage = $config['num_posts'] ? min(100, $user->data['user_posts'] / $config['num_posts'] * 100) : 0; $template->assign_vars(array('USER_COLOR' => !empty($user->data['user_colour']) ? $user->data['user_colour'] : '', 'JOINED' => $user->format_date($user->data['user_regdate']), 'VISITED' => empty($last_visit) ? ' - ' : $user->format_date($last_visit), 'WARNINGS' => $user->data['user_warnings'] ? $user->data['user_warnings'] : 0, 'POSTS' => $user->data['user_posts'] ? $user->data['user_posts'] : 0, 'POSTS_DAY' => sprintf($user->lang['POST_DAY'], $posts_per_day), 'POSTS_PCT' => sprintf($user->lang['POST_PCT'], $percentage), 'OCCUPATION' => !empty($row['user_occ']) ? $row['user_occ'] : '', 'INTERESTS' => !empty($row['user_interests']) ? $row['user_interests'] : '', 'S_SHOW_ACTIVITY' => $config['load_user_activity'] ? true : false, 'U_SEARCH_USER' => $auth->acl_get('u_search') ? append_sid("{$phpbb_root_path}search.{$phpEx}", 'author_id=' . $user->data['user_id'] . '&sr=posts') : '')); break; case 'subscribed': include $phpbb_root_path . 'includes/functions_display.' . $phpEx; $user->add_lang('viewforum'); $unwatch = isset($_POST['unwatch']) ? true : false; if ($unwatch) { $forums = isset($_POST['f']) ? implode(', ', array_map('intval', array_keys($_POST['f']))) : false; $topics = isset($_POST['t']) ? implode(', ', array_map('intval', array_keys($_POST['t']))) : false; if ($forums || $topics) { $l_unwatch = ''; if ($forums) { $sql = 'DELETE FROM ' . FORUMS_WATCH_TABLE . "\n\t\t\t\t\t\t\t\tWHERE forum_id IN ({$forums}) \n\t\t\t\t\t\t\t\t\tAND user_id = " . $user->data['user_id']; $db->sql_query($sql); $l_unwatch .= '_FORUMS'; } if ($topics) { $sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . "\n\t\t\t\t\t\t\t\tWHERE topic_id IN ({$topics}) \n\t\t\t\t\t\t\t\t\tAND user_id = " . $user->data['user_id']; $db->sql_query($sql); $l_unwatch .= '_TOPICS'; } $message = $user->lang['UNWATCHED' . $l_unwatch] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . append_sid("{$phpbb_root_path}ucp.{$phpEx}", "i={$id}&mode=subscribed") . '">', '</a>'); meta_refresh(3, append_sid("{$phpbb_root_path}ucp.{$phpEx}", "i={$id}&mode=subscribed")); trigger_error($message); } } $sql_array = array('SELECT' => 'f.*', 'FROM' => array(FORUMS_WATCH_TABLE => 'fw', FORUMS_TABLE => 'f'), 'WHERE' => 'fw.user_id = ' . $user->data['user_id'] . ' AND f.forum_id = fw.forum_id', 'ORDER_BY' => 'left_id'); if ($config['load_db_lastread']) { $sql_array['LEFT_JOIN'] = array(array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id')); $sql_array['SELECT'] .= ', ft.mark_time '; } else { $tracking_topics = isset($_COOKIE[$config['cookie_name'] . '_track']) ? STRIP ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track'] : ''; $tracking_topics = $tracking_topics ? unserialize($tracking_topics) : array(); } $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $forum_id = $row['forum_id']; if ($config['load_db_lastread']) { $forum_check = !empty($row['mark_time']) ? $row['mark_time'] : $user->data['user_lastmark']; } else { $forum_check = isset($tracking_topics['f'][$forum_id]) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark']; } $unread_forum = $row['forum_last_post_time'] > $forum_check ? true : false; // Which folder should we display? if ($row['forum_status'] == ITEM_LOCKED) { $folder_image = $unread_forum ? 'folder_locked_new' : 'folder_locked'; $folder_alt = 'FORUM_LOCKED'; } else { $folder_image = $unread_forum ? 'folder_new' : 'folder'; $folder_alt = $unread_forum ? 'NEW_POSTS' : 'NO_NEW_POSTS'; } // Create last post link information, if appropriate if ($row['forum_last_post_id']) { $last_post_time = $user->format_date($row['forum_last_post_time']); $last_poster = $row['forum_last_poster_name'] != '' ? $row['forum_last_poster_name'] : $user->lang['GUEST']; $last_poster_url = $row['forum_last_poster_id'] == ANONYMOUS ? '' : append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=viewprofile&u=' . $row['forum_last_poster_id']); $last_post_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&p=" . $row['forum_last_post_id']) . '#p' . $row['forum_last_post_id']; } else { $last_post_time = $last_poster = $last_poster_url = $last_post_url = ''; } $template->assign_block_vars('forumrow', array('FORUM_ID' => $forum_id, 'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt), 'FORUM_FOLDER_IMG_SRC' => $user->img($folder_image, $folder_alt, false, '', 'src'), 'FORUM_NAME' => $row['forum_name'], 'LAST_POST_IMG' => $user->img('icon_post_latest', 'VIEW_LATEST_POST'), 'LAST_POST_TIME' => $last_post_time, 'LAST_POST_AUTHOR' => $last_poster, 'U_LAST_POST_AUTHOR' => $last_poster_url, 'U_LAST_POST' => $last_post_url, 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']))); } $db->sql_freeresult($result); // Subscribed Topics $start = request_var('start', 0); $sql = 'SELECT COUNT(topic_id) as topics_count FROM ' . TOPICS_WATCH_TABLE . ' WHERE user_id = ' . $user->data['user_id']; $result = $db->sql_query($sql); $topics_count = (int) $db->sql_fetchfield('topics_count'); $db->sql_freeresult($result); if ($topics_count) { $template->assign_vars(array('PAGINATION' => generate_pagination($this->u_action, $topics_count, $config['topics_per_page'], $start), 'PAGE_NUMBER' => on_page($topics_count, $config['topics_per_page'], $start), 'TOTAL_TOPICS' => $topics_count == 1 ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $topics_count))); } $sql_array = array('SELECT' => 't.*', 'FROM' => array(TOPICS_WATCH_TABLE => 'tw', TOPICS_TABLE => 't'), 'WHERE' => 'tw.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tw.topic_id', 'ORDER_BY' => 't.topic_last_post_time DESC'); if ($config['load_db_lastread']) { $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.forum_id = t.forum_id AND ft.user_id = ' . $user->data['user_id']); $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TRACK_TABLE => 'tt'), 'ON' => 'tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id']); $sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time AS forum_mark_time'; } if ($config['load_db_track']) { $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_POSTED_TABLE => 'tp'), 'ON' => 'tp.topic_id = t.topic_id AND tp.user_id = ' . $user->data['user_id']); $sql_array['SELECT'] .= ', tp.topic_posted'; } $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); $topic_list = $topic_forum_list = $global_announce_list = $rowset = array(); while ($row = $db->sql_fetchrow($result)) { $topic_list[] = $row['topic_id']; $rowset[$row['topic_id']] = $row; $topic_forum_list[$row['forum_id']]['forum_mark_time'] = $config['load_db_lastread'] ? $row['forum_mark_time'] : 0; $topic_forum_list[$row['forum_id']]['topics'][] = $row['topic_id']; if ($row['topic_type'] == POST_GLOBAL) { $global_announce_list[] = $row['topic_id']; } } $db->sql_freeresult($result); $topic_tracking_info = array(); if ($config['load_db_lastread']) { foreach ($topic_forum_list as $f_id => $topic_row) { $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time']), $f_id == 0 ? $global_announce_list : false); } } else { foreach ($topic_forum_list as $f_id => $topic_row) { $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics'], $global_announce_list); } } foreach ($topic_list as $topic_id) { $row =& $rowset[$topic_id]; $forum_id = $row['forum_id']; $topic_id = $row['topic_id']; $unread_topic = isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id] ? true : false; // Replies $replies = $auth->acl_get('m_approve', $forum_id) ? $row['topic_replies_real'] : $row['topic_replies']; if ($row['topic_status'] == ITEM_MOVED) { $topic_id = $row['topic_moved_id']; } // Get folder img, topic status/type related informations $folder_img = $folder_alt = $topic_type = ''; topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type); $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&t={$topic_id}"); // Send vars to template $template->assign_block_vars('topicrow', array('FORUM_ID' => $forum_id, 'TOPIC_ID' => $topic_id, 'TOPIC_AUTHOR' => topic_topic_author($row), 'FIRST_POST_TIME' => $user->format_date($row['topic_time']), 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), 'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']), 'LAST_POST_AUTHOR' => $row['topic_last_poster_name'] != '' ? $row['topic_last_poster_name'] : $user->lang['GUEST'], 'PAGINATION' => topic_generate_pagination($replies, append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . ($row['forum_id'] ? $row['forum_id'] : $forum_id) . "&t={$topic_id}")), 'REPLIES' => $replies, 'VIEWS' => $row['topic_views'], 'TOPIC_TITLE' => censor_text($row['topic_title']), 'TOPIC_TYPE' => $topic_type, 'LAST_POST_IMG' => $user->img('icon_post_latest', 'VIEW_LATEST_POST'), 'NEWEST_POST_IMG' => $user->img('icon_post_newest', 'VIEW_NEWEST_POST'), 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'), 'TOPIC_ICON_IMG' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['img'] : '', 'TOPIC_ICON_IMG_WIDTH' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['width'] : '', 'TOPIC_ICON_IMG_HEIGHT' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['height'] : '', 'ATTACH_ICON_IMG' => $auth->acl_gets('f_download', 'u_download', $forum_id) && $row['topic_attachment'] ? $user->img('icon_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 'S_TOPIC_TYPE' => $row['topic_type'], 'S_USER_POSTED' => !empty($row['topic_posted']) ? true : false, 'S_UNREAD_TOPIC' => $unread_topic, 'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&t={$topic_id}&view=unread") . '#unread', 'U_LAST_POST' => $view_topic_url . '&p=' . $row['topic_last_post_id'] . '#p' . $row['topic_last_post_id'], 'U_LAST_POST_AUTHOR' => $row['topic_last_poster_id'] != ANONYMOUS && $row['topic_last_poster_id'] ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=viewprofile&u=' . $row['topic_last_poster_id']) : '', 'U_VIEW_TOPIC' => $view_topic_url)); } break; case 'bookmarks': if (!$config['allow_bookmarks']) { $template->assign_vars(array('S_NO_DISPLAY_BOOKMARKS' => true)); break; } include $phpbb_root_path . 'includes/functions_display.' . $phpEx; $user->add_lang('viewforum'); $move_up = request_var('move_up', 0); $move_down = request_var('move_down', 0); $sql = 'SELECT MAX(order_id) as max_order_id FROM ' . BOOKMARKS_TABLE . ' WHERE user_id = ' . $user->data['user_id']; $result = $db->sql_query($sql); $max_order_id = (int) $db->sql_fetchfield('max_order_id'); $db->sql_freeresult($result); if ($move_up || $move_down) { if ($move_up && $move_up != 1 || $move_down && $move_down != $max_order_id) { $order = $move_up ? $move_up : $move_down; $order_total = $order * 2 + ($move_up ? -1 : 1); $sql = 'UPDATE ' . BOOKMARKS_TABLE . "\n\t\t\t\t\t\t\tSET order_id = {$order_total} - order_id\n\t\t\t\t\t\t\tWHERE order_id IN ({$order}, " . ($move_up ? $order - 1 : $order + 1) . ') AND user_id = ' . $user->data['user_id']; $db->sql_query($sql); } } if (isset($_POST['unbookmark'])) { $s_hidden_fields = array('unbookmark' => 1); $topics = isset($_POST['t']) ? array_map('intval', array_keys($_POST['t'])) : array(); $url = $this->u_action; if (!sizeof($topics)) { trigger_error('NO_BOOKMARKS_SELECTED'); } foreach ($topics as $topic_id) { $s_hidden_fields['t'][$topic_id] = 1; } if (confirm_box(true)) { $sql = 'DELETE FROM ' . BOOKMARKS_TABLE . ' WHERE user_id = ' . $user->data['user_id'] . ' AND topic_id IN (' . implode(', ', $topics) . ')'; $db->sql_query($sql); // Re-Order bookmarks (possible with one query? This query massaker is not really acceptable...) $sql = 'SELECT topic_id FROM ' . BOOKMARKS_TABLE . ' WHERE user_id = ' . $user->data['user_id'] . ' ORDER BY order_id ASC'; $result = $db->sql_query($sql); $i = 1; while ($row = $db->sql_fetchrow($result)) { $sql = 'UPDATE ' . BOOKMARKS_TABLE . "\n\t\t\t\t\t\t\t\tSET order_id = {$i}\n\t\t\t\t\t\t\t\tWHERE topic_id = {$row['topic_id']}\n\t\t\t\t\t\t\t\t\tAND user_id = {$user->data['user_id']}"; $db->sql_query($sql); $i++; } $db->sql_freeresult($result); meta_refresh(3, $url); $message = $user->lang['BOOKMARKS_REMOVED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $url . '">', '</a>'); trigger_error($message); } else { confirm_box(false, 'REMOVE_SELECTED_BOOKMARKS', build_hidden_fields($s_hidden_fields)); } } // We grab deleted topics here too... // NOTE: At the moment bookmarks are not removed with topics, might be useful later (not really sure how though. :D) // But since bookmarks are sensible to the user, they should not be deleted without notice. $sql = 'SELECT b.order_id, b.topic_id as b_topic_id, t.*, f.forum_name FROM ' . BOOKMARKS_TABLE . ' b LEFT JOIN ' . TOPICS_TABLE . ' t ON (b.topic_id = t.topic_id) LEFT JOIN ' . FORUMS_TABLE . ' f ON (t.forum_id = f.forum_id) WHERE b.user_id = ' . $user->data['user_id'] . ' ORDER BY b.order_id ASC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $forum_id = $row['forum_id']; $topic_id = $row['b_topic_id']; $replies = $auth->acl_get('m_approve', $forum_id) ? $row['topic_replies_real'] : $row['topic_replies']; // Get folder img, topic status/type related informations $folder_img = $folder_alt = $topic_type = ''; $unread_topic = false; topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type); $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&t={$topic_id}"); $template->assign_block_vars('topicrow', array('FORUM_ID' => $forum_id, 'TOPIC_ID' => $topic_id, 'TOPIC_TITLE' => censor_text($row['topic_title']), 'TOPIC_TYPE' => $topic_type, 'FORUM_NAME' => $row['forum_name'], 'S_DELETED_TOPIC' => !$row['topic_id'] ? true : false, 'S_GLOBAL_TOPIC' => !$forum_id ? true : false, 'TOPIC_AUTHOR' => topic_topic_author($row), 'FIRST_POST_TIME' => $user->format_date($row['topic_time']), 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), 'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']), 'LAST_POST_AUTHOR' => $row['topic_last_poster_name'] != '' ? $row['topic_last_poster_name'] : $user->lang['GUEST'], 'PAGINATION' => topic_generate_pagination($replies, append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . ($row['forum_id'] ? $row['forum_id'] : $forum_id) . "&t={$topic_id}")), 'POSTED_AT' => $user->format_date($row['topic_time']), 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'), 'ATTACH_ICON_IMG' => $auth->acl_gets('f_download', 'u_download', $forum_id) && $row['topic_attachment'] ? $user->img('icon_attach', '') : '', 'LAST_POST_IMG' => $user->img('icon_post_latest', 'VIEW_LATEST_POST'), 'U_LAST_POST' => $view_topic_url . '&p=' . $row['topic_last_post_id'] . '#p' . $row['topic_last_post_id'], 'U_LAST_POST_AUTHOR' => $row['topic_last_poster_id'] != ANONYMOUS && $row['topic_last_poster_id'] ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=viewprofile&u=' . $row['topic_last_poster_id']) : '', 'U_VIEW_TOPIC' => $view_topic_url, 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $forum_id), 'U_MOVE_UP' => $row['order_id'] != 1 ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=main&mode=bookmarks&move_up=' . $row['order_id']) : '', 'U_MOVE_DOWN' => $row['order_id'] != $max_order_id ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=main&mode=bookmarks&move_down=' . $row['order_id']) : '')); } break; case 'drafts': $pm_drafts = $this->p_master->p_name == 'pm' ? true : false; $template->assign_var('S_SHOW_DRAFTS', true); $user->add_lang('posting'); $edit = isset($_REQUEST['edit']) ? true : false; $submit = isset($_POST['submit']) ? true : false; $draft_id = $edit ? intval($_REQUEST['edit']) : 0; $delete = isset($_POST['delete']) ? true : false; $s_hidden_fields = $edit ? '<input type="hidden" name="edit" value="' . $draft_id . '" />' : ''; $draft_subject = $draft_message = ''; if ($delete) { $drafts = isset($_POST['d']) ? implode(', ', array_map('intval', array_keys($_POST['d']))) : ''; if ($drafts) { $sql = 'DELETE FROM ' . DRAFTS_TABLE . "\n\t\t\t\t\t\t\tWHERE draft_id IN ({$drafts}) \n\t\t\t\t\t\t\t\tAND user_id = " . $user->data['user_id']; $db->sql_query($sql); $message = $user->lang['DRAFTS_DELETED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); meta_refresh(3, $this->u_action); trigger_error($message); } } if ($submit && $edit) { $draft_subject = request_var('subject', '', true); $draft_message = request_var('message', '', true); if ($draft_message && $draft_subject) { $draft_row = array('draft_subject' => $draft_subject, 'draft_message' => $draft_message); $sql = 'UPDATE ' . DRAFTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $draft_row) . " \n\t\t\t\t\t\t\tWHERE draft_id = {$draft_id}\n\t\t\t\t\t\t\t\tAND user_id = " . $user->data['user_id']; $db->sql_query($sql); $message = $user->lang['DRAFT_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); meta_refresh(3, $this->u_action); trigger_error($message); } else { $template->assign_var('ERROR', $draft_message == '' ? $user->lang['EMPTY_DRAFT'] : ($draft_subject == '' ? $user->lang['EMPTY_DRAFT_TITLE'] : '')); } } if (!$pm_drafts) { $sql = 'SELECT d.*, f.forum_name FROM ' . DRAFTS_TABLE . ' d, ' . FORUMS_TABLE . ' f WHERE d.user_id = ' . $user->data['user_id'] . ' ' . ($edit ? "AND d.draft_id = {$draft_id}" : '') . ' AND f.forum_id = d.forum_id ORDER BY d.save_time DESC'; } else { $sql = 'SELECT * FROM ' . DRAFTS_TABLE . ' WHERE user_id = ' . $user->data['user_id'] . ' ' . ($edit ? "AND draft_id = {$draft_id}" : '') . ' AND forum_id = 0 AND topic_id = 0 ORDER BY save_time DESC'; } $result = $db->sql_query($sql); $draftrows = $topic_ids = array(); while ($row = $db->sql_fetchrow($result)) { if ($row['topic_id']) { $topic_ids[] = (int) $row['topic_id']; } $draftrows[] = $row; } $db->sql_freeresult($result); if (sizeof($topic_ids)) { $sql = 'SELECT topic_id, forum_id, topic_title FROM ' . TOPICS_TABLE . ' WHERE topic_id IN (' . implode(',', array_unique($topic_ids)) . ')'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $topic_rows[$row['topic_id']] = $row; } $db->sql_freeresult($result); } unset($topic_ids); $template->assign_var('S_EDIT_DRAFT', $edit); $row_count = 0; foreach ($draftrows as $draft) { $link_topic = $link_forum = $link_pm = false; $insert_url = $view_url = $title = ''; if (isset($topic_rows[$draft['topic_id']]) && $auth->acl_get('f_read', $topic_rows[$draft['topic_id']]['forum_id'])) { $link_topic = true; $view_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $topic_rows[$draft['topic_id']]['forum_id'] . '&t=' . $draft['topic_id']); $title = $topic_rows[$draft['topic_id']]['topic_title']; $insert_url = append_sid("{$phpbb_root_path}posting.{$phpEx}", 'f=' . $topic_rows[$draft['topic_id']]['forum_id'] . '&t=' . $draft['topic_id'] . '&mode=reply&d=' . $draft['draft_id']); } else { if ($auth->acl_get('f_read', $draft['forum_id'])) { $link_forum = true; $view_url = append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $draft['forum_id']); $title = $draft['forum_name']; $insert_url = append_sid("{$phpbb_root_path}posting.{$phpEx}", 'f=' . $draft['forum_id'] . '&mode=post&d=' . $draft['draft_id']); } else { if ($pm_drafts) { $link_pm = true; $insert_url = append_sid("{$phpbb_root_path}ucp.{$phpEx}", "i={$id}&mode=compose&d=" . $draft['draft_id']); } } } $template_row = array('DATE' => $user->format_date($draft['save_time']), 'DRAFT_MESSAGE' => $submit ? $draft_message : $draft['draft_message'], 'DRAFT_SUBJECT' => $submit ? $draft_subject : $draft['draft_subject'], 'TITLE' => $title, 'DRAFT_ID' => $draft['draft_id'], 'FORUM_ID' => $draft['forum_id'], 'TOPIC_ID' => $draft['topic_id'], 'U_VIEW' => $view_url, 'U_VIEW_EDIT' => $this->u_action . '&edit=' . $draft['draft_id'], 'U_INSERT' => $insert_url, 'S_LINK_TOPIC' => $link_topic, 'S_LINK_FORUM' => $link_forum, 'S_LINK_PM' => $link_pm, 'S_HIDDEN_FIELDS' => $s_hidden_fields); $row_count++; $edit ? $template->assign_vars($template_row) : $template->assign_block_vars('draftrow', $template_row); } if (!$edit) { $template->assign_var('S_DRAFT_ROWS', $row_count); } break; } $template->assign_vars(array('L_TITLE' => $user->lang['UCP_MAIN_' . strtoupper($mode)], 'S_DISPLAY_MARK_ALL' => $mode == 'watched' || $mode == 'drafts' && !isset($_GET['edit']) ? true : false, 'S_HIDDEN_FIELDS' => isset($s_hidden_fields) ? $s_hidden_fields : '', 'S_UCP_ACTION' => $this->u_action)); // Set desired template $this->tpl_name = 'ucp_main_' . $mode; $this->page_title = 'UCP_MAIN_' . strtoupper($mode); }
/** * {@inheritdoc} */ public function get_template_center($module_id) { $announcement = $this->request->variable('announcement_' . $module_id, -1); $announcement = $announcement > $this->config['board3_announcements_length_' . $module_id] - 1 ? -1 : $announcement; $start = $this->request->variable('ap_' . $module_id, 0); $start = $start < 0 ? 0 : $start; $total_announcements = 1; // Fetch announcements from portal functions.php with check if "read full" is requested. $portal_announcement_length = $announcement < 0 && !$this->config['board3_announcements_style_' . $module_id] ? $this->config['board3_announcements_length_' . $module_id] : 0; $this->fetch_posts->set_module_id($module_id); $fetch_news = $this->fetch_posts->get_posts($this->config['board3_global_announcements_forum_' . $module_id], $this->config['board3_announcements_permissions_' . $module_id], $this->config['board3_number_of_announcements_' . $module_id], $portal_announcement_length, $this->config['board3_announcements_day_' . $module_id], 'announcements', $start, (bool) $this->config['board3_announcements_forum_exclude_' . $module_id]); $topic_icons = false; if (!empty($fetch_news['topic_icons'])) { $topic_icons = true; } // Standard announcements row $announcements_row = array('NEWEST_POST_IMG' => $this->user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), 'READ_POST_IMG' => $this->user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'GOTO_PAGE_IMG' => $this->user->img('icon_post_target', 'GOTO_PAGE'), 'S_DISPLAY_ANNOUNCEMENTS_RVS' => $this->config['board3_show_announcements_replies_views_' . $module_id] ? true : false, 'S_TOPIC_ICONS' => $topic_icons, 'MODULE_ID' => $module_id); // Any announcements present? If not terminate it here. if (sizeof($fetch_news) < 3) { $this->template->assign_block_vars('announcements', $announcements_row); $this->template->assign_block_vars('announcements.center_row', array('S_NO_TOPICS' => true, 'S_NOT_LAST' => false)); $this->template->assign_var('S_CAN_READ', false); } else { // Count number of posts for announcements archive, considering if permission check is dis- or enabled. if ($this->config['board3_announcements_archive_' . $module_id]) { $permissions = $this->config['board3_announcements_permissions_' . $module_id]; $forum_from = $this->config['board3_global_announcements_forum_' . $module_id]; $forum_from = strpos($forum_from, ',') !== false ? explode(',', $forum_from) : ($forum_from != '' ? array($forum_from) : array()); $time = $this->config['board3_announcements_day_' . $module_id] == 0 ? 0 : $this->config['board3_announcements_day_' . $module_id]; $post_time = $time == 0 ? '' : 'AND topic_time > ' . (time() - $time * 86400); $str_where = ''; // Get disallowed forums $disallow_access = $this->modules_helper->get_disallowed_forums($permissions); if ($this->config['board3_announcements_forum_exclude_' . $module_id] == true) { $disallow_access = array_merge($disallow_access, $forum_from); $forum_from = array(); } $global_f = 0; if (sizeof($forum_from)) { $disallow_access = array_diff($forum_from, $disallow_access); if (!sizeof($disallow_access)) { return array(); } foreach ($disallow_access as $acc_id) { $str_where .= 'forum_id = ' . (int) $acc_id . ' OR '; if ($global_f < 1 && $acc_id > 0) { $global_f = $acc_id; } } } else { foreach ($disallow_access as $acc_id) { $str_where .= 'forum_id <> ' . (int) $acc_id . ' AND '; } } $str_where = strlen($str_where) > 0 ? 'AND (forum_id = 0 OR (' . trim(substr($str_where, 0, -4)) . '))' : ''; $sql = 'SELECT COUNT(topic_id) AS num_topics FROM ' . TOPICS_TABLE . ' WHERE ((topic_type = ' . POST_GLOBAL . ') OR topic_type = ' . POST_ANNOUNCE . ') AND topic_visibility = 1 AND topic_moved_id = 0 ' . $post_time . ' ' . $str_where; $result = $this->db->sql_query($sql, 30); $total_announcements = (int) $this->db->sql_fetchfield('num_topics'); $this->db->sql_freeresult($result); } $topic_tracking_info = get_portal_tracking_info($fetch_news); if ($this->config['board3_number_of_announcements_' . $module_id] != 0 && $this->config['board3_announcements_archive_' . $module_id]) { $pagination = generate_portal_pagination($this->modules_helper->route('board3_portal_controller'), $total_announcements, $this->config['board3_number_of_announcements_' . $module_id], $start, 'announcements', $module_id); $announcements_row = array_merge($announcements_row, array('AP_PAGINATION' => isset($pagination) ? $pagination : '', 'TOTAL_ANNOUNCEMENTS' => $total_announcements == 1 ? $this->user->lang['VIEW_LATEST_ANNOUNCEMENT'] : sprintf($this->user->lang['VIEW_LATEST_ANNOUNCEMENTS'], $total_announcements), 'AP_PAGE_NUMBER' => $this->pagination->on_page($total_announcements, $this->config['board3_number_of_announcements_' . $module_id], $start))); } // Assign announcements row $this->template->assign_block_vars('announcements', $announcements_row); // Show the announcements overview if ($announcement < 0) { $count = $fetch_news['topic_count']; for ($i = 0; $i < $count; $i++) { if (isset($fetch_news[$i]['striped']) && $fetch_news[$i]['striped'] == true) { $open_bracket = '[ '; $close_bracket = ' ]'; $read_full = $this->user->lang['READ_FULL']; } else { $open_bracket = ''; $close_bracket = ''; $read_full = ''; } // unread? $forum_id = $fetch_news[$i]['forum_id']; $topic_id = $fetch_news[$i]['topic_id']; $unread_topic = isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id] ? true : false; $real_forum_id = $forum_id == 0 ? $fetch_news['global_id'] : $forum_id; $read_full_url = $this->request->is_set('ap_' . $module_id) ? "ap_{$module_id}={$start}&announcement_{$module_id}={$i}#a_{$module_id}_{$i}" : "announcement_{$module_id}={$i}#a_{$module_id}_{$i}"; $view_topic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . ($fetch_news[$i]['forum_id'] ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id); $replies = $this->auth->acl_get('m_approve', $forum_id) ? $fetch_news[$i]['topic_replies_real'] : $fetch_news[$i]['topic_replies']; switch ($fetch_news[$i]['topic_type']) { case POST_GLOBAL: $folder = 'global_read'; $folder_new = 'global_unread'; break; case POST_ANNOUNCE: $folder = 'announce_read'; $folder_new = 'announce_unread'; break; default: $folder = 'topic_read'; $folder_new = 'topic_unread'; if ($this->config['hot_threshold'] && $replies >= $this->config['hot_threshold'] && $fetch_news[$i]['topic_status'] != ITEM_LOCKED) { $folder .= '_hot'; $folder_new .= '_hot'; } break; } if ($fetch_news[$i]['topic_status'] == ITEM_LOCKED) { $folder .= '_locked'; $folder_new .= '_locked'; } if ($fetch_news[$i]['topic_posted']) { $folder .= '_mine'; $folder_new .= '_mine'; } $folder_img = $unread_topic ? $folder_new : $folder; $folder_alt = $unread_topic ? 'NEW_POSTS' : ($fetch_news[$i]['topic_status'] == ITEM_LOCKED ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS'); // Grab icons $icons = $this->cache->obtain_icons(); $this->template->assign_block_vars('announcements.center_row', array('ATTACH_ICON_IMG' => $fetch_news[$i]['attachment'] && $this->config['allow_attachments'] ? $this->user->img('icon_topic_attach', $this->user->lang['TOTAL_ATTACHMENTS']) : '', 'FORUM_NAME' => $forum_id ? $fetch_news[$i]['forum_name'] : '', 'TITLE' => $fetch_news[$i]['topic_title'], 'POSTER' => $fetch_news[$i]['username'], 'POSTER_FULL' => $fetch_news[$i]['username_full'], 'USERNAME_FULL_LAST' => $fetch_news[$i]['username_full_last'], 'U_USER_PROFILE' => ($fetch_news[$i]['user_type'] == USER_NORMAL || $fetch_news[$i]['user_type'] == USER_FOUNDER) && $fetch_news[$i]['user_id'] != ANONYMOUS ? append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=viewprofile&u=' . $fetch_news[$i]['user_id']) : '', 'TIME' => $fetch_news[$i]['topic_time'], 'LAST_POST_TIME' => $this->user->format_date($fetch_news[$i]['topic_last_post_time']), 'TEXT' => $fetch_news[$i]['post_text'], 'REPLIES' => $fetch_news[$i]['topic_replies'], 'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'], 'A_ID' => $i, 'TOPIC_IMG_STYLE' => $folder_img, 'TOPIC_FOLDER_IMG' => $this->user->img($folder_img, $folder_alt), 'TOPIC_FOLDER_IMG_SRC' => $this->user->img($folder_img, $folder_alt, false, '', 'src'), 'TOPIC_FOLDER_IMG_ALT' => $this->user->lang[$folder_alt], 'FOLDER_IMG' => $this->user->img('topic_read', 'NO_NEW_POSTS'), 'TOPIC_ICON_IMG' => !empty($icons[$fetch_news[$i]['icon_id']]) ? $icons[$fetch_news[$i]['icon_id']]['img'] : '', 'TOPIC_ICON_IMG_WIDTH' => !empty($icons[$fetch_news[$i]['icon_id']]) ? $icons[$fetch_news[$i]['icon_id']]['width'] : '', 'TOPIC_ICON_IMG_HEIGHT' => !empty($icons[$fetch_news[$i]['icon_id']]) ? $icons[$fetch_news[$i]['icon_id']]['height'] : '', 'U_VIEWFORUM' => append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id']), 'U_LAST_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", ($real_forum_id ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id . '&p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']), 'U_VIEW_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", ($real_forum_id ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id), 'U_VIEW_UNREAD' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", ($real_forum_id ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id . '&view=unread#unread'), 'U_POST_COMMENT' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", 'mode=reply&' . ($real_forum_id ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id), 'U_READ_FULL' => $this->modules_helper->route('board3_portal_controller') . '?' . $read_full_url, 'L_READ_FULL' => $read_full, 'OPEN' => $open_bracket, 'CLOSE' => $close_bracket, 'S_NOT_LAST' => $i < sizeof($fetch_news) - 1 ? true : false, 'S_POLL' => $fetch_news[$i]['poll'], 'S_UNREAD_INFO' => $unread_topic, 'S_HAS_ATTACHMENTS' => !empty($fetch_news[$i]['attachments']) ? true : false)); $this->pagination->generate_template_pagination($view_topic_url, 'announcements.center_row.pagination', 'start', $fetch_news[$i]['topic_replies'] + 1, $this->config['posts_per_page'], 1, true, true); if (!empty($fetch_news[$i]['attachments'])) { foreach ($fetch_news[$i]['attachments'] as $attachment) { $this->template->assign_block_vars('announcements.center_row.attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } } } } else { $i = $announcement; /** * redirect to portal page if the specified announcement does not exist * force #top anchor in order to get rid of the #a anchor */ if (!isset($fetch_news[$i])) { redirect($this->modules_helper->route('board3_portal_controller') . '#top'); } $forum_id = $fetch_news[$i]['forum_id']; $topic_id = $fetch_news[$i]['topic_id']; $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id); $unread_topic = isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id] ? true : false; $open_bracket = '[ '; $close_bracket = ' ]'; $read_full = $this->user->lang['BACK']; $real_forum_id = $forum_id == 0 ? $fetch_news['global_id'] : $forum_id; $read_full_url = $this->request->is_set('ap_' . $module_id) ? $this->modules_helper->route('board3_portal_controller') . "?ap_{$module_id}={$start}#a_{$module_id}_{$i}" : $this->modules_helper->route('board3_portal_controller') . "#a_{$module_id}_{$i}"; $view_topic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . ($fetch_news[$i]['forum_id'] ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id); $this->template->assign_block_vars('announcements.center_row', array('ATTACH_ICON_IMG' => $fetch_news[$i]['attachment'] && $this->config['allow_attachments'] ? $this->user->img('icon_topic_attach', $this->user->lang['TOTAL_ATTACHMENTS']) : '', 'FORUM_NAME' => $forum_id ? $fetch_news[$i]['forum_name'] : '', 'TITLE' => $fetch_news[$i]['topic_title'], 'POSTER' => $fetch_news[$i]['username'], 'POSTER_FULL' => $fetch_news[$i]['username_full'], 'TIME' => $fetch_news[$i]['topic_time'], 'TEXT' => $fetch_news[$i]['post_text'], 'REPLIES' => $fetch_news[$i]['topic_replies'], 'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'], 'A_ID' => $i, 'U_VIEWFORUM' => append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id']), 'U_LAST_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", ($real_forum_id ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id . '&p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']), 'U_VIEW_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", ($real_forum_id ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id), 'U_POST_COMMENT' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", 'mode=reply&' . ($real_forum_id ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id), 'S_POLL' => $fetch_news[$i]['poll'], 'S_UNREAD_INFO' => $unread_topic, 'U_READ_FULL' => $read_full_url, 'L_READ_FULL' => $read_full, 'OPEN' => $open_bracket, 'CLOSE' => $close_bracket, 'S_HAS_ATTACHMENTS' => !empty($fetch_news[$i]['attachments']) ? true : false)); $this->pagination->generate_template_pagination($view_topic_url, 'announcements.center_row.pagination', 'start', $fetch_news[$i]['topic_replies'] + 1, $this->config['posts_per_page'], 1, true, true); if (!empty($fetch_news[$i]['attachments'])) { foreach ($fetch_news[$i]['attachments'] as $attachment) { $this->template->assign_block_vars('announcements.center_row.attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } } } } if ($this->config['board3_announcements_style_' . $module_id]) { return 'announcements_center_compact.html'; } else { return 'announcements_center.html'; } }
function get_topic_func($xmlrpc_params) { global $db, $auth, $user, $config; $user->setup('viewforum'); $params = php_xmlrpc_decode($xmlrpc_params); list($start, $limit) = process_page($params[1], $params[2]); // get forum id from parameters $forum_id = intval($params[0]); if (!$forum_id) { trigger_error('NO_FORUM'); } // check if need sticky/announce topic only $topic_type = ''; if (isset($params[3])) { // check if need sticky topic only if ($params[3] == 'TOP') { $topic_type = POST_STICKY; $start = 0; $limit = 20; } else { if ($params[3] == 'ANN') { $topic_type = POST_ANNOUNCE . ', ' . POST_GLOBAL; $start = 0; $limit = 20; } } } // $default_sort_days = (!empty($user->data['user_topic_show_days'])) ? $user->data['user_topic_show_days'] : 0; // $default_sort_key = (!empty($user->data['user_topic_sortby_type'])) ? $user->data['user_topic_sortby_type'] : 't'; // $default_sort_dir = (!empty($user->data['user_topic_sortby_dir'])) ? $user->data['user_topic_sortby_dir'] : 'd'; // // $sort_days = request_var('st', $default_sort_days); // default to get all topic // $sort_key = request_var('sk', $default_sort_key); // default sort by last post time // $sort_dir = request_var('sd', $default_sort_dir); // default sort as DESC $sort_days = 0; $sort_key = 't'; $sort_dir = 'd'; //------- Grab appropriate forum data -------- $sql = "SELECT f.* FROM " . FORUMS_TABLE . " f WHERE f.forum_id = {$forum_id}"; $result = $db->sql_query($sql); $forum_data = $db->sql_fetchrow($result); $db->sql_freeresult($result); // Forum does not exist if (!$forum_data) { trigger_error('NO_FORUM'); } // Can not get topics from link forum if ($forum_data['forum_type'] == FORUM_LINK) { trigger_error('NO_FORUM'); } // Permissions check if (!$auth->acl_gets('f_list', 'f_read', $forum_id) || $forum_data['forum_type'] == FORUM_LINK && $forum_data['forum_link'] && !$auth->acl_get('f_read', $forum_id)) { if ($user->data['user_id'] != ANONYMOUS) { trigger_error('SORRY_AUTH_READ'); } trigger_error('LOGIN_VIEWFORUM'); } // Forum is passworded if ($forum_data['forum_password'] && !check_forum_password($forum_id)) { trigger_error('LOGIN_FORUM'); } if (!$auth->acl_get('f_read', $forum_id)) { trigger_error('NO_READ_ACCESS'); } // Topic ordering options $sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_post_time', 'r' => 't.topic_replies', 's' => 't.topic_title', 'v' => 't.topic_views'); // Limit topics to certain time frame, obtain correct topic count // global announcements must not be counted, normal announcements have to // be counted, as forum_topics(_real) includes them $sql_approved = $auth->acl_get('m_approve', $forum_id) ? '' : ' AND t.topic_approved = 1 '; // Get all shadow topics in this forum $sql = 'SELECT t.topic_moved_id, t.topic_id FROM ' . TOPICS_TABLE . ' t WHERE t.forum_id = ' . $forum_id . ' AND t.topic_type IN (' . POST_NORMAL . ', ' . POST_STICKY . ', ' . POST_ANNOUNCE . ', ' . POST_GLOBAL . ') AND t.topic_status = ' . ITEM_MOVED . ' ' . $sql_approved; $result = $db->sql_query($sql); $shadow_topic_list = array(); while ($row = $db->sql_fetchrow($result)) { $shadow_topic_list[$row['topic_moved_id']] = $row['topic_id']; } $db->sql_freeresult($result); // Pick out those shadow topics that the user has no permission to access if (!empty($shadow_topic_list)) { $sql = 'SELECT t.topic_id, t.forum_id FROM ' . TOPICS_TABLE . ' t WHERE ' . $db->sql_in_set('t.topic_id', array_keys($shadow_topic_list)); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if ($auth->acl_get('f_read', $row['forum_id'])) { unset($shadow_topic_list[$row['topic_id']]); } } $db->sql_freeresult($result); } // Grab all topic data $topic_list = array(); $sql_limit = $limit; // num of topics needs to be return, default is 20, at most 50 $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'DESC' : 'ASC'); $sql_shadow_out = empty($shadow_topic_list) ? '' : 'AND ' . $db->sql_in_set('t.topic_moved_id', $shadow_topic_list, true); // If the user is trying to reach late pages, start searching from the end $store_reverse = false; $unread_sticky_num = $unread_announce_count = 0; //get subscribe users $user_watch_row = array(); $sql = 'SELECT * FROM ' . TOPICS_WATCH_TABLE . ' WHERE user_id = ' . $user->data['user_id']; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $user_watch_row[$row['topic_id']] = $row['notify_status']; } $db->sql_freeresult($result); if (!empty($topic_type)) { $sql = 'SELECT t.*, u.user_avatar, u.user_avatar_type,bm.topic_id as bookmarked FROM ' . TOPICS_TABLE . ' t LEFT JOIN ' . USERS_TABLE . ' u ON (t.topic_poster = u.user_id) LEFT JOIN ' . BOOKMARKS_TABLE . ' bm ON (bm.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = bm.topic_id) WHERE t.forum_id IN (' . $forum_id . ', 0) AND t.topic_type IN (' . $topic_type . ') ' . $sql_shadow_out . ' ' . $sql_approved . ' ORDER BY ' . $sql_sort_order; $result = $db->sql_query_limit($sql, $sql_limit, $start); } else { if ($user->data['user_id'] != ANONYMOUS) { // get total number of unread sticky topics number $sql = 'SELECT t.topic_id, t.topic_last_post_time FROM ' . TOPICS_TABLE . ' t WHERE t.forum_id = ' . $forum_id . ' AND t.topic_type = ' . POST_STICKY . ' ' . $sql_shadow_out . ' ' . $sql_approved; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if (empty($forum_id) || empty($row['topic_id'])) { continue; } $topic_tracking = get_complete_topic_tracking($forum_id, $row['topic_id']); if (isset($topic_tracking[$row['topic_id']]) && $topic_tracking[$row['topic_id']] < $row['topic_last_post_time']) { $unread_sticky_num++; } } $db->sql_freeresult($result); // get total number of unread announce topics number $sql = 'SELECT t.topic_id, t.topic_last_post_time FROM ' . TOPICS_TABLE . ' t WHERE t.forum_id IN (' . $forum_id . ', 0) AND t.topic_type IN (' . POST_ANNOUNCE . ', ' . POST_GLOBAL . ') ' . $sql_shadow_out . ' ' . $sql_approved; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if (empty($forum_id) || empty($row['topic_id'])) { continue; } $topic_tracking = get_complete_topic_tracking($forum_id, $row['topic_id']); if (isset($topic_tracking[$row['topic_id']]) && $topic_tracking[$row['topic_id']] < $row['topic_last_post_time']) { $unread_announce_count++; } } $db->sql_freeresult($result); } // get total number of normal topics $sql = 'SELECT count(t.topic_id) AS num_topics FROM ' . TOPICS_TABLE . ' t WHERE t.forum_id = ' . $forum_id . ' AND t.topic_type = ' . POST_NORMAL . ' ' . $sql_shadow_out . ' ' . $sql_approved; $result = $db->sql_query($sql); $topics_count = (int) $db->sql_fetchfield('num_topics'); $db->sql_freeresult($result); if ($start > $topics_count / 2) { $store_reverse = true; if ($start + $sql_limit > $topics_count) { $sql_limit = min($sql_limit, max(1, $topics_count - $start)); } // Select the sort order $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'ASC' : 'DESC'); $start = max(0, $topics_count - $sql_limit - $start); } $sql = 'SELECT t.*, u.user_avatar, u.user_avatar_type,bm.topic_id as bookmarked FROM ' . TOPICS_TABLE . ' t LEFT JOIN ' . USERS_TABLE . ' u ON (t.topic_poster = u.user_id) LEFT JOIN ' . BOOKMARKS_TABLE . ' bm ON (bm.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = bm.topic_id) WHERE t.forum_id = ' . $forum_id . ' AND t.topic_type = ' . POST_NORMAL . ' ' . $sql_shadow_out . ' ' . $sql_approved . ' ORDER BY ' . $sql_sort_order; $result = $db->sql_query_limit($sql, $sql_limit, $start); } $tids = array(); $rowset = array(); while ($row = $db->sql_fetchrow($result)) { $rowset[] = $row; $tids[] = $row['topic_moved_id'] ? $row['topic_moved_id'] : $row['topic_id']; } $db->sql_freeresult($result); // get participated users of each topic // get_participated_user_avatars($tids); // global $topic_users, $user_avatar; $topic_list = array(); foreach ($rowset as $row) { $replies = $auth->acl_get('m_approve', $forum_id) ? $row['topic_replies_real'] : $row['topic_replies']; $short_content = get_short_content($row['topic_first_post_id']); $user_avatar_url = get_user_avatar_url($row['user_avatar'], $row['user_avatar_type']); $new_post = false; if ($user->data['user_id'] != ANONYMOUS) { if (empty($forum_id) || empty($row['topic_id'])) { continue; } $topic_tracking = get_complete_topic_tracking($forum_id, $row['topic_id']); $new_post = $topic_tracking[$row['topic_id']] < $row['topic_last_post_time'] ? true : false; } $allow_change_type = $auth->acl_get('m_', $forum_id) || $user->data['is_registered'] && $user->data['user_id'] == $row['topic_poster'] ? true : false; $topic_id = $row['topic_moved_id'] ? $row['topic_moved_id'] : $row['topic_id']; // $icon_urls = array(); // foreach($topic_users[$topic_id] as $posterid){ // $icon_urls[] = new xmlrpcval($user_avatar[$posterid], 'string'); // } $can_rename = $user->data['is_registered'] && ($auth->acl_get('m_edit', $forum_id) || $user->data['user_id'] == $row['topic_poster'] && $auth->acl_get('f_edit', $forum_id) && ($row['topic_time'] > time() - $config['edit_time'] * 60 || !$config['edit_time'])); $xmlrpc_topic = new xmlrpcval(array('forum_id' => new xmlrpcval($forum_id), 'topic_id' => new xmlrpcval($row['topic_moved_id'] ? $row['topic_moved_id'] : $row['topic_id']), 'topic_title' => new xmlrpcval(html_entity_decode(strip_tags(censor_text($row['topic_title'])), ENT_QUOTES, 'UTF-8'), 'base64'), 'topic_author_id' => new xmlrpcval($row['topic_first_post_id'], 'string'), 'topic_author_name' => new xmlrpcval(html_entity_decode($row['topic_first_poster_name']), 'base64'), 'last_reply_time' => new xmlrpcval(mobiquo_iso8601_encode($row['topic_last_post_time']), 'dateTime.iso8601'), 'timestamp' => new xmlrpcval($row['topic_last_post_time'], 'string'), 'reply_number' => new xmlrpcval($replies, 'int'), 'view_number' => new xmlrpcval($row['topic_views'], 'int'), 'short_content' => new xmlrpcval($short_content, 'base64'), 'new_post' => new xmlrpcval($new_post, 'boolean'), 'icon_url' => new xmlrpcval($user_avatar_url), 'attachment' => new xmlrpcval($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment'] ? 1 : 0, 'string'), 'can_delete' => new xmlrpcval($auth->acl_get('m_delete', $forum_id), 'boolean'), 'can_move' => new xmlrpcval($auth->acl_get('m_move', $forum_id), 'boolean'), 'can_subscribe' => new xmlrpcval(($config['email_enable'] || $config['jab_enable']) && $config['allow_topic_notify'] && $user->data['is_registered'], 'boolean'), 'is_subscribed' => new xmlrpcval(isset($user_watch_row[$topic_id]) ? true : false, 'boolean'), 'can_close' => new xmlrpcval($auth->acl_get('m_lock', $forum_id) || $auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $row['topic_poster'], 'boolean'), 'is_closed' => new xmlrpcval($row['topic_status'] == ITEM_LOCKED, 'boolean'), 'can_stick' => new xmlrpcval($allow_change_type && $auth->acl_get('f_sticky', $forum_id), 'boolean'), 'is_sticky' => new xmlrpcval($row['topic_type'] == POST_STICKY, 'boolean'), 'can_approve' => new xmlrpcval($auth->acl_get('m_approve', $forum_id) && !$row['topic_approved'], 'boolean'), 'is_approved' => new xmlrpcval($row['topic_approved'] ? true : false, 'boolean'), 'can_rename' => new xmlrpcval($can_rename, 'boolean')), 'struct'); $topic_list[] = $xmlrpc_topic; unset($xmlrpc_topic); } if ($store_reverse) { $topic_list = array_reverse($topic_list); } if (!empty($topic_type)) { $topic_num = count($topic_list); } else { $topic_num = $topics_count; } $allowed = $config['max_attachments'] && $auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && $config['allow_attachments'] && @ini_get('file_uploads') != '0' && strtolower(@ini_get('file_uploads')) != 'off'; $max_attachment = $auth->acl_get('a_') || $auth->acl_get('m_', $forum_id) ? 99 : ($allowed ? $config['max_attachments'] : 0); $max_png_size = $auth->acl_get('a_') || $auth->acl_get('m_', $forum_id) ? 10485760 : ($allowed ? $config['max_filesize'] === '0' ? 10485760 : $config['max_filesize'] : 0); $max_jpg_size = $auth->acl_get('a_') || $auth->acl_get('m_', $forum_id) ? 10485760 : ($allowed ? $config['max_filesize'] === '0' ? 10485760 : $config['max_filesize'] : 0); $read_only_forums = explode(",", $config['tapatalk_forum_read_only']); $can_post = true; if (empty($read_only_forums) || !is_array($read_only_forums)) { $read_only_forums = array(); } if (!$auth->acl_get('f_post', $forum_id) || in_array($forum_id, $read_only_forums)) { $can_post = false; } $response = new xmlrpcval(array('total_topic_num' => new xmlrpcval($topic_num, 'int'), 'unread_sticky_count' => new xmlrpcval($unread_sticky_num, 'int'), 'unread_announce_count' => new xmlrpcval($unread_announce_count, 'int'), 'forum_id' => new xmlrpcval($forum_id, 'string'), 'forum_name' => new xmlrpcval(html_entity_decode($forum_data['forum_name']), 'base64'), 'can_post' => new xmlrpcval($can_post, 'boolean'), 'can_upload' => new xmlrpcval($allowed, 'boolean'), 'max_attachment' => new xmlrpcval($max_attachment, 'int'), 'max_png_size' => new xmlrpcval($max_png_size, 'int'), 'max_jpg_size' => new xmlrpcval($max_jpg_size, 'int'), 'topics' => new xmlrpcval($topic_list, 'array')), 'struct'); return new xmlrpcresp($response); }
public function get_template_center($module_id) { global $config, $template, $db, $user, $auth, $cache, $phpEx, $phpbb_root_path; $announcement = request_var('announcement', -1); $announcement = ($announcement > $config['board3_announcements_length_' . $module_id] -1) ? -1 : $announcement; $start = request_var('ap', 0); $start = ($start < 0) ? 0 : $start; // Fetch announcements from portal/includes/functions.php with check if "read full" is requested. $portal_announcement_length = ($announcement < 0) ? $config['board3_announcements_length_' . $module_id] : 0; $fetch_news = phpbb_fetch_posts($module_id, $config['board3_global_announcements_forum_' . $module_id], $config['board3_announcements_permissions_' . $module_id], $config['board3_number_of_announcements_' . $module_id], $portal_announcement_length, $config['board3_announcements_day_' . $module_id], 'announcements', $start, $config['board3_announcements_forum_exclude_' . $module_id]); // Any announcements present? If not terminate it here. if (sizeof($fetch_news) == 0) { $template->assign_block_vars('announcements_center_row', array( 'S_NO_TOPICS' => true, 'S_NOT_LAST' => false )); $template->assign_var('S_CAN_READ', false); } else { // Count number of posts for announcements archive, considering if permission check is dis- or enabled. if ($config['board3_announcements_archive_' . $module_id]) { $permissions = $config['board3_announcements_permissions_' . $module_id]; $forum_from = $config['board3_global_announcements_forum_' . $module_id]; $forum_from = (strpos($forum_from, ',') !== false) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array()); $time = ($config['board3_announcements_day_' . $module_id] == 0) ? 0 : $config['board3_announcements_day_' . $module_id]; $post_time = ($time == 0) ? '' : 'AND topic_time > ' . (time() - $time * 86400); $str_where = ''; if($permissions == true) { $disallow_access = array_unique(array_keys($auth->acl_getf('!f_read', true))); } else { $disallow_access = array(); } if($config['board3_announcements_forum_exclude_' . $module_id] == true) { $disallow_access = array_merge($disallow_access, $forum_from); $forum_from = array(); } $global_f = 0; if(sizeof($forum_from)) { $disallow_access = array_diff($forum_from, $disallow_access); if(!sizeof($disallow_access)) { return array(); } foreach($disallow_access as $acc_id) { $acc_id = (int) $acc_id; $str_where .= "forum_id = $acc_id OR "; if($global_f < 1 && $acc_id > 0) { $global_f = $acc_id; } } } else { foreach($disallow_access as $acc_id) { $acc_id = (int) $acc_id; $str_where .= "forum_id <> $acc_id AND "; } } $str_where = (strlen($str_where) > 0) ? 'AND (forum_id = 0 OR (' . trim(substr($str_where, 0, -4)) . '))' : ''; $sql = 'SELECT COUNT(topic_id) AS num_topics FROM ' . TOPICS_TABLE . ' WHERE ((topic_type = ' . POST_GLOBAL . ') OR topic_type = ' . POST_ANNOUNCE . ') AND topic_approved = 1 AND topic_moved_id = 0 ' . $post_time . ' ' . $str_where; $result = $db->sql_query($sql); $total_announcements = (int) $db->sql_fetchfield('num_topics'); $db->sql_freeresult($result); } $topic_tracking_info = (get_portal_tracking_info($fetch_news)); if($announcement < 0) // Show the announcements overview { $count = $fetch_news['topic_count']; for ($i = 0; $i < $count; $i++) { if(isset($fetch_news[$i]['striped']) && $fetch_news[$i]['striped'] == true) { $open_bracket = '[ '; $close_bracket = ' ]'; $read_full = $user->lang['READ_FULL']; } else { $open_bracket = ''; $close_bracket = ''; $read_full = ''; } // unread? $forum_id = $fetch_news[$i]['forum_id']; $topic_id = $fetch_news[$i]['topic_id']; //$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id, $global_announce_list = false); $unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false; $real_forum_id = ($forum_id == 0) ? $fetch_news['global_id']: $forum_id; $read_full_url = (isset($_GET['ap'])) ? 'ap='. $start . '&announcement=' . $i . '#a' . $i : 'announcement=' . $i . '#a' . $i; $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id); if ($config['board3_announcements_archive_' . $module_id]) { $pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_announcements, $config['board3_number_of_announcements_' . $module_id], $start, 'announcements'); } $replies = ($auth->acl_get('m_approve', $forum_id)) ? $fetch_news[$i]['topic_replies_real'] : $fetch_news[$i]['topic_replies']; $folder_img = $folder_alt = $topic_type = $folder = $folder_new = ''; switch ($fetch_news[$i]['topic_type']) { case POST_GLOBAL: $folder = 'global_read'; $folder_new = 'global_unread'; break; case POST_ANNOUNCE: $folder = 'announce_read'; $folder_new = 'announce_unread'; break; default: $folder = 'topic_read'; $folder_new = 'topic_unread'; if ($config['hot_threshold'] && $replies >= $config['hot_threshold'] && $fetch_news[$i]['topic_status'] != ITEM_LOCKED) { $folder .= '_hot'; $folder_new .= '_hot'; } break; } if ($fetch_news[$i]['topic_status'] == ITEM_LOCKED) { $folder .= '_locked'; $folder_new .= '_locked'; } if ($fetch_news[$i]['topic_type'] == POST_GLOBAL) { $global_announce_list[$fetch_news[$i]['topic_id']] = true; } if ($fetch_news[$i]['topic_posted']) { $folder .= '_mine'; $folder_new .= '_mine'; } $folder_img = ($unread_topic) ? $folder_new : $folder; $folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($fetch_news[$i]['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS'); // Grab icons $icons = $cache->obtain_icons(); $template->assign_block_vars('announcements_center_row', array( 'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $config['allow_attachments']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 'FORUM_NAME' => ($forum_id) ? $fetch_news[$i]['forum_name'] : '', 'TITLE' => $fetch_news[$i]['topic_title'], 'POSTER' => $fetch_news[$i]['username'], 'POSTER_FULL' => $fetch_news[$i]['username_full'], 'USERNAME_FULL_LAST' => $fetch_news[$i]['username_full_last'], 'U_USER_PROFILE' => (($fetch_news[$i]['user_type'] == USER_NORMAL || $fetch_news[$i]['user_type'] == USER_FOUNDER) && $fetch_news[$i]['user_id'] != ANONYMOUS) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $fetch_news[$i]['user_id']) : '', 'TIME' => $fetch_news[$i]['topic_time'], 'LAST_POST_TIME' => $user->format_date($fetch_news[$i]['topic_last_post_time']), 'TEXT' => $fetch_news[$i]['post_text'], 'REPLIES' => $fetch_news[$i]['topic_replies'], 'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'], 'A_ID' => $i, 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'), 'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt], 'FOLDER_IMG' => $user->img('topic_read', 'NO_NEW_POSTS'), 'TOPIC_ICON_IMG' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['img'] : '', 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['width'] : '', 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['height'] : '', 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $fetch_news[$i]['forum_id']), 'U_LAST_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id . '&p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']), 'U_VIEW_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id), 'U_VIEW_UNREAD' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id . '&view=unread#unread'), 'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&' . (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id), 'U_READ_FULL' => append_sid("{$phpbb_root_path}portal.$phpEx", $read_full_url), 'L_READ_FULL' => $read_full, 'OPEN' => $open_bracket, 'CLOSE' => $close_bracket, 'S_NOT_LAST' => ($i < sizeof($fetch_news) - 1) ? true : false, 'S_POLL' => $fetch_news[$i]['poll'], 'S_UNREAD_INFO' => $unread_topic, 'PAGINATION' => topic_generate_pagination($fetch_news[$i]['topic_replies'], $view_topic_url), 'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false, )); if(!empty($fetch_news[$i]['attachments'])) { foreach ($fetch_news[$i]['attachments'] as $attachment) { $template->assign_block_vars('announcements_center_row.attachment', array( 'DISPLAY_ATTACHMENT' => $attachment) ); } } if ($config['board3_number_of_announcements_' . $module_id] != 0 && $config['board3_announcements_archive_' . $module_id]) { $template->assign_vars(array( 'AP_PAGINATION' => $pagination, 'TOTAL_ANNOUNCEMENTS' => ($total_announcements == 1) ? $user->lang['VIEW_LATEST_ANNOUNCEMENT'] : sprintf($user->lang['VIEW_LATEST_ANNOUNCEMENTS'], $total_announcements), 'AP_PAGE_NUMBER' => on_page($total_announcements, $config['board3_number_of_announcements_' . $module_id], $start)) ); } } } else // Show "read full" page { $i = $announcement; /** * redirect to portal page if the specified announcement does not exist * force #top anchor in order to get rid of the #a anchor */ if (!isset($fetch_news[$i])) { redirect(append_sid($phpbb_root_path . 'portal.' . $phpEx, '#top')); } $forum_id = $fetch_news[$i]['forum_id']; $topic_id = $fetch_news[$i]['topic_id']; $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id, $global_announce_list = false); $unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false; $open_bracket = '[ '; $close_bracket = ' ]'; $read_full = $user->lang['BACK']; $real_forum_id = ($forum_id == 0) ? $fetch_news['global_id']: $forum_id; $read_full_url = (isset($_GET['ap'])) ? append_sid("{$phpbb_root_path}portal.$phpEx", "ap=$start#a$i") : append_sid("{$phpbb_root_path}portal.$phpEx#a$i"); $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id); if ($config['board3_announcements_archive_' . $module_id]) { $pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_announcements, $config['board3_number_of_announcements_' . $module_id], $start, 'announcements'); } $template->assign_block_vars('announcements_center_row', array( 'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $config['allow_attachments']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 'FORUM_NAME' => ($forum_id) ? $fetch_news[$i]['forum_name'] : '', 'TITLE' => $fetch_news[$i]['topic_title'], 'POSTER' => $fetch_news[$i]['username'], 'POSTER_FULL' => $fetch_news[$i]['username_full'], 'TIME' => $fetch_news[$i]['topic_time'], 'TEXT' => $fetch_news[$i]['post_text'], 'REPLIES' => $fetch_news[$i]['topic_replies'], 'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'], 'A_ID' => $i, 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $fetch_news[$i]['forum_id']), 'U_LAST_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id . '&p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']), 'U_VIEW_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id), 'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&' . (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id), 'S_POLL' => $fetch_news[$i]['poll'], 'S_UNREAD_INFO' => $unread_topic, 'U_READ_FULL' => $read_full_url, 'L_READ_FULL' => $read_full, 'OPEN' => $open_bracket, 'CLOSE' => $close_bracket, 'PAGINATION' => topic_generate_pagination($fetch_news[$i]['topic_replies'], $view_topic_url), 'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false, )); if(!empty($fetch_news[$i]['attachments'])) { foreach ($fetch_news[$i]['attachments'] as $attachment) { $template->assign_block_vars('announcements_center_row.attachment', array( 'DISPLAY_ATTACHMENT' => $attachment) ); } } if ($config['board3_number_of_announcements_' . $module_id] <> 0 && $config['board3_announcements_archive_' . $module_id]) { $template->assign_vars(array( 'AP_PAGINATION' => $pagination, 'TOTAL_ANNOUNCEMENTS' => ($total_announcements == 1) ? $user->lang['VIEW_LATEST_ANNOUNCEMENT'] : sprintf($user->lang['VIEW_LATEST_ANNOUNCEMENTS'], $total_announcements), 'AP_PAGE_NUMBER' => on_page($total_announcements, $config['board3_number_of_announcements_' . $module_id], $start)) ); } } } $topic_icons = false; if(!empty($fetch_news['topic_icons'])) { $topic_icons = true; } $template->assign_vars(array( 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), 'READ_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'GOTO_PAGE_IMG' => $user->img('icon_post_target', 'GOTO_PAGE'), 'S_DISPLAY_ANNOUNCEMENTS_RVS' => ($config['board3_show_announcements_replies_views_' . $module_id]) ? true : false, 'S_TOPIC_ICONS' => $topic_icons, )); if ($config['board3_announcements_style_' . $module_id]) { return 'announcements_center_compact.html'; } else { return 'announcements_center.html'; } }
function main($id, $mode) { global $auth, $db, $user, $template, $cache; global $config, $phpbb_root_path, $phpEx, $action; include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); $forum_id = request_var('f', 0); $start = request_var('start', 0); $this->page_title = 'MCP_REPORTS'; switch ($action) { case 'close': case 'delete': include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); $report_id_list = request_var('report_id_list', array(0)); if (!sizeof($report_id_list)) { trigger_error('NO_REPORT_SELECTED'); } close_report($report_id_list, $mode, $action); break; } switch ($mode) { case 'report_details': $user->add_lang('posting'); $post_id = request_var('p', 0); // closed reports are accessed by report id $report_id = request_var('r', 0); $sql = 'SELECT r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour FROM ' . REPORTS_TABLE . ' r, ' . REPORTS_REASONS_TABLE . ' rr, ' . USERS_TABLE . ' u WHERE ' . (($report_id) ? 'r.report_id = ' . $report_id : "r.post_id = $post_id") . ' AND rr.reason_id = r.reason_id AND r.user_id = u.user_id ORDER BY report_closed ASC'; $result = $db->sql_query_limit($sql, 1); $report = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$report) { trigger_error('NO_REPORT'); } if (!$report_id && $report['report_closed']) { trigger_error('REPORT_CLOSED'); } $post_id = $report['post_id']; $report_id = $report['report_id']; $post_info = get_post_data(array($post_id), 'm_report', true); if (!sizeof($post_info)) { trigger_error('NO_REPORT_SELECTED'); } $post_info = $post_info[$post_id]; $reason = array('title' => $report['reason_title'], 'description' => $report['reason_description']); if (isset($user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])])) { $reason['description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])]; $reason['title'] = $user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]; } if (topic_review($post_info['topic_id'], $post_info['forum_id'], 'topic_review', 0, false)) { $template->assign_vars(array( 'S_TOPIC_REVIEW' => true, 'TOPIC_TITLE' => $post_info['topic_title']) ); } $topic_tracking_info = $extensions = $attachments = array(); // Get topic tracking info if ($config['load_db_lastread']) { $tmp_topic_data = array($post_info['topic_id'] => $post_info); $topic_tracking_info = get_topic_tracking($post_info['forum_id'], $post_info['topic_id'], $tmp_topic_data, array($post_info['forum_id'] => $post_info['forum_mark_time'])); unset($tmp_topic_data); } else { $topic_tracking_info = get_complete_topic_tracking($post_info['forum_id'], $post_info['topic_id']); } $post_unread = (isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']]) ? true : false; // Process message, leave it uncensored $message = $post_info['post_text']; if ($post_info['bbcode_bitfield']) { include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); $bbcode = new bbcode($post_info['bbcode_bitfield']); $bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']); } $message = bbcode_nl2br($message); $message = smiley_text($message); if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) { $extensions = $cache->obtain_attach_extensions($post_info['forum_id']); $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE post_msg_id = ' . $post_id . ' AND in_message = 0 ORDER BY filetime DESC, post_msg_id ASC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $attachments[] = $row; } $db->sql_freeresult($result); if (sizeof($attachments)) { $update_count = array(); parse_attachments($post_info['forum_id'], $message, $attachments, $update_count); } // Display not already displayed Attachments for this post, we already parsed them. ;) if (!empty($attachments)) { $template->assign_var('S_HAS_ATTACHMENTS', true); foreach ($attachments as $attachment) { $template->assign_block_vars('attachment', array( 'DISPLAY_ATTACHMENT' => $attachment) ); } } } $template->assign_vars(array( 'S_MCP_REPORT' => true, 'S_CLOSE_ACTION' => $this->u_action . '&p=' . $post_id . '&f=' . $forum_id, 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'], 'S_POST_UNAPPROVED' => !$post_info['post_approved'], 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_USER_NOTES' => true, 'U_EDIT' => ($auth->acl_get('m_edit', $post_info['forum_id'])) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '', 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_REPORTER_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $report['user_id']), 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $post_info['user_id']), 'U_MCP_WARN_REPORTER' => ($auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $report['user_id']) : '', 'U_MCP_WARN_USER' => ($auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $post_info['user_id']) : '', 'U_VIEW_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']), 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']), 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']), 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']), 'RETURN_REPORTS' => sprintf($user->lang['RETURN_REPORTS'], '<a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports' . (($post_info['post_reported']) ? '&mode=reports' : '&mode=reports_closed') . '&start=' . $start . '&f=' . $post_info['forum_id']) . '">', '</a>'), 'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']), 'REPORT_DATE' => $user->format_date($report['report_time']), 'REPORT_ID' => $report_id, 'REPORT_REASON_TITLE' => $reason['title'], 'REPORT_REASON_DESCRIPTION' => $reason['description'], 'REPORT_TEXT' => $report['report_text'], 'POST_AUTHOR_FULL' => get_username_string('full', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_AUTHOR' => get_username_string('username', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'REPORTER_FULL' => get_username_string('full', $report['user_id'], $report['username'], $report['user_colour']), 'REPORTER_COLOUR' => get_username_string('colour', $report['user_id'], $report['username'], $report['user_colour']), 'REPORTER_NAME' => get_username_string('username', $report['user_id'], $report['username'], $report['user_colour']), 'U_VIEW_REPORTER_PROFILE' => get_username_string('profile', $report['user_id'], $report['username'], $report['user_colour']), 'POST_PREVIEW' => $message, 'POST_SUBJECT' => ($post_info['post_subject']) ? $post_info['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_DATE' => $user->format_date($post_info['post_time']), 'POST_IP' => $post_info['poster_ip'], 'POST_IPADDR' => ($auth->acl_get('m_info', $post_info['forum_id']) && request_var('lookup', '')) ? @gethostbyaddr($post_info['poster_ip']) : '', 'POST_ID' => $post_info['post_id'], 'U_LOOKUP_IP' => ($auth->acl_get('m_info', $post_info['forum_id'])) ? $this->u_action . '&r=' . $report_id . '&p=' . $post_id . '&f=' . $forum_id . '&lookup=' . $post_info['poster_ip'] . '#ip' : '', )); $this->tpl_name = 'mcp_post'; break; case 'reports': case 'reports_closed': $topic_id = request_var('t', 0); $forum_info = array(); $forum_list_reports = get_forum_list('m_report', false, true); if ($topic_id && $forum_id) { $topic_info = get_topic_data(array($topic_id)); if (!sizeof($topic_info)) { trigger_error('TOPIC_NOT_EXIST'); } $topic_info = $topic_info[$topic_id]; $forum_id = $topic_info['forum_id']; } else if ($topic_id && !$forum_id) { $topic_id = 0; } $forum_list = array(); if (!$forum_id) { foreach ($forum_list_reports as $row) { $forum_list[] = $row['forum_id']; } if (!sizeof($forum_list)) { trigger_error('NOT_MODERATOR'); } $global_id = $forum_list[0]; $sql = 'SELECT SUM(forum_topics) as sum_forum_topics FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_list); $result = $db->sql_query($sql); $forum_info['forum_topics'] = (int) $db->sql_fetchfield('sum_forum_topics'); $db->sql_freeresult($result); } else { $forum_info = get_forum_data(array($forum_id), 'm_report'); if (!sizeof($forum_info)) { trigger_error('NOT_MODERATOR'); } $forum_info = $forum_info[$forum_id]; $forum_list = array($forum_id); $global_id = $forum_id; } $forum_list[] = 0; $forum_data = array(); $forum_options = '<option value="0"' . (($forum_id == 0) ? ' selected="selected"' : '') . '>' . $user->lang['ALL_FORUMS'] . '</option>'; foreach ($forum_list_reports as $row) { $forum_options .= '<option value="' . $row['forum_id'] . '"' . (($forum_id == $row['forum_id']) ? ' selected="selected"' : '') . '>' . str_repeat(' ', $row['padding']) . $row['forum_name'] . '</option>'; $forum_data[$row['forum_id']] = $row; } unset($forum_list_reports); $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id); $forum_topics = ($total == -1) ? $forum_info['forum_topics'] : $total; $limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : ''; if ($mode == 'reports') { $report_state = 'AND p.post_reported = 1 AND r.report_closed = 0'; } else { $report_state = 'AND r.report_closed = 1'; } $sql = 'SELECT r.report_id FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . REPORTS_TABLE . ' r ' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . (($sort_order_sql[0] == 'r') ? ', ' . USERS_TABLE . ' ru' : '') . ' WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . " $report_state AND r.post_id = p.post_id " . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . ' ' . (($sort_order_sql[0] == 'r') ? 'AND ru.user_id = p.poster_id' : '') . ' ' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . " AND t.topic_id = p.topic_id $limit_time_sql ORDER BY $sort_order_sql"; $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); $i = 0; $report_ids = array(); while ($row = $db->sql_fetchrow($result)) { $report_ids[] = $row['report_id']; $row_num[$row['report_id']] = $i++; } $db->sql_freeresult($result); if (sizeof($report_ids)) { $sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, p.post_id, p.post_subject, p.post_username, p.poster_id, p.post_time, u.username, u.username_clean, u.user_colour, r.user_id as reporter_id, ru.username as reporter_name, ru.user_colour as reporter_colour, r.report_time, r.report_id FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u, ' . USERS_TABLE . ' ru WHERE ' . $db->sql_in_set('r.report_id', $report_ids) . ' AND t.topic_id = p.topic_id AND r.post_id = p.post_id AND u.user_id = p.poster_id AND ru.user_id = r.user_id ORDER BY ' . $sort_order_sql; $result = $db->sql_query($sql); $report_data = $rowset = array(); while ($row = $db->sql_fetchrow($result)) { $global_topic = ($row['forum_id']) ? false : true; if ($global_topic) { $row['forum_id'] = $global_id; } $template->assign_block_vars('postrow', array( 'U_VIEWFORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '', 'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id']) . '#p' . $row['post_id'], 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=reports&start=$start&mode=report_details&f={$row['forum_id']}&r={$row['report_id']}"), 'POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'REPORTER_FULL' => get_username_string('full', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'REPORTER_COLOUR' => get_username_string('colour', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'REPORTER' => get_username_string('username', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'U_REPORTER' => get_username_string('profile', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'FORUM_NAME' => (!$global_topic) ? $forum_data[$row['forum_id']]['forum_name'] : $user->lang['GLOBAL_ANNOUNCEMENT'], 'POST_ID' => $row['post_id'], 'POST_SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_TIME' => $user->format_date($row['post_time']), 'REPORT_ID' => $row['report_id'], 'REPORT_TIME' => $user->format_date($row['report_time']), 'TOPIC_TITLE' => $row['topic_title']) ); } $db->sql_freeresult($result); unset($report_ids, $row); } // Now display the page $template->assign_vars(array( 'L_EXPLAIN' => ($mode == 'reports') ? $user->lang['MCP_REPORTS_OPEN_EXPLAIN'] : $user->lang['MCP_REPORTS_CLOSED_EXPLAIN'], 'L_TITLE' => ($mode == 'reports') ? $user->lang['MCP_REPORTS_OPEN'] : $user->lang['MCP_REPORTS_CLOSED'], 'L_ONLY_TOPIC' => ($topic_id) ? sprintf($user->lang['ONLY_TOPIC'], $topic_info['topic_title']) : '', 'S_MCP_ACTION' => $this->u_action, 'S_FORUM_OPTIONS' => $forum_options, 'S_CLOSED' => ($mode == 'reports_closed') ? true : false, 'PAGINATION' => generate_pagination($this->u_action . "&f=$forum_id&t=$topic_id&st=$sort_days&sk=$sort_key&sd=$sort_dir", $total, $config['topics_per_page'], $start), 'PAGE_NUMBER' => on_page($total, $config['topics_per_page'], $start), 'TOPIC_ID' => $topic_id, 'TOTAL' => $total, 'TOTAL_REPORTS' => ($total == 1) ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $total), ) ); $this->tpl_name = 'mcp_reports'; break; } }
public function toptopics($tpl_loopname = 'top_five_topic') { $howmany = $this->howmany(); $forum_ary = array(); $forum_read_ary = $this->auth->acl_getf('f_read'); foreach ($forum_read_ary as $forum_id => $allowed) { if ($allowed['f_read']) { $forum_ary[] = (int) $forum_id; } } $forum_ary = array_unique($forum_ary); if (sizeof($forum_ary)) { /** * Select topic_ids */ $sql = 'SELECT forum_id, topic_id, topic_type FROM ' . TOPICS_TABLE . ' WHERE ' . $this->content_visibility->get_forums_visibility_sql('topic', $forum_ary) . ' AND topic_status <> ' . ITEM_MOVED . ' ORDER BY topic_last_post_time DESC'; $result = $this->db->sql_query_limit($sql, $howmany); $forums = $ga_topic_ids = $topic_ids = array(); while ($row = $this->db->sql_fetchrow($result)) { $topic_ids[] = $row['topic_id']; if ($row['topic_type'] == POST_GLOBAL) { $ga_topic_ids[] = $row['topic_id']; } else { $forums[$row['forum_id']][] = $row['topic_id']; } } $this->db->sql_freeresult($result); // Get topic tracking $topic_tracking_info = array(); foreach ($forums as $forum_id => $topic_id) { $topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $topic_id, $ga_topic_ids); } /* * must have topic_ids. * A user can have forums and not have topic_ids before installing this extension */ if (sizeof($topic_ids)) { // grab all posts that meet criteria and auths $sql_array = array('SELECT' => 'u.user_id, u.username, u.user_colour, t.topic_title, t.forum_id, t.topic_id, t.topic_first_post_id, t.topic_last_post_id, t.topic_last_post_time, t.topic_last_poster_name, f.forum_name', 'FROM' => array(TOPICS_TABLE => 't'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 't.topic_last_poster_id = u.user_id'), array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 't.forum_id = f.forum_id')), 'WHERE' => $this->db->sql_in_set('t.topic_id', $topic_ids), 'ORDER_BY' => 't.topic_last_post_time DESC'); /** * Event to modify the SQL query before the topics data is retrieved * * @event rmcgirr83.topfive.sql_pull_topics_data * @var array sql_array The SQL array * @since 1.0.0 */ $vars = array('sql_array'); extract($this->dispatcher->trigger_event('rmcgirr83.topfive.sql_pull_topics_data', compact($vars))); // cache the query for one minute $result = $this->db->sql_query_limit($this->db->sql_build_query('SELECT', $sql_array), $howmany, 0, 60); while ($row = $this->db->sql_fetchrow($result)) { $topic_id = $row['topic_id']; $forum_id = $row['forum_id']; $forum_name = $row['forum_name']; $post_unread = isset($topic_tracking_info[$forum_id][$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$forum_id][$topic_id] ? true : false; $view_topic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $row['forum_id'] . '&p=' . $row['topic_last_post_id'] . '#p' . $row['topic_last_post_id']); $forum_name_url = append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $row['forum_id']); $topic_title = censor_text($row['topic_title']); $topic_title = truncate_string($topic_title, 60, 255, false, $this->user->lang['ELLIPSIS']); $is_guest = $row['user_id'] == ANONYMOUS ? true : false; $tpl_ary = array('U_TOPIC' => $view_topic_url, 'U_FORUM' => $forum_name_url, 'S_UNREAD' => $post_unread ? true : false, 'USERNAME_FULL' => $is_guest || !$this->auth->acl_get('u_viewprofile') ? $this->user->lang['POST_BY_AUTHOR'] . ' ' . get_username_string('no_profile', $row['user_id'], $row['username'], $row['user_colour'], $row['topic_last_poster_name']) : $this->user->lang['POST_BY_AUTHOR'] . ' ' . get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'LAST_TOPIC_TIME' => $this->user->format_date($row['topic_last_post_time']), 'TOPIC_TITLE' => $topic_title, 'FORUM_NAME' => $forum_name); /** * Modify the topic data before it is assigned to the template * * @event rmcgirr83.topfive.modify_tpl_ary * @var array row Array with topic data * @var array tpl_ary Template block array with topic data * @since 1.0.0 */ $vars = array('row', 'tpl_ary'); extract($this->dispatcher->trigger_event('rmcgirr83.topfive.modify_tpl_ary', compact($vars))); $this->template->assign_block_vars($tpl_loopname, $tpl_ary); } $this->db->sql_freeresult($result); } else { $this->template->assign_block_vars($tpl_loopname, array('NO_TOPIC_TITLE' => $this->user->lang['NO_TOPIC_EXIST'])); } } else { $this->template->assign_block_vars($tpl_loopname, array('NO_TOPIC_TITLE' => $this->user->lang['NO_TOPIC_EXIST'])); } }
/** * Returns an array of ideas. Defaults to ten ideas ordered by date * excluding duplicate or rejected ideas. * * @param int $number The number of ideas to return. * @param string $sort Thing to sort by. * @param string $sort_direction ASC / DESC. * @param array|int $status The id of the status(es) to load * @param int $start Start value for pagination * * @return array Array of row data */ public function get_ideas($number = 10, $sort = 'date', $sort_direction = 'DESC', $status = array(), $start = 0) { switch (strtolower($sort)) { case self::SORT_AUTHOR: $sortby = 'idea_author ' . $sort_direction; break; case self::SORT_DATE: $sortby = 'idea_date ' . $sort_direction; break; case self::SORT_SCORE: $sortby = 'CAST(idea_votes_up AS decimal) - CAST(idea_votes_down AS decimal) ' . $sort_direction; break; case self::SORT_TITLE: $sortby = 'idea_title ' . $sort_direction; break; case self::SORT_VOTES: $sortby = 'idea_votes_up + idea_votes_down ' . $sort_direction; break; case self::SORT_TOP: // Special case! $sortby = 'TOP'; break; default: // Special case! $sortby = 'ALL'; break; } // If we have a $status value or array lets use it, // otherwise lets exclude implemented, invalid and duplicate by default $where = !empty($status) ? $this->db->sql_in_set('idea_status', $status) : $this->db->sql_in_set('idea_status', array(self::$statuses['IMPLEMENTED'], self::$statuses['DUPLICATE'], self::$statuses['INVALID']), true); if ($sortby === 'TOP') { $where .= ' AND idea_votes_up > idea_votes_down'; } // Count the total number of ideas for pagination if ($number >= $this->config['posts_per_page']) { $sql = 'SELECT COUNT(idea_id) as num_ideas FROM ' . $this->table_ideas . "\n\t\t\t\tWHERE {$where}"; $result = $this->db->sql_query($sql); $num_ideas = (int) $this->db->sql_fetchfield('num_ideas'); $this->db->sql_freeresult($result); // Set the total number of ideas for pagination $this->idea_count = $num_ideas; } if ($sortby !== 'TOP' && $sortby !== 'ALL') { $sql = 'SELECT * FROM ' . $this->table_ideas . "\n\t\t\t\tWHERE {$where}\n\t\t\t\tORDER BY " . $this->db->sql_escape($sortby); } else { // YEEEEEEEEAAAAAAAAAAAAAHHHHHHH // From http://evanmiller.org/how-not-to-sort-by-average-rating.html $sql = 'SELECT *, ((idea_votes_up + 1.9208) / (idea_votes_up + idea_votes_down) - 1.96 * SQRT((idea_votes_up * idea_votes_down) / (idea_votes_up + idea_votes_down) + 0.9604) / (idea_votes_up + idea_votes_down)) / (1 + 3.8416 / (idea_votes_up + idea_votes_down)) AS ci_lower_bound FROM ' . $this->table_ideas . "\n \t\t\t\tWHERE {$where}\n \t\t\tORDER BY ci_lower_bound " . $this->db->sql_escape($sort_direction); } $result = $this->db->sql_query_limit($sql, $number, $start); $rows = $this->db->sql_fetchrowset($result); $this->db->sql_freeresult($result); if (count($rows)) { $topic_ids = array(); foreach ($rows as $row) { $topic_ids[] = $row['topic_id']; } $topic_tracking_info = get_complete_topic_tracking((int) $this->config['ideas_forum_id'], $topic_ids); $last_times = array(); $sql = 'SELECT topic_id, topic_last_post_time FROM ' . TOPICS_TABLE . ' WHERE ' . $this->db->sql_in_set('topic_id', $topic_ids); $result = $this->db->sql_query($sql); while ($last_time = $this->db->sql_fetchrow($result)) { $last_times[$last_time['topic_id']] = $last_time['topic_last_post_time']; } $this->db->sql_freeresult($result); foreach ($rows as &$row) { $topic_id = $row['topic_id']; $row['read'] = !(isset($topic_tracking_info[$topic_id]) && $last_times[$topic_id] > $topic_tracking_info[$topic_id]); } } return $rows; }
public function topposts_of_period($tpl_loopname = 'post_of_the_day', $period = 'month') { switch ($period) { case 'day': $howmany = $this->config['post_of_the_day_how_many_today']; $period_time = SECONDS_PER_DAY; $slack_time = SECONDS_PER_HOUR; $cache_time = SECONDS_PER_MINUTE; $period_name = 'LIKES_TODAY'; break; case 'week': $howmany = $this->config['post_of_the_day_how_many_this_week']; $period_time = SECONDS_PER_DAY * 7; $slack_time = SECONDS_PER_HOUR * 12; $cache_time = SECONDS_PER_MINUTE; $period_name = 'LIKES_THIS_WEEK'; break; case 'month': $howmany = $this->config['post_of_the_day_how_many_this_month']; $period_time = SECONDS_PER_DAY * 31; $slack_time = SECONDS_PER_HOUR * 12; $cache_time = SECONDS_PER_MINUTE; $period_name = 'LIKES_THIS_MONTH'; break; case 'year': $howmany = $this->config['post_of_the_day_how_many_this_year']; $period_time = SECONDS_PER_DAY * 366; $slack_time = SECONDS_PER_HOUR * 12; $cache_time = SECONDS_PER_MINUTE; $period_name = 'LIKES_THIS_YEAR'; break; } if ($howmany == 0) { return; } $forum_ary = array(); $forum_read_ary = $this->auth->acl_getf('f_read'); foreach ($forum_read_ary as $forum_id => $allowed) { if ($allowed['f_read']) { $forum_ary[] = (int) $forum_id; } } $forum_ary = array_unique($forum_ary); if (sizeof($forum_ary)) { // calculate the timestamp that we are interested in $time_threshold = time() - $period_time; // floor to an even hour to improve sql caching performance $time_threshold = $time_threshold - $time_threshold % $slack_time; /** * Select post_ids */ // find all the visible, liked posts in the given period $sql = 'SELECT ' . USERS_TABLE . '.user_id, ' . USERS_TABLE . '.username, ' . USERS_TABLE . '.user_colour, ' . TOPICS_TABLE . '.topic_title, ' . TOPICS_TABLE . '.forum_id, ' . TOPICS_TABLE . '.topic_id, ' . POSTS_TABLE . '.post_id, ' . POSTS_TABLE . '.post_time, ' . TOPICS_TABLE . '.topic_last_poster_name, ' . TOPICS_TABLE . '.topic_type, ' . FORUMS_TABLE . '.forum_name, sum_likes FROM ( SELECT post_id AS post, COUNT(*) AS sum_likes FROM ' . POSTS_LIKES_TABLE . ' WHERE ' . POSTS_LIKES_TABLE . '.timestamp > ' . $time_threshold . ' GROUP BY post_id ORDER BY sum_likes DESC ) AS liked_posts LEFT JOIN ' . POSTS_TABLE . ' ON post = post_id LEFT JOIN ' . TOPICS_TABLE . ' ON ' . POSTS_TABLE . '.topic_id = ' . TOPICS_TABLE . '.topic_id LEFT JOIN ' . USERS_TABLE . ' ON ' . POSTS_TABLE . '.poster_id = ' . USERS_TABLE . '.user_id LEFT JOIN ' . FORUMS_TABLE . ' ON ' . TOPICS_TABLE . '.forum_id = ' . FORUMS_TABLE . '.forum_id WHERE ' . $this->content_visibility->get_forums_visibility_sql('post', $forum_ary, POSTS_TABLE . '.') . ' AND topic_status <> ' . ITEM_MOVED . ' ORDER BY sum_likes DESC, post_time DESC'; // cache the query for one minute $result = $this->db->sql_query_limit($sql, $howmany, 0, $cache_time); $forums = $ga_topic_ids = $topic_ids = array(); while ($row = $this->db->sql_fetchrow($result)) { $topic_ids[] = $row['topic_id']; if ($row['topic_type'] == POST_GLOBAL) { $ga_topic_ids[] = $row['topic_id']; } else { $forums[$row['forum_id']][] = $row['topic_id']; } } // Get topic tracking $topic_tracking_info = array(); foreach ($forums as $forum_id => $topic_id) { $topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $topic_id, $ga_topic_ids); } $this->db->sql_rowseek(0, $result); while ($row = $this->db->sql_fetchrow($result)) { $topic_id = $row['topic_id']; $forum_id = $row['forum_id']; $forum_name = $row['forum_name']; $post_unread = isset($topic_tracking_info[$forum_id][$topic_id]) && $row['post_time'] > $topic_tracking_info[$forum_id][$topic_id] ? true : false; $view_topic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . '&p=' . $row['post_id'] . '#p' . $row['post_id']); $forum_name_url = append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $row['forum_id']); $topic_title = censor_text($row['topic_title']); if (utf8_strlen($topic_title) >= 60) { $topic_title = utf8_strlen($topic_title) > 60 + 3 ? utf8_substr($topic_title, 0, 60) . '...' : $topic_title; } $is_guest = $row['user_id'] == ANONYMOUS ? true : false; $tpl_ary = array('U_TOPIC' => $view_topic_url, 'U_FORUM' => $forum_name_url, 'S_UNREAD' => $post_unread ? true : false, 'USERNAME_FULL' => $is_guest || !$this->auth->acl_get('u_viewprofile') ? $this->user->lang['POST_BY_AUTHOR'] . ' ' . get_username_string('no_profile', $row['user_id'], $row['username'], $row['user_colour'], $row['topic_last_poster_name']) : $this->user->lang['POST_BY_AUTHOR'] . ' ' . get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'POST_TIME' => $this->user->format_date($row['post_time']), 'TOPIC_TITLE' => $topic_title, 'FORUM_NAME' => $forum_name, 'POST_LIKES_IN_PERIOD' => $this->user->lang($period_name, $row['sum_likes'])); /** * Modify the topic data before it is assigned to the template * * @event v12mike.postoftheday.modify_tpl_ary * @var array row Array with topic data * @var array tpl_ary Template block array with topic data * @since 1.0.0 */ $vars = array('row', 'tpl_ary'); extract($this->dispatcher->trigger_event('v12mike.postoftheday.modify_tpl_ary', compact($vars))); $this->template->assign_block_vars($tpl_loopname, $tpl_ary); } $this->db->sql_freeresult($result); } else { $this->template->assign_block_vars($tpl_loopname, array('NO_TOPIC_TITLE' => $this->user->lang['NO_TOPIC_EXIST'])); } }
function display_recent_topics($topics_per_page, $num_pages, $excluded_topics, $tpl_loopname = 'recenttopicrow', $spec_forum_id = 0, $include_subforums = true, $display_parent_forums = true) { global $auth, $cache, $config, $db, $template, $user; global $phpbb_root_path, $phpEx; $user->add_lang('mods/info_acp_recenttopics'); /** * Set some internal needed variables */ $start = request_var($tpl_loopname . '_start', 0); $excluded_topic_ids = explode(', ', $excluded_topics); $total_limit = $topics_per_page * $num_pages; $ga_forum_id = 0; // Forum id we use for global announcements /** * Get the forums we take our topics from */ // Get the allowed forums $forum_ary = array(); $forum_read_ary = $auth->acl_getf('f_read'); foreach ($forum_read_ary as $forum_id => $allowed) { if ($allowed['f_read']) { $forum_ary[] = (int) $forum_id; } } $forum_ids = array_unique($forum_ary); if (!sizeof($forum_ids)) { // No forums with f_read return; } $spec_forum_ary = array(); if ($spec_forum_id) { // Only take a special-forum if (!$include_subforums) { if (!in_array($spec_forum_id, $forum_ids)) { return; } $forum_ids = array(); $sql = 'SELECT 1 as display_forum FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $spec_forum_id . ' AND forum_recent_topics = 1'; $result = $db->sql_query_limit($sql, 1); $display_forum = (bool) $db->sql_fetchfield('display_forum'); $db->sql_freeresult($result); if ($display_forum) { $forum_ids = array($spec_forum_id); } } else { // ... and it's subforums $sql = 'SELECT f2.forum_id FROM ' . FORUMS_TABLE . ' f1 LEFT JOIN ' . FORUMS_TABLE . " f2\n\t\t\t\t\tON (f2.left_id BETWEEN f1.left_id AND f1.right_id\n\t\t\t\t\t\tAND f2.forum_recent_topics = 1)\n\t\t\t\tWHERE f1.forum_id = {$spec_forum_id}\n\t\t\t\t\tAND f1.forum_recent_topics = 1\n\t\t\t\tORDER BY f2.left_id DESC"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $spec_forum_ary[] = $row['forum_id']; } $db->sql_freeresult($result); $forum_ids = array_intersect($forum_ids, $spec_forum_ary); if (!sizeof($forum_ids)) { return; } } } else { $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_ids) . ' AND forum_recent_topics = 1'; $result = $db->sql_query($sql); $forum_ids = array(); while ($row = $db->sql_fetchrow($result)) { $forum_ids[] = $row['forum_id']; } $db->sql_freeresult($result); } // No forums with f_read if (!sizeof($forum_ids)) { return; } // Moderator forums $m_approve_ids = array(); $m_approve_ary = $auth->acl_getf('m_approve'); foreach ($m_approve_ary as $forum_id => $allowed) { if ($allowed['m_approve'] && in_array($forum_id, $forum_ids)) { $m_approve_ids[] = (int) $forum_id; } } // Get the allowed topics $sql_query_array = array('SELECT' => 't.forum_id, t.topic_id, t.topic_type, t.icon_id, tt.mark_time, ft.mark_time as f_mark_time', 'FROM' => array(TOPICS_TABLE => 't'), 'LEFT_JOIN' => array(array('FROM' => array(TOPICS_TRACK_TABLE => 'tt'), 'ON' => 'tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id']), array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.forum_id = t.forum_id AND ft.user_id = ' . $user->data['user_id'])), 'WHERE' => ' ( (' . $db->sql_in_set('t.topic_id', $excluded_topic_ids, true) . ' AND ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' ) OR t.topic_type = ' . POST_GLOBAL . ' ) AND t.topic_status <> ' . ITEM_MOVED . ' AND (' . $db->sql_in_set('t.forum_id', $m_approve_ids, false, true) . ' OR t.topic_approved = 1)', 'ORDER_BY' => 't.topic_last_post_time DESC'); // Is a soft delete MOD installed? if (file_exists("{$phpbb_root_path}includes/mods/soft_delete.{$phpEx}")) { $sql_query_array['WHERE'] .= ' AND topic_deleted = 0'; } $sql = $db->sql_build_query('SELECT', $sql_query_array); $result = $db->sql_query_limit($sql, $total_limit); $forums = $ga_topic_ids = $topic_ids = array(); $num_topics = 0; $obtain_icons = false; while ($row = $db->sql_fetchrow($result)) { $num_topics++; if ($num_topics > $start && $num_topics <= $start + $topics_per_page) { $topic_ids[] = $row['topic_id']; $rowset[$row['topic_id']] = $row; if (!isset($forums[$row['forum_id']]) && $user->data['is_registered'] && $config['load_db_lastread']) { $forums[$row['forum_id']]['mark_time'] = $row['f_mark_time']; } $forums[$row['forum_id']]['topic_list'][] = $row['topic_id']; $forums[$row['forum_id']]['rowset'][$row['topic_id']] =& $rowset[$row['topic_id']]; if ($row['icon_id'] && $auth->acl_get('f_icons', $row['forum_id'])) { $obtain_icons = true; } } } $db->sql_freeresult($result); // No topics to display if (!sizeof($topic_ids)) { return; } // Grab icons if ($obtain_icons) { $icons = $cache->obtain_icons(); } else { $icons = array(); } // Borrowed from search.php foreach ($forums as $forum_id => $forum) { if ($user->data['is_registered'] && $config['load_db_lastread']) { $topic_tracking_info[$forum_id] = get_topic_tracking($forum_id, $forum['topic_list'], $forum['rowset'], array($forum_id => $forum['mark_time']), $forum_id ? false : $forum['topic_list']); } else { if ($config['load_anon_lastread'] || $user->data['is_registered']) { $tracking_topics = isset($_COOKIE[$config['cookie_name'] . '_track']) ? STRIP ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track'] : ''; $tracking_topics = $tracking_topics ? tracking_unserialize($tracking_topics) : array(); $topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $forum['topic_list'], $forum_id ? false : $forum['topic_list']); if (!$user->data['is_registered']) { $user->data['user_lastmark'] = isset($tracking_topics['l']) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0; } } } } // Now only pull the data of the requested topics $sql_query_array = array('SELECT' => 't.*, tp.topic_posted, f.forum_name', 'FROM' => array(TOPICS_TABLE => 't'), 'LEFT_JOIN' => array(array('FROM' => array(TOPICS_POSTED_TABLE => 'tp'), 'ON' => 't.topic_id = tp.topic_id AND tp.user_id = ' . $user->data['user_id']), array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = t.forum_id')), 'WHERE' => $db->sql_in_set('t.topic_id', $topic_ids), 'ORDER_BY' => 't.topic_last_post_time DESC'); if ($display_parent_forums) { $sql_query_array['SELECT'] .= ', f.parent_id, f.forum_parents, f.left_id, f.right_id'; } $sql = $db->sql_build_query('SELECT', $sql_query_array); $result = $db->sql_query_limit($sql, $topics_per_page); $topic_icons = array(); while ($row = $db->sql_fetchrow($result)) { $topic_id = $row['topic_id']; $forum_id = $row['forum_id']; // Cheat for Global Announcements on the unread-link: copied from search.php if (!$forum_id && !$ga_forum_id) { $sql2 = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' WHERE forum_type = ' . FORUM_POST . ' AND ' . $db->sql_in_set('forum_id', $forum_ary, false, true); $result2 = $db->sql_query_limit($sql2, 1); $ga_forum_id = (int) $db->sql_fetchfield('forum_id'); $db->sql_freeresult($result2); $forum_id = $ga_forum_id; } else { if (!$forum_id && $ga_forum_id) { $forum_id = $ga_forum_id; } } $s_type_switch_test = $row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL ? 1 : 0; $replies = $auth->acl_get('m_approve', $forum_id) ? $row['topic_replies_real'] : $row['topic_replies']; topic_status($row, $replies, isset($topic_tracking_info[$forum_id][$row['topic_id']]) && $row['topic_last_post_time'] > $topic_tracking_info[$forum_id][$row['topic_id']] ? true : false, $folder_img, $folder_alt, $topic_type); $unread_topic = isset($topic_tracking_info[$forum_id][$row['topic_id']]) && $row['topic_last_post_time'] > $topic_tracking_info[$forum_id][$row['topic_id']] ? true : false; $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $forum_id . '&t=' . $topic_id); $view_forum_url = append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $forum_id); $topic_unapproved = !$row['topic_approved'] && $auth->acl_get('m_approve', $forum_id) ? true : false; $posts_unapproved = $row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $forum_id) ? true : false; $u_mcp_queue = $topic_unapproved || $posts_unapproved ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&mode=' . ($topic_unapproved ? 'approve_details' : 'unapproved_posts') . "&t={$topic_id}", true, $user->session_id) : ''; $s_type_switch = $row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL ? 1 : 0; if (!empty($icons[$row['icon_id']])) { $topic_icons[] = $topic_id; } $template->assign_block_vars($tpl_loopname, array('FORUM_ID' => $forum_id, 'TOPIC_ID' => $topic_id, 'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'FIRST_POST_TIME' => $user->format_date($row['topic_time']), 'LAST_POST_SUBJECT' => censor_text($row['topic_last_post_subject']), 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), 'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']), 'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'PAGINATION' => topic_generate_pagination($replies, $view_topic_url), 'REPLIES' => $replies, 'VIEWS' => $row['topic_views'], 'TOPIC_TITLE' => censor_text($row['topic_title']), 'FORUM_NAME' => $row['forum_name'], 'TOPIC_TYPE' => $topic_type, 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'), 'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt], 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), 'TOPIC_ICON_IMG' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['img'] : '', 'TOPIC_ICON_IMG_WIDTH' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['width'] : '', 'TOPIC_ICON_IMG_HEIGHT' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['height'] : '', 'ATTACH_ICON_IMG' => $auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment'] ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 'UNAPPROVED_IMG' => $topic_unapproved || $posts_unapproved ? $user->img('icon_topic_unapproved', $topic_unapproved ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', 'REPORTED_IMG' => $row['topic_reported'] && $auth->acl_get('m_report', $forum_id) ? $user->img('icon_topic_reported', 'TOPIC_REPORTED') : '', 'S_TOPIC_TYPE' => $row['topic_type'], 'S_USER_POSTED' => isset($row['topic_posted']) && $row['topic_posted'] ? true : false, 'S_UNREAD_TOPIC' => $unread_topic, 'S_TOPIC_REPORTED' => $row['topic_reported'] && $auth->acl_get('m_report', $forum_id) ? true : false, 'S_TOPIC_UNAPPROVED' => $topic_unapproved, 'S_POSTS_UNAPPROVED' => $posts_unapproved, 'S_HAS_POLL' => $row['poll_start'] ? true : false, 'S_POST_ANNOUNCE' => $row['topic_type'] == POST_ANNOUNCE ? true : false, 'S_POST_GLOBAL' => $row['topic_type'] == POST_GLOBAL ? true : false, 'S_POST_STICKY' => $row['topic_type'] == POST_STICKY ? true : false, 'S_TOPIC_LOCKED' => $row['topic_status'] == ITEM_LOCKED ? true : false, 'S_TOPIC_MOVED' => $row['topic_status'] == ITEM_MOVED ? true : false, 'S_TOPIC_TYPE_SWITCH' => $s_type_switch == $s_type_switch_test ? -1 : $s_type_switch_test, 'U_NEWEST_POST' => $view_topic_url . '&view=unread#unread', 'U_LAST_POST' => $view_topic_url . '&p=' . $row['topic_last_post_id'] . '#p' . $row['topic_last_post_id'], 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'U_VIEW_TOPIC' => $view_topic_url, 'U_VIEW_FORUM' => $view_forum_url, 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&mode=reports&f=' . $forum_id . '&t=' . $topic_id, true, $user->session_id), 'U_MCP_QUEUE' => $u_mcp_queue)); if ($display_parent_forums) { $forum_parents = get_forum_parents($row); foreach ($forum_parents as $parent_id => $data) { $template->assign_block_vars($tpl_loopname . '.parent_forums', array('FORUM_ID' => $parent_id, 'FORUM_NAME' => $data[0], 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $parent_id))); } } } $db->sql_freeresult($result); // Get URL-parameters for pagination $url_params = explode('&', $user->page['query_string']); $append_params = false; foreach ($url_params as $param) { if (!$param) { continue; } if (strpos($param, '=') === false) { // Fix MSSTI Advanced BBCode MOD $append_params[$param] = '1'; continue; } list($name, $value) = explode('=', $param); if ($name != $tpl_loopname . '_start') { $append_params[$name] = $value; } } $template->assign_vars(array('S_TOPIC_ICONS' => sizeof($topic_icons) ? true : false, 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), strtoupper($tpl_loopname) . '_DISPLAY' => true, strtoupper($tpl_loopname) . '_PAGE_NUMBER' => on_page($num_topics, $topics_per_page, $start), strtoupper($tpl_loopname) . '_PAGINATION' => recent_topics_generate_pagination(append_sid($phpbb_root_path . $user->page['page_name'], $append_params), $num_topics, $topics_per_page, $start, false, strtoupper($tpl_loopname), $tpl_loopname . '_start', $tpl_loopname))); }
/** * MCP Forum View */ function mcp_forum_view($id, $mode, $action, $forum_info) { global $template, $db, $user, $auth, $cache, $module; global $phpEx, $phpbb_root_path, $config; global $request, $phpbb_dispatcher, $phpbb_container; $user->add_lang(array('viewtopic', 'viewforum')); include_once $phpbb_root_path . 'includes/functions_display.' . $phpEx; // merge_topic is the quickmod action, merge_topics is the mcp_forum action, and merge_select is the mcp_topic action $merge_select = $action == 'merge_select' || $action == 'merge_topic' || $action == 'merge_topics' ? true : false; $forum_id = $forum_info['forum_id']; $start = $request->variable('start', 0); $topic_id_list = $request->variable('topic_id_list', array(0)); $post_id_list = $request->variable('post_id_list', array(0)); $source_topic_ids = array($request->variable('t', 0)); $to_topic_id = $request->variable('to_topic_id', 0); $url_extra = ''; $url_extra .= $forum_id ? "&f={$forum_id}" : ''; $url_extra .= $GLOBALS['topic_id'] ? '&t=' . $GLOBALS['topic_id'] : ''; $url_extra .= $GLOBALS['post_id'] ? '&p=' . $GLOBALS['post_id'] : ''; $url_extra .= $GLOBALS['user_id'] ? '&u=' . $GLOBALS['user_id'] : ''; $url = append_sid("{$phpbb_root_path}mcp.{$phpEx}?{$url_extra}"); // Resync Topics switch ($action) { case 'resync': $topic_ids = $request->variable('topic_id_list', array(0)); mcp_resync_topics($topic_ids); break; case 'merge_topics': $source_topic_ids = $topic_id_list; case 'merge_topic': if ($to_topic_id) { merge_topics($forum_id, $source_topic_ids, $to_topic_id); } break; } /** * Get some data in order to execute other actions. * * @event core.mcp_forum_view_before * @var string action The action * @var array forum_info Array with forum infos * @var int start Start value * @var array topic_id_list Array of topics ids * @var array post_id_list Array of posts ids * @var array source_topic_ids Array of source topics ids * @var int to_topic_id Array of destination topics ids * @since 3.1.6-RC1 */ $vars = array('action', 'forum_info', 'start', 'topic_id_list', 'post_id_list', 'source_topic_ids', 'to_topic_id'); extract($phpbb_dispatcher->trigger_event('core.mcp_forum_view_before', compact($vars))); /* @var $pagination \phpbb\pagination */ $pagination = $phpbb_container->get('pagination'); $selected_ids = ''; if (sizeof($post_id_list) && $action != 'merge_topics') { foreach ($post_id_list as $num => $post_id) { $selected_ids .= '&post_id_list[' . $num . ']=' . $post_id; } } else { if (sizeof($topic_id_list) && $action == 'merge_topics') { foreach ($topic_id_list as $num => $topic_id) { $selected_ids .= '&topic_id_list[' . $num . ']=' . $topic_id; } } } make_jumpbox($url . "&i={$id}&action={$action}&mode={$mode}" . ($merge_select ? $selected_ids : ''), $forum_id, false, 'm_', true); $topics_per_page = $forum_info['forum_topics_per_page'] ? $forum_info['forum_topics_per_page'] : $config['topics_per_page']; $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); phpbb_mcp_sorting('viewforum', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id); $forum_topics = $total == -1 ? $forum_info['forum_topics_approved'] : $total; $limit_time_sql = $sort_days ? 'AND t.topic_last_post_time >= ' . (time() - $sort_days * 86400) : ''; $base_url = $url . "&i={$id}&action={$action}&mode={$mode}&sd={$sort_dir}&sk={$sort_key}&st={$sort_days}" . ($merge_select ? $selected_ids : ''); $pagination->generate_template_pagination($base_url, 'pagination', 'start', $forum_topics, $topics_per_page, $start); $template->assign_vars(array('ACTION' => $action, 'FORUM_NAME' => $forum_info['forum_name'], 'FORUM_DESCRIPTION' => generate_text_for_display($forum_info['forum_desc'], $forum_info['forum_desc_uid'], $forum_info['forum_desc_bitfield'], $forum_info['forum_desc_options']), 'REPORTED_IMG' => $user->img('icon_topic_reported', 'TOPIC_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'), 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), 'S_CAN_REPORT' => $auth->acl_get('m_report', $forum_id), 'S_CAN_DELETE' => $auth->acl_get('m_delete', $forum_id), 'S_CAN_RESTORE' => $auth->acl_get('m_approve', $forum_id), 'S_CAN_MERGE' => $auth->acl_get('m_merge', $forum_id), 'S_CAN_MOVE' => $auth->acl_get('m_move', $forum_id), 'S_CAN_FORK' => $auth->acl_get('m_', $forum_id), 'S_CAN_LOCK' => $auth->acl_get('m_lock', $forum_id), 'S_CAN_SYNC' => $auth->acl_get('m_', $forum_id), 'S_CAN_APPROVE' => $auth->acl_get('m_approve', $forum_id), 'S_MERGE_SELECT' => $merge_select ? true : false, 'S_CAN_MAKE_NORMAL' => $auth->acl_gets('f_sticky', 'f_announce', 'f_announce_global', $forum_id), 'S_CAN_MAKE_STICKY' => $auth->acl_get('f_sticky', $forum_id), 'S_CAN_MAKE_ANNOUNCE' => $auth->acl_get('f_announce', $forum_id), 'S_CAN_MAKE_ANNOUNCE_GLOBAL' => $auth->acl_get('f_announce_global', $forum_id), 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $forum_id), 'U_VIEW_FORUM_LOGS' => $auth->acl_gets('a_', 'm_', $forum_id) && $module->loaded('logs') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=logs&mode=forum_logs&f=' . $forum_id) : '', 'S_MCP_ACTION' => $url . "&i={$id}&forum_action={$action}&mode={$mode}&start={$start}" . ($merge_select ? $selected_ids : ''), 'TOTAL_TOPICS' => $user->lang('VIEW_FORUM_TOPICS', (int) $forum_topics))); // Grab icons $icons = $cache->obtain_icons(); $topic_rows = array(); if ($config['load_db_lastread']) { $read_tracking_join = ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id'] . ')'; $read_tracking_select = ', tt.mark_time'; } else { $read_tracking_join = $read_tracking_select = ''; } /* @var $phpbb_content_visibility \phpbb\content_visibility */ $phpbb_content_visibility = $phpbb_container->get('content.visibility'); $sql = 'SELECT t.topic_id FROM ' . TOPICS_TABLE . ' t WHERE t.forum_id = ' . $forum_id . ' AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.') . "\n\t\t\t{$limit_time_sql}\n\t\tORDER BY t.topic_type DESC, {$sort_order_sql}"; /** * Modify SQL query before MCP forum view topic list is queried * * @event core.mcp_view_forum_modify_sql * @var string sql SQL query for forum view topic list * @var int forum_id ID of the forum * @var string limit_time_sql SQL query part for limit time * @var string sort_order_sql SQL query part for sort order * @var int topics_per_page Number of topics per page * @var int start Start value * @since 3.1.2-RC1 */ $vars = array('sql', 'forum_id', 'limit_time_sql', 'sort_order_sql', 'topics_per_page', 'start'); extract($phpbb_dispatcher->trigger_event('core.mcp_view_forum_modify_sql', compact($vars))); $result = $db->sql_query_limit($sql, $topics_per_page, $start); $topic_list = $topic_tracking_info = array(); while ($row_ary = $db->sql_fetchrow($result)) { $topic_list[] = $row_ary['topic_id']; } $db->sql_freeresult($result); $sql = "SELECT t.*{$read_tracking_select}\n\t\tFROM " . TOPICS_TABLE . " t {$read_tracking_join}\n\t\tWHERE " . $db->sql_in_set('t.topic_id', $topic_list, false, true); $result = $db->sql_query($sql); while ($row_ary = $db->sql_fetchrow($result)) { $topic_rows[$row_ary['topic_id']] = $row_ary; } $db->sql_freeresult($result); // If there is more than one page, but we have no topic list, then the start parameter is... erm... out of sync if (!sizeof($topic_list) && $forum_topics && $start > 0) { redirect($url . "&i={$id}&action={$action}&mode={$mode}"); } // Get topic tracking info if (sizeof($topic_list)) { if ($config['load_db_lastread']) { $topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time'])); } else { $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list); } } foreach ($topic_list as $topic_id) { $row_ary =& $topic_rows[$topic_id]; $replies = $phpbb_content_visibility->get_count('topic_posts', $row_ary, $forum_id) - 1; if ($row_ary['topic_status'] == ITEM_MOVED) { $unread_topic = false; } else { $unread_topic = isset($topic_tracking_info[$topic_id]) && $row_ary['topic_last_post_time'] > $topic_tracking_info[$topic_id] ? true : false; } // Get folder img, topic status/type related information $folder_img = $folder_alt = $topic_type = ''; topic_status($row_ary, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type); $topic_title = censor_text($row_ary['topic_title']); $topic_unapproved = ($row_ary['topic_visibility'] == ITEM_UNAPPROVED || $row_ary['topic_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $row_ary['forum_id']) ? true : false; $posts_unapproved = $row_ary['topic_visibility'] == ITEM_APPROVED && $row_ary['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row_ary['forum_id']) ? true : false; $topic_deleted = $row_ary['topic_visibility'] == ITEM_DELETED; $u_mcp_queue = $topic_unapproved || $posts_unapproved ? $url . '&i=queue&mode=' . ($topic_unapproved ? 'approve_details' : 'unapproved_posts') . '&t=' . $row_ary['topic_id'] : ''; $u_mcp_queue = !$u_mcp_queue && $topic_deleted ? $url . '&i=queue&mode=deleted_topics&t=' . $topic_id : $u_mcp_queue; $topic_row = array('ATTACH_ICON_IMG' => $auth->acl_get('u_download') && $auth->acl_get('f_download', $row_ary['forum_id']) && $row_ary['topic_attachment'] ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 'TOPIC_IMG_STYLE' => $folder_img, 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 'TOPIC_ICON_IMG' => !empty($icons[$row_ary['icon_id']]) ? $icons[$row_ary['icon_id']]['img'] : '', 'TOPIC_ICON_IMG_WIDTH' => !empty($icons[$row_ary['icon_id']]) ? $icons[$row_ary['icon_id']]['width'] : '', 'TOPIC_ICON_IMG_HEIGHT' => !empty($icons[$row_ary['icon_id']]) ? $icons[$row_ary['icon_id']]['height'] : '', 'UNAPPROVED_IMG' => $topic_unapproved || $posts_unapproved ? $user->img('icon_topic_unapproved', $topic_unapproved ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', 'DELETED_IMG' => $topic_deleted ? $user->img('icon_topic_deleted', 'POSTS_DELETED') : '', 'TOPIC_AUTHOR' => get_username_string('username', $row_ary['topic_poster'], $row_ary['topic_first_poster_name'], $row_ary['topic_first_poster_colour']), 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row_ary['topic_poster'], $row_ary['topic_first_poster_name'], $row_ary['topic_first_poster_colour']), 'TOPIC_AUTHOR_FULL' => get_username_string('full', $row_ary['topic_poster'], $row_ary['topic_first_poster_name'], $row_ary['topic_first_poster_colour']), 'U_TOPIC_AUTHOR' => get_username_string('profile', $row_ary['topic_poster'], $row_ary['topic_first_poster_name'], $row_ary['topic_first_poster_colour']), 'LAST_POST_AUTHOR' => get_username_string('username', $row_ary['topic_last_poster_id'], $row_ary['topic_last_poster_name'], $row_ary['topic_last_poster_colour']), 'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row_ary['topic_last_poster_id'], $row_ary['topic_last_poster_name'], $row_ary['topic_last_poster_colour']), 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row_ary['topic_last_poster_id'], $row_ary['topic_last_poster_name'], $row_ary['topic_last_poster_colour']), 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row_ary['topic_last_poster_id'], $row_ary['topic_last_poster_name'], $row_ary['topic_last_poster_colour']), 'TOPIC_TYPE' => $topic_type, 'TOPIC_TITLE' => $topic_title, 'REPLIES' => $phpbb_content_visibility->get_count('topic_posts', $row_ary, $row_ary['forum_id']) - 1, 'LAST_POST_TIME' => $user->format_date($row_ary['topic_last_post_time']), 'FIRST_POST_TIME' => $user->format_date($row_ary['topic_time']), 'LAST_POST_SUBJECT' => $row_ary['topic_last_post_subject'], 'LAST_VIEW_TIME' => $user->format_date($row_ary['topic_last_view_time']), 'S_TOPIC_REPORTED' => !empty($row_ary['topic_reported']) && empty($row_ary['topic_moved_id']) && $auth->acl_get('m_report', $row_ary['forum_id']) ? true : false, 'S_TOPIC_UNAPPROVED' => $topic_unapproved, 'S_POSTS_UNAPPROVED' => $posts_unapproved, 'S_TOPIC_DELETED' => $topic_deleted, 'S_UNREAD_TOPIC' => $unread_topic); if ($row_ary['topic_status'] == ITEM_MOVED) { $topic_row = array_merge($topic_row, array('U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "t={$row_ary['topic_moved_id']}"), 'U_DELETE_TOPIC' => $auth->acl_get('m_delete', $forum_id) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&f={$forum_id}&topic_id_list[]={$row_ary['topic_id']}&mode=forum_view&action=delete_topic") : '', 'S_MOVED_TOPIC' => true, 'TOPIC_ID' => $row_ary['topic_moved_id'])); } else { if ($action == 'merge_topic' || $action == 'merge_topics') { $u_select_topic = $url . "&i={$id}&mode=forum_view&action={$action}&to_topic_id=" . $row_ary['topic_id'] . $selected_ids; } else { $u_select_topic = $url . "&i={$id}&mode=topic_view&action=merge&to_topic_id=" . $row_ary['topic_id'] . $selected_ids; } $topic_row = array_merge($topic_row, array('U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&f={$forum_id}&t={$row_ary['topic_id']}&mode=topic_view"), 'S_SELECT_TOPIC' => $merge_select && !in_array($row_ary['topic_id'], $source_topic_ids) ? true : false, 'U_SELECT_TOPIC' => $u_select_topic, 'U_MCP_QUEUE' => $u_mcp_queue, 'U_MCP_REPORT' => $auth->acl_get('m_report', $forum_id) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=main&mode=topic_view&t=' . $row_ary['topic_id'] . '&action=reports') : '', 'TOPIC_ID' => $row_ary['topic_id'], 'S_TOPIC_CHECKED' => $topic_id_list && in_array($row_ary['topic_id'], $topic_id_list) ? true : false)); } $row = $row_ary; /** * Modify the topic data before it is assigned to the template in MCP * * @event core.mcp_view_forum_modify_topicrow * @var array row Array with topic data * @var array topic_row Template array with topic data * @since 3.1.0-a1 */ $vars = array('row', 'topic_row'); extract($phpbb_dispatcher->trigger_event('core.mcp_view_forum_modify_topicrow', compact($vars))); $row_ary = $row; unset($row); $template->assign_block_vars('topicrow', $topic_row); } unset($topic_rows); }
/** * MCP Forum View */ function mcp_forum_view($id, $mode, $action, $forum_info) { global $template, $db, $user, $auth, $cache, $module; global $phpEx, $phpbb_root_path, $config; $user->add_lang(array('viewtopic', 'viewforum')); include_once $phpbb_root_path . 'includes/functions_display.' . $phpEx; // merge_topic is the quickmod action, merge_topics is the mcp_forum action, and merge_select is the mcp_topic action $merge_select = $action == 'merge_select' || $action == 'merge_topic' || $action == 'merge_topics' ? true : false; if ($merge_select) { // Fixes a "bug" that makes forum_view use the same ordering as topic_view unset($_POST['sk'], $_POST['sd'], $_REQUEST['sk'], $_REQUEST['sd']); } $forum_id = $forum_info['forum_id']; $start = request_var('start', 0); $topic_id_list = request_var('topic_id_list', array(0)); $post_id_list = request_var('post_id_list', array(0)); $source_topic_ids = array(request_var('t', 0)); $to_topic_id = request_var('to_topic_id', 0); $url_extra = ''; $url_extra .= $forum_id ? "&f={$forum_id}" : ''; $url_extra .= $GLOBALS['topic_id'] ? '&t=' . $GLOBALS['topic_id'] : ''; $url_extra .= $GLOBALS['post_id'] ? '&p=' . $GLOBALS['post_id'] : ''; $url_extra .= $GLOBALS['user_id'] ? '&u=' . $GLOBALS['user_id'] : ''; $url = append_sid("{$phpbb_root_path}mcp.{$phpEx}?{$url_extra}"); // Resync Topics switch ($action) { case 'resync': $topic_ids = request_var('topic_id_list', array(0)); mcp_resync_topics($topic_ids); break; case 'merge_topics': $source_topic_ids = $topic_id_list; case 'merge_topic': if ($to_topic_id) { merge_topics($forum_id, $source_topic_ids, $to_topic_id); } break; } $selected_ids = ''; if (sizeof($post_id_list) && $action != 'merge_topics') { foreach ($post_id_list as $num => $post_id) { $selected_ids .= '&post_id_list[' . $num . ']=' . $post_id; } } else { if (sizeof($topic_id_list) && $action == 'merge_topics') { foreach ($topic_id_list as $num => $topic_id) { $selected_ids .= '&topic_id_list[' . $num . ']=' . $topic_id; } } } make_jumpbox($url . "&i={$id}&action={$action}&mode={$mode}" . ($merge_select ? $selected_ids : ''), $forum_id, false, 'm_', true); $topics_per_page = $forum_info['forum_topics_per_page'] ? $forum_info['forum_topics_per_page'] : $config['topics_per_page']; $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); mcp_sorting('viewforum', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id); $forum_topics = $total == -1 ? $forum_info['forum_topics'] : $total; $limit_time_sql = $sort_days ? 'AND t.topic_last_post_time >= ' . (time() - $sort_days * 86400) : ''; $template->assign_vars(array('ACTION' => $action, 'FORUM_NAME' => $forum_info['forum_name'], 'FORUM_DESCRIPTION' => generate_text_for_display($forum_info['forum_desc'], $forum_info['forum_desc_uid'], $forum_info['forum_desc_bitfield'], $forum_info['forum_desc_options']), 'REPORTED_IMG' => $user->img('icon_topic_reported', 'TOPIC_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'), 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), 'S_CAN_REPORT' => $auth->acl_get('m_report', $forum_id), 'S_CAN_DELETE' => $auth->acl_get('m_delete', $forum_id), 'S_CAN_MERGE' => $auth->acl_get('m_merge', $forum_id), 'S_CAN_MOVE' => $auth->acl_get('m_move', $forum_id), 'S_CAN_FORK' => $auth->acl_get('m_', $forum_id), 'S_CAN_LOCK' => $auth->acl_get('m_lock', $forum_id), 'S_CAN_SYNC' => $auth->acl_get('m_', $forum_id), 'S_CAN_APPROVE' => $auth->acl_get('m_approve', $forum_id), 'S_MERGE_SELECT' => $merge_select ? true : false, 'S_CAN_MAKE_NORMAL' => $auth->acl_gets('f_sticky', 'f_announce', $forum_id), 'S_CAN_MAKE_STICKY' => $auth->acl_get('f_sticky', $forum_id), 'S_CAN_MAKE_ANNOUNCE' => $auth->acl_get('f_announce', $forum_id), 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $forum_id), 'U_VIEW_FORUM_LOGS' => $auth->acl_gets('a_', 'm_', $forum_id) && $module->loaded('logs') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=logs&mode=forum_logs&f=' . $forum_id) : '', 'S_MCP_ACTION' => $url . "&i={$id}&forum_action={$action}&mode={$mode}&start={$start}" . ($merge_select ? $selected_ids : ''), 'PAGINATION' => generate_pagination($url . "&i={$id}&action={$action}&mode={$mode}&sd={$sort_dir}&sk={$sort_key}&st={$sort_days}" . ($merge_select ? $selected_ids : ''), $forum_topics, $topics_per_page, $start), 'PAGE_NUMBER' => on_page($forum_topics, $topics_per_page, $start), 'TOTAL_TOPICS' => $forum_topics == 1 ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $forum_topics))); // Grab icons $icons = $cache->obtain_icons(); $topic_rows = array(); if ($config['load_db_lastread']) { $read_tracking_join = ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id'] . ')'; $read_tracking_select = ', tt.mark_time'; } else { $read_tracking_join = $read_tracking_select = ''; } $sql = "SELECT t.topic_id\n\t\tFROM " . TOPICS_TABLE . " t\n\t\tWHERE t.forum_id IN({$forum_id}, 0)\n\t\t\t" . ($auth->acl_get('m_approve', $forum_id) ? '' : 'AND t.topic_approved = 1') . "\n\t\t\t{$limit_time_sql}\n\t\tORDER BY t.topic_type DESC, {$sort_order_sql}"; $result = $db->sql_query_limit($sql, $topics_per_page, $start); $topic_list = $topic_tracking_info = array(); while ($row = $db->sql_fetchrow($result)) { $topic_list[] = $row['topic_id']; } $db->sql_freeresult($result); $sql = "SELECT t.*{$read_tracking_select}\n\t\tFROM " . TOPICS_TABLE . " t {$read_tracking_join}\n\t\tWHERE " . $db->sql_in_set('t.topic_id', $topic_list, false, true); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $topic_rows[$row['topic_id']] = $row; } $db->sql_freeresult($result); // If there is more than one page, but we have no topic list, then the start parameter is... erm... out of sync if (!sizeof($topic_list) && $forum_topics && $start > 0) { redirect($url . "&i={$id}&action={$action}&mode={$mode}"); } // Get topic tracking info if (sizeof($topic_list)) { if ($config['load_db_lastread']) { $topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time']), array()); } else { $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list, array()); } } foreach ($topic_list as $topic_id) { $topic_title = ''; $row =& $topic_rows[$topic_id]; $replies = $auth->acl_get('m_approve', $forum_id) ? $row['topic_replies_real'] : $row['topic_replies']; if ($row['topic_status'] == ITEM_MOVED) { $unread_topic = false; } else { $unread_topic = isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id] ? true : false; } // Get folder img, topic status/type related information $folder_img = $folder_alt = $topic_type = ''; topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type); $topic_title = censor_text($row['topic_title']); $topic_unapproved = !$row['topic_approved'] && $auth->acl_get('m_approve', $row['forum_id']) ? true : false; $posts_unapproved = $row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $row['forum_id']) ? true : false; $u_mcp_queue = $topic_unapproved || $posts_unapproved ? $url . '&i=queue&mode=' . ($topic_unapproved ? 'approve_details' : 'unapproved_posts') . '&t=' . $row['topic_id'] : ''; $topic_row = array('SOLVED_TOPIC' => $row['topic_solved'] && $row['topic_type'] != POST_GLOBAL ? $forum_info['forum_solve_text'] ? $forum_info['forum_solve_text'] : $user->img('icon_topic_solved_list', 'TOPIC_SOLVED') : '', 'U_SOLVED_TOPIC' => $row['topic_solved'] ? append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'p=' . $row['topic_solved'] . '#p' . $row['topic_solved']) : '', 'SOLVED_STYLE' => $forum_info['forum_solve_color'] ? ' style="color: #' . $forum_info['forum_solve_color'] . '"' : '', 'ATTACH_ICON_IMG' => $auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['topic_attachment'] ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'), 'TOPIC_ICON_IMG' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['img'] : '', 'TOPIC_ICON_IMG_WIDTH' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['width'] : '', 'TOPIC_ICON_IMG_HEIGHT' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['height'] : '', 'UNAPPROVED_IMG' => $topic_unapproved || $posts_unapproved ? $user->img('icon_topic_unapproved', $topic_unapproved ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', 'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'TOPIC_TYPE' => $topic_type, 'TOPIC_TITLE' => $topic_title, 'REPLIES' => $auth->acl_get('m_approve', $row['forum_id']) ? $row['topic_replies_real'] : $row['topic_replies'], 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), 'FIRST_POST_TIME' => $user->format_date($row['topic_time']), 'LAST_POST_SUBJECT' => $row['topic_last_post_subject'], 'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']), 'S_TOPIC_REPORTED' => !empty($row['topic_reported']) && empty($row['topic_moved_id']) && $auth->acl_get('m_report', $row['forum_id']) ? true : false, 'S_TOPIC_UNAPPROVED' => $topic_unapproved, 'S_POSTS_UNAPPROVED' => $posts_unapproved, 'S_UNREAD_TOPIC' => $unread_topic); if ($row['topic_status'] == ITEM_MOVED) { $topic_row = array_merge($topic_row, array('U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "t={$row['topic_moved_id']}"), 'U_DELETE_TOPIC' => $auth->acl_get('m_delete', $forum_id) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&f={$forum_id}&topic_id_list[]={$row['topic_id']}&mode=forum_view&action=delete_topic") : '', 'S_MOVED_TOPIC' => true, 'TOPIC_ID' => $row['topic_moved_id'])); } else { if ($action == 'merge_topic' || $action == 'merge_topics') { $u_select_topic = $url . "&i={$id}&mode=forum_view&action={$action}&to_topic_id=" . $row['topic_id'] . $selected_ids; } else { $u_select_topic = $url . "&i={$id}&mode=topic_view&action=merge&to_topic_id=" . $row['topic_id'] . $selected_ids; } $topic_row = array_merge($topic_row, array('U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&f={$forum_id}&t={$row['topic_id']}&mode=topic_view"), 'S_SELECT_TOPIC' => $merge_select && !in_array($row['topic_id'], $source_topic_ids) ? true : false, 'U_SELECT_TOPIC' => $u_select_topic, 'U_MCP_QUEUE' => $u_mcp_queue, 'U_MCP_REPORT' => $auth->acl_get('m_report', $forum_id) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=main&mode=topic_view&t=' . $row['topic_id'] . '&action=reports') : '', 'TOPIC_ID' => $row['topic_id'], 'S_TOPIC_CHECKED' => $topic_id_list && in_array($row['topic_id'], $topic_id_list) ? true : false)); } $template->assign_block_vars('topicrow', $topic_row); } unset($topic_rows); }
$rowset[$orig_topic_id] = $row; } $db->sql_freeresult($result); } unset($shadow_topic_list); foreach ($forums as $forum_id => $forum) { if ($user->data['is_registered'] && $config['load_db_lastread']) { $topic_tracking_info[$forum_id] = get_topic_tracking($forum_id, $forum['topic_list'], $forum['rowset'], array($forum_id => $forum['mark_time']), ($forum_id) ? false : $forum['topic_list']); } else if ($config['load_anon_lastread'] || $user->data['is_registered']) { $topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $forum['topic_list'], ($forum_id) ? false : $forum['topic_list']); if (!$user->data['is_registered']) { $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0; } } } unset($forums); } else { $bbcode_bitfield = $text_only_message = ''; $attach_list = array(); while ($row = $db->sql_fetchrow($result))
/** * View topic in MCP */ function mcp_topic_view($id, $mode, $action) { global $phpEx, $src_root_path, $config; global $template, $db, $user, $auth, $cache, $src_container, $src_dispatcher; $url = append_sid("{$src_root_path}mcp.{$phpEx}?" . src_extra_url()); $user->add_lang('viewtopic'); $pagination = $src_container->get('pagination'); $topic_id = request_var('t', 0); $topic_info = src_get_topic_data(array($topic_id), false, true); if (!sizeof($topic_info)) { trigger_error('TOPIC_NOT_EXIST'); } $topic_info = $topic_info[$topic_id]; // Set up some vars $icon_id = request_var('icon', 0); $subject = utf8_normalize_nfc(request_var('subject', '', true)); $start = request_var('start', 0); $sort_days_old = request_var('st_old', 0); $forum_id = request_var('f', 0); $to_topic_id = request_var('to_topic_id', 0); $to_forum_id = request_var('to_forum_id', 0); $sort = isset($_POST['sort']) ? true : false; $submitted_id_list = request_var('post_ids', array(0)); $checked_ids = $post_id_list = request_var('post_id_list', array(0)); // Resync Topic? if ($action == 'resync') { if (!function_exists('mcp_resync_topics')) { include $src_root_path . 'includes/mcp/mcp_forum.' . $phpEx; } mcp_resync_topics(array($topic_id)); } // Split Topic? if ($action == 'split_all' || $action == 'split_beyond') { if (!$sort) { split_topic($action, $topic_id, $to_forum_id, $subject); } $action = 'split'; } // Merge Posts? if ($action == 'merge_posts') { if (!$sort) { merge_posts($topic_id, $to_topic_id); } $action = 'merge'; } if ($action == 'split' && !$subject) { $subject = $topic_info['topic_title']; } // Restore or pprove posts? if (($action == 'restore' || $action == 'approve') && $auth->acl_get('m_approve', $topic_info['forum_id'])) { include $src_root_path . 'includes/mcp/mcp_queue.' . $phpEx; include_once $src_root_path . 'includes/functions_posting.' . $phpEx; include_once $src_root_path . 'includes/functions_messenger.' . $phpEx; if (!sizeof($post_id_list)) { trigger_error('NO_POST_SELECTED'); } if (!$sort) { mcp_queue::approve_posts($action, $post_id_list, $id, $mode); } } // Jumpbox, sort selects and that kind of things make_jumpbox($url . "&i={$id}&mode=forum_view", $topic_info['forum_id'], false, 'm_', true); $where_sql = $action == 'reports' ? 'WHERE post_reported = 1 AND ' : 'WHERE'; $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); src_mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $topic_info['forum_id'], $topic_id, $where_sql); $limit_time_sql = $sort_days ? 'AND p.post_time >= ' . (time() - $sort_days * 86400) : ''; $src_content_visibility = $src_container->get('content.visibility'); if ($total == -1) { $total = $src_content_visibility->get_count('topic_posts', $topic_info, $topic_info['forum_id']); } $posts_per_page = max(0, request_var('posts_per_page', intval($config['posts_per_page']))); if ($posts_per_page == 0) { $posts_per_page = $total; } if (!empty($sort_days_old) && $sort_days_old != $sort_days || $total <= $posts_per_page) { $start = 0; } $start = $pagination->validate_start($start, $posts_per_page, $total); $sql = 'SELECT u.username, u.username_clean, u.user_colour, p.* FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE ' . ($action == 'reports' ? 'p.post_reported = 1 AND ' : '') . ' p.topic_id = ' . $topic_id . ' AND ' . $src_content_visibility->get_visibility_sql('post', $topic_info['forum_id'], 'p.') . ' AND p.poster_id = u.user_id ' . $limit_time_sql . ' ORDER BY ' . $sort_order_sql; $result = $db->sql_query_limit($sql, $posts_per_page, $start); $rowset = $post_id_list = array(); while ($row = $db->sql_fetchrow($result)) { $rowset[] = $row; $post_id_list[] = $row['post_id']; } $db->sql_freeresult($result); $topic_tracking_info = array(); // Get topic tracking info if ($config['load_db_lastread']) { $tmp_topic_data = array($topic_id => $topic_info); $topic_tracking_info = get_topic_tracking($topic_info['forum_id'], $topic_id, $tmp_topic_data, array($topic_info['forum_id'] => $topic_info['forum_mark_time'])); unset($tmp_topic_data); } else { $topic_tracking_info = get_complete_topic_tracking($topic_info['forum_id'], $topic_id); } $has_unapproved_posts = $has_deleted_posts = false; // Grab extensions $extensions = $attachments = array(); if ($topic_info['topic_attachment'] && sizeof($post_id_list)) { $extensions = $cache->obtain_attach_extensions($topic_info['forum_id']); // Get attachments... if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_info['forum_id'])) { $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE ' . $db->sql_in_set('post_msg_id', $post_id_list) . ' AND in_message = 0 ORDER BY filetime DESC, post_msg_id ASC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $attachments[$row['post_msg_id']][] = $row; } $db->sql_freeresult($result); } } foreach ($rowset as $i => $row) { $message = $row['post_text']; $post_subject = $row['post_subject'] != '' ? $row['post_subject'] : $topic_info['topic_title']; $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, false); if (!empty($attachments[$row['post_id']])) { $update_count = array(); parse_attachments($topic_info['forum_id'], $message, $attachments[$row['post_id']], $update_count); } if ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) { $has_unapproved_posts = true; } if ($row['post_visibility'] == ITEM_DELETED) { $has_deleted_posts = true; } $post_unread = isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id] ? true : false; $post_row = array('POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_DATE' => $user->format_date($row['post_time']), 'POST_SUBJECT' => $post_subject, 'MESSAGE' => $message, 'POST_ID' => $row['post_id'], 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$src_root_path}viewtopic.{$phpEx}", 't=' . $topic_id) . '">', '</a>'), 'MINI_POST_IMG' => $post_unread ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'S_POST_REPORTED' => $row['post_reported'] && $auth->acl_get('m_report', $topic_info['forum_id']), 'S_POST_UNAPPROVED' => ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE) && $auth->acl_get('m_approve', $topic_info['forum_id']), 'S_POST_DELETED' => $row['post_visibility'] == ITEM_DELETED && $auth->acl_get('m_approve', $topic_info['forum_id']), 'S_CHECKED' => $submitted_id_list && !in_array(intval($row['post_id']), $submitted_id_list) || in_array(intval($row['post_id']), $checked_ids) ? true : false, 'S_HAS_ATTACHMENTS' => !empty($attachments[$row['post_id']]) ? true : false, 'U_POST_DETAILS' => "{$url}&i={$id}&p={$row['post_id']}&mode=post_details" . ($forum_id ? "&f={$forum_id}" : ''), 'U_MCP_APPROVE' => $auth->acl_get('m_approve', $topic_info['forum_id']) ? append_sid("{$src_root_path}mcp.{$phpEx}", 'i=queue&mode=approve_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : '', 'U_MCP_REPORT' => $auth->acl_get('m_report', $topic_info['forum_id']) ? append_sid("{$src_root_path}mcp.{$phpEx}", 'i=reports&mode=report_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : ''); $current_row_number = $i; /** * Event to modify the template data block for topic reviews in the MCP * * @event core.mcp_topic_review_modify_row * @var int id ID of the tab we are displaying * @var string mode Mode of the MCP page we are displaying * @var int topic_id The topic ID we are currently reviewing * @var int forum_id The forum ID we are currently in * @var int start Start item of this page * @var int current_row_number Number of the post on this page * @var array post_row Template block array of the current post * @var array row Array with original post and user data * @var array topic_info Array with topic data * @var int total Total posts count * @since 3.1.4-RC1 */ $vars = array('id', 'mode', 'topic_id', 'forum_id', 'start', 'current_row_number', 'post_row', 'row', 'topic_info', 'total'); extract($src_dispatcher->trigger_event('core.mcp_topic_review_modify_row', compact($vars))); $template->assign_block_vars('postrow', $post_row); // Display not already displayed Attachments for this post, we already parsed them. ;) if (!empty($attachments[$row['post_id']])) { foreach ($attachments[$row['post_id']] as $attachment) { $template->assign_block_vars('postrow.attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } } unset($rowset[$i]); } // Display topic icons for split topic $s_topic_icons = false; if ($auth->acl_gets('m_split', 'm_merge', (int) $topic_info['forum_id'])) { include_once $src_root_path . 'includes/functions_posting.' . $phpEx; $s_topic_icons = posting_gen_topic_icons('', $icon_id); // Has the user selected a topic for merge? if ($to_topic_id) { $to_topic_info = src_get_topic_data(array($to_topic_id), 'm_merge'); if (!sizeof($to_topic_info)) { $to_topic_id = 0; } else { $to_topic_info = $to_topic_info[$to_topic_id]; if (!$to_topic_info['enable_icons'] || $auth->acl_get('!f_icons', $topic_info['forum_id'])) { $s_topic_icons = false; } } } } $s_hidden_fields = build_hidden_fields(array('st_old' => $sort_days, 'post_ids' => $post_id_list)); $base_url = append_sid("{$src_root_path}mcp.{$phpEx}", "i={$id}&t={$topic_info['topic_id']}&mode={$mode}&action={$action}&to_topic_id={$to_topic_id}&posts_per_page={$posts_per_page}&st={$sort_days}&sk={$sort_key}&sd={$sort_dir}"); if ($posts_per_page) { $pagination->generate_template_pagination($base_url, 'pagination', 'start', $total, $posts_per_page, $start); } $template->assign_vars(array('TOPIC_TITLE' => $topic_info['topic_title'], 'U_VIEW_TOPIC' => append_sid("{$src_root_path}viewtopic.{$phpEx}", 'f=' . $topic_info['forum_id'] . '&t=' . $topic_info['topic_id']), 'TO_TOPIC_ID' => $to_topic_id, 'TO_TOPIC_INFO' => $to_topic_id ? sprintf($user->lang['YOU_SELECTED_TOPIC'], $to_topic_id, '<a href="' . append_sid("{$src_root_path}viewtopic.{$phpEx}", 'f=' . $to_topic_info['forum_id'] . '&t=' . $to_topic_id) . '">' . $to_topic_info['topic_title'] . '</a>') : '', 'SPLIT_SUBJECT' => $subject, 'POSTS_PER_PAGE' => $posts_per_page, 'ACTION' => $action, 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), 'DELETED_IMG' => $user->img('icon_topic_deleted', 'POST_DELETED_RESTORE'), 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'), 'S_MCP_ACTION' => "{$url}&i={$id}&mode={$mode}&action={$action}&start={$start}", 'S_FORUM_SELECT' => $to_forum_id ? make_forum_select($to_forum_id, false, false, true, true, true) : make_forum_select($topic_info['forum_id'], false, false, true, true, true), 'S_CAN_SPLIT' => $auth->acl_get('m_split', $topic_info['forum_id']) ? true : false, 'S_CAN_MERGE' => $auth->acl_get('m_merge', $topic_info['forum_id']) ? true : false, 'S_CAN_DELETE' => $auth->acl_get('m_delete', $topic_info['forum_id']) ? true : false, 'S_CAN_APPROVE' => $has_unapproved_posts && $auth->acl_get('m_approve', $topic_info['forum_id']) ? true : false, 'S_CAN_RESTORE' => $has_deleted_posts && $auth->acl_get('m_approve', $topic_info['forum_id']) ? true : false, 'S_CAN_LOCK' => $auth->acl_get('m_lock', $topic_info['forum_id']) ? true : false, 'S_CAN_REPORT' => $auth->acl_get('m_report', $topic_info['forum_id']) ? true : false, 'S_CAN_SYNC' => $auth->acl_get('m_', $topic_info['forum_id']), 'S_REPORT_VIEW' => $action == 'reports' ? true : false, 'S_MERGE_VIEW' => $action == 'merge' ? true : false, 'S_SPLIT_VIEW' => $action == 'split' ? true : false, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, 'S_TOPIC_ICON' => $icon_id, 'U_SELECT_TOPIC' => "{$url}&i={$id}&mode=forum_view&action=merge_select" . ($forum_id ? "&f={$forum_id}" : ''), 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$src_root_path}viewtopic.{$phpEx}", "f={$topic_info['forum_id']}&t={$topic_info['topic_id']}&start={$start}") . '">', '</a>'), 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$src_root_path}viewforum.{$phpEx}", "f={$topic_info['forum_id']}&start={$start}") . '">', '</a>'), 'TOTAL_POSTS' => $user->lang('VIEW_TOPIC_POSTS', (int) $total))); }
} } else { if ($config['load_anon_lastread'] || $user->data['is_registered']) { foreach ($topic_forum_list as $f_id => $topic_row) { $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics'], false); } } } unset($topic_forum_list); } else { if ($config['load_db_lastread'] && $user->data['is_registered']) { $topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $rowset, array($forum_id => $forum_data['mark_time']), $global_announce_list); $mark_time_forum = !empty($forum_data['mark_time']) ? $forum_data['mark_time'] : $user->data['user_lastmark']; } else { if ($config['load_anon_lastread'] || $user->data['is_registered']) { $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list, $global_announce_list); if (!$user->data['is_registered']) { $user->data['user_lastmark'] = isset($tracking_topics['l']) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0; } $mark_time_forum = isset($tracking_topics['f'][$forum_id]) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark']; } } } $s_type_switch = 0; foreach ($topic_list as $topic_id) { $row =& $rowset[$topic_id]; // This will allow the style designer to output a different header // or even separate the list of announcements from sticky and normal topics $s_type_switch_test = $row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL ? 1 : 0; // Replies $replies = $auth->acl_get('m_approve', $forum_id) ? $row['topic_replies_real'] : $row['topic_replies'];
/** * Get similar topics by matching topic titles * * NOTE: Currently requires MySQL due to the use of FULLTEXT indexes * and MATCH and AGAINST and UNIX_TIMESTAMP. MySQL FULLTEXT has built-in * English ignore words. We use phpBB's ignore words for non-English * languages. We also remove any admin-defined special ignore words. * * @param array $topic_data Array with topic data * @return null * @access public */ public function display_similar_topics($topic_data) { $topic_title = $this->clean_topic_title($topic_data['topic_title']); // If the cleaned up topic_title is empty, no need to continue if (empty($topic_title)) { return; } // Similar Topics query $sql_array = array('SELECT' => "f.forum_id, f.forum_name, t.*,\n\t\t\t\tMATCH (t.topic_title) AGAINST ('" . $this->db->sql_escape($topic_title) . "') AS score", 'FROM' => array(TOPICS_TABLE => 't'), 'LEFT_JOIN' => array(array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = t.forum_id')), 'WHERE' => "MATCH (t.topic_title) AGAINST ('" . $this->db->sql_escape($topic_title) . "') >= 0.5\n\t\t\t\tAND t.topic_status <> " . ITEM_MOVED . ' AND t.topic_visibility = ' . ITEM_APPROVED . ' AND t.topic_time > (UNIX_TIMESTAMP() - ' . $this->config['similar_topics_time'] . ') AND t.topic_id <> ' . (int) $topic_data['topic_id']); // Add topic tracking data to the query (only if query caching is off) if ($this->user->data['is_registered'] && $this->config['load_db_lastread'] && !$this->config['similar_topics_cache']) { $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TRACK_TABLE => 'tt'), 'ON' => 'tt.topic_id = t.topic_id AND tt.user_id = ' . $this->user->data['user_id']); $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.forum_id = f.forum_id AND ft.user_id = ' . $this->user->data['user_id']); $sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as f_mark_time'; } else { if ($this->config['load_anon_lastread'] || $this->user->data['is_registered']) { // Cookie based tracking copied from search.php $tracking_topics = $this->request->variable($this->config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE); $tracking_topics = $tracking_topics ? tracking_unserialize($tracking_topics) : array(); } } // We need to exclude passworded forums so we do not leak the topic title $passworded_forums = $this->user->get_passworded_forums(); // See if the admin set this forum to only search a specific group of other forums, and include them if (!empty($topic_data['similar_topic_forums'])) { // Remove any passworded forums from this group of forums we will be searching $included_forums = array_diff(explode(',', $topic_data['similar_topic_forums']), $passworded_forums); // if there's nothing left to display (user has no access to the forums we want to search) if (empty($included_forums)) { return; } $sql_array['WHERE'] .= ' AND ' . $this->db->sql_in_set('f.forum_id', $included_forums); } else { if (!empty($this->config['similar_topics_ignore'])) { // Add passworded forums to the exlude array $excluded_forums = array_unique(array_merge(explode(',', $this->config['similar_topics_ignore']), $passworded_forums)); $sql_array['WHERE'] .= ' AND ' . $this->db->sql_in_set('f.forum_id', $excluded_forums, true); } else { if (!empty($passworded_forums)) { $sql_array['WHERE'] .= ' AND ' . $this->db->sql_in_set('f.forum_id', $passworded_forums, true); } } } /** * Event to modify the sql_array for similar topics * * @event vse.similartopics.get_topic_data * @var array sql_array SQL array to get similar topics data * @since 1.3.0 */ $vars = array('sql_array'); extract($this->dispatcher->trigger_event('vse.similartopics.get_topic_data', compact($vars))); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query_limit($sql, $this->config['similar_topics_limit'], 0, $this->config['similar_topics_cache']); // Grab icons $icons = $this->cache->obtain_icons(); $rowset = array(); while ($row = $this->db->sql_fetchrow($result)) { $similar_forum_id = (int) $row['forum_id']; $similar_topic_id = (int) $row['topic_id']; $rowset[$similar_topic_id] = $row; if ($this->auth->acl_get('f_read', $similar_forum_id)) { // Get topic tracking info if ($this->user->data['is_registered'] && $this->config['load_db_lastread'] && !$this->config['similar_topics_cache']) { $topic_tracking_info = get_topic_tracking($similar_forum_id, $similar_topic_id, $rowset, array($similar_forum_id => $row['f_mark_time'])); } else { if ($this->config['load_anon_lastread'] || $this->user->data['is_registered']) { $topic_tracking_info = get_complete_topic_tracking($similar_forum_id, $similar_topic_id); if (!$this->user->data['is_registered']) { $this->user->data['user_lastmark'] = isset($tracking_topics['l']) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $this->config['board_startdate']) : 0; } } } // Replies $replies = $this->content_visibility->get_count('topic_posts', $row, $similar_forum_id) - 1; // Get folder img, topic status/type related information $folder_img = $folder_alt = $topic_type = ''; $unread_topic = isset($topic_tracking_info[$similar_topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$similar_topic_id] ? true : false; topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type); $topic_unapproved = $row['topic_visibility'] == ITEM_UNAPPROVED && $this->auth->acl_get('m_approve', $similar_forum_id) ? true : false; $posts_unapproved = $row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $this->auth->acl_get('m_approve', $similar_forum_id) ? true : false; //$topic_deleted = $row['topic_visibility'] == ITEM_DELETED; $u_mcp_queue = $topic_unapproved || $posts_unapproved ? append_sid("{$this->root_path}mcp.{$this->php_ext}", 'i=queue&mode=' . ($topic_unapproved ? 'approve_details' : 'unapproved_posts') . "&t={$similar_topic_id}", true, $this->user->session_id) : ''; //$u_mcp_queue = (!$u_mcp_queue && $topic_deleted) ? append_sid("{$this->root_path}mcp.{$this->php_ext}", "i=queue&mode=deleted_topics&t=$similar_topic_id", true, $this->user->session_id) : $u_mcp_queue; $base_url = append_sid("{$this->root_path}viewtopic.{$this->php_ext}", 'f=' . $similar_forum_id . '&t=' . $similar_topic_id); $topic_row = array('TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'FIRST_POST_TIME' => $this->user->format_date($row['topic_time']), 'LAST_POST_TIME' => $this->user->format_date($row['topic_last_post_time']), 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'TOPIC_REPLIES' => $replies, 'TOPIC_VIEWS' => $row['topic_views'], 'TOPIC_TITLE' => $row['topic_title'], 'FORUM_TITLE' => $row['forum_name'], 'TOPIC_IMG_STYLE' => $folder_img, 'TOPIC_FOLDER_IMG' => $this->user->img($folder_img, $folder_alt), 'TOPIC_FOLDER_IMG_ALT' => $this->user->lang($folder_alt), 'TOPIC_ICON_IMG' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['img'] : '', 'TOPIC_ICON_IMG_WIDTH' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['width'] : '', 'TOPIC_ICON_IMG_HEIGHT' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['height'] : '', 'ATTACH_ICON_IMG' => $this->auth->acl_get('u_download') && $this->auth->acl_get('f_download', $similar_forum_id) && $row['topic_attachment'] ? $this->user->img('icon_topic_attach', $this->user->lang('TOTAL_ATTACHMENTS')) : '', 'UNAPPROVED_IMG' => $topic_unapproved || $posts_unapproved ? $this->user->img('icon_topic_unapproved', $topic_unapproved ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', 'S_UNREAD_TOPIC' => $unread_topic, 'S_TOPIC_REPORTED' => !empty($row['topic_reported']) && $this->auth->acl_get('m_report', $similar_forum_id) ? true : false, 'S_TOPIC_UNAPPROVED' => $topic_unapproved, 'S_POSTS_UNAPPROVED' => $posts_unapproved, 'S_HAS_POLL' => $row['poll_start'] ? true : false, 'U_NEWEST_POST' => append_sid("{$this->root_path}viewtopic.{$this->php_ext}", 'f=' . $similar_forum_id . '&t=' . $similar_topic_id . '&view=unread') . '#unread', 'U_LAST_POST' => append_sid("{$this->root_path}viewtopic.{$this->php_ext}", 'f=' . $similar_forum_id . '&t=' . $similar_topic_id . '&p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'], 'U_VIEW_TOPIC' => append_sid("{$this->root_path}viewtopic.{$this->php_ext}", 'f=' . $similar_forum_id . '&t=' . $similar_topic_id), 'U_VIEW_FORUM' => append_sid("{$this->root_path}viewforum.{$this->php_ext}", 'f=' . $similar_forum_id), 'U_MCP_REPORT' => append_sid("{$this->root_path}mcp.{$this->php_ext}", 'i=reports&mode=reports&f=' . $similar_forum_id . '&t=' . $similar_topic_id, true, $this->user->session_id), 'U_MCP_QUEUE' => $u_mcp_queue); /** * Event to modify the similar topics template block * * @event vse.similartopics.modify_topicrow * @var array row Array with similar topic data * @var array topic_row Template block array * @since 1.3.0 */ $vars = array('row', 'topic_row'); extract($this->dispatcher->trigger_event('vse.similartopics.modify_topicrow', compact($vars))); $this->template->assign_block_vars('similar', $topic_row); $this->pagination->generate_template_pagination($base_url, 'similar.pagination', 'start', $replies + 1, $this->config['posts_per_page'], 1, true, true); } } $this->db->sql_freeresult($result); $this->user->add_lang_ext('vse/similartopics', 'similar_topics'); $this->template->assign_vars(array('L_SIMILAR_TOPICS' => $this->user->lang('SIMILAR_TOPICS'), 'NEWEST_POST_IMG' => $this->user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), 'LAST_POST_IMG' => $this->user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'REPORTED_IMG' => $this->user->img('icon_topic_reported', 'TOPIC_REPORTED'), 'POLL_IMG' => $this->user->img('icon_topic_poll', 'TOPIC_POLL'))); }
$topic_forum_list = array(); foreach ($rowset as $t_id => $row) { if (isset($forum_tracking_info[$row['forum_id']])) { $row['forum_mark_time'] = $forum_tracking_info[$row['forum_id']]; } $topic_forum_list[$row['forum_id']]['forum_mark_time'] = $config['load_db_lastread'] && $user->data['is_registered'] && isset($row['forum_mark_time']) ? $row['forum_mark_time'] : 0; $topic_forum_list[$row['forum_id']]['topics'][] = (int) $t_id; } if ($config['load_db_lastread'] && $user->data['is_registered']) { foreach ($topic_forum_list as $f_id => $topic_row) { $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time'])); } } else { if ($config['load_anon_lastread'] || $user->data['is_registered']) { foreach ($topic_forum_list as $f_id => $topic_row) { $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics']); } } } unset($topic_forum_list); if (!$s_display_active) { if ($config['load_db_lastread'] && $user->data['is_registered']) { $mark_time_forum = !empty($forum_data['mark_time']) ? $forum_data['mark_time'] : $user->data['user_lastmark']; } else { if ($config['load_anon_lastread'] || $user->data['is_registered']) { if (!$user->data['is_registered']) { $user->data['user_lastmark'] = isset($tracking_topics['l']) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0; } $mark_time_forum = isset($tracking_topics['f'][$forum_id]) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark']; } }
public function main($id, $mode) { global $auth, $db, $user, $template, $cache, $request; global $config, $phpbb_root_path, $phpEx, $action, $phpbb_container; global $phpbb_dispatcher; include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx; $forum_id = $request->variable('f', 0); $start = $request->variable('start', 0); $this->page_title = 'MCP_QUEUE'; switch ($action) { case 'approve': case 'restore': include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx; $post_id_list = $request->variable('post_id_list', array(0)); $topic_id_list = $request->variable('topic_id_list', array(0)); if (!empty($post_id_list)) { self::approve_posts($action, $post_id_list, 'queue', $mode); } else { if (!empty($topic_id_list)) { self::approve_topics($action, $topic_id_list, 'queue', $mode); } else { trigger_error('NO_POST_SELECTED'); } } break; case 'delete': $post_id_list = $request->variable('post_id_list', array(0)); $topic_id_list = $request->variable('topic_id_list', array(0)); if (!empty($post_id_list)) { if (!function_exists('mcp_delete_post')) { global $phpbb_root_path, $phpEx; include $phpbb_root_path . 'includes/mcp/mcp_main.' . $phpEx; } mcp_delete_post($post_id_list, false, '', $action); } else { if (!empty($topic_id_list)) { if (!function_exists('mcp_delete_topic')) { global $phpbb_root_path, $phpEx; include $phpbb_root_path . 'includes/mcp/mcp_main.' . $phpEx; } mcp_delete_topic($topic_id_list, false, '', $action); } else { trigger_error('NO_POST_SELECTED'); } } break; case 'disapprove': $post_id_list = $request->variable('post_id_list', array(0)); $topic_id_list = $request->variable('topic_id_list', array(0)); if (!empty($topic_id_list) && $mode == 'deleted_topics') { if (!function_exists('mcp_delete_topics')) { global $phpbb_root_path, $phpEx; include $phpbb_root_path . 'includes/mcp/mcp_main.' . $phpEx; } mcp_delete_topic($topic_id_list, false, '', 'disapprove'); return; } if (!class_exists('messenger')) { include $phpbb_root_path . 'includes/functions_messenger.' . $phpEx; } if (!empty($topic_id_list)) { $post_visibility = $mode == 'deleted_topics' ? ITEM_DELETED : array(ITEM_UNAPPROVED, ITEM_REAPPROVE); $sql = 'SELECT post_id FROM ' . POSTS_TABLE . ' WHERE ' . $db->sql_in_set('post_visibility', $post_visibility) . ' AND ' . $db->sql_in_set('topic_id', $topic_id_list); $result = $db->sql_query($sql); $post_id_list = array(); while ($row = $db->sql_fetchrow($result)) { $post_id_list[] = (int) $row['post_id']; } $db->sql_freeresult($result); } if (!empty($post_id_list)) { self::disapprove_posts($post_id_list, 'queue', $mode); } else { trigger_error('NO_POST_SELECTED'); } break; } switch ($mode) { case 'approve_details': $this->tpl_name = 'mcp_post'; $user->add_lang(array('posting', 'viewtopic')); $post_id = $request->variable('p', 0); $topic_id = $request->variable('t', 0); /* @var $phpbb_notifications \phpbb\notification\manager */ $phpbb_notifications = $phpbb_container->get('notification_manager'); if ($topic_id) { $topic_info = phpbb_get_topic_data(array($topic_id), 'm_approve'); if (isset($topic_info[$topic_id]['topic_first_post_id'])) { $post_id = (int) $topic_info[$topic_id]['topic_first_post_id']; $phpbb_notifications->mark_notifications('topic_in_queue', $topic_id, $user->data['user_id']); } else { $topic_id = 0; } } $phpbb_notifications->mark_notifications('post_in_queue', $post_id, $user->data['user_id']); $post_info = phpbb_get_post_data(array($post_id), 'm_approve', true); if (!sizeof($post_info)) { trigger_error('NO_POST_SELECTED'); } $post_info = $post_info[$post_id]; if ($post_info['topic_first_post_id'] != $post_id && topic_review($post_info['topic_id'], $post_info['forum_id'], 'topic_review', 0, false)) { $template->assign_vars(array('S_TOPIC_REVIEW' => true, 'S_BBCODE_ALLOWED' => $post_info['enable_bbcode'], 'TOPIC_TITLE' => $post_info['topic_title'])); } $extensions = $attachments = $topic_tracking_info = array(); // Get topic tracking info if ($config['load_db_lastread']) { $tmp_topic_data = array($post_info['topic_id'] => $post_info); $topic_tracking_info = get_topic_tracking($post_info['forum_id'], $post_info['topic_id'], $tmp_topic_data, array($post_info['forum_id'] => $post_info['forum_mark_time'])); unset($tmp_topic_data); } else { $topic_tracking_info = get_complete_topic_tracking($post_info['forum_id'], $post_info['topic_id']); } $post_unread = isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']] ? true : false; // Process message, leave it uncensored $parse_flags = ($post_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; $message = generate_text_for_display($post_info['post_text'], $post_info['bbcode_uid'], $post_info['bbcode_bitfield'], $parse_flags, false); if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) { $extensions = $cache->obtain_attach_extensions($post_info['forum_id']); $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE post_msg_id = ' . $post_id . ' AND in_message = 0 ORDER BY filetime DESC, post_msg_id ASC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $attachments[] = $row; } $db->sql_freeresult($result); if (sizeof($attachments)) { $update_count = array(); parse_attachments($post_info['forum_id'], $message, $attachments, $update_count); } // Display not already displayed Attachments for this post, we already parsed them. ;) if (!empty($attachments)) { $template->assign_var('S_HAS_ATTACHMENTS', true); foreach ($attachments as $attachment) { $template->assign_block_vars('attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } } } // Deleting information if ($post_info['post_visibility'] == ITEM_DELETED && $post_info['post_delete_user']) { // User having deleted the post also being the post author? if (!$post_info['post_delete_user'] || $post_info['post_delete_user'] == $post_info['poster_id']) { $display_username = get_username_string('full', $post_info['poster_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']); } else { $sql = 'SELECT u.user_id, u.username, u.user_colour FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE p.post_id = ' . $post_info['post_id'] . ' AND p.post_delete_user = u.user_id'; $result = $db->sql_query($sql); $post_delete_userinfo = $db->sql_fetchrow($result); $db->sql_freeresult($result); $display_username = get_username_string('full', $post_info['post_delete_user'], $post_delete_userinfo['username'], $post_delete_userinfo['user_colour']); } $l_deleted_by = $user->lang('DELETED_INFORMATION', $display_username, $user->format_date($post_info['post_delete_time'], false, true)); } else { $l_deleted_by = ''; } $post_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']); $topic_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']); $template->assign_vars(array('S_MCP_QUEUE' => true, 'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=queue&p={$post_id}&f={$forum_id}"), 'S_CAN_DELETE_POST' => $auth->acl_get('m_delete', $post_info['forum_id']), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'], 'S_POST_UNAPPROVED' => $post_info['post_visibility'] == ITEM_UNAPPROVED || $post_info['post_visibility'] == ITEM_REAPPROVE, 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_USER_NOTES' => true, 'S_POST_DELETED' => $post_info['post_visibility'] == ITEM_DELETED, 'DELETED_MESSAGE' => $l_deleted_by, 'DELETE_REASON' => $post_info['post_delete_reason'], 'U_EDIT' => $auth->acl_get('m_edit', $post_info['forum_id']) ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '', 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&mode=user_notes&u=' . $post_info['user_id']), 'U_MCP_WARN_USER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&mode=warn_user&u=' . $post_info['user_id']) : '', 'U_VIEW_POST' => $post_url, 'U_VIEW_TOPIC' => $topic_url, 'MINI_POST_IMG' => $post_unread ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'RETURN_QUEUE' => sprintf($user->lang['RETURN_QUEUE'], '<a href="' . append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue' . ($topic_id ? '&mode=unapproved_topics' : '&mode=unapproved_posts')) . '&start=' . $start . '">', '</a>'), 'RETURN_POST' => sprintf($user->lang['RETURN_POST'], '<a href="' . $post_url . '">', '</a>'), 'RETURN_TOPIC_SIMPLE' => sprintf($user->lang['RETURN_TOPIC_SIMPLE'], '<a href="' . $topic_url . '">', '</a>'), 'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']), 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']), 'POST_AUTHOR_FULL' => get_username_string('full', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_AUTHOR' => get_username_string('username', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), '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' => $auth->acl_get('m_info', $post_info['forum_id']) && $request->variable('lookup', '') ? @gethostbyaddr($post_info['poster_ip']) : '', 'POST_ID' => $post_info['post_id'], 'S_FIRST_POST' => $post_info['topic_first_post_id'] == $post_id, 'U_LOOKUP_IP' => $auth->acl_get('m_info', $post_info['forum_id']) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id . '&lookup=' . $post_info['poster_ip']) . '#ip' : '')); break; case 'unapproved_topics': case 'unapproved_posts': case 'deleted_topics': case 'deleted_posts': $m_perm = 'm_approve'; $is_topics = $mode == 'unapproved_topics' || $mode == 'deleted_topics' ? true : false; $is_restore = $mode == 'deleted_posts' || $mode == 'deleted_topics' ? true : false; $visibility_const = !$is_restore ? array(ITEM_UNAPPROVED, ITEM_REAPPROVE) : ITEM_DELETED; $user->add_lang(array('viewtopic', 'viewforum')); $topic_id = $request->variable('t', 0); $forum_info = array(); /* @var $pagination \phpbb\pagination */ $pagination = $phpbb_container->get('pagination'); if ($topic_id) { $topic_info = phpbb_get_topic_data(array($topic_id)); if (!sizeof($topic_info)) { trigger_error('TOPIC_NOT_EXIST'); } $topic_info = $topic_info[$topic_id]; $forum_id = $topic_info['forum_id']; } $forum_list_approve = get_forum_list($m_perm, false, true); $forum_list_read = array_flip(get_forum_list('f_read', true, true)); // Flipped so we can isset() the forum IDs // Remove forums we cannot read foreach ($forum_list_approve as $k => $forum_data) { if (!isset($forum_list_read[$forum_data['forum_id']])) { unset($forum_list_approve[$k]); } } unset($forum_list_read); if (!$forum_id) { $forum_list = array(); foreach ($forum_list_approve as $row) { $forum_list[] = $row['forum_id']; } if (!sizeof($forum_list)) { trigger_error('NOT_MODERATOR'); } $sql = 'SELECT SUM(forum_topics_approved) as sum_forum_topics FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_list); $result = $db->sql_query($sql); $forum_info['forum_topics_approved'] = (int) $db->sql_fetchfield('sum_forum_topics'); $db->sql_freeresult($result); } else { $forum_info = phpbb_get_forum_data(array($forum_id), $m_perm); if (!sizeof($forum_info)) { trigger_error('NOT_MODERATOR'); } $forum_info = $forum_info[$forum_id]; $forum_list = $forum_id; } $forum_options = '<option value="0"' . ($forum_id == 0 ? ' selected="selected"' : '') . '>' . $user->lang['ALL_FORUMS'] . '</option>'; foreach ($forum_list_approve as $row) { $forum_options .= '<option value="' . $row['forum_id'] . '"' . ($forum_id == $row['forum_id'] ? ' selected="selected"' : '') . '>' . str_repeat(' ', $row['padding']) . truncate_string($row['forum_name'], 30, 255, false, $user->lang['ELLIPSIS']) . '</option>'; } $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); phpbb_mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id); $forum_topics = $total == -1 ? $forum_info['forum_topics_approved'] : $total; $limit_time_sql = $sort_days ? 'AND t.topic_last_post_time >= ' . (time() - $sort_days * 86400) : ''; $forum_names = array(); if (!$is_topics) { $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . ($sort_order_sql[0] == 'u' ? ', ' . USERS_TABLE . ' u' : '') . ' WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . ' AND ' . $db->sql_in_set('p.post_visibility', $visibility_const) . ' ' . ($sort_order_sql[0] == 'u' ? 'AND u.user_id = p.poster_id' : '') . ' ' . ($topic_id ? 'AND p.topic_id = ' . $topic_id : '') . "\n\t\t\t\t\t\t\tAND t.topic_id = p.topic_id\n\t\t\t\t\t\t\tAND (t.topic_visibility <> p.post_visibility\n\t\t\t\t\t\t\t\tOR t.topic_delete_user = 0)\n\t\t\t\t\t\t\t{$limit_time_sql}\n\t\t\t\t\t\tORDER BY {$sort_order_sql}"; /** * Alter sql query to get posts in queue to be accepted * * @event core.mcp_queue_get_posts_query_before * @var string sql Associative array with the query to be executed * @var array forum_list List of forums that contain the posts * @var int visibility_const Integer with one of the possible ITEM_* constant values * @var int topic_id If topic_id not equal to 0, the topic id to filter the posts to display * @var string limit_time_sql String with the SQL code to limit the time interval of the post (Note: May be empty string) * @var string sort_order_sql String with the ORDER BY SQL code used in this query * @since 3.1.0-RC3 */ $vars = array('sql', 'forum_list', 'visibility_const', 'topic_id', 'limit_time_sql', 'sort_order_sql'); extract($phpbb_dispatcher->trigger_event('core.mcp_queue_get_posts_query_before', compact($vars))); $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); $i = 0; $post_ids = array(); while ($row = $db->sql_fetchrow($result)) { $post_ids[] = $row['post_id']; $row_num[$row['post_id']] = $i++; } $db->sql_freeresult($result); if (sizeof($post_ids)) { $sql = 'SELECT t.topic_id, t.topic_title, t.forum_id, p.post_id, p.post_subject, p.post_username, p.poster_id, p.post_time, p.post_attachment, u.username, u.username_clean, u.user_colour FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u WHERE ' . $db->sql_in_set('p.post_id', $post_ids) . ' AND t.topic_id = p.topic_id AND u.user_id = p.poster_id ORDER BY ' . $sort_order_sql; $result = $db->sql_query($sql); $post_data = $rowset = array(); while ($row = $db->sql_fetchrow($result)) { $forum_names[] = $row['forum_id']; $post_data[$row['post_id']] = $row; } $db->sql_freeresult($result); foreach ($post_ids as $post_id) { $rowset[] = $post_data[$post_id]; } unset($post_data, $post_ids); } else { $rowset = array(); } } else { $sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, t.topic_title AS post_subject, t.topic_time AS post_time, t.topic_poster AS poster_id, t.topic_first_post_id AS post_id, t.topic_attachment AS post_attachment, t.topic_first_poster_name AS username, t.topic_first_poster_colour AS user_colour FROM ' . TOPICS_TABLE . ' t WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' AND ' . $db->sql_in_set('topic_visibility', $visibility_const) . "\n\t\t\t\t\t\t\tAND topic_delete_user <> 0\n\t\t\t\t\t\t\t{$limit_time_sql}\n\t\t\t\t\t\tORDER BY {$sort_order_sql}"; /** * Alter sql query to get information on all topics in the list of forums provided. * * @event core.mcp_queue_get_posts_for_topics_query_before * @var string sql String with the query to be executed * @var array forum_list List of forums that contain the posts * @var int visibility_const Integer with one of the possible ITEM_* constant values * @var int topic_id topic_id in the page request * @var string limit_time_sql String with the SQL code to limit the time interval of the post (Note: May be empty string) * @var string sort_order_sql String with the ORDER BY SQL code used in this query * @since 3.1.0-RC3 */ $vars = array('sql', 'forum_list', 'visibility_const', 'topic_id', 'limit_time_sql', 'sort_order_sql'); extract($phpbb_dispatcher->trigger_event('core.mcp_queue_get_posts_for_topics_query_before', compact($vars))); $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); $rowset = array(); while ($row = $db->sql_fetchrow($result)) { $forum_names[] = $row['forum_id']; $rowset[] = $row; } $db->sql_freeresult($result); } if (sizeof($forum_names)) { // Select the names for the forum_ids $sql = 'SELECT forum_id, forum_name FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_names); $result = $db->sql_query($sql, 3600); $forum_names = array(); while ($row = $db->sql_fetchrow($result)) { $forum_names[$row['forum_id']] = $row['forum_name']; } $db->sql_freeresult($result); } foreach ($rowset as $row) { if (empty($row['post_username'])) { $row['post_username'] = $row['username'] ?: $user->lang['GUEST']; } $template->assign_block_vars('postrow', array('U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']), 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']), 'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&p=' . $row['post_id']) . ($mode == 'unapproved_posts' ? '#p' . $row['post_id'] : ''), 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=queue&start={$start}&mode=approve_details&f={$row['forum_id']}&p={$row['post_id']}" . ($mode == 'unapproved_topics' ? "&t={$row['topic_id']}" : '')), 'POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_ID' => $row['post_id'], 'TOPIC_ID' => $row['topic_id'], 'FORUM_NAME' => $forum_names[$row['forum_id']], 'POST_SUBJECT' => $row['post_subject'] != '' ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'TOPIC_TITLE' => $row['topic_title'], 'POST_TIME' => $user->format_date($row['post_time']), 'ATTACH_ICON_IMG' => $auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment'] ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '')); } unset($rowset, $forum_names); $base_url = $this->u_action . "&f={$forum_id}&st={$sort_days}&sk={$sort_key}&sd={$sort_dir}"; $pagination->generate_template_pagination($base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start); // Now display the page $template->assign_vars(array('L_DISPLAY_ITEMS' => !$is_topics ? $user->lang['DISPLAY_POSTS'] : $user->lang['DISPLAY_TOPICS'], 'L_EXPLAIN' => $user->lang['MCP_QUEUE_' . strtoupper($mode) . '_EXPLAIN'], 'L_TITLE' => $user->lang['MCP_QUEUE_' . strtoupper($mode)], 'L_ONLY_TOPIC' => $topic_id ? sprintf($user->lang['ONLY_TOPIC'], $topic_info['topic_title']) : '', 'S_FORUM_OPTIONS' => $forum_options, 'S_MCP_ACTION' => build_url(array('t', 'f', 'sd', 'st', 'sk')), 'S_TOPICS' => $is_topics, 'S_RESTORE' => $is_restore, 'TOPIC_ID' => $topic_id, 'TOTAL' => $user->lang(!$is_topics ? 'VIEW_TOPIC_POSTS' : 'VIEW_FORUM_TOPICS', (int) $total))); $this->tpl_name = 'mcp_queue'; break; } }
function main($id, $mode) { global $auth, $db, $user, $template, $cache; global $config, $phpbb_root_path, $phpEx, $action, $phpbb_container, $phpbb_dispatcher; include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx; $forum_id = request_var('f', 0); $start = request_var('start', 0); $this->page_title = 'MCP_REPORTS'; switch ($action) { case 'close': case 'delete': include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx; $report_id_list = request_var('report_id_list', array(0)); if (!sizeof($report_id_list)) { trigger_error('NO_REPORT_SELECTED'); } close_report($report_id_list, $mode, $action); break; } switch ($mode) { case 'report_details': $user->add_lang(array('posting', 'viewforum', 'viewtopic')); $post_id = request_var('p', 0); // closed reports are accessed by report id $report_id = request_var('r', 0); $sql = 'SELECT r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, r.reported_post_text, r.reported_post_uid, r.reported_post_bitfield, r.reported_post_enable_magic_url, r.reported_post_enable_smilies, r.reported_post_enable_bbcode, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour FROM ' . REPORTS_TABLE . ' r, ' . REPORTS_REASONS_TABLE . ' rr, ' . USERS_TABLE . ' u WHERE ' . ($report_id ? 'r.report_id = ' . $report_id : "r.post_id = {$post_id}") . ' AND rr.reason_id = r.reason_id AND r.user_id = u.user_id AND r.pm_id = 0 ORDER BY report_closed ASC'; $result = $db->sql_query_limit($sql, 1); $report = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$report) { trigger_error('NO_REPORT'); } $phpbb_notifications = $phpbb_container->get('notification_manager'); $phpbb_notifications->mark_notifications_read('notification.type.report_post', $post_id, $user->data['user_id']); if (!$report_id && $report['report_closed']) { trigger_error('REPORT_CLOSED'); } $post_id = $report['post_id']; $report_id = $report['report_id']; $parse_post_flags = $report['reported_post_enable_bbcode'] ? OPTION_FLAG_BBCODE : 0; $parse_post_flags += $report['reported_post_enable_smilies'] ? OPTION_FLAG_SMILIES : 0; $parse_post_flags += $report['reported_post_enable_magic_url'] ? OPTION_FLAG_LINKS : 0; $post_info = phpbb_get_post_data(array($post_id), 'm_report', true); if (!sizeof($post_info)) { trigger_error('NO_REPORT_SELECTED'); } $post_info = $post_info[$post_id]; $reason = array('title' => $report['reason_title'], 'description' => $report['reason_description']); if (isset($user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])])) { $reason['description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])]; $reason['title'] = $user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]; } if (topic_review($post_info['topic_id'], $post_info['forum_id'], 'topic_review', 0, false)) { $template->assign_vars(array('S_TOPIC_REVIEW' => true, 'S_BBCODE_ALLOWED' => $post_info['enable_bbcode'], 'TOPIC_TITLE' => $post_info['topic_title'], 'REPORTED_POST_ID' => $post_id)); } $topic_tracking_info = $extensions = $attachments = array(); // Get topic tracking info if ($config['load_db_lastread']) { $tmp_topic_data = array($post_info['topic_id'] => $post_info); $topic_tracking_info = get_topic_tracking($post_info['forum_id'], $post_info['topic_id'], $tmp_topic_data, array($post_info['forum_id'] => $post_info['forum_mark_time'])); unset($tmp_topic_data); } else { $topic_tracking_info = get_complete_topic_tracking($post_info['forum_id'], $post_info['topic_id']); } $post_unread = isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']] ? true : false; $message = generate_text_for_display($report['reported_post_text'], $report['reported_post_uid'], $report['reported_post_bitfield'], $parse_post_flags, false); $report['report_text'] = make_clickable(bbcode_nl2br($report['report_text'])); if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) { $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE post_msg_id = ' . $post_id . ' AND in_message = 0 AND filetime <= ' . (int) $report['report_time'] . ' ORDER BY filetime DESC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $attachments[] = $row; } $db->sql_freeresult($result); if (sizeof($attachments)) { $update_count = array(); parse_attachments($post_info['forum_id'], $message, $attachments, $update_count); } // Display not already displayed Attachments for this post, we already parsed them. ;) if (!empty($attachments)) { $template->assign_var('S_HAS_ATTACHMENTS', true); foreach ($attachments as $attachment) { $template->assign_block_vars('attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } } } $template->assign_vars(array('S_MCP_REPORT' => true, 'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'], 'S_POST_UNAPPROVED' => $post_info['post_visibility'] == ITEM_UNAPPROVED || $post_info['post_visibility'] == ITEM_REAPPROVE, 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_REPORT_CLOSED' => $report['report_closed'], 'S_USER_NOTES' => true, 'U_EDIT' => $auth->acl_get('m_edit', $post_info['forum_id']) ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '', 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_REPORTER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&mode=user_notes&u=' . $report['user_id']), 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&mode=user_notes&u=' . $post_info['user_id']), 'U_MCP_WARN_REPORTER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&mode=warn_user&u=' . $report['user_id']) : '', 'U_MCP_WARN_USER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&mode=warn_user&u=' . $post_info['user_id']) : '', 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $post_info['forum_id']), 'U_VIEW_POST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']), 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']), 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']), 'MINI_POST_IMG' => $post_unread ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']), 'RETURN_REPORTS' => sprintf($user->lang['RETURN_REPORTS'], '<a href="' . append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports' . ($post_info['post_reported'] ? '&mode=reports' : '&mode=reports_closed') . '&start=' . $start . '&f=' . $post_info['forum_id']) . '">', '</a>'), 'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']), 'REPORT_DATE' => $user->format_date($report['report_time']), 'REPORT_ID' => $report_id, 'REPORT_REASON_TITLE' => $reason['title'], 'REPORT_REASON_DESCRIPTION' => $reason['description'], 'REPORT_TEXT' => $report['report_text'], 'POST_AUTHOR_FULL' => get_username_string('full', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_AUTHOR' => get_username_string('username', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'REPORTER_FULL' => get_username_string('full', $report['user_id'], $report['username'], $report['user_colour']), 'REPORTER_COLOUR' => get_username_string('colour', $report['user_id'], $report['username'], $report['user_colour']), 'REPORTER_NAME' => get_username_string('username', $report['user_id'], $report['username'], $report['user_colour']), 'U_VIEW_REPORTER_PROFILE' => get_username_string('profile', $report['user_id'], $report['username'], $report['user_colour']), 'POST_PREVIEW' => $message, 'POST_SUBJECT' => $post_info['post_subject'] ? $post_info['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_DATE' => $user->format_date($post_info['post_time']), 'POST_IP' => $post_info['poster_ip'], 'POST_IPADDR' => $auth->acl_get('m_info', $post_info['forum_id']) && request_var('lookup', '') ? @gethostbyaddr($post_info['poster_ip']) : '', 'POST_ID' => $post_info['post_id'], 'U_LOOKUP_IP' => $auth->acl_get('m_info', $post_info['forum_id']) ? $this->u_action . '&r=' . $report_id . '&p=' . $post_id . '&f=' . $forum_id . '&lookup=' . $post_info['poster_ip'] . '#ip' : '')); $this->tpl_name = 'mcp_post'; break; case 'reports': case 'reports_closed': $topic_id = request_var('t', 0); $forum_info = array(); $forum_list_reports = get_forum_list('m_report', false, true); $forum_list_read = array_flip(get_forum_list('f_read', true, true)); // Flipped so we can isset() the forum IDs // Remove forums we cannot read foreach ($forum_list_reports as $k => $forum_data) { if (!isset($forum_list_read[$forum_data['forum_id']])) { unset($forum_list_reports[$k]); } } unset($forum_list_read); if ($topic_id) { $topic_info = phpbb_get_topic_data(array($topic_id)); if (!sizeof($topic_info)) { trigger_error('TOPIC_NOT_EXIST'); } if ($forum_id != $topic_info[$topic_id]['forum_id']) { $topic_id = 0; } else { $topic_info = $topic_info[$topic_id]; $forum_id = (int) $topic_info['forum_id']; } } $forum_list = array(); if (!$forum_id) { foreach ($forum_list_reports as $row) { $forum_list[] = $row['forum_id']; } if (!sizeof($forum_list)) { trigger_error('NOT_MODERATOR'); } $global_id = $forum_list[0]; $sql = 'SELECT SUM(forum_topics_approved) as sum_forum_topics FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_list); $result = $db->sql_query($sql); $forum_info['forum_topics_approved'] = (int) $db->sql_fetchfield('sum_forum_topics'); $db->sql_freeresult($result); } else { $forum_info = phpbb_get_forum_data(array($forum_id), 'm_report'); if (!sizeof($forum_info)) { trigger_error('NOT_MODERATOR'); } $forum_info = $forum_info[$forum_id]; $forum_list = array($forum_id); } $forum_list[] = 0; $forum_data = array(); $pagination = $phpbb_container->get('pagination'); $forum_options = '<option value="0"' . ($forum_id == 0 ? ' selected="selected"' : '') . '>' . $user->lang['ALL_FORUMS'] . '</option>'; foreach ($forum_list_reports as $row) { $forum_options .= '<option value="' . $row['forum_id'] . '"' . ($forum_id == $row['forum_id'] ? ' selected="selected"' : '') . '>' . str_repeat(' ', $row['padding']) . $row['forum_name'] . '</option>'; $forum_data[$row['forum_id']] = $row; } unset($forum_list_reports); $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); phpbb_mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id); $forum_topics = $total == -1 ? $forum_info['forum_topics_approved'] : $total; $limit_time_sql = $sort_days ? 'AND r.report_time >= ' . (time() - $sort_days * 86400) : ''; if ($mode == 'reports') { $report_state = 'AND p.post_reported = 1 AND r.report_closed = 0'; } else { $report_state = 'AND r.report_closed = 1'; } $sql = 'SELECT r.report_id FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . REPORTS_TABLE . ' r ' . ($sort_order_sql[0] == 'u' ? ', ' . USERS_TABLE . ' u' : '') . ($sort_order_sql[0] == 'r' ? ', ' . USERS_TABLE . ' ru' : '') . ' WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . "\n\t\t\t\t\t\t{$report_state}\n\t\t\t\t\t\tAND r.post_id = p.post_id\n\t\t\t\t\t\t" . ($sort_order_sql[0] == 'u' ? 'AND u.user_id = p.poster_id' : '') . ' ' . ($sort_order_sql[0] == 'r' ? 'AND ru.user_id = r.user_id' : '') . ' ' . ($topic_id ? 'AND p.topic_id = ' . $topic_id : '') . "\n\t\t\t\t\t\tAND t.topic_id = p.topic_id\n\t\t\t\t\t\tAND r.pm_id = 0\n\t\t\t\t\t\t{$limit_time_sql}\n\t\t\t\t\tORDER BY {$sort_order_sql}"; /** * Alter sql query to get report id of all reports for requested forum and topic or just forum * * @event core.mcp_reports_get_reports_query_before * @var string sql String with the query to be executed * @var array forum_list List of forums that contain the posts * @var int topic_id topic_id in the page request * @var string limit_time_sql String with the SQL code to limit the time interval of the post (Note: May be empty string) * @var string sort_order_sql String with the ORDER BY SQL code used in this query * @since 3.1.0-RC4 */ $vars = array('sql', 'forum_list', 'topic_id', 'limit_time_sql', 'sort_order_sql'); extract($phpbb_dispatcher->trigger_event('core.mcp_reports_get_reports_query_before', compact($vars))); $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); $i = 0; $report_ids = array(); while ($row = $db->sql_fetchrow($result)) { $report_ids[] = $row['report_id']; $row_num[$row['report_id']] = $i++; } $db->sql_freeresult($result); if (sizeof($report_ids)) { $sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, p.post_id, p.post_subject, p.post_username, p.poster_id, p.post_time, p.post_attachment, u.username, u.username_clean, u.user_colour, r.user_id as reporter_id, ru.username as reporter_name, ru.user_colour as reporter_colour, r.report_time, r.report_id FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u, ' . USERS_TABLE . ' ru WHERE ' . $db->sql_in_set('r.report_id', $report_ids) . ' AND t.topic_id = p.topic_id AND r.post_id = p.post_id AND u.user_id = p.poster_id AND ru.user_id = r.user_id AND r.pm_id = 0 ORDER BY ' . $sort_order_sql; $result = $db->sql_query($sql); $report_data = $rowset = array(); while ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('postrow', array('U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']), 'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&p=' . $row['post_id']) . '#p' . $row['post_id'], 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=reports&start={$start}&mode=report_details&f={$row['forum_id']}&r={$row['report_id']}"), 'POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'REPORTER_FULL' => get_username_string('full', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'REPORTER_COLOUR' => get_username_string('colour', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'REPORTER' => get_username_string('username', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'U_REPORTER' => get_username_string('profile', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'FORUM_NAME' => $forum_data[$row['forum_id']]['forum_name'], 'POST_ID' => $row['post_id'], 'POST_SUBJECT' => $row['post_subject'] ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_TIME' => $user->format_date($row['post_time']), 'REPORT_ID' => $row['report_id'], 'REPORT_TIME' => $user->format_date($row['report_time']), 'TOPIC_TITLE' => $row['topic_title'], 'ATTACH_ICON_IMG' => $auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment'] ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '')); } $db->sql_freeresult($result); unset($report_ids, $row); } $base_url = $this->u_action . "&f={$forum_id}&t={$topic_id}&st={$sort_days}&sk={$sort_key}&sd={$sort_dir}"; $pagination->generate_template_pagination($base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start); // Now display the page $template->assign_vars(array('L_EXPLAIN' => $mode == 'reports' ? $user->lang['MCP_REPORTS_OPEN_EXPLAIN'] : $user->lang['MCP_REPORTS_CLOSED_EXPLAIN'], 'L_TITLE' => $mode == 'reports' ? $user->lang['MCP_REPORTS_OPEN'] : $user->lang['MCP_REPORTS_CLOSED'], 'L_ONLY_TOPIC' => $topic_id ? sprintf($user->lang['ONLY_TOPIC'], $topic_info['topic_title']) : '', 'S_MCP_ACTION' => $this->u_action, 'S_FORUM_OPTIONS' => $forum_options, 'S_CLOSED' => $mode == 'reports_closed' ? true : false, 'TOPIC_ID' => $topic_id, 'TOTAL' => $total, 'TOTAL_REPORTS' => $user->lang('LIST_REPORTS', (int) $total))); $this->tpl_name = 'mcp_reports'; break; } }
/** * Build and assign topiclist for bookmarks/subscribed topics */ function assign_topiclist($mode = 'subscribed', $forbidden_forum_ary = array()) { global $user, $db, $template, $config, $cache, $auth, $phpbb_root_path, $phpEx, $phpbb_container, $request, $phpbb_dispatcher; /* @var $pagination \phpbb\pagination */ $pagination = $phpbb_container->get('pagination'); $table = $mode == 'subscribed' ? TOPICS_WATCH_TABLE : BOOKMARKS_TABLE; $start = $request->variable('start', 0); // Grab icons $icons = $cache->obtain_icons(); $sql_array = array('SELECT' => 'COUNT(t.topic_id) as topics_count', 'FROM' => array($table => 'i', TOPICS_TABLE => 't'), 'WHERE' => 'i.topic_id = t.topic_id AND i.user_id = ' . $user->data['user_id'] . ' AND ' . $db->sql_in_set('t.forum_id', $forbidden_forum_ary, true, true)); /** * Modify the query used to retrieve the count of subscribed/bookmarked topics * * @event core.ucp_main_topiclist_count_modify_query * @var array sql_array The subscribed/bookmarked topics query * @var array forbidden_forum_ary The list of forbidden forums * @var string mode The type of topic list ('subscribed' or 'bookmarks') * @since 3.1.10-RC1 */ $vars = array('sql_array', 'forbidden_forum_ary', 'mode'); extract($phpbb_dispatcher->trigger_event('core.ucp_main_topiclist_count_modify_query', compact($vars))); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $topics_count = (int) $db->sql_fetchfield('topics_count'); $db->sql_freeresult($result); if ($topics_count) { $start = $pagination->validate_start($start, $config['topics_per_page'], $topics_count); $pagination->generate_template_pagination($this->u_action, 'pagination', 'start', $topics_count, $config['topics_per_page'], $start); $template->assign_vars(array('TOTAL_TOPICS' => $user->lang('VIEW_FORUM_TOPICS', (int) $topics_count))); } if ($mode == 'subscribed') { $sql_array = array('SELECT' => 't.*, f.forum_name', 'FROM' => array(TOPICS_WATCH_TABLE => 'tw', TOPICS_TABLE => 't'), 'WHERE' => 'tw.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tw.topic_id AND ' . $db->sql_in_set('t.forum_id', $forbidden_forum_ary, true, true), 'ORDER_BY' => 't.topic_last_post_time DESC, t.topic_last_post_id DESC'); $sql_array['LEFT_JOIN'] = array(); } else { $sql_array = array('SELECT' => 't.*, f.forum_name, b.topic_id as b_topic_id', 'FROM' => array(BOOKMARKS_TABLE => 'b'), 'WHERE' => 'b.user_id = ' . $user->data['user_id'] . ' AND ' . $db->sql_in_set('f.forum_id', $forbidden_forum_ary, true, true), 'ORDER_BY' => 't.topic_last_post_time DESC, t.topic_last_post_id DESC'); $sql_array['LEFT_JOIN'] = array(); $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TABLE => 't'), 'ON' => 'b.topic_id = t.topic_id'); } $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 't.forum_id = f.forum_id'); if ($config['load_db_lastread']) { $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.forum_id = t.forum_id AND ft.user_id = ' . $user->data['user_id']); $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TRACK_TABLE => 'tt'), 'ON' => 'tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id']); $sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time AS forum_mark_time'; } if ($config['load_db_track']) { $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_POSTED_TABLE => 'tp'), 'ON' => 'tp.topic_id = t.topic_id AND tp.user_id = ' . $user->data['user_id']); $sql_array['SELECT'] .= ', tp.topic_posted'; } /** * Modify the query used to retrieve the list of subscribed/bookmarked topics * * @event core.ucp_main_topiclist_modify_query * @var array sql_array The subscribed/bookmarked topics query * @var array forbidden_forum_ary The list of forbidden forums * @var string mode The type of topic list ('subscribed' or 'bookmarks') * @since 3.1.10-RC1 */ $vars = array('sql_array', 'forbidden_forum_ary', 'mode'); extract($phpbb_dispatcher->trigger_event('core.ucp_main_topiclist_modify_query', compact($vars))); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); $topic_list = $topic_forum_list = $global_announce_list = $rowset = array(); while ($row = $db->sql_fetchrow($result)) { $topic_id = isset($row['b_topic_id']) ? $row['b_topic_id'] : $row['topic_id']; $topic_list[] = $topic_id; $rowset[$topic_id] = $row; $topic_forum_list[$row['forum_id']]['forum_mark_time'] = $config['load_db_lastread'] ? $row['forum_mark_time'] : 0; $topic_forum_list[$row['forum_id']]['topics'][] = $topic_id; if ($row['topic_type'] == POST_GLOBAL) { $global_announce_list[] = $topic_id; } } $db->sql_freeresult($result); $topic_tracking_info = array(); if ($config['load_db_lastread']) { foreach ($topic_forum_list as $f_id => $topic_row) { $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time'])); } } else { foreach ($topic_forum_list as $f_id => $topic_row) { $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics']); } } /* @var $phpbb_content_visibility \phpbb\content_visibility */ $phpbb_content_visibility = $phpbb_container->get('content.visibility'); foreach ($topic_list as $topic_id) { $row =& $rowset[$topic_id]; $forum_id = $row['forum_id']; $topic_id = isset($row['b_topic_id']) ? $row['b_topic_id'] : $row['topic_id']; $unread_topic = isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id] ? true : false; // Replies $replies = $phpbb_content_visibility->get_count('topic_posts', $row, $forum_id) - 1; if ($row['topic_status'] == ITEM_MOVED && !empty($row['topic_moved_id'])) { $topic_id = $row['topic_moved_id']; } // Get folder img, topic status/type related information $folder_img = $folder_alt = $topic_type = ''; topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type); $view_topic_url_params = "f={$forum_id}&t={$topic_id}"; $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", $view_topic_url_params); // Send vars to template $template_vars = array('FORUM_ID' => $forum_id, 'TOPIC_ID' => $topic_id, 'FIRST_POST_TIME' => $user->format_date($row['topic_time']), 'LAST_POST_SUBJECT' => $row['topic_last_post_subject'], 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), 'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']), 'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'S_DELETED_TOPIC' => !$row['topic_id'] ? true : false, 'REPLIES' => $replies, 'VIEWS' => $row['topic_views'], 'TOPIC_TITLE' => censor_text($row['topic_title']), 'TOPIC_TYPE' => $topic_type, 'FORUM_NAME' => $row['forum_name'], 'TOPIC_IMG_STYLE' => $folder_img, 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt], 'TOPIC_ICON_IMG' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['img'] : '', 'TOPIC_ICON_IMG_WIDTH' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['width'] : '', 'TOPIC_ICON_IMG_HEIGHT' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['height'] : '', 'ATTACH_ICON_IMG' => $auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment'] ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 'S_TOPIC_TYPE' => $row['topic_type'], 'S_USER_POSTED' => !empty($row['topic_posted']) ? true : false, 'S_UNREAD_TOPIC' => $unread_topic, 'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", $view_topic_url_params . '&view=unread') . '#unread', 'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", $view_topic_url_params . '&p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'], 'U_VIEW_TOPIC' => $view_topic_url, 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $forum_id)); /** * Add template variables to a subscribed/bookmarked topic row. * * @event core.ucp_main_topiclist_topic_modify_template_vars * @var array template_vars Array containing the template variables for the row * @var array row Array containing the subscribed/bookmarked topic row data * @var int forum_id ID of the forum containing the topic * @var int topic_id Topic ID * @var int replies Number of replies in the topic * @var string topic_type Topic type * @var string folder_img Folder image * @var string folder_alt Alt text for the folder image * @var array icons Array containing topic icons * @var bool unread_topic Whether the topic has unread content or not * @var string view_topic_url The URL of the topic * @since 3.1.10-RC1 */ $vars = array('template_vars', 'row', 'forum_id', 'topic_id', 'replies', 'topic_type', 'folder_img', 'folder_alt', 'icons', 'unread_topic', 'view_topic_url'); extract($phpbb_dispatcher->trigger_event('core.ucp_main_topiclist_topic_modify_template_vars', compact($vars))); $template->assign_block_vars('topicrow', $template_vars); $pagination->generate_template_pagination(append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . "&t={$topic_id}"), 'topicrow.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true); } }