From ffc4222d10c4543413f32c31c47c81bc6a3bfddd Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 26 Jun 2005 23:18:07 +0000 Subject: [PATCH] r272: Delete and kill brances are done --- admin/autoaction.php | 83 ++++++++++++++++++++++++++++---------------- 1 file changed, 54 insertions(+), 29 deletions(-) diff --git a/admin/autoaction.php b/admin/autoaction.php index a6074f3..556582f 100644 --- a/admin/autoaction.php +++ b/admin/autoaction.php @@ -28,19 +28,33 @@ if (empty($_REQUEST['do'])) if ($_REQUEST['do'] == 'kill') { - // run code to remove item in database + $action = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "autoaction WHERE actionid = " . intval($bugsys->in['actionid'])); + if (!$action) + { + $admin->error(lang::p('error_invalid_id')); + } + + $db->query("DELETE FROM " . TABLE_PREFIX . "autoaction WHERE actionid = $action[actionid]"); + + $admin->redirect('autoaction.php?do=modify'); } // ################################################################### if ($_REQUEST['do'] == 'delete') { - // display delete confirmation message + $action = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "autoaction WHERE actionid = " . intval($bugsys->in['actionid'])); + if (!$action) + { + $admin->error(lang::p('error_invalid_id')); + } + + $admin->page_confirm('Are you sure you want to delete this action?', "autoaction.php?do=kill&actionid=$action[actionid]"); } // ################################################################### -if ($_POST['do'] == 'insert') +if ($_POST['do'] == 'insert' OR $_POST['do'] == 'update') { if (empty($bugsys->in['name'])) { @@ -68,23 +82,36 @@ if ($_POST['do'] == 'insert') $admin->error('You need to specify some fields to change.'); } - $db->query(" - INSERT INTO " . TABLE_PREFIX . "autoaction - (name, description, fieldchanges) - VALUES - ('" . $bugsys->in['name'] . "', '" . $bugsys->in['description'] . "', - '" . $bugsys->escape(serialize($deltas)) . "' - )" - ); - - $admin->redirect('autoaction.php', 'Action added.'); -} - -// ################################################################### - -if ($_POST['do'] == 'update') -{ - // run code to update item in database + if ($_POST['do'] == 'insert') + { + $db->query(" + INSERT INTO " . TABLE_PREFIX . "autoaction + (name, description, fieldchanges) + VALUES + ('" . $bugsys->in['name'] . "', '" . $bugsys->in['description'] . "', + '" . $bugsys->escape(serialize($deltas)) . "' + )" + ); + + $admin->redirect('autoaction.php'); + } + else + { + if (!$bugsys->in['actionid']) + { + $admin->error(lang::p('error_invalid_id')); + } + + $db->query(" + UPDATE " . TABLE_PREFIX . "autoaction + SET name = '" . $bugsys->in['name'] . "', + description = '" . $bugsys->in['description'] . "', + fieldchanges = '" . $bugsys->escape(serialize($deltas)) . "' + WHERE actionid = " . intval($bugsys->in['actionid']) + ); + + $admin->redirect('autoaction.php'); + } } // ################################################################### @@ -107,6 +134,12 @@ if ($_REQUEST['do'] == 'add' OR $_REQUEST['do'] == 'edit') $admin->page_start((($add) ? 'New Automatic Action' : 'Edit Auto Action')); $admin->form_start('autoaction.php', (($add) ? 'insert' : 'update')); + + if ($edit) + { + $admin->form_hidden_field('actionid', $action['actionid']); + } + $admin->table_start(); $admin->table_head((($add) ? 'New Automatic Action' : 'Edit Auto Action')); @@ -129,14 +162,6 @@ if ($_REQUEST['do'] == 'add' OR $_REQUEST['do'] == 'edit') construct_datastore_select('resolution', 'resolution', 'resolutionid', $action['fields']['builtin']['resolution'], true, true); $admin->row_list('Resolution', 'fields[resolution]'); - /*$select['dev'] = ''; - foreach ($bugsys->datastore['assignto'] AS $dev) - { - $value = $dev['userid']; - $label = construct_user_display($dev, false); - eval('$select[dev] .= "' . $template->fetch('selectoption') . '";'); - }*/ - $admin->row_span('', 'tcat', 'center'); // ------------------------------------------------------------------- @@ -172,7 +197,7 @@ if ($_REQUEST['do'] == 'add' OR $_REQUEST['do'] == 'edit') foreach ($selectopts AS $id => $select) { - $admin->list_item(stripslashes($select), $id, (($action['fields']['custom']["$field[fieldid]"] == $id) ? true : false)); + $admin->list_item(stripslashes($select), $id, (($action['fields']['custom']["$field[fieldid]"] == $id AND $edit) ? true : false)); } $admin->row_list($field['name'], "fields[custom][$field[fieldid]]"); break; -- 2.22.5