Beispiel #1
0
function forum_header($params)
{
    global $HTML, $group_id, $forum_name, $thread_id, $msg_id, $forum_id, $et, $et_cookie, $Language;
    $hp = Codendi_HTMLPurifier::instance();
    $uh = new UserHelper();
    $params['group'] = $group_id;
    $params['toptab'] = 'forum';
    $params['help'] = 'WebForums.html';
    /*
    	bastardization for news
    	Show icon bar unless it's a news forum
    */
    if ($group_id == $GLOBALS['sys_news_group']) {
        //this is a news item, not a regular forum
        if ($forum_id) {
            /*
            	Show this news item at the top of the page
            */
            $sql = "SELECT * FROM news_bytes WHERE forum_id=" . db_ei($forum_id);
            $result = db_query($sql);
            //backwards shim for all "generic news" that used to be submitted
            //as of may, "generic news" is not permitted - only project-specific news
            if (db_result($result, 0, 'group_id') != $GLOBALS['sys_news_group']) {
                $params['group'] = db_result($result, 0, 'group_id');
                $params['toptab'] = 'news';
                $group_id = db_result($result, 0, 'group_id');
                site_project_header($params);
            } else {
                $HTML->header($params);
                echo '
					<H2>' . $GLOBALS['sys_name'] . ' <A HREF="/news/">' . $Language->getText('forum_forum_utils', 'news') . '</A></H2><P>';
            }
            echo '<TABLE><TR><TD VALIGN="TOP">';
            if (!$result || db_numrows($result) < 1) {
                echo '
					<h3>' . $Language->getText('forum_forum_utils', 'news_not_found') . '</h3>';
            } else {
                echo '
				<B>' . $Language->getText('forum_forum_utils', 'posted_by') . ':</B> ' . $hp->purify($uh->getDisplayNameFromUserId(db_result($result, 0, 'submitted_by')), CODENDI_PURIFIER_CONVERT_HTML) . '<BR>
				<B>' . $Language->getText('forum_forum', 'date') . ':</B> ' . format_date($GLOBALS['Language']->getText('system', 'datefmt'), db_result($result, 0, 'date')) . '<BR>
				<B>' . $Language->getText('forum_forum_utils', 'summary') . ':</B><A HREF="/forum/forum.php?forum_id=' . db_result($result, 0, 'forum_id') . '">' . db_result($result, 0, 'summary') . '</A>
				<P>
				' . util_make_links(nl2br(db_result($result, 0, 'details')), $group_id);
                echo '<P>';
                $crossref_fact = new CrossReferenceFactory($forum_id, ReferenceManager::REFERENCE_NATURE_NEWS, $group_id);
                $crossref_fact->fetchDatas();
                if ($crossref_fact->getNbReferences() > 0) {
                    echo '<b> ' . $Language->getText('cross_ref_fact_include', 'references') . '</b>';
                    $crossref_fact->DisplayCrossRefs();
                }
            }
            echo '</TD><TD VALIGN="TOP" WIDTH="35%">';
            echo $HTML->box1_top($Language->getText('forum_forum_utils', 'proj_latest_news'), 0);
            echo news_show_latest(db_result($result, 0, 'group_id'), 5, false);
            echo $HTML->box1_bottom();
            echo '</TD></TR></TABLE>';
        }
    } else {
        //this is just a regular forum, not a news item
        site_project_header($params);
    }
    /*
    	Show horizontal forum links
    */
    if ($forum_id && $forum_name) {
        echo '<P><H3>' . $Language->getText('forum_forum_utils', 'discuss_forum') . ': <A HREF="/forum/forum.php?forum_id=' . $forum_id . '">' . $forum_name . '</A></H3>';
    }
    if (!isset($params['pv']) || isset($params['pv']) && !$params['pv']) {
        echo '<P><B>';
        $request =& HTTPRequest::instance();
        if ($forum_id && user_isloggedin() && !$request->exist('delete')) {
            if (user_monitor_forum($forum_id, user_getid())) {
                $msg = $Language->getText('forum_forum_utils', 'stop_monitor');
            } else {
                $msg = $Language->getText('forum_forum_utils', 'monitor');
            }
            echo '<A HREF="/forum/monitor.php?forum_id=' . $forum_id . '">';
            echo html_image("ic/monitor_forum.png", array()) . ' ' . $msg . '</A> | ';
            echo '<A HREF="/forum/monitor_thread.php?forum_id=' . $forum_id . '"> ' . html_image("ic/monitor_thread.png", array()) . $Language->getText('forum_forum_utils', 'monitor_thread') . '</A> | ';
            echo '<A HREF="/forum/save.php?forum_id=' . $forum_id . '">';
            echo html_image("ic/save.png", array()) . ' ' . $Language->getText('forum_forum_utils', 'save_place') . '</A> | ';
            print ' <a href="forum.php?forum_id=' . $forum_id . '#start_new_thread">';
            echo html_image("ic/thread.png", array()) . ' ' . $Language->getText('forum_forum_utils', 'start_thread') . '</A> | ';
            if (isset($msg_id) && $msg_id) {
                echo "<A HREF='" . $_SERVER['PHP_SELF'] . "?msg_id={$msg_id}&pv=1'><img src='" . util_get_image_theme("msg.png") . "' border='0'>&nbsp;" . $Language->getText('global', 'printer_version') . "</A> | ";
            } else {
                echo "<A HREF='" . $_SERVER['PHP_SELF'] . "?forum_id={$forum_id}&pv=1'><img src='" . util_get_image_theme("msg.png") . "' border='0'>&nbsp;" . $Language->getText('global', 'printer_version') . "</A> | ";
            }
        }
        // The forum admin link is only displayed for the forum moderators
        if (user_ismember($group_id, 'F2')) {
            echo '  <A HREF="/forum/admin/?group_id=' . $group_id . '">' . $Language->getText('forum_forum_utils', 'admin') . '</A></B>';
            if (isset($params['help']) && $params['help']) {
                echo ' | ';
            }
        }
        if (isset($params['help']) && $params['help']) {
            echo help_button($params['help'], false, $Language->getText('global', 'help'));
        }
        echo '</B><P>';
    }
}