[ Index ]

PHP Cross Reference of MantisBT

title

Body

[close]

/ -> view_all_set.php (source)

   1  <?php
   2  # MantisBT - A PHP based bugtracking system
   3  
   4  # MantisBT is free software: you can redistribute it and/or modify
   5  # it under the terms of the GNU General Public License as published by
   6  # the Free Software Foundation, either version 2 of the License, or
   7  # (at your option) any later version.
   8  #
   9  # MantisBT is distributed in the hope that it will be useful,
  10  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  # GNU General Public License for more details.
  13  #
  14  # You should have received a copy of the GNU General Public License
  15  # along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * @package MantisBT
  19   * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
  20   * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
  21   * @link http://www.mantisbt.org
  22   *
  23   * @uses core.php
  24   * @uses authentication_api.php
  25   * @uses config_api.php
  26   * @uses constant_inc.php
  27   * @uses custom_field_api.php
  28   * @uses error_api.php
  29   * @uses filter_api.php
  30   * @uses filter_constants_inc.php
  31   * @uses gpc_api.php
  32   * @uses helper_api.php
  33   * @uses html_api.php
  34   * @uses logging_api.php
  35   * @uses print_api.php
  36   * @uses tokens_api.php
  37   * @uses utility_api.php
  38   */
  39  
  40  /**
  41   * MantisBT Core API's
  42   */
  43  require_once ( 'core.php' );
  44  require_api( 'authentication_api.php' );
  45  require_api( 'config_api.php' );
  46  require_api( 'constant_inc.php' );
  47  require_api( 'custom_field_api.php' );
  48  require_api( 'error_api.php' );
  49  require_api( 'filter_api.php' );
  50  require_api( 'filter_constants_inc.php' );
  51  require_api( 'gpc_api.php' );
  52  require_api( 'helper_api.php' );
  53  require_api( 'html_api.php' );
  54  require_api( 'logging_api.php' );
  55  require_api( 'print_api.php' );
  56  require_api( 'tokens_api.php' );
  57  require_api( 'utility_api.php' );
  58  
  59  auth_ensure_user_authenticated();
  60  
  61  $f_type                    = gpc_get_int( 'type', -1 );
  62  $f_source_query_id        = gpc_get_int( 'source_query_id', -1 );
  63  $f_print                = gpc_get_bool( 'print' );
  64  $f_temp_filter            = gpc_get_bool( 'temporary' );
  65  
  66  # validate filter type
  67  $f_default_view_type = 'simple';
  68  if ( ADVANCED_DEFAULT == config_get( 'view_filters' ) ) {
  69      $f_default_view_type = 'advanced';
  70  }
  71  
  72  $f_view_type = gpc_get_string( 'view_type', $f_default_view_type );
  73  if ( ADVANCED_ONLY == config_get( 'view_filters' ) ) {
  74      $f_view_type = 'advanced';
  75  }
  76  if ( SIMPLE_ONLY == config_get( 'view_filters' ) ) {
  77      $f_view_type = 'simple';
  78  }
  79  if ( !in_array( $f_view_type, array( 'simple', 'advanced' ) ) ) {
  80      $f_view_type = $f_default_view_type;
  81  }
  82  
  83  # these are all possibly multiple selections for advanced filtering
  84  $f_show_category = array();
  85  if ( is_array( gpc_get( FILTER_PROPERTY_CATEGORY_ID, null ) ) ) {
  86      $f_show_category = gpc_get_string_array( FILTER_PROPERTY_CATEGORY_ID, META_FILTER_ANY );
  87  } else {
  88      $f_show_category = gpc_get_string( FILTER_PROPERTY_CATEGORY_ID, META_FILTER_ANY );
  89      $f_show_category = array( $f_show_category );
  90  }
  91  
  92  $f_platform = array();
  93  if ( is_array( gpc_get( FILTER_PROPERTY_PLATFORM, null ) ) ) {
  94      $f_platform = gpc_get_string_array( FILTER_PROPERTY_PLATFORM, META_FILTER_ANY );
  95  } else {
  96      $f_platform = gpc_get_string( FILTER_PROPERTY_PLATFORM, META_FILTER_ANY );
  97      $f_platform = array( $f_platform );
  98  }
  99  
 100  $f_os = array();
 101  if ( is_array( gpc_get( FILTER_PROPERTY_OS, null ) ) ) {
 102      $f_os = gpc_get_string_array( FILTER_PROPERTY_OS, META_FILTER_ANY );
 103  } else {
 104      $f_os = gpc_get_string( FILTER_PROPERTY_OS, META_FILTER_ANY );
 105      $f_os = array( $f_os );
 106  }
 107  
 108  $f_os_build = array();
 109  if ( is_array( gpc_get( FILTER_PROPERTY_OS_BUILD, null ) ) ) {
 110      $f_os_build = gpc_get_string_array( FILTER_PROPERTY_OS_BUILD, META_FILTER_ANY );
 111  } else {
 112      $f_os_build = gpc_get_string( FILTER_PROPERTY_OS_BUILD, META_FILTER_ANY );
 113      $f_os_build = array( $f_os_build );
 114  }
 115  
 116  $f_show_severity = array();
 117  if ( is_array( gpc_get( FILTER_PROPERTY_SEVERITY, null ) ) ) {
 118      $f_show_severity = gpc_get_string_array( FILTER_PROPERTY_SEVERITY, META_FILTER_ANY );
 119  } else {
 120      $f_show_severity = gpc_get_string( FILTER_PROPERTY_SEVERITY, META_FILTER_ANY );
 121      $f_show_severity = array( $f_show_severity );
 122  }
 123  
 124  $f_show_status = array();
 125  if ( is_array( gpc_get( FILTER_PROPERTY_STATUS, null ) ) ) {
 126      $f_show_status = gpc_get_string_array( FILTER_PROPERTY_STATUS, META_FILTER_ANY );
 127  } else {
 128      $f_show_status = gpc_get_string( FILTER_PROPERTY_STATUS, META_FILTER_ANY );
 129      $f_show_status = array( $f_show_status );
 130  }
 131  
 132  $f_hide_status = array();
 133  if ( is_array( gpc_get( FILTER_PROPERTY_HIDE_STATUS, null ) ) ) {
 134      $f_hide_status = gpc_get_string_array( FILTER_PROPERTY_HIDE_STATUS, META_FILTER_NONE );
 135  } else {
 136      $f_hide_status = gpc_get_string( FILTER_PROPERTY_HIDE_STATUS, META_FILTER_NONE );
 137      $f_hide_status = array( $f_hide_status );
 138  }
 139  
 140  $f_reporter_id = array();
 141  if ( is_array( gpc_get( FILTER_PROPERTY_REPORTER_ID, null ) ) ) {
 142      $f_reporter_id = gpc_get_string_array( FILTER_PROPERTY_REPORTER_ID, META_FILTER_ANY );
 143  } else {
 144      $f_reporter_id = gpc_get_string( FILTER_PROPERTY_REPORTER_ID, META_FILTER_ANY );
 145      $f_reporter_id = array( $f_reporter_id );
 146  }
 147  
 148  $f_handler_id = array();
 149  if ( is_array( gpc_get( FILTER_PROPERTY_HANDLER_ID, null ) ) ) {
 150      $f_handler_id = gpc_get_string_array( FILTER_PROPERTY_HANDLER_ID, META_FILTER_ANY );
 151  } else {
 152      $f_handler_id = gpc_get_string( FILTER_PROPERTY_HANDLER_ID, META_FILTER_ANY );
 153      $f_handler_id = array( $f_handler_id );
 154  }
 155  
 156  $f_project_id = array();
 157  if ( is_array( gpc_get( FILTER_PROPERTY_PROJECT_ID, null ) ) ) {
 158      $f_project_id = gpc_get_int_array( FILTER_PROPERTY_PROJECT_ID, META_FILTER_CURRENT );
 159  } else {
 160      $f_project_id = gpc_get_int( FILTER_PROPERTY_PROJECT_ID, META_FILTER_CURRENT );
 161      $f_project_id = array( $f_project_id );
 162  }
 163  
 164  $f_show_resolution = array();
 165  if ( is_array( gpc_get( FILTER_PROPERTY_RESOLUTION, null ) ) ) {
 166      $f_show_resolution = gpc_get_string_array( FILTER_PROPERTY_RESOLUTION, META_FILTER_ANY );
 167  } else {
 168      $f_show_resolution = gpc_get_string( FILTER_PROPERTY_RESOLUTION, META_FILTER_ANY );
 169      $f_show_resolution = array( $f_show_resolution );
 170  }
 171  
 172  $f_show_build = array();
 173  if ( is_array( gpc_get( FILTER_PROPERTY_BUILD, null ) ) ) {
 174      $f_show_build = gpc_get_string_array( FILTER_PROPERTY_BUILD, META_FILTER_ANY );
 175  } else {
 176      $f_show_build = gpc_get_string( FILTER_PROPERTY_BUILD, META_FILTER_ANY );
 177      $f_show_build = array( $f_show_build );
 178  }
 179  
 180  $f_show_version = array();
 181  if ( is_array( gpc_get( FILTER_PROPERTY_VERSION, null ) ) ) {
 182      $f_show_version = gpc_get_string_array( FILTER_PROPERTY_VERSION, META_FILTER_ANY );
 183  } else {
 184      $f_show_version = gpc_get_string( FILTER_PROPERTY_VERSION, META_FILTER_ANY );
 185      $f_show_version = array( $f_show_version );
 186  }
 187  
 188  $f_fixed_in_version = array();
 189  if ( is_array( gpc_get( FILTER_PROPERTY_FIXED_IN_VERSION, null ) ) ) {
 190      $f_fixed_in_version = gpc_get_string_array( FILTER_PROPERTY_FIXED_IN_VERSION, META_FILTER_ANY );
 191  } else {
 192      $f_fixed_in_version = gpc_get_string( FILTER_PROPERTY_FIXED_IN_VERSION, META_FILTER_ANY );
 193      $f_fixed_in_version = array( $f_fixed_in_version );
 194  }
 195  
 196  $f_target_version = array();
 197  if ( is_array( gpc_get( FILTER_PROPERTY_TARGET_VERSION, null ) ) ) {
 198      $f_target_version = gpc_get_string_array( FILTER_PROPERTY_TARGET_VERSION, META_FILTER_ANY );
 199  } else {
 200      $f_target_version = gpc_get_string( FILTER_PROPERTY_TARGET_VERSION, META_FILTER_ANY );
 201      $f_target_version = array( $f_target_version );
 202  }
 203  
 204  $f_show_profile = array();
 205  if ( is_array( gpc_get( FILTER_PROPERTY_PROFILE_ID, null ) ) ) {
 206      $f_show_profile = gpc_get_string_array( FILTER_PROPERTY_PROFILE_ID, META_FILTER_ANY );
 207  } else {
 208      $f_show_profile = gpc_get_string( FILTER_PROPERTY_PROFILE_ID, META_FILTER_ANY );
 209      $f_show_profile = array( $f_show_profile );
 210  }
 211  
 212  $f_show_priority = array();
 213  if ( is_array( gpc_get( FILTER_PROPERTY_PRIORITY, null ) ) ) {
 214      $f_show_priority = gpc_get_string_array( FILTER_PROPERTY_PRIORITY, META_FILTER_ANY );
 215  } else {
 216      $f_show_priority = gpc_get_string( FILTER_PROPERTY_PRIORITY, META_FILTER_ANY );
 217      $f_show_priority = array( $f_show_priority );
 218  }
 219  
 220  $f_user_monitor = array();
 221  if ( is_array( gpc_get( FILTER_PROPERTY_MONITOR_USER_ID, null ) ) ) {
 222      $f_user_monitor = gpc_get_string_array( FILTER_PROPERTY_MONITOR_USER_ID, META_FILTER_ANY );
 223  } else {
 224      $f_user_monitor = gpc_get_string( FILTER_PROPERTY_MONITOR_USER_ID, META_FILTER_ANY );
 225      $f_user_monitor = array( $f_user_monitor );
 226  }
 227  
 228  $f_note_user_id = array();
 229  if ( is_array( gpc_get( FILTER_PROPERTY_NOTE_USER_ID, null ) ) ) {
 230      $f_note_user_id = gpc_get_string_array( FILTER_PROPERTY_NOTE_USER_ID, META_FILTER_ANY );
 231  } else {
 232      $f_note_user_id = gpc_get_string( FILTER_PROPERTY_NOTE_USER_ID, META_FILTER_ANY );
 233      $f_note_user_id = array( $f_note_user_id );
 234  }
 235  
 236  # these are only single values, even when doing advanced filtering
 237  $f_per_page                = gpc_get_int( FILTER_PROPERTY_ISSUES_PER_PAGE, -1 );
 238  $f_highlight_changed    = gpc_get_int( FILTER_PROPERTY_HIGHLIGHT_CHANGED, config_get( 'default_show_changed' ) );
 239  $f_sticky_issues        = gpc_get_bool( FILTER_PROPERTY_STICKY );
 240  # sort direction
 241  $f_sort_d                = gpc_get_string( FILTER_PROPERTY_SORT_FIELD_NAME, '' );
 242  $f_dir_d                = gpc_get_string( FILTER_PROPERTY_SORT_DIRECTION, '' );
 243  $f_sort_0                = gpc_get_string( FILTER_PROPERTY_SORT_FIELD_NAME . '_0', 'last_updated' );
 244  $f_dir_0                = gpc_get_string( FILTER_PROPERTY_SORT_DIRECTION . '_0', 'DESC' );
 245  $f_sort_1                = gpc_get_string( FILTER_PROPERTY_SORT_FIELD_NAME . '_1', '' );
 246  $f_dir_1                = gpc_get_string( FILTER_PROPERTY_SORT_DIRECTION . '_1', '' );
 247  
 248  # date values
 249  $f_start_month            = gpc_get_int( FILTER_PROPERTY_START_MONTH, date( 'm' ) );
 250  $f_end_month            = gpc_get_int( FILTER_PROPERTY_END_MONTH, date( 'm' ) );
 251  $f_start_day            = gpc_get_int( FILTER_PROPERTY_START_DAY, 1 );
 252  $f_end_day                = gpc_get_int( FILTER_PROPERTY_END_DAY, date( 'd' ) );
 253  $f_start_year            = gpc_get_int( FILTER_PROPERTY_START_YEAR, date( 'Y' ) );
 254  $f_end_year                = gpc_get_int( FILTER_PROPERTY_END_YEAR, date( 'Y' ) );
 255  $f_search                = gpc_get_string( FILTER_PROPERTY_SEARCH, '' );
 256  $f_do_filter_by_date    = gpc_get_bool( FILTER_PROPERTY_FILTER_BY_DATE );
 257  $f_view_state            = gpc_get_int( FILTER_PROPERTY_VIEW_STATE, META_FILTER_ANY );
 258  
 259  $f_tag_string            = gpc_get_string( FILTER_PROPERTY_TAG_STRING, '' );
 260  $f_tag_select            = gpc_get_int( FILTER_PROPERTY_TAG_SELECT, '0' );
 261  
 262  # plugin filter updates
 263  $t_plugin_filters = filter_get_plugin_filters();
 264  $f_filter_input = array();
 265  
 266  foreach( $t_plugin_filters as $t_field_name => $t_filter_object ) {
 267      switch( $t_filter_object->type ) {
 268          case FILTER_TYPE_STRING:
 269              $f_filter_input[ $t_field_name ] = gpc_get_string( $t_field_name, $t_filter_object->default );
 270              break;
 271  
 272          case FILTER_TYPE_INT:
 273              $f_filter_input[ $t_field_name ] = gpc_get_int( $t_field_name, $t_filter_object->default );
 274              break;
 275  
 276          case FILTER_TYPE_BOOLEAN:
 277              $f_filter_input[ $t_field_name ] = gpc_get_bool( $t_field_name, OFF );
 278              break;
 279  
 280          case FILTER_TYPE_MULTI_STRING:
 281              $f_filter_input[ $t_field_name ] = gpc_get_string_array( $t_field_name, $t_filter_object->default );
 282              break;
 283  
 284          case FILTER_TYPE_MULTI_INT:
 285              $f_filter_input[ $t_field_name ] = gpc_get_int_array( $t_field_name, $t_filter_object->default );
 286              break;
 287      }
 288  }
 289  
 290  # custom field updates
 291  $t_custom_fields         = custom_field_get_ids(); /** @todo (thraxisp) This should really be the linked ids, but we don't know the project */
 292  $f_custom_fields_data     = array();
 293  if ( is_array( $t_custom_fields ) && ( count( $t_custom_fields ) > 0 ) ) {
 294      foreach( $t_custom_fields as $t_cfid ) {
 295          if (custom_field_type( $t_cfid ) == CUSTOM_FIELD_TYPE_DATE) {
 296              $t_control = gpc_get_string( 'custom_field_' . $t_cfid . '_control', null);
 297  
 298              $t_year = gpc_get_int( 'custom_field_' . $t_cfid . '_start_year', null);
 299              $t_month = gpc_get_int( 'custom_field_' . $t_cfid . '_start_month', null);
 300              $t_day = gpc_get_int( 'custom_field_' . $t_cfid . '_start_day', null);
 301              $t_start_date = mktime(0, 0, 0, $t_month, $t_day, $t_year);
 302  
 303              $t_year = gpc_get_int( 'custom_field_' . $t_cfid . '_end_year', null);
 304              $t_month = gpc_get_int( 'custom_field_' . $t_cfid . '_end_month', null);
 305              $t_day = gpc_get_int( 'custom_field_' . $t_cfid . '_end_day', null);
 306              $t_end_date = mktime(0, 0, 0, $t_month, $t_day, $t_year);
 307  
 308              $f_custom_fields_data[$t_cfid] = array();
 309              $f_custom_fields_data[$t_cfid][0] = $t_control;
 310              $t_start = 1;
 311              $t_end = 1;
 312              $t_one_day = 86399;
 313  
 314              switch ($t_control)
 315              {
 316              case CUSTOM_FIELD_DATE_ANY:
 317              case CUSTOM_FIELD_DATE_NONE:
 318                  break ;
 319              case CUSTOM_FIELD_DATE_BETWEEN:
 320                  $t_start = $t_start_date;
 321                  $t_end = $t_end_date + $t_one_day - 1;
 322                  break ;
 323              case CUSTOM_FIELD_DATE_ONORBEFORE:
 324                  $t_end = $t_start_date + $t_one_day - 1;
 325                  break;
 326              case CUSTOM_FIELD_DATE_BEFORE:
 327                  $t_end = $t_start_date;
 328                  break ;
 329              case CUSTOM_FIELD_DATE_ON:
 330                  $t_start = $t_start_date;
 331                  $t_end = $t_start_date + $t_one_day - 1;
 332                  break;
 333              case CUSTOM_FIELD_DATE_AFTER:
 334                  $t_start = $t_start_date + $t_one_day - 1;
 335                  $t_end = 2147483647; // Some time in 2038, max value of a signed int.
 336                  break;
 337              case CUSTOM_FIELD_DATE_ONORAFTER:
 338                  $t_start = $t_start_date;
 339                  $t_end = 2147483647; // Some time in 2038, max value of a signed int.
 340                  break;
 341              }
 342              $f_custom_fields_data[$t_cfid][1] = $t_start;
 343              $f_custom_fields_data[$t_cfid][2] = $t_end;
 344          } else {
 345              if ( is_array( gpc_get( 'custom_field_' . $t_cfid, null ) ) ) {
 346                  $f_custom_fields_data[$t_cfid] = gpc_get_string_array( 'custom_field_' . $t_cfid, META_FILTER_ANY );
 347              } else {
 348                  $f_custom_fields_data[$t_cfid] = gpc_get_string( 'custom_field_' . $t_cfid, META_FILTER_ANY );
 349                  $f_custom_fields_data[$t_cfid] = array( $f_custom_fields_data[$t_cfid] );
 350              }
 351          }
 352      }
 353  }
 354  
 355  $f_relationship_type = gpc_get_int( FILTER_PROPERTY_RELATIONSHIP_TYPE, -1 );
 356  $f_relationship_bug = gpc_get_int( FILTER_PROPERTY_RELATIONSHIP_BUG, 0 );
 357  
 358  if ( $f_temp_filter ) {
 359      $f_type = 1;
 360  }
 361  
 362  if ( $f_do_filter_by_date ) {
 363      $f_do_filter_by_date = 'on';
 364  }
 365  
 366  if ( $f_sticky_issues ) {
 367      $f_sticky_issues = 'on';
 368  } else {
 369      $f_sticky_issues = 'off';
 370  }
 371  
 372  if ( $f_type < 0 ) {
 373      print_header_redirect( 'view_all_bug_page.php' );
 374  }
 375  
 376  $t_hide_status_default = config_get( 'hide_status_default' );
 377  
 378  # show bugs per page
 379  if ( $f_per_page < 0 ) {
 380      $f_per_page = config_get( 'default_limit_view' );
 381  }
 382  
 383  # combine sort settings
 384  #  (f_sort overrides f_sort_1 if set to keep old sorting code working in view_all_bug_inc)
 385  $f_sort = ( ( $f_sort_d != "" ) ? $f_sort_d : $f_sort_0 ) . ( ( $f_sort_1 != "" ) ? "," . $f_sort_1 : "" );
 386  $f_dir = ( ( $f_dir_d != "" ) ? $f_dir_d : $f_dir_0 ) . ( ( $f_dir_1 != "" ) ? "," . $f_dir_1 : "" );
 387  
 388  # -1 is a special case stored query: it means we want to reset our filter
 389  if ( ( $f_type == 3 ) && ( $f_source_query_id == -1 ) ) {
 390      $f_type = 0;
 391  }
 392  
 393  /*   array contents
 394       --------------
 395       0: version
 396       1: $f_show_category
 397       2: $f_show_severity
 398       3: $f_show_status
 399       4: $f_per_page
 400       5: $f_highlight_changed
 401       6: $f_hide_closed
 402       7: $f_reporter_id
 403       8: $f_handler_id
 404       9: $f_sort
 405      10: $f_dir
 406      11: $f_start_month
 407      12: $f_start_day
 408      13: $f_start_year
 409      14: $f_end_month
 410      15: $f_end_day
 411      16: $f_end_year
 412      17: $f_search
 413      18: $f_hide_resolved
 414      19: $f_show_resolution
 415      20: $f_show_build
 416      21: $f_show_version
 417      22: $f_do_filter_by_date
 418      23: $f_custom_field
 419      24: $f_relationship_type
 420      25: $f_relationship_bug
 421      26: $f_show_profile
 422  
 423  */
 424  # Set new filter values.  These are stored in a cookie
 425  $t_view_all_cookie_id = gpc_get_cookie( config_get( 'view_all_cookie' ), '' );
 426  $t_view_all_cookie = filter_db_get_filter( $t_view_all_cookie_id );
 427  
 428  # process the cookie if it exists, it may be blank in a new install
 429  if ( !is_blank( $t_view_all_cookie ) ) {
 430      $t_setting_arr = filter_deserialize( $t_view_all_cookie );
 431      if ( false === $t_setting_arr ) {
 432          # couldn't deserialize, if we were trying to use the filter, clear it and reload
 433          # for ftype = 0, 1, or 3, we are going to re-write the filter anyways
 434          if ( !in_array( $f_type, array( 0, 1, 3 ) ) ) {
 435              gpc_clear_cookie( 'view_all_cookie' );
 436              error_proceed_url( 'view_all_set.php?type=0' );
 437              trigger_error( ERROR_FILTER_TOO_OLD, ERROR );
 438              exit; # stop here
 439          }
 440      }
 441  } else {
 442      # no cookie found, set it
 443      $f_type = 1;
 444  }
 445  
 446  $t_cookie_version = config_get( 'cookie_version' );
 447  $t_default_show_changed = config_get( 'default_show_changed' );
 448  
 449  # Clear the source query id.  Since we have entered new filter criteria.
 450  $t_setting_arr['_source_query_id'] = '';
 451  switch ( $f_type ) {
 452      # New cookie
 453      case '0':
 454              log_event( LOG_FILTERING, 'view_all_set.php: New cookie' );
 455              $t_setting_arr = array();
 456  
 457              break;
 458      # Update filters
 459      case '1':
 460              log_event( LOG_FILTERING, 'view_all_set.php: Update filters' );
 461              $t_setting_arr['_version']                                 = $t_cookie_version;
 462              $t_setting_arr['_view_type']                             = $f_view_type;
 463              $t_setting_arr[ FILTER_PROPERTY_CATEGORY_ID ]             = $f_show_category;
 464              $t_setting_arr[ FILTER_PROPERTY_SEVERITY ]                 = $f_show_severity;
 465              $t_setting_arr[ FILTER_PROPERTY_STATUS ]                 = $f_show_status;
 466              $t_setting_arr[ FILTER_PROPERTY_ISSUES_PER_PAGE ]         = $f_per_page;
 467              $t_setting_arr[ FILTER_PROPERTY_HIGHLIGHT_CHANGED ]     = $f_highlight_changed;
 468              $t_setting_arr[ FILTER_PROPERTY_REPORTER_ID ]             = $f_reporter_id;
 469              $t_setting_arr[ FILTER_PROPERTY_HANDLER_ID ]             = $f_handler_id;
 470              $t_setting_arr[ FILTER_PROPERTY_PROJECT_ID ]             = $f_project_id;
 471              $t_setting_arr[ FILTER_PROPERTY_SORT_FIELD_NAME ]         = $f_sort;
 472              $t_setting_arr[ FILTER_PROPERTY_SORT_DIRECTION ]         = $f_dir;
 473              $t_setting_arr[ FILTER_PROPERTY_START_MONTH ]             = $f_start_month;
 474              $t_setting_arr[ FILTER_PROPERTY_START_DAY ]             = $f_start_day;
 475              $t_setting_arr[ FILTER_PROPERTY_START_YEAR ]             = $f_start_year;
 476              $t_setting_arr[ FILTER_PROPERTY_END_MONTH ]             = $f_end_month;
 477              $t_setting_arr[ FILTER_PROPERTY_END_DAY ]                 = $f_end_day;
 478              $t_setting_arr[ FILTER_PROPERTY_END_YEAR ]                 = $f_end_year;
 479              $t_setting_arr[ FILTER_PROPERTY_SEARCH]                 = $f_search;
 480              $t_setting_arr[ FILTER_PROPERTY_HIDE_STATUS ]             = $f_hide_status;
 481              $t_setting_arr[ FILTER_PROPERTY_RESOLUTION ]             = $f_show_resolution;
 482              $t_setting_arr[ FILTER_PROPERTY_BUILD ]                 = $f_show_build;
 483              $t_setting_arr[ FILTER_PROPERTY_VERSION ]                 = $f_show_version;
 484              $t_setting_arr[ FILTER_PROPERTY_FILTER_BY_DATE ]         = $f_do_filter_by_date;
 485              $t_setting_arr[ FILTER_PROPERTY_FIXED_IN_VERSION ]         = $f_fixed_in_version;
 486              $t_setting_arr[ FILTER_PROPERTY_TARGET_VERSION ]         = $f_target_version;
 487              $t_setting_arr[ FILTER_PROPERTY_PRIORITY ]                 = $f_show_priority;
 488              $t_setting_arr[ FILTER_PROPERTY_MONITOR_USER_ID ]         = $f_user_monitor;
 489              $t_setting_arr[ FILTER_PROPERTY_VIEW_STATE ]             = $f_view_state;
 490              $t_setting_arr['custom_fields']                         = $f_custom_fields_data;
 491              $t_setting_arr[ FILTER_PROPERTY_STICKY ]                 = $f_sticky_issues;
 492              $t_setting_arr[ FILTER_PROPERTY_RELATIONSHIP_TYPE ]     = $f_relationship_type;
 493              $t_setting_arr[ FILTER_PROPERTY_RELATIONSHIP_BUG ]         = $f_relationship_bug;
 494              $t_setting_arr[ FILTER_PROPERTY_PROFILE_ID ]             = $f_show_profile;
 495              $t_setting_arr[ FILTER_PROPERTY_PLATFORM ]                 = $f_platform;
 496              $t_setting_arr[ FILTER_PROPERTY_OS ]                     = $f_os;
 497              $t_setting_arr[ FILTER_PROPERTY_OS_BUILD ]                 = $f_os_build;
 498              $t_setting_arr[ FILTER_PROPERTY_TAG_STRING ]             = $f_tag_string;
 499              $t_setting_arr[ FILTER_PROPERTY_TAG_SELECT ]             = $f_tag_select;
 500              $t_setting_arr[ FILTER_PROPERTY_NOTE_USER_ID ]             = $f_note_user_id;
 501              $t_setting_arr = array_merge( $t_setting_arr, $f_filter_input );
 502              break;
 503      # Set the sort order and direction
 504      case '2':
 505              log_event( LOG_FILTERING, 'view_all_set.php: Set the sort order and direction.' );
 506  
 507              # We only need to set those fields that we are overriding
 508              $t_setting_arr[ FILTER_PROPERTY_SORT_FIELD_NAME ] = $f_sort;
 509              $t_setting_arr[ FILTER_PROPERTY_SORT_DIRECTION ] = $f_dir;
 510  
 511              break;
 512      # This is when we want to copy another query from the
 513      # database over the top of our current one
 514      case '3':
 515              log_event( LOG_FILTERING, 'view_all_set.php: Copy another query from database' );
 516  
 517              $t_filter_string = filter_db_get_filter( $f_source_query_id );
 518              # If we can use the query that we've requested,
 519              # grab it. We will overwrite the current one at the
 520              # bottom of this page
 521              $t_setting_arr = filter_deserialize( $t_filter_string );
 522              if ( false === $t_setting_arr ) {
 523                  # couldn't deserialize, if we were trying to use the filter, clear it and reload
 524                  gpc_clear_cookie( 'view_all_cookie' );
 525                  error_proceed_url( 'view_all_set.php?type=0' );
 526                  trigger_error( ERROR_FILTER_TOO_OLD, ERROR );
 527                  exit; # stop here
 528              }
 529              # Store the source query id to select the correct filter in the drop down.
 530              $t_setting_arr['_source_query_id'] = $f_source_query_id;
 531              break;
 532      # Generalise the filter
 533      case '4':
 534              log_event( LOG_FILTERING, 'view_all_set.php: Generalise the filter' );
 535  
 536              $t_setting_arr[ FILTER_PROPERTY_CATEGORY_ID ]        = array( META_FILTER_ANY );
 537              $t_setting_arr[ FILTER_PROPERTY_REPORTER_ID ]         = array( META_FILTER_ANY );
 538              $t_setting_arr[ FILTER_PROPERTY_HANDLER_ID ]         = array( META_FILTER_ANY );
 539              $t_setting_arr[ FILTER_PROPERTY_BUILD ]             = array( META_FILTER_ANY );
 540              $t_setting_arr[ FILTER_PROPERTY_VERSION ]             = array( META_FILTER_ANY );
 541              $t_setting_arr[ FILTER_PROPERTY_PRIORITY ]            = array( META_FILTER_ANY );
 542              $t_setting_arr[ FILTER_PROPERTY_FIXED_IN_VERSION ]    = array( META_FILTER_ANY );
 543              $t_setting_arr[ FILTER_PROPERTY_TARGET_VERSION ]    = array( META_FILTER_ANY );
 544              $t_setting_arr[ FILTER_PROPERTY_MONITOR_USER_ID ]     = array( META_FILTER_ANY );
 545              $t_setting_arr[ FILTER_PROPERTY_NOTE_USER_ID ]      = array( META_FILTER_ANY );
 546              $t_setting_arr[ FILTER_PROPERTY_RELATIONSHIP_TYPE ] = -1;
 547              $t_setting_arr[ FILTER_PROPERTY_RELATIONSHIP_BUG ]     = 0;
 548  
 549              $t_custom_fields         = custom_field_get_ids(); # @@@ (thraxisp) This should really be the linked ids, but we don't know the project
 550              $t_custom_fields_data     = array();
 551              if ( is_array( $t_custom_fields ) && ( count( $t_custom_fields ) > 0 ) ) {
 552                  foreach( $t_custom_fields as $t_cfid ) {
 553                      $t_custom_fields_data[$t_cfid] =  array( META_FILTER_ANY );
 554                  }
 555              }
 556              $t_setting_arr['custom_fields'] = $t_custom_fields_data;
 557  
 558              break;
 559      # Just set the search string value
 560      case '5':
 561              log_event( LOG_FILTERING, 'view_all_set.php: Search Text' );
 562              $t_setting_arr[ FILTER_PROPERTY_SEARCH ] = $f_search;
 563  
 564              break;
 565      # Just set the view_state (simple / advanced) value
 566      case '6':
 567              log_event( LOG_FILTERING, 'view_all_set.php: View state (simple/advanced)' );
 568              $t_setting_arr['_view_type'] = $f_view_type;
 569  
 570              break;
 571      # does nothing. catch all case
 572      default:
 573              log_event( LOG_FILTERING, 'view_all_set.php: default - do nothing' );
 574              break;
 575  }
 576  
 577  $tc_setting_arr = filter_ensure_valid_filter( $t_setting_arr );
 578  
 579  /**
 580   *  Remove any statuses that should be excluded by the hide_status field
 581   */
 582  if( $f_view_type == "advanced" ) {
 583      if( $tc_setting_arr[FILTER_PROPERTY_HIDE_STATUS][0] > 0 ) {
 584          $t_statuses = MantisEnum::getValues( config_get( 'status_enum_string' ) );
 585          foreach( $t_statuses as $t_key=>$t_val ) {
 586              if( $t_val < $tc_setting_arr[FILTER_PROPERTY_HIDE_STATUS][0] ) {
 587                  $t_keep_statuses[$t_key] = $t_val;
 588              }
 589          }
 590          $tc_setting_arr[FILTER_PROPERTY_STATUS] = $t_keep_statuses;
 591      }
 592  }
 593  /**
 594   *  If a status is selected in the status and the hide status field, remove it from
 595   *  hide status
 596   */
 597  if( $f_view_type == "simple" && $tc_setting_arr[FILTER_PROPERTY_HIDE_STATUS][0] > 0 ) {
 598      foreach( $tc_setting_arr[FILTER_PROPERTY_STATUS] as $t_key => $t_val ) {
 599          if( $tc_setting_arr[FILTER_PROPERTY_STATUS][$t_key] == $tc_setting_arr[FILTER_PROPERTY_HIDE_STATUS][0] ) {
 600              unset( $tc_setting_arr[FILTER_PROPERTY_HIDE_STATUS][0] );
 601          }
 602      }
 603  }
 604  
 605  $t_settings_serialized = serialize( $tc_setting_arr );
 606  $t_settings_string = $t_cookie_version . '#' . $t_settings_serialized;
 607  
 608  # If only using a temporary filter, don't store it in the database
 609  if ( !$f_temp_filter ) {
 610      # Store the filter string in the database: its the current filter, so some values won't change
 611      $t_project_id = helper_get_current_project();
 612      $t_project_id = ( $t_project_id * -1 );
 613      $t_row_id = filter_db_set_for_current_user( $t_project_id, false, '', $t_settings_string );
 614  
 615      # set cookie values
 616      gpc_set_cookie( config_get( 'view_all_cookie' ), $t_row_id, time()+config_get( 'cookie_time_length' ), config_get( 'cookie_path' ) );
 617  }
 618  
 619  # redirect to print_all or view_all page
 620  if ( $f_print ) {
 621      $t_redirect_url = 'print_all_bug_page.php';
 622  } else {
 623      $t_redirect_url = 'view_all_bug_page.php';
 624  }
 625  
 626  if ( $f_temp_filter ) {
 627      $t_token_id = token_set( TOKEN_FILTER, $t_settings_serialized );
 628      $t_redirect_url = $t_redirect_url . '?filter=' . $t_token_id;
 629      html_meta_redirect( $t_redirect_url, 0 );
 630  } else {
 631      print_header_redirect( $t_redirect_url );
 632  }


Generated: Thu Jul 28 15:48:31 2011 Cross-referenced by PHPXref 0.7