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 <input type='hidden' name='php_c_check' value='1'>
806 </form></div>";
808 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
810 /* Print footer to have valid html */
811 echo "</body></html>";
813 $this->dispNewFreeze = false;
815 /* Postcreate */
817 /* Assign possible attributes */
818 $this->lock_type = $type;
819 $this->lock_name = $name;
820 $this->lock_dn = $baseToUse;
821 $this->postcreate();
824 /* Send daemon event to reload the fai release database
825 */
826 if(class_available("DaemonEvent") && class_available("gosaSupportDaemon")){
827 $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
828 if(isset($events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'])){
829 $evt = $events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'];
830 $tmp = new $evt['CLASS_NAME']($this->config);
831 $tmp->set_type(TRIGGERED_EVENT);
832 $tmp->add_targets(array("GOSA"));
833 $o_queue = new gosaSupportDaemon();
834 if(!$o_queue->append($tmp)){
835 msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
836 }
837 }
838 }else{
839 trigger_error("Unknown class DaemonEvent / gosaSupportDaemon");
840 msg_dialog::display(_("Fatal error"),
841 "Daemon events called but classes where not accessible, DaemonEvent gosaSupportDaemon",
842 FATAL_ERROR_DIALOG);
843 }
844 exit();
845 }
846 }
848 /****************
849 Display dialog to enter new Branch name
850 ****************/
852 /* Check if we have a post create method configured
853 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
854 */
855 if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
856 if(($s_action == "branch_branch")||($this->dispNewBranch)){
857 if(!preg_match("/c/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
858 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
859 }else{
860 $this->dispNewBranch=true;
861 $smarty->assign("iframe",false);
862 $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
863 return($display);
864 }
865 }
866 }
869 /****************
870 Display dialog to enter new Freeze name
871 ****************/
873 /* Check if we have a post create method configured
874 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
875 */
876 if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
877 if(($s_action == "freeze_branch")||($this->dispNewFreeze)){
878 if(!preg_match("/c/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
879 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
880 }else{
881 $this->dispNewFreeze = true;
882 $smarty->assign("iframe",false);
883 $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
884 return($display);
885 }
886 }
887 }
890 /****************
891 Create a new object
892 ****************/
894 $types = array( "new_partition" => "FAIpartitionTable",
895 "new_script" => "FAIscript",
896 "new_hook" => "FAIhook",
897 "new_variable" => "FAIvariable",
898 "new_template" => "FAItemplate",
899 "new_package" => "FAIpackageList");
900 $types_i18n = array( "new_partition" => _("partition table"),
901 "new_script" => _("script"),
902 "new_hook" => _("hook"),
903 "new_variable" => _("variable"),
904 "new_template" => _("template"),
905 "new_package" => _("package list"));
907 if(isset($types[$s_action])){
908 $acl = $this->ui->get_permissions($this->acl_base,"fai/".$type_acl_mapping[$types[$s_action]]);
909 if(preg_match("/c/",$acl)){
910 $this->dialog = new askClassName($this->config,$this->dn,$this->ui,$types[$s_action]);
911 $this->dialog->parent = &$this;
912 }else{
913 msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), $types_i18n[$s_action]), ERROR_DIALOG);
914 }
915 }
917 /* New Profile */
918 if($s_action == "new_profile"){
919 $this->dn = "new" ;
921 $acl = $this->ui->get_permissions($this->acl_base,"fai/faiProfile");
922 if(preg_match("/c/",$acl)){
923 $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
924 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
925 $this->dialog->set_acl_base($this->base);
926 $this->dialog->parent = &$this;
928 $this->is_dialog = false;
929 }else{
930 msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), _("profile")), ERROR_DIALOG);
931 }
932 }
935 /****************
936 Get from ask class name dialog
937 ****************/
939 if($s_action == "select_class_name_finished"){
940 $this->dialog->save_object();
941 if(count($this->dialog->check())!=0){
942 foreach($this->dialog->check() as $msg){
943 msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
944 }
945 }elseif(isset($this->dialog->objectClass)){
946 $this->dn = "new" ;
947 $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass)));
948 $name = $this->dialog->save();
950 if(class_exists($a_setup[0])){
951 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
952 $this->dialog->set_acl_base($this->base);
953 $this->dialog->by_object[$a_setup[1]]->cn = $name;
954 $this->dialog->parent = &$this;
955 $this->is_dialog = true;
956 }
957 }
958 }
961 /****************
962 Cancel dialogs
963 ****************/
965 if(isset($_POST['edit_cancel'])){
966 $this->dialog=FALSE;
967 $this->is_dialog = false;
968 session::un_set('objectinfo');
969 $this->remove_lock();
970 }
973 /****************
974 Save sub dialogs
975 ****************/
977 /* This check if the given tab could be saved
978 * If it was possible to save it, remove dialog object.
979 * If it wasn't possible, show errors and keep dialog.
980 */
981 if((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->dialog->config))){
982 $this->dialog->save_object();
983 $msgs= $this->dialog->check();
984 if(count($msgs)!=0){
985 foreach($msgs as $msg){
986 msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
987 }
988 }else{
989 $this->dialog->save();
990 FAI::save_release_changes_now();
991 if (!isset($_POST['edit_apply'])){
992 $this->remove_lock();
993 $this->dialog=FALSE;
994 $this->is_dialog=false;
995 session::un_set('objectinfo');
996 }else{
998 /* Reinitialize tab */
999 if($this->dialog instanceof tabs){
1000 $this->dialog->re_init();
1001 }
1002 }
1003 }
1004 }
1007 /****************
1008 Display currently open dialog
1009 ****************/
1011 /* If dialog is set, but $this->is_dialog==false, then
1012 * only the "abort" button is shown, this are dialogs that must not be saved.
1013 * If is_dialog == true, we are currently editing tab objects.
1014 * Here we need both, save and cancel
1015 */
1017 if(is_object($this->dialog)){
1018 $display .= $this->dialog->execute();
1019 /* Don't show buttons if tab dialog requests this */
1021 if(isset($this->dialog->current)){
1023 $obj = $this->dialog->by_object[$this->dialog->current];
1025 if((isset($obj->is_dialog) && (!$obj->is_dialog)) || (isset($obj->dialog) && (!$obj->dialog))){
1027 $display.= "<p style=\"text-align:right\">\n";
1028 if(!$this->no_save){
1029 $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
1030 $display.= " \n";
1031 if ($this->dn != "new"){
1032 $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
1033 $display.= " \n";
1034 }
1035 }
1036 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1037 $display.= "</p>";
1038 }elseif(!isset($this->dialog->current)){
1039 $display.= "<p style=\"text-align:right\">\n";
1040 $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\"> ";
1041 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1042 $display.= "</p>";
1043 }
1044 }else{
1045 $display.= "<p style=\"text-align:right\">\n";
1046 $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\"> ";
1047 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1048 $display.= "</p>";
1050 }
1051 return($display);
1052 }
1055 /****************
1056 Dialog display
1057 ****************/
1059 /* Check if there is a snapshot dialog open */
1060 $base = $this->fai_base;
1061 if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
1062 return($str);
1063 }
1065 /* Display dialog with system list */
1066 $this->reload();
1067 $this->DivListFai->parent = &$this;
1068 $this->DivListFai->execute();
1069 $this->DivListFai->setEntries($this->objects);
1070 return($this->DivListFai->Draw());
1071 }
1074 /* Return departments, that will be included within snapshot detection */
1075 function get_used_snapshot_bases()
1076 {
1077 $tmp = array();
1078 $types = array("faiPartitionRDN","faiScriptRDN","faiTemplateRDN","faiHookRDN","faiProfileRDN","faiVariableRDN","faiPackageRDN");
1079 foreach($types as $type){
1080 $tmp[] = get_ou($type).$this->fai_release;
1081 }
1082 return($tmp);
1083 }
1086 /* Get available branches for current base */
1087 function getBranches($base = false,$prefix = "")
1088 {
1089 $ret = array("/"=>$this->fai_base);
1090 $ldap = $this->config->get_ldap_link();
1091 if(!$base){
1092 $base = $this->fai_base;
1093 }
1094 $tmp = FAI::get_all_releases_from_base($base,true);
1095 foreach($tmp as $dn => $name){
1096 $ret[$name]=$dn;
1097 }
1098 ksort($ret);
1099 $ret = array_flip($ret);
1101 return ($ret);
1102 }
1105 function list_get_selected_items()
1106 {
1107 $ids = array();
1108 foreach($_POST as $name => $value){
1109 if(preg_match("/^item_selected_[0-9]*$/",$name)){
1110 $id = preg_replace("/^item_selected_/","",$name);
1111 $ids[$id] = $id;
1112 }
1113 }
1114 return($ids);
1115 }
1118 /* reload list of objects */
1119 function reload()
1120 {
1121 /* Variable initialisation */
1122 $str = "";
1123 $Regex = $this->DivListFai->Regex;
1124 $this->objects = array();
1126 /* Get base */
1127 $base = $this->fai_base;
1128 if($this->fai_release != $this->fai_base){
1129 $br = $this->getBranches();
1130 if(isset($br[$this->fai_release])){
1131 $base = $this->fai_release;
1132 }else{
1133 $base = $this->fai_base;
1134 }
1135 }
1136 $this->base = $base;
1137 $this->set_acl_base($this->acl_base);
1139 $this->lock_type = FAI::get_release_tag(FAI::get_release_dn($base));
1141 /* Create a new list of FAI object
1142 * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ...
1143 */
1144 $ObjectTypes = array(
1145 "FAIpartitionTable" => array("OU"=> get_ou('faiPartitionRDN') , "CHKBOX"=>"ShowPartitions" ,"ACL" => "faiPartitionTable"),
1146 "FAIpackageList" => array("OU"=> get_ou('faiPackageRDN') , "CHKBOX"=>"ShowPackages" ,"ACL" => "faiPackage"),
1147 "FAIscript" => array("OU"=> get_ou('faiScriptRDN') , "CHKBOX"=>"ShowScripts" ,"ACL" => "faiScript"),
1148 "FAIvariable" => array("OU"=> get_ou('faiVariableRDN') , "CHKBOX"=>"ShowVariables" ,"ACL" => "faiVariable"),
1149 "FAIhook" => array("OU"=> get_ou('faiHookRDN') , "CHKBOX"=>"ShowHooks" ,"ACL" => "faiHook"),
1150 "FAIprofile" => array("OU"=> get_ou('faiProfileRDN') , "CHKBOX"=>"ShowProfiles" ,"ACL" => "faiProfile"),
1151 "FAItemplate" => array("OU"=> get_ou('faiTemplateRDN') , "CHKBOX"=>"ShowTemplates" ,"ACL" => "faiTemplate"));
1153 $filter = "";
1154 foreach($ObjectTypes as $key => $data){
1155 if($this->DivListFai->$data['CHKBOX']){
1156 $filter.= "(objectClass=".$key.")";
1157 }
1158 }
1159 $filter = "(&(|".$filter.")(cn=$Regex))";
1161 /* Get resolved release dependencies */
1162 $tmp = FAI::get_all_objects_for_given_base($base,$filter);
1164 /* Ge listed ldap objects */
1165 $ldap = $this->config->get_ldap_link();
1166 $ldap->cd($this->config->current['BASE']);
1168 foreach($tmp as $entry){
1170 /* Get some more informations about the object */
1171 $ldap->cat($entry['dn'], array("cn","description","objectClass","FAIclass","FAIstate","objectClass"));
1172 $object = $ldap->fetch();
1174 /* Walk through possible types */
1175 foreach($ObjectTypes as $type => $rest){
1177 $acl = $this->ui->get_permissions($object['dn'],"fai/".$rest ['ACL']);
1179 if(in_array($type,$object['objectClass']) && preg_match("/r/",$acl)){
1181 /* Prepare object */
1182 unset($object['objectClass']['count']);
1183 if(!isset($object['description'][0])){
1184 $object['description'][0]="";
1185 }
1187 /* Clean up object informations */
1188 $obj = array();
1189 $obj['cn'] = $object['cn'][0];
1190 $obj['dn'] = $object['dn'];
1191 $obj['acl'] = $acl;
1192 $obj['class'] = $rest ['ACL'];
1193 $obj['FAIstate'] = $entry['FAIstate'];
1194 $obj['description'] = $object['description'][0];
1195 $obj['objectClass'] = $object['objectClass'];
1197 $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj;
1198 $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type;
1199 }
1200 }
1201 }
1203 /* Append opsi objects, if opsi is available and if we are on the fai_base
1204 */
1205 if($this->opsi instanceof opsi && $this->opsi->enabled()){
1206 $opsi_acl = $this->ui->get_permissions($base,"opsi/opsiProperties");
1207 if(preg_match("/r/",$opsi_acl)){
1208 $err = FALSE;
1209 if(!$err && $this->DivListFai->ShowOpsiNetboot){
1210 $n_pro = $this->opsi->get_netboot_products();
1211 $err |= $this->opsi->is_error();
1212 foreach($n_pro as $name => $data){
1213 $entry = array("cn" => $name,
1214 "description" => $data['DESC'],
1215 "type" => "opsi_netboot");
1216 $this->objects[$name."_opsi_netboot"] = $entry;
1217 }
1218 }
1219 if(!$err && $this->DivListFai->ShowOpsiLocal){
1220 $l_pro = $this->opsi->get_local_products();
1221 $err |= $this->opsi->is_error();
1222 foreach($l_pro as $name => $data){
1223 $entry = array("cn" => $name,
1224 "description" => $data['DESC'],
1225 "type" => "opsi_local");
1226 $this->objects[$name."_opsi_local"] = $entry;
1227 }
1228 }
1229 if($err){
1230 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
1231 }
1232 }
1233 }
1235 ksort($this->objects);
1236 reset ($this->objects);
1238 /* use numeric index, thats a bit more secure */
1239 $tmp0 = array();
1240 foreach($this->objects as $obj){
1241 $tmp0[]= $obj;
1242 }
1243 $this->objects = array();
1244 $this->objects = $tmp0;
1245 }
1247 function remove_lock()
1248 {
1249 if (isset($this->dn)){
1250 del_lock ($this->dn);
1251 }
1252 if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
1253 del_lock ($this->dns);
1254 }
1255 }
1257 function get_type($array){
1258 if(in_array("FAIpartitionTable",$array['objectClass'])){
1259 return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS"));
1260 }
1261 if(in_array("FAIscript",$array['objectClass'])){
1262 return(array("tabsScript","faiScript","FAISCRIPTTABS"));
1263 }
1264 if(in_array("FAItemplate",$array['objectClass'])){
1265 return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS"));
1266 }
1267 if(in_array("FAIhook",$array['objectClass'])){
1268 return(array("tabsHook","faiHook","FAIHOOKTABS"));
1269 }
1270 if(in_array("FAIvariable",$array['objectClass'])){
1271 return(array("tabsVariable","faiVariable","FAIVARIABLETABS"));
1272 }
1273 if(in_array("FAIprofile",$array['objectClass'])){
1274 return(array("tabsProfile","faiProfile","FAIPROFILETABS"));
1275 }
1277 if(in_array("FAIpackageList",$array['objectClass'])){
1278 return(array("tabsPackage","faiPackage","FAIPACKAGETABS"));
1279 }
1280 }
1282 function CheckNewBranchName($name,$base)
1283 {
1284 $f = $this->fai_release;
1285 if($name == ""){
1286 return(false);
1287 }elseif(in_array($name,$this->getBranches($f))) {
1288 return(false);
1289 }elseif(tests::is_department_name_reserved($name,$base)){
1290 return(false);
1291 }
1292 return(true);
1293 }
1295 function save_object()
1296 {
1297 $this->DivListFai->save_object();
1299 /* Get posted release */
1300 $r_releases = array_flip($this->getBranches());
1301 if(isset($_POST['fai_release']) && isset($r_releases[get_post('fai_release')])){
1303 /* Ensure that we have a valid release selected */
1304 if(!isset($r_releases[get_post('fai_release')])){
1305 msg_dialog::display(_("Warning"),_("The selected release is not available anymore. All triggered actions are skipped."));
1306 $_POST = array();
1307 $plug =$_GET['plug'];
1308 $_GET = array("plug" => $plug);
1309 $this->fai_release = $this->fai_base;
1310 }else{
1311 $this->fai_release = $r_releases[get_post('fai_release')];
1312 }
1314 $fai_filter = session::get("fai_filter");
1315 $fai_filter['fai_release'] = $this->fai_release;
1316 session::set("fai_filter",$fai_filter);
1317 }
1319 if(is_object($this->CopyPasteHandler)){
1320 $this->CopyPasteHandler->save_object();
1321 }
1322 }
1325 function copyPasteHandling_from_queue($s_action,$s_entry)
1326 {
1327 /* Check if Copy & Paste is disabled */
1328 if(!is_object($this->CopyPasteHandler)){
1329 return("");
1330 }
1332 $ui = get_userinfo();
1334 /* Add a single entry to queue */
1335 if($s_action == "copy"){
1337 /* Cleanup object queue */
1338 $this->CopyPasteHandler->cleanup_queue();
1339 $entry = $this->objects[$s_entry];
1340 $a_setup = $this->get_type($entry);
1341 $dn = $entry['dn'];
1343 if($ui->is_copyable($dn,"fai",$a_setup[1])){
1344 $this->CopyPasteHandler->add_to_queue($dn,$s_action,$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1345 }
1346 }
1348 /* Add entries to queue */
1349 if($s_action == "copy_multiple"){
1351 /* Cleanup object queue */
1352 $this->CopyPasteHandler->cleanup_queue();
1354 /* Add new entries to CP queue */
1355 foreach($this->list_get_selected_items() as $id){
1357 /* Cleanup object queue */
1358 $entry = $this->objects[$id];
1359 $a_setup = $this->get_type($entry);
1360 $dn = $entry['dn'];
1362 if($s_action == "copy_multiple" && $ui->is_copyable($dn,"fai",$a_setup[1])){
1363 $this->CopyPasteHandler->add_to_queue($dn,"copy",$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1364 }
1365 }
1366 }
1368 /* Start pasting entries */
1369 if($s_action == "editPaste" && !($this->lock_type == "freeze" && !$this->allow_freeze_object_attach)){
1370 $this->start_pasting_copied_objects = TRUE;
1371 }
1373 /* Return C&P dialog */
1374 if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
1376 /* Get dialog */
1377 $this->CopyPasteHandler->SetVar("parent",$this);
1378 $data = $this->CopyPasteHandler->execute();
1380 FAI::save_release_changes_now();
1382 /* Return dialog data */
1383 if(!empty($data)){
1384 return($data);
1385 }
1386 }
1388 /* Automatically disable status for pasting */
1389 if(!$this->CopyPasteHandler->entries_queued()){
1390 $this->start_pasting_copied_objects = FALSE;
1391 }
1392 return("");
1393 }
1396 /* Check if the given FAI class is used in this release
1397 */
1398 static function check_class_name($oc,$name,$dn)
1399 {
1400 $base = FAI::get_release_dn($dn);
1402 if($oc == "FAIprofile"){
1403 $f = "";
1404 $ocs = array("FAIprofile","FAItemplate","FAIhook","FAIpartitionTable","FAIpackageList","FAIscript","FAIvariable");
1405 foreach($ocs as $oc){
1406 $f .= "(objectClass=".$oc.")";
1407 }
1408 $res = FAI::get_all_objects_for_given_base($base,"(|".$f.")",TRUE);
1409 }else{
1410 $res = FAI::get_all_objects_for_given_base($base,"(objectClass=".$oc.")",TRUE);
1411 }
1412 $delete = array();
1413 $used = array();
1414 foreach($res as $object){
1415 $used[$object['cn'][0]]= $object['cn'][0];
1416 }
1417 return($used);
1418 }
1421 /* Return plugin informations for acl handling */
1422 static function plInfo()
1423 {
1424 return (array(
1425 "plShortName" => _("FAI releases"),
1426 "plDescription" => _("FAI release management"),
1427 "plSelfModify" => FALSE,
1428 "plDepends" => array(),
1429 "plPriority" => 0,
1430 "plSection" => array("administration"),
1431 "plCategory" => array("fai"=> array("description" => _("FAI"),
1432 "objectClass" => "FAIclass")),
1433 "plProvidedAcls"=> array()));
1434 }
1435 }
1436 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1437 ?>