Exemplo n.º 1
0
 /**
  * @author William DURAND <*****@*****.**>
  *
  * @param GetResponseEvent $event
  *
  * @return void
  * @throws AuthenticationException
  * @throws HttpException
  */
 public function handle(GetResponseEvent $event)
 {
     $apiMode = $this->factory->getParameter('api_mode');
     if ($apiMode != 'oauth1') {
         return;
     }
     $request = $event->getRequest();
     if (false === $request->attributes->get('oauth_request_parameters', false)) {
         return;
     }
     $token = new OAuthToken();
     $token->setRequestParameters($request->attributes->get('oauth_request_parameters'));
     $token->setRequestMethod($request->attributes->get('oauth_request_method'));
     $token->setRequestUrl($request->attributes->get('oauth_request_url'));
     try {
         $returnValue = $this->authenticationManager->authenticate($token);
         if ($returnValue instanceof TokenInterface) {
             return $this->securityContext->setToken($returnValue);
         } elseif ($returnValue instanceof Response) {
             return $event->setResponse($returnValue);
         }
     } catch (AuthenticationException $e) {
         throw $e;
     }
     throw new HttpException(401);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->factory = $this->getContainer()->get('mautic.factory');
     $queueMode = $this->factory->getParameter('queue_mode');
     // check to make sure we are in queue mode
     if ($queueMode != 'command_process') {
         $output->writeLn('Webhook Bundle is in immediate process mode. To use the command function change to command mode.');
         return 0;
     }
     $id = $input->getOption('webhook-id');
     /** @var \Mautic\WebhookBundle\Model\WebhookModel $model */
     $model = $this->factory->getModel('webhook');
     if ($id) {
         $webhook = $model->getEntity($id);
         $webhooks = $webhook !== null && $webhook->isPublished() ? array($id => $webhook) : array();
     } else {
         // make sure we only get published webhook entities
         $webhooks = $model->getEntities(array('filter' => array('force' => array(array('column' => 'e.isPublished', 'expr' => 'eq', 'value' => 1)))));
     }
     if (!count($webhooks)) {
         $output->writeln('<error>No published webhooks found. Try again later.</error>');
         return;
     }
     $output->writeLn('<info>Processing Webhooks</info>');
     try {
         $model->processWebhooks($webhooks);
     } catch (\Exception $e) {
         $output->writeLn('<error>' . $e->getMessage() . '</error>');
     }
     $output->writeLn('<info>Webhook Processing Complete</info>');
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function handle(GetResponseEvent $event)
 {
     $apiMode = $this->factory->getParameter('api_mode');
     if ($apiMode != 'oauth2') {
         return;
     }
     parent::handle($event);
 }
Exemplo n.º 4
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.º 5
0
 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->path = $factory->getParameter('cookie_path');
     $this->domain = $factory->getParameter('cookie_domain');
     $this->secure = $factory->getParameter('cookie_secure');
     if ($this->secure == '' || $this->secure == null) {
         $this->secure = $factory->getRequest()->server->get('HTTPS', false);
     }
     $this->httponly = $factory->getParameter('cookie_httponly');
 }
Exemplo n.º 6
0
 /**
  * Load each bundles routing.php file
  *
  * @param mixed $resource
  * @param null  $type
  *
  * @return RouteCollection
  * @throws \RuntimeException
  */
 public function load($resource, $type = null)
 {
     if (true === $this->loaded) {
         throw new \RuntimeException('Do not add the "mautic" loader twice');
     }
     $dispatcher = $this->factory->getDispatcher();
     // Public
     $event = new RouteEvent($this, 'public');
     $dispatcher->dispatch(CoreEvents::BUILD_ROUTE, $event);
     $collection = $event->getCollection();
     // Force all links to be SSL if the site_url parameter is SSL
     $siteUrl = $this->factory->getParameter('site_url');
     $forceSSL = false;
     if (!empty($siteUrl)) {
         $parts = parse_url($siteUrl);
         $forceSSL = !empty($parts['scheme']) && $parts['scheme'] == 'https';
     }
     if ($forceSSL) {
         $collection->setSchemes('https');
     }
     // Secured area - Default
     $event = new RouteEvent($this);
     $dispatcher->dispatch(CoreEvents::BUILD_ROUTE, $event);
     $secureCollection = $event->getCollection();
     // OneupUploader (added behind our secure /s)
     $secureCollection->addCollection($this->import('.', 'uploader'));
     if ($this->factory->getParameter('api_enabled')) {
         //API
         $event = new RouteEvent($this, 'api');
         $dispatcher->dispatch(CoreEvents::BUILD_ROUTE, $event);
         $apiCollection = $event->getCollection();
         $apiCollection->addPrefix('/api');
         if ($forceSSL) {
             $apiCollection->setSchemes('https');
         }
         $collection->addCollection($apiCollection);
     }
     $secureCollection->addPrefix('/s');
     if ($forceSSL) {
         $secureCollection->setSchemes('https');
     }
     $collection->addCollection($secureCollection);
     // Catch all
     $event = new RouteEvent($this, 'catchall');
     $dispatcher->dispatch(CoreEvents::BUILD_ROUTE, $event);
     $lastCollection = $event->getCollection();
     if ($forceSSL) {
         $lastCollection->setSchemes('https');
     }
     $collection->addCollection($lastCollection);
     $this->loaded = true;
     return $collection;
 }
