Example #1
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     parent::buildForm($builder, $options);
     $builder->add('custodian', 'entity', array('class' => 'Tixi\\CoreDomain\\Custodian', 'property' => 'nameStringWithID', 'label' => 'passenger.field.custodian', 'required' => false, 'empty_data' => null, 'empty_value' => 'passenger.field.custodian.empty', 'query_builder' => function (EntityRepository $er) {
         return $er->createQueryBuilder('s')->where('s.isDeleted = 0')->orderBy('s.firstname', 'ASC');
     }));
     $builder->add('building', 'text', array('required' => false, 'label' => 'address.field.building'));
     $builder->add('lookaheadaddress', 'addresslookahead', array('label' => 'address.field.lookahead'));
     /** formerly isAuthorizedToRide */
     $builder->add('isAuthorizedToRide', 'checkbox', array('required' => false, 'label' => 'passenger.field.isAuthorizedToRide'));
     $builder->add('hasMonthlyBilling', 'checkbox', array('required' => false, 'label' => 'passenger.field.monthlybilling'));
     $builder->add('isInWheelChair', 'checkbox', array('required' => false, 'label' => 'passenger.field.isinwheelchair'));
     $builder->add('handicaps', 'entity', array('required' => false, 'class' => 'Tixi\\CoreDomain\\Handicap', 'property' => 'name', 'expanded' => true, 'multiple' => true, 'label' => 'passenger.field.handicap', 'query_builder' => function (EntityRepository $er) {
         return $er->createQueryBuilder('e')->where('e.isDeleted = 0');
     }));
     $builder->add('insurances', 'entity', array('required' => false, 'class' => 'Tixi\\CoreDomain\\Insurance', 'property' => 'name', 'expanded' => true, 'multiple' => true, 'label' => 'passenger.field.insurance', 'query_builder' => function (EntityRepository $er) {
         return $er->createQueryBuilder('e')->where('e.isDeleted = 0');
     }));
     $builder->add('personCategories', 'entity', array('required' => false, 'class' => 'Tixi\\CoreDomain\\PersonCategory', 'property' => 'name', 'expanded' => true, 'multiple' => true, 'label' => 'passenger.field.personcategory', 'query_builder' => function (EntityRepository $er) {
         return $er->createQueryBuilder('e')->where('e.isDeleted = 0');
     }));
     $builder->add('entryDate', 'datePicker', array('required' => false, 'label' => 'person.field.entrydate'));
     $builder->add('birthday', 'datePicker', array('required' => false, 'label' => 'person.field.birthday'));
     $builder->add('extraMinutes', 'integer', array('required' => false, 'label' => 'person.field.extraminutes', 'attr' => array('title' => 'form.field.title.digit'), 'constraints' => array(new Regex(array('message' => 'form.field.title.digit', 'pattern' => '/\\d+/')), new Range(array('min' => 0, 'max' => 999, 'minMessage' => 'validate.min.extraminutes', 'maxMessage' => 'validate.max.extraminutes')))));
     $builder->add('notice', 'textarea', array('required' => false, 'label' => 'passenger.field.notice'));
     $builder->add('contradictVehicleCategories', 'entity', array('required' => false, 'class' => 'Tixi\\CoreDomain\\VehicleCategory', 'property' => 'name', 'expanded' => true, 'multiple' => true, 'label' => 'person.field.contradict_vehicle_category', 'query_builder' => function (EntityRepository $er) {
         return $er->createQueryBuilder('e')->where('e.isDeleted = 0');
     }));
     if ($this->user->hasRole('ROLE_MANAGER')) {
         $builder->add('details', 'textarea', array('required' => false, 'label' => 'person.field.details'));
     }
 }
Example #2
0
 /**
  * @param $username
  * @param $password
  * @param null $email
  * @return User
  */
 public static function registerUser($username, $password, $email = null)
 {
     $user = new User();
     $user->setUsername($username);
     $user->setPassword($password);
     if (!empty($email)) {
         $user->setEmail($email);
     }
     return $user;
 }
