Give users ability add images to a gallery they did not create, or a Shared Gallery

There are two ways to stop people from editing the gallery title and description, one with rules and another with path redirect. The path redirect is easier or requires fewer settings.

Lets say you have a scenario where you want to create an album/image relationship that will serve as a photo competition. Users must then have the ability to post images in this gallery, even though they have not created the gallery. They may need to edit or update their own images and add a title with a description for each image as well. Users must not be able to create galleries with this relationship and we do not want them to change the Title or Description associated with the Gallery. Lightbox2 can be used with the shared gallery if desired.
Note: This setup may not be needed in the future as the module matures. But we don't have to wait because we can do it now! Drupal is Cool...

    Modules used in this example:
  • node_gallery
  • CCK(Content Construction Kit)
  • content_access (requires rebuild permissions on install)
  • path_redirect
  • rules Allows site administrators to define conditionally executed actions based on occurring events.
  • masquerade (optional) This allows you login as admin and switch to a registered user. Used for posting test content and is a good way to edit a user image while keeping the uid for the image intact.

This is the node gallery relationship to be used for sharing

Create 2 new content types, for gallery and image nodes. (normal gallery relationship set up)
Note: A new Gallery Content Type is required, but an existing Gallery Image Content Type can be reused. The existing ImageCache presets can be reused or create new presets. When this has been done, set the permissions for the new shared gallery.

Permissions have been granted to all roles in this example:
Goto: Administer > User management > Permissions
system path: admin/user/permissions

    view imagecache node-gallery-cover
    view imagecache node-gallery-display
    view imagecache node-gallery-thumbnail

    create photo_competition_gallery content
    create photo_competition_image content
    edit any photo_competition_gallery content
    edit own photo_competition_image content

    view node gallery

Prepare the gallery for rules to prevent users from changing the Title and/or the Description

Goto: Administer > Content management > Content type > photo_competition_gallery
System path: admin/content/types/photo-competition-gallery

Remove the text in the core body or description field to disable.
Add a new CCK text area field for description.(photo_comp_description) This is needed for rules to work properly.

Create the new shared gallery to hold the images.
Goto: Administer > Create content > photo competition gallery
System path: admin/node/add/photo-competition-gallery

Enter the Title of the gallery new photo competition title
Enter the description of the gallery new photo competition description
After the shared gallery is created.

Set triggered rules to retain the original Title and/or Description if a user edits them

Goto: Administer > Rules > Triggered rules > Add a new rule
System path: admin/rules/trigger/add

    Add a new triggered rule:
    (label) whatever-- photocomp title
    (event) After updating existing content (save)

    section Rule Elements:
    (add a condition) Node: Content has type (next)
    (content types) photo competition gallery (save)

    section DO:
    (Add an action) set content title (next)
    Enter your actual title text new photo competition title (save)

    -----------

    Add a new triggered rule:
    (label) whatever-- photocomp description
    (event) After updating existing content (save)

    section DO:
    (add an action) Populate a field photo_comp_description_field (continue)
    Enter your actual description text new photo competition description (save)

Using path redirect instead of rules

You can use a workaround with the path_redirect module if you don't want to use rules. What this will do is -- if the user tries to click the 'edit' tab for the gallery, it will redirect them to the gallery. In effect, they will not be able to edit the gallery title, description or any other items on the gallery edit page.

In the path_redirect interface, set a redirect from:
http://www.example.com/node/51/edit
to
http://www.example.com/node/51
This is just an example path, change the '51' to the node that your gallery is using.
To see the node number right click the gallery edit tab and choose properties and redirect that url to the gallery they are using. The path you will redirect to will depend on url aliases and/or pathauto if you use those.

Set the content access for the Gallery Node

This is where the permissions magic happens. Each authenticated user that adds an image to the gallery will be able to edit their own images.
Note: This can also be set to allow permissions for specified users by user name. This does not work well for anonymous users as they can edit any image submitted by another anonymous user (unless the edit permission is disabled).

Content access, set this for the user roles to be included:
Goto: Administration > Content management > Content types > photo_competition_gallery > Access control
System path: admin/content/types/photo-competition-gallery/access

    View any content:
    [X] anonymous user
    [X] authenticated user

    Edit any content:
    [X] anonymous user
    [X] authenticated user

    View own content:
    [X] anonymous user
    [X] authenticated user

    Edit own content:
    [X] anonymous user
    [X] authenticated user

Prevent users from creating a new shared gallery

We do not want users to create a shared gallery because the rules module is used for control of the Title and Description. If they create a shared gallery, the Title and description will change to the preset value in the triggered rules.

Goto: Administer > Site building > Menus > List
System path: admin/build/menu/list

Open the Navigation menu and un-check the shared gallery and image content types.

    In this example:
    photo_competition_gallery
    photo_competition_image


Note: A version of this setup using views can also be done and will be added after the details are documented or it is requested.
Thanks goes out to Manamarak for the motivation to get this documented for all to enjoy.


Comments

nimzie’s picture

Wondering if you guys have indeed come up with a way to do this with views?

dbeall’s picture

It's not quite ready yet, but it is not far off now.. Thanks to all that have worked on it
http://drupal.org/node/544760#whatsup

3.x-dev is here.. This is in 'development'..
http://ftp.drupal.org/files/projects/node_gallery-6.x-3.x-dev.tar.gz

chrisdlk’s picture

Hello,

In the latest stable version there is a problem with the upload limit for authenticated users (those who have not created the gallery). The default setting indicates that the upload limit to 0 is unlimited, but it is not. 0 in this case indeed is 0, so the user is not allowed to upload images.

As a workaround I have put a number in the configuration upload limit, but is there any other way to solve it?

Regards

Canadaka’s picture

Using this method the user can add images to an existing gallery using the "Upload new images" tab which is powered by pupload in my case. But they can't use the node/add form because the "Assign to Gallery" selection is blank or does not contain access to the gallery. Likewise they cannot edit a photo which has been uploaded with the batch upload because the "Assign to Gallery" is blank.

shared galleries are the one big thing node_gallery is missing for me, I want some galleries to be public and anyone can contribute but also allow users to have their own private galleries.

dereckd’s picture

I realize this will only work for a very specific scenario, for my purposes I (the admin) will be creating all the shared galleries, I want people to be able to contribute to them but not edit them.

Goto: Administration > Content management > Content types > you_gallery_type > Access control

View any content:
[X] anonymous user
[X] authenticated user

Edit any content:
[ ] anonymous user
[ ] authenticated user

View own content:
[X] anonymous user
[X] authenticated user

Edit own content:
[X] anonymous user
[X] authenticated user

go to line 567 in node_gallery.module and change

return user_access('administer nodes') || user_access('edit any '. $gallery_type .' content');
to
return user_access('administer nodes') || user_access('edit own '. $gallery_type .' content');

essentially what this does is give upload acces (to any gallery) to anyone who can edit there own gallery, they still cannot "edit" the gallery since they only have permission to edit there own.

I know it's a little hacky, and breaks if the use case is altered, but I figured I would post a possible solution