/**
 * @param $edit_page
 * @param $obsolete_flag
 */
function print_versions($edit_page, $obsolete_flag)
{
    $specmanagement_database_api = new specmanagement_database_api();
    $specmanagement_print_api = new specmanagement_print_api();
    $obsolote = false;
    if ($obsolete_flag) {
        $obsolote = null;
    }
    if ($edit_page) {
        $versions = version_get_all_rows_with_subs(helper_get_current_project(), null, null);
    } else {
        $versions = version_get_all_rows_with_subs(helper_get_current_project(), null, $obsolote);
    }
    for ($version_index = 0; $version_index < count($versions); $version_index++) {
        $version = $versions[$version_index];
        $current_type = $specmanagement_database_api->get_type_string($specmanagement_database_api->get_type_by_version($version['id']));
        $specmanagement_print_api->printRow();
        echo '<input type="hidden" name="version_ids[]" value="' . $version['id'] . '"/>';
        print_name($edit_page, $version);
        print_released($edit_page, $version_index, $version);
        print_obsolete($edit_page, $version_index, $version);
        print_date($edit_page, $version);
        print_type($edit_page, $current_type, $version);
        print_description($edit_page, $version);
        print_action($edit_page, $version);
        echo '</tr>';
    }
}
示例#2
0
    function renderIssues($status)
    {
        $content = array();
        $t_project_id = helper_get_current_project();
        $t_bug_table = db_get_table('mantis_bug_table');
        $t_user_id = auth_get_current_user_id();
        $specific_where = helper_project_specific_where($t_project_id, $t_user_id);
        if ($this->severity) {
            $severityCond = '= ' . $this->severity;
        } else {
            $severityCond = '> -1';
        }
        $query = "SELECT *\n\t\t\tFROM {$t_bug_table}\n\t\t\tWHERE {$specific_where}\n\t\t\tAND status = {$status}\n\t\t\tAND severity {$severityCond}\n\t\t\tORDER BY last_updated DESC\n\t\t\tLIMIT 20";
        $result = db_query_bound($query);
        $category_count = db_num_rows($result);
        for ($i = 0; $i < $category_count; $i++) {
            $row = db_fetch_array($result);
            //pre_var_dump($row);
            $content[] = '<div class="portlet ui-helper-clearfix" id="' . $row['id'] . '">
			<div class="portlet-header">' . string_get_bug_view_link($row['id']) . ': ' . $row['summary'] . '</div>
			<div class="portlet-content">' . ($row['reporter_id'] ? 'Reporter: ' . user_get_name($row['reporter_id']) . BR : '') . ($row['handler_id'] ? 'Assigned: ' . user_get_name($row['handler_id']) . BR : '') . '</div></div>';
        }
        if ($row) {
            //pre_var_dump(array_keys($row));
        }
        return $content;
    }
function get_closed_count_by_date($p_date)
{
    $t_project_id = helper_get_current_project();
    $d_arr = explode('/', $p_date);
    $p_date = $d_arr[2] . '-' . $d_arr[0] . '-' . $d_arr[1];
    $query = "SELECT COUNT(*)\r\n\t\t\t\tFROM mantis_bug_table\r\n\t\t\t\tWHERE last_updated<='{$p_date}' AND\r\n\t\t\t\t\tstatus='90' AND\r\n\t\t\t\t\tproject_id='{$t_project_id}'";
    $result = db_query($query);
    return db_result($result, 0, 0);
}
 function footer()
 {
     $t_project_id = helper_get_current_project();
     $t_user_id = auth_get_current_user_id();
     $t_user_has_level = user_get_access_level($t_user_id, $t_project_id) >= plugin_config_get('BackgroundImageAccessLevel', PLUGINS_BACKGROUNDIMAGEVIEW_THRESHOLD_LEVEL_DEFAULT);
     if (plugin_config_get('ShowInFooter') == 1 && $t_user_has_level) {
         return '<address>' . $this->name . ' ' . $this->version . ' Copyright &copy; 2015 by <a href="mailto://' . $this->contact . '">' . $this->author . '</a></address>';
     }
     return null;
 }
示例#5
0
/**
 * if all projects selected, default to <username>.csv, otherwise default to
 * <projectname>.csv.
 * @return string filename
 * @access public
 */
function csv_get_default_filename()
{
    $t_current_project_id = helper_get_current_project();
    if (ALL_PROJECTS == $t_current_project_id) {
        $t_filename = user_get_name(auth_get_current_user_id());
    } else {
        $t_filename = project_get_field($t_current_project_id, 'name');
    }
    return $t_filename . '.csv';
}
/**
 * Set overrides
 * @param string $p_config     Configuration value.
 * @param bool   $p_can_change True if user has access level to change config
 * @param string $p_color      CSS class name
 * @return void
 */
