content_access.install in Content Access 6
File
content_access.install
View source
<?php
function content_access_install() {
drupal_install_schema('content_access');
}
function content_access_uninstall() {
variable_del('content_access_settings');
drupal_uninstall_schema('content_access');
}
function content_access_schema() {
$schema['content_access'] = array(
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'settings' => array(
'type' => 'text',
'not null' => FALSE,
'size' => 'medium',
),
),
'primary key' => array(
'nid',
),
);
return $schema;
}
function content_access_update_6001() {
drupal_load('module', 'content_access');
module_load_include('inc', 'content_access', 'content_access.admin');
$permissions = content_access_get_permissions_by_role();
$settings = content_access_get_settings();
foreach (node_get_types('names') as $type => $type_name) {
foreach (array(
'update',
'delete',
) as $op) {
foreach (content_access_get_settings($op, $type) as $rid => $value) {
if (is_numeric($rid)) {
$permissions[$rid][content_access_get_permission_by_op($op, $type)] = TRUE;
}
else {
if ($rid == 'author') {
$permissions[DRUPAL_AUTHENTICATED_RID][content_access_get_permission_by_op($op . '_own', $type)] = TRUE;
}
}
}
unset($settings[$op][$type]);
}
}
content_access_save_permissions($permissions);
content_access_set_settings($settings);
node_access_needs_rebuild(TRUE);
return array();
}