diff --git a/modules/backend/behaviors/ImportExportController.php b/modules/backend/behaviors/ImportExportController.php
index 0381ff269..a78a1707f 100644
--- a/modules/backend/behaviors/ImportExportController.php
+++ b/modules/backend/behaviors/ImportExportController.php
@@ -2,6 +2,8 @@
use Str;
use Lang;
+use View;
+use Response;
use Backend;
use Backend\Classes\ControllerBehavior;
use League\Csv\Reader as CsvReader;
@@ -124,6 +126,10 @@ class ImportExportController extends ControllerBehavior
public function import()
{
+ if ($response = $this->checkPermissionsForType('import')) {
+ return $response;
+ }
+
$this->addJs('js/october.import.js', 'core');
$this->addCss('css/import.css', 'core');
@@ -135,6 +141,10 @@ class ImportExportController extends ControllerBehavior
public function export()
{
+ if ($response = $this->checkPermissionsForType('export')) {
+ return $response;
+ }
+
$this->checkUseListExportMode();
$this->addJs('js/october.export.js', 'core');
@@ -265,8 +275,15 @@ class ImportExportController extends ControllerBehavior
if ($this->importColumns !== null) {
return $this->importColumns;
}
+
$columnConfig = $this->getConfig('import[list]');
- return $this->importColumns = $this->makeListColumns($columnConfig);
+ $columns = $this->makeListColumns($columnConfig);
+
+ if (empty($columns)) {
+ throw new ApplicationException('Please specify some columns to import.');
+ }
+
+ return $this->importColumns = $columns;
}
protected function getImportFileColumns()
@@ -432,8 +449,15 @@ class ImportExportController extends ControllerBehavior
if ($this->exportColumns !== null) {
return $this->exportColumns;
}
+
$columnConfig = $this->getConfig('export[list]');
- return $this->exportColumns = $this->makeListColumns($columnConfig);
+ $columns = $this->makeListColumns($columnConfig);
+
+ if (empty($columns)) {
+ throw new ApplicationException('Please specify some columns to export.');
+ }
+
+ return $this->exportColumns = $columns;
}
protected function makeExportFormatFormWidget()
@@ -587,6 +611,21 @@ class ImportExportController extends ControllerBehavior
return $contents;
}
+ /**
+ * Checks to see if the import/export is controlled by permissions
+ * and if the logged in user has permissions.
+ * @return \View
+ */
+ protected function checkPermissionsForType($type)
+ {
+ if (
+ ($permissions = $this->getConfig($type.'[permissions]')) &&
+ (!$this->controller->user->hasAnyAccess((array) $permissions))
+ ) {
+ return Response::make(View::make('backend::access_denied'), 403);
+ }
+ }
+
protected function makeOptionsFormWidgetForType($type)
{
if (!$this->getConfig($type)) {
@@ -632,7 +671,12 @@ class ImportExportController extends ControllerBehavior
$result = [];
foreach ($config->columns as $attribute => $column) {
- $result[$attribute] = array_get($column, 'label', $attribute);
+ if (is_array($column)) {
+ $result[$attribute] = array_get($column, 'label', $attribute);
+ }
+ else {
+ $result[$attribute] = $column ?: $attribute;
+ }
}
return $result;
diff --git a/modules/backend/behaviors/importexportcontroller/partials/_import_db_columns.htm b/modules/backend/behaviors/importexportcontroller/partials/_import_db_columns.htm
index b66f599e2..00eeef412 100644
--- a/modules/backend/behaviors/importexportcontroller/partials/_import_db_columns.htm
+++ b/modules/backend/behaviors/importexportcontroller/partials/_import_db_columns.htm
@@ -10,7 +10,7 @@
data-column-name="= e($column) ?>">
- = e($label) ?>
+ = e(trans($label)) ?>
diff --git a/modules/backend/behaviors/importexportcontroller/partials/fields_import.yaml b/modules/backend/behaviors/importexportcontroller/partials/fields_import.yaml
index b8c7f1c80..adee49efd 100644
--- a/modules/backend/behaviors/importexportcontroller/partials/fields_import.yaml
+++ b/modules/backend/behaviors/importexportcontroller/partials/fields_import.yaml
@@ -22,7 +22,7 @@ fields:
span: left
step2_section:
- label: 2. Match database fields to the CSV columns
+ label: 2. Match the file columns to database fields
type: section
column_control_panel: