Ejemplo n.º 1
0
function xthreads_global_forumbits_tpl()
{
    global $templatelist, $forum_tpl_prefixes;
    // see what custom prefixes we have and cache
    // I'm lazy, so just grab all the forum prefixes even if unneeded (in practice, difficult to filter out things properly anyway)
    // TODO: perhaps make this smarter??
    $forum_tpl_prefixes = xthreads_get_tplprefixes(false);
    if (!empty($forum_tpl_prefixes)) {
        $forumcache = $GLOBALS['cache']->read('forums');
        foreach ($forum_tpl_prefixes as $fid => &$prefs) {
            if ($forumcache[$fid]['xthreads_hideforum']) {
                continue;
            }
            foreach ($prefs as $pre) {
                // essentially, we need to escape this to prevent SQL injection
                // however, if we've taken over control over the templates engine, it'll already do the escaping for us, so don't double-escape
                if (!isset($GLOBALS['templates']->xt_tpl_prefix)) {
                    $pre = $GLOBALS['db']->escape_string($pre);
                }
                $templatelist .= ',' . $pre . 'forumbit_depth1_cat,' . $pre . 'forumbit_depth1_cat_subforum,' . $pre . 'forumbit_depth1_forum_lastpost,' . $pre . 'forumbit_depth2_cat,' . $pre . 'forumbit_depth2_forum,' . $pre . 'forumbit_depth2_forum_lastpost,' . $pre . 'forumbit_depth3,' . $pre . 'forumbit_depth3_statusicon,' . $pre . 'forumbit_moderators,' . $pre . 'forumbit_subforums';
            }
        }
    }
}
Ejemplo n.º 2
0
function xthreads_portal_announcement()
{
    static $doneinit = false;
    global $threadfield_cache, $announcement, $threadfields, $forum_tpl_prefixes;
    if (!$doneinit) {
        $doneinit = true;
        // cache templates
        $cachelist = '';
        $forum_tpl_prefixes = xthreads_get_tplprefixes(true, $GLOBALS['forum']);
        foreach ($forum_tpl_prefixes as $pref) {
            $pref = $GLOBALS['db']->escape_string($pref);
            $cachelist .= ($cachelist ? ',' : '') . $pref . 'portal_announcement,' . $pref . 'portal_announcement_numcomments,' . $pref . 'portal_announcement_numcomments_no';
        }
        if ($cachelist !== '') {
            $GLOBALS['templates']->cache($cachelist);
        }
    }
    // following two lines not needed as we have $anndate and $anntime
    //$announcement['threaddate'] = my_date($mybb->settings['dateformat'], $announcement['dateline']);
    //$announcement['threadtime'] = my_date($mybb->settings['timeformat'], $announcement['dateline']);
    xthreads_set_threadforum_urlvars('thread', $announcement['tid']);
    xthreads_set_threadforum_urlvars('forum', $announcement['fid']);
    if (!empty($threadfield_cache)) {
        // make threadfields array
        $threadfields = array();
        // clear previous threadfields
        foreach ($threadfield_cache as $k => &$v) {
            if ($v['forums'] && strpos(',' . $v['forums'] . ',', ',' . $announcement['fid'] . ',') === false) {
                continue;
            }
            $tids = '0' . $GLOBALS['tids'];
            xthreads_get_xta_cache($v, $tids);
            $threadfields[$k] =& $announcement['xthreads_' . $k];
            xthreads_sanitize_disp($threadfields[$k], $v, $announcement['username'] !== '' ? $announcement['username'] : $announcement['threadusername']);
        }
    }
    // template hack
    $tplprefix =& $forum_tpl_prefixes[$announcement['fid']];
    xthreads_portalsearch_cache_hack($tplprefix, 'portal_announcement');
    if (!xthreads_empty($tplprefix)) {
        $tplname = $tplprefix . 'portal_announcement_numcomments' . ($announcement['replies'] ? '' : '_no');
        if (!xthreads_empty($GLOBALS['templates']->cache[$tplname])) {
            global $lang, $mybb;
            // re-evaluate comments template
            eval('$GLOBALS[\'numcomments\'] = "' . $GLOBALS['templates']->get($tplname) . '";');
        }
    }
}