From 10025b35df5ebfe1901de5b27a44becaa81b63ec Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Thu, 16 Mar 2017 17:31:59 +0100 Subject: [PATCH 1/3] Add 'type' param to Source_FilterOption_Permalink() This allows parameters' initalization in Source_Generate_Filter() to specifically handle integers (before this, all parameters were treated as strings, with special handling for the 2 date fields). Fixes #207 --- Source/Source.FilterAPI.php | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/Source/Source.FilterAPI.php b/Source/Source.FilterAPI.php index 4ea4893ca..09ef71945 100644 --- a/Source/Source.FilterAPI.php +++ b/Source/Source.FilterAPI.php @@ -282,21 +282,22 @@ function Source_Process_FilterOption( $key, $option ) { function Source_Generate_Filter() { # Get form inputs $f_repo_type = Source_FilterOption_Permalink( 'repo_type', true ); - $f_repo_id = Source_FilterOption_Permalink( 'repo_id', true ); + $f_repo_id = Source_FilterOption_Permalink( 'repo_id', true, 'int' ); $f_branch = Source_FilterOption_Permalink( 'branch', true ); $f_file_action = Source_FilterOption_Permalink( 'file_action', true ); $f_ported = Source_FilterOption_Permalink( 'ported', true ); $f_revision = Source_FilterOption_Permalink( 'revision' ); $f_author = Source_FilterOption_Permalink( 'author' ); - $f_user_id = Source_FilterOption_Permalink( 'user_id' ); - $f_bug_id = Source_FilterOption_Permalink( 'bug_id' ); + $f_user_id = Source_FilterOption_Permalink( 'user_id', false, 'int' ); + $f_bug_id = Source_FilterOption_Permalink( 'bug_id', false, 'int' ); + $f_filename = Source_FilterOption_Permalink( 'filename' ); $f_message = Source_FilterOption_Permalink( 'message' ); - $f_date_start = Source_FilterOption_Permalink( 'date_start' ); - $f_date_end = Source_FilterOption_Permalink( 'date_end' ); + $f_date_start = Source_FilterOption_Permalink( 'date_start', false, 'date' ); + $f_date_end = Source_FilterOption_Permalink( 'date_end', false, 'date' ); # Get permalink $t_permalink = Source_FilterOption_Permalink(); @@ -361,7 +362,7 @@ function Source_Date_Validate( $p_string, $p_end_of_day=false ) { } } -function Source_FilterOption_Permalink( $p_string=null, $p_array=false ) { +function Source_FilterOption_Permalink( $p_string=null, $p_array=false, $p_type='string' ) { static $s_permalink = ''; if ( is_null( $p_string ) ) { @@ -371,7 +372,11 @@ function Source_FilterOption_Permalink( $p_string=null, $p_array=false ) { } if ( $p_array ) { - $t_input = gpc_get_string_array( $p_string, array() ); + if( $p_type == 'int') { + $t_input = gpc_get_int_array( $p_string, array() ); + } else { + $t_input = gpc_get_string_array( $p_string, array() ); + } $t_input_clean = array(); if ( is_array( $t_input ) && count( $t_input ) > 0 ) { @@ -384,10 +389,18 @@ function Source_FilterOption_Permalink( $p_string=null, $p_array=false ) { } } else { - $t_input_clean = gpc_get_string( $p_string, null ); - - if ( $p_string == 'date_start' || $p_string == 'date_end' ) { - $t_input_clean = Source_Date_Validate( $p_string, $p_string == 'date_end' ); + switch( $p_type ) { + case 'int': + $t_input_clean = gpc_get_int( $p_string, 0 ); + if( $t_input_clean == 0) { + $t_input_clean = null; + } + break; + case 'date': + $t_input_clean = Source_Date_Validate( $p_string, $p_string == 'date_end' ); + break; + default: + $t_input_clean = gpc_get_string( $p_string, null ); } if ( !is_blank( $t_input_clean ) ) { From 3c9bc3e93237edc5459fd47a05e8dbeb5659479b Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Thu, 16 Mar 2017 18:33:15 +0100 Subject: [PATCH 2/3] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5ea22a857..9072cadd4 100644 --- a/README.md +++ b/README.md @@ -60,15 +60,15 @@ The Source Integration framework's version numbering follows change in the minimum required MantisBT version. Depending on which version of MantisBT you are using, please make sure to -get the appropriate version of the source code. -Use [release tags](https://github.com/mantisbt-plugins/source-integration/releases), +get the appropriate version of the source code. +Use [release tags](https://github.com/mantisbt-plugins/source-integration/releases), or the relevant branch in the Plugin's GitHub repository, as per the table below: MantisBT version | Tags | Branch | Notes :---:|---|---|--- -2.0.x | v2.* | [modern-ui](https://github.com/mantisbt-plugins/source-integration/archive/modern-ui.zip) | Beta -1.3.x | v1.* | [master](https://github.com/mantisbt-plugins/source-integration/archive/master.zip) | **Current release** -1.2.x | v0.* | [master-1.2.x](https://github.com/mantisbt-plugins/source-integration/archive/master-1.2.x.zip) | Legacy +2.0.x | v2.* | [master](https://github.com/mantisbt-plugins/source-integration/archive/master.zip) | **Current release** +1.3.x | v1.* | [master-1.3.x](https://github.com/mantisbt-plugins/source-integration/archive/master-1.3.x.zip) | Old stable (bug fixes only) +1.2.x | v0.* | [master-1.2.x](https://github.com/mantisbt-plugins/source-integration/archive/master-1.2.x.zip) | Legacy (no longer supported) ### Setup instructions From cb804f230ee241afec33e220bfbdd77c672f9101 Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Thu, 16 Mar 2017 18:33:43 +0100 Subject: [PATCH 3/3] Bump version to 1.5.2 --- Source/MantisSourceBase.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/MantisSourceBase.class.php b/Source/MantisSourceBase.class.php index c5af116b5..b3f7ecf7f 100644 --- a/Source/MantisSourceBase.class.php +++ b/Source/MantisSourceBase.class.php @@ -19,7 +19,7 @@ abstract class MantisSourceBase extends MantisPlugin * a change in the minimum required MantisBT version: 0=1.2; 1=1.3, 2=2.x. * The framework version is incremented when the plugin's core files change. */ - const FRAMEWORK_VERSION = '1.5.1'; + const FRAMEWORK_VERSION = '1.5.2'; /** * Minimum required MantisBT version.