@@ -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 | ], |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | if ($editProfileForm->load(Yii::$app->request->post())) { |
| 59 | 59 | $saved_user = $editProfileForm->saveProfile(); |
| 60 | - if($saved_user) { |
|
| 60 | + if ($saved_user) { |
|
| 61 | 61 | Yii::$app->session->setFlash('success', 'New profile data saved!'); |
| 62 | 62 | } |
| 63 | 63 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $model = Yii::$container->get(\site\models\DeleteAccountForm::class, [Yii::$app->user->identity]); |
| 76 | 76 | |
| 77 | 77 | if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
| 78 | - if($model->deleteAccount()) { |
|
| 78 | + if ($model->deleteAccount()) { |
|
| 79 | 79 | $this->redirect(['site/index']); |
| 80 | 80 | } else { |
| 81 | 81 | Yii::$app->session->setFlash('error', 'Wrong password!'); |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $model = Yii::$container->get(\site\models\ChangePasswordForm::class, [Yii::$app->user->identity]); |
| 90 | 90 | |
| 91 | 91 | if ($model->load(Yii::$app->request->post())) { |
| 92 | - if($model->validate() && $model->changePassword()) { |
|
| 92 | + if ($model->validate() && $model->changePassword()) { |
|
| 93 | 93 | Yii::$app->session->setFlash('success', 'Password successfully changed'); |
| 94 | 94 | } else { |
| 95 | 95 | Yii::$app->session->setFlash('error', 'Wrong password!'); |
@@ -113,14 +113,14 @@ discard block |
||
| 113 | 113 | public function actionChangeEmail(string $token) { |
| 114 | 114 | $user = Yii::$container->get(\common\interfaces\UserInterface::class)->findByChangeEmailToken($token); |
| 115 | 115 | |
| 116 | - if($user) { |
|
| 116 | + if ($user) { |
|
| 117 | 117 | $validator = new \yii\validators\EmailValidator(); |
| 118 | - if($validator->validate($user->desired_email, $error)) { |
|
| 118 | + if ($validator->validate($user->desired_email, $error)) { |
|
| 119 | 119 | $user->removeChangeEmailToken(); |
| 120 | 120 | $user->email = $user->desired_email; |
| 121 | 121 | $user->desired_email = null; |
| 122 | 122 | $user->save(); |
| 123 | - if(!Yii::$app->user->isGuest) { |
|
| 123 | + if (!Yii::$app->user->isGuest) { |
|
| 124 | 124 | Yii::$app->user->logout(); |
| 125 | 125 | Yii::$app->session->setFlash('success', 'Your email address was successfully changed. For security, we\'ve logged you out.'); |
| 126 | 126 | } else { |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | public function actionExport() { |
| 142 | 142 | header("Content-Type: text/csv"); |
| 143 | - header("Content-Disposition: attachment; filename=fsa-data-export-".Yii::$app->user->identity->email."-".date('Ymd').".csv"); |
|
| 143 | + header("Content-Disposition: attachment; filename=fsa-data-export-" . Yii::$app->user->identity->email . "-" . date('Ymd') . ".csv"); |
|
| 144 | 144 | |
| 145 | 145 | $reader = Yii::$app->user->identity->getExportData(); |
| 146 | 146 | $fp = fopen('php://output', 'w'); |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | fputcsv($fp, $header); |
| 158 | 158 | $user_behavior = Yii::$container->get(\common\interfaces\UserBehaviorInterface::class); |
| 159 | - while($row = $reader->read()) { |
|
| 159 | + while ($row = $reader->read()) { |
|
| 160 | 160 | $row = $user_behavior::decorateWithCategory([$row]); |
| 161 | 161 | $row = Yii::$app->user->identity->cleanExportData($row); |
| 162 | 162 | fputcsv($fp, $row[0]); |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | public function actionBlog() |
| 56 | 56 | { |
| 57 | 57 | $time = Yii::$container->get(\common\interfaces\TimeInterface::class); |
| 58 | - $key = "index_blog_".$time->getLocalDate('UTC'); |
|
| 58 | + $key = "index_blog_" . $time->getLocalDate('UTC'); |
|
| 59 | 59 | $posts = Yii::$app->cache->get($key); |
| 60 | - if($posts === false) { |
|
| 60 | + if ($posts === false) { |
|
| 61 | 61 | $posts = \Yii::$app->getModule('blog') |
| 62 | 62 | ->fetch() |
| 63 | 63 | ->parse() |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | { |
| 91 | 91 | $model = new \site\models\ContactForm(); |
| 92 | 92 | if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
| 93 | - if($model->sendEmail(Yii::$app->params['adminEmail'])) { |
|
| 93 | + if ($model->sendEmail(Yii::$app->params['adminEmail'])) { |
|
| 94 | 94 | Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.'); |
| 95 | 95 | } else { |
| 96 | 96 | Yii::$app->session->setFlash('error', 'There was an error sending email.'); |
@@ -122,10 +122,10 @@ discard block |
||
| 122 | 122 | public function actionSignup() |
| 123 | 123 | { |
| 124 | 124 | $model = Yii::$container->get(\site\models\SignupForm::class); |
| 125 | - if($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
| 125 | + if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
| 126 | 126 | $model->signup(); |
| 127 | 127 | Yii::$app->session->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.'); |
| 128 | - return $this->redirect('/',302); |
|
| 128 | + return $this->redirect('/', 302); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | return $this->render('signup', [ |
@@ -136,10 +136,10 @@ discard block |
||
| 136 | 136 | public function actionRequestPasswordReset() |
| 137 | 137 | { |
| 138 | 138 | $model = Yii::$container->get(\site\models\PasswordResetRequestForm::class); |
| 139 | - if($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
| 140 | - if(!$model->sendEmail()) { |
|
| 139 | + if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
| 140 | + if (!$model->sendEmail()) { |
|
| 141 | 141 | $ip = Yii::$app->getRequest()->getUserIP() ?: "UNKNOWN"; |
| 142 | - Yii::warning("$ip has tried to reset the password for ".$model->email); |
|
| 142 | + Yii::warning("$ip has tried to reset the password for " . $model->email); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | Yii::$app->session->setFlash('success', 'If there is an account with the submitted email address you will receive further instructions in your email inbox.'); |
@@ -183,14 +183,14 @@ discard block |
||
| 183 | 183 | 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."); |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - if($user->isTokenConfirmed($user->verify_email_token)) { |
|
| 186 | + if ($user->isTokenConfirmed($user->verify_email_token)) { |
|
| 187 | 187 | Yii::$app->session->setFlash('success', 'Your account has already been verified. Please log in.'); |
| 188 | - return $this->redirect('/login',302); |
|
| 188 | + return $this->redirect('/login', 302); |
|
| 189 | 189 | } else if (Yii::$app->getUser()->login($user)) { |
| 190 | 190 | $user->confirmVerifyEmailToken(); |
| 191 | 191 | $user->save(); |
| 192 | 192 | Yii::$app->session->setFlash('success', 'Your account has been verified. Please continue with your check-in.'); |
| 193 | - return $this->redirect('/welcome',302); |
|
| 193 | + return $this->redirect('/welcome', 302); |
|
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | if (!empty($this->json)) { |
| 39 | - foreach($this->json[self::POS_READY] as $json_name => $json_value) { |
|
| 39 | + foreach ($this->json[self::POS_READY] as $json_name => $json_value) { |
|
| 40 | 40 | $lines[] = Html::script($json_value, ['type' => 'application/json', 'id' => $json_name]); |
| 41 | 41 | } |
| 42 | 42 | } |
@@ -33,8 +33,8 @@ |
||
| 33 | 33 | { |
| 34 | 34 | return [ |
| 35 | 35 | 'error' => [ |
| 36 | - 'class' => 'yii\web\ErrorAction', |
|
| 37 | - ], |
|
| 36 | + 'class' => 'yii\web\ErrorAction', |
|
| 37 | + ], |
|
| 38 | 38 | 'captcha' => [ |
| 39 | 39 | 'class' => 'yii\captcha\CaptchaAction', |
| 40 | 40 | ], |
@@ -60,10 +60,10 @@ |
||
| 60 | 60 | */ |
| 61 | 61 | public function login() |
| 62 | 62 | { |
| 63 | - if($this->validate()) { |
|
| 63 | + if ($this->validate()) { |
|
| 64 | 64 | $user = $this->getUser(); |
| 65 | - if($user->isVerified()) { |
|
| 66 | - return Yii::$app->user->login($user, $this->rememberMe ? 3600 * 24 * 30 : 0); |
|
| 65 | + if ($user->isVerified()) { |
|
| 66 | + return Yii::$app->user->login($user, $this->rememberMe ? 3600*24*30 : 0); |
|
| 67 | 67 | } else { |
| 68 | 68 | Yii::$app->session->setFlash('warning', 'You must verify your account before you can proceed. Please check your email inbox for a verification email and follow the instructions.'); |
| 69 | 69 | } |
@@ -12,13 +12,13 @@ |
||
| 12 | 12 | class Category extends \yii\base\BaseObject implements \common\interfaces\CategoryInterface { |
| 13 | 13 | |
| 14 | 14 | public static $categories = [ |
| 15 | - [ "id" => 1, "name" => "Restoration"], |
|
| 16 | - [ "id" => 2, "name" => "Forgetting Priorities"], |
|
| 17 | - [ "id" => 3, "name" => "Anxiety"], |
|
| 18 | - [ "id" => 4, "name" => "Speeding Up"], |
|
| 19 | - [ "id" => 5, "name" => "Ticked Off"], |
|
| 20 | - [ "id" => 6, "name" => "Exhausted"], |
|
| 21 | - [ "id" => 7, "name" => "Relapse/Moral Failure"], |
|
| 15 | + ["id" => 1, "name" => "Restoration"], |
|
| 16 | + ["id" => 2, "name" => "Forgetting Priorities"], |
|
| 17 | + ["id" => 3, "name" => "Anxiety"], |
|
| 18 | + ["id" => 4, "name" => "Speeding Up"], |
|
| 19 | + ["id" => 5, "name" => "Ticked Off"], |
|
| 20 | + ["id" => 6, "name" => "Exhausted"], |
|
| 21 | + ["id" => 7, "name" => "Relapse/Moral Failure"], |
|
| 22 | 22 | ]; |
| 23 | 23 | |
| 24 | 24 | public static $colors = [ |
@@ -10,8 +10,8 @@ discard block |
||
| 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); |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | ], |
| 29 | 29 | 'components' => [ |
| 30 | 30 | // by default, sessions are stored in a local file |
| 31 | - 'cache' => [ // DummyCache never actually caches anything |
|
| 31 | + 'cache' => [// DummyCache never actually caches anything |
|
| 32 | 32 | 'class'=> yii\caching\DummyCache::class, |
| 33 | 33 | ], |
| 34 | 34 | 'mailer' => [ |
@@ -14,8 +14,8 @@ discard block |
||
| 14 | 14 | use \Codeception\Specify; |
| 15 | 15 | |
| 16 | 16 | private $user; |
| 17 | - private $filepath = __DIR__.'/../../_output/test_graph.png'; |
|
| 18 | - private $filepath_extra = __DIR__.'/../../_output/charts/test_graph.png'; |
|
| 17 | + private $filepath = __DIR__ . '/../../_output/test_graph.png'; |
|
| 18 | + private $filepath_extra = __DIR__ . '/../../_output/charts/test_graph.png'; |
|
| 19 | 19 | |
| 20 | 20 | public function setUp() { |
| 21 | 21 | $this->user = $this->getMockBuilder('\site\tests\_support\MockUser') |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | ->willReturn('random1DH4sh'); |
| 37 | 37 | $graph = new Graph($this->user); |
| 38 | 38 | |
| 39 | - expect('the expected graph image filepath will be returned', $this->assertEquals(dirname(dirname(dirname(dirname(__DIR__)))).'/site/web/charts/random1DH4sh.png', $graph->getFilepath())); |
|
| 39 | + expect('the expected graph image filepath will be returned', $this->assertEquals(dirname(dirname(dirname(dirname(__DIR__)))) . '/site/web/charts/random1DH4sh.png', $graph->getFilepath())); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function testGetUrl() { |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | ->method('getFilepath') |
| 58 | 58 | ->willReturn($this->filepath); |
| 59 | 59 | |
| 60 | - if(!file_exists($this->filepath) && preg_match('%/_output/test_graph.png$%', $this->filepath)) { |
|
| 60 | + if (!file_exists($this->filepath) && preg_match('%/_output/test_graph.png$%', $this->filepath)) { |
|
| 61 | 61 | touch($this->filepath); |
| 62 | 62 | expect('just a check to be sure $filepath is sane', $this->assertStringEndsWith('/_output/test_graph.png', $this->filepath)); |
| 63 | 63 | expect('the generated file should exist', $this->assertFileExists($this->filepath)); |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | expect('the generated file should be readable', $this->assertFileExists($this->filepath_extra)); |
| 90 | 90 | |
| 91 | 91 | // cleanup |
| 92 | - if(file_exists($this->filepath_extra) && preg_match('%/_output/charts/test_graph.png%', $this->filepath_extra)) { |
|
| 92 | + if (file_exists($this->filepath_extra) && preg_match('%/_output/charts/test_graph.png%', $this->filepath_extra)) { |
|
| 93 | 93 | // just in case something is weird, we don't want to straight rm this file |
| 94 | 94 | unlink($this->filepath_extra); |
| 95 | 95 | rmdir(dirname($this->filepath_extra)); |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | -function checkinBreakdown () { |
|
| 100 | +function checkinBreakdown() { |
|
| 101 | 101 | return [ |
| 102 | 102 | '2019-01-31' => [], |
| 103 | 103 | '2019-02-01' => [], |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | '2019-02-27' => [], |
| 231 | 231 | '2019-02-28' => [], |
| 232 | 232 | '2019-03-01' => [ |
| 233 | - 2 => [ 'name' => 'Forgetting Priorities', |
|
| 233 | + 2 => ['name' => 'Forgetting Priorities', |
|
| 234 | 234 | 'count' => 6, |
| 235 | 235 | 'color' => '#4CA100', |
| 236 | 236 | 'highlight' => '#61B219', |
@@ -77,10 +77,10 @@ discard block |
||
| 77 | 77 | $graph = Yii::$container |
| 78 | 78 | ->get(\common\components\Graph::class, [$this->user]); |
| 79 | 79 | |
| 80 | - if($this->timezone) { |
|
| 80 | + if ($this->timezone) { |
|
| 81 | 81 | $user->timezone = $this->timezone; |
| 82 | 82 | } |
| 83 | - if($this->expose_graph) { |
|
| 83 | + if ($this->expose_graph) { |
|
| 84 | 84 | $user->expose_graph = true; |
| 85 | 85 | |
| 86 | 86 | // generate scores graph image |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | // if they haven't done a check-in in the last month this |
| 92 | 92 | // will explode because $checkinss_last_month is an empty |
| 93 | 93 | // array |
| 94 | - if($checkins_last_month) { |
|
| 94 | + if ($checkins_last_month) { |
|
| 95 | 95 | $graph->create($checkins_last_month, true); |
| 96 | 96 | } |
| 97 | 97 | } else { |
@@ -99,12 +99,12 @@ discard block |
||
| 99 | 99 | // remove scores graph image |
| 100 | 100 | $graph->destroy(); |
| 101 | 101 | } |
| 102 | - if($this->send_email) { |
|
| 102 | + if ($this->send_email) { |
|
| 103 | 103 | $user->send_email = true; |
| 104 | 104 | } else { |
| 105 | 105 | $user->send_email = false; |
| 106 | 106 | } |
| 107 | - if($this->send_email) { |
|
| 107 | + if ($this->send_email) { |
|
| 108 | 108 | $user->partner_email1 = $this->partner_email1; |
| 109 | 109 | $user->partner_email2 = $this->partner_email2; |
| 110 | 110 | $user->partner_email3 = $this->partner_email3; |
@@ -53,8 +53,8 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | - * @codeCoverageIgnore |
|
| 57 | - */ |
|
| 56 | + * @codeCoverageIgnore |
|
| 57 | + */ |
|
| 58 | 58 | public function attributeLabels() { |
| 59 | 59 | return [ |
| 60 | 60 | 'partner_email1' => "Partner Email #1", |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | // generate scores graph image |
| 87 | 87 | $checkins_last_month = (Yii::$container->get(\common\interfaces\UserBehaviorInterface::class)) |
| 88 | - ->getCheckInBreakdown(); |
|
| 88 | + ->getCheckInBreakdown(); |
|
| 89 | 89 | |
| 90 | 90 | // if they haven't done a check-in in the last month this |
| 91 | 91 | // will explode because $checkinss_last_month is an empty |