]>
src.bluestatic.org Git - bugdar.git/blob - admin/automation.php
2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright (c)2004-2008 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_automation.php');
25 APIError(array(new API_Error_Handler($admin), 'admin_error'));
27 NavLinks
::fieldsPages();
28 $navigator->set_focus('tab', 'fields', null);
30 if (!can_perform('canadminbugs'))
35 // ###################################################################
37 if (empty($_REQUEST['do']))
39 $_REQUEST['do'] = 'modify';
42 // ###################################################################
44 if ($_REQUEST['do'] == 'kill')
46 $action = new AutomationAPI();
47 $action->set('actionid', $input->in
['actionid']);
48 $action->set_condition();
51 $admin->redirect('automation.php?do=modify');
54 // ###################################################################
56 if ($_REQUEST['do'] == 'delete')
58 $admin->page_confirm(T('Are you sure you want to delete this automation?'), 'automation.php', 'kill', array('actionid' => $input->in
['actionid']));
61 // ###################################################################
63 if ($_POST['do'] == 'insert' OR $_POST['do'] == 'update')
65 $deltas = array('builtin' => array(), 'custom' => array());
67 if (is_array($input->in
['fields']))
69 foreach ($input->in
['fields'] AS $key => $value)
71 if (!empty($value) AND $value != -1 AND !is_array($value))
73 $deltas['builtin']["$key"] = $value;
78 if (is_array($input->in['fields']['custom']))
80 foreach ($input->in['fields']['custom'] AS $key => $value)
82 if ($value != '' AND $value != -1)
84 $deltas['custom']["$key"] = $value;
89 $action = new AutomationAPI();
90 $action->set('name', $input->in
['name']);
91 $action->set('description', $input->in
['description']);
92 $action->set('fieldchanges', $deltas);
93 $action->set('comment', $input->in
['comment']);
95 if ($_POST['do'] == 'insert')
99 $admin->redirect('automation.php');
103 $action->set('actionid', $input->in
['actionid']);
104 $action->set_condition();
107 $admin->redirect('automation.php');
111 // ###################################################################
113 if ($_REQUEST['do'] == 'add' OR $_REQUEST['do'] == 'edit')
115 $add = ($_REQUEST['do'] == 'add');
120 NavLinks
::automationsEdit($input->in
['actionid']);
121 $navigator->set_focus('link', 'fields-pages-automations', 'fields-pages');
123 $action = new AutomationAPI();
124 $action->set('actionid', $input->in
['actionid']);
125 $action->set_condition();
127 $action->record
['fields'] = unserialize($action->record
['fieldchanges']);
131 NavLinks
::automationsAdd();
132 $navigator->set_focus('link', 'automations-add', 'automations');
135 $admin->page_start(($add ? T('New Automation') : T('Edit Automation')));
137 $admin->form_start('automation.php', ($add ? 'insert' : 'update'));
141 $admin->form_hidden_field('actionid', $action->record
['actionid']);
144 $admin->table_start();
145 $admin->table_head(($add ? T('New Automation') : T('Edit Automation')));
147 $admin->row_input(T('Name'), 'name', $action->record
['name']);
148 $admin->row_textarea(T('Description'), 'description', $action->record
['description']);
149 $admin->row_textarea(T('Add Comment'), 'comment', $action->record
['comment']);
151 $admin->row_span(T('Field Changes'), 'thead', 'center');
153 // -------------------------------------------------------------------
155 construct_datastore_select('severity', 'severity', 'severityid', $action->record
['fields']['builtin']['severity'], true, true);
156 $admin->row_list(T('Severity'), 'fields[severity]');
158 construct_datastore_select('priority', 'priority', 'priorityid', $action->record
['fields']['builtin']['priority'], true, true);
159 $admin->row_list(T('Priority'), 'fields[priority]');
161 construct_datastore_select('status', 'status', 'statusid', $action->record
['fields']['builtin']['status'], true, true);
162 $admin->row_list(T('Status'), 'fields[status]');
164 construct_datastore_select('resolution', 'resolution', 'resolutionid', $action->record
['fields']['builtin']['resolution'], true, true);
165 $admin->row_list(T('Resolution'), 'fields[resolution]');
167 $admin->row_span('', 'tcat', 'center');
169 // -------------------------------------------------------------------
171 $fields_fetch = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bugfield ORDER BY fieldid ASC");
172 foreach ($fields_fetch as $field)
174 switch ($field['type'])
177 $admin->row_input($field['name'], "fields[custom][$field[fieldid]]", $action->record
['fields']['custom']["$field[fieldid]"]);
180 case 'input_checkbox':
181 $admin->list_item('', -1, (!$action->record
['fields']['custom']["$field[fieldid]"] OR $action->record
['fields']['custom']["$field[fieldid]"] == -1));
182 $admin->list_item(T('Checked'), 1, ($action->record
['fields']['custom']["$field[fieldid]"] == 1));
183 $admin->list_item(T('Un-Checked'), 0, (isset($action->record
['fields']['custom']["$field[fieldid]"]) AND $action->record
['fields']['custom']["$field[fieldid]"] == 0));
184 $admin->row_list($field['name'], "fields[custom][$field[fieldid]]");
187 case 'select_single':
188 $selectopts = unserialize($field['selects']);
190 $admin->list_item('', -1, (!isset($action->record
['fields']['custom']["$field[fieldid]"]) OR $action->record
['fields']['custom']["$field[fieldid]"] == -1));
192 foreach ($selectopts AS $id => $select)
194 $admin->list_item(stripslashes($select), $id, (isset($action->record
['fields']['custom']["$field[fieldid]"]) AND $action->record
['fields']['custom']["$field[fieldid]"] == $id));
196 $admin->row_list($field['name'], "fields[custom][$field[fieldid]]");
202 $admin->row_submit();
209 // ###################################################################
211 if ($_REQUEST['do'] == 'modify')
213 NavLinks
::automationsAdd();
214 $navigator->set_focus('link', 'fields-pages-automations', 'fields-pages');
216 $admin->page_start(T('Automations'));
218 $admin->table_start();
219 $admin->table_head(T('Automations'));
221 $actions = $db->query("SELECT * FROM " . TABLE_PREFIX
. "automation ORDER BY name ASC");
222 foreach ($actions as $action)
224 $admin->row_text($action['name'] . "\n<div class=\"smallfont\">$action[description]</div>", "<a href=\"automation.php?do=edit&actionid=$action[actionid]\">[" . T('Edit') . "]</a> <a href=\"automation.php?do=delete&actionid=$action[actionid]\">[" . T('Delete') . "]</a>");