Browse Source

Removed ability to preview nodes. The templates are messed up in preview and it's easier to just remove the button

Stephen Ficklin 11 years ago
parent
commit
a77526a07e

+ 9 - 3
tripal_analysis/tripal_analysis.module

@@ -297,11 +297,17 @@ function tripal_analysis_views_api() {
 
 
 
-/*
- *
-*/
+/**
+ * Implementation of hook_form_alter()
+ * 
+ * @param $form
+ * @param $form_state
+ * @param $form_id
+ */
 function tripal_analysis_form_alter(&$form, &$form_state, $form_id) {
+  // turn of preview button for insert/updates
   if ($form_id == "chado_analysis_node_form") {
+    $form['actions']['preview']['#access'] = FALSE;
   }
 }
 /**

+ 8 - 2
tripal_contact/tripal_contact.module

@@ -685,10 +685,16 @@ function tripal_contact_preprocess_tripal_contact_relationships(&$variables) {
   $contact->all_relationships = $relationships;
 }
 
-/*
- *
+/**
+ * Implementation of hook_form_alter()
+ * 
+ * @param $form
+ * @param $form_state
+ * @param $form_id
  */
 function tripal_contact_form_alter(&$form, &$form_state, $form_id) {
+  // turn of preview button for insert/updates
   if ($form_id == "chado_contact_node_form") {
+    $form['actions']['preview']['#access'] = FALSE;
   }
 }

+ 2 - 16
tripal_core/api/tripal_core_chado.api.inc

@@ -2542,13 +2542,8 @@ function tripal_core_delete_property_by_id($basetable, $record_id) {
  * Start a transaction block. Ensures the use of a persistent chado connection
  */
 function tripal_db_start_transaction() {
-/*  $connection = tripal_db_persistent_chado();
-  if ($connection) {
-    chado_query("BEGIN");
-    return $connection;
-  }
-  return FALSE;
-*/
+  $transaction = db_transaction();
+  return $transaction;
 }
 
 /**
@@ -2562,15 +2557,6 @@ function tripal_db_set_savepoint_transaction($savepoint, $release = FALSE) {
   chado_query("SAVEPOINT :savepoint", array(':savepoint' => $savepoint));
 }
 
-/**
- * A simple function to commit a database transaction
- *
- * @return nothing
- */
-function tripal_db_commit_transaction() {
-  chado_query("COMMIT");
-}
-
 /**
  * Rollback changes.
  *

+ 0 - 45
tripal_feature/api/tripal_feature.api.inc

@@ -831,51 +831,6 @@ function tripal_feature_get_formatted_sequence($feature_id, $feature_name,
   return $residues;
 }
 
-
-/**
- * This function defines the custom tables that will be created 
- * in the chado schema.
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_get_custom_tables($table = NULL) {
-
- if (!$table or strcmp($table, 'tripal_gff_temp')==0) {
-    $schema['tripal_gff_temp'] = array(
-      'table' => 'tripal_gff_temp',
-      'fields' => array(
-        'feature_id' => array(
-          'type' => 'int',
-          'not null' => TRUE,
-        ),
-        'organism_id' => array(
-          'type' => 'int',
-          'not null' => TRUE,
-        ),
-        'uniquename' => array(
-          'type' => 'text',
-          'not null' => TRUE,
-        ),
-        'type_name' => array(
-          'type' => 'varchar',
-          'length' => '1024',
-          'not null' => TRUE,
-        ),
-      ),
-      'indexes' => array(
-        'tripal_gff_temp_idx0' => array('feature_id'),
-        'tripal_gff_temp_idx0' => array('organism_id'),
-        'tripal_gff_temp_idx1' => array('uniquename'),
-      ),
-      'unique keys' => array(
-        'tripal_gff_temp_uq0' => array('feature_id'),
-        'tripal_gff_temp_uq1' => array('uniquename', 'organism_id', 'type_name'),
-      ),
-    );
-  }
-  return $schema;
-}
-
 /**
  * Using the tripal_core_expand_chado_vars function to retrieve a set
  * of relationships can be very slow, especialy if there are many relationships

+ 2 - 10
tripal_feature/includes/gff_loader.inc

@@ -311,23 +311,15 @@ function tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id,
   $start_line = 1, $landmark_type = '', $alt_id_attr = '', $create_organism = FALSE, 
   $job = NULL) {     
 
-  // make sure our temporary table exists
   $ret = array(); 
-  if (!db_table_exists('tripal_gff_temp')) { 
-    $schema = tripal_feature_get_custom_tables('tripal_gff_temp');  
-    $success = tripal_core_create_custom_table('tripal_gff_temp', $schema['tripal_gff_temp']);
-    if (!$success) {
-      watchdog('T_gff3_loader', "Cannot create temporary loading table", array(), WATCHDOG_ERROR); 
-      return;
-    } 
-  }
+
   // empty the temp table
   $sql = "DELETE FROM {tripal_gff_temp}";
   chado_query($sql);
   
   // begin the transaction
   if ($use_transaction) {
-    tripal_db_start_transaction();
+    $transaction = tripal_db_start_transaction();
     print "\nNOTE: Loading of this GFF file is performed using a database transaction. \n" .
          "If the load fails or is terminated prematurely then the entire set of \n" .
          "insertions/updates is rolled back and will not be found in the database\n\n";

+ 10 - 10
tripal_feature/theme/tripal_feature/tripal_feature_base.tpl.php

@@ -1,5 +1,5 @@
 <?php
-$feature  = $variables['node']->feature; ?>
+$feature  = $variables['node']->feature;  ?>
 
 <div id="tripal_feature-base-box" class="tripal_feature-info-box tripal-info-box">
   <div class="tripal_feature-info-box-title tripal-info-box-title">Details</div>
@@ -18,15 +18,6 @@ $feature  = $variables['node']->feature; ?>
   // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7 
   $rows = array();
 
-  // Is Obsolete Row
-  if(strcmp($feature->is_obsolete,'t')==0){
-    $rows[] = array(
-      array(
-        'data' => '<div class="tripal_feature-obsolete">This feature is obsolete</div>',
-        'colspan' => 2
-      ),
-    );
-  }
   // Name row
   $rows[] = array(
     array(
@@ -86,6 +77,15 @@ $feature  = $variables['node']->feature; ?>
       $feature->feature_id
     );
   }
+  // Is Obsolete Row
+  if($feature->is_obsolete == TRUE){
+    $rows[] = array(
+      array(
+        'data' => '<div class="tripal_feature-obsolete">This feature is obsolete</div>',
+        'colspan' => 2
+      ),
+    );
+  }
 
   // the $table array contains the headers and rows array as well as other
   // options for controlling the display of the table.  Additional

+ 42 - 0
tripal_feature/tripal_feature.install

@@ -53,6 +53,9 @@ function tripal_feature_install() {
   if ($mview_id = tripal_mviews_get_mview_id('organism_feature_count')) {
     tripal_mviews_action('update', $mview_id);
   }
+  
+  // add the custom tables to Chado
+  tripal_feature_add_custom_tables();
 }
 
 /**
@@ -180,4 +183,43 @@ function tripal_feature_add_organism_count_mview() {
   ";
 
   tripal_add_mview($view_name, 'tripal_feature', $schema, $sql, $comment);
+}
+
+/**
+ * 
+ */
+function tripal_feature_add_custom_tables() {
+  
+  $schema['tripal_gff_temp'] = array(
+    'table' => 'tripal_gff_temp',
+    'fields' => array(
+      'feature_id' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+      ),
+      'organism_id' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+      ),
+      'uniquename' => array(
+        'type' => 'text',
+        'not null' => TRUE,
+      ),
+      'type_name' => array(
+        'type' => 'varchar',
+        'length' => '1024',
+        'not null' => TRUE,
+      ),
+    ),
+    'indexes' => array(
+      'tripal_gff_temp_idx0' => array('feature_id'),
+      'tripal_gff_temp_idx0' => array('organism_id'),
+      'tripal_gff_temp_idx1' => array('uniquename'),
+    ),
+    'unique keys' => array(
+      'tripal_gff_temp_uq0' => array('feature_id'),
+      'tripal_gff_temp_uq1' => array('uniquename', 'organism_id', 'type_name'),
+    ),
+  );
+  tripal_core_create_custom_table('tripal_gff_temp', $schema, TRUE);
 }

