PluginProbe
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification / 2.12
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification v2.12
5.6.0 5.5.0 5.4.0 5.3.2 5.3.1 5.1.6 5.1.5 trunk 2.1.5 2.11 2.12 2.13 2.15 3.0.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.51 3.0.60 3.0.61 3.0.62 3.0.70 3.0.71 3.0.72 All 35 releases
double-opt-in / ui / UIDatabase.class.php

UIDatabase.class.php in Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification 2.12, at ui/UIDatabase.class.php

129 lines 4.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace forge12\contactform7\CF7DoubleOptIn {
4 if (!defined('ABSPATH')) {
5 exit;
6 }
7
8 /**
9 * Class UIDatabase
10 * @package forge12\contactform7\CF7DoubleOptIn
11 */
12 class UIDatabase extends UIPageForm
13 {
14 public function __construct($domain)
15 {
16 parent::__construct($domain, 'database', 'Database', 50);
17 $this->hideSubmitButton(true);
18 }
19
20 /**
21 * Save on form submit
22 */
23 private function maybeCleanDatabase()
24 {
25 // Check if the form is posted and the nonce is valid
26 if ((isset($_POST['doi-clean-submit']) || isset($_POST['doi-clean-confirmed-submit']) || isset($_POST['doi-clean-unconfirmed-submit']))) {
27 $CleanUp = new CleanUp();
28 if (isset($_POST['doi-clean-submit']) || isset($_POST['doi-clean-confirmed-submit'])) {
29 $CleanUp->removeConfirmedOptins();
30 }
31 if (isset($_POST['doi-clean-submit']) || isset($_POST['doi-clean-unconfirmed-submit'])) {
32 $CleanUp->removeUnconfirmedOptins();
33 }
34
35 Messages::getInstance()->add(__('Database cleaned.', 'double-opt-in'), 'success');
36 }
37 }
38
39 /**
40 * Reset the database deleting all entries.
41 */
42 private function maybeResetDatabase()
43 {
44 // Check if the form is posted and the nonce is valid
45 if (isset($_POST['doi-reset-submit'])) {
46 $CleanUp = new CleanUp();
47 $CleanUp->reset();
48
49 Messages::getInstance()->add(__('Database reset finished.', 'double-opt-in'), 'success');
50 }
51 }
52
53 /**
54 * Render the license subpage content
55 */
56 protected function theContent($slug, $page, $settings)
57 {
58 ?>
59 <h2>
60 <?php _e('Database', 'double-opt-in'); ?>
61 </h2>
62 <?php
63 wp_nonce_field('doi_settings_action', 'doi_settings_nonce');
64 ?>
65
66 <div class="option">
67 <div class="label">
68 <label for="delete"><?php _e('Clean Database', 'double-opt-in'); ?></label>
69 </div>
70 <div class="input">
71 <input type="submit" name="doi-clean-submit" class="button"
72 value="<?php _e('Clean All', 'double-opt-in'); ?>"/>
73 <input type="submit" name="doi-clean-confirmed-submit" class="button"
74 value="<?php _e('Clean Confirmed', 'double-opt-in'); ?>"/>
75 <input type="submit" name="doi-clean-unconfirmed-submit" class="button"
76 value="<?php _e('Clean Unconfirmed', 'double-opt-in'); ?>"/>
77 <p>
78 <?php _e('Make sure you backup your database before clicking one of these buttons.', 'double-opt-in'); ?>
79 </p>
80 </div>
81 </div>
82 <div class="option">
83 <div class="label">
84 <label for="delete"><?php _e('Reset Database', 'double-opt-in'); ?></label>
85 </div>
86 <div class="input">
87 <input type="submit" name="doi-reset-submit" class="button button-delete"
88 value="<?php _e('Reset', 'double-opt-in'); ?>"/>
89 <p>
90 <?php _e('Make sure you backup your database before clicking one of these buttons. If you click this button, all Opt-Ins will be deleted.', 'double-opt-in'); ?>
91 </p>
92 </div>
93 </div>
94 <?php
95 }
96
97 protected function theSidebar($slug, $page)
98 {
99 if ($page != 'settings') {
100 return;
101 }
102 ?>
103 <div class="box">
104 <h2>
105 <?php _e('Hint:', 'double-opt-in'); ?>
106 </h2>
107 <p>
108 <?php _e("In the table on the left side, you'll find an list containing all Opt-Ins and the required information from your customers. Click on the hash to open aditional informations about the form and the user data. All unconfirmed opt-ins will be deleted after 7 days.", 'double-opt-in'); ?>
109 </p>
110 </div>
111 <?php
112 }
113
114 public function getSettings($settings)
115 {
116 return $settings;
117 }
118
119 protected function onSave($settings)
120 {
121 // Check if the user wants to clean the database manually
122 $this->maybeCleanDatabase();
123 // Check if the user wants to reset the database manually
124 $this->maybeResetDatabase();
125
126 return $settings;
127 }
128 }
129 }