Code

Added grey restore vutton to top of divlist
[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     foreach($this->by_object['ogroup']->memberList as $dn => $val){
15       if(isset($val['objectClass'])){
16         if(in_array("goFonAccount",$val['objectClass'])){
17           $usePhoneTab = true;
18         }
19       }
20     }
21     if(((!$usePhoneTab)&&(isset($this->by_object['phonequeue'])))||((!preg_match("/U/",$objects))&&(isset($this->by_object['phonequeue'])))){
22       $this->by_object['phonequeue']->remove_from_parent();
23       unset($this->by_object['phonequeue']);
24       unset($this->by_name['phonequeue']);
25     }
26     /* Remove mail group if there is no user anymore */
27     if((!preg_match("/U/",$objects))&&(isset($this->by_object['mailogroup']))){
28       $this->by_object['mailogroup']->remove_from_parent();
29       unset($this->by_object['mailogroup']);
30       unset($this->by_name['mailogroup']);
31     }
32     
33     /* Remove terminal group, if theres no terminal left in the object list */
34     if(((!preg_match("/T/",$objects)) && (!preg_match("/W/",$objects)))&&(isset($this->by_object['termgroup']))){
35       $this->by_object['termgroup']->remove_from_parent();
36       unset($this->by_object['termgroup']);
37       unset($this->by_name['termgroup']);
38     }
39     
40     /* Remove ws tabs, if theres no ws left in the object list */
41     if((!preg_match("/W/",$objects))&&(isset($this->by_object['workstartup']))){
42       $this->by_object['workservice']->remove_from_parent();
43       unset($this->by_object['workservice']);
44       unset($this->by_name['workservice']);
45       $this->by_object['workstartup']->remove_from_parent();
46       unset($this->by_object['workstartup']);
47       unset($this->by_name['workstartup']);
48       $this->by_object['faiSummary']->remove_from_parent();
49       unset($this->by_object['faiSummary']);
50       unset($this->by_name['faiSummary']);
51     }
52   
53     /* Create goPhoneAccount if theres an user with goPhoneAccount
54      * but only if there is currently no queue enabled.
55      */
56     if(!isset($this->by_object['phonequeue'])){
57       foreach($this->by_object['ogroup']->memberList as $dn => $val){
58         if(isset($val['objectClass'])){
59           if(in_array("goFonAccount",$val['objectClass'])){
60             require_once("class_phonequeue.inc");
61             $this->by_name['phonequeue']= _("Phone queue");
62             $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn);
63             $this->by_object['phonequeue']->acl = "#all#";
64             $this->by_object['phonequeue']->parent= &$this;
65           }
66         }
67       }
68     }
70     /* Add mail group tab , if there is curerntly no mail tab defined */ 
71     if((preg_match("/U/",$objects))&&(!isset($this->by_object['mailogroup']))){
72       if(isset($this->config->current['MAILMETHOD'])){
73         if (preg_match('/kolab/i', $this->config->current['MAILMETHOD'])){
74           require_once("class_mailogroup.inc");
75           $this->by_name['mailogroup']= _("Mail");
76           $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn);
77           $this->by_object['mailogroup']->acl = "#all#";
78           $this->by_object['mailogroup']->parent= &$this;
79         }
80       }
81     }
83     /* Add Terminal tab */
84     if(((preg_match("/T/",$objects)) || (preg_match("/W/",$objects)))&&(!isset($this->by_object['termgroup']))){
85       require_once("class_termgroup.inc");
86       if(!isset($this->by_object['termgroup'])){
87         $this->by_name['termgroup']= _("System");
88         $this->by_object['termgroup']= new termgroup($this->config, $this->dn);
89         $this->by_object['termgroup']->acl = "#all#";
90         $this->by_object['termgroup']->inheritTimeServer = false;
91         $this->by_object['termgroup']->parent= &$this;
92       }
93     }
94     
95     /* Add Workstation tabs */
96     if((preg_match("/W/",$objects))&&(!isset($this->by_object['workstartup']))){
97       if(!isset($this->by_object['workstartup'])){
98         $this->by_name['workstartup']= _("Startup");
99         $this->by_object['workstartup']= new workstartup($this->config, $this->dn);
100         $this->by_object['workstartup']->acl = "#all#";
101         $this->by_object['workstartup']->parent= &$this;
102         $this->by_name['workservice']= _("Devices");
103         $this->by_object['workservice']= new workservice($this->config, $this->dn);
104         $this->by_object['workservice']->acl = "#all#";
105         $this->by_object['workservice']->inheritTimeServer = false;
106         $this->by_object['workservice']->parent= &$this;
107         $this->by_name['faiSummary']= _("Summary");
108         $this->by_object['faiSummary']= new faiSummaryTab($this->config, $this->dn);
109         $this->by_object['faiSummary']->acl = "#all#";
110         $this->by_object['faiSummary']->parent= &$this;
111       }
112     }
113   
114     /* Move reference tab to last position*/
115     if(isset($this->by_name['reference'])){
116       $tmp = $this->by_name['reference'];
117       unset($this->by_name['reference']);
118       $this->by_name['reference'] = $tmp;
119     }
120   }
122   function execute(){
123     $str = "";
124         /* Call parent execute */
125         plugin::execute();
127     $this->by_object['ogroup']->AddDelMembership();
128     $this->reload($this->by_object['ogroup']->gosaGroupObjects);
129     $str .= tabs::execute();
130     return ( $str);
131   }  
133   function ogrouptabs($config, $data, $dn)
134   {
136     tabs::tabs($config, $data, $dn);
137     $this->base= $this->by_object['ogroup']->base;
139     /* Insert extra tabs for several object types - if present */
141     $objects= preg_replace('/[\[\]]/', '', $this->by_object['ogroup']->gosaGroupObjects);
142     
143     for ($n= 0; $n<strlen($objects); $n++){
144       switch ($objects[$n]){
145         case "T":
146           /* Add a terminal tab */
147           require_once("class_termgroup.inc");
148           $this->by_name['termgroup']= _("Terminals");
149           $this->by_object['termgroup']= new termgroup($this->config, $this->dn);
150           $this->by_object['termgroup']->parent= &$this;
152           break;
154           case "U":
155             /* Append a PhoneQueue, if objectClass = goFonAccount */
156             $use = false;
157           foreach($this->by_object['ogroup']->memberList as $dn => $val){
158             if(isset($val['objectClass'])){
159               if(in_array("goFonAccount",$val['objectClass'])){
160                 $use = true; 
161               }
162             }
163           }
165           /* We found goFonAccount in users objectClasses*/
166           if($use){
167             require_once("class_phonequeue.inc");
168             $this->by_name['phonequeue']= _("Phone queue");
169             $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn);
170             $this->by_object['phonequeue']->parent= &$this;
172           } 
173  
174           /* Add a user tab used for mail distribution lists */
175           if(isset($this->config->current['MAILMETHOD'])){
176             if (preg_match('/kolab/i', $this->config->current['MAILMETHOD'])){
177               require_once("class_mailogroup.inc");
178               $this->by_name['mailogroup']= _("Mail");
179               $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn);
180               $this->by_object['mailogroup']->parent= &$this;
181             }
182           }
184           break;
185       }
186     }
187   }
190   function check()
191   {
192     return (tabs::check(FALSE));
193   }
196   function save_object($save_current= FALSE)
197   {
198     tabs::save_object($save_current);
200     /* Update reference, transfer variables */
201     $baseobject= $this->by_object['ogroup'];
202     foreach ($this->by_object as $name => $obj){
204       /* Don't touch base object */
205       if ($name != 'ogroup'){
206         $obj->parent= &$this;
207         $obj->uid= $baseobject->uid;
208         $obj->sn= $baseobject->uid;
209         $obj->givenName= $baseobject->uid;
210         $this->by_object[$name]= $obj;
211       }
213       /* Update parent in base object */
214       $this->by_object['ogroup']->parent= &$this;
215     }
216   }
219   function save()
220   {
221     $baseobject= $this->by_object['ogroup'];
223     /* Check for new 'dn', in order to propagate the
224        'dn' to all plugins */
225     $new_dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base;
227     /* Move group? */
228     if ($this->dn != $new_dn){
230       /* Write entry on new 'dn' */
231       if ($this->dn != "new"){
232         $baseobject->move($this->dn, $new_dn);
233         $this->by_object['ogroup']= $baseobject;
234       }
236       /* Happen to use the new one */
237       $this->dn= $new_dn;
238     }
240     if ($this->dn == "new"){
241       $this->dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base;
242     }
244     tabs::save();
246     /* Fix tagging if needed */
247                 $baseobject->dn= $new_dn;
248     $baseobject->handle_object_tagging();
249   }
253 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
254 ?>