]>
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/api_autoaction.php');
25 NavLinks
::fieldsPages();
26 $navigator->set_focus('tab', 'fields', null);
28 if (!can_perform('canadminbugs'))
33 // ###################################################################
35 if (empty($_REQUEST['do']))
37 $_REQUEST['do'] = 'modify';
40 // ###################################################################
42 if ($_REQUEST['do'] == 'kill')
44 $action = new AutoActionAPI($bugsys);
45 $action->set('actionid', $bugsys->in
['actionid']);
46 $action->set_condition();
49 $admin->redirect('autoaction.php?do=modify');
52 // ###################################################################
54 if ($_REQUEST['do'] == 'delete')
56 $admin->page_confirm($lang->string('Are you sure you want to delete this action?'), "autoaction.php?do=kill&actionid=$action[actionid]");
59 // ###################################################################
61 if ($_POST['do'] == 'insert' OR $_POST['do'] == 'update')
63 foreach ($bugsys->in
['fields'] AS $key => $value)
65 if (!empty($value) AND $value != -1 AND !is_array($value))
67 $deltas['builtin']["$key"] = $value;
71 foreach ($bugsys->in['fields']['custom'] AS $key => $value)
73 if (!empty($value) AND $value != -1)
75 $deltas['custom']["$key"] = $value;
79 $action = new AutoActionAPI($bugsys);
80 $action->set('name', $bugsys->in
['name']);
81 $action->set('description', $bugsys->in
['description']);
82 $action->set('fieldchanges', $deltas);
83 $action->set('comment', $bugsys->in
['comment']);
85 if ($_POST['do'] == 'insert')
89 $admin->redirect('autoaction.php');
93 $action->set('actionid', $bugsys->in
['actionid']);
94 $action->set_condition();
97 $admin->redirect('autoaction.php');
101 // ###################################################################
103 if ($_REQUEST['do'] == 'add' OR $_REQUEST['do'] == 'edit')
105 $add = (($_REQUEST['do'] == 'add') ? true : false);
106 $edit = (($add) ? false : true);
110 NavLinks
::autoactionsEdit($bugsys->in
['actionid']);
111 $navigator->set_focus('link', 'fields-pages-autoactions', 'fields-pages');
113 $action = new AutoActionAPI($bugsys);
114 $action->set('actionid', $bugsys->in
['actionid']);
115 $action->set_condition();
117 $action->objdata
['fields'] = unserialize($action->objdata
['fieldchanges']);
121 NavLinks
::autoactionsAdd();
122 $navigator->set_focus('link', 'autoactions-add', 'autoactions');
125 $admin->page_start(($add ? $lang->string('New Automatic Action') : $lang->string('Edit Automatic Action')));
127 $admin->form_start('autoaction.php', ($add ? 'insert' : 'update'));
131 $admin->form_hidden_field('actionid', $action->objdata
['actionid']);
134 $admin->table_start();
135 $admin->table_head(($add ? $lang->string('New Automatic Action') : $lang->string('Edit Automatic Action')));
137 $admin->row_input($lang->string('Name'), 'name', $action->objdata
['name']);
138 $admin->row_textarea($lang->string('Description'), 'description', $action->objdata
['description']);
139 $admin->row_textarea($lang->string('Add Comment'), 'comment', $action->objdata
['comment']);
141 $admin->row_span($lang->string('Field Changes'), 'thead', 'center');
143 // -------------------------------------------------------------------
145 construct_datastore_select('severity', 'severity', 'severityid', $action->objdata
['fields']['builtin']['severity'], true, true);
146 $admin->row_list($lang->string('Severity'), 'fields[severity]');
148 construct_datastore_select('priority', 'priority', 'priorityid', $action->objdata
['fields']['builtin']['priority'], true, true);
149 $admin->row_list($lang->string('Priority'), 'fields[priority]');
151 construct_datastore_select('status', 'status', 'statusid', $action->objdata
['fields']['builtin']['status'], true, true);
152 $admin->row_list($lang->string('Status'), 'fields[status]');
154 construct_datastore_select('resolution', 'resolution', 'resolutionid', $action->objdata
['fields']['builtin']['resolution'], true, true);
155 $admin->row_list($lang->string('Resolution'), 'fields[resolution]');
157 $admin->row_span('', 'tcat', 'center');
159 // -------------------------------------------------------------------
161 $fields_fetch = $bugsys->db
->query("
163 FROM " . TABLE_PREFIX
. "bugfield AS bugfield
164 LEFT JOIN " . TABLE_PREFIX
. "bugfieldpermission AS permission
165 ON (bugfield.fieldid = permission.fieldid)
166 WHERE permission.mask <> 0
167 AND permission.usergroupid = {$bugsys->userinfo['usergroupid']}
168 AND bugfield.cansearch = 1"
170 while ($field = $bugsys->db
->fetch_array($fields_fetch))
172 switch ($field['type'])
175 $admin->row_input($field['name'], "fields[custom][$field[fieldid]]", $action->objdata
['fields']['custom']["$field[fieldid]"]);
178 case 'input_checkbox':
179 $admin->list_item('', 0, ((!$action->objdata
['fields']['custom']["$field[fieldid]"]) ? true : false));
180 $admin->list_item($lang->string('Checked'), 1, (($action->objdata
['fields']['custom']["$field[fieldid]"] == 1) ? true : false));
181 $admin->list_item($lang->string('Un-Checked'), 2, (($action->objdata
['fields']['custom']["$field[fieldid]"] == 2) ? true : false));
182 $admin->row_list($field['name'], "fields[custom][$field[fieldid]]");
185 case 'select_single':
186 $selectopts = unserialize($field['selects']);
188 $admin->list_item('', -1, ((!$action->objdata
['fields']['custom']["$field[fieldid]"]) ? true : false));
190 foreach ($selectopts AS $id => $select)
192 $admin->list_item(stripslashes($select), $id, (($action->objdata
['fields']['custom']["$field[fieldid]"] == $id AND $edit) ? true : false));
194 $admin->row_list($field['name'], "fields[custom][$field[fieldid]]");
200 $admin->row_submit();
207 // ###################################################################
209 if ($_REQUEST['do'] == 'modify')
211 NavLinks
::autoactionsAdd();
212 $navigator->set_focus('link', 'fields-pages-autoactions', 'fields-pages');
214 $admin->page_start($lang->string('Automatic Actions'));
216 $admin->table_start();
217 $admin->table_head($lang->string('Automatic Actions'));
219 $actions = $db->query("SELECT * FROM " . TABLE_PREFIX
. "autoaction ORDER BY name ASC");
220 while ($action = $db->fetch_array($actions))
222 $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>");
230 /*=====================================================================*\
231 || ###################################################################
234 || ###################################################################
235 \*=====================================================================*/