瀏覽代碼

Fixed bug in pub search if no criteria are provided and to search both pub.series_name and proprties if Journal Name or Conference Name are used

spficklin 11 年之前
父節點
當前提交
51c3b688be
共有 1 個文件被更改,包括 17 次插入3 次删除
  1. 17 3
      tripal_pub/includes/pub_search.inc

+ 17 - 3
tripal_pub/includes/pub_search.inc

@@ -410,8 +410,9 @@ function tripal_pub_get_search_results($search_array, $limit, $pager_id) {
   $select = "SELECT DISTINCT P.*, CP.nid ";
   $from   = "FROM {pub} P
                LEFT JOIN public.chado_pub CP on P.pub_id = CP.pub_id 
+               INNER JOIN cvterm CVT on CVT.cvterm_id = P.type_id
             ";
-  $where  = "WHERE ";
+  $where  = "WHERE (NOT P.title = 'null') "; // always exclude the dummy pub
   $order  = "ORDER BY P.pyear DESC, P.title ASC";
   $fargs = array(); // arguments for from, inner join clause
   $wargs = array();  // arguments for where clause
@@ -473,8 +474,20 @@ function tripal_pub_get_search_results($search_array, $limit, $pager_id) {
       $wargs[] = $value;
     }
     elseif ($type_name == 'Journal Name') {
-      $where .= " $op (lower(P.series_name) $action) ";
-      $wargs[] = $value;             
+      $from .= " LEFT JOIN {pubprop} PP$i ON PP$i.pub_id = P.pub_id AND PP$i.type_id = %d ";      
+      $where .= " $op ((lower(P.series_name) $action and CVT.name = 'Journal Article') OR 
+                       (lower(PP$i.value) $action)) ";
+      $fargs[] = $type_id;
+      $wargs[] = $value;
+      $wargs[] = $value;            
+    }
+    elseif ($type_name == 'Conference Name') {
+      $from .= " LEFT JOIN {pubprop} PP$i ON PP$i.pub_id = P.pub_id AND PP$i.type_id = %d ";      
+      $where .= " $op ((lower(P.series_name) $action and CVT.name = 'Conference Proceedings') OR 
+                       (lower(PP$i.value) $action)) ";
+      $fargs[] = $type_id;
+      $wargs[] = $value;
+      $wargs[] = $value;
     }
     elseif ($type_id == 0) { //'Any Field'
       $from .= " LEFT JOIN {pubprop} PP$i ON PP$i.pub_id = P.pub_id ";
@@ -510,6 +523,7 @@ function tripal_pub_get_search_results($search_array, $limit, $pager_id) {
     $wargs[] = $to_year;
   }
   $sql = "$select $from $where $order";
+  dpm($sql);
   $count = "SELECT count(*) FROM ($select $from $where $order) as t1";
   $args = array_merge($fargs, $wargs);
   //dpm(array($mode, $sql, $args));