示例#1
0
 /**
  * Format message
  *
  * @param User $user
  * @param Mail $mail
  *
  * @return \Swift_Mime_MimePart
  */
 public function formatMessage(User $user, Mail $mail)
 {
     // Get base template for email
     $templateContent = $this->twig->loadTemplate('StfalconEventBundle::email.html.twig');
     $text = $mail->replace(array('%fullname%' => $user->getFullname(), '%user_id%' => $user->getId()));
     $body = $templateContent->render(array('text' => $text, 'mail' => $mail));
     $message = \Swift_Message::newInstance()->setSubject($mail->getTitle())->setFrom('*****@*****.**', 'Frameworks Days')->setTo($user->getEmail())->setBody($body, 'text/html');
     return $message;
 }
 /**
  * @param User $user
  *
  * @return string
  */
 private function getTranslatedUserPosition(User $user)
 {
     $position = $user->getPosition();
     /** @var UserTranslation $translation */
     foreach ($user->getTranslations()->getValues() as $translation) {
         if ($translation->getField() == 'position' && $translation->getLocale() == 'en') {
             $position = $translation->getContent();
         }
     }
     return $position;
 }
示例#3
0
 /**
  * @param Event     $event             Event
  * @param User      $user              User
  * @param Payment   $payment           Payment
  * @param FormView  $promoCodeFormView Promo code form view
  * @param PromoCode $promoCode         Promo code
  * @param FormView  $ticketFormView    Ticket form view
  * @param int       $discountAmount    Discount amount
  *
  * @return array
  *
  * @Template()
  * @Secure(roles="ROLE_USER")
  */
 public function payAction($event, $user, $payment, $promoCodeFormView, $promoCode, $ticketFormView, $discountAmount)
 {
     $config = $this->container->getParameter('stfalcon_payment.config');
     $description = 'Оплата участия в конференции ' . $event->getName() . '. Плательщик ' . $user->getFullname() . ' (#' . $user->getId() . ')';
     /** @var InterkassaService $interkassa */
     $interkassa = $this->container->get('stfalcon_event.interkassa.service');
     $params['ik_co_id'] = $config['interkassa']['shop_id'];
     $params['ik_am'] = $payment->getAmount();
     $params['ik_pm_no'] = $payment->getId();
     $params['ik_desc'] = $description;
     $params['ik_loc'] = 'ru';
     $data = array('ik_co_id' => $config['interkassa']['shop_id'], 'ik_desc' => $description, 'ik_sign' => $interkassa->getSignHash($params));
     return array('data' => $data, 'event' => $event, 'payment' => $payment, 'promoCodeForm' => $promoCodeFormView, 'promoCode' => $promoCode, 'ticketForm' => $ticketFormView, 'discountAmount' => $discountAmount);
 }
示例#4
0
 /**
  * {@inheritdoc}
  */
 protected function configureFormFields(FormMapper $formMapper)
 {
     parent::configureFormFields($formMapper);
     $formMapper->remove('firstname');
     $formMapper->remove('lastname');
     $formMapper->with('General')->add('ordering', null, array('required' => false, 'label' => 'Сортировка'))->add('usernameCanonical', null, ['label' => 'Username'])->end()->with('Profile')->add('translations', 'a2lix_translations_gedmo', array('translatable_class' => 'Application\\Bundle\\UserBundle\\Entity\\User', 'fields' => array('firstname' => array('label' => 'Имя', 'locale_options' => array('ru' => array('required' => true), 'en' => array('required' => false))), 'lastname' => array('label' => 'Фамилия', 'locale_options' => array('ru' => array('required' => true), 'en' => array('required' => false))), 'position' => array('label' => 'Должность', 'locale_options' => array('ru' => array('required' => true), 'en' => array('required' => false)))), 'label' => 'Перевод'))->add('avatar', 'file', array('required' => false, 'label' => 'Аватарка'))->add('caricature', 'file', array('required' => false, 'label' => 'Карикатура'))->end()->with('Interests', array('label' => 'Интересы'))->add('interests', 'choice', array('choices' => User::getInterestsList(), 'multiple' => true, 'required' => false, 'label' => 'Интересы'))->add('drink', 'choice', array('choices' => User::getDrinksList(), 'required' => false, 'label' => 'Любимый напиток'))->end();
 }
