mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2025-03-28 14:51:34 +01:00
LSldapObject : Change getPatternFilter() method to use common LSsearch lib
This commit is contained in:
parent
7ccd02e685
commit
577803d0f7
1 changed files with 6 additions and 40 deletions
|
@ -726,48 +726,14 @@ class LSldapObject {
|
||||||
* @retval string le filtre ldap correspondant
|
* @retval string le filtre ldap correspondant
|
||||||
*/
|
*/
|
||||||
function getPatternFilter($pattern=null,$approx=null) {
|
function getPatternFilter($pattern=null,$approx=null) {
|
||||||
if ($pattern!=NULL) {
|
if ($pattern) {
|
||||||
$attrs=array();
|
$search = new LSsearch($this -> type_name, 'LSldapObject', array('approx' => (bool)$approx));
|
||||||
if (is_array($this -> config['LSsearch']['attrs'])) {
|
$filter = $search -> getFilterFromPattern($pattern);
|
||||||
foreach ($this -> config['LSsearch']['attrs'] as $key => $val) {
|
if ($filter instanceof Net_LDAP2_Filter) {
|
||||||
if (is_int($key)) {
|
return $filter -> asString();
|
||||||
$attrs[$val]=array();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$attrs[$key]=$val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$attrs=array($this -> config['rdn'] => array());
|
|
||||||
}
|
|
||||||
$pfilter='(|';
|
|
||||||
if ($approx) {
|
|
||||||
foreach ($attrs as $attr_name => $attr_opts) {
|
|
||||||
if (isset($attr_opts['approxLSformat'])) {
|
|
||||||
$pfilter.=getFData($attr_opts['approxLSformat'],array('name' => $attr_name, 'pattern' => $pattern));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$pfilter.='('.$attr_name.'~='.$pattern.')';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
foreach ($attrs as $attr_name => $attr_opts) {
|
|
||||||
if (isset($attr_opts['searchLSformat'])) {
|
|
||||||
$pfilter.=getFData($attr_opts['searchLSformat'],array('name' => $attr_name, 'pattern' => $pattern));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$pfilter.='('.$attr_name.'=*'.$pattern.'*)';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$pfilter.=')';
|
|
||||||
return $pfilter;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue