public function updateCustomRecord($parameters)
 {
     $htmlLinks = ComunikLibrary::setMailingLinks($this->request, $parameters);
     EmailCampaign::where('id_044', $parameters['id'])->update(['name_044' => $this->request->input('name'), 'email_account_id_044' => $this->request->input('emailAccount'), 'template_id_044' => empty($this->request->input('template')) ? null : $this->request->input('template'), 'subject_044' => $this->request->input('subject'), 'theme_044' => $this->request->input('theme'), 'header_044' => $htmlLinks['header'], 'body_044' => $htmlLinks['body'], 'footer_044' => $htmlLinks['footer'], 'text_044' => $htmlLinks['text'], 'data_044' => $this->request->input('data', 'NULL'), 'shipping_date_044' => $this->request->has('shippingDate') ? \DateTime::createFromFormat(config('pulsar.datePattern') . ' H:i', $this->request->input('shippingDate'))->getTimestamp() : (int) date('U'), 'shipping_date_text_044' => $this->request->has('shippingDate') ? $this->request->input('shippingDate') : date(config('pulsar.datePattern') . ' H:i'), 'persistence_date_044' => $this->request->has('persistenceDate') ? \DateTime::createFromFormat(config('pulsar.datePattern') . ' H:i', $this->request->input('persistenceDate'))->getTimestamp() : null, 'persistence_date_text_044' => $this->request->has('persistenceDate') ? $this->request->input('persistenceDate') : null, 'sorting_044' => $this->request->has('sorting') ? $this->request->input('sorting') : null]);
     $emailCampaign = EmailCampaign::find($parameters['id']);
     $emailCampaign->getCountries()->sync($this->request->input('countries'));
     $emailCampaign->getGroups()->sync($this->request->input('groups'));
     // borramos los envíos de cola, de aquellos correos en estado, status_id_047 = 0 waiting
     // que no correspondan con los nuevos grupos, caso muy dificil de ocurrir,
     // ya que solo se pasan a cola cuando van a ser enviados
     EmailSendQueue::deleteMailingWithoutGroupSendQueue($this->request->input('groups'), $emailCampaign->id_044);
 }
 public function updateCustomRecord($parameters)
 {
     $htmlLinks = ComunikLibrary::setMailingLinks($this->request, $parameters);
     EmailTemplate::where('id_043', $parameters['id'])->update(['name_043' => $this->request->input('name'), 'subject_043' => $this->request->input('subject'), 'theme_043' => $this->request->input('theme'), 'header_043' => $htmlLinks['header'], 'body_043' => $htmlLinks['body'], 'footer_043' => $htmlLinks['footer'], 'text_043' => $htmlLinks['text'], 'data_043' => $this->request->input('data')]);
 }
示例#3
0
文件: Cron.php 项目: syscover/comunik
 /**
  * Recursive function
  *
  * @param \Syscover\Pulsar\Libraries\ImapServices   $imapService
  * @param \Syscover\Pulsar\Models\EmailAccount      $account
  * @param \Illuminate\Support\Collection            $patterns
  * @param integer                                   $position
  */
 public static function checkBouncedMessagesFromAccount($imapService, $account, $patterns, $position)
 {
     $nEmailsToChecck = 25;
     // Solicitamos los 10 anteriores mensajes a comprobar desde la última posición comnprobada
     $messages = $imapService->getServer()->getMessages($nEmailsToChecck, $position);
     $findLastCheckUid = false;
     foreach ($messages as $key => $message) {
         // comprobamos si el mensaje coincide con algún patron
         $response = ComunikLibrary::checkEmailPattern($message, $patterns);
         if ($response['success']) {
             if (count($response['contacts']) > 0) {
                 // Obtenemos el primer contacto del email que ha coincidido con el patrón
                 $contact = $response['contacts']->first();
             } else {
                 $contact = false;
             }
             // Acciones a realizar
             // 1 = nada
             // 2 = borrar contacto y mensaje
             // 3 = unsuscribe y borrar mensaje
             // 4 = borrar contacto
             // 5 = ususcribe contacto
             // 6 = borrar mensaje
             if ($contact != false && ($response['pattern']->action_049 == 2 || $response['pattern']->action_049 == 4)) {
                 // borrar contacto
                 Contact::where('id_041', $contact->id_041)->delete();
             }
             if ($contact != false && ($response['pattern']->action_049 == 3 || $response['pattern']->action_049 == 5)) {
                 // unsuscribe contacto
                 Contact::where('id_041', $contact->id_041)->update(['unsubscribe_email_041' => true]);
             }
             if ($response['pattern']->action_049 == 2 || $response['pattern']->action_049 == 3 || $response['pattern']->action_049 == 6) {
                 // borrar mensaje
                 $message->delete();
                 // retrasamos medio segundo la ejecución para no saturar el servidor IMAP de peticiones
                 usleep(500000);
             }
         }
         // si es la última interacción
         if ($key === count($messages) - 1) {
             // purge all delete messages
             $imapService->getServer()->expunge();
             // actualizamos el último UID comprobado
             EmailAccount::where('id_013', $account->id_013)->update(['last_check_uid_013' => $message->getUid()]);
         }
     }
 }