You are here

function tca_node_node_insert in Token Content Access 7

Implements hook_node_insert().

File

tca_node/tca_node.module, line 115
Main module file for Token Content Access nodes module.

Code

function tca_node_node_insert($node) {
  if (tca_get_active_entity('node', $node)) {
    $node->tca_token = tca_get_token('node', $node, $value = '');
    db_update('node')
      ->fields(array(
      'tca_token' => $node->tca_token,
    ))
      ->condition('nid', $node->nid)
      ->execute();
    if (user_access('administer tca_node')) {
      $token_url = url('node/' . $node->nid, array(
        'absolute' => TRUE,
        'query' => array(
          'tca' => $node->tca_token,
        ),
      ));
      drupal_set_message(t('URL to bypass Token Access Control for this item: @token', array(
        '@token' => $token_url,
      )));
    }
  }
}