4137ca8f9b8f0497f242e07b0b40df385ff5d3d1
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((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)){
346 $disallowed = array();
347 $this->dns = array();
348 foreach($ids as $id){
349 $dn = $this->grouplist[$id]['dn'];
350 $acl = $this->ui->get_permissions($dn, "groups/group");
351 if(preg_match("/d/",$acl)){
352 $this->dns[$id] = $dn;
353 }else{
354 $disallowed[] = $dn;
355 }
356 }
358 if(count($disallowed)){
359 msg_dialog::display(_("Permission"),msgPool::permDelete($disallowed),INFO_DIALOG);
360 }
362 if(count($this->dns)){
364 /* Check locks */
365 if ($user= get_multiple_locks($this->dns)){
366 return(gen_locked_message($user,$this->dns));
367 }
369 $dns_names = array();
370 foreach($this->dns as $dn){
371 $dns_names[] =@LDAP::fix($dn);
372 }
373 add_lock ($this->dns, $this->ui->dn);
375 /* Lock the current entry, so nobody will edit it during deletion */
376 $smarty->assign("info", msgPool::deleteInfo($dns_names,_("group")));
377 $smarty->assign("multiple", true);
378 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
379 }
380 }
381 }
384 /********************
385 Delete MULTIPLE entries confirmed
386 ********************/
388 /* Confirmation for deletion has been passed. Groups should be deleted. */
389 if (isset($_POST['delete_multiple_groups_confirm'])){
391 /* Remove user by user and check acls before removeing them */
392 foreach($this->dns as $key => $dn){
394 /* Load permissions for selected 'dn' and check if
395 we're allowed to remove this 'dn' */
396 $acl = $this->ui->get_permissions($dn,"groups/group");
397 if(preg_match("/d/",$acl)){
399 /* Delete request is permitted, perform LDAP action */
400 $this->grouptab= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $dn);
401 $this->grouptab->set_acl_base($dn);
402 $this->grouptab->delete ();
403 unset ($this->grouptab);
404 $this->grouptab= NULL;
406 } else {
408 /* Normally this shouldn't be reached, send some extra
409 logs to notify the administrator */
410 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
411 new log("security","groups/".get_class($this),$dn,array(),"Tried to trick deletion.");
412 }
413 }
415 /* Remove lock file after successfull deletion */
416 $this->remove_lock();
417 $this->dns = array();
418 }
421 /********************
422 Delete MULTIPLE entries Canceled
423 ********************/
425 /* Remove lock */
426 if(isset($_POST['delete_multiple_group_cance'])){
428 /* Remove lock file after successfull deletion */
429 $this->remove_lock();
430 $this->dns = array();
431 }
434 /********************
435 Delete group
436 ********************/
438 /* Remove group was requested */
439 if ($s_action=="del"){
441 /* Get 'dn' from posted 'uid' */
442 $this->dn= $this->grouplist[trim($s_entry)]['dn'];
444 /* Load permissions for selected 'dn' and check if
445 we're allowed to remove this 'dn' */
446 $acl = $this->ui->get_permissions($this->dn,"groups/group");
447 if(preg_match("/d/",$acl)){
449 /* Check locking, save current plugin in 'back_plugin', so
450 the dialog knows where to return. */
451 if (($user= get_lock($this->dn)) != ""){
452 return(gen_locked_message ($user, $this->dn));
453 }
455 /* Lock the current entry, so nobody will edit it during deletion */
456 add_lock ($this->dn, $this->ui->dn);
457 $smarty->assign("info", msgPool::deleteInfo(@LDAP::fix($this->dn),_("group")));
458 $smarty->assign("multiple", false);
459 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
461 } else {
463 /* Obviously the user isn't allowed to delete. Show message and clean session. */
464 msg_dialog::display(_("Permission error"), msgPool::permDelete());
465 }
466 }
469 /********************
470 Delete group confirmed
471 ********************/
473 /* Confirmation for deletion has been passed. Group should be deleted. */
474 if (isset($_POST['delete_group_confirm'])){
476 /* Some nice guy may send this as POST, so we've to check
477 for the permissions again. */
478 $acl = $this->ui->get_permissions($this->dn,"groups/group");
479 if(preg_match("/d/",$acl)){
481 /* Delete request is permitted, perform LDAP action */
482 $this->grouptab= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $this->dn);
483 $this->grouptab->set_acl_base($this->dn);
484 $this->grouptab->delete ();
485 unset ($this->grouptab);
486 $this->grouptab= NULL;
488 /* Group list has changed, reload it. */
489 //$this->reload ();
491 } else {
493 /* Normally this shouldn't be reached, send some extra
494 logs to notify the administrator */
495 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
496 new log("security","groups/".get_class($this),$dn,array(),"Tried to trick deletion.");
497 }
499 /* Remove lock file after successfull deletion */
500 $this->remove_lock();
501 session::un_set('objectinfo');
502 }
505 /********************
506 Delete group canceled
507 ********************/
509 /* Delete group canceled? */
510 if (isset($_POST['delete_cancel'])){
511 $this->remove_lock();
512 session::un_set('objectinfo');
513 }
516 /********************
517 A dialog was canceled
518 ********************/
520 /* Cancel dialogs */
521 if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){
522 if(isset($this->grouptab->dn)){
523 $this->remove_lock();
524 }
525 $this->grouptab= NULL;
526 session::un_set('objectinfo');
527 }
530 /********************
531 If there is currently a dialog open, display it
532 ********************/
534 /* Show tab dialog if object is present */
535 if (isset($this->grouptab->config)){
536 $display= $this->grouptab->execute();
538 /* Don't show buttons if tab dialog requests this */
539 if(isset($this->grouptab->by_object)){
540 if (!$this->grouptab->by_object[$this->grouptab->current]->dialog){
541 $display.= "<p style=\"text-align:right\">\n";
542 $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
543 $display.= " \n";
544 if ($this->dn != "new"){
545 $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
546 $display.= " \n";
547 }
548 $display.= "<input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
549 $display.= "</p>";
550 }
551 }
552 return ($display);
553 }
556 /* Check if there is a snapshot dialog open */
557 $base = $this->DivListGroup->selectedBase;
558 if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
559 return($str);
560 }
562 /* Display dialog with group list */
563 $this->DivListGroup->parent = $this;
564 $this->DivListGroup->execute();
566 /* Add departments if subsearch is disabled */
567 if(!$this->DivListGroup->SubSearch){
568 $this->DivListGroup->AddDepartments($this->DivListGroup->selectedBase,4,1);
569 }
570 $this->reload ();
571 $this->DivListGroup->setEntries($this->grouplist);
572 return($this->DivListGroup->Draw());
573 }
576 /* Return departments, that will be included within snapshot detection */
577 function get_used_snapshot_bases()
578 {
579 return(array(get_groups_ou().$this->DivListGroup->selectedBase));
580 }
583 function list_get_selected_items()
584 {
585 $ids = array();
586 foreach($_POST as $name => $value){
587 if(preg_match("/^item_selected_[0-9]*$/",$name)){
588 $id = preg_replace("/^item_selected_/","",$name);
589 $ids[$id] = $id;
590 }
591 }
592 return($ids);
593 }
596 function reload($CreatePosixsList=false)
597 {
598 $this->grouplist = array();
599 $primaries = array();
600 $functional = array();
601 $error= $error2 = "";
602 $filter = "(objectclass=posixGroup)";
604 $base = $this->DivListGroup->selectedBase;
605 $Regex = $this->DivListGroup->Regex;
606 $UserRegex = $this->DivListGroup->UserRegex;
607 $SubSearch = $this->DivListGroup->SubSearch;
608 $ShowPrimaryGroups = $this->DivListGroup->ShowPrimaryGroups;
609 $ShowSambaGroups = $this->DivListGroup->ShowSambaGroups;
610 $ShowApplicationGroups = $this->DivListGroup->ShowApplicationGroups;
611 $ShowMailGroups = $this->DivListGroup->ShowMailGroups;
612 $ShowFunctionalGroups = $this->DivListGroup->ShowFunctionalGroups;
614 /* Prepare ldap class */
615 $ldap= $this->config->get_ldap_link();
616 $ldap->cd($base);
617 $ldap->set_size_limit(session::get('size_limit'));
620 /********************
621 Create filter depending on selected checkboxes
622 ********************/
624 /* Add application groups */
625 if ($ShowApplicationGroups){
626 $filter.= "(objectClass=gosaApplicationGroup)";
627 }
629 /* Add Mail Groups */
630 if ($ShowMailGroups){
631 $filter.= "(objectClass=gosaMailAccount)";
632 }
634 $sfilter= "";
635 if ($this->config->current['SAMBAVERSION'] == 3){
636 if (!$ShowPrimaryGroups){
637 $sfilter= "(objectClass=sambaGroupMapping)";
638 } elseif ($ShowSambaGroups){
639 $filter.= "(objectClass=sambaGroupMapping)";
640 }
641 }
643 /* Prepare filter for given Regex && UserRegex */
644 if ($filter != ""){
645 $filter= "(&(cn=$Regex)(objectClass=posixGroup)(|$filter))";
646 if ($UserRegex != ""){
647 $filter= "(&(|(memberUID=".$UserRegex.")(cn=".$UserRegex."))$filter)";
648 }
649 }
652 /********************
653 Collect some groupids to be able to skip primary & functional groups
654 ********************/
656 /* Collect primary groupIDs to show primary groups
657 if this option is enabled in gosa conf && the checkbox is checked */
658 if ($this->ShowPrimaryCheckBox){
659 $res = get_list("(&(uid=$Regex)(!(uid=*$))(objectClass=posixAccount)(gidNumber=*))",
660 "groups", $base,array("gidNumber", "cn"), GL_SUBSEARCH);
661 foreach ($res as $attrs){
662 $primaries[$attrs['gidNumber'][0]]= $attrs['cn'][0];
663 }
664 }
666 /* Collect all GroupIDs from those groups which are functional.
667 Only perfrom this search if ShowFunctionalGroups is unchecked, else leave arre empty */
668 $ff = "(&(cn=$Regex)(objectClass=posixGroup)(!(|(objectClass=gosaMailAccount)(objectClass=gosaApplicationGroup)$sfilter)))";
669 if ($SubSearch){
670 $res = get_sub_list($ff, "groups",get_groups_ou(), $base,array("gidNumber", "cn", "description"), GL_SUBSEARCH);
671 } else {
672 $res = get_sub_list($ff, "groups",get_groups_ou(), $base,array("gidNumber", "cn", "description"), GL_NONE);
673 }
674 foreach($res as $attrs){
675 if (!isset($primaries[$attrs['gidNumber'][0]])){
676 $functional[$attrs['gidNumber'][0]]= $attrs['gidNumber'][0];
677 }
678 }
680 /********************
681 Search for the prepared filter
682 ********************/
684 /* Attributes to search for */
685 $attrs = array("cn", "description", "gidNumber", "objectClass");
687 /* If subsearch is activated search for subobjects too */
688 $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
689 if(!empty($tmp)){
690 $attrs [] = "FAIrelease";
691 }
693 if ($SubSearch){
694 $res= get_sub_list($filter, "groups",get_groups_ou(), $base, $attrs, GL_SIZELIMIT| GL_SUBSEARCH);
695 } else {
696 $res= get_sub_list($filter, "groups",get_groups_ou(), get_groups_ou().$base, $attrs, GL_SIZELIMIT);
697 }
699 /* Sort values into grouplist*/
700 $tmp = $tmp2 = array();
701 foreach ($res as $value){
702 /* Skip functional groups if checkbox isn't checked */
703 if (!$ShowFunctionalGroups && isset($functional[$value['gidNumber'][0]])){
704 continue;
705 }
707 /* If gidNumber is in $primaries skip this entry */
708 if (($ShowPrimaryGroups) || (!$ShowPrimaryGroups && !isset($primaries[$value['gidNumber'][0]]))){
709 $tmp2[$value['cn'][0]] = $value;
710 $tmp [$value['cn'][0]] = $value['cn'][0];
711 }
712 }
713 natcasesort($tmp);
714 foreach($tmp as $name){
715 $this->grouplist[] = $tmp2[$name];
716 }
717 reset ($this->grouplist);
718 }
721 function copyPasteHandling_from_queue($s_action,$s_entry)
722 {
723 /* Check if Copy & Paste is disabled */
724 if(!is_object($this->CopyPasteHandler)){
725 return("");
726 }
728 $ui = get_userinfo();
730 /* Add a single entry to queue */
731 if($s_action == "cut" || $s_action == "copy"){
733 /* Cleanup object queue */
734 $this->CopyPasteHandler->cleanup_queue();
735 $dn = $this->grouplist[$s_entry]['dn'];
736 if($s_action == "copy" && $ui->is_copyable($dn,"groups","group")){
737 $this->CopyPasteHandler->add_to_queue($dn,$s_action,"grouptabs","GROUPTABS","groups");
738 }
739 if($s_action == "cut" && $ui->is_cutable($dn,"groups","group")){
740 $this->CopyPasteHandler->add_to_queue($dn,$s_action,"grouptabs","GROUPTABS","groups");
741 }
743 }
746 /* Add entries to queue */
747 if($s_action == "copy_multiple" || $s_action == "cut_multiple"){
749 /* Cleanup object queue */
750 $this->CopyPasteHandler->cleanup_queue();
752 /* Add new entries to CP queue */
753 foreach($this->list_get_selected_items() as $id){
754 $dn = $this->grouplist[$id]['dn'];
756 if($s_action == "copy_multiple" && $ui->is_copyable($dn,"groups","group")){
757 $this->CopyPasteHandler->add_to_queue($dn,"copy","grouptabs","GROUPTABS","groups");
758 }
759 if($s_action == "cut_multiple" && $ui->is_cutable($dn,"groups","group")){
760 $this->CopyPasteHandler->add_to_queue($dn,"cut","grouptabs","GROUPTABS","groups");
761 }
762 }
763 }
765 /* Start pasting entries */
766 if($s_action == "editPaste"){
767 $this->start_pasting_copied_objects = TRUE;
768 }
770 /* Return C&P dialog */
771 if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
773 /* Get dialog */
774 $this->CopyPasteHandler->SetVar("base",$this->DivListGroup->selectedBase);
775 $data = $this->CopyPasteHandler->execute();
777 /* Return dialog data */
778 if(!empty($data)){
779 return($data);
780 }
781 }
783 /* Automatically disable status for pasting */
784 if(!$this->CopyPasteHandler->entries_queued()){
785 $this->start_pasting_copied_objects = FALSE;
786 }
787 return("");
788 }
791 /* Save data to object */
792 function save_object()
793 {
794 $this->DivListGroup->save_object();
795 if(is_object($this->CopyPasteHandler)){
796 $this->CopyPasteHandler->save_object();
797 }
798 }
801 function remove_lock()
802 {
803 if (isset($this->grouptab->dn)){
804 del_lock ($this->grouptab->dn);
805 }
806 if(isset($this->dn) && !empty($this->dn) && $this->dn != "new"){
807 del_lock($this->dn);
808 }
809 if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
810 del_lock($this->dns);
811 }
812 }
815 function remove_from_parent()
816 {
817 /* Optionally execute a command after we're done */
818 $this->postremove();
819 }
822 /* Save to LDAP */
823 function save()
824 {
825 /* Optionally execute a command after we're done */
826 $this->postcreate();
827 }
829 /* Unused functions */
830 function check() { }
831 function adapt_from_template($dn, $skip= array()) { }
832 function password_change_needed() { }
833 }
834 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
835 ?>