Exemplo n.º 7
0
 /**
  * Retrieves the update data from our home server
  *
  * @param bool $overrideCache
  *
  * @return array
  */
 public function fetchData($overrideCache = false)
 {
     $cacheFile = $this->factory->getSystemPath('cache') . '/lastUpdateCheck.txt';
     // Check if we have a cache file and try to return cached data if so
     if (!$overrideCache && is_readable($cacheFile)) {
         $update = (array) json_decode(file_get_contents($cacheFile));
         // Check if the user has changed the update channel, if so the cache is invalidated
         if ($update['stability'] == $this->factory->getParameter('update_stability')) {
             // If we're within the cache time, return the cached data
             if ($update['checkedTime'] > strtotime('-3 hours')) {
                 return $update;
             }
         }
     }
     // Before processing the update data, send up our metrics
     try {
         // Generate a unique instance ID for the site
         $instanceId = hash('sha1', $this->factory->getParameter('secret_key') . 'Mautic' . $this->factory->getParameter('db_driver'));
         $data = array('application' => 'Mautic', 'version' => $this->factory->getVersion(), 'phpVersion' => PHP_VERSION, 'dbDriver' => $this->factory->getParameter('db_driver'), 'serverOs' => php_uname('s') . ' ' . php_uname('r'), 'instanceId' => $instanceId, 'installSource' => $this->factory->getParameter('install_source', 'Mautic'));
         $this->connector->post('https://updates.mautic.org/stats/send', $data, array(), 10);
     } catch (\Exception $exception) {
         // Not so concerned about failures here, move along
     }
     // Get the update data
     try {
         $appData = array('appVersion' => $this->factory->getVersion(), 'phpVersion' => PHP_VERSION, 'stability' => $this->factory->getParameter('update_stability'));
         $data = $this->connector->post('https://updates.mautic.org/index.php?option=com_mauticdownload&task=checkUpdates', $appData, array(), 10);
         $update = json_decode($data->body);
     } catch (\Exception $exception) {
         // Log the error
         $logger = $this->factory->getLogger();
         $logger->addError('An error occurred while attempting to fetch updates: ' . $exception->getMessage());
         return array('error' => true, 'message' => 'mautic.core.updater.error.fetching.updates');
     }
     if ($data->code != 200) {
         // Log the error
         $logger = $this->factory->getLogger();
         $logger->addError(sprintf('An unexpected %1$s code was returned while attempting to fetch updates.  The message received was: %2$s', $data->code, is_string($data->body) ? $data->body : implode('; ', $data->body)));
         return array('error' => true, 'message' => 'mautic.core.updater.error.fetching.updates');
     }
     // If the user's up-to-date, go no further
     if ($update->latest_version) {
         return array('error' => false, 'message' => 'mautic.core.updater.running.latest.version');
     }
     // Last sanity check, if the $update->version is older than our current version
     if (version_compare($this->factory->getVersion(), $update->version, 'ge')) {
         return array('error' => false, 'message' => 'mautic.core.updater.running.latest.version');
     }
     // The user is able to update to the latest version, cache the data first
     $data = array('error' => false, 'message' => 'mautic.core.updater.update.available', 'version' => $update->version, 'announcement' => $update->announcement, 'package' => $update->package, 'checkedTime' => time(), 'stability' => $this->factory->getParameter('update_stability'));
     file_put_contents($cacheFile, json_encode($data));
     return $data;
 }
