forked from extern/egroupware
Fix check of std fields for filtering in read()
This commit is contained in:
parent
6fb051add4
commit
34f99bb3dd
@ -225,8 +225,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//if ($query) { echo "DEBUG: Queries temporarily unavailable"; }
|
|
||||||
|
|
||||||
// turn filter's a=b,c=d OR a=b into an array
|
// turn filter's a=b,c=d OR a=b into an array
|
||||||
if ($filter) {
|
if ($filter) {
|
||||||
if ($DEBUG) { echo "DEBUG - Inbound filter is: #".$filter."#"; }
|
if ($DEBUG) { echo "DEBUG - Inbound filter is: #".$filter."#"; }
|
||||||
@ -251,19 +249,23 @@
|
|||||||
// now check each element of the array and convert into SQL for queries
|
// now check each element of the array and convert into SQL for queries
|
||||||
// below
|
// below
|
||||||
$i=0;
|
$i=0;
|
||||||
|
reset($filterfields);
|
||||||
while (list($name,$value) = each($filterfields)) {
|
while (list($name,$value) = each($filterfields)) {
|
||||||
if ($DEBUG) { echo "<br>DEBUG - Filter intermediate strings 2: #".$name."# => #".$value."#"; }
|
if ($DEBUG) { echo "<br>DEBUG - Filter intermediate strings 2: #".$name."# => #".$value."#"; }
|
||||||
$isstd=0;
|
$isstd=0;
|
||||||
if ($name && empty($value)) {
|
if ($name && empty($value)) {
|
||||||
reset($stock_fields);
|
if ($DEBUG) { echo "<br>DEBUG - filter field '".$name."' is empty (NULL)"; }
|
||||||
while (list($fname,$fvalue)=each($stock_fields)) {
|
$check_stock = $this->stock_contact_fields + array('id' => 'id', 'tid' => 'tid', 'lid' => 'lid', 'owner' => 'owner');
|
||||||
|
while (list($fname,$fvalue)=each($check_stock)) {
|
||||||
if ($fvalue==$name) {
|
if ($fvalue==$name) {
|
||||||
$filterlist .= $name.' is NULL,';
|
$filterlist .= $name.' is NULL,';
|
||||||
$isstd=1;
|
$isstd=1;
|
||||||
|
if ($DEBUG) { echo "<br>DEBUG - filter field '".$name."' is a stock field"; }
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$isstd) {
|
if (!$isstd) {
|
||||||
|
if ($DEBUG) { echo "<br>DEBUG - filter field '".$name."' is an extra field"; }
|
||||||
$filterlist2 .= 'b.'.$name.' is NULL,';
|
$filterlist2 .= 'b.'.$name.' is NULL,';
|
||||||
$fieldlist2 .= 'b.'.$name.',';
|
$fieldlist2 .= 'b.'.$name.',';
|
||||||
}
|
}
|
||||||
@ -303,6 +305,7 @@
|
|||||||
|
|
||||||
if (!$sort) { $sort = "ASC"; }
|
if (!$sort) { $sort = "ASC"; }
|
||||||
|
|
||||||
|
reset($stock_fields);
|
||||||
if ($order) {
|
if ($order) {
|
||||||
while (list($name,$value)=each($stock_fields)) {
|
while (list($name,$value)=each($stock_fields)) {
|
||||||
if ($name == $order) {
|
if ($name == $order) {
|
||||||
@ -400,7 +403,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($DEBUG && $filtertemp) {
|
if ($DEBUG && $filtertemp) {
|
||||||
echo "<br>DEBUG - Filtering with: #" . $filtertemp . "#";
|
echo "<br>DEBUG - Final SELECT - Filtering with: #" . $filtertemp . "#";
|
||||||
}
|
}
|
||||||
|
|
||||||
$qfields = $std . $ext;
|
$qfields = $std . $ext;
|
||||||
@ -418,12 +421,12 @@
|
|||||||
$sql = 'SELECT a.id,a.tid,a.lid,a.owner,b.id,'
|
$sql = 'SELECT a.id,a.tid,a.lid,a.owner,b.id,'
|
||||||
. $qfields . ' FROM '.$this->std_table.' AS a, '
|
. $qfields . ' FROM '.$this->std_table.' AS a, '
|
||||||
. $tmp_table .' AS b WHERE a.id=b.id ' . $filtertemp
|
. $tmp_table .' AS b WHERE a.id=b.id ' . $filtertemp
|
||||||
. $squery . $ordermethod;
|
. $squery;
|
||||||
|
|
||||||
$this->db3->query($sql,__LINE__,__FILE__);
|
$this->db3->query($sql,__LINE__,__FILE__);
|
||||||
$this->total_records = $this->db3->num_rows();
|
$this->total_records = $this->db3->num_rows();
|
||||||
|
|
||||||
$this->db->query($sql. " " . $this->db->limit($start,$offset),__LINE__,__FILE__);
|
$this->db->query($sql. " " . " " . $ordermethod . " " . $this->db->limit($start,$offset),__LINE__,__FILE__);
|
||||||
|
|
||||||
$i=0;
|
$i=0;
|
||||||
while ($this->db->next_record()) {
|
while ($this->db->next_record()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user