]>
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 (!empty($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') ? true : false);
117 $edit = (($add) ? false : true);
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 = $bugsys->db
->query("
174 FROM " . TABLE_PREFIX
. "bugfield AS bugfield
175 LEFT JOIN " . TABLE_PREFIX
. "bugfieldpermission AS permission
176 ON (bugfield.fieldid = permission.fieldid)
177 WHERE permission.mask <> 0
178 AND permission.usergroupid = {$bugsys->userinfo['usergroupid']}
179 AND bugfield.cansearch = 1"
181 while ($field = $bugsys->db
->fetch_array($fields_fetch))
183 switch ($field['type'])
186 $admin->row_input($field['name'], "fields[custom][$field[fieldid]]", $action->objdata
['fields']['custom']["$field[fieldid]"]);
189 case 'input_checkbox':
190 $admin->list_item('', 0, ((!$action->objdata
['fields']['custom']["$field[fieldid]"]) ? true : false));
191 $admin->list_item(_('Checked'), 1, (($action->objdata
['fields']['custom']["$field[fieldid]"] == 1) ? true : false));
192 $admin->list_item(_('Un-Checked'), 2, (($action->objdata
['fields']['custom']["$field[fieldid]"] == 2) ? true : false));
193 $admin->row_list($field['name'], "fields[custom][$field[fieldid]]");
196 case 'select_single':
197 $selectopts = unserialize($field['selects']);
199 $admin->list_item('', -1, ((!$action->objdata
['fields']['custom']["$field[fieldid]"]) ? true : false));
201 foreach ($selectopts AS $id => $select)
203 $admin->list_item(stripslashes($select), $id, (($action->objdata
['fields']['custom']["$field[fieldid]"] == $id AND $edit) ? true : false));
205 $admin->row_list($field['name'], "fields[custom][$field[fieldid]]");
211 $admin->row_submit();
218 // ###################################################################
220 if ($_REQUEST['do'] == 'modify')
222 NavLinks
::automationsAdd();
223 $navigator->set_focus('link', 'fields-pages-automations', 'fields-pages');
225 $admin->page_start(_('Automations'));
227 $admin->table_start();
228 $admin->table_head(_('Automations'));
230 $actions = $db->query("SELECT * FROM " . TABLE_PREFIX
. "automation ORDER BY name ASC");
231 while ($action = $db->fetch_array($actions))
233 $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>");
241 /*=====================================================================*\
242 || ###################################################################
245 || ###################################################################
246 \*=====================================================================*/