Exemplo n.º 1
0
 /**
  * 	Handle the importing from other known components
  *
  *  @return void
  *  @since  1.0
  */
 public function import()
 {
     $com = JRequest::getString('jform-com', null);
     $type = JRequest::getString('jform-import-type', null);
     if (empty($com) || empty($type)) {
         $app = JFactory::getApplication()->enqueueMessage(JText::_('COM_NEWSLETTER_RUQUIRED_MISSING', 'error'));
         $this->setRedirect(JRoute::_('index.php?option=com_newsletter&tmpl=component&view=import', false));
         return;
     }
     $component = DataHelper::getComponentInstance($com);
     if ($type == 'lists') {
         $arr = $component->exportLists();
     }
     if ($arr === false) {
         $app = JFactory::getApplication()->enqueueMessage(JText::_('COM_NEWSLETTER_IMPORT_ERROR', 'error'));
         $this->setRedirect(JRoute::_('index.php?option=com_newsletter&tmpl=component&view=import', false));
         return;
     }
     $res = $component->importLists($arr);
     if ($res === false) {
         $app = JFactory::getApplication()->enqueueMessage(JText::_('COM_NEWSLETTER_IMPORT_ERROR', 'error'));
         $this->setRedirect(JRoute::_('index.php?option=com_newsletter&tmpl=component&view=import', false));
         return;
     }
     $app = JFactory::getApplication()->enqueueMessage(JText::_('COM_NEWSLETTER_IMPORT_SUCCESSFUL') . '. ' . JText::sprintf('COM_NEWSLETTER_N_SUBSCRIBERS_IMPORTED', $res), 'message');
     $this->setRedirect(JRoute::_('index.php?option=com_newsletter&tmpl=component&view=close', false));
 }