Exemplo n.º 8
0
 /**
  * @param        $content
  * @param string $contentType
  * @param null   $charset
  * @param bool   $ignoreTrackingPixel
  * @param bool   $ignoreEmbedImageConversion
  */
 public function setBody($content, $contentType = 'text/html', $charset = null, $ignoreTrackingPixel = false, $ignoreEmbedImageConversion = false)
 {
     if (!$ignoreEmbedImageConversion && $this->factory->getParameter('mailer_convert_embed_images')) {
         $matches = array();
         if (preg_match_all('/<img.+?src=[\\"\'](.+?)[\\"\'].*?>/i', $content, $matches)) {
             $replaces = array();
             foreach ($matches[1] as $match) {
                 if (strpos($match, 'cid:') === false) {
                     $replaces[$match] = $this->message->embed(\Swift_Image::fromPath($match));
                 }
             }
             $content = strtr($content, $replaces);
         }
     }
     if (!$ignoreTrackingPixel && $this->factory->getParameter('mailer_append_tracking_pixel')) {
         // Append tracking pixel
         $trackingImg = '<img style="display: none;" height="1" width="1" src="{tracking_pixel}" alt="Mautic is open source marketing automation" />';
         if (strpos($content, '</body>') !== false) {
             $content = str_replace('</body>', $trackingImg . '</body>', $content);
         } else {
             $content .= $trackingImg;
         }
     }
     // Update the identifier for the content
     $this->contentHash = md5($content . $this->plainText);
     $this->body = array('content' => $content, 'contentType' => $contentType, 'charset' => $charset);
 }
Exemplo n.º 9
0
 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->translator = $factory->getTranslator();
     $this->defaultTheme = $factory->getParameter('theme');
     $this->em = $factory->getEntityManager();
     $this->request = $factory->getRequest();
 }
Exemplo n.º 10
0
 /**
  * @param MauticFactory $factory
  * @param string        $theme
  *
  * @throws BadConfigurationException
  * @throws FileNotFoundException
  */
 public function __construct(MauticFactory $factory, $theme = 'current')
 {
     $this->factory = $factory;
     $this->theme = $theme == 'current' ? $factory->getParameter('theme') : $theme;
     if ($this->theme == null) {
         $this->theme = 'Mauve';
     }
     $this->themeDir = $factory->getSystemPath('themes') . '/' . $this->theme;
     $this->themePath = $factory->getSystemPath('themes_root') . '/' . $this->themeDir;
     //check to make sure the theme exists
     if (!file_exists($this->themePath)) {
         throw new FileNotFoundException($this->theme . ' not found!');
     }
     //get the config
     if (file_exists($this->themePath . '/config.json')) {
         $this->config = json_decode(file_get_contents($this->themePath . '/config.json'), true);
     } elseif (file_exists($this->themePath . '/config.php')) {
         $this->config = (include $this->themePath . '/config.php');
     } else {
         throw new BadConfigurationException($this->theme . ' is missing a required config file');
     }
     if (!isset($this->config['name'])) {
         throw new BadConfigurationException($this->theme . ' does not have a valid config file');
     }
 }
Exemplo n.º 11
0
 /**
  * Check if a bundle is enabled
  *
  * @param string $bundle
  * @param bool   $forceRefresh
  *
  * @return bool
  */
 public function isEnabled($bundle)
 {
     $dbName = $this->factory->getParameter('db_name');
     if (empty($dbName)) {
         //the database hasn't been installed yet
         return false;
     }
     if (!static::$loaded) {
         $this->buildAddonCache();
     }
     // Check if the bundle is registered
     if (isset(static::$addons[$bundle])) {
         return static::$addons[$bundle];
     }
     // If we don't know about the bundle, it isn't properly registered and we will always return false
     return false;
 }
Exemplo n.º 12
0
 /**
  * @param MauticFactory $factory
  *
  * @throws \RuntimeException if the mcrypt extension is not enabled
  */
 public function __construct(MauticFactory $factory)
 {
     // Toss an Exception back if mcrypt is not found
     if (!extension_loaded('mcrypt')) {
         throw new \RuntimeException($factory->getTranslator()->trans('mautic.core.error.no.mcrypt'));
     }
     $this->key = $factory->getParameter('secret_key');
 }
