Exemplo n.º 1
0
 /**
  * @param Group  $group
  * @param string $filename
  */
 public function exportGroupMembers(Group $group, $filename)
 {
     $handle = fopen($filename, 'w+');
     fputcsv($handle, ['Role', 'Id', 'Login name', 'First name', 'Last name', 'Email'], ';');
     $memberships = $this->membershipManager->findGroupMemberships($group->getId(), null, 0, 9999);
     foreach ($memberships as $membership) {
         $user = $membership->getUser();
         fputcsv($handle, [$membership->getRole(), $user->getId(), $user->getLoginName(), $user->getFirstName(), $user->getLastName(), $user->getEmail()], ';');
     }
     fclose($handle);
 }
Exemplo n.º 2
0
 /**
  * @inheritdoc
  *
  * @param Group $subject
  */
 protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
 {
     /** @var User $user */
     $user = $token->getUser();
     if (!$user instanceof User) {
         return false;
     }
     if ($subject->getOwnerId() == $user->getId()) {
         return true;
     }
     $membership = $this->membershipManager->findUserMembershipOfGroup($subject->getId(), $user->getId());
     if (!$membership) {
         return false;
     }
     if ($attribute === 'EDIT' && $membership->getRole() === Membership::ROLE_ADMIN) {
         return true;
     }
     return false;
 }