| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 | 
							- <?php
 
- /**
 
-  * @file
 
-  * Install the tripal project
 
-  */
 
- /**
 
-  * Implements hook_disable().
 
-  * Disable default views when module is disabled
 
-  *
 
-  * @ingroup tripal_project
 
-  */
 
- function tripal_project_disable() {
 
-   // Disable all default views provided by this module
 
-   require_once("tripal_project.views_default.inc");
 
-   $views = tripal_project_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_project
 
-  */
 
- function tripal_project_requirements($phase) {
 
-   $requirements = array();
 
-   if ($phase == 'install') {
 
-     // make sure chado is installed
 
-     if (!$GLOBALS["chado_is_installed"]) {
 
-       $requirements ['tripal_project'] = array(
 
-         'title' => "tripal_project",
 
-         'value' => "ERROR: Chado must be installed before this module can be enabled",
 
-         'severity' => REQUIREMENT_ERROR,
 
-       );
 
-     }
 
-   }
 
-   return $requirements;
 
- }
 
- /**
 
-  * Implementation of hook_install().
 
-  *
 
-  * @ingroup tripal_project
 
-  */
 
- function tripal_project_install() {
 
-   // create the module's data directory
 
-   tripal_create_files_dir('tripal_project');
 
-   tripal_project_add_cvs();
 
-   tripal_project_add_cvterms();
 
-   
 
-   // set the default vocabularies
 
-   tripal_set_default_cv('projectprop', 'type_id', 'project_property');
 
-   tripal_set_default_cv('project_relationship', 'type_id', 'project_relationship');
 
- }
 
- /**
 
-  * Implementation of hook_uninstall().
 
-  *
 
-  * @ingroup tripal_project
 
-  */
 
- function tripal_project_uninstall() {
 
- }
 
- /**
 
-  * Implementation of hook_schema().
 
-  *
 
-  * @ingroup tripal_project
 
-  */
 
- function tripal_project_schema() {
 
-   $schema['chado_project'] = array(
 
-     'fields' => array(
 
-       'nid' => array(
 
-         'type' => 'int',
 
-         'unsigned' => TRUE,
 
-         'not null' => TRUE,
 
-       ),
 
-       'vid' => array(
 
-           'type' => 'int',
 
-           'not null' => TRUE,
 
-       ),
 
-       'project_id' => array(
 
-         'type' => 'int',
 
-         'unsigned' => TRUE,
 
-         'not null' => TRUE,
 
-       ),
 
-     ),
 
-     'primary key' => array('nid', 'vid', 'project_id'),
 
-   );
 
-   return $schema;
 
- }
 
- /**
 
-  * Add cvs pertaining to projects
 
-  *
 
-  * @ingroup tripal_project
 
-  */
 
- function tripal_project_add_cvs() {
 
-   // Add the cv for project properties
 
-   tripal_cv_add_cv(
 
-     'project_property', 
 
-     'Contains properties for projects'
 
-   );
 
-   // Add cv for relationship types
 
-   tripal_cv_add_cv(
 
-     'project_relationship',
 
-     'Contains Types of relationships between projects.'
 
-   );
 
- }
 
- /**
 
-  * Add cvterms pertaining to projects
 
-  *
 
-  * @ingroup tripal_project
 
-  */
 
- function tripal_project_add_cvterms() {
 
-   // Insert cvterm 'Project Description' into cvterm table of chado
 
-   // database. This CV term is used to keep track of the project
 
-   // description in the projectprop table.
 
-   tripal_cv_add_cvterm(
 
-     array(
 
-       'name' => 'Project Description',
 
-       'def'  => 'Description of a project'
 
-     ),
 
-     'project_property', 0, 1, 'tripal'
 
-   );
 
- }
 
- /**
 
-  * This is the required update for tripal_project when upgrading from Drupal core API 6.x.
 
-  *
 
-  */
 
- function tripal_project_update_7200() {
 
-   
 
-   // add the project_property CV
 
-   try {
 
-     $cv_id = db_query("SELECT cv_id FROM chado.cv WHERE name = 'project_property'")->fetchField();
 
-     if (!$cv_id) {
 
-       // add the vocabulary
 
-       $cv_id = db_insert('chado.cv')
 
-         ->fields(array(
 
-           'name' => 'project_property',
 
-           'definition' => 'Contains properties for projects.'
 
-         ))
 
-         ->execute();
 
-     }
 
-     // use the new project_property CV we just added
 
-     db_insert('tripal_cv_defaults')
 
-       ->fields(array(
 
-       'table_name' => 'projectprop',
 
-       'field_name' => 'type_id',
 
-       'cv_id' => $cv_id
 
-       ))
 
-       ->execute();
 
-   }
 
-   catch (\PDOException $e) {
 
-     $error = $e->getMessage();
 
-     throw new DrupalUpdateException('Failed to add project_property vocabulary: '. $error);
 
-   }
 
-   
 
-   // add the project_relationship CV
 
-   try {
 
-     $cv_id = db_query("SELECT cv_id FROM chado.cv WHERE name = 'project_relationship'")->fetchField();
 
-     if (!$cv_id) {
 
-       // add the vocabulary
 
-       $cv_id = db_insert('chado.cv')
 
-       ->fields(array(
 
-         'name' => 'project_relationship',
 
-         'definition' => 'Contains types of relationships between projects.'
 
-       ))
 
-       ->execute();
 
-     }
 
-     // use the new project_property CV we just added
 
-     db_insert('tripal_cv_defaults')
 
-       ->fields(array(
 
-         'table_name' => 'project_relationship',
 
-         'field_name' => 'type_id',
 
-         'cv_id' => $cv_id
 
-       ))
 
-       ->execute();
 
-   }
 
-   catch (\PDOException $e) {
 
-     $error = $e->getMessage();
 
-     throw new DrupalUpdateException('Failed to add project_relationship vocabulary: '. $error);
 
-   }
 
-   // For Tripal in Drupal 6 the project_description cvterm was stored in the
 
-   // 'tripal' CV.  It should be stored in the new project_property CV that
 
-   // is added by this module for Tripal 2.0 and Drupal 7.  So, we need to
 
-   // reset the CV ID for that term and rename the term to 'Project Description'
 
-   // We cannot use the Tripal API calls'because during upgrade the tripal_core
 
-   // should also be disabled
 
-   $sql = "
 
-     UPDATE chado.cvterm CVT
 
-     SET
 
-       name = 'Project Description',
 
-       cv_id = (SELECT cv_id FROM chado.cv WHERE name = 'project_property')
 
-     WHERE
 
-       name = 'project_description' AND
 
-       cv_id = (SELECT cv_id FROM chado.cv WHERE name = 'tripal')
 
-   ";
 
-   try {
 
-     db_query($sql);
 
-   }
 
-   catch (\PDOException $e) {
 
-     $error = $e->getMessage();
 
-     throw new DrupalUpdateException('Failed to change project_description property type to the project_property CV and update the name: '. $error);
 
-   }
 
- }
 
- /**
 
-  * Implementation of hook_update_dependencies().  It specifies a list of
 
-  * other modules whose updates must be run prior to this one.
 
-  */
 
- function tripal_project_update_dependencies() {
 
-   $dependencies = array();
 
-   // the tripal_cv update 7200 must run prior to update 7200 of this module
 
-   $dependencies['tripal_project'][7200] = array(
 
-     'tripal_cv' => 7200
 
-   );
 
-   return $dependencies;
 
- }
 
 
  |