From a292d28bf04d611c1d18c804fbdd56f1294bb970 Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Mon, 21 Nov 2016 16:51:44 +0100 Subject: [PATCH 001/510] HTML area for forms --- app/bundles/FormBundle/Config/config.php | 4 ++ .../Entity/SubmissionRepository.php | 2 +- .../FormBundle/Form/Type/FieldType.php | 21 ++++++++ .../Form/Type/FormFieldHTMLType.php | 53 +++++++++++++++++++ .../FormBundle/Helper/FormFieldHelper.php | 1 + app/bundles/FormBundle/Model/FormModel.php | 2 +- .../Translations/en_US/messages.ini | 2 + .../FormBundle/Views/Field/freehtml.html.php | 32 +++++++++++ 8 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 app/bundles/FormBundle/Form/Type/FormFieldHTMLType.php create mode 100644 app/bundles/FormBundle/Views/Field/freehtml.html.php diff --git a/app/bundles/FormBundle/Config/config.php b/app/bundles/FormBundle/Config/config.php index 2004edbfae6..d91eeae9f31 100644 --- a/app/bundles/FormBundle/Config/config.php +++ b/app/bundles/FormBundle/Config/config.php @@ -195,6 +195,10 @@ 'class' => 'Mautic\FormBundle\Form\Type\FormFieldTextType', 'alias' => 'formfield_text', ], + 'mautic.form.type.field_propertyhtml' => [ + 'class' => 'Mautic\FormBundle\Form\Type\FormFieldHTMLType', + 'alias' => 'formfield_html', + ], 'mautic.form.type.field_propertyplaceholder' => [ 'class' => 'Mautic\FormBundle\Form\Type\FormFieldPlaceholderType', 'alias' => 'formfield_placeholder', diff --git a/app/bundles/FormBundle/Entity/SubmissionRepository.php b/app/bundles/FormBundle/Entity/SubmissionRepository.php index 1a97cd51091..2cfed2a4809 100644 --- a/app/bundles/FormBundle/Entity/SubmissionRepository.php +++ b/app/bundles/FormBundle/Entity/SubmissionRepository.php @@ -50,7 +50,7 @@ public function getEntities($args = []) //DBAL if (!isset($args['viewOnlyFields'])) { - $args['viewOnlyFields'] = ['button', 'freetext', 'pagebreak', 'captcha']; + $args['viewOnlyFields'] = ['button', 'freetext', 'freehtml', 'pagebreak', 'captcha']; } $viewOnlyFields = array_map(function ($value) { return '"'.$value.'"'; diff --git a/app/bundles/FormBundle/Form/Type/FieldType.php b/app/bundles/FormBundle/Form/Type/FieldType.php index 4c1a00b95bf..94dcbfc2128 100644 --- a/app/bundles/FormBundle/Form/Type/FieldType.php +++ b/app/bundles/FormBundle/Form/Type/FieldType.php @@ -95,6 +95,15 @@ public function buildForm(FormBuilderInterface $builder, array $options) $inputAttributesText = 'mautic.form.field.form.freetext_attributes'; $labelAttributesText = 'mautic.form.field.form.header_attributes'; + // Allow html + $cleanMasks['properties'] = 'html'; + break; + case 'freehtml': + $addHelpMessage = $addDefaultValue = $addIsRequired = $addLeadFieldList = $addSaveResult = $addBehaviorFields = false; + $labelText = 'mautic.form.field.form.header'; + $showLabelText = 'mautic.form.field.form.showheader'; + $inputAttributesText = 'mautic.form.field.form.freehtml_attributes'; + $labelAttributesText = 'mautic.form.field.form.header_attributes'; // Allow html $cleanMasks['properties'] = 'html'; break; @@ -449,6 +458,18 @@ public function buildForm(FormBuilderInterface $builder, array $options) ] ); break; + case 'freehtml': + $builder->add( + 'properties', + 'formfield_html', + [ + 'required' => false, + 'label' => false, + 'editor' => true, + 'data' => $propertiesData, + ] + ); + break; case 'date': case 'email': case 'number': diff --git a/app/bundles/FormBundle/Form/Type/FormFieldHTMLType.php b/app/bundles/FormBundle/Form/Type/FormFieldHTMLType.php new file mode 100644 index 00000000000..c005ccf59e4 --- /dev/null +++ b/app/bundles/FormBundle/Form/Type/FormFieldHTMLType.php @@ -0,0 +1,53 @@ +add('text', 'textarea', [ + 'label' => 'mautic.form.field.type.freehtml', + 'label_attr' => ['class' => 'control-label'], + 'attr' => ['class' => 'form-control', 'style' => 'min-height:150px'], + 'required' => true, + ]); + } + + /** + * {@inheritdoc} + */ + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver->setDefaults([ + 'editor' => false, + ]); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'formfield_html'; + } +} diff --git a/app/bundles/FormBundle/Helper/FormFieldHelper.php b/app/bundles/FormBundle/Helper/FormFieldHelper.php index 6923281c26e..90705d31711 100644 --- a/app/bundles/FormBundle/Helper/FormFieldHelper.php +++ b/app/bundles/FormBundle/Helper/FormFieldHelper.php @@ -56,6 +56,7 @@ class FormFieldHelper extends AbstractFormFieldHelper ], ], 'freetext' => [], + 'freehtml' => [], 'hidden' => [], 'number' => [ 'filter' => 'float', diff --git a/app/bundles/FormBundle/Model/FormModel.php b/app/bundles/FormBundle/Model/FormModel.php index b664cca49b7..e53c277e031 100644 --- a/app/bundles/FormBundle/Model/FormModel.php +++ b/app/bundles/FormBundle/Model/FormModel.php @@ -651,7 +651,7 @@ public function getCustomComponents() $customComponents['validators'] = $event->getValidators(); // Generate a list of fields that are not persisted to the database by default - $notPersist = ['button', 'captcha', 'freetext', 'pagebreak']; + $notPersist = ['button', 'captcha', 'freetext', 'freehtml', 'pagebreak']; foreach ($customComponents['fields'] as $type => $field) { if (isset($field['builderOptions']) && isset($field['builderOptions']['addSaveResult']) && false === $field['builderOptions']['addSaveResult']) { $notPersist[] = $type; diff --git a/app/bundles/FormBundle/Translations/en_US/messages.ini b/app/bundles/FormBundle/Translations/en_US/messages.ini index 1d178201494..28bb34691a4 100644 --- a/app/bundles/FormBundle/Translations/en_US/messages.ini +++ b/app/bundles/FormBundle/Translations/en_US/messages.ini @@ -52,6 +52,7 @@ mautic.form.field.form.container_attr="Field container attributes" mautic.form.field.form.value="Value" mautic.form.field.form.emptyvalue="Empty Value" mautic.form.field.form.freetext_attributes="Description text attributes" +mautic.form.field.form.freehtml_attributes="HTML text attributes" mautic.form.field.form.header="Header" mautic.form.field.form.header_attributes="Header attributes" mautic.form.field.form.helpmessage="Help message" @@ -93,6 +94,7 @@ mautic.form.field.type.button="Button" mautic.form.field.type.captcha="Captcha" mautic.form.field.type.checkboxgrp="Checkbox group" mautic.form.field.type.freetext="Description area" +mautic.form.field.type.freehtml="HTML area" mautic.form.field.type.hidden="Hidden" mautic.form.field.type.password="Password" mautic.form.field.type.pagebreak="Page break" diff --git a/app/bundles/FormBundle/Views/Field/freehtml.html.php b/app/bundles/FormBundle/Views/Field/freehtml.html.php new file mode 100644 index 00000000000..284c16aa465 --- /dev/null +++ b/app/bundles/FormBundle/Views/Field/freehtml.html.php @@ -0,0 +1,32 @@ + + {$field['label']} + +HTML; + +$html = <<{$label} +
+ {$properties['text']} +
+ + +HTML; + +echo $html; From 2305117aeca9b01dd1fcd75af755fced2ebaa37b Mon Sep 17 00:00:00 2001 From: arul Date: Fri, 9 Dec 2016 11:07:38 +0530 Subject: [PATCH 002/510] added new mautic datetime form field --- .../Translations/en_US/messages.ini | 1 + .../FormBundle/Helper/FormFieldHelper.php | 1 + .../FormBundle/Views/Field/datetime.html.php | 21 +++++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 app/bundles/FormBundle/Views/Field/datetime.html.php diff --git a/app/bundles/CoreBundle/Translations/en_US/messages.ini b/app/bundles/CoreBundle/Translations/en_US/messages.ini index 5c644f99a1b..5e80dd2a994 100644 --- a/app/bundles/CoreBundle/Translations/en_US/messages.ini +++ b/app/bundles/CoreBundle/Translations/en_US/messages.ini @@ -367,6 +367,7 @@ mautic.core.translations="Translations" mautic.core.translation_of="Translation of %parent%" mautic.core.type="Type" mautic.core.type.date="Date" +mautic.core.type.datetime="Date/Time" mautic.core.type.boolean="Boolean" mautic.core.type.country="List - Country" mautic.core.type.email="Email" diff --git a/app/bundles/FormBundle/Helper/FormFieldHelper.php b/app/bundles/FormBundle/Helper/FormFieldHelper.php index 6923281c26e..dd83da8b8b1 100644 --- a/app/bundles/FormBundle/Helper/FormFieldHelper.php +++ b/app/bundles/FormBundle/Helper/FormFieldHelper.php @@ -49,6 +49,7 @@ class FormFieldHelper extends AbstractFormFieldHelper 'checkboxgrp' => [], 'country' => [], 'date' => [], + 'datetime' => [], 'email' => [ 'filter' => 'email', 'constraints' => [ diff --git a/app/bundles/FormBundle/Views/Field/datetime.html.php b/app/bundles/FormBundle/Views/Field/datetime.html.php new file mode 100644 index 00000000000..a30d0daa07f --- /dev/null +++ b/app/bundles/FormBundle/Views/Field/datetime.html.php @@ -0,0 +1,21 @@ +render( + 'MauticFormBundle:Field:text.html.php', + [ + 'field' => $field, + 'inForm' => (isset($inForm)) ? $inForm : false, + 'type' => 'datetime-local', + 'id' => $id, + 'formId' => (isset($formId)) ? $formId : 0, + 'formName' => (isset($formName)) ? $formName : '', + ] +); From 25c7a3c196c5215a34a01938f119935f4bc876e6 Mon Sep 17 00:00:00 2001 From: Arul Raj Date: Mon, 9 Jan 2017 16:49:39 +0530 Subject: [PATCH 003/510] Email stats showing incorrect data in A/B testing mode --- app/bundles/CoreBundle/Helper/Chart/ChartQuery.php | 3 +-- app/bundles/EmailBundle/Model/EmailModel.php | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/bundles/CoreBundle/Helper/Chart/ChartQuery.php b/app/bundles/CoreBundle/Helper/Chart/ChartQuery.php index 6217dee11e1..def65780e4a 100644 --- a/app/bundles/CoreBundle/Helper/Chart/ChartQuery.php +++ b/app/bundles/CoreBundle/Helper/Chart/ChartQuery.php @@ -105,8 +105,7 @@ public function applyFilters(&$query, $filters) } } else { if (is_array($value)) { - $query->andWhere('t.'.$column.' IN(:'.$valId.')'); - $query->setParameter($valId, implode(',', $value)); + $query->andWhere($query->expr()->in('t.'.$column, $value)); } else { $query->andWhere('t.'.$column.' = :'.$valId); $query->setParameter($valId, $value); diff --git a/app/bundles/EmailBundle/Model/EmailModel.php b/app/bundles/EmailBundle/Model/EmailModel.php index 4d0e541aa86..966144c4594 100644 --- a/app/bundles/EmailBundle/Model/EmailModel.php +++ b/app/bundles/EmailBundle/Model/EmailModel.php @@ -1797,8 +1797,7 @@ public function getEmailsLineChartData($unit, \DateTime $dateFrom, \DateTime $da if (isset($filter['email_id'])) { if (is_array($filter['email_id'])) { - $q->andWhere('cut.channel_id IN(:channel_id)'); - $q->setParameter('channel_id', implode(',', $filter['email_id'])); + $q->andWhere($q->expr()->in('cut.channel_id', $filter['email_id'])); } else { $q->andWhere('cut.channel_id = :channel_id'); $q->setParameter('channel_id', $filter['email_id']); From 22840976d442ff957a126ea06c98d162b8b4df16 Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Fri, 20 Jan 2017 10:33:37 +0100 Subject: [PATCH 004/510] Init commit --- .../NotificationBundle/Config/config.php | 13 ++- .../EventListener/BuildJsSubscriber.php | 28 +++++ .../EventListener/PageSubscriber.php | 68 +----------- .../Form/Type/ConfigType.php | 14 +++ .../Helper/NotificationHelper.php | 103 +++++++++++++++++- .../Translations/en_US/messages.ini | 4 +- 6 files changed, 161 insertions(+), 69 deletions(-) diff --git a/app/bundles/NotificationBundle/Config/config.php b/app/bundles/NotificationBundle/Config/config.php index 2727ab45b9c..a95a91166a0 100644 --- a/app/bundles/NotificationBundle/Config/config.php +++ b/app/bundles/NotificationBundle/Config/config.php @@ -28,11 +28,14 @@ 'class' => 'Mautic\NotificationBundle\EventListener\PageSubscriber', 'arguments' => [ 'templating.helper.assets', - 'mautic.helper.core_parameters', + 'mautic.helper.core_parameters' ], ], 'mautic.core.js.subscriber' => [ 'class' => 'Mautic\NotificationBundle\EventListener\BuildJsSubscriber', + 'arguments' => [ + 'mautic.helper.notification', + ], ], 'mautic.notification.notificationbundle.subscriber' => [ 'class' => 'Mautic\NotificationBundle\EventListener\NotificationSubscriber', @@ -74,8 +77,13 @@ 'helpers' => [ 'mautic.helper.notification' => [ 'class' => 'Mautic\NotificationBundle\Helper\NotificationHelper', - 'arguments' => 'mautic.factory', 'alias' => 'notification_helper', + 'arguments' => [ + 'mautic.factory', + 'templating.helper.assets', + 'mautic.helper.core_parameters', + 'router', + ], ], ], 'other' => [ @@ -172,6 +180,7 @@ 'parameters' => [ 'notification_enabled' => false, 'notification_landing_page_enabled' => true, + 'notification_tracking_page_enabled' => false, 'notification_app_id' => null, 'notification_rest_api_key' => null, 'notification_safari_web_id' => null, diff --git a/app/bundles/NotificationBundle/EventListener/BuildJsSubscriber.php b/app/bundles/NotificationBundle/EventListener/BuildJsSubscriber.php index 4995da515d1..1446f7d1b98 100644 --- a/app/bundles/NotificationBundle/EventListener/BuildJsSubscriber.php +++ b/app/bundles/NotificationBundle/EventListener/BuildJsSubscriber.php @@ -15,12 +15,30 @@ use Mautic\CoreBundle\Event\BuildJsEvent; use Mautic\CoreBundle\EventListener\CommonSubscriber; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; +use Mautic\NotificationBundle\Helper\NotificationHelper; + /** * Class BuildJsSubscriber. */ class BuildJsSubscriber extends CommonSubscriber { + /** + * @var NotificationHelper + */ + protected $notificationHelper; + + /** + * PageSubscriber constructor. + * + * @param NotificationHelper $notificationHelper + */ + public function __construct(NotificationHelper $notificationHelper) + { + $this->notificationHelper = $notificationHelper; + } + + /** * @return array */ @@ -44,6 +62,16 @@ public function onBuildJs(BuildJsEvent $event) $js = <<notificationHelper->getScript()} + + var subscribeButton = document.getElementById('mautic-notification-subscribe'); if (subscribeButton) { diff --git a/app/bundles/NotificationBundle/EventListener/PageSubscriber.php b/app/bundles/NotificationBundle/EventListener/PageSubscriber.php index 878ec95c6fc..19111a2687e 100644 --- a/app/bundles/NotificationBundle/EventListener/PageSubscriber.php +++ b/app/bundles/NotificationBundle/EventListener/PageSubscriber.php @@ -60,72 +60,12 @@ public static function getSubscribedEvents() */ public function onPageDisplay(PageDisplayEvent $event) { - if (!$this->coreParametersHelper->getParameter('notification_landing_page_enabled')) { - return; - } - $appId = $this->coreParametersHelper->getParameter('notification_app_id'); - $safariWebId = $this->coreParametersHelper->getParameter('notification_safari_web_id'); - $welcomenotificationEnabled = $this->coreParametersHelper->getParameter('welcomenotification_enabled'); - - $this->assetsHelper->addScript($this->router->generate('mautic_js', [], UrlGeneratorInterface::ABSOLUTE_URL), 'onPageDisplay_headClose', true, 'mautic_js'); - $this->assetsHelper->addScript('https://cdn.onesignal.com/sdks/OneSignalSDK.js', 'onPageDisplay_headClose'); - - $manifestUrl = $this->router->generate('mautic_onesignal_manifest'); - $this->assetsHelper->addCustomDeclaration('', 'onPageDisplay_headClose'); - - $leadAssociationUrl = $this->router->generate('mautic_subscribe_notification', [], UrlGeneratorInterface::ABSOLUTE_URL); - - $welcomenotificationText = ''; - if (!$welcomenotificationEnabled) { - $welcomenotificationText = 'welcomeNotification: { "disable": true },'; - } - $oneSignalInit = <<coreParametersHelper->getParameter('notification_landing_page_enabled')) { + $script = 'disable_notification = true;'; } - }); - - // Just to be sure we've grabbed the ID - window.onbeforeunload = function() { - OneSignal.getUserId(function(userId) { - if (userId) { - postUserIdToMautic(userId); - } - }); - }; -JS; - $this->assetsHelper->addScriptDeclaration($oneSignalInit, 'onPageDisplay_headClose'); + $this->assetsHelper->addScriptDeclaration($script, 'onPageDisplay_headClose'); } } diff --git a/app/bundles/NotificationBundle/Form/Type/ConfigType.php b/app/bundles/NotificationBundle/Form/Type/ConfigType.php index 0f1f9582f99..4d483886b2a 100644 --- a/app/bundles/NotificationBundle/Form/Type/ConfigType.php +++ b/app/bundles/NotificationBundle/Form/Type/ConfigType.php @@ -45,6 +45,20 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'data' => (bool) $options['data']['notification_landing_page_enabled'], 'attr' => [ 'tooltip' => 'mautic.notification.config.form.notification.landingpage.enabled.tooltip', + 'data-show-on' => '{"config_notificationconfig_notification_enabled_1":"checked"}', + ], + ] + ); + + $builder->add( + 'notification_tracking_page_enabled', + 'yesno_button_group', + [ + 'label' => 'mautic.notification.config.form.notification.trackingpage.enabled', + 'data' => (bool) $options['data']['notification_tracking_page_enabled'], + 'attr' => [ + 'tooltip' => 'mautic.notification.config.form.notification.trackingpage.enabled.tooltip', + 'data-show-on' => '{"config_notificationconfig_notification_enabled_1":"checked"}', ], ] ); diff --git a/app/bundles/NotificationBundle/Helper/NotificationHelper.php b/app/bundles/NotificationBundle/Helper/NotificationHelper.php index 72ca6da2f6f..683e6af1347 100644 --- a/app/bundles/NotificationBundle/Helper/NotificationHelper.php +++ b/app/bundles/NotificationBundle/Helper/NotificationHelper.php @@ -14,6 +14,13 @@ use Mautic\CoreBundle\Factory\MauticFactory; use Mautic\LeadBundle\Entity\DoNotContact; use Mautic\LeadBundle\Entity\Lead; +use Mautic\CoreBundle\Helper\CoreParametersHelper; +use Mautic\CoreBundle\Templating\Helper\AssetsHelper; +use Symfony\Bundle\FrameworkBundle\Routing\Router; +use Symfony\Component\Routing\RouterInterface; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; + + class NotificationHelper { @@ -23,11 +30,33 @@ class NotificationHelper protected $factory; /** - * @param MauticFactory $factory + * @var CoreParametersHelper + */ + protected $coreParametersHelper; + + /** + * @var AssetsHelper + */ + protected $assetsHelper; + + /** + * @var Router */ - public function __construct(MauticFactory $factory) + protected $router; + + /** + * PageSubscriber constructor. + * + * @param AssetsHelper $assetsHelper + * @param CoreParametersHelper $coreParametersHelper + * @param Router $router + */ + public function __construct(MauticFactory $factory, AssetsHelper $assetsHelper, CoreParametersHelper $coreParametersHelper, Router $router) { $this->factory = $factory; + $this->assetsHelper = $assetsHelper; + $this->coreParametersHelper = $coreParametersHelper; + $this->router = $router; } /** @@ -47,4 +76,74 @@ public function unsubscribe($email) return $leadModel->addDncForLead($lead, 'notification', null, DoNotContact::UNSUBSCRIBED); } + + /** + * @param string $email + * + * @return bool + */ + public function getScript() + { +// if (!$this->coreParametersHelper->getParameter('notification_landing_page_enabled')) { +// return; +// } + $appId = $this->coreParametersHelper->getParameter('notification_app_id'); + $safariWebId = $this->coreParametersHelper->getParameter('notification_safari_web_id'); + $welcomenotificationEnabled = $this->coreParametersHelper->getParameter('welcomenotification_enabled'); + + $leadAssociationUrl = $this->router->generate('mautic_subscribe_notification', [], UrlGeneratorInterface::ABSOLUTE_URL); + + $welcomenotificationText = ''; + if (!$welcomenotificationEnabled) { + $welcomenotificationText = 'welcomeNotification: { "disable": true },'; + } + + $oneSignalInit = << Date: Fri, 20 Jan 2017 16:40:39 +0100 Subject: [PATCH 005/510] Add script to BuildJSSubscriber --- .../NotificationBundle/Config/config.php | 1 + .../EventListener/BuildJsSubscriber.php | 26 ++++---- .../Helper/NotificationHelper.php | 62 +++++++++++++++---- 3 files changed, 63 insertions(+), 26 deletions(-) diff --git a/app/bundles/NotificationBundle/Config/config.php b/app/bundles/NotificationBundle/Config/config.php index a95a91166a0..17511f355f3 100644 --- a/app/bundles/NotificationBundle/Config/config.php +++ b/app/bundles/NotificationBundle/Config/config.php @@ -83,6 +83,7 @@ 'templating.helper.assets', 'mautic.helper.core_parameters', 'router', + 'request_stack', ], ], ], diff --git a/app/bundles/NotificationBundle/EventListener/BuildJsSubscriber.php b/app/bundles/NotificationBundle/EventListener/BuildJsSubscriber.php index 1446f7d1b98..1c5383b238d 100644 --- a/app/bundles/NotificationBundle/EventListener/BuildJsSubscriber.php +++ b/app/bundles/NotificationBundle/EventListener/BuildJsSubscriber.php @@ -23,6 +23,7 @@ */ class BuildJsSubscriber extends CommonSubscriber { + /** * @var NotificationHelper */ @@ -33,8 +34,9 @@ class BuildJsSubscriber extends CommonSubscriber * * @param NotificationHelper $notificationHelper */ - public function __construct(NotificationHelper $notificationHelper) - { + public function __construct( + NotificationHelper $notificationHelper + ) { $this->notificationHelper = $notificationHelper; } @@ -54,24 +56,20 @@ public static function getSubscribedEvents() */ public function onBuildJs(BuildJsEvent $event) { - $subscribeUrl = $this->router->generate('mautic_notification_popup', [], UrlGeneratorInterface::ABSOLUTE_URL); + $subscribeUrl = $this->router->generate('mautic_notification_popup', [], UrlGeneratorInterface::ABSOLUTE_URL); $subscribeTitle = 'Subscribe To Notifications'; - $width = 450; - $height = 450; + $width = 450; + $height = 450; $js = <<notificationHelper->getHeaderScript()} + MauticJS.notification = { init: function () { - MauticJS.insertScript('https://cdn.onesignal.com/sdks/OneSignalSDK.js'); - var scrpt = document.createElement('link'); - scrpt.rel ='manifest'; - scrpt.href ='/manifest.json'; - var head = document.getElementsByTagName('head')[0]; - head.appendChild(scrpt); - + {$this->notificationHelper->getScript()} - var subscribeButton = document.getElementById('mautic-notification-subscribe'); if (subscribeButton) { @@ -114,4 +112,4 @@ public function onBuildJs(BuildJsEvent $event) $event->appendJs($js, 'Mautic Notification JS'); } -} + } diff --git a/app/bundles/NotificationBundle/Helper/NotificationHelper.php b/app/bundles/NotificationBundle/Helper/NotificationHelper.php index 683e6af1347..35e5bd87a30 100644 --- a/app/bundles/NotificationBundle/Helper/NotificationHelper.php +++ b/app/bundles/NotificationBundle/Helper/NotificationHelper.php @@ -15,6 +15,7 @@ use Mautic\LeadBundle\Entity\DoNotContact; use Mautic\LeadBundle\Entity\Lead; use Mautic\CoreBundle\Helper\CoreParametersHelper; +use Symfony\Component\HttpFoundation\RequestStack; use Mautic\CoreBundle\Templating\Helper\AssetsHelper; use Symfony\Bundle\FrameworkBundle\Routing\Router; use Symfony\Component\Routing\RouterInterface; @@ -44,6 +45,12 @@ class NotificationHelper */ protected $router; + /** + * @var Request + */ + protected $request; + + /** * PageSubscriber constructor. * @@ -51,12 +58,13 @@ class NotificationHelper * @param CoreParametersHelper $coreParametersHelper * @param Router $router */ - public function __construct(MauticFactory $factory, AssetsHelper $assetsHelper, CoreParametersHelper $coreParametersHelper, Router $router) + public function __construct(MauticFactory $factory, AssetsHelper $assetsHelper, CoreParametersHelper $coreParametersHelper, Router $router, RequestStack $requestStack) { $this->factory = $factory; $this->assetsHelper = $assetsHelper; $this->coreParametersHelper = $coreParametersHelper; $this->router = $router; + $this->request = $requestStack; } /** @@ -77,16 +85,23 @@ public function unsubscribe($email) return $leadModel->addDncForLead($lead, 'notification', null, DoNotContact::UNSUBSCRIBED); } - /** - * @param string $email - * - * @return bool - */ + + public function getHeaderScript(){ + if(!$this->hasScript()) { + return; + } + + return 'MauticJS.insertScript(\'https://cdn.onesignal.com/sdks/OneSignalSDK.js\'); + var OneSignal = OneSignal || [];'; + } + public function getScript() { -// if (!$this->coreParametersHelper->getParameter('notification_landing_page_enabled')) { -// return; -// } + + if(!$this->hasScript()) { + return; + } + $appId = $this->coreParametersHelper->getParameter('notification_app_id'); $safariWebId = $this->coreParametersHelper->getParameter('notification_safari_web_id'); $welcomenotificationEnabled = $this->coreParametersHelper->getParameter('welcomenotification_enabled'); @@ -99,9 +114,12 @@ public function getScript() } $oneSignalInit = <<request->getCurrentRequest()->server; + $landingPage = true; + if (strpos($server->get('HTTP_REFERER'), $this->coreParametersHelper->getParameter('site_url')) === false) { + $landingPage = false; + } + + if($landingPage == true && !$this->coreParametersHelper->getParameter('notification_landing_page_enabled')) + { + return false; + } + + if($landingPage == false && !$this->coreParametersHelper->getParameter('notification_tracking_page_enabled')) + { + return false; + } + + return true; + } + } From 8dc44e73af4f661316215abb0e1e5f4c39bf7af0 Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Fri, 20 Jan 2017 16:59:55 +0100 Subject: [PATCH 006/510] More work --- .../Api/NotificationApiController.php | 3 +-- .../Helper/NotificationHelper.php | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/bundles/NotificationBundle/Controller/Api/NotificationApiController.php b/app/bundles/NotificationBundle/Controller/Api/NotificationApiController.php index 17d89077092..5fa0ec9b6d0 100644 --- a/app/bundles/NotificationBundle/Controller/Api/NotificationApiController.php +++ b/app/bundles/NotificationBundle/Controller/Api/NotificationApiController.php @@ -41,7 +41,6 @@ public function initialize(FilterControllerEvent $event) public function subscribeAction() { $osid = $this->request->get('osid'); - if ($osid) { /** @var \Mautic\LeadBundle\Model\LeadModel $leadModel */ $leadModel = $this->getModel('lead'); @@ -52,7 +51,7 @@ public function subscribeAction() $leadModel->saveEntity($currentLead); - return new JsonResponse(['success' => true], 200, ['Access-Control-Allow-Origin' => '*']); + return new JsonResponse(['success' => true, 'osid' => $osid], 200, ['Access-Control-Allow-Origin' => '*']); } return new JsonResponse(['success' => 'false'], 200, ['Access-Control-Allow-Origin' => '*']); diff --git a/app/bundles/NotificationBundle/Helper/NotificationHelper.php b/app/bundles/NotificationBundle/Helper/NotificationHelper.php index 35e5bd87a30..673f9decec5 100644 --- a/app/bundles/NotificationBundle/Helper/NotificationHelper.php +++ b/app/bundles/NotificationBundle/Helper/NotificationHelper.php @@ -131,6 +131,12 @@ public function getScript() }]); var postUserIdToMautic = function(userId) { + MauticJS.makeCORSRequest('GET', '{$leadAssociationUrl}?osid=' + userId, {}, function(response, xhr) { + if (response.osid) { + document.cookie = "mtc_osid="+response.osid+";"; + } + }); + var xhr = new XMLHttpRequest(); xhr.open('post', '{$leadAssociationUrl}', true); @@ -165,17 +171,26 @@ public function getScript() } private function hasScript(){ - $server = $this->request->getCurrentRequest()->server; + $landingPage = true; + $server = $this->request->getCurrentRequest()->server; + + // already exist + if($this->request->cookies->get('mtc_osid')){ + return false; + } + if (strpos($server->get('HTTP_REFERER'), $this->coreParametersHelper->getParameter('site_url')) === false) { $landingPage = false; } + // disable on Landing pages if($landingPage == true && !$this->coreParametersHelper->getParameter('notification_landing_page_enabled')) { return false; } + // disable on tracking pages if($landingPage == false && !$this->coreParametersHelper->getParameter('notification_tracking_page_enabled')) { return false; From 8bce8334a71bf65780fd5e77f32268a11a2c938b Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Fri, 20 Jan 2017 17:08:23 +0100 Subject: [PATCH 007/510] Minor --- app/bundles/NotificationBundle/Config/config.php | 2 +- .../NotificationBundle/Helper/NotificationHelper.php | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/app/bundles/NotificationBundle/Config/config.php b/app/bundles/NotificationBundle/Config/config.php index 17511f355f3..070b3f3e42a 100644 --- a/app/bundles/NotificationBundle/Config/config.php +++ b/app/bundles/NotificationBundle/Config/config.php @@ -28,7 +28,7 @@ 'class' => 'Mautic\NotificationBundle\EventListener\PageSubscriber', 'arguments' => [ 'templating.helper.assets', - 'mautic.helper.core_parameters' + 'mautic.helper.core_parameters', ], ], 'mautic.core.js.subscriber' => [ diff --git a/app/bundles/NotificationBundle/Helper/NotificationHelper.php b/app/bundles/NotificationBundle/Helper/NotificationHelper.php index 673f9decec5..df28ec3542a 100644 --- a/app/bundles/NotificationBundle/Helper/NotificationHelper.php +++ b/app/bundles/NotificationBundle/Helper/NotificationHelper.php @@ -136,12 +136,6 @@ public function getScript() document.cookie = "mtc_osid="+response.osid+";"; } }); - - var xhr = new XMLHttpRequest(); - - xhr.open('post', '{$leadAssociationUrl}', true); - xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); - xhr.send('osid=' + userId); }; OneSignal.getUserId(function(userId) { From ef00697157d17c1ceaaef5aa4916a6f1b0b48c39 Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Fri, 20 Jan 2017 19:07:56 +0100 Subject: [PATCH 008/510] Minor --- app/bundles/NotificationBundle/Helper/NotificationHelper.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/bundles/NotificationBundle/Helper/NotificationHelper.php b/app/bundles/NotificationBundle/Helper/NotificationHelper.php index df28ec3542a..de4340eb3ae 100644 --- a/app/bundles/NotificationBundle/Helper/NotificationHelper.php +++ b/app/bundles/NotificationBundle/Helper/NotificationHelper.php @@ -168,9 +168,10 @@ private function hasScript(){ $landingPage = true; $server = $this->request->getCurrentRequest()->server; + $cookies = $this->request->getCurrentRequest()->cookies; // already exist - if($this->request->cookies->get('mtc_osid')){ + if($cookies->get('mtc_osid')){ return false; } From 1e83b35b474781dc95cfacfffe51060f20058392 Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Wed, 25 Jan 2017 19:43:34 +0100 Subject: [PATCH 009/510] Added subdomain support --- app/bundles/NotificationBundle/Config/config.php | 1 + .../NotificationBundle/Form/Type/ConfigType.php | 14 ++++++++++++++ .../Helper/NotificationHelper.php | 2 ++ .../Translations/en_US/messages.ini | 2 ++ 4 files changed, 19 insertions(+) diff --git a/app/bundles/NotificationBundle/Config/config.php b/app/bundles/NotificationBundle/Config/config.php index 070b3f3e42a..e95dd1cf77e 100644 --- a/app/bundles/NotificationBundle/Config/config.php +++ b/app/bundles/NotificationBundle/Config/config.php @@ -186,6 +186,7 @@ 'notification_rest_api_key' => null, 'notification_safari_web_id' => null, 'gcm_sender_id' => '482941778795', + 'notification_subdomain_name' => null, 'welcomenotification_enabled' => true, ], ]; diff --git a/app/bundles/NotificationBundle/Form/Type/ConfigType.php b/app/bundles/NotificationBundle/Form/Type/ConfigType.php index 4d483886b2a..067149a2fdc 100644 --- a/app/bundles/NotificationBundle/Form/Type/ConfigType.php +++ b/app/bundles/NotificationBundle/Form/Type/ConfigType.php @@ -118,6 +118,20 @@ public function buildForm(FormBuilderInterface $builder, array $options) ] ); + $builder->add( + 'notification_subdomain_name', + 'text', + [ + 'label' => 'mautic.notification.config.form.notification.subdomain_name', + 'data' => $options['data']['notification_subdomain_name'], + 'attr' => [ + 'tooltip' => 'mautic.notification.config.form.notification.subdomain_name.tooltip', + 'class' => 'form-control', + 'data-show-on' => '{"config_notificationconfig_notification_enabled_1":"checked"}', + ], + ] + ); + $builder->add( 'welcomenotification_enabled', 'yesno_button_group', diff --git a/app/bundles/NotificationBundle/Helper/NotificationHelper.php b/app/bundles/NotificationBundle/Helper/NotificationHelper.php index de4340eb3ae..06c41ced669 100644 --- a/app/bundles/NotificationBundle/Helper/NotificationHelper.php +++ b/app/bundles/NotificationBundle/Helper/NotificationHelper.php @@ -105,6 +105,7 @@ public function getScript() $appId = $this->coreParametersHelper->getParameter('notification_app_id'); $safariWebId = $this->coreParametersHelper->getParameter('notification_safari_web_id'); $welcomenotificationEnabled = $this->coreParametersHelper->getParameter('welcomenotification_enabled'); + $notificationSubdomainName = $this->coreParametersHelper->getParameter('notification_subdomain_name'); $leadAssociationUrl = $this->router->generate('mautic_subscribe_notification', [], UrlGeneratorInterface::ABSOLUTE_URL); @@ -124,6 +125,7 @@ public function getScript() appId: "{$appId}", safari_web_id: "{$safariWebId}", autoRegister: true, + subdomainName: "{$notificationSubdomainName}", {$welcomenotificationText} notifyButton: { enable: false // Set to false to hide diff --git a/app/bundles/NotificationBundle/Translations/en_US/messages.ini b/app/bundles/NotificationBundle/Translations/en_US/messages.ini index 1af876fc413..b6a9f3ffb4a 100644 --- a/app/bundles/NotificationBundle/Translations/en_US/messages.ini +++ b/app/bundles/NotificationBundle/Translations/en_US/messages.ini @@ -20,6 +20,8 @@ mautic.notification.config.form.notification.rest_api_key="Web Notifications Pro mautic.notification.config.form.notification.rest_api_key.tooltip="One Signal Rest API Key" mautic.notification.config.form.notification.gcm_sender_id="Shared key for push notifications" mautic.notification.config.form.notification.gcm_sender_id.tooltip="gcm_sender_id key - do not change it" +mautic.notification.config.form.notification.subdomain_name="subdomain of onesignal.com" +mautic.notification.config.form.notification.subdomain_name.tooltip="Web push notifications aren't actually supported for HTTP sites, we work around the issue by sending notifications from a subdomain of our site, onesignal.com, which is an HTTPS site" mautic.notification.config.form.notification.notification_safari_web_id="Web Notifications Provider Safari Web ID" mautic.notification.config.form.notification.notification_safari_web_id.tooltip="One Signal Safari Web ID for your One Signal App" mautic.notification.config.form.notification.icon="Web Notification Icon" From 87ef601cfb0c834c9322ad88ebc9a7156c39326b Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Wed, 25 Jan 2017 20:34:31 +0100 Subject: [PATCH 010/510] Add support for non https sites --- .../Helper/NotificationHelper.php | 76 +++++++++++++------ .../Translations/en_US/messages.ini | 2 +- 2 files changed, 53 insertions(+), 25 deletions(-) diff --git a/app/bundles/NotificationBundle/Helper/NotificationHelper.php b/app/bundles/NotificationBundle/Helper/NotificationHelper.php index 06c41ced669..6354fe53d56 100644 --- a/app/bundles/NotificationBundle/Helper/NotificationHelper.php +++ b/app/bundles/NotificationBundle/Helper/NotificationHelper.php @@ -97,16 +97,15 @@ public function getHeaderScript(){ public function getScript() { - if(!$this->hasScript()) { return; } + $appId = $this->coreParametersHelper->getParameter('notification_app_id'); $safariWebId = $this->coreParametersHelper->getParameter('notification_safari_web_id'); $welcomenotificationEnabled = $this->coreParametersHelper->getParameter('welcomenotification_enabled'); $notificationSubdomainName = $this->coreParametersHelper->getParameter('notification_subdomain_name'); - $leadAssociationUrl = $this->router->generate('mautic_subscribe_notification', [], UrlGeneratorInterface::ABSOLUTE_URL); $welcomenotificationText = ''; @@ -114,6 +113,18 @@ public function getScript() $welcomenotificationText = 'welcomeNotification: { "disable": true },'; } + $server = $this->request->getCurrentRequest()->server; + $https = (parse_url($server->get('HTTP_REFERER'), PHP_URL_SCHEME) == 'https') ? true :false; + + $subdomainName = ''; + if(!$https){ + $subdomainName = 'subdomainName: "'.$notificationSubdomainName.'", + httpPermissionRequest: { + enable: true, + useCustomModal: true + },'; + } + $oneSignalInit = << Date: Wed, 25 Jan 2017 20:38:14 +0100 Subject: [PATCH 011/510] Minor lang --- app/bundles/NotificationBundle/Translations/en_US/messages.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/bundles/NotificationBundle/Translations/en_US/messages.ini b/app/bundles/NotificationBundle/Translations/en_US/messages.ini index b4b5a01cbf6..127b2b3f3bd 100644 --- a/app/bundles/NotificationBundle/Translations/en_US/messages.ini +++ b/app/bundles/NotificationBundle/Translations/en_US/messages.ini @@ -21,7 +21,7 @@ mautic.notification.config.form.notification.rest_api_key.tooltip="One Signal Re mautic.notification.config.form.notification.gcm_sender_id="Shared key for push notifications" mautic.notification.config.form.notification.gcm_sender_id.tooltip="gcm_sender_id key - do not change it" mautic.notification.config.form.notification.subdomain_name="Subdomain of onesignal.com" -mautic.notification.config.form.notification.subdomain_name.tooltip="Web push notifications aren't actually supported for HTTP sites, we work around the issue by sending notifications from a subdomain of our site, onesignal.com, which is an HTTPS site" +mautic.notification.config.form.notification.subdomain_name.tooltip="Only for non https sites." mautic.notification.config.form.notification.notification_safari_web_id="Web Notifications Provider Safari Web ID" mautic.notification.config.form.notification.notification_safari_web_id.tooltip="One Signal Safari Web ID for your One Signal App" mautic.notification.config.form.notification.icon="Web Notification Icon" From 1ea69de5bff4397d982999cb4b42e4e3a203ebf0 Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Thu, 26 Jan 2017 14:16:06 +0100 Subject: [PATCH 012/510] Minor --- .../Helper/NotificationHelper.php | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/app/bundles/NotificationBundle/Helper/NotificationHelper.php b/app/bundles/NotificationBundle/Helper/NotificationHelper.php index 6354fe53d56..e23968fa113 100644 --- a/app/bundles/NotificationBundle/Helper/NotificationHelper.php +++ b/app/bundles/NotificationBundle/Helper/NotificationHelper.php @@ -87,45 +87,44 @@ public function unsubscribe($email) public function getHeaderScript(){ - if(!$this->hasScript()) { - return; - } - - return 'MauticJS.insertScript(\'https://cdn.onesignal.com/sdks/OneSignalSDK.js\'); + if($this->hasScript()) { + return 'MauticJS.insertScript(\'https://cdn.onesignal.com/sdks/OneSignalSDK.js\'); var OneSignal = OneSignal || [];'; + } } public function getScript() { - if(!$this->hasScript()) { - return; - } - - - $appId = $this->coreParametersHelper->getParameter('notification_app_id'); - $safariWebId = $this->coreParametersHelper->getParameter('notification_safari_web_id'); - $welcomenotificationEnabled = $this->coreParametersHelper->getParameter('welcomenotification_enabled'); - $notificationSubdomainName = $this->coreParametersHelper->getParameter('notification_subdomain_name'); - $leadAssociationUrl = $this->router->generate('mautic_subscribe_notification', [], UrlGeneratorInterface::ABSOLUTE_URL); - - $welcomenotificationText = ''; - if (!$welcomenotificationEnabled) { - $welcomenotificationText = 'welcomeNotification: { "disable": true },'; - } + if($this->hasScript()) { + + $appId = $this->coreParametersHelper->getParameter('notification_app_id'); + $safariWebId = $this->coreParametersHelper->getParameter('notification_safari_web_id'); + $welcomenotificationEnabled = $this->coreParametersHelper->getParameter('welcomenotification_enabled'); + $notificationSubdomainName = $this->coreParametersHelper->getParameter('notification_subdomain_name'); + $leadAssociationUrl = $this->router->generate( + 'mautic_subscribe_notification', + [], + UrlGeneratorInterface::ABSOLUTE_URL + ); + + $welcomenotificationText = ''; + if (!$welcomenotificationEnabled) { + $welcomenotificationText = 'welcomeNotification: { "disable": true },'; + } - $server = $this->request->getCurrentRequest()->server; - $https = (parse_url($server->get('HTTP_REFERER'), PHP_URL_SCHEME) == 'https') ? true :false; + $server = $this->request->getCurrentRequest()->server; + $https = (parse_url($server->get('HTTP_REFERER'), PHP_URL_SCHEME) == 'https') ? true : false; - $subdomainName = ''; - if(!$https){ - $subdomainName = 'subdomainName: "'.$notificationSubdomainName.'", + $subdomainName = ''; + if (!$https && $notificationSubdomainName) { + $subdomainName = 'subdomainName: "'.$notificationSubdomainName.'", httpPermissionRequest: { enable: true, useCustomModal: true },'; - } + } - $oneSignalInit = << Date: Mon, 23 Jan 2017 12:57:51 +0800 Subject: [PATCH 013/510] Try to find out the existing lead with device fingerprint when the session is unavailable. --- .../Entity/LeadDeviceRepository.php | 27 +++++++++++++++++++ app/bundles/LeadBundle/Model/LeadModel.php | 11 +++++++- app/bundles/PageBundle/Config/config.php | 8 ++++-- .../PageBundle/Form/Type/ConfigType.php | 8 ++++++ app/bundles/PageBundle/Model/PageModel.php | 15 ++++++++++- .../Translations/en_US/messages.ini | 2 ++ .../Config/_config_pageconfig_widget.html.php | 12 ++++++++- 7 files changed, 78 insertions(+), 5 deletions(-) diff --git a/app/bundles/LeadBundle/Entity/LeadDeviceRepository.php b/app/bundles/LeadBundle/Entity/LeadDeviceRepository.php index 760c50e9443..a8c626828c6 100644 --- a/app/bundles/LeadBundle/Entity/LeadDeviceRepository.php +++ b/app/bundles/LeadBundle/Entity/LeadDeviceRepository.php @@ -98,4 +98,31 @@ public function getDevice($lead, $deviceName = null, $deviceBrand = null, $devic return (!empty($device)) ? $device[0] : []; } + + /** + * @param string $fingerprint + * + * @return LeadDevice + */ + public function getDeviceByFingerprint($fingerprint) + { + if (!$fingerprint) { + return null; + } + + $sq = $this->_em->getConnection()->createQueryBuilder(); + $sq->select('es.id as id, es.lead_id as lead_id') + ->from(MAUTIC_TABLE_PREFIX.'lead_devices', 'es'); + + if ($fingerprint !== null) { + $sq->where( + $sq->expr()->eq('es.device_fingerprint', ':fingerprint') + ) + ->setParameter('fingerprint', $fingerprint); + } + //get totals + $device = $sq->execute()->fetchAll(); + + return (!empty($device)) ? $device[0] : []; + } } diff --git a/app/bundles/LeadBundle/Model/LeadModel.php b/app/bundles/LeadBundle/Model/LeadModel.php index fc4cfb1fef6..59274a6d714 100644 --- a/app/bundles/LeadBundle/Model/LeadModel.php +++ b/app/bundles/LeadBundle/Model/LeadModel.php @@ -800,7 +800,7 @@ public function getLeadFromRequest(array $queryFields = []) * * @return array|Lead|null */ - public function getContactFromRequest($queryFields = []) + public function getContactFromRequest($queryFields = [], $trackByFingerprint = false) { $lead = null; @@ -860,6 +860,15 @@ public function getContactFromRequest($queryFields = []) } } + // Search for lead by fingerprint + if (empty($lead) && !empty($queryFields['fingerprint']) && $trackByFingerprint) { + $deviceRepo = $this->getDeviceRepository(); + $device = $deviceRepo->getDeviceByFingerprint($queryFields['fingerprint']); + if ($device) { + $lead = $this->getEntity($device['lead_id']); + } + } + if (empty($lead)) { // No lead found so generate one $lead = $this->getCurrentLead(); diff --git a/app/bundles/PageBundle/Config/config.php b/app/bundles/PageBundle/Config/config.php index f70f9a3ce2a..d02bab71b7e 100644 --- a/app/bundles/PageBundle/Config/config.php +++ b/app/bundles/PageBundle/Config/config.php @@ -252,6 +252,9 @@ 'setCatInUrl' => [ '%mautic.cat_in_page_url%', ], + 'setTrackByFingerprint' => [ + '%mautic.track_by_fingerprint%', + ], ], ], 'mautic.page.model.redirect' => [ @@ -283,8 +286,9 @@ ], 'parameters' => [ - 'cat_in_page_url' => false, - 'google_analytics' => false, + 'cat_in_page_url' => false, + 'track_by_fingerprint' => false, + 'google_analytics' => false, 'redirect_list_types' => [ '301' => 'mautic.page.form.redirecttype.permanent', diff --git a/app/bundles/PageBundle/Form/Type/ConfigType.php b/app/bundles/PageBundle/Form/Type/ConfigType.php index 2875f6f4c6d..a8230a9032f 100644 --- a/app/bundles/PageBundle/Form/Type/ConfigType.php +++ b/app/bundles/PageBundle/Form/Type/ConfigType.php @@ -43,6 +43,14 @@ public function buildForm(FormBuilderInterface $builder, array $options) ], 'required' => false, ]); + + $builder->add('track_by_fingerprint', 'yesno_button_group', [ + 'label' => 'mautic.page.config.form.track.by.fingerprint', + 'data' => (bool) $options['data']['track_by_fingerprint'], + 'attr' => [ + 'tooltip' => 'mautic.page.config.form.track.by.fingerprint.tooltip', + ], + ]); } /** diff --git a/app/bundles/PageBundle/Model/PageModel.php b/app/bundles/PageBundle/Model/PageModel.php index c61137b1d68..cc90eaf0fd0 100644 --- a/app/bundles/PageBundle/Model/PageModel.php +++ b/app/bundles/PageBundle/Model/PageModel.php @@ -50,6 +50,11 @@ class PageModel extends FormModel */ protected $catInUrl; + /** + * @var bool + */ + protected $trackByFingerprint; + /** * @var CookieHelper */ @@ -114,6 +119,14 @@ public function setCatInUrl($catInUrl) $this->catInUrl = $catInUrl; } + /** + * @param $trackByFingerprint + */ + public function setTrackByFingerprint($trackByFingerprint) + { + $this->trackByFingerprint = $trackByFingerprint; + } + /** * @return \Mautic\PageBundle\Entity\PageRepository */ @@ -448,7 +461,7 @@ public function hitPage($page, Request $request, $code = '200', Lead $lead = nul // Get lead if required if (null == $lead) { - $lead = $this->leadModel->getContactFromRequest($query); + $lead = $this->leadModel->getContactFromRequest($query, $this->trackByFingerprint); } $this->leadModel->saveEntity($lead); diff --git a/app/bundles/PageBundle/Translations/en_US/messages.ini b/app/bundles/PageBundle/Translations/en_US/messages.ini index 71f68f28800..6bd824c7c0e 100644 --- a/app/bundles/PageBundle/Translations/en_US/messages.ini +++ b/app/bundles/PageBundle/Translations/en_US/messages.ini @@ -21,6 +21,8 @@ mautic.page.campaign.event.pagehit="Visits a page" mautic.page.campaign.event.pagehit_descr="Trigger actions on a page/url hit." mautic.page.config.form.cat.in.url="Show category in page URL?" mautic.page.config.form.cat.in.url.tooltip="If enabled, the category slug will be included in the URL." +mautic.page.config.form.track.by.fingerprint="Identify returning visitor by device fingerprint" +mautic.page.config.form.track.by.fingerprint.tooltip="If enabled, identify returning visitor by device fingerprint when no cookie exists yet." mautic.page.config.form.google.analytics="Analytics script (i.e. Google Analytics)" mautic.page.config.form.google.analytics.tooltip="Insert the analytics script to have it automatically included in the soure of landing pages." mautic.page.event.hit="Page hit" diff --git a/app/bundles/PageBundle/Views/FormTheme/Config/_config_pageconfig_widget.html.php b/app/bundles/PageBundle/Views/FormTheme/Config/_config_pageconfig_widget.html.php index cfad30f6d27..13089660272 100644 --- a/app/bundles/PageBundle/Views/FormTheme/Config/_config_pageconfig_widget.html.php +++ b/app/bundles/PageBundle/Views/FormTheme/Config/_config_pageconfig_widget.html.php @@ -15,7 +15,10 @@

trans('mautic.config.tab.pageconfig'); ?>

- children as $f): ?> + children as $k => $f): ?> +
row($f); ?> @@ -27,6 +30,7 @@

trans('mautic.config.tab.pagetracking'); ?>

+

trans('mautic.config.tab.pagetracking.info'); ?>

<script>
     (function(w,d,t,u,n,a,m){w['MauticTrackingObject']=n;
@@ -36,5 +40,11 @@
 
     mt('send', 'pageview');
 </script>
+
+
+
+ row($form->children['track_by_fingerprint']); ?> +
+
\ No newline at end of file From 9abeb9a59b7700cc428bce42e1c13132626ccf72 Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Mon, 30 Jan 2017 22:30:54 +0100 Subject: [PATCH 014/510] Add merge contact to edit Contact via API --- .../Controller/Api/LeadApiController.php | 39 +++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/app/bundles/LeadBundle/Controller/Api/LeadApiController.php b/app/bundles/LeadBundle/Controller/Api/LeadApiController.php index 086f4a3197f..5016f9d1832 100644 --- a/app/bundles/LeadBundle/Controller/Api/LeadApiController.php +++ b/app/bundles/LeadBundle/Controller/Api/LeadApiController.php @@ -41,11 +41,34 @@ public function initialize(FilterControllerEvent $event) * Creates a new lead or edits if one is found with same email. You should make a call to /api/leads/list/fields in order to get a list of custom fields that will be accepted. The key should be the alias of the custom field. You can also pass in a ipAddress parameter if the IP of the lead is different than that of the originating request. */ public function newEntityAction() + { + $existingLeads = $this->getExistingLeads(); + + if (!empty($existingLeads)) { + parent::editEntityAction($existingLeads[0]->getId()); + } + + return parent::newEntityAction(); + } + + public function editEntityAction($id) + { + $existingLeads = $this->getExistingLeads(); + + if (!empty($existingLeads)) { + $entity = $this->model->getEntity($id); + $this->model->mergeLeads($existingLeads[0], $entity, false); + } + + return parent::editEntityAction($id); + } + + protected function getExistingLeads() { // Check for an email to see if the lead already exists $parameters = $this->request->request->all(); - $uniqueLeadFields = $this->getModel('lead.field')->getUniqueIdentiferFields(); + $uniqueLeadFields = $this->getModel('lead.field')->getUniqueIdentiferFields(); $uniqueLeadFieldData = []; foreach ($parameters as $k => $v) { @@ -55,18 +78,10 @@ public function newEntityAction() } if (count($uniqueLeadFieldData)) { - if (count($uniqueLeadFieldData)) { - $existingLeads = $this->get('doctrine.orm.entity_manager')->getRepository('MauticLeadBundle:Lead')->getLeadsByUniqueFields($uniqueLeadFieldData); - - if (!empty($existingLeads)) { - // Lead found so edit rather than create a new one - - return parent::editEntityAction($existingLeads[0]->getId()); - } - } + return $this->get('doctrine.orm.entity_manager')->getRepository( + 'MauticLeadBundle:Lead' + )->getLeadsByUniqueFields($uniqueLeadFieldData); } - - return parent::newEntityAction(); } /** From 289601f564abd68fb208dda2a424f06d7423e3d2 Mon Sep 17 00:00:00 2001 From: MarkLL Date: Mon, 6 Feb 2017 10:31:17 +1100 Subject: [PATCH 015/510] FormJS Fix for issue #3344 --- .../Command/GenerateProductionAssetsCommand.php | 10 +++++++++- media/js/mautic-form.js | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/bundles/CoreBundle/Command/GenerateProductionAssetsCommand.php b/app/bundles/CoreBundle/Command/GenerateProductionAssetsCommand.php index ba39a58147c..da868585a73 100644 --- a/app/bundles/CoreBundle/Command/GenerateProductionAssetsCommand.php +++ b/app/bundles/CoreBundle/Command/GenerateProductionAssetsCommand.php @@ -51,9 +51,17 @@ protected function execute(InputInterface $input, OutputInterface $output) // Minify Mautic Form SDK file_put_contents( - $pathsHelper->getSystemPath('assets', true).'/js/mautic-form.js', + $pathsHelper->getSystemPath('assets', true).'/js/mautic-form-tmp.js', \Minify::combine([$pathsHelper->getSystemPath('assets', true).'/js/mautic-form-src.js']) ); + // Fix the MauticSDK loader + file_put_contents( + $pathsHelper->getSystemPath('assets', true).'/js/mautic-form.js', + str_replace("'mautic-form-src.js'", "'mautic-form.js'", + file_get_contents($pathsHelper->getSystemPath('assets', true).'/js/mautic-form-tmp.js')) + ); + // Remove temp file. + unlink($pathsHelper->getSystemPath('assets', true).'/js/mautic-form-tmp.js'); /** @var \Symfony\Bundle\FrameworkBundle\Translation\Translator $translator */ $translator = $container->get('translator'); diff --git a/media/js/mautic-form.js b/media/js/mautic-form.js index d5d369a3093..ee8acd9da76 100644 --- a/media/js/mautic-form.js +++ b/media/js/mautic-form.js @@ -42,5 +42,5 @@ this.buildOut();this.initializeEvents();window.getComputedStyle(this.modal).heig if(this.options.overlay===true){this.overlay=document.createElement("div");this.overlay.className="mauticForm-overlay "+this.options.className;docFrag.appendChild(this.overlay);} contentHolder=document.createElement("div");contentHolder.className="mauticForm-content";contentHolder.innerHTML=content;this.modal.appendChild(contentHolder);docFrag.appendChild(this.modal);document.body.appendChild(docFrag);};Modal.extendDefaults=function(source,properties){for(var property in properties){if(properties.hasOwnProperty(property))source[property]=properties[property];} return source;};Modal.initializeEvents=function(){if(this.closeButton)this.closeButton.addEventListener('click',this.close.bind(this));if(this.overlay)this.overlay.addEventListener('click',this.close.bind(this));};Modal.transitionSelect=function(){var el=document.createElement("div");return(el.style.WebkitTransition)?"webkitTransitionEnd":(el.style.WebkitTransition)?"webkitTransitionEnd":"oTransitionEnd";};Modal.close=function(){var _=this;this.modal.className=this.modal.className.replace(" mauticForm-open","");this.overlay.className=this.overlay.className.replace(" mauticForm-open","");this.modal.addEventListener(this.transitionSelect(),function(){_.modal.parentNode.removeChild(_.modal);});this.overlay.addEventListener(this.transitionSelect(),function(){if(_.overlay.parentNode)_.overlay.parentNode.removeChild(_.overlay);});this.overlay.parentNode.removeChild(this.overlay);this.modal.parentNode.removeChild(this.modal);};Core.parseToObject=function(params){return JSON.parse('{"'+decodeURI(params.trim().replace(/&/g,"\",\"").replace(/=/g,"\":\""))+'"}');};Core.setConfig=function(options){config=options;};Core.getConfig=function(){return config;};Core.debug=function(){return(typeof(config.debug)!='undefined'&&parseInt(config.debug)!='Nan'&&config.debug==1)?true:false;};Core.devMode=function(){return(typeof(config.devmode)!='undefined'&&parseInt(config.devmode)!='Nan'&&config.devmode==1)?true:false;};Core.setMauticBaseUrl=function(base_url){config.mautic_base_url=base_url.split('/').slice(0,-3).join('/')+'/';};Core.getMauticBaseUrl=function(){return config.mautic_base_url;};Core.initialize=function(base_url){Profiler.startTime();if(Core.debug())console.log('SDK initialized');if(typeof(config.mautic_base_url)=='undefined')Core.setMauticBaseUrl(base_url);if(Core.debug())console.log('Automatic setup mautic_base_url as: '+config.mautic_base_url);Modal.loadStyle();document.addEventListener("DOMContentLoaded",function(e){if(Core.debug())console.log('DOM is ready');Form.initialize();});};Core.openModal=function(options){Modal.open(options);};Core.onLoad=function(){Form.prepareForms();Form.registerFormMessenger();};return Core;} -if(typeof(MauticSDK)==='undefined'){window.MauticSDK=define_library();var sjs=document.getElementsByTagName('script'),tjs=sjs.length;for(var i=0;i Date: Mon, 6 Feb 2017 21:08:16 +1100 Subject: [PATCH 016/510] Gated Video in Dynamic Content Fix for issue #3349 --- .../EventListener/BuildJsSubscriber.php | 4 ++++ app/bundles/PageBundle/EventListener/BuildJsSubscriber.php | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/bundles/DynamicContentBundle/EventListener/BuildJsSubscriber.php b/app/bundles/DynamicContentBundle/EventListener/BuildJsSubscriber.php index 879d74c2267..54d9d7a3ab9 100644 --- a/app/bundles/DynamicContentBundle/EventListener/BuildJsSubscriber.php +++ b/app/bundles/DynamicContentBundle/EventListener/BuildJsSubscriber.php @@ -114,6 +114,10 @@ public function onBuildJs(BuildJsEvent $event) MauticJS.insertScript(m[1]); } } + + if (response.search("fr-gatedvideo") > 0) { + MauticJS.initGatedVideo(); + } } }); }); diff --git a/app/bundles/PageBundle/EventListener/BuildJsSubscriber.php b/app/bundles/PageBundle/EventListener/BuildJsSubscriber.php index 56c3a631602..e7f3e0109d3 100644 --- a/app/bundles/PageBundle/EventListener/BuildJsSubscriber.php +++ b/app/bundles/PageBundle/EventListener/BuildJsSubscriber.php @@ -208,8 +208,13 @@ public function onBuildJsForVideo(BuildJsEvent $event) $js = << Date: Fri, 10 Feb 2017 12:13:04 +0000 Subject: [PATCH 017/510] modified the way we are pushing leads to SF. this will now modify all records found related to the lead created in Mautic and/or email Lead/Contact --- .../Entity/IntegrationEntityRepository.php | 11 ++++--- plugins/MauticCrmBundle/Api/SalesforceApi.php | 31 +++++++++++++------ .../Integration/SalesforceIntegration.php | 13 ++++++++ 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/app/bundles/PluginBundle/Entity/IntegrationEntityRepository.php b/app/bundles/PluginBundle/Entity/IntegrationEntityRepository.php index ce52c9c26d2..f2a3f2290b5 100644 --- a/app/bundles/PluginBundle/Entity/IntegrationEntityRepository.php +++ b/app/bundles/PluginBundle/Entity/IntegrationEntityRepository.php @@ -34,16 +34,19 @@ class IntegrationEntityRepository extends CommonRepository public function getIntegrationsEntityId($integration, $integrationEntity, $internalEntity, $internalEntityId = null, $startDate = null, $endDate = null, $push = false, $start = 0, $limit = 0) { $q = $this->_em->getConnection()->createQueryBuilder() - ->select('i.integration_entity_id, i.id, i.internal_entity_id') + ->select('i.integration_entity_id, i.id, i.internal_entity_id, i.integration_entity') ->from(MAUTIC_TABLE_PREFIX.'integration_entity', 'i'); $q->where('i.integration = :integration') - ->andWhere('i.integration_entity = :integrationEntity') ->andWhere('i.internal_entity = :internalEntity') - ->setParameter('integration', $integration) - ->setParameter('integrationEntity', $integrationEntity) ->setParameter('internalEntity', $internalEntity); + + if ($integrationEntity) { + $q->andWhere('i.integration_entity = :integrationEntity') + ->setParameter('integrationEntity', $integrationEntity); + } + if ($push) { $q->join('i', MAUTIC_TABLE_PREFIX.'leads', 'l', 'l.id = i.internal_entity_id and l.last_active >= :startDate') ->setParameter('startDate', $startDate); diff --git a/plugins/MauticCrmBundle/Api/SalesforceApi.php b/plugins/MauticCrmBundle/Api/SalesforceApi.php index bcbb3ed73e1..72dbfa9292b 100644 --- a/plugins/MauticCrmBundle/Api/SalesforceApi.php +++ b/plugins/MauticCrmBundle/Api/SalesforceApi.php @@ -101,21 +101,32 @@ public function getLeadFields($object = null) */ public function createLead(array $data, $lead) { - //find lead - $update = false; - if (isset($data['Email'])) { - $findLead = 'select Id from Lead where email = \''.$data['Email'].'\''; + $createdLeadData = []; + //search for SF id in mautic records first to avoid making an API call + if (is_object($lead)) { + $sfLeadRecords = $this->integration->getSalesforceLeadId($lead); + } + //if not found then go ahead and make an API call to find all the records with that email + if (isset($data['Email']) && empty($sfLeadId)) { + $findLead = 'select Id, ConvertedContactId from Lead where email = \''.$data['Email'].'\''; $queryUrl = $this->integration->getQueryUrl(); $sfLead = $this->request('query', ['q' => $findLead], 'GET', false, null, $queryUrl); - $lead = $sfLead['records']; - if (isset($lead[0]['Id'])) { - $update = true; - } + $sfLeadRecords = $sfLead['records']; } - if ($update) { - $createdLeadData = $this->request('', $data, 'PATCH', false, 'Lead/'.$lead[0]['Id']); + if (!empty($sfLeadRecords)) { + foreach ($sfLeadRecords as $sfLeadRecord) { + $sfLeadId = (isset($sfLeadRecord['integration_entity_id']) ? $sfLeadRecord['integration_entity_id'] : $sfLeadRecord['Id']); + $sfObject = (isset($sfLeadRecord['integration_entity']) ? $sfLeadRecord['integration_entity'] : 'Lead'); + //update the converted contact if found and not the Lead because it will error in SF + if (isset($sfLeadRecord['ConvertedContactId']) && $sfLeadRecord['ConvertedContactId'] != null) { + unset($data['Company']); //because this record is not in the Contact object + $createdLeadData[] = $this->request('', $data, 'PATCH', false, 'Contact/'.$sfLeadRecord['ConvertedContactId']); + } else { + $createdLeadData[] = $this->request('', $data, 'PATCH', false, $sfObject.'/'.$sfLeadId); + } + } } else { $createdLeadData = $this->request('', $data, 'POST', false, 'Lead'); } diff --git a/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php b/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php index f1a40f55240..a09ad87eaf8 100644 --- a/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php +++ b/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php @@ -914,4 +914,17 @@ public function convertLeadFieldKey($key, $field) return $newKey; } + + public function getSalesforceLeadId($lead) + { + /** @var IntegrationEntityRepository $integrationEntityRepo */ + $integrationEntityRepo = $this->em->getRepository('MauticPluginBundle:IntegrationEntity'); + $result = $integrationEntityRepo->getIntegrationsEntityId('Salesforce', null, 'Lead', $lead->getId()); + if (empty($result)) { + //try searching for lead as this has been changed before in updated done to the plugin + $result = $integrationEntityRepo->getIntegrationsEntityId('Salesforce', null, 'lead', $lead->getId()); + } + + return $result; + } } From 9a66a24be42685683ee6cde7a0697dc0d3967b17 Mon Sep 17 00:00:00 2001 From: John Linhart Date: Mon, 13 Feb 2017 11:04:41 +0100 Subject: [PATCH 018/510] Campaign action to permanently delete a contact added --- .../CampaignBundle/Model/EventModel.php | 11 +++++++ .../EventListener/CampaignSubscriber.php | 29 +++++++++++++++++++ .../Translations/en_US/messages.ini | 3 ++ 3 files changed, 43 insertions(+) diff --git a/app/bundles/CampaignBundle/Model/EventModel.php b/app/bundles/CampaignBundle/Model/EventModel.php index de93602ef32..eade77fde37 100644 --- a/app/bundles/CampaignBundle/Model/EventModel.php +++ b/app/bundles/CampaignBundle/Model/EventModel.php @@ -1648,6 +1648,17 @@ public function executeEvent( //trigger the action $response = $this->invokeEventCallback($event, $thisEventSettings, $lead, null, true, $log); + // Check if the lead wasn't deleted during the event callback + if (null === $lead->getId() && $response === true) { + ++$executedEventCount; + + $this->logger->debug( + 'CAMPAIGN: Contact was deleted while executing '.ucfirst($event['eventType']).' ID# '.$event['id'] + ); + + return true; + } + $eventTriggered = false; if ($response instanceof LeadEventLog) { // Listener handled the event and returned a log entry diff --git a/app/bundles/LeadBundle/EventListener/CampaignSubscriber.php b/app/bundles/LeadBundle/EventListener/CampaignSubscriber.php index da47591e9a5..3aabbf04b71 100644 --- a/app/bundles/LeadBundle/EventListener/CampaignSubscriber.php +++ b/app/bundles/LeadBundle/EventListener/CampaignSubscriber.php @@ -69,6 +69,7 @@ public static function getSubscribedEvents() ['onCampaignTriggerActionUpdateTags', 3], ['onCampaignTriggerActionAddToCompany', 4], ['onCampaignTriggerActionChangeCompanyScore', 4], + ['onCampaignTriggerActionDeleteContact', 6], ], LeadEvents::ON_CAMPAIGN_TRIGGER_CONDITION => ['onCampaignTriggerCondition', 0], ]; @@ -131,6 +132,20 @@ public function onCampaignBuild(CampaignBuilderEvent $event) ]; $event->addAction('lead.scorecontactscompanies', $action); + $trigger = [ + 'label' => 'mautic.lead.lead.events.delete', + 'description' => 'mautic.lead.lead.events.delete_descr', + 'eventName' => LeadEvents::ON_CAMPAIGN_TRIGGER_ACTION, + 'connectionRestrictions' => [ + 'target' => [ + 'decision' => ['none'], + 'action' => ['none'], + 'condition' => ['none'], + ], + ], + ]; + $event->addAction('lead.deletecontact', $trigger); + $trigger = [ 'label' => 'mautic.lead.lead.events.field_value', 'description' => 'mautic.lead.lead.events.field_value_descr', @@ -278,6 +293,20 @@ public function onCampaignTriggerActionChangeCompanyScore(CampaignExecutionEvent } } + /** + * @param CampaignExecutionEvent $event + */ + public function onCampaignTriggerActionDeleteContact(CampaignExecutionEvent $event) + { + if (!$event->checkContext('lead.deletecontact')) { + return; + } + + $this->leadModel->deleteEntity($event->getLead()); + + return $event->setResult(true); + } + /** * @param CampaignExecutionEvent $event */ diff --git a/app/bundles/LeadBundle/Translations/en_US/messages.ini b/app/bundles/LeadBundle/Translations/en_US/messages.ini index 6661619fab1..070b7ee9534 100755 --- a/app/bundles/LeadBundle/Translations/en_US/messages.ini +++ b/app/bundles/LeadBundle/Translations/en_US/messages.ini @@ -5,6 +5,7 @@ mautic.campaign.lead.field_value="Contact field value" mautic.campaign.lead.updatelead="Update contact" mautic.contact.error.notfound="Contact not found." mautic.campaign.lead.scorecontactscompanies="Score company" +mautic.campaign.lead.deletecontact="Delete contact" mautic.core.date.added_first="First Touch Date Added" mautic.core.date.added_last="Last Touch Date Added" mautic.lead.add.note="Add note" @@ -181,6 +182,8 @@ mautic.lead.lead.events.pointchange_descr="Trigger event upon a contact's point mautic.lead.lead.events.removefromlists="Remove contact from selected segment(s)" mautic.lead.lead.events.updatelead="Update contact" mautic.lead.lead.events.updatelead_descr="Update the current contact's fields with the defined values from this action" +mautic.lead.lead.events.delete="Delete contact" +mautic.lead.lead.events.delete_descr="Permanently delete the current contact. The contact will be erased from the database as well as all the statistical data this contact created." mautic.lead.lead.events.field_value="Contact field value" mautic.lead.lead.events.field_value_descr="Condition based on a contact field value." mautic.lead.lead.field.custom_avatar="Custom" From f3d8d77e180e7c2053ebaf4c7d6494ab35bbde3f Mon Sep 17 00:00:00 2001 From: Marianela Queme Date: Tue, 14 Feb 2017 10:27:47 +0000 Subject: [PATCH 019/510] modifying field matching for plugins. the screen can get cluttered when there are too many integration fields --- app/bundles/PluginBundle/Assets/js/plugin.js | 8 +++++++- app/bundles/PluginBundle/Form/Type/FieldsType.php | 10 ++++++++-- ...on_details_featureSettings_leadFields_row.html.php | 11 +++++++++-- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/app/bundles/PluginBundle/Assets/js/plugin.js b/app/bundles/PluginBundle/Assets/js/plugin.js index 310e23cc638..80e4eed5e05 100644 --- a/app/bundles/PluginBundle/Assets/js/plugin.js +++ b/app/bundles/PluginBundle/Assets/js/plugin.js @@ -1,5 +1,11 @@ /* PluginBundle */ - +Mautic.addNewPluginField = function () { + mQuery('.add').click(function(e){ + e.preventDefault(); + if (mQuery("div.field div.active").is(":last-child")) return; + mQuery('div.field').find('div.active').removeClass('active').next().removeClass('hide').addClass('active'); + }); +}; Mautic.initiateIntegrationAuthorization = function() { mQuery('#integration_details_in_auth').val(1); diff --git a/app/bundles/PluginBundle/Form/Type/FieldsType.php b/app/bundles/PluginBundle/Form/Type/FieldsType.php index acaeb4506d3..31a13b08276 100644 --- a/app/bundles/PluginBundle/Form/Type/FieldsType.php +++ b/app/bundles/PluginBundle/Form/Type/FieldsType.php @@ -29,13 +29,19 @@ class FieldsType extends AbstractType */ public function buildForm(FormBuilderInterface $builder, array $options) { + $index = 0; foreach ($options['integration_fields'] as $field => $details) { + ++$index; $label = (is_array($details)) ? $details['label'] : $details; $field = InputHelper::alphanum($field, false, '_'); - $builder->add($field, 'choice', [ + $builder->add('i_'.$index, 'choice', [ + 'choices' => array_keys($options['integration_fields']), + 'label' => 'Integration', + ]); + $builder->add('m_'.$index, 'choice', [ 'choices' => $options['lead_fields'], - 'label' => $label, + 'label' => 'Mautic Lead Field', 'required' => (is_array($details) && isset($details['required'])) ? $details['required'] : false, 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control', 'data-placeholder' => ' '], diff --git a/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php b/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php index ec6e825cfee..6c8003c7ea6 100644 --- a/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php +++ b/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php @@ -16,12 +16,17 @@ trans($specialInstructions); ?>
-
+ +
errors($form); ?> children as $child): ?> -
+
row($child); ?> @@ -34,6 +39,8 @@
+ + Add a field
\ No newline at end of file From a30fa1fccdd0980e820a7c64a3ce85927d51ead8 Mon Sep 17 00:00:00 2001 From: Ruth Cheesley Date: Thu, 16 Feb 2017 14:05:37 +0000 Subject: [PATCH 020/510] Add styling for selected button --- app/bundles/CoreBundle/Assets/css/libraries/builder.less | 3 +++ 1 file changed, 3 insertions(+) mode change 100644 => 100755 app/bundles/CoreBundle/Assets/css/libraries/builder.less diff --git a/app/bundles/CoreBundle/Assets/css/libraries/builder.less b/app/bundles/CoreBundle/Assets/css/libraries/builder.less old mode 100644 new mode 100755 index 0d4c1d717da..e07489dc5fc --- a/app/bundles/CoreBundle/Assets/css/libraries/builder.less +++ b/app/bundles/CoreBundle/Assets/css/libraries/builder.less @@ -203,4 +203,7 @@ div[data-slot].ui-sortable-helper { .select-theme-link { margin-top: 5px; } + .select-theme-selected { + margin-top:5px; + } } From ea116e1ee0273610cc9c381c6e318b89007ba12b Mon Sep 17 00:00:00 2001 From: Alan Hartless Date: Thu, 16 Feb 2017 13:35:09 -0600 Subject: [PATCH 021/510] Fixed contact filter by segment to use segment date added --- app/bundles/LeadBundle/EventListener/ReportSubscriber.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/bundles/LeadBundle/EventListener/ReportSubscriber.php b/app/bundles/LeadBundle/EventListener/ReportSubscriber.php index b4e468a2a1a..71577bf0073 100644 --- a/app/bundles/LeadBundle/EventListener/ReportSubscriber.php +++ b/app/bundles/LeadBundle/EventListener/ReportSubscriber.php @@ -306,7 +306,6 @@ public function onReportGenerate(ReportGeneratorEvent $event) switch ($context) { case 'leads': - $event->applyDateFilters($qb, 'date_added', 'l'); $qb->from(MAUTIC_TABLE_PREFIX.'leads', 'l'); if ($event->hasColumn(['u.first_name', 'u.last_name']) || $event->hasFilter(['u.first_name', 'u.last_name'])) { @@ -320,6 +319,9 @@ public function onReportGenerate(ReportGeneratorEvent $event) if ($event->hasFilter('s.leadlist_id')) { $qb->join('l', MAUTIC_TABLE_PREFIX.'lead_lists_leads', 's', 's.lead_id = l.id AND s.manually_removed = 0'); + $event->applyDateFilters($qb, 'date_added', 's'); + } else { + $event->applyDateFilters($qb, 'date_added', 'l'); } break; From 4e069b08b633e8a8ccf578ad4ad61af6b14fdf65 Mon Sep 17 00:00:00 2001 From: Alan Hartless Date: Thu, 16 Feb 2017 13:35:29 -0600 Subject: [PATCH 022/510] Fixed filters that used formula columns --- .../ReportBundle/Builder/MauticReportBuilder.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/bundles/ReportBundle/Builder/MauticReportBuilder.php b/app/bundles/ReportBundle/Builder/MauticReportBuilder.php index 86c17c48c76..f932a7c51d7 100644 --- a/app/bundles/ReportBundle/Builder/MauticReportBuilder.php +++ b/app/bundles/ReportBundle/Builder/MauticReportBuilder.php @@ -335,7 +335,12 @@ private function applyFilters(array $filters, QueryBuilder $queryBuilder, array } $columnValue = ":$paramName"; - switch ($filterDefinitions[$filter['column']]['type']) { + $type = $filterDefinitions[$filter['column']]['type']; + if (isset($filterDefinitions[$filter['column']]['formula'])) { + $filter['column'] = $filterDefinitions[$filter['column']]['formula']; + } + + switch ($type) { case 'bool': case 'boolean': if ((int) $filter['value'] > 1) { @@ -359,9 +364,9 @@ private function applyFilters(array $filters, QueryBuilder $queryBuilder, array $queryBuilder->setParameter($paramName, $filter['value']); } - $filterExpr->add( - $expr->{$exprFunction}($filter['column'], $columnValue) - ); + $filterExpr->add( + $expr->{$exprFunction}($filter['column'], $columnValue) + ); } } } From 5f9f7a3739c7564a708f005ce89cadc8fd7b45ae Mon Sep 17 00:00:00 2001 From: Alan Hartless Date: Thu, 16 Feb 2017 13:36:03 -0600 Subject: [PATCH 023/510] Version bump and prod assets --- app/AppKernel.php | 2 +- app/version.txt | 2 +- media/js/app.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/AppKernel.php b/app/AppKernel.php index 1d31f40e67f..24f06906626 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -51,7 +51,7 @@ class AppKernel extends Kernel * * @const string */ - const EXTRA_VERSION = '-dev'; + const EXTRA_VERSION = ''; /** * @var array diff --git a/app/version.txt b/app/version.txt index c708446f793..b8d12d73710 100644 --- a/app/version.txt +++ b/app/version.txt @@ -1 +1 @@ -2.6.1-dev \ No newline at end of file +2.6.1 \ No newline at end of file diff --git a/media/js/app.js b/media/js/app.js index 8ad61ff356d..f11a64c7b98 100644 --- a/media/js/app.js +++ b/media/js/app.js @@ -268,7 +268,7 @@ var message=mQuery(el).data('message');var confirmText=mQuery(el).data('confirm- if(typeof cancelButton!='undefined'){confirmFooterDiv.append(cancelButton);} confirmFooterDiv.append(confirmButton);confirmContentDiv.append(confirmHeaderDiv);confirmContentDiv.append(confirmFooterDiv);confirmContainer.append(confirmDialogDiv.append(confirmContentDiv));mQuery('body').append(confirmContainer);mQuery('.confirmation-modal').on('hidden.bs.modal',function(){mQuery(this).remove();});mQuery('.confirmation-modal').modal('show');};Mautic.dismissConfirmation=function(){if(mQuery('.confirmation-modal').length){mQuery('.confirmation-modal').modal('hide');}};Mautic.closeModalAndRedirect=function(el,url){Mautic.startModalLoadingBar(el);Mautic.loadContent(url);mQuery('body').removeClass('noscroll');};Mautic.loadAjaxModalBySelectValue=function(el,value,route,header){var selectVal=mQuery(el).val();var hasValue=(selectVal==value);if(!hasValue&&mQuery.isArray(selectVal)){hasValue=(mQuery.inArray(value,selectVal)!==-1);} if(hasValue){route=route+(route.indexOf('?')>-1?'&':'?')+'modal=1&contentOnly=1&updateSelect='+mQuery(el).attr('id');mQuery(el).find('option[value="'+value+'"]').prop('selected',false);mQuery(el).trigger("chosen:updated");Mautic.loadAjaxModal('#MauticSharedModal',route,'get',header);}};Mautic.showModal=function(target){if(mQuery('.modal.in').length){if(mQuery(target).closest('.modal').length){mQuery('
').attr('data-modal-placeholder',target).insertAfter(mQuery(target));mQuery(target).attr('data-modal-moved',1);mQuery(target).appendTo('body');} -var activeModal=mQuery('.modal.in .modal-dialog:not(:has(.aside))').parents('.modal').last(),targetModal=mQuery(target);if(activeModal.length){targetModal.attr('data-previous-modal','#'+activeModal.attr('id'));activeModal.find('.modal-dialog').addClass('aside');var stackedDialogCount=mQuery('.modal.in .modal-dialog.aside').length;if(stackedDialogCount<=5){activeModal.find('.modal-dialog').addClass('aside-'+stackedDialogCount);} +var activeModal=mQuery('.modal.in .modal-dialog:not(:has(.aside))').parents('.modal').last(),targetModal=mQuery(target);if(activeModal.length&&activeModal.attr('id')!==targetModal.attr('id')){targetModal.attr('data-previous-modal','#'+activeModal.attr('id'));activeModal.find('.modal-dialog').addClass('aside');var stackedDialogCount=mQuery('.modal.in .modal-dialog.aside').length;if(stackedDialogCount<=5){activeModal.find('.modal-dialog').addClass('aside-'+stackedDialogCount);} mQuery(target).on('hide.bs.modal',function(){var modal=mQuery(this);var previous=modal.attr('data-previous-modal');if(previous){mQuery(previous).find('.modal-dialog').removeClass('aside');mQuery(modal).attr('data-previous-modal',undefined);} if(mQuery(modal).attr('data-modal-moved')){mQuery('[data-modal-placeholder').replaceWith(mQuery(modal));mQuery(modal).attr('data-modal-moved',undefined);}});}} mQuery(target).modal('show');};;MauticVars.liveCache=new Array();MauticVars.lastSearchStr="";MauticVars.globalLivecache=new Array();MauticVars.lastGlobalSearchStr="";Mautic.isNewEntity=function(idInputSelector){id=mQuery(idInputSelector);if(id.length){return id.val().match("^new_");} From 5d06914f26297ee271a5dd060128cb51b7e28ab8 Mon Sep 17 00:00:00 2001 From: Marianela Queme Date: Fri, 17 Feb 2017 15:45:14 +0000 Subject: [PATCH 024/510] modifying how fields are mapped in plugins --- app/bundles/PluginBundle/Assets/js/plugin.js | 37 ++++++++- app/bundles/PluginBundle/Config/config.php | 4 + .../Form/Type/CompanyFieldsType.php | 22 +++-- .../Form/Type/FeatureSettingsType.php | 42 ++++++++-- .../PluginBundle/Form/Type/FieldsType.php | 21 ++--- .../Form/Type/ObjectFieldsType.php | 82 +++++++++++++++++++ ...ls_featureSettings_leadFields_row.html.php | 26 ++++-- .../integration_object_fields_row.html.php | 36 ++++++++ .../Views/Integration/form.html.php | 26 +++++- plugins/MauticCrmBundle/Api/SalesforceApi.php | 2 +- .../Integration/CrmAbstractIntegration.php | 2 +- .../Integration/SalesforceIntegration.php | 19 ++--- 12 files changed, 267 insertions(+), 52 deletions(-) create mode 100644 app/bundles/PluginBundle/Form/Type/ObjectFieldsType.php create mode 100644 app/bundles/PluginBundle/Views/FormTheme/Integration/integration_object_fields_row.html.php diff --git a/app/bundles/PluginBundle/Assets/js/plugin.js b/app/bundles/PluginBundle/Assets/js/plugin.js index 80e4eed5e05..50de40d5f93 100644 --- a/app/bundles/PluginBundle/Assets/js/plugin.js +++ b/app/bundles/PluginBundle/Assets/js/plugin.js @@ -1,10 +1,39 @@ /* PluginBundle */ Mautic.addNewPluginField = function () { - mQuery('.add').click(function(e){ - e.preventDefault(); - if (mQuery("div.field div.active").is(":last-child")) return; - mQuery('div.field').find('div.active').removeClass('active').next().removeClass('hide').addClass('active'); + var items = mQuery('div.field').find('div.active'); + var currentItem = items.filter('.active'); + var selectors; + mQuery('.add').on('click', function() { + var nextItem = currentItem.next(); + currentItem.removeClass('active'); + if ( nextItem.length ) { + currentItem = nextItem.addClass('active').removeClass('hide'); + selectors = currentItem.find('select'); + selectors.each(function( ) { + mQuery( this ).prop('disabled', false).trigger("chosen:updated"); + }); + } }); + mQuery('.remove').on('click', function() { + var previousItem = currentItem.prev(); + currentItem.removeClass('active'); + if ( previousItem.length ) { + previousItem.addClass('active'); + selectors = currentItem.find('select'); + selectors.each(function( ) { + mQuery( this ).prop('disabled', true).trigger("chosen:updated"); + }); + currentItem.addClass('hide'); + currentItem = previousItem; + } + }); +}; +Mautic.matchFieldsType = function (index) { + var mauticField = mQuery('#integration_details_featureSettings_leadFields_m_' + index ).val(); + var integrationField = mQuery('#integration_details_featureSettings_leadFields_i_' + index ).val(); + var hiddenInput = mQuery('',{type:'hidden',id:'integration_details_featureSettings_leadFields_' + integrationField,name:'integration_details[featureSettings][leadFields][' + mauticField + ']', value:mauticField }); + + mQuery('#m_i_' + index ).empty().append( hiddenInput ); }; Mautic.initiateIntegrationAuthorization = function() { mQuery('#integration_details_in_auth').val(1); diff --git a/app/bundles/PluginBundle/Config/config.php b/app/bundles/PluginBundle/Config/config.php index 8a956f28480..21d544851c9 100644 --- a/app/bundles/PluginBundle/Config/config.php +++ b/app/bundles/PluginBundle/Config/config.php @@ -99,6 +99,10 @@ 'class' => 'Mautic\PluginBundle\Form\Type\CompanyFieldsType', 'alias' => 'integration_company_fields', ], + 'mautic.form.type.integration.object.fields' => [ + 'class' => 'Mautic\PluginBundle\Form\Type\ObjectFieldsType', + 'alias' => 'integration_object_fields', + ], 'mautic.form.type.integration.keys' => [ 'class' => 'Mautic\PluginBundle\Form\Type\KeysType', 'alias' => 'integration_keys', diff --git a/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php b/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php index 86678c3ea1f..ba03a5853aa 100644 --- a/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php +++ b/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php @@ -11,7 +11,6 @@ namespace Mautic\PluginBundle\Form\Type; -use Mautic\CoreBundle\Helper\InputHelper; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormInterface; @@ -29,16 +28,23 @@ class CompanyFieldsType extends AbstractType */ public function buildForm(FormBuilderInterface $builder, array $options) { + $index = 0; foreach ($options['integration_company_fields'] as $field => $details) { - $label = (is_array($details)) ? $details['label'] : $details; - $field = InputHelper::alphanum($field, false, '_'); + ++$index; + $builder->add('i_'.$index, 'choice', [ + 'choices' => array_keys($options['integration_company_fields']), + 'label' => 'Integration fields', + 'disabled' => ($index > 1) ? true : false, + ]); - $builder->add($field, 'choice', [ - 'choices' => $options['company_fields'], - 'label' => $label, - 'required' => (is_array($details) && isset($details['required'])) ? $details['required'] : false, + $builder->add('m_'.$index, 'choice', [ + 'choices' => $options['company_fields'], + 'label' => 'Mautic Company Field', + //'required' => (is_array($details) && isset($details['required'])) ? $details['required'] : false, 'label_attr' => ['class' => 'control-label'], - 'attr' => ['class' => 'form-control', 'data-placeholder' => ' '], + 'attr' => ['class' => 'form-control', 'data-placeholder' => ' ', 'onClick' => 'Mautic.matchFieldsType(this)'], + 'disabled' => ($index > 1) ? true : false, + ]); } } diff --git a/app/bundles/PluginBundle/Form/Type/FeatureSettingsType.php b/app/bundles/PluginBundle/Form/Type/FeatureSettingsType.php index a6a0bc92f08..4ce288db395 100644 --- a/app/bundles/PluginBundle/Form/Type/FeatureSettingsType.php +++ b/app/bundles/PluginBundle/Form/Type/FeatureSettingsType.php @@ -53,16 +53,28 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'ignore_field_cache' => true, ]; try { - $fields = $integration_object->getFormLeadFields($settings); - $fields = (isset($fields[0])) ? $fields[0] : $fields; + $fields = $integration_object->getFormLeadFields($settings); + $fields = (isset($fields[0])) ? $fields[0] : $fields; + $objects = isset($settings['feature_settings']['objects']) ? true : false; + unset($fields['company']); - if (isset($settings['feature_settings']['objects']) and in_array('company', $settings['feature_settings']['objects'])) { + if ($objects and in_array('company', $settings['feature_settings']['objects'])) { $integrationCompanyFields = $integration_object->getFormCompanyFields($settings); + if (isset($integrationCompanyFields['company'])) { $integrationCompanyFields = $integrationCompanyFields['company']; } } + if ($objects) { + foreach ($settings['feature_settings']['objects'] as $object) { + if ('company' == $object || 'Lead' == $object) { + continue; + } + $integrationObjectFields[$object] = $integration_object->getFormFieldsByObject($object); + } + } + if (!is_array($fields)) { $fields = []; } @@ -106,16 +118,32 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'companyFields', 'integration_company_fields', [ - 'label' => 'mautic.integration.comapanyfield_matches', - 'required' => false, - 'company_fields' => $companyFields, - //'data' => isset($data['leadFields']) && !empty($data['leadFields']) ? $data['leadFields'] : [], + 'label' => 'mautic.integration.comapanyfield_matches', + 'required' => false, + 'company_fields' => $companyFields, 'integration_company_fields' => $integrationCompanyFields, 'special_instructions' => $specialInstructions, 'alert_type' => $alertType, ] ); } + + if ($objects) { + foreach ($settings['feature_settings']['objects'] as $object) { + $form->add( + $object.'Fields', + 'integration_object_fields', + [ + 'label' => $object, + 'required' => false, + 'lead_fields' => $leadFields, + 'integration_fields' => $integrationObjectFields, + 'special_instructions' => $specialInstructions, + 'alert_type' => $alertType, + ] + ); + } + } if ($method == 'get' && $error) { $form->addError(new FormError($error)); } diff --git a/app/bundles/PluginBundle/Form/Type/FieldsType.php b/app/bundles/PluginBundle/Form/Type/FieldsType.php index 31a13b08276..e271cedeeb3 100644 --- a/app/bundles/PluginBundle/Form/Type/FieldsType.php +++ b/app/bundles/PluginBundle/Form/Type/FieldsType.php @@ -11,7 +11,6 @@ namespace Mautic\PluginBundle\Form\Type; -use Mautic\CoreBundle\Helper\InputHelper; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormInterface; @@ -29,22 +28,24 @@ class FieldsType extends AbstractType */ public function buildForm(FormBuilderInterface $builder, array $options) { - $index = 0; + $index = 0; + $integrationFields = [0 => ''] + array_combine(array_keys($options['integration_fields']), array_keys($options['integration_fields'])); foreach ($options['integration_fields'] as $field => $details) { ++$index; - $label = (is_array($details)) ? $details['label'] : $details; - $field = InputHelper::alphanum($field, false, '_'); - $builder->add('i_'.$index, 'choice', [ - 'choices' => array_keys($options['integration_fields']), - 'label' => 'Integration', + 'choices' => $integrationFields, + 'label' => false, + 'required' => true, + 'attr' => ['class' => 'form-control', 'data-placeholder' => ' ', 'onChange' => 'Mautic.matchFieldsType('.$index.')'], + 'disabled' => ($index > 1) ? true : false, ]); $builder->add('m_'.$index, 'choice', [ 'choices' => $options['lead_fields'], - 'label' => 'Mautic Lead Field', - 'required' => (is_array($details) && isset($details['required'])) ? $details['required'] : false, + 'label' => false, + 'required' => true, 'label_attr' => ['class' => 'control-label'], - 'attr' => ['class' => 'form-control', 'data-placeholder' => ' '], + 'attr' => ['class' => 'form-control', 'data-placeholder' => ' ', 'onChange' => 'Mautic.matchFieldsType('.$index.')'], + 'disabled' => ($index > 1) ? true : false, ]); } } diff --git a/app/bundles/PluginBundle/Form/Type/ObjectFieldsType.php b/app/bundles/PluginBundle/Form/Type/ObjectFieldsType.php new file mode 100644 index 00000000000..46bb8ca617f --- /dev/null +++ b/app/bundles/PluginBundle/Form/Type/ObjectFieldsType.php @@ -0,0 +1,82 @@ + $details) { + ++$index; + + $builder->add('i_'.$index, 'choice', [ + 'choices' => array_keys($options['integration_fields']), + 'label' => 'Integration', + 'disabled' => ($index > 1) ? true : false, + ]); + $builder->add('m_'.$index, 'choice', [ + 'choices' => $options['lead_fields'], + 'label' => 'Mautic Lead Field', + 'required' => (is_array($details) && isset($details['required'])) ? $details['required'] : false, + 'label_attr' => ['class' => 'control-label'], + 'attr' => ['class' => 'form-control', 'data-placeholder' => ' '], + 'disabled' => ($index > 1) ? true : false, + ]); + } + } + + /** + * @param OptionsResolver $resolver + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setRequired(['integration_fields', 'lead_fields']); + $resolver->setDefaults( + [ + 'special_instructions' => '', + 'alert_type' => '', + 'allow_extra_fields' => true, + ] + ); + } + + /** + * @return string + */ + public function getName() + { + return 'integration_object_fields'; + } + + /** + * {@inheritdoc} + */ + public function buildView(FormView $view, FormInterface $form, array $options) + { + $view->vars['specialInstructions'] = $options['special_instructions']; + $view->vars['alertType'] = $options['alert_type']; + } +} diff --git a/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php b/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php index 6c8003c7ea6..014d061dd2d 100644 --- a/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php +++ b/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php @@ -18,21 +18,35 @@
+
+
trans('mautic.plugins.integration.fields'); ?>
+
trans('mautic.plugins.mautic.fields'); ?>
errors($form); ?> - + + children as $child): ?> -
" class="row 2) { echo 'hide'; } else { echo 'active'; }?>"> - -
+
+ + + +
+ + + + +
row($child); ?>
-
+ +
+
@@ -41,6 +55,6 @@
- Add a field + Add field
\ No newline at end of file diff --git a/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_object_fields_row.html.php b/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_object_fields_row.html.php new file mode 100644 index 00000000000..7d5c4ec7943 --- /dev/null +++ b/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_object_fields_row.html.php @@ -0,0 +1,36 @@ + + +
"FieldsContainer"> + +
+ trans($specialInstructions); ?> +
+ + +
+ errors($form); ?> + + children as $child): ?> + +
+ +
+ row($child); ?> +
+ +
+ + + +
+
\ No newline at end of file diff --git a/app/bundles/PluginBundle/Views/Integration/form.html.php b/app/bundles/PluginBundle/Views/Integration/form.html.php index c0e6e36e79e..db95eb0e8f9 100644 --- a/app/bundles/PluginBundle/Views/Integration/form.html.php +++ b/app/bundles/PluginBundle/Views/Integration/form.html.php @@ -26,8 +26,21 @@ $fieldHtml = ($hasFields) ? $view['form']->row($form['featureSettings']['leadFields']) : ''; $companyFieldHtml = (isset($form['featureSettings']['companyFields']) && count($form['featureSettings']['companyFields'])) ? $view['form']->row($form['featureSettings']['companyFields']) : ''; -$fieldLabel = ($hasFields) ? $form['featureSettings']['leadFields']->vars['label'] : ''; -$fieldTabClass = ($hasFields) ? '' : ' hide'; +$objects = isset($form['featureSettings']['objects']) ? $form['featureSettings']['objects'] : []; +$index = 0; +foreach ($objects->vars['value'] as $object) { + // if ('company' == $object || 'Lead' == $object) { + // continue; + //} + + print_r($object); + + ++$index; + // $objectFieldHtml[$object] = (isset($form['featureSettings'][$object.'Fields']) && count($form['featureSettings'][$object.'Fields'])) ? $view['form']->row($form['featureSettings'][$object.'Fields']) : ''; +} + +$fieldLabel = ($hasFields) ? $form['featureSettings']['leadFields']->vars['label'] : ''; +$fieldTabClass = ($hasFields) ? '' : ' hide'; unset($form['featureSettings']['leadFields']); unset($form['featureSettings']['companyFields']); ?> @@ -101,5 +114,14 @@

trans('mautic.integration.comapanyfield_matches'); ?>

+ + $fieldHtml) { + ; + }?> +
+

+ +
+ end($form); ?> diff --git a/plugins/MauticCrmBundle/Api/SalesforceApi.php b/plugins/MauticCrmBundle/Api/SalesforceApi.php index bcbb3ed73e1..d0db4d4a5ee 100644 --- a/plugins/MauticCrmBundle/Api/SalesforceApi.php +++ b/plugins/MauticCrmBundle/Api/SalesforceApi.php @@ -253,8 +253,8 @@ public function getLeads($query, $object) } if (!empty($fields) and isset($query['start'])) { - $fields = implode(', ', $fields); $fields[] = 'Id'; + $fields = implode(', ', $fields); $config = $this->integration->mergeConfigToFeatureSettings([]); if (isset($config['updateOwner']) && isset($config['updateOwner'][0]) && $config['updateOwner'][0] == 'updateOwner') { diff --git a/plugins/MauticCrmBundle/Integration/CrmAbstractIntegration.php b/plugins/MauticCrmBundle/Integration/CrmAbstractIntegration.php index 0ecbf303f3c..ced05b7db8b 100644 --- a/plugins/MauticCrmBundle/Integration/CrmAbstractIntegration.php +++ b/plugins/MauticCrmBundle/Integration/CrmAbstractIntegration.php @@ -341,7 +341,7 @@ public function getMauticLead($data, $persist = true, $socialCache = null, $iden * * @return array|mixed */ - protected function getFormFieldsByObject($object) + public function getFormFieldsByObject($object) { $settings['feature_settings']['objects'] = [$object => $object]; diff --git a/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php b/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php index f1a40f55240..bbe2b2f9afd 100644 --- a/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php +++ b/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php @@ -260,19 +260,12 @@ public function getAvailableLeadFields($settings = []) } else { $type = 'string'; } - if ($sfObject !== 'company') { - $salesFields[$sfObject][$fieldInfo['name'].' - '.$sfObject] = [ - 'type' => $type, - 'label' => $sfObject.' - '.$fieldInfo['label'], - 'required' => $isRequired($fieldInfo, $sfObject), - ]; - } else { - $salesFields[$sfObject][$fieldInfo['name']] = [ - 'type' => $type, - 'label' => $fieldInfo['label'], - 'required' => $isRequired($fieldInfo, $sfObject), - ]; - } + + $salesFields[$sfObject][$fieldInfo['name']] = [ + 'type' => $type, + 'label' => $fieldInfo['label'], + 'required' => $isRequired($fieldInfo, $sfObject), + ]; } $this->cache->set('leadFields'.$cacheSuffix, $salesFields[$sfObject]); From 84bb3974116f5c9ed8697957aa9948ee88b56440 Mon Sep 17 00:00:00 2001 From: Marianela Queme Date: Fri, 17 Feb 2017 15:46:28 +0000 Subject: [PATCH 025/510] moved where id was being assigned to the array of fields --- plugins/MauticCrmBundle/Api/SalesforceApi.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/MauticCrmBundle/Api/SalesforceApi.php b/plugins/MauticCrmBundle/Api/SalesforceApi.php index bcbb3ed73e1..d0db4d4a5ee 100644 --- a/plugins/MauticCrmBundle/Api/SalesforceApi.php +++ b/plugins/MauticCrmBundle/Api/SalesforceApi.php @@ -253,8 +253,8 @@ public function getLeads($query, $object) } if (!empty($fields) and isset($query['start'])) { - $fields = implode(', ', $fields); $fields[] = 'Id'; + $fields = implode(', ', $fields); $config = $this->integration->mergeConfigToFeatureSettings([]); if (isset($config['updateOwner']) && isset($config['updateOwner'][0]) && $config['updateOwner'][0] == 'updateOwner') { From 81968c07d5c5f6fb665125602444566f2aec5ad9 Mon Sep 17 00:00:00 2001 From: Stephen Ostrow Date: Thu, 12 Jan 2017 00:03:01 -0500 Subject: [PATCH 026/510] Enhance the Top Segments Dashboard widget to link to Segment's Contacts Changes the displayed number of Contacts in the list of Top Segments to be a link to the Contacts listing page filtered by that Segment --- .../LeadBundle/EventListener/DashboardSubscriber.php | 7 +++++-- app/bundles/LeadBundle/Model/ListModel.php | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/bundles/LeadBundle/EventListener/DashboardSubscriber.php b/app/bundles/LeadBundle/EventListener/DashboardSubscriber.php index ba6ba12fa50..ac9085df110 100644 --- a/app/bundles/LeadBundle/EventListener/DashboardSubscriber.php +++ b/app/bundles/LeadBundle/EventListener/DashboardSubscriber.php @@ -167,8 +167,9 @@ public function onWidgetDetailGenerate(WidgetDetailEvent $event) // Build table rows with links if ($lists) { foreach ($lists as &$list) { - $listUrl = $this->router->generate('mautic_segment_action', ['objectAction' => 'edit', 'objectId' => $list['id']]); - $row = [ + $listUrl = $this->router->generate('mautic_segment_action', ['objectAction' => 'edit', 'objectId' => $list['id']]); + $contactUrl = $this->router->generate('mautic_contact_index', ['search' => 'segment:'.$list['alias']]); + $row = [ [ 'value' => $list['name'], 'type' => 'link', @@ -176,6 +177,8 @@ public function onWidgetDetailGenerate(WidgetDetailEvent $event) ], [ 'value' => $list['leads'], + 'type' => 'link', + 'link' => $contactUrl, ], ]; $items[] = $row; diff --git a/app/bundles/LeadBundle/Model/ListModel.php b/app/bundles/LeadBundle/Model/ListModel.php index 81bf7e1e71e..9b5122f01e5 100644 --- a/app/bundles/LeadBundle/Model/ListModel.php +++ b/app/bundles/LeadBundle/Model/ListModel.php @@ -1022,7 +1022,7 @@ protected function batchSleep() public function getTopLists($limit = 10, $dateFrom = null, $dateTo = null, $filters = []) { $q = $this->em->getConnection()->createQueryBuilder(); - $q->select('COUNT(t.date_added) AS leads, ll.id, ll.name') + $q->select('COUNT(t.date_added) AS leads, ll.id, ll.name, ll.alias') ->from(MAUTIC_TABLE_PREFIX.'lead_lists_leads', 't') ->join('t', MAUTIC_TABLE_PREFIX.'lead_lists', 'll', 'll.id = t.leadlist_id') ->orderBy('leads', 'DESC') From 6353064914a93db56780629368381851bdf7a47e Mon Sep 17 00:00:00 2001 From: Marianela Queme Date: Mon, 20 Feb 2017 09:44:03 +0000 Subject: [PATCH 027/510] field mapping ui changes --- app/bundles/PluginBundle/Assets/js/plugin.js | 3 ++- .../PluginBundle/Form/Type/FieldsType.php | 4 ++-- ...ls_featureSettings_leadFields_row.html.php | 24 +++++++++++++------ 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/app/bundles/PluginBundle/Assets/js/plugin.js b/app/bundles/PluginBundle/Assets/js/plugin.js index 50de40d5f93..427d116b6f0 100644 --- a/app/bundles/PluginBundle/Assets/js/plugin.js +++ b/app/bundles/PluginBundle/Assets/js/plugin.js @@ -14,7 +14,7 @@ Mautic.addNewPluginField = function () { }); } }); - mQuery('.remove').on('click', function() { + mQuery('.removeField').on('click', function() { var previousItem = currentItem.prev(); currentItem.removeClass('active'); if ( previousItem.length ) { @@ -27,6 +27,7 @@ Mautic.addNewPluginField = function () { currentItem = previousItem; } }); + return true; }; Mautic.matchFieldsType = function (index) { var mauticField = mQuery('#integration_details_featureSettings_leadFields_m_' + index ).val(); diff --git a/app/bundles/PluginBundle/Form/Type/FieldsType.php b/app/bundles/PluginBundle/Form/Type/FieldsType.php index e271cedeeb3..d582e5bda42 100644 --- a/app/bundles/PluginBundle/Form/Type/FieldsType.php +++ b/app/bundles/PluginBundle/Form/Type/FieldsType.php @@ -37,7 +37,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'label' => false, 'required' => true, 'attr' => ['class' => 'form-control', 'data-placeholder' => ' ', 'onChange' => 'Mautic.matchFieldsType('.$index.')'], - 'disabled' => ($index > 1) ? true : false, + 'disabled' => ($index > 1 && !in_array($field, $options['data'])) ? true : false, ]); $builder->add('m_'.$index, 'choice', [ 'choices' => $options['lead_fields'], @@ -45,7 +45,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'required' => true, 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control', 'data-placeholder' => ' ', 'onChange' => 'Mautic.matchFieldsType('.$index.')'], - 'disabled' => ($index > 1) ? true : false, + 'disabled' => ($index > 1 && !in_array($field, $options['data'])) ? true : false, ]); } } diff --git a/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php b/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php index 014d061dd2d..0108d6e0651 100644 --- a/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php +++ b/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php @@ -24,28 +24,38 @@ errors($form); ?> + children as $child): ?> -
" class="row 2 && (!isset($child->vars['data']) || empty($child->vars['data']))) { echo 'hide'; -} else { +} elseif ((!isset($child->vars['data']) || empty($child->vars['data'])) || $indexCount == count($child->vars['data'])) { echo 'active'; }?>">
- - + +
- + + vars['data']) && !empty($child->vars['data']))) { + $mauticField = $child->vars['data']; +} ?> -
row($child); ?>
-
+
+ + + +
From b4777dda1390a4b704c72416cf5ee1f77b9b195f Mon Sep 17 00:00:00 2001 From: Marianela Queme Date: Mon, 20 Feb 2017 12:58:20 +0000 Subject: [PATCH 028/510] changes to plugin field mapping --- .../PluginBundle/Form/Type/FieldsType.php | 9 ++++++ ...ls_featureSettings_leadFields_row.html.php | 28 ++++++++++++------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/app/bundles/PluginBundle/Form/Type/FieldsType.php b/app/bundles/PluginBundle/Form/Type/FieldsType.php index d582e5bda42..38bbd717260 100644 --- a/app/bundles/PluginBundle/Form/Type/FieldsType.php +++ b/app/bundles/PluginBundle/Form/Type/FieldsType.php @@ -39,6 +39,15 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'attr' => ['class' => 'form-control', 'data-placeholder' => ' ', 'onChange' => 'Mautic.matchFieldsType('.$index.')'], 'disabled' => ($index > 1 && !in_array($field, $options['data'])) ? true : false, ]); + $builder->add('update_mautic'.$index, + 'yesno_button_group', + [ + 'label' => false, + 'data' => isset($options['data']['update_mautic']) ? (bool) $options['data']['update_mautic'] : true, + 'no_label' => '<-', + 'yes_label' => '->', + ]); + $builder->add('m_'.$index, 'choice', [ 'choices' => $options['lead_fields'], 'label' => false, diff --git a/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php b/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php index 0108d6e0651..f14d208115f 100644 --- a/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php +++ b/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php @@ -18,9 +18,12 @@
-
-
trans('mautic.plugins.integration.fields'); ?>
-
trans('mautic.plugins.mautic.fields'); ?>
+
+
+
trans('mautic.plugins.integration.fields'); ?>
+
trans('mautic.plugins.mautic.direction'); ?>
+
trans('mautic.plugins.mautic.fields'); ?>
+
errors($form); ?> @@ -35,7 +38,7 @@ } elseif ((!isset($child->vars['data']) || empty($child->vars['data'])) || $indexCount == count($child->vars['data'])) { echo 'active'; }?>"> -
+
@@ -46,19 +49,24 @@ } ?> -
+
row($child); ?>
-
- - - -
+
+ 1): + ?> +
+ + + + +
From 2ebfda2f37f6af52cc78ad63d3e365f0c4c9d0e7 Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Mon, 20 Feb 2017 19:10:53 +0100 Subject: [PATCH 029/510] Init commit --- app/bundles/LeadBundle/Assets/js/lead.js | 2 +- .../LeadBundle/Entity/LeadListRepository.php | 230 +++++++++++++++++- .../LeadBundle/Form/Type/FilterType.php | 1 + app/bundles/LeadBundle/Model/ListModel.php | 205 ++++++++++++++++ .../Translations/en_US/messages.ini | 14 ++ 5 files changed, 442 insertions(+), 10 deletions(-) diff --git a/app/bundles/LeadBundle/Assets/js/lead.js b/app/bundles/LeadBundle/Assets/js/lead.js index 0838dba7127..1220f37f9b9 100644 --- a/app/bundles/LeadBundle/Assets/js/lead.js +++ b/app/bundles/LeadBundle/Assets/js/lead.js @@ -326,7 +326,7 @@ Mautic.addLeadListFilter = function (elId) { var prototype = mQuery('.available-filters').data('prototype'); var fieldType = mQuery(filterId).data('field-type'); var fieldObject = mQuery(filterId).data('field-object'); - var isSpecial = (mQuery.inArray(fieldType, ['leadlist', 'lead_email_received', 'tags', 'multiselect', 'boolean', 'select', 'country', 'timezone', 'region', 'stage', 'locale', 'globalcategory']) != -1); + var isSpecial = (mQuery.inArray(fieldType, ['leadlist', 'lead_email_received', 'lead_email_sent', 'tags', 'multiselect', 'boolean', 'select', 'country', 'timezone', 'region', 'stage', 'locale', 'globalcategory']) != -1); prototype = prototype.replace(/__name__/g, filterNum); prototype = prototype.replace(/__label__/g, label); diff --git a/app/bundles/LeadBundle/Entity/LeadListRepository.php b/app/bundles/LeadBundle/Entity/LeadListRepository.php index 6d1e427b3e5..e04e9cebf13 100644 --- a/app/bundles/LeadBundle/Entity/LeadListRepository.php +++ b/app/bundles/LeadBundle/Entity/LeadListRepository.php @@ -672,7 +672,7 @@ public function getListFilterExpr($filters, &$parameters, QueryBuilder $q, $not if ($details['type'] == 'datetime' || $details['type'] == 'date') { $relativeDateStrings = $this->getRelativeDateStrings(); // Check if the column type is a date/time stamp - $isTimestamp = ($columnType instanceof UTCDateTimeType || $details['type'] == 'datetime'); + $isTimestamp = ($details['type'] == 'datetime' || $columnType instanceof UTCDateTimeType); $getDate = function (&$string) use ($isTimestamp, $relativeDateStrings, &$details, &$func, $not) { $key = array_search($string, $relativeDateStrings); $dtHelper = new DateTimeHelper('midnight today', null, 'local'); @@ -859,8 +859,15 @@ public function getListFilterExpr($filters, &$parameters, QueryBuilder $q, $not switch ($details['field']) { case 'hit_url': - $operand = (($func == 'eq') || ($func == 'like')) ? 'EXISTS' : 'NOT EXISTS'; - + case 'referer': + case 'source': + case 'url_title': + $operand = (($func == 'eq') || ($func == 'like') || ($func == 'regexp')) ? 'EXISTS' : 'NOT EXISTS'; + + $column = $details['field']; + if($column == 'hit_url'){ + $column = 'url'; + } $subqb = $this->_em->getConnection() ->createQueryBuilder() ->select('id') @@ -869,20 +876,19 @@ public function getListFilterExpr($filters, &$parameters, QueryBuilder $q, $not case 'eq': case 'neq': $parameters[$parameter] = $details['filter']; - $subqb->where( $q->expr()->andX( - $q->expr()->eq($alias.'.url', $exprParameter), + $q->expr()->eq($alias.'.'.$column, $exprParameter), $q->expr()->eq($alias.'.lead_id', 'l.id') ) ); break; case 'like': case '!like': - $details['filter'] = '%'.$details['filter'].'%'; - $subqb->where( + $parameters[$parameter] = '%'.$details['filter'].'%'; + $subqb->where( $q->expr()->andX( - $q->expr()->like($alias.'.url', $exprParameter), + $q->expr()->like($alias.'.'.$column, $exprParameter), $q->expr()->eq($alias.'.lead_id', 'l.id') ) ); @@ -894,7 +900,7 @@ public function getListFilterExpr($filters, &$parameters, QueryBuilder $q, $not $subqb->where( $q->expr()->andX( $q->expr()->eq($alias.'.lead_id', 'l.id'), - $alias.'.url'.$not.' REGEXP '.$exprParameter + $alias.'.'.$column.$not.' REGEXP '.$exprParameter ) ); break; @@ -906,6 +912,207 @@ public function getListFilterExpr($filters, &$parameters, QueryBuilder $q, $not } $groupExpr->add(sprintf('%s (%s)', $operand, $subqb->getSQL())); break; + case 'hit_url_date': + case 'lead_email_read_date': + $operand = ($func == 'between' || in_array($func, ['eq', 'gt', 'lt', 'gte', 'lte'])) ? 'EXISTS' : 'NOT EXISTS'; + $table = 'page_hits'; + $column = 'date_hit'; + if ($details['field'] == 'lead_email_read_date') { + $column = 'date_read'; + $table = 'email_stats'; + } + $subqb = $this->_em->getConnection() + ->createQueryBuilder() + ->select('id') + ->from(MAUTIC_TABLE_PREFIX.$table, $alias); + switch ($func) { + case 'eq': + case 'neq': + $parameters[$parameter] = $details['filter']; + $subqb->where($q->expr() + ->andX($q->expr() + ->eq($alias.'.'.$column, $exprParameter), $q->expr() + ->eq($alias.'.lead_id', 'l.id'))); + break; + case 'between': + case 'notBetween': + // Filter should be saved with double || to separate options + $parameter2 = $this->generateRandomParameterName(); + $parameters[$parameter] = $details['filter'][0]; + $parameters[$parameter2] = $details['filter'][1]; + $exprParameter2 = ":$parameter2"; + $ignoreAutoFilter = true; + $field = $column; + if ($func == 'between') { + $subqb->where($q->expr() + ->andX( + $q->expr()->gte($alias.'.'.$field, $exprParameter), + $q->expr()->lt($alias.'.'.$field, $exprParameter2), + $q->expr()->eq($alias.'.lead_id', 'l.id') + )); + } else { + $subqb->where($q->expr() + ->andX( + $q->expr()->lt($alias.'.'.$field, $exprParameter), + $q->expr()->gte($alias.'.'.$field, $exprParameter2), + $q->expr()->eq($alias.'.lead_id', 'l.id') + )); + } + break; + default: + $parameters[$parameter] = $details['filter']; + $subqb->where($q->expr() + ->andX($q->expr() + ->$func($alias.'.'.$column, $exprParameter), $q->expr() + ->eq($alias.'.lead_id', 'l.id'))); + break; + } + // Specific lead + if (!empty($leadId)) { + $subqb->andWhere($subqb->expr() + ->eq($alias.'.lead_id', $leadId)); + } + $groupExpr->add(sprintf('%s (%s)', $operand, $subqb->getSQL())); + break; + case 'page_id': + case 'email_id': + case 'redirect_id': + case 'notification': + $operand = ($func == 'eq') ? 'EXISTS' : 'NOT EXISTS'; + $column = $details['field']; + $table = 'page_hits'; + $select = 'id'; + + if($column == 'notification'){ + $table = 'push_ids'; + } + + $subqb = $this->_em->getConnection() + ->createQueryBuilder() + ->select($select) + ->from(MAUTIC_TABLE_PREFIX.$table, $alias); + + if($details['filter'] == 1){ + $subqb->where($q->expr() + ->andX($q->expr() + ->isNotNull($alias.'.'.$column), $q->expr() + ->eq($alias.'.lead_id', 'l.id'))); + }else{ + $subqb->where($q->expr() + ->andX($q->expr() + ->isNull($alias.'.'.$column), $q->expr() + ->eq($alias.'.lead_id', 'l.id'))); + } + // Specific lead + if (!empty($leadId)) { + $subqb->andWhere($subqb->expr() + ->eq($alias.'.lead_id', $leadId)); + } + $groupExpr->add(sprintf('%s (%s)', $operand, $subqb->getSQL())); + break; + case 'sessions': + $operand = 'EXISTS'; + $column = $details['field']; + $table = 'page_hits'; + $select = 'COUNT(id)'; + + $subqb = $this->_em->getConnection() + ->createQueryBuilder() + ->select($select) + ->from(MAUTIC_TABLE_PREFIX.$table, $alias); + + $alias2 = $this->generateRandomParameterName(); + $subqb2 = $this->_em->getConnection() + ->createQueryBuilder() + ->select($alias2.'.id') + ->from(MAUTIC_TABLE_PREFIX.$table, $alias2); + + + $subqb2->where($q->expr() + ->andX( + $q->expr()->eq($alias2.'.lead_id', 'l.id'), + $q->expr()->gt($alias2.'.date_hit', '('.$alias.'.date_hit - INTERVAL 30 MINUTE)'), + $q->expr()->lt($alias2.'.date_hit', $alias.'.date_hit') + )); + + $parameters[$parameter] = $details['filter']; + $subqb->where($q->expr() + ->andX($q->expr() + ->eq($alias.'.lead_id', 'l.id'),$q->expr() + ->isNull($alias.'.email_id'),$q->expr() + ->isNull($alias.'.redirect_id'), + sprintf('%s (%s)', 'NOT EXISTS', $subqb2->getSQL()))); + + $opr = ''; + switch ($func) { + case 'eq': + $opr = '='; + break; + case 'gt': + $opr = '>'; + break; + case 'gte': + $opr = '>='; + break; + case 'lt': + $opr = '<'; + break; + case 'lte': + $opr = '<='; + break; + } + if ($opr) { + $parameters[$parameter] = $details['filter']; + $subqb->having($select.$opr.$details['filter']); + } + $groupExpr->add(sprintf('%s (%s)', $operand, $subqb->getSQL())); + break; + case 'hit_url_count': + case 'lead_email_received_count': + $operand = 'EXISTS'; + $column = $details['field']; + $table = 'page_hits'; + $select = 'COUNT(id)'; + if ($details['field'] == 'lead_email_received_count') { + $table = 'email_stats'; + $select = 'SUM(open_count)'; + } + $subqb = $this->_em->getConnection() + ->createQueryBuilder() + ->select($select) + ->from(MAUTIC_TABLE_PREFIX.$table, $alias); + + $parameters[$parameter] = $details['filter']; + $subqb->where($q->expr() + ->andX($q->expr() + ->eq($alias.'.lead_id', 'l.id'))); + + $opr = ''; + switch ($func) { + case 'eq': + $opr = '='; + break; + case 'gt': + $opr = '>'; + break; + case 'gte': + $opr = '>='; + break; + case 'lt': + $opr = '<'; + break; + case 'lte': + $opr = '<='; + break; + } + + if ($opr) { + $parameters[$parameter] = $details['filter']; + $subqb->having($select.$opr.$details['filter']); + } + + $groupExpr->add(sprintf('%s (%s)', $operand, $subqb->getSQL())); + break; case 'dnc_bounced': case 'dnc_unsubscribed': @@ -958,6 +1165,7 @@ public function getListFilterExpr($filters, &$parameters, QueryBuilder $q, $not case 'tags': case 'globalcategory': case 'lead_email_received': + case 'lead_email_sent': // Special handling of lead lists and tags $func = in_array($func, ['eq', 'in']) ? 'EXISTS' : 'NOT EXISTS'; @@ -1008,6 +1216,10 @@ public function getListFilterExpr($filters, &$parameters, QueryBuilder $q, $not ); $parameters[$trueParameter] = true; break; + case 'lead_email_sent': + $table = 'email_stats'; + $column = 'email_id'; + break; } $subExpr->add( diff --git a/app/bundles/LeadBundle/Form/Type/FilterType.php b/app/bundles/LeadBundle/Form/Type/FilterType.php index 27008c9e5c7..20c54b40670 100644 --- a/app/bundles/LeadBundle/Form/Type/FilterType.php +++ b/app/bundles/LeadBundle/Form/Type/FilterType.php @@ -105,6 +105,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) $type = 'choice'; break; case 'lead_email_received': + case 'lead_email_sent': if (!isset($data['filter'])) { $data['filter'] = []; } elseif (!is_array($data['filter'])) { diff --git a/app/bundles/LeadBundle/Model/ListModel.php b/app/bundles/LeadBundle/Model/ListModel.php index 81bf7e1e71e..bdffbaeb3a9 100644 --- a/app/bundles/LeadBundle/Model/ListModel.php +++ b/app/bundles/LeadBundle/Model/ListModel.php @@ -304,6 +304,54 @@ public function getChoiceFields() ), 'object' => 'lead', ], + 'lead_email_sent' => [ + 'label' => $this->translator->trans('mautic.lead.list.filter.lead_email_sent'), + 'properties' => [ + 'type' => 'lead_email_received', + ], + 'operators' => $this->getOperatorsForFieldType( + [ + 'include' => [ + 'in', + '!in', + ], + ] + ), + 'object' => 'lead', + ], + 'lead_email_read_date' => [ + 'label' => $this->translator->trans('mautic.lead.list.filter.lead_email_read_date'), + 'properties' => ['type' => 'datetime'], + 'operators' => $this->getOperatorsForFieldType( + [ + 'include' => [ + '=', + '!=', + 'gt', + 'lt', + 'gte', + 'lte', + ], + ] + ), + 'object' => 'lead', + ], + 'lead_email_read_count' => [ + 'label' => $this->translator->trans('mautic.lead.list.filter.lead_email_read_count'), + 'properties' => ['type' => 'number'], + 'operators' => $this->getOperatorsForFieldType( + [ + 'include' => [ + '=', + 'gt', + 'gte', + 'lt', + 'lte', + ], + ] + ), + 'object' => 'lead', + ], 'tags' => [ 'label' => $this->translator->trans('mautic.lead.list.filter.tags'), 'properties' => [ @@ -369,13 +417,170 @@ public function getChoiceFields() [ 'include' => [ '=', + '!=', 'like', + '!like', 'regexp', + '!regexp', ], ] ), 'object' => 'lead', ], + 'hit_url_date' => [ + 'label' => $this->translator->trans('mautic.lead.list.filter.visited_url_date'), + 'properties' => ['type' => 'datetime'], + 'operators' => $this->getOperatorsForFieldType( + [ + 'include' => [ + '=', + '!=', + 'gt', + 'lt', + 'gte', + 'lte', + ], + ] + ), + 'object' => 'lead', + ], + 'hit_url_count' => [ + 'label' => $this->translator->trans('mautic.lead.list.filter.visited_url_count'), + 'properties' => ['type' => 'number'], + 'operators' => $this->getOperatorsForFieldType( + [ + 'include' => [ + '=', + 'gt', + 'gte', + 'lt', + 'lte', + ], + ] + ), + 'object' => 'lead', + ], + 'sessions' => [ + 'label' => $this->translator->trans('mautic.lead.list.filter.session'), + 'properties' => ['type' => 'number'], + 'operators' => $this->getOperatorsForFieldType( + [ + 'include' => [ + '=', + 'gt', + 'gte', + 'lt', + 'lte', + ], + ] + ), + 'object' => 'lead', + ], + 'referer' => [ + 'label' => $this->translator->trans('mautic.lead.list.filter.referer'), + 'properties' => [ + 'type' => 'text', + ], + 'operators' => $this->getOperatorsForFieldType( + [ + 'include' => [ + '=', + '!=', + 'like', + '!like', + 'regexp', + '!regexp', + ], + ] + ), + 'object' => 'lead', + ], + 'url_title' => [ + 'label' => $this->translator->trans('mautic.lead.list.filter.url_title'), + 'properties' => [ + 'type' => 'text', + ], + 'operators' => $this->getOperatorsForFieldType( + [ + 'include' => [ + '=', + '!=', + 'like', + '!like', + 'regexp', + '!regexp', + ], + ] + ), + 'object' => 'lead', + ], + 'source' => [ + 'label' => $this->translator->trans('mautic.lead.list.filter.source'), + 'properties' => [ + 'type' => 'text', + ], + 'operators' => $this->getOperatorsForFieldType( + [ + 'include' => [ + '=', + '!=', + 'like', + '!like', + 'regexp', + '!regexp', + ], + ] + ), + 'object' => 'lead', + ], + 'notification' => [ + 'label' => $this->translator->trans('mautic.lead.list.filter.notification'), + 'properties' => [ + 'type' => 'boolean', + 'list' => [ + 0 => $this->translator->trans('mautic.core.form.no'), + 1 => $this->translator->trans('mautic.core.form.yes'), + ], + ], + 'operators' => $this->getOperatorsForFieldType('bool'), + 'object' => 'lead', + ], + 'page_id' => [ + 'label' => $this->translator->trans('mautic.lead.list.filter.page_id'), + 'properties' => [ + 'type' => 'boolean', + 'list' => [ + 0 => $this->translator->trans('mautic.core.form.no'), + 1 => $this->translator->trans('mautic.core.form.yes'), + ], + ], + 'operators' => $this->getOperatorsForFieldType('bool'), + 'object' => 'lead', + ], + 'email_id' => [ + 'label' => $this->translator->trans('mautic.lead.list.filter.email_id'), + 'properties' => [ + 'type' => 'boolean', + 'list' => [ + 0 => $this->translator->trans('mautic.core.form.no'), + 1 => $this->translator->trans('mautic.core.form.yes'), + ], + ], + 'operators' => $this->getOperatorsForFieldType('bool'), + 'object' => 'lead', + ], + 'redirect_id' => [ + 'label' => $this->translator->trans('mautic.lead.list.filter.redirect_id'), + 'properties' => [ + 'type' => 'boolean', + 'list' => [ + 0 => $this->translator->trans('mautic.core.form.no'), + 1 => $this->translator->trans('mautic.core.form.yes'), + ], + ], + 'operators' => $this->getOperatorsForFieldType('bool'), + 'object' => 'lead', + ], 'stage' => [ 'label' => $this->translator->trans('mautic.lead.lead.field.stage'), 'properties' => [ diff --git a/app/bundles/LeadBundle/Translations/en_US/messages.ini b/app/bundles/LeadBundle/Translations/en_US/messages.ini index 6661619fab1..8e155e10032 100755 --- a/app/bundles/LeadBundle/Translations/en_US/messages.ini +++ b/app/bundles/LeadBundle/Translations/en_US/messages.ini @@ -270,6 +270,20 @@ mautic.lead.list.filter.last_active="Date Last Active" mautic.lead.list.filter.date_modified="Modified date" mautic.lead.list.filter.lists="Segment Membership" mautic.lead.list.filter.lead_email_received="Email Read" +mautic.lead.list.filter.lead_email_sent="Email Sent" +mautic.lead.list.filter.lead_email_read_date="Email Read Date" +mautic.lead.list.filter.lead_email_read_count="Email Read Count" +mautic.lead.list.filter.visited_url="Visited URL" +mautic.lead.list.filter.visited_url_count="Visited URL Count" +mautic.lead.list.filter.url_title="Page title" +mautic.lead.list.filter.source="Source" +mautic.lead.list.filter.session="Sessions" +mautic.lead.list.filter.redirect_id="URL as redirect" +mautic.lead.list.filter.email_id="URL from email" +mautic.lead.list.filter.page_id="URL from landing page" +mautic.lead.list.filter.referer="Visited URL Referer" +mautic.lead.list.filter.visited_url_date="Visited URL Date" +mautic.lead.list.filter.notification="Notifications" mautic.lead.list.filter.owner="Owner" mautic.lead.list.filter.tags="Tags" mautic.lead.list.filter.visited_url="Visited URL" From e579097c5e71a9cffbf4ecea670ef98abfd6198a Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Mon, 20 Feb 2017 19:24:38 +0100 Subject: [PATCH 030/510] Minor --- app/bundles/LeadBundle/Entity/LeadListRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/bundles/LeadBundle/Entity/LeadListRepository.php b/app/bundles/LeadBundle/Entity/LeadListRepository.php index e04e9cebf13..5e176b912f2 100644 --- a/app/bundles/LeadBundle/Entity/LeadListRepository.php +++ b/app/bundles/LeadBundle/Entity/LeadListRepository.php @@ -862,7 +862,7 @@ public function getListFilterExpr($filters, &$parameters, QueryBuilder $q, $not case 'referer': case 'source': case 'url_title': - $operand = (($func == 'eq') || ($func == 'like') || ($func == 'regexp')) ? 'EXISTS' : 'NOT EXISTS'; + $operand = in_array($func, ['eq', 'like', 'regexp' ,'notRegexp']) ? 'EXISTS' : 'NOT EXISTS'; $column = $details['field']; if($column == 'hit_url'){ From adbbace4b1798099c75b76748078cfe937c52c0b Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Mon, 20 Feb 2017 22:17:58 +0100 Subject: [PATCH 031/510] Add choosen for fields --- app/bundles/FormBundle/Assets/js/form.js | 9 +++- .../FormBundle/Views/Builder/index.html.php | 43 ++++++++++--------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/app/bundles/FormBundle/Assets/js/form.js b/app/bundles/FormBundle/Assets/js/form.js index c3efdf89a59..84ef7558c1f 100644 --- a/app/bundles/FormBundle/Assets/js/form.js +++ b/app/bundles/FormBundle/Assets/js/form.js @@ -40,6 +40,14 @@ Mautic.formOnLoad = function (container) { } }); + mQuery('#available_fields').change(function (e) { + mQuery(this).find('option:selected'); + Mautic.ajaxifyModal(mQuery(this).find('option:selected')); + // Reset the dropdown + mQuery(this).val(''); + mQuery(this).trigger('chosen:updated'); + }); + Mautic.initFormFieldButtons(); } @@ -189,7 +197,6 @@ Mautic.formFieldOnLoad = function (container, response) { //initialize ajax'd modals mQuery(fieldContainer).find("[data-toggle='ajaxmodal']").on('click.ajaxmodal', function (event) { event.preventDefault(); - console.log(this); Mautic.ajaxifyModal(this, event); }); diff --git a/app/bundles/FormBundle/Views/Builder/index.html.php b/app/bundles/FormBundle/Views/Builder/index.html.php index 054de6b001a..80a988449b0 100644 --- a/app/bundles/FormBundle/Views/Builder/index.html.php +++ b/app/bundles/FormBundle/Views/Builder/index.html.php @@ -62,27 +62,28 @@ render('MauticFormBundle:Builder:style.html.php'); ?>
-

trans('mautic.form.form.addfield'); ?>

- + + +

trans('mautic.form.form.addfield'); ?>

+
From 8aa34d1e10f22bce5c51c860ee5e7e5a14eccaca Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Mon, 20 Feb 2017 22:22:44 +0100 Subject: [PATCH 032/510] Minor --- app/bundles/FormBundle/Views/Builder/index.html.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/bundles/FormBundle/Views/Builder/index.html.php b/app/bundles/FormBundle/Views/Builder/index.html.php index 80a988449b0..fef7ec49f27 100644 --- a/app/bundles/FormBundle/Views/Builder/index.html.php +++ b/app/bundles/FormBundle/Views/Builder/index.html.php @@ -62,8 +62,6 @@ render('MauticFormBundle:Builder:style.html.php'); ?>
- -

trans('mautic.form.form.addfield'); ?>

',{type:'hidden',id:'integration_details_featureSettings_leadFields_' + integrationField,name:'integration_details[featureSettings][leadFields][' + mauticField + ']', value:mauticField }); - mQuery('#m_i_' + index ).empty().append( hiddenInput ); -}; Mautic.initiateIntegrationAuthorization = function() { mQuery('#integration_details_in_auth').val(1); diff --git a/app/bundles/PluginBundle/Command/FetchLeadsCommand.php b/app/bundles/PluginBundle/Command/FetchLeadsCommand.php index 642750c4c17..4637d2fe756 100644 --- a/app/bundles/PluginBundle/Command/FetchLeadsCommand.php +++ b/app/bundles/PluginBundle/Command/FetchLeadsCommand.php @@ -91,20 +91,22 @@ protected function execute(InputInterface $input, OutputInterface $output) $integrationObject = $integrationHelper->getIntegrationObject($integration); $config = $integrationObject->mergeConfigToFeatureSettings(); + $supportedFeatures = $integrationObject->getSupportedFeatures(); $params['start'] = $startDate; $params['end'] = $endDate; - - if ($integrationObject !== null && method_exists($integrationObject, 'getLeads') && (in_array('Lead', $config['objects']) || in_array('contacts', $config['objects']))) { - $output->writeln(''.$translator->trans('mautic.plugin.command.fetch.leads', ['%integration%' => $integration]).''); - if (strtotime($startDate) > strtotime('-30 days')) { - $processed = intval($integrationObject->getLeads($params)); - - $output->writeln(''.$translator->trans('mautic.plugin.command.fetch.leads.starting').''); - - $output->writeln(''.$translator->trans('mautic.plugin.command.fetch.leads.events_executed', ['%events%' => $processed]).''."\n"); - } else { - $output->writeln(''.$translator->trans('mautic.plugin.command.fetch.leads.wrong.date').''); + if (isset($supportedFeatures[1]) && $supportedFeatures[1] == 'get_leads') { + if ($integrationObject !== null && method_exists($integrationObject, 'getLeads') && (in_array('Lead', $config['objects']) || in_array('contacts', $config['objects']))) { + $output->writeln(''.$translator->trans('mautic.plugin.command.fetch.leads', ['%integration%' => $integration]).''); + if (strtotime($startDate) > strtotime('-30 days')) { + $processed = intval($integrationObject->getLeads($params)); + + $output->writeln(''.$translator->trans('mautic.plugin.command.fetch.leads.starting').''); + + $output->writeln(''.$translator->trans('mautic.plugin.command.fetch.leads.events_executed', ['%events%' => $processed]).''."\n"); + } else { + $output->writeln(''.$translator->trans('mautic.plugin.command.fetch.leads.wrong.date').''); + } } } @@ -121,8 +123,14 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln(''.$translator->trans('mautic.plugin.command.fetch.leads.wrong.date').''); } } + + if (isset($supportedFeatures[2]) && $supportedFeatures[2] == 'push_leads') { + $output->writeln(''.$translator->trans('mautic.plugin.command.pushing.leads', ['%integration%' => $integration]).''); + $processed = $integrationObject->pushLeads($params); + $output->writeln(''.$translator->trans('mautic.plugin.command.fetch.pushing.leads.events_executed', ['%events%' => count($processed)]).''."\n"); + } } - return 0; + return true; } } diff --git a/app/bundles/PluginBundle/Controller/PluginController.php b/app/bundles/PluginBundle/Controller/PluginController.php index 6a1349d8e4c..b7c16bdf37a 100644 --- a/app/bundles/PluginBundle/Controller/PluginController.php +++ b/app/bundles/PluginBundle/Controller/PluginController.php @@ -205,10 +205,20 @@ public function configAction($name) //make sure now non-existent aren't saved $featureSettings = $entity->getFeatureSettings(); $submittedFields = $this->request->request->get('integration_details[featureSettings][leadFields]', [], true); - if (isset($featureSettings['leadFields'])) { - foreach ($featureSettings['leadFields'] as $f => $v) { - if (empty($v) || !isset($submittedFields[$f])) { - unset($featureSettings['leadFields'][$f]); + unset($featureSettings['leadFields']); + unset($featureSettings['update_mautic']); + if (!empty($submittedFields)) { + foreach ($submittedFields as $f => $v) { + if (!strstr($f, 'update_mautic')) { + if (!empty($v) && strstr($f, 'i_')) { + $integrationField = $v; + } + if (!empty($v) && strstr($f, 'm_') && isset($integrationField)) { + $mauticField = $v; + $featureSettings['leadFields'][$integrationField] = $mauticField; + } + } else { + $featureSettings['update_mautic'][$integrationField] = (int) $v; } } $entity->setFeatureSettings($featureSettings); diff --git a/app/bundles/PluginBundle/Entity/IntegrationEntityRepository.php b/app/bundles/PluginBundle/Entity/IntegrationEntityRepository.php index ce52c9c26d2..8f537a6c8d0 100644 --- a/app/bundles/PluginBundle/Entity/IntegrationEntityRepository.php +++ b/app/bundles/PluginBundle/Entity/IntegrationEntityRepository.php @@ -74,4 +74,45 @@ public function getIntegrationsEntityId($integration, $integrationEntity, $inter return $results; } + + /** + * @param $integration + * @param $internalEntity + * @param null $startDate + * @param null $endDate + * @param $leadFields + * + * @return array + */ + public function findLeadsToUpdate($integration, $internalEntity, $leadFields) + { + $q = $this->_em->getConnection()->createQueryBuilder() + ->select('i.integration_entity_id, i.integration_entity, i.id, i.internal_entity_id,'.$leadFields) + ->from(MAUTIC_TABLE_PREFIX.'integration_entity', 'i'); + + $q->where('i.integration = :integration') + ->andWhere('i.internal_entity = :internalEntity') + ->setParameter('integration', $integration) + ->setParameter('internalEntity', $internalEntity); + + $q->join('i', MAUTIC_TABLE_PREFIX.'leads', 'l', 'l.id = i.internal_entity_id and l.date_modified > i.last_sync_date'); + + $results = $q->execute()->fetchAll(); + + return $results; + } + + public function findLeadsToCreate($integration, $leadFields) + { + $q = $this->_em->getConnection()->createQueryBuilder() + ->select('l.id,'.$leadFields) + ->from(MAUTIC_TABLE_PREFIX.'leads', 'l'); + + $q->where('l.id not in (select i.internal_entity_id from '.MAUTIC_TABLE_PREFIX.' integration_entity i where i.integration = :integration and i.internal_entity = "Lead")') + ->setParameter('integration', $integration); + + $results = $q->execute()->fetchAll(); + + return $results; + } } diff --git a/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php b/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php index ba03a5853aa..723ffaada97 100644 --- a/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php +++ b/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php @@ -34,8 +34,20 @@ public function buildForm(FormBuilderInterface $builder, array $options) $builder->add('i_'.$index, 'choice', [ 'choices' => array_keys($options['integration_company_fields']), 'label' => 'Integration fields', - 'disabled' => ($index > 1) ? true : false, + 'disabled' => ($index > 1 && !in_array($field, $options['data'])) ? true : false, + 'mapped' => false, ]); + $builder->add('update_mautic_company'.$index, + 'yesno_button_group', + [ + 'label' => false, + 'data' => isset($options['data']['update_mautic_company']) ? (bool) $options['data']['update_mautic_company'] : true, + 'no_label' => '<-', + 'yes_label' => '->', + 'empty_value' => false, + 'disabled' => ($index > 1 && !in_array($field, $options['data'])) ? true : false, + 'mapped' => false, + ]); $builder->add('m_'.$index, 'choice', [ 'choices' => $options['company_fields'], @@ -43,7 +55,8 @@ public function buildForm(FormBuilderInterface $builder, array $options) //'required' => (is_array($details) && isset($details['required'])) ? $details['required'] : false, 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control', 'data-placeholder' => ' ', 'onClick' => 'Mautic.matchFieldsType(this)'], - 'disabled' => ($index > 1) ? true : false, + 'disabled' => ($index > 1 && !in_array($field, $options['data'])) ? true : false, + 'mapped' => false, ]); } diff --git a/app/bundles/PluginBundle/Form/Type/FeatureSettingsType.php b/app/bundles/PluginBundle/Form/Type/FeatureSettingsType.php index 4ce288db395..7749158c07b 100644 --- a/app/bundles/PluginBundle/Form/Type/FeatureSettingsType.php +++ b/app/bundles/PluginBundle/Form/Type/FeatureSettingsType.php @@ -53,28 +53,16 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'ignore_field_cache' => true, ]; try { - $fields = $integration_object->getFormLeadFields($settings); - $fields = (isset($fields[0])) ? $fields[0] : $fields; - $objects = isset($settings['feature_settings']['objects']) ? true : false; - + $fields = $integration_object->getFormLeadFields($settings); + $fields = (isset($fields[0])) ? $fields[0] : $fields; unset($fields['company']); - if ($objects and in_array('company', $settings['feature_settings']['objects'])) { + if (isset($settings['feature_settings']['objects']) and in_array('company', $settings['feature_settings']['objects'])) { $integrationCompanyFields = $integration_object->getFormCompanyFields($settings); - if (isset($integrationCompanyFields['company'])) { $integrationCompanyFields = $integrationCompanyFields['company']; } } - if ($objects) { - foreach ($settings['feature_settings']['objects'] as $object) { - if ('company' == $object || 'Lead' == $object) { - continue; - } - $integrationObjectFields[$object] = $integration_object->getFormFieldsByObject($object); - } - } - if (!is_array($fields)) { $fields = []; } @@ -99,7 +87,6 @@ public function buildForm(FormBuilderInterface $builder, array $options) foreach ($fieldsIntersection as $field) { $autoMatchedFields[$field] = strtolower($field); } - $form->add( 'leadFields', 'integration_fields', @@ -108,6 +95,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'required' => true, 'lead_fields' => $leadFields, 'data' => isset($data['leadFields']) && !empty($data['leadFields']) ? $data['leadFields'] : $autoMatchedFields, + 'update_mautic' => isset($data['update_mautic']) && !empty($data['update_mautic']) ? $data['update_mautic'] : [], 'integration_fields' => $fields, 'special_instructions' => $specialInstructions, 'alert_type' => $alertType, @@ -121,29 +109,13 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'label' => 'mautic.integration.comapanyfield_matches', 'required' => false, 'company_fields' => $companyFields, + 'data' => isset($data['companyFields']) && !empty($data['companyFields']) ? $data['companyFields'] : [], 'integration_company_fields' => $integrationCompanyFields, 'special_instructions' => $specialInstructions, 'alert_type' => $alertType, ] ); } - - if ($objects) { - foreach ($settings['feature_settings']['objects'] as $object) { - $form->add( - $object.'Fields', - 'integration_object_fields', - [ - 'label' => $object, - 'required' => false, - 'lead_fields' => $leadFields, - 'integration_fields' => $integrationObjectFields, - 'special_instructions' => $specialInstructions, - 'alert_type' => $alertType, - ] - ); - } - } if ($method == 'get' && $error) { $form->addError(new FormError($error)); } diff --git a/app/bundles/PluginBundle/Form/Type/FieldsType.php b/app/bundles/PluginBundle/Form/Type/FieldsType.php index 38bbd717260..2401076e760 100644 --- a/app/bundles/PluginBundle/Form/Type/FieldsType.php +++ b/app/bundles/PluginBundle/Form/Type/FieldsType.php @@ -29,32 +29,40 @@ class FieldsType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $index = 0; - $integrationFields = [0 => ''] + array_combine(array_keys($options['integration_fields']), array_keys($options['integration_fields'])); + $integrationFields = array_combine(array_keys($options['integration_fields']), array_keys($options['integration_fields'])); + $data = $options['data']; + foreach ($options['integration_fields'] as $field => $details) { ++$index; $builder->add('i_'.$index, 'choice', [ 'choices' => $integrationFields, 'label' => false, 'required' => true, + 'data' => isset($data[$field]) ? $field : '', 'attr' => ['class' => 'form-control', 'data-placeholder' => ' ', 'onChange' => 'Mautic.matchFieldsType('.$index.')'], - 'disabled' => ($index > 1 && !in_array($field, $options['data'])) ? true : false, + 'disabled' => ($index > 1 && !isset($data[$field])) ? true : false, ]); $builder->add('update_mautic'.$index, 'yesno_button_group', [ - 'label' => false, - 'data' => isset($options['data']['update_mautic']) ? (bool) $options['data']['update_mautic'] : true, - 'no_label' => '<-', - 'yes_label' => '->', + 'label' => false, + 'data' => isset($options['update_mautic'][$field]) ? (bool) $options['update_mautic'][$field] : '', + 'no_label' => '<-', + 'no_value' => 0, + 'yes_label' => '->', + 'yes_value' => 1, + 'empty_value' => false, + 'disabled' => ($index > 1 && !isset($data[$field])) ? true : false, ]); $builder->add('m_'.$index, 'choice', [ 'choices' => $options['lead_fields'], 'label' => false, 'required' => true, + 'data' => isset($data[$field]) ? $data[$field] : '', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control', 'data-placeholder' => ' ', 'onChange' => 'Mautic.matchFieldsType('.$index.')'], - 'disabled' => ($index > 1 && !in_array($field, $options['data'])) ? true : false, + 'disabled' => ($index > 1 && !isset($data[$field])) ? true : false, ]); } } @@ -64,7 +72,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) */ public function configureOptions(OptionsResolver $resolver) { - $resolver->setRequired(['integration_fields', 'lead_fields']); + $resolver->setRequired(['integration_fields', 'lead_fields', 'update_mautic']); $resolver->setDefaults( [ 'special_instructions' => '', diff --git a/app/bundles/PluginBundle/Translations/en_US/messages.ini b/app/bundles/PluginBundle/Translations/en_US/messages.ini index 8f16ba634c3..75f04062321 100644 --- a/app/bundles/PluginBundle/Translations/en_US/messages.ini +++ b/app/bundles/PluginBundle/Translations/en_US/messages.ini @@ -73,4 +73,6 @@ mautic.integration.form.feature.get_leads="Pull contacts from integration" mautic.plugin.command.push.leads.activity="Push activity timeline to salesforce mautic object" mautic.plugin.command.fetch.companies="Fetching companies" mautic.plugin.command.fetch.companies.starting="Fetch companies command is starting" -mautic.integration.comapanyfield_matches="Company Fields" \ No newline at end of file +mautic.integration.comapanyfield_matches="Company Fields" +mautic.plugin.command.pushing.leads="Updating/creating leads from Matic to %integration%" +mautic.plugin.command.fetch.pushing.leads.events_executed="Number of attempted executed commands %events%" \ No newline at end of file diff --git a/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php b/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php index f14d208115f..ade812f868c 100644 --- a/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php +++ b/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php @@ -26,50 +26,36 @@
errors($form); ?> - + children as $child): ?> - - vars['data']) && !empty($child->vars['data']))) { - $integrationField = $child->vars['data']; -}?> -
" class="row 0 && empty($child->vars['value'])) { echo 'hide'; -} elseif ((!isset($child->vars['data']) || empty($child->vars['data'])) || $indexCount == count($child->vars['data'])) { +} elseif ($rowCount == 0 || $rowCount == count($form->vars['data']) * 2) { echo 'active'; }?>">
- +
- - vars['data']) && !empty($child->vars['data']))) { - $mauticField = $child->vars['data']; -} ?> - + + +
row($child); ?>
- - +
- - 1): - ?> -
- - - - -
+ if ($rowCount % 3 == 1):?>
diff --git a/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_company_fields_row.html.php b/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_company_fields_row.html.php index e83a0b0d16b..745f972a731 100644 --- a/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_company_fields_row.html.php +++ b/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_company_fields_row.html.php @@ -18,18 +18,32 @@
errors($form); ?> - + children as $child): ?> - -
+ +
+
+ + + +
-
+ +
row($child); ?>
- +
- + + +
+ +
\ No newline at end of file diff --git a/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_object_fields_row.html.php b/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_object_fields_row.html.php deleted file mode 100644 index 7d5c4ec7943..00000000000 --- a/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_object_fields_row.html.php +++ /dev/null @@ -1,36 +0,0 @@ - - -
"FieldsContainer"> - -
- trans($specialInstructions); ?> -
- - -
- errors($form); ?> - - children as $child): ?> - -
- -
- row($child); ?> -
- -
- - - -
-
\ No newline at end of file diff --git a/plugins/MauticCrmBundle/Api/SalesforceApi.php b/plugins/MauticCrmBundle/Api/SalesforceApi.php index d0db4d4a5ee..587c1caee3d 100644 --- a/plugins/MauticCrmBundle/Api/SalesforceApi.php +++ b/plugins/MauticCrmBundle/Api/SalesforceApi.php @@ -125,6 +125,13 @@ public function createLead(array $data, $lead) return $createdLeadData; } + public function syncMauticToSalesforce(array $data) + { + $queryUrl = $this->integration->getCompositeUrl(); + + return $this->request('composite/', $data, 'POST', false, null, $queryUrl); + } + /** * @param array $activity * @param $object @@ -251,6 +258,8 @@ public function getLeads($query, $object) } } } + print_r($mixedFields); + die(); if (!empty($fields) and isset($query['start'])) { $fields[] = 'Id'; diff --git a/plugins/MauticCrmBundle/Integration/CrmAbstractIntegration.php b/plugins/MauticCrmBundle/Integration/CrmAbstractIntegration.php index ced05b7db8b..850d6050238 100644 --- a/plugins/MauticCrmBundle/Integration/CrmAbstractIntegration.php +++ b/plugins/MauticCrmBundle/Integration/CrmAbstractIntegration.php @@ -55,7 +55,7 @@ public function getAuthenticationType() */ public function getSupportedFeatures() { - return ['push_lead', 'get_leads']; + return ['push_lead', 'get_leads', 'push_leads']; } /** diff --git a/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php b/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php index bbe2b2f9afd..014df6a07af 100644 --- a/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php +++ b/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php @@ -144,6 +144,14 @@ public function getQueryUrl() return sprintf('%s/services/data/v34.0', $this->keys['instance_url']); } + /** + * @return string + */ + public function getCompositeUrl() + { + return sprintf('%s/services/data/v38.0', $this->keys['instance_url']); + } + /** * {@inheritdoc} * @@ -243,7 +251,6 @@ public function getAvailableLeadFields($settings = []) if (!isset($salesFields[$sfObject])) { $fields = $this->getApiHelper()->getLeadFields($sfObject); - if (!empty($fields['fields'])) { foreach ($fields['fields'] as $fieldInfo) { if ((!$fieldInfo['updateable'] && (!$fieldInfo['calculated'] && $fieldInfo['name'] != 'Id')) @@ -260,12 +267,19 @@ public function getAvailableLeadFields($settings = []) } else { $type = 'string'; } - - $salesFields[$sfObject][$fieldInfo['name']] = [ - 'type' => $type, - 'label' => $fieldInfo['label'], - 'required' => $isRequired($fieldInfo, $sfObject), - ]; + if ($sfObject !== 'company') { + $salesFields[$sfObject][$fieldInfo['name'].' - '.$sfObject] = [ + 'type' => $type, + 'label' => $sfObject.' - '.$fieldInfo['label'], + 'required' => $isRequired($fieldInfo), + ]; + } else { + $salesFields[$sfObject][$fieldInfo['name']] = [ + 'type' => $type, + 'label' => $fieldInfo['label'], + 'required' => $isRequired($fieldInfo), + ]; + } } $this->cache->set('leadFields'.$cacheSuffix, $salesFields[$sfObject]); @@ -907,4 +921,53 @@ public function convertLeadFieldKey($key, $field) return $newKey; } + + public function pushLeads($params = []) + { + $config = $this->mergeConfigToFeatureSettings(); + $integrationEntityRepo = $this->em->getRepository('MauticPluginBundle:IntegrationEntity'); + $mauticData = []; + $fields = implode(', l.', $config['leadFields']); + $fields = 'l.'.$fields; + $result = 0; + //update lead/contact records + $leadsToUpdate = $integrationEntityRepo->findLeadsToUpdate('Salesforce', 'Lead', $fields); + foreach ($leadsToUpdate as $lead) { + //use a composite patch here that can update and create (one query) every 200 records + foreach ($config['leadFields'] as $sfField => $mauticField) { + $body[$sfField] = $lead[$mauticField]; + } + $mauticData[] = [ + 'method' => 'PATCH', + 'url' => '/services/data/v38.0/sobjects/'.$lead['integration_entity'].'/'.$lead['integration_entity_id'], + 'referenceId' => $lead['internal_entity_id'].'-'.$lead['integration_entity_id'], + 'body' => $body, + ]; + } + //create lead records + $leadsToCreate = $integrationEntityRepo->findLeadsToCreate('Salesforce', $fields); + + foreach ($leadsToCreate as $lead) { + //use a composite patch here that can update and create (one query) every 200 records + foreach ($config['leadFields'] as $sfField => $mauticField) { + $body[$sfField] = $lead[$mauticField]; + } + $mauticData[] = [ + 'method' => 'POST', + 'url' => '/services/data/v38.0/sobjects/Lead', + 'referenceId' => $lead['id'].'- New Lead', + 'body' => $body, + ]; + } + $request['allOrNone'] = 'false'; + $request['compositeRequest'] = $mauticData; + + if (!empty($request)) { + /** @var SalesforceApi $apiHelper */ + $apiHelper = $this->getApiHelper(); + $result = $apiHelper->syncMauticToSalesforce($request); + } + + return $result['compositeResponse']; + } } From b65d5e4d64368b20dfffe4af2e3fafd2c1731175 Mon Sep 17 00:00:00 2001 From: Marianela Queme Date: Wed, 22 Feb 2017 21:54:23 +0000 Subject: [PATCH 038/510] modified selection of fields for company tab --- .../PluginBundle/Assets/css/plugin.css | 3 + app/bundles/PluginBundle/Assets/js/plugin.js | 70 +++++++++---------- .../Controller/PluginController.php | 26 ++++++- .../Entity/IntegrationEntityRepository.php | 2 +- .../Form/Type/CompanyFieldsType.php | 34 ++++----- .../PluginBundle/Form/Type/FieldsType.php | 20 +++--- .../Translations/en_US/messages.ini | 5 +- ...ls_featureSettings_leadFields_row.html.php | 53 +++++++------- .../integration_company_fields_row.html.php | 31 +++++--- .../Views/Integration/form.html.php | 26 +------ plugins/MauticCrmBundle/Api/SalesforceApi.php | 12 ++-- .../Integration/SalesforceIntegration.php | 7 +- 12 files changed, 149 insertions(+), 140 deletions(-) diff --git a/app/bundles/PluginBundle/Assets/css/plugin.css b/app/bundles/PluginBundle/Assets/css/plugin.css index f205f6b2fa9..d64136b0ca3 100644 --- a/app/bundles/PluginBundle/Assets/css/plugin.css +++ b/app/bundles/PluginBundle/Assets/css/plugin.css @@ -19,3 +19,6 @@ filter: url("data:image/svg+xml;utf8,#grayscale"); -webkit-filter: grayscale(0%); } +.field-selector { + width: 500px; +} diff --git a/app/bundles/PluginBundle/Assets/js/plugin.js b/app/bundles/PluginBundle/Assets/js/plugin.js index 6a00baf4c63..32b32445fbe 100644 --- a/app/bundles/PluginBundle/Assets/js/plugin.js +++ b/app/bundles/PluginBundle/Assets/js/plugin.js @@ -1,43 +1,39 @@ /* PluginBundle */ -Mautic.addNewPluginField = function (index) { - var items = mQuery('div.field').find('div.active'); +Mautic.addNewPluginField = function (selector) { + var items = mQuery( 'div.' + selector ).find( 'div.active' ); var currentItem = items.filter('.active'); var selectors; - mQuery('.add').on('click', function() { - var nextItem = currentItem.next(); - currentItem.removeClass('active'); - if ( nextItem.length ) { - currentItem = nextItem.addClass('active').removeClass('hide'); - selectors = currentItem.find('select'); - selectors.each(function( ) { - mQuery( this ).prop('disabled', false).trigger("chosen:updated"); - }); - selectors = currentItem.find('input[type="radio"]'); - selectors.each(function( ) { - mQuery( this ).prop('disabled', false).trigger("chosen:updated"); - }); - } - }); - mQuery('.removeField').on('click', function() { - currentItem = mQuery('#' + index); - var previousItem = currentItem.prev(); - currentItem.removeClass('active'); - if ( previousItem.length ) { - previousItem.addClass('active'); - selectors = currentItem.find('select'); - selectors.each(function( ) { - mQuery( this ).prop('disabled', true).trigger("chosen:updated"); - }); - selectors = currentItem.find('input[type="radio"]'); - selectors.each(function( ) { - mQuery( this ).prop('disabled', true).trigger("chosen:updated"); - }); - currentItem.addClass('hide'); - items = mQuery('div.field').find('div.active'); - currentItem = items.filter('.active'); - } - }); - return true; + var nextItem = currentItem.next(); + currentItem.removeClass('active'); + if (nextItem.length) { + currentItem = nextItem.addClass('active').removeClass('hide'); + selectors = currentItem.find('select'); + selectors.each(function () { + mQuery(this).prop('disabled', false).trigger("chosen:updated"); + }); + currentItem.find('.btn-no').removeClass('disabled'); + currentItem.find('.btn-yes').removeClass('disabled'); + currentItem.find('input[type="radio"]').prop('disabled', false).next().prop('disabled', false); + } + Mautic.stopIconSpinPostEvent(); +}; +Mautic.removePluginField = function (indexClass) { + var deleteCurrentItem = mQuery('#' + indexClass); + var previousItem = deleteCurrentItem.prev(); + deleteCurrentItem.removeClass('active') + if ( previousItem.length ) { + previousItem.addClass('active'); + selectors = deleteCurrentItem.find('select'); + selectors.each(function( ) { + mQuery( this ).prop('disabled', true).trigger("chosen:updated"); + }); + deleteCurrentItem.find('.btn-no').addClass('disabled'); + deleteCurrentItem.find('.btn-yes').addClass('disabled'); + deleteCurrentItem.find('input[type="radio"]').prop('disabled', true).next().prop('disabled', true); + + deleteCurrentItem.addClass('hide'); + } + Mautic.stopIconSpinPostEvent(); }; Mautic.initiateIntegrationAuthorization = function() { diff --git a/app/bundles/PluginBundle/Controller/PluginController.php b/app/bundles/PluginBundle/Controller/PluginController.php index b7c16bdf37a..9e4384e9d07 100644 --- a/app/bundles/PluginBundle/Controller/PluginController.php +++ b/app/bundles/PluginBundle/Controller/PluginController.php @@ -205,9 +205,9 @@ public function configAction($name) //make sure now non-existent aren't saved $featureSettings = $entity->getFeatureSettings(); $submittedFields = $this->request->request->get('integration_details[featureSettings][leadFields]', [], true); - unset($featureSettings['leadFields']); - unset($featureSettings['update_mautic']); if (!empty($submittedFields)) { + unset($featureSettings['leadFields']); + unset($featureSettings['update_mautic']); foreach ($submittedFields as $f => $v) { if (!strstr($f, 'update_mautic')) { if (!empty($v) && strstr($f, 'i_')) { @@ -221,8 +221,28 @@ public function configAction($name) $featureSettings['update_mautic'][$integrationField] = (int) $v; } } - $entity->setFeatureSettings($featureSettings); } + $submittedCompanyFields = $this->request->request->get('integration_details[featureSettings][companyFields]', [], true); + + if (!empty($submittedCompanyFields)) { + unset($featureSettings['companyFields']); + unset($featureSettings['update_mautic_company']); + foreach ($submittedCompanyFields as $f => $v) { + if (!strstr($f, 'update_mautic_company')) { + if (!empty($v) && strstr($f, 'i_')) { + $integrationField = $v; + } + if (!empty($v) && strstr($f, 'm_') && isset($integrationField)) { + $mauticField = $v; + $featureSettings['companyFields'][$integrationField] = $mauticField; + } + } else { + $featureSettings['update_mautic_company'][$integrationField] = (int) $v; + } + } + } + $this->factory->getLogger()->addError(print_r($featureSettings, true)); + $entity->setFeatureSettings($featureSettings); } } else { //make sure they aren't overwritten because of API connection issues diff --git a/app/bundles/PluginBundle/Entity/IntegrationEntityRepository.php b/app/bundles/PluginBundle/Entity/IntegrationEntityRepository.php index 8f537a6c8d0..72bb91560eb 100644 --- a/app/bundles/PluginBundle/Entity/IntegrationEntityRepository.php +++ b/app/bundles/PluginBundle/Entity/IntegrationEntityRepository.php @@ -108,7 +108,7 @@ public function findLeadsToCreate($integration, $leadFields) ->select('l.id,'.$leadFields) ->from(MAUTIC_TABLE_PREFIX.'leads', 'l'); - $q->where('l.id not in (select i.internal_entity_id from '.MAUTIC_TABLE_PREFIX.' integration_entity i where i.integration = :integration and i.internal_entity = "Lead")') + $q->where('l.id not in (select i.internal_entity_id from '.MAUTIC_TABLE_PREFIX.' integration_entity i where i.integration = :integration and i.internal_entity = "lead")') ->setParameter('integration', $integration); $results = $q->execute()->fetchAll(); diff --git a/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php b/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php index 723ffaada97..a3395122b84 100644 --- a/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php +++ b/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php @@ -28,36 +28,36 @@ class CompanyFieldsType extends AbstractType */ public function buildForm(FormBuilderInterface $builder, array $options) { - $index = 0; - foreach ($options['integration_company_fields'] as $field => $details) { + $index = 0; + $integrationFields = array_combine(array_keys($options['integration_company_fields']), array_keys($options['integration_company_fields'])); + $data = isset($options['data']) ? $options['data'] : []; + $integrationFieldsOrdered = array_merge($data, $integrationFields); + foreach ($integrationFieldsOrdered as $field => $details) { ++$index; $builder->add('i_'.$index, 'choice', [ - 'choices' => array_keys($options['integration_company_fields']), - 'label' => 'Integration fields', - 'disabled' => ($index > 1 && !in_array($field, $options['data'])) ? true : false, - 'mapped' => false, + 'choices' => $integrationFieldsOrdered, + 'label' => false, + 'data' => isset($data[$field]) ? $field : '', + 'attr' => ['class' => 'field-selector form-control', 'data-placeholder' => ' '], + 'disabled' => ($index > 1 && !isset($data[$field])) ? true : false, ]); $builder->add('update_mautic_company'.$index, 'yesno_button_group', [ 'label' => false, 'data' => isset($options['data']['update_mautic_company']) ? (bool) $options['data']['update_mautic_company'] : true, - 'no_label' => '<-', - 'yes_label' => '->', + 'no_label' => '', + 'yes_label' => '', 'empty_value' => false, - 'disabled' => ($index > 1 && !in_array($field, $options['data'])) ? true : false, - 'mapped' => false, + 'disabled' => ($index > 1 && !isset($data[$field])) ? true : false, ]); $builder->add('m_'.$index, 'choice', [ - 'choices' => $options['company_fields'], - 'label' => 'Mautic Company Field', - //'required' => (is_array($details) && isset($details['required'])) ? $details['required'] : false, + 'choices' => $options['company_fields'], + 'label' => false, 'label_attr' => ['class' => 'control-label'], - 'attr' => ['class' => 'form-control', 'data-placeholder' => ' ', 'onClick' => 'Mautic.matchFieldsType(this)'], - 'disabled' => ($index > 1 && !in_array($field, $options['data'])) ? true : false, - 'mapped' => false, - + 'attr' => ['class' => 'field-selector form-control', 'data-placeholder' => ' '], + 'disabled' => ($index > 1 && !isset($data[$field])) ? true : false, ]); } } diff --git a/app/bundles/PluginBundle/Form/Type/FieldsType.php b/app/bundles/PluginBundle/Form/Type/FieldsType.php index 2401076e760..8deb3b987f4 100644 --- a/app/bundles/PluginBundle/Form/Type/FieldsType.php +++ b/app/bundles/PluginBundle/Form/Type/FieldsType.php @@ -28,18 +28,18 @@ class FieldsType extends AbstractType */ public function buildForm(FormBuilderInterface $builder, array $options) { - $index = 0; - $integrationFields = array_combine(array_keys($options['integration_fields']), array_keys($options['integration_fields'])); - $data = $options['data']; - - foreach ($options['integration_fields'] as $field => $details) { + $index = 0; + $integrationFields = array_combine(array_keys($options['integration_fields']), array_keys($options['integration_fields'])); + $data = isset($options['data']) ? $options['data'] : []; + $integrationFieldsOrdered = array_merge($data, $integrationFields); + foreach ($integrationFieldsOrdered as $field => $details) { ++$index; $builder->add('i_'.$index, 'choice', [ 'choices' => $integrationFields, 'label' => false, 'required' => true, 'data' => isset($data[$field]) ? $field : '', - 'attr' => ['class' => 'form-control', 'data-placeholder' => ' ', 'onChange' => 'Mautic.matchFieldsType('.$index.')'], + 'attr' => ['class' => 'field-selector form-control', 'data-placeholder' => ' '], 'disabled' => ($index > 1 && !isset($data[$field])) ? true : false, ]); $builder->add('update_mautic'.$index, @@ -47,10 +47,8 @@ public function buildForm(FormBuilderInterface $builder, array $options) [ 'label' => false, 'data' => isset($options['update_mautic'][$field]) ? (bool) $options['update_mautic'][$field] : '', - 'no_label' => '<-', - 'no_value' => 0, - 'yes_label' => '->', - 'yes_value' => 1, + 'no_label' => '', + 'yes_label' => '', 'empty_value' => false, 'disabled' => ($index > 1 && !isset($data[$field])) ? true : false, ]); @@ -61,7 +59,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'required' => true, 'data' => isset($data[$field]) ? $data[$field] : '', 'label_attr' => ['class' => 'control-label'], - 'attr' => ['class' => 'form-control', 'data-placeholder' => ' ', 'onChange' => 'Mautic.matchFieldsType('.$index.')'], + 'attr' => ['class' => 'field-selector form-control', 'data-placeholder' => ' '], 'disabled' => ($index > 1 && !isset($data[$field])) ? true : false, ]); } diff --git a/app/bundles/PluginBundle/Translations/en_US/messages.ini b/app/bundles/PluginBundle/Translations/en_US/messages.ini index 75f04062321..dc96a50edb1 100644 --- a/app/bundles/PluginBundle/Translations/en_US/messages.ini +++ b/app/bundles/PluginBundle/Translations/en_US/messages.ini @@ -75,4 +75,7 @@ mautic.plugin.command.fetch.companies="Fetching companies" mautic.plugin.command.fetch.companies.starting="Fetch companies command is starting" mautic.integration.comapanyfield_matches="Company Fields" mautic.plugin.command.pushing.leads="Updating/creating leads from Matic to %integration%" -mautic.plugin.command.fetch.pushing.leads.events_executed="Number of attempted executed commands %events%" \ No newline at end of file +mautic.plugin.command.fetch.pushing.leads.events_executed="Number of attempted executed commands %events%" +mautic.plugins.integration.fields="Integration fields" +mautic.plugins.mautic.direction="Direction" +mautic.plugins.mautic.fields="Mautic fields" \ No newline at end of file diff --git a/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php b/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php index ade812f868c..ad37ae00360 100644 --- a/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php +++ b/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php @@ -16,49 +16,46 @@ trans($specialInstructions); ?>
- -
+
-
trans('mautic.plugins.integration.fields'); ?>
-
trans('mautic.plugins.mautic.direction'); ?>
-
trans('mautic.plugins.mautic.fields'); ?>
+

trans('mautic.plugins.integration.fields'); ?>

+

trans('mautic.plugins.mautic.direction'); ?>

+

trans('mautic.plugins.mautic.fields'); ?>

errors($form); ?> - - children as $child): ?> - -
" class="row 0 && empty($child->vars['value'])) { echo 'hide'; -} elseif ($rowCount == 0 || $rowCount == count($form->vars['data']) * 2) { +} elseif (($rowCount == 0 && count($form->vars['data']) == 0) || $indexCount == count($form->vars['data'])) { echo 'active'; }?>"> -
- - - -
- - - - -
- row($child); ?> -
- - +
+ + + +
+ + +
+ row($child); ?> +
+
- - Add field + Add field
\ No newline at end of file diff --git a/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_company_fields_row.html.php b/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_company_fields_row.html.php index 745f972a731..3b72eb50802 100644 --- a/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_company_fields_row.html.php +++ b/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_company_fields_row.html.php @@ -16,34 +16,47 @@ trans($specialInstructions); ?>
-
+
+
+
+

