Dotclear

source: plugins/blocNotes/inc/lib.blocNotes.php @ 2195

Revision 2195, 2.8 KB checked in by Moe, 14 years ago (diff)

Bloc-Notes 1.0.5 :

  • update the database only if the plugin has already been installed
Line 
1<?php
2# ***** BEGIN LICENSE BLOCK *****
3#
4# This file is part of Bloc-Notes.
5# Copyright 2008,2010 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
25class blocNotes
26     {
27          public static function adminDashboardIcons($core,$icons)
28          {
29               $icons['blocNotes'] = array(__('Notebook'),
30                    'plugin.php?p=blocNotes',
31                    'index.php?pf=blocNotes/icon-big.png');
32          }
33
34          public static function form()
35          {
36               global $core;
37               
38               $set = $core->blog->settings;
39               
40               $notes = $core->con->select('SELECT bloc_notes '.
41                    'FROM '.$core->prefix.'user '.
42                    'WHERE user_id = \''.
43                    $core->con->escape($core->auth->userID()).'\'')->f(0);
44
45               echo '<p class="area" id="blocNotes_personal">'.
46                    '<label for="blocNotes_personal_text">'.
47                         __('Personal notebook (other users can\'t edit it):').
48                    '</label>'.
49                    form::textarea('blocNotes_personal_text',80,5,
50                    html::escapeHTML($notes),'maximal').
51                    '</p>'.
52                    '<p class="area" id="blocNotes">'.
53                    '<label for="blocNotes_text">'.
54                         __('Blog-specific notebook (users of the blog can edit it):').
55                    '</label>'.
56                    form::textarea('blocNotes_text',80,5,
57                    html::escapeHTML(base64_decode($set->blocNotes_text)),
58                    'maximal').
59                    '</p>'.
60                    '<p class="form-note">'.
61                    __('These notes may be read by anyone, don\'t write some sensitive information (password, personal information, etc.)').
62                    '</p>';
63          }
64
65          public static function putSettings()
66          {
67               global $core;
68
69               if (isset($_POST['blocNotes_text']))
70               {
71                    # Personal notebook
72                    $cur = $core->con->openCursor($core->prefix.'user');
73                    $cur->bloc_notes = $_POST['blocNotes_personal_text'];
74                    $cur->update('WHERE user_id = \''.$core->con->escape($core->auth->userID()).'\'');
75                   
76                    $core->blog->settings->setNameSpace('blocnotes');
77                    # Blog-specific notebook
78                    $core->blog->settings->put('blocNotes_text',
79                         base64_encode($_POST['blocNotes_text']),'text',
80                         'Bloc-Notes\' text');
81               }
82          }
83
84          public static function adminPostHeaders()
85          {
86               return '<script type="text/javascript" '.
87                    'src="index.php?pf=blocNotes/post.js">'.
88                    '</script>'."\n";
89          }
90     }
91
92?>
Note: See TracBrowser for help on using the repository browser.

Sites map