Mantis-如何导出自定义字段的值


西西的博客

Mantis-如何导出自定义字段的值
关键词: 自定义字段导出                                          
大家在使用mantis提供的通用report报表的时候,有时候就会使用自定义字段的功能,使得表单的功能更符合实际,可是使用自定义字段,却有害怕在数据导出的时候会出现这些字段值得丢失,这让人感觉比较矛盾。没关系,以下篇章说明如何导出自定义字段的值,这会让你觉得使用起来会很简单。
1.         首先当然是根据你的需要自定义字段。
在菜单[ 管理 ]à[ 自定义字段管理 ]
进入自定义字段管理页面,新增所需的新字段,可选择其字段类型,默认值以及一些条件等等,点击确认就OK。
2.         进入[ 管理 ]à[ 项目管理 ],将所需的自定义字段添加到该项目里。
3.         这时候需要进入正题了,默认情况下,自定义字段是不会被导出的,据说是在Mantis1.1版本会增加这样的修改。现在我们要做的就是:
打开Mantis目录下的Core目录里面的custom_function_api.php,找个合适的地方(可添至原来代码最后)将以下的代码添加到里面就OK了。
#
-----------------------------------------------------------------------------------------------

function custom_function_override_get_columns_to_view( $p_columns_target =
COLUMNS_TARGET_VIEW_PAGE ) {
$t_columns = array();
 
if ( $p_columns_target == COLUMNS_TARGET_CSV_PAGE ) {
$t_columns[] = 'id'; // localized: 'id',
$t_columns[] = 'project_id'; // 'email_project'
$t_columns[] = 'reporter_id'; // 'reporter'
$t_columns[] = 'handler_id'; // 'assigned_to'
$t_columns[] = 'priority'; // 'priority'
$t_columns[] = 'severity'; // 'severity'
$t_columns[] = 'reproducibility'; // 'reproducibility'
$t_columns[] = 'version'; // 'version'
$t_columns[] = 'projection'; // 'projection'
$t_columns[] = 'category'; // 'category'
$t_columns[] = 'date_submitted'; // 'date_submitted'
$t_columns[] = 'eta'; // 'eta'
$t_columns[] = 'os'; // 'os'
$t_columns[] = 'os_build'; // 'os_version'
$t_columns[] = 'platform'; // 'platform'
$t_columns[] = 'view_state'; // 'view_status'
$t_columns[] = 'last_updated'; // 'last_update'
$t_columns[] = 'summary'; // 'summary'
$t_columns[] = 'status'; // 'status'
$t_columns[] = 'resolution'; // 'resolution'
$t_columns[] = 'fixed_in_version'; // 'fixed_in_version';
 
 
# if viewing only one Project, Add all custom fields linked to this project
if ( helper_get_current_project() != ALL_PROJECTS ) {
$t_custom_fields = custom_field_get_linked_ids(helper_get_current_project());
 
foreach( $t_custom_fields as $t_field_id ) {
$t_desc = custom_field_get_definition( $t_field_id );
 
$t_columns[] = 'custom_' . $t_desc['name'];
}
}
 
 
if ( OFF == config_get( 'enable_relationship' ) ) {
$t_columns[] = 'duplicate_id'; // 'duplicate_id'
}
} else {
$t_columns[] = 'selection';
 
if ( $p_columns_target == COLUMNS_TARGET_VIEW_PAGE ) {
$t_columns[] = 'edit';
}
 
$t_columns[] = 'priority';
$t_columns[] = 'id';
 
$t_enable_sponsorship = config_get( 'enable_sponsorship' );
if ( ON == $t_enable_sponsorship ) {
$t_columns[] = 'sponsorship';
}
 
$t_columns[] = 'bugnotes_count';
 
$t_show_attachments = config_get( 'show_attachment_indicator' );
if ( ON == $t_show_attachments ) {
$t_columns[] = 'attachment';
}
 
$t_columns[] = 'reporter_id';
 
$t_columns[] = 'category';
$t_columns[] = 'severity';
$t_columns[] = 'status';
$t_columns[] = 'last_updated';
$t_columns[] = 'summary';
}
 
return $t_columns;
}
4.         添加以上代码之后,保存就OK了。这时候,你可以来检验一下,提交一个包含自定义字段的报告,然后在issue view页面里,点击[
CSV导出 ]/[ CSV Export ] ,将导出的CSV文档保存到本地,然后打开看看,是不是自定义字段及其值就在里面呢,呵呵,All Done!!!
【作者: 西西】
你可以使用这个链接引用该篇文章 http://publishblog.blogchina.com/blog/tb.b?diaryID=5562718

posted on 2006-11-28 14:54  bmw  阅读(1552)  评论(0编辑  收藏  举报

导航