示例#1
0
		if($user->data['upi2db_access'])
		{
			$mark_always_read = mark_always_read($topic_rowset[$i]['topic_type'], $topic_id, $forum_id, 'viewforum', 'icon', $user->data['upi2db_unread'], $start, $topic_link['image']);
		}
		else
		{
			$mark_always_read = '<img src="' . $topic_link['image'] . '" style="margin-right: 4px;" alt="' . $topic_link['image_alt'] . '" title="' . $topic_link['image_alt'] . '" />';
		}
// UPI2DB - END
//----------------------------------------------------

		$views = $topic_rowset[$i]['topic_views'];

		$row_class = (!($i % 2)) ? $theme['td_class1'] : $theme['td_class2'];
		$calendar_title = '';
		$calendar_title = get_calendar_title($topic_rowset[$i]['topic_calendar_time'], $topic_rowset[$i]['topic_calendar_duration']);
		// Convert and clean special chars!
		// We shouldn't need this...
		//$calendar_title = htmlspecialchars_clean($calendar_title);
		if (!empty($calendar_title))
		{
			//$calendar_title = '</a></span>' . $calendar_title . '<span class="topiclink">';
			$calendar_title = '<span class="gensmall">' . $calendar_title . '</span>';
		}
		//$topic_title .= $calendar_title;

		if ($forum_row['auth_rate'] != -1)
		{
			$rating2 = sprintf("%.1f", round(($topic_rowset[$i]['topic_rating']), 0) / 2);
		}
