/** * 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')); }
/** * Save the configuration to component * * @return void * @since 1.0 */ function save() { // Check for request forgeries. JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Set FTP credentials, if given. jimport('joomla.client.helper'); JClientHelper::setCredentialsFromRequest('ftp'); // Initialise variables. $app = JFactory::getApplication(); $model = $this->getModel('configuration'); $form = $model->getForm(); $data = JRequest::getVar('jform', array(), 'post', 'array'); $id = JRequest::getInt('id'); $option = "com_newsletter"; // Check if the user is authorized to do this. if (!AclHelper::canConfigureComponent()) { AclHelper::redirectToAccessDenied(); return; } // Validate the posted data. $return = $model->validate($form, $data); // Check for validation errors. if ($return === false) { // Get the validation messages. $errors = $model->getErrors(); // Push up to three validation messages out to the user. for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) { if (JError::isError($errors[$i])) { $app->enqueueMessage($errors[$i]->getMessage(), 'warning'); } else { $app->enqueueMessage($errors[$i], 'warning'); } } // Save the data in the session. $app->setUserState('com_newsletter.config.global.data', $data); // Redirect back to the edit screen. $this->setRedirect(JRoute::_('index.php?option=com_newsletter&view=configuration', false)); return false; } // Attempt to save the configuration. $data = array('params' => $return, 'id' => $id, 'option' => $option); $newsletter = JModel::getInstance('Newsletter', 'NewsletterModelEntity'); $newsletter->loadFallBackNewsletter(); $newsletter->subject = $data['params']['confirm_mail_subject']; $newsletter->plain = $data['params']['confirm_mail_body']; $return2 = $newsletter->save(); unset($data['params']['confirm_mail_subject']); unset($data['params']['confirm_mail_body']); $data['option'] = 'com_newsletter'; $return = $model->save($data); // Check the return value. if ($return2 === false || $return === false) { // Save the data in the session. $app->setUserState('com_newsletter.config.global.data', $data); // Save failed, go back to the screen and display a notice. $message = JText::sprintf('JERROR_SAVE_FAILED', $model->getError()); $this->setRedirect('index.php?option=com_newsletter&view=configuration', $message, 'error'); return false; } // Set the redirect based on the task. switch ($this->getTask()) { case 'apply': $message = JText::_('COM_NEWSLETTER_SAVE_SUCCESS'); $this->setRedirect('index.php?option=com_newsletter&view=configuration', $message); break; case 'save': default: $this->setRedirect('index.php?option=com_newsletter&view=configuration'); break; } JFactory::getCache('com_newsletter')->clean(); $this->licDontCheck = true; return true; }
echo JHtml::_('tabs.panel', JText::_('COM_NEWSLETTER_NEWSLETTERS'), 'tab-newsletters'); echo $this->loadTemplate('newsletters', 'config'); echo JHtml::_('tabs.panel', JText::_('COM_NEWSLETTER_TEMPLATES'), 'tab-templates'); echo $this->loadTemplate('templates', 'config'); echo JHtml::_('tabs.panel', JText::_('COM_NEWSLETTER_SUBSCRIBERS'), 'tab-subscribers'); echo $this->loadTemplate('subscribers', 'config'); echo JHtml::_('tabs.panel', JText::_('COM_NEWSLETTER_ADVANCED'), 'tab-advanced'); echo $this->loadTemplate('advanced', 'config'); echo JHtml::_('tabs.panel', JText::_('COM_NEWSLETTER_IMPORT_EXPORT'), 'tab-export'); echo $this->loadTemplate('export', 'config'); echo JHtml::_('tabs.panel', JText::_('COM_NEWSLETTER_PERMISSIONS'), 'tab-permissions'); ?> <?php // First check if user has access to the component. if (AclHelper::canConfigureComponent()) { echo $this->loadTemplate('permissions', 'config'); } else { ?> <center> <?php echo JText::_('COM_NEWSLETTER_YOU_CANT_CHANGE_COMPONENT_PERMISSIONS'); ?> </center> <?php } echo JHtml::_('tabs.end'); ?> <div> <input type="hidden" name="task" value="" /> <input type="hidden" name="returnurl" value="<?php