diff --git a/app/Composers/AppComposer.php b/app/Composers/AppComposer.php index 5c0c2b7b..00a6523b 100644 --- a/app/Composers/AppComposer.php +++ b/app/Composers/AppComposer.php @@ -86,5 +86,6 @@ class AppComposer $view->withFontSubset($this->config->get('langs.'.$this->config->get('app.locale').'.subset', 'latin')); $view->withOnlyDisruptedDays($this->config->get('setting.only_disrupted_days')); $view->withDashboardLink($this->config->get('setting.dashboard_login_link')); + $view->withEnableSubscribers($this->config->get('setting.enable_subscribers')); } } diff --git a/app/Http/Middleware/SubscribersConfigured.php b/app/Http/Middleware/SubscribersConfigured.php index 378caa20..a8bc4056 100644 --- a/app/Http/Middleware/SubscribersConfigured.php +++ b/app/Http/Middleware/SubscribersConfigured.php @@ -12,6 +12,7 @@ namespace CachetHQ\Cachet\Http\Middleware; use Closure; +use Illuminate\Contracts\Config\Repository; use Illuminate\Http\Request; /** @@ -22,6 +23,25 @@ use Illuminate\Http\Request; */ class SubscribersConfigured { + /** + * The config repository instance. + * + * @var \Illuminate\Contracts\Config\Repository + */ + protected $config; + + /** + * Creates a subscribers configured middleware instance. + * + * @param \Illuminate\Contracts\Config\Repository $config + * + * @return void + */ + public function __construct(Repository $config) + { + $this->config = $config; + } + /** * Handle an incoming request. * @@ -32,7 +52,7 @@ class SubscribersConfigured */ public function handle(Request $request, Closure $next) { - if (!subscribers_enabled()) { + if (!$this->config->get('setting.enable_subscribers')) { return cachet_redirect('status-page'); } diff --git a/app/helpers.php b/app/helpers.php index cae1f908..e856917b 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -51,22 +51,6 @@ if (!function_exists('formatted_date')) { } } -if (!function_exists('subscribers_enabled')) { - /** - * Is the subscriber functionality enabled and configured. - * - * @return bool - */ - function subscribers_enabled() - { - $isEnabled = Config::get('setting.enable_subscribers', false); - $mailAddress = Config::get('mail.from.address', false); - $mailFrom = Config::get('mail.from.name', false); - - return $isEnabled && $mailAddress && $mailFrom; - } -} - if (!function_exists('color_darken')) { /** * Darken a color. diff --git a/resources/views/dashboard/incidents/add.blade.php b/resources/views/dashboard/incidents/add.blade.php index b1548f9a..7dc91b19 100644 --- a/resources/views/dashboard/incidents/add.blade.php +++ b/resources/views/dashboard/incidents/add.blade.php @@ -115,7 +115,7 @@ - @if(subscribers_enabled()) + @if($enable_subscribers)