Exemplo n.º 13
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.º 14
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.º 15
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, array('form', $form->getId()));
     if ($messengerMode) {
         return array('download' => $url);
     }
     $msg = $message . $factory->getTranslator()->trans('mautic.asset.asset.submitaction.downloadfile.msg', array('%url%' => $url));
     $content = $factory->getTemplating()->renderResponse('MauticCoreBundle::message.html.php', array('message' => $msg, 'type' => 'notice', 'template' => $factory->getParameter('theme')))->getContent();
     return new Response($content);
 }
Exemplo n.º 16
0
 /**
  * @param int|Asset $asset
  */
 public function attachAsset($asset)
 {
     $model = $this->factory->getModel('asset');
     if (!$asset instanceof Asset) {
         $asset = $model->getEntity($asset);
         if ($asset == null) {
             return;
         }
     }
     if ($asset->isPublished()) {
         $asset->setUploadDir($this->factory->getParameter('upload_dir'));
         $this->assets[$asset->getId()] = $asset;
     }
 }
Exemplo n.º 17
0
 /**
  * Obtains a list of entities as defined by the API URL
  *
  * @return Response
  */
 public function getEntitiesAction()
 {
     $repo = $this->model->getRepository();
     $tableAlias = $repo->getTableAlias();
     $publishedOnly = $this->request->get('published', 0);
     if ($publishedOnly) {
         $this->listFilters[] = array('column' => $tableAlias . '.isPublished', 'expr' => 'eq', 'value' => true);
     }
     $args = array('start' => $this->request->query->get('start', 0), 'limit' => $this->request->query->get('limit', $this->factory->getParameter('default_pagelimit')), 'filter' => array('string' => $this->request->query->get('search', ''), 'force' => $this->listFilters), 'orderBy' => $this->request->query->get('orderBy', ''), 'orderByDir' => $this->request->query->get('orderByDir', 'ASC'), 'withTotalCount' => true);
     $results = $this->model->getEntities($args);
     list($entities, $totalCount) = $this->prepareEntitiesForView($results);
     $view = $this->view(array('total' => $totalCount, $this->entityNameMulti => $entities), Codes::HTTP_OK);
     $this->setSerializationContext($view);
     return $this->handleView($view);
 }
Exemplo n.º 18
0
 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->translator = $factory->getTranslator();
     $this->defaultTheme = $factory->getParameter('theme');
     $this->em = $factory->getEntityManager();
     $this->request = $factory->getRequest();
     $this->countryChoices = FormFieldHelper::getCountryChoices();
     $this->regionChoices = FormFieldHelper::getRegionChoices();
     $this->timezoneChoices = FormFieldHelper::getTimezonesChoices();
     $this->localeChoices = FormFieldHelper::getLocaleChoices();
     $stages = $factory->getModel('stage')->getRepository()->getSimpleList();
     foreach ($stages as $stage) {
         $this->stageChoices[$stage['value']] = $stage['label'];
     }
 }
Exemplo n.º 19
0
 /**
  * Fetches the list of available languages
  *
  * @param bool $overrideCache
  *
  * @return array
  */
 public function fetchLanguages($overrideCache = false, $returnError = true)
 {
     $overrideFile = $this->factory->getParameter('language_list_file');
     if (!empty($overrideFile) && is_readable($overrideFile)) {
         $overrideData = json_decode(file_get_contents($overrideFile), true);
         if (isset($overrideData['languages'])) {
             return $overrideData['languages'];
         } elseif (isset($overrideData['name'])) {
             return $overrideData;
         } else {
             return array();
         }
     }
     // Check if we have a cache file and try to return cached data if so
     if (!$overrideCache && is_readable($this->cacheFile)) {
         $cacheData = json_decode(file_get_contents($this->cacheFile), true);
         // If we're within the cache time, return the cached data
         if ($cacheData['checkedTime'] > strtotime('-12 hours')) {
             return $cacheData['languages'];
         }
     }
     // Get the language data
     try {
         $data = $this->connector->post('https://updates.mautic.org/index.php?option=com_mauticdownload&task=fetchLanguages', array(), null, 10);
         $languages = json_decode($data->body, true);
         $languages = $languages['languages'];
     } catch (\Exception $exception) {
         // Log the error
         $logger = $this->factory->getLogger();
         $logger->addError('An error occurred while attempting to fetch the language list: ' . $exception->getMessage());
         return !$returnError ? array() : array('error' => true, 'message' => 'mautic.core.language.helper.error.fetching.languages');
     }
     if ($data->code != 200) {
         // Log the error
         $logger = $this->factory->getLogger();
         $logger->addError(sprintf('An unexpected %1$s code was returned while attempting to fetch the language.  The message received was: %2$s', $data->code, is_string($data->body) ? $data->body : implode('; ', $data->body)));
         return !$returnError ? array() : array('error' => true, 'message' => 'mautic.core.language.helper.error.fetching.languages');
     }
     // Alphabetize the languages
     ksort($languages);
     // Store to cache
     $cacheData = array('checkedTime' => time(), 'languages' => $languages);
     file_put_contents($this->cacheFile, json_encode($cacheData));
     return $languages;
 }
