Exemplo n.º 1
0
 /**
  * @param FormBuilderInterface $builder
  * @param array                $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->addEventSubscriber(new CleanFormSubscriber(array('body' => 'html')));
     $builder->add('subject', 'text', array('label' => 'mautic.email.subject', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control'), 'required' => false));
     $user = $this->factory->getUser();
     $default = empty($options['data']['from']) ? $user->getEmail() : $options['data']['from'];
     $builder->add('from', 'text', array('label' => 'mautic.lead.email.from_email', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control'), 'required' => false, 'data' => $default, 'constraints' => array(new NotBlank(array('message' => 'mautic.core.email.required')), new Email(array('message' => 'mautic.core.email.required')))));
     $builder->add('body', 'textarea', array('label' => 'mautic.email.form.body', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control editor-basic-fullpage editor-builder-tokens', 'data-token-callback' => 'email:getBuilderTokens', 'data-token-activator' => '{')));
     $builder->add('list', 'hidden');
     $builder->add('templates', 'email_list', array('label' => 'mautic.lead.email.template', 'label_attr' => array('class' => 'control-label'), 'required' => false, 'attr' => array('class' => 'form-control', 'onchange' => 'Mautic.getLeadEmailContent(this)'), 'multiple' => false));
     $builder->add('buttons', 'form_buttons', array('apply_text' => false, 'save_text' => 'mautic.email.send', 'save_class' => 'btn btn-primary', 'save_icon' => 'fa fa-send', 'cancel_icon' => 'fa fa-times'));
     if (!empty($options["action"])) {
         $builder->setAction($options["action"]);
     }
 }
Exemplo n.º 2
0
 /**
  * @param string              $tokenRegex     Token regex without wrapping regex escape characters.  Use (value) or (.*?) where the ID of the
  *                                            entity should go. i.e. {pagelink=(value)}
  * @param string              $filter         String to filter results by
  * @param string              $labelColumn    The column that houses the label
  * @param string              $valueColumn    The column that houses the value
  * @param CompositeExpression $expr           Use $factory->getDatabase()->getExpressionBuilder()->andX()
  *
  * @return array|void
  */
 public function getTokens($tokenRegex, $filter = '', $labelColumn = 'name', $valueColumn = 'id', CompositeExpression $expr = null)
 {
     //set some permissions
     $permissions = $this->factory->getSecurity()->isGranted($this->permissionSet, "RETURN_ARRAY");
     if (in_array(false, $permissions)) {
         return;
     }
     $repo = $this->factory->getModel($this->modelName)->getRepository();
     $prefix = $repo->getTableAlias();
     if (!empty($prefix)) {
         $prefix .= '.';
     }
     $exprBuilder = $this->factory->getDatabase()->getExpressionBuilder();
     if ($expr == null) {
         $expr = $exprBuilder->andX();
     }
     if (isset($permissions[$this->viewPermissionBase . ':viewother']) && !$permissions[$this->viewPermissionBase . ':viewother']) {
         $expr->add($exprBuilder->eq($prefix . 'createdBy', $this->factory->getUser()->getId()));
     }
     if (!empty($filter)) {
         $expr->add($exprBuilder->like('LOWER(' . $labelColumn . ')', ':label'));
         $parameters = array('label' => strtolower($filter) . '%');
     } else {
         $parameters = array();
     }
     $items = $repo->getSimpleList($expr, $parameters, $labelColumn, $valueColumn);
     $tokens = array();
     foreach ($items as $item) {
         $token = str_replace(array('(value)', '(.*?)'), $item['value'], $tokenRegex);
         $tokens[$token] = $item['label'];
     }
     return $tokens;
 }
Exemplo n.º 3
0
 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->translator = $factory->getTranslator();
     $this->em = $factory->getEntityManager();
     $this->model = $factory->getModel('page');
     $this->canViewOther = $factory->getSecurity()->isGranted('page:pages:viewother');
     $this->user = $factory->getUser();
 }
Exemplo n.º 4
0
 /**
  * Return a list of entities
  *
  * @param array $args [start, limit, filter, orderBy, orderByDir]
  *
  * @return \Doctrine\ORM\Tools\Pagination\Paginator|array
  */
 public function getEntities(array $args = array())
 {
     //set the translator
     $repo = $this->getRepository();
     if ($repo instanceof CommonRepository) {
         $repo->setTranslator($this->translator);
         $repo->setCurrentUser($this->factory->getUser());
         return $repo->getEntities($args);
     }
     return array();
 }
Exemplo n.º 5
0
 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $viewOther = $factory->getSecurity()->isGranted('asset:assets:viewother');
     $repo = $factory->getModel('asset')->getRepository();
     $repo->setCurrentUser($factory->getUser());
     $choices = $repo->getAssetList('', 0, 0, $viewOther);
     foreach ($choices as $asset) {
         $this->choices[$asset['language']][$asset['id']] = $asset['title'];
     }
     //sort by language
     ksort($this->choices);
 }
Exemplo n.º 6
0
 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->viewOther = $factory->getSecurity()->isGranted('dynamicContent:dynamicContents:viewother');
     $this->repo = $factory->getModel('dynamicContent')->getRepository();
     $this->repo->setCurrentUser($factory->getUser());
 }
Exemplo n.º 7
0
 /**
  * @return mixed
  */
 protected function getUser()
 {
     return $this->factory->getUser();
 }
Exemplo n.º 8
0
 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->factory = $factory;
     $this->user = $factory->getUser();
 }
 public function __construct(MauticFactory $factory)
 {
     $this->em = $factory->getEntityManager();
     $this->currentUser = $factory->getUser();
 }