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