Example #1
0
 /**
  * Add a delete entry to the audit log.
  *
  * @param Events\AssetEvent $event
  */
 public function onAssetDelete(Events\AssetEvent $event)
 {
     $asset = $event->getAsset();
     $log = ['bundle' => 'asset', 'object' => 'asset', 'objectId' => $asset->deletedId, 'action' => 'delete', 'details' => ['name' => $asset->getTitle()], 'ipAddress' => $this->ipLookupHelper->getIpAddressFromRequest()];
     $this->auditLogModel->writeToLog($log);
     //In case of batch delete, this method call remove the uploaded file
     $asset->removeUpload();
 }
 /**
  * Set a widget detail when needed.
  *
  * @param WidgetDetailEvent $event
  */
 public function onWidgetDetailGenerate(WidgetDetailEvent $event)
 {
     if ($event->getType() == 'recent.activity') {
         if (!$event->isCached()) {
             $height = $event->getWidget()->getHeight();
             $limit = round(($height - 80) / 75);
             $logs = $this->auditLogModel->getLogForObject(null, null, null, $limit);
             // Get names of log's items
             foreach ($logs as $key => &$log) {
                 if (!empty($log['bundle']) && !empty($log['object']) && !empty($log['objectId'])) {
                     try {
                         $model = $this->factory->getModel($log['bundle'] . '.' . $log['object']);
                         $item = $model->getEntity($log['objectId']);
                         if (method_exists($item, $model->getNameGetter())) {
                             $log['objectName'] = $item->{$model->getNameGetter()}();
                             if ($log['bundle'] == 'lead' && $log['objectName'] == 'mautic.lead.lead.anonymous') {
                                 $log['objectName'] = $this->translator->trans('mautic.lead.lead.anonymous');
                             }
                         } else {
                             $log['objectName'] = '';
                         }
                         $routeName = 'mautic_' . $log['bundle'] . '_action';
                         if ($this->router->getRouteCollection()->get($routeName) !== null) {
                             $log['route'] = $this->router->generate('mautic_' . $log['bundle'] . '_action', ['objectAction' => 'view', 'objectId' => $log['objectId']]);
                         } else {
                             $log['route'] = false;
                         }
                     } catch (\Exception $e) {
                         unset($logs[$key]);
                     }
                 }
             }
             $iconEvent = new IconEvent($this->security);
             $this->dispatcher->dispatch(CoreEvents::FETCH_ICONS, $iconEvent);
             $event->setTemplateData(['logs' => $logs, 'icons' => $iconEvent->getIcons()]);
         }
         $event->setTemplate('MauticDashboardBundle:Dashboard:recentactivity.html.php');
         $event->stopPropagation();
     }
 }
Example #3
0
 /**
  * @param Events\LeadTimelineEvent $event
  * @param                          $eventTypeKey
  * @param                          $eventTypeName
  */
 protected function addTimelineIpAddressEntries(Events\LeadTimelineEvent $event, $eventTypeKey, $eventTypeName)
 {
     $lead = $event->getLead();
     $rows = $this->auditLogModel->getRepository()->getLeadIpLogs($lead, $event->getQueryOptions());
     if (!$event->isEngagementCount()) {
         // Add to counter
         $event->addToCounter($eventTypeKey, $rows);
         // Add the entries to the event array
         /** @var \Mautic\CoreBundle\Entity\AuditLog $row */
         $ipAddresses = $lead->getIpAddresses()->toArray();
         foreach ($rows['results'] as $row) {
             if (!isset($ipAddresses[$row['ip_address']])) {
                 continue;
             }
             $event->addEvent(['event' => $eventTypeKey, 'eventLabel' => $row['ip_address'], 'eventType' => $eventTypeName, 'eventPriority' => -1, 'timestamp' => $row['date_added'], 'extra' => ['ipDetails' => $ipAddresses[$row['ip_address']]], 'contentTemplate' => 'MauticLeadBundle:SubscribedEvents\\Timeline:ipadded.html.php']);
         }
     } else {
         // Purposively not including this in engagements graph as it's info only
     }
 }
Example #4
0
 /**
  * Add a delete entry to the audit log.
  *
  * @param SmsEvent $event
  */
 public function onDelete(SmsEvent $event)
 {
     $entity = $event->getSms();
     $log = ['bundle' => 'sms', 'object' => 'sms', 'objectId' => $entity->deletedId, 'action' => 'delete', 'details' => ['name' => $entity->getName()]];
     $this->auditLogModel->writeToLog($log);
 }
 /**
  * Add a delete entry to the audit log.
  *
  * @param NotificationEvent $event
  */
 public function onDelete(NotificationEvent $event)
 {
     $entity = $event->getNotification();
     $log = ['bundle' => 'notification', 'object' => 'notification', 'objectId' => $entity->getId(), 'action' => 'delete', 'details' => ['name' => $entity->getName()]];
     $this->auditLogModel->writeToLog($log);
 }
Example #6
0
 /**
  * Add a delete entry to the audit log.
  *
  * @param Events\EmailEvent $event
  */
 public function onEmailDelete(Events\EmailEvent $event)
 {
     $email = $event->getEmail();
     $log = ['bundle' => 'email', 'object' => 'email', 'objectId' => $email->deletedId, 'action' => 'delete', 'details' => ['name' => $email->getName()], 'ipAddress' => $this->ipLookupHelper->getIpAddressFromRequest()];
     $this->auditLogModel->writeToLog($log);
 }
 /**
  * Add a delete entry to the audit log.
  *
  * @param Events\DynamicContentEvent $event
  */
 public function onDelete(Events\DynamicContentEvent $event)
 {
     $entity = $event->getDynamicContent();
     $log = ['bundle' => 'dynamicContent', 'object' => 'dynamicContent', 'objectId' => $entity->getId(), 'action' => 'delete', 'details' => ['name' => $entity->getName()]];
     $this->auditLogModel->writeToLog($log);
 }
