function group_stories($requestID, $catId, $view, $flag = 0) { global $db, $main_smarty, $the_template, $page_size, $cached_links; if (!is_numeric($requestID)) { die; } $link = new Link(); $group_new_display = ""; $group_published_display = ""; if ($catId) { $child_cats = ''; // do we also search the subcategories? if (Independent_Subcategories == true) { $child_array = ''; // get a list of all children and put them in $child_array. children_id_to_array($child_array, table_categories, $catId); if ($child_array != '') { // build the sql foreach ($child_array as $child_cat_id) { $child_cat_sql .= ' OR `link_category` = ' . $child_cat_id . ' '; if (Multiple_Categories) { $child_cat_sql .= ' OR ac_cat_id = ' . $child_cat_id . ' '; } } } } if (Multiple_Categories) { $child_cat_sql .= " OR ac_cat_id = {$catId} "; } $from_where .= " AND (link_category={$catId} " . $child_cat_sql . ")"; } $group_vote = group_check_to_publish($requestID); if ($view == 'new') { $from_where .= " AND link_votes<{$group_vote} AND link_status='new'"; } else { $from_where .= " AND ((link_votes >= {$group_vote} AND link_status = 'new') OR link_status = 'published')"; } $offset = (get_current_page() - 1) * $page_size; if ($flag == 1) { $sql = "SELECT SQL_CALC_FOUND_ROWS * FROM " . table_links . " WHERE link_group_id = {$requestID} AND link_group_status!='discard' {$from_where} GROUP BY link_id ORDER BY link_published_date DESC, link_date DESC "; } else { $sql = "SELECT SQL_CALC_FOUND_ROWS * FROM " . table_links . " WHERE link_group_id = {$requestID} AND link_group_status!='discard' {$from_where} GROUP BY link_id ORDER BY link_published_date DESC, link_date DESC LIMIT {$offset}, {$page_size}"; } // Search on additional categories if ($catId && Multiple_Categories) { $sql = str_replace("WHERE", " LEFT JOIN " . table_additional_categories . " ON ac_link_id=link_id WHERE", $sql); } $links = $db->get_results($sql); $rows = $db->get_var("SELECT FOUND_ROWS()"); if ($flag == 1) { return $rows; } if ($links) { foreach ($links as $dblink) { $link->id = $dblink->link_id; $cached_links[$dblink->link_id] = $dblink; $link->read(); $group_display .= $link->print_summary('summary', true); } } $main_smarty->assign('group_display', $group_display); //for auto scrolling if (Auto_scroll == 2 || Auto_scroll == 3) { $main_smarty->assign("scrollpageSize", $page_size); $main_smarty->assign('total_row', $rows); $main_smarty->assign("group_vote", $group_vote); if ($catId) { $main_smarty->assign('catID', $catId); } } else { $main_smarty->assign('group_story_pagination', do_pages($rows, $page_size, 'group_story', true)); } }
function group_stories($requestID) { global $db, $main_smarty, $the_template, $page_size, $cached_links; if (!is_numeric($requestID)) { die; } $link = new Link(); $group_upcoming_display = ""; $group_published_display = ""; $rows = $db->get_var("SELECT COUNT(link_id) FROM " . table_links . " WHERE link_group_id = {$requestID}"); $links = $db->get_results("SELECT * FROM " . table_links . " WHERE link_group_id = {$requestID}"); if ($links) { foreach ($links as $dblink) { $link->id = $dblink->link_id; $cached_links[$dblink->link_id] = $dblink; $link->read(); $to_publish = group_check_to_publish($requestID); if ($link->votes >= $to_publish) { $group_published_display .= $link->print_summary('summary', true); } else { $group_upcoming_display .= $link->print_summary('summary', true); } } } $main_smarty->assign('group_upcoming_display', $group_upcoming_display); $main_smarty->assign('group_published_display', $group_published_display); $main_smarty->assign('group_story_pagination', do_pages($rows, $page_size, 'group_story', true)); }