Пример #1
0
 /**
  * @param MauticEvents\GlobalSearchEvent $event
  */
 public function onGlobalSearch(MauticEvents\GlobalSearchEvent $event)
 {
     $str = $event->getSearchString();
     if (empty($str)) {
         return;
     }
     $filter = array("string" => $str, "force" => array());
     $permissions = $this->security->isGranted(array('report:reports:viewown', 'report:reports:viewother'), 'RETURN_ARRAY');
     if ($permissions['report:reports:viewown'] || $permissions['report:reports:viewother']) {
         if (!$permissions['report:reports:viewother']) {
             $filter['force'][] = array('column' => 'IDENTITY(r.createdBy)', 'expr' => 'eq', 'value' => $this->factory->getUser()->getId());
         }
         $items = $this->factory->getModel('report')->getEntities(array('limit' => 5, 'filter' => $filter));
         $count = count($items);
         if ($count > 0) {
             $results = array();
             foreach ($items as $item) {
                 $results[] = $this->templating->renderResponse('MauticReportBundle:SubscribedEvents\\Search:global.html.php', array('item' => $item))->getContent();
             }
             if ($count > 5) {
                 $results[] = $this->templating->renderResponse('MauticReportBundle:SubscribedEvents\\Search:global.html.php', array('showMore' => true, 'searchString' => $str, 'remaining' => $count - 5))->getContent();
             }
             $results['count'] = $count;
             $event->addResults('mautic.report.reports', $results);
         }
     }
 }
Пример #2
0
 /**
  * @param MauticEvents\GlobalSearchEvent $event
  */
 public function onGlobalSearch(MauticEvents\GlobalSearchEvent $event)
 {
     $str = $event->getSearchString();
     if (empty($str)) {
         return;
     }
     $security = $this->security;
     $filter = array("string" => $str, "force" => '');
     $permissions = $security->isGranted(array('form:forms:viewown', 'form:forms:viewother'), 'RETURN_ARRAY');
     if ($permissions['form:forms:viewown'] || $permissions['form:forms:viewother']) {
         //only show own forms if the user does not have permission to view others
         if (!$permissions['form:forms:viewother']) {
             $filter['force'] = array(array('column' => 'f.createdBy', 'expr' => 'eq', 'value' => $this->factory->getUser()->getId()->getId()));
         }
         $forms = $this->factory->getModel('form.form')->getEntities(array('limit' => 5, 'filter' => $filter));
         if (count($forms) > 0) {
             $formResults = array();
             foreach ($forms as $form) {
                 $formResults[] = $this->templating->renderResponse('MauticFormBundle:SubscribedEvents\\Search:global.html.php', array('form' => $form[0]))->getContent();
             }
             if (count($forms) > 5) {
                 $formResults[] = $this->templating->renderResponse('MauticFormBundle:SubscribedEvents\\Search:global.html.php', array('showMore' => true, 'searchString' => $str, 'remaining' => count($forms) - 5))->getContent();
             }
             $formResults['count'] = count($forms);
             $event->addResults('mautic.form.forms', $formResults);
         }
     }
 }
Пример #3
0
 /**
  * @param MauticEvents\GlobalSearchEvent $event
  */
 public function onGlobalSearch(MauticEvents\GlobalSearchEvent $event)
 {
     $str = $event->getSearchString();
     if (empty($str)) {
         return;
     }
     $filter = ['string' => $str, 'force' => []];
     $permissions = $this->security->isGranted(['asset:assets:viewown', 'asset:assets:viewother'], 'RETURN_ARRAY');
     if ($permissions['asset:assets:viewown'] || $permissions['asset:assets:viewother']) {
         if (!$permissions['asset:assets:viewother']) {
             $filter['force'][] = ['column' => 'IDENTITY(a.createdBy)', 'expr' => 'eq', 'value' => $this->factory->getUser()->getId()];
         }
         $assets = $this->assetModel->getEntities(['limit' => 5, 'filter' => $filter]);
         if (count($assets) > 0) {
             $assetResults = [];
             foreach ($assets as $asset) {
                 $assetResults[] = $this->templating->renderResponse('MauticAssetBundle:SubscribedEvents\\Search:global.html.php', ['asset' => $asset])->getContent();
             }
             if (count($assets) > 5) {
                 $assetResults[] = $this->templating->renderResponse('MauticAssetBundle:SubscribedEvents\\Search:global.html.php', ['showMore' => true, 'searchString' => $str, 'remaining' => count($assets) - 5])->getContent();
             }
             $assetResults['count'] = count($assets);
             $event->addResults('mautic.asset.assets', $assetResults);
         }
     }
 }
