Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create farm_api_oauth module #207

Closed
wants to merge 93 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
507c326
Add farmOS-map library to Drush makefile.
mstenta Jul 22, 2019
2bce9ef
Implement hook_libraries_info() in farm_map.module to integrate farmO…
mstenta Jul 22, 2019
6bc7e9f
Add new farm_map element type with theme function that renders a farm…
mstenta Jul 22, 2019
fbda7e5
Render new farmOS-map element in farm_map_build().
mstenta Jul 22, 2019
c0fa34f
Set the height of farmOS maps to 400px.
mstenta Jul 24, 2019
7361a17
Allow other modules to perform logic when a map is rendered via hook_…
mstenta Dec 5, 2019
18ec618
Add new hooks for defining farmOS map behaviors in Drupal, and a farm…
mstenta Dec 6, 2019
30ce3a7
Update farmOS-map.js to v0.2.0.
mstenta Dec 5, 2019
1178d1f
Change all area type styles to match those provided by farmOS-map.
mstenta Sep 11, 2019
d7c67a1
Add all area type layers to farmOS-map.
mstenta Sep 11, 2019
74a8f1d
Update farmOS-map library to v0.3.0.
mstenta Sep 18, 2019
2fbd605
Put all area layers in an "Areas" layer group.
mstenta Sep 18, 2019
9f09c05
Add a JS setting that defines the base path of the site.
mstenta Dec 6, 2019
2fb2ade
Display a popup when area features are clicked, and load area details…
mstenta Sep 18, 2019
c1ac402
Refactor farm area generator to use a farmOS-map behavior.
mstenta Dec 7, 2019
608eb04
@todo This assumes that there is only one map on the page.
mstenta Dec 7, 2019
0eea90d
Refactor NRCS Soil Survey to use a farmOS-map behavior.
mstenta Jul 24, 2019
d7fd542
Refactor farm_plan_map to use a farmOS-map behavior.
mstenta Jul 24, 2019
d67fb1c
Refactor MapKnitter module to use a farmOS-map behavior.
mstenta Sep 24, 2019
8b8ada2
Update farmOS-map library to v0.5.0.
mstenta Dec 4, 2019
942993d
Remove default base layer setting (defer to farmOS-map layer memory).
mstenta Oct 29, 2019
cc56644
Pass system of measurement into farmOS-map.
mstenta Dec 5, 2019
c8c89d1
Set onFocusOnly: true when initializing maps, so that the user must c…
mstenta Dec 5, 2019
1dbd7d4
Update farmOS-map library to v0.7.0.
mstenta Dec 6, 2019
7ea8f92
Update farmOS-map library to v0.8.0.
mstenta Jan 30, 2020
cd800b7
If WKT was provided in the element, show it in the map.
mstenta Dec 12, 2019
8baceff
If #edit is TRUE on a map element, enable the edit behavior.
mstenta Jan 30, 2020
a9a7129
Add the measure behavior to WKT layers.
mstenta Jan 30, 2020
a51da53
Initial commit of Farm Map Geofield module.
mstenta Dec 4, 2019
bfe8f91
Provide a farm_map_geofield field formatter that uses farmOS-map.
mstenta Dec 4, 2019
42ef006
Use farm_map_geofield formatter in all geofield displays.
mstenta Dec 4, 2019
7d3ad27
Show a combined "All areas" layer in geofields.
mstenta Dec 12, 2019
e93040e
Provide a farm_map_geofield field widget that uses farmOS-map.
mstenta Dec 4, 2019
2ea421a
Add Geocoder integration.
mstenta Jan 30, 2020
4f30833
Use farm_map_geofield widget in all geofields.
mstenta Dec 4, 2019
421b4d0
Install the new Farm Map Geofield module on existing sites.
mstenta Feb 7, 2020
f329def
Remove patch from Geofield - no longer needed.
mstenta Jan 5, 2020
755f076
Update farmOS-map library to v0.9.0.
mstenta Jan 30, 2020
0d3a71e
Refactor Google Maps integration to use a farmOS-map behavior.
mstenta Jul 24, 2019
e9e4859
Mapbox module: add Mapbox API key to farm map settings form and add t…
mstenta Sep 23, 2019
0f12177
Provide a Farm Map block.
mstenta Feb 7, 2020
40359f7
Show the map block as a top banner on the homepage.
mstenta Feb 7, 2020
59abbb1
Remove dashboard map pane.
mstenta Feb 7, 2020
8bb7fe4
Add JS to toggle expand/collapse map header and remember state in loc…
mstenta Feb 7, 2020
164709c
Add cluster support to the popup behavior.
mstenta Feb 7, 2020
d792512
Add behaviors for asset cluster maps.
mstenta Feb 7, 2020
ae60c5f
Display asset cluster maps in the farm map header block.
mstenta Feb 7, 2020
b8b13fd
Restrict access to the map header block so it isn't shown to anonymou…
mstenta Feb 7, 2020
9b5eb5a
Remove old farm_map_show variable.
mstenta Dec 12, 2019
7034539
Update Tours.
mstenta Jan 22, 2020
18e86f9
Refactor Drupal.behaviors.farm_map so that Drupal.settings.farm_map.m…
mstenta Feb 2, 2020
c3ca0cc
Destroy farmOS-map instances when Drupal behaviors are detached.
mstenta Feb 2, 2020
3984b8d
When AJAX reloads a geofield map, look for new WKT in $form_state['in…
mstenta Feb 2, 2020
6d8d070
Fix duplicate measure behavior on editable maps.
mstenta Feb 3, 2020
dd717a1
Fix zoom to all areas when WKT is empty.
mstenta Feb 3, 2020
c804366
If a map is inside a collapsed fieldset, update the map size when the…
mstenta Feb 3, 2020
9f6bbb8
Update farmOS-map library to v0.9.1 and add weights to behaviors.
mstenta Feb 3, 2020
b1a961a
Remove Openlayers modules, patches, dependencies, configuration, and …
mstenta Feb 7, 2020
d297855
Uninstall Openlayers modules and dependencies on existing sites.
mstenta Feb 7, 2020
7a6ae65
Update farmOS-map.js library to v0.9.2 to fix MapKnitter layers behin…
mstenta Feb 8, 2020
388ce9f
Remove "Calculated area" from area term page. It is shown in the map …
mstenta Feb 8, 2020
09691e0
Update farmOS-map.js library to v0.9.3.
mstenta Feb 8, 2020
cd87da0
Display polygon/linestring measurement in map popups.
mstenta Feb 8, 2020
c2da059
Remove "Calculated area" from area details.
mstenta Feb 8, 2020
7fe30ec
Fix Movement Geometry field settings on existing sites.
mstenta Feb 10, 2020
79190d5
Update farmOS-map library to v0.9.4.
mstenta Feb 17, 2020
797a8c4
Swap the Mapbox layers so that Satellite appears on top.
mstenta Feb 17, 2020
19579e9
When the map popup is closed, return focus to the map.
mstenta Feb 17, 2020
76bedcb
Make the Mapbox Satellite layer visible by default.
mstenta Feb 17, 2020
9f1f68b
Add farm_api_oauth as a submodule of farm_api.
paul121 Jan 16, 2020
e20cbac
Update the farm.json endpoint to check for OAuth Scopes.
paul121 Jan 16, 2020
16d498c
Update hook_farm_info api example.
paul121 Jan 16, 2020
d60fffa
Update farm_api_farm_info to require the farm_info scope for basic info.
paul121 Jan 16, 2020
f3e190f
Fix deletion of oauth2_server_client and oauth2_server_scope entities.
paul121 Jan 23, 2020
68fcc98
Do not enable the client_credentials grant, client secret by default.…
paul121 Jan 23, 2020
1c42b14
Disable the implicit OAuth flow by default. OAuth standards no longer…
paul121 Jan 23, 2020
c3b3250
Add oauth2-server-php library to drupal-org.make.
paul121 Jan 23, 2020
81e93db
Add contrib modules to drupal-org.make that support farm_api_oauth.
paul121 Jan 23, 2020
7eb24ee
Merge farm.install from farmOS-map branch.
paul121 Jan 23, 2020
a0c42c3
Add farm_api_oauth to the list of default farm modules.
paul121 Jan 24, 2020
6a74de4
Refactor to allow adding oauth clients via hook_farm_oauth_client, an…
paul121 Jan 28, 2020
f1aaf17
Refactor to allow modules to add oauth clients via hook_api
paul121 Jan 31, 2020
7e8de36
Remove default OAuth client.
paul121 Feb 27, 2020
2ddb9c9
Merge farm_api_oauth into farm_api.
paul121 Feb 28, 2020
e58352e
Rename hook_farm_oauth_client to hook_farm_api_oauth2_client.
paul121 Feb 28, 2020
038fca0
Allow modules to provide an option oauth2 client_secret.
paul121 Feb 28, 2020
acc8260
Document hook_farm_api_oauth2_client.
paul121 Feb 28, 2020
0cbc892
Remove redundant variable defining oauth2_server_name.
paul121 Feb 28, 2020
91f2975
Remove unnecessary variable.
paul121 Feb 28, 2020
8c54d40
Refactor to use hook_install and hook_uninstall not disable and enable.
paul121 Feb 28, 2020
2cbbf14
Enable the farmOS OAuth2 server on existing sites.
paul121 Feb 28, 2020
d9a4bac
Create separate farm_api_development module for development with OAuth.
paul121 Feb 28, 2020
877b628
Refactor authorized_callback.js to Drupal JS conventions.
paul121 Feb 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 15 additions & 36 deletions drupal-org.make
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ projects[geocoder][version] = "1.4"

projects[geofield][subdir] = "contrib"
projects[geofield][version] = "2.4"
; Patch to fix deleting map features.
projects[geofield][patch][] = "http://www.drupal.org/files/issues/geofield-delete_feature_fix-1350320-20.patch"

projects[geophp][subdir] = "contrib"
projects[geophp][version] = "1.x-dev"
Expand Down Expand Up @@ -100,31 +98,6 @@ projects[multiupload_imagefield_widget][version] = "1.3"
projects[navbar][subdir] = "contrib"
projects[navbar][version] = "1.7"

projects[openlayers][subdir] = "contrib"
projects[openlayers][download][type] = "git"
projects[openlayers][download][url] = "https://git.drupal.org/project/openlayers.git"
projects[openlayers][download][branch] = "7.x-3.x"
projects[openlayers][download][revision] = "569e90ca74ea1862c9ecfbc16836242e205de778"
; Move Elements dependency to Openlayers Examples.
projects[openlayers][patch][] = "http://www.drupal.org/files/issues/openlayers_examples_elements_dependency-2620098-2.patch"
; Switch to ROADMAP when zoomed further than Google's max zoom level.
projects[openlayers][patch][] = "http://www.drupal.org/files/issues/openlayers_gmap_zoom_switch_type-2680273-1.patch"
; Add a jQuery trigger event when popups are displayed.
projects[openlayers][patch][] = "http://www.drupal.org/files/issues/openlayers_popup_trigger-2687781-1.patch"
; Issue #2644580: Maps with Google layers break when loaded in invisible element
projects[openlayers][patch][] = "http://www.drupal.org/files/issues/openlayers_googlemaps_refresh-2644580-19.patch"
; Issue #2911611: Update ZoomToSource Component: use new view.animate() method.
projects[openlayers][patch][] = "http://www.drupal.org/files/issues/openlayers_ol4_zoomtosource-2911611-4.patch"
; Issue #2946213: Google maps do not support fractional zoom
projects[openlayers][patch][] = "http://www.drupal.org/files/issues/openlayers_googlemaps_fractional_zoom-2946213-2.patch"
; Issue #3006751: PHP 7 support
projects[openlayers][patch][] = "http://www.drupal.org/files/issues/2018-10-30/openlayers-2952602-6-php-72.patch"
; Remove base layer assignment code.
projects[openlayers][patch][] = "http://www.drupal.org/files/issues/2018-11-01/openlayers_base_layer_mechanism-2543130-12.patch"

projects[openlayers_geolocate_button][subdir] = "contrib"
projects[openlayers_geolocate_button][version] = "3.2"

projects[pathauto][subdir] = "contrib"
projects[pathauto][version] = "1.3"
; Fix SQLite3 issue.
Expand All @@ -133,9 +106,6 @@ projects[pathauto][patch][] = "http://www.drupal.org/files/issues/2582655-path-p
projects[pathauto_entity][subdir] = "contrib"
projects[pathauto_entity][version] = "1.0"

projects[registry_autoload][subdir] = "contrib"
projects[registry_autoload][version] = "1.3"

projects[restws][subdir] = "contrib"
projects[restws][version] = "2.8"
; Add ability to filter by entity bundle.
Expand All @@ -153,9 +123,6 @@ projects[restws_file][version] = "1.3"
; Fix Issue #3019850: Notice: Trying to get property of non-object in restws_file_restws_request_alter() (line 30 of restws_file.module).
projects[restws_file][patch][] = "http://www.drupal.org/files/issues/2019-10-26/restws_file-bundlenotice-3019850-3.patch"

projects[service_container][subdir] = "contrib"
projects[service_container][version] = "1.0-beta5"

projects[strongarm][subdir] = "contrib"
projects[strongarm][version] = "2.0"

Expand All @@ -179,6 +146,15 @@ projects[views_geojson][version] = "1.0-beta3"
projects[views_tree][subdir] = "contrib"
projects[views_tree][version] = "2.0"

projects[xautoload][subdir] = "contrib"
projects[xautoload][version] = "5.7"

projects[oauth2_server][subdir] = "contrib"
projects[oauth2_server][version] = "1.7"

projects[restws_oauth2_server][subdir] = "contrib"
projects[restws_oauth2_server][version] = "1.x-dev"

; -----------------------------------------------------------------------------
; Modules (Development)
; -----------------------------------------------------------------------------
Expand All @@ -205,11 +181,14 @@ libraries[backbone][download][url] = "http://github.com/jashkenas/backbone/archi
libraries[easy-responsive-tabs][download][type] = "get"
libraries[easy-responsive-tabs][download][url] = "https://github.com/samsono/Easy-Responsive-Tabs-to-Accordion/archive/1.2.2.zip"

libraries[farmOS-map][download][type] = "get"
libraries[farmOS-map][download][url] = "http://github.com/farmOS/farmOS-map/releases/download/v0.9.4/v0.9.4-dist.zip"

libraries[modernizr][download][type] = "get"
libraries[modernizr][download][url] = "http://github.com/Modernizr/Modernizr/archive/v2.8.3.zip"

libraries[openlayers3][download][type] = "get"
libraries[openlayers3][download][url] = "http://github.com/openlayers/openlayers/releases/download/v4.6.4/v4.6.4.zip"

libraries[underscore][download][type] = "get"
libraries[underscore][download][url] = "http://github.com/jashkenas/underscore/archive/1.9.1.zip"

libraries[oauth2-server-php][download][type] = "get"
libraries[oauth2-server-php][download][url] = "http://github.com/bshaffer/oauth2-server-php/archive/v1.11.1.zip"
158 changes: 137 additions & 21 deletions farm.install
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ function farm_modules() {
'farm_help' => st('farmOS Help Pages'),
'farm_tour' => st('farmOS Tours'),
'farm_api' => st('farmOS API'),
'farm_api_oauth' => st('farmOS API OAuth2 Server'),
),
'optional' => array(
'farm_water_test' => st('Water test logs'),
'farm_soil_compost' => st('Compost'),
'farm_sensor' => st('Sensor'),
'farm_sensor_listener' => st('Sensor: Listener'),
'farm_ledger' => st('Sale and purchase logs (beta)'),
'farm_quantity_report' => st('Quantity report generator (beta)'),
),
);
}
Expand All @@ -71,9 +73,6 @@ function farm_install() {

// Use the farm menu for primary links (provided by farm_admin).
variable_set('menu_main_links_source', 'farm');

// Set the Openlayers library variant to local.
\Drupal\openlayers\Config::set('openlayers.variant', 'local:4.6.4');
}

