1 <?php
2 /*
3 * This code is part of GOsa (http://www.gosa-project.org)
4 * Copyright (C) 2003-2008 GONICUS GmbH
5 *
6 * ID: $$Id$$
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
23 class listing {
25 var $xmlData;
26 var $entries;
27 var $departments= array();
28 var $departmentBrowser= false;
29 var $departmentRootVisible= false;
30 var $multiSelect= false;
31 var $template;
32 var $headline;
33 var $module;
34 var $base;
35 var $sortDirection= null;
36 var $sortColumn= null;
37 var $sortAttribute;
38 var $sortType;
39 var $numColumns;
40 var $baseMode= false;
41 var $bases= array();
42 var $header= array();
43 var $colprops= array();
44 var $filters= array();
45 var $pid;
46 var $objectTypes= array();
47 var $objectTypeCount= array();
48 var $objectDnMapping= array();
49 var $copyPasteHandler= null;
50 var $snapshotHandler= null;
51 var $exporter= array();
52 var $exportColumns= array();
53 var $useSpan= false;
54 var $height= 0;
57 function listing($filename)
58 {
59 global $config;
60 global $class_mapping;
62 // Initialize pid
63 $this->pid= preg_replace("/[^0-9]/", "", microtime(TRUE));
65 if (!$this->load($filename)) {
66 die("Cannot parse $filename!");
67 }
69 // Set base for filter
70 if ($this->baseMode) {
71 $this->base= session::global_get("CurrentMainBase");
72 if ($this->base == null) {
73 $this->base= $config->current['BASE'];
74 }
75 $this->refreshBasesList();
76 } else {
77 $this->base= $config->current['BASE'];
78 }
80 // Move footer information
81 $this->showFooter= ($config->get_cfg_value("listSummary") == "true");
83 // Register build in filters
84 $this->registerElementFilter("objectType", "listing::filterObjectType");
85 $this->registerElementFilter("departmentLink", "listing::filterDepartmentLink");
86 $this->registerElementFilter("link", "listing::filterLink");
87 $this->registerElementFilter("actions", "listing::filterActions");
89 // Load exporters
90 foreach($class_mapping as $class => $dummy) {
91 if (preg_match('/Exporter$/', $class)) {
92 $info= call_user_func(array($class, "getInfo"));
93 if ($info != null) {
94 $this->exporter= array_merge($this->exporter, $info);
95 }
96 }
97 }
98 }
101 function setCopyPasteHandler($handler)
102 {
103 $this->copyPasteHandler= &$handler;
104 }
107 function setHeight($height)
108 {
109 $this->height= $height;
110 }
113 function setSnapshotHandler($handler)
114 {
115 $this->snapshotHandler= &$handler;
116 }
119 function setFilter($filter)
120 {
121 $this->filter= &$filter;
122 if ($this->departmentBrowser){
123 $this->departments= $this->getDepartments();
124 }
125 $this->filter->setBase($this->base);
126 }
129 function registerElementFilter($name, $call)
130 {
131 if (!isset($this->filters[$name])) {
132 $this->filters[$name]= $call;
133 return true;
134 }
136 return false;
137 }
140 function load($filename)
141 {
142 $contents = file_get_contents($filename);
143 $this->xmlData= xml::xml2array($contents, 1);
145 if (!isset($this->xmlData['list'])) {
146 return false;
147 }
149 $this->xmlData= $this->xmlData["list"];
151 // Load some definition values
152 foreach (array("departmentBrowser", "departmentRootVisible", "multiSelect", "baseMode") as $token) {
153 if (isset($this->xmlData['definition'][$token]) &&
154 $this->xmlData['definition'][$token] == "true"){
155 $this->$token= true;
156 }
157 }
159 // Fill objectTypes from departments and xml definition
160 $types = departmentManagement::get_support_departments();
161 foreach ($types as $class => $data) {
162 $this->objectTypes[]= array("label" => $data['TITLE'],
163 "objectClass" => $data['OC'],
164 "image" => $data['IMG']);
165 }
166 $this->categories= array();
167 if (isset($this->xmlData['definition']['objectType'])) {
168 if(isset($this->xmlData['definition']['objectType']['label'])) {
169 $this->xmlData['definition']['objectType']= array($this->xmlData['definition']['objectType']);
170 }
171 foreach ($this->xmlData['definition']['objectType'] as $index => $otype) {
172 $this->objectTypes[]= $this->xmlData['definition']['objectType'][$index];
173 if (isset($this->xmlData['definition']['objectType'][$index]['category'])){
174 $this->categories[]= $this->xmlData['definition']['objectType'][$index]['category'];
175 }
176 }
177 }
179 // Parse layout per column
180 $this->colprops= $this->parseLayout($this->xmlData['table']['layout']);
182 // Prepare table headers
183 $this->renderHeader();
185 // Assign headline/module
186 $this->headline= _($this->xmlData['definition']['label']);
187 $this->module= $this->xmlData['definition']['module'];
188 if (!is_array($this->categories)){
189 $this->categories= array($this->categories);
190 }
192 // Evaluate columns to be exported
193 if (isset($this->xmlData['table']['column'])){
194 foreach ($this->xmlData['table']['column'] as $index => $config) {
195 if (isset($config['export']) && $config['export'] == "true"){
196 $this->exportColumns[]= $index;
197 }
198 }
199 }
201 return true;
202 }
205 function renderHeader()
206 {
207 $this->header= array();
208 $this->plainHeader= array();
210 // Initialize sort?
211 $sortInit= false;
212 if (!$this->sortDirection) {
213 $this->sortColumn= 0;
214 if (isset($this->xmlData['definition']['defaultSortColumn'])){
215 $this->sortColumn= $this->xmlData['definition']['defaultSortColumn'];
216 } else {
217 $this->sortAttribute= "";
218 }
219 $this->sortDirection= array();
220 $sortInit= true;
221 }
223 if (isset($this->xmlData['table']['column'])){
224 foreach ($this->xmlData['table']['column'] as $index => $config) {
225 // Initialize everything to one direction
226 if ($sortInit) {
227 $this->sortDirection[$index]= false;
228 }
230 $sorter= "";
231 if ($index == $this->sortColumn && isset($config['sortAttribute']) &&
232 isset($config['sortType'])) {
233 $this->sortAttribute= $config['sortAttribute'];
234 $this->sortType= $config['sortType'];
235 $sorter= " <img border='0' title='".($this->sortDirection[$index]?_("Up"):_("Down"))."' src='images/lists/sort-".($this->sortDirection[$index]?"up":"down").".png' align='top'>";
236 }
237 $sortable= (isset($config['sortAttribute']));
239 $link= "href='?plug=".$_GET['plug']."&PID=".$this->pid."&act=SORT_$index'";
240 if (isset($config['label'])) {
241 if ($sortable) {
242 $this->header[$index]= "<td class='listheader' ".$this->colprops[$index]."><a $link>"._($config['label'])."$sorter</a></td>";
243 } else {
244 $this->header[$index]= "<td class='listheader' ".$this->colprops[$index].">"._($config['label'])."</td>";
245 }
246 $this->plainHeader[]= _($config['label']);
247 } else {
248 if ($sortable) {
249 $this->header[$index]= "<td class='listheader' ".$this->colprops[$index]."><a $link> $sorter</a></td>";
250 } else {
251 $this->header[$index]= "<td class='listheader' ".$this->colprops[$index]."> </td>";
252 }
253 $this->plainHeader[]= "";
254 }
255 }
256 }
257 }
260 function render()
261 {
262 // Check for exeeded sizelimit
263 if (($message= check_sizelimit()) != ""){
264 return($message);
265 }
267 // Initialize list
268 $result= "<input type='hidden' value='$this->pid' name='PID'>\n";
269 $height= 450;
270 if ($this->height != 0) {
271 $result.= "<input type='hidden' value='$this->height' id='d_height'>\n";
272 $height= $this->height;
273 }
275 $result.= "<table cellpadding='0' cellspacing='0' border='0'><tr><td><div class='listContainer' id='d_scrollbody' style='border-top:1px solid #B0B0B0;width:700px;height:".($height+25)."px;'>\n";
277 $result.= "<table summary='$this->headline' style='height:99%;width:100%; table-layout:fixed;' cellspacing='0' cellpadding='0' id='t_scrolltable'>\n";
278 $this->numColumns= count($this->colprops) + ($this->multiSelect?1:0);
280 // Build list header
281 $result.= "<thead class='fixedListHeader listHeaderFormat'><tr>\n";
282 if ($this->multiSelect) {
283 $result.= "<td class='listheader' style='text-align:center;padding:0;width:24px;'><input type='checkbox' id='select_all' name='select_all' title='"._("Select all")."' onClick='toggle_all_(\"listing_selected_[0-9]*$\",\"select_all\");' ></td>\n";
284 }
285 foreach ($this->header as $header) {
286 $result.= $header;
287 }
288 $result.= "</tr></thead>\n";
290 // Build list body
291 $result.= "<tbody class='listScrollContent listBodyFormat' id='t_nscrollbody' style='height:".$height."px;'>\n";
293 // No results? Just take an empty colspanned row
294 if (count($this->entries) + count($this->departments) == 0) {
295 $result.= "<tr class='rowxp0'><td class='list1nohighlight' colspan='$this->numColumns' style='height:100%;border-right:0px;width:100%;'> </td></tr>";
296 }
298 // Line color alternation
299 $alt= 0;
300 $deps= 0;
302 // Draw department browser if configured and we're not in sub mode
303 $this->useSpan= false;
304 if ($this->departmentBrowser && $this->filter->scope != "sub") {
305 // Fill with department browser if configured this way
306 $departmentIterator= new departmentSortIterator($this->departments, $this->sortDirection[$this->sortColumn]);
307 foreach ($departmentIterator as $row => $entry){
308 $result.="<tr class='rowxp".($alt&1)."'>";
310 // Render multi select if needed
311 if ($this->multiSelect) {
312 $result.="<td style='text-align:center;width:24px;padding:0;' class='list1'> </td>";
313 }
315 // Render defined department columns, fill the rest with some stuff
316 $rest= $this->numColumns - 1;
317 foreach ($this->xmlData['table']['department'] as $index => $config) {
318 $colspan= 1;
319 if (isset($config['span'])){
320 $colspan= $config['span'];
321 $this->useSpan= true;
322 }
323 $result.="<td colspan='$colspan' ".$this->colprops[$index]." class='list1'>".$this->renderCell($config['value'], $entry, $row)."</td>";
324 $rest-= $colspan;
325 }
327 // Fill remaining cols with nothing
328 $last= $this->numColumns - $rest;
329 for ($i= 0; $i<$rest; $i++){
330 $result.= "<td ".$this->colprops[$last+$i-1]." class='list1'> </td>";
331 }
332 $result.="</tr>";
334 $alt++;
335 }
336 $deps= $alt;
337 }
339 // Fill with contents, sort as configured
340 foreach ($this->entries as $row => $entry) {
341 $trow= "";
343 // Render multi select if needed
344 if ($this->multiSelect) {
345 $trow.="<td style='text-align:center;width:20px;' class='list0'><input type='checkbox' id='listing_selected_$row' name='listing_selected_$row'></td>\n";
346 }
348 foreach ($this->xmlData['table']['column'] as $index => $config) {
349 $renderedCell= $this->renderCell($config['value'], $entry, $row);
350 $trow.="<td ".$this->colprops[$index]." class='list0'>".$renderedCell."</td>\n";
352 // Save rendered column
353 $sort= preg_replace('/.*>([^<]+)<.*$/', '$1', $renderedCell);
354 $sort= preg_replace('/ /', '', $sort);
355 if (preg_match('/</', $sort)){
356 $sort= "";
357 }
358 $this->entries[$row]["_sort$index"]= $sort;
359 }
361 // Save rendered entry
362 $this->entries[$row]['_rendered']= $trow;
363 }
365 // Complete list by sorting entries for _sort$index and appending them to the output
366 $entryIterator= new listingSortIterator($this->entries, $this->sortDirection[$this->sortColumn], "_sort".$this->sortColumn, $this->sortType);
367 foreach ($entryIterator as $row => $entry){
368 $alt++;
369 $result.="<tr class='rowxp".($alt&1)."'>\n";
370 $result.= $entry['_rendered'];
371 $result.="</tr>\n";
372 }
374 // Need to fill the list if it's not full (nobody knows why this is 22 ;-))
375 $emptyListStyle= (count($this->entries) + (($this->useSpan && count($this->entries))?$deps:0) == 0)?"border:0;":"";
376 if ((count($this->entries) + $deps) < 22) {
377 $result.= "<tr>";
378 for ($i= 0; $i<$this->numColumns; $i++) {
379 if ($i == 0) {
380 $result.= "<td class='list1nohighlight' style='$emptyListStyle height:100%;'> </td>";
381 continue;
382 }
383 if ($i != $this->numColumns-1) {
384 $result.= "<td class='list1nohighlight' style='$emptyListStyle'> </td>";
385 } else {
386 $result.= "<td class='list1nohighlight' style='border-right:1px solid #AAA;$emptyListStyle'> </td>";
387 }
388 }
389 $result.= "</tr>";
390 }
392 // Close list body
393 $result.= "</tbody></table></div></td></tr>";
395 // Add the footer if requested
396 if ($this->showFooter) {
397 $result.= "<tr><td class='nlistFooter'>";
399 foreach ($this->objectTypes as $objectType) {
400 if (isset($this->objectTypeCount[$objectType['label']])) {
401 $label= _($objectType['label']);
402 $result.= "<img class='center' src='".$objectType['image']."' title='$label' alt='$label'> ".$this->objectTypeCount[$objectType['label']]." ";
403 }
404 }
406 $result.= "</td></tr>";
407 }
409 // Close list
410 $result.= "</table>";
412 $smarty= get_smarty();
413 $smarty->assign("usePrototype", "true");
414 $smarty->assign("FILTER", $this->filter->render());
415 $smarty->assign("SIZELIMIT", print_sizelimit_warning());
416 $smarty->assign("LIST", $result);
418 // Assign navigation elements
419 $nav= $this->renderNavigation();
420 foreach ($nav as $key => $html) {
421 $smarty->assign($key, $html);
422 }
424 // Assign action menu / base
425 $smarty->assign("ACTIONS", $this->renderActionMenu());
426 $smarty->assign("BASE", $this->renderBase());
428 // Assign separator
429 $smarty->assign("SEPARATOR", "<img src='images/lists/seperator.png' alt='-' align='middle' height='16' width='1' class='center'>");
431 // Assign summary
432 $smarty->assign("HEADLINE", $this->headline);
434 return ($smarty->fetch(get_template_path($this->xmlData['definition']['template'], true)));
435 }
438 function update()
439 {
440 global $config;
441 $ui= get_userinfo();
443 // Reset object counter / DN mapping
444 $this->objectTypeCount= array();
445 $this->objectDnMapping= array();
447 // Do not do anything if this is not our PID
448 if(isset($_REQUEST['PID']) && $_REQUEST['PID'] != $this->pid) {
449 return;
450 }
452 // Save base
453 if (isset($_POST['BASE']) && $this->baseMode) {
454 $base= get_post('BASE');
455 if (isset($this->bases[$base])) {
456 $this->base= $base;
457 session::global_set("CurrentMainBase", $this->base);
458 }
459 }
461 // Override the base if we got a message from the browser navigation
462 if ($this->departmentBrowser && isset($_GET['act'])) {
463 if (preg_match('/^department_([0-9]+)$/', validate($_GET['act']), $match)){
464 if (isset($this->departments[$match[1]])){
465 $this->base= $this->departments[$match[1]]['dn'];
466 session::global_set("CurrentMainBase", $this->base);
467 }
468 }
469 }
471 // Filter POST with "act" attributes -> posted from action menu
472 if (isset($_POST['exec_act']) && $_POST['act'] != '') {
473 if (preg_match('/^export.*$/', $_POST['act']) && isset($this->exporter[$_POST['act']])) {
474 $exporter= $this->exporter[$_POST['act']];
475 $userinfo= ", "._("created by")." ".$ui->cn." - ".strftime('%A, %d. %B %Y, %H:%M:%S');
476 $entryIterator= new listingSortIterator($this->entries, $this->sortDirection[$this->sortColumn], "_sort".$this->sortColumn, $this->sortType);
477 $sortedEntries= array();
478 foreach ($entryIterator as $entry){
479 $sortedEntries[]= $entry;
480 }
481 $instance= new $exporter['class']($this->headline.$userinfo, $this->plainHeader, $sortedEntries, $this->exportColumns);
482 $type= call_user_func(array($exporter['class'], "getInfo"));
483 $type= $type[$_POST['act']];
484 send_binary_content($instance->query(), $type['filename'], $type= $type['mime']);
485 }
486 }
488 // Filter GET with "act" attributes
489 if (isset($_GET['act'])) {
490 $key= validate($_GET['act']);
491 if (preg_match('/^SORT_([0-9]+)$/', $key, $match)) {
492 // Switch to new column or invert search order?
493 $column= $match[1];
494 if ($this->sortColumn != $column) {
495 $this->sortColumn= $column;
496 } else {
497 $this->sortDirection[$column]= !$this->sortDirection[$column];
498 }
500 // Allow header to update itself according to the new sort settings
501 $this->renderHeader();
502 }
503 }
505 // Override base if we got signals from the navigation elements
506 $action= "";
507 foreach ($_POST as $key => $value) {
508 if (preg_match('/^(ROOT|BACK|HOME)_x$/', $key, $match)) {
509 $action= $match[1];
510 break;
511 }
512 }
514 // Navigation handling
515 if ($action == 'ROOT') {
516 $deps= $ui->get_module_departments($this->module);
517 $this->base= $deps[0];
518 }
519 if ($action == 'BACK') {
520 $deps= $ui->get_module_departments($this->module);
521 $base= preg_replace("/^[^,]+,/", "", $this->base);
522 if(in_array_ics($base, $deps)){
523 $this->base= $base;
524 }
525 }
526 if ($action == 'HOME') {
527 $ui= get_userinfo();
528 $this->base= $this->filter->getObjectBase($ui->dn);
529 }
531 // Reload departments
532 if ($this->departmentBrowser){
533 $this->departments= $this->getDepartments();
534 }
536 // Update filter and refresh entries
537 $this->filter->setBase($this->base);
538 $this->entries= $this->filter->query();
539 }
542 function setBase($base)
543 {
544 $this->base= $base;
545 }
548 function getBase()
549 {
550 return $this->base;
551 }
554 function parseLayout($layout)
555 {
556 $result= array();
557 $layout= preg_replace("/^\|/", "", $layout);
558 $layout= preg_replace("/\|$/", "", $layout);
559 $cols= split("\|", $layout);
561 foreach ($cols as $index => $config) {
562 if ($config != "") {
563 $res= "";
564 $components= split(';', $config);
565 foreach ($components as $part) {
566 if (preg_match("/^r$/", $part)) {
567 $res.= "text-align:right;";
568 continue;
569 }
570 if (preg_match("/^l$/", $part)) {
571 $res.= "text-align:left;";
572 continue;
573 }
574 if (preg_match("/^c$/", $part)) {
575 $res.= "text-align:center;";
576 continue;
577 }
578 if (preg_match("/^[0-9]+(|px|%)$/", $part)) {
579 $res.= "width:$part;min-width:$part;";
580 continue;
581 }
582 }
584 // Add minimum width for scalable columns
585 if (!preg_match('/width:/', $res)){
586 $res.= "min-width:200px;";
587 }
589 $result[$index]= " style='$res' ";
590 } else {
591 $result[$index]= " style='min-width:100px'";
592 }
593 }
595 // Save number of columns for later use
596 $this->numColumns= count($cols);
598 return $result;
599 }
602 function renderCell($data, $config, $row)
603 {
604 // Replace flat attributes in data string
605 for ($i= 0; $i<$config['count']; $i++) {
606 $attr= $config[$i];
607 $value= "";
608 if (is_array($config[$attr])) {
609 $value= $config[$attr][0];
610 } else {
611 $value= $config[$attr];
612 }
613 $data= preg_replace("/%\{$attr\}/", $value, $data);
614 }
616 // Watch out for filters and prepare to execute them
617 $data= $this->processElementFilter($data, $config, $row);
619 // Replace all non replaced %{...} instances because they
620 // are non resolved attributes or filters
621 $data= preg_replace('/%{[^}]+}/', ' ', $data);
623 return $data;
624 }
627 function renderBase()
628 {
629 if (!$this->baseMode) {
630 return;
631 }
633 $result= "<select name='BASE' onChange='mainform.submit()' size='1'>";
634 $firstDN= null;
635 $found= false;
637 foreach ($this->bases as $key=>$value) {
638 // Keep first entry to fall back eventually
639 if(!$firstDN) {
640 $firstDN= $key;
641 }
643 // Prepare to render entry
644 $selected= "";
645 if ($key == $this->base) {
646 $selected= " selected";
647 $found= true;
648 }
649 $key = htmlentities($key,ENT_QUOTES);
650 $result.= "\n<option value=\"".$key."\"$selected>".$value."</option>";
651 }
653 $result.= "</select>";
655 // Reset the currently used base to the first DN we found if there
656 // was no match.
657 if(!$found){
658 $this->base = $firstDN;
659 }
661 return $result;
662 }
665 function processElementFilter($data, $config, $row)
666 {
667 preg_match_all("/%\{filter:([^(]+)\((.*)\)\}/", $data, $matches, PREG_SET_ORDER);
669 foreach ($matches as $match) {
670 $cl= "";
671 $method= "";
672 if (preg_match('/::/', $match[1])) {
673 $cl= preg_replace('/::.*$/', '', $match[1]);
674 $method= preg_replace('/^.*::/', '', $match[1]);
675 } else {
676 if (!isset($this->filters[$match[1]])) {
677 continue;
678 }
679 $cl= preg_replace('/::.*$/', '', $this->filters[$match[1]]);
680 $method= preg_replace('/^.*::/', '', $this->filters[$match[1]]);
681 }
683 // Prepare params for function call
684 $params= array();
685 preg_match_all('/"[^"]+"|[^,]+/', $match[2], $parts);
686 foreach ($parts[0] as $param) {
688 // Row is replaced by the row number
689 if ($param == "row") {
690 $params[]= $row;
691 }
693 // pid is replaced by the current PID
694 if ($param == "pid") {
695 $params[]= $this->pid;
696 }
698 // base is replaced by the current base
699 if ($param == "base") {
700 $params[]= $this->getBase();
701 }
703 // Fixie with "" is passed directly
704 if (preg_match('/^".*"$/', $param)){
705 $params[]= preg_replace('/"/', '', $param);
706 }
708 // LDAP variables get replaced by their objects
709 for ($i= 0; $i<$config['count']; $i++) {
710 if ($param == $config[$i]) {
711 $values= $config[$config[$i]];
712 if (is_array($values)){
713 unset($values['count']);
714 }
715 $params[]= $values;
716 }
717 }
719 // Move dn if needed
720 if ($param == "dn") {
721 $params[]= LDAP::fix($config["dn"]);
722 }
723 }
725 // Replace information
726 if ($cl == "listing") {
727 // Non static call - seems to result in errors
728 $data= @preg_replace('/'.preg_quote($match[0]).'/', call_user_func_array(array($this, "$method"), $params), $data);
729 } else {
730 // Static call
731 $data= preg_replace('/'.preg_quote($match[0]).'/', call_user_func_array(array($cl, $method), $params), $data);
732 }
733 }
735 return $data;
736 }
739 function getObjectType($types, $classes)
740 {
741 // Walk thru types and see if there's something matching
742 foreach ($types as $objectType) {
743 $ocs= $objectType['objectClass'];
744 if (!is_array($ocs)){
745 $ocs= array($ocs);
746 }
748 $found= true;
749 foreach ($ocs as $oc){
750 if (preg_match('/^!(.*)$/', $oc, $match)) {
751 $oc= $match[1];
752 if (in_array($oc, $classes)) {
753 $found= false;
754 }
755 } else {
756 if (!in_array($oc, $classes)) {
757 $found= false;
758 }
759 }
760 }
762 if ($found) {
763 return $objectType;
764 }
765 }
767 return null;
768 }
771 function filterObjectType($dn, $classes)
772 {
773 // Walk thru classes and return on first match
774 $result= " ";
776 $objectType= $this->getObjectType($this->objectTypes, $classes);
777 if ($objectType) {
778 $this->objectDnMapping[$dn]= $objectType["objectClass"];
779 $result= "<img class='center' title='".LDAP::fix($dn)."' src='".$objectType["image"]."'>";
780 if (!isset($this->objectTypeCount[$objectType['label']])) {
781 $this->objectTypeCount[$objectType['label']]= 0;
782 }
783 $this->objectTypeCount[$objectType['label']]++;
784 }
786 return $result;
787 }
790 function filterActions($dn, $row, $classes)
791 {
792 // Do nothing if there's no menu defined
793 if (!isset($this->xmlData['actiontriggers']['action'])) {
794 return " ";
795 }
797 // Go thru all actions
798 $result= "";
799 $actions= $this->xmlData['actiontriggers']['action'];
800 foreach($actions as $action) {
801 // Skip the entry completely if there's no permission to execute it
802 if (!$this->hasActionPermission($action, $dn)) {
803 $result.= "<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
804 continue;
805 }
807 // Skip entry if the pseudo filter does not fit
808 if (isset($action['filter']) && preg_match('/^[a-z0-9_]+!?=[a-z0-9_]+$/i', $action['filter'])) {
809 list($fa, $fv)= split('=', $action['filter']);
810 if (preg_match('/^(.*)!$/', $fa, $m)){
811 $fa= $m[1];
812 if (isset($this->entries[$row][$fa]) && $this->entries[$row][$fa][0] == $fv) {
813 $result.= "<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
814 continue;
815 }
816 } else {
817 if (!isset($this->entries[$row][$fa]) && !$this->entries[$row][$fa][0] == $fv) {
818 $result.= "<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
819 continue;
820 }
821 }
822 }
825 // If there's an objectclass definition and we don't have it
826 // add an empty picture here.
827 if (isset($action['objectclass'])){
828 $objectclass= $action['objectclass'];
829 if (preg_match('/^!(.*)$/', $objectclass, $m)){
830 $objectclass= $m[1];
831 if(in_array($objectclass, $classes)) {
832 $result.= "<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
833 continue;
834 }
835 } else {
836 if(!in_array($objectclass, $classes)) {
837 $result.= "<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
838 continue;
839 }
840 }
841 }
843 // Render normal entries as usual
844 if ($action['type'] == "entry") {
845 $label= $this->processElementFilter($action['label'], $this->entries[$row], $row);
846 $image= $this->processElementFilter($action['image'], $this->entries[$row], $row);
847 $result.="<input class='center' type='image' src='$image' title='$label' ".
848 "name='listing_".$action['name']."_$row' style='padding:1px'>";
849 }
851 // Handle special types
852 if ($action['type'] == "copypaste" || $action['type'] == "snapshot") {
854 $objectType= $this->getObjectType($this->objectTypes, $this->entries[$row]['objectClass']);
855 $category= $class= null;
856 if ($objectType) {
857 $category= $objectType['category'];
858 $class= $objectType['class'];
859 }
861 if ($action['type'] == "copypaste") {
862 $result.= $this->renderCopyPasteActions($row, $this->entries[$row]['dn'], $category, $class);
863 } else {
864 $result.= $this->renderSnapshotActions($row, $this->entries[$row]['dn'], $category, $class);
865 }
866 }
867 }
869 return $result;
870 }
873 function filterDepartmentLink($row, $dn, $description)
874 {
875 $attr= $this->departments[$row]['sort-attribute'];
876 $name= $this->departments[$row][$attr];
877 if (is_array($name)){
878 $name= $name[0];
879 }
880 $result= sprintf("%s [%s]", $name, $description[0]);
881 return("<a href='?plug=".$_GET['plug']."&PID=$this->pid&act=department_$row' title='$dn'>$result</a>");
882 }
885 function filterLink()
886 {
887 $result= " ";
889 $row= func_get_arg(0);
890 $pid= $this->pid;
891 $dn= LDAP::fix(func_get_arg(1));
892 $params= array(func_get_arg(2));
894 // Collect sprintf params
895 for ($i = 3;$i < func_num_args();$i++) {
896 $val= func_get_arg($i);
897 if (is_array($val)){
898 $params[]= $val[0];
899 continue;
900 }
901 $params[]= $val;
902 }
904 $result= " ";
905 $trans= call_user_func_array("sprintf", $params);
906 if ($trans != "") {
907 return("<a href='?plug=".$_GET['plug']."&PID=$pid&act=listing_edit_$row' title='$dn'>$trans</a>");
908 }
910 return $result;
911 }
914 function renderNavigation()
915 {
916 $result= array();
917 $enableBack = true;
918 $enableRoot = true;
919 $enableHome = true;
921 $ui = get_userinfo();
923 /* Check if base = first available base */
924 $deps = $ui->get_module_departments($this->module);
926 if(!count($deps) || $deps[0] == $this->filter->base){
927 $enableBack = false;
928 $enableRoot = false;
929 }
931 $listhead ="";
933 /* Check if we are in users home department */
934 if(!count($deps) || $this->filter->base == $this->filter->getObjectBase($ui->dn)){
935 $enableHome = false;
936 }
938 /* Draw root button */
939 if($enableRoot){
940 $result["ROOT"]= "<input class='center' type='image' src='images/lists/root.png' align='middle' ".
941 "title='"._("Go to root department")."' name='ROOT' alt='"._("Root")."'>";
942 }else{
943 $result["ROOT"]= "<img src='images/lists/root_grey.png' class='center' alt='"._("Root")."'>";
944 }
946 /* Draw back button */
947 if($enableBack){
948 $result["BACK"]= "<input class='center' type='image' align='middle' src='images/lists/back.png' ".
949 "title='"._("Go up one department")."' alt='"._("Up")."' name='BACK'>";
950 }else{
951 $result["BACK"]= "<img src='images/lists/back_grey.png' class='center' alt='"._("Up")."'>";
952 }
954 /* Draw home button */
955 if($enableHome){
956 $result["HOME"]= "<input class='center' type='image' align='middle' src='images/lists/home.png' ".
957 "title='"._("Go to users department")."' alt='"._("Home")."' name='HOME'>";
958 }else{
959 $result["HOME"]= "<img src='images/lists/home_grey.png' class='center' alt='"._("Home")."'>";
960 }
962 /* Draw reload button, this button is enabled everytime */
963 $result["RELOAD"]= "<input class='center' type='image' src='images/lists/reload.png' align='middle' ".
964 "title='"._("Reload list")."' name='REFRESH' alt='"._("Submit")."'>";
966 return ($result);
967 }
970 function getAction()
971 {
972 // Do not do anything if this is not our PID, or there's even no PID available...
973 if(!isset($_REQUEST['PID']) || $_REQUEST['PID'] != $this->pid) {
974 return;
975 }
977 $result= array("targets" => array(), "action" => "");
979 // Filter GET with "act" attributes
980 if (isset($_GET['act'])) {
981 $key= validate($_GET['act']);
982 $target= preg_replace('/^listing_[a-zA-Z_]+_([0-9]+)$/', '$1', $key);
983 if (isset($this->entries[$target]['dn'])) {
984 $result['action']= preg_replace('/^listing_([a-zA-Z_]+)_[0-9]+$/', '$1', $key);
985 $result['targets'][]= $this->entries[$target]['dn'];
986 }
988 // Drop targets if empty
989 if (count($result['targets']) == 0) {
990 unset($result['targets']);
991 }
992 return $result;
993 }
995 // Filter POST with "listing_" attributes
996 foreach ($_POST as $key => $prop) {
998 // Capture selections
999 if (preg_match('/^listing_selected_[0-9]+$/', $key)) {
1000 $target= preg_replace('/^listing_selected_([0-9]+)$/', '$1', $key);
1001 if (isset($this->entries[$target]['dn'])) {
1002 $result['targets'][]= $this->entries[$target]['dn'];
1003 }
1004 continue;
1005 }
1007 // Capture action with target - this is a one shot
1008 if (preg_match('/^listing_[a-zA-Z_]+_[0-9]+(|_x)$/', $key)) {
1009 $target= preg_replace('/^listing_[a-zA-Z_]+_([0-9]+)(|_x)$/', '$1', $key);
1010 if (isset($this->entries[$target]['dn'])) {
1011 $result['action']= preg_replace('/^listing_([a-zA-Z_]+)_[0-9]+(|_x)$/', '$1', $key);
1012 $result['targets']= array($this->entries[$target]['dn']);
1013 }
1014 break;
1015 }
1017 // Capture action without target
1018 if (preg_match('/^listing_[a-zA-Z_]+(|_x)$/', $key)) {
1019 $result['action']= preg_replace('/^listing_([a-zA-Z_]+)(|_x)$/', '$1', $key);
1020 continue;
1021 }
1022 }
1024 // Filter POST with "act" attributes -> posted from action menu
1025 if (isset($_POST['act']) && $_POST['act'] != '') {
1026 if (!preg_match('/^export.*$/', $_POST['act'])){
1027 $result['action']= validate($_POST['act']);
1028 }
1029 }
1031 // Drop targets if empty
1032 if (count($result['targets']) == 0) {
1033 unset($result['targets']);
1034 }
1035 return $result;
1036 }
1039 function renderActionMenu()
1040 {
1041 // Don't send anything if the menu is not defined
1042 if (!isset($this->xmlData['actionmenu']['action'])){
1043 return "";
1044 }
1046 // Array?
1047 if (isset($this->xmlData['actionmenu']['action']['type'])){
1048 $this->xmlData['actionmenu']['action']= array($this->xmlData['actionmenu']['action']);
1049 }
1051 // Load shortcut
1052 $actions= &$this->xmlData['actionmenu']['action'];
1053 $result= "<input type='hidden' name='act' id='actionmenu' value=''><div style='display:none'><input type='submit' name='exec_act' id='exec_act' value=''></div>".
1054 "<ul class='level1' id='root'><li><a href='#'>"._("Actions")." <img ".
1055 "border=0 class='center' src='images/lists/sort-down.png'></a>";
1057 // Build ul/li list
1058 $result.= $this->recurseActions($actions);
1060 return "<div id='pulldown'>".$result."</li></ul><div>";
1061 }
1064 function recurseActions($actions)
1065 {
1066 global $class_mapping;
1067 static $level= 2;
1068 $result= "<ul class='level$level'>";
1069 $separator= "";
1071 foreach ($actions as $action) {
1073 // Skip the entry completely if there's no permission to execute it
1074 if (!$this->hasActionPermission($action, $this->filter->base)) {
1075 continue;
1076 }
1078 // Skip entry if there're missing dependencies
1079 if (isset($action['depends'])) {
1080 $deps= is_array($action['depends'])?$action['depends']:array($action['depends']);
1081 foreach($deps as $clazz) {
1082 if (!isset($class_mapping[$clazz])){
1083 continue 2;
1084 }
1085 }
1086 }
1088 // Fill image if set
1089 $img= "";
1090 if (isset($action['image'])){
1091 $img= "<img border='0' class='center' src='".$action['image']."'> ";
1092 }
1094 if ($action['type'] == "separator"){
1095 $separator= " style='border-top:1px solid #AAA' ";
1096 continue;
1097 }
1099 // Dive into subs
1100 if ($action['type'] == "sub" && isset($action['action'])) {
1101 $level++;
1102 if (isset($action['label'])){
1103 $result.= "<li$separator><a href='#'>$img"._($action['label'])." <img border='0' src='images/forward-arrow.png'></a>";
1104 }
1106 // Ensure we've an array of actions, this enables sub menus with only one action.
1107 if(isset($action['action']['type'])){
1108 $action['action'] = array($action['action']);
1109 }
1111 $result.= $this->recurseActions($action['action'])."</li>";
1112 $level--;
1113 $separator= "";
1114 continue;
1115 }
1117 // Render entry elseways
1118 if (isset($action['label'])){
1119 $result.= "<li$separator><a href='#' onClick='document.getElementById(\"actionmenu\").value= \"".$action['name']."\";mainform.submit();'>$img"._($action['label'])."</a></li>";
1120 }
1122 // Check for special types
1123 switch ($action['type']) {
1124 case 'copypaste':
1125 $result.= $this->renderCopyPasteMenu($separator);
1126 break;
1128 case 'snapshot':
1129 $result.= $this->renderSnapshotMenu($separator);
1130 break;
1132 case 'exporter':
1133 $result.= $this->renderExporterMenu($separator);
1134 break;
1136 case 'daemon':
1137 $result.= $this->renderDaemonMenu($separator);
1138 break;
1139 }
1141 $separator= "";
1142 }
1144 $result.= "</ul>";
1145 return $result;
1146 }
1149 function hasActionPermission($action, $dn)
1150 {
1151 $ui= get_userinfo();
1153 if (isset($action['acl'])) {
1154 $acls= $action['acl'];
1155 if (!is_array($acls)) {
1156 $acls= array($acls);
1157 }
1159 // Every ACL has to pass
1160 foreach ($acls as $acl) {
1161 $module= $this->module;
1162 $aclList= array();
1164 // Split for category and plugins if needed
1165 // match for "[rw]" style entries
1166 if (preg_match('/^\[([rwcdm]+)\]$/', $acl, $match)){
1167 $aclList= array($match[1]);
1168 }
1170 // match for "users[rw]" style entries
1171 if (preg_match('/^([a-zA-Z0-9]+)\[([rwcdm]+)\]$/', $acl, $match)){
1172 $module= $match[1];
1173 $aclList= array($match[2]);
1174 }
1176 // match for "users/user[rw]" style entries
1177 if (preg_match('/^([a-zA-Z0-9]+\/[a-zA-Z0-9]+)\[([rwcdm]+)\]$/', $acl, $match)){
1178 $module= $match[1];
1179 $aclList= array($match[2]);
1180 }
1182 // match "users/user[userPassword:rw(,...)*]" style entries
1183 if (preg_match('/^([a-zA-Z0-9]+\/[a-zA-Z0-9]+)\[([a-zA-Z0-9]+:[rwcdm]+(,[a-zA-Z0-9]+:[rwcdm]+)*)\]$/', $acl, $match)){
1184 $module= $match[1];
1185 $aclList= split(',', $match[2]);
1186 }
1188 // Walk thru prepared ACL by using $module
1189 foreach($aclList as $sAcl) {
1190 $checkAcl= "";
1192 // Category or detailed permission?
1193 if (strpos('/', $module) === false) {
1194 if (preg_match('/([a-zA-Z0-9]+):([rwcdm]+)/', $sAcl, $m) ) {
1195 $checkAcl= $ui->get_permissions($dn, $module, $m[1]);
1196 $sAcl= $m[2];
1197 } else {
1198 $checkAcl= $ui->get_permissions($dn, $module, '0');
1199 }
1200 } else {
1201 $checkAcl= $ui->get_category_permissions($dn, $module);
1202 }
1204 // Split up remaining part of the acl and check if it we're
1205 // allowed to do something...
1206 $parts= str_split($sAcl);
1207 foreach ($parts as $part) {
1208 if (strpos($checkAcl, $part) === false){
1209 return false;
1210 }
1211 }
1213 }
1214 }
1215 }
1217 return true;
1218 }
1221 function refreshBasesList()
1222 {
1223 global $config;
1224 $ui= get_userinfo();
1226 // Do some array munching to get it user friendly
1227 $ids= $config->idepartments;
1228 $d= $ui->get_module_departments($this->module);
1229 $k_ids= array_keys($ids);
1230 $deps= array_intersect($d,$k_ids);
1232 // Fill internal bases list
1233 $this->bases= array();
1234 foreach($k_ids as $department){
1235 $this->bases[$department] = $ids[$department];
1236 }
1237 }
1240 function getDepartments()
1241 {
1242 $departments= array();
1243 $ui= get_userinfo();
1245 // Get list of supported department types
1246 $types = departmentManagement::get_support_departments();
1248 // Load departments allowed by ACL
1249 $validDepartments = $ui->get_module_departments($this->module);
1251 // Build filter and look in the LDAP for possible sub departments
1252 // of current base
1253 $filter= "(&(objectClass=gosaDepartment)(|";
1254 $attrs= array("description", "objectClass");
1255 foreach($types as $name => $data){
1256 $filter.= "(objectClass=".$data['OC'].")";
1257 $attrs[]= $data['ATTR'];
1258 }
1259 $filter.= "))";
1260 $res= get_list($filter, $this->module, $this->base, $attrs, GL_NONE);
1262 // Analyze list of departments
1263 foreach ($res as $department) {
1264 if (!in_array($department['dn'], $validDepartments)) {
1265 continue;
1266 }
1268 // Add the attribute where we use for sorting
1269 $oc= null;
1270 foreach(array_keys($types) as $type) {
1271 if (in_array($type, $department['objectClass'])) {
1272 $oc= $type;
1273 break;
1274 }
1275 }
1276 $department['sort-attribute']= $types[$oc]['ATTR'];
1278 // Move to the result list
1279 $departments[]= $department;
1280 }
1282 return $departments;
1283 }
1286 function renderCopyPasteMenu($separator, $copy= true, $cut= true)
1287 {
1288 // We can only provide information if we've got a copypaste handler
1289 // instance
1290 if(!(isset($this->copyPasteHandler) && is_object($this->copyPasteHandler))){
1291 return "";
1292 }
1294 // Presets
1295 $result= "";
1296 $read= $paste= false;
1297 $ui= get_userinfo();
1299 // Switch flags to on if there's at least one category which allows read/paste
1300 foreach($this->categories as $category){
1301 $read= $read || preg_match('/r/', $ui->get_category_permissions($this->base, $category));
1302 $paste= $paste || $ui->is_pasteable($this->base, $category) == 1;
1303 }
1306 // Draw entries that allow copy and cut
1307 if($read){
1309 // Copy entry
1310 if($copy){
1311 $result.= "<li$separator><a href='#' onClick='document.getElementById(\"actionmenu\").value= \"copy\";document.getElementById(\"exec_act\").click();'><img src='images/lists/copy.png' alt='' border='0' class='center'> "._("Copy")."</a></li>";
1312 $separator= "";
1313 }
1315 // Cut entry
1316 if($cut){
1317 $result.= "<li$separator><a href='#' onClick='document.getElementById(\"actionmenu\").value= \"cut\";document.getElementById(\"exec_act\").click();'><img src='images/lists/cut.png' alt='' border='0' class='center'> "._("Cut")."</a></li>";
1318 $separator= "";
1319 }
1320 }
1322 // Draw entries that allow pasting entries
1323 if($paste){
1324 if($this->copyPasteHandler->entries_queued()){
1325 $result.= "<li$separator><a href='#' onClick='document.getElementById(\"actionmenu\").value= \"paste\";document.getElementById(\"exec_act\").click();'><img src='images/lists/paste.png' alt='' border='0' class='center'> "._("Paste")."</a></li>";
1326 }else{
1327 $result.= "<li$separator><a href='#'><img src='images/lists/paste-grey.png' alt='' border='0' class='center'> "._("Paste")."</a></li>";
1328 }
1329 }
1331 return($result);
1332 }
1335 function renderCopyPasteActions($row, $dn, $category, $class, $copy= true, $cut= true)
1336 {
1337 // We can only provide information if we've got a copypaste handler
1338 // instance
1339 if(!(isset($this->copyPasteHandler) && is_object($this->copyPasteHandler))){
1340 return "";
1341 }
1343 // Presets
1344 $ui = get_userinfo();
1345 $result = "";
1347 // Render cut entries
1348 if($cut){
1349 if($ui->is_cutable($dn, $category, $class)){
1350 $result .= "<input class='center' type='image'
1351 src='images/lists/cut.png' alt='"._("Cut")."' name='listing_cut_$row' title='"._("Cut this entry")."' style='padding:1px'>";
1352 }else{
1353 $result.="<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
1354 }
1355 }
1357 // Render copy entries
1358 if($copy){
1359 if($ui->is_copyable($dn, $category, $class)){
1360 $result.= "<input class='center' type='image'
1361 src='images/lists/copy.png' alt='"._("Copy")."' name='listing_copy_$row' title='"._("Copy this entry")."' style='padding:1px'>";
1362 }else{
1363 $result.="<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
1364 }
1365 }
1367 return($result);
1368 }
1371 function renderSnapshotMenu($separator)
1372 {
1373 // We can only provide information if we've got a snapshot handler
1374 // instance
1375 if(!(isset($this->snapshotHandler) && is_object($this->snapshotHandler))){
1376 return "";
1377 }
1379 // Presets
1380 $result = "";
1381 $ui = get_userinfo();
1383 if($this->snapshotHandler->enabled() && $ui->allow_snapshot_restore($this->base, $this->module)){
1385 // Check if there is something to restore
1386 $restore= false;
1387 foreach($this->snapshotHandler->getSnapshotBases() as $base){
1388 $restore= $restore || count($this->snapshotHandler->getDeletedSnapshots($base)) > 0;
1389 }
1391 // Draw icons according to the restore flag
1392 if($restore){
1393 $result.= "<li$separator><a href='#' onClick='document.getElementById(\"actionmenu\").value= \"restore\";document.getElementById(\"exec_act\").click();'><img src='images/lists/restore.png' alt='' border='0' class='center'> "._("Restore snapshots")."</a></li>";
1394 }else{
1395 $result.= "<li$separator><a href='#'><img src='images/lists/restore_grey.png' alt='' border='0' class='center'> "._("Restore snapshots")."</a></li>";
1396 }
1397 }
1399 return($result);
1400 }
1403 function renderExporterMenu($separator)
1404 {
1405 // Presets
1406 $result = "";
1408 // Draw entries
1409 $result.= "<li$separator><a href='#'><img border='0' class='center' src='images/lists/export.png'> "._("Export list")." <img border='0' src='images/forward-arrow.png'></a><ul class='level3'>";
1411 // Export CVS as build in exporter
1412 foreach ($this->exporter as $action => $exporter) {
1413 $result.= "<li><a href='#' onClick='document.getElementById(\"actionmenu\").value= \"$action\";document.getElementById(\"exec_act\").click();'><img border='0' class='center' src='".$exporter['image']."'> ".$exporter['label']."</a></li>";
1414 }
1416 // Finalize list
1417 $result.= "</ul></li>";
1419 return($result);
1420 }
1423 function renderSnapshotActions($row, $dn, $category, $class, $copy= true, $cut= true)
1424 {
1425 // We can only provide information if we've got a snapshot handler
1426 // instance
1427 if(!(isset($this->snapshotHandler) && is_object($this->snapshotHandler))){
1428 return "";
1429 }
1431 // Presets
1432 $result= "";
1433 $ui = get_userinfo();
1435 // Only act if enabled here
1436 if($this->snapshotHandler->enabled()){
1438 // Draw restore button
1439 if ($ui->allow_snapshot_restore($dn, $category)){
1441 // Do we have snapshots for this dn?
1442 if($this->snapshotHandler->hasSnapshots($dn)){
1443 $result.= "<input class='center' type='image' src='images/lists/restore.png' ".
1444 "alt='"._("Restore snapshot")."' name='listing_restore_$row' title='".
1445 _("Restore snapshot")."' style='padding:1px'>";
1446 } else {
1447 $result.= "<img src='images/lists/restore_grey.png' alt=' ' class='center' style='padding:1px'>";
1448 }
1449 }
1451 // Draw snapshot button
1452 if($ui->allow_snapshot_create($dn, $category)){
1453 $result.= "<input class='center' type='image' src='images/snapshot.png' ".
1454 "alt='"._("Create snapshot")."' name='listing_snapshot_$row' title='".
1455 _("Create a new snapshot from this object")."' style='padding:1px'>";
1456 }else{
1457 $result.= "<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
1458 }
1459 }
1461 return($result);
1462 }
1465 function renderDaemonMenu($separator)
1466 {
1467 $result= "";
1469 // If there is a daemon registered, draw the menu entries
1470 if(class_available("DaemonEvent")){
1471 $events= DaemonEvent::get_event_types_by_category($this->categories);
1472 if(isset($events['BY_CLASS']) && count($events['BY_CLASS'])){
1473 foreach($events['BY_CLASS'] as $name => $event){
1474 $result.= "<li$separator><a href='#' onClick='document.getElementById(\"actionmenu\").value=\"$name\";document.getElementById(\"exec_act\").click();'>".$event['MenuImage']." ".$event['s_Menu_Name']."</a></li>";
1475 $separator= "";
1476 }
1477 }
1478 }
1480 return $result;
1481 }
1484 function getType($dn)
1485 {
1486 if (isset($this->objectDnMapping[$dn])) {
1487 return $this->objectDnMapping[$dn];
1488 }
1489 return null;
1490 }
1492 }
1494 ?>