PluginProbe
HubSpot All-In-One Marketing – Forms, Popups, Live Chat / 11.1.15
HubSpot All-In-One Marketing – Forms, Popups, Live Chat v11.1.15
11.3.75 11.3.73 11.3.71 11.3.70 11.3.69 11.3.64 11.3.65 11.3.62 11.3.61 11.3.56 11.3.58 11.0.31 11.0.52 11.0.54 11.0.56 11.0.58 11.0.7 11.1.10 11.1.11 11.1.13 11.1.14 11.1.15 11.1.2 11.1.20 11.1.21 All 73 releases
leadin / public / data / class-portal-options.php

class-portal-options.php in HubSpot All-In-One Marketing – Forms, Popups, Live Chat 11.1.15, at public/data/class-portal-options.php

277 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 namespace Leadin\data;
4
5 /**
6 * Class that wraps the functions to access options related to the HubSpot account.
7 */
8 class Portal_Options {
9 const PORTAL_ID = LEADIN_PREFIX . '_portalId';
10 const PORTAL_DOMAIN = LEADIN_PREFIX . '_portal_domain';
11 const ACCOUNT_NAME = LEADIN_PREFIX . '_account_name';
12 const HUBLET = LEADIN_PREFIX . '_hublet';
13 const DISABLE_INTERNAL_TRACKING = LEADIN_PREFIX . '_disable_internal_tracking';
14 const ACTIVATION_TIME = LEADIN_PREFIX . '_activation_time';
15 const REFRESH_TOKEN = LEADIN_PREFIX . '_refresh_token';
16 const BUSINESS_UNIT_ID = LEADIN_PREFIX . '_business_unit_id';
17 const LAST_AUTHORIZE_TIME = LEADIN_PREFIX . '_last_authorize_time';
18 const LAST_DEAUTHORIZE_TIME = LEADIN_PREFIX . '_last_deauthorize_time';
19 const LAST_DISCONNECT_TIME = LEADIN_PREFIX . '_last_disconnect_time';
20 const REFRESH_TOKEN_ERROR = LEADIN_PREFIX . '_refresh_token_error';
21 /**
22 * Return portal id.
23 */
24 public static function get_portal_id() {
25 return get_option( self::PORTAL_ID );
26 }
27
28 /**
29 * Set portal id.
30 *
31 * @param Number $portal_id HubSpot portal id.
32 */
33 public static function set_portal_id( $portal_id ) {
34 return update_option( self::PORTAL_ID, $portal_id );
35 }
36
37 /**
38 * Delete portal id.
39 */
40 public static function delete_portal_id() {
41 return delete_option( self::PORTAL_ID );
42 }
43
44 /**
45 * Return portal's domain.
46 */
47 public static function get_portal_domain() {
48 return get_option( self::PORTAL_DOMAIN );
49 }
50
51 /**
52 * Set portal domain.
53 *
54 * @param string $domain domain.
55 */
56 public static function set_portal_domain( $domain ) {
57 return update_option( self::PORTAL_DOMAIN, $domain );
58 }
59
60 /**
61 * Delete portal domain.
62 */
63 public static function delete_portal_domain() {
64 return delete_option( self::PORTAL_DOMAIN );
65 }
66
67 /**
68 * Return account name.
69 */
70 public static function get_account_name() {
71 return get_option( self::ACCOUNT_NAME );
72 }
73
74 /**
75 * Set account name.
76 *
77 * @param string $name name.
78 */
79 public static function set_account_name( $name ) {
80 return update_option( self::ACCOUNT_NAME, $name );
81 }
82
83 /**
84 * Delete account name.
85 */
86 public static function delete_account_name() {
87 return delete_option( self::ACCOUNT_NAME );
88 }
89
90 /**
91 * Return option containing hublet info.
92 */
93 public static function get_hublet() {
94 return get_option( self::HUBLET );
95 }
96
97 /**
98 * Return option containing hublet info.
99 *
100 * @param string $hublet hublet.
101 */
102 public static function set_hublet( $hublet ) {
103 return update_option( self::HUBLET, $hublet );
104 }
105
106 /**
107 * Delete hublet
108 */
109 public static function delete_hublet() {
110 return delete_option( self::HUBLET );
111 }
112
113 /**
114 * Return option flag for disabling internal users to appear at HS analytics.
115 */
116 public static function get_disable_internal_tracking() {
117 return get_option( self::DISABLE_INTERNAL_TRACKING );
118 }
119
120 /**
121 * Set option containing flag for disabling internal users to appear at HS analytics.
122 *
123 * @param string $internal_tracking hublet.
124 */
125 public static function set_disable_internal_tracking( $internal_tracking = '0' ) {
126 return update_option( self::DISABLE_INTERNAL_TRACKING, $internal_tracking );
127 }
128
129 /**
130 * Delete option flag for disabling internal tracking
131 */
132 public static function delete_disable_internal_tracking() {
133 return delete_option( self::DISABLE_INTERNAL_TRACKING );
134 }
135
136 /**
137 * Return activation time.
138 */
139 public static function get_activation_time() {
140 return get_option( self::ACTIVATION_TIME );
141 }
142
143 /**
144 * Set activation time.
145 */
146 public static function set_activation_time() {
147 return update_option( self::ACTIVATION_TIME, time() );
148 }
149
150 /**
151 * Delete portal id.
152 */
153 public static function delete_activation_time() {
154 return delete_option( self::ACTIVATION_TIME );
155 }
156
157 /**
158 * Return refresh access token.
159 */
160 public static function get_refresh_token() {
161 return get_option( self::REFRESH_TOKEN );
162 }
163
164 /**
165 * Set refresh access token.
166 *
167 * @param string $refresh_token token.
168 */
169 public static function set_refresh_token( $refresh_token ) {
170 return update_option( self::REFRESH_TOKEN, $refresh_token );
171 }
172
173 /**
174 * Delete refresh access token.
175 */
176 public static function delete_refresh_token() {
177 return delete_option( self::REFRESH_TOKEN );
178 }
179
180 /**
181 * Return device id hash.
182 */
183 public static function get_device_id() {
184 $site_url = get_home_url();
185 $user_id = get_current_user_id();
186 return hash( 'sha256', "$site_url:$user_id" );
187 }
188
189 /**
190 * Return business_unit_id for connected portal.
191 */
192 public static function get_business_unit_id() {
193 return get_option( self::BUSINESS_UNIT_ID );
194 }
195
196 /**
197 * Set business_unit_id for the connected portal.
198 *
199 * @param number $business_unit_id businessUnitId.
200 */
201 public static function set_business_unit_id( $business_unit_id ) {
202 return update_option( self::BUSINESS_UNIT_ID, $business_unit_id );
203 }
204
205 /**
206 * Delete business_unit_id.
207 */
208 public static function delete_business_unit_id() {
209 return delete_option( self::BUSINESS_UNIT_ID );
210 }
211
212 /**
213 * Set when last authorized.
214 */
215 public static function set_last_authorize_time() {
216 return update_option( self::LAST_AUTHORIZE_TIME, time() );
217 }
218 /**
219 * Set when last deauthorized.
220 */
221 public static function set_last_deauthorize_time() {
222 return update_option( self::LAST_DEAUTHORIZE_TIME, time() );
223 }
224
225 /**
226 * Set when last disconnect.
227 */
228 public static function set_last_disconnect_time() {
229 return update_option( self::LAST_DISCONNECT_TIME, time() );
230 }
231
232 /**
233 * Set if the refresh token failed to be retrieved.
234 *
235 * @param string $error the error message.
236 */
237 public static function set_refresh_token_error( $error = 'unknown' ) {
238 return update_option( self::REFRESH_TOKEN_ERROR, $error );
239 }
240
241 /**
242 * Get the last time authorization was performed.
243 *
244 * @return mixed The last authorization time, or false if not set.
245 */
246 public static function get_last_authorize_time() {
247 return get_option( self::LAST_AUTHORIZE_TIME, false );
248 }
249
250 /**
251 * Get the last time deauthorization was performed.
252 *
253 * @return mixed The last deauthorization time, or false if not set.
254 */
255 public static function get_last_deauthorize_time() {
256 return get_option( self::LAST_DEAUTHORIZE_TIME, false );
257 }
258
259 /**
260 * Get the last time a disconnect was performed.
261 *
262 * @return mixed The last disconnect time, or false if not set.
263 */
264 public static function get_last_disconnect_time() {
265 return get_option( self::LAST_DISCONNECT_TIME, false );
266 }
267
268 /**
269 * Get the last error message for when retrieving the refresh token failed.
270 *
271 * @return string The error message, or 'unknown' if not set.
272 */
273 public static function get_refresh_token_error() {
274 return get_option( self::REFRESH_TOKEN_ERROR, 'unknown' );
275 }
276 }
277