]>
src.bluestatic.org Git - bugdar.git/blob - admin/autoaction.php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # Bugdar [#]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('canadminbugs'))
21 // ###################################################################
23 if (empty($_REQUEST['do']))
25 $_REQUEST['do'] = 'modify';
28 // ###################################################################
30 if ($_REQUEST['do'] == 'kill')
32 $action = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "autoaction WHERE actionid = " . intval($bugsys->in
['actionid']));
35 $admin->error($lang->getlex('error_invalid_id'));
38 $db->query("DELETE FROM " . TABLE_PREFIX
. "autoaction WHERE actionid = $action[actionid]");
42 $admin->redirect('autoaction.php?do=modify');
45 // ###################################################################
47 if ($_REQUEST['do'] == 'delete')
49 $action = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "autoaction WHERE actionid = " . intval($bugsys->in
['actionid']));
52 $admin->error($lang->getlex('error_invalid_id'));
55 $admin->page_confirm($lang->string('Are you sure you want to delete this action?'), "autoaction.php?do=kill&actionid=$action[actionid]");
58 // ###################################################################
60 if ($_POST['do'] == 'insert' OR $_POST['do'] == 'update')
62 if (empty($bugsys->in
['name']))
64 $admin->error($lang->string('You need to specify a name for this action.'));
67 foreach ($bugsys->in
['fields'] AS $key => $value)
69 if (!empty($value) AND $value != -1 AND !is_array($value))
71 $deltas['builtin']["$key"] = $value;
75 foreach ($bugsys->in['fields']['custom'] AS $key => $value)
77 if (!empty($value) AND $value != -1)
79 $deltas['custom']["$key"] = $value;
83 if (count($deltas['custom']) < 1 AND count($deltas['builtin']) < 1)
85 $admin->error($lang->string('You need to specify some fields to change.'));
88 if ($_POST['do'] == 'insert')
91 INSERT INTO " . TABLE_PREFIX
. "autoaction
92 (name, description, fieldchanges, comment)
94 ('" . $bugsys->in
['name'] . "', '" . $bugsys->in
['description'] . "',
95 '" . $bugsys->escape(serialize($deltas)) . "', '" . $bugsys->in
['comment'] . "'
101 $admin->redirect('autoaction.php');
105 if (!$bugsys->in
['actionid'])
107 $admin->error($lang->getlex('error_invalid_id'));
111 UPDATE " . TABLE_PREFIX
. "autoaction
112 SET name = '" . $bugsys->in
['name'] . "',
113 description = '" . $bugsys->in
['description'] . "',
114 fieldchanges = '" . $bugsys->escape(serialize($deltas)) . "',
115 comment = '" . $bugsys->in
['comment'] . "'
116 WHERE actionid = " . intval($bugsys->in
['actionid'])
119 build_auto_actions();
121 $admin->redirect('autoaction.php');
125 // ###################################################################
127 if ($_REQUEST['do'] == 'add' OR $_REQUEST['do'] == 'edit')
129 $add = (($_REQUEST['do'] == 'add') ? true : false);
130 $edit = (($add) ? false : true);
134 $action = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "autoaction WHERE actionid = " . intval($bugsys->in
['actionid']));
137 $admin->error($lang->getlex('error_invalid_id'));
139 $action['fields'] = unserialize($action['fieldchanges']);
142 $admin->page_start(($add ? $lang->string('New Automatic Action') : $lang->string('Edit Automatic Action')));
144 $admin->form_start('autoaction.php', ($add ? 'insert' : 'update'));
148 $admin->form_hidden_field('actionid', $action['actionid']);
151 $admin->table_start();
152 $admin->table_head(($add ? $lang->string('New Automatic Action') : $lang->string('Edit Automatic Action')), 2, 'automatic_actions');
154 $admin->row_input($lang->string('Name'), 'name', $action['name']);
155 $admin->row_textarea($lang->string('Description'), 'description', $action['description']);
156 $admin->row_textarea($lang->string('Add Comment'), 'comment', $action['comment']);
158 $admin->row_span($lang->string('Field Changes'), 'thead', 'center');
160 // -------------------------------------------------------------------
162 construct_datastore_select('severity', 'severity', 'severityid', $action['fields']['builtin']['severity'], true, true);
163 $admin->row_list($lang->string('Severity'), 'fields[severity]');
165 construct_datastore_select('priority', 'priority', 'priorityid', $action['fields']['builtin']['priority'], true, true);
166 $admin->row_list($lang->string('Priority'), 'fields[priority]');
168 construct_datastore_select('status', 'status', 'statusid', $action['fields']['builtin']['status'], true, true);
169 $admin->row_list($lang->string('Status'), 'fields[status]');
171 construct_datastore_select('resolution', 'resolution', 'resolutionid', $action['fields']['builtin']['resolution'], true, true);
172 $admin->row_list($lang->string('Resolution'), 'fields[resolution]');
174 $admin->row_span('', 'tcat', 'center');
176 // -------------------------------------------------------------------
178 $fields_fetch = $bugsys->db
->query("
180 FROM " . TABLE_PREFIX
. "bugfield AS bugfield
181 LEFT JOIN " . TABLE_PREFIX
. "bugfieldpermission AS permission
182 ON (bugfield.fieldid = permission.fieldid)
183 WHERE permission.mask <> 0
184 AND permission.usergroupid = {$bugsys->userinfo['usergroupid']}
185 AND bugfield.cansearch = 1"
187 while ($field = $bugsys->db
->fetch_array($fields_fetch))
189 switch ($field['type'])
192 $admin->row_input($field['name'], "fields[custom][$field[fieldid]]", $action['fields']['custom']["$field[fieldid]"]);
195 case 'input_checkbox':
196 $admin->list_item('', 0, ((!$action['fields']['custom']["$field[fieldid]"]) ? true : false));
197 $admin->list_item($lang->string('Checked'), 1, (($action['fields']['custom']["$field[fieldid]"] == 1) ? true : false));
198 $admin->list_item($lang->string('Un-Checked'), 2, (($action['fields']['custom']["$field[fieldid]"] == 2) ? true : false));
199 $admin->row_list($field['name'], "fields[custom][$field[fieldid]]");
202 case 'select_single':
203 $selectopts = unserialize($field['selects']);
205 $admin->list_item('', -1, ((!$action['fields']['custom']["$field[fieldid]"]) ? true : false));
207 foreach ($selectopts AS $id => $select)
209 $admin->list_item(stripslashes($select), $id, (($action['fields']['custom']["$field[fieldid]"] == $id AND $edit) ? true : false));
211 $admin->row_list($field['name'], "fields[custom][$field[fieldid]]");
217 $admin->row_submit();
224 // ###################################################################
226 if ($_REQUEST['do'] == 'modify')
228 $admin->page_start($lang->string('Automatic Actions'));
230 $admin->table_start();
231 $admin->table_head($lang->string('Automatic Actions'), 2, 'automatic_actions');
233 $actions = $db->query("SELECT * FROM " . TABLE_PREFIX
. "autoaction ORDER BY name ASC");
234 while ($action = $db->fetch_array($actions))
236 $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>");
239 $admin->row_span('<a href="autoaction.php?do=add">[' . $lang->string('New Automatic Action') . ']</a>', 'tfoot', 'center', 3);
245 /*=====================================================================*\
246 || ###################################################################
249 || ###################################################################
250 \*=====================================================================*/