From 74787804e7a252eb27358541e74fcca3ee5b1a46 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 1 Jun 2015 16:06:18 +0300 Subject: [PATCH] Minor tweaks --- app/Http/Controllers/AppController.php | 1 - app/Http/Controllers/PaymentController.php | 3 ++- app/Listeners/HandleUserLoggedIn.php | 16 ++++++++++++---- .../views/accounts/account_gateway.blade.php | 3 ++- .../views/accounts/invoice_design.blade.php | 2 -- resources/views/header.blade.php | 6 +++--- resources/views/invoices/edit.blade.php | 6 +++--- resources/views/invoices/pdf.blade.php | 2 +- resources/views/master.blade.php | 13 +------------ resources/views/public/license.blade.php | 8 ++++++++ 10 files changed, 32 insertions(+), 28 deletions(-) diff --git a/app/Http/Controllers/AppController.php b/app/Http/Controllers/AppController.php index 7616128b92bd..745c38579e5a 100644 --- a/app/Http/Controllers/AppController.php +++ b/app/Http/Controllers/AppController.php @@ -116,7 +116,6 @@ class AppController extends BaseController $user = $account->users()->first(); //Auth::login($user, true); - $this->accountRepo->registerUser($user); return Redirect::to('/login'); } diff --git a/app/Http/Controllers/PaymentController.php b/app/Http/Controllers/PaymentController.php index 8f38932de149..872bf25e0fd9 100644 --- a/app/Http/Controllers/PaymentController.php +++ b/app/Http/Controllers/PaymentController.php @@ -204,7 +204,7 @@ class PaymentController extends BaseController $gateway->$function($val); } - if ($accountGateway->gateway->id == GATEWAY_DWOLLA) { + if ($accountGateway->gateway->id == GATEWAY_DWOLLA && isset($_ENV['DWOLLA_KEY']) && isset($_ENV['DWOLLA_SECRET'])) { $gateway->setKeySecret($_ENV['DWOLLA_KEY'], $_ENV['DWOLLA_SECRET']); } @@ -444,6 +444,7 @@ class PaymentController extends BaseController 'message' => $affiliate->payment_subtitle, 'license' => $licenseKey, 'hideHeader' => true, + 'productId' => $license->product_id ]; $name = "{$license->first_name} {$license->last_name}"; diff --git a/app/Listeners/HandleUserLoggedIn.php b/app/Listeners/HandleUserLoggedIn.php index f1f4e36eff1d..bea1ab4df4b5 100644 --- a/app/Listeners/HandleUserLoggedIn.php +++ b/app/Listeners/HandleUserLoggedIn.php @@ -1,22 +1,25 @@ accountRepo = $accountRepo; } /** @@ -26,8 +29,13 @@ class HandleUserLoggedIn { * @return void */ public function handle(UserLoggedIn $event) - { + { $account = Auth::user()->account; + + if (!Utils::isNinja() && empty($account->last_login)) { + $this->accountRepo->registerUser(Auth::user()); + } + $account->last_login = Carbon::now()->toDateTimeString(); $account->save(); diff --git a/resources/views/accounts/account_gateway.blade.php b/resources/views/accounts/account_gateway.blade.php index 23815b1b2f07..673ea9eb25ae 100644 --- a/resources/views/accounts/account_gateway.blade.php +++ b/resources/views/accounts/account_gateway.blade.php @@ -48,7 +48,8 @@ @if (in_array($field, $hiddenFields)) {{-- do nothing --}} - @elseif ($gateway->id == GATEWAY_DWOLLA && ($field == 'Key' || $field == 'Secret')) + @elseif ($gateway->id == GATEWAY_DWOLLA && ($field == 'Key' || $field == 'Secret') + && isset($_ENV['DWOLLA_KEY']) && isset($_ENV['DWOLLA_SECRET'])) {{-- do nothing --}} @elseif ($field == 'testMode' || $field == 'developerMode' || $field == 'sandbox') {!! Former::checkbox($gateway->id.'_'.$field)->label(Utils::toSpaceCase($field))->text('Enable')->value('true') !!} diff --git a/resources/views/accounts/invoice_design.blade.php b/resources/views/accounts/invoice_design.blade.php index d14a70e75a93..0968619c407d 100644 --- a/resources/views/accounts/invoice_design.blade.php +++ b/resources/views/accounts/invoice_design.blade.php @@ -85,11 +85,9 @@ {!! Former::populate($account) !!} {!! Former::populateField('hide_quantity', intval($account->hide_quantity)) !!} {!! Former::populateField('hide_paid_to_date', intval($account->hide_paid_to_date)) !!} - @if ($invoiceLabels) @foreach ($invoiceLabels as $field => $value) {!! Former::populateField("labels_{$field}", $value) !!} @endforeach - @endif
diff --git a/resources/views/header.blade.php b/resources/views/header.blade.php index ac5414aef598..4ae7ce5d6ce4 100644 --- a/resources/views/header.blade.php +++ b/resources/views/header.blade.php @@ -106,7 +106,7 @@ success: function(result) { if (result) { localStorage.setItem('guest_key', ''); - trackUrl('/signed_up'); + trackEvent('/account', '/signed_up'); NINJA.isRegistered = true; $('#signUpButton').hide(); $('#myAccountButton').html(result); @@ -150,7 +150,7 @@ @if (Auth::check() && !Auth::user()->isPro()) function submitProPlan(feature) { - trackUrl('/submit_pro_plan/' + feature); + trackEvent('/account', '/submit_pro_plan/' + feature); if (NINJA.isRegistered) { $('#proPlanDiv, #proPlanFooter').hide(); $('#proPlanWorking').show(); @@ -263,7 +263,7 @@ validateSignUp(); $('#signUpModal').on('shown.bs.modal', function () { - trackUrl('/view_sign_up'); + trackEvent('/account', '/view_sign_up'); $(['first_name','last_name','email','password']).each(function(i, field) { var $input = $('form.signUpForm #new_'+field); if (!$input.val()) { diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index 1781087b1d8a..713019412c16 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -760,7 +760,7 @@ } function onDownloadClick() { - trackUrl('/download_pdf'); + trackEvent('/activity', '/download_pdf'); var invoice = createInvoiceModel(); var design = getDesignJavascript(); if (!design) return; @@ -1043,7 +1043,7 @@ } self.showClientForm = function() { - trackUrl('/view_client_form'); + trackEvent('/activity', '/view_client_form'); self.clientBackup = ko.mapping.toJS(self.invoice().client); $('#emailError').css( "display", "none" ); @@ -1051,7 +1051,7 @@ } self.clientFormComplete = function() { - trackUrl('/save_client_form'); + trackEvent('/activity', '/save_client_form'); var email = $('#email0').val(); var firstName = $('#first_name').val(); diff --git a/resources/views/invoices/pdf.blade.php b/resources/views/invoices/pdf.blade.php index 84d0a4900cf8..e851631c9a5c 100644 --- a/resources/views/invoices/pdf.blade.php +++ b/resources/views/invoices/pdf.blade.php @@ -120,7 +120,7 @@ } function showMoreDesigns() { - trackUrl('/view_more_designs'); + trackEvent('/account', '/view_more_designs'); $('#moreDesignsModal').modal('show'); } diff --git a/resources/views/master.blade.php b/resources/views/master.blade.php index 292c22ea4d93..386be8c45109 100644 --- a/resources/views/master.blade.php +++ b/resources/views/master.blade.php @@ -79,10 +79,6 @@ @elseif (isset($_ENV['ANALYTICS_KEY']) && $_ENV['ANALYTICS_KEY']) @@ -95,19 +91,12 @@ ga('create', '{{ $_ENV['ANALYTICS_KEY'] }}', 'auto'); ga('send', 'pageview'); - function trackUrl(url) { - url = '/track' + url.replace('http:/', ''); - ga('send', 'pageview', url); - - } - function trackEvent(category, action) { ga('send', 'event', category, action, this.src); } @else @endif @@ -132,7 +121,7 @@ } }); function openUrl(url, track) { - trackUrl(track ? track : url); + trackEvent('/view_link', track ? track : url); window.open(url, '_blank'); } diff --git a/resources/views/public/license.blade.php b/resources/views/public/license.blade.php index 92844a2a3123..e651dc573d4e 100644 --- a/resources/views/public/license.blade.php +++ b/resources/views/public/license.blade.php @@ -98,4 +98,12 @@ header h3 em {
+ + @stop \ No newline at end of file