diff --git a/administrator/views/hierarchys/view.csv.php b/administrator/views/hierarchys/view.csv.php index edfe8b6..f246063 100644 --- a/administrator/views/hierarchys/view.csv.php +++ b/administrator/views/hierarchys/view.csv.php @@ -23,12 +23,38 @@ class HierarchyViewHierarchys extends TjExportCsv /** * Display the Hierarchy view * - * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * @param STRING $tpl template name * - * @return void + * @return Object|Boolean in case of success instance and failure - boolean + * + * @since 1.0 */ public function display($tpl = null) { - parent::display(); + $input = JFactory::getApplication()->input; + $user = JFactory::getUser(); + $userAuthorisedExport = $user->authorise('core.export', 'com_hierarchy'); + + if ($userAuthorisedExport !== true || !$user->id) + { + // Redirect to the list screen. + $redirect = JRoute::_('index.php?option=com_hierarchy&view=hierarchys', false); + JFactory::getApplication()->redirect($redirect, JText::_('JERROR_ALERTNOAUTHOR')); + + return false; + } + else + { + if ($input->get('task') == 'download') + { + $fileName = $input->get('file_name'); + $this->download($fileName); + JFactory::getApplication()->close(); + } + else + { + parent::display(); + } + } } } diff --git a/administrator/views/hierarchys/view.html.php b/administrator/views/hierarchys/view.html.php index 43709a0..322de1e 100755 --- a/administrator/views/hierarchys/view.html.php +++ b/administrator/views/hierarchys/view.html.php @@ -105,21 +105,25 @@ protected function addToolbar() // Import Csv export button jimport('techjoomla.tjtoolbar.button.csvexport'); - + $user = JFactory::getUser(); + $canExportCSV = $user->authorise('core.export', 'com_tjreports'); $bar = JToolBar::getInstance('toolbar'); $state = $this->get('State'); $canDo = HierarchyHelper::getActions($state->get('filter.category_id')); - $message = array(); - $message['success'] = JText::_("COM_HIERARCHY_EXPORT_FILE_SUCCESS"); - $message['error'] = JText::_("COM_HIERARCHY_EXPORT_FILE_ERROR"); - $message['inprogress'] = JText::_("COM_HIERARCHY_EXPORT_FILE_NOTICE"); - $message['btn-name'] = JText::_("COM_HIERARCHY_EXPORT_CSV"); - - if ($canDo->get('core.csv.export')) + if (!empty($this->items) && $canExportCSV === true && $user->id) { - $bar->appendButton('CsvExport', $message); + $message = array(); + $message['success'] = JText::_("COM_HIERARCHY_EXPORT_FILE_SUCCESS"); + $message['error'] = JText::_("COM_HIERARCHY_EXPORT_FILE_ERROR"); + $message['inprogress'] = JText::_("COM_HIERARCHY_EXPORT_FILE_NOTICE"); + $message['btn-name'] = JText::_("COM_HIERARCHY_EXPORT_CSV"); + + if ($canDo->get('core.csv.export')) + { + $bar->appendButton('CsvExport', $message); + } } JToolBarHelper::title(JText::_('COM_HIERARCHY_TITLE_HIERARCHYS'), 'list');