LSldapObject getObjectFilter() : return filter Net_LDAP2_Filter object instead of string and fix resulting filter usage in validateAttrData() method

This commit is contained in:
Benjamin Renard 2014-11-28 16:19:01 +01:00
parent 1518888efa
commit 072acf21f7

View file

@ -458,19 +458,21 @@ class LSldapObject {
if((isset($test['filter'])||isset($test['basedn']))&&(isset($test['result']))) { if((isset($test['filter'])||isset($test['basedn']))&&(isset($test['result']))) {
$sparams=(isset($test['scope']))?array('scope' => $test['scope']):array(); $sparams=(isset($test['scope']))?array('scope' => $test['scope']):array();
$this -> other_values['val']=$val; $this -> other_values['val']=$val;
$sfilter_user=(isset($test['filter']))?getFData($test['filter'],$this,'getValue'):NULL; // Filter from test configuration
if(isset($test['object_type'])) { if (isset($test['filter']) && !empty($test['filter'])) {
$test_obj = new $test['object_type'](); $sfilter_user=getFData($test['filter'],$this,'getValue');
$sfilter=$test_obj->getObjectFilter(); if ($sfilter_user[0]!='(') $sfilter_user="(".$sfilter_user.")";
if ($sfilter_user) { $sfilter_user=Net_LDAP2_Filter::parse($sfilter_user);
$sfilter='(&'.$sfilter; }
if($sfilter_user[0]=='(') { else {
$sfilter=$sfilter.$sfilter_user.')'; $sfilter_user=NULL;
} }
else { if(isset($test['object_type']) && LSsession :: loadLSobject($test['object_type']) ) {
$sfilter=$sfilter.'('.$sfilter_user.'))'; $sfilter=self :: getObjectFilter($test['object_type']);
}
} if ($sfilter_user) {
$sfilter=LSldap::combineFilters('and',array($sfilter_user,$sfilter));
}
} }
else { else {
$sfilter=$sfilter_user; $sfilter=$sfilter_user;
@ -659,7 +661,7 @@ class LSldapObject {
* *
* @author Benjamin Renard <brenard@easter-eggs.com> * @author Benjamin Renard <brenard@easter-eggs.com>
* *
* @retval string le filtre ldap correspondant au type de l'objet * @retval Net_LDAP2_Filter le filtre ldap correspondant au type de l'objet
*/ */
function getObjectFilter($type=null) { function getObjectFilter($type=null) {
if (is_null($type)) { if (is_null($type)) {
@ -674,10 +676,10 @@ class LSldapObject {
$filter=LSconfig::get("LSobjects.$type.filter"); $filter=LSconfig::get("LSobjects.$type.filter");
if ($filter) { if ($filter) {
$filters[]=$filter; $filters[]=Net_LDAP2_Filter::parse($filter);
} }
$filter = LSldap::combineFilters('and',$filters,true); $filter = LSldap::combineFilters('and',$filters);
if ($filter) if ($filter)
return $filter; return $filter;
LSerror :: addErrorCode('LSldapObject_30',$type); LSerror :: addErrorCode('LSldapObject_30',$type);