5102 Posts in 1520 Topics by 1116 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 984 Views |
-
File upload quotas

16 December 2009 at 4:00am Last edited: 16 December 2009 4:02am
Hello all.
I'm looking to implement quotas that are given to individual users at the group level. I'm hoping someone would have some insight into the intricacies of this task.
My initial thoughts:
Create a DataObjectDecorator to extend the Group class
- Add a UserQuota field
- Add a userQuota() methodCreate a DataObjectDecorator to extend the File class
- Add a CreatedBy fieldCreate a DataObjectDecorator to extend the Member class
-Add a withinQuota() methodMy questions:
Will an Extension to the File class be inherited by other classes? Namely the Image class?
How can I set the CreatedBy field to the current user when files are uploaded?
Additionally, file uploads will need to check the member's withinQuota() method, how can this be accomplished?
Inside the withinQuota(), I will need to pull all Files owned by that user, how should this be done?Thank you in advance for any insight you can provide.
-
Re: File upload quotas

16 December 2009 at 9:22am Last edited: 16 December 2009 9:22am
Will an Extension to the File class be inherited by other classes? Namely the Image class?
Yes I believe it should be as long as no methods / field names clash with ones in Image.
How can I set the CreatedBy field to the current user when files are uploaded?
Files already have a OwnerID field which stores the value of who uploaded the file. I'm guessing that is the same as want you want to do with CreatedBy so you probably don't need to add that field
Additionally, file uploads will need to check the member's withinQuota() method, how can this be accomplished?
You can set limits on a per filefield basis by setting setAllowedMaxFileSize(). Not completely sure how to set it globally, there must be a way to do so but I can't seem to find it. Using setAllowedMaxFileSize() however you could set it like
$field->setAllowedMaxFileSize($member->withinQuota);
Inside the withinQuota(), I will need to pull all Files owned by that user, how should this be done?
Well because File has a OwnerID you can run a simple DataObject::get('File', "OwnerID = '$this->ID'"); which will return a set of files for that owner.
-
Re: File upload quotas

16 December 2009 at 9:24am
Thank you for the excellent response Willr. I will get to work on this right now.
| 984 Views | ||
|
Page:
1
|
Go to Top |


