Skip to content

Commit

Permalink
fixed parameter handling. http://my.candycane.jp/issues/show/99
Browse files Browse the repository at this point in the history
  • Loading branch information
yandod committed May 11, 2011
1 parent c60a72d commit 02076e7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
19 changes: 18 additions & 1 deletion app/controllers/components/queries.php
Expand Up @@ -56,7 +56,24 @@ function retrieve_query($query_id = 0, $forse_set_filter = null)
}
}
} else {
if (isset($self->params['url']['set_filter'], $self->params['form']['fields']) || $forse_set_filter) {
if (isset($self->params['url']['set_filter']) || $forse_set_filter) {
if ( !is_array($self->params['form'])) {
$self->params['form'] = array(
'fields' => array(),
'operators' => array(),
'values' => array(),
);
}
if (isset($self->params['url']) && is_array($self->params['url']) ) {
foreach ($self->params['url'] as $criteria_name => $criteria_val) {
$self->params['form']['fields'][$criteria_name] = $criteria_name;
$self->params['form']['operators'][$criteria_name] = '=';
$self->params['form']['values'][$criteria_name] = array($criteria_val);
if ($criteria_name == 'status_id') {
$self->params['form']['operators'][$criteria_name] = $criteria_val;
}
}
}
foreach ($self->params['form']['fields'] as $field) {
$operator = $self->params['form']['operators'][$field];
$values = isset($self->params['form']['values'][$field]) ? $self->params['form']['values'][$field] : null;
Expand Down
6 changes: 0 additions & 6 deletions app/controllers/issues_controller.php
Expand Up @@ -94,12 +94,6 @@ function beforeRender()
#
function index()
{
//url param translation for bug #72
if (isset($this->params['url']['tracker_id'])) {
$this->params['form']['fields']['tracker_id'] = 'tracker_id';
$this->params['form']['operators']['tracker_id'] = '=';
$this->params['form']['values']['tracker_id'] = array($this->params['url']['tracker_id']);
}
if (!isset($this->params['url']['query_id'])) $this->params['url']['query_id'] = 0;
$this->Queries->retrieve_query($this->params['url']['query_id']);
$limit = $this->_per_page_option();
Expand Down
19 changes: 19 additions & 0 deletions app/models/query.php
Expand Up @@ -134,6 +134,7 @@ function available_filters($project = array(), $currentuser = array())
$Enumeration = & ClassRegistry::init('Enumeration');
$user_values = a();
$tracker_values = a();
$version_values = array();
if ($currentuser) $user_values['me'] = __('me', true);
if (isset($project['User'])) {
foreach ($project['User'] as $user) {
Expand All @@ -144,6 +145,19 @@ function available_filters($project = array(), $currentuser = array())
if (isset($project['Tracker'])) {
foreach ($project['Tracker'] as $tracker) $tracker_values[$tracker['id']] = $tracker['name'];
}
if (isset($project['Project']['id'])) {
$Version = & ClassRegistry::init('Version');
$version_values = $Version->find('list', array(
'fields' => array(
'Version.id',
'Version.name',
),
'conditions' => array(
'Version.project_id' => $project['Project']['id']
)
));
}

$available_filters = array(
'status_id' => array(
'type' => 'list_status',
Expand All @@ -155,6 +169,11 @@ function available_filters($project = array(), $currentuser = array())
)),
'order' => 1,
),
'fixed_version_id' => array(
'type' => 'list',
'values' => $version_values,
'order' => 10
),
'start_date' => array(
'type' => 'date',
'order' => 11,
Expand Down

0 comments on commit 02076e7

Please sign in to comment.