1 | <?php |
---|
2 | # ***** BEGIN LICENSE BLOCK ***** |
---|
3 | # |
---|
4 | # This file is part of Bloc-Notes. |
---|
5 | # Copyright 2008,2009 Moe (http://gniark.net/) |
---|
6 | # |
---|
7 | # Bloc-Notes 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 | # Bloc-Notes 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 | # Icons (*.png) are from Tango Icon theme : |
---|
21 | # http://tango.freedesktop.org/Tango_Icon_Gallery |
---|
22 | # |
---|
23 | # ***** END LICENSE BLOCK ***** |
---|
24 | |
---|
25 | if (!defined('DC_CONTEXT_ADMIN')) {return;} |
---|
26 | |
---|
27 | # On lit la version du plugin |
---|
28 | $m_version = $core->plugins->moduleInfo('blocNotes','version'); |
---|
29 | |
---|
30 | # On lit la version du plugin dans la table des versions |
---|
31 | $i_version = $core->getVersion('blocNotes'); |
---|
32 | |
---|
33 | # La version dans la table est supérieure ou égale à |
---|
34 | # celle du module, on ne fait rien puisque celui-ci |
---|
35 | # est installé |
---|
36 | if (version_compare($i_version,$m_version,'>=')) { |
---|
37 | return; |
---|
38 | } |
---|
39 | |
---|
40 | # encode settings to preserve new lines when editing about:config |
---|
41 | if (version_compare($i_version,'1.0.2','<')) |
---|
42 | { |
---|
43 | # per-blog setting |
---|
44 | $rs = $core->con->select('SELECT setting_value, setting_id, blog_id '. |
---|
45 | 'FROM '.$core->prefix.'setting '. |
---|
46 | 'WHERE setting_ns = \'blocnotes\' '. |
---|
47 | 'AND (setting_id = \'blocNotes_text\');'); |
---|
48 | |
---|
49 | while($rs->fetch()) |
---|
50 | { |
---|
51 | $cur = $core->con->openCursor($core->prefix.'setting'); |
---|
52 | $cur->setting_value = base64_encode($rs->setting_value); |
---|
53 | $cur->update('WHERE setting_ns = \'blocnotes\' '. |
---|
54 | 'AND setting_id = \''.$rs->setting_id.'\''. |
---|
55 | 'AND blog_id = \''.$rs->blog_id.'\';'); |
---|
56 | } |
---|
57 | |
---|
58 | # users setting (global) |
---|
59 | $rs = $core->con->select('SELECT setting_value, setting_id, blog_id '. |
---|
60 | 'FROM '.$core->prefix.'setting '. |
---|
61 | 'WHERE setting_ns = \'blocnotes\' '. |
---|
62 | 'AND (setting_id LIKE \'blocNotes_text_%\');'); |
---|
63 | |
---|
64 | while($rs->fetch()) |
---|
65 | { |
---|
66 | $cur = $core->con->openCursor($core->prefix.'setting'); |
---|
67 | $cur->setting_value = base64_encode($rs->setting_value); |
---|
68 | $cur->update('WHERE setting_ns = \'blocnotes\' '. |
---|
69 | 'AND setting_id = \''.$rs->setting_id.'\';'); |
---|
70 | } |
---|
71 | } |
---|
72 | |
---|
73 | # table |
---|
74 | $s = new dbStruct($core->con,$core->prefix); |
---|
75 | |
---|
76 | # add blocNotes column to (dc_)user |
---|
77 | $s->user |
---|
78 | ->blocNotes('text',0,true,null) |
---|
79 | ; |
---|
80 | |
---|
81 | $si = new dbStruct($core->con,$core->prefix); |
---|
82 | $changes = $si->synchronize($s); |
---|
83 | |
---|
84 | # store users setting in (dc_)user |
---|
85 | if (version_compare($i_version,'1.0.3','<')) |
---|
86 | { |
---|
87 | # users setting (global) |
---|
88 | $rs = $core->con->select('SELECT setting_value, setting_id '. |
---|
89 | 'FROM '.$core->prefix.'setting '. |
---|
90 | 'WHERE setting_ns = \'blocnotes\' '. |
---|
91 | 'AND (setting_id LIKE \'blocNotes_text_%\');'); |
---|
92 | |
---|
93 | while($rs->fetch()) |
---|
94 | { |
---|
95 | $user_id = str_replace('blocNotes_text_','',$rs->setting_id); |
---|
96 | |
---|
97 | $cur = $core->con->openCursor($core->prefix.'user'); |
---|
98 | $cur->blocNotes = base64_decode($rs->setting_value); |
---|
99 | $cur->update('WHERE user_id = \''.$user_id.'\';'); |
---|
100 | } |
---|
101 | |
---|
102 | # delete old settings |
---|
103 | $core->con->execute('DELETE FROM '.$core->prefix.'setting '. |
---|
104 | 'WHERE setting_ns = \'blocnotes\' '. |
---|
105 | 'AND (setting_id LIKE \'blocNotes_text_%\');'); |
---|
106 | } |
---|
107 | |
---|
108 | # La procédure d'installation commence vraiment là |
---|
109 | $core->setVersion('blocNotes',$m_version); |
---|
110 | |
---|
111 | return true; |
---|
112 | ?> |
---|