Exemplo n.º 1
0
 /**
  * @param DoctrineResourceEvent $e
  */
 public function fetchAll(DoctrineResourceEvent $e)
 {
     /** @var QueryBuilder $queryBuilder */
     $queryBuilder = $e->getQueryBuilder();
     $user = $this->getUser($e, $this->userService);
     $this->groupService->fetchUserGroupsApi($queryBuilder, $user);
 }
Exemplo n.º 2
0
 /**
  * @param  \Zend\ServiceManager\ServiceLocatorInterface $sl
  * @return \Secretary\Service\Group
  */
 public function createService(ServiceLocatorInterface $sl)
 {
     $service = new Group();
     /* @var \Doctrine\Orm\EntityManager $em */
     $em = $sl->get('doctrine.entitymanager.orm_default');
     $service->setEntityManager($em);
     return $service;
 }
Exemplo n.º 3
0
 /**
  * Remove member from group
  *
  * @return \Zend\View\Model\ViewModel
  */
 public function removeAction()
 {
     $userId = (int) $this->getRequest()->getQuery('user');
     if ($this->groupRecord->getOwner() != $this->identity->getId()) {
         return $this->redirect()->toRoute('secretary/group');
     }
     if (empty($userId) || $userId == $this->identity->getId()) {
         return $this->redirect()->toRoute('secretary/group', array('action' => 'members', 'id' => $this->groupRecord->getId()));
     }
     $membershipCheck = $this->groupService->checkGroupMembership($this->groupRecord->getId(), $userId);
     if (false === $membershipCheck) {
         return $this->redirect()->toRoute('secretary/group', array('action' => 'members', 'id' => $this->groupRecord->getId()));
     }
     // Delete User from Group / Delete Group
     try {
         $groupName = $this->groupRecord->getName();
         $userRecord = $this->userService->getUserById($userId);
         $this->noteService->deleteUserFromGroupNotes($userRecord, $this->groupRecord);
         $this->groupService->removeUserFromGroup($userRecord, $this->groupRecord);
         $this->flashMessenger()->addSuccessMessage(sprintf($this->translator->translate('User "%s" was successfully removed from group "%s"'), $userRecord->getDisplayName(), $groupName));
         return $this->redirect()->toRoute('secretary/group', array('action' => 'members', 'id' => $this->groupRecord->getId()));
     } catch (\Exception $e) {
         $this->flashMessenger()->addErrorMessage('An error occurred: ' . $e->getMessage());
         return $this->redirect()->toRoute('secretary/group', array('action' => 'members', 'id' => $this->groupRecord->getId()));
     }
 }
Exemplo n.º 4
0
 /**
  * Return group members in JSON
  *
  * @return \Zend\View\Model\ViewModel
  */
 public function groupAction()
 {
     $jsonModel = new JsonModel(array('success' => false));
     $groupId = $this->getRequest()->getPost('group');
     if (empty($groupId) || !is_numeric($groupId)) {
         return $jsonModel;
     }
     $groupMembers = $this->groupService->fetchGroupMembers($groupId, $this->identity->getId());
     $jsonModel->setVariable('success', true);
     $jsonModel->setVariable('groupMembers', $groupMembers);
     return $jsonModel;
 }