1 | <?php |
---|
2 | # ***** BEGIN LICENSE BLOCK ***** |
---|
3 | # |
---|
4 | # This file is part of Bloc-Notes. |
---|
5 | # Copyright 2008,2009,2010,2011 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 | $__autoload['blocNotes'] = |
---|
28 | dirname(__FILE__).'/inc/lib.blocNotes.php'; |
---|
29 | |
---|
30 | # dashboard |
---|
31 | if ($core->auth->check('usage,contentadmin',$core->blog->id)) |
---|
32 | { |
---|
33 | $core->addBehavior('adminDashboardIcons', |
---|
34 | array('blocNotes','adminDashboardIcons')); |
---|
35 | } |
---|
36 | |
---|
37 | # post |
---|
38 | $core->addBehavior('adminPostForm',array('blocNotes','form')); |
---|
39 | $core->addBehavior('adminAfterPostCreate', |
---|
40 | array('blocNotes','putSettings')); |
---|
41 | $core->addBehavior('adminAfterPostUpdate', |
---|
42 | array('blocNotes','putSettings')); |
---|
43 | $core->addBehavior('adminPostHeaders', |
---|
44 | array('blocNotes','adminPostHeaders')); |
---|
45 | |
---|
46 | $_menu['Plugins']->addItem(__('Notebook'), |
---|
47 | 'plugin.php?p=blocNotes', |
---|
48 | 'index.php?pf=blocNotes/icon.png', |
---|
49 | preg_match('/plugin.php\?p=blocNotes(&.*)?$/', |
---|
50 | $_SERVER['REQUEST_URI']), |
---|
51 | $core->auth->check('usage,contentadmin',$core->blog->id)); |
---|
52 | |
---|
53 | |
---|
54 | # backups |
---|
55 | |
---|
56 | /*$core->addBehavior('exportFull', |
---|
57 | array('blocNotesExportImport','exportFull')); |
---|
58 | $core->addBehavior('exportSingle', |
---|
59 | array('blocNotesExportImport','exportSingle')); |
---|
60 | $core->addBehavior('importInit', |
---|
61 | array('blocNotesExportImport','importInit')); |
---|
62 | $core->addBehavior('importSingle', |
---|
63 | array('blocNotesExportImport','importSingle')); |
---|
64 | $core->addBehavior('importFull', |
---|
65 | array('blocNotesExportImport','importFull')); |
---|
66 | |
---|
67 | class blocNotesExportImport |
---|
68 | { |
---|
69 | public static function exportFull($core,$exp) |
---|
70 | { |
---|
71 | $exp->export('user', |
---|
72 | 'SELECT bloc_notes, user_id '. |
---|
73 | 'FROM '.$core->prefix.'user U '. |
---|
74 | "WHERE U.bloc_notes != '' " |
---|
75 | ); |
---|
76 | } |
---|
77 | |
---|
78 | public static function exportSingle($core,$exp,$blog_id) |
---|
79 | { |
---|
80 | # from /dotclear/admin/blog_pref.php |
---|
81 | $blog_users = $core->getBlogPermissions($blog_id,$core->auth->isSuperAdmin()); |
---|
82 | $blog_users = array_keys($blog_users); |
---|
83 | |
---|
84 | $exp->export('user', |
---|
85 | 'SELECT bloc_notes, user_id '. |
---|
86 | 'FROM '.$core->prefix.'user U '. |
---|
87 | "WHERE U.bloc_notes != '' ". |
---|
88 | "AND U.user_id ".$core->con->in($blog_users) |
---|
89 | ); |
---|
90 | } |
---|
91 | |
---|
92 | public static function importInit($bk,$core) |
---|
93 | { |
---|
94 | $bk->cur_user = $core->con->openCursor($core->prefix.'user'); |
---|
95 | } |
---|
96 | |
---|
97 | public static function importFull($line,$bk,$core) |
---|
98 | { |
---|
99 | if ($line->__name == 'user') |
---|
100 | { |
---|
101 | $bk->cur_user->bloc_notes = (string) $line->bloc_notes; |
---|
102 | $bk->cur_meta->update('WHERE user_id = \''. |
---|
103 | $core->con->escape($line->user_id).'\''); |
---|
104 | } |
---|
105 | } |
---|
106 | |
---|
107 | public static function importSingle($line,$bk,$core) |
---|
108 | { |
---|
109 | if ($line->__name == 'user') |
---|
110 | { |
---|
111 | $bk->cur_user->bloc_notes = (string) $line->bloc_notes; |
---|
112 | $bk->cur_meta->update('WHERE user_id = \''. |
---|
113 | $core->con->escape($line->user_id).'\''); |
---|
114 | } |
---|
115 | } |
---|
116 | }*/ |
---|
117 | |
---|
118 | ?> |
---|