コード例 #1
0
ファイル: forum.php プロジェクト: Yoyoyozo/webDiplomacy
    // New or archived posts anchor to the start of the thread
    if ($User->timeLastSessionEnded < $message['timeSent'] || $message['latestReplySent'] < $Misc->ThreadAliveThreshold) {
        print $messageAnchor;
        $messageAnchor = '';
    }
    if ($message['replies'] == 0) {
        print $messageAnchor;
    }
    print '<div class="leftRule message-head threadalternate' . $switch . '">

		<a href="profile.php?userID=' . $message['fromUserID'] . '">' . $message['fromusername'] . ' ' . libHTML::loggedOn($message['fromUserID']) . ' (' . $message['points'] . ' ' . libHTML::points() . User::typeIcon($message['userType']) . ')</a>' . '<br />
			<strong><em>' . libTime::text($message['timeSent']) . '</em></strong>' . $muteLink . '<br />
			' . $User->likeMessageToggleLink($message['id'], $message['fromUserID']) . libHTML::likeCount($message['likeCount']) . '</div>';
    print '<div class="message-subject">';
    print libHTML::forumMessage($message['id'], $message['latestReplySent']);
    print libHTML::forumParticipated($message['id']);
    if ($message['latestReplySent'] < $Misc->ThreadAliveThreshold) {
        $postLockedReason = l_t("Thread is too old to reply to");
    } elseif (isset($silence) && $silence->isEnabled()) {
        $postLockedReason = l_t("This thread has been locked; ") . $silence->reason;
    } elseif ($User->isSilenced()) {
        $postLockedReason = l_t("This account has been silenced; ") . $User->getActiveSilence()->reason;
    } else {
        unset($postLockedReason);
    }
    if (isset($postLockedReason)) {
        print '<img src="' . l_s('images/icons/lock.png') . '" title="' . $postLockedReason . '" /> ';
    }
    print '<strong>' . $message['subject'] . '</strong>';
    print '</div>
		
コード例 #2
0
ファイル: index.php プロジェクト: Yoyoyozo/webDiplomacy
    static function forumNew()
    {
        // Select by id, prints replies and new threads
        global $DB, $Misc;
        $tabl = $DB->sql_tabl("\r\n\t\t\tSELECT m.id as postID, t.id as threadID, m.type, m.timeSent, IF(t.replies IS NULL,m.replies,t.replies) as replies,\r\n\t\t\t\tIF(t.subject IS NULL,m.subject,t.subject) as subject,\r\n\t\t\t\tu.id as userID, u.username, u.points, IF(s.userID IS NULL,0,1) as online, u.type as userType,\r\n\t\t\t\tSUBSTRING(m.message,1,100) as message, m.latestReplySent, t.fromUserID as threadStarterUserID\r\n\t\t\tFROM wD_ForumMessages m\r\n\t\t\tINNER JOIN wD_Users u ON ( m.fromUserID = u.id )\r\n\t\t\tLEFT JOIN wD_Sessions s ON ( m.fromUserID = s.userID )\r\n\t\t\tLEFT JOIN wD_ForumMessages t ON ( m.toID = t.id AND t.type = 'ThreadStart' AND m.type = 'ThreadReply' )\r\n\t\t\tORDER BY m.timeSent DESC\r\n\t\t\tLIMIT 50");
        $oldThreads = 0;
        $threadCount = 0;
        $threadIDs = array();
        $threads = array();
        while (list($postID, $threadID, $type, $timeSent, $replies, $subject, $userID, $username, $points, $online, $userType, $message, $latestReplySent, $threadStarterUserID) = $DB->tabl_row($tabl)) {
            $threadCount++;
            if ($threadID) {
                $iconMessage = libHTML::forumMessage($threadID, $postID);
            } else {
                $iconMessage = libHTML::forumMessage($postID, $postID);
            }
            if ($type == 'ThreadStart') {
                $threadID = $postID;
            }
            if (!isset($threads[$threadID])) {
                if (strlen($subject) > 30) {
                    $subject = substr($subject, 0, 40) . '...';
                }
                $threadIDs[] = $threadID;
                $threads[$threadID] = array('subject' => $subject, 'replies' => $replies, 'posts' => array(), 'threadStarterUserID' => $threadStarterUserID);
            }
            $message = Message::refilterHTML($message);
            if (strlen($message) >= 50) {
                $message = substr($message, 0, 50) . '...';
            }
            $message = '<div class="message-contents threadID' . $threadID . '" fromUserID="' . $userID . '">' . $message . '</div>';
            $threads[$threadID]['posts'][] = array('iconMessage' => $iconMessage, 'userID' => $userID, 'username' => $username, 'message' => $message, 'points' => $points, 'online' => $online, 'userType' => $userType, 'timeSent' => $timeSent);
        }
        $buf = '';
        $threadCount = 0;
        foreach ($threadIDs as $threadID) {
            $data = $threads[$threadID];
            $buf .= '<div class="hr userID' . $threads[$threadID]['threadStarterUserID'] . ' threadID' . $threadID . '"></div>';
            $buf .= '<div class="homeForumGroup homeForumAlt' . ($threadCount % 2 + 1) . ' userID' . $threads[$threadID]['threadStarterUserID'] . ' threadID' . $threadID . '">
				<div class="homeForumSubject homeForumTopBorder">' . libHTML::forumParticipated($threadID) . ' ' . $data['subject'] . '</div> ';
            if (count($data['posts']) < $data['replies']) {
                $buf .= '<div class="homeForumPost homeForumMessage homeForumPostAlt' . libHTML::alternate() . ' ">

				...</div>';
            }
            $data['posts'] = array_reverse($data['posts']);
            foreach ($data['posts'] as $post) {
                $buf .= '<div class="homeForumPost homeForumPostAlt' . libHTML::alternate() . ' userID' . $post['userID'] . '">


					<div class="homeForumPostTime">' . libTime::text($post['timeSent']) . ' ' . $post['iconMessage'] . '</div>
					<a href="profile.php?userID=' . $post['userID'] . '" class="light">' . $post['username'] . '</a>
						' . libHTML::loggedOn($post['userID']) . ' (' . $post['points'] . libHTML::points() . User::typeIcon($post['userType']) . ')

					<div style="clear:both"></div>
					<div class="homeForumMessage">' . $post['message'] . '</div>
					</div>';
            }
            $buf .= '<div class="homeForumLink">
					<div class="homeForumReplies">' . l_t('%s replies', '<strong>' . $data['replies'] . '</strong>') . '</div>
					<a href="forum.php?threadID=' . $threadID . '#' . $threadID . '">' . l_t('Open') . '</a>
					</div>
					</div>';
        }
        if ($buf) {
            return $buf;
        } else {
            return '<div class="homeNoActivity">' . l_t('No forum posts found, why not ' . '<a href="forum.php?postboxopen=1#postbox" class="light">start one</a>?');
        }
    }