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 }
50 /* Create goPhoneAccount if theres an user with goPhoneAccount
51 * but only if there is currently no queue enabled.
52 */
53 if(!isset($this->by_object['phonequeue'])){
54 foreach($this->by_object['ogroup']->memberList as $dn => $val){
55 if(isset($val['objectClass'])){
56 if(in_array("goFonAccount",$val['objectClass'])){
57 require_once("class_phonequeue.inc");
58 $this->by_name['phonequeue']= _("Phone queue");
59 $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn);
60 $this->by_object['phonequeue']->acl = "#all#";
61 $this->by_object['phonequeue']->parent= &$this;
62 }
63 }
64 }
65 }
67 /* Add mail group tab , if there is curerntly no mail tab defined */
68 if((preg_match("/U/",$objects))&&(!isset($this->by_object['mailogroup']))){
69 if(isset($this->config->current['MAILMETHOD'])){
70 if (preg_match('/kolab/i', $this->config->current['MAILMETHOD'])){
71 require_once("class_mailogroup.inc");
72 $this->by_name['mailogroup']= _("Mail");
73 $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn);
74 $this->by_object['mailogroup']->acl = "#all#";
75 $this->by_object['mailogroup']->parent= &$this;
76 }
77 }
78 }
80 /* Add Terminal tab */
81 if(((preg_match("/T/",$objects)) || (preg_match("/W/",$objects)))&&(!isset($this->by_object['termgroup']))){
82 require_once("class_termgroup.inc");
83 if(!isset($this->by_object['termgroup'])){
84 $this->by_name['termgroup']= _("System");
85 $this->by_object['termgroup']= new termgroup($this->config, $this->dn);
86 $this->by_object['termgroup']->acl = "#all#";
87 $this->by_object['termgroup']->inheritTimeServer = false;
88 $this->by_object['termgroup']->parent= &$this;
89 }
90 }
92 /* Add Workstation tabs */
93 if((preg_match("/W/",$objects))&&(!isset($this->by_object['workstartup']))){
94 if(!isset($this->by_object['workstartup'])){
95 $this->by_name['workstartup']= _("Startup");
96 $this->by_object['workstartup']= new workstartup($this->config, $this->dn);
97 $this->by_object['workstartup']->acl = "#all#";
98 $this->by_object['workstartup']->parent= &$this;
99 $this->by_name['workservice']= _("Devices");
100 $this->by_object['workservice']= new workservice($this->config, $this->dn);
101 $this->by_object['workservice']->acl = "#all#";
102 $this->by_object['workservice']->inheritTimeServer = false;
103 $this->by_object['workservice']->parent= &$this;
104 }
105 }
107 /* Move reference tab to last position*/
108 if(isset($this->by_name['reference'])){
109 $tmp = $this->by_name['reference'];
110 unset($this->by_name['reference']);
111 $this->by_name['reference'] = $tmp;
112 }
113 }
115 function execute(){
116 $str = "";
117 /* Call parent execute */
118 plugin::execute();
120 $this->by_object['ogroup']->AddDelMembership();
121 $this->reload($this->by_object['ogroup']->gosaGroupObjects);
122 $str .= tabs::execute();
123 return ( $str);
124 }
126 function ogrouptabs($config, $data, $dn)
127 {
129 tabs::tabs($config, $data, $dn);
130 $this->base= $this->by_object['ogroup']->base;
132 /* Insert extra tabs for several object types - if present */
134 $objects= preg_replace('/[\[\]]/', '', $this->by_object['ogroup']->gosaGroupObjects);
136 for ($n= 0; $n<strlen($objects); $n++){
137 switch ($objects[$n]){
138 case "T":
139 /* Add a terminal tab */
140 require_once("class_termgroup.inc");
141 $this->by_name['termgroup']= _("Terminals");
142 $this->by_object['termgroup']= new termgroup($this->config, $this->dn);
143 $this->by_object['termgroup']->parent= &$this;
145 break;
147 case "U":
148 /* Append a PhoneQueue, if objectClass = goFonAccount */
149 $use = false;
150 foreach($this->by_object['ogroup']->memberList as $dn => $val){
151 if(isset($val['objectClass'])){
152 if(in_array("goFonAccount",$val['objectClass'])){
153 $use = true;
154 }
155 }
156 }
158 /* We found goFonAccount in users objectClasses*/
159 if($use){
160 require_once("class_phonequeue.inc");
161 $this->by_name['phonequeue']= _("Phone queue");
162 $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn);
163 $this->by_object['phonequeue']->parent= &$this;
165 }
167 /* Add a user tab used for mail distribution lists */
168 if(isset($this->config->current['MAILMETHOD'])){
169 if (preg_match('/kolab/i', $this->config->current['MAILMETHOD'])){
170 require_once("class_mailogroup.inc");
171 $this->by_name['mailogroup']= _("Mail");
172 $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn);
173 $this->by_object['mailogroup']->parent= &$this;
174 }
175 }
177 break;
178 }
179 }
180 }
183 function check()
184 {
185 return (tabs::check(FALSE));
186 }
189 function save_object($save_current= FALSE)
190 {
191 tabs::save_object($save_current);
193 /* Update reference, transfer variables */
194 $baseobject= $this->by_object['ogroup'];
195 foreach ($this->by_object as $name => $obj){
197 /* Don't touch base object */
198 if ($name != 'ogroup'){
199 $obj->parent= &$this;
200 $obj->uid= $baseobject->uid;
201 $obj->sn= $baseobject->uid;
202 $obj->givenName= $baseobject->uid;
203 $this->by_object[$name]= $obj;
204 }
206 /* Update parent in base object */
207 $this->by_object['ogroup']->parent= &$this;
208 }
209 }
212 function save()
213 {
214 $baseobject= $this->by_object['ogroup'];
216 /* Check for new 'dn', in order to propagate the
217 'dn' to all plugins */
218 $new_dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base;
220 /* Move group? */
221 if ($this->dn != $new_dn){
223 /* Write entry on new 'dn' */
224 if ($this->dn != "new"){
225 $baseobject->move($this->dn, $new_dn);
226 $this->by_object['ogroup']= $baseobject;
227 }
229 /* Happen to use the new one */
230 $this->dn= $new_dn;
231 }
233 if ($this->dn == "new"){
234 $this->dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base;
235 }
237 tabs::save();
239 /* Fix tagging if needed */
240 $baseobject->handle_object_tagging();
241 }
243 }
245 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
246 ?>