Code

Updated strings in dhcp error msgs
[gosa.git] / plugins / admin / systems / class_dhcpGroup.inc
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 dhcpGroup extends dhcpPlugin
22 {
23   /* attribute list for save action */
24   var $objectclasses= array('top', 'dhcpGroup', 'dhcpOptions');
26   function dhcpGroup($attrs)
27   {
28     /* Load statements / options */
29     dhcpPlugin::dhcpPlugin($attrs);
30   }
32   function execute()
33   {
34     $smarty= get_smarty();
35     $smarty->assign("cn", $this->cn);
37     /* Show main page */
38     $display= $smarty->fetch (get_template_path('dhcp_group.tpl', TRUE)).$this->network->execute();
40     /* Merge arrays for advanced view */
41     $this->fix_options();
42     foreach (array("options", "statements") as $type){
43       $this->advanced->$type= $this->$type + $this->network->$type;
44     }
46     $display.= $this->advanced->execute();
48     /* Merge back for removals */
49     foreach (array("options", "statements") as $type){
50       $this->$type= $this->advanced->$type;
51       $this->network->$type= $this->advanced->$type;
52     }
54     /* Add footer */
55     $display.= "<div style='width:100%;text-align:right;margin-top:5px;'><input type=submit name='save_dhcp' value='"._("Save")."'>".
56                "&nbsp;<input type=submit name='cancel_dhcp' value='"._("Cancel")."'></div>";
59     return ($display);
60   }
63   function remove_from_parent()
64   {
65   }
68   /* Save data to object */
69   function save_object()
70   {
71     /* Save cn */
72     if (isset($_POST['cn'])){
73       $this->cn= validate(get_post('cn'));
74     }
76     /* Handle global saving */
77     dhcpPlugin::save_object();
78   }
81   /* Check values */
82   function check($cache)
83   {
84     $message= array();
86     /* All required fields are set? */
87     if ($this->cn == ""){
88       $message[]= _("Required field 'Name' is not filled.");
89     }
90     if (!preg_match('/^[a-z0-9_-]*$/i', $this->cn)){
91       $message[]= _("Field 'Name' contains illegal characters.");
92     }
94     /* cn already used? */
95     if ($this->orig_cn != $this->cn || $this->new){
97       foreach($cache as $dn => $dummy){
98         if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){
99           $message[]= _("The name for this host section is already used!");
100           break;
101         }
102       }
103     }
105     /* Check external plugins */
106     $net= $this->network->check();
107     $adv= $this->advanced->check();
108     $message= array_merge($message, $net, $adv);
110     return $message;
111   }
114   /* Save to LDAP */
115   function save()
116   {
117     dhcpPlugin::save();
118     return ($this->attrs);
119   }
124 ?>