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() { 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_insert_cv( 'project_property', 'Contains properties for projects' ); // Add cv for relationship types tripal_insert_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_insert_cvterm( array( 'name' => 'Project Description', 'definition' => 'Description of a project', 'cv_name' => 'project_property', 'is_relationship' => 0, 'db_name' => 'tripal' ), array('update_existing' => TRUE) ); } /** * This is the required update for tripal_project when upgrading from Drupal core API 6.x. * */ function tripal_project_update_7200() { // Make sure we have the full API loaded this will help during a // site upgrade when the tripal_core module is disabled. module_load_include('module', 'tripal_core', 'tripal_core'); tripal_core_import_api(); module_load_include('inc', 'tripal_cv', 'api/tripal_cv.api'); // Add the project_property CV try { // First we add the cv. // Notice that tripal_insert_cv() will only add it if it doesn't exist already. $cv = tripal_insert_cv( 'project_property', 'Contains properties for projects' ); if ($cv) { $cv_id = $cv->cv_id; // Set as Default CV for contact types. $is_set = tripal_get_default_cv('projectprop', 'type_id'); if (!$is_set) { tripal_set_default_cv('projectprop','type_id', 'project_property', $cv_id); } } } catch (\PDOException $e) { $error = $e->getMessage(); throw new DrupalUpdateException('Failed to add project_property vocabulary: '. $error); } // add the project_relationship CV try { // First we add the cv. // Notice that tripal_insert_cv() will only add it if it doesn't exist already. $cv = tripal_insert_cv( 'project_relationship', 'Contains types of relationships between projects.' ); if ($cv) { $cv_id = $cv->cv_id; // Set as Default CV for contact types. $is_set = tripal_get_default_cv('project_relationship', 'type_id'); if (!$is_set) { tripal_set_default_cv('project_relationship','type_id', 'project_relationship', $cv_id); } } } 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' $sql = " UPDATE {cvterm} CVT SET name = 'Project Description', cv_id = (SELECT cv_id FROM {cv} WHERE name = 'project_property') WHERE name = 'project_description' AND cv_id = (SELECT cv_id FROM {cv} WHERE name = 'tripal') "; try { chado_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. It also ensures the the Tripal API is in scope for site * upgrades when tripal_core is disabled. */ 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; }