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
37 // ###################################################################
39 if (empty($_REQUEST['do']))
41 $_REQUEST['do'] = 'modify';
44 // ###################################################################
46 if ($_REQUEST['do'] == 'kill')
48 if (in_array($bugsys->in
['keystring'], $nokills))
50 $admin->error($lang->string('You cannot delete this help text because it is part of the default set.'));
53 $db->query("DELETE FROM " . TABLE_PREFIX
. "fieldhelp WHERE keystring = '" . $bugsys->in
['keystring'] . "'");
57 $admin->redirect('userhelp.php?do=modify');
60 // ###################################################################
62 if ($_REQUEST['do'] == 'delete')
64 if (in_array($bugsys->in
['keystring'], $nokills))
66 $admin->error($lang->string('You cannot delete this help text because it is part of the default set.'));
69 $admin->page_confirm($lang->string('Are you sure you want to delete help text?'), 'userhelp.php?do=kill&keystring=' . $bugsys->in
['keystring']);
72 // ###################################################################
74 if ($_POST['do'] == 'insert')
76 if (preg_match('#[^a-z0-9_]#', $bugsys->in
['keystring']))
78 $admin->error($lang->string('The unique key can only contain lowercase letters, underscores, and numbers.'));
81 if ($db->query_first("SELECT * FROM " . TABLE_PREFIX
. "fieldhelp WHERE keystring = '" . $bugsys->in
['keystring'] . "'"))
83 $admin->error($lang->string('The unique key must be unique.'));
86 if (empty($bugsys->in
['keystring']) OR empty($bugsys->in
['title']) OR empty($bugsys->in
['body']))
88 $admin->error($lang->string('All the fields are required. Please go back and fill each field in properly.'));
91 $db->query("INSERT INTO " . TABLE_PREFIX
. "fieldhelp (keystring, title, body) VALUES ('" . $bugsys->in
['keystring'] . "', '" . $bugsys->in
['title'] . "', '" . $bugsys->in
['body'] . "')");
95 $admin->redirect('userhelp.php?do=modify');
98 // ###################################################################
100 if ($_REQUEST['do'] == 'add')
102 $admin->page_start($lang->string('New Help Text'));
104 $admin->form_start('userhelp.php', 'insert');
106 $admin->table_start();
107 $admin->table_head($lang->string('New Help Text'), 2, 'user_help_manager');
109 $admin->row_input($lang->string('Topic Title'), 'title');
110 $admin->row_input($lang->string('Unique Key<br />(lowercase letters, underscores, and numbers only)'), 'keystring');
111 $admin->row_textarea($lang->string('Body Text'), 'body');
113 $admin->row_submit();
122 // ###################################################################
124 if ($_POST['do'] == 'update')
126 foreach ($bugsys->in
['help'] AS $keystring => $fields)
128 if (empty($fields['title']) OR empty($fields['body']))
130 $admin->error(sprintf($lang->string('No fields can be empty. Please correct this with the text for key <em>%1$s</em>.'), $keystring));
134 $query[] = "UPDATE " . TABLE_PREFIX
. "fieldhelp SET title = '$fields[title]', body = '$fields[body]' WHERE keystring = '$keystring'";
138 foreach ($query AS $sql)
145 $admin->redirect('userhelp.php?do=modify');
148 // ###################################################################
150 if ($_REQUEST['do'] == 'modify')
152 $admin->page_start($lang->string('Edit User Help'));
154 $admin->form_start('userhelp.php', 'update');
156 $admin->table_start();
157 $admin->table_head($lang->string('Edit User Help'), 2, 'user_help_manager');
159 $topics = $db->query("SELECT
* FROM
" . TABLE_PREFIX . "fieldhelp ORDER BY keystring ASC
");
160 while ($topic = $db->fetch_array($topics))
162 $inputfield = '<input type="text
" class="input
" name="help
[' . $topic['keystring
'] . '][title
]" value="' . $topic['title
'] . '" size="35" />';
163 $delete = (!in_array($topic['keystring'], $nokills) ? '<br /><br /><a href="userhelp
.php
?do=delete
&
;keystring
=' . $topic['keystring
'] . '">[' . $lang->string('Delete') . ']</a>' : '');
165 $admin->row_textarea($inputfield . '<br /><em>' . $topic['keystring'] . '</em>' . $delete, 'help[' . $topic['keystring'] . '][body]', $topic['body']);
168 $admin->row_submit('<a href="userhelp
.php
?do=add
">[' . $lang->string('Add New Help Text') . ']</a>');
175 /*=====================================================================*\
176 || ###################################################################
179 || ###################################################################
180 \*=====================================================================*/