Code

Backport from trunk
[gosa.git] / gosa-plugins / goto / addons / goto / events / class_EventAddUserDialog.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: class_EventAddSystemDialog.inc 15243 2010-01-22 08:53:18Z 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 EventAddUserDialog 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("core", "userRDN"), 
35                 get_ou("core", "groupRDN")); 
37         // Build filter
38         if (session::global_is_set(get_class($this)."_filter")){
39             $filter= session::global_get(get_class($this)."_filter");
40         } else {
41             $filter = new filter(get_template_path("../../addons/goto/events/eventTargetUser-filter.xml", TRUE));
42             $filter->setObjectStorage($this->storagePoints);
43         }
44         $this->setFilter($filter);
46         // Build headpage
47         $headpage = new listing(get_template_path("../../addons/goto/events/eventTargetUser-list.xml", TRUE));
48         $headpage->setFilter($filter);
49         parent::__construct($config, $ui, "object", $headpage);
50     }
52     function save_object() {}
54     function save()
55     {
56         $act = $this->detectPostActions();
57         $headpage = $this->getHeadpage();
58         if(!isset($act['targets'])) return(array());
59         $ret = array();
60         foreach($act['targets'] as $dn){
61             $ret[] = $headpage->getEntry($dn);
62         }
63         return($ret);
64     }
66     function get_selected_targets()
67     {
68         $entries = $this->save();
69         $a_targets = array("USERS" => array(),"GROUPS" => array());
70         foreach($entries as $entry){
71             if(in_array_strict("posixGroup",$entry['objectClass'])){
72                 $a_targets['GROUPS'][] = $entry['cn'][0];
73             }
74             if(in_array_strict("gosaAccount",$entry['objectClass'])){
75                 $a_targets['USERS'][] = $entry['uid'][0];
76             }
77         }
78         return($a_targets);
79     }
80 }
81 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
82 ?>