Ignore:
Timestamp:
Jun 27, 2012, 9:19:07 PM (12 years ago)
Author:
mistic100
Message:

updated for Piwigo 2.4
new filters : name, author, level, hits

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/SmartAlbums/maintain.inc.php

    r11451 r16104  
    22if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    33
     4global $prefixeTable;
     5define('smart_table', $prefixeTable . 'category_filters');
     6
     7define('smart_default_config', serialize(array(
     8    'update_on_upload' => false,
     9    'show_list_messages' => true,
     10    )));
     11
    412function plugin_install()
    513{
    6         global $prefixeTable;
    7 
    814  /* create table to store filters */
    915        pwg_query(
    10 'CREATE TABLE IF NOT EXISTS `' . $prefixeTable . 'category_filters` (
     16'CREATE TABLE IF NOT EXISTS `' . smart_table . '` (
    1117  `category_id` smallint(5) unsigned NOT NULL,
    1218  `type` varchar(16) NOT NULL,
     
    2026     
    2127  /* config parameter */
    22   pwg_query('
    23 INSERT INTO `' . CONFIG_TABLE . '`
    24   VALUES (
    25     \'SmartAlbums\',
    26     \''.serialize(array(
    27         'update_on_upload' => false,
    28         'show_list_messages' => true,
    29         )
    30       ).'\',
    31     \'Configuration for SmartAlbums plugin\'
    32   )
    33 ;');
    34 
     28  conf_update_param('SmartAlbums', smart_default_config);
    3529}
    3630
     
    4135  if (!isset($conf['SmartAlbums']))
    4236  {
    43     pwg_query('
    44 INSERT INTO `' . CONFIG_TABLE . '`
    45   VALUES (
    46     \'SmartAlbums\',
    47     \''.serialize(array(
    48         'update_on_upload' => false,
    49         'show_list_messages' => true,
    50         )
    51       ).'\',
    52     \'Configuration for SmartAlbums plugin\'
    53   )
    54 ;');
     37    conf_update_param('SmartAlbums', smart_default_config);
     38  }
     39 
     40  /* some filters renamed in 1.2 */
     41  $name_changes = array(
     42    'the' => 'the_post',
     43    'before' => 'before_post',
     44    'after' => 'after_post',
     45    'the_crea' => 'the_taken',
     46    'before_crea' => 'before_taken',
     47    'after_crea' => 'after_taken',
     48    );
     49  foreach ($name_changes as $old => $new)
     50  {
     51    pwg_query('UPDATE TABLE ' . smart_table . ' SET cond = "'.$new.'" WHERE cond = "'.$old.'";');
    5552  }
    5653}
    5754
    5855function plugin_uninstall()
    59 {
    60         global $prefixeTable;
    61  
    62   pwg_query('DROP TABLE `' . $prefixeTable . 'category_filters`;');
     56
     57  pwg_query('DROP TABLE `' . smart_table . '`;');
    6358  pwg_query('ALTER TABLE `' . IMAGE_CATEGORY_TABLE . '` DROP `smart`;');
    64   pwg_query('DELETE FROM `' . CONFIG_TABLE . '` WHERE param = \'SmartAlbums\';');
     59  pwg_query('DELETE FROM `' . CONFIG_TABLE . '` WHERE param = \'SmartAlbums\' LIMIT 1;');
    6560}
     61
    6662?>
Note: See TracChangeset for help on using the changeset viewer.