source: extensions/manage_properties_photos/maintain.class.php @ 32161

Last change on this file since 32161 was 32161, checked in by ddtddt, 4 years ago

[manage_properties_photos]

File size: 6.6 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Manage Properties Photos plugin for Piwigo by TEMMII                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2007-2020 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
22defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
23
24/* definie Typ
250 : default piwigo properties
261 : properties texte
272 : properties date
283 : properties exif
294 : properties select
305 : properties radio
31
32$conf['mpp_idexif'] ** picture id for list exif
33$conf['mpp_max_fields'] ** max fileds for select and radio default 5
34*/
35
36
37class manage_properties_photos_maintain extends PluginMaintain
38{
39  private $installed = false;
40
41  function __construct($plugin_id){
42    parent::__construct($plugin_id);
43  }
44
45  function install($plugin_version, &$errors=array()){
46       global $prefixeTable, $conf;
47
48if (!defined('ADD_PROP_PHOTO_TABLE')) define('ADD_PROP_PHOTO_TABLE', $prefixeTable.'add_properties_photos');
49        $query = "CREATE TABLE IF NOT EXISTS ". ADD_PROP_PHOTO_TABLE ." (
50id_prop_pho SMALLINT(5) UNSIGNED NOT NULL auto_increment,
51wording VARCHAR(255) NOT NULL ,
52orderprop SMALLINT(5) UNSIGNED NOT NULL ,
53active SMALLINT(5) UNSIGNED NOT NULL ,
54edit SMALLINT(5) UNSIGNED NOT NULL ,
55Typ SMALLINT(5) DEFAULT 1,
56dataprop LONGTEXT,
57PRIMARY KEY (id_prop_pho))DEFAULT CHARSET=utf8;";
58        $result = pwg_query($query);
59
60if (!defined('ADD_PROP_PHOTO_DATA_TABLE')) define('ADD_PROP_PHOTO_DATA_TABLE', $prefixeTable.'add_properties_photos_data');
61        $query = "CREATE TABLE IF NOT EXISTS ". ADD_PROP_PHOTO_DATA_TABLE ." (
62id_img SMALLINT(5) UNSIGNED NOT NULL ,
63id_prop_pho SMALLINT(5) UNSIGNED NOT NULL ,
64data VARCHAR(255) NOT NULL ,
65PRIMARY KEY (id_img,id_prop_pho))DEFAULT CHARSET=utf8;";
66        $result = pwg_query($query);
67       
68if (!defined('ADD_PROP_PHOTO_DATADATE_TABLE')) define('ADD_PROP_PHOTO_DATADATE_TABLE', $prefixeTable.'add_properties_photos_datadate');
69        $query = "CREATE TABLE IF NOT EXISTS ". ADD_PROP_PHOTO_DATADATE_TABLE ." (
70                id_img SMALLINT(5) UNSIGNED NOT NULL ,
71                id_prop_pho SMALLINT(5) UNSIGNED NOT NULL ,
72                datadate datetime ,
73                PRIMARY KEY (id_img,id_prop_pho))DEFAULT CHARSET=utf8;";
74        $result = pwg_query($query);
75
76       
77 
78  $activ=unserialize($conf['picture_informations']);
79  if($activ['author']==true){$activauteur=0;}else{$activauteur=1;}
80  if($activ['created_on']==true){$activco=0;}else{$activco=1;}
81  if($activ['posted_on']==true){$activpo=0;}else{$activpo=1;}
82  if($activ['dimensions']==true){$activdim=0;}else{$activdim=1;}
83  if($activ['file']==true){$activfile=0;}else{$activfile=1;}
84  if($activ['filesize']==true){$activfilesize=0;}else{$activfilesize=1;}
85  if($activ['tags']==true){$activtags=0;}else{$activtags=1;}
86  if($activ['categories']==true){$activcategories=0;}else{$activcategories=1;}
87  if($activ['visits']==true){$activvisits=0;}else{$activvisits=1;}
88  if($activ['rating_score']==true){$activrs=0;}else{$activrs=1;}
89  if($activ['privacy_level']==true){$activpl=0;}else{$activpl=1;}
90  $q = 'INSERT INTO ' . $prefixeTable . 'add_properties_photos(id_prop_pho,wording,orderprop,active,edit,Typ)VALUES
91        (1,"author",1,'.$activauteur.',0,0),
92        (2,"Created on",2,'.$activco.',0,0),
93        (3,"Posted on",3,'.$activpo.',0,0),
94        (4,"Dimensions",4,'.$activdim.',0,0),
95        (5,"File",5,'.$activfile.',0,0),
96        (6,"Filesize",6,'.$activfilesize.',0,0),
97        (7,"Tags",7,'.$activtags.',0,0),
98        (8,"Albums",8,'.$activcategories.',0,0),
99        (9,"Visits",9,'.$activvisits.',0,0),
100        (10,"Average",10,'.$activrs.',0,0),
101        (11,"Who can see this photo?",11,'.$activpl.',0,0)
102        ;';
103  pwg_query($q); 
104 
105if (!defined('ADD_PROP_PHOTO_DATADATE_TABLE')) define('ADD_PROP_PHOTO_DATADATE_TABLE', $prefixeTable.'add_properties_photos_datadate');
106        $query = "CREATE TABLE IF NOT EXISTS ". ADD_PROP_PHOTO_DATADATE_TABLE ." (
107id_img SMALLINT(5) UNSIGNED NOT NULL ,
108id_prop_pho SMALLINT(5) UNSIGNED NOT NULL ,
109datadate datetime ,
110PRIMARY KEY (id_img,id_prop_pho))DEFAULT CHARSET=utf8;";
111        $result = pwg_query($query);
112 
113  }
114
115  function activate($plugin_version, &$errors=array()){
116 
117  }
118
119  function update($old_version, $new_version, &$errors=array()){
120       global $prefixeTable;
121if (!defined('ADD_PROP_PHOTO_TABLE')) define('ADD_PROP_PHOTO_TABLE', $prefixeTable.'add_properties_photos'); 
122        /*Update to manage Typ select date*/
123        $col = pwg_db_fetch_assoc(pwg_query("SHOW COLUMNS FROM " . ADD_PROP_PHOTO_TABLE . " LIKE 'Typ';"));
124     if ($col == NULL){
125        $q = 'ALTER TABLE '. ADD_PROP_PHOTO_TABLE.' ADD COLUMN `Typ` SMALLINT(5) DEFAULT 1;';   
126    pwg_query($q);
127        $q = 'ALTER TABLE '. ADD_PROP_PHOTO_TABLE.' ADD COLUMN `dataprop` LONGTEXT;';   
128    pwg_query($q);
129        $q = 'UPDATE '. ADD_PROP_PHOTO_TABLE.' set Typ = 0 where edit =0;';     
130    pwg_query($q);
131         }
132       
133        /*Update for manage date*/
134        if (!defined('ADD_PROP_PHOTO_DATADATE_TABLE')) define('ADD_PROP_PHOTO_DATADATE_TABLE', $prefixeTable.'add_properties_photos_datadate');
135        $datatable= pwg_db_fetch_assoc(pwg_query("SHOW TABLES LIKE '" . ADD_PROP_PHOTO_DATADATE_TABLE . "';"));
136         if ($datatable == NULL){
137                $query = "CREATE TABLE IF NOT EXISTS ". ADD_PROP_PHOTO_DATADATE_TABLE ." (
138                id_img SMALLINT(5) UNSIGNED NOT NULL ,
139                id_prop_pho SMALLINT(5) UNSIGNED NOT NULL ,
140                datadate datetime ,
141                PRIMARY KEY (id_img,id_prop_pho))DEFAULT CHARSET=utf8;";
142                $result = pwg_query($query);
143         }
144 
145  }
146 
147  function deactivate(){
148  }
149
150  function uninstall(){
151          global $prefixeTable;
152    pwg_query('DROP TABLE ' . $prefixeTable . 'add_properties_photos;');
153    pwg_query('DROP TABLE ' . $prefixeTable . 'add_properties_photos_data;');
154        pwg_query('DROP TABLE ' . $prefixeTable . 'add_properties_photos_datadate;');
155  }
156}
157?>
Note: See TracBrowser for help on using the repository browser.