/** * 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')); }
/** * 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); }
/** * See parent's phpdoc * * @return boolean * @since 11.1 */ protected function allowEdit($data = array(), $key = 'id') { return AclHelper::actionIsAllowed('list.edit'); }
/** * 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&view=statistic&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')); }
/** * 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; }
/** * Add the page title and toolbar. * * @return void * @since 1.0 */ protected function addToolbar() { $isNew = !JRequest::getInt('list_id', false); $bar = JToolBar::getInstance('multitab-toolbar'); if ($isNew && AclHelper::actionIsAllowed('list.add') || !$isNew && AclHelper::actionIsAllowed('list.edit')) { $bar->appendButton('Standard', 'apply', 'JTOOLBAR_APPLY', 'list.apply', false); $bar->appendButton('Standard', 'save', 'JTOOLBAR_SAVE', 'list.save', false); } $bar->appendButton('Link', 'cancel', 'JTOOLBAR_CLOSE', 'index.php?option=com_newsletter&view=close&tmpl=component', false); $bar = MigurToolBar::getInstance('import-toolbar'); $bar->appendButton('Link', 'export', 'COM_NEWSLETTER_IMPORT_FROM_FILE', '#'); }
<?php if (count($this->items) > 0) { foreach ($this->items as $i => $item) { ?> <tr class="row<?php echo $i % 2; ?> "> <td class="center"> <?php echo JHtml::_('grid.id', $i, $item->id); ?> </td> <td> <?php if (AclHelper::actionIsAllowed('newsletter.edit')) { ?> <a href="<?php echo JRoute::_("index.php?option=com_newsletter&task=newsletter.edit&newsletter_id=" . (int) $item->id, false); ?> "> <?php echo $this->escape($item->name); ?> </a> <?php } else { echo $this->escape($item->name); } ?> </td>
JPluginHelper::importPlugin('migur'); $app = JFactory::getApplication(); $app->triggerEvent('onMigurNewsletterStart'); // Handle the messages from previous requests $sess = JFactory::getSession(); $msg = $sess->get('migur.queue'); if ($msg) { $sess->set('application.queue', $msg); $sess->set('migur.queue', null); } JFormHelper::addRulePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'rules'); JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables'); JModel::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'entities', 'NewsletterModelEntity'); // Add the site root and user's ACL to JS JavascriptHelper::addStringVar('migurSiteRoot', JUri::root()); JavascriptHelper::addObject('migurUserAcl', AclHelper::toArray()); // 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();
<form class="form-validate" method="POST" action="<?php echo JURI::base(); ?> index.php?option=com_newsletter&view=list&tmpl=component&<?php echo $this->session->getName() . '=' . $this->session->getId(); ?> &<?php echo JUtility::getToken(); ?> =1" enctype="multipart/form-data" id="listForm" name="listForm"> <?php echo JToolBar::getInstance('multitab-toolbar')->render(); echo JHtml::_('tabs.start', 'tabs-list', array('startOffset' => $this->subtask)); echo JHtml::_('tabs.panel', JText::_('COM_NEWSLETTER_OVERVIEW'), 'tab-overview'); echo $this->loadTemplate('overview', ''); if ($this->isNew && AclHelper::actionIsAllowed('list.add') || !$this->isNew && AclHelper::actionIsAllowed('list.edit')) { echo JHtml::_('tabs.panel', JText::_('COM_NEWSLETTER_IMPORT'), 'tab-import'); echo $this->loadTemplate('import', ''); echo JHtml::_('tabs.panel', JText::_('COM_NEWSLETTER_EXCLUDE'), 'tab-exclude'); echo $this->loadTemplate('exclude', ''); } echo JHtml::_('tabs.panel', JText::_('COM_NEWSLETTER_SUBSCRIBERS'), 'tab-subscribers'); echo $this->loadTemplate('subscribers', ''); echo JHtml::_('tabs.panel', JText::_('COM_NEWSLETTER_UNSUBSCRIBED'), 'tab-unsubscribed'); echo $this->loadTemplate('unsubscribed', ''); echo JHtml::_('tabs.panel', JText::_('COM_NEWSLETTER_ADVANCED'), 'tab-advanced'); echo $this->loadTemplate('advanced', ''); echo JHtml::_('tabs.end'); ?> <input type="hidden" name="list_id" value="<?php
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
/** * 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&task=subscriber.add&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&view=list&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')); }
public static function toArray() { if (self::$_toArrayCache !== null) { return self::$_toArrayCache; } $user = JFactory::getUser(); $result = array(); $actions = self::getActions(); foreach ($actions as $action) { $access = $user->authorise($action, 'com_newsletter'); $result[$action] = $access !== null ? $access : self::$resultForNonsetAction; } self::$_toArrayCache = $result; return self::$_toArrayCache; }
public function appendButton() { $args = func_get_args(); $action = $args[1]; if ($this->_useAcl) { if (!AclHelper::actionIsAllowed($this->_actionPrefix . '.' . $action)) { return false; } } return call_user_func_array(array('parent', 'appendButton'), $args); }
<tbody> <?php foreach ($this->lists->items as $i => $item) { ?> <tr class="row<?php echo $i % 2; ?> "> <td> <?php echo JHtml::_('multigrid.id', $i, $item->list_id, false, 'cid', 'listsForm'); ?> </td> <td> <?php if (AclHelper::actionIsAllowed('list.edit')) { ?> <a href="<?php echo JRoute::_("index.php?option=com_newsletter&tmpl=component&layout=edit&task=list.edit&list_id=" . (int) $item->list_id, false); ?> " rel="{handler: 'iframe', size: {x: 990, y: 580}}" class="modal" > <?php echo $this->escape($item->name); ?> </a> <?php } else { echo $this->escape($item->name); }