1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00
invoiceninja/app/Http/Requests/SaveClientPortalSettings.php

62 lines
1.6 KiB
PHP
Raw Normal View History

2017-01-30 20:40:43 +01:00
<?php
namespace App\Http\Requests;
use HTMLUtils;
2017-01-30 20:40:43 +01:00
use Utils;
class SaveClientPortalSettings extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->is_admin && $this->user()->isPro();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = [];
if ($this->custom_link == 'subdomain' && Utils::isNinja()) {
$rules['subdomain'] = "unique:accounts,subdomain,{$this->user()->account_id},id|valid_subdomain";
}
return $rules;
}
public function sanitize()
{
$input = $this->all();
if ($this->client_view_css && Utils::isNinja()) {
2017-05-07 09:00:38 +02:00
$input['client_view_css'] = HTMLUtils::sanitizeCSS($this->client_view_css);
}
2017-03-21 14:41:01 +01:00
if (Utils::isNinja()) {
if ($this->custom_link == 'subdomain') {
$subdomain = substr(strtolower($input['subdomain']), 0, MAX_SUBDOMAIN_LENGTH);
$input['subdomain'] = preg_replace('/[^a-zA-Z0-9_\-\.]/', '', $subdomain);
$input['iframe_url'] = null;
} else {
$iframeURL = substr(strtolower($input['iframe_url']), 0, MAX_IFRAME_URL_LENGTH);
$iframeURL = preg_replace('/[^a-zA-Z0-9_\-\:\/\.]/', '', $iframeURL);
2019-01-30 11:45:46 +01:00
$input['iframe_url'] = $iframeURL;
2017-03-21 14:41:01 +01:00
$input['subdomain'] = null;
}
2017-01-30 17:05:31 +01:00
}
2017-05-07 09:00:38 +02:00
$this->replace($input);
return $this->all();
}
}