Code

Updated ogroup management.
[gosa.git] / gosa-core / plugins / admin / ogroups / class_ogroupManagement.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 ogroupManagement extends plugin
24 {
25   /* Definitions */
26   var $plHeadline= "Object groups";
27   var $plDescription= "Manage object groups";
29   /* attribute list for save action */
30   var $attributes= array();
31   var $objectclasses= array();
32   var $obtypes= array();
33   var $ogroup;
35   var $CopyPasteHandler = NULL;
36   var $DivListOGroup    = NULL;
37   var $start_pasting_copied_objects = FALSE;
39   var $dns = array();
40   var $acl_module   = array("ogroups");  
42   function ogroupManagement (&$config, $dn= NULL)
43   {
44     /* Include config object */
45     $this->config= &$config;
46     $this->ui= get_userinfo();
48     /* Copy & Paste enabled ?
49      */
50     if ($this->config->get_cfg_value("copyPaste") == "true"){
51       $this->CopyPasteHandler = new CopyPasteHandler($this->config);
52     }
54     /* Div lsit management */
55     $this->DivListOGroup = new divListOGroup($this->config,$this);
56   }
58   function execute()
59   {
60     /* Call parent execute */
61     plugin::execute();
63     /****************
64       Variable intialisation && Check posts for commands  
65      ****************/
67     session::set('LOCK_VARS_TO_USE',array("/^act$/","/^id$/","/^group_edit_/","/^group_del_/","/^item_selected/","/^remove_multiple_ogroups/","/^menu_action/"));
69     $smarty     = get_smarty();
70     $s_action   = "";
71     $s_entry    = "";
73     /* Test Posts */
74     foreach($_POST as $key => $val){
75       // Post for delete
76       if(preg_match("/^group_del.*/",$key)){
77         $s_action = "del";
78         $s_entry  = preg_replace("/^group_".$s_action."_/i","",$key);
79         // Post for edit
80       }elseif(preg_match("/^group_edit_.*/",$key)){
81         $s_action="edit";
82         $s_entry  = preg_replace("/^group_".$s_action."_/i","",$key);
83         // Post for new
84       }elseif(preg_match("/^group_new.*/",$key)){
85         $s_action="new";
86       }elseif(preg_match("/^editPaste.*/i",$key)){
87         $s_action="editPaste";
88       }elseif(preg_match("/^copy_.*/",$key)){
89         $s_action="copy";
90         $s_entry  = preg_replace("/^copy_/i","",$key);
91       }elseif(preg_match("/^cut_.*/",$key)){
92         $s_action="cut";
93         $s_entry  = preg_replace("/^cut_/i","",$key);
94       }elseif(preg_match("/^remove_multiple_ogroups/",$key)){
95         $s_action="del_multiple";
96       }elseif(preg_match("/^multiple_cut_ogroups/",$key)){
97         $s_action = "cut_multiple";
98       }elseif(preg_match("/^multiple_copy_ogroups/",$key)){
99         $s_action = "copy_multiple";
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       }
106     }
107     $s_entry  = preg_replace("/_.$/","",$s_entry);
109     // Edit if
110     if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
111       $s_action ="edit";
112       $s_entry  = $_GET['id'];
113     }
117     /* handle C&P from layers menu */
118     if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){
119       $s_action = "copy_multiple";
120     }
121     if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){
122       $s_action = "cut_multiple";
123     }
124     if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){
125       $s_action = "editPaste";
126     }
128     /* Create options */
129     if(isset($_POST['menu_action']) && $_POST['menu_action'] == "group_new"){
130       $s_action = "new";
131     }
133     /* handle remove from layers menu */
134     if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){
135       $s_action = "del_multiple";
136     }
138     /* Hanlde notification event requests */
139     if(isset($_POST['menu_action']) && preg_match("/^event/",$_POST['menu_action'])){
140       $s_action = $_POST['menu_action'];
141     }
144     /********************
145       Create notification event
146      ********************/
148     if(preg_match("/^event_/",$s_action) && class_available("DaemonEvent")){
150       /* Resolve the selected items to their corresponding uids and group names */
151       $ids = $this->list_get_selected_items();
152       $targets = array();
153       $m_list  = array();
154       $ldap = $this->config->get_ldap_link();
155   
156       // Collect selected ogroups
157       foreach($ids as $id){
158         $ogroup = $this->ogrouplist[$id]['cn'][0];
159         $ldap->search("(&(cn=".$ogroup.")(member=*))", array('member'));
160         while ($entry = $ldap->fetch()) {
161           $m_list[] = $entry;
162         }
163       }
165       // Collect object group member dns 
166       foreach($m_list as $entry){
167         $members = $entry['member'];
168         for($i=0;$i<$members['count'];$i++) {
170           // Fetch member object
171           $ldap->cat($members[$i], array('uid','cn','objectClass'));
172           if ($ldap->count() > 0) {
174             // Determine which type the object has 
175             $attrs = $ldap->fetch();
176             if (array_search('gosaAccount', $attrs['objectClass'])) {
177               $uid = $attrs['uid'][0];
178               $targets['USERS'][] = $uid;
179             }elseif (array_search('posixGroup', $attrs['objectClass'])) {
180               $group = $attrs['cn'][0];
181               $targets['GROUPS'][] = $group;
182             }
183           }
184         }
185       }
187       // We've at least one recipient 
188       if(count($targets)){
189         $events = DaemonEvent::get_event_types(USER_EVENT);
190         $event = preg_replace("/^event_/","",$s_action);
191         if(isset($events['BY_CLASS'][$event])){
192           $type = $events['BY_CLASS'][$event];
193           $this->ogroup = new $type['CLASS_NAME']($this->config);
194           $this->ogroup->add_targets($targets);
195           $this->ogroup->set_type(TRIGGERED_EVENT);
196         }
197       }
198     }
200     /* Abort event dialog */
201     if(isset($_POST['abort_event_dialog'])){
202       $this->ogroup = FALSE;
203     }
205     /* Save event */
206     if(isset($_POST['save_event_dialog'])){
207       $this->ogroup->save_object();
208       $msgs = $this->ogroup->check();
209       if (count($msgs)) {
210         msg_dialog::displayChecks($msgs);
211       }
212       else {
213         $o_queue = new gosaSupportDaemon();
214         $o_queue->append($this->ogroup);
215         if($o_queue->is_error()){
216           msg_dialog::display(_("Infrastructure error"), msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
217         }else{
218           $this->ogroup = FALSE;
219         }
220       }
221     }
223     /* Display event */
224     if($this->ogroup instanceof DaemonEvent){
225       $this->ogroup->save_object();
226       return($this->ogroup->execute());
227     }
230     /****************
231       Copy & Paste handling 
232      ****************/
234     /* Display the copy & paste dialog, if it is currently open */
235     $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
236     if($ret){
237       return($ret);
238     }
241     /***************
242       Create a new object group 
243      ****************/
245     /* New group? */
246     if ($s_action=="new"){
248       /* By default we set 'dn' to 'new', all relevant plugins will
249          react on this. */
250       $this->dn= "new";
252       /* Create new ogroup- object */
253       $this->ogroup= new ogrouptabs($this->config,$this->config->data['TABS']['OGROUPTABS'], $this->dn,"ogroups");
254       $this->ogroup->set_acl_base($this->DivListOGroup->selectedBase);
255     }
258     /********************
259       Delete MULTIPLE entries requested, display confirm dialog
260      ********************/
261     if ($s_action=="del_multiple"){
262       $ids = $this->list_get_selected_items();
264       if(count($ids)){
265         $this->dns = array();
266         $disallowed = array();
267         foreach($ids as $id){
268           $dn = $this->ogrouplist[$id]['dn'];
269           $acl = $this->ui->get_permissions($dn, "ogroups/ogroup");
270           if(preg_match("/d/",$acl)){
271             $this->dns[$id] = $dn;
272           }else{
273             $disallowed[] = $dn;
274           }
275         }
277         if(count($disallowed)){
278           msg_dialog::display(_("Permission"),msgPool::permDelete($disallowed),INFO_DIALOG);
279         }
281         if(count($this->dns)){
283           /* Check locks */
284           if ($user= get_multiple_locks($this->dns)){
285             return(gen_locked_message($user,$this->dns));
286           }
288           $dns_names = array();
289           foreach($this->dns as $dn){
290             $dns_names[] = LDAP::fix($dn);
291           }
293           add_lock ($this->dns, $this->ui->dn);
295           /* Lock the current entry, so nobody will edit it during deletion */
296           $smarty->assign("info", msgPool::deleteInfo($dns_names,_("object group")));
297           $smarty->assign("multiple", true);
298           return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
299         }
300       }
301     }
304     /********************
305       Delete MULTIPLE entries confirmed
306      ********************/
308     /* Confirmation for deletion has been passed. Users should be deleted. */
309     if (isset($_POST['delete_multiple_ogroup_confirm'])){
311       /* Remove user by user and check acls before removeing them */
312       foreach($this->dns as $key => $dn){
314         $acl = $this->ui->get_permissions($dn, "ogroups/ogroup");
315         if (preg_match('/d/', $acl)){
317           /* Delete request is permitted, perform LDAP action */
318           $this->ogroup= new ogrouptabs($this->config,$this->config->data['TABS']['OGROUPTABS'], $dn);
319           $this->ogroup->delete ();
320           unset ($this->ogroup);
321           $this->ogroup= NULL;
322         } else {
324           /* Normally this shouldn't be reached, send some extra
325              logs to notify the administrator */
326           msg_dialog::display(_("Permission error"), msgPool::permDelete(), INFO_DIALOG);
327           new log("security","ogroups/".get_class($this),$dn,array(),"Tried to trick deletion.");
328         }
329       }
331       /* Remove lock file after successfull deletion */
332       $this->remove_lock();
333       $this->dns = array();
334     }
337     /********************
338       Delete MULTIPLE entries Canceled
339      ********************/
341     /* Remove lock */
342     if(isset($_POST['delete_multiple_ogroup_cancel'])){
344       /* Remove lock file after successfull deletion */
345       $this->remove_lock();
346       $this->dns = array();
347     }
350     /****************
351       Delete object group
352      ****************/
354     if ($s_action=="del"){
356       /* Get 'dn' from posted 'uid' */
357       $this->dn= $this->ogrouplist[$s_entry]['dn'];
359       /* Load permissions for selected 'dn' and check if
360          we're allowed to remove this 'dn' */
361       $acl = $this->ui->get_permissions($this->dn,"ogroups/ogroup");
362       if(preg_match("/d/",$acl)){
364         /* Check locking, save current plugin in 'back_plugin', so
365            the dialog knows where to return. */
366         if (($user= get_lock($this->dn)) != ""){
367           return(gen_locked_message ($user, $this->dn));
368         }
370         /* Lock the current entry, so nobody will edit it during deletion */
371         add_lock ($this->dn, $this->ui->dn);
372         $smarty->assign("info", msgPool::deleteInfo(LDAP::fix($this->dn),_("object group")));
373         $smarty->assign("multiple", false);
374         return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
375       } else {
377         /* Obviously the user isn't allowed to delete. Show message and
378            clean session. */
379         msg_dialog::display(_("Permission error"), msgPool::permDelete(), INFO_DIALOG);
380       }
381     }
384     /****************
385       Delete confirmed 
386      ****************/
388     /* Confirmation for deletion has been passed. Group should be deleted. */
389     if (isset($_POST['delete_group_confirm'])){
391       /* Some nice guy may send this as POST, so we've to check
392          for the permissions again. */
393       $acl = $this->ui->get_permissions($this->dn,"ogroups/ogroup");
394       if(preg_match("/d/",$acl)){
396         /* Delete request is permitted, perform LDAP action */
397         $this->ogroup= new ogrouptabs($this->config,
398             $this->config->data['TABS']['OGROUPTABS'], $this->dn);
399         $this->ogroup->delete ();
400         unset ($this->ogroup);
401         $this->ogroup= NULL;
402       } else {
404         /* Normally this shouldn't be reached, send some extra
405            logs to notify the administrator */
406         msg_dialog::display(_("Permission error"), msgPool::permDelete(), INFO_DIALOG);
407         new log("security","ogroups/".get_class($this),$dn,array(),"Tried to trick deletion.");
408       }
410       /* Remove lock file after successfull deletion */
411       $this->remove_lock();
412       set_object_info();
413     }
416     /****************
417       Delete object group Canceled
418      ****************/
420     /* Delete group canceled? */
421     if (isset($_POST['delete_cancel'])){
422       $this->remove_lock();
423       set_object_info();
424     }
427     /****************
428       Edit group
429      ****************/
431     if (($s_action=="edit") && (! isset($this->ogroup->config)) ){
433       /* Get 'dn' from posted 'uid', must be unique */
434       $this->dn= $this->ogrouplist[$s_entry]['dn'];
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,TRUE));
440       }
442       /* Lock the current entry, so everyone will get the
443          above dialog */
444       add_lock ($this->dn, $this->ui->dn);
446       /* Register grouptab to trigger edit dialog */
447       $this->ogroup= new ogrouptabs($this->config, $this->config->data['TABS']['OGROUPTABS'], $this->dn, "ogroups");
448       $this->ogroup->set_acl_base($this->dn);
449       set_object_info($this->dn);
450     }
453     /****************
454       Edit finished save 
455      ****************/
457     /* Finish button has been pressed */
458     if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->ogroup->config)) ){
460       /* Check tabs, will feed message array */
461       $message= $this->ogroup->check();
463       /* Save, or display error message? */
464       if (count($message) == 0){
466         /* Save user data to ldap */
467         $this->ogroup->save();
469         if (!isset($_POST['edit_apply'])){
470           /* Group has been saved successfully, remove lock from
471              LDAP. */
472           if ($this->dn != "new"){
473             $this->remove_lock();
474           }
476           unset ($this->ogroup);
477           $this->ogroup= NULL;
478           set_object_info();
479         }else{
481           /* Reinitialize tab */
482           if($this->ogroup instanceof tabs){
483             $this->ogroup->re_init();
484           }
485         }
486       } else {
487         /* Ok. There seem to be errors regarding to the tab data,
488            show message and continue as usual. */
489         msg_dialog::displayChecks($message);
490       }
491     }
494     /****************
495       Cancel edit object group
496      ****************/
498     /* Cancel dialogs */
499     if ((isset($_POST['edit_cancel']))  && (isset($this->ogroup->dn))){
500       $this->remove_lock();
501       $this->ogroup= NULL;
502       set_object_info();
503     }
506     /****************
507       Display open dialogs 
508      ****************/
510     /* Show dialog if object is present */
511     if (isset($this->ogroup->config)){
512       $display= $this->ogroup->execute();
514       /* Don't show buttons if tab dialog requests this */
515       if(($this->ogroup instanceOf tabs || $this->ogroup instanceOf plugin) && $this->ogroup->read_only == TRUE){
516         $display.= "<p style=\"text-align:right\">
517           <input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">
518           </p>";
519       }elseif (!$this->ogroup->by_object[$this->ogroup->current]->dialog){
520         $display.= "<p style=\"text-align:right\">\n";
521         $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
522         $display.= "&nbsp;\n";
523         if ($this->dn != "new"){
524           $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
525           $display.= "&nbsp;\n";
526         }
527         $display.= "<input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
528         $display.= "</p>";
529       }
530       return ($display);
531     }
534     /****************
535       Display list 
536      ****************/
538     /* Check if there is a snapshot dialog open */
539     $base = $this->DivListOGroup->selectedBase;
540     if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
541       return($str);
542     }
544     /* Display dialog with group list */
545     $this->DivListOGroup->parent = $this;
546     $this->DivListOGroup->execute();
548     /* Add departments if subsearch is disabled */
549     if(!$this->DivListOGroup->SubSearch){
550       $this->DivListOGroup->AddDepartments($this->DivListOGroup->selectedBase,4,1);
551     }
552     $this->reload ();
553     $this->DivListOGroup->setEntries($this->ogrouplist);
554     return($this->DivListOGroup->Draw());
555   }
558   /* Return departments, that will be included within snapshot detection */
559   function get_used_snapshot_bases()
560   {
561     return(array(get_ou('ogroupRDN').$this->DivListOGroup->selectedBase));
562   }
564   
566   function convert_list($input)
567   {
568     $temp= "";
570     $conv= array(   
571         "Y" => array("plugins/users/images/select_template.png",_("Templates") , "ogroup"),
572         "U" => array("plugins/generic/images/head.png"        ,_("User")        , "ogroup"),
573         "G" => array("plugins/groups/images/groups.png"       ,_("Group")       , "ogroup"),
574         "A" => array("plugins/ogroups/images/application.png" ,_("Application") , "ogroup"),
575         "D" => array("plugins/departments/department.png"     ,_("Department")  , "ogroup"),
576         "S" => array("plugins/ogroups/images/server.png"      ,_("Server")      , "ogroup"),
577         "F" => array("plugins/ogroups/images/asterisk.png"    ,_("Phone")       , "phonequeue"),
578         "W" => array("plugins/ogroups/images/workstation.png" ,_("Workstation") , "workstartup"),
579         "O" => array("plugins/ogroups/images/winstation.png"  ,_("Windows Install") , "ogroup"),
580         "T" => array("plugins/ogroups/images/terminal.png"    ,_("Terminal")    , "termgroup"),
581         "P" => array("plugins/ogroups/images/printer.png"     ,_("Printer")     , "ogroup"));
583     /* Assemble picture */
584     $type= $input['gosaGroupObjects'][0];
585     $type= preg_replace("/[^A-Z]/i","",$type);
586     if (isset($type[0])){
587       $p1['pic']= $conv[$type[0]][0];
588       $p1['tit']= $conv[$type[0]][1];
589       $p1['alt']= $type[0];
590       $p1['lnk']= $conv[$type[0]][2];
591       $html_object_1 = "<input type='image' name='".$p1['lnk']."_group_edit_%KEY' ";
592     } else {
593       $p1['pic']= "images/empty.png";
594       $p1['tit']= "";
595       $p1['alt']= "";
596       $p1['lnk']= "";//$conv[$type[0]][2];
597       $html_object_1 = "<img ";
598     }
600     if (isset($type[1])){
601       $p2['pic']= $conv[$type[1]][0];
602       $p2['alt']= $type[1];
603       $p2['tit']= $conv[$type[1]][1];
604       $p2['lnk']= $conv[$type[1]][2];
605       $html_object_2 = "<input type='image' name='".$p2['lnk']."_group_edit_%KEY' ";
606     } else {
607       $p2['pic']= "images/empty.png";
608       $p2['alt']= "";
609       $p2['tit']= "";
610       $p2['lnk']= ""; //$conv[$type[0]][2];
611       $html_object_2 = "<img ";
612     }
613     
614     $temp = $html_object_1." class='center' id='iconA".preg_replace("/_/","",$p1['lnk']."_group_edit_%KEY")."' 
615       src='".$p1['pic']."' alt='".$p1['alt']."' title='".$p1['tit']."'>";
616     $temp.= $html_object_2." class='center' id='iconB".preg_replace("/_/","",$p2['lnk']."_group_edit_%KEY")."' 
617       src='".$p2['pic']."' alt='".$p2['alt']."' title='".$p2['tit']."'>";
618     return ($temp);
619   }
622   function reload()
623   {
624     /* Set base for all searches && initialise some vars */
625     $this->ogrouplist= array();
626     $base     = $this->DivListOGroup->selectedBase;
627     $filter   = "(gosaGroupObjects=[])";
628     $Regex    = $this->DivListOGroup->Regex;
630     $chk = array(
631         "UserGroups"          => "(gosaGroupObjects=*U*)" ,
632         "GroupGroups"         => "(gosaGroupObjects=*G*)" ,
633         "ApplicationGroups"   => "(gosaGroupObjects=*A*)" ,
634         "DepartmentGroups"    => "(gosaGroupObjects=*D*)" ,
635         "ServerGroups"        => "(gosaGroupObjects=*S*)" ,
636         "WorkstationGroups"   => "(gosaGroupObjects=*W*)" ,
637         "WindowsGroups"       => "(gosaGroupObjects=*O*)" ,
638         "TerminalGroups"      => "(gosaGroupObjects=*T*)" ,
639         "PrinterGroups"       => "(gosaGroupObjects=*P*)" ,
640         "PhoneGroups"         => "(gosaGroupObjects=*F*)" );
641     /* Create filter */ 
642     foreach($chk as $chkBox => $FilterPart){
643       if($this->DivListOGroup->$chkBox){
644         $filter .=  $FilterPart;
645       }
646     }
647     $filter= "(&(cn=$Regex)(objectClass=gosaGroupOfNames)(|$filter))";
649     if($this->DivListOGroup->SubSearch){
650       $res= get_sub_list($filter, "ogroups",get_ou('ogroupRDN'), $base, array("cn","objectClass","gosaGroupObjects"), GL_SIZELIMIT | GL_SUBSEARCH);
651     }else{
652       $res= get_sub_list($filter, "ogroups",get_ou('ogroupRDN'), get_ou('ogroupRDN').$base, array("cn","objectClass","gosaGroupObjects"), GL_SIZELIMIT );
653     }
655     $this->ogrouplist= $res;
656     ksort ($this->ogrouplist);
657     reset ($this->ogrouplist);
658     $tmp=array();
659     $tmp2 = array();
660     foreach($this->ogrouplist as $tkey => $val ){
661       $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val;
662       $tmp2[strtolower($val['cn'][0]).$val['cn'][0]] = strtolower($val['cn'][0]).$val['cn'][0];
663     }
664     natcasesort($tmp2);
665     $this->ogrouplist=array();
666     foreach($tmp2 as $val){
667       $this->ogrouplist[]=$tmp[$val];
668     }
669     reset ($this->ogrouplist);
670   }
673   function list_get_selected_items()
674   {
675     $ids = array();
676     foreach($_POST as $name => $value){
677       if(preg_match("/^item_selected_[0-9]*$/",$name)){
678         $id   = preg_replace("/^item_selected_/","",$name);
679         $ids[$id] = $id;
680       }
681     }
682     return($ids);
683   }
686   function copyPasteHandling_from_queue($s_action,$s_entry)
687   {
688     /* Check if Copy & Paste is disabled */
689     if(!is_object($this->CopyPasteHandler)){
690       return("");
691     }
693     $ui = get_userinfo();
695     /* Add a single entry to queue */
696     if($s_action == "cut" || $s_action == "copy"){
698       /* Cleanup object queue */
699       $this->CopyPasteHandler->cleanup_queue();
700       $dn = $this->ogrouplist[$s_entry]['dn'];
701       if($s_action == "copy" && $ui->is_copyable($dn,"ogroups","ogroup")){
702         $this->CopyPasteHandler->add_to_queue($dn,$s_action,"ogrouptabs","OGROUPTABS","ogroups");
703       }
704       if($s_action == "cut" && $ui->is_cutable($dn,"ogroups","ogroup")){
705         $this->CopyPasteHandler->add_to_queue($dn,$s_action,"ogrouptabs","OGROUPTABS","ogroups");
706       }
707     }
710     /* Add entries to queue */
711     if($s_action == "copy_multiple" || $s_action == "cut_multiple"){
713       /* Cleanup object queue */
714       $this->CopyPasteHandler->cleanup_queue();
716       /* Add new entries to CP queue */
717       foreach($this->list_get_selected_items() as $id){
718         $dn = $this->ogrouplist[$id]['dn'];
720         if($s_action == "copy_multiple" && $ui->is_copyable($dn,"ogroups","ogroup")){ 
721           $this->CopyPasteHandler->add_to_queue($dn,"copy","ogrouptabs","OGROUPTABS","ogroups");
722         }
723         if($s_action == "cut_multiple" && $ui->is_cutable($dn,"ogroups","ogroup")){
724           $this->CopyPasteHandler->add_to_queue($dn,"cut","ogrouptabs","OGROUPTABS","ogroups");
725         }
726       }
727     }
729     /* Start pasting entries */
730     if($s_action == "editPaste"){
731       $this->start_pasting_copied_objects = TRUE;
732     }
734     /* Return C&P dialog */
735     if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
737       /* Get dialog */
738       $this->CopyPasteHandler->SetVar("base",$this->DivListOGroup->selectedBase);
739       $data = $this->CopyPasteHandler->execute();
741       /* Return dialog data */
742       if(!empty($data)){
743         return($data);
744       }
745     }
746     /* Automatically disable status for pasting */
747     if(!$this->CopyPasteHandler->entries_queued()){
748       $this->start_pasting_copied_objects = FALSE;
749     }
750     return("");
751   }
754   function remove_lock()
755   {
756     if (isset($this->apptabs->dn)){
757       del_lock ($this->apptabs->dn);
758     }elseif(isset($this->dn) && !empty($this->dn) && $this->dn != "new"){
759       del_lock($this->dn);
760     }
761     if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
762       del_lock($this->dns);
763     }
764   }
767   function save_object()
768   {
769     $this->DivListOGroup->save_object();
770     if(is_object($this->CopyPasteHandler)){
771       $this->CopyPasteHandler->save_object();
772     }
773   }
778 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
779 ?>