]>
src.bluestatic.org Git - bugdar.git/blob - admin/userhelp.php
2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright ©2002-2007 Blue Static
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 2 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/api_userhelp.php');
24 require_once('./includes/functions_datastore.php');
26 require_once('./includes/class_api_error.php');
27 APIError(array(new API_Error_Handler($admin), 'admin_error'));
29 NavLinks
::optionsPages();
30 NavLinks
::userhelpAdd();
31 $navigator->set_focus('tab', 'options', null);
33 if (!can_perform('canadmintools'))
38 // ###################################################################
40 if (empty($_REQUEST['do']))
42 $_REQUEST['do'] = 'modify';
45 // ###################################################################
47 if ($_REQUEST['do'] == 'kill')
49 $help = new UserHelpAPI($bugsys);
50 $help->set('keystring', $bugsys->in
['keystring']);
55 $admin->redirect('userhelp.php?do=modify');
58 // ###################################################################
60 if ($_REQUEST['do'] == 'delete')
62 $admin->page_confirm(T('Are you sure you want to delete help text?'), 'userhelp.php', 'kill', array('keystring' => $bugsys->in
['keystring']));
65 // ###################################################################
67 if ($_POST['do'] == 'insert')
69 $help = new UserHelpAPI($bugsys);
70 $help->set('keystring', $bugsys->in
['keystring']);
71 $help->set('title', $bugsys->in
['title']);
72 $help->set('body', $bugsys->in
['body']);
75 $admin->redirect('userhelp.php?do=modify');
78 // ###################################################################
80 if ($_REQUEST['do'] == 'add')
82 $navigator->set_focus('link', 'options-userhelp-add', 'options-userhelp');
84 $admin->page_start(T('New Help Text'));
86 $admin->form_start('userhelp.php', 'insert');
88 $admin->table_start();
89 $admin->table_head(T('New Help Text'));
91 $admin->row_input(T('Topic Title'), 'title');
92 $admin->row_input(T('Unique Key<br />(lowercase letters, underscores, and numbers only)'), 'keystring');
93 $admin->row_textarea(T('Body Text'), 'body');
104 // ###################################################################
106 if ($_POST['do'] == 'update')
108 foreach ($bugsys->in
['help'] AS $keystring => $fields)
110 $help = new UserHelpAPI($bugsys);
111 $help->norunners
= array('post_update');
112 $help->set('keystring', $keystring);
113 $help->set_condition();
114 $help->set('title', $fields['title']);
115 $help->set('body', $fields['body']);
121 $admin->redirect('userhelp.php?do=modify');
124 // ###################################################################
126 if ($_REQUEST['do'] == 'modify')
128 $navigator->set_focus('link', 'options-pages-userhelp', 'options-pages');
130 $admin->page_start(T('Edit User Help'));
132 $admin->form_start('userhelp.php', 'update');
134 $admin->table_start();
135 $admin->table_head(T('Edit User Help'));
137 $topics = $db->query("SELECT * FROM " . TABLE_PREFIX
. "fieldhelp ORDER BY keystring ASC");
138 foreach ($topics as $topic)
140 $inputfield = '<input type="text" class="input" name="help[' . $topic['keystring'] . '][title]" value="' . $topic['title'] . '" size="35" />';
141 $delete = (!in_array($topic['keystring'], UserHelpAPI
::not_able_to_delete()) ? '<br /><br /><a href="userhelp.php?do=delete&keystring=' . $topic['keystring'] . '">[' . T('Delete') . ']</a>' : '');
143 $admin->row_textarea($inputfield . '<br /><em>' . $topic['keystring'] . '</em>' . $delete, 'help[' . $topic['keystring'] . '][body]', $topic['body']);
146 $admin->row_submit();
152 /*=====================================================================*\
153 || ###################################################################
156 || ###################################################################
157 \*=====================================================================*/