trans('mautic.plugins.integration.fields'); ?>

+

trans('mautic.plugins.mautic.direction'); ?>

+

trans('mautic.plugins.mautic.fields'); ?>

+
errors($form); ?> - + children as $child): ?> -
" class="row 0 && empty($child->vars['value'])) { echo 'hide'; -} elseif ((!isset($child->vars['data']) || empty($child->vars['data'])) || $indexCount == count($child->vars['data'])) { +} elseif (($rowCount == 0 && count($form->vars['data']) == 0) || $indexCount == count($form->vars['data'])) { echo 'active'; -}?>"> +} + ?>">
- +
-
+
row($child); ?>
- +
-
+ Add field
\ No newline at end of file diff --git a/app/bundles/PluginBundle/Views/Integration/form.html.php b/app/bundles/PluginBundle/Views/Integration/form.html.php index db95eb0e8f9..c0e6e36e79e 100644 --- a/app/bundles/PluginBundle/Views/Integration/form.html.php +++ b/app/bundles/PluginBundle/Views/Integration/form.html.php @@ -26,21 +26,8 @@ $fieldHtml = ($hasFields) ? $view['form']->row($form['featureSettings']['leadFields']) : ''; $companyFieldHtml = (isset($form['featureSettings']['companyFields']) && count($form['featureSettings']['companyFields'])) ? $view['form']->row($form['featureSettings']['companyFields']) : ''; -$objects = isset($form['featureSettings']['objects']) ? $form['featureSettings']['objects'] : []; -$index = 0; -foreach ($objects->vars['value'] as $object) { - // if ('company' == $object || 'Lead' == $object) { - // continue; - //} - - print_r($object); - - ++$index; - // $objectFieldHtml[$object] = (isset($form['featureSettings'][$object.'Fields']) && count($form['featureSettings'][$object.'Fields'])) ? $view['form']->row($form['featureSettings'][$object.'Fields']) : ''; -} - -$fieldLabel = ($hasFields) ? $form['featureSettings']['leadFields']->vars['label'] : ''; -$fieldTabClass = ($hasFields) ? '' : ' hide'; +$fieldLabel = ($hasFields) ? $form['featureSettings']['leadFields']->vars['label'] : ''; +$fieldTabClass = ($hasFields) ? '' : ' hide'; unset($form['featureSettings']['leadFields']); unset($form['featureSettings']['companyFields']); ?> @@ -114,14 +101,5 @@

trans('mautic.integration.comapanyfield_matches'); ?>

- - $fieldHtml) { - ; - }?> -
-

