Code

Added workservice to ogorup tabs
[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     }
27     /* Remove mail group if there is no user anymore */
28     if((!preg_match("/U/",$objects))&&(isset($this->by_object['mailgroup']))){
29       $this->by_object['mailgroup']->remove_from_parent();
30       unset($this->by_object['mailgroup']);
31       unset($this->by_name['mailgroup']);
32     }
33     
34     /* Remove terminal group, if theres no terminal left in the object list */
35     if((!preg_match("/T/",$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['workstartup']->remove_from_parent();
44       unset($this->by_object['workstartup']);
45       unset($this->by_name['workstartup']);
46 //      $this->by_object['workservice']->remove_from_parent();
47       unset($this->by_object['workservice']);
48       unset($this->by_name['workservice']);
49     }
50   
51     /* Create goPhoneAccount if theres an user with goPhoneAccount
52      * but only if there is currently no queue enabled.
53      */
54     if(!isset($this->by_object['phonequeue'])){
55       foreach($this->by_object['ogroup']->memberList as $dn => $val){
56         if(isset($val['objectClass'])){
57           if(in_array("goFonAccount",$val['objectClass'])){
58             require_once("class_phonequeue.inc");
59             $this->by_name['phonequeue']= _("Phone queue");
60             $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn);
61             $this->by_object['phonequeue']->acl = "#all#";
62             $this->by_object['phonequeue']->parent= &$this;
63           }
64         }
65       }
66     }
68     /* Add mail group tab , if there is curerntly no mail tab defined */ 
69     if((preg_match("/U/",$objects))&&(!isset($this->by_object['mailogroup']))){
70       if(isset($this->config->current['MAILMETHOD'])){
71         if (preg_match('/kolab/i', $this->config->current['MAILMETHOD'])){
72           require_once("class_mailogroup.inc");
73           $this->by_name['mailogroup']= _("Mail");
74           $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn);
75           $this->by_object['mailogroup']->parent= &$this;
76         }
77       }
78     }
80     /* Add Terminal tab */
81     if((preg_match("/T/",$objects))&&(!isset($this->by_object['termgroup']))){
82       require_once("class_termgroup.inc");
83       if(!isset($this->by_object['termgroup'])){
84         $this->by_name['termgroup']= _("Terminals");
85         $this->by_object['termgroup']= new termgroup($this->config, $this->dn);
86         $this->by_object['termgroup']->parent= &$this;
87       }
88     }
89     
90     /* Add Workstation tabs */
91     if((preg_match("/W/",$objects))&&(!isset($this->by_object['workstartup']))){
92       if(!isset($this->by_object['workstartup'])){
93         $this->by_name['workstartup']= _("Startup");
94         $this->by_object['workstartup']= new workstartup($this->config, $this->dn);
95         $this->by_object['workstartup']->acl = "#all#";
96         $this->by_object['workstartup']->parent= &$this;
97         $this->by_name['workservice']= _("Service");
98         $this->by_object['workservice']= new workservice($this->config, $this->dn);
99         $this->by_object['workservice']->acl = "#all#";
100         $this->by_object['workservice']->parent= &$this;
101       }
102     }
103   }
105   function execute(){
106     $str = "";
107     $this->by_object['ogroup']->AddDelMembership();
108     $this->reload($this->by_object['ogroup']->gosaGroupObjects);
109     $str .= tabs::execute();
110     return ( $str);
111   }  
113   function ogrouptabs($config, $data, $dn)
114   {
116     tabs::tabs($config, $data, $dn);
117     $this->base= $this->by_object['ogroup']->base;
119     /* Insert extra tabs for several object types - if present */
121     $objects= preg_replace('/[\[\]]/', '', $this->by_object['ogroup']->gosaGroupObjects);
122     
123     for ($n= 0; $n<strlen($objects); $n++){
124       switch ($objects[$n]){
125         case "T":
126           /* Add a terminal tab */
127           require_once("class_termgroup.inc");
128           $this->by_name['termgroup']= _("Terminals");
129           $this->by_object['termgroup']= new termgroup($this->config, $this->dn);
130           $this->by_object['termgroup']->parent= &$this;
132           break;
134           case "U":
135             /* Append a PhoneQueue, if objectClass = goFonAccount */
136             $use = false;
137           foreach($this->by_object['ogroup']->memberList as $dn => $val){
138             if(isset($val['objectClass'])){
139               if(in_array("goFonAccount",$val['objectClass'])){
140                 $use = true; 
141               }
142             }
143           }
145           /* We found goFonAccount in users objectClasses*/
146           if($use){
147             require_once("class_phonequeue.inc");
148             $this->by_name['phonequeue']= _("Phone queue");
149             $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn);
150             $this->by_object['phonequeue']->parent= &$this;
152           } 
153  
154           /* Add a user tab used for mail distribution lists */
155           if(isset($this->config->current['MAILMETHOD'])){
156             if (preg_match('/kolab/i', $this->config->current['MAILMETHOD'])){
157               require_once("class_mailogroup.inc");
158               $this->by_name['mailogroup']= _("Mail");
159               $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn);
160               $this->by_object['mailogroup']->parent= &$this;
161             }
162           }
164           break;
165       }
166     }
167   }
170   function check()
171   {
172     return (tabs::check(TRUE));
173   }
176   function save_object($save_current= FALSE)
177   {
178     tabs::save_object($save_current);
180     /* Update reference, transfer variables */
181     $baseobject= $this->by_object['ogroup'];
182     foreach ($this->by_object as $name => $obj){
184       /* Don't touch base object */
185       if ($name != 'ogroup'){
186         $obj->parent= &$this;
187         $obj->uid= $baseobject->uid;
188         $obj->sn= $baseobject->uid;
189         $obj->givenName= $baseobject->uid;
190         $this->by_object[$name]= $obj;
191       }
193       /* Update parent in base object */
194       $this->by_object['ogroup']->parent= &$this;
195     }
196   }
199   function save()
200   {
201     $baseobject= $this->by_object['ogroup'];
203     /* Check for new 'dn', in order to propagate the
204        'dn' to all plugins */
205     $new_dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base;
207     /* Move group? */
208     if ($this->dn != $new_dn){
210       /* Write entry on new 'dn' */
211       if ($this->dn != "new"){
212         $baseobject->move($this->dn, $new_dn);
213         $this->by_object['ogroup']= $baseobject;
214       }
216       /* Happen to use the new one */
217       $this->dn= $new_dn;
218     }
220     if ($this->dn == "new"){
221       $this->dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base;
222     }
224     tabs::save();
225   }
229 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
230 ?>