/**
Expand Down Expand Up @@ -132,10 +131,18 @@ function farm_install_configure_form($form, &$form_state) {
$form['farm_map_google_api_key'] = array(
'#type' => 'textfield',
'#title' => t('Google Maps API Key'),
'#description' => t('Google Maps layers require that you obtain an API key. Refer to the <a href="@doc">Google Maps API Key</a> documentation on farmOS.org for instructions.', array('@doc' => 'https://farmos.org/hosting/googlemaps')) . ' ' . t('This can also be done after installation. If no key is provided, OpenStreetMaps will be used as the default map base layer.'),
'#description' => t('Google Maps layers require that you obtain an API key. Refer to the <a href="@doc">Google Maps API Key</a> documentation on farmOS.org for instructions.', array('@doc' => 'https://farmos.org/hosting/googlemaps')) . ' ' . t('This can also be done after installation.'),
'#default_value' => variable_get('farm_map_google_api_key', ''),
);

// Allow the user to enter a Mapbox API key.
$form['farm_map_mapbox_api_key'] = array(
'#type' => 'textfield',
'#title' => t('Mapbox API Key'),
'#description' => t('Enter your Mapbox API key.') . ' ' . t('This can also be done after installation.'),
'#default_value' => variable_get('farm_map_mapbox_api_key', ''),
);

// Form actions.
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
Expand All @@ -162,14 +169,20 @@ function farm_install_configure_form_submit($form, &$form_state) {
variable_set('farm_quantity_unit_system', $form_state['values']['farm_quantity_unit_system']);
}

// Save the Google Maps API key, and make Google Hybrid the default.
// If a Google Maps API key was not provided, make OpenStreetMap the default.
// If a Google Maps API key was provided, save it and enable the module.
if (!empty($form_state['values']['farm_map_google_api_key'])) {
variable_set('farm_map_google_api_key', $form_state['values']['farm_map_google_api_key']);
variable_set('farm_map_default_base_layer', 'farm_map_layer_google_hybrid');
if (!module_exists('farm_map_google')) {
module_enable(array('farm_map_google'));
}
}
else {
variable_set('farm_map_default_base_layer', 'farm_map_layer_openstreetmap');

// If a Mapbox API key was provided, save it and enable the module.
if (!empty($form_state['values']['farm_map_mapbox_api_key'])) {
variable_set('farm_map_mapbox_api_key', $form_state['values']['farm_map_mapbox_api_key']);
if (!module_exists('farm_map_mapbox')) {
module_enable(array('farm_map_mapbox'));
}
}
}

Expand Down Expand Up @@ -272,7 +285,7 @@ function farm_update_7001(&$sandbox) {

// Enable new module dependencies.
$modules = array(
'openlayers_geofield',
// 'openlayers_geofield', // Removed.
'views_geojson',
);
_farm_update_enable_modules($modules);
Expand Down Expand Up @@ -308,12 +321,7 @@ function farm_update_7004(&$sandbox) {
* Load Openlayers via CDN.
*/
function farm_update_7005(&$sandbox) {

// Enable the Libraries CDN module.
_farm_update_enable_modules(array('libraries_cdn'));

// Load Openlayers 3.8.2 from JSDelivr CDN.
\Drupal\openlayers\Config::set('openlayers.variant', 'jsdelivr:ol3:3.8.2');
// Removed.
}

