} else {
    if (isset($_GET['search_keyword']) && strlen(trim($_GET['search_keyword'])) > 0) {
        $search_keyword = trim($_GET['search_keyword']);
    } else {
        $search_keyword = '';
    }
}
if (isset($_POST['clear'])) {
    $search_keyword = '';
}
$header_text_array = array(FOLDER_IGNORED => gettext("Ignored Folders"), FOLDER_SUBSCRIBED => gettext("Subscribed Folders"));
$interest_level_array = array(FOLDER_IGNORED => gettext("Ignored"), FOLDER_SUBSCRIBED => gettext("Subscribed"));
if (isset($search_keyword) && strlen(trim($search_keyword)) > 0) {
    $folder_subscriptions = folders_search_user_subscriptions($search_keyword, $view, $page);
} else {
    $folder_subscriptions = folders_get_user_subscriptions($view, $page);
}
html_draw_top(array('title' => sprintf(gettext('My Controls - Folder Subscriptions - %s'), $header_text_array[$view]), 'js' => array('js/edit_subscriptions.js', 'js/prefs.js'), 'class' => 'window_title'));
echo "<h1>", gettext("Folder Subscriptions"), html_style_image('separator'), "{$header_text_array[$view]}</h1>\n";
if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
    html_display_error_array($error_msg_array, '700', 'left');
} else {
    if (isset($_GET['updated'])) {
        html_display_success_msg(gettext("Folder interests updated successfully"), '700', 'left');
    } else {
        if (sizeof($folder_subscriptions['folder_array']) < 1) {
            if (isset($search_keyword) && strlen(trim($search_keyword)) > 0) {
                html_display_warning_msg(gettext("Search Returned No Results"), '700', 'left');
            } else {
                if ($view == FOLDER_IGNORED) {
                    html_display_warning_msg(gettext("You are not ignoring any folders."), '700', 'left');
Example #2
0
function folders_get_user_subscriptions($interest_type = FOLDER_NOINTEREST, $page = 1)
{
    if (!($db = db::get())) {
        return false;
    }
    if (!isset($_SESSION['UID']) || !is_numeric($_SESSION['UID'])) {
        return false;
    }
    if (!is_numeric($page)) {
        $page = 1;
    }
    if (!is_numeric($interest_type)) {
        $interest_type = FOLDER_NOINTEREST;
    }
    $offset = calculate_page_offset($page, 20);
    if (!($table_prefix = get_table_prefix())) {
        return false;
    }
    $folder_subscriptions_array = array();
    $folders = folder_get_available();
    if ($interest_type != FOLDER_NOINTEREST) {
        $sql = "SELECT SQL_CALC_FOUND_ROWS FOLDER.FID, FOLDER.TITLE, ";
        $sql .= "USER_FOLDER.INTEREST 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 USER_FOLDER.INTEREST = '{$interest_type}' ";
        $sql .= "AND FOLDER.FID IN ({$folders}) ";
        $sql .= "ORDER BY FOLDER.POSITION DESC ";
        $sql .= "LIMIT {$offset}, 20";
    } else {
        $sql = "SELECT SQL_CALC_FOUND_ROWS FOLDER.FID, FOLDER.TITLE, ";
        $sql .= "USER_FOLDER.INTEREST 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 IN ({$folders}) ";
        $sql .= "ORDER BY FOLDER.POSITION DESC ";
        $sql .= "LIMIT {$offset}, 20";
    }
    if (!($result = $db->query($sql))) {
        return false;
    }
    $sql = "SELECT FOUND_ROWS() AS ROW_COUNT";
    if (!($result_count = $db->query($sql))) {
        return false;
    }
    list($folder_subscriptions_count) = $result_count->fetch_row();
    if ($result->num_rows == 0 && $folder_subscriptions_count > 0 && $page > 1) {
        return folders_get_user_subscriptions($interest_type, $page - 1);
    }
    while (($folder_data_array = $result->fetch_assoc()) !== null) {
        $folder_subscriptions_array[] = $folder_data_array;
    }
    return array('folder_count' => $folder_subscriptions_count, 'folder_array' => $folder_subscriptions_array);
}