You are here

public function UserSectionStorage::getPotentialEditors in Workbench Access 8

Gets a list of editors who may be assigned to a section.

This method does not remove editors already assigned to a section.

Parameters

string $id: The section id.

Return value

array An array of user ids.

Overrides UserSectionStorageInterface::getPotentialEditors

File

src/UserSectionStorage.php, line 178

Class

UserSectionStorage
Defines a class for storing and retrieving sections assigned to a user.

Namespace

Drupal\workbench_access

Code

public function getPotentialEditors($id) {

  // Get all role IDs that have the configured permissions.
  $roles = user_role_names(FALSE, 'use workbench access');

  // user_role_names() returns an array with the role IDs as keys, so take
  // the array keys and merge them with previously found role IDs.
  $rids = array_keys($roles);
  if (empty($rids)) {
    return [];
  }
  $query = $this
    ->userStorage()
    ->getQuery();
  $query
    ->condition('status', 1)
    ->sort('name');
  if (!in_array(AccountInterface::AUTHENTICATED_ROLE, $rids, TRUE)) {
    $query
      ->condition('roles', $rids, 'IN');
  }
  $users = $query
    ->execute();
  return $users;
}