| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 | <?php/** * @file * Installation of the publication module *//** * Implements hook_disable(). * Disable default views when module is disabled * * @ingroup tripal_pub */function tripal_pub_disable() {  // Disable all default views provided by this module  require_once("tripal_pub.views_default.inc");  $views = tripal_pub_views_default_views();  foreach (array_keys($views) as $view_name) {    tripal_views_admin_disable_view($view_name,FALSE,array('suppress_error' => TRUE));  }}/** * Implementation of hook_requirements(). * * @ingroup tripal_pub */function tripal_pub_requirements($phase) {  $requirements = array();  if ($phase == 'install') {    // make sure chado is installed    if (!$GLOBALS["chado_is_installed"]) {      $requirements ['tripal_pub'] = array(        'title' => "tripal_pub",        'value' => "ERROR: Chado must be installed before this module can be enabled",        'severity' => REQUIREMENT_ERROR,      );    }  }  return $requirements;}/** * Implementation of hook_install(). * * @ingroup tripal_pub */function tripal_pub_install() {  global $base_path;  // create the module's data directory  tripal_create_files_dir('tripal_pub');  // add loading of the the tripal pub ontology to the job queue  $obo_path =  drupal_realpath(drupal_get_path('module', 'tripal_pub') . '/files/tpub.obo');  $obo_id = tripal_cv_add_obo_ref('Tripal Publication', $obo_path);  tripal_cv_submit_obo_job($obo_id);  tripal_pub_add_cvs();  tripal_pub_add_cvterms();  // add the custom tables  tripal_pub_add_custom_tables();}/** * Implementation of hook_uninstall(). * * @ingroup tripal_pub */function tripal_pub_uninstall() {}/** * Implements hook_enable(). * * @ingroup tripal_pub */function tripal_pub_enable() {  // make sure we have our supported databases  tripal_db_add_db('PMID', 'PubMed', 'http://www.ncbi.nlm.nih.gov/pubmed', 'http://www.ncbi.nlm.nih.gov/pubmed/', TRUE);  tripal_db_add_db('AGL', 'USDA National Agricultural Library', 'http://agricola.nal.usda.gov/', '', TRUE);  variable_set('tripal_pub_supported_dbs', array('PMID', 'AGL'));}/** * Implementation of hook_schema(). * * @ingroup tripal_pub */function tripal_pub_schema() {  $schema['chado_pub'] = array(    'fields' => array(      'vid' => array(        'type' => 'int',        'unsigned' => TRUE,        'not null' => TRUE, 'default' => 0      ),      'nid' => array(        'type' => 'int',        'unsigned' => TRUE,        'not null' => TRUE,        'default' => 0      ),      'pub_id' => array(        'type' => 'int',        'not null' => TRUE,        'default' => 0      ),      'sync_date' => array(        'type' => 'int',        'not null' => FALSE,        'description' => 'UNIX integer sync date/time'      ),    ),    'indexes' => array(      'pub_id' => array('pub_id')    ),    'unique keys' => array(      'nid_vid' => array('nid', 'vid'),      'vid' => array('vid')    ),    'primary key' => array('nid'),  );  $schema['tripal_pub_import'] = array(    'fields' => array(      'pub_import_id' => array(        'type' => 'serial',        'not null' => TRUE      ),      'name' => array(        'type' => 'varchar',        'length' => 255,        'not null' => TRUE      ),      'criteria' => array(        'type' => 'text',        'size' => 'normal',        'not null' => TRUE,        'description' => 'Contains a serialized PHP array containing the search criteria'      ),      'disabled'  => array(        'type' => 'int',        'unsigned' => TRUE,        'not NULL' => TRUE,        'default' => 0      ),      'do_contact'  => array(        'type' => 'int',        'unsigned' => TRUE,        'not NULL' => TRUE,        'default' => 0      ),    ),    'primary key' => array('pub_import_id'),    'indexes' => array(      'name' => array('name')    ),  );  return $schema;}/** * Add custom table related to publications *  - pubauthor_contact * * @ingroup tripal_pub */function tripal_pub_add_custom_tables() {  $schema = array (    'table' => 'pubauthor_contact',    'fields' => array (      'pubauthor_contact_id' => array (        'type' => 'serial',        'not null' => true,      ),      'contact_id' => array (        'type' => 'int',        'not null' => true,      ),      'pubauthor_id' => array (        'type' => 'int',        'not null' => true,      ),    ),    'primary key' => array (      0 => 'pubauthor_contact_id',    ),    'unique keys' => array (      'pubauthor_contact_c1' => array (        0 => 'contact_id',        1 => 'pubauthor_id',      ),    ),    'foreign keys' => array (      'contact' => array (        'table' => 'contact',        'columns' => array (          'contact_id' => 'contact_id',        ),      ),      'pubauthor' => array (        'table' => 'pubauthor',        'columns' => array (          'pubauthor_id' => 'pubauthor_id',        ),      ),    ),  );  chado_create_custom_table('pubauthor_contact', $schema, TRUE);}/** * Add cvs related to publications * * @ingroup tripal_pub */function tripal_pub_add_cvs() {  // Add cv for relationship types  tripal_cv_add_cv(    'pub_relationship_types',    'Contains Types of relationships between publications.'  );}/** * Add cvterms related to publications * * @ingroup tripal_pub */function tripal_pub_add_cvterms() {}/** * This is the required update for tripal_contact when upgrading from Drupal core API 6.x. * * @ingroup tripal_pub */function tripal_pub_update_7000() {  tripal_pub_add_cvs();  tripal_pub_add_cvterms();}
 |