abt.install in Access By Term 7
abt.install Install, update and uninstall functions for the ABT module.
File
abt.installView source
<?php
/**
* @file abt.install
* Install, update and uninstall functions for the ABT module.
*/
/**
* Implements hook_uninstall().
*/
function abt_uninstall() {
$fields = field_read_fields(array(
'module' => 'taxonomy',
));
foreach ($fields as $field_name => $field) {
if (array_key_exists('abt_map', $field['settings'])) {
unset($field['settings']['abt_map']);
field_update_field($field);
}
}
}
/**
* Implements hook_enable().
*/
function abt_enable() {
drupal_set_message('Access by Term enabled. Do not forget to <a href="people/permissions">set the permissions</a>.');
}
function abt_update_7001() {
$schema['abt_map'] = array(
'description' => 'Holds the list of fieldnames which will control node access.',
'fields' => array(
'field_name' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'The field name.',
'translatable' => FALSE,
),
'ctrl_view_access' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Whether this field controls the view access.',
),
'ctrl_update_access' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Whether this field controls the update access.',
),
'ctrl_delete_access' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Whether this field controls the delete access.',
),
),
);
db_create_table('abt_map', $schema['abt_map']);
}
/**
* Convert from abt_map to field_config.
*/
function abt_update_7002() {
$access_map = db_select('abt_map', 'a')
->fields('a')
->execute();
while ($realm = $access_map
->fetchAssoc()) {
$field = field_info_field($realm['field_name']);
$field_abt_map = array(
'ctrl_view_access' => $realm['ctrl_view_access'],
'ctrl_update_access' => $realm['ctrl_update_access'],
'ctrl_delete_access' => $realm['ctrl_delete_access'],
);
$field['settings']['abt_map'] = $field_abt_map;
field_update_field($field);
}
db_drop_table('abt_map');
}
Functions
Name | Description |
---|---|
abt_enable | Implements hook_enable(). |
abt_uninstall | Implements hook_uninstall(). |
abt_update_7001 | |
abt_update_7002 | Convert from abt_map to field_config. |