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 // Some browsers don't have the ability do do scrollable table bodies, filter them
268 // here.
269 $switch= false;
270 if (preg_match('/(Opera|Konqueror|Safari)/i', $_SERVER['HTTP_USER_AGENT'])){
271 $switch= true;
272 }
274 // Initialize list
275 $result= "<input type='hidden' value='$this->pid' name='PID'>\n";
276 $height= 450;
277 if ($this->height != 0) {
278 $result.= "<input type='hidden' value='$this->height' id='d_height'>\n";
279 $height= $this->height;
280 }
282 $result.= "<table cellpadding='0' cellspacing='0' border='0'><tr><td><div class='listContainer' id='d_scrollbody' style='border-top:1px solid #B0B0B0;width:700px;min-height:".($height+25)."px;'>\n";
284 $height= "";
285 if ($switch){
286 $height= "height:100%;";
287 }
288 $result.= "<table summary='$this->headline' style='${height}width:100%; table-layout:fixed;' cellspacing='0' cellpadding='0' id='t_scrolltable'>\n";
289 $this->numColumns= count($this->colprops) + ($this->multiSelect?1:0);
291 // Build list header
292 $result.= "<thead class='fixedListHeader listHeaderFormat'><tr>\n";
293 if ($this->multiSelect) {
294 $width= "24px";
295 if (preg_match('/Konqueror/i', $_SERVER['HTTP_USER_AGENT'])){
296 $width= "28px";
297 }
298 $result.= "<td class='listheader' style='text-align:center;padding:0;width:$width;'><input type='checkbox' id='select_all' name='select_all' title='"._("Select all")."' onClick='toggle_all_(\"listing_selected_[0-9]*$\",\"select_all\");' ></td>\n";
299 }
300 foreach ($this->header as $header) {
301 $result.= $header;
302 }
303 $result.= "</tr></thead>\n";
305 // Build list body
306 $result.= "<tbody class='listScrollContent listBodyFormat' id='t_nscrollbody' style='height:".$height."px;'>\n";
308 // No results? Just take an empty colspanned row
309 if (count($this->entries) + count($this->departments) == 0) {
310 $result.= "<tr class='rowxp0'><td class='list1nohighlight' colspan='$this->numColumns' style='height:100%;border-right:0px;width:100%;'> </td></tr>";
311 }
313 // Line color alternation
314 $alt= 0;
315 $deps= 0;
317 // Draw department browser if configured and we're not in sub mode
318 $this->useSpan= false;
319 if ($this->departmentBrowser && $this->filter->scope != "sub") {
320 // Fill with department browser if configured this way
321 $departmentIterator= new departmentSortIterator($this->departments, $this->sortDirection[$this->sortColumn]);
322 foreach ($departmentIterator as $row => $entry){
323 $result.="<tr class='rowxp".($alt&1)."'>";
325 // Render multi select if needed
326 if ($this->multiSelect) {
327 $result.="<td style='text-align:center;padding:0;' class='list1'> </td>";
328 }
330 // Render defined department columns, fill the rest with some stuff
331 $rest= $this->numColumns - 1;
332 foreach ($this->xmlData['table']['department'] as $index => $config) {
333 $colspan= 1;
334 if (isset($config['span'])){
335 $colspan= $config['span'];
336 $this->useSpan= true;
337 }
338 $result.="<td colspan='$colspan' ".$this->colprops[$index]." class='list1'>".$this->renderCell($config['value'], $entry, $row)."</td>";
339 $rest-= $colspan;
340 }
342 // Fill remaining cols with nothing
343 $last= $this->numColumns - $rest;
344 for ($i= 0; $i<$rest; $i++){
345 $result.= "<td ".$this->colprops[$last+$i-1]." class='list1'> </td>";
346 }
347 $result.="</tr>";
349 $alt++;
350 }
351 $deps= $alt;
352 }
354 // Fill with contents, sort as configured
355 foreach ($this->entries as $row => $entry) {
356 $trow= "";
358 // Render multi select if needed
359 if ($this->multiSelect) {
360 $trow.="<td style='text-align:center;width:20px;' class='list0'><input type='checkbox' id='listing_selected_$row' name='listing_selected_$row'></td>\n";
361 }
363 foreach ($this->xmlData['table']['column'] as $index => $config) {
364 $renderedCell= $this->renderCell($config['value'], $entry, $row);
365 $trow.="<td ".$this->colprops[$index]." class='list0'>".$renderedCell."</td>\n";
367 // Save rendered column
368 $sort= preg_replace('/.*>([^<]+)<.*$/', '$1', $renderedCell);
369 $sort= preg_replace('/ /', '', $sort);
370 if (preg_match('/</', $sort)){
371 $sort= "";
372 }
373 $this->entries[$row]["_sort$index"]= $sort;
374 }
376 // Save rendered entry
377 $this->entries[$row]['_rendered']= $trow;
378 }
380 // Complete list by sorting entries for _sort$index and appending them to the output
381 $entryIterator= new listingSortIterator($this->entries, $this->sortDirection[$this->sortColumn], "_sort".$this->sortColumn, $this->sortType);
382 foreach ($entryIterator as $row => $entry){
383 $alt++;
384 $result.="<tr class='rowxp".($alt&1)."'>\n";
385 $result.= $entry['_rendered'];
386 $result.="</tr>\n";
387 }
389 // Need to fill the list if it's not full (nobody knows why this is 22 ;-))
390 $emptyListStyle= (count($this->entries) + (($this->useSpan && count($this->entries))?$deps:0) == 0)?"border:0;":"";
391 if ((count($this->entries) + $deps) < 22) {
392 $result.= "<tr>";
393 for ($i= 0; $i<$this->numColumns; $i++) {
394 if ($i == 0) {
395 $result.= "<td class='list1nohighlight' style='$emptyListStyle height:100%;'> </td>";
396 continue;
397 }
398 if ($i != $this->numColumns-1) {
399 $result.= "<td class='list1nohighlight' style='$emptyListStyle'> </td>";
400 } else {
401 $result.= "<td class='list1nohighlight' style='border-right:1px solid #AAA;$emptyListStyle'> </td>";
402 }
403 }
404 $result.= "</tr>";
405 }
407 // Close list body
408 $result.= "</tbody></table></div></td></tr>";
410 // Add the footer if requested
411 if ($this->showFooter) {
412 $result.= "<tr><td class='nlistFooter'>";
414 foreach ($this->objectTypes as $objectType) {
415 if (isset($this->objectTypeCount[$objectType['label']])) {
416 $label= _($objectType['label']);
417 $result.= "<img class='center' src='".$objectType['image']."' title='$label' alt='$label'> ".$this->objectTypeCount[$objectType['label']]." ";
418 }
419 }
421 $result.= "</td></tr>";
422 }
424 // Close list
425 $result.= "</table>";
426 $result.= $switch?"<input type='hidden' id='list_workaround'>":"";
428 $smarty= get_smarty();
429 $smarty->assign("usePrototype", "true");
430 $smarty->assign("FILTER", $this->filter->render());
431 $smarty->assign("SIZELIMIT", print_sizelimit_warning());
432 $smarty->assign("LIST", $result);
434 // Assign navigation elements
435 $nav= $this->renderNavigation();
436 foreach ($nav as $key => $html) {
437 $smarty->assign($key, $html);
438 }
440 // Assign action menu / base
441 $smarty->assign("ACTIONS", $this->renderActionMenu());
442 $smarty->assign("BASE", $this->renderBase());
444 // Assign separator
445 $smarty->assign("SEPARATOR", "<img src='images/lists/seperator.png' alt='-' align='middle' height='16' width='1' class='center'>");
447 // Assign summary
448 $smarty->assign("HEADLINE", $this->headline);
450 return ($smarty->fetch(get_template_path($this->xmlData['definition']['template'], true)));
451 }
454 function update()
455 {
456 global $config;
457 $ui= get_userinfo();
459 // Reset object counter / DN mapping
460 $this->objectTypeCount= array();
461 $this->objectDnMapping= array();
463 // Do not do anything if this is not our PID
464 if(isset($_REQUEST['PID']) && $_REQUEST['PID'] != $this->pid) {
465 return;
466 }
468 // Save base
469 if (isset($_POST['BASE']) && $this->baseMode) {
470 $base= get_post('BASE');
471 if (isset($this->bases[$base])) {
472 $this->base= $base;
473 session::global_set("CurrentMainBase", $this->base);
474 }
475 }
477 // Override the base if we got a message from the browser navigation
478 if ($this->departmentBrowser && isset($_GET['act'])) {
479 if (preg_match('/^department_([0-9]+)$/', validate($_GET['act']), $match)){
480 if (isset($this->departments[$match[1]])){
481 $this->base= $this->departments[$match[1]]['dn'];
482 session::global_set("CurrentMainBase", $this->base);
483 }
484 }
485 }
487 // Filter POST with "act" attributes -> posted from action menu
488 if (isset($_POST['exec_act']) && $_POST['act'] != '') {
489 if (preg_match('/^export.*$/', $_POST['act']) && isset($this->exporter[$_POST['act']])) {
490 $exporter= $this->exporter[$_POST['act']];
491 $userinfo= ", "._("created by")." ".$ui->cn." - ".strftime('%A, %d. %B %Y, %H:%M:%S');
492 $entryIterator= new listingSortIterator($this->entries, $this->sortDirection[$this->sortColumn], "_sort".$this->sortColumn, $this->sortType);
493 $sortedEntries= array();
494 foreach ($entryIterator as $entry){
495 $sortedEntries[]= $entry;
496 }
497 $instance= new $exporter['class']($this->headline.$userinfo, $this->plainHeader, $sortedEntries, $this->exportColumns);
498 $type= call_user_func(array($exporter['class'], "getInfo"));
499 $type= $type[$_POST['act']];
500 send_binary_content($instance->query(), $type['filename'], $type= $type['mime']);
501 }
502 }
504 // Filter GET with "act" attributes
505 if (isset($_GET['act'])) {
506 $key= validate($_GET['act']);
507 if (preg_match('/^SORT_([0-9]+)$/', $key, $match)) {
508 // Switch to new column or invert search order?
509 $column= $match[1];
510 if ($this->sortColumn != $column) {
511 $this->sortColumn= $column;
512 } else {
513 $this->sortDirection[$column]= !$this->sortDirection[$column];
514 }
516 // Allow header to update itself according to the new sort settings
517 $this->renderHeader();
518 }
519 }
521 // Override base if we got signals from the navigation elements
522 $action= "";
523 foreach ($_POST as $key => $value) {
524 if (preg_match('/^(ROOT|BACK|HOME)_x$/', $key, $match)) {
525 $action= $match[1];
526 break;
527 }
528 }
530 // Navigation handling
531 if ($action == 'ROOT') {
532 $deps= $ui->get_module_departments($this->module);
533 $this->base= $deps[0];
534 }
535 if ($action == 'BACK') {
536 $deps= $ui->get_module_departments($this->module);
537 $base= preg_replace("/^[^,]+,/", "", $this->base);
538 if(in_array_ics($base, $deps)){
539 $this->base= $base;
540 }
541 }
542 if ($action == 'HOME') {
543 $ui= get_userinfo();
544 $this->base= $this->filter->getObjectBase($ui->dn);
545 }
547 // Reload departments
548 if ($this->departmentBrowser){
549 $this->departments= $this->getDepartments();
550 }
552 // Update filter and refresh entries
553 $this->filter->setBase($this->base);
554 $this->entries= $this->filter->query();
555 }
558 function setBase($base)
559 {
560 $this->base= $base;
561 }
564 function getBase()
565 {
566 return $this->base;
567 }
570 function parseLayout($layout)
571 {
572 $result= array();
573 $layout= preg_replace("/^\|/", "", $layout);
574 $layout= preg_replace("/\|$/", "", $layout);
575 $cols= split("\|", $layout);
577 foreach ($cols as $index => $config) {
578 if ($config != "") {
579 $res= "";
580 $components= split(';', $config);
581 foreach ($components as $part) {
582 if (preg_match("/^r$/", $part)) {
583 $res.= "text-align:right;";
584 continue;
585 }
586 if (preg_match("/^l$/", $part)) {
587 $res.= "text-align:left;";
588 continue;
589 }
590 if (preg_match("/^c$/", $part)) {
591 $res.= "text-align:center;";
592 continue;
593 }
594 if (preg_match("/^[0-9]+(|px|%)$/", $part)) {
595 $res.= "width:$part;min-width:$part;";
596 continue;
597 }
598 }
600 // Add minimum width for scalable columns
601 if (!preg_match('/width:/', $res)){
602 $res.= "min-width:200px;";
603 }
605 $result[$index]= " style='$res' ";
606 } else {
607 $result[$index]= " style='min-width:100px'";
608 }
609 }
611 // Save number of columns for later use
612 $this->numColumns= count($cols);
614 return $result;
615 }
618 function renderCell($data, $config, $row)
619 {
620 // Replace flat attributes in data string
621 for ($i= 0; $i<$config['count']; $i++) {
622 $attr= $config[$i];
623 $value= "";
624 if (is_array($config[$attr])) {
625 $value= $config[$attr][0];
626 } else {
627 $value= $config[$attr];
628 }
629 $data= preg_replace("/%\{$attr\}/", $value, $data);
630 }
632 // Watch out for filters and prepare to execute them
633 $data= $this->processElementFilter($data, $config, $row);
635 // Replace all non replaced %{...} instances because they
636 // are non resolved attributes or filters
637 $data= preg_replace('/%{[^}]+}/', ' ', $data);
639 return $data;
640 }
643 function renderBase()
644 {
645 if (!$this->baseMode) {
646 return;
647 }
649 $result= "<select name='BASE' onChange='mainform.submit()' size='1'>";
650 $firstDN= null;
651 $found= false;
653 foreach ($this->bases as $key=>$value) {
654 // Keep first entry to fall back eventually
655 if(!$firstDN) {
656 $firstDN= $key;
657 }
659 // Prepare to render entry
660 $selected= "";
661 if ($key == $this->base) {
662 $selected= " selected";
663 $found= true;
664 }
665 $key = htmlentities($key,ENT_QUOTES);
666 $result.= "\n<option value=\"".$key."\"$selected>".$value."</option>";
667 }
669 $result.= "</select>";
671 // Reset the currently used base to the first DN we found if there
672 // was no match.
673 if(!$found){
674 $this->base = $firstDN;
675 }
677 return $result;
678 }
681 function processElementFilter($data, $config, $row)
682 {
683 preg_match_all("/%\{filter:([^(]+)\((.*)\)\}/", $data, $matches, PREG_SET_ORDER);
685 foreach ($matches as $match) {
686 $cl= "";
687 $method= "";
688 if (preg_match('/::/', $match[1])) {
689 $cl= preg_replace('/::.*$/', '', $match[1]);
690 $method= preg_replace('/^.*::/', '', $match[1]);
691 } else {
692 if (!isset($this->filters[$match[1]])) {
693 continue;
694 }
695 $cl= preg_replace('/::.*$/', '', $this->filters[$match[1]]);
696 $method= preg_replace('/^.*::/', '', $this->filters[$match[1]]);
697 }
699 // Prepare params for function call
700 $params= array();
701 preg_match_all('/"[^"]+"|[^,]+/', $match[2], $parts);
702 foreach ($parts[0] as $param) {
704 // Row is replaced by the row number
705 if ($param == "row") {
706 $params[]= $row;
707 }
709 // pid is replaced by the current PID
710 if ($param == "pid") {
711 $params[]= $this->pid;
712 }
714 // base is replaced by the current base
715 if ($param == "base") {
716 $params[]= $this->getBase();
717 }
719 // Fixie with "" is passed directly
720 if (preg_match('/^".*"$/', $param)){
721 $params[]= preg_replace('/"/', '', $param);
722 }
724 // LDAP variables get replaced by their objects
725 for ($i= 0; $i<$config['count']; $i++) {
726 if ($param == $config[$i]) {
727 $values= $config[$config[$i]];
728 if (is_array($values)){
729 unset($values['count']);
730 }
731 $params[]= $values;
732 }
733 }
735 // Move dn if needed
736 if ($param == "dn") {
737 $params[]= LDAP::fix($config["dn"]);
738 }
739 }
741 // Replace information
742 if ($cl == "listing") {
743 // Non static call - seems to result in errors
744 $data= @preg_replace('/'.preg_quote($match[0]).'/', call_user_func_array(array($this, "$method"), $params), $data);
745 } else {
746 // Static call
747 $data= preg_replace('/'.preg_quote($match[0]).'/', call_user_func_array(array($cl, $method), $params), $data);
748 }
749 }
751 return $data;
752 }
755 function getObjectType($types, $classes)
756 {
757 // Walk thru types and see if there's something matching
758 foreach ($types as $objectType) {
759 $ocs= $objectType['objectClass'];
760 if (!is_array($ocs)){
761 $ocs= array($ocs);
762 }
764 $found= true;
765 foreach ($ocs as $oc){
766 if (preg_match('/^!(.*)$/', $oc, $match)) {
767 $oc= $match[1];
768 if (in_array($oc, $classes)) {
769 $found= false;
770 }
771 } else {
772 if (!in_array($oc, $classes)) {
773 $found= false;
774 }
775 }
776 }
778 if ($found) {
779 return $objectType;
780 }
781 }
783 return null;
784 }
787 function filterObjectType($dn, $classes)
788 {
789 // Walk thru classes and return on first match
790 $result= " ";
792 $objectType= $this->getObjectType($this->objectTypes, $classes);
793 if ($objectType) {
794 $this->objectDnMapping[$dn]= $objectType["objectClass"];
795 $result= "<img class='center' title='".LDAP::fix($dn)."' src='".$objectType["image"]."'>";
796 if (!isset($this->objectTypeCount[$objectType['label']])) {
797 $this->objectTypeCount[$objectType['label']]= 0;
798 }
799 $this->objectTypeCount[$objectType['label']]++;
800 }
802 return $result;
803 }
806 function filterActions($dn, $row, $classes)
807 {
808 // Do nothing if there's no menu defined
809 if (!isset($this->xmlData['actiontriggers']['action'])) {
810 return " ";
811 }
813 // Go thru all actions
814 $result= "";
815 $actions= $this->xmlData['actiontriggers']['action'];
816 foreach($actions as $action) {
817 // Skip the entry completely if there's no permission to execute it
818 if (!$this->hasActionPermission($action, $dn)) {
819 $result.= "<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
820 continue;
821 }
823 // Skip entry if the pseudo filter does not fit
824 if (isset($action['filter']) && preg_match('/^[a-z0-9_]+!?=[a-z0-9_]+$/i', $action['filter'])) {
825 list($fa, $fv)= split('=', $action['filter']);
826 if (preg_match('/^(.*)!$/', $fa, $m)){
827 $fa= $m[1];
828 if (isset($this->entries[$row][$fa]) && $this->entries[$row][$fa][0] == $fv) {
829 $result.= "<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
830 continue;
831 }
832 } else {
833 if (!isset($this->entries[$row][$fa]) && !$this->entries[$row][$fa][0] == $fv) {
834 $result.= "<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
835 continue;
836 }
837 }
838 }
841 // If there's an objectclass definition and we don't have it
842 // add an empty picture here.
843 if (isset($action['objectclass'])){
844 $objectclass= $action['objectclass'];
845 if (preg_match('/^!(.*)$/', $objectclass, $m)){
846 $objectclass= $m[1];
847 if(in_array($objectclass, $classes)) {
848 $result.= "<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
849 continue;
850 }
851 } else {
852 if(!in_array($objectclass, $classes)) {
853 $result.= "<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
854 continue;
855 }
856 }
857 }
859 // Render normal entries as usual
860 if ($action['type'] == "entry") {
861 $label= $this->processElementFilter($action['label'], $this->entries[$row], $row);
862 $image= $this->processElementFilter($action['image'], $this->entries[$row], $row);
863 $result.="<input class='center' type='image' src='$image' title='$label' ".
864 "name='listing_".$action['name']."_$row' style='padding:1px'>";
865 }
867 // Handle special types
868 if ($action['type'] == "copypaste" || $action['type'] == "snapshot") {
870 $objectType= $this->getObjectType($this->objectTypes, $this->entries[$row]['objectClass']);
871 $category= $class= null;
872 if ($objectType) {
873 $category= $objectType['category'];
874 $class= $objectType['class'];
875 }
877 if ($action['type'] == "copypaste") {
878 $result.= $this->renderCopyPasteActions($row, $this->entries[$row]['dn'], $category, $class);
879 } else {
880 $result.= $this->renderSnapshotActions($row, $this->entries[$row]['dn'], $category, $class);
881 }
882 }
883 }
885 return $result;
886 }
889 function filterDepartmentLink($row, $dn, $description)
890 {
891 $attr= $this->departments[$row]['sort-attribute'];
892 $name= $this->departments[$row][$attr];
893 if (is_array($name)){
894 $name= $name[0];
895 }
896 $result= sprintf("%s [%s]", $name, $description[0]);
897 return("<a href='?plug=".$_GET['plug']."&PID=$this->pid&act=department_$row' title='$dn'>$result</a>");
898 }
901 function filterLink()
902 {
903 $result= " ";
905 $row= func_get_arg(0);
906 $pid= $this->pid;
907 $dn= LDAP::fix(func_get_arg(1));
908 $params= array(func_get_arg(2));
910 // Collect sprintf params
911 for ($i = 3;$i < func_num_args();$i++) {
912 $val= func_get_arg($i);
913 if (is_array($val)){
914 $params[]= $val[0];
915 continue;
916 }
917 $params[]= $val;
918 }
920 $result= " ";
921 $trans= call_user_func_array("sprintf", $params);
922 if ($trans != "") {
923 return("<a href='?plug=".$_GET['plug']."&PID=$pid&act=listing_edit_$row' title='$dn'>$trans</a>");
924 }
926 return $result;
927 }
930 function renderNavigation()
931 {
932 $result= array();
933 $enableBack = true;
934 $enableRoot = true;
935 $enableHome = true;
937 $ui = get_userinfo();
939 /* Check if base = first available base */
940 $deps = $ui->get_module_departments($this->module);
942 if(!count($deps) || $deps[0] == $this->filter->base){
943 $enableBack = false;
944 $enableRoot = false;
945 }
947 $listhead ="";
949 /* Check if we are in users home department */
950 if(!count($deps) || $this->filter->base == $this->filter->getObjectBase($ui->dn)){
951 $enableHome = false;
952 }
954 /* Draw root button */
955 if($enableRoot){
956 $result["ROOT"]= "<input class='center' type='image' src='images/lists/root.png' align='middle' ".
957 "title='"._("Go to root department")."' name='ROOT' alt='"._("Root")."'>";
958 }else{
959 $result["ROOT"]= "<img src='images/lists/root_grey.png' class='center' alt='"._("Root")."'>";
960 }
962 /* Draw back button */
963 if($enableBack){
964 $result["BACK"]= "<input class='center' type='image' align='middle' src='images/lists/back.png' ".
965 "title='"._("Go up one department")."' alt='"._("Up")."' name='BACK'>";
966 }else{
967 $result["BACK"]= "<img src='images/lists/back_grey.png' class='center' alt='"._("Up")."'>";
968 }
970 /* Draw home button */
971 if($enableHome){
972 $result["HOME"]= "<input class='center' type='image' align='middle' src='images/lists/home.png' ".
973 "title='"._("Go to users department")."' alt='"._("Home")."' name='HOME'>";
974 }else{
975 $result["HOME"]= "<img src='images/lists/home_grey.png' class='center' alt='"._("Home")."'>";
976 }
978 /* Draw reload button, this button is enabled everytime */
979 $result["RELOAD"]= "<input class='center' type='image' src='images/lists/reload.png' align='middle' ".
980 "title='"._("Reload list")."' name='REFRESH' alt='"._("Submit")."'>";
982 return ($result);
983 }
986 function getAction()
987 {
988 // Do not do anything if this is not our PID, or there's even no PID available...
989 if(!isset($_REQUEST['PID']) || $_REQUEST['PID'] != $this->pid) {
990 return;
991 }
993 $result= array("targets" => array(), "action" => "");
995 // Filter GET with "act" attributes
996 if (isset($_GET['act'])) {
997 $key= validate($_GET['act']);
998 $target= preg_replace('/^listing_[a-zA-Z_]+_([0-9]+)$/', '$1', $key);
999 if (isset($this->entries[$target]['dn'])) {
1000 $result['action']= preg_replace('/^listing_([a-zA-Z_]+)_[0-9]+$/', '$1', $key);
1001 $result['targets'][]= $this->entries[$target]['dn'];
1002 }
1004 // Drop targets if empty
1005 if (count($result['targets']) == 0) {
1006 unset($result['targets']);
1007 }
1008 return $result;
1009 }
1011 // Filter POST with "listing_" attributes
1012 foreach ($_POST as $key => $prop) {
1014 // Capture selections
1015 if (preg_match('/^listing_selected_[0-9]+$/', $key)) {
1016 $target= preg_replace('/^listing_selected_([0-9]+)$/', '$1', $key);
1017 if (isset($this->entries[$target]['dn'])) {
1018 $result['targets'][]= $this->entries[$target]['dn'];
1019 }
1020 continue;
1021 }
1023 // Capture action with target - this is a one shot
1024 if (preg_match('/^listing_[a-zA-Z_]+_[0-9]+(|_x)$/', $key)) {
1025 $target= preg_replace('/^listing_[a-zA-Z_]+_([0-9]+)(|_x)$/', '$1', $key);
1026 if (isset($this->entries[$target]['dn'])) {
1027 $result['action']= preg_replace('/^listing_([a-zA-Z_]+)_[0-9]+(|_x)$/', '$1', $key);
1028 $result['targets']= array($this->entries[$target]['dn']);
1029 }
1030 break;
1031 }
1033 // Capture action without target
1034 if (preg_match('/^listing_[a-zA-Z_]+(|_x)$/', $key)) {
1035 $result['action']= preg_replace('/^listing_([a-zA-Z_]+)(|_x)$/', '$1', $key);
1036 continue;
1037 }
1038 }
1040 // Filter POST with "act" attributes -> posted from action menu
1041 if (isset($_POST['act']) && $_POST['act'] != '') {
1042 if (!preg_match('/^export.*$/', $_POST['act'])){
1043 $result['action']= validate($_POST['act']);
1044 }
1045 }
1047 // Drop targets if empty
1048 if (count($result['targets']) == 0) {
1049 unset($result['targets']);
1050 }
1051 return $result;
1052 }
1055 function renderActionMenu()
1056 {
1057 // Don't send anything if the menu is not defined
1058 if (!isset($this->xmlData['actionmenu']['action'])){
1059 return "";
1060 }
1062 // Array?
1063 if (isset($this->xmlData['actionmenu']['action']['type'])){
1064 $this->xmlData['actionmenu']['action']= array($this->xmlData['actionmenu']['action']);
1065 }
1067 // Load shortcut
1068 $actions= &$this->xmlData['actionmenu']['action'];
1069 $result= "<input type='hidden' name='act' id='actionmenu' value=''><div style='display:none'><input type='submit' name='exec_act' id='exec_act' value=''></div>".
1070 "<ul class='level1' id='root'><li><a href='#'>"._("Actions")." <img ".
1071 "border=0 class='center' src='images/lists/sort-down.png'></a>";
1073 // Build ul/li list
1074 $result.= $this->recurseActions($actions);
1076 return "<div id='pulldown'>".$result."</li></ul><div>";
1077 }
1080 function recurseActions($actions)
1081 {
1082 global $class_mapping;
1083 static $level= 2;
1084 $result= "<ul class='level$level'>";
1085 $separator= "";
1087 foreach ($actions as $action) {
1089 // Skip the entry completely if there's no permission to execute it
1090 if (!$this->hasActionPermission($action, $this->filter->base)) {
1091 continue;
1092 }
1094 // Skip entry if there're missing dependencies
1095 if (isset($action['depends'])) {
1096 $deps= is_array($action['depends'])?$action['depends']:array($action['depends']);
1097 foreach($deps as $clazz) {
1098 if (!isset($class_mapping[$clazz])){
1099 continue 2;
1100 }
1101 }
1102 }
1104 // Fill image if set
1105 $img= "";
1106 if (isset($action['image'])){
1107 $img= "<img border='0' class='center' src='".$action['image']."'> ";
1108 }
1110 if ($action['type'] == "separator"){
1111 $separator= " style='border-top:1px solid #AAA' ";
1112 continue;
1113 }
1115 // Dive into subs
1116 if ($action['type'] == "sub" && isset($action['action'])) {
1117 $level++;
1118 if (isset($action['label'])){
1119 $result.= "<li$separator><a href='#'>$img"._($action['label'])." <img border='0' src='images/forward-arrow.png'></a>";
1120 }
1122 // Ensure we've an array of actions, this enables sub menus with only one action.
1123 if(isset($action['action']['type'])){
1124 $action['action'] = array($action['action']);
1125 }
1127 $result.= $this->recurseActions($action['action'])."</li>";
1128 $level--;
1129 $separator= "";
1130 continue;
1131 }
1133 // Render entry elseways
1134 if (isset($action['label'])){
1135 $result.= "<li$separator><a href='#' onClick='document.getElementById(\"actionmenu\").value= \"".$action['name']."\";mainform.submit();'>$img"._($action['label'])."</a></li>";
1136 }
1138 // Check for special types
1139 switch ($action['type']) {
1140 case 'copypaste':
1141 $result.= $this->renderCopyPasteMenu($separator);
1142 break;
1144 case 'snapshot':
1145 $result.= $this->renderSnapshotMenu($separator);
1146 break;
1148 case 'exporter':
1149 $result.= $this->renderExporterMenu($separator);
1150 break;
1152 case 'daemon':
1153 $result.= $this->renderDaemonMenu($separator);
1154 break;
1155 }
1157 $separator= "";
1158 }
1160 $result.= "</ul>";
1161 return $result;
1162 }
1165 function hasActionPermission($action, $dn)
1166 {
1167 $ui= get_userinfo();
1169 if (isset($action['acl'])) {
1170 $acls= $action['acl'];
1171 if (!is_array($acls)) {
1172 $acls= array($acls);
1173 }
1175 // Every ACL has to pass
1176 foreach ($acls as $acl) {
1177 $module= $this->module;
1178 $aclList= array();
1180 // Split for category and plugins if needed
1181 // match for "[rw]" style entries
1182 if (preg_match('/^\[([rwcdm]+)\]$/', $acl, $match)){
1183 $aclList= array($match[1]);
1184 }
1186 // match for "users[rw]" style entries
1187 if (preg_match('/^([a-zA-Z0-9]+)\[([rwcdm]+)\]$/', $acl, $match)){
1188 $module= $match[1];
1189 $aclList= array($match[2]);
1190 }
1192 // match for "users/user[rw]" style entries
1193 if (preg_match('/^([a-zA-Z0-9]+\/[a-zA-Z0-9]+)\[([rwcdm]+)\]$/', $acl, $match)){
1194 $module= $match[1];
1195 $aclList= array($match[2]);
1196 }
1198 // match "users/user[userPassword:rw(,...)*]" style entries
1199 if (preg_match('/^([a-zA-Z0-9]+\/[a-zA-Z0-9]+)\[([a-zA-Z0-9]+:[rwcdm]+(,[a-zA-Z0-9]+:[rwcdm]+)*)\]$/', $acl, $match)){
1200 $module= $match[1];
1201 $aclList= split(',', $match[2]);
1202 }
1204 // Walk thru prepared ACL by using $module
1205 foreach($aclList as $sAcl) {
1206 $checkAcl= "";
1208 // Category or detailed permission?
1209 if (strpos('/', $module) === false) {
1210 if (preg_match('/([a-zA-Z0-9]+):([rwcdm]+)/', $sAcl, $m) ) {
1211 $checkAcl= $ui->get_permissions($dn, $module, $m[1]);
1212 $sAcl= $m[2];
1213 } else {
1214 $checkAcl= $ui->get_permissions($dn, $module, '0');
1215 }
1216 } else {
1217 $checkAcl= $ui->get_category_permissions($dn, $module);
1218 }
1220 // Split up remaining part of the acl and check if it we're
1221 // allowed to do something...
1222 $parts= str_split($sAcl);
1223 foreach ($parts as $part) {
1224 if (strpos($checkAcl, $part) === false){
1225 return false;
1226 }
1227 }
1229 }
1230 }
1231 }
1233 return true;
1234 }
1237 function refreshBasesList()
1238 {
1239 global $config;
1240 $ui= get_userinfo();
1242 // Do some array munching to get it user friendly
1243 $ids= $config->idepartments;
1244 $d= $ui->get_module_departments($this->module);
1245 $k_ids= array_keys($ids);
1246 $deps= array_intersect($d,$k_ids);
1248 // Fill internal bases list
1249 $this->bases= array();
1250 foreach($k_ids as $department){
1251 $this->bases[$department] = $ids[$department];
1252 }
1253 }
1256 function getDepartments()
1257 {
1258 $departments= array();
1259 $ui= get_userinfo();
1261 // Get list of supported department types
1262 $types = departmentManagement::get_support_departments();
1264 // Load departments allowed by ACL
1265 $validDepartments = $ui->get_module_departments($this->module);
1267 // Build filter and look in the LDAP for possible sub departments
1268 // of current base
1269 $filter= "(&(objectClass=gosaDepartment)(|";
1270 $attrs= array("description", "objectClass");
1271 foreach($types as $name => $data){
1272 $filter.= "(objectClass=".$data['OC'].")";
1273 $attrs[]= $data['ATTR'];
1274 }
1275 $filter.= "))";
1276 $res= get_list($filter, $this->module, $this->base, $attrs, GL_NONE);
1278 // Analyze list of departments
1279 foreach ($res as $department) {
1280 if (!in_array($department['dn'], $validDepartments)) {
1281 continue;
1282 }
1284 // Add the attribute where we use for sorting
1285 $oc= null;
1286 foreach(array_keys($types) as $type) {
1287 if (in_array($type, $department['objectClass'])) {
1288 $oc= $type;
1289 break;
1290 }
1291 }
1292 $department['sort-attribute']= $types[$oc]['ATTR'];
1294 // Move to the result list
1295 $departments[]= $department;
1296 }
1298 return $departments;
1299 }
1302 function renderCopyPasteMenu($separator, $copy= true, $cut= true)
1303 {
1304 // We can only provide information if we've got a copypaste handler
1305 // instance
1306 if(!(isset($this->copyPasteHandler) && is_object($this->copyPasteHandler))){
1307 return "";
1308 }
1310 // Presets
1311 $result= "";
1312 $read= $paste= false;
1313 $ui= get_userinfo();
1315 // Switch flags to on if there's at least one category which allows read/paste
1316 foreach($this->categories as $category){
1317 $read= $read || preg_match('/r/', $ui->get_category_permissions($this->base, $category));
1318 $paste= $paste || $ui->is_pasteable($this->base, $category) == 1;
1319 }
1322 // Draw entries that allow copy and cut
1323 if($read){
1325 // Copy entry
1326 if($copy){
1327 $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>";
1328 $separator= "";
1329 }
1331 // Cut entry
1332 if($cut){
1333 $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>";
1334 $separator= "";
1335 }
1336 }
1338 // Draw entries that allow pasting entries
1339 if($paste){
1340 if($this->copyPasteHandler->entries_queued()){
1341 $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>";
1342 }else{
1343 $result.= "<li$separator><a href='#'><img src='images/lists/paste-grey.png' alt='' border='0' class='center'> "._("Paste")."</a></li>";
1344 }
1345 }
1347 return($result);
1348 }
1351 function renderCopyPasteActions($row, $dn, $category, $class, $copy= true, $cut= true)
1352 {
1353 // We can only provide information if we've got a copypaste handler
1354 // instance
1355 if(!(isset($this->copyPasteHandler) && is_object($this->copyPasteHandler))){
1356 return "";
1357 }
1359 // Presets
1360 $ui = get_userinfo();
1361 $result = "";
1363 // Render cut entries
1364 if($cut){
1365 if($ui->is_cutable($dn, $category, $class)){
1366 $result .= "<input class='center' type='image'
1367 src='images/lists/cut.png' alt='"._("Cut")."' name='listing_cut_$row' title='"._("Cut this entry")."' style='padding:1px'>";
1368 }else{
1369 $result.="<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
1370 }
1371 }
1373 // Render copy entries
1374 if($copy){
1375 if($ui->is_copyable($dn, $category, $class)){
1376 $result.= "<input class='center' type='image'
1377 src='images/lists/copy.png' alt='"._("Copy")."' name='listing_copy_$row' title='"._("Copy this entry")."' style='padding:1px'>";
1378 }else{
1379 $result.="<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
1380 }
1381 }
1383 return($result);
1384 }
1387 function renderSnapshotMenu($separator)
1388 {
1389 // We can only provide information if we've got a snapshot handler
1390 // instance
1391 if(!(isset($this->snapshotHandler) && is_object($this->snapshotHandler))){
1392 return "";
1393 }
1395 // Presets
1396 $result = "";
1397 $ui = get_userinfo();
1399 if($this->snapshotHandler->enabled() && $ui->allow_snapshot_restore($this->base, $this->module)){
1401 // Check if there is something to restore
1402 $restore= false;
1403 foreach($this->snapshotHandler->getSnapshotBases() as $base){
1404 $restore= $restore || count($this->snapshotHandler->getDeletedSnapshots($base)) > 0;
1405 }
1407 // Draw icons according to the restore flag
1408 if($restore){
1409 $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>";
1410 }else{
1411 $result.= "<li$separator><a href='#'><img src='images/lists/restore_grey.png' alt='' border='0' class='center'> "._("Restore snapshots")."</a></li>";
1412 }
1413 }
1415 return($result);
1416 }
1419 function renderExporterMenu($separator)
1420 {
1421 // Presets
1422 $result = "";
1424 // Draw entries
1425 $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'>";
1427 // Export CVS as build in exporter
1428 foreach ($this->exporter as $action => $exporter) {
1429 $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>";
1430 }
1432 // Finalize list
1433 $result.= "</ul></li>";
1435 return($result);
1436 }
1439 function renderSnapshotActions($row, $dn, $category, $class, $copy= true, $cut= true)
1440 {
1441 // We can only provide information if we've got a snapshot handler
1442 // instance
1443 if(!(isset($this->snapshotHandler) && is_object($this->snapshotHandler))){
1444 return "";
1445 }
1447 // Presets
1448 $result= "";
1449 $ui = get_userinfo();
1451 // Only act if enabled here
1452 if($this->snapshotHandler->enabled()){
1454 // Draw restore button
1455 if ($ui->allow_snapshot_restore($dn, $category)){
1457 // Do we have snapshots for this dn?
1458 if($this->snapshotHandler->hasSnapshots($dn)){
1459 $result.= "<input class='center' type='image' src='images/lists/restore.png' ".
1460 "alt='"._("Restore snapshot")."' name='listing_restore_$row' title='".
1461 _("Restore snapshot")."' style='padding:1px'>";
1462 } else {
1463 $result.= "<img src='images/lists/restore_grey.png' alt=' ' class='center' style='padding:1px'>";
1464 }
1465 }
1467 // Draw snapshot button
1468 if($ui->allow_snapshot_create($dn, $category)){
1469 $result.= "<input class='center' type='image' src='images/snapshot.png' ".
1470 "alt='"._("Create snapshot")."' name='listing_snapshot_$row' title='".
1471 _("Create a new snapshot from this object")."' style='padding:1px'>";
1472 }else{
1473 $result.= "<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
1474 }
1475 }
1477 return($result);
1478 }
1481 function renderDaemonMenu($separator)
1482 {
1483 $result= "";
1485 // If there is a daemon registered, draw the menu entries
1486 if(class_available("DaemonEvent")){
1487 $events= DaemonEvent::get_event_types_by_category($this->categories);
1488 if(isset($events['BY_CLASS']) && count($events['BY_CLASS'])){
1489 foreach($events['BY_CLASS'] as $name => $event){
1490 $result.= "<li$separator><a href='#' onClick='document.getElementById(\"actionmenu\").value=\"$name\";document.getElementById(\"exec_act\").click();'>".$event['MenuImage']." ".$event['s_Menu_Name']."</a></li>";
1491 $separator= "";
1492 }
1493 }
1494 }
1496 return $result;
1497 }
1500 function getType($dn)
1501 {
1502 if (isset($this->objectDnMapping[$dn])) {
1503 return $this->objectDnMapping[$dn];
1504 }
1505 return null;
1506 }
1508 }
1510 ?>