Exemple #1
0
function print_categories_checkboxes($user)
{
    global $db, $current_user;
    // Get selected categories
    $selected_set = $db->get_col("SELECT pref_value FROM prefs WHERE pref_user_id = {$user->id} and pref_key = 'category_" . SitesMgr::my_id() . "'");
    $selected = array();
    if ($selected_set) {
        foreach ($selected_set as $cat) {
            $selected[$cat] = true;
        }
    }
    $metas = SitesMgr::get_metas();
    $categories = array();
    foreach ($metas as $meta) {
        $categories[$meta->id] = SitesMgr::get_categories($meta->id);
        if ($selected) {
            // Check if all categories are selected for the current meta
            $all = true;
            foreach ($categories[$meta->id] as $sel) {
                if (!isset($selected[$sel->id])) {
                    $all = false;
                }
            }
            if ($all) {
                $selected[$meta->id] = true;
            }
        }
    }
    Haanga::Load('user/categories.html', compact('user', 'metas', 'categories', 'selected'));
}
Exemple #2
0
function print_categories_form($selected = 0)
{
    global $db, $dblang, $globals;
    $metas = SitesMgr::get_metas();
    foreach ($metas as &$meta) {
        $meta->categories = SitesMgr::get_categories($meta->id);
    }
    unset($meta);
    $vars = compact('selected', 'metas');
    return Haanga::Load('form_categories.html', $vars);
}
Exemple #3
0
function print_shakeit_tabs($option = -1)
{
    global $globals, $current_user, $db;
    $items = array();
    if ($current_user->has_personal) {
        $items[] = array('id' => 7, 'url' => 'shakeit.php', 'title' => _('personal'));
    }
    $items[] = array('id' => 1, 'url' => 'shakeit.php' . $globals['meta_skip'], 'title' => _('todas'));
    if (!$globals['mobile']) {
        $metas = SitesMgr::get_metas();
        if ($metas) {
            foreach ($metas as $meta) {
                $items[] = array('id' => 9999, 'url' => 'shakeit.php?meta=' . $meta->uri, 'selected' => $meta->id == $globals['meta_current'], 'title' => $meta->name);
            }
        }
    }
    $items[] = array('id' => 3, 'url' => 'shakeit.php?meta=_popular', 'title' => _('candidatas'));
    if ($current_user->user_id > 0) {
        $items[] = array('id' => 2, 'url' => 'shakeit.php?meta=_friends', 'title' => _('amigos'));
    }
    if (!$globals['bot']) {
        $items[] = array('id' => 5, 'url' => 'shakeit.php?meta=_discarded', 'title' => _('descartadas'));
    }
    // Print RSS teasers
    if (!$globals['mobile']) {
        switch ($option) {
            case 7:
                // Personalised, queued
                $feed = array("url" => "?status=queued&personal=" . $current_user->user_id, "title" => "");
                break;
            default:
                $feed = array("url" => "?status=queued&meta=" . $globals['meta_current'], "title" => "");
                break;
        }
    }
    $vars = compact('items', 'option', 'feed');
    return Haanga::Load('print_tabs.html', $vars);
}
Exemple #4
0
function print_index_tabs($option = -1)
{
    global $globals, $db, $current_user;
    if ($globals['mobile']) {
        return;
    }
    $items = array();
    if (isset($current_user->has_personal)) {
        $items[] = array('id' => 7, 'url' => '', 'title' => _('personal'));
    }
    $items[] = array('id' => 0, 'url' => $globals['meta_skip'], 'title' => _('todas'));
    $metas = SitesMgr::get_metas();
    if ($metas) {
        foreach ($metas as $meta) {
            $items[] = array('id' => 9999, 'url' => '?meta=' . $meta->uri, 'selected' => $meta->id == $globals['meta_current'], 'title' => $meta->name);
        }
    }
    // RSS teasers
    switch ($option) {
        case 7:
            // Personalised, published
            $feed = array("url" => "?personal=" . $current_user->user_id, "title" => _('categoría personalizadas'));
            break;
        default:
            $feed = array("url" => "?meta=" . $globals['meta_current'], "title" => "");
            break;
    }
    if ($current_user->user_id > 0) {
        $items[] = array('id' => 1, 'url' => '?meta=_friends', 'title' => _('amigos'));
    }
    $vars = compact('items', 'option', 'feed');
    return Haanga::Load('print_tabs.html', $vars);
}