Пример #1
0
function b_news_topicsnav_show($options)
{
    include_once XOOPS_ROOT_PATH . '/modules/news/include/functions.php';
    include_once XOOPS_ROOT_PATH . "/modules/news/class/class.newstopic.php";
    $myts =& MyTextSanitizer::getInstance();
    $block = array();
    $newscountbytopic = array();
    $perms = '';
    $xt = new NewsTopic();
    $restricted = getmoduleoption('restrictindex');
    if ($restricted) {
        global $xoopsUser;
        $module_handler =& xoops_gethandler('module');
        $newsModule =& $module_handler->getByDirname('news');
        $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
        $gperm_handler =& xoops_gethandler('groupperm');
        $topics = $gperm_handler->getItemIds('news_view', $groups, $newsModule->getVar('mid'));
        if (count($topics) > 0) {
            $topics = implode(',', $topics);
            $perms = " AND topic_id IN (" . $topics . ") ";
        } else {
            return '';
        }
    }
    $topics_arr = $xt->getChildTreeArray(0, "topic_title", $perms);
    if ($options[0] == 1) {
        $newscountbytopic = $xt->getNewsCountByTopic();
    }
    if (is_array($topics_arr) && count($topics_arr)) {
        foreach ($topics_arr as $onetopic) {
            if ($options[0] == 1) {
                $count = 0;
                if (array_key_exists($onetopic['topic_id'], $newscountbytopic)) {
                    $count = $newscountbytopic[$onetopic['topic_id']];
                }
            } else {
                $count = '';
            }
            $block['topics'][] = array('id' => $onetopic['topic_id'], 'news_count' => $count, 'topic_color' => '#' . $onetopic['topic_color'], 'title' => $myts->displayTarea($onetopic['topic_title']));
        }
    }
    return $block;
}
Пример #2
0
$restricted = news_getmoduleoption('restrictindex');
if ($restricted) {
    global $xoopsUser;
    $module_handler =& xoops_gethandler('module');
    $newsModule =& $module_handler->getByDirname('news');
    $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
    $gperm_handler =& xoops_gethandler('groupperm');
    $topics = $gperm_handler->getItemIds('news_view', $groups, $newsModule->getVar('mid'));
    if (count($topics) > 0) {
        $topics = implode(',', $topics);
        $perms = ' AND topic_id IN (' . $topics . ') ';
    } else {
        return '';
    }
}
$topics_arr = $xt->getChildTreeArray(0, 'topic_title', $perms);
$newscountbytopic = $xt->getNewsCountByTopic();
if (is_array($topics_arr) && count($topics_arr)) {
    foreach ($topics_arr as $onetopic) {
        $count = 0;
        if (array_key_exists($onetopic['topic_id'], $newscountbytopic)) {
            $count = $newscountbytopic[$onetopic['topic_id']];
        }
        if ($onetopic['topic_pid'] != 0) {
            $onetopic['prefix'] = str_replace('.', '-', $onetopic['prefix']) . ' ';
        } else {
            $onetopic['prefix'] = str_replace('.', '', $onetopic['prefix']);
        }
        $tbl_topics[] = array('id' => $onetopic['topic_id'], 'news_count' => $count, 'topic_color' => '#' . $onetopic['topic_color'], 'prefix' => $onetopic['prefix'], 'title' => $myts->displayTarea($onetopic['topic_title']));
    }
}