/**
Expand Down Expand Up @@ -455,14 +463,14 @@ function farm_update_7010(&$sandbox) {
* Load Openlayers 3.10.1 from CDNJS.
*/
function farm_update_7011(&$sandbox) {
\Drupal\openlayers\Config::set('openlayers.variant', 'cdnjs:ol3:3.10.1');
// Removed.
}

/**
* Load Openlayers 3.11.2 from CDNJS.
*/
function farm_update_7012(&$sandbox) {
\Drupal\openlayers\Config::set('openlayers.variant', 'cdnjs:ol3:3.11.2');
// Removed.
}

/**
Expand Down Expand Up @@ -642,7 +650,7 @@ function farm_update_7027(&$sandbox) {
* Update Openlayers JS library to 4.3.3.
*/
function farm_update_7028(&$sandbox) {
\Drupal\openlayers\Config::set('openlayers.variant', 'cdnjs:ol3:4.3.3');
// Removed.
}

/**
Expand Down Expand Up @@ -730,7 +738,7 @@ function farm_update_7037(&$sandbox) {
* Update Openlayers JS library to 4.6.4.
*/
function farm_update_7038(&$sandbox) {
\Drupal\openlayers\Config::set('openlayers.variant', 'cdnjs:ol3:4.6.4');
// Removed.
}

