source: extensions/Extended_author/maintain.inc.php @ 11819

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

Added all files to the svn repository

File size: 3.4 KB
Line 
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
24function plugin_install($plugin_id, $plugin_version, &$errors) {
25  global $conf, $prefixeTable;
26  load_language('plugin.lang', dirname(__FILE__).'/');
27 
28  // Check if the copyrights plugin is there
29  $query = '
30    SELECT `id`
31        FROM '.$prefixeTable.'plugins
32        WHERE id=\'Copyrights\'
33    ;';
34  $result = pwg_query($query);
35  // if not, cancel the install
36  if (!pwg_db_fetch_assoc($result)) {
37        $msg = l10n('To install this plugin, you need to install the <a href="http://piwigo.org/ext/extension_view.php?eid=537">Copyrights plugin</a> first.');
38        if(is_array($errors)) {
39          array_push($errors, $msg);
40        } else {
41          $errors=Array($msg);
42        }
43        return false;
44  }
45 
46  // Create the author table
47  $query = '
48    CREATE TABLE IF NOT EXISTS '.$prefixeTable.'author_extended (
49          author_id int(11) NOT NULL AUTO_INCREMENT,
50      name varchar(255) UNIQUE NOT NULL,
51      url varchar(255),
52      descr text DEFAULT NULL,
53          copyright int(11) DEFAULT NULL,
54      PRIMARY KEY (author_id)
55    ) ENGINE=MyISAM DEFAULT CHARACTER SET utf8
56    ;';
57  pwg_query($query);
58 
59  // Temporary disable the auto increment
60  $query = '
61        ALTER TABLE '.$prefixeTable.'copyrights_admin
62        MODIFY cr_id int(11) NOT NULL
63    ;';
64  pwg_query($query);
65  // Insert "author's default copyright" in the copyrights table. On duplicates, it does nothing.
66  $query = '
67        INSERT INTO '.$prefixeTable.'copyrights_admin
68        VALUES (-1, \'Author\'s default copyright\', \'\', \'This is the default copyright for an author.\', 1)
69        ON DUPLICATE KEY UPDATE cr_id = -1
70    ;';
71  pwg_query($query);
72  // Reenable the auto increment
73  $query = '
74        ALTER TABLE '.$prefixeTable.'copyrights_admin
75        MODIFY cr_id int(11) NOT NULL AUTO_INCREMENT
76    ;';
77  pwg_query($query);
78}
79
80function plugin_uninstall() {
81  global $prefixeTable;
82 
83  // Drop the author table
84  $query = '
85    DROP TABLE '.$prefixeTable.'author_extended
86    ;';
87  pwg_query($query);
88}
89
90?>
Note: See TracBrowser for help on using the repository browser.