Show foundation employees as well. Bug 720629.

git-svn-id: http://svn.mozilla.org/projects/phonebook/trunk@104459 4eb1ac78-321c-0410-a911-ec516a8615a5
This commit is contained in:
fwenzel@mozilla.com 2012-04-18 03:33:03 +00:00
Родитель 5e48df8e64
Коммит 9a006b6159
2 изменённых файлов: 29 добавлений и 16 удалений

Просмотреть файл

@ -198,14 +198,23 @@ class MozillaSearchAdapter extends SearchAdapter {
class MozillaTreeAdapter extends TreeAdapter { class MozillaTreeAdapter extends TreeAdapter {
public $conf = array( public $conf = array(
"ldap_search_base" => "o=com, dc=mozilla", array( // Corporation
"ldap_search_filter" => "mail=*", "ldap_search_base" => "o=com,dc=mozilla",
"ldap_search_attributes" => array( "ldap_search_filter" => "mail=*",
"sn", "cn", "manager", "title", "mail", "employeeType" "ldap_search_attributes" => array(
"sn", "cn", "manager", "title", "mail", "employeeType"
)
),
array( // Foundation
"ldap_search_base" => "o=org,dc=mozilla",
"ldap_search_filter" => "mail=*",
"ldap_search_attributes" => array(
"sn", "cn", "manager", "title", "mail", "employeeType"
)
) )
); );
public $roots = array( public $roots = array(
"mitchell@mozilla.com", "gkovacs@mozilla.com" "mitchell@mozilla.com", "gkovacs@mozilla.com", "mark@mozillafoundation.org"
); );
public function process_entry($person) { public function process_entry($person) {

Просмотреть файл

@ -8,13 +8,16 @@ $everyone = array();
$tree = new MozillaTreeAdapter($everyone); $tree = new MozillaTreeAdapter($everyone);
$auth = new MozillaAuthAdapter(); $auth = new MozillaAuthAdapter();
$search = ldap_search( $data = array();
$ldapconn, foreach ($tree->conf as $conf) {
$tree->conf["ldap_search_base"], $search = ldap_search(
$tree->conf["ldap_search_filter"], $ldapconn,
$tree->conf["ldap_search_attributes"] $conf["ldap_search_base"],
); $conf["ldap_search_filter"],
$data = ldap_get_entries($ldapconn, $search); $conf["ldap_search_attributes"]
);
$data = array_merge($data, ldap_get_entries($ldapconn, $search));
}
$tree_view_roots = $tree->roots; $tree_view_roots = $tree->roots;
foreach ($data as $person) { foreach ($data as $person) {
@ -22,7 +25,8 @@ foreach ($data as $person) {
$everyone[$mail] = $tree->process_entry($person); $everyone[$mail] = $tree->process_entry($person);
// If a user has a manager, try to find their place in the tree. // If a user has a manager, try to find their place in the tree.
if (!empty($person["manager"][0])) { // Unless they're a root themselves.
if (!in_array($mail, $tree_view_roots) && !empty($person["manager"][0])) {
$manager = $auth->dn_to_email($person["manager"][0]); $manager = $auth->dn_to_email($person["manager"][0]);
if (empty($people[$manager])) { if (empty($people[$manager])) {
$people[$manager] = array($mail); $people[$manager] = array($mail);
@ -86,11 +90,11 @@ require_once "templates/header.php";
<br /> <br />
<div id="orphans" class="tree"> <div id="orphans" class="tree">
<ul> <ul>
<li>People who need to set their manager</li> <li class="hr-node collapsed">People who need to set their manager</li>
<ul> <ul style="display:none">
<?php <?php
foreach ($orphans as $orphan) { foreach ($orphans as $orphan) {
print "\n". $tree->format_item($everyone, $orphan, TRUE); print "\n". $tree->format_item($everyone, $orphan, true);
} }
$invisible_people = array(); $invisible_people = array();
foreach ($invisible_managers as $invisible_manager) { foreach ($invisible_managers as $invisible_manager) {