1 <?php
2 /*
3 This code is part of GOsa (https://gosa.gonicus.de)
4 Copyright (C) 2003 Cajus Pollmeier
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20 require "tabs_group.inc";
22 class groupManagement extends plugin
23 {
24 /* Definitions */
25 var $plHeadline= "Groups";
26 var $plDescription= "This does something";
27 var $departments = array();
29 /* Dialog attributes */
30 var $grouptab= NULL;
31 var $grouplist= array();
32 var $ui= NULL;
33 var $acl= "";
35 var $CopyPasteHandler = NULL;
37 function groupManagement ($config, $ui)
38 {
39 /* Save configuration for internal use */
40 $this->config= $config;
41 $this->ui= $ui;
43 if((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE']))){
44 $this->CopyPasteHandler = new CopyPasteHandler($this->config);
45 }
47 /* Get global filter config */
48 if (!is_global("groupfilter")){
49 $base= get_base_from_people($ui->dn);
50 $groupfilter= array("primarygroups" => "checked",
51 "mailgroups" => "checked",
52 "sambagroups" => "checked",
53 "appgroups" => "checked",
54 "functionalgroups" => "checked",
55 "guser" => "*",
56 "subsearch" => "",
57 "regex" => "*");
58 register_global("groupfilter", $groupfilter);
59 }
60 if(!isset($_SESSION['CurrentMainBase'])){
61 $base = get_base_from_people($ui->dn);
62 $_SESSION['CurrentMainBase'] = $base;
63 }
64 }
66 function execute()
67 {
68 /* Call parent execute */
69 plugin::execute();
71 $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^group_edit_/","/^group_del_/");
73 /* Save data */
74 $groupfilter= get_global("groupfilter");
75 $s_action = "";
76 $s_entry = "";
78 if (!isset($this->grouptab)){
79 foreach( array( "guser", "regex") as $type){
80 if (isset($_POST[$type])){
81 $groupfilter[$type]= $_POST[$type];
82 }
83 }
84 if(isset($_POST['CurrentMainBase'])){
85 $_SESSION['CurrentMainBase'] = $_POST['CurrentMainBase'];
86 }
87 if (isset($_POST['regex'])){
88 foreach( array("primarygroups", "sambagroups", "mailgroups", "appgroups",
89 "functionalgroups", "subsearch") as $type){
91 if (isset($_POST[$type])) {
92 $groupfilter[$type]= "checked";
93 } else {
94 $groupfilter[$type]= "";
95 }
96 }
97 }
98 if (isset($_GET['search'])){
99 $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
100 if ($s == "**"){
101 $s= "*";
102 }
103 $groupfilter['regex']= $s;
104 }
105 register_global("groupfilter", $groupfilter);
106 }
109 /* Test Posts */
110 foreach($_POST as $key => $val){
111 // Post for delete
112 if(preg_match("/^group_del.*/",$key)){
113 $s_action = "del";
114 $s_entry = preg_replace("/group_".$s_action."_/i","",$key);
115 // Post for edit
116 }elseif(preg_match("/^group_edit_.*/",$key)){
117 $s_action="edit";
118 $s_entry = preg_replace("/group_".$s_action."_/i","",$key);
119 // Post for new
120 }elseif(preg_match("/^dep_back.*/i",$key)){
121 $s_action="back";
122 }elseif(preg_match("/^group_new.*/",$key)){
123 $s_action="new";
124 }elseif(preg_match("/^dep_home.*/i",$key)){
125 $s_action="home";
126 }elseif(preg_match("/^group_tplnew.*/i",$key)){
127 $s_action="new_tpl";
128 }elseif(preg_match("/^group_chgpw.*/i",$key)){
129 $s_action="change_pw";
130 $s_entry = preg_replace("/group_chgpw_/i","",$key);
131 }elseif(preg_match("/^dep_root.*/i",$key)){
132 $s_action="root";
133 }elseif(preg_match("/_group_edit_/",$key)){
134 $type = preg_replace("/_group_edit_.*$/","",$key);
135 $s_action="edit";
136 $s_entry = preg_replace("/".$type."_group_edit_/i","",$key);
137 $_POST['arg'] = $type;
138 }elseif(preg_match("/^editPaste.*/i",$key)){
139 $s_action="editPaste";
140 }elseif(preg_match("/^copy_.*/",$key)){
141 $s_action="copy";
142 $s_entry = preg_replace("/^copy_/i","",$key);
143 }elseif(preg_match("/^cut_.*/",$key)){
144 $s_action="cut";
145 $s_entry = preg_replace("/^cut_/i","",$key);
146 }
147 }
148 $s_entry = preg_replace("/_.$/","",$s_entry);
150 /* Start for New List Managment */
151 if(isset($_GET['act'])&&($_GET['act']=="dep_open")){
152 $s_action="open";
153 $s_entry = base64_decode($_GET['dep_id']);
154 $_SESSION['CurrentMainBase']= "".$this->config->departments[trim($s_entry)];
155 }
157 // Edit if
158 if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
159 $s_action ="edit";
160 $s_entry = $_GET['id'];
161 }
163 /* Department changed? */
164 if(isset($_POST['CurrentMainBase']) && $_POST['CurrentMainBase']){
165 $_SESSION['CurrentMainBase']= $_POST['CurrentMainBase'];
166 }
168 /* Homebutton is posted */
169 if($s_action=="home"){
170 //FIXME: This will not work if we've no subdirs (like i.e. ou=people)? See
171 // class_userManagement.inc for a fix.
172 $_SESSION['CurrentMainBase']= (preg_replace("/^[^,]+,/","",$this->ui->dn));
173 $_SESSION['CurrentMainBase']= (preg_replace("/^[^,]+,/","",$_SESSION['CurrentMainBase']));
174 }
176 if($s_action=="root"){
177 $_SESSION['CurrentMainBase']=($this->config->current['BASE']);
178 }
180 /* If Backbutton is Posted */
181 if($s_action == "back"){
182 $base_back= preg_replace("/^[^,]+,/","",$_SESSION['CurrentMainBase']);
183 $base_back= convert_department_dn($base_back);
185 if(isset($this->config->departments[trim($base_back)])){
186 $_SESSION['CurrentMainBase']= $this->config->departments[trim($base_back)];
187 }else{
188 $_SESSION['CurrentMainBase']= $this->config->departments["/"];
189 }
190 }
191 register_global("groupfilter", $groupfilter);
193 $smarty= get_smarty();
195 /* Prepare formular */
196 $this->reload();
198 /* Check for exeeded sizelimit */
199 if (($message= check_sizelimit()) != ""){
200 return($message);
201 }
203 /* Only perform copy&paste requests if it is enabled
204 */
205 if($this->CopyPasteHandler){
206 if($str = $this->copyPasteHandling($s_action,$s_entry)){
207 return $str;
208 }
209 }
211 /* New group? */
212 if ($s_action=="new"){
214 /* By default we set 'dn' to 'new', all relevant plugins will
215 react on this. */
216 $this->dn= "new";
218 /* Create new usertab object */
219 $this->grouptab= new grouptabs($this->config,
220 $this->config->data['TABS']['GROUPTABS'], $this->dn);
221 /* Set up the users ACL's for this 'dn' */
222 $acl= get_permissions ($_SESSION['CurrentMainBase'], $this->ui->subtreeACL);
223 $this->grouptab->set_acl($acl);
224 }
226 /* Cancel dialogs */
227 if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){
228 del_lock ($this->grouptab->dn);
229 unset ($this->grouptab);
230 $this->grouptab= NULL;
231 unset($_SESSION['objectinfo']);
232 }
234 /* Finish group edit is triggered by the tabulator dialog, so
235 the user wants to save edited data. Check and save at this
236 point. */
237 if ((isset($_POST['edit_finish'])) && (isset($this->grouptab->config)) ){
239 /* Check tabs, will feed message array */
240 $message= $this->grouptab->check();
242 /* Save, or display error message? */
243 if (count($message) == 0){
245 /* Save user data to ldap */
246 $this->grouptab->save();
247 gosa_log ("Group object'".$this->dn."' has been saved");
249 /* Group has been saved successfully, remove lock from
250 LDAP. */
251 if ($this->dn != "new"){
252 del_lock ($this->dn);
253 }
255 /* There's no page reload so we have to read new users at
256 this point. */
257 $this->reload ();
258 unset ($this->grouptab);
259 $this->grouptab= NULL;
260 unset ($_SESSION['objectinfo']);
262 } else {
263 /* Ok. There seem to be errors regarding to the tab data,
264 show message and continue as usual. */
265 show_errors($message);
266 }
267 }
269 /* User wants to edit data? */
270 if (($s_action=="edit") && (!isset($this->grouptab-> config))){
272 /* Get 'dn' from posted 'uid', must be unique */
273 $this->dn= $this->grouplist[trim($s_entry)]['dn'];
275 /* Check locking, save current plugin in 'back_plugin', so
276 the dialog knows where to return. */
278 $user = get_lock($this->dn);
280 if ($user != ""){
281 return(gen_locked_message ($user, $this->dn));
282 }
284 /* Lock the current entry, so everyone will get the
285 above dialog */
286 add_lock ($this->dn, $this->ui->dn);
288 /* Set up the users ACL's for this 'dn' */
289 $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
291 /* Register grouptab to trigger edit dialog */
292 $this->grouptab= new grouptabs($this->config,
293 $this->config->data['TABS']['GROUPTABS'], $this->dn);
294 $this->grouptab->set_acl($acl);
295 $_SESSION['objectinfo']= $this->dn;
296 }
298 /* Remove user was requested */
299 if ($s_action=="del"){
300 /* Get 'dn' from posted 'uid' */
301 $this->dn= $this->grouplist[trim($s_entry)]['dn'];
303 /* Load permissions for selected 'dn' and check if
304 we're allowed to remove this 'dn' */
305 $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
306 $this->acl= get_module_permission($acl, "group", $this->dn);
307 if (chkacl($this->acl, "delete") == ""){
309 /* Check locking, save current plugin in 'back_plugin', so
310 the dialog knows where to return. */
311 if (($user= get_lock($this->dn)) != ""){
312 return(gen_locked_message ($user, $this->dn));
313 }
315 /* Lock the current entry, so nobody will edit it during deletion */
316 add_lock ($this->dn, $this->ui->dn);
317 $smarty->assign("info", sprintf(_("You're about to delete the group '%s'."), @LDAP::fix($this->dn)));
318 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
319 } else {
321 /* Obviously the user isn't allowed to delete. Show message and
322 clean session. */
323 print_red (_("You are not allowed to delete this group!"));
324 }
325 }
327 /* Confirmation for deletion has been passed. Group should be deleted. */
328 if (isset($_POST['delete_group_confirm'])){
330 /* Some nice guy may send this as POST, so we've to check
331 for the permissions again. */
332 if (chkacl($this->acl, "delete") == ""){
334 /* Delete request is permitted, perform LDAP action */
335 $this->grouptab= new grouptabs($this->config,
336 $this->config->data['TABS']['GROUPTABS'], $this->dn);
337 $this->grouptab->set_acl(array($this->acl));
338 $this->grouptab->delete ();
339 gosa_log ("Group object'".$this->dn."' has been removed");
340 unset ($this->grouptab);
341 $this->grouptab= NULL;
343 /* Group list has changed, reload it. */
344 $this->reload ();
345 } else {
347 /* Normally this shouldn't be reached, send some extra
348 logs to notify the administrator */
349 print_red (_("You are not allowed to delete this group!"));
350 gosa_log ("Warning: '".$this->ui->uid."' tried to trick group deletion.");
351 }
353 /* Remove lock file after successfull deletion */
354 del_lock ($this->dn);
355 unset($_SESSION['objectinfo']);
356 }
359 /* Delete group canceled? */
360 if (isset($_POST['delete_cancel'])){
361 del_lock ($this->dn);
362 unset($_SESSION['objectinfo']);
363 }
365 /* Show tab dialog if object is present */
366 if (isset($this->grouptab->config)){
367 $display= $this->grouptab->execute();
369 /* Don't show buttons if tab dialog requests this */
370 if (!$this->grouptab->by_object[$this->grouptab->current]->dialog){
371 $display.= "<p style=\"text-align:right\">\n";
372 $display.= "<input type=submit name=\"edit_finish\" value=\""._("Save")."\">\n";
373 $display.= " \n";
374 $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
375 $display.= "</p>";
376 }
377 return ($display);
378 }
380 /* Prepare departments */
381 $options= "";
382 foreach ($this->config->idepartments as $key => $value){
383 if ($_SESSION['CurrentMainBase'] == $key){
384 $options.= "<option selected value='$key'>$value</option>";
385 } else {
386 $options.= "<option value='$key'>$value</option>";
387 }
388 }
390 /* Create paste icon
391 */
392 if($this->CopyPasteHandler){
393 $Copy_Paste = " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ";
394 if($this->CopyPasteHandler->isCurrentObjectPastAble()){
395 if($this->CopyPasteHandler->isCurrentCutted()){
396 $img = "images/cutpaste.png";
397 }else{
398 $img = "images/copypaste.png";
399 }
400 $Copy_Paste .= "<input type='image' name='editPaste' class='center'
401 src='".$img."' alt='"._("Paste")."' title='".$this->CopyPasteHandler->GetCurrentDn()."'> ";
402 }else{
403 $Copy_Paste .= "<img class='center' src='images/cant_editpaste.png' alt='"._("Can't paste")."'> ";
404 }
405 }else{
406 $Copy_Paste ="";
407 }
409 // Managment
410 $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
411 " <input type='image' class='center' src='images/list_root.png' title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'> ".
412 " <input type='image' class='center' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'> ".
413 " <input type='image' class='center' src='images/list_home.png' title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'> ".
414 " <input class='center' type='image' src='images/list_reload.png' align='middle' title='"._("Reload list")."' name='submit_department' alt='"._("Submit")."'> ".
415 " <img class='center' src='images/list_seperator.png' alt='' height='16' width='1'> ".
416 " <input type='image' class='center' src='images/list_new_group.png' title='"._("Create new group")."' alt='"._("New")."' name='group_new'> ".
417 $Copy_Paste.
418 " <img class='center' src='images/list_seperator.png' alt='' height='16' width='1'> ".
419 _("Base")." <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
420 " <input type='image' class='center' src='images/list_submit.png' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> ".
421 "</div>";
424 if($this->CopyPasteHandler){
425 $actions = "<input class='center' type='image'
426 src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'> ";
427 $actions.= "<input class='center' type='image'
428 src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'> ";
429 $actions.= "<input class='center' type='image'
430 src='images/edit.png' alt='"._("edit")."' name='group_edit_%KEY%' title='"._("Edit this entry")."'>";
431 $actions.= "<input class='center' type='image'
432 src='images/edittrash.png' alt='"._("delete")."' name='group_del_%KEY%' title='"._("Delete this entry")."'>";
433 }else{
434 $actions = "<input class='center' type='image'
435 src='images/edit.png' alt='"._("edit")."' name='group_edit_%KEY%' title='"._("Edit this entry")."'>";
436 $actions.= "<input class='center' type='image'
437 src='images/edittrash.png' alt='"._("delete")."' name='group_del_%KEY%' title='"._("Delete this entry")."'>";
438 }
441 // Defining Links
442 $linkopen = "<a href='?plug=".$_GET['plug']."&act=dep_open&dep_id=%s'>%s</a>";
444 // image Buttons
445 $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
446 $userimg = "<img class='center' src='images/select_groups.png' alt='User' title='%s'>";
448 /* Assign extension images */
449 $posiximg = "<input type='image' class='center' src='images/select_groups.png'
450 name='group_group_edit_%KEY%'
451 alt='P' title='"._("Posix") ."'>";
452 $mailimg = "<input type='image' class='center' src='images/mailto.png'
453 name='mailgroup_group_edit_%KEY%'
454 alt='M' title='"._("Mail") ."'>";
455 $sambaimg = "<input type='image' class='center' src='images/select_winstation.png'
456 name='group_group_edit_%KEY%'
457 alt='S' title='"._("Samba") ."'>";
458 $applimg = "<input type='image' class='center' src='images/select_application.png'
459 name='appgroup_group_edit_%KEY%'
460 alt='A' title='"._("Application")."'>";
461 $phoneimg = "<input type='image' class='center' src='images/select_phone.png'
462 name='group_group_edit_%KEY%'
463 alt='Ph' title='"._("Phone") ."'>";
464 $envimg = "<input type='image' class='center' src='images/smallenv.png'
465 name='environment_group_edit_%KEY%'
466 alt='E' title='"._("Environment") ."'>";
468 // Space
469 $empty = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt=''>";
471 $divlist = new divlist("groupstab");
472 $divlist->SetHeader(array(
473 array("string" => " ", "attach" => "style='text-align:center;width:20px;'"),
474 array("string" => _("Groupname")." / "._("Department"), "attach" => "style=''"),
475 array("string" => _("Properties"), "attach" => "style='width:136px;'"),
476 array("string" => _("Actions"), "attach" => "style='width:80px;border-right:0px;text-align:right;'")
477 ));
479 $divlist->SetSummary(_("This table displays all groups, in the selected tree."));
480 $divlist->SetEntriesPerPage(0);
482 foreach($this->departments as $key=> $val){
484 if(!isset($this->config->departments[trim($key)])){
485 $this->config->departments[trim($key)]="";
486 }
488 $non_empty="";
489 $keys= str_replace("/","\/",$key);
490 foreach($this->config->departments as $keyd=>$vald ){
491 if(preg_match("/".$keys."\/.*/",$keyd)){
492 $non_empty="full";
493 }
494 }
497 $field1 = array("string" => "<img src='images/".$non_empty."folder.png' alt='department'>", "attach" => "style='text-align:center;width:20px;'");
498 $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style=''");
499 $field3 = array("string" => " ", "attach" => "style='width:136px;'");
500 $field4 = array("string" => " ", "attach" => "style='width:80px;border-right:0px;text-align:right;'");
502 $divlist->AddEntry(array($field1,$field2,$field3,$field4));
503 }
505 foreach($this->grouplist as $key => $val){
507 $posix=$mail=$samba=$appl=$phone=$enviro=$empty;
509 if(isset($val['objectClass'])){
510 if(in_array("posixGroup", $val['objectClass'])) $posix = $posiximg;
511 if(in_array("gosaMailAccount", $val['objectClass'])) $mail = $mailimg;
512 if(in_array("sambaGroupMapping", $val['objectClass'])) $samba = $sambaimg;
513 if(in_array("gosaApplicationGroup", $val['objectClass'])) $appl = $applimg;
514 if(in_array("goFonPickupGroup", $val['objectClass'])) $phone = $phoneimg;
515 if(in_array("gotoEnvironment", $val['objectClass'])) $enviro= $envimg;
516 }
518 $title = "title='dn: ".@LDAP::fix($val['dn'])."'";
520 if(!isset($val['description'][0])){
521 $desc = "";
522 }else{
523 $desc = " - [ ".$val['description'][0]." ]";
524 }
526 /* FAIrelease tag from groupApplications */
527 if(isset($val['FAIrelease'][0])){
528 $desc .= " (".$val['FAIrelease'][0].")";
529 }
531 $field1 = array("string" => sprintf($userimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
532 $field2 = array("string" => sprintf($editlink,$key,($val['cn']['0'].$desc)), "attach" => "style='' ".$title);
533 $field3 = array("string" => preg_replace("/%KEY%/", $key, $posix." ".$enviro." ".$mail." ".$samba." ".$appl." ".$phone), "attach" => "style='width:136px;'");
534 $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:80px;border-right:0px;text-align:right;'");
536 $divlist->AddEntry(array($field1,$field2,$field3,$field4));
537 }
539 /* Show main page */
540 $smarty->assign("grouplisthead", $listhead);
541 $smarty->assign("grouplist", $divlist->DrawList());
542 $smarty->assign("search_image", get_template_path('images/search.png'));
543 $smarty->assign("searchu_image", get_template_path('images/search_user.png'));
544 $smarty->assign("tree_image", get_template_path('images/tree.png'));
545 $smarty->assign("infoimage", get_template_path('images/info.png'));
546 $smarty->assign("launchimage", get_template_path('images/launch.png'));
547 $smarty->assign("deplist", $this->config->idepartments);
548 foreach( array("guser", "regex", "primarygroups", "mailgroups","appgroups", "sambagroups", "functionalgroups", "subsearch") as $type){
549 $smarty->assign("$type", $groupfilter[$type]);
550 }
552 /* Extend if we are not using javascript */
553 $smarty->assign("apply", apply_filter());
554 $smarty->assign("alphabet", generate_alphabet());
555 $smarty->assign("hint", print_sizelimit_warning());
556 if (isset($this->config->data['MAIN']['NOPRIMARYGROUP'])){
557 $smarty->assign("showprimary", "");
558 } else {
559 $smarty->assign("showprimary", "true");
560 }
562 return($smarty->fetch(get_template_path('headpage.tpl', TRUE)));
563 }
565 function reload($CreatePosixsList=false)
566 {
567 /* Get config */
568 $groupfilter= get_global('groupfilter');
570 /* Set base for all searches */
571 $base= $_SESSION['CurrentMainBase'];
573 /* Regex filter? */
574 if ($groupfilter['regex'] != ""){
575 $regex= $groupfilter['regex'];
576 } else {
577 $regex= "*";
578 }
580 /* User filter? */
581 $filter= "(objectclass=posixGroup)";
582 $error= "";
583 $error2= "";
584 $this->grouplist= array();
586 /* What are primary groups? */
587 $primaries= array();
588 $ldap= $this->config->get_ldap_link();
589 if (!isset($this->config->data['MAIN']['NOPRIMARYGROUP'])){
590 $ldap->cd($base);
591 $ldap->search("(&(uid=$regex)(!(uid=*$))(objectClass=posixAccount)(gidNumber=*))", array("gidNumber", "cn"));
592 show_ldap_error($ldap->get_error());
593 while ($attrs= $ldap->fetch()){
594 $primaries[$attrs['gidNumber'][0]]= $attrs['cn'][0];
595 }
596 }
598 /* Set filter depending on selection */
599 $sfilter= "";
600 if ($groupfilter['appgroups'] == "checked"){
601 $filter.= "(objectClass=gosaApplicationGroup)";
602 }
603 if ($this->config->current['SAMBAVERSION'] == 3){
604 if ($groupfilter['primarygroups'] != "checked"){
605 $sfilter= "(objectClass=sambaGroupMapping)";
606 } elseif ($groupfilter['sambagroups'] == "checked"){
607 $filter.= "(objectClass=sambaGroupMapping)";
608 }
609 }
611 if ($groupfilter['mailgroups'] == "checked"){
612 $filter.= "(objectClass=gosaMailAccount)";
613 }
614 $functional= array();
615 $ldap->cd(get_groups_ou().$base);
616 $ldap->set_size_limit($_SESSION['size_limit']);
617 $ldap->search("(&(cn=$regex)(objectClass=posixGroup)(!(|(objectClass=gosaMailAccount)(objectClass=gosaApplicationGroup)$sfilter)))", array("cn", "gidNumber", "description"));
618 $error2= $ldap->error;
619 while ($attrs= $ldap->fetch()){
620 if (!isset($primaries[$attrs['gidNumber'][0]])){
621 $functional[$attrs['gidNumber'][0]]= $attrs['gidNumber'][0];
622 }
623 }
625 /*
626 * We also need to search for the departments
627 * So we are able to navigate like in konquerer
628 */
630 /* Get all departments within this subtree */
631 $deps= get_list("(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))", $this->ui->subtreeACL,
632 $base, array("ou", "description"), GL_SIZELIMIT | GL_CONVERT);
634 $this->departments = array();
635 foreach($deps as $value){
636 if(isset($value['description'][0])){
637 $this->departments[$value['dn']]= get_sub_department($value['dn'])." - [".$value["description"][0]."]";
638 }else{
639 $this->departments[$value['dn']]= get_sub_department($value['dn']);
640 }
641 }
642 natcasesort($this->departments);
643 /* Ende department generation
644 */
646 /* Generate grouplist */
647 if ($filter != ""){
648 $filter= "(&(cn=$regex)(objectClass=posixGroup)(|$filter))";
649 if ($groupfilter['guser'] != ""){
650 $filter= "(&(|(memberUID=" . $groupfilter['guser'] . ")(cn=" . $groupfilter['guser'] . "))$filter)";
651 }
652 }
655 /* Create attribute array, if releasemanagement is activated we search for FAIrelease too */
656 $attrs = array("cn", "description", "gidNumber", "objectClass");
657 $tmp = search_config($this->config->data,"faiManagement","CLASS");
658 if($tmp){
659 $attrs[] = "FAIrelease";
660 }
662 if ($groupfilter['subsearch'] == "checked"){
663 $res= get_list($filter, $this->ui->subtreeACL, $base, array("cn", "description", "gidNumber", "objectClass","FAIrelease"),
664 GL_SIZELIMIT);
665 } else {
666 $base= get_groups_ou().$base;
667 $res= get_list($filter, $this->ui->subtreeACL, $base, array("cn", "description", "gidNumber", "objectClass","FAIrelease"),
668 GL_SIZELIMIT);
669 }
670 if (preg_match("/size limit/i", $error) || preg_match("/size limit/i", $error2)){
671 $_SESSION['limit_exceeded']= TRUE;
672 }
674 foreach ($res as $value){
675 if ($groupfilter['functionalgroups'] != "checked" && isset($functional[$value['gidNumber'][0]])){
676 continue;
677 }
678 if ($groupfilter['primarygroups'] == "checked"){
679 $this->grouplist[$value['gidNumber'][0]]= $value;
680 } else {
681 if (!isset($primaries[$value['gidNumber'][0]])){
682 $this->grouplist[$value['gidNumber'][0]]= $value;
683 }
684 }
685 }
687 $tmp=array();
689 /* Create result for group management listbox*/
690 foreach($this->grouplist as $tkey => $val ){
691 $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val;
692 }
693 ksort($tmp);
694 $this->grouplist=array();
695 foreach($tmp as $val){
696 $this->grouplist[]=$val;
697 }
698 reset ($this->grouplist);
699 }
701 function remove_from_parent()
702 {
703 /* Optionally execute a command after we're done */
704 $this->postremove();
705 }
710 /* Perform copy & paste requests
711 If copy&paste is in progress this returns a dialog to fix required attributes
712 */
713 function copyPasteHandling($s_action,$s_entry)
714 {
715 /* Paste copied/cutted object in here
716 */
717 if(($s_action == "editPaste") || ($this->CopyPasteHandler->stillOpen())){
718 $this->CopyPasteHandler->save_object();
719 $this->CopyPasteHandler->SetVar("base",$_SESSION['CurrentMainBase']);
720 if($str = $this->CopyPasteHandler->execute()){
721 return( $str);
722 };
723 /* Ensure that the new object is shown in the list now */
724 $this->relaod();
725 }
728 /* Copy current object to CopyHandler
729 */
730 if($s_action == "copy"){
731 $this->CopyPasteHandler->Clear();
733 $dn = $this->grouplist[trim($s_entry)]['dn'];
734 $acl = get_permissions ($dn, $this->ui->subtreeACL);
736 $obj = new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $dn);
737 $objNew = new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], "new");
738 $obj->set_acl($acl);
739 $objNew->set_acl($acl);
740 $this->CopyPasteHandler->Copy($obj,$objNew);
741 }
744 /* Copy current object to CopyHandler
745 */
746 if($s_action == "cut"){
747 $this->CopyPasteHandler->Clear();
748 $dn = $this->grouplist[trim($s_entry)]['dn'];
749 $acl= get_permissions ($dn, $this->ui->subtreeACL);
751 $obj= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $dn);
752 $obj->set_acl($acl);
754 $this->CopyPasteHandler->Cut($obj);
755 }
756 }
758 /* Save data to object */
759 function save_object()
760 {
761 }
764 /* Check values */
765 function check()
766 {
767 }
770 /* Save to LDAP */
771 function save()
772 {
773 /* Optionally execute a command after we're done */
774 $this->postcreate();
775 }
777 function adapt_from_template($dn)
778 {
779 }
781 function password_change_needed()
782 {
783 }
785 function show_header($button_text, $text, $disabled= FALSE)
786 {
787 }
789 function remove_lock()
790 {
791 if (isset($this->grouptab->dn)){
792 del_lock ($this->grouptab->dn);
793 }
794 }
796 }
798 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
799 ?>