Explorar o código

Merge branch '7.x-3.x' into patch-1

Reynold Tan %!s(int64=5) %!d(string=hai) anos
pai
achega
fb945baba1

+ 1 - 1
.travis.yml

@@ -2,7 +2,7 @@ language: php
 
 services:
   - docker
-  - postgres
+  - postgresql
 
 sudo: required
 

+ 2 - 2
tripal/includes/tripal.fields.inc

@@ -765,8 +765,8 @@ function tripal_field_widget_form_validate($element, &$form_state, $form) {
   $field = $element['#field'];
   $instance = $element['#instance'];
 
-  $langcode = $element['#language'];
-  $delta = $element['#delta'];
+  $langcode = (isset($element['#language'])) ? $element['#language'] : LANGUAGE_NONE;
+  $delta = (isset($element['#delta'])) ? $element['#delta'] : 0;
 
   $widget_class = $instance['widget']['type'];
   tripal_load_include_field_class($widget_class);

+ 2 - 1
tripal_chado/includes/TripalFields/sio__vocabulary/sio__vocabulary_widget.inc

@@ -27,9 +27,10 @@ class sio__vocabulary_widget extends ChadoFieldWidget {
     // content managers to change it. Thus we need to look up the value for the
     // entity type and use it here.
     if (empty($items)) {
+
       // Use the bundle to get the cv_id choosen for this cvterm-based entity.
       // ASSUMPTION: the cv_id is saved as the "type_value" of the bundle.
-      $bundle = tripal_load_bundle_entity(['name' => $widget['#bundle']]);
+      $bundle = tripal_load_bundle_entity(['name' => $widget['#instance']['bundle']]);
       $cv = chado_get_cv(['cv_id' => $bundle->type_value]);
 
       // Now populate the items array with defaults based on the cv.

+ 7 - 2
tripal_chado/includes/tripal_chado.bundle.inc

@@ -118,6 +118,11 @@ function tripal_chado_create_bundle_table($bundle) {
     throw new Exception('Cannot create entity linker table for chado.');
   }
   db_create_table($chado_entity_table, $schema);
+
+  // Ensure we clear the drupal schema cache after creating this table.
+  // This is needed so we can publish records directly after creating a new
+  // content type.
+  drupal_get_complete_schema(TRUE);
 }
 
 /**
@@ -155,9 +160,9 @@ function tripal_chado_bundle_find_orphans($bundle, $count = FALSE, $offset = 0,
   if (!$count and $limit) {
     $qlimit = "LIMIT $limit OFFSET $offset ";
   }
-  // Get the count 
+  // Get the count
   $query = "
-    SELECT $select  
+    SELECT $select
     FROM [$chado_bundle_table] CT
       LEFT JOIN {" . $bundle->data_table . "} BT ON CT.record_id = BT.$primary_key
     WHERE BT.$primary_key IS NULL

+ 16 - 8
tripal_chado/includes/tripal_chado.db.inc

@@ -84,8 +84,8 @@ function tripal_chado_db_edit_form($form, &$form_state) {
   ];
 
 
-  // if we don't have a db_id then we can  return the form, otherwise
-  // add in the other fields
+  // If we don't have a db_id then we can  return the form, otherwise
+  // add in the other fields.
   if ($dbid) {
     tripal_chado_add_db_form_fields($form, $form_state, $dbid);
 
@@ -93,11 +93,19 @@ function tripal_chado_db_edit_form($form, &$form_state) {
       '#type' => 'submit',
       '#value' => t('Update'),
     ];
-    $form['delete'] = [
-      '#type' => 'submit',
-      '#value' => t('Delete'),
-      '#attributes' => ['onclick' => 'if(!confirm("Really Delete?")){return false;}'],
-    ];
+
+    $dbxref_count = chado_query('select count(dbxref_id) from {dbxref} WHERE db_id = :db_id', [':db_id' => $dbid])->fetchField();
+
+    if ($dbxref_count == 0) {
+      $form['delete'] = [
+        '#type' => 'submit',
+        '#value' => t('Delete'),
+        '#attributes' => ['onclick' => 'if(!confirm("Really Delete?")){return false;}'],
+      ];
+    }
+    else {
+      tripal_set_message("You cannot delete this db without first deleting the ${dbxref_count} dbxrefs associated with it.", TRIPAL_NOTICE);
+    }
   }
   else {
     // if we don't have a dbid then this is the first time the form has
@@ -346,4 +354,4 @@ function tripal_chado_db_edit_form_ajax($form, $form_state) {
   //drupal_set_message('<pre>' . print_r($elements, TRUE) . '</pre>', "status");
 
   return $elements;
-}
+}