Code

Fixed logging for open groupware account
[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['workstartup']))){
45       $this->by_object['workservice']->remove_from_parent();
46       unset($this->by_object['workservice']);
47       unset($this->by_name['workservice']);
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     if(!isset($this->by_object['phonequeue'])){
60       foreach($this->by_object['ogroup']->memberList as $dn => $val){
62         $obj = $this->by_object['ogroup']->objcache[$dn];
63   
64         if(isset($obj['objectClass'])){
65           if(in_array("goFonAccount",$obj['objectClass'])){
66             require_once("class_phonequeue.inc");
67             $this->by_name['phonequeue']= _("Phone queue");
68             $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn);
69             $this->by_object['phonequeue']->parent= &$this;
70             break;
71           }
72         }
73       }
74     }
76     /* Add mail group tab , if there is curerntly no mail tab defined */ 
77     if((preg_match("/U/",$objects))&&(!isset($this->by_object['mailogroup']))){
78       if(isset($this->config->current['MAILMETHOD'])){
79         if (preg_match('/kolab/i', $this->config->current['MAILMETHOD'])){
80           require_once("class_mailogroup.inc");
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       require_once("class_termgroup.inc");
91       if(!isset($this->by_object['termgroup'])){
92         $this->by_name['termgroup']= _("System");
93         $this->by_object['termgroup']= new termgroup($this->config, $this->dn);
94         $this->by_object['termgroup']->inheritTimeServer = false;
95         $this->by_object['termgroup']->parent= &$this;
96       }
97     }
98     
99     /* Add Workstation tabs */
100     if((preg_match("/W/",$objects))&&(!isset($this->by_object['workstartup']))){
101       if(!isset($this->by_object['workstartup'])){
102         $this->by_name['workstartup']= _("Startup");
103         $this->by_object['workstartup']= new workstartup($this->config, $this->dn);
104         $this->by_object['workstartup']->parent= &$this;
105         $this->by_name['workservice']= _("Devices");
106         $this->by_object['workservice']= new workservice($this->config, $this->dn);
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']->parent= &$this;
112       }
113     }
115     /* Move reference tab to second position from right */
116     if(isset($this->by_name['acl'])){
117       $tmp = $this->by_name['acl'];
118       unset($this->by_name['acl']);
119       $this->by_name['acl'] = $tmp;
120     }
121   
122     /* Move reference tab to last position*/
123     if(isset($this->by_name['reference'])){
124       $tmp = $this->by_name['reference'];
125       unset($this->by_name['reference']);
126       $this->by_name['reference'] = $tmp;
127     }
129     /* Reset acls */
130     $this->set_acl_base($this->base);
131     foreach($this->by_object as $name => $obj){
132       $this->by_object[$name]->set_acl_category($this->acl_category);
133     }
134   }
136   function execute(){
137     $str = "";
138     $this->by_object['ogroup']->AddDelMembership();
139     $this->reload($this->by_object['ogroup']->gosaGroupObjects);
140     $str .= tabs::execute();
141     return ( $str);
142   }  
144   function ogrouptabs($config, $data, $dn,$category ="ogroups")
145   {
147     tabs::tabs($config, $data, $dn, $category);
148     $this->base= $this->by_object['ogroup']->base;
149     $this->acl_category = $category;
151     /* Insert extra tabs for several object types - if present */
153     $objects= preg_replace('/[\[\]]/', '', $this->by_object['ogroup']->gosaGroupObjects);
154    
155     for ($n= 0; $n<strlen($objects); $n++){
156       switch ($objects[$n]){
157         case "T":
158           /* Add a terminal tab */
159           require_once("class_termgroup.inc");
160           $this->by_name['termgroup']= _("Terminals");
161           $this->by_object['termgroup']= new termgroup($this->config, $this->dn);
162           $this->by_object['termgroup']->parent= &$this;
164           break;
166           case "U":
167             /* Append a PhoneQueue, if objectClass = goFonAccount */
168             $use = false;
169           foreach($this->by_object['ogroup']->memberList as $dn => $val){
171             $obj = $this->by_object['ogroup']->objcache[$dn];
172             
173             if(isset($obj['objectClass'])){
174               if(in_array("goFonAccount",$obj['objectClass'])){
175                 $use = true; 
176               }
177             }
178           }
180           /* We found goFonAccount in users objectClasses*/
181           if($use){
182             require_once("class_phonequeue.inc");
183             $this->by_name['phonequeue']= _("Phone queue");
184             $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn);
185             $this->by_object['phonequeue']->parent= &$this;
186           } 
187  
188           /* Add a user tab used for mail distribution lists */
189           if(isset($this->config->current['MAILMETHOD'])){
190             if (preg_match('/kolab/i', $this->config->current['MAILMETHOD'])){
191               require_once("class_mailogroup.inc");
192               $this->by_name['mailogroup']= _("Mail");
193               $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn);
194               $this->by_object['mailogroup']->parent= &$this;
195             }
196           }
198           break;
199       }
200     }
202     /* Add references/acls/snapshots */
203     $this->reload($this->by_object['ogroup']->gosaGroupObjects);
204     $this->addSpecialTabs();
205   }
208   function check()
209   {
210     return (tabs::check(FALSE));
211   }
214   function save_object($save_current= FALSE)
215   {
216     tabs::save_object($save_current);
218     /* Update reference, transfer variables */
219     $baseobject= $this->by_object['ogroup'];
220     foreach ($this->by_object as $name => $obj){
222       /* Don't touch base object */
223       if ($name != 'ogroup'){
224         $obj->parent    = &$this;
225         $obj->uid       = $baseobject->uid;
226         $obj->cn        = $baseobject->cn;
227         $obj->sn        = $baseobject->uid;
228         $obj->givenName = $baseobject->uid;
229         $this->by_object[$name]= $obj;
230       }
232       /* Update parent in base object */
233       $this->by_object['ogroup']->parent= &$this;
234     }
235   }
238   function save()
239   {
240     $baseobject= $this->by_object['ogroup'];
242     /* Check for new 'dn', in order to propagate the
243        'dn' to all plugins */
244     $new_dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base;
246     /* Move group? */
247     if ($this->dn != $new_dn){
249       /* Write entry on new 'dn' */
250       if ($this->dn != "new"){
251         $baseobject->move($this->dn, $new_dn);
252         $this->by_object['ogroup']= $baseobject;
253       }
255       /* Happen to use the new one */
256       $this->dn= $new_dn;
257     }
259     if ($this->dn == "new"){
260       $this->dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base;
261     }
263     tabs::save();
265     /* Fix tagging if needed */
266                 $baseobject->dn= $new_dn;
267     $baseobject->handle_object_tagging();
268   }
270   function getCopyDialog()
271   {
272     $this->reload($this->by_object['ogroup']->gosaGroupObjects); 
273     return(tabs::getCopyDialog());
274   }
277 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
278 ?>