UserConsents.php
64 lines
| 1 | <?php |
| 2 | /** |
| 3 | * GDPR user contents table. |
| 4 | * |
| 5 | * @package Tutor\GDPR\DB |
| 6 | * @author Themeum <support@themeum.com> |
| 7 | * @link https://themeum.com |
| 8 | * @since 4.0.0 |
| 9 | */ |
| 10 | |
| 11 | namespace Tutor\GDPR\DB; |
| 12 | |
| 13 | defined( 'ABSPATH' ) || exit; |
| 14 | |
| 15 | /** |
| 16 | * User contents table class. |
| 17 | */ |
| 18 | class UserConsents extends DB { |
| 19 | |
| 20 | /** |
| 21 | * Get table name. |
| 22 | * |
| 23 | * @since 4.0.0 |
| 24 | * |
| 25 | * @return string |
| 26 | */ |
| 27 | public static function get_table_name() { |
| 28 | global $wpdb; |
| 29 | return $wpdb->prefix . 'tutor_user_consents'; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Get create table schema. |
| 34 | * |
| 35 | * @since 4.0.0 |
| 36 | * |
| 37 | * @return string |
| 38 | */ |
| 39 | public static function get_schema() { |
| 40 | global $wpdb; |
| 41 | |
| 42 | $table_name = static::get_table_name(); |
| 43 | $charset_collate = $wpdb->get_charset_collate(); |
| 44 | |
| 45 | return "CREATE TABLE {$table_name} ( |
| 46 | id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, |
| 47 | user_id BIGINT UNSIGNED NULL, |
| 48 | user_email VARCHAR(190) NOT NULL, |
| 49 | consent_title VARCHAR(100) NOT NULL, |
| 50 | label_snapshot TEXT NOT NULL, |
| 51 | links_snapshot JSON, |
| 52 | version VARCHAR(20) NOT NULL, |
| 53 | consent_method VARCHAR(255) NOT NULL, |
| 54 | ip_address VARCHAR(45), |
| 55 | user_agent TEXT, |
| 56 | source VARCHAR(50), -- consent page info |
| 57 | created_at_gmt DATETIME NOT NULL, |
| 58 | INDEX (user_id), |
| 59 | INDEX (consent_title), |
| 60 | INDEX (created_at_gmt) |
| 61 | ) {$charset_collate};"; |
| 62 | } |
| 63 | } |
| 64 |