@@ -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 | |
@@ -49,14 +49,14 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | // delete cached scores |
| 51 | 51 | $time = Yii::$container->get(\common\interfaces\TimeInterface::class); |
| 52 | - $key = "scores_of_last_month_".Yii::$app->user->id."_".$time->getLocalDate(); |
|
| 52 | + $key = "scores_of_last_month_" . Yii::$app->user->id . "_" . $time->getLocalDate(); |
|
| 53 | 53 | Yii::$app->cache->delete($key); |
| 54 | 54 | |
| 55 | 55 | // if the user has publicised their score graph, create the image |
| 56 | - if(Yii::$app->user->identity->expose_graph) { |
|
| 56 | + if (Yii::$app->user->identity->expose_graph) { |
|
| 57 | 57 | $user_behavior = Yii::$container->get(\common\interfaces\UserBehaviorInterface::class); |
| 58 | 58 | $scores_last_month = $user_behavior->calculateScoresOfLastMonth(); |
| 59 | - if($scores_last_month) { |
|
| 59 | + if ($scores_last_month) { |
|
| 60 | 60 | Yii::$container |
| 61 | 61 | ->get(\common\components\Graph::class, [Yii::$app->user->identity]) |
| 62 | 62 | ->create($scores_last_month, true); |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | $date = Yii::$container->get(\common\interfaces\TimeInterface::class)->getLocalDate(); |
| 82 | 82 | |
| 83 | 83 | $user_behaviors = $user_behavior->getUserBehaviorsWithCategory($date); |
| 84 | - if(count($user_behaviors) === 0) { |
|
| 84 | + if (count($user_behaviors) === 0) { |
|
| 85 | 85 | return $this->redirect(['view']); |
| 86 | 86 | } |
| 87 | 87 | |
@@ -91,10 +91,10 @@ discard block |
||
| 91 | 91 | $form->deleteToday(); |
| 92 | 92 | |
| 93 | 93 | $behaviors = $user_behavior->findAll($form->getUserBehaviorIds()); |
| 94 | - if($result = $form->saveAnswers($behaviors)) { |
|
| 94 | + if ($result = $form->saveAnswers($behaviors)) { |
|
| 95 | 95 | |
| 96 | 96 | $score = $user_behavior->getDailyScore(); |
| 97 | - if(Yii::$app->user->identity->isOverThreshold($score)) { |
|
| 97 | + if (Yii::$app->user->identity->isOverThreshold($score)) { |
|
| 98 | 98 | Yii::$app->user->identity->sendEmailReport($date); |
| 99 | 99 | Yii::$app->session->setFlash('warning', 'Your check-in is complete. A notification has been sent to your report partners because of your high score. Reach out to them!'); |
| 100 | 100 | } else { |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | public function actionView(string $date = null) |
| 115 | 115 | { |
| 116 | 116 | $time = Yii::$container->get(\common\interfaces\TimeInterface::class); |
| 117 | - if(is_null($date)) { |
|
| 117 | + if (is_null($date)) { |
|
| 118 | 118 | $date = $time->getLocalDate(); |
| 119 | - } else if($dt = $time->parse($date)) { |
|
| 119 | + } else if ($dt = $time->parse($date)) { |
|
| 120 | 120 | $date = $dt->format('Y-m-d'); |
| 121 | 121 | } else { |
| 122 | 122 | $date = $time->getLocalDate(); |
@@ -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> |
@@ -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 | ], |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | if ($editProfileForm->load(Yii::$app->request->post())) { |
| 74 | 74 | $saved_user = $editProfileForm->saveProfile(); |
| 75 | - if($saved_user) { |
|
| 75 | + if ($saved_user) { |
|
| 76 | 76 | Yii::$app->getSession()->setFlash('success', 'New profile data saved!'); |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $model = Yii::$container->get(\site\models\DeleteAccountForm::class, [Yii::$app->user->identity]); |
| 91 | 91 | |
| 92 | 92 | if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
| 93 | - if($model->deleteAccount()) { |
|
| 93 | + if ($model->deleteAccount()) { |
|
| 94 | 94 | $this->redirect(['site/index']); |
| 95 | 95 | } else { |
| 96 | 96 | Yii::$app->getSession()->setFlash('error', 'Wrong password!'); |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | $model = Yii::$container->get(\site\models\ChangePasswordForm::class, [Yii::$app->user->identity]); |
| 105 | 105 | |
| 106 | 106 | if ($model->load(Yii::$app->request->post())) { |
| 107 | - if($model->validate() && $model->changePassword()) { |
|
| 107 | + if ($model->validate() && $model->changePassword()) { |
|
| 108 | 108 | Yii::$app->getSession()->setFlash('success', 'Password successfully changed'); |
| 109 | 109 | } else { |
| 110 | 110 | Yii::$app->getSession()->setFlash('error', 'Wrong password!'); |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | $model = Yii::$container->get(\site\models\ChangeEmailForm::class, [Yii::$app->user->identity]); |
| 119 | 119 | |
| 120 | 120 | if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
| 121 | - if($model->changeEmail()) { |
|
| 121 | + if ($model->changeEmail()) { |
|
| 122 | 122 | Yii::$app->getSession()->setFlash('success', "We've sent an email to your requested email address to confirm. Please click on the verification link to continue."); |
| 123 | 123 | } else { |
| 124 | 124 | Yii::$app->getSession()->setFlash('error', 'Something went wrong!'); |
@@ -130,14 +130,14 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | public function actionChangeEmail(string $token) { |
| 132 | 132 | $user = \common\models\User::findByChangeEmailToken($token); |
| 133 | - if($user) { |
|
| 133 | + if ($user) { |
|
| 134 | 134 | $validator = new \yii\validators\EmailValidator(); |
| 135 | - if($validator->validate($user->desired_email, $error)) { |
|
| 135 | + if ($validator->validate($user->desired_email, $error)) { |
|
| 136 | 136 | $user->removeChangeEmailToken(); |
| 137 | 137 | $user->email = $user->desired_email; |
| 138 | 138 | $user->desired_email = null; |
| 139 | 139 | $user->save(); |
| 140 | - if(!Yii::$app->user->isGuest) { |
|
| 140 | + if (!Yii::$app->user->isGuest) { |
|
| 141 | 141 | Yii::$app->user->logout(); |
| 142 | 142 | Yii::$app->session->setFlash('success', 'Your email address was successfully changed. For security, we\'ve logged you out.'); |
| 143 | 143 | } else { |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | public function actionExport() { |
| 159 | 159 | header("Content-Type: text/csv"); |
| 160 | - header("Content-Disposition: attachment; filename=fsa-data-export-".Yii::$app->user->identity->email."-".date('Ymd').".csv"); |
|
| 160 | + header("Content-Disposition: attachment; filename=fsa-data-export-" . Yii::$app->user->identity->email . "-" . date('Ymd') . ".csv"); |
|
| 161 | 161 | |
| 162 | 162 | $reader = Yii::$app->user->identity->getExportData(); |
| 163 | 163 | $fp = fopen('php://output', 'w'); |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | |
| 174 | 174 | fputcsv($fp, $header); |
| 175 | 175 | $user_behavior = Yii::$container->get(\common\interfaces\UserBehaviorInterface::class); |
| 176 | - while($row = $reader->read()) { |
|
| 176 | + while ($row = $reader->read()) { |
|
| 177 | 177 | $row = $user_behavior::decorateWithCategory([$row]); |
| 178 | 178 | $row = Yii::$app->user->identity->cleanExportData($row); |
| 179 | 179 | fputcsv($fp, $row[0]); |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | // check that the desired_email is not already the email of another user |
| 49 | 49 | $user = $this->user->findByEmail($this->desired_email); |
| 50 | 50 | // if it is, we do nothing and return true, don't leak the data |
| 51 | - if(!$user) { |
|
| 51 | + if (!$user) { |
|
| 52 | 52 | $this->user->desired_email = $this->desired_email; |
| 53 | 53 | $this->user->generateChangeEmailToken(); |
| 54 | 54 | $this->user->save(); |