mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-03 13:25:05 +01:00
implemented different search-types:
- all fields - firstname, lastname, account-lid - start with - exact for the new account-selection popup
This commit is contained in:
parent
9952a1bdb8
commit
ab9ec83bc4
@ -114,6 +114,15 @@
|
||||
$this->account_type = $account_type;
|
||||
}
|
||||
|
||||
$this->query_types = array(
|
||||
'all' => 'all fields',
|
||||
'firstname' => 'firstname',
|
||||
'lastname' => 'lastname',
|
||||
'lid' => 'LoginID',
|
||||
'email' => 'email', // sql-constructor unsets this again, til the email column is added
|
||||
'start' => 'start with',
|
||||
'exact' => 'exact',
|
||||
);
|
||||
$this->accounts_(); // call constructor of extended class
|
||||
|
||||
$this->xmlrpc_methods[] = array(
|
||||
@ -170,7 +179,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
function get_list($_type='both',$start = '',$sort = '', $order = '', $query = '', $offset = '')
|
||||
function get_list($_type='both',$start = '',$sort = '', $order = '', $query = '', $offset = '',$query_type='')
|
||||
{
|
||||
//echo "<p>accounts::get_list(".print_r($_type,True).",start='$start',sort='$sort',order='$order',query='$query',offset='$offset')</p>\n";
|
||||
$this->setup_cache();
|
||||
@ -185,6 +194,7 @@
|
||||
$order = $p['order'];
|
||||
$query = $p['query'];
|
||||
$offset = $p['offset'];
|
||||
$query_type = $p['query_type'];
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -193,7 +203,8 @@
|
||||
'start' => $start,
|
||||
'order' => $order,
|
||||
'query' => $query,
|
||||
'offset' => $offset
|
||||
'offset' => $offset,
|
||||
'query_type' => $query_type ,
|
||||
);
|
||||
}
|
||||
$serial = serialize($p);
|
||||
@ -204,7 +215,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
$account_list[$serial]['data'] = accounts_::get_list($_type,$start,$sort,$order,$query,$offset);
|
||||
$account_list[$serial]['data'] = accounts_::get_list($_type,$start,$sort,$order,$query,$offset,$query_type);
|
||||
$account_list[$serial]['total'] = $this->total;
|
||||
}
|
||||
return $account_list[$serial]['data'];
|
||||
|
@ -455,7 +455,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
function get_list($_type='both', $start = '',$sort = '', $order = '', $query = '', $offset = '')
|
||||
function get_list($_type='both', $start = '',$sort = '', $order = '', $query = '', $offset = '',$query_type='')
|
||||
{
|
||||
//print "\$_type=$_type, \$start=$start , \$sort=$sort, \$order=$order, \$query=$query, \$offset=$offset<br>";
|
||||
$query = strtolower($query);
|
||||
@ -475,14 +475,37 @@
|
||||
|
||||
if($_type == 'accounts')
|
||||
{
|
||||
if(empty($query) || $query == "*")
|
||||
$filter = "(&(uidnumber=*)(phpgwaccounttype=u)";
|
||||
if (!empty($query) && $query != '*')
|
||||
{
|
||||
$filter = "(&(uidnumber=*)(phpgwaccounttype=u))";
|
||||
}
|
||||
else
|
||||
{
|
||||
$filter = "(&(uidnumber=*)(phpgwaccounttype=u)(|(uid=*$query*)(sn=*$query*)(cn=*$query*)(givenname=*$query*)))";
|
||||
switch($query_type)
|
||||
{
|
||||
case 'all':
|
||||
default:
|
||||
$query = '*'.$query;
|
||||
// fall-through
|
||||
case 'start':
|
||||
$query .= '*';
|
||||
// fall-through
|
||||
case 'exact':
|
||||
$filter .= "(|(uid=$query)(sn=$query)(cn=$query)(givenname=$query)(email=$query))";
|
||||
break;
|
||||
case 'firstname':
|
||||
case 'lastname':
|
||||
case 'lid':
|
||||
case 'email':
|
||||
$to_ldap = array(
|
||||
'firstname' => 'sn',
|
||||
'lastname' => 'givenname',
|
||||
'lid' => 'uid',
|
||||
'email' => 'email',
|
||||
);
|
||||
$filter .= '('.$to_ldap[$query_type].'=*'.$query.'*)';
|
||||
break;
|
||||
}
|
||||
}
|
||||
$filter .= ')';
|
||||
|
||||
$sri = ldap_search($this->ds, $this->user_context, $filter);
|
||||
$allValues = ldap_get_entries($this->ds, $sri);
|
||||
while (list($null,$allVals) = @each($allValues))
|
||||
|
@ -39,6 +39,8 @@
|
||||
function accounts_()
|
||||
{
|
||||
copyobj($GLOBALS['phpgw']->db,$this->db);
|
||||
|
||||
unset($this->query_types['email']);
|
||||
}
|
||||
|
||||
function list_methods($_type='xmlrpc')
|
||||
@ -128,7 +130,7 @@
|
||||
$this->db->unlock();
|
||||
}
|
||||
|
||||
function get_list($_type='both',$start = '',$sort = '', $order = '', $query = '', $offset = '')
|
||||
function get_list($_type='both',$start = '',$sort = '', $order = '', $query = '', $offset = '',$query_type='')
|
||||
{
|
||||
if (! $sort)
|
||||
{
|
||||
@ -166,9 +168,26 @@
|
||||
{
|
||||
$whereclause = ' WHERE ( ';
|
||||
}
|
||||
$query = $this->db->db_addslashes($query);
|
||||
$whereclause .= " account_firstname LIKE '%$query%' OR account_lastname LIKE "
|
||||
. "'%$query%' OR account_lid LIKE '%$query%' )";
|
||||
switch($query_type)
|
||||
{
|
||||
case 'all':
|
||||
default:
|
||||
$query = '%'.$query;
|
||||
// fall-through
|
||||
case 'start':
|
||||
$query .= '%';
|
||||
// fall-through
|
||||
case 'exact':
|
||||
$query = $this->db->quote($query);
|
||||
$whereclause .= " account_firstname LIKE $query OR account_lastname LIKE $query OR account_lid LIKE $query )";
|
||||
break;
|
||||
case 'firstname':
|
||||
case 'lastname':
|
||||
case 'lid':
|
||||
$query = $this->db->quote('%'.$query.'%');
|
||||
$whereclause .= " account_$query_type LIKE $query )";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM phpgw_accounts $whereclause $orderclause";
|
||||
@ -184,7 +203,6 @@
|
||||
{
|
||||
$this->db->query($sql,__LINE__,__FILE__);
|
||||
}
|
||||
|
||||
while ($this->db->next_record())
|
||||
{
|
||||
$accounts[] = Array(
|
||||
|
Loading…
Reference in New Issue
Block a user