Author: jfthomps
Date: Wed Oct 26 14:39:30 2011
New Revision: 1189245

URL: http://svn.apache.org/viewvc?rev=1189245&view=rev
Log:
VCL-509
error when adding computer with no groups selected

modified addComputer - check to see if $data['computergorup'] is empty before 
doing insert into resourcegroupmembers

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

Modified: incubator/vcl/trunk/web/.ht-inc/computers.php
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/computers.php?rev=1189245&r1=1189244&r2=1189245&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/computers.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/computers.php Wed Oct 26 14:39:30 2011
@@ -3582,15 +3582,17 @@ function addComputer($data) {
        $resid = dbLastInsertID();
 
        // add computer into selected groups
-       $vals = array();
-       foreach(array_keys($data['computergroup']) as $groupid)
-               $vals[] = "($resid, $groupid)";
-       $allvals = implode(',', $vals);
-       $query = "INSERT INTO resourcegroupmembers "
-              .        "(resourceid, "
-              .        "resourcegroupid) "
-              . "VALUES $allvals";
-       doQuery($query, 101);
+       if(! empty($data['computergroup'])) {
+               $vals = array();
+               foreach(array_keys($data['computergroup']) as $groupid)
+                       $vals[] = "($resid, $groupid)";
+               $allvals = implode(',', $vals);
+               $query = "INSERT INTO resourcegroupmembers "
+                      .        "(resourceid, "
+                      .        "resourcegroupid) "
+                      . "VALUES $allvals";
+               doQuery($query, 101);
+       }
 
        if($data['stateid'] == 20) {
                $profileid = processInputVar('profileid', ARG_NUMERIC);


Reply via email to