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