PluginProbe
Cookie Consent – GDPR & CCPA Cookie Banner & Consent Manager / trunk
Cookie Consent – GDPR & CCPA Cookie Banner & Consent Manager vtrunk
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 / script / database / script-table.php

script-table.php in Cookie Consent – GDPR & CCPA Cookie Banner & Consent Manager trunk, at modules/script/database/script-table.php

126 lines 3.6 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\Script\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 Script_Table
16 * Stores many-to-many relationship between cookies and script patterns
17 */
18 class Script_Table extends Table {
19 const DB_VERSION = '1';
20 const DB_VERSION_FLAG_NAME = 'cookiez_script_db_version';
21
22 const ID = 'id';
23 const NAME = 'name';
24 const COOKIE_ID = 'cookie_id';
25 const TYPE = 'type';
26 const VALUE = 'value';
27 const DESCRIPTION = 'description';
28 const CATEGORY = 'category';
29 const BLOCKING_MODE = 'blocking_mode';
30 const CREATED_AT = 'created_at';
31 const UPDATED_AT = 'updated_at';
32
33 public static $table_name = 'cookiez_scripts';
34
35 /**
36 * Get table columns definition
37 * @return array
38 */
39 public static function get_columns(): array {
40 return [
41 self::ID => [
42 'type' => Database_Constants::get_col_type( Database_Constants::BIGINT ) . ' UNSIGNED',
43 'flags' => Database_Constants::build_flags_string( [
44 Database_Constants::NOT_NULL,
45 Database_Constants::AUTO_INCREMENT,
46 ] ),
47 'key' => Database_Constants::get_primary_key_string( self::ID ),
48 ],
49 self::NAME => [
50 'type' => Database_Constants::get_col_type( Database_Constants::TEXT ),
51 'flags' => Database_Constants::build_flags_string( [
52 Database_Constants::NOT_NULL,
53 ] ),
54 ],
55 self::COOKIE_ID => [
56 'type' => Database_Constants::get_col_type( Database_Constants::BIGINT ) . ' UNSIGNED',
57 'flags' => Database_Constants::build_flags_string( [
58 Database_Constants::DEFAULT,
59 'NULL',
60 ] ),
61 ],
62 self::TYPE => [
63 'type' => Database_Constants::get_col_type( Database_Constants::VARCHAR, 20 ),
64 'flags' => Database_Constants::build_flags_string( [
65 Database_Constants::NOT_NULL,
66 ] ),
67 ],
68 self::VALUE => [
69 'type' => Database_Constants::get_col_type( Database_Constants::TEXT ),
70 'flags' => Database_Constants::build_flags_string( [
71 Database_Constants::NOT_NULL,
72 ] ),
73 ],
74 self::DESCRIPTION => [
75 'type' => Database_Constants::get_col_type( Database_Constants::TEXT ),
76 'flags' => Database_Constants::build_flags_string( [
77 Database_Constants::NULL,
78 Database_Constants::DEFAULT,
79 'NULL',
80 ] ),
81 ],
82 self::CATEGORY => [
83 'type' => Database_Constants::get_col_type( Database_Constants::VARCHAR, 20 ),
84 'flags' => Database_Constants::build_flags_string( [
85 Database_Constants::NOT_NULL,
86 ] ),
87 ],
88 self::BLOCKING_MODE => [
89 'type' => Database_Constants::get_col_type( Database_Constants::VARCHAR, 30 ),
90 'flags' => Database_Constants::build_flags_string( [
91 Database_Constants::NOT_NULL,
92 ] ),
93 ],
94 self::CREATED_AT => [
95 'type' => Database_Constants::get_col_type( Database_Constants::DATETIME ),
96 'flags' => Database_Constants::build_flags_string( [
97 Database_Constants::NOT_NULL,
98 Database_Constants::DEFAULT,
99 Database_Constants::CURRENT_TIMESTAMP,
100 ] ),
101 ],
102 self::UPDATED_AT => [
103 'type' => Database_Constants::get_col_type( Database_Constants::DATETIME ),
104 'flags' => Database_Constants::build_flags_string( [
105 Database_Constants::NOT_NULL,
106 Database_Constants::DEFAULT,
107 Database_Constants::CURRENT_TIMESTAMP,
108 Database_Constants::ON_UPDATE,
109 Database_Constants::CURRENT_TIMESTAMP,
110 ] ),
111 ],
112 ];
113 }
114
115 /**
116 * Get additional keys for the table
117 * @return array
118 */
119 protected static function get_extra_keys(): array {
120 return [
121 Database_Constants::build_key_string( Database_Constants::KEY, self::COOKIE_ID ),
122 'UNIQUE KEY `value_unique` (`' . self::VALUE . '`(255))',
123 ];
124 }
125 }
126