You are here

function _pm_permission_get_field_name in Drupal PM (Project Management) 8

Same name and namespace in other branches
  1. 7.3 includes/pm.permission.inc \_pm_permission_get_field_name()

A helper function to check if a field is present in a node.

Parameters

string $bundle_name: Node bundle machine name.

string $category: Category of permission {pm, assigned, parent}.

Return value

string The actual name of the field if present, false otherwise.

4 calls to _pm_permission_get_field_name()
pm_node_access_records in ./pm.module
Implements hook_node_access_records().
pm_permission_get_parent_nid_of_node in includes/pm.permission.inc
Recursively hunts and find out the first parent node of given type.
pm_permission_grants_list in includes/pm.permission.inc
Helper function for pm_permission_node_grants.
pm_permission_permission_per_bundle in includes/pm.permission.inc
Creates an array of permission name for the given node bundle.

File

includes/pm.permission.inc, line 327
Main module file for the pm_permission module.

Code

function _pm_permission_get_field_name($bundle_name, $category) {
  switch ($category) {
    case 'parent':
      $field_name = variable_get("pm_permission_field_parent_reference_for_{$bundle_name}", FALSE);
      break;
    case 'assigned':
      $field_name = variable_get("pm_permission_field_assigned_reference", FALSE);
      break;
    case 'pm':
      $field_name = variable_get("pm_permission_field_pm_reference", FALSE);
      break;
    default:
      $field_name = FALSE;
      break;
  }
  if ($field_name and field_info_instance('node', $field_name, $bundle_name)) {
    return $field_name;
  }
  return FALSE;
}