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: class_target_list.inc 9850 2008-03-14 14:15:12Z hickert $$
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 objectSelect extends management
24 {
25 // Tab definition
26 protected $skipFooter = TRUE;
27 protected $skipHeader = TRUE;
29 function __construct($config,$ui)
30 {
31 $this->config = $config;
32 $this->ui = $ui;
33 $this->storagePoints = array(
34 get_ou("userRDN"),
35 get_ou("groupRDN"),
36 get_ou("terminalRDN"),
37 get_ou("workstationRDN"),
38 get_ou("serverRDN"),
39 get_ou("printerRDN"),
40 get_ou("phoneRDN"));
42 # // Build filter
43 # if (session::global_is_set(get_class($this)."_filter")){
44 # $filter= session::global_get(get_class($this)."_filter");
45 # } else {
46 $filter = new filter(get_template_path("selectObject-filter.xml", true, dirname(__FILE__)));
47 $filter->setObjectStorage($this->storagePoints);
48 #}
49 $this->setFilter($filter);
51 // Build headpage
52 $headpage = new listing(get_template_path("selectObject-list.xml", true, dirname(__FILE__)));
53 $headpage->registerElementFilter("depLabel", "objectSelect::filterDepLabel");
54 $this->registerAction("open","openEntry");
55 $headpage->setFilter($filter);
56 parent::__construct($config, $ui, "object", $headpage);
57 }
60 // An action handler which enables to switch into deparmtment by clicking the names.
61 function openEntry($action,$entry)
62 {
63 $headpage = $this->getHeadpage();
64 $headpage->setBase(array_pop($entry));
65 }
68 // A filter which allows to open a department by clicking on the departments name.
69 static function filterDepLabel($row,$dn,$pid,$base,$objectClass, $cn)
70 {
71 $cn = $cn[0];
72 if(!in_array_strict('gosaDepartment', $objectClass)){
73 return($cn);
74 }
75 if($dn == $base){
76 $cn =".";
77 }
78 $dn= LDAP::fix(func_get_arg(1));
79 return("<a href='?plug=".$_GET['plug']."&PID=$pid&act=listing_open_$row' title='$dn'>$cn</a>");
80 }
82 function save()
83 {
84 $act = $this->detectPostActions();
85 $headpage = $this->getHeadpage();
86 if(!isset($act['targets'])) return(array());
87 $ret = array();
88 foreach($act['targets'] as $dn){
89 $ret[] = $headpage->getEntry($dn);
90 }
91 return($ret);
92 }
93 }
94 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
95 ?>