function set_overrides($p_config, $p_can_change, $p_color)
{
    global $g_overrides;
    if (!$p_can_change) {
        return;
    }
    $t_project = helper_get_current_project();
    if ($t_project == ALL_PROJECTS && $p_color == COLOR_GLOBAL || $t_project != ALL_PROJECTS && $p_color == COLOR_PROJECT) {
        $g_overrides[$p_config] = $p_config;
    }
}
 function add_columns()
 {
     $t_project_id = helper_get_current_project();
     $t_user_id = auth_get_current_user_id();
     $t_user_has_level = user_get_access_level($t_user_id, $t_project_id) >= plugin_config_get('RelationshipColumnAccessLevel', PLUGINS_RELATIONSHIPCOLUMNVIEW_THRESHOLD_LEVEL_DEFAULT);
     $t_result = array();
     if (plugin_config_get('ShowRelationshipColumn') == gpc_get_int('ShowRelationshipColumn', ON) && $t_user_has_level) {
         if ('1.2.' == substr(MANTIS_VERSION, 0, 4)) {
             require_once 'classes' . DIRECTORY_SEPARATOR . 'RelationshipColumn.class.1.2.0.php';
         } else {
             require_once 'classes' . DIRECTORY_SEPARATOR . 'RelationshipColumn.class.1.3.0.php';
         }
         $t_result[] = 'RelationshipColumn';
     }
     return $t_result;
 }
/**
 * @param $types
 */
function print_document_selection($types)
{
    $project_id = gpc_get_int('project_id', helper_get_current_project());
    $specmanagement_database_api = new specmanagement_database_api();
    echo '<select name="version_id">';
    foreach ($types as $type) {
        $type_string = string_html_specialchars($type);
        $type_id = $specmanagement_database_api->get_type_id($type);
        $version_id_array = get_version_ids($type_id, $project_id);
        foreach ($version_id_array as $version_id) {
            $version_spec_project_id = version_get_field($version_id, 'project_id');
            if (project_includes_user($version_spec_project_id, auth_get_current_user_id()) || user_is_administrator(auth_get_current_user_id())) {
                $version_string = version_full_name($version_id);
                echo '<option value="' . $version_id . '">';
                echo $type_string . " - " . $version_string;
                echo '</option>';
            }
        }
    }
    echo '</select>';
}
 function menu()
 {
     if (plugin_config_get('show_menu')) {
         require_once __DIR__ . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'wmApi.php';
         $projectId = helper_get_current_project();
         $userId = auth_get_current_user_id();
         $userAccessLevel = user_get_access_level($userId, $projectId);
         $whiteboardPlugins = wmApi::getWhiteboardPlugins();
         $showMenu = false;
         foreach ($whiteboardPlugins as $whiteboardPlugin) {
             $pluginAccessLevel = $whiteboardPlugin[2];
             if (user_is_administrator($userId) || $userAccessLevel >= $pluginAccessLevel) {
                 $showMenu = true;
                 break;
             }
         }
         if ($showMenu) {
             return '<a href="' . plugin_page('whiteboard_menu') . '">' . plugin_lang_get('menu_title') . '</a>';
         }
     }
     return null;
 }
示例#10
0
 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"];
         }
     }
 }
/**
 * Print table body
 * @param $status_cols
 */
function print_tbody($status_cols)
{
    $storyboard_db_api = new storyboard_db_api();
    $project_spec_bug_ids = $storyboard_db_api->get_bugarray_by_project(helper_get_current_project());
    $types = $storyboard_db_api->select_all_types();
    echo '<tbody>';
    foreach ($types as $type) {
        echo '<tr>';
        echo '<td class="category">' . $type[1] . '</td>';
        foreach ($status_cols as $status_col) {
            echo '<td class="story_baord">';
            foreach ($project_spec_bug_ids as $project_spec_bug_id) {
                $card = $storyboard_db_api->select_story_card($project_spec_bug_id);
                if ($card[2] == $type[0]) {
                    $bug_status = bug_get_field($project_spec_bug_id, 'status');
                    if ($bug_status == $status_col) {
                        echo '<a href="' . string_get_bug_view_url($project_spec_bug_id) . '" class="rcv_tooltip">';
                        echo '<div class="story_card">';
                        echo string_display_line(bug_format_id($project_spec_bug_id));
                        echo '<span>';
                        print_story_card_title($project_spec_bug_id);
                        print_story_card_info('summary', bug_get_field($project_spec_bug_id, 'summary'), false);
                        print_story_card_info('description', bug_get_text_field($project_spec_bug_id, 'description'), false);
                        print_story_card_info('card_risk', $card[3], true);
                        print_story_card_info('card_story_pt', $card[4], true);
                        print_story_card_info('card_story_pt_post', $card[5], true);
                        print_story_card_info('card_acc_crit', $card[6], true);
                        echo '</span>';
                        echo '</div>';
                        echo '</a><br/><br/><br/>';
                    }
                }
            }
            echo '</td>';
        }
        echo '</tr>';
    }
    echo '</tbody>';
}
示例#12
0
/**
 * Get list of affected issues between a given time period
 * @param integer $p_start_time Timestamp representing start time of the period.
 * @param integer $p_end_time   Timestamp representing end time of the period.
 * @return array
 */
