Hey all,
I'm creating a gallery that gives the owner the ability to protect (hide) some of there images if they would like, then unhide them for different users when they so desire. Here are the details
I've created a gallery item article for each image. Included is a radio field for the user to choose to protect the image (Yes/No options) If the user picks yes, the image will be protected and only invited users will be able to see it.
I've created a gallery owner to viewer relationship article for the gallery owners to store which user can view their protected images.
So, the process would be, a viewer would ask the owner permission to view their images, the owner would click "yes" and the owners ID and viewer ID would be stored in the relationship table.
SO, I've created a Select - Dynamic field to check and see if a viewer has permission to view the images I created an SQL statement to return a 0 if the user does NOT have permission and a 1 if the user does.
SELECT CASE
WHEN EXISTS (
SELECT *
FROM #__gallery_item
WHERE id = 56
and protect_image = 'Yes'
)
THEN
( SELECT count(*)
FROM #__gallery_item_user_relationship
WHERE gallery_viewer = 47 and gallery_owner = 45)
ELSE 1
END
I then created a LIST to show all the images in the gallery. What is supposed to happen is for each image the dynamic box checks to see if the current user can see the images. The way the SQL is set up is
SELECT *
FROM #__gallery_item WHERE id = 56 and protect_image = 'Yes' <-checks to see if the image is protected (56 is the current art_id for the image)
if it is protected
( SELECT count(*) FROM #__gallery_item_user_relationship WHERE gallery_viewer = 47 and gallery_owner = 45) <- check if the current user has permission to view the photos (47 is the current users ID and 45 is the owner of the gallery)
NOW THE QUESTION!! I know I can plug in $user->id to get the current users id (47) and I can pass the owners ID (45) in the URL and grab it with
$uri->getValue('owner_id') BUT, I can not figure out how to capture the ID of the image I am checking, in the above example it would be the 56. I tried $ccl->getValue("art_id") but that has not worked.
Anyone have a clue? Thanks a lot.
I know that a long explanation and not sure I made a lot of since, so if you have any questions, please let me know.
Thank you,
Ross