|
|
4c79b5 |
|
|
|
4c79b5 |
# Mantis - a php based bugtracking system
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
|
|
|
4c79b5 |
# Copyright (C) 2002 - 2007 Mantis Team - mantisbt-dev@lists.sourceforge.net
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Mantis is free software: you can redistribute it and/or modify
|
|
|
4c79b5 |
# it under the terms of the GNU General Public License as published by
|
|
|
4c79b5 |
# the Free Software Foundation, either version 2 of the License, or
|
|
|
4c79b5 |
# (at your option) any later version.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# Mantis is distributed in the hope that it will be useful,
|
|
|
4c79b5 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
4c79b5 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
4c79b5 |
# GNU General Public License for more details.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# You should have received a copy of the GNU General Public License
|
|
|
4c79b5 |
# along with Mantis. If not, see <http://www.gnu.org/licenses/>.
|
|
|
4c79b5 |
|
|
|
4c79b5 |
#------------------------------
|
|
|
4c79b5 |
# $Revision: 2643 $
|
|
|
4c79b5 |
# $Author: al $
|
|
|
4c79b5 |
# $Date: 2009-06-18 19:06:27 -0400 (Thu, 18 Jun 2009) $
|
|
|
4c79b5 |
#------------------------------
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
require_once( $t_core_dir . 'ajax_api.php' );
|
|
|
4c79b5 |
require_once( $t_core_dir . 'current_user_api.php' );
|
|
|
4c79b5 |
require_once( $t_core_dir . 'string_api.php' );
|
|
|
4c79b5 |
require_once( $t_core_dir . 'prepare_api.php' );
|
|
|
4c79b5 |
require_once( $t_core_dir . 'profile_api.php' );
|
|
|
4c79b5 |
require_once( $t_core_dir . 'last_visited_api.php' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
### Print API ###
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# this file handles printing functions
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# Print the headers to cause the page to redirect to $p_url
|
|
|
4c79b5 |
# If $p_die is true (default), terminate the execution of the script
|
|
|
4c79b5 |
# immediately
|
|
|
4c79b5 |
# If we have handled any errors on this page and the 'stop_on_errors' config
|
|
|
4c79b5 |
# option is turned on, return false and don't redirect.
|
|
|
4c79b5 |
# $p_sanitize - true/false - true in the case where the URL is extracted from GET/POST or untrusted source.
|
|
|
4c79b5 |
# This would be false if the URL is trusted (e.g. read from config_inc.php).
|
|
|
4c79b5 |
function print_header_redirect( $p_url, $p_die = true, $p_sanitize = false ) {
|
|
|
4c79b5 |
$t_use_iis = config_get( 'use_iis');
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( ON == config_get( 'stop_on_errors' ) && error_handled() ) {
|
|
|
4c79b5 |
return false;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# validate the url as part of this site before continuing
|
|
|
4c79b5 |
$t_url = $p_sanitize ? string_sanitize_url( $p_url ) : $p_url;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# don't send more headers if they have already been sent (guideweb)
|
|
|
4c79b5 |
if ( ! headers_sent() ) {
|
|
|
4c79b5 |
header( 'Content-Type: text/html; charset=' . lang_get( 'charset' ) );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( ON == $t_use_iis ) {
|
|
|
4c79b5 |
header( "Refresh: 0;url=$t_url" );
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
header( "Location: $t_url" );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
trigger_error( ERROR_PAGE_REDIRECTION, ERROR );
|
|
|
4c79b5 |
return false;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( $p_die ) {
|
|
|
4c79b5 |
die; # additional output can cause problems so let's just stop output here
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return true;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# Print a redirect header to view a bug
|
|
|
4c79b5 |
function print_header_redirect_view( $p_bug_id ) {
|
|
|
4c79b5 |
print_header_redirect( string_get_bug_view_url( $p_bug_id ) );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# Get a view URL for the bug id based on the user's preference and
|
|
|
4c79b5 |
# call print_successful_redirect() with that URL
|
|
|
4c79b5 |
function print_successful_redirect_to_bug( $p_bug_id ) {
|
|
|
4c79b5 |
$t_url = string_get_bug_view_url( $p_bug_id, auth_get_current_user_id() );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
print_successful_redirect( $t_url );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# If the show query count is ON, print success and redirect after the
|
|
|
4c79b5 |
# configured system wait time.
|
|
|
4c79b5 |
# If the show query count is OFF, redirect right away.
|
|
|
4c79b5 |
function print_successful_redirect( $p_redirect_to ) {
|
|
|
4c79b5 |
if ( helper_show_queries() ) {
|
|
|
4c79b5 |
html_meta_redirect( $p_redirect_to );
|
|
|
4c79b5 |
html_page_top1();
|
|
|
4c79b5 |
html_page_top2();
|
|
|
4c79b5 |
PRINT '';
|
|
|
4c79b5 |
PRINT '' . lang_get( 'operation_successful' ) . ' ';
|
|
|
4c79b5 |
print_bracket_link( $p_redirect_to, lang_get( 'proceed' ) );
|
|
|
4c79b5 |
PRINT '';
|
|
|
4c79b5 |
html_page_bottom1();
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
print_header_redirect( $p_redirect_to );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# Print a redirect header to update a bug
|
|
|
4c79b5 |
function print_header_redirect_update( $p_bug_id ) {
|
|
|
4c79b5 |
print_header_redirect( string_get_bug_update_url( $p_bug_id ) );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# Print a redirect header to update a bug
|
|
|
4c79b5 |
function print_header_redirect_report() {
|
|
|
4c79b5 |
print_header_redirect( string_get_bug_report_url() );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Print avatar image for the given user ID
|
|
|
4c79b5 |
function print_avatar( $p_user_id ) {
|
|
|
4c79b5 |
if ( !user_exists( $p_user_id ) ) {
|
|
|
4c79b5 |
return;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( access_has_project_level( config_get( 'show_avatar_threshold' ), null, $p_user_id ) ) {
|
|
|
4c79b5 |
$t_avatar = user_get_avatar( $p_user_id );
|
|
|
4c79b5 |
if ( false !== $t_avatar ) {
|
|
|
4c79b5 |
$t_avatar_url = $t_avatar[0];
|
|
|
4c79b5 |
$t_width = $t_avatar[1];
|
|
|
4c79b5 |
$t_height = $t_avatar[2];
|
|
|
4c79b5 |
echo '' .
|
|
|
4c79b5 |
'
|
|
|
4c79b5 |
' width="' . $t_width . '" height="' . $t_height . '" />';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# prints the name of the user given the id. also makes it an email link.
|
|
|
4c79b5 |
function print_user( $p_user_id ) {
|
|
|
4c79b5 |
echo prepare_user_name( $p_user_id );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# same as print_user() but fills in the subject with the bug summary
|
|
|
4c79b5 |
function print_user_with_subject( $p_user_id, $p_bug_id ) {
|
|
|
4c79b5 |
$c_user_id = db_prepare_int( $p_user_id );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( NO_USER == $p_user_id ) {
|
|
|
4c79b5 |
return;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_username = user_get_name( $p_user_id );
|
|
|
4c79b5 |
if ( user_exists( $p_user_id ) && user_get_field( $p_user_id, 'enabled' ) ) {
|
|
|
4c79b5 |
$t_email = user_get_field( $p_user_id, 'email' );
|
|
|
4c79b5 |
print_email_link_with_subject( $t_email, $t_username, $p_bug_id );
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
echo '<font STYLE="text-decoration: line-through">';
|
|
|
4c79b5 |
echo $t_username;
|
|
|
4c79b5 |
echo '</font>';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
function print_duplicate_id( $p_duplicate_id ) {
|
|
|
4c79b5 |
if ( $p_duplicate_id != 0 ) {
|
|
|
4c79b5 |
PRINT string_get_bug_view_link( $p_duplicate_id );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# print out an email editing input
|
|
|
4c79b5 |
function print_email_input( $p_field_name, $p_email ) {
|
|
|
4c79b5 |
$t_limit_email_domain = config_get( 'limit_email_domain' );
|
|
|
4c79b5 |
if ( $t_limit_email_domain ) {
|
|
|
4c79b5 |
# remove the domain part
|
|
|
4c79b5 |
$p_email = eregi_replace( "@$t_limit_email_domain$", '', $p_email );
|
|
|
4c79b5 |
PRINT '<input type="text" name="'.$p_field_name.'" size="20" maxlength="64" value="'.$p_email.'" />@'.$t_limit_email_domain;
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
PRINT '<input type="text" name="'.$p_field_name.'" size="32" maxlength="64" value="'.$p_email.'" />';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# print out an email editing input
|
|
|
4c79b5 |
function print_captcha_input( $p_field_name ) {
|
|
|
4c79b5 |
echo '<input type="text" name="'.$p_field_name.'" size="5" maxlength="5" value="" />';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
###########################################################################
|
|
|
4c79b5 |
# Option List Printing API
|
|
|
4c79b5 |
###########################################################################
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# sorts the array by the first element of the array element
|
|
|
4c79b5 |
# @@@ might not be used
|
|
|
4c79b5 |
function cmp( $p_var1, $p_var2 ) {
|
|
|
4c79b5 |
if ( $p_var1[0][0] == $p_var2[0][0] ) {
|
|
|
4c79b5 |
return 0;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
if ( $p_var1[0][0] < $p_var2[0][0] ) {
|
|
|
4c79b5 |
return -1;
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
return 1;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# This populates an option list with the appropriate users by access level
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# @@@ from print_reporter_option_list
|
|
|
4c79b5 |
function print_user_option_list( $p_user_id, $p_project_id = null, $p_access = ANYBODY ) {
|
|
|
4c79b5 |
$t_users = array();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( null === $p_project_id ) {
|
|
|
4c79b5 |
$p_project_id = helper_get_current_project();
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_users = project_get_all_user_rows( $p_project_id, $p_access ); # handles ALL_PROJECTS case
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_display = array();
|
|
|
4c79b5 |
$t_sort = array();
|
|
|
4c79b5 |
$t_show_realname = ( ON == config_get( 'show_realname' ) );
|
|
|
4c79b5 |
$t_sort_by_last_name = ( ON == config_get( 'sort_by_last_name' ) );
|
|
|
4c79b5 |
foreach ( $t_users as $t_user ) {
|
|
|
4c79b5 |
$t_user_name = string_attribute( $t_user['username'] );
|
|
|
4c79b5 |
$t_sort_name = strtolower( $t_user_name );
|
|
|
4c79b5 |
if ( $t_show_realname && ( $t_user['realname'] <> "" ) ){
|
|
|
4c79b5 |
$t_user_name = string_attribute( $t_user['realname'] );
|
|
|
4c79b5 |
if ( $t_sort_by_last_name ) {
|
|
|
4c79b5 |
$t_sort_name_bits = split( ' ', strtolower( $t_user_name ), 2 );
|
|
|
4c79b5 |
$t_sort_name = ( isset( $t_sort_name_bits[1] ) ? $t_sort_name_bits[1] . ', ' : '' ) . $t_sort_name_bits[0];
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
$t_sort_name = strtolower( $t_user_name );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$t_display[] = $t_user_name;
|
|
|
4c79b5 |
$t_sort[] = $t_sort_name;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
array_multisort( $t_sort, SORT_ASC, SORT_STRING, $t_users, $t_display );
|
|
|
4c79b5 |
for ($i = 0; $i < count( $t_sort ); $i++ ) {
|
|
|
4c79b5 |
$t_row = $t_users[$i];
|
|
|
4c79b5 |
PRINT '
|
|
|
4c79b5 |
check_selected( $p_user_id, $t_row['id'] );
|
|
|
4c79b5 |
PRINT '>' . $t_display[$i] . '</option>';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# ugly functions need to be refactored
|
|
|
4c79b5 |
# This populates the reporter option list with the appropriate users
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# @@@ This function really ought to print out all the users, I think.
|
|
|
4c79b5 |
# I just encountered a situation where a project used to be public and
|
|
|
4c79b5 |
# was made private, so now I can't filter on any of the reporters who
|
|
|
4c79b5 |
# actually reported the bugs at the time. Maybe we could get all user
|
|
|
4c79b5 |
# who are listed as the reporter in any bug? It would probably be a
|
|
|
4c79b5 |
# faster query actually.
|
|
|
4c79b5 |
function print_reporter_option_list( $p_user_id, $p_project_id = null ) {
|
|
|
4c79b5 |
print_user_option_list( $p_user_id, $p_project_id, config_get( 'report_bug_threshold' ) );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
function print_duplicate_id_option_list() {
|
|
|
4c79b5 |
$query = "SELECT id
|
|
|
4c79b5 |
FROM " . config_get ( 'mantis_bug_table' ) . "
|
|
|
4c79b5 |
ORDER BY id ASC";
|
|
|
4c79b5 |
$result = db_query( $query );
|
|
|
4c79b5 |
$duplicate_id_count = db_num_rows( $result );
|
|
|
4c79b5 |
PRINT '<option value="0"></option>';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
for ($i=0;$i<$duplicate_id_count;$i++) {
|
|
|
4c79b5 |
$row = db_fetch_array( $result );
|
|
|
4c79b5 |
$t_duplicate_id = $row['id'];
|
|
|
4c79b5 |
|
|
|
4c79b5 |
PRINT "<option value=\"$t_duplicate_id\">".$t_duplicate_id."</option>";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Print the entire form for attaching a tag to a bug.
|
|
|
4c79b5 |
* @param integer Bug ID
|
|
|
4c79b5 |
* @param string Default contents of the input box
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function print_tag_attach_form( $p_bug_id, $p_string="" ) {
|
|
|
4c79b5 |
?>
|
|
|
4c79b5 |
<small></small>
|
|
|
4c79b5 |
<form method="post" action="tag_attach.php">
|
|
|
4c79b5 |
|
|
|
4c79b5 |
<input type="hidden" name="bug_id" value="<?php echo $p_bug_id ?>" />
|
|
|
4c79b5 |
|
|
|
4c79b5 |
print_tag_input( $p_bug_id, $p_string );
|
|
|
4c79b5 |
?>
|
|
|
4c79b5 |
<input type="submit" value="<?php echo lang_get( 'tag_attach' ) ?>" class="button" />
|
|
|
4c79b5 |
</form>
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return true;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Print the separator comment, input box, and existing tag dropdown menu.
|
|
|
4c79b5 |
* @param integer Bug ID
|
|
|
4c79b5 |
* @param string Default contents of the input box
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function print_tag_input( $p_bug_id = 0, $p_string="" ) {
|
|
|
4c79b5 |
?>
|
|
|
4c79b5 |
<input type="hidden" id="tag_separator" value="<?php echo config_get( 'tag_separator' ) ?>" />
|
|
|
4c79b5 |
<input type="text" name="tag_string" id="tag_string" size="40" value="<?php echo string_attribute( $p_string ) ?>" />
|
|
|
4c79b5 |
<select <?php echo helper_get_tab_index() ?> name="tag_select" id="tag_select">
|
|
|
4c79b5 |
|
|
|
4c79b5 |
</select>
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return true;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Print the dropdown combo-box of existing tags.
|
|
|
4c79b5 |
* When passed a bug ID, the option list will not contain any tags attached to the given bug.
|
|
|
4c79b5 |
* @param integer Bug ID
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function print_tag_option_list( $p_bug_id = 0 ) {
|
|
|
4c79b5 |
$t_tag_table = config_get( 'mantis_tag_table' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$query = "SELECT id, name FROM $t_tag_table ";
|
|
|
4c79b5 |
if ( 0 != $p_bug_id ) {
|
|
|
4c79b5 |
$c_bug_id = db_prepare_int( $p_bug_id );
|
|
|
4c79b5 |
$t_bug_tag_table = config_get( 'mantis_bug_tag_table' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$query .= " WHERE id NOT IN (
|
|
|
4c79b5 |
SELECT tag_id FROM $t_bug_tag_table WHERE bug_id='$c_bug_id' ) ";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$query .= " ORDER BY name ASC ";
|
|
|
4c79b5 |
$result = db_query( $query );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
echo '<option value="0">',lang_get( 'tag_existing' ),'</option>';
|
|
|
4c79b5 |
while ( $row = db_fetch_array( $result ) ) {
|
|
|
4c79b5 |
echo '<option value="',$row['id'],'" onclick="tag_string_append(\'',$row['name'],'\')">',$row['name'],'</option>';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# Get current headlines and id prefix with v_
|
|
|
4c79b5 |
function print_news_item_option_list() {
|
|
|
4c79b5 |
$t_mantis_news_table = config_get( 'mantis_news_table' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_project_id = helper_get_current_project();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( access_has_project_level( ADMINISTRATOR ) ) {
|
|
|
4c79b5 |
$query = "SELECT id, headline, announcement, view_state
|
|
|
4c79b5 |
FROM $t_mantis_news_table
|
|
|
4c79b5 |
ORDER BY date_posted DESC";
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
$query = "SELECT id, headline, announcement, view_state
|
|
|
4c79b5 |
FROM $t_mantis_news_table
|
|
|
4c79b5 |
WHERE project_id='$t_project_id'
|
|
|
4c79b5 |
ORDER BY date_posted DESC";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$result = db_query( $query );
|
|
|
4c79b5 |
$news_count = db_num_rows( $result );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
for ($i=0;$i<$news_count;$i++) {
|
|
|
4c79b5 |
$row = db_fetch_array( $result );
|
|
|
4c79b5 |
extract( $row, EXTR_PREFIX_ALL, 'v' );
|
|
|
4c79b5 |
$v_headline = string_display( $v_headline );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_notes = array();
|
|
|
4c79b5 |
$t_note_string = '';
|
|
|
4c79b5 |
if ( 1 == $v_announcement ) {
|
|
|
4c79b5 |
array_push( $t_notes, lang_get( 'announcement' ) );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
if ( VS_PRIVATE == $v_view_state ) {
|
|
|
4c79b5 |
array_push( $t_notes, lang_get( 'private' ) );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
if ( sizeof( $t_notes ) > 0 ) {
|
|
|
4c79b5 |
$t_note_string = ' ['.implode( ' ', $t_notes ).']';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
PRINT "<option value=\"$v_id\">$v_headline$t_note_string</option>";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
#---------------
|
|
|
4c79b5 |
# Constructs the string for one news entry given the row retrieved from the news table.
|
|
|
4c79b5 |
function print_news_entry( $p_headline, $p_body, $p_poster_id, $p_view_state, $p_announcement, $p_date_posted ) {
|
|
|
4c79b5 |
$t_headline = string_display_links( $p_headline );
|
|
|
4c79b5 |
$t_body = string_display_links( $p_body );
|
|
|
4c79b5 |
$t_date_posted = date( config_get( 'normal_date_format' ), $p_date_posted );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( VS_PRIVATE == $p_view_state ) {
|
|
|
4c79b5 |
$t_news_css = 'news-heading-private';
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
$t_news_css = 'news-heading-public';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$output .= '' . $t_headline . '';
|
|
|
4c79b5 |
$output .= '';
|
|
|
4c79b5 |
$output .= '';
|
|
|
4c79b5 |
$output .= $t_date_posted . ' - ';
|
|
|
4c79b5 |
echo $output;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# @@@ eventually we should replace print's with methods to construct the
|
|
|
4c79b5 |
# strings.
|
|
|
4c79b5 |
print_user( $p_poster_id );
|
|
|
4c79b5 |
$output = '';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( 1 == $p_announcement ) {
|
|
|
4c79b5 |
$output .= ' - [' . lang_get( 'announcement' ) . ']';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
if ( VS_PRIVATE == $p_view_state ) {
|
|
|
4c79b5 |
$output .= ' - [' . lang_get( 'private' ) . ']';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$output .= '';
|
|
|
4c79b5 |
$output .= '' . $t_body . ' ';
|
|
|
4c79b5 |
$output .= '';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
echo $output;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# print a news item given a row in the news table.
|
|
|
4c79b5 |
function print_news_entry_from_row( $p_news_row ) {
|
|
|
4c79b5 |
extract( $p_news_row, EXTR_PREFIX_ALL, 'v' );
|
|
|
4c79b5 |
print_news_entry( $v_headline, $v_body, $v_poster_id, $v_view_state, $v_announcement, $v_date_posted );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# print a news item
|
|
|
4c79b5 |
function print_news_string_by_news_id( $p_news_id ) {
|
|
|
4c79b5 |
$row = news_get_row( $p_news_id );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# only show VS_PRIVATE posts to configured threshold and above
|
|
|
4c79b5 |
if ( ( VS_PRIVATE == $row['view_state'] ) &&
|
|
|
4c79b5 |
!access_has_project_level( config_get( 'private_news_threshold' ) ) ) {
|
|
|
4c79b5 |
return;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
print_news_entry_from_row( $row );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# Used for update pages
|
|
|
4c79b5 |
function print_field_option_list( $p_list, $p_item='' ) {
|
|
|
4c79b5 |
$t_mantis_bug_table = config_get( 'mantis_bug_table' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_category_string = get_enum_string( $t_mantis_bug_table, $p_list );
|
|
|
4c79b5 |
$t_arr = explode_enum_string( $t_category_string );
|
|
|
4c79b5 |
$entry_count = count( $t_arr );
|
|
|
4c79b5 |
for ($i=0;$i<$entry_count;$i++) {
|
|
|
4c79b5 |
$t_s = str_replace( '\'', '', $t_arr[$i] );
|
|
|
4c79b5 |
PRINT "
|
|
|
4c79b5 |
check_selected( $p_item, $t_s );
|
|
|
4c79b5 |
PRINT ">$t_s</option>";
|
|
|
4c79b5 |
} # end for
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
function print_assign_to_option_list( $p_user_id='', $p_project_id = null, $p_threshold = null ) {
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( null === $p_threshold ) {
|
|
|
4c79b5 |
$p_threshold = config_get( 'handle_bug_threshold' );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
print_user_option_list( $p_user_id, $p_project_id, $p_threshold );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# List projects that the current user has access to
|
|
|
4c79b5 |
function print_project_option_list( $p_project_id = null, $p_include_all_projects = true, $p_filter_project_id = null, $p_trace = false ) {
|
|
|
4c79b5 |
project_cache_all();
|
|
|
4c79b5 |
$t_project_ids = current_user_get_accessible_projects();
|
|
|
4c79b5 |
if ( $p_include_all_projects ) {
|
|
|
4c79b5 |
PRINT '
|
|
|
4c79b5 |
check_selected( $p_project_id, ALL_PROJECTS );
|
|
|
4c79b5 |
PRINT '>' . lang_get( 'all_projects' ) . '</option>' . "\n";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_project_count = count( $t_project_ids );
|
|
|
4c79b5 |
for ($i=0;$i<$t_project_count;$i++) {
|
|
|
4c79b5 |
$t_id = $t_project_ids[$i];
|
|
|
4c79b5 |
if ( $t_id != $p_filter_project_id ) {
|
|
|
4c79b5 |
PRINT "
|
|
|
4c79b5 |
check_selected( $p_project_id, $t_id );
|
|
|
4c79b5 |
PRINT '>' . string_display( project_get_field( $t_id, 'name' ) ) . '</option>' . "\n";
|
|
|
4c79b5 |
print_subproject_option_list( $t_id, $p_project_id, $p_filter_project_id, $p_trace );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# List projects that the current user has access to
|
|
|
4c79b5 |
function print_subproject_option_list( $p_parent_id, $p_project_id = null, $p_filter_project_id = null, $p_trace = false, $p_parents = Array() ) {
|
|
|
4c79b5 |
array_push( $p_parents, $p_parent_id );
|
|
|
4c79b5 |
$t_project_ids = current_user_get_accessible_subprojects( $p_parent_id );
|
|
|
4c79b5 |
$t_project_count = count( $t_project_ids );
|
|
|
4c79b5 |
for ($i=0;$i<$t_project_count;$i++) {
|
|
|
4c79b5 |
$t_full_id = $t_id = $t_project_ids[$i];
|
|
|
4c79b5 |
if ( $t_id != $p_filter_project_id ) {
|
|
|
4c79b5 |
PRINT "
|
|
|
4c79b5 |
if ( $p_trace ) {
|
|
|
4c79b5 |
$t_full_id = join( $p_parents, ";") . ';' . $t_id;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
PRINT "$t_full_id\"";
|
|
|
4c79b5 |
check_selected( $p_project_id, $t_full_id );
|
|
|
4c79b5 |
PRINT '>' . str_repeat( ' ', count( $p_parents ) ) . str_repeat( '»', count( $p_parents ) ) . ' ' . string_display( project_get_field( $t_id, 'name' ) ) . '</option>' . "\n";
|
|
|
4c79b5 |
print_subproject_option_list( $t_id, $p_project_id, $p_filter_project_id, $p_trace, $p_parents );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# Print extended project browser
|
|
|
4c79b5 |
function print_extended_project_browser( $p_trace=Array() ) {
|
|
|
4c79b5 |
project_cache_all();
|
|
|
4c79b5 |
$t_project_ids = current_user_get_accessible_projects();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
echo '<script type="text/javascript" language="JavaScript">' . "\n";
|
|
|
4c79b5 |
echo "
|
|
|
4c79b5 |
echo "var subprojects = new Object();\n";
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_projects = Array();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_project_count = count( $t_project_ids );
|
|
|
4c79b5 |
for ($i=0;$i<$t_project_count;$i++) {
|
|
|
4c79b5 |
$t_id = $t_project_ids[$i];
|
|
|
4c79b5 |
echo 'subprojects[\'' . $t_id . '\'] = new Object();' . "\n";
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_name = project_get_field( $t_id, 'name' );
|
|
|
4c79b5 |
$c_name = addslashes( $t_name );
|
|
|
4c79b5 |
echo 'subprojects[\'' . $t_id . '\'][\'' . $t_id . '\'] = \'' . $c_name . '\';' . "\n";
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_projects[$t_id] = $t_name;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
print_extended_project_browser_subproject_javascript( $t_id );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
echo "\n";
|
|
|
4c79b5 |
echo 'function setProject(projectVal) {' . "\n";
|
|
|
4c79b5 |
echo "\t" . 'var spInput = document.form_set_project.project_id;' . "\n";
|
|
|
4c79b5 |
echo "\t" . 'spInput.options.length = 0' . "\n";
|
|
|
4c79b5 |
echo "\t" . 'if (projectVal == "' . ALL_PROJECTS . '") {' . "\n";
|
|
|
4c79b5 |
echo "\t\t" . 'spInput.options[0] = new Option(\'--- All Projects ---\', \'' . ALL_PROJECTS . '\');' . "\n";
|
|
|
4c79b5 |
echo "\t" . '} else {' . "\n";
|
|
|
4c79b5 |
echo "\t\t" . 'var i = 0;' . "\n";
|
|
|
4c79b5 |
echo "\t\t" . 'var project = subprojects[ projectVal ];' . "\n";
|
|
|
4c79b5 |
echo "\t\t" . 'for ( var sp in project ) {' . "\n";
|
|
|
4c79b5 |
echo "\t\t\t" . 'spInput.options[ i++ ] = new Option( project[sp], sp );' . "\n";
|
|
|
4c79b5 |
echo "\t\t" . '}' . "\n";
|
|
|
4c79b5 |
echo "\t" . '}' . "\n";
|
|
|
4c79b5 |
echo '}' . "\n";
|
|
|
4c79b5 |
|
|
|
4c79b5 |
echo '// --></script>' . "\n";
|
|
|
4c79b5 |
echo '<select name="top_id" onChange="setProject(this.value); document.form_set_project.submit()" class="small">' . "\n";
|
|
|
4c79b5 |
echo '
|
|
|
4c79b5 |
echo check_selected( $p_project_id, ALL_PROJECTS );
|
|
|
4c79b5 |
echo '>' . lang_get('all_projects') . '</option>' . "\n";
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ( $t_projects as $t_id => $t_name ) {
|
|
|
4c79b5 |
$c_name = string_display( $t_name );
|
|
|
4c79b5 |
echo '
|
|
|
4c79b5 |
echo check_selected( $p_project_id, $t_id );
|
|
|
4c79b5 |
echo '>' . $c_name . '</option>' . "\n";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
echo '</select>' . "\n";
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( 0 === count( $p_trace ) ) {
|
|
|
4c79b5 |
$t_top_id = ALL_PROJECTS;
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
$t_top_id = $p_trace[0];
|
|
|
4c79b5 |
$t_trace_str = join( ';', $p_trace );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
echo '<select name="project_id" onChange="document.form_set_project.submit()" class="small-subprojects"></select>' . "\n";
|
|
|
4c79b5 |
echo '<script type="text/javascript" language="JavaScript">' . "\n";
|
|
|
4c79b5 |
echo '
|
|
|
4c79b5 |
echo 'document.form_set_project.top_id.value = \'' . $t_top_id . '\';'. "\n";
|
|
|
4c79b5 |
echo 'setProject(' . $t_top_id . ');' . "\n";
|
|
|
4c79b5 |
echo 'document.form_set_project.project_id.value = \'' . $t_trace_str . '\';' . "\n";
|
|
|
4c79b5 |
echo '// --></script>' . "\n";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# print the subproject javascript for the extended project browser
|
|
|
4c79b5 |
function print_extended_project_browser_subproject_javascript( $p_trace ) {
|
|
|
4c79b5 |
$t_trace_projects = split( ';', $p_trace);
|
|
|
4c79b5 |
$t_top_id = $t_trace_projects[0];
|
|
|
4c79b5 |
$t_level = count( $t_trace_projects );
|
|
|
4c79b5 |
$t_parent_id = $t_trace_projects[ $t_level - 1 ];
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_project_ids = current_user_get_accessible_subprojects( $t_parent_id );
|
|
|
4c79b5 |
$t_project_count = count( $t_project_ids );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
for ($i=0;$i<$t_project_count;$i++) {
|
|
|
4c79b5 |
$t_id = $t_project_ids[$i];
|
|
|
4c79b5 |
$t_nbsp = chr( 160 );
|
|
|
4c79b5 |
$t_name = addslashes( str_repeat( $t_nbsp , $t_level ) . str_repeat( '»', $t_level ) . ' ' . project_get_field( $t_id, 'name' ) );
|
|
|
4c79b5 |
echo 'subprojects[\'' . $t_top_id . '\'][\'' . $p_trace . ';' . $t_id . '\'] = \'' . $t_name . '\';' . "\n";
|
|
|
4c79b5 |
|
|
|
4c79b5 |
print_extended_project_browser_subproject_javascript( $p_trace . ';' . $t_id );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# prints the profiles given the user id
|
|
|
4c79b5 |
function print_profile_option_list( $p_user_id, $p_select_id='', $p_profiles = null ) {
|
|
|
4c79b5 |
if ( '' === $p_select_id ) {
|
|
|
4c79b5 |
$p_select_id = profile_get_default( $p_user_id );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
if ( $p_profiles != null ) {
|
|
|
4c79b5 |
$t_profiles = $p_profiles;
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
$t_profiles = profile_get_all_for_user( $p_user_id );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
print_profile_option_list_from_profiles( $t_profiles, $p_select_id );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# prints the profiles used in a certain project
|
|
|
4c79b5 |
function print_profile_option_list_for_project( $p_project_id, $p_select_id='', $p_profiles = null) {
|
|
|
4c79b5 |
if ( '' === $p_select_id ) {
|
|
|
4c79b5 |
$p_select_id = profile_get_default( $p_user_id );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
if ( $p_profiles != null ) {
|
|
|
4c79b5 |
$t_profiles = $p_profiles;
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
$t_profiles = profile_get_all_for_project( $p_project_id );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
print_profile_option_list_from_profiles( $t_profiles, $p_select_id );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# print the profile option list from profiles array
|
|
|
4c79b5 |
function print_profile_option_list_from_profiles ( $p_profiles, $p_select_id) {
|
|
|
4c79b5 |
echo '<option value=""></option>';
|
|
|
4c79b5 |
foreach ( $p_profiles as $t_profile ) {
|
|
|
4c79b5 |
extract( $t_profile, EXTR_PREFIX_ALL, 'v' );
|
|
|
4c79b5 |
$v_platform = string_display( $v_platform );
|
|
|
4c79b5 |
$v_os = string_display( $v_os );
|
|
|
4c79b5 |
$v_os_build = string_display( $v_os_build );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
echo '
|
|
|
4c79b5 |
check_selected( $p_select_id, $v_id );
|
|
|
4c79b5 |
echo '>' . $v_platform . ' ' . $v_os . ' ' . $v_os_build . '</option>';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
function print_news_project_option_list( $p_project_id ) {
|
|
|
4c79b5 |
$t_mantis_project_table = config_get( 'mantis_project_table' );
|
|
|
4c79b5 |
$t_mantis_project_user_list_table = config_get( 'mantis_project_user_list_table' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( access_has_project_level( ADMINISTRATOR ) ) {
|
|
|
4c79b5 |
$query = "SELECT *
|
|
|
4c79b5 |
FROM $t_mantis_project_table
|
|
|
4c79b5 |
ORDER BY name";
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
$t_user_id = auth_get_current_user_id();
|
|
|
4c79b5 |
$query = "SELECT p.id, p.name
|
|
|
4c79b5 |
FROM $t_mantis_project_table p, $t_mantis_project_user_list_table m
|
|
|
4c79b5 |
WHERE p.id=m.project_id AND
|
|
|
4c79b5 |
m.user_id='$t_user_id' AND
|
|
|
4c79b5 |
p.enabled='1'";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$result = db_query( $query );
|
|
|
4c79b5 |
$project_count = db_num_rows( $result );
|
|
|
4c79b5 |
for ($i=0;$i<$project_count;$i++) {
|
|
|
4c79b5 |
$row = db_fetch_array( $result );
|
|
|
4c79b5 |
extract( $row, EXTR_PREFIX_ALL, 'v' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
PRINT "
|
|
|
4c79b5 |
check_selected( $v_id, $p_project_id );
|
|
|
4c79b5 |
PRINT ">$v_name</option>";
|
|
|
4c79b5 |
} # end for
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# Since categories can be orphaned we need to grab all unique instances of category
|
|
|
4c79b5 |
# We check in the project category table and in the bug table
|
|
|
4c79b5 |
# We put them all in one array and make sure the entries are unique
|
|
|
4c79b5 |
function print_category_option_list( $p_category='', $p_project_id = null ) {
|
|
|
4c79b5 |
$t_mantis_project_category_table = config_get( 'mantis_project_category_table' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( null === $p_project_id ) {
|
|
|
4c79b5 |
$c_project_id = helper_get_current_project();
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
$c_project_id = db_prepare_int( $p_project_id );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_project_where = helper_project_specific_where( $c_project_id );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# grab all categories in the project category table
|
|
|
4c79b5 |
$cat_arr = array();
|
|
|
4c79b5 |
$query = "SELECT DISTINCT category
|
|
|
4c79b5 |
FROM $t_mantis_project_category_table
|
|
|
4c79b5 |
WHERE $t_project_where
|
|
|
4c79b5 |
ORDER BY category";
|
|
|
4c79b5 |
$result = db_query( $query );
|
|
|
4c79b5 |
$category_count = db_num_rows( $result );
|
|
|
4c79b5 |
for ($i=0;$i<$category_count;$i++) {
|
|
|
4c79b5 |
$row = db_fetch_array( $result );
|
|
|
4c79b5 |
$cat_arr[] = string_attribute( $row['category'] );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Add the default option if not in the list retrieved from DB
|
|
|
4c79b5 |
# This is useful for default categories and when updating an
|
|
|
4c79b5 |
# issue with a deleted category.
|
|
|
4c79b5 |
if ( !is_blank( $p_category ) && !in_array( $p_category, $cat_arr ) ) {
|
|
|
4c79b5 |
$cat_arr[] = $p_category;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
sort( $cat_arr );
|
|
|
4c79b5 |
$cat_arr = array_unique( $cat_arr );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach( $cat_arr as $t_category ) {
|
|
|
4c79b5 |
PRINT "
|
|
|
4c79b5 |
check_selected( $t_category, $p_category );
|
|
|
4c79b5 |
PRINT ">$t_category</option>";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# Since categories can be orphaned we need to grab all unique instances of category
|
|
|
4c79b5 |
# We check in the project category table and in the bug table
|
|
|
4c79b5 |
# We put them all in one array and make sure the entries are unique
|
|
|
4c79b5 |
function print_category_complete_option_list( $p_category='', $p_project_id = null ) {
|
|
|
4c79b5 |
$t_mantis_project_category_table = config_get( 'mantis_project_category_table' );
|
|
|
4c79b5 |
$t_mantis_bug_table = config_get( 'mantis_bug_table' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( null === $p_project_id ) {
|
|
|
4c79b5 |
$t_project_id = helper_get_current_project();
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
$t_project_id = $p_project_id;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_project_where = helper_project_specific_where( $t_project_id );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# grab all categories in the project category table
|
|
|
4c79b5 |
$cat_arr = array();
|
|
|
4c79b5 |
$query = "SELECT DISTINCT category
|
|
|
4c79b5 |
FROM $t_mantis_project_category_table
|
|
|
4c79b5 |
WHERE $t_project_where
|
|
|
4c79b5 |
ORDER BY category";
|
|
|
4c79b5 |
$result = db_query( $query );
|
|
|
4c79b5 |
$category_count = db_num_rows( $result );
|
|
|
4c79b5 |
for ($i=0;$i<$category_count;$i++) {
|
|
|
4c79b5 |
$row = db_fetch_array( $result );
|
|
|
4c79b5 |
$cat_arr[] = string_attribute( $row['category'] );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# grab all categories in the bug table
|
|
|
4c79b5 |
$query = "SELECT DISTINCT category
|
|
|
4c79b5 |
FROM $t_mantis_bug_table
|
|
|
4c79b5 |
WHERE $t_project_where
|
|
|
4c79b5 |
ORDER BY category";
|
|
|
4c79b5 |
$result = db_query( $query );
|
|
|
4c79b5 |
$category_count = db_num_rows( $result );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
for ($i=0;$i<$category_count;$i++) {
|
|
|
4c79b5 |
$row = db_fetch_array( $result );
|
|
|
4c79b5 |
$cat_arr[] = string_attribute( $row['category'] );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
sort( $cat_arr );
|
|
|
4c79b5 |
$cat_arr = array_unique( $cat_arr );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach( $cat_arr as $t_category ) {
|
|
|
4c79b5 |
PRINT "
|
|
|
4c79b5 |
check_selected( $p_category, $t_category );
|
|
|
4c79b5 |
PRINT ">$t_category</option>";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# Print the option list for platforms accessible for the specified user.
|
|
|
4c79b5 |
function print_platform_option_list( $p_platform, $p_user_id = null ) {
|
|
|
4c79b5 |
$t_platforms_array = profile_get_field_all_for_user( 'platform', $p_user_id );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ( $t_platforms_array as $t_platform ) {
|
|
|
4c79b5 |
echo "
|
|
|
4c79b5 |
check_selected( $p_platform, $t_platform );
|
|
|
4c79b5 |
echo ">$t_platform</option>";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# Print the option list for OSes accessible for the specified user.
|
|
|
4c79b5 |
function print_os_option_list( $p_os, $p_user_id = null ) {
|
|
|
4c79b5 |
$t_os_array = profile_get_field_all_for_user( 'os', $p_user_id );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ( $t_os_array as $t_os ) {
|
|
|
4c79b5 |
echo "
|
|
|
4c79b5 |
check_selected( $p_os, $t_os );
|
|
|
4c79b5 |
echo ">$t_os</option>";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# Print the option list for os_build accessible for the specified user.
|
|
|
4c79b5 |
function print_os_build_option_list( $p_os_build, $p_user_id = null ) {
|
|
|
4c79b5 |
$t_os_build_array = profile_get_field_all_for_user( 'os_build', $p_user_id );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ( $t_os_build_array as $t_os_build ) {
|
|
|
4c79b5 |
echo "
|
|
|
4c79b5 |
check_selected( $p_os_build, $t_os_build );
|
|
|
4c79b5 |
echo ">$t_os_build</option>";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# Print the option list for versions
|
|
|
4c79b5 |
# $p_version = currently selected version.
|
|
|
4c79b5 |
# $p_project_id = project id, otherwise current project will be used.
|
|
|
4c79b5 |
# $p_released = null to get all, 1: only released, 0: only future versions
|
|
|
4c79b5 |
# $p_leading_black = allow selection of no version
|
|
|
4c79b5 |
# $p_with_subs = include subprojects
|
|
|
4c79b5 |
function print_version_option_list( $p_version='', $p_project_id = null, $p_released = null, $p_leading_blank = true, $p_with_subs=false ) {
|
|
|
4c79b5 |
if ( null === $p_project_id ) {
|
|
|
4c79b5 |
$c_project_id = helper_get_current_project();
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
$c_project_id = db_prepare_int( $p_project_id );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( $p_with_subs ) {
|
|
|
4c79b5 |
$versions = version_get_all_rows_with_subs( $c_project_id, $p_released );
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
$versions = version_get_all_rows( $c_project_id, $p_released );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( $p_leading_blank ) {
|
|
|
4c79b5 |
echo '<option value=""></option>';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach( $versions as $version ) {
|
|
|
4c79b5 |
$t_version = string_attribute( $version['version'] );
|
|
|
4c79b5 |
echo "
|
|
|
4c79b5 |
check_selected( $p_version, $t_version );
|
|
|
4c79b5 |
echo '>', string_shorten( $t_version ), '</option>';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
function print_build_option_list( $p_build='' ) {
|
|
|
4c79b5 |
$t_bug_table = config_get( 'mantis_bug_table' );
|
|
|
4c79b5 |
$t_overall_build_arr = array();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_project_id = helper_get_current_project();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_project_where = helper_project_specific_where( $t_project_id );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Get the "found in" build list
|
|
|
4c79b5 |
$query = "SELECT DISTINCT build
|
|
|
4c79b5 |
FROM $t_bug_table
|
|
|
4c79b5 |
WHERE $t_project_where
|
|
|
4c79b5 |
ORDER BY build DESC";
|
|
|
4c79b5 |
$result = db_query( $query );
|
|
|
4c79b5 |
$option_count = db_num_rows( $result );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
for ( $i = 0; $i < $option_count; $i++ ) {
|
|
|
4c79b5 |
$row = db_fetch_array( $result );
|
|
|
4c79b5 |
$t_overall_build_arr[] = $row['build'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach( $t_overall_build_arr as $t_build ) {
|
|
|
4c79b5 |
PRINT "
|
|
|
4c79b5 |
check_selected( $p_build, $t_build );
|
|
|
4c79b5 |
PRINT ">" . string_shorten( $t_build ) . "</option>";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# select the proper enum values based on the input parameter
|
|
|
4c79b5 |
# $p_enum_name - name of enumeration (eg: status)
|
|
|
4c79b5 |
# $p_val: current value
|
|
|
4c79b5 |
function print_enum_string_option_list( $p_enum_name, $p_val = 0 ) {
|
|
|
4c79b5 |
$t_config_var_name = $p_enum_name.'_enum_string';
|
|
|
4c79b5 |
$t_config_var_value = config_get( $t_config_var_name );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_arr = explode_enum_string( $t_config_var_value );
|
|
|
4c79b5 |
$t_enum_count = count( $t_arr );
|
|
|
4c79b5 |
for ( $i = 0; $i < $t_enum_count; $i++) {
|
|
|
4c79b5 |
$t_elem = explode_enum_arr( $t_arr[$i] );
|
|
|
4c79b5 |
$t_key = trim( $t_elem[0] );
|
|
|
4c79b5 |
$t_elem2 = get_enum_element( $p_enum_name, $t_key );
|
|
|
4c79b5 |
echo "
|
|
|
4c79b5 |
check_selected( $p_val, $t_key );
|
|
|
4c79b5 |
echo ">$t_elem2</option>";
|
|
|
4c79b5 |
} # end for
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# Select the proper enum values for status based on workflow
|
|
|
4c79b5 |
# or the input parameter if workflows are not used
|
|
|
4c79b5 |
# $p_enum_name : name of enumeration (eg: status)
|
|
|
4c79b5 |
# $p_current_value : current value
|
|
|
4c79b5 |
function get_status_option_list( $p_user_auth = 0, $p_current_value = 0, $p_show_current = true, $p_add_close = false ) {
|
|
|
4c79b5 |
$t_config_var_value = config_get( 'status_enum_string' );
|
|
|
4c79b5 |
$t_enum_workflow = config_get( 'status_enum_workflow' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( count( $t_enum_workflow ) < 1 ) {
|
|
|
4c79b5 |
# workflow not defined, use default enum
|
|
|
4c79b5 |
$t_arr = explode_enum_string( $t_config_var_value );
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
# workflow defined - find allowed states
|
|
|
4c79b5 |
if ( isset( $t_enum_workflow[$p_current_value] ) ) {
|
|
|
4c79b5 |
$t_arr = explode_enum_string( $t_enum_workflow[$p_current_value] );
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
# workflow was not set for this status, this shouldn't happen
|
|
|
4c79b5 |
$t_arr = explode_enum_string( $t_config_var_value );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_enum_count = count( $t_arr );
|
|
|
4c79b5 |
$t_enum_list = array();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
for ( $i = 0; $i < $t_enum_count; $i++ ) {
|
|
|
4c79b5 |
$t_elem = explode_enum_arr( $t_arr[$i] );
|
|
|
4c79b5 |
if ( ( $p_user_auth >= access_get_status_threshold( $t_elem[0] ) ) &&
|
|
|
4c79b5 |
( ! ( ( false == $p_show_current ) && ( $p_current_value == $t_elem[0] ) ) ) ) {
|
|
|
4c79b5 |
$t_enum_list[$t_elem[0]] = get_enum_element( 'status', $t_elem[0] );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
} # end for
|
|
|
4c79b5 |
if ( true == $p_show_current ) {
|
|
|
4c79b5 |
$t_enum_list[$p_current_value] = get_enum_element( 'status', $p_current_value );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
if ( ( true == $p_add_close ) && ( $p_current_value >= config_get( 'bug_resolved_status_threshold' ) ) ) {
|
|
|
4c79b5 |
$t_enum_list[CLOSED] = get_enum_element( 'status', CLOSED );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
return $t_enum_list;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# print the status option list for the bug_update pages
|
|
|
4c79b5 |
function print_status_option_list( $p_select_label, $p_current_value = 0, $p_allow_close = false, $p_project_id = null ) {
|
|
|
4c79b5 |
$t_current_auth = access_get_project_level( $p_project_id );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_enum_list = get_status_option_list( $t_current_auth, $p_current_value, true, $p_allow_close );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( count( $t_enum_list ) > 0 ) {
|
|
|
4c79b5 |
# resort the list into ascending order
|
|
|
4c79b5 |
ksort( $t_enum_list );
|
|
|
4c79b5 |
reset( $t_enum_list );
|
|
|
4c79b5 |
echo '<select ', helper_get_tab_index(), ' name="' . $p_select_label . '">';
|
|
|
4c79b5 |
foreach ( $t_enum_list as $key => $val ) {
|
|
|
4c79b5 |
echo "
|
|
|
4c79b5 |
check_selected( $key, $p_current_value );
|
|
|
4c79b5 |
echo ">$val</option>";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
echo '</select>';
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
echo get_enum_to_string( 'status_enum_string', $p_current_value );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# prints the list of a project's users
|
|
|
4c79b5 |
# if no project is specified uses the current project
|
|
|
4c79b5 |
function print_project_user_option_list( $p_project_id=null ) {
|
|
|
4c79b5 |
print_user_option_list( 0, $p_project_id );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# prints the list of access levels that are less than or equal to the access level of the
|
|
|
4c79b5 |
# logged in user. This is used when adding users to projects
|
|
|
4c79b5 |
function print_project_access_levels_option_list( $p_val, $p_project_id = null ) {
|
|
|
4c79b5 |
$t_current_user_access_level = access_get_project_level( $p_project_id );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_access_levels_enum_string = config_get( 'access_levels_enum_string' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Add [default access level] to add the user to a project
|
|
|
4c79b5 |
# with his default access level.
|
|
|
4c79b5 |
PRINT "
|
|
|
4c79b5 |
PRINT ">[" . lang_get( 'default_access_level' ) . "]</option>";
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_arr = explode_enum_string( $t_access_levels_enum_string );
|
|
|
4c79b5 |
$enum_count = count( $t_arr );
|
|
|
4c79b5 |
for ($i=0;$i<$enum_count;$i++) {
|
|
|
4c79b5 |
$t_elem = explode_enum_arr( $t_arr[$i] );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# a user must not be able to assign another user an access level that is higher than theirs.
|
|
|
4c79b5 |
if ( $t_elem[0] > $t_current_user_access_level ) {
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_access_level = get_enum_element( 'access_levels', $t_elem[0] );
|
|
|
4c79b5 |
PRINT "
|
|
|
4c79b5 |
check_selected( $p_val, $t_elem[0] );
|
|
|
4c79b5 |
PRINT ">$t_access_level</option>";
|
|
|
4c79b5 |
} # end for
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
function print_language_option_list( $p_language ) {
|
|
|
4c79b5 |
$t_arr = config_get( 'language_choices_arr' );
|
|
|
4c79b5 |
$enum_count = count( $t_arr );
|
|
|
4c79b5 |
for ($i=0;$i<$enum_count;$i++) {
|
|
|
4c79b5 |
$t_language = string_attribute( $t_arr[$i] );
|
|
|
4c79b5 |
PRINT "
|
|
|
4c79b5 |
check_selected( $t_language, $p_language );
|
|
|
4c79b5 |
PRINT ">$t_language</option>";
|
|
|
4c79b5 |
} # end for
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# @@@ preliminary support for multiple bug actions.
|
|
|
4c79b5 |
function print_all_bug_action_option_list() {
|
|
|
4c79b5 |
$commands = array( 'MOVE' => lang_get('actiongroup_menu_move'),
|
|
|
4c79b5 |
'COPY' => lang_get('actiongroup_menu_copy'),
|
|
|
4c79b5 |
'ASSIGN' => lang_get('actiongroup_menu_assign'),
|
|
|
4c79b5 |
'CLOSE' => lang_get('actiongroup_menu_close'),
|
|
|
4c79b5 |
'DELETE' => lang_get('actiongroup_menu_delete'),
|
|
|
4c79b5 |
'RESOLVE' => lang_get('actiongroup_menu_resolve'),
|
|
|
4c79b5 |
'SET_STICKY' => lang_get( 'actiongroup_menu_set_sticky' ),
|
|
|
4c79b5 |
'UP_PRIOR' => lang_get('actiongroup_menu_update_priority'),
|
|
|
4c79b5 |
'UP_STATUS' => lang_get('actiongroup_menu_update_status'),
|
|
|
4c79b5 |
'UP_CATEGORY' => lang_get('actiongroup_menu_update_category'),
|
|
|
4c79b5 |
'VIEW_STATUS' => lang_get( 'actiongroup_menu_update_view_status' ),
|
|
|
4c79b5 |
'EXT_ADD_NOTE' => lang_get( 'actiongroup_menu_add_note' ),
|
|
|
4c79b5 |
'EXT_ATTACH_TAGS' => lang_get( 'actiongroup_menu_attach_tags' ),
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_project_id = helper_get_current_project();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( ALL_PROJECTS != $t_project_id ) {
|
|
|
4c79b5 |
$t_user_id = auth_get_current_user_id();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( access_has_project_level( config_get( 'update_bug_threshold' ), $t_project_id ) ) {
|
|
|
4c79b5 |
$commands['UP_FIXED_IN_VERSION'] = lang_get( 'actiongroup_menu_update_fixed_in_version' );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( access_has_project_level( config_get( 'roadmap_update_threshold' ), $t_project_id ) ) {
|
|
|
4c79b5 |
$commands['UP_TARGET_VERSION'] = lang_get( 'actiongroup_menu_update_target_version' );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_custom_field_ids = custom_field_get_linked_ids( $t_project_id );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach( $t_custom_field_ids as $t_custom_field_id ) {
|
|
|
4c79b5 |
# if user has not access right to modify the field, then there is no
|
|
|
4c79b5 |
# point in showing it.
|
|
|
4c79b5 |
if ( !custom_field_has_write_access_to_project( $t_custom_field_id, $t_project_id, $t_user_id ) ) {
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_custom_field_def = custom_field_get_definition( $t_custom_field_id );
|
|
|
4c79b5 |
$t_command_id = 'custom_field_' . $t_custom_field_id;
|
|
|
4c79b5 |
$t_command_caption = sprintf( lang_get( 'actiongroup_menu_update_field' ), lang_get_defaulted( $t_custom_field_def['name'] ) );
|
|
|
4c79b5 |
$commands[$t_command_id] = string_display( $t_command_caption );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_custom_group_actions = config_get( 'custom_group_actions' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach( $t_custom_group_actions as $t_custom_group_action ) {
|
|
|
4c79b5 |
# use label if provided to get the localized text, otherwise fallback to action name.
|
|
|
4c79b5 |
if ( isset( $t_custom_group_action['label'] ) ) {
|
|
|
4c79b5 |
$commands[$t_custom_group_action['action']] = lang_get_defaulted( $t_custom_group_action['label'] );
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
$commands[$t_custom_group_action['action']] = lang_get_defaulted( $t_custom_group_action['action'] );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
while (list ($key,$val) = each ($commands)) {
|
|
|
4c79b5 |
PRINT "<option value=\"".$key."\">".$val."</option>";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# list of users that are NOT in the specified project and that are enabled
|
|
|
4c79b5 |
# if no project is specified use the current project
|
|
|
4c79b5 |
# also exclude any administrators
|
|
|
4c79b5 |
function print_project_user_list_option_list( $p_project_id=null ) {
|
|
|
4c79b5 |
$t_mantis_project_user_list_table = config_get( 'mantis_project_user_list_table' );
|
|
|
4c79b5 |
$t_mantis_user_table = config_get( 'mantis_user_table' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( null === $p_project_id ) {
|
|
|
4c79b5 |
$p_project_id = helper_get_current_project();
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$c_project_id = (int)$p_project_id;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_adm = ADMINISTRATOR;
|
|
|
4c79b5 |
$query = "SELECT DISTINCT u.id, u.username, u.realname
|
|
|
4c79b5 |
FROM $t_mantis_user_table u
|
|
|
4c79b5 |
LEFT JOIN $t_mantis_project_user_list_table p
|
|
|
4c79b5 |
ON p.user_id=u.id AND p.project_id='$c_project_id'
|
|
|
4c79b5 |
WHERE u.access_level<$t_adm AND
|
|
|
4c79b5 |
u.enabled = 1 AND
|
|
|
4c79b5 |
p.user_id IS NULL
|
|
|
4c79b5 |
ORDER BY u.realname, u.username";
|
|
|
4c79b5 |
$result = db_query( $query );
|
|
|
4c79b5 |
$t_display = array();
|
|
|
4c79b5 |
$t_sort = array();
|
|
|
4c79b5 |
$t_users = array();
|
|
|
4c79b5 |
$t_show_realname = ( ON == config_get( 'show_realname' ) );
|
|
|
4c79b5 |
$t_sort_by_last_name = ( ON == config_get( 'sort_by_last_name' ) );
|
|
|
4c79b5 |
$category_count = db_num_rows( $result );
|
|
|
4c79b5 |
for ($i=0;$i<$category_count;$i++) {
|
|
|
4c79b5 |
$row = db_fetch_array( $result );
|
|
|
4c79b5 |
$t_users[] = $row['id'];
|
|
|
4c79b5 |
$t_user_name = string_attribute( $row['username'] );
|
|
|
4c79b5 |
$t_sort_name = $t_user_name;
|
|
|
4c79b5 |
if ( ( isset( $row['realname'] ) ) && ( $row['realname'] <> "" ) && $t_show_realname ) {
|
|
|
4c79b5 |
$t_user_name = string_attribute( $row['realname'] );
|
|
|
4c79b5 |
if ( $t_sort_by_last_name ) {
|
|
|
4c79b5 |
$t_sort_name_bits = split( ' ', strtolower( $t_user_name ), 2 );
|
|
|
4c79b5 |
$t_sort_name = ( isset( $t_sort_name_bits[1] ) ? $t_sort_name_bits[1] . ', ' : '' ) . $t_sort_name_bits[0];
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
$t_sort_name = strtolower( $t_user_name );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$t_display[] = $t_user_name;
|
|
|
4c79b5 |
$t_sort[] = $t_sort_name;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
array_multisort( $t_sort, SORT_ASC, SORT_STRING, $t_users, $t_display );
|
|
|
4c79b5 |
for ($i = 0; $i < count( $t_sort ); $i++ ) {
|
|
|
4c79b5 |
PRINT '<option value="' . $t_users[$i] . '">' . $t_display[$i] . '</option>';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# list of projects that a user is NOT in
|
|
|
4c79b5 |
function print_project_user_list_option_list2( $p_user_id ) {
|
|
|
4c79b5 |
$t_mantis_project_user_list_table = config_get( 'mantis_project_user_list_table' );
|
|
|
4c79b5 |
$t_mantis_project_table = config_get( 'mantis_project_table' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$c_user_id = db_prepare_int( $p_user_id );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$query = "SELECT DISTINCT p.id, p.name
|
|
|
4c79b5 |
FROM $t_mantis_project_table p
|
|
|
4c79b5 |
LEFT JOIN $t_mantis_project_user_list_table u
|
|
|
4c79b5 |
ON p.id=u.project_id AND u.user_id='$c_user_id'
|
|
|
4c79b5 |
WHERE p.enabled=1 AND
|
|
|
4c79b5 |
u.user_id IS NULL
|
|
|
4c79b5 |
ORDER BY p.name";
|
|
|
4c79b5 |
$result = db_query( $query );
|
|
|
4c79b5 |
$category_count = db_num_rows( $result );
|
|
|
4c79b5 |
for ($i=0;$i<$category_count;$i++) {
|
|
|
4c79b5 |
$row = db_fetch_array( $result );
|
|
|
4c79b5 |
$t_project_name = string_attribute( $row['name'] );
|
|
|
4c79b5 |
$t_user_id = $row['id'];
|
|
|
4c79b5 |
PRINT "<option value=\"$t_user_id\">$t_project_name</option>";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# list of projects that a user is in
|
|
|
4c79b5 |
function print_project_user_list( $p_user_id, $p_include_remove_link = true ) {
|
|
|
4c79b5 |
$t_mantis_project_user_list_table = config_get( 'mantis_project_user_list_table' );
|
|
|
4c79b5 |
$t_mantis_project_table = config_get( 'mantis_project_table' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$c_user_id = db_prepare_int( $p_user_id );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$query = "SELECT DISTINCT p.id, p.name, p.view_state, u.access_level
|
|
|
4c79b5 |
FROM $t_mantis_project_table p
|
|
|
4c79b5 |
LEFT JOIN $t_mantis_project_user_list_table u
|
|
|
4c79b5 |
ON p.id=u.project_id
|
|
|
4c79b5 |
WHERE p.enabled=1 AND
|
|
|
4c79b5 |
u.user_id='$c_user_id'
|
|
|
4c79b5 |
ORDER BY p.name";
|
|
|
4c79b5 |
$result = db_query( $query );
|
|
|
4c79b5 |
$category_count = db_num_rows( $result );
|
|
|
4c79b5 |
for ($i=0;$i<$category_count;$i++) {
|
|
|
4c79b5 |
$row = db_fetch_array( $result );
|
|
|
4c79b5 |
$t_project_id = $row['id'];
|
|
|
4c79b5 |
$t_project_name = $row['name'];
|
|
|
4c79b5 |
$t_view_state = $row['view_state'];
|
|
|
4c79b5 |
$t_access_level = $row['access_level'];
|
|
|
4c79b5 |
$t_access_level = get_enum_element( 'access_levels', $t_access_level );
|
|
|
4c79b5 |
$t_view_state = get_enum_element( 'project_view_state', $t_view_state );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
echo $t_project_name.' ['.$t_access_level.'] ('.$t_view_state.')';
|
|
|
4c79b5 |
if ( $p_include_remove_link && access_has_project_level( config_get( 'project_user_threshold' ), $t_project_id ) ) {
|
|
|
4c79b5 |
echo ' ['. lang_get( 'remove_link' ).']';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
echo ' ';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# List of projects with which the specified field id is linked.
|
|
|
4c79b5 |
# For every project, the project name is listed and then the list of custom
|
|
|
4c79b5 |
# fields linked in order with their sequence numbers. The specified field
|
|
|
4c79b5 |
# is always highlighted in italics and project names in bold.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# $p_field_id - The field to list the projects associated with.
|
|
|
4c79b5 |
function print_custom_field_projects_list( $p_field_id ) {
|
|
|
4c79b5 |
$c_field_id = (integer)$p_field_id;
|
|
|
4c79b5 |
$t_project_ids = custom_field_get_project_ids( $p_field_id );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_security_token = form_security_param( 'manage_proj_custom_field_remove' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ( $t_project_ids as $t_project_id ) {
|
|
|
4c79b5 |
$t_project_name = project_get_field( $t_project_id, 'name' );
|
|
|
4c79b5 |
$t_sequence = custom_field_get_sequence( $p_field_id, $t_project_id );
|
|
|
4c79b5 |
echo '', $t_project_name, ': ';
|
|
|
4c79b5 |
print_bracket_link( "manage_proj_custom_field_remove.php?field_id=$c_field_id&project_id=$t_project_id&return=custom_field$t_security_token", lang_get( 'remove_link' ) );
|
|
|
4c79b5 |
echo ' - ';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_linked_field_ids = custom_field_get_linked_ids( $t_project_id );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_current_project_fields = array();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_first = true;
|
|
|
4c79b5 |
foreach ( $t_linked_field_ids as $t_current_field_id ) {
|
|
|
4c79b5 |
if ( $t_first ) {
|
|
|
4c79b5 |
$t_first = false;
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
echo ', ';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( $t_current_field_id == $p_field_id ) {
|
|
|
4c79b5 |
echo '';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
echo string_display( custom_field_get_field( $t_current_field_id, 'name' ) );
|
|
|
4c79b5 |
echo ' (', custom_field_get_sequence( $t_current_field_id, $t_project_id ), ')';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( $t_current_field_id == $p_field_id ) {
|
|
|
4c79b5 |
echo '';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
echo '
';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
###########################################################################
|
|
|
4c79b5 |
# String printing API
|
|
|
4c79b5 |
###########################################################################
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# prints a link to VIEW a bug given an ID
|
|
|
4c79b5 |
# account for the user preference and site override
|
|
|
4c79b5 |
function print_bug_link( $p_bug_id, $p_detail_info = true ) {
|
|
|
4c79b5 |
PRINT string_get_bug_view_link( $p_bug_id, null, $p_detail_info );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# prints a link to UPDATE a bug given an ID
|
|
|
4c79b5 |
# account for the user preference and site override
|
|
|
4c79b5 |
function print_bug_update_link( $p_bug_id ) {
|
|
|
4c79b5 |
PRINT string_get_bug_update_link( $p_bug_id );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# formats the priority given the status
|
|
|
4c79b5 |
# shows the priority in BOLD if the bug is NOT closed and is of significant priority
|
|
|
4c79b5 |
function print_formatted_priority_string( $p_status, $p_priority ) {
|
|
|
4c79b5 |
$t_pri_str = get_enum_element( 'priority', $p_priority );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( ( HIGH <= $p_priority ) &&
|
|
|
4c79b5 |
( CLOSED != $p_status ) ) {
|
|
|
4c79b5 |
PRINT "$t_pri_str";
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
PRINT $t_pri_str;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# formats the severity given the status
|
|
|
4c79b5 |
# shows the severity in BOLD if the bug is NOT closed and is of significant severity
|
|
|
4c79b5 |
function print_formatted_severity_string( $p_status, $p_severity ) {
|
|
|
4c79b5 |
$t_sev_str = get_enum_element( 'severity', $p_severity );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( ( MAJOR <= $p_severity ) &&
|
|
|
4c79b5 |
( CLOSED != $p_status ) ) {
|
|
|
4c79b5 |
PRINT "$t_sev_str";
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
PRINT $t_sev_str;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
function print_project_category_string( $p_project_id ) {
|
|
|
4c79b5 |
$t_mantis_project_category_table = config_get( 'mantis_project_category_table' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$c_project_id = db_prepare_int( $p_project_id );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$query = "SELECT category
|
|
|
4c79b5 |
FROM $t_mantis_project_category_table
|
|
|
4c79b5 |
WHERE project_id='$c_project_id'
|
|
|
4c79b5 |
ORDER BY category";
|
|
|
4c79b5 |
$result = db_query( $query );
|
|
|
4c79b5 |
$category_count = db_num_rows( $result );
|
|
|
4c79b5 |
$t_string = '';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
for ($i=0;$i<$category_count;$i++) {
|
|
|
4c79b5 |
$row = db_fetch_array( $result );
|
|
|
4c79b5 |
$t_category = $row['category'];
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( $i+1 < $category_count ) {
|
|
|
4c79b5 |
$t_string .= $t_category.', ';
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
$t_string .= $t_category;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return $t_string;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
function print_project_version_string( $p_project_id ) {
|
|
|
4c79b5 |
$t_mantis_project_version_table = config_get( 'mantis_project_version_table' );
|
|
|
4c79b5 |
$t_mantis_project_table = config_get( 'mantis_project_table' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$c_project_id = db_prepare_int( $p_project_id );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$query = "SELECT version
|
|
|
4c79b5 |
FROM $t_mantis_project_version_table
|
|
|
4c79b5 |
WHERE project_id='$c_project_id'";
|
|
|
4c79b5 |
$result = db_query( $query );
|
|
|
4c79b5 |
$version_count = db_num_rows( $result );
|
|
|
4c79b5 |
$t_string = '';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
for ($i=0;$i<$version_count;$i++) {
|
|
|
4c79b5 |
$row = db_fetch_array( $result );
|
|
|
4c79b5 |
$t_version = $row['version'];
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( $i+1 < $version_count ) {
|
|
|
4c79b5 |
$t_string .= $t_version.', ';
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
$t_string .= $t_version;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return $t_string;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
###########################################################################
|
|
|
4c79b5 |
# Link Printing API
|
|
|
4c79b5 |
###########################################################################
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# $p_columns_target: see COLUMNS_TARGET_* in constant_inc.php
|
|
|
4c79b5 |
function print_view_bug_sort_link( $p_string, $p_sort_field, $p_sort, $p_dir, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
|
|
|
4c79b5 |
if ( $p_columns_target == COLUMNS_TARGET_PRINT_PAGE ) {
|
|
|
4c79b5 |
if ( $p_sort_field == $p_sort ) {
|
|
|
4c79b5 |
# We toggle between ASC and DESC if the user clicks the same sort order
|
|
|
4c79b5 |
if ( 'ASC' == $p_dir ) {
|
|
|
4c79b5 |
$p_dir = 'DESC';
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
$p_dir = 'ASC';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
} else { # Otherwise always start with ASCending
|
|
|
4c79b5 |
$t_dir = 'ASC';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
echo ''.$p_string.'';
|
|
|
4c79b5 |
} else if ( $p_columns_target == COLUMNS_TARGET_VIEW_PAGE ) {
|
|
|
4c79b5 |
if ( $p_sort_field == $p_sort ) {
|
|
|
4c79b5 |
# we toggle between ASC and DESC if the user clicks the same sort order
|
|
|
4c79b5 |
if ( 'ASC' == $p_dir ) {
|
|
|
4c79b5 |
$p_dir = 'DESC';
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
$p_dir = 'ASC';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
} else { # Otherwise always start with ASCending
|
|
|
4c79b5 |
$t_dir = 'ASC';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
echo ''.$p_string.'';
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
echo $p_string;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
function print_manage_user_sort_link( $p_page, $p_string, $p_field, $p_dir, $p_sort_by, $p_hide=0 ) {
|
|
|
4c79b5 |
if ( $p_sort_by == $p_field ) { # If this is the selected field flip the order
|
|
|
4c79b5 |
if ( 'ASC' == $p_dir || ASCENDING == $p_dir ) {
|
|
|
4c79b5 |
$t_dir = 'DESC';
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
$t_dir = 'ASC';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
} else { # Otherwise always start with ASCending
|
|
|
4c79b5 |
$t_dir = 'ASC';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
PRINT '' . $p_string . '';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
function print_manage_project_sort_link( $p_page, $p_string, $p_field, $p_dir, $p_sort_by ) {
|
|
|
4c79b5 |
if ( $p_sort_by == $p_field ) { # If this is the selected field flip the order
|
|
|
4c79b5 |
if ( 'ASC' == $p_dir || ASCENDING == $p_dir ) {
|
|
|
4c79b5 |
$t_dir = 'DESC';
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
$t_dir = 'ASC';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
} else { # Otherwise always start with ASCending
|
|
|
4c79b5 |
$t_dir = 'ASC';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
PRINT '' . $p_string . '';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# print a button which presents a standalone form.
|
|
|
4c79b5 |
# $p_action_page - The action page
|
|
|
4c79b5 |
# $p_label - The button label
|
|
|
4c79b5 |
# $p_args_to_post - An associative array with key => value to be posted, can be null.
|
|
|
4c79b5 |
function print_button( $p_action_page, $p_label, $p_args_to_post = null ) {
|
|
|
4c79b5 |
echo '<form method="post" action="', $p_action_page, '">';
|
|
|
4c79b5 |
echo '<input type="submit" class="button-small" value="', $p_label, '" />';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( $p_args_to_post !== null ) {
|
|
|
4c79b5 |
foreach( $p_args_to_post as $t_var => $t_value ) {
|
|
|
4c79b5 |
echo "<input type=\"hidden\" name=\"$t_var\" value=\"$t_value\" />";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
echo '</form>';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# print the bracketed links used near the top
|
|
|
4c79b5 |
# if the $p_link is blank then the text is printed but no link is created
|
|
|
4c79b5 |
# if $p_new_window is true, link will open in a new window, default false.
|
|
|
4c79b5 |
function print_bracket_link( $p_link, $p_url_text, $p_new_window = false ) {
|
|
|
4c79b5 |
echo '[ ';
|
|
|
4c79b5 |
if (is_blank( $p_link )) {
|
|
|
4c79b5 |
print $p_url_text;
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
if( true == $p_new_window ) {
|
|
|
4c79b5 |
print "$p_url_text";
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
print "$p_url_text";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
print ' ] ' . "\n";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# print a HTML link
|
|
|
4c79b5 |
function print_link( $p_link, $p_url_text ) {
|
|
|
4c79b5 |
if (is_blank( $p_link )) {
|
|
|
4c79b5 |
PRINT " $p_url_text ";
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
PRINT " $p_url_text ";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# print a HTML page link
|
|
|
4c79b5 |
function print_page_link( $p_page_url, $p_text = '', $p_page_no=0, $p_page_cur=0, $p_temp_filter_id = 0 ) {
|
|
|
4c79b5 |
if (is_blank( $p_text )) {
|
|
|
4c79b5 |
$p_text = $p_page_no;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( ( 0 < $p_page_no ) && ( $p_page_no != $p_page_cur ) ) {
|
|
|
4c79b5 |
if ( $p_temp_filter_id > 0 ) {
|
|
|
4c79b5 |
PRINT " $p_text ";
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
PRINT " $p_text ";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
PRINT " $p_text ";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# print a list of page number links (eg [1 2 3])
|
|
|
4c79b5 |
function print_page_links( $p_page, $p_start, $p_end, $p_current,$p_temp_filter_id = 0 ) {
|
|
|
4c79b5 |
$t_items = array();
|
|
|
4c79b5 |
$t_link = '';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Check if we have more than one page,
|
|
|
4c79b5 |
# otherwise return without doing anything.
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( $p_end - $p_start < 1 ) {
|
|
|
4c79b5 |
return;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Get localized strings
|
|
|
4c79b5 |
$t_first = lang_get( 'first' );
|
|
|
4c79b5 |
$t_last = lang_get( 'last' );
|
|
|
4c79b5 |
$t_prev = lang_get( 'prev' );
|
|
|
4c79b5 |
$t_next = lang_get( 'next' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_page_links = 10;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
print( "[ " );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# First and previous links
|
|
|
4c79b5 |
print_page_link( $p_page, $t_first, 1, $p_current, $p_temp_filter_id );
|
|
|
4c79b5 |
print_page_link( $p_page, $t_prev, $p_current - 1, $p_current, $p_temp_filter_id );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Page numbers ...
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_first_page = max( $p_start, $p_current - $t_page_links/2 );
|
|
|
4c79b5 |
$t_first_page = min( $t_first_page, $p_end - $t_page_links );
|
|
|
4c79b5 |
$t_first_page = max( $t_first_page, $p_start );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( $t_first_page > 1 ) {
|
|
|
4c79b5 |
print( " ... " );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_last_page = $t_first_page + $t_page_links;
|
|
|
4c79b5 |
$t_last_page = min( $t_last_page, $p_end );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
for ( $i = $t_first_page ; $i <= $t_last_page ; $i++ ) {
|
|
|
4c79b5 |
if ( $i == $p_current ) {
|
|
|
4c79b5 |
array_push( $t_items, $i );
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
if ( $p_temp_filter_id > 0 ) {
|
|
|
4c79b5 |
array_push( $t_items, "$i" );
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
array_push( $t_items, "$i" );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
PRINT implode( ' ', $t_items );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( $t_last_page < $p_end ) {
|
|
|
4c79b5 |
print( " ... " );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Next and Last links
|
|
|
4c79b5 |
if ( $p_current < $p_end ) {
|
|
|
4c79b5 |
print_page_link( $p_page, $t_next, $p_current + 1, $p_current, $p_temp_filter_id );
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
print_page_link( $p_page, $t_next, null, null, $p_temp_filter_id );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
print_page_link( $p_page, $t_last, $p_end, $p_current, $p_temp_filter_id );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
print( " ]" );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# print a mailto: href link
|
|
|
4c79b5 |
function print_email_link( $p_email, $p_text ) {
|
|
|
4c79b5 |
PRINT get_email_link($p_email, $p_text);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# return the mailto: href string link instead of printing it
|
|
|
4c79b5 |
function get_email_link( $p_email, $p_text ) {
|
|
|
4c79b5 |
return prepare_email_link( $p_email, $p_text );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# print a mailto: href link with subject
|
|
|
4c79b5 |
function print_email_link_with_subject( $p_email, $p_text, $p_bug_id ) {
|
|
|
4c79b5 |
$t_subject = email_build_subject( $p_bug_id );
|
|
|
4c79b5 |
PRINT get_email_link_with_subject( $p_email, $p_text, $t_subject );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# return the mailto: href string link instead of printing it
|
|
|
4c79b5 |
# add subject line
|
|
|
4c79b5 |
function get_email_link_with_subject( $p_email, $p_text, $p_summary ) {
|
|
|
4c79b5 |
if ( !access_has_project_level( config_get( 'show_user_email_threshold' ) ) ) {
|
|
|
4c79b5 |
return $p_text;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# If we apply string_url() to the whole mailto: link then the @
|
|
|
4c79b5 |
# gets turned into a %40 and you can't right click in browsers to
|
|
|
4c79b5 |
# do Copy Email Address. If we don't apply string_url() to the
|
|
|
4c79b5 |
# summary text then an ampersand (for example) will truncate the text
|
|
|
4c79b5 |
$p_summary = string_url( $p_summary );
|
|
|
4c79b5 |
$t_mailto = string_attribute( "mailto:$p_email?subject=$p_summary" );
|
|
|
4c79b5 |
$p_text = string_display( $p_text );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return "$p_text";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# Print a hidden input for each name=>value pair in the array
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# If a value is an array an input will be created for each item with a name
|
|
|
4c79b5 |
# that ends with []
|
|
|
4c79b5 |
# The names and values are passed through htmlspecialchars() before being displayed
|
|
|
4c79b5 |
function print_hidden_inputs( $p_assoc_array ) {
|
|
|
4c79b5 |
foreach ( $p_assoc_array as $key => $val ) {
|
|
|
4c79b5 |
$key = string_html_specialchars( $key );
|
|
|
4c79b5 |
if ( is_array( $val ) ) {
|
|
|
4c79b5 |
foreach ( $val as $val2 ) {
|
|
|
4c79b5 |
$val2 = string_html_specialchars( $val2 );
|
|
|
4c79b5 |
PRINT "<input type=\"hidden\" name=\"$val\[\]\" value=\"$val2\" />\n";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
$val = string_html_specialchars( $val );
|
|
|
4c79b5 |
PRINT "<input type=\"hidden\" name=\"$key\" value=\"$val\" />\n";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
#=============================
|
|
|
4c79b5 |
# Functions that used to be in html_api
|
|
|
4c79b5 |
#=============================
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# This prints the little [?] link for user help
|
|
|
4c79b5 |
# The $p_a_name is a link into the documentation.html file
|
|
|
4c79b5 |
function print_documentation_link( $p_a_name='' ) {
|
|
|
4c79b5 |
# @@@ Disable documentation links for now. May be re-enabled if linked to new manual.
|
|
|
4c79b5 |
# PRINT "[?]";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# print the hr
|
|
|
4c79b5 |
function print_hr( $p_hr_size=null, $p_hr_width=null ) {
|
|
|
4c79b5 |
if ( null === $p_hr_size ) {
|
|
|
4c79b5 |
$p_hr_size = config_get( 'hr_size' );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
if ( null === $p_hr_width ) {
|
|
|
4c79b5 |
$p_hr_width = config_get( 'hr_width' );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
PRINT " ";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# prints the signup link
|
|
|
4c79b5 |
function print_signup_link() {
|
|
|
4c79b5 |
if( ( ON == config_get( 'allow_signup' ) ) &&
|
|
|
4c79b5 |
( ON == config_get( 'enable_email_notification' ) ) ) {
|
|
|
4c79b5 |
print_bracket_link( 'signup_page.php', lang_get( 'signup_link' ) );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# prints the login link
|
|
|
4c79b5 |
function print_login_link() {
|
|
|
4c79b5 |
print_bracket_link( 'login_page.php', lang_get( 'login_title' ) );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# prints the lost pwd link
|
|
|
4c79b5 |
function print_lost_password_link() {
|
|
|
4c79b5 |
# lost password feature disabled or reset password via email disabled -> stop here!
|
|
|
4c79b5 |
if( ( ON == config_get( 'lost_password_feature' ) ) &&
|
|
|
4c79b5 |
( ON == config_get( 'send_reset_password' ) ) &&
|
|
|
4c79b5 |
( ON == config_get( 'enable_email_notification' ) ) ) {
|
|
|
4c79b5 |
print_bracket_link( 'lost_pwd_page.php', lang_get( 'lost_password_link' ) );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
function print_proceed( $p_result, $p_query, $p_link ) {
|
|
|
4c79b5 |
PRINT ' ';
|
|
|
4c79b5 |
PRINT '';
|
|
|
4c79b5 |
if ( $p_result ) { # SUCCESS
|
|
|
4c79b5 |
PRINT lang_get( 'operation_successful' ) . ' ';
|
|
|
4c79b5 |
} else { # FAILURE
|
|
|
4c79b5 |
print_sql_error( $p_query );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
print_bracket_link( $p_link, lang_get( 'proceed' ) );
|
|
|
4c79b5 |
PRINT '';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
#===============================
|
|
|
4c79b5 |
# Deprecated Functions
|
|
|
4c79b5 |
#===============================
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# print our standard mysql query error
|
|
|
4c79b5 |
# this function should rarely (if ever) be reached. instead the db_()
|
|
|
4c79b5 |
# functions should trap (although inelegantly).
|
|
|
4c79b5 |
function print_sql_error( $p_query ) {
|
|
|
4c79b5 |
global $g_administrator_email;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
PRINT error_string( ERROR_SQL );
|
|
|
4c79b5 |
print_email_link( $g_administrator_email, lang_get( 'administrator' ) );
|
|
|
4c79b5 |
PRINT " $p_query; ";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# Get icon corresponding to the specified filename
|
|
|
4c79b5 |
function print_file_icon( $p_filename ) {
|
|
|
4c79b5 |
$t_file_type_icons = config_get( 'file_type_icons' );
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$ext = strtolower( file_get_extension( $p_filename ) );
|
|
|
4c79b5 |
if ( is_blank( $ext ) || !isset( $t_file_type_icons[$ext] ) ) {
|
|
|
4c79b5 |
$ext = '?';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_name = $t_file_type_icons[$ext];
|
|
|
4c79b5 |
PRINT '
|
|
|
4c79b5 |
'" alt="' . $ext . ' file icon" width="16" height="16" border="0" />';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# Prints an RSS image that is hyperlinked to an RSS feed.
|
|
|
4c79b5 |
function print_rss( $p_feed_url, $p_title = '' ) {
|
|
|
4c79b5 |
$t_path = config_get( 'path' );
|
|
|
4c79b5 |
echo '';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# --------------------
|
|
|
4c79b5 |
# Prints the recently visited issues.
|
|
|
4c79b5 |
function print_recently_visited() {
|
|
|
4c79b5 |
if ( !last_visited_enabled() ) {
|
|
|
4c79b5 |
return;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$t_ids = last_visited_get_array();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ( count( $t_ids ) == 0 ) {
|
|
|
4c79b5 |
return;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
echo lang_get( 'recently_visited' ) . ': ';
|
|
|
4c79b5 |
$t_first = true;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach( $t_ids as $t_id ) {
|
|
|
4c79b5 |
if ( !$t_first ) {
|
|
|
4c79b5 |
echo ', ';
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
$t_first = false;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
echo string_get_bug_view_link( $t_id );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# ----------------------
|
|
|
4c79b5 |
# print a dropdown box from input array
|
|
|
4c79b5 |
function get_dropdown( $p_control_array, $p_control_name, $p_match = '', $p_add_any=false, $p_multiple=false, $p_change_script = '') {
|
|
|
4c79b5 |
$t_control_array = $p_control_array;
|
|
|
4c79b5 |
if ( $p_multiple ){
|
|
|
4c79b5 |
$t_size = ' SIZE="5"';
|
|
|
4c79b5 |
$t_multiple = ' MULTIPLE';
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
$t_size = '';
|
|
|
4c79b5 |
$t_multiple = '';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$t_script = ($p_change_script == '' ? '' : ' onchange="'.$p_change_script.'"');
|
|
|
4c79b5 |
$t_info = sprintf("<SELECT %s NAME=\"%s\" id=\"%s\"%s%s>",
|
|
|
4c79b5 |
$t_multiple, $p_control_name, $p_control_name, $t_size, $t_script);
|
|
|
4c79b5 |
if ( $p_add_any ) {
|
|
|
4c79b5 |
array_unshift_assoc( $t_control_array, FILTER_META_ANY, lang_trans( '[any]' ) );
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
while( list( $t_name, $t_desc ) = each( $t_control_array ) ) {
|
|
|
4c79b5 |
$t_sel = "";
|
|
|
4c79b5 |
if( is_array( $p_match ) ) {
|
|
|
4c79b5 |
if( in_array( $t_name, array_values( $p_match ) ) ||
|
|
|
4c79b5 |
in_array( $t_desc, array_values( $p_match ) ) ) {
|
|
|
4c79b5 |
$t_sel = " SELECTED";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
} else {
|
|
|
4c79b5 |
if( ( $t_name === $p_match ) || ( $t_desc === $p_match ) ) {
|
|
|
4c79b5 |
$t_sel = " SELECTED";
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$t_info .= sprintf("<OPTION%s VALUE=\"%s\">%s", $t_sel, $t_name, $t_desc);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$t_info .= "</SELECT>\n";
|
|
|
4c79b5 |
return $t_info;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
?>
|