From 2cad5733900276c0fffe04416a83c0fbdecef213 Mon Sep 17 00:00:00 2001 From: Victoria Mihell-Hale Date: Wed, 24 Jan 2024 20:25:20 +0000 Subject: [PATCH] Revert "[Confirm] Add proxy for fetching jobs from GraphQL API" This reverts commit 396f06c73ad8c05c1721da1cf37354b8021f70bb. Functionality now handled in open311-adapter. --- conf/config-example | 3 --- web/confirm.php | 44 -------------------------------------------- web/fns.php | 24 ++---------------------- 3 files changed, 2 insertions(+), 69 deletions(-) delete mode 100644 web/confirm.php diff --git a/conf/config-example b/conf/config-example index 9e0325c..7778be8 100644 --- a/conf/config-example +++ b/conf/config-example @@ -36,6 +36,3 @@ define('SM_API_URL', ''); define('SM_USERNAME', ''); define('SM_PASSWORD', ''); define('SM_MEMCACHE_PREFIX', ''); - -define('CONFIRM_API_CONFIG', []); -define('CONFIRM_LAYER_CONFIG', []); diff --git a/web/confirm.php b/web/confirm.php deleted file mode 100644 index bed1e3a..0000000 --- a/web/confirm.php +++ /dev/null @@ -1,44 +0,0 @@ - str_replace("__BBOX__", $poly, $layer_cfg['query']) ]; -$result = make_request($cfg['url'], $cfg['key'], $params, "Basic")->data->jobs; - -foreach ($result as $feature) { - if (!$layer_cfg['filter'] || $layer_cfg['filter']($feature)) { - $features[] = data_as_geojson($feature, $layer_cfg); - } -} - - - -print json_encode($geojson); - -# --- - -function data_as_geojson($feature, $layer_cfg) { - list($pre, $lon, $lat) = explode(" ", $feature->geometry); - $lon = substr($lon, 1); - $lat = substr($lat, 0, -1); - return [ - "type" => "Feature", - "geometry" => [ - "type" => "Point", - "coordinates" => [floatval($lon), floatval($lat)], - ], - "properties" => $layer_cfg['formatter']($feature), - ]; -} diff --git a/web/fns.php b/web/fns.php index 7bc907c..3f51c1e 100644 --- a/web/fns.php +++ b/web/fns.php @@ -27,26 +27,6 @@ function get_alloy_token() { return $token; } -function get_confirm_cfg() { - $url = get('url', 'https://[a-z.]+'); - $cfg = CONFIRM_API_CONFIG[$url]; - if (!$cfg) { - print EMPTY_RESULT; - exit; - } - return $cfg; -} - -function get_confirm_layer_cfg($layer) { - $url = get('url', 'https://[a-z.]+'); - $cfg = CONFIRM_LAYER_CONFIG[$url][$layer]; - if (!$cfg) { - print EMPTY_RESULT; - exit; - } - return $cfg; -} - function get($id, $regex, $default = null) { $var = isset($_GET[$id]) ? $_GET[$id] : ''; if ($var && preg_match('#^' . $regex . '$#', $var)) { @@ -55,14 +35,14 @@ function get($id, $regex, $default = null) { return $default; } -function make_request($url, $token, $params, $auth_type = "Bearer") { +function make_request($url, $token, $params) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', - "Authorization: $auth_type $token", + "Authorization: Bearer $token", ]); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));