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 | descr text DEFAULT NULL, |
---|
32 | visible bool DEFAULT 0, |
---|
33 | PRIMARY KEY (cr_id) |
---|
34 | ) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 |
---|
35 | ;"; |
---|
36 | pwg_query($query); |
---|
37 | |
---|
38 | $query = " |
---|
39 | CREATE TABLE IF NOT EXISTS ".$prefixeTable."copyrights_media ( |
---|
40 | media_id int(11) NOT NULL, |
---|
41 | cr_id int(11) default NULL |
---|
42 | ) ENGINE = MyISAM DEFAULT CHARACTER SET utf8 |
---|
43 | ;"; |
---|
44 | pwg_query($query); |
---|
45 | } |
---|
46 | |
---|
47 | function plugin_activate() { |
---|
48 | global $prefixeTable; |
---|
49 | |
---|
50 | $query = ' |
---|
51 | SELECT COUNT(*) |
---|
52 | FROM '.$prefixeTable.'copyrights_admin |
---|
53 | ;'; |
---|
54 | list($counter) = pwg_db_fetch_row(pwg_query($query)); |
---|
55 | if (0 == $counter) { |
---|
56 | copyrights_create_default(); |
---|
57 | } |
---|
58 | } |
---|
59 | |
---|
60 | function plugin_uninstall() { |
---|
61 | global $prefixeTable; |
---|
62 | |
---|
63 | $query = " |
---|
64 | DROP TABLE ".$prefixeTable."copyrights_admin |
---|
65 | ;"; |
---|
66 | pwg_query($query); |
---|
67 | |
---|
68 | $query = " |
---|
69 | DROP TABLE ".$prefixeTable."copyrights_media |
---|
70 | ;"; |
---|
71 | pwg_query($query); |
---|
72 | } |
---|
73 | |
---|
74 | function copyrights_create_default() { |
---|
75 | global $prefixeTable; |
---|
76 | |
---|
77 | // Insert the copyrights of Creative Commons |
---|
78 | $inserts = array( |
---|
79 | array( |
---|
80 | 'name' => 'Creative Commons (BY)', |
---|
81 | 'url' => 'http://creativecommons.org/licenses/by/3.0/', |
---|
82 | 'descr' => 'This license lets others distribute, remix, tweak, and build |
---|
83 | upon your work, even commercially, as long as they credit you |
---|
84 | for the original creation. This is the most accommodating of |
---|
85 | licenses offered. Recommended for maximum dissemination and |
---|
86 | use of licensed materials.', |
---|
87 | 'visible' => 1 |
---|
88 | ), |
---|
89 | array( |
---|
90 | 'name' => 'Creative Commons (BY-SA)', |
---|
91 | 'url' => 'http://creativecommons.org/licenses/by-sa/3.0/', |
---|
92 | 'descr' => 'This license lets others remix, tweak, and build upon your |
---|
93 | work even for commercial purposes, as long as they credit you |
---|
94 | and license their new creations under the identical terms. This |
---|
95 | license is often compared to “copyleft” free and open source |
---|
96 | software licenses. All new works based on yours will carry the |
---|
97 | same license, so any derivatives will also allow commercial |
---|
98 | use. This is the license used by Wikipedia, and is recommended |
---|
99 | for materials that would benefit from incorporating content |
---|
100 | from Wikipedia and similarly licensed projects.', |
---|
101 | 'visible' => 1 |
---|
102 | ), |
---|
103 | array( |
---|
104 | 'name' => 'Creative Commons (BY-ND)', |
---|
105 | 'url' => 'http://creativecommons.org/licenses/by-nd/3.0/', |
---|
106 | 'descr' => 'This license allows for redistribution, commercial and |
---|
107 | non-commercial, as long as it is passed along unchanged and in |
---|
108 | whole, with credit to you.', |
---|
109 | 'visible' => 1 |
---|
110 | ), |
---|
111 | array( |
---|
112 | 'name' => 'Creative Commons (BY-NC)', |
---|
113 | 'url' => 'http://creativecommons.org/licenses/by-nc/3.0/', |
---|
114 | 'descr' => 'This license lets others remix, tweak, and build upon your |
---|
115 | work non-commercially, and although their new works must also |
---|
116 | acknowledge you and be non-commercial, they don’t have to |
---|
117 | license their derivative works on the same terms.', |
---|
118 | 'visible' => 1 |
---|
119 | ), |
---|
120 | array( |
---|
121 | 'name' => 'Creative Commons (BY-NC-SA)', |
---|
122 | 'url' => 'http://creativecommons.org/licenses/by-nc-sa/3.0/', |
---|
123 | 'descr' => 'This license lets others remix, tweak, and build upon your |
---|
124 | work non-commercially, as long as they credit you and license |
---|
125 | their new creations under the identical terms.', |
---|
126 | 'visible' => 1 |
---|
127 | ), |
---|
128 | array( |
---|
129 | 'name' => 'Creative Commons (BY-NC-ND)', |
---|
130 | 'url' => 'http://creativecommons.org/licenses/by-nc-nd/3.0/', |
---|
131 | 'descr' => 'This license is the most restrictive of our six main licenses, |
---|
132 | only allowing others to download your works and share them with |
---|
133 | others as long as they credit you, but they can’t change them |
---|
134 | in any way or use them commercially.', |
---|
135 | 'visible' => 1 |
---|
136 | ) |
---|
137 | ); |
---|
138 | |
---|
139 | mass_inserts( |
---|
140 | $prefixeTable.'copyrights_admin', |
---|
141 | array_keys($inserts[0]), |
---|
142 | $inserts |
---|
143 | ); |
---|
144 | } |
---|
145 | |
---|
146 | ?> |
---|