From 802a256cdbbdd5212e7c9a69cf53fc6a7c79c0fb Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 31 Jan 2006 08:52:22 +0000 Subject: [PATCH] added seperated dns class for network devices git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2607 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../admin/systems/class_componentGeneric.inc | 29 ++- plugins/admin/systems/class_phoneGeneric.inc | 45 ++--- plugins/admin/systems/class_printGeneric.inc | 27 +-- plugins/admin/systems/class_servDB.inc | 3 - plugins/admin/systems/class_servDNS.inc | 168 +++++++++++++++++- plugins/admin/systems/class_servGeneric.inc | 19 +- plugins/admin/systems/class_termDNS.inc | 79 ++++++++ .../admin/systems/class_terminalGeneric.inc | 22 ++- plugins/admin/systems/class_winGeneric.inc | 32 +--- .../systems/class_workstationGeneric.inc | 22 +-- plugins/admin/systems/component.tpl | 2 +- plugins/admin/systems/phone.tpl | 2 +- plugins/admin/systems/printer.tpl | 2 +- plugins/admin/systems/servdns.tpl | 127 ++++++++++++- plugins/admin/systems/server.tpl | 2 +- plugins/admin/systems/termdns.tpl | 3 + plugins/admin/systems/terminal.tpl | 2 +- plugins/admin/systems/wingeneric.tpl | 2 +- plugins/admin/systems/workstation.tpl | 2 +- 19 files changed, 462 insertions(+), 128 deletions(-) create mode 100644 plugins/admin/systems/class_termDNS.inc create mode 100644 plugins/admin/systems/termdns.tpl diff --git a/plugins/admin/systems/class_componentGeneric.inc b/plugins/admin/systems/class_componentGeneric.inc index c3edb7590..164b4aa7c 100644 --- a/plugins/admin/systems/class_componentGeneric.inc +++ b/plugins/admin/systems/class_componentGeneric.inc @@ -14,14 +14,13 @@ class componentGeneric extends plugin /* Needed values and lists */ var $base= ""; var $cn= ""; - var $macAddress= ""; - var $ipHostNumber= ""; var $description= ""; var $orig_dn= ""; /* attribute list for save action */ - var $attributes= array("cn", "description", "macAddress", "ipHostNumber"); + var $attributes= array("cn", "description"); var $objectclasses= array("top", "device", "ipHost", "ieee802Device"); + var $netConfigDNS; function componentgeneric ($config, $dn= NULL) { @@ -35,7 +34,7 @@ class componentGeneric extends plugin } else { $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn); } - + $this->netConfigDNS = new termDNS($this->config,$this->dn,$this->objectclasses); /* Save dn for later references */ $this->orig_dn= $this->dn; } @@ -63,11 +62,8 @@ class componentGeneric extends plugin } $smarty->assign("base_select", $this->base); - /* Show Asterisk for required attribute ipHostNumber and macAddress */ - $smarty->assign("staticAddress", "*"); - /* Show main page */ - $smarty->assign("netconfig", dirname(__FILE__)."/network.tpl"); + $smarty->assign("netconfig", $this->netConfigDNS->execute()); return($smarty->fetch (get_template_path('component.tpl', TRUE))); } @@ -86,7 +82,7 @@ class componentGeneric extends plugin unset($og->member[$this->dn]); $og->save (); } - + $this->netConfigDNS->remove_from_parent(); } @@ -95,6 +91,8 @@ class componentGeneric extends plugin { plugin::save_object(); + $this->netConfigDNS->save_object(); + /* Save base, since this is no LDAP attribute */ if (isset($_POST['base']) && chkacl($this->acl, "create") == ""){ $this->base= $_POST['base']; @@ -106,18 +104,14 @@ class componentGeneric extends plugin function check() { $message= array(); + + $message = array_merge($message,$this->netConfigDNS->check()); + $this->dn= "cn=".$this->cn.",ou=netdevices,ou=systems,".$this->base; - /* must: cn, macAddress, ipHostNumber */ if ($this->cn == "" && chkacl ($this->acl, "cn") == ""){ $message[]= _("The required field 'Component name' is not set."); } - if ($this->macAddress == "" && chkacl ($this->acl, "macAddress") == ""){ - $message[]= _("The required field 'MAC-address' is not set."); - } - if ($this->ipHostNumber == "" && chkacl ($this->acl, "ipHostNumber") == ""){ - $message[]= _("The required field 'IP-address' is not set."); - } $ui= get_userinfo(); $acl= get_permissions ($this->dn, $ui->subtreeACL); @@ -178,6 +172,9 @@ class componentGeneric extends plugin $ldap->modify($this->attrs); $this->handle_post_events("modify"); } + + $this->netConfigDNS->save($this->dn); + show_ldap_error($ldap->get_error()); /* Optionally execute a command after we're done */ diff --git a/plugins/admin/systems/class_phoneGeneric.inc b/plugins/admin/systems/class_phoneGeneric.inc index 13fa101e9..97325ea67 100644 --- a/plugins/admin/systems/class_phoneGeneric.inc +++ b/plugins/admin/systems/class_phoneGeneric.inc @@ -14,8 +14,6 @@ class phoneGeneric extends plugin /* Needed values and lists */ var $base = ""; var $cn = ""; - var $macAddress = ""; - var $ipHostNumber = ""; var $description = ""; var $orig_dn = ""; var $goFonType = ""; @@ -33,23 +31,24 @@ class phoneGeneric extends plugin var $goFonAccountCode = ""; var $goFonMSN = ""; var $selected_categorie = 0; + var $netConfigDNS; /* attribute list for save action */ - var $attributes= array("cn", "description", "macAddress", "ipHostNumber" - ,"goFonType","goFonDmtfMode","goFonHost","goFonDefaultIP", + var $attributes= array("cn", "description", + "goFonType","goFonDmtfMode","goFonHost","goFonDefaultIP", "goFonQualify","goFonAuth","goFonSecret","goFonInkeys","goFonOutkey", "goFonTrunk","goFonAccountCode","goFonMSN","selected_categorie","goFonPermit","goFonDeny" ); /* this array defines which attributes are schown / saved for the different type of phones */ - var $usedattrs = array( "0"=>array("cn", "description", "macAddress", "ipHostNumber", + var $usedattrs = array( "0"=>array("cn", "description", "goFonType","goFonDmtfMode","goFonHost","goFonDefaultIP", "goFonQualify"), - "1"=>array("cn", "description", "macAddress", "ipHostNumber", + "1"=>array("cn", "description", "goFonType","goFonHost","goFonDefaultIP", "goFonQualify","goFonAuth","goFonSecret","goFonInkeys","goFonOutkey", "goFonTrunk","goFonAccountCode","selected_categorie","goFonPermit","goFonDeny"), - "2"=>array("cn", "description", "macAddress", "ipHostNumber","goFonMSN")); + "2"=>array("cn", "description", "goFonMSN")); var $objectclasses= array("top", "goFonHardware"); @@ -57,6 +56,7 @@ class phoneGeneric extends plugin function phonegeneric ($config, $dn= NULL) { plugin::plugin ($config, $dn); + $this->netConfigDNS = new termDNS($this->config,$this->dn,$this->objectclasses); /* Set base */ if ($this->dn == "new"){ @@ -197,11 +197,8 @@ class phoneGeneric extends plugin $smarty->assign("goFonDefaultIPs",array("dynamic"=>_("dynamic"),"network"=>_("Networksettings"))); - /* Show Asterisk for required attribute ipHostNumber and macAddress */ - $smarty->assign("staticAddress", "*"); - /* Show main page */ - $smarty->assign("netconfig", dirname(__FILE__)."/network.tpl"); + $smarty->assign("netconfig", $this->netConfigDNS->execute()); $smarty->assign("phonesettings", dirname(__FILE__)."/phonesettings.tpl"); return($smarty->fetch (get_template_path('phone.tpl', TRUE))); } @@ -230,7 +227,7 @@ class phoneGeneric extends plugin unset($og->member[$this->dn]); $og->save (); } - + $this->netConfigDNS->remove_from_parent(); } @@ -238,7 +235,7 @@ class phoneGeneric extends plugin function save_object() { plugin::save_object(); - + $this->netConfigDNS->save_object(); /* Save base, since this is no LDAP attribute */ if (isset($_POST['base']) && chkacl($this->acl, "create") == ""){ $this->base= $_POST['base']; @@ -249,7 +246,7 @@ class phoneGeneric extends plugin /* Check supplied data */ function check() { - $message= array(); + $message= $this->netConfigDNS->check(); $this->dn= "cn=".$this->cn.",ou=phones,ou=systems,".$this->base; /* To check for valid ip*/ @@ -268,27 +265,12 @@ class phoneGeneric extends plugin // } // } - /* must: cn, macAddress, ipHostNumber */ if ($this->cn == "" && chkacl ($this->acl, "cn") == ""){ $message[]= _("The required field 'Phone name' is not set."); } if ($this->cn == "0" && chkacl ($this->acl, "cn") == ""){ $message[]= _("The 'Phone name' '0' is reserved and cannot be used."); } - if ($this->macAddress == "" && chkacl ($this->acl, "macAddress") == ""){ - $message[]= _("The required field 'MAC-address' is not set."); - } - if ($this->ipHostNumber == "" && chkacl ($this->acl, "ipHostNumber") == ""){ - $message[]= _("The required field 'IP-address' is not set."); - } - if (!preg_match("/^$num\\.$num\\.$num\\.$num$/", $this->ipHostNumber)){ - $message[]= _("Wrong IP format in field IP-address."); - } - - $tr = count(split(":",$this->macAddress)); - if($tr!=6){ - $message[]=(_("The given macaddress is invalid. There must be 6 2byte segments seperated by ':'.")); - } $ui= get_userinfo(); $acl= get_permissions ($this->dn, $ui->subtreeACL); @@ -354,7 +336,7 @@ class phoneGeneric extends plugin } if($this->goFonDefaultIP!="dynamic"){ - $this->attrs['goFonDefaultIP'] = $this->ipHostNumber; + $this->attrs['goFonDefaultIP'] = $this->netConfigDNS->ipHostNumber; } /* Write back to ldap */ @@ -383,6 +365,9 @@ class phoneGeneric extends plugin } $this->handle_post_events("modify"); } + + $this->netConfigDNS->save($this->dn); + show_ldap_error($ldap->get_error()); /* Optionally execute a command after we're done */ $this->postcreate(); diff --git a/plugins/admin/systems/class_printGeneric.inc b/plugins/admin/systems/class_printGeneric.inc index 24fe12cf0..95d2a983c 100644 --- a/plugins/admin/systems/class_printGeneric.inc +++ b/plugins/admin/systems/class_printGeneric.inc @@ -14,8 +14,6 @@ class printgeneric extends plugin /* Needed values and lists */ var $base = ""; var $cn = ""; - var $macAddress = ""; - var $ipHostNumber = ""; var $l = ""; var $description = ""; var $labeledURI = ""; @@ -40,14 +38,19 @@ class printgeneric extends plugin var $type = ""; var $dialog =NULL; + var $netConfigDNS; + /* attribute list for save action */ - var $attributes = array("cn", "description", "l", "labeledURI", "macAddress", "ipHostNumber","gotoPrinterPPD"); + var $attributes = array("cn", "description", "l", "labeledURI", "gotoPrinterPPD"); var $objectclasses = array("top", "gotoPrinter"); function printgeneric ($config, $dn= NULL) { plugin::plugin ($config, $dn); $ldap= $this->config->get_ldap_link(); + + $this->netConfigDNS = new termDNS($this->config, $this->dn,$this->objectclasses); + /* Set base */ if ($this->dn == "new"){ @@ -371,10 +374,6 @@ class printgeneric extends plugin return $display; } - /* Don't show Asterisk for non-required attribute ipHostNumber and macAddress */ - $smarty->assign("staticAddress", ""); - - require_once ("class_ppdManager.inc"); if((isset($_SESSION['config']->data['MAIN']['PPD_PATH']))&&(is_dir($_SESSION['config']->data['MAIN']['PPD_PATH']))){ @@ -422,7 +421,7 @@ class printgeneric extends plugin $smarty->assign("AdminMember" ,$this->AdminMember); $smarty->assign("AdminMembers" ,$adminlist); $smarty->assign("AdminMemberKeys",array_flip($adminlist)); - $smarty->assign("netconfig", dirname(__FILE__)."/network.tpl"); + $smarty->assign("netconfig", $this->netConfigDNS->execute()); return($display.$smarty->fetch (get_template_path('printer.tpl', TRUE))); } @@ -446,14 +445,16 @@ class printgeneric extends plugin unset($og->member[$this->dn]); $og->save (); } + + $this->netConfigDNS->remove_from_parent(); } } } - /* Save data to object */ - function save_object() + /* Save data to object */ + function save_object() { plugin::save_object(); - + $this->netConfigDNS->save_object(); /* Save base, since this is no LDAP attribute */ if (isset($_POST['base']) && chkacl($this->acl, "create") == ""){ $this->base= $_POST['base']; @@ -463,7 +464,7 @@ class printgeneric extends plugin /* Check supplied data */ function check() { - $message= array(); + $message= $this->netConfigDNS->check(); if(isset($this->parent->by_name['workgeneric'])){ if($this->parent->by_object['workgeneric']->cn == "wdefault"){ @@ -620,6 +621,8 @@ class printgeneric extends plugin } show_ldap_error($ldap->get_error()); + $this->netConfigDNS->save($this->dn); + /* Optionally execute a command after we're done */ $this->postcreate(); } diff --git a/plugins/admin/systems/class_servDB.inc b/plugins/admin/systems/class_servDB.inc index 2ee9f873d..de6214635 100644 --- a/plugins/admin/systems/class_servDB.inc +++ b/plugins/admin/systems/class_servDB.inc @@ -83,9 +83,6 @@ class servdb extends plugin $smarty->assign("$attr"."ACL", chkacl($this->acl, $attr)); } - /* Don't show Asterisk for non-required attribute ipHostNumber and macAddress */ - $smarty->assign("staticAddress", ""); - /* Classes... */ foreach ($this->additionaloc as $oc => $dummy){ if (isset($this->objectclasses[$oc])){ diff --git a/plugins/admin/systems/class_servDNS.inc b/plugins/admin/systems/class_servDNS.inc index ab9342ead..fa48534c4 100644 --- a/plugins/admin/systems/class_servDNS.inc +++ b/plugins/admin/systems/class_servDNS.inc @@ -9,12 +9,124 @@ class servdns extends plugin /* attribute list for save action */ var $ignore_account= TRUE; - var $attributes= array(); + var $attributes= array("zoneName","relativeDomainName","dNSTTL","dNSClass","sOARecord"); var $objectclasses= array("whatever"); + var $RecordTypes = array(); + var $usedRecords = array(); + + var $Zones = array(); + var $editMode = false; + function servdns ($config, $dn= NULL) { plugin::plugin ($config, $dn); + + $RecordTypes['ARecord'] ['name'] ="A Record"; + $RecordTypes['ARecord'] ['type'] ="string"; + $RecordTypes['MDRecord'] ['name'] ="MD Record"; + $RecordTypes['MDRecord'] ['type'] ="string"; + $RecordTypes['MXRecord'] ['name'] ="MX Record"; + $RecordTypes['MXRecord'] ['type'] ="string"; + $RecordTypes['NSRecord'] ['name'] ="NS Record"; + $RecordTypes['NSRecord'] ['type'] ="string"; + $RecordTypes['CNAMERecord'] ['name'] ="CNAME Record"; + $RecordTypes['CNAMERecord'] ['type'] ="string"; + $RecordTypes['PTRRecord'] ['name'] ="PTR Record"; + $RecordTypes['PTRRecord'] ['type'] ="string"; + $RecordTypes['HINFORecord'] ['name'] ="HINFO Record"; + $RecordTypes['HINFORecord'] ['type'] ="string"; + $RecordTypes['MINFORecord'] ['name'] ="MINFO Record"; + $RecordTypes['MINFORecord'] ['type'] ="string"; + $RecordTypes['TXTRecord'] ['name'] ="TXT Record"; + $RecordTypes['TXTRecord'] ['type'] ="string"; + $RecordTypes['AFSDBRecord'] ['name'] ="AFSDB Record"; + $RecordTypes['AFSDBRecord'] ['type'] ="string"; + $RecordTypes['SIGRecord'] ['name'] ="SIG Record"; + $RecordTypes['SIGRecord'] ['type'] ="string"; + $RecordTypes['KEYRecord'] ['name'] ="KEY Record"; + $RecordTypes['KEYRecord'] ['type'] ="string"; + $RecordTypes['AAAARecord'] ['name'] ="AAAA Record"; + $RecordTypes['AAAARecord'] ['type'] ="string"; + $RecordTypes['LOCRecord'] ['name'] ="LOC Record"; + $RecordTypes['LOCRecord'] ['type'] ="string"; + $RecordTypes['NXTRecord'] ['name'] ="NXT Record"; + $RecordTypes['NXTRecord'] ['type'] ="string"; + $RecordTypes['SRVRecord'] ['name'] ="SRV Record"; + $RecordTypes['SRVRecord'] ['type'] ="string"; + $RecordTypes['NAPTRRecord'] ['name'] ="NAPTR Record"; + $RecordTypes['NAPTRRecord'] ['type'] ="string"; + $RecordTypes['KXRecord'] ['name'] ="KX Record"; + $RecordTypes['KXRecord'] ['type'] ="string"; + $RecordTypes['CERTRecord'] ['name'] ="CERT Record"; + $RecordTypes['CERTRecord'] ['type'] ="string"; + $RecordTypes['A6Record'] ['name'] ="A6 Record"; + $RecordTypes['A6Record'] ['type'] ="string"; + $RecordTypes['DNAMERecord'] ['name'] ="DBNAME Record"; + $RecordTypes['DNAMERecord'] ['type'] ="string"; + $RecordTypes['DSRecord'] ['name'] ="DS Record"; + $RecordTypes['DSRecord'] ['type'] ="string"; + $RecordTypes['SSHFPRecord'] ['name'] ="SSHFP Record"; + $RecordTypes['SSHFPRecord'] ['type'] ="string"; + $RecordTypes['RRSIGRecord'] ['name'] ="RRSIG Record"; + $RecordTypes['RRSIGRecord'] ['type'] ="string"; + $RecordTypes['NSECRecord'] ['name'] ="NSEC Record"; + $RecordTypes['NSECRecord'] ['type'] ="string"; + $RecordTypes['mXRecord'] ['name'] ="MX Record"; + $RecordTypes['mXRecord'] ['type'] ="string"; + $RecordTypes['nSRecord'] ['name'] ="nS Record"; + $RecordTypes['nSRecord'] ['type'] ="string"; + + $this->RecordTypes = $RecordTypes; + + $attrs = $this->attributes; + foreach($RecordTypes as $name => $att){ + $attrs2[] = $name; + } + $attrs3 = array_merge($attrs,$attrs2); + + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $ldap->search("(&(objectClass=dNSZone)(sOARecord=*))",$attrs3); + while($zone = $ldap->fetch()){ + $tmp = array(); + foreach($attrs as $att){ + if(isset($zone[$att]['count'])&&(is_array($zone[$att]))) + unset($zone[$att]['count']); + + if(isset($zone[$att])){ + $tmp[$att] = $zone[$att][0]; + }else{ + $tmp[$att] = ""; + } + } + + if(isset($tmp['sOARecord'])){ + $tmp2 = split("\ ",$tmp['sOARecord']); + unset($tmp['sOARecord']); + $tmp['sOARecord'] = array(); + $tmp['sOARecord']['sOAprimary'] = $tmp2[0]; + $tmp['sOARecord']['sOAmail'] = $tmp2[1]; + $tmp['sOARecord']['sOAserial'] = $tmp2[2]; + $tmp['sOARecord']['sOArefresh'] = $tmp2[3]; + $tmp['sOARecord']['sOAretry'] = $tmp2[4]; + $tmp['sOARecord']['sOAexpire'] = $tmp2[5]; + $tmp['sOARecord']['sOAttl'] = $tmp2[6]; + } + + $tmp['usedRecords'] = array(); + foreach($attrs2 as $name){ + if(isset($zone[$name])){ + for($i = 0 ; $i < $zone[$name]['count'] ; $i++ ){ + $tmp['usedRecords'][] = array("type"=> $name,"value"=>$zone[$name][$i]); + } + } + } + $this->Zones[$zone['zoneName'][0]] = $tmp; + } + if(count($this->Zones > 0)){ + $this->is_account = true; + } } function execute() @@ -41,6 +153,43 @@ class servdns extends plugin return ($display); } + $once = false; + foreach( $_POST as $name => $value){ + if(preg_match("/^editZone_/",$name)&&!$once){ + $once =true; + $tmp = preg_replace("/^editZone_/","",$name); + $tmp = base64_decode(preg_replace("/_.*$/","...",$tmp)); + $this->editMode = $this->Zones[$tmp]; + } + } + + + $smarty->assign("editMode",$this->editMode); + if($this->editMode){ + + foreach($this->attributes as $attrs){ + $smarty->assign($attrs,$this->editMode[$attrs]); + } + + foreach($this->editMode['sOARecord'] as $name => $value){ + $smarty->assign($name,$value); + } + $smarty->assign("records",""); + + }else{ + $ZoneList = new divSelectBox("dNSZones"); + $ZoneList -> SetHeight(254); + + $editImg = ""; + + foreach($this->Zones as $zone => $values ){ + $ZoneList->AddEntry(array(array("string" => $zone.str_replace("%s",base64_encode($zone),$editImg)))); + } + + + $smarty->assign("ZoneList",$ZoneList->DrawList()); + } + $display.= $smarty->fetch(get_template_path('servdns.tpl', TRUE)); return($display); } @@ -54,7 +203,22 @@ class servdns extends plugin /* Save data to object */ function save_object() { - plugin::save_object(); + //plugin::save_object(); + + if(!$this->editMode){return;} + + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->editMode[$attr] = $_POST[$attr]; + } + } + + foreach($this->editMode['sOARecord'] as $name => $value){ + if(isset($_POST[$name])){ + $this->editMode['sOARecord'][$name] = $_POST[$name]; + } + } + } diff --git a/plugins/admin/systems/class_servGeneric.inc b/plugins/admin/systems/class_servGeneric.inc index b85d9c834..0c7c0d99e 100644 --- a/plugins/admin/systems/class_servGeneric.inc +++ b/plugins/admin/systems/class_servGeneric.inc @@ -15,15 +15,15 @@ class servgeneric extends plugin var $base= ""; var $cn= ""; var $l= ""; - var $macAddress= ""; - var $ipHostNumber= ""; var $description= ""; var $orig_dn= ""; /* attribute list for save action */ - var $attributes= array("cn", "description", "macAddress", "ipHostNumber"); + var $attributes= array("cn", "description"); var $objectclasses= array("top", "goServer"); + var $netConfigDNS; + function servgeneric ($config, $dn= NULL) { plugin::plugin ($config, $dn); @@ -36,7 +36,7 @@ class servgeneric extends plugin } else { $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn); } - + $this->netConfigDNS = new termDNS($this->config,$this->dn,$this->objectclasses); /* Save dn for later references */ $this->orig_dn= $this->dn; } @@ -61,7 +61,7 @@ class servgeneric extends plugin if ($cmd == ""){ print_red(_("No WAKECMD definition found in your gosa.conf")); } else { - exec ($cmd." ".$this->macAddress, $dummy, $retval); + exec ($cmd." ".$this->netConfigDNS->macAddress, $dummy, $retval); if ($retval != 0){ print_red(sprintf(_("Execution of '%s' failed!"), $cmd)); } @@ -119,7 +119,7 @@ class servgeneric extends plugin /* Show main page */ - $smarty->assign("netconfig", dirname(__FILE__)."/network.tpl"); + $smarty->assign("netconfig", $this->netConfigDNS->execute()); return($smarty->fetch (get_template_path('server.tpl', TRUE))); } @@ -138,7 +138,7 @@ class servgeneric extends plugin unset($og->member[$this->dn]); $og->save (); } - + $this->netConfigDNS->remove_from_parent(); $this->handle_post_events("remove"); } @@ -147,7 +147,7 @@ class servgeneric extends plugin function save_object() { plugin::save_object(); - + $this->netConfigDNS->save_object(); /* Save base, since this is no LDAP attribute */ if (isset($_POST['base']) && chkacl($this->acl, "create") == ""){ $this->base= $_POST['base']; @@ -158,7 +158,7 @@ class servgeneric extends plugin /* Check supplied data */ function check() { - $message= array(); + $message= $this->netConfigDNS->check(); $this->dn= "cn=".$this->cn.",ou=servers,ou=systems,".$this->base; /* must: cn */ @@ -235,6 +235,7 @@ class servgeneric extends plugin $ldap->modify($this->attrs); $mode= "modify"; } + $this->netConfigDNS->save($this->dn); show_ldap_error($ldap->get_error()); /* Optionally execute a command after we're done */ diff --git a/plugins/admin/systems/class_termDNS.inc b/plugins/admin/systems/class_termDNS.inc new file mode 100644 index 000000000..f3cfc4ed6 --- /dev/null +++ b/plugins/admin/systems/class_termDNS.inc @@ -0,0 +1,79 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account= TRUE; + var $attributes= array("ipHostNumber","macAddress"); + var $objectclasses= array("whatever"); + + var $ipHostNumber =""; + var $macAddress =""; + + function termDNS ($config, $dn,$objectClasses) + { + $this->objectclasses= $objectClasses; + plugin::plugin ($config, $dn); + } + + function execute() + { + /* Call parent execute */ + $smarty= get_smarty(); + $display= ""; + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + $smarty->assign("staticAddress","*"); + $display.= $smarty->fetch(get_template_path('network.tpl', TRUE)); + return($display); + } + + function remove_from_parent() + { + /* This cannot be removed... */ + } + + + /* Save data to object */ + function save_object() + { + plugin::save_object(); + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = $_POST[$attr]; + } + } + } + + + /* Check supplied data */ + function check() + { + $message= array(); + + return ($message); + } + + + /* Save to LDAP */ + function save($dn) + { + $org_dn = $dn; + $this->dn = $dn; + plugin::save(); + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/admin/systems/class_terminalGeneric.inc b/plugins/admin/systems/class_terminalGeneric.inc index 5c825dcae..e6a949ab3 100644 --- a/plugins/admin/systems/class_terminalGeneric.inc +++ b/plugins/admin/systems/class_terminalGeneric.inc @@ -18,8 +18,6 @@ class termgeneric extends plugin var $gotoCdromEnable= ""; var $ghCpuType= "-"; var $ghMemSize= "-"; - var $macAddress= ""; - var $ipHostNumber= ""; var $ghUsbSupport= "-"; var $ghNetNic= array(); var $ghIdeDev= array(); @@ -27,7 +25,7 @@ class termgeneric extends plugin var $ghGfxAdapter= "-"; var $ghSoundAdapter= "-"; var $gotoLastUser= "-"; - + var $netConfigDNS; /* Needed values and lists */ var $base= ""; var $cn= ""; @@ -38,17 +36,17 @@ class termgeneric extends plugin /* attribute list for save action */ var $ignore_account= TRUE; - var $attributes= array("gotoMode", "gotoTerminalPath", "macAddress", + var $attributes= array("gotoMode", "gotoTerminalPath", "gotoSwapServer", "gotoSyslogServer", "gotoNtpServer", "gotoFloppyEnable", "gotoCdromEnable", "cn", "gotoSndModule", - "ghCpuType", "ghMemSize", "ipHostNumber", "ghUsbSupport", + "ghCpuType", "ghMemSize","ghUsbSupport", "ghGfxAdapter", "ghSoundAdapter", "gotoLastUser"); var $objectclasses= array("top", "gotoTerminal", "GOhard"); function termgeneric ($config, $dn= NULL) { plugin::plugin ($config, $dn); - + $this->netConfigDNS = new termDNS($this->config,$this->dn,$this->objectclasses); /* Read arrays */ foreach (array("ghNetNic", "ghIdeDev", "ghScsiDev") as $val){ if (!isset($this->attrs[$val])){ @@ -91,7 +89,7 @@ class termgeneric extends plugin if ($cmd == ""){ print_red(_("No WAKECMD definition found in your gosa.conf")); } else { - exec ($cmd." ".$this->macAddress, $dummy, $retval); + exec ($cmd." ".$this->netConfigDNS->macAddress, $dummy, $retval); if ($retval != 0){ print_red(sprintf(_("Execution of '%s' failed!"), $cmd)); } @@ -182,11 +180,9 @@ class termgeneric extends plugin $smarty->assign($val."_select", $this->$val); $smarty->assign($val."ACL", chkacl($this->acl, $val)); } - $smarty->assign("ipHostNumber", $this->ipHostNumber); - $smarty->assign("macAddress", $this->macAddress); /* Show main page */ - $smarty->assign("netconfig", dirname(__FILE__)."/network.tpl"); + $smarty->assign("netconfig", $this->netConfigDNS->execute()); $smarty->assign("actionACL", chkacl($this->acl, 'action')); return($smarty->fetch (get_template_path('terminal.tpl', TRUE))); } @@ -213,6 +209,7 @@ class termgeneric extends plugin unset($og->member[$this->dn]); $og->save (); } + $this->netConfigDNS->remove_from_parent(); } } @@ -221,7 +218,7 @@ class termgeneric extends plugin function save_object() { plugin::save_object(); - + $this->netConfigDNS->save_object(); /* Save base, since this is no LDAP attribute */ if (isset($_POST['base']) && chkacl($this->acl, "create") == ""){ $this->base= $_POST['base']; @@ -236,7 +233,7 @@ class termgeneric extends plugin /* Check supplied data */ function check() { - $message= array(); + $message= $this->netConfigDNS->check(); /* Permissions for that base? */ $this->dn= "cn=".$this->cn."ou=terminals,ou=systems,".$this->base; @@ -322,6 +319,7 @@ class termgeneric extends plugin $ldap->modify($this->attrs); $this->handle_post_events("modify"); } + $this->netConfigDNS->save($this->dn); show_ldap_error($ldap->get_error()); /* Optionally execute a command after we're done */ diff --git a/plugins/admin/systems/class_winGeneric.inc b/plugins/admin/systems/class_winGeneric.inc index 82b847a79..4fc4ab92e 100644 --- a/plugins/admin/systems/class_winGeneric.inc +++ b/plugins/admin/systems/class_winGeneric.inc @@ -34,7 +34,7 @@ class wingeneric extends plugin var $sambaNTPassword=""; var $sambaPwdLastSet=""; var $sambaAcctFlags=""; - + var $netConfigDNS; /* attribute list for save action */ var $ignore_account= TRUE; var $attributes = array("cn", "description","shadowLastChange", @@ -48,7 +48,7 @@ class wingeneric extends plugin function wingeneric ($config, $dn= NULL) { plugin::plugin ($config, $dn); - + $this->netConfigDNS = new termDNS($this->config,$this->dn,$this->objectclasses); /* Set base */ if ($this->dn == "new"){ $ui= get_userinfo(); @@ -78,9 +78,6 @@ class wingeneric extends plugin $smarty= get_smarty(); // Undefined index in wingeneric.tpl ... - $smarty->assign("macAddress",""); - $smarty->assign("ipHostNumber",""); - $smarty->assign("bases", $this->config->idepartments); /* Assign attributes */ @@ -89,13 +86,10 @@ class wingeneric extends plugin $smarty->assign("$attr", $this->$attr); } - /* Show Asterisk for required attribute ipHostNumber and macAddress */ - $smarty->assign("staticAddress", "*"); - $smarty->assign("base_select", $this->base); /* Show main page */ - $smarty->assign("netconfig", dirname(__FILE__)."/network.tpl"); + $smarty->assign("netconfig", $this->netConfigDNS->execute()); return($smarty->fetch (get_template_path('wingeneric.tpl', TRUE))); } @@ -114,7 +108,7 @@ class wingeneric extends plugin unset($og->member[$this->dn]); $og->save (); } - + $this->netConfigDNS->remove_from_parent(); } @@ -122,7 +116,7 @@ class wingeneric extends plugin function save_object() { plugin::save_object(); - + $this->netConfigDNS->save_object(); /* Save base, since this is no LDAP attribute */ if (isset($_POST['base']) && chkacl($this->acl, "create") == ""){ $this->base= $_POST['base']; @@ -133,22 +127,9 @@ class wingeneric extends plugin /* Check supplied data */ function check() { - $message= array(); + $message=$this->netConfigDNS->check(); $this->dn= "cn=".$this->cn.",ou=netdevices,ou=systems,".$this->base; - - /* must: cn, macAddress */ - if ($this->cn == "" && chkacl ($this->acl, "cn") == ""){ - $message[]= _("The required field 'Component name' is not set."); - } - -/* if ($this->macAddress == "" && chkacl ($this->acl, "macAddress") == ""){ - $message[]= _("The required field 'MAC-address' is not set."); - } - if ($this->ipHostNumber == "" && chkacl ($this->acl, "ipHostNumber") == ""){ - $message[]= _("The required field 'IP-address' is not set."); - } -*/ $ui= get_userinfo(); $acl= get_permissions ($this->dn, $ui->subtreeACL); $acl= get_module_permission($acl, "component", $this->dn); @@ -208,6 +189,7 @@ class wingeneric extends plugin $ldap->modify($this->attrs); $this->handle_post_events("modify"); } + $this->netConfigDNS->save($this->dn); show_ldap_error($ldap->get_error()); /* Optionally execute a command after we're done */ diff --git a/plugins/admin/systems/class_workstationGeneric.inc b/plugins/admin/systems/class_workstationGeneric.inc index 33a49bcb0..88abf0466 100644 --- a/plugins/admin/systems/class_workstationGeneric.inc +++ b/plugins/admin/systems/class_workstationGeneric.inc @@ -16,8 +16,6 @@ class workgeneric extends plugin var $gotoCdromEnable= ""; var $ghCpuType= "-"; var $ghMemSize= "-"; - var $macAddress= ""; - var $ipHostNumber= ""; var $ghUsbSupport= "-"; var $ghNetNic= array(); var $ghIdeDev= array(); @@ -37,18 +35,20 @@ class workgeneric extends plugin /* Plugin side filled */ var $modes= array(); + var $netConfigDNS; + /* attribute list for save action */ var $ignore_account= TRUE; - var $attributes= array("gotoMode", "macAddress", "gotoSyslogServer", "gotoNtpServer", + var $attributes= array("gotoMode", "gotoSyslogServer", "gotoNtpServer", "gotoFloppyEnable", "gotoCdromEnable", "cn", "gotoSndModule", - "ghCpuType", "ghMemSize", "ghUsbSupport", "ipHostNumber", + "ghCpuType", "ghMemSize", "ghUsbSupport", "ghGfxAdapter", "ghSoundAdapter", "gotoLastUser", "l","FAIscript"); var $objectclasses= array("top", "gotoWorkstation", "GOhard","FAIobject"); function workgeneric ($config, $dn= NULL) { plugin::plugin ($config, $dn); - + $this->netConfigDNS = new termDNS($this->config,$this->dn,$this->objectclasses); /* Load available modes */ $ldap= $this->config->get_ldap_link(); $ldap->cd ($this->config->current['BASE']); @@ -99,7 +99,7 @@ class workgeneric extends plugin if ($cmd == ""){ print_red(_("No ACTIONCMD definition found in your gosa.conf")); } else { - exec ($cmd." ".$this->macAddress." ".escapeshellarg($_POST['saction']), $dummy, $retval); + exec ($cmd." ".$this->netConfigDNS->macAddress." ".escapeshellarg($_POST['saction']), $dummy, $retval); if ($retval != 0){ print_red(sprintf(_("Execution of '%s' failed!"), $cmd)); } else { @@ -149,12 +149,10 @@ class workgeneric extends plugin $smarty->assign($val."_select", $this->$val); $smarty->assign($val."ACL", chkacl($this->acl, $val)); } - $smarty->assign("ipHostNumber", $this->ipHostNumber); - $smarty->assign("macAddress", $this->macAddress); $smarty->assign("actionACL", chkacl($this->acl, 'action')); /* Show main page */ - $smarty->assign("netconfig", dirname(__FILE__)."/network.tpl"); + $smarty->assign("netconfig", $this->netConfigDNS->execute()); return($smarty->fetch (get_template_path('workstation.tpl', TRUE))); } @@ -175,7 +173,7 @@ class workgeneric extends plugin unset($og->member[$this->dn]); $og->save (); } - + $this->netConfigDNS->remove_from_parent(); } @@ -188,13 +186,14 @@ class workgeneric extends plugin if (isset($_POST['base']) && chkacl($this->acl, "create") == ""){ $this->base= $_POST['base']; } + $this->netConfigDNS->save_object(); } /* Check supplied data */ function check() { - $message= array(); + $message=$this->netConfigDNS->check(); $ui= get_userinfo(); $this->dn= "cn=".$this->cn.",ou=workstations,ou=systems,".$this->base; @@ -282,6 +281,7 @@ class workgeneric extends plugin $this->handle_post_events("modify"); } } + $this->netConfigDNS->save($this->dn); show_ldap_error($ldap->get_error()); } diff --git a/plugins/admin/systems/component.tpl b/plugins/admin/systems/component.tpl index ce04d6ffe..a1581c2d5 100644 --- a/plugins/admin/systems/component.tpl +++ b/plugins/admin/systems/component.tpl @@ -31,7 +31,7 @@

 

-{include file="$netconfig"} +{$netconfig}