Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
18 / 18 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| PickupMail | |
100.00% |
18 / 18 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
| readResponse | |
100.00% |
18 / 18 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * |
| 5 | * @package Zmsadmin |
| 6 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 7 | * |
| 8 | */ |
| 9 | |
| 10 | namespace BO\Zmsadmin; |
| 11 | |
| 12 | use BO\Mellon\Validator; |
| 13 | use BO\Slim\Render; |
| 14 | use BO\Zmsentities\Mail as Entity; |
| 15 | |
| 16 | /** |
| 17 | * Delete a process |
| 18 | */ |
| 19 | class PickupMail extends BaseController |
| 20 | { |
| 21 | /** |
| 22 | * @SuppressWarnings(Param) |
| 23 | * @return String |
| 24 | */ |
| 25 | public function readResponse( |
| 26 | \Psr\Http\Message\RequestInterface $request, |
| 27 | \Psr\Http\Message\ResponseInterface $response, |
| 28 | array $args |
| 29 | ) { |
| 30 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 1])->getEntity(); |
| 31 | $validator = $request->getAttribute('validator'); |
| 32 | $processId = $validator->getParameter('selectedprocess')->isNumber()->getValue(); |
| 33 | $process = \App::$http->readGetResult('/process/' . $processId . '/', ['resolveReferences' => 1])->getEntity(); |
| 34 | // disabled 2021-01-20 by TK because in ZMS1 it is allowed to send pickup mailings |
| 35 | // to processes from another scope in department |
| 36 | //$workstation->validateProcessScopeAccess($workstation->getScopeList(), $process); |
| 37 | $config = \App::$http->readGetResult('/config/')->getEntity(); |
| 38 | $department = \App::$http->readGetResult('/scope/' . $workstation->scope['id'] . '/department/')->getEntity(); |
| 39 | |
| 40 | if (! $process->scope->hasEmailFrom()) { |
| 41 | throw new \BO\Zmsadmin\Exception\MailFromMissing(); |
| 42 | } |
| 43 | $mail = (new Entity())->toResolvedEntity($process, $config, 'pickup'); |
| 44 | $mail = \App::$http->readPostResult('/mails/', $mail->withDepartment($department))->getEntity(); |
| 45 | |
| 46 | return \BO\Slim\Render::withHtml( |
| 47 | $response, |
| 48 | 'block/pickup/mailSent.twig', |
| 49 | array( |
| 50 | 'process' => $process, |
| 51 | 'mail' => $mail |
| 52 | ) |
| 53 | ); |
| 54 | } |
| 55 | } |