PluginProbe
HubSpot All-In-One Marketing – Forms, Popups, Live Chat / 11.0.58
HubSpot All-In-One Marketing – Forms, Popups, Live Chat v11.0.58
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.0.58, at public/data/class-portal-options.php

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