Code

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