Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1] 2   Go Down

Author Topic: limit one user album by category ?  (Read 21686 times)

0 Members and 1 Guest are viewing this topic.

colapaca

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 37
limit one user album by category ?
« on: November 11, 2010, 06:30:08 pm »

Hello,

I recently upgrade the CPG gallery from 1.4.18 to 1.5.8 after expecting since a long time the new administrative right possibilities.
I really appreciate now that it's possible for user to add their own gallery in existing category.

I would appreciate to limit one user album by category (I don't talk about limit the number of pictures). I suppose the code should be modified somewhere ?

Perhaps I'm wrong but I didn't find any discussion about this possibility.
Thanks for your listening and your help.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: limit one user album by category ?
« Reply #1 on: November 11, 2010, 06:41:48 pm »

Shall your users can create just 1 album per public category or in general?
Logged

colapaca

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 37
Re: limit one user album by category ?
« Reply #2 on: November 11, 2010, 10:04:18 pm »

Yes, just 1 album per public category is my absolute organization priority (I would like to only have category by events and that's why one album by user is enough inside).

For the in general, not really sure about consequences. I didn't really think about it. is it about personal album?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: limit one user album by category ?
« Reply #3 on: November 12, 2010, 11:42:47 am »

We need to modify some core code and add a check that counts the albums. It was just a question, so I can generate the correct check for you.
Logged

colapaca

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 37
Re: limit one user album by category ?
« Reply #4 on: November 12, 2010, 09:51:06 pm »

if you could take in count my request, it could be helpful and interesting.
One user album by category is fine.
Logged

klinkoo

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: limit one user album by category ?
« Reply #5 on: November 14, 2010, 06:48:12 am »

I am also interested in this option André! merci!
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: limit one user album by category ?
« Reply #6 on: November 19, 2010, 02:56:36 pm »

Open delete.php, find
Code: [Select]
        if (!empty($get_album_name)) {
            //add the album to database
            $query = "INSERT INTO {$CONFIG['TABLE_ALBUMS']} (category, title, uploads, pos, description, owner) VALUES ('$category', '$get_album_name', 'NO', '{$position}', '', '$user_id')";
            cpg_db_query($query);
   
            //get the aid of added the albums
            $getAid = mysql_insert_id($CONFIG['LINK_ID']);
   
            $dataArray = array(
                'message' => 'true',
                'newAid'  => $getAid,
            );
        } else {
            $dataArray = array(
                'message' => 'false',
                'title'  => $lang_errors['error'],
                'description' => $lang_albmgr_php['alb_need_name']
            );
        }
and replace with
Code: [Select]
        if (!GALLERY_ADMIN_MODE && $category < FIRST_USER_CAT && mysql_result(cpg_db_query("SELECT COUNT(*) FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = $category AND owner = ".USER_ID), 0) > 0) {
            $dataArray = array(
                'message' => 'false',
                'title'  => $lang_errors['error'],
                'description' => 'Only 1 album per public category'
            );
        } elseif (!empty($get_album_name)) {
            //add the album to database
            $query = "INSERT INTO {$CONFIG['TABLE_ALBUMS']} (category, title, uploads, pos, description, owner) VALUES ('$category', '$get_album_name', 'NO', '{$position}', '', '$user_id')";
            cpg_db_query($query);

            //get the aid of added the albums
            $getAid = mysql_insert_id($CONFIG['LINK_ID']);

            $dataArray = array(
                'message' => 'true',
                'newAid'  => $getAid,
                'album_name' => $get_album_name,
            );
        } else {
            $dataArray = array(
                'message' => 'false',
                'title'  => $lang_errors['error'],
                'description' => $lang_albmgr_php['alb_need_name']
            );
        }
« Last Edit: February 03, 2014, 10:43:34 am by Αndré »
Logged

colapaca

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 37
Re: limit one user album by category ?
« Reply #7 on: November 21, 2010, 07:06:25 pm »

Dear Andre,

thank you for this useful solution and your so quick reply. It's perfect!


A nice extension to stay in the same spirit, could be to assign automatically the name of the user to the album and grant directly some default permissions decided by the administrator. Should I need to open another post?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: limit one user album by category ?
« Reply #8 on: November 21, 2010, 07:18:47 pm »

Should I need to open another post?
Yes.
Logged

colapaca

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 37
Re: limit one user album by category ?
« Reply #9 on: January 28, 2014, 02:19:08 am »

Dear André,

I think my new question concern this modification you made previous for one album creation by category but let me know if you want I open another topic.

When you select the option "create/sort album" under "my profil", you see the full list of albums and it's not usefull to select quickly the category when you have created an album. The result written on the left can only appear after you select one of the album:


You can't see it as well as it's in the option list for example:


Could you please help to have a request code to have the same useful display as the second picture ?

Many thanks.
Logged

colapaca

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 37
Re: limit one user album by category ?
« Reply #10 on: January 28, 2014, 02:20:32 am »

Dear André,

I think my new question concern this modification you made previous for one album creation by category but let me know if you want I open another topic.

When you select the option "create/sort album" under "my profil", you see the full list of albums and it's not usefull to select quickly the category when you have created an album. The result written on the left can only appear after you select one of the album (alb1):

You can't see it as well as it's in the option list for example (alb2):

Could you please help to have a request code to have the same useful display as the second picture ?

Many thanks.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: limit one user album by category ?
« Reply #11 on: January 28, 2014, 10:34:41 am »

Please don't mix up the terms "category" and "album". Your screenshot "alb1" shows the album manager, where you need to select a category first. After you selected a category, you'll see the existing albums of that category, which you can move, delete, rename or create a new album.

I currently don't get why you want to adjust the drop-down box according to screenshot "alb2", as you'd select albums, which is not how the album manager is supposed to work. What exactly do you want to accomplish?
Logged

colapaca

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 37
Re: limit one user album by category ?
« Reply #12 on: January 28, 2014, 01:56:15 pm »

Andre,

you are right I'm confusing both of them in my explaination.

I would really appreciate a to improve the "create/sort album" selection list (under "my profil") who could show directly if an album already exist in public category (and not to have to display the category one by one before the result display on the page)
That 's why I thought it could look like the "modify my albums" list : alb2.png (where the album already appear in the list).

Also to be in coherency with the delete.php you well modified for me long time ago (in order to force users to create only one just 1 album per public category), the *my album* should not appear to not allow them to create an album outside the fixed public category.

Let me know if you know how to modify the script as I would be very happy to improve this "limit one user album by category" case and share it with other interested people.

Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: limit one user album by category ?
« Reply #13 on: January 28, 2014, 02:00:04 pm »

Your goal is to have 1 album at maximum per user in each category, right? If so, I suggest to display just the categories where the user doesn't already created an album. If you agree, I'll try to create the mod.
Logged

colapaca

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 37
Re: limit one user album by category ?
« Reply #14 on: January 28, 2014, 02:20:03 pm »

this is exactly that, as the case "sort album" isn't necessary with this goal.
And in addition, it will avoid the Error message display : "Only 1 album per public category".
Perfect! :)
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: limit one user album by category ?
« Reply #15 on: January 28, 2014, 02:53:40 pm »

Open albmgr.php, find
Code: [Select]
                if ($check_group_rowset) {
                    $CAT_LIST[] = array($subcat['cid'], $ident . $subcat['name']);
                }
and replace with
Code: [Select]
                if ($check_group_rowset) {
                    if (mysql_result(cpg_db_query("SELECT COUNT(*) FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = {$subcat['cid']} AND owner = ".USER_ID), 0) == 0) {
                        $CAT_LIST[] = array($subcat['cid'], $ident . $subcat['name']);
                    }
                }

Note: I used the code from 2010-11-19 as base. I just noticed that code checks for the overall number of albums. This means, if one user (or you, as admin) already created an album in a category, no other user can create an additional album. I assume this is not how it is supposed to work? If so, I'll update both database queries (i.e. add an additional check for the user ID).


*my album* should not appear to not allow them to create an album outside the fixed public category.
Disable personal gallery in the groups manager.
« Last Edit: January 29, 2014, 02:06:42 pm by Αndré »
Logged

colapaca

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 37
Re: limit one user album by category ?
« Reply #16 on: January 29, 2014, 01:57:42 pm »

you're right, this is not how it is supposed to work.
The logical is well that each user should be able to create one album in the category even if another user already create one in this category. It would be nice if you could update the script as you suggested.

Therefore, don't know if the modification you made in albmgr.php already work like that, but the interest is that the drop-down menu should display all the category where the user didn't already create an album.


Furthermore, "my album*" is not showed anymore (as excepted) after the setup change in the groups manager, thanks!
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: limit one user album by category ?
« Reply #17 on: January 29, 2014, 02:07:33 pm »

I just updated both codes accordingly.
Logged

colapaca

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 37
Re: limit one user album by category ?
« Reply #18 on: January 31, 2014, 03:31:28 am »

update done, working fine on the principle but just small issue:

When you validate the new album name typed on the boxfield, the name becomes finally "undefined".
Could it take the text typed - and/or - may be a better solution, assign directly the owner user name without having typing something ?

I also noticed 2 strange Menu behaviours :

1) With "create/sort my albums":
After creating an new album, even if you select another menu and came back on the "create/sort my albums" area, you still see the category with the new album jsute created. It's only cleared if you select another category in the drop list. Could it be arrange?

