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