1 <?php
3 class ogrouptabs extends tabs
4 {
5 var $base= "";
6 var $acl_category;
8 function reload($dd){
9 $objects= preg_replace('/[\[\]]/', '', $dd);
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){
16 if(isset($val['objectClass'])){
17 if(in_array("goFonAccount",$val['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 }
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 }
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['workservice']->remove_from_parent();
44 unset($this->by_object['workservice']);
45 unset($this->by_name['workservice']);
46 $this->by_object['workstartup']->remove_from_parent();
47 unset($this->by_object['workstartup']);
48 unset($this->by_name['workstartup']);
49 $this->by_object['faiSummary']->remove_from_parent();
50 unset($this->by_object['faiSummary']);
51 unset($this->by_name['faiSummary']);
52 }
54 /* Create goPhoneAccount if theres an user with goPhoneAccount
55 * but only if there is currently no queue enabled.
56 */
57 if(!isset($this->by_object['phonequeue'])){
58 foreach($this->by_object['ogroup']->memberList as $dn => $val){
59 if(isset($val['objectClass'])){
60 if(in_array("goFonAccount",$val['objectClass'])){
61 require_once("class_phonequeue.inc");
62 $this->by_name['phonequeue']= _("Phone queue");
63 $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn);
64 $this->by_object['phonequeue']->acl = "#all#";
65 $this->by_object['phonequeue']->parent= &$this;
66 }
67 }
68 }
69 }
71 /* Add mail group tab , if there is curerntly no mail tab defined */
72 if((preg_match("/U/",$objects))&&(!isset($this->by_object['mailogroup']))){
73 if(isset($this->config->current['MAILMETHOD'])){
74 if (preg_match('/kolab/i', $this->config->current['MAILMETHOD'])){
75 require_once("class_mailogroup.inc");
76 $this->by_name['mailogroup']= _("Mail");
77 $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn);
78 $this->by_object['mailogroup']->acl = "#all#";
79 $this->by_object['mailogroup']->parent= &$this;
80 }
81 }
82 }
84 /* Add Terminal tab */
85 if(((preg_match("/T/",$objects)) || (preg_match("/W/",$objects)))&&(!isset($this->by_object['termgroup']))){
86 require_once("class_termgroup.inc");
87 if(!isset($this->by_object['termgroup'])){
88 $this->by_name['termgroup']= _("System");
89 $this->by_object['termgroup']= new termgroup($this->config, $this->dn);
90 $this->by_object['termgroup']->acl = "#all#";
91 $this->by_object['termgroup']->inheritTimeServer = false;
92 $this->by_object['termgroup']->parent= &$this;
93 }
94 }
96 /* Add Workstation tabs */
97 if((preg_match("/W/",$objects))&&(!isset($this->by_object['workstartup']))){
98 if(!isset($this->by_object['workstartup'])){
99 $this->by_name['workstartup']= _("Startup");
100 $this->by_object['workstartup']= new workstartup($this->config, $this->dn);
101 $this->by_object['workstartup']->acl = "#all#";
102 $this->by_object['workstartup']->parent= &$this;
103 $this->by_name['workservice']= _("Devices");
104 $this->by_object['workservice']= new workservice($this->config, $this->dn);
105 $this->by_object['workservice']->acl = "#all#";
106 $this->by_object['workservice']->inheritTimeServer = false;
107 $this->by_object['workservice']->parent= &$this;
108 $this->by_name['faiSummary']= _("Summary");
109 $this->by_object['faiSummary']= new faiSummaryTab($this->config, $this->dn);
110 $this->by_object['faiSummary']->acl = "#all#";
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 }
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 = "";
139 $this->by_object['ogroup']->AddDelMembership();
140 $this->reload($this->by_object['ogroup']->gosaGroupObjects);
141 $str .= tabs::execute();
142 return ( $str);
143 }
145 function ogrouptabs($config, $data, $dn,$category ="")
146 {
148 tabs::tabs($config, $data, $dn, $category);
149 $this->base= $this->by_object['ogroup']->base;
150 $this->acl_category = $category;
152 /* Insert extra tabs for several object types - if present */
154 $objects= preg_replace('/[\[\]]/', '', $this->by_object['ogroup']->gosaGroupObjects);
156 for ($n= 0; $n<strlen($objects); $n++){
157 switch ($objects[$n]){
158 case "T":
159 /* Add a terminal tab */
160 require_once("class_termgroup.inc");
161 $this->by_name['termgroup']= _("Terminals");
162 $this->by_object['termgroup']= new termgroup($this->config, $this->dn);
163 $this->by_object['termgroup']->parent= &$this;
165 break;
167 case "U":
168 /* Append a PhoneQueue, if objectClass = goFonAccount */
169 $use = false;
170 foreach($this->by_object['ogroup']->memberList as $dn => $val){
171 if(isset($val['objectClass'])){
172 if(in_array("goFonAccount",$val['objectClass'])){
173 $use = true;
174 }
175 }
176 }
178 /* We found goFonAccount in users objectClasses*/
179 if($use){
180 require_once("class_phonequeue.inc");
181 $this->by_name['phonequeue']= _("Phone queue");
182 $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn);
183 $this->by_object['phonequeue']->parent= &$this;
185 }
187 /* Add a user tab used for mail distribution lists */
188 if(isset($this->config->current['MAILMETHOD'])){
189 if (preg_match('/kolab/i', $this->config->current['MAILMETHOD'])){
190 require_once("class_mailogroup.inc");
191 $this->by_name['mailogroup']= _("Mail");
192 $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn);
193 $this->by_object['mailogroup']->parent= &$this;
194 }
195 }
197 break;
198 }
199 }
201 /* Add references/acls/snapshots */
202 $this->addSpecialTabs();
203 }
206 function check()
207 {
208 return (tabs::check(FALSE));
209 }
212 function save_object($save_current= FALSE)
213 {
214 tabs::save_object($save_current);
216 /* Update reference, transfer variables */
217 $baseobject= $this->by_object['ogroup'];
218 foreach ($this->by_object as $name => $obj){
220 /* Don't touch base object */
221 if ($name != 'ogroup'){
222 $obj->parent = &$this;
223 $obj->uid = $baseobject->uid;
224 $obj->cn = $baseobject->cn;
225 $obj->sn = $baseobject->uid;
226 $obj->givenName = $baseobject->uid;
227 $this->by_object[$name]= $obj;
228 }
230 /* Update parent in base object */
231 $this->by_object['ogroup']->parent= &$this;
232 }
233 }
236 function save()
237 {
238 $baseobject= $this->by_object['ogroup'];
240 /* Check for new 'dn', in order to propagate the
241 'dn' to all plugins */
242 $new_dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base;
244 /* Move group? */
245 if ($this->dn != $new_dn){
247 /* Write entry on new 'dn' */
248 if ($this->dn != "new"){
249 $baseobject->move($this->dn, $new_dn);
250 $this->by_object['ogroup']= $baseobject;
251 }
253 /* Happen to use the new one */
254 $this->dn= $new_dn;
255 }
257 if ($this->dn == "new"){
258 $this->dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base;
259 }
261 tabs::save();
263 /* Fix tagging if needed */
264 $baseobject->dn= $new_dn;
265 $baseobject->handle_object_tagging();
266 }
268 }
270 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
271 ?>