Skip to content

Commit

Permalink
Listed site permissions in user page.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-KM committed Mar 22, 2018
1 parent 1c67e9a commit 126375c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
6 changes: 4 additions & 2 deletions application/src/Api/Representation/SiteRepresentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
15 changes: 15 additions & 0 deletions application/src/Api/Representation/UserRepresentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
22 changes: 22 additions & 0 deletions application/view/omeka/admin/user/show.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,26 @@
</div>
<?php endif; ?>
</div>
<div class="property site-permissions">
<h4><?php echo $this->translate('Site permissions'); ?></h4>
<?php $sitePermissions = $user->sitePermissions(); ?>
<?php if (empty($sitePermissions)): ?>
<div class="value no-value">
<?php echo $escape($this->translate('None')); ?>
</div>
<?php else: ?>
<div class="value">
<ul style="margin: 0;">
<?php foreach ($sitePermissions as $sitePermission): ?>
<li>
<?php $site = $sitePermission->site(); ?>
<?php echo sprintf('%s (%s)',
$site->link($site->title(), 'users'),
$escape($this->translate($sitePermission->role()))); ?>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
</div>
<?php $this->trigger('view.show.after'); ?>

0 comments on commit 126375c

Please sign in to comment.