function timeline_get_affected_issues($p_start_time, $p_end_time)
{
    $t_query = 'SELECT DISTINCT(bug_id) from {bug_history} WHERE date_modified >= ' . db_param() . ' AND date_modified < ' . db_param();
    $t_result = db_query($t_query, array($p_start_time, $p_end_time));
    $t_current_project = helper_get_current_project();
    $t_all_issue_ids = array();
    while (($t_row = db_fetch_array($t_result)) !== false) {
        $t_all_issue_ids[] = $t_row['bug_id'];
    }
    bug_cache_array_rows($t_all_issue_ids);
    $t_issue_ids = array();
    foreach ($t_all_issue_ids as $t_issue_id) {
        if ($t_current_project != ALL_PROJECTS && $t_current_project != bug_get_field($t_issue_id, 'project_id')) {
            continue;
        }
        if (!access_has_bug_level(config_get('view_bug_threshold'), $t_issue_id)) {
            continue;
        }
        $t_issue_ids[] = $t_issue_id;
    }
    return $t_issue_ids;
}
示例#13
0
 /**
  * print menu entrys for each plugin
  */
 public static function printWhiteboardMenu()
 {
     $projectId = helper_get_current_project();
     $userId = auth_get_current_user_id();
     $userAccessLevel = user_get_access_level($userId, $projectId);
     $whiteboardPlugins = self::getWhiteboardPlugins();
     $whiteboardPluginCount = count($whiteboardPlugins);
     echo '<div class="table">';
     for ($index = 0; $index < $whiteboardPluginCount; $index++) {
         $whiteboardPlugin = $whiteboardPlugins[$index];
         $plugin = $whiteboardPlugin[1];
         $pluginAccessLevel = $whiteboardPlugin[2];
         $pluginShowMenu = $whiteboardPlugin[3];
         if ((user_is_administrator($userId) || $userAccessLevel >= $pluginAccessLevel) && $pluginShowMenu == 1) {
             if ($index > 0) {
                 echo '<div class="item">&nbsp;|&nbsp;</div>';
             }
             $pluginLink = $whiteboardPlugin[4];
             echo '<div class="item"><a href="' . $pluginLink . '">' . plugin_lang_get('menu_title', $plugin) . '</a></div>';
         }
     }
     echo '</div>';
 }
示例#14
0
function print_project_user_list_option_list($p_project_id = null)
{
    $t_mantis_project_user_list_table = db_get_table('mantis_project_user_list_table');
    $t_mantis_user_table = db_get_table('mantis_user_table');
    if (null === $p_project_id) {
        $p_project_id = helper_get_current_project();
    }
    $c_project_id = (int) $p_project_id;
    $t_adm = config_get_global('admin_site_threshold');
    $query = "SELECT DISTINCT u.id, u.username, u.realname\n\t\t\t\tFROM {$t_mantis_user_table} u\n\t\t\t\tLEFT JOIN {$t_mantis_project_user_list_table} p\n\t\t\t\tON p.user_id=u.id AND p.project_id=" . db_param() . "\n\t\t\t\tWHERE u.access_level<" . db_param() . " AND\n\t\t\t\t\tu.enabled = " . db_param() . " AND\n\t\t\t\t\tp.user_id IS NULL\n\t\t\t\tORDER BY u.realname, u.username";
    $result = db_query_bound($query, array($c_project_id, $t_adm, true));
    $t_display = array();
    $t_sort = array();
    $t_users = array();
    $t_show_realname = ON == config_get('show_realname');
    $t_sort_by_last_name = ON == config_get('sort_by_last_name');
    $category_count = db_num_rows($result);
    for ($i = 0; $i < $category_count; $i++) {
        $row = db_fetch_array($result);
        $t_users[] = $row['id'];
        $t_user_name = string_attribute($row['username']);
        $t_sort_name = $t_user_name;
        if (isset($row['realname']) && $row['realname'] != '' && $t_show_realname) {
            $t_user_name = string_attribute($row['realname']);
            if ($t_sort_by_last_name) {
                $t_sort_name_bits = explode(' ', utf8_strtolower($t_user_name), 2);
                $t_sort_name = (isset($t_sort_name_bits[1]) ? $t_sort_name_bits[1] . ', ' : '') . $t_sort_name_bits[0];
            } else {
                $t_sort_name = utf8_strtolower($t_user_name);
            }
        }
        $t_display[] = $t_user_name;
        $t_sort[] = $t_sort_name;
    }
    array_multisort($t_sort, SORT_ASC, SORT_STRING, $t_users, $t_display);
    $t_count = count($t_sort);
    for ($i = 0; $i < $t_count; $i++) {
        echo '<option value="' . $t_users[$i] . '">' . $t_display[$i] . '</option>';
    }
}
示例#15
0
/**
 * Note: any changes made in this function should be reflected in
 * mci_filter_db_get_available_queries())
 * @param integer $p_project_id A valid project identifier.
 * @param integer $p_user_id    A valid user identifier.
 * @return mixed
 */
