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 if (!can_perform('canadmintools'))
30 // don't allow deleting of these
47 // ###################################################################
49 if (empty($_REQUEST['do']))
51 $_REQUEST['do'] = 'modify';
54 // ###################################################################
56 if ($_REQUEST['do'] == 'kill')
58 if (in_array($bugsys->in
['keystring'], $nokills))
60 $admin->error($lang->string('You cannot delete this help text because it is part of the default set.'));
63 $db->query("DELETE FROM " . TABLE_PREFIX
. "fieldhelp WHERE keystring = '" . $bugsys->in
['keystring'] . "'");
67 $admin->redirect('userhelp.php?do=modify');
70 // ###################################################################
72 if ($_REQUEST['do'] == 'delete')
74 if (in_array($bugsys->in
['keystring'], $nokills))
76 $admin->error($lang->string('You cannot delete this help text because it is part of the default set.'));
79 $admin->page_confirm($lang->string('Are you sure you want to delete help text?'), 'userhelp.php?do=kill&keystring=' . $bugsys->in
['keystring']);
82 // ###################################################################
84 if ($_POST['do'] == 'insert')
86 if (preg_match('#[^a-z0-9_]#', $bugsys->in
['keystring']))
88 $admin->error($lang->string('The unique key can only contain lowercase letters, underscores, and numbers.'));
91 if ($db->query_first("SELECT * FROM " . TABLE_PREFIX
. "fieldhelp WHERE keystring = '" . $bugsys->in
['keystring'] . "'"))
93 $admin->error($lang->string('The unique key must be unique.'));
96 if (empty($bugsys->in
['keystring']) OR empty($bugsys->in
['title']) OR empty($bugsys->in
['body']))
98 $admin->error($lang->string('All the fields are required. Please go back and fill each field in properly.'));
101 $db->query("INSERT INTO " . TABLE_PREFIX
. "fieldhelp (keystring, title, body) VALUES ('" . $bugsys->in
['keystring'] . "', '" . $bugsys->in
['title'] . "', '" . $bugsys->in
['body'] . "')");
105 $admin->redirect('userhelp.php?do=modify');
108 // ###################################################################
110 if ($_REQUEST['do'] == 'add')
112 $admin->page_start($lang->string('New Help Text'));
114 $admin->form_start('userhelp.php', 'insert');
116 $admin->table_start();
117 $admin->table_head($lang->string('New Help Text'), 2, 'user_help_manager');
119 $admin->row_input($lang->string('Topic Title'), 'title');
120 $admin->row_input($lang->string('Unique Key<br />(lowercase letters, underscores, and numbers only)'), 'keystring');
121 $admin->row_textarea($lang->string('Body Text'), 'body');
123 $admin->row_submit();
132 // ###################################################################
134 if ($_POST['do'] == 'update')
136 foreach ($bugsys->in
['help'] AS $keystring => $fields)
138 if (empty($fields['title']) OR empty($fields['body']))
140 $admin->error(sprintf($lang->string('No fields can be empty. Please correct this with the text for key <em>%1$s</em>.'), $keystring));
144 $query[] = "UPDATE " . TABLE_PREFIX
. "fieldhelp SET title = '$fields[title]', body = '$fields[body]' WHERE keystring = '$keystring'";
148 foreach ($query AS $sql)
155 $admin->redirect('userhelp.php?do=modify');
158 // ###################################################################
160 if ($_REQUEST['do'] == 'modify')
162 $admin->page_start($lang->string('Edit User Help'));
164 $admin->form_start('userhelp.php', 'update');
166 $admin->table_start();
167 $admin->table_head($lang->string('Edit User Help'), 2, 'user_help_manager');
169 $topics = $db->query("SELECT
* FROM
" . TABLE_PREFIX . "fieldhelp ORDER BY keystring ASC
");
170 while ($topic = $db->fetch_array($topics))
172 $inputfield = '<input type="text
" class="input
" name="help
[' . $topic['keystring
'] . '][title
]" value="' . $topic['title
'] . '" size="35" />';
173 $delete = (!in_array($topic['keystring'], $nokills) ? '<br /><br /><a href="userhelp
.php
?do=delete
&
;keystring
=' . $topic['keystring
'] . '">[' . $lang->string('Delete') . ']</a>' : '');
175 $admin->row_textarea($inputfield . '<br /><em>' . $topic['keystring'] . '</em>' . $delete, 'help[' . $topic['keystring'] . '][body]', $topic['body']);
178 $admin->row_submit('<a href="userhelp
.php
?do=add
">[' . $lang->string('Add New Help Text') . ']</a>');
185 /*=====================================================================*\
186 || ###################################################################
189 || ###################################################################
190 \*=====================================================================*/