Code

38ff24b241628f7977fe4e01d73b973621ef1aad
[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;
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_value("enablecopypaste") == "true"){
48       $this->CopyPasteHandler = new CopyPasteHandler($this->config);
49     }
50     
51     /* Detect if we have to display the primary group checkbox */
52     $tmp = "";
53     if ($this->config->get_cfg_value("noprimarygroup") == "true"){
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));
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 {
459         
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     }
511     
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)){
537         if (!$this->grouptab->by_object[$this->grouptab->current]->dialog){
538           $display.= "<p style=\"text-align:right\">\n";
539           $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
540           $display.= "&nbsp;\n";
541           if ($this->dn != "new"){
542             $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
543             $display.= "&nbsp;\n";
544           }
545           $display.= "<input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
546           $display.= "</p>";
547         }
548       }
549       return ($display);
550     }
553     /* Check if there is a snapshot dialog open */
554     $base = $this->DivListGroup->selectedBase;
555     if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
556       return($str);
557     }
558    
559     /* Display dialog with group list */
560     $this->DivListGroup->parent = $this;
561     $this->DivListGroup->execute();
563     /* Add departments if subsearch is disabled */
564     if(!$this->DivListGroup->SubSearch){
565       $this->DivListGroup->AddDepartments($this->DivListGroup->selectedBase,4,1);
566     }
567     $this->reload ();
568     $this->DivListGroup->setEntries($this->grouplist);
569     return($this->DivListGroup->Draw());
570   }
573   /* Return departments, that will be included within snapshot detection */
574   function get_used_snapshot_bases()
575   {
576     return(array(get_groups_ou().$this->DivListGroup->selectedBase));
577   }
580   function list_get_selected_items()
581   {
582     $ids = array();
583     foreach($_POST as $name => $value){
584       if(preg_match("/^item_selected_[0-9]*$/",$name)){
585         $id   = preg_replace("/^item_selected_/","",$name);
586         $ids[$id] = $id;
587       }
588     }
589     return($ids);
590   }
593   function reload($CreatePosixsList=false)
594   {
595     $this->grouplist        = array();
596     $primaries              = array();
597     $functional             = array();
598     $error= $error2         = "";
599     $filter                 = "(objectclass=posixGroup)";
601     $base                   = $this->DivListGroup->selectedBase;
602     $Regex                  = $this->DivListGroup->Regex;
603     $UserRegex              = $this->DivListGroup->UserRegex;
604     $SubSearch              = $this->DivListGroup->SubSearch;
605     $ShowPrimaryGroups      = $this->DivListGroup->ShowPrimaryGroups;
606     $ShowSambaGroups        = $this->DivListGroup->ShowSambaGroups;
607     $ShowApplicationGroups  = $this->DivListGroup->ShowApplicationGroups;
608     $ShowMailGroups         = $this->DivListGroup->ShowMailGroups;
609     $ShowFunctionalGroups   = $this->DivListGroup->ShowFunctionalGroups;
611     /* Prepare ldap class */
612     $ldap= $this->config->get_ldap_link();
613     $ldap->cd($base);
614     $ldap->set_size_limit(session::get('size_limit'));
617     /********************
618       Create filter depending on selected checkboxes 
619      ********************/
621     /* Add application groups */
622     if ($ShowApplicationGroups){
623       $filter.= "(objectClass=gosaApplicationGroup)";
624     }
625     
626     /* Add Mail Groups */
627     if ($ShowMailGroups){
628       $filter.= "(objectClass=gosaMailAccount)";
629     }
631     $sfilter= "";
632     if ($this->config->get_cfg_value("sambaversion") == 3){
633       if (!$ShowPrimaryGroups){
634         $sfilter= "(objectClass=sambaGroupMapping)";
635       } elseif ($ShowSambaGroups){
636         $filter.= "(objectClass=sambaGroupMapping)";
637       }
638     }
640     /* Prepare filter for given Regex && UserRegex */
641     if ($filter != ""){
642       $filter= "(&(cn=$Regex)(objectClass=posixGroup)(|$filter))";
643       if ($UserRegex != ""){
644         $filter= "(&(|(memberUID=".$UserRegex.")(cn=".$UserRegex."))$filter)";
645       }
646     }
649     /********************
650       Collect some groupids to be able to skip primary & functional groups 
651      ********************/
653     /* Collect primary groupIDs to show primary groups 
654        if this option is enabled in gosa conf && the checkbox is checked */  
655     if ($this->ShowPrimaryCheckBox){
656       $res = get_list("(&(uid=$Regex)(!(uid=*$))(objectClass=posixAccount)(gidNumber=*))",
657             "groups", $base,array("gidNumber", "cn"),  GL_SUBSEARCH);
658       foreach ($res as $attrs){
659         $primaries[$attrs['gidNumber'][0]]= $attrs['cn'][0];
660       }
661     }
663     /* Collect all GroupIDs from those groups which are functional.
664        Only perfrom this search if  ShowFunctionalGroups  is unchecked, else leave arre empty  */ 
665     $ff = "(&(cn=$Regex)(objectClass=posixGroup)(!(|(objectClass=gosaMailAccount)(objectClass=gosaApplicationGroup)$sfilter)))";
666     if ($SubSearch){
667       $res = get_sub_list($ff, "groups",get_groups_ou(), $base,array("gidNumber", "cn", "description"), GL_SUBSEARCH);
668     } else {
669       $res = get_sub_list($ff, "groups",get_groups_ou(), $base,array("gidNumber", "cn", "description"), GL_NONE);
670     }
671     foreach($res as $attrs){
672       if (!isset($primaries[$attrs['gidNumber'][0]])){
673         $functional[$attrs['gidNumber'][0]]= $attrs['gidNumber'][0];
674       }
675     }
676  
677     /********************
678       Search for the prepared filter 
679      ********************/
680    
681     /* Attributes to search for */    
682     $attrs = array("cn", "description", "gidNumber", "objectClass");
683  
684     /* If subsearch is activated search for subobjects too */
685     $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
686     if(!empty($tmp)){
687       $attrs [] = "FAIrelease";
688     }
690     if ($SubSearch){
691       $res= get_sub_list($filter, "groups",get_groups_ou(), $base, $attrs, GL_SIZELIMIT| GL_SUBSEARCH);
692     } else {
693       $res= get_sub_list($filter, "groups",get_groups_ou(), get_groups_ou().$base, $attrs, GL_SIZELIMIT);
694     }
696     /* Sort values into grouplist*/
697     $tmp = $tmp2 = array();
698     foreach ($res as $value){
699       /* Skip functional groups if checkbox isn't checked */
700       if (!$ShowFunctionalGroups && isset($functional[$value['gidNumber'][0]])){
701         continue;
702       }
703       
704       /* If gidNumber is in $primaries skip this entry */
705       if (($ShowPrimaryGroups)   ||   (!$ShowPrimaryGroups && !isset($primaries[$value['gidNumber'][0]]))){
706         $tmp2[$value['cn'][0]] = $value;
707         $tmp [$value['cn'][0]] = $value['cn'][0];
708       }
709     }
710     natcasesort($tmp);
711     foreach($tmp as $name){
712       $this->grouplist[] = $tmp2[$name]; 
713     }
714     reset ($this->grouplist);
715   }
718   function copyPasteHandling_from_queue($s_action,$s_entry)
719   {
720     /* Check if Copy & Paste is disabled */
721     if(!is_object($this->CopyPasteHandler)){
722       return("");
723     }
725     $ui = get_userinfo();
727     /* Add a single entry to queue */
728     if($s_action == "cut" || $s_action == "copy"){
730       /* Cleanup object queue */
731       $this->CopyPasteHandler->cleanup_queue();
732       $dn = $this->grouplist[$s_entry]['dn'];
733       if($s_action == "copy" && $ui->is_copyable($dn,"groups","group")){
734         $this->CopyPasteHandler->add_to_queue($dn,$s_action,"grouptabs","GROUPTABS","groups");
735       }
736       if($s_action == "cut" && $ui->is_cutable($dn,"groups","group")){
737         $this->CopyPasteHandler->add_to_queue($dn,$s_action,"grouptabs","GROUPTABS","groups");
738       }
740     }
743     /* Add entries to queue */
744     if($s_action == "copy_multiple" || $s_action == "cut_multiple"){
746       /* Cleanup object queue */
747       $this->CopyPasteHandler->cleanup_queue();
749       /* Add new entries to CP queue */
750       foreach($this->list_get_selected_items() as $id){
751         $dn = $this->grouplist[$id]['dn'];
753         if($s_action == "copy_multiple" && $ui->is_copyable($dn,"groups","group")){
754           $this->CopyPasteHandler->add_to_queue($dn,"copy","grouptabs","GROUPTABS","groups");
755         }
756         if($s_action == "cut_multiple" && $ui->is_cutable($dn,"groups","group")){
757           $this->CopyPasteHandler->add_to_queue($dn,"cut","grouptabs","GROUPTABS","groups");
758         }
759       }
760     }
762     /* Start pasting entries */
763     if($s_action == "editPaste"){
764       $this->start_pasting_copied_objects = TRUE;
765     }
767     /* Return C&P dialog */
768     if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
770       /* Get dialog */
771       $this->CopyPasteHandler->SetVar("base",$this->DivListGroup->selectedBase);
772       $data = $this->CopyPasteHandler->execute();
774       /* Return dialog data */
775       if(!empty($data)){
776         return($data);
777       }
778     }
780     /* Automatically disable status for pasting */
781     if(!$this->CopyPasteHandler->entries_queued()){
782       $this->start_pasting_copied_objects = FALSE;
783     }
784     return("");
785   }
788   /* Save data to object */
789   function save_object()
790   {
791     $this->DivListGroup->save_object();
792     if(is_object($this->CopyPasteHandler)){
793       $this->CopyPasteHandler->save_object();
794     }
795   }
798   function remove_lock()
799   {
800     if (isset($this->grouptab->dn)){
801       del_lock ($this->grouptab->dn);
802     }
803     if(isset($this->dn) && !empty($this->dn) && $this->dn != "new"){
804       del_lock($this->dn);
805     }
806     if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
807       del_lock($this->dns);
808     }
809   }
812   function remove_from_parent()
813   {
814     /* Optionally execute a command after we're done */
815     $this->postremove();
816   }
819   /* Save to LDAP */
820   function save()
821   {
822     /* Optionally execute a command after we're done */
823     $this->postcreate();
824   }
826   /* Unused functions  */
827   function check()  { }
828   function adapt_from_template($dn, $skip= array()) { }
829   function password_change_needed()  { }
831 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
832 ?>