Code

c84f6f7bdad6a10fe7330b9db75d509d564e2b3d
[gosa.git] / gosa-plugins / goto / addons / goto / events / class_EventAddSystemDialog.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 EventAddSystemDialog 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("serverRDN"), 
35         get_ou("workstationRDN"), 
36         get_ou("ogroupRDN"), 
37         get_ou('terminalRDN'));
39     // Build filter
40 #    if (session::global_is_set(get_class($this)."_filter")){
41  #     $filter= session::global_get(get_class($this)."_filter");
42   #  } else {
43       $filter = new filter(get_template_path("../../addons/goto/events/eventTargetSystems-filter.xml", TRUE));
44       $filter->setObjectStorage($this->storagePoints);
45    # }
46     $this->setFilter($filter);
48     // Build headpage
49     $headpage = new listing(get_template_path("../../addons/goto/events/eventTargetSystems-list.xml", TRUE));
50     $headpage->setFilter($filter);
51     parent::__construct($config, $ui, "object", $headpage);
52   }
54   function save_object() {}
56   function save()
57   {
58     $act = $this->detectPostActions();
59     $headpage = $this->getHeadpage();
60     if(!isset($act['targets'])) return(array());
61     $ret = array();
62     foreach($act['targets'] as $dn){
63       $ret[] = $headpage->getEntry($dn);
64     }
65     return($ret);
66   }
68   function get_selected_targets()
69   {
70     // Collect mac addresses 
71     $entries = $this->save();
72     $macs = array();
73     $ldap = $this->config->get_ldap_link();
74     $ldap->cd($this->config->current['BASE']);
75     $member_dns = array();
76     foreach($entries as $entry){
77       if(isset($entry['macAddress'][0])){
78         $macs[] = $entry['macAddress'][0];
79       }
80       if(in_array("gosaGroupOfNames", $entry['objectClass'])){
81         $ldap->cat($entry['dn']);
82         if($ldap->count()){
83           $attrs = $ldap->fetch();
84           if(isset($attrs['member'])){
85             for($i =0 ; $i< $attrs['member']['count']; $i++){
86               $member_dns[] = $attrs['member'][$i];
87             }
88           }
89         }
90       }
91     }
92     foreach($member_dns as $dn){
93       $ldap->cat($dn, array('macAddress')); 
94       if($ldap->count()){
95         $attrs = $ldap->fetch();
96         if(isset($attrs['macAddress'])){
97           $macs[] = $attrs['macAddress'][0];
98         }
99       }
100     }
101     return($macs);
102   }
104 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
105 ?>