mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-22 09:59:06 +01:00
LSaddon::orgchart: improve logging
This commit is contained in:
parent
85d6a87fcf
commit
f3e7557421
1 changed files with 20 additions and 10 deletions
|
@ -90,6 +90,7 @@ function organizationalChartPage() {
|
|||
}
|
||||
|
||||
function organizationalChartData() {
|
||||
$logger = LSlog :: get_logger('LSaddon_orgchart');
|
||||
$root_entity = (isset($GLOBALS['ORGCHART_ROOT_ENTITY'])?$GLOBALS['ORGCHART_ROOT_ENTITY']:null);
|
||||
|
||||
$objects = array();
|
||||
|
@ -98,11 +99,14 @@ function organizationalChartData() {
|
|||
$objects_attr2dn_need = array();
|
||||
$requested_attrs = array();
|
||||
|
||||
$logger -> trace(
|
||||
"Orgchart entity object types configuration:\n".
|
||||
print_r($GLOBALS['ORGCHART_ENTITY_OBJECT_TYPES'], 1));
|
||||
|
||||
// Load all object types
|
||||
foreach($GLOBALS['ORGCHART_ENTITY_OBJECT_TYPES'] as $obj_type => $conf) {
|
||||
if (!LSsession :: loadLSobject($obj_type))
|
||||
LStemplate :: fatal_error("Fail to load object type '$obj_type'.");
|
||||
$logger -> fatal("Fail to load object type '$obj_type'.");
|
||||
$objects[$obj_type] = array();
|
||||
$requested_attrs[$obj_type] = array();
|
||||
$objects_attr2dn[$obj_type] = array();
|
||||
|
@ -115,7 +119,7 @@ function organizationalChartData() {
|
|||
$parent_id_attr = LSconfig :: get('parent_id_attr', '', 'string', $conf);
|
||||
if ($parent_id_attr) {
|
||||
if (!$obj_type :: hasAttr($parent_id_attr))
|
||||
LStemplate :: fatal_error("Object '$obj_type' does not have attribute '$parent_id_attr'.");
|
||||
$logger -> fatal("Object '$obj_type' does not have attribute '$parent_id_attr'.");
|
||||
$requested_attrs[$obj_type][] = $parent_id_attr;
|
||||
}
|
||||
$objects_conf[$obj_type]['parent_id_attr'] = $parent_id_attr;
|
||||
|
@ -129,7 +133,7 @@ function organizationalChartData() {
|
|||
|
||||
foreach(getFieldInFormat($attr) as $a) {
|
||||
if (!$obj_type :: hasAttr($a))
|
||||
LStemplate :: fatal_error("Object '$obj_type' does not have attribute '$a'.");
|
||||
$logger -> fatal("Object '$obj_type' does not have attribute '$a'.");
|
||||
if (!in_array($a, $requested_attrs[$obj_type]))
|
||||
$requested_attrs[$obj_type][] = $a;
|
||||
}
|
||||
|
@ -144,12 +148,12 @@ function organizationalChartData() {
|
|||
'array', $conf);
|
||||
foreach($objects_conf[$obj_type]['parent_object_types'] as $parent_object_type) {
|
||||
if (!array_key_exists($parent_object_type, $objects))
|
||||
LStemplate :: fatal_error("Object type '$parent_object_type' not configured for the organizational chart.");
|
||||
$logger -> fatal("Object type '$parent_object_type' not configured for the organizational chart.");
|
||||
|
||||
if ($parent_id_attr_value == 'dn') continue;
|
||||
|
||||
if (!$parent_object_type :: hasAttr($parent_id_attr_value))
|
||||
LStemplate :: fatal_error("Object '$parent_object_type' does not have attribute '$parent_id_attr_value'.");
|
||||
$logger -> fatal("Object '$parent_object_type' does not have attribute '$parent_id_attr_value'.");
|
||||
|
||||
if (!in_array($parent_id_attr_value, $requested_attrs[$parent_object_type]))
|
||||
$requested_attrs[$parent_object_type][] = $parent_id_attr_value;
|
||||
|
@ -163,10 +167,11 @@ function organizationalChartData() {
|
|||
// Load optional filter
|
||||
$objects_conf[$obj_type]['filter'] = LSconfig :: get('filter', '', 'string', $conf);
|
||||
}
|
||||
$logger -> trace("Objects types configuration:\n".print_r($objects_conf, 1));
|
||||
|
||||
// Load all objects
|
||||
if (!LSsession :: loadLSclass('LSsearch'))
|
||||
LStemplate :: fatal_error("Error loading LSsearch class");
|
||||
$logger -> fatal("Error loading LSsearch class");
|
||||
foreach($objects_conf as $obj_type => $conf) {
|
||||
// Compute search parameters
|
||||
$search_params = array(
|
||||
|
@ -206,6 +211,8 @@ function organizationalChartData() {
|
|||
$objects_attr2dn[$obj_type][$attr][$value] = $dn;
|
||||
}
|
||||
}
|
||||
$logger -> trace("Loaded object:\n".print_r($objects, 1));
|
||||
$logger -> trace("Loaded attr2dn:\n".print_r($objects_attr2dn, 1));
|
||||
|
||||
// Compute list of org chart entities
|
||||
$entities = array();
|
||||
|
@ -238,12 +245,15 @@ function organizationalChartData() {
|
|||
}
|
||||
|
||||
if (is_null($data['parentId'])) {
|
||||
// Parent not found: use root entity if defined or ignored object
|
||||
if ($root_entity)
|
||||
$logger -> warning(sprintf('%s: Parent "%s" not found: use root entity if defined or ignored object', $dn, $data['parent_id']));
|
||||
if ($root_entity) {
|
||||
$data['parentId'] = $root_entity['id'];
|
||||
else
|
||||
}
|
||||
else {
|
||||
// No root entity: do not add this object from chart
|
||||
$logger -> warning(sprintf('%s: No root entity: do not add this object from chart', $dn));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($root_entity && !$data['parent_id']) {
|
||||
|
@ -268,7 +278,7 @@ function organizationalChartData() {
|
|||
$entities[] = $root_entity;
|
||||
}
|
||||
elseif(count($root_entities) != 1) {
|
||||
LStemplate :: fatal_error('More than one root entities found : '.implode(' / ', $root_entities));
|
||||
$logger -> fatal('More than one root entities found : '.implode(' / ', $root_entities));
|
||||
}
|
||||
|
||||
// Adjust content-type and dump entities data as JSON
|
||||
|
|
Loading…
Reference in a new issue