Remove includes/class_api_error.php and all of the places we require() it
[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 APIError(array(new API_Error_Handler($admin), 'admin_error'));
27
28 NavLinks::optionsPages();
29 NavLinks::userhelpAdd();
30 $navigator->set_focus('tab', 'options', null);
31
32 if (!can_perform('canadmintools'))
33 {
34 admin_login();
35 }
36
37 // ###################################################################
38
39 if (empty($_REQUEST['do']))
40 {
41 $_REQUEST['do'] = 'modify';
42 }
43
44 // ###################################################################
45
46 if ($_REQUEST['do'] == 'kill')
47 {
48 $help = new UserHelpAPI();
49 $help->set('keystring', $input->in['keystring']);
50 $help->delete();
51
52 build_user_help();
53
54 $admin->redirect('userhelp.php?do=modify');
55 }
56
57 // ###################################################################
58
59 if ($_REQUEST['do'] == 'delete')
60 {
61 $admin->page_confirm(T('Are you sure you want to delete help text?'), 'userhelp.php', 'kill', array('keystring' => $input->in['keystring']));
62 }
63
64 // ###################################################################
65
66 if ($_POST['do'] == 'insert')
67 {
68 $help = new UserHelpAPI();
69 $help->set('keystring', $input->in['keystring']);
70 $help->set('title', $input->in['title']);
71 $help->set('body', $input->in['body']);
72 $help->insert();
73
74 $admin->redirect('userhelp.php?do=modify');
75 }
76
77 // ###################################################################
78
79 if ($_REQUEST['do'] == 'add')
80 {
81 $navigator->set_focus('link', 'options-userhelp-add', 'options-userhelp');
82
83 $admin->page_start(T('New Help Text'));
84
85 $admin->form_start('userhelp.php', 'insert');
86
87 $admin->table_start();
88 $admin->table_head(T('New Help Text'));
89
90 $admin->row_input(T('Topic Title'), 'title');
91 $admin->row_input(T('Unique Key<br />(lowercase letters, underscores, and numbers only)'), 'keystring');
92 $admin->row_textarea(T('Body Text'), 'body');
93
94 $admin->row_submit();
95
96 $admin->table_end();
97
98 $admin->form_end();
99
100 $admin->page_end();
101 }
102
103 // ###################################################################
104
105 if ($_POST['do'] == 'update')
106 {
107 foreach ($input->in['help'] AS $keystring => $fields)
108 {
109 $help = new UserHelpAPI();
110 $help->norunners = array('post_update');
111 $help->set('keystring', $keystring);
112 $help->set_condition();
113 $help->set('title', $fields['title']);
114 $help->set('body', $fields['body']);
115 $help->update();
116 }
117
118 build_user_help();
119
120 $admin->redirect('userhelp.php?do=modify');
121 }
122
123 // ###################################################################
124
125 if ($_REQUEST['do'] == 'modify')
126 {
127 $navigator->set_focus('link', 'options-pages-userhelp', 'options-pages');
128
129 $admin->page_start(T('Edit User Help'));
130
131 $admin->form_start('userhelp.php', 'update');
132
133 $admin->table_start();
134 $admin->table_head(T('Edit User Help'));
135
136 $topics = $db->query("SELECT * FROM " . TABLE_PREFIX . "fieldhelp ORDER BY keystring ASC");
137 foreach ($topics as $topic)
138 {
139 $inputfield = '<input type="text" class="input" name="help[' . $topic['keystring'] . '][title]" value="' . $topic['title'] . '" size="35" />';
140 $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>' : '');
141
142 $admin->row_textarea($inputfield . '<br /><em>' . $topic['keystring'] . '</em>' . $delete, 'help[' . $topic['keystring'] . '][body]', $topic['body']);
143 }
144
145 $admin->row_submit();
146 $admin->table_end();
147
148 $admin->page_end();
149 }
150
151 /*=====================================================================*\
152 || ###################################################################
153 || # $HeadURL$
154 || # $Id$
155 || ###################################################################
156 \*=====================================================================*/
157 ?>