ecbfd736d2b8d5ff8f2b62d96eb4806c44fb0772
1 <?php
2 /*
3 This code is part of GOsa (https://gosa.gonicus.de)
4 Copyright (C) 2003 Cajus Pollmeier
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
22 class faiManagement extends plugin
23 {
24 /* Definitions */
25 var $plHeadline = "Software deployment";
26 var $plDescription = "Manage software packages and deployment reciepes";
27 var $plIcon = "plugins/fai/images/plugin.png";
29 /* Headpage attributes */
30 var $lock_type = ""; // should be branch/freeze
31 var $lock_name = "";
32 var $lock_dn = "";
34 /* attribute list for save action */
35 var $attributes = array("lock_type","lock_name","lock_dn"); // Attributes Managed by this plugin
36 var $objectclasses= array(); // ObjectClasses which the attributes are related to
37 var $dialog = array(); // This object contains every dialog we have currently opened
39 var $objects = array(); // This array contains all available objects shown in divlist
40 var $is_dialog = false;
42 var $dispNewBranch= false;
43 var $dispNewFreeze= false;
45 var $DivListFai;
46 var $start_pasting_copied_objects = FALSE;
47 var $CopyPasteHandler = FALSE;
49 /* Allow inserting of new elements if freezed releases
50 */
51 var $allow_freeze_object_attach = TRUE;
52 var $no_save;
53 var $acl_base ="";
54 var $fai_base ="";
55 var $fai_release ="";
56 var $acl_module = array("fai");
57 var $opsi = NULL;
59 /* construction/reconstruction
60 */
61 function faiManagement (&$config, $ui)
62 {
63 /* Set defaults */
64 $this->dn = "";
65 $this->config = $config;
66 $this->ui = $ui;
68 /* Check if the opsi plugin is installed.
69 */
70 if(class_available("opsi")){
71 $this->opsi = new opsi($this->config);;
72 }
74 /* Creat dialog object */
75 $this->DivListFai = new divListFai($this->config,$this);
77 /* Copy & Paste handler */
78 if ($this->config->boolValueIsTrue("main", "copyPaste")){
79 $this->CopyPasteHandler= new CopyPasteHandler($this->config);
80 }
82 /* Set default release
83 */
84 $this->acl_base = $this->config->current['BASE'];
85 $this->fai_base = get_ou("faiBaseRDN").$this->config->current['BASE'];
87 if(!session::is_set("fai_filter")){
89 /* Set intial release */
90 $rel = $config->search("faiManagement","DEFAULTFAIRELEASE",array("menu"));
91 $rels = array_flip($this->getBranches());
92 if(isset($rels[$rel])){
93 $rel = $rels[$rel];
94 }else{
95 $rel = $this->fai_base;
96 }
98 session::set("fai_filter",array("fai_release" => $rel));
99 }
101 $fai_filter = session::get("fai_filter");
102 $this->fai_release = $fai_filter['fai_release'];
103 }
105 function execute()
106 {
107 /* Call parent execute */
108 plugin::execute();
110 /* Initialise vars and smarty */
111 $smarty = get_smarty();
112 $smarty->assign("BranchName","");
114 $display = "";
115 $s_action = "";
116 $s_entry = "";
117 $no_save = FALSE; // hide Apply / Save buttons
119 /* If an entry was locked, these vars will be stored in a session to allow direct edit */
120 session::set('LOCK_VARS_TO_USE',array("/^edit_freeze_entry$/","/^edit_entry$/","/^id$/","/^entry_edit_/","/^entry_delete_/","/^item_selected/","/^remove_multiple_fai_objects/","/^menu_action/","/^faiGroupHandle_apply$/"));
122 /****************
123 Handle posts
124 ****************/
126 /* Check ImageButton posts
127 * Create new tab ich new_xx is posted
128 */
129 $posts = array( "/^remove_branch/" =>"remove_branch",
130 "/^branch_branch/" =>"branch_branch",
131 "/^freeze_branch/" =>"freeze_branch",
133 "/^create_partition/i" =>"new_partition",
134 "/^create_script/i" =>"new_script",
135 "/^create_hook/i" =>"new_hook",
136 "/^create_variable/i" =>"new_variable",
137 "/^create_template/i" =>"new_template",
138 "/^create_package/i" =>"new_package",
139 "/^create_profile/i" =>"new_profile",
141 "/^edit_continue$/" => "select_class_name_finished",
143 "/^group_copy/" => "group_copy",
144 "/^group_cut/" => "group_cut",
145 "/^group_edit/" => "group_edit",
146 "/^group_remove/" => "group_remove");
147 foreach($_POST as $name => $value){
148 foreach($posts as $reg => $act ){
149 if(preg_match($reg,$name)){
150 $s_action = $act;
151 $s_entry = ltrim(preg_replace($reg,"",$name),"_");
152 $s_entry = preg_replace("/_.*$/","",$s_entry);
153 break;
154 }
155 }
156 if(preg_match("/^edit_[0-9]*_.*$/",$name)){
157 $i_entryID = preg_replace("/^edit_([0-9]*)_.*$/i","\\1",$name);
158 $s_entryType= preg_replace("/^edit_[0-9]*_([^_]*)_.*$/i","\\1",$name);
159 $s_action = "edit";
160 }
161 }
163 if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id'])){
164 if(isset($this->objects[$_GET['id']])){
165 $s_action = "group_edit";
166 $s_entry = $_GET['id'];
167 }
168 }
170 foreach(array("freeze_branch" => "freeze_branch",
171 "branch_branch" => "branch_branch",
172 "remove_branch" => "remove_branch") as $from => $to){
173 if(isset($_GET['act']) && $_GET['act'] == $from){
174 $s_action = $to;
175 }
176 }
178 /* handle C&P from layer menu */
179 if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){
180 $s_action = "copy_multiple";
181 }
182 if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){
183 $s_action = "cut_multiple";
184 }
185 if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){
186 $s_action = "editPaste";
187 }
190 if((isset($_POST['CancelBranchName'])) || (isset($_POST['CloseIFrame']))){
191 $this->dispNewBranch = false;
192 $this->dispNewFreeze = false;
193 }
195 /* Create options */
196 if(isset($_POST['menu_action']) && preg_match("/^Create_/",$_POST['menu_action'])){
197 $s_action = "new_".preg_replace("/^Create_/","",$_POST['menu_action']);;
198 $s_entry = preg_replace("/^Create_/","",$_POST['menu_action']);
199 }
201 /* handle remove from layers menu */
202 if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){
203 $s_action = "del_multiple";
204 }
207 if(!empty($s_action)){
208 $this->no_save = $no_save;
209 }
212 /*******************
213 Opsi extension
214 *******************/
216 if($this->opsi instanceof opsi && $this->opsi->enabled()){
217 if($s_action == "opsi_edit"){
218 $name = $this->objects[$s_entry]['cn'];
219 $cfg = $this->opsi->get_product_properties($name);
220 $this->dialog = new tabs_opsiProdConfig($this->config, $this->config->data['TABS']['OPSIPRODCONFIG'],"","opsi");
221 if(isset($this->dialog->by_object['opsiProperties'])){
222 $this->dialog->by_object['opsiProperties']->set_cfg($cfg);
223 $this->dialog->by_object['opsiProperties']->set_product($name);
224 }else{
225 trigger_error("Unknown tab, please check config.");
226 }
227 }
228 if($this->dialog instanceof tabs_opsiProdConfig && isset($_POST['cancel_properties'])){
229 $this->dialog = NULL;
230 }
231 if($this->dialog instanceof tabs_opsiProdConfig && isset($_POST['save_properties'])){
232 $this->dialog->save_object();
233 $op = $this->dialog->by_object['opsiProperties'];
234 $name = $op->get_product();
235 $cfg = $op->get_cfg();
236 $this->opsi->set_product_properties($name,$cfg);
237 if($this->opsi->is_error()){
238 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
239 }else{
240 $this->dialog = NULL;
241 }
242 }
243 if($this->dialog instanceof tabs_opsiProdConfig){
244 $this->dialog->save_object();
245 return($this->dialog->execute());
246 }
247 }
250 /****************
251 Delete a group of FAI objects
252 (Group = same name & different classes)
253 ****************/
255 if($s_action == "group_remove"){
256 if(isset($this->objects[$s_entry])){
257 $group = $this->objects[$s_entry];
259 /* Do not allow to remove opsi products */
260 foreach(array("opsi_netboot","opsi_local") as $type){
261 if(isset($group[$type])) unset($group[$type]);
262 }
263 if(count($group)){
264 $this->dialog = new faiGroupHandle($group,"remove");
265 }
266 }
267 }elseif($s_action == "group_edit"){
268 if(isset($this->objects[$s_entry])){
269 $group = $this->objects[$s_entry];
270 $this->dialog = new faiGroupHandle($group,"edit");
271 }
272 }elseif($s_action == "group_cut"){
273 if(isset($this->objects[$s_entry])){
274 $group = $this->objects[$s_entry];
275 $this->dialog = new faiGroupHandle($group,"cut");
276 }
277 }elseif($s_action == "group_copy"){
278 if(isset($this->objects[$s_entry])){
279 $group = $this->objects[$s_entry];
280 $this->dialog = new faiGroupHandle($group,"copy");
281 }
282 }
283 if($this->dialog instanceOf faiGroupHandle){
284 $this->dialog->save_object();
285 if($this->dialog->is_open()){
286 return($this->dialog->execute());
287 }elseif($this->dialog->is_canceled() || isset($_POST['cancel_lock'])){
288 $this->dialog = FALSE;
289 }else{
290 if(!count($this->dialog->get_selected())){
291 $this->dialog = FALSE;
292 }
293 }
294 }
296 /********************
297 Copy & Paste
298 ********************/
300 /* Display the copy & paste dialog, if it is currently open */
301 $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
302 if($ret){
303 return($ret);
304 }
307 /********************
308 Delete MULTIPLE entries confirmed
309 ********************/
311 /* Confirmation for deletion has been passed. Users should be deleted. */
312 if (isset($_POST['delete_multiple_fai_object_confirm'])){
314 /* Find out more about the object type */
315 $ldap = $this->config->get_ldap_link();
317 /* Remove user by user and check acls before removeing them */
318 foreach($this->dns as $key => $dn){
319 $ldap->cat($dn, array('objectClass'));
320 $attrs = $ldap->fetch();
321 $type = $this->get_type($attrs);
322 $acl = $this->ui->get_permissions($dn,"fai/".$type[1]);
323 if(preg_match("/d/",$acl)){
324 $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $dn,"fai");
325 $this->dialog->parent = &$this;
326 $this->dialog->set_acl_base($dn);
327 $this->dialog->by_object[$type[1]]->remove_from_parent ();
328 $this->dialog= FALSE;
329 FAI::save_release_changes_now();
330 $to_del = FAI::clean_up_releases($dn);
331 /* Remove sub-objects (e.g. the variable key/value of a FAIvariable) from LDAP entirely */
332 $children = FAI::get_child_objects($dn);
333 if ($children) {
334 $to_del += $children;
335 }
336 foreach($to_del as $dn){
337 $ldap->rmdir_recursive($dn);
338 }
339 } else {
341 /* Normally this shouldn't be reached, send some extra
342 logs to notify the administrator */
343 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
344 new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion.");
345 }
346 }
348 /* Remove lock file after successfull deletion */
349 $this->remove_lock();
350 $this->dns = array();
351 $this->dialog = FALSE;
352 }
355 /****************
356 Delete confirme dialog
357 ****************/
359 if ($s_action=="del_multiple" ||
360 $this->dialog instanceOf faiGroupHandle && $this->dialog->get_mode() == "remove"){
362 /* Collect objects to delete and check if objects are freezed
363 */
364 $dns = array();
365 $errors = "";
366 $this->dns = array();
367 if($this->dialog instanceOf faiGroupHandle){
368 $to_delete = $this->dialog->get_selected();
369 }else{
370 $ids = $this->list_get_selected_items();
371 $to_delete = array();
372 foreach($ids as $id){
373 foreach($this->objects[$id] as $obj) {
374 array_push($to_delete, $obj);
375 }
376 }
377 }
379 foreach($to_delete as $obj){
380 if(isset($obj['type']) && in_array($obj['type'],array("opsi_netboot","opsi_local"))){
381 continue;
382 }
383 if(isset($obj['FAIstate']) && preg_match('/^freeze/', $obj['FAIstate'])){
384 $errors .= $obj['cn'].", ";
385 }else{
386 $this->dns[] = $obj['dn'];
387 }
388 }
390 if($errors != ""){
391 msg_dialog::display(_("Branch locked"),sprintf(_("The following entries are locked, you can't remove them %s."),
392 "<br><br>".trim($errors,", ")),INFO_DIALOG);
393 }
395 /* Check locking
396 */
397 if(count($this->dns)){
398 if ($user= get_multiple_locks($this->dns)){
399 return(gen_locked_message($user,$this->dns));
400 }
401 if(count($this->dns)){
402 $dns_names = array();
403 foreach($this->dns as $dn){
404 add_lock ($dn, $this->ui->dn);
405 $dns_names[] = LDAP::fix($dn);
406 }
407 $smarty->assign("warning",msgPool::deleteInfo($dns_names,_("FAI object")));
408 $smarty->assign("multiple", true);
409 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
410 }
411 }
412 }
416 /********************
417 Delete MULTIPLE entries Canceled
418 ********************/
420 /* Remove lock */
421 if(isset($_POST['delete_multiple_fai_object_cancel'])){
422 $this->remove_lock();
423 $this->dns = array();
424 }
426 /****************
427 Edit entry
428 ****************/
430 if($s_action == "edit" || $this->dialog instanceOf faiGroupHandle && $this->dialog->get_mode() == "edit"){
432 $entry = array();
433 if($this->dialog instanceOf faiGroupHandle){
434 $entries = $this->dialog->get_selected();
435 $entry = array_pop($entries);
436 }elseif(isset($this->objects[$i_entryID][$s_entryType])){
437 $entry = $this->objects[$i_entryID][$s_entryType];
438 }
440 if(count($entry)){
441 $a_setup = $this->get_type($entry);
443 /* Special handling for opsi products
444 */
446 if(in_array($entry['type'],array("opsi_local","opsi_netboot")) &&
447 $this->opsi instanceof opsi && $this->opsi->enabled() ){
449 $name = $entry['cn'];
450 $cfg = $this->opsi->get_product_properties($name);
451 $this->dialog = new tabs_opsiProdConfig($this->config, $this->config->data['TABS']['OPSIPRODCONFIG'],"","opsi");
452 if(isset($this->dialog->by_object['opsiProperties'])){
453 $this->dialog->by_object['opsiProperties']->set_cfg($cfg);
454 $this->dialog->by_object['opsiProperties']->set_product($name);
455 }else{
456 trigger_error("Unknown tab, please check config.");
457 }
458 }elseif(count($a_setup)){
460 $this->dn = $entry['dn'];
461 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
462 if (($user= get_lock($this->dn)) != ""){
463 return(gen_locked_message ($user, $this->dn, TRUE));
464 }
465 add_lock ($this->dn, $this->ui->dn);
467 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
468 $this->dialog->parent = &$this;
469 $this->dialog->by_object[$a_setup[1]]->FAIstate = $entry['FAIstate'];
470 $this->dialog->set_acl_base($this->dn);
471 $this->is_dialog = true;
472 set_object_info($this->dn);
473 }
474 }
475 }
478 /* Branch handling
479 09.01.2006
480 */
482 /****************
483 Remove branch
484 ****************/
486 /* Remove branch
487 */
488 if($s_action == "remove_branch"){
489 $base= $this->fai_release;
491 /* Check if we have a post remove method configured
492 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
493 */
494 if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
495 /* Load permissions for selected 'dn' and check if
496 we're allowed to remove this 'dn' */
497 if(preg_match("/d/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
498 $smarty->assign("release_hidden",base64_encode($this->fai_release));
499 $smarty->assign("info", msgPool::deleteInfo(LDAP::fix($this->fai_release),_("FAI branch/freeze")));
500 return($smarty->fetch(get_template_path('remove_branch.tpl',TRUE)));
501 } else {
502 msg_dialog::display(_("Permission error"), _("You have no permission to delete this release!"), ERROR_DIALOG);
503 }
504 }
505 }
508 /****************
509 Remove branch confirmed
510 ****************/
512 if(isset($_POST['delete_branch_confirm'])){
514 /* Check if we have a post remove method configured
515 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
516 */
517 if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
519 if(!isset($_POST['release_hidden']) || base64_decode($_POST['release_hidden']) != $this->fai_release){
520 msg_dialog::display(_("Warning"),_("Release remove aborted because the release name check failed!"));
521 }else{
523 $bb = $this->fai_release;
524 if(!isset($ldap)){
525 $ldap = $this->config->get_ldap_link();
526 }
528 $br = $this->getBranches();
530 if(isset($br[$bb]) && preg_match("/d/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
531 $name = $br[$bb];
533 $ldap->cd($bb);
534 $ldap->recursive_remove();
535 $ldap->cd(preg_replace('/,'.preg_quote(get_ou('faiBaseRDN'), '/').'/', ','.get_ou('applicationRDN'), $bb));
536 $ldap->recursive_remove();
537 $ldap->cd(preg_replace('/,'.preg_quote(get_ou('faiBaseRDN'), '/').'/', ','.get_ou('mimetypeRDN'), $bb));
538 $ldap->recursive_remove();
540 /* Search for all groups with configured application menus.
541 - First search all groups, to ensure that we only remove entries form whithin groups.
542 - The search für menu configuration for the specified release and collect all those dns.
543 - Remove entries
544 */
545 $release_ou = preg_replace("/".preg_quote(get_ou("faiBaseRDN"), '/').".*$/","",$bb);
546 $ldap->cd($this->config->current['BASE']);
547 $ldap->search("(objectClass=posixGroup)",array("dn"));
549 /* Collect all group dns
550 */
551 $groups = array();
552 while($attrs = $ldap->fetch()){
553 $groups[] = $attrs['dn'];
554 }
556 /* Collect all group menu release dns that match the release we have removed
557 */
558 $dns = array();
559 foreach($groups as $dn){
560 $ldap->cd($dn);
561 $ldap->search("(objectClass=FAIbranch)",array("dn"));
562 while($attrs = $ldap->fetch()){
563 if(preg_match("/^".preg_quote($release_ou, '/')."/",$attrs['dn'])){
564 $dns[] = $attrs['dn'];
565 }
566 }
567 }
569 /* Finally remove collected release dns
570 */
571 foreach($dns as $dn){
572 $ldap->cd($dn);
573 $ldap->recursive_remove();
574 }
576 /* Post remove */
577 $this->fai_release = $this->fai_base;
578 $this->lock_name = $name;
579 $this->lock_dn = $bb;
580 $this->postremove();
582 $fai_filter = session::get("fai_filter");
583 $fai_filter['fai_release'] = $this->fai_release;
584 session::set("fai_filter",$fai_filter);
586 new log("remove","fai/".get_class($this),$br[$bb],array(),"Release removed");
587 }
588 }
589 }
590 }
593 /****************
594 Create a new branch "insert Name"
595 ****************/
597 if((isset($_POST['UseBranchName']))&&(($this->dispNewBranch)||($this->dispNewFreeze))){
598 session::set('LASTPOST',$_POST);
600 if($this->dispNewBranch){
601 $type = "branch";
602 }else{
603 $type = "freeze";
604 }
606 /* Check branch name */
607 $name = $_POST['BranchName'];
608 $is_ok = true;
609 $smarty->assign("BranchName",$name);
610 $base= $this->fai_base;
612 /* Check used characters */
613 if(!preg_match("/^[0-9a-z\.]*$/",$name)){
614 msg_dialog::display(_("Error"), msgPool::invalid(_("Name"),$name,"/[0-9a-z\.]/"), ERROR_DIALOG);
615 $is_ok = false;
616 }
618 /* Check if this name is already in use */
619 if(!$this->CheckNewBranchName($_POST['BranchName'],$this->fai_release)){
620 msg_dialog::display(_("Error"), msgPool::duplicated(_("Name")), ERROR_DIALOG);
621 $is_ok = false;
622 }
624 if($is_ok){
626 if(session::is_set('LASTPOST')){
627 $LASTPOST = session::get('LASTPOST');
628 }else{
629 $LASTPOST = array();
630 }
631 $LASTPOST['base'] = $base;
632 $LASTPOST['type'] = $type;
633 session::set('LASTPOST',$LASTPOST);
634 $smarty->assign("iframe", true);
635 $smarty->assign("plugID", $_GET['plug']);
636 $display = $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
637 return($display);
638 }
639 }
642 /****************
643 Create a new branch
644 ****************/
646 if(isset($_GET['PerformBranch'])){
648 if(!preg_match("/c/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
649 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
650 }else{
652 /* In order to see error messages we have to reset the error handler.
653 Due to the exit();
654 */
655 restore_error_handler();
657 /* Create it know */
658 $this->dispNewBranch = false;
659 $this->dispNewFreeze = false;
661 $LASTPOST = session::get('LASTPOST');
662 $base = $LASTPOST['base'];
663 $_POST = session::get('LASTPOST');
664 $name = $_POST['BranchName'];
666 $type = $LASTPOST['type'];
667 $ldap = $this->config->get_ldap_link();
669 $baseToUse = $base;
670 if($this->fai_release != $this->fai_base){
671 $baseToUse = $this->fai_release;
672 }
674 /* Create new Release name to be able to set faidebianRelease for FAIpackageList */
676 $CurrentReleases = $this->getBranches();
677 $NewReleaseName = $name;
678 if(isset($CurrentReleases[$this->fai_release])) {
679 if($this->fai_release != $this->fai_base){
680 $NewReleaseName = $CurrentReleases[$this->fai_release]."/".$name;
681 $NewReleaseName = preg_replace("#\/#","/",$NewReleaseName);
682 }else{
683 $NewReleaseName = $name;
684 }
685 }
687 $appsrc = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('applicationRDN'),$baseToUse);
688 $appdst = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('applicationRDN'),"ou=".$name.",".$baseToUse) ;
690 $mimesrc = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('mimetypeRDN'),$baseToUse);
691 $mimedst = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('mimetypeRDN'),"ou=".$name.",".$baseToUse) ;
693 /* Check if source depeartments exist */
694 foreach(array($baseToUse,$appsrc,$mimesrc) as $dep){
695 $ldap->cd($this->config->current['BASE']);
696 $ldap->cat($dep);
697 if(!$ldap->count()){
698 $ldap->create_missing_trees($dep);
699 }
700 }
702 /* Print header to have styles included */
703 echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
704 <html>
705 <head>
706 <title></title>
707 <style type="text/css">@import url("themes/default/style.css");</style>
708 <script language="javascript" src="include/focus.js" type="text/javascript"></script>
709 </head>
710 <body style="background: none;margin:3px;color:black">
711 ';
713 new log("create","fai/".get_class($this),$NewReleaseName,array(),"New $type created");
715 /* Duplicate group application releases
716 */
717 FAI::copy_FAI_group_releases($CurrentReleases[$this->fai_release],$name,$type);
719 /* Duplicate applications
720 */
721 $ldap->cat($appsrc,array("dn")) ;
722 if($ldap->count()){
723 $ldap->cd ($appdst);
724 $ldap->recursive_remove();
725 FAI::copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true);
726 }
728 /* Duplicate mime types
729 */
730 $ldap->cat($mimesrc,array("dn")) ;
731 if($ldap->count()){
732 $ldap->cd ($mimedst);
733 $ldap->recursive_remove();
734 FAI::copy_FAI_resource_recursive($mimesrc,$mimedst,$NewReleaseName,$type,true);
735 }
737 $attr = array();
738 $attr['objectClass'] = array("organizationalUnit","FAIbranch");
739 $attr['ou'] = $name;
740 $attr['FAIstate'] = $type;
741 $ldap->cd($this->config->current['BASE']);
742 $ldap->cd("ou=".$name.",".$baseToUse);
743 $ldap->cat("ou=".$name.",".$baseToUse);
744 if($ldap->count()){
745 $ldap->modify($attr);
746 }else{
747 $ldap->add($attr);
748 }
750 /* Duplicate fai objects
751 */
752 // $ldap->cd ("ou=".$name.",".$baseToUse);
753 // $ldap->recursive_remove();
754 // FAI::copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,$NewReleaseName,$type,true);
756 echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
757 <br><input type='submit' name='CloseIFrame' value='"._("Continue")."'>
758 <input type='hidden' name='php_c_check' value='1'>
759 </form></div>";
761 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
763 /* Print footer to have valid html */
764 echo "</body></html>";
766 $this->dispNewFreeze = false;
768 /* Postcreate */
770 /* Assign possible attributes */
771 $this->lock_type = $type;
772 $this->lock_name = $name;
773 $this->lock_dn = $baseToUse;
774 $this->postcreate();
777 /* Send daemon event to reload the fai release database
778 */
779 if(class_available("DaemonEvent") && class_available("gosaSupportDaemon")){
780 $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
781 if(isset($events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'])){
782 $evt = $events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'];
783 $tmp = new $evt['CLASS_NAME']($this->config);
784 $tmp->set_type(TRIGGERED_EVENT);
785 $tmp->add_targets(array("GOSA"));
786 $o_queue = new gosaSupportDaemon();
787 if(!$o_queue->append($tmp)){
788 msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
789 }
790 }
791 }else{
792 trigger_error("Unknown class DaemonEvent / gosaSupportDaemon");
793 msg_dialog::display(_("Fatal error"),
794 "Daemon events called but classes where not accessible, DaemonEvent gosaSupportDaemon",
795 FATAL_ERROR_DIALOG);
796 }
797 exit();
798 }
799 }
801 /****************
802 Display dialog to enter new Branch name
803 ****************/
805 /* Check if we have a post create method configured
806 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
807 */
808 if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
809 if(($s_action == "branch_branch")||($this->dispNewBranch)){
810 if(!preg_match("/c/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
811 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
812 }else{
813 $this->dispNewBranch=true;
814 $smarty->assign("iframe",false);
815 $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
816 return($display);
817 }
818 }
819 }
822 /****************
823 Display dialog to enter new Freeze name
824 ****************/
826 /* Check if we have a post create method configured
827 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
828 */
829 if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
830 if(($s_action == "freeze_branch")||($this->dispNewFreeze)){
831 if(!preg_match("/c/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
832 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
833 }else{
834 $this->dispNewFreeze = true;
835 $smarty->assign("iframe",false);
836 $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
837 return($display);
838 }
839 }
840 }
843 /****************
844 Create a new object
845 ****************/
847 $types = array( "new_partition" => "FAIpartitionTable",
848 "new_script" => "FAIscript",
849 "new_hook" => "FAIhook",
850 "new_variable" => "FAIvariable",
851 "new_template" => "FAItemplate",
852 "new_package" => "FAIpackageList");
853 $types_i18n = array( "new_partition" => _("partition table"),
854 "new_script" => _("script"),
855 "new_hook" => _("hook"),
856 "new_variable" => _("variable"),
857 "new_template" => _("template"),
858 "new_package" => _("package list"));
860 if(isset($types[$s_action])){
862 $type_acl_mapping = array(
863 "FAIpartitionTable" => "faiPartitionTable",
864 "FAIpackageList" => "faiPackage",
865 "FAIscript" => "faiScript",
866 "FAIvariable" => "faiVariable",
867 "FAIhook" => "faiHook",
868 "FAIprofile" => "faiProfile",
869 "FAItemplate" => "faiTemplate");
871 $acl = $this->ui->get_permissions($this->acl_base,"fai/".$type_acl_mapping[$types[$s_action]]);
872 if(preg_match("/c/",$acl)){
873 $this->dialog = new askClassName($this->config,$this->dn,$this->ui,$types[$s_action]);
874 $this->dialog->parent = &$this;
875 }else{
876 msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), $types_i18n[$s_action]), ERROR_DIALOG);
877 }
878 }
880 /* New Profile */
881 if($s_action == "new_profile"){
882 $this->dn = "new" ;
884 $acl = $this->ui->get_permissions($this->acl_base,"fai/faiProfile");
885 if(preg_match("/c/",$acl)){
886 $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
887 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
888 $this->dialog->set_acl_base($this->acl_base);
889 $this->dialog->parent = &$this;
891 $this->is_dialog = false;
892 }else{
893 msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), _("profile")), ERROR_DIALOG);
894 }
895 }
898 /****************
899 Get name from ask_class_name dialog
900 ****************/
902 if($s_action == "select_class_name_finished"){
903 $this->dialog->save_object();
904 if(count($this->dialog->check())!=0){
905 foreach($this->dialog->check() as $msg){
906 msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
907 }
908 }elseif(isset($this->dialog->objectClass)){
909 $this->dn = "new" ;
910 $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass)));
911 $name = $this->dialog->save();
913 if(class_exists($a_setup[0])){
914 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
915 $this->dialog->set_acl_base($this->acl_base);
916 $this->dialog->by_object[$a_setup[1]]->cn = $name;
917 $this->dialog->parent = &$this;
918 $this->is_dialog = true;
919 }
920 }
921 }
924 /****************
925 Cancel dialogs
926 ****************/
928 if(isset($_POST['edit_cancel'])){
929 $this->dialog=FALSE;
930 $this->is_dialog = false;
931 set_object_info();
932 $this->remove_lock();
933 }
936 /****************
937 Handle opsi dialogs
938 ****************/
940 if($this->dialog instanceof tabs_opsiProdConfig && isset($_POST['cancel_properties'])){
941 $this->dialog = NULL;
942 }
943 if($this->dialog instanceof tabs_opsiProdConfig && isset($_POST['save_properties'])){
944 $this->dialog->save_object();
945 $op = $this->dialog->by_object['opsiProperties'];
946 $name = $op->get_product();
947 $cfg = $op->get_cfg();
948 $this->opsi->set_product_properties($name,$cfg);
949 if($this->opsi->is_error()){
950 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
951 }else{
952 $this->dialog = NULL;
953 }
954 }
955 if($this->dialog instanceof tabs_opsiProdConfig){
956 $this->dialog->save_object();
957 return($this->dialog->execute());
958 }
961 /****************
962 Save sub dialogs
963 ****************/
965 /* This check if the given tab could be saved
966 * If it was possible to save it, remove dialog object.
967 * If it wasn't possible, show errors and keep dialog.
968 */
969 if((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->dialog->config))){
970 $this->dialog->save_object();
971 $msgs= $this->dialog->check();
972 if(count($msgs)!=0){
973 foreach($msgs as $msg){
974 msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
975 }
976 }else{
977 $this->dialog->save();
978 FAI::save_release_changes_now();
979 if (!isset($_POST['edit_apply'])){
980 $this->remove_lock();
981 $this->dialog=FALSE;
982 $this->is_dialog=false;
983 set_object_info();
984 }else{
986 /* Reinitialize tab */
987 if($this->dialog instanceof tabs){
988 $this->dialog->re_init();
989 }
990 }
991 }
992 }
995 /****************
996 Display currently open dialog
997 ****************/
999 /* If dialog is set, but $this->is_dialog==false, then
1000 * only the "abort" button is shown, this are dialogs that must not be saved.
1001 * If is_dialog == true, we are currently editing tab objects.
1002 * Here we need both, save and cancel
1003 */
1005 if(is_object($this->dialog)){
1006 $display .= $this->dialog->execute();
1007 /* Don't show buttons if tab dialog requests this */
1009 if(isset($this->dialog->current)){
1011 $obj = $this->dialog->by_object[$this->dialog->current];
1013 if(($this->dialog instanceOf tabs || $this->dialog instanceOf plugin) && $this->dialog->read_only == TRUE){
1014 $display.= "<p style=\"text-align:right\">
1015 <input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">
1016 </p>";
1017 }elseif((isset($obj->is_dialog) && (!$obj->is_dialog)) || (isset($obj->dialog) && (!$obj->dialog))){
1019 $display.= "<p style=\"text-align:right\">\n";
1020 if(!$this->no_save){
1021 $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
1022 $display.= " \n";
1023 if ($this->dn != "new"){
1024 $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
1025 $display.= " \n";
1026 }
1027 }
1028 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1029 $display.= "</p>";
1030 }elseif(!isset($this->dialog->current)){
1031 $display.= "<p style=\"text-align:right\">\n";
1032 $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\"> ";
1033 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1034 $display.= "</p>";
1035 }
1036 }else{
1037 $display.= "<p style=\"text-align:right\">\n";
1038 $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\"> ";
1039 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1040 $display.= "</p>";
1042 }
1043 return($display);
1044 }
1047 /****************
1048 Dialog display
1049 ****************/
1051 /* Check if there is a snapshot dialog open */
1052 $base = $this->fai_base;
1053 if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
1054 return($str);
1055 }
1057 /* Display dialog with system list */
1058 $this->reload();
1059 $this->DivListFai->parent = &$this;
1060 $this->DivListFai->execute();
1061 $this->DivListFai->setEntries($this->objects);
1062 return($this->DivListFai->Draw());
1063 }
1066 /* Return departments, that will be included within snapshot detection */
1067 function get_used_snapshot_bases()
1068 {
1069 $tmp = array();
1070 $types = array("faiPartitionRDN","faiScriptRDN","faiTemplateRDN","faiHookRDN","faiProfileRDN","faiVariableRDN","faiPackageRDN");
1071 foreach($types as $type){
1072 $tmp[] = get_ou($type).$this->fai_release;
1073 }
1074 return($tmp);
1075 }
1078 /* Get available branches for current base */
1079 function getBranches($base = false,$prefix = "")
1080 {
1081 $ret = array("/"=>$this->fai_base);
1082 $ldap = $this->config->get_ldap_link();
1083 if(!$base){
1084 $base = $this->fai_base;
1085 }
1086 $tmp = FAI::get_all_releases_from_base($base,true);
1087 foreach($tmp as $dn => $name){
1088 $ret[$name]=$dn;
1089 }
1090 ksort($ret);
1091 $ret = array_flip($ret);
1093 return ($ret);
1094 }
1097 function list_get_selected_items()
1098 {
1099 $ids = array();
1100 foreach($_POST as $name => $value){
1101 if(preg_match("/^item_selected_[0-9]*$/",$name)){
1102 $id = preg_replace("/^item_selected_/","",$name);
1103 $ids[$id] = $id;
1104 }
1105 }
1106 return($ids);
1107 }
1110 /* reload list of objects */
1111 function reload()
1112 {
1113 /* Variable initialisation */
1114 $str = "";
1115 $Regex = $this->DivListFai->Regex;
1116 $this->objects = array();
1118 /* Get base */
1119 $base = $this->fai_base;
1120 if($this->fai_release != $this->fai_base){
1121 $br = $this->getBranches();
1122 if(isset($br[$this->fai_release])){
1123 $base = $this->fai_release;
1124 }else{
1125 $base = $this->fai_base;
1126 }
1127 }
1128 $this->base = $base;
1129 $this->set_acl_base($this->acl_base);
1131 $this->lock_type = FAI::get_release_tag(FAI::get_release_dn($base));
1133 /* Create a new list of FAI object
1134 * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ...
1135 */
1136 $ObjectTypes = array(
1137 "FAIpartitionTable" => array("OU"=> get_ou('faiPartitionRDN') , "CHKBOX"=>"ShowPartitions" ,"ACL" => "faiPartitionTable"),
1138 "FAIpackageList" => array("OU"=> get_ou('faiPackageRDN') , "CHKBOX"=>"ShowPackages" ,"ACL" => "faiPackage"),
1139 "FAIscript" => array("OU"=> get_ou('faiScriptRDN') , "CHKBOX"=>"ShowScripts" ,"ACL" => "faiScript"),
1140 "FAIvariable" => array("OU"=> get_ou('faiVariableRDN') , "CHKBOX"=>"ShowVariables" ,"ACL" => "faiVariable"),
1141 "FAIhook" => array("OU"=> get_ou('faiHookRDN') , "CHKBOX"=>"ShowHooks" ,"ACL" => "faiHook"),
1142 "FAIprofile" => array("OU"=> get_ou('faiProfileRDN') , "CHKBOX"=>"ShowProfiles" ,"ACL" => "faiProfile"),
1143 "FAItemplate" => array("OU"=> get_ou('faiTemplateRDN') , "CHKBOX"=>"ShowTemplates" ,"ACL" => "faiTemplate"));
1145 $filter = "";
1146 foreach($ObjectTypes as $key => $data){
1147 if($this->DivListFai->$data['CHKBOX']){
1148 $filter.= "(objectClass=".$key.")";
1149 }
1150 }
1151 $filter = "(&(|".$filter.")(cn=$Regex))";
1153 /* Get resolved release dependencies */
1154 $tmp = FAI::get_all_objects_for_given_base($base,$filter);
1156 /* Ge listed ldap objects */
1157 $ldap = $this->config->get_ldap_link();
1158 $ldap->cd($this->config->current['BASE']);
1160 foreach($tmp as $entry){
1162 /* Get some more informations about the object */
1163 $ldap->cat($entry['dn'], array("cn","description","objectClass","FAIclass","FAIstate","objectClass"));
1164 $object = $ldap->fetch();
1166 /* Walk through possible types */
1167 foreach($ObjectTypes as $type => $rest){
1169 $acl = $this->ui->get_permissions($object['dn'],"fai/".$rest ['ACL']);
1171 if(in_array($type,$object['objectClass']) && preg_match("/r/",$acl)){
1173 /* Prepare object */
1174 unset($object['objectClass']['count']);
1175 if(!isset($object['description'][0])){
1176 $object['description'][0]="";
1177 }
1179 /* Clean up object informations */
1180 $obj = array();
1181 $obj['cn'] = $object['cn'][0];
1182 $obj['dn'] = $object['dn'];
1183 $obj['acl'] = $acl;
1184 $obj['class'] = $rest ['ACL'];
1185 $obj['FAIstate'] = $entry['FAIstate'];
1186 $obj['description'] = $object['description'][0];
1187 $obj['objectClass'] = $object['objectClass'];
1189 $this->objects[$obj['cn']][$type] = $obj;
1190 $this->objects[$obj['cn']][$type]['type']=$type;
1191 }
1192 }
1193 }
1195 /* Append opsi objects, if opsi is available and if we are on the fai_base
1196 */
1197 if($this->opsi instanceof opsi && $this->opsi->enabled()){
1198 $opsi_acl = $this->ui->get_permissions($base,"opsi/opsiProperties");
1199 if(preg_match("/r/",$opsi_acl)){
1200 $err = FALSE;
1201 if(!$err && $this->DivListFai->ShowOpsiNetboot){
1202 $n_pro = $this->opsi->get_netboot_products();
1203 $err |= $this->opsi->is_error();
1204 foreach($n_pro as $name => $data){
1205 $entry = array(
1206 "cn" => $name,
1207 "description" => $data['DESC'],
1208 "type" => "opsi_netboot");
1209 $this->objects[$name]['opsi_netboot'] = $entry;
1210 }
1211 }
1212 if(!$err && $this->DivListFai->ShowOpsiLocal){
1213 $l_pro = $this->opsi->get_local_products();
1214 $err |= $this->opsi->is_error();
1215 foreach($l_pro as $name => $data){
1216 $entry = array("cn" => $name,
1217 "description" => $data['DESC'],
1218 "type" => "opsi_local");
1219 $this->objects[$name]["opsi_local"] = $entry;
1220 }
1221 }
1222 if($err){
1223 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
1224 }
1225 }
1226 }
1228 uksort($this->objects, 'strnatcasecmp');
1229 reset ($this->objects);
1230 $this->objects = array_values($this->objects);
1231 }
1233 function remove_lock()
1234 {
1235 if (isset($this->dn) && !empty($this->dn)){
1236 del_lock ($this->dn);
1237 }
1238 if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
1239 del_lock ($this->dns);
1240 }
1241 }
1243 function get_type($array){
1244 if(!isset($array['objectClass'])) return(array());
1245 if(in_array("FAIpartitionTable",$array['objectClass'])){
1246 return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS"));
1247 }
1248 if(in_array("FAIscript",$array['objectClass'])){
1249 return(array("tabsScript","faiScript","FAISCRIPTTABS"));
1250 }
1251 if(in_array("FAItemplate",$array['objectClass'])){
1252 return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS"));
1253 }
1254 if(in_array("FAIhook",$array['objectClass'])){
1255 return(array("tabsHook","faiHook","FAIHOOKTABS"));
1256 }
1257 if(in_array("FAIvariable",$array['objectClass'])){
1258 return(array("tabsVariable","faiVariable","FAIVARIABLETABS"));
1259 }
1260 if(in_array("FAIprofile",$array['objectClass'])){
1261 return(array("tabsProfile","faiProfile","FAIPROFILETABS"));
1262 }
1264 if(in_array("FAIpackageList",$array['objectClass'])){
1265 return(array("tabsPackage","faiPackage","FAIPACKAGETABS"));
1266 }
1267 return(array());
1268 }
1270 function CheckNewBranchName($name,$base)
1271 {
1272 $f = $this->fai_release;
1273 if($name == ""){
1274 return(false);
1275 }elseif(in_array($name,$this->getBranches($f))) {
1276 return(false);
1277 }elseif(tests::is_department_name_reserved($name,$base)){
1278 return(false);
1279 }
1280 return(true);
1281 }
1283 function save_object()
1284 {
1285 $this->DivListFai->save_object();
1287 /* Get posted release */
1288 $r_releases = array_flip($this->getBranches());
1289 if(isset($_POST['fai_release']) && isset($r_releases[get_post('fai_release')])){
1291 /* Ensure that we have a valid release selected */
1292 if(!isset($r_releases[get_post('fai_release')])){
1293 msg_dialog::display(_("Warning"),_("The selected release is not available anymore. All triggered actions are skipped."));
1294 $_POST = array();
1295 $plug =$_GET['plug'];
1296 $_GET = array("plug" => $plug);
1297 $this->fai_release = $this->fai_base;
1298 }else{
1299 $this->fai_release = $r_releases[get_post('fai_release')];
1300 }
1302 $fai_filter = session::get("fai_filter");
1303 $fai_filter['fai_release'] = $this->fai_release;
1304 session::set("fai_filter",$fai_filter);
1305 }
1307 if(is_object($this->CopyPasteHandler)){
1308 $this->CopyPasteHandler->save_object();
1309 }
1310 }
1313 function copyPasteHandling_from_queue($s_action,$s_entry)
1314 {
1315 /* Check if Copy & Paste is disabled */
1316 if(!is_object($this->CopyPasteHandler)){
1317 return("");
1318 }
1320 $ui = get_userinfo();
1322 /* Add a single entry to queue */
1323 if($this->dialog instanceOf faiGroupHandle && !$this->dialog->is_open()){
1325 if(in_array($this->dialog->get_mode(),array("copy"))){
1327 /* Cleanup object queue */
1328 $this->CopyPasteHandler->cleanup_queue();
1329 $group = $this->dialog->get_selected();
1330 foreach($group as $entry){
1331 $a_setup = $this->get_type($entry);
1332 $dn = $entry['dn'];
1333 if($ui->is_copyable($dn,"fai",$a_setup[1])){
1334 $this->CopyPasteHandler->add_to_queue($dn,$this->dialog->get_mode(),$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1335 }
1336 }
1337 $this->dialog = FALSE;
1338 }
1339 }
1341 /* Add entries to queue */
1342 if($s_action == "copy_multiple"){
1344 /* Cleanup object queue */
1345 $this->CopyPasteHandler->cleanup_queue();
1347 /* Add new entries to CP queue */
1348 foreach($this->list_get_selected_items() as $id){
1349 $group = $this->objects[$id];
1350 foreach($group as $entry){
1351 $a_setup = $this->get_type($entry);
1352 $dn = $entry['dn'];
1354 if($s_action == "copy_multiple" && $ui->is_copyable($dn,"fai",$a_setup[1])){
1355 $this->CopyPasteHandler->add_to_queue($dn,"copy",$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1356 }
1357 }
1358 }
1359 }
1361 /* Start pasting entries */
1362 if($s_action == "editPaste" && !($this->lock_type == "freeze" && !$this->allow_freeze_object_attach)){
1363 $this->start_pasting_copied_objects = TRUE;
1364 }
1366 /* Return C&P dialog */
1367 if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
1369 /* Get dialog */
1370 $this->CopyPasteHandler->SetVar("parent",$this);
1371 $data = $this->CopyPasteHandler->execute();
1373 FAI::save_release_changes_now();
1375 /* Return dialog data */
1376 if(!empty($data)){
1377 return($data);
1378 }
1379 }
1381 /* Automatically disable status for pasting */
1382 if(!$this->CopyPasteHandler->entries_queued()){
1383 $this->start_pasting_copied_objects = FALSE;
1384 }
1385 return("");
1386 }
1389 /* Check if the given FAI class is used in this release
1390 */
1391 static function check_class_name($oc,$name,$dn)
1392 {
1393 $base = FAI::get_release_dn($dn);
1395 if($oc == "FAIprofile"){
1396 $f = "";
1397 $ocs = array("FAIprofile","FAItemplate","FAIhook","FAIpartitionTable","FAIpackageList","FAIscript","FAIvariable");
1398 foreach($ocs as $oc){
1399 $f .= "(objectClass=".$oc.")";
1400 }
1401 $res = FAI::get_all_objects_for_given_base($base,"(|".$f.")",TRUE);
1402 }else{
1403 $res = FAI::get_all_objects_for_given_base($base,"(objectClass=".$oc.")",TRUE);
1404 }
1405 $delete = array();
1406 $used = array();
1407 foreach($res as $object){
1408 $used[$object['cn'][0]]= $object['cn'][0];
1409 }
1410 return($used);
1411 }
1414 /* Return plugin informations for acl handling */
1415 static function plInfo()
1416 {
1417 return (array(
1418 "plShortName" => _("FAI releases"),
1419 "plDescription" => _("FAI release management"),
1420 "plSelfModify" => FALSE,
1421 "plDepends" => array(),
1422 "plPriority" => 0,
1423 "plSection" => array("administration"),
1424 "plCategory" => array("fai"=> array("description" => _("FAI"),
1425 "objectClass" => "FAIclass")),
1426 "plProvidedAcls"=> array()));
1427 }
1428 }
1429 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1430 ?>