Code

Updated DNS lists
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 13 Apr 2010 09:47:50 +0000 (09:47 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 13 Apr 2010 09:47:50 +0000 (09:47 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@17604 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/dns/admin/systems/services/dns/class_servDNS.inc
gosa-plugins/dns/admin/systems/services/dns/class_servDNSeditZone.inc

index 8591519a2c73fa16bd1e7e560388bac4af2a967b..43f87152723de4dd938277f801e454ad5f1f25f7 100644 (file)
@@ -49,6 +49,16 @@ class servdns extends goService
       $this->is_account = true;
     }
     $this->initially_was_account = $this->is_account;
+
+    // Prepare lists
+    $this->zoneList = new sortableListing();
+    $this->zoneList->setDeleteable(true);
+    $this->zoneList->setEditable(true);
+    $this->zoneList->setWidth("100%");
+    $this->zoneList->setHeight("300px");
+    $this->zoneList->setHeader(array(_("Zone"),_("Reverse zone"),_("TTL"),_("Class")));
+    $this->zoneList->setColspecs(array('*','*','*','*','40px'));
+    $this->zoneList->setDefaultSortColumn(0);
   }
 
 
@@ -203,49 +213,19 @@ class servdns extends goService
 
     /* Check for edit zone request 
      */
-    $once = false;
-    foreach( $_POST as $name => $value){
-  
-      /* check all post for edit request 
-       */
-      if(preg_match("/^editZone_/",$name)&&!$once){
-        $once =true;
-        $tmp = postDecode(preg_replace("/^editZone_/","",$name));
-        $this->dialog= new servdnseditZone($this->config,$this->dn,$this->Zones[$tmp]);
-        $this->dialog->acl_base = $this->acl_base;
-        $this->dialog->acl_category = $this->acl_category;
-      }
-
-      /* check posts for delete zone 
-       */
-      if(preg_match("/^delZone_/",$name)&&!$once){
-
-        $once =true;
-        $tmp = postDecode(preg_replace("/^delZone_/","",$name));
-     
-        /* Initiate deletion
-         */ 
-        $this->RemoveZone($tmp); 
-      }
-    }
-
-    if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id'])){
-      $id = postDecode($_GET['id']);
-      if(isset($this->Zones[$id])){
+    $this->zoneList->save_object();
+    $action = $this->zoneList->getAction();
+    if($action['action'] == 'delete'){
+        $id = $this->zoneList->getKey($action['targets'][0]);
+        $this->RemoveZone($id);
+    }
+    if($action['action'] == 'edit'){
+        $id = $this->zoneList->getKey($action['targets'][0]);
         $this->dialog= new servdnseditZone($this->config,$this->dn,$this->Zones[$id]);
         $this->dialog->acl_base = $this->acl_base;
         $this->dialog->acl_category = $this->acl_category;
-      }
     }
 
-    if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id'])){
-      $id = postDecode($_GET['id']);
-      if(isset($this->Zones[$id])){
-         $this->dialog= new servdnseditZone($this->config,$this->dn,$this->Zones[$id]);
-         $this->dialog->acl_base = $this->acl_base;
-         $this->dialog->acl_category = $this->acl_category;
-      }
-    }
 
     /* Show dialog 
      */
@@ -257,30 +237,18 @@ class servdns extends goService
 
     /* Create Listbox with existing Zones 
      */
-    $ZoneList = new divSelectBox("dNSZones");
-    $ZoneList -> SetHeight(254);
-
-    /* Add entries to divlist
-     */
-    $editImg = image('images/lists/edit.png','editZone_%s');
-    if($this->acl_is_removeable()){
-      $editImg.= image('images/lists/trash.png','delZone_%s');
-    }
+    $this->zoneList->setAcl($this->getacl(""));
 
-    $link = "<a href='?plug=".$_GET['plug']."&amp;act=edit&amp;id=%s'>%s</a>";
+    $lData = array();
     foreach($this->Zones as $zone => $values ){
-      $ZoneList->AddEntry(array(
-            array("string" => sprintf($link,postEncode($zone),($zone))),
-            array("string" => sprintf($link,postEncode($zone),_("Reverse zone")." : ".($values['ReverseZone']))),
-            array("string" => _("TTL")." : ".$values['sOAttl']),
-            array("string" => _("Class")." : ".$values['dNSClass']),
-            array("string" =>str_replace("%s",postEncode($zone),$editImg))
-            ));
+      $lData[$zone] = array('data' => array($zone,$values['ReverseZone'],$values['sOAttl'],$values['dNSClass']));
     }    
+    $this->zoneList->setListData($this->Zones,$lData);
+    $this->zoneList->update();
 
     /* Display tempalte 
      */
-    $smarty->assign("ZoneList",$ZoneList->DrawList());
+    $smarty->assign("ZoneList",$this->zoneList->render());
     $display.= $smarty->fetch(get_template_path('servdns.tpl', TRUE, dirname(__FILE__)));
     return($display);
   }
index 6ac624fa4eef938e7104edf536fee0297aeb5c77..65e75c9191129446e99464abe4299b9a72eb6407 100644 (file)
@@ -135,6 +135,18 @@ class servdnseditZone extends plugin
         $this->ReverseZone .= ".0"; 
       }
     }
+
+    // Prepare lists
+    $this->mxList = new sortableListing(array(),array(), TRUE);
+    $this->mxList->setDeleteable(true);
+    $this->mxList->setInstantDelete(true);
+    $this->mxList->setEditable(false);
+    $this->mxList->setWidth("100%");
+    $this->mxList->setHeight("100px");
+    $this->mxList->setHeader(array(_("Record")));
+    $this->mxList->setColspecs(array('*','20px'));
+    $this->mxList->setDefaultSortColumn(0);
+
   }
 
   /* TRansports the geiven Arraykey one position up*/
@@ -209,6 +221,7 @@ class servdnseditZone extends plugin
 
     /* Fill templating stuff */
     $smarty= get_smarty();
+    $smarty->assign("usePrototype", "true");
     $smarty->assign("Zone_is_used",$this->Zone_is_used);
     $ui = get_userinfo();
 
@@ -273,32 +286,11 @@ class servdnseditZone extends plugin
       return($this->dialog->execute());
     }
 
-    $once =true;
-    foreach($_POST as $name => $value){
-      if((preg_match("/^MXup_/",$name)) && ($once)){
-        $once = false;
-        $id = preg_replace("/^MXup_/","",$name);
-        $id = postDecode($id);
-        $this->mXRecords = $this->ArrayUp(($id+1),$this->mXRecords);
-      }
-      if((preg_match("/^MXdown_/",$name)) && ($once)){
-        $once = false;
-        $id = preg_replace("/^MXdown_/","",$name);
-        $id = postDecode($id);
-        $this->mXRecords = $this->ArrayDown(($id+1),$this->mXRecords);
-      }
-      if((preg_match("/^MXdel_/",$name)) && ($once)){
-        $once = false;
-        $id = preg_replace("/^MXdel_/","",$name);
-        $id = postDecode($id);
-        unset($this->mXRecords[$id]);
-        $tmp  =array();
-        foreach($this->mXRecords as $entry){
-          $tmp[] = $entry;
-        }
-        $this->mXRecords = $tmp; 
-      }
+
+    $this->mxList->save_object();
+    $action = $this->mxList->getAction();
+    if($action['action'] == 'delete' || $action['action'] == 'reorder'){
+        $this->mXRecords = $this->mxList->getMaintainedData();
     }
 
     if($this->parent->acl_is_writeable("mXRecord")){
@@ -330,25 +322,17 @@ class servdnseditZone extends plugin
     }
 
 
-    $div = new divSelectBox("MxRecords");
-    $div->setHeight(120);
-    $recs = $this->mXRecords;
-
-    $oneup   = image('images/lists/sort-up.png','MXup_%s',_("Up"),"top");
-    $onedown = image('images/lists/sort-down.png','MXdown_%s',_("Down"),"bottom");
-    $onedel  = image('images/lists/trash.png','MXdel_%s',_("Delete"));
-
-    foreach($recs as $key => $rec){
-      $div ->AddEntry(array(
-            array("string"=>$rec['value']),
-            array("string"=>str_replace("%s",postEncode($key),$oneup.$onedown.$onedel),
-                  "attach"=>"style='width:70px;border-right:0px;'")
-            ));
+    $this->mxList->setAcl($this->parent->getacl("mXRecord"));
+    $lData = array();
+    foreach($this->mXRecords as $key => $record){
+        $lData[$key] = array('data'=>array($record['value']));
     }
+    $this->mxList->setListData($this->mXRecords, $lData);
+    $this->mxList->update();
 
     /* Assign records list */
     $smarty->assign("NotNew", false);
-    $smarty->assign("Mxrecords",  $div->DrawList());
+    $smarty->assign("Mxrecords",  $this->mxList->render());
     $smarty->assign("records"  ,  $this->generateRecordsList());
     $smarty->assign("NetworkClass",  $this->NetworkClass);
     $smarty->assign("NetworkClasses",  array("A"=>"255.0.0.0 (Class A)","B"=>"255.255.0.0 (Class B)","C"=>"255.255.255.0 (Class C)"));