function filter_db_get_available_queries($p_project_id = null, $p_user_id = null)
{
    $t_overall_query_arr = array();
    if (null === $p_project_id) {
        $t_project_id = helper_get_current_project();
    } else {
        $t_project_id = (int) $p_project_id;
    }
    if (null === $p_user_id) {
        $t_user_id = auth_get_current_user_id();
    } else {
        $t_user_id = (int) $p_user_id;
    }
    # If the user doesn't have access rights to stored queries, just return
    if (!access_has_project_level(config_get('stored_query_use_threshold'))) {
        return $t_overall_query_arr;
    }
    # Get the list of available queries. By sorting such that public queries are
    # first, we can override any query that has the same name as a private query
    # with that private one
    $t_query = 'SELECT * FROM {filters}
					WHERE (project_id=' . db_param() . '
						OR project_id=0)
					AND name!=\'\'
					AND (is_public = ' . db_param() . '
						OR user_id = ' . db_param() . ')
					ORDER BY is_public DESC, name ASC';
    $t_result = db_query($t_query, array($t_project_id, true, $t_user_id));
    while ($t_row = db_fetch_array($t_result)) {
        $t_overall_query_arr[$t_row['id']] = $t_row['name'];
    }
    $t_overall_query_arr = array_unique($t_overall_query_arr);
    asort($t_overall_query_arr);
    return $t_overall_query_arr;
}
示例#16
0
 * @link http://www.mantisbt.org
 */
/**
 * MantisBT Core API's
 */
require_once 'core.php';
require_once 'news_api.php';
require_once 'print_api.php';
news_ensure_enabled();
form_security_validate('news_add');
access_ensure_project_level(config_get('manage_news_threshold'));
$f_view_state = gpc_get_int('view_state');
$f_headline = gpc_get_string('headline');
$f_announcement = gpc_get_bool('announcement');
$f_body = gpc_get_string('body');
$t_news_id = news_create(helper_get_current_project(), auth_get_current_user_id(), $f_view_state, $f_announcement, $f_headline, $f_body);
form_security_purge('news_add');
$t_news_row = news_get_row($t_news_id);
html_page_top();
?>

