예제 #1
0
파일: view.html.php 프로젝트: Rikisha/proj
 /**
  * Add the page title and toolbar.
  *
  * @return void
  * @since	1.0
  */
 protected function addToolbar()
 {
     $bar = JToolBar::getInstance('sender');
     $bar->appendButton('Link', 'export', 'COM_NEWSLETTER_NEWSLETTER_SEND', '#');
     // Load the submenu.
     NewsletterHelper::addSubmenu(JRequest::getVar('view'));
 }
예제 #2
0
파일: view.html.php 프로젝트: Rikisha/proj
 /**
  * Add the page title and toolbar.
  *
  * @return void
  * @since	1.0
  */
 protected function addToolbar()
 {
     JToolBarHelper::title(JText::_('COM_NEWSLETTER_BOUNCEDS_TITLE'), 'article.png');
     $bar = JToolBar::getInstance('bounceds');
     $bar->appendButton('Standard', 'process', 'JTOOLBAR_PROCESS', 'bounceds.process', false);
     // Load the submenu.
     NewsletterHelper::addSubmenu(JRequest::getVar('view'));
 }
예제 #3
0
파일: view.html.php 프로젝트: Rikisha/proj
 /**
  * Add the page title and toolbar.
  *
  * @return void
  * @since	1.0
  */
 protected function addToolbar()
 {
     JToolBarHelper::title(JText::_('COM_NEWSLETTER_LOG_TITLE'), 'article.png');
     $bar = JToolBar::getInstance('logs');
     $bar->appendButton('Standard', 'trash', 'JTOOLBAR_DELETE', 'logs.delete', false);
     // Load the submenu.
     NewsletterHelper::addSubmenu(JRequest::getVar('view'));
 }
예제 #4
0
파일: view.html.php 프로젝트: Rikisha/proj
 /**
  * Add the page title and toolbar.
  *
  * @return void
  * @since	1.0
  */
 protected function addToolbar()
 {
     JToolBarHelper::title(JText::_('COM_NEWSLETTER_AUTOMAILINGS_TITLE'), 'article.png');
     $bar = JToolBar::getInstance('automailings');
     $bar->appendButton('Popup', 'new', 'JTOOLBAR_NEW', 'index.php?option=com_newsletter&view=automailing&tmpl=component', 350, 175, 0, 0);
     $bar->appendButton('Link', 'edit', 'JTOOLBAR_EDIT', 'automailing.edit', false);
     $bar->appendButton('Standard', 'trash', 'JTOOLBAR_DELETE', 'automailings.delete', false);
     // Load the submenu.
     NewsletterHelper::addSubmenu(JRequest::getVar('view'));
 }
예제 #5
0
파일: view.html.php 프로젝트: Rikisha/proj
 /**
  * Add the page title and toolbar.
  *
  * @since	1.0
  */
 protected function addToolbar()
 {
     JToolBarHelper::title(JText::_('COM_NEWSLETTER_CONFIGURATION_TITLE'), 'article.png');
     $bar = JToolBar::getInstance('toolbar');
     if (AclHelper::canConfigureComponent()) {
         $bar->appendButton('Standard', 'apply', 'JTOOLBAR_APPLY', 'configuration.apply', false);
     }
     // Load the submenu.
     NewsletterHelper::addSubmenu(JRequest::getVar('view'));
 }
예제 #6
0
파일: view.html.php 프로젝트: Rikisha/proj
 function display($tpl = null)
 {
     /*
      * Get the info about current user.
      * Check if the user is admin.
      */
     $alias = JRequest::getString('alias', null);
     if (!empty($alias)) {
         $newslettter = NewsletterHelper::getByAlias($alias);
         $this->assignRef('newsletter', $newslettter);
         parent::display();
     }
 }
예제 #7
0
파일: view.html.php 프로젝트: Rikisha/proj
 /**
  * Add the page title and toolbar.
  *
  * @return void
  * @since	1.0
  */
 protected function addToolbar()
 {
     JToolBarHelper::title(JText::_('COM_NEWSLETTER_CONFLICT_TITLE'), 'article.png');
     $bar = JToolBar::getInstance();
     // delete all/selected;
     $bar->appendButton('Standard', 'trash', 'COM_NEWSLETTER_DELETE_SUBS', 'conflicts.deletesubs', false);
     // merge selected. preserve J! user's data
     $bar->appendButton('Standard', 'trash', 'COM_NEWSLETTER_MERGE_USERS', 'conflicts.mergeusers', false);
     // merge selected. preserve J! subscriber's data
     $bar->appendButton('Standard', 'trash', 'COM_NEWSLETTER_MERGE_SUBS', 'conflicts.mergesubs', false);
     // TODO merge history (yes/no)
     // Load the submenu.
     NewsletterHelper::addSubmenu(JRequest::getVar('view'));
 }
