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 Oct 27, 2019
1 parent 962901b commit 2cf28f3
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 @@ -180,9 +180,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 @@ -195,8 +196,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 @@ -63,6 +63,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 @@ -63,4 +63,26 @@ $this->htmlElement('body')->appendAttribute('class', 'users show');
</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 2cf28f3

Please sign in to comment.