@@ -14,14 +14,14 @@ |
||
14 | 14 | */ |
15 | 15 | protected function redirectTo($request) |
16 | 16 | { |
17 | - if($request->has('sso')){ |
|
17 | + if ($request->has('sso')) { |
|
18 | 18 | list(,$wikiCode,) = explode('/', $request->getRequestUri()); |
19 | 19 | session()->put('sso', $request->get('sso')); |
20 | 20 | session()->put('sig', $request->get('sig')); |
21 | 21 | session()->put('wikiCode', strtolower($wikiCode)); |
22 | 22 | } |
23 | 23 | |
24 | - if (! $request->expectsJson()) { |
|
24 | + if (!$request->expectsJson()) { |
|
25 | 25 | return route('login'); |
26 | 26 | } |
27 | 27 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | public function showLoginForm(Request $request) |
27 | 27 | { |
28 | - if($request->has('wiki_callback')){ |
|
28 | + if ($request->has('wiki_callback')) { |
|
29 | 29 | session()->flash('wiki_callback', $request->input('wiki_callback')); |
30 | 30 | session()->flash('wiki_token', $request->input('wiki_token')); |
31 | 31 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | protected function loggedOut(Request $request) |
53 | 53 | { |
54 | 54 | $request->session()->reflash(); |
55 | - if($request->session()->has('should_attach_to_organization')){ |
|
55 | + if ($request->session()->has('should_attach_to_organization')) { |
|
56 | 56 | $linkToRedirect = $request->session()->get('should_attach_to_organization_redirect'); |
57 | 57 | return $request->wantsJson() |
58 | 58 | ? new Response('', 204) |
@@ -68,12 +68,12 @@ discard block |
||
68 | 68 | $user->save(); |
69 | 69 | } |
70 | 70 | |
71 | - if($user->context_id === null){ |
|
71 | + if ($user->context_id === null) { |
|
72 | 72 | return redirect()->route('wizard.profile'); |
73 | 73 | } |
74 | 74 | |
75 | - if($request->session()->has('sso')){ |
|
76 | - if(!$user->hasVerifiedEmail()){ |
|
75 | + if ($request->session()->has('sso')) { |
|
76 | + if (!$user->hasVerifiedEmail()) { |
|
77 | 77 | $request->session()->flash('from_forum', true); |
78 | 78 | return redirect()->route('email.verify'); |
79 | 79 | } |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | return redirect($wikiCode.'/neayi/discourse/sso?sso='.$sso.'&sig='.$sig); |
84 | 84 | } |
85 | 85 | |
86 | - if($request->session()->has('wiki_callback')){ |
|
86 | + if ($request->session()->has('wiki_callback')) { |
|
87 | 87 | $user->wiki_token = $request->session()->get('wiki_token'); |
88 | 88 | $user->save(); |
89 | 89 | $callback = urldecode($request->session()->get('wiki_callback')); |
90 | - if(!$user->hasVerifiedEmail()){ |
|
90 | + if (!$user->hasVerifiedEmail()) { |
|
91 | 91 | return redirect()->route('verification.notice'); |
92 | 92 | } |
93 | 93 | return redirect($callback); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | public function redirectToProvider(string $provider) |
100 | 100 | { |
101 | - if($provider === 'twitter'){ |
|
101 | + if ($provider === 'twitter') { |
|
102 | 102 | config(['services.'.$provider.'.redirect' => env(strtoupper($provider).'_CALLBACK_LOGIN')]); |
103 | 103 | return Socialite::driver($provider)->redirect(); |
104 | 104 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | try { |
47 | 47 | $context = $contextQueryByUser->execute(Auth::user()->uuid)->toArray(); |
48 | - }catch (\Throwable $e){ |
|
48 | + } catch (\Throwable $e) { |
|
49 | 49 | // profile not found, we redirect to creation of profile |
50 | 50 | return redirect()->route('wizard.profile'); |
51 | 51 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $roles = $getUserRole->get()->toArray(); |
55 | 55 | $practises = $getUserPractises->get(Auth::user()->uuid); |
56 | 56 | $interactions = $getInteractionsByUser->get(Auth::user()->uuid); |
57 | - $usersCharacteristics = array_merge($context['productions'], $context['characteristics'], $context['characteristics_departement']); |
|
57 | + $usersCharacteristics = array_merge($context['productions'], $context['characteristics'], $context['characteristics_departement']); |
|
58 | 58 | $uuidsUserCharacteristics = array_column($usersCharacteristics, 'uuid'); |
59 | 59 | $role = last($user['roles']); |
60 | 60 | $routeComment = route('profile.comments.show'); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $usersCharacteristics = array_merge($context['productions'], $context['characteristics']); |
96 | 96 | } else { |
97 | 97 | $context = [ |
98 | - 'fullname' => $user['firstname'] . ' ' . $user['lastname'], |
|
98 | + 'fullname' => $user['firstname'].' '.$user['lastname'], |
|
99 | 99 | 'description' => '', |
100 | 100 | ]; |
101 | 101 | $usersCharacteristics = []; |
@@ -45,7 +45,7 @@ |
||
45 | 45 | |
46 | 46 | try { |
47 | 47 | $context = $contextQueryByUser->execute(Auth::user()->uuid)->toArray(); |
48 | - }catch (\Throwable $e){ |
|
48 | + } catch (\Throwable $e){ |
|
49 | 49 | // profile not found, we redirect to creation of profile |
50 | 50 | return redirect()->route('wizard.profile'); |
51 | 51 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | { |
36 | 36 | $uuid = ''; |
37 | 37 | $user = User::query()->where("discourse_username", $username)->first(); |
38 | - if(!empty($user)){ |
|
38 | + if (!empty($user)) { |
|
39 | 39 | $uuid = $user->uuid; |
40 | 40 | } |
41 | 41 | $avatar = $getAvatar->execute($uuid, $width, true, $firstLetter, $color); |
@@ -37,10 +37,10 @@ discard block |
||
37 | 37 | $interactions = $request->input('interactions'); |
38 | 38 | $doneValue = $request->input('done_value', []); |
39 | 39 | $wikiCode = $request->input('wiki'); |
40 | - $handleInteractions->execute((int)$pageId, $interactions, $wikiCode, $doneValue); |
|
40 | + $handleInteractions->execute((int) $pageId, $interactions, $wikiCode, $doneValue); |
|
41 | 41 | |
42 | - $interaction = $interactionsQueryByPageAndUser->execute((int)$pageId, $wikiCode); |
|
43 | - $counts = $countInteractionsOnPage->execute((int)$pageId, $wikiCode); |
|
42 | + $interaction = $interactionsQueryByPageAndUser->execute((int) $pageId, $wikiCode); |
|
43 | + $counts = $countInteractionsOnPage->execute((int) $pageId, $wikiCode); |
|
44 | 44 | |
45 | 45 | return [ |
46 | 46 | 'state' => isset($interaction) ? $interaction->toArray() : [], |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | { |
58 | 58 | $wikiCode = $request->input('wiki'); |
59 | 59 | |
60 | - return $countInteractionsOnPage->execute((int)$pageId, $wikiCode); |
|
60 | + return $countInteractionsOnPage->execute((int) $pageId, $wikiCode); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | ) |
74 | 74 | { |
75 | 75 | $wikiCode = $request->input('wiki'); |
76 | - $interaction = $interactionsQueryByPageAndUser->execute((int)$pageId, $wikiCode); |
|
77 | - $counts = $countInteractionsOnPage->execute((int)$pageId, $wikiCode); |
|
76 | + $interaction = $interactionsQueryByPageAndUser->execute((int) $pageId, $wikiCode); |
|
77 | + $counts = $countInteractionsOnPage->execute((int) $pageId, $wikiCode); |
|
78 | 78 | |
79 | 79 | return [ |
80 | 80 | 'state' => isset($interaction) ? $interaction->toArray() : [], |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | $croppingId = $request->input('cropping_id', null); |
99 | 99 | $wikiCode = $request->input('wiki'); |
100 | 100 | |
101 | - return $getFollowersOfPage->execute((int)$pageId, $type, $dept, $farmingId, $croppingId, $wikiCode); |
|
101 | + return $getFollowersOfPage->execute((int) $pageId, $type, $dept, $farmingId, $croppingId, $wikiCode); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | public function getStatsDepartment($pageId, Request $request, GetStatsByDepartment $getStatsByDepartment) |
105 | 105 | { |
106 | 106 | $type = $request->input('type', 'follow'); |
107 | 107 | |
108 | - return $getStatsByDepartment->execute((int)$pageId, $type); |
|
108 | + return $getStatsByDepartment->execute((int) $pageId, $type); |
|
109 | 109 | } |
110 | 110 | } |
@@ -16,12 +16,12 @@ discard block |
||
16 | 16 | { |
17 | 17 | $token = $request->input('wiki_token', null); |
18 | 18 | |
19 | - if($token === null || $token === ''){ |
|
19 | + if ($token === null || $token === '') { |
|
20 | 20 | return ['error' => 'invalid_token']; |
21 | 21 | } |
22 | 22 | $user = User::where('wiki_token', $token)->first(); |
23 | 23 | |
24 | - if($user === null){ |
|
24 | + if ($user === null) { |
|
25 | 25 | return ['error' => 'invalid_token']; |
26 | 26 | } |
27 | 27 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | { |
42 | 42 | $user = Auth::user(); |
43 | 43 | |
44 | - if(isset($user)){ |
|
44 | + if (isset($user)) { |
|
45 | 45 | $wikiUrl = $user->locale()->wiki_url; |
46 | 46 | $user->wiki_token = ''; |
47 | 47 | $user->save(); |
@@ -46,8 +46,7 @@ |
||
46 | 46 | $user->wiki_token = ''; |
47 | 47 | $user->save(); |
48 | 48 | Auth::logout(); |
49 | - } |
|
50 | - else |
|
49 | + } else |
|
51 | 50 | { |
52 | 51 | $request = request(); |
53 | 52 | $locale = \App\LocalesConfig::getLocaleFromCode($request->getPreferredLanguage()); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | public function adminlte_image() |
39 | 39 | { |
40 | 40 | $urlPicture = $this->path_picture != "" ? asset('storage/'.str_replace('app/public/', '', $this->path_picture)) : null; |
41 | - if(!isset($urlPicture) || $urlPicture === ""){ |
|
41 | + if (!isset($urlPicture) || $urlPicture === "") { |
|
42 | 42 | $urlPicture = url('').'/'.config('adminlte.logo_img'); |
43 | 43 | } |
44 | 44 | return $urlPicture; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | $title = $this->context->sector; |
81 | 81 | if (!empty($this->context->structure)) |
82 | - $title .= ' (' . $this->context->structure . ')'; |
|
82 | + $title .= ' ('.$this->context->structure.')'; |
|
83 | 83 | |
84 | 84 | return $title; |
85 | 85 | } |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | public function sendEmailVerificationNotification() |
117 | 117 | { |
118 | 118 | $callback = ''; |
119 | - if(session()->has('wiki_callback')){ |
|
119 | + if (session()->has('wiki_callback')) { |
|
120 | 120 | $callback = base64_encode(urldecode(session()->get('wiki_callback'))); |
121 | 121 | } |
122 | 122 | |
123 | - if(session()->has('sso')){ |
|
123 | + if (session()->has('sso')) { |
|
124 | 124 | $sso = session()->get('sso'); |
125 | 125 | $sig = session()->get('sig'); |
126 | 126 | $callback = base64_encode(url('neayi/discourse/sso?sso='.$sso.'&sig='.$sig)); |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | |
146 | 146 | public function addCharacteristics(array $characteristics) |
147 | 147 | { |
148 | - foreach($characteristics as $characteristicUuid){ |
|
149 | - $characteristic = CharacteristicsModel::where('uuid', (string)$characteristicUuid)->first(); |
|
150 | - if(isset($characteristic)) { |
|
148 | + foreach ($characteristics as $characteristicUuid) { |
|
149 | + $characteristic = CharacteristicsModel::where('uuid', (string) $characteristicUuid)->first(); |
|
150 | + if (isset($characteristic)) { |
|
151 | 151 | $this->characteristics()->save($characteristic); |
152 | 152 | } |
153 | 153 | } |
@@ -156,9 +156,9 @@ discard block |
||
156 | 156 | public function syncCharacteristics(array $characteristics) |
157 | 157 | { |
158 | 158 | $characteristicsToSync = []; |
159 | - foreach($characteristics as $characteristicUuid){ |
|
160 | - $characteristicModel = CharacteristicsModel::where('uuid', (string)$characteristicUuid)->first(); |
|
161 | - if(isset($characteristicModel)) { |
|
159 | + foreach ($characteristics as $characteristicUuid) { |
|
160 | + $characteristicModel = CharacteristicsModel::where('uuid', (string) $characteristicUuid)->first(); |
|
161 | + if (isset($characteristicModel)) { |
|
162 | 162 | $characteristicsToSync[] = $characteristicModel->id; |
163 | 163 | } |
164 | 164 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | public function askDiscourseSync() |
180 | 180 | { |
181 | 181 | $sync = UserSyncDiscourseModel::query()->where('user_id', $this->id)->first(); |
182 | - if(!isset($sync)){ |
|
182 | + if (!isset($sync)) { |
|
183 | 183 | $sync = new UserSyncDiscourseModel(); |
184 | 184 | $sync->user_id = $this->id; |
185 | 185 | $sync->uuid = $this->uuid; |
@@ -63,8 +63,9 @@ discard block |
||
63 | 63 | |
64 | 64 | public function getBioAttribute() |
65 | 65 | { |
66 | - if (empty($this->context) || empty($this->context->description)) |
|
67 | - return ''; |
|
66 | + if (empty($this->context) || empty($this->context->description)) { |
|
67 | + return ''; |
|
68 | + } |
|
68 | 69 | |
69 | 70 | return $this->context->description; |
70 | 71 | } |
@@ -74,12 +75,14 @@ discard block |
||
74 | 75 | */ |
75 | 76 | public function getTitleAttribute() |
76 | 77 | { |
77 | - if (empty($this->context) || empty($this->context->sector)) |
|
78 | - return ''; |
|
78 | + if (empty($this->context) || empty($this->context->sector)) { |
|
79 | + return ''; |
|
80 | + } |
|
79 | 81 | |
80 | 82 | $title = $this->context->sector; |
81 | - if (!empty($this->context->structure)) |
|
82 | - $title .= ' (' . $this->context->structure . ')'; |
|
83 | + if (!empty($this->context->structure)) { |
|
84 | + $title .= ' (' . $this->context->structure . ')'; |
|
85 | + } |
|
83 | 86 | |
84 | 87 | return $title; |
85 | 88 | } |
@@ -92,8 +95,9 @@ discard block |
||
92 | 95 | */ |
93 | 96 | public function getDiscourseUsernameAttribute($value) |
94 | 97 | { |
95 | - if (empty($value)) |
|
96 | - return trim(substr(Str::of($this->fullname)->slug('.'), 0, 20), '.'); |
|
98 | + if (empty($value)) { |
|
99 | + return trim(substr(Str::of($this->fullname)->slug('.'), 0, 20), '.'); |
|
100 | + } |
|
97 | 101 | |
98 | 102 | return $value; |
99 | 103 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | try { |
26 | 26 | $response = $this->client->get($uri); |
27 | 27 | return json_decode($response->getBody()->getContents(), true); |
28 | - } catch (\Throwable $e){ |
|
28 | + } catch (\Throwable $e) { |
|
29 | 29 | return ['results' => []]; |
30 | 30 | } |
31 | 31 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | return json_decode($response->getBody()->getContents(), true); |
111 | 111 | } |
112 | 112 | |
113 | - public function getPagesAdditionalDetail(string|int $offset = null): array |
|
113 | + public function getPagesAdditionalDetail(string | int $offset = null): array |
|
114 | 114 | { |
115 | 115 | $query = "action=ask&format=json&api_version=3&query=[[A un glyph::%2B]]|?A un glyph|?A un type de page"; |
116 | 116 |
@@ -32,21 +32,21 @@ discard block |
||
32 | 32 | |
33 | 33 | public function getUserByEmail(string $email): array |
34 | 34 | { |
35 | - $response = $this->client->get('/admin/users/list/active.json?filter=' . $email . '&show_emails=true&order=&ascending=&page=1'); |
|
35 | + $response = $this->client->get('/admin/users/list/active.json?filter='.$email.'&show_emails=true&order=&ascending=&page=1'); |
|
36 | 36 | |
37 | 37 | return json_decode($response->getBody()->getContents(), true); |
38 | 38 | } |
39 | 39 | |
40 | 40 | public function getUserByInsightId(int $id): array |
41 | 41 | { |
42 | - $result = $this->client->get('u/by-external/' . $id . '.json'); |
|
42 | + $result = $this->client->get('u/by-external/'.$id.'.json'); |
|
43 | 43 | |
44 | 44 | return json_decode($result->getBody()->getContents(), true); |
45 | 45 | } |
46 | 46 | |
47 | 47 | public function updateEmail(string $username, string $email): array |
48 | 48 | { |
49 | - $result = $this->client->put('u/' . $username . '/preferences/email.json', [ |
|
49 | + $result = $this->client->put('u/'.$username.'/preferences/email.json', [ |
|
50 | 50 | 'json' => [ |
51 | 51 | 'email' => $email, |
52 | 52 | ] |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | public function updateUser(User $user, string $bio): array |
59 | 59 | { |
60 | - $result = $this->client->put('u/' . $user->discourse_username . '.json', [ |
|
60 | + $result = $this->client->put('u/'.$user->discourse_username.'.json', [ |
|
61 | 61 | 'json' => [ |
62 | 62 | 'name' => $user->fullname, |
63 | 63 | 'title' => $user->title, |