Пример #1
0
 /**
  * View Tracking Information task
  *
  * @return 	void
  */
 public function trackingTask()
 {
     //get request vars
     $ids = Request::getVar('id', array());
     $id = isset($ids) ? $ids[0] : null;
     //instantiate newsletter mailing object
     $newsletterMailing = new NewsletterMailing($this->database);
     $mailing = $newsletterMailing->getMailings($id);
     //get mailing recipients
     $newsletterMailingRecipient = new MailingRecipient($this->database);
     $this->view->recipients = $newsletterMailingRecipient->getRecipients($id, 'sent');
     //instantiate newsletter object
     $newsletterNewsletter = new Newsletter($this->database);
     $newsletterNewsletter->load($mailing->nid);
     //make sure we are supposed to be tracking
     if (!$newsletterNewsletter->tracking) {
         $this->setError(Lang::txt('COM_NEWSLETTER_MAILING_NOT_TRACKING'));
         $this->displayTask();
         return;
     }
     //get bounces
     $sql = "SELECT * FROM `#__email_bounces`\n\t\t\t\tWHERE component='com_newsletter'\n\t\t\t\tAND object=" . $this->database->quote('Campaign Mailing') . "\n\t\t\t\tAND object_id=" . $this->database->quote($id);
     $this->database->setQuery($sql);
     $this->view->bounces = $this->database->loadObjectList();
     //new mailing recipient action object
     $newsletterMailingRecipientAction = new MailingRecipientAction($this->database);
     //get opens, clicks, forwards, and prints
     $this->view->opens = $newsletterMailingRecipientAction->getMailingActions($id, 'open');
     $this->view->forwards = $newsletterMailingRecipientAction->getMailingActions($id, 'forward');
     $this->view->prints = $newsletterMailingRecipientAction->getMailingActions($id, 'print');
     //get opens geo
     $this->view->opensGeo = $this->getOpensGeoTask($id);
     //get clicks and process
     $clicks = $newsletterMailingRecipientAction->getMailingActions($id, 'click');
     $this->view->clicks = array();
     foreach ($clicks as $click) {
         //get click action
         $clickAction = json_decode($click->action_vars);
         $this->view->clicks[$clickAction->url] = isset($this->view->clicks[$clickAction->url]) ? $this->view->clicks[$clickAction->url] + 1 : 1;
     }
     // Set any errors
     if ($this->getError()) {
         $this->view->setError($this->getError());
     }
     // Output the HTML
     $this->view->setLayout('tracking')->display();
 }
Пример #2
0
 /**
  * Display send newsletter form
  *
  * @return  void
  */
 public function sendNewsletterTask()
 {
     // get the request vars
     $ids = Request::getVar("id", array());
     $id = isset($ids[0]) ? $ids[0] : null;
     // make sure we have an id
     if (!$id) {
         $this->setError(Lang::txt('COM_NEWSLETTER_SELECT_NEWSLETTER_FOR_MAILING'));
         $this->displayTask();
         return;
     }
     // get the newsletter
     $newsletterNewsletter = new Letter($this->database);
     $this->view->newsletter = $newsletterNewsletter->getNewsletters($id);
     // get newsletter mailing lists
     $newsletterMailinglist = new Mailinglist($this->database);
     $this->view->mailinglists = $newsletterMailinglist->getLists();
     // get the mailings
     $newsletterMailing = new Mailing($this->database);
     $this->view->mailings = $newsletterMailing->getMailings(null, $id);
     // get # left to send
     foreach ($this->view->mailings as $k => $mailing) {
         $this->database->setQuery("SELECT COUNT(*) FROM `#__newsletter_mailing_recipients` WHERE mid=" . $this->database->quote($mailing->id) . " AND status='queued'");
         $mailing->queueCount = $this->database->loadResult();
     }
     // check if we have any errors
     if ($this->getError()) {
         $this->view->setError($this->getError());
     }
     // vars for view
     $this->view->database = $this->database;
     // Output the HTML
     $this->view->setLayout('send')->display();
 }
Пример #3
0
 /**
  * Unsubscribe User Mailing Lists
  *
  * @return 	void
  */
 public function doUnsubscribeTask()
 {
     //get request vars
     $email = urldecode(Request::getVar('e', ''));
     $token = Request::getVar('t', '');
     $reason = Request::getVar('reason', '');
     $reason_alt = Request::getVar('reason-alt', '');
     //grab the reason explaination if user selected other
     if ($reason == 'Other') {
         $reason = $reason_alt;
     }
     //parse mailing token
     $recipient = Helper::parseMailingToken($token);
     //make sure the token is valid
     if (!is_object($recipient) || $email != $recipient->email) {
         App::redirect(Route::url('index.php?option=com_newsletter&task=subscribe'), Lang::txt('COM_NEWSLETTER_MAILINGLIST_UNSUBSCRIBE_LINK_ISSUE'), 'error');
         return;
     }
     //get newsletter mailing to get mailing list id mailing was sent to
     $newsletterMailing = new Mailing($this->database);
     $mailing = $newsletterMailing->getMailings($recipient->mid);
     //make sure we have a mailing object
     if (!is_object($mailing)) {
         App::redirect(Route::url('index.php?option=com_newsletter&task=subscribe'), Lang::txt('COM_NEWSLETTER_MAILINGLIST_UNSUBSCRIBE_NO_MAILING'), 'error');
         return;
     }
     //are we unsubscribing from default list?
     $sql = '';
     if ($mailing->lid == '-1') {
         if (!User::isGuest()) {
             $sql = "UPDATE #__xprofiles SET mailPreferenceOption=0 WHERE uidNumber=" . $this->database->quote(User::get('id'));
         } else {
             //build return url and redirect url
             $return = Route::url('index.php?option=com_newsletter&task=unsubscribe&e=' . $email . '&t=' . $token);
             //inform user and redirect
             App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($return)), Lang::txt('COM_NEWSLETTER_MAILINGLIST_UNSUBSCRIBE_MUST_LOGIN'), 'warning');
             return;
         }
     } else {
         //update the emails status on the mailing list
         $sql = "UPDATE #__newsletter_mailinglist_emails\n\t\t\t\t\tSET status=" . $this->database->quote('unsubscribed') . "\n\t\t\t\t\tWHERE mid=" . $this->database->quote($mailing->lid) . "\n\t\t\t\t\tAND email=" . $this->database->quote($recipient->email);
     }
     //set query and execute
     $this->database->setQuery($sql);
     if (!$this->database->query()) {
         App::redirect(Route::url('index.php?option=com_newsletter&task=unsubscribe&e=' . $email . '&t=' . $token), Lang::txt('COM_NEWSLETTER_MAILINGLIST_UNSUBSCRIBE_ERROR'), 'error');
         return;
     }
     //insert unsubscribe reason
     $sql = "INSERT INTO #__newsletter_mailinglist_unsubscribes(mid,email,reason)\n\t\t\t\tVALUES(" . $this->database->quote($mailing->lid) . "," . $this->database->quote($recipient->email) . "," . $this->database->quote($reason) . ")";
     $this->database->setQuery($sql);
     $this->database->query();
     //inform user of successful unsubscribe
     Notify::success(Lang::txt('COM_NEWSLETTER_MAILINGLIST_UNSUBSCRIBE_SUCCESS'));
     if (User::isGuest()) {
         App::redirect(Route::url('index.php?option=com_newsletter'));
         return;
     }
     App::redirect(Route::url('index.php?option=com_newsletter&task=subscribe'));
 }