@@ -14,103 +14,103 @@ discard block |
||
| 14 | 14 | class Behavior extends \yii\base\BaseObject implements BehaviorInterface |
| 15 | 15 | { |
| 16 | 16 | public static $behaviors = [ |
| 17 | - ['id' => 1, 'name' => 'no current secrets', 'category_id' => 1], |
|
| 18 | - ['id' => 2, 'name' => 'resolving problems', 'category_id' => 1], |
|
| 19 | - ['id' => 3, 'name' => 'identifying fears and feelings', 'category_id' => 1], |
|
| 20 | - ['id' => 4, 'name' => 'keeping commitments to meetings, prayer, family, church, people, goals, and self', 'category_id' => 1], |
|
| 21 | - ['id' => 5, 'name' => 'being open', 'category_id' => 1], |
|
| 22 | - ['id' => 6, 'name' => 'being honest', 'category_id' => 1], |
|
| 23 | - ['id' => 7, 'name' => 'making eye contact', 'category_id' => 1], |
|
| 24 | - ['id' => 8, 'name' => 'reaching out to others', 'category_id' => 1], |
|
| 25 | - ['id' => 9, 'name' => 'increasing in relationships with God and others', 'category_id' => 1], |
|
| 26 | - ['id' => 10, 'name' => 'accountability', 'category_id' => 1], |
|
| 27 | - ['id' => 11, 'name' => 'secrets', 'category_id' => 2], |
|
| 28 | - ['id' => 12, 'name' => 'bored', 'category_id' => 2], |
|
| 29 | - ['id' => 13, 'name' => 'less time/energy for God, meetings, and church', 'category_id' => 2], |
|
| 30 | - ['id' => 14, 'name' => 'avoiding support and accountability towards people', 'category_id' => 2], |
|
| 31 | - ['id' => 15, 'name' => 'superficial conversations', 'category_id' => 2], |
|
| 32 | - ['id' => 16, 'name' => 'sarcasm', 'category_id' => 2], |
|
| 33 | - ['id' => 17, 'name' => 'isolating yourself', 'category_id' => 2], |
|
| 34 | - ['id' => 18, 'name' => 'changes in goals', 'category_id' => 2], |
|
| 35 | - ['id' => 19, 'name' => 'flirting', 'category_id' => 2], |
|
| 36 | - ['id' => 20, 'name' => 'obsessed with relationships', 'category_id' => 2], |
|
| 37 | - ['id' => 21, 'name' => 'breaking promises/commitments', 'category_id' => 2], |
|
| 38 | - ['id' => 22, 'name' => 'neglecting family', 'category_id' => 2], |
|
| 39 | - ['id' => 23, 'name' => 'preoccupation with material things, television, or entertainment', 'category_id' => 2], |
|
| 40 | - ['id' => 24, 'name' => 'procrastination', 'category_id' => 2], |
|
| 41 | - ['id' => 25, 'name' => 'lying', 'category_id' => 2], |
|
| 42 | - ['id' => 26, 'name' => 'over-confidence', 'category_id' => 2], |
|
| 43 | - ['id' => 27, 'name' => 'hiding money', 'category_id' => 2], |
|
| 44 | - ['id' => 28, 'name' => 'worry', 'category_id' => 3], |
|
| 45 | - ['id' => 29, 'name' => 'using profanity', 'category_id' => 3], |
|
| 46 | - ['id' => 30, 'name' => 'being fearful', 'category_id' => 3], |
|
| 47 | - ['id' => 31, 'name' => 'being resentful', 'category_id' => 3], |
|
| 48 | - ['id' => 32, 'name' => 'replaying old, negative thoughts', 'category_id' => 3], |
|
| 49 | - ['id' => 33, 'name' => 'perfectionism', 'category_id' => 3], |
|
| 50 | - ['id' => 34, 'name' => 'judging others\' motives', 'category_id' => 3], |
|
| 51 | - ['id' => 35, 'name' => 'making goals and lists you can\'t complete', 'category_id' => 3], |
|
| 52 | - ['id' => 36, 'name' => 'poor planning', 'category_id' => 3], |
|
| 53 | - ['id' => 37, 'name' => 'mind reading', 'category_id' => 3], |
|
| 54 | - ['id' => 38, 'name' => 'fantasy', 'category_id' => 3], |
|
| 55 | - ['id' => 41, 'name' => 'co-dependent rescuing', 'category_id' => 3], |
|
| 56 | - ['id' => 42, 'name' => 'sleep problems', 'category_id' => 3], |
|
| 57 | - ['id' => 43, 'name' => 'trouble concentrating', 'category_id' => 3], |
|
| 58 | - ['id' => 44, 'name' => 'seeking/creating drama', 'category_id' => 3], |
|
| 59 | - ['id' => 45, 'name' => 'gossip', 'category_id' => 3], |
|
| 60 | - ['id' => 46, 'name' => 'using over-the-counter medication for pain, sleep, and weight control', 'category_id' => 3], |
|
| 61 | - ['id' => 47, 'name' => 'super busy', 'category_id' => 4], |
|
| 62 | - ['id' => 48, 'name' => 'workaholic', 'category_id' => 4], |
|
| 63 | - ['id' => 49, 'name' => 'can\'t relax', 'category_id' => 4], |
|
| 64 | - ['id' => 50, 'name' => 'driving too fast', 'category_id' => 4], |
|
| 65 | - ['id' => 51, 'name' => 'avoiding slowing down', 'category_id' => 4], |
|
| 66 | - ['id' => 52, 'name' => 'feeling driven', 'category_id' => 4], |
|
| 67 | - ['id' => 53, 'name' => 'in a hurry', 'category_id' => 4], |
|
| 68 | - ['id' => 54, 'name' => 'can\'t turn off thoughts', 'category_id' => 4], |
|
| 69 | - ['id' => 55, 'name' => 'skipping meals', 'category_id' => 4], |
|
| 70 | - ['id' => 56, 'name' => 'binge eating (usually at night)', 'category_id' => 4], |
|
| 71 | - ['id' => 57, 'name' => 'overspending', 'category_id' => 4], |
|
| 72 | - ['id' => 58, 'name' => 'can\'t identify own feelings/needs', 'category_id' => 4], |
|
| 73 | - ['id' => 59, 'name' => 'repetitive, negative thoughts', 'category_id' => 4], |
|
| 74 | - ['id' => 60, 'name' => 'irritable', 'category_id' => 4], |
|
| 75 | - ['id' => 61, 'name' => 'making excuses for "having to do it all"', 'category_id' => 4], |
|
| 76 | - ['id' => 62, 'name' => 'dramatic mood swings', 'category_id' => 4], |
|
| 77 | - ['id' => 63, 'name' => 'lust', 'category_id' => 4], |
|
| 78 | - ['id' => 64, 'name' => 'too much caffeine', 'category_id' => 4], |
|
| 79 | - ['id' => 65, 'name' => 'over exercising', 'category_id' => 4], |
|
| 80 | - ['id' => 66, 'name' => 'nervousness', 'category_id' => 4], |
|
| 81 | - ['id' => 67, 'name' => 'difficulty being alone or with people', 'category_id' => 4], |
|
| 82 | - ['id' => 68, 'name' => 'difficulty listening to others', 'category_id' => 4], |
|
| 83 | - ['id' => 69, 'name' => 'avoiding support', 'category_id' => 4], |
|
| 84 | - ['id' => 70, 'name' => 'procrastination causing crises in money, work, or relationships', 'category_id' => 5], |
|
| 85 | - ['id' => 71, 'name' => 'sarcasm', 'category_id' => 5], |
|
| 86 | - ['id' => 72, 'name' => 'black and white, all or nothing thinking', 'category_id' => 5], |
|
| 87 | - ['id' => 73, 'name' => 'feeling that no one understands', 'category_id' => 5], |
|
| 88 | - ['id' => 74, 'name' => 'overreacting', 'category_id' => 5], |
|
| 89 | - ['id' => 75, 'name' => 'road rage', 'category_id' => 5], |
|
| 90 | - ['id' => 76, 'name' => 'constant resentments', 'category_id' => 5], |
|
| 91 | - ['id' => 77, 'name' => 'pushing others away', 'category_id' => 5], |
|
| 92 | - ['id' => 78, 'name' => 'increased isolation', 'category_id' => 5], |
|
| 93 | - ['id' => 79, 'name' => 'blaming', 'category_id' => 5], |
|
| 94 | - ['id' => 80, 'name' => 'self pity', 'category_id' => 5], |
|
| 95 | - ['id' => 81, 'name' => 'arguing', 'category_id' => 5], |
|
| 96 | - ['id' => 82, 'name' => 'irrationality', 'category_id' => 5], |
|
| 97 | - ['id' => 83, 'name' => 'can\'t handle criticism', 'category_id' => 5], |
|
| 98 | - ['id' => 84, 'name' => 'defensive', 'category_id' => 5], |
|
| 99 | - ['id' => 85, 'name' => 'people are avoiding you', 'category_id' => 5], |
|
| 100 | - ['id' => 86, 'name' => 'having to be right', 'category_id' => 5], |
|
| 101 | - ['id' => 87, 'name' => 'digestive problems', 'category_id' => 5], |
|
| 102 | - ['id' => 88, 'name' => 'headaches', 'category_id' => 5], |
|
| 103 | - ['id' => 89, 'name' => 'obsessive (stuck) thoughts', 'category_id' => 5], |
|
| 104 | - ['id' => 90, 'name' => 'can\'t forgive', 'category_id' => 5], |
|
| 105 | - ['id' => 91, 'name' => 'feeling grandiose (superior)', 'category_id' => 5], |
|
| 106 | - ['id' => 92, 'name' => 'intimidation', 'category_id' => 5], |
|
| 107 | - ['id' => 93, 'name' => 'feeling aggressive', 'category_id' => 5], |
|
| 108 | - ['id' => 94, 'name' => 'depressed', 'category_id' => 6], |
|
| 109 | - ['id' => 95, 'name' => 'panicked', 'category_id' => 6], |
|
| 110 | - ['id' => 96, 'name' => 'confused', 'category_id' => 6], |
|
| 111 | - ['id' => 97, 'name' => 'hopeless', 'category_id' => 6], |
|
| 112 | - ['id' => 98, 'name' => 'sleeping too much or too little', 'category_id' => 6], |
|
| 113 | - ['id' => 99, 'name' => 'can\'t cope', 'category_id' => 6], |
|
| 17 | + ['id' => 1, 'name' => 'no current secrets', 'category_id' => 1], |
|
| 18 | + ['id' => 2, 'name' => 'resolving problems', 'category_id' => 1], |
|
| 19 | + ['id' => 3, 'name' => 'identifying fears and feelings', 'category_id' => 1], |
|
| 20 | + ['id' => 4, 'name' => 'keeping commitments to meetings, prayer, family, church, people, goals, and self', 'category_id' => 1], |
|
| 21 | + ['id' => 5, 'name' => 'being open', 'category_id' => 1], |
|
| 22 | + ['id' => 6, 'name' => 'being honest', 'category_id' => 1], |
|
| 23 | + ['id' => 7, 'name' => 'making eye contact', 'category_id' => 1], |
|
| 24 | + ['id' => 8, 'name' => 'reaching out to others', 'category_id' => 1], |
|
| 25 | + ['id' => 9, 'name' => 'increasing in relationships with God and others', 'category_id' => 1], |
|
| 26 | + ['id' => 10, 'name' => 'accountability', 'category_id' => 1], |
|
| 27 | + ['id' => 11, 'name' => 'secrets', 'category_id' => 2], |
|
| 28 | + ['id' => 12, 'name' => 'bored', 'category_id' => 2], |
|
| 29 | + ['id' => 13, 'name' => 'less time/energy for God, meetings, and church', 'category_id' => 2], |
|
| 30 | + ['id' => 14, 'name' => 'avoiding support and accountability towards people', 'category_id' => 2], |
|
| 31 | + ['id' => 15, 'name' => 'superficial conversations', 'category_id' => 2], |
|
| 32 | + ['id' => 16, 'name' => 'sarcasm', 'category_id' => 2], |
|
| 33 | + ['id' => 17, 'name' => 'isolating yourself', 'category_id' => 2], |
|
| 34 | + ['id' => 18, 'name' => 'changes in goals', 'category_id' => 2], |
|
| 35 | + ['id' => 19, 'name' => 'flirting', 'category_id' => 2], |
|
| 36 | + ['id' => 20, 'name' => 'obsessed with relationships', 'category_id' => 2], |
|
| 37 | + ['id' => 21, 'name' => 'breaking promises/commitments', 'category_id' => 2], |
|
| 38 | + ['id' => 22, 'name' => 'neglecting family', 'category_id' => 2], |
|
| 39 | + ['id' => 23, 'name' => 'preoccupation with material things, television, or entertainment', 'category_id' => 2], |
|
| 40 | + ['id' => 24, 'name' => 'procrastination', 'category_id' => 2], |
|
| 41 | + ['id' => 25, 'name' => 'lying', 'category_id' => 2], |
|
| 42 | + ['id' => 26, 'name' => 'over-confidence', 'category_id' => 2], |
|
| 43 | + ['id' => 27, 'name' => 'hiding money', 'category_id' => 2], |
|
| 44 | + ['id' => 28, 'name' => 'worry', 'category_id' => 3], |
|
| 45 | + ['id' => 29, 'name' => 'using profanity', 'category_id' => 3], |
|
| 46 | + ['id' => 30, 'name' => 'being fearful', 'category_id' => 3], |
|
| 47 | + ['id' => 31, 'name' => 'being resentful', 'category_id' => 3], |
|
| 48 | + ['id' => 32, 'name' => 'replaying old, negative thoughts', 'category_id' => 3], |
|
| 49 | + ['id' => 33, 'name' => 'perfectionism', 'category_id' => 3], |
|
| 50 | + ['id' => 34, 'name' => 'judging others\' motives', 'category_id' => 3], |
|
| 51 | + ['id' => 35, 'name' => 'making goals and lists you can\'t complete', 'category_id' => 3], |
|
| 52 | + ['id' => 36, 'name' => 'poor planning', 'category_id' => 3], |
|
| 53 | + ['id' => 37, 'name' => 'mind reading', 'category_id' => 3], |
|
| 54 | + ['id' => 38, 'name' => 'fantasy', 'category_id' => 3], |
|
| 55 | + ['id' => 41, 'name' => 'co-dependent rescuing', 'category_id' => 3], |
|
| 56 | + ['id' => 42, 'name' => 'sleep problems', 'category_id' => 3], |
|
| 57 | + ['id' => 43, 'name' => 'trouble concentrating', 'category_id' => 3], |
|
| 58 | + ['id' => 44, 'name' => 'seeking/creating drama', 'category_id' => 3], |
|
| 59 | + ['id' => 45, 'name' => 'gossip', 'category_id' => 3], |
|
| 60 | + ['id' => 46, 'name' => 'using over-the-counter medication for pain, sleep, and weight control', 'category_id' => 3], |
|
| 61 | + ['id' => 47, 'name' => 'super busy', 'category_id' => 4], |
|
| 62 | + ['id' => 48, 'name' => 'workaholic', 'category_id' => 4], |
|
| 63 | + ['id' => 49, 'name' => 'can\'t relax', 'category_id' => 4], |
|
| 64 | + ['id' => 50, 'name' => 'driving too fast', 'category_id' => 4], |
|
| 65 | + ['id' => 51, 'name' => 'avoiding slowing down', 'category_id' => 4], |
|
| 66 | + ['id' => 52, 'name' => 'feeling driven', 'category_id' => 4], |
|
| 67 | + ['id' => 53, 'name' => 'in a hurry', 'category_id' => 4], |
|
| 68 | + ['id' => 54, 'name' => 'can\'t turn off thoughts', 'category_id' => 4], |
|
| 69 | + ['id' => 55, 'name' => 'skipping meals', 'category_id' => 4], |
|
| 70 | + ['id' => 56, 'name' => 'binge eating (usually at night)', 'category_id' => 4], |
|
| 71 | + ['id' => 57, 'name' => 'overspending', 'category_id' => 4], |
|
| 72 | + ['id' => 58, 'name' => 'can\'t identify own feelings/needs', 'category_id' => 4], |
|
| 73 | + ['id' => 59, 'name' => 'repetitive, negative thoughts', 'category_id' => 4], |
|
| 74 | + ['id' => 60, 'name' => 'irritable', 'category_id' => 4], |
|
| 75 | + ['id' => 61, 'name' => 'making excuses for "having to do it all"', 'category_id' => 4], |
|
| 76 | + ['id' => 62, 'name' => 'dramatic mood swings', 'category_id' => 4], |
|
| 77 | + ['id' => 63, 'name' => 'lust', 'category_id' => 4], |
|
| 78 | + ['id' => 64, 'name' => 'too much caffeine', 'category_id' => 4], |
|
| 79 | + ['id' => 65, 'name' => 'over exercising', 'category_id' => 4], |
|
| 80 | + ['id' => 66, 'name' => 'nervousness', 'category_id' => 4], |
|
| 81 | + ['id' => 67, 'name' => 'difficulty being alone or with people', 'category_id' => 4], |
|
| 82 | + ['id' => 68, 'name' => 'difficulty listening to others', 'category_id' => 4], |
|
| 83 | + ['id' => 69, 'name' => 'avoiding support', 'category_id' => 4], |
|
| 84 | + ['id' => 70, 'name' => 'procrastination causing crises in money, work, or relationships', 'category_id' => 5], |
|
| 85 | + ['id' => 71, 'name' => 'sarcasm', 'category_id' => 5], |
|
| 86 | + ['id' => 72, 'name' => 'black and white, all or nothing thinking', 'category_id' => 5], |
|
| 87 | + ['id' => 73, 'name' => 'feeling that no one understands', 'category_id' => 5], |
|
| 88 | + ['id' => 74, 'name' => 'overreacting', 'category_id' => 5], |
|
| 89 | + ['id' => 75, 'name' => 'road rage', 'category_id' => 5], |
|
| 90 | + ['id' => 76, 'name' => 'constant resentments', 'category_id' => 5], |
|
| 91 | + ['id' => 77, 'name' => 'pushing others away', 'category_id' => 5], |
|
| 92 | + ['id' => 78, 'name' => 'increased isolation', 'category_id' => 5], |
|
| 93 | + ['id' => 79, 'name' => 'blaming', 'category_id' => 5], |
|
| 94 | + ['id' => 80, 'name' => 'self pity', 'category_id' => 5], |
|
| 95 | + ['id' => 81, 'name' => 'arguing', 'category_id' => 5], |
|
| 96 | + ['id' => 82, 'name' => 'irrationality', 'category_id' => 5], |
|
| 97 | + ['id' => 83, 'name' => 'can\'t handle criticism', 'category_id' => 5], |
|
| 98 | + ['id' => 84, 'name' => 'defensive', 'category_id' => 5], |
|
| 99 | + ['id' => 85, 'name' => 'people are avoiding you', 'category_id' => 5], |
|
| 100 | + ['id' => 86, 'name' => 'having to be right', 'category_id' => 5], |
|
| 101 | + ['id' => 87, 'name' => 'digestive problems', 'category_id' => 5], |
|
| 102 | + ['id' => 88, 'name' => 'headaches', 'category_id' => 5], |
|
| 103 | + ['id' => 89, 'name' => 'obsessive (stuck) thoughts', 'category_id' => 5], |
|
| 104 | + ['id' => 90, 'name' => 'can\'t forgive', 'category_id' => 5], |
|
| 105 | + ['id' => 91, 'name' => 'feeling grandiose (superior)', 'category_id' => 5], |
|
| 106 | + ['id' => 92, 'name' => 'intimidation', 'category_id' => 5], |
|
| 107 | + ['id' => 93, 'name' => 'feeling aggressive', 'category_id' => 5], |
|
| 108 | + ['id' => 94, 'name' => 'depressed', 'category_id' => 6], |
|
| 109 | + ['id' => 95, 'name' => 'panicked', 'category_id' => 6], |
|
| 110 | + ['id' => 96, 'name' => 'confused', 'category_id' => 6], |
|
| 111 | + ['id' => 97, 'name' => 'hopeless', 'category_id' => 6], |
|
| 112 | + ['id' => 98, 'name' => 'sleeping too much or too little', 'category_id' => 6], |
|
| 113 | + ['id' => 99, 'name' => 'can\'t cope', 'category_id' => 6], |
|
| 114 | 114 | ['id' => 100, 'name' => 'overwhelmed', 'category_id' => 6], |
| 115 | 115 | ['id' => 101, 'name' => 'crying for "no reason"', 'category_id' => 6], |
| 116 | 116 | ['id' => 102, 'name' => 'can\'t think', 'category_id' => 6], |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | public function getCategories() { |
| 181 | 181 | $bhvrs_by_cat = AH::index(self::$behaviors, null, 'category_id'); |
| 182 | 182 | $cats = AH::index(\common\models\Category::$categories, "id"); |
| 183 | - foreach($cats as $id => &$cat) { |
|
| 183 | + foreach ($cats as $id => &$cat) { |
|
| 184 | 184 | $cat['behavior_count'] = count($bhvrs_by_cat[$id]); // add count of behaviors |
| 185 | 185 | $cat['category_id'] = $cat['id']; // rename id to category_id |
| 186 | 186 | unset($cat['id']); |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | */ |
| 144 | 144 | public function findByPasswordResetToken($token) |
| 145 | 145 | { |
| 146 | - if(!$this->isTokenCurrent($token)) { |
|
| 146 | + if (!$this->isTokenCurrent($token)) { |
|
| 147 | 147 | return null; |
| 148 | 148 | } |
| 149 | 149 | |
@@ -161,15 +161,15 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function findByVerifyEmailToken($token) |
| 163 | 163 | { |
| 164 | - if($this->isTokenConfirmed($token)) return null; |
|
| 164 | + if ($this->isTokenConfirmed($token)) return null; |
|
| 165 | 165 | |
| 166 | 166 | $user = $this->findOne([ |
| 167 | 167 | 'verify_email_token' => [$token, $token . self::CONFIRMED_STRING], |
| 168 | 168 | 'status' => self::STATUS_ACTIVE, |
| 169 | 169 | ]); |
| 170 | 170 | |
| 171 | - if($user) { |
|
| 172 | - if(!$this->isTokenConfirmed($token) && |
|
| 171 | + if ($user) { |
|
| 172 | + if (!$this->isTokenConfirmed($token) && |
|
| 173 | 173 | !$this->isTokenCurrent($token, 'user.verifyAccountTokenExpire')) { |
| 174 | 174 | return null; |
| 175 | 175 | } |
@@ -191,8 +191,8 @@ discard block |
||
| 191 | 191 | 'status' => self::STATUS_ACTIVE, |
| 192 | 192 | ]); |
| 193 | 193 | |
| 194 | - if($user) { |
|
| 195 | - if(!$user->isTokenCurrent($token, 'user.verifyAccountTokenExpire')) { |
|
| 194 | + if ($user) { |
|
| 195 | + if (!$user->isTokenCurrent($token, 'user.verifyAccountTokenExpire')) { |
|
| 196 | 196 | return null; |
| 197 | 197 | } |
| 198 | 198 | } |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | public function isTokenCurrent($token, String $paramPath = 'user.passwordResetTokenExpire') { |
| 211 | 211 | $expire = \Yii::$app->params[$paramPath]; |
| 212 | 212 | $parts = explode('_', $token); |
| 213 | - $timestamp = (int) end($parts); |
|
| 213 | + $timestamp = (int)end($parts); |
|
| 214 | 214 | if ($timestamp + $expire < time()) { |
| 215 | 215 | // token expired |
| 216 | 216 | return false; |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | * @param string $match the needle to search for |
| 226 | 226 | */ |
| 227 | 227 | public function isTokenConfirmed($token = null, String $match = self::CONFIRMED_STRING) { |
| 228 | - if(is_null($token)) $token = $this->verify_email_token; |
|
| 228 | + if (is_null($token)) $token = $this->verify_email_token; |
|
| 229 | 229 | return substr($token, -strlen($match)) === $match; |
| 230 | 230 | } |
| 231 | 231 | |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | public function isVerified() { |
| 253 | - if(is_null($this->verify_email_token)) { |
|
| 253 | + if (is_null($this->verify_email_token)) { |
|
| 254 | 254 | // for old users who verified their accounts before the addition of |
| 255 | 255 | // '_confirmed' to the token |
| 256 | 256 | return true; |
@@ -358,14 +358,14 @@ discard block |
||
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | public function sendEmailReport($date) { |
| 361 | - if(!$this->send_email) return false; // no partner emails set |
|
| 361 | + if (!$this->send_email) return false; // no partner emails set |
|
| 362 | 362 | list($start, $end) = $this->time->getUTCBookends($date); |
| 363 | - $user_behaviors = $this->getUserBehaviors($date); |
|
| 363 | + $user_behaviors = $this->getUserBehaviors($date); |
|
| 364 | 364 | $user_questions = $this->getUserQuestions($date); |
| 365 | 365 | |
| 366 | 366 | $messages = []; |
| 367 | - foreach($this->getPartnerEmails() as $email) { |
|
| 368 | - if($email) { |
|
| 367 | + foreach ($this->getPartnerEmails() as $email) { |
|
| 368 | + if ($email) { |
|
| 369 | 369 | $messages[] = Yii::$app->mailer->compose('checkinReport', [ |
| 370 | 370 | 'user' => $this, |
| 371 | 371 | 'email' => $email, |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | 'behaviors_list' => \common\models\Behavior::$behaviors, |
| 378 | 378 | ])->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name]) |
| 379 | 379 | ->setReplyTo($this->email) |
| 380 | - ->setSubject($this->email." has completed a Faster Scale check-in") |
|
| 380 | + ->setSubject($this->email . " has completed a Faster Scale check-in") |
|
| 381 | 381 | ->setTo($email); |
| 382 | 382 | } |
| 383 | 383 | } |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | return \Yii::$app->mailer->compose('signupNotification') |
| 451 | 451 | ->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name]) |
| 452 | 452 | ->setTo(\Yii::$app->params['adminEmail']) |
| 453 | - ->setSubject('A new user has signed up for '.\Yii::$app->name) |
|
| 453 | + ->setSubject('A new user has signed up for ' . \Yii::$app->name) |
|
| 454 | 454 | ->send(); |
| 455 | 455 | } |
| 456 | 456 | |
@@ -458,20 +458,20 @@ discard block |
||
| 458 | 458 | return \Yii::$app->mailer->compose('verifyEmail', ['user' => $this]) |
| 459 | 459 | ->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name]) |
| 460 | 460 | ->setTo($this->email) |
| 461 | - ->setSubject('Please verify your '.\Yii::$app->name .' account') |
|
| 461 | + ->setSubject('Please verify your ' . \Yii::$app->name . ' account') |
|
| 462 | 462 | ->send(); |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | public function sendDeleteNotificationEmail() { |
| 466 | 466 | $messages = []; |
| 467 | - foreach(array_merge([$this->email], $this->getPartnerEmails()) as $email) { |
|
| 468 | - if($email) { |
|
| 467 | + foreach (array_merge([$this->email], $this->getPartnerEmails()) as $email) { |
|
| 468 | + if ($email) { |
|
| 469 | 469 | $messages[] = Yii::$app->mailer->compose('deleteNotification', [ |
| 470 | 470 | 'user' => $this, |
| 471 | 471 | 'email' => $email |
| 472 | 472 | ])->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name]) |
| 473 | 473 | ->setReplyTo($this->email) |
| 474 | - ->setSubject($this->email." has deleted their The Faster Scale App account") |
|
| 474 | + ->setSubject($this->email . " has deleted their The Faster Scale App account") |
|
| 475 | 475 | ->setTo($email); |
| 476 | 476 | } |
| 477 | 477 | } |
@@ -480,13 +480,13 @@ discard block |
||
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | public function getUserQuestions($local_date = null) { |
| 483 | - if(is_null($local_date)) $local_date = $this->time->getLocalDate(); |
|
| 483 | + if (is_null($local_date)) $local_date = $this->time->getLocalDate(); |
|
| 484 | 484 | $questions = $this->getQuestionData($local_date); |
| 485 | 485 | return $this->parseQuestionData($questions); |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | public function getUserBehaviors($local_date = null) { |
| 489 | - if(is_null($local_date)) $local_date = $this->time->getLocalDate(); |
|
| 489 | + if (is_null($local_date)) $local_date = $this->time->getLocalDate(); |
|
| 490 | 490 | |
| 491 | 491 | $behaviors = $this->getBehaviorData($local_date); |
| 492 | 492 | $behaviors = $this->user_behavior::decorateWithCategory($behaviors); |
@@ -494,10 +494,10 @@ discard block |
||
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | public function parseQuestionData($questions) { |
| 497 | - if(!$questions) return []; |
|
| 497 | + if (!$questions) return []; |
|
| 498 | 498 | |
| 499 | 499 | $question_answers = []; |
| 500 | - foreach($questions as $question) { |
|
| 500 | + foreach ($questions as $question) { |
|
| 501 | 501 | $behavior = $question['behavior']; |
| 502 | 502 | |
| 503 | 503 | $question_answers[$behavior['id']]['question'] = [ |
@@ -515,10 +515,10 @@ discard block |
||
| 515 | 515 | } |
| 516 | 516 | |
| 517 | 517 | public function parseBehaviorData($behaviors) { |
| 518 | - if(!$behaviors) return []; |
|
| 518 | + if (!$behaviors) return []; |
|
| 519 | 519 | |
| 520 | 520 | $opts_by_cat = []; |
| 521 | - foreach($behaviors as $behavior) { |
|
| 521 | + foreach ($behaviors as $behavior) { |
|
| 522 | 522 | $indx = $behavior['behavior']['category_id']; |
| 523 | 523 | |
| 524 | 524 | $opts_by_cat[$indx]['category_name'] = $behavior['behavior']['category']['name']; |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | return rtrim( |
| 611 | 611 | strtr( |
| 612 | 612 | base64_encode( |
| 613 | - hash('sha256', $this->id."::".$this->created_at, true) |
|
| 613 | + hash('sha256', $this->id . "::" . $this->created_at, true) |
|
| 614 | 614 | ), |
| 615 | 615 | '+/', '-_'), |
| 616 | 616 | '='); |
@@ -161,7 +161,9 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function findByVerifyEmailToken($token) |
| 163 | 163 | { |
| 164 | - if($this->isTokenConfirmed($token)) return null; |
|
| 164 | + if($this->isTokenConfirmed($token)) { |
|
| 165 | + return null; |
|
| 166 | + } |
|
| 165 | 167 | |
| 166 | 168 | $user = $this->findOne([ |
| 167 | 169 | 'verify_email_token' => [$token, $token . self::CONFIRMED_STRING], |
@@ -225,7 +227,9 @@ discard block |
||
| 225 | 227 | * @param string $match the needle to search for |
| 226 | 228 | */ |
| 227 | 229 | public function isTokenConfirmed($token = null, String $match = self::CONFIRMED_STRING) { |
| 228 | - if(is_null($token)) $token = $this->verify_email_token; |
|
| 230 | + if(is_null($token)) { |
|
| 231 | + $token = $this->verify_email_token; |
|
| 232 | + } |
|
| 229 | 233 | return substr($token, -strlen($match)) === $match; |
| 230 | 234 | } |
| 231 | 235 | |
@@ -358,7 +362,10 @@ discard block |
||
| 358 | 362 | } |
| 359 | 363 | |
| 360 | 364 | public function sendEmailReport($date) { |
| 361 | - if(!$this->send_email) return false; // no partner emails set |
|
| 365 | + if(!$this->send_email) { |
|
| 366 | + return false; |
|
| 367 | + } |
|
| 368 | + // no partner emails set |
|
| 362 | 369 | list($start, $end) = $this->time->getUTCBookends($date); |
| 363 | 370 | $user_behaviors = $this->getUserBehaviors($date); |
| 364 | 371 | $user_questions = $this->getUserQuestions($date); |
@@ -480,13 +487,17 @@ discard block |
||
| 480 | 487 | } |
| 481 | 488 | |
| 482 | 489 | public function getUserQuestions($local_date = null) { |
| 483 | - if(is_null($local_date)) $local_date = $this->time->getLocalDate(); |
|
| 490 | + if(is_null($local_date)) { |
|
| 491 | + $local_date = $this->time->getLocalDate(); |
|
| 492 | + } |
|
| 484 | 493 | $questions = $this->getQuestionData($local_date); |
| 485 | 494 | return $this->parseQuestionData($questions); |
| 486 | 495 | } |
| 487 | 496 | |
| 488 | 497 | public function getUserBehaviors($local_date = null) { |
| 489 | - if(is_null($local_date)) $local_date = $this->time->getLocalDate(); |
|
| 498 | + if(is_null($local_date)) { |
|
| 499 | + $local_date = $this->time->getLocalDate(); |
|
| 500 | + } |
|
| 490 | 501 | |
| 491 | 502 | $behaviors = $this->getBehaviorData($local_date); |
| 492 | 503 | $behaviors = $this->user_behavior::decorateWithCategory($behaviors); |
@@ -494,7 +505,9 @@ discard block |
||
| 494 | 505 | } |
| 495 | 506 | |
| 496 | 507 | public function parseQuestionData($questions) { |
| 497 | - if(!$questions) return []; |
|
| 508 | + if(!$questions) { |
|
| 509 | + return []; |
|
| 510 | + } |
|
| 498 | 511 | |
| 499 | 512 | $question_answers = []; |
| 500 | 513 | foreach($questions as $question) { |
@@ -515,7 +528,9 @@ discard block |
||
| 515 | 528 | } |
| 516 | 529 | |
| 517 | 530 | public function parseBehaviorData($behaviors) { |
| 518 | - if(!$behaviors) return []; |
|
| 531 | + if(!$behaviors) { |
|
| 532 | + return []; |
|
| 533 | + } |
|
| 519 | 534 | |
| 520 | 535 | $opts_by_cat = []; |
| 521 | 536 | foreach($behaviors as $behavior) { |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | ]); ?> |
| 25 | 25 | <?= $form->field($profile, 'timezone')->dropDownList(array_combine($timezones, $timezones)); ?> |
| 26 | 26 | <?= $form->field($profile, 'send_email')->checkbox() ?> |
| 27 | - <div id='send_email_fields' <?php if(!$profile->send_email) { ?>style="display: none;"<?php } ?>> |
|
| 27 | + <div id='send_email_fields' <?php if (!$profile->send_email) { ?>style="display: none;"<?php } ?>> |
|
| 28 | 28 | <?= $form->field($profile, 'partner_email1')->input('email'); ?> |
| 29 | 29 | <?= $form->field($profile, 'partner_email2')->input('email'); ?> |
| 30 | 30 | <?= $form->field($profile, 'partner_email3')->input('email'); ?> |
@@ -69,16 +69,16 @@ |
||
| 69 | 69 | public function saveProfile() |
| 70 | 70 | { |
| 71 | 71 | if ($this->validate()) { |
| 72 | - $user = $this->user; |
|
| 72 | + $user = $this->user; |
|
| 73 | 73 | |
| 74 | - if($this->timezone) |
|
| 74 | + if ($this->timezone) |
|
| 75 | 75 | $user->timezone = $this->timezone; |
| 76 | - if($this->expose_graph) { |
|
| 76 | + if ($this->expose_graph) { |
|
| 77 | 77 | $user->expose_graph = true; |
| 78 | 78 | } else { |
| 79 | 79 | $user->expose_graph = false; |
| 80 | 80 | } |
| 81 | - if($this->send_email) { |
|
| 81 | + if ($this->send_email) { |
|
| 82 | 82 | $user->partner_email1 = $this->partner_email1; |
| 83 | 83 | $user->partner_email2 = $this->partner_email2; |
| 84 | 84 | $user->partner_email3 = $this->partner_email3; |
@@ -71,8 +71,9 @@ |
||
| 71 | 71 | if ($this->validate()) { |
| 72 | 72 | $user = $this->user; |
| 73 | 73 | |
| 74 | - if($this->timezone) |
|
| 75 | - $user->timezone = $this->timezone; |
|
| 74 | + if($this->timezone) { |
|
| 75 | + $user->timezone = $this->timezone; |
|
| 76 | + } |
|
| 76 | 77 | if($this->expose_graph) { |
| 77 | 78 | $user->expose_graph = true; |
| 78 | 79 | } else { |