From: hickert Date: Fri, 24 Aug 2007 09:51:13 +0000 (+0000) Subject: Updated gotomasses in trunk X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6a7abdb1bf15c7fa155b0554610c1de806a574f1;p=gosa.git Updated gotomasses in trunk git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7129 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/addons/gotomasses/class_goto_task.inc b/plugins/addons/gotomasses/class_goto_task.inc index 19e018d87..b905318ff 100644 --- a/plugins/addons/gotomasses/class_goto_task.inc +++ b/plugins/addons/gotomasses/class_goto_task.inc @@ -14,6 +14,13 @@ class goto_task extends plugin 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(); @@ -21,8 +28,10 @@ class goto_task extends plugin var $Initial_Target = array(); var $Actions = array(); var $new = FALSE; - var $attributes = array("OGroup","Minute","Hour","Day","Month","Weekday","Action","Comment","Target","Initial_Target"); + var $attributes = array("Zone","Section","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()) { @@ -32,7 +41,6 @@ class goto_task extends plugin /* Intialize plugin */ $this->config = $config; if(count($data)){ - $tmp = $this->get_array_values(); foreach($this->attributes as $attr){ if(!isset($data[$attr])){ @@ -45,6 +53,20 @@ class goto_task extends plugin $this->new = TRUE; } + if(!empty($this->Zone) && !preg_match("/^\"\"$/",$this->Zone)){ + $this->configure_dns = TRUE; + } + if(!empty($this->Section) && !preg_match("/^\"\"$/",$this->Section)){ + $this->configure_dhcp = 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()); @@ -88,12 +110,20 @@ class goto_task extends plugin $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); } @@ -110,15 +140,15 @@ class goto_task extends plugin $line = fgets($fp,512); $tmp = preg_split("/(,|;)/",$line); - $MAC = $IP = $NAME = ""; + $MAC = $IP = $NAME; 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(is_mac($MAC)){ $this->Initial_Target[] = array("MAC"=>$MAC,"IP"=>$IP,"NAME"=>$NAME); @@ -177,14 +207,14 @@ class goto_task extends plugin /* 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" => _("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;'"); + $field3 = array("string" => $target['NAME'] ,"attach" => "style='width:150px;'"); $divlist->AddEntry(array($field1,$field2,$field3,preg_replace("/%KEY%/",$key,$field_del))); } }else{ @@ -203,6 +233,15 @@ class goto_task extends plugin $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']); @@ -217,6 +256,62 @@ class goto_task extends plugin 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() @@ -234,10 +329,10 @@ class goto_task extends plugin } } if(count($this->Target) == 0 && $this->Action != "initial_install"){ - $message[] = sprintf(_("You must specify at least one traget")); + $message[] = sprintf(_("You must specify at least one target")); } if(count($this->Initial_Target) == 0 && $this->Action == "initial_install"){ - $message[] = sprintf(_("You must specify at least one traget")); + $message[] = sprintf(_("You must specify at least one target")); } return($message); } @@ -254,10 +349,30 @@ class goto_task extends plugin { 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->Zone = "\"\""; + $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; + $this->Section = "\"\""; + } } } - + /* Check if given target is vald. * It must either be a valid MAC address or an existing object group */ @@ -281,6 +396,12 @@ class goto_task extends plugin foreach($this->attributes as $attr){ $tmp[$attr] = $this->$attr; } + if(!$this->configure_dns){ + $tmp['Zone'] = "\"\""; + } + if(!$this->configure_dhcp){ + $tmp['Section'] = "\"\""; + } return($tmp); } diff --git a/plugins/addons/gotomasses/class_target_list.inc b/plugins/addons/gotomasses/class_target_list.inc index 4c1e79e72..248f59428 100644 --- a/plugins/addons/gotomasses/class_target_list.inc +++ b/plugins/addons/gotomasses/class_target_list.inc @@ -45,7 +45,7 @@ class target_list extends MultiSelectWindow $this->AddHeader(array("string" => _("Object name"), "attach" => "style=''")); /* Text ,Value, Name, Is selected */ - $this->AddCheckBox("ogroups", _("Select to see object groups"), _("Show object object groups"), true); + $this->AddCheckBox("ogroups", _("Select to see object groups"), _("Show object groups"), true); $this->AddCheckBox("servers", _("Select to see servers") , _("Show servers"), true); $this->AddCheckBox("workstations", _("Select to see workstations"),_("Show workstations"), true); diff --git a/plugins/addons/gotomasses/goto_task.tpl b/plugins/addons/gotomasses/goto_task.tpl index 9de2a0c63..799d910b3 100644 --- a/plugins/addons/gotomasses/goto_task.tpl +++ b/plugins/addons/gotomasses/goto_task.tpl @@ -29,6 +29,50 @@ {/render} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -63,7 +107,7 @@ - +
{render acl=$TargetACL} @@ -100,7 +144,7 @@
- +
{t}CVS import from file{/t}