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 = "";
125 $this->by_object['ogroup']->AddDelMembership();
126 $this->reload($this->by_object['ogroup']->gosaGroupObjects);
127 $str .= tabs::execute();
128 return ( $str);
129 }
131 function ogrouptabs($config, $data, $dn)
132 {
134 tabs::tabs($config, $data, $dn);
135 $this->base= $this->by_object['ogroup']->base;
137 /* Insert extra tabs for several object types - if present */
139 $objects= preg_replace('/[\[\]]/', '', $this->by_object['ogroup']->gosaGroupObjects);
141 for ($n= 0; $n<strlen($objects); $n++){
142 switch ($objects[$n]){
143 case "T":
144 /* Add a terminal tab */
145 require_once("class_termgroup.inc");
146 $this->by_name['termgroup']= _("Terminals");
147 $this->by_object['termgroup']= new termgroup($this->config, $this->dn);
148 $this->by_object['termgroup']->parent= &$this;
150 break;
152 case "U":
153 /* Append a PhoneQueue, if objectClass = goFonAccount */
154 $use = false;
155 foreach($this->by_object['ogroup']->memberList as $dn => $val){
156 if(isset($val['objectClass'])){
157 if(in_array("goFonAccount",$val['objectClass'])){
158 $use = true;
159 }
160 }
161 }
163 /* We found goFonAccount in users objectClasses*/
164 if($use){
165 require_once("class_phonequeue.inc");
166 $this->by_name['phonequeue']= _("Phone queue");
167 $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn);
168 $this->by_object['phonequeue']->parent= &$this;
170 }
172 /* Add a user tab used for mail distribution lists */
173 if(isset($this->config->current['MAILMETHOD'])){
174 if (preg_match('/kolab/i', $this->config->current['MAILMETHOD'])){
175 require_once("class_mailogroup.inc");
176 $this->by_name['mailogroup']= _("Mail");
177 $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn);
178 $this->by_object['mailogroup']->parent= &$this;
179 }
180 }
182 break;
183 }
184 }
186 /* Add references/acls/snapshots */
187 $this->addSpecialTabs();
188 }
191 function check()
192 {
193 return (tabs::check(FALSE));
194 }
197 function save_object($save_current= FALSE)
198 {
199 tabs::save_object($save_current);
201 /* Update reference, transfer variables */
202 $baseobject= $this->by_object['ogroup'];
203 foreach ($this->by_object as $name => $obj){
205 /* Don't touch base object */
206 if ($name != 'ogroup'){
207 $obj->parent= &$this;
208 $obj->uid= $baseobject->uid;
209 $obj->sn= $baseobject->uid;
210 $obj->givenName= $baseobject->uid;
211 $this->by_object[$name]= $obj;
212 }
214 /* Update parent in base object */
215 $this->by_object['ogroup']->parent= &$this;
216 }
217 }
220 function save()
221 {
222 $baseobject= $this->by_object['ogroup'];
224 /* Check for new 'dn', in order to propagate the
225 'dn' to all plugins */
226 $new_dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base;
228 /* Move group? */
229 if ($this->dn != $new_dn){
231 /* Write entry on new 'dn' */
232 if ($this->dn != "new"){
233 $baseobject->move($this->dn, $new_dn);
234 $this->by_object['ogroup']= $baseobject;
235 }
237 /* Happen to use the new one */
238 $this->dn= $new_dn;
239 }
241 if ($this->dn == "new"){
242 $this->dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base;
243 }
245 tabs::save();
247 /* Fix tagging if needed */
248 $baseobject->dn= $new_dn;
249 $baseobject->handle_object_tagging();
250 }
252 }
254 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
255 ?>