You are here

public static function wf_crm_webform_ajax::autocompleteAccess in Webform CiviCRM Integration 7.4

Same name and namespace in other branches
  1. 7.5 includes/wf_crm_webform_ajax.inc \wf_crm_webform_ajax::autocompleteAccess()

Access callback. Check if user has permission to view autocomplete results.

Parameters

stdClass $node:

int $fid: Webform component id

Return value

bool

2 calls to wf_crm_webform_ajax::autocompleteAccess()
webform_civicrm_webform_autocomplete_options_alter in ./webform_civicrm.module
Implements hook_webform_autocomplete_options()
wf_crm_webform_ajax::contactAjax in includes/wf_crm_webform_ajax.inc
Load one or more contacts via ajax

File

includes/wf_crm_webform_ajax.inc, line 172

Class

wf_crm_webform_ajax

Code

public static function autocompleteAccess($node, $fid) {
  global $user;
  if (!$fid || empty($node->webform_civicrm)) {
    return FALSE;
  }
  if (empty($node->webform['components'][$fid]) || !node_access('view', $node)) {
    return FALSE;
  }
  if ($user->uid === 1 || webform_results_access($node)) {
    return TRUE;
  }
  if (!empty($node->webform['components'][$fid]['private'])) {
    return FALSE;
  }
  if (variable_get('webform_submission_access_control', 1)) {
    $allowed_roles = array();
    foreach ($node->webform['roles'] as $rid) {
      $allowed_roles[$rid] = isset($user->roles[$rid]) ? TRUE : FALSE;
    }
    if (array_search(TRUE, $allowed_roles) === FALSE) {
      return FALSE;
    }
  }
  return TRUE;
}