$fetchtemplates = array(
'search',
'search_results',
+ 'search_update',
'trackerhome_bits',
'list_head',
'pagenav_bit',
require_once('./global.php');
require_once('./includes/functions_product.php');
require_once('./includes/class_sort.php');
+require_once('./includes/api_bug.php');
+require_once('./includes/class_api_error.php');
+
+APIError(array($message, 'error'));
if (!can_perform('cansearch'))
{
// ###################################################################
+if ($_REQUEST['do'] == 'update')
+{
+ $search = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "search WHERE searchid = " . $bugsys->input_clean('searchid', TYPE_UINT) . " AND userid = " . $bugsys->userinfo['userid']);
+ if (!$search)
+ {
+ $message->error_permission();
+ }
+
+ $productSelect = ConstructProductSelect();
+
+ $show['update'] = true;
+
+ // -------------------------------------------------------------------
+ // custom fields
+ $fields = construct_custom_fields(null, true, false, true);
+ $i = 0;
+ foreach ($fields AS $field)
+ {
+ if ($i % 2 == 0)
+ {
+ $customfields['left'] .= $field;
+ }
+ else
+ {
+ $customfields['right'] .= $field;
+ }
+ $i++;
+ }
+
+ // -------------------------------------------------------------------
+ // built-in fields
+ $select['severity'] = construct_datastore_select('severity', 'severity', 'severityid', 0, 0);
+ $select['priority'] = construct_datastore_select('priority', 'priority', 'priorityid', 0, 0);
+ $select['status'] = construct_datastore_select('status', 'status', 'statusid', 0, 0);
+ $select['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid', 0, 0);
+
+ $select['dev'] = '';
+ $value = '0';
+ $label = '';
+ $selected = true;
+ eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
+ $selected = false;
+ foreach ($bugsys->datastore['assignto'] AS $dev)
+ {
+ $value = $dev['userid'];
+ $label = construct_user_display($dev, false);
+ eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
+ }
+
+ eval('$template->flush("' . $template->fetch('search_update') . '");');
+}
+
+// ###################################################################
+
+if ($_POST['do'] == 'doupdate')
+{
+ $search = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "search WHERE searchid = " . $bugsys->input_clean('searchid', TYPE_UINT) . " AND userid = " . $bugsys->userinfo['userid']);
+ if (!$search)
+ {
+ $message->error_permission();
+ }
+
+ // find all the bugs that we can edit
+ $bugs = $db->query("
+ SELECT * FROM " . TABLE_PREFIX . "bug
+ WHERE bugid IN ($search[ids])
+ AND product IN (" . fetch_on_bits('canviewbugs') . ")
+ AND
+ (
+ product IN (" . fetch_on_bits('caneditother') . ")
+ OR
+ (userid = " . $bugsys->userinfo['userid'] . " AND product IN (" . fetch_on_bits('caneditown') . "))
+ )
+ ");
+ while ($bug = $db->fetch_array($bugs))
+ {
+ if (!((can_perform('caneditown', $bug['product']) AND $bugsys->userinfo['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['product']) AND $bugsys->userinfo['userid'] != $bug['userid'])) AND !can_perform('canpostcomments', $bug['product']))
+ {
+ continue;
+ }
+
+ // TODO - need to add logging for custom fields
+
+ $api = new BugApi($bugsys);
+ $log = new Logging();
+ $log->set_bugid($bug['bugid']);
+ $log->add_data(true, $bug, $log->getCommonFields());
+
+ if ($bugsys->in['status'] AND can_perform('canchangestatus', $bug['product']))
+ {
+ $api->set('status', $bugsys->in['status']);
+ }
+ if ($bugsys->in['priority'] AND can_perform('canchangestatus', $bug['product']))
+ {
+ $api->set('priority', $bugsys->in['priority']);
+ }
+ if ($bugsys->in['severity'])
+ {
+ $api->set('severity', $bugsys->in['severity']);
+ }
+ if ($bugsys->in['resolution'] AND can_perform('canchangestatus', $bug['product']))
+ {
+ $api->set('resolution', $bugsys->in['resolution']);
+ }
+ if ($bugsys->in['assignedto'] AND can_perform('canassign', $bug['product']))
+ {
+ $api->set('severity', $bugsys->in['severity']);
+ }
+ if ($bugsys->in['product'])
+ {
+ $product = explode(',', $bugsys->in['product']);
+ $api->set('product', $product[0]);
+ $api->set('component', $product[1]);
+ $api->set('version', $product[2]);
+ }
+
+ $log->add_data(false, $api->values, $log->getCommonFields());
+
+ process_custom_fields($bug['bugid'], $message);
+
+ $api->update();
+ $log->update_history();
+ }
+
+ $message->redirect(_('The specified bugs have been updated and you will now return to your search results.'), 'search.php?do=results&searchid=' . $bugsys->in['searchid']);
+}
+
+// ###################################################################
+
if ($_REQUEST['do'] == 'export')
{
if (!$bugsys->in['searchid'] AND $bugsys->userinfo['userid'])