track_field_changes.install in Track Field Changes 7
Same filename and directory in other branches
The Track Field Changes install.
File
track_field_changes.installView source
<?php
/**
* @file
* The Track Field Changes install.
*/
/**
* Implements hook_uninstall().
*/
function track_field_changes_uninstall() {
// Clear variables.
variable_del('track_field_changes_node_types');
foreach (node_type_get_types() as $type => $content_type) {
variable_del("track_field_changes_enable_log_{$type}");
variable_del("track_field_changes_basic_new_{$type}");
variable_del("track_field_changes_basic_revision_{$type}");
variable_del("track_field_changes_track_revision_fields_{$type}");
}
}
/**
* Implements hook_schema().
*/
function track_field_changes_schema() {
$schema['track_field_changes_audit'] = array(
'description' => 'Mark wich field need to be audited',
'fields' => array(
'nid' => array(
'description' => 'The {node}.nid this record tracks.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'timestamp' => array(
'description' => 'The Unix timestamp when the change has been created',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'uid' => array(
'description' => '',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'field_name' => array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'description' => 'The name of this field.',
),
'before_value_text' => array(
'description' => '',
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
),
'after_value_text' => array(
'description' => '',
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
),
'type' => array(
'description' => '',
'type' => 'varchar',
'length' => 8,
'not null' => TRUE,
'default' => '',
),
'log' => array(
'description' => '',
'type' => 'varchar',
'length' => 256,
'not null' => TRUE,
'default' => '',
),
),
'indexes' => array(
'track_field_changes' => array(
'nid',
'field_name',
),
),
);
$schema['track_field_changes'] = array(
'fields' => array(
'field_name' => array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'entity_type' => array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'bundle' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
),
),
'indexes' => array(
'track_field_changes' => array(
'field_name',
'bundle',
),
),
'primary key' => array(
'field_name',
'bundle',
),
);
return $schema;
}
/**
* Add a comment column to track field changes.
*/
function track_field_changes_update_7001() {
$log = array(
'type' => 'varchar',
'length' => 256,
'not null' => TRUE,
'default' => '',
);
db_add_field('track_field_changes_audit', 'log', $log);
$type = array(
'type' => 'varchar',
'length' => 8,
'not null' => TRUE,
'default' => '',
);
db_add_field('track_field_changes_audit', 'type', $type);
}
Functions
Name | Description |
---|---|
track_field_changes_schema | Implements hook_schema(). |
track_field_changes_uninstall | Implements hook_uninstall(). |
track_field_changes_update_7001 | Add a comment column to track field changes. |