예제 #8
0
 public function delete()
 {
     $cids = JRequest::getVar('cid', array());
     $unsets = array();
     if (!empty($cids)) {
         foreach ($cids as $idx => $cid) {
             $newsletter = NewsletterHelper::get($cid);
             if ($newsletter['used_as_static'] == 1 || !$newsletter['saveable']) {
                 $unsets[] = $cids[$idx];
                 unset($cids[$idx]);
             }
         }
         JRequest::setVar('cid', $cids);
     }
     if (count($unsets) > 0) {
         $deleteLink = '<a class="micro-button" href="' . JRoute::_('index.php?option=com_newsletter&task=newsletters.deletehard&' . JSession::getFormToken() . '=1&cid=' . implode(',', $unsets)) . '">&nbsp;X&nbsp;</a>';
         JFactory::getApplication()->enqueueMessage(sprintf(JText::_('COM_NEWSLETTER_SOME_COULDNOT_DELETE'), count($unsets), $deleteLink), 'message');
     }
     if (count($cids) > 0) {
         parent::delete();
     }
     $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
 }
예제 #9
0
 /**
  * Handles the sending of the letter to a lists. 
  * Adds the items to "_queue" table.
  *
  * @return boolean
  * @since 1.0
  */
 public function addToQueue()
 {
     $newsletterId = JRequest::getInt('newsletter_id');
     $lists = JRequest::getVar('lists');
     $added = 0;
     $errors = 0;
     if (empty($newsletterId) || empty($lists)) {
         $this->setError('Required data is absent');
         NewsletterHelper::jsonError(JText::_('Required data is absent'));
     }
     foreach ($lists as $list) {
         $dbo = JFactory::getDbo();
         $query = $dbo->getQuery(true);
         $query->select('distinct s.subscriber_id')->from('#__newsletter_sub_list AS sl')->join('', '#__newsletter_subscribers AS s ON s.subscriber_id = sl.subscriber_id')->where('list_id=' . (int) $list);
         //echo nl2br(str_replace('#__','jos_',$query));
         $subs = $dbo->setQuery($query)->loadAssocList();
         if (!empty($subs)) {
             foreach ($subs as $item) {
                 $table = JTable::getInstance('queue', 'NewsletterTable');
                 if (!$table->load(array('newsletter_id' => $newsletterId, 'subscriber_id' => $item['subscriber_id']))) {
                     // add new row only if it does not exist...
                     if ($table->save(array('newsletter_id' => $newsletterId, 'subscriber_id' => $item['subscriber_id'], 'created' => date('Y-m-d H:i:s'), 'state' => 1))) {
                         $added++;
                     } else {
                         $errors++;
                     }
                 }
                 unset($table);
             }
         }
     }
     $data = array('added' => $added, 'errors' => $errors);
     if ($errors > 0) {
         NewsletterHelper::jsonError(JText::_('COM_NEWSLETTER_AN_ERROR_OCCURED'), $data);
     }
     NewsletterHelper::jsonMessage('ok', $data);
 }
예제 #10
0
 function add_newsletter($mail = false)
 {
     return NewsletterHelper::Add($mail);
 }
