mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-26 11:52:59 +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(
|
'col2' => array(
|
||||||
'label' => 'label column 2',
|
'label' => 'label column 2',
|
||||||
|
'generateFunction' => '[fonction de génération]',
|
||||||
|
'additionalAttrs' => array('[attr1]', '[attr2]', ...)
|
||||||
|
),
|
||||||
|
'col3' => array(
|
||||||
|
'label' => 'label column 3',
|
||||||
'LSformat' => '[LSformat]',
|
'LSformat' => '[LSformat]',
|
||||||
'alternativeLSformats' => array (
|
'alternativeLSformats' => array (
|
||||||
'[LSformat 1]',
|
'[LSformat 1]',
|
||||||
|
@ -59,7 +64,7 @@ configuration des &LSobjects;, dans la variable <varname>LSsearch</varname>
|
||||||
'[LSprofile 1]',
|
'[LSprofile 1]',
|
||||||
'[LSprofile 2]'
|
'[LSprofile 2]'
|
||||||
)
|
)
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
'customActions' => array (
|
'customActions' => array (
|
||||||
// Configuration des customActions pour les recherches de ce type d'objet
|
// 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>
|
</listitem>
|
||||||
</varlistentry>
|
</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>
|
<varlistentry>
|
||||||
<term>cssStyle</term>
|
<term>cssStyle</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
|
|
@ -798,20 +798,26 @@ class LSsearch {
|
||||||
// Extra Columns
|
// Extra Columns
|
||||||
if ($this -> params['extraDisplayedColumns'] && is_array($this -> config['extraDisplayedColumns'])) {
|
if ($this -> params['extraDisplayedColumns'] && is_array($this -> config['extraDisplayedColumns'])) {
|
||||||
foreach ($this -> config['extraDisplayedColumns'] as $id => $conf) {
|
foreach ($this -> config['extraDisplayedColumns'] as $id => $conf) {
|
||||||
$attrs=getFieldInFormat($conf['LSformat']);
|
$attrs=array();
|
||||||
if(is_array($conf['alternativeLSformats'])) {
|
if (isset($conf['LSformat'])) {
|
||||||
foreach ($conf['alternativeLSformats'] as $format) {
|
$attrs=getFieldInFormat($conf['LSformat']);
|
||||||
$attrs=array_merge($attrs,getFieldInFormat($format));
|
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 {
|
if(isset($conf['additionalAttrs'])) {
|
||||||
$attrs=array_merge($attrs,getFieldInFormat($conf['alternativeLSformats']));
|
$attrs=array_unique(array_merge($attrs,(is_array($conf['additionalAttrs'])?$conf['additionalAttrs']:array($conf['additionalAttrs']))));
|
||||||
}
|
|
||||||
if(isset($conf['formaterLSformat'])) {
|
|
||||||
$attrs=array_unique(array_merge($attrs,getFieldInFormat($conf['formaterLSformat'])));
|
|
||||||
if(($key = array_search('val', $attrs)) !== false) {
|
|
||||||
unset($attrs[$key]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(is_array($retval['attributes'])) {
|
if(is_array($retval['attributes'])) {
|
||||||
$retval['attributes']=array_merge($attrs,$retval['attributes']);
|
$retval['attributes']=array_merge($attrs,$retval['attributes']);
|
||||||
|
|
|
@ -196,25 +196,32 @@ class LSsearchEntry {
|
||||||
if(isset($this -> cache[$key])) {
|
if(isset($this -> cache[$key])) {
|
||||||
return $this -> cache[$key];
|
return $this -> cache[$key];
|
||||||
}
|
}
|
||||||
$ret=$this -> getFData($this->LSsearch->extraDisplayedColumns[$key]['LSformat']);
|
if (isset($this->LSsearch->extraDisplayedColumns[$key]['generateFunction'])) {
|
||||||
if (empty($ret) && is_array($this->LSsearch->extraDisplayedColumns[$key]['alternativeLSformats'])) {
|
if (!is_callable($this->LSsearch->extraDisplayedColumns[$key]['generateFunction']))
|
||||||
foreach($this->LSsearch->extraDisplayedColumns[$key]['alternativeLSformats'] as $format) {
|
return False;
|
||||||
$ret=$this -> getFData($format);
|
$ret=call_user_func_array($this->LSsearch->extraDisplayedColumns[$key]['generateFunction'],array(&$this));
|
||||||
if (!empty($ret)) break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!empty($ret) && isset($this->LSsearch->extraDisplayedColumns[$key]['formaterLSformat'])) {
|
else {
|
||||||
$this -> registerOtherValue('val',$ret);
|
$ret=$this -> getFData($this->LSsearch->extraDisplayedColumns[$key]['LSformat']);
|
||||||
$ret=$this -> getFData($this->LSsearch->extraDisplayedColumns[$key]['formaterLSformat']);
|
if (empty($ret) && is_array($this->LSsearch->extraDisplayedColumns[$key]['alternativeLSformats'])) {
|
||||||
}
|
foreach($this->LSsearch->extraDisplayedColumns[$key]['alternativeLSformats'] as $format) {
|
||||||
if (!empty($ret) && isset($this->LSsearch->extraDisplayedColumns[$key]['formaterFunction'])) {
|
$ret=$this -> getFData($format);
|
||||||
if (is_callable($this->LSsearch->extraDisplayedColumns[$key]['formaterFunction'])) {
|
if (!empty($ret)) break;
|
||||||
$ret=call_user_func($this->LSsearch->extraDisplayedColumns[$key]['formaterFunction'],$ret);
|
}
|
||||||
}
|
}
|
||||||
else {
|
if (!empty($ret) && isset($this->LSsearch->extraDisplayedColumns[$key]['formaterLSformat'])) {
|
||||||
$func=$this->LSsearch->extraDisplayedColumns[$key]['formaterFunction'];
|
$this -> registerOtherValue('val',$ret);
|
||||||
if(is_array($func)) $func=print_r($func,1);
|
$ret=$this -> getFData($this->LSsearch->extraDisplayedColumns[$key]['formaterLSformat']);
|
||||||
LSerror::addErrorCode('LSsearchEntry_01',array('func' => $func, 'column' => $key));
|
}
|
||||||
|
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;
|
$this -> cache[$key] = $ret;
|
||||||
|
|
Loading…
Reference in a new issue