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 $fai_base ="";
55 var $fai_release ="";
57 var $acl_module = array("fai");
59 var $opsi = NULL;
61 /* construction/reconstruction
62 */
63 function faiManagement (&$config, $ui)
64 {
65 /* Set defaults */
66 $this->dn = "";
67 $this->config = $config;
68 $this->ui = $ui;
70 /* Check if the opsi plugin is installed.
71 */
72 if(class_available("opsi")){
73 $this->opsi = new opsi($this->config);;
74 }
76 /* Creat dialog object */
77 $this->DivListFai = new divListFai($this->config,$this);
79 /* Copy & Paste handler */
80 if ($this->config->boolValueIsTrue("main", "enableCopyPaste")){
81 $this->CopyPasteHandler= new CopyPasteHandler($this->config);
82 }
84 /* Set default release */
85 $this->fai_base = get_ou("faiou").$this->config->current['BASE'];
87 if(!session::is_set("fai_filter")){
89 /* Set intial release */
90 $rel = $config->search("faiManagement","DEFAULT_RELEASE",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/"));
124 /****************
125 Handle posts
126 ****************/
128 /* Check ImageButton posts
129 * Create new tab ich new_xx is posted
130 */
131 $posts = array( "/remove_branch/"=>"remove_branch", "/branch_branch/"=>"branch_branch",
132 "/freeze_branch/"=>"freeze_branch", "/create_partition/i"=>"new_partition",
133 "/create_script/i"=>"new_script", "/create_hook/i"=>"new_hook",
134 "/create_variable/i"=>"new_variable", "/create_template/i"=>"new_template",
135 "/create_package/i"=>"new_package", "/create_profile/i"=>"new_profile",
136 "/edit_continue/"=>"select_class_name_finished",
137 "/^multiple_copy_fai/" => "copy_multiple",
138 "/^multiple_cut_fai/" => "cut_multiple",
139 "/^copy/" => "copy",
140 "/^remove_multiple_fai_objects/" => "del_multiple");
142 print_a($_POST);
144 foreach($_POST as $name => $value){
145 foreach($posts as $reg => $act ){
146 if(preg_match($reg,$name)){
147 $s_action = $act;
148 $s_entry = ltrim(preg_replace($reg,"",$name),"_");
149 $s_entry = preg_replace("/_.*$/","",$s_entry);
150 break;
151 }
152 }
153 if(preg_match("/^entry_edit_.*/",$name)){
154 $s_entry = preg_replace("/^entry_edit_/","",$name);
155 $s_entry = preg_replace("/_.*$/","",$s_entry);
156 $s_action = "edit";
157 break;
158 }elseif(preg_match("/^entry_freeze_edit_.*/",$name)){
159 $s_entry = preg_replace("/^entry_freeze_edit_/","",$name);
160 $s_entry = preg_replace("/_.*$/","",$s_entry);
161 $s_action = "edit";
162 $no_save = TRUE;
163 break;
164 }elseif(preg_match("/^entry_delete_.*/",$name)){
165 $s_entry = preg_replace("/^entry_delete_/","",$name);
166 $s_entry = preg_replace("/_.*$/","",$s_entry);
167 $s_action = "delete";
168 break;
169 }
171 /* Get posts from opsi onjects
172 */
173 if($this->opsi instanceof opsi && $this->opsi->enabled()){
174 if(preg_match("/^entry_opsi_edit_/",$name)){
175 $s_entry = preg_replace("/^entry_opsi_edit_([0-9]*).*$/","\\1",$name);
176 $s_action = "opsi_edit";
177 break;
178 }
179 }
180 }
182 /* Get posts from opsi objects
183 */
184 if($this->opsi instanceof opsi && $this->opsi->enabled() && isset($_GET['edit_opsi_entry'])){
185 $s_entry = $_GET['edit_opsi_entry'];
186 $s_action = "opsi_edit";
187 }
189 if(isset($_GET['edit_entry'])){
190 $s_entry = $_GET['edit_entry'];
191 $s_action = "edit";
192 }
194 if(isset($_GET['edit_freeze_entry'])){
195 $s_entry = $_GET['edit_freeze_entry'];
196 $s_action = "edit";
197 $no_save = TRUE;
198 }
200 if(isset($_GET['act']) && $_GET['act'] == "freeze_branch"){
201 $s_action = "freeze_branch";
202 }
203 if(isset($_GET['act']) && $_GET['act'] == "branch_branch"){
204 $s_action = "branch_branch";
205 }
206 if(isset($_GET['act']) && $_GET['act'] == "remove_branch"){
207 $s_action = "remove_branch";
208 }
210 if((isset($_POST['CancelBranchName'])) || (isset($_POST['CloseIFrame']))){
211 $this->dispNewBranch = false;
212 $this->dispNewFreeze = false;
213 }
216 $type_acl_mapping = array(
217 "FAIpartitionTable" => "faiPartitionTable",
218 "FAIpackageList" => "faiPackage",
219 "FAIscript" => "faiScript",
220 "FAIvariable" => "faiVariable",
221 "FAIhook" => "faiHook",
222 "FAIprofile" => "faiProfile",
223 "FAItemplate" => "faiTemplate");
226 /* handle C&P from layers menu */
227 if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){
228 $s_action = "copy_multiple";
229 }
230 if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){
231 $s_action = "cut_multiple";
232 }
233 if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){
234 $s_action = "editPaste";
235 }
237 /* Create options */
238 if(isset($_POST['menu_action']) && preg_match("/^Create_/",$_POST['menu_action'])){
239 $s_action = "new_".preg_replace("/^Create_/","",$_POST['menu_action']);;
240 $s_entry = preg_replace("/^Create_/","",$_POST['menu_action']);
241 }
243 /* handle remove from layers menu */
244 if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){
245 $s_action = "del_multiple";
246 }
249 if(!empty($s_action)){
250 $this->no_save = $no_save;
251 }
253 /********************
254 Copy & Paste
255 ********************/
257 /* Display the copy & paste dialog, if it is currently open */
258 $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
259 if($ret){
260 return($ret);
261 }
264 /*******************
265 Opsi extension
266 *******************/
268 if($this->opsi instanceof opsi && $this->opsi->enabled()){
269 if($s_action == "opsi_edit"){
270 $name = $this->objects[$s_entry]['cn'];
271 $cfg = $this->opsi->get_product_properties($name);
272 $this->dialog = new opsiProductConfig($this->config, $name,$cfg);
273 }
274 if($this->dialog instanceof opsiProductConfig && isset($_POST['cancel_properties'])){
275 $this->dialog = NULL;
276 }
277 if($this->dialog instanceof opsiProductConfig && isset($_POST['save_properties'])){
278 $this->dialog->save_object();
279 $name = $this->dialog->get_product();
280 $cfg = $this->dialog->get_cfg();
281 $this->opsi->set_product_properties($name,$cfg);
282 if($this->opsi->is_error()){
283 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
284 }else{
285 $this->dialog = NULL;
286 }
287 }
288 if($this->dialog instanceof opsiProductConfig){
289 $this->dialog->save_object();
290 return($this->dialog->execute());
291 }
292 }
295 /****************
296 Delete confirme dialog
297 ****************/
299 if ($s_action=="delete"){
301 /* Get 'dn' from posted termlinst */
302 $this->dn= $this->objects[$s_entry]['dn'];
304 /* Load permissions for selected 'dn' and check if
305 we're allowed to remove this 'dn' */
306 $acl = $this->ui->get_permissions($this->dn,"fai/".$type_acl_mapping[$this->objects[$s_entry]['type']]);
307 if(preg_match("/d/",$acl)){
309 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
310 if (($user= get_lock($this->dn)) != ""){
311 return(gen_locked_message ($user, $this->dn));
312 }
314 /* Lock the current entry, so nobody will edit it during deletion */
315 add_lock ($this->dn, $this->ui->dn);
316 $smarty->assign("warning",msgPool::deleteInfo(@LDAP::fix($this->dn),_("FAI object")));
317 $smarty->assign("multiple", false);
318 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
319 } else {
321 /* Obviously the user isn't allowed to delete. Show message and clean session. */
322 msg_dialog::display(_("Permission error"), msgPool::permDelete(),ERROR_DIALOG);
323 }
324 }
327 /********************
328 Delete MULTIPLE entries requested, display confirm dialog
329 ********************/
331 if ($s_action=="del_multiple"){
332 $this->dns = array();
333 $ids = $this->list_get_selected_items();
335 if(count($ids)){
337 $errors = "";
338 foreach($ids as $id){
339 $dn = $this->objects[$id]['dn'];
340 $cn = $this->objects[$id]['cn'];
341 if(!preg_match('/^freeze/', $this->objects[$id]['FAIstate'])){
342 $this->dns[$id] = $dn;
343 }else{
344 $errors .= $cn.", ";
345 }
346 }
347 if ($user= get_multiple_locks($this->dns)){
348 return(gen_locked_message($user,$this->dns));
349 }
351 if($errors != ""){
352 msg_dialog::display(_("Branch locked"),sprintf(_("The following entries are locked, you can't remove them %s."),
353 "<br><br>".trim($errors,", ")),INFO_DIALOG);
354 }
356 if(count($this->dns)){
358 $dns_names = array();
359 foreach($this->dns as $dn){
360 add_lock ($dn, $this->ui->dn);
361 $dns_names[] = @LDAP::fix($dn);
362 }
364 /* Lock the current entry, so nobody will edit it during deletion */
365 $smarty->assign("warning",msgPool::deleteInfo($dns_names,_("FAI object")));
366 $smarty->assign("multiple", true);
367 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
368 }
369 }
370 }
373 /********************
374 Delete MULTIPLE entries confirmed
375 ********************/
377 /* Confirmation for deletion has been passed. Users should be deleted. */
378 if (isset($_POST['delete_multiple_fai_object_confirm'])){
380 /* Find out more about the object type */
381 $ldap = $this->config->get_ldap_link();
383 /* Remove user by user and check acls before removeing them */
384 foreach($this->dns as $key => $dn){
386 $ldap->cat($dn, array('objectClass'));
387 $attrs = $ldap->fetch();
388 $type = $this->get_type($attrs);
390 $acl = $this->ui->get_permissions($dn,"fai/".$type[1]);
391 if(preg_match("/d/",$acl)){
393 $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $dn,"fai");
394 $this->dialog->parent = &$this;
395 $this->dialog->set_acl_base($dn);
396 $this->dialog->by_object[$type[1]]->remove_from_parent ();
397 unset ($this->dialog);
398 $this->dialog= FALSE;
399 $to_del = FAI::clean_up_releases($dn);
400 FAI::save_release_changes_now();
402 foreach($to_del as $dn){
403 $ldap->rmdir_recursive($dn);
404 }
406 } else {
408 /* Normally this shouldn't be reached, send some extra
409 logs to notify the administrator */
410 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
411 new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion.");
412 }
413 }
415 /* Remove lock file after successfull deletion */
416 $this->remove_lock();
417 $this->dns = array();
418 }
421 /********************
422 Delete MULTIPLE entries Canceled
423 ********************/
425 /* Remove lock */
426 if(isset($_POST['delete_multiple_fai_object_cancel'])){
427 $this->dns = array();
428 $this->remove_lock();
429 }
432 /****************
433 Delete aborted
434 ****************/
436 /* Delete canceled? */
437 if (isset($_POST['delete_cancel'])){
438 $this->remove_lock();
439 }
442 /****************
443 Delete confirmed
444 ****************/
446 /* Deltetion was confirmed, so delete this entry
447 */
448 if (isset($_POST['delete_terminal_confirm'])){
450 /* Some nice guy may send this as POST, so we've to check
451 for the permissions again. */
453 /* Find out more about the object type */
454 $ldap = $this->config->get_ldap_link();
455 $ldap->cat($this->dn, array('objectClass'));
456 if($ldap->count()){
457 $attrs = $ldap->fetch();
458 $type = $this->get_type($attrs);
460 $acl = $this->ui->get_permissions($this->dn,"fai/".$type[1]);
461 if(preg_match("/d/",$acl)){
463 $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $this->dn,"fai");
464 $this->dialog->set_acl_base($this->dn);
465 $this->dialog->parent = &$this;
466 $this->dialog->by_object[$type[1]]->remove_from_parent ();
467 unset ($this->dialog);
468 $this->dialog= FALSE;
469 $to_del = FAI::clean_up_releases($this->dn);
470 FAI::save_release_changes_now();
472 foreach($to_del as $dn){
473 $ldap->rmdir_recursive($dn);
474 }
476 } else {
478 /* Normally this shouldn't be reached, send some extra
479 logs to notify the administrator */
480 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
481 new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion.");
482 }
484 }else{
485 msg_dialog::display(_("Error"), sprintf(_("Cannot delete '%s': object does not exist!"), $this->dn) , ERROR_DIALOG);
486 }
488 /* Remove lock file after successfull deletion */
489 $this->remove_lock();
490 }
493 /****************
494 Edit entry
495 ****************/
497 if(($s_action == "edit") && (!isset($this->dialog->config))){
498 $entry = $this->objects[$s_entry];
499 $a_setup = $this->get_type($entry);
500 $this->dn = $entry['dn'];
502 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
503 if (($user= get_lock($this->dn)) != ""){
504 return(gen_locked_message ($user, $this->dn));
505 }
506 add_lock ($this->dn, $this->ui->dn);
508 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
509 $this->dialog->parent = &$this;
510 $this->dialog->by_object[$a_setup[1]]->FAIstate = $entry['FAIstate'];
511 $this->dialog->set_acl_base($this->dn);
512 $this->is_dialog = true;
513 session::set('objectinfo',$this->dn);
514 }
517 /* Branch handling
518 09.01.2006
519 */
521 /****************
522 Remove branch
523 ****************/
525 /* Remove branch
526 */
527 if($s_action == "remove_branch"){
528 $base= $this->fai_release;
530 /* Check if we have a post remove method configured
531 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
532 */
533 if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
534 /* Load permissions for selected 'dn' and check if
535 we're allowed to remove this 'dn' */
536 if($this->acl_is_removeable()){
537 $smarty->assign("release_hidden",base64_encode($this->fai_release));
538 $smarty->assign("info", msgPool::deleteInfo(@LDAP::fix($this->fai_release),_("FAI branch/freeze")));
539 return($smarty->fetch(get_template_path('remove_branch.tpl',TRUE)));
540 } else {
541 msg_dialog::display(_("Permission error"), _("You have no permission to delete this release!"), ERROR_DIALOG);
542 }
543 }
544 }
547 /****************
548 Remove branch confirmed
549 ****************/
551 if(isset($_POST['delete_branch_confirm'])){
553 /* Check if we have a post remove method configured
554 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
555 */
556 if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
558 if(!isset($_POST['release_hidden']) || base64_decode($_POST['release_hidden']) != $this->fai_release){
559 msg_dialog::display(_("Warning"),_("Release remove aborted because the release name check failed!"));
560 }else{
562 $bb = $this->fai_release;
563 if(!isset($ldap)){
564 $ldap = $this->config->get_ldap_link();
565 }
567 $br = $this->getBranches();
569 if(isset($br[$bb]) && $this->acl_is_removeable()){
570 $name = $br[$bb];
572 $ldap->cd($bb);
573 $ldap->recursive_remove();
574 $ldap->cd(preg_replace('/,'.normalizePreg(get_ou('faiou')).'/', ','.get_ou('applicationou'), $bb));
575 $ldap->recursive_remove();
576 $ldap->cd(preg_replace('/,'.normalizePreg(get_ou('faiou')).'/', ','.get_ou('mimetypeou'), $bb));
577 $ldap->recursive_remove();
579 /* Search for all groups with configured application menus.
580 - First search all groups, to ensure that we only remove entries form whithin groups.
581 - The search für menu configuration for the specified release and collect all those dns.
582 - Remove entries
583 */
584 $release_ou = preg_replace("/".normalizePreg(get_ou("faiou")).".*$/","",$bb);
585 $ldap->cd($this->config->current['BASE']);
586 $ldap->search("(objectClass=posixGroup)",array("dn"));
588 /* Collect all group dns
589 */
590 $groups = array();
591 while($attrs = $ldap->fetch()){
592 $groups[] = $attrs['dn'];
593 }
595 /* Collect all group menu release dns that match the release we have removed
596 */
597 $dns = array();
598 foreach($groups as $dn){
599 $ldap->cd($dn);
600 $ldap->search("(objectClass=FAIbranch)",array("dn"));
601 while($attrs = $ldap->fetch()){
602 if(preg_match("/^".normalizePreg($release_ou)."/",$attrs['dn'])){
603 $dns[] = $attrs['dn'];
604 }
605 }
606 }
608 /* Finally remove collected release dns
609 */
610 foreach($dns as $dn){
611 $ldap->cd($dn);
612 $ldap->recursive_remove();
613 }
615 /* Post remove */
616 $this->fai_release = $this->fai_base;
617 $this->lock_name = $name;
618 $this->lock_dn = $bb;
619 $this->postremove();
621 $fai_filter = session::get("fai_filter");
622 $fai_filter['fai_release'] = $this->fai_release;
623 session::set("fai_filter",$fai_filter);
625 new log("remove","fai/".get_class($this),$br[$bb],array(),"Release removed");
626 }
627 }
628 }
629 }
632 /****************
633 Create a new branch "insert Name"
634 ****************/
636 if((isset($_POST['UseBranchName']))&&(($this->dispNewBranch)||($this->dispNewFreeze))){
637 session::set('LASTPOST',$_POST);
639 if($this->dispNewBranch){
640 $type = "branch";
641 }else{
642 $type = "freeze";
643 }
645 /* Check branch name */
646 $name = $_POST['BranchName'];
647 $is_ok = true;
648 $smarty->assign("BranchName",$name);
649 $base= $this->fai_base;
651 /* Check used characters */
652 if(!preg_match("/^[0-9a-z\.]*$/",$name)){
653 msg_dialog::display(_("Error"), msgPool::invalid(_("Name"),$name,"/[0-9a-z\.]/"), ERROR_DIALOG);
654 $is_ok = false;
655 }
657 /* Check if this name is already in use */
658 if(!$this->CheckNewBranchName($_POST['BranchName'],$this->fai_release)){
659 msg_dialog::display(_("Error"), msgPool::duplicated(_("Name")), ERROR_DIALOG);
660 $is_ok = false;
661 }
663 if($is_ok){
665 if(session::is_set('LASTPOST')){
666 $LASTPOST = session::get('LASTPOST');
667 }else{
668 $LASTPOST = array();
669 }
670 $LASTPOST['base'] = $base;
671 $LASTPOST['type'] = $type;
672 session::set('LASTPOST',$LASTPOST);
673 $smarty->assign("iframe", true);
674 $smarty->assign("plugID", $_GET['plug']);
675 $display = $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
676 return($display);
677 }
678 }
681 /****************
682 Create a new branch
683 ****************/
685 if(isset($_GET['PerformBranch'])){
687 if(!$this->acl_is_createable()){
688 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
689 }else{
691 /* In order to see error messages we have to reset the error handler.
692 Due to the exit();
693 */
694 restore_error_handler();
696 /* Create it know */
697 $this->dispNewBranch = false;
698 $this->dispNewFreeze = false;
700 $LASTPOST = session::get('LASTPOST');
701 $base = $LASTPOST['base'];
702 $_POST = session::get('LASTPOST');
703 $name = $_POST['BranchName'];
705 $type = $LASTPOST['type'];
706 $ldap = $this->config->get_ldap_link();
708 $baseToUse = $base;
709 if($this->fai_release != $this->fai_base){
710 $baseToUse = $this->fai_release;
711 }
713 /* Create new Release name to be able to set faidebianRelease for FAIpackageList */
715 $CurrentReleases = $this->getBranches();
716 $NewReleaseName = $name;
717 if(isset($CurrentReleases[$this->fai_release])) {
718 if($this->fai_release != $this->fai_base){
719 $NewReleaseName = $CurrentReleases[$this->fai_release]."/".$name;
720 $NewReleaseName = preg_replace("#\/#","/",$NewReleaseName);
721 }else{
722 $NewReleaseName = $name;
723 }
724 }
726 $appsrc = preg_replace("/".normalizePreg(get_ou('faiou'))."/",get_ou('applicationou'),$baseToUse);
727 $appdst = preg_replace("/".normalizePreg(get_ou('faiou'))."/",get_ou('applicationou'),"ou=".$name.",".$baseToUse) ;
729 $mimesrc = preg_replace("/".normalizePreg(get_ou('faiou'))."/",get_ou('mimetypeou'),$baseToUse);
730 $mimedst = preg_replace("/".normalizePreg(get_ou('faiou'))."/",get_ou('mimetypeou'),"ou=".$name.",".$baseToUse) ;
732 /* Check if source depeartments exist */
733 foreach(array($baseToUse,$appsrc,$mimesrc) as $dep){
734 $ldap->cd($this->config->current['BASE']);
735 $ldap->cat($dep);
736 if(!$ldap->count()){
737 $ldap->create_missing_trees($dep);
738 }
739 }
741 /* Print header to have styles included */
742 echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
743 <html>
744 <head>
745 <title></title>
746 <style type="text/css">@import url("themes/default/style.css");</style>
747 <script language="javascript" src="include/focus.js" type="text/javascript"></script>
748 </head>
749 <body style="background: none;margin:3px;color:black">
750 ';
752 new log("create","fai/".get_class($this),$NewReleaseName,array(),"New $type created");
754 /* Duplicate group application releases
755 */
756 FAI::copy_FAI_group_releases($CurrentReleases[$this->fai_release],$name,$type);
758 /* Duplicate applications
759 */
760 $ldap->cat($appsrc,array("dn")) ;
761 if($ldap->count()){
762 $ldap->cd ($appdst);
763 $ldap->recursive_remove();
764 FAI::copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true);
765 }
767 /* Duplicate mime types
768 */
769 $ldap->cat($mimesrc,array("dn")) ;
770 if($ldap->count()){
771 $ldap->cd ($mimedst);
772 $ldap->recursive_remove();
773 FAI::copy_FAI_resource_recursive($mimesrc,$mimedst,$NewReleaseName,$type,true);
774 }
776 $attr = array();
777 $attr['objectClass'] = array("organizationalUnit","FAIbranch");
778 $attr['ou'] = $name;
779 $attr['FAIstate'] = $type;
780 $ldap->cd($this->config->current['BASE']);
781 $ldap->cd("ou=".$name.",".$baseToUse);
782 $ldap->cat("ou=".$name.",".$baseToUse);
783 if($ldap->count()){
784 $ldap->modify($attr);
785 }else{
786 $ldap->add($attr);
787 }
789 /* Duplicate fai objects
790 */
791 // $ldap->cd ("ou=".$name.",".$baseToUse);
792 // $ldap->recursive_remove();
793 // FAI::copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,$NewReleaseName,$type,true);
795 echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
796 <br><input type='submit' name='CloseIFrame' value='"._("Continue")."'>
797 </form></div>";
799 echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
801 /* Print footer to have valid html */
802 echo "</body></html>";
804 $this->dispNewFreeze = false;
806 /* Postcreate */
808 /* Assign possible attributes */
809 $this->lock_type = $type;
810 $this->lock_name = $name;
811 $this->lock_dn = $baseToUse;
812 $this->postcreate();
815 /* Send daemon event to reload the fai release database
816 */
817 if(class_available("DaemonEvent") && class_available("gosaSupportDaemon")){
818 $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
819 if(isset($events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'])){
820 $evt = $events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'];
821 $tmp = new $evt['CLASS_NAME']($this->config);
822 $tmp->set_type(TRIGGERED_EVENT);
823 $tmp->add_targets(array("GOsa"));
824 $o_queue = new gosaSupportDaemon();
825 if(!$o_queue->append($tmp)){
826 msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
827 }
828 }
829 }else{
830 trigger_error("Unknown class DaemonEvent / gosaSupportDaemon");
831 msg_dialog::display(_("Fatal error"),
832 "Daemon events called but classes where not accessible, DaemonEvent gosaSupportDaemon",
833 FATAL_ERROR_DIALOG);
834 }
835 exit();
836 }
837 }
839 /****************
840 Display dialog to enter new Branch name
841 ****************/
843 /* Check if we have a post create method configured
844 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
845 */
846 if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
847 if(($s_action == "branch_branch")||($this->dispNewBranch)){
848 if(!$this->acl_is_createable()){
849 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
850 }else{
851 $this->dispNewBranch=true;
852 $smarty->assign("iframe",false);
853 $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
854 return($display);
855 }
856 }
857 }
860 /****************
861 Display dialog to enter new Freeze name
862 ****************/
864 /* Check if we have a post create method configured
865 * else skip this operation. (Skip:Button in the ui should be disabled in this case too)
866 */
867 if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
868 if(($s_action == "freeze_branch")||($this->dispNewFreeze)){
869 if(!$this->acl_is_createable()){
870 msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
871 }else{
872 $this->dispNewFreeze = true;
873 $smarty->assign("iframe",false);
874 $display .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
875 return($display);
876 }
877 }
878 }
881 /****************
882 Create a new object
883 ****************/
885 $types = array( "new_partition" => "FAIpartitionTable",
886 "new_script" => "FAIscript",
887 "new_hook" => "FAIhook",
888 "new_variable" => "FAIvariable",
889 "new_template" => "FAItemplate",
890 "new_package" => "FAIpackageList");
891 $types_i18n = array( "new_partition" => _("partition table"),
892 "new_script" => _("script"),
893 "new_hook" => _("hook"),
894 "new_variable" => _("variable"),
895 "new_template" => _("template"),
896 "new_package" => _("package list"));
898 if(isset($types[$s_action])){
899 $acl = $this->ui->get_permissions($this->fai_base,"fai/".$type_acl_mapping[$types[$s_action]]);
900 if(preg_match("/c/",$acl)){
901 $this->dialog = new askClassName($this->config,$this->dn,$this->ui,$types[$s_action]);
902 $this->dialog->parent = &$this;
903 }else{
904 msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), $types_i18n[$s_action]), ERROR_DIALOG);
905 }
906 }
908 /* New Profile */
909 if($s_action == "new_profile"){
910 $this->dn = "new" ;
912 $acl = $this->ui->get_permissions($this->fai_base,"fai/faiProfile");
913 if(preg_match("/c/",$acl)){
914 $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
915 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
916 $this->dialog->set_acl_base($this->base);
917 $this->dialog->parent = &$this;
919 $this->is_dialog = false;
920 }else{
921 msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), _("profile")), ERROR_DIALOG);
922 }
923 }
926 /****************
927 Get from ask class name dialog
928 ****************/
930 if($s_action == "select_class_name_finished"){
931 $this->dialog->save_object();
932 if(count($this->dialog->check())!=0){
933 foreach($this->dialog->check() as $msg){
934 msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
935 }
936 }elseif(isset($this->dialog->objectClass)){
937 $this->dn = "new" ;
938 $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass)));
939 $name = $this->dialog->save();
941 if(class_exists($a_setup[0])){
942 $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
943 $this->dialog->set_acl_base($this->base);
944 $this->dialog->by_object[$a_setup[1]]->cn = $name;
945 $this->dialog->parent = &$this;
946 $this->is_dialog = true;
947 }
948 }
949 }
952 /****************
953 Cancel dialogs
954 ****************/
956 if(isset($_POST['edit_cancel'])){
957 $this->dialog=FALSE;
958 $this->is_dialog = false;
959 session::un_set('objectinfo');
960 $this->remove_lock();
961 }
964 /****************
965 Save sub dialogs
966 ****************/
968 /* This check if the given tab could be saved
969 * If it was possible to save it, remove dialog object.
970 * If it wasn't possible, show errors and keep dialog.
971 */
972 if((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->dialog->config))){
973 $this->dialog->save_object();
974 $msgs= $this->dialog->check();
975 if(count($msgs)!=0){
976 foreach($msgs as $msg){
977 msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
978 }
979 }else{
980 $this->dialog->save();
981 FAI::save_release_changes_now();
982 if (!isset($_POST['edit_apply'])){
983 $this->remove_lock();
984 $this->dialog=FALSE;
985 $this->is_dialog=false;
986 session::un_set('objectinfo');
987 }else{
989 /* Reinitialize tab */
990 if($this->dialog instanceof tabs){
991 $this->dialog->re_init();
992 }
993 }
994 }
995 }
998 /****************
999 Display currently open dialog
1000 ****************/
1002 /* If dialog is set, but $this->is_dialog==false, then
1003 * only the "abort" button is shown, this are dialogs that must not be saved.
1004 * If is_dialog == true, we are currently editing tab objects.
1005 * Here we need both, save and cancel
1006 */
1008 if(is_object($this->dialog)){
1009 $display .= $this->dialog->execute();
1010 /* Don't show buttons if tab dialog requests this */
1012 if(isset($this->dialog->current)){
1014 $obj = $this->dialog->by_object[$this->dialog->current];
1016 if((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("faipartitionou","faiscriptou","faitemplateou","faihookou","faiprofileou","faivariableou","faipackageou");
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->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('faipartitionou') , "CHKBOX"=>"ShowPartitions" ,"ACL" => "faiPartitionTable"),
1137 "FAIpackageList" => array("OU"=> get_ou('faipackageou') , "CHKBOX"=>"ShowPackages" ,"ACL" => "faiPackage"),
1138 "FAIscript" => array("OU"=> get_ou('faiscriptou') , "CHKBOX"=>"ShowScripts" ,"ACL" => "faiScript"),
1139 "FAIvariable" => array("OU"=> get_ou('faivariableou') , "CHKBOX"=>"ShowVariables" ,"ACL" => "faiVariable"),
1140 "FAIhook" => array("OU"=> get_ou('faihookou') , "CHKBOX"=>"ShowHooks" ,"ACL" => "faiHook"),
1141 "FAIprofile" => array("OU"=> get_ou('faiprofileou') , "CHKBOX"=>"ShowProfiles" ,"ACL" => "faiProfile"),
1142 "FAItemplate" => array("OU"=> get_ou('faitemplateou') , "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[strtolower($obj['cn']).$obj['cn'].$type] = $obj;
1189 $this->objects[strtolower($obj['cn']).$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()){
1198 $err = FALSE;
1199 if(!$err && $this->DivListFai->ShowOpsiNetboot){
1200 $n_pro = $this->opsi->get_netboot_products();
1201 $err |= $this->opsi->is_error();
1202 foreach($n_pro as $name => $data){
1203 $entry = array("cn" => $name,
1204 "description" => $data['DESC'],
1205 "type" => "opsi_netboot");
1206 $this->objects[$name."_opsi_netboot"] = $entry;
1207 }
1208 }
1209 if(!$err && $this->DivListFai->ShowOpsiLocal){
1210 $l_pro = $this->opsi->get_local_products();
1211 $err |= $this->opsi->is_error();
1212 foreach($l_pro as $name => $data){
1213 $entry = array("cn" => $name,
1214 "description" => $data['DESC'],
1215 "type" => "opsi_local");
1216 $this->objects[$name."_opsi_local"] = $entry;
1217 }
1218 }
1219 if($err){
1220 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
1221 }
1222 }
1224 ksort($this->objects);
1225 reset ($this->objects);
1227 /* use numeric index, thats a bit more secure */
1228 $tmp0 = array();
1229 foreach($this->objects as $obj){
1230 $tmp0[]= $obj;
1231 }
1232 $this->objects = array();
1233 $this->objects = $tmp0;
1234 }
1236 function remove_lock()
1237 {
1238 if (isset($this->dn)){
1239 del_lock ($this->dn);
1240 }
1241 if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
1242 del_lock ($this->dns);
1243 }
1244 }
1246 function get_type($array){
1247 if(in_array("FAIpartitionTable",$array['objectClass'])){
1248 return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS"));
1249 }
1250 if(in_array("FAIscript",$array['objectClass'])){
1251 return(array("tabsScript","faiScript","FAISCRIPTTABS"));
1252 }
1253 if(in_array("FAItemplate",$array['objectClass'])){
1254 return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS"));
1255 }
1256 if(in_array("FAIhook",$array['objectClass'])){
1257 return(array("tabsHook","faiHook","FAIHOOKTABS"));
1258 }
1259 if(in_array("FAIvariable",$array['objectClass'])){
1260 return(array("tabsVariable","faiVariable","FAIVARIABLETABS"));
1261 }
1262 if(in_array("FAIprofile",$array['objectClass'])){
1263 return(array("tabsProfile","faiProfile","FAIPROFILETABS"));
1264 }
1266 if(in_array("FAIpackageList",$array['objectClass'])){
1267 return(array("tabsPackage","faiPackage","FAIPACKAGETABS"));
1268 }
1269 }
1271 function CheckNewBranchName($name,$base)
1272 {
1273 $f = $this->fai_release;
1274 if($name == ""){
1275 return(false);
1276 }elseif(in_array($name,$this->getBranches($f))) {
1277 return(false);
1278 }elseif(tests::is_department_name_reserved($name,$base)){
1279 return(false);
1280 }
1281 return(true);
1282 }
1284 function save_object()
1285 {
1286 $this->DivListFai->save_object();
1288 /* Get posted release */
1289 $r_releases = array_flip($this->getBranches());
1290 if(isset($_POST['fai_release']) && isset($r_releases[get_post('fai_release')])){
1292 /* Ensure that we have a valid release selected */
1293 if(!isset($r_releases[get_post('fai_release')])){
1294 msg_dialog::display(_("Warning"),_("The selected release is not available anymore. All triggered actions are skipped."));
1295 $_POST = array();
1296 $plug =$_GET['plug'];
1297 $_GET = array("plug" => $plug);
1298 $this->fai_release = $this->fai_base;
1299 }else{
1300 $this->fai_release = $r_releases[get_post('fai_release')];
1301 }
1303 $fai_filter = session::get("fai_filter");
1304 $fai_filter['fai_release'] = $this->fai_release;
1305 session::set("fai_filter",$fai_filter);
1306 }
1308 if(is_object($this->CopyPasteHandler)){
1309 $this->CopyPasteHandler->save_object();
1310 }
1311 }
1314 function copyPasteHandling_from_queue($s_action,$s_entry)
1315 {
1316 /* Check if Copy & Paste is disabled */
1317 if(!is_object($this->CopyPasteHandler)){
1318 return("");
1319 }
1321 $ui = get_userinfo();
1323 /* Add a single entry to queue */
1324 if($s_action == "copy"){
1326 /* Cleanup object queue */
1327 $this->CopyPasteHandler->cleanup_queue();
1328 $entry = $this->objects[$s_entry];
1329 $a_setup = $this->get_type($entry);
1330 $dn = $entry['dn'];
1332 if($ui->is_copyable($dn,"fai",$a_setup[1])){
1333 $this->CopyPasteHandler->add_to_queue($dn,$s_action,$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1334 }
1335 }
1337 /* Add entries to queue */
1338 if($s_action == "copy_multiple"){
1340 /* Cleanup object queue */
1341 $this->CopyPasteHandler->cleanup_queue();
1343 /* Add new entries to CP queue */
1344 foreach($this->list_get_selected_items() as $id){
1346 /* Cleanup object queue */
1347 $entry = $this->objects[$id];
1348 $a_setup = $this->get_type($entry);
1349 $dn = $entry['dn'];
1351 if($s_action == "copy_multiple" && $ui->is_copyable($dn,"fai",$a_setup[1])){
1352 $this->CopyPasteHandler->add_to_queue($dn,"copy",$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1353 }
1354 }
1355 }
1357 /* Start pasting entries */
1358 if($s_action == "editPaste" && !($this->lock_type == "freeze" && !$this->allow_freeze_object_attach)){
1359 $this->start_pasting_copied_objects = TRUE;
1360 }
1362 /* Return C&P dialog */
1363 if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
1365 /* Get dialog */
1366 $this->CopyPasteHandler->SetVar("parent",$this);
1367 $data = $this->CopyPasteHandler->execute();
1369 FAI::save_release_changes_now();
1371 /* Return dialog data */
1372 if(!empty($data)){
1373 return($data);
1374 }
1375 }
1377 /* Automatically disable status for pasting */
1378 if(!$this->CopyPasteHandler->entries_queued()){
1379 $this->start_pasting_copied_objects = FALSE;
1380 }
1381 return("");
1382 }
1385 /* Check if the given FAI class is used in this release
1386 */
1387 static function check_class_name($oc,$name,$dn)
1388 {
1389 $base = FAI::get_release_dn($dn);
1390 $res = FAI::get_all_objects_for_given_base($base,"(objectClass=".$oc.")",TRUE);
1391 $delete = array();
1392 $used = array();
1393 foreach($res as $object){
1394 $used[$object['cn'][0]]= $object['cn'][0];
1395 }
1396 return($used);
1397 }
1400 /* Return plugin informations for acl handling */
1401 static function plInfo()
1402 {
1403 return (array(
1404 "plShortName" => _("FAI releases"),
1405 "plDescription" => _("FAI release management"),
1406 "plSelfModify" => FALSE,
1407 "plDepends" => array(),
1408 "plPriority" => 0,
1409 "plSection" => array("administration"),
1410 "plCategory" => array("fai"=> array("description" => _("FAI"),
1411 "objectClass" => "FAIclass")),
1412 "plProvidedAcls"=> array()));
1413 }
1414 }
1415 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1416 ?>