]> src.bluestatic.org Git - bugdar.git/blob - admin/userhelp.php
Change $bugsys->input_clean to $input->inputClean
[bugdar.git] / admin / userhelp.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright ©2002-2007 Blue Static
6 || #
7 || # This program 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; version 2 of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 require_once('./global.php');
23 require_once('./includes/api_userhelp.php');
24 require_once('./includes/functions_datastore.php');
25
26 require_once('./includes/class_api_error.php');
27 APIError(array(new API_Error_Handler($admin), 'admin_error'));
28
29 NavLinks::optionsPages();
30 NavLinks::userhelpAdd();
31 $navigator->set_focus('tab', 'options', null);
32
33 if (!can_perform('canadmintools'))
34 {
35 admin_login();
36 }
37
38 // ###################################################################
39
40 if (empty($_REQUEST['do']))
41 {
42 $_REQUEST['do'] = 'modify';
43 }
44
45 // ###################################################################
46
47 if ($_REQUEST['do'] == 'kill')
48 {
49 $help = new UserHelpAPI($bugsys);
50 $help->set('keystring', $bugsys->in['keystring']);
51 $help->delete();
52
53 build_user_help();
54
55 $admin->redirect('userhelp.php?do=modify');
56 }
57
58 // ###################################################################
59
60 if ($_REQUEST['do'] == 'delete')
61 {
62 $admin->page_confirm(T('Are you sure you want to delete help text?'), 'userhelp.php', 'kill', array('keystring' => $bugsys->in['keystring']));
63 }
64
65 // ###################################################################
66
67 if ($_POST['do'] == 'insert')
68 {
69 $help = new UserHelpAPI($bugsys);
70 $help->set('keystring', $bugsys->in['keystring']);
71 $help->set('title', $bugsys->in['title']);
72 $help->set('body', $bugsys->in['body']);
73 $help->insert();
74
75 $admin->redirect('userhelp.php?do=modify');
76 }
77
78 // ###################################################################
79
80 if ($_REQUEST['do'] == 'add')
81 {
82 $navigator->set_focus('link', 'options-userhelp-add', 'options-userhelp');
83
84 $admin->page_start(T('New Help Text'));
85
86 $admin->form_start('userhelp.php', 'insert');
87
88 $admin->table_start();
89 $admin->table_head(T('New Help Text'));
90
91 $admin->row_input(T('Topic Title'), 'title');
92 $admin->row_input(T('Unique Key<br />(lowercase letters, underscores, and numbers only)'), 'keystring');
93 $admin->row_textarea(T('Body Text'), 'body');
94
95 $admin->row_submit();
96
97 $admin->table_end();
98
99 $admin->form_end();
100
101 $admin->page_end();
102 }
103
104 // ###################################################################
105
106 if ($_POST['do'] == 'update')
107 {
108 foreach ($bugsys->in['help'] AS $keystring => $fields)
109 {
110 $help = new UserHelpAPI($bugsys);
111 $help->norunners = array('post_update');
112 $help->set('keystring', $keystring);
113 $help->set_condition();
114 $help->set('title', $fields['title']);
115 $help->set('body', $fields['body']);
116 $help->update();
117 }
118
119 build_user_help();
120
121 $admin->redirect('userhelp.php?do=modify');
122 }
123
124 // ###################################################################
125
126 if ($_REQUEST['do'] == 'modify')
127 {
128 $navigator->set_focus('link', 'options-pages-userhelp', 'options-pages');
129
130 $admin->page_start(T('Edit User Help'));
131
132 $admin->form_start('userhelp.php', 'update');
133
134 $admin->table_start();
135 $admin->table_head(T('Edit User Help'));
136
137 $topics = $db->query("SELECT * FROM " . TABLE_PREFIX . "fieldhelp ORDER BY keystring ASC");
138 foreach ($topics as $topic)
139 {
140 $inputfield = '<input type="text" class="input" name="help[' . $topic['keystring'] . '][title]" value="' . $topic['title'] . '" size="35" />';
141 $delete = (!in_array($topic['keystring'], UserHelpAPI::not_able_to_delete()) ? '<br /><br /><a href="userhelp.php?do=delete&amp;keystring=' . $topic['keystring'] . '">[' . T('Delete') . ']</a>' : '');
142
143 $admin->row_textarea($inputfield . '<br /><em>' . $topic['keystring'] . '</em>' . $delete, 'help[' . $topic['keystring'] . '][body]', $topic['body']);
144 }
145
146 $admin->row_submit();
147 $admin->table_end();
148
149 $admin->page_end();
150 }
151
152 /*=====================================================================*\
153 || ###################################################################
154 || # $HeadURL$
155 || # $Id$
156 || ###################################################################
157 \*=====================================================================*/
158 ?>