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 $acl_base ="";
55 var $fai_base ="";
56 var $fai_release ="";
58 var $acl_module = array("fai");
60 var $opsi = NULL;
62 /* construction/reconstruction
63 */
64 function faiManagement (&$config, $ui)
65 {
66 /* Set defaults */
67 $this->dn = "";
68 $this->config = $config;
69 $this->ui = $ui;
71 /* Check if the opsi plugin is installed.
72 */
73 if(class_available("opsi")){
74 $this->opsi = new opsi($this->config);;
75 }
77 /* Creat dialog object */
78 $this->DivListFai = new divListFai($this->config,$this);
80 /* Copy & Paste handler */
81 if ($this->config->boolValueIsTrue("main", "copyPaste")){
82 $this->CopyPasteHandler= new CopyPasteHandler($this->config);
83 }
85 /* Set default release */
86 $this->fai_base = get_ou("faiou").$this->config->current['BASE'];
87 $this->acl_base = $this->config->current['BASE'];
89 if(!session::is_set("fai_filter")){
91 /* Set intial release */
92 $rel = $config->search("faiManagement","DEFAULT_RELEASE",array("menu"));
93 $rels = array_flip($this->getBranches());
94 if(isset($rels[$rel])){
95 $rel = $rels[$rel];
96 }else{
97 $rel = $this->fai_base;
98 }
100 session::set("fai_filter",array("fai_release" => $rel));
101 }
103 $fai_filter = session::get("fai_filter");
104 $this->fai_release = $fai_filter['fai_release'];
105 }
107 function execute()
108 {
109 /* Call parent execute */
110 plugin::execute();
113 /* Initialise vars and smarty */
114 $smarty = get_smarty();
115 $smarty->assign("BranchName","");
117 $display = "";
118 $s_action = "";
119 $s_entry = "";
120 $no_save = FALSE; // hide Apply / Save buttons
122 /* If an entry was locked, these vars will be stored in a session to allow direct edit */
123 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/"));
126 /****************
127 Handle posts
128 ****************/
130 /* Check ImageButton posts
131 * Create new tab ich new_xx is posted
132 */
133 $posts = array( "/remove_branch/"=>"remove_branch", "/branch_branch/"=>"branch_branch",
134 "/freeze_branch/"=>"freeze_branch", "/create_partition/i"=>"new_partition",
135 "/create_script/i"=>"new_script", "/create_hook/i"=>"new_hook",
136 "/create_variable/i"=>"new_variable", "/create_template/i"=>"new_template",
137 "/create_package/i"=>"new_package", "/create_profile/i"=>"new_profile",
138 "/edit_continue/"=>"select_class_name_finished",
139 "/^multiple_copy_fai/" => "copy_multiple",
140 "/^multiple_cut_fai/" => "cut_multiple",
141 "/^copy/" => "copy",
142 "/^remove_multiple_fai_objects/" => "del_multiple");
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 }
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 tabs_opsiProdConfig($this->config, $this->config->data['TABS']['OPSIPRODCONFIG'],"","opsi");
273 if(isset($this->dialog->by_object['opsiProperties'])){
274 $this->dialog->by_object['opsiProperties']->set_cfg($cfg);
275 $this->dialog->by_object['opsiProperties']->set_product($name);
276 }else{
277 trigger_error("Unknown tab, please check config.");
278 }
279 }
280 if($this->dialog instanceof tabs_opsiProdConfig && isset($_POST['cancel_properties'])){
281 $this->dialog = NULL;
282 }
283 if($this->dialog instanceof tabs_opsiProdConfig && isset($_POST['save_properties'])){
284 $this->dialog->save_object();
285 $op = $this->dialog->by_object['opsiProperties'];
286 $name = $op->get_product();
287 $cfg = $op->get_cfg();
288 $this->opsi->set_product_properties($name,$cfg);
289 if($this->opsi->is_error()){
290 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
291 }else{
292 $this->dialog = NULL;
293 }
294 }
295 if($this->dialog instanceof tabs_opsiProdConfig){
296 $this->dialog->save_object();
297 return($this->dialog->execute());
298 }
299 }
302 /****************
303 Delete confirme dialog
304 ****************/
306 if ($s_action=="delete"){
308 /* Get 'dn' from posted termlinst */
309 $this->dn= $this->objects[$s_entry]['dn'];
311 /* Load permissions for selected 'dn' and check if
312 we're allowed to remove this 'dn' */
313 $acl = $this->ui->get_permissions($this->dn,"fai/".$type_acl_mapping[$this->objects[$s_entry]['type']]);
314 if(preg_match("/d/",$acl)){
316 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
317 if (($user= get_lock($this->dn)) != ""){
318 return(gen_locked_message ($user, $this->dn));
319 }
321 /* Lock the current entry, so nobody will edit it during deletion */
322 add_lock ($this->dn, $this->ui->dn);
323 $smarty->assign("warning",msgPool::deleteInfo(@LDAP::fix($this->dn),_("FAI object")));
324 $smarty->assign("multiple", false);
325 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
326 } else {
328 /* Obviously the user isn't allowed to delete. Show message and clean session. */
329 msg_dialog::display(_("Permission error"), msgPool::permDelete(),ERROR_DIALOG);
330 }
331 }
334 /********************
335 Delete MULTIPLE entries requested, display confirm dialog
336 ********************/
338 if ($s_action=="del_multiple"){
339 $this->dns = array();
340 $ids = $this->list_get_selected_items();
342 if(count($ids)){
344 $errors = "";
345 foreach($ids as $id){
346 $dn = $this->objects[$id]['dn'];
347 $cn = $this->objects[$id]['cn'];
348 if(!preg_match('/^freeze/', $this->objects[$id]['FAIstate'])){
349 $this->dns[$id] = $dn;
350 }else{
351 $errors .= $cn.", ";
352 }
353 }
354 if ($user= get_multiple_locks($this->dns)){
355 return(gen_locked_message($user,$this->dns));
356 }
358 if($errors != ""){
359 msg_dialog::display(_("Branch locked"),sprintf(_("The following entries are locked, you can't remove them %s."),
360 "<br><br>".trim($errors,", ")),INFO_DIALOG);
361 }
363 if(count($this->dns)){
365 $dns_names = array();
366 foreach($this->dns as $dn){
367 add_lock ($dn, $this->ui->dn);
368 $dns_names[] = @LDAP::fix($dn);
369 }
371 /* Lock the current entry, so nobody will edit it during deletion */
372 $smarty->assign("warning",msgPool::deleteInfo($dns_names,_("FAI object")));
373 $smarty->assign("multiple", true);
374 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
375 }
376 }
377 }
380 /********************
381 Delete MULTIPLE entries confirmed
382 ********************/
384 /* Confirmation for deletion has been passed. Users should be deleted. */
385 if (isset($_POST['delete_multiple_fai_object_confirm'])){
387 /* Find out more about the object type */
388 $ldap = $this->config->get_ldap_link();
390 /* Remove user by user and check acls before removeing them */
391 foreach($this->dns as $key => $dn){
393 $ldap->cat($dn, array('objectClass'));
394 $attrs = $ldap->fetch();
395 $type = $this->get_type($attrs);
397 $acl = $this->ui->get_permissions($dn,"fai/".$type[1]);
398 if(preg_match("/d/",$acl)){
400 $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $dn,"fai");
401 $this->dialog->parent = &$this;
402 $this->dialog->set_acl_base($dn);
403 $this->dialog->by_object[$type[1]]->remove_from_parent ();
404 unset ($this->dialog);
405 $this->dialog= FALSE;
406 $to_del = FAI::clean_up_releases($dn);
407 FAI::save_release_changes_now();
409 foreach($to_del as $dn){
410 $ldap->rmdir_recursive($dn);
411 }
413 } else {
415 /* Normally this shouldn't be reached, send some extra
416 logs to notify the administrator */
417 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
418 new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion.");
419 }
420 }
422 /* Remove lock file after successfull deletion */
423 $this->remove_lock();
424 $this->dns = array();
425 }
428 /********************
429 Delete MULTIPLE entries Canceled
430 ********************/
432 /* Remove lock */
433 if(isset($_POST['delete_multiple_fai_object_cancel'])){
434 $this->dns = array();
435 $this->remove_lock();
436 }
439 /****************
440 Delete aborted
441 ****************/
443 /* Delete canceled? */
444 if (isset($_POST['delete_cancel'])){
445 $this->remove_lock();
446 }
449 /****************
450 Delete confirmed
451 ****************/
453 /* Deletion was confirmed, so delete this entry
454 */
455 if (isset($_POST['delete_terminal_confirm'])){
457 /* Some nice guy may send this as POST, so we've to check
458 for the permissions again. */
460 /* Find out more about the object type */
461 $ldap = $this->config->get_ldap_link();
462 $ldap->cat($this->dn, array('objectClass'));
463 if($ldap->count()){
464 $attrs = $ldap->fetch();
465 $type = $this->get_type($attrs);
467 $acl = $this->ui->get_permissions($this->dn,"fai/".$type[1]);
468 if(preg_match("/d/",$acl)){
470 $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $this->dn,"fai");
471 $this->dialog->set_acl_base($this->dn);
472 $this->dialog->parent = &$this;
473 $this->dialog->by_object[$type[1]]->remove_from_parent ();
474 unset ($this->dialog);
475 $this->dialog= FALSE;
476 $to_del = FAI::clean_up_releases($this->dn);
477 FAI::save_release_changes_now();
479 foreach($to_del as $dn){
480 $ldap->rmdir_recursive($dn);
481 }
483 } else {
485 /* Normally this shouldn't be reached, send some extra
486 logs to notify the administrator */
487 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
488 new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion.");
489 }
491 }else{
492 msg_dialog::display(_("Error"), sprintf(_("Cannot delete '%s': object does not exist!"), $this->dn) , ERROR_DIALOG);
493 }
495 /* Remove lock file after successfull deletion */
496 $this->remove_lock();
497 }
500 /****************
501 Edit entry
502 ****************/
504 if(($s_action == "edit") && (!isset($this->dialog->config))){
505 $entry = $this->objects[$s_entry];
506 $a_setup = $this->get_type($entry);
507 $this->dn = $entry['dn'];
509 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
510 if (($user= get_lock($this->dn)) != ""){
511 return(gen_locked_message ($user, $this->dn));
512 }
513 add_lock ($this->dn, $this->ui->dn);
515 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
516 $this->dialog->parent = &$this;
517 $this->dialog->by_object[$a_setup[1]]->FAIstate = $entry['FAIstate'];
518 $this->dialog->set_acl_base($this->dn);
519 $this->is_dialog = true;
520 session::set('objectinfo',$this->dn);
521 }
524 /* Branch handling
525 09.01.2006
526 */
528 /****************
529 Remove branch
530 ****************/
532 /* Remove branch
533 */
534 if($s_action == "remove_branch"){
535 $base= $this->fai_release;
537 /* Check if we have a post remove method configured
538 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
539 */
540 if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
541 /* Load permissions for selected 'dn' and check if
542 we're allowed to remove this 'dn' */
543 if(preg_match("/d/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
544 $smarty->assign("release_hidden",base64_encode($this->fai_release));
545 $smarty->assign("info", msgPool::deleteInfo(@LDAP::fix($this->fai_release),_("FAI branch/freeze")));
546 return($smarty->fetch(get_template_path('remove_branch.tpl',TRUE)));
547 } else {
548 msg_dialog::display(_("Permission error"), _("You have no permission to delete this release!"), ERROR_DIALOG);
549 }
550 }
551 }
554 /****************
555 Remove branch confirmed
556 ****************/
558 if(isset($_POST['delete_branch_confirm'])){
560 /* Check if we have a post remove method configured
561 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
562 */
563 if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
565 if(!isset($_POST['release_hidden']) || base64_decode($_POST['release_hidden']) != $this->fai_release){
566 msg_dialog::display(_("Warning"),_("Release remove aborted because the release name check failed!"));
567 }else{
569 $bb = $this->fai_release;
570 if(!isset($ldap)){
571 $ldap = $this->config->get_ldap_link();
572 }
574 $br = $this->getBranches();
576 if(isset($br[$bb]) && preg_match("/d/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
577 $name = $br[$bb];
579 $ldap->cd($bb);
580 $ldap->recursive_remove();
581 $ldap->cd(preg_replace('/,'.normalizePreg(get_ou('faiou')).'/', ','.get_ou('applicationou'), $bb));
582 $ldap->recursive_remove();
583 $ldap->cd(preg_replace('/,'.normalizePreg(get_ou('faiou')).'/', ','.get_ou('mimetypeou'), $bb));
584 $ldap->recursive_remove();
586 /* Search for all groups with configured application menus.
587 - First search all groups, to ensure that we only remove entries form whithin groups.
588 - The search für menu configuration for the specified release and collect all those dns.
589 - Remove entries
590 */
591 $release_ou = preg_replace("/".normalizePreg(get_ou("faiou")).".*$/","",$bb);
592 $ldap->cd($this->config->current['BASE']);
593 $ldap->search("(objectClass=posixGroup)",array("dn"));
595 /* Collect all group dns
596 */
597 $groups = array();
598 while($attrs = $ldap->fetch()){
599 $groups[] = $attrs['dn'];
600 }
602 /* Collect all group menu release dns that match the release we have removed
603 */
604 $dns = array();
605 foreach($groups as $dn){
606 $ldap->cd($dn);
607 $ldap->search("(objectClass=FAIbranch)",array("dn"));
608 while($attrs = $ldap->fetch()){
609 if(preg_match("/^".normalizePreg($release_ou)."/",$attrs['dn'])){
610 $dns[] = $attrs['dn'];
611 }
612 }
613 }
615 /* Finally remove collected release dns
616 */
617 foreach($dns as $dn){
618 $ldap->cd($dn);
619 $ldap->recursive_remove();
620 }
622 /* Post remove */
623 $this->fai_release = $this->fai_base;
624 $this->lock_name = $name;
625 $this->lock_dn = $bb;
626 $this->postremove();
628 $fai_filter = session::get("fai_filter");
629 $fai_filter['fai_release'] = $this->fai_release;
630 session::set("fai_filter",$fai_filter);
632 new log("remove","fai/".get_class($this),$br[$bb],array(),"Release removed");
633 }
634 }
635 }
636 }
639 /****************
640 Create a new branch "insert Name"
641 ****************/
643 if((isset($_POST['UseBranchName']))&&(($this->dispNewBranch)||($this->dispNewFreeze))){
644 session::set('LASTPOST',$_POST);
646 if($this->dispNewBranch){
647 $type = "branch";
648 }else{
649 $type = "freeze";
650 }
652 /* Check branch name */
653 $name = $_POST['BranchName'];
654 $is_ok = true;
655 $smarty->assign("BranchName",$name);
656 $base= $this->fai_base;
658 /* Check used characters */
659 if(!preg_match("/^[0-9a-z\.]*$/",$name)){
660 msg_dialog::display(_("Error"), msgPool::invalid(_("Name"),$name,"/[0-9a-z\.]/"), ERROR_DIALOG);
661 $is_ok = false;
662 }
664 /* Check if this name is already in use */
665 if(!$this->CheckNewBranchName($_POST['BranchName'],$this->fai_release)){
666 msg_dialog::display(_("Error"), msgPool::duplicated(_("Name")), ERROR_DIALOG);
667 $is_ok = false;
668 }
670 if($is_ok){
672 if(session::is_set('LASTPOST')){
673 $LASTPOST = session::get('LASTPOST');
674 }else{
675 $LASTPOST = array();
676 }
677 $LASTPOST['base'] = $base;
678 $LASTPOST['type'] = $type;
679 session::set('LASTPOST',$LASTPOST);
680 $smarty->assign("iframe", true);
681 $smarty->assign("plugID", $_GET['plug']);
682 $display = $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
683 return($display);
684 }
685 }
688 /****************
689 Create a new branch
690 ****************/
692 if(isset($_GET['PerformBranch'])){
694 if(!preg_match("/c/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
695 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
696 }else{
698 /* In order to see error messages we have to reset the error handler.
699 Due to the exit();
700 */
701 restore_error_handler();
703 /* Create it know */
704 $this->dispNewBranch = false;
705 $this->dispNewFreeze = false;
707 $LASTPOST = session::get('LASTPOST');
708 $base = $LASTPOST['base'];
709 $_POST = session::get('LASTPOST');
710 $name = $_POST['BranchName'];
712 $type = $LASTPOST['type'];
713 $ldap = $this->config->get_ldap_link();
715 $baseToUse = $base;
716 if($this->fai_release != $this->fai_base){
717 $baseToUse = $this->fai_release;
718 }
720 /* Create new Release name to be able to set faidebianRelease for FAIpackageList */
722 $CurrentReleases = $this->getBranches();
723 $NewReleaseName = $name;
724 if(isset($CurrentReleases[$this->fai_release])) {
725 if($this->fai_release != $this->fai_base){
726 $NewReleaseName = $CurrentReleases[$this->fai_release]."/".$name;
727 $NewReleaseName = preg_replace("#\/#","/",$NewReleaseName);
728 }else{
729 $NewReleaseName = $name;
730 }
731 }
733 $appsrc = preg_replace("/".normalizePreg(get_ou('faiou'))."/",get_ou('applicationou'),$baseToUse);
734 $appdst = preg_replace("/".normalizePreg(get_ou('faiou'))."/",get_ou('applicationou'),"ou=".$name.",".$baseToUse) ;
736 $mimesrc = preg_replace("/".normalizePreg(get_ou('faiou'))."/",get_ou('mimetypeou'),$baseToUse);
737 $mimedst = preg_replace("/".normalizePreg(get_ou('faiou'))."/",get_ou('mimetypeou'),"ou=".$name.",".$baseToUse) ;
739 /* Check if source depeartments exist */
740 foreach(array($baseToUse,$appsrc,$mimesrc) as $dep){
741 $ldap->cd($this->config->current['BASE']);
742 $ldap->cat($dep);
743 if(!$ldap->count()){
744 $ldap->create_missing_trees($dep);
745 }
746 }
748 /* Print header to have styles included */
749 echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
750 <html>
751 <head>
752 <title></title>
753 <style type="text/css">@import url("themes/default/style.css");</style>
754 <script language="javascript" src="include/focus.js" type="text/javascript"></script>
755 </head>
756 <body style="background: none;margin:3px;color:black">
757 ';
759 new log("create","fai/".get_class($this),$NewReleaseName,array(),"New $type created");
761 /* Duplicate group application releases
762 */
763 FAI::copy_FAI_group_releases($CurrentReleases[$this->fai_release],$name,$type);
765 /* Duplicate applications
766 */
767 $ldap->cat($appsrc,array("dn")) ;
768 if($ldap->count()){
769 $ldap->cd ($appdst);
770 $ldap->recursive_remove();
771 FAI::copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true);
772 }
774 /* Duplicate mime types
775 */
776 $ldap->cat($mimesrc,array("dn")) ;
777 if($ldap->count()){
778 $ldap->cd ($mimedst);
779 $ldap->recursive_remove();
780 FAI::copy_FAI_resource_recursive($mimesrc,$mimedst,$NewReleaseName,$type,true);
781 }
783 $attr = array();
784 $attr['objectClass'] = array("organizationalUnit","FAIbranch");
785 $attr['ou'] = $name;
786 $attr['FAIstate'] = $type;
787 $ldap->cd($this->config->current['BASE']);
788 $ldap->cd("ou=".$name.",".$baseToUse);
789 $ldap->cat("ou=".$name.",".$baseToUse);
790 if($ldap->count()){
791 $ldap->modify($attr);
792 }else{
793 $ldap->add($attr);
794 }
796 /* Duplicate fai objects
797 */
798 // $ldap->cd ("ou=".$name.",".$baseToUse);
799 // $ldap->recursive_remove();
800 // FAI::copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,$NewReleaseName,$type,true);
802 echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
803 <br><input type='submit' name='CloseIFrame' value='"._("Continue")."'>
804 <input type='hidden' name='php_c_check' value='1'>
805 </form></div>";
807 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
809 /* Print footer to have valid html */
810 echo "</body></html>";
812 $this->dispNewFreeze = false;
814 /* Postcreate */
816 /* Assign possible attributes */
817 $this->lock_type = $type;
818 $this->lock_name = $name;
819 $this->lock_dn = $baseToUse;
820 $this->postcreate();
823 /* Send daemon event to reload the fai release database
824 */
825 if(class_available("DaemonEvent") && class_available("gosaSupportDaemon")){
826 $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
827 if(isset($events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'])){
828 $evt = $events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'];
829 $tmp = new $evt['CLASS_NAME']($this->config);
830 $tmp->set_type(TRIGGERED_EVENT);
831 $tmp->add_targets(array("GOsa"));
832 $o_queue = new gosaSupportDaemon();
833 if(!$o_queue->append($tmp)){
834 msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
835 }
836 }
837 }else{
838 trigger_error("Unknown class DaemonEvent / gosaSupportDaemon");
839 msg_dialog::display(_("Fatal error"),
840 "Daemon events called but classes where not accessible, DaemonEvent gosaSupportDaemon",
841 FATAL_ERROR_DIALOG);
842 }
843 exit();
844 }
845 }
847 /****************
848 Display dialog to enter new Branch name
849 ****************/
851 /* Check if we have a post create method configured
852 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
853 */
854 if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
855 if(($s_action == "branch_branch")||($this->dispNewBranch)){
856 if(!preg_match("/c/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
857 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
858 }else{
859 $this->dispNewBranch=true;
860 $smarty->assign("iframe",false);
861 $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
862 return($display);
863 }
864 }
865 }
868 /****************
869 Display dialog to enter new Freeze name
870 ****************/
872 /* Check if we have a post create method configured
873 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
874 */
875 if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
876 if(($s_action == "freeze_branch")||($this->dispNewFreeze)){
877 if(!preg_match("/c/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
878 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
879 }else{
880 $this->dispNewFreeze = true;
881 $smarty->assign("iframe",false);
882 $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
883 return($display);
884 }
885 }
886 }
889 /****************
890 Create a new object
891 ****************/
893 $types = array( "new_partition" => "FAIpartitionTable",
894 "new_script" => "FAIscript",
895 "new_hook" => "FAIhook",
896 "new_variable" => "FAIvariable",
897 "new_template" => "FAItemplate",
898 "new_package" => "FAIpackageList");
899 $types_i18n = array( "new_partition" => _("partition table"),
900 "new_script" => _("script"),
901 "new_hook" => _("hook"),
902 "new_variable" => _("variable"),
903 "new_template" => _("template"),
904 "new_package" => _("package list"));
906 if(isset($types[$s_action])){
907 $acl = $this->ui->get_permissions($this->acl_base,"fai/".$type_acl_mapping[$types[$s_action]]);
908 if(preg_match("/c/",$acl)){
909 $this->dialog = new askClassName($this->config,$this->dn,$this->ui,$types[$s_action]);
910 $this->dialog->parent = &$this;
911 }else{
912 msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), $types_i18n[$s_action]), ERROR_DIALOG);
913 }
914 }
916 /* New Profile */
917 if($s_action == "new_profile"){
918 $this->dn = "new" ;
919 $acl = $this->ui->get_permissions($this->acl_base,"fai/faiProfile");
920 if(preg_match("/c/",$acl)){
921 $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
922 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
923 $this->dialog->set_acl_base($this->acl_base);
924 $this->dialog->parent = &$this;
925 $this->is_dialog = false;
926 }else{
927 msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), _("profile")), ERROR_DIALOG);
928 }
929 }
932 /****************
933 Get from ask class name dialog
934 ****************/
936 if($s_action == "select_class_name_finished"){
937 $this->dialog->save_object();
938 if(count($this->dialog->check())!=0){
939 foreach($this->dialog->check() as $msg){
940 msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
941 }
942 }elseif(isset($this->dialog->objectClass)){
943 $this->dn = "new" ;
944 $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass)));
945 $name = $this->dialog->save();
947 if(class_exists($a_setup[0])){
948 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
949 $this->dialog->set_acl_base($this->acl_base);
950 $this->dialog->by_object[$a_setup[1]]->cn = $name;
951 $this->dialog->parent = &$this;
952 $this->is_dialog = true;
953 }
954 }
955 }
958 /****************
959 Cancel dialogs
960 ****************/
962 if(isset($_POST['edit_cancel'])){
963 $this->dialog=FALSE;
964 $this->is_dialog = false;
965 session::un_set('objectinfo');
966 $this->remove_lock();
967 }
970 /****************
971 Save sub dialogs
972 ****************/
974 /* This check if the given tab could be saved
975 * If it was possible to save it, remove dialog object.
976 * If it wasn't possible, show errors and keep dialog.
977 */
978 if((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->dialog->config))){
979 $this->dialog->save_object();
980 $msgs= $this->dialog->check();
981 if(count($msgs)!=0){
982 foreach($msgs as $msg){
983 msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
984 }
985 }else{
986 $this->dialog->save();
987 FAI::save_release_changes_now();
988 if (!isset($_POST['edit_apply'])){
989 $this->remove_lock();
990 $this->dialog=FALSE;
991 $this->is_dialog=false;
992 session::un_set('objectinfo');
993 }else{
995 /* Reinitialize tab */
996 if($this->dialog instanceof tabs){
997 $this->dialog->re_init();
998 }
999 }
1000 }
1001 }
1004 /****************
1005 Display currently open dialog
1006 ****************/
1008 /* If dialog is set, but $this->is_dialog==false, then
1009 * only the "abort" button is shown, this are dialogs that must not be saved.
1010 * If is_dialog == true, we are currently editing tab objects.
1011 * Here we need both, save and cancel
1012 */
1014 if(is_object($this->dialog)){
1015 $display .= $this->dialog->execute();
1016 /* Don't show buttons if tab dialog requests this */
1018 if(isset($this->dialog->current)){
1020 $obj = $this->dialog->by_object[$this->dialog->current];
1022 if((isset($obj->is_dialog) && (!$obj->is_dialog)) || (isset($obj->dialog) && (!$obj->dialog))){
1024 $display.= "<p style=\"text-align:right\">\n";
1025 if(!$this->no_save){
1026 $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
1027 $display.= " \n";
1028 if ($this->dn != "new"){
1029 $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
1030 $display.= " \n";
1031 }
1032 }
1033 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1034 $display.= "</p>";
1035 }elseif(!isset($this->dialog->current)){
1036 $display.= "<p style=\"text-align:right\">\n";
1037 $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\"> ";
1038 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1039 $display.= "</p>";
1040 }
1041 }else{
1042 $display.= "<p style=\"text-align:right\">\n";
1043 $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\"> ";
1044 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1045 $display.= "</p>";
1047 }
1048 return($display);
1049 }
1052 /****************
1053 Dialog display
1054 ****************/
1056 /* Check if there is a snapshot dialog open */
1057 $base = $this->fai_base;
1058 if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
1059 return($str);
1060 }
1062 /* Display dialog with system list */
1063 $this->reload();
1064 $this->DivListFai->parent = &$this;
1065 $this->DivListFai->execute();
1066 $this->DivListFai->setEntries($this->objects);
1067 return($this->DivListFai->Draw());
1068 }
1071 /* Return departments, that will be included within snapshot detection */
1072 function get_used_snapshot_bases()
1073 {
1074 $tmp = array();
1075 $types = array("faipartitionou","faiscriptou","faitemplateou","faihookou","faiprofileou","faivariableou","faipackageou");
1076 foreach($types as $type){
1077 $tmp[] = get_ou($type).$this->fai_release;
1078 }
1079 return($tmp);
1080 }
1083 /* Get available branches for current base */
1084 function getBranches($base = false,$prefix = "")
1085 {
1086 $ret = array("/"=>$this->fai_base);
1087 $ldap = $this->config->get_ldap_link();
1088 if(!$base){
1089 $base = $this->fai_base;
1090 }
1091 $tmp = FAI::get_all_releases_from_base($base,true);
1092 foreach($tmp as $dn => $name){
1093 $ret[$name]=$dn;
1094 }
1095 ksort($ret);
1096 $ret = array_flip($ret);
1098 return ($ret);
1099 }
1102 function list_get_selected_items()
1103 {
1104 $ids = array();
1105 foreach($_POST as $name => $value){
1106 if(preg_match("/^item_selected_[0-9]*$/",$name)){
1107 $id = preg_replace("/^item_selected_/","",$name);
1108 $ids[$id] = $id;
1109 }
1110 }
1111 return($ids);
1112 }
1115 /* reload list of objects */
1116 function reload()
1117 {
1118 /* Variable initialisation */
1119 $str = "";
1120 $Regex = $this->DivListFai->Regex;
1121 $this->objects = array();
1123 /* Get base */
1124 $base = $this->fai_base;
1125 if($this->fai_release != $this->fai_base){
1126 $br = $this->getBranches();
1127 if(isset($br[$this->fai_release])){
1128 $base = $this->fai_release;
1129 }else{
1130 $base = $this->fai_base;
1131 }
1132 }
1133 $this->base = $base;
1134 $this->set_acl_base($this->acl_base);
1136 $this->lock_type = FAI::get_release_tag(FAI::get_release_dn($base));
1138 /* Create a new list of FAI object
1139 * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ...
1140 */
1141 $ObjectTypes = array(
1142 "FAIpartitionTable" => array("OU"=> get_ou('faipartitionou') , "CHKBOX"=>"ShowPartitions" ,"ACL" => "faiPartitionTable"),
1143 "FAIpackageList" => array("OU"=> get_ou('faipackageou') , "CHKBOX"=>"ShowPackages" ,"ACL" => "faiPackage"),
1144 "FAIscript" => array("OU"=> get_ou('faiscriptou') , "CHKBOX"=>"ShowScripts" ,"ACL" => "faiScript"),
1145 "FAIvariable" => array("OU"=> get_ou('faivariableou') , "CHKBOX"=>"ShowVariables" ,"ACL" => "faiVariable"),
1146 "FAIhook" => array("OU"=> get_ou('faihookou') , "CHKBOX"=>"ShowHooks" ,"ACL" => "faiHook"),
1147 "FAIprofile" => array("OU"=> get_ou('faiprofileou') , "CHKBOX"=>"ShowProfiles" ,"ACL" => "faiProfile"),
1148 "FAItemplate" => array("OU"=> get_ou('faitemplateou') , "CHKBOX"=>"ShowTemplates" ,"ACL" => "faiTemplate"));
1150 $filter = "";
1151 foreach($ObjectTypes as $key => $data){
1152 if($this->DivListFai->$data['CHKBOX']){
1153 $filter.= "(objectClass=".$key.")";
1154 }
1155 }
1156 $filter = "(&(|".$filter.")(cn=$Regex))";
1158 /* Get resolved release dependencies */
1159 $tmp = FAI::get_all_objects_for_given_base($base,$filter);
1161 /* Ge listed ldap objects */
1162 $ldap = $this->config->get_ldap_link();
1163 $ldap->cd($this->config->current['BASE']);
1165 foreach($tmp as $entry){
1167 /* Get some more informations about the object */
1168 $ldap->cat($entry['dn'], array("cn","description","objectClass","FAIclass","FAIstate","objectClass"));
1169 $object = $ldap->fetch();
1171 /* Walk through possible types */
1172 foreach($ObjectTypes as $type => $rest){
1174 $acl = $this->ui->get_permissions($object['dn'],"fai/".$rest ['ACL']);
1176 if(in_array($type,$object['objectClass']) && preg_match("/r/",$acl)){
1178 /* Prepare object */
1179 unset($object['objectClass']['count']);
1180 if(!isset($object['description'][0])){
1181 $object['description'][0]="";
1182 }
1184 /* Clean up object informations */
1185 $obj = array();
1186 $obj['cn'] = $object['cn'][0];
1187 $obj['dn'] = $object['dn'];
1188 $obj['acl'] = $acl;
1189 $obj['class'] = $rest ['ACL'];
1190 $obj['FAIstate'] = $entry['FAIstate'];
1191 $obj['description'] = $object['description'][0];
1192 $obj['objectClass'] = $object['objectClass'];
1194 $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj;
1195 $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type;
1196 }
1197 }
1198 }
1200 /* Append opsi objects, if opsi is available and if we are on the fai_base
1201 */
1202 if($this->opsi instanceof opsi && $this->opsi->enabled()){
1204 $err = FALSE;
1205 if(!$err && $this->DivListFai->ShowOpsiNetboot){
1206 $n_pro = $this->opsi->get_netboot_products();
1207 $err |= $this->opsi->is_error();
1208 foreach($n_pro as $name => $data){
1209 $entry = array("cn" => $name,
1210 "description" => $data['DESC'],
1211 "type" => "opsi_netboot");
1212 $this->objects[$name."_opsi_netboot"] = $entry;
1213 }
1214 }
1215 if(!$err && $this->DivListFai->ShowOpsiLocal){
1216 $l_pro = $this->opsi->get_local_products();
1217 $err |= $this->opsi->is_error();
1218 foreach($l_pro as $name => $data){
1219 $entry = array("cn" => $name,
1220 "description" => $data['DESC'],
1221 "type" => "opsi_local");
1222 $this->objects[$name."_opsi_local"] = $entry;
1223 }
1224 }
1225 if($err){
1226 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
1227 }
1228 }
1230 ksort($this->objects);
1231 reset ($this->objects);
1233 /* use numeric index, thats a bit more secure */
1234 $tmp0 = array();
1235 foreach($this->objects as $obj){
1236 $tmp0[]= $obj;
1237 }
1238 $this->objects = array();
1239 $this->objects = $tmp0;
1240 }
1242 function remove_lock()
1243 {
1244 if (isset($this->dn)){
1245 del_lock ($this->dn);
1246 }
1247 if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
1248 del_lock ($this->dns);
1249 }
1250 }
1252 function get_type($array){
1253 if(in_array("FAIpartitionTable",$array['objectClass'])){
1254 return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS"));
1255 }
1256 if(in_array("FAIscript",$array['objectClass'])){
1257 return(array("tabsScript","faiScript","FAISCRIPTTABS"));
1258 }
1259 if(in_array("FAItemplate",$array['objectClass'])){
1260 return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS"));
1261 }
1262 if(in_array("FAIhook",$array['objectClass'])){
1263 return(array("tabsHook","faiHook","FAIHOOKTABS"));
1264 }
1265 if(in_array("FAIvariable",$array['objectClass'])){
1266 return(array("tabsVariable","faiVariable","FAIVARIABLETABS"));
1267 }
1268 if(in_array("FAIprofile",$array['objectClass'])){
1269 return(array("tabsProfile","faiProfile","FAIPROFILETABS"));
1270 }
1272 if(in_array("FAIpackageList",$array['objectClass'])){
1273 return(array("tabsPackage","faiPackage","FAIPACKAGETABS"));
1274 }
1275 }
1277 function CheckNewBranchName($name,$base)
1278 {
1279 $f = $this->fai_release;
1280 if($name == ""){
1281 return(false);
1282 }elseif(in_array($name,$this->getBranches($f))) {
1283 return(false);
1284 }elseif(tests::is_department_name_reserved($name,$base)){
1285 return(false);
1286 }
1287 return(true);
1288 }
1290 function save_object()
1291 {
1292 $this->DivListFai->save_object();
1294 /* Get posted release */
1295 $r_releases = array_flip($this->getBranches());
1296 if(isset($_POST['fai_release']) && isset($r_releases[get_post('fai_release')])){
1298 /* Ensure that we have a valid release selected */
1299 if(!isset($r_releases[get_post('fai_release')])){
1300 msg_dialog::display(_("Warning"),_("The selected release is not available anymore. All triggered actions are skipped."));
1301 $_POST = array();
1302 $plug =$_GET['plug'];
1303 $_GET = array("plug" => $plug);
1304 $this->fai_release = $this->fai_base;
1305 }else{
1306 $this->fai_release = $r_releases[get_post('fai_release')];
1307 }
1309 $fai_filter = session::get("fai_filter");
1310 $fai_filter['fai_release'] = $this->fai_release;
1311 session::set("fai_filter",$fai_filter);
1312 }
1314 if(is_object($this->CopyPasteHandler)){
1315 $this->CopyPasteHandler->save_object();
1316 }
1317 }
1320 function copyPasteHandling_from_queue($s_action,$s_entry)
1321 {
1322 /* Check if Copy & Paste is disabled */
1323 if(!is_object($this->CopyPasteHandler)){
1324 return("");
1325 }
1327 $ui = get_userinfo();
1329 /* Add a single entry to queue */
1330 if($s_action == "copy"){
1332 /* Cleanup object queue */
1333 $this->CopyPasteHandler->cleanup_queue();
1334 $entry = $this->objects[$s_entry];
1335 $a_setup = $this->get_type($entry);
1336 $dn = $entry['dn'];
1338 if($ui->is_copyable($dn,"fai",$a_setup[1])){
1339 $this->CopyPasteHandler->add_to_queue($dn,$s_action,$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1340 }
1341 }
1343 /* Add entries to queue */
1344 if($s_action == "copy_multiple"){
1346 /* Cleanup object queue */
1347 $this->CopyPasteHandler->cleanup_queue();
1349 /* Add new entries to CP queue */
1350 foreach($this->list_get_selected_items() as $id){
1352 /* Cleanup object queue */
1353 $entry = $this->objects[$id];
1354 $a_setup = $this->get_type($entry);
1355 $dn = $entry['dn'];
1357 if($s_action == "copy_multiple" && $ui->is_copyable($dn,"fai",$a_setup[1])){
1358 $this->CopyPasteHandler->add_to_queue($dn,"copy",$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1359 }
1360 }
1361 }
1363 /* Start pasting entries */
1364 if($s_action == "editPaste" && !($this->lock_type == "freeze" && !$this->allow_freeze_object_attach)){
1365 $this->start_pasting_copied_objects = TRUE;
1366 }
1368 /* Return C&P dialog */
1369 if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
1371 /* Get dialog */
1372 $this->CopyPasteHandler->SetVar("parent",$this);
1373 $data = $this->CopyPasteHandler->execute();
1375 FAI::save_release_changes_now();
1377 /* Return dialog data */
1378 if(!empty($data)){
1379 return($data);
1380 }
1381 }
1383 /* Automatically disable status for pasting */
1384 if(!$this->CopyPasteHandler->entries_queued()){
1385 $this->start_pasting_copied_objects = FALSE;
1386 }
1387 return("");
1388 }
1391 /* Check if the given FAI class is used in this release
1392 */
1393 static function check_class_name($oc,$name,$dn)
1394 {
1395 $base = FAI::get_release_dn($dn);
1397 if($oc == "FAIprofile"){
1398 $f = "";
1399 $ocs = array("FAIprofile","FAItemplate","FAIhook","FAIpartitionTable","FAIpackageList","FAIscript","FAIvariable");
1400 foreach($ocs as $oc){
1401 $f .= "(objectClass=".$oc.")";
1402 }
1403 $res = FAI::get_all_objects_for_given_base($base,"(|".$f.")",TRUE);
1404 }else{
1405 $res = FAI::get_all_objects_for_given_base($base,"(objectClass=".$oc.")",TRUE);
1406 }
1407 $delete = array();
1408 $used = array();
1409 foreach($res as $object){
1410 $used[$object['cn'][0]]= $object['cn'][0];
1411 }
1412 return($used);
1413 }
1416 /* Return plugin informations for acl handling */
1417 static function plInfo()
1418 {
1419 return (array(
1420 "plShortName" => _("FAI releases"),
1421 "plDescription" => _("FAI release management"),
1422 "plSelfModify" => FALSE,
1423 "plDepends" => array(),
1424 "plPriority" => 0,
1425 "plSection" => array("administration"),
1426 "plCategory" => array("fai"=> array("description" => _("FAI"),
1427 "objectClass" => "FAIclass")),
1428 "plProvidedAcls"=> array()));
1429 }
1430 }
1431 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1432 ?>