Code

Replaced in_array calls with in_array_strict
[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("servgeneric", "serverRDN"), 
35         get_ou("workgeneric", "workstationRDN"), 
36         get_ou("group", "ogroupRDN"), 
37         get_ou("termgeneric", "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       $member_dns[] = $entry['dn'];
78       if(in_array_strict("gosaGroupOfNames", $entry['objectClass'])){
79         $ldap->cat($entry['dn']);
80         if($ldap->count()){
81           $attrs = $ldap->fetch();
82           if(isset($attrs['member'])){
83             for($i =0 ; $i< $attrs['member']['count']; $i++){
84               $member_dns[] = $attrs['member'][$i];
85             }
86           }
87         }
88       }
89     }
90     foreach($member_dns as $dn){
91       $ldap->cat($dn, array('macAddress')); 
92       if($ldap->count()){
93         $attrs = $ldap->fetch();
94         if(isset($attrs['macAddress'])){
95           $macs[] = $attrs['macAddress'][0];
96         }
97       }
98     }
99     return($macs);
100   }
102 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
103 ?>