limit one user album by category ? limit one user album by category ?
 

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

Main Menu

limit one user album by category ?

Started by colapaca, November 11, 2010, 06:30:08 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

colapaca

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.

Αndré

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

colapaca

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?

Αndré

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.

colapaca

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

klinkoo

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

Αndré

#6
Open delete.php, find
        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
        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']
            );
        }

colapaca

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?

Αndré


colapaca

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.

colapaca

Quote from: colapaca 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 (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.

Αndré

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?

colapaca

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.


Αndré

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.

colapaca

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! :)

Αndré

#15
Open albmgr.php, find
                if ($check_group_rowset) {
                    $CAT_LIST[] = array($subcat['cid'], $ident . $subcat['name']);
                }

and replace with
                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).


Quote from: colapaca on January 28, 2014, 01:56:15 PM
*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.

colapaca

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!

Αndré


colapaca

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.

Αndré

Quote from: colapaca on January 31, 2014, 03:31:28 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).


Quote from: colapaca on January 31, 2014, 03:31:28 AM
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?


Quote from: colapaca on January 31, 2014, 03:31:28 AM
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
if(data['message'] == 'true'){
and below, add
window.location.replace('albmgr.php');


Quote from: colapaca on January 31, 2014, 03:31:28 AM
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".