帮帮忙吧,PHP语言 搭建了Mantis软件,但是有一栏叫“分类”,提交问题时是必填选项,现在想把这一栏改成非必填选项,请问是改什么函数? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Mantis软件,先介绍下吧,谢谢!!! 代码太多了红色标出的是必填的,category这项不想必填 access_ensure_project_level( config_get('report_bug_threshold' ) ); $t_bug_data = new BugData; $t_bug_data->project_id = $t_project_id; $t_bug_data->reporter_id = auth_get_current_user_id(); $t_bug_data->build = gpc_get_string( 'build', '' ); $t_bug_data->platform = gpc_get_string( 'platform', '' ); $t_bug_data->os = gpc_get_string( 'os', '' ); $t_bug_data->os_build = gpc_get_string( 'os_build', '' ); $t_bug_data->version = gpc_get_string( 'product_version', '' ); $t_bug_data->profile_id = gpc_get_int( 'profile_id', 0 ); $t_bug_data->handler_id = gpc_get_int( 'handler_id', 0 ); $t_bug_data->view_state = gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) ); $t_bug_data->category_id = gpc_get_int( 'category_id', 0 ); $t_bug_data->reproducibility = gpc_get_int( 'reproducibility', config_get( 'default_bug_reproducibility' ) ); $t_bug_data->severity = gpc_get_int( 'severity', config_get( 'default_bug_severity' ) ); $t_bug_data->priority = gpc_get_int( 'priority', config_get( 'default_bug_priority' ) ); $t_bug_data->projection = gpc_get_int( 'projection', config_get( 'default_bug_projection' ) ); $t_bug_data->eta = gpc_get_int( 'eta', config_get( 'default_bug_eta' ) ); $t_bug_data->resolution = gpc_get_string('resolution', config_get( 'default_bug_resolution' ) ); $t_bug_data->status = gpc_get_string( 'status', config_get( 'bug_submit_status' ) ); $t_bug_data->summary = trim( gpc_get_string( 'summary' ) ); $t_bug_data->description = gpc_get_string( 'description' ); $t_bug_data->steps_to_reproduce = gpc_get_string( 'steps_to_reproduce', config_get( 'default_bug_steps_to_reproduce' ) ); $t_bug_data->issue_reason = gpc_get_string( 'issue_reason', config_get( 'default_bug_issue_reason' ) ); $t_bug_data->additional_information = gpc_get_string( 'additional_info', config_get ( 'default_bug_additional_info' ) ); $t_bug_data->due_date = gpc_get_string( 'due_date', ''); if ( is_blank ( $t_bug_data->due_date ) ) { $t_bug_data->due_date = date_get_null(); } $f_files = gpc_get_file( 'ufile', null ); /** @todo (thraxisp) Note that this always returns a structure */ $f_report_stay = gpc_get_bool( 'report_stay', false ); $f_copy_notes_from_parent = gpc_get_bool( 'copy_notes_from_parent', false); $f_copy_attachments_from_parent = gpc_get_bool( 'copy_attachments_from_parent', false); if ( access_has_project_level( config_get( 'roadmap_update_threshold' ), $t_bug_data->project_id ) ) { $t_bug_data->target_version = gpc_get_string( 'target_version', '' ); } # if a profile was selected then let's use that information if ( 0 != $t_bug_data->profile_id ) { if ( profile_is_global( $t_bug_data->profile_id ) ) { $row = user_get_profile_row( ALL_USERS, $t_bug_data->profile_id ); } else { $row = user_get_profile_row( $t_bug_data->reporter_id, $t_bug_data->profile_id ); } if ( is_blank( $t_bug_data->platform ) ) { $t_bug_data->platform = $row['platform']; } if ( is_blank( $t_bug_data->os ) ) { $t_bug_data->os = $row['os']; } if ( is_blank( $t_bug_data->os_build ) ) { $t_bug_data->os_build = $row['os_build']; } } helper_call_custom_function( 'issue_create_validate', array( $t_bug_data ) ); # Validate the custom fields before adding the bug. $t_related_custom_field_ids = custom_field_get_linked_ids( $t_bug_data->project_id ); foreach( $t_related_custom_field_ids as $t_id ) { $t_def = custom_field_get_definition( $t_id ); # Produce an error if the field is required but wasn't posted if ( !gpc_isset_custom_field( $t_id, $t_def['type'] ) && ( $t_def['require_report'] ) ) { error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) ); trigger_error( ERROR_EMPTY_FIELD, ERROR ); } if ( !custom_field_validate( $t_id, gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], NULL ) ) ) { error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) ); trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR ); } } Mantis是一个开源的管理bug的软件,基于PHP+mysql的 找到 BugData 类定义public $category_id = 你需要的初值 BugData类定义里面都是要的值,因为刚提交的bug不清楚属于哪个类,想即使是空也可以通过,可以吗? 怎么,你自己也不清楚?如果你不知道修改产生的后果,就不要修改如果你只是想某个属性是否可以缺省,那么可以注释掉赋值语句后观察结果比如//$t_bug_data->category_id = gpc_get_int( 'category_id', 0 ); 是这样子,上面要求类这一项不是必填,即使类这一项为空,问题也必须能正常提交。我也试着把这一行注释掉了,但是页面就会报错,找不到“分类”这一栏问题提交是在bug_report_page.php中,点击提交后转入bug_report.php,在整个文件夹里搜索也没找到empty与计算strlen的语句,该怎么弄啊?谢谢 怎么弄?#7 应经说了但实际上 gpc_get_int 函数应该是初始化函数 gpc_get_int( 'category_id', 0 ); 是将分类初始化为 0这样才能正确执行 RHEL5 GD Library及Mysql的问题 软件完工 PHP 5 高级应用开发实践 (中文高清PDF版) 请问有将excel 数据导入到mysql 的工具吗? 急~~~在线求解 zencart中怎么把一段文字显示在首页里 zend studio 或者eclipse 如何求数组中最小值 mssql_query()错误! dede首页图片展示的位置在哪个文件夹 关于 echo 'document.write跪求高手帮忙!!! php xml 正则表达式
access_ensure_project_level( config_get('report_bug_threshold' ) ); $t_bug_data = new BugData;
$t_bug_data->project_id = $t_project_id;
$t_bug_data->reporter_id = auth_get_current_user_id();
$t_bug_data->build = gpc_get_string( 'build', '' );
$t_bug_data->platform = gpc_get_string( 'platform', '' );
$t_bug_data->os = gpc_get_string( 'os', '' );
$t_bug_data->os_build = gpc_get_string( 'os_build', '' );
$t_bug_data->version = gpc_get_string( 'product_version', '' );
$t_bug_data->profile_id = gpc_get_int( 'profile_id', 0 );
$t_bug_data->handler_id = gpc_get_int( 'handler_id', 0 );
$t_bug_data->view_state = gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) );
$t_bug_data->category_id = gpc_get_int( 'category_id', 0 );
$t_bug_data->reproducibility = gpc_get_int( 'reproducibility', config_get( 'default_bug_reproducibility' ) );
$t_bug_data->severity = gpc_get_int( 'severity', config_get( 'default_bug_severity' ) );
$t_bug_data->priority = gpc_get_int( 'priority', config_get( 'default_bug_priority' ) );
$t_bug_data->projection = gpc_get_int( 'projection', config_get( 'default_bug_projection' ) );
$t_bug_data->eta = gpc_get_int( 'eta', config_get( 'default_bug_eta' ) );
$t_bug_data->resolution = gpc_get_string('resolution', config_get( 'default_bug_resolution' ) );
$t_bug_data->status = gpc_get_string( 'status', config_get( 'bug_submit_status' ) );
$t_bug_data->summary = trim( gpc_get_string( 'summary' ) );
$t_bug_data->description = gpc_get_string( 'description' );
$t_bug_data->steps_to_reproduce = gpc_get_string( 'steps_to_reproduce', config_get( 'default_bug_steps_to_reproduce' ) );
$t_bug_data->issue_reason = gpc_get_string( 'issue_reason', config_get( 'default_bug_issue_reason' ) );
$t_bug_data->additional_information = gpc_get_string( 'additional_info', config_get ( 'default_bug_additional_info' ) );
$t_bug_data->due_date = gpc_get_string( 'due_date', '');
if ( is_blank ( $t_bug_data->due_date ) ) {
$t_bug_data->due_date = date_get_null();
} $f_files = gpc_get_file( 'ufile', null ); /** @todo (thraxisp) Note that this always returns a structure */
$f_report_stay = gpc_get_bool( 'report_stay', false );
$f_copy_notes_from_parent = gpc_get_bool( 'copy_notes_from_parent', false);
$f_copy_attachments_from_parent = gpc_get_bool( 'copy_attachments_from_parent', false); if ( access_has_project_level( config_get( 'roadmap_update_threshold' ), $t_bug_data->project_id ) ) {
$t_bug_data->target_version = gpc_get_string( 'target_version', '' );
} # if a profile was selected then let's use that information
if ( 0 != $t_bug_data->profile_id ) {
if ( profile_is_global( $t_bug_data->profile_id ) ) {
$row = user_get_profile_row( ALL_USERS, $t_bug_data->profile_id );
} else {
$row = user_get_profile_row( $t_bug_data->reporter_id, $t_bug_data->profile_id );
} if ( is_blank( $t_bug_data->platform ) ) {
$t_bug_data->platform = $row['platform'];
}
if ( is_blank( $t_bug_data->os ) ) {
$t_bug_data->os = $row['os'];
}
if ( is_blank( $t_bug_data->os_build ) ) {
$t_bug_data->os_build = $row['os_build'];
}
}
helper_call_custom_function( 'issue_create_validate', array( $t_bug_data ) ); # Validate the custom fields before adding the bug.
$t_related_custom_field_ids = custom_field_get_linked_ids( $t_bug_data->project_id );
foreach( $t_related_custom_field_ids as $t_id ) {
$t_def = custom_field_get_definition( $t_id ); # Produce an error if the field is required but wasn't posted
if ( !gpc_isset_custom_field( $t_id, $t_def['type'] ) &&
( $t_def['require_report'] ) ) {
error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) );
trigger_error( ERROR_EMPTY_FIELD, ERROR );
} if ( !custom_field_validate( $t_id, gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], NULL ) ) ) {
error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) );
trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR );
}
}
public $category_id = 你需要的初值
BugData类定义里面都是要的值,因为刚提交的bug不清楚属于哪个类,想即使是空也可以通过,可以吗?
如果你只是想某个属性是否可以缺省,那么可以注释掉赋值语句后观察结果
比如
//$t_bug_data->category_id = gpc_get_int( 'category_id', 0 );
是这样子,上面要求类这一项不是必填,即使类这一项为空,问题也必须能正常提交。
我也试着把这一行注释掉了,但是页面就会报错,找不到“分类”这一栏
问题提交是在bug_report_page.php中,点击提交后转入bug_report.php,在整个文件夹里搜索也没找到empty与计算strlen的语句,该怎么弄啊?谢谢
gpc_get_int( 'category_id', 0 ); 是将分类初始化为 0
这样才能正确执行