function nodeaccess_node_type in Nodeaccess 5
Same name and namespace in other branches
- 6.2 nodeaccess.module \nodeaccess_node_type()
- 6 nodeaccess.module \nodeaccess_node_type()
Implementation of hook_node_type().
File
- ./
nodeaccess.module, line 656
Code
function nodeaccess_node_type($op, $info) {
switch ($op) {
case 'delete':
// Node type is being deleted, delete its preferences.
variable_del('nodeaccess_' . $info->type);
$author_prefs = variable_get('nodeaccess_authors', array());
unset($author_prefs[$info->type]);
variable_set('nodeaccess_authors', $author_prefs);
break;
case 'update':
// 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);
}
break;
case 'insert':
// New node type, default to view for authenticated and
// anonymous users, and all permissions for author.
$grants[] = array(
'gid' => 1,
'realm' => 'nodeaccess_rid',
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
);
$grants[] = array(
'gid' => 2,
'realm' => 'nodeaccess_rid',
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
);
variable_set('nodeaccess_' . $info->type, $grants);
$author_prefs = variable_get('nodeaccess_authors', array());
$author_prefs[$info->type] = array(
'grant_view' => 1,
'grant_update' => 1,
'grant_delete' => 1,
);
variable_set('nodeaccess_authors', $author_prefs);
node_access_rebuild();
break;
}
}