Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions administrator/views/hierarchys/view.csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
}
22 changes: 13 additions & 9 deletions administrator/views/hierarchys/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down