1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK ---------------------------------- |
---|
3 | # This file is part of eventdata, 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_RC_PATH')) return; |
---|
14 | |
---|
15 | class eventdataInstall |
---|
16 | { |
---|
17 | public static function pluginsBeforeDelete($plugin) |
---|
18 | { |
---|
19 | if($plugin['id'] == 'eventdata') { |
---|
20 | http::redirect('plugin.php?p=eventdata&t=uninstall'); |
---|
21 | exit; |
---|
22 | } |
---|
23 | } |
---|
24 | |
---|
25 | public static function setTable(&$core) |
---|
26 | { |
---|
27 | # Database schema |
---|
28 | $s = new dbStruct($core->con,$core->prefix); |
---|
29 | $s->eventdata |
---|
30 | ->post_id ('bigint',0,false) |
---|
31 | ->eventdata_start ('timestamp',0,false,'now()') |
---|
32 | ->eventdata_end ('timestamp',0,false,'now()') |
---|
33 | ->eventdata_type('varchar',64,false) |
---|
34 | ->primary('pk_eventdata','eventdata_type','post_id','eventdata_start','eventdata_end') |
---|
35 | ->index('idx_eventdata_post_id','btree','post_id') |
---|
36 | ->index('idx_eventdata_event_type','btree','eventdata_type') |
---|
37 | ->index('idx_eventdata_event_start','btree','eventdata_start') |
---|
38 | ->index('idx_eventdata_event_end','btree','eventdata_end') |
---|
39 | ->reference('fk_eventdata_post','post_id','post','post_id','cascade','cascade'); |
---|
40 | # Schema installation |
---|
41 | $si = new dbStruct($core->con,$core->prefix); |
---|
42 | $changes = $si->synchronize($s); |
---|
43 | } |
---|
44 | |
---|
45 | public static function delTable(&$core) |
---|
46 | { |
---|
47 | @$core->con->execute('TRUNCATE TABLE '.$core->con->escape($core->prefix.'eventdata').''); |
---|
48 | @$core->con->execute('DROP TABLE '.$core->con->escape($core->prefix.'eventdata').''); |
---|
49 | } |
---|
50 | |
---|
51 | public static function setSettings(&$core) |
---|
52 | { |
---|
53 | # Settings options |
---|
54 | $core->blog->settings->setNameSpace('eventdata'); |
---|
55 | $core->blog->settings->put('eventdata_option_active',false,'boolean','eventdata plugin enabled',false,true); |
---|
56 | $core->blog->settings->put('eventdata_option_menu',false,'boolean','Icon place on admin menu',false,true); |
---|
57 | $core->blog->settings->put('eventdata_option_public',false,'boolean','eventdata public page enabled',false,true); |
---|
58 | # Settings permissions |
---|
59 | $core->blog->settings->put('eventdata_perm_pst',false,'boolean','Perm to manage events on entries',false,true); |
---|
60 | $core->blog->settings->put('eventdata_perm_cat',false,'boolean','Perm to manage events categories',false,true); |
---|
61 | $core->blog->settings->put('eventdata_perm_tpl',false,'boolean','Perm to manage events template',false,true); |
---|
62 | $core->blog->settings->put('eventdata_perm_adm',false,'boolean','Perm to manage eventdata plugin',false,true); |
---|
63 | # Settings templates |
---|
64 | $core->blog->settings->put('eventdata_tpl_title','Events','string','Public page title',false,true); |
---|
65 | $core->blog->settings->put('eventdata_tpl_desc','','string','Public page description',false,true); |
---|
66 | $core->blog->settings->put('eventdata_tpl_url','events','string','Public page default name',false,true); |
---|
67 | $core->blog->settings->put('eventdata_tpl_dis_bhv',false,'boolean','Disable public entry behavior',false,true); |
---|
68 | $core->blog->settings->put('eventdata_tpl_theme','default','string','Public page template',false,true); |
---|
69 | $core->blog->settings->put('eventdata_tpl_cats','','string','Redirected categories',false,true); |
---|
70 | $core->blog->settings->put('eventdata_no_cats','','string','Unlisted categories',false,true); |
---|
71 | } |
---|
72 | |
---|
73 | public static function delSettings(&$core) |
---|
74 | { |
---|
75 | $core->con->execute('DELETE FROM '.$core->prefix.'setting WHERE setting_ns = \'eventdata\' '); |
---|
76 | } |
---|
77 | |
---|
78 | public static function setVersion(&$core) |
---|
79 | { |
---|
80 | $core->setVersion('eventdata',$core->plugins->moduleInfo('eventdata','version')); |
---|
81 | } |
---|
82 | |
---|
83 | public static function delVersion(&$core) |
---|
84 | { |
---|
85 | $core->delVersion('eventdata'); |
---|
86 | } |
---|
87 | |
---|
88 | public static function delTemplates(&$core) |
---|
89 | { |
---|
90 | // Not yet |
---|
91 | } |
---|
92 | |
---|
93 | public static function delModule(&$core) |
---|
94 | { |
---|
95 | $core->plugins->deleteModule('eventdata'); |
---|
96 | } |
---|
97 | } |
---|
98 | ?> |
---|