示例#2
0
		}

		//$preview_message = str_replace("\n", '<br />', $preview_message);
		$url = '[url="' . CMS_PAGE_VIEWTOPIC . '?' . (!empty($forum_id_append) ? ($forum_id_append . '&') : '') . (!empty($topic_id_append) ? ($topic_id_append . '&') : '') . POST_POST_URL . '=' . $lock_subject . '#p' . $lock_subject . '"]';
		$extra_message_body = sprintf($lang['Link_to_post'], $url, '[/url]') . $message;
		$preview_message = ($lock_subject) ? ($extra_message_body . $preview_message) : $preview_message;

		$template->set_filenames(array('preview' => 'posting_preview.tpl'));
		if (!empty($topic_calendar_time))
		{
			$topic_calendar_duration_preview = $topic_calendar_duration - 1;
			if ($topic_calendar_duration_preview < 0)
			{
				$topic_calendar_duration_preview = 0;
			}
			$preview_subject .= get_calendar_title($topic_calendar_time, $topic_calendar_duration_preview);
		}
		$attachment_mod['posting']->preview_attachments();

		if (($mode == 'newtopic') || (($mode == 'editpost') && $post_data['first_post']))
		{
			$template->assign_var('S_POSTING_TOPIC', true);
		}

		//$preview_subject = strtr($preview_subject, array_flip(get_html_translation_table(HTML_ENTITIES)));
		$template->assign_vars(array(
			'TOPIC_TITLE' => $preview_subject,
			'POSTER_NAME' => $preview_username,
			'POST_DATE' => create_date_ip($config['default_dateformat'], time(), $config['board_timezone']),
			'USER_SIG' => ($attach_sig) ? $user_sig : '',
示例#3
0
function topic_list($box, $tpl = '', $topic_rowset, $list_title = '', $split_type = false, $display_nav_tree = true, $footer = '', $inbox = true, $select_field = '', $select_type = 0, $select_formname = '', $select_values = array())
{
    global $db, $template, $board_config, $userdata, $lang, $images, $tree, $CPG_SESS, $module_name;
    static $box_id;
    // save template state
    $sav_tpl = $template->_tpldata;
    // init
    if (empty($tpl)) {
        $tpl = 'topics_list_box';
    }
    if (empty($list_title)) {
        $list_title = $lang['Topics'];
    }
    if (!empty($select_values) && !is_array($select_values)) {
        $s_values = $select_values;
        $select_values = array();
        $select_values[] = $s_values;
    }
    // selections
    $select_multi = false;
    $select_unique = false;
    if (!empty($select_field) && $select_type > 0 && !empty($select_formname)) {
        switch ($select_type) {
            case 1:
                $select_multi = true;
                break;
            case 2:
                $select_unique = true;
                break;
        }
    }
    // get split params
    $switch_split_global_announce = isset($board_config['split_global_announce']) && isset($lang['Post_Global_Announcement']) ? intval($board_config['split_global_announce']) : false;
    $switch_split_announce = isset($board_config['split_announce']) ? intval($board_config['split_announce']) : false;
    $switch_split_sticky = isset($board_config['split_sticky']) ? intval($board_config['split_sticky']) : false;
    // set in separate table
    $split_box = $inbox && (isset($board_config['split_topic_split']) ? intval($board_config['split_topic_split']) : false);
    // take care of the context
    if (!$split_type) {
        $split_box = false;
        $switch_split_global_announce = false;
        $switch_split_announce = false;
        $switch_split_sticky = false;
    }
    if (!$switch_split_global_announce && !$switch_split_announce && !$switch_split_sticky) {
        $split_type = false;
        $split_box = false;
    }
    // Define censored word matches
    $orig_word = array();
    $replacement_word = array();
    obtain_word_list($orig_word, $replacement_word);
    // read the user cookie
    $tracking_topics = isset($CPG_SESS[$module_name]['track_topics']) ? $CPG_SESS[$module_name]['track_topics'] : array();
    $tracking_forums = isset($CPG_SESS[$module_name]['track_forums']) ? $CPG_SESS[$module_name]['track_forums'] : array();
    $tracking_all = isset($CPG_SESS[$module_name]['track_all']) ? $CPG_SESS[$module_name]['track_all'] : NULL;
    // categories hierarchy v 2 compliancy
    $cat_hierarchy = function_exists(get_auth_keys);
    if (!$cat_hierarchy) {
        // standard read
        $is_auth = array();
        $is_auth = auth(AUTH_ALL, AUTH_LIST_ALL, $userdata);
    }
    // topic icon present
    $icon_installed = function_exists(get_icon_title);
    // get a default title
    if (empty($list_title)) {
        $list_title = $lang['forum'];
    }
    // choose template
    $template->set_filenames(array($tpl => 'forums/' . $tpl . '.html'));
    // check if user replied to the topics
    $user_topics = array();
    if ($userdata['user_id'] != ANONYMOUS) {
        // get all the topic ids to display
        $topic_ids = array();
        for ($i = 0; $i < count($topic_rowset); $i++) {
            $topic_item_type = substr($topic_rowset[$i]['topic_id'], 0, 1);
            $topic_id = intval(substr($topic_rowset[$i]['topic_id'], 1));
            if ($topic_item_type == POST_TOPIC_URL) {
                $topic_ids[] = $topic_id;
            }
        }
        // check if the user replied to
        if (!empty($topic_ids)) {
            // check the posts
            $s_topic_ids = implode(', ', $topic_ids);
            $sql = "SELECT DISTINCT topic_id FROM " . POSTS_TABLE . " \n\t\t\t\t\tWHERE topic_id IN ({$s_topic_ids})\n\t\t\t\t\t\tAND poster_id = " . $userdata['user_id'];
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                $user_topics[POST_TOPIC_URL . $row['topic_id']] = true;
            }
        }
    }
    // initiate
    $template->assign_block_vars($tpl, array('FORMNAME' => $select_formname, 'FIELDNAME' => $select_field));
    // spanning of the first column (list name)
    $span_left = 1;
    if (count($topic_rowset) > 0) {
        // add folder image
        $span_left++;
    }
    if ($icon_installed) {
        // add topic icon
        $span_left++;
    }
    if ($select_unique) {
        // selection in front is asked
        $span_left++;
    }
    // spanning of the whole line (bottom row and/or empty list)
    $span_all = $span_left + 4;
    if ($select_multi && count($topic_rowset) > 0) {
        $span_all++;
    }
    // display topics
    $color = false;
    $prec_topic_type = '';
    $header_sent = false;
    if (!isset($box_id)) {
        $box_id = -1;
    }
    for ($i = 0; $i < count($topic_rowset); $i++) {
        $topic_item_type = substr($topic_rowset[$i]['topic_id'], 0, 1);
        $topic_id = intval(substr($topic_rowset[$i]['topic_id'], 1));
        $topic_title = count($orig_word) ? preg_replace($orig_word, $replacement_word, $topic_rowset[$i]['topic_title']) : $topic_rowset[$i]['topic_title'];
        $replies = $topic_rowset[$i]['topic_replies'];
        $topic_type = $topic_rowset[$i]['topic_type'];
        $user_replied = !empty($user_topics) && isset($user_topics[$topic_rowset[$i]['topic_id']]);
        $force_type_display = false;
        $forum_id = $topic_rowset[$i]['forum_id'];
        if (defined('POST_BIRTHDAY') && $topic_type == POST_BIRTHDAY) {
            $topic_type = $lang['Birthday'] . ': ';
        } else {
            if ($topic_type == POST_GLOBAL_ANNOUNCE) {
                $topic_type = $lang['Topic_Global_Announcement'] . ' ';
            } else {
                if ($topic_type == POST_ANNOUNCE) {
                    $topic_type = $lang['Topic_Announcement'] . ' ';
                } else {
                    if ($topic_type == POST_STICKY) {
                        $topic_type = $lang['Topic_Sticky'] . ' ';
                    } else {
                        $topic_type = '';
                    }
                }
            }
        }
        if ($topic_rowset[$i]['topic_vote']) {
            $topic_type .= $lang['Topic_Poll'] . ' ';
            $force_type_display = true;
        }
        if (defined('POST_BIRTHDAY') && $topic_rowset[$i]['topic_type'] == POST_BIRTHDAY) {
            $folder_image = $images['folder_birthday'];
            $folder_alt = $lang['Happy_birthday'];
            $newest_post_img = '';
        } else {
            if ($topic_rowset[$i]['topic_status'] == TOPIC_MOVED) {
                $topic_type = $lang['Topic_Moved'] . ' ';
                $topic_id = $topic_rowset[$i]['topic_moved_id'];
                $folder_image = $images['folder'];
                $folder_alt = $lang['Topics_Moved'];
                $newest_post_img = '';
                $force_type_display = true;
            } else {
                if (defined('POST_BIRTHDAY') && $topic_rowset[$i]['topic_type'] == POST_BIRTHDAY) {
                    $folder = $images['folder_birthday'];
                    $folder_new = $images['folder_birthday'];
                } else {
                    if ($topic_rowset[$i]['topic_type'] == POST_GLOBAL_ANNOUNCE) {
                        $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['folder_global_announce_own'] : $images['folder_global_announce'];
                        $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['folder_global_announce_new_own'] : $images['folder_global_announce_new'];
                    } else {
                        if ($topic_rowset[$i]['topic_type'] == POST_ANNOUNCE) {
                            $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['folder_announce_own'] : $images['folder_announce'];
                            $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['folder_announce_new_own'] : $images['folder_announce_new'];
                        } else {
                            if ($topic_rowset[$i]['topic_type'] == POST_STICKY) {
                                $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['folder_sticky_own'] : $images['folder_sticky'];
                                $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['folder_sticky_new_own'] : $images['folder_sticky_new'];
                            } else {
                                if ($topic_rowset[$i]['topic_status'] == TOPIC_LOCKED) {
                                    $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['folder_locked_own'] : $images['folder_locked'];
                                    $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['folder_locked_new_own'] : $images['folder_locked_new'];
                                } else {
                                    if ($replies >= $board_config['hot_threshold']) {
                                        $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['folder_hot_own'] : $images['folder_hot'];
                                        $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['folder_hot_new_own'] : $images['folder_hot_new'];
                                    } else {
                                        $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['folder_own'] : $images['folder'];
                                        $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['folder_new_own'] : $images['folder_new'];
                                    }
                                }
                            }
                        }
                    }
                }
                $newest_post_img = '';
                if (is_user() && $topic_item_type == POST_TOPIC_URL) {
                    if ($topic_rowset[$i]['post_time'] > $userdata['user_lastvisit']) {
                        if (!empty($tracking_topics) || !empty($tracking_forums) || !empty($tracking_all)) {
                            $unread_topics = true;
                            if (!empty($tracking_topics[$topic_id])) {
                                if ($tracking_topics[$topic_id] >= $topic_rowset[$i]['post_time']) {
                                    $unread_topics = false;
                                }
                            }
                            if (!empty($tracking_forums[$forum_id])) {
                                if ($tracking_forums[$forum_id] >= $topic_rowset[$i]['post_time']) {
                                    $unread_topics = false;
                                }
                            }
                            if (!empty($tracking_all)) {
                                if ($tracking_all >= $topic_rowset[$i]['post_time']) {
                                    $unread_topics = false;
                                }
                            }
                            if ($unread_topics) {
                                $folder_image = $folder_new;
                                $folder_alt = $lang['New_posts'];
                                $newest_post_img = '<a href="' . URL::index("&amp;file=viewtopic&amp;" . POST_TOPIC_URL . "={$topic_id}&amp;view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" /></a> ';
                            } else {
                                $folder_image = $folder;
                                $folder_alt = $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ? $lang['Topic_locked'] : $lang['No_new_posts'];
                                $newest_post_img = '';
                            }
                        } else {
                            $folder_image = $folder_new;
                            $folder_alt = $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ? $lang['Topic_locked'] : $lang['New_posts'];
                            $newest_post_img = '<a href="' . URL::index("&amp;file=viewtopic&amp;" . POST_TOPIC_URL . "={$topic_id}&amp;view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" /></a> ';
                        }
                    } else {
                        $folder_image = $folder;
                        $folder_alt = $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ? $lang['Topic_locked'] : $lang['No_new_posts'];
                        $newest_post_img = '';
                    }
                } else {
                    $folder_image = $folder;
                    $folder_alt = $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ? $lang['Topic_locked'] : $lang['No_new_posts'];
                    $newest_post_img = '';
                }
            }
        }
        // generate list of page for the topic
        $goto_page = '';
        if ($replies + 1 > $board_config['posts_per_page']) {
            $total_pages = ceil(($replies + 1) / $board_config['posts_per_page']);
            $goto_page = ' [ <img src="' . $images['icon_gotopost'] . '" alt="' . $lang['Goto_page'] . '" title="' . $lang['Goto_page'] . '" />' . $lang['Goto_page'] . ': ';
            $times = 1;
            for ($j = 0; $j < $replies + 1; $j += $board_config['posts_per_page']) {
                $goto_page .= '<a href="' . URL::index("&amp;file=viewtopic&amp;" . POST_TOPIC_URL . "=" . $topic_id . "&amp;start={$j}") . '">' . $times . '</a>';
                if ($times == 1 && $total_pages > 4) {
                    $goto_page .= ' ... ';
                    $times = $total_pages - 3;
                    $j += ($total_pages - 4) * $board_config['posts_per_page'];
                } else {
                    if ($times < $total_pages) {
                        $goto_page .= ', ';
                    }
                }
                $times++;
            }
            $goto_page .= ' ] ';
        }
        $topic_author = '';
        $first_post_time = '';
        $last_post_time = '';
        $last_post_url = '';
        $views = '';
        switch ($topic_item_type) {
            case POST_USERS_URL:
                $view_topic_url = URL::index("&amp;file=profile&amp;" . POST_USERS_URL . "={$topic_id}");
                break;
            default:
                $view_topic_url = URL::index("&amp;file=viewtopic&amp;" . POST_TOPIC_URL . "={$topic_id}");
                $topic_author = $topic_rowset[$i]['user_id'] != ANONYMOUS ? '<a href="' . URL::index("Your_Account&amp;profile=" . $topic_rowset[$i]['user_id']) . '">' : '';
                $topic_author .= $topic_rowset[$i]['user_id'] != ANONYMOUS ? $topic_rowset[$i]['username'] : ($topic_rowset[$i]['post_username'] != '' ? $topic_rowset[$i]['post_username'] : $lang['Guest']);
                $topic_author .= $topic_rowset[$i]['user_id'] != ANONYMOUS ? '</a>' : '';
                $first_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['topic_time']);
                $last_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['post_time']);
                $last_post_author = $topic_rowset[$i]['id2'] == ANONYMOUS ? $topic_rowset[$i]['post_username2'] != '' ? $topic_rowset[$i]['post_username2'] . ' ' : $lang['Guest'] . ' ' : '<a href="' . URL::index("Your_Account&amp;profile=" . $topic_rowset[$i]['id2']) . '">' . $topic_rowset[$i]['user2'] . '</a>';
                $last_post_url = '<a href="' . URL::index("&amp;file=viewtopic&amp;" . POST_POST_URL . '=' . $topic_rowset[$i]['topic_last_post_id']) . '#' . $topic_rowset[$i]['topic_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>';
                $views = $topic_rowset[$i]['topic_views'];
                break;
        }
        // categories hierarchy v 2 compliancy
        $nav_tree = '';
        if ($display_nav_tree && !empty($topic_rowset[$i]['forum_id'])) {
            if ($cat_hierarchy) {
                if ($tree['auth'][POST_FORUM_URL . $topic_rowset[$i]['forum_id']]['tree.auth_view']) {
                    $nav_tree = make_cat_nav_tree(POST_FORUM_URL . $topic_rowset[$i]['forum_id'], '', 'gensmall');
                }
            } else {
                if ($is_auth[$topic_rowset[$i]['forum_id']]['auth_view']) {
                    $nav_tree = '<a href="' . URL::index("&amp;file=viewforum&amp;f=" . $topic_rowset[$i]['forum_id']) . '" class="gensmall">' . $topic_rowset[$i]['forum_name'] . '</a>';
                }
            }
        }
        if (!empty($nav_tree)) {
            $nav_tree = '[ ' . $nav_tree . ' ]';
        }
        // get the type for rupture
        $topic_real_type = $topic_rowset[$i]['topic_type'];
        // if no split between global and standard announcement, group them with standard announcement
        if (!$switch_split_global_announce && $topic_real_type == POST_GLOBAL_ANNOUNCE) {
            $topic_real_type = POST_ANNOUNCE;
        }
        // if no split between announce and sticky, group them with sticky
        if (!$switch_split_announce && $topic_real_type == POST_ANNOUNCE) {
            $topic_real_type = POST_STICKY;
        }
        // if no split between sticky and normal, group them with normal
        if (!$switch_split_sticky && $topic_real_type == POST_STICKY) {
            $topic_real_type = POST_NORMAL;
        }
        // check if rupture
        $rupt = false;
        // split
        if ($i == 0 || $split_type) {
            if ($i == 0) {
                $rupt = true;
            }
            // check the rupt
            if ($prec_topic_type != $topic_real_type) {
                $rupt = true;
            }
        }
        $prec_topic_type = $topic_real_type;
        // header
        if ($rupt) {
            // close the prec box
            if ($split_box && $i != 0) {
                // footer
                $template->assign_block_vars($tpl . '.row', array('COLSPAN' => $span_all));
                // table closure
                $template->assign_block_vars($tpl . '.row.footer_table', array());
                // spacing
                $template->assign_block_vars($tpl . '.row', array());
                $template->assign_block_vars($tpl . '.row.spacer', array());
                // unset header
                $header_sent = false;
            }
            // get box title
            $main_title = $list_title;
            $sub_title = $list_title;
            switch ($topic_real_type) {
                case POST_BIRTHDAY:
                    $sub_title = $lang['Birthday'];
                    break;
                case POST_GLOBAL_ANNOUNCE:
                    $sub_title = $lang['Post_Global_Announcement'];
                    break;
                case POST_ANNOUNCE:
                    $sub_title = $lang['Post_Announcement'];
                    break;
                case POST_STICKY:
                    $sub_title = $lang['Post_Sticky'];
                    break;
                case POST_CALENDAR:
                    $sub_title = $lang['Calendar_event'];
                    break;
                case POST_NORMAL:
                    $sub_title = $lang['Topics'];
                    break;
            }
            $template->assign_block_vars($tpl . '.row', array('L_TITLE' => !$split_box ? $main_title : $sub_title, 'L_REPLIES' => $lang['Replies'], 'L_AUTHOR' => $lang['Author'], 'L_VIEWS' => $lang['Views'], 'L_LASTPOST' => $lang['Last_Post'], 'COLSPAN' => $span_all));
            // open a new box
            if ($split_box || $i == 0) {
                $box_id++;
                $template->assign_block_vars($tpl . '.row.header_table', array('COLSPAN' => $span_left, 'BOX_ID' => $box_id));
                // selection fields
                if ($select_multi) {
                    $template->assign_block_vars($tpl . '.row.header_table.multi_selection', array());
                }
                // set header
                $header_sent = true;
            }
            // not in box, send a row title
            if ($split_type && !$split_box) {
                $template->assign_block_vars($tpl . '.row', array('L_TITLE' => $sub_title, 'COLSPAN' => $span_all));
                $template->assign_block_vars($tpl . '.row.header_row', array());
            }
        }
        // erase the type before the title if split
        if ($split_type && $topic_real_type == $topic_rowset[$i]['topic_type'] && !$force_type_display) {
            $topic_type = '';
        }
        // get the announces dates
        $topic_announces_dates = '';
        if (function_exists(get_announces_title) && in_array($topic_rowset[$i]['topic_type'], array(POST_ANNOUNCE, POST_GLOBAL_ANNOUNCE))) {
            $topic_announces_dates = get_announces_title($topic_rowset[$i]['topic_time'], $topic_rowset[$i]['topic_announce_duration']);
        }
        // get the calendar dates
        $topic_calendar_dates = '';
        if (function_exists(get_calendar_title)) {
            $topic_calendar_dates = get_calendar_title($topic_rowset[$i]['topic_calendar_time'], $topic_rowset[$i]['topic_calendar_duration']);
        }
        // get the topic icons
        $icon = '';
        if ($icon_installed) {
            $type = $topic_rowset[$i]['topic_type'];
            if ($type == POST_NORMAL) {
                if (defined('POST_CALENDAR') && !empty($topic_rowset[$i]['topic_calendar_time'])) {
                    $type = POST_CALENDAR;
                }
                if (defined('POST_PICTURE') && !empty($topic_rowset[$i]['topic_pic_url'])) {
                    $type = POST_PICTURE;
                }
            }
            $icon = get_icon_title($topic_rowset[$i]['topic_icon'], 1, $type);
        }
        // send topic to template
        $selected = !empty($select_values) && in_array($topic_rowset[$i]['topic_id'], $select_values);
        $color = !$color;
        $template->assign_block_vars($tpl . '.row', array('ROW_CLASS' => $color || !defined('TOPIC_ALTERNATE_ROW_CLASS') ? 'row1' : 'row2', 'ROW_FOLDER_CLASS' => $user_replied && defined('USER_REPLIED_CLASS') ? USER_REPLIED_CLASS : ($color || !defined('TOPIC_ALTERNATE_ROW_CLASS') ? 'row1' : 'row2'), 'FORUM_ID' => $forum_id, 'TOPIC_ID' => $topic_id, 'TOPIC_FOLDER_IMG' => $folder_image, 'TOPIC_AUTHOR' => $topic_author, 'GOTO_PAGE' => !empty($goto_page) ? '<br />' . $goto_page : '', 'TOPIC_NAV_TREE' => !empty($nav_tree) ? (empty($goto_page) ? '<br />' : '') . $nav_tree : '', 'REPLIES' => $replies, 'NEWEST_POST_IMG' => $newest_post_img, 'ICON' => $icon, 'TOPIC_TITLE' => $topic_title, 'TOPIC_ANNOUNCES_DATES' => $topic_announces_dates, 'TOPIC_CALENDAR_DATES' => $topic_calendar_dates, 'TOPIC_TYPE' => $topic_type, 'VIEWS' => $views, 'FIRST_POST_TIME' => $first_post_time, 'LAST_POST_TIME' => $last_post_time, 'LAST_POST_AUTHOR' => $last_post_author, 'LAST_POST_IMG' => $last_post_url, 'L_TOPIC_FOLDER_ALT' => $folder_alt, 'U_VIEW_TOPIC' => $view_topic_url, 'BOX_ID' => $box_id, 'FID' => $topic_rowset[$i]['topic_id'], 'L_SELECT' => $selected && ($select_multi || $select_unique) ? 'checked="checked"' : ''));
        $template->assign_block_vars($tpl . '.row.topic', array());
        // selection fields
        if ($select_multi) {
            $template->assign_block_vars($tpl . '.row.topic.multi_selection', array());
        }
        if ($select_unique) {
            $template->assign_block_vars($tpl . '.row.topic.single_selection', array());
        }
        // icons
        if ($icon_installed) {
            $template->assign_block_vars($tpl . '.row.topic.icon', array());
        }
        // nav tree asked
        if ($display_nav_tree && !empty($nav_tree)) {
            $template->assign_block_vars($tpl . '.row.topic.nav_tree', array());
        }
    }
    // end for topic_rowset read
    // send an header if missing
    if (!$header_sent) {
        $template->assign_block_vars($tpl . '.row', array('L_TITLE' => $list_title, 'L_REPLIES' => $lang['Replies'], 'L_AUTHOR' => $lang['Author'], 'L_VIEWS' => $lang['Views'], 'L_LASTPOST' => $lang['Last_Post'], 'COLSPAN' => $span_all));
        // open a new box
        $template->assign_block_vars($tpl . '.row.header_table', array('COLSPAN' => $span_left));
    }
    // no data
    if (count($topic_rowset) == 0) {
        // send no topics notice
        $template->assign_block_vars($tpl . '.row', array('L_NO_TOPICS' => $lang['No_search_match'], 'COLSPAN' => $span_all));
        $template->assign_block_vars($tpl . '.row.no_topics', array());
    }
    // bottom line
    if (!empty($footer)) {
        $template->assign_block_vars($tpl . '.row', array('COLSPAN' => $span_all, 'FOOTER' => $footer));
        $template->assign_block_vars($tpl . '.row.bottom', array());
    }
    // table closure
    $template->assign_block_vars($tpl . '.row', array('COLSPAN' => $span_all));
    $template->assign_block_vars($tpl . '.row.footer_table', array());
    // spacing
    if (empty($footer)) {
        // spacing
        $template->assign_block_vars($tpl . '.row', array());
        $template->assign_block_vars($tpl . '.row.spacer', array());
    }
    // transfert to a var
    $template->assign_var_from_handle('_box', $tpl);
    $res = $template->_tpldata['.'][0]['_box'];
    // restore template saved state
    $template->_tpldata = $sav_tpl;
    // assign value to the main template
    $template->assign_vars(array($box => $res));
}
示例#4
0
							$mini_post_alt = $lang['New_post'];
						}
						else
						{
							$mini_post_img = $images['icon_minipost'];
							$mini_post_alt = $lang['Post'];
						}
					}
					else
					{
						$mini_post_img = $images['icon_minipost'];
						$mini_post_alt = $lang['Post'];
					}
					if (!empty($searchset[$i]['topic_calendar_time']) && ($searchset[$i]['post_id'] == $searchset[$i]['topic_first_post_id']))
					{
						$post_subject .= '</a></b>' . get_calendar_title($searchset[$i]['topic_calendar_time'], $searchset[$i]['topic_calendar_duration']);
					}
