'pagenav'
);
-define('SVN', '$Id$');
$focus['search'] = 'focus';
require_once('./includes/class_sort.php');
require_once('./includes/class_logging.php');
require_once('./includes/api_bug.php');
-require_once('./includes/class_api_error.php');
-
-APIError(array($message, 'error'));
if (!can_perform('cansearch'))
{
define('MODE_ALL', 2);
define('MODE_RAW', 3);
-$var = $db->query_first("SHOW VARIABLES LIKE 'ft_min_word_len'");
+$var = $db->queryFirst("SHOW VARIABLES LIKE 'ft_min_word_len'");
define('SEARCH_WORD_MIN', $var['Value']);
$db->query("DELETE FROM " . TABLE_PREFIX . "search WHERE userid = 0 AND dateline < " . (TIMENOW - 3600));
if ($_REQUEST['do'] == 'search')
{
- if ($bugsys->in['new'])
+ if ($input->in['new'])
{
$newsearch = true;
}
- else if ($bugsys->in['searchid'])
+ else if ($input->in['searchid'])
{
- $cachedsearch = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "search WHERE searchid = " . $bugsys->input_clean('searchid', TYPE_UINT) . " AND userid = " . $bugsys->userinfo['userid']);
+ $cachedsearch = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "search WHERE searchid = " . $input->inputClean('searchid', TYPE_UINT) . " AND userid = " . bugdar::$userinfo['userid']);
}
- else if ($bugsys->userinfo['userid'])
+ else if (bugdar::$userinfo['userid'])
{
- $cachedsearch = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "search WHERE name IS NULL AND userid = " . $bugsys->userinfo['userid']);
+ $cachedsearch = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "search WHERE name IS NULL AND userid = " . bugdar::$userinfo['userid']);
}
else
{
if ($cachedsearch)
{
$show['cached'] = true;
- if ($cachedsearch['dateline'] < TIMENOW - 900 OR $bugsys->in['rerun'])
+ if ($cachedsearch['dateline'] < TIMENOW - 900 OR $input->in['rerun'])
{
$_REQUEST['do'] = 'process';
- $bugsys->in = array_merge(unserialize($cachedsearch['query']), $bugsys->in);
- $bugsys->debug('rerunning the search');
+ $input->in = array_merge(unserialize($cachedsearch['query']), $input->in);
+ BSApp::debug('rerunning the search');
}
else
{
if ($newsearch)
{
- if (!is_array($bugsys->datastore['product']))
+ if (!is_array(bugdar::$datastore['product']))
{
$message->error(T('No products are setup, therefore there can be no bugs and thus search cannot function.'));
}
- if (!is_array($bugsys->datastore['version']))
+ if (!is_array(bugdar::$datastore['version']))
{
$message->error(T('No versions have been added underneath your product(s), there can be no bugs and thus search cannot function.'));
}
- $productSelect = ConstructProductSelect();
-
// -------------------------------------------------------------------
// custom fields
$fields = construct_custom_fields(null, true, false, true);
$select['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid');
$searches = '';
- if ($bugsys->userinfo['userid'])
+ if (bugdar::$userinfo['userid'])
{
- $searchesFetch = $db->query("SELECT * FROM " . TABLE_PREFIX . "search WHERE name IS NOT NULL AND userid = " . $bugsys->userinfo['userid']);
- while ($search = $db->fetch_array($searchesFetch))
+ $searchesFetch = $db->query("SELECT * FROM " . TABLE_PREFIX . "search WHERE name IS NOT NULL AND userid = " . bugdar::$userinfo['userid']);
+ foreach ($searchesFetch as $search)
{
- $value = $search['searchid'];
- $label = $search['name'];
- eval('$searches .= "' . $template->fetch('selectoption') . '";');
+ $tpl = new BSTemplate('selectoption');
+ $tpl->vars = array(
+ 'value' => $search['searchid'],
+ 'label' => $search['name']
+ );
+ $searches .= $tpl->evaluate()->getTemplate();
}
}
$select['dev'] = '';
- foreach ($bugsys->datastore['assignto'] AS $dev)
+ foreach (bugdar::$datastore['assignto'] AS $dev)
{
- $value = $dev['userid'];
- $label = construct_user_display($dev, false);
- eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
+ $tpl = new BSTemplate('selectoption');
+ $tpl->vars = array(
+ 'value' => $dev['userid'],
+ 'label' => construct_user_display($dev, false)
+ );
+ $select['dev'] .= $tpl->evaluate()->getTemplate();
}
-
- eval('$template->flush("' . $template->fetch('search') . '");');
+
+ $tpl = new BSTemplate('search');
+ $tpl->vars = array(
+ 'select' => $select,
+ 'productSelect' => construct_product_select(),
+ 'customfields' => $customfields,
+ 'searches' => $searches
+ );
+ $tpl->evaluate()->flush();
}
}
{
// -------------------------------------------------------------------
// handle keywords
- if ($bugsys->in['summary'])
+ if ($input->in['summary'])
{
- $keywords = preg_split('#\s+#', $bugsys->in['summary']);
+ $keywords = preg_split('#\s+#', $input->in['summary']);
// TODO - need to have some str to bool conversions
continue;
}
- if ($bugsys->in['mode'] == MODE_ALL)
+ if ($input->in['mode'] == MODE_ALL)
{
$querybuild['text'] .= " +$word";
}
$temp = trim($querybuild['text']);
- if ($bugsys->in['mode'] == MODE_ALL OR $bugsys->in['mode'] == MODE_RAW)
+ if ($input->in['mode'] == MODE_ALL OR $input->in['mode'] == MODE_RAW)
{
$bool_flag = ' IN BOOLEAN MODE';
}
// -------------------------------------------------------------------
// reporter
- if ($bugsys->in['reporter'])
+ if ($input->in['reporter'])
{
// force email or name?? make a distinction?
// more elegant way to do this? probably
- $user = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE email LIKE '%" . str_replace('%', '\%', $bugsys->input_escape('reporter')) . "' OR displayname LIKE '%" . str_replace('%', '\%', $bugsys->input_escape('reporter')) . "%'");
+ $user = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "user WHERE email LIKE '%" . str_replace('%', '\%', $input->inputEscape('reporter')) . "' OR displayname LIKE '%" . str_replace('%', '\%', $input->inputEscape('reporter')) . "%'");
if ($user['userid'])
{
$querybuild['reporter'] = "AND bug.userid = $user[userid] OR comment.userid = $user[userid]";
// -------------------------------------------------------------------
// product/component/version stuff
- if (is_array($bugsys->in['product']))
+ if (is_array($input->in['product']))
{
- foreach ($bugsys->in['product'] AS $prod)
+ foreach ($input->in['product'] AS $prod)
{
$product = explode(',', $prod);
- $product = $bugsys->clean($product, TYPE_UINT);
+ $product = $input->clean($product, TYPE_UINT);
$products[] = $product[0];
$components[] = $product[1];
$versions[] = $product[2];
// severity, priority, status, resolution, assignedto
// severity
- if ($bugsys->in['severity'])
+ if ($input->in['severity'])
{
- $bugsys->input_clean('severity', TYPE_UINT);
- $querybuild['severity'] = "AND bug.severity IN (" . implode(',', $bugsys->in['severity']) . ")";
+ $input->inputClean('severity', TYPE_UINT);
+ $querybuild['severity'] = "AND bug.severity IN (" . implode(',', $input->in['severity']) . ")";
}
// priority
- if ($bugsys->in['priority'])
+ if ($input->in['priority'])
{
- $bugsys->input_clean('priority', TYPE_UINT);
- $querybuild['priority'] = "AND bug.priority IN (" . implode(',', $bugsys->in['priority']) . ")";
+ $input->inputClean('priority', TYPE_UINT);
+ $querybuild['priority'] = "AND bug.priority IN (" . implode(',', $input->in['priority']) . ")";
}
// status
- if ($bugsys->in['status'])
+ if ($input->in['status'])
{
- $bugsys->input_clean('status', TYPE_UINT);
- $querybuild['status'] = "AND bug.status IN (" . implode(',', $bugsys->in['status']) . ")";
+ $input->inputClean('status', TYPE_UINT);
+ $querybuild['status'] = "AND bug.status IN (" . implode(',', $input->in['status']) . ")";
}
// resolution
- if ($bugsys->in['resolution'])
+ if ($input->in['resolution'])
{
- $bugsys->input_clean('resolution', TYPE_UINT);
- $querybuild['resolution'] = "AND bug.resolution IN (" . implode(',', $bugsys->in['resolution']) . ")";
+ $input->inputClean('resolution', TYPE_UINT);
+ $querybuild['resolution'] = "AND bug.resolution IN (" . implode(',', $input->in['resolution']) . ")";
}
// assignment
- if ($bugsys->in['assignedto'])
+ if ($input->in['assignedto'])
{
- $bugsys->input_clean('assignedto', TYPE_UINT);
- $querybuild['assignedto'] = "AND bug.assignedto IN (" . implode(',', $bugsys->in['assignedto']) . ")";
+ $input->inputClean('assignedto', TYPE_UINT);
+ $querybuild['assignedto'] = "AND bug.assignedto IN (" . implode(',', $input->in['assignedto']) . ")";
}
// -------------------------------------------------------------------
// date
- if ($bugsys->in['date'])
+ if ($input->in['date'])
{
// now - (seconds/day * number of days)
- $dateline = time() - ($bugsys->input_clean('date', TYPE_INT) * 3600);
+ $dateline = time() - ($input->inputClean('date', TYPE_INT) * 3600);
$querybuild['date'] = "AND bug.dateline >= $dateline";
}
// -------------------------------------------------------------------
// favorites
- $bugsys->input_clean('favorite', TYPE_INT);
- if ($bugsys->in['favorite'] != 0 AND $bugsys->userinfo['userid'])
+ $input->inputClean('favorite', TYPE_INT);
+ if ($input->in['favorite'] != 0 AND bugdar::$userinfo['userid'])
{
- $favorites = $db->query("SELECT * FROM " . TABLE_PREFIX . "favorite WHERE userid = " . $bugsys->userinfo['userid']);
- while ($favorite = $db->fetch_array($favorites))
+ $favorites = $db->query("SELECT * FROM " . TABLE_PREFIX . "favorite WHERE userid = " . bugdar::$userinfo['userid']);
+ foreach ($favorites as $favorite)
{
$ids[] = $favorite['bugid'];
}
- $querybuild['favorites'] = "AND bug.bugid " . ($bugsys->in['favorite'] > 0 ? "IN" : "NOT IN") . " (" . implode(', ', $ids) . ")";
+ $querybuild['favorites'] = "AND bug.bugid " . ($input->in['favorite'] > 0 ? "IN" : "NOT IN") . " (" . implode(', ', $ids) . ")";
}
// -------------------------------------------------------------------
// sort by
$sortby = array('bugid', 'severity', 'priority', 'status', 'resolution', 'dateline');
$orderby = array('ASC', 'DESC');
- $bugsys->in['orderby'] = strtoupper($bugsys->in['orderby']);
- if (in_array($bugsys->in['sortby'], $sortby) AND in_array($bugsys->in['orderby'], $orderby))
+ $input->in['orderby'] = strtoupper($input->in['orderby']);
+ if (in_array($input->in['sortby'], $sortby) AND in_array($input->in['orderby'], $orderby))
{
- $sortclause = "ORDER BY " . $bugsys->in['sortby'] . ' ' . $bugsys->in['orderby'];
+ $sortclause = "ORDER BY " . $input->in['sortby'] . ' ' . $input->in['orderby'];
}
- else if ($bugsys->in['sortby'] == 'relevance')
+ else if ($input->in['sortby'] == 'relevance')
{
$sortclause = '';
}
// -------------------------------------------------------------------
// custom fields
- $fields_fetch = $bugsys->db->query("
+ $fields_fetch = $db->query("
SELECT bugfield.*, MAX(permission.mask) AS mask
FROM " . TABLE_PREFIX . "bugfield AS bugfield
LEFT JOIN " . TABLE_PREFIX . "bugfieldpermission AS permission
ON (bugfield.fieldid = permission.fieldid)
WHERE mask <> 0
- AND permission.usergroupid IN ({$bugsys->userinfo['usergroupid']}" . (sizeof($bugsys->userinfo['groupids']) != 0 ? ',' . implode(',', $bugsys->userinfo['groupids']) : '') . ")
+ AND permission.usergroupid IN (" . bugdar::$userinfo['usergroupid'] . (sizeof(bugdar::$userinfo['groupids']) != 0 ? ',' . implode(',', bugdar::$userinfo['groupids']) : '') . ")
AND bugfield.cansearch = 1
GROUP BY (bugfield.fieldid)"
);
- while ($field = $bugsys->db->fetch_array($fields_fetch))
+ foreach ($fields_fetch as $field)
{
- if (!empty($bugsys->in["custom$field[fieldid]"]) OR ($field['type'] == 'select_single' AND isset($bugsys->in["custom$field[fieldid]"])))
+ if (!empty($input->in["custom$field[fieldid]"]) OR ($field['type'] == 'select_single' AND isset($input->in["custom$field[fieldid]"])))
{
- if ($field['type'] == 'input_checkbox' AND $bugsys->input_clean("custom$field[fieldid]", TYPE_INT) != 0)
+ if ($field['type'] == 'input_checkbox' AND $input->inputClean("custom$field[fieldid]", TYPE_INT) != 0)
{
- $querybuild[] = "AND bug.custom$field[fieldid] = " . ($bugsys->in["custom$field[fieldid]"] > 0 ? 1 : 0);
+ $querybuild[] = "AND bug.custom$field[fieldid] = " . ($input->in["custom$field[fieldid]"] > 0 ? 1 : 0);
}
else if ($field['type'] == 'input_text')
{
- $querybuild[] = "AND bug.custom$field[fieldid] LIKE '%" . $bugsys->in["custom$field[fieldid]"] . "%'";
+ $querybuild[] = "AND bug.custom$field[fieldid] LIKE '%" . $input->in["custom$field[fieldid]"] . "%'";
}
- else if ($field['type'] == 'select_single' AND $bugsys->in["custom$field[fieldid]"] != -1)
+ else if ($field['type'] == 'select_single' AND $input->in["custom$field[fieldid]"] != -1)
{
$temp = unserialize($field['selects']);
- $querybuild[] = "AND bug.custom$field[fieldid] = '" . trim($temp[ intval($bugsys->in["custom$field[fieldid]"]) ]) . "'";
+ $querybuild[] = "AND bug.custom$field[fieldid] = '" . trim($temp[ intval($input->in["custom$field[fieldid]"]) ]) . "'";
}
}
}
OR
(bug.hidden AND bug.product IN (" . fetch_on_bits('canviewhidden') . "))" . (can_perform('canviewownhidden') ? "
OR
- (bug.hidden AND bug.userid = " . $bugsys->userinfo['userid'] . " AND bug.product IN (" . fetch_on_bits('canviewonhidden') . "))" : "") . "
+ (bug.hidden AND bug.userid = " . bugdar::$userinfo['userid'] . " AND bug.product IN (" . fetch_on_bits('canviewonhidden') . "))" : "") . "
)
" . implode("\n\t\t", $querybuild) . "
GROUP BY bug.bugid
$sortclause
");
- $numrows = $db->num_rows($search);
+ $numrows = $search->size();
if ($numrows < 1)
{
$message->error(T('No search results were returned that matched your criteria. Please <a href="search.php?new=1">try again</a> with different search requirements.'));
}
- while ($result = $db->fetch_array($search))
+ foreach ($search as $result)
{
$ids[] = $result['bugid'];
$results[] = $result;
}
- if ($bugsys->userinfo['userid'] AND !$cachedsearch AND !$bugsys->in['rerun'])
+ if (bugdar::$userinfo['userid'] AND !$cachedsearch AND !$input->in['rerun'])
{
- $db->query("DELETE FROM " . TABLE_PREFIX . "search WHERE userid = " . $bugsys->userinfo['userid'] . " AND name IS NULL");
+ $db->query("DELETE FROM " . TABLE_PREFIX . "search WHERE userid = " . bugdar::$userinfo['userid'] . " AND name IS NULL");
}
// store the search params
- $params = $bugsys->in;
+ $params = $input->in;
foreach ($_COOKIE AS $key => $value)
{
unset($params["$key"]);
INSERT INTO " . TABLE_PREFIX . "search
(userid, dateline, query, ids, orderby, hilight, resultcount)
VALUES
- (" . $bugsys->userinfo['userid'] . ",
- " . TIMENOW . ", '" . $bugsys->escape(serialize($params)) . "',
- '" . implode(',', $ids) . "', '" . $bugsys->escape($sortclause) . "',
- '" . $bugsys->escape($hilight) . "',
+ (" . bugdar::$userinfo['userid'] . ",
+ " . TIMENOW . ", '" . $input->escape(serialize($params)) . "',
+ '" . implode(',', $ids) . "', '" . $input->escape($sortclause) . "',
+ '" . $input->escape($hilight) . "',
" . sizeof($results) . "
)"
);
- $search = array('searchid' => $db->insert_id(), 'ids' => implode(',', $ids), 'orderby' => $sortclause, 'hilight' => $hilight, 'resultcount' => sizeof($results));
+ $search = array('searchid' => $db->insertId(), 'ids' => implode(',', $ids), 'orderby' => $sortclause, 'hilight' => $hilight, 'resultcount' => sizeof($results));
}
$_POST['do'] = 'results';
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']);
+ $search = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "search WHERE searchid = " . $input->inputClean('searchid', TYPE_UINT) . " AND userid = " . bugdar::$userinfo['userid']);
if (!$search OR !can_perform('caneditother'))
{
$message->errorPermission();
}
- $productSelect = ConstructProductSelect();
-
$show['update'] = true;
// -------------------------------------------------------------------
$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)
+ $tpl = new BSTemplate('selectoption');
+ $tpl->vars = array(
+ 'value' => 0,
+ 'label' => '',
+ 'selected' => true
+ );
+ $select['dev'] = $tpl->evaluate()->getTemplate();
+
+ foreach (bugdar::$datastore['assignto'] as $dev)
{
- $value = $dev['userid'];
- $label = construct_user_display($dev, false);
- eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
+ $tpl = new BSTemplate('selectoption');
+ $tpl->vars = array(
+ 'value' => $dev['userid'],
+ 'label' => construct_user_display($dev, false)
+ );
+ $select['dev'] .= $tpl->evaluate()->getTemplate();
}
-
- eval('$template->flush("' . $template->fetch('search_update') . '");');
+
+ $tpl = new BSTemplate('search_update');
+ $tpl->vars = array(
+ 'search' => $search,
+ 'select' => $select,
+ 'customfields' => $customfields,
+ 'productSelect' => construct_product_select()
+ );
+ $tpl->evaluate()->flush();
}
// ###################################################################
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']);
+ $search = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "search WHERE searchid = " . $input->inputClean('searchid', TYPE_UINT) . " AND userid = " . bugdar::$userinfo['userid']);
if (!$search OR !can_perform('caneditother'))
{
$message->errorPermission();
(
product IN (" . fetch_on_bits('caneditother') . ")
OR
- (userid = " . $bugsys->userinfo['userid'] . " AND product IN (" . fetch_on_bits('caneditown') . "))
+ (userid = " . bugdar::$userinfo['userid'] . " AND product IN (" . fetch_on_bits('caneditown') . "))
)
");
- while ($bug = $db->fetch_array($bugs))
+ foreach ($bugs as $bug)
{
- 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']))
+ if (!((can_perform('caneditown', $bug['product']) AND bugdar::$userinfo['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['product']) AND bugdar::$userinfo['userid'] != $bug['userid'])) AND !can_perform('canpostcomments', $bug['product']))
{
continue;
}
- $api = new BugApi($bugsys);
+ $api = new BugApi();
$api->set('bugid', $bug['bugid']);
- $api->set_condition();
$api->values = $bug;
$log = new Logging();
- $log->set_bugid($bug['bugid']);
- $log->add_data(true, $bug, $log->getCommonFields(), true);
+ $log->setBugId($bug['bugid']);
+ $log->addData(true, $bug, $log->getCommonFields(), true);
- if ($bugsys->in['status'] AND can_perform('canchangestatus', $bug['product']))
+ if ($input->in['status'] AND can_perform('canchangestatus', $bug['product']))
{
- $api->set('status', $bugsys->in['status']);
+ $api->set('status', $input->in['status']);
}
- if ($bugsys->in['priority'] AND can_perform('canchangestatus', $bug['product']))
+ if ($input->in['priority'] AND can_perform('canchangestatus', $bug['product']))
{
- $api->set('priority', $bugsys->in['priority']);
+ $api->set('priority', $input->in['priority']);
}
- if ($bugsys->in['severity'])
+ if ($input->in['severity'])
{
- $api->set('severity', $bugsys->in['severity']);
+ $api->set('severity', $input->in['severity']);
}
- if ($bugsys->in['resolution'] AND can_perform('canchangestatus', $bug['product']))
+ if ($input->in['resolution'] AND can_perform('canchangestatus', $bug['product']))
{
- $api->set('resolution', $bugsys->in['resolution']);
+ $api->set('resolution', $input->in['resolution']);
}
- if ($bugsys->in['assignedto'] AND can_perform('canassign', $bug['product']))
+ if ($input->in['assignedto'] AND can_perform('canassign', $bug['product']))
{
- $api->set('assignedto', $bugsys->in['assignedto']);
+ $api->set('assignedto', $input->in['assignedto']);
}
- if ($bugsys->in['product'])
+ if ($input->in['product'])
{
- $product = explode(',', $bugsys->in['product']);
+ $product = explode(',', $input->in['product']);
$api->set('product', $product[0]);
$api->set('component', $product[1]);
$api->set('version', $product[2]);
process_custom_fields($api, $message, false, true);
- $log->add_data(false, $api->values, $log->getCommonFields(), true);
+ $log->addData(false, $api->values, $log->getCommonFields(), true);
$api->update();
- $log->update_history();
+ $log->updateHistory();
}
- $message->redirect(T('The specified bugs have been updated and you will now return to your search results.'), 'search.php?searchid=' . $bugsys->in['searchid']);
+ $message->redirect(T('The specified bugs have been updated and you will now return to your search results.'), 'search.php?searchid=' . $input->in['searchid']);
}
// ###################################################################
if ($_REQUEST['do'] == 'export')
{
- if (!$bugsys->in['searchid'] AND $bugsys->userinfo['userid'])
+ if (!$input->in['searchid'] AND bugdar::$userinfo['userid'])
{
- $search = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "search WHERE name IS NULL AND userid = " . $bugsys->userinfo['userid']);
+ $search = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "search WHERE name IS NULL AND userid = " . bugdar::$userinfo['userid']);
}
- else if ($bugsys->in['searchid'])
+ else if ($input->in['searchid'])
{
- $search = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "search WHERE searchid = " . $bugsys->input_clean('searchid', TYPE_UINT) . " AND userid = " . $bugsys->userinfo['userid']);
+ $search = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "search WHERE searchid = " . $input->inputClean('searchid', TYPE_UINT) . " AND userid = " . bugdar::$userinfo['userid']);
}
else
{
$xml = '<?xml version="1.0" encoding="' . $language['charset'] . '"?>
-<bugdarExport user="' . $bugsys->unsanitize(construct_user_display($bugsys->userinfo, false)) . '" date="' . $datef->format('r', TIMENOW) . '" searchid="' . $search['searchid'] . '">';
+<bugdarExport user="' . $input->unsanitize(construct_user_display(bugdar::$userinfo, false)) . '" date="' . $datef->format('r', TIMENOW) . '" searchid="' . $search['searchid'] . '">';
- while ($bug = $db->fetch_array($bugs))
+ foreach ($bugs as $bug)
{
$xml .= "\n\t<bug>";
$xml .= "\n\t\t<dateReported>" . $datef->format('r', $bug['dateline']) . "</dateReported>";
if ($bug['userid'])
{
- $xml .= "\n\t\t<reporter>" . construct_user_display($db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE userid = $bug[userid]"), false) . "</reporter>";
+ $xml .= "\n\t\t<reporter>" . construct_user_display($db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "user WHERE userid = $bug[userid]"), false) . "</reporter>";
}
$xml .= "\n\t\t<summary>" . $bug['summary'] . "</summary>";
$xml .= "\n\t\t<product>" . $bug['product'] . "</product>";
$xml .= "\n\t\t<status>" . $bug['status'] . "</status>";
if ($bug['assignedto'])
{
- $xml .= "\n\t\t<assignedTo>" . construct_user_display($bugsys->datastore['assignto']["$bug[assignedto]"], false) . "</assignedTo>";
+ $xml .= "\n\t\t<assignedTo>" . construct_user_display(bugdar::$datastore['assignto']["$bug[assignedto]"], false) . "</assignedTo>";
}
$xml .= "\n\t\t<resolution>" . $bug['resolution'] . "</resolution>";
$xml .= "\n\t\t<severity>" . $bug['severity'] . "</severity>";
$xml .= "\n</bugdarExport>";
- $funct->download_file($xml, T('bugdar-search-' . $search['searchid'] . '.xml'), true);
+ BSFunctions::download_file($xml, T('bugdar-search-' . $search['searchid'] . '.xml'), true);
}
// ###################################################################
if ($_POST['do'] == 'dosave')
{
- $search = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "search WHERE searchid = " . $bugsys->input_clean('searchid', TYPE_UINT) . " AND userid = " . $bugsys->userinfo['userid']);
+ $search = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "search WHERE searchid = " . $input->inputClean('searchid', TYPE_UINT) . " AND userid = " . bugdar::$userinfo['userid']);
if (!$search)
{
$message->addError(T('The search does not exist.'));
{
$message->addError(sprintf(T('This search has already been named "%1$s".'), $search['name']));
}
- if (empty($bugsys->in['name']))
+ if (empty($input->in['name']))
{
$message->addError(T('The name cannot be empty.'));
}
if (!$message->hasErrors())
{
- $db->query("UPDATE " . TABLE_PREFIX . "search SET name = '" . $bugsys->input_escape('name') . "' WHERE searchid = " . $bugsys->in['searchid']);
+ $db->query("UPDATE " . TABLE_PREFIX . "search SET name = '" . $input->inputEscape('name') . "' WHERE searchid = " . $input->in['searchid']);
$message->redirect(T('Your search has been saved.'), 'search.php?searchid=' . $search['searchid']);
}
else
if ($_REQUEST['do'] == 'save')
{
- if (!$bugsys->userinfo['userid'])
+ if (!bugdar::$userinfo['userid'])
{
$message->errorPermission();
}
- eval('$template->flush("' . $template->fetch('search_save') . '");');
+ $tpl = new BSTemplate('search_save');
+ $tpl->vars = array(
+ 'message' => $message,
+ 'searchid' => $input->in['searchid'],
+ 'name' => $input->in['name']
+ );
+ $tpl->evaluate()->flush();
}
// ###################################################################
$searchid = $search['searchid'];
$hilight = $search['hilight'];
-
- LoadPaginationFramework();
+
+ require_once 'includes/pagination.php';
+ $pagination = new Pagination();
+ $pagination->processIncomingData();
$pagination->setTotal($search['resultcount']);
$pagination->splitPages();
$sort = new ListSorter('search');
- $show['save'] = ($bugsys->userinfo['userid'] AND !$search['name']);
+ $show['save'] = (bugdar::$userinfo['userid'] AND !$search['name']);
$show['update'] = can_perform('caneditother');
$bugs = '';
$search = $db->query("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid IN ($search[ids]) $search[orderby] LIMIT " . $pagination->fetchLimit($pagination->getPage() - 1) . ", " . $pagination->getPerPage());
- while ($bug = $db->fetch_array($search))
+ foreach ($search as $bug)
{
- $funct->exec_swap_bg('altcolor', '');
- $bug = ProcessBugDataForDisplay($bug, $funct->bgcolour);
+ BSFunctions::swap_css_classes('altcolor', '');
+ $bug = ProcessBugDataForDisplay($bug, BSFunctions::$cssClass);
$bugs .= $sort->constructRow($bug, "&hilight=$hilight");
}
$show['pagenav'] = ($pagination->getPageCount() > 1);
$pagenav = $pagination->constructPageNav('search.php?searchid=' . $searchid);
- eval('$template->flush("' . $template->fetch('search_results') . '");');
+ $tpl = new BSTemplate('search_results');
+ $tpl->vars = array(
+ 'columnHeads' => $columnHeads,
+ 'bugs' => $bugs,
+ 'searchid' => $searchid
+ );
+ $tpl->evaluate()->flush();
}
-/*=====================================================================*\
-|| ###################################################################
-|| # $HeadURL$
-|| # $Id$
-|| ###################################################################
-\*=====================================================================*/
?>
\ No newline at end of file