Code

Hide tabs frames
[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['workservice']))){
43       $this->by_object['workservice']->remove_from_parent();
44       unset($this->by_object['workservice']);
45       unset($this->by_name['workservice']);
46     }
47     if((!preg_match("/S/",$objects) && !preg_match("/W/",$objects))&&(isset($this->by_object['workstartup']))){
48       $this->by_object['workstartup']->remove_from_parent();
49       unset($this->by_object['workstartup']);
50       unset($this->by_name['workstartup']);
51       $this->by_object['faiSummary']->remove_from_parent();
52       unset($this->by_object['faiSummary']);
53       unset($this->by_name['faiSummary']);
54     }
55   
56     /* Create goPhoneAccount if theres an user with goPhoneAccount
57      * but only if there is currently no queue enabled.
58      */
59     $o_cache = $this->by_object['ogroup']->objcache;
60     if(!isset($this->by_object['phonequeue'])){
61       foreach($this->by_object['ogroup']->memberList as $dn => $val){
62         if(isset($o_cache[$dn]['objectClass'])){
63           if(in_array("goFonAccount",$o_cache[$dn]['objectClass'])){
64             require_once("class_phonequeue.inc");
65             $this->by_name['phonequeue']= _("Phone queue");
66             $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn);
67             $this->by_object['phonequeue']->acl = "#all#";
68             $this->by_object['phonequeue']->parent= &$this;
69           }
70         }
71       }
72     }
74     /* Add mail group tab , if there is curerntly no mail tab defined */ 
75     if((preg_match("/U/",$objects))&&(!isset($this->by_object['mailogroup']))){
76       if(isset($this->config->current['MAILMETHOD'])){
77         if (preg_match('/kolab/i', $this->config->current['MAILMETHOD'])){
78           require_once("class_mailogroup.inc");
79           $this->by_name['mailogroup']= _("Mail");
80           $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn);
81           $this->by_object['mailogroup']->acl = "#all#";
82           $this->by_object['mailogroup']->parent= &$this;
83         }
84       }
85     }
87     /* Add Terminal tab */
88     if(((preg_match("/T/",$objects)) || (preg_match("/W/",$objects)))&&(!isset($this->by_object['termgroup']))){
89       require_once("class_termgroup.inc");
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']->acl = "#all#";
94         $this->by_object['termgroup']->inheritTimeServer = false;
95         $this->by_object['termgroup']->parent= &$this;
96       }
97     }
99     /* Add Workstation tabs */
100     if((preg_match("/W/",$objects))&&(!isset($this->by_object['workservice']))){
101       $this->by_name['workservice']= _("Devices");
102       $this->by_object['workservice']= new workservice($this->config, $this->dn);
103       $this->by_object['workservice']->inheritTimeServer = false;
104       $this->by_object['workservice']->parent= &$this;
105     }
106     if((preg_match("/S/",$objects) || preg_match("/W/",$objects))&&(!isset($this->by_object['workstartup']))){
107       $this->by_name['workstartup']= _("Startup");
108       $this->by_object['workstartup']= new workstartup($this->config, $this->dn);
109       $this->by_object['workstartup']->parent= &$this;
110       $this->by_name['faiSummary']= _("Summary");
111       $this->by_object['faiSummary']= new faiSummaryTab($this->config, $this->dn);
112       $this->by_object['faiSummary']->parent= &$this;
113     }
115     /* Add application tab if user or group is member in this object group*/ 
116     if((preg_match("/G/",$objects) || preg_match("/U/",$objects)) && !isset($this->by_name['appgroup'])){
117       $this->by_name['appgroup']= _("Application");
118       $this->by_object['appgroup']= new appgroup($this->config, $this->dn);
119       $this->by_object['appgroup']->acl = "#all#";
120       $this->by_object['appgroup']->parent= &$this;
121     }
123     /* Remove application tab if not required any longer */
124     if(!preg_match("/G/",$objects) && !preg_match("/U/",$objects) && isset($this->by_name['appgroup'])){
125       $this->by_object['appgroup']->remove_from_parent();
126       unset($this->by_name['appgroup']);
127       unset($this->by_object['appgroup']);
128     }  
129  
130  
131     /* Add environment tab if user or group is member in this object group*/ 
132     if((preg_match("/G/",$objects) || preg_match("/U/",$objects)) && !isset($this->by_name['environment'])){
133       $this->by_name['environment']= _("Environment");
134       $this->by_object['environment']= new environment($this->config, $this->dn);
135       $this->by_object['environment']->acl = "#all#";
136       $this->by_object['environment']->parent= &$this;
137     }
139     /* Remove environment tab if not required any longer */
140     if(!preg_match("/G/",$objects) && !preg_match("/U/",$objects) && isset($this->by_name['environment'])){
141       $this->by_object['environment']->remove_from_parent();
142       unset($this->by_name['environment']);
143       unset($this->by_object['environment']);
144     }  
146  
147     /* Move reference tab to last position*/
148     if(isset($this->by_name['reference'])){
149       $tmp = $this->by_name['reference'];
150       unset($this->by_name['reference']);
151       $this->by_name['reference'] = $tmp;
152     }
153   }
155   function execute(){
156     $str = "";
157     $this->by_object['ogroup']->AddDelMembership();
158     $this->reload($this->by_object['ogroup']->gosaGroupObjects);
159     $str .= tabs::execute();
160     return ( $str);
161   }  
163   function ogrouptabs($config, $data, $dn)
164   {
166     tabs::tabs($config, $data, $dn);
167     $this->base= $this->by_object['ogroup']->base;
169     /* Insert extra tabs for several object types - if present */
171     $objects= preg_replace('/[\[\]]/', '', $this->by_object['ogroup']->gosaGroupObjects);
172     
173     for ($n= 0; $n<strlen($objects); $n++){
174       switch ($objects[$n]){
175         case "T":
176           /* Add a terminal tab */
177           require_once("class_termgroup.inc");
178           $this->by_name['termgroup']= _("Terminals");
179           $this->by_object['termgroup']= new termgroup($this->config, $this->dn);
180           $this->by_object['termgroup']->parent= &$this;
182           break;
184           case "U":
185             /* Append a PhoneQueue, if objectClass = goFonAccount */
186             $use = false;
187           $o_cache = $this->by_object['ogroup']->objcache;
188           foreach($this->by_object['ogroup']->memberList as $dn => $val){
189             if(isset($o_cache[$dn]['objectClass'])){
190               if(in_array("goFonAccount",$o_cache[$dn]['objectClass'])){
191                 $use = true; 
192               }
193             }
194           }
196           /* We found goFonAccount in users objectClasses*/
197           if($use){
198             require_once("class_phonequeue.inc");
199             $this->by_name['phonequeue']= _("Phone queue");
200             $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn);
201             $this->by_object['phonequeue']->parent= &$this;
203           } 
204  
205           /* Add a user tab used for mail distribution lists */
206           if(isset($this->config->current['MAILMETHOD'])){
207             if (preg_match('/kolab/i', $this->config->current['MAILMETHOD'])){
208               require_once("class_mailogroup.inc");
209               $this->by_name['mailogroup']= _("Mail");
210               $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn);
211               $this->by_object['mailogroup']->parent= &$this;
212             }
213           }
215           break;
216       }
217     }
218     $this->reload($this->by_object['ogroup']->gosaGroupObjects);
219   }
222   function check()
223   {
224     return (tabs::check(FALSE));
225   }
228   function save_object($save_current= FALSE)
229   {
230     tabs::save_object($save_current);
232     /* Update reference, transfer variables */
233     $baseobject= $this->by_object['ogroup'];
234     foreach ($this->by_object as $name => $obj){
236       /* Don't touch base object */
237       if ($name != 'ogroup'){
238         $obj->parent    = &$this;
239         $obj->uid       = $baseobject->uid;
240         $obj->cn        = $baseobject->cn;
241         $obj->sn        = $baseobject->uid;
242         $obj->givenName = $baseobject->uid;
243         $this->by_object[$name]= $obj;
244       }
246       /* Update parent in base object */
247       $this->by_object['ogroup']->parent= &$this;
248     }
249   }
252   function save()
253   {
254     $baseobject= $this->by_object['ogroup'];
256     /* Check for new 'dn', in order to propagate the
257        'dn' to all plugins */
258     $new_dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base;
260     /* Move group? */
261     if ($this->dn != $new_dn){
263       /* Write entry on new 'dn' */
264       if ($this->dn != "new"){
265         $baseobject->move($this->dn, $new_dn);
266         $this->by_object['ogroup']= $baseobject;
267       }
269       /* Happen to use the new one */
270       $this->dn= $new_dn;
271     }
273     if ($this->dn == "new"){
274       $this->dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base;
275     }
277     tabs::save();
279     /* Fix tagging if needed */
280                 $baseobject->dn= $new_dn;
281     $baseobject->handle_object_tagging();
282   }
284   function saveCopyDialog()
285   {
286     tabs::saveCopyDialog();
287     $baseobject= $this->by_object['ogroup'];
288     $cn = $baseobject->cn;
289     foreach($this->by_object as  $name => $obj){
290       $this->by_object[$name]->cn = $cn;
291     }
292   }
296 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
297 ?>