@@ -158,7 +158,9 @@ discard block |
||
158 | 158 | */ |
159 | 159 | public function findByVerifyEmailToken($token) |
160 | 160 | { |
161 | - if($this->isTokenConfirmed($token)) return null; |
|
161 | + if($this->isTokenConfirmed($token)) { |
|
162 | + return null; |
|
163 | + } |
|
162 | 164 | |
163 | 165 | $user = $this->findOne([ |
164 | 166 | 'verify_email_token' => [$token, $token . self::CONFIRMED_STRING], |
@@ -222,7 +224,9 @@ discard block |
||
222 | 224 | * @param string $match the needle to search for |
223 | 225 | */ |
224 | 226 | public function isTokenConfirmed($token = null, String $match = self::CONFIRMED_STRING) { |
225 | - if(is_null($token)) $token = $this->verify_email_token; |
|
227 | + if(is_null($token)) { |
|
228 | + $token = $this->verify_email_token; |
|
229 | + } |
|
226 | 230 | return substr($token, -strlen($match)) === $match; |
227 | 231 | } |
228 | 232 | |
@@ -366,7 +370,10 @@ discard block |
||
366 | 370 | * partner email address the user has set. |
367 | 371 | */ |
368 | 372 | public function sendEmailReport($date) { |
369 | - if(!$this->send_email) return false; // no partner emails set |
|
373 | + if(!$this->send_email) { |
|
374 | + return false; |
|
375 | + } |
|
376 | + // no partner emails set |
|
370 | 377 | list($start, $end) = $this->time->getUTCBookends($date); |
371 | 378 | |
372 | 379 | $user_behavior = Yii::$container->get(UserBehaviorInterface::class); |
@@ -375,14 +382,22 @@ discard block |
||
375 | 382 | // we should only proceed with sending the email if the user |
376 | 383 | // scored above their set email threshold (User::email_category) |
377 | 384 | $this_checkin = $checkins_last_month[$date]; // gets the check-in |
378 | - if(!$this_checkin) return false; // sanity check |
|
385 | + if(!$this_checkin) { |
|
386 | + return false; |
|
387 | + } |
|
388 | + // sanity check |
|
379 | 389 | $highest_cat_data = end($this_checkin); // gets the data for the highest category from the check-in |
380 | - if(!$highest_cat_data) return false; // another sanity check |
|
390 | + if(!$highest_cat_data) { |
|
391 | + return false; |
|
392 | + } |
|
393 | + // another sanity check |
|
381 | 394 | $highest_cat_idx = key($this_checkin); // gets the key of the highest category |
382 | 395 | |
383 | 396 | // if the highest category they reached today was less than |
384 | 397 | // the category threshold they have set, don't send the email |
385 | - if($highest_cat_idx < $this->email_category) return false; |
|
398 | + if($highest_cat_idx < $this->email_category) { |
|
399 | + return false; |
|
400 | + } |
|
386 | 401 | |
387 | 402 | $user_behaviors = $user_behavior->getByDate(Yii::$app->user->id, $date); |
388 | 403 |
@@ -523,26 +523,26 @@ |
||
523 | 523 | } |
524 | 524 | |
525 | 525 | public function cleanExportData($row) { |
526 | - // change timestamp to local time (for the user) |
|
527 | - $row['date'] = $this->time->convertUTCToLocal($row['date'], false); |
|
528 | - |
|
529 | - // clean up things we don't need |
|
530 | - $row['category'] = $row['category']['name']; |
|
531 | - if(array_key_exists('behavior', $row)) { |
|
532 | - $row['behavior'] = $row['behavior']['name']; |
|
533 | - } else { |
|
534 | - $row['behavior'] = $row['custom_behavior']; |
|
535 | - } |
|
536 | - unset($row['id']); |
|
537 | - unset($row['behavior_id']); |
|
538 | - unset($row['category_id']); |
|
539 | - unset($row['custom_behavior']); |
|
540 | - |
|
541 | - // sort the array into a sensible order |
|
542 | - uksort($row, function($a, $b) { |
|
543 | - return $this->export_order[$a] <=> $this->export_order[$b]; |
|
544 | - }); |
|
545 | - return $row; |
|
526 | + // change timestamp to local time (for the user) |
|
527 | + $row['date'] = $this->time->convertUTCToLocal($row['date'], false); |
|
528 | + |
|
529 | + // clean up things we don't need |
|
530 | + $row['category'] = $row['category']['name']; |
|
531 | + if(array_key_exists('behavior', $row)) { |
|
532 | + $row['behavior'] = $row['behavior']['name']; |
|
533 | + } else { |
|
534 | + $row['behavior'] = $row['custom_behavior']; |
|
535 | + } |
|
536 | + unset($row['id']); |
|
537 | + unset($row['behavior_id']); |
|
538 | + unset($row['category_id']); |
|
539 | + unset($row['custom_behavior']); |
|
540 | + |
|
541 | + // sort the array into a sensible order |
|
542 | + uksort($row, function($a, $b) { |
|
543 | + return $this->export_order[$a] <=> $this->export_order[$b]; |
|
544 | + }); |
|
545 | + return $row; |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /* |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | */ |
150 | 150 | public function findByPasswordResetToken($token) |
151 | 151 | { |
152 | - if(!$this->isTokenCurrent($token)) { |
|
152 | + if (!$this->isTokenCurrent($token)) { |
|
153 | 153 | return null; |
154 | 154 | } |
155 | 155 | |
@@ -167,15 +167,15 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public function findByVerifyEmailToken($token) |
169 | 169 | { |
170 | - if($this->isTokenConfirmed($token)) return null; |
|
170 | + if ($this->isTokenConfirmed($token)) return null; |
|
171 | 171 | |
172 | 172 | $user = $this->findOne([ |
173 | 173 | 'verify_email_token' => [$token, $token . self::CONFIRMED_STRING], |
174 | 174 | 'status' => self::STATUS_ACTIVE, |
175 | 175 | ]); |
176 | 176 | |
177 | - if($user) { |
|
178 | - if(!$this->isTokenConfirmed($token) && |
|
177 | + if ($user) { |
|
178 | + if (!$this->isTokenConfirmed($token) && |
|
179 | 179 | !$this->isTokenCurrent($token, 'user.verifyAccountTokenExpire')) { |
180 | 180 | return null; |
181 | 181 | } |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | 'status' => self::STATUS_ACTIVE, |
198 | 198 | ]); |
199 | 199 | |
200 | - if($user) { |
|
201 | - if(!$user->isTokenCurrent($token, 'user.verifyAccountTokenExpire')) { |
|
200 | + if ($user) { |
|
201 | + if (!$user->isTokenCurrent($token, 'user.verifyAccountTokenExpire')) { |
|
202 | 202 | return null; |
203 | 203 | } |
204 | 204 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | public function isTokenCurrent($token, String $paramPath = 'user.passwordResetTokenExpire') { |
217 | 217 | $expire = \Yii::$app->params[$paramPath]; |
218 | 218 | $parts = explode('_', $token); |
219 | - $timestamp = (int) end($parts); |
|
219 | + $timestamp = (int)end($parts); |
|
220 | 220 | if ($timestamp + $expire < time()) { |
221 | 221 | // token expired |
222 | 222 | return false; |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @param string $match the needle to search for |
232 | 232 | */ |
233 | 233 | public function isTokenConfirmed($token = null, String $match = self::CONFIRMED_STRING) { |
234 | - if(is_null($token)) $token = $this->verify_email_token; |
|
234 | + if (is_null($token)) $token = $this->verify_email_token; |
|
235 | 235 | return substr($token, -strlen($match)) === $match; |
236 | 236 | } |
237 | 237 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | } |
257 | 257 | |
258 | 258 | public function isVerified() { |
259 | - if(is_null($this->verify_email_token)) { |
|
259 | + if (is_null($this->verify_email_token)) { |
|
260 | 260 | // for old users who verified their accounts before the addition of |
261 | 261 | // '_confirmed' to the token |
262 | 262 | return true; |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * partner email address the user has set. |
376 | 376 | */ |
377 | 377 | public function sendEmailReport($date) { |
378 | - if(!$this->send_email) return false; // no partner emails set |
|
378 | + if (!$this->send_email) return false; // no partner emails set |
|
379 | 379 | list($start, $end) = $this->time->getUTCBookends($date); |
380 | 380 | |
381 | 381 | $user_behavior = Yii::$container->get(UserBehaviorInterface::class); |
@@ -384,14 +384,14 @@ discard block |
||
384 | 384 | // we should only proceed with sending the email if the user |
385 | 385 | // scored above their set email threshold (User::email_category) |
386 | 386 | $this_checkin = $checkins_last_month[$date]; // gets the check-in |
387 | - if(!$this_checkin) return false; // sanity check |
|
388 | - $highest_cat_data = end($this_checkin); // gets the data for the highest category from the check-in |
|
389 | - if(!$highest_cat_data) return false; // another sanity check |
|
390 | - $highest_cat_idx = key($this_checkin); // gets the key of the highest category |
|
387 | + if (!$this_checkin) return false; // sanity check |
|
388 | + $highest_cat_data = end($this_checkin); // gets the data for the highest category from the check-in |
|
389 | + if (!$highest_cat_data) return false; // another sanity check |
|
390 | + $highest_cat_idx = key($this_checkin); // gets the key of the highest category |
|
391 | 391 | |
392 | 392 | // if the highest category they reached today was less than |
393 | 393 | // the category threshold they have set, don't send the email |
394 | - if($highest_cat_idx < $this->email_category) return false; |
|
394 | + if ($highest_cat_idx < $this->email_category) return false; |
|
395 | 395 | |
396 | 396 | $user_behaviors = $user_behavior->getByDate(Yii::$app->user->id, $date); |
397 | 397 | |
@@ -403,8 +403,8 @@ discard block |
||
403 | 403 | ->create($checkins_last_month); |
404 | 404 | |
405 | 405 | $messages = []; |
406 | - foreach($this->getPartnerEmails() as $email) { |
|
407 | - if($email) { |
|
406 | + foreach ($this->getPartnerEmails() as $email) { |
|
407 | + if ($email) { |
|
408 | 408 | $messages[] = Yii::$app->mailer->compose('checkinReport', [ |
409 | 409 | 'user' => $this, |
410 | 410 | 'email' => $email, |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | 'behaviors_list' => \common\models\Behavior::$behaviors, |
417 | 417 | ])->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name]) |
418 | 418 | ->setReplyTo($this->email) |
419 | - ->setSubject($this->email." has completed a Faster Scale check-in") |
|
419 | + ->setSubject($this->email . " has completed a Faster Scale check-in") |
|
420 | 420 | ->setTo($email); |
421 | 421 | } |
422 | 422 | } |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | return \Yii::$app->mailer->compose('signupNotification') |
494 | 494 | ->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name]) |
495 | 495 | ->setTo(\Yii::$app->params['adminEmail']) |
496 | - ->setSubject('A new user has signed up for '.\Yii::$app->name) |
|
496 | + ->setSubject('A new user has signed up for ' . \Yii::$app->name) |
|
497 | 497 | ->send(); |
498 | 498 | } |
499 | 499 | |
@@ -501,20 +501,20 @@ discard block |
||
501 | 501 | return \Yii::$app->mailer->compose('verifyEmail', ['user' => $this]) |
502 | 502 | ->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name]) |
503 | 503 | ->setTo($this->email) |
504 | - ->setSubject('Please verify your '.\Yii::$app->name .' account') |
|
504 | + ->setSubject('Please verify your ' . \Yii::$app->name . ' account') |
|
505 | 505 | ->send(); |
506 | 506 | } |
507 | 507 | |
508 | 508 | public function sendDeleteNotificationEmail() { |
509 | 509 | $messages = []; |
510 | - foreach(array_merge([$this->email], $this->getPartnerEmails()) as $email) { |
|
511 | - if($email) { |
|
510 | + foreach (array_merge([$this->email], $this->getPartnerEmails()) as $email) { |
|
511 | + if ($email) { |
|
512 | 512 | $messages[] = Yii::$app->mailer->compose('deleteNotification', [ |
513 | 513 | 'user' => $this, |
514 | 514 | 'email' => $email |
515 | 515 | ])->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name]) |
516 | 516 | ->setReplyTo($this->email) |
517 | - ->setSubject($this->email." has deleted their The Faster Scale App account") |
|
517 | + ->setSubject($this->email . " has deleted their The Faster Scale App account") |
|
518 | 518 | ->setTo($email); |
519 | 519 | } |
520 | 520 | } |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | |
529 | 529 | // clean up things we don't need |
530 | 530 | $row['category'] = $row['category']['name']; |
531 | - if(array_key_exists('behavior', $row)) { |
|
531 | + if (array_key_exists('behavior', $row)) { |
|
532 | 532 | $row['behavior'] = $row['behavior']['name']; |
533 | 533 | } else { |
534 | 534 | $row['behavior'] = $row['custom_behavior']; |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | return rtrim( |
565 | 565 | strtr( |
566 | 566 | base64_encode( |
567 | - hash('sha256', $this->id."::".$this->created_at, true) |
|
567 | + hash('sha256', $this->id . "::" . $this->created_at, true) |
|
568 | 568 | ), |
569 | 569 | '+/', '-_'), |
570 | 570 | '='); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | 'whenClient' => "function(attribute, value) { return false; }", // lame, but acceptable |
74 | 74 | "message" => "You must select a behavior your responses apply to."], |
75 | 75 | |
76 | - [['answer_1a','answer_1b','answer_1c','answer_2a','answer_2b','answer_2c','answer_3a','answer_3b','answer_3c','answer_4a','answer_4b','answer_4c','answer_5a', 'answer_5b','answer_5c','answer_6a', 'answer_6b','answer_6c','answer_7a','answer_7b','answer_7c'], 'safe'] |
|
76 | + [['answer_1a', 'answer_1b', 'answer_1c', 'answer_2a', 'answer_2b', 'answer_2c', 'answer_3a', 'answer_3b', 'answer_3c', 'answer_4a', 'answer_4b', 'answer_4c', 'answer_5a', 'answer_5b', 'answer_5c', 'answer_6a', 'answer_6b', 'answer_6c', 'answer_7a', 'answer_7b', 'answer_7c'], 'safe'] |
|
77 | 77 | ]; |
78 | 78 | } |
79 | 79 | |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | |
92 | 92 | public function getBhvrValidator() { |
93 | 93 | return function($model, $attr) { |
94 | - $attrNum = $attr[strlen($attr)-1]; |
|
95 | - foreach(['a', 'b', 'c'] as $l) { |
|
94 | + $attrNum = $attr[strlen($attr) - 1]; |
|
95 | + foreach (['a', 'b', 'c'] as $l) { |
|
96 | 96 | $attr = "answer_{$attrNum}{$l}"; |
97 | - if($model->$attr) return true; |
|
97 | + if ($model->$attr) return true; |
|
98 | 98 | } |
99 | 99 | return false; |
100 | 100 | }; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | public function getPrefixProps($prefix) { |
127 | 127 | return array_filter(get_object_vars($this), function($v, $k) use($prefix) { |
128 | - if(strpos($k, $prefix) === 0 && strlen($v)) { |
|
128 | + if (strpos($k, $prefix) === 0 && strlen($v)) { |
|
129 | 129 | return true; |
130 | 130 | } |
131 | 131 | }, ARRAY_FILTER_USE_BOTH); |
@@ -143,9 +143,9 @@ discard block |
||
143 | 143 | public function getAnswers($bhvrs) { |
144 | 144 | $answers = []; |
145 | 145 | $user_bhvrs = array_combine($this->getUserBehaviorProps(), $bhvrs); |
146 | - foreach($user_bhvrs as $property => $user_bhvr) { |
|
146 | + foreach ($user_bhvrs as $property => $user_bhvr) { |
|
147 | 147 | $behavior_id = intval(substr($property, -1, 1)); |
148 | - foreach($this->behaviorToAnswers($behavior_id) as $answer_letter => $answer) { |
|
148 | + foreach ($this->behaviorToAnswers($behavior_id) as $answer_letter => $answer) { |
|
149 | 149 | $question_id = \common\models\Question::$TYPES[$answer_letter]; |
150 | 150 | array_push($answers, [ |
151 | 151 | 'behavior_id' => $user_bhvr->behavior_id, |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | |
162 | 162 | public function saveAnswers($bhvrs) { |
163 | 163 | $result = true; |
164 | - foreach($this->getAnswers($bhvrs) as $answer) { |
|
164 | + foreach ($this->getAnswers($bhvrs) as $answer) { |
|
165 | 165 | $model = new \common\models\Question; |
166 | 166 | $model->user_id = Yii::$app->user->id; |
167 | 167 | $model->behavior_id = $answer['behavior_id']; |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | $model->date = new Expression("now()::timestamp"); |
171 | 171 | $model->question = $answer['question_id']; |
172 | 172 | $model->answer = $answer['answer']; |
173 | - if(!$model->save()) { |
|
173 | + if (!$model->save()) { |
|
174 | 174 | $result = false; |
175 | - var_dump( $model->errors); |
|
175 | + var_dump($model->errors); |
|
176 | 176 | exit(); |
177 | 177 | } |
178 | 178 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | $plus_week = $time->alterLocalDate($actual_date, "+1 week"); |
28 | 28 | |
29 | 29 | $pie_data = []; |
30 | -if($answer_pie) { |
|
30 | +if ($answer_pie) { |
|
31 | 31 | $values = array_map('intval', array_column($answer_pie, "count")); |
32 | 32 | $labels = array_column($answer_pie, "name"); |
33 | 33 | $colors = array_column($answer_pie, "color"); |
@@ -68,15 +68,15 @@ discard block |
||
68 | 68 | </div> |
69 | 69 | </div> |
70 | 70 | |
71 | - <?php if($questions) { |
|
72 | - foreach($questions as $behavior_id => $behavior_questions) { |
|
71 | + <?php if ($questions) { |
|
72 | + foreach ($questions as $behavior_id => $behavior_questions) { |
|
73 | 73 | print "<div class='well well-sm'>"; |
74 | 74 | print "<button type='button' class='btn btn-primary' disabled='disabled'>{$behavior_questions['question']['behavior_name']}</button>"; |
75 | 75 | print "<div class='row'>"; |
76 | - foreach($behavior_questions['answers'] as $question) { |
|
76 | + foreach ($behavior_questions['answers'] as $question) { |
|
77 | 77 | print "<div class='col-md-4'>"; |
78 | 78 | print "<p><strong>{$question['title']}</strong></p>"; |
79 | - print "<p>".Html::encode($question['answer'])."</p>"; |
|
79 | + print "<p>" . Html::encode($question['answer']) . "</p>"; |
|
80 | 80 | print "</div>"; |
81 | 81 | } |
82 | 82 | print "</div></div>"; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | 'options' => ['class' => 'form-horizontal'], |
89 | 89 | ]); |
90 | 90 | |
91 | - foreach($categories as $category) { |
|
91 | + foreach ($categories as $category) { |
|
92 | 92 | $behaviors = AH::map($behaviorsList[$category['id']], 'id', 'name'); |
93 | 93 | print $form |
94 | 94 | ->field($model, "behaviors{$category['id']}") |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | $this->container = new \yii\di\Container; |
33 | 33 | $this->container->set('common\interfaces\UserInterface', '\site\tests\_support\MockUser'); |
34 | 34 | $this->container->set('common\interfaces\UserBehaviorInterface', '\site\tests\_support\MockUserBehavior'); |
35 | - $this->container->set('common\interfaces\TimeInterface', function () { |
|
35 | + $this->container->set('common\interfaces\TimeInterface', function() { |
|
36 | 36 | return new \common\components\Time('America/Los_Angeles'); |
37 | 37 | }); |
38 | 38 | |
39 | 39 | // instantiate mock objects |
40 | 40 | $user_behavior = $this->container->get(\common\interfaces\UserBehaviorInterface::class); |
41 | - $time = $this->container->get(\common\interfaces\TimeInterface::class); |
|
41 | + $time = $this->container->get(\common\interfaces\TimeInterface::class); |
|
42 | 42 | |
43 | 43 | $question = $this->getMockBuilder(\common\models\Question::class) |
44 | 44 | ->setMethods(['save', 'attributes']) |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | // set up a side effect to occur when the user's save() function is called |
109 | 109 | $saved = false; |
110 | - $this->user->method('save')->will($this->returnCallback(function($runValidation=true, $attributeNames=null) use(&$saved) { |
|
110 | + $this->user->method('save')->will($this->returnCallback(function($runValidation = true, $attributeNames = null) use(&$saved) { |
|
111 | 111 | $saved = true; |
112 | 112 | return $this->user; |
113 | 113 | })); |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | |
134 | 134 | public function testSignupExistingConfirmedUser() { |
135 | 135 | $saved = false; |
136 | - $this->existing_user->method('save')->will($this->returnCallback(function($runValidation=true, $attributeNames=null) use(&$saved) { |
|
136 | + $this->existing_user->method('save')->will($this->returnCallback(function($runValidation = true, $attributeNames = null) use(&$saved) { |
|
137 | 137 | $saved = true; |
138 | 138 | return $this->existing_user; |
139 | 139 | })); |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | |
153 | 153 | public function testSignupExistingUnconfirmedUser() { |
154 | 154 | $saved = false; |
155 | - $this->existing_user->method('save')->will($this->returnCallback(function($runValidation=true, $attributeNames=null) use(&$saved) { |
|
155 | + $this->existing_user->method('save')->will($this->returnCallback(function($runValidation = true, $attributeNames = null) use(&$saved) { |
|
156 | 156 | $saved = true; |
157 | 157 | return $this->existing_user; |
158 | 158 | })); |
@@ -183,14 +183,14 @@ discard block |
||
183 | 183 | |
184 | 184 | $result = $form->setFields($this->user); |
185 | 185 | $this->specify('populate should set the values of the user model from the form', function() use ($result) { |
186 | - foreach($this->whitelist as $attr) { |
|
186 | + foreach ($this->whitelist as $attr) { |
|
187 | 187 | $this->assertEquals($this->vals[$attr], $result->$attr); |
188 | 188 | } |
189 | 189 | }); |
190 | 190 | } |
191 | 191 | |
192 | 192 | private function setAttrs($form, Array $vals) { |
193 | - foreach($vals as $key => $val) { |
|
193 | + foreach ($vals as $key => $val) { |
|
194 | 194 | $form->$key = $val; |
195 | 195 | } |
196 | 196 | return $form; |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | } |
212 | 212 | |
213 | 213 | private function getForm($user = null) { |
214 | - if(is_null($user)) $user = $this->user; |
|
214 | + if (is_null($user)) $user = $this->user; |
|
215 | 215 | $form = $this->container->get('\site\models\SignupForm', [$user]); |
216 | 216 | $form->attributes = $this->vals; // massive assignment |
217 | 217 | return $form; |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | 'allow' => true, |
28 | 28 | 'roles' => ['@'], |
29 | 29 | ], [ |
30 | - 'actions' => [ 'change-email', ], |
|
30 | + 'actions' => ['change-email', ], |
|
31 | 31 | 'allow' => true, |
32 | 32 | ], |
33 | 33 | ], |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | if ($editProfileForm->load(Yii::$app->request->post())) { |
60 | 60 | $saved_user = $editProfileForm->saveProfile(); |
61 | - if($saved_user) { |
|
61 | + if ($saved_user) { |
|
62 | 62 | Yii::$app->session->setFlash('success', 'New profile data saved!'); |
63 | 63 | } |
64 | 64 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | $model = Yii::$container->get(\site\models\DeleteAccountForm::class, [Yii::$app->user->identity]); |
79 | 79 | |
80 | 80 | if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
81 | - if($model->deleteAccount()) { |
|
81 | + if ($model->deleteAccount()) { |
|
82 | 82 | $this->redirect(['site/index']); |
83 | 83 | } else { |
84 | 84 | Yii::$app->session->setFlash('error', 'Wrong password!'); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $model = Yii::$container->get(\site\models\ChangePasswordForm::class, [Yii::$app->user->identity]); |
93 | 93 | |
94 | 94 | if ($model->load(Yii::$app->request->post())) { |
95 | - if($model->validate() && $model->changePassword()) { |
|
95 | + if ($model->validate() && $model->changePassword()) { |
|
96 | 96 | Yii::$app->session->setFlash('success', 'Password successfully changed'); |
97 | 97 | } else { |
98 | 98 | Yii::$app->session->setFlash('error', 'Wrong password!'); |
@@ -116,14 +116,14 @@ discard block |
||
116 | 116 | public function actionChangeEmail(string $token) { |
117 | 117 | $user = Yii::$container->get(\common\interfaces\UserInterface::class)->findByChangeEmailToken($token); |
118 | 118 | |
119 | - if($user) { |
|
119 | + if ($user) { |
|
120 | 120 | $validator = new \yii\validators\EmailValidator(); |
121 | - if($validator->validate($user->desired_email, $error)) { |
|
121 | + if ($validator->validate($user->desired_email, $error)) { |
|
122 | 122 | $user->removeChangeEmailToken(); |
123 | 123 | $user->email = $user->desired_email; |
124 | 124 | $user->desired_email = null; |
125 | 125 | $user->save(); |
126 | - if(!Yii::$app->user->isGuest) { |
|
126 | + if (!Yii::$app->user->isGuest) { |
|
127 | 127 | Yii::$app->user->logout(); |
128 | 128 | Yii::$app->session->setFlash('success', 'Your email address was successfully changed. For security, we\'ve logged you out.'); |
129 | 129 | } else { |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | |
144 | 144 | public function actionExport() { |
145 | 145 | header("Content-Type: text/csv"); |
146 | - header("Content-Disposition: attachment; filename=fsa-data-export-".Yii::$app->user->identity->email."-".date('Ymd').".csv"); |
|
146 | + header("Content-Disposition: attachment; filename=fsa-data-export-" . Yii::$app->user->identity->email . "-" . date('Ymd') . ".csv"); |
|
147 | 147 | |
148 | 148 | $reader = Yii::$app->user->identity->getExportData(); |
149 | 149 | $fp = fopen('php://output', 'w'); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | |
160 | 160 | fputcsv($fp, $header); |
161 | 161 | $user_behavior = Yii::$container->get(\common\interfaces\UserBehaviorInterface::class); |
162 | - while($row = $reader->read()) { |
|
162 | + while ($row = $reader->read()) { |
|
163 | 163 | $row = $user_behavior::decorate([$row]); |
164 | 164 | $row = Yii::$app->user->identity->cleanExportData($row[0]); |
165 | 165 | fputcsv($fp, $row); |
@@ -125,14 +125,14 @@ discard block |
||
125 | 125 | <th style="Margin:0;color:#0a0a0a;font-family:Arial,Verdana,Helvetica,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left"> |
126 | 126 | |
127 | 127 | <?php |
128 | -if($questions) { |
|
129 | - foreach($questions as $behavior_id => $behavior_questions) { |
|
128 | +if ($questions) { |
|
129 | + foreach ($questions as $behavior_id => $behavior_questions) { |
|
130 | 130 | ?> |
131 | 131 | |
132 | 132 | <h4 style="Margin:0;Margin-bottom:10px;color:#37b98f;font-family:Arial,Verdana,Helvetica,sans-serif;font-size:24px;font-weight:400;line-height:1.3;margin:0;margin-bottom:5px;padding:0 8px;text-align:left;word-wrap:normal"> <?= Html::encode($behavior_questions['question']['behavior_name']) ?> </h4> |
133 | 133 | |
134 | 134 | <?php |
135 | - foreach($behavior_questions['answers'] as $key => $question) { ?> |
|
135 | + foreach ($behavior_questions['answers'] as $key => $question) { ?> |
|
136 | 136 | <p style="Margin:0;Margin-bottom:10px;color:#0a0a0a;font-family:Arial,Verdana,Helvetica,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0 8px 4px 8px;text-align:left"><strong><?= Html::encode($question['title']) ?></strong> <?= Html::encode($question['answer']) ?></p> |
137 | 137 | <?php |
138 | 138 | } |
@@ -189,12 +189,12 @@ discard block |
||
189 | 189 | <th style="Margin:0;color:#0a0a0a;font-family:Arial,Verdana,Helvetica,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left"> |
190 | 190 | |
191 | 191 | <?php |
192 | -if($user_behaviors) { |
|
193 | - foreach($user_behaviors as $cat_key => $behaviors) { ?> |
|
192 | +if ($user_behaviors) { |
|
193 | + foreach ($user_behaviors as $cat_key => $behaviors) { ?> |
|
194 | 194 | <p style="Margin:0;Margin-bottom:10px;color:#0a0a0a;font-family:Arial,Verdana,Helvetica,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0 8px 4px 8px;text-align:left"> |
195 | 195 | <strong style="color:#37b98f"><?= Html::encode($categories[$cat_key]) ?></strong> |
196 | 196 | <?php |
197 | - foreach($behaviors as $behavior) { ?> |
|
197 | + foreach ($behaviors as $behavior) { ?> |
|
198 | 198 | <br><?= Html::encode($behavior['name']) ?> |
199 | 199 | <?php |
200 | 200 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | $this->container = new \yii\di\Container; |
89 | 89 | $this->container->set('common\interfaces\UserInterface', '\site\tests\_support\MockUser'); |
90 | 90 | $this->container->set('common\interfaces\UserBehaviorInterface', '\site\tests\_support\MockUserBehavior'); |
91 | - $this->container->set('common\interfaces\TimeInterface', function () { |
|
91 | + $this->container->set('common\interfaces\TimeInterface', function() { |
|
92 | 92 | return new \common\components\Time('America/Los_Angeles'); |
93 | 93 | }); |
94 | 94 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | } |
135 | 135 | |
136 | 136 | public function testIsTokenCurrent() { |
137 | - $this->specify('isTokenCurrent should function correctly', function () { |
|
137 | + $this->specify('isTokenCurrent should function correctly', function() { |
|
138 | 138 | $good_token = \Yii::$app |
139 | 139 | ->getSecurity() |
140 | 140 | ->generateRandomString() . '_' . time(); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | public function testConfirmVerifyEmailToken() { |
169 | 169 | $this->user->verify_email_token = 'hello_world'; |
170 | 170 | $this->user->confirmVerifyEmailToken(); |
171 | - expect('confirmVerifyEmailToken should append User::CONFIRMED_STRING to the end of the verify_email_token property', $this->assertEquals($this->user->verify_email_token, 'hello_world'.$this->user::CONFIRMED_STRING)); |
|
171 | + expect('confirmVerifyEmailToken should append User::CONFIRMED_STRING to the end of the verify_email_token property', $this->assertEquals($this->user->verify_email_token, 'hello_world' . $this->user::CONFIRMED_STRING)); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | public function testIsVerified() { |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | ->disableOriginalConstructor() |
263 | 263 | ->setMethods(['save', 'attributes', 'getCheckinBreakdown']) |
264 | 264 | ->getMock(); |
265 | - $expected = require(__DIR__.'/../data/expected_getCheckinBreakdown.php'); |
|
265 | + $expected = require(__DIR__ . '/../data/expected_getCheckinBreakdown.php'); |
|
266 | 266 | $user_behavior->method('getCheckinBreakdown')->willReturn($expected); |
267 | 267 | |
268 | 268 | $user = $this->getMockBuilder(User::class) |
@@ -211,8 +211,8 @@ |
||
211 | 211 | |
212 | 212 | public function setUp() { |
213 | 213 | $this->question = $this->getMockBuilder('\common\models\Question') |
214 | - ->setMethods(['save', 'attributes']) |
|
215 | - ->getMock(); |
|
214 | + ->setMethods(['save', 'attributes']) |
|
215 | + ->getMock(); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | public function testParseQuestionData() { |