Commit a1f5d49e authored by Cottser's avatar Cottser Committed by Youri van Koppen
Browse files

Issue #3255551 by Cottser, irinaz, MegaChriz: Allow users with 'access feed...

Issue #3255551 by Cottser, irinaz, MegaChriz: Allow users with 'access feed overview' and without 'administer feeds' to see the feed type name on the feed listing (/admin/content/feed).
parent da27e8ad
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -307,7 +307,7 @@ display:
          click_sort_column: target_id
          type: entity_reference_label
          settings:
            link: true
            link: false
          group_column: target_id
          group_columns: {  }
          group_rows: true
+12 −3
Original line number Diff line number Diff line
@@ -20,17 +20,26 @@ class FeedTypeAccessControlHandler extends EntityAccessControlHandler {
   * {@inheritdoc}
   */
  protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
    if ($operation === 'delete') {
    switch ($operation) {
      case 'view':
        $has_perm = $account->hasPermission('administer feeds') || $account->hasPermission("view {$entity->id()} feeds");
        return AccessResult::allowedIf($has_perm);

        break;

      case 'delete':
        if ($entity->isNew()) {
          return AccessResult::forbidden()->addCacheableDependency($entity);
        }

        // The delete operation is not cacheable since the locked status can
        // change in the background.
        return AccessResult::allowedIf($account->hasPermission('administer feeds') && !$entity->isLocked())->addCacheableDependency(FALSE);
    }

        break;

      default:
        return parent::checkAccess($entity, $operation, $account);
    }
  }

}
+4 −0
Original line number Diff line number Diff line
@@ -42,6 +42,9 @@ class FeedTypeAccessControlHandlerTest extends FeedsUnitTestCase {
   * @covers ::checkAccess
   */
  public function testCheckAccess() {
    $this->entity->id()->willReturn('feed_type');
    $this->account->hasPermission('view feed_type feeds')->willReturn(TRUE);

    $method = $this->getMethod(FeedTypeAccessControlHandler::class, 'checkAccess');
    $result = $method->invokeArgs($this->controller, [
      $this->entity->reveal(),
@@ -78,6 +81,7 @@ class FeedTypeAccessControlHandlerTest extends FeedsUnitTestCase {
    ]);
    $this->assertFalse($result->isAllowed());

    $this->account->hasPermission('view feed_type feeds')->willReturn(FALSE);
    $result = $method->invokeArgs($this->controller, [
      $this->entity->reveal(),
      'view',