Marius Burkard
2016-04-20 4569cae57f127afd093794310ccd290d2d9fdf36
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         ),
33ad8f 153         'bootorder' => array (
FS 154             'datatype' => 'INTEGER',
155             'formtype' => 'TEXT',
156             'default' => '0',
157             'value'  => '',
158             'width'  => '3',
159             'maxlength' => '3',
160             'validators' => array (  0 => array ( 'type' => 'ISPOSITIVE',
04bc9d 161                 'errmsg'=> 'bootorder_error_notpositive'),
33ad8f 162             ),
FS 163         ),
b74ef5 164         'active' => array (
b1a6a5 165             'datatype' => 'VARCHAR',
MC 166             'formtype' => 'CHECKBOX',
167             'default' => 'y',
168             'value'  => array(0 => 'n', 1 => 'y')
b74ef5 169         ),
T 170         'active_until_date' => array (
b1a6a5 171             'datatype' => 'DATE',
MC 172             'formtype' => 'TEXT',
173             'default' => '',
174             'value'  => '',
175             'width'  => '30',
176             'maxlength' => '255'
b74ef5 177         ),
T 178         'description' => array (
b1a6a5 179             'datatype' => 'TEXT',
MC 180             'formtype' => 'TEXTAREA',
181             'default' => '',
182             'value'  => '',
183             'separator' => '',
184             'width'  => '',
185             'maxlength' => '',
186             'rows'  => '10',
187             'cols'  => '30',
4c28d9 188             'searchable' => 2
b74ef5 189         ),
b1a6a5 190         //#################################
MC 191         // ENDE Datatable fields
192         //#################################
b74ef5 193     )
T 194 );
195
f5ea1b 196 if($_SESSION["s"]["user"]["typ"] == 'admin') {
b1a6a5 197     $form["tabs"]['advanced'] = array (
MC 198         'title'  => "Advanced",
199         'width'  => 100,
200         'template'  => "templates/openvz_vm_advanced_edit.htm",
201         'fields'  => array (
202             //#################################
203             // Begin Datatable fields
204             //#################################
205             'veid' => array (
206                 'datatype' => 'INTEGER',
207                 'formtype' => 'TEXT',
208                 'validators' => array (  0 => array ( 'type' => 'NOTEMPTY',
209                         'errmsg'=> 'veid_error_empty'),
210                     1 => array ( 'type' => 'UNIQUE',
211                         'errmsg'=> 'veid_error_unique'),
212                 ),
213                 'default' => '',
214                 'value'  => '',
215                 'width'  => '30',
216                 'maxlength' => '255'
217             ),
218             'create_dns' => array (
219                 'datatype' => 'VARCHAR',
220                 'formtype' => 'CHECKBOX',
221                 'default' => 'y',
222                 'value'  => array(0 => 'n', 1 => 'y')
223             ),
224             'diskspace' => array (
225                 'datatype' => 'INTEGER',
226                 'formtype' => 'TEXT',
227                 'validators' => array (  0 => array ( 'type' => 'NOTEMPTY',
228                         'errmsg'=> 'diskspace_error_empty'),
229                 ),
230                 'default' => '',
231                 'value'  => '',
232                 'width'  => '30',
233                 'maxlength' => '255'
234             ),
235             'ram' => array (
236                 'datatype' => 'INTEGER',
237                 'formtype' => 'TEXT',
238                 'validators' => array (  0 => array ( 'type' => 'NOTEMPTY',
239                         'errmsg'=> 'ram_error_empty'),
240                 ),
241                 'default' => '',
242                 'value'  => '',
243                 'width'  => '30',
244                 'maxlength' => '255'
245             ),
246             'ram_burst' => array (
247                 'datatype' => 'INTEGER',
248                 'formtype' => 'TEXT',
249                 'validators' => array (  0 => array ( 'type' => 'NOTEMPTY',
250                         'errmsg'=> 'ram_burst_error_empty'),
251                 ),
252                 'default' => '',
253                 'value'  => '',
254                 'width'  => '30',
255                 'maxlength' => '255'
256             ),
257             'cpu_units' => array (
258                 'datatype' => 'INTEGER',
259                 'formtype' => 'TEXT',
260                 'validators' => array (  0 => array ( 'type' => 'NOTEMPTY',
261                         'errmsg'=> 'cpu_units_error_empty'),
262                 ),
263                 'default' => '1000',
264                 'value'  => '',
265                 'width'  => '30',
266                 'maxlength' => '255'
267             ),
268             'cpu_num' => array (
269                 'datatype' => 'INTEGER',
270                 'formtype' => 'TEXT',
271                 'validators' => array (  0 => array ( 'type' => 'NOTEMPTY',
272                         'errmsg'=> 'cpu_num_error_empty'),
273                 ),
274                 'default' => '4',
275                 'value'  => '',
276                 'width'  => '30',
277                 'maxlength' => '255'
278             ),
279             'cpu_limit' => array (
280                 'datatype' => 'INTEGER',
281                 'formtype' => 'TEXT',
282                 'validators' => array (  0 => array ( 'type' => 'NOTEMPTY',
283                         'errmsg'=> 'cpu_limit_error_empty'),
284                 ),
285                 'default' => '400',
286                 'value'  => '',
287                 'width'  => '30',
288                 'maxlength' => '255'
289             ),
290             'io_priority' => array (
291                 'datatype' => 'INTEGER',
292                 'formtype' => 'TEXT',
293                 'validators' => array (  0 => array ( 'type' => 'NOTEMPTY',
294                         'errmsg'=> 'io_priority_error_empty'),
295                 ),
296                 'default' => '4',
297                 'value'  => '',
298                 'width'  => '30',
299                 'maxlength' => '255'
300             ),
301             'nameserver' => array (
302                 'datatype' => 'VARCHAR',
303                 'formtype' => 'TEXT',
304                 'validators' => array (  0 => array ( 'type' => 'NOTEMPTY',
305                         'errmsg'=> 'template_nameserver_error_empty'),
306                 ),
307                 'default' => '8.8.8.8 8.8.4.4',
308                 'value'  => '',
309                 'width'  => '30',
310                 'maxlength' => '255'
311             ),
312             'capability' => array (
313                 'datatype' => 'VARCHAR',
314                 'formtype' => 'TEXT',
315                 'default' => '',
316                 'value'  => '',
317                 'width'  => '30',
318                 'maxlength' => '255'
319             ),
503bbb 320             'features' => array (
FS 321                 'datatype' => 'VARCHAR',
322                 'formtype' => 'TEXT',
323                 'default' => '',
324                 'value'  => '',
325                 'width'  => '30',
326                 'maxlength' => '255'
327             ),
a3609a 328             'iptables' => array (
FS 329                 'datatype' => 'VARCHAR',
330                 'formtype' => 'TEXT',
331                 'default' => '',
332                 'value'  => '',
333                 'width'  => '30',
334                 'maxlength' => '255'
335             ),
ca0698 336             'custom' => array (
FS 337                 'datatype' => 'TEXT',
338                 'formtype' => 'TEXTAREA',
339                 'default' => '',
340                 'value'  => '',
341                 'separator' => '',
342                 'width'  => '',
343                 'maxlength' => '',
344                 'rows'  => '10',
345                 'cols'  => '30',
346                 'searchable' => 2,
347                 'validators'    => array (  0 => array ('type'  => 'CUSTOM',
348                     'class' => 'validate_openvz',
349                     'function' => 'check_custom',
350                     'errmsg'=> 'custom_error'),
351                 ),
352             ),
b1a6a5 353             //#################################
MC 354             // ENDE Datatable fields
355             //#################################
356         )
357     );
a4657c 358
FS 359     $form["tabs"]['additional_ip'] = array (
360         'title'  => "Additional IP",
361         'width'  => 100,
362         'template'  => "templates/openvz_vm_additional_ip_edit.htm",
363     );
f5ea1b 364 }
b74ef5 365
T 366
b1a6a5 367 ?>