forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 miscellaneous => Topic started by: ymca on May 29, 2006, 01:33:55 pm

Title: 1 pic per user...
Post by: ymca on May 29, 2006, 01:33:55 pm
Hi,
can anyone help me on how to add an option that let me limit the upload pictures to 1 picture per user?

thnx
Title: Re: 1 pic per user...
Post by: Joachim Müller on May 30, 2006, 04:45:03 am
One at a time? Check the groups page.
Title: Re: 1 pic per user...
Post by: ymca on May 30, 2006, 10:51:54 am
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)
Title: Re: 1 pic per user...
Post by: Stramm on May 30, 2006, 12:33:27 pm
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
Code: [Select]
    // 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
Code: [Select]
    // 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)
Code: [Select]
  '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
Title: Re: 1 pic per user...
Post by: ymca on May 30, 2006, 01:08:18 pm
I get this message after i uploaded a picture & want to upload again.
(the first picture was approved)
Quote
Your file was uploaded successfully.

It will be visible after admin approval.
Title: Re: 1 pic per user...
Post by: Stramm on May 30, 2006, 01:23:26 pm
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...
Title: Re: 1 pic per user...
Post by: ymca on May 30, 2006, 01:36:47 pm
the registers already have a quota of 224kb
Title: Re: 1 pic per user...
Post by: Stramm on May 30, 2006, 01:46:47 pm
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
Title: Re: 1 pic per user...
Post by: ymca on May 30, 2006, 02:35:20 pm
no change for me... :(
maybe because i approve uploads after they upload them?
Title: Re: 1 pic per user...
Post by: Stramm on May 30, 2006, 02:40:53 pm
are you logged in as user (no admin rights)?
if yes, zip your picmgmnt.inc.php and attach it to your next post
Title: Re: 1 pic per user...
Post by: ymca on May 30, 2006, 02:48:52 pm
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.
Title: Re: 1 pic per user...
Post by: Stramm on May 30, 2006, 02:59:28 pm
tried yours... works like a charm for me (I'm using upload approval as well)
Title: Re: 1 pic per user...
Post by: ymca on May 30, 2006, 03:07:24 pm
 :'( so where the problem can be  ???
Title: Re: 1 pic per user...
Post by: Stramm on May 30, 2006, 08:51:44 pm
you've tried as admin?
Title: Re: 1 pic per user...
Post by: ymca on May 30, 2006, 08:58:00 pm
now yes, have no upload limit.
Title: Re: 1 pic per user...
Post by: Stramm on May 30, 2006, 09:18:26 pm
so should it be.. as admin you can upload without limit. Logout and use a testuser account without admin privileges
Title: Re: 1 pic per user...
Post by: ymca on May 30, 2006, 09:36:20 pm
i did that in the begining
Title: Re: 1 pic per user...
Post by: Stramm on May 31, 2006, 05:56:57 am
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
Title: Re: 1 pic per user...
Post by: Stramm on May 31, 2006, 06:16:00 pm
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
Title: Re: 1 pic per user...
Post by: ymca on May 31, 2006, 06:31:26 pm
yes i did.
maybe i need to do update.php?
Title: Re: 1 pic per user...
Post by: ymca on June 01, 2006, 07:50:49 pm
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.
Title: Re: 1 pic per user...
Post by: ymca on June 26, 2006, 11:56:43 pm
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 ?
Title: Re: 1 pic per user...
Post by: 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

Code: [Select]
        $result = cpg_db_query("SELECT pid FROM {$CONFIG['TABLE_PICTURES']} WHERE owner_name = '" . (USER_NAME) . "'");
Title: Re: 1 pic per user...
Post by: ymca on August 04, 2006, 08:56:54 am
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-

Quote
You 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 ?
Title: Re: 1 pic per user...
Post by: Stramm on August 04, 2006, 09:15:55 am
The message depends on what you've set in the lang file.
Title: Re: 1 pic per user...
Post by: ymca on August 04, 2006, 09:21:01 am
thank you
Title: Re: 1 pic per user...
Post by: 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.     
Title: Re: 1 pic per user...
Post by: Oracle9 on October 24, 2007, 07:52:45 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
Title: Re: 1 pic per user...
Post by: Sami on October 25, 2007, 11:04:42 am
it should works , unless you're uploading as an admin
Title: Re: 1 pic per user...
Post by: Oracle9 on November 01, 2007, 10:30:40 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
Title: Re: 1 pic per user...
Post by: Stramm on November 01, 2007, 11:06:23 am
use that instead... it uses the limits from the group control panel as number of files instead of kb

Code: [Select]
    // 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'] ) {
Title: Re: 1 pic per user...
Post by: treret on November 01, 2007, 08:05:10 pm
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.
Title: Re: 1 pic per user...
Post by: Stramm on November 01, 2007, 08:19:57 pm
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
Title: Re: 1 pic per user...
Post by: Prometheus on August 21, 2009, 08:01:45 pm
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. :)
Title: Re: 1 pic per user...
Post by: Joachim Müller on August 23, 2009, 09:14:53 am
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.