Managing user disk space I need a mechanism for managing users' storage space.  I have multiple content types with file upload fields.  Admin should be able to set it globally, or per individual user.

My initial approach is to add a field in the admin configuration menu, for admin to set the default limit, and a field for users for individual space allocations.

When a user goes to create new content, I check their used space to see if they are maxed out.  Then when they are about to upload a file, I'll check the file size and see if it will put the user over the limit.  If not, I let the upload occur.

The Drupal API gives us a file_space_used() function, which gives the total file space used by a particular user, so that's pretty cool.

Am I on the right track?

EDIT AFTER ANSWER: syd asked me to post my script, and I forgot.

function mymod_file_validate($file)
{
    global $user;
    $ulimit = 0;    // user limit


    // get the limits per role (I had two to check against, and vals are
    // in megabytes (hence the *1000000))
    if (array_search(HL_ROLE_REG, $user-&gt;roles))
        $ulimit = variable_get(HL_VARKEY_REGSPACE) * 1000000;

    if (array_search(HL_ROLE_PREM, $user-&gt;roles))
        $ulimit = variable_get(HL_VARKEY_PREMSPACE) * 1000000;

    return (file_validate_size($file, 0, $ulimit));
}
Drupal does all the work.

I made a call to file_validate_size() in my hook_file_validate() handler.  I also made an admin form to modify each role's allowable space (using variable_get/set), and it works great.

Next step is to create a table containing non-default values (keyed by uid), and an admin tool to set individual users' allowable space.  I'll then update my hook_file_validate() handler to check for the user in that table.  If not, then check the default.