Esempio n. 1
0
function folder_get($fid)
{
    if (!($db = db::get())) {
        return false;
    }
    if (!is_numeric($fid)) {
        return false;
    }
    if (!($table_prefix = get_table_prefix())) {
        return false;
    }
    if (!isset($_SESSION['UID']) || !is_numeric($_SESSION['UID'])) {
        return false;
    }
    $sql = "SELECT FOLDER.FID, FOLDER.TITLE, FOLDER.DESCRIPTION, FOLDER.POSITION, ";
    $sql .= "FOLDER.PREFIX, FOLDER.ALLOWED_TYPES, FOLDER.PERM, USER_FOLDER.INTEREST ";
    $sql .= "FROM `{$table_prefix}FOLDER` FOLDER ";
    $sql .= "LEFT JOIN `{$table_prefix}USER_FOLDER` USER_FOLDER ";
    $sql .= "ON (USER_FOLDER.FID = FOLDER.FID AND USER_FOLDER.UID = '{$_SESSION['UID']}') ";
    $sql .= "WHERE FOLDER.FID = '{$fid}' GROUP BY FOLDER.FID, FOLDER.TITLE";
    if (!($result = $db->query($sql))) {
        return false;
    }
    if ($result->num_rows == 0) {
        return false;
    }
    $folder_array = $result->fetch_assoc();
    $folder_array['THREAD_COUNT'] = folder_get_thread_count($fid);
    return $folder_array;
}
Esempio n. 2
0
function thread_get_folder($tid, $thread_count = true)
{
    if (!($db = db::get())) {
        return false;
    }
    if (!is_numeric($tid)) {
        return false;
    }
    if (!($table_prefix = get_table_prefix())) {
        return false;
    }
    if (!isset($_SESSION['UID']) || !is_numeric($_SESSION['UID'])) {
        return false;
    }
    $sql = "SELECT FOLDER.FID, FOLDER.TITLE, FOLDER.DESCRIPTION, FOLDER.POSITION, FOLDER.PREFIX, ";
    $sql .= "FOLDER.ALLOWED_TYPES, FOLDER.PERM, USER_FOLDER.INTEREST FROM `{$table_prefix}FOLDER` FOLDER ";
    $sql .= "INNER JOIN `{$table_prefix}THREAD` THREAD ON (THREAD.FID = FOLDER.FID) ";
    $sql .= "LEFT JOIN `{$table_prefix}USER_FOLDER` USER_FOLDER ON (USER_FOLDER.FID = FOLDER.FID ";
    $sql .= "AND USER_FOLDER.UID = '{$_SESSION['UID']}') WHERE THREAD.TID = '{$tid}' ";
    $sql .= "GROUP BY FOLDER.FID, FOLDER.TITLE";
    if (!($result = $db->query($sql))) {
        return false;
    }
    if ($result->num_rows == 0) {
        return false;
    }
    $folder_data = $result->fetch_assoc();
    if ($thread_count) {
        $folder_data['THREAD_COUNT'] = folder_get_thread_count($folder_data['FID']);
    }
    return $folder_data;
}