RooGetTrait.php
authoredward <edward@roojs.com>
Thu, 31 Mar 2016 02:14:58 +0000 (10:14 +0800)
committeredward <edward@roojs.com>
Thu, 31 Mar 2016 02:14:58 +0000 (10:14 +0800)
RooGetTrait.php

index 1ddc7d2..97db393 100644 (file)
@@ -275,135 +275,6 @@ trait Pman_Core_RooGetTrait {
         
     }
     
-    function setFilters($x, $q)
-    {
-        if (method_exists($x, 'applyFilters')) {
-           // DB_DataObject::debugLevel(1);
-            if (false === $x->applyFilters($q, $this->getAuthUser(), $this)) {
-                return; 
-            } 
-        }
-        $q_filtered = array();
-        
-        $keys = $x->keys();
-        // var_dump($keys);exit;
-        foreach($q as $key=>$val) {
-            
-            if (in_array($key,$keys) && !is_array($val)) {
-               
-                $x->$key  = $val;
-            }
-            
-             // handles name[]=fred&name[]=brian => name in ('fred', 'brian').
-            // value is an array..
-            if (is_array($val) ) {
-                
-                $pref = '';
-                
-                if ($key[0] == '!') {
-                    $pref = '!';
-                    $key = substr($key,1);
-                }
-                
-                if (!in_array( $key,  array_keys($this->cols))) {
-                    continue;
-                }
-                
-                // support a[0] a[1] ..... => whereAddIn(
-                $ar = array();
-                $quote = false;
-                foreach($val as $k=>$v) {
-                    if (!is_numeric($k)) {
-                        $ar = array();
-                        break;
-                    }
-                    // FIXME: note this is not typesafe for anything other than mysql..
-                    
-                    if (!is_numeric($v) || !is_long($v)) {
-                        $quote = true;
-                    }
-                    $ar[] = $v;
-                    
-                }
-                if (count($ar)) {
-                    
-                    
-                    $x->whereAddIn($pref . (
-                        isset($this->colsJname[$key]) ? 
-                            $this->colsJname[$key] :
-                            ($x->tableName(). '.'.$key)),
-                        $ar, $quote ? 'string' : 'int');
-                }
-                
-                continue;
-            }
-            
-            
-            // handles !name=fred => name not equal fred.
-            if ($key[0] == '!' && in_array(substr($key, 1), array_keys($this->cols))) {
-                
-                $key  = substr($key, 1) ;
-                
-                $x->whereAdd(   (
-                        isset($this->colsJname[$key]) ? 
-                            $this->colsJname[$key] :
-                            $x->tableName(). '.'.$key ) . ' != ' .
-                    (is_numeric($val) ? $val : "'".  $x->escape($val) . "'")
-                );
-                continue;
-                
-            }
-
-            switch($key) {
-                    
-                // Events and remarks -- fixme - move to events/remarsk...
-                case 'on_id':  // where TF is this used...
-                    if (!empty($q['query']['original'])) {
-                      //  DB_DataObject::debugLevel(1);
-                        $o = (int) $q['query']['original'];
-                        $oid = (int) $val;
-                        $x->whereAdd("(on_id = $oid  OR 
-                                on_id IN ( SELECT distinct(id) FROM Documents WHERE original = $o ) 
-                            )");
-                        continue;
-                                
-                    }
-                    $x->on_id = $val;
-                
-                
-                default:
-                    if (strlen($val) && $key[0] != '_') {
-                        $q_filtered[$key] = $val;
-                    }
-                    
-                    // subjoined columns = check the values.
-                    // note this is not typesafe for anything other than mysql..
-                    
-                    if (isset($this->colsJname[$key])) {
-                        $quote = false;
-                        if (!is_numeric($val) || !is_long($val)) {
-                            $quote = true;
-                        }
-                        $x->whereAdd( "{$this->colsJname[$key]} = " . ($quote ? "'". $x->escape($val) ."'" : $val));
-                        
-                    }
-                    
-                    
-                    continue;
-            }
-        }
-        if (!empty($q_filtered)) {
-            $x->setFrom($q_filtered);
-        }
-        
-        if (!empty($q['query']['name'])) {
-            if (in_array( 'name',  array_keys($x->table()))) {
-                $x->whereAdd($x->tableName().".name LIKE '". $x->escape($q['query']['name']) . "%'");
-            }
-        }
-        
-    }
-    
     function applySort($x, $sort = '', $dir ='')
     {
         $sort = empty($_REQUEST['sort']) ? $sort : $_REQUEST['sort'];