... | ... |
@@ -10,12 +10,6 @@ declare(strict_types=1); |
10 | 10 |
* @license commercial |
11 | 11 |
*/ |
12 | 12 |
|
13 |
-use vossmedien\DacoreBundle\Controller\Frontend\Module\JoblistModuleController; |
|
14 |
-use vossmedien\DacoreBundle\Controller\Frontend\Module\JobSearchModuleController; |
|
15 |
-use vossmedien\DacoreBundle\Controller\Frontend\Module\JobReaderModuleController; |
|
16 | 13 |
use vossmedien\DacoreBundle\Controller\Frontend\Module\JobApplicationFormController; |
17 | 14 |
|
18 | 15 |
$GLOBALS['TL_DCA']['tl_module']['palettes'][JobApplicationFormController::TYPE] = '{title_legend},name,type;{dacore_form_legend},form;{redirect_legend},jumpTo;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; |
19 |
-$GLOBALS['TL_DCA']['tl_module']['palettes'][JoblistModuleController::TYPE] = '{title_legend},name,type;{alox_legend},jumpTo,perPage;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; |
|
20 |
-$GLOBALS['TL_DCA']['tl_module']['palettes'][JobSearchModuleController::TYPE] = '{title_legend},name,type;{aloxSearch_legend},jumpTo;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; |
|
21 |
-$GLOBALS['TL_DCA']['tl_module']['palettes'][JobReaderModuleController::TYPE] = '{title_legend},name,type;{aloxReader_legend},overviewPage;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; |
... | ... |
@@ -10,16 +10,7 @@ declare(strict_types=1); |
10 | 10 |
* @license commercial |
11 | 11 |
*/ |
12 | 12 |
|
13 |
-use vossmedien\DacoreBundle\Controller\Frontend\Module\JoblistModuleController; |
|
14 |
-use vossmedien\DacoreBundle\Controller\Frontend\Module\JobSearchModuleController; |
|
15 |
-use vossmedien\DacoreBundle\Controller\Frontend\Module\JobReaderModuleController; |
|
16 | 13 |
use vossmedien\DacoreBundle\Controller\Frontend\Module\JobApplicationFormController; |
17 | 14 |
|
18 | 15 |
$GLOBALS['TL_LANG']['FMD'][JobApplicationFormController::TYPE][0] = 'Dacore Bewerbungsformular'; |
19 | 16 |
$GLOBALS['TL_LANG']['FMD'][JobApplicationFormController::TYPE][1] = 'Erzeugt ein Formular für Bewerbungen.'; |
20 |
-$GLOBALS['TL_LANG']['FMD'][JoblistModuleController::TYPE][0] = 'Alox Job Liste'; |
|
21 |
-$GLOBALS['TL_LANG']['FMD'][JoblistModuleController::TYPE][1] = 'Gibt eine Liste mit Jobs aus.'; |
|
22 |
-$GLOBALS['TL_LANG']['FMD'][JobSearchModuleController::TYPE][0] = 'Alox Job Suchmaske'; |
|
23 |
-$GLOBALS['TL_LANG']['FMD'][JobSearchModuleController::TYPE][1] = 'Gibt eine Suchmaske aus, die auf eine Joblistenseite verlinkt werden kann.'; |
|
24 |
-$GLOBALS['TL_LANG']['FMD'][JobReaderModuleController::TYPE][0] = 'Alox Job Reader'; |
|
25 |
-$GLOBALS['TL_LANG']['FMD'][JobReaderModuleController::TYPE][1] = 'Gibt Details zu einem Stellenangebot aus.'; |
... | ... |
@@ -59,8 +59,13 @@ class Softgarden |
59 | 59 |
return [$this->getClientId(),'']; |
60 | 60 |
} |
61 | 61 |
|
62 |
- protected function sendRequest(string $relEndpoint, array $options, string $method = 'GET') |
|
62 |
+ protected function sendRequest(string $relEndpoint, array $options, string $method = 'GET',bool $blnFQDNEndpoint=false) |
|
63 | 63 |
{ |
64 |
+ if ($blnFQDNEndpoint) |
|
65 |
+ { |
|
66 |
+ return $this->httpClient->request($method,$relEndpoint,$options); |
|
67 |
+ } |
|
68 |
+ |
|
64 | 69 |
$relEndpoint = '/' . ltrim($relEndpoint,'/'); |
65 | 70 |
|
66 | 71 |
return $this->httpClient->request($method,$this->getApiDomain().$relEndpoint,$options); |
... | ... |
@@ -68,6 +73,7 @@ class Softgarden |
68 | 73 |
|
69 | 74 |
public function testApiRequest() |
70 | 75 |
{ |
76 |
+ // bewerber@dacore.api / Aebekai2ail4coum |
|
71 | 77 |
$options = [ |
72 | 78 |
'auth_basic' => $this->getBasicAuthorization(), |
73 | 79 |
'headers' => ['Content-Type: application/json'] |
... | ... |
@@ -85,6 +91,117 @@ class Softgarden |
85 | 91 |
return null; |
86 | 92 |
} |
87 | 93 |
|
94 |
+ public function hasApplied(int $jobId, $token_type, $access_token) |
|
95 |
+ { |
|
96 |
+ // bewerber@dacore.api / Aebekai2ail4coum |
|
97 |
+ $options = [ |
|
98 |
+ 'headers' => [ |
|
99 |
+ 'Authorization: ' . $token_type . ' ' . $access_token |
|
100 |
+ ] |
|
101 |
+ ]; |
|
102 |
+ |
|
103 |
+ $response = $this->sendRequest('jobs/' . $jobId . '/applied',$options); |
|
104 |
+ |
|
105 |
+ if ($response->getStatusCode() == 200) |
|
106 |
+ { |
|
107 |
+ $content = $response->getContent(); |
|
108 |
+ |
|
109 |
+ return $content == 'true'; |
|
110 |
+ } |
|
111 |
+ |
|
112 |
+ return false; |
|
113 |
+ } |
|
114 |
+ |
|
115 |
+ public function getApplicationId(int $jobId, $token_type, $access_token) |
|
116 |
+ { |
|
117 |
+ // bewerber@dacore.api / Aebekai2ail4coum |
|
118 |
+ $options = [ |
|
119 |
+ 'headers' => [ |
|
120 |
+ 'Authorization: ' . $token_type . ' ' . $access_token, |
|
121 |
+ 'Content-Type: application/json' |
|
122 |
+ ] |
|
123 |
+ ]; |
|
124 |
+ |
|
125 |
+ $response = $this->sendRequest('jobs/' . $jobId . '/application',$options, 'POST'); |
|
126 |
+ |
|
127 |
+ if ($response->getStatusCode() == 200) |
|
128 |
+ { |
|
129 |
+ $content = $response->getContent(); |
|
130 |
+ |
|
131 |
+ return $content; |
|
132 |
+ } |
|
133 |
+ |
|
134 |
+ return null; |
|
135 |
+ } |
|
136 |
+ |
|
137 |
+ public function startApplication(int $jobId, $token_type, $access_token) |
|
138 |
+ { |
|
139 |
+ // bewerber@dacore.api / Aebekai2ail4coum |
|
140 |
+ $options = [ |
|
141 |
+ 'headers' => [ |
|
142 |
+ 'Authorization: ' . $token_type . ' ' . $access_token, |
|
143 |
+ 'Content-Type: application/json' |
|
144 |
+ ] |
|
145 |
+ ]; |
|
146 |
+ |
|
147 |
+ $response = $this->sendRequest('applications?jobId='.$jobId,$options, 'POST'); |
|
148 |
+ |
|
149 |
+ if ($response->getStatusCode() == 200) |
|
150 |
+ { |
|
151 |
+ $content = $response->getContent(); |
|
152 |
+ |
|
153 |
+ return $content; |
|
154 |
+ } |
|
155 |
+ |
|
156 |
+ return null; |
|
157 |
+ } |
|
158 |
+ |
|
159 |
+ public function getApplication($applicationId, $token_type, $access_token) |
|
160 |
+ { |
|
161 |
+ // bewerber@dacore.api / Aebekai2ail4coum |
|
162 |
+ $options = [ |
|
163 |
+ 'headers' => [ |
|
164 |
+ 'Authorization: ' . $token_type . ' ' . $access_token, |
|
165 |
+ 'Content-Type: application/json' |
|
166 |
+ ] |
|
167 |
+ ]; |
|
168 |
+ |
|
169 |
+ $response = $this->sendRequest('applications/' . $applicationId . '?fields=*',$options); |
|
170 |
+ |
|
171 |
+ if ($response->getStatusCode() == 200) |
|
172 |
+ { |
|
173 |
+ $content = json_decode($response->getContent()); |
|
174 |
+ |
|
175 |
+ return count($content) < 2 ? array_shift($content) : $content; |
|
176 |
+ } |
|
177 |
+ |
|
178 |
+ return null; |
|
179 |
+ } |
|
180 |
+ |
|
181 |
+ public function getUserAccessToken($username, $password) |
|
182 |
+ { |
|
183 |
+ // bewerber@dacore.api / Aebekai2ail4coum |
|
184 |
+ $options = [ |
|
185 |
+ 'auth_basic' => $this->getBasicAuthorization(), |
|
186 |
+ 'body' => [ |
|
187 |
+ 'grant_type' => 'password', |
|
188 |
+ 'username' => $username, |
|
189 |
+ 'password' => $password |
|
190 |
+ ] |
|
191 |
+ ]; |
|
192 |
+ |
|
193 |
+ $response = $this->sendRequest('https://api.softgarden.io/api/rest/oauth/frontend/token',$options,'POST',true); |
|
194 |
+ |
|
195 |
+ if ($response->getStatusCode() == 200) |
|
196 |
+ { |
|
197 |
+ $content = $response->getContent(); |
|
198 |
+ |
|
199 |
+ return json_decode($content); |
|
200 |
+ } |
|
201 |
+ |
|
202 |
+ return null; |
|
203 |
+ } |
|
204 |
+ |
|
88 | 205 |
public function getStellenFiltered(array $params=[]): ?StellenModel |
89 | 206 |
{ |
90 | 207 |
$options = [ |
... | ... |
@@ -42,6 +42,30 @@ class JobApplicationFormController extends AbstractFrontendModuleController |
42 | 42 |
|
43 | 43 |
protected function getResponse(Template $template, ModuleModel $model, Request $request): ?Response |
44 | 44 |
{ |
45 |
+ if (($userToken = $this->api->getUserAccessToken('bewerber@dacore.api','Aebekai2ail4coum')) === null) |
|
46 |
+ { |
|
47 |
+ return new Response(); |
|
48 |
+ } |
|
49 |
+ |
|
50 |
+ if (!$this->api->hasApplied(32630195,$userToken->token_type,$userToken->access_token)) |
|
51 |
+ { |
|
52 |
+ $applicationId = $this->api->startApplication(32630195,$userToken->token_type,$userToken->access_token); |
|
53 |
+ } else { |
|
54 |
+ $applicationId = $this->api->getApplicationId(32630195,$userToken->token_type,$userToken->access_token); |
|
55 |
+ } |
|
56 |
+ |
|
57 |
+ $application = $this->api->getApplication($applicationId,$userToken->token_type,$userToken->access_token); |
|
58 |
+ |
|
59 |
+ if ($application !== null && isset($application->applicationEditable) && !$application->applicationEditable) |
|
60 |
+ { |
|
61 |
+ return new Response('Already applied'); |
|
62 |
+ } |
|
63 |
+ elseif ($application === null || !isset($application->applicationId)) |
|
64 |
+ { |
|
65 |
+ return new Response('Bewerbung derzeit nicht möglich'); |
|
66 |
+ } |
|
67 |
+ |
|
68 |
+ |
|
45 | 69 |
$strFormId = 'jobapplication-form'; |
46 | 70 |
|
47 | 71 |
$Form = new Form($strFormId,'POST', function($objHaste) { |