You are here

function nodeaccess_node_type_update in Nodeaccess 7

Implements hook_node_type_update().

Parameters

Object $info:

File

./nodeaccess.module, line 772
Provide per node access control

Code

function nodeaccess_node_type_update($info) {

  // Node type has changed, move preferences to new type.
  if (!empty($info->old_type) && $info->old_type != $info->type) {
    $setting = variable_get('nodeaccess_' . $info->old_type, array());
    variable_del('nodeaccess_' . $info->old_type);
    variable_set('nodeaccess_' . $info->type, $setting);
    $author_prefs = variable_get('nodeaccess_authors', array());
    $author_prefs[$info->type] = array(
      'grant_view' => $author_prefs[$info->old_type]['grant_view'],
      'grant_update' => $author_prefs[$info->old_type]['grant_update'],
      'grant_delete' => $author_prefs[$info->old_type]['grant_delete'],
    );
    unset($author_prefs[$info->old_type]);
    variable_set('nodeaccess_authors', $author_prefs);
  }
}