1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based picture gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008-2009 Piwigo Team http://piwigo.org | |
---|
6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | // | This program is free software; you can redistribute it and/or modify | |
---|
10 | // | it under the terms of the GNU General Public License as published by | |
---|
11 | // | the Free Software Foundation | |
---|
12 | // | | |
---|
13 | // | This program is distributed in the hope that it will be useful, but | |
---|
14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
16 | // | General Public License for more details. | |
---|
17 | // | | |
---|
18 | // | You should have received a copy of the GNU General Public License | |
---|
19 | // | along with this program; if not, write to the Free Software | |
---|
20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
21 | // | USA. | |
---|
22 | // +-----------------------------------------------------------------------+ |
---|
23 | |
---|
24 | function plugin_install() { |
---|
25 | global $conf, $prefixeTable; |
---|
26 | $query = " |
---|
27 | CREATE TABLE IF NOT EXISTS ".$prefixeTable."copyrights_admin ( |
---|
28 | cr_id int(11) NOT NULL AUTO_INCREMENT, |
---|
29 | name varchar(255) UNIQUE NOT NULL, |
---|
30 | url varchar(255) NOT NULL, |
---|
31 | visible bool DEFAULT 0, |
---|
32 | PRIMARY KEY (cr_id) |
---|
33 | ) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 |
---|
34 | ;"; |
---|
35 | pwg_query($query); |
---|
36 | |
---|
37 | $query = " |
---|
38 | CREATE TABLE IF NOT EXISTS ".$prefixeTable."copyrights_media ( |
---|
39 | media_id int(11) NOT NULL, |
---|
40 | cr_id int(11) default NULL |
---|
41 | ) ENGINE = MyISAM DEFAULT CHARACTER SET utf8 |
---|
42 | ;"; |
---|
43 | pwg_query($query); |
---|
44 | } |
---|
45 | |
---|
46 | function plugin_activate() { |
---|
47 | global $prefixeTable; |
---|
48 | |
---|
49 | $query = " |
---|
50 | SELECT COUNT(*) |
---|
51 | FROM ".$prefixeTable."copyrights_admin |
---|
52 | ;"; |
---|
53 | list($counter) = pwg_db_fetch_row(pwg_query($query)); |
---|
54 | if (0 == $counter) { |
---|
55 | copyrights_create_default(); |
---|
56 | } |
---|
57 | } |
---|
58 | |
---|
59 | function plugin_uninstall() { |
---|
60 | global $prefixeTable; |
---|
61 | |
---|
62 | $query = " |
---|
63 | DROP TABLE ".$prefixeTable."copyrights_admin |
---|
64 | ;"; |
---|
65 | pwg_query($query); |
---|
66 | |
---|
67 | $query = " |
---|
68 | DROP TABLE ".$prefixeTable."copyrights_media |
---|
69 | ;"; |
---|
70 | pwg_query($query); |
---|
71 | } |
---|
72 | |
---|
73 | function copyrights_create_default() { |
---|
74 | global $prefixeTable; |
---|
75 | |
---|
76 | // Insert the copyrights of Creative Commons |
---|
77 | $inserts = array( |
---|
78 | array( |
---|
79 | 'name' => 'Creative Commons (BY)', |
---|
80 | 'url' => 'http://creativecommons.org/licenses/by/3.0/', |
---|
81 | 'visible' => 1 |
---|
82 | ), |
---|
83 | array( |
---|
84 | 'name' => 'Creative Commons (BY-SA)', |
---|
85 | 'url' => 'http://creativecommons.org/licenses/by-sa/3.0/', |
---|
86 | 'visible' => 1 |
---|
87 | ), |
---|
88 | array( |
---|
89 | 'name' => 'Creative Commons (BY-ND)', |
---|
90 | 'url' => 'http://creativecommons.org/licenses/by-nd/3.0/', |
---|
91 | 'visible' => 1 |
---|
92 | ), |
---|
93 | array( |
---|
94 | 'name' => 'Creative Commons (BY-NC)', |
---|
95 | 'url' => 'http://creativecommons.org/licenses/by-nc/3.0/', |
---|
96 | 'visible' => 1 |
---|
97 | ), |
---|
98 | array( |
---|
99 | 'name' => 'Creative Commons (BY-NC-SA)', |
---|
100 | 'url' => 'http://creativecommons.org/licenses/by-nc-sa/3.0/', |
---|
101 | 'visible' => 1 |
---|
102 | ), |
---|
103 | array( |
---|
104 | 'name' => 'Creative Commons (BY-NC-ND)', |
---|
105 | 'url' => 'http://creativecommons.org/licenses/by-nc-nd/3.0/', |
---|
106 | 'visible' => 1 |
---|
107 | ) |
---|
108 | ); |
---|
109 | |
---|
110 | mass_inserts( |
---|
111 | $prefixeTable.'copyrights_admin', |
---|
112 | array( |
---|
113 | 'name', |
---|
114 | 'url', |
---|
115 | 'visible' |
---|
116 | ), |
---|
117 | $inserts |
---|
118 | ); |
---|
119 | } |
---|