Code

Updated management plugins, re-initialize after apply was pressed.
[gosa.git] / gosa-core / plugins / admin / groups / class_groupManagement.inc
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   function groupManagement (&$config, &$ui)
39   {
40     /* Save configuration for internal use */
41     $this->config = &$config;
42     $this->ui     = &$ui;
44     /* Copy & Paste enabled ?*/
45     if((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE']))){
46       $this->CopyPasteHandler = new CopyPasteHandler($this->config);
47     }
48     
49     /* Detect if we have to display the primary group checkbox */
50     $tmp = "";
51     if (isset($this->config->data['MAIN']['NOPRIMARYGROUP'])){
52       $tmp = $this->config->data['MAIN']['NOPRIMARYGROUP'];
53     }
54     if(preg_match("/true/i",$tmp)|| (preg_match("/yes/",$tmp))){ 
55       $this->ShowPrimaryCheckBox = false;
56     } else {
57       $this->ShowPrimaryCheckBox = true;
58     }
60     /* Create dialog object */
61     $this->DivListGroup = new divListGroup($this->config,$this);
62     $this->DivListGroup->DisableCheckBox("ShowPrimaryGroups",$this->ShowPrimaryCheckBox);
63   }
66   function execute()
67   {
68         /* Call parent execute */
69         plugin::execute();
71     /* Store these posts if the current object is locked (used by somebody else)*/
72     session::set('LOCK_VARS_TO_USE',array("/^act$/","/^id$/","/^group_edit_/","/^group_del_/","/^item_selected/","/^remove_multiple_groups/","/^multiple_edit/","/menu_action/"));
74     /* Save data */
75     $s_action   = "";
76     $s_entry    = "";
78     /* Test Posts */
79     foreach($_POST as $key => $val){
80       // Post for delete
81       if(preg_match("/^group_del.*/",$key)){
82         $s_action = "del";
83         $s_entry  = preg_replace("/group_".$s_action."_/i","",$key);
84         // Post for edit
85       }elseif(preg_match("/^group_edit_.*/",$key)){
86         $s_action="edit";
87         $s_entry  = preg_replace("/group_".$s_action."_/i","",$key);
88         // Post for new
89       }elseif(preg_match("/^group_new.*/",$key)){
90         $s_action="new";
91       }elseif(preg_match("/^dep_home.*/i",$key)){
92         $s_action="home";
93       }elseif(preg_match("/^group_tplnew.*/i",$key)){
94         $s_action="new_tpl";
95       }elseif(preg_match("/^group_chgpw.*/i",$key)){
96         $s_action="change_pw";
97         $s_entry  = preg_replace("/group_chgpw_/i","",$key);
98       }elseif(preg_match("/_group_edit_/",$key)){
99         $type = preg_replace("/_group_edit_.*$/","",$key);
100         $s_action="edit";
101         $s_entry  = preg_replace("/".$type."_group_edit_/i","",$key); 
102         $_POST['arg'] = $type;
103       }elseif(preg_match("/^editPaste.*/i",$key)){
104         $s_action="editPaste";
105       }elseif(preg_match("/^copy_.*/",$key)){
106         $s_action="copy";
107         $s_entry  = preg_replace("/^copy_/i","",$key);
108       }elseif(preg_match("/^cut_.*/",$key)){
109         $s_action="cut";
110         $s_entry  = preg_replace("/^cut_/i","",$key);
111       }elseif(preg_match("/^remove_multiple_groups/",$key)){
112         $s_action="del_multiple";
113       }elseif(preg_match("/^multiple_copy_groups/",$key)){
114         $s_action = "copy_multiple";
115       }elseif(preg_match("/^multiple_cut_groups/",$key)){
116         $s_action = "cut_multiple";
117       }
118     }
119     $s_entry  = preg_replace("/_.$/","",$s_entry); 
121     /* Check for posted gets */
122     if((isset($_GET['act'])) && ($_GET['act'] == "edit_entry")){
123       $s_entry    = $_GET['id'];
124       $s_action = "edit";
125     }
127     /* handle C&P from layers menu */
128     if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){
129       $s_action = "copy_multiple";
130     }
131     if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){
132       $s_action = "cut_multiple";
133     }
134     if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){
135       $s_action = "editPaste";
136     }
138     /* Create options */
139     if(isset($_POST['menu_action']) && $_POST['menu_action'] == "group_new"){
140       $s_action = "new";
141     }
143     /* handle remove from layers menu */
144     if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){
145       $s_action = "del_multiple";
146     }
147     if(isset($_POST['menu_action']) && $_POST['menu_action'] == "multiple_edit"){
148       $s_action = "multiple_edit";
149     }
151     if(isset($_POST['menu_action']) && preg_match("/^event/",$_POST['menu_action'])){
152       $s_action = $_POST['menu_action'];
153     }
155     $smarty= get_smarty();
159     /********************
160       Create notification event
161      ********************/
163     if(preg_match("/^event_/",$s_action) && class_available("DaemonEvent")){
164       $ids = $this->list_get_selected_items();
165       $uids = array();
166       foreach($ids as $id){
167         $uids[] = $this->grouplist[$id]['cn'][0];
168       }
169       if(count($uids)){
170         $events = DaemonEvent::get_event_types(USER_EVENT);
171         $event = preg_replace("/^event_/","",$s_action);
172         if(isset($events['BY_CLASS'][$event])){
173           $type = $events['BY_CLASS'][$event];
174           $this->grouptab = new $type['CLASS_NAME']($this->config);
175           $this->grouptab->add_groups($uids);
176           $this->grouptab->set_type(TRIGGERED_EVENT);
177         }
178       }
179     }
181     /* Abort event dialog */
182     if(isset($_POST['abort_event_dialog'])){
183       $this->grouptab = FALSE;
184     }
186     /* Save event */
187     if(isset($_POST['save_event_dialog'])){
188       $this->grouptab->save_object();
189       $msgs = $this->grouptab->check();
190       if(count($msgs)){
191         msg_dialog::displayChecks($msgs);
192       }else{
193         $o_queue = new gosaSupportDaemon();
194         $o_queue->append($this->grouptab);
195         if($o_queue->is_error()){
196           msg_dialog::display(_("Infrastructure error"), msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
197         }else{
198           $this->grouptab = FALSE;
199         }
200       }
201     }
203     /* Display event */
204     if($this->grouptab instanceof DaemonEvent){
205       $this->grouptab->save_object();
206       return($this->grouptab->execute());
207     }
210     /********************
211       Copy & Paste Handling  ...
212      ********************/
214     /* Display the copy & paste dialog, if it is currently open */
215     $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
216     if($ret){
217       return($ret);
218     }
221     /********************
222       Create a new group  ...
223      ********************/
225     /* New group? */
226     if ($s_action=="new"){
228       /* Check create permissions */
229       $acl = $this->ui->get_permissions($this->DivListGroup->selectedBase,"groups/group");
230       if(preg_match("/c/",$acl)){
232         /* By default we set 'dn' to 'new', all relevant plugins will
233            react on this. */
234         $this->dn= "new";
236         /* Create new grouptab object */
237         $this->grouptab= new grouptabs($this->config, $this->config->data['TABS']['GROUPTABS'], $this->dn);
239         /* Set up the group ACL's for this 'dn' */
240         $this->grouptab->set_acl_base($this->DivListGroup->selectedBase);
241       }
242     }
245     /********************
246       Save Group Tab/Object Changes
247      ********************/
249     /* Finish group edit is triggered by the tabulator dialog, so
250        the user wants to save edited data. Check and save at this
251        point. */
252     if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->grouptab->config)) ){
254       /* Check tabs, will feed message array 
255          Save, or display error message? */
256       $message= $this->grouptab->check();
257       if (count($message) == 0){
259         /* Save user data to ldap */
260         $this->grouptab->save();
262         if (!isset($_POST['edit_apply'])){
263           /* Group has been saved successfully, remove lock from LDAP. */
264           if ($this->dn != "new"){
265             del_lock ($this->dn);
266           }
268           /* There's no page reload so we have to read new groups at this point. */
269           //$this->reload ();
270           unset ($this->grouptab);
271           $this->grouptab= NULL;
272           session::un_set('objectinfo');
273         }else{
275           /* Reinitialize tab */
276           if($this->grouptab instanceof tabs){
277             $this->grouptab->re_init();
278           }
279         }
280       } else {
281         /* Ok. There seem to be errors regarding to the tab data,
282            show message and continue as usual. */
283         msg_dialog::displayChecks($message);
284       }
285     }
288     /********************
289       Edit multiple entries
290      ********************/
292     /* User wants to edit data? */
293     if ($s_action == "multiple_edit" && !isset($this->grouptab->config)){
295       $this->dn = array();
296       foreach($this->list_get_selected_items() as $id){
297         $this->dn[] = $this->grouplist[$id]['dn'];;
298       }
299       $tmp = new multi_plug($this->config,"grouptabs",$this->config->data['TABS']['GROUPTABS'],
300             $this->dn,$this->DivListGroup->selectedBase,"groups");
301       if ($tmp->entries_locked()){
302         return($tmp->display_lock_message());
303       }
304       $tmp->lock_entries($this->ui->dn);
305       if($tmp->multiple_available()){
306         $this->grouptab = $tmp;
307         session::set('objectinfo',$this->grouptab->get_object_info());
308       }
309     }
312     /********************
313       Edit existing group 
314      ********************/
316     /* User wants to edit data? */
317     if (($s_action=="edit") && (!isset($this->grouptab-> config))){
319       /* Get 'dn' from posted 'uid', must be unique */
320       $this->dn= $this->grouplist[trim($s_entry)]['dn'];
322       /* Check locking & lock entry if required */
323       $user = get_lock($this->dn);
324       if ($user != ""){
325         return(gen_locked_message ($user, $this->dn));
326       }
327       add_lock ($this->dn, $this->ui->dn);
329       /* Register grouptab to trigger edit dialog */
330       $this->grouptab= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $this->dn);
331       $this->grouptab->set_acl_base($this->dn);
332       session::set('objectinfo',$this->dn);
333     }
336     /********************
337       Delete MULTIPLE entries requested, display confirm dialog
338      ********************/
340     if ($s_action=="del_multiple"){
341       $ids = $this->list_get_selected_items();
343       if(count($ids)){
345         foreach($ids as $id){
346           $dn = $this->grouplist[$id]['dn'];
347           if (($user= get_lock($dn)) != ""){
348             return(gen_locked_message ($user, $dn));
349           }
350           $this->dns[$id] = $dn;
351         }
353         $dns_names = array();
354         foreach($this->dns as $dn){
355           add_lock ($dn, $this->ui->dn);
356           $dns_names[] =@LDAP::fix($dn);
357         }
359         /* Lock the current entry, so nobody will edit it during deletion */
360         $smarty->assign("info", msgPool::deleteInfo($dns_names,_("group")));
361         $smarty->assign("multiple", true);
362         return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
363       }
364     }
367     /********************
368       Delete MULTIPLE entries confirmed
369      ********************/
371       /* Confirmation for deletion has been passed. Groups should be deleted. */
372       if (isset($_POST['delete_multiple_groups_confirm'])){
374         /* Remove user by user and check acls before removeing them */
375         foreach($this->dns as $key => $dn){
377           /* Load permissions for selected 'dn' and check if
378              we're allowed to remove this 'dn' */
379           $acl = $this->ui->get_permissions($dn,"groups/group");
380           if(preg_match("/d/",$acl)){
382             /* Delete request is permitted, perform LDAP action */
383             $this->grouptab= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $dn);
384             $this->grouptab->set_acl_base($dn);
385             $this->grouptab->delete ();
386             unset ($this->grouptab);
387             $this->grouptab= NULL;
389           } else {
391             /* Normally this shouldn't be reached, send some extra
392                logs to notify the administrator */
393             msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
394             new log("security","groups/".get_class($this),$dn,array(),"Tried to trick deletion.");
395           }
396           /* Remove lock file after successfull deletion */
397           del_lock ($dn);
398           unset($this->dns[$key]);
399         }
400       }
403       /********************
404         Delete MULTIPLE entries Canceled
405        ********************/
407       /* Remove lock */
408     if(isset($_POST['delete_multiple_user_cancel'])){
409       foreach($this->dns as $key => $dn){
410         del_lock ($dn);
411         unset($this->dns[$key]);
412       }
413     }
416     /********************
417       Delete group 
418      ********************/
420     /* Remove group was requested */
421     if ($s_action=="del"){
423       /* Get 'dn' from posted 'uid' */
424       $this->dn= $this->grouplist[trim($s_entry)]['dn'];
426       /* Load permissions for selected 'dn' and check if
427          we're allowed to remove this 'dn' */
428       $acl = $this->ui->get_permissions($this->dn,"groups/group");
429       if(preg_match("/d/",$acl)){
431         /* Check locking, save current plugin in 'back_plugin', so
432            the dialog knows where to return. */
433         if (($user= get_lock($this->dn)) != ""){
434           return(gen_locked_message ($user, $this->dn));
435         }
437         /* Lock the current entry, so nobody will edit it during deletion */
438         add_lock ($this->dn, $this->ui->dn);
439         $smarty->assign("info", msgPool::deleteInfo(@LDAP::fix($this->dn),_("group")));
440         $smarty->assign("multiple", false);
441         return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
443       } else {
444         
445         /* Obviously the user isn't allowed to delete. Show message and clean session. */
446         msg_dialog::display(_("Permission error"), msgPool::permDelete());
447       }
448     }
451     /********************
452       Delete group confirmed  
453      ********************/
455     /* Confirmation for deletion has been passed. Group should be deleted. */
456     if (isset($_POST['delete_group_confirm'])){
458       /* Some nice guy may send this as POST, so we've to check
459          for the permissions again. */
460       $acl = $this->ui->get_permissions($this->dn,"groups/group");
461       if(preg_match("/d/",$acl)){
463         /* Delete request is permitted, perform LDAP action */
464         $this->grouptab= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $this->dn);
465         $this->grouptab->set_acl_base($this->dn);
466         $this->grouptab->delete ();
467         unset ($this->grouptab);
468         $this->grouptab= NULL;
470         /* Group list has changed, reload it. */
471         //$this->reload ();
473       } else {
475         /* Normally this shouldn't be reached, send some extra
476            logs to notify the administrator */
477         msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
478         new log("security","groups/".get_class($this),$dn,array(),"Tried to trick deletion.");
479       }
481       /* Remove lock file after successfull deletion */
482       del_lock ($this->dn);
483       session::un_set('objectinfo');
484     }
487     /********************
488       Delete group canceled  
489      ********************/
491     /* Delete group canceled? */
492     if (isset($_POST['delete_cancel'])){
493       del_lock ($this->dn);
494       session::un_set('objectinfo');
495     }
496     
498     /********************
499       A dialog was canceled  
500      ********************/
502     /* Cancel dialogs */
503     if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){
504       if(isset($this->grouptab->dn)){
505         del_lock ($this->grouptab->dn);
506       }
507       unset ($this->grouptab);
508       $this->grouptab= NULL;
509       session::un_set('objectinfo');
510     }
513     /********************
514       If there is currently a dialog open, display it
515      ********************/
517     /* Show tab dialog if object is present */
518     if (isset($this->grouptab->config)){
519       $display= $this->grouptab->execute();
521       /* Don't show buttons if tab dialog requests this */
522       if(isset($this->grouptab->by_object)){
523         if (!$this->grouptab->by_object[$this->grouptab->current]->dialog){
524           $display.= "<p style=\"text-align:right\">\n";
525           $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
526           $display.= "&nbsp;\n";
527           if ($this->dn != "new"){
528             $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
529             $display.= "&nbsp;\n";
530           }
531           $display.= "<input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
532           $display.= "</p>";
533         }
534       }
535       return ($display);
536     }
539     /* Check if there is a snapshot dialog open */
540     $base = $this->DivListGroup->selectedBase;
541     if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
542       return($str);
543     }
544    
545     /* Display dialog with group list */
546     $this->DivListGroup->parent = $this;
547     $this->DivListGroup->execute();
549     /* Add departments if subsearch is disabled */
550     if(!$this->DivListGroup->SubSearch){
551       $this->DivListGroup->AddDepartments($this->DivListGroup->selectedBase,4,1);
552     }
553     $this->reload ();
554     $this->DivListGroup->setEntries($this->grouplist);
555     return($this->DivListGroup->Draw());
556   }
559   /* Return departments, that will be included within snapshot detection */
560   function get_used_snapshot_bases()
561   {
562     return(array(get_groups_ou().$this->DivListGroup->selectedBase));
563   }
566   function list_get_selected_items()
567   {
568     $ids = array();
569     foreach($_POST as $name => $value){
570       if(preg_match("/^item_selected_[0-9]*$/",$name)){
571         $id   = preg_replace("/^item_selected_/","",$name);
572         $ids[$id] = $id;
573       }
574     }
575     return($ids);
576   }
579   function reload($CreatePosixsList=false)
580   {
581     $this->grouplist        = array();
582     $primaries              = array();
583     $functional             = array();
584     $error= $error2         = "";
585     $filter                 = "(objectclass=posixGroup)";
587     $base                   = $this->DivListGroup->selectedBase;
588     $Regex                  = $this->DivListGroup->Regex;
589     $UserRegex              = $this->DivListGroup->UserRegex;
590     $SubSearch              = $this->DivListGroup->SubSearch;
591     $ShowPrimaryGroups      = $this->DivListGroup->ShowPrimaryGroups;
592     $ShowSambaGroups        = $this->DivListGroup->ShowSambaGroups;
593     $ShowApplicationGroups  = $this->DivListGroup->ShowApplicationGroups;
594     $ShowMailGroups         = $this->DivListGroup->ShowMailGroups;
595     $ShowFunctionalGroups   = $this->DivListGroup->ShowFunctionalGroups;
597     /* Prepare ldap class */
598     $ldap= $this->config->get_ldap_link();
599     $ldap->cd($base);
600     $ldap->set_size_limit(session::get('size_limit'));
603     /********************
604       Create filter depending on selected checkboxes 
605      ********************/
607     /* Add application groups */
608     if ($ShowApplicationGroups){
609       $filter.= "(objectClass=gosaApplicationGroup)";
610     }
611     
612     /* Add Mail Groups */
613     if ($ShowMailGroups){
614       $filter.= "(objectClass=gosaMailAccount)";
615     }
617     $sfilter= "";
618     if ($this->config->current['SAMBAVERSION'] == 3){
619       if (!$ShowPrimaryGroups){
620         $sfilter= "(objectClass=sambaGroupMapping)";
621       } elseif ($ShowSambaGroups){
622         $filter.= "(objectClass=sambaGroupMapping)";
623       }
624     }
626     /* Prepare filter for given Regex && UserRegex */
627     if ($filter != ""){
628       $filter= "(&(cn=$Regex)(objectClass=posixGroup)(|$filter))";
629       if ($UserRegex != ""){
630         $filter= "(&(|(memberUID=".$UserRegex.")(cn=".$UserRegex."))$filter)";
631       }
632     }
635     /********************
636       Collect some groupids to be able to skip primary & functional groups 
637      ********************/
639     /* Collect primary groupIDs to show primary groups 
640        if this option is enabled in gosa conf && the checkbox is checked */  
641     if ($this->ShowPrimaryCheckBox){
642       $res = get_list("(&(uid=$Regex)(!(uid=*$))(objectClass=posixAccount)(gidNumber=*))",
643             "groups", $base,array("gidNumber", "cn"),  GL_SUBSEARCH);
644       foreach ($res as $attrs){
645         $primaries[$attrs['gidNumber'][0]]= $attrs['cn'][0];
646       }
647     }
649     /* Collect all GroupIDs from those groups which are functional.
650        Only perfrom this search if  ShowFunctionalGroups  is unchecked, else leave arre empty  */ 
651     $ff = "(&(cn=$Regex)(objectClass=posixGroup)(!(|(objectClass=gosaMailAccount)(objectClass=gosaApplicationGroup)$sfilter)))";
652     if ($SubSearch){
653       $res = get_sub_list($ff, "groups",get_groups_ou(), $base,array("gidNumber", "cn", "description"), GL_SUBSEARCH);
654     } else {
655       $res = get_sub_list($ff, "groups",get_groups_ou(), $base,array("gidNumber", "cn", "description"), GL_NONE);
656     }
657     foreach($res as $attrs){
658       if (!isset($primaries[$attrs['gidNumber'][0]])){
659         $functional[$attrs['gidNumber'][0]]= $attrs['gidNumber'][0];
660       }
661     }
662  
663     /********************
664       Search for the prepared filter 
665      ********************/
666    
667     /* Attributes to search for */    
668     $attrs = array("cn", "description", "gidNumber", "objectClass");
669  
670     /* If subsearch is activated search for subobjects too */
671     $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
672     if(!empty($tmp)){
673       $attrs [] = "FAIrelease";
674     }
676     if ($SubSearch){
677       $res= get_sub_list($filter, "groups",get_groups_ou(), $base, $attrs, GL_SIZELIMIT| GL_SUBSEARCH);
678     } else {
679       $res= get_sub_list($filter, "groups",get_groups_ou(), get_groups_ou().$base, $attrs, GL_SIZELIMIT);
680     }
682     /* Sort values into grouplist*/
683     $tmp = $tmp2 = array();
684     foreach ($res as $value){
685       /* Skip functional groups if checkbox isn't checked */
686       if (!$ShowFunctionalGroups && isset($functional[$value['gidNumber'][0]])){
687         continue;
688       }
689       
690       /* If gidNumber is in $primaries skip this entry */
691       if (($ShowPrimaryGroups)   ||   (!$ShowPrimaryGroups && !isset($primaries[$value['gidNumber'][0]]))){
692         $tmp2[$value['cn'][0]] = $value;
693         $tmp [$value['cn'][0]] = $value['cn'][0];
694       }
695     }
696     natcasesort($tmp);
697     foreach($tmp as $name){
698       $this->grouplist[] = $tmp2[$name]; 
699     }
700     reset ($this->grouplist);
701   }
704   function copyPasteHandling_from_queue($s_action,$s_entry)
705   {
706     /* Check if Copy & Paste is disabled */
707     if(!is_object($this->CopyPasteHandler)){
708       return("");
709     }
711     /* Add a single entry to queue */
712     if($s_action == "cut" || $s_action == "copy"){
714       /* Cleanup object queue */
715       $this->CopyPasteHandler->cleanup_queue();
716       $dn = $this->grouplist[$s_entry]['dn'];
717       $this->CopyPasteHandler->add_to_queue($dn,$s_action,"grouptabs","GROUPTABS","groups");
718     }
721     /* Add entries to queue */
722     if($s_action == "copy_multiple" || $s_action == "cut_multiple"){
724       /* Cleanup object queue */
725       $this->CopyPasteHandler->cleanup_queue();
727       /* Add new entries to CP queue */
728       foreach($this->list_get_selected_items() as $id){
729         $dn = $this->grouplist[$id]['dn'];
731         if($s_action == "copy_multiple"){
732           $this->CopyPasteHandler->add_to_queue($dn,"copy","grouptabs","GROUPTABS","groups");
733         }
734         if($s_action == "cut_multiple"){
735           $this->CopyPasteHandler->add_to_queue($dn,"cut","grouptabs","GROUPTABS","groups");
736         }
737       }
738     }
740     /* Start pasting entries */
741     if($s_action == "editPaste"){
742       $this->start_pasting_copied_objects = TRUE;
743     }
745     /* Return C&P dialog */
746     if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
748       /* Get dialog */
749       $data = $this->CopyPasteHandler->execute();
750       $this->CopyPasteHandler->SetVar("base",$this->DivListGroup->selectedBase);
752       /* Return dialog data */
753       if(!empty($data)){
754         return($data);
755       }
756     }
758     /* Automatically disable status for pasting */
759     if(!$this->CopyPasteHandler->entries_queued()){
760       $this->start_pasting_copied_objects = FALSE;
761     }
762     return("");
763   }
766   /* Save data to object */
767   function save_object()
768   {
769     $this->DivListGroup->save_object();
770     if(is_object($this->CopyPasteHandler)){
771       $this->CopyPasteHandler->save_object();
772     }
773   }
776   function remove_lock()
777   {
778     if (isset($this->grouptab->dn)){
779       del_lock ($this->grouptab->dn);
780     }
781   }
784   function remove_from_parent()
785   {
786     /* Optionally execute a command after we're done */
787     $this->postremove();
788   }
791   /* Save to LDAP */
792   function save()
793   {
794     /* Optionally execute a command after we're done */
795     $this->postcreate();
796   }
798   /* Unused functions  */
799   function check()  { }
800   function adapt_from_template($dn, $skip= array()) { }
801   function password_change_needed()  { }
803 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
804 ?>