2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]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 // ###################################################################
23 if (empty($_REQUEST['do']))
25 // set default branch for this script
26 $_REQUEST['do'] = 'modify';
29 // ###################################################################
31 if ($_REQUEST['do'] == 'kill')
33 // run code to remove item in database
36 // ###################################################################
38 if ($_REQUEST['do'] == 'delete')
40 // display delete confirmation message
43 // ###################################################################
45 if ($_POST['do'] == 'insert')
47 if (preg_match('#[^a-z0-9_]#', $bugsys->in
['keystring']))
49 $admin->error($lang->string('The unique key can only contain lowercase letters, underscores, and numbers.'));
52 if ($db->query_first("SELECT * FROM " . TABLE_PREFIX
. "fieldhelp WHERE keystring = '" . $bugsys->in
['keystring'] . "'"))
54 $admin->error($lang->string('The unique key must be unique.'));
57 if (empty($bugsys->in
['keystring']) OR empty($bugsys->in
['title']) OR empty($bugsys->in
['body']))
59 $admin->error($lang->string('All the fields are required. Please go back and fill each field in properly.'));
62 $db->query("INSERT INTO " . TABLE_PREFIX
. "fieldhelp (keystring, title, body) VALUES ('" . $bugsys->in
['keystring'] . "', '" . $bugsys->in
['title'] . "', '" . $bugsys->in
['body'] . "')");
66 $admin->redirect('userhelp.php?do=modify');
69 // ###################################################################
71 if ($_REQUEST['do'] == 'add')
73 $admin->page_start($lang->string('New Help Text'));
75 $admin->form_start('userhelp.php', 'insert');
77 $admin->table_start();
78 $admin->table_head($lang->string('New Help Text'));
80 $admin->row_input($lang->string('Topic Title'), 'title');
81 $admin->row_input($lang->string('Unique Key<br />(lowercase letters, underscores, and numbers only)'), 'keystring');
82 $admin->row_textarea($lang->string('Body Text'), 'body');
93 // ###################################################################
95 if ($_POST['do'] == 'update')
97 foreach ($bugsys->in
['help'] AS $keystring => $fields)
99 if (empty($fields['title']) OR empty($fields['body']))
101 $admin->error(sprintf($lang->string('No fields can be empty. Please correct this with the text for key <em>%1$s</em>.'), $keystring));
105 $query[] = "UPDATE " . TABLE_PREFIX
. "fieldhelp SET title = '$fields[title]', body = '$fields[body]' WHERE keystring = '$keystring'";
109 foreach ($query AS $sql)
116 $admin->redirect('userhelp.php?do=modify');
119 // ###################################################################
121 if ($_REQUEST['do'] == 'modify')
123 $admin->page_start($lang->string('Edit User Help'));
125 $admin->form_start('userhelp.php', 'update');
127 $admin->table_start();
128 $admin->table_head($lang->string('Edit User Help'));
130 $topics = $db->query("SELECT * FROM " . TABLE_PREFIX
. "fieldhelp ORDER BY keystring ASC");
131 while ($topic = $db->fetch_array($topics))
133 $inputfield = '<input type="text" class="input" name="help[' . $topic['keystring'] . '][title]" value="' . $topic['title'] . '" size="35" />';
134 $admin->row_textarea($inputfield . '<br /><em>' . $topic['keystring'] . '</em>', 'help[' . $topic['keystring'] . '][body]', $topic['body']);
137 $admin->row_submit('<a href="userhelp.php?do=add">[' . $lang->string('Add New Help Text') . ']</a>');
144 /*=====================================================================*\
145 || ###################################################################
148 || ###################################################################
149 \*=====================================================================*/