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();
111 /* Initialise vars and smarty */
112 $smarty = get_smarty();
113 $smarty->assign("BranchName","");
115 $display = "";
116 $s_action = "";
117 $s_entry = "";
118 $no_save = FALSE; // hide Apply / Save buttons
120 /* If an entry was locked, these vars will be stored in a session to allow direct edit */
121 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$/"));
123 /****************
124 Handle posts
125 ****************/
127 /* Check ImageButton posts
128 * Create new tab ich new_xx is posted
129 */
130 $posts = array( "/^remove_branch/" =>"remove_branch",
131 "/^branch_branch/" =>"branch_branch",
132 "/^freeze_branch/" =>"freeze_branch",
134 "/^create_partition/i" =>"new_partition",
135 "/^create_script/i" =>"new_script",
136 "/^create_hook/i" =>"new_hook",
137 "/^create_variable/i" =>"new_variable",
138 "/^create_template/i" =>"new_template",
139 "/^create_package/i" =>"new_package",
140 "/^create_profile/i" =>"new_profile",
142 "/^edit_continue$/" => "select_class_name_finished",
144 "/^group_edit/" => "group_edit",
145 "/^group_remove/" => "group_remove");
146 foreach($_POST as $name => $value){
147 foreach($posts as $reg => $act ){
148 if(preg_match($reg,$name)){
149 $s_action = $act;
150 $s_entry = ltrim(preg_replace($reg,"",$name),"_");
151 $s_entry = preg_replace("/_.*$/","",$s_entry);
152 break;
153 }
154 }
155 if(preg_match("/^edit_[0-9]*_.*$/",$name)){
156 $i_entryID = preg_replace("/^edit_([0-9]*)_.*$/i","\\1",$name);
157 $s_entryType= preg_replace("/^edit_[0-9]*_([^_]*)_.*$/i","\\1",$name);
158 $s_action = "edit";
159 break;
160 }elseif(preg_match("/^entry_delete_.*/",$name)){
161 $s_entry = preg_replace("/^entry_delete_/","",$name);
162 $s_entry = preg_replace("/_.*$/","",$s_entry);
163 $s_action = "delete";
164 break;
165 }
167 /* Get posts from opsi onjects
168 */
169 if($this->opsi instanceof opsi && $this->opsi->enabled()){
170 if(preg_match("/^entry_opsi_edit_/",$name)){
171 $s_entry = preg_replace("/^entry_opsi_edit_([0-9]*).*$/","\\1",$name);
172 $s_action = "opsi_edit";
173 break;
174 }
175 }
176 }
178 /* Get posts from opsi objects
179 */
180 if($this->opsi instanceof opsi && $this->opsi->enabled() && isset($_GET['edit_opsi_entry'])){
181 $s_entry = $_GET['edit_opsi_entry'];
182 $s_action = "opsi_edit";
183 }
185 if(isset($_GET['act']) && $_GET['act'] == "freeze_branch"){
186 $s_action = "freeze_branch";
187 }
188 if(isset($_GET['act']) && $_GET['act'] == "branch_branch"){
189 $s_action = "branch_branch";
190 }
191 if(isset($_GET['act']) && $_GET['act'] == "remove_branch"){
192 $s_action = "remove_branch";
193 }
195 if((isset($_POST['CancelBranchName'])) || (isset($_POST['CloseIFrame']))){
196 $this->dispNewBranch = false;
197 $this->dispNewFreeze = false;
198 }
201 $type_acl_mapping = array(
202 "FAIpartitionTable" => "faiPartitionTable",
203 "FAIpackageList" => "faiPackage",
204 "FAIscript" => "faiScript",
205 "FAIvariable" => "faiVariable",
206 "FAIhook" => "faiHook",
207 "FAIprofile" => "faiProfile",
208 "FAItemplate" => "faiTemplate");
211 /* handle C&P from layers menu */
212 if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){
213 $s_action = "copy_multiple";
214 }
215 if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){
216 $s_action = "cut_multiple";
217 }
218 if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){
219 $s_action = "editPaste";
220 }
222 /* Create options */
223 if(isset($_POST['menu_action']) && preg_match("/^Create_/",$_POST['menu_action'])){
224 $s_action = "new_".preg_replace("/^Create_/","",$_POST['menu_action']);;
225 $s_entry = preg_replace("/^Create_/","",$_POST['menu_action']);
226 }
228 /* handle remove from layers menu */
229 if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){
230 $s_action = "del_multiple";
231 }
234 if(!empty($s_action)){
235 $this->no_save = $no_save;
236 }
238 /********************
239 Copy & Paste
240 ********************/
242 /* Display the copy & paste dialog, if it is currently open */
243 $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
244 if($ret){
245 return($ret);
246 }
249 /*******************
250 Opsi extension
251 *******************/
253 if($this->opsi instanceof opsi && $this->opsi->enabled()){
254 if($s_action == "opsi_edit"){
255 $name = $this->objects[$s_entry]['cn'];
256 $cfg = $this->opsi->get_product_properties($name);
257 $this->dialog = new tabs_opsiProdConfig($this->config, $this->config->data['TABS']['OPSIPRODCONFIG'],"","opsi");
258 if(isset($this->dialog->by_object['opsiProperties'])){
259 $this->dialog->by_object['opsiProperties']->set_cfg($cfg);
260 $this->dialog->by_object['opsiProperties']->set_product($name);
261 }else{
262 trigger_error("Unknown tab, please check config.");
263 }
264 }
265 if($this->dialog instanceof tabs_opsiProdConfig && isset($_POST['cancel_properties'])){
266 $this->dialog = NULL;
267 }
268 if($this->dialog instanceof tabs_opsiProdConfig && isset($_POST['save_properties'])){
269 $this->dialog->save_object();
270 $op = $this->dialog->by_object['opsiProperties'];
271 $name = $op->get_product();
272 $cfg = $op->get_cfg();
273 $this->opsi->set_product_properties($name,$cfg);
274 if($this->opsi->is_error()){
275 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
276 }else{
277 $this->dialog = NULL;
278 }
279 }
280 if($this->dialog instanceof tabs_opsiProdConfig){
281 $this->dialog->save_object();
282 return($this->dialog->execute());
283 }
284 }
287 /****************
288 Delete a group of FAI objects
289 (Group = same name & different classes)
290 ****************/
292 if($s_action == "group_remove"){
293 if(isset($this->objects[$s_entry])){
294 $group = $this->objects[$s_entry];
295 $this->dialog = new faiGroupHandle($group,"remove");
297 }
298 }elseif($s_action == "group_edit"){
299 if(isset($this->objects[$s_entry])){
300 $group = $this->objects[$s_entry];
301 $this->dialog = new faiGroupHandle($group,"edit");
302 }
303 }
304 if($this->dialog instanceOf faiGroupHandle){
305 $this->dialog->save_object();
306 if($this->dialog->is_open()){
307 return($this->dialog->execute());
308 }
309 if($this->dialog->is_canceled() || isset($_POST['cancel_lock'])){
310 $this->dialog = FALSE;
311 }
312 }
315 /********************
316 Delete MULTIPLE entries confirmed
317 ********************/
319 /* Confirmation for deletion has been passed. Users should be deleted. */
320 if (isset($_POST['delete_multiple_fai_object_confirm'])){
322 /* Find out more about the object type */
323 $ldap = $this->config->get_ldap_link();
325 /* Remove user by user and check acls before removeing them */
326 foreach($this->dns as $key => $dn){
328 $ldap->cat($dn, array('objectClass'));
329 $attrs = $ldap->fetch();
330 $type = $this->get_type($attrs);
332 $acl = $this->ui->get_permissions($dn,"fai/".$type[1]);
333 if(preg_match("/d/",$acl)){
335 $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $dn,"fai");
336 $this->dialog->parent = &$this;
337 $this->dialog->set_acl_base($dn);
338 $this->dialog->by_object[$type[1]]->remove_from_parent ();
339 unset ($this->dialog);
340 $this->dialog= FALSE;
341 $to_del = FAI::clean_up_releases($dn);
342 FAI::save_release_changes_now();
344 foreach($to_del as $dn){
345 $ldap->rmdir_recursive($dn);
346 }
348 } else {
350 /* Normally this shouldn't be reached, send some extra
351 logs to notify the administrator */
352 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
353 new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion.");
354 }
355 }
357 /* Remove lock file after successfull deletion */
358 $this->remove_lock();
359 $this->dns = array();
360 $this->dialog = FALSE;
361 }
364 /****************
365 Delete confirme dialog
366 ****************/
368 if ($s_action=="del_multiple" ||
369 $this->dialog instanceOf faiGroupHandle && $this->dialog->get_mode() == "remove"){
371 /* Collect objects to delete and check if object is freezed
372 */
373 $dns = array();
374 $errors = "";
375 $this->dns = array();
376 if($this->dialog instanceOf faiGroupHandle){
377 $to_delete = $this->dialog->get_selected();
378 foreach($to_delete as $obj){
379 if(!preg_match('/^freeze/', $obj['FAIstate'])){
380 $this->dns[] = $obj['dn'];
381 }else{
382 $errors .= $obj['cn'].", ";
383 }
384 }
385 }else{
386 $ids = $this->list_get_selected_items();
387 foreach($ids as $id){
388 foreach($this->objects[$id] as $obj){
389 if(!preg_match('/^freeze/', $obj['FAIstate'])){
390 $this->dns[] = $obj['dn'];
391 }else{
392 $errors .= $obj['cn'].", ";
393 }
394 }
395 }
396 }
397 if($errors != ""){
398 msg_dialog::display(_("Branch locked"),sprintf(_("The following entries are locked, you can't remove them %s."),
399 "<br><br>".trim($errors,", ")),INFO_DIALOG);
400 }
402 if(count($this->dns)){
403 if ($user= get_multiple_locks($this->dns)){
404 return(gen_locked_message($user,$this->dns));
405 }
406 if(count($this->dns)){
407 $dns_names = array();
408 foreach($this->dns as $dn){
409 add_lock ($dn, $this->ui->dn);
410 $dns_names[] = LDAP::fix($dn);
411 }
412 /* Lock the current entry, so nobody will edit it during deletion */
413 $smarty->assign("warning",msgPool::deleteInfo($dns_names,_("FAI object")));
414 $smarty->assign("multiple", true);
415 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
416 }
417 }
418 }
422 /********************
423 Delete MULTIPLE entries Canceled
424 ********************/
426 /* Remove lock */
427 if(isset($_POST['delete_multiple_fai_object_cancel'])){
428 $this->remove_lock();
429 $this->dns = array();
430 }
433 /****************
434 Delete aborted
435 ****************/
437 /* Delete canceled? */
438 if (isset($_POST['delete_cancel'])){
439 $this->remove_lock();
440 }
443 /****************
444 Delete confirmed
445 ****************/
447 /* Deletion was confirmed, so delete this entry
448 */
449 if (isset($_POST['delete_terminal_confirm'])){
451 /* Some nice guy may send this as POST, so we've to check
452 for the permissions again. */
454 /* Find out more about the object type */
455 $ldap = $this->config->get_ldap_link();
456 $ldap->cat($this->dn, array('objectClass'));
457 if($ldap->count()){
458 $attrs = $ldap->fetch();
459 $type = $this->get_type($attrs);
461 $acl = $this->ui->get_permissions($this->dn,"fai/".$type[1]);
462 if(preg_match("/d/",$acl)){
464 $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $this->dn,"fai");
465 $this->dialog->set_acl_base($this->dn);
466 $this->dialog->parent = &$this;
467 $this->dialog->by_object[$type[1]]->remove_from_parent ();
468 unset ($this->dialog);
469 $this->dialog= FALSE;
470 $to_del = FAI::clean_up_releases($this->dn);
471 FAI::save_release_changes_now();
473 foreach($to_del as $dn){
474 $ldap->rmdir_recursive($dn);
475 }
477 } else {
479 /* Normally this shouldn't be reached, send some extra
480 logs to notify the administrator */
481 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
482 new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion.");
483 }
485 }else{
486 msg_dialog::display(_("Error"), sprintf(_("Cannot delete '%s': object does not exist!"), $this->dn) , ERROR_DIALOG);
487 }
489 /* Remove lock file after successfull deletion */
490 $this->remove_lock();
491 }
494 /****************
495 Edit entry
496 ****************/
498 if(($s_action == "edit") || $this->dialog instanceOf faiGroupHandle && $this->dialog->get_mode() == "edit"){
500 $entry = array();
501 if($this->dialog instanceOf faiGroupHandle){
502 $entries = $this->dialog->get_selected();
503 $entry = array_pop($entries);
504 }elseif(isset($this->objects[$i_entryID][$s_entryType])){
505 $entry = $this->objects[$i_entryID][$s_entryType];
506 }
508 if(count($entry)){
509 $a_setup = $this->get_type($entry);
510 $this->dn = $entry['dn'];
512 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
513 if (($user= get_lock($this->dn)) != ""){
514 return(gen_locked_message ($user, $this->dn, TRUE));
515 }
516 add_lock ($this->dn, $this->ui->dn);
518 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
519 $this->dialog->parent = &$this;
520 $this->dialog->by_object[$a_setup[1]]->FAIstate = $entry['FAIstate'];
521 $this->dialog->set_acl_base($this->dn);
522 $this->is_dialog = true;
523 session::set('objectinfo',$this->dn);
524 }
525 }
528 /* Branch handling
529 09.01.2006
530 */
532 /****************
533 Remove branch
534 ****************/
536 /* Remove branch
537 */
538 if($s_action == "remove_branch"){
539 $base= $this->fai_release;
541 /* Check if we have a post remove method configured
542 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
543 */
544 if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
545 /* Load permissions for selected 'dn' and check if
546 we're allowed to remove this 'dn' */
547 if(preg_match("/d/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
548 $smarty->assign("release_hidden",base64_encode($this->fai_release));
549 $smarty->assign("info", msgPool::deleteInfo(LDAP::fix($this->fai_release),_("FAI branch/freeze")));
550 return($smarty->fetch(get_template_path('remove_branch.tpl',TRUE)));
551 } else {
552 msg_dialog::display(_("Permission error"), _("You have no permission to delete this release!"), ERROR_DIALOG);
553 }
554 }
555 }
558 /****************
559 Remove branch confirmed
560 ****************/
562 if(isset($_POST['delete_branch_confirm'])){
564 /* Check if we have a post remove method configured
565 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
566 */
567 if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
569 if(!isset($_POST['release_hidden']) || base64_decode($_POST['release_hidden']) != $this->fai_release){
570 msg_dialog::display(_("Warning"),_("Release remove aborted because the release name check failed!"));
571 }else{
573 $bb = $this->fai_release;
574 if(!isset($ldap)){
575 $ldap = $this->config->get_ldap_link();
576 }
578 $br = $this->getBranches();
580 if(isset($br[$bb]) && preg_match("/d/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
581 $name = $br[$bb];
583 $ldap->cd($bb);
584 $ldap->recursive_remove();
585 $ldap->cd(preg_replace('/,'.preg_quote(get_ou('faiBaseRDN'), '/').'/', ','.get_ou('applicationRDN'), $bb));
586 $ldap->recursive_remove();
587 $ldap->cd(preg_replace('/,'.preg_quote(get_ou('faiBaseRDN'), '/').'/', ','.get_ou('mimetypeRDN'), $bb));
588 $ldap->recursive_remove();
590 /* Search for all groups with configured application menus.
591 - First search all groups, to ensure that we only remove entries form whithin groups.
592 - The search für menu configuration for the specified release and collect all those dns.
593 - Remove entries
594 */
595 $release_ou = preg_replace("/".preg_quote(get_ou("faiBaseRDN"), '/').".*$/","",$bb);
596 $ldap->cd($this->config->current['BASE']);
597 $ldap->search("(objectClass=posixGroup)",array("dn"));
599 /* Collect all group dns
600 */
601 $groups = array();
602 while($attrs = $ldap->fetch()){
603 $groups[] = $attrs['dn'];
604 }
606 /* Collect all group menu release dns that match the release we have removed
607 */
608 $dns = array();
609 foreach($groups as $dn){
610 $ldap->cd($dn);
611 $ldap->search("(objectClass=FAIbranch)",array("dn"));
612 while($attrs = $ldap->fetch()){
613 if(preg_match("/^".preg_quote($release_ou, '/')."/",$attrs['dn'])){
614 $dns[] = $attrs['dn'];
615 }
616 }
617 }
619 /* Finally remove collected release dns
620 */
621 foreach($dns as $dn){
622 $ldap->cd($dn);
623 $ldap->recursive_remove();
624 }
626 /* Post remove */
627 $this->fai_release = $this->fai_base;
628 $this->lock_name = $name;
629 $this->lock_dn = $bb;
630 $this->postremove();
632 $fai_filter = session::get("fai_filter");
633 $fai_filter['fai_release'] = $this->fai_release;
634 session::set("fai_filter",$fai_filter);
636 new log("remove","fai/".get_class($this),$br[$bb],array(),"Release removed");
637 }
638 }
639 }
640 }
643 /****************
644 Create a new branch "insert Name"
645 ****************/
647 if((isset($_POST['UseBranchName']))&&(($this->dispNewBranch)||($this->dispNewFreeze))){
648 session::set('LASTPOST',$_POST);
650 if($this->dispNewBranch){
651 $type = "branch";
652 }else{
653 $type = "freeze";
654 }
656 /* Check branch name */
657 $name = $_POST['BranchName'];
658 $is_ok = true;
659 $smarty->assign("BranchName",$name);
660 $base= $this->fai_base;
662 /* Check used characters */
663 if(!preg_match("/^[0-9a-z\.]*$/",$name)){
664 msg_dialog::display(_("Error"), msgPool::invalid(_("Name"),$name,"/[0-9a-z\.]/"), ERROR_DIALOG);
665 $is_ok = false;
666 }
668 /* Check if this name is already in use */
669 if(!$this->CheckNewBranchName($_POST['BranchName'],$this->fai_release)){
670 msg_dialog::display(_("Error"), msgPool::duplicated(_("Name")), ERROR_DIALOG);
671 $is_ok = false;
672 }
674 if($is_ok){
676 if(session::is_set('LASTPOST')){
677 $LASTPOST = session::get('LASTPOST');
678 }else{
679 $LASTPOST = array();
680 }
681 $LASTPOST['base'] = $base;
682 $LASTPOST['type'] = $type;
683 session::set('LASTPOST',$LASTPOST);
684 $smarty->assign("iframe", true);
685 $smarty->assign("plugID", $_GET['plug']);
686 $display = $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
687 return($display);
688 }
689 }
692 /****************
693 Create a new branch
694 ****************/
696 if(isset($_GET['PerformBranch'])){
698 if(!preg_match("/c/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
699 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
700 }else{
702 /* In order to see error messages we have to reset the error handler.
703 Due to the exit();
704 */
705 restore_error_handler();
707 /* Create it know */
708 $this->dispNewBranch = false;
709 $this->dispNewFreeze = false;
711 $LASTPOST = session::get('LASTPOST');
712 $base = $LASTPOST['base'];
713 $_POST = session::get('LASTPOST');
714 $name = $_POST['BranchName'];
716 $type = $LASTPOST['type'];
717 $ldap = $this->config->get_ldap_link();
719 $baseToUse = $base;
720 if($this->fai_release != $this->fai_base){
721 $baseToUse = $this->fai_release;
722 }
724 /* Create new Release name to be able to set faidebianRelease for FAIpackageList */
726 $CurrentReleases = $this->getBranches();
727 $NewReleaseName = $name;
728 if(isset($CurrentReleases[$this->fai_release])) {
729 if($this->fai_release != $this->fai_base){
730 $NewReleaseName = $CurrentReleases[$this->fai_release]."/".$name;
731 $NewReleaseName = preg_replace("#\/#","/",$NewReleaseName);
732 }else{
733 $NewReleaseName = $name;
734 }
735 }
737 $appsrc = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('applicationRDN'),$baseToUse);
738 $appdst = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('applicationRDN'),"ou=".$name.",".$baseToUse) ;
740 $mimesrc = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('mimetypeRDN'),$baseToUse);
741 $mimedst = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('mimetypeRDN'),"ou=".$name.",".$baseToUse) ;
743 /* Check if source depeartments exist */
744 foreach(array($baseToUse,$appsrc,$mimesrc) as $dep){
745 $ldap->cd($this->config->current['BASE']);
746 $ldap->cat($dep);
747 if(!$ldap->count()){
748 $ldap->create_missing_trees($dep);
749 }
750 }
752 /* Print header to have styles included */
753 echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
754 <html>
755 <head>
756 <title></title>
757 <style type="text/css">@import url("themes/default/style.css");</style>
758 <script language="javascript" src="include/focus.js" type="text/javascript"></script>
759 </head>
760 <body style="background: none;margin:3px;color:black">
761 ';
763 new log("create","fai/".get_class($this),$NewReleaseName,array(),"New $type created");
765 /* Duplicate group application releases
766 */
767 FAI::copy_FAI_group_releases($CurrentReleases[$this->fai_release],$name,$type);
769 /* Duplicate applications
770 */
771 $ldap->cat($appsrc,array("dn")) ;
772 if($ldap->count()){
773 $ldap->cd ($appdst);
774 $ldap->recursive_remove();
775 FAI::copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true);
776 }
778 /* Duplicate mime types
779 */
780 $ldap->cat($mimesrc,array("dn")) ;
781 if($ldap->count()){
782 $ldap->cd ($mimedst);
783 $ldap->recursive_remove();
784 FAI::copy_FAI_resource_recursive($mimesrc,$mimedst,$NewReleaseName,$type,true);
785 }
787 $attr = array();
788 $attr['objectClass'] = array("organizationalUnit","FAIbranch");
789 $attr['ou'] = $name;
790 $attr['FAIstate'] = $type;
791 $ldap->cd($this->config->current['BASE']);
792 $ldap->cd("ou=".$name.",".$baseToUse);
793 $ldap->cat("ou=".$name.",".$baseToUse);
794 if($ldap->count()){
795 $ldap->modify($attr);
796 }else{
797 $ldap->add($attr);
798 }
800 /* Duplicate fai objects
801 */
802 // $ldap->cd ("ou=".$name.",".$baseToUse);
803 // $ldap->recursive_remove();
804 // FAI::copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,$NewReleaseName,$type,true);
806 echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
807 <br><input type='submit' name='CloseIFrame' value='"._("Continue")."'>
808 <input type='hidden' name='php_c_check' value='1'>
809 </form></div>";
811 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
813 /* Print footer to have valid html */
814 echo "</body></html>";
816 $this->dispNewFreeze = false;
818 /* Postcreate */
820 /* Assign possible attributes */
821 $this->lock_type = $type;
822 $this->lock_name = $name;
823 $this->lock_dn = $baseToUse;
824 $this->postcreate();
827 /* Send daemon event to reload the fai release database
828 */
829 if(class_available("DaemonEvent") && class_available("gosaSupportDaemon")){
830 $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
831 if(isset($events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'])){
832 $evt = $events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'];
833 $tmp = new $evt['CLASS_NAME']($this->config);
834 $tmp->set_type(TRIGGERED_EVENT);
835 $tmp->add_targets(array("GOSA"));
836 $o_queue = new gosaSupportDaemon();
837 if(!$o_queue->append($tmp)){
838 msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
839 }
840 }
841 }else{
842 trigger_error("Unknown class DaemonEvent / gosaSupportDaemon");
843 msg_dialog::display(_("Fatal error"),
844 "Daemon events called but classes where not accessible, DaemonEvent gosaSupportDaemon",
845 FATAL_ERROR_DIALOG);
846 }
847 exit();
848 }
849 }
851 /****************
852 Display dialog to enter new Branch name
853 ****************/
855 /* Check if we have a post create method configured
856 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
857 */
858 if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
859 if(($s_action == "branch_branch")||($this->dispNewBranch)){
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->acl_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->acl_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(($this->dialog instanceOf tabs || $this->dialog instanceOf plugin) && $this->dialog->read_only == TRUE){
1029 $display.= "<p style=\"text-align:right\">
1030 <input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">
1031 </p>";
1032 }elseif((isset($obj->is_dialog) && (!$obj->is_dialog)) || (isset($obj->dialog) && (!$obj->dialog))){
1034 $display.= "<p style=\"text-align:right\">\n";
1035 if(!$this->no_save){
1036 $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
1037 $display.= " \n";
1038 if ($this->dn != "new"){
1039 $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
1040 $display.= " \n";
1041 }
1042 }
1043 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1044 $display.= "</p>";
1045 }elseif(!isset($this->dialog->current)){
1046 $display.= "<p style=\"text-align:right\">\n";
1047 $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\"> ";
1048 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1049 $display.= "</p>";
1050 }
1051 }else{
1052 $display.= "<p style=\"text-align:right\">\n";
1053 $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\"> ";
1054 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1055 $display.= "</p>";
1057 }
1058 return($display);
1059 }
1062 /****************
1063 Dialog display
1064 ****************/
1066 /* Check if there is a snapshot dialog open */
1067 $base = $this->fai_base;
1068 if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
1069 return($str);
1070 }
1072 /* Display dialog with system list */
1073 $this->reload();
1074 $this->DivListFai->parent = &$this;
1075 $this->DivListFai->execute();
1076 $this->DivListFai->setEntries($this->objects);
1077 return($this->DivListFai->Draw());
1078 }
1081 /* Return departments, that will be included within snapshot detection */
1082 function get_used_snapshot_bases()
1083 {
1084 $tmp = array();
1085 $types = array("faiPartitionRDN","faiScriptRDN","faiTemplateRDN","faiHookRDN","faiProfileRDN","faiVariableRDN","faiPackageRDN");
1086 foreach($types as $type){
1087 $tmp[] = get_ou($type).$this->fai_release;
1088 }
1089 return($tmp);
1090 }
1093 /* Get available branches for current base */
1094 function getBranches($base = false,$prefix = "")
1095 {
1096 $ret = array("/"=>$this->fai_base);
1097 $ldap = $this->config->get_ldap_link();
1098 if(!$base){
1099 $base = $this->fai_base;
1100 }
1101 $tmp = FAI::get_all_releases_from_base($base,true);
1102 foreach($tmp as $dn => $name){
1103 $ret[$name]=$dn;
1104 }
1105 ksort($ret);
1106 $ret = array_flip($ret);
1108 return ($ret);
1109 }
1112 function list_get_selected_items()
1113 {
1114 $ids = array();
1115 foreach($_POST as $name => $value){
1116 if(preg_match("/^item_selected_[0-9]*$/",$name)){
1117 $id = preg_replace("/^item_selected_/","",$name);
1118 $ids[$id] = $id;
1119 }
1120 }
1121 return($ids);
1122 }
1125 /* reload list of objects */
1126 function reload()
1127 {
1128 /* Variable initialisation */
1129 $str = "";
1130 $Regex = $this->DivListFai->Regex;
1131 $this->objects = array();
1133 /* Get base */
1134 $base = $this->fai_base;
1135 if($this->fai_release != $this->fai_base){
1136 $br = $this->getBranches();
1137 if(isset($br[$this->fai_release])){
1138 $base = $this->fai_release;
1139 }else{
1140 $base = $this->fai_base;
1141 }
1142 }
1143 $this->base = $base;
1144 $this->set_acl_base($this->acl_base);
1146 $this->lock_type = FAI::get_release_tag(FAI::get_release_dn($base));
1148 /* Create a new list of FAI object
1149 * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ...
1150 */
1151 $ObjectTypes = array(
1152 "FAIpartitionTable" => array("OU"=> get_ou('faiPartitionRDN') , "CHKBOX"=>"ShowPartitions" ,"ACL" => "faiPartitionTable"),
1153 "FAIpackageList" => array("OU"=> get_ou('faiPackageRDN') , "CHKBOX"=>"ShowPackages" ,"ACL" => "faiPackage"),
1154 "FAIscript" => array("OU"=> get_ou('faiScriptRDN') , "CHKBOX"=>"ShowScripts" ,"ACL" => "faiScript"),
1155 "FAIvariable" => array("OU"=> get_ou('faiVariableRDN') , "CHKBOX"=>"ShowVariables" ,"ACL" => "faiVariable"),
1156 "FAIhook" => array("OU"=> get_ou('faiHookRDN') , "CHKBOX"=>"ShowHooks" ,"ACL" => "faiHook"),
1157 "FAIprofile" => array("OU"=> get_ou('faiProfileRDN') , "CHKBOX"=>"ShowProfiles" ,"ACL" => "faiProfile"),
1158 "FAItemplate" => array("OU"=> get_ou('faiTemplateRDN') , "CHKBOX"=>"ShowTemplates" ,"ACL" => "faiTemplate"));
1160 $filter = "";
1161 foreach($ObjectTypes as $key => $data){
1162 if($this->DivListFai->$data['CHKBOX']){
1163 $filter.= "(objectClass=".$key.")";
1164 }
1165 }
1166 $filter = "(&(|".$filter.")(cn=$Regex))";
1168 /* Get resolved release dependencies */
1169 $tmp = FAI::get_all_objects_for_given_base($base,$filter);
1171 /* Ge listed ldap objects */
1172 $ldap = $this->config->get_ldap_link();
1173 $ldap->cd($this->config->current['BASE']);
1175 foreach($tmp as $entry){
1177 /* Get some more informations about the object */
1178 $ldap->cat($entry['dn'], array("cn","description","objectClass","FAIclass","FAIstate","objectClass"));
1179 $object = $ldap->fetch();
1181 /* Walk through possible types */
1182 foreach($ObjectTypes as $type => $rest){
1184 $acl = $this->ui->get_permissions($object['dn'],"fai/".$rest ['ACL']);
1186 if(in_array($type,$object['objectClass']) && preg_match("/r/",$acl)){
1188 /* Prepare object */
1189 unset($object['objectClass']['count']);
1190 if(!isset($object['description'][0])){
1191 $object['description'][0]="";
1192 }
1194 /* Clean up object informations */
1195 $obj = array();
1196 $obj['cn'] = $object['cn'][0];
1197 $obj['dn'] = $object['dn'];
1198 $obj['acl'] = $acl;
1199 $obj['class'] = $rest ['ACL'];
1200 $obj['FAIstate'] = $entry['FAIstate'];
1201 $obj['description'] = $object['description'][0];
1202 $obj['objectClass'] = $object['objectClass'];
1204 $this->objects[$obj['cn']][$type] = $obj;
1205 $this->objects[$obj['cn']][$type]['type']=$type;
1206 }
1207 }
1208 }
1210 /* Append opsi objects, if opsi is available and if we are on the fai_base
1211 */
1212 if($this->opsi instanceof opsi && $this->opsi->enabled()){
1213 $opsi_acl = $this->ui->get_permissions($base,"opsi/opsiProperties");
1214 if(preg_match("/r/",$opsi_acl)){
1215 $err = FALSE;
1216 if(!$err && $this->DivListFai->ShowOpsiNetboot){
1217 $n_pro = $this->opsi->get_netboot_products();
1218 $err |= $this->opsi->is_error();
1219 foreach($n_pro as $name => $data){
1220 $entry = array("cn" => $name,
1221 "description" => $data['DESC'],
1222 "type" => "opsi_netboot");
1223 $this->objects[$name]['opse_netboot'] = $entry;
1224 }
1225 }
1226 if(!$err && $this->DivListFai->ShowOpsiLocal){
1227 $l_pro = $this->opsi->get_local_products();
1228 $err |= $this->opsi->is_error();
1229 foreach($l_pro as $name => $data){
1230 $entry = array("cn" => $name,
1231 "description" => $data['DESC'],
1232 "type" => "opsi_local");
1233 $this->objects[$name]["opsi_local"] = $entry;
1234 }
1235 }
1236 if($err){
1237 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
1238 }
1239 }
1240 }
1242 uksort($this->objects, 'strnatcasecmp');
1243 reset ($this->objects);
1244 $this->objects = array_values($this->objects);
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 ?>