2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
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.
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
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 \*=====================================================================*/
22 require_once('./global.php');
23 require_once('./includes/functions_datastore.php');
25 NavLinks
::optionsPages();
26 NavLinks
::userhelpAdd();
27 $navigator->set_focus('tab', 'options', null
);
29 if (!can_perform('canadmintools'))
34 // don't allow deleting of these
51 // ###################################################################
53 if (empty($_REQUEST['do']))
55 $_REQUEST['do'] = 'modify';
58 // ###################################################################
60 if ($_REQUEST['do'] == 'kill')
62 if (in_array($bugsys->in
['keystring'], $nokills))
64 $admin->error($lang->string('You cannot delete this help text because it is part of the default set.'));
67 $db->query("DELETE FROM " . TABLE_PREFIX
. "fieldhelp WHERE keystring = '" . $bugsys->in
['keystring'] . "'");
71 $admin->redirect('userhelp.php?do=modify');
74 // ###################################################################
76 if ($_REQUEST['do'] == 'delete')
78 if (in_array($bugsys->in
['keystring'], $nokills))
80 $admin->error($lang->string('You cannot delete this help text because it is part of the default set.'));
83 $admin->page_confirm($lang->string('Are you sure you want to delete help text?'), 'userhelp.php?do=kill&keystring=' . $bugsys->in
['keystring']);
86 // ###################################################################
88 if ($_POST['do'] == 'insert')
90 if (preg_match('#[^a-z0-9_]#', $bugsys->in
['keystring']))
92 $admin->error($lang->string('The unique key can only contain lowercase letters, underscores, and numbers.'));
95 if ($db->query_first("SELECT * FROM " . TABLE_PREFIX
. "fieldhelp WHERE keystring = '" . $bugsys->in
['keystring'] . "'"))
97 $admin->error($lang->string('The unique key must be unique.'));
100 if (empty($bugsys->in
['keystring']) OR empty($bugsys->in
['title']) OR empty($bugsys->in
['body']))
102 $admin->error($lang->string('All the fields are required. Please go back and fill each field in properly.'));
105 $db->query("INSERT INTO " . TABLE_PREFIX
. "fieldhelp (keystring, title, body) VALUES ('" . $bugsys->in
['keystring'] . "', '" . $bugsys->in
['title'] . "', '" . $bugsys->in
['body'] . "')");
109 $admin->redirect('userhelp.php?do=modify');
112 // ###################################################################
114 if ($_REQUEST['do'] == 'add')
116 $navigator->set_focus('link', 'options-userhelp-add', 'options-userhelp');
118 $admin->page_start($lang->string('New Help Text'));
120 $admin->form_start('userhelp.php', 'insert');
122 $admin->table_start();
123 $admin->table_head($lang->string('New Help Text'), 2, 'user_help_manager');
125 $admin->row_input($lang->string('Topic Title'), 'title');
126 $admin->row_input($lang->string('Unique Key<br />(lowercase letters, underscores, and numbers only)'), 'keystring');
127 $admin->row_textarea($lang->string('Body Text'), 'body');
129 $admin->row_submit();
138 // ###################################################################
140 if ($_POST['do'] == 'update')
142 foreach ($bugsys->in
['help'] AS $keystring => $fields)
144 if (empty($fields['title']) OR empty($fields['body']))
146 $admin->error(sprintf($lang->string('No fields can be empty. Please correct this with the text for key <em>%1$s</em>.'), $keystring));
150 $query[] = "UPDATE " . TABLE_PREFIX
. "fieldhelp SET title = '$fields[title]', body = '$fields[body]' WHERE keystring = '$keystring'";
154 foreach ($query AS $sql)
161 $admin->redirect('userhelp.php?do=modify');
164 // ###################################################################
166 if ($_REQUEST['do'] == 'modify')
168 $navigator->set_focus('link', 'options-pages-userhelp', 'options-pages');
170 $admin->page_start($lang->string('Edit User Help'));
172 $admin->form_start('userhelp.php', 'update');
174 $admin->table_start();
175 $admin->table_head($lang->string('Edit User Help'), 2, 'user_help_manager');
177 $topics = $db->query("SELECT * FROM " . TABLE_PREFIX
. "fieldhelp ORDER BY keystring ASC");
178 while ($topic = $db->fetch_array($topics))
180 $inputfield = '<input type="text" class="input" name="help[' . $topic['keystring'] . '][title]" value="' . $topic['title'] . '" size="35" />';
181 $delete = (!in_array($topic['keystring'], $nokills) ?
'<br /><br /><a href="userhelp.php?do=delete&keystring=' . $topic['keystring'] . '">[' . $lang->string('Delete') . ']</a>' : '');
183 $admin->row_textarea($inputfield . '<br /><em>' . $topic['keystring'] . '</em>' . $delete, 'help[' . $topic['keystring'] . '][body]', $topic['body']);
191 /*=====================================================================*\
192 || ###################################################################
195 || ###################################################################
196 \*=====================================================================*/