Code

5e5b985d2543704226d17410b346c1d0b597c864
[gosa.git] / trunk / 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")){
149       $ids = $this->list_get_selected_items();
150       /* Resolve the selected items to their corresponding uids and group names */
151       $targets = array();
152       foreach($ids as $id){
153         $ogroup = $this->ogrouplist[$id]['cn'][0];
154         $ldap = $this->config->get_ldap_link();
155         $ldap->search("(&(cn=".$ogroup.")(member=*))", array('member'));
157         while ($entry = $ldap->fetch()) {
158           $members = $entry['member'];
159           for($i=0;$i<$members['count'];$i++) {
160             $ldap->cat($members[$i], array('uid','cn','objectClass'));
161             if ($ldap->count() > 0) {
162               $attrs = $ldap->fetch();
164               /* Determine which type the object has */
165               if (array_search('gosaAccount', $attrs['objectClass'])) {
166                 $uid = $attrs['uid'][0];
167                 $targets['USERS'][] = $uid;
168               }
169               elseif (array_search('posixGroup', $attrs['objectClass'])) {
170                 $group = $attrs['cn'][0];
171                 $targets['GROUPS'][] = $group;
172               }
173             }
174           }
175         }
176       }
177       if(count($targets)){
178         $events = DaemonEvent::get_event_types(USER_EVENT);
179         $event = preg_replace("/^event_/","",$s_action);
180         if(isset($events['BY_CLASS'][$event])){
181           $type = $events['BY_CLASS'][$event];
182           $this->ogroup = new $type['CLASS_NAME']($this->config);
183           $this->ogroup->add_targets($targets);
184           $this->ogroup->set_type(TRIGGERED_EVENT);
185         }
186       }
187     }
189     /* Abort event dialog */
190     if(isset($_POST['abort_event_dialog'])){
191       $this->ogroup = FALSE;
192     }
194     /* Save event */
195     if(isset($_POST['save_event_dialog'])){
196       $this->ogroup->save_object();
197       $msgs = $this->ogroup->check();
198       if (count($msgs)) {
199         msg_dialog::displayChecks($msgs);
200       }
201       else {
202         $o_queue = new gosaSupportDaemon();
203         $o_queue->append($this->ogroup);
204         if($o_queue->is_error()){
205           msg_dialog::display(_("Infrastructure error"), msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
206         }else{
207           $this->ogroup = FALSE;
208         }
209       }
210     }
212     /* Display event */
213     if($this->ogroup instanceof DaemonEvent){
214       $this->ogroup->save_object();
215       return($this->ogroup->execute());
216     }
219     /****************
220       Copy & Paste handling 
221      ****************/
223     /* Display the copy & paste dialog, if it is currently open */
224     $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
225     if($ret){
226       return($ret);
227     }
230     /***************
231       Create a new object group 
232      ****************/
234     /* New group? */
235     if ($s_action=="new"){
237       /* By default we set 'dn' to 'new', all relevant plugins will
238          react on this. */
239       $this->dn= "new";
241       /* Create new ogroup- object */
242       $this->ogroup= new ogrouptabs($this->config,$this->config->data['TABS']['OGROUPTABS'], $this->dn,"ogroups");
243       $this->ogroup->set_acl_base($this->DivListOGroup->selectedBase);
244     }
247     /********************
248       Delete MULTIPLE entries requested, display confirm dialog
249      ********************/
250     if ($s_action=="del_multiple"){
251       $ids = $this->list_get_selected_items();
253       if(count($ids)){
254         $this->dns = array();
255         $disallowed = array();
256         foreach($ids as $id){
257           $dn = $this->ogrouplist[$id]['dn'];
258           $acl = $this->ui->get_permissions($dn, "ogroups/ogroup");
259           if(preg_match("/d/",$acl)){
260             $this->dns[$id] = $dn;
261           }else{
262             $disallowed[] = $dn;
263           }
264         }
266         if(count($disallowed)){
267           msg_dialog::display(_("Permission"),msgPool::permDelete($disallowed),INFO_DIALOG);
268         }
270         if(count($this->dns)){
272           /* Check locks */
273           if ($user= get_multiple_locks($this->dns)){
274             return(gen_locked_message($user,$this->dns));
275           }
277           $dns_names = array();
278           foreach($this->dns as $dn){
279             $dns_names[] = LDAP::fix($dn);
280           }
282           add_lock ($this->dns, $this->ui->dn);
284           /* Lock the current entry, so nobody will edit it during deletion */
285           $smarty->assign("info", msgPool::deleteInfo($dns_names,_("object group")));
286           $smarty->assign("multiple", true);
287           return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
288         }
289       }
290     }
293     /********************
294       Delete MULTIPLE entries confirmed
295      ********************/
297     /* Confirmation for deletion has been passed. Users should be deleted. */
298     if (isset($_POST['delete_multiple_ogroup_confirm'])){
300       /* Remove user by user and check acls before removeing them */
301       foreach($this->dns as $key => $dn){
303         $acl = $this->ui->get_permissions($dn, "ogroups/ogroup");
304         if (preg_match('/d/', $acl)){
306           /* Delete request is permitted, perform LDAP action */
307           $this->ogroup= new ogrouptabs($this->config,$this->config->data['TABS']['OGROUPTABS'], $dn);
308           $this->ogroup->delete ();
309           unset ($this->ogroup);
310           $this->ogroup= NULL;
311         } else {
313           /* Normally this shouldn't be reached, send some extra
314              logs to notify the administrator */
315           msg_dialog::display(_("Permission error"), msgPool::permDelete(), INFO_DIALOG);
316           new log("security","ogroups/".get_class($this),$dn,array(),"Tried to trick deletion.");
317         }
318       }
320       /* Remove lock file after successfull deletion */
321       $this->remove_lock();
322       $this->dns = array();
323     }
326     /********************
327       Delete MULTIPLE entries Canceled
328      ********************/
330     /* Remove lock */
331     if(isset($_POST['delete_multiple_ogroup_cancel'])){
333       /* Remove lock file after successfull deletion */
334       $this->remove_lock();
335       $this->dns = array();
336     }
339     /****************
340       Delete object group
341      ****************/
343     if ($s_action=="del"){
345       /* Get 'dn' from posted 'uid' */
346       $this->dn= $this->ogrouplist[$s_entry]['dn'];
348       /* Load permissions for selected 'dn' and check if
349          we're allowed to remove this 'dn' */
350       $acl = $this->ui->get_permissions($this->dn,"ogroups/ogroup");
351       if(preg_match("/d/",$acl)){
353         /* Check locking, save current plugin in 'back_plugin', so
354            the dialog knows where to return. */
355         if (($user= get_lock($this->dn)) != ""){
356           return(gen_locked_message ($user, $this->dn));
357         }
359         /* Lock the current entry, so nobody will edit it during deletion */
360         add_lock ($this->dn, $this->ui->dn);
361         $smarty->assign("info", msgPool::deleteInfo(LDAP::fix($this->dn),_("object group")));
362         $smarty->assign("multiple", false);
363         return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
364       } else {
366         /* Obviously the user isn't allowed to delete. Show message and
367            clean session. */
368         msg_dialog::display(_("Permission error"), msgPool::permDelete(), INFO_DIALOG);
369       }
370     }
373     /****************
374       Delete confirmed 
375      ****************/
377     /* Confirmation for deletion has been passed. Group should be deleted. */
378     if (isset($_POST['delete_group_confirm'])){
380       /* Some nice guy may send this as POST, so we've to check
381          for the permissions again. */
382       $acl = $this->ui->get_permissions($this->dn,"ogroups/ogroup");
383       if(preg_match("/d/",$acl)){
385         /* Delete request is permitted, perform LDAP action */
386         $this->ogroup= new ogrouptabs($this->config,
387             $this->config->data['TABS']['OGROUPTABS'], $this->dn);
388         $this->ogroup->delete ();
389         unset ($this->ogroup);
390         $this->ogroup= NULL;
391       } else {
393         /* Normally this shouldn't be reached, send some extra
394            logs to notify the administrator */
395         msg_dialog::display(_("Permission error"), msgPool::permDelete(), INFO_DIALOG);
396         new log("security","ogroups/".get_class($this),$dn,array(),"Tried to trick deletion.");
397       }
399       /* Remove lock file after successfull deletion */
400       $this->remove_lock();
401       set_object_info();
402     }
405     /****************
406       Delete object group Canceled
407      ****************/
409     /* Delete group canceled? */
410     if (isset($_POST['delete_cancel'])){
411       $this->remove_lock();
412       set_object_info();
413     }
416     /****************
417       Edit group
418      ****************/
420     if (($s_action=="edit") && (! isset($this->ogroup->config)) ){
422       /* Get 'dn' from posted 'uid', must be unique */
423       $this->dn= $this->ogrouplist[$s_entry]['dn'];
425       /* Check locking, save current plugin in 'back_plugin', so
426          the dialog knows where to return. */
427       if (($user= get_lock($this->dn)) != ""){
428         return(gen_locked_message ($user, $this->dn,TRUE));
429       }
431       /* Lock the current entry, so everyone will get the
432          above dialog */
433       add_lock ($this->dn, $this->ui->dn);
435       /* Register grouptab to trigger edit dialog */
436       $this->ogroup= new ogrouptabs($this->config, $this->config->data['TABS']['OGROUPTABS'], $this->dn, "ogroups");
437       $this->ogroup->set_acl_base($this->dn);
438       set_object_info($this->dn);
439     }
442     /****************
443       Edit finished save 
444      ****************/
446     /* Finish button has been pressed */
447     if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->ogroup->config)) ){
449       /* Check tabs, will feed message array */
450       $message= $this->ogroup->check();
452       /* Save, or display error message? */
453       if (count($message) == 0){
455         /* Save user data to ldap */
456         $this->ogroup->save();
458         if (!isset($_POST['edit_apply'])){
459           /* Group has been saved successfully, remove lock from
460              LDAP. */
461           if ($this->dn != "new"){
462             $this->remove_lock();
463           }
465           unset ($this->ogroup);
466           $this->ogroup= NULL;
467           set_object_info();
468         }else{
470           /* Reinitialize tab */
471           if($this->ogroup instanceof tabs){
472             $this->ogroup->re_init();
473           }
474         }
475       } else {
476         /* Ok. There seem to be errors regarding to the tab data,
477            show message and continue as usual. */
478         msg_dialog::displayChecks($message);
479       }
480     }
483     /****************
484       Cancel edit object group
485      ****************/
487     /* Cancel dialogs */
488     if ((isset($_POST['edit_cancel']))  && (isset($this->ogroup->dn))){
489       $this->remove_lock();
490       $this->ogroup= NULL;
491       set_object_info();
492     }
495     /****************
496       Display open dialogs 
497      ****************/
499     /* Show dialog if object is present */
500     if (isset($this->ogroup->config)){
501       $display= $this->ogroup->execute();
503       /* Don't show buttons if tab dialog requests this */
504       if(($this->ogroup instanceOf tabs || $this->ogroup instanceOf plugin) && $this->ogroup->read_only == TRUE){
505         $display.= "<p style=\"text-align:right\">
506           <input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">
507           </p>";
508       }elseif (!$this->ogroup->by_object[$this->ogroup->current]->dialog){
509         $display.= "<p style=\"text-align:right\">\n";
510         $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
511         $display.= "&nbsp;\n";
512         if ($this->dn != "new"){
513           $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
514           $display.= "&nbsp;\n";
515         }
516         $display.= "<input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
517         $display.= "</p>";
518       }
519       return ($display);
520     }
523     /****************
524       Display list 
525      ****************/
527     /* Check if there is a snapshot dialog open */
528     $base = $this->DivListOGroup->selectedBase;
529     if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
530       return($str);
531     }
533     /* Display dialog with group list */
534     $this->DivListOGroup->parent = $this;
535     $this->DivListOGroup->execute();
537     /* Add departments if subsearch is disabled */
538     if(!$this->DivListOGroup->SubSearch){
539       $this->DivListOGroup->AddDepartments($this->DivListOGroup->selectedBase,4,1);
540     }
541     $this->reload ();
542     $this->DivListOGroup->setEntries($this->ogrouplist);
543     return($this->DivListOGroup->Draw());
544   }
547   /* Return departments, that will be included within snapshot detection */
548   function get_used_snapshot_bases()
549   {
550     return(array(get_ou('ogroupRDN').$this->DivListOGroup->selectedBase));
551   }
553   
555   function convert_list($input)
556   {
557     $temp= "";
559     $conv= array(   
560         "Y" => array("plugins/users/images/select_template.png",_("Templates") , "ogroup"),
561         "U" => array("plugins/generic/images/head.png"        ,_("User")        , "ogroup"),
562         "G" => array("plugins/groups/images/groups.png"       ,_("Group")       , "ogroup"),
563         "A" => array("plugins/ogroups/images/application.png" ,_("Application") , "ogroup"),
564         "D" => array("plugins/departments/department.png"     ,_("Department")  , "ogroup"),
565         "S" => array("plugins/ogroups/images/server.png"      ,_("Server")      , "ogroup"),
566         "F" => array("plugins/ogroups/images/asterisk.png"    ,_("Phone")       , "phonequeue"),
567         "W" => array("plugins/ogroups/images/workstation.png" ,_("Workstation") , "workstartup"),
568         "O" => array("plugins/ogroups/images/winstation.png"  ,_("Windows Install") , "ogroup"),
569         "T" => array("plugins/ogroups/images/terminal.png"    ,_("Terminal")    , "termgroup"),
570         "P" => array("plugins/ogroups/images/printer.png"     ,_("Printer")     , "ogroup"));
572     /* Assemble picture */
573     $type= $input['gosaGroupObjects'][0];
574     $type= preg_replace("/[^A-Z]/i","",$type);
575     if (isset($type[0])){
576       $p1['pic']= $conv[$type[0]][0];
577       $p1['tit']= $conv[$type[0]][1];
578       $p1['alt']= $type[0];
579       $p1['lnk']= $conv[$type[0]][2];
580       $html_object_1 = "<input type='image' name='".$p1['lnk']."_group_edit_%KEY' ";
581     } else {
582       $p1['pic']= "images/empty.png";
583       $p1['tit']= "";
584       $p1['alt']= "";
585       $p1['lnk']= "";//$conv[$type[0]][2];
586       $html_object_1 = "<img ";
587     }
589     if (isset($type[1])){
590       $p2['pic']= $conv[$type[1]][0];
591       $p2['alt']= $type[1];
592       $p2['tit']= $conv[$type[1]][1];
593       $p2['lnk']= $conv[$type[1]][2];
594       $html_object_2 = "<input type='image' name='".$p2['lnk']."_group_edit_%KEY' ";
595     } else {
596       $p2['pic']= "images/empty.png";
597       $p2['alt']= "";
598       $p2['tit']= "";
599       $p2['lnk']= ""; //$conv[$type[0]][2];
600       $html_object_2 = "<img ";
601     }
602     
603     $temp = $html_object_1." class='center' id='iconA".preg_replace("/_/","",$p1['lnk']."_group_edit_%KEY")."' 
604       src='".$p1['pic']."' alt='".$p1['alt']."' title='".$p1['tit']."'>";
605     $temp.= $html_object_2." class='center' id='iconB".preg_replace("/_/","",$p2['lnk']."_group_edit_%KEY")."' 
606       src='".$p2['pic']."' alt='".$p2['alt']."' title='".$p2['tit']."'>";
607     return ($temp);
608   }
611   function reload()
612   {
613     /* Set base for all searches && initialise some vars */
614     $this->ogrouplist= array();
615     $base     = $this->DivListOGroup->selectedBase;
616     $filter   = "(gosaGroupObjects=[])";
617     $Regex    = $this->DivListOGroup->Regex;
619     $chk = array(
620         "UserGroups"          => "(gosaGroupObjects=*U*)" ,
621         "GroupGroups"         => "(gosaGroupObjects=*G*)" ,
622         "ApplicationGroups"   => "(gosaGroupObjects=*A*)" ,
623         "DepartmentGroups"    => "(gosaGroupObjects=*D*)" ,
624         "ServerGroups"        => "(gosaGroupObjects=*S*)" ,
625         "WorkstationGroups"   => "(gosaGroupObjects=*W*)" ,
626         "WindowsGroups"       => "(gosaGroupObjects=*O*)" ,
627         "TerminalGroups"      => "(gosaGroupObjects=*T*)" ,
628         "PrinterGroups"       => "(gosaGroupObjects=*P*)" ,
629         "PhoneGroups"         => "(gosaGroupObjects=*F*)" );
630     /* Create filter */ 
631     foreach($chk as $chkBox => $FilterPart){
632       if($this->DivListOGroup->$chkBox){
633         $filter .=  $FilterPart;
634       }
635     }
636     $filter= "(&(cn=$Regex)(objectClass=gosaGroupOfNames)(|$filter))";
638     if($this->DivListOGroup->SubSearch){
639       $res= get_sub_list($filter, "ogroups",get_ou('ogroupRDN'), $base, array("cn","objectClass","gosaGroupObjects"), GL_SIZELIMIT | GL_SUBSEARCH);
640     }else{
641       $res= get_sub_list($filter, "ogroups",get_ou('ogroupRDN'), get_ou('ogroupRDN').$base, array("cn","objectClass","gosaGroupObjects"), GL_SIZELIMIT );
642     }
644     $this->ogrouplist= $res;
645     ksort ($this->ogrouplist);
646     reset ($this->ogrouplist);
647     $tmp=array();
648     $tmp2 = array();
649     foreach($this->ogrouplist as $tkey => $val ){
650       $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val;
651       $tmp2[strtolower($val['cn'][0]).$val['cn'][0]] = strtolower($val['cn'][0]).$val['cn'][0];
652     }
653     natcasesort($tmp2);
654     $this->ogrouplist=array();
655     foreach($tmp2 as $val){
656       $this->ogrouplist[]=$tmp[$val];
657     }
658     reset ($this->ogrouplist);
659   }
662   function list_get_selected_items()
663   {
664     $ids = array();
665     foreach($_POST as $name => $value){
666       if(preg_match("/^item_selected_[0-9]*$/",$name)){
667         $id   = preg_replace("/^item_selected_/","",$name);
668         $ids[$id] = $id;
669       }
670     }
671     return($ids);
672   }
675   function copyPasteHandling_from_queue($s_action,$s_entry)
676   {
677     /* Check if Copy & Paste is disabled */
678     if(!is_object($this->CopyPasteHandler)){
679       return("");
680     }
682     $ui = get_userinfo();
684     /* Add a single entry to queue */
685     if($s_action == "cut" || $s_action == "copy"){
687       /* Cleanup object queue */
688       $this->CopyPasteHandler->cleanup_queue();
689       $dn = $this->ogrouplist[$s_entry]['dn'];
690       if($s_action == "copy" && $ui->is_copyable($dn,"ogroups","ogroup")){
691         $this->CopyPasteHandler->add_to_queue($dn,$s_action,"ogrouptabs","OGROUPTABS","ogroups");
692       }
693       if($s_action == "cut" && $ui->is_cutable($dn,"ogroups","ogroup")){
694         $this->CopyPasteHandler->add_to_queue($dn,$s_action,"ogrouptabs","OGROUPTABS","ogroups");
695       }
696     }
699     /* Add entries to queue */
700     if($s_action == "copy_multiple" || $s_action == "cut_multiple"){
702       /* Cleanup object queue */
703       $this->CopyPasteHandler->cleanup_queue();
705       /* Add new entries to CP queue */
706       foreach($this->list_get_selected_items() as $id){
707         $dn = $this->ogrouplist[$id]['dn'];
709         if($s_action == "copy_multiple" && $ui->is_copyable($dn,"ogroups","ogroup")){ 
710           $this->CopyPasteHandler->add_to_queue($dn,"copy","ogrouptabs","OGROUPTABS","ogroups");
711         }
712         if($s_action == "cut_multiple" && $ui->is_cutable($dn,"ogroups","ogroup")){
713           $this->CopyPasteHandler->add_to_queue($dn,"cut","ogrouptabs","OGROUPTABS","ogroups");
714         }
715       }
716     }
718     /* Start pasting entries */
719     if($s_action == "editPaste"){
720       $this->start_pasting_copied_objects = TRUE;
721     }
723     /* Return C&P dialog */
724     if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
726       /* Get dialog */
727       $this->CopyPasteHandler->SetVar("base",$this->DivListOGroup->selectedBase);
728       $data = $this->CopyPasteHandler->execute();
730       /* Return dialog data */
731       if(!empty($data)){
732         return($data);
733       }
734     }
735     /* Automatically disable status for pasting */
736     if(!$this->CopyPasteHandler->entries_queued()){
737       $this->start_pasting_copied_objects = FALSE;
738     }
739     return("");
740   }
743   function remove_lock()
744   {
745     if (isset($this->apptabs->dn)){
746       del_lock ($this->apptabs->dn);
747     }elseif(isset($this->dn) && !empty($this->dn) && $this->dn != "new"){
748       del_lock($this->dn);
749     }
750     if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
751       del_lock($this->dns);
752     }
753   }
756   function save_object()
757   {
758     $this->DivListOGroup->save_object();
759     if(is_object($this->CopyPasteHandler)){
760       $this->CopyPasteHandler->save_object();
761     }
762   }
767 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
768 ?>