Beispiel #1
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()));
     }
 }
Beispiel #2
0
 /**
  * @param  Entity\Group $group
  * @param  string      $groupname
  * @return Entity\Group
  */
 public function updateGroup(Entity\Group $group, $groupname)
 {
     $group->setName($groupname);
     $this->em->persist($group);
     $this->em->flush();
     return $group;
 }
Beispiel #3
0
 /**
  * @param Entity\User $user
  * @param Entity\Group $group
  * @return void
  */
 public function deleteUserFromGroupNotes(Entity\User $user, Entity\Group $group)
 {
     $groupNotesQb = $this->getNoteRepository()->fetchGroupNotes($user->getId(), $group->getId());
     $groupNotesQb->addOrderBy('n.title', 'ASC');
     $groupNotes = $groupNotesQb->getQuery()->getResult(AbstractQuery::HYDRATE_OBJECT);
     if (empty($groupNotes)) {
         return;
     }
     $groupOwner = $this->getUserRepository()->find($group->getOwner());
     foreach ($groupNotes as $note) {
         $this->getUser2NoteRepository()->checkNoteOwnershipForLeavingUser($note, $user->getId(), $groupOwner->getId());
     }
     return;
 }
 /**
  * {@inheritDoc}
  */
 public function getInputFilter()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getInputFilter', array());
     return parent::getInputFilter();
 }