source: extensions/BatchDownloader/include/install.inc.php @ 21422

Revision 21422, 2.4 KB checked in by mistic100, 6 years ago (diff)

add option too allow/disallow download of categories/collections/specials

Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4function batch_download_install() 
5{
6  global $conf, $prefixeTable;
7 
8  // configuration
9  if (empty($conf['batch_download']))
10  {
11    $batch_download_default_config = array(
12      'groups'          => array(),
13      'level'           => 0,
14      'what'            => array('categories','specials','collections'),
15      'photo_size'      => 'original',
16      'archive_prefix'  => 'piwigo',
17      'archive_timeout' => 48, /* hours */
18      'max_elements'    => 500,
19      'max_size'        => 100, /* MB */
20      'last_clean'      => time(),
21      );
22     
23    $conf['batch_download'] = serialize($batch_download_default_config);
24    $conf['batch_download_comment'] = null;
25   
26    conf_update_param('batch_download', $conf['batch_download']);
27    conf_update_param('batch_download_comment', $conf['batch_download_comment']);
28  }
29  else
30  {
31    $new_conf = is_string($conf['batch_download']) ? unserialize($conf['batch_download']) : $conf['batch_download'];
32   
33    if (empty($new_conf['what']))
34    {
35      $new_conf['what'] = array('categories','specials','collections');
36     
37      $conf['batch_download'] = serialize($new_conf);
38      conf_update_param('batch_download', $conf['batch_download']);
39    }
40  }
41
42  // archives directory
43  if (!file_exists(PHPWG_ROOT_PATH . $conf['data_location'] . 'download_archives/'))
44  {
45    mkgetdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'download_archives/', MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
46  }
47
48  // create tables
49  $query = '
50CREATE TABLE IF NOT EXISTS `' . $prefixeTable . 'download_sets` (
51  `id` mediumint(8) NOT NULL AUTO_INCREMENT,
52  `user_id` smallint(5) NOT NULL,
53  `date_creation` datetime NOT NULL,
54  `type` varchar(16) CHARACTER SET utf8 NOT NULL,
55  `type_id` varchar(64) CHARACTER SET utf8 NOT NULL,
56  `nb_zip` smallint(3) NOT NULL DEFAULT 0,
57  `last_zip` smallint(3) NOT NULL DEFAULT 0,
58  `nb_images` mediumint(8) NOT NULL DEFAULT 0,
59  `total_size` int(10) NOT NULL DEFAULT 0,
60  `status` enum("new","download","done") CHARACTER SET utf8 NOT NULL DEFAULT "new",
61  PRIMARY KEY (`id`)
62) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1
63;';
64  pwg_query($query);
65 
66  $query = '
67CREATE TABLE IF NOT EXISTS `' . $prefixeTable . 'download_sets_images` (
68  `set_id` mediumint(8) NOT NULL,
69  `image_id` mediumint(8) NOT NULL,
70  `zip` smallint(5) NOT NULL DEFAULT 0,
71  UNIQUE KEY `UNIQUE` (`set_id`,`image_id`)
72) DEFAULT CHARSET=utf8
73;';
74  pwg_query($query);
75}
76
77?>
Note: See TracBrowser for help on using the repository browser.