index options added

This commit is contained in:
carodej
2020-07-13 09:49:25 +02:00
parent a74c1c7b6e
commit 2ae60003d6
50 changed files with 1106 additions and 135 deletions

View File

@@ -18,6 +18,33 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
class AppFunctionsController extends Controller
{
/**
* List of allowed settings to get from public request
*
* @var array
*/
private $whitelist = [
'footer_content',
'get_started_description',
'get_started_title',
'pricing_description',
'pricing_title',
'feature_description_3',
'feature_title_3',
'feature_description_2',
'feature_title_2',
'feature_description_1',
'feature_title_1',
'features_description',
'features_title',
'header_description',
'header_title',
'section_get_started',
'section_pricing_content',
'section_feature_boxes',
'section_features',
];
/**
* Show index page
*
@@ -31,6 +58,7 @@ class AppFunctionsController extends Controller
$connection = $this->get_setup_status();
$settings = json_decode(Setting::all()->pluck('value', 'name')->toJson());
$legal = Page::whereIn('slug', ['terms-of-service', 'privacy-policy', 'cookie-policy'])->get(['visibility', 'title', 'slug']);
} catch (PDOException $e) {
$connection = 'setup-database';
@@ -39,6 +67,7 @@ class AppFunctionsController extends Controller
return view("index")
->with('settings', $settings)
->with('legal', $legal)
->with('installation', $connection);
}
@@ -72,6 +101,32 @@ class AppFunctionsController extends Controller
);
}
/**
* Get selected settings from public route
*
* @param Request $request
* @return mixed
*/
public function get_settings(Request $request)
{
$column = $request->get('column');
if (strpos($column, '|') !== false) {
$columns = collect(explode('|', $column));
$columns->each(function ($column) {
if (! in_array($column, $this->whitelist)) abort(401);
});
return Setting::whereIn('name', $columns)->pluck('value', 'name');
}
if (! in_array($column, $this->whitelist)) abort(401);
return Setting::where('name', $column)->pluck('value', 'name');
}
/**
* Check if setup wizard was passed
*