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!!!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值