Skip to content

Commit

Permalink
Fix not all issues returned via REST API
Browse files Browse the repository at this point in the history
- Add FILTER_STANDARD_ANY
- Add filter_create_any() to filter_api
- Handle FILTER_STANDARD_ANY in filter_standard_get
- Use in issues_rest, if the request doesn't contain a filter_id

Fixes #25102
  • Loading branch information
obmsch authored and vboctor committed Feb 24, 2019
1 parent 8ff8d8d commit 4cc687a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
4 changes: 2 additions & 2 deletions api/rest/restcore/issues_rest.php
Expand Up @@ -107,8 +107,8 @@ function rest_issue_get( \Slim\Http\Request $p_request, \Slim\Http\Response $p_r
$t_issues = mc_filter_get_issues(
'', '', $t_project_id, $t_filter_id, $t_page_number, $t_page_size );
} else {
$t_issues = mc_project_get_issues(
'', '', $t_project_id, $t_page_number, $t_page_size );
$t_issues = mc_filter_get_issues(
'', '', $t_project_id, FILTER_STANDARD_ANY, $t_page_number, $t_page_size );
}

$t_result = array( 'issues' => $t_issues );
Expand Down
2 changes: 1 addition & 1 deletion api/soap/mc_filter_api.php
Expand Up @@ -181,7 +181,7 @@ function mc_filter_get_issues( $p_username, $p_password, $p_project_id, $p_filte
if( is_numeric( $p_filter_id ) ) {
$t_filter = filter_get( $p_filter_id );
} else {
$t_filter = filter_standard_get( $p_filter_id, $t_user_id );
$t_filter = filter_standard_get( $p_filter_id, $t_user_id, $p_project_id );
}

if( $t_filter === null ) {
Expand Down
1 change: 1 addition & 0 deletions core/constant_inc.php
Expand Up @@ -484,6 +484,7 @@
define( 'FILTER_MATCH_ANY', 1 );

# Standard Filters
define( 'FILTER_STANDARD_ANY', 'any' );
define( 'FILTER_STANDARD_ASSIGNED', 'assigned' );
define( 'FILTER_STANDARD_UNASSIGNED', 'unassigned' );
define( 'FILTER_STANDARD_REPORTED', 'reported' );
Expand Down
31 changes: 29 additions & 2 deletions core/filter_api.php
Expand Up @@ -3170,6 +3170,23 @@ function filter_create_recently_modified( $p_days, $p_filter = null ) {
return filter_ensure_valid_filter( $p_filter );
}

/**
* Create a filter for getting issues assigned to the specified project.
* @param integer $p_project_id The project id or ALL_PROJECTS.
* @return mixed A valid filter.
*/
function filter_create_any( $p_project_id ) {
$t_filter = filter_get_default();

$t_filter[FILTER_PROPERTY_HIDE_STATUS] = META_FILTER_NONE;

if( $p_project_id != ALL_PROJECTS ) {
$t_filter[FILTER_PROPERTY_PROJECT_ID] = array( '0' => $p_project_id );
}

return filter_ensure_valid_filter( $t_filter );
}

/**
* Create a filter for getting issues assigned to the specified project and user that
* are not yet resolved.
Expand Down Expand Up @@ -3813,18 +3830,28 @@ function filter_get( $p_filter_id, array $p_default = null ) {
* Return a standard filter
* @param string $p_filter_name The name of the filter
* @param integer|null $p_user_id A user id to build this filter. Null for current user
* @param integer|null $p_project_id A project id to build this filter. Null for current project
* @return null|boolean|array null filter not found, false invalid filter, otherwise the filter.
*/
function filter_standard_get( $p_filter_name, $p_user_id = null ) {
function filter_standard_get( $p_filter_name, $p_user_id = null, $p_project_id = null ) {
$p_filter_name = strtolower( $p_filter_name );
$t_project_id = helper_get_current_project();

if( null === $p_project_id ) {
$t_project_id = helper_get_current_project();
} else {
$t_project_id = $p_project_id;
}

if( null === $p_user_id ) {
$t_user_id = auth_get_current_user_id();
} else {
$t_user_id = $p_user_id;
}

switch( $p_filter_name ) {
case FILTER_STANDARD_ANY:
$t_filter = filter_create_any( $t_project_id );
break;
case FILTER_STANDARD_ASSIGNED:
$t_filter = filter_create_assigned_to_unresolved( $t_project_id, $t_user_id );
break;
Expand Down

0 comments on commit 4cc687a

Please sign in to comment.