Code

- Correcting spelling
[gosa.git] / plugins / admin / systems / class_servDHCP.inc
index ce22ef93a121ed058529c2dbe1a3bc1f0a1e3d2e..d883bf4ae9173537b704eee070159493f9c8463d 100644 (file)
@@ -19,8 +19,9 @@ class servdhcp extends plugin
 
   var $orig_dn = "";
 
-  var $dhcp_server_list   = array();
+  var $dhcp_server_list   = array("ENTRIES"=> array(),"FOR_LIST"=> array());
   var $take_over_id       = -1;
+  var $display_warning  = TRUE;
 
   function servdhcp ($config, $dn= NULL, $parent= NULL)
   {
@@ -50,18 +51,11 @@ class servdhcp extends plugin
     $this->reload(); 
     if (!count($this->dhcpSections)){
       $this->is_account= FALSE;
+      $this->dhcp_server_list = $this->get_list_of_dhcp_servers();
     }
-               
-    $this->dhcp_server_list = $this->get_list_of_dhcp_servers();
   }
 
   
-  function take_over_service()
-  {
-    
-  }
-
-
   function get_list_of_dhcp_servers()
   {
     $ret = array("ENTRIES"=> array(),"FOR_LIST"=> array());
@@ -84,20 +78,6 @@ class servdhcp extends plugin
   }  
 
 
-  function get_dhcp_info_string($id)
-  {
-    $ret = "";
-    $ldap = $this->config->get_ldap_link();
-    $ldap->cd("cn=dhcp,".$this->dhcp_server_list['ENTRIES'][$id]['dn']);
-    $ldap->search("(|(objectClass=dhcpSharedNetwork)(objectClass=dhcpSubnet)(objectClass=dhcpPool)(objectClass=dhcpGroup)(objectClass=dhcpHost))",array("dn","cn"));
-    $ldap->search("(objectClass=*)",array("dn","cn"));
-    while($attrs = $ldap->fetch()){
-      $ret .= $attrs['dn']."\n";
-    }
-    return($ret);
-  }
-
-
   function execute()
   {
     /* Call parent execute */
@@ -138,13 +118,15 @@ class servdhcp extends plugin
     if($this->take_over_id != -1){
       $this->dialog = FALSE;
       $id = $this->take_over_id;
-      $info = $this->get_dhcp_info_string($id);
       $smarty->assign("dns_take_over",TRUE);
-      $smarty->assign("info",$info);
-      $warning = sprintf(_("You are going to take over the dhcp setup from server '%s'."),$this->dhcp_server_list['ENTRIES'][$id]['cn'][0]);
-      $warning2 = _("The take over will be startet when you save this system. To abort this action, use the cancel button below."); 
-      $smarty->assign("warning",$warning);
-      $smarty->assign("warning2",$warning2);
+
+     $warning = sprintf(_("You are going to migrate the DHCP setup from server '%s'."),$this->dhcp_server_list['ENTRIES'][$id]['cn'][0]);
+     $warning.= " "._("The migration will be started when you save this system. To cancel this action, use the cancel button below.");
+
+      if($this->display_warning){
+        print_red($warning);
+        $this->display_warning = FALSE;
+      }
       return($smarty->fetch(get_template_path('servdhcp.tpl', TRUE)));
     }
 
@@ -296,6 +278,16 @@ class servdhcp extends plugin
 
     }
 
+    if(isset($_GET['act']) && $_GET['act']=="edit" && isset($_GET['id'])){
+      $dn = base64_decode($_GET['id']);
+      if (isset($this->dhcpObjectCache[$dn])){
+        $section= $this->objectType($dn);
+        $this->current_object= $dn;
+        $this->dialog= new $section($this->dhcpObjectCache[$dn]);
+      }
+    }
+    
+
     /* Do we need to flip is_account state? */
     if (isset($_POST['modify_state'])){
       $this->is_account= !$this->is_account;
@@ -353,7 +345,9 @@ class servdhcp extends plugin
        
     $tmp = new dhcpNewSectionDialog(NULL);
     foreach($this->dhcpSections as $section => $values ){
-       
+    
+      $values = "<a href='?plug=".$_GET['plug']."&act=edit&id=".base64_encode($section)."'>".$values."</a>";
+       
       if (count($tmp->sectionMap[$this->objectType($section)])){
         if ($this->objectType($section) == "dhcpService"){
           $DhcpList->AddEntry(array(
@@ -529,6 +523,11 @@ class servdhcp extends plugin
       $this->dhcpServiceDN= preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$this->dhcpServiceDN);
     }
 
+    /* Replace 'new' dn */ 
+    if(preg_match("/new$/",$this->dhcpServiceDN)){
+      $this->dhcpServiceDN = preg_replace("/new$/",$this->dn,$this->dhcpServiceDN);
+    }
+
     plugin::save();
     
     /* Save data to LDAP */