[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [16637] property: refine search on generic
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [16637] property: refine search on generic |
Date: |
Thu, 27 Apr 2017 04:41:15 -0400 (EDT) |
Revision: 16637
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16637
Author: sigurdne
Date: 2017-04-27 04:41:15 -0400 (Thu, 27 Apr 2017)
Log Message:
-----------
property: refine search on generic
Modified Paths:
--------------
trunk/property/inc/class.bogeneric.inc.php
trunk/property/inc/class.sogeneric_.inc.php
Modified: trunk/property/inc/class.bogeneric.inc.php
===================================================================
--- trunk/property/inc/class.bogeneric.inc.php 2017-04-27 03:50:45 UTC (rev
16636)
+++ trunk/property/inc/class.bogeneric.inc.php 2017-04-27 08:41:15 UTC (rev
16637)
@@ -383,16 +383,21 @@
}
}
$params['custom_filter'] = $custom_filter;
+ $params['disable_id_search'] =
phpgw::get_var('disable_id_search', 'bool');
$values = $this->read($params);
-/*
- foreach ($values as &$entry)
+ $include = phpgw::get_var('include');
+
+ if($include)
{
- if ($entry['parent_id'])
+ foreach ($values as &$entry)
{
- $entry['name'] = "[{$entry['name']}] ::
{$entry['parent_id']}";
+ if ($entry[$include])
+ {
+ $entry['name'] =
"{$entry[$include]} {$entry['name']}";
+ }
}
}
-*/
+
return array('ResultSet' => array('Result' => $values));
}
@@ -399,8 +404,30 @@
public function get_single_name( $data = array() )
{
+ $include = !empty($data['include']) ? $data['include']
: false;
+ $attributes = array();
+ if($include)
+ {
+ $attributes[] = array('column_name' =>
$include);
+ }
+
$this->get_location_info($data['type']);
- $values = $this->so->read_single(array('id' =>
$data['id']));
+ $values = $this->so->read_single(array('id' =>
$data['id']), array('attributes' => $attributes));
+ if($include)
+ {
+ if (!empty($values['attributes']))
+ {
+ foreach ($values['attributes'] as
$entry)
+ {
+ if($entry['column_name'] ==
$include && $entry['value'])
+ {
+ $values['name'] =
"{$entry['value']} {$values['name']}";
+ break;
+ }
+ }
+ }
+ }
+
// $values['path'] = $values['name'];
// if ($values['parent_id'])
// {
Modified: trunk/property/inc/class.sogeneric_.inc.php
===================================================================
--- trunk/property/inc/class.sogeneric_.inc.php 2017-04-27 03:50:45 UTC (rev
16636)
+++ trunk/property/inc/class.sogeneric_.inc.php 2017-04-27 08:41:15 UTC (rev
16637)
@@ -62,6 +62,7 @@
$query = isset($data['query']) ? $data['query'] : '';
$sort = isset($data['sort']) && $data['sort'] ?
$data['sort'] : 'DESC';
$order = isset($data['order']) ? $data['order'] : '';
+ $disable_id_search = empty($data['disable_id_search'])
? false : true;
$allrows = isset($data['allrows']) ? $data['allrows'] :
'';
$custom_criteria = isset($data['custom_criteria']) &&
$data['custom_criteria'] ? $data['custom_criteria'] : array();
$custom_filter = isset($data['custom_filter']) &&
$data['custom_filter'] ? $data['custom_filter'] : array();
@@ -242,20 +243,28 @@
$_query_end = ')';
}
$query = $this->_db->db_addslashes($query);
- $querymethod = " {$where } {$_query_start}
({$table}.{$this->location_info['id']['name']} = {$id_query}";
- //_debug_array($filtermethod);
- //_debug_array($where);die();
-
- if ($this->location_info['id']['type'] ==
'varchar')
+ if($disable_id_search)
{
- $querymethod .= " OR
{$table}.{$this->location_info['id']['name']} $this->_like '%$query%'";
- $where = 'OR';
+ $querymethod = " {$where }
{$_query_start} (1=0";
}
else
{
- $querymethod .= " OR CAST
({$table}.{$this->location_info['id']['name']} AS TEXT) $this->_like
'%$query%'";
+ $querymethod = " {$where }
{$_query_start} ({$table}.{$this->location_info['id']['name']} = {$id_query}";
+ if ($this->location_info['id']['type']
== 'varchar')
+ {
+ $querymethod .= " OR
{$table}.{$this->location_info['id']['name']} $this->_like '%$query%'";
+ $where = 'OR';
+ }
+ else
+ {
+ $querymethod .= " OR CAST
({$table}.{$this->location_info['id']['name']} AS TEXT) $this->_like
'%$query%'";
+ }
}
+ //_debug_array($filtermethod);
+ //_debug_array($where);die();
+ $where = 'OR';
+
foreach ($this->location_info['fields'] as
$field)
{
if ($field['type'] == 'varchar')
@@ -262,7 +271,6 @@
{
$querymethod .= " OR
{$table}.{$field['name']} $this->_like '%$query%'";
}
- $where = 'OR';
}
$querymethod .= ')';
@@ -282,7 +290,8 @@
{
if (ctype_digit($query))
{
- $_querymethod[]
= "$table." . $this->_db->f('column_name') . '=' . (int)$query;
+ // $_querymethod[]
= "$table." . $this->_db->f('column_name') . '=' . (int)$query;
+ $_querymethod[]
= "CAST ($table." . $this->_db->f('column_name') . " AS TEXT) {$this->_like}
'%" . (int)$query . "%'";
}
}
else
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [16637] property: refine search on generic,
sigurdne <=