bcb71bd1a624236b73c6d8833bdedb25cadc5a4b
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;
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((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE']))){
48 $this->CopyPasteHandler = new CopyPasteHandler($this->config);
49 }
51 /* Detect if we have to display the primary group checkbox */
52 $tmp = "";
53 if (isset($this->config->data['MAIN']['NOPRIMARYGROUP'])){
54 $tmp = $this->config->data['MAIN']['NOPRIMARYGROUP'];
55 }
56 if(preg_match("/true/i",$tmp)|| (preg_match("/yes/",$tmp))){
57 $this->ShowPrimaryCheckBox = false;
58 } else {
59 $this->ShowPrimaryCheckBox = true;
60 }
62 /* Create dialog object */
63 $this->DivListGroup = new divListGroup($this->config,$this);
64 $this->DivListGroup->DisableCheckBox("ShowPrimaryGroups",$this->ShowPrimaryCheckBox);
65 }
68 function execute()
69 {
70 /* Call parent execute */
71 plugin::execute();
73 /* Store these posts if the current object is locked (used by somebody else)*/
74 session::set('LOCK_VARS_TO_USE',array("/^act$/","/^id$/","/^group_edit_/","/^group_del_/","/^item_selected/","/^remove_multiple_groups/","/^multiple_edit/","/menu_action/"));
76 /* Save data */
77 $s_action = "";
78 $s_entry = "";
80 /* Test Posts */
81 foreach($_POST as $key => $val){
82 // Post for delete
83 if(preg_match("/^group_del.*/",$key)){
84 $s_action = "del";
85 $s_entry = preg_replace("/group_".$s_action."_/i","",$key);
86 // Post for edit
87 }elseif(preg_match("/^group_edit_.*/",$key)){
88 $s_action="edit";
89 $s_entry = preg_replace("/group_".$s_action."_/i","",$key);
90 // Post for new
91 }elseif(preg_match("/^group_new.*/",$key)){
92 $s_action="new";
93 }elseif(preg_match("/^dep_home.*/i",$key)){
94 $s_action="home";
95 }elseif(preg_match("/^group_tplnew.*/i",$key)){
96 $s_action="new_tpl";
97 }elseif(preg_match("/^group_chgpw.*/i",$key)){
98 $s_action="change_pw";
99 $s_entry = preg_replace("/group_chgpw_/i","",$key);
100 }elseif(preg_match("/_group_edit_/",$key)){
101 $type = preg_replace("/_group_edit_.*$/","",$key);
102 $s_action="edit";
103 $s_entry = preg_replace("/".$type."_group_edit_/i","",$key);
104 $_POST['arg'] = $type;
105 }elseif(preg_match("/^editPaste.*/i",$key)){
106 $s_action="editPaste";
107 }elseif(preg_match("/^copy_.*/",$key)){
108 $s_action="copy";
109 $s_entry = preg_replace("/^copy_/i","",$key);
110 }elseif(preg_match("/^cut_.*/",$key)){
111 $s_action="cut";
112 $s_entry = preg_replace("/^cut_/i","",$key);
113 }elseif(preg_match("/^remove_multiple_groups/",$key)){
114 $s_action="del_multiple";
115 }elseif(preg_match("/^multiple_copy_groups/",$key)){
116 $s_action = "copy_multiple";
117 }elseif(preg_match("/^multiple_cut_groups/",$key)){
118 $s_action = "cut_multiple";
119 }
120 }
121 $s_entry = preg_replace("/_.$/","",$s_entry);
123 /* Check for posted gets */
124 if((isset($_GET['act'])) && ($_GET['act'] == "edit_entry")){
125 $s_entry = $_GET['id'];
126 $s_action = "edit";
127 }
129 /* handle C&P from layers menu */
130 if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){
131 $s_action = "copy_multiple";
132 }
133 if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){
134 $s_action = "cut_multiple";
135 }
136 if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){
137 $s_action = "editPaste";
138 }
140 /* Create options */
141 if(isset($_POST['menu_action']) && $_POST['menu_action'] == "group_new"){
142 $s_action = "new";
143 }
145 /* handle remove from layers menu */
146 if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){
147 $s_action = "del_multiple";
148 }
149 if(isset($_POST['menu_action']) && $_POST['menu_action'] == "multiple_edit"){
150 $s_action = "multiple_edit";
151 }
153 if(isset($_POST['menu_action']) && preg_match("/^event/",$_POST['menu_action'])){
154 $s_action = $_POST['menu_action'];
155 }
157 $smarty= get_smarty();
161 /********************
162 Create notification event
163 ********************/
165 if(preg_match("/^event_/",$s_action) && class_available("DaemonEvent")){
166 $ids = $this->list_get_selected_items();
167 $uids = array();
168 foreach($ids as $id){
169 $uids[] = $this->grouplist[$id]['cn'][0];
170 }
171 if(count($uids)){
172 $events = DaemonEvent::get_event_types(USER_EVENT);
173 $event = preg_replace("/^event_/","",$s_action);
174 if(isset($events['BY_CLASS'][$event])){
175 $type = $events['BY_CLASS'][$event];
176 $this->grouptab = new $type['CLASS_NAME']($this->config);
177 $this->grouptab->add_groups($uids);
178 $this->grouptab->set_type(TRIGGERED_EVENT);
179 }
180 }
181 }
183 /* Abort event dialog */
184 if(isset($_POST['abort_event_dialog'])){
185 $this->grouptab = FALSE;
186 }
188 /* Save event */
189 if(isset($_POST['save_event_dialog'])){
190 $this->grouptab->save_object();
191 $msgs = $this->grouptab->check();
192 if(count($msgs)){
193 msg_dialog::displayChecks($msgs);
194 }else{
195 $o_queue = new gosaSupportDaemon();
196 $o_queue->append($this->grouptab);
197 if($o_queue->is_error()){
198 msg_dialog::display(_("Infrastructure error"), msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
199 }else{
200 $this->grouptab = FALSE;
201 }
202 }
203 }
205 /* Display event */
206 if($this->grouptab instanceof DaemonEvent){
207 $this->grouptab->save_object();
208 return($this->grouptab->execute());
209 }
212 /********************
213 Copy & Paste Handling ...
214 ********************/
216 /* Display the copy & paste dialog, if it is currently open */
217 $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
218 if($ret){
219 return($ret);
220 }
223 /********************
224 Create a new group ...
225 ********************/
227 /* New group? */
228 if ($s_action=="new"){
230 /* Check create permissions */
231 $acl = $this->ui->get_permissions($this->DivListGroup->selectedBase,"groups/group");
232 if(preg_match("/c/",$acl)){
234 /* By default we set 'dn' to 'new', all relevant plugins will
235 react on this. */
236 $this->dn= "new";
238 /* Create new grouptab object */
239 $this->grouptab= new grouptabs($this->config, $this->config->data['TABS']['GROUPTABS'], $this->dn);
241 /* Set up the group ACL's for this 'dn' */
242 $this->grouptab->set_acl_base($this->DivListGroup->selectedBase);
243 }
244 }
247 /********************
248 Save Group Tab/Object Changes
249 ********************/
251 /* Finish group edit is triggered by the tabulator dialog, so
252 the user wants to save edited data. Check and save at this
253 point. */
254 if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->grouptab->config)) ){
256 /* Check tabs, will feed message array
257 Save, or display error message? */
258 $message= $this->grouptab->check();
259 if (count($message) == 0){
261 /* Save user data to ldap */
262 $this->grouptab->save();
264 if (!isset($_POST['edit_apply'])){
265 /* Group has been saved successfully, remove lock from LDAP. */
266 if ($this->dn != "new"){
267 $this->remove_lock();
268 }
270 /* There's no page reload so we have to read new groups at this point. */
271 //$this->reload ();
272 unset ($this->grouptab);
273 $this->grouptab= NULL;
274 session::un_set('objectinfo');
275 }else{
277 /* Reinitialize tab */
278 if($this->grouptab instanceof tabs){
279 $this->grouptab->re_init();
280 }
281 }
282 } else {
283 /* Ok. There seem to be errors regarding to the tab data,
284 show message and continue as usual. */
285 msg_dialog::displayChecks($message);
286 }
287 }
290 /********************
291 Edit multiple entries
292 ********************/
294 /* User wants to edit data? */
295 if ($s_action == "multiple_edit" && !isset($this->grouptab->config)){
297 $this->dn = array();
298 foreach($this->list_get_selected_items() as $id){
299 $this->dn[] = $this->grouplist[$id]['dn'];;
300 }
301 $tmp = new multi_plug($this->config,"grouptabs",$this->config->data['TABS']['GROUPTABS'],
302 $this->dn,$this->DivListGroup->selectedBase,"groups");
303 if ($tmp->entries_locked()){
304 return($tmp->display_lock_message());
305 }
306 $tmp->lock_entries($this->ui->dn);
307 if($tmp->multiple_available()){
308 $this->grouptab = $tmp;
309 session::set('objectinfo',$this->grouptab->get_object_info());
310 }
311 }
314 /********************
315 Edit existing group
316 ********************/
318 /* User wants to edit data? */
319 if (($s_action=="edit") && (!isset($this->grouptab-> config))){
321 /* Get 'dn' from posted 'uid', must be unique */
322 $this->dn= $this->grouplist[trim($s_entry)]['dn'];
324 /* Check locking & lock entry if required */
325 $user = get_lock($this->dn);
326 if ($user != ""){
327 return(gen_locked_message ($user, $this->dn));
328 }
329 add_lock ($this->dn, $this->ui->dn);
331 /* Register grouptab to trigger edit dialog */
332 $this->grouptab= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $this->dn);
333 $this->grouptab->set_acl_base($this->dn);
334 session::set('objectinfo',$this->dn);
335 }
338 /********************
339 Delete MULTIPLE entries requested, display confirm dialog
340 ********************/
342 if ($s_action=="del_multiple"){
343 $ids = $this->list_get_selected_items();
345 if(count($ids)){
347 $this->dns = array();
348 foreach($ids as $id){
349 $this->dns[$id] = $this->grouplist[$id]['dn'];
350 }
352 /* Check locks */
353 if ($user= get_multiple_locks($this->dns)){
354 return(gen_locked_message($user,$this->dns));
355 }
357 $dns_names = array();
358 foreach($this->dns as $dn){
359 $dns_names[] =@LDAP::fix($dn);
360 }
361 add_lock ($this->dns, $this->ui->dn);
363 /* Lock the current entry, so nobody will edit it during deletion */
364 $smarty->assign("info", msgPool::deleteInfo($dns_names,_("group")));
365 $smarty->assign("multiple", true);
366 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
367 }
368 }
371 /********************
372 Delete MULTIPLE entries confirmed
373 ********************/
375 /* Confirmation for deletion has been passed. Groups should be deleted. */
376 if (isset($_POST['delete_multiple_groups_confirm'])){
378 /* Remove user by user and check acls before removeing them */
379 foreach($this->dns as $key => $dn){
381 /* Load permissions for selected 'dn' and check if
382 we're allowed to remove this 'dn' */
383 $acl = $this->ui->get_permissions($dn,"groups/group");
384 if(preg_match("/d/",$acl)){
386 /* Delete request is permitted, perform LDAP action */
387 $this->grouptab= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $dn);
388 $this->grouptab->set_acl_base($dn);
389 $this->grouptab->delete ();
390 unset ($this->grouptab);
391 $this->grouptab= NULL;
393 } else {
395 /* Normally this shouldn't be reached, send some extra
396 logs to notify the administrator */
397 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
398 new log("security","groups/".get_class($this),$dn,array(),"Tried to trick deletion.");
399 }
400 }
402 /* Remove lock file after successfull deletion */
403 $this->remove_lock();
404 $this->dns = array();
405 }
408 /********************
409 Delete MULTIPLE entries Canceled
410 ********************/
412 /* Remove lock */
413 if(isset($_POST['delete_multiple_user_cancel'])){
415 /* Remove lock file after successfull deletion */
416 $this->remove_lock();
417 $this->dns = array();
418 }
421 /********************
422 Delete group
423 ********************/
425 /* Remove group was requested */
426 if ($s_action=="del"){
428 /* Get 'dn' from posted 'uid' */
429 $this->dn= $this->grouplist[trim($s_entry)]['dn'];
431 /* Load permissions for selected 'dn' and check if
432 we're allowed to remove this 'dn' */
433 $acl = $this->ui->get_permissions($this->dn,"groups/group");
434 if(preg_match("/d/",$acl)){
436 /* Check locking, save current plugin in 'back_plugin', so
437 the dialog knows where to return. */
438 if (($user= get_lock($this->dn)) != ""){
439 return(gen_locked_message ($user, $this->dn));
440 }
442 /* Lock the current entry, so nobody will edit it during deletion */
443 add_lock ($this->dn, $this->ui->dn);
444 $smarty->assign("info", msgPool::deleteInfo(@LDAP::fix($this->dn),_("group")));
445 $smarty->assign("multiple", false);
446 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
448 } else {
450 /* Obviously the user isn't allowed to delete. Show message and clean session. */
451 msg_dialog::display(_("Permission error"), msgPool::permDelete());
452 }
453 }
456 /********************
457 Delete group confirmed
458 ********************/
460 /* Confirmation for deletion has been passed. Group should be deleted. */
461 if (isset($_POST['delete_group_confirm'])){
463 /* Some nice guy may send this as POST, so we've to check
464 for the permissions again. */
465 $acl = $this->ui->get_permissions($this->dn,"groups/group");
466 if(preg_match("/d/",$acl)){
468 /* Delete request is permitted, perform LDAP action */
469 $this->grouptab= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $this->dn);
470 $this->grouptab->set_acl_base($this->dn);
471 $this->grouptab->delete ();
472 unset ($this->grouptab);
473 $this->grouptab= NULL;
475 /* Group list has changed, reload it. */
476 //$this->reload ();
478 } else {
480 /* Normally this shouldn't be reached, send some extra
481 logs to notify the administrator */
482 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
483 new log("security","groups/".get_class($this),$dn,array(),"Tried to trick deletion.");
484 }
486 /* Remove lock file after successfull deletion */
487 $this->remove_lock();
488 session::un_set('objectinfo');
489 }
492 /********************
493 Delete group canceled
494 ********************/
496 /* Delete group canceled? */
497 if (isset($_POST['delete_cancel'])){
498 $this->remove_lock();
499 session::un_set('objectinfo');
500 }
503 /********************
504 A dialog was canceled
505 ********************/
507 /* Cancel dialogs */
508 if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){
509 if(isset($this->grouptab->dn)){
510 $this->remove_lock();
511 }
512 $this->grouptab= NULL;
513 session::un_set('objectinfo');
514 }
517 /********************
518 If there is currently a dialog open, display it
519 ********************/
521 /* Show tab dialog if object is present */
522 if (isset($this->grouptab->config)){
523 $display= $this->grouptab->execute();
525 /* Don't show buttons if tab dialog requests this */
526 if(isset($this->grouptab->by_object)){
527 if (!$this->grouptab->by_object[$this->grouptab->current]->dialog){
528 $display.= "<p style=\"text-align:right\">\n";
529 $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
530 $display.= " \n";
531 if ($this->dn != "new"){
532 $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
533 $display.= " \n";
534 }
535 $display.= "<input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
536 $display.= "</p>";
537 }
538 }
539 return ($display);
540 }
543 /* Check if there is a snapshot dialog open */
544 $base = $this->DivListGroup->selectedBase;
545 if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
546 return($str);
547 }
549 /* Display dialog with group list */
550 $this->DivListGroup->parent = $this;
551 $this->DivListGroup->execute();
553 /* Add departments if subsearch is disabled */
554 if(!$this->DivListGroup->SubSearch){
555 $this->DivListGroup->AddDepartments($this->DivListGroup->selectedBase,4,1);
556 }
557 $this->reload ();
558 $this->DivListGroup->setEntries($this->grouplist);
559 return($this->DivListGroup->Draw());
560 }
563 /* Return departments, that will be included within snapshot detection */
564 function get_used_snapshot_bases()
565 {
566 return(array(get_groups_ou().$this->DivListGroup->selectedBase));
567 }
570 function list_get_selected_items()
571 {
572 $ids = array();
573 foreach($_POST as $name => $value){
574 if(preg_match("/^item_selected_[0-9]*$/",$name)){
575 $id = preg_replace("/^item_selected_/","",$name);
576 $ids[$id] = $id;
577 }
578 }
579 return($ids);
580 }
583 function reload($CreatePosixsList=false)
584 {
585 $this->grouplist = array();
586 $primaries = array();
587 $functional = array();
588 $error= $error2 = "";
589 $filter = "(objectclass=posixGroup)";
591 $base = $this->DivListGroup->selectedBase;
592 $Regex = $this->DivListGroup->Regex;
593 $UserRegex = $this->DivListGroup->UserRegex;
594 $SubSearch = $this->DivListGroup->SubSearch;
595 $ShowPrimaryGroups = $this->DivListGroup->ShowPrimaryGroups;
596 $ShowSambaGroups = $this->DivListGroup->ShowSambaGroups;
597 $ShowApplicationGroups = $this->DivListGroup->ShowApplicationGroups;
598 $ShowMailGroups = $this->DivListGroup->ShowMailGroups;
599 $ShowFunctionalGroups = $this->DivListGroup->ShowFunctionalGroups;
601 /* Prepare ldap class */
602 $ldap= $this->config->get_ldap_link();
603 $ldap->cd($base);
604 $ldap->set_size_limit(session::get('size_limit'));
607 /********************
608 Create filter depending on selected checkboxes
609 ********************/
611 /* Add application groups */
612 if ($ShowApplicationGroups){
613 $filter.= "(objectClass=gosaApplicationGroup)";
614 }
616 /* Add Mail Groups */
617 if ($ShowMailGroups){
618 $filter.= "(objectClass=gosaMailAccount)";
619 }
621 $sfilter= "";
622 if ($this->config->current['SAMBAVERSION'] == 3){
623 if (!$ShowPrimaryGroups){
624 $sfilter= "(objectClass=sambaGroupMapping)";
625 } elseif ($ShowSambaGroups){
626 $filter.= "(objectClass=sambaGroupMapping)";
627 }
628 }
630 /* Prepare filter for given Regex && UserRegex */
631 if ($filter != ""){
632 $filter= "(&(cn=$Regex)(objectClass=posixGroup)(|$filter))";
633 if ($UserRegex != ""){
634 $filter= "(&(|(memberUID=".$UserRegex.")(cn=".$UserRegex."))$filter)";
635 }
636 }
639 /********************
640 Collect some groupids to be able to skip primary & functional groups
641 ********************/
643 /* Collect primary groupIDs to show primary groups
644 if this option is enabled in gosa conf && the checkbox is checked */
645 if ($this->ShowPrimaryCheckBox){
646 $res = get_list("(&(uid=$Regex)(!(uid=*$))(objectClass=posixAccount)(gidNumber=*))",
647 "groups", $base,array("gidNumber", "cn"), GL_SUBSEARCH);
648 foreach ($res as $attrs){
649 $primaries[$attrs['gidNumber'][0]]= $attrs['cn'][0];
650 }
651 }
653 /* Collect all GroupIDs from those groups which are functional.
654 Only perfrom this search if ShowFunctionalGroups is unchecked, else leave arre empty */
655 $ff = "(&(cn=$Regex)(objectClass=posixGroup)(!(|(objectClass=gosaMailAccount)(objectClass=gosaApplicationGroup)$sfilter)))";
656 if ($SubSearch){
657 $res = get_sub_list($ff, "groups",get_groups_ou(), $base,array("gidNumber", "cn", "description"), GL_SUBSEARCH);
658 } else {
659 $res = get_sub_list($ff, "groups",get_groups_ou(), $base,array("gidNumber", "cn", "description"), GL_NONE);
660 }
661 foreach($res as $attrs){
662 if (!isset($primaries[$attrs['gidNumber'][0]])){
663 $functional[$attrs['gidNumber'][0]]= $attrs['gidNumber'][0];
664 }
665 }
667 /********************
668 Search for the prepared filter
669 ********************/
671 /* Attributes to search for */
672 $attrs = array("cn", "description", "gidNumber", "objectClass");
674 /* If subsearch is activated search for subobjects too */
675 $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
676 if(!empty($tmp)){
677 $attrs [] = "FAIrelease";
678 }
680 if ($SubSearch){
681 $res= get_sub_list($filter, "groups",get_groups_ou(), $base, $attrs, GL_SIZELIMIT| GL_SUBSEARCH);
682 } else {
683 $res= get_sub_list($filter, "groups",get_groups_ou(), get_groups_ou().$base, $attrs, GL_SIZELIMIT);
684 }
686 /* Sort values into grouplist*/
687 $tmp = $tmp2 = array();
688 foreach ($res as $value){
689 /* Skip functional groups if checkbox isn't checked */
690 if (!$ShowFunctionalGroups && isset($functional[$value['gidNumber'][0]])){
691 continue;
692 }
694 /* If gidNumber is in $primaries skip this entry */
695 if (($ShowPrimaryGroups) || (!$ShowPrimaryGroups && !isset($primaries[$value['gidNumber'][0]]))){
696 $tmp2[$value['cn'][0]] = $value;
697 $tmp [$value['cn'][0]] = $value['cn'][0];
698 }
699 }
700 natcasesort($tmp);
701 foreach($tmp as $name){
702 $this->grouplist[] = $tmp2[$name];
703 }
704 reset ($this->grouplist);
705 }
708 function copyPasteHandling_from_queue($s_action,$s_entry)
709 {
710 /* Check if Copy & Paste is disabled */
711 if(!is_object($this->CopyPasteHandler)){
712 return("");
713 }
715 /* Add a single entry to queue */
716 if($s_action == "cut" || $s_action == "copy"){
718 /* Cleanup object queue */
719 $this->CopyPasteHandler->cleanup_queue();
720 $dn = $this->grouplist[$s_entry]['dn'];
721 $this->CopyPasteHandler->add_to_queue($dn,$s_action,"grouptabs","GROUPTABS","groups");
722 }
725 /* Add entries to queue */
726 if($s_action == "copy_multiple" || $s_action == "cut_multiple"){
728 /* Cleanup object queue */
729 $this->CopyPasteHandler->cleanup_queue();
731 /* Add new entries to CP queue */
732 foreach($this->list_get_selected_items() as $id){
733 $dn = $this->grouplist[$id]['dn'];
735 if($s_action == "copy_multiple"){
736 $this->CopyPasteHandler->add_to_queue($dn,"copy","grouptabs","GROUPTABS","groups");
737 }
738 if($s_action == "cut_multiple"){
739 $this->CopyPasteHandler->add_to_queue($dn,"cut","grouptabs","GROUPTABS","groups");
740 }
741 }
742 }
744 /* Start pasting entries */
745 if($s_action == "editPaste"){
746 $this->start_pasting_copied_objects = TRUE;
747 }
749 /* Return C&P dialog */
750 if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
752 /* Get dialog */
753 $data = $this->CopyPasteHandler->execute();
754 $this->CopyPasteHandler->SetVar("base",$this->DivListGroup->selectedBase);
756 /* Return dialog data */
757 if(!empty($data)){
758 return($data);
759 }
760 }
762 /* Automatically disable status for pasting */
763 if(!$this->CopyPasteHandler->entries_queued()){
764 $this->start_pasting_copied_objects = FALSE;
765 }
766 return("");
767 }
770 /* Save data to object */
771 function save_object()
772 {
773 $this->DivListGroup->save_object();
774 if(is_object($this->CopyPasteHandler)){
775 $this->CopyPasteHandler->save_object();
776 }
777 }
780 function remove_lock()
781 {
782 if (isset($this->grouptab->dn)){
783 del_lock ($this->grouptab->dn);
784 }
785 if(isset($this->dn) && !empty($this->dn) && $this->dn != "new"){
786 del_lock($this->dn);
787 }
788 if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
789 del_lock($this->dns);
790 }
791 }
794 function remove_from_parent()
795 {
796 /* Optionally execute a command after we're done */
797 $this->postremove();
798 }
801 /* Save to LDAP */
802 function save()
803 {
804 /* Optionally execute a command after we're done */
805 $this->postcreate();
806 }
808 /* Unused functions */
809 function check() { }
810 function adapt_from_template($dn, $skip= array()) { }
811 function password_change_needed() { }
812 }
813 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
814 ?>