Code

Updated objectListing
[gosa.git] / gosa-core / plugins / admin / groups / class_groupManagement.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 groupManagement extends management
24 {
25     var $plHeadline     = "Groups";
26     var $plDescription  = "Manage aspects of groups like members, POSIX, desktop, samba and mail settings";
27     var $plIcon  = "plugins/groups/images/plugin.png";
29     // Tab definition 
30     protected $tabClass = "grouptabs";
31     protected $tabType = "GROUPTABS";
32     protected $aclCategory = "groups";
33     protected $aclPlugin   = "group";
34     protected $objectName   = "group";
36     function __construct($config,$ui)
37     {
38         $this->config = $config;
39         $this->ui = $ui;
41         $this->storagePoints = array(get_ou("core", "groupRDN"));
43         // Build filter
44         if (session::global_is_set(get_class($this)."_filter")){
45             $filter= session::global_get(get_class($this)."_filter");
46         } else {
47             $filter = new filter(get_template_path("group-filter.xml", true));
48             $filter->setObjectStorage($this->storagePoints);
49         }
50         $this->setFilter($filter);
52         // Build headpage
53         $headpage = new listing(get_template_path("group-list.xml", true));
54         $headpage->registerElementFilter("filterProperties", "groupManagement::filterProperties");
55         $headpage->setFilter($filter);
57         // Add copy&paste and snapshot handler.
58         if ($this->config->boolValueIsTrue("core", "copyPaste")){
59             $this->cpHandler = new CopyPasteHandler($this->config);
60         }
61         if($this->config->get_cfg_value("core","enableSnapshots") == "true"){
62             $this->snapHandler = new SnapshotHandler($this->config);
63         }
64         parent::__construct($config, $ui, "groups", $headpage);
66         $this->registerAction("edit_group","editEntry");
67         $this->registerAction("edit_group_","editEntry");
68         $this->registerAction("edit_group__","editEntry");
69         $this->registerAction("edit_environment","editEntry");
70         $this->registerAction("edit_appgroup","editEntry");
71         $this->registerAction("edit_mailgroup","editEntry");
73         $this->registerAction("sendMessage", "sendMessage");
74         $this->registerAction("saveEventDialog", "saveEventDialog");
75         $this->registerAction("abortEventDialog", "closeDialogs");
76     }
78     // Inject user actions
79     function detectPostActions()
80     {
81         $action = management::detectPostActions();
82         if(isset($_POST['save_event_dialog'])) $action['action'] = "saveEventDialog";
83         if(isset($_POST['abort_event_dialog'])) $action['action'] = "abortEventDialog";
84         return($action);
85     }
88     /*! \brief  Sends a message to a set of users using gosa-si events.
89      */
90     function saveEventDialog()
91     {
92         $this->dialogObject->save_object();
93         $msgs = $this->dialogObject->check();
94         if(count($msgs)){
95             msg_dialog::displayChecks($msgs);
96         }else{
97             $o_queue = new gosaSupportDaemon();
98             $o_queue->append($this->dialogObject);
99             if($o_queue->is_error()){
100                 msg_dialog::display(_("Infrastructure error"), msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
101             }
102             $this->closeDialogs();
103         }
104     }
107     /*! \brief  Sends a message to a set of users using gosa-si events.
108      */
109     function sendMessage($action="",$target=array(),$all=array())
110     {
111         $uids = array();
112         $ldap = $this->config->get_ldap_link();
113         $ldap->cd($this->config->current['BASE']);
114         foreach($target as $dn){
115             $ldap->cat($dn,array('cn'));
116             if($ldap->count()){
117                 $attrs = $ldap->fetch();
118                 $uids[] = $attrs['cn'][0];
119             }
120         }
121         if(count($uids)){
122             $events = DaemonEvent::get_event_types(USER_EVENT);
123             $event = "DaemonEvent_notify";
124             if(isset($events['BY_CLASS'][$event])){
125                 $type = $events['BY_CLASS'][$event];
126                 $this->dialogObject = new $type['CLASS_NAME']($this->config);
127                 $this->dialogObject->add_groups($uids);
128                 $this->dialogObject->set_type(SCHEDULED_EVENT);
129             }
130         }
131     }
134     function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
135     {
136         $str = management::editEntry($action,$target);
137         if(preg_match("/^edit_/",$action)){
138             $tab = preg_replace("/^edit_([^_]*).*$/","\\1",$action);
139             if(isset($this->tabObject->by_object[$tab])){
140                 $this->tabObject->current = $tab;
141             }else{
142                 trigger_error("Unknown tab: ".$tab);
143             }
144         }
145         if(!empty($str)) return($str);
146     }
148     static function filterProperties($row, $classes)
149     {
150         $result= "";
152         $map = array(
153                 "posixGroup" => 
154                 array(
155                     "image" => "plugins/groups/images/select_group.png",
156                     "plugin" => "group",
157                     "alt" => _("POSIX"),
158                     "title" => _("Edit POSIX properties")
159                     ),
161                 "gosaMailAccount" => 
162                 array(
163                     "image" => "plugins/groups/images/mail.png",
164                     "plugin" => "mailgroup",
165                     "alt" => _("Mail"),
166                     "title" => _("Edit mail properties")
167                     ),
169                 "sambaGroupMapping" => 
170                 array(
171                     "image" => "plugins/groups/images/samba.png",
172                     "plugin" => "group_",
173                     "alt" => _("Samba"),
174                     "title" => _("Edit samba properties")
175                     ),
177                 "goFonPickupGroup" => 
178                     array(
179                             "image" => "plugins/groups/images/asterisk.png",
180                             "plugin" => "group__",
181                             "alt" => _("Phone"),
182                             "title" => _("Edit phone properties")
183                          ),
185                 "gotoMenuGroup" => 
186                     array(
187                             "image" => "plugins/groups/images/menu.png",
188                             "plugin" => "appgroup",
189                             "alt" => _("Menu"),
190                             "title" => _("Edit start menu properties")
191                          ),
193                 "gotoEnvironment" => 
194                     array(
195                             "image" => "plugins/groups/images/environment.png",
196                             "plugin" => "environment",
197                             "alt" => _("Environment"),
198                             "title" => _("Edit environment properties")
199                          )
200                     );
203         // Walk thru map
204         foreach ($map as $oc => $properties) {
205             if (in_array_ics($oc, $classes)) {
206                 $result.= image($properties['image'], 'listing_edit_'.$properties['plugin'].'_'.$row, $properties['title']);
207             } else {
208                 $result.= image('images/empty.png');
209             }
210         }
211         return $result;
212     }
213
214 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
215 ?>