예제 #11
0
파일: view.html.php 프로젝트: Rikisha/proj
 /**
  * Add the page title and toolbar.
  *
  * @return void
  * @since	1.0
  */
 protected function addToolbar()
 {
     JToolBarHelper::title(JText::_('COM_NEWSLETTER_SUBSCRIBERS_TITLE'), 'article.png');
     $bar = MigurToolBar::getInstance('subscribers', null, '');
     if (AclHelper::actionIsAllowed('list.edit')) {
         $bar->appendButton('Link', 'cancel', 'COM_NEWSLETTER_REMOVE_FROM_LIST', 'list.unbindgroup', false);
         $bar->appendButton('Link', 'copy', 'COM_NEWSLETTER_ASSIGN_TO_LIST', 'list.assigngroup', false);
     }
     $bar->appendButton('Popup', 'new', 'JTOOLBAR_NEW', 'index.php?option=com_newsletter&amp;task=subscriber.add&amp;tmpl=component', 400, 220, 0, 0);
     $bar->appendButton('Standard', 'trash', 'JTOOLBAR_DELETE', 'subscribers.delete', false);
     $bar->appendButton('Standard', 'unpublish', 'JTOOLBAR_DISABLE', 'subscribers.unpublish', false);
     $bar->appendButton('Standard', 'publish', 'JTOOLBAR_ENABLE', 'subscribers.publish', false);
     $bar->appendButton('MigurHelp', 'help', 'COM_NEWSLETTER_HELP', 'http://migur.com/support/documentation/newsletter');
     $bar = MigurToolBar::getInstance('lists');
     if (AclHelper::actionIsAllowed('list.add')) {
         $bar->appendButton('Popup', 'new', 'JTOOLBAR_NEW', 'index.php?option=com_newsletter&amp;view=list&amp;tmpl=component', 1000, 600, 0, 0);
     }
     $bar->appendButton('Standard', 'trash', 'JTOOLBAR_DELETE', 'lists.delete', false);
     if (AclHelper::actionIsAllowed('list.edit')) {
         $bar->appendButton('Standard', 'unpublish', 'JTOOLBAR_DISABLE', 'lists.unpublish', false);
         $bar->appendButton('Standard', 'publish', 'JTOOLBAR_ENABLE', 'lists.publish', false);
     }
     $bar->appendButton('MigurHelp', 'help', 'COM_NEWSLETTER_HELP', 'http://migur.com/support/documentation/newsletter');
     // Load the submenu.
     NewsletterHelper::addSubmenu(JRequest::getVar('view'));
 }
예제 #12
0
 /**
  * Check connections to ALL mailbox servers.
  * 
  * @return string json
  */
 public function checkMailboxes()
 {
     $res = array();
     $manager = JModel::getInstance('Mailboxprofiles', 'NewsletterModel');
     $mailboxes = $manager->getAllItems();
     if (!empty($mailboxes)) {
         jimport('migur.library.mailer.mailbox');
         foreach ($mailboxes as $mailboxSettings) {
             $text = JText::sprintf('COM_NEWSLETTER_MAINTAINANCE_CHECKMAILBOX', $mailboxSettings->mailbox_profile_name) . '...';
             $mailboxSettings = (array) $mailboxSettings;
             $mailbox = new MigurMailerMailbox($mailboxSettings);
             $errors = array();
             if ($mailbox->connect()) {
                 $mailbox->close();
             } else {
                 $errors[] = JText::_('COM_NEWSLETTER_UNABLE_TO_CONNECT');
                 $errors[] = $mailbox->getLastError();
                 if (!$mailbox->protocol->getOption('noValidateCert')) {
                     $mailbox->protocol->setOption('noValidateCert', true);
                     $errors[] = JText::_('COM_NEWSLETTER_TRYING_TO_CONNECT_WITHOUT_CERT');
                     if ($mailbox->connect()) {
                         $mailbox->close();
                         $errors[] = JText::_('COM_NEWSLETTER_OK_CHECK_YOUR_CERT');
                     } else {
                         $errors[] = JText::_('COM_NEWSLETTER_FAILED') . '. ' . $mailbox->getLastError();
                     }
                 }
             }
             if (count($errors) > 0) {
                 $text .= '<br/>' . implode('<br/>', $errors);
             }
             imap_errors();
             imap_alerts();
             $res[] = array('text' => $text, 'type' => count($errors) == 0);
         }
     } else {
         $res[] = array('text' => JText::sprintf('COM_NEWSLETTER_MAINTAINANCE_NO_MAILBOXES'), 'type' => false);
     }
     // Return data
     NewsletterHelper::jsonMessage('checkMailboxes', $res);
 }
