Marius Cramer
2015-08-06 37b29231e47a0c4458dc1c15d98588f16f07e1e2
commit | author | age
b74ef5 1 <?php
T 2
3 /*
4     Form Definition
5
6     Tabledefinition
7
8     Datatypes:
9     - INTEGER (Forces the input to Int)
10     - DOUBLE
11     - CURRENCY (Formats the values to currency notation)
12     - VARCHAR (no format check, maxlength: 255)
13     - TEXT (no format check)
14     - DATE (Dateformat, automatic conversion to timestamps)
15
16     Formtype:
17     - TEXT (Textfield)
18     - TEXTAREA (Textarea)
19     - PASSWORD (Password textfield, input is not shown when edited)
20     - SELECT (Select option field)
21     - RADIO
22     - CHECKBOX
23     - CHECKBOXARRAY
24     - FILE
25
26     VALUE:
27     - Wert oder Array
28
29     Hint:
30     The ID field of the database table is not part of the datafield definition.
31     The ID field must be always auto incement (int or bigint).
b1a6a5 32
4c28d9 33     Search:
F 34     - searchable = 1 or searchable = 2 include the field in the search
35     - searchable = 1: this field will be the title of the search result
36     - searchable = 2: this field will be included in the description of the search result
b74ef5 37
T 38
39 */
40
b1a6a5 41 $form["title"]    = "Openvz virtual server";
MC 42 $form["description"]  = "";
43 $form["name"]    = "openvz_vm";
44 $form["action"]   = "openvz_vm_edit.php";
45 $form["db_table"]  = "openvz_vm";
46 $form["db_table_idx"] = "vm_id";
47 $form["db_history"]  = "yes";
48 $form["tab_default"] = "main";
49 $form["list_default"] = "openvz_vm_list.php";
50 $form["auth"]   = 'yes'; // yes / no
b74ef5 51
T 52 $form["auth_preset"]["userid"]  = 0; // 0 = id of the user, > 0 id must match with id of current user
53 $form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
54 $form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
55 $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
56 $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
57
58 $form["tabs"]['main'] = array (
b1a6a5 59     'title'  => "Virtual server",
MC 60     'width'  => 100,
61     'template'  => "templates/openvz_vm_edit.htm",
62     'fields'  => array (
63         //#################################
64         // Begin Datatable fields
65         //#################################
b74ef5 66         'server_id' => array (
b1a6a5 67             'datatype' => 'INTEGER',
MC 68             'formtype' => 'SELECT',
69             'default' => '',
70             'datasource' => array (  'type' => 'SQL',
71                 'querystring' => 'SELECT server_id,server_name FROM server WHERE vserver_server = 1 AND mirror_server_id = 0 ORDER BY server_name',
72                 'keyfield'=> 'server_id',
73                 'valuefield'=> 'server_name'
74             ),
75             'value'  => ''
b74ef5 76         ),
T 77         'ostemplate_id' => array (
b1a6a5 78             'datatype' => 'INTEGER',
MC 79             'formtype' => 'SELECT',
80             'default' => '',
81             'datasource' => array (  'type' => 'SQL',
82                 'querystring' => 'SELECT ostemplate_id,template_name FROM openvz_ostemplate WHERE 1 ORDER BY template_name',
83                 'keyfield'=> 'ostemplate_id',
84                 'valuefield'=> 'template_name'
85             ),
86             'value'  => ''
b74ef5 87         ),
T 88         'template_id' => array (
b1a6a5 89             'datatype' => 'INTEGER',
MC 90             'formtype' => 'SELECT',
91             'default' => '',
f414ab 92             /*
b74ef5 93             'datasource'    => array (     'type'    => 'SQL',
f414ab 94                                         'querystring' => 'SELECT template_id,template_name FROM openvz_template WHERE 1 ORDER BY template_name',
b74ef5 95                                         'keyfield'=> 'template_id',
T 96                                         'valuefield'=> 'template_name'
97                                      ),
f414ab 98             */
b1a6a5 99             'value'  => ''
b74ef5 100         ),
T 101         'ip_address' => array (
b1a6a5 102             'datatype' => 'VARCHAR',
MC 103             'formtype' => 'SELECT',
104             'validators' => array (  0 => array ( 'type' => 'NOTEMPTY',
105                     'errmsg'=> 'ip_address_error_empty'),
106             ),
107             'default' => '',
26c0fc 108             /*
b74ef5 109             'datasource'    => array (     'type'    => 'SQL',
f414ab 110                                         'querystring' => "SELECT ip_address FROM openvz_ip WHERE reserved = 'n' AND (vm_id = 0 or vm_id = '{RECORDID}') ORDER BY ip_address",
b74ef5 111                                         'keyfield'=> 'ip_address',
T 112                                         'valuefield'=> 'ip_address'
113                                      ),
26c0fc 114             */
b1a6a5 115             'value'  => ''
b74ef5 116         ),
T 117         'hostname' => array (
b1a6a5 118             'datatype' => 'VARCHAR',
MC 119             'formtype' => 'TEXT',
120             'filters'   => array( 0 => array( 'event' => 'SAVE',
121                     'type' => 'IDNTOASCII'),
122                 1 => array( 'event' => 'SHOW',
123                     'type' => 'IDNTOUTF8'),
124                 2 => array( 'event' => 'SAVE',
125                     'type' => 'TOLOWER')
126             ),
127             'validators' => array (  0 => array ( 'type' => 'NOTEMPTY',
128                     'errmsg'=> 'hostname_error_empty'),
129             ),
130             'default' => '',
131             'value'  => '',
132             'width'  => '30',
133             'maxlength' => '255',
4c28d9 134             'searchable' => 1
b74ef5 135         ),
T 136         'vm_password' => array (
b1a6a5 137             'datatype' => 'VARCHAR',
MC 138             'formtype' => 'TEXT',
139             'validators' => array (  0 => array ( 'type' => 'NOTEMPTY',
140                     'errmsg'=> 'vm_password_error_empty'),
141             ),
142             'default' => $app->auth->get_random_password(10),
143             'value'  => '',
144             'width'  => '30',
145             'maxlength' => '255'
b74ef5 146         ),
T 147         'start_boot' => array (
b1a6a5 148             'datatype' => 'VARCHAR',
MC 149             'formtype' => 'CHECKBOX',
150             'default' => 'y',
151             'value'  => array(0 => 'n', 1 => 'y')
b74ef5 152         ),
T 153         'active' => array (
b1a6a5 154             'datatype' => 'VARCHAR',
MC 155             'formtype' => 'CHECKBOX',
156             'default' => 'y',
157             'value'  => array(0 => 'n', 1 => 'y')
b74ef5 158         ),
T 159         'active_until_date' => array (
b1a6a5 160             'datatype' => 'DATE',
MC 161             'formtype' => 'TEXT',
162             'default' => '',
163             'value'  => '',
164             'width'  => '30',
165             'maxlength' => '255'
b74ef5 166         ),
T 167         'description' => array (
b1a6a5 168             'datatype' => 'TEXT',
MC 169             'formtype' => 'TEXTAREA',
170             'default' => '',
171             'value'  => '',
172             'separator' => '',
173             'width'  => '',
174             'maxlength' => '',
175             'rows'  => '10',
176             'cols'  => '30',
4c28d9 177             'searchable' => 2
b74ef5 178         ),
b1a6a5 179         //#################################
MC 180         // ENDE Datatable fields
181         //#################################
b74ef5 182     )
T 183 );
184
f5ea1b 185 if($_SESSION["s"]["user"]["typ"] == 'admin') {
b1a6a5 186     $form["tabs"]['advanced'] = array (
MC 187         'title'  => "Advanced",
188         'width'  => 100,
189         'template'  => "templates/openvz_vm_advanced_edit.htm",
190         'fields'  => array (
191             //#################################
192             // Begin Datatable fields
193             //#################################
194             'veid' => array (
195                 'datatype' => 'INTEGER',
196                 'formtype' => 'TEXT',
197                 'validators' => array (  0 => array ( 'type' => 'NOTEMPTY',
198                         'errmsg'=> 'veid_error_empty'),
199                     1 => array ( 'type' => 'UNIQUE',
200                         'errmsg'=> 'veid_error_unique'),
201                 ),
202                 'default' => '',
203                 'value'  => '',
204                 'width'  => '30',
205                 'maxlength' => '255'
206             ),
207             'create_dns' => array (
208                 'datatype' => 'VARCHAR',
209                 'formtype' => 'CHECKBOX',
210                 'default' => 'y',
211                 'value'  => array(0 => 'n', 1 => 'y')
212             ),
213             'diskspace' => array (
214                 'datatype' => 'INTEGER',
215                 'formtype' => 'TEXT',
216                 'validators' => array (  0 => array ( 'type' => 'NOTEMPTY',
217                         'errmsg'=> 'diskspace_error_empty'),
218                 ),
219                 'default' => '',
220                 'value'  => '',
221                 'width'  => '30',
222                 'maxlength' => '255'
223             ),
224             'ram' => array (
225                 'datatype' => 'INTEGER',
226                 'formtype' => 'TEXT',
227                 'validators' => array (  0 => array ( 'type' => 'NOTEMPTY',
228                         'errmsg'=> 'ram_error_empty'),
229                 ),
230                 'default' => '',
231                 'value'  => '',
232                 'width'  => '30',
233                 'maxlength' => '255'
234             ),
235             'ram_burst' => array (
236                 'datatype' => 'INTEGER',
237                 'formtype' => 'TEXT',
238                 'validators' => array (  0 => array ( 'type' => 'NOTEMPTY',
239                         'errmsg'=> 'ram_burst_error_empty'),
240                 ),
241                 'default' => '',
242                 'value'  => '',
243                 'width'  => '30',
244                 'maxlength' => '255'
245             ),
246             'cpu_units' => array (
247                 'datatype' => 'INTEGER',
248                 'formtype' => 'TEXT',
249                 'validators' => array (  0 => array ( 'type' => 'NOTEMPTY',
250                         'errmsg'=> 'cpu_units_error_empty'),
251                 ),
252                 'default' => '1000',
253                 'value'  => '',
254                 'width'  => '30',
255                 'maxlength' => '255'
256             ),
257             'cpu_num' => array (
258                 'datatype' => 'INTEGER',
259                 'formtype' => 'TEXT',
260                 'validators' => array (  0 => array ( 'type' => 'NOTEMPTY',
261                         'errmsg'=> 'cpu_num_error_empty'),
262                 ),
263                 'default' => '4',
264                 'value'  => '',
265                 'width'  => '30',
266                 'maxlength' => '255'
267             ),
268             'cpu_limit' => array (
269                 'datatype' => 'INTEGER',
270                 'formtype' => 'TEXT',
271                 'validators' => array (  0 => array ( 'type' => 'NOTEMPTY',
272                         'errmsg'=> 'cpu_limit_error_empty'),
273                 ),
274                 'default' => '400',
275                 'value'  => '',
276                 'width'  => '30',
277                 'maxlength' => '255'
278             ),
279             'io_priority' => array (
280                 'datatype' => 'INTEGER',
281                 'formtype' => 'TEXT',
282                 'validators' => array (  0 => array ( 'type' => 'NOTEMPTY',
283                         'errmsg'=> 'io_priority_error_empty'),
284                 ),
285                 'default' => '4',
286                 'value'  => '',
287                 'width'  => '30',
288                 'maxlength' => '255'
289             ),
290             'nameserver' => array (
291                 'datatype' => 'VARCHAR',
292                 'formtype' => 'TEXT',
293                 'validators' => array (  0 => array ( 'type' => 'NOTEMPTY',
294                         'errmsg'=> 'template_nameserver_error_empty'),
295                 ),
296                 'default' => '8.8.8.8 8.8.4.4',
297                 'value'  => '',
298                 'width'  => '30',
299                 'maxlength' => '255'
300             ),
301             'capability' => array (
302                 'datatype' => 'VARCHAR',
303                 'formtype' => 'TEXT',
304                 'default' => '',
305                 'value'  => '',
306                 'width'  => '30',
307                 'maxlength' => '255'
308             ),
503bbb 309             'features' => array (
FS 310                 'datatype' => 'VARCHAR',
311                 'formtype' => 'TEXT',
312                 'default' => '',
313                 'value'  => '',
314                 'width'  => '30',
315                 'maxlength' => '255'
316             ),
a3609a 317             'iptables' => array (
FS 318                 'datatype' => 'VARCHAR',
319                 'formtype' => 'TEXT',
320                 'default' => '',
321                 'value'  => '',
322                 'width'  => '30',
323                 'maxlength' => '255'
324             ),
b1a6a5 325             //#################################
MC 326             // ENDE Datatable fields
327             //#################################
328         )
329     );
f5ea1b 330 }
b74ef5 331
T 332
b1a6a5 333 ?>