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;
52 var $no_save;
53 var $acl_base ="";
54 var $fai_base ="";
55 var $fai_release ="";
56 var $acl_module = array("fai");
57 var $opsi = NULL;
59 /* construction/reconstruction
60 */
61 function faiManagement (&$config, $ui)
62 {
63 /* Set defaults */
64 $this->dn = "";
65 $this->config = $config;
66 $this->ui = $ui;
68 /* Check if the opsi plugin is installed.
69 */
70 if(class_available("opsi")){
71 $this->opsi = new opsi($this->config);;
72 }
74 /* Creat dialog object */
75 $this->DivListFai = new divListFai($this->config,$this);
77 /* Copy & Paste handler */
78 if ($this->config->boolValueIsTrue("main", "copyPaste")){
79 $this->CopyPasteHandler= new CopyPasteHandler($this->config);
80 }
82 /* Set default release
83 */
84 $this->acl_base = $this->config->current['BASE'];
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();
110 /* Initialise vars and smarty */
111 $smarty = get_smarty();
112 $smarty->assign("BranchName","");
114 $display = "";
115 $s_action = "";
116 $s_entry = "";
117 $no_save = FALSE; // hide Apply / Save buttons
119 /* If an entry was locked, these vars will be stored in a session to allow direct edit */
120 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/","/^faiGroupHandle_apply$/"));
122 /****************
123 Handle posts
124 ****************/
126 /* Check ImageButton posts
127 * Create new tab ich new_xx is posted
128 */
129 $posts = array( "/^remove_branch/" =>"remove_branch",
130 "/^branch_branch/" =>"branch_branch",
131 "/^freeze_branch/" =>"freeze_branch",
133 "/^create_partition/i" =>"new_partition",
134 "/^create_script/i" =>"new_script",
135 "/^create_hook/i" =>"new_hook",
136 "/^create_variable/i" =>"new_variable",
137 "/^create_template/i" =>"new_template",
138 "/^create_package/i" =>"new_package",
139 "/^create_profile/i" =>"new_profile",
141 "/^edit_continue$/" => "select_class_name_finished",
143 "/^group_edit/" => "group_edit",
144 "/^group_remove/" => "group_remove");
145 foreach($_POST as $name => $value){
146 foreach($posts as $reg => $act ){
147 if(preg_match($reg,$name)){
148 $s_action = $act;
149 $s_entry = ltrim(preg_replace($reg,"",$name),"_");
150 $s_entry = preg_replace("/_.*$/","",$s_entry);
151 break;
152 }
153 }
154 }
156 if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id'])){
157 if(isset($this->objects[$_GET['id']])){
158 $s_action = "group_edit";
159 $s_entry = $_GET['id'];
160 }
161 }
163 foreach(array("freeze_branch" => "freeze_branch",
164 "branch_branch" => "branch_branch",
165 "remove_branch" => "remove_branch") as $from => $to){
166 if(isset($_GET['act']) && $_GET['act'] == $from){
167 $s_action = $to;
168 }
169 }
171 /* handle C&P from layer menu */
172 if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){
173 $s_action = "copy_multiple";
174 }
175 if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){
176 $s_action = "cut_multiple";
177 }
178 if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){
179 $s_action = "editPaste";
180 }
183 if((isset($_POST['CancelBranchName'])) || (isset($_POST['CloseIFrame']))){
184 $this->dispNewBranch = false;
185 $this->dispNewFreeze = false;
186 }
188 /* Create options */
189 if(isset($_POST['menu_action']) && preg_match("/^Create_/",$_POST['menu_action'])){
190 $s_action = "new_".preg_replace("/^Create_/","",$_POST['menu_action']);;
191 $s_entry = preg_replace("/^Create_/","",$_POST['menu_action']);
192 }
194 /* handle remove from layers menu */
195 if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){
196 $s_action = "del_multiple";
197 }
200 if(!empty($s_action)){
201 $this->no_save = $no_save;
202 }
204 /********************
205 Copy & Paste
206 ********************/
208 /* Display the copy & paste dialog, if it is currently open */
209 $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
210 if($ret){
211 return($ret);
212 }
215 /*******************
216 Opsi extension
217 *******************/
219 if($this->opsi instanceof opsi && $this->opsi->enabled()){
220 if($s_action == "opsi_edit"){
221 $name = $this->objects[$s_entry]['cn'];
222 $cfg = $this->opsi->get_product_properties($name);
223 $this->dialog = new tabs_opsiProdConfig($this->config, $this->config->data['TABS']['OPSIPRODCONFIG'],"","opsi");
224 if(isset($this->dialog->by_object['opsiProperties'])){
225 $this->dialog->by_object['opsiProperties']->set_cfg($cfg);
226 $this->dialog->by_object['opsiProperties']->set_product($name);
227 }else{
228 trigger_error("Unknown tab, please check config.");
229 }
230 }
231 if($this->dialog instanceof tabs_opsiProdConfig && isset($_POST['cancel_properties'])){
232 $this->dialog = NULL;
233 }
234 if($this->dialog instanceof tabs_opsiProdConfig && isset($_POST['save_properties'])){
235 $this->dialog->save_object();
236 $op = $this->dialog->by_object['opsiProperties'];
237 $name = $op->get_product();
238 $cfg = $op->get_cfg();
239 $this->opsi->set_product_properties($name,$cfg);
240 if($this->opsi->is_error()){
241 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
242 }else{
243 $this->dialog = NULL;
244 }
245 }
246 if($this->dialog instanceof tabs_opsiProdConfig){
247 $this->dialog->save_object();
248 return($this->dialog->execute());
249 }
250 }
253 /****************
254 Delete a group of FAI objects
255 (Group = same name & different classes)
256 ****************/
258 if($s_action == "group_remove"){
259 if(isset($this->objects[$s_entry])){
260 $group = $this->objects[$s_entry];
262 /* Do not allow to remove opsi products */
263 foreach(array("opsi_netboot","opsi_local") as $type){
264 if(isset($group[$type])) unset($group[$type]);
265 }
266 if(count($group)){
267 $this->dialog = new faiGroupHandle($group,"remove");
268 }
269 }
270 }elseif($s_action == "group_edit"){
271 if(isset($this->objects[$s_entry])){
272 $group = $this->objects[$s_entry];
273 $this->dialog = new faiGroupHandle($group,"edit");
274 }
275 }
276 if($this->dialog instanceOf faiGroupHandle){
277 $this->dialog->save_object();
278 if($this->dialog->is_open()){
279 return($this->dialog->execute());
280 }
281 if($this->dialog->is_canceled() || isset($_POST['cancel_lock'])){
282 $this->dialog = FALSE;
283 }
284 }
287 /********************
288 Delete MULTIPLE entries confirmed
289 ********************/
291 /* Confirmation for deletion has been passed. Users should be deleted. */
292 if (isset($_POST['delete_multiple_fai_object_confirm'])){
294 /* Find out more about the object type */
295 $ldap = $this->config->get_ldap_link();
297 /* Remove user by user and check acls before removeing them */
298 foreach($this->dns as $key => $dn){
299 $ldap->cat($dn, array('objectClass'));
300 $attrs = $ldap->fetch();
301 $type = $this->get_type($attrs);
302 $acl = $this->ui->get_permissions($dn,"fai/".$type[1]);
303 if(preg_match("/d/",$acl)){
304 $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $dn,"fai");
305 $this->dialog->parent = &$this;
306 $this->dialog->set_acl_base($dn);
307 $this->dialog->by_object[$type[1]]->remove_from_parent ();
308 $this->dialog= FALSE;
309 $to_del = FAI::clean_up_releases($dn);
310 FAI::save_release_changes_now();
311 foreach($to_del as $dn){
312 $ldap->rmdir_recursive($dn);
313 }
314 } else {
316 /* Normally this shouldn't be reached, send some extra
317 logs to notify the administrator */
318 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
319 new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion.");
320 }
321 }
323 /* Remove lock file after successfull deletion */
324 $this->remove_lock();
325 $this->dns = array();
326 $this->dialog = FALSE;
327 }
330 /****************
331 Delete confirme dialog
332 ****************/
334 if ($s_action=="del_multiple" ||
335 $this->dialog instanceOf faiGroupHandle && $this->dialog->get_mode() == "remove"){
337 /* Collect objects to delete and check if objects are freezed
338 */
339 $dns = array();
340 $errors = "";
341 $this->dns = array();
342 if($this->dialog instanceOf faiGroupHandle){
343 $to_delete = $this->dialog->get_selected();
344 }else{
345 $ids = $this->list_get_selected_items();
346 $to_delete = array();
347 foreach($ids as $id){
348 $to_delete = array_merge($to_delete,$this->objects[$id]);
349 }
350 }
352 foreach($to_delete as $obj){
353 if(isset($obj['type']) && in_array($obj['type'],array("opsi_netboot","opsi_local"))){
354 continue;
355 }
356 if(isset($obj['FAIstate']) && preg_match('/^freeze/', $obj['FAIstate'])){
357 $errors .= $obj['cn'].", ";
358 }else{
359 $this->dns[] = $obj['dn'];
360 }
361 }
363 if($errors != ""){
364 msg_dialog::display(_("Branch locked"),sprintf(_("The following entries are locked, you can't remove them %s."),
365 "<br><br>".trim($errors,", ")),INFO_DIALOG);
366 }
368 /* Check locking
369 */
370 if(count($this->dns)){
371 if ($user= get_multiple_locks($this->dns)){
372 return(gen_locked_message($user,$this->dns));
373 }
374 if(count($this->dns)){
375 $dns_names = array();
376 foreach($this->dns as $dn){
377 add_lock ($dn, $this->ui->dn);
378 $dns_names[] = LDAP::fix($dn);
379 }
380 $smarty->assign("warning",msgPool::deleteInfo($dns_names,_("FAI object")));
381 $smarty->assign("multiple", true);
382 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
383 }
384 }
385 }
389 /********************
390 Delete MULTIPLE entries Canceled
391 ********************/
393 /* Remove lock */
394 if(isset($_POST['delete_multiple_fai_object_cancel'])){
395 $this->remove_lock();
396 $this->dns = array();
397 }
400 /****************
401 Edit entry
402 ****************/
404 if($this->dialog instanceOf faiGroupHandle && $this->dialog->get_mode() == "edit"){
406 $entry = array();
407 if($this->dialog instanceOf faiGroupHandle){
408 $entries = $this->dialog->get_selected();
409 $entry = array_pop($entries);
410 }elseif(isset($this->objects[$i_entryID][$s_entryType])){
411 $entry = $this->objects[$i_entryID][$s_entryType];
412 }
414 if(count($entry)){
415 $a_setup = $this->get_type($entry);
417 /* Special handling for opsi products
418 */
420 if(in_array($entry['type'],array("opsi_local","opsi_netboot")) &&
421 $this->opsi instanceof opsi && $this->opsi->enabled() ){
423 $name = $entry['cn'];
424 $cfg = $this->opsi->get_product_properties($name);
425 $this->dialog = new tabs_opsiProdConfig($this->config, $this->config->data['TABS']['OPSIPRODCONFIG'],"","opsi");
426 if(isset($this->dialog->by_object['opsiProperties'])){
427 $this->dialog->by_object['opsiProperties']->set_cfg($cfg);
428 $this->dialog->by_object['opsiProperties']->set_product($name);
429 }else{
430 trigger_error("Unknown tab, please check config.");
431 }
432 }elseif(count($a_setup)){
434 $this->dn = $entry['dn'];
435 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
436 if (($user= get_lock($this->dn)) != ""){
437 return(gen_locked_message ($user, $this->dn, TRUE));
438 }
439 add_lock ($this->dn, $this->ui->dn);
441 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
442 $this->dialog->parent = &$this;
443 $this->dialog->by_object[$a_setup[1]]->FAIstate = $entry['FAIstate'];
444 $this->dialog->set_acl_base($this->dn);
445 $this->is_dialog = true;
446 session::set('objectinfo',$this->dn);
447 }
448 }
449 }
452 /* Branch handling
453 09.01.2006
454 */
456 /****************
457 Remove branch
458 ****************/
460 /* Remove branch
461 */
462 if($s_action == "remove_branch"){
463 $base= $this->fai_release;
465 /* Check if we have a post remove method configured
466 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
467 */
468 if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
469 /* Load permissions for selected 'dn' and check if
470 we're allowed to remove this 'dn' */
471 if(preg_match("/d/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
472 $smarty->assign("release_hidden",base64_encode($this->fai_release));
473 $smarty->assign("info", msgPool::deleteInfo(LDAP::fix($this->fai_release),_("FAI branch/freeze")));
474 return($smarty->fetch(get_template_path('remove_branch.tpl',TRUE)));
475 } else {
476 msg_dialog::display(_("Permission error"), _("You have no permission to delete this release!"), ERROR_DIALOG);
477 }
478 }
479 }
482 /****************
483 Remove branch confirmed
484 ****************/
486 if(isset($_POST['delete_branch_confirm'])){
488 /* Check if we have a post remove method configured
489 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
490 */
491 if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
493 if(!isset($_POST['release_hidden']) || base64_decode($_POST['release_hidden']) != $this->fai_release){
494 msg_dialog::display(_("Warning"),_("Release remove aborted because the release name check failed!"));
495 }else{
497 $bb = $this->fai_release;
498 if(!isset($ldap)){
499 $ldap = $this->config->get_ldap_link();
500 }
502 $br = $this->getBranches();
504 if(isset($br[$bb]) && preg_match("/d/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
505 $name = $br[$bb];
507 $ldap->cd($bb);
508 $ldap->recursive_remove();
509 $ldap->cd(preg_replace('/,'.preg_quote(get_ou('faiBaseRDN'), '/').'/', ','.get_ou('applicationRDN'), $bb));
510 $ldap->recursive_remove();
511 $ldap->cd(preg_replace('/,'.preg_quote(get_ou('faiBaseRDN'), '/').'/', ','.get_ou('mimetypeRDN'), $bb));
512 $ldap->recursive_remove();
514 /* Search for all groups with configured application menus.
515 - First search all groups, to ensure that we only remove entries form whithin groups.
516 - The search für menu configuration for the specified release and collect all those dns.
517 - Remove entries
518 */
519 $release_ou = preg_replace("/".preg_quote(get_ou("faiBaseRDN"), '/').".*$/","",$bb);
520 $ldap->cd($this->config->current['BASE']);
521 $ldap->search("(objectClass=posixGroup)",array("dn"));
523 /* Collect all group dns
524 */
525 $groups = array();
526 while($attrs = $ldap->fetch()){
527 $groups[] = $attrs['dn'];
528 }
530 /* Collect all group menu release dns that match the release we have removed
531 */
532 $dns = array();
533 foreach($groups as $dn){
534 $ldap->cd($dn);
535 $ldap->search("(objectClass=FAIbranch)",array("dn"));
536 while($attrs = $ldap->fetch()){
537 if(preg_match("/^".preg_quote($release_ou, '/')."/",$attrs['dn'])){
538 $dns[] = $attrs['dn'];
539 }
540 }
541 }
543 /* Finally remove collected release dns
544 */
545 foreach($dns as $dn){
546 $ldap->cd($dn);
547 $ldap->recursive_remove();
548 }
550 /* Post remove */
551 $this->fai_release = $this->fai_base;
552 $this->lock_name = $name;
553 $this->lock_dn = $bb;
554 $this->postremove();
556 $fai_filter = session::get("fai_filter");
557 $fai_filter['fai_release'] = $this->fai_release;
558 session::set("fai_filter",$fai_filter);
560 new log("remove","fai/".get_class($this),$br[$bb],array(),"Release removed");
561 }
562 }
563 }
564 }
567 /****************
568 Create a new branch "insert Name"
569 ****************/
571 if((isset($_POST['UseBranchName']))&&(($this->dispNewBranch)||($this->dispNewFreeze))){
572 session::set('LASTPOST',$_POST);
574 if($this->dispNewBranch){
575 $type = "branch";
576 }else{
577 $type = "freeze";
578 }
580 /* Check branch name */
581 $name = $_POST['BranchName'];
582 $is_ok = true;
583 $smarty->assign("BranchName",$name);
584 $base= $this->fai_base;
586 /* Check used characters */
587 if(!preg_match("/^[0-9a-z\.]*$/",$name)){
588 msg_dialog::display(_("Error"), msgPool::invalid(_("Name"),$name,"/[0-9a-z\.]/"), ERROR_DIALOG);
589 $is_ok = false;
590 }
592 /* Check if this name is already in use */
593 if(!$this->CheckNewBranchName($_POST['BranchName'],$this->fai_release)){
594 msg_dialog::display(_("Error"), msgPool::duplicated(_("Name")), ERROR_DIALOG);
595 $is_ok = false;
596 }
598 if($is_ok){
600 if(session::is_set('LASTPOST')){
601 $LASTPOST = session::get('LASTPOST');
602 }else{
603 $LASTPOST = array();
604 }
605 $LASTPOST['base'] = $base;
606 $LASTPOST['type'] = $type;
607 session::set('LASTPOST',$LASTPOST);
608 $smarty->assign("iframe", true);
609 $smarty->assign("plugID", $_GET['plug']);
610 $display = $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
611 return($display);
612 }
613 }
616 /****************
617 Create a new branch
618 ****************/
620 if(isset($_GET['PerformBranch'])){
622 if(!preg_match("/c/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
623 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
624 }else{
626 /* In order to see error messages we have to reset the error handler.
627 Due to the exit();
628 */
629 restore_error_handler();
631 /* Create it know */
632 $this->dispNewBranch = false;
633 $this->dispNewFreeze = false;
635 $LASTPOST = session::get('LASTPOST');
636 $base = $LASTPOST['base'];
637 $_POST = session::get('LASTPOST');
638 $name = $_POST['BranchName'];
640 $type = $LASTPOST['type'];
641 $ldap = $this->config->get_ldap_link();
643 $baseToUse = $base;
644 if($this->fai_release != $this->fai_base){
645 $baseToUse = $this->fai_release;
646 }
648 /* Create new Release name to be able to set faidebianRelease for FAIpackageList */
650 $CurrentReleases = $this->getBranches();
651 $NewReleaseName = $name;
652 if(isset($CurrentReleases[$this->fai_release])) {
653 if($this->fai_release != $this->fai_base){
654 $NewReleaseName = $CurrentReleases[$this->fai_release]."/".$name;
655 $NewReleaseName = preg_replace("#\/#","/",$NewReleaseName);
656 }else{
657 $NewReleaseName = $name;
658 }
659 }
661 $appsrc = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('applicationRDN'),$baseToUse);
662 $appdst = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('applicationRDN'),"ou=".$name.",".$baseToUse) ;
664 $mimesrc = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('mimetypeRDN'),$baseToUse);
665 $mimedst = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('mimetypeRDN'),"ou=".$name.",".$baseToUse) ;
667 /* Check if source depeartments exist */
668 foreach(array($baseToUse,$appsrc,$mimesrc) as $dep){
669 $ldap->cd($this->config->current['BASE']);
670 $ldap->cat($dep);
671 if(!$ldap->count()){
672 $ldap->create_missing_trees($dep);
673 }
674 }
676 /* Print header to have styles included */
677 echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
678 <html>
679 <head>
680 <title></title>
681 <style type="text/css">@import url("themes/default/style.css");</style>
682 <script language="javascript" src="include/focus.js" type="text/javascript"></script>
683 </head>
684 <body style="background: none;margin:3px;color:black">
685 ';
687 new log("create","fai/".get_class($this),$NewReleaseName,array(),"New $type created");
689 /* Duplicate group application releases
690 */
691 FAI::copy_FAI_group_releases($CurrentReleases[$this->fai_release],$name,$type);
693 /* Duplicate applications
694 */
695 $ldap->cat($appsrc,array("dn")) ;
696 if($ldap->count()){
697 $ldap->cd ($appdst);
698 $ldap->recursive_remove();
699 FAI::copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true);
700 }
702 /* Duplicate mime types
703 */
704 $ldap->cat($mimesrc,array("dn")) ;
705 if($ldap->count()){
706 $ldap->cd ($mimedst);
707 $ldap->recursive_remove();
708 FAI::copy_FAI_resource_recursive($mimesrc,$mimedst,$NewReleaseName,$type,true);
709 }
711 $attr = array();
712 $attr['objectClass'] = array("organizationalUnit","FAIbranch");
713 $attr['ou'] = $name;
714 $attr['FAIstate'] = $type;
715 $ldap->cd($this->config->current['BASE']);
716 $ldap->cd("ou=".$name.",".$baseToUse);
717 $ldap->cat("ou=".$name.",".$baseToUse);
718 if($ldap->count()){
719 $ldap->modify($attr);
720 }else{
721 $ldap->add($attr);
722 }
724 /* Duplicate fai objects
725 */
726 // $ldap->cd ("ou=".$name.",".$baseToUse);
727 // $ldap->recursive_remove();
728 // FAI::copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,$NewReleaseName,$type,true);
730 echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
731 <br><input type='submit' name='CloseIFrame' value='"._("Continue")."'>
732 <input type='hidden' name='php_c_check' value='1'>
733 </form></div>";
735 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
737 /* Print footer to have valid html */
738 echo "</body></html>";
740 $this->dispNewFreeze = false;
742 /* Postcreate */
744 /* Assign possible attributes */
745 $this->lock_type = $type;
746 $this->lock_name = $name;
747 $this->lock_dn = $baseToUse;
748 $this->postcreate();
751 /* Send daemon event to reload the fai release database
752 */
753 if(class_available("DaemonEvent") && class_available("gosaSupportDaemon")){
754 $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
755 if(isset($events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'])){
756 $evt = $events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'];
757 $tmp = new $evt['CLASS_NAME']($this->config);
758 $tmp->set_type(TRIGGERED_EVENT);
759 $tmp->add_targets(array("GOSA"));
760 $o_queue = new gosaSupportDaemon();
761 if(!$o_queue->append($tmp)){
762 msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
763 }
764 }
765 }else{
766 trigger_error("Unknown class DaemonEvent / gosaSupportDaemon");
767 msg_dialog::display(_("Fatal error"),
768 "Daemon events called but classes where not accessible, DaemonEvent gosaSupportDaemon",
769 FATAL_ERROR_DIALOG);
770 }
771 exit();
772 }
773 }
775 /****************
776 Display dialog to enter new Branch name
777 ****************/
779 /* Check if we have a post create method configured
780 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
781 */
782 if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
783 if(($s_action == "branch_branch")||($this->dispNewBranch)){
784 if(!preg_match("/c/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
785 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
786 }else{
787 $this->dispNewBranch=true;
788 $smarty->assign("iframe",false);
789 $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
790 return($display);
791 }
792 }
793 }
796 /****************
797 Display dialog to enter new Freeze name
798 ****************/
800 /* Check if we have a post create method configured
801 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
802 */
803 if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
804 if(($s_action == "freeze_branch")||($this->dispNewFreeze)){
805 if(!preg_match("/c/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
806 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
807 }else{
808 $this->dispNewFreeze = true;
809 $smarty->assign("iframe",false);
810 $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
811 return($display);
812 }
813 }
814 }
817 /****************
818 Create a new object
819 ****************/
821 $types = array( "new_partition" => "FAIpartitionTable",
822 "new_script" => "FAIscript",
823 "new_hook" => "FAIhook",
824 "new_variable" => "FAIvariable",
825 "new_template" => "FAItemplate",
826 "new_package" => "FAIpackageList");
827 $types_i18n = array( "new_partition" => _("partition table"),
828 "new_script" => _("script"),
829 "new_hook" => _("hook"),
830 "new_variable" => _("variable"),
831 "new_template" => _("template"),
832 "new_package" => _("package list"));
834 if(isset($types[$s_action])){
836 $type_acl_mapping = array(
837 "FAIpartitionTable" => "faiPartitionTable",
838 "FAIpackageList" => "faiPackage",
839 "FAIscript" => "faiScript",
840 "FAIvariable" => "faiVariable",
841 "FAIhook" => "faiHook",
842 "FAIprofile" => "faiProfile",
843 "FAItemplate" => "faiTemplate");
845 $acl = $this->ui->get_permissions($this->acl_base,"fai/".$type_acl_mapping[$types[$s_action]]);
846 if(preg_match("/c/",$acl)){
847 $this->dialog = new askClassName($this->config,$this->dn,$this->ui,$types[$s_action]);
848 $this->dialog->parent = &$this;
849 }else{
850 msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), $types_i18n[$s_action]), ERROR_DIALOG);
851 }
852 }
854 /* New Profile */
855 if($s_action == "new_profile"){
856 $this->dn = "new" ;
858 $acl = $this->ui->get_permissions($this->acl_base,"fai/faiProfile");
859 if(preg_match("/c/",$acl)){
860 $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
861 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
862 $this->dialog->set_acl_base($this->base);
863 $this->dialog->parent = &$this;
865 $this->is_dialog = false;
866 }else{
867 msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), _("profile")), ERROR_DIALOG);
868 }
869 }
872 /****************
873 Get name from ask_class_name dialog
874 ****************/
876 if($s_action == "select_class_name_finished"){
877 $this->dialog->save_object();
878 if(count($this->dialog->check())!=0){
879 foreach($this->dialog->check() as $msg){
880 msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
881 }
882 }elseif(isset($this->dialog->objectClass)){
883 $this->dn = "new" ;
884 $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass)));
885 $name = $this->dialog->save();
887 if(class_exists($a_setup[0])){
888 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
889 $this->dialog->set_acl_base($this->base);
890 $this->dialog->by_object[$a_setup[1]]->cn = $name;
891 $this->dialog->parent = &$this;
892 $this->is_dialog = true;
893 }
894 }
895 }
898 /****************
899 Cancel dialogs
900 ****************/
902 if(isset($_POST['edit_cancel'])){
903 $this->dialog=FALSE;
904 $this->is_dialog = false;
905 session::un_set('objectinfo');
906 $this->remove_lock();
907 }
910 /****************
911 Handle opsi dialogs
912 ****************/
914 if($this->dialog instanceof tabs_opsiProdConfig && isset($_POST['cancel_properties'])){
915 $this->dialog = NULL;
916 }
917 if($this->dialog instanceof tabs_opsiProdConfig && isset($_POST['save_properties'])){
918 $this->dialog->save_object();
919 $op = $this->dialog->by_object['opsiProperties'];
920 $name = $op->get_product();
921 $cfg = $op->get_cfg();
922 $this->opsi->set_product_properties($name,$cfg);
923 if($this->opsi->is_error()){
924 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
925 }else{
926 $this->dialog = NULL;
927 }
928 }
929 if($this->dialog instanceof tabs_opsiProdConfig){
930 $this->dialog->save_object();
931 return($this->dialog->execute());
932 }
935 /****************
936 Save sub dialogs
937 ****************/
939 /* This check if the given tab could be saved
940 * If it was possible to save it, remove dialog object.
941 * If it wasn't possible, show errors and keep dialog.
942 */
943 if((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->dialog->config))){
944 $this->dialog->save_object();
945 $msgs= $this->dialog->check();
946 if(count($msgs)!=0){
947 foreach($msgs as $msg){
948 msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
949 }
950 }else{
951 $this->dialog->save();
952 FAI::save_release_changes_now();
953 if (!isset($_POST['edit_apply'])){
954 $this->remove_lock();
955 $this->dialog=FALSE;
956 $this->is_dialog=false;
957 session::un_set('objectinfo');
958 }else{
960 /* Reinitialize tab */
961 if($this->dialog instanceof tabs){
962 $this->dialog->re_init();
963 }
964 }
965 }
966 }
969 /****************
970 Display currently open dialog
971 ****************/
973 /* If dialog is set, but $this->is_dialog==false, then
974 * only the "abort" button is shown, this are dialogs that must not be saved.
975 * If is_dialog == true, we are currently editing tab objects.
976 * Here we need both, save and cancel
977 */
979 if(is_object($this->dialog)){
980 $display .= $this->dialog->execute();
981 /* Don't show buttons if tab dialog requests this */
983 if(isset($this->dialog->current)){
985 $obj = $this->dialog->by_object[$this->dialog->current];
987 if(($this->dialog instanceOf tabs || $this->dialog instanceOf plugin) && $this->dialog->read_only == TRUE){
988 $display.= "<p style=\"text-align:right\">
989 <input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">
990 </p>";
991 }elseif((isset($obj->is_dialog) && (!$obj->is_dialog)) || (isset($obj->dialog) && (!$obj->dialog))){
993 $display.= "<p style=\"text-align:right\">\n";
994 if(!$this->no_save){
995 $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
996 $display.= " \n";
997 if ($this->dn != "new"){
998 $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
999 $display.= " \n";
1000 }
1001 }
1002 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1003 $display.= "</p>";
1004 }elseif(!isset($this->dialog->current)){
1005 $display.= "<p style=\"text-align:right\">\n";
1006 $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\"> ";
1007 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1008 $display.= "</p>";
1009 }
1010 }else{
1011 $display.= "<p style=\"text-align:right\">\n";
1012 $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\"> ";
1013 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1014 $display.= "</p>";
1016 }
1017 return($display);
1018 }
1021 /****************
1022 Dialog display
1023 ****************/
1025 /* Check if there is a snapshot dialog open */
1026 $base = $this->fai_base;
1027 if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
1028 return($str);
1029 }
1031 /* Display dialog with system list */
1032 $this->reload();
1033 $this->DivListFai->parent = &$this;
1034 $this->DivListFai->execute();
1035 $this->DivListFai->setEntries($this->objects);
1036 return($this->DivListFai->Draw());
1037 }
1040 /* Return departments, that will be included within snapshot detection */
1041 function get_used_snapshot_bases()
1042 {
1043 $tmp = array();
1044 $types = array("faiPartitionRDN","faiScriptRDN","faiTemplateRDN","faiHookRDN","faiProfileRDN","faiVariableRDN","faiPackageRDN");
1045 foreach($types as $type){
1046 $tmp[] = get_ou($type).$this->fai_release;
1047 }
1048 return($tmp);
1049 }
1052 /* Get available branches for current base */
1053 function getBranches($base = false,$prefix = "")
1054 {
1055 $ret = array("/"=>$this->fai_base);
1056 $ldap = $this->config->get_ldap_link();
1057 if(!$base){
1058 $base = $this->fai_base;
1059 }
1060 $tmp = FAI::get_all_releases_from_base($base,true);
1061 foreach($tmp as $dn => $name){
1062 $ret[$name]=$dn;
1063 }
1064 ksort($ret);
1065 $ret = array_flip($ret);
1067 return ($ret);
1068 }
1071 function list_get_selected_items()
1072 {
1073 $ids = array();
1074 foreach($_POST as $name => $value){
1075 if(preg_match("/^item_selected_[0-9]*$/",$name)){
1076 $id = preg_replace("/^item_selected_/","",$name);
1077 $ids[$id] = $id;
1078 }
1079 }
1080 return($ids);
1081 }
1084 /* reload list of objects */
1085 function reload()
1086 {
1087 /* Variable initialisation */
1088 $str = "";
1089 $Regex = $this->DivListFai->Regex;
1090 $this->objects = array();
1092 /* Get base */
1093 $base = $this->fai_base;
1094 if($this->fai_release != $this->fai_base){
1095 $br = $this->getBranches();
1096 if(isset($br[$this->fai_release])){
1097 $base = $this->fai_release;
1098 }else{
1099 $base = $this->fai_base;
1100 }
1101 }
1102 $this->base = $base;
1103 $this->set_acl_base($this->acl_base);
1105 $this->lock_type = FAI::get_release_tag(FAI::get_release_dn($base));
1107 /* Create a new list of FAI object
1108 * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ...
1109 */
1110 $ObjectTypes = array(
1111 "FAIpartitionTable" => array("OU"=> get_ou('faiPartitionRDN') , "CHKBOX"=>"ShowPartitions" ,"ACL" => "faiPartitionTable"),
1112 "FAIpackageList" => array("OU"=> get_ou('faiPackageRDN') , "CHKBOX"=>"ShowPackages" ,"ACL" => "faiPackage"),
1113 "FAIscript" => array("OU"=> get_ou('faiScriptRDN') , "CHKBOX"=>"ShowScripts" ,"ACL" => "faiScript"),
1114 "FAIvariable" => array("OU"=> get_ou('faiVariableRDN') , "CHKBOX"=>"ShowVariables" ,"ACL" => "faiVariable"),
1115 "FAIhook" => array("OU"=> get_ou('faiHookRDN') , "CHKBOX"=>"ShowHooks" ,"ACL" => "faiHook"),
1116 "FAIprofile" => array("OU"=> get_ou('faiProfileRDN') , "CHKBOX"=>"ShowProfiles" ,"ACL" => "faiProfile"),
1117 "FAItemplate" => array("OU"=> get_ou('faiTemplateRDN') , "CHKBOX"=>"ShowTemplates" ,"ACL" => "faiTemplate"));
1119 $filter = "";
1120 foreach($ObjectTypes as $key => $data){
1121 if($this->DivListFai->$data['CHKBOX']){
1122 $filter.= "(objectClass=".$key.")";
1123 }
1124 }
1125 $filter = "(&(|".$filter.")(cn=$Regex))";
1127 /* Get resolved release dependencies */
1128 $tmp = FAI::get_all_objects_for_given_base($base,$filter);
1130 /* Ge listed ldap objects */
1131 $ldap = $this->config->get_ldap_link();
1132 $ldap->cd($this->config->current['BASE']);
1134 foreach($tmp as $entry){
1136 /* Get some more informations about the object */
1137 $ldap->cat($entry['dn'], array("cn","description","objectClass","FAIclass","FAIstate","objectClass"));
1138 $object = $ldap->fetch();
1140 /* Walk through possible types */
1141 foreach($ObjectTypes as $type => $rest){
1143 $acl = $this->ui->get_permissions($object['dn'],"fai/".$rest ['ACL']);
1145 if(in_array($type,$object['objectClass']) && preg_match("/r/",$acl)){
1147 /* Prepare object */
1148 unset($object['objectClass']['count']);
1149 if(!isset($object['description'][0])){
1150 $object['description'][0]="";
1151 }
1153 /* Clean up object informations */
1154 $obj = array();
1155 $obj['cn'] = $object['cn'][0];
1156 $obj['dn'] = $object['dn'];
1157 $obj['acl'] = $acl;
1158 $obj['class'] = $rest ['ACL'];
1159 $obj['FAIstate'] = $entry['FAIstate'];
1160 $obj['description'] = $object['description'][0];
1161 $obj['objectClass'] = $object['objectClass'];
1163 $this->objects[$obj['cn']][$type] = $obj;
1164 $this->objects[$obj['cn']][$type]['type']=$type;
1165 }
1166 }
1167 }
1169 /* Append opsi objects, if opsi is available and if we are on the fai_base
1170 */
1171 if($this->opsi instanceof opsi && $this->opsi->enabled()){
1172 $opsi_acl = $this->ui->get_permissions($base,"opsi/opsiProperties");
1173 if(preg_match("/r/",$opsi_acl)){
1174 $err = FALSE;
1175 if(!$err && $this->DivListFai->ShowOpsiNetboot){
1176 $n_pro = $this->opsi->get_netboot_products();
1177 $err |= $this->opsi->is_error();
1178 foreach($n_pro as $name => $data){
1179 $entry = array(
1180 "cn" => $name,
1181 "description" => $data['DESC'],
1182 "type" => "opsi_netboot");
1183 $this->objects[$name]['opsi_netboot'] = $entry;
1184 }
1185 }
1186 if(!$err && $this->DivListFai->ShowOpsiLocal){
1187 $l_pro = $this->opsi->get_local_products();
1188 $err |= $this->opsi->is_error();
1189 foreach($l_pro as $name => $data){
1190 $entry = array("cn" => $name,
1191 "description" => $data['DESC'],
1192 "type" => "opsi_local");
1193 $this->objects[$name]["opsi_local"] = $entry;
1194 }
1195 }
1196 if($err){
1197 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
1198 }
1199 }
1200 }
1202 uksort($this->objects, 'strnatcasecmp');
1203 reset ($this->objects);
1204 $this->objects = array_values($this->objects);
1205 }
1207 function remove_lock()
1208 {
1209 if (isset($this->dn)){
1210 del_lock ($this->dn);
1211 }
1212 if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
1213 del_lock ($this->dns);
1214 }
1215 }
1217 function get_type($array){
1218 if(!isset($array['objectClass'])) return(array());
1219 if(in_array("FAIpartitionTable",$array['objectClass'])){
1220 return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS"));
1221 }
1222 if(in_array("FAIscript",$array['objectClass'])){
1223 return(array("tabsScript","faiScript","FAISCRIPTTABS"));
1224 }
1225 if(in_array("FAItemplate",$array['objectClass'])){
1226 return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS"));
1227 }
1228 if(in_array("FAIhook",$array['objectClass'])){
1229 return(array("tabsHook","faiHook","FAIHOOKTABS"));
1230 }
1231 if(in_array("FAIvariable",$array['objectClass'])){
1232 return(array("tabsVariable","faiVariable","FAIVARIABLETABS"));
1233 }
1234 if(in_array("FAIprofile",$array['objectClass'])){
1235 return(array("tabsProfile","faiProfile","FAIPROFILETABS"));
1236 }
1238 if(in_array("FAIpackageList",$array['objectClass'])){
1239 return(array("tabsPackage","faiPackage","FAIPACKAGETABS"));
1240 }
1241 return(array());
1242 }
1244 function CheckNewBranchName($name,$base)
1245 {
1246 $f = $this->fai_release;
1247 if($name == ""){
1248 return(false);
1249 }elseif(in_array($name,$this->getBranches($f))) {
1250 return(false);
1251 }elseif(tests::is_department_name_reserved($name,$base)){
1252 return(false);
1253 }
1254 return(true);
1255 }
1257 function save_object()
1258 {
1259 $this->DivListFai->save_object();
1261 /* Get posted release */
1262 $r_releases = array_flip($this->getBranches());
1263 if(isset($_POST['fai_release']) && isset($r_releases[get_post('fai_release')])){
1265 /* Ensure that we have a valid release selected */
1266 if(!isset($r_releases[get_post('fai_release')])){
1267 msg_dialog::display(_("Warning"),_("The selected release is not available anymore. All triggered actions are skipped."));
1268 $_POST = array();
1269 $plug =$_GET['plug'];
1270 $_GET = array("plug" => $plug);
1271 $this->fai_release = $this->fai_base;
1272 }else{
1273 $this->fai_release = $r_releases[get_post('fai_release')];
1274 }
1276 $fai_filter = session::get("fai_filter");
1277 $fai_filter['fai_release'] = $this->fai_release;
1278 session::set("fai_filter",$fai_filter);
1279 }
1281 if(is_object($this->CopyPasteHandler)){
1282 $this->CopyPasteHandler->save_object();
1283 }
1284 }
1287 function copyPasteHandling_from_queue($s_action,$s_entry)
1288 {
1289 /* Check if Copy & Paste is disabled */
1290 if(!is_object($this->CopyPasteHandler)){
1291 return("");
1292 }
1294 $ui = get_userinfo();
1296 /* Add a single entry to queue */
1297 if($s_action == "copy"){
1299 /* Cleanup object queue */
1300 $this->CopyPasteHandler->cleanup_queue();
1301 $entry = $this->objects[$s_entry];
1302 $a_setup = $this->get_type($entry);
1303 $dn = $entry['dn'];
1305 if($ui->is_copyable($dn,"fai",$a_setup[1])){
1306 $this->CopyPasteHandler->add_to_queue($dn,$s_action,$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1307 }
1308 }
1310 /* Add entries to queue */
1311 if($s_action == "copy_multiple"){
1313 /* Cleanup object queue */
1314 $this->CopyPasteHandler->cleanup_queue();
1316 /* Add new entries to CP queue */
1317 foreach($this->list_get_selected_items() as $id){
1319 /* Cleanup object queue */
1320 $entry = $this->objects[$id];
1321 $a_setup = $this->get_type($entry);
1322 $dn = $entry['dn'];
1324 if($s_action == "copy_multiple" && $ui->is_copyable($dn,"fai",$a_setup[1])){
1325 $this->CopyPasteHandler->add_to_queue($dn,"copy",$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1326 }
1327 }
1328 }
1330 /* Start pasting entries */
1331 if($s_action == "editPaste" && !($this->lock_type == "freeze" && !$this->allow_freeze_object_attach)){
1332 $this->start_pasting_copied_objects = TRUE;
1333 }
1335 /* Return C&P dialog */
1336 if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
1338 /* Get dialog */
1339 $this->CopyPasteHandler->SetVar("parent",$this);
1340 $data = $this->CopyPasteHandler->execute();
1342 FAI::save_release_changes_now();
1344 /* Return dialog data */
1345 if(!empty($data)){
1346 return($data);
1347 }
1348 }
1350 /* Automatically disable status for pasting */
1351 if(!$this->CopyPasteHandler->entries_queued()){
1352 $this->start_pasting_copied_objects = FALSE;
1353 }
1354 return("");
1355 }
1358 /* Check if the given FAI class is used in this release
1359 */
1360 static function check_class_name($oc,$name,$dn)
1361 {
1362 $base = FAI::get_release_dn($dn);
1364 if($oc == "FAIprofile"){
1365 $f = "";
1366 $ocs = array("FAIprofile","FAItemplate","FAIhook","FAIpartitionTable","FAIpackageList","FAIscript","FAIvariable");
1367 foreach($ocs as $oc){
1368 $f .= "(objectClass=".$oc.")";
1369 }
1370 $res = FAI::get_all_objects_for_given_base($base,"(|".$f.")",TRUE);
1371 }else{
1372 $res = FAI::get_all_objects_for_given_base($base,"(objectClass=".$oc.")",TRUE);
1373 }
1374 $delete = array();
1375 $used = array();
1376 foreach($res as $object){
1377 $used[$object['cn'][0]]= $object['cn'][0];
1378 }
1379 return($used);
1380 }
1383 /* Return plugin informations for acl handling */
1384 static function plInfo()
1385 {
1386 return (array(
1387 "plShortName" => _("FAI releases"),
1388 "plDescription" => _("FAI release management"),
1389 "plSelfModify" => FALSE,
1390 "plDepends" => array(),
1391 "plPriority" => 0,
1392 "plSection" => array("administration"),
1393 "plCategory" => array("fai"=> array("description" => _("FAI"),
1394 "objectClass" => "FAIclass")),
1395 "plProvidedAcls"=> array()));
1396 }
1397 }
1398 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1399 ?>