Skip to content

Commit

Permalink
Allow plugin columns to pre-validate user input
Browse files Browse the repository at this point in the history
  • Loading branch information
amyreese committed Oct 30, 2009
1 parent 1d01388 commit 571ce38
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core/classes/MantisFilter.class.php
Expand Up @@ -49,6 +49,17 @@ abstract class MantisFilter {
*/
public $size = null;

/**
* Validate the filter input, returning true if input is
* valid, or returning false if invalid. Invalid inputs will
* be replaced with the filter's default value.
* @param multi Filter field input
* @return boolean Input valid (true) or invalid (false)
*/
public function validate( $p_filter_input ) {
return true;
}

/**
* Build the SQL query elements 'join', 'where', and 'params'
* as used by core/filter_api.php to create the primary filter
Expand Down
4 changes: 4 additions & 0 deletions core/filter_api.php
Expand Up @@ -570,6 +570,10 @@ function filter_ensure_valid_filter( $p_filter_arr ) {
$p_filter_arr[ $t_field_name ] = META_FILTER_ANY;
}
}

if ( ! $t_filter_object->validate( $p_filter_arr[ $t_field_name ] ) ) {
$p_filter_arr[ $t_field_name ] = $t_filter_object->default;
}
}

$t_custom_fields = custom_field_get_ids();
Expand Down

0 comments on commit 571ce38

Please sign in to comment.