Pārlūkot izejas kodu

Merge branch '6.x-0.4-dev' of git.drupal.org:sandbox/spficklin/1337878 into 6.x-0.4-dev

Lacey Sanderson 12 gadi atpakaļ
vecāks
revīzija
dfa8bc968d

+ 2 - 2
tripal_feature/tripal_feature.module

@@ -456,7 +456,7 @@ function chado_feature_insert($node) {
   $istatus = tripal_core_chado_insert('feature', $values);
   if (!$istatus) {
     drupal_set_message(t('Unable to add feature.'), 'warning');
-    watchdog('tripal_organism',
+    watchdog('tripal_feature',
     'Insert feature: Unable to create feature where values: %values',
     array('%values' => print_r($values, TRUE)),
     WATCHDOG_WARNING
@@ -531,7 +531,7 @@ function chado_feature_update($node) {
     }
     else {
       drupal_set_message(t('Unable to update feature.'), 'warning');
-      watchdog('tripal_organism',
+      watchdog('tripal_feature',
       'Update feature: Unable to update feature where values: %values',
       array('%values' => print_r($values, TRUE)),
       WATCHDOG_WARNING

+ 7 - 0
tripal_views/tripal_views.views.inc

@@ -727,8 +727,15 @@ function tripal_views_data_export_download_form(&$form_state, $view, $display_id
   $displays = $view->display;
   $options = array();
   $default = '';
+  $current_display = $view->current_display;
   foreach ($displays as $name => $display) {
     if (preg_match("/^views_data_export/", $name)) {
+    
+      // only add this display to the form if it is attached 
+      $display_options = $display->display_options;
+      if(strcmp($display_options['displays'][$current_display],$current_display)!=0){
+         continue;
+      } 
 
       // set the first item as default
       if (!$default) {

+ 35 - 5
tripal_views/views/handlers/views_handler_filter_chado_select_string.inc

@@ -44,6 +44,12 @@ class views_handler_filter_chado_select_string extends views_handler_filter_stri
       '#default_value' => (isset($this->options['max_length'])) ? $this->options['max_length'] : 40,
 
     );
+    $form['max_length'] = array(
+      '#type' => 'markup',
+      '#value' => t('<strong><font color="red">Note:</font></strong> If another filter exists for the same table then '.
+                    'the values shown in the drop box will only include those from rows that are not filtered.'),
+
+    );
 
   }
 
@@ -64,19 +70,43 @@ class views_handler_filter_chado_select_string extends views_handler_filter_stri
     }
     else {
 
-      // Get Options
-      if ($this->options['optional']) {
-        //$options['<select '.$this->table.'>'] = '--None--';
-        $options['All'] = '--Any--';
+      // build a where clause that will filter the list in the drop box
+      // using fields that are not exposed and that are for the table
+      // from whcih the values in the drop box will be slected and
+      // we only want to use non-exposed fields because these are not
+      // available to the user to edit--their fixed.
+      $where = '';
+      $filters = $this->view->filter;
+      foreach($filters as $filter_name => $details){
+         // we only want to inclue non-exposed filters 
+         if($details->options['exposed'] == FALSE){
+            // we only want to filter on the table we're getting the list from
+            if(strcmp($details->table,$this->table)==0){
+              $where .= "$details->field $details->operator ". $details->value['value'];
+              $where .= ' AND ';
+            }
+         }
+      } 
+      if($where){
+         $where = "WHERE $where";
+         $where = substr($where,0,-5); # remove the final ' AND '
       }
-      $sql = "SELECT $this->field FROM $this->table ORDER BY $this->field ASC";
+
+      // get the values from the table
+      $sql = "SELECT $this->real_field FROM $this->table $where ORDER BY $this->field ASC";
       $previous_db = tripal_db_set_active('chado');  // use chado database
       $results = db_query($sql);
       tripal_db_set_active($previous_db);  // now use drupal database
+
+      // Build the select box options
       $max_length = $this->options['max_length'];
       if (!$max_length) {
         $max_length = 40;
       }
+      if ($this->options['optional']) {
+        //$options['<select '.$this->table.'>'] = '--None--';
+        $options['All'] = '--Any--';
+      }
       while ($r = db_fetch_object($results)) {
         if (drupal_strlen($r->{$this->field}) > $max_length) {
           $options[$r->{$this->field}] = drupal_substr($r->{$this->field}, 0, $max_length) . '...';