From eb00496153a5b027e90e8a2d4f6f138f055395d6 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Sun, 25 Jan 2009 17:43:30 +0000 Subject: [PATCH] =?UTF-8?q?-=20LSldapObject=20:=20=09->=20Ajout=20de=20par?= =?UTF-8?q?am=C3=A8tres=20de=20configuration=20pour=20d=C3=A9finir=20les?= =?UTF-8?q?=20attributs=20devant=20=09=09=20=C3=AAtre=20utilis=C3=A9s=20po?= =?UTF-8?q?ur=20passer=20un=20pattern=20recherch=C3=A9s.=20=09->=20Ajout?= =?UTF-8?q?=20de=20la=20m=C3=A9thode=20getPatternFilter()=20=09->=20Utilis?= =?UTF-8?q?ation=20de=20la=20m=C3=A9thode=20getPatternFilter()=20dans=20ge?= =?UTF-8?q?tSelectArray()=20-=20view.php=20&=20select.php=20:=20Utilisatio?= =?UTF-8?q?n=20de=20getPatternFilter()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LSobjects/config.LSobjects.LSeepeople.php | 10 ++++ trunk/includes/class/class.LSldapObject.php | 55 +++++++++++++------ trunk/select.php | 13 +---- trunk/view.php | 13 +---- 4 files changed, 50 insertions(+), 41 deletions(-) diff --git a/trunk/conf/LSobjects/config.LSobjects.LSeepeople.php b/trunk/conf/LSobjects/config.LSobjects.LSeepeople.php index 3b0f021e..17fae517 100644 --- a/trunk/conf/LSobjects/config.LSobjects.LSeepeople.php +++ b/trunk/conf/LSobjects/config.LSobjects.LSeepeople.php @@ -106,6 +106,16 @@ $GLOBALS['LSobjects']['LSeepeople'] = array ( ) // fin Layout ), // fin LSform + 'LSsearch' => array ( + 'attrs' => array ( + 'givenName', + 'sn', + 'cn', + 'uid', + 'mail' + ) + ), + // Attributes 'attrs' => array ( diff --git a/trunk/includes/class/class.LSldapObject.php b/trunk/includes/class/class.LSldapObject.php index 50665a93..7c85f061 100644 --- a/trunk/includes/class/class.LSldapObject.php +++ b/trunk/includes/class/class.LSldapObject.php @@ -628,6 +628,43 @@ class LSldapObject { return $filter; } + /** + * Retourne le filtre correpondants au pattern passé + * + * @author Benjamin Renard + * + * @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); } diff --git a/trunk/select.php b/trunk/select.php index 1ae6fbad..b9ba1120 100644 --- a/trunk/select.php +++ b/trunk/select.php @@ -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; diff --git a/trunk/view.php b/trunk/view.php index 72cbd494..ef269bb8 100644 --- a/trunk/view.php +++ b/trunk/view.php @@ -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;