Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Support private attachments with empty note
  • Loading branch information
vboctor committed Aug 25, 2019
1 parent ca816d7 commit 13d0f15
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 36 deletions.
46 changes: 16 additions & 30 deletions bugnote_add.php
Expand Up @@ -44,38 +44,24 @@

$t_query = array( 'issue_id' => $f_bug_id );

if( count( $f_files ) > 0 && is_blank( $f_text ) && helper_duration_to_minutes( $f_duration ) == 0 ) {
$t_payload = array(
'files' => helper_array_transpose( $f_files )
);
$t_payload = array(
'text' => $f_text,
'view_state' => array(
'id' => gpc_get_bool( 'private' ) ? VS_PRIVATE : VS_PUBLIC
),
'time_tracking' => array(
'duration' => $f_duration
),
'files' => helper_array_transpose( $f_files )
);

$t_data = array(
'query' => $t_query,
'payload' => $t_payload,
);
$t_data = array(
'query' => $t_query,
'payload' => $t_payload,
);

$t_command = new IssueFileAddCommand( $t_data );
$t_command->execute();
} else {
$t_payload = array(
'text' => $f_text,
'view_state' => array(
'id' => gpc_get_bool( 'private' ) ? VS_PRIVATE : VS_PUBLIC
),
'time_tracking' => array(
'duration' => $f_duration
),
'files' => helper_array_transpose( $f_files )
);

$t_data = array(
'query' => $t_query,
'payload' => $t_payload,
);

$t_command = new IssueNoteAddCommand( $t_data );
$t_command->execute();
}
$t_command = new IssueNoteAddCommand( $t_data );
$t_command->execute();

form_security_purge( 'bugnote_add' );

Expand Down
11 changes: 9 additions & 2 deletions bugnote_view_inc.php
Expand Up @@ -269,6 +269,8 @@
<td class="<?php echo $t_activity['style'] ?>">
<?php
if( $t_activity['type'] == ENTRY_TYPE_NOTE ) {
$t_add_space = false;

switch ( $t_activity['note']->note_type ) {
case REMINDER:
echo '<strong>';
Expand All @@ -294,19 +296,24 @@
}

echo '</strong><br /><br />';
$t_add_space = true;
break;

case TIME_TRACKING:
if( $t_show_time_tracking ) {
echo '<div class="time-tracked label label-grey label-sm">', lang_get( 'time_tracking_time_spent' ) . ' ' . $t_time_tracking_hhmm, '</div>';
echo '<div class="clearfix"></div>';
$t_add_space = true;
}
break;
}

echo string_display_links( $t_activity['note']->note );
if( !is_blank( $t_activity['note']->note ) ) {
echo string_display_links( $t_activity['note']->note );
$t_add_space = true;
}

if( isset( $t_activity['attachments'] ) && count( $t_activity['attachments'] ) > 0 ) {
if( $t_add_space && isset( $t_activity['attachments'] ) && count( $t_activity['attachments'] ) > 0 ) {
echo '<br /><br />';
}
} else {
Expand Down
4 changes: 0 additions & 4 deletions core/bugnote_api.php
Expand Up @@ -253,10 +253,6 @@ function bugnote_add( $p_bug_id, $p_bugnote_text, $p_time_tracking = '0:00', $p_
}

$c_type = TIME_TRACKING;
} else if( is_blank( $p_bugnote_text ) ) {
# This is not time tracking (i.e. it's a normal bugnote)
# @todo should we not trigger an error in this case ?
return false;
}
}

Expand Down

0 comments on commit 13d0f15

Please sign in to comment.