// Show suscribed } $char_selected = $chars = false; // User for index by first letter do_header(_("subs menéame"), 'm/'); print_tabs($option); /*** SIDEBAR ****/ echo '<div id="sidebar">'; do_banner_right(); do_banner_promotions(); echo '</div>'; /*** END SIDEBAR ***/ echo '<div id="newswrap">'; switch ($option) { case 0: $subs = SitesMgr::get_subscriptions($current_user->user_id); $template = 'subs_simple.html'; $all = false; break; case 1: $all = false; $template = 'subs.html'; $sql = "select subs.*, user_id, user_login, user_avatar, count(*) as c from subs LEFT JOIN users ON (user_id = owner), sub_statuses where date > date_sub(now(), interval 5 day) and subs.id = sub_statuses.id and sub_statuses.id = sub_statuses.origen and sub_statuses.status = 'published' and subs.sub = 1 group by subs.id order by c desc limit 50"; $subs = $db->get_results($sql); break; default: $all = true; $chars = $db->get_col("select distinct(left(ucase(name), 1)) from subs"); // Check if we must show just those beginning with a letter if (!empty($_GET['c']) && ($char_selected = substr(clean_input_string($_GET['c']), 0, 1))) { $extra = "subs.name like '{$char_selected}%' and";
function print_subs_form($selected = false) { global $db, $globals, $current_user; function id($s) { return $s->id; } if (!empty($globals['submnm'])) { $subs = false; } else { $subs = SitesMgr::get_sub_subs(); $ids = array_map('id', $subs); // A link in a sub is edited from another sub, or from the main site // Add its selected sub. if ($selected != false && !in_array($selected, $ids)) { $e = SitesMgr::get_info($selected); if ($e) { array_unshift($subs, $e); // Add to the form array_unshift($ids, $selected); // Avoid to show it again if subscribed to } } $extras = SitesMgr::get_subscriptions($current_user->user_id); // Don't repeat the same subs $subscriptions = array(); foreach ($extras as $s) { if (!in_array($s->id, $ids)) { $subscriptions[] = $s; } } } if ($selected == false) { $selected = SitesMgr::my_id(); } $vars = compact('selected', 'subs', 'subscriptions'); return Haanga::Load('form_subs.html', $vars); }