2017-08-24 22:24:02 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Helpers\Helper;
|
|
|
|
|
|
|
|
class ModalController extends Controller
|
|
|
|
{
|
2020-05-23 09:19:19 -07:00
|
|
|
|
2021-12-30 18:16:49 -08:00
|
|
|
/**
|
|
|
|
* Load the modal views after confirming they are in the allowed_types array.
|
|
|
|
* The allowed types away just prevents shithead skiddies from fuzzing the urls
|
|
|
|
* with automated scripts and junking up the logs. - snipe
|
2021-12-30 18:33:28 -08:00
|
|
|
*
|
|
|
|
* @version v5.3.7-pre
|
|
|
|
* @author [Brady Wetherington] [<uberbrady@gmail.com>]
|
|
|
|
* @author [A. Gianotto] [<snipe@snipe.net]
|
|
|
|
* @return View
|
2021-12-30 18:16:49 -08:00
|
|
|
*/
|
2023-02-06 12:44:02 -08:00
|
|
|
public function show ($type, $itemId = null) {
|
2021-12-30 18:16:49 -08:00
|
|
|
|
2021-12-30 18:33:28 -08:00
|
|
|
// These values should correspond to a file in resources/views/modals/
|
2021-12-30 18:16:49 -08:00
|
|
|
$allowed_types = [
|
|
|
|
'category',
|
|
|
|
'kit-model',
|
|
|
|
'kit-license',
|
|
|
|
'kit-consumable',
|
|
|
|
'kit-accessory',
|
|
|
|
'location',
|
|
|
|
'manufacturer',
|
|
|
|
'model',
|
|
|
|
'statuslabel',
|
|
|
|
'supplier',
|
|
|
|
'upload-file',
|
|
|
|
'user',
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
if (in_array($type, $allowed_types)) {
|
2020-05-23 09:19:19 -07:00
|
|
|
$view = view("modals.${type}");
|
|
|
|
|
2021-12-30 18:16:49 -08:00
|
|
|
if ($type == "statuslabel") {
|
2020-05-23 09:19:19 -07:00
|
|
|
$view->with('statuslabel_types', Helper::statusTypeList());
|
|
|
|
}
|
2021-06-10 13:15:52 -07:00
|
|
|
if (in_array($type, ['kit-model', 'kit-license', 'kit-consumable', 'kit-accessory'])) {
|
2020-05-23 09:19:19 -07:00
|
|
|
$view->with('kitId', $itemId);
|
2021-12-30 18:16:49 -08:00
|
|
|
}
|
|
|
|
return $view;
|
2020-05-23 09:19:19 -07:00
|
|
|
}
|
2021-06-10 13:15:52 -07:00
|
|
|
|
2021-12-30 18:16:49 -08:00
|
|
|
abort(404,'Page not found');
|
|
|
|
|
2019-02-19 11:19:00 -08:00
|
|
|
}
|
2017-08-24 22:24:02 -07:00
|
|
|
}
|