2009-08-20 00:16:54 +04:00
|
|
|
<?php
|
|
|
|
require_once "init.php";
|
|
|
|
|
2009-11-27 20:03:35 +03:00
|
|
|
$people = array();
|
|
|
|
$orphans = array();
|
|
|
|
$everyone = array();
|
|
|
|
|
|
|
|
$tree = new MozillaTreeAdapter($everyone);
|
2010-01-26 03:35:38 +03:00
|
|
|
$auth = new MozillaAuthAdapter();
|
2009-11-27 20:03:35 +03:00
|
|
|
|
2009-08-20 00:16:54 +04:00
|
|
|
$search = ldap_search(
|
|
|
|
$ldapconn,
|
2009-11-27 20:03:35 +03:00
|
|
|
$tree->conf["ldap_search_base"],
|
|
|
|
$tree->conf["ldap_search_filter"],
|
|
|
|
$tree->conf["ldap_search_attributes"]
|
2009-08-20 00:16:54 +04:00
|
|
|
);
|
|
|
|
$data = ldap_get_entries($ldapconn, $search);
|
|
|
|
|
2009-11-27 20:03:35 +03:00
|
|
|
$tree_view_roots = $tree->roots;
|
2009-08-20 00:16:54 +04:00
|
|
|
foreach ($data as $person) {
|
|
|
|
$mail = $person['mail'][0];
|
2009-11-27 20:03:35 +03:00
|
|
|
$everyone[$mail] = $tree->process_entry($person);
|
2009-08-20 00:16:54 +04:00
|
|
|
|
|
|
|
// If a user has a manager, try to find their place in the tree.
|
|
|
|
if (!empty($person["manager"][0])) {
|
2010-01-26 03:35:38 +03:00
|
|
|
$manager = $auth->dn_to_email($person["manager"][0]);
|
2009-08-20 00:16:54 +04:00
|
|
|
if (empty($people[$manager])) {
|
|
|
|
$people[$manager] = array($mail);
|
|
|
|
} else {
|
|
|
|
$people[$manager][] = $mail;
|
|
|
|
}
|
2009-09-02 14:58:21 +04:00
|
|
|
} elseif (!empty($mail) && !in_array($mail, $tree_view_roots)) {
|
2009-08-20 00:16:54 +04:00
|
|
|
// Person is an orphan.
|
|
|
|
$orphans[] = $mail;
|
|
|
|
}
|
|
|
|
}
|
2010-01-26 03:35:38 +03:00
|
|
|
$managers = array_keys($people);
|
|
|
|
$visible_managers = array();
|
2009-08-20 00:16:54 +04:00
|
|
|
|
2009-09-16 22:49:08 +04:00
|
|
|
function make_tree($level, $root, $nodes=NULL) {
|
2009-08-20 00:16:54 +04:00
|
|
|
global $people;
|
|
|
|
global $everyone;
|
2009-11-27 20:03:35 +03:00
|
|
|
global $tree;
|
2010-01-26 03:35:38 +03:00
|
|
|
global $managers;
|
|
|
|
global $visible_managers;
|
2009-08-20 00:16:54 +04:00
|
|
|
|
2009-11-27 20:03:35 +03:00
|
|
|
print "\n". $tree->format_item($everyone, $root, ($nodes == NULL));
|
2009-08-20 00:16:54 +04:00
|
|
|
|
2010-01-26 03:35:38 +03:00
|
|
|
if ($nodes !== NULL && in_array($root, $managers)) {
|
|
|
|
$visible_managers[] = $root;
|
|
|
|
}
|
|
|
|
|
2009-08-20 00:16:54 +04:00
|
|
|
if (is_array($nodes)) {
|
|
|
|
print "\n<ul>";
|
2009-11-27 20:03:35 +03:00
|
|
|
usort($nodes, array($tree, "sort_items"));
|
2009-08-20 00:16:54 +04:00
|
|
|
foreach ($nodes as $node) {
|
|
|
|
if (!empty($people[$node])) {
|
|
|
|
make_tree($level + 1, $node, $people[$node]);
|
|
|
|
} else {
|
|
|
|
make_tree($level + 1, $node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print "\n</ul>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
require_once "templates/header.php";
|
|
|
|
?>
|
|
|
|
|
2009-08-21 14:26:36 +04:00
|
|
|
<div id="page">
|
|
|
|
|
2009-08-20 00:16:54 +04:00
|
|
|
<div id="orgchart" class="tree">
|
|
|
|
<ul>
|
2009-09-02 14:58:21 +04:00
|
|
|
<?php
|
|
|
|
foreach ($tree_view_roots as $root) {
|
|
|
|
if (!isset($people[$root])) {
|
|
|
|
make_tree(0, $root);
|
|
|
|
} else {
|
|
|
|
make_tree(0, $root, $people[$root]);
|
|
|
|
}
|
|
|
|
}
|
2010-01-26 03:35:38 +03:00
|
|
|
$invisible_managers = array_values(array_diff($managers, $visible_managers));
|
2009-09-02 14:58:21 +04:00
|
|
|
?>
|
2009-08-20 00:16:54 +04:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<br />
|
|
|
|
<div id="orphans" class="tree">
|
|
|
|
<ul>
|
|
|
|
<li>People who need to set their manager</li>
|
|
|
|
<ul>
|
|
|
|
<?php
|
|
|
|
foreach ($orphans as $orphan) {
|
2009-11-27 20:03:35 +03:00
|
|
|
print "\n". $tree->format_item($everyone, $orphan, TRUE);
|
2009-08-20 00:16:54 +04:00
|
|
|
}
|
2010-01-26 03:35:38 +03:00
|
|
|
$invisible_people = array();
|
|
|
|
foreach ($invisible_managers as $invisible_manager) {
|
|
|
|
foreach ($people[$invisible_manager] as $invisible_person) {
|
|
|
|
$invisible_people[] = $invisible_person;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach (array_unique($invisible_people) as $invisible_person) {
|
|
|
|
print "\n". $tree->format_item($everyone, $invisible_person, TRUE);
|
|
|
|
}
|
2009-08-20 00:16:54 +04:00
|
|
|
?>
|
|
|
|
</ul>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="person">
|
|
|
|
</div>
|
|
|
|
|
2009-08-21 14:26:36 +04:00
|
|
|
</div>
|
|
|
|
|
2009-09-02 14:58:21 +04:00
|
|
|
<script type="text/javascript" src="js/view-tree.js"></script>
|
2009-08-20 00:16:54 +04:00
|
|
|
|
|
|
|
<?php require_once "templates/footer.php"; ?>
|