Exemplo n.º 1
0
    /**
     * {@inheritdoc}
     */
    public function open()
    {
        // Check if forum exists
        $sql = 'SELECT forum_id, forum_name, forum_password, forum_type, forum_options
			FROM ' . FORUMS_TABLE . '
			WHERE forum_id = ' . $this->forum_id;
        $result = $this->db->sql_query($sql);
        $this->forum_data = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        if (empty($this->forum_data)) {
            throw new no_forum_exception($this->forum_id);
        }
        // Forum needs to be postable
        if ($this->forum_data['forum_type'] != FORUM_POST) {
            throw new no_feed_exception();
        }
        // Make sure forum is not excluded from feed
        if (phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $this->forum_data['forum_options'])) {
            throw new no_feed_exception();
        }
        // Make sure we can read this forum
        if (!$this->auth->acl_get('f_read', $this->forum_id)) {
            throw new unauthorized_forum_exception($this->forum_id);
        }
        // Make sure forum is not passworded or user is authed
        if ($this->forum_data['forum_password']) {
            $forum_ids_passworded = $this->get_passworded_forums();
            if (isset($forum_ids_passworded[$this->forum_id])) {
                throw new unauthorized_forum_exception($this->forum_id);
            }
            unset($forum_ids_passworded);
        }
        parent::open();
    }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 protected function add_missing_fields(array $row)
 {
     if (!isset($this->keyoptions)) {
         $this->save_keyoptions();
     }
     $options = $row['user_options'];
     $row += array('enable_bbcode' => phpbb_optionget($this->keyoptions['sig_bbcode'], $options), 'enable_smilies' => phpbb_optionget($this->keyoptions['sig_smilies'], $options), 'enable_magic_url' => phpbb_optionget($this->keyoptions['sig_links'], $options));
     return parent::add_missing_fields($row);
 }
Exemplo n.º 3
0
    /**
     * {@inheritdoc}
     */
    public function open()
    {
        $sql = 'SELECT f.forum_options, f.forum_password, t.topic_id, t.forum_id, t.topic_visibility, t.topic_title, t.topic_time, t.topic_views, t.topic_posts_approved, t.topic_type
			FROM ' . TOPICS_TABLE . ' t
			LEFT JOIN ' . FORUMS_TABLE . ' f
				ON (f.forum_id = t.forum_id)
			WHERE t.topic_id = ' . $this->topic_id;
        $result = $this->db->sql_query($sql);
        $this->topic_data = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        if (empty($this->topic_data)) {
            throw new no_topic_exception($this->topic_id);
        }
        $this->forum_id = (int) $this->topic_data['forum_id'];
        // Make sure topic is either approved or user authed
        if ($this->topic_data['topic_visibility'] != ITEM_APPROVED && !$this->auth->acl_get('m_approve', $this->forum_id)) {
            if ($this->user->data['user_id'] != ANONYMOUS) {
                send_status_line(403, 'Forbidden');
            } else {
                send_status_line(401, 'Unauthorized');
            }
            throw new unauthorized_topic_exception($this->topic_id);
        }
        // Make sure forum is not excluded from feed
        if (phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $this->topic_data['forum_options'])) {
            throw new no_feed_exception();
        }
        // Make sure we can read this forum
        if (!$this->auth->acl_get('f_read', $this->forum_id)) {
            if ($this->user->data['user_id'] != ANONYMOUS) {
                send_status_line(403, 'Forbidden');
            } else {
                send_status_line(401, 'Unauthorized');
            }
            throw new unauthorized_forum_exception($this->forum_id);
        }
        // Make sure forum is not passworded or user is authed
        if ($this->topic_data['forum_password']) {
            $forum_ids_passworded = $this->get_passworded_forums();
            if (isset($forum_ids_passworded[$this->forum_id])) {
                if ($this->user->data['user_id'] != ANONYMOUS) {
                    send_status_line(403, 'Forbidden');
                } else {
                    send_status_line(401, 'Unauthorized');
                }
                throw new unauthorized_forum_exception($this->forum_id);
            }
            unset($forum_ids_passworded);
        }
        parent::open();
    }
