1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK ---------------------------------- |
---|
3 | # This file is part of kUtRL, a plugin for Dotclear 2. |
---|
4 | # |
---|
5 | # Copyright (c) 2009 JC Denis and contributors |
---|
6 | # jcdenis@gdwd.com |
---|
7 | # |
---|
8 | # Licensed under the GPL version 2.0 license. |
---|
9 | # A copy of this license is available in LICENSE file or at |
---|
10 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
11 | # -- END LICENSE BLOCK ------------------------------------ |
---|
12 | |
---|
13 | if (!defined('DC_CONTEXT_ADMIN')){return;} |
---|
14 | |
---|
15 | # Get new version |
---|
16 | $new_version = $core->plugins->moduleInfo('kUtRL','version'); |
---|
17 | $old_version = $core->getVersion('kUtRL'); |
---|
18 | |
---|
19 | # Compare versions |
---|
20 | if (version_compare($old_version,$new_version,'>=')) {return;} |
---|
21 | |
---|
22 | # Install or update |
---|
23 | try |
---|
24 | { |
---|
25 | # Check DC version (dev on) |
---|
26 | if (!version_compare(DC_VERSION,'2.1.6','>=')) |
---|
27 | { |
---|
28 | throw new Exception('Plugin called kUtRL requires Dotclear 2.1.6 or higher.'); |
---|
29 | } |
---|
30 | # Check DC version (new settings) |
---|
31 | if (version_compare(DC_VERSION,'2.2','>=')) |
---|
32 | { |
---|
33 | throw new Exception('Plugin called kUtRL requires Dotclear up to 2.2.'); |
---|
34 | } |
---|
35 | |
---|
36 | # Table |
---|
37 | $s = null; |
---|
38 | $s = new dbStruct($core->con,$core->prefix); |
---|
39 | $s->kutrl |
---|
40 | ->kut_id('bigint',0,false) |
---|
41 | ->blog_id('varchar',32,false) |
---|
42 | ->kut_service('varchar',32,false,"'kUtRL'") |
---|
43 | ->kut_type('varchar',32,false) |
---|
44 | ->kut_hash('varchar',32,false) |
---|
45 | ->kut_url('text',0,false) |
---|
46 | ->kut_dt('timestamp',0,false,'now()') |
---|
47 | ->kut_password('varchar',32,true) |
---|
48 | ->kut_counter('bigint',0,false,0) |
---|
49 | |
---|
50 | ->primary('pk_kutrl','kut_id') |
---|
51 | ->index('idx_kut_blog_id','btree','blog_id') |
---|
52 | ->index('idx_kut_hash','btree','kut_hash') |
---|
53 | ->index('idx_kut_service','btree','kut_service') |
---|
54 | ->index('idx_kut_type','btree','kut_type'); |
---|
55 | |
---|
56 | $si = new dbStruct($core->con,$core->prefix); |
---|
57 | $changes = $si->synchronize($s); |
---|
58 | |
---|
59 | # Settings |
---|
60 | $s = null; |
---|
61 | $s =& $core->blog->settings; |
---|
62 | $s->setNameSpace('kUtRL'); |
---|
63 | $s->put('kutrl_active',false,'boolean','Enabled kutrl plugin',false,true); |
---|
64 | $s->put('kutrl_admin_service','local','string','Service to use to shorten links on admin',false,true); |
---|
65 | $s->put('kutrl_tpl_service','local','string','Service to use to shorten links on template',false,true); |
---|
66 | $s->put('kutrl_wiki_service','','string','Service to use to shorten links on contents',false,true); |
---|
67 | $s->put('kutrl_limit_to_blog',false,'boolean','Limited short url to current blog\'s url',false,true); |
---|
68 | $s->put('kutrl_tpl_passive',true,'boolean','Template return long url if kutrl is unactivate',false,true); |
---|
69 | $s->put('kutrl_admin_entry_default',true,'boolean','Create short link an new entry by default',false,true); |
---|
70 | # Settings for features related to others plugins |
---|
71 | $s->put('kutrl_extend_importexport',true,'boolean','Enabled import/export behaviors',false,true); |
---|
72 | $s->put('kutrl_extend_activityreport',true,'boolean','Enabled activiyReport behaviors',false,true); |
---|
73 | $s->put('kutrl_extend_dcadvancedcleaner',true,'boolean','Enabled activiyReport behaviors',false,true); |
---|
74 | # Settings for "local" service |
---|
75 | $local_css = |
---|
76 | ".shortenkutrlwidget input { border: 1px solid #CCCCCC; }\n". |
---|
77 | ".dc-kutrl input { border: 1px solid #CCCCCC; margin: 10px; }"; |
---|
78 | $s->put('kutrl_srv_local_protocols','http:,https:,ftp:,ftps:,irc:','string','Allowed kutrl local service protocols',false,true); |
---|
79 | $s->put('kutrl_srv_local_public',false,'boolean','Enabled local service public page',false,true); |
---|
80 | $s->put('kutrl_srv_local_css',$local_css,'string','Special CSS for kutrl local service',false,true); |
---|
81 | # Settings for "bilbolinks" service |
---|
82 | $s->put('kutrl_srv_bilbolinks_base','http://tux-pla.net/','string','URL of bilbolinks service',false,true); |
---|
83 | $s->setNameSpace('system'); |
---|
84 | |
---|
85 | # Version |
---|
86 | $core->setVersion('kUtRL',$new_version); |
---|
87 | |
---|
88 | # Get dcMiniUrl records as this plugin do the same |
---|
89 | if ($core->plugins->moduleExists('dcMiniUrl')) |
---|
90 | { |
---|
91 | require_once dirname(__FILE__).'/inc/patch.dcminiurl.php'; |
---|
92 | } |
---|
93 | return true; |
---|
94 | } |
---|
95 | catch (Exception $e) |
---|
96 | { |
---|
97 | $core->error->add($e->getMessage()); |
---|
98 | return false; |
---|
99 | } |
---|
100 | ?> |
---|