Code

aaf50515d420a3077e3e3381d76c0ffad2fb7c7f
[gosa.git] / gosa-core / include / class_listing.inc
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= "&nbsp;<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']."&amp;PID=".$this->pid."&amp;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>&nbsp;$sorter</a></td>";
250           } else {
251             $this->header[$index]= "<td class='listheader' ".$this->colprops[$index].">&nbsp;</td>";
252           }
253           $this->plainHeader[]= "";
254         }
255       }
256     }
257   }
259   function render()
260   {
261     // Check for exeeded sizelimit
262     if (($message= check_sizelimit()) != ""){
263       return($message);
264     }
266     // Initialize list
267     $result= "<input type='hidden' value='$this->pid' name='PID'>\n";
268     $height= 450;
269     if ($this->height != 0) {
270       $result.= "<input type='hidden' value='$this->height' id='d_height'>\n";
271       $height= $this->height;
272     }
273     
274     $result.= "<div class='contentboxb' id='listing_container' style='border-top:1px solid #B0B0B0;'>\n";
275     $result.= "<table summary='$this->headline' style='width:600px;height:".$height."px;' cellspacing='0' id='t_scrolltable'>
276 <tr><td class='scrollhead'><table summary='' style='width:100%;' cellspacing='0' id='t_scrollhead'>\n";
277     $this->numColumns= count($this->colprops) + ($this->multiSelect?1:0);
279     // Build list header
280     $result.= "<tr>\n";
281     if ($this->multiSelect) {
282       $result.= "<td class='listheader' style='width:20px;'><input type='checkbox' id='select_all' name='select_all' title='"._("Select all")."' onClick='toggle_all_(\"listing_selected_[0-9]*$\",\"select_all\");' ></td>\n";
283     }
284     foreach ($this->header as $header) {
285       $result.= $header;
286     }
288     // Add 13px for scroller
289     $result.= "<td class='listheader' style='width:13px;border-right:0px;'>&nbsp;</td></table></td></tr>\n";
291     // New table for the real list contents
292     $result.= "<tr><td colspan='$this->numColumns' class='scrollbody'><div style='width:600px;height:".($height-20)."px;' id='d_scrollbody' class='scrollbody'><table summary='' style='height:100%;width:581px;' cellspacing='0' id='t_scrollbody'>\n";
294     // No results? Just take an empty colspanned row
295     if (count($this->entries) + count($this->departments) == 0) {
296       $result.= "<tr class='rowxp0'><td class='list1nohighlight' colspan='$this->numColumns' style='height:100%;border-right:0px;width:100%;'>&nbsp;</td></tr>";
297     }
299     // Line color alternation
300     $alt= 0;
301     $deps= 0;
303     // Draw department browser if configured and we're not in sub mode
304     $this->useSpan= false;
305     if ($this->departmentBrowser && $this->filter->scope != "sub") {
306       // Fill with department browser if configured this way
307       $departmentIterator= new departmentSortIterator($this->departments, $this->sortDirection[$this->sortColumn]);
308       foreach ($departmentIterator as $row => $entry){
309         $result.="<tr class='rowxp".($alt&1)."'>";
311         // Render multi select if needed
312         if ($this->multiSelect) {
313           $result.="<td style='text-align:center;width:20px;' class='list1'>&nbsp;</td>";
314         }
316         // Render defined department columns, fill the rest with some stuff
317         $rest= $this->numColumns - 1;
318         foreach ($this->xmlData['table']['department'] as $index => $config) {
319           $colspan= 1;
320           if (isset($config['span'])){
321             $colspan= $config['span'];
322             $this->useSpan= true;
323           }
324           $result.="<td colspan='$colspan' ".$this->colprops[$index]." class='list1'>".$this->renderCell($config['value'], $entry, $row)."</td>";
325           $rest-= $colspan;
326         }
328         // Fill remaining cols with nothing
329         $last= $this->numColumns - $rest;
330         for ($i= 0; $i<$rest; $i++){
331           $result.= "<td ".$this->colprops[$last+$i-1]." class='list1'>&nbsp;</td>";
332         }
333         $result.="</tr>";
335         $alt++;
336       }
337       $deps= $alt;
338     }
340     // Fill with contents, sort as configured
341     foreach ($this->entries as $row => $entry) {
342       $trow= "";
344       // Render multi select if needed
345       if ($this->multiSelect) {
346         $trow.="<td style='text-align:center;width:20px;' class='list0'><input type='checkbox' id='listing_selected_$row' name='listing_selected_$row'></td>\n";
347       }
349       foreach ($this->xmlData['table']['column'] as $index => $config) {
350         $renderedCell= $this->renderCell($config['value'], $entry, $row);
351         $trow.="<td ".$this->colprops[$index]." class='list0'>".$renderedCell."</td>\n";
353         // Save rendered column
354         $sort= preg_replace('/.*>([^<]+)<.*$/', '$1', $renderedCell);
355         $sort= preg_replace('/&nbsp;/', '', $sort);
356         if (preg_match('/</', $sort)){
357           $sort= "";
358         }
359         $this->entries[$row]["_sort$index"]= $sort;
360       }
362       // Save rendered entry
363       $this->entries[$row]['_rendered']= $trow;
364     }
366     // Complete list by sorting entries for _sort$index and appending them to the output
367     $entryIterator= new listingSortIterator($this->entries, $this->sortDirection[$this->sortColumn], "_sort".$this->sortColumn, $this->sortType);
368     foreach ($entryIterator as $row => $entry){
369       $alt++;
370       $result.="<tr class='rowxp".($alt&1)."'>\n";
371       $result.= $entry['_rendered'];
372       $result.="</tr>\n";
373     }
375     // Need to fill the list if it's not full (nobody knows why this is 22 ;-))
376     $emptyListStyle= (count($this->entries) + (($this->useSpan && count($this->entries))?$deps:0) == 0)?"border:0;":"";
377     if ((count($this->entries) + $deps) < 22) {
378       $result.= "<tr>";
379       for ($i= 0; $i<$this->numColumns; $i++) {
380         if ($i == 0) {
381           $result.= "<td class='list1nohighlight' style='$emptyListStyle height:100%;'>&nbsp;</td>";
382           continue;
383         }
384         if ($i != $this->numColumns-1) {
385           $result.= "<td class='list1nohighlight' style='$emptyListStyle'>&nbsp;</td>";
386         } else {
387           $result.= "<td class='list1nohighlight' style='border-right:1px solid #AAA;$emptyListStyle'>&nbsp;</td>";
388         }
389       }
390       $result.= "</tr>";
391     }
393     $result.= "</table></div></td></tr>";
395     // Add the footer if requested
396     if ($this->showFooter) {
397       $result.= "<tr><td class='scrollhead'><table summary='' style='width:100%' cellspacing='0' id='t_scrollfoot'><tr><td class='listfooter' style='border-bottom:0px;'>";
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'>&nbsp;".$this->objectTypeCount[$objectType['label']]."&nbsp;&nbsp;&nbsp;&nbsp;";
403         }
404       }
406       $result.= "<td class='listfooter' style='width:13px;border-right:0px;'>&nbsp;</td></table></td></tr>";
407     }
409     $result.= "</table></div>";
411     $smarty= get_smarty();
412     $smarty->assign("usePrototype", "true");
413     $smarty->assign("FILTER", $this->filter->render());
414     $smarty->assign("SIZELIMIT", print_sizelimit_warning());
415     $smarty->assign("LIST", $result);
417     // Assign navigation elements
418     $nav= $this->renderNavigation();
419     foreach ($nav as $key => $html) {
420       $smarty->assign($key, $html);
421     }
423     // Assign action menu / base
424     $smarty->assign("ACTIONS", $this->renderActionMenu());
425     $smarty->assign("BASE", $this->renderBase());
427     // Assign separator
428     $smarty->assign("SEPARATOR", "<img src='images/lists/seperator.png' alt='-' align='middle' height='16' width='1' class='center'>");
430     // Assign summary
431     $smarty->assign("HEADLINE", $this->headline);
433     return ($smarty->fetch(get_template_path($this->xmlData['definition']['template'], true)));
434   }
437   function update()
438   {
439     global $config;
440     $ui= get_userinfo();
442     // Reset object counter / DN mapping
443     $this->objectTypeCount= array();
444     $this->objectDnMapping= array();
446     // Do not do anything if this is not our PID
447     if(isset($_REQUEST['PID']) && $_REQUEST['PID'] != $this->pid) {
448       return;
449     }
451     // Save base
452     if (isset($_POST['BASE']) && $this->baseMode) {
453       $base= validate($_POST['BASE']);
454       if (isset($this->bases[$base])) {
455         $this->base= $base;
456         session::global_set("CurrentMainBase", $this->base);
457       }
458     }
460     // Override the base if we got a message from the browser navigation
461     if ($this->departmentBrowser && isset($_GET['act'])) {
462       if (preg_match('/^department_([0-9]+)$/', validate($_GET['act']), $match)){
463         if (isset($this->departments[$match[1]])){
464           $this->base= $this->departments[$match[1]]['dn'];
465         }
466       }
467     }
469     // Filter POST with "act" attributes -> posted from action menu
470     if (isset($_POST['exec_act']) && $_POST['act'] != '') {
471       if (preg_match('/^export.*$/', $_POST['act']) && isset($this->exporter[$_POST['act']])) {
472         $exporter= $this->exporter[$_POST['act']];
473         $userinfo= ", "._("created by")." ".$ui->cn." - ".strftime('%A, %d. %B %Y, %H:%M:%S');
474         $entryIterator= new listingSortIterator($this->entries, $this->sortDirection[$this->sortColumn], "_sort".$this->sortColumn, $this->sortType);
475         $sortedEntries= array();
476         foreach ($entryIterator as $entry){
477           $sortedEntries[]= $entry;
478         }
479         $instance= new $exporter['class']($this->headline.$userinfo, $this->plainHeader, $sortedEntries, $this->exportColumns);
480         $type= call_user_func(array($exporter['class'], "getInfo"));
481         $type= $type[$_POST['act']];
482         send_binary_content($instance->query(), $type['filename'], $type= $type['mime']);
483       }
484     }
486     // Filter GET with "act" attributes
487     if (isset($_GET['act'])) {
488       $key= validate($_GET['act']);
489       if (preg_match('/^SORT_([0-9]+)$/', $key, $match)) {
490         // Switch to new column or invert search order?
491         $column= $match[1];
492         if ($this->sortColumn != $column) {
493           $this->sortColumn= $column;
494         } else {
495           $this->sortDirection[$column]= !$this->sortDirection[$column];
496         }
498         // Allow header to update itself according to the new sort settings
499         $this->renderHeader();
500       }
501     }
503     // Override base if we got signals from the navigation elements
504     $action= "";
505     foreach ($_POST as $key => $value) {
506       if (preg_match('/^(ROOT|BACK|HOME)_x$/', $key, $match)) {
507         $action= $match[1];
508         break;
509       }
510     }
512     // Navigation handling
513     if ($action == 'ROOT') {
514       $deps= $ui->get_module_departments($this->module);
515       $this->base= $deps[0];
516     }
517     if ($action == 'BACK') {
518       $deps= $ui->get_module_departments($this->module);
519       $base= preg_replace("/^[^,]+,/", "", $this->base);
520       if(in_array_ics($base, $deps)){
521         $this->base= $base;
522       }
523     }
524     if ($action == 'HOME') {
525       $ui= get_userinfo();
526       $this->base= $this->filter->getObjectBase($ui->dn);
527     }
529     // Reload departments
530     if ($this->departmentBrowser){
531       $this->departments= $this->getDepartments();
532     }
534     // Update filter and refresh entries
535     $this->filter->setBase($this->base);
536     $this->entries= $this->filter->query();
537   }
540   function setBase($base)
541   {
542     $this->base= $base;
543   }
546   function getBase()
547   {
548     return $this->base;
549   }
552   function parseLayout($layout)
553   {
554     $result= array();
555     $layout= preg_replace("/^\|/", "", $layout);
556     $layout= preg_replace("/\|$/", "", $layout);
557     $cols= split("\|", $layout);
559     foreach ($cols as $index => $config) {
560       if ($config != "") {
561         $res= "";
562         $components= split(';', $config);
563         foreach ($components as $part) {
564           if (preg_match("/^r$/", $part)) {
565             $res.= "text-align:right;";
566             continue;
567           }
568           if (preg_match("/^l$/", $part)) {
569             $res.= "text-align:left;";
570             continue;
571           }
572           if (preg_match("/^c$/", $part)) {
573             $res.= "text-align:center;";
574             continue;
575           }
576           if (preg_match("/^[0-9]+(|px|%)$/", $part)) {
577             $res.= "width:$part;min-width:$part;";
578             continue;
579           }
580         }
582         // Add minimum width for scalable columns
583         if (!preg_match('/width:/', $res)){
584           $res.= "min-width:200px;";
585         }
587         $result[$index]= " style='$res' ";
588       } else {
589         $result[$index]= " style='min-width:100px'";
590       }
591     }
593     // Save number of columns for later use
594     $this->numColumns= count($cols);
596     return $result;
597   }
600   function renderCell($data, $config, $row)
601   {
602     // Replace flat attributes in data string
603     for ($i= 0; $i<$config['count']; $i++) {
604       $attr= $config[$i];
605       $value= "";
606       if (is_array($config[$attr])) {
607         $value= $config[$attr][0];
608       } else {
609         $value= $config[$attr];
610       }
611       $data= preg_replace("/%\{$attr\}/", $value, $data);
612     }
614     // Watch out for filters and prepare to execute them
615     $data= $this->processElementFilter($data, $config, $row);
617     // Replace all non replaced %{...} instances because they
618     // are non resolved attributes or filters
619     $data= preg_replace('/%{[^}]+}/', '&nbsp;', $data);
621     return $data;
622   }
625   function renderBase()
626   {
627     if (!$this->baseMode) {
628       return;
629     }
631     $result= "<select name='BASE' onChange='mainform.submit()' size='1'>";
632     $firstDN= null;
633     $found= false;
635     foreach ($this->bases as $key=>$value) {
636       // Keep first entry to fall back eventually
637       if(!$firstDN) {
638         $firstDN= $key;
639       }
641       // Prepare to render entry
642       $selected= "";
643       if ($key == $this->base) {
644         $selected= " selected";
645         $found= true;
646       }
647       $result.= "<option value='".$key."'$selected>".$value."</option>";
648     }
649     $result.= "</select>";
651     // Reset the currently used base to the first DN we found if there
652     // was no match.
653     if(!$found){
654       $this->base = $firstDN;
655     }
657     return $result;
658   }
661   function processElementFilter($data, $config, $row)
662   {
663     preg_match_all("/%\{filter:([^(]+)\((.*)\)\}/", $data, $matches, PREG_SET_ORDER);
665     foreach ($matches as $match) {
666       if (!isset($this->filters[$match[1]])) {
667         continue;
668       }
669       $cl= preg_replace('/::.*$/', '', $this->filters[$match[1]]);
670       $method= preg_replace('/^.*::/', '', $this->filters[$match[1]]);
672       // Prepare params for function call
673       $params= array();
674       preg_match_all('/"[^"]+"|[^,]+/', $match[2], $parts);
675       foreach ($parts[0] as $param) {
677         // Row is replaced by the row number
678         if ($param == "row") {
679           $params[]= $row;
680         }
682         // pid is replaced by the current PID
683         if ($param == "pid") {
684           $params[]= $this->pid;
685         }
687         // base is replaced by the current base
688         if ($param == "base") {
689           $params[]= $this->getBase();
690         }
692         // Fixie with "" is passed directly
693         if (preg_match('/^".*"$/', $param)){
694           $params[]= preg_replace('/"/', '', $param);
695         }
697         // LDAP variables get replaced by their objects
698         for ($i= 0; $i<$config['count']; $i++) {
699           if ($param == $config[$i]) {
700             $values= $config[$config[$i]];
701             if (is_array($values)){
702               unset($values['count']);
703             }
704             $params[]= $values;
705           }
706         }
708         // Move dn if needed
709         if ($param == "dn") {
710           $params[]= LDAP::fix($config["dn"]);
711         }
712       }
714       // Replace information
715       if ($cl == "listing") {
716         // Non static call - seems to result in errors
717         $data= @preg_replace('/'.preg_quote($match[0]).'/', call_user_func_array(array($this, "$method"), $params), $data);
718       } else {
719         // Static call
720         $data= preg_replace('/'.preg_quote($match[0]).'/', call_user_func_array(array($cl, $method), $params), $data);
721       }
722     }
724     return $data;
725   }
728   function getObjectType($types, $classes)
729   {
730     // Walk thru types and see if there's something matching
731     foreach ($types as $objectType) {
732       $ocs= $objectType['objectClass'];
733       if (!is_array($ocs)){
734         $ocs= array($ocs);
735       }
737       $found= true;
738       foreach ($ocs as $oc){
739         if (preg_match('/^!(.*)$/', $oc, $match)) {
740           $oc= $match[1];
741           if (in_array($oc, $classes)) {
742             $found= false;
743           }
744         } else {
745           if (!in_array($oc, $classes)) {
746             $found= false;
747           }
748         }
749       }
751       if ($found) {
752         return $objectType;
753       }
754     }
756     return null;
757   }
760   function filterObjectType($dn, $classes)
761   {
762     // Walk thru classes and return on first match
763     $result= "&nbsp;";
765     $objectType= $this->getObjectType($this->objectTypes, $classes);
766     if ($objectType) {
767       $this->objectDnMapping[$dn]= $objectType["objectClass"];
768       $result= "<img class='center' title='".LDAP::fix($dn)."' src='".$objectType["image"]."'>";
769       if (!isset($this->objectTypeCount[$objectType['label']])) {
770         $this->objectTypeCount[$objectType['label']]= 0;
771       }
772       $this->objectTypeCount[$objectType['label']]++;
773     }
775     return $result;
776   }
779   function filterActions($dn, $row, $classes)
780   {
781     // Do nothing if there's no menu defined
782     if (!isset($this->xmlData['actiontriggers']['action'])) {
783       return "&nbsp;";
784     }
786     // Go thru all actions
787     $result= "";
788     $actions= $this->xmlData['actiontriggers']['action'];
789     foreach($actions as $action) {
790       // Skip the entry completely if there's no permission to execute it
791       if (!$this->hasActionPermission($action, $dn)) {
792         $result.= "<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
793         continue;
794       }
796       // Skip entry if the pseudo filter does not fit
797       if (isset($action['filter']) && preg_match('/^[a-z0-9_]+!?=[a-z0-9_]+$/i', $action['filter'])) {
798         list($fa, $fv)= split('=', $action['filter']);
799         if (preg_match('/^(.*)!$/', $fa, $m)){
800           $fa= $m[1];
801           if (isset($this->entries[$row][$fa]) && $this->entries[$row][$fa][0] == $fv) {
802             $result.= "<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
803             continue;
804           }
805         } else {
806           if (!isset($this->entries[$row][$fa]) && !$this->entries[$row][$fa][0] == $fv) {
807             $result.= "<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
808             continue;
809           }
810         }
811       }
814       // If there's an objectclass definition and we don't have it
815       // add an empty picture here.
816       if (isset($action['objectclass'])){
817         $objectclass= $action['objectclass'];
818         if (preg_match('/^!(.*)$/', $objectclass, $m)){
819           $objectclass= $m[1];
820           if(in_array($objectclass, $classes)) {
821             $result.= "<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
822             continue;
823           }
824         } else {
825           if(!in_array($objectclass, $classes)) {
826             $result.= "<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
827             continue;
828           }
829         }
830       }
832       // Render normal entries as usual
833       if ($action['type'] == "entry") {
834         $label= $this->processElementFilter($action['label'], $this->entries[$row], $row);
835         $image= $this->processElementFilter($action['image'], $this->entries[$row], $row);
836         $result.="<input class='center' type='image' src='$image' title='$label' ".
837                  "name='listing_".$action['name']."_$row' style='padding:1px'>";
838       }
840       // Handle special types
841       if ($action['type'] == "copypaste" || $action['type'] == "snapshot") {
843         $objectType= $this->getObjectType($this->objectTypes, $this->entries[$row]['objectClass']);
844         $category= $class= null;
845         if ($objectType) {
846           $category= $objectType['category'];
847           $class= $objectType['class'];
848         }
850         if ($action['type'] == "copypaste") {
851           $result.= $this->renderCopyPasteActions($row, $this->entries[$row]['dn'], $category, $class);
852         } else {
853           $result.= $this->renderSnapshotActions($row, $this->entries[$row]['dn'], $category, $class);
854         }
855       }
856     }
858     return $result;
859   }
862   function filterDepartmentLink($row, $dn, $description)
863   {
864     $attr= $this->departments[$row]['sort-attribute'];
865     $name= $this->departments[$row][$attr];
866     if (is_array($name)){
867       $name= $name[0];
868     }
869     $result= sprintf("%s [%s]", $name, $description[0]);
870     return("<a href='?plug=".$_GET['plug']."&amp;PID=$this->pid&amp;act=department_$row' title='$dn'>$result</a>");
871   }
874   function filterLink()
875   {
876     $result= "&nbsp;";
878     $row= func_get_arg(0);
879     $pid= $this->pid;
880     $dn= LDAP::fix(func_get_arg(1));
881     $params= array(func_get_arg(2));
883     // Collect sprintf params
884     for ($i = 3;$i < func_num_args();$i++) {
885       $val= func_get_arg($i);
886       if (is_array($val)){
887         $params[]= $val[0];
888         continue;
889       }
890       $params[]= $val;
891     }
893     $result= "&nbsp;";
894     $trans= call_user_func_array("sprintf", $params);
895     if ($trans != "") {
896       return("<a href='?plug=".$_GET['plug']."&amp;PID=$pid&amp;act=listing_edit_$row' title='$dn'>$trans</a>");
897     }
899     return $result;
900   }
903   function renderNavigation()
904   {
905     $result= array();
906     $enableBack = true;
907     $enableRoot = true;
908     $enableHome = true;
910     $ui = get_userinfo();
912     /* Check if base = first available base */
913     $deps = $ui->get_module_departments($this->module);
915     if(!count($deps) || $deps[0] == $this->filter->base){
916       $enableBack = false;
917       $enableRoot = false;
918     }
920     $listhead ="";
922     /* Check if we are in users home  department */
923     if(!count($deps) || $this->filter->base == $this->filter->getObjectBase($ui->dn)){
924       $enableHome = false;
925     }
927     /* Draw root button */
928     if($enableRoot){
929       $result["ROOT"]= "<input class='center' type='image' src='images/lists/root.png' align='middle' ".
930                        "title='"._("Go to root department")."' name='ROOT' alt='"._("Root")."'>";
931     }else{
932       $result["ROOT"]= "<img src='images/lists/root_grey.png' class='center' alt='"._("Root")."'>";
933     }
935     /* Draw back button */
936     if($enableBack){
937       $result["BACK"]= "<input class='center' type='image' align='middle' src='images/lists/back.png' ".
938                        "title='"._("Go up one department")."' alt='"._("Up")."' name='BACK'>";
939     }else{
940       $result["BACK"]= "<img src='images/lists/back_grey.png' class='center' alt='"._("Up")."'>";
941     }
943     /* Draw home button */
944     if($enableHome){
945       $result["HOME"]= "<input class='center' type='image' align='middle' src='images/lists/home.png' ".
946                        "title='"._("Go to users department")."' alt='"._("Home")."' name='HOME'>";
947     }else{
948       $result["HOME"]= "<img src='images/lists/home_grey.png' class='center' alt='"._("Home")."'>";
949     }
951     /* Draw reload button, this button is enabled everytime */
952     $result["RELOAD"]= "<input class='center' type='image' src='images/lists/reload.png' align='middle' ".
953                        "title='"._("Reload list")."' name='REFRESH' alt='"._("Submit")."'>";
955     return ($result);
956   }
959   function getAction()
960   {
961     // Do not do anything if this is not our PID, or there's even no PID available...
962     if(!isset($_REQUEST['PID']) || $_REQUEST['PID'] != $this->pid) {
963       return;
964     }
966     $result= array("targets" => array(), "action" => "");
968     // Filter GET with "act" attributes
969     if (isset($_GET['act'])) {
970       $key= validate($_GET['act']);
971       $target= preg_replace('/^listing_[a-zA-Z_]+_([0-9]+)$/', '$1', $key);
972       if (isset($this->entries[$target]['dn'])) {
973         $result['action']= preg_replace('/^listing_([a-zA-Z_]+)_[0-9]+$/', '$1', $key);
974         $result['targets'][]= $this->entries[$target]['dn'];
975       }
977       // Drop targets if empty
978       if (count($result['targets']) == 0) {
979         unset($result['targets']);
980       }
981       return $result;
982     }
984     // Filter POST with "listing_" attributes
985     foreach ($_POST as $key => $prop) {
987       // Capture selections
988       if (preg_match('/^listing_selected_[0-9]+$/', $key)) {
989         $target= preg_replace('/^listing_selected_([0-9]+)$/', '$1', $key);
990         if (isset($this->entries[$target]['dn'])) {
991           $result['targets'][]= $this->entries[$target]['dn'];
992         }
993         continue;
994       }
996       // Capture action with target - this is a one shot
997       if (preg_match('/^listing_[a-zA-Z_]+_[0-9]+(|_x)$/', $key)) {
998         $target= preg_replace('/^listing_[a-zA-Z_]+_([0-9]+)(|_x)$/', '$1', $key);
999         if (isset($this->entries[$target]['dn'])) {
1000           $result['action']= preg_replace('/^listing_([a-zA-Z_]+)_[0-9]+(|_x)$/', '$1', $key);
1001           $result['targets']= array($this->entries[$target]['dn']);
1002         }
1003         break;
1004       }
1006       // Capture action without target
1007       if (preg_match('/^listing_[a-zA-Z_]+(|_x)$/', $key)) {
1008         $result['action']= preg_replace('/^listing_([a-zA-Z_]+)(|_x)$/', '$1', $key);
1009         continue;
1010       }
1011     }
1013     // Filter POST with "act" attributes -> posted from action menu
1014     if (isset($_POST['act']) && $_POST['act'] != '') {
1015       if (!preg_match('/^export.*$/', $_POST['act'])){
1016         $result['action']= validate($_POST['act']);
1017       }
1018     }
1020     // Drop targets if empty
1021     if (count($result['targets']) == 0) {
1022       unset($result['targets']);
1023     }
1024     return $result;
1025   }
1028   function renderActionMenu()
1029   {
1030     // Don't send anything if the menu is not defined
1031     if (!isset($this->xmlData['actionmenu']['action'])){
1032       return "";
1033     }
1035     // Array?
1036     if (isset($this->xmlData['actionmenu']['action']['type'])){
1037       $this->xmlData['actionmenu']['action']= array($this->xmlData['actionmenu']['action']);
1038     }
1040     // Load shortcut
1041     $actions= &$this->xmlData['actionmenu']['action'];
1042     $result= "<input type='hidden' name='act' id='actionmenu' value=''><div style='display:none'><input type='submit' name='exec_act' id='exec_act' value=''></div>".
1043              "<ul class='level1' id='root'><li><a href='#'>"._("Actions")."&nbsp;<img ".
1044              "border=0 class='center' src='images/lists/sort-down.png'></a>";
1046     // Build ul/li list
1047     $result.= $this->recurseActions($actions);
1049     return "<div id='pulldown'>".$result."</li></ul><div>";
1050   }
1053   function recurseActions($actions)
1054   {
1055     global $class_mapping;
1056     static $level= 2;
1057     $result= "<ul class='level$level'>";
1058     $separator= "";
1060     foreach ($actions as $action) {
1062       // Skip the entry completely if there's no permission to execute it
1063       if (!$this->hasActionPermission($action, $this->filter->base)) {
1064         continue;
1065       }
1067       // Skip entry if there're missing dependencies
1068       if (isset($action['depends'])) {
1069         $deps= is_array($action['depends'])?$action['depends']:array($action['depends']);
1070         foreach($deps as $clazz) {
1071           if (!isset($class_mapping[$clazz])){
1072             continue 2;
1073           }
1074         }
1075       }
1077       // Fill image if set
1078       $img= "";
1079       if (isset($action['image'])){
1080         $img= "<img border='0' class='center' src='".$action['image']."'>&nbsp;";
1081       }
1083       if ($action['type'] == "separator"){
1084         $separator= " style='border-top:1px solid #AAA' ";
1085         continue;
1086       }
1088       // Dive into subs
1089       if ($action['type'] == "sub" && isset($action['action'])) {
1090         $level++;
1091         if (isset($action['label'])){
1092           $result.= "<li$separator><a href='#'>$img"._($action['label'])."&nbsp;<img border='0' src='images/forward-arrow.png'></a>";
1093         }
1094         $result.= $this->recurseActions($action['action'])."</li>";
1095         $level--;
1096         $separator= "";
1097         continue;
1098       }
1100       // Render entry elseways
1101       if (isset($action['label'])){
1102         $result.= "<li$separator><a href='#' onClick='document.getElementById(\"actionmenu\").value= \"".$action['name']."\";mainform.submit();'>$img"._($action['label'])."</a></li>";
1103       }
1105       // Check for special types
1106       switch ($action['type']) {
1107         case 'copypaste':
1108           $result.= $this->renderCopyPasteMenu($separator);
1109           break;
1111         case 'snapshot':
1112           $result.= $this->renderSnapshotMenu($separator);
1113           break;
1115         case 'exporter':
1116           $result.= $this->renderExporterMenu($separator);
1117           break;
1119         case 'daemon':
1120           $result.= $this->renderDaemonMenu($separator);
1121           break;
1122       }
1124       $separator= "";
1125     }
1127     $result.= "</ul>";
1128     return $result;
1129   }
1132   function hasActionPermission($action, $dn)
1133   {
1134     $ui= get_userinfo();
1136     if (isset($action['acl'])) {
1137       $acls= $action['acl'];
1138       if (!is_array($acls)) {
1139         $acls= array($acls);
1140       }
1142       // Every ACL has to pass
1143       foreach ($acls as $acl) {
1144         $module= $this->module;
1145         $aclList= array();
1147         // Split for category and plugins if needed
1148         // match for "[rw]" style entries
1149         if (preg_match('/^\[([rwcdm]+)\]$/', $acl, $match)){
1150           $aclList= array($match[1]);
1151         }
1153         // match for "users[rw]" style entries
1154         if (preg_match('/^([a-zA-Z0-9]+)\[([rwcdm]+)\]$/', $acl, $match)){
1155           $module= $match[1];
1156           $aclList= array($match[2]);
1157         }
1159         // match for "users/user[rw]" style entries
1160         if (preg_match('/^([a-zA-Z0-9]+\/[a-zA-Z0-9]+)\[([rwcdm]+)\]$/', $acl, $match)){
1161           $module= $match[1];
1162           $aclList= array($match[2]);
1163         }
1165         // match "users/user[userPassword:rw(,...)*]" style entries
1166         if (preg_match('/^([a-zA-Z0-9]+\/[a-zA-Z0-9]+)\[([a-zA-Z0-9]+:[rwcdm]+(,[a-zA-Z0-9]+:[rwcdm]+)*)\]$/', $acl, $match)){
1167           $module= $match[1];
1168           $aclList= split(',', $match[2]);
1169         }
1171         // Walk thru prepared ACL by using $module
1172         foreach($aclList as $sAcl) {
1173           $checkAcl= "";
1175           // Category or detailed permission?
1176           if (strpos('/', $module) === false) {
1177             if (preg_match('/([a-zA-Z0-9]+):([rwcdm]+)/', $sAcl, $m) ) {
1178               $checkAcl= $ui->get_permissions($dn, $module, $m[1]);
1179               $sAcl= $m[2];
1180             } else {
1181               $checkAcl= $ui->get_permissions($dn, $module, '0');
1182             }
1183           } else {
1184             $checkAcl= $ui->get_category_permissions($dn, $module);
1185           }
1187           // Split up remaining part of the acl and check if it we're
1188           // allowed to do something...
1189           $parts= str_split($sAcl);
1190           foreach ($parts as $part) {
1191             if (strpos($checkAcl, $part) === false){
1192               return false;
1193             }
1194           }
1196         }
1197       }
1198     }
1200     return true;
1201   }
1204   function refreshBasesList()
1205   {
1206     global $config;
1207     $ui= get_userinfo();
1209     // Do some array munching to get it user friendly
1210     $ids= $config->idepartments;
1211     $d= $ui->get_module_departments($this->module);
1212     $k_ids= array_keys($ids);
1213     $deps= array_intersect($d,$k_ids);
1215     // Fill internal bases list
1216     $this->bases= array();
1217     foreach($k_ids as $department){
1218       $this->bases[$department] = $ids[$department];
1219     }
1220   }
1223   function getDepartments()
1224   {
1225     $departments= array();
1226     $ui= get_userinfo();
1228     // Get list of supported department types
1229     $types = departmentManagement::get_support_departments();
1231     // Load departments allowed by ACL
1232     $validDepartments = $ui->get_module_departments($this->module);
1234     // Build filter and look in the LDAP for possible sub departments
1235     // of current base
1236     $filter= "(&(objectClass=gosaDepartment)(|";
1237     $attrs= array("description", "objectClass");
1238     foreach($types as $name => $data){
1239       $filter.= "(objectClass=".$data['OC'].")";
1240       $attrs[]= $data['ATTR'];
1241     }
1242     $filter.= "))";
1243     $res= get_list($filter, $this->module, $this->base, $attrs, GL_NONE);
1245     // Analyze list of departments
1246     foreach ($res as $department) {
1247       if (!in_array($department['dn'], $validDepartments)) {
1248         continue;
1249       }
1251       // Add the attribute where we use for sorting
1252       $oc= null;
1253       foreach(array_keys($types) as $type) {
1254         if (in_array($type, $department['objectClass'])) {
1255           $oc= $type;
1256           break;
1257         }
1258       }
1259       $department['sort-attribute']= $types[$oc]['ATTR'];
1261       // Move to the result list
1262       $departments[]= $department;
1263     }
1265     return $departments;
1266   }
1269   function renderCopyPasteMenu($separator, $copy= true, $cut= true)
1270   {
1271     // We can only provide information if we've got a copypaste handler
1272     // instance
1273     if(!(isset($this->copyPasteHandler) && is_object($this->copyPasteHandler))){
1274       return "";
1275     }
1277     // Presets
1278     $result= "";
1279     $read= $paste= false;
1280     $ui= get_userinfo();
1282     // Switch flags to on if there's at least one category which allows read/paste
1283     foreach($this->categories as $category){
1284       $read= $read || preg_match('/r/', $ui->get_category_permissions($this->base, $category));
1285       $paste= $paste || $ui->is_pasteable($this->base, $category) == 1;
1286     }
1289     // Draw entries that allow copy and cut
1290     if($read){
1292       // Copy entry
1293       if($copy){
1294         $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'>&nbsp;"._("Copy")."</a></li>";
1295         $separator= "";
1296       }
1298       // Cut entry
1299       if($cut){
1300         $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'>&nbsp;"._("Cut")."</a></li>";
1301         $separator= "";
1302       }
1303     }
1305     // Draw entries that allow pasting entries
1306     if($paste){
1307       if($this->copyPasteHandler->entries_queued()){
1308         $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'>&nbsp;"._("Paste")."</a></li>";
1309       }else{
1310         $result.= "<li$separator><a href='#'><img src='images/lists/paste-grey.png' alt='' border='0' class='center'>&nbsp;"._("Paste")."</a></li>";
1311       }
1312     }
1313     
1314     return($result);
1315   }
1318   function renderCopyPasteActions($row, $dn, $category, $class, $copy= true, $cut= true)
1319   {
1320     // We can only provide information if we've got a copypaste handler
1321     // instance
1322     if(!(isset($this->copyPasteHandler) && is_object($this->copyPasteHandler))){
1323       return "";
1324     }
1326     // Presets
1327     $ui = get_userinfo();
1328     $result = "";
1330     // Render cut entries
1331     if($cut){
1332       if($ui->is_cutable($dn, $category, $class)){
1333         $result .= "<input class='center' type='image'
1334           src='images/lists/cut.png' alt='"._("Cut")."' name='listing_cut_$row' title='"._("Cut this entry")."' style='padding:1px'>";
1335       }else{
1336         $result.="<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
1337       }
1338     }
1340     // Render copy entries
1341     if($copy){
1342       if($ui->is_copyable($dn, $category, $class)){
1343         $result.= "<input class='center' type='image'
1344           src='images/lists/copy.png' alt='"._("Copy")."' name='listing_copy_$row' title='"._("Copy this entry")."' style='padding:1px'>";
1345       }else{
1346         $result.="<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
1347       }
1348     }
1350     return($result);
1351   }
1354   function renderSnapshotMenu($separator)
1355   {
1356     // We can only provide information if we've got a snapshot handler
1357     // instance
1358     if(!(isset($this->snapshotHandler) && is_object($this->snapshotHandler))){
1359       return "";
1360     }
1362     // Presets
1363     $result = "";
1364     $ui = get_userinfo();
1366     if($this->snapshotHandler->enabled() && $ui->allow_snapshot_restore($this->base, $this->module)){
1368       // Check if there is something to restore
1369       $restore= false;
1370       foreach($this->snapshotHandler->getSnapshotBases() as $base){
1371         $restore= $restore || count($this->snapshotHandler->getDeletedSnapshots($base)) > 0;
1372       }
1374       // Draw icons according to the restore flag
1375       if($restore){
1376         $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'>&nbsp;"._("Restore snapshots")."</a></li>";
1377       }else{
1378         $result.= "<li$separator><a href='#'><img src='images/lists/restore_grey.png' alt='' border='0' class='center'>&nbsp;"._("Restore snapshots")."</a></li>";
1379       }
1380     }
1382     return($result);
1383   }
1386   function renderExporterMenu($separator)
1387   {
1388     // Presets
1389     $result = "";
1391     // Draw entries
1392     $result.= "<li$separator><a href='#'><img border='0' class='center' src='images/lists/export.png'>&nbsp;"._("Export list")."&nbsp;<img border='0' src='images/forward-arrow.png'></a><ul class='level3'>";
1394     // Export CVS as build in exporter
1395     foreach ($this->exporter as $action => $exporter) {
1396       $result.= "<li><a href='#' onClick='document.getElementById(\"actionmenu\").value= \"$action\";document.getElementById(\"exec_act\").click();'><img border='0' class='center' src='".$exporter['image']."'>&nbsp;".$exporter['label']."</a></li>";
1397     }
1399     // Finalize list
1400     $result.= "</ul></li>";
1402     return($result);
1403   }
1406   function renderSnapshotActions($row, $dn, $category, $class, $copy= true, $cut= true)
1407   {
1408     // We can only provide information if we've got a snapshot handler
1409     // instance
1410     if(!(isset($this->snapshotHandler) && is_object($this->snapshotHandler))){
1411       return "";
1412     }
1414     // Presets
1415     $result= "";
1416     $ui = get_userinfo();
1418     // Only act if enabled here
1419     if($this->snapshotHandler->enabled()){
1421       // Draw restore button
1422       if ($ui->allow_snapshot_restore($dn, $category)){
1424         // Do we have snapshots for this dn?
1425         if($this->snapshotHandler->hasSnapshots($dn)){
1426           $result.= "<input class='center' type='image' src='images/lists/restore.png' ".
1427                      "alt='"._("Restore snapshot")."' name='listing_restore_$row' title='".
1428                      _("Restore snapshot")."' style='padding:1px'>";
1429         } else {
1430           $result.= "<img src='images/lists/restore_grey.png' alt=' ' class='center' style='padding:1px'>";
1431         }
1432       }
1434       // Draw snapshot button
1435       if($ui->allow_snapshot_create($dn, $category)){
1436           $result.= "<input class='center' type='image' src='images/snapshot.png' ".
1437                      "alt='"._("Create snapshot")."' name='listing_snapshot_$row' title='".
1438                      _("Create a new snapshot from this object")."' style='padding:1px'>";
1439       }else{
1440           $result.= "<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
1441       }
1442     }
1444     return($result);
1445   }
1448   function renderDaemonMenu($separator)
1449   {
1450     $result= "";
1452     // If there is a daemon registered, draw the menu entries
1453     if(class_available("DaemonEvent")){
1454       $events= DaemonEvent::get_event_types_by_category($this->categories);
1455       if(isset($events['BY_CLASS']) && count($events['BY_CLASS'])){
1456         foreach($events['BY_CLASS'] as $name => $event){
1457           $result.= "<li$separator><a href='#' onClick='document.getElementById(\"actionmenu\").value=\"$name\";document.getElementById(\"exec_act\").click();'>".$event['MenuImage']."&nbsp;".$event['s_Menu_Name']."</a></li>";
1458           $separator= "";
1459         }
1460       }
1461     }
1463     return $result;
1464   }
1467   function getType($dn)
1468   {
1469     if (isset($this->objectDnMapping[$dn])) {
1470       return $this->objectDnMapping[$dn];
1471     }
1472     return null;
1473   }
1477 ?>