1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK ---------------------------------- |
---|
3 | # |
---|
4 | # This file is part of dcFilterDuplicate, a plugin for Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2009-2013 Jean-Christian Denis and contributors |
---|
7 | # contact@jcdenis.fr http://jcd.lv |
---|
8 | # |
---|
9 | # Licensed under the GPL version 2.0 license. |
---|
10 | # A copy of this license is available in LICENSE file or at |
---|
11 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
12 | # |
---|
13 | # -- END LICENSE BLOCK ------------------------------------ |
---|
14 | |
---|
15 | if (!defined('DC_CONTEXT_ADMIN')) { |
---|
16 | |
---|
17 | return null; |
---|
18 | } |
---|
19 | |
---|
20 | # -- Module specs -- |
---|
21 | |
---|
22 | $dc_min = '2.6'; |
---|
23 | $mod_id = 'dcFilterDuplicate'; |
---|
24 | $mod_conf = array( |
---|
25 | array( |
---|
26 | 'dcfilterduplicate_minlen', |
---|
27 | 'Minimum lenght of comment to filter', |
---|
28 | 30, |
---|
29 | 'integer' |
---|
30 | ) |
---|
31 | ); |
---|
32 | |
---|
33 | # -- Nothing to change below -- |
---|
34 | |
---|
35 | try { |
---|
36 | |
---|
37 | # Check module version |
---|
38 | if (version_compare( |
---|
39 | $core->getVersion($mod_id), |
---|
40 | $core->plugins->moduleInfo($mod_id, 'version'), |
---|
41 | '>=' |
---|
42 | )) { |
---|
43 | |
---|
44 | return null; |
---|
45 | } |
---|
46 | |
---|
47 | # Check Dotclear version |
---|
48 | if (!method_exists('dcUtils', 'versionsCompare') |
---|
49 | || dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) { |
---|
50 | throw new Exception(sprintf( |
---|
51 | '%s requires Dotclear %s', $mod_id, $dc_min |
---|
52 | )); |
---|
53 | } |
---|
54 | |
---|
55 | # Set module settings |
---|
56 | $core->blog->settings->addNamespace($mod_id); |
---|
57 | foreach($mod_conf as $v) { |
---|
58 | $core->blog->settings->{$mod_id}->put( |
---|
59 | $v[0], $v[2], $v[3], $v[1], false, true |
---|
60 | ); |
---|
61 | } |
---|
62 | |
---|
63 | # Set module version |
---|
64 | $core->setVersion( |
---|
65 | $mod_id, |
---|
66 | $core->plugins->moduleInfo($mod_id, 'version') |
---|
67 | ); |
---|
68 | |
---|
69 | return true; |
---|
70 | } |
---|
71 | catch (Exception $e) { |
---|
72 | $core->error->add($e->getMessage()); |
---|
73 | |
---|
74 | return false; |
---|
75 | } |
---|