Piwigo.org

You are not logged in. (Register / Login)

Announcement

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

romanf
Member
Registered: 2017-01-22
Posts: 31

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
Location: Nantes, France, Europe
Registered: 2002-04-05
Posts: 13080
Website

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.


Latest blog post (March 23th 2017) Piwigo.com Enterprise plans, now official!

Offline

 

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

romanf
Member
Registered: 2017-01-22
Posts: 31

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

 

Board footer

Powered by FluxBB

github twitter facebook google+ newsletter Donate Piwigo.org © 2002-2017 · Contact