Code

Added checks to avoid overwriting releases
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 20 Apr 2011 14:15:40 +0000 (14:15 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 20 Apr 2011 14:15:40 +0000 (14:15 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20759 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto-ng/admin/newConfigManagement/class_newConfigManagement.inc
gosa-plugins/goto-ng/admin/newConfigManagement/goto/Config/root.tpl

index b16916f93d1532208a1af70851c343b5c50609bc..7c38705c922227f6268a0b9d3bcc4eafe59d1f0d 100644 (file)
@@ -165,6 +165,7 @@ class newConfigManagement extends plugin
         // Load distributions 
         $rpc = $this->config->getRpcHandle();
         $res = $rpc->getDistributions();
+        print_a($res);
         if(!$rpc->success()){
             $this->errorMessage = sprintf(_("Failed to load distributions: %s"), $rpc->get_error());
             return(FALSE);
@@ -699,6 +700,12 @@ class newConfigManagement extends plugin
 
             // We've to create a new distribution
             if($type == 'Distribution'){
+                
+                // Distributions cannot be renamed!
+                if(isset($item['name']) && $item['name'] != $values['name']){
+                    msg_dialog::displayChecks(array("Distributions cannot be renamed!"));
+                    return;
+                }
                 $name = $values['name'];
                 $itype = $values['installation_type'];
                 $imethod = $values['installation_method'];
@@ -707,13 +714,27 @@ class newConfigManagement extends plugin
                 // Initiate the rpc request.
                 $rpc = $this->config->getRpcHandle();
                 $res = $rpc->createDistribution($name, $itype, array('mirror'=>$origin, 'install_method' => $imethod));
+                print_a(array($name, $itype, array('mirror'=>$origin, 'install_method' => $imethod)));
                 if(!$rpc->success()){
                     msg_dialog::display(_("Error"), sprintf(_("Failed to save distributions: %s"), $rpc->get_error()),ERROR_DIALOG);
                     return(NULL);
                 }else{
 
+                    // Set mirror properties
+                    $data = array();
+                    $data['distribution'] = $name;
+                    $data['arch'] = $values['architectures'];
+                    $data['component'] = $values['components'];
+                    $data['mirror_sources'] = $values['mirror_sources'];
+                    $rpc->addMirrorProperty($data);
+                    if(!$rpc->success()){
+                        msg_dialog::display(_("Error"), sprintf(_("Failed to save distributions: %s"), 
+                                    $rpc->get_error()),ERROR_DIALOG);
+                        return(NULL);
+                    }
+
                     // We've successfully added the item, now add it to the tree.
-                    $this->dataModel->addItem($type, $this->selectedContainer, $values['name'],array(), '-' );
+                    $this->dataModel->addItem($type, $this->selectedContainer, $values['name'],$values, '-' );
 
                     // Finally - close the dialog. 
                     $this->listing->clearDialogObject();
@@ -735,6 +756,11 @@ class newConfigManagement extends plugin
                 $dist = $this->getDistributionPath($this->selectedContainer);
                 $dist = preg_replace("#^/root/#", "", $dist);
 
+                if(isset($item['name']) && $item['name'] != $values['name']){
+                    echo "Implement rename for releases";
+                    return;
+                }
+    
                 // Initiate the rpc request.
                 $rpc = $this->config->getRpcHandle();
                 $res = $rpc->createRelease($dist, $newPath);
index 0e0db6f4bd9c2ce6be93d25353f9df50e4c9251f..839a4c69b22e4bc489c222e023519db6e6ab522a 100644 (file)
@@ -1,6 +1,6 @@
 {if $type == 'Distribution'}
 
-<table>
+<table width="100%">
     <tr>
         <td style='width: 50%'>
             <table>
@@ -8,6 +8,10 @@
                     <td>{$nameName}</td>
                     <td>{$name}</td>
                 </tr>
+                <tr>
+                    <td>{$originName}</td>
+                    <td>{$origin}</td>
+                </tr>
                 <tr>
                     <td>{$installation_typeName}</td>
                     <td>{$installation_type}</td>
                     <td>{$installation_method}</td>
                 </tr>
                 <tr>
-                    <td>{$originName}</td>
-                    <td>{$origin}</td>
+                    <td>{$mirror_sourcesName}</td>
+                    <td>{$mirror_sources}</td>
                 </tr>
             </table>
         </td>
-        <td>
+        <td class="left-border">
+        </td><td>
             <table>
                 <tr>
                     <td>{$architecturesName}</td>
                     <td>{$componentsName}</td>
                     <td>{$components}</td>
                 </tr>
-                <tr>
-                    <td>{$mirror_sourcesName}</td>
-                    <td>{$mirror_sources}</td>
-                </tr>
             </table>
         </td>
     </tr>