ckp before redoing forms
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 5 Feb 2009 10:22:58 +0000 (10:22 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 5 Feb 2009 10:22:58 +0000 (10:22 +0000)
planetlab/includes/plc_functions.php
planetlab/nodes/node_add.php
planetlab/sites/site.php
planetlab/sites/site_update.php [moved from planetlab/sites/update_site.php with 83% similarity]

index ff4afd7..ea34b78 100644 (file)
@@ -64,7 +64,7 @@ function l_sites ()                   { return "/db/sites/index.php"; }
 function l_sites_peer ($peer_id)       { return "/db/sites/index.php?peerscope=$peer_id"; }
 function l_site ($site_id)             { return "/db/sites/index.php?id=$site_id"; }
 function l_site_t ($site_id,$text)     { return href (l_site($site_id),$text); }
-function l_site_update($site_id)       { return "/xxx-undefined"; }
+function l_site_update($site_id)       { return "/db/sites/site_update.php?site_id=$site_id"; }
 
 function l_slices ()                   { return "/db/slices/index.php"; }
 function l_slices_peer ($peer_id)      { return "/db/slices/index.php?peerscope=$peer_id"; }
@@ -73,7 +73,7 @@ function l_slice_t ($slice_id,$text)  { return href (l_slice($slice_id),$text); }
 function l_slice_add ()                        { return "/db/slices/add_slice.php"; }
 function l_slices_site($site_id)       { return "/db/slices/index.php?site_id=$site_id"; }
 // from an object
-function l_slice_text ($slice)         { return l_slice_t ($slice['slice_id'],$slice['name']); }
+function l_slice_obj ($slice)          { return l_slice_t ($slice['slice_id'],$slice['name']); }
 
 function l_sliver ($node_id,$slice_id) { return "/db/nodes/slivers.php?node_id=$node_id&slice_id=$slice_id"; }
 function l_sliver_t ($node_id,$slice_id,$text) { 
index b56cf1b..f0e5cc6 100644 (file)
@@ -199,7 +199,7 @@ value="<?php print($model); ?>" size="40" maxlength="256"></td>
 <table width="100%" cellspacing="0" cellpadding="4" border="0">
 
 <tr>
-<td valign='top' width="250">Addressing Method</td>
+<td valign='top' width="250">Addressing method</td>
 <td>
 <input type="radio" name="method" value="dhcp" onChange='updateStaticFields()'
 <?php if($method == 'dhcp') { echo "checked"; } ?>>DHCP 
@@ -209,7 +209,7 @@ value="<?php print($model); ?>" size="40" maxlength="256"></td>
 </tr>
 
 <tr> 
-<td valign='top'>IP Address</td>
+<td valign='top'>IP address</td>
 <td><input type="text" name="ip" value="<?php print($ip); ?>"></td>
 </tr>
 
@@ -225,7 +225,7 @@ value="<?php print($model); ?>" size="40" maxlength="256"></td>
 </tr>
 
 <tr> 
-<td valign='top'>Gateway Address</td>
+<td valign='top'>Gateway address</td>
 <td><input type="text" name="gateway" value="<?php print($gateway); ?>"></td>
 </tr>
 
index c4d64dc..7bb738e 100644 (file)
@@ -188,7 +188,7 @@ if ( $local_peer ) {
   if (count($slice_ids) >= $max_slices) $slice_text = plc_warning_text ($slice_text);
   plc_details_line("# Slices", href(l_slices_site($site_id),$slice_text));
   if ($slices) foreach ($slices as $slice)
-     plc_details_line($slice['instantiation'],l_slice_text($slice));
+     plc_details_line($slice['instantiation'],l_slice_obj($slice));
 
 
   // Addresses
similarity index 83%
rename from planetlab/sites/update_site.php
rename to planetlab/sites/site_update.php
index 9b0ef32..5bda0a9 100644 (file)
@@ -16,12 +16,12 @@ $_person= $plc->person;
 $_roles= $_person['role_ids'];
 
 // redirect if no site id is set add instead
-if( !$_GET['id'] )
-  $do= 'Add';
-else {
-  $site_id= $_GET['id'];
+if( $_GET['site_id'] ) {
+  $site_id= $_GET['site_id'];
   $do= 'Update';
-}
+ } else {
+  $do= 'Add';
+ }
 
 // if form not submitted get data from API
 if( $_POST['submitted'] ) {
@@ -59,14 +59,28 @@ if( $_POST['submitted'] ) {
   
   
   // if no errors add/update site
-  if( $do == 'Add' ) {
-    $fields= array( "name" => $name, "url" => $url, "longitude" => floatval( $longitude ), "login_base" => $login_base, "latitude" => floatval( $latitude ), "is_public" => true, "abbreviated_name" => $abbrev_name, "max_slices" => 0 );
-    $api->AddSite( $fields );
-    //echo "<pre>"; print_r( $fields ); echo "</pre>";
+  if ( $do == 'Add' ) {
+    $fields= array( "name" => $name, 
+                   "abbreviated_name" => $abbrev_name, 
+                   "url" => $url, 
+                   "login_base" => $login_base, 
+                   "latitude" => floatval( $latitude ), 
+                   "longitude" => floatval( $longitude ), 
+                   "max_slices" => 0,
+                   "is_public" => true);
+    $site_id=$api->AddSite( $fields );
+    plc_redirect(l_site($site_id));
   }
   
-  if( $do == 'Update' ) {
-    $fields= array( "name" => $name, "url" => $url, "longitude" => floatval( $longitude ), "login_base" => $login_base, "latitude" => floatval( $latitude ), "is_public" => true, "abbreviated_name" => $abbrev_name, "max_slices" => intval( $max_slices ) );
+  if ( $do == 'Update' ) {
+    $fields= array( "name" => $name, 
+                   "abbreviated_name" => $abbrev_name, 
+                   "url" => $url, 
+                   "login_base" => $login_base, 
+                   "latitude" => floatval( $latitude ), 
+                   "longitude" => floatval( $longitude ), 
+                   "max_slices" => intval( $max_slices ),
+                   "is_public" => true);
     $api->UpdateSite( intval( $site_id ), $fields );
     // Thierry aug 31 07 - redirect to the site's details page
     plc_redirect(l_site($site_id));
@@ -119,6 +133,9 @@ if( $error['max_slices'] )
   $max_err= " style='border: 1px solid red;'";
 
 // start form
+require_once 'plc_forms.php';
+
+plc_
 echo "<form action='update_site.php?id=$site_id' method='post'>\n";
 echo "<h2>$do $name</h2>\n";
 
@@ -138,11 +155,13 @@ else
 
 echo "<tr><td></td><td colspan=2><input type=submit name='submitted' value='$do Site'></td></tr>\n";
 echo "</tbody></table><br />\n";
-
-echo "<p><a href='index.php?id=$site_id'>Back to Site</a>\n";
-
 echo "</form>\n";
 
+if ($do == "Update")
+  print href(l_site($site_id),"Back to site");
+ else
+   print href(l_sites(),"Back to sites");
+
 
 // Print footer
 include 'plc_footer.php';