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 var $plHeadline = "Object selection";
31 function __construct($config,$ui)
32 {
33 $this->config = $config;
34 $this->ui = $ui;
35 $this->storagePoints = array(
36 get_ou("core", "userRDN"),
37 get_ou("core", "groupRDN"),
38 get_ou("termgeneric", "terminalRDN"),
39 get_ou("workgeneric", "workstationRDN"),
40 get_ou("servgeneric", "serverRDN"),
41 get_ou("printgeneric", "printerRDN"),
42 get_ou("phoneGeneric", "phoneRDN"));
44 // Build filter
45 if (session::global_is_set(get_class($this)."_filter")){
46 $filter= session::global_get(get_class($this)."_filter");
47 } else {
48 $filter = new filter(get_template_path("selectObject-filter.xml", true, dirname(__FILE__)));
49 $filter->setObjectStorage($this->storagePoints);
50 }
51 $this->setFilter($filter);
53 // Build headpage
54 $headpage = new listing(get_template_path("selectObject-list.xml", true, dirname(__FILE__)));
55 $headpage->registerElementFilter("depLabel", "objectSelect::filterDepLabel");
56 $this->registerAction("open","openEntry");
57 $headpage->setFilter($filter);
58 parent::__construct($config, $ui, "object", $headpage);
59 }
62 // An action handler which enables to switch into deparmtment by clicking the names.
63 function openEntry($action,$entry)
64 {
65 $headpage = $this->getHeadpage();
66 $headpage->setBase(array_pop($entry));
67 }
70 // A filter which allows to open a department by clicking on the departments name.
71 static function filterDepLabel($row,$dn,$pid,$base,$objectClass, $cn)
72 {
73 $cn = $cn[0];
74 if(!in_array_strict('gosaDepartment', $objectClass)){
75 return($cn);
76 }
77 if($dn == $base){
78 $cn =".";
79 }
80 $dn= LDAP::fix(func_get_arg(1));
81 return("<a href='?plug=".$_GET['plug']."&PID=$pid&act=listing_open_$row' title='$dn'>$cn</a>");
82 }
84 function save()
85 {
86 $act = $this->detectPostActions();
87 $headpage = $this->getHeadpage();
88 if(!isset($act['targets'])) return(array());
89 $ret = array();
90 foreach($act['targets'] as $dn){
91 $ret[] = $headpage->getEntry($dn);
92 }
93 return($ret);
94 }
95 }
96 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
97 ?>