]> git.andy128k.dev Git - ipf.git/commitdiff
fix misc
authoravl <alex.litovchenko@gmail.com>
Fri, 19 Jun 2009 16:46:11 +0000 (19:46 +0300)
committeravl <alex.litovchenko@gmail.com>
Fri, 19 Jun 2009 16:46:11 +0000 (19:46 +0300)
ipf/admin/model.php

index bbc553dd9182871e541431a3d7ffd3cb4c5c606b..fb49fd4f3ba93bfbd63a98abb360ae43ac5e2752 100644 (file)
@@ -450,19 +450,25 @@ class IPF_Admin_Model{
        return false;
     }
 
-    protected function _ListSearchQuery($request){
-       $this->search_value = null;
-       if (!$this->_isSearch())
-               return;
-       $fields = $this->_searchFields();
-       $this->search_value = @$request->GET['q'];
-       if ($this->search_value!=''){
-               foreach ($fields as $f){
-                   $this->q->where($f.' like ?',array('%'.$this->search_value.'%'));
-               }
-       }
-    }
-
+       protected function _ListSearchQuery($request){
+           $this->search_value = null;
+           if (!$this->_isSearch())
+               return;
+           $fields = $this->_searchFields();
+           $this->search_value = @$request->GET['q'];
+           if ($this->search_value!=''){
+               $wh = '';
+               $whv = array();
+               foreach ($fields as $f){
+                   if ($wh!='') $wh.=' or ';
+                   $wh.= $f.' like ?';
+                   $whv[] = '%'.$this->search_value.'%';
+               }
+               $this->q->where($wh,$whv);
+               return true;
+           }
+           return false;
+       }
 
     protected function _GetFilters($request){
        $this->filters = array();
@@ -508,8 +514,8 @@ class IPF_Admin_Model{
     public function ListItems($request, $lapp, $lmodel){
         $this->ListItemsQuery();
         $this->_GetFilters($request);
-        $this->_ListSearchQuery($request);
-        $this->_ListFilterQuery($request);
+        if (!$this->_ListSearchQuery($request))
+            $this->_ListFilterQuery($request);
         $this->ListItemsHeader();
 
         $currentPage = (int)@$request->GET['page'];