/**
  * @param Action        $action
  * @param MauticFactory $factory
  *
  * @return array
  */
 public static function onFormSubmit(Action $action, MauticFactory $factory)
 {
     $properties = $action->getProperties();
     $assetId = $properties['asset'];
     /** @var \Mautic\AssetBundle\Model\AssetModel $model */
     $model = $factory->getModel('asset');
     $asset = $model->getEntity($assetId);
     $form = $action->getForm();
     //make sure the asset still exists and is published
     if ($asset != null && $asset->isPublished()) {
         //register a callback after the other actions have been fired
         return array('callback' => '\\Mautic\\AssetBundle\\Helper\\FormSubmitHelper::downloadFile', 'form' => $form, 'asset' => $asset, 'message' => isset($properties['message']) ? $properties['message'] : '');
     }
 }
Example #2
0
 /**
  * @param       $action
  *
  * @return array
  */
 public static function sendEmail($tokens, Action $action, MauticFactory $factory, $feedback)
 {
     $properties = $action->getProperties();
     $emailId = isset($properties['useremail']) ? (int) $properties['useremail']['email'] : (int) $properties['email'];
     $form = $action->getForm();
     /** @var \Mautic\EmailBundle\Model\EmailModel $emailModel */
     $emailModel = $factory->getModel('email');
     $email = $emailModel->getEntity($emailId);
     /** @var \Mautic\LeadBundle\Model\LeadModel $leadModel */
     $leadModel = $factory->getModel('lead');
     //make sure the email still exists and is published
     if ($email != null && $email->isPublished()) {
         // Deal with Lead email
         if (!empty($feedback['lead.create']['lead'])) {
             //the lead was just created via the lead.create action
             $currentLead = $feedback['lead.create']['lead'];
         } else {
             $currentLead = $leadModel->getCurrentLead();
         }
         if ($currentLead instanceof Lead) {
             //flatten the lead
             $lead = $currentLead;
             $currentLead = array('id' => $lead->getId());
             $leadFields = $leadModel->flattenFields($lead->getFields());
             $currentLead = array_merge($currentLead, $leadFields);
         }
         if (isset($properties['user_id']) && $properties['user_id']) {
             // User email
             $emailModel->sendEmailToUser($email, $properties['user_id'], $currentLead, $tokens);
         } elseif (isset($currentLead)) {
             if (isset($leadFields['email'])) {
                 $options = array('source' => array('form', $form->getId()), 'tokens' => $tokens, 'ignoreDNC' => true);
                 $emailModel->sendEmail($email, $currentLead, $options);
             }
         }
     }
 }
 /**
  * @param Action        $action
  * @param MauticFactory $factory
  *
  * @return array
  */
 public static function onFormSubmit($tokens, Action $action, MauticFactory $factory, $feedback)
 {
     $properties = $action->getProperties();
     $leadModel = $factory->getModel('lead');
     $emailRepo = $factory->getModel('email');
     // Deal with Lead email
     if (!empty($feedback['lead.create']['lead'])) {
         //the lead was just created via the lead.create action
         $currentLead = $feedback['lead.create']['lead'];
     } else {
         $currentLead = $leadModel->getCurrentLead();
     }
     if ($currentLead instanceof Lead) {
         //flatten the lead
         $lead = $currentLead;
         $currentLead = array('id' => $lead->getId());
         $leadFields = $leadModel->flattenFields($lead->getFields());
         $currentLead = array_merge($currentLead, $leadFields);
     }
     $email_address = $currentLead->getEmail();
     if ($email_address) {
         $emailRepo->removeDoNotContact($email_address);
     }
 }
 /**
  * {@inheritDoc}
  */
 public function getName()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getName', array());
     return parent::getName();
 }
Example #5
0
 /**
  * Add actions
  *
  * @param        $key
  * @param Action $action
  *
  * @return Form
  */
 public function addAction($key, Action $action)
 {
     if ($changes = $action->getChanges()) {
         $this->isChanged('actions', array($key, $changes));
     }
     $this->actions[$key] = $action;
     return $this;
 }
