Skip to content

Commit

Permalink
Fix uploading attachments when assigning in step 4 (Bug #13621).
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Dec 9, 2014
1 parent 414bb83 commit 5146f18
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 7 additions & 1 deletion whups/lib/Ticket.php
Expand Up @@ -110,14 +110,14 @@ static public function newTicket($info, $requester)
}

// Check for a deferred attachment upload.
$a_name = null;
if (!empty($info['deferred_attachment']) &&
($a_name = $GLOBALS['session']->get('whups', 'deferred_attachment/' . $info['deferred_attachment']))) {
$ticket->change(
'attachment',
array(
'name' => $info['deferred_attachment'],
'tmp_name' => $a_name));
unlink($a_name);
}

// Check for manually added attachments.
Expand All @@ -131,6 +131,12 @@ static public function newTicket($info, $requester)
$info['last-transaction'],
false);

// Delete deferred attachment now, because it will be attached in the
// commit() call above.
if ($a_name) {
unlink($a_name);
}

// Send email notifications.
$ticket->notify($ticket->get('user_id_requester'), true);

Expand Down
5 changes: 2 additions & 3 deletions whups/ticket/create.php
Expand Up @@ -56,7 +56,6 @@
}
$notification->push(sprintf(_("Your ticket ID is %s. An appropriate person has been notified of this request."), $ticket->getId()), 'horde.success');
$ticket->show();
exit;
}

// Start the page.
Expand Down Expand Up @@ -95,12 +94,12 @@
if (!empty($info['newattachment']['name'])) {
$file_name = $info['newattachment']['name'];

$tmp_file_path = Horde::getTempFile('whups');
$tmp_file_path = Horde::getTempFile('whups', false);
if (move_uploaded_file($info['newattachment']['tmp_name'],
$tmp_file_path)) {
$session->set('whups', 'deferred_attachment/' . $file_name, $tmp_file_path);
$vars->set('deferred_attachment', $file_name);
$form3->preserveVarByPost($vars, 'deferred_attachment');
$form4->preserveVarByPost($vars, 'deferred_attachment');
}
}

Expand Down

0 comments on commit 5146f18

Please sign in to comment.