Exemplo n.º 20
0
 /**
  * Gets a count of integrations
  *
  * @param $plugin
  *
  * @return int
  */
 public function getIntegrationCount($plugin)
 {
     if (!is_array($plugin)) {
         $plugins = $this->factory->getParameter('plugin.bundles');
         if (array_key_exists($plugin, $plugins)) {
             $plugin = $plugins[$plugin];
         } else {
             // It doesn't exist so return 0
             return 0;
         }
     }
     if (is_dir($plugin['directory'] . '/Integration')) {
         $finder = new Finder();
         $finder->files()->name('*Integration.php')->in($plugin['directory'] . '/Integration')->ignoreDotFiles(true);
         return iterator_count($finder);
     }
     return 0;
 }
Exemplo n.º 21
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.º 22
0
 /**
  * @param Lead $lead
  */
 public function applyFrequencyRules(Lead $lead)
 {
     $frequencyRule = $lead->getFrequencyRules();
     /** @var \Mautic\EmailBundle\Model\EmailModel $emailModel */
     $emailModel = $this->factory->getModel('email');
     $statRepo = $emailModel->getStatRepository();
     $now = new \DateTime();
     $channels = $frequencyRule['channels'];
     if (!empty($frequencyRule) and in_array('email', $channels, true)) {
         $frequencyTime = new \DateInterval('P' . $frequencyRule['frequency_time']);
         $frequencyNumber = $frequencyRule['frequency_number'];
     } elseif ($this->factory->getParameter('frequency_number') > 0) {
         $frequencyTime = new \DateInterval('P' . $frequencyRule['frequency_time']);
         $frequencyNumber = $this->factory->getParameter('frequency_number');
     }
     $now->sub($frequencyTime);
     $sentQuery = $statRepo->getLeadStats($lead->getId(), ['fromDate' => $now]);
     if (!empty($sentQuery) and count($sentQuery) < $frequencyNumber) {
         return true;
     } elseif (empty($sentQuery)) {
         return true;
     }
     return false;
 }
