Example #1
0
 public function makeTournament()
 {
     $host = new Host();
     $host->setName("Test host");
     //        $host->setHostplan(new HostPlan());
     $tournament = new Tournament();
     $tournament->setName("Test tournament");
     $tournament->setDescription("Test edition of a tournament");
     $tournament->setEdition("2015");
     $tournament->setKey("TST2015");
     $tournament->setHost($host);
     $host->getTournaments()->add($tournament);
     $editor = new User();
     $editor->setUsername("test");
     $editor->setName("Test user");
     $editor->setPassword("");
     $editor->setEmail("*****@*****.**");
     $editor->addRole(User::ROLE_EDITOR_ADMIN);
     $editor->setEnabled(true);
     $editor->setHost($host);
     $host->getUsers()->add($editor);
     $this->em->persist($host);
     $this->em->flush();
     return $tournament;
 }
Example #2
0
 /**
  * Verify that user is admin or an editor allowed to access the host specified by hostid.
  * This function does not ensure that user->pid is referring to a valid host - if user is an admin.
  * @param User $user
  * @param Host $host
  * @throws ValidationException
  */
 public function validateEditorAdminUser(User $user, Host $host)
 {
     // If user is admin anything is allowed...
     if (!$this->isAdminUser($user)) {
         // Since this is not the admin - validate for editor
         if (!$user->isEditor()) {
             // Controller is called by club user user
             throw new ValidationException("NOTEDITORADMIN", "user="******"NOTEDITORADMIN", "user="******", hostid=" . $host->getId());
         }
     }
 }
 private function checkForm($form, Host $host)
 {
     if ($form->isValid()) {
         if ($host->getName() == null || trim($host->getName()) == '') {
             $form->addError(new FormError($this->get('translator')->trans('FORM.HOST.NONAME', array(), 'admin')));
             return false;
         }
         return true;
     }
     return false;
 }