PluginProbe
Depicter — Popup & Slider Builder / trunk
Depicter — Popup & Slider Builder vtrunk
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / app / src / Services / AuthenticationService.php

AuthenticationService.php in Depicter — Popup & Slider Builder trunk, at app/src/Services/AuthenticationService.php

112 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Depicter\Services;
4
5 class AuthenticationService {
6
7 /**
8 * Retrieves client's tier
9 *
10 * @return string
11 */
12 public function getTier(){
13 $baseTier = 'free-user';
14 $baseVer = '2.0.9';
15 $initialVersion = \Depicter::options()->get('version_initial', $baseVer);
16
17 if (version_compare($initialVersion, $baseVer, '<=')) {
18 $baseTier .= '+';
19 } elseif (version_compare($initialVersion, '4.0.5', '<=')) {
20 $baseTier .= '-';
21 }
22
23 return \Depicter::options()->get('user_tier', $baseTier ) ?: $baseTier;
24 }
25
26 /**
27 * Whether client has not free tier or not
28 *
29 * @return bool
30 */
31 public function isPaid(){
32 return false === strpos( $this->getTier(), 'free-user' );
33 }
34
35 /**
36 * Whether client has not free tier or not
37 *
38 * @return bool
39 */
40 public function isFreeTier($class = ''){
41 return $this->getTier() === 'free-user' . $class;
42 }
43
44 /**
45 * Verify if it is an activated installation or not
46 *
47 * @return bool
48 */
49 public function verifyActivation(){
50 return \Depicter::client()->validateActivation();
51 }
52
53 /**
54 * Whether it is an activated installation or not
55 *
56 * @return bool
57 */
58 public function isActivated(){
59 return $this->getActivationStatus() === 'activated';
60 }
61
62 /**
63 * Retrieves subscription activation status
64 *
65 * @return string
66 */
67 public function getActivationStatus(){
68 $activationStatus = \Depicter::options()->get('subscription_status', 'not-activated');
69 $activationError = \Depicter::options()->get('activation_error_message', '');
70 return ( 'activated' !== $activationStatus ) && ! empty( $activationError ) ? 'error': $activationStatus;
71 }
72
73 /**
74 * Retrieves subscription status
75 *
76 * @return string
77 */
78 public function getSubscriptionStatus(){
79
80 if( $subExpiresAt = \Depicter::options()->get('subscription_expires_at' , '') ){
81 $subExpiresAtTimestamp = strtotime($subExpiresAt." UTC");
82 $afterExpirationInSeconds = time() - $subExpiresAtTimestamp;
83
84 if( $afterExpirationInSeconds > 5 * DAY_IN_SECONDS ) {
85 return 'expired';
86 } elseif( $afterExpirationInSeconds > 0 ){
87 return 'expired-early';
88 }
89 }
90
91 return \Depicter::options()->get('subscription_status', '');
92 }
93
94 /**
95 * If current subscription is expired
96 *
97 * @return bool
98 */
99 public function isSubscriptionExpired(){
100 return $this->getSubscriptionStatus() === 'expired';
101 }
102
103 /**
104 * Get client key
105 *
106 * @return string
107 */
108 public function getClientKey(){
109 return \Depicter::options()->get( 'client_key', '' );
110 }
111 }
112