I was browsing through the dev docs looking for a schema of the database... but couldn't find it.
Can anybody point me to it? :)
Background: For the MenuRandomPhoto Plugin, I would like to understand how to ensure that it only displays images according to the user's permissions.
Also I was asked to implement a way to include/exclude albums from the Random selection (e.g. to promote certain albums or to exclude old/test albums)... In order to implement that, I am trying to understand if I have to extend existing tables or create new ones...
Thanks!
Roman
Offline
Hi romanf,
romanf wrote:
I was browsing through the dev docs looking for a schema of the database... but couldn't find it.
You won't find any "picture" with a schema "drawn". You can find install/piwigo_structure-mysql.sql which is used to create tables.
What is important, in my opinion, is the relations you have between tables.
image_id or element_id refer to images.id
cat_id or category_id refer to category.id
user_id or images.added_by refer users.id
...
romanf wrote:
Background: For the MenuRandomPhoto Plugin, I would like to understand how to ensure that it only displays images according to the user's permissions.
Function get_sql_condition_FandF is your friend. See it in action, for example, on [extension by plg] Private Share
function pshare_is_photo_visible($image_id) { $query=' SELECT id FROM '.CATEGORIES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON category_id = id WHERE image_id = '.$image_id.' '.get_sql_condition_FandF( array( 'forbidden_categories' => 'category_id', 'forbidden_images' => 'image_id', ), ' AND' ).' LIMIT 1 ;'; if (pwg_db_num_rows(pwg_query($query)) < 1) { return false; } return true; }
Also I was asked to implement a way to include/exclude albums from the Random selection (e.g. to promote certain albums or to exclude old/test albums)... In order to implement that, I am trying to understand if I have to extend existing tables or create new ones...
You can get inspiration from [extension by plg] PayPal Shopping Cart which let the admin decide on which the PayPal cart can be applied.
Offline
Ah, the tip with the PayPal plugin was PERFECT! :)
It helped me a great deal. I'm currently beta-testing the new feature of MenuRandomPhoto...
Thanks a lot!
-Roman
Offline