You are here

function _pm_permission_grants_belonged in Drupal PM (Project Management) 8

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

Generate grants for belonged permission set.

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

File

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

Code

function _pm_permission_grants_belonged($node, $type, $belonged) {

  // PM permission $type: view own %belonged.
  $belonged_nid = _pm_permission_get_belonged_id($node, $type, $belonged);
  $grants = array();
  if ($belonged_nid) {
    $grants[] = array(
      'realm' => "pm_permission_{$type}_view_belonged_{$belonged}",
      'gid' => $belonged_nid,
      'grant_view' => 1,
      'grant_update' => 0,
      'grant_delete' => 0,
      'priority' => 0,
    );
    $grants[] = array(
      'realm' => "pm_permission_{$type}_update_belonged_{$belonged}",
      'gid' => $belonged_nid,
      'grant_view' => 0,
      'grant_update' => 1,
      'grant_delete' => 0,
      'priority' => 0,
    );
    $grants[] = array(
      'realm' => "pm_permission_{$type}_delete_belonged_{$belonged}",
      'gid' => $belonged_nid,
      'grant_view' => 0,
      'grant_update' => 0,
      'grant_delete' => 1,
      'priority' => 0,
    );
  }
  return $grants;
}