@@ -10,8 +10,8 @@ |
||
10 | 10 | 'common\interfaces\QuestionInterface' => \common\models\Question::class, |
11 | 11 | 'common\interfaces\BehaviorInterface' => \common\models\Behavior::class, |
12 | 12 | 'common\interfaces\CategoryInterface' => \common\models\Category::class, |
13 | - 'common\interfaces\TimeInterface' => function () { |
|
14 | - if(Yii::$app->user->getIsGuest()) { |
|
13 | + 'common\interfaces\TimeInterface' => function() { |
|
14 | + if (Yii::$app->user->getIsGuest()) { |
|
15 | 15 | return new \common\components\Time('UTC'); |
16 | 16 | } else { |
17 | 17 | return new \common\components\Time(Yii::$app->user->identity->timezone); |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | public function actionIndex() |
72 | 72 | { |
73 | 73 | $time = Yii::$container->get(\common\interfaces\TimeInterface::class); |
74 | - $key = "index_blog_".$time->getLocalDate('UTC'); |
|
74 | + $key = "index_blog_" . $time->getLocalDate('UTC'); |
|
75 | 75 | $posts = Yii::$app->cache->get($key); |
76 | - if($posts === false) { |
|
76 | + if ($posts === false) { |
|
77 | 77 | $posts = \Yii::$app->getModule('blog') |
78 | 78 | ->fetch() |
79 | 79 | ->parse() |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | { |
107 | 107 | $model = new ContactForm(); |
108 | 108 | if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
109 | - if($model->sendEmail(Yii::$app->params['adminEmail'])) { |
|
109 | + if ($model->sendEmail(Yii::$app->params['adminEmail'])) { |
|
110 | 110 | Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.'); |
111 | 111 | } else { |
112 | 112 | Yii::$app->session->setFlash('error', 'There was an error sending email.'); |
@@ -138,10 +138,10 @@ discard block |
||
138 | 138 | public function actionSignup() |
139 | 139 | { |
140 | 140 | $model = Yii::$container->get(\site\models\SignupForm::class); |
141 | - if($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
141 | + if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
142 | 142 | $model->signup(); |
143 | 143 | Yii::$app->getSession()->setFlash('success', 'We have sent a verification email to the email address you provided. Please check your inbox and follow the instructions to verify your account.'); |
144 | - return $this->redirect('/',302); |
|
144 | + return $this->redirect('/', 302); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | return $this->render('signup', [ |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | public function actionRequestPasswordReset() |
153 | 153 | { |
154 | 154 | $model = Yii::$container->get(\site\models\PasswordResetRequestForm::class); |
155 | - if($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
156 | - if(!$model->sendEmail()) { |
|
155 | + if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
156 | + if (!$model->sendEmail()) { |
|
157 | 157 | $ip = Yii::$app->getRequest()->getUserIP() ?: "UNKNOWN"; |
158 | - Yii::warning("$ip has tried to reset the password for ".$model->email); |
|
158 | + Yii::warning("$ip has tried to reset the password for " . $model->email); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | Yii::$app->getSession()->setFlash('success', 'If there is an account with the submitted email address you will receive further instructions in your email inbox.'); |
@@ -198,14 +198,14 @@ discard block |
||
198 | 198 | throw new BadRequestHttpException("Wrong or expired email verification token. If you aren't sure why this error occurs perhaps you've already verified your account. Please try logging in."); |
199 | 199 | } |
200 | 200 | |
201 | - if($user->isTokenConfirmed($user->verify_email_token)) { |
|
201 | + if ($user->isTokenConfirmed($user->verify_email_token)) { |
|
202 | 202 | Yii::$app->getSession()->setFlash('success', 'Your account has already been verified. Please log in.'); |
203 | - return $this->redirect('/login',302); |
|
203 | + return $this->redirect('/login', 302); |
|
204 | 204 | } else if (Yii::$app->getUser()->login($user)) { |
205 | 205 | $user->confirmVerifyEmailToken(); |
206 | 206 | $user->save(); |
207 | 207 | Yii::$app->getSession()->setFlash('success', 'Your account has been verified. Please continue with your check-in.'); |
208 | - return $this->redirect('/welcome',302); |
|
208 | + return $this->redirect('/welcome', 302); |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | public function actionExport() |
223 | 223 | { |
224 | 224 | header("Content-Type: text/csv"); |
225 | - header("Content-Disposition: attachment; filename=fsa-data-export-".Yii::$app->user->identity->email."-".date('Ymd').".csv"); |
|
225 | + header("Content-Disposition: attachment; filename=fsa-data-export-" . Yii::$app->user->identity->email . "-" . date('Ymd') . ".csv"); |
|
226 | 226 | |
227 | 227 | $reader = Yii::$app->user->identity->getExportData(); |
228 | 228 | $fp = fopen('php://output', 'w'); |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | |
239 | 239 | fputcsv($fp, $header); |
240 | 240 | $user_behavior = Yii::$container->get(\common\interfaces\UserBehaviorInterface::class); |
241 | - while($row = $reader->read()) { |
|
241 | + while ($row = $reader->read()) { |
|
242 | 242 | $row = $user_behavior::decorateWithCategory([$row]); |
243 | 243 | $row = Yii::$app->user->identity->cleanExportData($row); |
244 | 244 | fputcsv($fp, $row[0]); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | if ($editProfileForm->load(Yii::$app->request->post())) { |
69 | 69 | $saved_user = $editProfileForm->saveProfile(); |
70 | - if($saved_user) { |
|
70 | + if ($saved_user) { |
|
71 | 71 | Yii::$app->getSession()->setFlash('success', 'New profile data saved!'); |
72 | 72 | } |
73 | 73 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $model = Yii::$container->get(\site\models\DeleteAccountForm::class, [Yii::$app->user->identity]); |
86 | 86 | |
87 | 87 | if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
88 | - if($model->deleteAccount()) { |
|
88 | + if ($model->deleteAccount()) { |
|
89 | 89 | $this->redirect(['site/index']); |
90 | 90 | } else { |
91 | 91 | Yii::$app->getSession()->setFlash('error', 'Wrong password!'); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | $model = Yii::$container->get(\site\models\ChangePasswordForm::class, [Yii::$app->user->identity]); |
101 | 101 | |
102 | 102 | if ($model->load(Yii::$app->request->post())) { |
103 | - if($model->validate() && $model->changePassword()) { |
|
103 | + if ($model->validate() && $model->changePassword()) { |
|
104 | 104 | Yii::$app->getSession()->setFlash('success', 'Password successfully changed'); |
105 | 105 | } else { |
106 | 106 | Yii::$app->getSession()->setFlash('error', 'Wrong password!'); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | public function actionExport() |
114 | 114 | { |
115 | 115 | header("Content-Type: text/csv"); |
116 | - header("Content-Disposition: attachment; filename=fsa-data-export-".Yii::$app->user->identity->email."-".date('Ymd').".csv"); |
|
116 | + header("Content-Disposition: attachment; filename=fsa-data-export-" . Yii::$app->user->identity->email . "-" . date('Ymd') . ".csv"); |
|
117 | 117 | |
118 | 118 | $reader = Yii::$app->user->identity->getExportData(); |
119 | 119 | $fp = fopen('php://output', 'w'); |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | |
130 | 130 | fputcsv($fp, $header); |
131 | 131 | $user_behavior = Yii::$container->get(\common\interfaces\UserBehaviorInterface::class); |
132 | - while($row = $reader->read()) { |
|
132 | + while ($row = $reader->read()) { |
|
133 | 133 | $row = $user_behavior::decorateWithCategory([$row]); |
134 | 134 | $row = Yii::$app->user->identity->cleanExportData($row); |
135 | 135 | fputcsv($fp, $row[0]); |
@@ -92,7 +92,7 @@ |
||
92 | 92 | print $form |
93 | 93 | ->field($model, "behaviors{$category['id']}") |
94 | 94 | ->checkboxList($behaviors, |
95 | - ['item' => "checkboxItemTemplate"]); |
|
95 | + ['item' => "checkboxItemTemplate"]); |
|
96 | 96 | } |
97 | 97 | ActiveForm::end(); |
98 | 98 |
@@ -41,10 +41,10 @@ |
||
41 | 41 | |
42 | 42 | <?php |
43 | 43 | switch(true) { |
44 | - case ($score < 30): |
|
45 | - $alert_level = "success"; |
|
46 | - $alert_msg = "You're doing well! Keep on doing whatever it is you're doing!"; |
|
47 | - break; |
|
44 | + case ($score < 30): |
|
45 | + $alert_level = "success"; |
|
46 | + $alert_msg = "You're doing well! Keep on doing whatever it is you're doing!"; |
|
47 | + break; |
|
48 | 48 | |
49 | 49 | case ($score < 40): |
50 | 50 | $alert_level = "info"; |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | $this->title = "The Faster Scale App | Previous Check-ins"; |
16 | 16 | $time = Yii::$container->get('common\interfaces\TimeInterface'); |
17 | 17 | $this->registerJsFile('/js/checkin/view.js', ['depends' => [\site\assets\AppAsset::class]]); |
18 | -if($answer_pie) { |
|
18 | +if ($answer_pie) { |
|
19 | 19 | $this->registerJsFile('/js/checkin/charts/pie.js', ['depends' => [\site\assets\AppAsset::class]]); |
20 | 20 | } |
21 | 21 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | } |
26 | 26 | |
27 | 27 | $pie_data = []; |
28 | -if($answer_pie) { |
|
28 | +if ($answer_pie) { |
|
29 | 29 | $values = array_map('intval', array_column($answer_pie, "count")); |
30 | 30 | $labels = array_column($answer_pie, "name"); |
31 | 31 | $colors = array_column($answer_pie, "color"); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | <h1>View Previous Check-ins</h1> |
52 | 52 | |
53 | 53 | <?php |
54 | - switch(true) { |
|
54 | + switch (true) { |
|
55 | 55 | case ($score < 30): |
56 | 56 | $alert_level = "success"; |
57 | 57 | $alert_msg = "You're doing well! Keep on doing whatever it is you're doing!"; |
@@ -112,16 +112,16 @@ discard block |
||
112 | 112 | </div> |
113 | 113 | |
114 | 114 | |
115 | - <?php if($questions) { |
|
115 | + <?php if ($questions) { |
|
116 | 116 | print "<h3>Processing Questions:</h3>"; |
117 | - foreach($questions as $behavior_id => $behavior_questions) { |
|
117 | + foreach ($questions as $behavior_id => $behavior_questions) { |
|
118 | 118 | print "<div class='well well-sm'>"; |
119 | 119 | print "<button type='button' class='btn btn-primary' disabled='disabled'>{$behavior_questions['question']['title']}</button>"; |
120 | 120 | print "<div class='row'>"; |
121 | - foreach($behavior_questions['answers'] as $question) { |
|
121 | + foreach ($behavior_questions['answers'] as $question) { |
|
122 | 122 | print "<div class='col-md-4'>"; |
123 | 123 | print "<p><strong>{$question['title']}</strong></p>"; |
124 | - print "<p>".Html::encode($question['answer'])."</p>"; |
|
124 | + print "<p>" . Html::encode($question['answer']) . "</p>"; |
|
125 | 125 | print "</div>"; |
126 | 126 | } |
127 | 127 | print "</div></div>"; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | 'options' => ['class' => 'form-horizontal'], |
137 | 137 | ]); |
138 | 138 | |
139 | - foreach($categories as $category) { |
|
139 | + foreach ($categories as $category) { |
|
140 | 140 | $behaviors = AH::map($behaviorsList[$category['id']], 'id', 'name'); |
141 | 141 | print $form |
142 | 142 | ->field($model, "behaviors{$category['id']}") |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | ActiveForm::end(); |
147 | 147 | |
148 | 148 | $this->registerJson($past_checkin_dates, "past-checkin-dates"); |
149 | -if($answer_pie) { |
|
149 | +if ($answer_pie) { |
|
150 | 150 | $this->registerJson($pie_data, "pie_data"); |
151 | 151 | } |
152 | 152 | ?> |
@@ -102,9 +102,12 @@ |
||
102 | 102 | <div class='card-text'> |
103 | 103 | <?php if ($pie_data): ?> |
104 | 104 | <canvas id='category-pie-chart'></canvas> |
105 | - <?php else: ?> |
|
105 | + <?php else { |
|
106 | + : ?> |
|
106 | 107 | <p>no data</p> |
107 | - <?php endif; ?> |
|
108 | + <?php endif; |
|
109 | +} |
|
110 | +?> |
|
108 | 111 | </div> |
109 | 112 | </div> |
110 | 113 | </div> |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | if ($form->load(Yii::$app->request->post()) && $form->validate()) { |
40 | 40 | $form->compiled_behaviors = $form->compileBehaviors(); |
41 | 41 | |
42 | - if(sizeof($form->compiled_behaviors) === 0) { |
|
42 | + if (sizeof($form->compiled_behaviors) === 0) { |
|
43 | 43 | return $this->redirect(['view']); |
44 | 44 | } |
45 | 45 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $date = Yii::$container->get(\common\interfaces\TimeInterface::class)->getLocalDate(); |
66 | 66 | |
67 | 67 | $user_behaviors = $user_behavior->getUserBehaviorsWithCategory($date); |
68 | - if(count($user_behaviors) === 0) { |
|
68 | + if (count($user_behaviors) === 0) { |
|
69 | 69 | return $this->redirect(['view']); |
70 | 70 | } |
71 | 71 | |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | $form->deleteToday(); |
76 | 76 | |
77 | 77 | $behaviors = $user_behavior->findAll($form->getUserBehaviorIds()); |
78 | - if($result = $form->saveAnswers($behaviors)) { |
|
78 | + if ($result = $form->saveAnswers($behaviors)) { |
|
79 | 79 | |
80 | - if(Yii::$app->user->identity->send_email) { |
|
80 | + if (Yii::$app->user->identity->send_email) { |
|
81 | 81 | Yii::$app->user->identity->sendEmailReport($date); |
82 | 82 | Yii::$app->session->setFlash('success', 'Your check-in is complete. A notification has been sent to your report partners.'); |
83 | 83 | } else { |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | public function actionView(string $date = null) |
98 | 98 | { |
99 | 99 | $time = Yii::$container->get(\common\interfaces\TimeInterface::class); |
100 | - if(is_null($date)) { |
|
100 | + if (is_null($date)) { |
|
101 | 101 | $date = $time->getLocalDate(); |
102 | - } else if($dt = $time->parse($date)) { |
|
102 | + } else if ($dt = $time->parse($date)) { |
|
103 | 103 | $date = $dt->format('Y-m-d'); |
104 | 104 | } else { |
105 | 105 | $date = $time->getLocalDate(); |
@@ -25,7 +25,7 @@ |
||
25 | 25 | <?= $form->field($profile, 'email', ['inputTemplate' => '<div class="input-group"><span class="input-group-addon">@</span>{input}</div>']); ?> |
26 | 26 | <?= $form->field($profile, 'timezone')->dropDownList(array_combine($timezones, $timezones)); ?> |
27 | 27 | <?= $form->field($profile, 'send_email')->checkbox() ?> |
28 | - <div id='send_email_fields' <?php if(!$profile->send_email) { ?>style="display: none;"<?php } ?>> |
|
28 | + <div id='send_email_fields' <?php if (!$profile->send_email) { ?>style="display: none;"<?php } ?>> |
|
29 | 29 | <?= $form->field($profile, 'partner_email1')->input('email'); ?> |
30 | 30 | <?= $form->field($profile, 'partner_email2')->input('email'); ?> |
31 | 31 | <?= $form->field($profile, 'partner_email3')->input('email'); ?> |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | ['email', 'filter', 'filter' => 'trim'], |
42 | 42 | ['email', 'filter', 'filter' => 'strtolower'], |
43 | 43 | ['email', 'email'], |
44 | - ['email', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This email address has already been taken.', 'filter' => "id <> ".Yii::$app->user->id], |
|
44 | + ['email', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This email address has already been taken.', 'filter' => "id <> " . Yii::$app->user->id], |
|
45 | 45 | |
46 | 46 | ['timezone', 'string', 'min' => 2, 'max' => 255], |
47 | 47 | ['timezone', 'in', 'range'=>DateTimeZone::listIdentifiers()], |
@@ -75,18 +75,18 @@ discard block |
||
75 | 75 | public function saveProfile() |
76 | 76 | { |
77 | 77 | if ($this->validate()) { |
78 | - $user = $this->user; |
|
78 | + $user = $this->user; |
|
79 | 79 | |
80 | - if($this->email) |
|
80 | + if ($this->email) |
|
81 | 81 | $user->email = $this->email; |
82 | - if($this->timezone) |
|
82 | + if ($this->timezone) |
|
83 | 83 | $user->timezone = $this->timezone; |
84 | - if($this->expose_graph) { |
|
84 | + if ($this->expose_graph) { |
|
85 | 85 | $user->expose_graph = true; |
86 | 86 | } else { |
87 | 87 | $user->expose_graph = false; |
88 | 88 | } |
89 | - if($this->send_email) { |
|
89 | + if ($this->send_email) { |
|
90 | 90 | $user->partner_email1 = $this->partner_email1; |
91 | 91 | $user->partner_email2 = $this->partner_email2; |
92 | 92 | $user->partner_email3 = $this->partner_email3; |
@@ -77,10 +77,12 @@ |
||
77 | 77 | if ($this->validate()) { |
78 | 78 | $user = $this->user; |
79 | 79 | |
80 | - if($this->email) |
|
81 | - $user->email = $this->email; |
|
82 | - if($this->timezone) |
|
83 | - $user->timezone = $this->timezone; |
|
80 | + if($this->email) { |
|
81 | + $user->email = $this->email; |
|
82 | + } |
|
83 | + if($this->timezone) { |
|
84 | + $user->timezone = $this->timezone; |
|
85 | + } |
|
84 | 86 | if($this->expose_graph) { |
85 | 87 | $user->expose_graph = true; |
86 | 88 | } else { |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function signup() { |
84 | 84 | $user = $this->user->findByEmail($this->email); |
85 | - if(!$user) { |
|
85 | + if (!$user) { |
|
86 | 86 | // this is a brand new user |
87 | 87 | $this->user = $this->setFields($this->user); |
88 | 88 | $this->user->save(); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * this is a user that for whatever reason is trying to sign up again |
97 | 97 | * with the same email address. |
98 | 98 | */ |
99 | - if(!$user->isTokenConfirmed()) { |
|
99 | + if (!$user->isTokenConfirmed()) { |
|
100 | 100 | /* |
101 | 101 | * they've never verified their account. We don't care if their |
102 | 102 | * verification token is current or expired. We're resetting their |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $user->generateAuthKey(); |
125 | 125 | $user->generateVerifyEmailToken(); |
126 | 126 | |
127 | - if($user->send_email) { |
|
127 | + if ($user->send_email) { |
|
128 | 128 | $user->partner_email1 = $this->partner_email1; |
129 | 129 | $user->partner_email2 = $this->partner_email2; |
130 | 130 | $user->partner_email3 = $this->partner_email3; |
@@ -89,19 +89,19 @@ |
||
89 | 89 | expect('decorate should add Behavior data and Category data to an array of UserBehaviors', |
90 | 90 | $this->assertEquals( |
91 | 91 | $this->user_behavior->decorateWithCategory($this->singleSimpleBehaviorNoBehavior), |
92 | - [['id' => 396, |
|
93 | - 'user_id' => 2, |
|
94 | - 'behavior_id' => 107, |
|
95 | - 'date' => '2016-06-17 04:12:43', |
|
96 | - 'behavior' => [ |
|
97 | - 'id' => 107, |
|
98 | - 'name' => 'numb', |
|
99 | - 'category_id' => 6, |
|
100 | - 'category' => [ |
|
101 | - 'id' => 6, |
|
102 | - 'name' => 'Exhausted', |
|
103 | - ] |
|
104 | - ]]])); |
|
92 | + [['id' => 396, |
|
93 | + 'user_id' => 2, |
|
94 | + 'behavior_id' => 107, |
|
95 | + 'date' => '2016-06-17 04:12:43', |
|
96 | + 'behavior' => [ |
|
97 | + 'id' => 107, |
|
98 | + 'name' => 'numb', |
|
99 | + 'category_id' => 6, |
|
100 | + 'category' => [ |
|
101 | + 'id' => 6, |
|
102 | + 'name' => 'Exhausted', |
|
103 | + ] |
|
104 | + ]]])); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | public function testGetTopBehaviors() { |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | ]; |
34 | 34 | public function setUp() { |
35 | 35 | // pull in test data |
36 | - $data = require(__DIR__.'/../data/checkinData.php'); |
|
36 | + $data = require(__DIR__ . '/../data/checkinData.php'); |
|
37 | 37 | $this->singleBhvr = $data['singleBhvr']; |
38 | 38 | $this->manyBhvrs = $data['manyBhvrs']; |
39 | 39 | $this->allBhvrs = $data['allBhvrs']; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $this->container->set('common\interfaces\UserInterface', '\site\tests\_support\MockUser'); |
44 | 44 | $this->container->set('common\interfaces\QuestionInterface', '\site\tests\_support\MockQuestion'); |
45 | 45 | $this->container->set('common\interfaces\BehaviorInterface', 'common\models\Behavior'); |
46 | - $this->container->set('common\interfaces\TimeInterface', function () { |
|
46 | + $this->container->set('common\interfaces\TimeInterface', function() { |
|
47 | 47 | return new \common\components\Time('America/Los_Angeles'); |
48 | 48 | }); |
49 | 49 |