public function join($params) { if (empty($params['groupId'])) { throw new Redirect404Exception(); } if (!OW::getUser()->isAuthenticated()) { throw new AuthenticateException(); } $groupId = (int) $params['groupId']; $userId = OW::getUser()->getId(); $groupDto = $this->service->findGroupById($groupId); if ($groupDto === null) { throw new Redirect404Exception(); } if (!$this->service->isCurrentUserCanView($groupDto->userId)) { throw new Redirect403Exception(); } $invite = $this->service->findInvite($groupDto->id, $userId); if ($invite !== null) { $this->service->markInviteAsViewed($groupDto->id, $userId); } else { if ($groupDto->whoCanView == GROUPS_BOL_Service::WCV_INVITE) { $this->redirect(OW::getRouter()->urlForRoute('groups-private-group', array('groupId' => $groupDto->id))); } } GROUPS_BOL_Service::getInstance()->addUser($groupId, $userId); $redirectUrl = OW::getRouter()->urlForRoute('groups-view', array('groupId' => $groupId)); OW::getFeedback()->info(OW::getLanguage()->text('groups', 'join_complete_message')); $this->redirect($redirectUrl); }