예제 #13
0
파일: newsletter.php 프로젝트: Rikisha/proj
    // Setup the cache
    $cache = JFactory::getCache('com_newsletter');
    $cache->setCaching(true);
    $cache->setLifeTime(900);
    // cache to 5 min
    // Get an instance of the controller
    // Here we get full task
    $controller = JController::getInstance('Newsletter');
    // Perform the Request task
    // Here we get only tail of a task
    $controller->execute(JRequest::getCmd('task'));
    // Trigger events after exacution
    $app->triggerEvent('onMigurNewsletterEnd');
    // Redirect if set by the controller
    $controller->redirect();
    //$app = JFactory::getApplication();
    //$results = $app->triggerEvent('onAfterRender', array());
    // If there is no redirection then let's check the license and notify the admin
    // No need to check if this is a redirection
    if (JRequest::getString('tmpl') != 'component') {
        // Get license data (may be cached data)
        $info = NewsletterHelper::getCommonInfo();
        // If it has no valid license then show the RED message
        if ($info->is_valid == "JNO") {
            $app->enqueueMessage(JText::_('COM_NEWSLETTER_LICENSE_INVALID'), 'error');
        }
    }
} catch (Exception $e) {
    LogHelper::addDebug('COM_NEWSLETTER_UNKNOWN_ERROR', 'common', (array) $e);
    throw $e;
}
예제 #14
0
파일: view.html.php 프로젝트: Rikisha/proj
 /**
  * Add the page title and toolbar.
  *
  * @return void
  * @since	1.0
  */
 protected function addToolbar()
 {
     JToolBarHelper::title(JText::_('COM_NEWSLETTER_QUEUE_TITLE'), 'article.png');
     $bar = JToolBar::getInstance();
     $bar->appendButton('Custom', '', 'preloader', '');
     $bar->appendButton('Link', 'messaging', 'COM_NEWSLETTER_PROCESS_QUEUE', '#');
     $bar->appendButton('Link', 'alert', 'COM_NEWSLETTER_PROCESS_BOUNCES', '#');
     $bar->appendButton('Separator', null, '30');
     $bar->appendButton('Standard', 'trash', 'JTOOLBAR_DELETE', 'queues.delete', false);
     // Load the submenu.
     NewsletterHelper::addSubmenu(JRequest::getVar('view'));
 }
예제 #15
0
파일: newsletter.php 프로젝트: Rikisha/proj
 /**
  * Bulk save method for saving of newsletter 
  * or copying of several ones.
  * 
  * @return type 
  */
 public function save()
 {
     $task = JRequest::getString('task');
     if (!empty($task) && strpos($task, 'save2copy') !== false) {
         // Actualy on this step will be performed
         // the checking for NEWSLETTER.ADD permission. It's ok
         if (!$this->allowSave()) {
             $this->setError(JText::_('JLIB_APPLICATION_ERROR_SAVE_NOT_PERMITTED'));
             $this->setMessage($this->getError(), 'error');
             $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false));
             return false;
         }
         $nIds = JRequest::getVar('cid', array());
         if (!empty($nIds)) {
             $table = JTable::getInstance('Newsletter', 'NewsletterTable');
             $relTable = JTable::getInstance('Newsletterext', 'NewsletterTable');
             $downTable = JTable::getInstance('Downloads', 'NewsletterTable');
             foreach ($nIds as $nId) {
                 // Copying the newsletter...
                 $table->load($nId);
                 $data = $table->getProperties();
                 // reset
                 $table->reset();
                 $table->set($table->getKeyName(), null);
                 unset($data['newsletter_id']);
                 $data['name'] .= '(copy)';
                 $data['sent_started'] = '';
                 $data['alias'] = NewsletterHelper::getFreeAlias($data['alias']);
                 // bind
                 if (!$table->bind($data)) {
                     $this->setError($table->getError());
                     return false;
                 }
                 // Store data.
                 if (!$table->store()) {
                     $this->setError($table->getError());
                     return false;
                 }
                 $newNid = $table->get($table->getKeyName());
                 // Copy extensions...
                 $exts = $relTable->getRowsBy($nId);
                 if (!empty($exts)) {
                     foreach ($exts as $ext) {
                         // reset
                         $relTable->reset();
                         $relTable->set($relTable->getKeyName(), null);
                         unset($ext[$relTable->getKeyName()]);
                         $ext['newsletter_id'] = $newNid;
                         // bind
                         if (!$relTable->bind($ext)) {
                             $this->setError($relTable->getError());
                             return false;
                         }
                         // Store data.
                         if (!$relTable->store()) {
                             $this->setError($relTable->getError());
                             return false;
                         }
                     }
                 }
                 // Copy downloads...
                 $exts = $downTable->getRowsBy($nId);
                 if (!empty($exts)) {
                     foreach ($exts as $ext) {
                         // reset
                         $downTable->reset();
                         $downTable->set($downTable->getKeyName(), null);
                         unset($ext[$downTable->getKeyName()]);
                         $ext['newsletter_id'] = $newNid;
                         // bind
                         if (!$downTable->bind($ext)) {
                             $this->setError($downTable->getError());
                             return false;
                         }
                         // Store data.
                         if (!$downTable->store()) {
                             $this->setError($downTable->getError());
                             return false;
                         }
                     }
                 }
                 // Clean the cache.
                 $cache = JFactory::getCache($this->option);
                 $cache->clean();
             }
             $message = JText::_('COM_NEWSLETTER_NEWSLETTER_COPY_SUCCESS');
             $this->setRedirect(JRoute::_('index.php?option=com_newsletter&view=newsletters&form=newsletters', false), $message, 'message');
             return true;
         } else {
             $message = JText::_('COM_NEWSLETTER_SELECT_AT_LEAST_ONE_ITEM');
             $this->setRedirect(JRoute::_('index.php?option=com_newsletter&view=newsletters&form=newsletters', false), $message, 'error');
             return true;
         }
         return parent::save();
     } else {
         $nsid = JRequest::getVar('newsletter_id', '0');
         $type = JRequest::getVar('task');
         $context = JRequest::getString('context', 'html');
         // save new newsletter (create it) or autosave an existing letter
         $data = JRequest::getVar('jform', array(), 'post', 'array');
         // If the type is not changeable then replace type as now (for success validation).
         if (!empty($nsid)) {
             // Get newsletter's extended info
             $nl = NewsletterHelper::get($nsid);
             if (!$nl['type_changeable']) {
                 $data['type'] = $nl['type'];
                 JRequest::setVar('jform', $data, 'post');
             }
             // Check if we can change the newsletter
             if (!$nl['saveable']) {
                 $error = JText::_('COM_NEWSLETTER_CANNOT_SAVE_NEWSLETTER');
                 if ($context == 'json') {
                     echo json_encode(array('state' => $error, 'newsletter_id' => $nsid));
                     jexit();
                 } else {
                     JFactory::getApplication()->enqueueMessage($error, 'error');
                     $this->setRedirect(JRoute::_('index.php?option=com_newsletter&view=newsletter&layout=edit&newsletter_id=' . $nsid, false));
                     return;
                 }
             }
         } else {
             if (empty($data['alias'])) {
                 $data['alias'] = 'newsletter';
             }
             // Get newsletters with similar aliases
             $data['alias'] = NewsletterHelper::getFreeAlias($data['alias']);
         }
         if (parent::save()) {
             $nsid = $this->newsletterId;
             $htmlTpl = (object) json_decode($data['htmlTpl']);
             $plugins = (array) json_decode($data['plugins']);
             $htmlTpl->extensions = array_merge($htmlTpl->extensions, $plugins);
             $newExtsModel = $this->getModel('newsletterext');
             if ($newExtsModel->rebindExtensions($htmlTpl->extensions, $nsid)) {
             } else {
                 $error = $newExtsModel->getError();
             }
         } else {
             $error = $this->getError();
         }
         if ($context == 'json') {
             $this->setRedirect(null);
             if (empty($error)) {
                 $error = JFactory::getApplication()->getMessageQueue();
             }
             echo json_encode(array('state' => !empty($error) ? $error : 'ok', 'newsletter_id' => $nsid, 'alias' => $data['alias']));
             jexit();
         }
     }
 }
