PluginProbe
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification / 2.11
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification v2.11
5.6.2 5.6.3 5.6.1 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 All 38 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.11, at ui/UIDatabase.class.php

126 lines 4.8 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
63 <div class="option">
64 <div class="label">
65 <label for="delete"><?php _e('Clean Database', 'double-opt-in'); ?></label>
66 </div>
67 <div class="input">
68 <input type="submit" name="doi-clean-submit" class="button"
69 value="<?php _e('Clean All', 'double-opt-in'); ?>"/>
70 <input type="submit" name="doi-clean-confirmed-submit" class="button"
71 value="<?php _e('Clean Confirmed', 'double-opt-in'); ?>"/>
72 <input type="submit" name="doi-clean-unconfirmed-submit" class="button"
73 value="<?php _e('Clean Unconfirmed', 'double-opt-in'); ?>"/>
74 <p>
75 <?php _e('Make sure you backup your database before clicking one of these buttons.', 'double-opt-in'); ?>
76 </p>
77 </div>
78 </div>
79 <div class="option">
80 <div class="label">
81 <label for="delete"><?php _e('Reset Database', 'double-opt-in'); ?></label>
82 </div>
83 <div class="input">
84 <input type="submit" name="doi-reset-submit" class="button button-delete"
85 value="<?php _e('Reset', 'double-opt-in'); ?>"/>
86 <p>
87 <?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'); ?>
88 </p>
89 </div>
90 </div>
91 <?php
92 }
93
94 protected function theSidebar($slug, $page)
95 {
96 if ($page != 'settings') {
97 return;
98 }
99 ?>
100 <div class="box">
101 <h2>
102 <?php _e('Hint:', 'double-opt-in'); ?>
103 </h2>
104 <p>
105 <?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'); ?>
106 </p>
107 </div>
108 <?php
109 }
110
111 public function getSettings($settings)
112 {
113 return $settings;
114 }
115
116 protected function onSave($settings)
117 {
118 // Check if the user wants to clean the database manually
119 $this->maybeCleanDatabase();
120 // Check if the user wants to reset the database manually
121 $this->maybeResetDatabase();
122
123 return $settings;
124 }
125 }
126 }