/**
Expand Down Expand Up @@ -781,7 +789,7 @@ function farm_update_7044(&$sandbox) {
function farm_update_7045(&$sandbox) {

// Set the variant config in the Openlayers module.
\Drupal\openlayers\Config::set('openlayers.variant', 'local:4.6.4');
// Removed.

// Uninstall Libraries CDN.
db_query("DELETE FROM {system} WHERE name = 'libraries_cdn' AND type = 'module'");
Expand Down Expand Up @@ -819,6 +827,114 @@ function farm_update_7049(&$sandbox) {
_farm_update_enable_modules(array('farm_fields_autocomplete'));
}

/**
* Install the new Farm Map Geofield module and update Geofield instance settings.
*/
function farm_update_7050(&$sandbox) {

// Enable farm_map_geofield.
_farm_update_enable_modules(array('farm_map_geofield'));

// Update all instances of field_farm_geofield.
$instances_info = field_info_instances();
foreach ($instances_info as $entity_type => $bundles) {
foreach ($bundles as $bundle => $instances) {
foreach ($instances as $field_name => $instance) {

// If the field name is not field_farm_geofield, skip.
if ($field_name != 'field_farm_geofield') {
continue;
}

// Update widget settings.
if (!empty($instance['widget'])) {
$instance['widget']['module'] = 'farm_map_geofield';
$remove_settings = array('allow_edit', 'data_storage', 'feature_types', 'openlayers_map', 'showInputField');
foreach ($remove_settings as $name) {
unset($instance['widget']['settings'][$name]);
}
$instance['widget']['type'] = 'farm_map_geofield';
}

// Update display settings.
if (!empty($instance['display']['default'])) {
$instance['display']['default']['module'] = 'farm_map_geofield';
$instance['display']['default']['settings'] = array();
$instance['display']['default']['type'] = 'farm_map_geofield';
}

// Update the instance.
field_update_instance($instance);
}
}
}
}

