/** * Allows the selected file to be viewed. * * @author [A. Gianotto] [<*****@*****.**>] * @since [v1.4] * @param int $licenseId * @param int $fileId * @return Redirect */ public function displayFile($licenseId = null, $fileId = null) { $license = License::find($licenseId); // the license is valid if (isset($license->id)) { if (!Company::isCurrentUserHasAccess($license)) { return redirect()->to('admin/licenses')->with('error', trans('general.insufficient_permissions')); } $log = Actionlog::find($fileId); $file = $log->get_src('licenses'); return Response::download($file); } else { // Prepare the error message $error = trans('admin/licenses/message.does_not_exist', compact('id')); // Redirect to the licence management page return redirect()->route('licenses')->with('error', $error); } }
/** * Check for permissions and display the file. * * @author [A. Gianotto] [<*****@*****.**>] * @param int $assetId * @param int $fileId * @since [v1.0] * @return View */ public function displayFile($assetId = null, $fileId = null) { $asset = Asset::find($assetId); // the asset is valid if (isset($asset->id)) { if (!Company::isCurrentUserHasAccess($asset)) { return redirect()->to('hardware')->with('error', trans('general.insufficient_permissions')); } $log = Actionlog::find($fileId); $file = $log->get_src('assets'); $filetype = Helper::checkUploadIsImage($file); if ($filetype) { $contents = file_get_contents($file); return Response::make($contents)->header('Content-Type', $filetype); } else { return Response::download($file); } } else { // Prepare the error message $error = trans('admin/hardware/message.does_not_exist', compact('id')); // Redirect to the hardware management page return redirect()->route('hardware')->with('error', $error); } }
/** * updateAssetLogWithThreadInformation * * @param $assetLog * * @author Vincent Sposato <*****@*****.**> * @version v1.0 */ protected function updateAssetLogWithThreadInformation($assetLog) { $loadedAssetLog = Actionlog::find($assetLog->id); $loadedAssetLog->thread_id = $this->currentAssetLogId; $loadedAssetLog->update(); unset($loadedAssetLog); }