1 <?php
3 class faiGroupHandle{
6 private $FAI_group;
7 private $mode = "edit";
8 private $open = TRUE;
9 private $canceled = FALSE;
11 public function __construct($FAI_group, $Action)
12 {
13 if(in_array($Action,array("edit","remove","copy","cut"))){
14 $this->mode = $Action;
15 }else{
16 trigger_error("Wrong action type '".$Action."'.");
17 exit();
18 }
20 /* Preset required values */
21 $select_set = FALSE;
22 foreach($FAI_group as $type => $data){
23 $FAI_group[$type]['selected'] = FALSE;
24 $FAI_group[$type]['freezed'] = isset($data['FAIstate']) && preg_match("/freeze/",$data['FAIstate']);
25 if(!$select_set && ($this->mode == "cut" || $this->mode == "edit") && !$FAI_group[$type]['freezed']){
26 $FAI_group[$type]['selected'] = TRUE;
27 $select_set =TRUE;
28 }
29 }
30 $this->FAI_group = $FAI_group;
31 }
33 function execute()
34 {
35 $smarty = get_smarty();
36 $smarty->assign("FAI_group",$this->FAI_group);
37 $smarty->assign("types",$this->get_types());
38 $smarty->assign("mode",$this->mode);
39 return($smarty->fetch(get_template_path("faiGroupHandle.tpl",TRUE,dirname(__FILE__))));
40 }
42 function save_object()
43 {
44 if(isset($_POST['faiGroupHandle'])){
45 if(in_array($this->mode,array("copy","cut","remove"))){
46 foreach($this->FAI_group as $key => $group){
47 if(isset($_POST[$this->mode."_".$key])){
48 $this->FAI_group[$key]['selected'] = TRUE;
49 }else{
50 $this->FAI_group[$key]['selected'] = FALSE;
51 }
52 }
53 }else{
54 if(isset($_POST['edit_selected']) && isset($this->FAI_group[get_post('edit_selected')])){
55 foreach($this->FAI_group as $key => $obj){
56 $this->FAI_group[$key]['selected'] = FALSE;
57 }
58 $this->FAI_group[get_post('edit_selected')]['selected'] = TRUE;
59 }
60 }
61 if(isset($_POST['faiGroupHandle_apply']) || isset($_POST['faiGroupHandle_cancel'])){
62 $this->open = FALSE;
63 }
64 if(isset($_POST['faiGroupHandle_cancel'])){
65 $this->canceled = TRUE;
66 }
67 }
68 }
70 function is_open()
71 {
72 return($this->open);
73 }
75 function is_canceled()
76 {
77 return($this->canceled);
78 }
80 function get_mode()
81 {
82 return($this->mode);
83 }
85 function get_selected()
86 {
87 $ret= array();
88 foreach($this->FAI_group as $key => $obj){
89 if($obj['selected']){
90 $ret[$key] = $obj;
91 }
92 }
93 return($ret);
94 }
96 function get_types()
97 {
98 $objects = array(
99 "FAIpartitionTable" => array("IMG"=> "plugins/fai/images/fai_partitionTable.png",
100 "NAME"=>_("Partition table"),"KZL"=> "PT", "VAR"=>"ShowPartitions"),
101 "FAIpackageList" => array("IMG"=> "plugins/fai/images/fai_packages.png",
102 "NAME"=>_("Package list") , "KZL"=> "PL", "VAR"=>"ShowPackages"),
103 "FAIscript" => array("IMG"=> "plugins/fai/images/fai_script.png",
104 "NAME"=>_("Scripts") , "KZL"=> "S", "VAR"=>"ShowScripts"),
105 "FAIvariable" => array("IMG"=> "plugins/fai/images/fai_variable.png",
106 "NAME"=>_("Variables") , "KZL"=> "V", "VAR"=>"ShowVariables"),
107 "FAIhook" => array("IMG"=> "plugins/fai/images/fai_hook.png",
108 "NAME"=>_("Hooks"), "KZL"=> "H", "VAR"=>"ShowHooks"),
109 "FAIprofile" => array("IMG"=> "plugins/fai/images/fai_profile.png",
110 "NAME"=>_("Profile") , "KZL"=> "P", "VAR"=>"ShowProfiles"),
111 "FAItemplate" => array("IMG"=> "plugins/fai/images/fai_template.png",
112 "NAME"=>_("Templates") , "KZL"=> "T", "VAR"=>"ShowTemplates"),
113 "opsi_netboot" => array("IMG"=> "plugins/opsi/images/netboot_package.png",
114 "NAME"=>_("OPSI netboot product") , "KZL"=> "ON", "VAR"=>"ShowOpsiNetboot"),
115 "opsi_local" => array("IMG"=> "plugins/opsi/images/local_package.png",
116 "NAME"=>_("OPSI local product") , "KZL"=> "OL", "VAR"=>"ShowOpsiLocal"));
117 return($objects);
118 }
119 }
126 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
127 ?>