示例#1
0
function makeForumList($fieldname, $selectedID, $allowNone = false)
{
    global $loguserid, $loguser, $forumBoards;
    $viewableforums = ForumsWithPermission('forum.viewforum');
    $viewhidden = HasPermission('user.viewhiddenforums');
    $noneOption = '';
    if ($allowNone) {
        $noneOption = '<option value=0>' . __('(none)') . '</option>';
    }
    $rCats = Query("SELECT id, name, board FROM {categories} ORDER BY board, corder, id");
    $cats = array();
    while ($cat = Fetch($rCats)) {
        $cats[$cat['id']] = $cat;
    }
    $rFora = Query("\tSELECT\n\t\t\t\t\t\t\tf.id, f.title, f.catid\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t{forums} f\n\t\t\t\t\t\tWHERE f.id IN ({0c})" . (!$viewhidden ? " AND f.hidden=0" : '') . " AND f.redirect=''\n\t\t\t\t\t\tORDER BY f.forder, f.id", $viewableforums);
    $fora = array();
    while ($forum = Fetch($rFora)) {
        $fora[$forum['catid']][] = $forum;
    }
    $theList = '';
    foreach ($cats as $cid => $cat) {
        if (empty($fora[$cid])) {
            continue;
        }
        $cname = $cat['name'];
        if ($cat['board']) {
            $cname = $forumBoards[$cat['board']] . ' - ' . $cname;
        }
        $theList .= '			<optgroup label="' . htmlspecialchars($cname) . '">
' . mfl_forumBlock($fora, $cid, $selectedID, 0) . '			</optgroup>
';
    }
    return "<select id=\"{$fieldname}\" name=\"{$fieldname}\">{$noneOption}{$theList}</select>";
}
示例#2
0
文件: layout.php 项目: knytrune/ABXD
function makeForumList($fieldname, $selectedID)
{
    global $loguserid, $loguser;
    $pl = $loguser['powerlevel'];
    if ($pl < 0) {
        $pl = 0;
    }
    $rCats = Query("SELECT id, name FROM {categories} ORDER BY corder, id");
    $cats = array();
    while ($cat = Fetch($rCats)) {
        $cats[$cat['id']] = $cat;
    }
    $rFora = Query("\tSELECT\n\t\t\t\t\t\t\tf.id, f.title, f.catid\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t{forums} f\n\t\t\t\t\t\tWHERE " . forumAccessControlSQL() . ($pl < 1 ? " AND f.hidden=0" : '') . "\n\t\t\t\t\t\tORDER BY f.forder, f.id");
    $fora = array();
    while ($forum = Fetch($rFora)) {
        $fora[$forum['catid']][] = $forum;
    }
    $theList = '';
    foreach ($cats as $cid => $cat) {
        if (empty($fora[$cid])) {
            continue;
        }
        $cname = $cat['name'];
        $theList .= '			<optgroup label="' . htmlspecialchars($cname) . '">
' . mfl_forumBlock($fora, $cid, $selectedID, 0) . '			</optgroup>
';
    }
    return "<select id=\"{$fieldname}\" name=\"{$fieldname}\">{$theList}</select>";
}