PluginProbe
SMS Alert – SMS & OTP for WooCommerce, Order Notifications & Abandoned Cart Recovery / trunk
SMS Alert – SMS & OTP for WooCommerce, Order Notifications & Abandoned Cart Recovery vtrunk
4.0.0 3.9.9 3.9.8 3.9.7 3.9.6 trunk 3.0.0 3.5.0 3.6.0 3.7.0 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.8.8 3.8.9 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 All 26 releases
sms-alert / handler / forms / FormInterface.php

FormInterface.php in SMS Alert – SMS & OTP for WooCommerce, Order Notifications & Abandoned Cart Recovery trunk, at handler/forms/FormInterface.php

130 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * This file handles wpmember form authentication via sms notification
4 *
5 * PHP version 5
6 *
7 * @category Handler
8 * @package SMSAlert
9 * @author SMS Alert <support@cozyvision.com>
10 * @license URI: http://www.gnu.org/licenses/gpl-2.0.html
11 * @link https://www.smsalert.co.in/
12 */
13
14 if (! defined('ABSPATH') ) {
15 exit;
16 }
17
18 /**
19 * PHP version 5
20 *
21 * @category Handler
22 * @package SMSAlert
23 * @author SMS Alert <support@cozyvision.com>
24 * @license URI: http://www.gnu.org/licenses/gpl-2.0.html
25 * @link https://www.smsalert.co.in/
26 * FormInterface class.
27 */
28 abstract class FormInterface
29 {
30
31 /**
32 * Tx_session_id.
33 *
34 * @var stirng
35 */
36 protected $tx_session_id = 'mo_customer_validation_site_txID';
37
38 /**
39 * Construct function for form interface.
40 *
41 * @return void
42 */
43 function __construct()
44 {
45 // Action to call the handleFormOptions of each form class.
46 // This is used to save any form related options by the admin.
47 add_action('admin_init', array( $this, 'handleFormOptions' ), 1);
48
49 // Make sure otp verification is enabled for the form.
50 if (! $this->isFormEnabled() ) {
51 return;
52 }
53
54 // Action called on init to call the handleForm of each form class.
55 // This is used to start the OTP Verification process for each form.
56 add_action('init', array( $this, 'handleForm' ), 1);
57
58 // Action calls handle_post_verification function to handle post successful OTP Validation.
59 add_action('otp_verification_successful', array( $this, 'handle_post_verification' ), 10, 6);
60
61 // Action calls handle_failed_verification function to handle failed successful OTP Validation.
62 add_action('otp_verification_failed', array( $this, 'handle_failed_verification' ), 10, 3);
63
64 // Filter to call the is_ajax_form_in_play function of each form class to check if otp verification.
65 // has been started for a form and if that form is of the type ajax. Should return TRUE or FALSE.
66 add_filter('is_ajax_form', array( $this, 'is_ajax_form_in_play' ), 1, 1);
67
68 // action to unset session variable for the form.
69 add_action('unset_session_variable', array( $this, 'unsetOTPSessionVariables' ), 1, 0);
70 }
71
72 // Abstract function to be defined by the form class extending this class.
73
74 /**
75 * Clear otp session variable
76 *
77 * @return void
78 */
79 abstract public function unsetOTPSessionVariables();
80
81 /**
82 * Handle after post verification
83 *
84 * @param string $redirect_to redirect url.
85 * @param object $user_login user object.
86 * @param string $user_email user email.
87 * @param string $password user password.
88 * @param string $phone_number phone number.
89 * @param string $extra_data extra hidden fields.
90 *
91 * @return void
92 */
93 abstract public function handle_post_verification( $redirect_to, $user_login, $user_email, $password, $phone_number, $extra_data);
94
95
96 /**
97 * Handle after failed verification
98 *
99 * @param object $user_login users object.
100 * @param string $user_email user email.
101 * @param string $phone_number phone number.
102 *
103 * @return void
104 */
105 abstract public function handle_failed_verification( $user_login, $user_email, $phone_number);
106
107 /**
108 * Handle OTP form
109 *
110 * @return void
111 */
112 abstract public function handleForm();
113
114 /**
115 * Handle form for WordPress backend
116 *
117 * @return void
118 */
119 abstract public function handleFormOptions();
120
121 /**
122 * Check current form submission is ajax or not
123 *
124 * @param bool $is_ajax bool value for form type.
125 *
126 * @return bool
127 */
128 abstract public function is_ajax_form_in_play( $is_ajax);
129 }
130