示例#5
0
 /**
  * Team page
  *
  * @return array()
  * @Route("/team", name="team")
  * @Template()
  */
 public function indexAction()
 {
     $request = $this->get('request');
     $seo = $this->get('sonata.seo.page');
     $seo->generateLangAlternates($request);
     $users = $this->getDoctrine()->getManager()->getRepository("ApplicationUserBundle:User")->findAllActiveUsers();
     $interestsList = User::getInterestsList();
     return array('users' => $users, 'interestsList' => $interestsList);
 }
 /**
  * User solutions action
  *
  * @param User $user User
  *
  * @return Response
  *
  * @Method({"GET"})
  * @Route("/{username}/solutions", name="user_solutions_list")
  * @ParamConverter("user", class="ApplicationUserBundle:User")
  */
 public function userSolutionsAction(User $user)
 {
     // Check if user from URL is same as current user
     if ($user->getId() != $this->getUser()->getId()) {
         throw new AccessDeniedException();
     }
     $em = $this->getDoctrine()->getManager();
     $solutionRepository = $em->getRepository('ApplicationCoreBundle:Solution');
     $threadRepository = $em->getRepository('ApplicationCoreBundle:Thread');
     /** @var \Application\Bundle\CoreBundle\Entity\Solution[] $solutions */
     $solutions = $solutionRepository->findBy(['user' => $user]);
     $threadIds = [];
     foreach ($solutions as $solution) {
         $threadIds[] = 's_' . $solution->getId();
     }
     $solutionCommentsNum = $threadRepository->getThreadsCommentsStats($threadIds);
     return $this->render('ApplicationCoreBundle:User:solutions.html.twig', ['user' => $user, 'solutions' => $solutions, 'solution_comments_stats' => $solutionCommentsNum]);
 }
示例#7
0
 /**
  * Load fixtures
  *
  * @param ObjectManager $manager Manager
  */
 public function load(ObjectManager $manager)
 {
     $user1 = new User();
     $user1->setUsername('user_1');
     $user1->setEmail('*****@*****.**');
     $user1->setPlainPassword('user_1');
     $user1->setGithubId('some_id');
     $manager->persist($user1);
     $manager->flush();
     $user2 = new User();
     $user2->setUsername('user_2');
     $user2->setPlainPassword('user_2');
     $user2->setGithubId('some_id');
     $user2->setEmail('*****@*****.**');
     $manager->persist($user2);
     $manager->flush();
     $user3 = new User();
     $user3->setUsername('user_3');
     $user3->setPlainPassword('user_3');
     $user3->setGithubId('some_id');
     $user3->setEmail('*****@*****.**');
     $manager->persist($user3);
     $manager->flush();
     $this->addReference('user_1', $user1);
     $this->addReference('user_2', $user2);
     $this->addReference('user_3', $user3);
 }
示例#8
0
 /**
  * Format message
  *
  * @param User $user          User
  * @param Mail $mail          Mail
  * @param bool $isTestMessage Test message (needed for admin mails)
  *
  * @return \Swift_Mime_MimePart
  */
 public function formatMessage(User $user, Mail $mail, $isTestMessage = false)
 {
     $text = $mail->replace(array('%fullname%' => $user->getFullname(), '%user_id%' => $user->getId()));
     $unsubscribeLink = $this->router->generate('unsubscribe', ['hash' => $user->getSalt(), 'userId' => $user->getId()], true);
     $body = $this->renderTwigTemplate('StfalconEventBundle::email.html.twig', ['text' => $text, 'mail' => $mail, 'unsubscribeLink' => $unsubscribeLink]);
     $title = $mail->getTitle();
     // Модифицируем заголовок, если рассылка является для админов, т.е. тестовой
     if ($isTestMessage) {
         // Тестовая рассылка
         $title = 'Тестовая рассылка для админов! ' . $title;
     }
     return $this->createMessage($title, $user->getEmail(), $body);
 }