2) Same kind of display in the "main menu":
latence if you select the "Albums" menu directly it show you the same result as when you are arriving in the gallery or if you select "Home" (it shows all the categories). But, if you select "Albums", just after "My Gallery", it's staying blocked on the same "My Gallery" display.

Seems that I clearly abuse with all my review and requests... :)
Sorry for the time and the work I'm asking you to improve the gallery ergonomic experience.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: limit one user album by category ?
« Reply #19 on: February 03, 2014, 11:32:53 am »

When you validate the new album name typed on the boxfield, the name becomes finally "undefined".
I just updated the above code (for some reason the line "'album_name' => $get_album_name," got lost).


Could it take the text typed - and/or - may be a better solution, assign directly the owner user name without having typing something ?
We have 2 possibilities:
1. Pre-populate the album manager with the user name, so he just need to accept the default value. In this case, the user is able to change the album name.
2. Always force the user name as album name, regardless what the user enters. Keep in mind that it's still possible to change the album name at another form, so if you want to disable that option you need some more modification.

Which option do you prefer?


1) With "create/sort my albums":
After creating an new album, even if you select another menu and came back on the "create/sort my albums" area, you still see the category with the new album jsute created. It's only cleared if you select another category in the drop list. Could it be arrange?
Quick & dirty solution: open js/albmgr.js, find
Code: [Select]
if(data['message'] == 'true'){and below, add
Code: [Select]
window.location.replace('albmgr.php');

2) Same kind of display in the "main menu":
latence if you select the "Albums" menu directly it show you the same result as when you are arriving in the gallery or if you select "Home" (it shows all the categories). But, if you select "Albums", just after "My Gallery", it's staying blocked on the same "My Gallery" display.
That's intended behavior, but could of course be changed if you always want to go to your gallery root when selecting "Album list".
Logged
Pages: [1] 2   Go Up
 

Page created in 0.03 seconds with 19 queries.