You are here

function _print_mail_access in Printer, email and PDF versions 7.2

Same name and namespace in other branches
  1. 5.4 print_mail/print_mail.module \_print_mail_access()
  2. 6 print_mail/print_mail.module \_print_mail_access()
  3. 7 print_mail/print_mail.module \_print_mail_access()
  4. 5.x print_mail/print_mail.module \_print_mail_access()

Access callback to check a combination of user_acess() and page access.

Parameters

string $permission: Permission required to view the page.

Return value

bool TRUE if the user has permission to view the page, FALSE otherwise

1 string reference to '_print_mail_access'
print_mail_menu in print_mail/print_mail.module
Implements hook_menu().

File

print_mail/print_mail.module, line 260
Displays Printer-friendly versions of Drupal pages.

Code

function _print_mail_access($permission) {
  $link = print_mail_print_link();
  $page_access = TRUE;
  $parts = explode('/', $_GET['q']);
  if ($parts[0] == $link['path']) {
    if (count($parts) > 1) {
      unset($parts[0]);
      $path = implode('/', $parts);
      if (ctype_digit($parts[1])) {
        if (drupal_lookup_path('source', $path)) {

          // This is a numeric alias.
          $path = drupal_get_normal_path($path);
        }
        else {

          // Normal nid.
          $path = 'node/' . $path;
        }
      }
      else {
        $path = drupal_get_normal_path($path);
      }

      // If the destination page is not accessible, don't show the form.
      if (!($router_item = menu_get_item($path)) || !$router_item['access']) {
        $page_access = FALSE;
      }
    }
  }
  return user_access($permission) && $page_access;
}