PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.12
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.12
6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 All 196 releases
fluentform / app / Http / Controllers / GlobalIntegrationController.php

GlobalIntegrationController.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 6.2.12, at app/Http/Controllers/GlobalIntegrationController.php

88 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\App\Http\Controllers;
4
5 use FluentForm\App\Services\Integrations\GlobalIntegrationService;
6 use FluentForm\Framework\Helpers\ArrayHelper as Arr;
7 use Exception;
8
9 class GlobalIntegrationController extends Controller
10 {
11
12 public function index(GlobalIntegrationService $globalIntegrationService)
13 {
14 try {
15 $attributes = $this->request->all();
16 $returnData = $globalIntegrationService->get($attributes);
17 if (Arr::isTrue($returnData, 'status')) {
18 return $this->sendSuccess($returnData);
19 }
20 // No settings_key provided is a list-style call, not an error; return 200 with empty payload.
21 if (!Arr::get($attributes, 'settings_key')) {
22 return $this->sendSuccess([
23 'status' => false,
24 'integration' => [],
25 'settings' => [],
26 ]);
27 }
28 return $this->sendError($returnData);
29 } catch (Exception $e) {
30 return $this->sendError([
31 'message' => $e->getMessage(),
32 ], 422);
33 }
34 }
35
36 public function updateIntegration()
37 {
38 try {
39 $settingsKey = sanitize_text_field($this->request->get('settings_key'));
40 $integration = wp_unslash($this->request->get('integration'));
41
42 // SECURITY (FINDING-16): connected credentials are redacted on read; restore any field
43 // the browser posted back still masked so a re-save (e.g. "Verify Connection Again")
44 // cannot overwrite a live credential with the '********' mask.
45 $integration = (new GlobalIntegrationService())->unmaskCredentials($settingsKey, $integration);
46
47 do_action_deprecated(
48 'fluentform_save_global_integration_settings_' . $settingsKey,
49 [
50 $integration
51 ],
52 FLUENTFORM_FRAMEWORK_UPGRADE,
53 'fluentform/save_global_integration_settings_' . $settingsKey,
54 'Use fluentform/save_global_integration_settings_' . $settingsKey . ' instead of fluentform_save_global_integration_settings_' . $settingsKey
55 );
56
57 do_action('fluentform/save_global_integration_settings_' . $settingsKey, $integration);
58
59 // Someone should catch that above action and send response
60 return $this->sendError([
61 'message' => __('Sorry, no Integration found. Please make sure that latest version of Fluent Forms pro installed',
62 'fluentform'),
63 ]);
64 } catch (Exception $e) {
65 return $this->sendError([
66 'message' => $e->getMessage(),
67 ], 422);
68 }
69 }
70
71 public function updateModuleStatus(GlobalIntegrationService $globalIntegrationService)
72 {
73 try {
74 $globalIntegrationService->updateModuleStatus($this->request->get());
75 return $this->sendSuccess([
76 'message' => __('Status successfully updated', 'fluentform'),
77 ], 200);
78 } catch (Exception $e) {
79 return $this->sendError([
80 'message' => $e->getMessage(),
81 ], 422);
82 }
83 }
84
85
86
87 }
88