]>
src.bluestatic.org Git - bugdar.git/blob - admin/automation.php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] 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 [#]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/api_automation.php');
25 require_once('./includes/class_api_error.php');
26 APIError(array(new API_Error_Handler($admin), 'admin_error'));
28 NavLinks
::fieldsPages();
29 $navigator->set_focus('tab', 'fields', null);
31 if (!can_perform('canadminbugs'))
36 // ###################################################################
38 if (empty($_REQUEST['do']))
40 $_REQUEST['do'] = 'modify';
43 // ###################################################################
45 if ($_REQUEST['do'] == 'kill')
47 $action = new AutomationAPI($bugsys);
48 $action->set('actionid', $bugsys->in
['actionid']);
49 $action->set_condition();
52 $admin->redirect('automation.php?do=modify');
55 // ###################################################################
57 if ($_REQUEST['do'] == 'delete')
59 $admin->page_confirm(_('Are you sure you want to delete this automation?'), 'automation.php', 'kill', array('actionid' => $bugsys->in
['actionid']));
62 // ###################################################################
64 if ($_POST['do'] == 'insert' OR $_POST['do'] == 'update')
66 $deltas = array('builtin' => array(), 'custom' => array());
68 if (is_array($bugsys->in
['fields']))
70 foreach ($bugsys->in
['fields'] AS $key => $value)
72 if (!empty($value) AND $value != -1 AND !is_array($value))
74 $deltas['builtin']["$key"] = $value;
79 if (is_array($bugsys->in['fields']['custom']))
81 foreach ($bugsys->in['fields']['custom'] AS $key => $value)
83 if ($value != '' AND $value != -1)
85 $deltas['custom']["$key"] = $value;
90 $action = new AutomationAPI($bugsys);
91 $action->set('name', $bugsys->in
['name']);
92 $action->set('description', $bugsys->in
['description']);
93 $action->set('fieldchanges', $deltas);
94 $action->set('comment', $bugsys->in
['comment']);
96 if ($_POST['do'] == 'insert')
100 $admin->redirect('automation.php');
104 $action->set('actionid', $bugsys->in
['actionid']);
105 $action->set_condition();
108 $admin->redirect('automation.php');
112 // ###################################################################
114 if ($_REQUEST['do'] == 'add' OR $_REQUEST['do'] == 'edit')
116 $add = ($_REQUEST['do'] == 'add');
121 NavLinks
::automationsEdit($bugsys->in
['actionid']);
122 $navigator->set_focus('link', 'fields-pages-automations', 'fields-pages');
124 $action = new AutomationAPI($bugsys);
125 $action->set('actionid', $bugsys->in
['actionid']);
126 $action->set_condition();
128 $action->objdata
['fields'] = unserialize($action->objdata
['fieldchanges']);
132 NavLinks
::automationsAdd();
133 $navigator->set_focus('link', 'automations-add', 'automations');
136 $admin->page_start(($add ? _('New Automation') : _('Edit Automation')));
138 $admin->form_start('automation.php', ($add ? 'insert' : 'update'));
142 $admin->form_hidden_field('actionid', $action->objdata
['actionid']);
145 $admin->table_start();
146 $admin->table_head(($add ? _('New Automation') : _('Edit Automation')));
148 $admin->row_input(_('Name'), 'name', $action->objdata
['name']);
149 $admin->row_textarea(_('Description'), 'description', $action->objdata
['description']);
150 $admin->row_textarea(_('Add Comment'), 'comment', $action->objdata
['comment']);
152 $admin->row_span(_('Field Changes'), 'thead', 'center');
154 // -------------------------------------------------------------------
156 construct_datastore_select('severity', 'severity', 'severityid', $action->objdata
['fields']['builtin']['severity'], true, true);
157 $admin->row_list(_('Severity'), 'fields[severity]');
159 construct_datastore_select('priority', 'priority', 'priorityid', $action->objdata
['fields']['builtin']['priority'], true, true);
160 $admin->row_list(_('Priority'), 'fields[priority]');
162 construct_datastore_select('status', 'status', 'statusid', $action->objdata
['fields']['builtin']['status'], true, true);
163 $admin->row_list(_('Status'), 'fields[status]');
165 construct_datastore_select('resolution', 'resolution', 'resolutionid', $action->objdata
['fields']['builtin']['resolution'], true, true);
166 $admin->row_list(_('Resolution'), 'fields[resolution]');
168 $admin->row_span('', 'tcat', 'center');
170 // -------------------------------------------------------------------
172 $fields_fetch = $db->query("SELECT * FROM " . TABLE_PREFIX
. "bugfield ORDER BY fieldid ASC");
173 while ($field = $db->fetch_array($fields_fetch))
175 switch ($field['type'])
178 $admin->row_input($field['name'], "fields[custom][$field[fieldid]]", $action->objdata
['fields']['custom']["$field[fieldid]"]);
181 case 'input_checkbox':
182 $admin->list_item('', -1, (!$action->objdata
['fields']['custom']["$field[fieldid]"] OR $action->objdata
['fields']['custom']["$field[fieldid]"] == -1));
183 $admin->list_item(_('Checked'), 1, ($action->objdata
['fields']['custom']["$field[fieldid]"] == 1));
184 $admin->list_item(_('Un-Checked'), 0, (isset($action->objdata
['fields']['custom']["$field[fieldid]"]) AND $action->objdata
['fields']['custom']["$field[fieldid]"] == 0));
185 $admin->row_list($field['name'], "fields[custom][$field[fieldid]]");
188 case 'select_single':
189 $selectopts = unserialize($field['selects']);
191 $admin->list_item('', -1, (!isset($action->objdata
['fields']['custom']["$field[fieldid]"]) OR $action->objdata
['fields']['custom']["$field[fieldid]"] == -1));
193 foreach ($selectopts AS $id => $select)
195 $admin->list_item(stripslashes($select), $id, (isset($action->objdata
['fields']['custom']["$field[fieldid]"]) AND $action->objdata
['fields']['custom']["$field[fieldid]"] == $id));
197 $admin->row_list($field['name'], "fields[custom][$field[fieldid]]");
203 $admin->row_submit();
210 // ###################################################################
212 if ($_REQUEST['do'] == 'modify')
214 NavLinks
::automationsAdd();
215 $navigator->set_focus('link', 'fields-pages-automations', 'fields-pages');
217 $admin->page_start(_('Automations'));
219 $admin->table_start();
220 $admin->table_head(_('Automations'));
222 $actions = $db->query("SELECT * FROM " . TABLE_PREFIX
. "automation ORDER BY name ASC");
223 while ($action = $db->fetch_array($actions))
225 $admin->row_text($action['name'] . "\n<div class=\"smallfont\">$action[description]</div>", "<a href=\"automation.php?do=edit&actionid=$action[actionid]\">[" . _('Edit') . "]</a> <a href=\"automation.php?do=delete&actionid=$action[actionid]\">[" . _('Delete') . "]</a>");
233 /*=====================================================================*\
234 || ###################################################################
237 || ###################################################################
238 \*=====================================================================*/