Changeset 11844


Ignore:
Timestamp:
Jul 27, 2011, 8:19:46 PM (13 years ago)
Author:
Mattias
Message:

fixed a bug in image.php when the extended author plugin is deactivated, but there is a -1 copyright

also added primary key to CR_media (the media_id)
and changed CR_id to NOT NULL

Location:
extensions/Copyrights
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/Copyrights/image.php

    r11794 r11844  
    5656                $descr = '';
    5757                if (count($row) > 0) {
     58                        // If its the authors default copyright, get the data from the author table, instead of the copyright table
    5859                        if ($row['cr_id'] == -1) {
    59                                                 $query = sprintf('
    60                                                         SELECT name, url, descr
    61                                                         FROM %s
    62                                                         WHERE cr_id IN (
    63                                                                 SELECT a.copyright
    64                                                                 FROM '.$prefixeTable.'images i, '.$prefixeTable.'author_extended a
    65                                                                 WHERE i.id = %d
    66                                                                 AND i.author = a.name
    67                                                         )
     60                                // Check if the extended author plugin is active
     61                                $query = '
     62                                        SELECT *
     63                                        FROM '.$prefixeTable.'plugins
     64                                        WHERE id=\'Extended_author\'
     65                                        AND state=\'active\'
     66                                        ;';
     67                                $result = pwg_query($query);
     68                                $row = pwg_db_fetch_assoc($result);
     69                               
     70                                // Only get the authors default copyright when it is active.
     71                                if (count($row) > 0) {
     72                                        $query = sprintf('
     73                                                SELECT name, url, descr
     74                                                FROM %s
     75                                                WHERE cr_id IN (
     76                                                        SELECT a.copyright
     77                                                        FROM '.$prefixeTable.'images i, '.$prefixeTable.'author_extended a
     78                                                        WHERE i.id = %d
     79                                                        AND i.author = a.name
     80                                                )
    6881                                                ;',
    6982                                                COPYRIGHTS_ADMIN, $page['image_id']);
    70                                                 $result = pwg_query($query);
    71                                                 $row = pwg_db_fetch_assoc($result);
     83                                        $result = pwg_query($query);
     84                                        $row = pwg_db_fetch_assoc($result);
     85                                }
    7286                        }
    7387                }
     88                // Get the data from the chosen row
    7489                if (count($row) > 0) {
    7590                        $name = $row['name'];
  • extensions/Copyrights/main.inc.php

    r11836 r11844  
    22/*
    33Plugin Name: Copyrights
    4 Version: 1.0
     4Version: 1.1.1
    55Description: Create copyrights and assign them to your photos.
    66Plugin URI: http://piwigo.org/ext/extension_view.php?eid=537
  • extensions/Copyrights/maintain.inc.php

    r11656 r11844  
    3939    CREATE TABLE IF NOT EXISTS ".$prefixeTable."copyrights_media (
    4040      media_id int(11) NOT NULL,
    41       cr_id int(11) default NULL
     41      cr_id int(11) NOT NULL,
     42      PRIMARY KEY (media_id)
    4243    ) ENGINE = MyISAM DEFAULT CHARACTER SET utf8
    4344    ;";
Note: See TracChangeset for help on using the changeset viewer.