Code

Updated zone Handling
[gosa.git] / plugins / admin / ogroups / tabs_ogroups.inc
1 <?php
3 class ogrouptabs extends tabs
4 {
5   var $base= "";
6   
7   function reload($dd){
8     $objects= preg_replace('/[\[\]]/', '', $dd);
9     
10     /* If there is a phonequeue,
11      * but there is no user left with goPhoneAccount ... remove it.
12      */
13     $usePhoneTab = false;
14     $o_cache = $this->by_object['ogroup']->objcache;
15     foreach($this->by_object['ogroup']->memberList as $dn => $val){
16       if(isset($o_cache[$dn]['objectClass'])){
17         if(in_array("goFonAccount",$o_cache[$dn]['objectClass'])){
18           $usePhoneTab = true;
19         }
20       }
21     }
22     if(((!$usePhoneTab)&&(isset($this->by_object['phonequeue'])))||((!preg_match("/U/",$objects))&&(isset($this->by_object['phonequeue'])))){
23       $this->by_object['phonequeue']->remove_from_parent();
24       unset($this->by_object['phonequeue']);
25       unset($this->by_name['phonequeue']);
26     }
27     /* Remove mail group if there is no user anymore */
28     if((!preg_match("/U/",$objects))&&(isset($this->by_object['mailogroup']))){
29       $this->by_object['mailogroup']->remove_from_parent();
30       unset($this->by_object['mailogroup']);
31       unset($this->by_name['mailogroup']);
32     }
33     
34     /* Remove terminal group, if theres no terminal left in the object list */
35     if(((!preg_match("/T/",$objects)) && (!preg_match("/W/",$objects)))&&(isset($this->by_object['termgroup']))){
36       $this->by_object['termgroup']->remove_from_parent();
37       unset($this->by_object['termgroup']);
38       unset($this->by_name['termgroup']);
39     }
40     
41     /* Remove ws tabs, if theres no ws left in the object list */
42     if((!preg_match("/W/",$objects))&&(isset($this->by_object['workstartup']))){
43       $this->by_object['workservice']->remove_from_parent();
44       unset($this->by_object['workservice']);
45       unset($this->by_name['workservice']);
46       $this->by_object['workstartup']->remove_from_parent();
47       unset($this->by_object['workstartup']);
48       unset($this->by_name['workstartup']);
49       $this->by_object['faiSummary']->remove_from_parent();
50       unset($this->by_object['faiSummary']);
51       unset($this->by_name['faiSummary']);
52     }
53   
54     /* Create goPhoneAccount if theres an user with goPhoneAccount
55      * but only if there is currently no queue enabled.
56      */
57     $o_cache = $this->by_object['ogroup']->objcache;
58     if(!isset($this->by_object['phonequeue'])){
59       foreach($this->by_object['ogroup']->memberList as $dn => $val){
60         if(isset($o_cache[$dn]['objectClass'])){
61           if(in_array("goFonAccount",$o_cache[$dn]['objectClass'])){
62             require_once("class_phonequeue.inc");
63             $this->by_name['phonequeue']= _("Phone queue");
64             $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn);
65             $this->by_object['phonequeue']->acl = "#all#";
66             $this->by_object['phonequeue']->parent= &$this;
67           }
68         }
69       }
70     }
72     /* Add mail group tab , if there is curerntly no mail tab defined */ 
73     if((preg_match("/U/",$objects))&&(!isset($this->by_object['mailogroup']))){
74       if(isset($this->config->current['MAILMETHOD'])){
75         if (preg_match('/kolab/i', $this->config->current['MAILMETHOD'])){
76           require_once("class_mailogroup.inc");
77           $this->by_name['mailogroup']= _("Mail");
78           $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn);
79           $this->by_object['mailogroup']->acl = "#all#";
80           $this->by_object['mailogroup']->parent= &$this;
81         }
82       }
83     }
85     /* Add Terminal tab */
86     if(((preg_match("/T/",$objects)) || (preg_match("/W/",$objects)))&&(!isset($this->by_object['termgroup']))){
87       require_once("class_termgroup.inc");
88       if(!isset($this->by_object['termgroup'])){
89         $this->by_name['termgroup']= _("System");
90         $this->by_object['termgroup']= new termgroup($this->config, $this->dn);
91         $this->by_object['termgroup']->acl = "#all#";
92         $this->by_object['termgroup']->inheritTimeServer = false;
93         $this->by_object['termgroup']->parent= &$this;
94       }
95     }
96     
97     /* Add Workstation tabs */
98     if((preg_match("/W/",$objects))&&(!isset($this->by_object['workstartup']))){
99       if(!isset($this->by_object['workstartup'])){
100         $this->by_name['workstartup']= _("Startup");
101         $this->by_object['workstartup']= new workstartup($this->config, $this->dn);
102         $this->by_object['workstartup']->acl = "#all#";
103         $this->by_object['workstartup']->parent= &$this;
104         $this->by_name['workservice']= _("Devices");
105         $this->by_object['workservice']= new workservice($this->config, $this->dn);
106         $this->by_object['workservice']->acl = "#all#";
107         $this->by_object['workservice']->inheritTimeServer = false;
108         $this->by_object['workservice']->parent= &$this;
109         $this->by_name['faiSummary']= _("Summary");
110         $this->by_object['faiSummary']= new faiSummaryTab($this->config, $this->dn);
111         $this->by_object['faiSummary']->acl = "#all#";
112         $this->by_object['faiSummary']->parent= &$this;
113       }
114     }
116     /* Add application tab if user or group is member in this object group*/ 
117     if((preg_match("/G/",$objects) || preg_match("/U/",$objects)) && !isset($this->by_name['appgroup'])){
118       $this->by_name['appgroup']= _("Application");
119       $this->by_object['appgroup']= new appgroup($this->config, $this->dn);
120       $this->by_object['appgroup']->acl = "#all#";
121       $this->by_object['appgroup']->parent= &$this;
122     }
124     /* Remove application tab if not required any longer */
125     if(!preg_match("/G/",$objects) && !preg_match("/U/",$objects) && isset($this->by_name['appgroup'])){
126       $this->by_object['appgroup']->remove_from_parent();
127       unset($this->by_name['appgroup']);
128       unset($this->by_object['appgroup']);
129     }  
130  
131  
132     /* Add environment tab if user or group is member in this object group*/ 
133     if((preg_match("/G/",$objects) || preg_match("/U/",$objects)) && !isset($this->by_name['environment'])){
134       $this->by_name['environment']= _("Environment");
135       $this->by_object['environment']= new environment($this->config, $this->dn);
136       $this->by_object['environment']->acl = "#all#";
137       $this->by_object['environment']->parent= &$this;
138     }
140     /* Remove environment tab if not required any longer */
141     if(!preg_match("/G/",$objects) && !preg_match("/U/",$objects) && isset($this->by_name['environment'])){
142       $this->by_object['environment']->remove_from_parent();
143       unset($this->by_name['environment']);
144       unset($this->by_object['environment']);
145     }  
147  
148     /* Move reference tab to last position*/
149     if(isset($this->by_name['reference'])){
150       $tmp = $this->by_name['reference'];
151       unset($this->by_name['reference']);
152       $this->by_name['reference'] = $tmp;
153     }
154   }
156   function execute(){
157     $str = "";
158     $this->by_object['ogroup']->AddDelMembership();
159     $this->reload($this->by_object['ogroup']->gosaGroupObjects);
160     $str .= tabs::execute();
161     return ( $str);
162   }  
164   function ogrouptabs($config, $data, $dn)
165   {
167     tabs::tabs($config, $data, $dn);
168     $this->base= $this->by_object['ogroup']->base;
170     /* Insert extra tabs for several object types - if present */
172     $objects= preg_replace('/[\[\]]/', '', $this->by_object['ogroup']->gosaGroupObjects);
173     
174     for ($n= 0; $n<strlen($objects); $n++){
175       switch ($objects[$n]){
176         case "T":
177           /* Add a terminal tab */
178           require_once("class_termgroup.inc");
179           $this->by_name['termgroup']= _("Terminals");
180           $this->by_object['termgroup']= new termgroup($this->config, $this->dn);
181           $this->by_object['termgroup']->parent= &$this;
183           break;
185           case "U":
186             /* Append a PhoneQueue, if objectClass = goFonAccount */
187             $use = false;
188           $o_cache = $this->by_object['ogroup']->objcache;
189           foreach($this->by_object['ogroup']->memberList as $dn => $val){
190             if(isset($o_cache[$dn]['objectClass'])){
191               if(in_array("goFonAccount",$o_cache[$dn]['objectClass'])){
192                 $use = true; 
193               }
194             }
195           }
197           /* We found goFonAccount in users objectClasses*/
198           if($use){
199             require_once("class_phonequeue.inc");
200             $this->by_name['phonequeue']= _("Phone queue");
201             $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn);
202             $this->by_object['phonequeue']->parent= &$this;
204           } 
205  
206           /* Add a user tab used for mail distribution lists */
207           if(isset($this->config->current['MAILMETHOD'])){
208             if (preg_match('/kolab/i', $this->config->current['MAILMETHOD'])){
209               require_once("class_mailogroup.inc");
210               $this->by_name['mailogroup']= _("Mail");
211               $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn);
212               $this->by_object['mailogroup']->parent= &$this;
213             }
214           }
216           break;
217       }
218     }
219     $this->reload($this->by_object['ogroup']->gosaGroupObjects);
220   }
223   function check()
224   {
225     return (tabs::check(FALSE));
226   }
229   function save_object($save_current= FALSE)
230   {
231     tabs::save_object($save_current);
233     /* Update reference, transfer variables */
234     $baseobject= $this->by_object['ogroup'];
235     foreach ($this->by_object as $name => $obj){
237       /* Don't touch base object */
238       if ($name != 'ogroup'){
239         $obj->parent    = &$this;
240         $obj->uid       = $baseobject->uid;
241         $obj->cn        = $baseobject->cn;
242         $obj->sn        = $baseobject->uid;
243         $obj->givenName = $baseobject->uid;
244         $this->by_object[$name]= $obj;
245       }
247       /* Update parent in base object */
248       $this->by_object['ogroup']->parent= &$this;
249     }
250   }
253   function save()
254   {
255     $baseobject= $this->by_object['ogroup'];
257     /* Check for new 'dn', in order to propagate the
258        'dn' to all plugins */
259     $new_dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base;
261     /* Move group? */
262     if ($this->dn != $new_dn){
264       /* Write entry on new 'dn' */
265       if ($this->dn != "new"){
266         $baseobject->move($this->dn, $new_dn);
267         $this->by_object['ogroup']= $baseobject;
268       }
270       /* Happen to use the new one */
271       $this->dn= $new_dn;
272     }
274     if ($this->dn == "new"){
275       $this->dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base;
276     }
278     tabs::save();
280     /* Fix tagging if needed */
281                 $baseobject->dn= $new_dn;
282     $baseobject->handle_object_tagging();
283   }
285   function saveCopyDialog()
286   {
287     tabs::saveCopyDialog();
288     $baseobject= $this->by_object['ogroup'];
289     $cn = $baseobject->cn;
290     foreach($this->by_object as  $name => $obj){
291       $this->by_object[$name]->cn = $cn;
292     }
293   }
297 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
298 ?>