Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 34 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| UseraccountByRole | |
0.00% |
0 / 34 |
|
0.00% |
0 / 1 |
56 | |
0.00% |
0 / 1 |
| readResponse | |
0.00% |
0 / 34 |
|
0.00% |
0 / 1 |
56 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @package Zmsadmin |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 6 | **/ |
| 7 | |
| 8 | namespace BO\Zmsadmin; |
| 9 | |
| 10 | use BO\Zmsentities\Collection\UseraccountList as Collection; |
| 11 | use Psr\Http\Message\RequestInterface; |
| 12 | use Psr\Http\Message\ResponseInterface; |
| 13 | |
| 14 | class UseraccountByRole extends BaseController |
| 15 | { |
| 16 | /** |
| 17 | * @SuppressWarnings(Param) |
| 18 | * @return ResponseInterface |
| 19 | */ |
| 20 | public function readResponse( |
| 21 | RequestInterface $request, |
| 22 | ResponseInterface $response, |
| 23 | array $args |
| 24 | ) { |
| 25 | $roleLevel = $args['level']; |
| 26 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 2])->getEntity(); |
| 27 | $success = $request->getAttribute('validator')->getParameter('success')->isString()->getValue(); |
| 28 | $ownerList = \App::$http->readGetResult('/owner/', array('resolveReferences' => 2))->getCollection(); |
| 29 | |
| 30 | $useraccountList = new Collection(); |
| 31 | if ($workstation->hasSuperUseraccount()) { |
| 32 | try { |
| 33 | $useraccountList = \App::$http->readGetResult("/role/$roleLevel/useraccount/")->getCollection(); |
| 34 | } catch (\Exception $e) { |
| 35 | false; |
| 36 | } |
| 37 | } else { |
| 38 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 2])->getEntity(); |
| 39 | $departmentList = $workstation->getUseraccount()->getDepartmentList(); |
| 40 | |
| 41 | foreach ($departmentList as $accountDepartment) { |
| 42 | try { |
| 43 | $departmentUseraccountList = \App::$http |
| 44 | ->readGetResult("/role/$roleLevel/department/$accountDepartment->id/useraccount/") |
| 45 | ->getCollection(); |
| 46 | } catch (\Exception $e) { |
| 47 | continue; |
| 48 | } |
| 49 | |
| 50 | if ($departmentUseraccountList) { |
| 51 | $useraccountList = $useraccountList->addList($departmentUseraccountList)->withoutDublicates(); |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | return \BO\Slim\Render::withHtml( |
| 57 | $response, |
| 58 | 'page/useraccount.twig', |
| 59 | array( |
| 60 | 'title' => 'Nutzer', |
| 61 | 'roleLevel' => $roleLevel, |
| 62 | 'menuActive' => 'useraccount', |
| 63 | 'workstation' => $workstation, |
| 64 | 'useraccountListByRole' => ($useraccountList) ? |
| 65 | $useraccountList->sortByCustomStringKey('id') : |
| 66 | new Collection(), |
| 67 | 'ownerlist' => $ownerList, |
| 68 | 'success' => $success, |
| 69 | ) |
| 70 | ); |
| 71 | } |
| 72 | } |