function __construct() { $this->project_id = helper_get_current_project(); if (isset($_REQUEST['severity'])) { // isset to allow empty $this->severity = intval($_REQUEST['severity']); $_SESSION[__CLASS__]['severity'] = $this->severity; } else { $this->severity = $_SESSION[__CLASS__]['severity']; } $versions = version_get_all_rows($this->project_id, null, null); $this->versions = []; foreach ($versions as $version) { if ($_REQUEST['versions'] === $version['version']) { // isset to allow empty $this->versions[$version['version']] = [$version['version'], "true"]; $this->version = $version['version']; } else { $this->versions[$version['version']] = [$version['version'], "false"]; } } }
/** * Checks whether the product version should be shown * (i.e. report, update, view, print). * @param integer $p_project_id The project id. * @return bool true: show, false: otherwise. */ function version_should_show_product_version($p_project_id) { return ON == config_get('show_product_version', null, null, $p_project_id) || AUTO == config_get('show_product_version', null, null, $p_project_id) && count(version_get_all_rows($p_project_id)) > 0; }
?> <!-- PROJECTS --> <?php $t_project_name = str_repeat("» ", $p_level) . project_get_name($t_project); ?> <tr valign="top"> <td class="category"><?php echo $t_project_name; ?> </td> <td> <table> <!-- PROJECT VERSIONS --> <?php $t_versions = version_get_all_rows($t_project, null, null); if (count($t_versions) > 0) { foreach ($t_versions as $t_version) { if ($t_version['project_id'] != $t_project) { $t_inherited = true; } else { $t_inherited = false; } $t_version_name = version_full_name($t_version['id'], $t_inherited, $t_project); $t_released = $t_version['released']; $t_obsolete = $t_version['obsolete']; if (!date_is_null($t_version['date_order'])) { $t_date_formatted = date(config_get('complete_date_format'), $t_version['date_order']); } else { $t_date_formatted = ' '; }
html_page_top(bug_format_summary($f_bug_id, SUMMARY_CAPTION)); print_recently_visited(); } $t_action_button_position = config_get('action_button_position'); $t_bugslist = gpc_get_cookie(config_get('bug_list_cookie'), false); $tpl_show_versions = version_should_show_product_version($tpl_bug->project_id); $tpl_show_product_version = $tpl_show_versions && in_array('product_version', $t_fields); $tpl_show_fixed_in_version = $tpl_show_versions && in_array('fixed_in_version', $t_fields); $tpl_show_product_build = $tpl_show_versions && in_array('product_build', $t_fields) && config_get('enable_product_build') == ON; $tpl_product_build = $tpl_show_product_build ? string_display_line($tpl_bug->build) : ''; $tpl_show_target_version = $tpl_show_versions && in_array('target_version', $t_fields) && access_has_bug_level(config_get('roadmap_view_threshold'), $f_bug_id); $tpl_product_version_string = ''; $tpl_target_version_string = ''; $tpl_fixed_in_version_string = ''; if ($tpl_show_product_version || $tpl_show_fixed_in_version || $tpl_show_target_version) { $t_version_rows = version_get_all_rows($tpl_bug->project_id); if ($tpl_show_product_version) { $tpl_product_version_string = prepare_version_string($tpl_bug->project_id, version_get_id($tpl_bug->version, $tpl_bug->project_id), $t_version_rows); } if ($tpl_show_target_version) { $tpl_target_version_string = prepare_version_string($tpl_bug->project_id, version_get_id($tpl_bug->target_version, $tpl_bug->project_id), $t_version_rows); } if ($tpl_show_fixed_in_version) { $tpl_fixed_in_version_string = prepare_version_string($tpl_bug->project_id, version_get_id($tpl_bug->fixed_in_version, $tpl_bug->project_id), $t_version_rows); } } $tpl_product_version_string = string_display_line($tpl_product_version_string); $tpl_target_version_string = string_display_line($tpl_target_version_string); $tpl_fixed_in_version_string = string_display_line($tpl_fixed_in_version_string); $tpl_bug_id = $f_bug_id; $tpl_form_title = lang_get('bug_view_title');
$t_project_ids = user_get_all_accessible_subprojects($t_user_id, $t_project_id); array_unshift($t_project_ids, $t_project_id); } $t_project_index = 0; version_cache_array_rows($t_project_ids); category_cache_array_rows_by_project($t_project_ids); foreach ($t_project_ids as $t_project_id) { $t_project_name = project_get_field($t_project_id, 'name'); $t_can_view_private = access_has_project_level(config_get('private_bug_threshold'), $t_project_id); $t_limit_reporters = config_get('limit_reporters'); $t_user_access_level_is_reporter = REPORTER == access_get_project_level($t_project_id); $t_resolved = config_get('bug_resolved_status_threshold'); $t_bug_table = db_get_table('mantis_bug_table'); $t_relation_table = db_get_table('mantis_bug_relationship_table'); # grab version info for later use $t_version_rows = version_get_all_rows($t_project_id, null, false); # cache category info, but ignore the results for now category_get_all_rows($t_project_id); $t_project_header_printed = false; foreach ($t_version_rows as $t_version_row) { $t_version_header_printed = false; $t_version = $t_version_row['version']; $t_version_id = $t_version_row['id']; # Skip all versions except the specified one (if any). if ($f_version_id != -1 && $f_version_id != $t_version_id) { continue; } $query = "SELECT sbt.*, dbt.fixed_in_version AS parent_version, rt.source_bug_id\n FROM {$t_bug_table} AS sbt\n LEFT JOIN {$t_relation_table} AS rt\n ON sbt.id=rt.destination_bug_id AND rt.relationship_type=" . BUG_DEPENDANT . "\n LEFT JOIN {$t_bug_table} AS dbt ON dbt.id=rt.source_bug_id\n WHERE sbt.project_id=" . db_param() . "\n AND sbt.fixed_in_version=" . db_param() . "\n ORDER BY sbt.status ASC, sbt.last_updated DESC"; $t_description = version_get_field($t_version_id, 'description'); $t_first_entry = true; $t_issue_ids = array();
print_version_option_list( '', $t_project_id, VERSION_ALL ); break; } echo '</select>'; } ?> </td> </tr> <?php if ( isset( $t_question_title2 ) ) { switch ( $f_action ) { case 'RESOLVE': $t_show_product_version = ( ON == config_get( 'show_product_version' ) ) || ( ( AUTO == config_get( 'show_product_version' ) ) && ( count( version_get_all_rows( $t_project_id ) ) > 0 ) ); if ( $t_show_product_version ) { ?> <tr class="row-2"> <th class="category"> <?php echo $t_question_title2 ?> </th> <td> <select name="<?php echo $t_form2 ?>"> <?php print_version_option_list( '', null, VERSION_ALL );?> </select> </td> </tr> <?php } break;
?> </select> </td> </tr> <?php } ?> <!-- spacer --> <tr class="spacer"> <td colspan="2"></td> </tr> <?php $t_show_version = ON == config_get('show_product_version') || AUTO == config_get('show_product_version') && count(version_get_all_rows($t_project_id)) > 0; if ($t_show_version) { ?> <!-- Product Version --> <tr <?php echo helper_alternate_class(); ?> > <td class="category"> <?php echo lang_get('product_version'); ?> </td> <td> <select <?php echo helper_get_tab_index();
helper_alternate_class(0); ?> <!-- PROJECT VERSIONS --> <table id="versions" class="width75" cellspacing="1"> <!-- Title --> <tr> <td class="form-title" colspan="3"> <?php echo lang_get('versions'); ?> </td> </tr> <?php $t_versions = version_get_all_rows($f_project_id, null, null); if (count($t_versions) > 0) { ?> <tr class="row-category"> <td> <?php echo lang_get('version'); ?> </td> <td class="center"> <?php echo lang_get('released'); ?> </td> <td class="center"> <?php
} else { access_ensure_project_level(config_get('roadmap_view_threshold'), $t_project_id); $t_project_ids = user_get_all_accessible_subprojects($t_user_id, $t_project_id); array_unshift($t_project_ids, $t_project_id); } $t_project_id_for_access_check = $t_project_id; html_page_top(lang_get('roadmap')); version_cache_array_rows($t_project_ids); category_cache_array_rows_by_project($t_project_ids); foreach ($t_project_ids as $t_project_id) { $t_project_name = project_get_field($t_project_id, 'name'); $t_can_view_private = access_has_project_level(config_get('private_bug_threshold'), $t_project_id); $t_limit_reporters = config_get('limit_reporters'); $t_user_access_level_is_reporter = config_get('report_bug_threshold', null, null, $t_project_id) == access_get_project_level($t_project_id); $t_resolved = config_get('bug_resolved_status_threshold'); $t_version_rows = array_reverse(version_get_all_rows($t_project_id)); # cache category info, but ignore the results for now category_get_all_rows($t_project_id); $t_project_header_printed = false; foreach ($t_version_rows as $t_version_row) { if ($t_version_row['released'] == 1) { continue; } # Skip all versions except the specified one (if any). if ($f_version_id != -1 && $f_version_id != $t_version_row['id']) { continue; } $t_issues_planned = 0; $t_issues_resolved = 0; $t_issues_counted = array(); $t_version_header_printed = false;
/** * Checks whether the product version should be shown * (i.e. report, update, view, print). * @param integer $p_project_id The project id. * @return bool true: show, false: otherwise. */ function version_should_show_product_version( $p_project_id ) { return ( ON == config_get( 'show_product_version', /* default */ null, /* user_id */ null, $p_project_id ) ) || ( ( AUTO == config_get( 'show_product_version', /* default */ null, /* user_id */ null, $p_project_id ) ) && ( count( version_get_all_rows( $p_project_id ) ) > 0 ) ); }
require_api('version_api.php'); form_security_validate('manage_proj_ver_copy'); auth_reauthenticate(); $f_project_id = gpc_get_int('project_id'); $f_other_project_id = gpc_get_int('other_project_id'); $f_copy_from = gpc_get_bool('copy_from'); $f_copy_to = gpc_get_bool('copy_to'); project_ensure_exists($f_project_id); project_ensure_exists($f_other_project_id); access_ensure_project_level(config_get('manage_project_threshold'), $f_project_id); access_ensure_project_level(config_get('manage_project_threshold'), $f_other_project_id); if ($f_copy_from) { $t_src_project_id = $f_other_project_id; $t_dst_project_id = $f_project_id; } else { if ($f_copy_to) { $t_src_project_id = $f_project_id; $t_dst_project_id = $f_other_project_id; } else { trigger_error(ERROR_VERSION_NO_ACTION, ERROR); } } $t_rows = version_get_all_rows($t_src_project_id); foreach ($t_rows as $t_row) { if (version_is_unique($t_row['version'], $t_dst_project_id)) { $t_version_id = version_add($t_dst_project_id, $t_row['version'], $t_row['released'], $t_row['description'], $t_row['date_order']); event_signal('EVENT_MANAGE_VERSION_CREATE', array($t_version_id)); } } form_security_purge('manage_proj_ver_copy'); print_header_redirect('manage_proj_edit_page.php?project_id=' . $f_project_id);
function print_version_option_list($p_version = '', $p_project_id = null, $p_released = null, $p_leading_blank = true, $p_with_subs = false) { if (null === $p_project_id) { $c_project_id = helper_get_current_project(); } else { $c_project_id = db_prepare_int($p_project_id); } if ($p_with_subs) { $versions = version_get_all_rows_with_subs($c_project_id, $p_released); } else { $versions = version_get_all_rows($c_project_id, $p_released); } if ($p_leading_blank) { echo '<option value=""></option>'; } foreach ($versions as $version) { $t_version = string_attribute($version['version']); echo "<option value=\"{$t_version}\""; check_selected($p_version, $t_version); echo '>', string_shorten($t_version), '</option>'; } }
/** * Get all unreleased (a.k.a. future) versions of a project. * * @param string $p_username The name of the user trying to access the versions. * @param string $p_password The password of the user. * @param integer $p_project_id The id of the project to retrieve the versions for. * @return Array representing a ProjectVersionDataArray structure. */ function mc_project_get_unreleased_versions( $p_username, $p_password, $p_project_id ) { $t_user_id = mci_check_login( $p_username, $p_password ); if( $t_user_id === false ) { return mci_soap_fault_login_failed(); } if( !project_exists( $p_project_id ) ) { return new soap_fault( 'Client', '', "Project '$p_project_id' does not exist." ); } if( !mci_has_readonly_access( $t_user_id, $p_project_id ) ) { return mci_soap_fault_access_denied( $t_user_id ); } $t_result = array(); foreach( version_get_all_rows( $p_project_id, VERSION_FUTURE ) as $t_version ) $t_result[] = mci_project_version_as_array ( $t_version ); return $t_result; }
<div id="project-versions-div" class="form-container"> <h2><?php echo lang_get( 'versions' ); ?></h2> <form id="manage-project-version-copy-form" method="post" action="manage_proj_ver_copy.php"> <fieldset> <?php echo form_security_field( 'manage_proj_ver_copy' ) ?> <input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" /> <select name="other_project_id"> <?php print_project_option_list( null, false, $f_project_id ); ?> </select> <input type="submit" name="copy_from" class="button" value="<?php echo lang_get( 'copy_versions_from' ) ?>" /> <input type="submit" name="copy_to" class="button" value="<?php echo lang_get( 'copy_versions_to' ) ?>" /> </fieldset> </form><?php $t_versions = version_get_all_rows( $f_project_id, /* released = */ null, /* obsolete = */ null ); if ( count( $t_versions ) > 0 ) { ?> <table id="versions" cellspacing="1" cellpadding="5" border="1"> <tr class="row-category"> <th><?php echo lang_get( 'version' ) ?></th> <th><?php echo lang_get( 'released' ) ?></th> <th><?php echo lang_get( 'obsolete' ) ?></th> <th><?php echo lang_get( 'timestamp' ) ?></th> <th colspan="2"><?php echo lang_get( 'actions' ) ?></th> </tr><?php foreach ( $t_versions as $t_version ) { $t_inherited = ( $t_version['project_id'] != $f_project_id ? true : false ); $t_name = version_full_name( $t_version['id'], /* showProject */ $t_inherited, $f_project_id ); $t_released = $t_version['released']; $t_obsolete = $t_version['obsolete'];
/** * Construct an enumeration for future versions for the current project. * The enumeration will be empty if current project is ALL PROJECTS. * Enumerations format is: "abc|lmn|xyz" * To use this in a custom field type "=future_versions" in the possible values field. * @return string */ function custom_function_default_enum_future_versions() { $t_versions = version_get_all_rows(helper_get_current_project()); $t_enum = array(); foreach ($t_versions as $t_version) { if ($t_version['released'] == 0) { $t_enum[] = $t_version['version']; } } $t_possible_values = implode('|', $t_enum); return $t_possible_values; }
?> <!-- PROJECT VERSIONS --> <a name="versions" /> <table class="width75" cellspacing="1"> <!-- Title --> <tr> <td class="form-title" colspan="3"> <?php echo lang_get('versions'); ?> </td> </tr> <?php $t_versions = version_get_all_rows($f_project_id); if (count($t_versions) > 0) { ?> <tr class="row-category"> <td> <?php echo lang_get('version'); ?> </td> <td class="center"> <?php echo lang_get('released'); ?> </td> <td class="center"> <?php
/** * Get all unreleased (a.k.a. future) versions of a project. * * @param string $p_username The name of the user trying to access the versions. * @param string $p_password The password of the user. * @param integer $p_project_id The id of the project to retrieve the versions for. * @return Array representing a ProjectVersionDataArray structure. */ function mc_project_get_unreleased_versions($p_username, $p_password, $p_project_id) { $t_user_id = mci_check_login($p_username, $p_password); if ($t_user_id === false) { return mci_soap_fault_login_failed(); } if (!project_exists($p_project_id)) { return new soap_fault('Client', '', "Project '{$p_project_id}' does not exist."); } if (!mci_has_readonly_access($t_user_id, $p_project_id)) { return mci_soap_fault_access_denied($t_user_id); } $t_result = array(); foreach (version_get_all_rows($p_project_id, VERSION_FUTURE) as $t_version) { $t_result[] = array('id' => $t_version['id'], 'name' => $t_version['version'], 'project_id' => $p_project_id, 'date_order' => timestamp_to_iso8601($t_version['date_order']), 'description' => mci_null_if_empty($t_version['description']), 'released' => $t_version['released']); } return $t_result; }
version_cache_array_rows( $t_project_ids ); category_cache_array_rows_by_project( $t_project_ids ); foreach( $t_project_ids as $t_project_id ) { $t_project_name = project_get_field( $t_project_id, 'name' ); $t_can_view_private = access_has_project_level( config_get( 'private_bug_threshold' ), $t_project_id ); $t_limit_reporters = config_get( 'limit_reporters' ); $t_user_access_level_is_reporter = ( REPORTER == access_get_project_level( $t_project_id ) ); $t_resolved = config_get( 'bug_resolved_status_threshold' ); $t_bug_table = db_get_table( 'bug' ); $t_relation_table = db_get_table( 'bug_relationship' ); # grab version info for later use $t_version_rows = version_get_all_rows( $t_project_id, /* released */ null, /* obsolete */ false ); # cache category info, but ignore the results for now category_get_all_rows( $t_project_id ); $t_project_header_printed = false; foreach( $t_version_rows as $t_version_row ) { $t_issues_planned = 0; $t_issues_resolved = 0; $t_version_header_printed = false; $t_version = $t_version_row['version']; $t_version_id = $t_version_row['id'];
/** * Given a bug ID, apply the appropriate branch mapping algorithm * to find and return the appropriate version ID. * @param int Bug ID * @return int Version ID */ function apply($p_bug_id) { static $s_versions = array(); static $s_versions_sorted = array(); # if it's explicit, return the version_id before doing anything else if ($this->type == SOURCE_EXPLICIT) { return $this->version; } # cache project/version sets, and the appropriate sorting $t_project_id = bug_get_field($p_bug_id, 'project_id'); if (!isset($s_versions[$t_project_id])) { $s_versions[$t_project_id] = version_get_all_rows($t_project_id, false); } # handle empty version sets if (count($s_versions[$t_project_id]) < 1) { return ''; } # cache the version set based on the current algorithm if (!isset($s_versions_sorted[$t_project_id][$this->type])) { $s_versions_sorted[$t_project_id][$this->type] = $s_versions[$t_project_id]; switch ($this->type) { case SOURCE_NEAR: usort($s_versions_sorted[$t_project_id][$this->type], array('SourceMapping', 'cmp_near')); break; case SOURCE_FAR: usort($s_versions_sorted[$t_project_id][$this->type], array('SourceMapping', 'cmp_far')); break; case SOURCE_FIRST: usort($s_versions_sorted[$t_project_id][$this->type], array('SourceMapping', 'cmp_first')); break; case SOURCE_LAST: usort($s_versions_sorted[$t_project_id][$this->type], array('SourceMapping', 'cmp_last')); break; } } # pull the appropriate versions set from the cache $t_versions = $s_versions_sorted[$t_project_id][$this->type]; # handle non-regex mappings if (is_blank($this->regex)) { return $t_versions[0]['version']; } # handle regex mappings foreach ($t_versions as $t_version) { if (preg_match($this->regex, $t_version['version'])) { return $t_version['version']; } } # no version matches the regex return ''; }
/** * Get all unreleased (a.k.a. future) versions of a project. * * @param string $p_username The name of the user trying to access the versions. * @param string $p_password The password of the user. * @param integer $p_project_id The id of the project to retrieve the versions for. * @return array representing a ProjectVersionDataArray structure. */ function mc_project_get_unreleased_versions($p_username, $p_password, $p_project_id) { global $g_project_override; $t_user_id = mci_check_login($p_username, $p_password); if ($t_user_id === false) { return mci_soap_fault_login_failed(); } if (!project_exists($p_project_id)) { return SoapObjectsFactory::newSoapFault('Client', 'Project \'' . $p_project_id . '\' does not exist.'); } $g_project_override = $p_project_id; if (!mci_has_readonly_access($t_user_id, $p_project_id)) { return mci_soap_fault_access_denied($t_user_id); } $t_result = array(); foreach (version_get_all_rows($p_project_id, VERSION_FUTURE) as $t_version) { $t_result[] = mci_project_version_as_array($t_version); } return $t_result; }
function print_version_option_list($p_version = '', $p_project_id = null, $p_released = null, $p_leading_blank = true, $p_with_subs = false) { if (null === $p_project_id) { $c_project_id = helper_get_current_project(); } else { $c_project_id = db_prepare_int($p_project_id); } if ($p_with_subs) { $versions = version_get_all_rows_with_subs($c_project_id, $p_released, null); } else { $versions = version_get_all_rows($c_project_id, $p_released, null); } # Ensure the selected version (if specified) is included in the list # Note: Filter API specifies selected versions as an array if (!is_array($p_version)) { if (!empty($p_version)) { $t_version_id = version_get_id($p_version, $c_project_id); if ($t_version_id !== false) { $versions[] = version_cache_row($t_version_id); } } } if ($p_leading_blank) { echo '<option value=""></option>'; } $t_listed = array(); $t_max_length = config_get('max_dropdown_length'); $t_show_version_dates = access_has_project_level(config_get('show_version_dates_threshold')); $t_short_date_format = config_get('short_date_format'); foreach ($versions as $version) { # If the current version is obsolete, and current version not equal to $p_version, # then skip it. if ((int) $version['obsolete'] == 1) { if ($version['version'] != $p_version) { continue; } } $t_version = string_attribute($version['version']); if (!in_array($t_version, $t_listed)) { $t_listed[] = $t_version; echo '<option value="' . $t_version . '"'; check_selected($p_version, $version['version']); $t_version_string = string_attribute(prepare_version_string($c_project_id, $version['id'])); echo '>', string_shorten($t_version_string, $t_max_length), '</option>'; } } }
* modified for new Mantis plugin system by Jiri Hron * * Created: 2008-01-05 * Last update: 2012-05-23 * * @link http://deboutv.free.fr/mantis/ * @copyright * @author Vincent DEBOUT <*****@*****.**> * @author Jiri Hron <*****@*****.**> */ require_once 'core.php'; require_once 'bug_api.php'; html_page_top(plugin_lang_get('display_page_title')); $t_user_id = auth_get_current_user_id(); $t_project_id = helper_get_current_project(); $t_releases = version_get_all_rows($t_project_id, 1); $t_project_name = project_get_name($t_project_id); $t_user_has_upload_level = user_get_access_level($t_user_id, $t_project_id) >= plugin_config_get('upload_threshold_level', PLUGINS_RELEASEMGT_UPLOAD_THRESHOLD_LEVEL_DEFAULT); echo '<br /><span class="pagetitle">', string_display($t_project_name), ' - ', plugin_lang_get('display_page_title'), '</span><br /><br />'; foreach ($t_releases as $t_release) { $t_prj_id = $t_release['project_id']; $t_project_name = project_get_field($t_prj_id, 'name'); $t_release_title = string_display($t_project_name) . ' - ' . string_display($t_release['version']); echo '<tt>' . $t_release_title . '<br />'; echo str_pad('', strlen($t_release_title), '='), '</tt><br /><br />'; $t_query = 'SELECT id, title, description FROM ' . plugin_table('file') . ' WHERE project_id=' . db_prepare_int($t_prj_id) . ' AND version_id=' . db_prepare_int($t_release['id']) . ' ORDER BY title ASC'; $t_result = db_query($t_query); while ($t_row = db_fetch_array($t_result)) { echo '- <a href="' . plugin_page('download') . '&id=' . $t_row['id'] . '" title="' . plugin_lang_get('download_link') . '">' . $t_row['title'] . '</a>'; if ($t_user_has_upload_level) { echo ' ';