예제 #16
0
파일: view.html.php 프로젝트: Rikisha/proj
 /**
  * Add the page title and toolbar.
  *
  * @return void
  * @since	1.0
  */
 protected function addToolbar()
 {
     JToolBarHelper::title(JText::_('COM_NEWSLETTER_DASHBOARD_TITLE'), 'article.png');
     $bar = JToolBar::getInstance();
     $bar->appendButton('Link', 'alert', 'COM_NEWSLETTER_NOTIFICATIONS', 'index.php?option=com_newsletter&amp;view=logs');
     JToolBarHelper::custom('', 'progress', '', '', false);
     $bar = MigurToolBar::getInstance('newsletters-toolbar');
     $bar->appendButton('Link', 'new', 'COM_NEWSLETTER_NEWSLETTER_CREATE', 'index.php?option=com_newsletter&amp;view=newsletter');
     $bar->appendButton('Popup', 'export', 'COM_NEWSLETTER_NEWSLETTER_SEND', 'index.php?option=com_newsletter&amp;view=sender&amp;tmpl=component', 920, 450, 0, 0);
     $bar = MigurToolBar::getInstance('subscribers-toolbar');
     $bar->appendButton('Popup', 'new', 'COM_NEWSLETTER_SUBSCRIBER_CREATE', 'index.php?option=com_newsletter&amp;view=subscriber&amp;tmpl=component', 400, 220, 0, 0);
     $bar->appendButton('Popup', 'new', 'COM_NEWSLETTER_LIST_CREATE', 'index.php?option=com_newsletter&amp;view=list&amp;tmpl=component', 1000, 600, 0, 0);
     $bar = MigurToolBar::getInstance('config-toolbar');
     $bar->appendButton('Popup', 'export', 'COM_NEWSLETTER_EXTENSIONS_INSTALL', 'index.php?option=com_newsletter&amp;view=extension&amp;layout=install&amp;tmpl=component', 350, 150, 0, 0);
     $bar->appendButton('Link', 'options', 'COM_NEWSLETTER_CONFIGURATION', 'index.php?option=com_newsletter&amp;view=configuration');
     $bar = MigurToolBar::getInstance('help-toolbar');
     $bar->appendButton('Popup', 'publish', 'COM_NEWSLETTER_ABOUT', 'http://migur.com/products/newsletter', 800, 600, 0, 0);
     $bar->appendButton('MigurHelp', 'help', 'COM_NEWSLETTER_HELP', 'http://migur.com/support/documentation/newsletter');
     // Load the submenu.
     NewsletterHelper::addSubmenu(JRequest::getVar('view'));
 }
 /**
  * Añade un mail al newsletter
  *
  * @param bool|string $mail mail que será añadido al newsletter.
  * @return string mensaje de error o de éxito.
  * @throws Exception si el algún setting del Newsletter no ha sido configurado.
  */
 public static function Add($mail = false)
 {
     global $mensaje;
     $mail = (string) $mail;
     if (!$mail || !is_email($mail)) {
         $mensaje->add_error('No se ha recibido un mail válido');
     } else {
         try {
             $cc = new ConstantContact(NewsletterHelper::ApiKey());
             $list = NewsletterHelper::ListNumber();
             $response = $cc->getContactByEmail(NewsletterHelper::AccessToken(), $mail);
             if (empty($response->results)) {
                 $contact = new Contact();
                 $contact->addEmail($mail);
                 $contact->addList($list);
                 $returnContact = $cc->addContact(NewsletterHelper::AccessToken(), $contact, true);
             } else {
                 $contact = $response->results[0];
                 $contact->addList($list);
                 $returnContact = $cc->updateContact(NewsletterHelper::AccessToken(), $contact, true);
             }
             $mensaje->add_mensaje('Tu correo se ha añadido correctamente a la lista');
         } catch (Exception $ex) {
             if ($ex instanceof CtctException) {
                 $errores = reset($ex->getErrors());
                 $mensaje->add_error($errores['error_message']);
             } else {
                 $mensaje->add_error($ex->getMessage());
             }
         }
     }
 }