/**
* Uninstall Openlayers modules and dependencies.
*/
function farm_update_7051(&$sandbox) {
global $conf;
foreach (array_keys($conf) as $key) {
if (strpos($key, 'openlayers_') === 0) {
variable_del($key);
}
}
$modules = array(
'openlayers',
'openlayers_block',
'openlayers_block_switcher',
'openlayers_boxes',
'openlayers_cesium',
'openlayers_content_types',
'openlayers_contextual_links',
'openlayers_examples',
'openlayers_field',
'openlayers_geofield',
'openlayers_geolocate_button',
'openlayers_library',
'openlayers_quicktabs',
'openlayers_services',
'openlayers_ui',
'openlayers_views',
'registry_autoload',
'registry_autoload_test',
'service_container',
'service_container_annotation_discovery',
'service_container_annotation_discovery_subtest',
'service_container_annotation_discovery_test',
'service_container_block',
'service_container_symfony',
'service_container_symfony_subtest',
'service_container_symfony_test',
'service_container_test',
'service_container_test_ctools',
);
foreach ($modules as $module) {
db_query("DELETE FROM {system} WHERE name = '$module' AND type = 'module'");
}
$tables = array(
'openlayers_components',
'openlayers_controls',
'openlayers_interactions',
'openlayers_layers',
'openlayers_maps',
'openlayers_projections',
'openlayers_sources',
'openlayers_styles',
);
foreach ($tables as $table) {
db_query("DROP TABLE {$table}");
}
}

/**
* Enable farm_api_oauth module.
*/
function farm_update_7052(&$sandbox) {
_farm_update_enable_modules(array('farm_api_oauth'));
}

/**
* Update helper function: enable modules.
*/
Expand Down