- -
-
end($form); ?> diff --git a/plugins/MauticCrmBundle/Api/SalesforceApi.php b/plugins/MauticCrmBundle/Api/SalesforceApi.php index 587c1caee3d..7b8985e9223 100644 --- a/plugins/MauticCrmBundle/Api/SalesforceApi.php +++ b/plugins/MauticCrmBundle/Api/SalesforceApi.php @@ -256,11 +256,12 @@ public function getLeads($query, $object) if (strpos($sfField, '__'.$object) !== false) { $fields[] = str_replace('__'.$object, '', $sfField); } + if (strpos($sfField, ' - '.$object) !== false) { + $fields[] = str_replace(' - '.$object, '', $sfField); + } } } - print_r($mixedFields); - die(); - + $result = []; if (!empty($fields) and isset($query['start'])) { $fields[] = 'Id'; $fields = implode(', ', $fields); @@ -271,9 +272,8 @@ public function getLeads($query, $object) } $getLeadsQuery = 'SELECT '.$fields.' from '.$object.' where LastModifiedDate>='.$query['start'].' and LastModifiedDate<='.$query['end']; - $result = $this->request('query', ['q' => $getLeadsQuery], 'GET', false, null, $queryUrl); - } else { - $result = $this->request('query/'.$query, [], 'GET', false, null, $queryUrl); + + $result = $this->request('query', ['q' => $getLeadsQuery], 'GET', false, null, $queryUrl); } return $result; diff --git a/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php b/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php index 014df6a07af..5e825ba335c 100644 --- a/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php +++ b/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php @@ -251,6 +251,7 @@ public function getAvailableLeadFields($settings = []) if (!isset($salesFields[$sfObject])) { $fields = $this->getApiHelper()->getLeadFields($sfObject); + if (!empty($fields['fields'])) { foreach ($fields['fields'] as $fieldInfo) { if ((!$fieldInfo['updateable'] && (!$fieldInfo['calculated'] && $fieldInfo['name'] != 'Id')) @@ -271,13 +272,13 @@ public function getAvailableLeadFields($settings = []) $salesFields[$sfObject][$fieldInfo['name'].' - '.$sfObject] = [ 'type' => $type, 'label' => $sfObject.' - '.$fieldInfo['label'], - 'required' => $isRequired($fieldInfo), + 'required' => $isRequired($fieldInfo, $sfObject), ]; } else { $salesFields[$sfObject][$fieldInfo['name']] = [ 'type' => $type, 'label' => $fieldInfo['label'], - 'required' => $isRequired($fieldInfo), + 'required' => $isRequired($fieldInfo, $sfObject), ]; } } @@ -931,7 +932,7 @@ public function pushLeads($params = []) $fields = 'l.'.$fields; $result = 0; //update lead/contact records - $leadsToUpdate = $integrationEntityRepo->findLeadsToUpdate('Salesforce', 'Lead', $fields); + $leadsToUpdate = $integrationEntityRepo->findLeadsToUpdate('Salesforce', 'lead', $fields); foreach ($leadsToUpdate as $lead) { //use a composite patch here that can update and create (one query) every 200 records foreach ($config['leadFields'] as $sfField => $mauticField) { From e494c87808e6da4774eb80d736fb8960d273e78f Mon Sep 17 00:00:00 2001 From: Marianela Queme Date: Wed, 22 Feb 2017 22:12:38 +0000 Subject: [PATCH 039/510] added priority of fields --- plugins/MauticCrmBundle/Api/SalesforceApi.php | 8 +++++--- .../MauticCrmBundle/Integration/SalesforceIntegration.php | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/MauticCrmBundle/Api/SalesforceApi.php b/plugins/MauticCrmBundle/Api/SalesforceApi.php index 7b8985e9223..d2adf9a0933 100644 --- a/plugins/MauticCrmBundle/Api/SalesforceApi.php +++ b/plugins/MauticCrmBundle/Api/SalesforceApi.php @@ -247,11 +247,13 @@ public function getLeads($query, $object) switch ($object) { case 'company': case 'Account': - $fields = array_keys(array_filter($fields['companyFields'])); + $companyFieldsToUpdateInMautic = isset($fields['update_mautic_company']) ? array_keys($fields['update_mautic_company'], 0) : []; + $fields = array_keys(array_filter(array_diff_key($fields['companyFields'], $companyFieldsToUpdateInMautic))); break; default: - $mixedFields = array_filter($fields['leadFields']); - $fields = []; + $fieldsToUpdateInMautic = isset($fields['update_mautic']) ? array_keys($fields['update_mautic'], 0) : []; + $mixedFields = array_filter(array_diff_key($fields['leadFields'], $fieldsToUpdateInMautic)); + $fields = []; foreach ($mixedFields as $sfField => $mField) { if (strpos($sfField, '__'.$object) !== false) { $fields[] = str_replace('__'.$object, '', $sfField); diff --git a/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php b/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php index 5e825ba335c..0702a3033b1 100644 --- a/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php +++ b/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php @@ -928,7 +928,8 @@ public function pushLeads($params = []) $config = $this->mergeConfigToFeatureSettings(); $integrationEntityRepo = $this->em->getRepository('MauticPluginBundle:IntegrationEntity'); $mauticData = []; - $fields = implode(', l.', $config['leadFields']); + $fieldsToUpdateInSf = array_keys($config['update_mautic'], 1); + $fields = implode(', l.', array_diff_key($config['leadFields'], $fieldsToUpdateInSf)); $fields = 'l.'.$fields; $result = 0; //update lead/contact records From a28d983320580cefeb84a814ee4814a32ef54622 Mon Sep 17 00:00:00 2001 From: Marianela Queme Date: Thu, 23 Feb 2017 11:07:20 +0000 Subject: [PATCH 040/510] changes some UI stuff --- .../PluginBundle/Assets/css/plugin.css | 4 + app/bundles/PluginBundle/Assets/js/plugin.js | 36 ++++---- app/bundles/PluginBundle/Config/config.php | 4 - .../Form/Type/CompanyFieldsType.php | 1 + .../PluginBundle/Form/Type/FieldsType.php | 1 + .../Form/Type/ObjectFieldsType.php | 82 ------------------- .../Translations/en_US/messages.ini | 3 +- ...ls_featureSettings_leadFields_row.html.php | 43 +++++----- .../integration_company_fields_row.html.php | 53 ++++++------ 9 files changed, 73 insertions(+), 154 deletions(-) delete mode 100644 app/bundles/PluginBundle/Form/Type/ObjectFieldsType.php diff --git a/app/bundles/PluginBundle/Assets/css/plugin.css b/app/bundles/PluginBundle/Assets/css/plugin.css index d64136b0ca3..40585b2eace 100644 --- a/app/bundles/PluginBundle/Assets/css/plugin.css +++ b/app/bundles/PluginBundle/Assets/css/plugin.css @@ -22,3 +22,7 @@ .field-selector { width: 500px; } +.col-centered{ + margin: 0 auto; + float: none; +} diff --git a/app/bundles/PluginBundle/Assets/js/plugin.js b/app/bundles/PluginBundle/Assets/js/plugin.js index 32b32445fbe..99af95577d1 100644 --- a/app/bundles/PluginBundle/Assets/js/plugin.js +++ b/app/bundles/PluginBundle/Assets/js/plugin.js @@ -1,12 +1,12 @@ /* PluginBundle */ Mautic.addNewPluginField = function (selector) { - var items = mQuery( 'div.' + selector ).find( 'div.active' ); - var currentItem = items.filter('.active'); + var items = mQuery( 'div.' + selector ).find( 'div.hide' ); + var currentItem = items.filter('.hide'); var selectors; - var nextItem = currentItem.next(); - currentItem.removeClass('active'); + var nextItem = currentItem.first(); + if (nextItem.length) { - currentItem = nextItem.addClass('active').removeClass('hide'); + currentItem = nextItem.removeClass('hide'); selectors = currentItem.find('select'); selectors.each(function () { mQuery(this).prop('disabled', false).trigger("chosen:updated"); @@ -17,22 +17,19 @@ Mautic.addNewPluginField = function (selector) { } Mautic.stopIconSpinPostEvent(); }; -Mautic.removePluginField = function (indexClass) { +Mautic.removePluginField = function (selector, indexClass) { var deleteCurrentItem = mQuery('#' + indexClass); - var previousItem = deleteCurrentItem.prev(); - deleteCurrentItem.removeClass('active') - if ( previousItem.length ) { - previousItem.addClass('active'); - selectors = deleteCurrentItem.find('select'); - selectors.each(function( ) { - mQuery( this ).prop('disabled', true).trigger("chosen:updated"); - }); - deleteCurrentItem.find('.btn-no').addClass('disabled'); - deleteCurrentItem.find('.btn-yes').addClass('disabled'); - deleteCurrentItem.find('input[type="radio"]').prop('disabled', true).next().prop('disabled', true); - deleteCurrentItem.addClass('hide'); - } + selectors = deleteCurrentItem.find('select'); + selectors.each(function( ) { + mQuery( this ).prop('disabled', true).trigger("chosen:updated"); + }); + + deleteCurrentItem.find('.btn-no').addClass('disabled'); + deleteCurrentItem.find('.btn-yes').addClass('disabled'); + deleteCurrentItem.find('input[type="radio"]').prop('disabled', true).next().prop('disabled', true); + deleteCurrentItem.addClass('hide'); + Mautic.stopIconSpinPostEvent(); }; @@ -87,6 +84,7 @@ Mautic.integrationOnLoad = function(container, response) { } else { Mautic.filterIntegrations(); } + mQuery('[data-toggle="tooltip"]').tooltip(); }; Mautic.filterIntegrations = function(update) { diff --git a/app/bundles/PluginBundle/Config/config.php b/app/bundles/PluginBundle/Config/config.php index 21d544851c9..8a956f28480 100644 --- a/app/bundles/PluginBundle/Config/config.php +++ b/app/bundles/PluginBundle/Config/config.php @@ -99,10 +99,6 @@ 'class' => 'Mautic\PluginBundle\Form\Type\CompanyFieldsType', 'alias' => 'integration_company_fields', ], - 'mautic.form.type.integration.object.fields' => [ - 'class' => 'Mautic\PluginBundle\Form\Type\ObjectFieldsType', - 'alias' => 'integration_object_fields', - ], 'mautic.form.type.integration.keys' => [ 'class' => 'Mautic\PluginBundle\Form\Type\KeysType', 'alias' => 'integration_keys', diff --git a/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php b/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php index a3395122b84..4b9a6402258 100644 --- a/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php +++ b/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php @@ -49,6 +49,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'no_label' => '', 'yes_label' => '', 'empty_value' => false, + 'attr' => ['data-toggle' => 'tooltip', 'title' => 'mautic.plugin.direction.data.update'], 'disabled' => ($index > 1 && !isset($data[$field])) ? true : false, ]); diff --git a/app/bundles/PluginBundle/Form/Type/FieldsType.php b/app/bundles/PluginBundle/Form/Type/FieldsType.php index 8deb3b987f4..42b807ce700 100644 --- a/app/bundles/PluginBundle/Form/Type/FieldsType.php +++ b/app/bundles/PluginBundle/Form/Type/FieldsType.php @@ -50,6 +50,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'no_label' => '', 'yes_label' => '', 'empty_value' => false, + 'attr' => ['data-toggle' => 'tooltip', 'title' => 'mautic.plugin.direction.data.update'], 'disabled' => ($index > 1 && !isset($data[$field])) ? true : false, ]); diff --git a/app/bundles/PluginBundle/Form/Type/ObjectFieldsType.php b/app/bundles/PluginBundle/Form/Type/ObjectFieldsType.php deleted file mode 100644 index 46bb8ca617f..00000000000 --- a/app/bundles/PluginBundle/Form/Type/ObjectFieldsType.php +++ /dev/null @@ -1,82 +0,0 @@ - $details) { - ++$index; - - $builder->add('i_'.$index, 'choice', [ - 'choices' => array_keys($options['integration_fields']), - 'label' => 'Integration', - 'disabled' => ($index > 1) ? true : false, - ]); - $builder->add('m_'.$index, 'choice', [ - 'choices' => $options['lead_fields'], - 'label' => 'Mautic Lead Field', - 'required' => (is_array($details) && isset($details['required'])) ? $details['required'] : false, - 'label_attr' => ['class' => 'control-label'], - 'attr' => ['class' => 'form-control', 'data-placeholder' => ' '], - 'disabled' => ($index > 1) ? true : false, - ]); - } - } - - /** - * @param OptionsResolver $resolver - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setRequired(['integration_fields', 'lead_fields']); - $resolver->setDefaults( - [ - 'special_instructions' => '', - 'alert_type' => '', - 'allow_extra_fields' => true, - ] - ); - } - - /** - * @return string - */ - public function getName() - { - return 'integration_object_fields'; - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars['specialInstructions'] = $options['special_instructions']; - $view->vars['alertType'] = $options['alert_type']; - } -} diff --git a/app/bundles/PluginBundle/Translations/en_US/messages.ini b/app/bundles/PluginBundle/Translations/en_US/messages.ini index dc96a50edb1..f6ba6bd7434 100644 --- a/app/bundles/PluginBundle/Translations/en_US/messages.ini +++ b/app/bundles/PluginBundle/Translations/en_US/messages.ini @@ -78,4 +78,5 @@ mautic.plugin.command.pushing.leads="Updating/creating leads from Matic to %inte mautic.plugin.command.fetch.pushing.leads.events_executed="Number of attempted executed commands %events%" mautic.plugins.integration.fields="Integration fields" mautic.plugins.mautic.direction="Direction" -mautic.plugins.mautic.fields="Mautic fields" \ No newline at end of file +mautic.plugins.mautic.fields="Mautic fields" +mautic.plugin.direction.data.update="Pick direction of data update" \ No newline at end of file diff --git a/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php b/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php index ad37ae00360..f8c0e27bde9 100644 --- a/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php +++ b/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php @@ -18,43 +18,44 @@
-
-

trans('mautic.plugins.integration.fields'); ?>

-

trans('mautic.plugins.mautic.direction'); ?>

-

trans('mautic.plugins.mautic.fields'); ?>

+

trans('mautic.plugins.integration.fields'); ?>

+
+

trans('mautic.plugins.mautic.fields'); ?>

+
errors($form); ?> children as $child): ?> - -
-
- - - -
+ +
-
pl-xs pr-xs col-sm-"> row($child); ?>
+
+ + + +
- + -
+
Add field diff --git a/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_company_fields_row.html.php b/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_company_fields_row.html.php index 3b72eb50802..976776da5c6 100644 --- a/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_company_fields_row.html.php +++ b/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_company_fields_row.html.php @@ -18,38 +18,37 @@
-
-

trans('mautic.plugins.integration.fields'); ?>

-

trans('mautic.plugins.mautic.direction'); ?>

-

trans('mautic.plugins.mautic.fields'); ?>

+

trans('mautic.plugins.integration.fields'); ?>

+
+

trans('mautic.plugins.mautic.fields'); ?>

+
errors($form); ?> children as $child): ?> -
-
- - - -
- - -
- row($child); ?> -
- +
+ + +
+ row($child); ?> +
+ +
+ + + +
From 1255cbc4040bb1ae9efd5f4bd1d4a5657ef2549e Mon Sep 17 00:00:00 2001 From: Marianela Queme Date: Thu, 23 Feb 2017 11:32:10 +0000 Subject: [PATCH 041/510] added translation string --- app/bundles/PluginBundle/Translations/en_US/messages.ini | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/bundles/PluginBundle/Translations/en_US/messages.ini b/app/bundles/PluginBundle/Translations/en_US/messages.ini index f6ba6bd7434..37210770da4 100644 --- a/app/bundles/PluginBundle/Translations/en_US/messages.ini +++ b/app/bundles/PluginBundle/Translations/en_US/messages.ini @@ -8,7 +8,7 @@ mautic.integration.form.enabled="Is enabled?" mautic.integration.form.feature.login_button="Login Button" mautic.integration.form.feature.public_activity="Display public activity" mautic.integration.form.feature.public_profile="Display public profile and enable profile to contact field matching" -mautic.integration.form.feature.push_lead="Push contacts to this integration" +mautic.integration.form.feature.push_lead="Triggered action push contacts to integration" mautic.integration.form.feature.settings="Feature Specific Settings" mautic.integration.form.feature.share_button="Display share button on landing page social widget" mautic.integration.form.feature.sso_service="Single Sign On - Service Authentication" @@ -79,4 +79,5 @@ mautic.plugin.command.fetch.pushing.leads.events_executed="Number of attempted e mautic.plugins.integration.fields="Integration fields" mautic.plugins.mautic.direction="Direction" mautic.plugins.mautic.fields="Mautic fields" -mautic.plugin.direction.data.update="Pick direction of data update" \ No newline at end of file +mautic.plugin.direction.data.update="Pick direction of data update" +mautic.integration.form.feature.push_leads="Push contacts to this integration" \ No newline at end of file From 8b138f7ad1e5685fa50a36d593a0e9f29c7c5332 Mon Sep 17 00:00:00 2001 From: Arul Raj Date: Thu, 23 Feb 2017 17:21:58 +0530 Subject: [PATCH 042/510] delete migration created --- app/migrations/Version20170222061829.php | 36 ------------------------ 1 file changed, 36 deletions(-) delete mode 100644 app/migrations/Version20170222061829.php diff --git a/app/migrations/Version20170222061829.php b/app/migrations/Version20170222061829.php deleted file mode 100644 index 4f345697a62..00000000000 --- a/app/migrations/Version20170222061829.php +++ /dev/null @@ -1,36 +0,0 @@ -abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); - - $this->addSql('ALTER TABLE dynamic_content_lead_data DROP FOREIGN KEY FK_515B221BD9D0CD7'); - $this->addSql('ALTER TABLE dynamic_content_lead_data ADD CONSTRAINT FK_515B221BD9D0CD7 FOREIGN KEY (dynamic_content_id) REFERENCES dynamic_content (id) ON DELETE CASCADE'); - } - - /** - * @param Schema $schema - */ - public function down(Schema $schema) - { - // this down() migration is auto-generated, please modify it to your needs - $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); - - $this->addSql('ALTER TABLE dynamic_content_lead_data DROP FOREIGN KEY FK_515B221BD9D0CD7'); - $this->addSql('ALTER TABLE dynamic_content_lead_data ADD CONSTRAINT FK_515B221BD9D0CD7 FOREIGN KEY (dynamic_content_id) REFERENCES dynamic_content (id)'); - } -} From 26a042ccbacd3e18006f9638d91b678d683df238 Mon Sep 17 00:00:00 2001 From: Werner Garcia Date: Thu, 23 Feb 2017 14:53:03 -0600 Subject: [PATCH 043/510] Added new slot types --- .../Assets/css/app/less/custom.less | 5 +- app/bundles/CoreBundle/Assets/js/4.builder.js | 14 +++++ .../js/libraries/froala/plugins/token.js | 8 +-- app/bundles/CoreBundle/Config/config.php | 24 +++++++++ .../CoreBundle/Form/Type/SlotCodeModeType.php | 52 +++++++++++++++++++ .../Form/Type/SlotImageCaptionType.php | 52 +++++++++++++++++++ .../Form/Type/SlotImageCardType.php | 52 +++++++++++++++++++ .../CoreBundle/Form/Type/SlotImageType.php | 52 +++++++++++++++++++ .../Form/Type/SlotSocialFollowType.php | 52 +++++++++++++++++++ .../Form/Type/SlotSocialShareType.php | 52 +++++++++++++++++++ .../CoreBundle/Views/Helper/builder.html.php | 2 +- .../CoreBundle/Views/Slots/codemode.html.php | 13 +++++ .../Views/Slots/imagecaption.html.php | 16 ++++++ .../CoreBundle/Views/Slots/imagecard.html.php | 14 +++++ .../Views/Slots/socialfollow.html.php | 13 +++++ .../Views/Slots/socialshare.html.php | 13 +++++ .../PageBundle/Controller/AjaxController.php | 1 + .../EventListener/BuilderSubscriber.php | 44 +++++++++++++++- .../EventListener/EmailSubscriber.php | 1 + 19 files changed, 472 insertions(+), 8 deletions(-) create mode 100644 app/bundles/CoreBundle/Form/Type/SlotCodeModeType.php create mode 100644 app/bundles/CoreBundle/Form/Type/SlotImageCaptionType.php create mode 100644 app/bundles/CoreBundle/Form/Type/SlotImageCardType.php create mode 100644 app/bundles/CoreBundle/Form/Type/SlotImageType.php create mode 100644 app/bundles/CoreBundle/Form/Type/SlotSocialFollowType.php create mode 100644 app/bundles/CoreBundle/Form/Type/SlotSocialShareType.php create mode 100644 app/bundles/CoreBundle/Views/Slots/codemode.html.php create mode 100644 app/bundles/CoreBundle/Views/Slots/imagecaption.html.php create mode 100644 app/bundles/CoreBundle/Views/Slots/imagecard.html.php create mode 100644 app/bundles/CoreBundle/Views/Slots/socialfollow.html.php create mode 100644 app/bundles/CoreBundle/Views/Slots/socialshare.html.php diff --git a/app/bundles/CoreBundle/Assets/css/app/less/custom.less b/app/bundles/CoreBundle/Assets/css/app/less/custom.less index 305b8a09002..febd4d76d6d 100644 --- a/app/bundles/CoreBundle/Assets/css/app/less/custom.less +++ b/app/bundles/CoreBundle/Assets/css/app/less/custom.less @@ -269,5 +269,8 @@ td.col-id, th.col-id { .badge-wrapper { float: right; vertical-align: middle; - margin-left: 10px; + margin-right: -10px; +} +span.slot-caption { + font-size: 12px; } diff --git a/app/bundles/CoreBundle/Assets/js/4.builder.js b/app/bundles/CoreBundle/Assets/js/4.builder.js index 6f7169d4689..0eb14297cf2 100644 --- a/app/bundles/CoreBundle/Assets/js/4.builder.js +++ b/app/bundles/CoreBundle/Assets/js/4.builder.js @@ -899,6 +899,20 @@ Mautic.initSlotListeners = function() { } else if (fieldParam === 'float') { var values = ['left', 'center', 'right']; params.slot.find('a').parent().attr('align', values[params.field.val()]); + } else if (fieldParam === 'imgalign') { + Mautic.builderContents.find('[data-slot-focus]').each( function() { + var focusedSlot = mQuery(this).closest('[data-slot]'); + if (focusedSlot.attr('data-slot') == 'image') { + // Deactivate froala toolbar + focusedSlot.find('img').each( function() { + mQuery(this).froalaEditor('popups.hideAll'); + }); + Mautic.builderContents.find('.fr-image-resizer.fr-active').removeClass('fr-active'); + } + }); + + var values = ['left', 'center', 'right']; + params.slot.find('img').attr('align', values[params.field.val()]); } else if (fieldParam === 'button-size') { var values = [ {padding: '10px 13px', fontSize: '14px'}, diff --git a/app/bundles/CoreBundle/Assets/js/libraries/froala/plugins/token.js b/app/bundles/CoreBundle/Assets/js/libraries/froala/plugins/token.js index 35cb6cd3462..0476598c7a3 100644 --- a/app/bundles/CoreBundle/Assets/js/libraries/froala/plugins/token.js +++ b/app/bundles/CoreBundle/Assets/js/libraries/froala/plugins/token.js @@ -44,7 +44,6 @@ function apply (val) { editor.html.insert(val); -// editor.$el.keyup(); } return { @@ -68,7 +67,6 @@ var method = location.href.match(/email/i)? 'email:getBuilderTokens' : 'page:getBuilderTokens'; Mautic.getTokens(method, function(tokens) { mQuery.each(tokens, function(k,v){ - //if (k.match(/form=/i)){tokens[k] = 'Form: ' + v;} if (k.match(/assetlink=/i)){ delete tokens[k]; var nv = v.replace('a:', ''); @@ -98,8 +96,10 @@ for (var i = 0; i < keys.length; i++) { var val = keys[i]; var str = '
_BADGE_
'; - var badge = (val.match(/page link/i))? str.replace(/_BADGE_/, 'page link') : (val.match(/asset link/i))? str.replace(/_BADGE_/, 'asset link') : (val.match(/form=/i))? str.replace(/_BADGE_/,'form') : (val.match(/focus=/i))? str.replace(/_BADGE_/,'focus') : ''; - c += '
  • ' + options[val] + badge + '
  • '; + var badge = (val.match(/page link/i))? str.replace(/_BADGE_/, 'page') : (val.match(/asset link/i))? str.replace(/_BADGE_/, 'asset') : (val.match(/form=/i))? str.replace(/_BADGE_/,'form') : (val.match(/focus=/i))? str.replace(/_BADGE_/,'focus') : ''; + var title = options[val]; + if (title.length>24) title = title.substr(0, 24) + '...'; + c += '
  • ' + title + badge + '
  • '; } c += ''; diff --git a/app/bundles/CoreBundle/Config/config.php b/app/bundles/CoreBundle/Config/config.php index 6ce421ce5fd..01ba677b44f 100644 --- a/app/bundles/CoreBundle/Config/config.php +++ b/app/bundles/CoreBundle/Config/config.php @@ -266,6 +266,30 @@ 'class' => 'Mautic\CoreBundle\Form\Type\SlotButtonType', 'alias' => 'slot_button', ], + 'mautic.form.type.slot.image' => [ + 'class' => 'Mautic\CoreBundle\Form\Type\SlotImageType', + 'alias' => 'slot_image', + ], + 'mautic.form.type.slot.imagecard' => [ + 'class' => 'Mautic\CoreBundle\Form\Type\SlotImageCardType', + 'alias' => 'slot_imagecard', + ], + 'mautic.form.type.slot.imagecaption' => [ + 'class' => 'Mautic\CoreBundle\Form\Type\SlotImageCaptionType', + 'alias' => 'slot_imagecaption', + ], + 'mautic.form.type.slot.socialshare' => [ + 'class' => 'Mautic\CoreBundle\Form\Type\SlotSocialShareType', + 'alias' => 'slot_socialshare', + ], + 'mautic.form.type.slot.socialfollow' => [ + 'class' => 'Mautic\CoreBundle\Form\Type\SlotSocialFollowType', + 'alias' => 'slot_socialfollow', + ], + 'mautic.form.type.slot.codemode' => [ + 'class' => 'Mautic\CoreBundle\Form\Type\SlotCodeModeType', + 'alias' => 'slot_codemode', + ], 'mautic.form.type.theme.upload' => [ 'class' => 'Mautic\CoreBundle\Form\Type\ThemeUploadType', 'alias' => 'theme_upload', diff --git a/app/bundles/CoreBundle/Form/Type/SlotCodeModeType.php b/app/bundles/CoreBundle/Form/Type/SlotCodeModeType.php new file mode 100644 index 00000000000..3234d600906 --- /dev/null +++ b/app/bundles/CoreBundle/Form/Type/SlotCodeModeType.php @@ -0,0 +1,52 @@ +add('codemode_align', 'button_group', [ + 'label' => 'mautic.core.image.position', + 'label_attr' => ['class' => 'control-label'], + 'required' => false, + 'attr' => [ + 'class' => 'form-control', + 'data-slot-param' => 'divalign', + ], + 'choice_list' => new ChoiceList( + ['left', 'center', 'right'], + ['mautic.core.left', 'mautic.core.center', 'mautic.core.right'] + ), + ]); + } + + /** + * @return string + */ + public function getName() + { + return 'slot_codemode'; + } +} diff --git a/app/bundles/CoreBundle/Form/Type/SlotImageCaptionType.php b/app/bundles/CoreBundle/Form/Type/SlotImageCaptionType.php new file mode 100644 index 00000000000..ed71892ce81 --- /dev/null +++ b/app/bundles/CoreBundle/Form/Type/SlotImageCaptionType.php @@ -0,0 +1,52 @@ +add('imagecaption_align', 'button_group', [ + 'label' => 'mautic.core.image.position', + 'label_attr' => ['class' => 'control-label'], + 'required' => false, + 'attr' => [ + 'class' => 'form-control', + 'data-slot-param' => 'imgalign', + ], + 'choice_list' => new ChoiceList( + ['left', 'center', 'right'], + ['mautic.core.left', 'mautic.core.center', 'mautic.core.right'] + ), + ]); + + parent::buildForm($builder, $options); + } + + /** + * @return string + */ + public function getName() + { + return 'slot_imagecaption'; + } +} diff --git a/app/bundles/CoreBundle/Form/Type/SlotImageCardType.php b/app/bundles/CoreBundle/Form/Type/SlotImageCardType.php new file mode 100644 index 00000000000..c4c90ae535f --- /dev/null +++ b/app/bundles/CoreBundle/Form/Type/SlotImageCardType.php @@ -0,0 +1,52 @@ +add('imagecard_align', 'button_group', [ + 'label' => 'mautic.core.image.position', + 'label_attr' => ['class' => 'control-label'], + 'required' => false, + 'attr' => [ + 'class' => 'form-control', + 'data-slot-param' => 'imgalign', + ], + 'choice_list' => new ChoiceList( + ['left', 'center', 'right'], + ['mautic.core.left', 'mautic.core.center', 'mautic.core.right'] + ), + ]); + } + + /** + * @return string + */ + public function getName() + { + return 'slot_imagecard'; + } +} diff --git a/app/bundles/CoreBundle/Form/Type/SlotImageType.php b/app/bundles/CoreBundle/Form/Type/SlotImageType.php new file mode 100644 index 00000000000..1688039333d --- /dev/null +++ b/app/bundles/CoreBundle/Form/Type/SlotImageType.php @@ -0,0 +1,52 @@ +add('image_align', 'button_group', [ + 'label' => 'mautic.core.image.position', + 'label_attr' => ['class' => 'control-label'], + 'required' => false, + 'attr' => [ + 'class' => 'form-control', + 'data-slot-param' => 'imgalign', + ], + 'choice_list' => new ChoiceList( + ['left', 'center', 'right'], + ['mautic.core.left', 'mautic.core.center', 'mautic.core.right'] + ), + ]); + + parent::buildForm($builder, $options); + } + + /** + * @return string + */ + public function getName() + { + return 'slot_image'; + } +} diff --git a/app/bundles/CoreBundle/Form/Type/SlotSocialFollowType.php b/app/bundles/CoreBundle/Form/Type/SlotSocialFollowType.php new file mode 100644 index 00000000000..885d06806f3 --- /dev/null +++ b/app/bundles/CoreBundle/Form/Type/SlotSocialFollowType.php @@ -0,0 +1,52 @@ +add('socialfollow_align', 'button_group', [ + 'label' => 'mautic.core.image.position', + 'label_attr' => ['class' => 'control-label'], + 'required' => false, + 'attr' => [ + 'class' => 'form-control', + 'data-slot-param' => 'divalign', + ], + 'choice_list' => new ChoiceList( + ['left', 'center', 'right'], + ['mautic.core.left', 'mautic.core.center', 'mautic.core.right'] + ), + ]); + } + + /** + * @return string + */ + public function getName() + { + return 'slot_socialfollow'; + } +} diff --git a/app/bundles/CoreBundle/Form/Type/SlotSocialShareType.php b/app/bundles/CoreBundle/Form/Type/SlotSocialShareType.php new file mode 100644 index 00000000000..e845dd4f1c1 --- /dev/null +++ b/app/bundles/CoreBundle/Form/Type/SlotSocialShareType.php @@ -0,0 +1,52 @@ +add('socialshare_align', 'button_group', [ + 'label' => 'mautic.core.image.position', + 'label_attr' => ['class' => 'control-label'], + 'required' => false, + 'attr' => [ + 'class' => 'form-control', + 'data-slot-param' => 'divalign', + ], + 'choice_list' => new ChoiceList( + ['left', 'center', 'right'], + ['mautic.core.left', 'mautic.core.center', 'mautic.core.right'] + ), + ]); + } + + /** + * @return string + */ + public function getName() + { + return 'slot_socialshare'; + } +} diff --git a/app/bundles/CoreBundle/Views/Helper/builder.html.php b/app/bundles/CoreBundle/Views/Helper/builder.html.php index a988a198213..00833b1fe67 100644 --- a/app/bundles/CoreBundle/Views/Helper/builder.html.php +++ b/app/bundles/CoreBundle/Views/Helper/builder.html.php @@ -48,7 +48,7 @@

    - + diff --git a/app/bundles/CoreBundle/Views/Slots/codemode.html.php b/app/bundles/CoreBundle/Views/Slots/codemode.html.php new file mode 100644 index 00000000000..a53baed4a14 --- /dev/null +++ b/app/bundles/CoreBundle/Views/Slots/codemode.html.php @@ -0,0 +1,13 @@ + + +Insert text here diff --git a/app/bundles/CoreBundle/Views/Slots/imagecaption.html.php b/app/bundles/CoreBundle/Views/Slots/imagecaption.html.php new file mode 100644 index 00000000000..a446c1ffd4a --- /dev/null +++ b/app/bundles/CoreBundle/Views/Slots/imagecaption.html.php @@ -0,0 +1,16 @@ + +
    + An image +
    Caption goes here
    +
    +
    diff --git a/app/bundles/CoreBundle/Views/Slots/imagecard.html.php b/app/bundles/CoreBundle/Views/Slots/imagecard.html.php new file mode 100644 index 00000000000..a737c52262a --- /dev/null +++ b/app/bundles/CoreBundle/Views/Slots/imagecard.html.php @@ -0,0 +1,14 @@ + + +An image +
    diff --git a/app/bundles/CoreBundle/Views/Slots/socialfollow.html.php b/app/bundles/CoreBundle/Views/Slots/socialfollow.html.php new file mode 100644 index 00000000000..a53baed4a14 --- /dev/null +++ b/app/bundles/CoreBundle/Views/Slots/socialfollow.html.php @@ -0,0 +1,13 @@ + + +Insert text here diff --git a/app/bundles/CoreBundle/Views/Slots/socialshare.html.php b/app/bundles/CoreBundle/Views/Slots/socialshare.html.php new file mode 100644 index 00000000000..a53baed4a14 --- /dev/null +++ b/app/bundles/CoreBundle/Views/Slots/socialshare.html.php @@ -0,0 +1,13 @@ + + +Insert text here diff --git a/app/bundles/PageBundle/Controller/AjaxController.php b/app/bundles/PageBundle/Controller/AjaxController.php index adff8c72b47..cf7c093100a 100644 --- a/app/bundles/PageBundle/Controller/AjaxController.php +++ b/app/bundles/PageBundle/Controller/AjaxController.php @@ -119,6 +119,7 @@ protected function getBuilderTokens($query) /** @var \Mautic\PageBundle\Model\PageModel $model */ $model = $this->getModel('page'); + // $requestedComponents must be an array so ajax calls can properly manage responses return $model->getBuilderComponents(null, ['tokens'], $query); } } diff --git a/app/bundles/PageBundle/EventListener/BuilderSubscriber.php b/app/bundles/PageBundle/EventListener/BuilderSubscriber.php index 5fc0ec7a3ed..127afd9b7a1 100644 --- a/app/bundles/PageBundle/EventListener/BuilderSubscriber.php +++ b/app/bundles/PageBundle/EventListener/BuilderSubscriber.php @@ -127,9 +127,25 @@ public function onPageBuild(Events\PageBuilderEvent $event) 'Image', 'image', 'MauticCoreBundle:Slots:image.html.php', - 'slot', + 'slot_image', 900 ); + $event->addSlotType( + 'imagecard', + 'Image Card', + 'id-card-o', + 'MauticCoreBundle:Slots:imagecard.html.php', + 'slot_imagecard', + 870 + ); + $event->addSlotType( + 'imagecaption', + 'Image+Caption', + 'image', + 'MauticCoreBundle:Slots:imagecaption.html.php', + 'slot_imagecaption', + 850 + ); $event->addSlotType( 'button', 'Button', @@ -138,13 +154,37 @@ public function onPageBuild(Events\PageBuilderEvent $event) 'slot_button', 800 ); + $event->addSlotType( + 'socialshare', + 'Social Share', + 'share-alt', + 'MauticCoreBundle:Slots:socialshare.html.php', + 'slot', + 700 + ); + $event->addSlotType( + 'socialfollow', + 'Social Follow', + 'twitter', + 'MauticCoreBundle:Slots:socialfollow.html.php', + 'slot', + 600 + ); + $event->addSlotType( + 'codemode', + 'Code Mode', + 'code', + 'MauticCoreBundle:Slots:codemode.html.php', + 'slot', + 500 + ); $event->addSlotType( 'separator', 'Separator', 'minus', 'MauticCoreBundle:Slots:separator.html.php', 'slot', - 700 + 400 ); } } diff --git a/plugins/MauticCitrixBundle/EventListener/EmailSubscriber.php b/plugins/MauticCitrixBundle/EventListener/EmailSubscriber.php index c15bcea5730..0135d865bb4 100644 --- a/plugins/MauticCitrixBundle/EventListener/EmailSubscriber.php +++ b/plugins/MauticCitrixBundle/EventListener/EmailSubscriber.php @@ -57,6 +57,7 @@ public function onTokenGenerate(TokenGenerateEvent $event) */ public function onEmailBuild(EmailBuilderEvent $event) { + // register tokens only if the plugins are enabled $tokens = []; $activeProducts = []; foreach (['meeting', 'training', 'assist'] as $p) { From 8059d578543c52d3f1fef5374886796de7fa6474 Mon Sep 17 00:00:00 2001 From: Marianela Queme Date: Fri, 24 Feb 2017 12:08:22 +0000 Subject: [PATCH 044/510] added ability to turn data priority feature on and off per integration, default is false --- .../Form/Type/CompanyFieldsType.php | 27 ++++++++++--------- .../Form/Type/FeatureSettingsType.php | 10 ++++++- .../PluginBundle/Form/Type/FieldsType.php | 27 ++++++++++--------- .../Integration/AbstractIntegration.php | 13 ++++++++- ...ls_featureSettings_leadFields_row.html.php | 18 +++++++------ .../integration_company_fields_row.html.php | 19 +++++++------ .../Integration/SalesforceIntegration.php | 10 +++++++ 7 files changed, 82 insertions(+), 42 deletions(-) diff --git a/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php b/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php index 4b9a6402258..0bf44fc797f 100644 --- a/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php +++ b/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php @@ -32,6 +32,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) $integrationFields = array_combine(array_keys($options['integration_company_fields']), array_keys($options['integration_company_fields'])); $data = isset($options['data']) ? $options['data'] : []; $integrationFieldsOrdered = array_merge($data, $integrationFields); + foreach ($integrationFieldsOrdered as $field => $details) { ++$index; $builder->add('i_'.$index, 'choice', [ @@ -41,18 +42,19 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'attr' => ['class' => 'field-selector form-control', 'data-placeholder' => ' '], 'disabled' => ($index > 1 && !isset($data[$field])) ? true : false, ]); - $builder->add('update_mautic_company'.$index, - 'yesno_button_group', - [ - 'label' => false, - 'data' => isset($options['data']['update_mautic_company']) ? (bool) $options['data']['update_mautic_company'] : true, - 'no_label' => '', - 'yes_label' => '', - 'empty_value' => false, - 'attr' => ['data-toggle' => 'tooltip', 'title' => 'mautic.plugin.direction.data.update'], - 'disabled' => ($index > 1 && !isset($data[$field])) ? true : false, - ]); - + if (isset($options['enable_data_priority']) and $options['enable_data_priority']) { + $builder->add('update_mautic_company'.$index, + 'yesno_button_group', + [ + 'label' => false, + 'data' => isset($options['data']['update_mautic_company']) ? (bool) $options['data']['update_mautic_company'] : true, + 'no_label' => '', + 'yes_label' => '', + 'empty_value' => false, + 'attr' => ['data-toggle' => 'tooltip', 'title' => 'mautic.plugin.direction.data.update'], + 'disabled' => ($index > 1 && !isset($data[$field])) ? true : false, + ]); + } $builder->add('m_'.$index, 'choice', [ 'choices' => $options['company_fields'], 'label' => false, @@ -74,6 +76,7 @@ public function configureOptions(OptionsResolver $resolver) 'special_instructions' => '', 'alert_type' => '', 'allow_extra_fields' => true, + 'enable_data_priority' => false, ] ); } diff --git a/app/bundles/PluginBundle/Form/Type/FeatureSettingsType.php b/app/bundles/PluginBundle/Form/Type/FeatureSettingsType.php index 7749158c07b..8fe3b7d14ba 100644 --- a/app/bundles/PluginBundle/Form/Type/FeatureSettingsType.php +++ b/app/bundles/PluginBundle/Form/Type/FeatureSettingsType.php @@ -45,8 +45,9 @@ public function buildForm(FormBuilderInterface $builder, array $options) $integration_object->appendToForm($builder, $options['data'], 'features'); $leadFields = $options['lead_fields']; $companyFields = $options['company_fields']; + $formSettings = $options['integration_object']->getFormDisplaySettings(); - $formModifier = function (FormInterface $form, $data, $method = 'get') use ($integration_object, $leadFields, $companyFields) { + $formModifier = function (FormInterface $form, $data, $method = 'get') use ($integration_object, $leadFields, $companyFields, $formSettings) { $settings = [ 'silence_exceptions' => false, 'feature_settings' => $data, @@ -82,6 +83,11 @@ public function buildForm(FormBuilderInterface $builder, array $options) $integrationFields = array_keys($fields); $flattenLeadFields = array_keys($flattenLeadFields); $fieldsIntersection = array_uintersect($integrationFields, $flattenLeadFields, 'strcasecmp'); + $enableDataPriority = false; + $this->factory->getLogger()->addError(print_r($formSettings, true)); + if (isset($formSettings['enable_data_priority'])) { + $enableDataPriority = $formSettings['enable_data_priority']; + } $autoMatchedFields = []; foreach ($fieldsIntersection as $field) { @@ -99,6 +105,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'integration_fields' => $fields, 'special_instructions' => $specialInstructions, 'alert_type' => $alertType, + 'enable_data_priority' => $enableDataPriority, ] ); if (!empty($integrationCompanyFields)) { @@ -113,6 +120,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'integration_company_fields' => $integrationCompanyFields, 'special_instructions' => $specialInstructions, 'alert_type' => $alertType, + 'enable_data_priority' => $enableDataPriority, ] ); } diff --git a/app/bundles/PluginBundle/Form/Type/FieldsType.php b/app/bundles/PluginBundle/Form/Type/FieldsType.php index 42b807ce700..309ef77df71 100644 --- a/app/bundles/PluginBundle/Form/Type/FieldsType.php +++ b/app/bundles/PluginBundle/Form/Type/FieldsType.php @@ -32,6 +32,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) $integrationFields = array_combine(array_keys($options['integration_fields']), array_keys($options['integration_fields'])); $data = isset($options['data']) ? $options['data'] : []; $integrationFieldsOrdered = array_merge($data, $integrationFields); + foreach ($integrationFieldsOrdered as $field => $details) { ++$index; $builder->add('i_'.$index, 'choice', [ @@ -42,18 +43,19 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'attr' => ['class' => 'field-selector form-control', 'data-placeholder' => ' '], 'disabled' => ($index > 1 && !isset($data[$field])) ? true : false, ]); - $builder->add('update_mautic'.$index, - 'yesno_button_group', - [ - 'label' => false, - 'data' => isset($options['update_mautic'][$field]) ? (bool) $options['update_mautic'][$field] : '', - 'no_label' => '', - 'yes_label' => '', - 'empty_value' => false, - 'attr' => ['data-toggle' => 'tooltip', 'title' => 'mautic.plugin.direction.data.update'], - 'disabled' => ($index > 1 && !isset($data[$field])) ? true : false, - ]); - + if (isset($options['enable_data_priority']) and $options['enable_data_priority']) { + $builder->add('update_mautic'.$index, + 'yesno_button_group', + [ + 'label' => false, + 'data' => isset($options['update_mautic'][$field]) ? (bool) $options['update_mautic'][$field] : '', + 'no_label' => '', + 'yes_label' => '', + 'empty_value' => false, + 'attr' => ['data-toggle' => 'tooltip', 'title' => 'mautic.plugin.direction.data.update'], + 'disabled' => ($index > 1 && !isset($data[$field])) ? true : false, + ]); + } $builder->add('m_'.$index, 'choice', [ 'choices' => $options['lead_fields'], 'label' => false, @@ -77,6 +79,7 @@ public function configureOptions(OptionsResolver $resolver) 'special_instructions' => '', 'alert_type' => '', 'allow_extra_fields' => true, + 'enable_data_priority' => false, ] ); } diff --git a/app/bundles/PluginBundle/Integration/AbstractIntegration.php b/app/bundles/PluginBundle/Integration/AbstractIntegration.php index 386d2a26e12..d8f32d40912 100644 --- a/app/bundles/PluginBundle/Integration/AbstractIntegration.php +++ b/app/bundles/PluginBundle/Integration/AbstractIntegration.php @@ -166,6 +166,15 @@ public function getIcon() */ abstract public function getAuthenticationType(); + /** + * Get if data priority is enabled in the integration or not default is false. + * + * @return string + */ + public function getDataPriority() + { + return false; + } /** * Get a list of supported features for this integration. * @@ -1711,7 +1720,8 @@ public function appendToForm(&$builder, $data, $formArea) */ public function getFormSettings() { - $type = $this->getAuthenticationType(); + $type = $this->getAuthenticationType(); + $enableDataPriority = $this->getDataPriority(); switch ($type) { case 'oauth1a': case 'oauth2': @@ -1726,6 +1736,7 @@ public function getFormSettings() 'requires_callback' => $callback, 'requires_authorization' => $authorization, 'default_features' => [], + 'enable_data_priority' => $enableDataPriority, ]; } diff --git a/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php b/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php index f8c0e27bde9..824d95e987c 100644 --- a/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php +++ b/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php @@ -17,34 +17,36 @@
    + offsetExists('update_mautic1')) ? 3 : 2; ?>

    trans('mautic.plugins.integration.fields'); ?>

    -
    + +
    +

    trans('mautic.plugins.mautic.fields'); ?>

    errors($form); ?> - children as $child): ?> - +
    -
    pl-xs pr-xs col-sm- pl-xs pr-xs col-sm-"> row($child); ?>
    -
    - +
    @@ -54,7 +56,7 @@ endif; ?> + if ($rowCount % $numberOfFields == 1):?>
    Add field diff --git a/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_company_fields_row.html.php b/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_company_fields_row.html.php index 976776da5c6..d7b71632706 100644 --- a/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_company_fields_row.html.php +++ b/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_company_fields_row.html.php @@ -17,42 +17,45 @@
    + offsetExists('update_mautic_company1')) ? 3 : 2; ?>

    trans('mautic.plugins.integration.fields'); ?>

    -
    + +
    +

    trans('mautic.plugins.mautic.fields'); ?>

    errors($form); ?> - + children as $child): ?> - +
    -
    pl-xs pr-xs col-sm- pl-xs pr-xs col-sm-"> row($child); ?>
    -
    - +
    - +
    diff --git a/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php b/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php index 0702a3033b1..0abefd458d3 100644 --- a/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php +++ b/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php @@ -176,6 +176,16 @@ public function getAuthenticationType() return 'oauth2'; } + /** + * {@inheritdoc} + * + * @return bool + */ + public function getDataPriority() + { + return true; + } + /** * Get available company fields for choices in the config UI. * From fc8ef251361c27e3a3836210bca4bc69622c20e7 Mon Sep 17 00:00:00 2001 From: Don Gilbert Date: Sat, 25 Feb 2017 16:06:23 -0500 Subject: [PATCH 045/510] Gated Video slot UI --- app/bundles/CoreBundle/Assets/js/4.builder.js | 37 +++++- .../CoreBundle/Form/Type/GatedVideoType.php | 120 ++++++++++++++++++ .../Views/Slots/gatedvideo.html.php | 17 +++ .../EventListener/BuilderSubscriber.php | 9 ++ media/js/app.js | 8 +- 5 files changed, 187 insertions(+), 4 deletions(-) create mode 100644 app/bundles/CoreBundle/Form/Type/GatedVideoType.php create mode 100644 app/bundles/CoreBundle/Views/Slots/gatedvideo.html.php diff --git a/app/bundles/CoreBundle/Assets/js/4.builder.js b/app/bundles/CoreBundle/Assets/js/4.builder.js index f031a1e6477..ef5869024b3 100644 --- a/app/bundles/CoreBundle/Assets/js/4.builder.js +++ b/app/bundles/CoreBundle/Assets/js/4.builder.js @@ -751,13 +751,32 @@ Mautic.initSlotListeners = function() { // Prefill the form field values with the values from slot attributes if any parent.mQuery.each(clickedSlot.get(0).attributes, function(i, attr) { - var attrPrefix = 'data-param-'; var regex = /data-param-(.*)/; var match = regex.exec(attr.name); if (match !== null) { focusForm.find('input[type="text"][data-slot-param="'+match[1]+'"]').val(attr.value); focusForm.find('input[type="radio"][data-slot-param="'+match[1]+'"][value="'+attr.value+'"]').prop('checked', 1); + + var selectField = focusForm.find('select[data-slot-param="'+match[1]+'"]'); + + if (selectField) { + selectField.val(attr.value) + } + + // URL fields + var urlField = focusForm.find('input[type="url"][data-slot-param="'+match[1]+'"]'); + + if (urlField) { + urlField.val(attr.value); + } + + // Number fields + var numberField = focusForm.find('input[type="number"][data-slot-param="'+match[1]+'"]'); + + if (numberField) { + numberField.val(attr.value); + } } }); @@ -911,6 +930,22 @@ Mautic.initSlotListeners = function() { params.slot.find('a').attr('background', '#'+params.field.val()); } else if (fieldParam === 'color') { params.slot.find('a').css(fieldParam, '#'+params.field.val()); + } else if (/gatedvideo/.test(fieldParam)) { + // Handle gatedVideo replacements + var toInsert = fieldParam.split('-')[1]; + var insertVal = params.field.val(); + + if (toInsert === 'url') { + params.slot.find('source').attr('src', insertVal); + } else if (toInsert === 'gatetime') { + params.slot.find('video').attr('data-gate-time', insertVal); + } else if (toInsert === 'formid') { + params.slot.find('video').attr('data-form-id', insertVal); + } else if (toInsert === 'height') { + params.slot.find('video').attr('height', insertVal); + } else if (toInsert === 'width') { + params.slot.find('video').attr('width', insertVal); + } } if (params.type == 'text') { diff --git a/app/bundles/CoreBundle/Form/Type/GatedVideoType.php b/app/bundles/CoreBundle/Form/Type/GatedVideoType.php new file mode 100644 index 00000000000..598b1a1c064 --- /dev/null +++ b/app/bundles/CoreBundle/Form/Type/GatedVideoType.php @@ -0,0 +1,120 @@ +add( + 'url', + UrlType::class, + [ + 'label' => 'Video URL', + 'label_attr' => ['class' => 'control-label'], + 'required' => true, + 'attr' => [ + 'class' => 'form-control', + 'data-slot-param' => 'gatedvideo-url', + ], + ] + ); + + $builder->add( + 'gateTime', + IntegerType::class, + [ + 'label' => 'Gate Time', + 'label_attr' => ['class' => 'control-label'], + 'required' => true, + 'attr' => [ + 'class' => 'form-control', + 'data-slot-param' => 'gatedvideo-gatetime', + ], + ] + ); + + $builder->add( + 'formId', + EntityType::class, + [ + 'label' => 'Form', + 'label_attr' => ['class' => 'control-label'], + 'required' => true, + 'attr' => [ + 'class' => 'form-control', + 'data-slot-param' => 'gatedvideo-formid', + ], + 'placeholder' => 'Select your form', + 'class' => Form::class, + 'choice_label' => function ($form) { + return sprintf('%s (ID #%d)', $form->getName(), $form->getId()); + }, + ] + ); + + $builder->add( + 'width', + IntegerType::class, + [ + 'label' => 'Width', + 'label_attr' => ['class' => 'control-label'], + 'required' => true, + 'attr' => [ + 'class' => 'form-control', + 'data-slot-param' => 'gatedvideo-width', + ], + ] + ); + + $builder->add( + 'height', + IntegerType::class, + [ + 'label' => 'Height', + 'label_attr' => ['class' => 'control-label'], + 'required' => true, + 'attr' => [ + 'class' => 'form-control', + 'data-slot-param' => 'gatedvideo-height', + ], + ] + ); + + parent::buildForm($builder, $options); + } + + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver->setDefaults([ + 'width' => 640, + 'height' => 320, + ]); + + parent::setDefaultOptions($resolver); // TODO: Change the autogenerated stub + } + + /** + * @return mixed + */ + public function getName() + { + return self::class; + } +} diff --git a/app/bundles/CoreBundle/Views/Slots/gatedvideo.html.php b/app/bundles/CoreBundle/Views/Slots/gatedvideo.html.php new file mode 100644 index 00000000000..c596ef37f72 --- /dev/null +++ b/app/bundles/CoreBundle/Views/Slots/gatedvideo.html.php @@ -0,0 +1,17 @@ + + + + + diff --git a/app/bundles/PageBundle/EventListener/BuilderSubscriber.php b/app/bundles/PageBundle/EventListener/BuilderSubscriber.php index 5fc0ec7a3ed..73b29d0a862 100644 --- a/app/bundles/PageBundle/EventListener/BuilderSubscriber.php +++ b/app/bundles/PageBundle/EventListener/BuilderSubscriber.php @@ -12,6 +12,7 @@ namespace Mautic\PageBundle\EventListener; use Mautic\CoreBundle\EventListener\CommonSubscriber; +use Mautic\CoreBundle\Form\Type\GatedVideoType; use Mautic\CoreBundle\Form\Type\SlotTextType; use Mautic\CoreBundle\Helper\BuilderTokenHelper; use Mautic\EmailBundle\EmailEvents; @@ -146,6 +147,14 @@ public function onPageBuild(Events\PageBuilderEvent $event) 'slot', 700 ); + $event->addSlotType( + 'gatedvideo', + 'Video', + 'video-camera', + 'MauticCoreBundle:Slots:gatedvideo.html.php', + GatedVideoType::class, + 600 + ); } } diff --git a/media/js/app.js b/media/js/app.js index 8ad61ff356d..b6fcca1c7a8 100644 --- a/media/js/app.js +++ b/media/js/app.js @@ -172,12 +172,14 @@ slot.append(focus);deleteLink.click(function(e){slot.trigger('slot:destroy',{slo slot.append(slotToolbar);},function(){if(Mautic.sortActive){return;} slotToolbar.remove();focus.remove();});slot.on('click',function(){var clickedSlot=mQuery(this);clickedSlot.trigger('slot:selected',clickedSlot);var minicolors=parent.mQuery('#slot-form-container .minicolors');if(minicolors.length){parent.mQuery('#slot-form-container input[data-toggle="color"]').each(function(){mQuery(this).minicolors('destroy');});parent.mQuery('#slot-form-container').off('change.minicolors');} if(parent.mQuery('#slot-form-container').find('textarea.editor')){parent.mQuery('#slot-form-container').find('textarea.editor').each(function(){parent.mQuery(this).froalaEditor('popups.hideAll');});} -var focusType=clickedSlot.attr('data-slot');var focusForm=mQuery(parent.mQuery('script[data-slot-type-form="'+focusType+'"]').html());parent.mQuery('#slot-form-container').html(focusForm);parent.mQuery.each(clickedSlot.get(0).attributes,function(i,attr){var attrPrefix='data-param-';var regex=/data-param-(.*)/;var match=regex.exec(attr.name);if(match!==null){focusForm.find('input[type="text"][data-slot-param="'+match[1]+'"]').val(attr.value);focusForm.find('input[type="radio"][data-slot-param="'+match[1]+'"][value="'+attr.value+'"]').prop('checked',1);}});focusForm.on('keyup',function(e){var field=mQuery(e.target);clickedSlot.attr('data-param-'+field.attr('data-slot-param'),field.val());clickedSlot.trigger('slot:change',{slot:clickedSlot,field:field,type:focusType});});focusForm.find('.btn').on('click',function(e){var field=mQuery(this).find('input:radio');if(field.length){clickedSlot.attr('data-param-'+field.attr('data-slot-param'),field.val());clickedSlot.trigger('slot:change',{slot:clickedSlot,field:field,type:focusType});}});focusForm.find('input[data-toggle="color"]').each(function(){parent.Mautic.activateColorPicker(this);});focusForm.find('textarea.editor').each(function(){var theEditor=this;var slotHtml=parent.mQuery('
    ').html(clickedSlot.html());slotHtml.find('[data-slot-focus]').remove();slotHtml.find('[data-slot-toolbar]').remove();var buttons=['undo','redo','|','bold','italic','underline','paragraphFormat','fontFamily','fontSize','color','align','formatOL','formatUL','quote','clearFormatting','insertLink','insertImage','insertGatedVideo','insertTable','html','fullscreen'] +var focusType=clickedSlot.attr('data-slot');var focusForm=mQuery(parent.mQuery('script[data-slot-type-form="'+focusType+'"]').html());parent.mQuery('#slot-form-container').html(focusForm);parent.mQuery.each(clickedSlot.get(0).attributes,function(i,attr){var regex=/data-param-(.*)/;var match=regex.exec(attr.name);if(match!==null){focusForm.find('input[type="text"][data-slot-param="'+match[1]+'"]').val(attr.value);focusForm.find('input[type="radio"][data-slot-param="'+match[1]+'"][value="'+attr.value+'"]').prop('checked',1);var selectField=focusForm.find('select[data-slot-param="'+match[1]+'"]');if(selectField){selectField.val(attr.value)} +var urlField=focusForm.find('input[type="url"][data-slot-param="'+match[1]+'"]');if(urlField){urlField.val(attr.value);} +var numberField=focusForm.find('input[type="number"][data-slot-param="'+match[1]+'"]');if(numberField){numberField.val(attr.value);}}});focusForm.on('keyup',function(e){var field=mQuery(e.target);clickedSlot.attr('data-param-'+field.attr('data-slot-param'),field.val());clickedSlot.trigger('slot:change',{slot:clickedSlot,field:field,type:focusType});});focusForm.find('.btn').on('click',function(e){var field=mQuery(this).find('input:radio');if(field.length){clickedSlot.attr('data-param-'+field.attr('data-slot-param'),field.val());clickedSlot.trigger('slot:change',{slot:clickedSlot,field:field,type:focusType});}});focusForm.find('input[data-toggle="color"]').each(function(){parent.Mautic.activateColorPicker(this);});focusForm.find('textarea.editor').each(function(){var theEditor=this;var slotHtml=parent.mQuery('
    ').html(clickedSlot.html());slotHtml.find('[data-slot-focus]').remove();slotHtml.find('[data-slot-toolbar]').remove();var buttons=['undo','redo','|','bold','italic','underline','paragraphFormat','fontFamily','fontSize','color','align','formatOL','formatUL','quote','clearFormatting','insertLink','insertImage','insertGatedVideo','insertTable','html','fullscreen'] var builderEl=parent.mQuery('.builder');if(builderEl.length&&builderEl.hasClass('email-builder')){buttons=parent.mQuery.grep(buttons,function(value){return value!='insertGatedVideo';});} var froalaOptions={toolbarButtons:buttons,toolbarButtonsMD:buttons,toolbarButtonsSM:buttons,toolbarButtonsXS:buttons,linkList:[],imageEditButtons:['imageReplace','imageAlign','imageRemove','imageAlt','imageSize','|','imageLink','linkOpen','linkEdit','linkRemove']};parent.mQuery(this).on('froalaEditor.initialized',function(e,editor){parent.Mautic.initAtWho(editor.$el,parent.Mautic.getBuilderTokensMethod(),editor);Mautic.setTextSlotEditorStyle(editor.$el,clickedSlot);});parent.mQuery(this).on('froalaEditor.contentChanged',function(e,editor){var slotHtml=mQuery('
    ').append(parent.mQuery(theEditor).froalaEditor('html.get'));clickedSlot.html(slotHtml.html());});parent.mQuery(this).val(slotHtml.html());parent.mQuery(this).froalaEditor(parent.mQuery.extend({},Mautic.basicFroalaOptions,froalaOptions));});parent.mQuery('#slot-form-container').on('change.minicolors',function(e,hex){var field=mQuery(e.target);clickedSlot.attr('data-param-'+field.attr('data-slot-param'),field.val());clickedSlot.trigger('slot:change',{slot:clickedSlot,field:field,type:focusType});});});if(type==='image'){var image=mQuery(this).find('img');image.removeAttr('data-froala.editor');image.on('froalaEditor.click',function(e,editor){mQuery(this).closest('[data-slot]').trigger('click');});image.froalaEditor(mQuery.extend({},Mautic.basicFroalaOptions,{linkList:[],imageEditButtons:['imageReplace','imageAlt','imageSize','|','imageLink','linkOpen','linkEdit','linkRemove']}));}else if(type==='button'){mQuery(this).find('a').click(function(e){e.preventDefault();});} Mautic.builderSlots.push({slot:mQuery(this),type:type});});Mautic.getPredefinedLinks=function(callback){var linkList=[];Mautic.getTokens(Mautic.getBuilderTokensMethod(),function(tokens){if(tokens.length){mQuery.each(tokens,function(token,label){if(token.startsWith('{pagelink=')||token.startsWith('{assetlink=')||token.startsWith('{webview_url')||token.startsWith('{unsubscribe_url')){linkList.push({text:label,href:token});}});} return callback(linkList);});} -Mautic.builderContents.on('slot:change',function(event,params){var fieldParam=params.field.attr('data-slot-param');if(fieldParam==='padding-top'||fieldParam==='padding-bottom'){params.slot.css(fieldParam,params.field.val()+'px');}else if(fieldParam==='href'){params.slot.find('a').attr('href',params.field.val());}else if(fieldParam==='link-text'){params.slot.find('a').text(params.field.val());}else if(fieldParam==='float'){var values=['left','center','right'];params.slot.find('a').parent().attr('align',values[params.field.val()]);}else if(fieldParam==='button-size'){var values=[{padding:'10px 13px',fontSize:'14px'},{padding:'12px 18px',fontSize:'16px'},{padding:'15px 20px',fontSize:'18px'}];params.slot.find('a').css(values[params.field.val()]);}else if(fieldParam==='background-color'){params.slot.find('a').css(fieldParam,'#'+params.field.val());params.slot.find('a').attr('background','#'+params.field.val());}else if(fieldParam==='color'){params.slot.find('a').css(fieldParam,'#'+params.field.val());} +Mautic.builderContents.on('slot:change',function(event,params){var fieldParam=params.field.attr('data-slot-param');if(fieldParam==='padding-top'||fieldParam==='padding-bottom'){params.slot.css(fieldParam,params.field.val()+'px');}else if(fieldParam==='href'){params.slot.find('a').attr('href',params.field.val());}else if(fieldParam==='link-text'){params.slot.find('a').text(params.field.val());}else if(fieldParam==='float'){var values=['left','center','right'];params.slot.find('a').parent().attr('align',values[params.field.val()]);}else if(fieldParam==='button-size'){var values=[{padding:'10px 13px',fontSize:'14px'},{padding:'12px 18px',fontSize:'16px'},{padding:'15px 20px',fontSize:'18px'}];params.slot.find('a').css(values[params.field.val()]);}else if(fieldParam==='background-color'){params.slot.find('a').css(fieldParam,'#'+params.field.val());params.slot.find('a').attr('background','#'+params.field.val());}else if(fieldParam==='color'){params.slot.find('a').css(fieldParam,'#'+params.field.val());}else if(/gatedvideo/.test(fieldParam)){var toInsert=fieldParam.split('-')[1];var insertVal=params.field.val();if(toInsert==='url'){params.slot.find('source').attr('src',insertVal);}else if(toInsert==='gatetime'){params.slot.find('video').attr('data-gate-time',insertVal);}else if(toInsert==='formid'){params.slot.find('video').attr('data-form-id',insertVal);}else if(toInsert==='height'){params.slot.find('video').attr('height',insertVal);}else if(toInsert==='width'){params.slot.find('video').attr('width',insertVal);}} if(params.type=='text'){Mautic.setTextSlotEditorStyle(parent.mQuery('#slot_text_content'),params.slot);}});Mautic.builderContents.on('slot:destroy',function(event,params){if(params.type==='text'){if(parent.mQuery('#slot_content').length){parent.mQuery('#slot_content').froalaEditor('destroy');parent.mQuery('#slot_content').find('.atwho-inserted').atwho('destroy');}}else if(params.type==='image'){var image=params.slot.find('img');image.removeAttr('data-froala.editor');image.froalaEditor('destroy');} Mautic.builderContents.find('.sf-toolbar').remove();});};Mautic.setTextSlotEditorStyle=function(editorEl,slot) {var wrapper=parent.mQuery(editorEl).closest('.form-group').find('.fr-wrapper .fr-element').first();if(typeof wrapper=='undefined'){return;} @@ -268,7 +270,7 @@ var message=mQuery(el).data('message');var confirmText=mQuery(el).data('confirm- if(typeof cancelButton!='undefined'){confirmFooterDiv.append(cancelButton);} confirmFooterDiv.append(confirmButton);confirmContentDiv.append(confirmHeaderDiv);confirmContentDiv.append(confirmFooterDiv);confirmContainer.append(confirmDialogDiv.append(confirmContentDiv));mQuery('body').append(confirmContainer);mQuery('.confirmation-modal').on('hidden.bs.modal',function(){mQuery(this).remove();});mQuery('.confirmation-modal').modal('show');};Mautic.dismissConfirmation=function(){if(mQuery('.confirmation-modal').length){mQuery('.confirmation-modal').modal('hide');}};Mautic.closeModalAndRedirect=function(el,url){Mautic.startModalLoadingBar(el);Mautic.loadContent(url);mQuery('body').removeClass('noscroll');};Mautic.loadAjaxModalBySelectValue=function(el,value,route,header){var selectVal=mQuery(el).val();var hasValue=(selectVal==value);if(!hasValue&&mQuery.isArray(selectVal)){hasValue=(mQuery.inArray(value,selectVal)!==-1);} if(hasValue){route=route+(route.indexOf('?')>-1?'&':'?')+'modal=1&contentOnly=1&updateSelect='+mQuery(el).attr('id');mQuery(el).find('option[value="'+value+'"]').prop('selected',false);mQuery(el).trigger("chosen:updated");Mautic.loadAjaxModal('#MauticSharedModal',route,'get',header);}};Mautic.showModal=function(target){if(mQuery('.modal.in').length){if(mQuery(target).closest('.modal').length){mQuery('
    ').attr('data-modal-placeholder',target).insertAfter(mQuery(target));mQuery(target).attr('data-modal-moved',1);mQuery(target).appendTo('body');} -var activeModal=mQuery('.modal.in .modal-dialog:not(:has(.aside))').parents('.modal').last(),targetModal=mQuery(target);if(activeModal.length){targetModal.attr('data-previous-modal','#'+activeModal.attr('id'));activeModal.find('.modal-dialog').addClass('aside');var stackedDialogCount=mQuery('.modal.in .modal-dialog.aside').length;if(stackedDialogCount<=5){activeModal.find('.modal-dialog').addClass('aside-'+stackedDialogCount);} +var activeModal=mQuery('.modal.in .modal-dialog:not(:has(.aside))').parents('.modal').last(),targetModal=mQuery(target);if(activeModal.length&&activeModal.attr('id')!==targetModal.attr('id')){targetModal.attr('data-previous-modal','#'+activeModal.attr('id'));activeModal.find('.modal-dialog').addClass('aside');var stackedDialogCount=mQuery('.modal.in .modal-dialog.aside').length;if(stackedDialogCount<=5){activeModal.find('.modal-dialog').addClass('aside-'+stackedDialogCount);} mQuery(target).on('hide.bs.modal',function(){var modal=mQuery(this);var previous=modal.attr('data-previous-modal');if(previous){mQuery(previous).find('.modal-dialog').removeClass('aside');mQuery(modal).attr('data-previous-modal',undefined);} if(mQuery(modal).attr('data-modal-moved')){mQuery('[data-modal-placeholder').replaceWith(mQuery(modal));mQuery(modal).attr('data-modal-moved',undefined);}});}} mQuery(target).modal('show');};;MauticVars.liveCache=new Array();MauticVars.lastSearchStr="";MauticVars.globalLivecache=new Array();MauticVars.lastGlobalSearchStr="";Mautic.isNewEntity=function(idInputSelector){id=mQuery(idInputSelector);if(id.length){return id.val().match("^new_");} From a9cb8d3f375264c74e5324907b1b6ccddcc4590e Mon Sep 17 00:00:00 2001 From: Marianela Queme Date: Mon, 27 Feb 2017 14:14:21 +0000 Subject: [PATCH 046/510] fixed issues with company fields, removed debugging --- app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php | 7 +++++-- app/bundles/PluginBundle/Form/Type/FeatureSettingsType.php | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php b/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php index 0bf44fc797f..4dd85786963 100644 --- a/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php +++ b/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php @@ -38,6 +38,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) $builder->add('i_'.$index, 'choice', [ 'choices' => $integrationFieldsOrdered, 'label' => false, + 'required' => true, 'data' => isset($data[$field]) ? $field : '', 'attr' => ['class' => 'field-selector form-control', 'data-placeholder' => ' '], 'disabled' => ($index > 1 && !isset($data[$field])) ? true : false, @@ -47,7 +48,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'yesno_button_group', [ 'label' => false, - 'data' => isset($options['data']['update_mautic_company']) ? (bool) $options['data']['update_mautic_company'] : true, + 'data' => isset($options['update_mautic_company'][$field]) ? (bool) $options['update_mautic_company'][$field] : '', 'no_label' => '', 'yes_label' => '', 'empty_value' => false, @@ -58,6 +59,8 @@ public function buildForm(FormBuilderInterface $builder, array $options) $builder->add('m_'.$index, 'choice', [ 'choices' => $options['company_fields'], 'label' => false, + 'required' => true, + 'data' => isset($data[$field]) ? $data[$field] : '', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'field-selector form-control', 'data-placeholder' => ' '], 'disabled' => ($index > 1 && !isset($data[$field])) ? true : false, @@ -70,7 +73,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) */ public function configureOptions(OptionsResolver $resolver) { - $resolver->setRequired(['integration_company_fields', 'company_fields']); + $resolver->setRequired(['integration_company_fields', 'company_fields', 'update_mautic_company']); $resolver->setDefaults( [ 'special_instructions' => '', diff --git a/app/bundles/PluginBundle/Form/Type/FeatureSettingsType.php b/app/bundles/PluginBundle/Form/Type/FeatureSettingsType.php index 8fe3b7d14ba..85ea949a177 100644 --- a/app/bundles/PluginBundle/Form/Type/FeatureSettingsType.php +++ b/app/bundles/PluginBundle/Form/Type/FeatureSettingsType.php @@ -84,7 +84,6 @@ public function buildForm(FormBuilderInterface $builder, array $options) $flattenLeadFields = array_keys($flattenLeadFields); $fieldsIntersection = array_uintersect($integrationFields, $flattenLeadFields, 'strcasecmp'); $enableDataPriority = false; - $this->factory->getLogger()->addError(print_r($formSettings, true)); if (isset($formSettings['enable_data_priority'])) { $enableDataPriority = $formSettings['enable_data_priority']; } @@ -117,6 +116,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'required' => false, 'company_fields' => $companyFields, 'data' => isset($data['companyFields']) && !empty($data['companyFields']) ? $data['companyFields'] : [], + 'update_mautic_company' => isset($data['update_mautic_company']) && !empty($data['update_mautic_company']) ? $data['update_mautic_company'] : [], 'integration_company_fields' => $integrationCompanyFields, 'special_instructions' => $specialInstructions, 'alert_type' => $alertType, From 4e4572c92ce09a8bfda44d1aef072f88e2715699 Mon Sep 17 00:00:00 2001 From: David C Date: Mon, 27 Feb 2017 17:03:54 +0100 Subject: [PATCH 047/510] report export including dyn filter --- app/bundles/ReportBundle/Controller/ReportController.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/bundles/ReportBundle/Controller/ReportController.php b/app/bundles/ReportBundle/Controller/ReportController.php index e9d4b1d2114..4da69bb1b4e 100644 --- a/app/bundles/ReportBundle/Controller/ReportController.php +++ b/app/bundles/ReportBundle/Controller/ReportController.php @@ -783,9 +783,12 @@ public function exportAction($objectId, $format = 'csv') $fromDate = $session->get('mautic.report.date.from', (new \DateTime('-30 days'))->format('Y-m-d')); $toDate = $session->get('mautic.report.date.to', (new \DateTime())->format('Y-m-d')); + $dynamicFilters = $session->get('mautic.report.'.$objectId.'.filters', []); + $reportData = $model->getReportData($entity, null, [ - 'dateFrom' => new \DateTime($fromDate), - 'dateTo' => new \DateTime($toDate), + 'dateFrom' => new \DateTime($fromDate), + 'dateTo' => new \DateTime($toDate), + 'dynamicFilters' => $dynamicFilters, ]); return $model->exportResults($format, $entity, $reportData); From 5f4668237460736f744ab961f753a38010d3749c Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Mon, 27 Feb 2017 19:04:37 +0100 Subject: [PATCH 048/510] fix getSentCounts --- .../NotificationBundle/Entity/StatRepository.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/bundles/NotificationBundle/Entity/StatRepository.php b/app/bundles/NotificationBundle/Entity/StatRepository.php index 77471fd35c3..d2f8559800f 100644 --- a/app/bundles/NotificationBundle/Entity/StatRepository.php +++ b/app/bundles/NotificationBundle/Entity/StatRepository.php @@ -243,20 +243,20 @@ public function getMostNotifications($query, $limit = 10, $offset = 0) public function getSentCounts($notificationIds = [], \DateTime $fromDate = null) { $q = $this->_em->getConnection()->createQueryBuilder(); - $q->select('e.email_id, count(e.id) as sentcount') - ->from(MAUTIC_TABLE_PREFIX.'push_notification_stats', 'e') + $q->select('s.notification_id, count(n.id) as sentcount') + ->from(MAUTIC_TABLE_PREFIX.'push_notification_stats', 's') ->where( - $q->expr()->in('e.notification_id', $notificationIds) + $q->expr()->in('s.notification_id', $notificationIds) ); if ($fromDate !== null) { //make sure the date is UTC $dt = new DateTimeHelper($fromDate); $q->andWhere( - $q->expr()->gte('e.date_read', $q->expr()->literal($dt->toUtcString())) + $q->expr()->gte('s.date_read', $q->expr()->literal($dt->toUtcString())) ); } - $q->groupBy('e.notification_id'); + $q->groupBy('s.notification_id'); //get a total number of sent notifications first $results = $q->execute()->fetchAll(); From eb0d99d1d9de82a23993a07e3cdcab106f446a27 Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Mon, 27 Feb 2017 19:06:24 +0100 Subject: [PATCH 049/510] Add data do CORS request --- .../NotificationBundle/Helper/NotificationHelper.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/bundles/NotificationBundle/Helper/NotificationHelper.php b/app/bundles/NotificationBundle/Helper/NotificationHelper.php index df82d922efc..8e1c261e573 100644 --- a/app/bundles/NotificationBundle/Helper/NotificationHelper.php +++ b/app/bundles/NotificationBundle/Helper/NotificationHelper.php @@ -143,11 +143,9 @@ public function getScript() }]); var postUserIdToMautic = function(userId) { - MauticJS.makeCORSRequest('GET', '{$leadAssociationUrl}?osid=' + userId, {}, function(response, xhr) { - if (response.osid) { - document.cookie = "mtc_osid="+response.osid+"; max-age=" + 60 * 60 * 24; - } - }); + var data = []; + data['osid'] = userId; + MauticJS.makeCORSRequest('GET', '{$leadAssociationUrl}', data); }; OneSignal.push(function() { @@ -199,7 +197,6 @@ private function hasScript(){ $landingPage = true; $server = $this->request->getCurrentRequest()->server; $cookies = $this->request->getCurrentRequest()->cookies; - // already exist if($cookies->get('mtc_osid')){ return false; From 0f0b07387ae8ca51d173c2d28d187b276d41851e Mon Sep 17 00:00:00 2001 From: John Linhart Date: Tue, 28 Feb 2017 08:47:01 +0100 Subject: [PATCH 050/510] An error occured if the page was 0 and not 1. Happened on contact timeline while filtering events. --- app/bundles/LeadBundle/Event/LeadTimelineEvent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/bundles/LeadBundle/Event/LeadTimelineEvent.php b/app/bundles/LeadBundle/Event/LeadTimelineEvent.php index c58d1da1152..bd77806016f 100644 --- a/app/bundles/LeadBundle/Event/LeadTimelineEvent.php +++ b/app/bundles/LeadBundle/Event/LeadTimelineEvent.php @@ -296,7 +296,7 @@ public function getEventLimit() return [ 'leadId' => $this->lead->getId(), 'limit' => $this->limit, - 'start' => (1 === $this->page) ? 0 : ($this->page - 1) * $this->limit, + 'start' => (1 >= $this->page) ? 0 : ($this->page - 1) * $this->limit, ]; } From 0c9d8ebd56d7f70a31d55684f8454ebf3ebdf2d1 Mon Sep 17 00:00:00 2001 From: John Linhart Date: Tue, 28 Feb 2017 12:19:17 +0100 Subject: [PATCH 051/510] trigger_error method works only with E_USER family of constants --- app/bundles/CategoryBundle/Helper/MenuHelper.php | 2 +- app/bundles/CoreBundle/Event/ChannelBroadcastEvent.php | 2 +- app/bundles/CoreBundle/Event/MessageQueueBatchProcessEvent.php | 2 +- app/bundles/CoreBundle/Event/MessageQueueEvent.php | 2 +- app/bundles/CoreBundle/Event/MessageQueueProcessEvent.php | 2 +- app/bundles/EmailBundle/Helper/MailHelper.php | 2 +- app/bundles/LeadBundle/Event/ChannelEvent.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/bundles/CategoryBundle/Helper/MenuHelper.php b/app/bundles/CategoryBundle/Helper/MenuHelper.php index b0eec836275..9441dda3b46 100644 --- a/app/bundles/CategoryBundle/Helper/MenuHelper.php +++ b/app/bundles/CategoryBundle/Helper/MenuHelper.php @@ -26,6 +26,6 @@ class MenuHelper */ public static function addCategoryMenuItems(&$items, $bundleName, CorePermissions $security) { - @trigger_error('Individual category menu items are no longer used.', E_DEPRECATED); + @trigger_error('Individual category menu items are no longer used.', E_USER_DEPRECATED); } } diff --git a/app/bundles/CoreBundle/Event/ChannelBroadcastEvent.php b/app/bundles/CoreBundle/Event/ChannelBroadcastEvent.php index 241941f34fd..86939c07bdb 100644 --- a/app/bundles/CoreBundle/Event/ChannelBroadcastEvent.php +++ b/app/bundles/CoreBundle/Event/ChannelBroadcastEvent.php @@ -11,7 +11,7 @@ namespace Mautic\CoreBundle\Event; -@trigger_error('Mautic\CoreBundle\Event\ChannelBroadcastEvent was deprecated in 2.4 and to be removed in 3.0 Use \Mautic\ChannelBundle\Event\ChannelBroadcastEvent instead', E_DEPRECATED); +@trigger_error('Mautic\CoreBundle\Event\ChannelBroadcastEvent was deprecated in 2.4 and to be removed in 3.0 Use \Mautic\ChannelBundle\Event\ChannelBroadcastEvent instead', E_USER_DEPRECATED); /** * Class ChannelBroadcastEvent. diff --git a/app/bundles/CoreBundle/Event/MessageQueueBatchProcessEvent.php b/app/bundles/CoreBundle/Event/MessageQueueBatchProcessEvent.php index 0571ccaf3d0..f70705b5e4b 100644 --- a/app/bundles/CoreBundle/Event/MessageQueueBatchProcessEvent.php +++ b/app/bundles/CoreBundle/Event/MessageQueueBatchProcessEvent.php @@ -11,7 +11,7 @@ namespace Mautic\CoreBundle\Event; -@trigger_error('Mautic\CoreBundle\Event\MessageQueueBatchProcessEvent was deprecated in 2.4 and to be removed in 3.0 Use \Mautic\ChannelBundle\Event\MessageQueueBatchProcessEvent instead', E_DEPRECATED); +@trigger_error('Mautic\CoreBundle\Event\MessageQueueBatchProcessEvent was deprecated in 2.4 and to be removed in 3.0 Use \Mautic\ChannelBundle\Event\MessageQueueBatchProcessEvent instead', E_USER_DEPRECATED); /** * Class MessageQueueBatchProcessEvent. diff --git a/app/bundles/CoreBundle/Event/MessageQueueEvent.php b/app/bundles/CoreBundle/Event/MessageQueueEvent.php index 0c5c4e5cdba..0228e6ff0d9 100644 --- a/app/bundles/CoreBundle/Event/MessageQueueEvent.php +++ b/app/bundles/CoreBundle/Event/MessageQueueEvent.php @@ -11,7 +11,7 @@ namespace Mautic\CoreBundle\Event; -@trigger_error('Mautic\CoreBundle\Event\MessageQueueEvent was deprecated in 2.4 and to be removed in 3.0 Use \Mautic\ChannelBundle\Event\MessageQueueEvent instead', E_DEPRECATED); +@trigger_error('Mautic\CoreBundle\Event\MessageQueueEvent was deprecated in 2.4 and to be removed in 3.0 Use \Mautic\ChannelBundle\Event\MessageQueueEvent instead', E_USER_DEPRECATED); /** * Class MessageQueueEvent. diff --git a/app/bundles/CoreBundle/Event/MessageQueueProcessEvent.php b/app/bundles/CoreBundle/Event/MessageQueueProcessEvent.php index e06c6f05eec..7fa45e98bc9 100644 --- a/app/bundles/CoreBundle/Event/MessageQueueProcessEvent.php +++ b/app/bundles/CoreBundle/Event/MessageQueueProcessEvent.php @@ -11,7 +11,7 @@ namespace Mautic\CoreBundle\Event; -@trigger_error('Mautic\CoreBundle\Event\MessageQueueProcessEvent was deprecated in 2.4 and to be removed in 3.0 Use \Mautic\ChannelBundle\Event\MessageQueueProcessEvent instead', E_DEPRECATED); +@trigger_error('Mautic\CoreBundle\Event\MessageQueueProcessEvent was deprecated in 2.4 and to be removed in 3.0 Use \Mautic\ChannelBundle\Event\MessageQueueProcessEvent instead', E_USER_DEPRECATED); /** * Class MessageQueueProcessEvent. diff --git a/app/bundles/EmailBundle/Helper/MailHelper.php b/app/bundles/EmailBundle/Helper/MailHelper.php index a19abb8354f..ce092013601 100644 --- a/app/bundles/EmailBundle/Helper/MailHelper.php +++ b/app/bundles/EmailBundle/Helper/MailHelper.php @@ -1475,7 +1475,7 @@ public function parsePlainText($content = null) */ public function useMailerTokenization($tokenizationEnabled = true) { - @trigger_error('useMailerTokenization() is now deprecated. Use enableQueue() instead.', E_DEPRECATED); + @trigger_error('useMailerTokenization() is now deprecated. Use enableQueue() instead.', E_USER_DEPRECATED); $this->enableQueue($tokenizationEnabled); } diff --git a/app/bundles/LeadBundle/Event/ChannelEvent.php b/app/bundles/LeadBundle/Event/ChannelEvent.php index ddfd8e54a6c..b7738993f6a 100644 --- a/app/bundles/LeadBundle/Event/ChannelEvent.php +++ b/app/bundles/LeadBundle/Event/ChannelEvent.php @@ -11,7 +11,7 @@ namespace Mautic\LeadBundle\Event; -@trigger_error('\Mautic\LeadBundle\Event\ChannelEvent was deprecated in 2.4 and to be removed in 3.0 Use \Mautic\ChannelBundle\Event\ChannelEvent instead', E_DEPRECATED); +@trigger_error('\Mautic\LeadBundle\Event\ChannelEvent was deprecated in 2.4 and to be removed in 3.0 Use \Mautic\ChannelBundle\Event\ChannelEvent instead', E_USER_DEPRECATED); /** * Class ChannelEvent. From da784bea83aeae82005a8bb75328a1f9c7877871 Mon Sep 17 00:00:00 2001 From: Arul Raj Date: Tue, 28 Feb 2017 17:15:31 +0530 Subject: [PATCH 052/510] change ondelete to set null in dynamicContentLeadData --- .../DynamicContentBundle/Entity/DynamicContentLeadData.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/bundles/DynamicContentBundle/Entity/DynamicContentLeadData.php b/app/bundles/DynamicContentBundle/Entity/DynamicContentLeadData.php index ebee2f1b11a..83b478fca59 100644 --- a/app/bundles/DynamicContentBundle/Entity/DynamicContentLeadData.php +++ b/app/bundles/DynamicContentBundle/Entity/DynamicContentLeadData.php @@ -66,7 +66,7 @@ public static function loadMetadata(ORM\ClassMetadata $metadata) $builder->createManyToOne('dynamicContent', 'DynamicContent') ->inversedBy('id') - ->addJoinColumn('dynamic_content_id', 'id', true, false, 'CASCADE') + ->addJoinColumn('dynamic_content_id', 'id', true, false, 'SET NULL') ->build(); $builder->createField('slot', 'text') From 36c1b6cf7928760d0604fc1e0ed9c27c36df357f Mon Sep 17 00:00:00 2001 From: Werner Garcia Date: Tue, 28 Feb 2017 08:34:00 -0600 Subject: [PATCH 053/510] Added more properties --- .../CoreBundle/Assets/css/app/less/custom.less | 9 +++++++++ app/bundles/CoreBundle/Assets/js/4.builder.js | 16 ++++++++++++++-- .../Form/Type/SlotImageCaptionType.php | 15 +++++++++++++++ .../CoreBundle/Form/Type/SlotImageCardType.php | 17 ++++++++++++++++- .../CoreBundle/Translations/en_US/messages.ini | 2 ++ .../CoreBundle/Views/Slots/imagecard.html.php | 5 ++++- .../Views/Slots/socialfollow.html.php | 2 +- .../CoreBundle/Views/Slots/socialshare.html.php | 5 ++++- 8 files changed, 65 insertions(+), 6 deletions(-) diff --git a/app/bundles/CoreBundle/Assets/css/app/less/custom.less b/app/bundles/CoreBundle/Assets/css/app/less/custom.less index febd4d76d6d..b6822d53309 100644 --- a/app/bundles/CoreBundle/Assets/css/app/less/custom.less +++ b/app/bundles/CoreBundle/Assets/css/app/less/custom.less @@ -274,3 +274,12 @@ td.col-id, th.col-id { span.slot-caption { font-size: 12px; } +.imagecard-caption, figcaption { + font-size: 16px; +} +.imagecard { + background-color: #ddd !important; +} +.imagecard .imagecard-caption { + background-color: #bbb !important; +} diff --git a/app/bundles/CoreBundle/Assets/js/4.builder.js b/app/bundles/CoreBundle/Assets/js/4.builder.js index 0eb14297cf2..d4a54e1e9fe 100644 --- a/app/bundles/CoreBundle/Assets/js/4.builder.js +++ b/app/bundles/CoreBundle/Assets/js/4.builder.js @@ -841,7 +841,7 @@ Mautic.initSlotListeners = function() { }); // Initialize different slot types - if (type === 'image') { + if (type === 'image' || type === 'imagecaption') { var image = mQuery(this).find('img'); // fix of badly destroyed image slot image.removeAttr('data-froala.editor'); @@ -899,7 +899,17 @@ Mautic.initSlotListeners = function() { } else if (fieldParam === 'float') { var values = ['left', 'center', 'right']; params.slot.find('a').parent().attr('align', values[params.field.val()]); - } else if (fieldParam === 'imgalign') { + } else if (fieldParam === 'caption') { + params.slot.find('figcaption').text(params.field.val()); + } else if (fieldParam === 'cardcaption') { + params.slot.find('td.imagecard-caption').text(params.field.val()); + } else if (fieldParam === 'imgalign' && type === 'imagecaption') { + var values = ['left', 'center', 'right']; + params.slot.find('figure').css('text-align', values[params.field.val()]); + } else if (fieldParam === 'imgalign' && type === 'imagecard') { + var values = ['left', 'center', 'right']; + params.slot.find('table.imagecard').attr('align', values[params.field.val()]); + } else if (fieldParam === 'imgalign' && type === 'image') { Mautic.builderContents.find('[data-slot-focus]').each( function() { var focusedSlot = mQuery(this).closest('[data-slot]'); if (focusedSlot.attr('data-slot') == 'image') { @@ -930,6 +940,8 @@ Mautic.initSlotListeners = function() { if (params.type == 'text') { Mautic.setTextSlotEditorStyle(parent.mQuery('#slot_text_content'), params.slot); } + + event.stopPropagation(); }); Mautic.builderContents.on('slot:destroy', function(event, params) { diff --git a/app/bundles/CoreBundle/Form/Type/SlotImageCaptionType.php b/app/bundles/CoreBundle/Form/Type/SlotImageCaptionType.php index ed71892ce81..7d17f1a9d45 100644 --- a/app/bundles/CoreBundle/Form/Type/SlotImageCaptionType.php +++ b/app/bundles/CoreBundle/Form/Type/SlotImageCaptionType.php @@ -12,6 +12,7 @@ namespace Mautic\CoreBundle\Form\Type; use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList; +use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; /** @@ -25,6 +26,20 @@ class SlotImageCaptionType extends SlotType */ public function buildForm(FormBuilderInterface $builder, array $options) { + $builder->add( + 'caption', + TextType::class, + [ + 'label' => 'mautic.core.image.caption', + 'label_attr' => ['class' => 'control-label'], + 'required' => false, + 'attr' => [ + 'class' => 'form-control', + 'data-slot-param' => 'caption', + ], + ] + ); + $builder->add('imagecaption_align', 'button_group', [ 'label' => 'mautic.core.image.position', 'label_attr' => ['class' => 'control-label'], diff --git a/app/bundles/CoreBundle/Form/Type/SlotImageCardType.php b/app/bundles/CoreBundle/Form/Type/SlotImageCardType.php index c4c90ae535f..c2b36f1f9f1 100644 --- a/app/bundles/CoreBundle/Form/Type/SlotImageCardType.php +++ b/app/bundles/CoreBundle/Form/Type/SlotImageCardType.php @@ -12,6 +12,7 @@ namespace Mautic\CoreBundle\Form\Type; use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList; +use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; /** @@ -25,7 +26,19 @@ class SlotImageCardType extends SlotType */ public function buildForm(FormBuilderInterface $builder, array $options) { - parent::buildForm($builder, $options); + $builder->add( + 'cardcaption', + TextType::class, + [ + 'label' => 'mautic.core.image.caption', + 'label_attr' => ['class' => 'control-label'], + 'required' => false, + 'attr' => [ + 'class' => 'form-control', + 'data-slot-param' => 'cardcaption', + ], + ] + ); $builder->add('imagecard_align', 'button_group', [ 'label' => 'mautic.core.image.position', @@ -40,6 +53,8 @@ public function buildForm(FormBuilderInterface $builder, array $options) ['mautic.core.left', 'mautic.core.center', 'mautic.core.right'] ), ]); + + parent::buildForm($builder, $options); } /** diff --git a/app/bundles/CoreBundle/Translations/en_US/messages.ini b/app/bundles/CoreBundle/Translations/en_US/messages.ini index 3014d87fed0..861a225644a 100644 --- a/app/bundles/CoreBundle/Translations/en_US/messages.ini +++ b/app/bundles/CoreBundle/Translations/en_US/messages.ini @@ -445,6 +445,8 @@ mautic.core.button.text="Button Text" mautic.core.button.link="Button Link" mautic.core.button.size="Button Size" mautic.core.button.position="Button Position" +mautic.core.image.position="Image Position" +mautic.core.image.caption="Image Caption" mautic.core.background.color="Background Color" mautic.core.content.background.color="Content Background Color" mautic.core.continue="Continue" diff --git a/app/bundles/CoreBundle/Views/Slots/imagecard.html.php b/app/bundles/CoreBundle/Views/Slots/imagecard.html.php index a737c52262a..2de99399950 100644 --- a/app/bundles/CoreBundle/Views/Slots/imagecard.html.php +++ b/app/bundles/CoreBundle/Views/Slots/imagecard.html.php @@ -10,5 +10,8 @@ */ ?> -An image + + + +
    An image
    Caption goes here
    diff --git a/app/bundles/CoreBundle/Views/Slots/socialfollow.html.php b/app/bundles/CoreBundle/Views/Slots/socialfollow.html.php index a53baed4a14..2fbe76da4c1 100644 --- a/app/bundles/CoreBundle/Views/Slots/socialfollow.html.php +++ b/app/bundles/CoreBundle/Views/Slots/socialfollow.html.php @@ -10,4 +10,4 @@ */ ?> -Insert text here +google+facebooktwitter diff --git a/app/bundles/CoreBundle/Views/Slots/socialshare.html.php b/app/bundles/CoreBundle/Views/Slots/socialshare.html.php index a53baed4a14..3089a5fa06f 100644 --- a/app/bundles/CoreBundle/Views/Slots/socialshare.html.php +++ b/app/bundles/CoreBundle/Views/Slots/socialshare.html.php @@ -10,4 +10,7 @@ */ ?> -Insert text here + +
    + trans('mautic.page.token.share'); ?> +
    \ No newline at end of file From c1fb67f9b4d1a12d222f9a67c4a22214d187d395 Mon Sep 17 00:00:00 2001 From: Marianela Queme Date: Tue, 28 Feb 2017 17:32:14 +0000 Subject: [PATCH 054/510] fixed BC field mapping --- .../PluginBundle/Form/Type/FieldsType.php | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/app/bundles/PluginBundle/Form/Type/FieldsType.php b/app/bundles/PluginBundle/Form/Type/FieldsType.php index 309ef77df71..75aa58b4da3 100644 --- a/app/bundles/PluginBundle/Form/Type/FieldsType.php +++ b/app/bundles/PluginBundle/Form/Type/FieldsType.php @@ -28,20 +28,23 @@ class FieldsType extends AbstractType */ public function buildForm(FormBuilderInterface $builder, array $options) { - $index = 0; - $integrationFields = array_combine(array_keys($options['integration_fields']), array_keys($options['integration_fields'])); - $data = isset($options['data']) ? $options['data'] : []; - $integrationFieldsOrdered = array_merge($data, $integrationFields); + $index = 0; + $integrationFields = array_combine(array_keys($options['integration_fields']), array_keys($options['integration_fields'])); + $data = isset($options['data']) ? $options['data'] : []; + foreach ($data as $key => $field) { + $fieldData[str_replace('__', ' - ', $key)] = $field; + } + $integrationFieldsOrdered = array_merge($fieldData, $integrationFields); foreach ($integrationFieldsOrdered as $field => $details) { ++$index; $builder->add('i_'.$index, 'choice', [ - 'choices' => $integrationFields, + 'choices' => $integrationFieldsOrdered, 'label' => false, 'required' => true, - 'data' => isset($data[$field]) ? $field : '', + 'data' => isset($fieldData[$field]) ? $field : '', 'attr' => ['class' => 'field-selector form-control', 'data-placeholder' => ' '], - 'disabled' => ($index > 1 && !isset($data[$field])) ? true : false, + 'disabled' => ($index > 1 && !isset($fieldData[$field])) ? true : false, ]); if (isset($options['enable_data_priority']) and $options['enable_data_priority']) { $builder->add('update_mautic'.$index, @@ -53,17 +56,17 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'yes_label' => '', 'empty_value' => false, 'attr' => ['data-toggle' => 'tooltip', 'title' => 'mautic.plugin.direction.data.update'], - 'disabled' => ($index > 1 && !isset($data[$field])) ? true : false, + 'disabled' => ($index > 1 && !isset($fieldData[$field])) ? true : false, ]); } $builder->add('m_'.$index, 'choice', [ 'choices' => $options['lead_fields'], 'label' => false, 'required' => true, - 'data' => isset($data[$field]) ? $data[$field] : '', + 'data' => isset($fieldData[$field]) ? $fieldData[$field] : '', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'field-selector form-control', 'data-placeholder' => ' '], - 'disabled' => ($index > 1 && !isset($data[$field])) ? true : false, + 'disabled' => ($index > 1 && !isset($fieldData[$field])) ? true : false, ]); } } From 78e64ea037fec4115b1d54d9338c7437551272ee Mon Sep 17 00:00:00 2001 From: Marianela Queme Date: Tue, 28 Feb 2017 17:39:53 +0000 Subject: [PATCH 055/510] fixed issue with not declaring queryUrl properly --- plugins/MauticCrmBundle/Api/SalesforceApi.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/MauticCrmBundle/Api/SalesforceApi.php b/plugins/MauticCrmBundle/Api/SalesforceApi.php index d2adf9a0933..58e9b981a1b 100644 --- a/plugins/MauticCrmBundle/Api/SalesforceApi.php +++ b/plugins/MauticCrmBundle/Api/SalesforceApi.php @@ -234,10 +234,8 @@ public function createLeadActivity(array $activity, $object) public function getLeads($query, $object) { $organizationCreatedDate = $this->getOrganizationCreatedDate(); - + $queryUrl = $this->integration->getQueryUrl(); if (isset($query['start'])) { - $queryUrl = $this->integration->getQueryUrl(); - if (strtotime($query['start']) < strtotime($organizationCreatedDate)) { $query['start'] = date('c', strtotime($organizationCreatedDate.' +1 hour')); } From 5fa36762ed322119f32235054a998fd7eb8e5e5d Mon Sep 17 00:00:00 2001 From: Werner Garcia Date: Tue, 28 Feb 2017 12:26:59 -0600 Subject: [PATCH 056/510] Fixed slot properties --- app/bundles/CoreBundle/Assets/js/4.builder.js | 86 ++++++++++++++++++- .../CoreBundle/Views/Slots/codemode.html.php | 4 +- .../Views/Slots/imagecaption.html.php | 4 +- .../CoreBundle/Views/Slots/imagecard.html.php | 4 +- .../Views/Slots/socialfollow.html.php | 8 +- .../EventListener/BuilderSubscriber.php | 42 ++++++++- 6 files changed, 140 insertions(+), 8 deletions(-) diff --git a/app/bundles/CoreBundle/Assets/js/4.builder.js b/app/bundles/CoreBundle/Assets/js/4.builder.js index d4a54e1e9fe..45a8263c5ad 100644 --- a/app/bundles/CoreBundle/Assets/js/4.builder.js +++ b/app/bundles/CoreBundle/Assets/js/4.builder.js @@ -2,6 +2,7 @@ * Launch builder * * @param formName + * @param actionName */ Mautic.launchBuilder = function (formName, actionName) { Mautic.codeMode = mQuery('.builder').hasClass('code-mode'); @@ -83,6 +84,86 @@ Mautic.launchBuilder = function (formName, actionName) { }); }; +/** + * Launch builder + * + */ +Mautic.launchBuilderSlot = function (slot) { + Mautic.codeMode = mQuery('.builder').hasClass('code-mode'); + Mautic.showChangeThemeWarning = true; + + mQuery('slotbody').css('overflow-y', 'hidden'); + + // Activate the builder + mQuery('.builder').addClass('builder-active').removeClass('hide'); + + var builderCss = { + margin: "0", + padding: "0", + border: "none", + width: "100%", + height: "100%" + }; + + // Load the theme from the custom HTML textarea + var themeHtml = mQuery(slot).html(); + + if (Mautic.codeMode) { + var rawTokens = mQuery.map(Mautic.builderTokens, function (element, index) { + return index + }).sort(); + Mautic.builderCodeMirror = CodeMirror(document.getElementById('customHtmlContainer'), { + value: themeHtml, + lineNumbers: true, + mode: 'htmlmixed', + extraKeys: {"Ctrl-Space": "autocomplete"}, + lineWrapping: true, + hintOptions: { + hint: function (editor) { + var cursor = editor.getCursor(); + var currentLine = editor.getLine(cursor.line); + var start = cursor.ch; + var end = start; + while (end < currentLine.length && /[\w|}$]+/.test(currentLine.charAt(end))) ++end; + while (start && /[\w|{$]+/.test(currentLine.charAt(start - 1))) --start; + var curWord = start != end && currentLine.slice(start, end); + var regex = new RegExp('^' + curWord, 'i'); + var result = { + list: (!curWord ? rawTokens : mQuery(rawTokens).filter(function(idx) { + return (rawTokens[idx].indexOf(curWord) !== -1); + })), + from: CodeMirror.Pos(cursor.line, start), + to: CodeMirror.Pos(cursor.line, end) + }; + + return result; + } + } + }); + + Mautic.keepPreviewAlive('builder-template-content'); + } + + var panelHeight = (mQuery('.builder-content').css('right') == '0px') ? mQuery('.builder-panel').height() : 0, + panelWidth = (mQuery('.builder-content').css('right') == '0px') ? 0 : mQuery('.builder-panel').width(), + spinnerLeft = (mQuery(window).width() - panelWidth - 60) / 2, + spinnerTop = (mQuery(window).height() - panelHeight - 60) / 2; + + var overlay = mQuery('').css(builderCss).appendTo('.builder-content'); + + // Disable the close button until everything is loaded + mQuery('.btn-close-builder').prop('disabled', true); + + // Insert the Mautic assets to the header + var assets = Mautic.htmlspecialchars_decode(mQuery('[data-builder-assets]').html()); + themeHtml = themeHtml.replace('', assets+''); + + Mautic.buildBuilderIframe(themeHtml, 'builder-template-content', function() { + mQuery('#builder-overlay').addClass('hide'); + mQuery('.btn-close-builder').prop('disabled', false); + }); +}; + /** * Frmats code style in the CodeMirror editor */ @@ -841,7 +922,7 @@ Mautic.initSlotListeners = function() { }); // Initialize different slot types - if (type === 'image' || type === 'imagecaption') { + if (type === 'image' || type === 'imagecaption' || type === 'imagecard') { var image = mQuery(this).find('img'); // fix of badly destroyed image slot image.removeAttr('data-froala.editor'); @@ -860,6 +941,8 @@ Mautic.initSlotListeners = function() { mQuery(this).find('a').click(function(e) { e.preventDefault(); }); + } else if (type === 'codemode') { + Mautic.launchBuilderSlot(this); } // Store the slot to a global var @@ -890,6 +973,7 @@ Mautic.initSlotListeners = function() { Mautic.builderContents.on('slot:change', function(event, params) { // Change some slot styles when the values are changed in the slot edit form var fieldParam = params.field.attr('data-slot-param'); + var type = params.type; if (fieldParam === 'padding-top' || fieldParam === 'padding-bottom') { params.slot.css(fieldParam, params.field.val() + 'px'); } else if (fieldParam === 'href') { diff --git a/app/bundles/CoreBundle/Views/Slots/codemode.html.php b/app/bundles/CoreBundle/Views/Slots/codemode.html.php index a53baed4a14..98ac021556c 100644 --- a/app/bundles/CoreBundle/Views/Slots/codemode.html.php +++ b/app/bundles/CoreBundle/Views/Slots/codemode.html.php @@ -9,5 +9,7 @@ * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ ?> - +
    Insert text here +
    + diff --git a/app/bundles/CoreBundle/Views/Slots/imagecaption.html.php b/app/bundles/CoreBundle/Views/Slots/imagecaption.html.php index a446c1ffd4a..07c251ebc5a 100644 --- a/app/bundles/CoreBundle/Views/Slots/imagecaption.html.php +++ b/app/bundles/CoreBundle/Views/Slots/imagecaption.html.php @@ -10,7 +10,7 @@ */ ?>
    - An image -
    Caption goes here
    + An image +
    Your image caption goes here. You can change the position of the caption and style in the customize slot tab.
    diff --git a/app/bundles/CoreBundle/Views/Slots/imagecard.html.php b/app/bundles/CoreBundle/Views/Slots/imagecard.html.php index 2de99399950..8ba0e9b9d9b 100644 --- a/app/bundles/CoreBundle/Views/Slots/imagecard.html.php +++ b/app/bundles/CoreBundle/Views/Slots/imagecard.html.php @@ -11,7 +11,7 @@ ?> - - + +
    An image
    Caption goes here
    An image
    Your image caption goes here. You can change the position of the caption and style in the customize slot tab.
    diff --git a/app/bundles/CoreBundle/Views/Slots/socialfollow.html.php b/app/bundles/CoreBundle/Views/Slots/socialfollow.html.php index 2fbe76da4c1..545015038f7 100644 --- a/app/bundles/CoreBundle/Views/Slots/socialfollow.html.php +++ b/app/bundles/CoreBundle/Views/Slots/socialfollow.html.php @@ -10,4 +10,10 @@ */ ?> -google+facebooktwitter +google+ +facebook +twitter + diff --git a/app/bundles/EmailBundle/EventListener/BuilderSubscriber.php b/app/bundles/EmailBundle/EventListener/BuilderSubscriber.php index 14d03aff225..e2091899102 100644 --- a/app/bundles/EmailBundle/EventListener/BuilderSubscriber.php +++ b/app/bundles/EmailBundle/EventListener/BuilderSubscriber.php @@ -151,6 +151,22 @@ public function onEmailBuild(EmailBuilderEvent $event) 'slot', 900 ); + $event->addSlotType( + 'imagecard', + 'Image Card', + 'id-card-o', + 'MauticCoreBundle:Slots:imagecard.html.php', + 'slot_imagecard', + 870 + ); + $event->addSlotType( + 'imagecaption', + 'Image+Caption', + 'image', + 'MauticCoreBundle:Slots:imagecaption.html.php', + 'slot_imagecaption', + 850 + ); $event->addSlotType( 'button', 'Button', @@ -159,13 +175,37 @@ public function onEmailBuild(EmailBuilderEvent $event) 'slot_button', 800 ); + $event->addSlotType( + 'socialshare', + 'Social Share', + 'share-alt', + 'MauticCoreBundle:Slots:socialshare.html.php', + 'slot', + 700 + ); + $event->addSlotType( + 'socialfollow', + 'Social Follow', + 'twitter', + 'MauticCoreBundle:Slots:socialfollow.html.php', + 'slot', + 600 + ); + $event->addSlotType( + 'codemode', + 'Code Mode', + 'code', + 'MauticCoreBundle:Slots:codemode.html.php', + 'slot', + 500 + ); $event->addSlotType( 'separator', 'Separator', 'minus', 'MauticCoreBundle:Slots:separator.html.php', 'slot', - 700 + 400 ); } } From 0f2cc4db2cde366aed926ab4c2b1c17805bb2d04 Mon Sep 17 00:00:00 2001 From: Marianela Queme Date: Tue, 28 Feb 2017 18:36:45 +0000 Subject: [PATCH 057/510] fixing field matching --- app/bundles/PluginBundle/Form/Type/FieldsType.php | 9 +++------ plugins/MauticCrmBundle/Api/SalesforceApi.php | 12 +++++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/bundles/PluginBundle/Form/Type/FieldsType.php b/app/bundles/PluginBundle/Form/Type/FieldsType.php index 75aa58b4da3..df4ce36102d 100644 --- a/app/bundles/PluginBundle/Form/Type/FieldsType.php +++ b/app/bundles/PluginBundle/Form/Type/FieldsType.php @@ -28,12 +28,9 @@ class FieldsType extends AbstractType */ public function buildForm(FormBuilderInterface $builder, array $options) { - $index = 0; - $integrationFields = array_combine(array_keys($options['integration_fields']), array_keys($options['integration_fields'])); - $data = isset($options['data']) ? $options['data'] : []; - foreach ($data as $key => $field) { - $fieldData[str_replace('__', ' - ', $key)] = $field; - } + $index = 0; + $integrationFields = array_combine(str_replace(' - ', '__', array_keys($options['integration_fields'])), array_keys($options['integration_fields'])); + $fieldData = isset($options['data']) ? $options['data'] : []; $integrationFieldsOrdered = array_merge($fieldData, $integrationFields); foreach ($integrationFieldsOrdered as $field => $details) { diff --git a/plugins/MauticCrmBundle/Api/SalesforceApi.php b/plugins/MauticCrmBundle/Api/SalesforceApi.php index 58e9b981a1b..a5aa77476b5 100644 --- a/plugins/MauticCrmBundle/Api/SalesforceApi.php +++ b/plugins/MauticCrmBundle/Api/SalesforceApi.php @@ -245,13 +245,15 @@ public function getLeads($query, $object) switch ($object) { case 'company': case 'Account': - $companyFieldsToUpdateInMautic = isset($fields['update_mautic_company']) ? array_keys($fields['update_mautic_company'], 0) : []; - $fields = array_keys(array_filter(array_diff_key($fields['companyFields'], $companyFieldsToUpdateInMautic))); + // $companyFieldsToUpdateInMautic = isset($fields['update_mautic_company']) ? array_keys($fields['update_mautic_company'], 0) : []; + // $fields = array_keys(array_filter(array_diff_key($fields['companyFields'], $companyFieldsToUpdateInMautic))); + $fields = array_keys(array_filter($fields['companyFields'])); break; default: - $fieldsToUpdateInMautic = isset($fields['update_mautic']) ? array_keys($fields['update_mautic'], 0) : []; - $mixedFields = array_filter(array_diff_key($fields['leadFields'], $fieldsToUpdateInMautic)); - $fields = []; + // $fieldsToUpdateInMautic = isset($fields['update_mautic']) ? array_keys($fields['update_mautic'], 0) : []; + // $mixedFields = array_filter(array_diff_key($fields['leadFields'], $fieldsToUpdateInMautic)); + $mixedFields = array_filter($fields['leadFields']); + $fields = []; foreach ($mixedFields as $sfField => $mField) { if (strpos($sfField, '__'.$object) !== false) { $fields[] = str_replace('__'.$object, '', $sfField); From 57e7a0a271b736624e4c04441bb227cebffcf412 Mon Sep 17 00:00:00 2001 From: Marianela Queme Date: Tue, 28 Feb 2017 19:35:16 +0000 Subject: [PATCH 058/510] =?UTF-8?q?changed=20how=20legacy=20fields=20are?= =?UTF-8?q?=20matched=C2=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Integration/CrmAbstractIntegration.php | 7 +++++++ .../Integration/SalesforceIntegration.php | 10 +++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/plugins/MauticCrmBundle/Integration/CrmAbstractIntegration.php b/plugins/MauticCrmBundle/Integration/CrmAbstractIntegration.php index 850d6050238..cb9b5f19ef0 100644 --- a/plugins/MauticCrmBundle/Integration/CrmAbstractIntegration.php +++ b/plugins/MauticCrmBundle/Integration/CrmAbstractIntegration.php @@ -214,6 +214,10 @@ public function getMauticCompany($data, $persist = true, $identifiers = null) // Match that data with mapped lead fields $matchedFields = $this->populateMauticLeadData($data, $config, 'company'); + $fieldsToUpdateInMautic = isset($config['update_mautic_company']) ? array_keys($config['update_mautic_company'], 0) : []; + $fieldsToUpdateInMautic = array_diff_key($config['companyFields'], array_flip($fieldsToUpdateInMautic)); + $matchedFields = array_filter(array_diff_key($matchedFields, array_flip($fieldsToUpdateInMautic))); + if (!isset($matchedFields['companyname'])) { if (isset($matchedFields['companywebsite'])) { $matchedFields['companyname'] = $matchedFields['companywebsite']; @@ -296,6 +300,9 @@ public function getMauticLead($data, $persist = true, $socialCache = null, $iden $lead = array_shift($existingLeads); } } + $fieldsToUpdateInMautic = isset($config['update_mautic']) ? array_keys($config['update_mautic'], 0) : []; + $fieldsToUpdateInMautic = array_diff_key($config['leadFields'], array_flip($fieldsToUpdateInMautic)); + $matchedFields = array_filter(array_diff_key($matchedFields, array_flip($fieldsToUpdateInMautic))); $leadModel->setFieldValues($lead, $matchedFields, false, false); if (!empty($socialCache)) { diff --git a/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php b/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php index 0abefd458d3..e598203737d 100644 --- a/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php +++ b/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php @@ -939,7 +939,7 @@ public function pushLeads($params = []) $integrationEntityRepo = $this->em->getRepository('MauticPluginBundle:IntegrationEntity'); $mauticData = []; $fieldsToUpdateInSf = array_keys($config['update_mautic'], 1); - $fields = implode(', l.', array_diff_key($config['leadFields'], $fieldsToUpdateInSf)); + $fields = implode(', l.', array_diff_key($config['leadFields'], array_flip($fieldsToUpdateInSf))); $fields = 'l.'.$fields; $result = 0; //update lead/contact records @@ -947,7 +947,9 @@ public function pushLeads($params = []) foreach ($leadsToUpdate as $lead) { //use a composite patch here that can update and create (one query) every 200 records foreach ($config['leadFields'] as $sfField => $mauticField) { - $body[$sfField] = $lead[$mauticField]; + if (isset($lead[$mauticField])) { + $body[$sfField] = $lead[$mauticField]; + } } $mauticData[] = [ 'method' => 'PATCH', @@ -962,7 +964,9 @@ public function pushLeads($params = []) foreach ($leadsToCreate as $lead) { //use a composite patch here that can update and create (one query) every 200 records foreach ($config['leadFields'] as $sfField => $mauticField) { - $body[$sfField] = $lead[$mauticField]; + if (isset($lead[$mauticField])) { + $body[$sfField] = $lead[$mauticField]; + } } $mauticData[] = [ 'method' => 'POST', From cafa039f52805cd861712992b4a017799e114f2c Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Wed, 1 Mar 2017 01:49:28 +0100 Subject: [PATCH 059/510] Typo fix --- app/bundles/LeadBundle/Entity/LeadListRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/bundles/LeadBundle/Entity/LeadListRepository.php b/app/bundles/LeadBundle/Entity/LeadListRepository.php index 3edbe84aef5..5d04df36bbc 100644 --- a/app/bundles/LeadBundle/Entity/LeadListRepository.php +++ b/app/bundles/LeadBundle/Entity/LeadListRepository.php @@ -1069,7 +1069,7 @@ public function getListFilterExpr($filters, &$parameters, QueryBuilder $q, $not $groupExpr->add(sprintf('%s (%s)', $operand, $subqb->getSQL())); break; case 'hit_url_count': - case 'lead_email_received_count': + case 'lead_email_read_count': $operand = 'EXISTS'; $column = $details['field']; $table = 'page_hits'; From 594a5b1fae09a647722bddacc95d3097197b6de8 Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Wed, 1 Mar 2017 01:50:24 +0100 Subject: [PATCH 060/510] Minor again :( --- app/bundles/LeadBundle/Entity/LeadListRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/bundles/LeadBundle/Entity/LeadListRepository.php b/app/bundles/LeadBundle/Entity/LeadListRepository.php index 5d04df36bbc..da44847905b 100644 --- a/app/bundles/LeadBundle/Entity/LeadListRepository.php +++ b/app/bundles/LeadBundle/Entity/LeadListRepository.php @@ -1074,7 +1074,7 @@ public function getListFilterExpr($filters, &$parameters, QueryBuilder $q, $not $column = $details['field']; $table = 'page_hits'; $select = 'COUNT(id)'; - if ($details['field'] == 'lead_email_received_count') { + if ($details['field'] == 'lead_email_read_count') { $table = 'email_stats'; $select = 'SUM(open_count)'; } From 8d0f73d69285656f5e0780ddf068e2d8ff76695b Mon Sep 17 00:00:00 2001 From: Zdeno Kuzmany Date: Wed, 1 Mar 2017 01:59:25 +0100 Subject: [PATCH 061/510] Fix timeline if action is failed --- .../Views/SubscribedEvents/Timeline/index.html.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/bundles/NotificationBundle/Views/SubscribedEvents/Timeline/index.html.php b/app/bundles/NotificationBundle/Views/SubscribedEvents/Timeline/index.html.php index d8201c2196a..9b0be91d5b9 100644 --- a/app/bundles/NotificationBundle/Views/SubscribedEvents/Timeline/index.html.php +++ b/app/bundles/NotificationBundle/Views/SubscribedEvents/Timeline/index.html.php @@ -9,7 +9,9 @@ * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ $data = $event['extra']['log']['metadata']; - +if (isset($data['failed'])) { + return; +} ?>
    From e3e3426560cc26f3629f9f12a495da681e9b5e39 Mon Sep 17 00:00:00 2001 From: Marianela Queme Date: Wed, 1 Mar 2017 10:29:06 +0000 Subject: [PATCH 062/510] changed arrow buttons and made spinner class not to be added --- app/bundles/CoreBundle/Assets/js/1.core.js | 3 ++- app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php | 5 ++--- app/bundles/PluginBundle/Form/Type/FieldsType.php | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/bundles/CoreBundle/Assets/js/1.core.js b/app/bundles/CoreBundle/Assets/js/1.core.js index ca3cdde9132..1b6857fd354 100644 --- a/app/bundles/CoreBundle/Assets/js/1.core.js +++ b/app/bundles/CoreBundle/Assets/js/1.core.js @@ -394,10 +394,11 @@ var Mautic = { if (mQuery(target).length) { var hasBtn = mQuery(target).hasClass('btn'); var hasIcon = mQuery(target).hasClass('fa'); + var dontspin = mQuery(target).hasClass('btn-nospin'); var i = (hasBtn && mQuery(target).find('i.fa').length) ? mQuery(target).find('i.fa') : target; - if ((hasBtn && mQuery(target).find('i.fa').length) || hasIcon) { + if (!dontspin && ((hasBtn && mQuery(target).find('i.fa').length) || hasIcon)) { var el = (hasIcon) ? target : mQuery(target).find('i.fa').first(); var identifierClass = (new Date).getTime(); MauticVars.iconClasses[identifierClass] = mQuery(el).attr('class'); diff --git a/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php b/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php index 4dd85786963..21a0399edbb 100644 --- a/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php +++ b/app/bundles/PluginBundle/Form/Type/CompanyFieldsType.php @@ -45,12 +45,11 @@ public function buildForm(FormBuilderInterface $builder, array $options) ]); if (isset($options['enable_data_priority']) and $options['enable_data_priority']) { $builder->add('update_mautic_company'.$index, - 'yesno_button_group', + 'button_group', [ + 'choices' => ['', ''], 'label' => false, 'data' => isset($options['update_mautic_company'][$field]) ? (bool) $options['update_mautic_company'][$field] : '', - 'no_label' => '', - 'yes_label' => '', 'empty_value' => false, 'attr' => ['data-toggle' => 'tooltip', 'title' => 'mautic.plugin.direction.data.update'], 'disabled' => ($index > 1 && !isset($data[$field])) ? true : false, diff --git a/app/bundles/PluginBundle/Form/Type/FieldsType.php b/app/bundles/PluginBundle/Form/Type/FieldsType.php index df4ce36102d..80263ecbe52 100644 --- a/app/bundles/PluginBundle/Form/Type/FieldsType.php +++ b/app/bundles/PluginBundle/Form/Type/FieldsType.php @@ -45,12 +45,11 @@ public function buildForm(FormBuilderInterface $builder, array $options) ]); if (isset($options['enable_data_priority']) and $options['enable_data_priority']) { $builder->add('update_mautic'.$index, - 'yesno_button_group', + 'button_group', [ + 'choices' => ['', ''], 'label' => false, 'data' => isset($options['update_mautic'][$field]) ? (bool) $options['update_mautic'][$field] : '', - 'no_label' => '', - 'yes_label' => '', 'empty_value' => false, 'attr' => ['data-toggle' => 'tooltip', 'title' => 'mautic.plugin.direction.data.update'], 'disabled' => ($index > 1 && !isset($fieldData[$field])) ? true : false, From a74ab5efabd697c5c0eb1faa293ff8b23a2f99b8 Mon Sep 17 00:00:00 2001 From: Marianela Queme Date: Wed, 1 Mar 2017 10:31:30 +0000 Subject: [PATCH 063/510] removed debugger leftover --- app/bundles/PluginBundle/Controller/PluginController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/bundles/PluginBundle/Controller/PluginController.php b/app/bundles/PluginBundle/Controller/PluginController.php index 9e4384e9d07..ba7ef67e596 100644 --- a/app/bundles/PluginBundle/Controller/PluginController.php +++ b/app/bundles/PluginBundle/Controller/PluginController.php @@ -241,7 +241,6 @@ public function configAction($name) } } } - $this->factory->getLogger()->addError(print_r($featureSettings, true)); $entity->setFeatureSettings($featureSettings); } } else { From a1df973958f69bf20f785e395347b4d4ced95406 Mon Sep 17 00:00:00 2001 From: Marianela Queme Date: Wed, 1 Mar 2017 10:34:45 +0000 Subject: [PATCH 064/510] cleaned up some code --- ...ration_details_featureSettings_leadFields_row.html.php | 8 ++++---- .../Integration/integration_company_fields_row.html.php | 8 ++++---- plugins/MauticCrmBundle/Api/SalesforceApi.php | 4 ---- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php b/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php index 824d95e987c..b71df3f67ee 100644 --- a/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php +++ b/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php @@ -34,13 +34,13 @@ } ?>"> -
    pl-xs pr-xs col-sm- pl-xs pr-xs col-sm-"> +endif; ?>"> row($child); ?>
    "> -
    pl-xs pr-xs col-sm- pl-xs pr-xs col-sm-"> +endif; ?>"> row($child); ?>
    $mField) { From ada7b0e8e726ef0d4591035b55174fd857bb649e Mon Sep 17 00:00:00 2001 From: Werner Garcia Date: Wed, 1 Mar 2017 05:51:19 -0600 Subject: [PATCH 065/510] fixed bug when changing properties --- app/bundles/CoreBundle/Views/Slots/imagecaption.html.php | 4 ++-- app/bundles/CoreBundle/Views/Slots/imagecard.html.php | 2 +- app/bundles/PageBundle/Controller/AjaxController.php | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/bundles/CoreBundle/Views/Slots/imagecaption.html.php b/app/bundles/CoreBundle/Views/Slots/imagecaption.html.php index 07c251ebc5a..551683cef69 100644 --- a/app/bundles/CoreBundle/Views/Slots/imagecaption.html.php +++ b/app/bundles/CoreBundle/Views/Slots/imagecaption.html.php @@ -9,8 +9,8 @@ * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ ?> -
    +
    An image -
    Your image caption goes here. You can change the position of the caption and style in the customize slot tab.
    +
    Your image caption goes here. You can change the position of the caption and style in the customize slot tab.
    diff --git a/app/bundles/CoreBundle/Views/Slots/imagecard.html.php b/app/bundles/CoreBundle/Views/Slots/imagecard.html.php index 8ba0e9b9d9b..1d9f811312f 100644 --- a/app/bundles/CoreBundle/Views/Slots/imagecard.html.php +++ b/app/bundles/CoreBundle/Views/Slots/imagecard.html.php @@ -12,6 +12,6 @@ - +
    An image
    Your image caption goes here. You can change the position of the caption and style in the customize slot tab.
    Your image caption goes here. You can change the position of the caption and style in the customize slot tab.
    diff --git a/app/bundles/PageBundle/Controller/AjaxController.php b/app/bundles/PageBundle/Controller/AjaxController.php index cf7c093100a..adff8c72b47 100644 --- a/app/bundles/PageBundle/Controller/AjaxController.php +++ b/app/bundles/PageBundle/Controller/AjaxController.php @@ -119,7 +119,6 @@ protected function getBuilderTokens($query) /** @var \Mautic\PageBundle\Model\PageModel $model */ $model = $this->getModel('page'); - // $requestedComponents must be an array so ajax calls can properly manage responses return $model->getBuilderComponents(null, ['tokens'], $query); } } From 7ab67cb395d34e7fb457fe03b605404dd7078711 Mon Sep 17 00:00:00 2001 From: Marianela Queme Date: Wed, 1 Mar 2017 11:52:58 +0000 Subject: [PATCH 066/510] remove unused js, due to code changes --- app/bundles/PluginBundle/Assets/js/plugin.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/bundles/PluginBundle/Assets/js/plugin.js b/app/bundles/PluginBundle/Assets/js/plugin.js index 99af95577d1..7ee5a213766 100644 --- a/app/bundles/PluginBundle/Assets/js/plugin.js +++ b/app/bundles/PluginBundle/Assets/js/plugin.js @@ -11,8 +11,6 @@ Mautic.addNewPluginField = function (selector) { selectors.each(function () { mQuery(this).prop('disabled', false).trigger("chosen:updated"); }); - currentItem.find('.btn-no').removeClass('disabled'); - currentItem.find('.btn-yes').removeClass('disabled'); currentItem.find('input[type="radio"]').prop('disabled', false).next().prop('disabled', false); } Mautic.stopIconSpinPostEvent(); @@ -24,9 +22,6 @@ Mautic.removePluginField = function (selector, indexClass) { selectors.each(function( ) { mQuery( this ).prop('disabled', true).trigger("chosen:updated"); }); - - deleteCurrentItem.find('.btn-no').addClass('disabled'); - deleteCurrentItem.find('.btn-yes').addClass('disabled'); deleteCurrentItem.find('input[type="radio"]').prop('disabled', true).next().prop('disabled', true); deleteCurrentItem.addClass('hide'); From 627d4d4e157062b322393ef24369399c67c56722 Mon Sep 17 00:00:00 2001 From: Marianela Queme Date: Wed, 1 Mar 2017 12:01:32 +0000 Subject: [PATCH 067/510] added tooltip to direction picker --- ..._integration_details_featureSettings_leadFields_row.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php b/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php index b71df3f67ee..a5d7cd54126 100644 --- a/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php +++ b/app/bundles/PluginBundle/Views/FormTheme/Integration/_integration_details_featureSettings_leadFields_row.html.php @@ -40,7 +40,7 @@ echo '2 ml-xs'; else : echo '4'; -endif; ?>"> +endif; ?>" data-toggle="tooltip" title="trans('mautic.plugin.direction.data.update'); ?>" > row($child); ?>
    Date: Wed, 1 Mar 2017 12:30:10 +0000 Subject: [PATCH 068/510] fixed enable checkboxes issues caused by changes in code --- app/bundles/PluginBundle/Assets/js/plugin.js | 2 ++ .../Integration/integration_company_fields_row.html.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/bundles/PluginBundle/Assets/js/plugin.js b/app/bundles/PluginBundle/Assets/js/plugin.js index 7ee5a213766..f9b89dfcbb7 100644 --- a/app/bundles/PluginBundle/Assets/js/plugin.js +++ b/app/bundles/PluginBundle/Assets/js/plugin.js @@ -11,6 +11,7 @@ Mautic.addNewPluginField = function (selector) { selectors.each(function () { mQuery(this).prop('disabled', false).trigger("chosen:updated"); }); + currentItem.find('label').removeClass('disabled'); currentItem.find('input[type="radio"]').prop('disabled', false).next().prop('disabled', false); } Mautic.stopIconSpinPostEvent(); @@ -23,6 +24,7 @@ Mautic.removePluginField = function (selector, indexClass) { mQuery( this ).prop('disabled', true).trigger("chosen:updated"); }); deleteCurrentItem.find('input[type="radio"]').prop('disabled', true).next().prop('disabled', true); + deleteCurrentItem.find('label').addClass('disabled'); deleteCurrentItem.addClass('hide'); Mautic.stopIconSpinPostEvent(); diff --git a/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_company_fields_row.html.php b/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_company_fields_row.html.php index 8719ff86cd6..e06d58224c0 100644 --- a/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_company_fields_row.html.php +++ b/app/bundles/PluginBundle/Views/FormTheme/Integration/integration_company_fields_row.html.php @@ -41,7 +41,7 @@ echo '2 ml-xs'; else : echo '4'; -endif; ?>"> +endif; ?>" data-toggle="tooltip" title="trans('mautic.plugin.direction.data.update'); ?>" > row($child); ?>
    Date: Wed, 1 Mar 2017 07:25:13 -0600 Subject: [PATCH 069/510] Fixed image bug --- .../css/app/less/components/builder.less | 44 ++++++- .../Assets/css/libraries/builder.less | 4 +- app/bundles/CoreBundle/Assets/js/4.builder.js | 108 +++++++++++------- .../CoreBundle/Form/Type/SlotCodeModeType.php | 15 --- .../Form/Type/SlotImageCaptionType.php | 29 ++++- .../Form/Type/SlotImageCardType.php | 53 ++++++++- .../CoreBundle/Form/Type/SlotImageType.php | 4 +- .../Form/Type/SlotSocialFollowType.php | 59 +++++++--- .../Form/Type/SlotSocialShareType.php | 15 --- .../Translations/en_US/messages.ini | 5 + .../CoreBundle/Views/Slots/codemode.html.php | 5 +- .../Views/Slots/imagecaption.html.php | 2 +- .../CoreBundle/Views/Slots/imagecard.html.php | 2 +- .../Views/Slots/socialfollow.html.php | 6 +- .../EventListener/BuilderSubscriber.php | 20 ++-- .../EventListener/BuilderSubscriber.php | 20 ++-- 16 files changed, 270 insertions(+), 121 deletions(-) diff --git a/app/bundles/CoreBundle/Assets/css/app/less/components/builder.less b/app/bundles/CoreBundle/Assets/css/app/less/components/builder.less index 382859b254a..0f83752d588 100644 --- a/app/bundles/CoreBundle/Assets/css/app/less/components/builder.less +++ b/app/bundles/CoreBundle/Assets/css/app/less/components/builder.less @@ -1,5 +1,5 @@ -.builder { +.builder, .builder-slot { position: relative; [data-token] { @@ -78,6 +78,48 @@ white-space: normal; } +/********** SLOT ************/ + +.builder-active-slot { + background-color: #fff; + z-index: 1030; +} + +.builder-panel-slot { + width: 50%; + padding: 15px; + background-color: #d5d4d4; + overflow-y: auto; + + .btn-close-builder { + width: 100%; + } +} + +.builder-content-slot { + left: 50%; + width: 50%; +} + +.code-mode { + .builder-panel-slot { + width: 50%; + } + .builder-content-slot { + width: 50%; + } + .btn-close-builder { + width: 150px; + float: right; + } +} + +.builder-panel-slot .panel a.btn { + white-space: normal; +} + +/************* END SLOT ******************/ + .ui-draggable-iframeFix { z-index: 9999 !important; } diff --git a/app/bundles/CoreBundle/Assets/css/libraries/builder.less b/app/bundles/CoreBundle/Assets/css/libraries/builder.less index 0d4c1d717da..3dbc0cb2520 100644 --- a/app/bundles/CoreBundle/Assets/css/libraries/builder.less +++ b/app/bundles/CoreBundle/Assets/css/libraries/builder.less @@ -119,12 +119,12 @@ div[data-slot], [data-section-wrapper] { position: relative; } -div[data-slot="image"] { +div[data-slot^="image"] { padding-top: 1px; // prevent z-index of image from hiding the bottom border of a slot with focus above it padding-bottom: 1px; } -div[data-slot="image"] img { +div[data-slot^="image"] img { z-index: 2; position: relative; } diff --git a/app/bundles/CoreBundle/Assets/js/4.builder.js b/app/bundles/CoreBundle/Assets/js/4.builder.js index 45a8263c5ad..3d4b099562c 100644 --- a/app/bundles/CoreBundle/Assets/js/4.builder.js +++ b/app/bundles/CoreBundle/Assets/js/4.builder.js @@ -87,26 +87,26 @@ Mautic.launchBuilder = function (formName, actionName) { /** * Launch builder * + * @param slot mQuery object */ Mautic.launchBuilderSlot = function (slot) { - Mautic.codeMode = mQuery('.builder').hasClass('code-mode'); - Mautic.showChangeThemeWarning = true; + Mautic.codeMode = mQuery('.builder-slot').hasClass('code-mode'); - mQuery('slotbody').css('overflow-y', 'hidden'); + slot.css('overflow-y', 'hidden'); // Activate the builder - mQuery('.builder').addClass('builder-active').removeClass('hide'); + mQuery('.builder-slot').addClass('builder-active').removeClass('hide'); var builderCss = { margin: "0", padding: "0", border: "none", - width: "100%", - height: "100%" + // width: "100%", + // height: "100%" }; // Load the theme from the custom HTML textarea - var themeHtml = mQuery(slot).html(); + var themeHtml = slot.html(); if (Mautic.codeMode) { var rawTokens = mQuery.map(Mautic.builderTokens, function (element, index) { @@ -144,24 +144,7 @@ Mautic.launchBuilderSlot = function (slot) { Mautic.keepPreviewAlive('builder-template-content'); } - var panelHeight = (mQuery('.builder-content').css('right') == '0px') ? mQuery('.builder-panel').height() : 0, - panelWidth = (mQuery('.builder-content').css('right') == '0px') ? 0 : mQuery('.builder-panel').width(), - spinnerLeft = (mQuery(window).width() - panelWidth - 60) / 2, - spinnerTop = (mQuery(window).height() - panelHeight - 60) / 2; - - var overlay = mQuery('').css(builderCss).appendTo('.builder-content'); - - // Disable the close button until everything is loaded - mQuery('.btn-close-builder').prop('disabled', true); - - // Insert the Mautic assets to the header - var assets = Mautic.htmlspecialchars_decode(mQuery('[data-builder-assets]').html()); - themeHtml = themeHtml.replace('', assets+''); - - Mautic.buildBuilderIframe(themeHtml, 'builder-template-content', function() { - mQuery('#builder-overlay').addClass('hide'); - mQuery('.btn-close-builder').prop('disabled', false); - }); + Mautic.buildBuilderIframeSlot(themeHtml, 'builder-template-content', function() {}); }; /** @@ -271,6 +254,31 @@ Mautic.buildBuilderIframe = function(themeHtml, id, onLoadCallback) { Mautic.updateIframeContent(id, themeHtml); }; +Mautic.buildBuilderIframeSlot = function(themeHtml, id, onLoadCallback) { + if (mQuery('iframe#'+id).length) { + var builder = mQuery('iframe#'+id); + } else { + var builder = mQuery("