示例#1
0
function onNewTopic($iForumId, $sTopicSubject, $sTopicText, $isTopicSticky, $sUser, $sTopicUri, $iPostId)
{
    $fdb = new DbForum();
    $oProfile = new BxDolProfile($sUser);
    $aTopic = $fdb->getTopicByUri($sTopicUri);
    if (BX_ORCA_INTEGRATION == 'dolphin' && !isAdmin($oProfile->getID())) {
        defineForumActions();
        $aForum = $fdb->getForum($iForumId, false);
        $iActionId = BX_FORUM_PUBLIC_POST;
        if (isset($aForum['forum_type']) && 'private' == $aForum['forum_type']) {
            $iActionId = BX_FORUM_PRIVATE_POST;
        }
        checkAction($oProfile->getID(), $iActionId, true);
        // perform action
    }
    $a = array($iForumId, $sTopicSubject, $sTopicText, $isTopicSticky, $sUser);
    forumAlert('new_topic', $aTopic['topic_id'], $oProfile->getID(), $a);
}
    /**
     * forum rss feed, 10 latest topics in the forum
     *	@param $forum_id	forum id	
     */
    function getRssForum($forum_id)
    {
        global $gConf;
        $gConf['topics_per_page'] = 10;
        $gConf['date_format'] = '%a, %e %b %Y %k:%i:%s GMT';
        $fdb = new DbForum();
        $f = $fdb->getForum($forum_id);
        if (!$f) {
            exit;
        }
        $a = $fdb->getTopics($forum_id, 0);
        reset($a);
        $items = '';
        $lastBuildDate = '';
        while (list(, $r) = each($a)) {
            $lp = $fdb->getTopicPost($r['topic_id'], 'last');
            $td = strip_tags($fdb->getTopicDesc($r['topic_id']));
            if (!$lastBuildDate) {
                $lastBuildDate = $lp['when'];
            }
            $items .= <<<EOF
\t\t\t<item>
\t\t\t\t<title>{$r['topic_title']}</title>
\t\t\t\t<link>{$gConf['url']['base']}index.php?action=goto&amp;topic_id={$r['topic_id']}</link>
\t\t\t\t<description>{$td}</description>
\t\t\t\t<pubDate>{$lp['when']}</pubDate>
\t\t\t\t<guid>{$gConf['url']['base']}index.php?action=goto&amp;topic_id={$r['topic_id']}</guid>
\t\t\t</item>
EOF;
        }
        return <<<EOF
<rss version="2.0">
\t<channel>
\t\t<title>{$f['forum_title']}</title>
\t\t<link>{$gConf['url']['base']}index.php?action=goto&amp;forum_id={$forum_id}</link>
\t\t<description>{$f['forum_desc']}</description>
\t\t<lastBuildDate>{$lastBuildDate}</lastBuildDate>\t
\t\t{$items}
\t</channel>
</rss>
EOF;
    }
    /**
     * post new topic
     * @param $p	_post array
     */
    function postNewTopicXML($p)
    {
        $fdb = new DbForum();
        $f = $fdb->getForum((int) $p['forum_id']);
        if (!$this->_checkUserPerm('', $f['forum_type'], 'post', (int) $p['forum_id'])) {
            return <<<EOF
<html>
<body>
<script language="javascript" type="text/javascript">

\tif (window.parent.document.getElementById('tinyEditor'))
\t\twindow.parent.tinyMCE.execCommand('mceRemoveControl', false, 'tinyEditor');

\twindow.parent.document.f.accessDenied();

</script>
</body>
</html>
EOF;
        }
        if ($p['topic_sticky'] == 'on' && !$this->_checkUserPerm('', '', 'sticky', (int) $p['forum_id'])) {
            return <<<EOF
<html>
<body>
<script language="javascript" type="text/javascript">

\tif (window.parent.document.getElementById('tinyEditor'))
\t\twindow.parent.tinyMCE.execCommand('mceRemoveControl', false, 'tinyEditor');

\twindow.parent.document.f.accessDenied();

</script>
</body>
</html>
EOF;
        }
        // post mesage here
        $user = $this->_getLoginUserName();
        prepare_to_db($p['topic_subject'], 0);
        prepare_to_db($p['topic_text'], 1);
        $topic_uri = $this->uriGenerate($p['topic_subject'], TF_FORUM_TOPIC, 'topic_uri');
        $fdb->newTopic((int) $p['forum_id'], $p['topic_subject'], $p['topic_text'], $p['topic_sticky'] == 'on', $user, $topic_uri);
        return <<<EOF
<html>
<body>
<script language="javascript" type="text/javascript">

\tif (window.parent.document.getElementById('tinyEditor'))
\t\twindow.parent.tinyMCE.execCommand('mceRemoveControl', false, 'tinyEditor');

\twindow.parent.document.f.postSuccess('{$f['forum_uri']}');

</script>
</body>
</html>
EOF;
    }