]>
src.bluestatic.org Git - bugdar.git/blob - autoaction.php
b81adcd79645e7e67f12c2ae37986629b2d26162
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_autoaction.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 AutoActionAPI($bugsys);
48 $action->set('actionid', $bugsys->in
['actionid']);
49 $action->set_condition();
52 $admin->redirect('autoaction.php?do=modify');
55 // ###################################################################
57 if ($_REQUEST['do'] == 'delete')
59 $admin->page_confirm($lang->string('Are you sure you want to delete this action?'), "autoaction.php?do=kill&actionid=$action[actionid]");
62 // ###################################################################
64 if ($_POST['do'] == 'insert' OR $_POST['do'] == 'update')
66 foreach ($bugsys->in
['fields'] AS $key => $value)
68 if (!empty($value) AND $value != -1 AND !is_array($value))
70 $deltas['builtin']["$key"] = $value;
74 foreach ($bugsys->in['fields']['custom'] AS $key => $value)
76 if (!empty($value) AND $value != -1)
78 $deltas['custom']["$key"] = $value;
82 $action = new AutoActionAPI($bugsys);
83 $action->set('name', $bugsys->in
['name']);
84 $action->set('description', $bugsys->in
['description']);
85 $action->set('fieldchanges', $deltas);
86 $action->set('comment', $bugsys->in
['comment']);
88 if ($_POST['do'] == 'insert')
92 $admin->redirect('autoaction.php');
96 $action->set('actionid', $bugsys->in
['actionid']);
97 $action->set_condition();
100 $admin->redirect('autoaction.php');
104 // ###################################################################
106 if ($_REQUEST['do'] == 'add' OR $_REQUEST['do'] == 'edit')
108 $add = (($_REQUEST['do'] == 'add') ? true : false);
109 $edit = (($add) ? false : true);
113 NavLinks
::autoactionsEdit($bugsys->in
['actionid']);
114 $navigator->set_focus('link', 'fields-pages-autoactions', 'fields-pages');
116 $action = new AutoActionAPI($bugsys);
117 $action->set('actionid', $bugsys->in
['actionid']);
118 $action->set_condition();
120 $action->objdata
['fields'] = unserialize($action->objdata
['fieldchanges']);
124 NavLinks
::autoactionsAdd();
125 $navigator->set_focus('link', 'autoactions-add', 'autoactions');
128 $admin->page_start(($add ? $lang->string('New Automatic Action') : $lang->string('Edit Automatic Action')));
130 $admin->form_start('autoaction.php', ($add ? 'insert' : 'update'));
134 $admin->form_hidden_field('actionid', $action->objdata
['actionid']);
137 $admin->table_start();
138 $admin->table_head(($add ? $lang->string('New Automatic Action') : $lang->string('Edit Automatic Action')));
140 $admin->row_input($lang->string('Name'), 'name', $action->objdata
['name']);
141 $admin->row_textarea($lang->string('Description'), 'description', $action->objdata
['description']);
142 $admin->row_textarea($lang->string('Add Comment'), 'comment', $action->objdata
['comment']);
144 $admin->row_span($lang->string('Field Changes'), 'thead', 'center');
146 // -------------------------------------------------------------------
148 construct_datastore_select('severity', 'severity', 'severityid', $action->objdata
['fields']['builtin']['severity'], true, true);
149 $admin->row_list($lang->string('Severity'), 'fields[severity]');
151 construct_datastore_select('priority', 'priority', 'priorityid', $action->objdata
['fields']['builtin']['priority'], true, true);
152 $admin->row_list($lang->string('Priority'), 'fields[priority]');
154 construct_datastore_select('status', 'status', 'statusid', $action->objdata
['fields']['builtin']['status'], true, true);
155 $admin->row_list($lang->string('Status'), 'fields[status]');
157 construct_datastore_select('resolution', 'resolution', 'resolutionid', $action->objdata
['fields']['builtin']['resolution'], true, true);
158 $admin->row_list($lang->string('Resolution'), 'fields[resolution]');
160 $admin->row_span('', 'tcat', 'center');
162 // -------------------------------------------------------------------
164 $fields_fetch = $bugsys->db
->query("
166 FROM " . TABLE_PREFIX
. "bugfield AS bugfield
167 LEFT JOIN " . TABLE_PREFIX
. "bugfieldpermission AS permission
168 ON (bugfield.fieldid = permission.fieldid)
169 WHERE permission.mask <> 0
170 AND permission.usergroupid = {$bugsys->userinfo['usergroupid']}
171 AND bugfield.cansearch = 1"
173 while ($field = $bugsys->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('', 0, ((!$action->objdata
['fields']['custom']["$field[fieldid]"]) ? true : false));
183 $admin->list_item($lang->string('Checked'), 1, (($action->objdata
['fields']['custom']["$field[fieldid]"] == 1) ? true : false));
184 $admin->list_item($lang->string('Un-Checked'), 2, (($action->objdata
['fields']['custom']["$field[fieldid]"] == 2) ? true : false));
185 $admin->row_list($field['name'], "fields[custom][$field[fieldid]]");
188 case 'select_single':
189 $selectopts = unserialize($field['selects']);
191 $admin->list_item('', -1, ((!$action->objdata
['fields']['custom']["$field[fieldid]"]) ? true : false));
193 foreach ($selectopts AS $id => $select)
195 $admin->list_item(stripslashes($select), $id, (($action->objdata
['fields']['custom']["$field[fieldid]"] == $id AND $edit) ? true : false));
197 $admin->row_list($field['name'], "fields[custom][$field[fieldid]]");
203 $admin->row_submit();
210 // ###################################################################
212 if ($_REQUEST['do'] == 'modify')
214 NavLinks
::autoactionsAdd();
215 $navigator->set_focus('link', 'fields-pages-autoactions', 'fields-pages');
217 $admin->page_start($lang->string('Automatic Actions'));
219 $admin->table_start();
220 $admin->table_head($lang->string('Automatic Actions'));
222 $actions = $db->query("SELECT * FROM " . TABLE_PREFIX
. "autoaction 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=\"autoaction.php?do=edit&actionid=$action[actionid]\">[" . $lang->string('Edit') . "]</a> <a href=\"autoaction.php?do=delete&actionid=$action[actionid]\">[" . $lang->string('Delete') . "]</a>");
233 /*=====================================================================*\
234 || ###################################################################
237 || ###################################################################
238 \*=====================================================================*/