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 foreach($this->objects[$id] as $obj) {
369 array_push($to_delete, $obj);
370 }
371 }
372 }
374 foreach($to_delete as $obj){
375 if(isset($obj['type']) && in_array($obj['type'],array("opsi_netboot","opsi_local"))){
376 continue;
377 }
378 if(isset($obj['FAIstate']) && preg_match('/^freeze/', $obj['FAIstate'])){
379 $errors .= $obj['cn'].", ";
380 }else{
381 $this->dns[] = $obj['dn'];
382 }
383 }
385 if($errors != ""){
386 msg_dialog::display(_("Branch locked"),sprintf(_("The following entries are locked, you can't remove them %s."),
387 "<br><br>".trim($errors,", ")),INFO_DIALOG);
388 }
390 /* Check locking
391 */
392 if(count($this->dns)){
393 if ($user= get_multiple_locks($this->dns)){
394 return(gen_locked_message($user,$this->dns));
395 }
396 if(count($this->dns)){
397 $dns_names = array();
398 foreach($this->dns as $dn){
399 add_lock ($dn, $this->ui->dn);
400 $dns_names[] = LDAP::fix($dn);
401 }
402 $smarty->assign("warning",msgPool::deleteInfo($dns_names,_("FAI object")));
403 $smarty->assign("multiple", true);
404 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
405 }
406 }
407 }
411 /********************
412 Delete MULTIPLE entries Canceled
413 ********************/
415 /* Remove lock */
416 if(isset($_POST['delete_multiple_fai_object_cancel'])){
417 $this->remove_lock();
418 $this->dns = array();
419 }
421 /****************
422 Edit entry
423 ****************/
425 if($s_action == "edit" || $this->dialog instanceOf faiGroupHandle && $this->dialog->get_mode() == "edit"){
427 $entry = array();
428 if($this->dialog instanceOf faiGroupHandle){
429 $entries = $this->dialog->get_selected();
430 $entry = array_pop($entries);
431 }elseif(isset($this->objects[$i_entryID][$s_entryType])){
432 $entry = $this->objects[$i_entryID][$s_entryType];
433 }
435 if(count($entry)){
436 $a_setup = $this->get_type($entry);
438 /* Special handling for opsi products
439 */
441 if(in_array($entry['type'],array("opsi_local","opsi_netboot")) &&
442 $this->opsi instanceof opsi && $this->opsi->enabled() ){
444 $name = $entry['cn'];
445 $cfg = $this->opsi->get_product_properties($name);
446 $this->dialog = new tabs_opsiProdConfig($this->config, $this->config->data['TABS']['OPSIPRODCONFIG'],"","opsi");
447 if(isset($this->dialog->by_object['opsiProperties'])){
448 $this->dialog->by_object['opsiProperties']->set_cfg($cfg);
449 $this->dialog->by_object['opsiProperties']->set_product($name);
450 }else{
451 trigger_error("Unknown tab, please check config.");
452 }
453 }elseif(count($a_setup)){
455 $this->dn = $entry['dn'];
456 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
457 if (($user= get_lock($this->dn)) != ""){
458 return(gen_locked_message ($user, $this->dn, TRUE));
459 }
460 add_lock ($this->dn, $this->ui->dn);
462 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
463 $this->dialog->parent = &$this;
464 $this->dialog->by_object[$a_setup[1]]->FAIstate = $entry['FAIstate'];
465 $this->dialog->set_acl_base($this->dn);
466 $this->is_dialog = true;
467 set_object_info($this->dn);
468 }
469 }
470 }
473 /* Branch handling
474 09.01.2006
475 */
477 /****************
478 Remove branch
479 ****************/
481 /* Remove branch
482 */
483 if($s_action == "remove_branch"){
484 $base= $this->fai_release;
486 /* Check if we have a post remove method configured
487 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
488 */
489 if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
490 /* Load permissions for selected 'dn' and check if
491 we're allowed to remove this 'dn' */
492 if(preg_match("/d/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
493 $smarty->assign("release_hidden",base64_encode($this->fai_release));
494 $smarty->assign("info", msgPool::deleteInfo(LDAP::fix($this->fai_release),_("FAI branch/freeze")));
495 return($smarty->fetch(get_template_path('remove_branch.tpl',TRUE)));
496 } else {
497 msg_dialog::display(_("Permission error"), _("You have no permission to delete this release!"), ERROR_DIALOG);
498 }
499 }
500 }
503 /****************
504 Remove branch confirmed
505 ****************/
507 if(isset($_POST['delete_branch_confirm'])){
509 /* Check if we have a post remove method configured
510 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
511 */
512 if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
514 if(!isset($_POST['release_hidden']) || base64_decode($_POST['release_hidden']) != $this->fai_release){
515 msg_dialog::display(_("Warning"),_("Release remove aborted because the release name check failed!"));
516 }else{
518 $bb = $this->fai_release;
519 if(!isset($ldap)){
520 $ldap = $this->config->get_ldap_link();
521 }
523 $br = $this->getBranches();
525 if(isset($br[$bb]) && preg_match("/d/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
526 $name = $br[$bb];
528 $ldap->cd($bb);
529 $ldap->recursive_remove();
530 $ldap->cd(preg_replace('/,'.preg_quote(get_ou('faiBaseRDN'), '/').'/', ','.get_ou('applicationRDN'), $bb));
531 $ldap->recursive_remove();
532 $ldap->cd(preg_replace('/,'.preg_quote(get_ou('faiBaseRDN'), '/').'/', ','.get_ou('mimetypeRDN'), $bb));
533 $ldap->recursive_remove();
535 /* Search for all groups with configured application menus.
536 - First search all groups, to ensure that we only remove entries form whithin groups.
537 - The search für menu configuration for the specified release and collect all those dns.
538 - Remove entries
539 */
540 $release_ou = preg_replace("/".preg_quote(get_ou("faiBaseRDN"), '/').".*$/","",$bb);
541 $ldap->cd($this->config->current['BASE']);
542 $ldap->search("(objectClass=posixGroup)",array("dn"));
544 /* Collect all group dns
545 */
546 $groups = array();
547 while($attrs = $ldap->fetch()){
548 $groups[] = $attrs['dn'];
549 }
551 /* Collect all group menu release dns that match the release we have removed
552 */
553 $dns = array();
554 foreach($groups as $dn){
555 $ldap->cd($dn);
556 $ldap->search("(objectClass=FAIbranch)",array("dn"));
557 while($attrs = $ldap->fetch()){
558 if(preg_match("/^".preg_quote($release_ou, '/')."/",$attrs['dn'])){
559 $dns[] = $attrs['dn'];
560 }
561 }
562 }
564 /* Finally remove collected release dns
565 */
566 foreach($dns as $dn){
567 $ldap->cd($dn);
568 $ldap->recursive_remove();
569 }
571 /* Post remove */
572 $this->fai_release = $this->fai_base;
573 $this->lock_name = $name;
574 $this->lock_dn = $bb;
575 $this->postremove();
577 $fai_filter = session::get("fai_filter");
578 $fai_filter['fai_release'] = $this->fai_release;
579 session::set("fai_filter",$fai_filter);
581 new log("remove","fai/".get_class($this),$br[$bb],array(),"Release removed");
582 }
583 }
584 }
585 }
588 /****************
589 Create a new branch "insert Name"
590 ****************/
592 if((isset($_POST['UseBranchName']))&&(($this->dispNewBranch)||($this->dispNewFreeze))){
593 session::set('LASTPOST',$_POST);
595 if($this->dispNewBranch){
596 $type = "branch";
597 }else{
598 $type = "freeze";
599 }
601 /* Check branch name */
602 $name = $_POST['BranchName'];
603 $is_ok = true;
604 $smarty->assign("BranchName",$name);
605 $base= $this->fai_base;
607 /* Check used characters */
608 if(!preg_match("/^[0-9a-z\.]*$/",$name)){
609 msg_dialog::display(_("Error"), msgPool::invalid(_("Name"),$name,"/[0-9a-z\.]/"), ERROR_DIALOG);
610 $is_ok = false;
611 }
613 /* Check if this name is already in use */
614 if(!$this->CheckNewBranchName($_POST['BranchName'],$this->fai_release)){
615 msg_dialog::display(_("Error"), msgPool::duplicated(_("Name")), ERROR_DIALOG);
616 $is_ok = false;
617 }
619 if($is_ok){
621 if(session::is_set('LASTPOST')){
622 $LASTPOST = session::get('LASTPOST');
623 }else{
624 $LASTPOST = array();
625 }
626 $LASTPOST['base'] = $base;
627 $LASTPOST['type'] = $type;
628 session::set('LASTPOST',$LASTPOST);
629 $smarty->assign("iframe", true);
630 $smarty->assign("plugID", $_GET['plug']);
631 $display = $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
632 return($display);
633 }
634 }
637 /****************
638 Create a new branch
639 ****************/
641 if(isset($_GET['PerformBranch'])){
643 if(!preg_match("/c/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
644 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
645 }else{
647 /* In order to see error messages we have to reset the error handler.
648 Due to the exit();
649 */
650 restore_error_handler();
652 /* Create it know */
653 $this->dispNewBranch = false;
654 $this->dispNewFreeze = false;
656 $LASTPOST = session::get('LASTPOST');
657 $base = $LASTPOST['base'];
658 $_POST = session::get('LASTPOST');
659 $name = $_POST['BranchName'];
661 $type = $LASTPOST['type'];
662 $ldap = $this->config->get_ldap_link();
664 $baseToUse = $base;
665 if($this->fai_release != $this->fai_base){
666 $baseToUse = $this->fai_release;
667 }
669 /* Create new Release name to be able to set faidebianRelease for FAIpackageList */
671 $CurrentReleases = $this->getBranches();
672 $NewReleaseName = $name;
673 if(isset($CurrentReleases[$this->fai_release])) {
674 if($this->fai_release != $this->fai_base){
675 $NewReleaseName = $CurrentReleases[$this->fai_release]."/".$name;
676 $NewReleaseName = preg_replace("#\/#","/",$NewReleaseName);
677 }else{
678 $NewReleaseName = $name;
679 }
680 }
682 $appsrc = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('applicationRDN'),$baseToUse);
683 $appdst = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('applicationRDN'),"ou=".$name.",".$baseToUse) ;
685 $mimesrc = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('mimetypeRDN'),$baseToUse);
686 $mimedst = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('mimetypeRDN'),"ou=".$name.",".$baseToUse) ;
688 /* Check if source depeartments exist */
689 foreach(array($baseToUse,$appsrc,$mimesrc) as $dep){
690 $ldap->cd($this->config->current['BASE']);
691 $ldap->cat($dep);
692 if(!$ldap->count()){
693 $ldap->create_missing_trees($dep);
694 }
695 }
697 /* Print header to have styles included */
698 echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
699 <html>
700 <head>
701 <title></title>
702 <style type="text/css">@import url("themes/default/style.css");</style>
703 <script language="javascript" src="include/focus.js" type="text/javascript"></script>
704 </head>
705 <body style="background: none;margin:3px;color:black">
706 ';
708 new log("create","fai/".get_class($this),$NewReleaseName,array(),"New $type created");
710 /* Duplicate group application releases
711 */
712 FAI::copy_FAI_group_releases($CurrentReleases[$this->fai_release],$name,$type);
714 /* Duplicate applications
715 */
716 $ldap->cat($appsrc,array("dn")) ;
717 if($ldap->count()){
718 $ldap->cd ($appdst);
719 $ldap->recursive_remove();
720 FAI::copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true);
721 }
723 /* Duplicate mime types
724 */
725 $ldap->cat($mimesrc,array("dn")) ;
726 if($ldap->count()){
727 $ldap->cd ($mimedst);
728 $ldap->recursive_remove();
729 FAI::copy_FAI_resource_recursive($mimesrc,$mimedst,$NewReleaseName,$type,true);
730 }
732 $attr = array();
733 $attr['objectClass'] = array("organizationalUnit","FAIbranch");
734 $attr['ou'] = $name;
735 $attr['FAIstate'] = $type;
736 $ldap->cd($this->config->current['BASE']);
737 $ldap->cd("ou=".$name.",".$baseToUse);
738 $ldap->cat("ou=".$name.",".$baseToUse);
739 if($ldap->count()){
740 $ldap->modify($attr);
741 }else{
742 $ldap->add($attr);
743 }
745 /* Duplicate fai objects
746 */
747 // $ldap->cd ("ou=".$name.",".$baseToUse);
748 // $ldap->recursive_remove();
749 // FAI::copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,$NewReleaseName,$type,true);
751 echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
752 <br><input type='submit' name='CloseIFrame' value='"._("Continue")."'>
753 <input type='hidden' name='php_c_check' value='1'>
754 </form></div>";
756 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
758 /* Print footer to have valid html */
759 echo "</body></html>";
761 $this->dispNewFreeze = false;
763 /* Postcreate */
765 /* Assign possible attributes */
766 $this->lock_type = $type;
767 $this->lock_name = $name;
768 $this->lock_dn = $baseToUse;
769 $this->postcreate();
772 /* Send daemon event to reload the fai release database
773 */
774 if(class_available("DaemonEvent") && class_available("gosaSupportDaemon")){
775 $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
776 if(isset($events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'])){
777 $evt = $events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'];
778 $tmp = new $evt['CLASS_NAME']($this->config);
779 $tmp->set_type(TRIGGERED_EVENT);
780 $tmp->add_targets(array("GOSA"));
781 $o_queue = new gosaSupportDaemon();
782 if(!$o_queue->append($tmp)){
783 msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
784 }
785 }
786 }else{
787 trigger_error("Unknown class DaemonEvent / gosaSupportDaemon");
788 msg_dialog::display(_("Fatal error"),
789 "Daemon events called but classes where not accessible, DaemonEvent gosaSupportDaemon",
790 FATAL_ERROR_DIALOG);
791 }
792 exit();
793 }
794 }
796 /****************
797 Display dialog to enter new Branch 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 == "branch_branch")||($this->dispNewBranch)){
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->dispNewBranch=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 Display dialog to enter new Freeze name
819 ****************/
821 /* Check if we have a post create method configured
822 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
823 */
824 if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
825 if(($s_action == "freeze_branch")||($this->dispNewFreeze)){
826 if(!preg_match("/c/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
827 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
828 }else{
829 $this->dispNewFreeze = true;
830 $smarty->assign("iframe",false);
831 $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
832 return($display);
833 }
834 }
835 }
838 /****************
839 Create a new object
840 ****************/
842 $types = array( "new_partition" => "FAIpartitionTable",
843 "new_script" => "FAIscript",
844 "new_hook" => "FAIhook",
845 "new_variable" => "FAIvariable",
846 "new_template" => "FAItemplate",
847 "new_package" => "FAIpackageList");
848 $types_i18n = array( "new_partition" => _("partition table"),
849 "new_script" => _("script"),
850 "new_hook" => _("hook"),
851 "new_variable" => _("variable"),
852 "new_template" => _("template"),
853 "new_package" => _("package list"));
855 if(isset($types[$s_action])){
857 $type_acl_mapping = array(
858 "FAIpartitionTable" => "faiPartitionTable",
859 "FAIpackageList" => "faiPackage",
860 "FAIscript" => "faiScript",
861 "FAIvariable" => "faiVariable",
862 "FAIhook" => "faiHook",
863 "FAIprofile" => "faiProfile",
864 "FAItemplate" => "faiTemplate");
866 $acl = $this->ui->get_permissions($this->acl_base,"fai/".$type_acl_mapping[$types[$s_action]]);
867 if(preg_match("/c/",$acl)){
868 $this->dialog = new askClassName($this->config,$this->dn,$this->ui,$types[$s_action]);
869 $this->dialog->parent = &$this;
870 }else{
871 msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), $types_i18n[$s_action]), ERROR_DIALOG);
872 }
873 }
875 /* New Profile */
876 if($s_action == "new_profile"){
877 $this->dn = "new" ;
879 $acl = $this->ui->get_permissions($this->acl_base,"fai/faiProfile");
880 if(preg_match("/c/",$acl)){
881 $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
882 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
883 $this->dialog->set_acl_base($this->acl_base);
884 $this->dialog->parent = &$this;
886 $this->is_dialog = false;
887 }else{
888 msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), _("profile")), ERROR_DIALOG);
889 }
890 }
893 /****************
894 Get name from ask_class_name dialog
895 ****************/
897 if($s_action == "select_class_name_finished"){
898 $this->dialog->save_object();
899 if(count($this->dialog->check())!=0){
900 foreach($this->dialog->check() as $msg){
901 msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
902 }
903 }elseif(isset($this->dialog->objectClass)){
904 $this->dn = "new" ;
905 $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass)));
906 $name = $this->dialog->save();
908 if(class_exists($a_setup[0])){
909 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
910 $this->dialog->set_acl_base($this->acl_base);
911 $this->dialog->by_object[$a_setup[1]]->cn = $name;
912 $this->dialog->parent = &$this;
913 $this->is_dialog = true;
914 }
915 }
916 }
919 /****************
920 Cancel dialogs
921 ****************/
923 if(isset($_POST['edit_cancel'])){
924 $this->dialog=FALSE;
925 $this->is_dialog = false;
926 set_object_info();
927 $this->remove_lock();
928 }
931 /****************
932 Handle opsi dialogs
933 ****************/
935 if($this->dialog instanceof tabs_opsiProdConfig && isset($_POST['cancel_properties'])){
936 $this->dialog = NULL;
937 }
938 if($this->dialog instanceof tabs_opsiProdConfig && isset($_POST['save_properties'])){
939 $this->dialog->save_object();
940 $op = $this->dialog->by_object['opsiProperties'];
941 $name = $op->get_product();
942 $cfg = $op->get_cfg();
943 $this->opsi->set_product_properties($name,$cfg);
944 if($this->opsi->is_error()){
945 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
946 }else{
947 $this->dialog = NULL;
948 }
949 }
950 if($this->dialog instanceof tabs_opsiProdConfig){
951 $this->dialog->save_object();
952 return($this->dialog->execute());
953 }
956 /****************
957 Save sub dialogs
958 ****************/
960 /* This check if the given tab could be saved
961 * If it was possible to save it, remove dialog object.
962 * If it wasn't possible, show errors and keep dialog.
963 */
964 if((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->dialog->config))){
965 $this->dialog->save_object();
966 $msgs= $this->dialog->check();
967 if(count($msgs)!=0){
968 foreach($msgs as $msg){
969 msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
970 }
971 }else{
972 $this->dialog->save();
973 FAI::save_release_changes_now();
974 if (!isset($_POST['edit_apply'])){
975 $this->remove_lock();
976 $this->dialog=FALSE;
977 $this->is_dialog=false;
978 set_object_info();
979 }else{
981 /* Reinitialize tab */
982 if($this->dialog instanceof tabs){
983 $this->dialog->re_init();
984 }
985 }
986 }
987 }
990 /****************
991 Display currently open dialog
992 ****************/
994 /* If dialog is set, but $this->is_dialog==false, then
995 * only the "abort" button is shown, this are dialogs that must not be saved.
996 * If is_dialog == true, we are currently editing tab objects.
997 * Here we need both, save and cancel
998 */
1000 if(is_object($this->dialog)){
1001 $display .= $this->dialog->execute();
1002 /* Don't show buttons if tab dialog requests this */
1004 if(isset($this->dialog->current)){
1006 $obj = $this->dialog->by_object[$this->dialog->current];
1008 if(($this->dialog instanceOf tabs || $this->dialog instanceOf plugin) && $this->dialog->read_only == TRUE){
1009 $display.= "<p style=\"text-align:right\">
1010 <input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">
1011 </p>";
1012 }elseif((isset($obj->is_dialog) && (!$obj->is_dialog)) || (isset($obj->dialog) && (!$obj->dialog))){
1014 $display.= "<p style=\"text-align:right\">\n";
1015 if(!$this->no_save){
1016 $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
1017 $display.= " \n";
1018 if ($this->dn != "new"){
1019 $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
1020 $display.= " \n";
1021 }
1022 }
1023 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1024 $display.= "</p>";
1025 }elseif(!isset($this->dialog->current)){
1026 $display.= "<p style=\"text-align:right\">\n";
1027 $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\"> ";
1028 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1029 $display.= "</p>";
1030 }
1031 }else{
1032 $display.= "<p style=\"text-align:right\">\n";
1033 $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\"> ";
1034 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1035 $display.= "</p>";
1037 }
1038 return($display);
1039 }
1042 /****************
1043 Dialog display
1044 ****************/
1046 /* Check if there is a snapshot dialog open */
1047 $base = $this->fai_base;
1048 if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
1049 return($str);
1050 }
1052 /* Display dialog with system list */
1053 $this->reload();
1054 $this->DivListFai->parent = &$this;
1055 $this->DivListFai->execute();
1056 $this->DivListFai->setEntries($this->objects);
1057 return($this->DivListFai->Draw());
1058 }
1061 /* Return departments, that will be included within snapshot detection */
1062 function get_used_snapshot_bases()
1063 {
1064 $tmp = array();
1065 $types = array("faiPartitionRDN","faiScriptRDN","faiTemplateRDN","faiHookRDN","faiProfileRDN","faiVariableRDN","faiPackageRDN");
1066 foreach($types as $type){
1067 $tmp[] = get_ou($type).$this->fai_release;
1068 }
1069 return($tmp);
1070 }
1073 /* Get available branches for current base */
1074 function getBranches($base = false,$prefix = "")
1075 {
1076 $ret = array("/"=>$this->fai_base);
1077 $ldap = $this->config->get_ldap_link();
1078 if(!$base){
1079 $base = $this->fai_base;
1080 }
1081 $tmp = FAI::get_all_releases_from_base($base,true);
1082 foreach($tmp as $dn => $name){
1083 $ret[$name]=$dn;
1084 }
1085 ksort($ret);
1086 $ret = array_flip($ret);
1088 return ($ret);
1089 }
1092 function list_get_selected_items()
1093 {
1094 $ids = array();
1095 foreach($_POST as $name => $value){
1096 if(preg_match("/^item_selected_[0-9]*$/",$name)){
1097 $id = preg_replace("/^item_selected_/","",$name);
1098 $ids[$id] = $id;
1099 }
1100 }
1101 return($ids);
1102 }
1105 /* reload list of objects */
1106 function reload()
1107 {
1108 /* Variable initialisation */
1109 $str = "";
1110 $Regex = $this->DivListFai->Regex;
1111 $this->objects = array();
1113 /* Get base */
1114 $base = $this->fai_base;
1115 if($this->fai_release != $this->fai_base){
1116 $br = $this->getBranches();
1117 if(isset($br[$this->fai_release])){
1118 $base = $this->fai_release;
1119 }else{
1120 $base = $this->fai_base;
1121 }
1122 }
1123 $this->base = $base;
1124 $this->set_acl_base($this->acl_base);
1126 $this->lock_type = FAI::get_release_tag(FAI::get_release_dn($base));
1128 /* Create a new list of FAI object
1129 * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ...
1130 */
1131 $ObjectTypes = array(
1132 "FAIpartitionTable" => array("OU"=> get_ou('faiPartitionRDN') , "CHKBOX"=>"ShowPartitions" ,"ACL" => "faiPartitionTable"),
1133 "FAIpackageList" => array("OU"=> get_ou('faiPackageRDN') , "CHKBOX"=>"ShowPackages" ,"ACL" => "faiPackage"),
1134 "FAIscript" => array("OU"=> get_ou('faiScriptRDN') , "CHKBOX"=>"ShowScripts" ,"ACL" => "faiScript"),
1135 "FAIvariable" => array("OU"=> get_ou('faiVariableRDN') , "CHKBOX"=>"ShowVariables" ,"ACL" => "faiVariable"),
1136 "FAIhook" => array("OU"=> get_ou('faiHookRDN') , "CHKBOX"=>"ShowHooks" ,"ACL" => "faiHook"),
1137 "FAIprofile" => array("OU"=> get_ou('faiProfileRDN') , "CHKBOX"=>"ShowProfiles" ,"ACL" => "faiProfile"),
1138 "FAItemplate" => array("OU"=> get_ou('faiTemplateRDN') , "CHKBOX"=>"ShowTemplates" ,"ACL" => "faiTemplate"));
1140 $filter = "";
1141 foreach($ObjectTypes as $key => $data){
1142 if($this->DivListFai->$data['CHKBOX']){
1143 $filter.= "(objectClass=".$key.")";
1144 }
1145 }
1146 $filter = "(&(|".$filter.")(cn=$Regex))";
1148 /* Get resolved release dependencies */
1149 $tmp = FAI::get_all_objects_for_given_base($base,$filter);
1151 /* Ge listed ldap objects */
1152 $ldap = $this->config->get_ldap_link();
1153 $ldap->cd($this->config->current['BASE']);
1155 foreach($tmp as $entry){
1157 /* Get some more informations about the object */
1158 $ldap->cat($entry['dn'], array("cn","description","objectClass","FAIclass","FAIstate","objectClass"));
1159 $object = $ldap->fetch();
1161 /* Walk through possible types */
1162 foreach($ObjectTypes as $type => $rest){
1164 $acl = $this->ui->get_permissions($object['dn'],"fai/".$rest ['ACL']);
1166 if(in_array($type,$object['objectClass']) && preg_match("/r/",$acl)){
1168 /* Prepare object */
1169 unset($object['objectClass']['count']);
1170 if(!isset($object['description'][0])){
1171 $object['description'][0]="";
1172 }
1174 /* Clean up object informations */
1175 $obj = array();
1176 $obj['cn'] = $object['cn'][0];
1177 $obj['dn'] = $object['dn'];
1178 $obj['acl'] = $acl;
1179 $obj['class'] = $rest ['ACL'];
1180 $obj['FAIstate'] = $entry['FAIstate'];
1181 $obj['description'] = $object['description'][0];
1182 $obj['objectClass'] = $object['objectClass'];
1184 $this->objects[$obj['cn']][$type] = $obj;
1185 $this->objects[$obj['cn']][$type]['type']=$type;
1186 }
1187 }
1188 }
1190 /* Append opsi objects, if opsi is available and if we are on the fai_base
1191 */
1192 if($this->opsi instanceof opsi && $this->opsi->enabled()){
1193 $opsi_acl = $this->ui->get_permissions($base,"opsi/opsiProperties");
1194 if(preg_match("/r/",$opsi_acl)){
1195 $err = FALSE;
1196 if(!$err && $this->DivListFai->ShowOpsiNetboot){
1197 $n_pro = $this->opsi->get_netboot_products();
1198 $err |= $this->opsi->is_error();
1199 foreach($n_pro as $name => $data){
1200 $entry = array(
1201 "cn" => $name,
1202 "description" => $data['DESC'],
1203 "type" => "opsi_netboot");
1204 $this->objects[$name]['opsi_netboot'] = $entry;
1205 }
1206 }
1207 if(!$err && $this->DivListFai->ShowOpsiLocal){
1208 $l_pro = $this->opsi->get_local_products();
1209 $err |= $this->opsi->is_error();
1210 foreach($l_pro as $name => $data){
1211 $entry = array("cn" => $name,
1212 "description" => $data['DESC'],
1213 "type" => "opsi_local");
1214 $this->objects[$name]["opsi_local"] = $entry;
1215 }
1216 }
1217 if($err){
1218 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
1219 }
1220 }
1221 }
1223 uksort($this->objects, 'strnatcasecmp');
1224 reset ($this->objects);
1225 $this->objects = array_values($this->objects);
1226 }
1228 function remove_lock()
1229 {
1230 if (isset($this->dn) && !empty($this->dn)){
1231 del_lock ($this->dn);
1232 }
1233 if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
1234 del_lock ($this->dns);
1235 }
1236 }
1238 function get_type($array){
1239 if(!isset($array['objectClass'])) return(array());
1240 if(in_array("FAIpartitionTable",$array['objectClass'])){
1241 return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS"));
1242 }
1243 if(in_array("FAIscript",$array['objectClass'])){
1244 return(array("tabsScript","faiScript","FAISCRIPTTABS"));
1245 }
1246 if(in_array("FAItemplate",$array['objectClass'])){
1247 return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS"));
1248 }
1249 if(in_array("FAIhook",$array['objectClass'])){
1250 return(array("tabsHook","faiHook","FAIHOOKTABS"));
1251 }
1252 if(in_array("FAIvariable",$array['objectClass'])){
1253 return(array("tabsVariable","faiVariable","FAIVARIABLETABS"));
1254 }
1255 if(in_array("FAIprofile",$array['objectClass'])){
1256 return(array("tabsProfile","faiProfile","FAIPROFILETABS"));
1257 }
1259 if(in_array("FAIpackageList",$array['objectClass'])){
1260 return(array("tabsPackage","faiPackage","FAIPACKAGETABS"));
1261 }
1262 return(array());
1263 }
1265 function CheckNewBranchName($name,$base)
1266 {
1267 $f = $this->fai_release;
1268 if($name == ""){
1269 return(false);
1270 }elseif(in_array($name,$this->getBranches($f))) {
1271 return(false);
1272 }elseif(tests::is_department_name_reserved($name,$base)){
1273 return(false);
1274 }
1275 return(true);
1276 }
1278 function save_object()
1279 {
1280 $this->DivListFai->save_object();
1282 /* Get posted release */
1283 $r_releases = array_flip($this->getBranches());
1284 if(isset($_POST['fai_release']) && isset($r_releases[get_post('fai_release')])){
1286 /* Ensure that we have a valid release selected */
1287 if(!isset($r_releases[get_post('fai_release')])){
1288 msg_dialog::display(_("Warning"),_("The selected release is not available anymore. All triggered actions are skipped."));
1289 $_POST = array();
1290 $plug =$_GET['plug'];
1291 $_GET = array("plug" => $plug);
1292 $this->fai_release = $this->fai_base;
1293 }else{
1294 $this->fai_release = $r_releases[get_post('fai_release')];
1295 }
1297 $fai_filter = session::get("fai_filter");
1298 $fai_filter['fai_release'] = $this->fai_release;
1299 session::set("fai_filter",$fai_filter);
1300 }
1302 if(is_object($this->CopyPasteHandler)){
1303 $this->CopyPasteHandler->save_object();
1304 }
1305 }
1308 function copyPasteHandling_from_queue($s_action,$s_entry)
1309 {
1310 /* Check if Copy & Paste is disabled */
1311 if(!is_object($this->CopyPasteHandler)){
1312 return("");
1313 }
1315 $ui = get_userinfo();
1317 /* Add a single entry to queue */
1318 if($this->dialog instanceOf faiGroupHandle && !$this->dialog->is_open()){
1320 if(in_array($this->dialog->get_mode(),array("copy"))){
1322 /* Cleanup object queue */
1323 $this->CopyPasteHandler->cleanup_queue();
1324 $group = $this->dialog->get_selected();
1325 foreach($group as $entry){
1326 $a_setup = $this->get_type($entry);
1327 $dn = $entry['dn'];
1328 if($ui->is_copyable($dn,"fai",$a_setup[1])){
1329 $this->CopyPasteHandler->add_to_queue($dn,$this->dialog->get_mode(),$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1330 }
1331 }
1332 $this->dialog = FALSE;
1333 }
1334 }
1336 /* Add entries to queue */
1337 if($s_action == "copy_multiple"){
1339 /* Cleanup object queue */
1340 $this->CopyPasteHandler->cleanup_queue();
1342 /* Add new entries to CP queue */
1343 foreach($this->list_get_selected_items() as $id){
1344 $group = $this->objects[$id];
1345 foreach($group as $entry){
1346 $a_setup = $this->get_type($entry);
1347 $dn = $entry['dn'];
1349 if($s_action == "copy_multiple" && $ui->is_copyable($dn,"fai",$a_setup[1])){
1350 $this->CopyPasteHandler->add_to_queue($dn,"copy",$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1351 }
1352 }
1353 }
1354 }
1356 /* Start pasting entries */
1357 if($s_action == "editPaste" && !($this->lock_type == "freeze" && !$this->allow_freeze_object_attach)){
1358 $this->start_pasting_copied_objects = TRUE;
1359 }
1361 /* Return C&P dialog */
1362 if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
1364 /* Get dialog */
1365 $this->CopyPasteHandler->SetVar("parent",$this);
1366 $data = $this->CopyPasteHandler->execute();
1368 FAI::save_release_changes_now();
1370 /* Return dialog data */
1371 if(!empty($data)){
1372 return($data);
1373 }
1374 }
1376 /* Automatically disable status for pasting */
1377 if(!$this->CopyPasteHandler->entries_queued()){
1378 $this->start_pasting_copied_objects = FALSE;
1379 }
1380 return("");
1381 }
1384 /* Check if the given FAI class is used in this release
1385 */
1386 static function check_class_name($oc,$name,$dn)
1387 {
1388 $base = FAI::get_release_dn($dn);
1390 if($oc == "FAIprofile"){
1391 $f = "";
1392 $ocs = array("FAIprofile","FAItemplate","FAIhook","FAIpartitionTable","FAIpackageList","FAIscript","FAIvariable");
1393 foreach($ocs as $oc){
1394 $f .= "(objectClass=".$oc.")";
1395 }
1396 $res = FAI::get_all_objects_for_given_base($base,"(|".$f.")",TRUE);
1397 }else{
1398 $res = FAI::get_all_objects_for_given_base($base,"(objectClass=".$oc.")",TRUE);
1399 }
1400 $delete = array();
1401 $used = array();
1402 foreach($res as $object){
1403 $used[$object['cn'][0]]= $object['cn'][0];
1404 }
1405 return($used);
1406 }
1409 /* Return plugin informations for acl handling */
1410 static function plInfo()
1411 {
1412 return (array(
1413 "plShortName" => _("FAI releases"),
1414 "plDescription" => _("FAI release management"),
1415 "plSelfModify" => FALSE,
1416 "plDepends" => array(),
1417 "plPriority" => 0,
1418 "plSection" => array("administration"),
1419 "plCategory" => array("fai"=> array("description" => _("FAI"),
1420 "objectClass" => "FAIclass")),
1421 "plProvidedAcls"=> array()));
1422 }
1423 }
1424 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1425 ?>