Example #3
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     parent::buildForm($builder, $options);
     $builder->add('name', 'text', array('label' => 'poi.field.name', 'attr' => array('title' => 'form.field.title.not_blank'), 'constraints' => array(new NotBlank(array('message' => 'field.not_blank')))));
     $builder->add('department', 'text', array('required' => false, 'label' => 'poi.field.department'));
     $builder->add('telephone', 'telephoneType', array('required' => false, 'label' => 'poi.field.telephone'));
     $builder->add('keywords', 'entity', array('required' => false, 'class' => 'Tixi\\CoreDomain\\POIKeyword', 'property' => 'name', 'label' => 'poi.field.keyword', 'multiple' => true, 'expanded' => true, 'query_builder' => function (EntityRepository $er) {
         return $er->createQueryBuilder('k')->where('k.isDeleted = 0')->orderBy('k.name', 'ASC');
     }));
     $builder->add('address', 'addresslookahead', array('label' => 'address.field.lookahead'));
     $builder->add('comment', 'textarea', array('required' => false, 'label' => 'poi.field.comment'));
     if ($this->user->hasRole('ROLE_MANAGER')) {
         $builder->add('details', 'textarea', array('required' => false, 'label' => 'poi.field.details'));
     }
 }
Example #4
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('id', 'hidden');
     $builder->add('category', 'entity', array('class' => 'Tixi\\CoreDomain\\VehicleCategory', 'property' => 'name', 'label' => 'vehicle.field.category'));
     $builder->add('name', 'text', array('label' => 'vehicle.field.name', 'attr' => array('title' => 'form.field.title.not_blank'), 'constraints' => array(new NotBlank(array('message' => 'vehicle.name.not_blank')))));
     $builder->add('companyOwned', 'checkbox', array('required' => false, 'label' => 'vehicle.field.companyowned'));
     $builder->add('licenceNumber', 'text', array('label' => 'vehicle.field.licencenumber', 'attr' => array('title' => 'form.field.title.gletter_digit_space'), 'pattern' => '^[A-Z\\d ]+$', 'constraints' => array(new NotBlank(array('message' => 'vehicle.nr.not_blank')))));
     $builder->add('dateOfFirstRegistration', 'datePicker', array('label' => 'vehicle.field.dateoffirstregistration'));
     $builder->add('supervisor', 'entity', array('class' => 'Tixi\\CoreDomain\\Driver', 'property' => 'nameStringWithID', 'label' => 'vehicle.field.supervisor', 'required' => false, 'empty_data' => null, 'empty_value' => 'vehicle.field.supervisor.empty', 'query_builder' => function (EntityRepository $er) {
         return $er->createQueryBuilder('s')->where('s.isDeleted = 0')->orderBy('s.firstname', 'ASC');
     }));
     $builder->add('depot', 'entity', array('class' => 'Tixi\\CoreDomain\\VehicleDepot', 'property' => 'nameString', 'label' => 'vehicle.field.depot', 'required' => false, 'empty_data' => null, 'empty_value' => 'vehicle.field.depot.empty', 'query_builder' => function (EntityRepository $er) {
         return $er->createQueryBuilder('d')->where('d.isDeleted = 0')->orderBy('d.name', 'ASC');
     }));
     $builder->add('parking', 'text', array('required' => false, 'label' => 'vehicle.field.parking'));
     $builder->add('memo', 'textarea', array('label' => 'vehicle.field.memo', 'required' => false));
     if ($this->user->hasRole('ROLE_MANAGER')) {
         $builder->add('managementDetails', 'textarea', array('label' => 'vehicle.field.managementdetails', 'required' => false));
     }
 }
