sbp_paths.install in Search by Page 7
Same filename and directory in other branches
Install hooks for sbp_paths module
File
sbp_paths.installView source
<?php
/**
* @file
* Install hooks for sbp_paths module
*/
/**
* Implements hook_schema().
*/
function sbp_paths_schema() {
$schema['sbpp_path'] = array(
'description' => 'Contains paths to be indexed by sbp_paths module',
'fields' => array(
'pid' => array(
'description' => 'Primary key',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'environment' => array(
'description' => 'Environment ID',
'type' => 'int',
'size' => 'big',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
// Do not use 'path' as a db field - reserved word!
'page_path' => array(
'description' => 'Path to index',
'type' => 'varchar',
'length' => 255,
),
'title' => array(
'description' => 'Title of this page',
'type' => 'varchar',
'length' => 255,
),
// Do not use 'type' as a db field - reserved word!
'page_type' => array(
'description' => 'Type to display for this page',
'type' => 'varchar',
'length' => 255,
),
'snippet' => array(
'description' => 'Yes, no, or some custom snippet text',
'type' => 'text',
'size' => 'medium',
),
'role' => array(
'description' => 'Role ID used to index this path',
'type' => 'int',
'size' => 'big',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'languages' => array(
'description' => 'Serialized array of languages that can be used for this path',
'type' => 'text',
),
),
'indexes' => array(
'pth' => array(
'page_path',
),
'ttl' => array(
'title',
),
'envi' => array(
'environment',
),
),
'primary key' => array(
'pid',
),
);
return $schema;
}
/**
* Implements hook_update_N().
*
* Adds languages, environment, and uname fields to sbpp_path table.
*/
function sbp_paths_update_6000() {
db_add_field('sbpp_path', 'languages', array(
'description' => 'Serialized array of languages that can be used for this path',
'type' => 'text',
));
db_add_field('sbpp_path', 'environment', array(
'description' => 'Environment ID',
'type' => 'int',
'size' => 'big',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
));
db_add_index('sbpp_path', 'envi', array(
'environment',
));
db_add_field('sbpp_path', 'uname', array(
'description' => 'User name used to index this path',
'type' => 'varchar',
'length' => '60',
));
// Set default for languages and environment
$lang = language_default('language');
$val = serialize(array(
$lang => $lang,
));
db_update('sbpp_path')
->fields(array(
'languages' => $val,
'environment' => 1,
))
->execute();
}
/**
* Implements hook_update_N().
*
* Removes uname field, adds role field.
*/
function sbp_paths_update_6001() {
db_drop_field('sbpp_path', 'uname');
db_add_field('sbpp_path', 'role', array(
'description' => 'Role ID used to index this path',
'type' => 'int',
'size' => 'big',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => DRUPAL_ANONYMOUS_RID,
));
}
Functions
Name | Description |
---|---|
sbp_paths_schema | Implements hook_schema(). |
sbp_paths_update_6000 | Implements hook_update_N(). |
sbp_paths_update_6001 | Implements hook_update_N(). |