forked from extern/egroupware
Sorting works, filtering very strict
This commit is contained in:
parent
7b91787b6f
commit
4573f18ad7
@ -277,12 +277,6 @@
|
||||
$DEBUG = 0;
|
||||
|
||||
list($stock_fields,$stock_fieldnames,$extra_fields) = $this->split_stock_and_extras($fields);
|
||||
if (count($stock_fieldnames)) {
|
||||
$t_fields = "," . implode(",",$stock_fieldnames);
|
||||
if ($t_fields == ",") {
|
||||
unset($t_fields);
|
||||
}
|
||||
}
|
||||
|
||||
// turn filter's a=b,c=d OR a=b into an array
|
||||
if ($filter) {
|
||||
@ -351,63 +345,37 @@
|
||||
|
||||
if (!$sort) { $sort = "ASC"; }
|
||||
|
||||
if ($order) {
|
||||
$ordermethod = "order by $order $sort ";
|
||||
} else {
|
||||
$ordermethod = "order by n_family,n_given,email $sort";
|
||||
if (!$order) {
|
||||
$order = "n_family";
|
||||
}
|
||||
|
||||
if ($DEBUG && $ordermethod) {
|
||||
echo "<br>DEBUG - $ordermethod";
|
||||
if ($DEBUG && $order) {
|
||||
echo "<br>DEBUG - ORDER by $order";
|
||||
}
|
||||
|
||||
// This logic allows you to limit rows, or not.
|
||||
// The export feature, for example, does not limit rows.
|
||||
// This way, it can retrieve all rows at once.
|
||||
if ($start && $offset) {
|
||||
//$limit = $this->db->limit($start,$offset);
|
||||
} elseif ($start && !$offset) {
|
||||
$limit = "";
|
||||
} elseif(!$start && !$offset) {
|
||||
$limit = $this->total_records;
|
||||
} else { #(!$start && $offset) {
|
||||
$start = 0;
|
||||
//$limit = $this->db->limit($start,$offset);
|
||||
}
|
||||
|
||||
$this->db3 = $this->db2 = $this->db; // Create new result objects before our queries
|
||||
/*
|
||||
if ($query) {
|
||||
$this->db3->query("SELECT * FROM $this->std_table WHERE (n_family LIKE '"
|
||||
. "%$query%' OR n_given LIKE '%$query%' OR email LIKE '%$query%' OR "
|
||||
. "adr_one_street LIKE '%$query%' OR adr_one_locality LIKE '%$query%' OR adr_one_region LIKE '%$query%' OR "
|
||||
. "adr_one_postalcode LIKE '%$query%' OR adr_one_countryname LIKE '%$query%' OR "
|
||||
. "adr_two_street LIKE '%$query%' OR adr_two_locality LIKE '%$query%' OR adr_two_region LIKE '%$query%' OR "
|
||||
. "adr_two_postalcode LIKE '%$query%' OR adr_two_countryname LIKE '%$query%' OR "
|
||||
. "org_name LIKE '%$query%' OR org_unit LIKE '%$query%') " . $fand . $filtermethod . $ordermethod,__LINE__,__FILE__);
|
||||
$this->total_records = $this->db3->num_rows();
|
||||
|
||||
$this->db->query("SELECT * FROM $this->std_table WHERE (n_family LIKE '"
|
||||
. "%$query%' OR n_given LIKE '%$query%' OR email LIKE '%$query%' OR "
|
||||
. "adr_one_street LIKE '%$query%' OR adr_one_locality LIKE '%$query%' OR adr_one_region LIKE '%$query%' OR "
|
||||
. "adr_one_postalcode LIKE '%$query%' OR adr_one_countryname LIKE '%$query%' OR "
|
||||
. "adr_two_street LIKE '%$query%' OR adr_two_locality LIKE '%$query%' OR adr_two_region LIKE '%$query%' OR "
|
||||
. "adr_two_postalcode LIKE '%$query%' OR adr_two_countryname LIKE '%$query%' OR "
|
||||
. "org_name LIKE '%$query%' OR org_unit LIKE '%$query%') " . $fand . $filtermethod . $ordermethod . " "
|
||||
. $limit,__LINE__,__FILE__);
|
||||
$ldap_fields = array();
|
||||
$total = 0;
|
||||
while (list($name,$value) = each($stock_fieldnames) ) {
|
||||
$lquery = $value.'='.$query;
|
||||
//echo $lquery; exit;
|
||||
$sri = ldap_search($this->ldap, $phpgw_info["server"]["ldap_contact_context"], $lquery);
|
||||
$ldap_fields += ldap_get_entries($this->ldap, $sri);
|
||||
$total = $total + ldap_count_entries($this->ldap, $sri);
|
||||
}
|
||||
$this->total_records = $total;
|
||||
} else {
|
||||
$this->db3->query("SELECT id,lid,tid,owner $t_fields FROM $this->std_table " . $fwhere
|
||||
. $filtermethod,__LINE__,__FILE__);
|
||||
$this->total_records = $this->db3->num_rows();
|
||||
|
||||
$this->db->query("SELECT id,lid,tid,owner $t_fields FROM $this->std_table " . $fwhere
|
||||
. $filtermethod . " " . $ordermethod . " " . $limit,__LINE__,__FILE__);
|
||||
$sri = ldap_search($this->ldap, $phpgw_info["server"]["ldap_contact_context"], "phpgwowner=*");
|
||||
$ldap_fields = ldap_get_entries($this->ldap, $sri);
|
||||
$this->total_records = ldap_count_entries($this->ldap, $sri);
|
||||
}
|
||||
*/
|
||||
|
||||
$sri = ldap_search($this->ldap, $phpgw_info["server"]["ldap_contact_context"], "phpgwowner=*");
|
||||
$ldap_fields = ldap_get_entries($this->ldap, $sri);
|
||||
$this->total_records = ldap_count_entries($this->ldap, $sri);
|
||||
// Use shared sorting routines, based on sort and order
|
||||
if ($sort == "ASC") {
|
||||
$ldap_fields = $this->asortbyindex($ldap_fields, $this->stock_contact_fields[$order]);
|
||||
} else {
|
||||
$ldap_fields = $this->arsortbyindex($ldap_fields, $this->stock_contact_fields[$order]);
|
||||
}
|
||||
|
||||
// This logic allows you to limit rows, or not.
|
||||
// The export feature, for example, does not limit rows.
|
||||
@ -438,18 +406,19 @@
|
||||
$return_fields[$j]["owner"] = $ldap_fields[$i]["phpgwowner"][0];
|
||||
|
||||
if (gettype($stock_fieldnames) == "array") {
|
||||
reset($stock_fieldnames);
|
||||
while (list($f_name,$f_value) = each($stock_fieldnames)) {
|
||||
$return_fields[$j][$f_name] = $ldap_fields[$i][$f_value][0];
|
||||
}
|
||||
reset($stock_fieldnames);
|
||||
}
|
||||
$this->db2->query("SELECT contact_name,contact_value FROM $this->ext_table WHERE contact_id='"
|
||||
$this->db->query("SELECT contact_name,contact_value FROM $this->ext_table WHERE contact_id='"
|
||||
. $ldap_fields[$i]["id"] . "'",__LINE__,__FILE__);
|
||||
while ($this->db2->next_record()) {
|
||||
while ($this->db->next_record()) {
|
||||
// If its not in the list to be returned, don't return it.
|
||||
// This is still quicker then 5(+) separate queries
|
||||
if ($extra_fields[$this->db2->f("contact_name")]) {
|
||||
$return_fields[$j][$this->db2->f("contact_name")] = $this->db2->f("contact_value");
|
||||
if ($extra_fields[$this->db->f("contact_name")]) {
|
||||
$return_fields[$j][$this->db->f("contact_name")] = $this->db->f("contact_value");
|
||||
}
|
||||
}
|
||||
$j++;
|
||||
@ -545,7 +514,8 @@
|
||||
if (gettype($stock_fieldnames) == "array") {
|
||||
$stock_fields['phpgwowner'] = $owner;
|
||||
// Check each value, add our extra attributes if they are missing, and
|
||||
// otherwise fix the entry while we can
|
||||
// otherwise fix the entry while we can.
|
||||
//
|
||||
// Verify uidnumber
|
||||
if (empty($ldap_fields[0]['uidnumber'])) {
|
||||
$stock_fields['uidnumber'] = $id;
|
||||
|
Loading…
Reference in New Issue
Block a user