PluginProbe
E2Pdf – Export Pdf Tool for WordPress / 1.32.18
E2Pdf – Export Pdf Tool for WordPress v1.32.18
1.32.48 1.32.43 1.32.40 1.32.34 1.32.32 1.32.31 1.32.26 1.32.22 1.32.23 1.32.18 1.32.17 1.32.15 trunk 1.00.00 1.00.13 1.01.01 1.02.02 1.03.07 1.04.07 1.05.03 1.06.02 1.07.11 1.08.00 1.08.06 1.08.09 All 71 releases
e2pdf / classes / controller / e2pdf-integrations.php

e2pdf-integrations.php in E2Pdf – Export Pdf Tool for WordPress 1.32.18, at classes/controller/e2pdf-integrations.php

148 lines 6.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * File: /controller/e2pdf-integrations.php
5 *
6 * @package E2Pdf
7 * @license GPLv3
8 * @link https://e2pdf.com
9 */
10 if (!defined('ABSPATH')) {
11 die('Access denied.');
12 }
13
14 class Controller_E2pdf_Integrations extends Helper_E2pdf_View {
15
16 // url: admin.php?page=e2pdf-integrations
17 public function index_action() {
18 if ($this->post->get('_wpnonce')) {
19 if (wp_verify_nonce($this->post->get('_wpnonce'), 'e2pdf_integrations')) {
20 /* translators: %s: Action */
21 $this->add_notification('update', sprintf(__('Success: %s', 'e2pdf'), __('Settings Saved', 'e2pdf')));
22 } else {
23 wp_die($this->message('wp_verify_nonce_error'));
24 }
25 }
26 $this->view('options', Model_E2pdf_Options::get_options(false, ['zapier_group']));
27 $this->view('groups', $this->get_groups());
28 }
29
30 // url: admin.php?page=e2pdf-integrations&action=adobesign
31 public function adobesign_action() {
32 if ($this->post->get('_wpnonce')) {
33 if (wp_verify_nonce($this->post->get('_wpnonce'), 'e2pdf_integrations')) {
34 if (
35 get_option('e2pdf_adobesign_client_id', '') !== $this->post->get('e2pdf_adobesign_client_id') ||
36 get_option('e2pdf_adobesign_client_secret', '') !== $this->post->get('e2pdf_adobesign_client_secret') ||
37 get_option('e2pdf_adobesign_region', '') !== $this->post->get('e2pdf_adobesign_region') ||
38 !get_option('e2pdf_adobesign_refresh_token')
39 ) {
40 update_option('e2pdf_adobesign_code', false);
41 update_option('e2pdf_adobesign_api_access_point', false);
42 update_option('e2pdf_adobesign_web_access_point', false);
43 update_option('e2pdf_adobesign_refresh_token', false);
44 set_transient('e2pdf_adobesign_access_token', false);
45 Model_E2pdf_Options::update_options('adobesign_group', $this->post->get());
46 if (!get_option('e2pdf_adobesign_client_id', '') || !get_option('e2pdf_adobesign_client_secret', '') || !get_option('e2pdf_adobesign_region', '')) {
47 $this->add_notification('update', __('Not Authorized', 'e2pdf'));
48 $this->redirect(
49 $this->helper->get_url(
50 [
51 'page' => 'e2pdf-integrations',
52 'action' => 'adobesign',
53 ]
54 )
55 );
56 } else {
57 $request = (new Model_E2pdf_AdobeSign())->get_code();
58 if (isset($request['redirect'])) {
59 $this->redirect($request['redirect']);
60 }
61 }
62 }
63 } else {
64 wp_die($this->message('wp_verify_nonce_error'));
65 }
66 } elseif ($this->get->get('code') && $this->get->get('_wpnonce') && get_option('e2pdf_adobesign_client_id', '') && get_option('e2pdf_adobesign_client_secret', '')) {
67 if (wp_verify_nonce($this->get->get('_wpnonce'), 'e2pdf_adobe')) {
68 update_option('e2pdf_adobesign_code', sanitize_text_field(wp_unslash($this->get->get('code'))));
69 $request = (new Model_E2pdf_AdobeSign())->get_token();
70 if (isset($request['error'])) {
71 $this->add_notification('error', $request['error']);
72 } else {
73 $this->add_notification('update', __('App Authorized', 'e2pdf'));
74 }
75 $this->redirect(
76 $this->helper->get_url(
77 [
78 'page' => 'e2pdf-integrations',
79 'action' => 'adobesign',
80 ]
81 )
82 );
83 } else {
84 wp_die($this->message('wp_verify_nonce_error'));
85 }
86 } else {
87 new Model_E2pdf_AdobeSign();
88 }
89
90 $this->view('options', Model_E2pdf_Options::get_options(false, ['adobesign_group']));
91 $this->view('groups', $this->get_groups());
92 }
93
94 // url: admin.php?page=e2pdf-integrations&action=gdrive
95 public function gdrive_action() {
96 if ($this->post->get('_wpnonce')) {
97 if (wp_verify_nonce($this->post->get('_wpnonce'), 'e2pdf_integrations')) {
98 if (
99 get_option('e2pdf_gdrive_client_id', '') !== $this->post->get('e2pdf_gdrive_client_id') ||
100 get_option('e2pdf_gdrive_client_secret', '') !== $this->post->get('e2pdf_gdrive_client_secret') ||
101 !get_option('e2pdf_gdrive_refresh_token')
102 ) {
103 update_option('e2pdf_gdrive_refresh_token', '');
104 delete_transient('e2pdf_gdrive_access_token');
105 Model_E2pdf_Options::update_options('gdrive_group', $this->post->get());
106 if (!get_option('e2pdf_gdrive_client_id', '') || !get_option('e2pdf_gdrive_client_secret', '')) {
107 $this->add_notification('update', __('Not Authorized', 'e2pdf'));
108 $this->redirect(
109 $this->helper->get_url(
110 [
111 'page' => 'e2pdf-integrations',
112 'action' => 'gdrive',
113 ]
114 )
115 );
116 } else {
117 $request = (new Model_E2pdf_Gdrive())->get_code();
118 if (isset($request['redirect'])) {
119 $this->redirect($request['redirect']);
120 }
121 }
122 }
123 } else {
124 wp_die($this->message('wp_verify_nonce_error'));
125 }
126 } else {
127 new Model_E2pdf_Gdrive();
128 }
129 $this->view('options', Model_E2pdf_Options::get_options(false, ['gdrive_group']));
130 $this->view('groups', $this->get_groups());
131 }
132
133 // get integration option groups
134 public function get_groups() {
135 $groups = Model_E2pdf_Options::get_options(
136 false,
137 [
138 'zapier_group',
139 'adobesign_group',
140 'gdrive_group',
141 ],
142 false
143 );
144
145 return $groups;
146 }
147 }
148