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 }
76 /* Creat dialog object */
77 $this->DivListFai = new divListFai($this->config,$this);
79 /* Copy & Paste handler */
80 if ($this->config->boolValueIsTrue("main", "copyPaste")){
81 $this->CopyPasteHandler= new CopyPasteHandler($this->config);
82 }
84 /* Set default release */
85 $this->fai_base = get_ou("faiBaseRDN").$this->config->current['BASE'];
87 if(!session::is_set("fai_filter")){
89 /* Set intial release */
90 $rel = $config->search("faiManagement","DEFAULTFAIRELEASE",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","");
115 $display = "";
116 $s_action = "";
117 $s_entry = "";
118 $no_save = FALSE; // hide Apply / Save buttons
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 foreach($_POST as $name => $value){
143 foreach($posts as $reg => $act ){
144 if(preg_match($reg,$name)){
145 $s_action = $act;
146 $s_entry = ltrim(preg_replace($reg,"",$name),"_");
147 $s_entry = preg_replace("/_.*$/","",$s_entry);
148 break;
149 }
150 }
151 if(preg_match("/^entry_edit_.*/",$name)){
152 $s_entry = preg_replace("/^entry_edit_/","",$name);
153 $s_entry = preg_replace("/_.*$/","",$s_entry);
154 $s_action = "edit";
155 break;
156 }elseif(preg_match("/^entry_freeze_edit_.*/",$name)){
157 $s_entry = preg_replace("/^entry_freeze_edit_/","",$name);
158 $s_entry = preg_replace("/_.*$/","",$s_entry);
159 $s_action = "edit";
160 $no_save = TRUE;
161 break;
162 }elseif(preg_match("/^entry_delete_.*/",$name)){
163 $s_entry = preg_replace("/^entry_delete_/","",$name);
164 $s_entry = preg_replace("/_.*$/","",$s_entry);
165 $s_action = "delete";
166 break;
167 }
169 /* Get posts from opsi onjects
170 */
171 if($this->opsi instanceof opsi && $this->opsi->enabled()){
172 if(preg_match("/^entry_opsi_edit_/",$name)){
173 $s_entry = preg_replace("/^entry_opsi_edit_([0-9]*).*$/","\\1",$name);
174 $s_action = "opsi_edit";
175 break;
176 }
177 }
178 }
180 /* Get posts from opsi objects
181 */
182 if($this->opsi instanceof opsi && $this->opsi->enabled() && isset($_GET['edit_opsi_entry'])){
183 $s_entry = $_GET['edit_opsi_entry'];
184 $s_action = "opsi_edit";
185 }
187 if(isset($_GET['edit_entry'])){
188 $s_entry = $_GET['edit_entry'];
189 $s_action = "edit";
190 }
192 if(isset($_GET['edit_freeze_entry'])){
193 $s_entry = $_GET['edit_freeze_entry'];
194 $s_action = "edit";
195 $no_save = TRUE;
196 }
198 if(isset($_GET['act']) && $_GET['act'] == "freeze_branch"){
199 $s_action = "freeze_branch";
200 }
201 if(isset($_GET['act']) && $_GET['act'] == "branch_branch"){
202 $s_action = "branch_branch";
203 }
204 if(isset($_GET['act']) && $_GET['act'] == "remove_branch"){
205 $s_action = "remove_branch";
206 }
208 if((isset($_POST['CancelBranchName'])) || (isset($_POST['CloseIFrame']))){
209 $this->dispNewBranch = false;
210 $this->dispNewFreeze = false;
211 }
214 $type_acl_mapping = array(
215 "FAIpartitionTable" => "faiPartitionTable",
216 "FAIpackageList" => "faiPackage",
217 "FAIscript" => "faiScript",
218 "FAIvariable" => "faiVariable",
219 "FAIhook" => "faiHook",
220 "FAIprofile" => "faiProfile",
221 "FAItemplate" => "faiTemplate");
224 /* handle C&P from layers menu */
225 if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){
226 $s_action = "copy_multiple";
227 }
228 if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){
229 $s_action = "cut_multiple";
230 }
231 if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){
232 $s_action = "editPaste";
233 }
235 /* Create options */
236 if(isset($_POST['menu_action']) && preg_match("/^Create_/",$_POST['menu_action'])){
237 $s_action = "new_".preg_replace("/^Create_/","",$_POST['menu_action']);;
238 $s_entry = preg_replace("/^Create_/","",$_POST['menu_action']);
239 }
241 /* handle remove from layers menu */
242 if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){
243 $s_action = "del_multiple";
244 }
247 if(!empty($s_action)){
248 $this->no_save = $no_save;
249 }
251 /********************
252 Copy & Paste
253 ********************/
255 /* Display the copy & paste dialog, if it is currently open */
256 $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
257 if($ret){
258 return($ret);
259 }
262 /*******************
263 Opsi extension
264 *******************/
266 if($this->opsi instanceof opsi && $this->opsi->enabled()){
267 if($s_action == "opsi_edit"){
268 $name = $this->objects[$s_entry]['cn'];
269 $cfg = $this->opsi->get_product_properties($name);
270 $this->dialog = new tabs_opsiProdConfig($this->config, $this->config->data['TABS']['OPSIPRODCONFIG'],"","opsi");
271 if(isset($this->dialog->by_object['opsiProperties'])){
272 $this->dialog->by_object['opsiProperties']->set_cfg($cfg);
273 $this->dialog->by_object['opsiProperties']->set_product($name);
274 }else{
275 trigger_error("Unknown tab, please check config.");
276 }
277 }
278 if($this->dialog instanceof tabs_opsiProdConfig && isset($_POST['cancel_properties'])){
279 $this->dialog = NULL;
280 }
281 if($this->dialog instanceof tabs_opsiProdConfig && isset($_POST['save_properties'])){
282 $this->dialog->save_object();
283 $op = $this->dialog->by_object['opsiProperties'];
284 $name = $op->get_product();
285 $cfg = $op->get_cfg();
286 $this->opsi->set_product_properties($name,$cfg);
287 if($this->opsi->is_error()){
288 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
289 }else{
290 $this->dialog = NULL;
291 }
292 }
293 if($this->dialog instanceof tabs_opsiProdConfig){
294 $this->dialog->save_object();
295 return($this->dialog->execute());
296 }
297 }
300 /****************
301 Delete confirme dialog
302 ****************/
304 if ($s_action=="delete"){
306 /* Get 'dn' from posted termlinst */
307 $this->dn= $this->objects[$s_entry]['dn'];
309 /* Load permissions for selected 'dn' and check if
310 we're allowed to remove this 'dn' */
311 $acl = $this->ui->get_permissions($this->dn,"fai/".$type_acl_mapping[$this->objects[$s_entry]['type']]);
312 if(preg_match("/d/",$acl)){
314 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
315 if (($user= get_lock($this->dn)) != ""){
316 return(gen_locked_message ($user, $this->dn));
317 }
319 /* Lock the current entry, so nobody will edit it during deletion */
320 add_lock ($this->dn, $this->ui->dn);
321 $smarty->assign("warning",msgPool::deleteInfo(@LDAP::fix($this->dn),_("FAI object")));
322 $smarty->assign("multiple", false);
323 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
324 } else {
326 /* Obviously the user isn't allowed to delete. Show message and clean session. */
327 msg_dialog::display(_("Permission error"), msgPool::permDelete(),ERROR_DIALOG);
328 }
329 }
332 /********************
333 Delete MULTIPLE entries requested, display confirm dialog
334 ********************/
336 if ($s_action=="del_multiple"){
337 $this->dns = array();
338 $ids = $this->list_get_selected_items();
340 if(count($ids)){
342 $errors = "";
343 foreach($ids as $id){
344 $dn = $this->objects[$id]['dn'];
345 $cn = $this->objects[$id]['cn'];
346 if(!preg_match('/^freeze/', $this->objects[$id]['FAIstate'])){
347 $this->dns[$id] = $dn;
348 }else{
349 $errors .= $cn.", ";
350 }
351 }
352 if ($user= get_multiple_locks($this->dns)){
353 return(gen_locked_message($user,$this->dns));
354 }
356 if($errors != ""){
357 msg_dialog::display(_("Branch locked"),sprintf(_("The following entries are locked, you can't remove them %s."),
358 "<br><br>".trim($errors,", ")),INFO_DIALOG);
359 }
361 if(count($this->dns)){
363 $dns_names = array();
364 foreach($this->dns as $dn){
365 add_lock ($dn, $this->ui->dn);
366 $dns_names[] = @LDAP::fix($dn);
367 }
369 /* Lock the current entry, so nobody will edit it during deletion */
370 $smarty->assign("warning",msgPool::deleteInfo($dns_names,_("FAI object")));
371 $smarty->assign("multiple", true);
372 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
373 }
374 }
375 }
378 /********************
379 Delete MULTIPLE entries confirmed
380 ********************/
382 /* Confirmation for deletion has been passed. Users should be deleted. */
383 if (isset($_POST['delete_multiple_fai_object_confirm'])){
385 /* Find out more about the object type */
386 $ldap = $this->config->get_ldap_link();
388 /* Remove user by user and check acls before removeing them */
389 foreach($this->dns as $key => $dn){
391 $ldap->cat($dn, array('objectClass'));
392 $attrs = $ldap->fetch();
393 $type = $this->get_type($attrs);
395 $acl = $this->ui->get_permissions($dn,"fai/".$type[1]);
396 if(preg_match("/d/",$acl)){
398 $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $dn,"fai");
399 $this->dialog->parent = &$this;
400 $this->dialog->set_acl_base($dn);
401 $this->dialog->by_object[$type[1]]->remove_from_parent ();
402 unset ($this->dialog);
403 $this->dialog= FALSE;
404 $to_del = FAI::clean_up_releases($dn);
405 FAI::save_release_changes_now();
407 foreach($to_del as $dn){
408 $ldap->rmdir_recursive($dn);
409 }
411 } else {
413 /* Normally this shouldn't be reached, send some extra
414 logs to notify the administrator */
415 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
416 new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion.");
417 }
418 }
420 /* Remove lock file after successfull deletion */
421 $this->remove_lock();
422 $this->dns = array();
423 }
426 /********************
427 Delete MULTIPLE entries Canceled
428 ********************/
430 /* Remove lock */
431 if(isset($_POST['delete_multiple_fai_object_cancel'])){
432 $this->dns = array();
433 $this->remove_lock();
434 }
437 /****************
438 Delete aborted
439 ****************/
441 /* Delete canceled? */
442 if (isset($_POST['delete_cancel'])){
443 $this->remove_lock();
444 }
447 /****************
448 Delete confirmed
449 ****************/
451 /* Deltetion was confirmed, so delete this entry
452 */
453 if (isset($_POST['delete_terminal_confirm'])){
455 /* Some nice guy may send this as POST, so we've to check
456 for the permissions again. */
458 /* Find out more about the object type */
459 $ldap = $this->config->get_ldap_link();
460 $ldap->cat($this->dn, array('objectClass'));
461 if($ldap->count()){
462 $attrs = $ldap->fetch();
463 $type = $this->get_type($attrs);
465 $acl = $this->ui->get_permissions($this->dn,"fai/".$type[1]);
466 if(preg_match("/d/",$acl)){
468 $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $this->dn,"fai");
469 $this->dialog->set_acl_base($this->dn);
470 $this->dialog->parent = &$this;
471 $this->dialog->by_object[$type[1]]->remove_from_parent ();
472 unset ($this->dialog);
473 $this->dialog= FALSE;
474 $to_del = FAI::clean_up_releases($this->dn);
475 FAI::save_release_changes_now();
477 foreach($to_del as $dn){
478 $ldap->rmdir_recursive($dn);
479 }
481 } else {
483 /* Normally this shouldn't be reached, send some extra
484 logs to notify the administrator */
485 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
486 new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion.");
487 }
489 }else{
490 msg_dialog::display(_("Error"), sprintf(_("Cannot delete '%s': object does not exist!"), $this->dn) , ERROR_DIALOG);
491 }
493 /* Remove lock file after successfull deletion */
494 $this->remove_lock();
495 }
498 /****************
499 Edit entry
500 ****************/
502 if(($s_action == "edit") && (!isset($this->dialog->config))){
503 $entry = $this->objects[$s_entry];
504 $a_setup = $this->get_type($entry);
505 $this->dn = $entry['dn'];
507 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
508 if (($user= get_lock($this->dn)) != ""){
509 return(gen_locked_message ($user, $this->dn));
510 }
511 add_lock ($this->dn, $this->ui->dn);
513 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
514 $this->dialog->parent = &$this;
515 $this->dialog->by_object[$a_setup[1]]->FAIstate = $entry['FAIstate'];
516 $this->dialog->set_acl_base($this->dn);
517 $this->is_dialog = true;
518 session::set('objectinfo',$this->dn);
519 }
522 /* Branch handling
523 09.01.2006
524 */
526 /****************
527 Remove branch
528 ****************/
530 /* Remove branch
531 */
532 if($s_action == "remove_branch"){
533 $base= $this->fai_release;
535 /* Check if we have a post remove method configured
536 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
537 */
538 if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
539 /* Load permissions for selected 'dn' and check if
540 we're allowed to remove this 'dn' */
541 if($this->acl_is_removeable()){
542 $smarty->assign("release_hidden",base64_encode($this->fai_release));
543 $smarty->assign("info", msgPool::deleteInfo(@LDAP::fix($this->fai_release),_("FAI branch/freeze")));
544 return($smarty->fetch(get_template_path('remove_branch.tpl',TRUE)));
545 } else {
546 msg_dialog::display(_("Permission error"), _("You have no permission to delete this release!"), ERROR_DIALOG);
547 }
548 }
549 }
552 /****************
553 Remove branch confirmed
554 ****************/
556 if(isset($_POST['delete_branch_confirm'])){
558 /* Check if we have a post remove method configured
559 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
560 */
561 if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
563 if(!isset($_POST['release_hidden']) || base64_decode($_POST['release_hidden']) != $this->fai_release){
564 msg_dialog::display(_("Warning"),_("Release remove aborted because the release name check failed!"));
565 }else{
567 $bb = $this->fai_release;
568 if(!isset($ldap)){
569 $ldap = $this->config->get_ldap_link();
570 }
572 $br = $this->getBranches();
574 if(isset($br[$bb]) && $this->acl_is_removeable()){
575 $name = $br[$bb];
577 $ldap->cd($bb);
578 $ldap->recursive_remove();
579 $ldap->cd(preg_replace('/,'.normalizePreg(get_ou('faiBaseRDN')).'/', ','.get_ou('applicationRDN'), $bb));
580 $ldap->recursive_remove();
581 $ldap->cd(preg_replace('/,'.normalizePreg(get_ou('faiBaseRDN')).'/', ','.get_ou('mimetypeRDN'), $bb));
582 $ldap->recursive_remove();
584 /* Search for all groups with configured application menus.
585 - First search all groups, to ensure that we only remove entries form whithin groups.
586 - The search für menu configuration for the specified release and collect all those dns.
587 - Remove entries
588 */
589 $release_ou = preg_replace("/".normalizePreg(get_ou("faiBaseRDN")).".*$/","",$bb);
590 $ldap->cd($this->config->current['BASE']);
591 $ldap->search("(objectClass=posixGroup)",array("dn"));
593 /* Collect all group dns
594 */
595 $groups = array();
596 while($attrs = $ldap->fetch()){
597 $groups[] = $attrs['dn'];
598 }
600 /* Collect all group menu release dns that match the release we have removed
601 */
602 $dns = array();
603 foreach($groups as $dn){
604 $ldap->cd($dn);
605 $ldap->search("(objectClass=FAIbranch)",array("dn"));
606 while($attrs = $ldap->fetch()){
607 if(preg_match("/^".normalizePreg($release_ou)."/",$attrs['dn'])){
608 $dns[] = $attrs['dn'];
609 }
610 }
611 }
613 /* Finally remove collected release dns
614 */
615 foreach($dns as $dn){
616 $ldap->cd($dn);
617 $ldap->recursive_remove();
618 }
620 /* Post remove */
621 $this->fai_release = $this->fai_base;
622 $this->lock_name = $name;
623 $this->lock_dn = $bb;
624 $this->postremove();
626 $fai_filter = session::get("fai_filter");
627 $fai_filter['fai_release'] = $this->fai_release;
628 session::set("fai_filter",$fai_filter);
630 new log("remove","fai/".get_class($this),$br[$bb],array(),"Release removed");
631 }
632 }
633 }
634 }
637 /****************
638 Create a new branch "insert Name"
639 ****************/
641 if((isset($_POST['UseBranchName']))&&(($this->dispNewBranch)||($this->dispNewFreeze))){
642 session::set('LASTPOST',$_POST);
644 if($this->dispNewBranch){
645 $type = "branch";
646 }else{
647 $type = "freeze";
648 }
650 /* Check branch name */
651 $name = $_POST['BranchName'];
652 $is_ok = true;
653 $smarty->assign("BranchName",$name);
654 $base= $this->fai_base;
656 /* Check used characters */
657 if(!preg_match("/^[0-9a-z\.]*$/",$name)){
658 msg_dialog::display(_("Error"), msgPool::invalid(_("Name"),$name,"/[0-9a-z\.]/"), ERROR_DIALOG);
659 $is_ok = false;
660 }
662 /* Check if this name is already in use */
663 if(!$this->CheckNewBranchName($_POST['BranchName'],$this->fai_release)){
664 msg_dialog::display(_("Error"), msgPool::duplicated(_("Name")), ERROR_DIALOG);
665 $is_ok = false;
666 }
668 if($is_ok){
670 if(session::is_set('LASTPOST')){
671 $LASTPOST = session::get('LASTPOST');
672 }else{
673 $LASTPOST = array();
674 }
675 $LASTPOST['base'] = $base;
676 $LASTPOST['type'] = $type;
677 session::set('LASTPOST',$LASTPOST);
678 $smarty->assign("iframe", true);
679 $smarty->assign("plugID", $_GET['plug']);
680 $display = $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
681 return($display);
682 }
683 }
686 /****************
687 Create a new branch
688 ****************/
690 if(isset($_GET['PerformBranch'])){
692 if(!$this->acl_is_createable()){
693 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
694 }else{
696 /* In order to see error messages we have to reset the error handler.
697 Due to the exit();
698 */
699 restore_error_handler();
701 /* Create it know */
702 $this->dispNewBranch = false;
703 $this->dispNewFreeze = false;
705 $LASTPOST = session::get('LASTPOST');
706 $base = $LASTPOST['base'];
707 $_POST = session::get('LASTPOST');
708 $name = $_POST['BranchName'];
710 $type = $LASTPOST['type'];
711 $ldap = $this->config->get_ldap_link();
713 $baseToUse = $base;
714 if($this->fai_release != $this->fai_base){
715 $baseToUse = $this->fai_release;
716 }
718 /* Create new Release name to be able to set faidebianRelease for FAIpackageList */
720 $CurrentReleases = $this->getBranches();
721 $NewReleaseName = $name;
722 if(isset($CurrentReleases[$this->fai_release])) {
723 if($this->fai_release != $this->fai_base){
724 $NewReleaseName = $CurrentReleases[$this->fai_release]."/".$name;
725 $NewReleaseName = preg_replace("#\/#","/",$NewReleaseName);
726 }else{
727 $NewReleaseName = $name;
728 }
729 }
731 $appsrc = preg_replace("/".normalizePreg(get_ou('faiBaseRDN'))."/",get_ou('applicationRDN'),$baseToUse);
732 $appdst = preg_replace("/".normalizePreg(get_ou('faiBaseRDN'))."/",get_ou('applicationRDN'),"ou=".$name.",".$baseToUse) ;
734 $mimesrc = preg_replace("/".normalizePreg(get_ou('faiBaseRDN'))."/",get_ou('mimetypeRDN'),$baseToUse);
735 $mimedst = preg_replace("/".normalizePreg(get_ou('faiBaseRDN'))."/",get_ou('mimetypeRDN'),"ou=".$name.",".$baseToUse) ;
737 /* Check if source depeartments exist */
738 foreach(array($baseToUse,$appsrc,$mimesrc) as $dep){
739 $ldap->cd($this->config->current['BASE']);
740 $ldap->cat($dep);
741 if(!$ldap->count()){
742 $ldap->create_missing_trees($dep);
743 }
744 }
746 /* Print header to have styles included */
747 echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
748 <html>
749 <head>
750 <title></title>
751 <style type="text/css">@import url("themes/default/style.css");</style>
752 <script language="javascript" src="include/focus.js" type="text/javascript"></script>
753 </head>
754 <body style="background: none;margin:3px;color:black">
755 ';
757 new log("create","fai/".get_class($this),$NewReleaseName,array(),"New $type created");
759 /* Duplicate group application releases
760 */
761 FAI::copy_FAI_group_releases($CurrentReleases[$this->fai_release],$name,$type);
763 /* Duplicate applications
764 */
765 $ldap->cat($appsrc,array("dn")) ;
766 if($ldap->count()){
767 $ldap->cd ($appdst);
768 $ldap->recursive_remove();
769 FAI::copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true);
770 }
772 /* Duplicate mime types
773 */
774 $ldap->cat($mimesrc,array("dn")) ;
775 if($ldap->count()){
776 $ldap->cd ($mimedst);
777 $ldap->recursive_remove();
778 FAI::copy_FAI_resource_recursive($mimesrc,$mimedst,$NewReleaseName,$type,true);
779 }
781 $attr = array();
782 $attr['objectClass'] = array("organizationalUnit","FAIbranch");
783 $attr['ou'] = $name;
784 $attr['FAIstate'] = $type;
785 $ldap->cd($this->config->current['BASE']);
786 $ldap->cd("ou=".$name.",".$baseToUse);
787 $ldap->cat("ou=".$name.",".$baseToUse);
788 if($ldap->count()){
789 $ldap->modify($attr);
790 }else{
791 $ldap->add($attr);
792 }
794 /* Duplicate fai objects
795 */
796 // $ldap->cd ("ou=".$name.",".$baseToUse);
797 // $ldap->recursive_remove();
798 // FAI::copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,$NewReleaseName,$type,true);
800 echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
801 <br><input type='submit' name='CloseIFrame' value='"._("Continue")."'>
802 </form></div>";
804 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
806 /* Print footer to have valid html */
807 echo "</body></html>";
809 $this->dispNewFreeze = false;
811 /* Postcreate */
813 /* Assign possible attributes */
814 $this->lock_type = $type;
815 $this->lock_name = $name;
816 $this->lock_dn = $baseToUse;
817 $this->postcreate();
820 /* Send daemon event to reload the fai release database
821 */
822 if(class_available("DaemonEvent") && class_available("gosaSupportDaemon")){
823 $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
824 if(isset($events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'])){
825 $evt = $events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'];
826 $tmp = new $evt['CLASS_NAME']($this->config);
827 $tmp->set_type(TRIGGERED_EVENT);
828 $tmp->add_targets(array("GOSA"));
829 $o_queue = new gosaSupportDaemon();
830 if(!$o_queue->append($tmp)){
831 msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
832 }
833 }
834 }else{
835 trigger_error("Unknown class DaemonEvent / gosaSupportDaemon");
836 msg_dialog::display(_("Fatal error"),
837 "Daemon events called but classes where not accessible, DaemonEvent gosaSupportDaemon",
838 FATAL_ERROR_DIALOG);
839 }
840 exit();
841 }
842 }
844 /****************
845 Display dialog to enter new Branch name
846 ****************/
848 /* Check if we have a post create method configured
849 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
850 */
851 if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
852 if(($s_action == "branch_branch")||($this->dispNewBranch)){
853 if(!$this->acl_is_createable()){
854 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
855 }else{
856 $this->dispNewBranch=true;
857 $smarty->assign("iframe",false);
858 $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
859 return($display);
860 }
861 }
862 }
865 /****************
866 Display dialog to enter new Freeze name
867 ****************/
869 /* Check if we have a post create method configured
870 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
871 */
872 if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
873 if(($s_action == "freeze_branch")||($this->dispNewFreeze)){
874 if(!$this->acl_is_createable()){
875 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
876 }else{
877 $this->dispNewFreeze = true;
878 $smarty->assign("iframe",false);
879 $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
880 return($display);
881 }
882 }
883 }
886 /****************
887 Create a new object
888 ****************/
890 $types = array( "new_partition" => "FAIpartitionTable",
891 "new_script" => "FAIscript",
892 "new_hook" => "FAIhook",
893 "new_variable" => "FAIvariable",
894 "new_template" => "FAItemplate",
895 "new_package" => "FAIpackageList");
896 $types_i18n = array( "new_partition" => _("partition table"),
897 "new_script" => _("script"),
898 "new_hook" => _("hook"),
899 "new_variable" => _("variable"),
900 "new_template" => _("template"),
901 "new_package" => _("package list"));
903 if(isset($types[$s_action])){
904 $acl = $this->ui->get_permissions($this->fai_base,"fai/".$type_acl_mapping[$types[$s_action]]);
905 if(preg_match("/c/",$acl)){
906 $this->dialog = new askClassName($this->config,$this->dn,$this->ui,$types[$s_action]);
907 $this->dialog->parent = &$this;
908 }else{
909 msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), $types_i18n[$s_action]), ERROR_DIALOG);
910 }
911 }
913 /* New Profile */
914 if($s_action == "new_profile"){
915 $this->dn = "new" ;
917 $acl = $this->ui->get_permissions($this->fai_base,"fai/faiProfile");
918 if(preg_match("/c/",$acl)){
919 $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
920 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
921 $this->dialog->set_acl_base($this->base);
922 $this->dialog->parent = &$this;
924 $this->is_dialog = false;
925 }else{
926 msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), _("profile")), ERROR_DIALOG);
927 }
928 }
931 /****************
932 Get from ask class name dialog
933 ****************/
935 if($s_action == "select_class_name_finished"){
936 $this->dialog->save_object();
937 if(count($this->dialog->check())!=0){
938 foreach($this->dialog->check() as $msg){
939 msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
940 }
941 }elseif(isset($this->dialog->objectClass)){
942 $this->dn = "new" ;
943 $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass)));
944 $name = $this->dialog->save();
946 if(class_exists($a_setup[0])){
947 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
948 $this->dialog->set_acl_base($this->base);
949 $this->dialog->by_object[$a_setup[1]]->cn = $name;
950 $this->dialog->parent = &$this;
951 $this->is_dialog = true;
952 }
953 }
954 }
957 /****************
958 Cancel dialogs
959 ****************/
961 if(isset($_POST['edit_cancel'])){
962 $this->dialog=FALSE;
963 $this->is_dialog = false;
964 session::un_set('objectinfo');
965 $this->remove_lock();
966 }
969 /****************
970 Save sub dialogs
971 ****************/
973 /* This check if the given tab could be saved
974 * If it was possible to save it, remove dialog object.
975 * If it wasn't possible, show errors and keep dialog.
976 */
977 if((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->dialog->config))){
978 $this->dialog->save_object();
979 $msgs= $this->dialog->check();
980 if(count($msgs)!=0){
981 foreach($msgs as $msg){
982 msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
983 }
984 }else{
985 $this->dialog->save();
986 FAI::save_release_changes_now();
987 if (!isset($_POST['edit_apply'])){
988 $this->remove_lock();
989 $this->dialog=FALSE;
990 $this->is_dialog=false;
991 session::un_set('objectinfo');
992 }else{
994 /* Reinitialize tab */
995 if($this->dialog instanceof tabs){
996 $this->dialog->re_init();
997 }
998 }
999 }
1000 }
1003 /****************
1004 Display currently open dialog
1005 ****************/
1007 /* If dialog is set, but $this->is_dialog==false, then
1008 * only the "abort" button is shown, this are dialogs that must not be saved.
1009 * If is_dialog == true, we are currently editing tab objects.
1010 * Here we need both, save and cancel
1011 */
1013 if(is_object($this->dialog)){
1014 $display .= $this->dialog->execute();
1015 /* Don't show buttons if tab dialog requests this */
1017 if(isset($this->dialog->current)){
1019 $obj = $this->dialog->by_object[$this->dialog->current];
1021 if((isset($obj->is_dialog) && (!$obj->is_dialog)) || (isset($obj->dialog) && (!$obj->dialog))){
1023 $display.= "<p style=\"text-align:right\">\n";
1024 if(!$this->no_save){
1025 $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
1026 $display.= " \n";
1027 if ($this->dn != "new"){
1028 $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
1029 $display.= " \n";
1030 }
1031 }
1032 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1033 $display.= "</p>";
1034 }elseif(!isset($this->dialog->current)){
1035 $display.= "<p style=\"text-align:right\">\n";
1036 $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\"> ";
1037 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1038 $display.= "</p>";
1039 }
1040 }else{
1041 $display.= "<p style=\"text-align:right\">\n";
1042 $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\"> ";
1043 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1044 $display.= "</p>";
1046 }
1047 return($display);
1048 }
1051 /****************
1052 Dialog display
1053 ****************/
1055 /* Check if there is a snapshot dialog open */
1056 $base = $this->fai_base;
1057 if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
1058 return($str);
1059 }
1061 /* Display dialog with system list */
1062 $this->reload();
1063 $this->DivListFai->parent = &$this;
1064 $this->DivListFai->execute();
1065 $this->DivListFai->setEntries($this->objects);
1066 return($this->DivListFai->Draw());
1067 }
1070 /* Return departments, that will be included within snapshot detection */
1071 function get_used_snapshot_bases()
1072 {
1073 $tmp = array();
1074 $types = array("faiPartitionRDN","faiScriptRDN","faiTemplateRDN","faiHookRDN","faiProfileRDN","faiVariableRDN","faiPackageRDN");
1075 foreach($types as $type){
1076 $tmp[] = get_ou($type).$this->fai_release;
1077 }
1078 return($tmp);
1079 }
1082 /* Get available branches for current base */
1083 function getBranches($base = false,$prefix = "")
1084 {
1085 $ret = array("/"=>$this->fai_base);
1086 $ldap = $this->config->get_ldap_link();
1087 if(!$base){
1088 $base = $this->fai_base;
1089 }
1090 $tmp = FAI::get_all_releases_from_base($base,true);
1091 foreach($tmp as $dn => $name){
1092 $ret[$name]=$dn;
1093 }
1094 ksort($ret);
1095 $ret = array_flip($ret);
1097 return ($ret);
1098 }
1101 function list_get_selected_items()
1102 {
1103 $ids = array();
1104 foreach($_POST as $name => $value){
1105 if(preg_match("/^item_selected_[0-9]*$/",$name)){
1106 $id = preg_replace("/^item_selected_/","",$name);
1107 $ids[$id] = $id;
1108 }
1109 }
1110 return($ids);
1111 }
1114 /* reload list of objects */
1115 function reload()
1116 {
1117 /* Variable initialisation */
1118 $str = "";
1119 $Regex = $this->DivListFai->Regex;
1120 $this->objects = array();
1122 /* Get base */
1123 $base = $this->fai_base;
1124 if($this->fai_release != $this->fai_base){
1125 $br = $this->getBranches();
1126 if(isset($br[$this->fai_release])){
1127 $base = $this->fai_release;
1128 }else{
1129 $base = $this->fai_base;
1130 }
1131 }
1132 $this->base = $base;
1133 $this->set_acl_base($this->base);
1135 $this->lock_type = FAI::get_release_tag(FAI::get_release_dn($base));
1137 /* Create a new list of FAI object
1138 * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ...
1139 */
1140 $ObjectTypes = array(
1141 "FAIpartitionTable" => array("OU"=> get_ou('faiPartitionRDN') , "CHKBOX"=>"ShowPartitions" ,"ACL" => "faiPartitionTable"),
1142 "FAIpackageList" => array("OU"=> get_ou('faiPackageRDN') , "CHKBOX"=>"ShowPackages" ,"ACL" => "faiPackage"),
1143 "FAIscript" => array("OU"=> get_ou('faiScriptRDN') , "CHKBOX"=>"ShowScripts" ,"ACL" => "faiScript"),
1144 "FAIvariable" => array("OU"=> get_ou('faiVariableRDN') , "CHKBOX"=>"ShowVariables" ,"ACL" => "faiVariable"),
1145 "FAIhook" => array("OU"=> get_ou('faiHookRDN') , "CHKBOX"=>"ShowHooks" ,"ACL" => "faiHook"),
1146 "FAIprofile" => array("OU"=> get_ou('faiProfileRDN') , "CHKBOX"=>"ShowProfiles" ,"ACL" => "faiProfile"),
1147 "FAItemplate" => array("OU"=> get_ou('faiTemplateRDN') , "CHKBOX"=>"ShowTemplates" ,"ACL" => "faiTemplate"));
1149 $filter = "";
1150 foreach($ObjectTypes as $key => $data){
1151 if($this->DivListFai->$data['CHKBOX']){
1152 $filter.= "(objectClass=".$key.")";
1153 }
1154 }
1155 $filter = "(&(|".$filter.")(cn=$Regex))";
1157 /* Get resolved release dependencies */
1158 $tmp = FAI::get_all_objects_for_given_base($base,$filter);
1160 /* Ge listed ldap objects */
1161 $ldap = $this->config->get_ldap_link();
1162 $ldap->cd($this->config->current['BASE']);
1164 foreach($tmp as $entry){
1166 /* Get some more informations about the object */
1167 $ldap->cat($entry['dn'], array("cn","description","objectClass","FAIclass","FAIstate","objectClass"));
1168 $object = $ldap->fetch();
1170 /* Walk through possible types */
1171 foreach($ObjectTypes as $type => $rest){
1173 $acl = $this->ui->get_permissions($object['dn'],"fai/".$rest ['ACL']);
1175 if(in_array($type,$object['objectClass']) && preg_match("/r/",$acl)){
1177 /* Prepare object */
1178 unset($object['objectClass']['count']);
1179 if(!isset($object['description'][0])){
1180 $object['description'][0]="";
1181 }
1183 /* Clean up object informations */
1184 $obj = array();
1185 $obj['cn'] = $object['cn'][0];
1186 $obj['dn'] = $object['dn'];
1187 $obj['acl'] = $acl;
1188 $obj['class'] = $rest ['ACL'];
1189 $obj['FAIstate'] = $entry['FAIstate'];
1190 $obj['description'] = $object['description'][0];
1191 $obj['objectClass'] = $object['objectClass'];
1193 $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj;
1194 $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type;
1195 }
1196 }
1197 }
1199 /* Append opsi objects, if opsi is available and if we are on the fai_base
1200 */
1201 if($this->opsi instanceof opsi && $this->opsi->enabled()){
1202 $opsi_acl = $this->ui->get_permissions($base,"opsi/opsiProperties");
1203 if(preg_match("/r/",$opsi_acl)){
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 }
1229 }
1231 ksort($this->objects);
1232 reset ($this->objects);
1234 /* use numeric index, thats a bit more secure */
1235 $tmp0 = array();
1236 foreach($this->objects as $obj){
1237 $tmp0[]= $obj;
1238 }
1239 $this->objects = array();
1240 $this->objects = $tmp0;
1241 }
1243 function remove_lock()
1244 {
1245 if (isset($this->dn)){
1246 del_lock ($this->dn);
1247 }
1248 if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
1249 del_lock ($this->dns);
1250 }
1251 }
1253 function get_type($array){
1254 if(in_array("FAIpartitionTable",$array['objectClass'])){
1255 return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS"));
1256 }
1257 if(in_array("FAIscript",$array['objectClass'])){
1258 return(array("tabsScript","faiScript","FAISCRIPTTABS"));
1259 }
1260 if(in_array("FAItemplate",$array['objectClass'])){
1261 return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS"));
1262 }
1263 if(in_array("FAIhook",$array['objectClass'])){
1264 return(array("tabsHook","faiHook","FAIHOOKTABS"));
1265 }
1266 if(in_array("FAIvariable",$array['objectClass'])){
1267 return(array("tabsVariable","faiVariable","FAIVARIABLETABS"));
1268 }
1269 if(in_array("FAIprofile",$array['objectClass'])){
1270 return(array("tabsProfile","faiProfile","FAIPROFILETABS"));
1271 }
1273 if(in_array("FAIpackageList",$array['objectClass'])){
1274 return(array("tabsPackage","faiPackage","FAIPACKAGETABS"));
1275 }
1276 }
1278 function CheckNewBranchName($name,$base)
1279 {
1280 $f = $this->fai_release;
1281 if($name == ""){
1282 return(false);
1283 }elseif(in_array($name,$this->getBranches($f))) {
1284 return(false);
1285 }elseif(tests::is_department_name_reserved($name,$base)){
1286 return(false);
1287 }
1288 return(true);
1289 }
1291 function save_object()
1292 {
1293 $this->DivListFai->save_object();
1295 /* Get posted release */
1296 $r_releases = array_flip($this->getBranches());
1297 if(isset($_POST['fai_release']) && isset($r_releases[get_post('fai_release')])){
1299 /* Ensure that we have a valid release selected */
1300 if(!isset($r_releases[get_post('fai_release')])){
1301 msg_dialog::display(_("Warning"),_("The selected release is not available anymore. All triggered actions are skipped."));
1302 $_POST = array();
1303 $plug =$_GET['plug'];
1304 $_GET = array("plug" => $plug);
1305 $this->fai_release = $this->fai_base;
1306 }else{
1307 $this->fai_release = $r_releases[get_post('fai_release')];
1308 }
1310 $fai_filter = session::get("fai_filter");
1311 $fai_filter['fai_release'] = $this->fai_release;
1312 session::set("fai_filter",$fai_filter);
1313 }
1315 if(is_object($this->CopyPasteHandler)){
1316 $this->CopyPasteHandler->save_object();
1317 }
1318 }
1321 function copyPasteHandling_from_queue($s_action,$s_entry)
1322 {
1323 /* Check if Copy & Paste is disabled */
1324 if(!is_object($this->CopyPasteHandler)){
1325 return("");
1326 }
1328 $ui = get_userinfo();
1330 /* Add a single entry to queue */
1331 if($s_action == "copy"){
1333 /* Cleanup object queue */
1334 $this->CopyPasteHandler->cleanup_queue();
1335 $entry = $this->objects[$s_entry];
1336 $a_setup = $this->get_type($entry);
1337 $dn = $entry['dn'];
1339 if($ui->is_copyable($dn,"fai",$a_setup[1])){
1340 $this->CopyPasteHandler->add_to_queue($dn,$s_action,$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1341 }
1342 }
1344 /* Add entries to queue */
1345 if($s_action == "copy_multiple"){
1347 /* Cleanup object queue */
1348 $this->CopyPasteHandler->cleanup_queue();
1350 /* Add new entries to CP queue */
1351 foreach($this->list_get_selected_items() as $id){
1353 /* Cleanup object queue */
1354 $entry = $this->objects[$id];
1355 $a_setup = $this->get_type($entry);
1356 $dn = $entry['dn'];
1358 if($s_action == "copy_multiple" && $ui->is_copyable($dn,"fai",$a_setup[1])){
1359 $this->CopyPasteHandler->add_to_queue($dn,"copy",$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1360 }
1361 }
1362 }
1364 /* Start pasting entries */
1365 if($s_action == "editPaste" && !($this->lock_type == "freeze" && !$this->allow_freeze_object_attach)){
1366 $this->start_pasting_copied_objects = TRUE;
1367 }
1369 /* Return C&P dialog */
1370 if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
1372 /* Get dialog */
1373 $this->CopyPasteHandler->SetVar("parent",$this);
1374 $data = $this->CopyPasteHandler->execute();
1376 FAI::save_release_changes_now();
1378 /* Return dialog data */
1379 if(!empty($data)){
1380 return($data);
1381 }
1382 }
1384 /* Automatically disable status for pasting */
1385 if(!$this->CopyPasteHandler->entries_queued()){
1386 $this->start_pasting_copied_objects = FALSE;
1387 }
1388 return("");
1389 }
1392 /* Check if the given FAI class is used in this release
1393 */
1394 static function check_class_name($oc,$name,$dn)
1395 {
1396 $base = FAI::get_release_dn($dn);
1398 if($oc == "FAIprofile"){
1399 $f = "";
1400 $ocs = array("FAItemplate","FAIhook","FAIpartitionTable","FAIpackageList","FAIscript","FAIvariable");
1401 foreach($ocs as $oc){
1402 $f .= "(objectClass=".$oc.")";
1403 }
1404 $res = FAI::get_all_objects_for_given_base($base,"(|".$f.")",TRUE);
1405 }else{
1406 $res = FAI::get_all_objects_for_given_base($base,"(objectClass=".$oc.")",TRUE);
1407 }
1408 $delete = array();
1409 $used = array();
1410 foreach($res as $object){
1411 $used[$object['cn'][0]]= $object['cn'][0];
1412 }
1413 return($used);
1414 }
1417 /* Return plugin informations for acl handling */
1418 static function plInfo()
1419 {
1420 return (array(
1421 "plShortName" => _("FAI releases"),
1422 "plDescription" => _("FAI release management"),
1423 "plSelfModify" => FALSE,
1424 "plDepends" => array(),
1425 "plPriority" => 0,
1426 "plSection" => array("administration"),
1427 "plCategory" => array("fai"=> array("description" => _("FAI"),
1428 "objectClass" => "FAIclass")),
1429 "plProvidedAcls"=> array()));
1430 }
1431 }
1432 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1433 ?>