// UPI2DB - BEGIN
					$folder_image = $images['topic_nor_read'];
					$folder_alt = ($searchset[$i]['topic_status'] == TOPIC_LOCKED) ? $lang['Topic_locked'] : $lang['No_new_posts'];
				}
				else
				{
					search_calc_unread_ip($user->data['upi2db_unread'], $topic_id, $searchset, $i, $mini_post_img, $mini_post_alt, $unread_color, $folder_image, $folder_alt);
				}
				$mark_topic_unread_array['unmark_post'] = 0;
				if($user->data['upi2db_access'])
				{
					if($s2 == 'mark')
					{
						$post_id = $searchset[$i]['post_id'];
示例#5
0
function topic_review($forum_id, $topic_id, $is_inline_review)
{
    global $db, $config, $auth, $user, $lang, $template, $images, $theme, $bbcode, $tree;
    global $user_ip, $starttime, $gen_simple_header;
    if (!$is_inline_review) {
        if (!isset($topic_id) || !$topic_id) {
            if (!defined('STATUS_404')) {
                define('STATUS_404', true);
            }
            message_die(GENERAL_MESSAGE, 'NO_TOPIC');
        }
        // Get topic info ...
        $sql = "SELECT t.topic_title, t.topic_calendar_time, t.topic_calendar_duration, t.topic_first_post_id, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments\n\t\t\tFROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f\n\t\t\tWHERE t.topic_id = {$topic_id}\n\t\t\t\tAND f.forum_id = t.forum_id";
        $tmp = '';
        attach_setup_viewtopic_auth($tmp, $sql);
        $result = $db->sql_query($sql);
        if (!($forum_row = $db->sql_fetchrow($result))) {
            if (!defined('STATUS_404')) {
                define('STATUS_404', true);
            }
            message_die(GENERAL_MESSAGE, 'NO_TOPIC');
        }
        $db->sql_freeresult($result);
        $forum_id = $forum_row['forum_id'];
        $topic_title = $forum_row['topic_title'];
        $topic_calendar_time = intval($forum_row['topic_calendar_time']);
        $topic_first_post_id = intval($forum_row['topic_first_post_id']);
        $topic_calendar_duration = intval($forum_row['topic_calendar_duration']);
        // Start session management
        $user->session_begin();
        $auth->acl($user->data);
        $user->setup();
        // End session management
        $is_auth = array();
        $is_auth = auth(AUTH_ALL, $forum_id, $user->data, $forum_row);
        if (!$is_auth['auth_read']) {
            message_die(GENERAL_MESSAGE, sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']));
        }
        $gen_simple_header = true;
        $meta_content['page_title'] = $lang['Topic_review'] . ' - ' . $topic_title;
        $meta_content['description'] = '';
        $meta_content['keywords'] = '';
        page_header($meta_content['page_title'], true);
        $template->set_filenames(array('reviewbody' => 'posting_topic_review.tpl'));
    }
    // Go ahead and pull all data for this topic
    $sql = "SELECT u.username, u.user_id, p.*\n\t\tFROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u\n\t\tWHERE p.topic_id = {$topic_id}\n\t\t\tAND p.poster_id = u.user_id\n\t\tORDER BY p.post_time DESC\n\t\tLIMIT " . $config['posts_per_page'];
    $result = $db->sql_query($sql);
    if (!empty($is_auth)) {
        init_display_review_attachments($is_auth);
    }
    // Okay, let's do the loop, yeah come on baby let's do the loop and it goes like this ...
    if ($row = $db->sql_fetchrow($result)) {
        //Begin Lo-Fi Mod
        global $lofi;
        //End Lo-Fi Mod
        $mini_post_img = $images['icon_minipost'];
        $mini_post_alt = $lang['Post'];
        $i = 0;
        do {
            $poster_id = $row['user_id'];
            $poster = $row['username'];
            $post_date = create_date($config['default_dateformat'], $row['post_time'], $config['board_timezone']);
            // Handle anon users posting with usernames
            if ($poster_id == ANONYMOUS && $row['post_username'] != '') {
                $poster = $row['post_username'];
                $poster_rank = $lang['Guest'];
            } elseif ($poster_id == ANONYMOUS) {
                $poster = $lang['Guest'];
                $poster_rank = '';
            }
            $post_subject = $row['post_subject'] != '' ? $row['post_subject'] : '';
            $message = $row['post_text'];
            // Quick Quote - BEGIN
            $look_up_array = array('\\"', '"', "<", ">", "\n", chr(13));
            $replacement_array = array('&q_mg;', '\\"', "&lt_mg;", "&gt_mg;", "\\n", "");
            $plain_message = $row['post_text'];
            $plain_message = strtr($plain_message, array_flip(get_html_translation_table(HTML_ENTITIES)));
            //Hide MOD
            if (preg_match('/\\[hide/i', $plain_message)) {
                $search = array("/\\[hide\\](.*?)\\[\\/hide\\]/");
                $replace = array('[hide]' . $lang['xs_bbc_hide_quote_message'] . '[/hide]');
                $plain_message = preg_replace($search, $replace, $plain_message);
            }
            //Hide MOD
            $plain_message = censor_text($plain_message);
            $plain_message = str_replace($look_up_array, $replacement_array, $plain_message);
            // Quick Quote - END
            $post_subject = censor_text($post_subject);
            $message = censor_text($message);
            $bbcode->allow_html = $config['allow_html'] && $row['enable_bbcode'] ? true : false;
            $bbcode->allow_bbcode = $config['allow_bbcode'] && $row['enable_bbcode'] ? true : false;
            $bbcode->allow_smilies = $config['allow_smilies'] && $row['enable_smilies'] ? true : false;
            $message = $bbcode->parse($message);
            if ($row['enable_autolinks_acronyms']) {
                $message = $bbcode->acronym_pass($message);
                $message = $bbcode->autolink_text($message, $forum_id);
            }
            //$message = kb_word_wrap_pass ($message);
            if (!empty($topic_calendar_time) && $topic_first_post_id == $row['post_id']) {
                $post_subject .= get_calendar_title($topic_calendar_time, $topic_calendar_duration);
            }
            // Again this will be handled by the templating code at some point
            $row_class = !($i % 2) ? $theme['td_class1'] : $theme['td_class2'];
            // Strip iframe from $message... we need this to avoid the topic review "iframe" being broken from BBCodes like YouTube
            $strip_array = array('@<iframe[^>]*?>.*?</iframe>@si');
            $message = preg_replace($strip_array, '', $message);
            $template->assign_block_vars('postrow', array('ROW_CLASS' => $row_class, 'MINI_POST_IMG' => $mini_post_img, 'POSTER_NAME' => $poster, 'POST_DATE' => $post_date, 'POST_SUBJECT' => $post_subject, 'MESSAGE' => $message, 'U_POST_ID' => $row['post_id'], 'PLAIN_MESSAGE' => $plain_message, 'L_MINI_POST_ALT' => $mini_post_alt));
            if (!empty($is_auth)) {
                display_review_attachments($row['post_id'], $row['post_attachment'], $is_auth);
            }
            $i++;
        } while ($row = $db->sql_fetchrow($result));
    } else {
        if (!defined('STATUS_404')) {
            define('STATUS_404', true);
        }
        message_die(GENERAL_MESSAGE, 'NO_TOPIC', '', __LINE__, __FILE__, $sql);
    }
    $db->sql_freeresult($result);
    $template->assign_vars(array('L_AUTHOR' => $lang['Author'], 'L_MESSAGE' => $lang['Message'], 'L_POSTED' => $lang['Posted'], 'L_POST_SUBJECT' => $lang['Post_subject'], 'IMG_QUICK_QUOTE' => $images['icon_quote'], 'IMG_OFFTOPIC' => $images['icon_offtopic'], 'L_QUICK_QUOTE' => $lang['QuickQuote'], 'L_OFFTOPIC' => $lang['OffTopic'], 'L_TOPIC_REVIEW' => $lang['Topic_review']));
    if (!$is_inline_review) {
        $template->pparse('reviewbody');
        page_footer(true, '', true);
    }
}
function topic_list($box, $tpl = '', $topic_rowset, $list_title = '', $split_type = false, $display_nav_tree = true, $footer = '', $inbox = true, $select_field = '', $select_type = 0, $select_formname = '', $select_values = array())
{
    global $template, $db, $cache, $config, $user, $lang, $images, $theme;
    global $tree, $bbcode, $user;
    static $box_id;
    // save template state
    $sav_tpl = $template->_tpldata;
    // init
    if (empty($tpl)) {
        $tpl = 'topics_list_box';
    }
    if (empty($list_title)) {
        $list_title = $lang['Topics'];
    }
    if (!empty($select_values) && !is_array($select_values)) {
        $s_values = $select_values;
        $select_values = array();
        $select_values[] = $s_values;
    }
    // selections
    $select_multi = false;
    $select_unique = false;
    if (!empty($select_field) && $select_type > 0 && !empty($select_formname)) {
        switch ($select_type) {
            case 1:
                $select_multi = true;
                break;
            case 2:
                $select_unique = true;
                break;
        }
    }
    // get split params
    $switch_split_global_announce = isset($config['split_global_announce']) && isset($lang['Post_Global_Announcement']) ? intval($config['split_global_announce']) : false;
    $switch_split_announce = isset($config['split_announce']) ? intval($config['split_announce']) : false;
    $switch_split_sticky = isset($config['split_sticky']) ? intval($config['split_sticky']) : false;
    $switch_split_news = isset($config['split_news']) ? intval($config['split_news']) : false;
    // set in separate table
    $split_box = $inbox && (isset($config['split_topic_split']) ? intval($config['split_topic_split']) : false);
    // take care of the context
    if (!$split_type) {
        $split_box = false;
        $switch_split_global_announce = false;
        $switch_split_announce = false;
        $switch_split_sticky = false;
        $switch_split_news = false;
    }
    if (!$switch_split_global_announce && !$switch_split_announce && !$switch_split_sticky && !$switch_split_news) {
        $split_type = false;
        $split_box = false;
    }
    // read the user cookie
    $tracking_forums = isset($_COOKIE[$config['cookie_name'] . '_f']) ? unserialize($_COOKIE[$config['cookie_name'] . '_f']) : array();
    $tracking_topics = isset($_COOKIE[$config['cookie_name'] . '_t']) ? unserialize($_COOKIE[$config['cookie_name'] . '_t']) : array();
    $tracking_all = isset($_COOKIE[$config['cookie_name'] . '_f_all']) ? intval($_COOKIE[$config['cookie_name'] . '_f_all']) : NULL;
    // categories hierarchy v 2 compliancy
    $cat_hierarchy = function_exists('get_auth_keys');
    if (!$cat_hierarchy) {
        // standard read
        $is_auth = array();
        $is_auth = auth(AUTH_ALL, AUTH_LIST_ALL, $user->data);
    }
    // topic icon present
    $icon_installed = function_exists('get_icon_title');
    // get a default title
    if (empty($list_title)) {
        $list_title = $lang['forum'];
    }
    // choose template
    $template->set_filenames(array($tpl => $tpl . '.tpl'));
    // check if user replied to the topic
    $user_topics = array();
    if ($user->data['user_id'] != ANONYMOUS) {
        // get all the topic ids to display
        $topic_ids = array();
        for ($i = 0; $i < sizeof($topic_rowset); $i++) {
            $topic_item_type = substr($topic_rowset[$i]['topic_id'], 0, 1);
            $topic_id = intval(substr($topic_rowset[$i]['topic_id'], 1));
            if ($topic_item_type == POST_TOPIC_URL) {
                $topic_ids[] = $topic_id;
            }
        }
        // check if the user replied to
        if (!empty($topic_ids)) {
            // check the posts
            $s_topic_ids = implode(', ', $topic_ids);
            $sql = "SELECT DISTINCT topic_id FROM " . POSTS_TABLE . "\n\t\t\t\t\tWHERE topic_id IN ({$s_topic_ids})\n\t\t\t\t\t\tAND poster_id = " . $user->data['user_id'];
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                $user_topics[POST_TOPIC_URL . $row['topic_id']] = true;
            }
        }
    }
    // initiate
    $template->assign_block_vars($tpl, array('FORMNAME' => $select_formname, 'FIELDNAME' => $select_field));
    // spanning of the first column (list name)
    $span_left = 1;
    if (sizeof($topic_rowset) > 0) {
        // add folder image
        $span_left++;
    }
    if ($icon_installed) {
        // add topic icon
        $span_left++;
    }
    if ($select_unique) {
        // selection in front is asked
        $span_left++;
    }
    // spanning of the whole line (bottom row and/or empty list)
    $span_all = $span_left + 4;
    if ($select_multi && sizeof($topic_rowset) > 0) {
        $span_all++;
    }
    // display topics
    $color = false;
    $prec_topic_type = '';
    $header_sent = false;
    if (!isset($box_id)) {
        $box_id = -1;
    }
    for ($i = 0; $i < sizeof($topic_rowset); $i++) {
        $topic_item_type = substr($topic_rowset[$i]['topic_id'], 0, 1);
        $topic_id = intval(substr($topic_rowset[$i]['topic_id'], 1));
        $topic_title = censor_text($topic_rowset[$i]['topic_title']);
        $replies = $topic_rowset[$i]['topic_replies'];
        $topic_type = $topic_rowset[$i]['topic_type'];
        $user_replied = !empty($user_topics) && isset($user_topics[$topic_rowset[$i]['topic_id']]);
        $force_type_display = false;
        $forum_id = $topic_rowset[$i]['forum_id'];
        if (defined('POST_BIRTHDAY') && $topic_type == POST_BIRTHDAY) {
            $topic_type = $lang['Birthday'] . ': ';
        } elseif ($topic_type == POST_NEWS) {
            $topic_type = $lang['News'] . ': ';
        } elseif ($topic_type == POST_GLOBAL_ANNOUNCE) {
            $topic_type = $lang['Topic_Global_Announcement'] . ' ';
        } elseif ($topic_type == POST_ANNOUNCE) {
            $topic_type = $lang['Topic_Announcement'] . ' ';
        } elseif ($topic_type == POST_STICKY) {
            $topic_type = $lang['Topic_Sticky'] . ' ';
        } else {
            $topic_type = '';
        }
        if (!empty($topic_rowset[$i]['poll_start']) && $topic_rowset[$i]['topic_status'] != TOPIC_MOVED) {
            $topic_type .= $lang['Topic_Poll'] . ' ';
            $force_type_display = true;
        }
        if (defined('POST_BIRTHDAY') && $topic_rowset[$i]['topic_type'] == POST_BIRTHDAY) {
            $folder_image = $images['folder_birthday'];
            $folder_alt = $lang['HAPPY_BIRTHDAY'];
            $newest_post_img = '';
        } elseif ($topic_rowset[$i]['topic_status'] == TOPIC_MOVED) {
            $topic_type = $lang['Topic_Moved'] . ' ';
            $topic_id = $topic_rowset[$i]['topic_moved_id'];
            $folder_image = $images['topic_nor_read'];
            $folder_alt = $lang['Topics_Moved'];
            $newest_post_img = '';
            $force_type_display = true;
        } else {
            /*
            define('USER_REPLIED_ICON', true);
            $user_replied = true;
            */
            if (defined('POST_BIRTHDAY') && $topic_rowset[$i]['topic_type'] == POST_BIRTHDAY) {
                $folder = $images['folder_birthday'];
                $folder_new = $images['folder_birthday'];
            } elseif ($topic_rowset[$i]['topic_type'] == POST_NEWS) {
                $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_nor_read_own'] : $images['topic_nor_read'];
                $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_nor_unread_own'] : $images['topic_nor_unread'];
            } elseif ($topic_rowset[$i]['topic_type'] == POST_GLOBAL_ANNOUNCE) {
                $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_glo_read_own'] : $images['topic_glo_read'];
                $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_glo_unread_own'] : $images['topic_glo_unread'];
            } elseif ($topic_rowset[$i]['topic_type'] == POST_ANNOUNCE) {
                $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_ann_read_own'] : $images['topic_ann_read'];
                $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_ann_unread_own'] : $images['topic_ann_unread'];
            } elseif ($topic_rowset[$i]['topic_type'] == POST_STICKY) {
                $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_imp_read_own'] : $images['topic_imp_read'];
                $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_imp_unread_own'] : $images['topic_imp_unread'];
            } elseif ($topic_rowset[$i]['topic_status'] == TOPIC_LOCKED) {
                $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_nor_locked_read_own'] : $images['topic_nor_locked_read'];
                $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_nor_locked_unread_own'] : $images['topic_nor_locked_unread'];
            } else {
                if ($replies >= $config['hot_threshold']) {
                    $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_hot_read_own'] : $images['topic_hot_read'];
                    $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_hot_unread_own'] : $images['topic_hot_unread'];
                } else {
                    $folder = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_nor_read_own'] : $images['topic_nor_read'];
                    $folder_new = $user_replied && defined('USER_REPLIED_ICON') ? $images['topic_nor_unread_own'] : $images['topic_nor_unread'];
                }
            }
            $newest_post_img = '';
            if ($user->data['session_logged_in'] && $topic_item_type == POST_TOPIC_URL) {
                // UPI2DB - BEGIN
                if (!$user->data['upi2db_access']) {
                    // UPI2DB - END
                    if ($topic_rowset[$i]['post_time'] > $user->data['user_lastvisit']) {
                        if (!empty($tracking_topics) || !empty($tracking_forums) || !empty($tracking_all)) {
                            $unread_topics = true;
                            if (!empty($tracking_topics[$topic_id])) {
                                if ($tracking_topics[$topic_id] >= $topic_rowset[$i]['post_time']) {
                                    $unread_topics = false;
                                }
                            }
                            if (!empty($tracking_forums[$forum_id])) {
                                if ($tracking_forums[$forum_id] >= $topic_rowset[$i]['post_time']) {
                                    $unread_topics = false;
                                }
                            }
                            if (!empty($tracking_all)) {
                                if ($tracking_all >= $topic_rowset[$i]['post_time']) {
                                    $unread_topics = false;
                                }
                            }
                            if ($unread_topics) {
                                $folder_image = $folder_new;
                                $folder_alt = $lang['New_posts'];
                                $newest_post_img = '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . "?" . POST_TOPIC_URL . "={$topic_id}&amp;view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" /></a> ';
                            } else {
                                $folder_image = $folder;
                                $folder_alt = $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ? $lang['Topic_locked'] : $lang['No_new_posts'];
                                $newest_post_img = '';
                            }
                        } else {
                            $folder_image = $folder_new;
                            $folder_alt = $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ? $lang['Topic_locked'] : $lang['New_posts'];
                            $newest_post_img = '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . "?" . POST_TOPIC_URL . "={$topic_id}&amp;view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" /></a> ';
                        }
                    } else {
                        $folder_image = $folder;
                        $folder_alt = $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ? $lang['Topic_locked'] : $lang['No_new_posts'];
                        $newest_post_img = '';
                    }
                    // UPI2DB - BEGIN
                } else {
                    viewforum_calc_unread($user->data['upi2db_unread'], $topic_id, $topic_rowset, $i, $folder_new, $folder, $folder_alt, $folder_image, $newest_post_img, $upi2db_status);
                }
                // UPI2DB - END
            } else {
                $folder_image = $folder;
                $folder_alt = $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ? $lang['Topic_locked'] : $lang['No_new_posts'];
                $newest_post_img = '';
            }
        }
        // generate list of page for the topic
        $topic_pagination = generate_topic_pagination($forum_id, $topic_id, $replies);
        $topic_author = '';
        $first_post_time = '';
        $last_post_time = '';
        $last_post_url = '';
        $views = '';
        switch ($topic_item_type) {
            case POST_USERS_URL:
                $view_topic_url = append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_TOPIC_URL . '=' . $topic_id);
                break;
            default:
                $view_topic_url = append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_TOPIC_URL . '=' . $topic_id);
                $topic_author = $topic_rowset[$i]['user_id'] != ANONYMOUS ? '<a href="' . append_sid(CMS_PAGE_PROFILE . '?mode=viewprofile&amp;' . POST_USERS_URL . '=' . $topic_rowset[$i]['user_id']) . '">' : '';
                $topic_author .= $topic_rowset[$i]['user_id'] != ANONYMOUS ? $topic_rowset[$i]['username'] : ($topic_rowset[$i]['post_username'] != '' ? $topic_rowset[$i]['post_username'] : $lang['Guest']);
                $topic_author .= $topic_rowset[$i]['user_id'] != ANONYMOUS ? '</a>' : '';
                $first_post_time = create_date_ip($config['default_dateformat'], $topic_rowset[$i]['topic_time'], $config['board_timezone']);
                $last_post_time = create_date_ip($config['default_dateformat'], $topic_rowset[$i]['post_time'], $config['board_timezone']);
                $last_post_author = $topic_rowset[$i]['id2'] == ANONYMOUS ? $topic_rowset[$i]['post_username2'] != '' ? $topic_rowset[$i]['post_username2'] . ' ' : $lang['Guest'] . ' ' : '<a href="' . append_sid(CMS_PAGE_PROFILE . '?mode=viewprofile&amp;' . POST_USERS_URL . '=' . $topic_rowset[$i]['id2']) . '">' . $topic_rowset[$i]['user2'] . '</a>';
                $last_post_url = '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_POST_URL . '=' . $topic_rowset[$i]['topic_last_post_id']) . '#p' . $topic_rowset[$i]['topic_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>';
                $views = $topic_rowset[$i]['topic_views'];
                // BEGIN cmx_mod
                $news_label = $topic_rowset[$i]['news_id'] > 0 ? $lang['News'] . ':' : '';
                // END cmx_mod
                break;
        }
        // categories hierarchy v 2 compliancy
        $nav_tree = '';
        if ($display_nav_tree && !empty($topic_rowset[$i]['forum_id'])) {
            if ($cat_hierarchy) {
                if ($tree['auth'][POST_FORUM_URL . $topic_rowset[$i]['forum_id']]['tree.auth_view']) {
                    $nav_tree = make_cat_nav_tree(POST_FORUM_URL . $topic_rowset[$i]['forum_id'], '', '', 'gensmall');
                }
            } else {
                if ($is_auth[$topic_rowset[$i]['forum_id']]['auth_view']) {
                    $nav_tree = '<a href="' . append_sid(CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $topic_rowset[$i]['forum_id']) . '" class="gensmall">' . $topic_rowset[$i]['forum_name'] . '</a>';
                }
            }
        }
        if (!empty($nav_tree)) {
            $nav_tree = '[ ' . $nav_tree . ' ]';
        }
        // get the type for rupture
        $topic_real_type = $topic_rowset[$i]['topic_type'];
        // if no split between global and standard announcement, group them with standard announcement
        if (!$switch_split_global_announce && $topic_real_type == POST_GLOBAL_ANNOUNCE) {
            $topic_real_type = POST_ANNOUNCE;
        }
        // if no split between announce and sticky, group them with sticky
        if (!$switch_split_announce && $topic_real_type == POST_ANNOUNCE) {
            $topic_real_type = POST_NEWS;
        }
        // if no split between news and global announcement, group them with normal
        if (!$switch_split_news && $topic_real_type == POST_NEWS) {
            $topic_real_type = POST_STICKY;
        }
        // if no split between sticky and normal, group them with normal
        if (!$switch_split_sticky && $topic_real_type == POST_STICKY) {
            $topic_real_type = POST_NORMAL;
        }
        // check if rupture
        $rupt = false;
        // split
        if ($i == 0 || $split_type) {
            if ($i == 0) {
                $rupt = true;
            }
            // check the rupt
            if ($prec_topic_type != $topic_real_type) {
                $rupt = true;
            }
        }
        $prec_topic_type = $topic_real_type;
        // header
        if ($rupt) {
            // close the prec box
            if ($split_box && $i != 0) {
                // footer
                $template->assign_block_vars($tpl . '.row', array('COLSPAN' => $span_all));
                // table closure
                $template->assign_block_vars($tpl . '.row.footer_table', array());
                // spacing
                $template->assign_block_vars($tpl . '.row', array());
                $template->assign_block_vars($tpl . '.row.spacer', array());
                // unset header
                $header_sent = false;
            }
            // get box title
            $main_title = $list_title;
            $sub_title = $list_title;
            switch ($topic_real_type) {
                case POST_BIRTHDAY:
                    $sub_title = $lang['Birthday'];
                    break;
                case POST_NEWS:
                    $sub_title = $lang['News'];
                    break;
                case POST_GLOBAL_ANNOUNCE:
                    $sub_title = $lang['Post_Global_Announcement'];
                    break;
                case POST_ANNOUNCE:
                    $sub_title = $lang['Post_Announcement'];
                    break;
                case POST_STICKY:
                    $sub_title = $lang['Post_Sticky'];
                    break;
                case POST_CALENDAR:
                    $sub_title = $lang['Calendar_event'];
                    break;
                case POST_NORMAL:
                    $sub_title = $lang['Topics'];
                    break;
            }
            $template->assign_block_vars($tpl . '.row', array('L_TITLE' => !$split_box ? $main_title : $sub_title, 'L_REPLIES' => $lang['Replies'], 'L_AUTHOR' => $lang['Author'], 'L_VIEWS' => $lang['Views'], 'L_LASTPOST' => $lang['Last_Post'], 'COLSPAN' => $span_all));
            // open a new box
            if ($split_box || $i == 0) {
                $box_id++;
                $template->assign_block_vars($tpl . '.row.header_table', array('COLSPAN' => $span_left, 'BOX_ID' => $box_id));
                // selection fields
                if ($select_multi) {
                    $template->assign_block_vars($tpl . '.row.header_table.multi_selection', array());
                }
                // set header
                $header_sent = true;
            }
            // not in box, send a row title
            if ($split_type && !$split_box) {
                $template->assign_block_vars($tpl . '.row', array('L_TITLE' => $sub_title, 'COLSPAN' => $span_all));
                $template->assign_block_vars($tpl . '.row.header_row', array());
            }
        }
        // erase the type before the title if split
        if ($split_type && $topic_real_type == $topic_rowset[$i]['topic_type'] && !$force_type_display) {
            $topic_type = '';
        }
        // get the announces dates
        $topic_announces_dates = '';
        // get the calendar dates
        $topic_calendar_dates = '';
        if (function_exists(get_calendar_title)) {
            $topic_calendar_dates = get_calendar_title($topic_rowset[$i]['topic_calendar_time'], $topic_rowset[$i]['topic_calendar_duration']);
        }
        // get the topic icons
        $icon = '';
        if ($icon_installed) {
            $type = $topic_rowset[$i]['topic_type'];
            if ($type == POST_NORMAL) {
                if (defined('POST_CALENDAR') && !empty($topic_rowset[$i]['topic_calendar_time'])) {
                    $type = POST_CALENDAR;
                }
                if (defined('POST_PICTURE') && !empty($topic_rowset[$i]['topic_pic_url'])) {
                    $type = POST_PICTURE;
                }
            }
            $icon = get_icon_title($topic_rowset[$i]['topic_icon'], 1, $type);
        }
        // UPI2DB - BEGIN
        if ($user->data['upi2db_access']) {
            $mark_always_read = mark_always_read($topic_rowset[$i]['topic_type'], $topic_id, $forum_id, 'viewforum', 'icon', $user->data['upi2db_unread'], $start, $folder_image);
        } else {
            $mark_always_read = '<img src="' . $folder_image . '" alt="' . $folder_alt . '" title="' . $folder_alt . '" />';
        }
        // UPI2DB - END
        // send topic to template
        $selected = !empty($select_values) && in_array($topic_rowset[$i]['topic_id'], $select_values);
        $color = !$color;
        $template->assign_block_vars($tpl . '.row', array('ROW_CLASS' => $color || !defined('TOPIC_ALTERNATE_ROW_CLASS') ? $theme['td_class1'] : $theme['td_class2'], 'ROW_FOLDER_CLASS' => $user_replied && defined('USER_REPLIED_CLASS') ? USER_REPLIED_CLASS : ($color || !defined('TOPIC_ALTERNATE_ROW_CLASS') ? $theme['td_class1'] : $theme['td_class2']), 'FORUM_ID' => $forum_id, 'TOPIC_ID' => $topic_id, 'TOPIC_FOLDER_IMG' => $folder_image, 'TOPIC_AUTHOR' => $topic_author, 'TOPIC_DESCRIPTION' => $topic_desc, 'GOTO_PAGE' => $topic_pagination['base'], 'GOTO_PAGE_FULL' => $topic_pagination['full'], 'TOPIC_NAV_TREE' => !empty($nav_tree) ? (empty($goto_page) ? '<br />' : '') . $nav_tree : '', 'REPLIES' => $replies, 'NEWEST_POST_IMG' => $newest_post_img, 'TOPIC_ATTACHMENT_IMG' => topic_attachment_image($topic_rowset[$i]['topic_attachment']), 'ICON' => $icon, 'TOPIC_TITLE' => $topic_title, 'TOPIC_ANNOUNCES_DATES' => $topic_announces_dates, 'TOPIC_CALENDAR_DATES' => $topic_calendar_dates, 'TOPIC_TYPE' => $topic_type, 'VIEWS' => $views, 'FIRST_POST_TIME' => $first_post_time, 'LAST_POST_TIME' => $last_post_time, 'LAST_POST_AUTHOR' => $last_post_author, 'LAST_POST_IMG' => $last_post_url, 'L_NEWS' => $news_label, 'L_TOPIC_FOLDER_ALT' => $folder_alt, 'U_VIEW_TOPIC' => $view_topic_url, 'BOX_ID' => $box_id, 'FID' => $topic_rowset[$i]['topic_id'], 'U_MARK_ALWAYS_READ' => $mark_always_read, 'L_SELECT' => $selected && ($select_multi || $select_unique) ? 'checked="checked"' : ''));
        $template->assign_block_vars($tpl . '.row.topic', array());
        if (!empty($topic_rowset[$i]['topic_desc']) && $config['show_topic_description']) {
            $template->assign_block_vars($tpl . '.row.topic.switch_topic_desc', array());
        }
        // selection fields
        if ($select_multi) {
            $template->assign_block_vars($tpl . '.row.topic.multi_selection', array());
        }
        if ($select_unique) {
            $template->assign_block_vars($tpl . '.row.topic.single_selection', array());
        }
        // icons
        if ($icon_installed) {
            $template->assign_block_vars($tpl . '.row.topic.icon', array());
        }
        // nav tree asked
        if ($display_nav_tree && !empty($nav_tree)) {
            $template->assign_block_vars($tpl . '.row.topic.nav_tree', array());
        }
    }
    // end for topic_rowset read
    // send an header if missing
    if (!$header_sent) {
        $template->assign_block_vars($tpl . '.row', array('L_TITLE' => $list_title, 'L_REPLIES' => $lang['Replies'], 'L_AUTHOR' => $lang['Author'], 'L_VIEWS' => $lang['Views'], 'L_LASTPOST' => $lang['Last_Post'], 'COLSPAN' => $span_all));
        // open a new box
        $template->assign_block_vars($tpl . '.row.header_table', array('COLSPAN' => $span_left));
    }
    // no data
    if (sizeof($topic_rowset) == 0) {
        // send no topics notice
        $template->assign_block_vars($tpl . '.row', array('L_NO_TOPICS' => $lang['No_search_match'], 'COLSPAN' => $span_all));
        $template->assign_block_vars($tpl . '.row.no_topics', array());
    }
    // bottom line
    if (!empty($footer)) {
        $template->assign_block_vars($tpl . '.row', array('COLSPAN' => $span_all, 'FOOTER' => $footer));
        $template->assign_block_vars($tpl . '.row.bottom', array());
    }
    // table closure
    $template->assign_block_vars($tpl . '.row', array('COLSPAN' => $span_all));
    $template->assign_block_vars($tpl . '.row.footer_table', array());
    // spacing
    if (empty($footer)) {
        // spacing
        $template->assign_block_vars($tpl . '.row', array());
        $template->assign_block_vars($tpl . '.row.spacer', array());
    }
    // transfert to a var
    $template->assign_var_from_handle('_box', $tpl);
    $res = $template->_tpldata['.'][0]['_box'];
    // restore template saved state
    $template->_tpldata = $sav_tpl;
    // assign value to the main template
    $template->assign_vars(array($box => $res));
}
示例#7
0
		$l_edited_by = '';
	}

	// Convert and clean special chars!
	$post_subject = htmlspecialchars_clean($post_subject);
	// SMILEYS IN TITLE - BEGIN
	if (($config['smilies_topic_title'] == true) && !$lofi)
	{
		$bbcode->allow_smilies = ($config['allow_smilies'] && $postrow[$i]['enable_smilies'] ? true : false);
		$post_subject = $bbcode->parse_only_smilies($post_subject);
	}
	// SMILEYS IN TITLE - END

	if (!empty($topic_calendar_time) && ($postrow[$i]['post_id'] == $topic_first_post_id))
	{
		$post_subject .= get_calendar_title($topic_calendar_time, $topic_calendar_duration);
	}

// UPI2DB - BEGIN
	if($user->data['upi2db_access'])
	{
		$post_edit_max = ($postrow[$i]['post_time'] >= $postrow[$i]['post_edit_time']) ? $postrow[$i]['post_time'] : $postrow[$i]['post_edit_time'];
		$post_time_max = (empty($config['upi2db_edit_as_new'])) ? $postrow[$i]['post_time'] : $post_edit_max;
		$post_id = $postrow[$i]['post_id'];
		$mark_topic_unread_array = mark_post_viewtopic_array($post_time_max, $user->data['upi2db_unread'], $topic_id, $forum_id, $post_id, $except_time, $forum_topic_data['topic_type']);
	}
// UPI2DB - END

	$post_id = $postrow[$i]['post_id'];
	$poster_number = ($postrow[$i]['poster_id'] == ANONYMOUS) ? '' : $lang['User_Number'] . ': ' . $postrow[$i]['poster_id'];
	$post_edit_link = append_sid('edit_post_details.' . PHP_EXT . '?' . $forum_id_append . '&amp;' . $topic_id_append . '&amp;' . POST_POST_URL . '=' . $postrow[$i]['post_id']);