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 last position*/
116 if(isset($this->by_name['reference'])){
117 $tmp = $this->by_name['reference'];
118 unset($this->by_name['reference']);
119 $this->by_name['reference'] = $tmp;
120 }
122 /* Reset acls */
123 $this->set_acl_base($this->base);
124 foreach($this->by_object as $name => $obj){
125 $this->by_object[$name]->set_acl_category($this->acl_category);
126 }
127 }
129 function execute(){
130 $str = "";
132 $this->by_object['ogroup']->AddDelMembership();
133 $this->reload($this->by_object['ogroup']->gosaGroupObjects);
134 $str .= tabs::execute();
135 return ( $str);
136 }
138 function ogrouptabs($config, $data, $dn,$category ="")
139 {
141 tabs::tabs($config, $data, $dn, $category);
142 $this->base= $this->by_object['ogroup']->base;
143 $this->acl_category = $category;
145 /* Insert extra tabs for several object types - if present */
147 $objects= preg_replace('/[\[\]]/', '', $this->by_object['ogroup']->gosaGroupObjects);
149 for ($n= 0; $n<strlen($objects); $n++){
150 switch ($objects[$n]){
151 case "T":
152 /* Add a terminal tab */
153 require_once("class_termgroup.inc");
154 $this->by_name['termgroup']= _("Terminals");
155 $this->by_object['termgroup']= new termgroup($this->config, $this->dn);
156 $this->by_object['termgroup']->parent= &$this;
158 break;
160 case "U":
161 /* Append a PhoneQueue, if objectClass = goFonAccount */
162 $use = false;
163 foreach($this->by_object['ogroup']->memberList as $dn => $val){
164 if(isset($val['objectClass'])){
165 if(in_array("goFonAccount",$val['objectClass'])){
166 $use = true;
167 }
168 }
169 }
171 /* We found goFonAccount in users objectClasses*/
172 if($use){
173 require_once("class_phonequeue.inc");
174 $this->by_name['phonequeue']= _("Phone queue");
175 $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn);
176 $this->by_object['phonequeue']->parent= &$this;
178 }
180 /* Add a user tab used for mail distribution lists */
181 if(isset($this->config->current['MAILMETHOD'])){
182 if (preg_match('/kolab/i', $this->config->current['MAILMETHOD'])){
183 require_once("class_mailogroup.inc");
184 $this->by_name['mailogroup']= _("Mail");
185 $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn);
186 $this->by_object['mailogroup']->parent= &$this;
187 }
188 }
190 break;
191 }
192 }
194 /* Add references/acls/snapshots */
195 $this->addSpecialTabs();
196 }
199 function check()
200 {
201 return (tabs::check(FALSE));
202 }
205 function save_object($save_current= FALSE)
206 {
207 tabs::save_object($save_current);
209 /* Update reference, transfer variables */
210 $baseobject= $this->by_object['ogroup'];
211 foreach ($this->by_object as $name => $obj){
213 /* Don't touch base object */
214 if ($name != 'ogroup'){
215 $obj->parent= &$this;
216 $obj->uid= $baseobject->uid;
217 $obj->sn= $baseobject->uid;
218 $obj->givenName= $baseobject->uid;
219 $this->by_object[$name]= $obj;
220 }
222 /* Update parent in base object */
223 $this->by_object['ogroup']->parent= &$this;
224 }
225 }
228 function save()
229 {
230 $baseobject= $this->by_object['ogroup'];
232 /* Check for new 'dn', in order to propagate the
233 'dn' to all plugins */
234 $new_dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base;
236 /* Move group? */
237 if ($this->dn != $new_dn){
239 /* Write entry on new 'dn' */
240 if ($this->dn != "new"){
241 $baseobject->move($this->dn, $new_dn);
242 $this->by_object['ogroup']= $baseobject;
243 }
245 /* Happen to use the new one */
246 $this->dn= $new_dn;
247 }
249 if ($this->dn == "new"){
250 $this->dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base;
251 }
253 tabs::save();
255 /* Fix tagging if needed */
256 $baseobject->dn= $new_dn;
257 $baseobject->handle_object_tagging();
258 }
260 }
262 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
263 ?>