From 01439a0f43f509e1b6678f5e7d7ad053e55bbbb2 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 8 Jan 2017 17:43:56 +0200 Subject: [PATCH] Enable non-admins to set notification preferences --- app/Http/Controllers/AccountController.php | 7 ++++ .../views/accounts/notifications.blade.php | 16 +-------- .../accounts/partials/notifications.blade.php | 16 +++++++++ .../views/accounts/user_details.blade.php | 33 +++++++++++-------- 4 files changed, 43 insertions(+), 29 deletions(-) create mode 100644 resources/views/accounts/partials/notifications.blade.php diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 8008dce28388..fe0702d9588a 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -1220,6 +1220,13 @@ class AccountController extends BaseController $user->email = trim(strtolower(Input::get('email'))); $user->phone = trim(Input::get('phone')); + if ( ! Auth::user()->is_admin) { + $user->notify_sent = Input::get('notify_sent'); + $user->notify_viewed = Input::get('notify_viewed'); + $user->notify_paid = Input::get('notify_paid'); + $user->notify_approved = Input::get('notify_approved'); + } + if (Utils::isNinja()) { if (Input::get('referral_code') && !$user->referral_code) { $user->referral_code = $this->accountRepo->getReferralCode(); diff --git a/resources/views/accounts/notifications.blade.php b/resources/views/accounts/notifications.blade.php index e7260784d346..e0199063270e 100644 --- a/resources/views/accounts/notifications.blade.php +++ b/resources/views/accounts/notifications.blade.php @@ -7,22 +7,8 @@ {!! Former::open()->addClass('warn-on-exit') !!} {{ Former::populate($account) }} - {{ Former::populateField('notify_sent', intval(Auth::user()->notify_sent)) }} - {{ Former::populateField('notify_viewed', intval(Auth::user()->notify_viewed)) }} - {{ Former::populateField('notify_paid', intval(Auth::user()->notify_paid)) }} - {{ Former::populateField('notify_approved', intval(Auth::user()->notify_approved)) }} -
-
-

{!! trans('texts.email_notifications') !!}

-
-
- {!! Former::checkbox('notify_sent')->label(' ')->text(trans('texts.email_sent')) !!} - {!! Former::checkbox('notify_viewed')->label(' ')->text(trans('texts.email_viewed')) !!} - {!! Former::checkbox('notify_paid')->label(' ')->text(trans('texts.email_paid')) !!} - {!! Former::checkbox('notify_approved')->label(' ')->text(trans('texts.email_approved')) !!} -
-
+ @include('accounts.partials.notifications')
diff --git a/resources/views/accounts/partials/notifications.blade.php b/resources/views/accounts/partials/notifications.blade.php new file mode 100644 index 000000000000..5ed6cd6039f4 --- /dev/null +++ b/resources/views/accounts/partials/notifications.blade.php @@ -0,0 +1,16 @@ +{{ Former::populateField('notify_sent', intval(Auth::user()->notify_sent)) }} +{{ Former::populateField('notify_viewed', intval(Auth::user()->notify_viewed)) }} +{{ Former::populateField('notify_paid', intval(Auth::user()->notify_paid)) }} +{{ Former::populateField('notify_approved', intval(Auth::user()->notify_approved)) }} + +
+
+

{!! trans('texts.email_notifications') !!}

+
+
+ {!! Former::checkbox('notify_sent')->label(' ')->text(trans('texts.email_sent')) !!} + {!! Former::checkbox('notify_viewed')->label(' ')->text(trans('texts.email_viewed')) !!} + {!! Former::checkbox('notify_paid')->label(' ')->text(trans('texts.email_paid')) !!} + {!! Former::checkbox('notify_approved')->label(' ')->text(trans('texts.email_approved')) !!} +
+
diff --git a/resources/views/accounts/user_details.blade.php b/resources/views/accounts/user_details.blade.php index 5b62dbc21c7f..4ee5a762ae79 100644 --- a/resources/views/accounts/user_details.blade.php +++ b/resources/views/accounts/user_details.blade.php @@ -74,22 +74,27 @@
-
- @if (Auth::user()->confirmed) - {!! Button::primary(trans('texts.change_password')) - ->appendIcon(Icon::create('lock')) - ->large()->withAttributes(['onclick'=>'showChangePassword()']) !!} - @elseif (Auth::user()->registered && Utils::isNinja()) - {!! Button::primary(trans('texts.resend_confirmation')) - ->appendIcon(Icon::create('send')) - ->asLinkTo(URL::to('/resend_confirmation'))->large() !!} - @endif - {!! Button::success(trans('texts.save')) - ->submit()->large() - ->appendIcon(Icon::create('floppy-disk')) !!} -
+ @if ( ! Auth::user()->is_admin) + @include('accounts.partials.notifications') + @endif + +
+ @if (Auth::user()->confirmed) + {!! Button::primary(trans('texts.change_password')) + ->appendIcon(Icon::create('lock')) + ->large()->withAttributes(['onclick'=>'showChangePassword()']) !!} + @elseif (Auth::user()->registered && Utils::isNinja()) + {!! Button::primary(trans('texts.resend_confirmation')) + ->appendIcon(Icon::create('send')) + ->asLinkTo(URL::to('/resend_confirmation'))->large() !!} + @endif + {!! Button::success(trans('texts.save')) + ->submit()->large() + ->appendIcon(Icon::create('floppy-disk')) !!} +
+