1 <?php
3 class ogrouptabs extends tabs
4 {
5 var $base= "";
7 function reload($dd){
8 $objects= preg_replace('/[\[\]]/', '', $dd);
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 }
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 }
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 }
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 }
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 }
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 $this->by_object['ogroup']->AddDelMembership();
125 $this->reload($this->by_object['ogroup']->gosaGroupObjects);
126 $str .= tabs::execute();
127 return ( $str);
128 }
130 function ogrouptabs($config, $data, $dn)
131 {
133 tabs::tabs($config, $data, $dn);
134 $this->base= $this->by_object['ogroup']->base;
136 /* Insert extra tabs for several object types - if present */
138 $objects= preg_replace('/[\[\]]/', '', $this->by_object['ogroup']->gosaGroupObjects);
140 for ($n= 0; $n<strlen($objects); $n++){
141 switch ($objects[$n]){
142 case "T":
143 /* Add a terminal tab */
144 require_once("class_termgroup.inc");
145 $this->by_name['termgroup']= _("Terminals");
146 $this->by_object['termgroup']= new termgroup($this->config, $this->dn);
147 $this->by_object['termgroup']->parent= &$this;
149 break;
151 case "U":
152 /* Append a PhoneQueue, if objectClass = goFonAccount */
153 $use = false;
154 foreach($this->by_object['ogroup']->memberList as $dn => $val){
155 if(isset($val['objectClass'])){
156 if(in_array("goFonAccount",$val['objectClass'])){
157 $use = true;
158 }
159 }
160 }
162 /* We found goFonAccount in users objectClasses*/
163 if($use){
164 require_once("class_phonequeue.inc");
165 $this->by_name['phonequeue']= _("Phone queue");
166 $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn);
167 $this->by_object['phonequeue']->parent= &$this;
169 }
171 /* Add a user tab used for mail distribution lists */
172 if(isset($this->config->current['MAILMETHOD'])){
173 if (preg_match('/kolab/i', $this->config->current['MAILMETHOD'])){
174 require_once("class_mailogroup.inc");
175 $this->by_name['mailogroup']= _("Mail");
176 $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn);
177 $this->by_object['mailogroup']->parent= &$this;
178 }
179 }
181 break;
182 }
183 }
184 }
187 function check()
188 {
189 return (tabs::check(FALSE));
190 }
193 function save_object($save_current= FALSE)
194 {
195 tabs::save_object($save_current);
197 /* Update reference, transfer variables */
198 $baseobject= $this->by_object['ogroup'];
199 foreach ($this->by_object as $name => $obj){
201 /* Don't touch base object */
202 if ($name != 'ogroup'){
203 $obj->parent= &$this;
204 $obj->uid= $baseobject->uid;
205 $obj->sn= $baseobject->uid;
206 $obj->givenName= $baseobject->uid;
207 $this->by_object[$name]= $obj;
208 }
210 /* Update parent in base object */
211 $this->by_object['ogroup']->parent= &$this;
212 }
213 }
216 function save()
217 {
218 $baseobject= $this->by_object['ogroup'];
220 /* Check for new 'dn', in order to propagate the
221 'dn' to all plugins */
222 $new_dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base;
224 /* Move group? */
225 if ($this->dn != $new_dn){
227 /* Write entry on new 'dn' */
228 if ($this->dn != "new"){
229 $baseobject->move($this->dn, $new_dn);
230 $this->by_object['ogroup']= $baseobject;
231 }
233 /* Happen to use the new one */
234 $this->dn= $new_dn;
235 }
237 if ($this->dn == "new"){
238 $this->dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base;
239 }
241 tabs::save();
243 /* Fix tagging if needed */
244 $baseobject->dn= $new_dn;
245 $baseobject->handle_object_tagging();
246 }
248 }
250 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
251 ?>