Example #6
0
 /**
  * @param Schema $schema
  */
 public function postUp(Schema $schema)
 {
     $em = $this->factory->getEntityManager();
     // Migrate asset download messages to form message
     $q = $this->connection->createQueryBuilder();
     $q->select('fa.properties, fa.form_id')->from(MAUTIC_TABLE_PREFIX . 'form_actions', 'fa')->where($q->expr()->eq('fa.type', $q->expr()->literal('asset.download')));
     $results = $q->execute()->fetchAll();
     foreach ($results as $r) {
         $properties = unserialize($r['properties']);
         if (is_array($properties) && !empty($properties['message'])) {
             $this->connection->update(MAUTIC_TABLE_PREFIX . 'forms', array('post_action' => 'message', 'post_action_property' => $properties['message']), array('id' => $r['form_id']));
         }
     }
     // Set save_result to true for most form fields
     $q = $this->connection->createQueryBuilder();
     $q->update(MAUTIC_TABLE_PREFIX . 'form_fields')->set('save_result', ':true')->where($q->expr()->andX($q->expr()->neq('type', $q->expr()->literal('button')), $q->expr()->neq('type', $q->expr()->literal('freetext')), $q->expr()->neq('type', $q->expr()->literal('captcha'))))->setParameter('true', true, 'boolean')->execute();
     // Find and migrate the lead.create actions
     // Get a list of lead field entities
     $results = $this->connection->createQueryBuilder()->select('f.id, f.alias')->from(MAUTIC_TABLE_PREFIX . 'lead_fields', 'f')->execute()->fetchAll();
     $fields = array();
     foreach ($results as $field) {
         $fields[$field['id']] = $field['alias'];
     }
     unset($results);
     // Get all the actions that are lead.create
     $q = $this->connection->createQueryBuilder();
     $actions = $q->select('a.id, a.properties, a.form_id, a.action_order, f.created_by, f.created_by_user')->from(MAUTIC_TABLE_PREFIX . 'form_actions', 'a')->join('a', MAUTIC_TABLE_PREFIX . 'forms', 'f', 'a.form_id = f.id')->where($q->expr()->eq('a.type', $q->expr()->literal('lead.create')))->execute()->fetchAll();
     $formFieldMatches = array();
     $actionEntities = array();
     $deleteActions = array();
     foreach ($actions as $action) {
         try {
             $properties = unserialize($action['properties']);
             foreach ($properties['mappedFields'] as $leadFieldId => $formFieldId) {
                 if (!empty($formFieldId)) {
                     $formFieldMatches[$leadFieldId][] = $formFieldId;
                 }
             }
             if (!empty($properties['points'])) {
                 // Create a new point action
                 $formAction = new Action();
                 $formAction->setType('lead.pointschange');
                 $formAction->setName('Migrated');
                 $formAction->setDescription('<p>Migrated during 1.1.0 upgrade. The Create/Update Lead form submit action is now obsolete.</p>');
                 $formAction->setForm($em->getReference('MauticFormBundle:Form', $action['form_id']));
                 $formAction->setOrder($action['action_order']);
                 $formAction->setProperties(array('operator' => 'plus', 'points' => $properties['points']));
                 $actionEntities[] = $formAction;
                 unset($formAction);
             }
             $deleteActions[] = $action['id'];
         } catch (\Exception $e) {
         }
     }
     if (!empty($actionEntities)) {
         $this->factory->getModel('point')->getRepository()->saveEntities($actionEntities);
         $em->clear('Mautic\\FormBundle\\Entity\\Action');
     }
     foreach ($formFieldMatches as $leadFieldId => $formFieldIds) {
         if (!isset($fields[$leadFieldId])) {
             continue;
         }
         $q = $this->connection->createQueryBuilder();
         $q->update(MAUTIC_TABLE_PREFIX . 'form_fields')->set('lead_field', $q->expr()->literal($fields[$leadFieldId]))->where($q->expr()->in('id', $formFieldIds))->execute();
     }
     if (!empty($deleteActions)) {
         $q = $this->connection->createQueryBuilder();
         $q->delete(MAUTIC_TABLE_PREFIX . 'form_actions')->where($q->expr()->in('id', $deleteActions))->execute();
     }
     // Set captcha form fields to required
     $q = $this->connection->createQueryBuilder();
     $q->update(MAUTIC_TABLE_PREFIX . 'form_fields')->set('is_required', ':true')->where($q->expr()->eq('type', $q->expr()->literal('captcha')))->setParameter('true', true, 'boolean')->execute();
     // Set all forms as standalone
     $q = $this->connection->createQueryBuilder();
     $q->update(MAUTIC_TABLE_PREFIX . 'forms')->set('form_type', $q->expr()->literal('standalone'))->execute();
     // Rebuild all the forms
     /** @var \Mautic\FormBundle\Model\FormModel $formModel */
     $formModel = $this->factory->getModel('form');
     $formRepo = $formModel->getRepository();
     $q = $formRepo->createQueryBuilder('f')->select('f, ff')->leftJoin('f.fields', 'ff');
     $forms = $q->getQuery()->getResult();
     if (!empty($forms)) {
         foreach ($forms as $form) {
             // Rebuild the forms
             $formModel->generateHtml($form, false);
         }
         $formRepo->saveEntities($forms);
         $em->clear('Mautic\\FormBundle\\Entity\\Form');
     }
     // Clear template for custom mode
     $q = $this->connection->createQueryBuilder();
     $q->update(MAUTIC_TABLE_PREFIX . 'pages')->set('template', $q->expr()->literal(''))->where($q->expr()->eq('content_mode', $q->expr()->literal('custom')))->execute();
     // Convert email landing page hits to redirects
     $q = $this->connection->createQueryBuilder();
     $q->update(MAUTIC_TABLE_PREFIX . 'page_hits')->set('email_id', 'source_id')->where($q->expr()->eq('source', $q->expr()->literal('email')), $q->expr()->isNull('email_id'))->execute();
     $q = $this->connection->createQueryBuilder();
     $clicks = $q->select('ph.url, ph.email_id, count(distinct(ph.tracking_id)) as unique_click_count, count(ph.tracking_id) as click_count')->from(MAUTIC_TABLE_PREFIX . 'page_hits', 'ph')->where($q->expr()->andX($q->expr()->isNotNull('email_id'), $q->expr()->isNotNull('page_id')))->groupBy('ph.url, ph.email_id')->execute()->fetchAll();
     // See which already have URLs created as redirects
     $redirectEntities = array();
     foreach ($clicks as $click) {
         $redirect = new Redirect();
         $redirect->setDateAdded(new \DateTime());
         $redirect->setEmail($em->getReference('MauticEmailBundle:Email', $click['email_id']));
         $redirect->setUrl($click['url']);
         $redirect->setHits($click['click_count']);
         $redirect->setUniqueHits($click['unique_click_count']);
         $redirect->setRedirectId();
         $redirectEntities[] = $redirect;
     }
     if (!empty($redirectEntities)) {
         $this->factory->getModel('page.redirect')->getRepository()->saveEntities($redirectEntities);
         $em->clear('Mautic\\PageBundle\\Entity\\Redirect');
     }
     // Copy subjects as names
     $q = $this->connection->createQueryBuilder();
     $q->update(MAUTIC_TABLE_PREFIX . 'emails')->set('name', 'subject')->execute();
     // Clear template for custom mode
     $q = $this->connection->createQueryBuilder();
     $q->update(MAUTIC_TABLE_PREFIX . 'emails')->set('template', $q->expr()->literal(''))->where($q->expr()->eq('content_mode', $q->expr()->literal('custom')))->execute();
     // Assume all as templates to start
     $q = $this->connection->createQueryBuilder();
     $q->update(MAUTIC_TABLE_PREFIX . 'emails')->set('email_type', $q->expr()->literal('template'))->execute();
     // Get a list of emails that have been sent to lead lists
     $q = $this->connection->createQueryBuilder();
     $q->select('s.email_id, count(*) as sent_count, sum(case when s.is_read then 1 else 0 end) as read_count')->from(MAUTIC_TABLE_PREFIX . 'email_stats', 's')->where($q->expr()->isNotNull('s.list_id'))->groupBy('s.email_id');
     $results = $q->execute()->fetchAll();
     if (!empty($results)) {
         $templateEmails = array();
         foreach ($results as $email) {
             $templateEmails[$email['email_id']] = $email;
         }
         $templateEmailIds = array_keys($templateEmails);
         /** @var \Mautic\EmailBundle\Model\EmailModel $emailModel */
         $emailModel = $this->factory->getModel('email');
         $emails = $emailModel->getEntities(array('iterator_mode' => true, 'filter' => array('force' => array(array('column' => 'e.id', 'expr' => 'in', 'value' => $templateEmailIds)))));
         $persistListEmails = $persistTemplateEmails = $variants = array();
         // Clone since the ID may be in a bunch of serialized properties then convert new to a list based email
         while (($row = $emails->next()) !== false) {
             /** @var \Mautic\EmailBundle\Entity\Email $templateEmail */
             $templateEmail = reset($row);
             $id = $templateEmail->getId();
             $listEmail = clone $templateEmail;
             $listEmail->setEmailType('list');
             $listEmail->clearVariants();
             $listEmail->clearStats();
             $listSentCount = $templateEmails[$id]['sent_count'];
             $listReadCount = $templateEmails[$id]['read_count'];
             $currentSentCount = $templateEmail->getSentCount();
             $currentReadCount = $templateEmail->getReadCount();
             // Assume the difference between the current counts and the list counts are template related
             $templateEmail->setSentCount($currentSentCount - $listSentCount);
             $templateEmail->setReadCount($currentReadCount - $listReadCount);
             // Set the list email stats
             $listEmail->setSentCount($listSentCount);
             $listEmail->setReadCount($listReadCount);
             // Special cases for variants
             if ($variantStartDate = $templateEmail->getVariantStartDate()) {
                 // Take note that this email needs to also have it's variants
                 if (!in_array($id, $variants)) {
                     $variants[] = $id;
                 }
                 $dtHelper = new DateTimeHelper($variantStartDate);
                 $q = $this->connection->createQueryBuilder();
                 $q->select('s.email_id, count(*) as sent_count, sum(case when s.is_read then 1 else 0 end) as read_count')->from(MAUTIC_TABLE_PREFIX . 'email_stats', 's')->where($q->expr()->andX($q->expr()->isNotNull('s.list_id'), $q->expr()->eq('s.email_id', $id), $q->expr()->gte('s.date_sent', $q->expr()->literal($dtHelper->toUtcString('Y-m-d H:i:s')))))->groupBy('s.email_id');
                 $results = $q->execute()->fetchAll();
                 $variantListSentCount = $results[0]['sent_count'];
                 $variantListReadCount = $results[0]['read_count'];
                 $variantCurrentSentCount = $templateEmail->getVariantSentCount();
                 $variantCurrentReadCount = $templateEmail->getVariantReadCount();
                 // Assume the difference between the current counts and the list counts are template related
                 $templateEmail->setVariantSentCount($variantCurrentSentCount - $variantListSentCount);
                 $templateEmail->setVariantReadCount($variantCurrentReadCount - $variantListReadCount);
                 // Set the list email stats
                 $listEmail->setVariantSentCount($variantListSentCount);
                 $listEmail->setVariantReadCount($variantListReadCount);
             }
             $persistListEmails[$id] = $listEmail;
             $persistTemplateEmails[$id] = $templateEmail;
             unset($listEmail, $templateEmail);
         }
         $repo = $emailModel->getRepository();
         // Update template emails; no need to run through audit log stuff so just use repo
         $repo->saveEntities($persistTemplateEmails);
         // Create new list emails and tell audit log to use system
         define('MAUTIC_IGNORE_AUDITLOG_USER', 1);
         $emailModel->saveEntities($persistListEmails);
         // Clone variants
         $persistVariants = array();
         $processedVariants = array();
         foreach ($variants as $templateEmailId) {
             if ($persistTemplateEmails[$templateEmailId]->isVariant(true)) {
                 // A variant of another so get parent
                 $templateParent = $persistTemplateEmails[$templateEmailId]->getVariantParent();
             } else {
                 $templateParent = $persistTemplateEmails[$templateEmailId];
             }
             if (in_array($templateParent->getId(), $processedVariants)) {
                 continue;
             }
             $processedVariants[] = $templateParent->getId();
             // Get the children to clone each one
             $children = $templateParent->getVariantChildren();
             // If the parent is not already cloned, then do so
             /** @var \Mautic\EmailBundle\Entity\Email $listParent */
             if (!isset($persistListEmails[$templateParent->getId()])) {
                 $listParent = clone $templateParent;
                 $listParent->setEmailType('list');
                 $listParent->clearVariants();
                 $listParent->clearStats();
                 $persistVariants[$templateParent->getId()] = $listParent;
             } else {
                 $listParent = $persistListEmails[$templateParent->getId()];
             }
             unset($templateParent);
             /** @var \Mautic\EmailBundle\Entity\Email $templateChild */
             foreach ($children as $templateChild) {
                 // If the variant already exists, then just set the parent and save
                 if (isset($persistListEmails[$templateChild->getId()])) {
                     $persistListEmails[$templateChild->getId()]->setVariantParent($listParent);
                     $persistVariants[$templateChild->getId()] = $persistListEmails[$templateChild->getId()];
                     continue;
                 }
                 $listChild = clone $templateChild;
                 $listChild->clearStats();
                 $listChild->setEmailType('list');
                 $listChild->setVariantParent($listParent);
                 $persistVariants[$templateChild->getId()] = $listChild;
                 unset($listChild, $templateChild);
             }
             unset($listParent, $children);
         }
         // Create new variants
         $emailModel->saveEntities($persistVariants);
         // Now update lead log stats, page hit stats, and email stats
         foreach ($persistListEmails as $templateId => $listEmail) {
             // Update page hits
             $sq = $this->connection->createQueryBuilder();
             $sq->select('es.lead_id')->from(MAUTIC_TABLE_PREFIX . 'email_stats', 'es')->where($sq->expr()->andX($sq->expr()->eq('es.email_id', $templateId), $q->expr()->isNotNull('es.list_id')));
             $q = $this->connection->createQueryBuilder();
             $q->update(MAUTIC_TABLE_PREFIX . 'page_hits')->set('email_id', $listEmail->getId())->where('lead_id IN ' . sprintf('(%s)', $sq->getSql()) . ' AND email_id = ' . $templateId)->execute();
             // Update download hits
             $q = $this->connection->createQueryBuilder();
             $q->update(MAUTIC_TABLE_PREFIX . 'asset_downloads')->set('email_id', $listEmail->getId())->where('lead_id IN ' . sprintf('(%s)', $sq->getSql()) . ' AND email_id = ' . $templateId)->execute();
             $q = $this->connection->createQueryBuilder();
             $q->update(MAUTIC_TABLE_PREFIX . 'email_stats')->set('email_id', $listEmail->getId())->where($q->expr()->andX($q->expr()->isNotNull('list_id'), $q->expr()->eq('email_id', $templateId)))->execute();
             unset($listEmail, $persistListEmails[$templateId]);
         }
         // Delete all lead list cross references for the emails converted to templates
         $q = $this->connection->createQueryBuilder();
         $q->delete(MAUTIC_TABLE_PREFIX . 'email_list_xref')->where($q->expr()->in('email_id', $templateEmailIds))->execute();
     } else {
         // Delete all lead list cross references
         $q = $this->connection->createQueryBuilder();
         $q->delete(MAUTIC_TABLE_PREFIX . 'email_list_xref')->execute();
     }
 }
