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, $conf; |
---|
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 | $activ=unserialize($conf['picture_informations']); |
---|
53 | if($activ['author']==true){$activauteur=0;}else{$activauteur=1;} |
---|
54 | if($activ['created_on']==true){$activco=0;}else{$activco=1;} |
---|
55 | if($activ['posted_on']==true){$activpo=0;}else{$activpo=1;} |
---|
56 | if($activ['dimensions']==true){$activdim=0;}else{$activdim=1;} |
---|
57 | if($activ['file']==true){$activfile=0;}else{$activfile=1;} |
---|
58 | if($activ['filesize']==true){$activfilesize=0;}else{$activfilesize=1;} |
---|
59 | if($activ['tags']==true){$activtags=0;}else{$activtags=1;} |
---|
60 | if($activ['categories']==true){$activcategories=0;}else{$activcategories=1;} |
---|
61 | if($activ['visits']==true){$activvisits=0;}else{$activvisits=1;} |
---|
62 | if($activ['rating_score']==true){$activrs=0;}else{$activrs=1;} |
---|
63 | if($activ['privacy_level']==true){$activpl=0;}else{$activpl=1;} |
---|
64 | $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit)VALUES |
---|
65 | (1,"author",1,'.$activauteur.',0), |
---|
66 | (2,"Created on",2,'.$activco.',0), |
---|
67 | (3,"Posted on",3,'.$activpo.',0), |
---|
68 | (4,"Dimensions",4,'.$activdim.',0), |
---|
69 | (5,"File",5,'.$activfile.',0), |
---|
70 | (6,"Filesize",6,'.$activfilesize.',0), |
---|
71 | (7,"Tags",7,'.$activtags.',0), |
---|
72 | (8,"Albums",8,'.$activcategories.',0), |
---|
73 | (9,"Visits",9,'.$activvisits.',0), |
---|
74 | (10,"Average",10,'.$activrs.',0), |
---|
75 | (11,"Who can see this photo?",11,'.$activpl.',0), |
---|
76 | (12,"Description",12,1,0) |
---|
77 | ;'; |
---|
78 | pwg_query($q); |
---|
79 | |
---|
80 | } |
---|
81 | |
---|
82 | function activate($plugin_version, &$errors=array()){ |
---|
83 | |
---|
84 | } |
---|
85 | |
---|
86 | function update($old_version, $new_version, &$errors=array()){ |
---|
87 | global $prefixeTable; |
---|
88 | if (!defined('ADD_PROP_PHOTO_TABLE')) define('ADD_PROP_PHOTO_TABLE', $prefixeTable.'add_properties_photos'); |
---|
89 | $desc = pwg_db_fetch_assoc(pwg_query("SELECT wording FROM " . ADD_PROP_PHOTO_TABLE . " WHERE wording = 'Description' LIMIT 1;")); |
---|
90 | if ($desc == NULL){ |
---|
91 | $order=pwg_db_fetch_assoc(pwg_query('SELECT orderprop FROM ' . ADD_PROP_PHOTO_TABLE . ' ORDER BY orderprop DESC LIMIT 1;')); |
---|
92 | $order=$order['orderprop']+1; |
---|
93 | $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(wording,orderprop,active,edit)VALUES ("Description",'.$order.',1,0);'; |
---|
94 | pwg_query($q); |
---|
95 | } |
---|
96 | |
---|
97 | } |
---|
98 | |
---|
99 | function deactivate(){ |
---|
100 | } |
---|
101 | |
---|
102 | function uninstall(){ |
---|
103 | global $prefixeTable; |
---|
104 | $q = 'DROP TABLE ' . $prefixeTable . 'add_properties_photos;'; |
---|
105 | pwg_query($q); |
---|
106 | $q = 'DROP TABLE ' . $prefixeTable . 'add_properties_photos_data;'; |
---|
107 | pwg_query($q); |
---|
108 | } |
---|
109 | } |
---|
110 | ?> |
---|