예제 #18
0
파일: view.html.php 프로젝트: Rikisha/proj
 /**
  * Add the page title and toolbar.
  *
  * @return void
  * @since	1.0
  */
 protected function addToolbar()
 {
     JToolBarHelper::title(JText::_('COM_NEWSLETTER_NEWSLETTERS_TITLE'), 'article.png');
     $bar = JToolBar::getInstance('newsletters');
     $bar->appendButton('Link', 'default', 'COM_NEWSLETTER_SHOW_STATISTICS', 'index.php?option=com_newsletter&amp;view=statistic&amp;tmpl=component');
     if (AclHelper::actionIsAllowed('newsletter.add')) {
         $bar->appendButton('Standard', 'new', 'JTOOLBAR_NEW', 'newsletter.add', false);
         $bar->appendButton('Standard', 'copy', 'JTOOLBAR_SAVE_AS_COPY', 'newsletter.save2copy', false);
     }
     $bar->appendButton('Standard', 'trash', 'JTOOLBAR_DELETE', 'newsletters.delete', false);
     // Load the submenu.
     NewsletterHelper::addSubmenu(JRequest::getVar('view'));
 }
 /**
  * Añade un mail al newsletter
  *
  * @param bool|string $mail mail que será añadido al newsletter.
  * @return string mensaje de error o de éxito.
  * @throws Exception si el algún setting del Newsletter no ha sido configurado.
  */
 public static function Add($mail = false)
 {
     $handle = new Mensajes();
     $mail = (string) $mail;
     if (!$mail || !is_email($mail)) {
         $handle->add_error('No se ha recibido un mail válido');
     } else {
         require_once '../php-sdk-development/src/Ctct/autoload.php';
         $cc = new ConstantContact(NewsletterHelper::ApiKey());
         $list = NewsletterHelper::ListNumber();
         try {
             $response = $cc->getContactByEmail(NewsletterHelper::AccessToken(), $mail);
             if (empty($response->results)) {
                 $contact = new Contact();
                 $contact->addEmail($mail);
                 $contact->addList($list);
                 $returnContact = $cc->addContact(NewsletterHelper::AccessToken(), $contact, true);
             } else {
                 $contact = $response->results[0];
                 $contact->addList($list);
                 $returnContact = $cc->updateContact(NewsletterHelper::AccessToken(), $contact, true);
             }
             $handle->add_mensaje('Tu correo se ha añadido correctamente a la lista');
         } catch (CtctException $ex) {
             $errores = reset($ex->getErrors());
             $handle->add_error($errores['error_message']);
         }
     }
     return $handle->imprimir(false, true);
     //.'<script>finalizar_subscripcion();</script>';
 }
