Exemple #1
0
    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)) {
            trigger_error('NO_FORUM');
        }
        // Forum needs to be postable
        if ($this->forum_data['forum_type'] != FORUM_POST) {
            trigger_error('NO_FEED');
        }
        // Make sure forum is not excluded from feed
        if (src_optionget(FORUM_OPTION_FEED_EXCLUDE, $this->forum_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->forum_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();
    }
Exemple #2
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 (src_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();
    }
Exemple #3
0
 /**
  * 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 src_optionget($this->keyoptions[$key], $var);
 }
Exemple #4
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($src_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("{$src_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("{$src_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("{$src_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'] && !src_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_srcrd_url() . '/' . append_sid("viewtopic.{$phpEx}", "t={$topic_id}" . ($start ? "&start={$start}" : ''), true, ''), 'U_VIEW_FORUM' => append_sid("{$src_root_path}viewforum.{$phpEx}", 'f=' . $forum_id), 'U_VIEW_OLDER_TOPIC' => append_sid("{$src_root_path}viewtopic.{$phpEx}", "f={$forum_id}&t={$topic_id}&view=previous"), 'U_VIEW_NEWER_TOPIC' => append_sid("{$src_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("{$src_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("{$src_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("{$src_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("{$src_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
Exemple #5
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'] = src_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;
 }
Exemple #6
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 src_optionget($user->keyoptions[$key], $var);
 }
Exemple #7
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, $src_root_path, $src_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("{$src_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("{$src_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 && !src_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($src_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;
}