Example #8
0
 /**
  * Add a role delete entry to the audit log.
  *
  * @param Events\ClientEvent $event
  */
 public function onClientDelete(Events\ClientEvent $event)
 {
     $client = $event->getClient();
     $log = ['bundle' => 'api', 'object' => 'client', 'objectId' => $client->deletedId, 'action' => 'delete', 'details' => ['name' => $client->getName()], 'ipAddress' => $this->ipLookupHelper->getIpAddressFromRequest()];
     $this->auditLogModel->writeToLog($log);
 }
Example #9
0
 /**
  * Add a company delete entry to the audit log.
  *
  * @param Events\CompanyEvent $event
  */
 public function onCompanyDelete(Events\CompanyEvent $event)
 {
     $company = $event->getCompany();
     $log = ['bundle' => 'lead', 'object' => 'field', 'objectId' => $company->deletedId, 'action' => 'delete', 'details' => ['name', $company->getPrimaryIdentifier()], 'ipAddress' => $this->ipLookupHelper->getIpAddressFromRequest()];
     $this->auditLogModel->writeToLog($log);
 }
Example #10
0
 /**
  * Add a delete entry to the audit log.
  *
  * @param Events\CategoryEvent $event
  */
 public function onCategoryDelete(Events\CategoryEvent $event)
 {
     $category = $event->getCategory();
     $log = ['bundle' => 'category', 'object' => 'category', 'objectId' => $category->deletedId, 'action' => 'delete', 'details' => ['name' => $category->getTitle()], 'ipAddress' => $this->ipLookupHelper->getIpAddressFromRequest()];
     $this->auditLogModel->writeToLog($log);
 }
Example #11
0
 /**
  * Add a delete entry to the audit log.
  *
  * @param Events\PageEvent $event
  */
 public function onPageDelete(Events\PageEvent $event)
 {
     $page = $event->getPage();
     $log = ['bundle' => 'page', 'object' => 'page', 'objectId' => $page->deletedId, 'action' => 'delete', 'details' => ['name' => $page->getTitle()], 'ipAddress' => $this->ipLookupHelper->getIpAddressFromRequest()];
     $this->auditLogModel->writeToLog($log);
 }
Example #12
0
 /**
  * Add a role delete entry to the audit log.
  *
  * @param Events\RoleEvent $event
  */
 public function onRoleDelete(Events\RoleEvent $event)
 {
     $role = $event->getRole();
     $log = ['bundle' => 'user', 'object' => 'role', 'objectId' => $role->deletedId, 'action' => 'delete', 'details' => ['name' => $role->getName()], 'ipAddress' => $this->ipLookupHelper->getIpAddressFromRequest()];
     $this->auditLogModel->writeToLog($log);
 }
Example #13
0
 /**
  * Add a delete entry to the audit log.
  *
  * @param Events\TriggerEvent $event
  */
 public function onTriggerDelete(Events\TriggerEvent $event)
 {
     $trigger = $event->getTrigger();
     $log = ['bundle' => 'point', 'object' => 'trigger', 'objectId' => $trigger->deletedId, 'action' => 'delete', 'details' => ['name' => $trigger->getName()], 'ipAddress' => $this->ipLookupHelper->getIpAddressFromRequest()];
     $this->auditLogModel->writeToLog($log);
 }
Example #14
0
 /**
  * Add a delete entry to the audit log.
  *
  * @param WebhookEvent $event
  */
 public function onWebhookDelete(WebhookEvent $event)
 {
     $webhook = $event->getWebhook();
     $log = ['bundle' => 'webhook', 'object' => 'webhook', 'objectId' => $event->getWebhook()->deletedId, 'action' => 'delete', 'details' => ['name' => $webhook->getName()], 'ipAddress' => $this->ipLookupHelper->getIpAddressFromRequest()];
     $this->auditLogModel->writeToLog($log);
 }
Example #15
0
 /**
  * Add a delete entry to the audit log.
  *
  * @param ReportEvent $event
  */
 public function onReportDelete(ReportEvent $event)
 {
     $report = $event->getReport();
     $log = ['bundle' => 'report', 'object' => 'report', 'objectId' => $report->deletedId, 'action' => 'delete', 'details' => ['name' => $report->getName()], 'ipAddress' => $this->ipLookupHelper->getIpAddressFromRequest()];
     $this->auditLogModel->writeToLog($log);
 }
Example #16
0
 /**
  * Add a delete entry to the audit log.
  *
  * @param Events\FormEvent $event
  */
 public function onFormDelete(Events\FormEvent $event)
 {
     $form = $event->getForm();
     $log = ['bundle' => 'form', 'object' => 'form', 'objectId' => $form->deletedId, 'action' => 'delete', 'details' => ['name' => $form->getName()], 'ipAddress' => $this->ipLookupHelper->getIpAddressFromRequest()];
     $this->auditLogModel->writeToLog($log);
 }
Example #17
0
 /**
  * Add a delete entry to the audit log.
  *
  * @param FocusEvent $event
  */
 public function onFocusDelete(FocusEvent $event)
 {
     $entity = $event->getFocus();
     $log = ['bundle' => 'focus', 'object' => 'focus', 'objectId' => $entity->deletedId, 'action' => 'delete', 'details' => ['name' => $entity->getName()], 'ipAddress' => $this->ipHelper->getIpAddressFromRequest()];
     $this->auditLogModel->writeToLog($log);
 }