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_copy/" => "group_copy",
144 "/^group_cut/" => "group_cut",
145 "/^group_edit/" => "group_edit",
146 "/^group_remove/" => "group_remove");
147 foreach($_POST as $name => $value){
148 foreach($posts as $reg => $act ){
149 if(preg_match($reg,$name)){
150 $s_action = $act;
151 $s_entry = ltrim(preg_replace($reg,"",$name),"_");
152 $s_entry = preg_replace("/_.*$/","",$s_entry);
153 break;
154 }
155 }
156 }
158 if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id'])){
159 if(isset($this->objects[$_GET['id']])){
160 $s_action = "group_edit";
161 $s_entry = $_GET['id'];
162 }
163 }
165 foreach(array("freeze_branch" => "freeze_branch",
166 "branch_branch" => "branch_branch",
167 "remove_branch" => "remove_branch") as $from => $to){
168 if(isset($_GET['act']) && $_GET['act'] == $from){
169 $s_action = $to;
170 }
171 }
173 /* handle C&P from layer menu */
174 if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){
175 $s_action = "copy_multiple";
176 }
177 if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){
178 $s_action = "cut_multiple";
179 }
180 if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){
181 $s_action = "editPaste";
182 }
185 if((isset($_POST['CancelBranchName'])) || (isset($_POST['CloseIFrame']))){
186 $this->dispNewBranch = false;
187 $this->dispNewFreeze = false;
188 }
190 /* Create options */
191 if(isset($_POST['menu_action']) && preg_match("/^Create_/",$_POST['menu_action'])){
192 $s_action = "new_".preg_replace("/^Create_/","",$_POST['menu_action']);;
193 $s_entry = preg_replace("/^Create_/","",$_POST['menu_action']);
194 }
196 /* handle remove from layers menu */
197 if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){
198 $s_action = "del_multiple";
199 }
202 if(!empty($s_action)){
203 $this->no_save = $no_save;
204 }
207 /*******************
208 Opsi extension
209 *******************/
211 if($this->opsi instanceof opsi && $this->opsi->enabled()){
212 if($s_action == "opsi_edit"){
213 $name = $this->objects[$s_entry]['cn'];
214 $cfg = $this->opsi->get_product_properties($name);
215 $this->dialog = new tabs_opsiProdConfig($this->config, $this->config->data['TABS']['OPSIPRODCONFIG'],"","opsi");
216 if(isset($this->dialog->by_object['opsiProperties'])){
217 $this->dialog->by_object['opsiProperties']->set_cfg($cfg);
218 $this->dialog->by_object['opsiProperties']->set_product($name);
219 }else{
220 trigger_error("Unknown tab, please check config.");
221 }
222 }
223 if($this->dialog instanceof tabs_opsiProdConfig && isset($_POST['cancel_properties'])){
224 $this->dialog = NULL;
225 }
226 if($this->dialog instanceof tabs_opsiProdConfig && isset($_POST['save_properties'])){
227 $this->dialog->save_object();
228 $op = $this->dialog->by_object['opsiProperties'];
229 $name = $op->get_product();
230 $cfg = $op->get_cfg();
231 $this->opsi->set_product_properties($name,$cfg);
232 if($this->opsi->is_error()){
233 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
234 }else{
235 $this->dialog = NULL;
236 }
237 }
238 if($this->dialog instanceof tabs_opsiProdConfig){
239 $this->dialog->save_object();
240 return($this->dialog->execute());
241 }
242 }
245 /****************
246 Delete a group of FAI objects
247 (Group = same name & different classes)
248 ****************/
250 if($s_action == "group_remove"){
251 if(isset($this->objects[$s_entry])){
252 $group = $this->objects[$s_entry];
254 /* Do not allow to remove opsi products */
255 foreach(array("opsi_netboot","opsi_local") as $type){
256 if(isset($group[$type])) unset($group[$type]);
257 }
258 if(count($group)){
259 $this->dialog = new faiGroupHandle($group,"remove");
260 }
261 }
262 }elseif($s_action == "group_edit"){
263 if(isset($this->objects[$s_entry])){
264 $group = $this->objects[$s_entry];
265 $this->dialog = new faiGroupHandle($group,"edit");
266 }
267 }elseif($s_action == "group_cut"){
268 if(isset($this->objects[$s_entry])){
269 $group = $this->objects[$s_entry];
270 $this->dialog = new faiGroupHandle($group,"cut");
271 }
272 }elseif($s_action == "group_copy"){
273 if(isset($this->objects[$s_entry])){
274 $group = $this->objects[$s_entry];
275 $this->dialog = new faiGroupHandle($group,"copy");
276 }
277 }
278 if($this->dialog instanceOf faiGroupHandle){
279 $this->dialog->save_object();
280 if($this->dialog->is_open()){
281 return($this->dialog->execute());
282 }elseif($this->dialog->is_canceled() || isset($_POST['cancel_lock'])){
283 $this->dialog = FALSE;
284 }else{
285 if(!count($this->dialog->get_selected())){
286 $this->dialog = FALSE;
287 }
288 }
289 }
291 /********************
292 Copy & Paste
293 ********************/
295 /* Display the copy & paste dialog, if it is currently open */
296 $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
297 if($ret){
298 return($ret);
299 }
302 /********************
303 Delete MULTIPLE entries confirmed
304 ********************/
306 /* Confirmation for deletion has been passed. Users should be deleted. */
307 if (isset($_POST['delete_multiple_fai_object_confirm'])){
309 /* Find out more about the object type */
310 $ldap = $this->config->get_ldap_link();
312 /* Remove user by user and check acls before removeing them */
313 foreach($this->dns as $key => $dn){
314 $ldap->cat($dn, array('objectClass'));
315 $attrs = $ldap->fetch();
316 $type = $this->get_type($attrs);
317 $acl = $this->ui->get_permissions($dn,"fai/".$type[1]);
318 if(preg_match("/d/",$acl)){
319 $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $dn,"fai");
320 $this->dialog->parent = &$this;
321 $this->dialog->set_acl_base($dn);
322 $this->dialog->by_object[$type[1]]->remove_from_parent ();
323 $this->dialog= FALSE;
324 $to_del = FAI::clean_up_releases($dn);
325 FAI::save_release_changes_now();
326 foreach($to_del as $dn){
327 $ldap->rmdir_recursive($dn);
328 }
329 } else {
331 /* Normally this shouldn't be reached, send some extra
332 logs to notify the administrator */
333 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
334 new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion.");
335 }
336 }
338 /* Remove lock file after successfull deletion */
339 $this->remove_lock();
340 $this->dns = array();
341 $this->dialog = FALSE;
342 }
345 /****************
346 Delete confirme dialog
347 ****************/
349 if ($s_action=="del_multiple" ||
350 $this->dialog instanceOf faiGroupHandle && $this->dialog->get_mode() == "remove"){
352 /* Collect objects to delete and check if objects are freezed
353 */
354 $dns = array();
355 $errors = "";
356 $this->dns = array();
357 if($this->dialog instanceOf faiGroupHandle){
358 $to_delete = $this->dialog->get_selected();
359 }else{
360 $ids = $this->list_get_selected_items();
361 $to_delete = array();
362 foreach($ids as $id){
363 $to_delete = array_merge($to_delete,$this->objects[$id]);
364 }
365 }
367 foreach($to_delete as $obj){
368 if(isset($obj['type']) && in_array($obj['type'],array("opsi_netboot","opsi_local"))){
369 continue;
370 }
371 if(isset($obj['FAIstate']) && preg_match('/^freeze/', $obj['FAIstate'])){
372 $errors .= $obj['cn'].", ";
373 }else{
374 $this->dns[] = $obj['dn'];
375 }
376 }
378 if($errors != ""){
379 msg_dialog::display(_("Branch locked"),sprintf(_("The following entries are locked, you can't remove them %s."),
380 "<br><br>".trim($errors,", ")),INFO_DIALOG);
381 }
383 /* Check locking
384 */
385 if(count($this->dns)){
386 if ($user= get_multiple_locks($this->dns)){
387 return(gen_locked_message($user,$this->dns));
388 }
389 if(count($this->dns)){
390 $dns_names = array();
391 foreach($this->dns as $dn){
392 add_lock ($dn, $this->ui->dn);
393 $dns_names[] = LDAP::fix($dn);
394 }
395 $smarty->assign("warning",msgPool::deleteInfo($dns_names,_("FAI object")));
396 $smarty->assign("multiple", true);
397 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
398 }
399 }
400 }
404 /********************
405 Delete MULTIPLE entries Canceled
406 ********************/
408 /* Remove lock */
409 if(isset($_POST['delete_multiple_fai_object_cancel'])){
410 $this->remove_lock();
411 $this->dns = array();
412 }
414 /****************
415 Edit entry
416 ****************/
418 if($this->dialog instanceOf faiGroupHandle && $this->dialog->get_mode() == "edit"){
420 $entry = array();
421 if($this->dialog instanceOf faiGroupHandle){
422 $entries = $this->dialog->get_selected();
423 $entry = array_pop($entries);
424 }elseif(isset($this->objects[$i_entryID][$s_entryType])){
425 $entry = $this->objects[$i_entryID][$s_entryType];
426 }
428 if(count($entry)){
429 $a_setup = $this->get_type($entry);
431 /* Special handling for opsi products
432 */
434 if(in_array($entry['type'],array("opsi_local","opsi_netboot")) &&
435 $this->opsi instanceof opsi && $this->opsi->enabled() ){
437 $name = $entry['cn'];
438 $cfg = $this->opsi->get_product_properties($name);
439 $this->dialog = new tabs_opsiProdConfig($this->config, $this->config->data['TABS']['OPSIPRODCONFIG'],"","opsi");
440 if(isset($this->dialog->by_object['opsiProperties'])){
441 $this->dialog->by_object['opsiProperties']->set_cfg($cfg);
442 $this->dialog->by_object['opsiProperties']->set_product($name);
443 }else{
444 trigger_error("Unknown tab, please check config.");
445 }
446 }elseif(count($a_setup)){
448 $this->dn = $entry['dn'];
449 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
450 if (($user= get_lock($this->dn)) != ""){
451 return(gen_locked_message ($user, $this->dn, TRUE));
452 }
453 add_lock ($this->dn, $this->ui->dn);
455 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
456 $this->dialog->parent = &$this;
457 $this->dialog->by_object[$a_setup[1]]->FAIstate = $entry['FAIstate'];
458 $this->dialog->set_acl_base($this->dn);
459 $this->is_dialog = true;
460 session::set('objectinfo',$this->dn);
461 }
462 }
463 }
466 /* Branch handling
467 09.01.2006
468 */
470 /****************
471 Remove branch
472 ****************/
474 /* Remove branch
475 */
476 if($s_action == "remove_branch"){
477 $base= $this->fai_release;
479 /* Check if we have a post remove method configured
480 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
481 */
482 if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
483 /* Load permissions for selected 'dn' and check if
484 we're allowed to remove this 'dn' */
485 if(preg_match("/d/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
486 $smarty->assign("release_hidden",base64_encode($this->fai_release));
487 $smarty->assign("info", msgPool::deleteInfo(LDAP::fix($this->fai_release),_("FAI branch/freeze")));
488 return($smarty->fetch(get_template_path('remove_branch.tpl',TRUE)));
489 } else {
490 msg_dialog::display(_("Permission error"), _("You have no permission to delete this release!"), ERROR_DIALOG);
491 }
492 }
493 }
496 /****************
497 Remove branch confirmed
498 ****************/
500 if(isset($_POST['delete_branch_confirm'])){
502 /* Check if we have a post remove method configured
503 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
504 */
505 if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
507 if(!isset($_POST['release_hidden']) || base64_decode($_POST['release_hidden']) != $this->fai_release){
508 msg_dialog::display(_("Warning"),_("Release remove aborted because the release name check failed!"));
509 }else{
511 $bb = $this->fai_release;
512 if(!isset($ldap)){
513 $ldap = $this->config->get_ldap_link();
514 }
516 $br = $this->getBranches();
518 if(isset($br[$bb]) && preg_match("/d/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
519 $name = $br[$bb];
521 $ldap->cd($bb);
522 $ldap->recursive_remove();
523 $ldap->cd(preg_replace('/,'.preg_quote(get_ou('faiBaseRDN'), '/').'/', ','.get_ou('applicationRDN'), $bb));
524 $ldap->recursive_remove();
525 $ldap->cd(preg_replace('/,'.preg_quote(get_ou('faiBaseRDN'), '/').'/', ','.get_ou('mimetypeRDN'), $bb));
526 $ldap->recursive_remove();
528 /* Search for all groups with configured application menus.
529 - First search all groups, to ensure that we only remove entries form whithin groups.
530 - The search für menu configuration for the specified release and collect all those dns.
531 - Remove entries
532 */
533 $release_ou = preg_replace("/".preg_quote(get_ou("faiBaseRDN"), '/').".*$/","",$bb);
534 $ldap->cd($this->config->current['BASE']);
535 $ldap->search("(objectClass=posixGroup)",array("dn"));
537 /* Collect all group dns
538 */
539 $groups = array();
540 while($attrs = $ldap->fetch()){
541 $groups[] = $attrs['dn'];
542 }
544 /* Collect all group menu release dns that match the release we have removed
545 */
546 $dns = array();
547 foreach($groups as $dn){
548 $ldap->cd($dn);
549 $ldap->search("(objectClass=FAIbranch)",array("dn"));
550 while($attrs = $ldap->fetch()){
551 if(preg_match("/^".preg_quote($release_ou, '/')."/",$attrs['dn'])){
552 $dns[] = $attrs['dn'];
553 }
554 }
555 }
557 /* Finally remove collected release dns
558 */
559 foreach($dns as $dn){
560 $ldap->cd($dn);
561 $ldap->recursive_remove();
562 }
564 /* Post remove */
565 $this->fai_release = $this->fai_base;
566 $this->lock_name = $name;
567 $this->lock_dn = $bb;
568 $this->postremove();
570 $fai_filter = session::get("fai_filter");
571 $fai_filter['fai_release'] = $this->fai_release;
572 session::set("fai_filter",$fai_filter);
574 new log("remove","fai/".get_class($this),$br[$bb],array(),"Release removed");
575 }
576 }
577 }
578 }
581 /****************
582 Create a new branch "insert Name"
583 ****************/
585 if((isset($_POST['UseBranchName']))&&(($this->dispNewBranch)||($this->dispNewFreeze))){
586 session::set('LASTPOST',$_POST);
588 if($this->dispNewBranch){
589 $type = "branch";
590 }else{
591 $type = "freeze";
592 }
594 /* Check branch name */
595 $name = $_POST['BranchName'];
596 $is_ok = true;
597 $smarty->assign("BranchName",$name);
598 $base= $this->fai_base;
600 /* Check used characters */
601 if(!preg_match("/^[0-9a-z\.]*$/",$name)){
602 msg_dialog::display(_("Error"), msgPool::invalid(_("Name"),$name,"/[0-9a-z\.]/"), ERROR_DIALOG);
603 $is_ok = false;
604 }
606 /* Check if this name is already in use */
607 if(!$this->CheckNewBranchName($_POST['BranchName'],$this->fai_release)){
608 msg_dialog::display(_("Error"), msgPool::duplicated(_("Name")), ERROR_DIALOG);
609 $is_ok = false;
610 }
612 if($is_ok){
614 if(session::is_set('LASTPOST')){
615 $LASTPOST = session::get('LASTPOST');
616 }else{
617 $LASTPOST = array();
618 }
619 $LASTPOST['base'] = $base;
620 $LASTPOST['type'] = $type;
621 session::set('LASTPOST',$LASTPOST);
622 $smarty->assign("iframe", true);
623 $smarty->assign("plugID", $_GET['plug']);
624 $display = $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
625 return($display);
626 }
627 }
630 /****************
631 Create a new branch
632 ****************/
634 if(isset($_GET['PerformBranch'])){
636 if(!preg_match("/c/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
637 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
638 }else{
640 /* In order to see error messages we have to reset the error handler.
641 Due to the exit();
642 */
643 restore_error_handler();
645 /* Create it know */
646 $this->dispNewBranch = false;
647 $this->dispNewFreeze = false;
649 $LASTPOST = session::get('LASTPOST');
650 $base = $LASTPOST['base'];
651 $_POST = session::get('LASTPOST');
652 $name = $_POST['BranchName'];
654 $type = $LASTPOST['type'];
655 $ldap = $this->config->get_ldap_link();
657 $baseToUse = $base;
658 if($this->fai_release != $this->fai_base){
659 $baseToUse = $this->fai_release;
660 }
662 /* Create new Release name to be able to set faidebianRelease for FAIpackageList */
664 $CurrentReleases = $this->getBranches();
665 $NewReleaseName = $name;
666 if(isset($CurrentReleases[$this->fai_release])) {
667 if($this->fai_release != $this->fai_base){
668 $NewReleaseName = $CurrentReleases[$this->fai_release]."/".$name;
669 $NewReleaseName = preg_replace("#\/#","/",$NewReleaseName);
670 }else{
671 $NewReleaseName = $name;
672 }
673 }
675 $appsrc = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('applicationRDN'),$baseToUse);
676 $appdst = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('applicationRDN'),"ou=".$name.",".$baseToUse) ;
678 $mimesrc = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('mimetypeRDN'),$baseToUse);
679 $mimedst = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('mimetypeRDN'),"ou=".$name.",".$baseToUse) ;
681 /* Check if source depeartments exist */
682 foreach(array($baseToUse,$appsrc,$mimesrc) as $dep){
683 $ldap->cd($this->config->current['BASE']);
684 $ldap->cat($dep);
685 if(!$ldap->count()){
686 $ldap->create_missing_trees($dep);
687 }
688 }
690 /* Print header to have styles included */
691 echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
692 <html>
693 <head>
694 <title></title>
695 <style type="text/css">@import url("themes/default/style.css");</style>
696 <script language="javascript" src="include/focus.js" type="text/javascript"></script>
697 </head>
698 <body style="background: none;margin:3px;color:black">
699 ';
701 new log("create","fai/".get_class($this),$NewReleaseName,array(),"New $type created");
703 /* Duplicate group application releases
704 */
705 FAI::copy_FAI_group_releases($CurrentReleases[$this->fai_release],$name,$type);
707 /* Duplicate applications
708 */
709 $ldap->cat($appsrc,array("dn")) ;
710 if($ldap->count()){
711 $ldap->cd ($appdst);
712 $ldap->recursive_remove();
713 FAI::copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true);
714 }
716 /* Duplicate mime types
717 */
718 $ldap->cat($mimesrc,array("dn")) ;
719 if($ldap->count()){
720 $ldap->cd ($mimedst);
721 $ldap->recursive_remove();
722 FAI::copy_FAI_resource_recursive($mimesrc,$mimedst,$NewReleaseName,$type,true);
723 }
725 $attr = array();
726 $attr['objectClass'] = array("organizationalUnit","FAIbranch");
727 $attr['ou'] = $name;
728 $attr['FAIstate'] = $type;
729 $ldap->cd($this->config->current['BASE']);
730 $ldap->cd("ou=".$name.",".$baseToUse);
731 $ldap->cat("ou=".$name.",".$baseToUse);
732 if($ldap->count()){
733 $ldap->modify($attr);
734 }else{
735 $ldap->add($attr);
736 }
738 /* Duplicate fai objects
739 */
740 // $ldap->cd ("ou=".$name.",".$baseToUse);
741 // $ldap->recursive_remove();
742 // FAI::copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,$NewReleaseName,$type,true);
744 echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
745 <br><input type='submit' name='CloseIFrame' value='"._("Continue")."'>
746 <input type='hidden' name='php_c_check' value='1'>
747 </form></div>";
749 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
751 /* Print footer to have valid html */
752 echo "</body></html>";
754 $this->dispNewFreeze = false;
756 /* Postcreate */
758 /* Assign possible attributes */
759 $this->lock_type = $type;
760 $this->lock_name = $name;
761 $this->lock_dn = $baseToUse;
762 $this->postcreate();
765 /* Send daemon event to reload the fai release database
766 */
767 if(class_available("DaemonEvent") && class_available("gosaSupportDaemon")){
768 $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
769 if(isset($events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'])){
770 $evt = $events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'];
771 $tmp = new $evt['CLASS_NAME']($this->config);
772 $tmp->set_type(TRIGGERED_EVENT);
773 $tmp->add_targets(array("GOSA"));
774 $o_queue = new gosaSupportDaemon();
775 if(!$o_queue->append($tmp)){
776 msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
777 }
778 }
779 }else{
780 trigger_error("Unknown class DaemonEvent / gosaSupportDaemon");
781 msg_dialog::display(_("Fatal error"),
782 "Daemon events called but classes where not accessible, DaemonEvent gosaSupportDaemon",
783 FATAL_ERROR_DIALOG);
784 }
785 exit();
786 }
787 }
789 /****************
790 Display dialog to enter new Branch name
791 ****************/
793 /* Check if we have a post create method configured
794 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
795 */
796 if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
797 if(($s_action == "branch_branch")||($this->dispNewBranch)){
798 if(!preg_match("/c/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
799 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
800 }else{
801 $this->dispNewBranch=true;
802 $smarty->assign("iframe",false);
803 $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
804 return($display);
805 }
806 }
807 }
810 /****************
811 Display dialog to enter new Freeze name
812 ****************/
814 /* Check if we have a post create method configured
815 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
816 */
817 if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
818 if(($s_action == "freeze_branch")||($this->dispNewFreeze)){
819 if(!preg_match("/c/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
820 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
821 }else{
822 $this->dispNewFreeze = true;
823 $smarty->assign("iframe",false);
824 $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
825 return($display);
826 }
827 }
828 }
831 /****************
832 Create a new object
833 ****************/
835 $types = array( "new_partition" => "FAIpartitionTable",
836 "new_script" => "FAIscript",
837 "new_hook" => "FAIhook",
838 "new_variable" => "FAIvariable",
839 "new_template" => "FAItemplate",
840 "new_package" => "FAIpackageList");
841 $types_i18n = array( "new_partition" => _("partition table"),
842 "new_script" => _("script"),
843 "new_hook" => _("hook"),
844 "new_variable" => _("variable"),
845 "new_template" => _("template"),
846 "new_package" => _("package list"));
848 if(isset($types[$s_action])){
850 $type_acl_mapping = array(
851 "FAIpartitionTable" => "faiPartitionTable",
852 "FAIpackageList" => "faiPackage",
853 "FAIscript" => "faiScript",
854 "FAIvariable" => "faiVariable",
855 "FAIhook" => "faiHook",
856 "FAIprofile" => "faiProfile",
857 "FAItemplate" => "faiTemplate");
859 $acl = $this->ui->get_permissions($this->acl_base,"fai/".$type_acl_mapping[$types[$s_action]]);
860 if(preg_match("/c/",$acl)){
861 $this->dialog = new askClassName($this->config,$this->dn,$this->ui,$types[$s_action]);
862 $this->dialog->parent = &$this;
863 }else{
864 msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), $types_i18n[$s_action]), ERROR_DIALOG);
865 }
866 }
868 /* New Profile */
869 if($s_action == "new_profile"){
870 $this->dn = "new" ;
872 $acl = $this->ui->get_permissions($this->acl_base,"fai/faiProfile");
873 if(preg_match("/c/",$acl)){
874 $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
875 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
876 $this->dialog->set_acl_base($this->base);
877 $this->dialog->parent = &$this;
879 $this->is_dialog = false;
880 }else{
881 msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), _("profile")), ERROR_DIALOG);
882 }
883 }
886 /****************
887 Get name from ask_class_name dialog
888 ****************/
890 if($s_action == "select_class_name_finished"){
891 $this->dialog->save_object();
892 if(count($this->dialog->check())!=0){
893 foreach($this->dialog->check() as $msg){
894 msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
895 }
896 }elseif(isset($this->dialog->objectClass)){
897 $this->dn = "new" ;
898 $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass)));
899 $name = $this->dialog->save();
901 if(class_exists($a_setup[0])){
902 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
903 $this->dialog->set_acl_base($this->base);
904 $this->dialog->by_object[$a_setup[1]]->cn = $name;
905 $this->dialog->parent = &$this;
906 $this->is_dialog = true;
907 }
908 }
909 }
912 /****************
913 Cancel dialogs
914 ****************/
916 if(isset($_POST['edit_cancel'])){
917 $this->dialog=FALSE;
918 $this->is_dialog = false;
919 session::un_set('objectinfo');
920 $this->remove_lock();
921 }
924 /****************
925 Handle opsi dialogs
926 ****************/
928 if($this->dialog instanceof tabs_opsiProdConfig && isset($_POST['cancel_properties'])){
929 $this->dialog = NULL;
930 }
931 if($this->dialog instanceof tabs_opsiProdConfig && isset($_POST['save_properties'])){
932 $this->dialog->save_object();
933 $op = $this->dialog->by_object['opsiProperties'];
934 $name = $op->get_product();
935 $cfg = $op->get_cfg();
936 $this->opsi->set_product_properties($name,$cfg);
937 if($this->opsi->is_error()){
938 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
939 }else{
940 $this->dialog = NULL;
941 }
942 }
943 if($this->dialog instanceof tabs_opsiProdConfig){
944 $this->dialog->save_object();
945 return($this->dialog->execute());
946 }
949 /****************
950 Save sub dialogs
951 ****************/
953 /* This check if the given tab could be saved
954 * If it was possible to save it, remove dialog object.
955 * If it wasn't possible, show errors and keep dialog.
956 */
957 if((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->dialog->config))){
958 $this->dialog->save_object();
959 $msgs= $this->dialog->check();
960 if(count($msgs)!=0){
961 foreach($msgs as $msg){
962 msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
963 }
964 }else{
965 $this->dialog->save();
966 FAI::save_release_changes_now();
967 if (!isset($_POST['edit_apply'])){
968 $this->remove_lock();
969 $this->dialog=FALSE;
970 $this->is_dialog=false;
971 session::un_set('objectinfo');
972 }else{
974 /* Reinitialize tab */
975 if($this->dialog instanceof tabs){
976 $this->dialog->re_init();
977 }
978 }
979 }
980 }
983 /****************
984 Display currently open dialog
985 ****************/
987 /* If dialog is set, but $this->is_dialog==false, then
988 * only the "abort" button is shown, this are dialogs that must not be saved.
989 * If is_dialog == true, we are currently editing tab objects.
990 * Here we need both, save and cancel
991 */
993 if(is_object($this->dialog)){
994 $display .= $this->dialog->execute();
995 /* Don't show buttons if tab dialog requests this */
997 if(isset($this->dialog->current)){
999 $obj = $this->dialog->by_object[$this->dialog->current];
1001 if(($this->dialog instanceOf tabs || $this->dialog instanceOf plugin) && $this->dialog->read_only == TRUE){
1002 $display.= "<p style=\"text-align:right\">
1003 <input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">
1004 </p>";
1005 }elseif((isset($obj->is_dialog) && (!$obj->is_dialog)) || (isset($obj->dialog) && (!$obj->dialog))){
1007 $display.= "<p style=\"text-align:right\">\n";
1008 if(!$this->no_save){
1009 $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
1010 $display.= " \n";
1011 if ($this->dn != "new"){
1012 $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
1013 $display.= " \n";
1014 }
1015 }
1016 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1017 $display.= "</p>";
1018 }elseif(!isset($this->dialog->current)){
1019 $display.= "<p style=\"text-align:right\">\n";
1020 $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\"> ";
1021 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1022 $display.= "</p>";
1023 }
1024 }else{
1025 $display.= "<p style=\"text-align:right\">\n";
1026 $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\"> ";
1027 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1028 $display.= "</p>";
1030 }
1031 return($display);
1032 }
1035 /****************
1036 Dialog display
1037 ****************/
1039 /* Check if there is a snapshot dialog open */
1040 $base = $this->fai_base;
1041 if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
1042 return($str);
1043 }
1045 /* Display dialog with system list */
1046 $this->reload();
1047 $this->DivListFai->parent = &$this;
1048 $this->DivListFai->execute();
1049 $this->DivListFai->setEntries($this->objects);
1050 return($this->DivListFai->Draw());
1051 }
1054 /* Return departments, that will be included within snapshot detection */
1055 function get_used_snapshot_bases()
1056 {
1057 $tmp = array();
1058 $types = array("faiPartitionRDN","faiScriptRDN","faiTemplateRDN","faiHookRDN","faiProfileRDN","faiVariableRDN","faiPackageRDN");
1059 foreach($types as $type){
1060 $tmp[] = get_ou($type).$this->fai_release;
1061 }
1062 return($tmp);
1063 }
1066 /* Get available branches for current base */
1067 function getBranches($base = false,$prefix = "")
1068 {
1069 $ret = array("/"=>$this->fai_base);
1070 $ldap = $this->config->get_ldap_link();
1071 if(!$base){
1072 $base = $this->fai_base;
1073 }
1074 $tmp = FAI::get_all_releases_from_base($base,true);
1075 foreach($tmp as $dn => $name){
1076 $ret[$name]=$dn;
1077 }
1078 ksort($ret);
1079 $ret = array_flip($ret);
1081 return ($ret);
1082 }
1085 function list_get_selected_items()
1086 {
1087 $ids = array();
1088 foreach($_POST as $name => $value){
1089 if(preg_match("/^item_selected_[0-9]*$/",$name)){
1090 $id = preg_replace("/^item_selected_/","",$name);
1091 $ids[$id] = $id;
1092 }
1093 }
1094 return($ids);
1095 }
1098 /* reload list of objects */
1099 function reload()
1100 {
1101 /* Variable initialisation */
1102 $str = "";
1103 $Regex = $this->DivListFai->Regex;
1104 $this->objects = array();
1106 /* Get base */
1107 $base = $this->fai_base;
1108 if($this->fai_release != $this->fai_base){
1109 $br = $this->getBranches();
1110 if(isset($br[$this->fai_release])){
1111 $base = $this->fai_release;
1112 }else{
1113 $base = $this->fai_base;
1114 }
1115 }
1116 $this->base = $base;
1117 $this->set_acl_base($this->acl_base);
1119 $this->lock_type = FAI::get_release_tag(FAI::get_release_dn($base));
1121 /* Create a new list of FAI object
1122 * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ...
1123 */
1124 $ObjectTypes = array(
1125 "FAIpartitionTable" => array("OU"=> get_ou('faiPartitionRDN') , "CHKBOX"=>"ShowPartitions" ,"ACL" => "faiPartitionTable"),
1126 "FAIpackageList" => array("OU"=> get_ou('faiPackageRDN') , "CHKBOX"=>"ShowPackages" ,"ACL" => "faiPackage"),
1127 "FAIscript" => array("OU"=> get_ou('faiScriptRDN') , "CHKBOX"=>"ShowScripts" ,"ACL" => "faiScript"),
1128 "FAIvariable" => array("OU"=> get_ou('faiVariableRDN') , "CHKBOX"=>"ShowVariables" ,"ACL" => "faiVariable"),
1129 "FAIhook" => array("OU"=> get_ou('faiHookRDN') , "CHKBOX"=>"ShowHooks" ,"ACL" => "faiHook"),
1130 "FAIprofile" => array("OU"=> get_ou('faiProfileRDN') , "CHKBOX"=>"ShowProfiles" ,"ACL" => "faiProfile"),
1131 "FAItemplate" => array("OU"=> get_ou('faiTemplateRDN') , "CHKBOX"=>"ShowTemplates" ,"ACL" => "faiTemplate"));
1133 $filter = "";
1134 foreach($ObjectTypes as $key => $data){
1135 if($this->DivListFai->$data['CHKBOX']){
1136 $filter.= "(objectClass=".$key.")";
1137 }
1138 }
1139 $filter = "(&(|".$filter.")(cn=$Regex))";
1141 /* Get resolved release dependencies */
1142 $tmp = FAI::get_all_objects_for_given_base($base,$filter);
1144 /* Ge listed ldap objects */
1145 $ldap = $this->config->get_ldap_link();
1146 $ldap->cd($this->config->current['BASE']);
1148 foreach($tmp as $entry){
1150 /* Get some more informations about the object */
1151 $ldap->cat($entry['dn'], array("cn","description","objectClass","FAIclass","FAIstate","objectClass"));
1152 $object = $ldap->fetch();
1154 /* Walk through possible types */
1155 foreach($ObjectTypes as $type => $rest){
1157 $acl = $this->ui->get_permissions($object['dn'],"fai/".$rest ['ACL']);
1159 if(in_array($type,$object['objectClass']) && preg_match("/r/",$acl)){
1161 /* Prepare object */
1162 unset($object['objectClass']['count']);
1163 if(!isset($object['description'][0])){
1164 $object['description'][0]="";
1165 }
1167 /* Clean up object informations */
1168 $obj = array();
1169 $obj['cn'] = $object['cn'][0];
1170 $obj['dn'] = $object['dn'];
1171 $obj['acl'] = $acl;
1172 $obj['class'] = $rest ['ACL'];
1173 $obj['FAIstate'] = $entry['FAIstate'];
1174 $obj['description'] = $object['description'][0];
1175 $obj['objectClass'] = $object['objectClass'];
1177 $this->objects[$obj['cn']][$type] = $obj;
1178 $this->objects[$obj['cn']][$type]['type']=$type;
1179 }
1180 }
1181 }
1183 /* Append opsi objects, if opsi is available and if we are on the fai_base
1184 */
1185 if($this->opsi instanceof opsi && $this->opsi->enabled()){
1186 $opsi_acl = $this->ui->get_permissions($base,"opsi/opsiProperties");
1187 if(preg_match("/r/",$opsi_acl)){
1188 $err = FALSE;
1189 if(!$err && $this->DivListFai->ShowOpsiNetboot){
1190 $n_pro = $this->opsi->get_netboot_products();
1191 $err |= $this->opsi->is_error();
1192 foreach($n_pro as $name => $data){
1193 $entry = array(
1194 "cn" => $name,
1195 "description" => $data['DESC'],
1196 "type" => "opsi_netboot");
1197 $this->objects[$name]['opsi_netboot'] = $entry;
1198 }
1199 }
1200 if(!$err && $this->DivListFai->ShowOpsiLocal){
1201 $l_pro = $this->opsi->get_local_products();
1202 $err |= $this->opsi->is_error();
1203 foreach($l_pro as $name => $data){
1204 $entry = array("cn" => $name,
1205 "description" => $data['DESC'],
1206 "type" => "opsi_local");
1207 $this->objects[$name]["opsi_local"] = $entry;
1208 }
1209 }
1210 if($err){
1211 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
1212 }
1213 }
1214 }
1216 uksort($this->objects, 'strnatcasecmp');
1217 reset ($this->objects);
1218 $this->objects = array_values($this->objects);
1219 }
1221 function remove_lock()
1222 {
1223 if (isset($this->dn)){
1224 del_lock ($this->dn);
1225 }
1226 if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
1227 del_lock ($this->dns);
1228 }
1229 }
1231 function get_type($array){
1232 if(!isset($array['objectClass'])) return(array());
1233 if(in_array("FAIpartitionTable",$array['objectClass'])){
1234 return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS"));
1235 }
1236 if(in_array("FAIscript",$array['objectClass'])){
1237 return(array("tabsScript","faiScript","FAISCRIPTTABS"));
1238 }
1239 if(in_array("FAItemplate",$array['objectClass'])){
1240 return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS"));
1241 }
1242 if(in_array("FAIhook",$array['objectClass'])){
1243 return(array("tabsHook","faiHook","FAIHOOKTABS"));
1244 }
1245 if(in_array("FAIvariable",$array['objectClass'])){
1246 return(array("tabsVariable","faiVariable","FAIVARIABLETABS"));
1247 }
1248 if(in_array("FAIprofile",$array['objectClass'])){
1249 return(array("tabsProfile","faiProfile","FAIPROFILETABS"));
1250 }
1252 if(in_array("FAIpackageList",$array['objectClass'])){
1253 return(array("tabsPackage","faiPackage","FAIPACKAGETABS"));
1254 }
1255 return(array());
1256 }
1258 function CheckNewBranchName($name,$base)
1259 {
1260 $f = $this->fai_release;
1261 if($name == ""){
1262 return(false);
1263 }elseif(in_array($name,$this->getBranches($f))) {
1264 return(false);
1265 }elseif(tests::is_department_name_reserved($name,$base)){
1266 return(false);
1267 }
1268 return(true);
1269 }
1271 function save_object()
1272 {
1273 $this->DivListFai->save_object();
1275 /* Get posted release */
1276 $r_releases = array_flip($this->getBranches());
1277 if(isset($_POST['fai_release']) && isset($r_releases[get_post('fai_release')])){
1279 /* Ensure that we have a valid release selected */
1280 if(!isset($r_releases[get_post('fai_release')])){
1281 msg_dialog::display(_("Warning"),_("The selected release is not available anymore. All triggered actions are skipped."));
1282 $_POST = array();
1283 $plug =$_GET['plug'];
1284 $_GET = array("plug" => $plug);
1285 $this->fai_release = $this->fai_base;
1286 }else{
1287 $this->fai_release = $r_releases[get_post('fai_release')];
1288 }
1290 $fai_filter = session::get("fai_filter");
1291 $fai_filter['fai_release'] = $this->fai_release;
1292 session::set("fai_filter",$fai_filter);
1293 }
1295 if(is_object($this->CopyPasteHandler)){
1296 $this->CopyPasteHandler->save_object();
1297 }
1298 }
1301 function copyPasteHandling_from_queue($s_action,$s_entry)
1302 {
1303 /* Check if Copy & Paste is disabled */
1304 if(!is_object($this->CopyPasteHandler)){
1305 return("");
1306 }
1308 $ui = get_userinfo();
1310 /* Add a single entry to queue */
1311 if($this->dialog instanceOf faiGroupHandle && !$this->dialog->is_open()){
1313 if(in_array($this->dialog->get_mode(),array("copy"))){
1315 /* Cleanup object queue */
1316 $this->CopyPasteHandler->cleanup_queue();
1317 $group = $this->dialog->get_selected();
1318 foreach($group as $entry){
1319 $a_setup = $this->get_type($entry);
1320 $dn = $entry['dn'];
1321 if($ui->is_copyable($dn,"fai",$a_setup[1])){
1322 $this->CopyPasteHandler->add_to_queue($dn,$this->dialog->get_mode(),$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1323 }
1324 }
1325 $this->dialog = FALSE;
1326 }
1327 }
1329 /* Add entries to queue */
1330 if($s_action == "copy_multiple"){
1332 /* Cleanup object queue */
1333 $this->CopyPasteHandler->cleanup_queue();
1335 /* Add new entries to CP queue */
1336 foreach($this->list_get_selected_items() as $id){
1337 $group = $this->objects[$id];
1338 foreach($group as $entry){
1339 $a_setup = $this->get_type($entry);
1340 $dn = $entry['dn'];
1342 if($s_action == "copy_multiple" && $ui->is_copyable($dn,"fai",$a_setup[1])){
1343 $this->CopyPasteHandler->add_to_queue($dn,"copy",$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1344 }
1345 }
1346 }
1347 }
1349 /* Start pasting entries */
1350 if($s_action == "editPaste" && !($this->lock_type == "freeze" && !$this->allow_freeze_object_attach)){
1351 $this->start_pasting_copied_objects = TRUE;
1352 }
1354 /* Return C&P dialog */
1355 if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
1357 /* Get dialog */
1358 $this->CopyPasteHandler->SetVar("parent",$this);
1359 $data = $this->CopyPasteHandler->execute();
1361 FAI::save_release_changes_now();
1363 /* Return dialog data */
1364 if(!empty($data)){
1365 return($data);
1366 }
1367 }
1369 /* Automatically disable status for pasting */
1370 if(!$this->CopyPasteHandler->entries_queued()){
1371 $this->start_pasting_copied_objects = FALSE;
1372 }
1373 return("");
1374 }
1377 /* Check if the given FAI class is used in this release
1378 */
1379 static function check_class_name($oc,$name,$dn)
1380 {
1381 $base = FAI::get_release_dn($dn);
1383 if($oc == "FAIprofile"){
1384 $f = "";
1385 $ocs = array("FAIprofile","FAItemplate","FAIhook","FAIpartitionTable","FAIpackageList","FAIscript","FAIvariable");
1386 foreach($ocs as $oc){
1387 $f .= "(objectClass=".$oc.")";
1388 }
1389 $res = FAI::get_all_objects_for_given_base($base,"(|".$f.")",TRUE);
1390 }else{
1391 $res = FAI::get_all_objects_for_given_base($base,"(objectClass=".$oc.")",TRUE);
1392 }
1393 $delete = array();
1394 $used = array();
1395 foreach($res as $object){
1396 $used[$object['cn'][0]]= $object['cn'][0];
1397 }
1398 return($used);
1399 }
1402 /* Return plugin informations for acl handling */
1403 static function plInfo()
1404 {
1405 return (array(
1406 "plShortName" => _("FAI releases"),
1407 "plDescription" => _("FAI release management"),
1408 "plSelfModify" => FALSE,
1409 "plDepends" => array(),
1410 "plPriority" => 0,
1411 "plSection" => array("administration"),
1412 "plCategory" => array("fai"=> array("description" => _("FAI"),
1413 "objectClass" => "FAIclass")),
1414 "plProvidedAcls"=> array()));
1415 }
1416 }
1417 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1418 ?>