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;
 }
Example #2
0
 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);
     }
 }
Example #3
0
 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);
     }
 }
Example #4
0
 /**
  * @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);
 }
Example #5
0
 /**
  * @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;
 }
Example #7
0
 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;
 }
Example #8
0
 /**
  * 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;
 }
Example #9
0
 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;
 }
Example #10
0
 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;
 }
Example #11
0
 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;
 }
Example #12
0
 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;
 }
Example #13
0
 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;
 }
Example #14
0
 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;
 }
Example #15
0
 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;
 }
Example #16
0
 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;
 }
Example #17
0
 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;
 }
Example #18
0
 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;
 }
Example #19
0
 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;
 }