When viewing a paged result set by a user who does not normally have permission to view the files, the pager is missing.

Example: Authenticated users have access to these nodes and anon users do not. I setup the filter (pretty awesome by the way).

Authenticated users see the results with a pager below.

Anonymous users see the results but the pager is missing.

Comments

crystaldawn’s picture

Yea I just discovered this one myself. It's going to require a patch to the views.inc file in order to fix it. Ideally I'd like to propose a new hook to the views project that allows modules to modify the pager query but I dont think that such a request would be accepted since it's a 'new feature' and drupal projects for some reason are afraid of 'new features' and would rather live with buggy things than with things that actually function properly. So for now here is how I fixed it for my own site:

To get the pager to show up for users that do not have access to the "administer nodes" rule, you need to modify the view.inc file on line 702
Line 702 starts with $count_query = db_rewrite_sql($this->build_info['count_query'], $this->base_table, $this->base_field, array('view' => &$this));
Simply add this right after line 702 in views/includes/view.inc

if (is_object($this->display[$this->current_display]->handler->handlers['filter']['ignore_node_permissions']))
{
$count_query = $this->build_info['count_query'];
}

This will fix users not being able to see the pager.

seehawk’s picture

Having the same issue.

Being able to bypass node permissions has been on the Views team's radar for at least a year:
http://drupal.org/node/548104
http://drupal.org/node/621142

So they might be receptive to a patch. Could be worth a try.

gooddesignusa’s picture

Darn this is a deal breaker for me :(
Keeping an eye on this issue.

David_Rothstein’s picture

Status: Active » Needs review
StatusFileSize
new1.31 KB

It shouldn't be necessary to hack Views to fix this issue. Can't we just fix it in this module?

The attached patch seems like it should work... I've tested it lightly combined with Views 6.x-2.16 and haven't seen any problems so far.

othermachines’s picture

Thanks, David. Works great for me.

Do we care to support versions < 6.x-2.14?

      if (method_exists($view, 'synchronize_pager')) {
        $view->synchronize_pager();
      }
      else {
        if (!empty($view->pager['use_pager'])) {
          // dump information about what we already know into the globals
          global $pager_page_array, $pager_total, $pager_total_items;
          // total rows in query
          $pager_total_items[$view->pager['element']] = $view->total_rows;
          // total pages
          $pager_total[$view->pager['element']] = ceil($pager_total_items[$view->pager['element']] / $view->pager['items_per_page']);

          // What page was requested:
          $pager_page_array = isset($_GET['page']) ? explode(',', $_GET['page']) : array();

          // If the requested page was within range. $this->pager['current_page']
          // defaults to 0 so we don't need to set it in an out-of-range condition.
          if (!empty($pager_page_array[$view->pager['element']])) {
            $page = intval($pager_page_array[$view->pager['element']]);
            if ($page > 0 && $page < $pager_total[$view->pager['element']]) {
              $view->pager['current_page'] = $page;
            }
          }
          $pager_page_array[$view->pager['element']] = $view->pager['current_page'];
        }
      }

(Snippet ganked from Views Bulk Operations' views_bulk_operations_pager_helper class.)

oskar_calvo’s picture

should be great a new version with the patch.

thanks

Oskar

othermachines’s picture

It's been a few weeks so I'm adding a revised patch that takes versions < 6.x-2.14 into account. Care to test, anyone?

oskar_calvo’s picture

I wll test it.

Thanks

Oskar