Changeset 11625


Ignore:
Timestamp:
Jul 4, 2011, 5:08:07 PM (13 years ago)
Author:
J.Commelin
Message:

Fixed bug concerning multiple copyrights with same name.

Location:
extensions/Copyrights
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/Copyrights/TODO

    r11624 r11625  
    1010
    1111=== Bugs ===
    12         - If you create a new copyright with a name that's already used
     12        - If you create a new copyright with a name that's already used (fixed??)
  • extensions/Copyrights/admin.php

    r11268 r11625  
    5050    $visible = (isset($_REQUEST['visible']) ? 1 : 0);
    5151    $query = sprintf(
    52       'INSERT INTO %s
    53       (`name`,`url`,`descr`,`visible`) VALUES
    54       ("%s","%s","%s",%d)
     52      'SELECT COUNT(*)
     53      FROM %s
     54      WHERE `name` = '%s'
    5555      ;',
    56       COPYRIGHTS_ADMIN, $name, $url, $descr, $visible);
    57     pwg_query($query);
     56      COPYRIGHTS_ADMIN, $name);
     57    list($counter) = pwg_db_fetch_row(pwg_query($query));
     58    if ($counter != 0) {
     59      array_push($page['errors'], l10n('This copyright already exists'));
     60    } else {
     61      $query = sprintf(
     62        'INSERT INTO %s
     63        (`name`,`url`,`descr`,`visible`) VALUES
     64        ("%s","%s","%s",%d)
     65        ;',
     66        COPYRIGHTS_ADMIN, $name, $url, $descr, $visible);
     67      pwg_query($query);
     68    }
    5869  }
    5970
Note: See TracChangeset for help on using the changeset viewer.