diff --git a/doc/conf/LSobject/LSsearch.docbook b/doc/conf/LSobject/LSsearch.docbook
index 728a2196..7327bbd9 100644
--- a/doc/conf/LSobject/LSsearch.docbook
+++ b/doc/conf/LSobject/LSsearch.docbook
@@ -38,6 +38,20 @@ configuration des &LSobjects;, dans la variable LSsearch
'predefinedFilters' => array(
'filter1' => 'label filter1',
'filter2' => 'label filter2'
+ ),
+ 'extraDisplayedColumns' => array(
+ 'col1' => array(
+ 'label' => 'label column 1',
+ 'LSformat' => '[LSformat]'
+ ),
+ 'col2' => array(
+ 'label' => 'label column 2',
+ 'LSformat' => '[LSformat]',
+ 'alternativeLSformats' => array (
+ '[LSformat 1]',
+ '[LSformat 2]'
+ )
+ )
)
);]]>
@@ -217,6 +231,44 @@ contexte dans lequel cette recherche est effectuée.
+
+ extraDisplayedColumns
+
+ Tableau associatif contenant des colonnes supplémentaires à afficher dans les
+ résultats de recherche. Les clés sont les identifiants des colonnes supplémentaires
+ et les valeurs sont leur configuration définie à partir des paramètres suivant :
+
+
+
+
+ label
+
+ Le label de la colonne.
+
+
+
+
+ LSformat
+
+ Le &LSformat; d'affichage de la colonne. Ce format est composé à partir
+ des attributs des objets LDAP dans leur format brut.
+
+
+
+
+ alternativeLSformats
+
+ Tableau des &LSformats; alternatifs à utiliser si le résultat du format
+ principal est vide. Les formats définis dans cette liste sont essayés les uns
+ après les autres et le premier &LSformat; retournant une valeur non-vide est
+ utilisé.
+
+
+
+
+
+
+
diff --git a/public_html/conf/LSobjects/config.LSobjects.LSpeople.php b/public_html/conf/LSobjects/config.LSobjects.LSpeople.php
index b18d523d..96ce0304 100644
--- a/public_html/conf/LSobjects/config.LSobjects.LSpeople.php
+++ b/public_html/conf/LSobjects/config.LSobjects.LSpeople.php
@@ -143,6 +143,12 @@ $GLOBALS['LSobjects']['LSpeople'] = array (
'predefinedFilters' => array (
'(jpegPhoto=*)' => 'With photo',
'(!(jpegPhoto=*))' => 'Without photo'
+ ),
+ 'extraDisplayedColumns' => array (
+ 'mail' => array (
+ 'label' => 'Mail',
+ 'LSformat' => '%{mail}'
+ ),
)
),
diff --git a/public_html/includes/class/class.LSsearch.php b/public_html/includes/class/class.LSsearch.php
index 398db9bc..dc990f17 100644
--- a/public_html/includes/class/class.LSsearch.php
+++ b/public_html/includes/class/class.LSsearch.php
@@ -60,7 +60,8 @@ class LSsearch {
'nbObjectsByPage' => NB_LSOBJECT_LIST,
'nbPageLinkByPage' => 10,
'customInfos' => array(),
- 'withoutCache' => false
+ 'withoutCache' => false,
+ 'extraDisplayedColumns' => false,
);
// The cache of search parameters
@@ -365,7 +366,7 @@ class LSsearch {
// Sort By
if (isset($params['sortBy']) && is_string($params['sortBy'])) {
- if (in_array($params['sortBy'],array('displayName','subDn'))) {
+ if (in_array($params['sortBy'],array('displayName','subDn')) || ($this ->extraDisplayedColumns && isset($this ->extraDisplayedColumns[$params['sortBy']]))) {
if ($this -> params['sortBy'] == $params['sortBy']) {
$this -> toggleSortDirection();
}
@@ -452,6 +453,11 @@ class LSsearch {
}
}
+ // Extra Columns
+ if (isset($params['extraDisplayedColumns'])) {
+ $this -> params['extraDisplayedColumns']=(bool)$params['extraDisplayedColumns'];
+ }
+
// predefinedFilter
if (isset($params['predefinedFilter'])) {
if (is_string($params['predefinedFilter'])) {
@@ -788,6 +794,31 @@ class LSsearch {
else {
$retval['attributes']=$attrs;
}
+
+ // 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));
+ }
+ }
+ else {
+ $attrs=array_merge($attrs,getFieldInFormat($conf['alternativeLSformats']));
+ }
+ if(is_array($retval['attributes'])) {
+ $retval['attributes']=array_merge($attrs,$retval['attributes']);
+ }
+ else {
+ $retval['attributes']=$attrs;
+ }
+ }
+ }
+
+ if (is_array($retval['attributes'])) {
+ $retval['attributes']=array_unique($retval['attributes']);
+ }
$this -> _searchParams = $retval;
}
@@ -1042,6 +1073,14 @@ class LSsearch {
}
return $retval;
}
+ elseif ($key=='extraDisplayedColumns') {
+ if ($this->params['extraDisplayedColumns'] && is_array($this -> config['extraDisplayedColumns'])) {
+ return $this -> config['extraDisplayedColumns'];
+ }
+ else {
+ return False;
+ }
+ }
else {
throw new Exception('Incorrect property !');
}
diff --git a/public_html/includes/class/class.LSsearchEntry.php b/public_html/includes/class/class.LSsearchEntry.php
index 00e68063..35c492eb 100644
--- a/public_html/includes/class/class.LSsearchEntry.php
+++ b/public_html/includes/class/class.LSsearchEntry.php
@@ -174,6 +174,20 @@ class LSsearchEntry {
}
return;
}
+ elseif (is_array($this->LSsearch->extraDisplayedColumns) && array_key_exists($key,$this->LSsearch->extraDisplayedColumns)) {
+ 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;
+ }
+ }
+ $this -> cache[$key] = $ret;
+ return $ret;
+ }
elseif (in_array($key,array_keys($this -> attrs))) {
return $this -> attrs[$key];
}
diff --git a/public_html/lang/generate_lang_file.php b/public_html/lang/generate_lang_file.php
index 27cb02b1..1d525002 100755
--- a/public_html/lang/generate_lang_file.php
+++ b/public_html/lang/generate_lang_file.php
@@ -122,6 +122,11 @@ if (loadDir('../'.LS_OBJECTS_DIR) && loadDir('../'.LS_LOCAL_DIR.LS_OBJECTS_DIR))
add($lay);
}
}
+ if (is_array($conf['LSsearch']['extraDisplayedColumns'])) {
+ foreach($conf['LSsearch']['extraDisplayedColumns'] as $cid => $cconf) {
+ add($cconf['label']);
+ }
+ }
if(is_array($conf['attrs'])) {
diff --git a/public_html/templates/default/viewSearch.tpl b/public_html/templates/default/viewSearch.tpl
index 462453e3..23898be4 100644
--- a/public_html/templates/default/viewSearch.tpl
+++ b/public_html/templates/default/viewSearch.tpl
@@ -70,12 +70,35 @@
{/if}
{/if}
+ {if $LSsearch->extraDisplayedColumns}
+ {foreach from=$LSsearch->extraDisplayedColumns item=conf key=cid}
+
+ {if $LSsearch->sort}
+
+ {if $LSsearch->sortBy == $cid}
+ {tr msg=$conf.label}
+
+ {else}
+ {tr msg=$conf.label}
+ {/if}
+
+ {else}
+ {tr msg=$conf.label}
+ {/if}
+ |
+ {/foreach}
+ {/if}
{$LSsearch->label_actions} |
{foreach from=$page.list item=object}
{$object->displayName} |
{if $LSsearch->displaySubDn}{$object->subDn} | {/if}
+ {if $LSsearch->extraDisplayedColumns}
+ {foreach from=$LSsearch->extraDisplayedColumns item=conf key=cid}
+ {$object->$cid}
+ {/foreach}
+ {/if}
|
{foreach from=$object->actions item=item}
diff --git a/public_html/view.php b/public_html/view.php
index 6e5f109b..78afd767 100644
--- a/public_html/view.php
+++ b/public_html/view.php
@@ -109,6 +109,7 @@ if(LSsession :: startLSsession()) {
LStemplate :: assign('pagetitle',$object -> getLabel());
$LSsearch = new LSsearch($LSobject,'LSview');
+ $LSsearch -> setParam('extraDisplayedColumns',True);
$LSsearch -> setParamsFormPostData();
$searchForm = array (
|