/** * @param int $page * * @return string */ public function getTokenContent($page = 1) { if (!$this->factory->getSecurity()->isGranted('lead:fields:full')) { return; } $session = $this->factory->getSession(); //set limits $limit = 5; $start = $page === 1 ? 0 : ($page - 1) * $limit; if ($start < 0) { $start = 0; } $request = $this->factory->getRequest(); $search = $request->get('search', $session->get('mautic.lead.emailtoken.filter', '')); $session->set('mautic.lead.emailtoken.filter', $search); $filter = array('string' => $search, 'force' => array(array('column' => 'f.isPublished', 'expr' => 'eq', 'value' => true))); $fields = $this->factory->getModel('lead.field')->getEntities(array('start' => $start, 'limit' => $limit, 'filter' => $filter, 'orderBy' => 'f.label', 'orderByDir' => 'ASC', 'hydration_mode' => 'HYDRATE_ARRAY')); $count = count($fields); if ($count && $count < $start + 1) { //the number of entities are now less then the current page so redirect to the last page if ($count === 1) { $page = 1; } else { $page = ceil($count / $limit) ?: 1; } $session->set('mautic.lead.emailtoken.page', $page); } return $this->factory->getTemplating()->render('MauticLeadBundle:SubscribedEvents\\EmailToken:list.html.php', array('items' => $fields, 'page' => $page, 'limit' => $limit, 'totalCount' => $count, 'tmpl' => $request->get('tmpl', 'index'), 'searchValue' => $search)); }
/** * @param string $tokenRegex Token regex without wrapping regex escape characters. Use (value) or (.*?) where the ID of the * entity should go. i.e. {pagelink=(value)} * @param string $filter String to filter results by * @param string $labelColumn The column that houses the label * @param string $valueColumn The column that houses the value * @param CompositeExpression $expr Use $factory->getDatabase()->getExpressionBuilder()->andX() * * @return array|void */ public function getTokens($tokenRegex, $filter = '', $labelColumn = 'name', $valueColumn = 'id', CompositeExpression $expr = null) { //set some permissions $permissions = $this->factory->getSecurity()->isGranted($this->permissionSet, "RETURN_ARRAY"); if (in_array(false, $permissions)) { return; } $repo = $this->factory->getModel($this->modelName)->getRepository(); $prefix = $repo->getTableAlias(); if (!empty($prefix)) { $prefix .= '.'; } $exprBuilder = $this->factory->getDatabase()->getExpressionBuilder(); if ($expr == null) { $expr = $exprBuilder->andX(); } if (isset($permissions[$this->viewPermissionBase . ':viewother']) && !$permissions[$this->viewPermissionBase . ':viewother']) { $expr->add($exprBuilder->eq($prefix . 'createdBy', $this->factory->getUser()->getId())); } if (!empty($filter)) { $expr->add($exprBuilder->like('LOWER(' . $labelColumn . ')', ':label')); $parameters = array('label' => strtolower($filter) . '%'); } else { $parameters = array(); } $items = $repo->getSimpleList($expr, $parameters, $labelColumn, $valueColumn); $tokens = array(); foreach ($items as $item) { $token = str_replace(array('(value)', '(.*?)'), $item['value'], $tokenRegex); $tokens[$token] = $item['label']; } return $tokens; }
/** * @param MauticFactory $factory */ public function __construct(MauticFactory $factory) { $this->translator = $factory->getTranslator(); /** @var \Mautic\LeadBundle\Model\ListModel $listModel */ $listModel = $factory->getModel('lead.list'); $this->fieldChoices = $listModel->getChoiceFields(); // Locales $this->timezoneChoices = FormFieldHelper::getTimezonesChoices(); $this->countryChoices = FormFieldHelper::getCountryChoices(); $this->regionChoices = FormFieldHelper::getRegionChoices(); // Segments $lists = $listModel->getUserLists(); foreach ($lists as $list) { $this->listChoices[$list['id']] = $list['name']; } // Emails /** @var \Mautic\EmailBundle\Model\EmailModel $emailModel */ $emailModel = $factory->getModel('email'); $viewOther = $factory->getSecurity()->isGranted('email:emails:viewother'); $emails = $emailModel->getRepository()->getEmailList('', 0, 0, $viewOther, true); foreach ($emails as $email) { $this->emailChoices[$email['language']][$email['id']] = $email['name']; } ksort($this->emailChoices); // Tags $leadModel = $factory->getModel('lead'); $tags = $leadModel->getTagList(); foreach ($tags as $tag) { $this->tagChoices[$tag['value']] = $tag['label']; } }
/** * @param MauticFactory $factory */ public function __construct(MauticFactory $factory) { $this->translator = $factory->getTranslator(); $this->em = $factory->getEntityManager(); $this->model = $factory->getModel('page'); $this->canViewOther = $factory->getSecurity()->isGranted('page:pages:viewother'); $this->user = $factory->getUser(); }
/** * @param MauticFactory $factory */ public function __construct(MauticFactory $factory) { $this->em = $factory->getEntityManager(); $this->security = $factory->getSecurity(); $this->dispatcher = $factory->getDispatcher(); $this->translator = $factory->getTranslator(); $this->factory = $factory; }
/** * Generates access denied message * * @param bool $batch Flag if a batch action is being performed * @param string $msg Message that is logged * * @return JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse|array * @throws AccessDeniedHttpException */ public function accessDenied($batch = false, $msg = 'mautic.core.url.error.401') { $anonymous = $this->factory->getSecurity()->isAnonymous(); if ($anonymous || !$batch) { throw new AccessDeniedHttpException($this->factory->getTranslator()->trans($msg, array('%url%' => $this->request->getRequestUri()))); } if ($batch) { return array('type' => 'error', 'msg' => $this->factory->getTranslator()->trans('mautic.core.error.accessdenied', array(), 'flashes')); } }
/** * @param MauticFactory $factory */ public function __construct(MauticFactory $factory) { $viewOther = $factory->getSecurity()->isGranted('asset:assets:viewother'); $choices = $factory->getModel('asset')->getRepository()->getAssetList('', 0, 0, $viewOther); foreach ($choices as $asset) { $this->choices[$asset['language']][$asset['id']] = $asset['title']; } //sort by language ksort($this->choices); }
/** * @param MauticFactory $factory */ public function __construct(MauticFactory $factory) { $this->factory = $factory; $this->templating = $factory->getTemplating(); $this->request = $factory->getRequest(); $this->security = $factory->getSecurity(); $this->serializer = $factory->getSerializer(); $this->params = $factory->getSystemParameters(); $this->dispatcher = $factory->getDispatcher(); $this->translator = $factory->getTranslator(); $this->init(); }
/** * @param MauticFactory $factory */ public function __construct(MauticFactory $factory) { $this->translator = $factory->getTranslator(); $this->security = $factory->getSecurity(); }
/** * @param MauticFactory $factory */ public function __construct(MauticFactory $factory) { $this->viewOther = $factory->getSecurity()->isGranted('email:emails:viewother'); $this->repo = $factory->getModel('email')->getRepository(); }
/** * @param MauticFactory $factory */ public function __construct(MauticFactory $factory) { $this->viewOther = $factory->getSecurity()->isGranted('dynamicContent:dynamicContents:viewother'); $this->repo = $factory->getModel('dynamicContent')->getRepository(); $this->repo->setCurrentUser($factory->getUser()); }
/** * @return mixed */ protected function getSecurity() { return $this->factory->getSecurity(); }
/** * Initialize some variables * * @param FilterControllerEvent $event * * @return void */ public function initialize(FilterControllerEvent $event) { $this->security = $this->factory->getSecurity(); }
/** * @param $permission * * @return mixed */ public function isGranted($permission) { return $this->factory->getSecurity()->isGranted($permission); }
/** * @param MauticFactory $factory */ public function __construct(MauticFactory $factory) { $this->model = $factory->getModel('page'); $this->canViewOther = $factory->getSecurity()->isGranted('page:pages:viewother'); }
/** * @param MauticFactory $factory */ public function __construct(MauticFactory $factory) { $this->em = $factory->getEntityManager(); $this->mauticSecurity = $factory->getSecurity(); $this->translator = $factory->getTranslator(); }