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

Last change on this file since 31409 was 31409, checked in by ddtddt, 8 years ago

[extensions] - manage_properties_photos

File size: 5.3 KB
Line 
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
22defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
23
24class 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
35if (!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 ." (
37id_prop_pho SMALLINT(5) UNSIGNED NOT NULL auto_increment,
38wording VARCHAR(255) NOT NULL ,
39orderprop SMALLINT(5) UNSIGNED NOT NULL ,
40active SMALLINT(5) UNSIGNED NOT NULL ,
41edit SMALLINT(5) UNSIGNED NOT NULL ,
42PRIMARY KEY (id_prop_pho))DEFAULT CHARSET=utf8;";
43        $result = pwg_query($query);
44
45if (!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 ." (
47id_img SMALLINT(5) UNSIGNED NOT NULL ,
48id_prop_pho SMALLINT(5) UNSIGNED NOT NULL ,
49data VARCHAR(255) NOT NULL ,
50PRIMARY 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?>
Note: See TracBrowser for help on using the repository browser.