Inoperative Next & Last Page UI navigation controls for Group Management

Issue #557 resolved
Grip Admin created an issue

Piler version 1.1.0, build 884

If there is more than one page of entries on the Group Management UI page (administration > groups) the Next and Last page navigation controls do nothing. Manually changing the URL to include &page=1 &page=2 (etc) displays subsequent pages of entries, as expected. The Previous and First Page controls function correctly on all pages.

Looking at the <div class="pagenav"> section in mailpiler/view/theme/default/templates/group/list.tpl, it appears that two variables used to determine the next/last controls contain unexpected values. The variables are $total_groups and $total_pages.

For example, we have 43 groups that span 3 pages ($page_len=20). When $page=0, $total_groups=1, $next_page=1, $total_pages=0 When $page=1, $total_groups=1, $next_page=2, $total_pages=0 When $page=2, $total_groups=1, $next_page=3, $total_pages=0

This obviously only affects the administrator and there is a manual work-around; no urgency to resolve.

Comments (4)

  1. Janos SUTO repo owner

    There's a bug in the related model. Apply the following diff against model/group/group.php, and it should be fixed:

    @@ -72,16 +72,16 @@ class ModelGroupGroup extends Model {
           $where_cond = "";
           $Q = array();
    
    -      $search = preg_replace("/\s{1,}/", "", $search) . '%';
    +      if($search) {
    +         $search = preg_replace("/\s{1,}/", "", $search) . '%';
    
    -      if($search){
              $where_cond .= " WHERE `groupname` like '?'";
              array_push($Q, $search);
           }
    
           $query = $this->db->query("SELECT COUNT(*) AS num FROM `" . TABLE_GROUP . "` $where_cond", $Q);
    
    -      return $query->num_rows;
    +      return $query->row['num'];
        }
    
  2. Grip Admin reporter

    Thanks, Janos. That works perfectly for the next page, previous page and first page controls. The last page control is still not a link, because $total_pages=0

  3. Janos SUTO repo owner

    Apply the following diff to fix it (sorry for the long time it took me):

    diff --git a/webui/controller/group/list.php b/webui/controller/group/list.php
    index b5c164a..0e34d8b 100644
    --- a/webui/controller/group/list.php
    +++ b/webui/controller/group/list.php
    @@ -74,7 +74,7 @@ class ControllerGroupList extends Controller {
           $this->data['prev_page'] = $this->data['page'] - 1;
           $this->data['next_page'] = $this->data['page'] + 1;
    
    -      $this->data['total_pages'] = floor($this->data['total_users'] / $this->data['page_len']);
    +      $this->data['total_pages'] = floor($this->data['total_groups'] / $this->data['page_len']);
    
    
           $this->render();
    
  4. Log in to comment