/**
 * A function that prepares the version string for outputting to the user on view / print issue pages.
 * This function would add the version date, if appropriate.
 *
 * @param integer $p_project_id  The project id.
 * @param integer $p_version_id  The version id.  If false then this method will return an empty string.
 * @return The formatted version string.
 */
function prepare_version_string($p_project_id, $p_version_id)
{
    if ($p_version_id === false) {
        return '';
    }
    $t_version_text = version_full_name($p_version_id, null, $p_project_id);
    if (access_has_project_level(config_get('show_version_dates_threshold'), $p_project_id)) {
        $t_short_date_format = config_get('short_date_format');
        $t_version = version_get($p_version_id);
        $t_version_text .= ' (' . date($t_short_date_format, $t_version->date_order) . ')';
    }
    return $t_version_text;
}
Example #2
0
 public function addVersion($projID, $version)
 {
     if (MANTIS_LOCAL) {
         if (version_add($projID, $version, true, $version)) {
             $t_version_id = version_get_id($version, $projID);
             if (!is_blank($v_date_order)) {
                 $t_version = version_get($t_version_id);
                 $t_version->date_order = date("Y-m-d H:i:s", strtotime($v_date_order));
                 version_update($t_version);
             }
         }
     } else {
         $this->client->mc_project_version_add(MANTIS_USER, MANTIS_PWD, array('name' => $version, 'project_id' => $projID, 'description' => $version, 'released' => true));
     }
 }
/**
 * Calculate page content
 */
function calculate_changes()
{
    $specmanagement_print_api = new specmanagement_print_api();
    $other_version = version_get($_POST['version_other']);
    $my_version = version_get($_POST['version_my']);
    $specified_versions = specify_version($my_version, $other_version);
    $old_version = $specified_versions[0];
    $new_version = $specified_versions[1];
    $specmanagement_print_api->print_page_head(plugin_lang_get('changes_title') . ': ' . $old_version->version . ' / ' . $new_version->version);
    echo '<table class="editor">';
    print_changes_table_head($old_version, $new_version);
    print_changes_table_body($old_version, $new_version);
    $specmanagement_print_api->printTableFoot();
    html_page_bottom1();
}
Example #4
0
/**
 * Submit the specified version details.
 *
 * @param string $p_username  The name of the user trying to add the issue.
 * @param string $p_password  The password of the user.
 * @param Array $p_version  A ProjectVersionData structure containing information about the new verison.
 * @return integer  The id of the created version.
 */
function mc_project_version_add($p_username, $p_password, $p_version)
{
    $t_user_id = mci_check_login($p_username, $p_password);
    if ($t_user_id === false) {
        return mci_soap_fault_login_failed();
    }
    $t_project_id = $p_version['project_id'];
    $t_name = $p_version['name'];
    $t_released = $p_version['released'];
    $t_description = $p_version['description'];
    $t_date_order = $p_version['date_order'];
    if (is_blank($t_project_id)) {
        return new soap_fault('Client', '', 'Mandatory field "project_id" was missing');
    }
    if (!project_exists($t_project_id)) {
        return new soap_fault('Client', '', "Project '{$t_project_id}' does not exist.");
    }
    if (!mci_has_readwrite_access($t_user_id, $t_project_id)) {
        return mci_soap_fault_access_denied($t_user_id);
    }
    if (!mci_has_access(config_get('manage_project_threshold'), $t_user_id, $t_project_id)) {
        return mci_soap_fault_access_denied($t_user_id);
    }
    if (is_blank($t_name)) {
        return new soap_fault('Client', '', 'Mandatory field "name" was missing');
    }
    if (!version_is_unique($t_name, $t_project_id)) {
        return new soap_fault('Client', '', 'Version exists for project', 'The version you attempted to add already exists for this project');
    }
    if ($t_released === false) {
        $t_released = VERSION_FUTURE;
    } else {
        $t_released = VERSION_RELEASED;
    }
    if (version_add($t_project_id, $t_name, $t_released, $t_description)) {
        $t_version_id = version_get_id($t_name, $t_project_id);
        if (!is_blank($t_date_order)) {
            $t_version = version_get($t_version_id);
            $t_version->date_order = date("Y-m-d H:i:s", strtotime($t_date_order));
            version_update($t_version);
        }
        return $t_version_id;
    }
    return null;
}
Example #5
0
/**
 * Submit the specified version details.
 *
 * @param string $p_username  The name of the user trying to add the issue.
 * @param string $p_password  The password of the user.
 * @param Array $p_version  A ProjectVersionData structure containing information about the new verison.
 * @return integer  The id of the created version.
 */
