Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     /** @var \Mautic\PluginBundle\Helper\IntegrationHelper $integrationHelper */
     $integrationHelper = $this->factory->getHelper('integration');
     $integrationObjects = $integrationHelper->getIntegrationObjects(null, $options['supported_features'], true);
     $integrations = ['' => ''];
     foreach ($integrationObjects as $name => $object) {
         $settings = $object->getIntegrationSettings();
         if ($settings->isPublished()) {
             if (!isset($integrations[$settings->getPlugin()->getName()])) {
                 $integrations[$settings->getPlugin()->getName()] = [];
             }
             $integrations[$settings->getPlugin()->getName()][$object->getName()] = $object->getDisplayName();
         }
     }
     $builder->add('integration', 'choice', ['choices' => $integrations, 'expanded' => false, 'label_attr' => ['class' => 'control-label'], 'multiple' => false, 'label' => 'mautic.integration.integration', 'attr' => ['class' => 'form-control', 'tooltip' => 'mautic.integration.integration.tooltip', 'onchange' => 'Mautic.getIntegrationConfig(this);'], 'required' => true, 'constraints' => [new NotBlank(['message' => 'mautic.core.value.required'])]]);
     $formModifier = function (FormInterface $form, $data) use($integrationObjects) {
         $form->add('config', 'integration_config', ['label' => false, 'attr' => ['class' => 'integration-config-container'], 'integration' => isset($integrationObjects[$data['integration']]) ? $integrationObjects[$data['integration']] : null, 'data' => isset($data['config']) ? $data['config'] : []]);
     };
     $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($formModifier) {
         $data = $event->getData();
         $formModifier($event->getForm(), $data);
     });
     $builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use($formModifier) {
         $data = $event->getData();
         $formModifier($event->getForm(), $data);
     });
 }
Exemplo n.º 2
0
 /**
  * @param FormBuilderInterface $builder
  * @param array                $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $monitoredShowOn = $options['mailbox'] == 'general' ? '{}' : '{"config_emailconfig_monitored_email_' . $options['mailbox'] . '_override_settings_1": "checked"}';
     $builder->add('address', 'text', array('label' => 'mautic.email.config.monitored_email_address', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.email.config.monitored_email_address.tooltip', 'data-show-on' => $monitoredShowOn), 'constraints' => array(new Email(array('message' => 'mautic.core.email.required'))), 'required' => false));
     $builder->add('host', 'text', array('label' => 'mautic.email.config.monitored_email_host', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.email.config.monitored_email_host.tooltip', 'data-show-on' => $monitoredShowOn), 'required' => false));
     $builder->add('port', 'text', array('label' => 'mautic.email.config.monitored_email_port', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.email.config.monitored_email_port.tooltip', 'data-show-on' => $monitoredShowOn), 'required' => false, 'data' => array_key_exists('port', $options['data']) ? $options['data']['port'] : 993));
     if (extension_loaded('openssl')) {
         $builder->add('encryption', 'choice', array('choices' => array('/ssl' => 'mautic.email.config.mailer_encryption.ssl', '/ssl/novalidate-cert' => 'mautic.email.config.monitored_email_encryption.ssl_novalidate', '/tls' => 'mautic.email.config.mailer_encryption.tls', '/tls/novalidate-cert' => 'mautic.email.config.monitored_email_encryption.tls_novalidate'), 'label' => 'mautic.email.config.monitored_email_encryption', 'required' => false, 'attr' => array('class' => 'form-control', 'data-show-on' => $monitoredShowOn, 'tooltip' => 'mautic.email.config.monitored_email_encryption.tooltip'), 'empty_value' => 'mautic.email.config.mailer_encryption.none', 'data' => isset($options['data']['encryption']) ? $options['data']['encryption'] : '/ssl'));
     }
     $builder->add('user', 'text', array('label' => 'mautic.email.config.monitored_email_user', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.email.config.monitored_email_user.tooltip', 'autocomplete' => 'off', 'data-show-on' => $monitoredShowOn), 'required' => false));
     $builder->add('password', 'password', array('label' => 'mautic.email.config.monitored_email_password', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'placeholder' => 'mautic.user.user.form.passwordplaceholder', 'preaddon' => 'fa fa-lock', 'tooltip' => 'mautic.email.config.monitored_email_password.tooltip', 'autocomplete' => 'off', 'data-show-on' => $monitoredShowOn), 'required' => false));
     if ($options['mailbox'] != 'general') {
         $builder->add('override_settings', 'yesno_button_group', array('label' => 'mautic.email.config.monitored_email_override_settings', 'label_attr' => array('class' => 'control-label'), 'data' => array_key_exists('override_settings', $options['data']) && !empty($options['data']['override_settings']) ? true : false, 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.email.config.monitored_email_override_settings.tooltip'), 'required' => false));
         /** @var \Mautic\EmailBundle\MonitoredEmail\Mailbox $mailbox */
         $mailbox = $this->factory->getHelper('mailbox');
         $settings = empty($options['data']['override_settings']) ? $options['general_settings'] : $options['data'];
         $mailbox->setMailboxSettings($settings);
         // Check for IMAP connection and get a folder list
         $choices = array('INBOX' => 'INBOX', 'Trash' => 'Trash');
         if ($mailbox->isConfigured()) {
             try {
                 $folders = $mailbox->getListingFolders();
                 $choices = array_combine($folders, $folders);
             } catch (\Exception $e) {
                 // If the connection failed - add back the selected folder just in case it's a temporary connection issue
                 if (!empty($options['data']['folder'])) {
                     $choices[$options['data']['folder']] = $options['data']['folder'];
                 }
             }
         }
         $builder->add('folder', 'choice', array('choices' => $choices, 'label' => 'mautic.email.config.monitored_email_folder', 'label_attr' => array('class' => 'control-label'), 'attr' => array_merge(array('class' => 'form-control', 'tooltip' => 'mautic.email.config.monitored_email_folder.tooltip', 'data-imap-folders' => $options['mailbox'])), 'data' => array_key_exists('folder', $options['data']) ? $options['data']['folder'] : $options['default_folder'], 'required' => false));
     }
     $builder->add('test_connection_button', 'standalone_button', array('label' => 'mautic.email.config.monitored_email.test_connection', 'required' => false, 'attr' => array('class' => 'btn btn-success', 'onclick' => 'Mautic.testMonitoredEmailServerConnection(\'' . $options['mailbox'] . '\')')));
 }