<br />
<div align="center">
<?php 
echo lang_get('operation_successful') . '<br />';
print_bracket_link('news_menu_page.php', lang_get('proceed'));
echo '<br /><br />';
print_news_entry_from_row($t_news_row);
?>
</div>
示例#17
0
function helper_get_default_export_filename($p_extension_with_dot, $p_prefix = '', $p_suffix = '')
{
    $t_filename = $p_prefix;
    $t_current_project_id = helper_get_current_project();
    if (ALL_PROJECTS == $t_current_project_id) {
        $t_filename .= user_get_name(auth_get_current_user_id());
    } else {
        $t_filename .= project_get_field($t_current_project_id, 'name');
    }
    return $t_filename . $p_suffix . $p_extension_with_dot;
}
示例#18
0
function print_column_category($p_row, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE)
{
    global $t_sort, $t_dir;
    # grab the project name
    $t_project_name = project_get_field($p_row['project_id'], 'name');
    echo '<td class="center">';
    # type project name if viewing 'all projects' or if issue is in a subproject
    if (ON == config_get('show_bug_project_links') && helper_get_current_project() != $p_row['project_id']) {
        echo '<small>[';
        print_view_bug_sort_link($t_project_name, 'project_id', $t_sort, $t_dir, $p_columns_target);
        echo ']</small><br />';
    }
    echo string_display($p_row['category']);
    echo '</td>';
}
示例#19
0
 public function process(XMLreader $reader)
 {
     //print "\nImportIssue process()\n";
     $t_project_id = helper_get_current_project();
     // TODO: category_get_id_by_name could work by default on current project
     $userId = auth_get_current_user_id();
     $t_custom_fields = array();
     $t_bugnotes = array();
     $t_attachments = array();
     $depth = $reader->depth;
     while ($reader->read() && ($reader->depth > $depth || $reader->nodeType != XMLReader::END_ELEMENT)) {
         if ($reader->nodeType == XMLReader::ELEMENT) {
             switch ($reader->localName) {
                 case 'reporter':
                     $t_old_id = $reader->getAttribute('id');
                     $reader->read();
                     $this->newbug_->reporter_id = $this->get_user_id($reader->value, $userId);
                     //echo "reporter: old id = $t_old_id - new id = {$this->newbug_->reporter_id}\n";
                     break;
                 case 'handler':
                     $t_old_id = $reader->getAttribute('id');
                     $reader->read();
                     $this->newbug_->handler_id = $this->get_user_id($reader->value, $userId);
                     //echo "handler: old id = $t_old_id - new id = {$this->newbug_->handler_id}\n";
                     break;
                 case 'category':
                     $this->newbug_->category_id = $this->defaultCategory_;
                     if (version_compare(MANTIS_VERSION, '1.2', '>') === true) {
                         $reader->read();
                         if ($this->keepCategory_) {
                             # Check for the category's existence in the current project
                             # well as its parents (if any)
                             $t_projects_hierarchy = project_hierarchy_inheritance($t_project_id);
                             foreach ($t_projects_hierarchy as $t_project) {
                                 $t_category_id = category_get_id_by_name($reader->value, $t_project, false);
                                 if ($t_category_id !== false) {
                                     $this->newbug_->category_id = $t_category_id;
                                     break;
                                 }
                             }
                         }
                         //	echo "new id = {$this->newbug_->category_id}\n";
                     }
                     break;
                 case 'eta':
                 case 'priority':
                 case 'projection':
                 case 'reproducibility':
                 case 'resolution':
                 case 'severity':
                 case 'status':
                 case 'view_state':
                     $t_field = $reader->localName;
                     $t_id = $reader->getAttribute('id');
                     $reader->read();
                     $t_value = $reader->value;
                     // Here we assume ids have the same meaning in both installations
                     // TODO add a check for customized values
                     $this->newbug_->{$t_field} = $t_id;
                     break;
                 case 'id':
                     $reader->read();
                     $this->old_id_ = $reader->value;
                     break;
                 case 'project':
                     // ignore original value, use current project
                     $this->newbug_->project_id = $t_project_id;
                     break;
                 case 'custom_fields':
                     // store custom fields
                     $i = -1;
                     $depth_cf = $reader->depth;
                     while ($reader->read() && ($reader->depth > $depth_cf || $reader->nodeType != XMLReader::END_ELEMENT)) {
                         if ($reader->nodeType == XMLReader::ELEMENT) {
                             if ($reader->localName == 'custom_field') {
                                 $t_custom_fields[++$i] = new stdClass();
                             }
                             switch ($reader->localName) {
                                 default:
                                     $field = $reader->localName;
                                     $reader->read();
                                     $t_custom_fields[$i]->{$field} = $reader->value;
                             }
                         }
                     }
                     break;
                 case 'bugnotes':
                     // store bug notes
                     $i = -1;
                     $depth_bn = $reader->depth;
                     while ($reader->read() && ($reader->depth > $depth_bn || $reader->nodeType != XMLReader::END_ELEMENT)) {
                         if ($reader->nodeType == XMLReader::ELEMENT) {
                             if ($reader->localName == 'bugnote') {
                                 $t_bugnotes[++$i] = new stdClass();
                             }
                             switch ($reader->localName) {
                                 case 'reporter':
                                     $t_old_id = $reader->getAttribute('id');
                                     $reader->read();
                                     $t_bugnotes[$i]->reporter_id = $this->get_user_id($reader->value, $userId);
                                     break;
                                 case 'view_state':
                                     $t_old_id = $reader->getAttribute('id');
                                     $reader->read();
                                     $t_bugnotes[$i]->private = $reader->value == VS_PRIVATE ? true : false;
                                     break;
                                 default:
                                     $field = $reader->localName;
                                     $reader->read();
                                     $t_bugnotes[$i]->{$field} = $reader->value;
                             }
                         }
                     }
                     break;
                 case 'attachments':
                     // store attachments
                     $i = -1;
                     $depth_att = $reader->depth;
                     while ($reader->read() && ($reader->depth > $depth_att || $reader->nodeType != XMLReader::END_ELEMENT)) {
                         if ($reader->nodeType == XMLReader::ELEMENT) {
                             if ($reader->localName == 'attachment') {
                                 $t_attachments[++$i] = new stdClass();
                             }
                             switch ($reader->localName) {
                                 default:
                                     $field = $reader->localName;
                                     $reader->read();
                                     $t_attachments[$i]->{$field} = $reader->value;
                             }
                         }
                     }
                     break;
                 default:
                     $field = $reader->localName;
                     //echo "using default handler for field: $field\n";
                     $reader->read();
                     $this->newbug_->{$field} = $reader->value;
             }
         }
     }
     // now save the new bug
     $this->new_id_ = $this->newbug_->create();
     // add custom fields
     if ($this->new_id_ > 0 && is_array($t_custom_fields) && count($t_custom_fields) > 0) {
         foreach ($t_custom_fields as $t_custom_field) {
             $t_custom_field_id = custom_field_get_id_from_name($t_custom_field->name);
             if (custom_field_ensure_exists($t_custom_field_id) && custom_field_is_linked($t_custom_field_id, $t_project_id)) {
                 custom_field_set_value($t_custom_field->id, $this->new_id_, $t_custom_field->value);
             } else {
                 error_parameters($t_custom_field->name, $t_custom_field_id);
                 trigger_error(ERROR_CUSTOM_FIELD_NOT_LINKED_TO_PROJECT, ERROR);
             }
         }
     }
     // add bugnotes
     if ($this->new_id_ > 0 && is_array($t_bugnotes) && count($t_bugnotes) > 0) {
         foreach ($t_bugnotes as $t_bugnote) {
             bugnote_add($this->new_id_, $t_bugnote->note, $t_bugnote->time_tracking, $t_bugnote->private, $t_bugnote->note_type, $t_bugnote->note_attr, $t_bugnote->reporter_id, false, $t_bugnote->date_submitted, $t_bugnote->last_modified, true);
         }
     }
     // add attachments
     if ($this->new_id_ > 0 && is_array($t_attachments) && count($t_attachments) > 0) {
         foreach ($t_attachments as $t_attachment) {
             // Create a temporary file in the temporary files directory using sys_get_temp_dir()
             $temp_file_name = tempnam(sys_get_temp_dir(), 'MantisImport');
             file_put_contents($temp_file_name, base64_decode($t_attachment->content));
             $file_data = array('name' => $t_attachment->filename, 'type' => $t_attachment->file_type, 'tmp_name' => $temp_file_name, 'size' => filesize($temp_file_name), 'error' => UPLOAD_ERR_OK);
             // unfortunately we have no clue who has added the attachment (this could only be fetched from history -> feel free to implement this)
             // also I have no clue where description should come from...
             file_add($this->new_id_, $file_data, 'bug', $t_attachment->title, $p_desc = '', $p_user_id = null, $t_attachment->date_added, true);
             unlink($temp_file_name);
         }
     }
     //echo "\nnew bug: $this->new_id_\n";
 }
