1 <?php
2 /*
3 This code is part of GOsa (https://gosa.gonicus.de)
4 Copyright (C) 2003 Cajus Pollmeier
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
22 class faiManagement extends plugin
23 {
24 /* Definitions */
25 var $plHeadline = "Software deployment";
26 var $plDescription = "Manage software packages and deployment reciepes";
27 var $plIcon = "plugins/fai/images/plugin.png";
29 /* Headpage attributes */
30 var $lock_type = ""; // should be branch/freeze
31 var $lock_name = "";
32 var $lock_dn = "";
34 /* attribute list for save action */
35 var $attributes = array("lock_type","lock_name","lock_dn"); // Attributes Managed by this plugin
36 var $objectclasses= array(); // ObjectClasses which the attributes are related to
37 var $dialog = array(); // This object contains every dialog we have currently opened
39 var $objects = array(); // This array contains all available objects shown in divlist
40 var $is_dialog = false;
42 var $dispNewBranch= false;
43 var $dispNewFreeze= false;
45 var $DivListFai;
46 var $start_pasting_copied_objects = FALSE;
47 var $CopyPasteHandler = FALSE;
49 /* Allow inserting of new elements if freezed releases
50 */
51 var $allow_freeze_object_attach = TRUE;
53 var $no_save;
54 var $acl_base ="";
55 var $fai_base ="";
56 var $fai_release ="";
58 var $acl_module = array("fai");
60 var $opsi = NULL;
62 /* construction/reconstruction
63 */
64 function faiManagement (&$config, $ui)
65 {
66 /* Set defaults */
67 $this->dn = "";
68 $this->config = $config;
69 $this->ui = $ui;
71 /* Check if the opsi plugin is installed.
72 */
73 if(class_available("opsi")){
74 $this->opsi = new opsi($this->config);;
75 }
77 /* Creat dialog object */
78 $this->DivListFai = new divListFai($this->config,$this);
80 /* Copy & Paste handler */
81 if ($this->config->boolValueIsTrue("main", "copyPaste")){
82 $this->CopyPasteHandler= new CopyPasteHandler($this->config);
83 }
85 /* Set default release
86 */
87 $this->acl_base = $this->config->current['BASE'];
88 $this->fai_base = get_ou("faiBaseRDN").$this->config->current['BASE'];
90 if(!session::is_set("fai_filter")){
92 /* Set intial release */
93 $rel = $config->search("faiManagement","DEFAULTFAIRELEASE",array("menu"));
94 $rels = array_flip($this->getBranches());
95 if(isset($rels[$rel])){
96 $rel = $rels[$rel];
97 }else{
98 $rel = $this->fai_base;
99 }
101 session::set("fai_filter",array("fai_release" => $rel));
102 }
104 $fai_filter = session::get("fai_filter");
105 $this->fai_release = $fai_filter['fai_release'];
106 }
108 function execute()
109 {
110 /* Call parent execute */
111 plugin::execute();
114 /* Initialise vars and smarty */
115 $smarty = get_smarty();
116 $smarty->assign("BranchName","");
118 $display = "";
119 $s_action = "";
120 $s_entry = "";
121 $no_save = FALSE; // hide Apply / Save buttons
123 /* If an entry was locked, these vars will be stored in a session to allow direct edit */
124 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/"));
127 /****************
128 Handle posts
129 ****************/
131 /* Check ImageButton posts
132 * Create new tab ich new_xx is posted
133 */
134 $posts = array( "/remove_branch/"=>"remove_branch", "/branch_branch/"=>"branch_branch",
135 "/freeze_branch/"=>"freeze_branch", "/create_partition/i"=>"new_partition",
136 "/create_script/i"=>"new_script", "/create_hook/i"=>"new_hook",
137 "/create_variable/i"=>"new_variable", "/create_template/i"=>"new_template",
138 "/create_package/i"=>"new_package", "/create_profile/i"=>"new_profile",
139 "/edit_continue/"=>"select_class_name_finished",
140 "/^multiple_copy_fai/" => "copy_multiple",
141 "/^multiple_cut_fai/" => "cut_multiple",
142 "/^copy/" => "copy",
143 "/^remove_multiple_fai_objects/" => "del_multiple");
145 foreach($_POST as $name => $value){
146 foreach($posts as $reg => $act ){
147 if(preg_match($reg,$name)){
148 $s_action = $act;
149 $s_entry = ltrim(preg_replace($reg,"",$name),"_");
150 $s_entry = preg_replace("/_.*$/","",$s_entry);
151 break;
152 }
153 }
154 if(preg_match("/^entry_edit_.*/",$name)){
155 $s_entry = preg_replace("/^entry_edit_/","",$name);
156 $s_entry = preg_replace("/_.*$/","",$s_entry);
157 $s_action = "edit";
158 break;
159 }elseif(preg_match("/^entry_freeze_edit_.*/",$name)){
160 $s_entry = preg_replace("/^entry_freeze_edit_/","",$name);
161 $s_entry = preg_replace("/_.*$/","",$s_entry);
162 $s_action = "edit";
163 $no_save = TRUE;
164 break;
165 }elseif(preg_match("/^entry_delete_.*/",$name)){
166 $s_entry = preg_replace("/^entry_delete_/","",$name);
167 $s_entry = preg_replace("/_.*$/","",$s_entry);
168 $s_action = "delete";
169 break;
170 }
172 /* Get posts from opsi onjects
173 */
174 if($this->opsi instanceof opsi && $this->opsi->enabled()){
175 if(preg_match("/^entry_opsi_edit_/",$name)){
176 $s_entry = preg_replace("/^entry_opsi_edit_([0-9]*).*$/","\\1",$name);
177 $s_action = "opsi_edit";
178 break;
179 }
180 }
181 }
183 /* Get posts from opsi objects
184 */
185 if($this->opsi instanceof opsi && $this->opsi->enabled() && isset($_GET['edit_opsi_entry'])){
186 $s_entry = $_GET['edit_opsi_entry'];
187 $s_action = "opsi_edit";
188 }
190 if(isset($_GET['edit_entry'])){
191 $s_entry = $_GET['edit_entry'];
192 $s_action = "edit";
193 }
195 if(isset($_GET['edit_freeze_entry'])){
196 $s_entry = $_GET['edit_freeze_entry'];
197 $s_action = "edit";
198 $no_save = TRUE;
199 }
201 if(isset($_GET['act']) && $_GET['act'] == "freeze_branch"){
202 $s_action = "freeze_branch";
203 }
204 if(isset($_GET['act']) && $_GET['act'] == "branch_branch"){
205 $s_action = "branch_branch";
206 }
207 if(isset($_GET['act']) && $_GET['act'] == "remove_branch"){
208 $s_action = "remove_branch";
209 }
211 if((isset($_POST['CancelBranchName'])) || (isset($_POST['CloseIFrame']))){
212 $this->dispNewBranch = false;
213 $this->dispNewFreeze = false;
214 }
217 $type_acl_mapping = array(
218 "FAIpartitionTable" => "faiPartitionTable",
219 "FAIpackageList" => "faiPackage",
220 "FAIscript" => "faiScript",
221 "FAIvariable" => "faiVariable",
222 "FAIhook" => "faiHook",
223 "FAIprofile" => "faiProfile",
224 "FAItemplate" => "faiTemplate");
227 /* handle C&P from layers menu */
228 if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){
229 $s_action = "copy_multiple";
230 }
231 if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){
232 $s_action = "cut_multiple";
233 }
234 if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){
235 $s_action = "editPaste";
236 }
238 /* Create options */
239 if(isset($_POST['menu_action']) && preg_match("/^Create_/",$_POST['menu_action'])){
240 $s_action = "new_".preg_replace("/^Create_/","",$_POST['menu_action']);;
241 $s_entry = preg_replace("/^Create_/","",$_POST['menu_action']);
242 }
244 /* handle remove from layers menu */
245 if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){
246 $s_action = "del_multiple";
247 }
250 if(!empty($s_action)){
251 $this->no_save = $no_save;
252 }
254 /********************
255 Copy & Paste
256 ********************/
258 /* Display the copy & paste dialog, if it is currently open */
259 $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
260 if($ret){
261 return($ret);
262 }
265 /*******************
266 Opsi extension
267 *******************/
269 if($this->opsi instanceof opsi && $this->opsi->enabled()){
270 if($s_action == "opsi_edit"){
271 $name = $this->objects[$s_entry]['cn'];
272 $cfg = $this->opsi->get_product_properties($name);
273 $this->dialog = new tabs_opsiProdConfig($this->config, $this->config->data['TABS']['OPSIPRODCONFIG'],"","opsi");
274 if(isset($this->dialog->by_object['opsiProperties'])){
275 $this->dialog->by_object['opsiProperties']->set_cfg($cfg);
276 $this->dialog->by_object['opsiProperties']->set_product($name);
277 }else{
278 trigger_error("Unknown tab, please check config.");
279 }
280 }
281 if($this->dialog instanceof tabs_opsiProdConfig && isset($_POST['cancel_properties'])){
282 $this->dialog = NULL;
283 }
284 if($this->dialog instanceof tabs_opsiProdConfig && isset($_POST['save_properties'])){
285 $this->dialog->save_object();
286 $op = $this->dialog->by_object['opsiProperties'];
287 $name = $op->get_product();
288 $cfg = $op->get_cfg();
289 $this->opsi->set_product_properties($name,$cfg);
290 if($this->opsi->is_error()){
291 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
292 }else{
293 $this->dialog = NULL;
294 }
295 }
296 if($this->dialog instanceof tabs_opsiProdConfig){
297 $this->dialog->save_object();
298 return($this->dialog->execute());
299 }
300 }
303 /****************
304 Delete confirme dialog
305 ****************/
307 if ($s_action=="delete"){
309 /* Get 'dn' from posted termlinst */
310 $this->dn= $this->objects[$s_entry]['dn'];
312 /* Load permissions for selected 'dn' and check if
313 we're allowed to remove this 'dn' */
314 $acl = $this->ui->get_permissions($this->dn,"fai/".$type_acl_mapping[$this->objects[$s_entry]['type']]);
315 if(preg_match("/d/",$acl)){
317 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
318 if (($user= get_lock($this->dn)) != ""){
319 return(gen_locked_message ($user, $this->dn));
320 }
322 /* Lock the current entry, so nobody will edit it during deletion */
323 add_lock ($this->dn, $this->ui->dn);
324 $smarty->assign("warning",msgPool::deleteInfo(LDAP::fix($this->dn),_("FAI object")));
325 $smarty->assign("multiple", false);
326 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
327 } else {
329 /* Obviously the user isn't allowed to delete. Show message and clean session. */
330 msg_dialog::display(_("Permission error"), msgPool::permDelete(),ERROR_DIALOG);
331 }
332 }
335 /********************
336 Delete MULTIPLE entries requested, display confirm dialog
337 ********************/
339 if ($s_action=="del_multiple"){
340 $this->dns = array();
341 $ids = $this->list_get_selected_items();
343 if(count($ids)){
345 $errors = "";
346 foreach($ids as $id){
347 $dn = $this->objects[$id]['dn'];
348 $cn = $this->objects[$id]['cn'];
349 if(!preg_match('/^freeze/', $this->objects[$id]['FAIstate'])){
350 $this->dns[$id] = $dn;
351 }else{
352 $errors .= $cn.", ";
353 }
354 }
355 if ($user= get_multiple_locks($this->dns)){
356 return(gen_locked_message($user,$this->dns));
357 }
359 if($errors != ""){
360 msg_dialog::display(_("Branch locked"),sprintf(_("The following entries are locked, you can't remove them %s."),
361 "<br><br>".trim($errors,", ")),INFO_DIALOG);
362 }
364 if(count($this->dns)){
366 $dns_names = array();
367 foreach($this->dns as $dn){
368 add_lock ($dn, $this->ui->dn);
369 $dns_names[] = LDAP::fix($dn);
370 }
372 /* Lock the current entry, so nobody will edit it during deletion */
373 $smarty->assign("warning",msgPool::deleteInfo($dns_names,_("FAI object")));
374 $smarty->assign("multiple", true);
375 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
376 }
377 }
378 }
381 /********************
382 Delete MULTIPLE entries confirmed
383 ********************/
385 /* Confirmation for deletion has been passed. Users should be deleted. */
386 if (isset($_POST['delete_multiple_fai_object_confirm'])){
388 /* Find out more about the object type */
389 $ldap = $this->config->get_ldap_link();
391 /* Remove user by user and check acls before removeing them */
392 foreach($this->dns as $key => $dn){
394 $ldap->cat($dn, array('objectClass'));
395 $attrs = $ldap->fetch();
396 $type = $this->get_type($attrs);
398 $acl = $this->ui->get_permissions($dn,"fai/".$type[1]);
399 if(preg_match("/d/",$acl)){
401 $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $dn,"fai");
402 $this->dialog->parent = &$this;
403 $this->dialog->set_acl_base($dn);
404 $this->dialog->by_object[$type[1]]->remove_from_parent ();
405 unset ($this->dialog);
406 $this->dialog= FALSE;
407 $to_del = FAI::clean_up_releases($dn);
408 FAI::save_release_changes_now();
410 foreach($to_del as $dn){
411 $ldap->rmdir_recursive($dn);
412 }
414 } else {
416 /* Normally this shouldn't be reached, send some extra
417 logs to notify the administrator */
418 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
419 new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion.");
420 }
421 }
423 /* Remove lock file after successfull deletion */
424 $this->remove_lock();
425 $this->dns = array();
426 }
429 /********************
430 Delete MULTIPLE entries Canceled
431 ********************/
433 /* Remove lock */
434 if(isset($_POST['delete_multiple_fai_object_cancel'])){
435 $this->dns = array();
436 $this->remove_lock();
437 }
440 /****************
441 Delete aborted
442 ****************/
444 /* Delete canceled? */
445 if (isset($_POST['delete_cancel'])){
446 $this->remove_lock();
447 }
450 /****************
451 Delete confirmed
452 ****************/
454 /* Deletion was confirmed, so delete this entry
455 */
456 if (isset($_POST['delete_terminal_confirm'])){
458 /* Some nice guy may send this as POST, so we've to check
459 for the permissions again. */
461 /* Find out more about the object type */
462 $ldap = $this->config->get_ldap_link();
463 $ldap->cat($this->dn, array('objectClass'));
464 if($ldap->count()){
465 $attrs = $ldap->fetch();
466 $type = $this->get_type($attrs);
468 $acl = $this->ui->get_permissions($this->dn,"fai/".$type[1]);
469 if(preg_match("/d/",$acl)){
471 $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $this->dn,"fai");
472 $this->dialog->set_acl_base($this->dn);
473 $this->dialog->parent = &$this;
474 $this->dialog->by_object[$type[1]]->remove_from_parent ();
475 unset ($this->dialog);
476 $this->dialog= FALSE;
477 $to_del = FAI::clean_up_releases($this->dn);
478 FAI::save_release_changes_now();
480 foreach($to_del as $dn){
481 $ldap->rmdir_recursive($dn);
482 }
484 } else {
486 /* Normally this shouldn't be reached, send some extra
487 logs to notify the administrator */
488 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
489 new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion.");
490 }
492 }else{
493 msg_dialog::display(_("Error"), sprintf(_("Cannot delete '%s': object does not exist!"), $this->dn) , ERROR_DIALOG);
494 }
496 /* Remove lock file after successfull deletion */
497 $this->remove_lock();
498 }
501 /****************
502 Edit entry
503 ****************/
505 if(($s_action == "edit") && (!isset($this->dialog->config))){
506 $entry = $this->objects[$s_entry];
507 $a_setup = $this->get_type($entry);
508 $this->dn = $entry['dn'];
510 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
511 if (($user= get_lock($this->dn)) != ""){
512 return(gen_locked_message ($user, $this->dn));
513 }
514 add_lock ($this->dn, $this->ui->dn);
516 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
517 $this->dialog->parent = &$this;
518 $this->dialog->by_object[$a_setup[1]]->FAIstate = $entry['FAIstate'];
519 $this->dialog->set_acl_base($this->dn);
520 $this->is_dialog = true;
521 session::set('objectinfo',$this->dn);
522 }
525 /* Branch handling
526 09.01.2006
527 */
529 /****************
530 Remove branch
531 ****************/
533 /* Remove branch
534 */
535 if($s_action == "remove_branch"){
536 $base= $this->fai_release;
538 /* Check if we have a post remove method configured
539 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
540 */
541 if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
542 /* Load permissions for selected 'dn' and check if
543 we're allowed to remove this 'dn' */
544 if(preg_match("/d/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
545 $smarty->assign("release_hidden",base64_encode($this->fai_release));
546 $smarty->assign("info", msgPool::deleteInfo(LDAP::fix($this->fai_release),_("FAI branch/freeze")));
547 return($smarty->fetch(get_template_path('remove_branch.tpl',TRUE)));
548 } else {
549 msg_dialog::display(_("Permission error"), _("You have no permission to delete this release!"), ERROR_DIALOG);
550 }
551 }
552 }
555 /****************
556 Remove branch confirmed
557 ****************/
559 if(isset($_POST['delete_branch_confirm'])){
561 /* Check if we have a post remove method configured
562 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
563 */
564 if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
566 if(!isset($_POST['release_hidden']) || base64_decode($_POST['release_hidden']) != $this->fai_release){
567 msg_dialog::display(_("Warning"),_("Release remove aborted because the release name check failed!"));
568 }else{
570 $bb = $this->fai_release;
571 if(!isset($ldap)){
572 $ldap = $this->config->get_ldap_link();
573 }
575 $br = $this->getBranches();
577 if(isset($br[$bb]) && preg_match("/d/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
578 $name = $br[$bb];
580 $ldap->cd($bb);
581 $ldap->recursive_remove();
582 $ldap->cd(preg_replace('/,'.preg_quote(get_ou('faiBaseRDN'), '/').'/', ','.get_ou('applicationRDN'), $bb));
583 $ldap->recursive_remove();
584 $ldap->cd(preg_replace('/,'.preg_quote(get_ou('faiBaseRDN'), '/').'/', ','.get_ou('mimetypeRDN'), $bb));
585 $ldap->recursive_remove();
587 /* Search for all groups with configured application menus.
588 - First search all groups, to ensure that we only remove entries form whithin groups.
589 - The search für menu configuration for the specified release and collect all those dns.
590 - Remove entries
591 */
592 $release_ou = preg_replace("/".preg_quote(get_ou("faiBaseRDN"), '/').".*$/","",$bb);
593 $ldap->cd($this->config->current['BASE']);
594 $ldap->search("(objectClass=posixGroup)",array("dn"));
596 /* Collect all group dns
597 */
598 $groups = array();
599 while($attrs = $ldap->fetch()){
600 $groups[] = $attrs['dn'];
601 }
603 /* Collect all group menu release dns that match the release we have removed
604 */
605 $dns = array();
606 foreach($groups as $dn){
607 $ldap->cd($dn);
608 $ldap->search("(objectClass=FAIbranch)",array("dn"));
609 while($attrs = $ldap->fetch()){
610 if(preg_match("/^".preg_quote($release_ou, '/')."/",$attrs['dn'])){
611 $dns[] = $attrs['dn'];
612 }
613 }
614 }
616 /* Finally remove collected release dns
617 */
618 foreach($dns as $dn){
619 $ldap->cd($dn);
620 $ldap->recursive_remove();
621 }
623 /* Post remove */
624 $this->fai_release = $this->fai_base;
625 $this->lock_name = $name;
626 $this->lock_dn = $bb;
627 $this->postremove();
629 $fai_filter = session::get("fai_filter");
630 $fai_filter['fai_release'] = $this->fai_release;
631 session::set("fai_filter",$fai_filter);
633 new log("remove","fai/".get_class($this),$br[$bb],array(),"Release removed");
634 }
635 }
636 }
637 }
640 /****************
641 Create a new branch "insert Name"
642 ****************/
644 if((isset($_POST['UseBranchName']))&&(($this->dispNewBranch)||($this->dispNewFreeze))){
645 session::set('LASTPOST',$_POST);
647 if($this->dispNewBranch){
648 $type = "branch";
649 }else{
650 $type = "freeze";
651 }
653 /* Check branch name */
654 $name = $_POST['BranchName'];
655 $is_ok = true;
656 $smarty->assign("BranchName",$name);
657 $base= $this->fai_base;
659 /* Check used characters */
660 if(!preg_match("/^[0-9a-z\.]*$/",$name)){
661 msg_dialog::display(_("Error"), msgPool::invalid(_("Name"),$name,"/[0-9a-z\.]/"), ERROR_DIALOG);
662 $is_ok = false;
663 }
665 /* Check if this name is already in use */
666 if(!$this->CheckNewBranchName($_POST['BranchName'],$this->fai_release)){
667 msg_dialog::display(_("Error"), msgPool::duplicated(_("Name")), ERROR_DIALOG);
668 $is_ok = false;
669 }
671 if($is_ok){
673 if(session::is_set('LASTPOST')){
674 $LASTPOST = session::get('LASTPOST');
675 }else{
676 $LASTPOST = array();
677 }
678 $LASTPOST['base'] = $base;
679 $LASTPOST['type'] = $type;
680 session::set('LASTPOST',$LASTPOST);
681 $smarty->assign("iframe", true);
682 $smarty->assign("plugID", $_GET['plug']);
683 $display = $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
684 return($display);
685 }
686 }
689 /****************
690 Create a new branch
691 ****************/
693 if(isset($_GET['PerformBranch'])){
695 if(!preg_match("/c/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
696 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
697 }else{
699 /* In order to see error messages we have to reset the error handler.
700 Due to the exit();
701 */
702 restore_error_handler();
704 /* Create it know */
705 $this->dispNewBranch = false;
706 $this->dispNewFreeze = false;
708 $LASTPOST = session::get('LASTPOST');
709 $base = $LASTPOST['base'];
710 $_POST = session::get('LASTPOST');
711 $name = $_POST['BranchName'];
713 $type = $LASTPOST['type'];
714 $ldap = $this->config->get_ldap_link();
716 $baseToUse = $base;
717 if($this->fai_release != $this->fai_base){
718 $baseToUse = $this->fai_release;
719 }
721 /* Create new Release name to be able to set faidebianRelease for FAIpackageList */
723 $CurrentReleases = $this->getBranches();
724 $NewReleaseName = $name;
725 if(isset($CurrentReleases[$this->fai_release])) {
726 if($this->fai_release != $this->fai_base){
727 $NewReleaseName = $CurrentReleases[$this->fai_release]."/".$name;
728 $NewReleaseName = preg_replace("#\/#","/",$NewReleaseName);
729 }else{
730 $NewReleaseName = $name;
731 }
732 }
734 $appsrc = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('applicationRDN'),$baseToUse);
735 $appdst = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('applicationRDN'),"ou=".$name.",".$baseToUse) ;
737 $mimesrc = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('mimetypeRDN'),$baseToUse);
738 $mimedst = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('mimetypeRDN'),"ou=".$name.",".$baseToUse) ;
740 /* Check if source depeartments exist */
741 foreach(array($baseToUse,$appsrc,$mimesrc) as $dep){
742 $ldap->cd($this->config->current['BASE']);
743 $ldap->cat($dep);
744 if(!$ldap->count()){
745 $ldap->create_missing_trees($dep);
746 }
747 }
749 /* Print header to have styles included */
750 echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
751 <html>
752 <head>
753 <title></title>
754 <style type="text/css">@import url("themes/default/style.css");</style>
755 <script language="javascript" src="include/focus.js" type="text/javascript"></script>
756 </head>
757 <body style="background: none;margin:3px;color:black">
758 ';
760 new log("create","fai/".get_class($this),$NewReleaseName,array(),"New $type created");
762 /* Duplicate group application releases
763 */
764 FAI::copy_FAI_group_releases($CurrentReleases[$this->fai_release],$name,$type);
766 /* Duplicate applications
767 */
768 $ldap->cat($appsrc,array("dn")) ;
769 if($ldap->count()){
770 $ldap->cd ($appdst);
771 $ldap->recursive_remove();
772 FAI::copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true);
773 }
775 /* Duplicate mime types
776 */
777 $ldap->cat($mimesrc,array("dn")) ;
778 if($ldap->count()){
779 $ldap->cd ($mimedst);
780 $ldap->recursive_remove();
781 FAI::copy_FAI_resource_recursive($mimesrc,$mimedst,$NewReleaseName,$type,true);
782 }
784 $attr = array();
785 $attr['objectClass'] = array("organizationalUnit","FAIbranch");
786 $attr['ou'] = $name;
787 $attr['FAIstate'] = $type;
788 $ldap->cd($this->config->current['BASE']);
789 $ldap->cd("ou=".$name.",".$baseToUse);
790 $ldap->cat("ou=".$name.",".$baseToUse);
791 if($ldap->count()){
792 $ldap->modify($attr);
793 }else{
794 $ldap->add($attr);
795 }
797 /* Duplicate fai objects
798 */
799 // $ldap->cd ("ou=".$name.",".$baseToUse);
800 // $ldap->recursive_remove();
801 // FAI::copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,$NewReleaseName,$type,true);
803 echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
804 <br><input type='submit' name='CloseIFrame' value='"._("Continue")."'>
805 </form></div>";
807 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
809 /* Print footer to have valid html */
810 echo "</body></html>";
812 $this->dispNewFreeze = false;
814 /* Postcreate */
816 /* Assign possible attributes */
817 $this->lock_type = $type;
818 $this->lock_name = $name;
819 $this->lock_dn = $baseToUse;
820 $this->postcreate();
823 /* Send daemon event to reload the fai release database
824 */
825 if(class_available("DaemonEvent") && class_available("gosaSupportDaemon")){
826 $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
827 if(isset($events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'])){
828 $evt = $events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'];
829 $tmp = new $evt['CLASS_NAME']($this->config);
830 $tmp->set_type(TRIGGERED_EVENT);
831 $tmp->add_targets(array("GOSA"));
832 $o_queue = new gosaSupportDaemon();
833 if(!$o_queue->append($tmp)){
834 msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
835 }
836 }
837 }else{
838 trigger_error("Unknown class DaemonEvent / gosaSupportDaemon");
839 msg_dialog::display(_("Fatal error"),
840 "Daemon events called but classes where not accessible, DaemonEvent gosaSupportDaemon",
841 FATAL_ERROR_DIALOG);
842 }
843 exit();
844 }
845 }
847 /****************
848 Display dialog to enter new Branch name
849 ****************/
851 /* Check if we have a post create method configured
852 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
853 */
854 if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
855 if(($s_action == "branch_branch")||($this->dispNewBranch)){
857 echo $this->acl_base;
858 echo "->".$this->ui->get_permissions($this->acl_base,"fai/faiManagement");
860 if(!preg_match("/c/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
861 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
862 }else{
863 $this->dispNewBranch=true;
864 $smarty->assign("iframe",false);
865 $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
866 return($display);
867 }
868 }
869 }
872 /****************
873 Display dialog to enter new Freeze name
874 ****************/
876 /* Check if we have a post create method configured
877 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
878 */
879 if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
880 if(($s_action == "freeze_branch")||($this->dispNewFreeze)){
881 if(!preg_match("/c/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
882 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
883 }else{
884 $this->dispNewFreeze = true;
885 $smarty->assign("iframe",false);
886 $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
887 return($display);
888 }
889 }
890 }
893 /****************
894 Create a new object
895 ****************/
897 $types = array( "new_partition" => "FAIpartitionTable",
898 "new_script" => "FAIscript",
899 "new_hook" => "FAIhook",
900 "new_variable" => "FAIvariable",
901 "new_template" => "FAItemplate",
902 "new_package" => "FAIpackageList");
903 $types_i18n = array( "new_partition" => _("partition table"),
904 "new_script" => _("script"),
905 "new_hook" => _("hook"),
906 "new_variable" => _("variable"),
907 "new_template" => _("template"),
908 "new_package" => _("package list"));
910 if(isset($types[$s_action])){
911 $acl = $this->ui->get_permissions($this->fai_base,"fai/".$type_acl_mapping[$types[$s_action]]);
912 if(preg_match("/c/",$acl)){
913 $this->dialog = new askClassName($this->config,$this->dn,$this->ui,$types[$s_action]);
914 $this->dialog->parent = &$this;
915 }else{
916 msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), $types_i18n[$s_action]), ERROR_DIALOG);
917 }
918 }
920 /* New Profile */
921 if($s_action == "new_profile"){
922 $this->dn = "new" ;
924 $acl = $this->ui->get_permissions($this->fai_base,"fai/faiProfile");
925 if(preg_match("/c/",$acl)){
926 $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
927 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
928 $this->dialog->set_acl_base($this->base);
929 $this->dialog->parent = &$this;
931 $this->is_dialog = false;
932 }else{
933 msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), _("profile")), ERROR_DIALOG);
934 }
935 }
938 /****************
939 Get from ask class name dialog
940 ****************/
942 if($s_action == "select_class_name_finished"){
943 $this->dialog->save_object();
944 if(count($this->dialog->check())!=0){
945 foreach($this->dialog->check() as $msg){
946 msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
947 }
948 }elseif(isset($this->dialog->objectClass)){
949 $this->dn = "new" ;
950 $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass)));
951 $name = $this->dialog->save();
953 if(class_exists($a_setup[0])){
954 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
955 $this->dialog->set_acl_base($this->base);
956 $this->dialog->by_object[$a_setup[1]]->cn = $name;
957 $this->dialog->parent = &$this;
958 $this->is_dialog = true;
959 }
960 }
961 }
964 /****************
965 Cancel dialogs
966 ****************/
968 if(isset($_POST['edit_cancel'])){
969 $this->dialog=FALSE;
970 $this->is_dialog = false;
971 session::un_set('objectinfo');
972 $this->remove_lock();
973 }
976 /****************
977 Save sub dialogs
978 ****************/
980 /* This check if the given tab could be saved
981 * If it was possible to save it, remove dialog object.
982 * If it wasn't possible, show errors and keep dialog.
983 */
984 if((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->dialog->config))){
985 $this->dialog->save_object();
986 $msgs= $this->dialog->check();
987 if(count($msgs)!=0){
988 foreach($msgs as $msg){
989 msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
990 }
991 }else{
992 $this->dialog->save();
993 FAI::save_release_changes_now();
994 if (!isset($_POST['edit_apply'])){
995 $this->remove_lock();
996 $this->dialog=FALSE;
997 $this->is_dialog=false;
998 session::un_set('objectinfo');
999 }else{
1001 /* Reinitialize tab */
1002 if($this->dialog instanceof tabs){
1003 $this->dialog->re_init();
1004 }
1005 }
1006 }
1007 }
1010 /****************
1011 Display currently open dialog
1012 ****************/
1014 /* If dialog is set, but $this->is_dialog==false, then
1015 * only the "abort" button is shown, this are dialogs that must not be saved.
1016 * If is_dialog == true, we are currently editing tab objects.
1017 * Here we need both, save and cancel
1018 */
1020 if(is_object($this->dialog)){
1021 $display .= $this->dialog->execute();
1022 /* Don't show buttons if tab dialog requests this */
1024 if(isset($this->dialog->current)){
1026 $obj = $this->dialog->by_object[$this->dialog->current];
1028 if((isset($obj->is_dialog) && (!$obj->is_dialog)) || (isset($obj->dialog) && (!$obj->dialog))){
1030 $display.= "<p style=\"text-align:right\">\n";
1031 if(!$this->no_save){
1032 $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
1033 $display.= " \n";
1034 if ($this->dn != "new"){
1035 $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
1036 $display.= " \n";
1037 }
1038 }
1039 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1040 $display.= "</p>";
1041 }elseif(!isset($this->dialog->current)){
1042 $display.= "<p style=\"text-align:right\">\n";
1043 $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\"> ";
1044 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1045 $display.= "</p>";
1046 }
1047 }else{
1048 $display.= "<p style=\"text-align:right\">\n";
1049 $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\"> ";
1050 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1051 $display.= "</p>";
1053 }
1054 return($display);
1055 }
1058 /****************
1059 Dialog display
1060 ****************/
1062 /* Check if there is a snapshot dialog open */
1063 $base = $this->fai_base;
1064 if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
1065 return($str);
1066 }
1068 /* Display dialog with system list */
1069 $this->reload();
1070 $this->DivListFai->parent = &$this;
1071 $this->DivListFai->execute();
1072 $this->DivListFai->setEntries($this->objects);
1073 return($this->DivListFai->Draw());
1074 }
1077 /* Return departments, that will be included within snapshot detection */
1078 function get_used_snapshot_bases()
1079 {
1080 $tmp = array();
1081 $types = array("faiPartitionRDN","faiScriptRDN","faiTemplateRDN","faiHookRDN","faiProfileRDN","faiVariableRDN","faiPackageRDN");
1082 foreach($types as $type){
1083 $tmp[] = get_ou($type).$this->fai_release;
1084 }
1085 return($tmp);
1086 }
1089 /* Get available branches for current base */
1090 function getBranches($base = false,$prefix = "")
1091 {
1092 $ret = array("/"=>$this->fai_base);
1093 $ldap = $this->config->get_ldap_link();
1094 if(!$base){
1095 $base = $this->fai_base;
1096 }
1097 $tmp = FAI::get_all_releases_from_base($base,true);
1098 foreach($tmp as $dn => $name){
1099 $ret[$name]=$dn;
1100 }
1101 ksort($ret);
1102 $ret = array_flip($ret);
1104 return ($ret);
1105 }
1108 function list_get_selected_items()
1109 {
1110 $ids = array();
1111 foreach($_POST as $name => $value){
1112 if(preg_match("/^item_selected_[0-9]*$/",$name)){
1113 $id = preg_replace("/^item_selected_/","",$name);
1114 $ids[$id] = $id;
1115 }
1116 }
1117 return($ids);
1118 }
1121 /* reload list of objects */
1122 function reload()
1123 {
1124 /* Variable initialisation */
1125 $str = "";
1126 $Regex = $this->DivListFai->Regex;
1127 $this->objects = array();
1129 /* Get base */
1130 $base = $this->fai_base;
1131 if($this->fai_release != $this->fai_base){
1132 $br = $this->getBranches();
1133 if(isset($br[$this->fai_release])){
1134 $base = $this->fai_release;
1135 }else{
1136 $base = $this->fai_base;
1137 }
1138 }
1139 $this->base = $base;
1140 $this->set_acl_base($this->acl_base);
1142 $this->lock_type = FAI::get_release_tag(FAI::get_release_dn($base));
1144 /* Create a new list of FAI object
1145 * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ...
1146 */
1147 $ObjectTypes = array(
1148 "FAIpartitionTable" => array("OU"=> get_ou('faiPartitionRDN') , "CHKBOX"=>"ShowPartitions" ,"ACL" => "faiPartitionTable"),
1149 "FAIpackageList" => array("OU"=> get_ou('faiPackageRDN') , "CHKBOX"=>"ShowPackages" ,"ACL" => "faiPackage"),
1150 "FAIscript" => array("OU"=> get_ou('faiScriptRDN') , "CHKBOX"=>"ShowScripts" ,"ACL" => "faiScript"),
1151 "FAIvariable" => array("OU"=> get_ou('faiVariableRDN') , "CHKBOX"=>"ShowVariables" ,"ACL" => "faiVariable"),
1152 "FAIhook" => array("OU"=> get_ou('faiHookRDN') , "CHKBOX"=>"ShowHooks" ,"ACL" => "faiHook"),
1153 "FAIprofile" => array("OU"=> get_ou('faiProfileRDN') , "CHKBOX"=>"ShowProfiles" ,"ACL" => "faiProfile"),
1154 "FAItemplate" => array("OU"=> get_ou('faiTemplateRDN') , "CHKBOX"=>"ShowTemplates" ,"ACL" => "faiTemplate"));
1156 $filter = "";
1157 foreach($ObjectTypes as $key => $data){
1158 if($this->DivListFai->$data['CHKBOX']){
1159 $filter.= "(objectClass=".$key.")";
1160 }
1161 }
1162 $filter = "(&(|".$filter.")(cn=$Regex))";
1164 /* Get resolved release dependencies */
1165 $tmp = FAI::get_all_objects_for_given_base($base,$filter);
1167 /* Ge listed ldap objects */
1168 $ldap = $this->config->get_ldap_link();
1169 $ldap->cd($this->config->current['BASE']);
1171 foreach($tmp as $entry){
1173 /* Get some more informations about the object */
1174 $ldap->cat($entry['dn'], array("cn","description","objectClass","FAIclass","FAIstate","objectClass"));
1175 $object = $ldap->fetch();
1177 /* Walk through possible types */
1178 foreach($ObjectTypes as $type => $rest){
1180 $acl = $this->ui->get_permissions($object['dn'],"fai/".$rest ['ACL']);
1182 if(in_array($type,$object['objectClass']) && preg_match("/r/",$acl)){
1184 /* Prepare object */
1185 unset($object['objectClass']['count']);
1186 if(!isset($object['description'][0])){
1187 $object['description'][0]="";
1188 }
1190 /* Clean up object informations */
1191 $obj = array();
1192 $obj['cn'] = $object['cn'][0];
1193 $obj['dn'] = $object['dn'];
1194 $obj['acl'] = $acl;
1195 $obj['class'] = $rest ['ACL'];
1196 $obj['FAIstate'] = $entry['FAIstate'];
1197 $obj['description'] = $object['description'][0];
1198 $obj['objectClass'] = $object['objectClass'];
1200 $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj;
1201 $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type;
1202 }
1203 }
1204 }
1206 /* Append opsi objects, if opsi is available and if we are on the fai_base
1207 */
1208 if($this->opsi instanceof opsi && $this->opsi->enabled()){
1209 $opsi_acl = $this->ui->get_permissions($base,"opsi/opsiProperties");
1210 if(preg_match("/r/",$opsi_acl)){
1211 $err = FALSE;
1212 if(!$err && $this->DivListFai->ShowOpsiNetboot){
1213 $n_pro = $this->opsi->get_netboot_products();
1214 $err |= $this->opsi->is_error();
1215 foreach($n_pro as $name => $data){
1216 $entry = array("cn" => $name,
1217 "description" => $data['DESC'],
1218 "type" => "opsi_netboot");
1219 $this->objects[$name."_opsi_netboot"] = $entry;
1220 }
1221 }
1222 if(!$err && $this->DivListFai->ShowOpsiLocal){
1223 $l_pro = $this->opsi->get_local_products();
1224 $err |= $this->opsi->is_error();
1225 foreach($l_pro as $name => $data){
1226 $entry = array("cn" => $name,
1227 "description" => $data['DESC'],
1228 "type" => "opsi_local");
1229 $this->objects[$name."_opsi_local"] = $entry;
1230 }
1231 }
1232 if($err){
1233 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
1234 }
1235 }
1236 }
1238 ksort($this->objects);
1239 reset ($this->objects);
1241 /* use numeric index, thats a bit more secure */
1242 $tmp0 = array();
1243 foreach($this->objects as $obj){
1244 $tmp0[]= $obj;
1245 }
1246 $this->objects = array();
1247 $this->objects = $tmp0;
1248 }
1250 function remove_lock()
1251 {
1252 if (isset($this->dn)){
1253 del_lock ($this->dn);
1254 }
1255 if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
1256 del_lock ($this->dns);
1257 }
1258 }
1260 function get_type($array){
1261 if(in_array("FAIpartitionTable",$array['objectClass'])){
1262 return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS"));
1263 }
1264 if(in_array("FAIscript",$array['objectClass'])){
1265 return(array("tabsScript","faiScript","FAISCRIPTTABS"));
1266 }
1267 if(in_array("FAItemplate",$array['objectClass'])){
1268 return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS"));
1269 }
1270 if(in_array("FAIhook",$array['objectClass'])){
1271 return(array("tabsHook","faiHook","FAIHOOKTABS"));
1272 }
1273 if(in_array("FAIvariable",$array['objectClass'])){
1274 return(array("tabsVariable","faiVariable","FAIVARIABLETABS"));
1275 }
1276 if(in_array("FAIprofile",$array['objectClass'])){
1277 return(array("tabsProfile","faiProfile","FAIPROFILETABS"));
1278 }
1280 if(in_array("FAIpackageList",$array['objectClass'])){
1281 return(array("tabsPackage","faiPackage","FAIPACKAGETABS"));
1282 }
1283 }
1285 function CheckNewBranchName($name,$base)
1286 {
1287 $f = $this->fai_release;
1288 if($name == ""){
1289 return(false);
1290 }elseif(in_array($name,$this->getBranches($f))) {
1291 return(false);
1292 }elseif(tests::is_department_name_reserved($name,$base)){
1293 return(false);
1294 }
1295 return(true);
1296 }
1298 function save_object()
1299 {
1300 $this->DivListFai->save_object();
1302 /* Get posted release */
1303 $r_releases = array_flip($this->getBranches());
1304 if(isset($_POST['fai_release']) && isset($r_releases[get_post('fai_release')])){
1306 /* Ensure that we have a valid release selected */
1307 if(!isset($r_releases[get_post('fai_release')])){
1308 msg_dialog::display(_("Warning"),_("The selected release is not available anymore. All triggered actions are skipped."));
1309 $_POST = array();
1310 $plug =$_GET['plug'];
1311 $_GET = array("plug" => $plug);
1312 $this->fai_release = $this->fai_base;
1313 }else{
1314 $this->fai_release = $r_releases[get_post('fai_release')];
1315 }
1317 $fai_filter = session::get("fai_filter");
1318 $fai_filter['fai_release'] = $this->fai_release;
1319 session::set("fai_filter",$fai_filter);
1320 }
1322 if(is_object($this->CopyPasteHandler)){
1323 $this->CopyPasteHandler->save_object();
1324 }
1325 }
1328 function copyPasteHandling_from_queue($s_action,$s_entry)
1329 {
1330 /* Check if Copy & Paste is disabled */
1331 if(!is_object($this->CopyPasteHandler)){
1332 return("");
1333 }
1335 $ui = get_userinfo();
1337 /* Add a single entry to queue */
1338 if($s_action == "copy"){
1340 /* Cleanup object queue */
1341 $this->CopyPasteHandler->cleanup_queue();
1342 $entry = $this->objects[$s_entry];
1343 $a_setup = $this->get_type($entry);
1344 $dn = $entry['dn'];
1346 if($ui->is_copyable($dn,"fai",$a_setup[1])){
1347 $this->CopyPasteHandler->add_to_queue($dn,$s_action,$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1348 }
1349 }
1351 /* Add entries to queue */
1352 if($s_action == "copy_multiple"){
1354 /* Cleanup object queue */
1355 $this->CopyPasteHandler->cleanup_queue();
1357 /* Add new entries to CP queue */
1358 foreach($this->list_get_selected_items() as $id){
1360 /* Cleanup object queue */
1361 $entry = $this->objects[$id];
1362 $a_setup = $this->get_type($entry);
1363 $dn = $entry['dn'];
1365 if($s_action == "copy_multiple" && $ui->is_copyable($dn,"fai",$a_setup[1])){
1366 $this->CopyPasteHandler->add_to_queue($dn,"copy",$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1367 }
1368 }
1369 }
1371 /* Start pasting entries */
1372 if($s_action == "editPaste" && !($this->lock_type == "freeze" && !$this->allow_freeze_object_attach)){
1373 $this->start_pasting_copied_objects = TRUE;
1374 }
1376 /* Return C&P dialog */
1377 if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
1379 /* Get dialog */
1380 $this->CopyPasteHandler->SetVar("parent",$this);
1381 $data = $this->CopyPasteHandler->execute();
1383 FAI::save_release_changes_now();
1385 /* Return dialog data */
1386 if(!empty($data)){
1387 return($data);
1388 }
1389 }
1391 /* Automatically disable status for pasting */
1392 if(!$this->CopyPasteHandler->entries_queued()){
1393 $this->start_pasting_copied_objects = FALSE;
1394 }
1395 return("");
1396 }
1399 /* Check if the given FAI class is used in this release
1400 */
1401 static function check_class_name($oc,$name,$dn)
1402 {
1403 $base = FAI::get_release_dn($dn);
1405 if($oc == "FAIprofile"){
1406 $f = "";
1407 $ocs = array("FAIprofile","FAItemplate","FAIhook","FAIpartitionTable","FAIpackageList","FAIscript","FAIvariable");
1408 foreach($ocs as $oc){
1409 $f .= "(objectClass=".$oc.")";
1410 }
1411 $res = FAI::get_all_objects_for_given_base($base,"(|".$f.")",TRUE);
1412 }else{
1413 $res = FAI::get_all_objects_for_given_base($base,"(objectClass=".$oc.")",TRUE);
1414 }
1415 $delete = array();
1416 $used = array();
1417 foreach($res as $object){
1418 $used[$object['cn'][0]]= $object['cn'][0];
1419 }
1420 return($used);
1421 }
1424 /* Return plugin informations for acl handling */
1425 static function plInfo()
1426 {
1427 return (array(
1428 "plShortName" => _("FAI releases"),
1429 "plDescription" => _("FAI release management"),
1430 "plSelfModify" => FALSE,
1431 "plDepends" => array(),
1432 "plPriority" => 0,
1433 "plSection" => array("administration"),
1434 "plCategory" => array("fai"=> array("description" => _("FAI"),
1435 "objectClass" => "FAIclass")),
1436 "plProvidedAcls"=> array()));
1437 }
1438 }
1439 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1440 ?>