Beispiel #1
0
 //	$sql = "SELECT f.*
 //		FROM " . FORUMS_TABLE . " f, " . CATEGORIES_TABLE . " c
 //		WHERE f.cat_id = c.cat_id
 //		ORDER BY c.cat_order, f.forum_order ASC";
 // get cat ids
 $catids = array();
 $sql = "select * from " . CATEGORIES_TABLE;
 if (!($result = $db->sql_query($sql))) {
     message_die(GENERAL_ERROR, "Couldn't obtain cats information", "", __LINE__, __FILE__, $sql);
 }
 while ($row = $db->sql_fetchrow($result)) {
     $catids[] = $row['cat_id'];
 }
 // get cats array sorted, with level
 $catrows = array();
 get_auth_cat_order($catrows, $catids);
 // create a keyed by cat_id array
 $categories = array();
 $inc_max = 0;
 for ($i = 0; $i < count($catrows); $i++) {
     $categories[$catrows[$i]['cat_id']] = $catrows[$i];
     if ($catrows[$i]['level'] > $inc_max) {
         $inc_max = $catrows[$i]['level'];
     }
 }
 $sql = "SELECT f.*, c.cat_title, c.cat_main \n\t\t\tFROM " . FORUMS_TABLE . " f, " . CATEGORIES_TABLE . " as c \n\t\t\tWHERE f.cat_id = c.cat_id \n\t\t\tORDER BY c.cat_order, f.forum_order";
 // End PNphpBB2 Categories Hierarchie Mod
 if (!($result = $db->sql_query($sql))) {
     message_die(GENERAL_ERROR, "Couldn't obtain forum information", "", __LINE__, __FILE__, $sql);
 }
 $forum_access = array();
Beispiel #2
0
function get_auth_cat()
{
    global $db, $userdata;
    // get the cat id of all auth forums
    $catlist = array();
    $sql = "select * from " . FORUMS_TABLE;
    if (!($result = $db->sql_query($sql))) {
        message_die(GENERAL_ERROR, "Couldn't obtain forum list.", "", __LINE__, __FILE__, $sql);
    }
    while ($row = $db->sql_fetchrow($result)) {
        $is_auth = array();
        $is_auth = auth(AUTH_ALL, $row['forum_id'], $userdata);
        if ($is_auth['auth_view']) {
            $catlist[] = $row['cat_id'];
        }
    }
    // get the mother cat
    $t_cat = $catlist;
    while (count($t_cat) > 0) {
        $s_cat = implode(', ', $t_cat);
        $t_cat = array();
        $sql = "select * from " . CATEGORIES_TABLE . " where cat_id in ({$s_cat})";
        if (!($result = $db->sql_query($sql))) {
            message_die(GENERAL_ERROR, "Couldn't obtain category list.", "", __LINE__, __FILE__, $sql);
        }
        while ($row = $db->sql_fetchrow($result)) {
            if (!in_array($row['cat_main'], $catlist)) {
                $catlist[] = $row['cat_main'];
                $t_cat[] = $row['cat_main'];
            }
        }
    }
    // read cat sorted
    $catrows = array();
    get_auth_cat_order($catrows, $catlist);
    return $catrows;
}