mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-26 03:43:08 +01:00
Add generateFunction and additionalAttrs parameters for extraDisplayedColumns
This commit is contained in:
parent
835dccb5f6
commit
7be590d842
3 changed files with 66 additions and 30 deletions
|
@ -47,6 +47,11 @@ configuration des &LSobjects;, dans la variable <varname>LSsearch</varname>
|
|||
),
|
||||
'col2' => array(
|
||||
'label' => 'label column 2',
|
||||
'generateFunction' => '[fonction de génération]',
|
||||
'additionalAttrs' => array('[attr1]', '[attr2]', ...)
|
||||
),
|
||||
'col3' => array(
|
||||
'label' => 'label column 3',
|
||||
'LSformat' => '[LSformat]',
|
||||
'alternativeLSformats' => array (
|
||||
'[LSformat 1]',
|
||||
|
@ -59,7 +64,7 @@ configuration des &LSobjects;, dans la variable <varname>LSsearch</varname>
|
|||
'[LSprofile 1]',
|
||||
'[LSprofile 2]'
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
'customActions' => array (
|
||||
// Configuration des customActions pour les recherches de ce type d'objet
|
||||
|
@ -306,6 +311,24 @@ contexte dans lequel cette recherche est effectuée.</para>
|
|||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>generateFunction</term>
|
||||
<listitem>
|
||||
<simpara>Le nom d'une fonction qui sera utilisée pour générer la valeur d'affichage de
|
||||
cette colonne. La fonction prendra en paramètre une référence de l'objet <literal>
|
||||
LSsearchEntry</literal> et retournera la valeur de la colonne.</simpara>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>additionalAttrs</term>
|
||||
<listitem>
|
||||
<simpara>Un tableau de nom d'attributs à inclure dans le resultat de la recherche LDAP.
|
||||
Ce tableau permet notamment d'inclure les attributs nécessaires au bon fonctionnement
|
||||
de la fonction <literal>generateFunction</literal>.</simpara>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>cssStyle</term>
|
||||
<listitem>
|
||||
|
|
|
@ -798,20 +798,26 @@ class LSsearch {
|
|||
// Extra Columns
|
||||
if ($this -> params['extraDisplayedColumns'] && is_array($this -> config['extraDisplayedColumns'])) {
|
||||
foreach ($this -> config['extraDisplayedColumns'] as $id => $conf) {
|
||||
$attrs=getFieldInFormat($conf['LSformat']);
|
||||
if(is_array($conf['alternativeLSformats'])) {
|
||||
foreach ($conf['alternativeLSformats'] as $format) {
|
||||
$attrs=array_merge($attrs,getFieldInFormat($format));
|
||||
$attrs=array();
|
||||
if (isset($conf['LSformat'])) {
|
||||
$attrs=getFieldInFormat($conf['LSformat']);
|
||||
if(is_array($conf['alternativeLSformats'])) {
|
||||
foreach ($conf['alternativeLSformats'] as $format) {
|
||||
$attrs=array_merge($attrs,getFieldInFormat($format));
|
||||
}
|
||||
}
|
||||
else {
|
||||
$attrs=array_merge($attrs,getFieldInFormat($conf['alternativeLSformats']));
|
||||
}
|
||||
if(isset($conf['formaterLSformat'])) {
|
||||
$attrs=array_unique(array_merge($attrs,getFieldInFormat($conf['formaterLSformat'])));
|
||||
if(($key = array_search('val', $attrs)) !== false) {
|
||||
unset($attrs[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$attrs=array_merge($attrs,getFieldInFormat($conf['alternativeLSformats']));
|
||||
}
|
||||
if(isset($conf['formaterLSformat'])) {
|
||||
$attrs=array_unique(array_merge($attrs,getFieldInFormat($conf['formaterLSformat'])));
|
||||
if(($key = array_search('val', $attrs)) !== false) {
|
||||
unset($attrs[$key]);
|
||||
}
|
||||
if(isset($conf['additionalAttrs'])) {
|
||||
$attrs=array_unique(array_merge($attrs,(is_array($conf['additionalAttrs'])?$conf['additionalAttrs']:array($conf['additionalAttrs']))));
|
||||
}
|
||||
if(is_array($retval['attributes'])) {
|
||||
$retval['attributes']=array_merge($attrs,$retval['attributes']);
|
||||
|
|
|
@ -196,25 +196,32 @@ class LSsearchEntry {
|
|||
if(isset($this -> cache[$key])) {
|
||||
return $this -> cache[$key];
|
||||
}
|
||||
$ret=$this -> getFData($this->LSsearch->extraDisplayedColumns[$key]['LSformat']);
|
||||
if (empty($ret) && is_array($this->LSsearch->extraDisplayedColumns[$key]['alternativeLSformats'])) {
|
||||
foreach($this->LSsearch->extraDisplayedColumns[$key]['alternativeLSformats'] as $format) {
|
||||
$ret=$this -> getFData($format);
|
||||
if (!empty($ret)) break;
|
||||
}
|
||||
if (isset($this->LSsearch->extraDisplayedColumns[$key]['generateFunction'])) {
|
||||
if (!is_callable($this->LSsearch->extraDisplayedColumns[$key]['generateFunction']))
|
||||
return False;
|
||||
$ret=call_user_func_array($this->LSsearch->extraDisplayedColumns[$key]['generateFunction'],array(&$this));
|
||||
}
|
||||
if (!empty($ret) && isset($this->LSsearch->extraDisplayedColumns[$key]['formaterLSformat'])) {
|
||||
$this -> registerOtherValue('val',$ret);
|
||||
$ret=$this -> getFData($this->LSsearch->extraDisplayedColumns[$key]['formaterLSformat']);
|
||||
}
|
||||
if (!empty($ret) && isset($this->LSsearch->extraDisplayedColumns[$key]['formaterFunction'])) {
|
||||
if (is_callable($this->LSsearch->extraDisplayedColumns[$key]['formaterFunction'])) {
|
||||
$ret=call_user_func($this->LSsearch->extraDisplayedColumns[$key]['formaterFunction'],$ret);
|
||||
else {
|
||||
$ret=$this -> getFData($this->LSsearch->extraDisplayedColumns[$key]['LSformat']);
|
||||
if (empty($ret) && is_array($this->LSsearch->extraDisplayedColumns[$key]['alternativeLSformats'])) {
|
||||
foreach($this->LSsearch->extraDisplayedColumns[$key]['alternativeLSformats'] as $format) {
|
||||
$ret=$this -> getFData($format);
|
||||
if (!empty($ret)) break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$func=$this->LSsearch->extraDisplayedColumns[$key]['formaterFunction'];
|
||||
if(is_array($func)) $func=print_r($func,1);
|
||||
LSerror::addErrorCode('LSsearchEntry_01',array('func' => $func, 'column' => $key));
|
||||
if (!empty($ret) && isset($this->LSsearch->extraDisplayedColumns[$key]['formaterLSformat'])) {
|
||||
$this -> registerOtherValue('val',$ret);
|
||||
$ret=$this -> getFData($this->LSsearch->extraDisplayedColumns[$key]['formaterLSformat']);
|
||||
}
|
||||
if (!empty($ret) && isset($this->LSsearch->extraDisplayedColumns[$key]['formaterFunction'])) {
|
||||
if (is_callable($this->LSsearch->extraDisplayedColumns[$key]['formaterFunction'])) {
|
||||
$ret=call_user_func($this->LSsearch->extraDisplayedColumns[$key]['formaterFunction'],$ret);
|
||||
}
|
||||
else {
|
||||
$func=$this->LSsearch->extraDisplayedColumns[$key]['formaterFunction'];
|
||||
if(is_array($func)) $func=print_r($func,1);
|
||||
LSerror::addErrorCode('LSsearchEntry_01',array('func' => $func, 'column' => $key));
|
||||
}
|
||||
}
|
||||
}
|
||||
$this -> cache[$key] = $ret;
|
||||
|
|
Loading…
Reference in a new issue