source: extensions/SmartAlbums/include/install.inc.php @ 19446

Last change on this file since 19446 was 19446, checked in by mistic100, 11 years ago
  • add regex for phot name, author
  • add dimensions filter
  • rewrite javascript algorithms
  • add auto update on timeout (default 3 days)
  • display photos count on plugin albums list
File size: 2.6 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4function smart_albums_install() 
5{
6  global $conf, $prefixeTable;
7 
8  // configuration
9  if (!isset($conf['SmartAlbums']))
10  {
11    $smart_default_config = serialize(array(
12      'update_on_upload' => false,
13      'update_on_date' => true,
14      'update_timeout' => 3,
15      'show_list_messages' => true,
16      'smart_is_forbidden' => true,
17      'last_update' => 0,
18      ));
19   
20    conf_update_param('SmartAlbums', $smart_default_config);
21    $conf['SmartAlbums'] = $smart_default_config;
22  }
23  else
24  {
25    $new_conf = unserialize($conf['SmartAlbums']);
26    // new param in 2.0.2
27    if (!isset($new_conf['smart_is_forbidden']))
28    {
29      $new_conf['smart_is_forbidden'] = true;
30    }
31    // new params in 2.1.0
32    if (!isset($new_conf['update_on_date']))
33    {
34      $new_conf['update_on_date'] = true;
35      $new_conf['update_timeout'] = 3;
36      $new_conf['last_update'] = 0;
37    }
38    conf_update_param('SmartAlbums', serialize($new_conf));
39    $conf['SmartAlbums'] = serialize($new_conf);
40  }
41 
42  // new table
43        pwg_query(
44'CREATE TABLE IF NOT EXISTS `' . $prefixeTable . 'category_filters` (
45  `category_id` smallint(5) unsigned NOT NULL,
46  `type` varchar(16) NOT NULL,
47  `cond` varchar(16) NULL,
48  `value` text
49) ENGINE=MyISAM DEFAULT CHARSET=utf8
50;');
51 
52  // new column on image category table
53  $result = pwg_query('SHOW COLUMNS FROM `' . IMAGE_CATEGORY_TABLE . '` LIKE "smart";');
54  if (!pwg_db_num_rows($result))
55  {     
56    pwg_query('ALTER TABLE `' . IMAGE_CATEGORY_TABLE . '` ADD `smart` ENUM(\'true\', \'false\') NOT NULL DEFAULT \'false\';');
57  }
58 
59  // new column on category table
60  $result = pwg_query('SHOW COLUMNS FROM `' . CATEGORIES_TABLE . '` LIKE "smart_update";');
61  if (!pwg_db_num_rows($result))
62  {     
63    pwg_query('ALTER TABLE `' . CATEGORIES_TABLE . '` ADD `smart_update` DATETIME NOT NULL;');
64  }
65 
66  // date filters renamed in 2.0
67  $query = '
68SELECT category_id
69  FROM `' . $prefixeTable . 'category_filters`
70  WHERE
71    type = "date" AND
72    cond IN ("the","before","after","the_crea","before_crea","after_crea")
73;';
74
75  if (pwg_db_num_rows(pwg_query($query)))
76  {
77    $name_changes = array(
78      'the' => 'the_post',
79      'before' => 'before_post',
80      'after' => 'after_post',
81      'the_crea' => 'the_taken',
82      'before_crea' => 'before_taken',
83      'after_crea' => 'after_taken',
84      );
85    foreach ($name_changes as $old => $new)
86    {
87      pwg_query('UPDATE `' . $prefixeTable . 'category_filters` SET cond = "'.$new.'" WHERE type = "date" AND cond = "'.$old.'";');
88    }
89  }
90}
91
92?>
Note: See TracBrowser for help on using the repository browser.