Exemplo n.º 23
0
 /**
  * Generates and returns assets
  *
  * @param bool $forceRegeneration
  *
  * @return array
  */
 public function getAssets($forceRegeneration = false)
 {
     static $assets = array();
     if (empty($assets)) {
         $loadAll = true;
         $env = $forceRegeneration ? 'prod' : $this->factory->getEnvironment();
         $rootPath = $this->factory->getSystemPath('assets_root');
         $assetsPath = $this->factory->getSystemPath('assets');
         $assetsFullPath = "{$rootPath}/{$assetsPath}";
         if ($env == 'prod') {
             $loadAll = false;
             //by default, loading should not be required
             //check for libraries and app files and generate them if they don't exist if in prod environment
             $prodFiles = array('css/libraries.css', 'css/app.css', 'js/libraries.js', 'js/app.js');
             foreach ($prodFiles as $file) {
                 if (!file_exists("{$assetsFullPath}/{$file}")) {
                     $loadAll = true;
                     //it's missing so compile it
                     break;
                 }
             }
         }
         if ($loadAll || $forceRegeneration) {
             if ($env == 'prod') {
                 ini_set('max_execution_time', 300);
                 $inProgressFile = "{$assetsFullPath}/generation_in_progress.txt";
                 if (!$forceRegeneration) {
                     while (file_exists($inProgressFile)) {
                         //dummy loop to prevent conflicts if one process is actively regenerating assets
                     }
                 }
                 file_put_contents($inProgressFile, date('r'));
             }
             $modifiedLast = array();
             //get a list of all core asset files
             $bundles = $this->factory->getParameter('bundles');
             $fileTypes = array('css', 'js');
             foreach ($bundles as $bundle) {
                 foreach ($fileTypes as $ft) {
                     if (!isset($modifiedLast[$ft])) {
                         $modifiedLast[$ft] = array();
                     }
                     $dir = "{$bundle['directory']}/Assets/{$ft}";
                     if (file_exists($dir)) {
                         $modifiedLast[$ft] = array_merge($modifiedLast[$ft], $this->findAssets($dir, $ft, $env, $assets));
                     }
                 }
             }
             $modifiedLast = array_merge($modifiedLast, $this->findOverrides($env, $assets));
             //combine the files into their corresponding name and put in the root media folder
             if ($env == "prod") {
                 $checkPaths = array($assetsFullPath, "{$assetsFullPath}/css", "{$assetsFullPath}/js");
                 array_walk($checkPaths, function ($path) {
                     if (!file_exists($path)) {
                         mkdir($path);
                     }
                 });
                 $useMinify = class_exists('\\Minify');
                 foreach ($assets as $type => $groups) {
                     foreach ($groups as $group => $files) {
                         $assetFile = "{$assetsFullPath}/{$type}/{$group}.{$type}";
                         //only refresh if a change has occurred
                         $modified = $forceRegeneration || !file_exists($assetFile) ? true : filemtime($assetFile) < $modifiedLast[$type][$group];
                         if ($modified) {
                             if (file_exists($assetFile)) {
                                 //delete it
                                 unlink($assetFile);
                             }
                             if ($type == 'css') {
                                 $out = fopen($assetFile, 'w');
                                 foreach ($files as $relPath => $details) {
                                     $cssRel = '../../' . dirname($relPath) . '/';
                                     if ($useMinify) {
                                         $content = \Minify::combine(array($details['fullPath']), array('rewriteCssUris' => false, 'minifierOptions' => array('text/css' => array('currentDir' => '', 'prependRelativePath' => $cssRel))));
                                     } else {
                                         $content = file_get_contents($details['fullPath']);
                                         $search = '#url\\((?!\\s*([\'"]?(((?:https?:)?//)|(?:data\\:?:))))\\s*([\'"])?#';
                                         $replace = "url(\$4{$cssRel}";
                                         $content = preg_replace($search, $replace, $content);
                                     }
                                     fwrite($out, $content);
                                 }
                                 fclose($out);
                             } else {
                                 array_walk($files, function (&$file) {
                                     $file = $file['fullPath'];
                                 });
                                 file_put_contents($assetFile, \Minify::combine($files));
                             }
                         }
                     }
                 }
                 unlink($inProgressFile);
             }
         }
         if ($env == 'prod') {
             //return prod generated assets
             $assets = array('css' => array("{$assetsPath}/css/libraries.css?v{$this->version}", "{$assetsPath}/css/app.css?v{$this->version}"), 'js' => array("{$assetsPath}/js/libraries.js?v{$this->version}", "{$assetsPath}/js/app.js?v{$this->version}"));
         } else {
             foreach ($assets as $type => &$typeAssets) {
                 $typeAssets = array_keys($typeAssets);
             }
         }
     }
     return $assets;
 }
Exemplo n.º 24
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.º 25
0
 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->translator = $factory->getTranslator();
     $this->validator = $factory->getValidator();
     $this->apiMode = $factory->getParameter('api_mode');
 }
Exemplo n.º 26
0
 public function __construct(MauticFactory $factory)
 {
     $this->code = htmlspecialchars_decode($factory->getParameter('google_analytics', ''));
 }
Exemplo n.º 27
0
 /**
  * @param $name
  *
  * @return bool|mixed
  */
 protected function getParameter($name)
 {
     return $this->factory->getParameter($name);
 }
Exemplo n.º 28
0
 /**
  * @return bool|mixed
  */
 protected function getBundles()
 {
     return $this->factory->getParameter('bundles');
 }
Exemplo n.º 29
0
 /**
  * @param MauticFactory $factory
  *
  * @return void
  */
 public function setFactory(MauticFactory $factory)
 {
     $this->factory = $factory;
     $this->version = substr(hash('sha1', $this->factory->getParameter('secret_key') . $this->factory->getVersion()), 0, 8);
 }
Exemplo n.º 30
0
 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->formats = array('datetime' => $factory->getParameter('date_format_full'), 'short' => $factory->getParameter('date_format_short'), 'date' => $factory->getParameter('date_format_dateonly'), 'time' => $factory->getParameter('date_format_timeonly'));
     $this->helper = $factory->getDate();
     $this->translator = $factory->getTranslator();
 }