PluginProbe
Cookie Consent – GDPR & CCPA Cookie Banner & Consent Manager / 0.0.3
Cookie Consent – GDPR & CCPA Cookie Banner & Consent Manager v0.0.3
0.0.11 0.0.10 0.0.9 0.0.8 0.0.7 0.0.6 trunk 0.0.1 0.0.2 0.0.3 0.0.4 0.0.5
cookiez / modules / scanner / database / scan-table.php

scan-table.php in Cookie Consent – GDPR & CCPA Cookie Banner & Consent Manager 0.0.3, at modules/scanner/database/scan-table.php

111 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Cookiez\Modules\Scanner\Database;
4
5 use Cookiez\Classes\Database\{
6 Database_Constants,
7 Table
8 };
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit;
12 }
13
14 /**
15 * Class Scan_Table
16 * Stores scan metadata and status
17 */
18 class Scan_Table extends Table {
19 const DB_VERSION = '2';
20 const DB_VERSION_FLAG_NAME = 'cookiez_scan_db_version';
21
22 const ID = 'id';
23 const API_ID = 'api_id';
24 const STATUS = 'status';
25 const TYPE = 'type';
26 const INITIATOR = 'initiator';
27 const SUMMARY = 'summary';
28 const CREATED_AT = 'created_at';
29 const UPDATED_AT = 'updated_at';
30
31 public static $table_name = 'cookiez_scans';
32
33 /**
34 * Get table columns definition
35 * @return array
36 */
37 public static function get_columns(): array {
38 return [
39 self::ID => [
40 'type' => Database_Constants::get_col_type( Database_Constants::BIGINT ) . ' UNSIGNED',
41 'flags' => Database_Constants::build_flags_string( [
42 Database_Constants::NOT_NULL,
43 Database_Constants::AUTO_INCREMENT,
44 ] ),
45 'key' => Database_Constants::get_primary_key_string( self::ID ),
46 ],
47 self::API_ID => [
48 'type' => Database_Constants::get_col_type( Database_Constants::VARCHAR, 36 ),
49 'flags' => Database_Constants::build_flags_string( [
50 Database_Constants::DEFAULT,
51 'NULL',
52 ] ),
53 ],
54 self::STATUS => [
55 'type' => Database_Constants::get_col_type( Database_Constants::VARCHAR, 20 ),
56 'flags' => Database_Constants::build_flags_string( [
57 Database_Constants::NOT_NULL,
58 ] ),
59 ],
60 self::TYPE => [
61 'type' => Database_Constants::get_col_type( Database_Constants::VARCHAR, 20 ),
62 'flags' => Database_Constants::build_flags_string( [
63 Database_Constants::NOT_NULL,
64 ] ),
65 ],
66 self::INITIATOR => [
67 'type' => Database_Constants::get_col_type( Database_Constants::VARCHAR, 20 ),
68 'flags' => Database_Constants::build_flags_string( [
69 Database_Constants::NOT_NULL,
70 ] ),
71 ],
72 self::SUMMARY => [
73 'type' => Database_Constants::get_col_type( Database_Constants::LONGTEXT ),
74 'flags' => Database_Constants::build_flags_string( [
75 Database_Constants::DEFAULT,
76 'NULL',
77 ] ),
78 ],
79 self::CREATED_AT => [
80 'type' => Database_Constants::get_col_type( Database_Constants::DATETIME ),
81 'flags' => Database_Constants::build_flags_string( [
82 Database_Constants::NOT_NULL,
83 Database_Constants::DEFAULT,
84 Database_Constants::CURRENT_TIMESTAMP,
85 ] ),
86 ],
87 self::UPDATED_AT => [
88 'type' => Database_Constants::get_col_type( Database_Constants::DATETIME ),
89 'flags' => Database_Constants::build_flags_string( [
90 Database_Constants::NOT_NULL,
91 Database_Constants::DEFAULT,
92 Database_Constants::CURRENT_TIMESTAMP,
93 Database_Constants::ON_UPDATE,
94 Database_Constants::CURRENT_TIMESTAMP,
95 ] ),
96 ],
97 ];
98 }
99
100 /**
101 * Get additional keys for the table
102 * @return array
103 */
104 protected static function get_extra_keys(): array {
105 return [
106 Database_Constants::build_key_string( Database_Constants::KEY, self::STATUS ),
107 Database_Constants::build_key_string( Database_Constants::KEY, self::CREATED_AT ),
108 ];
109 }
110 }
111