示例#20
0
/**
 * print build option list
 * @param string $p_build The current build value.
 * @return void
 */
function print_build_option_list($p_build = '')
{
    $t_overall_build_arr = array();
    $t_project_id = helper_get_current_project();
    $t_project_where = helper_project_specific_where($t_project_id);
    # Get the "found in" build list
    $t_query = 'SELECT DISTINCT build
				FROM {bug}
				WHERE ' . $t_project_where . '
				ORDER BY build DESC';
    $t_result = db_query($t_query);
    while ($t_row = db_fetch_array($t_result)) {
        $t_overall_build_arr[] = $t_row['build'];
    }
    $t_max_length = config_get('max_dropdown_length');
    foreach ($t_overall_build_arr as $t_build_unescaped) {
        $t_build = string_attribute($t_build_unescaped);
        echo '<option value="' . $t_build . '"';
        check_selected($p_build, $t_build_unescaped);
        echo '>' . string_shorten($t_build, $t_max_length) . '</option>';
    }
}
示例#21
0
form_security_validate($t_form_name);
$t_custom_group_actions = config_get('custom_group_actions');
foreach ($t_custom_group_actions as $t_custom_group_action) {
    if ($f_action == $t_custom_group_action['action']) {
        require_once $t_custom_group_action['action_page'];
        exit;
    }
}
$t_failed_ids = array();
if (0 != $f_custom_field_id) {
    $t_custom_field_def = custom_field_get_definition($f_custom_field_id);
}
foreach ($f_bug_arr as $t_bug_id) {
    bug_ensure_exists($t_bug_id);
    $t_bug = bug_get($t_bug_id, true);
    if ($t_bug->project_id != helper_get_current_project()) {
        # in case the current project is not the same project of the bug we are viewing...
        # ... override the current project. This to avoid problems with categories and handlers lists etc.
        $g_project_override = $t_bug->project_id;
        # @todo (thraxisp) the next line goes away if the cache was smarter and used project
        config_flush_cache();
        # flush the config cache so that configs are refetched
    }
    $t_status = $t_bug->status;
    switch ($f_action) {
        case 'CLOSE':
            $t_closed = config_get('bug_closed_status_threshold');
            if (access_can_close_bug($t_bug)) {
                if ($t_status < $t_closed && bug_check_workflow($t_status, $t_closed)) {
                    # @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $f_bug_id, $t_bug_data, $f_bugnote_text ) );
                    bug_close($t_bug_id, $f_bug_notetext, $f_bug_noteprivate);
示例#22
0
/**
 * Print column content for column target version
 *
 * @param BugData $p_bug bug object
 * @param int $p_columns_target see COLUMNS_TARGET_* in constant_inc.php
 * @return null
 * @access public
 */
function print_column_target_version($p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE)
{
    echo '<td class="column-target-version">';
    # In case of a specific project, if the current user has no access to the field, then it would have been excluded from the
    # list of columns to view.  In case of ALL_PROJECTS, then we need to check the access per row.
    if (helper_get_current_project() != ALL_PROJECTS || access_has_project_level(config_get('roadmap_view_threshold'), $p_bug->project_id)) {
        echo string_display_line($p_bug->target_version);
    }
    echo '</td>';
}
示例#23
0
/**
 * Check the current user's access against the given value and return true
 * if the user's access is equal to or higher, false otherwise.
 * @param int $p_access_level integer representing access level
 * @param int $p_project_id integer representing project id to check access against
 * @param int|null $p_user_id integer representing user id, defaults to null to use current user
 * @return bool whether user has access level specified
 * @access public
 */
function access_has_project_level($p_access_level, $p_project_id = null, $p_user_id = null)
{
    # Short circuit the check in this case
    if (NOBODY == $p_access_level) {
        return false;
    }
    if (null === $p_user_id) {
        $p_user_id = auth_get_current_user_id();
    }
    if (null === $p_project_id) {
        $p_project_id = helper_get_current_project();
    }
    $t_access_level = access_get_project_level($p_project_id, $p_user_id);
    return access_compare_level($t_access_level, $p_access_level);
}
示例#24
0
$t_show_severity = in_array('severity', $t_fields);
$t_show_priority = in_array('priority', $t_fields);
$t_show_steps_to_reproduce = in_array('steps_to_reproduce', $t_fields);
$t_show_handler = in_array('handler', $t_fields) && access_has_project_level(config_get('update_bug_assign_threshold'));
$t_show_profiles = config_get('enable_profiles');
$t_show_platform = $t_show_profiles && in_array('platform', $t_fields);
$t_show_os = $t_show_profiles && in_array('os', $t_fields);
$t_show_os_version = $t_show_profiles && in_array('os_version', $t_fields);
$t_show_resolution = in_array('resolution', $t_fields);
$t_show_status = in_array('status', $t_fields);
$t_show_versions = version_should_show_product_version($t_project_id);
$t_show_product_version = $t_show_versions && in_array('product_version', $t_fields);
$t_show_product_build = $t_show_versions && in_array('product_build', $t_fields) && config_get('enable_product_build') == ON;
$t_show_target_version = $t_show_versions && in_array('target_version', $t_fields) && access_has_project_level(config_get('roadmap_update_threshold'));
$t_show_additional_info = in_array('additional_info', $t_fields);
$t_show_due_date = in_array('due_date', $t_fields) && access_has_project_level(config_get('due_date_update_threshold'), helper_get_current_project(), auth_get_current_user_id());
$t_show_attachments = in_array('attachments', $t_fields) && file_allow_bug_upload();
$t_show_view_state = in_array('view_state', $t_fields) && access_has_project_level(config_get('set_view_status_threshold'));
if ($t_show_due_date) {
    require_js('jscalendar/calendar.js');
    require_js('jscalendar/lang/calendar-en.js');
    require_js('jscalendar/calendar-setup.js');
    require_css('calendar-blue.css');
}
# don't index bug report page
html_robots_noindex();
html_page_top(lang_get('report_bug_link'));
print_recently_visited();
$t_form_encoding = '';
if ($t_show_attachments) {
    $t_form_encoding = 'enctype="multipart/form-data"';
示例#25
0
require_api('constant_inc.php');
require_api('helper_api.php');
require_api('html_api.php');
require_api('lang_api.php');
require_api('news_api.php');
require_api('print_api.php');
require_api('string_api.php');
news_ensure_enabled();
access_ensure_project_level(VIEWER);
html_page_top();
?>

<br />
<?php 
# Select the news posts
$rows = news_get_rows(helper_get_current_project());
$t_count = count($rows);
if ($t_count > 0) {
    ?>
	<ul><?php 
    # Loop through results
    for ($i = 0; $i < $t_count; $i++) {
        extract($rows[$i], EXTR_PREFIX_ALL, 'v');
        if (VS_PRIVATE == $v_view_state && !access_has_project_level(config_get('private_news_threshold'), $v_project_id)) {
            continue;
        }
        $v_headline = string_display($v_headline);
        $v_date_posted = date(config_get('complete_date_format'), $v_date_posted);
        ?>
		<li>
			<span class="news-date-posted"><?php 
示例#26
0
print lang_get('query_name_label') . lang_get('word_separator');
?>
<form method="post" action="query_store.php">
<?php 
echo form_security_field('query_store');
?>
<input type="text" name="query_name" /><br />
<?php 
if (access_has_project_level(config_get('stored_query_create_shared_threshold'))) {
    print '<input type="checkbox" name="is_public" value="on" /> ';
    print lang_get('make_public');
    print '<br />';
}
?>
<input type="checkbox" name="all_projects" value="on" <?php 
check_checked(ALL_PROJECTS == helper_get_current_project());
?>
 >
<?php 
print lang_get('all_projects');
?>
<br /><br />
<input type="submit" class="button" value="<?php 
print lang_get('save_query');
?>
" />
</form>
<form action="view_all_bug_page.php">
<?php 
# CSRF protection not required here - form does not result in modifications
?>
示例#27
0
function print_build_option_list($p_build = '')
{
    $t_bug_table = db_get_table('bug');
    $t_overall_build_arr = array();
    $t_project_id = helper_get_current_project();
    $t_project_where = helper_project_specific_where($t_project_id);
    # Get the "found in" build list
    $query = "SELECT DISTINCT build\n\t\t\t\tFROM {$t_bug_table}\n\t\t\t\tWHERE {$t_project_where}\n\t\t\t\tORDER BY build DESC";
    $result = db_query_bound($query);
    $option_count = db_num_rows($result);
    for ($i = 0; $i < $option_count; $i++) {
        $row = db_fetch_array($result);
        $t_overall_build_arr[] = $row['build'];
    }
    $t_max_length = config_get('max_dropdown_length');
    foreach ($t_overall_build_arr as $t_build_unescaped) {
        $t_build = string_attribute($t_build_unescaped);
        echo "<option value=\"{$t_build}\"";
        check_selected($p_build, $t_build_unescaped);
        echo ">" . string_shorten($t_build, $t_max_length) . "</option>";
    }
}
示例#28
0
require_api('current_user_api.php');
require_api('database_api.php');
require_api('event_api.php');
require_api('helper_api.php');
require_api('lang_api.php');
require_api('prepare_api.php');
require_api('print_api.php');
require_api('string_api.php');
require_api('user_api.php');
# grab the user id currently logged in
$t_user_id = auth_get_current_user_id();
#precache access levels
if (isset($g_project_override)) {
    access_cache_matrix_project($g_project_override);
} else {
    access_cache_matrix_project(helper_get_current_project());
}
# get the bugnote data
$t_bugnote_order = current_user_get_pref('bugnote_order');
$t_bugnotes = bugnote_get_all_visible_bugnotes($f_bug_id, $t_bugnote_order, 0, $t_user_id);
#precache users
$t_bugnote_users = array();
foreach ($t_bugnotes as $t_bugnote) {
    $t_bugnote_users[] = $t_bugnote->reporter_id;
}
user_cache_array_rows($t_bugnote_users);
$num_notes = count($t_bugnotes);
?>

<?php 
# Bugnotes BEGIN
$f_dir = null;
$t_project_id = 0;
$t_columns = helper_get_columns_to_view(COLUMNS_TARGET_PRINT_PAGE);
$t_num_of_columns = count($t_columns);
# check to see if the cookie exists
if (!is_blank($t_cookie_value)) {
    # check to see if new cookie is needed
    if (!filter_is_cookie_valid()) {
        print_header_redirect('view_all_set.php?type=0&print=1');
    }
    $t_setting_arr = explode('#', $t_cookie_value, 2);
    $t_filter_cookie_arr = unserialize($t_setting_arr[1]);
    $f_highlight_changed = $t_filter_cookie_arr[FILTER_PROPERTY_HIGHLIGHT_CHANGED];
    $f_sort = $t_filter_cookie_arr[FILTER_PROPERTY_SORT_FIELD_NAME];
    $f_dir = $t_filter_cookie_arr[FILTER_PROPERTY_SORT_DIRECTION];
    $t_project_id = helper_get_current_project();
}
# This replaces the actual search that used to be here
$f_page_number = gpc_get_int('page_number', 1);
$t_per_page = -1;
$t_bug_count = null;
$t_page_count = null;
$result = filter_get_bug_rows($f_page_number, $t_per_page, $t_page_count, $t_bug_count);
$row_count = count($result);
# pre-cache custom column data
columns_plugin_cache_issue_data($result);
# for export
$t_show_flag = gpc_get_int('show_flag', 0);
html_page_top1();
html_head_end();
html_body_begin();
示例#30
0
function news_get_limited_rows($p_offset, $p_project_id = null)
{
    if ($p_project_id === null) {
        $p_project_id = helper_get_current_project();
    }
    $c_offset = db_prepare_int($p_offset);
    $t_projects = current_user_get_all_accessible_subprojects($p_project_id);
    $t_projects[] = (int) $p_project_id;
    if (ALL_PROJECTS != $p_project_id) {
        $t_projects[] = ALL_PROJECTS;
    }
    $t_news_table = db_get_table('mantis_news_table');
    $t_news_view_limit = config_get('news_view_limit');
    $t_news_view_limit_days = config_get('news_view_limit_days') * SECONDS_PER_DAY;
    switch (config_get('news_limit_method')) {
        case 0:
            # BY_LIMIT - Select the news posts
            $query = "SELECT *\n\t\t\t\t\t\tFROM {$t_news_table}";
            if (1 == count($t_projects)) {
                $c_project_id = $t_projects[0];
                $query .= " WHERE project_id='{$c_project_id}'";
            } else {
                $query .= ' WHERE project_id IN (' . join($t_projects, ',') . ')';
            }
            $query .= ' ORDER BY announcement DESC, id DESC';
            $result = db_query($query, $t_news_view_limit, $c_offset);
            break;
        case 1:
            # BY_DATE - Select the news posts
            $query = "SELECT *\n\t\t\t\t\t\tFROM {$t_news_table} WHERE\n\t\t\t\t\t\t( " . db_helper_compare_days(0, 'date_posted', "< {$t_news_view_limit_days}") . "\n\t\t\t\t\t\t OR announcement = " . db_param() . " ) ";
            $t_params = array(db_now(), 1);
            if (1 == count($t_projects)) {
                $c_project_id = $t_projects[0];
                $query .= " AND project_id=" . db_param();
                $t_params[] = $c_project_id;
            } else {
                $query .= ' AND project_id IN (' . join($t_projects, ',') . ')';
            }
            $query .= " ORDER BY announcement DESC, id DESC";
            $result = db_query_bound($query, $t_params, $t_news_view_limit, $c_offset);
            break;
    }
    # end switch
    $t_row_count = db_num_rows($result);
    $t_rows = array();
    for ($i = 0; $i < $t_row_count; $i++) {
        $row = db_fetch_array($result);
        array_push($t_rows, $row);
    }
    return $t_rows;
}