Пример #4
0
 /**
  * @param MauticEvents\GlobalSearchEvent $event
  */
 public function onGlobalSearch(MauticEvents\GlobalSearchEvent $event)
 {
     $str = $event->getSearchString();
     if (empty($str)) {
         return;
     }
     $anonymous = $this->translator->trans('mautic.lead.lead.searchcommand.isanonymous');
     $mine = $this->translator->trans('mautic.core.searchcommand.ismine');
     $filter = ['string' => $str, 'force' => ''];
     //only show results that are not anonymous so as to not clutter up things
     if (strpos($str, "{$anonymous}") === false) {
         $filter['force'] = " !{$anonymous}";
     }
     $permissions = $this->security->isGranted(['lead:leads:viewown', 'lead:leads:viewother'], 'RETURN_ARRAY');
     if ($permissions['lead:leads:viewown'] || $permissions['lead:leads:viewother']) {
         //only show own leads if the user does not have permission to view others
         if (!$permissions['lead:leads:viewother']) {
             $filter['force'] .= " {$mine}";
         }
         $results = $this->leadModel->getEntities(['limit' => 5, 'filter' => $filter, 'withTotalCount' => true]);
         $count = $results['count'];
         if ($count > 0) {
             $leads = $results['results'];
             $leadResults = [];
             foreach ($leads as $lead) {
                 $leadResults[] = $this->templating->renderResponse('MauticLeadBundle:SubscribedEvents\\Search:global.html.php', ['lead' => $lead])->getContent();
             }
             if ($results['count'] > 5) {
                 $leadResults[] = $this->templating->renderResponse('MauticLeadBundle:SubscribedEvents\\Search:global.html.php', ['showMore' => true, 'searchString' => $str, 'remaining' => $results['count'] - 5])->getContent();
             }
             $leadResults['count'] = $results['count'];
             $event->addResults('mautic.lead.leads', $leadResults);
         }
     }
 }
Пример #5
0
 /**
  * @param MauticEvents\GlobalSearchEvent $event
  */
 public function onGlobalSearch(MauticEvents\GlobalSearchEvent $event)
 {
     if ($this->security->isGranted('point:points:view')) {
         $str = $event->getSearchString();
         if (empty($str)) {
             return;
         }
         $items = $this->factory->getModel('point')->getEntities(array('limit' => 5, 'filter' => $str));
         $pointCount = count($items);
         if ($pointCount > 0) {
             $pointsResults = array();
             $canEdit = $this->security->isGranted('point:points:edit');
             foreach ($items as $item) {
                 $pointsResults[] = $this->templating->renderResponse('MauticPointBundle:SubscribedEvents\\Search:global_point.html.php', array('item' => $item, 'canEdit' => $canEdit))->getContent();
             }
             if ($pointCount > 5) {
                 $pointsResults[] = $this->templating->renderResponse('MauticPointBundle:SubscribedEvents\\Search:global_point.html.php', array('showMore' => true, 'searchString' => $str, 'remaining' => $pointCount - 5))->getContent();
             }
             $pointsResults['count'] = $pointCount;
             $event->addResults('mautic.point.actions.header.index', $pointsResults);
         }
     }
     if ($this->security->isGranted('point:triggers:view')) {
         $str = $event->getSearchString();
         if (empty($str)) {
             return;
         }
         $items = $this->factory->getModel('point.trigger')->getEntities(array('limit' => 5, 'filter' => $str));
         $count = count($items);
         if ($count > 0) {
             $results = array();
             $canEdit = $this->security->isGranted('point:triggers:edit');
             foreach ($items as $item) {
                 $results[] = $this->templating->renderResponse('MauticPointBundle:SubscribedEvents\\Search:global_trigger.html.php', array('item' => $item, 'canEdit' => $canEdit))->getContent();
             }
             if ($count > 5) {
                 $results[] = $this->templating->renderResponse('MauticPointBundle:SubscribedEvents\\Search:global_trigger.html.php', array('showMore' => true, 'searchString' => $str, 'remaining' => $count - 5))->getContent();
             }
             $results['count'] = $count;
             $event->addResults('mautic.point.trigger.header.index', $results);
         }
     }
 }