예제 #20
0
파일: view.html.php 프로젝트: Rikisha/proj
 /**
  * Add the page title and toolbar.
  *
  * @return void
  * @since	1.0
  */
 protected function addToolbar()
 {
     $isNew = !JRequest::getInt('newsletter_id', false);
     JToolBarHelper::title($isNew ? JText::_('COM_NEWSLETTER_NEWSLETTERS_ADD_TITLE') : JText::_('COM_NEWSLETTER_NEWSLETTERS_EDIT_TITLE'), 'article.png');
     $bar = JToolBar::getInstance('toolbar');
     if ($isNew && AclHelper::actionIsAllowed('newsletter.add') || !$isNew && AclHelper::actionIsAllowed('newsletter.edit')) {
         $bar->appendButton('Link', 'autosaver', '', '#', false);
         $bar->appendButton('Separator', null, '50');
         $bar->appendButton('Link', 'apply', 'JTOOLBAR_APPLY', '#', false);
         $bar->appendButton('Standard', 'save', 'JTOOLBAR_SAVE', 'newsletter.save', false);
     }
     $helpLink = 'http://migur.com/support/documentation/newsletter/' . NewsletterHelper::getManifest()->version . '/newsletters';
     $bar->appendButton('Popup', 'default', 'COM_NEWSLETTER_TUTORIAL', $helpLink, 1000, 600, 0, 0);
     $bar->appendButton('Standard', 'cancel', 'JTOOLBAR_CANCEL', 'newsletter.cancel', false);
 }
예제 #21
0
파일: list.json.php 프로젝트: Rikisha/proj
 /**
  * Fetches and adds the data to DB from the file uploaded before
  * @return void
  * @since 1.0
  */
 public function import()
 {
     $type = JRequest::getString('subscriber_type', '');
     $subtask = JRequest::getString('subtask', '');
     $currentList = JRequest::getInt('list_id', '0');
     if ($currentList < 1) {
         NewsletterHelper::jsonError('No list Id');
     }
     if (!($settings = $this->_getSettings())) {
         NewsletterHelper::jsonError('No settings');
     }
     if ($subtask == 'parse') {
         $mapping = $settings->fields;
         $sess = JFactory::getSession();
         $file = $sess->get('list.' . $currentList . '.file.uploaded', array());
         if (($handle = fopen($file['file']['filepath'], "r")) === FALSE) {
             NewsletterHelper::jsonError('Cannot open file');
         }
         $res = array();
         $total = 0;
         $skipped = 0;
         //get the header
         fgetcsv($handle, 1000, $settings->delimiter, $settings->enclosure);
         while (($data = fgetcsv($handle, 1000, $settings->delimiter, $settings->enclosure)) !== FALSE) {
             if ($mapping->html->mapped === null || !isset($data[$mapping->html->mapped])) {
                 $htmlVal = $mapping->html->default;
             } else {
                 $htmlVal = $data[$mapping->html->mapped];
             }
             if (!empty($data[$mapping->username->mapped]) && !empty($data[$mapping->email->mapped])) {
                 $res[] = array('name' => $data[$mapping->username->mapped], 'email' => $data[$mapping->email->mapped], 'html' => $htmlVal);
             } else {
                 $skipped++;
             }
             $total++;
         }
         fclose($handle);
         $subscriber = JModel::getInstance('Subscriber', 'NewsletterModelEntity');
         $errors = 0;
         $added = 0;
         $updated = 0;
         $assigned = 0;
         foreach ($res as $row) {
             $success = true;
             // Try to load a man
             $isExists = $subscriber->load(array('email' => $row['email']));
             // Set confirmed is it's empty
             if (!$subscriber->confirmed == 0) {
                 $subscriber->confirmed = 1;
             }
             if (!$isExists) {
                 // If user is not exists then add it!
                 $success = $subscriber->save($row, $type == 'juser');
                 $added++;
             } else {
                 if ($settings->overwrite) {
                     // If user is present and we can update it...
                     $success = $subscriber->save($row);
                     $updated++;
                 }
             }
             if ($subscriber->getId() && $success) {
                 // Assign the man only if he is not in list already
                 if (!$subscriber->isInList($currentList)) {
                     if ($subscriber->assignToList($currentList)) {
                         $assigned++;
                     } else {
                         $errors++;
                     }
                 }
             } else {
                 $errors++;
             }
         }
         if (!empty($errors)) {
             NewsletterHelper::jsonError('Import failed!', array('total' => $total, 'skipped' => $skipped, 'errors' => $errors, 'added' => $added, 'updated' => $updated, 'assigned' => $assigned));
         }
         unlink($file['file']['filepath']);
         $sess->clear('list.' . $currentList . '.file.uploaded');
         NewsletterHelper::jsonMessage('Import complete!', array('total' => $total, 'skipped' => $skipped, 'errors' => $errors, 'added' => $added, 'updated' => $updated, 'assigned' => $assigned));
     }
 }
