mirror of
https://github.com/farmOS/farmOS.git
synced 2024-02-23 11:37:38 +01:00
62 lines
1.3 KiB
Plaintext
62 lines
1.3 KiB
Plaintext
<?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';
|
|
}
|
|
return $return;
|
|
}
|
|
|
|
/**
|
|
* 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;
|
|
}
|
|
|
|
/**
|
|
* Implements hook_farm_ui_actions().
|
|
*/
|
|
function farm_import_farm_ui_actions() {
|
|
$actions = array();
|
|
|
|
// Load entity UI information.
|
|
$ui_info = farm_ui_entities();
|
|
|
|
// Add action links to asset importers on asset listing pages.
|
|
if (!empty($ui_info['farm_asset'])) {
|
|
foreach ($ui_info['farm_asset'] as $bundle => $info) {
|
|
if (!empty($info['view'])) {
|
|
$actions[$bundle . '_import'] = array(
|
|
'title' => t('Import') . ' ' . strtolower($info['label_plural']),
|
|
'href' => 'import/farm_asset_' . $bundle,
|
|
'views' => array(
|
|
$info['view'],
|
|
),
|
|
'weight' => 100,
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
return $actions;
|
|
}
|