Active
Project:
User Quota
Version:
6.x-1.0-beta1
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
31 Dec 2008 at 12:10 UTC
Updated:
8 Nov 2010 at 19:21 UTC
Hi
Currently, if no quota has been set for a user, he has unlimited quotas, because there is no entry in the database yet.
When quotas are given, he has x amount and an entry is made in the database.
When he used up his quota, he blocked as he now have an entry in the database with 0 quotas.
There is no way that a user can be given unlimited quotas again, unless the entry in the database is deleted (currently manually).
I'm busy making some add ons to this module for use on a web page, which I will share when I'm done.
I want to propose the following:
All users with no set quotas (no db entries) are blocked.
Users with say +1000 quotas are unlimited
function user_quota_get_limit($type, $user = FALSE) {
if (!$user) {
global $user;
}
$limit = db_result(db_query("SELECT current_limit FROM {user_quota} WHERE uid = %d AND type = '%s'", $user->uid, $type));
if (is_numeric($limit)) {
if ($limit >= 1000) {
return 'unlimited'
}
else {
return $limit;
}
else {
return 0;
}
}
Your thoughts?
Comments
Comment #1
Max_Headroom commentedcode error in previous listing:
Comment #2
gregglesThis is a potential problem with the module.
I don't really like this solution much :/
Here are the potential solutions I can think of:
1. We make it admin configurable whether users without a record are blocked or not.
2. We change the quota column to a varchar and either store a number, in which case they are limited, or we store the word unlimited in which case they are unlimited...
Thoughts?
Comment #3
Max_Headroom commentedActually me neither ;)
I would suggest creating a status column, where you can set a users' status to Blocked, Active, Unlimited. That way you have more control without affecting a users quota.
Comment #4
gregglesYeah, a new status column sounds good to me.
Unlimited makes sense. But why do we need "blocked" and "active"? Why not just "limited/unlimited" as the two options?