You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@vcl.apache.org by Jeremy Cole <ja...@ncsu.edu> on 2011/06/24 01:12:23 UTC

VCL 2.2.1 - Block Allocation Request Issue

Hey all, I found an issue with block allocation requests (creating and
modifying allocations works fine). Maybe it has been addressed, or maybe
it's just me, but I'll describe it anyway.

If you request a block allocation without specifying a user group, you'll be
receive an Ajax error that looks similar to:

    AJAX Error: missing ; before statement
    Line 58 in https://www.foobar.com/js/blockallocations.js

This error corresponds to the eval() function that is being called in
generalReqCB() of blockallocations.js. The error is being generated because
of a mysql query that could have invalid syntax. You'll find this query in
the AJblockAllocationSubmit() function located in blockallocations.php
(~Line 706) . This is the query:

 $query = "INSERT INTO blockRequest "
                       .        "(name, "
                       .        "imageid, "
                       .        "numMachines, "
                       .        "groupid, "
                       .        "repeating, "
                       .        "ownerid, "
                       .        "admingroupid, "
                       .        "expireTime, "
                       .        "status, "
                       .        "comments) "
                       . "VALUES "
                       .        "('(awaiting approval)', "
                       .        "{$data['imageid']}, "
                       .        "{$data['seats']}, "
                       .        "{$data['groupid']}, " <---This value causes
issues
                       .        "'{$data['type']}', "
                       .        "{$user['id']}, "
                       .        "0, "
                       .        "'{$data['expiretime']}', "
                       .        "'requested', "
                       .        "'$esccomments')";

In the situation where a user doesn't specify a user group for their block
allocation request, groupid will be equal to zero. This caused issues for me
because 0 isn't a valid ID for a user group. To correct the problem, I added
the following if-statement to the end of processBlockAllocation() function,
also located in blockallocations.php. The statement is:

    if(!$return['groupid'])
        $return['groupid'] = 3; #If no user group is specified...
temporarily set owning user group to AdminUsers@Local (3 is the default
group ID for this user group)

This statement will set the user group for a block allocation if a user
doesn't specify it. My reasoning is that the admin who accepts the block
request can change the user group to whatever it needs to be.



-- 
Jeremy Cole
North Carolina State University
Electrical Engineering, Graduate Student