1 | <?php |
---|
2 | |
---|
3 | /* |
---|
4 | * Plugin Blockreferer |
---|
5 | * Copyright (C) 2007 Pierre Andrews |
---|
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, either version 3 of the License, or |
---|
10 | * (at your option) any later version. |
---|
11 | * |
---|
12 | * This program is distributed in the hope that it will be useful, |
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | * GNU General Public License for more details. |
---|
16 | * |
---|
17 | * You should have received a copy of the GNU General Public License |
---|
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
19 | */ |
---|
20 | |
---|
21 | |
---|
22 | function blockreferer_droptables() { |
---|
23 | spip_query("DROP TABLE IF EXISTS ".$GLOBALS['table_prefix']."_blockreferer_blacklist;"); |
---|
24 | } |
---|
25 | |
---|
26 | function blockreferer_doupgrade() { |
---|
27 | include_spip('base/blockreferer_db'); |
---|
28 | $installe = $GLOBALS['meta']['blockreferer:installe']; |
---|
29 | $uptodate = $installe && ($installe == $GLOBALS['blockrefererdb_version']); |
---|
30 | if(!$uptodate) { |
---|
31 | include_spip('base/create'); |
---|
32 | include_spip('base/abstract_sql'); |
---|
33 | creer_base(); |
---|
34 | ecrire_meta('blockreferer:installe',$GLOBALS['blockrefererdb_version']); |
---|
35 | ecrire_metas(); |
---|
36 | } |
---|
37 | } |
---|
38 | |
---|
39 | function blockreferer_install($action){ |
---|
40 | switch ($action){ |
---|
41 | case 'test': |
---|
42 | include_spip('base/blockreferer_db'); |
---|
43 | //Contrôle du plugin à chaque chargement de la page d'administration |
---|
44 | $installe = $GLOBALS['meta']['blockreferer:installe']; |
---|
45 | $uptodate = $installe && ($installe == $GLOBALS['blockrefererdb_version']); |
---|
46 | return $uptodate; |
---|
47 | break; |
---|
48 | case 'install': |
---|
49 | blockreferer_doupgrade(); |
---|
50 | break; |
---|
51 | case 'uninstall': |
---|
52 | //Appel de la fonction de suppression |
---|
53 | blockreferer_droptables(); |
---|
54 | effacer_meta('blockreferer:installe'); |
---|
55 | ecrire_metas(); |
---|
56 | break; |
---|
57 | } |
---|
58 | } |
---|
59 | |
---|
60 | ?> |
---|