1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK ---------------------------------- |
---|
3 | # This file is part of pollsFactory, a plugin for Dotclear 2. |
---|
4 | # |
---|
5 | # Copyright (c) 2009-2010 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 | $new_version = $core->plugins->moduleInfo('pollsFactory','version'); |
---|
16 | $old_version = $core->getVersion('pollsFactory'); |
---|
17 | |
---|
18 | if (version_compare($old_version,$new_version,'>=')) return; |
---|
19 | |
---|
20 | try |
---|
21 | { |
---|
22 | # Check DC version |
---|
23 | if (version_compare(DC_VERSION,'2.2-alpha','<')) |
---|
24 | { |
---|
25 | throw new Exception('pollsFactory requires Dotclear 2.2 or higher.'); |
---|
26 | } |
---|
27 | # Tables |
---|
28 | $s = new dbStruct($core->con,$core->prefix); |
---|
29 | $s->post_option |
---|
30 | ->option_id ('bigint',0,false) |
---|
31 | ->post_id ('bigint',0,false) |
---|
32 | ->option_meta ('varchar',255,true,null) |
---|
33 | ->option_creadt ('timestamp',0,false,'now()') |
---|
34 | ->option_upddt ('timestamp',0,false,'now()') |
---|
35 | ->option_type ('varchar',32,false,"''") |
---|
36 | ->option_format ('varchar',32,false,"'xhtml'") |
---|
37 | ->option_lang ('varchar',5,true,null) |
---|
38 | ->option_title ('varchar',255,true,null) |
---|
39 | ->option_content ('text',0,true,null) |
---|
40 | ->option_content_xhtml ('text',0,false) |
---|
41 | ->option_selected ('smallint',0,false,0) |
---|
42 | ->option_position ('integer',0,false,0) |
---|
43 | |
---|
44 | ->index('idx_post_option_option','btree','option_id') |
---|
45 | ->index('idx_post_option_post','btree','post_id') |
---|
46 | ->index('idx_post_option_meta','btree','option_meta') |
---|
47 | ->index('idx_post_option_type','btree','option_type'); |
---|
48 | |
---|
49 | $si = new dbStruct($core->con,$core->prefix); |
---|
50 | $changes = $si->synchronize($s); |
---|
51 | |
---|
52 | # Settings |
---|
53 | $core->blog->settings->addNamespace('pollsFactory'); |
---|
54 | $s = $core->blog->settings->pollsFactory; |
---|
55 | $s->put('pollsFactory_active',false,'boolean','Enable extension',false,true); |
---|
56 | $s->put('pollsFactory_user_ident',0,'integer','User identification',false,true); |
---|
57 | $s->put('pollsFactory_public_show',true,'boolean','Show reponse when user votes',false,true); |
---|
58 | $s->put('pollsFactory_public_pos',true,'boolean','Show poll after post content',false,true); |
---|
59 | $s->put('pollsFactory_public_full',true,'boolean','Show full content after post content',false,true); |
---|
60 | $s->put('pollsFactory_public_graph',true,'boolean','Use graphics for results',false,true); |
---|
61 | $s->put('pollsFactory_graph_cache',true,'boolean','Use cache for graphics',false,true); |
---|
62 | $s->put('pollsFactory_graph_trigger',0,'integer','Last change for graph settings',false,true); |
---|
63 | $s->put('pollsFactory_graph_options',serialize(pollsFactoryChart::defaultOptions()),'string','graphic options',false,true); |
---|
64 | $s->put('pollsFactory_public_tpltypes',serialize(array('post')),'string','List of templates types for full description of polls',false,true); |
---|
65 | |
---|
66 | # Version |
---|
67 | $core->setVersion('pollsFactory',$new_version); |
---|
68 | |
---|
69 | return true; |
---|
70 | } |
---|
71 | catch (Exception $e) |
---|
72 | { |
---|
73 | $core->error->add($e->getMessage()); |
---|
74 | } |
---|
75 | return false; |
---|
76 | ?> |
---|