Example #5
0
 /**
  * @param $username
  * @param $password
  * @param $roles
  * @return User
  */
 public function createUser($username, $password, $roles)
 {
     $user = $this->init->userRepo->findOneBy(array('username' => $username));
     if (empty($user)) {
         $user = new User();
         $user->setUsername($username);
         $encoder = $this->init->encFactory->getEncoder($user);
         $encPassword = $encoder->encodePassword($password, $user->getSalt());
         if (!$encoder->isPasswordValid($encPassword, $password, $user->getSalt())) {
             $this->assert('Password not valid');
         } else {
             $user->setPassword($encPassword);
         }
         foreach ($roles as $role) {
             $user->assignRole($role);
         }
         $this->init->userRepo->store($user);
     }
     return $user;
 }
Example #6
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     parent::buildForm($builder, $options);
     $builder->add('fax', 'telephoneType', array('required' => false, 'label' => 'person.field.fax'));
     $builder->add('email', 'email', array('required' => false, 'label' => 'person.field.email'));
     $builder->add('lookaheadaddress', 'addresslookahead', array('label' => 'address.field.lookahead'));
     $builder->add('licenceNumber', 'text', array('label' => 'driver.field.licence', 'attr' => array('title' => 'form.field.title.not_blank'), 'constraints' => array(new NotBlank(array('message' => 'form.field.not_blank')))));
     $builder->add('wheelChairAttendance', 'checkbox', array('required' => false, 'label' => 'driver.field.wheelchair'));
     $builder->add('driverCategory', 'entity', array('class' => 'Tixi\\CoreDomain\\DriverCategory', 'property' => 'name', 'label' => 'driver.field.category', 'attr' => array('title' => 'form.field.title.not_selected'), 'constraints' => array(new NotBlank(array('message' => 'form.field.not_blank'))), 'query_builder' => function (EntityRepository $er) {
         return $er->createQueryBuilder('e')->where('e.isDeleted = 0');
     }));
     $builder->add('entryDate', 'datePicker', array('required' => false, 'label' => 'person.field.entrydate'));
     $builder->add('birthday', 'datePicker', array('required' => false, 'label' => 'person.field.birthday'));
     $builder->add('extraMinutes', 'integer', array('required' => false, 'label' => 'person.field.extraminutes', 'attr' => array('title' => 'form.field.title.digit'), 'constraints' => array(new Regex(array('message' => 'form.field.title.digit', 'pattern' => '/\\d+/')), new Range(array('min' => 0, 'max' => 999, 'minMessage' => 'validate.min.extraminutes', 'maxMessage' => 'validate.max.extraminutes')))));
     $builder->add('contradictVehicleCategories', 'entity', array('required' => false, 'class' => 'Tixi\\CoreDomain\\VehicleCategory', 'property' => 'name', 'expanded' => true, 'multiple' => true, 'label' => 'person.field.contradict_vehicle_category', 'query_builder' => function (EntityRepository $er) {
         return $er->createQueryBuilder('e')->where('e.isDeleted = 0');
     }));
     $builder->add('operationWish', 'textarea', array('required' => false, 'label' => 'driver.field.operationwish'));
     if ($this->user->hasRole('ROLE_MANAGER')) {
         $builder->add('details', 'textarea', array('required' => false, 'label' => 'person.field.details'));
     }
 }
Example #7
0
 /**
  * @param User $user
  * @param $role
  * @param RoleRepository $roleRepository
  */
 private function assignRolesFromSelection(User $user, Role $role, RoleRepository $roleRepository)
 {
     $roleDispo = $roleRepository->findOneBy(array('role' => Role::$roleDispo));
     $roleManager = $roleRepository->findOneBy(array('role' => Role::$roleManager));
     $roleAdmin = $roleRepository->findOneBy(array('role' => Role::$roleAdmin));
     switch ($role->getName()) {
         case Role::$roleDispoName:
             $user->assignRole($roleDispo);
             $user->unsignRole($roleManager);
             $user->unsignRole($roleAdmin);
             break;
         case Role::$roleManagerName:
             $user->assignRole($roleDispo);
             $user->assignRole($roleManager);
             $user->unsignRole($roleAdmin);
             break;
         case Role::$roleAdminName:
             $user->assignRole($roleDispo);
             $user->assignRole($roleManager);
             $user->assignRole($roleAdmin);
             break;
     }
 }