/** * Print filter by date fields * @param boolean $p_hide_checkbox Hide data filter checkbox. * @return void */ function print_filter_do_filter_by_date($p_hide_checkbox = false) { global $g_filter; ?> <table cellspacing="0" cellpadding="0"> <?php $t_menu_disabled = ''; if (!$p_hide_checkbox) { ?> <tr> <td colspan="2"> <label> <input type="checkbox" id="use_date_filters" name="<?php echo FILTER_PROPERTY_FILTER_BY_DATE; ?> "<?php check_checked(gpc_string_to_bool($g_filter[FILTER_PROPERTY_FILTER_BY_DATE]), true); ?> /> <?php echo lang_get('use_date_filters'); ?> </label> </td> </tr> <?php if ('on' !== $g_filter[FILTER_PROPERTY_FILTER_BY_DATE]) { $t_menu_disabled = ' disabled="disabled" '; } } ?> <!-- Start date --> <tr> <td> <?php echo lang_get('start_date_label'); ?> </td> <td class="nowrap"> <?php $t_chars = preg_split('//', config_get('short_date_format'), -1, PREG_SPLIT_NO_EMPTY); foreach ($t_chars as $t_char) { if (strcasecmp($t_char, 'M') == 0) { echo '<select name="', FILTER_PROPERTY_START_MONTH, '"', $t_menu_disabled, '>'; print_month_option_list($g_filter[FILTER_PROPERTY_START_MONTH]); print "</select>\n"; } if (strcasecmp($t_char, 'D') == 0) { echo '<select name="', FILTER_PROPERTY_START_DAY, '"', $t_menu_disabled, '>'; print_day_option_list($g_filter[FILTER_PROPERTY_START_DAY]); print "</select>\n"; } if (strcasecmp($t_char, 'Y') == 0) { echo '<select name="', FILTER_PROPERTY_START_YEAR, '"', $t_menu_disabled, '>'; print_year_option_list($g_filter[FILTER_PROPERTY_START_YEAR]); print "</select>\n"; } } ?> </td> </tr> <!-- End date --> <tr> <td> <?php echo lang_get('end_date_label'); ?> </td> <td> <?php $t_chars = preg_split('//', config_get('short_date_format'), -1, PREG_SPLIT_NO_EMPTY); foreach ($t_chars as $t_char) { if (strcasecmp($t_char, 'M') == 0) { echo '<select name="', FILTER_PROPERTY_END_MONTH, '"', $t_menu_disabled, '>'; print_month_option_list($g_filter[FILTER_PROPERTY_END_MONTH]); print "</select>\n"; } if (strcasecmp($t_char, 'D') == 0) { echo '<select name="', FILTER_PROPERTY_END_DAY, '"', $t_menu_disabled, '>'; print_day_option_list($g_filter[FILTER_PROPERTY_END_DAY]); print "</select>\n"; } if (strcasecmp($t_char, 'Y') == 0) { echo '<select name="', FILTER_PROPERTY_END_YEAR, '"', $t_menu_disabled, '>'; print_year_option_list($g_filter[FILTER_PROPERTY_END_YEAR]); print "</select>\n"; } } ?> </td> </tr> </table> <?php }
function gpc_get_bool_array($p_var_name, $p_default = null) { # Don't pass along a default unless one was given to us # otherwise we prevent an error being triggered $args = func_get_args(); $t_result = call_user_func_array('gpc_get', $args); # If we the result isn't the default we were given or an array, error if (!(1 < func_num_args() && $t_result === $p_default || is_array($t_result))) { error_parameters($p_var_name); trigger_error(ERROR_GPC_ARRAY_EXPECTED, ERROR); } for ($i = 0; $i < sizeof($t_result); $i++) { $t_result[$i] = gpc_string_to_bool($t_result[$i]); } return $t_result; }
function gpc_get_bool($p_var_name, $p_default = false) { $t_result = gpc_get($p_var_name, $p_default); if ($t_result === $p_default) { return $p_default; } else { if (is_array($t_result)) { error_parameters($p_var_name); trigger_error(ERROR_GPC_ARRAY_UNEXPECTED, ERROR); } return gpc_string_to_bool($t_result); } }
/** * Localizes one raw history item specified by set the next parameters: $p_field_name, $p_type, $p_old_value, $p_new_value * Returns array with two elements indexed as 'note' and 'change' * @param string $p_field_name The field name of the field being localized. * @param integer $p_type The type of the history entry. * @param string $p_old_value The old value of the field. * @param string $p_new_value The new value of the field. * @param boolean $p_linkify Whether to return a string containing hyperlinks. * @return array */ function history_localize_item($p_field_name, $p_type, $p_old_value, $p_new_value, $p_linkify = true) { $t_note = ''; $t_change = ''; $t_field_localized = $p_field_name; $t_raw = true; if (PLUGIN_HISTORY == $p_type) { $t_note = lang_get_defaulted('plugin_' . $p_field_name, $p_field_name); $t_change = isset($p_new_value) ? $p_old_value . ' => ' . $p_new_value : $p_old_value; return array('note' => $t_note, 'change' => $t_change, 'raw' => true); } switch ($p_field_name) { case 'category': $t_field_localized = lang_get('category'); break; case 'status': $p_old_value = get_enum_element('status', $p_old_value); $p_new_value = get_enum_element('status', $p_new_value); $t_field_localized = lang_get('status'); break; case 'severity': $p_old_value = get_enum_element('severity', $p_old_value); $p_new_value = get_enum_element('severity', $p_new_value); $t_field_localized = lang_get('severity'); break; case 'reproducibility': $p_old_value = get_enum_element('reproducibility', $p_old_value); $p_new_value = get_enum_element('reproducibility', $p_new_value); $t_field_localized = lang_get('reproducibility'); break; case 'resolution': $p_old_value = get_enum_element('resolution', $p_old_value); $p_new_value = get_enum_element('resolution', $p_new_value); $t_field_localized = lang_get('resolution'); break; case 'priority': $p_old_value = get_enum_element('priority', $p_old_value); $p_new_value = get_enum_element('priority', $p_new_value); $t_field_localized = lang_get('priority'); break; case 'eta': $p_old_value = get_enum_element('eta', $p_old_value); $p_new_value = get_enum_element('eta', $p_new_value); $t_field_localized = lang_get('eta'); break; case 'view_state': $p_old_value = get_enum_element('view_state', $p_old_value); $p_new_value = get_enum_element('view_state', $p_new_value); $t_field_localized = lang_get('view_status'); break; case 'projection': $p_old_value = get_enum_element('projection', $p_old_value); $p_new_value = get_enum_element('projection', $p_new_value); $t_field_localized = lang_get('projection'); break; case 'sticky': $p_old_value = gpc_string_to_bool($p_old_value) ? lang_get('yes') : lang_get('no'); $p_new_value = gpc_string_to_bool($p_new_value) ? lang_get('yes') : lang_get('no'); $t_field_localized = lang_get('sticky_issue'); break; case 'project_id': if (project_exists($p_old_value)) { $p_old_value = project_get_field($p_old_value, 'name'); } else { $p_old_value = '@' . $p_old_value . '@'; } # Note that the new value maybe an intermediately project and not the # current one. if (project_exists($p_new_value)) { $p_new_value = project_get_field($p_new_value, 'name'); } else { $p_new_value = '@' . $p_new_value . '@'; } $t_field_localized = lang_get('email_project'); break; case 'handler_id': $t_field_localized = lang_get('assigned_to'); case 'reporter_id': if ('reporter_id' == $p_field_name) { $t_field_localized = lang_get('reporter'); } if (0 == $p_old_value) { $p_old_value = ''; } else { $p_old_value = user_get_name($p_old_value); } if (0 == $p_new_value) { $p_new_value = ''; } else { $p_new_value = user_get_name($p_new_value); } break; case 'version': $t_field_localized = lang_get('product_version'); break; case 'fixed_in_version': $t_field_localized = lang_get('fixed_in_version'); break; case 'target_version': $t_field_localized = lang_get('target_version'); break; case 'date_submitted': $p_old_value = date(config_get('normal_date_format'), $p_old_value); $p_new_value = date(config_get('normal_date_format'), $p_new_value); $t_field_localized = lang_get('date_submitted'); break; case 'last_updated': $p_old_value = date(config_get('normal_date_format'), $p_old_value); $p_new_value = date(config_get('normal_date_format'), $p_new_value); $t_field_localized = lang_get('last_update'); break; case 'os': $t_field_localized = lang_get('os'); break; case 'os_build': $t_field_localized = lang_get('os_version'); break; case 'build': $t_field_localized = lang_get('build'); break; case 'platform': $t_field_localized = lang_get('platform'); break; case 'summary': $t_field_localized = lang_get('summary'); break; case 'duplicate_id': $t_field_localized = lang_get('duplicate_id'); break; case 'sponsorship_total': $t_field_localized = lang_get('sponsorship_total'); break; case 'due_date': if ($p_old_value !== '') { $p_old_value = date(config_get('normal_date_format'), (int) $p_old_value); } if ($p_new_value !== '') { $p_new_value = date(config_get('normal_date_format'), (int) $p_new_value); } $t_field_localized = lang_get('due_date'); break; default: # assume it's a custom field name $t_field_id = custom_field_get_id_from_name($p_field_name); if (false !== $t_field_id) { $t_cf_type = custom_field_type($t_field_id); if ('' != $p_old_value) { $p_old_value = string_custom_field_value_for_email($p_old_value, $t_cf_type); } $p_new_value = string_custom_field_value_for_email($p_new_value, $t_cf_type); $t_field_localized = lang_get_defaulted($p_field_name); } } if (NORMAL_TYPE != $p_type) { switch ($p_type) { case NEW_BUG: $t_note = lang_get('new_bug'); break; case BUGNOTE_ADDED: $t_note = lang_get('bugnote_added') . ': ' . $p_old_value; break; case BUGNOTE_UPDATED: $t_note = lang_get('bugnote_edited') . ': ' . $p_old_value; $t_old_value = (int) $p_old_value; $t_new_value = (int) $p_new_value; if ($p_linkify && bug_revision_exists($t_new_value)) { if (bugnote_exists($t_old_value)) { $t_bug_revision_view_page_argument = 'bugnote_id=' . $t_old_value . '#r' . $t_new_value; } else { $t_bug_revision_view_page_argument = 'rev_id=' . $t_new_value; } $t_change = '<a href="bug_revision_view_page.php?' . $t_bug_revision_view_page_argument . '">' . lang_get('view_revisions') . '</a>'; $t_raw = false; } break; case BUGNOTE_DELETED: $t_note = lang_get('bugnote_deleted') . ': ' . $p_old_value; break; case DESCRIPTION_UPDATED: $t_note = lang_get('description_updated'); $t_old_value = (int) $p_old_value; if ($p_linkify && bug_revision_exists($t_old_value)) { $t_change = '<a href="bug_revision_view_page.php?rev_id=' . $t_old_value . '#r' . $t_old_value . '">' . lang_get('view_revisions') . '</a>'; $t_raw = false; } break; case ADDITIONAL_INFO_UPDATED: $t_note = lang_get('additional_information_updated'); $t_old_value = (int) $p_old_value; if ($p_linkify && bug_revision_exists($t_old_value)) { $t_change = '<a href="bug_revision_view_page.php?rev_id=' . $t_old_value . '#r' . $t_old_value . '">' . lang_get('view_revisions') . '</a>'; $t_raw = false; } break; case STEP_TO_REPRODUCE_UPDATED: $t_note = lang_get('steps_to_reproduce_updated'); $t_old_value = (int) $p_old_value; if ($p_linkify && bug_revision_exists($t_old_value)) { $t_change = '<a href="bug_revision_view_page.php?rev_id=' . $t_old_value . '#r' . $t_old_value . '">' . lang_get('view_revisions') . '</a>'; $t_raw = false; } break; case FILE_ADDED: $t_note = lang_get('file_added') . ': ' . $p_old_value; break; case FILE_DELETED: $t_note = lang_get('file_deleted') . ': ' . $p_old_value; break; case BUGNOTE_STATE_CHANGED: $p_old_value = get_enum_element('view_state', $p_old_value); $t_note = lang_get('bugnote_view_state') . ': ' . $p_new_value . ': ' . $p_old_value; break; case BUG_MONITOR: $p_old_value = user_get_name($p_old_value); $t_note = lang_get('bug_monitor') . ': ' . $p_old_value; break; case BUG_UNMONITOR: if ($p_old_value !== '') { $p_old_value = user_get_name($p_old_value); } $t_note = lang_get('bug_end_monitor') . ': ' . $p_old_value; break; case BUG_DELETED: $t_note = lang_get('bug_deleted') . ': ' . $p_old_value; break; case BUG_ADD_SPONSORSHIP: $t_note = lang_get('sponsorship_added'); $t_change = user_get_name($p_old_value) . ': ' . sponsorship_format_amount($p_new_value); break; case BUG_UPDATE_SPONSORSHIP: $t_note = lang_get('sponsorship_updated'); $t_change = user_get_name($p_old_value) . ': ' . sponsorship_format_amount($p_new_value); break; case BUG_DELETE_SPONSORSHIP: $t_note = lang_get('sponsorship_deleted'); $t_change = user_get_name($p_old_value) . ': ' . sponsorship_format_amount($p_new_value); break; case BUG_PAID_SPONSORSHIP: $t_note = lang_get('sponsorship_paid'); $t_change = user_get_name($p_old_value) . ': ' . get_enum_element('sponsorship', $p_new_value); break; case BUG_ADD_RELATIONSHIP: $t_note = lang_get('relationship_added'); $t_change = relationship_get_description_for_history($p_old_value) . ' ' . bug_format_id($p_new_value); break; case BUG_REPLACE_RELATIONSHIP: $t_note = lang_get('relationship_replaced'); $t_change = relationship_get_description_for_history($p_old_value) . ' ' . bug_format_id($p_new_value); break; case BUG_DEL_RELATIONSHIP: $t_note = lang_get('relationship_deleted'); # Fix for #7846: There are some cases where old value is empty, this may be due to an old bug. if (!is_blank($p_old_value) && $p_old_value > 0) { $t_change = relationship_get_description_for_history($p_old_value) . ' ' . bug_format_id($p_new_value); } else { $t_change = bug_format_id($p_new_value); } break; case BUG_CLONED_TO: $t_note = lang_get('bug_cloned_to') . ': ' . bug_format_id($p_new_value); break; case BUG_CREATED_FROM: $t_note = lang_get('bug_created_from') . ': ' . bug_format_id($p_new_value); break; case TAG_ATTACHED: $t_note = lang_get('tag_history_attached') . ': ' . $p_old_value; break; case TAG_DETACHED: $t_note = lang_get('tag_history_detached') . ': ' . $p_old_value; break; case TAG_RENAMED: $t_note = lang_get('tag_history_renamed'); $t_change = $p_old_value . ' => ' . $p_new_value; break; case BUG_REVISION_DROPPED: $t_note = lang_get('bug_revision_dropped_history') . ': ' . bug_revision_get_type_name($p_new_value) . ': ' . $p_old_value; break; case BUGNOTE_REVISION_DROPPED: $t_note = lang_get('bugnote_revision_dropped_history') . ': ' . $p_new_value . ': ' . $p_old_value; break; } } # output special cases if (NORMAL_TYPE == $p_type) { $t_note = $t_field_localized; $t_change = $p_old_value . ' => ' . $p_new_value; } # end if DEFAULT return array('note' => $t_note, 'change' => $t_change, 'raw' => $t_raw); }
function gpc_get_bool_array($p_var_name, $p_default = null) { # Don't pass along a default unless one was given to us # otherwise we prevent an error being triggered if (func_num_args() > 1) { $t_result = gpc_get($p_var_name, $p_default); } else { $t_result = gpc_get($p_var_name); } if (!is_array($t_result)) { #trigger_error( ERROR_GPC_ARRAY_EXPECTED, ERROR); echo "Unexpected array '{$p_var_name}'."; } for ($i = 0; $i < sizeof($t_result); $i++) { $t_result[$i] = gpc_string_to_bool($t_result[$i]); } return $t_result; }
/** * print sticky issues field */ function print_filter_sticky_issues() { global $t_filter; ?> <!-- Show or hide sticky bugs --> <input type="checkbox" name="<?php echo FILTER_PROPERTY_STICKY; ?> "<?php check_checked(gpc_string_to_bool($t_filter[FILTER_PROPERTY_STICKY]), true); ?> /> <?php }
function print_filter_sticky_issues() { global $t_filter; ?> <!-- Show or hide sticky bugs --> <input type="checkbox" name="sticky_issues" <?php check_checked(gpc_string_to_bool($t_filter['sticky_issues']), 'on'); ?> /> <?php }
function history_localize_item($p_field_name, $p_type, $p_old_value, $p_new_value) { $t_note = ''; $t_change = ''; $t_field_localized = $p_field_name; switch ($p_field_name) { case 'category': $t_field_localized = lang_get('category'); break; case 'status': $p_old_value = get_enum_element('status', $p_old_value); $p_new_value = get_enum_element('status', $p_new_value); $t_field_localized = lang_get('status'); break; case 'severity': $p_old_value = get_enum_element('severity', $p_old_value); $p_new_value = get_enum_element('severity', $p_new_value); $t_field_localized = lang_get('severity'); break; case 'reproducibility': $p_old_value = get_enum_element('reproducibility', $p_old_value); $p_new_value = get_enum_element('reproducibility', $p_new_value); $t_field_localized = lang_get('reproducibility'); break; case 'resolution': $p_old_value = get_enum_element('resolution', $p_old_value); $p_new_value = get_enum_element('resolution', $p_new_value); $t_field_localized = lang_get('resolution'); break; case 'priority': $p_old_value = get_enum_element('priority', $p_old_value); $p_new_value = get_enum_element('priority', $p_new_value); $t_field_localized = lang_get('priority'); break; case 'eta': $p_old_value = get_enum_element('eta', $p_old_value); $p_new_value = get_enum_element('eta', $p_new_value); $t_field_localized = lang_get('eta'); break; case 'view_state': $p_old_value = get_enum_element('view_state', $p_old_value); $p_new_value = get_enum_element('view_state', $p_new_value); $t_field_localized = lang_get('view_status'); break; case 'projection': $p_old_value = get_enum_element('projection', $p_old_value); $p_new_value = get_enum_element('projection', $p_new_value); $t_field_localized = lang_get('projection'); break; case 'sticky': $p_old_value = gpc_string_to_bool($p_old_value) ? lang_get('yes') : lang_get('no'); $p_new_value = gpc_string_to_bool($p_new_value) ? lang_get('yes') : lang_get('no'); $t_field_localized = lang_get('sticky_issue'); break; case 'project_id': if (project_exists($p_old_value)) { $p_old_value = project_get_field($p_old_value, 'name'); } else { $p_old_value = '@' . $p_old_value . '@'; } # Note that the new value maybe an intermediately project and not the # current one. if (project_exists($p_new_value)) { $p_new_value = project_get_field($p_new_value, 'name'); } else { $p_new_value = '@' . $p_new_value . '@'; } $t_field_localized = lang_get('email_project'); break; case 'handler_id': $t_field_localized = lang_get('assigned_to'); case 'reporter_id': if ('reporter_id' == $p_field_name) { $t_field_localized = lang_get('reporter'); } if (0 == $p_old_value) { $p_old_value = ''; } else { $p_old_value = user_get_name($p_old_value); } if (0 == $p_new_value) { $p_new_value = ''; } else { $p_new_value = user_get_name($p_new_value); } break; case 'fixed_in_version': $t_field_localized = lang_get('fixed_in_version'); break; case 'date_submitted': $t_field_localized = lang_get('date_submitted'); break; case 'last_updated': $t_field_localized = lang_get('last_update'); break; case 'summary': $t_field_localized = lang_get('summary'); break; case 'duplicate_id': $t_field_localized = lang_get('duplicate_id'); break; case 'sponsorship_total': $t_field_localized = lang_get('sponsorship_total'); break; default: # assume it's a custom field name $t_field_id = custom_field_get_id_from_name($p_field_name); if (false !== $t_field_id) { $t_cf_type = custom_field_type($t_field_id); if ('' != $p_old_value) { $p_old_value = string_custom_field_value_for_email($p_old_value, $t_cf_type); } $p_new_value = string_custom_field_value_for_email($p_new_value, $t_cf_type); } } if (NORMAL_TYPE != $p_type) { switch ($p_type) { case NEW_BUG: $t_note = lang_get('new_bug'); break; case BUGNOTE_ADDED: $t_note = lang_get('bugnote_added') . ": " . $p_old_value; break; case BUGNOTE_UPDATED: $t_note = lang_get('bugnote_edited') . ": " . $p_old_value; break; case BUGNOTE_DELETED: $t_note = lang_get('bugnote_deleted') . ": " . $p_old_value; break; case DESCRIPTION_UPDATED: $t_note = lang_get('description_updated'); break; case ADDITIONAL_INFO_UPDATED: $t_note = lang_get('additional_information_updated'); break; case STEP_TO_REPRODUCE_UPDATED: $t_note = lang_get('steps_to_reproduce_updated'); break; case FILE_ADDED: $t_note = lang_get('file_added') . ": " . $p_old_value; break; case FILE_DELETED: $t_note = lang_get('file_deleted') . ": " . $p_old_value; break; case BUGNOTE_STATE_CHANGED: $p_old_value = get_enum_element('view_state', $p_old_value); $t_note = lang_get('bugnote_view_state') . ": " . $p_old_value . ": " . $p_new_value; break; case BUG_MONITOR: $p_old_value = user_get_name($p_old_value); $t_note = lang_get('bug_monitor') . ": " . $p_old_value; break; case BUG_UNMONITOR: $p_old_value = user_get_name($p_old_value); $t_note = lang_get('bug_end_monitor') . ": " . $p_old_value; break; case BUG_DELETED: $t_note = lang_get('bug_deleted') . ": " . $p_old_value; break; case BUG_ADD_SPONSORSHIP: $t_note = lang_get('sponsorship_added'); $t_change = user_get_name($p_old_value) . ': ' . sponsorship_format_amount($p_new_value); break; case BUG_UPDATE_SPONSORSHIP: $t_note = lang_get('sponsorship_updated'); $t_change = user_get_name($p_old_value) . ': ' . sponsorship_format_amount($p_new_value); break; case BUG_DELETE_SPONSORSHIP: $t_note = lang_get('sponsorship_deleted'); $t_change = user_get_name($p_old_value) . ': ' . sponsorship_format_amount($p_new_value); break; case BUG_PAID_SPONSORSHIP: $t_note = lang_get('sponsorship_paid'); $t_change = user_get_name($p_old_value) . ': ' . get_enum_element('sponsorship', $p_new_value); break; case BUG_ADD_RELATIONSHIP: $t_note = lang_get('relationship_added'); $t_change = relationship_get_description_for_history($p_old_value) . ' ' . bug_format_id($p_new_value); break; case BUG_REPLACE_RELATIONSHIP: $t_note = lang_get('relationship_replaced'); $t_change = relationship_get_description_for_history($p_old_value) . ' ' . bug_format_id($p_new_value); break; case BUG_DEL_RELATIONSHIP: $t_note = lang_get('relationship_deleted'); $t_change = relationship_get_description_for_history($p_old_value) . ' ' . bug_format_id($p_new_value); break; case BUG_CLONED_TO: $t_note = lang_get('bug_cloned_to'); $t_change = bug_format_id($p_new_value); break; case BUG_CREATED_FROM: $t_note = lang_get('bug_created_from'); $t_change = bug_format_id($p_new_value); break; case CHECKIN: $t_note = lang_get('checkin'); break; } } # output special cases if (NORMAL_TYPE == $p_type) { $t_note = $t_field_localized; $t_change = $p_old_value . ' => ' . $p_new_value; } # end if DEFAULT return array('note' => $t_note, 'change' => $t_change); }
/** * Retrieve a boolean array GPC variable. Uses gpc_get(). * If you pass in *no* default, an error will be triggered if the variable does not exist. * @param string $p_var_name Variable name to retrieve. * @param array $p_default Default value of the boolean array if not set. * @return array */ function gpc_get_bool_array($p_var_name, array $p_default = null) { # Don't pass along a default unless one was given to us # otherwise we prevent an error being triggered $t_args = func_get_args(); $t_result = call_user_func_array('gpc_get', $t_args); # If the result isn't the default we were given or an array, error if (!(1 < func_num_args() && $t_result === $p_default || is_array($t_result))) { error_parameters($p_var_name); trigger_error(ERROR_GPC_ARRAY_EXPECTED, ERROR); } if (is_array($t_result)) { foreach ($t_result as $t_key => $t_value) { $t_result[$t_key] = gpc_string_to_bool($t_value); } } return $t_result; }