Exemplo n.º 3
0
 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->devMode = $factory->getEnvironment() == 'dev';
     $this->imageDir = $factory->getSystemPath('images');
     $this->assetHelper = $factory->getHelper('template.assets');
     $this->avatarHelper = $factory->getHelper('template.avatar');
 }
Exemplo n.º 4
0
 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->devMode = $factory->getEnvironment() == 'dev';
     $this->imageDir = $factory->getSystemPath('images');
     $this->assetHelper = $factory->getHelper('template.assets');
     $this->avatarHelper = $factory->getHelper('template.avatar');
     $this->request = $factory->getRequest();
     $this->devHosts = (array) $factory->getParameter('dev_hosts');
 }
Exemplo n.º 5
0
 /**
  * @param FormBuilderInterface $builder
  * @param array                $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('site_url', 'text', array('label' => 'mautic.core.config.form.site.url', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.site.url.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     $builder->add('webroot', 'page_list', array('label' => 'mautic.core.config.form.webroot', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.webroot.tooltip', 'data-placeholder' => $this->factory->getTranslator()->trans('mautic.core.config.form.webroot.dashboard')), 'multiple' => false, 'empty_value' => '', 'required' => false));
     $builder->add('cache_path', 'text', array('label' => 'mautic.core.config.form.cache.path', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.cache.path.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     $builder->add('log_path', 'text', array('label' => 'mautic.core.config.form.log.path', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.log.path.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     $builder->add('image_path', 'text', array('label' => 'mautic.core.config.form.image.path', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.image.path.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     $builder->add('theme', 'theme_list', array('label' => 'mautic.core.config.form.theme', 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.page.form.template.help')));
     // Get the list of available languages
     /** @var \Mautic\CoreBundle\Helper\LanguageHelper $languageHelper */
     $languageHelper = $this->factory->getHelper('language');
     $languages = $languageHelper->fetchLanguages(false, false);
     $langChoices = array();
     foreach ($languages as $code => $langData) {
         $langChoices[$code] = $langData['name'];
     }
     $langChoices = array_merge($langChoices, $this->factory->getParameter('supported_languages'));
     // Alpha sort the languages by name
     asort($langChoices);
     $builder->add('locale', 'choice', array('choices' => $langChoices, 'label' => 'mautic.core.config.form.locale', 'required' => false, 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.locale.tooltip'), 'empty_value' => false));
     $arrayStringTransformer = new ArrayStringTransformer();
     $builder->add($builder->create('trusted_hosts', 'text', array('label' => 'mautic.core.config.form.trusted.hosts', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.trusted.hosts.tooltip'), 'required' => false))->addViewTransformer($arrayStringTransformer));
     $builder->add($builder->create('trusted_proxies', 'text', array('label' => 'mautic.core.config.form.trusted.proxies', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.trusted.proxies.tooltip'), 'required' => false))->addViewTransformer($arrayStringTransformer));
     $arrayLinebreakTransformer = new ArrayLinebreakTransformer();
     $builder->add($builder->create('do_not_track_ips', 'textarea', array('label' => 'mautic.core.config.form.do_not_track_ips', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.do_not_track_ips.tooltip'), 'required' => false))->addViewTransformer($arrayLinebreakTransformer));
     $builder->add('rememberme_key', 'text', array('label' => 'mautic.core.config.form.rememberme.key', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.rememberme.key.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     $builder->add('rememberme_lifetime', 'text', array('label' => 'mautic.core.config.form.rememberme.lifetime', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.rememberme.lifetime.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     $builder->add('rememberme_path', 'text', array('label' => 'mautic.core.config.form.rememberme.path', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.rememberme.path.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     $builder->add('rememberme_domain', 'text', array('label' => 'mautic.core.config.form.rememberme.domain', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.rememberme.domain.tooltip'), 'required' => false));
     $builder->add('default_pagelimit', 'choice', array('choices' => array(5 => 'mautic.core.pagination.5', 10 => 'mautic.core.pagination.10', 15 => 'mautic.core.pagination.15', 20 => 'mautic.core.pagination.20', 25 => 'mautic.core.pagination.25', 30 => 'mautic.core.pagination.30', 50 => 'mautic.core.pagination.50', 100 => 'mautic.core.pagination.100'), 'expanded' => false, 'multiple' => false, 'label' => 'mautic.core.config.form.default.pagelimit', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.default.pagelimit.tooltip'), 'required' => false, 'empty_value' => false));
     $builder->add('default_timezone', 'timezone', array('label' => 'mautic.core.config.form.default.timezone', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.default.timezone.tooltip'), 'multiple' => false, 'empty_value' => 'mautic.user.user.form.defaulttimezone', 'required' => false));
     $builder->add('date_format_full', 'text', array('label' => 'mautic.core.config.form.date.format.full', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.date.format.full.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     $builder->add('date_format_short', 'text', array('label' => 'mautic.core.config.form.date.format.short', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.date.format.short.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     $builder->add('date_format_dateonly', 'text', array('label' => 'mautic.core.config.form.date.format.dateonly', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.date.format.dateonly.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     $builder->add('date_format_timeonly', 'text', array('label' => 'mautic.core.config.form.date.format.timeonly', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.date.format.timeonly.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     // Search for IP Services
     $bundles = $this->factory->getMauticBundles(true);
     $choices = array();
     foreach ($bundles as $bundle) {
         if (isset($bundle['config']['ip_lookup_services'])) {
             foreach ($bundle['config']['ip_lookup_services'] as $service => $details) {
                 $choices[$service] = $details['display_name'];
             }
         }
     }
     natcasesort($choices);
     $builder->add('ip_lookup_service', 'choice', array('choices' => $choices, 'label' => 'mautic.core.config.form.ip.lookup.service', 'label_attr' => array('class' => 'control-label'), 'required' => false, 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.ip.lookup.service.tooltip')));
     $builder->add('ip_lookup_auth', 'text', array('label' => 'mautic.core.config.form.ip.lookup.auth', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.ip.lookup.auth.tooltip'), 'required' => false));
     $builder->add('transifex_username', 'text', array('label' => 'mautic.core.config.form.transifex.username', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.transifex.username.tooltip', 'autocomplete' => 'off'), 'required' => false));
     $builder->add('transifex_password', 'password', array('label' => 'mautic.core.config.form.transifex.password', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'placeholder' => 'mautic.user.user.form.passwordplaceholder', 'preaddon' => 'fa fa-lock', 'tooltip' => 'mautic.core.config.form.transifex.password.tooltip', 'autocomplete' => 'off'), 'required' => false));
     $builder->add('update_stability', 'choice', array('choices' => array('alpha' => 'mautic.core.config.update_stability.alpha', 'beta' => 'mautic.core.config.update_stability.beta', 'rc' => 'mautic.core.config.update_stability.rc', 'stable' => 'mautic.core.config.update_stability.stable'), 'label' => 'mautic.core.config.form.update.stability', 'required' => false, 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.update.stability.tooltip'), 'empty_value' => false));
     $builder->add('cookie_path', 'text', array('label' => 'mautic.core.config.form.cookie.path', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.cookie.path.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     $builder->add('cookie_domain', 'text', array('label' => 'mautic.core.config.form.cookie.domain', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.cookie.domain.tooltip'), 'required' => false));
     $builder->add('cookie_secure', 'yesno_button_group', array('label' => 'mautic.core.config.form.cookie.secure', 'empty_value' => 'mautic.core.form.default', 'data' => array_key_exists('cookie_secure', $options['data']) && !empty($options['data']['cookie_secure']) ? true : false, 'attr' => array('tooltip' => 'mautic.core.config.form.cookie.secure.tooltip')));
     $builder->add('cookie_httponly', 'yesno_button_group', array('label' => 'mautic.core.config.form.cookie.httponly', 'data' => array_key_exists('cookie_httponly', $options['data']) && !empty($options['data']['cookie_httponly']) ? true : false, 'attr' => array('tooltip' => 'mautic.core.config.form.cookie.httponly.tooltip')));
 }
Exemplo n.º 6
0
 /**
  * @param FactoryInterface $knpFactory
  * @param MatcherInterface $matcher
  * @param MauticFactory    $factory
  */
 public function __construct(FactoryInterface $knpFactory, MatcherInterface $matcher, MauticFactory $factory)
 {
     $this->factory = $knpFactory;
     $this->matcher = $matcher;
     $this->dispatcher = $factory->getDispatcher();
     $this->menuHelper = $factory->getHelper('menu');
 }
Exemplo n.º 7
0
 /**
  * Find and add menu items
  *
  * @param MauticEvents\IconEvent $event
  *
  * @return void
  */
 protected function buildIcons(MauticEvents\IconEvent $event)
 {
     $session = $this->factory->getSession();
     $icons = $session->get('mautic.menu.icons', array());
     if (empty($icons)) {
         $bundles = $this->factory->getMauticBundles(true);
         $menuHelper = $this->factory->getHelper('menu');
         foreach ($bundles as $bundle) {
             if (!empty($bundle['config']['menu']['main'])) {
                 $items = !isset($bundle['config']['menu']['main']['items']) ? $bundle['config']['menu']['main'] : $bundle['config']['menu']['main']['items'];
             }
             if (!empty($items)) {
                 $menuHelper->createMenuStructure($items);
                 foreach ($items as $item) {
                     if (isset($item['iconClass']) && isset($item['id'])) {
                         $id = explode('_', $item['id']);
                         if (isset($id[1])) {
                             // some bundle names are in plural, create also singular item
                             if (substr($id[1], -1) == 's') {
                                 $event->addIcon(rtrim($id[1], 's'), $item['iconClass']);
                             }
                             $event->addIcon($id[1], $item['iconClass']);
                         }
                     }
                 }
             }
         }
         unset($bundles, $menuHelper);
         $icons = $event->getIcons();
         $session->set('mautic.menu.icons', $icons);
     } else {
         $event->setIcons($icons);
     }
 }
Exemplo n.º 8
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     /** @var \Mautic\PluginBundle\Helper\IntegrationHelper $integrationHelper */
     $integrationHelper = $this->factory->getHelper('integration');
     $integrations = '';
     $integrationObjects = $integrationHelper->getIntegrationObjects(null, 'login_button');
     foreach ($integrationObjects as $integrationObject) {
         if ($integrationObject->getIntegrationSettings()->isPublished()) {
             /** @var \Mautic\AssetBundle\Model\AssetModel $model */
             $model = $this->factory->getModel('form');
             $integrations .= $integrationObject->getName() . ",";
             $integration = array('integration' => $integrationObject->getName());
             $builder->add('authUrl_' . $integrationObject->getName(), 'hidden', array('data' => $model->buildUrl('mautic_integration_auth_user', $integration, true, array())));
         }
     }
     $builder->add('integrations', 'hidden', array('data' => $integrations));
 }
Exemplo n.º 9
0
 /**
  * @param Form          $form
  * @param Asset         $asset
  * @param MauticFactory $factory
  * @param               $message
  * @param               $messageMode
  *
  * @return RedirectResponse|Response
  */
 public static function downloadFile(Form $form, Asset $asset, MauticFactory $factory, $message, $messengerMode)
 {
     /** @var \Mautic\AssetBundle\Model\AssetModel $model */
     $model = $factory->getModel('asset');
     $url = $model->generateUrl($asset, true, ['form', $form->getId()]);
     if ($messengerMode) {
         return ['download' => $url];
     }
     $msg = $message . $factory->getTranslator()->trans('mautic.asset.asset.submitaction.downloadfile.msg', ['%url%' => $url]);
     $analytics = $factory->getHelper('template.analytics')->getCode();
     if (!empty($analytics)) {
         $factory->getHelper('template.assets')->addCustomDeclaration($analytics);
     }
     $logicalName = $factory->getHelper('theme')->checkForTwigTemplate(':' . $factory->getParameter('theme') . ':message.html.php');
     $content = $factory->getTemplating()->renderResponse($logicalName, ['message' => $msg, 'type' => 'notice', 'template' => $factory->getParameter('theme')])->getContent();
     return new Response($content);
 }
Exemplo n.º 10
0
 /**
  * Check to see if a monitored email box is enabled and configured
  *
  * @param $bundleKey
  * @param $folderKey
  *
  * @return bool|array
  */
 public function isMontoringEnabled($bundleKey, $folderKey)
 {
     /** @var \Mautic\EmailBundle\MonitoredEmail\Mailbox $mailboxHelper */
     $mailboxHelper = $this->factory->getHelper('mailbox');
     if ($mailboxHelper->isConfigured($bundleKey, $folderKey)) {
         return $mailboxHelper->getMailboxSettings();
     }
     return false;
 }
Exemplo n.º 11
0
 /**
  * @param       $route
  * @param array $routeParams
  * @param bool  $absolute
  * @param array $clickthrough
  * @param bool  $shortenUrl
  *
  * @return string
  */
 public function buildUrl($route, $routeParams = array(), $absolute = true, $clickthrough = array(), $shortenUrl = false)
 {
     $url = $this->factory->getRouter()->generate($route, $routeParams, $absolute);
     $url .= !empty($clickthrough) ? '?ct=' . $this->encodeArrayForUrl($clickthrough) : '';
     if ($shortenUrl) {
         /** @var UrlHelper $urlHelper */
         $urlHelper = $this->factory->getHelper('url');
         return $urlHelper->buildShortUrl($url);
     }
     return $url;
 }
Exemplo n.º 12
0
 /**
  * Decrypts API keys
  *
  * @param array $keys
  *
  * @return array
  */
 public function decryptApiKeys(array $keys)
 {
     /** @var \Mautic\CoreBundle\Helper\EncryptionHelper $helper */
     $helper = $this->factory->getHelper('encryption');
     $decrypted = array();
     foreach ($keys as $name => $key) {
         $key = $helper->decrypt($key);
         $decrypted[$name] = $key;
     }
     return $decrypted;
 }
Exemplo n.º 13
0
 /**
  * @param        $message
  * @param array  $messageVars
  * @param string $domain
  * @param null   $title
  * @param null   $icon
  * @param bool   $addNotification
  * @param string $type
  */
 public function addBrowserNotification($message, $messageVars = array(), $domain = 'flashes', $title = null, $icon = null, $addNotification = true, $type = 'notice')
 {
     if ($domain == null) {
         $domain = 'flashes';
     }
     $translator = $this->factory->getTranslator();
     if ($domain === false) {
         //message is already translated
         $translatedMessage = $message;
     } else {
         if (isset($messageVars['pluralCount'])) {
             $translatedMessage = $translator->transChoice($message, $messageVars['pluralCount'], $messageVars, $domain);
         } else {
             $translatedMessage = $translator->trans($message, $messageVars, $domain);
         }
     }
     if ($title !== null) {
         $title = $translator->trans($title);
     } else {
         $title = 'Mautic';
     }
     if ($icon == null) {
         $icon = 'media/images/favicon.ico';
     }
     if (strpos($icon, 'http') !== 0) {
         $assetHelper = $this->factory->getHelper('template.assets');
         $icon = $assetHelper->getUrl($icon, null, null, true);
     }
     $session = $this->factory->getSession();
     $browserNotifications = $session->get('mautic.browser.notifications', array());
     $browserNotifications[] = array('message' => $translatedMessage, 'title' => $title, 'icon' => $icon);
     $session->set('mautic.browser.notifications', $browserNotifications);
     if (!defined('MAUTIC_INSTALLER') && $addNotification) {
         switch ($type) {
             case 'warning':
                 $iconClass = "text-warning fa-exclamation-triangle";
                 break;
             case 'error':
                 $iconClass = "text-danger fa-exclamation-circle";
                 break;
             case 'notice':
                 $iconClass = "fa-info-circle";
             default:
                 break;
         }
         //If the user has not interacted with the browser for the last 30 seconds, consider the message unread
         $lastActive = $this->request->get('mauticUserLastActive', 0);
         $isRead = $lastActive > 30 ? 0 : 1;
         $this->addNotification($translatedMessage, null, $isRead, null, $iconClass);
     }
 }
Exemplo n.º 14
0
 /**
  * @param $slots
  * @param Email $entity
  */
 public function processSlots($slots, $entity)
 {
     /** @var \Mautic\CoreBundle\Templating\Helper\SlotsHelper $slotsHelper */
     $slotsHelper = $this->factory->getHelper('template.slots');
     $content = $entity->getContent();
     foreach ($slots as $slot => $slotConfig) {
         if (is_numeric($slot)) {
             $slot = $slotConfig;
             $slotConfig = [];
         }
         $value = isset($content[$slot]) ? $content[$slot] : '';
         $slotsHelper->set($slot, $value);
     }
 }
Exemplo n.º 15
0
 /**
  * @param FormBuilderInterface $builder
  * @param array                $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     /** @var \Mautic\PluginBundle\Helper\IntegrationHelper $helper */
     $helper = $this->factory->getHelper('integration');
     /** @var \MauticPlugin\MauticEmailMarketingBundle\Integration\ConstantContactIntegration $object */
     $object = $helper->getIntegrationObject('ConstantContact');
     $api = $object->getApiHelper();
     try {
         $lists = $api->getLists();
         $choices = [];
         if (!empty($lists)) {
             foreach ($lists as $list) {
                 $choices[$list['id']] = $list['name'];
             }
             asort($choices);
         }
     } catch (\Exception $e) {
         $choices = [];
         $error = $e->getMessage();
     }
     $builder->add('list', 'choice', ['choices' => $choices, 'label' => 'mautic.emailmarketing.list', 'required' => false, 'attr' => ['tooltip' => 'mautic.emailmarketing.list.tooltip']]);
     $builder->add('sendWelcome', 'yesno_button_group', ['label' => 'mautic.emailmarketing.send_welcome', 'data' => !isset($options['data']['sendWelcome']) ? true : $options['data']['sendWelcome']]);
     if (!empty($error)) {
         $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($error) {
             $form = $event->getForm();
             if ($error) {
                 $form['list']->addError(new FormError($error));
             }
         });
     }
     if (isset($options['form_area']) && $options['form_area'] == 'integration') {
         $leadFields = $this->factory->getModel('plugin')->getLeadFields();
         $fields = $object->getFormLeadFields();
         list($specialInstructions, $alertType) = $object->getFormNotes('leadfield_match');
         $builder->add('leadFields', 'integration_fields', ['label' => 'mautic.integration.leadfield_matches', 'required' => true, 'lead_fields' => $leadFields, 'data' => isset($options['data']['leadFields']) ? $options['data']['leadFields'] : [], 'integration_fields' => $fields, 'special_instructions' => $specialInstructions, 'alert_type' => $alertType]);
     }
 }
Exemplo n.º 16
0
 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->translator = $factory->getTranslator();
     $this->em = $factory->getEntityManager();
     $this->model = $factory->getModel('user');
     // Get the list of available languages
     /** @var \Mautic\CoreBundle\Helper\LanguageHelper $languageHelper */
     $languageHelper = $factory->getHelper('language');
     $languages = $languageHelper->fetchLanguages(false, false);
     $langChoices = array();
     foreach ($languages as $code => $langData) {
         $langChoices[$code] = $langData['name'];
     }
     $langChoices = array_merge($langChoices, $factory->getParameter('supported_languages'));
     // Alpha sort the languages by name
     asort($langChoices);
     $this->supportedLanguages = $langChoices;
 }
Exemplo n.º 17
0
 /**
  * @param               $lead
  * @param MauticFactory $factory
  */
 public static function pushLead($config, $lead, MauticFactory $factory)
 {
     /** @var \Mautic\PluginBundle\Helper\IntegrationHelper $integrationHelper */
     $integrationHelper = $factory->getHelper('integration');
     $integration = !empty($config['integration']) ? $config['integration'] : null;
     $feature = empty($integration) ? 'push_lead' : null;
     $services = $integrationHelper->getIntegrationObjects($integration, $feature);
     $success = false;
     foreach ($services as $name => $s) {
         $settings = $s->getIntegrationSettings();
         if (!$settings->isPublished()) {
             continue;
         }
         if (method_exists($s, 'pushLead')) {
             if ($s->pushLead($lead, $config)) {
                 $success = true;
             }
         }
     }
     return $success;
 }
Exemplo n.º 18
0
 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->dateHelper = $factory->getHelper('template.date');
     $this->version = $factory->getVersion();
 }
Exemplo n.º 19
0
 /**
  * @param bool|false $absolute
  *
  * @return mixed
  */
 public function getDefaultAvatar($absolute = false)
 {
     return $this->factory->getHelper('template.assets')->getUrl($this->factory->getSystemPath('assets') . '/images/avatar.png', null, null, $absolute);
 }
Exemplo n.º 20
0
 /**
  * @param FormBuilderInterface $builder
  * @param array                $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('site_url', 'text', array('label' => 'mautic.core.config.form.site.url', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.site.url.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     $builder->add('webroot', 'page_list', array('label' => 'mautic.core.config.form.webroot', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.webroot.tooltip', 'data-placeholder' => $this->factory->getTranslator()->trans('mautic.core.config.form.webroot.dashboard')), 'multiple' => false, 'empty_value' => '', 'required' => false));
     $builder->add('cache_path', 'text', array('label' => 'mautic.core.config.form.cache.path', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.cache.path.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     $builder->add('log_path', 'text', array('label' => 'mautic.core.config.form.log.path', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.log.path.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     $builder->add('image_path', 'text', array('label' => 'mautic.core.config.form.image.path', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.image.path.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     $builder->add('theme', 'theme_list', array('label' => 'mautic.core.config.form.theme', 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.page.form.template.help')));
     $builder->add('mailer_from_name', 'text', array('label' => 'mautic.core.config.form.mailer.from.name', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.mailer.from.name.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     $builder->add('mailer_from_email', 'text', array('label' => 'mautic.core.config.form.mailer.from.email', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.mailer.from.email.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.email.required')), new Email(array('message' => 'mautic.core.email.required')))));
     $builder->add('mailer_return_path', 'text', array('label' => 'mautic.core.config.form.mailer.return.path', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.mailer.return.path.tooltip'), 'required' => false));
     $builder->add('mailer_transport', 'choice', array('choices' => array('mail' => 'mautic.core.config.mailer_transport.mail', 'mautic.transport.mandrill' => 'mautic.core.config.mailer_transport.mandrill', 'mautic.transport.sendgrid' => 'mautic.core.config.mailer_transport.sendgrid', 'mautic.transport.amazon' => 'mautic.core.config.mailer_transport.amazon', 'mautic.transport.postmark' => 'mautic.core.config.mailer_transport.postmark', 'gmail' => 'mautic.core.config.mailer_transport.gmail', 'sendmail' => 'mautic.core.config.mailer_transport.sendmail', 'smtp' => 'mautic.core.config.mailer_transport.smtp'), 'label' => 'mautic.core.config.form.mailer.transport', 'required' => false, 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.mailer.transport.tooltip'), 'empty_value' => false));
     $smtpServiceShowConditions = '{"config_coreconfig_mailer_transport":["smtp"]}';
     $builder->add('mailer_host', 'text', array('label' => 'mautic.core.config.form.mailer.host', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'data-show-on' => $smtpServiceShowConditions, 'tooltip' => 'mautic.core.config.form.mailer.host.tooltip'), 'required' => false));
     $builder->add('mailer_port', 'text', array('label' => 'mautic.core.config.form.mailer.port', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'data-show-on' => $smtpServiceShowConditions, 'tooltip' => 'mautic.core.config.form.mailer.port.tooltip'), 'required' => false));
     $mailerLoginShowConditions = '{
         "config_coreconfig_mailer_auth_mode":[
             "plain",
             "login",
             "cram-md5"
         ], "config_coreconfig_mailer_transport":[
             "mautic.transport.mandrill",
             "mautic.transport.sendgrid",
             "mautic.transport.amazon",
             "mautic.transport.postmark",
             "gmail"
         ]
     }';
     $mailerLoginHideConditions = '{
      "config_coreconfig_mailer_transport":[
             "mail",
             "sendmail"
         ]
     }';
     $builder->add('mailer_auth_mode', 'choice', array('choices' => array('plain' => 'mautic.core.config.mailer_auth_mode.plain', 'login' => 'mautic.core.config.mailer_auth_mode.login', 'cram-md5' => 'mautic.core.config.mailer_auth_mode.cram-md5'), 'label' => 'mautic.core.config.form.mailer.auth.mode', 'label_attr' => array('class' => 'control-label'), 'required' => false, 'attr' => array('class' => 'form-control', 'data-show-on' => $smtpServiceShowConditions, 'tooltip' => 'mautic.core.config.form.mailer.auth.mode.tooltip'), 'empty_value' => 'mautic.core.config.mailer_auth_mode.none'));
     $builder->add('mailer_user', 'text', array('label' => 'mautic.core.config.form.mailer.user', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'data-show-on' => $mailerLoginShowConditions, 'data-hide-on' => $mailerLoginHideConditions, 'tooltip' => 'mautic.core.config.form.mailer.user.tooltip', 'autocomplete' => 'off'), 'required' => false));
     $builder->add('mailer_password', 'password', array('label' => 'mautic.core.config.form.mailer.password', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'placeholder' => 'mautic.user.user.form.passwordplaceholder', 'preaddon' => 'fa fa-lock', 'data-show-on' => $mailerLoginShowConditions, 'data-hide-on' => $mailerLoginHideConditions, 'tooltip' => 'mautic.core.config.form.mailer.password.tooltip', 'autocomplete' => 'off'), 'required' => false));
     $builder->add('mailer_encryption', 'choice', array('choices' => array('ssl' => 'mautic.core.config.mailer_encryption.ssl', 'tls' => 'mautic.core.config.mailer_encryption.tls'), 'label' => 'mautic.core.config.form.mailer.encryption', 'required' => false, 'attr' => array('class' => 'form-control', 'data-show-on' => $smtpServiceShowConditions, 'tooltip' => 'mautic.core.config.form.mailer.encryption.tooltip'), 'empty_value' => 'mautic.core.config.mailer_encryption.none'));
     $builder->add('mailer_test_connection_button', 'standalone_button', array('label' => 'mautic.core.config.form.mailer.transport.test_connection', 'required' => false, 'attr' => array('class' => 'btn btn-success', 'onclick' => 'Mautic.testEmailServerConnection()')));
     $builder->add('mailer_test_send_button', 'standalone_button', array('label' => 'mautic.core.config.form.mailer.transport.test_send', 'required' => false, 'attr' => array('class' => 'btn btn-info', 'onclick' => 'Mautic.testEmailServerConnection(true)')));
     $spoolConditions = '{"config_coreconfig_mailer_spool_type":["memory"]}';
     $builder->add('mailer_spool_type', 'choice', array('choices' => array('memory' => 'mautic.core.config.mailer_spool_type.memory', 'file' => 'mautic.core.config.mailer_spool_type.file'), 'label' => 'mautic.core.config.form.mailer.spool.type', 'label_attr' => array('class' => 'control-label'), 'required' => false, 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.mailer.spool.type.tooltip'), 'empty_value' => false));
     $builder->add('mailer_spool_path', 'text', array('label' => 'mautic.core.config.form.mailer.spool.path', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'data-hide-on' => $spoolConditions, 'tooltip' => 'mautic.core.config.form.mailer.spool.path.tooltip'), 'required' => false));
     $builder->add('mailer_spool_msg_limit', 'text', array('label' => 'mautic.core.config.form.mailer.spool.msg.limit', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'data-hide-on' => $spoolConditions, 'tooltip' => 'mautic.core.config.form.mailer.spool.msg.limit.tooltip'), 'required' => false));
     $builder->add('mailer_spool_time_limit', 'text', array('label' => 'mautic.core.config.form.mailer.spool.time.limit', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'data-hide-on' => $spoolConditions, 'tooltip' => 'mautic.core.config.form.mailer.spool.time.limit.tooltip'), 'required' => false));
     $builder->add('mailer_spool_recover_timeout', 'text', array('label' => 'mautic.core.config.form.mailer.spool.recover.timeout', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'data-hide-on' => $spoolConditions, 'tooltip' => 'mautic.core.config.form.mailer.spool.recover.timeout.tooltip'), 'required' => false));
     $builder->add('mailer_spool_clear_timeout', 'text', array('label' => 'mautic.core.config.form.mailer.spool.clear.timeout', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'data-hide-on' => $spoolConditions, 'tooltip' => 'mautic.core.config.form.mailer.spool.clear.timeout.tooltip'), 'required' => false));
     // Get the list of available languages
     /** @var \Mautic\CoreBundle\Helper\LanguageHelper $languageHelper */
     $languageHelper = $this->factory->getHelper('language');
     $languages = $languageHelper->fetchLanguages(false, false);
     $langChoices = array();
     foreach ($languages as $code => $langData) {
         $langChoices[$code] = $langData['name'];
     }
     $langChoices = array_merge($langChoices, $this->factory->getParameter('supported_languages'));
     // Alpha sort the languages by name
     asort($langChoices);
     $builder->add('locale', 'choice', array('choices' => $langChoices, 'label' => 'mautic.core.config.form.locale', 'required' => false, 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.locale.tooltip'), 'empty_value' => false));
     $arrayStringTransformer = new ArrayStringTransformer();
     $builder->add($builder->create('trusted_hosts', 'text', array('label' => 'mautic.core.config.form.trusted.hosts', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.trusted.hosts.tooltip'), 'required' => false))->addViewTransformer($arrayStringTransformer));
     $builder->add($builder->create('trusted_proxies', 'text', array('label' => 'mautic.core.config.form.trusted.proxies', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.trusted.proxies.tooltip'), 'required' => false))->addViewTransformer($arrayStringTransformer));
     $arrayLinebreakTransformer = new ArrayLinebreakTransformer();
     $builder->add($builder->create('do_not_track_ips', 'textarea', array('label' => 'mautic.core.config.form.do_not_track_ips', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.do_not_track_ips.tooltip'), 'required' => false))->addViewTransformer($arrayLinebreakTransformer));
     $builder->add('rememberme_key', 'text', array('label' => 'mautic.core.config.form.rememberme.key', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.rememberme.key.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     $builder->add('rememberme_lifetime', 'text', array('label' => 'mautic.core.config.form.rememberme.lifetime', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.rememberme.lifetime.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     $builder->add('rememberme_path', 'text', array('label' => 'mautic.core.config.form.rememberme.path', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.rememberme.path.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     $builder->add('rememberme_domain', 'text', array('label' => 'mautic.core.config.form.rememberme.domain', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.rememberme.domain.tooltip'), 'required' => false));
     $builder->add('default_pagelimit', 'choice', array('choices' => array(5 => 'mautic.core.pagination.5', 10 => 'mautic.core.pagination.10', 15 => 'mautic.core.pagination.15', 20 => 'mautic.core.pagination.20', 25 => 'mautic.core.pagination.25', 30 => 'mautic.core.pagination.30', 50 => 'mautic.core.pagination.50', 100 => 'mautic.core.pagination.100'), 'expanded' => false, 'multiple' => false, 'label' => 'mautic.core.config.form.default.pagelimit', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.default.pagelimit.tooltip'), 'required' => false, 'empty_value' => false));
     $builder->add('default_timezone', 'timezone', array('label' => 'mautic.core.config.form.default.timezone', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.default.timezone.tooltip'), 'multiple' => false, 'empty_value' => 'mautic.user.user.form.defaulttimezone', 'required' => false));
     $builder->add('date_format_full', 'text', array('label' => 'mautic.core.config.form.date.format.full', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.date.format.full.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     $builder->add('date_format_short', 'text', array('label' => 'mautic.core.config.form.date.format.short', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.date.format.short.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     $builder->add('date_format_dateonly', 'text', array('label' => 'mautic.core.config.form.date.format.dateonly', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.date.format.dateonly.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     $builder->add('date_format_timeonly', 'text', array('label' => 'mautic.core.config.form.date.format.timeonly', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.date.format.timeonly.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     // TODO - Write an API endpoint listing our supported services and build this list from that
     // see CoreBundle\Entity\IpAddress
     $builder->add('ip_lookup_service', 'choice', array('choices' => array('telize' => 'mautic.core.config.ip_lookup_service.telize', 'freegeoip' => 'mautic.core.config.ip_lookup_service.freegeoip', 'geobytes' => 'mautic.core.config.ip_lookup_service.geobytes', 'ipinfodb' => 'mautic.core.config.ip_lookup_service.ipinfodb', 'geoips' => 'mautic.core.config.ip_lookup_service.geoips', 'maxmind_country' => 'mautic.core.config.ip_lookup_service.maxmind_country', 'maxmind_precision' => 'mautic.core.config.ip_lookup_service.maxmind_precision', 'maxmind_omni' => 'mautic.core.config.ip_lookup_service.maxmind_omni'), 'label' => 'mautic.core.config.form.ip.lookup.service', 'label_attr' => array('class' => 'control-label'), 'required' => false, 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.ip.lookup.service.tooltip')));
     $builder->add('ip_lookup_auth', 'text', array('label' => 'mautic.core.config.form.ip.lookup.auth', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.ip.lookup.auth.tooltip'), 'required' => false));
     $builder->add('transifex_username', 'text', array('label' => 'mautic.core.config.form.transifex.username', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.transifex.username.tooltip', 'autocomplete' => 'off'), 'required' => false));
     $builder->add('transifex_password', 'password', array('label' => 'mautic.core.config.form.transifex.password', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'placeholder' => 'mautic.user.user.form.passwordplaceholder', 'preaddon' => 'fa fa-lock', 'tooltip' => 'mautic.core.config.form.transifex.password.tooltip', 'autocomplete' => 'off'), 'required' => false));
     $builder->add('update_stability', 'choice', array('choices' => array('alpha' => 'mautic.core.config.update_stability.alpha', 'beta' => 'mautic.core.config.update_stability.beta', 'rc' => 'mautic.core.config.update_stability.rc', 'stable' => 'mautic.core.config.update_stability.stable'), 'label' => 'mautic.core.config.form.update.stability', 'required' => false, 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.update.stability.tooltip'), 'empty_value' => false));
     $builder->add('cookie_path', 'text', array('label' => 'mautic.core.config.form.cookie.path', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.cookie.path.tooltip'), 'constraints' => array(new NotBlank(array('message' => 'mautic.core.value.required')))));
     $builder->add('cookie_domain', 'text', array('label' => 'mautic.core.config.form.cookie.domain', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.core.config.form.cookie.domain.tooltip'), 'required' => false));
     $builder->add('cookie_secure', 'yesno_button_group', array('label' => 'mautic.core.config.form.cookie.secure', 'empty_value' => 'mautic.core.form.default', 'data' => array_key_exists('cookie_secure', $options['data']) && !empty($options['data']['cookie_secure']) ? true : false, 'attr' => array('tooltip' => 'mautic.core.config.form.cookie.secure.tooltip')));
     $builder->add('cookie_httponly', 'yesno_button_group', array('label' => 'mautic.core.config.form.cookie.httponly', 'data' => array_key_exists('cookie_httponly', $options['data']) && !empty($options['data']['cookie_httponly']) ? true : false, 'attr' => array('tooltip' => 'mautic.core.config.form.cookie.httponly.tooltip')));
 }
Exemplo n.º 21
0
 public function __construct(MauticFactory $factory)
 {
     $this->helper = $factory->getHelper('template.slots');
 }
Exemplo n.º 22
0
 /**
  * @param FormBuilderInterface $builder
  * @param array                $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     /** @var \Mautic\PluginBundle\Helper\IntegrationHelper $helper */
     $helper = $this->factory->getHelper('integration');
     /** @var \MauticPlugin\MauticEmailMarketingBundle\Integration\MailchimpIntegration $mailchimp */
     $mailchimp = $helper->getIntegrationObject('Mailchimp');
     $api = $mailchimp->getApiHelper();
     try {
         $lists = $api->getLists();
         $choices = array();
         if (!empty($lists)) {
             if ($lists['total']) {
                 foreach ($lists['data'] as $list) {
                     $choices[$list['id']] = $list['name'];
                 }
             }
             asort($choices);
         }
     } catch (\Exception $e) {
         $choices = array();
         $error = $e->getMessage();
     }
     $builder->add('list', 'choice', array('choices' => $choices, 'label' => 'mautic.emailmarketing.list', 'required' => false, 'attr' => array('tooltip' => 'mautic.emailmarketing.list.tooltip', 'onchange' => 'Mautic.getIntegrationLeadFields(\'Mailchimp\', this, {"list": this.value});')));
     $builder->add('doubleOptin', 'yesno_button_group', array('choice_list' => new ChoiceList(array(false, true), array('mautic.core.form.no', 'mautic.core.form.yes')), 'label' => 'mautic.mailchimp.double_optin', 'data' => !isset($options['data']['doubleOptin']) ? true : $options['data']['doubleOptin']));
     $builder->add('sendWelcome', 'yesno_button_group', array('choice_list' => new ChoiceList(array(false, true), array('mautic.core.form.no', 'mautic.core.form.yes')), 'label' => 'mautic.emailmarketing.send_welcome', 'data' => !isset($options['data']['sendWelcome']) ? true : $options['data']['sendWelcome']));
     if (!empty($error)) {
         $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($error) {
             $form = $event->getForm();
             if ($error) {
                 $form['list']->addError(new FormError($error));
             }
         });
     }
     if (isset($options['form_area']) && $options['form_area'] == 'integration') {
         $leadFields = $this->factory->getModel('plugin')->getLeadFields();
         $formModifier = function (FormInterface $form, $data) use($mailchimp, $leadFields) {
             $settings = array('silence_exceptions' => false, 'feature_settings' => array('list_settings' => $data));
             try {
                 $fields = $mailchimp->getFormLeadFields($settings);
                 if (!is_array($fields)) {
                     $fields = array();
                 }
                 $error = '';
             } catch (\Exception $e) {
                 $fields = array();
                 $error = $e->getMessage();
             }
             list($specialInstructions, $alertType) = $mailchimp->getFormNotes('leadfield_match');
             $form->add('leadFields', 'integration_fields', array('label' => 'mautic.integration.leadfield_matches', 'required' => true, 'lead_fields' => $leadFields, 'data' => isset($data['leadFields']) ? $data['leadFields'] : array(), 'integration_fields' => $fields, 'special_instructions' => $specialInstructions, 'alert_type' => $alertType));
             if ($error) {
                 $form->addError(new FormError($error));
             }
         };
         $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($formModifier) {
             $data = $event->getData();
             $formModifier($event->getForm(), $data);
         });
         $builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use($formModifier) {
             $data = $event->getData();
             $formModifier($event->getForm(), $data);
         });
     }
 }