Code

Added empty lines
[gosa.git] / plugins / admin / fai / class_faiPackageNew.inc
1 <?php
3 class faiPackageNew extends plugin
4 {
5   /* CLI vars */
6   var $cli_summary        = "Manage server basic objects";
7   var $cli_description    = "Some longer text\nfor help";
8   var $cli_parameters     = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
10   /* attribute list for save action */
11   var $ignore_account     = TRUE;
12   var $attributes         = array();
13   var $objectclasses      = array();
14  
15   var $mirrors            = array(); // The possible mirror,release and section combinations
16   var $servers            = array(); // All available server
17   var $sections           = array(); // All sections
18   var $releases           = array(); // Releases 
20   var $FAIdebianRelease   = "";     // The selected release
21   var $FAIdebianSection   = array();     // selected section
22   var $FAIdebianMirror    = "";     // selected mirror
25   var $obj;
27   function faiPackageNew ($config, $dn= NULL,$mirrors,$servers,$sections,$releases)
28   {
29     plugin::plugin ($config, $dn);
30     $this->mirrors  = $mirrors;
31     $this->servers  = $servers;
32     $this->sections = $sections;
33     $this->releases = $releases;
35     foreach($this->sections as $sec){
36       $this->sections[$sec]  =false;
37     }
38   }
40   function execute()
41   {
42         /* Call parent execute */
43         plugin::execute();
45     /* Fill templating stuff */
46     $smarty     = get_smarty();
47     $display = "";
49     // reset grayout options 
50     $disableRelease   = false;
51     $disableMirror    = false;
52     $disableContinue  = false;
53     $disableSection   = false;
55     /* Post handling for Section, Release and Mirror Setup */
56     if(isset($_POST['SetRepository'])){
57       foreach($this->sections as $sec => $val){
58         if(isset($_POST[$sec])){
59           $this->sections[$sec]=true;
60           $this->FAIdebianSection[$sec]=$sec;
61         }else{
62           $this->sections[$sec]=false;
63         }
64       }
65     
66     }
68     /* Grayout settings */    
69     if(empty($this->FAIdebianRelease)){
70       $disableSection = $disableMirror  = $disableContinue = true;
71     }elseif(empty($this->FAIdebianSection)){
72       $disableRelease = $disableMirror  = $disableContinue = true;
73     }elseif(empty($this->FAIdebianMirror)){
74       $disableRelease = $disableSection =  true;
75     }else{
76       $disableRelease = $disableSection =  true;
77     }
79     /* check servers matching release and section settings */
80     $availableServer = array();
81     foreach($this->mirrors as $mir){
82     
83       /* Check if release and section match */
84       if($mir['release'] == $this->FAIdebianRelease){
85         $pass = true;
86     
87         foreach($this->FAIdebianSection as $sec){
89         /* If a mirror match, attach */
90           if($sec != $mir['section']){
91             $pass = false;
92           }
94         /* Save all matching */ 
95         if($pass){
96             $availableServer[$mir['mirror']]=$mir['mirror'];
97           }
98         }
99       }
100     }
102     /* If no servers matching the settings, allow setting release and section again */
103     if(($disableMirror==false)&&(count($availableServer)==0)){
104       $this->FAIdebianRelease = $this->FAIdebianMirror = "";
105       $this->FAIdebianSection = array();
106       $disableSection = $disableMirror  = $disableContinue = true;
107       $disableRelease = false;
108     }
110     /* Create checkboxes for the avaliable sections */
111     $strsec = "<table><tr>";
112     foreach($this->sections as $sec => $val){
114       /* Only add this section if it is supported by the selected release */
115       $goon = false;
116       foreach($this->mirrors as $mir){
118         /* Is there a release with this section ? */
119         if((($mir['release'] == $this->FAIdebianRelease )&&($mir['section'] == $sec))){
120           $goon = true; 
121         }
122       }
124       if($goon){
125         if($this->sections[$sec] == true ){
126           $chk = " checked ";
127         }else{
128           $chk = "";
129         }
131         /* Add disabled if needed */
132         if($disableSection){
133           $strsec .= "<td><input type='checkbox' name='".$sec."' disabled ".$chk.">".$sec."</td>";
134         }else{
135           $strsec .= "<td><input type='checkbox' name='".$sec."' ".$chk.">".$sec."</td>";
136         }
137       }
138     }
139     $strsec .= "</table>";
140     
141     /* Add --- to mirror selectbox if it is empty */
142     if(count($availableServer)==0){
143       $availableServer=array("---");
144     }
146     /* Tell smarty the grayout settigs */
147     $smarty->assign("ReleaseACL"  , "");
148     $smarty->assign("MirrorACL"   , "");
149     $smarty->assign("ContinueACL" , "");
150     $smarty->assign("SectionACL"  , "");
152     if($disableContinue){
153       $smarty->assign("ContinueACL"," disabled ");
154     }
155     if($disableRelease){
156       $smarty->assign("ReleaseACL"," disabled ");
157     }
158     if($disableMirror){
159       $smarty->assign("MirrorACL"," disabled ");
160     }
161     if($disableSection){
162       $smarty->assign("SectionACL"," disabled ");
163     }
166     $smarty->assign("DisSection",!empty($this->FAIdebianSection));
167     $smarty->assign("DisRelease",!empty($this->FAIdebianRelease));
169     $smarty->assign("mirrors" ,$availableServer);
170     $smarty->assign("mirror"  ,$this->FAIdebianMirror);
171     $smarty->assign("releases",$this->releases);
172     $smarty->assign("release" ,$this->FAIdebianRelease);
173     $smarty->assign("sections",$strsec);
174     $smarty->assign("section" ,$this->FAIdebianSection);
176     $display.= $smarty->fetch(get_template_path('faiPackageNew.tpl', TRUE));
177     return($display);
178   }
180   /* Save data to object */
181   function save_object()
182   {
183     if(isset($_POST['SetRepository'])){
184       /* Post handling for Section, Release and Mirror Setup */
185       if((isset($_POST['FAIdebianReleaseS']))&&(!empty($_POST['FAIdebianReleaseS']))){
186         $this->FAIdebianRelease = $_POST['FAIdebianReleaseS'];
187       }
188       if((isset($_POST['FAIdebianMirrorS']))&&(!empty($_POST['FAIdebianMirrorS']))){
189         $this->FAIdebianMirror = $_POST['FAIdebianMirrorS'];
190       }
191     }
192   }
194   /* Check supplied data */
195   function check()
196   {
197     $message= array();
198     return ($message);
199   }
201   function save()
202   {
203   }
205 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
206 ?>