示例#9
0
 /**
  * Create and load user fixtures to database
  *
  * @param ObjectManager $manager Entity manager object
  *
  * @return void
  */
 public function load(ObjectManager $manager)
 {
     $userAdmin = new User();
     $userAdmin->setUsername('admin');
     $userAdmin->setEmail('*****@*****.**');
     $userAdmin->setPlainPassword('qwerty');
     $userAdmin->setRoles(array('ROLE_SUPER_ADMIN'));
     $userAdmin->setEnabled(true);
     $userAdmin->setExpired(false);
     $userAdmin->setLocked(false);
     $userAdmin->setAvatar($this->copyFile('summer.jpg'));
     $userAdmin->setCaricature($this->copyFile('autumn.jpg'));
     $userAdmin->setFirstname('Admin');
     $userAdmin->setLastname('User');
     $userAdmin->setPosition('CEO');
     $userAdmin->setInterests(array('games', 'sportsman'));
     $userAdmin->setDrink('tea');
     $userAdmin->setOrdering(0);
     $manager->persist($userAdmin);
     $this->addReference('user-admin', $userAdmin);
     $user = new User();
     $user->setUsername('firstuser');
     $user->setEmail('*****@*****.**');
     $user->setPlainPassword('qwerty');
     $user->setFirstname('First');
     $user->setLastname('User');
     $user->setPosition('PHP developer');
     $user->setEnabled(true);
     $user->setExpired(false);
     $user->setLocked(false);
     $user->setAvatar($this->copyFile('summer.jpg'));
     $user->setCaricature($this->copyFile('autumn.jpg'));
     $user->setInterests(array('ironman', 'art', 'detectives'));
     $user->setDrink('beer');
     $user->setOrdering(1);
     $manager->persist($user);
     $this->addReference('user-first', $user);
     $user = new User();
     $user->setUsername('seconduser');
     $user->setEmail('*****@*****.**');
     $user->setPlainPassword('qwerty');
     $user->setFirstname('Second');
     $user->setLastname('User');
     $user->setPosition('Art director, Designer');
     $user->setEnabled(true);
     $user->setExpired(false);
     $user->setLocked(false);
     $user->setAvatar($this->copyFile('summer.jpg'));
     $user->setCaricature($this->copyFile('autumn.jpg'));
     $user->setInterests(array('cyclists', 'art', 'books'));
     $user->setDrink('water');
     $user->setOrdering(2);
     $manager->persist($user);
     $this->addReference('user-second', $user);
     $manager->flush();
 }
示例#10
0
 /**
  * Team page
  *
  * @return array()
  * @Route("/team", name="team")
  * @Template()
  */
 public function indexAction()
 {
     $users = $this->getDoctrine()->getManager()->getRepository("ApplicationUserBundle:User")->findAllActiveUsers();
     $interestsList = User::getInterestsList();
     return array('users' => $users, 'interestsList' => $interestsList);
 }
