Code cleaning

This commit is contained in:
Benjamin Renard 2024-09-25 17:11:14 +02:00
parent ee69cc302c
commit 6cfde7f084
Signed by: bn8
GPG key ID: 3E2E1CE1907115BC
2 changed files with 32 additions and 23 deletions

View file

@ -47,7 +47,13 @@ class LSattr_html_select_object extends LSattr_html{
*/
public function addToForm (&$form, $idForm, $data=NULL) {
$this -> config['attrObject'] = $this;
$element=$form -> addElement($this -> LSformElement_type, $this -> name, $this -> getLabel(), $this -> config, $this);
$element = $form -> addElement(
$this -> LSformElement_type,
$this -> name,
$this -> getLabel(),
$this -> config,
$this
);
if(!$element) {
LSerror :: addErrorCode('LSform_06', $this -> name);
return false;

View file

@ -1024,37 +1024,40 @@ class LSldapObject extends LSlog_staticLoggerClass {
*
* @param Net_LDAP2_Filter|string|null $filter LDAP search filter
* @param string|null $sbasedn Base DN of the search
* @param array $sparams Search parameters (as expected by Net_LDAP2::search())
* @param array|null $sparams Search parameters (as expected by Net_LDAP2::search())
* @param string|false $displayFormat LSformat of objects's display name
* @param bool $cache Enable/disable cache (default: true)
*
* @return array|false Tableau dn => name correspondant au resultat de la recherche, ou false
*/
public function listObjectsName($filter=NULL,$sbasedn=NULL,$sparams=array(),$displayFormat=false,$cache=true) {
public function listObjectsName($filter=NULL, $sbasedn=NULL, $sparams=null, $displayFormat=false, $cache=true) {
if (!LSsession :: loadLSclass('LSsearch')) {
LSerror::addErrorCode('LSsession_05', 'LSsearch');
return false;
}
if (!$displayFormat) {
$displayFormat = $this -> getDisplayNameFormat();
}
$params = array(
'displayFormat' => $displayFormat,
$params = [
'displayFormat' => $displayFormat?$displayFormat:$this -> getDisplayNameFormat(),
'basedn' => $sbasedn,
'filter' => $filter
];
$LSsearch = new LSsearch(
$this -> type_name,
'LSldapObject::listObjectsName',
(
is_array($sparams)?
$params = array_merge($sparams, $params):
$sparams
),
true
);
if (is_array($sparams)) {
$params=array_merge($sparams,$params);
}
$LSsearch = new LSsearch($this -> type_name,'LSldapObject::listObjectsName',$params,true);
$LSsearch -> run($cache);
return $LSsearch -> listObjectsName();
return (
$LSsearch -> run($cache)?
$LSsearch -> listObjectsName():
false
);
}