From 498410aeb03da5ea9f2e295f8227ba01c1ca26f6 Mon Sep 17 00:00:00 2001 From: Daniel Berthereau Date: Mon, 8 Jan 2018 00:00:00 +0100 Subject: [PATCH] Listed site permissions in user page. --- .../Api/Representation/SiteRepresentation.php | 6 +++-- .../Api/Representation/UserRepresentation.php | 15 +++++++++++++ application/view/omeka/admin/user/show.phtml | 22 +++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/application/src/Api/Representation/SiteRepresentation.php b/application/src/Api/Representation/SiteRepresentation.php index 88a26cb5d9..643b1ed9d3 100644 --- a/application/src/Api/Representation/SiteRepresentation.php +++ b/application/src/Api/Representation/SiteRepresentation.php @@ -165,9 +165,10 @@ public function notLinkedPages() public function sitePermissions() { $sitePermissions = []; + $services = $this->getServiceLocator(); foreach ($this->resource->getSitePermissions() as $sitePermission) { $sitePermissions[] = new SitePermissionRepresentation( - $sitePermission, $this->getServiceLocator()); + $sitePermission, $services); } return $sitePermissions; } @@ -180,8 +181,9 @@ public function sitePermissions() public function siteItemSets() { $itemSets = []; + $services = $this->getServiceLocator(); foreach ($this->resource->getSiteItemSets() as $itemSet) { - $itemSets[] = new SiteItemSetRepresentation($itemSet, $this->getServiceLocator()); + $itemSets[] = new SiteItemSetRepresentation($itemSet, $services); } return $itemSets; } diff --git a/application/src/Api/Representation/UserRepresentation.php b/application/src/Api/Representation/UserRepresentation.php index c3c1b2ae6b..f43dac69b5 100644 --- a/application/src/Api/Representation/UserRepresentation.php +++ b/application/src/Api/Representation/UserRepresentation.php @@ -69,6 +69,21 @@ public function sites() return $sites; } + public function sitePermissions() + { + $sitePermissions = []; + $services = $this->getServiceLocator(); + $entityManager = $services->get('Omeka\EntityManager'); + $sitePermissionRepository = $entityManager->getRepository(\Omeka\Entity\SitePermission::class); + $sitePermissionEntities = $sitePermissionRepository + ->findBy(['user' => $this->id()]); + foreach ($sitePermissionEntities as $sitePermissionEntity) { + $sitePermissions[] = new SitePermissionRepresentation( + $sitePermissionEntity, $services); + } + return $sitePermissions; + } + public function displayRole() { $roleIndex = $this->resource->getRole(); diff --git a/application/view/omeka/admin/user/show.phtml b/application/view/omeka/admin/user/show.phtml index 777ee992ac..4c05a85ff3 100644 --- a/application/view/omeka/admin/user/show.phtml +++ b/application/view/omeka/admin/user/show.phtml @@ -62,4 +62,26 @@ +
+

translate('Site permissions'); ?>

+ sitePermissions(); ?> + +
+ translate('None')); ?> +
+ +
+
    + +
  • + site(); ?> + link($site->title(), 'users'), + $escape($this->translate($sitePermission->role()))); ?> +
  • + +
+
+ +
trigger('view.show.after'); ?>