PluginProbe
E2Pdf – Export Pdf Tool for WordPress / 1.32.31
E2Pdf – Export Pdf Tool for WordPress v1.32.31
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.31, at classes/controller/e2pdf-integrations.php

136 lines 6.3 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 $this->view('options', Model_E2pdf_Options::get_options(false, ['zapier_group']));
19 $this->view('groups', $this->get_groups());
20 }
21
22 // url: admin.php?page=e2pdf-integrations&action=adobesign
23 public function adobesign_action() {
24 if ($this->post->get('_wpnonce')) {
25 if (wp_verify_nonce($this->post->get('_wpnonce'), 'e2pdf_integrations')) {
26 if (
27 get_option('e2pdf_adobesign_client_id', '') !== $this->post->get('e2pdf_adobesign_client_id') ||
28 get_option('e2pdf_adobesign_client_secret', '') !== $this->post->get('e2pdf_adobesign_client_secret') ||
29 get_option('e2pdf_adobesign_region', '') !== $this->post->get('e2pdf_adobesign_region') ||
30 !get_option('e2pdf_adobesign_refresh_token')
31 ) {
32 update_option('e2pdf_adobesign_code', false);
33 update_option('e2pdf_adobesign_api_access_point', false);
34 update_option('e2pdf_adobesign_web_access_point', false);
35 update_option('e2pdf_adobesign_refresh_token', false);
36 set_transient('e2pdf_adobesign_access_token', false);
37 Model_E2pdf_Options::update_options('adobesign_group', $this->post->get());
38 if (!get_option('e2pdf_adobesign_client_id', '') || !get_option('e2pdf_adobesign_client_secret', '') || !get_option('e2pdf_adobesign_region', '')) {
39 $this->redirect(
40 $this->helper->get_url(
41 [
42 'page' => 'e2pdf-integrations',
43 'action' => 'adobesign',
44 'notification' => $this->add_notification('update', __('Not Authorized', 'e2pdf')),
45 ]
46 )
47 );
48 } else {
49 $request = (new Model_E2pdf_AdobeSign())->get_code();
50 if (isset($request['redirect'])) {
51 $this->redirect($request['redirect']);
52 }
53 }
54 }
55 } else {
56 wp_die($this->message('wp_verify_nonce_error'));
57 }
58 } elseif ($this->get->get('code') && $this->get->get('_wpnonce') && get_option('e2pdf_adobesign_client_id', '') && get_option('e2pdf_adobesign_client_secret', '')) {
59 if (wp_verify_nonce($this->get->get('_wpnonce'), 'e2pdf_adobe')) {
60 update_option('e2pdf_adobesign_code', sanitize_text_field(wp_unslash($this->get->get('code'))));
61 $request = (new Model_E2pdf_AdobeSign())->get_token();
62 $this->redirect(
63 $this->helper->get_url(
64 [
65 'page' => 'e2pdf-integrations',
66 'action' => 'adobesign',
67 'notification' => isset($request['error']) ? $this->add_notification('error', $request['error']) : $this->add_notification('update', __('App Authorized', 'e2pdf')),
68 ]
69 )
70 );
71 } else {
72 wp_die($this->message('wp_verify_nonce_error'));
73 }
74 } else {
75 new Model_E2pdf_AdobeSign();
76 }
77
78 $this->view('options', Model_E2pdf_Options::get_options(false, ['adobesign_group']));
79 $this->view('groups', $this->get_groups());
80 }
81
82 // url: admin.php?page=e2pdf-integrations&action=gdrive
83 public function gdrive_action() {
84 if ($this->post->get('_wpnonce')) {
85 if (wp_verify_nonce($this->post->get('_wpnonce'), 'e2pdf_integrations')) {
86 if (
87 get_option('e2pdf_gdrive_client_id', '') !== $this->post->get('e2pdf_gdrive_client_id') ||
88 get_option('e2pdf_gdrive_client_secret', '') !== $this->post->get('e2pdf_gdrive_client_secret') ||
89 !get_option('e2pdf_gdrive_refresh_token')
90 ) {
91 update_option('e2pdf_gdrive_refresh_token', '');
92 delete_transient('e2pdf_gdrive_access_token');
93 Model_E2pdf_Options::update_options('gdrive_group', $this->post->get());
94 if (!get_option('e2pdf_gdrive_client_id', '') || !get_option('e2pdf_gdrive_client_secret', '')) {
95 $this->redirect(
96 $this->helper->get_url(
97 [
98 'page' => 'e2pdf-integrations',
99 'action' => 'gdrive',
100 'notification' => $this->add_notification('update', __('Not Authorized', 'e2pdf')),
101 ]
102 )
103 );
104 } else {
105 $request = (new Model_E2pdf_Gdrive())->get_code();
106 if (isset($request['redirect'])) {
107 $this->redirect($request['redirect']);
108 }
109 }
110 }
111 } else {
112 wp_die($this->message('wp_verify_nonce_error'));
113 }
114 } else {
115 new Model_E2pdf_Gdrive();
116 }
117 $this->view('options', Model_E2pdf_Options::get_options(false, ['gdrive_group']));
118 $this->view('groups', $this->get_groups());
119 }
120
121 // get integration option groups
122 public function get_groups() {
123 $groups = Model_E2pdf_Options::get_options(
124 false,
125 [
126 'zapier_group',
127 'adobesign_group',
128 'gdrive_group',
129 ],
130 false
131 );
132
133 return $groups;
134 }
135 }
136