From 82e64ef13b17bd35fc396345b3cb3b1ab66cc8d9 Mon Sep 17 00:00:00 2001 From: cajus Date: Mon, 7 Dec 2009 13:29:14 +0000 Subject: [PATCH] Added classes and subclasses. We need fine tuning later on if someone needs that - see #115. Closes #794 git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14875 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../systems/services/dhcp/class_dhcpClass.inc | 120 ++++++++++++++++++ .../dhcp/class_dhcpNewSectionDialog.inc | 8 +- .../services/dhcp/class_dhcpSubClass.inc | 120 ++++++++++++++++++ .../systems/services/dhcp/class_servDHCP.inc | 4 +- 4 files changed, 246 insertions(+), 6 deletions(-) create mode 100644 gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpClass.inc create mode 100644 gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpSubClass.inc diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpClass.inc b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpClass.inc new file mode 100644 index 000000000..f3671b165 --- /dev/null +++ b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpClass.inc @@ -0,0 +1,120 @@ +assign("cn", $this->cn); + + /* Assign ACLs */ + $smarty->assign("acl",$this->parent->getacl("")); + + /* Show main page */ + $display= $smarty->fetch (get_template_path('dhcp_group.tpl', TRUE, + dirname(__FILE__))).$this->network->execute(); + $display.= $this->advanced->execute(); + + /* Add footer */ + $display.= "
"; + if(preg_match("/w/",$this->parent->getacl(""))){ + $display.= " "; + } + $display.= ""; + $display.= "
"; + + return ($display); + } + + + function remove_from_parent() + { + } + + + /* Save data to object */ + function save_object() + { + /* Save cn */ + if (preg_match("/w/",$this->parent->getacl("")) && isset($_POST['cn'])){ + $this->cn= validate(get_post('cn')); + } + + /* Handle global saving */ + dhcpPlugin::save_object(); + } + + + /* Check values */ + function check() + { + $message= array(); + + $cache = $this->parent->dhcpObjectCache; + + /* All required fields are set? */ + if ($this->cn == ""){ + $message[]= msgPool::required(_("Name")); + } + if (!preg_match('/^[a-z0-9_-]*$/i', $this->cn)){ + $message[]= msgPool::invalid(_("Name"),$this->cn,"/[a-z0-9_-]/i"); + } + + /* cn already used? */ + if ($this->orig_cn != $this->cn || $this->new){ + + foreach($cache as $dn => $dummy){ + if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){ + $message[]= msgPool::duplicated(_("Name")); + break; + } + } + } + + /* Check external plugins */ + $net= $this->network->check(); + $adv= $this->advanced->check(); + $message= array_merge($message, $net, $adv); + + return $message; + } + + + /* Save to LDAP */ + function save() + { + dhcpPlugin::save(); + return ($this->attrs); + } + + +} + +?> diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpNewSectionDialog.inc b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpNewSectionDialog.inc index 893761340..9204e2aa0 100644 --- a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpNewSectionDialog.inc +++ b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpNewSectionDialog.inc @@ -10,13 +10,13 @@ class dhcpNewSectionDialog extends plugin /* Mapping array */ var $types= array(); var $classtype= ""; - var $sectionMap= array( "dhcpService" => array("dhcpSharedNetwork", "dhcpSubnet", "dhcpGroup", "dhcpHost" /*, "dhcpClass"*/), - #"dhcpClass" => array("dhcpSubClass"), + var $sectionMap= array( "dhcpService" => array("dhcpSharedNetwork", "dhcpSubnet", "dhcpGroup", "dhcpHost", "dhcpClass"), + "dhcpClass" => array("dhcpSubClass"), "dhcpSubClass" => array(), "dhcpHost" => array(), "dhcpGroup" => array("dhcpHost"), "dhcpPool" => array(), - "dhcpSubnet" => array("dhcpPool", "dhcpGroup", "dhcpHost" /*, "dhcpClass"*/), + "dhcpSubnet" => array("dhcpPool", "dhcpGroup", "dhcpHost", "dhcpClass"), "dhcpSharedNetwork" => array("dhcpSubnet", "dhcpPool")); @@ -24,7 +24,7 @@ class dhcpNewSectionDialog extends plugin function dhcpNewSectionDialog($type) { $this->types= array( "dhcpService" => _("Global options"), - /*"dhcpClass" => _("Class"),*/ + "dhcpClass" => _("Class"), "dhcpSubClass" => _("Subclass"), "dhcpHost" => _("Host"), "dhcpGroup" => _("Group"), diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpSubClass.inc b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpSubClass.inc new file mode 100644 index 000000000..a18213177 --- /dev/null +++ b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_dhcpSubClass.inc @@ -0,0 +1,120 @@ +assign("cn", $this->cn); + + /* Assign ACLs */ + $smarty->assign("acl",$this->parent->getacl("")); + + /* Show main page */ + $display= $smarty->fetch (get_template_path('dhcp_group.tpl', TRUE, + dirname(__FILE__))).$this->network->execute(); + $display.= $this->advanced->execute(); + + /* Add footer */ + $display.= "
"; + if(preg_match("/w/",$this->parent->getacl(""))){ + $display.= " "; + } + $display.= ""; + $display.= "
"; + + return ($display); + } + + + function remove_from_parent() + { + } + + + /* Save data to object */ + function save_object() + { + /* Save cn */ + if (preg_match("/w/",$this->parent->getacl("")) && isset($_POST['cn'])){ + $this->cn= validate(get_post('cn')); + } + + /* Handle global saving */ + dhcpPlugin::save_object(); + } + + + /* Check values */ + function check() + { + $message= array(); + + $cache = $this->parent->dhcpObjectCache; + + /* All required fields are set? */ + if ($this->cn == ""){ + $message[]= msgPool::required(_("Name")); + } + if (!preg_match('/^[a-z0-9_-]*$/i', $this->cn)){ + $message[]= msgPool::invalid(_("Name"),$this->cn,"/[a-z0-9_-]/i"); + } + + /* cn already used? */ + if ($this->orig_cn != $this->cn || $this->new){ + + foreach($cache as $dn => $dummy){ + if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){ + $message[]= msgPool::duplicated(_("Name")); + break; + } + } + } + + /* Check external plugins */ + $net= $this->network->check(); + $adv= $this->advanced->check(); + $message= array_merge($message, $net, $adv); + + return $message; + } + + + /* Save to LDAP */ + function save() + { + dhcpPlugin::save(); + return ($this->attrs); + } + + +} + +?> diff --git a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_servDHCP.inc b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_servDHCP.inc index 8fd87ac96..891141bf5 100644 --- a/gosa-plugins/dhcp/admin/systems/services/dhcp/class_servDHCP.inc +++ b/gosa-plugins/dhcp/admin/systems/services/dhcp/class_servDHCP.inc @@ -373,7 +373,7 @@ class servdhcp extends goService $DhcpList->AddEntry(array( array("string" => $values), array("string" => $dhcpObject->statements->get('fixed-address')), - array("string" => preg_replace('/^[^ ]+ /', '', $dhcpObject->dhcpHWAddress)), + array("string" => preg_replace('/^[^ ]+ /', '', isset($dhcpObject->dhcpHWAddress)?$dhcpObject->dhcpHWAddress:"")), array("string" => str_replace("%s",$id,$editImg), "attach" => "style='text-align:right;'") )); } @@ -477,7 +477,7 @@ class servdhcp extends goService continue; } - /* Opdate dhcp option 'server-name' to actual server name */ + /* Update dhcp option 'server-name' to actual server name */ if($this->dn != $this->orig_dn){ $fixed = FALSE; foreach(array("dhcpHost","dhcpSubnet","dhcpGroup","dhcpSharedNetwork") as $object){ -- 2.30.2