]>
src.bluestatic.org Git - bugdar.git/blob - admin/autoaction.php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
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 [#]gpl[#] 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/functions_datastore.php');
25 if (!can_perform('canadminbugs'))
30 // ###################################################################
32 if (empty($_REQUEST['do']))
34 $_REQUEST['do'] = 'modify';
37 // ###################################################################
39 if ($_REQUEST['do'] == 'kill')
41 $action = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "autoaction WHERE actionid = " . intval($bugsys->in
['actionid']));
44 $admin->error($lang->getlex('error_invalid_id'));
47 $db->query("DELETE FROM " . TABLE_PREFIX
. "autoaction WHERE actionid = $action[actionid]");
51 $admin->redirect('autoaction.php?do=modify');
54 // ###################################################################
56 if ($_REQUEST['do'] == 'delete')
58 $action = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "autoaction WHERE actionid = " . intval($bugsys->in
['actionid']));
61 $admin->error($lang->getlex('error_invalid_id'));
64 $admin->page_confirm($lang->string('Are you sure you want to delete this action?'), "autoaction.php?do=kill&actionid=$action[actionid]");
67 // ###################################################################
69 if ($_POST['do'] == 'insert' OR $_POST['do'] == 'update')
71 if (empty($bugsys->in
['name']))
73 $admin->error($lang->string('You need to specify a name for this action.'));
76 foreach ($bugsys->in
['fields'] AS $key => $value)
78 if (!empty($value) AND $value != -1 AND !is_array($value))
80 $deltas['builtin']["$key"] = $value;
84 foreach ($bugsys->in['fields']['custom'] AS $key => $value)
86 if (!empty($value) AND $value != -1)
88 $deltas['custom']["$key"] = $value;
92 if (count($deltas['custom']) < 1 AND count($deltas['builtin']) < 1)
94 $admin->error($lang->string('You need to specify some fields to change.'));
97 if ($_POST['do'] == 'insert')
100 INSERT INTO " . TABLE_PREFIX
. "autoaction
101 (name, description, fieldchanges, comment)
103 ('" . $bugsys->in
['name'] . "', '" . $bugsys->in
['description'] . "',
104 '" . $bugsys->escape(serialize($deltas)) . "', '" . $bugsys->in
['comment'] . "'
108 build_auto_actions();
110 $admin->redirect('autoaction.php');
114 if (!$bugsys->in
['actionid'])
116 $admin->error($lang->getlex('error_invalid_id'));
120 UPDATE " . TABLE_PREFIX
. "autoaction
121 SET name = '" . $bugsys->in
['name'] . "',
122 description = '" . $bugsys->in
['description'] . "',
123 fieldchanges = '" . $bugsys->escape(serialize($deltas)) . "',
124 comment = '" . $bugsys->in
['comment'] . "'
125 WHERE actionid = " . intval($bugsys->in
['actionid'])
128 build_auto_actions();
130 $admin->redirect('autoaction.php');
134 // ###################################################################
136 if ($_REQUEST['do'] == 'add' OR $_REQUEST['do'] == 'edit')
138 $add = (($_REQUEST['do'] == 'add') ? true : false);
139 $edit = (($add) ? false : true);
143 $action = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "autoaction WHERE actionid = " . intval($bugsys->in
['actionid']));
146 $admin->error($lang->getlex('error_invalid_id'));
148 $action['fields'] = unserialize($action['fieldchanges']);
151 $admin->page_start(($add ? $lang->string('New Automatic Action') : $lang->string('Edit Automatic Action')));
153 $admin->form_start('autoaction.php', ($add ? 'insert' : 'update'));
157 $admin->form_hidden_field('actionid', $action['actionid']);
160 $admin->table_start();
161 $admin->table_head(($add ? $lang->string('New Automatic Action') : $lang->string('Edit Automatic Action')), 2, 'automatic_actions');
163 $admin->row_input($lang->string('Name'), 'name', $action['name']);
164 $admin->row_textarea($lang->string('Description'), 'description', $action['description']);
165 $admin->row_textarea($lang->string('Add Comment'), 'comment', $action['comment']);
167 $admin->row_span($lang->string('Field Changes'), 'thead', 'center');
169 // -------------------------------------------------------------------
171 construct_datastore_select('severity', 'severity', 'severityid', $action['fields']['builtin']['severity'], true, true);
172 $admin->row_list($lang->string('Severity'), 'fields[severity]');
174 construct_datastore_select('priority', 'priority', 'priorityid', $action['fields']['builtin']['priority'], true, true);
175 $admin->row_list($lang->string('Priority'), 'fields[priority]');
177 construct_datastore_select('status', 'status', 'statusid', $action['fields']['builtin']['status'], true, true);
178 $admin->row_list($lang->string('Status'), 'fields[status]');
180 construct_datastore_select('resolution', 'resolution', 'resolutionid', $action['fields']['builtin']['resolution'], true, true);
181 $admin->row_list($lang->string('Resolution'), 'fields[resolution]');
183 $admin->row_span('', 'tcat', 'center');
185 // -------------------------------------------------------------------
187 $fields_fetch = $bugsys->db
->query("
189 FROM " . TABLE_PREFIX
. "bugfield AS bugfield
190 LEFT JOIN " . TABLE_PREFIX
. "bugfieldpermission AS permission
191 ON (bugfield.fieldid = permission.fieldid)
192 WHERE permission.mask <> 0
193 AND permission.usergroupid = {$bugsys->userinfo['usergroupid']}
194 AND bugfield.cansearch = 1"
196 while ($field = $bugsys->db
->fetch_array($fields_fetch))
198 switch ($field['type'])
201 $admin->row_input($field['name'], "fields[custom][$field[fieldid]]", $action['fields']['custom']["$field[fieldid]"]);
204 case 'input_checkbox':
205 $admin->list_item('', 0, ((!$action['fields']['custom']["$field[fieldid]"]) ? true : false));
206 $admin->list_item($lang->string('Checked'), 1, (($action['fields']['custom']["$field[fieldid]"] == 1) ? true : false));
207 $admin->list_item($lang->string('Un-Checked'), 2, (($action['fields']['custom']["$field[fieldid]"] == 2) ? true : false));
208 $admin->row_list($field['name'], "fields[custom][$field[fieldid]]");
211 case 'select_single':
212 $selectopts = unserialize($field['selects']);
214 $admin->list_item('', -1, ((!$action['fields']['custom']["$field[fieldid]"]) ? true : false));
216 foreach ($selectopts AS $id => $select)
218 $admin->list_item(stripslashes($select), $id, (($action['fields']['custom']["$field[fieldid]"] == $id AND $edit) ? true : false));
220 $admin->row_list($field['name'], "fields[custom][$field[fieldid]]");
226 $admin->row_submit();
233 // ###################################################################
235 if ($_REQUEST['do'] == 'modify')
237 $admin->page_start($lang->string('Automatic Actions'));
239 $admin->table_start();
240 $admin->table_head($lang->string('Automatic Actions'), 2, 'automatic_actions');
242 $actions = $db->query("SELECT * FROM " . TABLE_PREFIX
. "autoaction ORDER BY name ASC");
243 while ($action = $db->fetch_array($actions))
245 $admin->row_text($action['name'] . "\n<div class=\"smallfont\">$action[description]</div>", "<a href=\"autoaction.php?do=edit&actionid=$action[actionid]\">[" . $lang->string('Edit') . "]</a> <a href=\"autoaction.php?do=delete&actionid=$action[actionid]\">[" . $lang->string('Delete') . "]</a>");
248 $admin->row_span('<a href="autoaction.php?do=add">[' . $lang->string('New Automatic Action') . ']</a>', 'tfoot', 'center', 3);
254 /*=====================================================================*\
255 || ###################################################################
258 || ###################################################################
259 \*=====================================================================*/