function profile_sections_get_by_page($page = 1) { if (!($db = db::get())) { return false; } if (!is_numeric($page) || $page < 1) { $page = 1; } $offset = calculate_page_offset($page, 10); if (!($table_prefix = get_table_prefix())) { return false; } $profile_sections_array = array(); $sql = "SELECT SQL_CALC_FOUND_ROWS PROFILE_SECTION.PSID, PROFILE_SECTION.NAME, "; $sql .= "PROFILE_SECTION.POSITION, COUNT(PROFILE_ITEM.PIID) AS ITEM_COUNT "; $sql .= "FROM `{$table_prefix}PROFILE_SECTION` PROFILE_SECTION "; $sql .= "LEFT JOIN `{$table_prefix}PROFILE_ITEM` PROFILE_ITEM "; $sql .= "ON (PROFILE_ITEM.PSID = PROFILE_SECTION.PSID) "; $sql .= "GROUP BY PROFILE_SECTION.PSID "; $sql .= "ORDER BY PROFILE_SECTION.POSITION, PROFILE_SECTION.PSID "; $sql .= "LIMIT {$offset}, 10"; if (!($result = $db->query($sql))) { return false; } // Fetch the number of total results $sql = "SELECT FOUND_ROWS() AS ROW_COUNT"; if (!($result_count = $db->query($sql))) { return false; } list($profile_sections_count) = $result_count->fetch_row(); if ($result->num_rows == 0 && $profile_sections_count > 0 && $page > 1) { return profile_sections_get_by_page($page - 1); } while ($profile_data = $result->fetch_assoc()) { $profile_sections_array[] = $profile_data; } return array('profile_sections_array' => $profile_sections_array, 'profile_sections_count' => $profile_sections_count); }
echo " </table>\n"; echo " </td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td align=\"left\"> </td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td align=\"center\">", form_submit("editfeedsubmit", gettext("Save")), " ", form_submit("viewitems[{$psid}]", gettext("View items")), " ", form_submit("cancel", gettext("Back")), "</td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </form>\n"; echo "</div>\n"; html_draw_bottom(); } else { html_draw_top(array('title' => gettext('Admin - Manage Profile Sections'), 'class' => 'window_title', 'main_css' => 'admin.css')); $profile_sections = profile_sections_get_by_page($page); echo "<h1>", gettext("Admin"), html_style_image('separator'), gettext("Manage Profile Sections"), "</h1>\n"; if (isset($error_msg_array) && sizeof($error_msg_array) > 0) { html_display_error_array($error_msg_array, '86%', 'center'); } else { if (isset($_GET['added'])) { html_display_success_msg(gettext("Successfully added profile section"), '86%', 'center'); } else { if (isset($_GET['edited'])) { html_display_success_msg(gettext("Successfully edited profile section"), '86%', 'center'); } else { if (isset($_GET['deleted'])) { html_display_success_msg(gettext("Successfully removed selected profile sections"), '86%', 'center'); } else { if (sizeof($profile_sections['profile_sections_array']) < 1) { html_display_warning_msg(gettext("No existing profile sections found. To add a profile section click the 'Add New' button below."), '86%', 'center');