You are here

function fillpdf_merge_pdf_access in FillPDF 6

Same name and namespace in other branches
  1. 7.2 fillpdf.module \fillpdf_merge_pdf_access()
  2. 7 fillpdf.module \fillpdf_merge_pdf_access()

Make sure the user has access to data they want to populate the PDF

1 call to fillpdf_merge_pdf_access()
fillpdf_merge_pdf in ./fillpdf.module
Constructs a page from scratch (pdf content-type) and sends it to the browser or saves it, depending on if a custom path is configured or not.

File

./fillpdf.module, line 441
Allows mappings of PDFs to site content

Code

function fillpdf_merge_pdf_access($nodes = array(), $webforms = array()) {
  if (user_access('administer pdfs') || user_access('publish all pdfs')) {
    return TRUE;
  }
  if (!user_access('publish own pdfs')) {
    return FALSE;
  }
  global $user;
  if (empty($webforms)) {
    foreach ($nodes as $node) {

      // own node?
      if (!node_access('view', $node) || $node->uid != $user->uid) {
        return FALSE;
      }
    }
  }
  else {
    foreach ($webforms as $webform) {

      // In this case, we only care that they can view the Webform
      if (!node_access('view', node_load($webform['webform']->nid))) {
        return FALSE;
      }
    }
  }

  // Own webform submission?
  if (!empty($webforms)) {
    if (!($user->uid && (user_access('access own webform submissions') || user_access('access webform results') || user_access('access webform submissions')))) {
      return FALSE;
    }
    foreach ($webforms as $webform) {
      if (!webform_submission_access($webform['webform'], $webform['submission'], 'view')) {
        return FALSE;
      }
    }
  }
  return TRUE;
}