farm_mapknitter.module in farmOS 7
Code for the Farm MapKnitter module.
File
modules/farm/farm_mapknitter/farm_mapknitter.moduleView source
<?php
/**
* @file
* Code for the Farm MapKnitter module.
*/
/**
* Implements hook_permission().
*/
function farm_mapknitter_permission() {
$perms = array(
'administer farm_mapknitter module' => array(
'title' => t('Administer farm MapKnitter module'),
),
);
return $perms;
}
/**
* Implements hook_farm_access_perms().
*/
function farm_mapknitter_farm_access_perms($role) {
$perms = array();
// Load the list of farm roles.
$roles = farm_access_roles();
// If this role has 'config' access, grant administer permission
if (!empty($roles[$role]['access']['config'])) {
$perms[] = 'administer farm_mapknitter module';
}
return $perms;
}
/**
* Implements hook_menu().
*/
function farm_mapknitter_menu() {
$items = array();
$items['admin/config/farm/mapknitter'] = array(
'title' => 'MapKnitter',
'description' => 'Include a MapKnitter layer in your farm maps.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'farm_mapknitter_form',
),
'access arguments' => array(
'administer farm_mapknitter module',
),
);
return $items;
}
/**
* MapKnitter configuration form.
*/
function farm_mapknitter_form($form, &$form_state) {
// MapKnitter layer title.
$form['farm_mapknitter_title'] = array(
'#type' => 'textfield',
'#title' => t('MapKnitter layer title'),
'#description' => t('Give your MapKnitter layer a name. This will be used in the layer switcher '),
'#default_value' => variable_get('farm_mapknitter_title', ''),
);
// MapKnitter slug.
$form['farm_mapknitter_slug'] = array(
'#type' => 'textfield',
'#title' => t('MapKnitter Slug'),
'#description' => t('Enter the unique MapKnitter slug. This would be the [map-slug] part in your MapKnitter map URL: http://mapknitter.org/maps/[map-slug]'),
'#default_value' => variable_get('farm_mapknitter_slug', ''),
);
return system_settings_form($form);
}
Functions
Name | Description |
---|---|
farm_mapknitter_farm_access_perms | Implements hook_farm_access_perms(). |
farm_mapknitter_form | MapKnitter configuration form. |
farm_mapknitter_menu | Implements hook_menu(). |
farm_mapknitter_permission | Implements hook_permission(). |