1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | User Custom Fields plugin for Piwigo by TEMMII | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2016-2021 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 user_custom_fields_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 | if (!defined('UCF_TABLE')) define('UCF_TABLE', $prefixeTable.'user_custom_fields'); |
---|
35 | $query = "CREATE TABLE IF NOT EXISTS ". UCF_TABLE ." ( |
---|
36 | id_ucf SMALLINT(5) UNSIGNED NOT NULL auto_increment, |
---|
37 | wording VARCHAR(255) NOT NULL , |
---|
38 | order_ucf SMALLINT(5) UNSIGNED NOT NULL , |
---|
39 | active SMALLINT(5) UNSIGNED NOT NULL , |
---|
40 | edit SMALLINT(5) UNSIGNED NOT NULL , |
---|
41 | adminonly SMALLINT(5) UNSIGNED NOT NULL , |
---|
42 | obligatory SMALLINT(5) UNSIGNED NOT NULL , |
---|
43 | PRIMARY KEY (id_ucf))DEFAULT CHARSET=utf8;"; |
---|
44 | $result = pwg_query($query); |
---|
45 | |
---|
46 | if (!defined('UCFD_TABLE')) define('UCFD_TABLE', $prefixeTable.'user_custom_fields_data'); |
---|
47 | $query = "CREATE TABLE IF NOT EXISTS ". UCFD_TABLE ." ( |
---|
48 | id_user SMALLINT(5) UNSIGNED NOT NULL , |
---|
49 | id_ucf SMALLINT(5) UNSIGNED NOT NULL , |
---|
50 | data VARCHAR(255) NOT NULL , |
---|
51 | PRIMARY KEY (id_user,id_ucf))DEFAULT CHARSET=utf8;"; |
---|
52 | $result = pwg_query($query); |
---|
53 | |
---|
54 | if($conf['obligatory_user_mail_address']==true){$oblisend=1;}else{$oblisend=0;} |
---|
55 | |
---|
56 | $q = 'INSERT INTO ' . UCF_TABLE . ' (id_ucf,wording,order_ucf,active,edit,adminonly,obligatory)VALUES |
---|
57 | (1,"Username",1,1,0,0,1), |
---|
58 | (2,"password",2,1,0,0,1), |
---|
59 | (3,"mail_address",3,1,0,0,1), |
---|
60 | (4,"send_mail",4,1,0,0,'.$oblisend.') |
---|
61 | ;'; |
---|
62 | pwg_query($q); |
---|
63 | |
---|
64 | } |
---|
65 | |
---|
66 | function activate($plugin_version, &$errors=array()){ |
---|
67 | |
---|
68 | } |
---|
69 | |
---|
70 | function update($old_version, $new_version, &$errors=array()){ |
---|
71 | |
---|
72 | } |
---|
73 | |
---|
74 | function deactivate(){ |
---|
75 | } |
---|
76 | |
---|
77 | function uninstall(){ |
---|
78 | global $prefixeTable; |
---|
79 | $q = 'DROP TABLE ' . $prefixeTable . 'user_custom_fields;'; |
---|
80 | pwg_query($q); |
---|
81 | $q = 'DROP TABLE ' . $prefixeTable . 'user_custom_fields_data;'; |
---|
82 | pwg_query($q); |
---|
83 | } |
---|
84 | } |
---|
85 | ?> |
---|