1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Manage Properties Photos plugin for Piwigo | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2014-2016 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 | // +-----------------------------------------------------------------------+ |
---|
21 | |
---|
22 | defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); |
---|
23 | |
---|
24 | class manage_properties_photos_maintain extends PluginMaintain |
---|
25 | { |
---|
26 | private $installed = false; |
---|
27 | |
---|
28 | function __construct($plugin_id){ |
---|
29 | parent::__construct($plugin_id); |
---|
30 | } |
---|
31 | |
---|
32 | function install($plugin_version, &$errors=array()){ |
---|
33 | global $prefixeTable; |
---|
34 | |
---|
35 | if (!defined('ADD_PROP_PHOTO_TABLE')) define('ADD_PROP_PHOTO_TABLE', $prefixeTable.'add_properties_photos'); |
---|
36 | $query = "CREATE TABLE IF NOT EXISTS ". ADD_PROP_PHOTO_TABLE ." ( |
---|
37 | id_prop_pho SMALLINT(5) UNSIGNED NOT NULL auto_increment, |
---|
38 | wording VARCHAR(255) NOT NULL , |
---|
39 | orderprop SMALLINT(5) UNSIGNED NOT NULL , |
---|
40 | active SMALLINT(5) UNSIGNED NOT NULL , |
---|
41 | edit SMALLINT(5) UNSIGNED NOT NULL , |
---|
42 | PRIMARY KEY (id_prop_pho))DEFAULT CHARSET=utf8;"; |
---|
43 | $result = pwg_query($query); |
---|
44 | |
---|
45 | if (!defined('ADD_PROP_PHOTO_DATA_TABLE')) define('ADD_PROP_PHOTO_DATA_TABLE', $prefixeTable.'add_properties_photos_data'); |
---|
46 | $query = "CREATE TABLE IF NOT EXISTS ". ADD_PROP_PHOTO_DATA_TABLE ." ( |
---|
47 | id_img SMALLINT(5) UNSIGNED NOT NULL , |
---|
48 | id_prop_pho SMALLINT(5) UNSIGNED NOT NULL , |
---|
49 | data VARCHAR(255) NOT NULL , |
---|
50 | PRIMARY KEY (id_img,id_prop_pho))DEFAULT CHARSET=utf8;"; |
---|
51 | $result = pwg_query($query); |
---|
52 | |
---|
53 | $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit)VALUES (1,"author",1,0,0);'; |
---|
54 | pwg_query($q); |
---|
55 | $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit)VALUES (2,"Created on",2,0,0);'; |
---|
56 | pwg_query($q); |
---|
57 | $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit)VALUES (3,"Posted on",3,0,0);'; |
---|
58 | pwg_query($q); |
---|
59 | $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit)VALUES (4,"Dimensions",4,0,0);'; |
---|
60 | pwg_query($q); |
---|
61 | $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit)VALUES (5,"File",5,0,0);'; |
---|
62 | pwg_query($q); |
---|
63 | $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit)VALUES (6,"Filesize",6,0,0);'; |
---|
64 | pwg_query($q); |
---|
65 | $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit)VALUES (7,"Tags",7,0,0);'; |
---|
66 | pwg_query($q); |
---|
67 | $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit)VALUES (8,"Albums",8,0,0);'; |
---|
68 | pwg_query($q); |
---|
69 | $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit)VALUES (9,"Visits",9,0,0);'; |
---|
70 | pwg_query($q); |
---|
71 | $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit)VALUES (10,"Average",10,0,0);'; |
---|
72 | pwg_query($q); |
---|
73 | $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit)VALUES (11,"Who can see this photo?",11,0,0);'; |
---|
74 | pwg_query($q); |
---|
75 | |
---|
76 | } |
---|
77 | |
---|
78 | function activate($plugin_version, &$errors=array()){ |
---|
79 | |
---|
80 | } |
---|
81 | |
---|
82 | function update($old_version, $new_version, &$errors=array()){ |
---|
83 | global $prefixeTable; |
---|
84 | if (!defined('ADD_PROP_PHOTO_TABLE')) define('ADD_PROP_PHOTO_TABLE', $prefixeTable.'add_properties_photos'); |
---|
85 | $desc = pwg_db_fetch_assoc(pwg_query("SELECT wording FROM " . ADD_PROP_PHOTO_TABLE . " WHERE wording = 'Description' LIMIT 1;")); |
---|
86 | if ($desc == NULL){ |
---|
87 | $order=pwg_db_fetch_assoc(pwg_query('SELECT orderprop FROM ' . ADD_PROP_PHOTO_TABLE . ' ORDER BY orderprop DESC LIMIT 1;')); |
---|
88 | $order=$order['orderprop']+1; |
---|
89 | $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(wording,orderprop,active,edit)VALUES ("Description",'.$order.',1,0);'; |
---|
90 | pwg_query($q); |
---|
91 | } |
---|
92 | |
---|
93 | } |
---|
94 | |
---|
95 | function deactivate(){ |
---|
96 | } |
---|
97 | |
---|
98 | function uninstall(){ |
---|
99 | $q = 'DROP TABLE ' . $prefixeTable . 'add_properties_photos;'; |
---|
100 | pwg_query($q); |
---|
101 | $q = 'DROP TABLE ' . $prefixeTable . 'add_properties_photos_data;'; |
---|
102 | pwg_query($q); |
---|
103 | } |
---|
104 | } |
---|
105 | ?> |
---|