Skip to content

Commit

Permalink
Fix attaching files when submititng issues via web
Browse files Browse the repository at this point in the history
  • Loading branch information
vboctor committed Mar 4, 2018
1 parent 1ae16f1 commit 567fc79
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bug_report.php
Expand Up @@ -84,7 +84,7 @@

$f_files = gpc_get_file( 'ufile', null );
if( $f_files !== null && !empty( $f_files ) ) {
$t_issue['attachments'] = helper_array_transpose( $f_files );
$t_issue['files'] = helper_array_transpose( $f_files );
}

$t_build = gpc_get_string( 'build', '' );
Expand Down
2 changes: 1 addition & 1 deletion core/commands/IssueAddCommand.php
Expand Up @@ -289,7 +289,7 @@ function validate() {
mci_project_custom_fields_validate( $t_project_id, $t_issue['custom_fields'] );

if( isset( $t_issue['files'] ) && !empty( $t_issue['files'] ) ) {
if( !file_allow_bug_upload( $t_issue_id ) ) {
if( !file_allow_bug_upload( /* issue id */ null, /* user id */ null, $t_project_id ) ) {
throw new ClientException(
'User not allowed to attach files.',
ERROR_ACCESS_DENIED );
Expand Down
5 changes: 3 additions & 2 deletions core/file_api.php
Expand Up @@ -911,9 +911,10 @@ function file_allow_project_upload( $p_project_id = null, $p_user_id = null ) {
* upload a file to a new bug in the current project
* @param integer $p_bug_id A bug identifier.
* @param integer $p_user_id A user identifier.
* @param integer $p_project_id The project id to check for or null for bug project or current project.
* @return boolean
*/
function file_allow_bug_upload( $p_bug_id = null, $p_user_id = null ) {
function file_allow_bug_upload( $p_bug_id = null, $p_user_id = null, $p_project_id = null ) {
if( null === $p_user_id ) {
$p_user_id = auth_get_current_user_id();
}
Expand All @@ -925,7 +926,7 @@ function file_allow_bug_upload( $p_bug_id = null, $p_user_id = null ) {

if( null === $p_bug_id ) {
# new bug
$t_project_id = helper_get_current_project();
$t_project_id = $p_project_id === null ? helper_get_current_project() : $p_project_id;

# the user must be the reporter if they're reporting a new bug
$t_reporter = true;
Expand Down

0 comments on commit 567fc79

Please sign in to comment.