You are here

function _pm_permission_grants_assigned in Drupal PM (Project Management) 7.3

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

Generate grants for assigned permission set.

1 call to _pm_permission_grants_assigned()
pm_node_access_records in ./pm.module
Implements hook_node_access_records().

File

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

Code

function _pm_permission_grants_assigned($node, $type, $assigned) {

  // PM permission $type: view own %assigned.
  $assigned_nids = _pm_permission_get_assigned_id($node, $type, $assigned);
  $grants = array();
  if ($assigned_nids) {
    foreach ($assigned_nids as $assigned_nid) {
      if ($assigned_nid) {
        $grants[] = array(
          'realm' => "pm_permission_{$type}_view_assigned_{$assigned}",
          'gid' => $assigned_nid,
          'grant_view' => 1,
          'grant_update' => 0,
          'grant_delete' => 0,
          'priority' => 0,
        );
        $grants[] = array(
          'realm' => "pm_permission_{$type}_update_assigned_{$assigned}",
          'gid' => $assigned_nid,
          'grant_view' => 0,
          'grant_update' => 1,
          'grant_delete' => 0,
          'priority' => 0,
        );
        $grants[] = array(
          'realm' => "pm_permission_{$type}_delete_assigned_{$assigned}",
          'gid' => $assigned_nid,
          'grant_view' => 0,
          'grant_update' => 0,
          'grant_delete' => 1,
          'priority' => 0,
        );
      }
    }
  }
  return $grants;
}