function mc_project_version_add($p_username, $p_password, $p_version)
{
    $t_user_id = mci_check_login($p_username, $p_password);
    if ($t_user_id === false) {
        return new soap_fault('Client', '', 'Access Denied', 'Username/password combination was incorrect');
    }
    if (!mci_has_administrator_access($t_user_id)) {
        return new soap_fault('Client', '', 'Access Denied', 'User does not have administrator access');
    }
    extract($p_version, EXTR_PREFIX_ALL, 'v');
    if (is_blank($v_project_id)) {
        return new soap_fault('Client', '', 'Mandatory field "project_id" was missing');
    }
    if (is_blank($v_name)) {
        return new soap_fault('Client', '', 'Mandatory field "name" was missing');
    }
    if (!version_is_unique($v_name, $v_project_id)) {
        return new soap_fault('Client', '', 'Version exists for project', 'The version you attempted to add already exists for this project');
    }
    if ($v_released === false) {
        $v_released = VERSION_FUTURE;
    } else {
        $v_released = VERSION_RELEASED;
    }
    if (version_add($v_project_id, $v_name, $v_released, $v_description)) {
        $t_version_id = version_get_id($v_name, $v_project_id);
        if (!is_blank($v_date_order)) {
            $t_version = version_get($t_version_id);
            $t_version->date_order = date("Y-m-d H:i:s", strtotime($v_date_order));
            version_update($t_version);
        }
        return $t_version_id;
    } else {
        return null;
    }
}
    $new_version_name_trimmed = trim(preg_replace('/\\s+/', ' ', $new_version_name));
    if (version_is_unique($new_version_name_trimmed, $project_id) && strlen($new_version_name_trimmed) > 0) {
        version_add($project_id, $new_version_name_trimmed, false, '', $new_version_date_timestamp);
    }
}
/**
 * Change all existing versions
 */
