@@ -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,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | return $this->redirect(['questions']); |
51 | 51 | } else { |
52 | - $behaviors = Yii::$container->get(BehaviorInterface::class)::$behaviors; |
|
52 | + $behaviors = Yii::$container->get(BehaviorInterface::class)::$behaviors; |
|
53 | 53 | return $this->render('index', [ |
54 | 54 | 'categories' => Yii::$container->get(CategoryInterface::class)::$categories, |
55 | 55 | 'model' => $form, |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $date = Yii::$container->get(TimeInterface::class)->getLocalDate(); |
65 | 65 | |
66 | 66 | $user_behaviors = $user_behavior->getUserBehaviorsWithCategory($date); |
67 | - if(count($user_behaviors) === 0) { |
|
67 | + if (count($user_behaviors) === 0) { |
|
68 | 68 | return $this->redirect(['view']); |
69 | 69 | } |
70 | 70 | |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | $form->deleteToday(); |
75 | 75 | |
76 | 76 | $behaviors = $user_behavior->findAll($form->getUserBehaviorIds()); |
77 | - if($result = $form->saveAnswers($behaviors)) { |
|
77 | + if ($result = $form->saveAnswers($behaviors)) { |
|
78 | 78 | |
79 | 79 | $score = $user_behavior->getDailyScore(); |
80 | - if(Yii::$app->user->identity->isOverThreshold($score)) { |
|
80 | + if (Yii::$app->user->identity->isOverThreshold($score)) { |
|
81 | 81 | Yii::$app->user->identity->sendEmailReport($date); |
82 | 82 | 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!'); |
83 | 83 | } else { |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | public function actionBlog() |
71 | 71 | { |
72 | 72 | $time = Yii::$container->get(\common\interfaces\TimeInterface::class); |
73 | - $key = "index_blog_".$time->getLocalDate('UTC'); |
|
73 | + $key = "index_blog_" . $time->getLocalDate('UTC'); |
|
74 | 74 | $posts = Yii::$app->cache->get($key); |
75 | - if($posts === false) { |
|
75 | + if ($posts === false) { |
|
76 | 76 | $posts = \Yii::$app->getModule('blog') |
77 | 77 | ->fetch() |
78 | 78 | ->parse() |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | { |
106 | 106 | $model = new \site\models\ContactForm(); |
107 | 107 | if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
108 | - if($model->sendEmail(Yii::$app->params['adminEmail'])) { |
|
108 | + if ($model->sendEmail(Yii::$app->params['adminEmail'])) { |
|
109 | 109 | Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.'); |
110 | 110 | } else { |
111 | 111 | Yii::$app->session->setFlash('error', 'There was an error sending email.'); |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | public function actionSignup() |
138 | 138 | { |
139 | 139 | $model = Yii::$container->get(\site\models\SignupForm::class); |
140 | - if($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
140 | + if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
141 | 141 | $model->signup(); |
142 | 142 | 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.'); |
143 | - return $this->redirect('/',302); |
|
143 | + return $this->redirect('/', 302); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | return $this->render('signup', [ |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | public function actionRequestPasswordReset() |
152 | 152 | { |
153 | 153 | $model = Yii::$container->get(\site\models\PasswordResetRequestForm::class); |
154 | - if($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
155 | - if(!$model->sendEmail()) { |
|
154 | + if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
155 | + if (!$model->sendEmail()) { |
|
156 | 156 | $ip = Yii::$app->getRequest()->getUserIP() ?: "UNKNOWN"; |
157 | - Yii::warning("$ip has tried to reset the password for ".$model->email); |
|
157 | + Yii::warning("$ip has tried to reset the password for " . $model->email); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | 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 |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | $graph = Yii::$container |
82 | 82 | ->get(\common\components\Graph::class, [$this->user]); |
83 | 83 | |
84 | - if($this->timezone) { |
|
84 | + if ($this->timezone) { |
|
85 | 85 | $user->timezone = $this->timezone; |
86 | 86 | } |
87 | - if($this->expose_graph) { |
|
87 | + if ($this->expose_graph) { |
|
88 | 88 | $user->expose_graph = true; |
89 | 89 | |
90 | 90 | // generate scores graph image |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | // if they haven't done a check-in in the last month this |
93 | 93 | // will explode because $scores_last_month is an empty |
94 | 94 | // array |
95 | - if($scores_last_month) { |
|
95 | + if ($scores_last_month) { |
|
96 | 96 | $graph->create($scores_last_month, true); |
97 | 97 | } |
98 | 98 | } else { |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | // remove scores graph image |
101 | 101 | $graph->destroy(); |
102 | 102 | } |
103 | - if($this->send_email) { |
|
103 | + if ($this->send_email) { |
|
104 | 104 | $user->email_threshold = $this->email_threshold; |
105 | 105 | $user->partner_email1 = $this->partner_email1; |
106 | 106 | $user->partner_email2 = $this->partner_email2; |
@@ -59,8 +59,8 @@ |
||
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
62 | - * @codeCoverageIgnore |
|
63 | - */ |
|
62 | + * @codeCoverageIgnore |
|
63 | + */ |
|
64 | 64 | public function attributeLabels() { |
65 | 65 | return [ |
66 | 66 | 'partner_email1' => "Partner Email #1", |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | public function setBehaviors($behaviors) { |
67 | - foreach($behaviors as $category_id => $category_data) { |
|
67 | + foreach ($behaviors as $category_id => $category_data) { |
|
68 | 68 | $attribute = "behaviors$category_id"; |
69 | 69 | $this->$attribute = []; |
70 | - foreach($category_data['behaviors'] as $behavior) { |
|
70 | + foreach ($category_data['behaviors'] as $behavior) { |
|
71 | 71 | $this->{$attribute}[] = $behavior['id']; |
72 | 72 | } |
73 | 73 | } |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | |
76 | 76 | public function validateBehaviors($attribute, $params) { |
77 | 77 | if (!$this->hasErrors()) { |
78 | - foreach($this->$attribute as $behavior) { |
|
79 | - if(!is_numeric($behavior)) { |
|
78 | + foreach ($this->$attribute as $behavior) { |
|
79 | + if (!is_numeric($behavior)) { |
|
80 | 80 | $this->addError($attribute, 'One of your behaviors is not an integer!'); |
81 | 81 | } |
82 | 82 | } |
@@ -110,17 +110,17 @@ discard block |
||
110 | 110 | |
111 | 111 | // delete cached scores |
112 | 112 | $time = Yii::$container->get(\common\interfaces\TimeInterface::class); |
113 | - $key = "scores_of_last_month_".Yii::$app->user->id."_".$time->getLocalDate(); |
|
113 | + $key = "scores_of_last_month_" . Yii::$app->user->id . "_" . $time->getLocalDate(); |
|
114 | 114 | Yii::$app->cache->delete($key); |
115 | 115 | } |
116 | 116 | |
117 | 117 | public function save() { |
118 | - if(empty($this->compiled_behaviors)) { |
|
118 | + if (empty($this->compiled_behaviors)) { |
|
119 | 119 | $this->commpiled_behaviors = $this->compileBehaviors(); |
120 | 120 | } |
121 | 121 | |
122 | 122 | $rows = []; |
123 | - foreach($this->compiled_behaviors as $behavior_id) { |
|
123 | + foreach ($this->compiled_behaviors as $behavior_id) { |
|
124 | 124 | $temp = [ |
125 | 125 | Yii::$app->user->id, |
126 | 126 | (int)$behavior_id, |
@@ -139,10 +139,10 @@ discard block |
||
139 | 139 | )->execute(); |
140 | 140 | |
141 | 141 | // if the user has publicised their score graph, create the image |
142 | - if(Yii::$app->user->identity->expose_graph) { |
|
142 | + if (Yii::$app->user->identity->expose_graph) { |
|
143 | 143 | $scores_last_month = $this->user_behavior->calculateScoresOfLastMonth(); |
144 | 144 | |
145 | - if($scores_last_month) { |
|
145 | + if ($scores_last_month) { |
|
146 | 146 | Yii::$container |
147 | 147 | ->get(\common\components\Graph::class, [Yii::$app->user->identity]) |
148 | 148 | ->create($scores_last_month, true); |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | * @return \DateTime the parsed time or the default value |
37 | 37 | */ |
38 | 38 | public function parse($time, $default = false, string $format = 'Y-m-d') { |
39 | - if(is_string($time)) { |
|
39 | + if (is_string($time)) { |
|
40 | 40 | $dt = DateTime::createFromFormat($format, $time, new DateTimeZone($this->timezone)); |
41 | - if($dt) { |
|
41 | + if ($dt) { |
|
42 | 42 | // for some reason, using createFromFromat adds in the time. The regular DateTime constructor _does not_ do this. We manually zero out the time here to make the DateTime objects match. |
43 | 43 | $dt->setTime(0, 0, 0); |
44 | 44 | $formatted = $dt->format($format); |
45 | - if($formatted === $time && $this->inBounds($dt)) { |
|
45 | + if ($formatted === $time && $this->inBounds($dt)) { |
|
46 | 46 | return $dt; |
47 | 47 | } |
48 | 48 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | $test = strtotime($dt->format('Y-m-d')); |
63 | 63 | $now = strtotime($this->getLocalDate()); |
64 | 64 | |
65 | - if($first <= $test && $test <= $now) { |
|
65 | + if ($first <= $test && $test <= $now) { |
|
66 | 66 | return true; |
67 | 67 | } else { |
68 | 68 | return false; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | public function getLocalTime($timezone = null) { |
89 | - if($timezone === null) |
|
89 | + if ($timezone === null) |
|
90 | 90 | $timezone = $this->timezone; |
91 | 91 | |
92 | 92 | $timestamp = new DateTime("now", new DateTimeZone($timezone)); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | } |
95 | 95 | |
96 | 96 | public function getLocalDate($timezone = null) { |
97 | - if($timezone === null) |
|
97 | + if ($timezone === null) |
|
98 | 98 | $timezone = $this->timezone; |
99 | 99 | |
100 | 100 | return (new DateTime("now", new DateTimeZone($timezone))) |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | public function getUTCBookends($local) { |
110 | 110 | $local = trim($local); |
111 | - if(strpos($local, " ")) { |
|
111 | + if (strpos($local, " ")) { |
|
112 | 112 | return false; |
113 | 113 | } |
114 | 114 |
@@ -35,7 +35,7 @@ |
||
35 | 35 | { |
36 | 36 | /* @var $user User */ |
37 | 37 | $user = $this->user; |
38 | - if($user->isGuest) { |
|
38 | + if ($user->isGuest) { |
|
39 | 39 | $user = $this->user->findOne([ |
40 | 40 | 'email' => $this->email, |
41 | 41 | ]); |