LSsearch : Added onlyAccessible parameter

This commit is contained in:
Benjamin Renard 2013-02-08 13:42:41 +01:00
parent 9e69912df1
commit 2d80c4a852

View file

@ -51,6 +51,7 @@ class LSsearch {
'recursive' => false, 'recursive' => false,
'attributes' => array(), 'attributes' => array(),
// Display params // Display params
'onlyAccessible' => NULL,
'sortDirection' => NULL, 'sortDirection' => NULL,
'sortBy' => NULL, 'sortBy' => NULL,
'sortlimit' => 0, 'sortlimit' => 0,
@ -496,6 +497,11 @@ class LSsearch {
} }
} }
// Only Accessible objects
if (isset($params['onlyAccessible'])) {
$this -> params['onlyAccessible'] = (bool)$params['onlyAccessible'];
}
$this -> saveParamsInSession(); $this -> saveParamsInSession();
return $OK; return $OK;
} }
@ -787,16 +793,34 @@ class LSsearch {
'sortBy' => NULL, 'sortBy' => NULL,
'sortDirection' => NULL 'sortDirection' => NULL
); );
$this -> result['list'] = LSldap :: search(
// Search in LDAP
$list = LSldap :: search(
$this -> _searchParams['filter'], $this -> _searchParams['filter'],
$this -> _searchParams['basedn'], $this -> _searchParams['basedn'],
$this -> _searchParams $this -> _searchParams
); );
if ($this -> result['list'] === false) {
// Check result
if ($list === false) {
LSerror :: addErrorCode('LSsearch_12'); LSerror :: addErrorCode('LSsearch_12');
unset($this -> result['list']);
return; return;
} }
if ($this -> getParam('onlyAccessible') && LSsession :: getLSuserObjectDn()) {
$this -> result['list']=array();
// Check user rights on objets
foreach($list as $id => $obj) {
if (LSsession :: canAccess($this -> LSobject,$obj['dn'])) {
$this -> result['list'][]=$obj;
}
}
}
else {
$this -> result['list']=$list;
}
$this -> addResultToCache(); $this -> addResultToCache();
} }