Hi,
can anyone help me on how to add an option that let me limit the upload pictures to 1 picture per user?
thnx
One at a time? Check the groups page.
not at a time but 1 picture & not more!
if i give users a limit in Kb they can upload how many pics they want in the limit of the Kb but i want them to just have a"number of pics that i want" (like 1 per user)
I've a quick hack for that. The disk quota settings in the groupmanager won't have a function anymore after applying it. Only admins will be able to upload more than 1 pic
in include/picmgmnt.inc.php find
// Test if disk quota exceeded
if (!GALLERY_ADMIN_MODE && $USER_DATA['group_quota']) {
$result = cpg_db_query("SELECT sum(total_filesize) FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND category = '" . (FIRST_USER_CAT + USER_ID) . "'");
$record = mysql_fetch_array($result);
$total_space_used = $record[0];
mysql_free_result($result);
if ((($total_space_used + $total_filesize)>>10) > $USER_DATA['group_quota'] ) {
and replace with
// Test if disk quota exceeded
if (!GALLERY_ADMIN_MODE) {
$result = cpg_db_query("SELECT total_filesize FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND category = '" . (FIRST_USER_CAT + USER_ID) . "'");
$record = mysql_fetch_array($result);
$total_space_used = count($record);
mysql_free_result($result);
if ($total_space_used > 1 ) {
now open your lang file and find (I'm using english.php in that example)
'quota_exceeded' => 'Disk quota exceeded<br /><br />You have a space quota of [quota]K, your files currently use [space]K, adding this file would make you exceed your quota.',
and modify it to your needs... eg. 'You have already uploaded a pic' or similar
Should work but I haven't tested it. Therefore backup your files before modifying them
I get this message after i uploaded a picture & want to upload again.
(the first picture was approved)
QuoteYour file was uploaded successfully.
It will be visible after admin approval.
I've modified the part after // Test if disk quota exceeded a lil bit.
Before the modification you needed to set a quota in group manager even if coppermine doesn't use it anymore. Just to trigger...
the registers already have a quota of 224kb
I've applied my above changes to my test gallery... works as expected
after uploading a second image with a non admin registered user (as said, admins are able to upload without limits)
'Error
Disk quota exceeded'
cause I haven't changed the lang file
no change for me... :(
maybe because i approve uploads after they upload them?
are you logged in as user (no admin rights)?
if yes, zip your picmgmnt.inc.php and attach it to your next post
here's my zip.
also after i did change the need approve to no it gave me -
The selected album/file does not exist !
but still the pic did go to the albom.
tried yours... works like a charm for me (I'm using upload approval as well)
:'( so where the problem can be ???
you've tried as admin?
now yes, have no upload limit.
so should it be.. as admin you can upload without limit. Logout and use a testuser account without admin privileges
i did that in the begining
Last thing you can do is posting a testuser account and the URL to your gallery.
I can't replicate your problems cause all works well for me... so not much I can advice you
tried and I can upload more pics to your gallery. Have you replaced the old picmgmnt.inc.php? --> uploaded into the include dir?
I've chosen exactly the same settings for my test environment as you and the lil mod works perfectly for me
yes i did.
maybe i need to do update.php?
I think that the problem is related to the other problem
that after i did change the need approve to "no" it gave me -
The selected album/file does not exist !
but still the pic did go to the albom.
Stramm...
i have also tried to make the Quota:1
but still i can upload 2 pictures.
do you know if the problem is from another file that is linked to the picmgmt.inc.php ?
cause someone else on the german support board asked this question too and had similar problems...
Coppermine (standard behaviour) checks limitations only for the user galleries and not pics of a user in the public galleries. So does this hack. To change the behaviour and allow users only to upload a certain number of pics to public and user galleries you'll have to change the query eg. to
$result = cpg_db_query("SELECT pid FROM {$CONFIG['TABLE_PICTURES']} WHERE owner_name = '" . (USER_NAME) . "'");
thnx... its working
i tried to upload a pic after i had 1 already, i got to the choose gallery & after that it gave me-
QuoteYou have already uploaded a pic
You have a limit quota of 1pictures, your files currently use 0K, adding this file would make you exceed your quota.
the "0K" is ok ?
The message depends on what you've set in the lang file.
thank you
It works,
but
I want to allow 2 photos and no more, so I change
if ($total_space_used > 1 ) {
to
if ($total_space_used > 2 ) {
It doesn't work and users can upload 3 or more files.
What it doesn't work?
Thanks.
Quote from: treret on October 22, 2007, 06:50:29 PM
It works,
but
I want to allow 2 photos and no more, so I change
if ($total_space_used > 1 ) {
to
if ($total_space_used > 2 ) {
It doesn't work and users can upload 3 or more files.
What it doesn't work?
Thanks.
I got the same error , did you find why ?
Regards
it should works , unless you're uploading as an admin
Quote from: Sami on October 25, 2007, 11:04:42 AM
it should works , unless you're uploading as an admin
Thanks Sami for your replay but I loged as a user not Admin , and have the same issue , I tried the select statment on MySQL and it work fine , but after adding it to the php , it work only with : if ($total_space_used > 1 )s
Regards
use that instead... it uses the limits from the group control panel as number of files instead of kb
// Test if disk quota exceeded
if (!GALLERY_ADMIN_MODE && $USER_DATA['group_quota'] && $category == FIRST_USER_CAT + USER_ID) {
$result = cpg_db_query("SELECT 1 FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND category = '" . (FIRST_USER_CAT + USER_ID) . "'");
$total_space_used = mysql_num_rows($result);
mysql_free_result($result);
if (($total_space_used) >= $USER_DATA['group_quota'] ) {
I set In GROUP Diisc Quota = 12 for registered.
I Login with different usernane as a registered user, who already has 12 images.
I uploaded the 13th image without problem.
It seems to me that the mod doesn't work.
Quote from: Stramm on August 04, 2006, 08:20:23 AM
cause someone else on the german support board asked this question too and had similar problems...
Coppermine (standard behaviour) checks limitations only for the user galleries and not pics of a user in the public galleries. So does this hack. To change the behaviour and allow users only to upload a certain number of pics to public and user galleries you'll have to change the query eg. to
Phew! After searching really hard I managed to find this thread. Was worth the effort as it works flawlessly. Thanks, though it would have been great is someone had pointed me to this thread in the first place. :)
Thanks for your review.
This thread hasn't made it into the mods board because it contained too much personall issues of the thread starter. You might want to summarize the mod instructions into a posting in a new thread so it could be moved into the mods board. Ideally, this could be done as a plugin.