source: extensions/Copyrights/maintain.inc.php @ 15903

Last change on this file since 15903 was 12192, checked in by Mattias, 13 years ago

Fixed a small bug with single quotes in the copyright name
and some very small things

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