session_begin(); $auth->acl($user->data); // Initial var setup $forum_id = request_var('f', 0); $topic_id = request_var('t', 0); $post_id = request_var('p', 0); $voted_id = request_var('vote_id', array('' => 0)); $voted_id = (sizeof($voted_id) > 1) ? array_unique($voted_id) : $voted_id; $start = request_var('start', 0); $view = request_var('view', ''); $default_sort_days = (!empty($user->data['user_post_show_days'])) ? $user->data['user_post_show_days'] : 0; $default_sort_key = (!empty($user->data['user_post_sortby_type'])) ? $user->data['user_post_sortby_type'] : 't'; $default_sort_dir = (!empty($user->data['user_post_sortby_dir'])) ? $user->data['user_post_sortby_dir'] : 'a'; $sort_days = request_var('st', $default_sort_days); $sort_key = request_var('sk', $default_sort_key); $sort_dir = request_var('sd', $default_sort_dir); $update = request_var('update', false); $s_can_vote = false; /** * @todo normalize? */ $hilit_words = request_var('hilit', '', true); // Do we have a topic or post id? if (!$topic_id && !$post_id) { trigger_error('NO_TOPIC'); } // Find topic id if user requested a newer or older topic if ($view && !$post_id) { if (!$forum_id) { $sql = 'SELECT forum_id FROM ' . TOPICS_TABLE . " WHERE topic_id = $topic_id"; $result = $db->sql_query($sql); $forum_id = (int) $db->sql_fetchfield('forum_id'); $db->sql_freeresult($result); if (!$forum_id) { trigger_error('NO_TOPIC'); } } if ($view == 'unread') { // Get topic tracking info $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id); $topic_last_read = (isset($topic_tracking_info[$topic_id])) ? $topic_tracking_info[$topic_id] : 0; $sql = 'SELECT post_id, topic_id, forum_id FROM ' . POSTS_TABLE . " WHERE topic_id = $topic_id " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1') . " AND post_time > $topic_last_read AND forum_id = $forum_id ORDER BY post_time ASC"; $result = $db->sql_query_limit($sql, 1); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$row) { $sql = 'SELECT topic_last_post_id as post_id, topic_id, forum_id FROM ' . TOPICS_TABLE . ' WHERE topic_id = ' . $topic_id; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); } if (!$row) { // Setup user environment so we can process lang string $user->setup('viewtopic'); trigger_error('NO_TOPIC'); } $post_id = $row['post_id']; $topic_id = $row['topic_id']; } else if ($view == 'next' || $view == 'previous') { $sql_condition = ($view == 'next') ? '>' : '<'; $sql_ordering = ($view == 'next') ? 'ASC' : 'DESC'; $sql = 'SELECT forum_id, topic_last_post_time FROM ' . TOPICS_TABLE . ' WHERE topic_id = ' . $topic_id; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$row) { $user->setup('viewtopic'); // OK, the topic doesn't exist. This error message is not helpful, but technically correct. trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS'); } else { $sql = 'SELECT topic_id, forum_id FROM ' . TOPICS_TABLE . ' WHERE forum_id = ' . $row['forum_id'] . " AND topic_moved_id = 0 AND topic_last_post_time $sql_condition {$row['topic_last_post_time']} " . (($auth->acl_get('m_approve', $row['forum_id'])) ? '' : 'AND topic_approved = 1') . " ORDER BY topic_last_post_time $sql_ordering"; $result = $db->sql_query_limit($sql, 1); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$row) { $user->setup('viewtopic'); trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS'); } else { $topic_id = $row['topic_id']; // Check for global announcement correctness? if (!$row['forum_id'] && !$forum_id) { trigger_error('NO_TOPIC'); } else if ($row['forum_id']) { $forum_id = $row['forum_id']; } } } } // Check for global announcement correctness? if ((!isset($row) || !$row['forum_id']) && !$forum_id) { trigger_error('NO_TOPIC'); } else if (isset($row) && $row['forum_id']) { $forum_id = $row['forum_id']; } } // This rather complex gaggle of code handles querying for topics but // also allows for direct linking to a post (and the calculation of which // page the post is on and the correct display of viewtopic) $sql_array = array( 'SELECT' => 't.*, f.*', 'FROM' => array(FORUMS_TABLE => 'f'), ); // Firebird handles two columns of the same name a little differently, this // addresses that by forcing the forum_id to come from the forums table. if ($db->sql_layer === 'firebird') { $sql_array['SELECT'] = 'f.forum_id AS forum_id, ' . $sql_array['SELECT']; } // The FROM-Order is quite important here, else t.* columns can not be correctly bound. if ($post_id) { $sql_array['SELECT'] .= ', p.post_approved'; $sql_array['FROM'][POSTS_TABLE] = 'p'; } // Topics table need to be the last in the chain $sql_array['FROM'][TOPICS_TABLE] = 't'; if ($user->data['is_registered']) { $sql_array['SELECT'] .= ', tw.notify_status'; $sql_array['LEFT_JOIN'] = array(); $sql_array['LEFT_JOIN'][] = array( 'FROM' => array(TOPICS_WATCH_TABLE => 'tw'), 'ON' => 'tw.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tw.topic_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' ); } if ($config['load_db_lastread']) { $sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as forum_mark_time'; $sql_array['LEFT_JOIN'][] = array( 'FROM' => array(TOPICS_TRACK_TABLE => 'tt'), 'ON' => 'tt.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tt.topic_id' ); $sql_array['LEFT_JOIN'][] = array( 'FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND t.forum_id = ft.forum_id' ); } } if (!$post_id) { $sql_array['WHERE'] = "t.topic_id = $topic_id"; } else { $sql_array['WHERE'] = "p.post_id = $post_id AND t.topic_id = p.topic_id"; } $sql_array['WHERE'] .= ' AND (f.forum_id = t.forum_id'; if (!$forum_id) { // If it is a global announcement make sure to set the forum id to a postable forum $sql_array['WHERE'] .= ' OR (t.topic_type = ' . POST_GLOBAL . ' AND f.forum_type = ' . FORUM_POST . ')'; } else { $sql_array['WHERE'] .= ' OR (t.topic_type = ' . POST_GLOBAL . " AND f.forum_id = $f#- $Id$ $ package urpm_pkg; sub flag_available { return 1; } package pkgs; use log; sub rpmDbOpen { #- install_steps:343 } sub packageByName { #- install_steps:344 return bless {}, 'urpm_pkg'; #- we'll need to call flag_available on it } sub selectPackage { #- install_steps:344 } sub packagesToInstall { #- install_steps:346 return (); } 1;