source: extensions/see_photos_by_user/maintain.class.php @ 33008

Last change on this file since 33008 was 33008, checked in by ddtddt, 5 months ago

[see_photos_by_user] section user- / updae history and enum

File size: 5.3 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | See photos by user plugin for piwigo  by TEMMII                       |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2014 - 2023 ddtddt             http://temmii.com/piwigo/ |
6// +-----------------------------------------------------------------------+
7// | This program is free software; you can redistribute it and/or modify  |
8// | it under the terms of the GNU General Public License as published by  |
9// | the Free Software Foundation                                          |
10// |                                                                       |
11// | This program is distributed in the hope that it will be useful, but   |
12// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
13// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
14// | General Public License for more details.                              |
15// |                                                                       |
16// | You should have received a copy of the GNU General Public License     |
17// | along with this program; if not, write to the Free Software           |
18// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
19// | USA.                                                                  |
20// +-----------------------------------------------------------------------+
21defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
22
23class see_photos_by_user_maintain extends PluginMaintain
24{
25  private $installed = false;
26
27  function __construct($plugin_id)
28  {
29    parent::__construct($plugin_id);
30  }
31
32  function install($plugin_version, &$errors=array())
33  {
34   
35  }
36
37  function activate($plugin_version, &$errors=array())
38  {
39      global $conf;
40    if (!isset($conf['see_photos_by_user_nbphotos'])) {
41        conf_update_param('see_photos_by_user_nbphotos', '0',true);
42    }
43    if (!isset($conf['see_photos_by_user_limit'])) {
44        conf_update_param('see_photos_by_user_limit', '1000',true);
45    }
46    if (!isset($conf['see_photos_by_user_order'])) {
47        conf_update_param('see_photos_by_user_order', 'username ASC');
48    }
49    if (!isset($conf['see_photos_by_user_show'])||$conf['see_photos_by_user_show']>2) {
50        conf_update_param('see_photos_by_user_show', '1',true);
51    }
52    if (!isset($conf['see_photos_by_user_show_user_home'])) {
53        conf_update_param('see_photos_by_user_show_user_home', '1',true);
54    }
55    if (!isset($conf['see_photos_by_user_color'])) {
56        conf_update_param('see_photos_by_user_color', '#ffffff',true);
57    }
58    if (!isset($conf['see_photos_by_user_shape'])) {
59        conf_update_param('see_photos_by_user_shape', 'sphere',true);
60    }
61       
62        pwg_query('UPDATE '.HISTORY_TABLE.' SET section = \'user-\' WHERE section like \'user-%\'');
63        $history_sections = get_enums(HISTORY_TABLE, 'section');
64        foreach ($history_sections as $key => $value) {
65        if (substr($value,0,5) == 'user-') {
66            unset($history_sections[$key]);
67        }
68    }
69        $history_sections[]='user-';
70        pwg_query('ALTER TABLE '.HISTORY_TABLE.' CHANGE section section enum(\''.implode("','", array_unique($history_sections)).'\') DEFAULT NULL;');
71        conf_update_param('history_sections_cache', get_enums(HISTORY_TABLE, 'section'), true);
72   
73  }
74
75  function update($old_version, $new_version, &$errors=array())
76  {
77    global $conf;
78    if (!isset($conf['see_photos_by_user_nbphotos'])) {
79        conf_update_param('see_photos_by_user_nbphotos', '0',true);
80    }
81    if (!isset($conf['see_photos_by_user_limit'])) {
82        conf_update_param('see_photos_by_user_limit', '1000',true);
83    }
84    if (!isset($conf['see_photos_by_user_order'])) {
85        conf_update_param('see_photos_by_user_order', 'username ASC');
86    }
87    if (!isset($conf['see_photos_by_user_show'])||$conf['see_photos_by_user_show']>2) {
88        conf_update_param('see_photos_by_user_show', '1',true);
89    }
90    if (!isset($conf['see_photos_by_user_show_user_home'])) {
91        conf_update_param('see_photos_by_user_show_user_home', '1',true);
92    }
93    if (!isset($conf['see_photos_by_user_color'])) {
94        conf_update_param('see_photos_by_user_color', '#ffffff',true);
95    }
96    if (!isset($conf['see_photos_by_user_shape'])) {
97        conf_update_param('see_photos_by_user_shape', 'sphere',true);
98    }
99       
100        pwg_query('UPDATE '.HISTORY_TABLE.' SET section = \'user-\' WHERE section like \'user-%\'');
101        $history_sections = get_enums(HISTORY_TABLE, 'section');
102        foreach ($history_sections as $key => $value) {
103        if (substr($value,0,5) == 'user-') {
104            unset($history_sections[$key]);
105        }
106    }
107        $history_sections[]='user-';
108        pwg_query('ALTER TABLE '.HISTORY_TABLE.' CHANGE section section enum(\''.implode("','", array_unique($history_sections)).'\') DEFAULT NULL;');
109        conf_update_param('history_sections_cache', get_enums(HISTORY_TABLE, 'section'), true);
110       
111  }
112 
113  function deactivate()
114  {
115  }
116
117  function uninstall()
118  {
119    conf_delete_param('see_photos_by_user_nbphotos');
120        conf_delete_param('see_photos_by_user_limit');
121        conf_delete_param('see_photos_by_user_order');
122        conf_delete_param('see_photos_by_user_show');
123        conf_delete_param('see_photos_by_user_show_user_home');
124        conf_delete_param('see_photos_by_user_color');
125        conf_delete_param('see_photos_by_user_shape');
126  }
127}
128?>
Note: See TracBrowser for help on using the repository browser.