2 /*=====================================================================*\
3 || ################################################################### ||
4 || # Bugdar [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
13 require_once('./global.php');
14 require_once('./includes/functions_datastore.php');
16 if (!can_perform('canadmintools'))
21 // don't allow deleting of these
38 // ###################################################################
40 if (empty($_REQUEST['do']))
42 $_REQUEST['do'] = 'modify';
45 // ###################################################################
47 if ($_REQUEST['do'] == 'kill')
49 if (in_array($bugsys->in
['keystring'], $nokills))
51 $admin->error($lang->string('You cannot delete this help text because it is part of the default set.'));
54 $db->query("DELETE FROM " . TABLE_PREFIX
. "fieldhelp WHERE keystring = '" . $bugsys->in
['keystring'] . "'");
58 $admin->redirect('userhelp.php?do=modify');
61 // ###################################################################
63 if ($_REQUEST['do'] == 'delete')
65 if (in_array($bugsys->in
['keystring'], $nokills))
67 $admin->error($lang->string('You cannot delete this help text because it is part of the default set.'));
70 $admin->page_confirm($lang->string('Are you sure you want to delete help text?'), 'userhelp.php?do=kill&keystring=' . $bugsys->in
['keystring']);
73 // ###################################################################
75 if ($_POST['do'] == 'insert')
77 if (preg_match('#[^a-z0-9_]#', $bugsys->in
['keystring']))
79 $admin->error($lang->string('The unique key can only contain lowercase letters, underscores, and numbers.'));
82 if ($db->query_first("SELECT * FROM " . TABLE_PREFIX
. "fieldhelp WHERE keystring = '" . $bugsys->in
['keystring'] . "'"))
84 $admin->error($lang->string('The unique key must be unique.'));
87 if (empty($bugsys->in
['keystring']) OR empty($bugsys->in
['title']) OR empty($bugsys->in
['body']))
89 $admin->error($lang->string('All the fields are required. Please go back and fill each field in properly.'));
92 $db->query("INSERT INTO " . TABLE_PREFIX
. "fieldhelp (keystring, title, body) VALUES ('" . $bugsys->in
['keystring'] . "', '" . $bugsys->in
['title'] . "', '" . $bugsys->in
['body'] . "')");
96 $admin->redirect('userhelp.php?do=modify');
99 // ###################################################################
101 if ($_REQUEST['do'] == 'add')
103 $admin->page_start($lang->string('New Help Text'));
105 $admin->form_start('userhelp.php', 'insert');
107 $admin->table_start();
108 $admin->table_head($lang->string('New Help Text'), 2, 'user_help_manager');
110 $admin->row_input($lang->string('Topic Title'), 'title');
111 $admin->row_input($lang->string('Unique Key<br />(lowercase letters, underscores, and numbers only)'), 'keystring');
112 $admin->row_textarea($lang->string('Body Text'), 'body');
114 $admin->row_submit();
123 // ###################################################################
125 if ($_POST['do'] == 'update')
127 foreach ($bugsys->in
['help'] AS $keystring => $fields)
129 if (empty($fields['title']) OR empty($fields['body']))
131 $admin->error(sprintf($lang->string('No fields can be empty. Please correct this with the text for key <em>%1$s</em>.'), $keystring));
135 $query[] = "UPDATE " . TABLE_PREFIX
. "fieldhelp SET title = '$fields[title]', body = '$fields[body]' WHERE keystring = '$keystring'";
139 foreach ($query AS $sql)
146 $admin->redirect('userhelp.php?do=modify');
149 // ###################################################################
151 if ($_REQUEST['do'] == 'modify')
153 $admin->page_start($lang->string('Edit User Help'));
155 $admin->form_start('userhelp.php', 'update');
157 $admin->table_start();
158 $admin->table_head($lang->string('Edit User Help'), 2, 'user_help_manager');
160 $topics = $db->query("SELECT
* FROM
" . TABLE_PREFIX . "fieldhelp ORDER BY keystring ASC
");
161 while ($topic = $db->fetch_array($topics))
163 $inputfield = '<input type="text
" class="input
" name="help
[' . $topic['keystring
'] . '][title
]" value="' . $topic['title
'] . '" size="35" />';
164 $delete = (!in_array($topic['keystring'], $nokills) ? '<br /><br /><a href="userhelp
.php
?do=delete
&
;keystring
=' . $topic['keystring
'] . '">[' . $lang->string('Delete') . ']</a>' : '');
166 $admin->row_textarea($inputfield . '<br /><em>' . $topic['keystring'] . '</em>' . $delete, 'help[' . $topic['keystring'] . '][body]', $topic['body']);
169 $admin->row_submit('<a href="userhelp
.php
?do=add
">[' . $lang->string('Add New Help Text') . ']</a>');
176 /*=====================================================================*\
177 || ###################################################################
180 || ###################################################################
181 \*=====================================================================*/