+ 4 - 0
tripal_feature/tripal_feature.module

@@ -2239,4 +2239,8 @@ function tripal_feature_form_alter(&$form, &$form_state, $form_id) {
     // to the normal form URL
     $form['#action'] = url("find/sequences");
   }
+  // turn of preview button for feature insert/updates
+  if ($form_id == "chado_feature_node_form") {
+    $form['actions']['preview']['#access'] = FALSE;
+  }
 }

+ 14 - 0
tripal_featuremap/tripal_featuremap.module

@@ -667,3 +667,17 @@ function chado_featuremap_delete(&$node) {
   chado_query("DELETE FROM {featuremap} WHERE featuremap_id = :featuremap_id", array(':featuremap_id' => $featuremap_id));
   chado_query("DELETE FROM {featuremapprop} WHERE featuremap_id = :featuremap_id", array(':featuremap_id' => $featuremap_id));
 }
+
+/**
+ * Implementation of hook_form_alter()
+ *
+ * @param $form
+ * @param $form_state
+ * @param $form_id
+ */
+function tripal_featuremap_form_alter(&$form, &$form_state, $form_id) {
+  // turn of preview button for insert/updates
+  if ($form_id == "chado_featuremap_node_form") {
+    $form['actions']['preview']['#access'] = FALSE;
+  }
+}

