You are here

function pmpapi_permissions_set_node_permissions in Public Media Platform API Integration 7

Creates a PMP permission object from fields, then attaches it to the node object in the form.

$form array An entity CRUD form array.

$form_state array The current state of the form

File

pmpapi_permissions/pmpapi_permissions.module, line 231

Code

function pmpapi_permissions_set_node_permissions($form, &$form_state) {
  $entity_type = 'node';
  $group = !empty($form_state['values']['pmpapi_permissions_group']) ? $form_state['values']['pmpapi_permissions_group'] : NULL;
  $permission = pmp_permissions_create_permission($group);
  if ($permission !== NULL) {
    $form_state[$entity_type]->pmpapi_permissions = array(
      $permission,
    );
  }
  else {
    unset($form_state[$entity_type]->pmpapi_permissions);
  }
  $form_state[$entity_type]->pmpapi_permissions_added = TRUE;
}