6f99ab6de56efe05ff0a00e3934949d5d088310c
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", "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","");
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 $this->dialog->by_object['opsiProperties']->set_cfg($cfg);
272 $this->dialog->by_object['opsiProperties']->set_product($name);
273 }
274 if($this->dialog instanceof tabs_opsiProdConfig && isset($_POST['cancel_properties'])){
275 $this->dialog = NULL;
276 }
277 if($this->dialog instanceof tabs_opsiProdConfig && isset($_POST['save_properties'])){
278 $this->dialog->save_object();
279 $op = $this->dialog->by_object['opsiProperties'];
280 $name = $op->get_product();
281 $cfg = $op->get_cfg();
282 $this->opsi->set_product_properties($name,$cfg);
283 if($this->opsi->is_error()){
284 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
285 }else{
286 $this->dialog = NULL;
287 }
288 }
289 if($this->dialog instanceof tabs_opsiProdConfig){
290 $this->dialog->save_object();
291 return($this->dialog->execute());
292 }
293 }
296 /****************
297 Delete confirme dialog
298 ****************/
300 if ($s_action=="delete"){
302 /* Get 'dn' from posted termlinst */
303 $this->dn= $this->objects[$s_entry]['dn'];
305 /* Load permissions for selected 'dn' and check if
306 we're allowed to remove this 'dn' */
307 $acl = $this->ui->get_permissions($this->dn,"fai/".$type_acl_mapping[$this->objects[$s_entry]['type']]);
308 if(preg_match("/d/",$acl)){
310 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
311 if (($user= get_lock($this->dn)) != ""){
312 return(gen_locked_message ($user, $this->dn));
313 }
315 /* Lock the current entry, so nobody will edit it during deletion */
316 add_lock ($this->dn, $this->ui->dn);
317 $smarty->assign("warning",msgPool::deleteInfo(@LDAP::fix($this->dn),_("FAI object")));
318 $smarty->assign("multiple", false);
319 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
320 } else {
322 /* Obviously the user isn't allowed to delete. Show message and clean session. */
323 msg_dialog::display(_("Permission error"), msgPool::permDelete(),ERROR_DIALOG);
324 }
325 }
328 /********************
329 Delete MULTIPLE entries requested, display confirm dialog
330 ********************/
332 if ($s_action=="del_multiple"){
333 $this->dns = array();
334 $ids = $this->list_get_selected_items();
336 if(count($ids)){
338 $errors = "";
339 foreach($ids as $id){
340 $dn = $this->objects[$id]['dn'];
341 $cn = $this->objects[$id]['cn'];
342 if(!preg_match('/^freeze/', $this->objects[$id]['FAIstate'])){
343 $this->dns[$id] = $dn;
344 }else{
345 $errors .= $cn.", ";
346 }
347 }
348 if ($user= get_multiple_locks($this->dns)){
349 return(gen_locked_message($user,$this->dns));
350 }
352 if($errors != ""){
353 msg_dialog::display(_("Branch locked"),sprintf(_("The following entries are locked, you can't remove them %s."),
354 "<br><br>".trim($errors,", ")),INFO_DIALOG);
355 }
357 if(count($this->dns)){
359 $dns_names = array();
360 foreach($this->dns as $dn){
361 add_lock ($dn, $this->ui->dn);
362 $dns_names[] = @LDAP::fix($dn);
363 }
365 /* Lock the current entry, so nobody will edit it during deletion */
366 $smarty->assign("warning",msgPool::deleteInfo($dns_names,_("FAI object")));
367 $smarty->assign("multiple", true);
368 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
369 }
370 }
371 }
374 /********************
375 Delete MULTIPLE entries confirmed
376 ********************/
378 /* Confirmation for deletion has been passed. Users should be deleted. */
379 if (isset($_POST['delete_multiple_fai_object_confirm'])){
381 /* Find out more about the object type */
382 $ldap = $this->config->get_ldap_link();
384 /* Remove user by user and check acls before removeing them */
385 foreach($this->dns as $key => $dn){
387 $ldap->cat($dn, array('objectClass'));
388 $attrs = $ldap->fetch();
389 $type = $this->get_type($attrs);
391 $acl = $this->ui->get_permissions($dn,"fai/".$type[1]);
392 if(preg_match("/d/",$acl)){
394 $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $dn,"fai");
395 $this->dialog->parent = &$this;
396 $this->dialog->set_acl_base($dn);
397 $this->dialog->by_object[$type[1]]->remove_from_parent ();
398 unset ($this->dialog);
399 $this->dialog= FALSE;
400 $to_del = FAI::clean_up_releases($dn);
401 FAI::save_release_changes_now();
403 foreach($to_del as $dn){
404 $ldap->rmdir_recursive($dn);
405 }
407 } else {
409 /* Normally this shouldn't be reached, send some extra
410 logs to notify the administrator */
411 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
412 new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion.");
413 }
414 }
416 /* Remove lock file after successfull deletion */
417 $this->remove_lock();
418 $this->dns = array();
419 }
422 /********************
423 Delete MULTIPLE entries Canceled
424 ********************/
426 /* Remove lock */
427 if(isset($_POST['delete_multiple_fai_object_cancel'])){
428 $this->dns = array();
429 $this->remove_lock();
430 }
433 /****************
434 Delete aborted
435 ****************/
437 /* Delete canceled? */
438 if (isset($_POST['delete_cancel'])){
439 $this->remove_lock();
440 }
443 /****************
444 Delete confirmed
445 ****************/
447 /* Deltetion was confirmed, so delete this entry
448 */
449 if (isset($_POST['delete_terminal_confirm'])){
451 /* Some nice guy may send this as POST, so we've to check
452 for the permissions again. */
454 /* Find out more about the object type */
455 $ldap = $this->config->get_ldap_link();
456 $ldap->cat($this->dn, array('objectClass'));
457 if($ldap->count()){
458 $attrs = $ldap->fetch();
459 $type = $this->get_type($attrs);
461 $acl = $this->ui->get_permissions($this->dn,"fai/".$type[1]);
462 if(preg_match("/d/",$acl)){
464 $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $this->dn,"fai");
465 $this->dialog->set_acl_base($this->dn);
466 $this->dialog->parent = &$this;
467 $this->dialog->by_object[$type[1]]->remove_from_parent ();
468 unset ($this->dialog);
469 $this->dialog= FALSE;
470 $to_del = FAI::clean_up_releases($this->dn);
471 FAI::save_release_changes_now();
473 foreach($to_del as $dn){
474 $ldap->rmdir_recursive($dn);
475 }
477 } else {
479 /* Normally this shouldn't be reached, send some extra
480 logs to notify the administrator */
481 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
482 new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion.");
483 }
485 }else{
486 msg_dialog::display(_("Error"), sprintf(_("Cannot delete '%s': object does not exist!"), $this->dn) , ERROR_DIALOG);
487 }
489 /* Remove lock file after successfull deletion */
490 $this->remove_lock();
491 }
494 /****************
495 Edit entry
496 ****************/
498 if(($s_action == "edit") && (!isset($this->dialog->config))){
499 $entry = $this->objects[$s_entry];
500 $a_setup = $this->get_type($entry);
501 $this->dn = $entry['dn'];
503 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
504 if (($user= get_lock($this->dn)) != ""){
505 return(gen_locked_message ($user, $this->dn));
506 }
507 add_lock ($this->dn, $this->ui->dn);
509 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
510 $this->dialog->parent = &$this;
511 $this->dialog->by_object[$a_setup[1]]->FAIstate = $entry['FAIstate'];
512 $this->dialog->set_acl_base($this->dn);
513 $this->is_dialog = true;
514 session::set('objectinfo',$this->dn);
515 }
518 /* Branch handling
519 09.01.2006
520 */
522 /****************
523 Remove branch
524 ****************/
526 /* Remove branch
527 */
528 if($s_action == "remove_branch"){
529 $base= $this->fai_release;
531 /* Check if we have a post remove method configured
532 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
533 */
534 if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
535 /* Load permissions for selected 'dn' and check if
536 we're allowed to remove this 'dn' */
537 if($this->acl_is_removeable()){
538 $smarty->assign("release_hidden",base64_encode($this->fai_release));
539 $smarty->assign("info", msgPool::deleteInfo(@LDAP::fix($this->fai_release),_("FAI branch/freeze")));
540 return($smarty->fetch(get_template_path('remove_branch.tpl',TRUE)));
541 } else {
542 msg_dialog::display(_("Permission error"), _("You have no permission to delete this release!"), ERROR_DIALOG);
543 }
544 }
545 }
548 /****************
549 Remove branch confirmed
550 ****************/
552 if(isset($_POST['delete_branch_confirm'])){
554 /* Check if we have a post remove method configured
555 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
556 */
557 if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
559 if(!isset($_POST['release_hidden']) || base64_decode($_POST['release_hidden']) != $this->fai_release){
560 msg_dialog::display(_("Warning"),_("Release remove aborted because the release name check failed!"));
561 }else{
563 $bb = $this->fai_release;
564 if(!isset($ldap)){
565 $ldap = $this->config->get_ldap_link();
566 }
568 $br = $this->getBranches();
570 if(isset($br[$bb]) && $this->acl_is_removeable()){
571 $name = $br[$bb];
573 $ldap->cd($bb);
574 $ldap->recursive_remove();
575 $ldap->cd(preg_replace('/,'.normalizePreg(get_ou('faiou')).'/', ','.get_ou('applicationou'), $bb));
576 $ldap->recursive_remove();
577 $ldap->cd(preg_replace('/,'.normalizePreg(get_ou('faiou')).'/', ','.get_ou('mimetypeou'), $bb));
578 $ldap->recursive_remove();
580 /* Search for all groups with configured application menus.
581 - First search all groups, to ensure that we only remove entries form whithin groups.
582 - The search für menu configuration for the specified release and collect all those dns.
583 - Remove entries
584 */
585 $release_ou = preg_replace("/".normalizePreg(get_ou("faiou")).".*$/","",$bb);
586 $ldap->cd($this->config->current['BASE']);
587 $ldap->search("(objectClass=posixGroup)",array("dn"));
589 /* Collect all group dns
590 */
591 $groups = array();
592 while($attrs = $ldap->fetch()){
593 $groups[] = $attrs['dn'];
594 }
596 /* Collect all group menu release dns that match the release we have removed
597 */
598 $dns = array();
599 foreach($groups as $dn){
600 $ldap->cd($dn);
601 $ldap->search("(objectClass=FAIbranch)",array("dn"));
602 while($attrs = $ldap->fetch()){
603 if(preg_match("/^".normalizePreg($release_ou)."/",$attrs['dn'])){
604 $dns[] = $attrs['dn'];
605 }
606 }
607 }
609 /* Finally remove collected release dns
610 */
611 foreach($dns as $dn){
612 $ldap->cd($dn);
613 $ldap->recursive_remove();
614 }
616 /* Post remove */
617 $this->fai_release = $this->fai_base;
618 $this->lock_name = $name;
619 $this->lock_dn = $bb;
620 $this->postremove();
622 $fai_filter = session::get("fai_filter");
623 $fai_filter['fai_release'] = $this->fai_release;
624 session::set("fai_filter",$fai_filter);
626 new log("remove","fai/".get_class($this),$br[$bb],array(),"Release removed");
627 }
628 }
629 }
630 }
633 /****************
634 Create a new branch "insert Name"
635 ****************/
637 if((isset($_POST['UseBranchName']))&&(($this->dispNewBranch)||($this->dispNewFreeze))){
638 session::set('LASTPOST',$_POST);
640 if($this->dispNewBranch){
641 $type = "branch";
642 }else{
643 $type = "freeze";
644 }
646 /* Check branch name */
647 $name = $_POST['BranchName'];
648 $is_ok = true;
649 $smarty->assign("BranchName",$name);
650 $base= $this->fai_base;
652 /* Check used characters */
653 if(!preg_match("/^[0-9a-z\.]*$/",$name)){
654 msg_dialog::display(_("Error"), msgPool::invalid(_("Name"),$name,"/[0-9a-z\.]/"), ERROR_DIALOG);
655 $is_ok = false;
656 }
658 /* Check if this name is already in use */
659 if(!$this->CheckNewBranchName($_POST['BranchName'],$this->fai_release)){
660 msg_dialog::display(_("Error"), msgPool::duplicated(_("Name")), ERROR_DIALOG);
661 $is_ok = false;
662 }
664 if($is_ok){
666 if(session::is_set('LASTPOST')){
667 $LASTPOST = session::get('LASTPOST');
668 }else{
669 $LASTPOST = array();
670 }
671 $LASTPOST['base'] = $base;
672 $LASTPOST['type'] = $type;
673 session::set('LASTPOST',$LASTPOST);
674 $smarty->assign("iframe", true);
675 $smarty->assign("plugID", $_GET['plug']);
676 $display = $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
677 return($display);
678 }
679 }
682 /****************
683 Create a new branch
684 ****************/
686 if(isset($_GET['PerformBranch'])){
688 if(!$this->acl_is_createable()){
689 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
690 }else{
692 /* In order to see error messages we have to reset the error handler.
693 Due to the exit();
694 */
695 restore_error_handler();
697 /* Create it know */
698 $this->dispNewBranch = false;
699 $this->dispNewFreeze = false;
701 $LASTPOST = session::get('LASTPOST');
702 $base = $LASTPOST['base'];
703 $_POST = session::get('LASTPOST');
704 $name = $_POST['BranchName'];
706 $type = $LASTPOST['type'];
707 $ldap = $this->config->get_ldap_link();
709 $baseToUse = $base;
710 if($this->fai_release != $this->fai_base){
711 $baseToUse = $this->fai_release;
712 }
714 /* Create new Release name to be able to set faidebianRelease for FAIpackageList */
716 $CurrentReleases = $this->getBranches();
717 $NewReleaseName = $name;
718 if(isset($CurrentReleases[$this->fai_release])) {
719 if($this->fai_release != $this->fai_base){
720 $NewReleaseName = $CurrentReleases[$this->fai_release]."/".$name;
721 $NewReleaseName = preg_replace("#\/#","/",$NewReleaseName);
722 }else{
723 $NewReleaseName = $name;
724 }
725 }
727 $appsrc = preg_replace("/".normalizePreg(get_ou('faiou'))."/",get_ou('applicationou'),$baseToUse);
728 $appdst = preg_replace("/".normalizePreg(get_ou('faiou'))."/",get_ou('applicationou'),"ou=".$name.",".$baseToUse) ;
730 $mimesrc = preg_replace("/".normalizePreg(get_ou('faiou'))."/",get_ou('mimetypeou'),$baseToUse);
731 $mimedst = preg_replace("/".normalizePreg(get_ou('faiou'))."/",get_ou('mimetypeou'),"ou=".$name.",".$baseToUse) ;
733 /* Check if source depeartments exist */
734 foreach(array($baseToUse,$appsrc,$mimesrc) as $dep){
735 $ldap->cd($this->config->current['BASE']);
736 $ldap->cat($dep);
737 if(!$ldap->count()){
738 $ldap->create_missing_trees($dep);
739 }
740 }
742 /* Print header to have styles included */
743 echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
744 <html>
745 <head>
746 <title></title>
747 <style type="text/css">@import url("themes/default/style.css");</style>
748 <script language="javascript" src="include/focus.js" type="text/javascript"></script>
749 </head>
750 <body style="background: none;margin:3px;color:black">
751 ';
753 new log("create","fai/".get_class($this),$NewReleaseName,array(),"New $type created");
755 /* Duplicate group application releases
756 */
757 FAI::copy_FAI_group_releases($CurrentReleases[$this->fai_release],$name,$type);
759 /* Duplicate applications
760 */
761 $ldap->cat($appsrc,array("dn")) ;
762 if($ldap->count()){
763 $ldap->cd ($appdst);
764 $ldap->recursive_remove();
765 FAI::copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true);
766 }
768 /* Duplicate mime types
769 */
770 $ldap->cat($mimesrc,array("dn")) ;
771 if($ldap->count()){
772 $ldap->cd ($mimedst);
773 $ldap->recursive_remove();
774 FAI::copy_FAI_resource_recursive($mimesrc,$mimedst,$NewReleaseName,$type,true);
775 }
777 $attr = array();
778 $attr['objectClass'] = array("organizationalUnit","FAIbranch");
779 $attr['ou'] = $name;
780 $attr['FAIstate'] = $type;
781 $ldap->cd($this->config->current['BASE']);
782 $ldap->cd("ou=".$name.",".$baseToUse);
783 $ldap->cat("ou=".$name.",".$baseToUse);
784 if($ldap->count()){
785 $ldap->modify($attr);
786 }else{
787 $ldap->add($attr);
788 }
790 /* Duplicate fai objects
791 */
792 // $ldap->cd ("ou=".$name.",".$baseToUse);
793 // $ldap->recursive_remove();
794 // FAI::copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,$NewReleaseName,$type,true);
796 echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
797 <br><input type='submit' name='CloseIFrame' value='"._("Continue")."'>
798 </form></div>";
800 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
802 /* Print footer to have valid html */
803 echo "</body></html>";
805 $this->dispNewFreeze = false;
807 /* Postcreate */
809 /* Assign possible attributes */
810 $this->lock_type = $type;
811 $this->lock_name = $name;
812 $this->lock_dn = $baseToUse;
813 $this->postcreate();
816 /* Send daemon event to reload the fai release database
817 */
818 if(class_available("DaemonEvent") && class_available("gosaSupportDaemon")){
819 $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
820 if(isset($events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'])){
821 $evt = $events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'];
822 $tmp = new $evt['CLASS_NAME']($this->config);
823 $tmp->set_type(TRIGGERED_EVENT);
824 $tmp->add_targets(array("GOsa"));
825 $o_queue = new gosaSupportDaemon();
826 if(!$o_queue->append($tmp)){
827 msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
828 }
829 }
830 }else{
831 trigger_error("Unknown class DaemonEvent / gosaSupportDaemon");
832 msg_dialog::display(_("Fatal error"),
833 "Daemon events called but classes where not accessible, DaemonEvent gosaSupportDaemon",
834 FATAL_ERROR_DIALOG);
835 }
836 exit();
837 }
838 }
840 /****************
841 Display dialog to enter new Branch name
842 ****************/
844 /* Check if we have a post create method configured
845 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
846 */
847 if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
848 if(($s_action == "branch_branch")||($this->dispNewBranch)){
849 if(!$this->acl_is_createable()){
850 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
851 }else{
852 $this->dispNewBranch=true;
853 $smarty->assign("iframe",false);
854 $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
855 return($display);
856 }
857 }
858 }
861 /****************
862 Display dialog to enter new Freeze name
863 ****************/
865 /* Check if we have a post create method configured
866 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
867 */
868 if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
869 if(($s_action == "freeze_branch")||($this->dispNewFreeze)){
870 if(!$this->acl_is_createable()){
871 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
872 }else{
873 $this->dispNewFreeze = true;
874 $smarty->assign("iframe",false);
875 $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
876 return($display);
877 }
878 }
879 }
882 /****************
883 Create a new object
884 ****************/
886 $types = array( "new_partition" => "FAIpartitionTable",
887 "new_script" => "FAIscript",
888 "new_hook" => "FAIhook",
889 "new_variable" => "FAIvariable",
890 "new_template" => "FAItemplate",
891 "new_package" => "FAIpackageList");
892 $types_i18n = array( "new_partition" => _("partition table"),
893 "new_script" => _("script"),
894 "new_hook" => _("hook"),
895 "new_variable" => _("variable"),
896 "new_template" => _("template"),
897 "new_package" => _("package list"));
899 if(isset($types[$s_action])){
900 $acl = $this->ui->get_permissions($this->fai_base,"fai/".$type_acl_mapping[$types[$s_action]]);
901 if(preg_match("/c/",$acl)){
902 $this->dialog = new askClassName($this->config,$this->dn,$this->ui,$types[$s_action]);
903 $this->dialog->parent = &$this;
904 }else{
905 msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), $types_i18n[$s_action]), ERROR_DIALOG);
906 }
907 }
909 /* New Profile */
910 if($s_action == "new_profile"){
911 $this->dn = "new" ;
913 $acl = $this->ui->get_permissions($this->fai_base,"fai/faiProfile");
914 if(preg_match("/c/",$acl)){
915 $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
916 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
917 $this->dialog->set_acl_base($this->base);
918 $this->dialog->parent = &$this;
920 $this->is_dialog = false;
921 }else{
922 msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), _("profile")), ERROR_DIALOG);
923 }
924 }
927 /****************
928 Get from ask class name dialog
929 ****************/
931 if($s_action == "select_class_name_finished"){
932 $this->dialog->save_object();
933 if(count($this->dialog->check())!=0){
934 foreach($this->dialog->check() as $msg){
935 msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
936 }
937 }elseif(isset($this->dialog->objectClass)){
938 $this->dn = "new" ;
939 $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass)));
940 $name = $this->dialog->save();
942 if(class_exists($a_setup[0])){
943 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
944 $this->dialog->set_acl_base($this->base);
945 $this->dialog->by_object[$a_setup[1]]->cn = $name;
946 $this->dialog->parent = &$this;
947 $this->is_dialog = true;
948 }
949 }
950 }
953 /****************
954 Cancel dialogs
955 ****************/
957 if(isset($_POST['edit_cancel'])){
958 $this->dialog=FALSE;
959 $this->is_dialog = false;
960 session::un_set('objectinfo');
961 $this->remove_lock();
962 }
965 /****************
966 Save sub dialogs
967 ****************/
969 /* This check if the given tab could be saved
970 * If it was possible to save it, remove dialog object.
971 * If it wasn't possible, show errors and keep dialog.
972 */
973 if((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->dialog->config))){
974 $this->dialog->save_object();
975 $msgs= $this->dialog->check();
976 if(count($msgs)!=0){
977 foreach($msgs as $msg){
978 msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
979 }
980 }else{
981 $this->dialog->save();
982 FAI::save_release_changes_now();
983 if (!isset($_POST['edit_apply'])){
984 $this->remove_lock();
985 $this->dialog=FALSE;
986 $this->is_dialog=false;
987 session::un_set('objectinfo');
988 }else{
990 /* Reinitialize tab */
991 if($this->dialog instanceof tabs){
992 $this->dialog->re_init();
993 }
994 }
995 }
996 }
999 /****************
1000 Display currently open dialog
1001 ****************/
1003 /* If dialog is set, but $this->is_dialog==false, then
1004 * only the "abort" button is shown, this are dialogs that must not be saved.
1005 * If is_dialog == true, we are currently editing tab objects.
1006 * Here we need both, save and cancel
1007 */
1009 if(is_object($this->dialog)){
1010 $display .= $this->dialog->execute();
1011 /* Don't show buttons if tab dialog requests this */
1013 if(isset($this->dialog->current)){
1015 $obj = $this->dialog->by_object[$this->dialog->current];
1017 if((isset($obj->is_dialog) && (!$obj->is_dialog)) || (isset($obj->dialog) && (!$obj->dialog))){
1019 $display.= "<p style=\"text-align:right\">\n";
1020 if(!$this->no_save){
1021 $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
1022 $display.= " \n";
1023 if ($this->dn != "new"){
1024 $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
1025 $display.= " \n";
1026 }
1027 }
1028 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1029 $display.= "</p>";
1030 }elseif(!isset($this->dialog->current)){
1031 $display.= "<p style=\"text-align:right\">\n";
1032 $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\"> ";
1033 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1034 $display.= "</p>";
1035 }
1036 }else{
1037 $display.= "<p style=\"text-align:right\">\n";
1038 $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\"> ";
1039 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1040 $display.= "</p>";
1042 }
1043 return($display);
1044 }
1047 /****************
1048 Dialog display
1049 ****************/
1051 /* Check if there is a snapshot dialog open */
1052 $base = $this->fai_base;
1053 if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
1054 return($str);
1055 }
1057 /* Display dialog with system list */
1058 $this->reload();
1059 $this->DivListFai->parent = &$this;
1060 $this->DivListFai->execute();
1061 $this->DivListFai->setEntries($this->objects);
1062 return($this->DivListFai->Draw());
1063 }
1066 /* Return departments, that will be included within snapshot detection */
1067 function get_used_snapshot_bases()
1068 {
1069 $tmp = array();
1070 $types = array("faipartitionou","faiscriptou","faitemplateou","faihookou","faiprofileou","faivariableou","faipackageou");
1071 foreach($types as $type){
1072 $tmp[] = get_ou($type).$this->fai_release;
1073 }
1074 return($tmp);
1075 }
1078 /* Get available branches for current base */
1079 function getBranches($base = false,$prefix = "")
1080 {
1081 $ret = array("/"=>$this->fai_base);
1082 $ldap = $this->config->get_ldap_link();
1083 if(!$base){
1084 $base = $this->fai_base;
1085 }
1086 $tmp = FAI::get_all_releases_from_base($base,true);
1087 foreach($tmp as $dn => $name){
1088 $ret[$name]=$dn;
1089 }
1090 ksort($ret);
1091 $ret = array_flip($ret);
1093 return ($ret);
1094 }
1097 function list_get_selected_items()
1098 {
1099 $ids = array();
1100 foreach($_POST as $name => $value){
1101 if(preg_match("/^item_selected_[0-9]*$/",$name)){
1102 $id = preg_replace("/^item_selected_/","",$name);
1103 $ids[$id] = $id;
1104 }
1105 }
1106 return($ids);
1107 }
1110 /* reload list of objects */
1111 function reload()
1112 {
1113 /* Variable initialisation */
1114 $str = "";
1115 $Regex = $this->DivListFai->Regex;
1116 $this->objects = array();
1118 /* Get base */
1119 $base = $this->fai_base;
1120 if($this->fai_release != $this->fai_base){
1121 $br = $this->getBranches();
1122 if(isset($br[$this->fai_release])){
1123 $base = $this->fai_release;
1124 }else{
1125 $base = $this->fai_base;
1126 }
1127 }
1128 $this->base = $base;
1129 $this->set_acl_base($this->base);
1131 $this->lock_type = FAI::get_release_tag(FAI::get_release_dn($base));
1133 /* Create a new list of FAI object
1134 * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ...
1135 */
1136 $ObjectTypes = array(
1137 "FAIpartitionTable" => array("OU"=> get_ou('faipartitionou') , "CHKBOX"=>"ShowPartitions" ,"ACL" => "faiPartitionTable"),
1138 "FAIpackageList" => array("OU"=> get_ou('faipackageou') , "CHKBOX"=>"ShowPackages" ,"ACL" => "faiPackage"),
1139 "FAIscript" => array("OU"=> get_ou('faiscriptou') , "CHKBOX"=>"ShowScripts" ,"ACL" => "faiScript"),
1140 "FAIvariable" => array("OU"=> get_ou('faivariableou') , "CHKBOX"=>"ShowVariables" ,"ACL" => "faiVariable"),
1141 "FAIhook" => array("OU"=> get_ou('faihookou') , "CHKBOX"=>"ShowHooks" ,"ACL" => "faiHook"),
1142 "FAIprofile" => array("OU"=> get_ou('faiprofileou') , "CHKBOX"=>"ShowProfiles" ,"ACL" => "faiProfile"),
1143 "FAItemplate" => array("OU"=> get_ou('faitemplateou') , "CHKBOX"=>"ShowTemplates" ,"ACL" => "faiTemplate"));
1145 $filter = "";
1146 foreach($ObjectTypes as $key => $data){
1147 if($this->DivListFai->$data['CHKBOX']){
1148 $filter.= "(objectClass=".$key.")";
1149 }
1150 }
1151 $filter = "(&(|".$filter.")(cn=$Regex))";
1153 /* Get resolved release dependencies */
1154 $tmp = FAI::get_all_objects_for_given_base($base,$filter);
1156 /* Ge listed ldap objects */
1157 $ldap = $this->config->get_ldap_link();
1158 $ldap->cd($this->config->current['BASE']);
1160 foreach($tmp as $entry){
1162 /* Get some more informations about the object */
1163 $ldap->cat($entry['dn'], array("cn","description","objectClass","FAIclass","FAIstate","objectClass"));
1164 $object = $ldap->fetch();
1166 /* Walk through possible types */
1167 foreach($ObjectTypes as $type => $rest){
1169 $acl = $this->ui->get_permissions($object['dn'],"fai/".$rest ['ACL']);
1171 if(in_array($type,$object['objectClass']) && preg_match("/r/",$acl)){
1173 /* Prepare object */
1174 unset($object['objectClass']['count']);
1175 if(!isset($object['description'][0])){
1176 $object['description'][0]="";
1177 }
1179 /* Clean up object informations */
1180 $obj = array();
1181 $obj['cn'] = $object['cn'][0];
1182 $obj['dn'] = $object['dn'];
1183 $obj['acl'] = $acl;
1184 $obj['class'] = $rest ['ACL'];
1185 $obj['FAIstate'] = $entry['FAIstate'];
1186 $obj['description'] = $object['description'][0];
1187 $obj['objectClass'] = $object['objectClass'];
1189 $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj;
1190 $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type;
1191 }
1192 }
1193 }
1195 /* Append opsi objects, if opsi is available and if we are on the fai_base
1196 */
1197 if($this->opsi instanceof opsi && $this->opsi->enabled()){
1199 $err = FALSE;
1200 if(!$err && $this->DivListFai->ShowOpsiNetboot){
1201 $n_pro = $this->opsi->get_netboot_products();
1202 $err |= $this->opsi->is_error();
1203 foreach($n_pro as $name => $data){
1204 $entry = array("cn" => $name,
1205 "description" => $data['DESC'],
1206 "type" => "opsi_netboot");
1207 $this->objects[$name."_opsi_netboot"] = $entry;
1208 }
1209 }
1210 if(!$err && $this->DivListFai->ShowOpsiLocal){
1211 $l_pro = $this->opsi->get_local_products();
1212 $err |= $this->opsi->is_error();
1213 foreach($l_pro as $name => $data){
1214 $entry = array("cn" => $name,
1215 "description" => $data['DESC'],
1216 "type" => "opsi_local");
1217 $this->objects[$name."_opsi_local"] = $entry;
1218 }
1219 }
1220 if($err){
1221 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
1222 }
1223 }
1225 ksort($this->objects);
1226 reset ($this->objects);
1228 /* use numeric index, thats a bit more secure */
1229 $tmp0 = array();
1230 foreach($this->objects as $obj){
1231 $tmp0[]= $obj;
1232 }
1233 $this->objects = array();
1234 $this->objects = $tmp0;
1235 }
1237 function remove_lock()
1238 {
1239 if (isset($this->dn)){
1240 del_lock ($this->dn);
1241 }
1242 if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
1243 del_lock ($this->dns);
1244 }
1245 }
1247 function get_type($array){
1248 if(in_array("FAIpartitionTable",$array['objectClass'])){
1249 return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS"));
1250 }
1251 if(in_array("FAIscript",$array['objectClass'])){
1252 return(array("tabsScript","faiScript","FAISCRIPTTABS"));
1253 }
1254 if(in_array("FAItemplate",$array['objectClass'])){
1255 return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS"));
1256 }
1257 if(in_array("FAIhook",$array['objectClass'])){
1258 return(array("tabsHook","faiHook","FAIHOOKTABS"));
1259 }
1260 if(in_array("FAIvariable",$array['objectClass'])){
1261 return(array("tabsVariable","faiVariable","FAIVARIABLETABS"));
1262 }
1263 if(in_array("FAIprofile",$array['objectClass'])){
1264 return(array("tabsProfile","faiProfile","FAIPROFILETABS"));
1265 }
1267 if(in_array("FAIpackageList",$array['objectClass'])){
1268 return(array("tabsPackage","faiPackage","FAIPACKAGETABS"));
1269 }
1270 }
1272 function CheckNewBranchName($name,$base)
1273 {
1274 $f = $this->fai_release;
1275 if($name == ""){
1276 return(false);
1277 }elseif(in_array($name,$this->getBranches($f))) {
1278 return(false);
1279 }elseif(tests::is_department_name_reserved($name,$base)){
1280 return(false);
1281 }
1282 return(true);
1283 }
1285 function save_object()
1286 {
1287 $this->DivListFai->save_object();
1289 /* Get posted release */
1290 $r_releases = array_flip($this->getBranches());
1291 if(isset($_POST['fai_release']) && isset($r_releases[get_post('fai_release')])){
1293 /* Ensure that we have a valid release selected */
1294 if(!isset($r_releases[get_post('fai_release')])){
1295 msg_dialog::display(_("Warning"),_("The selected release is not available anymore. All triggered actions are skipped."));
1296 $_POST = array();
1297 $plug =$_GET['plug'];
1298 $_GET = array("plug" => $plug);
1299 $this->fai_release = $this->fai_base;
1300 }else{
1301 $this->fai_release = $r_releases[get_post('fai_release')];
1302 }
1304 $fai_filter = session::get("fai_filter");
1305 $fai_filter['fai_release'] = $this->fai_release;
1306 session::set("fai_filter",$fai_filter);
1307 }
1309 if(is_object($this->CopyPasteHandler)){
1310 $this->CopyPasteHandler->save_object();
1311 }
1312 }
1315 function copyPasteHandling_from_queue($s_action,$s_entry)
1316 {
1317 /* Check if Copy & Paste is disabled */
1318 if(!is_object($this->CopyPasteHandler)){
1319 return("");
1320 }
1322 $ui = get_userinfo();
1324 /* Add a single entry to queue */
1325 if($s_action == "copy"){
1327 /* Cleanup object queue */
1328 $this->CopyPasteHandler->cleanup_queue();
1329 $entry = $this->objects[$s_entry];
1330 $a_setup = $this->get_type($entry);
1331 $dn = $entry['dn'];
1333 if($ui->is_copyable($dn,"fai",$a_setup[1])){
1334 $this->CopyPasteHandler->add_to_queue($dn,$s_action,$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1335 }
1336 }
1338 /* Add entries to queue */
1339 if($s_action == "copy_multiple"){
1341 /* Cleanup object queue */
1342 $this->CopyPasteHandler->cleanup_queue();
1344 /* Add new entries to CP queue */
1345 foreach($this->list_get_selected_items() as $id){
1347 /* Cleanup object queue */
1348 $entry = $this->objects[$id];
1349 $a_setup = $this->get_type($entry);
1350 $dn = $entry['dn'];
1352 if($s_action == "copy_multiple" && $ui->is_copyable($dn,"fai",$a_setup[1])){
1353 $this->CopyPasteHandler->add_to_queue($dn,"copy",$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1354 }
1355 }
1356 }
1358 /* Start pasting entries */
1359 if($s_action == "editPaste" && !($this->lock_type == "freeze" && !$this->allow_freeze_object_attach)){
1360 $this->start_pasting_copied_objects = TRUE;
1361 }
1363 /* Return C&P dialog */
1364 if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
1366 /* Get dialog */
1367 $this->CopyPasteHandler->SetVar("parent",$this);
1368 $data = $this->CopyPasteHandler->execute();
1370 FAI::save_release_changes_now();
1372 /* Return dialog data */
1373 if(!empty($data)){
1374 return($data);
1375 }
1376 }
1378 /* Automatically disable status for pasting */
1379 if(!$this->CopyPasteHandler->entries_queued()){
1380 $this->start_pasting_copied_objects = FALSE;
1381 }
1382 return("");
1383 }
1386 /* Check if the given FAI class is used in this release
1387 */
1388 static function check_class_name($oc,$name,$dn)
1389 {
1390 $base = FAI::get_release_dn($dn);
1392 if($oc == "FAIprofile"){
1393 $f = "";
1394 $ocs = array("FAItemplate","FAIhook","FAIpartitionTable","FAIpackageList","FAIscript","FAIvariable");
1395 foreach($ocs as $oc){
1396 $f .= "(objectClass=".$oc.")";
1397 }
1398 $res = FAI::get_all_objects_for_given_base($base,"(|".$f.")",TRUE);
1399 }else{
1400 $res = FAI::get_all_objects_for_given_base($base,"(objectClass=".$oc.")",TRUE);
1401 }
1402 $delete = array();
1403 $used = array();
1404 foreach($res as $object){
1405 $used[$object['cn'][0]]= $object['cn'][0];
1406 }
1407 return($used);
1408 }
1411 /* Return plugin informations for acl handling */
1412 static function plInfo()
1413 {
1414 return (array(
1415 "plShortName" => _("FAI releases"),
1416 "plDescription" => _("FAI release management"),
1417 "plSelfModify" => FALSE,
1418 "plDepends" => array(),
1419 "plPriority" => 0,
1420 "plSection" => array("administration"),
1421 "plCategory" => array("fai"=> array("description" => _("FAI"),
1422 "objectClass" => "FAIclass")),
1423 "plProvidedAcls"=> array()));
1424 }
1425 }
1426 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1427 ?>