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