mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-22 18:09:06 +01:00
API: search method now return true attributes value as handle by LdapSaisie (instead of raw attributes's values)
This commit is contained in:
parent
60d67f3123
commit
f960b2d394
3 changed files with 25 additions and 8 deletions
|
@ -165,8 +165,6 @@
|
|||
<varlistentry>
|
||||
<term>attributes</term>
|
||||
<listitem><simpara>Liste des attributs supplémentaires que devra retourner la recherche.</simpara>
|
||||
<warning><simpara>Attention, ici ce sont les valeurs brutes des attributs qui seront retournées et
|
||||
par forcément les valeurs telle que retournées habituellement.</simpara></warning>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
|
|
@ -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 <brenard@easter-eggs.com>
|
||||
*
|
||||
* @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 {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue