mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-26 11:52:59 +01:00
- LSldapObject :
-> Ajout de paramètres de configuration pour définir les attributs devant être utilisés pour passer un pattern recherchés. -> Ajout de la méthode getPatternFilter() -> Utilisation de la méthode getPatternFilter() dans getSelectArray() - view.php & select.php : Utilisation de getPatternFilter()
This commit is contained in:
parent
4ec62d0694
commit
eb00496153
4 changed files with 50 additions and 41 deletions
|
@ -106,6 +106,16 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
) // fin Layout
|
||||
), // fin LSform
|
||||
|
||||
'LSsearch' => array (
|
||||
'attrs' => array (
|
||||
'givenName',
|
||||
'sn',
|
||||
'cn',
|
||||
'uid',
|
||||
'mail'
|
||||
)
|
||||
),
|
||||
|
||||
// Attributes
|
||||
'attrs' => array (
|
||||
|
||||
|
|
|
@ -628,6 +628,43 @@ class LSldapObject {
|
|||
return $filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le filtre correpondants au pattern passé
|
||||
*
|
||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*
|
||||
* @param[in] $pattern string Le mot clé recherché
|
||||
* @param[in] $approx booléen Booléen activant ou non la recherche approximative
|
||||
*
|
||||
* @retval string le filtre ldap correspondant
|
||||
*/
|
||||
function getPatternFilter($pattern=null,$approx=null) {
|
||||
if ($pattern!=NULL) {
|
||||
if (is_array($GLOBALS['LSobjects'][$this -> getType()]['LSsearch']['attrs'])) {
|
||||
$attrs=$GLOBALS['LSobjects'][$this -> getType()]['LSsearch']['attrs'];
|
||||
}
|
||||
else {
|
||||
$attrs=array($GLOBALS['LSobjects'][$this -> getType()]['rdn']);
|
||||
}
|
||||
$pfilter='(|';
|
||||
if ($approx) {
|
||||
foreach ($attrs as $attr_name) {
|
||||
$pfilter.='('.$attr_name.'~='.$pattern.')';
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach ($attrs as $attr_name) {
|
||||
$pfilter.='('.$attr_name.'=*'.$pattern.'*)';
|
||||
}
|
||||
}
|
||||
$pfilter.=')';
|
||||
return $pfilter;
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne une liste d'objet du même type.
|
||||
*
|
||||
|
@ -961,23 +998,7 @@ class LSldapObject {
|
|||
* @retval array('dn' => 'display')
|
||||
*/
|
||||
function getSelectArray($pattern=NULL,$topDn=NULL,$displayFormat=NULL,$approx=false) {
|
||||
if ($pattern!=NULL) {
|
||||
$filter='(|';
|
||||
if ($approx) {
|
||||
foreach ($this -> attrs as $attr_name => $attr_val) {
|
||||
$filter.='('.$attr_name.'~='.$pattern.')';
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach ($this -> attrs as $attr_name => $attr_val) {
|
||||
$filter.='('.$attr_name.'=*'.$pattern.'*)';
|
||||
}
|
||||
}
|
||||
$filter.=')';
|
||||
}
|
||||
else {
|
||||
$filter=NULL;
|
||||
}
|
||||
$filter=$this -> getPatternFilter($pattern,$approx);
|
||||
return $this -> listObjectsName($filter,$topDn,array(),$displayFormat);
|
||||
}
|
||||
|
||||
|
|
|
@ -79,18 +79,7 @@ if(LSsession :: startLSsession()) {
|
|||
$approx = (isset($_REQUEST['LSview_approx']));
|
||||
|
||||
if ($pattern && $pattern!='') {
|
||||
$filter='(|';
|
||||
if ($approx) {
|
||||
foreach ($object -> attrs as $attr_name => $attr_val) {
|
||||
$filter.='('.$attr_name.'~='.$pattern.')';
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach ($object -> attrs as $attr_name => $attr_val) {
|
||||
$filter.='('.$attr_name.'=*'.$pattern.'*)';
|
||||
}
|
||||
}
|
||||
$filter.=')';
|
||||
$filter=$object -> getPatternFilter($pattern,$approx);
|
||||
}
|
||||
else {
|
||||
$filter = NULL;
|
||||
|
|
|
@ -210,18 +210,7 @@ if(LSsession :: startLSsession()) {
|
|||
$approx = (isset($_REQUEST['LSview_approx']));
|
||||
|
||||
if ($pattern && $pattern!='') {
|
||||
$filter='(|';
|
||||
if ($approx) {
|
||||
foreach ($object -> attrs as $attr_name => $attr_val) {
|
||||
$filter.='('.$attr_name.'~='.$pattern.')';
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach ($object -> attrs as $attr_name => $attr_val) {
|
||||
$filter.='('.$attr_name.'=*'.$pattern.'*)';
|
||||
}
|
||||
}
|
||||
$filter.=')';
|
||||
$filter=$object -> getPatternFilter($pattern,$approx);
|
||||
}
|
||||
else {
|
||||
$filter = NULL;
|
||||
|
|
Loading…
Reference in a new issue