/**
  * Returns an array with all roles of a user's accounts, including parent roles, the "Everybody" role and the
  * "AuthenticatedUser" role, assuming that the user is logged in.
  *
  * @param User $user The user
  * @return array
  */
 protected function getAllRoles(User $user)
 {
     $roles = array('TYPO3.Flow:Everybody' => $this->policyService->getRole('TYPO3.Flow:Everybody'), 'TYPO3.Flow:AuthenticatedUser' => $this->policyService->getRole('TYPO3.Flow:AuthenticatedUser'));
     /** @var Account $account */
     foreach ($user->getAccounts() as $account) {
         $accountRoles = $account->getRoles();
         /** @var $currentRole Role */
         foreach ($accountRoles as $currentRole) {
             if (!in_array($currentRole, $roles)) {
                 $roles[$currentRole->getIdentifier()] = $currentRole;
             }
             /** @var $currentParentRole Role */
             foreach ($currentRole->getAllParentRoles() as $currentParentRole) {
                 if (!in_array($currentParentRole, $roles)) {
                     $roles[$currentParentRole->getIdentifier()] = $currentParentRole;
                 }
             }
         }
     }
     return $roles;
 }
 /**
  * Prepares a table row for output with data of the given User
  *
  * @param User $user The user
  * @return array
  */
 protected function getTableRowForUser(User $user)
 {
     $roleNames = array();
     $accountIdentifiers = array();
     foreach ($user->getAccounts() as $account) {
         /** @var Account $account */
         $authenticationProviderName = $account->getAuthenticationProviderName();
         if ($authenticationProviderName !== $this->userService->getDefaultAuthenticationProviderName()) {
             $authenticationProviderLabel = ' (' . (isset($this->authenticationProviderSettings[$authenticationProviderName]['label']) ? $this->authenticationProviderSettings[$authenticationProviderName]['label'] : $authenticationProviderName) . ')';
         } else {
             $authenticationProviderLabel = '';
         }
         $accountIdentifiers[] = $account->getAccountIdentifier() . $authenticationProviderLabel;
         foreach ($account->getRoles() as $role) {
             /** @var Role $role */
             $roleNames[] = $role->getIdentifier();
         }
     }
     return array($user->getName()->getFullName(), $user->getPrimaryElectronicAddress(), implode(', ', $accountIdentifiers), implode(', ', $roleNames), $user->isActive() ? 'yes' : 'no');
 }
 /**
  * Deactivates the given user
  *
  * @param User $user The user to deactivate
  * @return void
  * @api
  */
 public function deactivateUser(User $user)
 {
     foreach ($user->getAccounts() as $account) {
         /** @var Account $account */
         $account->setExpirationDate($this->now);
         $this->accountRepository->update($account);
     }
     $this->emitUserDeactivated($user);
 }