Exemplo n.º 1
0
 /**
  * Note if this submission is from a focus submit.
  *
  * @param SubmissionEvent $event
  */
 public function onFormSubmit(SubmissionEvent $event)
 {
     // Check the request for a focus field
     $id = $this->request->request->get('mauticform[focusId]', false, true);
     if (!empty($id)) {
         $focus = $this->model->getEntity($id);
         if ($focus && $focus->isPublished()) {
             // Make sure the form is still applicable
             $form = $event->getSubmission()->getForm();
             if ((int) $form->getId() === (int) $focus->getForm()) {
                 $this->model->addStat($focus, Stat::TYPE_FORM, $event->getSubmission());
             }
         }
     }
 }
Exemplo n.º 2
0
 /**
  * @param PageDisplayEvent $event
  */
 public function onPageDisplay(PageDisplayEvent $event)
 {
     $content = $event->getContent();
     $regex = '/' . $this->regex . '/i';
     preg_match_all($regex, $content, $matches);
     if (count($matches[0])) {
         foreach ($matches[1] as $k => $id) {
             $focus = $this->model->getEntity($id);
             if ($focus !== null && ($focus->isPublished() || $this->security->hasEntityAccess('plugin:focus:items:viewown', 'plugin:focus:items:viewother', $focus->getCreatedBy()))) {
                 $script = '<script src="' . $this->router->generate('mautic_focus_generate', ['id' => $id], true) . '" type="text/javascript" charset="utf-8" async="async"></script>';
                 $content = preg_replace('#{focus=' . $id . '}#', $script, $content);
             } else {
                 $content = preg_replace('#{focus=' . $id . '}#', '', $content);
             }
         }
     }
     $event->setContent($content);
 }