Example #7
0
 /**
  * Generates edit form and processes post data.
  *
  * @param int $objectId
  *
  * @return JsonResponse
  */
 public function editAction($objectId)
 {
     $session = $this->get('session');
     $method = $this->request->getMethod();
     $formId = $method == 'POST' ? $this->request->request->get('formaction[formId]', '', true) : $this->request->query->get('formId');
     $actions = $session->get('mautic.form.' . $formId . '.actions.modified', []);
     $success = 0;
     $valid = $cancelled = false;
     $formAction = array_key_exists($objectId, $actions) ? $actions[$objectId] : null;
     if ($formAction !== null) {
         $actionType = $formAction['type'];
         $customComponents = $this->getModel('form.form')->getCustomComponents();
         $formAction['settings'] = $customComponents['actions'][$actionType];
         //ajax only for form fields
         if (!$actionType || !$this->request->isXmlHttpRequest() || !$this->get('mautic.security')->isGranted(['form:forms:editown', 'form:forms:editother', 'form:forms:create'], 'MATCH_ONE')) {
             return $this->modalAccessDenied();
         }
         $form = $this->get('form.factory')->create('formaction', $formAction, ['action' => $this->generateUrl('mautic_formaction_action', ['objectAction' => 'edit', 'objectId' => $objectId]), 'settings' => $formAction['settings'], 'formId' => $formId]);
         $form->get('formId')->setData($formId);
         //Check for a submitted form and process it
         if ($method == 'POST') {
             if (!($cancelled = $this->isFormCancelled($form))) {
                 if ($valid = $this->isFormValid($form)) {
                     $success = 1;
                     //form is valid so process the data
                     //save the properties to session
                     $session = $this->get('session');
                     $actions = $session->get('mautic.form.' . $formId . '.actions.modified');
                     $formData = $form->getData();
                     //overwrite with updated data
                     $formAction = array_merge($actions[$objectId], $formData);
                     if (empty($formAction['name'])) {
                         //set it to the event default
                         $formAction['name'] = $this->get('translator')->trans($formAction['settings']['label']);
                     }
                     $actions[$objectId] = $formAction;
                     $session->set('mautic.form.' . $formId . '.actions.modified', $actions);
                     //generate HTML for the field
                     $keyId = $objectId;
                     //take note if this is a submit button or not
                     if ($actionType == 'button') {
                         $submits = $session->get('mautic.formactions.submits', []);
                         if ($formAction['properties']['type'] == 'submit' && !in_array($keyId, $submits)) {
                             //button type updated to submit
                             $submits[] = $keyId;
                             $session->set('mautic.formactions.submits', $submits);
                         } elseif ($formAction['properties']['type'] != 'submit' && in_array($keyId, $submits)) {
                             //button type updated to something other than submit
                             $key = array_search($keyId, $submits);
                             unset($submits[$key]);
                             $session->set('mautic.formactions.submits', $submits);
                         }
                     }
                 }
             }
         }
         $viewParams = ['type' => $actionType];
         if ($cancelled || $valid) {
             $closeModal = true;
         } else {
             $closeModal = false;
             $viewParams['tmpl'] = 'action';
             $viewParams['form'] = isset($formAction['settings']['formTheme']) ? $this->setFormTheme($form, 'MauticFormBundle:Builder:action.html.php', $formAction['settings']['formTheme']) : $form->createView();
             $viewParams['actionHeader'] = $this->get('translator')->trans($formAction['settings']['label']);
         }
         $passthroughVars = ['mauticContent' => 'formAction', 'success' => $success, 'route' => false];
         if (!empty($keyId)) {
             $passthroughVars['actionId'] = $keyId;
             //prevent undefined errors
             $entity = new Action();
             $blank = $entity->convertToArray();
             $formAction = array_merge($blank, $formAction);
             $template = !empty($formAction['settings']['template']) ? $formAction['settings']['template'] : 'MauticFormBundle:Action:generic.html.php';
             $passthroughVars['actionHtml'] = $this->renderView($template, ['inForm' => true, 'action' => $formAction, 'id' => $keyId, 'formId' => $formId]);
         }
         if ($closeModal) {
             //just close the modal
             $passthroughVars['closeModal'] = 1;
             $response = new JsonResponse($passthroughVars);
             return $response;
         }
         return $this->ajaxAction(['contentTemplate' => 'MauticFormBundle:Builder:' . $viewParams['tmpl'] . '.html.php', 'viewParameters' => $viewParams, 'passthroughVars' => $passthroughVars]);
     }
     $response = new JsonResponse(['success' => 0]);
     return $response;
 }
 /**
  * Undeletes the entity
  *
  * @param $objectId
  *
  * @return JsonResponse
  */
 public function undeleteAction($objectId)
 {
     $session = $this->factory->getSession();
     $formId = $this->request->query->get('formId');
     $actions = $session->get('mautic.form.' . $formId . '.actions.modified', array());
     $delete = $session->get('mautic.form.' . $formId . '.actions.deleted', array());
     //ajax only for form fields
     if (!$this->request->isXmlHttpRequest() || !$this->factory->getSecurity()->isGranted(array('form:forms:editown', 'form:forms:editother', 'form:forms:create'), 'MATCH_ONE')) {
         return $this->accessDenied();
     }
     $formAction = array_key_exists($objectId, $actions) ? $actions[$objectId] : null;
     if ($this->request->getMethod() == 'POST' && $formAction !== null) {
         //add the field to the delete list
         if (in_array($objectId, $delete)) {
             $key = array_search($objectId, $delete);
             unset($delete[$key]);
             $session->set('mautic.form.' . $formId . '.actions.deleted', $delete);
         }
         //take note if this is a submit button or not
         if ($formAction['type'] == 'button') {
             $properties = $formAction['properties'];
             if ($properties['type'] == 'submit') {
                 $submits = $session->get('mautic.formactions.submits', array());
                 $submits[] = $objectId;
                 $session->set('mautic.formactions.submits', $submits);
             }
         }
         $template = !empty($formAction['settings']['template']) ? $formAction['settings']['template'] : 'MauticFormBundle:Action:generic.html.php';
         //prevent undefined errors
         $entity = new Action();
         $blank = $entity->convertToArray();
         $formAction = array_merge($blank, $formAction);
         $dataArray = array('mauticContent' => 'formAction', 'success' => 1, 'target' => '#mauticform_' . $objectId, 'route' => false, 'actionId' => $objectId, 'actionHtml' => $this->renderView($template, array('inForm' => true, 'action' => $formAction, 'id' => $objectId, 'deleted' => false, 'formId' => $formId)));
     } else {
         $dataArray = array('success' => 0);
     }
     $response = new JsonResponse($dataArray);
     $response->headers->set('Content-Length', strlen($response->getContent()));
     return $response;
 }