Beispiel #1
0
 /**
  * Displays the view.
  *
  * @param  string $tpl the template name
  *
  * @return void
  * @since  1.0
  */
 public function display($tpl = null)
 {
     $isNew = !JRequest::getInt('list_id', false);
     if ($isNew && !AclHelper::actionIsAllowed('list.add') || !$isNew && !AclHelper::actionIsAllowed('list.edit')) {
         $msg = $isNew ? 'JLIB_APPLICATION_ERROR_CREATE_RECORD_NOT_PERMITTED' : 'JLIB_APPLICATION_ERROR_EDIT_NOT_PERMITTED';
         JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_newsletter&view=subscribers', false), JText::_($msg), 'error');
         return;
     }
     //TODO: Bulk-code. Need to refactor
     $listId = JRequest::getInt('list_id', 0);
     switch (JRequest::getString('subtask', '')) {
         case 'import':
             $this->subtask = 1;
             break;
         case 'exclude':
             $this->subtask = 2;
             break;
         default:
             $this->subtask = 0;
     }
     JavaScriptHelper::addStringVar('subtask', $this->subtask);
     $script = $this->get('Script');
     $this->script = $script;
     $this->listForm = $this->get('Form', 'list');
     $this->setModel(JModel::getInstance('subscribers', 'NewsletterModel'));
     $sess = JFactory::getSession();
     $data = $sess->get('list.' . $listId . '.file.uploaded');
     if ($data) {
         JavaScriptHelper::addObject('uploadData', $data);
     }
     $modelSubs = new NewsletterModelSubscribers();
     $modelSubs->setState('list.limit', 10);
     if (!empty($listId)) {
         $this->subs = $modelSubs->getSubscribersByList(array('list_id' => JRequest::getInt('list_id')));
         $items = $modelSubs->getUnsubscribedList(array('list_id' => JRequest::getInt('list_id')));
     } else {
         $items = array();
         $this->subs = array();
     }
     $ss = (object) array('items' => $items, 'state' => $modelSubs->getState(), 'listOrder' => $modelSubs->getState('list.unsubscribed.ordering'), 'listDirn' => $modelSubs->getState('list.unsubscribed.direction'));
     $this->assignRef('subscribers', $ss);
     // get data for "excluded"
     $model = JModel::getInstance('lists', 'NewsletterModel');
     // get only active lists
     $model->setState('filter.fields', array('a.state="1"', 'a.list_id<>' . JRequest::getInt('list_id')));
     $this->lists = (object) array('items' => $model->getItems(), 'state' => $model->getState(), 'listOrder' => $model->getState('list.ordering'), 'listDirn' => $model->getState('list.direction'));
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     // We don't need toolbar in the modal window.
     $this->addToolbar();
     $config = JComponentHelper::getParams('com_media');
     $app = JFactory::getApplication();
     $lang = JFactory::getLanguage();
     $append = '';
     if ($config->get('enable_flash', 1)) {
         JHTML::stylesheet('media/com_newsletter/css/uploaders.css');
         JHTML::script(JURI::root() . "administrator/components/com_newsletter/views/list/uploaders.js");
         $fileTypes = $config->get('image_extensions', 'bmp,gif,jpg,png,jpeg');
         $types = explode(',', $fileTypes);
         $displayTypes = '';
         // this is what the user sees
         $filterTypes = '';
         // this is what controls the logic
         $firstType = true;
         foreach ($types as $type) {
             if (!$firstType) {
                 $displayTypes .= ', ';
                 $filterTypes .= '; ';
             } else {
                 $firstType = false;
             }
             $displayTypes .= '*.' . $type;
             $filterTypes .= '*.' . $type;
         }
         $typeString = '{ \'' . JText::_('COM_MEDIA_FILES', 'true') . ' (' . $displayTypes . ')\': \'' . $filterTypes . '\' }';
     }
     /*
      * Display form for FTP credentials?
      * Don't set them here, as there are other functions called before this one if there is any file write operation
      */
     jimport('joomla.client.helper');
     $ftp = !JClientHelper::hasCredentials('ftp');
     $this->assignRef('session', JFactory::getSession());
     $this->assignRef('config', $config);
     $this->assignRef('state', $this->get('state'));
     $this->assignRef('folderList', $this->get('folderList'));
     $this->assign('require_ftp', $ftp);
     $this->setStatisticsData();
     // Set the document
     $this->setDocument();
     parent::display($tpl);
 }