Templateize admin/userhelp.php
[bugdar.git] / admin / userhelp.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright (c)2004-2009 Blue Static
6 || #
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.
10 || #
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
14 || # more details.
15 || #
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 \*=====================================================================*/
21
22 require_once('./global.php');
23 require_once('./includes/api_userhelp.php');
24 require_once('./includes/functions_datastore.php');
25
26 if (!can_perform('canadmintools'))
27 {
28 admin_login();
29 }
30
31 // ###################################################################
32
33 if (empty($_REQUEST['do']))
34 {
35 $_REQUEST['do'] = 'modify';
36 }
37
38 // ###################################################################
39
40 if ($_REQUEST['do'] == 'kill')
41 {
42 $help = new UserHelpAPI();
43 $help->set('keystring', $input->in['keystring']);
44 $help->delete();
45
46 build_user_help();
47
48 admin_flash_redirect('userhelp.php?do=modify');
49 }
50
51 // ###################################################################
52
53 if ($_REQUEST['do'] == 'delete')
54 {
55 $admin->page_confirm(T('Are you sure you want to delete help text?'), 'userhelp.php', 'kill', array('keystring' => $input->in['keystring']));
56 }
57
58 // ###################################################################
59
60 if ($_POST['do'] == 'insert')
61 {
62 $help = new UserHelpAPI();
63 $help->set('keystring', $input->in['keystring']);
64 $help->set('title', $input->in['title']);
65 $help->set('body', $input->in['body']);
66 $help->insert();
67
68 admin_flash_redirect('userhelp.php?do=modify');
69 }
70
71 // ###################################################################
72
73 if ($_REQUEST['do'] == 'add')
74 {
75 BSTemplate::fetch('userhelp_add')->evaluate()->flush();
76 }
77
78 // ###################################################################
79
80 if ($_POST['do'] == 'update')
81 {
82 foreach ($input->in['help'] as $keystring => $fields)
83 {
84 $help = new UserHelpAPI();
85 $help->set('keystring', $keystring);
86 $help->set('title', $fields['title']);
87 $help->set('body', $fields['body']);
88 $help->update(true, false);
89 }
90
91 build_user_help();
92
93 admin_flash_redirect('userhelp.php?do=modify');
94 }
95
96 // ###################################################################
97
98 if ($_REQUEST['do'] == 'modify')
99 {
100 $admin = new BSTemplate('userhelp');
101 $admin->vars['topics'] = $db->query("SELECT * FROM " . TABLE_PREFIX . "fieldhelp ORDER BY keystring ASC");
102 $admin->evaluate()->flush();
103 }
104
105 ?>