if(!check_perms('site_torrents_notify')) { error(403); } define('NOTIFICATIONS_PER_PAGE', 50); list($Page,$Limit) = Format::page_limit(NOTIFICATIONS_PER_PAGE); $UserID = $LoggedUser['ID']; $Results = $DB->query("SELECT SQL_CALC_FOUND_ROWS unt.TorrentID, unt.UnRead, unt.FilterID, unf.Label, t.GroupID FROM users_notify_torrents AS unt JOIN torrents AS t ON t.ID = unt.TorrentID LEFT JOIN users_notify_filters AS unf ON unf.ID = unt.FilterID WHERE unt.UserID=$UserID". ((!empty($_GET['filterid']) && is_number($_GET['filterid'])) ? " AND unf.ID='$_GET[filterid]'" : "")." ORDER BY TorrentID DESC LIMIT $Limit"); $GroupIDs = array_unique($DB->collect('GroupID')); $DB->query('SELECT FOUND_ROWS()'); list($TorrentCount) = $DB->next_record(); $Debug->log_var($TorrentCount, 'Torrent count'); $Pages = Format::get_pages($Page, $TorrentCount, NOTIFICATIONS_PER_PAGE, 9); if(count($GroupIDs)) { $TorrentGroups = Torrents::get_groups($GroupIDs); $TorrentGroups = $TorrentGroups['matches']; // Need some extra info that Torrents::get_groups() doesn't return $DB->query("SELECT ID, CategoryID FROM torrents_group WHERE ID IN (".implode(',', $GroupIDs).")"); $GroupCategoryIDs = $DB->to_array('ID', MYSQLI_ASSOC, false); //Clear before header but after query so as to not have the alert bar on this page load $DB->query("UPDATE users_notify_torrents SET UnRead='0' WHERE UserID=".$LoggedUser['ID']); $Cache->delete_value('notifications_new_'.$LoggedUser['ID']); } View::show_header('My notifications', 'notifications'); $DB->set_query_id($Results); ?>
No new notifications found! Edit notification filters |