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 }
27 /* Remove mail group if there is no user anymore */
28 if((!preg_match("/U/",$objects))&&(isset($this->by_object['mailgroup']))){
29 $this->by_object['mailgroup']->remove_from_parent();
30 unset($this->by_object['mailgroup']);
31 unset($this->by_name['mailgroup']);
32 }
34 /* Remove terminal group, if theres no terminal left in the object list */
35 if((!preg_match("/T/",$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 }
51 /* Create goPhoneAccount if theres an user with goPhoneAccount
52 * but only if there is currently no queue enabled.
53 */
54 if(!isset($this->by_object['phonequeue'])){
55 foreach($this->by_object['ogroup']->memberList as $dn => $val){
56 if(isset($val['objectClass'])){
57 if(in_array("goFonAccount",$val['objectClass'])){
58 require_once("class_phonequeue.inc");
59 $this->by_name['phonequeue']= _("Phone queue");
60 $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn);
61 $this->by_object['phonequeue']->acl = "#all#";
62 $this->by_object['phonequeue']->parent= &$this;
63 }
64 }
65 }
66 }
68 /* Add mail group tab , if there is curerntly no mail tab defined */
69 if((preg_match("/U/",$objects))&&(!isset($this->by_object['mailogroup']))){
70 if(isset($this->config->current['MAILMETHOD'])){
71 if (preg_match('/kolab/i', $this->config->current['MAILMETHOD'])){
72 require_once("class_mailogroup.inc");
73 $this->by_name['mailogroup']= _("Mail");
74 $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn);
75 $this->by_object['mailogroup']->parent= &$this;
76 }
77 }
78 }
80 /* Add Terminal tab */
81 if((preg_match("/T/",$objects))&&(!isset($this->by_object['termgroup']))){
82 require_once("class_termgroup.inc");
83 if(!isset($this->by_object['termgroup'])){
84 $this->by_name['termgroup']= _("Terminals");
85 $this->by_object['termgroup']= new termgroup($this->config, $this->dn);
86 $this->by_object['termgroup']->parent= &$this;
87 }
88 }
90 /* Add Workstation tabs */
91 if((preg_match("/W/",$objects))&&(!isset($this->by_object['workstartup']))){
92 if(!isset($this->by_object['workstartup'])){
93 $this->by_name['workstartup']= _("Startup");
94 $this->by_object['workstartup']= new workstartup($this->config, $this->dn);
95 $this->by_object['workstartup']->acl = "#all#";
96 $this->by_object['workstartup']->parent= &$this;
97 $this->by_name['workservice']= _("Devices");
98 $this->by_object['workservice']= new workservice($this->config, $this->dn);
99 $this->by_object['workservice']->acl = "#all#";
100 $this->by_object['workservice']->parent= &$this;
101 }
102 }
103 }
105 function execute(){
106 $str = "";
107 /* Call parent execute */
108 plugin::execute();
110 $this->by_object['ogroup']->AddDelMembership();
111 $this->reload($this->by_object['ogroup']->gosaGroupObjects);
112 $str .= tabs::execute();
113 return ( $str);
114 }
116 function ogrouptabs($config, $data, $dn)
117 {
119 tabs::tabs($config, $data, $dn);
120 $this->base= $this->by_object['ogroup']->base;
122 /* Insert extra tabs for several object types - if present */
124 $objects= preg_replace('/[\[\]]/', '', $this->by_object['ogroup']->gosaGroupObjects);
126 for ($n= 0; $n<strlen($objects); $n++){
127 switch ($objects[$n]){
128 case "T":
129 /* Add a terminal tab */
130 require_once("class_termgroup.inc");
131 $this->by_name['termgroup']= _("Terminals");
132 $this->by_object['termgroup']= new termgroup($this->config, $this->dn);
133 $this->by_object['termgroup']->parent= &$this;
135 break;
137 case "U":
138 /* Append a PhoneQueue, if objectClass = goFonAccount */
139 $use = false;
140 foreach($this->by_object['ogroup']->memberList as $dn => $val){
141 if(isset($val['objectClass'])){
142 if(in_array("goFonAccount",$val['objectClass'])){
143 $use = true;
144 }
145 }
146 }
148 /* We found goFonAccount in users objectClasses*/
149 if($use){
150 require_once("class_phonequeue.inc");
151 $this->by_name['phonequeue']= _("Phone queue");
152 $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn);
153 $this->by_object['phonequeue']->parent= &$this;
155 }
157 /* Add a user tab used for mail distribution lists */
158 if(isset($this->config->current['MAILMETHOD'])){
159 if (preg_match('/kolab/i', $this->config->current['MAILMETHOD'])){
160 require_once("class_mailogroup.inc");
161 $this->by_name['mailogroup']= _("Mail");
162 $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn);
163 $this->by_object['mailogroup']->parent= &$this;
164 }
165 }
167 break;
168 }
169 }
170 }
173 function check()
174 {
175 return (tabs::check(FALSE));
176 }
179 function save_object($save_current= FALSE)
180 {
181 tabs::save_object($save_current);
183 /* Update reference, transfer variables */
184 $baseobject= $this->by_object['ogroup'];
185 foreach ($this->by_object as $name => $obj){
187 /* Don't touch base object */
188 if ($name != 'ogroup'){
189 $obj->parent= &$this;
190 $obj->uid= $baseobject->uid;
191 $obj->sn= $baseobject->uid;
192 $obj->givenName= $baseobject->uid;
193 $this->by_object[$name]= $obj;
194 }
196 /* Update parent in base object */
197 $this->by_object['ogroup']->parent= &$this;
198 }
199 }
202 function save()
203 {
204 $baseobject= $this->by_object['ogroup'];
206 /* Check for new 'dn', in order to propagate the
207 'dn' to all plugins */
208 $new_dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base;
210 /* Move group? */
211 if ($this->dn != $new_dn){
213 /* Write entry on new 'dn' */
214 if ($this->dn != "new"){
215 $baseobject->move($this->dn, $new_dn);
216 $this->by_object['ogroup']= $baseobject;
217 }
219 /* Happen to use the new one */
220 $this->dn= $new_dn;
221 }
223 if ($this->dn == "new"){
224 $this->dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base;
225 }
227 tabs::save();
228 }
230 }
232 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
233 ?>