+ 13 - 0
tripal_library/tripal_library.module

@@ -748,3 +748,16 @@ function chado_library_delete(&$node) {
 }
 
 
+/**
+ * Implementation of hook_form_alter()
+ *
+ * @param $form
+ * @param $form_state
+ * @param $form_id
+ */
+function tripal_library_form_alter(&$form, &$form_state, $form_id) {
+  // turn of preview button for insert/updates
+  if ($form_id == "chado_library_node_form") {
+    $form['actions']['preview']['#access'] = FALSE;
+  }
+}

+ 14 - 0
tripal_organism/tripal_organism.module

@@ -654,3 +654,17 @@ function chado_organism_load($nodes) {
     $nodes[$nid]->organism = $organism;
   }
 }
+
+/**
+ * Implementation of hook_form_alter()
+ *
+ * @param $form
+ * @param $form_state
+ * @param $form_id
+ */
+function tripal_organism_form_alter(&$form, &$form_state, $form_id) {
+  // turn of preview button for insert/updates
+  if ($form_id == "chado_organism_node_form") {
+    $form['actions']['preview']['#access'] = FALSE;
+  }
+}

+ 13 - 0
tripal_project/tripal_project.module

@@ -596,4 +596,17 @@ function tripal_project_preprocess_tripal_project_relationships(&$variables) {
 
   $project->all_relationships = $relationships;
 
+}
+/**
+ * Implementation of hook_form_alter()
+ *
+ * @param $form
+ * @param $form_state
+ * @param $form_id
+ */
+function tripal_project_form_alter(&$form, &$form_state, $form_id) {
+  // turn of preview button for insert/updates
+  if ($form_id == "chado_project_node_form") {
+    $form['actions']['preview']['#access'] = FALSE;
+  }
 }

+ 14 - 0
tripal_pub/tripal_pub.module

@@ -999,3 +999,17 @@ function tripal_pub_node_update($node) {
     tripal_pub_set_pub_url($node, $pub_id);
   }
 }
+
+/**
+ * Implementation of hook_form_alter()
+ *
+ * @param $form
+ * @param $form_state
+ * @param $form_id
+ */
+function tripal_pub_form_alter(&$form, &$form_state, $form_id) {
+  // turn of preview button for insert/updates
+  if ($form_id == "chado_pub_node_form") {
+    $form['actions']['preview']['#access'] = FALSE;
+  }
+}

+ 14 - 0
tripal_stock/tripal_stock.module

@@ -1253,4 +1253,18 @@ function tripal_stock_match_stocks_page($id) {
   $output = "<p>The following stocks match the name '$id'.</p>";
   $output .= theme_table($header, $rows, $table_attrs, $caption);
   return $output;
+}
+
+/**
+ * Implementation of hook_form_alter()
+ *
+ * @param $form
+ * @param $form_state
+ * @param $form_id
+ */
+function tripal_stock_form_alter(&$form, &$form_state, $form_id) {
+  // turn of preview button for insert/updates
+  if ($form_id == "chado_stock_node_form") {
+    $form['actions']['preview']['#access'] = FALSE;
+  }
 }