09da2d50d48439e6e9a16c5b6d0660ed1e80c564
1 <?php
2 /*
3 * This code is part of GOsa (http://www.gosa-project.org)
4 * Copyright (C) 2003-2008 GONICUS GmbH
5 *
6 * ID: $$Id$$
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
23 class groupManagement extends plugin
24 {
25 /* Definitions */
26 var $plHeadline= "Groups";
27 var $plDescription= "Manage POSIX groups";
29 /* Dialog attributes */
30 var $grouptab = NULL;
31 var $grouplist = array();
32 var $ui = NULL;
33 var $CopyPasteHandler = NULL;
34 var $DivListGroup = NULL;
35 var $ShowPrimaryCheckBox= false;
36 var $start_pasting_copied_objects = FALSE;
37 var $acl_module = "groups";
38 var $dns = array();
40 function groupManagement (&$config, &$ui)
41 {
42 /* Save configuration for internal use */
43 $this->config = &$config;
44 $this->ui = &$ui;
46 /* Copy & Paste enabled ?*/
47 if($this->config->get_cfg_value("copyPaste") == "true"){
48 $this->CopyPasteHandler = new CopyPasteHandler($this->config);
49 }
51 /* Detect if we have to display the primary group checkbox */
52 $tmp = "";
53 if ($this->config->get_cfg_value("primaryGroupFilter") == "false"){
54 $this->ShowPrimaryCheckBox = false;
55 } else {
56 $this->ShowPrimaryCheckBox = true;
57 }
59 /* Create dialog object */
60 $this->DivListGroup = new divListGroup($this->config,$this);
61 $this->DivListGroup->DisableCheckBox("ShowPrimaryGroups",$this->ShowPrimaryCheckBox);
62 }
65 function execute()
66 {
67 /* Call parent execute */
68 plugin::execute();
70 /* Store these posts if the current object is locked (used by somebody else)*/
71 session::set('LOCK_VARS_TO_USE',array("/^act$/","/^id$/","/^group_edit_/","/^group_del_/","/^item_selected/","/^remove_multiple_groups/","/^multiple_edit/","/menu_action/","/_group_/"));
73 /* Save data */
74 $s_action = "";
75 $s_entry = "";
77 /* Test Posts */
78 foreach($_POST as $key => $val){
79 // Post for delete
80 if(preg_match("/^group_del.*/",$key)){
81 $s_action = "del";
82 $s_entry = preg_replace("/group_".$s_action."_/i","",$key);
83 // Post for edit
84 }elseif(preg_match("/^group_edit_.*/",$key)){
85 $s_action="edit";
86 $s_entry = preg_replace("/group_".$s_action."_/i","",$key);
87 // Post for new
88 }elseif(preg_match("/^group_new.*/",$key)){
89 $s_action="new";
90 }elseif(preg_match("/^dep_home.*/i",$key)){
91 $s_action="home";
92 }elseif(preg_match("/^group_tplnew.*/i",$key)){
93 $s_action="new_tpl";
94 }elseif(preg_match("/^group_chgpw.*/i",$key)){
95 $s_action="change_pw";
96 $s_entry = preg_replace("/group_chgpw_/i","",$key);
97 }elseif(preg_match("/_group_edit_/",$key)){
98 $type = preg_replace("/_group_edit_.*$/","",$key);
99 $s_action="edit";
100 $s_entry = preg_replace("/".$type."_group_edit_/i","",$key);
101 $_POST['arg'] = $type;
102 }elseif(preg_match("/^editPaste.*/i",$key)){
103 $s_action="editPaste";
104 }elseif(preg_match("/^copy_.*/",$key)){
105 $s_action="copy";
106 $s_entry = preg_replace("/^copy_/i","",$key);
107 }elseif(preg_match("/^cut_.*/",$key)){
108 $s_action="cut";
109 $s_entry = preg_replace("/^cut_/i","",$key);
110 }elseif(preg_match("/^remove_multiple_groups/",$key)){
111 $s_action="del_multiple";
112 }elseif(preg_match("/^multiple_copy_groups/",$key)){
113 $s_action = "copy_multiple";
114 }elseif(preg_match("/^multiple_cut_groups/",$key)){
115 $s_action = "cut_multiple";
116 }
117 }
118 $s_entry = preg_replace("/_.$/","",$s_entry);
120 /* Check for posted gets */
121 if((isset($_GET['act'])) && ($_GET['act'] == "edit_entry")){
122 $s_entry = $_GET['id'];
123 $s_action = "edit";
124 }
126 /* handle C&P from layers menu */
127 if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){
128 $s_action = "copy_multiple";
129 }
130 if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){
131 $s_action = "cut_multiple";
132 }
133 if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){
134 $s_action = "editPaste";
135 }
137 /* Create options */
138 if(isset($_POST['menu_action']) && $_POST['menu_action'] == "group_new"){
139 $s_action = "new";
140 }
142 /* handle remove from layers menu */
143 if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){
144 $s_action = "del_multiple";
145 }
146 if(isset($_POST['menu_action']) && $_POST['menu_action'] == "multiple_edit"){
147 $s_action = "multiple_edit";
148 }
150 if(isset($_POST['menu_action']) && preg_match("/^event/",$_POST['menu_action'])){
151 $s_action = $_POST['menu_action'];
152 }
154 $smarty= get_smarty();
158 /********************
159 Create notification event
160 ********************/
162 if(preg_match("/^event_/",$s_action) && class_available("DaemonEvent")){
163 $ids = $this->list_get_selected_items();
164 $uids = array();
165 foreach($ids as $id){
166 $uids[] = $this->grouplist[$id]['cn'][0];
167 }
168 if(count($uids)){
169 $events = DaemonEvent::get_event_types(USER_EVENT);
170 $event = preg_replace("/^event_/","",$s_action);
171 if(isset($events['BY_CLASS'][$event])){
172 $type = $events['BY_CLASS'][$event];
173 $this->grouptab = new $type['CLASS_NAME']($this->config);
174 $this->grouptab->add_groups($uids);
175 $this->grouptab->set_type(TRIGGERED_EVENT);
176 }
177 }
178 }
180 /* Abort event dialog */
181 if(isset($_POST['abort_event_dialog'])){
182 $this->grouptab = FALSE;
183 }
185 /* Save event */
186 if(isset($_POST['save_event_dialog'])){
187 $this->grouptab->save_object();
188 $msgs = $this->grouptab->check();
189 if(count($msgs)){
190 msg_dialog::displayChecks($msgs);
191 }else{
192 $o_queue = new gosaSupportDaemon();
193 $o_queue->append($this->grouptab);
194 if($o_queue->is_error()){
195 msg_dialog::display(_("Infrastructure error"), msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
196 }else{
197 $this->grouptab = FALSE;
198 }
199 }
200 }
202 /* Display event */
203 if($this->grouptab instanceof DaemonEvent){
204 $this->grouptab->save_object();
205 return($this->grouptab->execute());
206 }
209 /********************
210 Copy & Paste Handling ...
211 ********************/
213 /* Display the copy & paste dialog, if it is currently open */
214 $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
215 if($ret){
216 return($ret);
217 }
220 /********************
221 Create a new group ...
222 ********************/
224 /* New group? */
225 if ($s_action=="new"){
227 /* Check create permissions */
228 $acl = $this->ui->get_permissions($this->DivListGroup->selectedBase,"groups/group");
229 if(preg_match("/c/",$acl)){
231 /* By default we set 'dn' to 'new', all relevant plugins will
232 react on this. */
233 $this->dn= "new";
235 /* Create new grouptab object */
236 $this->grouptab= new grouptabs($this->config, $this->config->data['TABS']['GROUPTABS'], $this->dn);
238 /* Set up the group ACL's for this 'dn' */
239 $this->grouptab->set_acl_base($this->DivListGroup->selectedBase);
240 }
241 }
244 /********************
245 Save Group Tab/Object Changes
246 ********************/
248 /* Finish group edit is triggered by the tabulator dialog, so
249 the user wants to save edited data. Check and save at this
250 point. */
251 if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->grouptab->config)) ){
253 /* Check tabs, will feed message array
254 Save, or display error message? */
255 $message= $this->grouptab->check();
256 if (count($message) == 0){
258 /* Save user data to ldap */
259 $this->grouptab->save();
261 if (!isset($_POST['edit_apply'])){
262 /* Group has been saved successfully, remove lock from LDAP. */
263 if ($this->dn != "new"){
264 $this->remove_lock();
265 }
267 /* There's no page reload so we have to read new groups at this point. */
268 //$this->reload ();
269 unset ($this->grouptab);
270 $this->grouptab= NULL;
271 session::un_set('objectinfo');
272 }else{
274 /* Reinitialize tab */
275 if($this->grouptab instanceof tabs){
276 $this->grouptab->re_init();
277 }
278 }
279 } else {
280 /* Ok. There seem to be errors regarding to the tab data,
281 show message and continue as usual. */
282 msg_dialog::displayChecks($message);
283 }
284 }
287 /********************
288 Edit multiple entries
289 ********************/
291 /* User wants to edit data? */
292 if ($s_action == "multiple_edit" && !isset($this->grouptab->config)){
294 $this->dn = array();
295 foreach($this->list_get_selected_items() as $id){
296 $this->dn[] = $this->grouplist[$id]['dn'];;
297 }
298 $tmp = new multi_plug($this->config,"grouptabs",$this->config->data['TABS']['GROUPTABS'],
299 $this->dn,$this->DivListGroup->selectedBase,"groups");
300 if ($tmp->entries_locked()){
301 return($tmp->display_lock_message());
302 }
303 $tmp->lock_entries($this->ui->dn);
304 if($tmp->multiple_available()){
305 $this->grouptab = $tmp;
306 session::set('objectinfo',$this->grouptab->get_object_info());
307 }
308 }
311 /********************
312 Edit existing group
313 ********************/
315 /* User wants to edit data? */
316 if (($s_action=="edit") && (!isset($this->grouptab-> config))){
318 /* Get 'dn' from posted 'uid', must be unique */
319 $this->dn= $this->grouplist[trim($s_entry)]['dn'];
321 /* Check locking & lock entry if required */
322 $user = get_lock($this->dn);
323 if ($user != ""){
324 return(gen_locked_message ($user, $this->dn,TRUE));
325 }
326 add_lock ($this->dn, $this->ui->dn);
328 /* Register grouptab to trigger edit dialog */
329 $this->grouptab= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $this->dn);
330 $this->grouptab->set_acl_base($this->dn);
331 session::set('objectinfo',$this->dn);
332 }
335 /********************
336 Delete MULTIPLE entries requested, display confirm dialog
337 ********************/
339 if ($s_action=="del_multiple"){
340 $ids = $this->list_get_selected_items();
342 if(count($ids)){
343 $disallowed = array();
344 $this->dns = array();
345 foreach($ids as $id){
346 $dn = $this->grouplist[$id]['dn'];
347 $acl = $this->ui->get_permissions($dn, "groups/group");
348 if(preg_match("/d/",$acl)){
349 $this->dns[$id] = $dn;
350 }else{
351 $disallowed[] = $dn;
352 }
353 }
355 if(count($disallowed)){
356 msg_dialog::display(_("Permission"),msgPool::permDelete($disallowed),INFO_DIALOG);
357 }
359 if(count($this->dns)){
361 /* Check locks */
362 if ($user= get_multiple_locks($this->dns)){
363 return(gen_locked_message($user,$this->dns));
364 }
366 $dns_names = array();
367 foreach($this->dns as $dn){
368 $dns_names[] =LDAP::fix($dn);
369 }
370 add_lock ($this->dns, $this->ui->dn);
372 /* Lock the current entry, so nobody will edit it during deletion */
373 $smarty->assign("info", msgPool::deleteInfo($dns_names,_("group")));
374 $smarty->assign("multiple", true);
375 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
376 }
377 }
378 }
381 /********************
382 Delete MULTIPLE entries confirmed
383 ********************/
385 /* Confirmation for deletion has been passed. Groups should be deleted. */
386 if (isset($_POST['delete_multiple_groups_confirm'])){
388 /* Remove user by user and check acls before removeing them */
389 foreach($this->dns as $key => $dn){
391 /* Load permissions for selected 'dn' and check if
392 we're allowed to remove this 'dn' */
393 $acl = $this->ui->get_permissions($dn,"groups/group");
394 if(preg_match("/d/",$acl)){
396 /* Delete request is permitted, perform LDAP action */
397 $this->grouptab= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $dn);
398 $this->grouptab->set_acl_base($dn);
399 $this->grouptab->delete ();
400 unset ($this->grouptab);
401 $this->grouptab= NULL;
403 } else {
405 /* Normally this shouldn't be reached, send some extra
406 logs to notify the administrator */
407 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
408 new log("security","groups/".get_class($this),$dn,array(),"Tried to trick deletion.");
409 }
410 }
412 /* Remove lock file after successfull deletion */
413 $this->remove_lock();
414 $this->dns = array();
415 }
418 /********************
419 Delete MULTIPLE entries Canceled
420 ********************/
422 /* Remove lock */
423 if(isset($_POST['delete_multiple_group_cance'])){
425 /* Remove lock file after successfull deletion */
426 $this->remove_lock();
427 $this->dns = array();
428 }
431 /********************
432 Delete group
433 ********************/
435 /* Remove group was requested */
436 if ($s_action=="del"){
438 /* Get 'dn' from posted 'uid' */
439 $this->dn= $this->grouplist[trim($s_entry)]['dn'];
441 /* Load permissions for selected 'dn' and check if
442 we're allowed to remove this 'dn' */
443 $acl = $this->ui->get_permissions($this->dn,"groups/group");
444 if(preg_match("/d/",$acl)){
446 /* Check locking, save current plugin in 'back_plugin', so
447 the dialog knows where to return. */
448 if (($user= get_lock($this->dn)) != ""){
449 return(gen_locked_message ($user, $this->dn));
450 }
452 /* Lock the current entry, so nobody will edit it during deletion */
453 add_lock ($this->dn, $this->ui->dn);
454 $smarty->assign("info", msgPool::deleteInfo(LDAP::fix($this->dn),_("group")));
455 $smarty->assign("multiple", false);
456 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
458 } else {
460 /* Obviously the user isn't allowed to delete. Show message and clean session. */
461 msg_dialog::display(_("Permission error"), msgPool::permDelete());
462 }
463 }
466 /********************
467 Delete group confirmed
468 ********************/
470 /* Confirmation for deletion has been passed. Group should be deleted. */
471 if (isset($_POST['delete_group_confirm'])){
473 /* Some nice guy may send this as POST, so we've to check
474 for the permissions again. */
475 $acl = $this->ui->get_permissions($this->dn,"groups/group");
476 if(preg_match("/d/",$acl)){
478 /* Delete request is permitted, perform LDAP action */
479 $this->grouptab= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $this->dn);
480 $this->grouptab->set_acl_base($this->dn);
481 $this->grouptab->delete ();
482 unset ($this->grouptab);
483 $this->grouptab= NULL;
485 /* Group list has changed, reload it. */
486 //$this->reload ();
488 } else {
490 /* Normally this shouldn't be reached, send some extra
491 logs to notify the administrator */
492 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
493 new log("security","groups/".get_class($this),$dn,array(),"Tried to trick deletion.");
494 }
496 /* Remove lock file after successfull deletion */
497 $this->remove_lock();
498 session::un_set('objectinfo');
499 }
502 /********************
503 Delete group canceled
504 ********************/
506 /* Delete group canceled? */
507 if (isset($_POST['delete_cancel'])){
508 $this->remove_lock();
509 session::un_set('objectinfo');
510 }
513 /********************
514 A dialog was canceled
515 ********************/
517 /* Cancel dialogs */
518 if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){
519 if(isset($this->grouptab->dn)){
520 $this->remove_lock();
521 }
522 $this->grouptab= NULL;
523 session::un_set('objectinfo');
524 }
527 /********************
528 If there is currently a dialog open, display it
529 ********************/
531 /* Show tab dialog if object is present */
532 if (isset($this->grouptab->config)){
533 $display= $this->grouptab->execute();
535 /* Don't show buttons if tab dialog requests this */
536 if(isset($this->grouptab->by_object)){
538 if(($this->grouptab instanceOf tabs || $this->grouptab instanceOf plugin) && $this->grouptab->read_only == TRUE){
539 $display.= "<p style=\"text-align:right\">
540 <input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">
541 </p>";
542 }elseif (!$this->grouptab->by_object[$this->grouptab->current]->dialog){
543 $display.= "<p style=\"text-align:right\">\n";
544 $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
545 $display.= " \n";
546 if ($this->dn != "new"){
547 $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
548 $display.= " \n";
549 }
550 $display.= "<input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
551 $display.= "</p>";
552 }
553 }
554 return ($display);
555 }
558 /* Check if there is a snapshot dialog open */
559 $base = $this->DivListGroup->selectedBase;
560 if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
561 return($str);
562 }
564 /* Display dialog with group list */
565 $this->DivListGroup->parent = $this;
566 $this->DivListGroup->execute();
568 /* Add departments if subsearch is disabled */
569 if(!$this->DivListGroup->SubSearch){
570 $this->DivListGroup->AddDepartments($this->DivListGroup->selectedBase,4,1);
571 }
572 $this->reload ();
573 $this->DivListGroup->setEntries($this->grouplist);
574 return($this->DivListGroup->Draw());
575 }
578 /* Return departments, that will be included within snapshot detection */
579 function get_used_snapshot_bases()
580 {
581 return(array(get_groups_ou().$this->DivListGroup->selectedBase));
582 }
585 function list_get_selected_items()
586 {
587 $ids = array();
588 foreach($_POST as $name => $value){
589 if(preg_match("/^item_selected_[0-9]*$/",$name)){
590 $id = preg_replace("/^item_selected_/","",$name);
591 $ids[$id] = $id;
592 }
593 }
594 return($ids);
595 }
598 function reload($CreatePosixsList=false)
599 {
600 $this->grouplist = array();
601 $primaries = array();
602 $functional = array();
603 $error= $error2 = "";
604 $filter = "(objectclass=posixGroup)";
606 $base = $this->DivListGroup->selectedBase;
607 $Regex = $this->DivListGroup->Regex;
608 $UserRegex = $this->DivListGroup->UserRegex;
609 $SubSearch = $this->DivListGroup->SubSearch;
610 $ShowPrimaryGroups = $this->DivListGroup->ShowPrimaryGroups;
611 $ShowSambaGroups = $this->DivListGroup->ShowSambaGroups;
612 $ShowApplicationGroups = $this->DivListGroup->ShowApplicationGroups;
613 $ShowMailGroups = $this->DivListGroup->ShowMailGroups;
614 $ShowFunctionalGroups = $this->DivListGroup->ShowFunctionalGroups;
616 /* Prepare ldap class */
617 $ldap= $this->config->get_ldap_link();
618 $ldap->cd($base);
619 $ldap->set_size_limit(session::get('size_limit'));
622 /********************
623 Create filter depending on selected checkboxes
624 ********************/
626 /* Add application groups */
627 if ($ShowApplicationGroups){
628 $filter.= "(objectClass=gosaApplicationGroup)";
629 }
631 /* Add Mail Groups */
632 if ($ShowMailGroups){
633 $filter.= "(objectClass=gosaMailAccount)";
634 }
636 $sfilter= "";
637 if ($this->config->get_cfg_value("sambaversion") == 3){
638 if (!$ShowPrimaryGroups){
639 $sfilter= "(objectClass=sambaGroupMapping)";
640 } elseif ($ShowSambaGroups){
641 $filter.= "(objectClass=sambaGroupMapping)";
642 }
643 }
645 /* Prepare filter for given Regex && UserRegex */
646 if ($filter != ""){
647 $filter= "(&(cn=$Regex)(objectClass=posixGroup)(|$filter))";
648 if ($UserRegex != ""){
649 $filter= "(&(|(memberUID=".$UserRegex.")(cn=".$UserRegex."))$filter)";
650 }
651 }
654 /********************
655 Collect some groupids to be able to skip primary & functional groups
656 ********************/
658 /* Collect primary groupIDs to show primary groups
659 if this option is enabled in gosa conf && the checkbox is checked */
660 if ($this->ShowPrimaryCheckBox){
661 $res = get_list("(&(uid=$Regex)(!(uid=*$))(objectClass=posixAccount)(gidNumber=*))",
662 "groups", $base,array("gidNumber", "cn"), GL_SUBSEARCH);
663 foreach ($res as $attrs){
664 $primaries[$attrs['gidNumber'][0]]= $attrs['cn'][0];
665 }
666 }
668 /* Collect all GroupIDs from those groups which are functional.
669 Only perfrom this search if ShowFunctionalGroups is unchecked, else leave arre empty */
670 $ff = "(&(cn=$Regex)(objectClass=posixGroup)(!(|(objectClass=gosaMailAccount)(objectClass=gosaApplicationGroup)$sfilter)))";
671 if ($SubSearch){
672 $res = get_sub_list($ff, "groups",get_groups_ou(), $base,array("gidNumber", "cn", "description"), GL_SUBSEARCH);
673 } else {
674 $res = get_sub_list($ff, "groups",get_groups_ou(), $base,array("gidNumber", "cn", "description"), GL_NONE);
675 }
676 foreach($res as $attrs){
677 if (!isset($primaries[$attrs['gidNumber'][0]])){
678 $functional[$attrs['gidNumber'][0]]= $attrs['gidNumber'][0];
679 }
680 }
682 /********************
683 Search for the prepared filter
684 ********************/
686 /* Attributes to search for */
687 $attrs = array("cn", "description", "gidNumber", "objectClass");
689 /* If subsearch is activated search for subobjects too */
690 $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
691 if(!empty($tmp)){
692 $attrs [] = "FAIrelease";
693 }
695 if ($SubSearch){
696 $res= get_sub_list($filter, "groups",get_groups_ou(), $base, $attrs, GL_SIZELIMIT| GL_SUBSEARCH);
697 } else {
698 $res= get_sub_list($filter, "groups",get_groups_ou(), get_groups_ou().$base, $attrs, GL_SIZELIMIT);
699 }
701 /* Sort values into grouplist*/
702 $tmp = $tmp2 = array();
703 foreach ($res as $value){
704 /* Skip functional groups if checkbox isn't checked */
705 if (!$ShowFunctionalGroups && isset($functional[$value['gidNumber'][0]])){
706 continue;
707 }
709 /* If gidNumber is in $primaries skip this entry */
710 if (($ShowPrimaryGroups) || (!$ShowPrimaryGroups && !isset($primaries[$value['gidNumber'][0]]))){
711 $tmp2[$value['cn'][0]] = $value;
712 $tmp [$value['cn'][0]] = $value['cn'][0];
713 }
714 }
715 natcasesort($tmp);
716 foreach($tmp as $name){
717 $this->grouplist[] = $tmp2[$name];
718 }
719 reset ($this->grouplist);
720 }
723 function copyPasteHandling_from_queue($s_action,$s_entry)
724 {
725 /* Check if Copy & Paste is disabled */
726 if(!is_object($this->CopyPasteHandler)){
727 return("");
728 }
730 $ui = get_userinfo();
732 /* Add a single entry to queue */
733 if($s_action == "cut" || $s_action == "copy"){
735 /* Cleanup object queue */
736 $this->CopyPasteHandler->cleanup_queue();
737 $dn = $this->grouplist[$s_entry]['dn'];
738 if($s_action == "copy" && $ui->is_copyable($dn,"groups","group")){
739 $this->CopyPasteHandler->add_to_queue($dn,$s_action,"grouptabs","GROUPTABS","groups");
740 }
741 if($s_action == "cut" && $ui->is_cutable($dn,"groups","group")){
742 $this->CopyPasteHandler->add_to_queue($dn,$s_action,"grouptabs","GROUPTABS","groups");
743 }
745 }
748 /* Add entries to queue */
749 if($s_action == "copy_multiple" || $s_action == "cut_multiple"){
751 /* Cleanup object queue */
752 $this->CopyPasteHandler->cleanup_queue();
754 /* Add new entries to CP queue */
755 foreach($this->list_get_selected_items() as $id){
756 $dn = $this->grouplist[$id]['dn'];
758 if($s_action == "copy_multiple" && $ui->is_copyable($dn,"groups","group")){
759 $this->CopyPasteHandler->add_to_queue($dn,"copy","grouptabs","GROUPTABS","groups");
760 }
761 if($s_action == "cut_multiple" && $ui->is_cutable($dn,"groups","group")){
762 $this->CopyPasteHandler->add_to_queue($dn,"cut","grouptabs","GROUPTABS","groups");
763 }
764 }
765 }
767 /* Start pasting entries */
768 if($s_action == "editPaste"){
769 $this->start_pasting_copied_objects = TRUE;
770 }
772 /* Return C&P dialog */
773 if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
775 /* Get dialog */
776 $this->CopyPasteHandler->SetVar("base",$this->DivListGroup->selectedBase);
777 $data = $this->CopyPasteHandler->execute();
779 /* Return dialog data */
780 if(!empty($data)){
781 return($data);
782 }
783 }
785 /* Automatically disable status for pasting */
786 if(!$this->CopyPasteHandler->entries_queued()){
787 $this->start_pasting_copied_objects = FALSE;
788 }
789 return("");
790 }
793 /* Save data to object */
794 function save_object()
795 {
796 $this->DivListGroup->save_object();
797 if(is_object($this->CopyPasteHandler)){
798 $this->CopyPasteHandler->save_object();
799 }
800 }
803 function remove_lock()
804 {
805 if (isset($this->grouptab->dn)){
806 del_lock ($this->grouptab->dn);
807 }elseif(isset($this->dn) && !empty($this->dn) && $this->dn != "new"){
808 del_lock($this->dn);
809 }
810 if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
811 del_lock($this->dns);
812 }
813 }
816 function remove_from_parent()
817 {
818 /* Optionally execute a command after we're done */
819 $this->postremove();
820 }
823 /* Save to LDAP */
824 function save()
825 {
826 /* Optionally execute a command after we're done */
827 $this->postcreate();
828 }
830 /* Unused functions */
831 function check() { }
832 function adapt_from_template($dn, $skip= array()) { }
833 function password_change_needed() { }
834 }
835 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
836 ?>