3266af679a579eb894bea5977aafdd48ba019705
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 }
299 if($this->dialog instanceOf faiGroupHandle){
300 $this->dialog->save_object();
301 if($this->dialog->is_open()){
302 return($this->dialog->execute());
303 }
304 if($this->dialog->is_canceled() || isset($_POST['cancel_lock'])){
305 $this->dialog = FALSE;
306 }
307 }
310 /********************
311 Delete MULTIPLE entries confirmed
312 ********************/
314 /* Confirmation for deletion has been passed. Users should be deleted. */
315 if (isset($_POST['delete_multiple_fai_object_confirm'])){
317 /* Find out more about the object type */
318 $ldap = $this->config->get_ldap_link();
320 /* Remove user by user and check acls before removeing them */
321 foreach($this->dns as $key => $dn){
323 $ldap->cat($dn, array('objectClass'));
324 $attrs = $ldap->fetch();
325 $type = $this->get_type($attrs);
327 $acl = $this->ui->get_permissions($dn,"fai/".$type[1]);
328 if(preg_match("/d/",$acl)){
330 $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $dn,"fai");
331 $this->dialog->parent = &$this;
332 $this->dialog->set_acl_base($dn);
333 $this->dialog->by_object[$type[1]]->remove_from_parent ();
334 unset ($this->dialog);
335 $this->dialog= FALSE;
336 $to_del = FAI::clean_up_releases($dn);
337 FAI::save_release_changes_now();
339 foreach($to_del as $dn){
340 $ldap->rmdir_recursive($dn);
341 }
343 } else {
345 /* Normally this shouldn't be reached, send some extra
346 logs to notify the administrator */
347 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
348 new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion.");
349 }
350 }
352 /* Remove lock file after successfull deletion */
353 $this->remove_lock();
354 $this->dns = array();
355 $this->dialog = FALSE;
356 }
359 /****************
360 Delete confirme dialog
361 ****************/
363 if ($s_action=="del_multiple" ||
364 $this->dialog instanceOf faiGroupHandle && $this->dialog->get_mode() == "remove"){
366 /* Collect objects to delete and check if object is freezed
367 */
368 $dns = array();
369 $errors = "";
370 $this->dns = array();
371 if($this->dialog instanceOf faiGroupHandle){
372 $to_delete = $this->dialog->get_selected();
373 foreach($to_delete as $obj){
374 if(!preg_match('/^freeze/', $obj['FAIstate'])){
375 $this->dns[] = $obj['dn'];
376 }else{
377 $errors .= $obj['cn'].", ";
378 }
379 }
380 }else{
381 $ids = $this->list_get_selected_items();
382 foreach($ids as $id){
383 foreach($this->objects[$id] as $obj){
384 if(!preg_match('/^freeze/', $obj['FAIstate'])){
385 $this->dns[] = $obj['dn'];
386 }else{
387 $errors .= $obj['cn'].", ";
388 }
389 }
390 }
391 }
392 if($errors != ""){
393 msg_dialog::display(_("Branch locked"),sprintf(_("The following entries are locked, you can't remove them %s."),
394 "<br><br>".trim($errors,", ")),INFO_DIALOG);
395 }
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 /* Lock the current entry, so nobody will edit it during deletion */
408 $smarty->assign("warning",msgPool::deleteInfo($dns_names,_("FAI object")));
409 $smarty->assign("multiple", true);
410 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
411 }
412 }
413 }
417 /********************
418 Delete MULTIPLE entries Canceled
419 ********************/
421 /* Remove lock */
422 if(isset($_POST['delete_multiple_fai_object_cancel'])){
423 $this->remove_lock();
424 $this->dns = array();
425 }
428 /****************
429 Delete aborted
430 ****************/
432 /* Delete canceled? */
433 if (isset($_POST['delete_cancel'])){
434 $this->remove_lock();
435 }
438 /****************
439 Delete confirmed
440 ****************/
442 /* Deletion was confirmed, so delete this entry
443 */
444 if (isset($_POST['delete_terminal_confirm'])){
446 /* Some nice guy may send this as POST, so we've to check
447 for the permissions again. */
449 /* Find out more about the object type */
450 $ldap = $this->config->get_ldap_link();
451 $ldap->cat($this->dn, array('objectClass'));
452 if($ldap->count()){
453 $attrs = $ldap->fetch();
454 $type = $this->get_type($attrs);
456 $acl = $this->ui->get_permissions($this->dn,"fai/".$type[1]);
457 if(preg_match("/d/",$acl)){
459 $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $this->dn,"fai");
460 $this->dialog->set_acl_base($this->dn);
461 $this->dialog->parent = &$this;
462 $this->dialog->by_object[$type[1]]->remove_from_parent ();
463 unset ($this->dialog);
464 $this->dialog= FALSE;
465 $to_del = FAI::clean_up_releases($this->dn);
466 FAI::save_release_changes_now();
468 foreach($to_del as $dn){
469 $ldap->rmdir_recursive($dn);
470 }
472 } else {
474 /* Normally this shouldn't be reached, send some extra
475 logs to notify the administrator */
476 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
477 new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion.");
478 }
480 }else{
481 msg_dialog::display(_("Error"), sprintf(_("Cannot delete '%s': object does not exist!"), $this->dn) , ERROR_DIALOG);
482 }
484 /* Remove lock file after successfull deletion */
485 $this->remove_lock();
486 }
489 /****************
490 Edit entry
491 ****************/
493 if(($s_action == "edit") && (!isset($this->dialog->config))){
494 if(isset($this->objects[$i_entryID][$s_entryType])){
495 $entry = $this->objects[$i_entryID][$s_entryType];
496 $a_setup = $this->get_type($entry);
497 $this->dn = $entry['dn'];
499 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
500 if (($user= get_lock($this->dn)) != ""){
501 return(gen_locked_message ($user, $this->dn, TRUE));
502 }
503 add_lock ($this->dn, $this->ui->dn);
505 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
506 $this->dialog->parent = &$this;
507 $this->dialog->by_object[$a_setup[1]]->FAIstate = $entry['FAIstate'];
508 $this->dialog->set_acl_base($this->dn);
509 $this->is_dialog = true;
510 session::set('objectinfo',$this->dn);
511 }
512 }
515 /* Branch handling
516 09.01.2006
517 */
519 /****************
520 Remove branch
521 ****************/
523 /* Remove branch
524 */
525 if($s_action == "remove_branch"){
526 $base= $this->fai_release;
528 /* Check if we have a post remove method configured
529 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
530 */
531 if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
532 /* Load permissions for selected 'dn' and check if
533 we're allowed to remove this 'dn' */
534 if(preg_match("/d/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
535 $smarty->assign("release_hidden",base64_encode($this->fai_release));
536 $smarty->assign("info", msgPool::deleteInfo(LDAP::fix($this->fai_release),_("FAI branch/freeze")));
537 return($smarty->fetch(get_template_path('remove_branch.tpl',TRUE)));
538 } else {
539 msg_dialog::display(_("Permission error"), _("You have no permission to delete this release!"), ERROR_DIALOG);
540 }
541 }
542 }
545 /****************
546 Remove branch confirmed
547 ****************/
549 if(isset($_POST['delete_branch_confirm'])){
551 /* Check if we have a post remove method configured
552 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
553 */
554 if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
556 if(!isset($_POST['release_hidden']) || base64_decode($_POST['release_hidden']) != $this->fai_release){
557 msg_dialog::display(_("Warning"),_("Release remove aborted because the release name check failed!"));
558 }else{
560 $bb = $this->fai_release;
561 if(!isset($ldap)){
562 $ldap = $this->config->get_ldap_link();
563 }
565 $br = $this->getBranches();
567 if(isset($br[$bb]) && preg_match("/d/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
568 $name = $br[$bb];
570 $ldap->cd($bb);
571 $ldap->recursive_remove();
572 $ldap->cd(preg_replace('/,'.preg_quote(get_ou('faiBaseRDN'), '/').'/', ','.get_ou('applicationRDN'), $bb));
573 $ldap->recursive_remove();
574 $ldap->cd(preg_replace('/,'.preg_quote(get_ou('faiBaseRDN'), '/').'/', ','.get_ou('mimetypeRDN'), $bb));
575 $ldap->recursive_remove();
577 /* Search for all groups with configured application menus.
578 - First search all groups, to ensure that we only remove entries form whithin groups.
579 - The search für menu configuration for the specified release and collect all those dns.
580 - Remove entries
581 */
582 $release_ou = preg_replace("/".preg_quote(get_ou("faiBaseRDN"), '/').".*$/","",$bb);
583 $ldap->cd($this->config->current['BASE']);
584 $ldap->search("(objectClass=posixGroup)",array("dn"));
586 /* Collect all group dns
587 */
588 $groups = array();
589 while($attrs = $ldap->fetch()){
590 $groups[] = $attrs['dn'];
591 }
593 /* Collect all group menu release dns that match the release we have removed
594 */
595 $dns = array();
596 foreach($groups as $dn){
597 $ldap->cd($dn);
598 $ldap->search("(objectClass=FAIbranch)",array("dn"));
599 while($attrs = $ldap->fetch()){
600 if(preg_match("/^".preg_quote($release_ou, '/')."/",$attrs['dn'])){
601 $dns[] = $attrs['dn'];
602 }
603 }
604 }
606 /* Finally remove collected release dns
607 */
608 foreach($dns as $dn){
609 $ldap->cd($dn);
610 $ldap->recursive_remove();
611 }
613 /* Post remove */
614 $this->fai_release = $this->fai_base;
615 $this->lock_name = $name;
616 $this->lock_dn = $bb;
617 $this->postremove();
619 $fai_filter = session::get("fai_filter");
620 $fai_filter['fai_release'] = $this->fai_release;
621 session::set("fai_filter",$fai_filter);
623 new log("remove","fai/".get_class($this),$br[$bb],array(),"Release removed");
624 }
625 }
626 }
627 }
630 /****************
631 Create a new branch "insert Name"
632 ****************/
634 if((isset($_POST['UseBranchName']))&&(($this->dispNewBranch)||($this->dispNewFreeze))){
635 session::set('LASTPOST',$_POST);
637 if($this->dispNewBranch){
638 $type = "branch";
639 }else{
640 $type = "freeze";
641 }
643 /* Check branch name */
644 $name = $_POST['BranchName'];
645 $is_ok = true;
646 $smarty->assign("BranchName",$name);
647 $base= $this->fai_base;
649 /* Check used characters */
650 if(!preg_match("/^[0-9a-z\.]*$/",$name)){
651 msg_dialog::display(_("Error"), msgPool::invalid(_("Name"),$name,"/[0-9a-z\.]/"), ERROR_DIALOG);
652 $is_ok = false;
653 }
655 /* Check if this name is already in use */
656 if(!$this->CheckNewBranchName($_POST['BranchName'],$this->fai_release)){
657 msg_dialog::display(_("Error"), msgPool::duplicated(_("Name")), ERROR_DIALOG);
658 $is_ok = false;
659 }
661 if($is_ok){
663 if(session::is_set('LASTPOST')){
664 $LASTPOST = session::get('LASTPOST');
665 }else{
666 $LASTPOST = array();
667 }
668 $LASTPOST['base'] = $base;
669 $LASTPOST['type'] = $type;
670 session::set('LASTPOST',$LASTPOST);
671 $smarty->assign("iframe", true);
672 $smarty->assign("plugID", $_GET['plug']);
673 $display = $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
674 return($display);
675 }
676 }
679 /****************
680 Create a new branch
681 ****************/
683 if(isset($_GET['PerformBranch'])){
685 if(!preg_match("/c/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
686 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
687 }else{
689 /* In order to see error messages we have to reset the error handler.
690 Due to the exit();
691 */
692 restore_error_handler();
694 /* Create it know */
695 $this->dispNewBranch = false;
696 $this->dispNewFreeze = false;
698 $LASTPOST = session::get('LASTPOST');
699 $base = $LASTPOST['base'];
700 $_POST = session::get('LASTPOST');
701 $name = $_POST['BranchName'];
703 $type = $LASTPOST['type'];
704 $ldap = $this->config->get_ldap_link();
706 $baseToUse = $base;
707 if($this->fai_release != $this->fai_base){
708 $baseToUse = $this->fai_release;
709 }
711 /* Create new Release name to be able to set faidebianRelease for FAIpackageList */
713 $CurrentReleases = $this->getBranches();
714 $NewReleaseName = $name;
715 if(isset($CurrentReleases[$this->fai_release])) {
716 if($this->fai_release != $this->fai_base){
717 $NewReleaseName = $CurrentReleases[$this->fai_release]."/".$name;
718 $NewReleaseName = preg_replace("#\/#","/",$NewReleaseName);
719 }else{
720 $NewReleaseName = $name;
721 }
722 }
724 $appsrc = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('applicationRDN'),$baseToUse);
725 $appdst = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('applicationRDN'),"ou=".$name.",".$baseToUse) ;
727 $mimesrc = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('mimetypeRDN'),$baseToUse);
728 $mimedst = preg_replace("/".preg_quote(get_ou('faiBaseRDN'), '/')."/",get_ou('mimetypeRDN'),"ou=".$name.",".$baseToUse) ;
730 /* Check if source depeartments exist */
731 foreach(array($baseToUse,$appsrc,$mimesrc) as $dep){
732 $ldap->cd($this->config->current['BASE']);
733 $ldap->cat($dep);
734 if(!$ldap->count()){
735 $ldap->create_missing_trees($dep);
736 }
737 }
739 /* Print header to have styles included */
740 echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
741 <html>
742 <head>
743 <title></title>
744 <style type="text/css">@import url("themes/default/style.css");</style>
745 <script language="javascript" src="include/focus.js" type="text/javascript"></script>
746 </head>
747 <body style="background: none;margin:3px;color:black">
748 ';
750 new log("create","fai/".get_class($this),$NewReleaseName,array(),"New $type created");
752 /* Duplicate group application releases
753 */
754 FAI::copy_FAI_group_releases($CurrentReleases[$this->fai_release],$name,$type);
756 /* Duplicate applications
757 */
758 $ldap->cat($appsrc,array("dn")) ;
759 if($ldap->count()){
760 $ldap->cd ($appdst);
761 $ldap->recursive_remove();
762 FAI::copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true);
763 }
765 /* Duplicate mime types
766 */
767 $ldap->cat($mimesrc,array("dn")) ;
768 if($ldap->count()){
769 $ldap->cd ($mimedst);
770 $ldap->recursive_remove();
771 FAI::copy_FAI_resource_recursive($mimesrc,$mimedst,$NewReleaseName,$type,true);
772 }
774 $attr = array();
775 $attr['objectClass'] = array("organizationalUnit","FAIbranch");
776 $attr['ou'] = $name;
777 $attr['FAIstate'] = $type;
778 $ldap->cd($this->config->current['BASE']);
779 $ldap->cd("ou=".$name.",".$baseToUse);
780 $ldap->cat("ou=".$name.",".$baseToUse);
781 if($ldap->count()){
782 $ldap->modify($attr);
783 }else{
784 $ldap->add($attr);
785 }
787 /* Duplicate fai objects
788 */
789 // $ldap->cd ("ou=".$name.",".$baseToUse);
790 // $ldap->recursive_remove();
791 // FAI::copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,$NewReleaseName,$type,true);
793 echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
794 <br><input type='submit' name='CloseIFrame' value='"._("Continue")."'>
795 <input type='hidden' name='php_c_check' value='1'>
796 </form></div>";
798 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
800 /* Print footer to have valid html */
801 echo "</body></html>";
803 $this->dispNewFreeze = false;
805 /* Postcreate */
807 /* Assign possible attributes */
808 $this->lock_type = $type;
809 $this->lock_name = $name;
810 $this->lock_dn = $baseToUse;
811 $this->postcreate();
814 /* Send daemon event to reload the fai release database
815 */
816 if(class_available("DaemonEvent") && class_available("gosaSupportDaemon")){
817 $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
818 if(isset($events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'])){
819 $evt = $events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'];
820 $tmp = new $evt['CLASS_NAME']($this->config);
821 $tmp->set_type(TRIGGERED_EVENT);
822 $tmp->add_targets(array("GOSA"));
823 $o_queue = new gosaSupportDaemon();
824 if(!$o_queue->append($tmp)){
825 msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
826 }
827 }
828 }else{
829 trigger_error("Unknown class DaemonEvent / gosaSupportDaemon");
830 msg_dialog::display(_("Fatal error"),
831 "Daemon events called but classes where not accessible, DaemonEvent gosaSupportDaemon",
832 FATAL_ERROR_DIALOG);
833 }
834 exit();
835 }
836 }
838 /****************
839 Display dialog to enter new Branch name
840 ****************/
842 /* Check if we have a post create method configured
843 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
844 */
845 if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
846 if(($s_action == "branch_branch")||($this->dispNewBranch)){
847 if(!preg_match("/c/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
848 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
849 }else{
850 $this->dispNewBranch=true;
851 $smarty->assign("iframe",false);
852 $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
853 return($display);
854 }
855 }
856 }
859 /****************
860 Display dialog to enter new Freeze name
861 ****************/
863 /* Check if we have a post create method configured
864 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
865 */
866 if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
867 if(($s_action == "freeze_branch")||($this->dispNewFreeze)){
868 if(!preg_match("/c/",$this->ui->get_permissions($this->acl_base,"fai/faiManagement"))){
869 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
870 }else{
871 $this->dispNewFreeze = true;
872 $smarty->assign("iframe",false);
873 $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
874 return($display);
875 }
876 }
877 }
880 /****************
881 Create a new object
882 ****************/
884 $types = array( "new_partition" => "FAIpartitionTable",
885 "new_script" => "FAIscript",
886 "new_hook" => "FAIhook",
887 "new_variable" => "FAIvariable",
888 "new_template" => "FAItemplate",
889 "new_package" => "FAIpackageList");
890 $types_i18n = array( "new_partition" => _("partition table"),
891 "new_script" => _("script"),
892 "new_hook" => _("hook"),
893 "new_variable" => _("variable"),
894 "new_template" => _("template"),
895 "new_package" => _("package list"));
897 if(isset($types[$s_action])){
898 $acl = $this->ui->get_permissions($this->acl_base,"fai/".$type_acl_mapping[$types[$s_action]]);
899 if(preg_match("/c/",$acl)){
900 $this->dialog = new askClassName($this->config,$this->dn,$this->ui,$types[$s_action]);
901 $this->dialog->parent = &$this;
902 }else{
903 msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), $types_i18n[$s_action]), ERROR_DIALOG);
904 }
905 }
907 /* New Profile */
908 if($s_action == "new_profile"){
909 $this->dn = "new" ;
911 $acl = $this->ui->get_permissions($this->acl_base,"fai/faiProfile");
912 if(preg_match("/c/",$acl)){
913 $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
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->base);
916 $this->dialog->parent = &$this;
918 $this->is_dialog = false;
919 }else{
920 msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), _("profile")), ERROR_DIALOG);
921 }
922 }
925 /****************
926 Get from ask class name dialog
927 ****************/
929 if($s_action == "select_class_name_finished"){
930 $this->dialog->save_object();
931 if(count($this->dialog->check())!=0){
932 foreach($this->dialog->check() as $msg){
933 msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
934 }
935 }elseif(isset($this->dialog->objectClass)){
936 $this->dn = "new" ;
937 $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass)));
938 $name = $this->dialog->save();
940 if(class_exists($a_setup[0])){
941 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
942 $this->dialog->set_acl_base($this->base);
943 $this->dialog->by_object[$a_setup[1]]->cn = $name;
944 $this->dialog->parent = &$this;
945 $this->is_dialog = true;
946 }
947 }
948 }
951 /****************
952 Cancel dialogs
953 ****************/
955 if(isset($_POST['edit_cancel'])){
956 $this->dialog=FALSE;
957 $this->is_dialog = false;
958 session::un_set('objectinfo');
959 $this->remove_lock();
960 }
963 /****************
964 Save sub dialogs
965 ****************/
967 /* This check if the given tab could be saved
968 * If it was possible to save it, remove dialog object.
969 * If it wasn't possible, show errors and keep dialog.
970 */
971 if((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->dialog->config))){
972 $this->dialog->save_object();
973 $msgs= $this->dialog->check();
974 if(count($msgs)!=0){
975 foreach($msgs as $msg){
976 msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
977 }
978 }else{
979 $this->dialog->save();
980 FAI::save_release_changes_now();
981 if (!isset($_POST['edit_apply'])){
982 $this->remove_lock();
983 $this->dialog=FALSE;
984 $this->is_dialog=false;
985 session::un_set('objectinfo');
986 }else{
988 /* Reinitialize tab */
989 if($this->dialog instanceof tabs){
990 $this->dialog->re_init();
991 }
992 }
993 }
994 }
997 /****************
998 Display currently open dialog
999 ****************/
1001 /* If dialog is set, but $this->is_dialog==false, then
1002 * only the "abort" button is shown, this are dialogs that must not be saved.
1003 * If is_dialog == true, we are currently editing tab objects.
1004 * Here we need both, save and cancel
1005 */
1007 if(is_object($this->dialog)){
1008 $display .= $this->dialog->execute();
1009 /* Don't show buttons if tab dialog requests this */
1011 if(isset($this->dialog->current)){
1013 $obj = $this->dialog->by_object[$this->dialog->current];
1015 if(($this->dialog instanceOf tabs || $this->dialog instanceOf plugin) && $this->dialog->read_only == TRUE){
1016 $display.= "<p style=\"text-align:right\">
1017 <input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">
1018 </p>";
1019 }elseif((isset($obj->is_dialog) && (!$obj->is_dialog)) || (isset($obj->dialog) && (!$obj->dialog))){
1021 $display.= "<p style=\"text-align:right\">\n";
1022 if(!$this->no_save){
1023 $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
1024 $display.= " \n";
1025 if ($this->dn != "new"){
1026 $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
1027 $display.= " \n";
1028 }
1029 }
1030 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1031 $display.= "</p>";
1032 }elseif(!isset($this->dialog->current)){
1033 $display.= "<p style=\"text-align:right\">\n";
1034 $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\"> ";
1035 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
1036 $display.= "</p>";
1037 }
1038 }else{
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>";
1044 }
1045 return($display);
1046 }
1049 /****************
1050 Dialog display
1051 ****************/
1053 /* Check if there is a snapshot dialog open */
1054 $base = $this->fai_base;
1055 if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
1056 return($str);
1057 }
1059 /* Display dialog with system list */
1060 $this->reload();
1061 $this->DivListFai->parent = &$this;
1062 $this->DivListFai->execute();
1063 $this->DivListFai->setEntries($this->objects);
1064 return($this->DivListFai->Draw());
1065 }
1068 /* Return departments, that will be included within snapshot detection */
1069 function get_used_snapshot_bases()
1070 {
1071 $tmp = array();
1072 $types = array("faiPartitionRDN","faiScriptRDN","faiTemplateRDN","faiHookRDN","faiProfileRDN","faiVariableRDN","faiPackageRDN");
1073 foreach($types as $type){
1074 $tmp[] = get_ou($type).$this->fai_release;
1075 }
1076 return($tmp);
1077 }
1080 /* Get available branches for current base */
1081 function getBranches($base = false,$prefix = "")
1082 {
1083 $ret = array("/"=>$this->fai_base);
1084 $ldap = $this->config->get_ldap_link();
1085 if(!$base){
1086 $base = $this->fai_base;
1087 }
1088 $tmp = FAI::get_all_releases_from_base($base,true);
1089 foreach($tmp as $dn => $name){
1090 $ret[$name]=$dn;
1091 }
1092 ksort($ret);
1093 $ret = array_flip($ret);
1095 return ($ret);
1096 }
1099 function list_get_selected_items()
1100 {
1101 $ids = array();
1102 foreach($_POST as $name => $value){
1103 if(preg_match("/^item_selected_[0-9]*$/",$name)){
1104 $id = preg_replace("/^item_selected_/","",$name);
1105 $ids[$id] = $id;
1106 }
1107 }
1108 return($ids);
1109 }
1112 /* reload list of objects */
1113 function reload()
1114 {
1115 /* Variable initialisation */
1116 $str = "";
1117 $Regex = $this->DivListFai->Regex;
1118 $this->objects = array();
1120 /* Get base */
1121 $base = $this->fai_base;
1122 if($this->fai_release != $this->fai_base){
1123 $br = $this->getBranches();
1124 if(isset($br[$this->fai_release])){
1125 $base = $this->fai_release;
1126 }else{
1127 $base = $this->fai_base;
1128 }
1129 }
1130 $this->base = $base;
1131 $this->set_acl_base($this->acl_base);
1133 $this->lock_type = FAI::get_release_tag(FAI::get_release_dn($base));
1135 /* Create a new list of FAI object
1136 * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ...
1137 */
1138 $ObjectTypes = array(
1139 "FAIpartitionTable" => array("OU"=> get_ou('faiPartitionRDN') , "CHKBOX"=>"ShowPartitions" ,"ACL" => "faiPartitionTable"),
1140 "FAIpackageList" => array("OU"=> get_ou('faiPackageRDN') , "CHKBOX"=>"ShowPackages" ,"ACL" => "faiPackage"),
1141 "FAIscript" => array("OU"=> get_ou('faiScriptRDN') , "CHKBOX"=>"ShowScripts" ,"ACL" => "faiScript"),
1142 "FAIvariable" => array("OU"=> get_ou('faiVariableRDN') , "CHKBOX"=>"ShowVariables" ,"ACL" => "faiVariable"),
1143 "FAIhook" => array("OU"=> get_ou('faiHookRDN') , "CHKBOX"=>"ShowHooks" ,"ACL" => "faiHook"),
1144 "FAIprofile" => array("OU"=> get_ou('faiProfileRDN') , "CHKBOX"=>"ShowProfiles" ,"ACL" => "faiProfile"),
1145 "FAItemplate" => array("OU"=> get_ou('faiTemplateRDN') , "CHKBOX"=>"ShowTemplates" ,"ACL" => "faiTemplate"));
1147 $filter = "";
1148 foreach($ObjectTypes as $key => $data){
1149 if($this->DivListFai->$data['CHKBOX']){
1150 $filter.= "(objectClass=".$key.")";
1151 }
1152 }
1153 $filter = "(&(|".$filter.")(cn=$Regex))";
1155 /* Get resolved release dependencies */
1156 $tmp = FAI::get_all_objects_for_given_base($base,$filter);
1158 /* Ge listed ldap objects */
1159 $ldap = $this->config->get_ldap_link();
1160 $ldap->cd($this->config->current['BASE']);
1162 foreach($tmp as $entry){
1164 /* Get some more informations about the object */
1165 $ldap->cat($entry['dn'], array("cn","description","objectClass","FAIclass","FAIstate","objectClass"));
1166 $object = $ldap->fetch();
1168 /* Walk through possible types */
1169 foreach($ObjectTypes as $type => $rest){
1171 $acl = $this->ui->get_permissions($object['dn'],"fai/".$rest ['ACL']);
1173 if(in_array($type,$object['objectClass']) && preg_match("/r/",$acl)){
1175 /* Prepare object */
1176 unset($object['objectClass']['count']);
1177 if(!isset($object['description'][0])){
1178 $object['description'][0]="";
1179 }
1181 /* Clean up object informations */
1182 $obj = array();
1183 $obj['cn'] = $object['cn'][0];
1184 $obj['dn'] = $object['dn'];
1185 $obj['acl'] = $acl;
1186 $obj['class'] = $rest ['ACL'];
1187 $obj['FAIstate'] = $entry['FAIstate'];
1188 $obj['description'] = $object['description'][0];
1189 $obj['objectClass'] = $object['objectClass'];
1191 $this->objects[$obj['cn']][$type] = $obj;
1192 $this->objects[$obj['cn']][$type]['type']=$type;
1193 }
1194 }
1195 }
1197 /* Append opsi objects, if opsi is available and if we are on the fai_base
1198 */
1199 if($this->opsi instanceof opsi && $this->opsi->enabled()){
1200 $opsi_acl = $this->ui->get_permissions($base,"opsi/opsiProperties");
1201 if(preg_match("/r/",$opsi_acl)){
1202 $err = FALSE;
1203 if(!$err && $this->DivListFai->ShowOpsiNetboot){
1204 $n_pro = $this->opsi->get_netboot_products();
1205 $err |= $this->opsi->is_error();
1206 foreach($n_pro as $name => $data){
1207 $entry = array("cn" => $name,
1208 "description" => $data['DESC'],
1209 "type" => "opsi_netboot");
1210 $this->objects[$name]['opse_netboot'] = $entry;
1211 }
1212 }
1213 if(!$err && $this->DivListFai->ShowOpsiLocal){
1214 $l_pro = $this->opsi->get_local_products();
1215 $err |= $this->opsi->is_error();
1216 foreach($l_pro as $name => $data){
1217 $entry = array("cn" => $name,
1218 "description" => $data['DESC'],
1219 "type" => "opsi_local");
1220 $this->objects[$name]["opsi_local"] = $entry;
1221 }
1222 }
1223 if($err){
1224 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
1225 }
1226 }
1227 }
1229 uksort($this->objects, 'strnatcasecmp');
1230 reset ($this->objects);
1231 $this->objects = array_values($this->objects);
1232 }
1234 function remove_lock()
1235 {
1236 if (isset($this->dn)){
1237 del_lock ($this->dn);
1238 }
1239 if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
1240 del_lock ($this->dns);
1241 }
1242 }
1244 function get_type($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 }
1269 function CheckNewBranchName($name,$base)
1270 {
1271 $f = $this->fai_release;
1272 if($name == ""){
1273 return(false);
1274 }elseif(in_array($name,$this->getBranches($f))) {
1275 return(false);
1276 }elseif(tests::is_department_name_reserved($name,$base)){
1277 return(false);
1278 }
1279 return(true);
1280 }
1282 function save_object()
1283 {
1284 $this->DivListFai->save_object();
1286 /* Get posted release */
1287 $r_releases = array_flip($this->getBranches());
1288 if(isset($_POST['fai_release']) && isset($r_releases[get_post('fai_release')])){
1290 /* Ensure that we have a valid release selected */
1291 if(!isset($r_releases[get_post('fai_release')])){
1292 msg_dialog::display(_("Warning"),_("The selected release is not available anymore. All triggered actions are skipped."));
1293 $_POST = array();
1294 $plug =$_GET['plug'];
1295 $_GET = array("plug" => $plug);
1296 $this->fai_release = $this->fai_base;
1297 }else{
1298 $this->fai_release = $r_releases[get_post('fai_release')];
1299 }
1301 $fai_filter = session::get("fai_filter");
1302 $fai_filter['fai_release'] = $this->fai_release;
1303 session::set("fai_filter",$fai_filter);
1304 }
1306 if(is_object($this->CopyPasteHandler)){
1307 $this->CopyPasteHandler->save_object();
1308 }
1309 }
1312 function copyPasteHandling_from_queue($s_action,$s_entry)
1313 {
1314 /* Check if Copy & Paste is disabled */
1315 if(!is_object($this->CopyPasteHandler)){
1316 return("");
1317 }
1319 $ui = get_userinfo();
1321 /* Add a single entry to queue */
1322 if($s_action == "copy"){
1324 /* Cleanup object queue */
1325 $this->CopyPasteHandler->cleanup_queue();
1326 $entry = $this->objects[$s_entry];
1327 $a_setup = $this->get_type($entry);
1328 $dn = $entry['dn'];
1330 if($ui->is_copyable($dn,"fai",$a_setup[1])){
1331 $this->CopyPasteHandler->add_to_queue($dn,$s_action,$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1332 }
1333 }
1335 /* Add entries to queue */
1336 if($s_action == "copy_multiple"){
1338 /* Cleanup object queue */
1339 $this->CopyPasteHandler->cleanup_queue();
1341 /* Add new entries to CP queue */
1342 foreach($this->list_get_selected_items() as $id){
1344 /* Cleanup object queue */
1345 $entry = $this->objects[$id];
1346 $a_setup = $this->get_type($entry);
1347 $dn = $entry['dn'];
1349 if($s_action == "copy_multiple" && $ui->is_copyable($dn,"fai",$a_setup[1])){
1350 $this->CopyPasteHandler->add_to_queue($dn,"copy",$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1351 }
1352 }
1353 }
1355 /* Start pasting entries */
1356 if($s_action == "editPaste" && !($this->lock_type == "freeze" && !$this->allow_freeze_object_attach)){
1357 $this->start_pasting_copied_objects = TRUE;
1358 }
1360 /* Return C&P dialog */
1361 if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
1363 /* Get dialog */
1364 $this->CopyPasteHandler->SetVar("parent",$this);
1365 $data = $this->CopyPasteHandler->execute();
1367 FAI::save_release_changes_now();
1369 /* Return dialog data */
1370 if(!empty($data)){
1371 return($data);
1372 }
1373 }
1375 /* Automatically disable status for pasting */
1376 if(!$this->CopyPasteHandler->entries_queued()){
1377 $this->start_pasting_copied_objects = FALSE;
1378 }
1379 return("");
1380 }
1383 /* Check if the given FAI class is used in this release
1384 */
1385 static function check_class_name($oc,$name,$dn)
1386 {
1387 $base = FAI::get_release_dn($dn);
1389 if($oc == "FAIprofile"){
1390 $f = "";
1391 $ocs = array("FAIprofile","FAItemplate","FAIhook","FAIpartitionTable","FAIpackageList","FAIscript","FAIvariable");
1392 foreach($ocs as $oc){
1393 $f .= "(objectClass=".$oc.")";
1394 }
1395 $res = FAI::get_all_objects_for_given_base($base,"(|".$f.")",TRUE);
1396 }else{
1397 $res = FAI::get_all_objects_for_given_base($base,"(objectClass=".$oc.")",TRUE);
1398 }
1399 $delete = array();
1400 $used = array();
1401 foreach($res as $object){
1402 $used[$object['cn'][0]]= $object['cn'][0];
1403 }
1404 return($used);
1405 }
1408 /* Return plugin informations for acl handling */
1409 static function plInfo()
1410 {
1411 return (array(
1412 "plShortName" => _("FAI releases"),
1413 "plDescription" => _("FAI release management"),
1414 "plSelfModify" => FALSE,
1415 "plDepends" => array(),
1416 "plPriority" => 0,
1417 "plSection" => array("administration"),
1418 "plCategory" => array("fai"=> array("description" => _("FAI"),
1419 "objectClass" => "FAIclass")),
1420 "plProvidedAcls"=> array()));
1421 }
1422 }
1423 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1424 ?>