コード例 #1
0
 /**
  * @param Attachment                $attachment
  * @param AttachmentHelperInterface $helper
  *
  * @return string
  */
 public function download(Attachment $attachment, AttachmentHelperInterface $helper)
 {
     $file = $helper->getAttachmentLocation($attachment);
     if (file_exists($file)) {
         $quoted = sprintf('"%s"', addcslashes(basename($attachment->filename), '"\\'));
         return response(Crypt::decrypt(file_get_contents($file)), 200)->header('Content-Description', 'File Transfer')->header('Content-Type', 'application/octet-stream')->header('Content-Disposition', 'attachment; filename=' . $quoted)->header('Content-Transfer-Encoding', 'binary')->header('Connection', 'Keep-Alive')->header('Expires', '0')->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')->header('Pragma', 'public')->header('Content-Length', $attachment->size);
     } else {
         abort(404);
     }
 }
コード例 #2
0
 /**
  * @param Attachment                $attachment
  * @param AttachmentHelperInterface $helper
  */
 public function download(Attachment $attachment, AttachmentHelperInterface $helper)
 {
     $file = $helper->getAttachmentLocation($attachment);
     if (file_exists($file)) {
         $quoted = sprintf('"%s"', addcslashes(basename($attachment->filename), '"\\'));
         header('Content-Description: File Transfer');
         header('Content-Type: application/octet-stream');
         header('Content-Disposition: attachment; filename=' . $quoted);
         header('Content-Transfer-Encoding: binary');
         header('Connection: Keep-Alive');
         header('Expires: 0');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: public');
         header('Content-Length: ' . $attachment->size);
         echo Crypt::decrypt(file_get_contents($file));
     } else {
         abort(404);
     }
 }
コード例 #3
0
 /**
  * @param JournalFormRequest         $request
  * @param JournalRepositoryInterface $repository
  * @param AttachmentHelperInterface  $att
  * @param TransactionJournal         $journal
  *
  * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function update(JournalFormRequest $request, JournalRepositoryInterface $repository, AttachmentHelperInterface $att, TransactionJournal $journal)
 {
     $journalData = $request->getJournalData();
     $repository->update($journal, $journalData);
     // save attachments:
     $att->saveAttachmentsForModel($journal);
     // flash errors
     if (count($att->getErrors()->get('attachments')) > 0) {
         Session::flash('error', $att->getErrors()->get('attachments'));
     }
     // flash messages
     if (count($att->getMessages()->get('attachments')) > 0) {
         Session::flash('info', $att->getMessages()->get('attachments'));
     }
     event(new TransactionJournalUpdated($journal));
     // update, get events by date and sort DESC
     Session::flash('success', 'Transaction "' . e($journalData['description']) . '" updated.');
     Preferences::mark();
     if (intval(Input::get('return_to_edit')) === 1) {
         // set value so edit routine will not overwrite URL:
         Session::put('transactions.edit.fromUpdate', true);
         return redirect(route('transactions.edit', [$journal->id]))->withInput(['return_to_edit' => 1]);
     }
     // redirect to previous URL.
     return redirect(Session::get('transactions.edit.url'));
 }
コード例 #4
0
 /**
  * @param TransactionJournal        $journal
  * @param SplitJournalFormRequest   $request
  * @param JournalInterface          $repository
  * @param AttachmentHelperInterface $att
  *
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function update(TransactionJournal $journal, SplitJournalFormRequest $request, JournalInterface $repository, AttachmentHelperInterface $att)
 {
     $data = $request->getSplitData();
     $journal = $repository->updateJournal($journal, $data);
     // save attachments:
     $att->saveAttachmentsForModel($journal);
     event(new TransactionJournalUpdated($journal));
     // update, get events by date and sort DESC
     // flash messages
     if (count($att->getMessages()->get('attachments')) > 0) {
         Session::flash('info', $att->getMessages()->get('attachments'));
     }
     $type = strtolower($journal->transaction_type_type ?? TransactionJournal::transactionTypeStr($journal));
     Session::flash('success', strval(trans('firefly.updated_' . $type, ['description' => e($data['journal_description'])])));
     Preferences::mark();
     if (intval($request->get('return_to_edit')) === 1) {
         // set value so edit routine will not overwrite URL:
         Session::put('transactions.edit-split.fromUpdate', true);
         return redirect(route('split.journal.edit', [$journal->id]))->withInput(['return_to_edit' => 1]);
     }
     // redirect to previous URL.
     return redirect(session('transactions.edit-split.url'));
 }