public function getGroups() { if (!isset($this->groups)) { try { $this->groups = $this->groupsService->getAllSportGroups(); } catch (Exceptions\DataErrorException $ex) { $this->logError($ex->getMessage); throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } } return $this->groups; }
public function groupInit() { $group = null; $abbr = $this->groupValues["abbr"]; try { $group = $this->groupService->getSportGroupAbbr($abbr); } catch (Exceptions\NoResultException $ex) { $this->logger->addDebug($ex); } if ($group === null) { $this->logger->addInfo("System module initializer - Sport Group - no group with abbr {$abbr} found. New one is gonna be created."); $g = new SportGroup((array) $this->getGroupValues()); $this->groupService->createSportGroup($g); } }
public function positionsInit() { $pos = null; try { $user = $this->userService->getUserEmail($this->getDefaultUserEmail()); $role = $this->roleService->getRoleName("admin"); $group = $this->groupService->getSportGroupAbbr("root"); } catch (Exceptions\NoResultException $ex) { return null; } try { $pos = $this->positionService->getUniquePosition($user, $group, $role); } catch (Exceptions\NoResultException $ex) { $this->logger->addDebug($ex->getMessage()); } if ($pos === null) { $this->logger->addInfo("Security module initializer - Position - no position with user {$user}, role {$role} and group {$group} found. New one is gonna be created."); $pos = new Position(); $pos->setGroup($group); $pos->setOwner($user); $pos->setRole($role); $pos->setName("Webmaster"); $pos->setComment("System created"); $this->positionService->createPosition($pos); } }
/** * @Secured(resource="showThread") */ public function actionShowThread($id, $abbr) { $thread = $sg = null; try { if (is_numeric($abbr)) { $sg = $this->sportGroupService->getSportGroup($abbr); } elseif (is_string($abbr)) { $sg = $this->sportGroupService->getSportGroupAbbr($abbr); } if (is_numeric($id)) { $thread = $this->forumService->getForumThread($id); } elseif (is_string($id)) { $thread = $this->forumService->getForumThreadAlias($id); } } catch (Exceptions\DataErrorException $ex) { $this->handleDataLoad($id, "default", $ex); } $type = $sg->getSportType(); if ($type !== null) { $type = " ({$type->getName()})"; } else { $type = ""; } $groupLabel = $sg->getName() . $type; $this->template->groupLabel = $groupLabel; $this->template->abbr = $sg->getAbbr(); $forum = $thread->getForum(); $this->template->forumTitle = $forum->getTitle(); $this->template->forumAlias = $forum->getAlias(); $this->template->thread = $thread; $this->setEntity($thread); }
/** * @Secured(resource="default") */ public function actionDefault($abbr = self::ROOT_GROUP) { $data = null; try { if (is_string($abbr)) { $sg = $this->sportGroupService->getSportGroupAbbr($abbr); } elseif (is_numeric($abbr)) { $sg = $this->sportGroupService->getSportGroup($abbr); } $data = $this->eventService->getEvents($sg); } catch (Exceptions\DataErrorException $ex) { $this->handleDataLoad($abbr, "default", $ex); } $this->template->data = $data; $this->template->commentable = true; }
private function prepareTreeData() { $res = []; try { $sportTypes = $this->sportTypeService->getAllSportTypes(true, true); $groups = $this->sportGroupService->getAllSportGroups(null, true); $rootArray = array_filter($groups, function ($e) { if ($e->getParent() == null) { return true; } return false; }); if (!empty($rootArray)) { $rootGroup = $rootArray[0]; foreach ($sportTypes as $type) { $typeGroups = array_filter($groups, function ($e) use($type) { if ($e->getSportType() != null && $e->getSportType()->getId() == $type->getId()) { return true; } return false; }); array_push($res, [PMC::TYPE_ID => $type, PMC::GROUPS_ID => $typeGroups, PMC::ROOT_ID => $rootGroup]); } } } catch (Exceptions\DataErrorException $ex) { $this->logError($ex); throw new Exceptions\InvalidStateException("COMPONENT PublicMenu could not be inicialized - {$ex->getMessage()}", $ex->getCode(), $ex->getPrevious()); } return $res; }
protected function createComponentWebProfileMenu($name) { $c = new \App\Components\MenuControl($this, $name); $group = $data = null; $gid = $this->getParameter("gid"); try { if (is_numeric($gid)) { $group = $this->sportGroupService->getSportGroup($gid); } else { $group = $this->sportGroupService->getSportGroupAbbr($gid); } $raw = $this->positionService->getPositionsWithinGroup($group); $data = array_filter($raw, function ($e) { if ($e->getRole()->getName() == $this->defaultPlayerRoleName) { return true; } return false; }); } catch (Exceptions\DataErrorException $ex) { $this->handleDataLoad($gid, "default", $ex); } $c->setLabel("{$group->getName()} ({$group->getSportType()->getName()})"); $user = $this->getEntity(); foreach ($data as $p) { $owner = $p->getOwner(); $node = $c->addNode("{$owner->getName()} {$owner->getSurName()}", ":Users:Public:showWebProfile"); if ($owner->getId() == $user->getId()) { $c->setCurrentNode($node); } } return $c; }
/** * Action for displaying list of Articles within given group. * @param string $abbr */ public function actionDefault($abbr = self::ROOT_GROUP) { $data = null; $sg = null; try { if (is_string($abbr)) { $sg = $this->sportGroupService->getSportGroupAbbr($abbr); } elseif (is_numeric($abbr)) { $sg = $this->sportGroupService->getSportGroup($abbr); } $data = $this->articleService->getArticles($sg); } catch (Exceptions\DataErrorException $ex) { $this->handleDataLoad($abbr, ":System:Homepage:default", $ex); } $this->template->data = $data; $this->template->abbr = $abbr; }
private function getSelectSportGroups() { try { if (!isset($this->selectGroups)) { $this->selectGroups = $this->groupService->getSelectApplicablegroups(); } } catch (Exceptions\DataErrorException $ex) { $this->handleDataLoad(null, self::LAST_CHANCE_REDIRECT, $ex); } return $this->selectGroups; }
private function preparePositionForm($name) { $form = new PositionForm($this, $name, $this->getTranslator()); $roles = $this->roleService->getSelectRoles(); $users = $this->userService->getSelectUsers(); $groups = $this->sportGroupService->getSelectAllSportGroups(); $form->setSportGroups($groups); $form->setRoles($roles); $form->setUsers($users); return $form; }
protected function createComponentContactsGroupsMenu($name) { $c = new \App\Components\MenuControl($this, $name); $c->setLabel("securityModule.public.contacts.groupsMenu"); $groups = $this->sportGroupService->getAllSportGroups(null, true); $gid = $this->getParameter("gid"); foreach ($groups as $g) { $id = null; if (is_numeric($gid)) { $id = $g->getId(); } else { $id = $g->getAbbr(); } $name = $g->getSportType() !== null ? "{$g->getName()} ({$g->getSportType()->getName()})" : "{$g->getName()}"; $node = $c->addNode($name, ":Security:Public:default", null, ["param" => $id]); if ($id == $gid || ($gid == self::ROOT_GROUP || $gid === null) && $id == self::ROOT_GROUP) { $c->setCurrentNode($node); } } return $c; }
private function prepareArticleForm($name) { $form = new ArticleForm($this, $name, $this->getTranslator()); try { $users = $this->usersService->getSelectUsers(); $form->setUsers($users); $sGroups = $this->sportGroupService->getSelectAllSportGroups(); $form->setSportGroups($sGroups); } catch (Exceptions\DataErrorException $ex) { $this->handleDataLoad(null, "default", $ex); } return $form; }
public function prepareEventForm($name) { $form = new EventForm($this, $name, $this->getTranslator()); try { $groups = $this->sportGroupsService->getSelectAllSportGroups(); $form->setSportGroups($groups); $users = $this->userService->getSelectUsers(); $form->setUsers($users); } catch (\Exception $ex) { $this->handleDataLoad(null, "default", $ex); } return $form; }
private function prepareStaticPageForm($name, $selfId = null) { $form = new StaticPageForm($this, $name, $this->getTranslator()); try { $sportGroups = $this->sportGroupService->getSelectAllSportGroups($selfId); $form->setSportGroups($sportGroups); $users = $this->userService->getSelectUsers(); $form->setUsers($users); $pages = $this->staticPageService->getSelectStaticPages($selfId); $form->setPages($pages); } catch (Exceptions\DataErrorException $ex) { $this->flashMessage($ex->getMessage(), self::FM_ERROR); } return $form; }
private function taxSportGroupTypeHandle(MotivationTax $t) { if ($t == null) { throw new Exceptions\NullPointerException("Argument MotivationTax cannot be null"); } try { $group = $this->getMixId($t->getSportGroup()); $sportGroup = $this->sportGroupService->getSportGroup((int) $group, false); $t->setSportGroup($sportGroup); } catch (\Exception $ex) { $this->logError($ex->getMessage()); throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } return $t; }
private function posGroupTypeHandle(Position $p) { if ($p === null) { throw new Exceptions\NullPointerException("Argument Position was null"); } try { $group = null; $id = $this->getMixId($p->getGroup()); if ($id !== null) { $group = $this->sportGroupService->getSportGroup($id, false); } $p->setGroup($group); } catch (\Exception $e) { $this->logError($e); throw new Exceptions\DataErrorException($e->getMessage(), $e->getCode(), $e->getPrevious()); } return $p; }
private function sportGroupsTypeHandle(WallPost $wp) { if ($wp === null) { throw new Exceptions\NullPointerException("Argument event was null"); } try { $coll = new ArrayCollection(); foreach ($wp->getGroups() as $wpg) { $dbG = $this->sportGroupService->getSportGroup($wpg, false); if ($dbG !== null) { $coll->add($dbG); } } $wp->setGroups($coll); } catch (\Exception $ex) { $this->logError($ex->getMessage()); throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); } return $wp; }
protected function createComponentWallHistoryControl($name) { $c = new WallHistoryControl($this, $name); $data = $group = null; try { $abbr = $this->getParameter("abbr"); $gid = empty($abbr) ? self::ROOT_GROUP : $abbr; if (is_numeric($gid)) { $group = $this->sportGroupService->getSportGroup($gid); } else { $group = $this->sportGroupService->getSportGroupAbbr($gid); } $data = $this->wallService->getOldWallPosts($group); } catch (Exceptions\DataErrorException $ex) { $this->presenter->handleDataLoad(null, ":System:Default:clubRoot", $ex); } $c->setData($data); $c->setParam($gid); return $c; }
protected function createComponentStaticPagesGroupsMenu($name) { $c = new \App\Components\MenuControl($this, $name); $c->setLabel("systemModule.publicPages.groupsMenu"); $groups = $this->sportGroupService->getAllSportGroups(null, true); $currentAbbr = null; $e = $this->getEntity(); if ($this->getEntity() instanceof SportGroup) { $currentAbbr = $e->getAbbr(); } elseif ($e instanceof StaticPage) { $currentAbbr = $e->getGroup()->getAbbr(); } foreach ($groups as $g) { $abbr = $g->getAbbr(); //if (!$g->getStaticPages()->isEmpty()) { $node = $c->addNode($g->getName(), "showGroupPages", true, ["param" => $abbr]); if ($currentAbbr == $abbr) { $c->setCurrentNode($node); } //} } return $c; }