Parcourir la source

prevent deleting in use dbs

bradfordcondon il y a 5 ans
Parent
commit
cd5a9c55a7
1 fichiers modifiés avec 8 ajouts et 9 suppressions
  1. 8 9
      tripal_chado/includes/tripal_chado.db.inc

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

@@ -84,9 +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);
 
@@ -94,19 +93,19 @@ function tripal_chado_db_edit_form($form, &$form_state) {
       '#type' => 'submit',
       '#value' => t('Update'),
     ];
-  
-  
+
     // Assert we have some configuration in our database.
-  $dbxref_count = chado_query('select count(dbxref_id) from {dbxref_id} WHERE db_id = :db_id', [':db_id'] => $dbid);  
-  
+    $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 {
+      tripal_set_message("You cannot delete this db without first deleting the ${dbxref_count} dbxrefs associated with it.", TRIPAL_NOTICE);
     }
   }
   else {