summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 43d57f1)
raw | patch | inline | side by side (parent: 43d57f1)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 24 Aug 2007 07:31:06 +0000 (07:31 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 24 Aug 2007 07:31:06 +0000 (07:31 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7126 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/plugins/addons/gotomasses/class_goto_task.inc b/plugins/addons/gotomasses/class_goto_task.inc
index 9e52abafdad0b516631bb720b9bb5e0bbd524e9d..6ea40603e0b5a90acdc01576267774f4cad57730 100644 (file)
var $Month = "*";
var $Weekday = "*";
var $Action = "install";
+
+ var $Zone = "";
+ var $Section = "";
+
+ var $Zones = array();
+ var $Sections = array();
+
var $Comment = "";
var $OGroup = "keep_current";
var $OGroups = array();
var $new = FALSE;
var $attributes = array("OGroup","Minute","Hour","Day","Month","Weekday","Action","Comment","Target","Initial_Target");
+ var $configure_dhcp = FALSE;
+ var $configure_dns = FALSE;
function goto_task($config,$parent,$data = array())
{
/* Intialize plugin */
$this->config = $config;
if(count($data)){
-
$tmp = $this->get_array_values();
foreach($this->attributes as $attr){
if(!isset($data[$attr])){
$this->new = TRUE;
}
+ /* Set dns and dhcp attributes */
+ foreach(getAvailableZones($this->config) as $zone){
+ $name = preg_replace("#^[^/]+/#","",$zone);
+ $this->Zones[$name] = $zone;
+ }
+ $this->Sections = $this->get_dhcp_sections();
+
/* Create ogroup select list */
$this->OGroups = array("\"\"" => "["._("Keep current")."]");
$this->OGroups = array_merge($this->OGroups,$this->parent->get_object_groups());
$MAC = $_POST['task_MAC'];
$NAME= "";
$IP = "";
+ $DNS = "";
+ $DHCP = "";
if(isset($_POST['task_Name'])){
$NAME = $_POST['task_Name'];
}
if(isset($_POST['task_IP']) && is_ip($_POST['task_IP'])){
$IP = $_POST['task_IP'];
}
+ if(isset($_POST['configure_dns']) && isset($_POST['Zone']) && isset($this->Zones[$_POST['Zone']])){
+ $DNS = $_POST['Zone'];
+ }
+ if(isset($_POST['configure_dhcp']) && isset($_POST['Section']) && isset($this->Sections[$_POST['Section']])){
+ $DHCP = $_POST['Section'];
+ }
if(is_mac($MAC)){
- $this->Initial_Target[] = array("MAC"=>$MAC,"IP"=>$IP,"NAME"=>$NAME);
+ $this->Initial_Target[] = array("MAC"=>$MAC,"IP"=>$IP,"NAME"=>$NAME,
+ "ZONE" => $DNS , "SECTION" => $DHCP);
}
}
}
$line = fgets($fp,512);
$tmp = preg_split("/(,|;)/",$line);
- $MAC = $IP = $NAME = "";
+ $MAC = $IP = $NAME = $ZONE = $SECTION ="";
if(isset($tmp[0])){
- $MAC = $tmp[0];
+ $MAC = trim($tmp[0]);
}
if(isset($tmp[1])){
- $IP = $tmp[1];
+ $IP = trim($tmp[1]);
}
if(isset($tmp[2])){
- $NAME = $tmp[2];
+ $NAME = trim($tmp[2]);
+ }
+ if(isset($tmp[3])){
+ $ZONE = trim($tmp[3]);
+ }
+ if(isset($tmp[4])){
+ $SECTION = trim($tmp[4]);
}
if(is_mac($MAC)){
- $this->Initial_Target[] = array("MAC"=>$MAC,"IP"=>$IP,"NAME"=>$NAME);
+ $this->Initial_Target[] = array("MAC"=>$MAC,"IP"=>$IP,"NAME"=>$NAME,"ZONE"=> $ZONE,"SECTION"=>$SECTION);
}
}
}
/* Add entries to divlist */
if($this->Action == "initial_install"){
$divlist->SetHeader(array(
- array("string" => _("Target systems")),
+ array("string" => _("Target systems") ,"attach" => "style='width:120px;'"),
array("string" => _("IP") , "attach" => "style='width:90px;'"),
+ array("string" => _("DNS") ),
+ array("string" => _("DHCP") , "attach" => "style='width:120px;'"),
array("string" => _("Name") , "attach" => "style='width:150px;'"),
array("string" => _("Actions") , "attach" => "style='width:44px;border-right:0px;text-align:right;'")));
foreach($this->Initial_Target as $key => $target){
- $field1 = array("string" => $target['MAC'] );
+ $field1 = array("string" => $target['MAC'] ,"attach" => "style='width:120px;'");
$field2 = array("string" => $target['IP'] ,"attach" => "style='width:90px;'");
- $field3 = array("string" => $target['NAME'] ,"attach" => "style='width:150px;'");
- $divlist->AddEntry(array($field1,$field2,$field3,preg_replace("/%KEY%/",$key,$field_del)));
+ if(isset($this->Zones[$target['ZONE']])){
+ $field2a = array("string" =>"<div style='overflow:hidden'><nobr>".
+ $this->Zones[$target['ZONE']]."</nobr></div>");
+ }else{
+ $field2a = array("string" => "<div style='overflow:hidden'><nobr>".
+ $target['ZONE']."</nobr></div>");
+ }
+ if(isset($this->Sections[$target['SECTION']])){
+ $field2b = array("string" => "<div style='overflow:hidden'><nobr>".
+ $this->Sections[$target['SECTION']]."</nobr></div>","attach" => "style='width:120px;'");
+ }else{
+ $field2b = array("string" => "<div style='overflow:hidden'><nobr>".
+ $target['SECTION']."</nobr></div>" ,"attach" => "style='width:120px;'");
+ }
+ $field3 = array("string" => $target['NAME'] ,"attach" => "style='width:150px;'");
+ $divlist->AddEntry(array($field1,$field2,$field2a,$field2b,$field3,preg_replace("/%KEY%/",$key,$field_del)));
}
}else{
$divlist->SetHeader(array(
$smarty->assign($attr,$this->$attr);
}
+ $smarty->assign("Zones", $this->Zones);
+ $smarty->assign("Sections", $this->Sections);
+
+ $smarty->assign("Zone", $this->Zone);
+ $smarty->assign("Section", $this->Section);
+
+ $smarty->assign("configure_dhcp", $this->configure_dhcp);
+ $smarty->assign("configure_dns", $this->configure_dns);
+
$tmp = $this->get_array_values();
$smarty->assign("JS" , $_SESSION['js']);
$smarty->assign("Minutes" , $tmp['Minute']);
return ($smarty->fetch (get_template_path('goto_task.tpl', TRUE)));
}
+
+ function create_tree($arr,$base,$current = "")
+ {
+ $ret = array();
+ foreach($arr as $r => $name){
+ $base_part = str_replace($base,"",$r);
+ if(preg_match("/^[a-z]*=".normalizePreg($name)."(|,)$/i",$base_part)){
+ $ret[$r] = $current.$name;
+ $tmp = $this->create_tree($arr,$r,$current.". ");
+ foreach($tmp as $sub_key => $sub_name){
+ $ret[$sub_key] = $sub_name;
+ }
+ }
+ }
+ return($ret);
+ }
+
+
+
+ function get_dhcp_sections()
+ {
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(objectClass=dhcpService)",array("dhcpPrimaryDN"));
+
+ $tmp = array();
+ $tmp2 = array();
+
+ $dhcp_dns = array();
+ while($attr = $ldap->fetch()){
+ $dhcp_dns[$attr['dn']] = $attr['dhcpPrimaryDN'][0];
+ }
+
+ foreach($dhcp_dns as $key => $pri_dns){
+ $ldap->cat($pri_dns,array("cn"));
+ $tmp = $ldap->fetch();
+ $dhcp_dns[$key] = $tmp['cn'][0];
+ }
+
+ foreach($dhcp_dns as $dn => $cn){
+ $ldap->cd($dn);
+ $ldap->search("(|(objectClass=dhcpService)(objectClass=dhcpGroup)".
+ "(objectClass=dhcpSubnet)(objectClass=dhcpSharedNetwork))",array("cn"));
+ $tmp = array();
+ while($attr = $ldap->fetch()){
+ $tmp[$attr['dn']] = $attr['cn'][0];
+ }
+ $tmp2 = $this->create_tree($tmp,preg_replace("/^[^,]+,/i","",$dn),"(".$cn.") ");
+ }
+ $ret = array();
+ foreach($tmp2 as $key => $label){
+ $ret[$tmp[$key]] = $label;
+ }
+ return($ret);
+ }
+
/* check given values */
function check()
function save_object()
{
if(isset($_POST['goto_task_posted'])){
- plugin::save_object();
+
+ if(isset($_POST['configure_dns'])){
+ $this->configure_dns = TRUE;
+ if(isset($_POST['Zone'])){
+ $this->Zone = get_post("Zone");
+ }
+ }else{
+ $this->configure_dns = FALSE;
+ }
+
+ if(isset($_POST['configure_dhcp'])){
+ $this->configure_dhcp = TRUE;
+ if(isset($_POST['Section'])){
+ $this->Section = get_post("Section");
+ }
+ }else{
+ $this->configure_dhcp = FALSE;
+ }
+
foreach($this->attributes as $attr){
if(in_array($attr,array("Initial_Target","Target"))){
continue;
diff --git a/plugins/addons/gotomasses/class_gotomasses.inc b/plugins/addons/gotomasses/class_gotomasses.inc
index fcbb929d30e387aea892d21862072d54f15f3b12..037ac99b6b9b2b0038bd569f31ff42d4e20521ea 100644 (file)
var $dialog = FALSE;
var $ids_to_remove = array();
+
function gotomasses($config, $dn= NULL)
{
/* Include config object */
$tmp2 = split(";",$parts[7]);
foreach($tmp2 as $target){
$tmp = split(",",$target);
- $entry['Initial_Target'][] = array("MAC" => $tmp[0],"IP"=>$tmp[1],"NAME" => $tmp[2]);
+ $entry['Initial_Target'][] = array(
+ "MAC" => $tmp[0],
+ "IP" => $tmp[1],
+ "NAME" => $tmp[2],
+ "ZONE" => $tmp[3],
+ "SECTION" => $tmp[4]);
}
$entry['Target'] = array();
}else{
$str .= str_pad($task['OGroup'] ,5," ")." ";
if($task['Action'] == "initial_install"){
foreach($task['Initial_Target'] as $target){
- $str .= trim($target['MAC']).",".trim($target['IP']).",".trim($target['NAME']).";";
+ $str .= trim($target['MAC']).",".trim($target['IP']).",".trim($target['NAME']).",".
+ trim($target['ZONE']).",".trim($target['SECTION']).";";
}
}else{
foreach($task['Target'] as $target){
index ca020d3a44755fe6786fcb1c80ab7577d9e1975a..248fe965ba56a5050ac9ecc4241b52239538dbd0 100644 (file)
<input type="submit" name="add_target" value="{t}Add{/t}">
</td>
</tr>
+ <tr>
+ <td><input class='center' {if $configure_dns} checked {/if} id='configure_dns'
+ type='checkbox' name='configure_dns' value='1' >
+ <label for='configure_dns'>{t}Configure DNS{/t}</label>
+ </td>
+ <td>
+ <select name="Zone">
+ {html_options options=$Zones selected=$Zone}
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td><input class='center' {if $configure_dhcp} checked {/if} id='configure_dhcp'
+ type='checkbox' name='configure_dhcp' value='1' >
+ <label for='configure_dhcp'>{t}Configure DHCP{/t}</label>
+ </td>
+ <td>
+ <select name="Section">
+ {html_options options=$Sections selected=$Section}
+ </select>
+ </td>
+ </tr>
</table>
</td>
<td>
index 6a932ef38b3ce1758edd15fcaa53653d23bac0fc..154eac38fe108a95d5d6aaa107d784cad56afe01 100644 (file)
$smarty->assign("dhcpParentNodes",$this->dhcpParentNodes);
-
-
-
-
/* There is no dns available
*/
if($this->DNSenabled == false){