示例#11
0
 /**
  * Create and load user fixtures to database
  *
  * @param ObjectManager $manager Entity manager object
  *
  * @return void
  */
 public function load(ObjectManager $manager)
 {
     $userAdmin = new User();
     $userAdmin->setUsername('Администратор');
     $userAdmin->setFullname('Super Admin');
     $userAdmin->setEmail('*****@*****.**');
     $userAdmin->setPlainPassword('qwerty');
     $userAdmin->setRoles(array('ROLE_SUPER_ADMIN'));
     $userAdmin->setEnabled(true);
     $userAdmin->setExpired(false);
     $userAdmin->setLocked(false);
     $manager->persist($userAdmin);
     $this->addReference('user-admin', $userAdmin);
     $userVolunteer = new User();
     $userVolunteer->setUsername('Волонтер');
     $userVolunteer->setFullname('Volunteer Jack');
     $userVolunteer->setEmail('*****@*****.**');
     $userVolunteer->setPlainPassword('qwerty');
     $userVolunteer->setRoles(array('ROLE_VOLUNTEER'));
     $userVolunteer->setEnabled(true);
     $userVolunteer->setExpired(false);
     $userVolunteer->setLocked(false);
     $manager->persist($userVolunteer);
     $this->addReference('user-volunteer', $userVolunteer);
     $userDefault = new User();
     $userDefault->setUsername('Пользователь');
     $userDefault->setFullname('Michael Jordan');
     $userDefault->setEmail('*****@*****.**');
     $userDefault->setPlainPassword('qwerty');
     $userDefault->addRole('ROLE_USER');
     $userDefault->setCountry('USA');
     $userDefault->setCity('Boston');
     $userDefault->setCompany('NBA');
     $userDefault->setPost('Point Guard');
     $userDefault->setEnabled(true);
     $userDefault->setExpired(false);
     $userDefault->setLocked(false);
     $manager->persist($userDefault);
     $this->addReference('user-default', $userDefault);
     $userDefault2 = new User();
     $userDefault2->setUsername('Pirate');
     $userDefault2->setFullname('Jack Sparrow');
     $userDefault2->setEmail('*****@*****.**');
     $userDefault2->setPlainPassword('qwerty');
     $userDefault2->addRole('ROLE_USER');
     $userDefault2->setCountry('Haiti');
     $userDefault2->setCity('Tortuga');
     $userDefault2->setCompany('Pirates of the Caribbean');
     $userDefault2->setPost('Captain');
     $userDefault2->setEnabled(true);
     $userDefault2->setExpired(false);
     $userDefault2->setLocked(false);
     $manager->persist($userDefault2);
     $this->addReference('user-default2', $userDefault2);
     $userDefault3 = new User();
     $userDefault3->setUsername('Spiderman');
     $userDefault3->setFullname('Peter Parker');
     $userDefault3->setEmail('*****@*****.**');
     $userDefault3->setPlainPassword('qwerty');
     $userDefault3->addRole('ROLE_USER');
     $userDefault3->setCountry('USA');
     $userDefault3->setCity('New-York');
     $userDefault3->setCompany('The New-York Times');
     $userDefault3->setPost('Journalist');
     $userDefault3->setEnabled(true);
     $userDefault3->setExpired(false);
     $userDefault3->setLocked(false);
     $manager->persist($userDefault3);
     $this->addReference('user-default3', $userDefault3);
     $userDefault4 = new User();
     $userDefault4->setUsername('Rasmus');
     $userDefault4->setFullname('Rasmus Lerdorf');
     $userDefault4->setEmail('*****@*****.**');
     $userDefault4->setPlainPassword('qwerty');
     $userDefault4->addRole('ROLE_USER');
     $userDefault4->setCountry('Greenland');
     $userDefault4->setCity('Tortuga');
     $userDefault4->setCompany('PHP');
     $userDefault4->setPost('Core developer');
     $userDefault4->setEnabled(true);
     $userDefault4->setSubscribe(false);
     $userDefault4->setExpired(false);
     $userDefault4->setLocked(false);
     $manager->persist($userDefault4);
     $this->addReference('user-default4', $userDefault4);
     for ($i = 1; $i <= 100; $i++) {
         $userDefault = new User();
         $userDefault->setUsername('Пользователь ' . $i);
         $userDefault->setFullname('Default User ' . $i);
         $userDefault->setEmail('user' . $i . '@fwdays.com');
         $userDefault->setPlainPassword('qwerty');
         $userDefault->addRole('ROLE_USER');
         $userDefault->setCountry('Ukraine');
         $userDefault->setCity('Khmelnytskyi');
         $userDefault->setCompany('Anonumous');
         $userDefault->setPost('Tester');
         $userDefault->setEnabled(true);
         $userDefault->setExpired(false);
         $userDefault->setLocked(false);
         $manager->persist($userDefault);
         $this->addReference('user-default-' . $i, $userDefault);
     }
     $manager->flush();
 }
示例#12
0
 /**
  *  Find ticket for event by user
  *
  * @param Event $event
  * @param User $user
  *
  * @return Ticket
  */
 public function getTicketForEventByUser(Event $event, User $user)
 {
     return $this->findOneBy(array('event' => $event->getId(), 'user' => $user->getId()));
 }
示例#13
0
 /**
  * Get posts query by user
  *
  * @param User $user User
  * @param string $locale Locale
  *
  * @return array
  */
 public function getPostsQueryByUser(User $user, $locale)
 {
     $qb = $this->createQueryBuilder('p');
     $qb->where($qb->expr()->eq('p.author', ':user_id'))->andWhere($qb->expr()->eq('p.published', true))->orderBy('p.created', 'DESC')->setParameter('user_id', $user->getId());
     $this->addLocaleFilter($locale, $qb);
     return $qb->getQuery();
 }