static function get_notification($id, $type) { global $db; $r = $db->get_var("select counter from notifications where user = {$id} and type = '{$type}'"); if ($r < 0) { User::reset_notification($id, $type); return 0; } return $r; }
static function get_unread($id) { global $db; $r = User::get_notification($id, 'private'); if (is_null($r)) { $r = (int) $db->get_var("select count(*) from privates where `to` = {$id} and `read` = 0"); User::reset_notification($id, 'private', $r); } return $r; }
static function get_unread_conversations($user = 0) { global $db, $globals, $current_user; $key = 'p_last_read'; if (!$user && $current_user->user_id > 0) { $user = $current_user->user_id; } $n = User::get_notification($user, 'post'); if (is_null($n)) { $last_read = intval($db->get_var("select pref_value from prefs where pref_user_id = {$user} and pref_key = '{$key}'")); $n = (int) $db->get_var("select count(*) from conversations where conversation_user_to = {$user} and conversation_type = 'post' and conversation_time > FROM_UNIXTIME({$last_read})"); User::reset_notification($user, 'post', $n); } return $n; }
$page_size = 50; $offset = (get_current_page() - 1) * $page_size; $page_title = _('mensajes privados') . ' | ' . _('menéame'); switch ($argv[1]) { case 'sent': $where = "privates.user = {$current_user->user_id}"; $order_by = "ORDER BY date desc"; $limit = "LIMIT {$offset},{$page_size}"; $view = 1; break; default: $where = "privates.to = {$current_user->user_id}"; $order_by = "ORDER BY date desc"; $limit = "LIMIT {$offset},{$page_size}"; $view = 0; User::reset_notification($current_user->user_id, 'private'); } $rows = $db->get_var("select count(*) from privates where {$where}"); do_header($page_title, _('privados'), get_posts_menu(5, $user->username)); $options = array(_('recibidos') => post_get_base_url('_priv'), _('enviados') => post_get_base_url('_priv') . '/sent'); do_priv_subheader($options, $view); /*** SIDEBAR ****/ echo '<div id="sidebar">'; do_banner_right(); //do_best_stories(); if ($rows > 20) { do_best_posts(); do_best_comments(); } echo '</div>' . "\n"; /*** END SIDEBAR ***/