Announcement

  •  » Engine
  •  » Database Schema?

#1 2017-04-02 21:25:11

romanf
Member
2017-01-22
40

Database Schema?

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

 

#2 2017-04-12 17:43:11

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: Database Schema?

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

Code:

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

 

#3 2017-04-23 09:42:38

romanf
Member
2017-01-22
40

Re: Database Schema?

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

 
  •  » Engine
  •  » Database Schema?

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact