2017-06-29 19:29:55 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Farm import module.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_ctools_plugin_api().
|
|
|
|
*/
|
|
|
|
function farm_import_ctools_plugin_api($module = NULL, $api = NULL) {
|
|
|
|
$return = array();
|
|
|
|
if ($module == 'feeds' && $api == 'feeds_importer_default') {
|
|
|
|
$return['version'] = '1';
|
|
|
|
}
|
2017-07-04 14:46:41 +02:00
|
|
|
if ($module == 'feeds_tamper' && $api == 'feeds_tamper_default') {
|
|
|
|
$return['version'] = '2';
|
|
|
|
}
|
2017-06-29 19:29:55 +02:00
|
|
|
return $return;
|
|
|
|
}
|
2017-06-29 20:53:34 +02:00
|
|
|
|
2017-06-29 21:32:49 +02:00
|
|
|
/**
|
|
|
|
* Implements hook_farm_access_perms().
|
|
|
|
*/
|
|
|
|
function farm_import_farm_access_perms($role) {
|
|
|
|
$perms = array();
|
|
|
|
|
|
|
|
// Grant farm managers access to Feeds importers.
|
|
|
|
if ($role == 'Farm Manager') {
|
|
|
|
$types = farm_asset_types();
|
|
|
|
foreach ($types as $type) {
|
|
|
|
$perms[] = 'import farm_asset_' . $type->type . ' feeds';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $perms;
|
|
|
|
}
|
|
|
|
|
2017-06-29 20:53:34 +02:00
|
|
|
/**
|
|
|
|
* Implements hook_farm_ui_actions().
|
|
|
|
*/
|
|
|
|
function farm_import_farm_ui_actions() {
|
|
|
|
$actions = array();
|
|
|
|
|
|
|
|
// Load entity UI information.
|
|
|
|
$ui_info = farm_ui_entities();
|
|
|
|
|
2017-07-04 19:53:57 +02:00
|
|
|
// Add action links to asset and log importers on listing pages.
|
|
|
|
$types = array(
|
|
|
|
'farm_asset',
|
|
|
|
'log',
|
|
|
|
);
|
|
|
|
foreach ($types as $type) {
|
|
|
|
if (!empty($ui_info[$type])) {
|
|
|
|
foreach ($ui_info[$type] as $bundle => $info) {
|
|
|
|
if (!empty($info['view'])) {
|
|
|
|
$actions[$bundle . '_import'] = array(
|
|
|
|
'title' => t('Import') . ' ' . strtolower($info['label_plural']),
|
|
|
|
'href' => 'import/' . $type . '_' . $bundle,
|
|
|
|
'views' => array(
|
|
|
|
$info['view'],
|
|
|
|
),
|
|
|
|
'weight' => 100,
|
|
|
|
);
|
|
|
|
}
|
2017-06-29 20:53:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $actions;
|
|
|
|
}
|