Newer
Older
* Install, update and uninstall functions for the Linkit module.
/**
* Implements hook_schema().
*/
function linkit_schema() {
$schema = array();
$schema['linkit_profiles'] = array(
'description' => 'Base table holding Linkit profiles.',
'export' => array(
'key' => 'name',
'key name' => 'Name',
'primary key' => 'pid',
'identifier' => 'linkit_profile',
'default hook' => 'default_linkit_profile',
'load callback' => 'linkit_profile_load',
'load all callback' => 'linkit_profile_load_all',
'save callback' => 'linkit_profile_save',
'minimum_version' => 1,
'current_version' => 1,
),
),
'fields' => array(
'pid' => array(
'description' => 'Serial id for this profile.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'no export' => TRUE,
),
'name' => array(
bratanon
committed
'description' => 'Machine-readable name for this profile.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
),
'description' => 'Administrative title for this profile.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
),
'data' => array(
'type' => 'text',
'size' => 'big',
bratanon
committed
'description' => 'A serialized array with settings.',
'role_rids' => array(
'type' => 'text',
'size' => 'big',
'description' => 'A serialized array with role rids that is assign to this profile.',
),
'description' => 'Profile weight.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
bratanon
committed
'primary key' => array('pid'),
'unique keys' => array(
'name' => array('name'),
),
* Implements hook_uninstall().
Emil Stjerneman
committed
}
/**
* Create the {linkit_profiles} table if it not exists.
*/
function linkit_update_7200() {
if (!db_table_exists('linkit_profiles')) {
// Call the schema function to reduce the lines of code here.
$schema = linkit_schema();
// Create the table.
db_create_table('linkit_profiles', $schema['linkit_profiles']);
return t('The table {linkit_profiles} was successfully created.');
}
}
/**
* Delete old linkit settings.
*/
function linkit_update_7201() {
// Delete old settings if any.
$num_deleted = db_delete('variable')
->condition('name', array('linkit_node', 'linkit_term'), 'IN')
->execute();
// No old settings deleted
if(!$num_deleted) {
return t("No old Linkit settings were deleted.");
Emil Stjerneman
committed
}
else {
return t("Old Linkit settings were deleted.");
Emil Stjerneman
committed
}