Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->addEventSubscriber(new CleanFormSubscriber(['description' => 'html']));
     $builder->addEventSubscriber(new FormExitSubscriber('point', $options));
     $builder->add('name', 'text', ['label' => 'mautic.core.name', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control']]);
     $builder->add('description', 'textarea', ['label' => 'mautic.core.description', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control editor'], 'required' => false]);
     $builder->add('type', 'choice', ['choices' => $options['pointActions']['choices'], 'empty_value' => '', 'label' => 'mautic.point.form.type', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control', 'onchange' => 'Mautic.getPointActionPropertiesForm(this.value);']]);
     $builder->add('delta', 'number', ['label' => 'mautic.point.action.delta', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control', 'tooltip' => 'mautic.point.action.delta.help'], 'precision' => 0]);
     $type = !empty($options['actionType']) ? $options['actionType'] : $options['data']->getType();
     if ($type) {
         $formType = !empty($options['pointActions']['actions'][$type]['formType']) ? $options['pointActions']['actions'][$type]['formType'] : 'genericpoint_settings';
         $properties = $options['data'] ? $options['data']->getProperties() : [];
         $builder->add('properties', $formType, ['label' => false, 'data' => $properties]);
     }
     if (!empty($options['data']) && $options['data'] instanceof Point) {
         $readonly = !$this->security->hasEntityAccess('point:points:publishown', 'point:points:publishother', $options['data']->getCreatedBy());
         $data = $options['data']->isPublished(false);
     } elseif (!$this->security->isGranted('point:points:publishown')) {
         $readonly = true;
         $data = false;
     } else {
         $readonly = false;
         $data = true;
     }
     $builder->add('isPublished', 'yesno_button_group', ['read_only' => $readonly, 'data' => $data]);
     $builder->add('publishUp', 'datetime', ['widget' => 'single_text', 'label' => 'mautic.core.form.publishup', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control', 'data-toggle' => 'datetime'], 'format' => 'yyyy-MM-dd HH:mm', 'required' => false]);
     $builder->add('publishDown', 'datetime', ['widget' => 'single_text', 'label' => 'mautic.core.form.publishdown', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control', 'data-toggle' => 'datetime'], 'format' => 'yyyy-MM-dd HH:mm', 'required' => false]);
     //add category
     $builder->add('category', 'category', ['bundle' => 'point']);
     $builder->add('buttons', 'form_buttons');
     if (!empty($options['action'])) {
         $builder->setAction($options['action']);
     }
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->addEventSubscriber(new CleanFormSubscriber(array('description' => 'html')));
     $builder->addEventSubscriber(new FormExitSubscriber('point', $options));
     $builder->add('name', 'text', array('label' => 'mautic.core.name', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control')));
     $builder->add('description', 'textarea', array('label' => 'mautic.core.description', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control editor'), 'required' => false));
     //add category
     $builder->add('category', 'category', array('bundle' => 'point'));
     $builder->add('points', 'number', array('label' => 'mautic.point.trigger.form.points', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.point.trigger.form.points_descr'), 'required' => false));
     $color = $options['data']->getColor();
     $builder->add('color', 'text', array('label' => 'mautic.point.trigger.form.color', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'data-toggle' => 'color', 'tooltip' => 'mautic.point.trigger.form.color_descr'), 'required' => false, 'data' => !empty($color) ? $color : 'a0acb8', 'empty_data' => 'a0acb8'));
     $builder->add('triggerExistingLeads', 'yesno_button_group', array('label' => 'mautic.point.trigger.form.existingleads'));
     if (!empty($options['data']) && $options['data']->getId()) {
         $readonly = !$this->security->isGranted('point:triggers:publish');
         $data = $options['data']->isPublished(false);
     } elseif (!$this->security->isGranted('point:triggers:publish')) {
         $readonly = true;
         $data = false;
     } else {
         $readonly = false;
         $data = false;
     }
     $builder->add('isPublished', 'yesno_button_group', array('read_only' => $readonly, 'data' => $data));
     $builder->add('publishUp', 'datetime', array('widget' => 'single_text', 'label' => 'mautic.core.form.publishup', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'data-toggle' => 'datetime'), 'format' => 'yyyy-MM-dd HH:mm', 'required' => false));
     $builder->add('publishDown', 'datetime', array('widget' => 'single_text', 'label' => 'mautic.core.form.publishdown', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'data-toggle' => 'datetime'), 'format' => 'yyyy-MM-dd HH:mm', 'required' => false));
     $builder->add('sessionId', 'hidden', array('mapped' => false));
     $builder->add('buttons', 'form_buttons');
     if (!empty($options["action"])) {
         $builder->setAction($options["action"]);
     }
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->addEventSubscriber(new CleanFormSubscriber(['description' => 'html']));
     $builder->addEventSubscriber(new FormExitSubscriber('stage', $options));
     $builder->add('description', 'textarea', ['label' => 'mautic.core.description', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control editor'], 'required' => false]);
     $builder->add('name', 'text', ['label' => 'mautic.core.name', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control']]);
     $builder->add('weight', 'number', ['label' => 'mautic.stage.action.weight', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control', 'tooltip' => 'mautic.stage.action.weight.help'], 'precision' => 0, 'required' => false]);
     if (!empty($options['data']) && $options['data'] instanceof Stage) {
         $readonly = !$this->security->hasEntityAccess('stage:stages:publishown', 'stage:stages:publishother', $options['data']->getCreatedBy());
         $data = $options['data']->isPublished(false);
     } elseif (!$this->security->isGranted('stage:stages:publishown')) {
         $readonly = true;
         $data = false;
     } else {
         $readonly = false;
         $data = true;
     }
     $builder->add('isPublished', 'yesno_button_group', ['read_only' => $readonly, 'data' => $data]);
     $builder->add('publishUp', 'datetime', ['widget' => 'single_text', 'label' => 'mautic.core.form.publishup', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control', 'data-toggle' => 'datetime'], 'format' => 'yyyy-MM-dd HH:mm', 'required' => false]);
     $builder->add('publishDown', 'datetime', ['widget' => 'single_text', 'label' => 'mautic.core.form.publishdown', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control', 'data-toggle' => 'datetime'], 'format' => 'yyyy-MM-dd HH:mm', 'required' => false]);
     //add category
     $builder->add('category', 'category', ['bundle' => 'stage']);
     $builder->add('buttons', 'form_buttons');
     if (!empty($options['action'])) {
         $builder->setAction($options['action']);
     }
 }
Exemplo n.º 4
0
 /**
  * @param FormBuilderInterface $builder
  * @param array                $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->addEventSubscriber(new CleanFormSubscriber(['website' => 'url']));
     $builder->addEventSubscriber(new FormExitSubscriber('focus', $options));
     $builder->add('name', 'text', ['label' => 'mautic.core.name', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control']]);
     $builder->add('description', 'textarea', ['label' => 'mautic.core.description', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control editor'], 'required' => false]);
     $builder->add('website', 'url', ['label' => 'mautic.focus.form.website', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control', 'tooltip' => 'mautic.focus.form.website.tooltip'], 'required' => false]);
     //add category
     $builder->add('category', 'category', ['bundle' => 'plugin:focus']);
     if (!empty($options['data']) && $options['data']->getId()) {
         $readonly = !$this->security->isGranted('plugin:focus:items:publish');
         $data = $options['data']->isPublished(false);
     } elseif (!$this->security->isGranted('plugin:focus:items:publish')) {
         $readonly = true;
         $data = false;
     } else {
         $readonly = false;
         $data = false;
     }
     $builder->add('isPublished', 'yesno_button_group', ['read_only' => $readonly, 'data' => $data]);
     $builder->add('publishUp', 'datetime', ['widget' => 'single_text', 'label' => 'mautic.core.form.publishup', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control', 'data-toggle' => 'datetime'], 'format' => 'yyyy-MM-dd HH:mm', 'required' => false]);
     $builder->add('publishDown', 'datetime', ['widget' => 'single_text', 'label' => 'mautic.core.form.publishdown', 'label_attr' => ['class' => 'control-label'], 'attr' => ['class' => 'form-control', 'data-toggle' => 'datetime'], 'format' => 'yyyy-MM-dd HH:mm', 'required' => false]);
     $builder->add('properties', 'focus_entity_properties', ['data' => $options['data']->getProperties()]);
     // Will be managed by JS
     $builder->add('type', 'hidden');
     $builder->add('style', 'hidden');
     $builder->add('form', 'form_list', ['label' => 'mautic.focus.form.choose_form', 'multiple' => false, 'empty_value' => '', 'attr' => ['onchange' => 'Mautic.focusUpdatePreview()']]);
     if (!empty($options['action'])) {
         $builder->setAction($options['action']);
     }
     $builder->add('buttons', 'form_buttons', ['pre_extra_buttons' => [['name' => 'builder', 'label' => 'mautic.core.builder', 'attr' => ['class' => 'btn btn-default btn-dnd btn-nospin', 'icon' => 'fa fa-cube', 'onclick' => 'Mautic.launchFocusBuilder();']]]]);
 }
Exemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->addEventSubscriber(new CleanFormSubscriber(array('description' => 'html')));
     $builder->addEventSubscriber(new FormExitSubscriber('form.form', $options));
     //details
     $builder->add('name', 'text', array('label' => 'mautic.core.name', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control')));
     $builder->add('description', 'textarea', array('label' => 'mautic.core.description', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control editor'), 'required' => false));
     //add category
     $builder->add('category', 'category', array('bundle' => 'form'));
     $builder->add('template', 'theme_list', array('feature' => 'form', 'empty_value' => ' ', 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.form.form.template.help')));
     if (!empty($options['data']) && $options['data']->getId()) {
         $readonly = !$this->security->hasEntityAccess('form:forms:publishown', 'form:forms:publishother', $options['data']->getCreatedBy());
         $data = $options['data']->isPublished(false);
     } elseif (!$this->security->isGranted('form:forms:publishown')) {
         $readonly = true;
         $data = false;
     } else {
         $readonly = false;
         $data = true;
     }
     $builder->add('isPublished', 'yesno_button_group', array('read_only' => $readonly, 'data' => $data));
     $builder->add('inKioskMode', 'yesno_button_group', array('label' => 'mautic.form.form.kioskmode', 'attr' => array('tooltip' => 'mautic.form.form.kioskmode.tooltip')));
     $builder->add('publishUp', 'datetime', array('widget' => 'single_text', 'label' => 'mautic.core.form.publishup', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'data-toggle' => 'datetime'), 'format' => 'yyyy-MM-dd HH:mm', 'required' => false));
     $builder->add('publishDown', 'datetime', array('widget' => 'single_text', 'label' => 'mautic.core.form.publishdown', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'data-toggle' => 'datetime'), 'format' => 'yyyy-MM-dd HH:mm', 'required' => false));
     $builder->add('postAction', 'choice', array('choices' => array('return' => 'mautic.form.form.postaction.return', 'redirect' => 'mautic.form.form.postaction.redirect', 'message' => 'mautic.form.form.postaction.message'), 'label' => 'mautic.form.form.postaction', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'onchange' => 'Mautic.onPostSubmitActionChange(this.value);'), 'required' => false, 'empty_value' => false));
     $postAction = isset($options['data']) ? $options['data']->getPostAction() : '';
     $required = in_array($postAction, array('redirect', 'message')) ? true : false;
     $builder->add('postActionProperty', 'text', array('label' => 'mautic.form.form.postactionproperty', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control'), 'required' => $required));
     $builder->add('sessionId', 'hidden', array('mapped' => false));
     $builder->add('buttons', 'form_buttons');
     $builder->add('formType', 'hidden');
     if (!empty($options["action"])) {
         $builder->setAction($options["action"]);
     }
 }
Exemplo n.º 6
0
 /**
  * Check if the user has permission to see the widgets.
  *
  * @param array $permissions
  *
  * @return bool
  */
 public function hasPermissions(array $permissions)
 {
     if (!$this->security) {
         return true;
     }
     $perm = $this->security->isGranted($permissions, 'RETURN_ARRAY');
     return !in_array(false, $perm);
 }
Exemplo n.º 7
0
 /**
  * @param OAuthEvent $event
  *
  * @throws AccessDeniedException
  */
 public function onPreAuthorizationProcess(OAuthEvent $event)
 {
     if ($user = $this->getUser($event)) {
         //check to see if user has api access
         if (!$this->mauticSecurity->isGranted('api:access:full')) {
             throw new AccessDeniedException($this->translator->trans('mautic.core.error.accessdenied', [], 'flashes'));
         }
         $client = $event->getClient();
         $event->setAuthorizedClient($client->isAuthorizedClient($user, $this->em));
     }
 }
Exemplo n.º 8
0
 /**
  * Check if the user has defined permission to see the widgets
  *
  * @param  string $permission
  *
  * @return boolean
  */
 public function hasPermission($permission)
 {
     if (!$this->security) {
         return true;
     }
     return $this->security->isGranted($permission);
 }
Exemplo n.º 9
0
 /**
  * Adds the category menu items to a bundle's menu.
  *
  * @param $items
  * @param $bundleName
  * @param $security
  */
 public static function addCategoryMenuItems(&$items, $bundleName, CorePermissions $security)
 {
     if (!$security->isGranted($bundleName . ':categories:view')) {
         return;
     }
     $items['mautic.category.menu.index'] = ['route' => 'mautic_category_index', 'id' => "mautic_{$bundleName}category_index", 'routeParameters' => ['bundle' => $bundleName]];
 }
Exemplo n.º 10
0
 /**
  * Checks if user has permission to access retrieved entity
  *
  * @param mixed  $entity
  * @param string $action view|create|edit|publish|delete
  *
  * @return bool
  */
 protected function checkEntityAccess($entity, $action = 'view')
 {
     if ($action != 'create') {
         $ownPerm = "{$this->permissionBase}:{$action}own";
         $otherPerm = "{$this->permissionBase}:{$action}other";
         return $this->security->hasEntityAccess($ownPerm, $otherPerm, $entity->getCreatedBy());
     }
     return $this->security->isGranted("{$this->permissionBase}:create");
 }
Exemplo n.º 11
0
 /**
  * @param $permission
  *
  * @return mixed
  */
 public function isGranted($permission)
 {
     return $this->security->isGranted($permission);
 }
Exemplo n.º 12
0
 /**
  * Converts menu config into something KNP menus expects
  *
  * @param      $items
  * @param int  $depth
  * @param int  $defaultPriority
  */
 public function createMenuStructure(&$items, $depth = 0, $defaultPriority = 9999)
 {
     foreach ($items as $k => &$i) {
         if (!is_array($i) || empty($i)) {
             continue;
         }
         if (isset($i['bundle'])) {
             // Category shortcut
             $bundleName = $i['bundle'];
             $i = ['access' => $bundleName . ':categories:view', 'route' => 'mautic_category_index', 'id' => 'mautic_' . $bundleName . 'category_index', 'routeParameters' => ['bundle' => $bundleName]];
         }
         // Check to see if menu is restricted
         if (isset($i['access'])) {
             if ($i['access'] == 'admin') {
                 if (!$this->user->isAdmin()) {
                     unset($items[$k]);
                     continue;
                 }
             } elseif (!$this->security->isGranted($i['access'], 'MATCH_ONE')) {
                 unset($items[$k]);
                 continue;
             }
         }
         if (isset($i['checks'])) {
             $passChecks = true;
             foreach ($i['checks'] as $checkGroup => $checks) {
                 foreach ($checks as $name => $value) {
                     if ($checkGroup == 'parameters') {
                         if ($this->getParameter($name) != $value) {
                             $passChecks = false;
                             break;
                         }
                     } elseif ($checkGroup == 'request') {
                         if ($this->request->get($name) != $value) {
                             $passChecks = false;
                             break;
                         }
                     }
                 }
             }
             if (!$passChecks) {
                 unset($items[$k]);
                 continue;
             }
         }
         //Set ID to route name
         if (!isset($i['id'])) {
             if (!empty($i['route'])) {
                 $i['id'] = $i['route'];
             } else {
                 $i['id'] = 'menu-item-' . uniqid();
             }
         }
         //Set link attributes
         if (!isset($i['linkAttributes'])) {
             $i['linkAttributes'] = ['data-menu-link' => $i['id'], 'id' => $i['id']];
         } elseif (!isset($i['linkAttributes']['id'])) {
             $i['linkAttributes']['id'] = $i['id'];
             $i['linkAttributes']['data-menu-link'] = $i['id'];
         } elseif (!isset($i['linkAttributes']['data-menu-link'])) {
             $i['linkAttributes']['data-menu-link'] = $i['id'];
         }
         $i['extras'] = [];
         $i['extras']['depth'] = $depth;
         // Note a divider
         if (!empty($i['divider'])) {
             $i['extras']['divider'] = true;
         }
         // Note a header
         if (!empty($i['header'])) {
             $i['extras']['header'] = $i['header'];
         }
         //Set the icon class for the menu item
         if (!empty($i['iconClass'])) {
             $i['extras']['iconClass'] = $i['iconClass'];
         }
         //Set the actual route name so that it's available to the menu template
         if (isset($i['route'])) {
             $i['extras']['routeName'] = $i['route'];
         }
         //Repeat for sub items
         if (isset($i['children'])) {
             $this->createMenuStructure($i['children'], $depth + 1, $defaultPriority);
         }
         // Determine if this item needs to be listed in a bundle outside it's own
         if (isset($i['parent'])) {
             if (!isset($this->orphans[$i['parent']])) {
                 $this->orphans[$i['parent']] = [];
             }
             $this->orphans[$i['parent']][$k] = $i;
             unset($items[$k]);
             // Don't set a default priority here as it'll assume that of it's parent
         } elseif (!isset($i['priority'])) {
             // Ensure a priority for non-orphans
             $i['priority'] = $defaultPriority;
         }
     }
 }