Пример #6
0
 /**
  * @param MauticEvents\GlobalSearchEvent $event
  */
 public function onGlobalSearch(MauticEvents\GlobalSearchEvent $event)
 {
     if ($this->security->isGranted('campaign:campaigns:view')) {
         $str = $event->getSearchString();
         if (empty($str)) {
             return;
         }
         $campaigns = $this->factory->getModel('campaign')->getEntities(array('limit' => 5, 'filter' => $str));
         if (count($campaigns) > 0) {
             $campaignResults = array();
             foreach ($campaigns as $campaign) {
                 $campaignResults[] = $this->templating->renderResponse('MauticCampaignBundle:SubscribedEvents\\Search:global.html.php', array('campaign' => $campaign))->getContent();
             }
             if (count($campaigns) > 5) {
                 $campaignResults[] = $this->templating->renderResponse('MauticCampaignBundle:SubscribedEvents\\Search:global.html.php', array('showMore' => true, 'searchString' => $str, 'remaining' => count($campaigns) - 5))->getContent();
             }
             $campaignResults['count'] = count($campaigns);
             $event->addResults('mautic.campaign.campaigns', $campaignResults);
         }
     }
 }
Пример #7
0
 /**
  * @param MauticEvents\GlobalSearchEvent $event
  */
 public function onGlobalSearch(MauticEvents\GlobalSearchEvent $event)
 {
     $str = $event->getSearchString();
     if (empty($str)) {
         return;
     }
     /** @var \MauticAddon\MauticChatBundle\Model\ChatModel $model */
     $model = $this->factory->getModel('addon.mauticChat.chat');
     $searchMessages = $model->searchMessages($str);
     if ($searchMessages['count'] > 0) {
         $results = array();
         foreach ($searchMessages['messages'] as $message) {
             $results[] = $this->templating->renderResponse('MauticChatBundle:SubscribedEvents\\Search:global.html.php', array('chat' => $message))->getContent();
         }
         if ($searchMessages['total'] > 30) {
             $results[] = $this->templating->renderResponse('MauticChatBundle:SubscribedEvents\\Search:global.html.php', array('showMore' => true, 'searchString' => $str, 'remaining' => $searchMessages['total'] - $searchMessages['count']))->getContent();
         }
         $results['count'] = $searchMessages['total'];
         $event->addResults('mautic.chat.header.index', $results);
     }
 }
