biblio_pm.install in Bibliography Module 7.2
Same filename and directory in other branches
Database table creation for biblio_pm module.
File
modules/pubmed/biblio_pm.installView source
<?php
/**
* @file
* Database table creation for biblio_pm module.
*/
/**
* Implementation of hook_install().
*/
function biblio_pm_install() {
biblio_pm_add_fields();
biblio_pm_add_field_instances();
}
function biblio_pm_uninstall() {
variable_del('biblio_pm_dup_action');
variable_del('biblio_pm_auto_update');
variable_del('biblio_pm_update_interval');
variable_del('biblio_pm_update_limit');
variable_del('biblio_pm_age_limit');
variable_del('biblio_pm_update_next_execution');
biblio_pm_delete_default_fields();
}
function biblio_pm_enable() {
biblio_pm_set_system_weight();
}
function biblio_pm_set_system_weight() {
db_update('system')
->fields(array(
'weight' => 19,
))
->condition('name', 'biblio_pm')
->execute();
}
/**
* Implementation of hook_schema().
*
* Note: Pro Drupal Development models use of t() to translate 'description'
* for field definitions, but Drupal core does not use them. We follow core.
*/
function biblio_pm_schema() {
$schema = array();
$schema['biblio_pubmed'] = array(
'fields' => array(
'biblio_pubmed_id' => array(
'type' => 'int',
'not null' => TRUE,
),
'biblio_pmcid' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'bid' => array(
'type' => 'int',
'not null' => TRUE,
),
'biblio_pubmed_md5' => array(
'type' => 'char',
'length' => 32,
'not null' => TRUE,
),
'biblio_pm_changed' => array(
'description' => 'The Unix timestamp when the pmid was most recently saved.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'bid',
),
);
return $schema;
}
/**
*
* add two new fields to the biblio_pubmed table
*
*/
function biblio_pm_update_7001() {
$spec = array(
'description' => 'The Unix timestamp when the pmid was most recently saved.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
);
db_add_field('biblio_pubmed', 'biblio_pm_changed', $spec);
$spec = array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
);
db_add_field('biblio_pubmed', 'biblio_pmcid', $spec);
}
function biblio_pm_delete_default_fields() {
$field_name = 'biblio_pmid';
if (field_info_field($field_name)) {
field_delete_field($field_name);
field_purge_batch(10);
}
}
Functions
Name![]() |
Description |
---|---|
biblio_pm_delete_default_fields | |
biblio_pm_enable | |
biblio_pm_install | Implementation of hook_install(). |
biblio_pm_schema | Implementation of hook_schema(). |
biblio_pm_set_system_weight | |
biblio_pm_uninstall | |
biblio_pm_update_7001 | add two new fields to the biblio_pubmed table |