Code

Updated opsi
[gosa.git] / gosa-plugins / fai / admin / fai / class_faiManagement.inc
1 <?php
2 /*
3    This code is part of GOsa (https://gosa.gonicus.de)
4    Copyright (C) 2003  Cajus Pollmeier
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
22 class faiManagement extends plugin
23 {
24         /* Definitions */
25   var $plHeadline     = "Software deployment";
26   var $plDescription  = "Manage software packages and deployment reciepes";
27   var $plIcon         = "plugins/fai/images/plugin.png";
29         /* Headpage attributes */
30   var $lock_type    = "";    // should be branch/freeze
31   var $lock_name    = "";
32   var $lock_dn      = "";  
34         /* attribute list for save action */
35         var $attributes         = array("lock_type","lock_name","lock_dn");     //      Attributes Managed by this plugin 
36         var $objectclasses= array();    //      ObjectClasses which the attributes are related to
37         var $dialog                             = array();      //      This object contains every dialog we have currently opened
39         var $objects                    = array();      //      This array contains all available objects shown in divlist
40         var $is_dialog          = false;
42   var $dispNewBranch= false;
43   var $dispNewFreeze= false;
45   var $DivListFai;
46   var $start_pasting_copied_objects = FALSE;
47   var $CopyPasteHandler = FALSE;
49   /* Allow inserting of new elements if freezed releases 
50   */
51   var $allow_freeze_object_attach = TRUE;
53   var $no_save;
54   var $fai_base     ="";
55   var $fai_release  ="";
57   var $acl_module = array("fai");
59   var $opsi = NULL;
61         /* construction/reconstruction 
62          */
63         function faiManagement (&$config, $ui)
64         {
65                 /* Set defaults */
66                 $this->dn                       = "";
67                 $this->config   = $config;
68                 $this->ui                       = $ui;  
70     /* Check if the opsi plugin is installed.
71      */
72     if(class_available("opsi")){
73       $this->opsi = new opsi($this->config);;
74     }
75     
76     /* Creat dialog object */
77     $this->DivListFai = new divListFai($this->config,$this);
79     /* Copy & Paste handler */
80     if ($this->config->boolValueIsTrue("main", "enableCopyPaste")){
81       $this->CopyPasteHandler= new CopyPasteHandler($this->config);
82     }
84     /* Set default release */
85     $this->fai_base = get_ou("faiou").$this->config->current['BASE'];
87     if(!session::is_set("fai_filter")){
89       /* Set intial release */
90       $rel = $config->search("faiManagement","DEFAULT_RELEASE",array("menu"));
91       $rels = array_flip($this->getBranches());
92       if(isset($rels[$rel])){
93         $rel = $rels[$rel];
94       }else{
95         $rel = $this->fai_base;
96       }
98       session::set("fai_filter",array("fai_release" => $rel));
99     }
101     $fai_filter = session::get("fai_filter");
102     $this->fai_release = $fai_filter['fai_release'];
103         }
105         function execute()
106         {
107     /* Call parent execute */
108     plugin::execute();
111     /* Initialise vars and smarty */
112                 $smarty         = get_smarty();
113                 $smarty->assign("BranchName","");
114     
115                 $display        = "";
116     $s_action   = "";
117                 $s_entry        = "";
118     $no_save = FALSE;   // hide Apply / Save buttons
119     
120     /* If an entry was locked, these vars will be stored in a session to allow direct edit */
121     session::set('LOCK_VARS_TO_USE',array("/^edit_freeze_entry$/","/^edit_entry$/","/^id$/","/^entry_edit_/","/^entry_delete_/","/^item_selected/","/^remove_multiple_fai_objects/","/^menu_action/"));
124     /****************
125       Handle posts 
126      ****************/
128                 /* Check ImageButton posts
129                  * Create new tab ich new_xx is posted
130                  */
131     $posts = array( "/remove_branch/"=>"remove_branch",    "/branch_branch/"=>"branch_branch",
132                     "/freeze_branch/"=>"freeze_branch",    "/create_partition/i"=>"new_partition",
133                     "/create_script/i"=>"new_script",      "/create_hook/i"=>"new_hook",
134                     "/create_variable/i"=>"new_variable",  "/create_template/i"=>"new_template",
135                     "/create_package/i"=>"new_package",    "/create_profile/i"=>"new_profile",
136                     "/edit_continue/"=>"select_class_name_finished",
137                     "/^multiple_copy_fai/" => "copy_multiple", 
138                     "/^multiple_cut_fai/" => "cut_multiple", 
139                     "/^copy/" => "copy",
140                     "/^remove_multiple_fai_objects/" => "del_multiple");
142     print_a($_POST);
144                 foreach($_POST as $name => $value){
145       foreach($posts as $reg => $act ){
146         if(preg_match($reg,$name)){
147           $s_action = $act;
148           $s_entry = ltrim(preg_replace($reg,"",$name),"_");
149           $s_entry = preg_replace("/_.*$/","",$s_entry);
150           break;
151         }
152       }
153                         if(preg_match("/^entry_edit_.*/",$name)){
154                                 $s_entry = preg_replace("/^entry_edit_/","",$name);
155                                 $s_entry = preg_replace("/_.*$/","",$s_entry);
156         $s_action = "edit";
157         break;
158       }elseif(preg_match("/^entry_freeze_edit_.*/",$name)){
159         $s_entry = preg_replace("/^entry_freeze_edit_/","",$name);
160         $s_entry = preg_replace("/_.*$/","",$s_entry);
161         $s_action = "edit";
162         $no_save = TRUE;
163         break;
164       }elseif(preg_match("/^entry_delete_.*/",$name)){
165         $s_entry = preg_replace("/^entry_delete_/","",$name);
166         $s_entry = preg_replace("/_.*$/","",$s_entry);
167         $s_action = "delete";
168         break;
169       }
171       /* Get posts from opsi onjects 
172        */  
173       if($this->opsi instanceof opsi && $this->opsi->enabled()){
174         if(preg_match("/^entry_opsi_edit_/",$name)){
175           $s_entry = preg_replace("/^entry_opsi_edit_([0-9]*).*$/","\\1",$name);
176           $s_action = "opsi_edit";
177           break;
178         }
179       }
180     }
182     /* Get posts from opsi objects 
183      */ 
184                 if($this->opsi instanceof opsi && $this->opsi->enabled() && isset($_GET['edit_opsi_entry'])){
185                         $s_entry = $_GET['edit_opsi_entry'];
186                         $s_action = "opsi_edit";
187                 }
189                 if(isset($_GET['edit_entry'])){
190                         $s_entry = $_GET['edit_entry'];
191                         $s_action = "edit";
192                 }
194                 if(isset($_GET['edit_freeze_entry'])){
195                         $s_entry = $_GET['edit_freeze_entry'];
196                         $s_action = "edit";
197       $no_save = TRUE;
198                 }
200     if(isset($_GET['act']) && $_GET['act'] == "freeze_branch"){
201       $s_action = "freeze_branch";
202     }
203     if(isset($_GET['act']) && $_GET['act'] == "branch_branch"){
204       $s_action = "branch_branch";
205     }
206     if(isset($_GET['act']) && $_GET['act'] == "remove_branch"){
207       $s_action = "remove_branch";
208     }
209     
210     if((isset($_POST['CancelBranchName'])) || (isset($_POST['CloseIFrame']))){
211       $this->dispNewBranch = false;
212       $this->dispNewFreeze = false;
213     }
216     $type_acl_mapping = array(
217         "FAIpartitionTable"  => "faiPartitionTable", 
218         "FAIpackageList"     => "faiPackage",
219         "FAIscript"          => "faiScript",
220         "FAIvariable"        => "faiVariable",
221         "FAIhook"            => "faiHook",
222         "FAIprofile"         => "faiProfile",
223         "FAItemplate"        => "faiTemplate");
226     /* handle C&P from layers menu */
227     if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){
228       $s_action = "copy_multiple";
229     }
230     if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){
231       $s_action = "cut_multiple";
232     }
233     if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){
234       $s_action = "editPaste";
235     }
237     /* Create options */
238     if(isset($_POST['menu_action']) && preg_match("/^Create_/",$_POST['menu_action'])){
239       $s_action = "new_".preg_replace("/^Create_/","",$_POST['menu_action']);;
240       $s_entry  = preg_replace("/^Create_/","",$_POST['menu_action']);
241     }
243     /* handle remove from layers menu */
244     if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){
245       $s_action = "del_multiple";
246     }
249     if(!empty($s_action)){
250       $this->no_save = $no_save;
251     }
253     /********************
254       Copy & Paste
255      ********************/
257     /* Display the copy & paste dialog, if it is currently open */
258     $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
259     if($ret){
260       return($ret);
261     }
264     /*******************
265       Opsi extension 
266      *******************/
268     if($this->opsi instanceof opsi && $this->opsi->enabled()){
269       if($s_action == "opsi_edit"){
270         $name = $this->objects[$s_entry]['cn'];
271         $cfg = $this->opsi->get_product_properties($name);
272         $this->dialog = new opsi_product_config($this->config, $name,$cfg);
273       }
274       if($this->dialog instanceof opsi_product_config && isset($_POST['cancel_properties'])){
275         $this->dialog = NULL;
276       }
277       if($this->dialog instanceof opsi_product_config && isset($_POST['save_properties'])){
278         $this->dialog->save_object();
279         $name  = $this->dialog->get_product();
280         $cfg   = $this->dialog->get_cfg();
281         for($i = 0 ; $i < 10 ; $i ++){
282           $cfg["name$i"] = microtime(1);
283         }
284         $this->opsi->set_product_properties($name,$cfg); 
285         $this->dialog = NULL;
286       }
287       if($this->dialog instanceof opsi_product_config){
288         $this->dialog->save_object();
289         return($this->dialog->execute());
290       }
291     }
294     /****************
295       Delete confirme dialog 
296      ****************/
298                 if ($s_action=="delete"){
300       /* Get 'dn' from posted termlinst */
301       $this->dn= $this->objects[$s_entry]['dn'];
303                         /* Load permissions for selected 'dn' and check if
304                            we're allowed to remove this 'dn' */
305       $acl  = $this->ui->get_permissions($this->dn,"fai/".$type_acl_mapping[$this->objects[$s_entry]['type']]);
306       if(preg_match("/d/",$acl)){
308                                 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
309                                 if (($user= get_lock($this->dn)) != ""){
310                                         return(gen_locked_message ($user, $this->dn));
311                                 }
313                                 /* Lock the current entry, so nobody will edit it during deletion */
314                                 add_lock ($this->dn, $this->ui->dn);
315                                 $smarty->assign("warning",msgPool::deleteInfo(@LDAP::fix($this->dn),_("FAI object")));
316         $smarty->assign("multiple", false);
317                                 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
318                         } else {
320                                 /* Obviously the user isn't allowed to delete. Show message and clean session. */
321         msg_dialog::display(_("Permission error"), msgPool::permDelete(),ERROR_DIALOG);
322                         }
323                 }
326     /********************
327       Delete MULTIPLE entries requested, display confirm dialog
328      ********************/
330     if ($s_action=="del_multiple"){
331       $this->dns = array();
332       $ids = $this->list_get_selected_items();
334       if(count($ids)){
336         $errors = "";
337         foreach($ids as $id){
338           $dn = $this->objects[$id]['dn'];
339           $cn = $this->objects[$id]['cn'];
340           if(!preg_match('/^freeze/', $this->objects[$id]['FAIstate'])){
341             $this->dns[$id] = $dn;
342           }else{
343             $errors .= $cn.", ";
344           }
345         }
346         if ($user= get_multiple_locks($this->dns)){
347           return(gen_locked_message($user,$this->dns));
348         }
350         if($errors != ""){
351           msg_dialog::display(_("Branch locked"),sprintf(_("The following entries are locked, you can't remove them %s."),
352             "<br><br>".trim($errors,", ")),INFO_DIALOG);
353         }
355         if(count($this->dns)){
357           $dns_names = array();
358           foreach($this->dns as $dn){
359             add_lock ($dn, $this->ui->dn);
360             $dns_names[] = @LDAP::fix($dn);
361           }
363           /* Lock the current entry, so nobody will edit it during deletion */
364                                   $smarty->assign("warning",msgPool::deleteInfo($dns_names,_("FAI object")));
365           $smarty->assign("multiple", true);
366           return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
367         }
368       }
369     }
372     /********************
373       Delete MULTIPLE entries confirmed
374      ********************/
376     /* Confirmation for deletion has been passed. Users should be deleted. */
377     if (isset($_POST['delete_multiple_fai_object_confirm'])){
379       /* Find out more about the object type */
380       $ldap   = $this->config->get_ldap_link();
382       /* Remove user by user and check acls before removeing them */
383       foreach($this->dns as $key => $dn){
385         $ldap->cat($dn, array('objectClass'));
386         $attrs  = $ldap->fetch();
387         $type   = $this->get_type($attrs);
389         $acl  = $this->ui->get_permissions($dn,"fai/".$type[1]);
390         if(preg_match("/d/",$acl)){
392           $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $dn,"fai");
393           $this->dialog->parent = &$this;
394           $this->dialog->set_acl_base($dn);
395           $this->dialog->by_object[$type[1]]->remove_from_parent ();
396           unset ($this->dialog);
397           $this->dialog= FALSE;
398           $to_del = FAI::clean_up_releases($dn);
399           FAI::save_release_changes_now();
401           foreach($to_del as $dn){
402             $ldap->rmdir_recursive($dn);
403           }
405         } else {
407           /* Normally this shouldn't be reached, send some extra
408              logs to notify the administrator */
409           msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
410           new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion.");
411         }
412       }
414       /* Remove lock file after successfull deletion */
415       $this->remove_lock();
416       $this->dns = array();
417     }
420     /********************
421       Delete MULTIPLE entries Canceled
422      ********************/
424     /* Remove lock */
425     if(isset($_POST['delete_multiple_fai_object_cancel'])){
426       $this->dns = array();
427       $this->remove_lock();
428     }
431     /****************
432       Delete aborted  
433      ****************/
435                 /* Delete canceled? */
436                 if (isset($_POST['delete_cancel'])){
437       $this->remove_lock();
438                 }
441     /****************
442       Delete confirmed 
443      ****************/
445                 /* Deltetion was confirmed, so delete this entry
446      */
447     if (isset($_POST['delete_terminal_confirm'])){
449       /* Some nice guy may send this as POST, so we've to check
450          for the permissions again. */
452       /* Find out more about the object type */
453       $ldap       = $this->config->get_ldap_link();
454       $ldap->cat($this->dn, array('objectClass'));
455       if($ldap->count()){
456         $attrs  = $ldap->fetch();
457         $type     = $this->get_type($attrs);                    
459         $acl  = $this->ui->get_permissions($this->dn,"fai/".$type[1]);
460         if(preg_match("/d/",$acl)){
462           $this->dialog = new $type[0]($this->config,   $this->config->data['TABS'][$type[2]], $this->dn,"fai");
463           $this->dialog->set_acl_base($this->dn);
464           $this->dialog->parent = &$this;
465           $this->dialog->by_object[$type[1]]->remove_from_parent ();
466           unset ($this->dialog);
467           $this->dialog= FALSE;
468           $to_del = FAI::clean_up_releases($this->dn);
469           FAI::save_release_changes_now();
471           foreach($to_del as $dn){
472             $ldap->rmdir_recursive($dn);
473           }
475         } else {
477           /* Normally this shouldn't be reached, send some extra
478              logs to notify the administrator */
479           msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
480           new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion.");
481         }
483       }else{
484         msg_dialog::display(_("Error"), sprintf(_("Cannot delete '%s': object does not exist!"), $this->dn) , ERROR_DIALOG);
485       }
487       /* Remove lock file after successfull deletion */
488       $this->remove_lock();
489     }
492     /****************
493       Edit entry 
494      ****************/
496                 if(($s_action == "edit") && (!isset($this->dialog->config))){
497                         $entry    = $this->objects[$s_entry];
498                         $a_setup  = $this->get_type($entry);
499                         $this->dn = $entry['dn'];
501                         /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
502                         if (($user= get_lock($this->dn)) != ""){
503                                 return(gen_locked_message ($user, $this->dn));
504                         }
505                         add_lock ($this->dn, $this->ui->dn);
507                         $this->dialog     = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
508       $this->dialog->parent = &$this;
509       $this->dialog->by_object[$a_setup[1]]->FAIstate = $entry['FAIstate'];
510       $this->dialog->set_acl_base($this->dn);
511                         $this->is_dialog  = true;
512                         session::set('objectinfo',$this->dn);
513                 }
516     /*  Branch handling 
517         09.01.2006
518     */
520     /****************
521       Remove branch
522      ****************/
524     /* Remove branch 
525      */
526     if($s_action == "remove_branch"){
527       $base= $this->fai_release;
529       /* Check if we have a post remove method configured
530        *  else skip this operation. (Skip:Button in the ui should be disabled in this case too)
531        */
532       if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
533         /* Load permissions for selected 'dn' and check if
534            we're allowed to remove this 'dn' */
535         if($this->acl_is_removeable()){
536           $smarty->assign("release_hidden",base64_encode($this->fai_release));
537           $smarty->assign("info", msgPool::deleteInfo(@LDAP::fix($this->fai_release),_("FAI branch/freeze")));
538           return($smarty->fetch(get_template_path('remove_branch.tpl',TRUE)));
539         } else {
540           msg_dialog::display(_("Permission error"), _("You have no permission to delete this release!"), ERROR_DIALOG);
541         }
542       }
543     }
545     
546     /****************
547       Remove branch confirmed
548      ****************/
550     if(isset($_POST['delete_branch_confirm'])){
552       /* Check if we have a post remove method configured
553        *  else skip this operation. (Skip:Button in the ui should be disabled in this case too)
554        */
555       if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
557         if(!isset($_POST['release_hidden']) || base64_decode($_POST['release_hidden']) != $this->fai_release){
558           msg_dialog::display(_("Warning"),_("Release remove aborted because the release name check failed!"));
559         }else{
561           $bb =  $this->fai_release;
562           if(!isset($ldap)){
563             $ldap = $this->config->get_ldap_link();
564           }
566           $br = $this->getBranches();
568           if(isset($br[$bb]) && $this->acl_is_removeable()){
569             $name = $br[$bb];
571             $ldap->cd($bb);
572             $ldap->recursive_remove();
573             $ldap->cd(preg_replace('/,'.normalizePreg(get_ou('faiou')).'/', ','.get_ou('applicationou'), $bb));
574             $ldap->recursive_remove();
575             $ldap->cd(preg_replace('/,'.normalizePreg(get_ou('faiou')).'/', ','.get_ou('mimetypeou'), $bb));
576             $ldap->recursive_remove();
578             /* Search for all groups with configured application menus.
579               - First search all groups, to ensure that we only remove entries form whithin groups. 
580               - The search für menu configuration for the specified release and collect all those dns.
581               - Remove entries
582              */
583             $release_ou = preg_replace("/".normalizePreg(get_ou("faiou")).".*$/","",$bb);
584             $ldap->cd($this->config->current['BASE']);
585             $ldap->search("(objectClass=posixGroup)",array("dn"));
586           
587             /* Collect all group dns 
588              */
589             $groups = array();
590             while($attrs = $ldap->fetch()){
591               $groups[] = $attrs['dn'];
592             }
594             /* Collect all group menu release dns that match the release we have removed 
595              */
596             $dns = array();
597             foreach($groups as $dn){
598               $ldap->cd($dn);
599               $ldap->search("(objectClass=FAIbranch)",array("dn"));
600               while($attrs = $ldap->fetch()){
601                 if(preg_match("/^".normalizePreg($release_ou)."/",$attrs['dn'])){
602                   $dns[] = $attrs['dn'];
603                 }
604               }
605             }
606             
607             /* Finally remove collected release dns 
608              */
609             foreach($dns as $dn){
610               $ldap->cd($dn);
611               $ldap->recursive_remove();
612             }
614             /* Post remove */
615             $this->fai_release = $this->fai_base;
616             $this->lock_name   = $name;
617             $this->lock_dn     = $bb;
618             $this->postremove();
620             $fai_filter = session::get("fai_filter");
621             $fai_filter['fai_release'] = $this->fai_release;
622             session::set("fai_filter",$fai_filter);
624             new log("remove","fai/".get_class($this),$br[$bb],array(),"Release removed");
625           }
626         }
627       }
628     }
631     /****************
632       Create a new branch "insert Name"
633      ****************/
635     if((isset($_POST['UseBranchName']))&&(($this->dispNewBranch)||($this->dispNewFreeze))){
636       session::set('LASTPOST',$_POST);
638       if($this->dispNewBranch){
639         $type = "branch";
640       }else{
641         $type = "freeze";
642       }
644       /* Check branch name */
645       $name = $_POST['BranchName'];
646       $is_ok = true;
647       $smarty->assign("BranchName",$name);
648       $base= $this->fai_base;
650       /* Check used characters */
651       if(!preg_match("/^[0-9a-z\.]*$/",$name)){
652         msg_dialog::display(_("Error"), msgPool::invalid(_("Name"),$name,"/[0-9a-z\.]/"), ERROR_DIALOG);
653         $is_ok = false;
654       }
656       /* Check if this name is already in use */
657       if(!$this->CheckNewBranchName($_POST['BranchName'],$this->fai_release)){
658         msg_dialog::display(_("Error"), msgPool::duplicated(_("Name")), ERROR_DIALOG);
659         $is_ok = false;
660       }
662       if($is_ok){
664         if(session::is_set('LASTPOST')){
665           $LASTPOST = session::get('LASTPOST');
666         }else{
667           $LASTPOST = array();
668         }
669         $LASTPOST['base'] = $base;
670         $LASTPOST['type'] = $type;
671         session::set('LASTPOST',$LASTPOST);
672         $smarty->assign("iframe", true);
673         $smarty->assign("plugID", $_GET['plug']);
674         $display        = $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
675         return($display);
676       }
677     }
680     /****************
681       Create a new branch 
682      ****************/
684     if(isset($_GET['PerformBranch'])){
685     
686       if(!$this->acl_is_createable()){
687         msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
688       }else{
690         /* In order to see error messages we have to reset the error handler.
691             Due to the exit(); 
692          */
693         restore_error_handler();
695         /* Create it know */
696         $this->dispNewBranch = false;
697         $this->dispNewFreeze = false;
699         $LASTPOST = session::get('LASTPOST');
700         $base = $LASTPOST['base'];
701         $_POST  = session::get('LASTPOST');      
702         $name = $_POST['BranchName'];
704         $type = $LASTPOST['type'];
705         $ldap = $this->config->get_ldap_link();
707         $baseToUse = $base;
708         if($this->fai_release !=  $this->fai_base){
709           $baseToUse = $this->fai_release;
710         }
712         /* Create new Release name to be able to set faidebianRelease for FAIpackageList */
714         $CurrentReleases  = $this->getBranches();
715         $NewReleaseName   = $name;
716         if(isset($CurrentReleases[$this->fai_release])) {
717           if($this->fai_release != $this->fai_base){
718             $NewReleaseName = $CurrentReleases[$this->fai_release]."/".$name;
719             $NewReleaseName = preg_replace("#\/#","/",$NewReleaseName); 
720           }else{
721             $NewReleaseName   = $name;
722           }
723         }
725         $appsrc = preg_replace("/".normalizePreg(get_ou('faiou'))."/",get_ou('applicationou'),$baseToUse); 
726         $appdst = preg_replace("/".normalizePreg(get_ou('faiou'))."/",get_ou('applicationou'),"ou=".$name.",".$baseToUse) ; 
728         $mimesrc = preg_replace("/".normalizePreg(get_ou('faiou'))."/",get_ou('mimetypeou'),$baseToUse); 
729         $mimedst = preg_replace("/".normalizePreg(get_ou('faiou'))."/",get_ou('mimetypeou'),"ou=".$name.",".$baseToUse) ; 
731         /* Check if source depeartments exist */
732         foreach(array($baseToUse,$appsrc,$mimesrc) as $dep){
733           $ldap->cd($this->config->current['BASE']);
734           $ldap->cat($dep);
735           if(!$ldap->count()){
736             $ldap->create_missing_trees($dep);
737           }
738         }
740         /* Print header to have styles included */
741         echo '  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
742           <html>
743           <head>
744           <title></title>
745           <style type="text/css">@import url("themes/default/style.css");</style>
746           <script language="javascript" src="include/focus.js" type="text/javascript"></script>
747           </head>
748           <body style="background: none;margin:3px;color:black">
749           ';
751         new log("create","fai/".get_class($this),$NewReleaseName,array(),"New $type created");
753         /* Duplicate group application releases 
754          */
755         FAI::copy_FAI_group_releases($CurrentReleases[$this->fai_release],$name,$type);
757         /* Duplicate applications 
758          */
759         $ldap->cat($appsrc,array("dn")) ;
760         if($ldap->count()){
761           $ldap->cd ($appdst);
762           $ldap->recursive_remove();
763           FAI::copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true);
764         }
766         /* Duplicate mime types 
767          */
768         $ldap->cat($mimesrc,array("dn")) ;
769         if($ldap->count()){
770           $ldap->cd ($mimedst);
771           $ldap->recursive_remove();
772           FAI::copy_FAI_resource_recursive($mimesrc,$mimedst,$NewReleaseName,$type,true);
773         }
775         $attr = array();
776         $attr['objectClass'] = array("organizationalUnit","FAIbranch");
777         $attr['ou']       = $name;
778         $attr['FAIstate'] = $type;
779         $ldap->cd($this->config->current['BASE']);
780         $ldap->cd("ou=".$name.",".$baseToUse);
781         $ldap->cat("ou=".$name.",".$baseToUse);
782         if($ldap->count()){
783           $ldap->modify($attr);
784         }else{
785           $ldap->add($attr);
786         }
788         /* Duplicate fai objects 
789          */
790         //      $ldap->cd ("ou=".$name.",".$baseToUse);
791         //      $ldap->recursive_remove();
792         //      FAI::copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,$NewReleaseName,$type,true);
794         echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
795           <br><input type='submit' name='CloseIFrame' value='"._("Continue")."'>
796           </form></div>";
798         echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
800         /* Print footer to have valid html */
801         echo "</body></html>";
803         $this->dispNewFreeze = false; 
805         /* Postcreate */ 
807         /* Assign possible attributes */
808         $this->lock_type  = $type; 
809         $this->lock_name  = $name; 
810         $this->lock_dn    = $baseToUse;
811         $this->postcreate();
814         /* Send daemon event to reload the fai release database 
815          */
816         if(class_available("DaemonEvent") && class_available("gosaSupportDaemon")){
817           $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
818           if(isset($events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'])){
819             $evt = $events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'];
820             $tmp = new $evt['CLASS_NAME']($this->config);
821             $tmp->set_type(TRIGGERED_EVENT);
822             $tmp->add_targets(array("GOsa"));
823             $o_queue = new gosaSupportDaemon();
824             if(!$o_queue->append($tmp)){
825               msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
826             }
827           }
828         }else{  
829           trigger_error("Unknown class DaemonEvent / gosaSupportDaemon");
830           msg_dialog::display(_("Fatal error"),
831               "Daemon events called but classes where not accessible, DaemonEvent gosaSupportDaemon",
832               FATAL_ERROR_DIALOG);
833         }
834         exit();
835       }
836     }
838     /****************
839       Display dialog to enter new Branch name
840      ****************/
842     /* Check if we have a post create method configured
843      *  else skip this operation. (Skip:Button in the ui should be disabled in this case too)
844      */
845     if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
846       if(($s_action == "branch_branch")||($this->dispNewBranch)){
847         if(!$this->acl_is_createable()){
848         msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
849         }else{
850           $this->dispNewBranch=true;
851           $smarty->assign("iframe",false);
852           $display      .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
853           return($display);
854         }
855       } 
856     }
858  
859     /****************
860       Display dialog to enter new Freeze name
861      ****************/
863     /* Check if we have a post create method configured
864      *  else skip this operation. (Skip:Button in the ui should be disabled in this case too)
865      */
866     if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
867       if(($s_action == "freeze_branch")||($this->dispNewFreeze)){
868         if(!$this->acl_is_createable()){
869           msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
870         }else{
871           $this->dispNewFreeze = true;
872           $smarty->assign("iframe",false);
873           $display      .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
874           return($display);
875         }
876       }
877     }
880     /****************
881       Create a new object 
882      ****************/
884     $types = array( "new_partition"     =>  "FAIpartitionTable",
885                     "new_script"        =>  "FAIscript",
886                     "new_hook"          =>  "FAIhook",
887                     "new_variable"      =>  "FAIvariable",
888                     "new_template"      =>  "FAItemplate",
889                     "new_package"       =>  "FAIpackageList");
890     $types_i18n = array( "new_partition"     =>  _("partition table"),
891                     "new_script"        =>  _("script"),
892                     "new_hook"          =>  _("hook"),
893                     "new_variable"      =>  _("variable"),
894                     "new_template"      =>  _("template"),
895                     "new_package"       =>  _("package list"));
897     if(isset($types[$s_action])){
898       $acl = $this->ui->get_permissions($this->fai_base,"fai/".$type_acl_mapping[$types[$s_action]]);
899       if(preg_match("/c/",$acl)){
900         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,$types[$s_action]);
901         $this->dialog->parent = &$this;
902       }else{
903         msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), $types_i18n[$s_action]), ERROR_DIALOG);
904       }
905     }
907     /* New Profile */
908     if($s_action == "new_profile"){
909       $this->dn = "new" ;
911       $acl = $this->ui->get_permissions($this->fai_base,"fai/faiProfile");
912       if(preg_match("/c/",$acl)){
913         $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
914         $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
915         $this->dialog->set_acl_base($this->base);
916         $this->dialog->parent = &$this;
918         $this->is_dialog = false;
919       }else{
920         msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), _("profile")), ERROR_DIALOG);
921       }
922     }
925     /****************
926       Get from ask class name dialog 
927      ****************/
929     if($s_action == "select_class_name_finished"){
930       $this->dialog->save_object();
931       if(count($this->dialog->check())!=0){
932         foreach($this->dialog->check() as $msg){
933           msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
934         }               
935       }elseif(isset($this->dialog->objectClass)){
936         $this->dn = "new" ;
937         $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass)));
938         $name = $this->dialog->save();
940         if(class_exists($a_setup[0])){
941           $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
942           $this->dialog->set_acl_base($this->base);
943           $this->dialog->by_object[$a_setup[1]]->cn = $name;
944           $this->dialog->parent = &$this;
945           $this->is_dialog = true;
946         }
947       }         
948     }   
951     /****************
952      Cancel dialogs 
953      ****************/
955                 if(isset($_POST['edit_cancel'])){
956                         $this->dialog=FALSE;
957                         $this->is_dialog = false;
958                         session::un_set('objectinfo');
959       $this->remove_lock();
960                 }
963     /****************
964       Save sub dialogs 
965      ****************/
967                 /* This check if the given tab could be saved 
968                  * If it was possible to save it, remove dialog object. 
969                  * If it wasn't possible, show errors and keep dialog.
970                  */
971                 if((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->dialog->config))){
972                         $this->dialog->save_object();
973       $msgs= $this->dialog->check();
974                         if(count($msgs)!=0){
975                                 foreach($msgs as $msg){
976           msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
977                                 }
978                         }else{
979                                 $this->dialog->save();
980         FAI::save_release_changes_now();
981         if (!isset($_POST['edit_apply'])){
982           $this->remove_lock();
983           $this->dialog=FALSE;
984           $this->is_dialog=false;
985           session::un_set('objectinfo');
986         }else{
988           /* Reinitialize tab */
989           if($this->dialog instanceof tabs){
990             $this->dialog->re_init();
991           }
992         }
993                         }
994                 }
997     /****************
998       Display currently open dialog 
999      ****************/
1001                 /* If dialog is set, but $this->is_dialog==false, then 
1002                  *  only the "abort" button is shown, this are dialogs that must not be saved.  
1003                  * If is_dialog == true, we are currently editing tab objects.
1004                  *  Here we need both, save and cancel
1005                  */ 
1007                 if(is_object($this->dialog)){
1008                         $display .= $this->dialog->execute();
1009                         /* Don't show buttons if tab dialog requests this */
1011       if(isset($this->dialog->current)){
1013         $obj = $this->dialog->by_object[$this->dialog->current];
1015         if((isset($obj->is_dialog) && (!$obj->is_dialog)) || (isset($obj->dialog) && (!$obj->dialog))){
1017           $display.= "<p style=\"text-align:right\">\n";
1018           if(!$this->no_save){
1019             $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
1020             $display.= "&nbsp;\n";
1021             if ($this->dn != "new"){
1022               $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
1023               $display.= "&nbsp;\n";
1024             }
1025           }
1026           $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1027           $display.= "</p>";
1028         }elseif(!isset($this->dialog->current)){
1029           $display.= "<p style=\"text-align:right\">\n";
1030           $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\">&nbsp;";
1031           $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1032           $display.= "</p>";
1033         }
1034       }else{
1035         $display.= "<p style=\"text-align:right\">\n";
1036         $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\">&nbsp;";
1037         $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1038         $display.= "</p>";
1040       }
1041       return($display);
1042                 }
1043                 
1045     /****************
1046       Dialog display
1047      ****************/
1049     /* Check if there is a snapshot dialog open */
1050     $base = $this->fai_base;
1051     if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
1052       return($str);
1053     }
1055     /* Display dialog with system list */
1056     $this->reload();
1057     $this->DivListFai->parent = &$this;
1058     $this->DivListFai->execute();
1059     $this->DivListFai->setEntries($this->objects);
1060     return($this->DivListFai->Draw());
1061         }
1064   /* Return departments, that will be included within snapshot detection */
1065   function get_used_snapshot_bases()
1066   {
1067     $tmp = array();
1068     $types = array("faipartitionou","faiscriptou","faitemplateou","faihookou","faiprofileou","faivariableou","faipackageou");
1069     foreach($types as $type){
1070       $tmp[] = get_ou($type).$this->fai_release;
1071     }
1072     return($tmp);
1073   }
1076   /* Get available branches for current base */
1077   function getBranches($base = false,$prefix = "")
1078   {
1079     $ret = array("/"=>$this->fai_base);
1080     $ldap = $this->config->get_ldap_link();
1081     if(!$base){
1082       $base = $this->fai_base;
1083     }
1084     $tmp = FAI::get_all_releases_from_base($base,true);
1085     foreach($tmp as $dn => $name){
1086       $ret[$name]=$dn;
1087     }
1088     ksort($ret);
1089     $ret = array_flip($ret);
1091     return ($ret);
1092   }
1093   
1095   function list_get_selected_items()
1096   {
1097     $ids = array();
1098     foreach($_POST as $name => $value){
1099       if(preg_match("/^item_selected_[0-9]*$/",$name)){
1100         $id   = preg_replace("/^item_selected_/","",$name);
1101         $ids[$id] = $id;
1102       }
1103     }
1104     return($ids);
1105   }
1108   /* reload list of objects */
1109   function reload()
1110   {
1111     /* Variable initialisation */
1112     $str            = "";
1113     $Regex          = $this->DivListFai->Regex;
1114     $this->objects  = array();
1116     /* Get base */
1117     $base = $this->fai_base;
1118     if($this->fai_release != $this->fai_base){
1119       $br = $this->getBranches();
1120       if(isset($br[$this->fai_release])){
1121         $base = $this->fai_release;
1122       }else{
1123         $base = $this->fai_base;
1124       }
1125     }
1126     $this->base = $base;
1127     $this->set_acl_base($this->base);
1129     $this->lock_type = FAI::get_release_tag(FAI::get_release_dn($base));
1131     /* Create a new list of FAI object 
1132      * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ... 
1133      */
1134     $ObjectTypes = array(
1135         "FAIpartitionTable"  => array("OU"=> get_ou('faipartitionou') , "CHKBOX"=>"ShowPartitions"  ,"ACL" => "faiPartitionTable"),
1136         "FAIpackageList"     => array("OU"=> get_ou('faipackageou')   , "CHKBOX"=>"ShowPackages"    ,"ACL" => "faiPackage"),
1137         "FAIscript"          => array("OU"=> get_ou('faiscriptou')    , "CHKBOX"=>"ShowScripts"     ,"ACL" => "faiScript"),
1138         "FAIvariable"        => array("OU"=> get_ou('faivariableou')  , "CHKBOX"=>"ShowVariables"   ,"ACL" => "faiVariable"),
1139         "FAIhook"            => array("OU"=> get_ou('faihookou')      , "CHKBOX"=>"ShowHooks"       ,"ACL" => "faiHook"),
1140         "FAIprofile"         => array("OU"=> get_ou('faiprofileou')   , "CHKBOX"=>"ShowProfiles"    ,"ACL" => "faiProfile"),
1141         "FAItemplate"        => array("OU"=> get_ou('faitemplateou')  , "CHKBOX"=>"ShowTemplates"   ,"ACL" => "faiTemplate"));
1143     $filter = "";
1144     foreach($ObjectTypes as $key => $data){
1145       if($this->DivListFai->$data['CHKBOX']){
1146         $filter.= "(objectClass=".$key.")";
1147       }
1148     }
1149     $filter = "(&(|".$filter.")(cn=$Regex))";
1150     
1151     /* Get resolved release dependencies */
1152     $tmp = FAI::get_all_objects_for_given_base($base,$filter);
1154     /* Ge listed ldap objects */
1155     $ldap = $this->config->get_ldap_link();
1156     $ldap->cd($this->config->current['BASE']);
1158     foreach($tmp as $entry){
1160       /* Get some more informations about the object */ 
1161       $ldap->cat($entry['dn'], array("cn","description","objectClass","FAIclass","FAIstate","objectClass"));
1162       $object  = $ldap->fetch();
1164       /* Walk through possible types */
1165       foreach($ObjectTypes as $type => $rest){  
1167         $acl = $this->ui->get_permissions($object['dn'],"fai/".$rest ['ACL']);
1169         if(in_array($type,$object['objectClass']) && preg_match("/r/",$acl)){
1171           /* Prepare object */
1172           unset($object['objectClass']['count']);
1173           if(!isset($object['description'][0])){
1174             $object['description'][0]="";
1175           }
1177           /* Clean up object informations */
1178           $obj                  = array();
1179           $obj['cn']                          = $object['cn'][0];
1180           $obj['dn']                          = $object['dn'];
1181           $obj['acl']                       = $acl;
1182           $obj['class']                           = $rest ['ACL'];
1183           $obj['FAIstate']      = $entry['FAIstate'];
1184           $obj['description']   = $object['description'][0];
1185           $obj['objectClass']   = $object['objectClass'];
1187           $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj;
1188           $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type;
1189         }
1190                         }
1191                 }
1193     /*  Append opsi objects, if opsi is available and if we are on the fai_base
1194      */
1195     if($this->opsi instanceof opsi && $this->opsi->enabled()){  
1197       $err = FALSE;
1198       if(!$err && $this->DivListFai->ShowOpsiNetboot){
1199         $n_pro = $this->opsi->get_netboot_products();
1200         $err |= $this->opsi->is_error();
1201         foreach($n_pro as $name => $data){
1202           $entry = array("cn" => $name,
1203               "description" => $data['DESC'],
1204               "type" => "opsi_netboot");
1205           $this->objects[$name."_opsi_netboot"] = $entry;
1206         }  
1207       }
1208       if(!$err && $this->DivListFai->ShowOpsiLocal){
1209         $l_pro = $this->opsi->get_local_products();
1210         $err |= $this->opsi->is_error();
1211         foreach($l_pro as $name => $data){
1212           $entry = array("cn" => $name,
1213               "description" => $data['DESC'],
1214               "type" => "opsi_local");
1215           $this->objects[$name."_opsi_local"] = $entry;
1216         }  
1217       }  
1218       if($err){
1219         msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
1220       }
1221     }
1223                 ksort($this->objects);
1224                 reset ($this->objects);
1225         
1226                 /* use numeric index, thats a bit more secure */        
1227                 $tmp0 = array();
1228                 foreach($this->objects as $obj){
1229                         $tmp0[]= $obj;
1230                 }
1231                 $this->objects = array();
1232                 $this->objects = $tmp0;
1233         }
1235         function remove_lock()
1236         {
1237                 if (isset($this->dn)){
1238                         del_lock ($this->dn);
1239                 }
1240     if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
1241       del_lock ($this->dns);
1242     }
1243         }
1245         function get_type($array){
1246                 if(in_array("FAIpartitionTable",$array['objectClass'])){
1247                         return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS"));
1248                 }
1249                 if(in_array("FAIscript",$array['objectClass'])){
1250                         return(array("tabsScript","faiScript","FAISCRIPTTABS"));
1251                 }
1252                 if(in_array("FAItemplate",$array['objectClass'])){
1253                         return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS"));
1254                 }
1255                 if(in_array("FAIhook",$array['objectClass'])){
1256                         return(array("tabsHook","faiHook","FAIHOOKTABS"));
1257                 }
1258                 if(in_array("FAIvariable",$array['objectClass'])){
1259                         return(array("tabsVariable","faiVariable","FAIVARIABLETABS"));
1260                 }
1261                 if(in_array("FAIprofile",$array['objectClass'])){
1262                         return(array("tabsProfile","faiProfile","FAIPROFILETABS"));
1263                 }
1264                 
1265                 if(in_array("FAIpackageList",$array['objectClass'])){
1266                         return(array("tabsPackage","faiPackage","FAIPACKAGETABS"));
1267                 }
1268         }
1270   function CheckNewBranchName($name,$base)
1271   {
1272     $f = $this->fai_release;
1273     if($name == ""){
1274       return(false);
1275     }elseif(in_array($name,$this->getBranches($f))) {
1276       return(false);
1277     }elseif(tests::is_department_name_reserved($name,$base)){
1278       return(false);
1279     }
1280     return(true);
1281   }
1283   function save_object()
1284   {
1285     $this->DivListFai->save_object();
1287     /* Get posted release */
1288     $r_releases = array_flip($this->getBranches());
1289     if(isset($_POST['fai_release']) && isset($r_releases[get_post('fai_release')])){
1291       /* Ensure that we have a valid release selected */
1292       if(!isset($r_releases[get_post('fai_release')])){
1293         msg_dialog::display(_("Warning"),_("The selected release is not available anymore. All triggered actions are skipped."));
1294         $_POST = array();
1295         $plug =$_GET['plug'];
1296         $_GET  = array("plug" => $plug);
1297         $this->fai_release = $this->fai_base;
1298       }else{
1299         $this->fai_release = $r_releases[get_post('fai_release')];
1300       }
1302       $fai_filter = session::get("fai_filter");
1303       $fai_filter['fai_release'] = $this->fai_release;
1304       session::set("fai_filter",$fai_filter);
1305     }
1307     if(is_object($this->CopyPasteHandler)){
1308       $this->CopyPasteHandler->save_object();
1309     }
1310   }
1313   function copyPasteHandling_from_queue($s_action,$s_entry)
1314   {
1315     /* Check if Copy & Paste is disabled */
1316     if(!is_object($this->CopyPasteHandler)){
1317       return("");
1318     }
1320     $ui = get_userinfo();
1322     /* Add a single entry to queue */
1323     if($s_action == "copy"){
1325       /* Cleanup object queue */
1326       $this->CopyPasteHandler->cleanup_queue();
1327       $entry    = $this->objects[$s_entry];
1328       $a_setup  = $this->get_type($entry);
1329       $dn = $entry['dn'];
1331       if($ui->is_copyable($dn,"fai",$a_setup[1])){
1332         $this->CopyPasteHandler->add_to_queue($dn,$s_action,$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1333       }
1334     }
1336     /* Add entries to queue */
1337     if($s_action == "copy_multiple"){
1339       /* Cleanup object queue */
1340       $this->CopyPasteHandler->cleanup_queue();
1342       /* Add new entries to CP queue */
1343       foreach($this->list_get_selected_items() as $id){
1345         /* Cleanup object queue */
1346         $entry    = $this->objects[$id];
1347         $a_setup  = $this->get_type($entry);
1348         $dn = $entry['dn'];
1350         if($s_action == "copy_multiple" && $ui->is_copyable($dn,"fai",$a_setup[1])){
1351           $this->CopyPasteHandler->add_to_queue($dn,"copy",$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1352         }
1353       }
1354     }
1356     /* Start pasting entries */
1357     if($s_action == "editPaste" && !($this->lock_type == "freeze" && !$this->allow_freeze_object_attach)){
1358       $this->start_pasting_copied_objects = TRUE;
1359     }
1361     /* Return C&P dialog */
1362     if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
1364       /* Get dialog */
1365       $this->CopyPasteHandler->SetVar("parent",$this);
1366       $data = $this->CopyPasteHandler->execute();
1368       FAI::save_release_changes_now();
1370       /* Return dialog data */
1371       if(!empty($data)){
1372         return($data);
1373       }
1374     }
1376     /* Automatically disable status for pasting */
1377     if(!$this->CopyPasteHandler->entries_queued()){
1378       $this->start_pasting_copied_objects = FALSE;
1379     }
1380     return("");
1381   }
1384   /* Check if the given FAI class is used in this release 
1385    */
1386   static function check_class_name($oc,$name,$dn)
1387   {
1388     $base = FAI::get_release_dn($dn);
1389     $res  = FAI::get_all_objects_for_given_base($base,"(objectClass=".$oc.")",TRUE);
1390     $delete = array();
1391     $used   = array();
1392     foreach($res as $object){
1393       $used[$object['cn'][0]]= $object['cn'][0];
1394     }
1395     return($used);
1396   }
1399   /* Return plugin informations for acl handling */ 
1400   static function plInfo()
1401   {
1402     return (array( 
1403           "plShortName"   => _("FAI releases"),
1404           "plDescription" => _("FAI release management"),
1405           "plSelfModify"  => FALSE,
1406           "plDepends"     => array(),
1407           "plPriority"    => 0,
1408           "plSection"     => array("administration"),           
1409           "plCategory"    => array("fai"=> array("description" => _("FAI"),
1410                                                  "objectClass" => "FAIclass")),
1411           "plProvidedAcls"=> array()));
1412   }
1414 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1415 ?>