diff --git a/doc/api/api.docbook b/doc/api/api.docbook
index d6f39e52..89a50aef 100644
--- a/doc/api/api.docbook
+++ b/doc/api/api.docbook
@@ -165,8 +165,6 @@
attributes
Liste des attributs supplémentaires que devra retourner la recherche.
- Attention, ici ce sont les valeurs brutes des attributs qui seront retournées et
- par forcément les valeurs telle que retournées habituellement.
diff --git a/src/includes/class/class.LSattribute.php b/src/includes/class/class.LSattribute.php
index b3105d71..0aa7b2eb 100644
--- a/src/includes/class/class.LSattribute.php
+++ b/src/includes/class/class.LSattribute.php
@@ -168,19 +168,24 @@ class LSattribute extends LSlog_staticLoggerClass {
}
/**
- * Retourne la valeur d'affichage de l'attribut
+ * Return attribute's display value
+ *
+ * @param[in] $data mixed Custom attribute data (optional, default: current attribute data)
*
* @author Benjamin Renard
*
- * @retval string La valeur d'affichage de l'attribut
+ * @retval mixed The display value of the attribute
*/
- public function getDisplayValue() {
+ public function getDisplayValue($data=false) {
if (!$this -> ldap) {
LSerror :: addErrorCode('LSattribute_09',array('type' => 'ldap','name' => $this -> name));
return;
}
- if ($this -> isUpdate()) {
+ if ($data !== false) {
+ $data = $this -> ldap -> getDisplayValue($data);
+ }
+ elseif ($this -> isUpdate()) {
$data = $this -> ldap -> getDisplayValue($this -> updateData);
}
else {
diff --git a/src/includes/routes.php b/src/includes/routes.php
index 1363b6a7..a60411f4 100644
--- a/src/includes/routes.php
+++ b/src/includes/routes.php
@@ -1612,6 +1612,16 @@ function handle_api_LSobject_search($request) {
'objects' => array(),
'total' => $search -> total,
);
+
+ // Instanciate LSform export to handle custom requested attributes
+ if (!LSsession :: loadLSclass('LSform'))
+ LSlog :: fatal("Fail to load LSform.");
+ $export = new LSform($object, 'export');
+ foreach ($search -> attributes as $attr) {
+ if (array_key_exists($attr, $object -> attrs))
+ $object -> attrs[$attr] -> addToExport($export);
+ }
+
if (!$all) {
$data['page'] = $page['nb'];
$data['nbPages'] = $page['nbPages'];
@@ -1631,8 +1641,12 @@ function handle_api_LSobject_search($request) {
}
}
foreach ($search -> attributes as $attr) {
- if (LSsession :: canAccess($LSobject, $obj -> dn, 'r', $attr))
- $data['objects'][$obj -> dn][$attr] = $obj -> $attr;
+ if (!LSsession :: canAccess($LSobject, $obj -> dn, 'r', $attr))
+ continue;
+ $export -> elements[$attr] -> setValue(
+ $object -> attrs[$attr] -> getDisplayValue($obj -> $attr)
+ );
+ $data['objects'][$obj -> dn][$attr] = $export -> elements[$attr] -> getApiValue(false);
}
}
// Handle as_list parameter