예제 #22
0
파일: newsletter.php 프로젝트: Rikisha/proj
 /**
  * Render and send the letter to the selected emails
  *
  * @return void
  * @since  1.0
  */
 public function sendPreview()
 {
     $emails = JRequest::getVar('emails', array());
     $newsletterId = JRequest::getVar('newsletter_id');
     $type = JRequest::getVar('type');
     if (empty($type) || empty($newsletterId)) {
         NewsletterHelper::jsonError(JText::_('COM_NEWSLETTER_RUQUIRED_MISSING'));
     }
     if (empty($emails)) {
         NewsletterHelper::jsonError(JText::_('COM_NEWSLETTER_ADD_EMAILS'));
     }
     $data = array('newsletter_id' => $newsletterId, 'type' => $type, 'tracking' => true);
     foreach ($emails as $email) {
         $data['subscribers'][] = SubscriberHelper::getByEmail($email[1]);
     }
     $mailer = new MigurMailer();
     if (!$mailer->sendToList($data)) {
         $errors = $mailer->getErrors();
         LogHelper::addDebug('Sending of preview was failed.', LogHelper::CAT_MAILER, array('Errors' => $errors, 'Emails' => $emails));
         NewsletterHelper::jsonError($errors, $emails);
     }
     LogHelper::addDebug('Preview was sent successfully.', LogHelper::CAT_MAILER, array('Emails' => $emails));
     NewsletterHelper::jsonMessage('ok', $emails);
 }
 /**
  * Añade un mail al newsletter
  *
  * @param bool|string $mail mail que será añadido al newsletter.
  * @return string mensaje de error o de éxito.
  * @throws Exception si el algún setting del Newsletter no ha sido configurado.
  */
 public static function Add($mail = false)
 {
     global $mensaje;
     $mail = (string) $mail;
     if (!$mail || filter_var($mail, FILTER_VALIDATE_EMAIL) === false) {
         $mensaje->add_error('No se ha recibido un mail válido');
     } else {
         try {
             $cc = new ConstantContact(NewsletterHelper::ApiKey());
             $list = NewsletterHelper::ListNumber();
             $response = $cc->contactService->getContacts(NewsletterHelper::AccessToken(), array('email' => $mail));
             // Parameters
             $actionByVisitor = true;
             $params = array();
             if ($actionByVisitor == true) {
                 $params['action_by'] = "ACTION_BY_VISITOR";
             }
             if (empty($response->results)) {
                 $contact = new Contact();
                 $contact->addEmail($mail);
                 $contact->addList($list);
                 $returnContact = $cc->contactService->addContact(NewsletterHelper::AccessToken(), $contact, $params);
             } else {
                 /**
                  * @var $contact Contact
                  */
                 $contact = $response->results[0];
                 $contact->addList($list);
                 $returnContact = $cc->contactService->updateContact(NewsletterHelper::AccessToken(), $contact, $params);
             }
             $mensaje->add_mensaje('Tu correo se ha añadido correctamente a la lista');
         } catch (Exception $ex) {
             if ($ex instanceof CtctException) {
                 $allErrors = $ex->getErrors();
                 $errores = reset($allErrors);
                 $mensaje->add_error($errores->error_message);
             } else {
                 $mensaje->add_error($ex->getMessage());
             }
         }
     }
 }
예제 #24
0
파일: newsletter.php 프로젝트: Rikisha/proj
 public static function getManifest()
 {
     if (!self::$_manifest) {
         $file = JPATH_COMPONENT_ADMINISTRATOR . DS . 'newsletter.xml';
         $path = JPath::clean($file);
         if (file_exists($path)) {
             self::$_manifest = simplexml_load_file($path);
         } else {
             self::$_manifest = new JObject();
         }
     }
     return self::$_manifest;
 }