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 */
21 class dhcpAdvanced extends plugin
22 {
23 /* Used attributes */
24 var $options= array();
25 var $statements= array();
27 /* attribute list for save action */
28 var $attributes= array();
29 var $objectclasses= array();
31 function dhcpAdvanced()
32 {
33 /* This is always an account */
34 $this->is_account= TRUE;
35 }
37 function execute()
38 {
39 /* Check for interaction */
40 if (isset($_POST['add_statement']) && $_POST['addstatement'] != ""){
41 $key= preg_replace('/^([a-z0-9-]+)\s(.*)$/', '\\1', $_POST['addstatement']);
42 $val= preg_replace("/^$key\s*/", '', $_POST['addstatement']);
43 $this->statements[$key]= $val;
44 }
45 if (isset($_POST['delete_statement']) && isset($_POST['dhcpstatements'])){
46 $key= preg_replace('/([a-z0-9-]+)\s(.*)$/', '\\1', $_POST['dhcpstatements']);
47 unset($this->statements[$key]);
48 }
49 if (isset($_POST['add_option']) && $_POST['addoption'] != ""){
50 $key= preg_replace('/^([a-z0-9-]+)\s(.*)$/', '\\1', $_POST['addoption']);
51 $val= preg_replace("/^$key\s*/", '', $_POST['addoption']);
52 $this->options[$key]= $val;
53 }
54 if (isset($_POST['delete_option']) && isset($_POST['dhcpoptions'])){
55 $key= preg_replace('/([a-z0-9-]+)\s(.*)$/', '\\1', $_POST['dhcpoptions']);
56 unset($this->options[$key]);
57 }
59 $smarty= get_smarty();
61 /* Assign arrays */
62 $statements= array();
63 foreach ($this->statements as $key => $val){
64 $statements[$key]= "$key $val";
65 }
66 $smarty->assign("dhcpstatements", $statements);
67 $options= array();
68 foreach ($this->options as $key => $val){
69 $options[$key]= "$key $val";
70 }
71 $smarty->assign("dhcpoptions", $options);
73 /* Show main page */
74 return ($smarty->fetch (get_template_path('dhcp_advanced.tpl', TRUE)));
75 }
77 function remove_from_parent()
78 {
79 }
82 /* Save data to object */
83 function save_object()
84 {
85 }
88 /* Check values */
89 function check()
90 {
91 /* Nothing to check here */
92 $message= array();
93 return $message;
94 }
97 /* Save to LDAP */
98 function save()
99 {
100 }
102 }
104 ?>