source: extensions/title/maintain.class.php @ 32013

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

[extensions] - title - 2.8

File size: 5.0 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Title plugin for piwigo                                               |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2011 - 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
22if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
23
24class title_maintain extends PluginMaintain
25{
26  function install($plugin_version, &$errors=array())
27  {
28    global $conf, $prefixeTable;
29
30    $q = 'CREATE TABLE IF NOT EXISTS ' . $prefixeTable . 'title(
31id SMALLINT( 5 ) UNSIGNED NOT NULL ,
32page VARCHAR( 255 ) NOT NULL ,
33title lONGTEXT NOT NULL ,
34PRIMARY KEY (id))DEFAULT CHARSET=utf8;';
35    pwg_query($q);
36       
37        $q = '
38INSERT INTO ' . $prefixeTable . 'title(id,page,title)VALUES (1,"home","");';
39    pwg_query($q);
40        $q = '
41INSERT INTO ' . $prefixeTable . 'title(id,page,title)VALUES (2,"best_rated","");';
42    pwg_query($q);
43                $q = '
44INSERT INTO ' . $prefixeTable . 'title(id,page,title)VALUES (3,"most_visited","");';
45    pwg_query($q);
46                $q = '
47INSERT INTO ' . $prefixeTable . 'title(id,page,title)VALUES (4,"recent_pics","");';
48    pwg_query($q);
49                $q = '
50INSERT INTO ' . $prefixeTable . 'title(id,page,title)VALUES (5,"recent_cats","");';
51    pwg_query($q);
52                $q = '
53INSERT INTO ' . $prefixeTable . 'title(id,page,title)VALUES (6,"favorites","");';
54    pwg_query($q);     
55                $q = '
56INSERT INTO ' . $prefixeTable . 'title(id,page,title)VALUES (7,"tags","");';
57    pwg_query($q);
58                $q = '
59INSERT INTO ' . $prefixeTable . 'title(id,page,title)VALUES (8,"comments","");';
60    pwg_query($q);
61                $q = '
62INSERT INTO ' . $prefixeTable . 'title(id,page,title)VALUES (9,"about","");';
63    pwg_query($q);
64                $q = '
65INSERT INTO ' . $prefixeTable . 'title(id,page,title)VALUES (10,"search","");';
66    pwg_query($q);
67                $q = '
68INSERT INTO ' . $prefixeTable . 'title(id,page,title)VALUES (11,"random","");';
69    pwg_query($q);
70                $q = '
71INSERT INTO ' . $prefixeTable . 'title(id,page,title)VALUES (12,"notification","");';
72    pwg_query($q);     
73       
74if (!defined('TITLE_PHOTO_TABLE')) define('TITLE_PHOTO_TABLE', $prefixeTable.'title_photo');
75        $query = "CREATE TABLE IF NOT EXISTS ". TITLE_PHOTO_TABLE ." (
76id SMALLINT( 5 ) UNSIGNED NOT NULL ,
77title VARCHAR( 255 ) NOT NULL ,
78PRIMARY KEY (id))DEFAULT CHARSET=utf8;";
79        $result = pwg_query($query);
80
81if (!defined('TITLE_ALBUM_TABLE')) define('TITLE_ALBUM_TABLE', $prefixeTable.'title_album');   
82        $query = "CREATE TABLE IF NOT EXISTS ". TITLE_ALBUM_TABLE ." (
83id SMALLINT( 5 ) UNSIGNED NOT NULL ,
84title VARCHAR( 255 ) NOT NULL ,
85PRIMARY KEY (id))DEFAULT CHARSET=utf8;";
86        $result = pwg_query($query);
87       
88  if (empty($conf['contacttitle']))
89  {
90        conf_update_param('contacttitle', '');
91  }
92 
93        if (!defined('TITLE_AP_TABLE')) define('TITLE_AP_TABLE', $prefixeTable.'title_ap');     
94        $query = "CREATE TABLE IF NOT EXISTS ". TITLE_AP_TABLE ." (
95id SMALLINT( 5 ) UNSIGNED NOT NULL ,
96title VARCHAR( 255 ) NOT NULL ,
97PRIMARY KEY (id))DEFAULT CHARSET=utf8;";
98        $result = pwg_query($query);
99  }
100
101  function update($old_version, $new_version, &$errors=array())
102  {
103        //$this->install($new_version, $errors);
104        global $conf, $prefixeTable;
105  if (!isset($conf['contacttitle']))
106  {
107        conf_update_param('contacttitle', '');
108  }
109 
110        if (!defined('TITLE_AP_TABLE')) define('TITLE_AP_TABLE', $prefixeTable.'title_ap');     
111        $query = "CREATE TABLE IF NOT EXISTS ". TITLE_AP_TABLE ." (
112id SMALLINT( 5 ) UNSIGNED NOT NULL ,
113title VARCHAR( 255 ) NOT NULL ,
114PRIMARY KEY (id))DEFAULT CHARSET=utf8;";
115        $result = pwg_query($query);
116       
117  }
118
119  function uninstall()
120  {
121        global $prefixeTable;
122
123        $q = 'DROP TABLE ' . $prefixeTable . 'title;';
124    pwg_query($q);
125       
126        $q = 'DROP TABLE ' . $prefixeTable . 'title_photo;';
127    pwg_query($q);
128
129        $q = 'DROP TABLE ' . $prefixeTable . 'title_album;';
130    pwg_query($q);
131       
132        $q = 'DROP TABLE ' . $prefixeTable . 'title_ap;';
133    pwg_query($q);
134       
135        conf_delete_param('contacttitle');
136
137  }
138}
Note: See TracBrowser for help on using the repository browser.