Пример #8
0
 /**
  * @param MauticEvents\GlobalSearchEvent $event
  */
 public function onGlobalSearch(MauticEvents\GlobalSearchEvent $event)
 {
     if ($this->security->isGranted('api:clients:view')) {
         $str = $event->getSearchString();
         if (empty($str)) {
             return;
         }
         $clients = $this->apiClientModel->getEntities(['limit' => 5, 'filter' => $str]);
         if (count($clients) > 0) {
             $clientResults = [];
             $canEdit = $this->security->isGranted('api:clients:edit');
             foreach ($clients as $client) {
                 $clientResults[] = $this->templating->renderResponse('MauticApiBundle:SubscribedEvents\\Search:global.html.php', ['client' => $client, 'canEdit' => $canEdit])->getContent();
             }
             if (count($clients) > 5) {
                 $clientResults[] = $this->templating->renderResponse('MauticApiBundle:SubscribedEvents\\Search:global.html.php', ['showMore' => true, 'searchString' => $str, 'remaining' => count($clients) - 5])->getContent();
             }
             $clientResults['count'] = count($clients);
             $event->addResults('mautic.api.client.menu.index', $clientResults);
         }
     }
 }
Пример #9
0
 /**
  * @param MauticEvents\GlobalSearchEvent $event
  */
 public function onGlobalSearch(MauticEvents\GlobalSearchEvent $event)
 {
     if ($this->security->isGranted('stage:stages:view')) {
         $str = $event->getSearchString();
         if (empty($str)) {
             return;
         }
         $items = $this->stageModel->getEntities(['limit' => 5, 'filter' => $str]);
         $stageCount = count($items);
         if ($stageCount > 0) {
             $stagesResults = [];
             $canEdit = $this->security->isGranted('stage:stages:edit');
             foreach ($items as $item) {
                 $stagesResults[] = $this->templating->renderResponse('MauticStageBundle:SubscribedEvents\\Search:global.html.php', ['item' => $item, 'canEdit' => $canEdit])->getContent();
             }
             if ($stageCount > 5) {
                 $stagesResults[] = $this->templating->renderResponse('MauticStageBundle:SubscribedEvents\\Search:global.html.php', ['showMore' => true, 'searchString' => $str, 'remaining' => $stageCount - 5])->getContent();
             }
             $stagesResults['count'] = $stageCount;
             $event->addResults('mautic.stage.actions.header.index', $stagesResults);
         }
     }
 }
Пример #10
0
 public function onGlobalSearch(MauticEvents\GlobalSearchEvent $event)
 {
     $str = $event->getSearchString();
     if (empty($str)) {
         return;
     }
     if ($this->security->isGranted('user:users:view')) {
         $users = $this->factory->getModel('user.user')->getEntities(array('limit' => 5, 'filter' => $str));
         if (count($users) > 0) {
             $userResults = array();
             $canEdit = $this->security->isGranted('user:users:edit');
             foreach ($users as $user) {
                 $userResults[] = $this->templating->renderResponse('MauticUserBundle:SubscribedEvents\\Search:global_user.html.php', array('user' => $user, 'canEdit' => $canEdit))->getContent();
             }
             if (count($users) > 5) {
                 $userResults[] = $this->templating->renderResponse('MauticUserBundle:SubscribedEvents\\Search:global_user.html.php', array('showMore' => true, 'searchString' => $str, 'remaining' => count($users) - 5))->getContent();
             }
             $userResults['count'] = count($users);
             $event->addResults('mautic.user.users', $userResults);
         }
     }
     if ($this->security->isGranted('user:roles:view')) {
         $roles = $this->factory->getModel('user.role')->getEntities(array('limit' => 5, 'filter' => $str));
         if (count($roles)) {
             $roleResults = array();
             $canEdit = $this->security->isGranted('user:roles:edit');
             foreach ($roles as $role) {
                 $roleResults[] = $this->templating->renderResponse('MauticUserBundle:SubscribedEvents\\Search:global_role.html.php', array('role' => $role, 'canEdit' => $canEdit))->getContent();
             }
             if (count($roles) > 5) {
                 $roleResults[] = $this->templating->renderResponse('MauticUserBundle:SubscribedEvents\\Search:global_role.html.php', array('showMore' => true, 'searchString' => $str, 'remaining' => count($roles) - 5))->getContent();
             }
             $roleResults['count'] = count($roles);
             $event->addResults('mautic.user.roles', $roleResults);
         }
     }
 }