Author: jfthomps
Date: Thu Sep 29 20:28:55 2011
New Revision: 1177420

URL: http://svn.apache.org/viewvc?rev=1177420&view=rev
Log:
VCL-342
problem selecting image revision id when making a cluster reservation with 
identical subimages

requests.php - modified submitRequest:
-print name of input radio button for image revision selection as 
revisionid[$subimage][$cnt] instead of just revisionid[$subimage]
-set $data['revisionid'] to be $_POST['revisionid'] and added appropriate 
validation check
-changed any checks of $data['revisionid'][$imagei] to account for it being an 
array

utils.php: modified addRequest - when getting $imagerevisionid from 
$revisionid, call array_shift on $revisionid[$imageid] instead of just 
referencing it directly

Modified:
    incubator/vcl/trunk/web/.ht-inc/requests.php
    incubator/vcl/trunk/web/.ht-inc/utils.php

Modified: incubator/vcl/trunk/web/.ht-inc/requests.php
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/requests.php?rev=1177420&r1=1177419&r2=1177420&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/requests.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/requests.php Thu Sep 29 20:28:55 2011
@@ -486,12 +486,16 @@ function submitRequest() {
 
        if($mode == 'submitTestProd') {
                $data = getContinuationVar();
-               $data["revisionid"] = processInputVar("revisionid", 
ARG_MULTINUMERIC);
+               $data["revisionid"] = $_POST['revisionid'];
                # TODO check for valid revisionids for each image
                if(! empty($data["revisionid"])) {
-                       foreach($data['revisionid'] as $key => $val) {
-                               if(! is_numeric($val) || $val < 0)
-                                       unset($data['revisionid']);
+                       foreach($data['revisionid'] as $val) {
+                               foreach($val as $val2) {
+                                       if(! is_numeric($val2) || $val2 < 0) {
+                                               unset($data['revisionid']);
+                                               break 2; // TODO make sure this 
breaks as far as needed
+                                       }
+                               }
                        }
                }
        }
@@ -602,8 +606,10 @@ function submitRequest() {
                abort(3);
 
        if(array_key_exists('revisionid', $data) &&
-               array_key_exists($data['imageid'], $data['revisionid']))
-               $revisionid = $data['revisionid'][$data['imageid']];
+          array_key_exists($data['imageid'], $data['revisionid']) &&
+          array_key_exists(0, $data['revisionid'][$data['imageid']])) {
+               $revisionid = $data['revisionid'][$data['imageid']][0];
+       }
        else
                $revisionid = getProductionRevisionid($data['imageid']);
        $availablerc = isAvailable($images, $data["imageid"], $revisionid, 
$start,
@@ -664,6 +670,7 @@ function submitRequest() {
                if(! array_key_exists('subimages', $images[$data['imageid']]))
                        $images[$data['imageid']]['subimages'] = array();
                array_unshift($images[$data['imageid']]['subimages'], 
$data['imageid']);
+               $cnt = 0;
                foreach($images[$data['imageid']]['subimages'] as $subimage) {
                        print "{$images[$subimage]['prettyname']}:<br>\n";
                        print "<table summary=\"lists versions of the selected 
environment, one must be selected to continue\">\n";
@@ -676,13 +683,15 @@ function submitRequest() {
                        print "  </TR>\n";
                        foreach($images[$subimage]['imagerevision'] as 
$revision) {
                                print "  <TR>\n";
-                               if(array_key_exists($subimage, 
$data['revisionid']) && 
-                                  $data['revisionid'][$subimage] == 
$revision['id'])
-                                       print "    <TD align=center><INPUT 
type=radio name=revisionid[$subimage] value={$revision['id']} checked></TD>\n";
-                               elseif($revision['production'])
-                                       print "    <TD align=center><INPUT 
type=radio name=revisionid[$subimage] value={$revision['id']} checked></TD>\n";
+                               // if revision was selected or it wasn't 
selected but it is the production revision, show checked
+                               if((array_key_exists('revisionid', $data) &&
+                                  array_key_exists($subimage, 
$data['revisionid']) &&
+                                       array_key_exists($cnt, 
$data['revisionid'][$subimage]) &&
+                                  $data['revisionid'][$subimage][$cnt] == 
$revisionid['id']) ||
+                                  $revision['production'])
+                                       print "    <TD align=center><INPUT 
type=radio name=revisionid[$subimage][$cnt] value={$revision['id']} 
checked></TD>\n";
                                else
-                                       print "    <TD align=center><INPUT 
type=radio name=revisionid[$subimage] value={$revision['id']}></TD>\n";
+                                       print "    <TD align=center><INPUT 
type=radio name=revisionid[$subimage][$cnt] value={$revision['id']}></TD>\n";
                                print "    <TD 
align=center>{$revision['revision']}</TD>\n";
                                print "    <TD 
align=center>{$revision['user']}</TD>\n";
                                print "    <TD 
align=center>{$revision['prettydate']}</TD>\n";
@@ -693,6 +702,7 @@ function submitRequest() {
                                print "  </TR>\n";
                        }
                        print "</table>\n";
+                       $cnt++;
                }
                $cont = addContinuationsEntry('submitTestProd', $data);
                print "<br><INPUT type=hidden name=continuation 
value=\"$cont\">\n";

Modified: incubator/vcl/trunk/web/.ht-inc/utils.php
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/utils.php?rev=1177420&r1=1177419&r2=1177420&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/utils.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/utils.php Thu Sep 29 20:28:55 2011
@@ -4459,7 +4459,7 @@ function addRequest($forimaging=0, $revi
        foreach($requestInfo["images"] as $key => $imageid) {
                if(array_key_exists($imageid, $revisionid) &&
                   ! empty($revisionid[$imageid]))
-                       $imagerevisionid = $revisionid[$imageid];
+                       $imagerevisionid = array_shift($revisionid[$imageid]);
                else
                        $imagerevisionid = getProductionRevisionid($imageid);
                $computerid = $requestInfo["computers"][$key];


Reply via email to