示例#1
0
文件: Message.php 项目: symbb/symbb
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if ($this->full) {
         $transformer = new UsersToReceiverTransformer($this->message);
         $users = $this->userManager->findUsers(999999, 1);
         $receivers = $builder->create('receivers', 'entity', array('choices' => $users, 'class' => 'SymbbCoreUserBundle:User', 'required' => true, "multiple" => true))->addModelTransformer($transformer);
         $builder->add($receivers);
     }
     $builder->add('subject', 'text', array("required" => true))->add('message', 'textarea', array("required" => true));
 }
示例#2
0
 /**
  *
  * @param type $format
  * @return \IntlDateFormatter
  * @throws Exception
  */
 protected function getIntlDateFormater($format)
 {
     if (\is_string($format)) {
         $format = \constant('\\IntlDateFormatter::' . \strtoupper($format));
     } else {
         if (!\is_numeric($format)) {
             throw new Exception('Format must be an string or IntlDateFormater Int Value');
         }
     }
     $locale = \Symfony\Component\Locale\Locale::getDefault();
     $tz = $this->userManager->getTimezone();
     $fmt = new \IntlDateFormatter($locale, $format, $format, $tz->getName(), \IntlDateFormatter::GREGORIAN);
     return $fmt;
 }
示例#3
0
 public function parsePostText(\Symbb\Core\ForumBundle\Event\PostManagerParseTextEvent $event)
 {
     $text = $event->getText();
     $matches = array();
     preg_match_all("|\\W@(\\S+)?|", $text, $matches);
     if (isset($matches[1])) {
         foreach ($matches[1] as $username) {
             $userFound = $this->userManager->findByUsername($username);
             if (\is_object($userFound)) {
                 $uri = $this->router->generate('symbb_user_profile', array('id' => $userFound->getId(), 'name' => $userFound->getUsername()));
                 $text = \str_replace("@" . $username, "<a href='" . $uri . "'>@" . $userFound->getUsername() . "</a>", $text);
             }
         }
     }
     $event->setText($text);
 }
示例#4
0
 /**
  *
  * @return UserInterface
  */
 public function getUser()
 {
     if (!is_object($this->user)) {
         $this->user = $this->userManager->getCurrentUser();
     }
     return $this->user;
 }
示例#5
0
 /**
  * get a ISO8601 String ( Date with Timezone and Time Information )
  * @param \DateTime $datetime
  * @return null|string
  */
 public function getISO8601ForUser(\DateTime $datetime = null)
 {
     if ($datetime) {
         $datetime->setTimezone($this->userManager->getTimezone());
         return $datetime->format(\DateTime::ISO8601);
     }
     return null;
 }
示例#6
0
 /**
  * @param $object
  * @param string $flag
  */
 public function insertFlags($object, $flag = null)
 {
     if (!$flag) {
         $flag = AbstractFlagHandler::FLAG_NEW;
     }
     if (is_object($this->getUser())) {
         // adding user flags
         $users = $this->userManager->findUsers();
         foreach ($users as $user) {
             if ($user->getSymbbType() === 'user' && ($flag !== AbstractFlagHandler::FLAG_NEW || $user->getId() != $this->getUser()->getId())) {
                 $this->insertFlag($object, $flag, $user, false);
             }
         }
         $this->em->flush();
     }
 }
示例#7
0
文件: PostType.php 项目: symbb/symbb
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('name', "text", array('label' => 'Titel', 'required' => true, 'attr' => array('placeholder' => 'Enter a name here')));
     $builder->add('text', 'textarea', array('attr' => array('placeholder' => 'Give Your text here', "class" => "symbb-editable")));
     $builder->add('id', 'hidden');
     $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($builder) {
         $data = $event->getData();
         /* Check we're looking at the right data/form */
         if ($data instanceof Post) {
             $form = $event->getForm();
             $form->add('notifyMe', 'checkbox', array("mapped" => false, 'required' => false, 'label' => 'Notify me', "data" => $this->topicManager->checkFlag($data->getTopic(), "notify", $this->userManager->getCurrentUser())));
         }
     });
     // create Event to manipulate Post Form
     $event = new \Symbb\Core\EventBundle\Event\FormPostEvent($builder, $this->translator, $this->postManager, $this->userManager, $this->groupManager);
     $this->dispatcher->dispatch('symbb.core.forum.topic.post.create', $event);
 }
示例#8
0
文件: UserApi.php 项目: symbb/symbb
 /**
  * @param int|UserInterface $object
  * @return bool
  */
 public function delete($object)
 {
     if (is_numeric($object)) {
         $object = $this->find($object);
     } else {
         if (!$object instanceof UserInterface) {
             $this->addErrorMessage(self::ERROR_WRONG_OBJECT);
         }
     }
     if (!$this->hasError()) {
         $check = $this->userManager->removeUser($object);
         if ($check) {
             $this->addSuccessMessage(self::SUCCESS_DELETED);
         }
         return $check;
     }
     return false;
 }
示例#9
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('email', 'email', array('label' => 'form.email', 'translation_domain' => 'symbb_frontend', 'attr' => array('placeholder' => 'Your E-Mail')))->add('username', null, array('label' => 'form.username', 'translation_domain' => 'symbb_frontend', 'attr' => array('placeholder' => 'Your Username')))->add('plainPassword', 'repeated', array('type' => 'password', 'options' => array('translation_domain' => 'symbb_frontend'), 'first_options' => array('label' => 'form.password', 'attr' => array('placeholder' => 'Your Password')), 'second_options' => array('label' => 'form.password_confirmation', 'attr' => array('placeholder' => 'Retype your Password')), 'invalid_message' => 'fos_user.password.mismatch', 'constraints' => $this->usermanager->getPasswordValidatorConstraints()))->add('terms', 'checkbox', array('label' => 'Read and accepted Terms of Use', 'translation_domain' => 'symbb_frontend', 'mapped' => false, 'required' => true));
     $builder->add('recaptcha', 'formextra_recaptcha', array('widget_options' => array('theme' => 'white'), 'mapped' => false));
 }
示例#10
0
 public function __construct(UserManager $usermanager, $em)
 {
     $this->user = $usermanager->getCurrentUser();
     $this->em = $em;
 }
示例#11
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('plainPassword', 'repeated', array('type' => 'password', 'invalid_message' => 'The password fields must match.', 'options' => array('attr' => array('class' => 'password-field')), 'required' => true, 'first_options' => array('label' => 'Password'), 'second_options' => array('label' => 'Repeat Password'), 'constraints' => $this->usermanager->getPasswordValidatorConstraints()));
 }