/**
  * Convert emoji unicode to HTML
  *
  * @param array|string $content
  *
  * @return string|array
  */
 public function transform($content)
 {
     if (is_array($content)) {
         foreach ($content as &$convert) {
             $convert = $this->transform($convert);
         }
     } else {
         $content = EmojiHelper::toHtml($content);
     }
     return $content;
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function getPublicActivity($identifier, &$socialCache)
 {
     if ($id = $this->getUserId($identifier, $socialCache)) {
         //due to the way Twitter filters, get more than 10 tweets
         $data = $this->makeRequest($this->getApiUrl("/statuses/user_timeline"), array('user_id' => $id, 'exclude_replies' => 'true', 'count' => 25, 'trim_user' => 'true'));
         if (!empty($data) && count($data)) {
             $socialCache['has']['activity'] = true;
             $socialCache['activity'] = array('tweets' => array(), 'photos' => array(), 'tags' => array());
             foreach ($data as $k => $d) {
                 if ($k == 10) {
                     break;
                 }
                 $tweet = array('tweet' => EmojiHelper::toHtml($d['text']), 'url' => "https://twitter.com/{$id}/status/{$d['id']}", 'coordinates' => $d['coordinates'], 'published' => $d['created_at']);
                 $socialCache['activity']['tweets'][] = $tweet;
                 //images
                 if (isset($d['entities']['media'])) {
                     foreach ($d['entities']['media'] as $m) {
                         if ($m['type'] == 'photo') {
                             $photo = array('url' => isset($m['media_url_https']) ? $m['media_url_https'] : $m['media_url']);
                             $socialCache['activity']['photos'][] = $photo;
                         }
                     }
                 }
                 //hastags
                 if (isset($d['entities']['hashtags'])) {
                     foreach ($d['entities']['hashtags'] as $h) {
                         if (isset($socialCache['activity']['tags'][$h['text']])) {
                             $socialCache['activity']['tags'][$h['text']]['count']++;
                         } else {
                             $socialCache['activity']['tags'][$h['text']] = array('count' => 1, 'url' => 'https://twitter.com/search?q=%23' . $h['text']);
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * @param int $objectId
  *
  * @return JsonResponse
  */
 protected function emailAction($objectId = 0)
 {
     $valid = $cancelled = false;
     /** @var \Mautic\LeadBundle\Model\LeadModel $model */
     $model = $this->factory->getModel('lead');
     /** @var \Mautic\LeadBundle\Entity\Lead $lead */
     $lead = $model->getEntity($objectId);
     if ($lead === null || !$this->factory->getSecurity()->hasEntityAccess('lead:leads:viewown', 'lead:leads:viewother', $lead->getOwner())) {
         return $this->modalAccessDenied();
     }
     $leadFields = $model->flattenFields($lead->getFields());
     $leadFields['id'] = $lead->getId();
     $leadEmail = $leadFields['email'];
     $leadName = $leadFields['firstname'] . ' ' . $leadFields['lastname'];
     $inList = $this->request->getMethod() == 'GET' ? $this->request->get('list', 0) : $this->request->request->get('lead_quickemail[list]', 0, true);
     $email = array('list' => $inList);
     $action = $this->generateUrl('mautic_lead_action', array('objectAction' => 'email', 'objectId' => $objectId));
     $form = $this->get('form.factory')->create('lead_quickemail', $email, array('action' => $action));
     if ($this->request->getMethod() == 'POST') {
         $valid = false;
         if (!($cancelled = $this->isFormCancelled($form))) {
             if ($valid = $this->isFormValid($form)) {
                 $email = $form->getData();
                 $bodyCheck = trim(strip_tags($email['body']));
                 if (!empty($bodyCheck)) {
                     $mailer = $this->factory->getMailer();
                     // To lead
                     $mailer->addTo($leadEmail, $leadName);
                     // From user
                     $user = $this->factory->getUser();
                     $mailer->setFrom($email['from'], strtolower($user->getEmail()) !== strtolower($email['from']) ? null : $user->getFirstName() . ' ' . $user->getLastName());
                     // Set Content
                     BuilderTokenHelper::replaceVisualPlaceholdersWithTokens($email['body']);
                     $mailer->setBody($email['body']);
                     $mailer->parsePlainText($email['body']);
                     // Set lead
                     $mailer->setLead($leadFields);
                     $mailer->setIdHash();
                     $mailer->setSubject($email['subject']);
                     // Ensure safe emoji for notification
                     $subject = EmojiHelper::toHtml($email['subject']);
                     if ($mailer->send(true)) {
                         $mailer->createLeadEmailStat();
                         $this->addFlash('mautic.lead.email.notice.sent', array('%subject%' => $subject, '%email%' => $leadEmail));
                     } else {
                         $this->addFlash('mautic.lead.email.error.failed', array('%subject%' => $subject, '%email%' => $leadEmail));
                         $valid = false;
                     }
                 } else {
                     $form['body']->addError(new FormError($this->get('translator')->trans('mautic.lead.email.body.required', array(), 'validators')));
                     $valid = false;
                 }
             }
         }
     }
     if (empty($leadEmail) || $valid || $cancelled) {
         if ($inList) {
             $route = 'mautic_lead_index';
             $viewParameters = array('page' => $this->factory->getSession()->get('mautic.lead.page', 1));
             $func = 'index';
         } else {
             $route = 'mautic_lead_action';
             $viewParameters = array('objectAction' => 'view', 'objectId' => $objectId);
             $func = 'view';
         }
         return $this->postActionRedirect(array('returnUrl' => $this->generateUrl($route, $viewParameters), 'viewParameters' => $viewParameters, 'contentTemplate' => 'MauticLeadBundle:Lead:' . $func, 'passthroughVars' => array('mauticContent' => 'lead', 'closeModal' => 1)));
     }
     return $this->ajaxAction(array('contentTemplate' => 'MauticLeadBundle:Lead:email.html.php', 'viewParameters' => array('form' => $form->createView()), 'passthroughVars' => array('mauticContent' => 'leadEmail', 'route' => false)));
 }
Ejemplo n.º 4
0
$percent = $progress[1] ? ceil($progress[0] / $progress[1] * 100) : 100;
$id = $status != 'inprogress' ? 'emailSendProgressComplete' : 'emailSendProgress';
?>

<div class="row ma-lg email-send-progress" id="<?php 
echo $id;
?>
">
    <div class="col-sm-offset-3 col-sm-6 text-center">
        <div class="panel panel-<?php 
echo $status != 'inprogress' ? 'success' : 'danger';
?>
">
            <div class="panel-heading">
                <h4 class="panel-title"><?php 
echo $view['translator']->trans('mautic.email.send.' . $status, ['%subject%' => \Mautic\CoreBundle\Helper\EmojiHelper::toHtml($email->getSubject(), 'short')]);
?>
</h4>
            </div>
            <div class="panel-body">
                <?php 
if ($status != 'inprogress') {
    ?>
                <h4><?php 
    echo $view['translator']->trans('mautic.email.send.stats', ['%sent%' => $stats['sent'], '%failed%' => $stats['failed']]);
    ?>
</h4>
                <?php 
}
?>
                <div class="progress mt-md" style="height:50px;">
Ejemplo n.º 5
0
 /**
  * Write a notification.
  *
  * @param string    $message   Message of the notification
  * @param string    $type      Optional $type to ID the source of the notification
  * @param bool|true $isRead    Add unread indicator
  * @param string    $header    Header for message
  * @param string    $iconClass Font Awesome CSS class for the icon (e.g. fa-eye)
  * @param \DateTime $datetime  Date the item was created
  * @param User|null $user      User object; defaults to current user
  */
 public function addNotification($message, $type = null, $isRead = false, $header = null, $iconClass = null, \DateTime $datetime = null, User $user = null)
 {
     if ($user === null) {
         $user = $this->userHelper->getUser();
     }
     if ($user === null || !$user->getId()) {
         //ensure notifications aren't written for non users
         return;
     }
     $notification = new Notification();
     $notification->setType($type);
     $notification->setIsRead($isRead);
     $notification->setHeader(EmojiHelper::toHtml(InputHelper::html($header)));
     $notification->setMessage(EmojiHelper::toHtml(InputHelper::html($message)));
     $notification->setIconClass($iconClass);
     $notification->setUser($user);
     if ($datetime == null) {
         $datetime = new \DateTime();
     }
     $notification->setDateAdded($datetime);
     $this->saveEntity($notification);
 }
Ejemplo n.º 6
0
 /**
  * @param int $objectId
  *
  * @return JsonResponse
  */
 public function emailAction($objectId = 0)
 {
     $valid = $cancelled = false;
     /** @var \Mautic\LeadBundle\Model\LeadModel $model */
     $model = $this->getModel('lead');
     /** @var \Mautic\LeadBundle\Entity\Lead $lead */
     $lead = $model->getEntity($objectId);
     if ($lead === null || !$this->get('mautic.security')->hasEntityAccess('lead:leads:viewown', 'lead:leads:viewother', $lead->getPermissionUser())) {
         return $this->modalAccessDenied();
     }
     $leadFields = $lead->getProfileFields();
     $leadFields['id'] = $lead->getId();
     $leadEmail = $leadFields['email'];
     $leadName = $leadFields['firstname'] . ' ' . $leadFields['lastname'];
     // Set onwer ID to be the current user ID so it will use his signature
     $leadFields['owner_id'] = $this->get('mautic.helper.user')->getUser()->getId();
     // Check if lead has a bounce status
     /** @var \Mautic\EmailBundle\Model\EmailModel $emailModel */
     $emailModel = $this->getModel('email');
     $dnc = $emailModel->getRepository()->checkDoNotEmail($leadEmail);
     $inList = $this->request->getMethod() == 'GET' ? $this->request->get('list', 0) : $this->request->request->get('lead_quickemail[list]', 0, true);
     $email = ['list' => $inList];
     $action = $this->generateUrl('mautic_contact_action', ['objectAction' => 'email', 'objectId' => $objectId]);
     $form = $this->get('form.factory')->create('lead_quickemail', $email, ['action' => $action]);
     if ($this->request->getMethod() == 'POST') {
         $valid = false;
         if (!($cancelled = $this->isFormCancelled($form))) {
             if ($valid = $this->isFormValid($form)) {
                 $email = $form->getData();
                 $bodyCheck = trim(strip_tags($email['body']));
                 if (!empty($bodyCheck)) {
                     $mailer = $this->get('mautic.helper.mailer')->getMailer();
                     // To lead
                     $mailer->addTo($leadEmail, $leadName);
                     // From user
                     $user = $this->get('mautic.helper.user')->getUser();
                     $mailer->setFrom($email['from'], empty($email['fromname']) ? '' : $email['fromname']);
                     // Set Content
                     BuilderTokenHelper::replaceVisualPlaceholdersWithTokens($email['body']);
                     $mailer->setBody($email['body']);
                     $mailer->parsePlainText($email['body']);
                     // Set lead
                     $mailer->setLead($leadFields);
                     $mailer->setIdHash();
                     $mailer->setSubject($email['subject']);
                     // Ensure safe emoji for notification
                     $subject = EmojiHelper::toHtml($email['subject']);
                     if ($mailer->send(true, false, false)) {
                         $mailer->createEmailStat();
                         $this->addFlash('mautic.lead.email.notice.sent', ['%subject%' => $subject, '%email%' => $leadEmail]);
                     } else {
                         $errors = $mailer->getErrors();
                         // Unset the array of failed email addresses
                         if (isset($errors['failures'])) {
                             unset($errors['failures']);
                         }
                         $form->addError(new FormError($this->get('translator')->trans('mautic.lead.email.error.failed', ['%subject%' => $subject, '%email%' => $leadEmail, '%error%' => is_array($errors) ? implode('<br />', $errors) : $errors], 'flashes')));
                         $valid = false;
                     }
                 } else {
                     $form['body']->addError(new FormError($this->get('translator')->trans('mautic.lead.email.body.required', [], 'validators')));
                     $valid = false;
                 }
             }
         }
     }
     if (empty($leadEmail) || $valid || $cancelled) {
         if ($inList) {
             $route = 'mautic_contact_index';
             $viewParameters = ['page' => $this->get('session')->get('mautic.lead.page', 1)];
             $func = 'index';
         } else {
             $route = 'mautic_contact_action';
             $viewParameters = ['objectAction' => 'view', 'objectId' => $objectId];
             $func = 'view';
         }
         return $this->postActionRedirect(['returnUrl' => $this->generateUrl($route, $viewParameters), 'viewParameters' => $viewParameters, 'contentTemplate' => 'MauticLeadBundle:Lead:' . $func, 'passthroughVars' => ['mauticContent' => 'lead', 'closeModal' => 1]]);
     }
     return $this->ajaxAction(['contentTemplate' => 'MauticLeadBundle:Lead:email.html.php', 'viewParameters' => ['form' => $form->createView(), 'dnc' => $dnc], 'passthroughVars' => ['mauticContent' => 'leadEmail', 'route' => false]]);
 }
Ejemplo n.º 7
0
$customButtons[] = array('attr' => array('data-toggle' => 'ajax', 'href' => $view['router']->generate('mautic_email_action', array('objectAction' => 'example', 'objectId' => $email->getId()))), 'iconClass' => 'fa fa-send', 'btnText' => 'mautic.email.send.example');
$customButtons[] = array('attr' => array('data-toggle' => 'ajax', 'href' => $view['router']->generate('mautic_email_action', array("objectAction" => "clone", "objectId" => $email->getId()))), 'iconClass' => 'fa fa-copy', 'btnText' => 'mautic.core.form.clone');
$view['slots']->set('actions', $view->render('MauticCoreBundle:Helper:page_actions.html.php', array('item' => $email, 'templateButtons' => array('edit' => $edit, 'delete' => $security->hasEntityAccess($permissions['email:emails:deleteown'], $permissions['email:emails:deleteother'], $email->getCreatedBy()), 'abtest' => !$isVariant && $edit && $permissions['email:emails:create']), 'routeBase' => 'email', 'preCustomButtons' => $customButtons)));
?>

<!-- start: box layout -->
<div class="box-layout">
    <!-- left section -->
    <div class="col-md-9 bg-white height-auto">
        <div class="bg-auto">
            <!-- email detail header -->
            <div class="pr-md pl-md pt-lg pb-lg">
                <div class="box-layout">
                    <div class="col-xs-10">
                        <div><?php 
echo \Mautic\CoreBundle\Helper\EmojiHelper::toHtml($email->getSubject(), 'short');
?>
</div>
                        <div class="text-muted"><?php 
echo $email->getDescription();
?>
</div>
                    </div>
                    <div class="col-xs-2 text-right">
                        <?php 
echo $view->render('MauticCoreBundle:Helper:publishstatus_badge.html.php', array('entity' => $email));
?>
                    </div>
                </div>
            </div>
            <!--/ email detail header -->