if ($update && isset($_POST['version_ids'])) {
    $version_ids = $_POST['version_ids'];
    $versions = $_POST['version'];
    $date_order = $_POST['date_order'];
    $type = $_POST['type'];
    $description = $_POST['description'];
    for ($version_index = 0; $version_index < count($version_ids); $version_index++) {
        $version = version_get($version_ids[$version_index]);
        $version_id = $version->id;
        $project_id = version_get_field($version_id, 'project_id');
        $released = null;
        $obsolete = null;
        if (isset($_POST['released' . $version_index])) {
            $released = $_POST['released' . $version_index];
        }
        if (isset($_POST['obsolete' . $version_index])) {
            $obsolete = $_POST['obsolete' . $version_index];
        }
        if (!is_null($versions)) {
            $new_version = $versions[$version_index];
            $version->version = trim($new_version);
        }
        if (is_null($released)) {
<?php

# Mantis - a php based bugtracking system
# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
# Copyright (C) 2002 - 2004  Mantis Team   - mantisbt-dev@lists.sourceforge.net
# This program is distributed under the terms and conditions of the GPL
# See the README and LICENSE files for details
# --------------------------------------------------------
# $Id: manage_proj_ver_delete.php,v 1.22 2004/12/14 20:37:07 marcelloscata Exp $
# --------------------------------------------------------
require_once 'core.php';
$t_core_path = config_get('core_path');
require_once $t_core_path . 'version_api.php';
$f_version_id = gpc_get_int('version_id');
$t_version_info = version_get($f_version_id);
$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $t_version_info->project_id;
access_ensure_project_level(config_get('manage_project_threshold'), $t_version_info->project_id);
# Confirm with the user
helper_ensure_confirmed(lang_get('version_delete_sure') . '<br/>' . lang_get('version') . ': ' . $t_version_info->version, lang_get('delete_version_button'));
version_remove($f_version_id);
html_page_top1();
html_meta_redirect($t_redirect_url);
html_page_top2();
?>
<br />
<div align="center">
<?php 
echo lang_get('operation_successful') . '<br />';
print_bracket_link($t_redirect_url, lang_get('proceed'));
?>
</div>
#
# You should have received a copy of the GNU General Public License
# along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.
/**
 * @package MantisBT
 * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
 * @copyright Copyright (C) 2002 - 2014  MantisBT Team - mantisbt-dev@lists.sourceforge.net
 * @link http://www.mantisbt.org
 */
/**
 * MantisBT Core API's
 */
require_once 'core.php';
auth_reauthenticate();
$f_version_id = gpc_get_int('version_id');
$t_version = version_get($f_version_id);
access_ensure_project_level(config_get('manage_project_threshold'), $t_version->project_id);
html_page_top();
print_manage_menu('manage_proj_ver_edit_page.php');
?>
<br />
<div align="center">
<form method="post" action="manage_proj_ver_update.php">
<?php 
echo form_security_field('manage_proj_ver_update');
?>
<input type="hidden" name="version_id" value="<?php 
echo string_attribute($t_version->id);
?>
" />
<table class="width50" cellspacing="1">
<?php

require_once SPECMANAGEMENT_CORE_URI . 'specmanagement_database_api.php';
auth_reauthenticate();
$specmanagement_database_api = new specmanagement_database_api();
$version_id = gpc_get_int('version_id');
$version = version_get($version_id);
access_ensure_project_level(config_get('manage_project_threshold'), $version->project_id);
helper_ensure_confirmed(lang_get('version_delete_sure') . '<br/>' . lang_get('word_separator') . string_display_line($version->version), lang_get('delete_version_button'));
$plugin_version_row = $specmanagement_database_api->get_plugin_version_row_by_version_id($version_id);
$p_version_id = $plugin_version_row[0];
$specmanagement_database_api->update_source_version_set_null($p_version_id);
$specmanagement_database_api->delete_version_row($version_id);
version_remove($version_id);
print_successful_redirect(plugin_page('manage_versions', true));
 /**
  * Print table body from directory
  *
  * @param $p_version_id
  * @param $work_packages
  * @param $no_work_package_bug_ids
  * @param $option_show_duration
  * @param $detail_flag
  * @param $print_flag
  */
 public function generate_content($p_version_id, $work_packages, $no_work_package_bug_ids, $option_show_duration, $detail_flag, $print_flag)
 {
     $specmanagement_database_api = new specmanagement_database_api();
     $directory_depth = $this->calculate_directory_depth($work_packages);
     $chapter_counter_array = $this->prepare_chapter_counter($directory_depth);
     $last_chapter_depth = 0;
     $version_id = $_POST['version_id'];
     $version = version_get($version_id);
     $version_date = $version->date_order;
     /** Iterate through defined work packages */
     if (!is_null($work_packages)) {
         foreach ($work_packages as $work_package) {
             if (strlen($work_package) > 0) {
                 $work_package_spec_bug_ids = $specmanagement_database_api->get_workpackage_spec_bugs($p_version_id, $work_package);
                 $chapters = explode('/', $work_package);
                 $chapter_depth = count($chapters);
                 if ($chapter_depth == 1) {
                     $this->reset_chapter_counter($chapter_counter_array);
                 }
                 $chapter_prefix_data = $this->generate_chapter_prefix($chapter_counter_array, $chapter_depth, $last_chapter_depth);
                 $chapter_counter_array = $chapter_prefix_data[0];
                 $chapter_prefix = $chapter_prefix_data[1];
                 $chapter_suffix = $this->generate_chapter_suffix($chapters, $chapter_depth);
                 $this->process_chapter($p_version_id, $work_package, $chapter_prefix, $chapter_suffix, $option_show_duration, $detail_flag, $print_flag);
                 $this->process_content($work_package_spec_bug_ids, $version_date, $chapter_prefix, $chapter_suffix, $option_show_duration, $detail_flag, $print_flag);
                 $last_chapter_depth = $chapter_depth;
             }
         }
     }
     /** Iterate through issues without defined work package */
     $chapter_prefix = $chapter_counter_array[0] + 1;
     $chapter_suffix = plugin_lang_get('editor_no_workpackage');
     if (count($no_work_package_bug_ids) > 0) {
         $this->process_chapter($p_version_id, '', $chapter_prefix, $chapter_suffix, $option_show_duration, $detail_flag, $print_flag);
         $this->process_content($no_work_package_bug_ids, $version_date, $chapter_prefix, $chapter_suffix, $option_show_duration, $detail_flag, $print_flag);
     }
 }
Example #11
0
 function update_version_acra_option($p_event, $p_arr)
 {
     if (isset($p_arr)) {
         if ($_FILES['map_file']['error'] > 0) {
             trigger_error(ERROR_PLUGIN_GENERIC, E_USER_ERROR);
         }
         $t_ver_data = version_get($p_arr);
         $t_acra_prj_table = plugin_table("project");
         $query = "SELECT * FROM {$t_acra_prj_table} WHERE project_id = " . $t_ver_data->project_id . " LIMIT 0,1";
         $result = db_query_bound($query);
         $result = db_fetch_array($result);
         $t_package_name = "";
         if ($result !== false && is_array($result)) {
             $t_package_name = $result['package_name'];
         }
         if (strlen($t_package_name) === 0) {
             trigger_error(ERROR_PLUGIN_GENERIC, E_USER_ERROR);
         }
         $t_map_name = array('upload', 'acra', $t_package_name, date("Y"));
         $file_name = str_ireplace('manage_proj_ver_update.php', '', $_SERVER['SCRIPT_FILENAME']);
         $file_name = $file_name . implode(DIRECTORY_SEPARATOR, $t_map_name);
         create_map_file_folder($file_name);
         $t_ver_name = preg_replace("^[ ?/\\\\]{1}^is", "_", $t_ver_data->version) . '.map';
         $file_name = $file_name . DIRECTORY_SEPARATOR . $t_ver_name;
         handle_mapping_file($_FILES['map_file']['tmp_name'], $file_name);
         $t_acra_ver_table = plugin_table("version");
         $query = "SELECT * FROM {$t_acra_ver_table} WHERE `version_id` = " . $p_arr . " LIMIT 0,1";
         $result = db_query_bound($query);
         $rows = $result->RowCount();
         $map = mysql_real_escape_string($file_name);
         if ($rows === 0) {
             $query = "INSERT INTO {$t_acra_ver_table} (`id`, `version_id`, `map_file`) VALUES (NULL, '{$p_arr}', '{$map}'); ";
         } else {
             $query = "UPDATE {$t_acra_ver_table} SET `map_file` = '{$map}' WHERE `version_id` = {$p_arr}; ";
         }
         db_query_bound($query);
         //update the title of bugs
         update_bug_summary_by_version($t_ver_data->version, $file_name);
     }
 }
/**
 * Print table body from directory
 *
 * @param $pdf
 * @param $p_version_id
 * @param $work_packages
 * @param $no_work_package_bug_ids
 * @param $option_show_duration
 * @param $detail_flag
 * @return Array
 */
function generate_content(PDF $pdf, $p_version_id, $work_packages, $no_work_package_bug_ids, $option_show_duration, $detail_flag)
{
    $specmanagement_database_api = new specmanagement_database_api();
    $specmanagement_editor_api = new specmanagement_editor_api();
    $directory_depth = $specmanagement_editor_api->calculate_directory_depth($work_packages);
    $chapter_counter_array = $specmanagement_editor_api->prepare_chapter_counter($directory_depth);
    $last_chapter_depth = 0;
    $version_id = $_POST['version_id'];
    $version = version_get($version_id);
    $version_date = $version->date_order;
    /** Iterate through defined work packages */
    if (!is_null($work_packages)) {
        foreach ($work_packages as $work_package) {
            if (strlen($work_package) > 0) {
                $work_package_spec_bug_ids = $specmanagement_database_api->get_workpackage_spec_bugs($p_version_id, $work_package);
                $chapters = explode('/', $work_package);
                $chapter_depth = count($chapters);
                if ($chapter_depth == 1) {
                    $specmanagement_editor_api->reset_chapter_counter($chapter_counter_array);
                }
                $chapter_prefix_data = $specmanagement_editor_api->generate_chapter_prefix($chapter_counter_array, $chapter_depth, $last_chapter_depth);
                $chapter_counter_array = $chapter_prefix_data[0];
                $chapter_prefix = $chapter_prefix_data[1];
                $chapter_suffix = $specmanagement_editor_api->generate_chapter_suffix($chapters, $chapter_depth);
                $chapter_duration = $specmanagement_database_api->get_workpackage_duration($p_version_id, $work_package);
                if ($detail_flag) {
                    $pdf->ChapterTitle($chapter_prefix, utf8_decode($chapter_suffix), $option_show_duration, $chapter_duration);
                } else {
                    $pdf->SetFont('Arial', 'B', 12);
                    $pdf->SetFillColor(255, 255, 255);
                    $pdf->Cell(95, 6, $chapter_prefix . ' ' . utf8_decode($chapter_suffix), 0, 0, 'L', 1);
                    $pdf->Cell(95, 6, $pdf->PageNo(), 0, 0, 'R', 1);
                    $pdf->SetFont('Arial', '', 12);
                    $pdf->Ln();
                }
                process_content($pdf, $work_package_spec_bug_ids, $version_date, $chapter_prefix, $option_show_duration, $detail_flag);
                $last_chapter_depth = $chapter_depth;
            }
            if ($detail_flag) {
                $pdf->Cell(0, 0, '', 'T');
            }
            $pdf->Ln(7);
        }
    }
    /** Iterate through issues without defined work package */
    $chapter_prefix = $chapter_counter_array[0] + 1;
    if (count($no_work_package_bug_ids) > 0) {
        $chapter_suffix = plugin_lang_get('editor_no_workpackage');
        $chapter_duration = $specmanagement_database_api->get_workpackage_duration($p_version_id, '');
        if ($detail_flag) {
            $pdf->ChapterTitle($chapter_prefix, utf8_decode($chapter_suffix), $option_show_duration, $chapter_duration);
        } else {
            $pdf->SetFont('Arial', 'B', 12);
            $pdf->SetFillColor(255, 255, 255);
            $pdf->Cell(0, 6, $chapter_prefix . ' ' . utf8_decode($chapter_suffix), 0, 0, 'L', 1);
            $pdf->SetFont('Arial', '', 12);
            $pdf->Ln();
        }
        process_content($pdf, $no_work_package_bug_ids, $version_date, $chapter_prefix, $option_show_duration, $detail_flag);
        if ($detail_flag) {
            $pdf->Cell(0, 0, '', 'T');
        }
        $pdf->Ln(7);
        $chapter_prefix++;
    }
    $content_package = array();
    $content_package[0] = $pdf;
    $content_package[1] = $chapter_prefix;
    return $content_package;
}