Exemplo n.º 4
0
    function open()
    {
        $sql = 'SELECT f.forum_options, f.forum_password, t.topic_id, t.forum_id, t.topic_visibility, t.topic_title, t.topic_time, t.topic_views, t.topic_posts_approved, t.topic_type
			FROM ' . TOPICS_TABLE . ' t
			LEFT JOIN ' . FORUMS_TABLE . ' f
				ON (f.forum_id = t.forum_id)
			WHERE t.topic_id = ' . $this->topic_id;
        $result = $this->db->sql_query($sql);
        $this->topic_data = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        if (empty($this->topic_data)) {
            trigger_error('NO_TOPIC');
        }
        $this->forum_id = (int) $this->topic_data['forum_id'];
        // Make sure topic is either approved or user authed
        if ($this->topic_data['topic_visibility'] != ITEM_APPROVED && !$this->auth->acl_get('m_approve', $this->forum_id)) {
            trigger_error('SORRY_AUTH_READ');
        }
        // Make sure forum is not excluded from feed
        if (phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $this->topic_data['forum_options'])) {
            trigger_error('NO_FEED');
        }
        // Make sure we can read this forum
        if (!$this->auth->acl_get('f_read', $this->forum_id)) {
            trigger_error('SORRY_AUTH_READ');
        }
        // Make sure forum is not passworded or user is authed
        if ($this->topic_data['forum_password']) {
            $forum_ids_passworded = $this->get_passworded_forums();
            if (isset($forum_ids_passworded[$this->forum_id])) {
                trigger_error('SORRY_AUTH_READ');
            }
            unset($forum_ids_passworded);
        }
        parent::open();
    }
Exemplo n.º 5
0
 /**
  * Get option bit field from user options in a user row array.
  *
  * Optionget replacement for this module based on $user->optionget.
  *
  * @param array $user_row Row from the users table.
  * @param int $key option key, as defined in $user->keyoptions property.
  * @param int $data bit field value to use, or false to use $user_row['user_options']
  * @return bool true if the option is set in the bit field, false otherwise
  */
 function optionget(&$user_row, $key, $data = false)
 {
     global $user;
     $var = $data !== false ? $data : $user_row['user_options'];
     return phpbb_optionget($user->keyoptions[$key], $var);
 }
 /**
  * Get option bit field from user options.
  *
  * @param int $key option key, as defined in $keyoptions property.
  * @param int $data bit field value to use, or false to use $this->data['user_options']
  * @return bool true if the option is set in the bit field, false otherwise
  */
 function optionget($key, $data = false)
 {
     $var = $data !== false ? $data : $this->data['user_options'];
     return phpbb_optionget($this->keyoptions[$key], $var);
 }
