From b70b0951a486d7ec8e0e76fada5dc7b20e64d674 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Tue, 30 Jul 2013 07:54:51 +0000 Subject: [PATCH] 2013-07-30 Sergio Martin * godmode/groups/group_list.php: Fix pagination on manage groups view git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8593 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 5 +++ pandora_console/godmode/groups/group_list.php | 41 +++++++++---------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index d5d19e32e7..d0cacb0c9b 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2013-07-30 Sergio Martin + + * godmode/groups/group_list.php: Fix pagination on + manage groups view + 2013-07-29 Miguel de Dios * include/functions_api.php: a lot of tiny fixes. diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index 44177296d3..13446f13e5 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -283,43 +283,40 @@ if (!empty($groups)) { //Set the content of page of groups $offset = (int)get_parameter('offset', 0); $count_visible_groups = 0; - $count_visible_groups_block = 0; - $stop_count_block = false; $count = 0; $start = 0; $stop = 0; - //$offset = $offset - $offset / $config['block_size']; + + // Do the pagination manually to show the N first groups of first level (parent=0) + // TODO: Do it better. Maybe with ajax like tree view foreach ($groups as $group) { if (((int)$group['parent']) == 0) { $count_visible_groups++; - if (!$stop_count_block) - $count_visible_groups_block++; + + if (($count_visible_groups - 1) == $offset) { + $start = $count; + if ($offset > 0) { + $start++; + } + } + + if (($count_visible_groups - 1) == ($config['block_size'] + $offset)) { + $stop = $count; + } } - - if (($count_visible_groups - 1) == ($offset) ) { - $stop_count_block = true; - $start = $count; - } - - // -1 for in the all pages is added all group - if (($count_visible_groups - 1) == ($offset + ($config['block_size'] - 1))) { - $stop_count_block = true; - $stop = $count; - } - + $count++; } if ($stop == 0) { - $stop = $start + $config['block_size']; + $stop = $start + $config['block_size'] + 1; } - + // 1 for to add all group - ui_pagination($count_visible_groups + 1, false, 0, $config['block_size'] - 1); - + ui_pagination($count_visible_groups + 1, false, 0, $config['block_size']); $groups = array_slice($groups, $start, ($stop - $start)); $groups = array_merge(array($all_group), $groups); - + foreach ($groups as $id_group => $group) { if ($group['deep'] == 0) { $table->rowstyle[$iterator] = '';