123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <?php
- /**
- * @file
- * Implements hooks from the Schema API
- */
- /**
- * Implementation of hook_install().
- */
- function tripal_natural_diversity_install() {
- // create the module's data directory
- tripal_create_moddir('tripal_natural_diversity');
-
- // add cvterms
- tripal_natural_diversity_add_cvterms();
-
- // add chado_nd_geolocation table
- if (!db_table_exists('chado_nd_geolocation')) {
- drupal_install_schema('tripal_natural_diversity_nd_geolocation');
- }
- }
- /**
- * Update for Drupal 6.x, Tripal 1.1, Natural Diversity Module 1.1
- * This update adds new cvterms for experiment types
- *
- */
- function tripal_natural_diversity_update_6100() {
-
- // add cvterms
- tripal_natural_diversity_add_cvterms();
-
- $ret = array(
- '#finished' => 1,
- );
- return $ret;
- }
- /*
- *
- */
- function tripal_natural_diversity_add_cvterms(){
-
- // add cvterms for the nd_experiment_types
- tripal_cv_add_cvterm(array('name' => 'Genotyping','def' => 'An experiment where genotypes of individuals are identified.'),
- 'nd_experiment_types', 0, 1, 'tripal');
- tripal_cv_add_cvterm(array('name' => 'Phenotyping','def' => 'An experiment where phenotypes of individuals are identified.'),
- 'nd_experiment_types', 0, 1, 'tripal');
-
- tripal_cv_add_cvterm(array('name' => 'Location','def' => 'The name of the location.'),
- 'nd_geolocation_property', 0, 1, 'tripal');
- }
- /**
- * Implementation of hook_uninstall().
- */
- function tripal_natural_diversity_uninstall() {
- }
- /**
- * Implementation of hook_requirements().
- */
- function tripal_natural_diversity_requirements($phase) {
- $requirements = array();
- if ($phase == 'install') {
- // make sure chado is installed
- if (!tripal_core_is_chado_installed()) {
- $requirements ['tripal_natural_diversity'] = array(
- 'title' => "tripal_natural_diversity",
- 'value' => "ERROR: Chado most be installed before this module can be enabled",
- 'severity' => REQUIREMENT_ERROR,
- );
- }
- }
- return $requirements;
- }
- /**
- * Update for Drupal 6.x, Tripal 1.1, Natural Diversity Module 1.1
- * This update adds new chado_nd_geolocation table
- *
- */
- function tripal_natural_diversity_update_6101() {
-
- // add chado_nd_geolocation table
- drupal_install_schema('tripal_natural_diversity_nd_geolocation');
- $ret = array(
- '#finished' => 1,
- );
- return $ret;
- }
- /**
- * Implementation of hook_schema().
- */
- function tripal_natural_diversity_nd_geolocation_schema() {
- $schema['chado_nd_geolocation'] = array(
- 'fields' => array(
- 'nid' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- ),
- 'vid' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'nd_geolocation_id' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- ),
- ),
- 'primary key' => array('nid', 'vid', 'nd_geolocation_id'),
- );
- return $schema;
- }
|