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