Exemplo n.º 7
0
* @var	int		post_id				Post ID
* @var	array	quickmod_array		Array with quick moderation options data
* @var	int		start				Pagination information
* @var	array	topic_data			Array with topic data
* @var	int		topic_id			Topic ID
* @var	array	topic_tracking_info	Array with topic tracking data
* @var	int		total_posts			Topic total posts count
* @var	string	viewtopic_url		URL to the topic page
* @since 3.1.0-RC4
* @change 3.1.2-RC1 Added viewtopic_url
*/
$vars = array('base_url', 'forum_id', 'post_id', 'quickmod_array', 'start', 'topic_data', 'topic_id', 'topic_tracking_info', 'total_posts', 'viewtopic_url');
extract($phpbb_dispatcher->trigger_event('core.viewtopic_assign_template_vars_before', compact($vars)));
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_posts, $config['posts_per_page'], $start);
// Send vars to template
$template->assign_vars(array('FORUM_ID' => $forum_id, 'FORUM_NAME' => $topic_data['forum_name'], 'FORUM_DESC' => generate_text_for_display($topic_data['forum_desc'], $topic_data['forum_desc_uid'], $topic_data['forum_desc_bitfield'], $topic_data['forum_desc_options']), 'TOPIC_ID' => $topic_id, 'TOPIC_TITLE' => $topic_data['topic_title'], 'TOPIC_POSTER' => $topic_data['topic_poster'], 'TOPIC_AUTHOR_FULL' => get_username_string('full', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), 'TOPIC_AUTHOR' => get_username_string('username', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), 'TOTAL_POSTS' => $user->lang('VIEW_TOPIC_POSTS', (int) $total_posts), 'U_MCP' => $auth->acl_get('m_', $forum_id) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=main&mode=topic_view&f={$forum_id}&t={$topic_id}" . ($start == 0 ? '' : "&start={$start}") . (strlen($u_sort_param) ? "&{$u_sort_param}" : ''), true, $user->session_id) : '', 'MODERATORS' => isset($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id]) ? implode($user->lang['COMMA_SEPARATOR'], $forum_moderators[$forum_id]) : '', 'POST_IMG' => $topic_data['forum_status'] == ITEM_LOCKED ? $user->img('button_topic_locked', 'FORUM_LOCKED') : $user->img('button_topic_new', 'POST_NEW_TOPIC'), 'QUOTE_IMG' => $user->img('icon_post_quote', 'REPLY_WITH_QUOTE'), 'REPLY_IMG' => $topic_data['forum_status'] == ITEM_LOCKED || $topic_data['topic_status'] == ITEM_LOCKED ? $user->img('button_topic_locked', 'TOPIC_LOCKED') : $user->img('button_topic_reply', 'REPLY_TO_TOPIC'), 'EDIT_IMG' => $user->img('icon_post_edit', 'EDIT_POST'), 'DELETE_IMG' => $user->img('icon_post_delete', 'DELETE_POST'), 'DELETED_IMG' => $user->img('icon_topic_deleted', 'POST_DELETED_RESTORE'), 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'), 'PROFILE_IMG' => $user->img('icon_user_profile', 'READ_PROFILE'), 'SEARCH_IMG' => $user->img('icon_user_search', 'SEARCH_USER_POSTS'), 'PM_IMG' => $user->img('icon_contact_pm', 'SEND_PRIVATE_MESSAGE'), 'EMAIL_IMG' => $user->img('icon_contact_email', 'SEND_EMAIL'), 'JABBER_IMG' => $user->img('icon_contact_jabber', 'JABBER'), 'REPORT_IMG' => $user->img('icon_post_report', 'REPORT_POST'), 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), 'WARN_IMG' => $user->img('icon_user_warn', 'WARN_USER'), 'S_IS_LOCKED' => $topic_data['topic_status'] == ITEM_UNLOCKED && $topic_data['forum_status'] == ITEM_UNLOCKED ? false : true, 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_SINGLE_MODERATOR' => !empty($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id]) > 1 ? false : true, 'S_TOPIC_ACTION' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&t={$topic_id}" . ($start == 0 ? '' : "&start={$start}")), 'S_MOD_ACTION' => $s_quickmod_action, 'L_RETURN_TO_FORUM' => $user->lang('RETURN_TO', $topic_data['forum_name']), 'S_VIEWTOPIC' => true, 'S_UNREAD_VIEW' => $view == 'unread', 'S_DISPLAY_SEARCHBOX' => $auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search'] ? true : false, 'S_SEARCHBOX_ACTION' => append_sid("{$phpbb_root_path}search.{$phpEx}"), 'S_SEARCH_LOCAL_HIDDEN_FIELDS' => build_hidden_fields($s_search_hidden_fields), 'S_DISPLAY_POST_INFO' => $topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? true : false, 'S_DISPLAY_REPLY_INFO' => $topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? true : false, 'S_ENABLE_FEEDS_TOPIC' => $config['feed_topic'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $topic_data['forum_options']) ? true : false, 'U_TOPIC' => "{$server_path}viewtopic.{$phpEx}?f={$forum_id}&t={$topic_id}", 'U_FORUM' => $server_path, 'U_VIEW_TOPIC' => $viewtopic_url, 'U_CANONICAL' => generate_board_url() . '/' . append_sid("viewtopic.{$phpEx}", "t={$topic_id}" . ($start ? "&start={$start}" : ''), true, ''), 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $forum_id), 'U_VIEW_OLDER_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&t={$topic_id}&view=previous"), 'U_VIEW_NEWER_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&t={$topic_id}&view=next"), 'U_PRINT_TOPIC' => $auth->acl_get('f_print', $forum_id) ? $viewtopic_url . '&view=print' : '', 'U_EMAIL_TOPIC' => $auth->acl_get('f_email', $forum_id) && $config['email_enable'] ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=email&t={$topic_id}") : '', 'U_WATCH_TOPIC' => $s_watching_topic['link'], 'U_WATCH_TOPIC_TOGGLE' => $s_watching_topic['link_toggle'], 'S_WATCH_TOPIC_TITLE' => $s_watching_topic['title'], 'S_WATCH_TOPIC_TOGGLE' => $s_watching_topic['title_toggle'], 'S_WATCHING_TOPIC' => $s_watching_topic['is_watching'], 'U_BOOKMARK_TOPIC' => $user->data['is_registered'] && $config['allow_bookmarks'] ? $viewtopic_url . '&bookmark=1&hash=' . generate_link_hash("topic_{$topic_id}") : '', 'S_BOOKMARK_TOPIC' => $user->data['is_registered'] && $config['allow_bookmarks'] && $topic_data['bookmarked'] ? $user->lang['BOOKMARK_TOPIC_REMOVE'] : $user->lang['BOOKMARK_TOPIC'], 'S_BOOKMARK_TOGGLE' => !$user->data['is_registered'] || !$config['allow_bookmarks'] || !$topic_data['bookmarked'] ? $user->lang['BOOKMARK_TOPIC_REMOVE'] : $user->lang['BOOKMARK_TOPIC'], 'S_BOOKMARKED_TOPIC' => $user->data['is_registered'] && $config['allow_bookmarks'] && $topic_data['bookmarked'] ? true : false, 'U_POST_NEW_TOPIC' => $auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=post&f={$forum_id}") : '', 'U_POST_REPLY_TOPIC' => $auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=reply&f={$forum_id}&t={$topic_id}") : '', 'U_BUMP_TOPIC' => bump_topic_allowed($forum_id, $topic_data['topic_bumped'], $topic_data['topic_last_post_time'], $topic_data['topic_poster'], $topic_data['topic_last_poster_id']) ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=bump&f={$forum_id}&t={$topic_id}&hash=" . generate_link_hash("topic_{$topic_id}")) : ''));
// Does this topic contain a poll?
if (!empty($topic_data['poll_start'])) {
    $sql = 'SELECT o.*, p.bbcode_bitfield, p.bbcode_uid
		FROM ' . POLL_OPTIONS_TABLE . ' o, ' . POSTS_TABLE . " p\n\t\tWHERE o.topic_id = {$topic_id}\n\t\t\tAND p.post_id = {$topic_data['topic_first_post_id']}\n\t\t\tAND p.topic_id = o.topic_id\n\t\tORDER BY o.poll_option_id";
    $result = $db->sql_query($sql);
    $poll_info = $vote_counts = array();
    while ($row = $db->sql_fetchrow($result)) {
        $poll_info[] = $row;
        $option_id = (int) $row['poll_option_id'];
        $vote_counts[$option_id] = (int) $row['poll_option_total'];
    }
    $db->sql_freeresult($result);
    $cur_voted_id = array();
    if ($user->data['is_registered']) {
        $sql = 'SELECT poll_option_id
Exemplo n.º 8
0
/**
* Create forum navigation links for given forum, create parent
* list if currently null, assign basic forum info to template
*/
function generate_forum_nav(&$forum_data)
{
    global $db, $user, $template, $auth, $config;
    global $phpEx, $phpbb_root_path;
    if (!$auth->acl_get('f_list', $forum_data['forum_id'])) {
        return;
    }
    // Get forum parents
    $forum_parents = get_forum_parents($forum_data);
    // Build navigation links
    if (!empty($forum_parents)) {
        foreach ($forum_parents as $parent_forum_id => $parent_data) {
            list($parent_name, $parent_type) = array_values($parent_data);
            // Skip this parent if the user does not have the permission to view it
            if (!$auth->acl_get('f_list', $parent_forum_id)) {
                continue;
            }
            $template->assign_block_vars('navlinks', array('S_IS_CAT' => $parent_type == FORUM_CAT ? true : false, 'S_IS_LINK' => $parent_type == FORUM_LINK ? true : false, 'S_IS_POST' => $parent_type == FORUM_POST ? true : false, 'FORUM_NAME' => $parent_name, 'FORUM_ID' => $parent_forum_id, 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $parent_forum_id)));
        }
    }
    $template->assign_block_vars('navlinks', array('S_IS_CAT' => $forum_data['forum_type'] == FORUM_CAT ? true : false, 'S_IS_LINK' => $forum_data['forum_type'] == FORUM_LINK ? true : false, 'S_IS_POST' => $forum_data['forum_type'] == FORUM_POST ? true : false, 'FORUM_NAME' => $forum_data['forum_name'], 'FORUM_ID' => $forum_data['forum_id'], 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $forum_data['forum_id'])));
    $template->assign_vars(array('FORUM_ID' => $forum_data['forum_id'], 'FORUM_NAME' => $forum_data['forum_name'], 'FORUM_DESC' => generate_text_for_display($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options']), 'S_ENABLE_FEEDS_FORUM' => $config['feed_forum'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $forum_data['forum_options']) ? true : false));
    return;
}
Exemplo n.º 9
0
 function select_exclude_forums($value, $key)
 {
     global $user, $config;
     $forum_list = make_forum_select(false, false, true, true, true, false, true);
     // Build forum options
     $s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
     foreach ($forum_list as $f_id => $f_row) {
         $f_row['selected'] = phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $f_row['forum_options']);
         $s_forum_options .= '<option value="' . $f_id . '"' . ($f_row['selected'] ? ' selected="selected"' : '') . ($f_row['disabled'] ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>';
     }
     $s_forum_options .= '</select>';
     return $s_forum_options;
 }
Exemplo n.º 10
0
	'S_SELECT_SORT_DIR' 	=> $s_sort_dir,
	'S_SELECT_SORT_KEY' 	=> $s_sort_key,
	'S_SELECT_SORT_DAYS' 	=> $s_limit_days,
	'S_SINGLE_MODERATOR'	=> (!empty($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id]) > 1) ? false : true,
	'S_TOPIC_ACTION' 		=> append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id" . (($start == 0) ? '' : "&amp;start=$start")),
	'S_TOPIC_MOD' 			=> ($topic_mod != '') ? '<select name="action" id="quick-mod-select">' . $topic_mod . '</select>' : '',
	'S_MOD_ACTION' 			=> append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&amp;t=$topic_id" . (($start == 0) ? '' : "&amp;start=$start") . "&amp;quickmod=1&amp;redirect=" . urlencode(str_replace('&amp;', '&', $viewtopic_url)), true, $user->session_id),

	'S_VIEWTOPIC'			=> true,
	'S_DISPLAY_SEARCHBOX'	=> ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false,
	'S_SEARCHBOX_ACTION'	=> append_sid("{$phpbb_root_path}search.$phpEx"),
	'S_SEARCH_LOCAL_HIDDEN_FIELDS'	=> build_hidden_fields($s_search_hidden_fields),

	'S_DISPLAY_POST_INFO'	=> ($topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false,
	'S_DISPLAY_REPLY_INFO'	=> ($topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false,
	'S_ENABLE_FEEDS_TOPIC'	=> ($config['feed_topic'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $topic_data['forum_options'])) ? true : false,

	'U_TOPIC'				=> "{$server_path}viewtopic.$phpEx?f=$forum_id&amp;t=$topic_id",
	'U_FORUM'				=> $server_path,
	'U_VIEW_TOPIC' 			=> $viewtopic_url,
	'U_VIEW_FORUM' 			=> append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
	'U_VIEW_OLDER_TOPIC'	=> append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;view=previous"),
	'U_VIEW_NEWER_TOPIC'	=> append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;view=next"),
	'U_PRINT_TOPIC'			=> ($auth->acl_get('f_print', $forum_id)) ? $viewtopic_url . '&amp;view=print' : '',
	'U_EMAIL_TOPIC'			=> ($auth->acl_get('f_email', $forum_id) && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&amp;t=$topic_id") : '',

	'U_WATCH_TOPIC' 		=> $s_watching_topic['link'],
	'L_WATCH_TOPIC' 		=> $s_watching_topic['title'],
	'S_WATCHING_TOPIC'		=> $s_watching_topic['is_watching'],

	'U_BOOKMARK_TOPIC'		=> ($user->data['is_registered'] && $config['allow_bookmarks']) ? $viewtopic_url . '&amp;bookmark=1&amp;hash=' . generate_link_hash("topic_$topic_id") : '',
Exemplo n.º 11
0
$pagination = generate_pagination(append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&amp;t={$topic_id}" . (strlen($u_sort_param) ? "&amp;{$u_sort_param}" : '') . ($highlight_match ? "&amp;hilit={$highlight}" : '')), $total_posts, $config['posts_per_page'], $start);
// Navigation links
generate_forum_nav($topic_data);
// Forum Rules
generate_forum_rules($topic_data);
// Moderators
$forum_moderators = array();
if ($config['load_moderators']) {
    get_moderators($forum_moderators, $forum_id);
}
// This is only used for print view so ...
$server_path = !$view ? $phpbb_root_path : generate_board_url() . '/';
// Replace naughty words in title
$topic_data['topic_title'] = censor_text($topic_data['topic_title']);
// Send vars to template
$template->assign_vars(array('FORUM_ID' => $forum_id, 'FORUM_NAME' => $topic_data['forum_name'], 'FORUM_DESC' => generate_text_for_display($topic_data['forum_desc'], $topic_data['forum_desc_uid'], $topic_data['forum_desc_bitfield'], $topic_data['forum_desc_options']), 'TOPIC_ID' => $topic_id, 'TOPIC_TITLE' => $topic_data['topic_title'], 'TOPIC_POSTER' => $topic_data['topic_poster'], 'TOPIC_AUTHOR_FULL' => get_username_string('full', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), 'TOPIC_AUTHOR' => get_username_string('username', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), 'PAGINATION' => $pagination, 'PAGE_NUMBER' => on_page($total_posts, $config['posts_per_page'], $start), 'TOTAL_POSTS' => $total_posts == 1 ? $user->lang['VIEW_TOPIC_POST'] : sprintf($user->lang['VIEW_TOPIC_POSTS'], $total_posts), 'U_MCP' => $auth->acl_get('m_', $forum_id) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=main&amp;mode=topic_view&amp;f={$forum_id}&amp;t={$topic_id}&amp;start={$start}" . (strlen($u_sort_param) ? "&amp;{$u_sort_param}" : ''), true, $user->session_id) : '', 'MODERATORS' => isset($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id]) ? implode(', ', $forum_moderators[$forum_id]) : '', 'POST_IMG' => $topic_data['forum_status'] == ITEM_LOCKED ? $user->img('button_topic_locked', 'FORUM_LOCKED') : $user->img('button_topic_new', 'POST_NEW_TOPIC'), 'QUOTE_IMG' => $user->img('icon_post_quote', 'REPLY_WITH_QUOTE'), 'REPLY_IMG' => $topic_data['forum_status'] == ITEM_LOCKED || $topic_data['topic_status'] == ITEM_LOCKED ? $user->img('button_topic_locked', 'TOPIC_LOCKED') : $user->img('button_topic_reply', 'REPLY_TO_TOPIC'), 'EDIT_IMG' => $user->img('icon_post_edit', 'EDIT_POST'), 'DELETE_IMG' => $user->img('icon_post_delete', 'DELETE_POST'), 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'), 'PROFILE_IMG' => $user->img('icon_user_profile', 'READ_PROFILE'), 'SEARCH_IMG' => $user->img('icon_user_search', 'SEARCH_USER_POSTS'), 'PM_IMG' => $user->img('icon_contact_pm', 'SEND_PRIVATE_MESSAGE'), 'EMAIL_IMG' => $user->img('icon_contact_email', 'SEND_EMAIL'), 'WWW_IMG' => $user->img('icon_contact_www', 'VISIT_WEBSITE'), 'ICQ_IMG' => $user->img('icon_contact_icq', 'ICQ'), 'AIM_IMG' => $user->img('icon_contact_aim', 'AIM'), 'MSN_IMG' => $user->img('icon_contact_msnm', 'MSNM'), 'YIM_IMG' => $user->img('icon_contact_yahoo', 'YIM'), 'JABBER_IMG' => $user->img('icon_contact_jabber', 'JABBER'), 'REPORT_IMG' => $user->img('icon_post_report', 'REPORT_POST'), 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), 'WARN_IMG' => $user->img('icon_user_warn', 'WARN_USER'), 'S_IS_LOCKED' => $topic_data['topic_status'] == ITEM_UNLOCKED && $topic_data['forum_status'] == ITEM_UNLOCKED ? false : true, 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_SINGLE_MODERATOR' => !empty($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id]) > 1 ? false : true, 'S_TOPIC_ACTION' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&amp;t={$topic_id}&amp;start={$start}"), 'S_TOPIC_MOD' => $topic_mod != '' ? '<select name="action" id="quick-mod-select">' . $topic_mod . '</select>' : '', 'S_MOD_ACTION' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "f={$forum_id}&amp;t={$topic_id}&amp;start={$start}&amp;quickmod=1&amp;redirect=" . urlencode(str_replace('&amp;', '&', $viewtopic_url)), true, $user->session_id), 'S_VIEWTOPIC' => true, 'S_DISPLAY_SEARCHBOX' => $auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search'] ? true : false, 'S_SEARCHBOX_ACTION' => append_sid("{$phpbb_root_path}search.{$phpEx}", 't=' . $topic_id), 'S_DISPLAY_POST_INFO' => $topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? true : false, 'S_DISPLAY_REPLY_INFO' => $topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? true : false, 'S_ENABLE_FEEDS_TOPIC' => $config['feed_topic'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $topic_data['forum_options']) ? true : false, 'U_TOPIC' => "{$server_path}viewtopic.{$phpEx}?f={$forum_id}&amp;t={$topic_id}", 'U_FORUM' => $server_path, 'U_VIEW_TOPIC' => $viewtopic_url, 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $forum_id), 'U_VIEW_OLDER_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&amp;t={$topic_id}&amp;view=previous"), 'U_VIEW_NEWER_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&amp;t={$topic_id}&amp;view=next"), 'U_PRINT_TOPIC' => $auth->acl_get('f_print', $forum_id) ? $viewtopic_url . '&amp;view=print' : '', 'U_EMAIL_TOPIC' => $auth->acl_get('f_email', $forum_id) && $config['email_enable'] ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=email&amp;t={$topic_id}") : '', 'U_WATCH_TOPIC' => $s_watching_topic['link'], 'L_WATCH_TOPIC' => $s_watching_topic['title'], 'S_WATCHING_TOPIC' => $s_watching_topic['is_watching'], 'U_BOOKMARK_TOPIC' => $user->data['is_registered'] && $config['allow_bookmarks'] ? $viewtopic_url . '&amp;bookmark=1&amp;hash=' . generate_link_hash("topic_{$topic_id}") : '', 'L_BOOKMARK_TOPIC' => $user->data['is_registered'] && $config['allow_bookmarks'] && $topic_data['bookmarked'] ? $user->lang['BOOKMARK_TOPIC_REMOVE'] : $user->lang['BOOKMARK_TOPIC'], 'U_POST_NEW_TOPIC' => $auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=post&amp;f={$forum_id}") : '', 'U_POST_REPLY_TOPIC' => $auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=reply&amp;f={$forum_id}&amp;t={$topic_id}") : '', 'U_BUMP_TOPIC' => bump_topic_allowed($forum_id, $topic_data['topic_bumped'], $topic_data['topic_last_post_time'], $topic_data['topic_poster'], $topic_data['topic_last_poster_id']) ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=bump&amp;f={$forum_id}&amp;t={$topic_id}&amp;hash=" . generate_link_hash("topic_{$topic_id}")) : ''));
// Does this topic contain a poll?
if (!empty($topic_data['poll_start'])) {
    $sql = 'SELECT o.*, p.bbcode_bitfield, p.bbcode_uid
		FROM ' . POLL_OPTIONS_TABLE . ' o, ' . POSTS_TABLE . " p\n\t\tWHERE o.topic_id = {$topic_id}\n\t\t\tAND p.post_id = {$topic_data['topic_first_post_id']}\n\t\t\tAND p.topic_id = o.topic_id\n\t\tORDER BY o.poll_option_id";
    $result = $db->sql_query($sql);
    $poll_info = array();
    while ($row = $db->sql_fetchrow($result)) {
        $poll_info[] = $row;
    }
    $db->sql_freeresult($result);
    $cur_voted_id = array();
    if ($user->data['is_registered']) {
        $sql = 'SELECT poll_option_id
			FROM ' . POLL_VOTES_TABLE . '
			WHERE topic_id = ' . $topic_id . '
Exemplo n.º 12
0
    function open()
    {
        global $auth, $db, $user;
        $sql = 'SELECT f.forum_options, f.forum_password, t.topic_id, t.forum_id, t.topic_approved, t.topic_title, t.topic_time, t.topic_views, t.topic_replies, t.topic_type
			FROM ' . TOPICS_TABLE . ' t
			LEFT JOIN ' . FORUMS_TABLE . ' f
				ON (f.forum_id = t.forum_id)
			WHERE t.topic_id = ' . $this->topic_id;
        $result = $db->sql_query($sql);
        $this->topic_data = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        if (empty($this->topic_data)) {
            trigger_error('NO_TOPIC');
        }
        if ($this->topic_data['topic_type'] == POST_GLOBAL) {
            // We need to find at least one postable forum where feeds are enabled,
            // that the user can read and maybe also has approve permissions.
            $in_fid_ary = $this->get_readable_forums();
            if (empty($in_fid_ary)) {
                // User cannot read any forums
                trigger_error('SORRY_AUTH_READ');
            }
            if (!$this->topic_data['topic_approved']) {
                // Also require m_approve
                $in_fid_ary = array_intersect($in_fid_ary, $this->get_moderator_approve_forums());
                if (empty($in_fid_ary)) {
                    trigger_error('SORRY_AUTH_READ');
                }
            }
            // Diff excluded forums
            $in_fid_ary = array_diff($in_fid_ary, $this->get_excluded_forums());
            if (empty($in_fid_ary)) {
                trigger_error('SORRY_AUTH_READ');
            }
            // Also exclude passworded forums
            $in_fid_ary = array_diff($in_fid_ary, $this->get_passworded_forums());
            if (empty($in_fid_ary)) {
                trigger_error('SORRY_AUTH_READ');
            }
            $sql = 'SELECT forum_id, left_id
				FROM ' . FORUMS_TABLE . '
				WHERE forum_type = ' . FORUM_POST . '
					AND ' . $db->sql_in_set('forum_id', $in_fid_ary) . '
				ORDER BY left_id ASC';
            $result = $db->sql_query_limit($sql, 1);
            $this->forum_data = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if (empty($this->forum_data)) {
                // No forum found.
                trigger_error('SORRY_AUTH_READ');
            }
            unset($in_fid_ary);
        } else {
            $this->forum_id = (int) $this->topic_data['forum_id'];
            // Make sure topic is either approved or user authed
            if (!$this->topic_data['topic_approved'] && !$auth->acl_get('m_approve', $this->forum_id)) {
                trigger_error('SORRY_AUTH_READ');
            }
            // Make sure forum is not excluded from feed
            if (phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $this->topic_data['forum_options'])) {
                trigger_error('NO_FEED');
            }
            // Make sure we can read this forum
            if (!$auth->acl_get('f_read', $this->forum_id)) {
                trigger_error('SORRY_AUTH_READ');
            }
            // Make sure forum is not passworded or user is authed
            if ($this->topic_data['forum_password']) {
                $forum_ids_passworded = $this->get_passworded_forums();
                if (isset($forum_ids_passworded[$this->forum_id])) {
                    trigger_error('SORRY_AUTH_READ');
                }
                unset($forum_ids_passworded);
            }
        }
    }
Exemplo n.º 13
0
/**
* Create forum navigation links for given forum, create parent
* list if currently null, assign basic forum info to template
*/
function generate_forum_nav(&$forum_data)
{
    global $db, $user, $template, $auth, $config;
    global $phpEx, $phpbb_root_path, $phpbb_dispatcher;
    if (!$auth->acl_get('f_list', $forum_data['forum_id'])) {
        return;
    }
    $navlinks = $navlinks_parents = $forum_template_data = array();
    // Get forum parents
    $forum_parents = get_forum_parents($forum_data);
    $microdata_attr = 'data-forum-id';
    // Build navigation links
    if (!empty($forum_parents)) {
        foreach ($forum_parents as $parent_forum_id => $parent_data) {
            list($parent_name, $parent_type) = array_values($parent_data);
            // Skip this parent if the user does not have the permission to view it
            if (!$auth->acl_get('f_list', $parent_forum_id)) {
                continue;
            }
            $navlinks_parents[] = array('S_IS_CAT' => $parent_type == FORUM_CAT ? true : false, 'S_IS_LINK' => $parent_type == FORUM_LINK ? true : false, 'S_IS_POST' => $parent_type == FORUM_POST ? true : false, 'FORUM_NAME' => $parent_name, 'FORUM_ID' => $parent_forum_id, 'MICRODATA' => $microdata_attr . '="' . $parent_forum_id . '"', 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $parent_forum_id));
        }
    }
    $navlinks = array('S_IS_CAT' => $forum_data['forum_type'] == FORUM_CAT ? true : false, 'S_IS_LINK' => $forum_data['forum_type'] == FORUM_LINK ? true : false, 'S_IS_POST' => $forum_data['forum_type'] == FORUM_POST ? true : false, 'FORUM_NAME' => $forum_data['forum_name'], 'FORUM_ID' => $forum_data['forum_id'], 'MICRODATA' => $microdata_attr . '="' . $forum_data['forum_id'] . '"', 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $forum_data['forum_id']));
    $forum_template_data = array('FORUM_ID' => $forum_data['forum_id'], 'FORUM_NAME' => $forum_data['forum_name'], 'FORUM_DESC' => generate_text_for_display($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options']), 'S_ENABLE_FEEDS_FORUM' => $config['feed_forum'] && $forum_data['forum_type'] == FORUM_POST && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $forum_data['forum_options']) ? true : false);
    /**
     * Event to modify the navlinks text
     *
     * @event core.generate_forum_nav
     * @var	array	forum_data				Array with the forum data
     * @var	array	forum_template_data		Array with generic forum template data
     * @var	string	microdata_attr			The microdata attribute
     * @var	array	navlinks_parents		Array with the forum parents navlinks data
     * @var	array	navlinks				Array with the forum navlinks data
     * @since 3.1.5-RC1
     */
    $vars = array('forum_data', 'forum_template_data', 'microdata_attr', 'navlinks_parents', 'navlinks');
    extract($phpbb_dispatcher->trigger_event('core.generate_forum_nav', compact($vars)));
    $template->assign_block_vars_array('navlinks', $navlinks_parents);
    $template->assign_block_vars('navlinks', $navlinks);
    $template->assign_vars($forum_template_data);
    return;
}
Exemplo n.º 14
0
 public function get_bit($bit)
 {
     return phpbb_optionget($bit, $this->_bits);
 }