/** * {@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); }); }
/** * @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'); }
/** * @param $tokens * @param $config * @param MauticFactory $factory * @param Lead $lead */ public static function sendEmail($tokens, $config, MauticFactory $factory, Lead $lead) { $mailer = $factory->getMailer(); $emails = !empty($config['to']) ? explode(',', $config['to']) : array(); $mailer->setTo($emails); $leadEmail = $lead->getEmail(); if (!empty($leadEmail)) { // Reply to lead for user convenience $mailer->setReplyTo($leadEmail); } if (!empty($config['cc'])) { $emails = explode(',', $config['cc']); $mailer->setCc($emails); } if (!empty($config['bcc'])) { $emails = explode(',', $config['bcc']); $mailer->setBcc($emails); } $mailer->setSubject($config['subject']); $mailer->setTokens($tokens); $mailer->setBody($config['message']); $mailer->parsePlainText($config['message']); $mailer->send(); if ($config['copy_lead'] && !empty($leadEmail)) { // Send copy to lead $mailer->reset(); $mailer->setTo($leadEmail); $mailer->setSubject($config['subject']); $mailer->setTokens($tokens); $mailer->setBody($config['message']); $mailer->parsePlainText($config['message']); $mailer->send(); } }
/** * @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); }
/** * @param MauticFactory $factory * @param $lead * @param $event * * @throws \Doctrine\ORM\ORMException */ public static function addRemoveLead(MauticFactory $factory, $lead, $event) { /** @var \Mautic\CampaignBundle\Model\CampaignModel $campaignModel */ $campaignModel = $factory->getModel('campaign'); $properties = $event['properties']; $addToCampaigns = $properties['addTo']; $removeFromCampaigns = $properties['removeFrom']; $em = $factory->getEntityManager(); $leadsModified = false; if (!empty($addToCampaigns)) { foreach ($addToCampaigns as $c) { $campaignModel->addLead($em->getReference('MauticCampaignBundle:Campaign', $c), $lead, true); } $leadsModified = true; } if (!empty($removeFromCampaigns)) { foreach ($removeFromCampaigns as $c) { if ($c == 'this') { $c = $event['campaign']['id']; } $campaignModel->removeLead($em->getReference('MauticCampaignBundle:Campaign', $c), $lead, true); } $leadsModified = true; } return $leadsModified; }
/** * {@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>'); }
/** * @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'] . '\')'))); }
/** * @param MatcherInterface $matcher * @param MauticFactory $factory * @param string $charset * @param array $defaultOptions */ public function __construct(MatcherInterface $matcher, MauticFactory $factory, $charset, array $defaultOptions = array()) { $this->engine = $factory->getTemplating(); $this->matcher =& $matcher; $this->defaultOptions = array_merge(array('depth' => null, 'matchingDepth' => null, 'currentAsLink' => true, 'currentClass' => 'active', 'ancestorClass' => 'open', 'firstClass' => 'first', 'lastClass' => 'last', 'template' => 'MauticCoreBundle:Menu:main.html.php', 'compressed' => false, 'allow_safe_labels' => false, 'clear_matcher' => true), $defaultOptions); $this->charset = $charset; }
/** * @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'); } }
/** * Determines the winner of A/B test based on dwell time rates * * @param MauticFactory $factory * @param Page $parent * @param $children * * @return array */ public static function determineDwellTimeTestWinner($factory, $parent, $children) { //find the hits that did not go any further $repo = $factory->getEntityManager()->getRepository('MauticPageBundle:Hit'); $pageIds = array($parent->getId()); foreach ($children as $c) { $pageIds[] = $c->getId(); } $startDate = $parent->getVariantStartDate(); if ($startDate != null && !empty($pageIds)) { //get their bounce rates $counts = $repo->getDwellTimes(array('pageIds' => $pageIds, 'startDate' => $startDate)); $translator = $factory->getTranslator(); $support = array(); if ($counts) { //in order to get a fair grade, we have to compare the averages here since a page that is only shown //25% of the time will have a significantly lower sum than a page shown 75% of the time $avgs = array(); $support['data'] = array(); $support['labels'] = array(); foreach ($counts as $pid => $stats) { $avgs[$pid] = $stats['average']; $support['data'][$translator->trans('mautic.page.abtest.label.dewlltime.average')][] = $stats['average']; $support['labels'][] = $pid . ':' . $stats['title']; } //set max for scales $max = max($avgs); $support['step_width'] = ceil($max / 10) * 10; //get the page ids with the greatest average dwell time $winners = $max > 0 ? array_keys($avgs, $max) : array(); return array('winners' => $winners, 'support' => $support, 'basedOn' => 'page.dwelltime', 'supportTemplate' => 'MauticPageBundle:SubscribedEvents\\AbTest:bargraph.html.php'); } } return array('winners' => array(), 'support' => array(), 'basedOn' => 'page.dwelltime'); }
/** * @param MauticFactory $factory */ public function __construct(MauticFactory $factory) { $this->em = $factory->getEntityManager(); $this->translator = $factory->getTranslator(); $this->model = $factory->getModel('category'); $this->router = $factory->getRouter(); }
/** * @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'); }
/** * {@inheritdoc} */ public function authenticate(TokenInterface $token) { if (!$this->supports($token)) { return null; } $translator = $this->factory->getTranslator(); $requestParameters = $token->getRequestParameters(); $requestMethod = $token->getRequestMethod(); $requestUrl = $token->getRequestUrl(); if ($this->serverService->validateRequest($requestParameters, $requestMethod, $requestUrl)) { $accessToken = $this->tokenProvider->loadAccessTokenByToken($requestParameters['oauth_token']); $user = $accessToken->getUser(); if (null !== $user) { //Recreate token to include user roles in order to be able to avoid CSRF checks with forms $token = new OAuthToken($user->getRoles()); $token->setRequestParameters($requestParameters); $token->setRequestMethod($requestMethod); $token->setRequestUrl($requestUrl); $token->setAuthenticated(true); $token->setUser($user); } return $token; } throw new AuthenticationException($translator->trans('mautic.api.oauth.auth.failed')); }
/** * @param MauticFactory $factory * @param $lead * @param $event * * @return bool|mixed */ public static function sendEmailAction(MauticFactory $factory, $lead, $event) { $emailSent = false; if ($lead instanceof Lead) { $fields = $lead->getFields(); /** @var \Mautic\LeadBundle\Model\LeadModel $leadModel */ $leadModel = $factory->getModel('lead'); $leadCredentials = $leadModel->flattenFields($fields); $leadCredentials['id'] = $lead->getId(); } else { $leadCredentials = $lead; } if (!empty($leadCredentials['email'])) { /** @var \Mautic\EmailBundle\Model\EmailModel $emailModel */ $emailModel = $factory->getModel('email'); $emailId = (int) $event['properties']['email']; $email = $emailModel->getEntity($emailId); if ($email != null && $email->isPublished()) { $options = array('source' => array('campaign', $event['campaign']['id'])); $emailSent = $emailModel->sendEmail($email, $leadCredentials, $options); } } unset($lead, $leadCredentials, $email, $emailModel, $factory); return $emailSent; }
/** * @param $action * * @return array */ public static function sendEmail($tokens, $config, MauticFactory $factory, $lead) { $mailer = $factory->getMailer(); $emails = !empty($config['to']) ? explode(',', $config['to']) : array(); $fields = $lead->getFields(); $email = $fields['core']['email']['value']; if (!empty($email)) { if ($config['copy_lead']) { $emails[] = $email; } $mailer->setReplyTo($email); } $mailer->setTo($emails); if (!empty($config['cc'])) { $emails = explode(',', $config['cc']); $mailer->setCc($emails); } if (!empty($config['bcc'])) { $emails = explode(',', $config['bcc']); $mailer->setBcc($emails); } $mailer->setSubject($config['subject']); $mailer->setTokens($tokens); $mailer->setBody($config['message']); $mailer->parsePlainText($config['message']); $mailer->send(); }
/** * @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(); }
/** * @param array $config * @param Lead $lead * @param MauticFactory $factory * * @return boolean */ public static function send(array $config, Lead $lead, MauticFactory $factory) { /** @var \Mautic\LeadBundle\Model\LeadModel $leadModel */ $leadModel = $factory->getModel('lead.lead'); if ($leadModel->isContactable($lead, 'sms') !== DoNotContact::IS_CONTACTABLE) { return array('failed' => 1); } $leadPhoneNumber = $lead->getFieldValue('mobile'); if (empty($leadPhoneNumber)) { $leadPhoneNumber = $lead->getFieldValue('phone'); } if (empty($leadPhoneNumber)) { return array('failed' => 1); } /** @var \Mautic\SmsBundle\Api\AbstractSmsApi $sms */ $smsApi = $factory->getKernel()->getContainer()->get('mautic.sms.api'); /** @var \Mautic\SmsBundle\Model\SmsModel $smsModel */ $smsModel = $factory->getModel('sms'); $smsId = (int) $config['sms']; /** @var \Mautic\SmsBundle\Entity\Sms $sms */ $sms = $smsModel->getEntity($smsId); if ($sms->getId() !== $smsId) { return array('failed' => 1); } $dispatcher = $factory->getDispatcher(); $event = new SmsSendEvent($sms->getMessage(), $lead); $event->setSmsId($smsId); $dispatcher->dispatch(SmsEvents::SMS_ON_SEND, $event); $metadata = $smsApi->sendSms($leadPhoneNumber, $event->getContent()); // If there was a problem sending at this point, it's an API problem and should be requeued if ($metadata === false) { return false; } return array('type' => 'mautic.sms.sms', 'status' => 'mautic.sms.timeline.status.delivered', 'id' => $sms->getId(), 'name' => $sms->getName(), 'content' => $event->getContent()); }
/** * @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'); }
/** * Convert a non-tracked url to a tracked url. * * @param string $url * @param array $clickthrough * * @return string */ public function convertToTrackedUrl($url, array $clickthrough = []) { /** @var \Mautic\PageBundle\Model\TrackableModel $trackableModel */ $trackableModel = $this->factory->getModel('page.trackable'); /* @var \Mautic\PageBundle\Entity\Redirect $redirect */ $trackable = $trackableModel->getTrackableByUrl($url, 'notification', $clickthrough['notification']); return $trackableModel->generateTrackableUrl($trackable, $clickthrough); }
/** * {@inheritdoc} */ public function handle(GetResponseEvent $event) { $apiMode = $this->factory->getParameter('api_mode'); if ($apiMode != 'oauth2') { return; } parent::handle($event); }
/** * @param MauticFactory $factory */ public function __construct(MauticFactory $factory) { $this->factory = $factory; $this->cacheDir = $factory->getSystemPath('cache', true); $this->env = $factory->getEnvironment(); $this->configFile = $this->factory->getLocalConfigFile(false); $this->containerFile = $this->factory->getKernel()->getContainerFile(); }
/** * Handle bounces & complaints from Amazon. * * @param Request $request * @param MauticFactory $factory * * @return mixed */ public function handleCallbackResponse(Request $request, MauticFactory $factory) { $translator = $factory->getTranslator(); $logger = $factory->getLogger(); $logger->debug('Receiving webhook from Amazon'); $payload = json_decode($request->getContent(), true); return $this->processJsonPayload($payload, $logger, $translator); }
/** * @param string $email * * @return bool */ public function unsubscribe($email) { /** @var \Mautic\LeadBundle\Entity\LeadRepository $repo */ $repo = $this->factory->getEntityManager()->getRepository('MauticLeadBundle:Lead'); $lead = $repo->getLeadByEmail($email); /** @var \Mautic\LeadBundle\Model\LeadModel $leadModel */ $leadModel = $this->factory->getModel('lead.lead'); return $leadModel->addDncForLead($lead, 'notification', null, DoNotContact::UNSUBSCRIBED); }
/** * @param Lead $lead * @param $config * @param MauticFactory $factory * * @return bool */ public static function updateTags(Lead $lead, $config, MauticFactory $factory) { /** @var \Mautic\LeadBundle\Model\LeadModel $leadModel */ $leadModel = $factory->getModel('lead'); $addTags = !empty($config['add_tags']) ? $config['add_tags'] : array(); $removeTags = !empty($config['remove_tags']) ? $config['remove_tags'] : array(); $leadModel->modifyTags($lead, $addTags, $removeTags); return true; }
/** * @param MauticFactory $factory */ public function __construct(MauticFactory $factory) { $choices = $factory->getModel('user')->getRepository()->getEntities(array('filter' => array('force' => array(array('column' => 'u.isPublished', 'expr' => 'eq', 'value' => true))))); foreach ($choices as $choice) { $this->choices[$choice->getId()] = $choice->getName(true); } //sort by language ksort($this->choices); }
/** * @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'))); }
/** * DynamicContentFilterEntryFiltersType constructor. * * @param MauticFactory $factory * @param ListModel $listModel */ public function __construct(MauticFactory $factory, ListModel $listModel) { $operatorChoices = $listModel->getFilterExpressionFunctions(); foreach ($operatorChoices as $key => $value) { if (empty($value['hide'])) { $this->operatorChoices[$key] = $value['label']; } } $this->translator = $factory->getTranslator(); }
/** * @param MauticFactory $factory */ public function __construct(MauticFactory $factory) { $viewOther = $factory->getSecurity()->isGranted('asset:assets:viewother'); $choices = $factory->getModel('asset')->getRepository()->getAssetList('', 0, 0, $viewOther); foreach ($choices as $asset) { $this->choices[$asset['language']][$asset['id']] = $asset['title']; } //sort by language ksort($this->choices); }
/** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $model = $this->factory->getModel('lead.list'); $lists = $model->getUserLists(); $segments = []; $segments[0] = $this->factory->getTranslator()->trans('mautic.lead.all.leads'); foreach ($lists as $list) { $segments[$list['id']] = $list['name']; } $builder->add('flag', 'choice', ['label' => 'mautic.lead.list.filter', 'multiple' => true, 'choices' => $segments, 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control'], 'required' => false]); }
/** * 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; }