@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | // unfortunately, this needs to be done upon INCLUSION of this file, |
10 | 10 | // instead of construction, because it only gets constructed on first page load |
11 | 11 | // (all other times it gets resurrected from a wordpress option) |
12 | -$stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*'); |
|
12 | +$stages = glob(EE_CORE.'data_migration_scripts/4_9_0_stages/*'); |
|
13 | 13 | $class_to_filepath = array(); |
14 | 14 | foreach ($stages as $filepath) { |
15 | 15 | $matches = array(); |
16 | 16 | preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
17 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
17 | + $class_to_filepath[$matches[1]] = $filepath; |
|
18 | 18 | } |
19 | 19 | // give addons a chance to autoload their stages too |
20 | 20 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath); |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | if (version_compare($version_string, '4.9.0.decaf', '<') && version_compare($version_string, '4.8.0.decaf', '>=')) { |
66 | 66 | // echo "$version_string can be migrated from"; |
67 | 67 | return true; |
68 | - } elseif (! $version_string) { |
|
68 | + } elseif ( ! $version_string) { |
|
69 | 69 | // echo "no version string provided: $version_string"; |
70 | 70 | // no version string provided... this must be pre 4.3 |
71 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
71 | + return false; // changed mind. dont want people thinking they should migrate yet because they cant |
|
72 | 72 | } else { |
73 | 73 | // echo "$version_string doesnt apply"; |
74 | 74 | return false; |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function schema_changes_before_migration() |
84 | 84 | { |
85 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
85 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
86 | 86 | $now_in_mysql = current_time('mysql', true); |
87 | 87 | $table_name = 'esp_answer'; |
88 | 88 | $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | $stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*'); |
13 | 13 | $class_to_filepath = array(); |
14 | 14 | foreach ($stages as $filepath) { |
15 | - $matches = array(); |
|
16 | - preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
15 | + $matches = array(); |
|
16 | + preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
18 | 18 | } |
19 | 19 | // give addons a chance to autoload their stages too |
20 | 20 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath); |
@@ -33,68 +33,68 @@ discard block |
||
33 | 33 | */ |
34 | 34 | class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base |
35 | 35 | { |
36 | - /** |
|
37 | - * return EE_DMS_Core_4_9_0 |
|
38 | - * |
|
39 | - * @param TableManager $table_manager |
|
40 | - * @param TableAnalysis $table_analysis |
|
41 | - */ |
|
42 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
43 | - { |
|
44 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso"); |
|
45 | - $this->_priority = 10; |
|
46 | - $this->_migration_stages = array( |
|
47 | - new EE_DMS_4_9_0_Email_System_Question(), |
|
48 | - new EE_DMS_4_9_0_Answers_With_No_Registration(), |
|
49 | - ); |
|
50 | - parent::__construct($table_manager, $table_analysis); |
|
51 | - } |
|
36 | + /** |
|
37 | + * return EE_DMS_Core_4_9_0 |
|
38 | + * |
|
39 | + * @param TableManager $table_manager |
|
40 | + * @param TableAnalysis $table_analysis |
|
41 | + */ |
|
42 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
43 | + { |
|
44 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso"); |
|
45 | + $this->_priority = 10; |
|
46 | + $this->_migration_stages = array( |
|
47 | + new EE_DMS_4_9_0_Email_System_Question(), |
|
48 | + new EE_DMS_4_9_0_Answers_With_No_Registration(), |
|
49 | + ); |
|
50 | + parent::__construct($table_manager, $table_analysis); |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Whether to migrate or not. |
|
57 | - * |
|
58 | - * @param array $version_array |
|
59 | - * @return bool |
|
60 | - */ |
|
61 | - public function can_migrate_from_version($version_array) |
|
62 | - { |
|
63 | - $version_string = $version_array['Core']; |
|
64 | - if (version_compare($version_string, '4.9.0.decaf', '<') && version_compare($version_string, '4.8.0.decaf', '>=')) { |
|
65 | - // echo "$version_string can be migrated from"; |
|
66 | - return true; |
|
67 | - } elseif (! $version_string) { |
|
68 | - // echo "no version string provided: $version_string"; |
|
69 | - // no version string provided... this must be pre 4.3 |
|
70 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
71 | - } else { |
|
72 | - // echo "$version_string doesnt apply"; |
|
73 | - return false; |
|
74 | - } |
|
75 | - } |
|
55 | + /** |
|
56 | + * Whether to migrate or not. |
|
57 | + * |
|
58 | + * @param array $version_array |
|
59 | + * @return bool |
|
60 | + */ |
|
61 | + public function can_migrate_from_version($version_array) |
|
62 | + { |
|
63 | + $version_string = $version_array['Core']; |
|
64 | + if (version_compare($version_string, '4.9.0.decaf', '<') && version_compare($version_string, '4.8.0.decaf', '>=')) { |
|
65 | + // echo "$version_string can be migrated from"; |
|
66 | + return true; |
|
67 | + } elseif (! $version_string) { |
|
68 | + // echo "no version string provided: $version_string"; |
|
69 | + // no version string provided... this must be pre 4.3 |
|
70 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
71 | + } else { |
|
72 | + // echo "$version_string doesnt apply"; |
|
73 | + return false; |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | 78 | |
79 | - /** |
|
80 | - * @return bool |
|
81 | - */ |
|
82 | - public function schema_changes_before_migration() |
|
83 | - { |
|
84 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
85 | - $now_in_mysql = current_time('mysql', true); |
|
86 | - $table_name = 'esp_answer'; |
|
87 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
79 | + /** |
|
80 | + * @return bool |
|
81 | + */ |
|
82 | + public function schema_changes_before_migration() |
|
83 | + { |
|
84 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
85 | + $now_in_mysql = current_time('mysql', true); |
|
86 | + $table_name = 'esp_answer'; |
|
87 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
88 | 88 | REG_ID int(10) unsigned NOT NULL, |
89 | 89 | QST_ID int(10) unsigned NOT NULL, |
90 | 90 | ANS_value text NOT NULL, |
91 | 91 | PRIMARY KEY (ANS_ID), |
92 | 92 | KEY REG_ID (REG_ID), |
93 | 93 | KEY QST_ID (QST_ID)"; |
94 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
95 | - $table_name = 'esp_attendee_meta'; |
|
96 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email'); |
|
97 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
94 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
95 | + $table_name = 'esp_attendee_meta'; |
|
96 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email'); |
|
97 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
98 | 98 | ATT_ID bigint(20) unsigned NOT NULL, |
99 | 99 | ATT_fname varchar(45) NOT NULL, |
100 | 100 | ATT_lname varchar(45) NOT NULL, |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | KEY ATT_email (ATT_email(191)), |
112 | 112 | KEY ATT_lname (ATT_lname), |
113 | 113 | KEY ATT_fname (ATT_fname)"; |
114 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
115 | - $table_name = 'esp_checkin'; |
|
116 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
114 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
115 | + $table_name = 'esp_checkin'; |
|
116 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
117 | 117 | REG_ID int(10) unsigned NOT NULL, |
118 | 118 | DTT_ID int(10) unsigned NOT NULL, |
119 | 119 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | PRIMARY KEY (CHK_ID), |
122 | 122 | KEY REG_ID (REG_ID), |
123 | 123 | KEY DTT_ID (DTT_ID)"; |
124 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
125 | - $table_name = 'esp_country'; |
|
126 | - $sql = "CNT_ISO varchar(2) NOT NULL, |
|
124 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
125 | + $table_name = 'esp_country'; |
|
126 | + $sql = "CNT_ISO varchar(2) NOT NULL, |
|
127 | 127 | CNT_ISO3 varchar(3) NOT NULL, |
128 | 128 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
129 | 129 | CNT_name varchar(45) NOT NULL, |
@@ -139,29 +139,29 @@ discard block |
||
139 | 139 | CNT_is_EU tinyint(1) DEFAULT '0', |
140 | 140 | CNT_active tinyint(1) DEFAULT '0', |
141 | 141 | PRIMARY KEY (CNT_ISO)"; |
142 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
143 | - $table_name = 'esp_currency'; |
|
144 | - $sql = "CUR_code varchar(6) NOT NULL, |
|
142 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
143 | + $table_name = 'esp_currency'; |
|
144 | + $sql = "CUR_code varchar(6) NOT NULL, |
|
145 | 145 | CUR_single varchar(45) DEFAULT 'dollar', |
146 | 146 | CUR_plural varchar(45) DEFAULT 'dollars', |
147 | 147 | CUR_sign varchar(45) DEFAULT '$', |
148 | 148 | CUR_dec_plc varchar(1) NOT NULL DEFAULT '2', |
149 | 149 | CUR_active tinyint(1) DEFAULT '0', |
150 | 150 | PRIMARY KEY (CUR_code)"; |
151 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
152 | - // note: although this table is no longer in use, |
|
153 | - // it hasn't been removed because then queries to the model will have errors. |
|
154 | - // but you should expect this table and its corresponding model to be removed in |
|
155 | - // the next few months |
|
156 | - $table_name = 'esp_currency_payment_method'; |
|
157 | - $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
151 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
152 | + // note: although this table is no longer in use, |
|
153 | + // it hasn't been removed because then queries to the model will have errors. |
|
154 | + // but you should expect this table and its corresponding model to be removed in |
|
155 | + // the next few months |
|
156 | + $table_name = 'esp_currency_payment_method'; |
|
157 | + $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
158 | 158 | CUR_code varchar(6) NOT NULL, |
159 | 159 | PMD_ID int(11) NOT NULL, |
160 | 160 | PRIMARY KEY (CPM_ID), |
161 | 161 | KEY PMD_ID (PMD_ID)"; |
162 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
163 | - $table_name = 'esp_datetime'; |
|
164 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
162 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
163 | + $table_name = 'esp_datetime'; |
|
164 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
165 | 165 | EVT_ID bigint(20) unsigned NOT NULL, |
166 | 166 | DTT_name varchar(255) NOT NULL DEFAULT '', |
167 | 167 | DTT_description text NOT NULL, |
@@ -178,25 +178,25 @@ discard block |
||
178 | 178 | KEY DTT_EVT_start (DTT_EVT_start), |
179 | 179 | KEY EVT_ID (EVT_ID), |
180 | 180 | KEY DTT_is_primary (DTT_is_primary)"; |
181 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
182 | - $table_name = "esp_datetime_ticket"; |
|
183 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
181 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
182 | + $table_name = "esp_datetime_ticket"; |
|
183 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
184 | 184 | DTT_ID int(10) unsigned NOT NULL, |
185 | 185 | TKT_ID int(10) unsigned NOT NULL, |
186 | 186 | PRIMARY KEY (DTK_ID), |
187 | 187 | KEY DTT_ID (DTT_ID), |
188 | 188 | KEY TKT_ID (TKT_ID)"; |
189 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
190 | - $table_name = 'esp_event_message_template'; |
|
191 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
189 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
190 | + $table_name = 'esp_event_message_template'; |
|
191 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
192 | 192 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
193 | 193 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
194 | 194 | PRIMARY KEY (EMT_ID), |
195 | 195 | KEY EVT_ID (EVT_ID), |
196 | 196 | KEY GRP_ID (GRP_ID)"; |
197 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | - $table_name = 'esp_event_meta'; |
|
199 | - $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
197 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | + $table_name = 'esp_event_meta'; |
|
199 | + $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
200 | 200 | EVT_ID bigint(20) unsigned NOT NULL, |
201 | 201 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
202 | 202 | EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -211,34 +211,34 @@ discard block |
||
211 | 211 | EVT_donations tinyint(1) NULL, |
212 | 212 | PRIMARY KEY (EVTM_ID), |
213 | 213 | KEY EVT_ID (EVT_ID)"; |
214 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
215 | - $table_name = 'esp_event_question_group'; |
|
216 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
214 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
215 | + $table_name = 'esp_event_question_group'; |
|
216 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
217 | 217 | EVT_ID bigint(20) unsigned NOT NULL, |
218 | 218 | QSG_ID int(10) unsigned NOT NULL, |
219 | 219 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
220 | 220 | PRIMARY KEY (EQG_ID), |
221 | 221 | KEY EVT_ID (EVT_ID), |
222 | 222 | KEY QSG_ID (QSG_ID)"; |
223 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
224 | - $table_name = 'esp_event_venue'; |
|
225 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
223 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
224 | + $table_name = 'esp_event_venue'; |
|
225 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
226 | 226 | EVT_ID bigint(20) unsigned NOT NULL, |
227 | 227 | VNU_ID bigint(20) unsigned NOT NULL, |
228 | 228 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
229 | 229 | PRIMARY KEY (EVV_ID)"; |
230 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
231 | - $table_name = 'esp_extra_meta'; |
|
232 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
230 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
231 | + $table_name = 'esp_extra_meta'; |
|
232 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
233 | 233 | OBJ_ID int(11) DEFAULT NULL, |
234 | 234 | EXM_type varchar(45) DEFAULT NULL, |
235 | 235 | EXM_key varchar(45) DEFAULT NULL, |
236 | 236 | EXM_value text, |
237 | 237 | PRIMARY KEY (EXM_ID), |
238 | 238 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
239 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
240 | - $table_name = 'esp_extra_join'; |
|
241 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
239 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
240 | + $table_name = 'esp_extra_join'; |
|
241 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
242 | 242 | EXJ_first_model_id varchar(6) NOT NULL, |
243 | 243 | EXJ_first_model_name varchar(20) NOT NULL, |
244 | 244 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | PRIMARY KEY (EXJ_ID), |
247 | 247 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
248 | 248 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
249 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
250 | - $table_name = 'esp_line_item'; |
|
251 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
249 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
250 | + $table_name = 'esp_line_item'; |
|
251 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
252 | 252 | LIN_code varchar(245) NOT NULL DEFAULT '', |
253 | 253 | TXN_ID int(11) DEFAULT NULL, |
254 | 254 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -269,11 +269,11 @@ discard block |
||
269 | 269 | KEY txn_type_timestamp (TXN_ID,LIN_type,LIN_timestamp), |
270 | 270 | KEY txn_obj_id_obj_type (TXN_ID,OBJ_ID,OBJ_type), |
271 | 271 | KEY obj_id_obj_type (OBJ_ID,OBJ_type)"; |
272 | - $this->_get_table_manager()->dropIndex('esp_line_item', 'TXN_ID'); |
|
273 | - $this->_get_table_manager()->dropIndex('esp_line_item', 'LIN_code'); |
|
274 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
275 | - $table_name = 'esp_log'; |
|
276 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
272 | + $this->_get_table_manager()->dropIndex('esp_line_item', 'TXN_ID'); |
|
273 | + $this->_get_table_manager()->dropIndex('esp_line_item', 'LIN_code'); |
|
274 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
275 | + $table_name = 'esp_log'; |
|
276 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
277 | 277 | LOG_time datetime DEFAULT NULL, |
278 | 278 | OBJ_ID varchar(45) DEFAULT NULL, |
279 | 279 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -284,12 +284,12 @@ discard block |
||
284 | 284 | KEY LOG_time (LOG_time), |
285 | 285 | KEY OBJ (OBJ_type,OBJ_ID), |
286 | 286 | KEY LOG_type (LOG_type)"; |
287 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
288 | - $table_name = 'esp_message'; |
|
289 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to'); |
|
290 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from'); |
|
291 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject'); |
|
292 | - $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
287 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
288 | + $table_name = 'esp_message'; |
|
289 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to'); |
|
290 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from'); |
|
291 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject'); |
|
292 | + $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
293 | 293 | GRP_ID int(10) unsigned NULL, |
294 | 294 | MSG_token varchar(255) NULL, |
295 | 295 | TXN_ID int(10) unsigned NULL, |
@@ -321,18 +321,18 @@ discard block |
||
321 | 321 | KEY STS_ID (STS_ID), |
322 | 322 | KEY MSG_created (MSG_created), |
323 | 323 | KEY MSG_modified (MSG_modified)"; |
324 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
325 | - $table_name = 'esp_message_template'; |
|
326 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
324 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
325 | + $table_name = 'esp_message_template'; |
|
326 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
327 | 327 | GRP_ID int(10) unsigned NOT NULL, |
328 | 328 | MTP_context varchar(50) NOT NULL, |
329 | 329 | MTP_template_field varchar(30) NOT NULL, |
330 | 330 | MTP_content text NOT NULL, |
331 | 331 | PRIMARY KEY (MTP_ID), |
332 | 332 | KEY GRP_ID (GRP_ID)"; |
333 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
334 | - $table_name = 'esp_message_template_group'; |
|
335 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
333 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
334 | + $table_name = 'esp_message_template_group'; |
|
335 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
336 | 336 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
337 | 337 | MTP_name varchar(245) NOT NULL DEFAULT '', |
338 | 338 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -344,9 +344,9 @@ discard block |
||
344 | 344 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
345 | 345 | PRIMARY KEY (GRP_ID), |
346 | 346 | KEY MTP_user_id (MTP_user_id)"; |
347 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
348 | - $table_name = 'esp_payment'; |
|
349 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
347 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
348 | + $table_name = 'esp_payment'; |
|
349 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
350 | 350 | TXN_ID int(10) unsigned DEFAULT NULL, |
351 | 351 | STS_ID varchar(3) DEFAULT NULL, |
352 | 352 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -363,9 +363,9 @@ discard block |
||
363 | 363 | PRIMARY KEY (PAY_ID), |
364 | 364 | KEY PAY_timestamp (PAY_timestamp), |
365 | 365 | KEY TXN_ID (TXN_ID)"; |
366 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
367 | - $table_name = 'esp_payment_method'; |
|
368 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
366 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
367 | + $table_name = 'esp_payment_method'; |
|
368 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
369 | 369 | PMD_type varchar(124) DEFAULT NULL, |
370 | 370 | PMD_name varchar(255) DEFAULT NULL, |
371 | 371 | PMD_desc text, |
@@ -381,24 +381,24 @@ discard block |
||
381 | 381 | PRIMARY KEY (PMD_ID), |
382 | 382 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
383 | 383 | KEY PMD_type (PMD_type)"; |
384 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
385 | - $table_name = "esp_ticket_price"; |
|
386 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
384 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
385 | + $table_name = "esp_ticket_price"; |
|
386 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
387 | 387 | TKT_ID int(10) unsigned NOT NULL, |
388 | 388 | PRC_ID int(10) unsigned NOT NULL, |
389 | 389 | PRIMARY KEY (TKP_ID), |
390 | 390 | KEY TKT_ID (TKT_ID), |
391 | 391 | KEY PRC_ID (PRC_ID)"; |
392 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
393 | - $table_name = "esp_ticket_template"; |
|
394 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
392 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
393 | + $table_name = "esp_ticket_template"; |
|
394 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
395 | 395 | TTM_name varchar(45) NOT NULL, |
396 | 396 | TTM_description text, |
397 | 397 | TTM_file varchar(45), |
398 | 398 | PRIMARY KEY (TTM_ID)"; |
399 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
400 | - $table_name = 'esp_question'; |
|
401 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
399 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
400 | + $table_name = 'esp_question'; |
|
401 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
402 | 402 | QST_display_text text NOT NULL, |
403 | 403 | QST_admin_label varchar(255) NOT NULL, |
404 | 404 | QST_system varchar(25) DEFAULT NULL, |
@@ -412,18 +412,18 @@ discard block |
||
412 | 412 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
413 | 413 | PRIMARY KEY (QST_ID), |
414 | 414 | KEY QST_order (QST_order)'; |
415 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
416 | - $table_name = 'esp_question_group_question'; |
|
417 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
415 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
416 | + $table_name = 'esp_question_group_question'; |
|
417 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
418 | 418 | QSG_ID int(10) unsigned NOT NULL, |
419 | 419 | QST_ID int(10) unsigned NOT NULL, |
420 | 420 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
421 | 421 | PRIMARY KEY (QGQ_ID), |
422 | 422 | KEY QST_ID (QST_ID), |
423 | 423 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
424 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
425 | - $table_name = 'esp_question_option'; |
|
426 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
424 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
425 | + $table_name = 'esp_question_option'; |
|
426 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
427 | 427 | QSO_value varchar(255) NOT NULL, |
428 | 428 | QSO_desc text NOT NULL, |
429 | 429 | QST_ID int(10) unsigned NOT NULL, |
@@ -433,9 +433,9 @@ discard block |
||
433 | 433 | PRIMARY KEY (QSO_ID), |
434 | 434 | KEY QST_ID (QST_ID), |
435 | 435 | KEY QSO_order (QSO_order)"; |
436 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
437 | - $table_name = 'esp_registration'; |
|
438 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
436 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
437 | + $table_name = 'esp_registration'; |
|
438 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
439 | 439 | EVT_ID bigint(20) unsigned NOT NULL, |
440 | 440 | ATT_ID bigint(20) unsigned NOT NULL, |
441 | 441 | TXN_ID int(10) unsigned NOT NULL, |
@@ -459,18 +459,18 @@ discard block |
||
459 | 459 | KEY TKT_ID (TKT_ID), |
460 | 460 | KEY EVT_ID (EVT_ID), |
461 | 461 | KEY STS_ID (STS_ID)"; |
462 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
463 | - $table_name = 'esp_registration_payment'; |
|
464 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
462 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
463 | + $table_name = 'esp_registration_payment'; |
|
464 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
465 | 465 | REG_ID int(10) unsigned NOT NULL, |
466 | 466 | PAY_ID int(10) unsigned NULL, |
467 | 467 | RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
468 | 468 | PRIMARY KEY (RPY_ID), |
469 | 469 | KEY REG_ID (REG_ID), |
470 | 470 | KEY PAY_ID (PAY_ID)"; |
471 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
472 | - $table_name = 'esp_state'; |
|
473 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
471 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
472 | + $table_name = 'esp_state'; |
|
473 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
474 | 474 | CNT_ISO varchar(2) NOT NULL, |
475 | 475 | STA_abbrev varchar(24) NOT NULL, |
476 | 476 | STA_name varchar(100) NOT NULL, |
@@ -478,9 +478,9 @@ discard block |
||
478 | 478 | PRIMARY KEY (STA_ID), |
479 | 479 | KEY STA_abbrev (STA_abbrev), |
480 | 480 | KEY CNT_ISO (CNT_ISO)"; |
481 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
482 | - $table_name = 'esp_status'; |
|
483 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
481 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
482 | + $table_name = 'esp_status'; |
|
483 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
484 | 484 | STS_code varchar(45) NOT NULL, |
485 | 485 | STS_type varchar(45) NOT NULL, |
486 | 486 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -488,9 +488,9 @@ discard block |
||
488 | 488 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
489 | 489 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
490 | 490 | KEY STS_type (STS_type)"; |
491 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
492 | - $table_name = 'esp_transaction'; |
|
493 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
491 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
492 | + $table_name = 'esp_transaction'; |
|
493 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
494 | 494 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
495 | 495 | TXN_total decimal(12,3) DEFAULT '0.00', |
496 | 496 | TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00', |
@@ -502,9 +502,9 @@ discard block |
||
502 | 502 | PRIMARY KEY (TXN_ID), |
503 | 503 | KEY TXN_timestamp (TXN_timestamp), |
504 | 504 | KEY STS_ID (STS_ID)"; |
505 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
506 | - $table_name = 'esp_venue_meta'; |
|
507 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
505 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
506 | + $table_name = 'esp_venue_meta'; |
|
507 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
508 | 508 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
509 | 509 | VNU_address varchar(255) DEFAULT NULL, |
510 | 510 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -523,10 +523,10 @@ discard block |
||
523 | 523 | KEY VNU_ID (VNU_ID), |
524 | 524 | KEY STA_ID (STA_ID), |
525 | 525 | KEY CNT_ISO (CNT_ISO)"; |
526 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
527 | - // modified tables |
|
528 | - $table_name = "esp_price"; |
|
529 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
526 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
527 | + // modified tables |
|
528 | + $table_name = "esp_price"; |
|
529 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
530 | 530 | PRT_ID tinyint(3) unsigned NOT NULL, |
531 | 531 | PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
532 | 532 | PRC_name varchar(245) NOT NULL, |
@@ -539,9 +539,9 @@ discard block |
||
539 | 539 | PRC_parent int(10) unsigned DEFAULT 0, |
540 | 540 | PRIMARY KEY (PRC_ID), |
541 | 541 | KEY PRT_ID (PRT_ID)"; |
542 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
543 | - $table_name = "esp_price_type"; |
|
544 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
542 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
543 | + $table_name = "esp_price_type"; |
|
544 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
545 | 545 | PRT_name varchar(45) NOT NULL, |
546 | 546 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
547 | 547 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -550,9 +550,9 @@ discard block |
||
550 | 550 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
551 | 551 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
552 | 552 | PRIMARY KEY (PRT_ID)"; |
553 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
554 | - $table_name = "esp_ticket"; |
|
555 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
553 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
554 | + $table_name = "esp_ticket"; |
|
555 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
556 | 556 | TTM_ID int(10) unsigned NOT NULL, |
557 | 557 | TKT_name varchar(245) NOT NULL DEFAULT '', |
558 | 558 | TKT_description text NOT NULL, |
@@ -575,9 +575,9 @@ discard block |
||
575 | 575 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
576 | 576 | PRIMARY KEY (TKT_ID), |
577 | 577 | KEY TKT_start_date (TKT_start_date)"; |
578 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
579 | - $table_name = 'esp_question_group'; |
|
580 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
578 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
579 | + $table_name = 'esp_question_group'; |
|
580 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
581 | 581 | QSG_name varchar(255) NOT NULL, |
582 | 582 | QSG_identifier varchar(100) NOT NULL, |
583 | 583 | QSG_desc text NULL, |
@@ -590,165 +590,165 @@ discard block |
||
590 | 590 | PRIMARY KEY (QSG_ID), |
591 | 591 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
592 | 592 | KEY QSG_order (QSG_order)'; |
593 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
594 | - $this->insert_default_data(); |
|
595 | - return true; |
|
596 | - } |
|
593 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
594 | + $this->insert_default_data(); |
|
595 | + return true; |
|
596 | + } |
|
597 | 597 | |
598 | - /** |
|
599 | - * Inserts default data after parent was called. |
|
600 | - * @since 4.10.0.p |
|
601 | - * @throws EE_Error |
|
602 | - * @throws InvalidArgumentException |
|
603 | - * @throws ReflectionException |
|
604 | - * @throws InvalidDataTypeException |
|
605 | - * @throws InvalidInterfaceException |
|
606 | - */ |
|
607 | - public function insert_default_data() |
|
608 | - { |
|
609 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
610 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
611 | - // (because many need to convert old string states to foreign keys into the states table) |
|
612 | - $script_4_1_defaults->insert_default_states(); |
|
613 | - $script_4_1_defaults->insert_default_countries(); |
|
614 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
615 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
616 | - $script_4_5_defaults->insert_default_price_types(); |
|
617 | - $script_4_5_defaults->insert_default_prices(); |
|
618 | - $script_4_5_defaults->insert_default_tickets(); |
|
619 | - /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
620 | - $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
621 | - $script_4_6_defaults->add_default_admin_only_payments(); |
|
622 | - $script_4_6_defaults->insert_default_currencies(); |
|
623 | - /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
624 | - $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
625 | - $script_4_8_defaults->verify_new_countries(); |
|
626 | - $script_4_8_defaults->verify_new_currencies(); |
|
627 | - $this->verify_db_collations(); |
|
628 | - $this->verify_db_collations_again(); |
|
629 | - } |
|
598 | + /** |
|
599 | + * Inserts default data after parent was called. |
|
600 | + * @since 4.10.0.p |
|
601 | + * @throws EE_Error |
|
602 | + * @throws InvalidArgumentException |
|
603 | + * @throws ReflectionException |
|
604 | + * @throws InvalidDataTypeException |
|
605 | + * @throws InvalidInterfaceException |
|
606 | + */ |
|
607 | + public function insert_default_data() |
|
608 | + { |
|
609 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
610 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
611 | + // (because many need to convert old string states to foreign keys into the states table) |
|
612 | + $script_4_1_defaults->insert_default_states(); |
|
613 | + $script_4_1_defaults->insert_default_countries(); |
|
614 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
615 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
616 | + $script_4_5_defaults->insert_default_price_types(); |
|
617 | + $script_4_5_defaults->insert_default_prices(); |
|
618 | + $script_4_5_defaults->insert_default_tickets(); |
|
619 | + /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
620 | + $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
621 | + $script_4_6_defaults->add_default_admin_only_payments(); |
|
622 | + $script_4_6_defaults->insert_default_currencies(); |
|
623 | + /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
624 | + $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
625 | + $script_4_8_defaults->verify_new_countries(); |
|
626 | + $script_4_8_defaults->verify_new_currencies(); |
|
627 | + $this->verify_db_collations(); |
|
628 | + $this->verify_db_collations_again(); |
|
629 | + } |
|
630 | 630 | |
631 | 631 | |
632 | 632 | |
633 | - /** |
|
634 | - * @return boolean |
|
635 | - */ |
|
636 | - public function schema_changes_after_migration() |
|
637 | - { |
|
638 | - return true; |
|
639 | - } |
|
633 | + /** |
|
634 | + * @return boolean |
|
635 | + */ |
|
636 | + public function schema_changes_after_migration() |
|
637 | + { |
|
638 | + return true; |
|
639 | + } |
|
640 | 640 | |
641 | 641 | |
642 | 642 | |
643 | - public function migration_page_hooks() |
|
644 | - { |
|
645 | - } |
|
643 | + public function migration_page_hooks() |
|
644 | + { |
|
645 | + } |
|
646 | 646 | |
647 | 647 | |
648 | 648 | |
649 | - /** |
|
650 | - * Verify all EE4 models' tables use utf8mb4 collation |
|
651 | - * |
|
652 | - * @return void |
|
653 | - */ |
|
654 | - public function verify_db_collations() |
|
655 | - { |
|
656 | - global $wpdb; |
|
657 | - // double-check we haven't already done it or that that the DB doesn't support utf8mb4 |
|
658 | - if ( |
|
659 | - 'utf8mb4' !== $wpdb->charset |
|
660 | - || get_option('ee_verified_db_collations', false) |
|
661 | - ) { |
|
662 | - return; |
|
663 | - } |
|
664 | - // grab tables from each model |
|
665 | - $tables_to_check = array(); |
|
666 | - foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
667 | - if (method_exists($model_name, 'instance')) { |
|
668 | - $model_obj = call_user_func(array($model_name, 'instance')); |
|
669 | - if ($model_obj instanceof EEM_Base) { |
|
670 | - foreach ($model_obj->get_tables() as $table) { |
|
671 | - if ( |
|
672 | - strpos($table->get_table_name(), 'esp_') |
|
673 | - && (is_main_site()// for main tables, verify global tables |
|
674 | - || ! $table->is_global()// if not the main site, then only verify non-global tables (avoid doubling up) |
|
675 | - ) |
|
676 | - && function_exists('maybe_convert_table_to_utf8mb4') |
|
677 | - ) { |
|
678 | - $tables_to_check[] = $table->get_table_name(); |
|
679 | - } |
|
680 | - } |
|
681 | - } |
|
682 | - } |
|
683 | - } |
|
684 | - // and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active |
|
685 | - // when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead |
|
686 | - // of hard-coding this |
|
687 | - $addon_tables = array( |
|
688 | - // mailchimp |
|
689 | - 'esp_event_mailchimp_list_group', |
|
690 | - 'esp_event_question_mailchimp_field', |
|
691 | - // multisite |
|
692 | - 'esp_blog_meta', |
|
693 | - // people |
|
694 | - 'esp_people_to_post', |
|
695 | - // promotions |
|
696 | - 'esp_promotion', |
|
697 | - 'esp_promotion_object', |
|
698 | - ); |
|
699 | - foreach ($addon_tables as $table_name) { |
|
700 | - $tables_to_check[] = $table_name; |
|
701 | - } |
|
702 | - $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
703 | - // ok and now let's remember this was done (without needing to check the db schemas all over again) |
|
704 | - add_option('ee_verified_db_collations', true, null, 'no'); |
|
705 | - // seeing how this ran with the fix from 10435, no need to check again |
|
706 | - add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
707 | - } |
|
649 | + /** |
|
650 | + * Verify all EE4 models' tables use utf8mb4 collation |
|
651 | + * |
|
652 | + * @return void |
|
653 | + */ |
|
654 | + public function verify_db_collations() |
|
655 | + { |
|
656 | + global $wpdb; |
|
657 | + // double-check we haven't already done it or that that the DB doesn't support utf8mb4 |
|
658 | + if ( |
|
659 | + 'utf8mb4' !== $wpdb->charset |
|
660 | + || get_option('ee_verified_db_collations', false) |
|
661 | + ) { |
|
662 | + return; |
|
663 | + } |
|
664 | + // grab tables from each model |
|
665 | + $tables_to_check = array(); |
|
666 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
667 | + if (method_exists($model_name, 'instance')) { |
|
668 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
669 | + if ($model_obj instanceof EEM_Base) { |
|
670 | + foreach ($model_obj->get_tables() as $table) { |
|
671 | + if ( |
|
672 | + strpos($table->get_table_name(), 'esp_') |
|
673 | + && (is_main_site()// for main tables, verify global tables |
|
674 | + || ! $table->is_global()// if not the main site, then only verify non-global tables (avoid doubling up) |
|
675 | + ) |
|
676 | + && function_exists('maybe_convert_table_to_utf8mb4') |
|
677 | + ) { |
|
678 | + $tables_to_check[] = $table->get_table_name(); |
|
679 | + } |
|
680 | + } |
|
681 | + } |
|
682 | + } |
|
683 | + } |
|
684 | + // and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active |
|
685 | + // when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead |
|
686 | + // of hard-coding this |
|
687 | + $addon_tables = array( |
|
688 | + // mailchimp |
|
689 | + 'esp_event_mailchimp_list_group', |
|
690 | + 'esp_event_question_mailchimp_field', |
|
691 | + // multisite |
|
692 | + 'esp_blog_meta', |
|
693 | + // people |
|
694 | + 'esp_people_to_post', |
|
695 | + // promotions |
|
696 | + 'esp_promotion', |
|
697 | + 'esp_promotion_object', |
|
698 | + ); |
|
699 | + foreach ($addon_tables as $table_name) { |
|
700 | + $tables_to_check[] = $table_name; |
|
701 | + } |
|
702 | + $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
703 | + // ok and now let's remember this was done (without needing to check the db schemas all over again) |
|
704 | + add_option('ee_verified_db_collations', true, null, 'no'); |
|
705 | + // seeing how this ran with the fix from 10435, no need to check again |
|
706 | + add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
707 | + } |
|
708 | 708 | |
709 | 709 | |
710 | 710 | |
711 | - /** |
|
712 | - * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435 |
|
713 | - * which meant some DB collations might not have been updated |
|
714 | - * @return void |
|
715 | - */ |
|
716 | - public function verify_db_collations_again() |
|
717 | - { |
|
718 | - global $wpdb; |
|
719 | - // double-check we haven't already done this or that the DB doesn't support it |
|
720 | - // compare to how WordPress' upgrade_430() function does this check |
|
721 | - if ( |
|
722 | - 'utf8mb4' !== $wpdb->charset |
|
723 | - || get_option('ee_verified_db_collations_again', false) |
|
724 | - ) { |
|
725 | - return; |
|
726 | - } |
|
727 | - $tables_to_check = array( |
|
728 | - 'esp_attendee_meta', |
|
729 | - 'esp_message' |
|
730 | - ); |
|
731 | - $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
732 | - add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
733 | - } |
|
711 | + /** |
|
712 | + * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435 |
|
713 | + * which meant some DB collations might not have been updated |
|
714 | + * @return void |
|
715 | + */ |
|
716 | + public function verify_db_collations_again() |
|
717 | + { |
|
718 | + global $wpdb; |
|
719 | + // double-check we haven't already done this or that the DB doesn't support it |
|
720 | + // compare to how WordPress' upgrade_430() function does this check |
|
721 | + if ( |
|
722 | + 'utf8mb4' !== $wpdb->charset |
|
723 | + || get_option('ee_verified_db_collations_again', false) |
|
724 | + ) { |
|
725 | + return; |
|
726 | + } |
|
727 | + $tables_to_check = array( |
|
728 | + 'esp_attendee_meta', |
|
729 | + 'esp_message' |
|
730 | + ); |
|
731 | + $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
732 | + add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
733 | + } |
|
734 | 734 | |
735 | 735 | |
736 | 736 | |
737 | - /** |
|
738 | - * Runs maybe_convert_table_to_utf8mb4 on the specified tables |
|
739 | - * @param $tables_to_check |
|
740 | - * @return boolean true if logic ran, false if it didn't |
|
741 | - */ |
|
742 | - protected function _verify_db_collations_for_tables($tables_to_check) |
|
743 | - { |
|
744 | - foreach ($tables_to_check as $table_name) { |
|
745 | - $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
|
746 | - if ( |
|
747 | - ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name) |
|
748 | - && $this->_get_table_analysis()->tableExists($table_name) |
|
749 | - ) { |
|
750 | - maybe_convert_table_to_utf8mb4($table_name); |
|
751 | - } |
|
752 | - } |
|
753 | - } |
|
737 | + /** |
|
738 | + * Runs maybe_convert_table_to_utf8mb4 on the specified tables |
|
739 | + * @param $tables_to_check |
|
740 | + * @return boolean true if logic ran, false if it didn't |
|
741 | + */ |
|
742 | + protected function _verify_db_collations_for_tables($tables_to_check) |
|
743 | + { |
|
744 | + foreach ($tables_to_check as $table_name) { |
|
745 | + $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
|
746 | + if ( |
|
747 | + ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name) |
|
748 | + && $this->_get_table_analysis()->tableExists($table_name) |
|
749 | + ) { |
|
750 | + maybe_convert_table_to_utf8mb4($table_name); |
|
751 | + } |
|
752 | + } |
|
753 | + } |
|
754 | 754 | } |
@@ -66,8 +66,8 @@ |
||
66 | 66 | { |
67 | 67 | |
68 | 68 | $templates_relative_path = 'modules/gateways/Invoice/lib/templates/'; |
69 | - $overridden_invoice_body = EEH_Template::locate_template($templates_relative_path . 'invoice_body.template.php', null, false, false, true); |
|
70 | - $overridden_receipt_body = EEH_Template::locate_template($templates_relative_path . 'receipt_body.template.php', null, false, false, true); |
|
69 | + $overridden_invoice_body = EEH_Template::locate_template($templates_relative_path.'invoice_body.template.php', null, false, false, true); |
|
70 | + $overridden_receipt_body = EEH_Template::locate_template($templates_relative_path.'receipt_body.template.php', null, false, false, true); |
|
71 | 71 | if ($overridden_invoice_body || $overridden_receipt_body) { |
72 | 72 | new PersistentAdminNotice( |
73 | 73 | 'invoice_overriding_templates', |
@@ -27,59 +27,59 @@ |
||
27 | 27 | */ |
28 | 28 | class EE_DMS_4_6_0_invoice_settings extends EE_Data_Migration_Script_Stage |
29 | 29 | { |
30 | - /** |
|
31 | - * Just initializes the status of the migration |
|
32 | - */ |
|
33 | - public function __construct() |
|
34 | - { |
|
35 | - $this->_pretty_name = esc_html__('Update Invoice Settings', 'event_espresso'); |
|
36 | - parent::__construct(); |
|
37 | - } |
|
30 | + /** |
|
31 | + * Just initializes the status of the migration |
|
32 | + */ |
|
33 | + public function __construct() |
|
34 | + { |
|
35 | + $this->_pretty_name = esc_html__('Update Invoice Settings', 'event_espresso'); |
|
36 | + parent::__construct(); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * _count_records_to_migrate |
|
43 | - * Counts the records to migrate; the public version may cache it |
|
44 | - * |
|
45 | - * @access protected |
|
46 | - * @return int |
|
47 | - */ |
|
48 | - protected function _count_records_to_migrate() |
|
49 | - { |
|
50 | - return 1; |
|
51 | - } |
|
41 | + /** |
|
42 | + * _count_records_to_migrate |
|
43 | + * Counts the records to migrate; the public version may cache it |
|
44 | + * |
|
45 | + * @access protected |
|
46 | + * @return int |
|
47 | + */ |
|
48 | + protected function _count_records_to_migrate() |
|
49 | + { |
|
50 | + return 1; |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * _migration_step |
|
57 | - * |
|
58 | - * @access protected |
|
59 | - * @param int $num_items |
|
60 | - * @throws EE_Error |
|
61 | - * @return int number of items ACTUALLY migrated |
|
62 | - * @throws InvalidDataTypeException |
|
63 | - */ |
|
64 | - protected function _migration_step($num_items = 1) |
|
65 | - { |
|
55 | + /** |
|
56 | + * _migration_step |
|
57 | + * |
|
58 | + * @access protected |
|
59 | + * @param int $num_items |
|
60 | + * @throws EE_Error |
|
61 | + * @return int number of items ACTUALLY migrated |
|
62 | + * @throws InvalidDataTypeException |
|
63 | + */ |
|
64 | + protected function _migration_step($num_items = 1) |
|
65 | + { |
|
66 | 66 | |
67 | - $templates_relative_path = 'modules/gateways/Invoice/lib/templates/'; |
|
68 | - $overridden_invoice_body = EEH_Template::locate_template($templates_relative_path . 'invoice_body.template.php', null, false, false, true); |
|
69 | - $overridden_receipt_body = EEH_Template::locate_template($templates_relative_path . 'receipt_body.template.php', null, false, false, true); |
|
70 | - if ($overridden_invoice_body || $overridden_receipt_body) { |
|
71 | - new PersistentAdminNotice( |
|
72 | - 'invoice_overriding_templates', |
|
73 | - esc_html__( |
|
74 | - 'Note: in this version of Event Espresso, PDF and HTML Invoices and Receipts are now Messages and can be changed just like any other messages; however we noticed you had previously overridden the old default Invoice/Receipt templates. Because of this, your old Invoice/Receipt templates will continue to be used INSTEAD of the new Invoice/Receipt message equivalents (but this will be removed in an upcoming version). We recommend deleting your old Invoice/Receipt templates and using the new messages system. Then modify the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.', |
|
75 | - 'event_espresso' |
|
76 | - ), |
|
77 | - true |
|
78 | - ); |
|
79 | - } |
|
67 | + $templates_relative_path = 'modules/gateways/Invoice/lib/templates/'; |
|
68 | + $overridden_invoice_body = EEH_Template::locate_template($templates_relative_path . 'invoice_body.template.php', null, false, false, true); |
|
69 | + $overridden_receipt_body = EEH_Template::locate_template($templates_relative_path . 'receipt_body.template.php', null, false, false, true); |
|
70 | + if ($overridden_invoice_body || $overridden_receipt_body) { |
|
71 | + new PersistentAdminNotice( |
|
72 | + 'invoice_overriding_templates', |
|
73 | + esc_html__( |
|
74 | + 'Note: in this version of Event Espresso, PDF and HTML Invoices and Receipts are now Messages and can be changed just like any other messages; however we noticed you had previously overridden the old default Invoice/Receipt templates. Because of this, your old Invoice/Receipt templates will continue to be used INSTEAD of the new Invoice/Receipt message equivalents (but this will be removed in an upcoming version). We recommend deleting your old Invoice/Receipt templates and using the new messages system. Then modify the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.', |
|
75 | + 'event_espresso' |
|
76 | + ), |
|
77 | + true |
|
78 | + ); |
|
79 | + } |
|
80 | 80 | |
81 | - // regardless of whether it worked or not, we ought to continue the migration |
|
82 | - $this->set_completed(); |
|
83 | - return 1; |
|
84 | - } |
|
81 | + // regardless of whether it worked or not, we ought to continue the migration |
|
82 | + $this->set_completed(); |
|
83 | + return 1; |
|
84 | + } |
|
85 | 85 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | protected function _generate_restrictions(): array |
20 | 20 | { |
21 | 21 | // if there are no standard caps for this model, then for allow full access |
22 | - if (! $this->model()->cap_slug()) { |
|
22 | + if ( ! $this->model()->cap_slug()) { |
|
23 | 23 | return []; |
24 | 24 | } |
25 | 25 | |
@@ -32,17 +32,17 @@ discard block |
||
32 | 32 | ) |
33 | 33 | ) { |
34 | 34 | if ($this->model() instanceof EEM_CPT_Base) { |
35 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
35 | + $restrictions[EE_Restriction_Generator_Base::get_cap_name( |
|
36 | 36 | $this->model(), |
37 | 37 | $this->action() |
38 | - ) ] = new EE_Default_Where_Conditions( |
|
38 | + )] = new EE_Default_Where_Conditions( |
|
39 | 39 | $this->addPublishedPostConditions() |
40 | 40 | ); |
41 | 41 | } elseif ($this->model() instanceof EEM_Soft_Delete_Base) { |
42 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
42 | + $restrictions[EE_Restriction_Generator_Base::get_cap_name( |
|
43 | 43 | $this->model(), |
44 | 44 | $this->action() |
45 | - ) ] = new EE_Default_Where_Conditions( |
|
45 | + )] = new EE_Default_Where_Conditions( |
|
46 | 46 | [$this->model()->deleted_field_name() => false] |
47 | 47 | ); |
48 | 48 | } |
@@ -52,21 +52,21 @@ discard block |
||
52 | 52 | if ( |
53 | 53 | EE_Restriction_Generator_Base::is_cap( |
54 | 54 | $this->model(), |
55 | - $this->action() . '_others' |
|
55 | + $this->action().'_others' |
|
56 | 56 | ) |
57 | 57 | ) {// both caps exist |
58 | 58 | if ($this->model() instanceof EEM_CPT_Base) { |
59 | 59 | // then if they don't have the others cap, |
60 | 60 | // AT MOST show them their own and other published ones |
61 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
61 | + $restrictions[EE_Restriction_Generator_Base::get_cap_name( |
|
62 | 62 | $this->model(), |
63 | - $this->action() . '_others' |
|
64 | - ) ] = new EE_Default_Where_Conditions( |
|
63 | + $this->action().'_others' |
|
64 | + )] = new EE_Default_Where_Conditions( |
|
65 | 65 | [ |
66 | - 'OR*' . |
|
66 | + 'OR*'. |
|
67 | 67 | EE_Restriction_Generator_Base::get_cap_name( |
68 | 68 | $this->model(), |
69 | - $this->action() . '_others' |
|
69 | + $this->action().'_others' |
|
70 | 70 | ) => $this->addPublishedPostConditions( |
71 | 71 | [ |
72 | 72 | EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
@@ -77,15 +77,15 @@ discard block |
||
77 | 77 | } elseif ($this->model() instanceof EEM_Soft_Delete_Base) { |
78 | 78 | // then if they don't have the other cap, |
79 | 79 | // AT MOST show them their own or non deleted ones |
80 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
80 | + $restrictions[EE_Restriction_Generator_Base::get_cap_name( |
|
81 | 81 | $this->model(), |
82 | - $this->action() . '_others' |
|
83 | - ) ] = new EE_Default_Where_Conditions( |
|
82 | + $this->action().'_others' |
|
83 | + )] = new EE_Default_Where_Conditions( |
|
84 | 84 | [ |
85 | - 'OR*' . |
|
85 | + 'OR*'. |
|
86 | 86 | EE_Restriction_Generator_Base::get_cap_name( |
87 | 87 | $this->model(), |
88 | - $this->action() . '_others' |
|
88 | + $this->action().'_others' |
|
89 | 89 | ) => [ |
90 | 90 | EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
91 | 91 | $this->model()->deleted_field_name( |
@@ -101,20 +101,20 @@ discard block |
||
101 | 101 | if ( |
102 | 102 | EE_Restriction_Generator_Base::is_cap( |
103 | 103 | $this->model(), |
104 | - $this->action() . '_private' |
|
104 | + $this->action().'_private' |
|
105 | 105 | ) && $this->model() instanceof EEM_CPT_Base |
106 | 106 | ) { |
107 | 107 | // if they have basic and others, but not private, |
108 | 108 | // restrict them to see theirs and others' that aren't private |
109 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
109 | + $restrictions[EE_Restriction_Generator_Base::get_cap_name( |
|
110 | 110 | $this->model(), |
111 | - $this->action() . '_private' |
|
112 | - ) ] = new EE_Default_Where_Conditions( |
|
111 | + $this->action().'_private' |
|
112 | + )] = new EE_Default_Where_Conditions( |
|
113 | 113 | [ |
114 | - 'OR*' . |
|
114 | + 'OR*'. |
|
115 | 115 | EE_Restriction_Generator_Base::get_cap_name( |
116 | 116 | $this->model(), |
117 | - $this->action() . '_private' |
|
117 | + $this->action().'_private' |
|
118 | 118 | ) => $this->addPublishedPostConditions( |
119 | 119 | [ |
120 | 120 | EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
@@ -11,123 +11,123 @@ |
||
11 | 11 | */ |
12 | 12 | class EE_Restriction_Generator_Public extends EE_Restriction_Generator_Base |
13 | 13 | { |
14 | - /** |
|
15 | - * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[] |
|
16 | - * @throws EE_Error |
|
17 | - */ |
|
18 | - protected function _generate_restrictions(): array |
|
19 | - { |
|
20 | - // if there are no standard caps for this model, then for allow full access |
|
21 | - if (! $this->model()->cap_slug()) { |
|
22 | - return []; |
|
23 | - } |
|
14 | + /** |
|
15 | + * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[] |
|
16 | + * @throws EE_Error |
|
17 | + */ |
|
18 | + protected function _generate_restrictions(): array |
|
19 | + { |
|
20 | + // if there are no standard caps for this model, then for allow full access |
|
21 | + if (! $this->model()->cap_slug()) { |
|
22 | + return []; |
|
23 | + } |
|
24 | 24 | |
25 | - $restrictions = []; |
|
26 | - // does the basic cap exist? (eg 'ee_read_registrations') |
|
27 | - if ( |
|
28 | - EE_Restriction_Generator_Base::is_cap( |
|
29 | - $this->model(), |
|
30 | - $this->action() |
|
31 | - ) |
|
32 | - ) { |
|
33 | - if ($this->model() instanceof EEM_CPT_Base) { |
|
34 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
35 | - $this->model(), |
|
36 | - $this->action() |
|
37 | - ) ] = new EE_Default_Where_Conditions( |
|
38 | - $this->addPublishedPostConditions() |
|
39 | - ); |
|
40 | - } elseif ($this->model() instanceof EEM_Soft_Delete_Base) { |
|
41 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
42 | - $this->model(), |
|
43 | - $this->action() |
|
44 | - ) ] = new EE_Default_Where_Conditions( |
|
45 | - [$this->model()->deleted_field_name() => false] |
|
46 | - ); |
|
47 | - } |
|
48 | - // don't impose any restrictions if they don't have the basic reading cap |
|
25 | + $restrictions = []; |
|
26 | + // does the basic cap exist? (eg 'ee_read_registrations') |
|
27 | + if ( |
|
28 | + EE_Restriction_Generator_Base::is_cap( |
|
29 | + $this->model(), |
|
30 | + $this->action() |
|
31 | + ) |
|
32 | + ) { |
|
33 | + if ($this->model() instanceof EEM_CPT_Base) { |
|
34 | + $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
35 | + $this->model(), |
|
36 | + $this->action() |
|
37 | + ) ] = new EE_Default_Where_Conditions( |
|
38 | + $this->addPublishedPostConditions() |
|
39 | + ); |
|
40 | + } elseif ($this->model() instanceof EEM_Soft_Delete_Base) { |
|
41 | + $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
42 | + $this->model(), |
|
43 | + $this->action() |
|
44 | + ) ] = new EE_Default_Where_Conditions( |
|
45 | + [$this->model()->deleted_field_name() => false] |
|
46 | + ); |
|
47 | + } |
|
48 | + // don't impose any restrictions if they don't have the basic reading cap |
|
49 | 49 | |
50 | - // does the others cap exist? (eg 'ee_read_others_registrations') |
|
51 | - if ( |
|
52 | - EE_Restriction_Generator_Base::is_cap( |
|
53 | - $this->model(), |
|
54 | - $this->action() . '_others' |
|
55 | - ) |
|
56 | - ) {// both caps exist |
|
57 | - if ($this->model() instanceof EEM_CPT_Base) { |
|
58 | - // then if they don't have the others cap, |
|
59 | - // AT MOST show them their own and other published ones |
|
60 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
61 | - $this->model(), |
|
62 | - $this->action() . '_others' |
|
63 | - ) ] = new EE_Default_Where_Conditions( |
|
64 | - [ |
|
65 | - 'OR*' . |
|
66 | - EE_Restriction_Generator_Base::get_cap_name( |
|
67 | - $this->model(), |
|
68 | - $this->action() . '_others' |
|
69 | - ) => $this->addPublishedPostConditions( |
|
70 | - [ |
|
71 | - EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
72 | - ] |
|
73 | - ), |
|
74 | - ] |
|
75 | - ); |
|
76 | - } elseif ($this->model() instanceof EEM_Soft_Delete_Base) { |
|
77 | - // then if they don't have the other cap, |
|
78 | - // AT MOST show them their own or non deleted ones |
|
79 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
80 | - $this->model(), |
|
81 | - $this->action() . '_others' |
|
82 | - ) ] = new EE_Default_Where_Conditions( |
|
83 | - [ |
|
84 | - 'OR*' . |
|
85 | - EE_Restriction_Generator_Base::get_cap_name( |
|
86 | - $this->model(), |
|
87 | - $this->action() . '_others' |
|
88 | - ) => [ |
|
89 | - EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
90 | - $this->model()->deleted_field_name( |
|
91 | - ) => false, |
|
92 | - ], |
|
93 | - ] |
|
94 | - ); |
|
95 | - } |
|
96 | - // again, if they don't have the others cap, |
|
97 | - // continue showing all because there are no inherently hidden ones |
|
50 | + // does the others cap exist? (eg 'ee_read_others_registrations') |
|
51 | + if ( |
|
52 | + EE_Restriction_Generator_Base::is_cap( |
|
53 | + $this->model(), |
|
54 | + $this->action() . '_others' |
|
55 | + ) |
|
56 | + ) {// both caps exist |
|
57 | + if ($this->model() instanceof EEM_CPT_Base) { |
|
58 | + // then if they don't have the others cap, |
|
59 | + // AT MOST show them their own and other published ones |
|
60 | + $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
61 | + $this->model(), |
|
62 | + $this->action() . '_others' |
|
63 | + ) ] = new EE_Default_Where_Conditions( |
|
64 | + [ |
|
65 | + 'OR*' . |
|
66 | + EE_Restriction_Generator_Base::get_cap_name( |
|
67 | + $this->model(), |
|
68 | + $this->action() . '_others' |
|
69 | + ) => $this->addPublishedPostConditions( |
|
70 | + [ |
|
71 | + EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
72 | + ] |
|
73 | + ), |
|
74 | + ] |
|
75 | + ); |
|
76 | + } elseif ($this->model() instanceof EEM_Soft_Delete_Base) { |
|
77 | + // then if they don't have the other cap, |
|
78 | + // AT MOST show them their own or non deleted ones |
|
79 | + $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
80 | + $this->model(), |
|
81 | + $this->action() . '_others' |
|
82 | + ) ] = new EE_Default_Where_Conditions( |
|
83 | + [ |
|
84 | + 'OR*' . |
|
85 | + EE_Restriction_Generator_Base::get_cap_name( |
|
86 | + $this->model(), |
|
87 | + $this->action() . '_others' |
|
88 | + ) => [ |
|
89 | + EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
90 | + $this->model()->deleted_field_name( |
|
91 | + ) => false, |
|
92 | + ], |
|
93 | + ] |
|
94 | + ); |
|
95 | + } |
|
96 | + // again, if they don't have the others cap, |
|
97 | + // continue showing all because there are no inherently hidden ones |
|
98 | 98 | |
99 | - // does the private cap exist (eg 'ee_read_others_private_events') |
|
100 | - if ( |
|
101 | - EE_Restriction_Generator_Base::is_cap( |
|
102 | - $this->model(), |
|
103 | - $this->action() . '_private' |
|
104 | - ) && $this->model() instanceof EEM_CPT_Base |
|
105 | - ) { |
|
106 | - // if they have basic and others, but not private, |
|
107 | - // restrict them to see theirs and others' that aren't private |
|
108 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
109 | - $this->model(), |
|
110 | - $this->action() . '_private' |
|
111 | - ) ] = new EE_Default_Where_Conditions( |
|
112 | - [ |
|
113 | - 'OR*' . |
|
114 | - EE_Restriction_Generator_Base::get_cap_name( |
|
115 | - $this->model(), |
|
116 | - $this->action() . '_private' |
|
117 | - ) => $this->addPublishedPostConditions( |
|
118 | - [ |
|
119 | - EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
120 | - ], |
|
121 | - false |
|
122 | - ), |
|
123 | - ] |
|
124 | - ); |
|
125 | - } |
|
126 | - } |
|
127 | - } else { |
|
128 | - // there is no basic cap. So allow full access |
|
129 | - $restrictions = []; |
|
130 | - } |
|
131 | - return $restrictions; |
|
132 | - } |
|
99 | + // does the private cap exist (eg 'ee_read_others_private_events') |
|
100 | + if ( |
|
101 | + EE_Restriction_Generator_Base::is_cap( |
|
102 | + $this->model(), |
|
103 | + $this->action() . '_private' |
|
104 | + ) && $this->model() instanceof EEM_CPT_Base |
|
105 | + ) { |
|
106 | + // if they have basic and others, but not private, |
|
107 | + // restrict them to see theirs and others' that aren't private |
|
108 | + $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
109 | + $this->model(), |
|
110 | + $this->action() . '_private' |
|
111 | + ) ] = new EE_Default_Where_Conditions( |
|
112 | + [ |
|
113 | + 'OR*' . |
|
114 | + EE_Restriction_Generator_Base::get_cap_name( |
|
115 | + $this->model(), |
|
116 | + $this->action() . '_private' |
|
117 | + ) => $this->addPublishedPostConditions( |
|
118 | + [ |
|
119 | + EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
120 | + ], |
|
121 | + false |
|
122 | + ), |
|
123 | + ] |
|
124 | + ); |
|
125 | + } |
|
126 | + } |
|
127 | + } else { |
|
128 | + // there is no basic cap. So allow full access |
|
129 | + $restrictions = []; |
|
130 | + } |
|
131 | + return $restrictions; |
|
132 | + } |
|
133 | 133 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | public function __construct(string $default_field_name, string $path_to_event_model) |
44 | 44 | { |
45 | 45 | $this->_default_field_name = $default_field_name; |
46 | - $this->_path_to_event_model = rtrim($path_to_event_model, '.') . '.'; |
|
46 | + $this->_path_to_event_model = rtrim($path_to_event_model, '.').'.'; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | { |
56 | 56 | // if there are no standard caps for this model, then for now |
57 | 57 | // all we know is if they need the default cap to access this |
58 | - if (! $this->model()->cap_slug()) { |
|
58 | + if ( ! $this->model()->cap_slug()) { |
|
59 | 59 | return [ |
60 | 60 | self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions(), |
61 | 61 | ]; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | // if they don't have the "others" default capability, |
84 | 84 | // restrict access to only their default ones, and non-default ones |
85 | 85 | if (EE_Restriction_Generator_Base::is_cap($this->model(), $others_default)) { |
86 | - $restrictions[ $this->getCapKey($this->model(), $others_default) ] = $this->othersDefaultRestrictions( |
|
86 | + $restrictions[$this->getCapKey($this->model(), $others_default)] = $this->othersDefaultRestrictions( |
|
87 | 87 | $others_default |
88 | 88 | ); |
89 | 89 | } |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | [ |
127 | 127 | // if they don't have the others default cap, they can't access others default items |
128 | 128 | // (but they can access their own default items, and non-default items) |
129 | - 'OR*no_' . $this->getCapKey($this->model(), $action) => [ |
|
129 | + 'OR*no_'.$this->getCapKey($this->model(), $action) => [ |
|
130 | 130 | 'AND' => [ |
131 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
131 | + $this->_path_to_event_model.'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
132 | 132 | $this->_default_field_name => true, |
133 | 133 | ], |
134 | 134 | $this->_default_field_name => false, |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | { |
149 | 149 | return new EE_Default_Where_Conditions( |
150 | 150 | [ |
151 | - 'OR*no_' . $this->getCapKey($event_model, $action) => [ |
|
152 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
151 | + 'OR*no_'.$this->getCapKey($event_model, $action) => [ |
|
152 | + $this->_path_to_event_model.'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
153 | 153 | ], |
154 | 154 | $this->_default_field_name => true, |
155 | 155 | ] |
@@ -167,9 +167,9 @@ discard block |
||
167 | 167 | { |
168 | 168 | return new EE_Default_Where_Conditions( |
169 | 169 | [ |
170 | - 'OR*no_' . $this->getCapKey($event_model, $action) => [ |
|
171 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
172 | - $this->_path_to_event_model . 'status' => ['!=', 'private'], |
|
170 | + 'OR*no_'.$this->getCapKey($event_model, $action) => [ |
|
171 | + $this->_path_to_event_model.'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
172 | + $this->_path_to_event_model.'status' => ['!=', 'private'], |
|
173 | 173 | $this->_default_field_name => true, |
174 | 174 | ], |
175 | 175 | ] |
@@ -14,164 +14,164 @@ |
||
14 | 14 | */ |
15 | 15 | class EE_Restriction_Generator_Default_Protected extends EE_Restriction_Generator_Base |
16 | 16 | { |
17 | - /** |
|
18 | - * Name of the field on this model (or a related model, including the model chain to it) |
|
19 | - * that is a boolean indicating whether or not a model object is considered "Default" or not |
|
20 | - * |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - protected $_default_field_name; |
|
24 | - |
|
25 | - /** |
|
26 | - * The model chain to follow to get to the event model, including the event model itself. |
|
27 | - * Eg 'Ticket.Datetime.Event' |
|
28 | - * |
|
29 | - * @var string |
|
30 | - */ |
|
31 | - protected $_path_to_event_model; |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * @param string $default_field_name the name of the field Name of the field on this model |
|
36 | - * (or a related model, including the model chain to it) |
|
37 | - * that is a boolean indicating whether or not a model object |
|
38 | - * is considered "Default" or not |
|
39 | - * @param string $path_to_event_model The model chain to follow to get to the event model, |
|
40 | - * including the event model itself. Eg 'Ticket.Datetime.Event' |
|
41 | - */ |
|
42 | - public function __construct(string $default_field_name, string $path_to_event_model) |
|
43 | - { |
|
44 | - $this->_default_field_name = $default_field_name; |
|
45 | - $this->_path_to_event_model = rtrim($path_to_event_model, '.') . '.'; |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[] |
|
51 | - * @throws EE_Error |
|
52 | - */ |
|
53 | - protected function _generate_restrictions(): array |
|
54 | - { |
|
55 | - // if there are no standard caps for this model, then for now |
|
56 | - // all we know is if they need the default cap to access this |
|
57 | - if (! $this->model()->cap_slug()) { |
|
58 | - return [ |
|
59 | - self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions(), |
|
60 | - ]; |
|
61 | - } |
|
62 | - |
|
63 | - $action = $this->action(); |
|
64 | - $others = "{$action}_others"; |
|
65 | - $private = "{$action}_private"; |
|
66 | - $default = "{$action}_default"; |
|
67 | - $others_default = "{$action}_others_default"; |
|
68 | - $event_model = EEM_Event::instance(); |
|
69 | - |
|
70 | - $restrictions = [ |
|
71 | - // first: access to non-defaults is essentially controlled by which events are accessible |
|
72 | - // if they don't have the basic event cap, they can't access ANY non-default items |
|
73 | - $this->getCapKey($event_model, $action) => $this->nonDefaultRestrictions(true), |
|
74 | - // if they don't have the others event cap, they can't access others' non-default items |
|
75 | - $this->getCapKey($event_model, $others) => $this->othersNonDefaultRestrictions($event_model, $others), |
|
76 | - // if they have basic and others, but not private, they can't access others' private non-default items |
|
77 | - $this->getCapKey($event_model, $private) => $this->privateRestrictions($event_model, $private), |
|
78 | - // second: access to defaults is controlled by the default capabilities |
|
79 | - // if they don't have the default capability, restrict access to only non-default items |
|
80 | - $this->getCapKey($this->model(), $default) => $this->nonDefaultRestrictions(false), |
|
81 | - ]; |
|
82 | - // if they don't have the "others" default capability, |
|
83 | - // restrict access to only their default ones, and non-default ones |
|
84 | - if (EE_Restriction_Generator_Base::is_cap($this->model(), $others_default)) { |
|
85 | - $restrictions[ $this->getCapKey($this->model(), $others_default) ] = $this->othersDefaultRestrictions( |
|
86 | - $others_default |
|
87 | - ); |
|
88 | - } |
|
89 | - return $restrictions; |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * @param EEM_Base $model |
|
95 | - * @param string $action |
|
96 | - * @return string |
|
97 | - * @since $VID:$ |
|
98 | - */ |
|
99 | - private function getCapKey(EEM_Base $model, string $action): string |
|
100 | - { |
|
101 | - return EE_Restriction_Generator_Base::get_cap_name($model, $action); |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * @param bool $use_default_field_name |
|
107 | - * @return EE_Default_Where_Conditions |
|
108 | - * @since $VID:$ |
|
109 | - */ |
|
110 | - private function nonDefaultRestrictions(bool $use_default_field_name): EE_Default_Where_Conditions |
|
111 | - { |
|
112 | - return new EE_Default_Where_Conditions([$this->_default_field_name => $use_default_field_name]); |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * @param string $action |
|
118 | - * @return EE_Default_Where_Conditions |
|
119 | - * @throws EE_Error |
|
120 | - * @since $VID:$ |
|
121 | - */ |
|
122 | - private function othersDefaultRestrictions(string $action): EE_Default_Where_Conditions |
|
123 | - { |
|
124 | - return new EE_Default_Where_Conditions( |
|
125 | - [ |
|
126 | - // if they don't have the others default cap, they can't access others default items |
|
127 | - // (but they can access their own default items, and non-default items) |
|
128 | - 'OR*no_' . $this->getCapKey($this->model(), $action) => [ |
|
129 | - 'AND' => [ |
|
130 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
131 | - $this->_default_field_name => true, |
|
132 | - ], |
|
133 | - $this->_default_field_name => false, |
|
134 | - ], |
|
135 | - ] |
|
136 | - ); |
|
137 | - } |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * @param EEM_Event $event_model |
|
142 | - * @param string $action |
|
143 | - * @return EE_Default_Where_Conditions |
|
144 | - * @since $VID:$ |
|
145 | - */ |
|
146 | - private function othersNonDefaultRestrictions(EEM_Event $event_model, string $action): EE_Default_Where_Conditions |
|
147 | - { |
|
148 | - return new EE_Default_Where_Conditions( |
|
149 | - [ |
|
150 | - 'OR*no_' . $this->getCapKey($event_model, $action) => [ |
|
151 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
152 | - ], |
|
153 | - $this->_default_field_name => true, |
|
154 | - ] |
|
155 | - ); |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - /** |
|
160 | - * @param EEM_Event $event_model |
|
161 | - * @param string $action |
|
162 | - * @return EE_Default_Where_Conditions |
|
163 | - * @since $VID:$ |
|
164 | - */ |
|
165 | - private function privateRestrictions(EEM_Event $event_model, string $action): EE_Default_Where_Conditions |
|
166 | - { |
|
167 | - return new EE_Default_Where_Conditions( |
|
168 | - [ |
|
169 | - 'OR*no_' . $this->getCapKey($event_model, $action) => [ |
|
170 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
171 | - $this->_path_to_event_model . 'status' => ['!=', 'private'], |
|
172 | - $this->_default_field_name => true, |
|
173 | - ], |
|
174 | - ] |
|
175 | - ); |
|
176 | - } |
|
17 | + /** |
|
18 | + * Name of the field on this model (or a related model, including the model chain to it) |
|
19 | + * that is a boolean indicating whether or not a model object is considered "Default" or not |
|
20 | + * |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + protected $_default_field_name; |
|
24 | + |
|
25 | + /** |
|
26 | + * The model chain to follow to get to the event model, including the event model itself. |
|
27 | + * Eg 'Ticket.Datetime.Event' |
|
28 | + * |
|
29 | + * @var string |
|
30 | + */ |
|
31 | + protected $_path_to_event_model; |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * @param string $default_field_name the name of the field Name of the field on this model |
|
36 | + * (or a related model, including the model chain to it) |
|
37 | + * that is a boolean indicating whether or not a model object |
|
38 | + * is considered "Default" or not |
|
39 | + * @param string $path_to_event_model The model chain to follow to get to the event model, |
|
40 | + * including the event model itself. Eg 'Ticket.Datetime.Event' |
|
41 | + */ |
|
42 | + public function __construct(string $default_field_name, string $path_to_event_model) |
|
43 | + { |
|
44 | + $this->_default_field_name = $default_field_name; |
|
45 | + $this->_path_to_event_model = rtrim($path_to_event_model, '.') . '.'; |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[] |
|
51 | + * @throws EE_Error |
|
52 | + */ |
|
53 | + protected function _generate_restrictions(): array |
|
54 | + { |
|
55 | + // if there are no standard caps for this model, then for now |
|
56 | + // all we know is if they need the default cap to access this |
|
57 | + if (! $this->model()->cap_slug()) { |
|
58 | + return [ |
|
59 | + self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions(), |
|
60 | + ]; |
|
61 | + } |
|
62 | + |
|
63 | + $action = $this->action(); |
|
64 | + $others = "{$action}_others"; |
|
65 | + $private = "{$action}_private"; |
|
66 | + $default = "{$action}_default"; |
|
67 | + $others_default = "{$action}_others_default"; |
|
68 | + $event_model = EEM_Event::instance(); |
|
69 | + |
|
70 | + $restrictions = [ |
|
71 | + // first: access to non-defaults is essentially controlled by which events are accessible |
|
72 | + // if they don't have the basic event cap, they can't access ANY non-default items |
|
73 | + $this->getCapKey($event_model, $action) => $this->nonDefaultRestrictions(true), |
|
74 | + // if they don't have the others event cap, they can't access others' non-default items |
|
75 | + $this->getCapKey($event_model, $others) => $this->othersNonDefaultRestrictions($event_model, $others), |
|
76 | + // if they have basic and others, but not private, they can't access others' private non-default items |
|
77 | + $this->getCapKey($event_model, $private) => $this->privateRestrictions($event_model, $private), |
|
78 | + // second: access to defaults is controlled by the default capabilities |
|
79 | + // if they don't have the default capability, restrict access to only non-default items |
|
80 | + $this->getCapKey($this->model(), $default) => $this->nonDefaultRestrictions(false), |
|
81 | + ]; |
|
82 | + // if they don't have the "others" default capability, |
|
83 | + // restrict access to only their default ones, and non-default ones |
|
84 | + if (EE_Restriction_Generator_Base::is_cap($this->model(), $others_default)) { |
|
85 | + $restrictions[ $this->getCapKey($this->model(), $others_default) ] = $this->othersDefaultRestrictions( |
|
86 | + $others_default |
|
87 | + ); |
|
88 | + } |
|
89 | + return $restrictions; |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * @param EEM_Base $model |
|
95 | + * @param string $action |
|
96 | + * @return string |
|
97 | + * @since $VID:$ |
|
98 | + */ |
|
99 | + private function getCapKey(EEM_Base $model, string $action): string |
|
100 | + { |
|
101 | + return EE_Restriction_Generator_Base::get_cap_name($model, $action); |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * @param bool $use_default_field_name |
|
107 | + * @return EE_Default_Where_Conditions |
|
108 | + * @since $VID:$ |
|
109 | + */ |
|
110 | + private function nonDefaultRestrictions(bool $use_default_field_name): EE_Default_Where_Conditions |
|
111 | + { |
|
112 | + return new EE_Default_Where_Conditions([$this->_default_field_name => $use_default_field_name]); |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * @param string $action |
|
118 | + * @return EE_Default_Where_Conditions |
|
119 | + * @throws EE_Error |
|
120 | + * @since $VID:$ |
|
121 | + */ |
|
122 | + private function othersDefaultRestrictions(string $action): EE_Default_Where_Conditions |
|
123 | + { |
|
124 | + return new EE_Default_Where_Conditions( |
|
125 | + [ |
|
126 | + // if they don't have the others default cap, they can't access others default items |
|
127 | + // (but they can access their own default items, and non-default items) |
|
128 | + 'OR*no_' . $this->getCapKey($this->model(), $action) => [ |
|
129 | + 'AND' => [ |
|
130 | + $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
131 | + $this->_default_field_name => true, |
|
132 | + ], |
|
133 | + $this->_default_field_name => false, |
|
134 | + ], |
|
135 | + ] |
|
136 | + ); |
|
137 | + } |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * @param EEM_Event $event_model |
|
142 | + * @param string $action |
|
143 | + * @return EE_Default_Where_Conditions |
|
144 | + * @since $VID:$ |
|
145 | + */ |
|
146 | + private function othersNonDefaultRestrictions(EEM_Event $event_model, string $action): EE_Default_Where_Conditions |
|
147 | + { |
|
148 | + return new EE_Default_Where_Conditions( |
|
149 | + [ |
|
150 | + 'OR*no_' . $this->getCapKey($event_model, $action) => [ |
|
151 | + $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
152 | + ], |
|
153 | + $this->_default_field_name => true, |
|
154 | + ] |
|
155 | + ); |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + /** |
|
160 | + * @param EEM_Event $event_model |
|
161 | + * @param string $action |
|
162 | + * @return EE_Default_Where_Conditions |
|
163 | + * @since $VID:$ |
|
164 | + */ |
|
165 | + private function privateRestrictions(EEM_Event $event_model, string $action): EE_Default_Where_Conditions |
|
166 | + { |
|
167 | + return new EE_Default_Where_Conditions( |
|
168 | + [ |
|
169 | + 'OR*no_' . $this->getCapKey($event_model, $action) => [ |
|
170 | + $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
171 | + $this->_path_to_event_model . 'status' => ['!=', 'private'], |
|
172 | + $this->_default_field_name => true, |
|
173 | + ], |
|
174 | + ] |
|
175 | + ); |
|
176 | + } |
|
177 | 177 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | { |
30 | 30 | // if there are no standard caps for this model, then for now all we know |
31 | 31 | // if they need the default cap to access this |
32 | - if (! $this->model()->cap_slug()) { |
|
32 | + if ( ! $this->model()->cap_slug()) { |
|
33 | 33 | return [ |
34 | 34 | EE_Restriction_Generator_Base::get_default_restrictions_cap( |
35 | 35 | ) => new EE_Return_None_Where_Conditions(), |
@@ -44,22 +44,22 @@ discard block |
||
44 | 44 | $this->action() |
45 | 45 | ) |
46 | 46 | ) { |
47 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
47 | + $restrictions[EE_Restriction_Generator_Base::get_cap_name( |
|
48 | 48 | $this->model(), |
49 | 49 | $this->action() |
50 | - ) ] = new EE_Return_None_Where_Conditions(); |
|
50 | + )] = new EE_Return_None_Where_Conditions(); |
|
51 | 51 | // does the others cap exist? (eg 'ee_read_others_registrations') |
52 | 52 | if ( |
53 | 53 | EE_Restriction_Generator_Base::is_cap( |
54 | 54 | $this->model(), |
55 | - $this->action() . '_others' |
|
55 | + $this->action().'_others' |
|
56 | 56 | ) |
57 | 57 | ) { |
58 | 58 | // both caps exist |
59 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
59 | + $restrictions[EE_Restriction_Generator_Base::get_cap_name( |
|
60 | 60 | $this->model(), |
61 | - $this->action() . '_others' |
|
62 | - ) ] = new EE_Default_Where_Conditions( |
|
61 | + $this->action().'_others' |
|
62 | + )] = new EE_Default_Where_Conditions( |
|
63 | 63 | [ |
64 | 64 | EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
65 | 65 | ] |
@@ -68,20 +68,20 @@ discard block |
||
68 | 68 | if ( |
69 | 69 | EE_Restriction_Generator_Base::is_cap( |
70 | 70 | $this->model(), |
71 | - $this->action() . '_private' |
|
71 | + $this->action().'_private' |
|
72 | 72 | ) && $this->model() instanceof EEM_CPT_Base |
73 | 73 | ) { |
74 | 74 | // if they have basic and others, but not private, |
75 | 75 | // restrict them to see theirs and others' that aren't private |
76 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
76 | + $restrictions[EE_Restriction_Generator_Base::get_cap_name( |
|
77 | 77 | $this->model(), |
78 | - $this->action() . '_private' |
|
79 | - ) ] = new EE_Default_Where_Conditions( |
|
78 | + $this->action().'_private' |
|
79 | + )] = new EE_Default_Where_Conditions( |
|
80 | 80 | [ |
81 | - 'OR*no_' . |
|
81 | + 'OR*no_'. |
|
82 | 82 | EE_Restriction_Generator_Base::get_cap_name( |
83 | 83 | $this->model(), |
84 | - $this->action() . '_private' |
|
84 | + $this->action().'_private' |
|
85 | 85 | ) => [ |
86 | 86 | EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
87 | 87 | 'status' => [ |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | } else { |
97 | 97 | // there is no basic cap. |
98 | 98 | // So they can only access this if they have the default admin cap |
99 | - $restrictions[ EE_Restriction_Generator_Base::get_default_restrictions_cap( |
|
100 | - ) ] = new EE_Return_None_Where_Conditions(); |
|
99 | + $restrictions[EE_Restriction_Generator_Base::get_default_restrictions_cap( |
|
100 | + )] = new EE_Return_None_Where_Conditions(); |
|
101 | 101 | } |
102 | 102 | return $restrictions; |
103 | 103 | } |
@@ -20,84 +20,84 @@ |
||
20 | 20 | */ |
21 | 21 | class EE_Restriction_Generator_Protected extends EE_Restriction_Generator_Base |
22 | 22 | { |
23 | - /** |
|
24 | - * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[] |
|
25 | - * @throws EE_Error |
|
26 | - */ |
|
27 | - protected function _generate_restrictions(): array |
|
28 | - { |
|
29 | - // if there are no standard caps for this model, then for now all we know |
|
30 | - // if they need the default cap to access this |
|
31 | - if (! $this->model()->cap_slug()) { |
|
32 | - return [ |
|
33 | - EE_Restriction_Generator_Base::get_default_restrictions_cap( |
|
34 | - ) => new EE_Return_None_Where_Conditions(), |
|
35 | - ]; |
|
36 | - } |
|
23 | + /** |
|
24 | + * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[] |
|
25 | + * @throws EE_Error |
|
26 | + */ |
|
27 | + protected function _generate_restrictions(): array |
|
28 | + { |
|
29 | + // if there are no standard caps for this model, then for now all we know |
|
30 | + // if they need the default cap to access this |
|
31 | + if (! $this->model()->cap_slug()) { |
|
32 | + return [ |
|
33 | + EE_Restriction_Generator_Base::get_default_restrictions_cap( |
|
34 | + ) => new EE_Return_None_Where_Conditions(), |
|
35 | + ]; |
|
36 | + } |
|
37 | 37 | |
38 | - $restrictions = []; |
|
39 | - // does the basic cap exist? (eg 'ee_read_registrations') |
|
40 | - if ( |
|
41 | - EE_Restriction_Generator_Base::is_cap( |
|
42 | - $this->model(), |
|
43 | - $this->action() |
|
44 | - ) |
|
45 | - ) { |
|
46 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
47 | - $this->model(), |
|
48 | - $this->action() |
|
49 | - ) ] = new EE_Return_None_Where_Conditions(); |
|
50 | - // does the others cap exist? (eg 'ee_read_others_registrations') |
|
51 | - if ( |
|
52 | - EE_Restriction_Generator_Base::is_cap( |
|
53 | - $this->model(), |
|
54 | - $this->action() . '_others' |
|
55 | - ) |
|
56 | - ) { |
|
57 | - // both caps exist |
|
58 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
59 | - $this->model(), |
|
60 | - $this->action() . '_others' |
|
61 | - ) ] = new EE_Default_Where_Conditions( |
|
62 | - [ |
|
63 | - EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
64 | - ] |
|
65 | - ); |
|
66 | - // does the private cap exist (eg 'ee_read_others_private_events') |
|
67 | - if ( |
|
68 | - EE_Restriction_Generator_Base::is_cap( |
|
69 | - $this->model(), |
|
70 | - $this->action() . '_private' |
|
71 | - ) && $this->model() instanceof EEM_CPT_Base |
|
72 | - ) { |
|
73 | - // if they have basic and others, but not private, |
|
74 | - // restrict them to see theirs and others' that aren't private |
|
75 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
76 | - $this->model(), |
|
77 | - $this->action() . '_private' |
|
78 | - ) ] = new EE_Default_Where_Conditions( |
|
79 | - [ |
|
80 | - 'OR*no_' . |
|
81 | - EE_Restriction_Generator_Base::get_cap_name( |
|
82 | - $this->model(), |
|
83 | - $this->action() . '_private' |
|
84 | - ) => [ |
|
85 | - EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
86 | - 'status' => [ |
|
87 | - '!=', |
|
88 | - 'private', |
|
89 | - ], |
|
90 | - ], |
|
91 | - ] |
|
92 | - ); |
|
93 | - } |
|
94 | - } |
|
95 | - } else { |
|
96 | - // there is no basic cap. |
|
97 | - // So they can only access this if they have the default admin cap |
|
98 | - $restrictions[ EE_Restriction_Generator_Base::get_default_restrictions_cap( |
|
99 | - ) ] = new EE_Return_None_Where_Conditions(); |
|
100 | - } |
|
101 | - return $restrictions; |
|
102 | - } |
|
38 | + $restrictions = []; |
|
39 | + // does the basic cap exist? (eg 'ee_read_registrations') |
|
40 | + if ( |
|
41 | + EE_Restriction_Generator_Base::is_cap( |
|
42 | + $this->model(), |
|
43 | + $this->action() |
|
44 | + ) |
|
45 | + ) { |
|
46 | + $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
47 | + $this->model(), |
|
48 | + $this->action() |
|
49 | + ) ] = new EE_Return_None_Where_Conditions(); |
|
50 | + // does the others cap exist? (eg 'ee_read_others_registrations') |
|
51 | + if ( |
|
52 | + EE_Restriction_Generator_Base::is_cap( |
|
53 | + $this->model(), |
|
54 | + $this->action() . '_others' |
|
55 | + ) |
|
56 | + ) { |
|
57 | + // both caps exist |
|
58 | + $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
59 | + $this->model(), |
|
60 | + $this->action() . '_others' |
|
61 | + ) ] = new EE_Default_Where_Conditions( |
|
62 | + [ |
|
63 | + EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
64 | + ] |
|
65 | + ); |
|
66 | + // does the private cap exist (eg 'ee_read_others_private_events') |
|
67 | + if ( |
|
68 | + EE_Restriction_Generator_Base::is_cap( |
|
69 | + $this->model(), |
|
70 | + $this->action() . '_private' |
|
71 | + ) && $this->model() instanceof EEM_CPT_Base |
|
72 | + ) { |
|
73 | + // if they have basic and others, but not private, |
|
74 | + // restrict them to see theirs and others' that aren't private |
|
75 | + $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
76 | + $this->model(), |
|
77 | + $this->action() . '_private' |
|
78 | + ) ] = new EE_Default_Where_Conditions( |
|
79 | + [ |
|
80 | + 'OR*no_' . |
|
81 | + EE_Restriction_Generator_Base::get_cap_name( |
|
82 | + $this->model(), |
|
83 | + $this->action() . '_private' |
|
84 | + ) => [ |
|
85 | + EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
86 | + 'status' => [ |
|
87 | + '!=', |
|
88 | + 'private', |
|
89 | + ], |
|
90 | + ], |
|
91 | + ] |
|
92 | + ); |
|
93 | + } |
|
94 | + } |
|
95 | + } else { |
|
96 | + // there is no basic cap. |
|
97 | + // So they can only access this if they have the default admin cap |
|
98 | + $restrictions[ EE_Restriction_Generator_Base::get_default_restrictions_cap( |
|
99 | + ) ] = new EE_Return_None_Where_Conditions(); |
|
100 | + } |
|
101 | + return $restrictions; |
|
102 | + } |
|
103 | 103 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | { |
49 | 49 | // if there are no standard caps for this model, then for now |
50 | 50 | // all we know is if they need the default cap to access this |
51 | - if (! $this->model()->cap_slug()) { |
|
51 | + if ( ! $this->model()->cap_slug()) { |
|
52 | 52 | return [ |
53 | 53 | EE_Restriction_Generator_Base::get_default_restrictions_cap( |
54 | 54 | ) => new EE_Return_None_Where_Conditions(), |
@@ -61,14 +61,14 @@ discard block |
||
61 | 61 | ) => new EE_Return_None_Where_Conditions(), |
62 | 62 | EE_Restriction_Generator_Base::get_cap_name( |
63 | 63 | $this->model(), |
64 | - $this->action() . '_others' |
|
64 | + $this->action().'_others' |
|
65 | 65 | ) => new EE_Default_Where_Conditions( |
66 | 66 | [ |
67 | 67 | // I need to be the owner, or it must be a global item |
68 | - 'OR*no_' . |
|
68 | + 'OR*no_'. |
|
69 | 69 | EE_Restriction_Generator_Base::get_cap_name( |
70 | 70 | $this->model(), |
71 | - $this->action() . '_others' |
|
71 | + $this->action().'_others' |
|
72 | 72 | ) => [ |
73 | 73 | EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
74 | 74 | $this->_global_field_name => true, |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | ), |
78 | 78 | EE_Restriction_Generator_Base::get_cap_name( |
79 | 79 | $this->model(), |
80 | - $this->action() . '_global' |
|
80 | + $this->action().'_global' |
|
81 | 81 | ) => new EE_Default_Where_Conditions( |
82 | 82 | [ |
83 | 83 | // it mustn't be global |
@@ -19,70 +19,70 @@ |
||
19 | 19 | */ |
20 | 20 | class EE_Restriction_Generator_Global extends EE_Restriction_Generator_Base |
21 | 21 | { |
22 | - /** |
|
23 | - * name of the model field that indicates whether or not a model object is |
|
24 | - * "global" |
|
25 | - * |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - protected $_global_field_name; |
|
22 | + /** |
|
23 | + * name of the model field that indicates whether or not a model object is |
|
24 | + * "global" |
|
25 | + * |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + protected $_global_field_name; |
|
29 | 29 | |
30 | 30 | |
31 | - /** |
|
32 | - * @param string $global_field_name name of the model field that indicates |
|
33 | - * whether or not a model object is |
|
34 | - * "global" |
|
35 | - */ |
|
36 | - public function __construct(string $global_field_name) |
|
37 | - { |
|
38 | - $this->_global_field_name = $global_field_name; |
|
39 | - } |
|
31 | + /** |
|
32 | + * @param string $global_field_name name of the model field that indicates |
|
33 | + * whether or not a model object is |
|
34 | + * "global" |
|
35 | + */ |
|
36 | + public function __construct(string $global_field_name) |
|
37 | + { |
|
38 | + $this->_global_field_name = $global_field_name; |
|
39 | + } |
|
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[] |
|
44 | - * @throws EE_Error |
|
45 | - */ |
|
46 | - protected function _generate_restrictions(): array |
|
47 | - { |
|
48 | - // if there are no standard caps for this model, then for now |
|
49 | - // all we know is if they need the default cap to access this |
|
50 | - if (! $this->model()->cap_slug()) { |
|
51 | - return [ |
|
52 | - EE_Restriction_Generator_Base::get_default_restrictions_cap( |
|
53 | - ) => new EE_Return_None_Where_Conditions(), |
|
54 | - ]; |
|
55 | - } |
|
56 | - return [ |
|
57 | - EE_Restriction_Generator_Base::get_cap_name( |
|
58 | - $this->model(), |
|
59 | - $this->action() |
|
60 | - ) => new EE_Return_None_Where_Conditions(), |
|
61 | - EE_Restriction_Generator_Base::get_cap_name( |
|
62 | - $this->model(), |
|
63 | - $this->action() . '_others' |
|
64 | - ) => new EE_Default_Where_Conditions( |
|
65 | - [ |
|
66 | - // I need to be the owner, or it must be a global item |
|
67 | - 'OR*no_' . |
|
68 | - EE_Restriction_Generator_Base::get_cap_name( |
|
69 | - $this->model(), |
|
70 | - $this->action() . '_others' |
|
71 | - ) => [ |
|
72 | - EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
73 | - $this->_global_field_name => true, |
|
74 | - ], |
|
75 | - ] |
|
76 | - ), |
|
77 | - EE_Restriction_Generator_Base::get_cap_name( |
|
78 | - $this->model(), |
|
79 | - $this->action() . '_global' |
|
80 | - ) => new EE_Default_Where_Conditions( |
|
81 | - [ |
|
82 | - // it mustn't be global |
|
83 | - $this->_global_field_name => false, |
|
84 | - ] |
|
85 | - ), |
|
86 | - ]; |
|
87 | - } |
|
42 | + /** |
|
43 | + * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[] |
|
44 | + * @throws EE_Error |
|
45 | + */ |
|
46 | + protected function _generate_restrictions(): array |
|
47 | + { |
|
48 | + // if there are no standard caps for this model, then for now |
|
49 | + // all we know is if they need the default cap to access this |
|
50 | + if (! $this->model()->cap_slug()) { |
|
51 | + return [ |
|
52 | + EE_Restriction_Generator_Base::get_default_restrictions_cap( |
|
53 | + ) => new EE_Return_None_Where_Conditions(), |
|
54 | + ]; |
|
55 | + } |
|
56 | + return [ |
|
57 | + EE_Restriction_Generator_Base::get_cap_name( |
|
58 | + $this->model(), |
|
59 | + $this->action() |
|
60 | + ) => new EE_Return_None_Where_Conditions(), |
|
61 | + EE_Restriction_Generator_Base::get_cap_name( |
|
62 | + $this->model(), |
|
63 | + $this->action() . '_others' |
|
64 | + ) => new EE_Default_Where_Conditions( |
|
65 | + [ |
|
66 | + // I need to be the owner, or it must be a global item |
|
67 | + 'OR*no_' . |
|
68 | + EE_Restriction_Generator_Base::get_cap_name( |
|
69 | + $this->model(), |
|
70 | + $this->action() . '_others' |
|
71 | + ) => [ |
|
72 | + EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
73 | + $this->_global_field_name => true, |
|
74 | + ], |
|
75 | + ] |
|
76 | + ), |
|
77 | + EE_Restriction_Generator_Base::get_cap_name( |
|
78 | + $this->model(), |
|
79 | + $this->action() . '_global' |
|
80 | + ) => new EE_Default_Where_Conditions( |
|
81 | + [ |
|
82 | + // it mustn't be global |
|
83 | + $this->_global_field_name => false, |
|
84 | + ] |
|
85 | + ), |
|
86 | + ]; |
|
87 | + } |
|
88 | 88 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | { |
45 | 45 | // if there are no standard caps for this model, then for now |
46 | 46 | // all we know if they need the default cap to access this |
47 | - if (! $this->model()->cap_slug()) { |
|
47 | + if ( ! $this->model()->cap_slug()) { |
|
48 | 48 | return [ |
49 | 49 | self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions(), |
50 | 50 | ]; |
@@ -67,15 +67,15 @@ discard block |
||
67 | 67 | // they can't access others' non-default items |
68 | 68 | self::get_cap_name( |
69 | 69 | $event_model, |
70 | - $this->action() . '_others' |
|
70 | + $this->action().'_others' |
|
71 | 71 | ) => new EE_Default_Where_Conditions( |
72 | 72 | [ |
73 | - 'OR*' . self::get_cap_name( |
|
73 | + 'OR*'.self::get_cap_name( |
|
74 | 74 | $event_model, |
75 | - $this->action() . '_others' |
|
75 | + $this->action().'_others' |
|
76 | 76 | ) => $this->addPublishedPostConditions( |
77 | 77 | [ |
78 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
78 | + $this->_path_to_event_model.'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
79 | 79 | ], |
80 | 80 | true, |
81 | 81 | $this->_path_to_event_model |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | ), |
85 | 85 | // if they have basic and others, but not private, |
86 | 86 | // they can't access others' private non-default items |
87 | - self::get_cap_name($event_model, $this->action() . '_private') => new EE_Default_Where_Conditions( |
|
87 | + self::get_cap_name($event_model, $this->action().'_private') => new EE_Default_Where_Conditions( |
|
88 | 88 | [ |
89 | - 'OR*no_' . self::get_cap_name( |
|
89 | + 'OR*no_'.self::get_cap_name( |
|
90 | 90 | $event_model, |
91 | - $this->action() . '_private' |
|
91 | + $this->action().'_private' |
|
92 | 92 | ) => $this->addPublishedPostConditions( |
93 | 93 | [ |
94 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
94 | + $this->_path_to_event_model.'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
95 | 95 | ], |
96 | 96 | false, |
97 | 97 | $this->_path_to_event_model |
@@ -13,90 +13,90 @@ |
||
13 | 13 | */ |
14 | 14 | class EE_Restriction_Generator_Event_Related_Public extends EE_Restriction_Generator_Base |
15 | 15 | { |
16 | - /** |
|
17 | - * Path to the event model from the model this restriction generator will |
|
18 | - * be applied to; including the event model itself. Eg |
|
19 | - * "Ticket.Datetime.Event" |
|
20 | - * |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - protected $_path_to_event_model; |
|
16 | + /** |
|
17 | + * Path to the event model from the model this restriction generator will |
|
18 | + * be applied to; including the event model itself. Eg |
|
19 | + * "Ticket.Datetime.Event" |
|
20 | + * |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + protected $_path_to_event_model; |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * @param string $path_to_event_model |
|
28 | - */ |
|
29 | - public function __construct(string $path_to_event_model) |
|
30 | - { |
|
31 | - if (substr($path_to_event_model, -1, 1) != '.') { |
|
32 | - $path_to_event_model .= '.'; |
|
33 | - } |
|
34 | - $this->_path_to_event_model = $path_to_event_model; |
|
35 | - } |
|
26 | + /** |
|
27 | + * @param string $path_to_event_model |
|
28 | + */ |
|
29 | + public function __construct(string $path_to_event_model) |
|
30 | + { |
|
31 | + if (substr($path_to_event_model, -1, 1) != '.') { |
|
32 | + $path_to_event_model .= '.'; |
|
33 | + } |
|
34 | + $this->_path_to_event_model = $path_to_event_model; |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[] |
|
40 | - * @throws EE_Error |
|
41 | - */ |
|
42 | - protected function _generate_restrictions(): array |
|
43 | - { |
|
44 | - // if there are no standard caps for this model, then for now |
|
45 | - // all we know if they need the default cap to access this |
|
46 | - if (! $this->model()->cap_slug()) { |
|
47 | - return [ |
|
48 | - self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions(), |
|
49 | - ]; |
|
50 | - } |
|
38 | + /** |
|
39 | + * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[] |
|
40 | + * @throws EE_Error |
|
41 | + */ |
|
42 | + protected function _generate_restrictions(): array |
|
43 | + { |
|
44 | + // if there are no standard caps for this model, then for now |
|
45 | + // all we know if they need the default cap to access this |
|
46 | + if (! $this->model()->cap_slug()) { |
|
47 | + return [ |
|
48 | + self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions(), |
|
49 | + ]; |
|
50 | + } |
|
51 | 51 | |
52 | - $event_model = EEM_Event::instance(); |
|
53 | - return [ |
|
54 | - // first: basically access to non-defaults is essentially |
|
55 | - // controlled by which events are accessible |
|
56 | - // if they don't have the basic event cap, |
|
57 | - // they can only read things for published events |
|
58 | - self::get_cap_name($event_model, $this->action()) => new EE_Default_Where_Conditions( |
|
59 | - $this->addPublishedPostConditions( |
|
60 | - [], |
|
61 | - true, |
|
62 | - $this->_path_to_event_model |
|
63 | - ) |
|
64 | - ), |
|
65 | - // if they don't have the others event cap, |
|
66 | - // they can't access others' non-default items |
|
67 | - self::get_cap_name( |
|
68 | - $event_model, |
|
69 | - $this->action() . '_others' |
|
70 | - ) => new EE_Default_Where_Conditions( |
|
71 | - [ |
|
72 | - 'OR*' . self::get_cap_name( |
|
73 | - $event_model, |
|
74 | - $this->action() . '_others' |
|
75 | - ) => $this->addPublishedPostConditions( |
|
76 | - [ |
|
77 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
78 | - ], |
|
79 | - true, |
|
80 | - $this->_path_to_event_model |
|
81 | - ), |
|
82 | - ] |
|
83 | - ), |
|
84 | - // if they have basic and others, but not private, |
|
85 | - // they can't access others' private non-default items |
|
86 | - self::get_cap_name($event_model, $this->action() . '_private') => new EE_Default_Where_Conditions( |
|
87 | - [ |
|
88 | - 'OR*no_' . self::get_cap_name( |
|
89 | - $event_model, |
|
90 | - $this->action() . '_private' |
|
91 | - ) => $this->addPublishedPostConditions( |
|
92 | - [ |
|
93 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
94 | - ], |
|
95 | - false, |
|
96 | - $this->_path_to_event_model |
|
97 | - ), |
|
98 | - ] |
|
99 | - ), |
|
100 | - ]; |
|
101 | - } |
|
52 | + $event_model = EEM_Event::instance(); |
|
53 | + return [ |
|
54 | + // first: basically access to non-defaults is essentially |
|
55 | + // controlled by which events are accessible |
|
56 | + // if they don't have the basic event cap, |
|
57 | + // they can only read things for published events |
|
58 | + self::get_cap_name($event_model, $this->action()) => new EE_Default_Where_Conditions( |
|
59 | + $this->addPublishedPostConditions( |
|
60 | + [], |
|
61 | + true, |
|
62 | + $this->_path_to_event_model |
|
63 | + ) |
|
64 | + ), |
|
65 | + // if they don't have the others event cap, |
|
66 | + // they can't access others' non-default items |
|
67 | + self::get_cap_name( |
|
68 | + $event_model, |
|
69 | + $this->action() . '_others' |
|
70 | + ) => new EE_Default_Where_Conditions( |
|
71 | + [ |
|
72 | + 'OR*' . self::get_cap_name( |
|
73 | + $event_model, |
|
74 | + $this->action() . '_others' |
|
75 | + ) => $this->addPublishedPostConditions( |
|
76 | + [ |
|
77 | + $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
78 | + ], |
|
79 | + true, |
|
80 | + $this->_path_to_event_model |
|
81 | + ), |
|
82 | + ] |
|
83 | + ), |
|
84 | + // if they have basic and others, but not private, |
|
85 | + // they can't access others' private non-default items |
|
86 | + self::get_cap_name($event_model, $this->action() . '_private') => new EE_Default_Where_Conditions( |
|
87 | + [ |
|
88 | + 'OR*no_' . self::get_cap_name( |
|
89 | + $event_model, |
|
90 | + $this->action() . '_private' |
|
91 | + ) => $this->addPublishedPostConditions( |
|
92 | + [ |
|
93 | + $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
94 | + ], |
|
95 | + false, |
|
96 | + $this->_path_to_event_model |
|
97 | + ), |
|
98 | + ] |
|
99 | + ), |
|
100 | + ]; |
|
101 | + } |
|
102 | 102 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | { |
64 | 64 | // if there are no standard caps for this model, then for now all we know |
65 | 65 | // if they need the default cap to access this |
66 | - if (! $this->model()->cap_slug()) { |
|
66 | + if ( ! $this->model()->cap_slug()) { |
|
67 | 67 | return [ |
68 | 68 | self::get_default_restrictions_cap( |
69 | 69 | ) => new EE_Return_None_Where_Conditions(), |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $this->action() |
83 | 83 | ) => new EE_Default_Where_Conditions( |
84 | 84 | [ |
85 | - 'OR*no_' . |
|
85 | + 'OR*no_'. |
|
86 | 86 | EE_Restriction_Generator_Base::get_cap_name( |
87 | 87 | $event_model, |
88 | 88 | $this->action() |
@@ -100,16 +100,16 @@ discard block |
||
100 | 100 | // others' that are for published events, or defaults |
101 | 101 | EE_Restriction_Generator_Base::get_cap_name( |
102 | 102 | $event_model, |
103 | - $this->action() . '_others' |
|
103 | + $this->action().'_others' |
|
104 | 104 | ) => new EE_Default_Where_Conditions( |
105 | 105 | [ |
106 | - 'OR*no_' . |
|
106 | + 'OR*no_'. |
|
107 | 107 | EE_Restriction_Generator_Base::get_cap_name( |
108 | 108 | $event_model, |
109 | - $this->action() . '_others' |
|
109 | + $this->action().'_others' |
|
110 | 110 | ) => $this->addPublishedPostConditions( |
111 | 111 | [ |
112 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
112 | + $this->_path_to_event_model.'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
113 | 113 | $this->_default_field_name => true, |
114 | 114 | ], |
115 | 115 | true, |
@@ -122,16 +122,16 @@ discard block |
||
122 | 122 | // and others' that aren't private |
123 | 123 | EE_Restriction_Generator_Base::get_cap_name( |
124 | 124 | $event_model, |
125 | - $this->action() . '_private' |
|
125 | + $this->action().'_private' |
|
126 | 126 | ) => new EE_Default_Where_Conditions( |
127 | 127 | [ |
128 | - 'OR*no_' . |
|
128 | + 'OR*no_'. |
|
129 | 129 | EE_Restriction_Generator_Base::get_cap_name( |
130 | 130 | $event_model, |
131 | - $this->action() . '_private' |
|
131 | + $this->action().'_private' |
|
132 | 132 | ) => $this->addPublishedPostConditions( |
133 | 133 | [ |
134 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
134 | + $this->_path_to_event_model.'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
135 | 135 | $this->_default_field_name => true, |
136 | 136 | ], |
137 | 137 | false, |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | // restrict access to only non-default items |
146 | 146 | EE_Restriction_Generator_Base::get_cap_name( |
147 | 147 | $this->model(), |
148 | - $this->action() . '_default' |
|
148 | + $this->action().'_default' |
|
149 | 149 | ) => new EE_Default_Where_Conditions( |
150 | 150 | [$this->_default_field_name => false] |
151 | 151 | ), |
@@ -153,24 +153,24 @@ discard block |
||
153 | 153 | if ( |
154 | 154 | EE_Restriction_Generator_Base::is_cap( |
155 | 155 | $this->model(), |
156 | - $this->action() . '_others_default' |
|
156 | + $this->action().'_others_default' |
|
157 | 157 | ) |
158 | 158 | ) { |
159 | 159 | // if they don't have the "others" default capability, |
160 | 160 | // restrict access to only their default ones, and non-default ones |
161 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
161 | + $restrictions[EE_Restriction_Generator_Base::get_cap_name( |
|
162 | 162 | $this->model(), |
163 | - $this->action() . '_others_default' |
|
164 | - ) ] = new EE_Default_Where_Conditions( |
|
163 | + $this->action().'_others_default' |
|
164 | + )] = new EE_Default_Where_Conditions( |
|
165 | 165 | [ |
166 | 166 | // if they don't have the others default cap, |
167 | 167 | // they can't access others default items |
168 | 168 | // (but they can access their own default items, |
169 | 169 | // and non-default items) |
170 | - 'OR*no_' . |
|
170 | + 'OR*no_'. |
|
171 | 171 | EE_Restriction_Generator_Base::get_cap_name( |
172 | 172 | $this->model(), |
173 | - $this->action() . '_others_default' |
|
173 | + $this->action().'_others_default' |
|
174 | 174 | ) => [ |
175 | 175 | 'AND' => [ |
176 | 176 | EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
@@ -14,172 +14,172 @@ |
||
14 | 14 | */ |
15 | 15 | class EE_Restriction_Generator_Default_Public extends EE_Restriction_Generator_Base |
16 | 16 | { |
17 | - /** |
|
18 | - * Name of the field on this model (or a related model, including the model |
|
19 | - * chain to it) that is a boolean indicating whether or not a model object |
|
20 | - * is considered "Default" or not |
|
21 | - * |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - protected $_default_field_name; |
|
17 | + /** |
|
18 | + * Name of the field on this model (or a related model, including the model |
|
19 | + * chain to it) that is a boolean indicating whether or not a model object |
|
20 | + * is considered "Default" or not |
|
21 | + * |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + protected $_default_field_name; |
|
25 | 25 | |
26 | - /** |
|
27 | - * The model chain to follow to get to the event model, including the event |
|
28 | - * model itself. Eg 'Ticket.Datetime.Event' |
|
29 | - * |
|
30 | - * @var string |
|
31 | - */ |
|
32 | - protected $_path_to_event_model; |
|
26 | + /** |
|
27 | + * The model chain to follow to get to the event model, including the event |
|
28 | + * model itself. Eg 'Ticket.Datetime.Event' |
|
29 | + * |
|
30 | + * @var string |
|
31 | + */ |
|
32 | + protected $_path_to_event_model; |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * @param string $default_field_name the name of the field Name of the |
|
37 | - * field on this model (or a related |
|
38 | - * model, including the model chain to |
|
39 | - * it) that is a boolean indicating |
|
40 | - * whether or not a model object is |
|
41 | - * considered "Default" or not |
|
42 | - * @param string $path_to_event_model The model chain to follow to get to |
|
43 | - * the event model, including the event |
|
44 | - * model itself. Eg |
|
45 | - * 'Ticket.Datetime.Event' |
|
46 | - */ |
|
47 | - public function __construct(string $default_field_name, string $path_to_event_model) |
|
48 | - { |
|
49 | - $this->_default_field_name = $default_field_name; |
|
50 | - if (substr($path_to_event_model, -1, 1) != '.') { |
|
51 | - $path_to_event_model .= '.'; |
|
52 | - } |
|
53 | - $this->_path_to_event_model = $path_to_event_model; |
|
54 | - } |
|
35 | + /** |
|
36 | + * @param string $default_field_name the name of the field Name of the |
|
37 | + * field on this model (or a related |
|
38 | + * model, including the model chain to |
|
39 | + * it) that is a boolean indicating |
|
40 | + * whether or not a model object is |
|
41 | + * considered "Default" or not |
|
42 | + * @param string $path_to_event_model The model chain to follow to get to |
|
43 | + * the event model, including the event |
|
44 | + * model itself. Eg |
|
45 | + * 'Ticket.Datetime.Event' |
|
46 | + */ |
|
47 | + public function __construct(string $default_field_name, string $path_to_event_model) |
|
48 | + { |
|
49 | + $this->_default_field_name = $default_field_name; |
|
50 | + if (substr($path_to_event_model, -1, 1) != '.') { |
|
51 | + $path_to_event_model .= '.'; |
|
52 | + } |
|
53 | + $this->_path_to_event_model = $path_to_event_model; |
|
54 | + } |
|
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[] |
|
59 | - * @throws EE_Error |
|
60 | - */ |
|
61 | - protected function _generate_restrictions(): array |
|
62 | - { |
|
63 | - // if there are no standard caps for this model, then for now all we know |
|
64 | - // if they need the default cap to access this |
|
65 | - if (! $this->model()->cap_slug()) { |
|
66 | - return [ |
|
67 | - self::get_default_restrictions_cap( |
|
68 | - ) => new EE_Return_None_Where_Conditions(), |
|
69 | - ]; |
|
70 | - } |
|
57 | + /** |
|
58 | + * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[] |
|
59 | + * @throws EE_Error |
|
60 | + */ |
|
61 | + protected function _generate_restrictions(): array |
|
62 | + { |
|
63 | + // if there are no standard caps for this model, then for now all we know |
|
64 | + // if they need the default cap to access this |
|
65 | + if (! $this->model()->cap_slug()) { |
|
66 | + return [ |
|
67 | + self::get_default_restrictions_cap( |
|
68 | + ) => new EE_Return_None_Where_Conditions(), |
|
69 | + ]; |
|
70 | + } |
|
71 | 71 | |
72 | - $event_model = EEM_Event::instance(); |
|
72 | + $event_model = EEM_Event::instance(); |
|
73 | 73 | |
74 | - $restrictions = [ |
|
75 | - // first: basically access to non-defaults is essentially |
|
76 | - // controlled by which events are accessible |
|
77 | - // if they don't have the basic event cap, |
|
78 | - // they can't access ANY non-default items |
|
79 | - EE_Restriction_Generator_Base::get_cap_name( |
|
80 | - $event_model, |
|
81 | - $this->action() |
|
82 | - ) => new EE_Default_Where_Conditions( |
|
83 | - [ |
|
84 | - 'OR*no_' . |
|
85 | - EE_Restriction_Generator_Base::get_cap_name( |
|
86 | - $event_model, |
|
87 | - $this->action() |
|
88 | - ) => $this->addPublishedPostConditions( |
|
89 | - [ |
|
90 | - $this->_default_field_name => true, |
|
91 | - ], |
|
92 | - true, |
|
93 | - $this->_path_to_event_model |
|
94 | - ), |
|
95 | - ] |
|
96 | - ), |
|
97 | - // if they don't have the others event cap, |
|
98 | - // they can only access their own, |
|
99 | - // others' that are for published events, or defaults |
|
100 | - EE_Restriction_Generator_Base::get_cap_name( |
|
101 | - $event_model, |
|
102 | - $this->action() . '_others' |
|
103 | - ) => new EE_Default_Where_Conditions( |
|
104 | - [ |
|
105 | - 'OR*no_' . |
|
106 | - EE_Restriction_Generator_Base::get_cap_name( |
|
107 | - $event_model, |
|
108 | - $this->action() . '_others' |
|
109 | - ) => $this->addPublishedPostConditions( |
|
110 | - [ |
|
111 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
112 | - $this->_default_field_name => true, |
|
113 | - ], |
|
114 | - true, |
|
115 | - $this->_path_to_event_model |
|
116 | - ), |
|
117 | - ] |
|
118 | - ), |
|
119 | - // if they have basic and others, but not private, |
|
120 | - // they can access default, their own, |
|
121 | - // and others' that aren't private |
|
122 | - EE_Restriction_Generator_Base::get_cap_name( |
|
123 | - $event_model, |
|
124 | - $this->action() . '_private' |
|
125 | - ) => new EE_Default_Where_Conditions( |
|
126 | - [ |
|
127 | - 'OR*no_' . |
|
128 | - EE_Restriction_Generator_Base::get_cap_name( |
|
129 | - $event_model, |
|
130 | - $this->action() . '_private' |
|
131 | - ) => $this->addPublishedPostConditions( |
|
132 | - [ |
|
133 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
134 | - $this->_default_field_name => true, |
|
135 | - ], |
|
136 | - false, |
|
137 | - $this->_path_to_event_model |
|
138 | - ), |
|
139 | - ] |
|
140 | - ), |
|
141 | - // second: access to defaults is controlled |
|
142 | - // by the default capabilities |
|
143 | - // if they don't have the basic default capability, |
|
144 | - // restrict access to only non-default items |
|
145 | - EE_Restriction_Generator_Base::get_cap_name( |
|
146 | - $this->model(), |
|
147 | - $this->action() . '_default' |
|
148 | - ) => new EE_Default_Where_Conditions( |
|
149 | - [$this->_default_field_name => false] |
|
150 | - ), |
|
151 | - ]; |
|
152 | - if ( |
|
153 | - EE_Restriction_Generator_Base::is_cap( |
|
154 | - $this->model(), |
|
155 | - $this->action() . '_others_default' |
|
156 | - ) |
|
157 | - ) { |
|
158 | - // if they don't have the "others" default capability, |
|
159 | - // restrict access to only their default ones, and non-default ones |
|
160 | - $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
161 | - $this->model(), |
|
162 | - $this->action() . '_others_default' |
|
163 | - ) ] = new EE_Default_Where_Conditions( |
|
164 | - [ |
|
165 | - // if they don't have the others default cap, |
|
166 | - // they can't access others default items |
|
167 | - // (but they can access their own default items, |
|
168 | - // and non-default items) |
|
169 | - 'OR*no_' . |
|
170 | - EE_Restriction_Generator_Base::get_cap_name( |
|
171 | - $this->model(), |
|
172 | - $this->action() . '_others_default' |
|
173 | - ) => [ |
|
174 | - 'AND' => [ |
|
175 | - EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
176 | - $this->_default_field_name => true |
|
177 | - ], |
|
178 | - $this->_default_field_name => false |
|
179 | - ] |
|
180 | - ] |
|
181 | - ); |
|
182 | - } |
|
183 | - return $restrictions; |
|
184 | - } |
|
74 | + $restrictions = [ |
|
75 | + // first: basically access to non-defaults is essentially |
|
76 | + // controlled by which events are accessible |
|
77 | + // if they don't have the basic event cap, |
|
78 | + // they can't access ANY non-default items |
|
79 | + EE_Restriction_Generator_Base::get_cap_name( |
|
80 | + $event_model, |
|
81 | + $this->action() |
|
82 | + ) => new EE_Default_Where_Conditions( |
|
83 | + [ |
|
84 | + 'OR*no_' . |
|
85 | + EE_Restriction_Generator_Base::get_cap_name( |
|
86 | + $event_model, |
|
87 | + $this->action() |
|
88 | + ) => $this->addPublishedPostConditions( |
|
89 | + [ |
|
90 | + $this->_default_field_name => true, |
|
91 | + ], |
|
92 | + true, |
|
93 | + $this->_path_to_event_model |
|
94 | + ), |
|
95 | + ] |
|
96 | + ), |
|
97 | + // if they don't have the others event cap, |
|
98 | + // they can only access their own, |
|
99 | + // others' that are for published events, or defaults |
|
100 | + EE_Restriction_Generator_Base::get_cap_name( |
|
101 | + $event_model, |
|
102 | + $this->action() . '_others' |
|
103 | + ) => new EE_Default_Where_Conditions( |
|
104 | + [ |
|
105 | + 'OR*no_' . |
|
106 | + EE_Restriction_Generator_Base::get_cap_name( |
|
107 | + $event_model, |
|
108 | + $this->action() . '_others' |
|
109 | + ) => $this->addPublishedPostConditions( |
|
110 | + [ |
|
111 | + $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
112 | + $this->_default_field_name => true, |
|
113 | + ], |
|
114 | + true, |
|
115 | + $this->_path_to_event_model |
|
116 | + ), |
|
117 | + ] |
|
118 | + ), |
|
119 | + // if they have basic and others, but not private, |
|
120 | + // they can access default, their own, |
|
121 | + // and others' that aren't private |
|
122 | + EE_Restriction_Generator_Base::get_cap_name( |
|
123 | + $event_model, |
|
124 | + $this->action() . '_private' |
|
125 | + ) => new EE_Default_Where_Conditions( |
|
126 | + [ |
|
127 | + 'OR*no_' . |
|
128 | + EE_Restriction_Generator_Base::get_cap_name( |
|
129 | + $event_model, |
|
130 | + $this->action() . '_private' |
|
131 | + ) => $this->addPublishedPostConditions( |
|
132 | + [ |
|
133 | + $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
134 | + $this->_default_field_name => true, |
|
135 | + ], |
|
136 | + false, |
|
137 | + $this->_path_to_event_model |
|
138 | + ), |
|
139 | + ] |
|
140 | + ), |
|
141 | + // second: access to defaults is controlled |
|
142 | + // by the default capabilities |
|
143 | + // if they don't have the basic default capability, |
|
144 | + // restrict access to only non-default items |
|
145 | + EE_Restriction_Generator_Base::get_cap_name( |
|
146 | + $this->model(), |
|
147 | + $this->action() . '_default' |
|
148 | + ) => new EE_Default_Where_Conditions( |
|
149 | + [$this->_default_field_name => false] |
|
150 | + ), |
|
151 | + ]; |
|
152 | + if ( |
|
153 | + EE_Restriction_Generator_Base::is_cap( |
|
154 | + $this->model(), |
|
155 | + $this->action() . '_others_default' |
|
156 | + ) |
|
157 | + ) { |
|
158 | + // if they don't have the "others" default capability, |
|
159 | + // restrict access to only their default ones, and non-default ones |
|
160 | + $restrictions[ EE_Restriction_Generator_Base::get_cap_name( |
|
161 | + $this->model(), |
|
162 | + $this->action() . '_others_default' |
|
163 | + ) ] = new EE_Default_Where_Conditions( |
|
164 | + [ |
|
165 | + // if they don't have the others default cap, |
|
166 | + // they can't access others default items |
|
167 | + // (but they can access their own default items, |
|
168 | + // and non-default items) |
|
169 | + 'OR*no_' . |
|
170 | + EE_Restriction_Generator_Base::get_cap_name( |
|
171 | + $this->model(), |
|
172 | + $this->action() . '_others_default' |
|
173 | + ) => [ |
|
174 | + 'AND' => [ |
|
175 | + EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
176 | + $this->_default_field_name => true |
|
177 | + ], |
|
178 | + $this->_default_field_name => false |
|
179 | + ] |
|
180 | + ] |
|
181 | + ); |
|
182 | + } |
|
183 | + return $restrictions; |
|
184 | + } |
|
185 | 185 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | { |
90 | 90 | // if there are no standard caps for this model, then for now |
91 | 91 | // all we know if they need the default cap to access this |
92 | - if (! $this->model()->cap_slug()) { |
|
92 | + if ( ! $this->model()->cap_slug()) { |
|
93 | 93 | return [ |
94 | 94 | self::get_default_restrictions_cap( |
95 | 95 | ) => new EE_Return_None_Where_Conditions(), |
@@ -110,26 +110,26 @@ discard block |
||
110 | 110 | // they can't access others' non-default items |
111 | 111 | EE_Restriction_Generator_Base::get_cap_name( |
112 | 112 | $event_model, |
113 | - $this->action_for_event() . '_others' |
|
113 | + $this->action_for_event().'_others' |
|
114 | 114 | ) => new EE_Default_Where_Conditions( |
115 | 115 | [ |
116 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
116 | + $this->_path_to_event_model.'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
117 | 117 | ] |
118 | 118 | ), |
119 | 119 | // if they have basic and others, but not private, |
120 | 120 | // they can't access others' private non-default items |
121 | 121 | EE_Restriction_Generator_Base::get_cap_name( |
122 | 122 | $event_model, |
123 | - $this->action_for_event() . '_private' |
|
123 | + $this->action_for_event().'_private' |
|
124 | 124 | ) => new EE_Default_Where_Conditions( |
125 | 125 | [ |
126 | - 'OR*no_' . |
|
126 | + 'OR*no_'. |
|
127 | 127 | EE_Restriction_Generator_Base::get_cap_name( |
128 | 128 | $event_model, |
129 | - $this->action_for_event() . '_private' |
|
129 | + $this->action_for_event().'_private' |
|
130 | 130 | ) => $this->addPublishedPostConditions( |
131 | 131 | [ |
132 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
132 | + $this->_path_to_event_model.'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
133 | 133 | ], |
134 | 134 | false, |
135 | 135 | $this->_path_to_event_model |
@@ -13,128 +13,128 @@ |
||
13 | 13 | */ |
14 | 14 | class EE_Restriction_Generator_Event_Related_Protected extends EE_Restriction_Generator_Base |
15 | 15 | { |
16 | - /** |
|
17 | - * Path to the event model from the model this restriction generator will |
|
18 | - * be applied to; including the event model itself. Eg |
|
19 | - * "Ticket.Datetime.Event" |
|
20 | - * |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - protected $_path_to_event_model = null; |
|
16 | + /** |
|
17 | + * Path to the event model from the model this restriction generator will |
|
18 | + * be applied to; including the event model itself. Eg |
|
19 | + * "Ticket.Datetime.Event" |
|
20 | + * |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + protected $_path_to_event_model = null; |
|
24 | 24 | |
25 | - /** |
|
26 | - * Capability context on event model when creating restrictions. |
|
27 | - * Eg, although we may want capability restrictions relating to deleting |
|
28 | - * datetimes, they don't need to be able to DELETE EVENTS, they just need |
|
29 | - * to be able to EDIT EVENTS in order to DELETE DATETIMES. |
|
30 | - * |
|
31 | - * @var string one of EEM_Base::valid_cap_contexts() |
|
32 | - */ |
|
33 | - protected $_cap_context_on_event_model = null; |
|
25 | + /** |
|
26 | + * Capability context on event model when creating restrictions. |
|
27 | + * Eg, although we may want capability restrictions relating to deleting |
|
28 | + * datetimes, they don't need to be able to DELETE EVENTS, they just need |
|
29 | + * to be able to EDIT EVENTS in order to DELETE DATETIMES. |
|
30 | + * |
|
31 | + * @var string one of EEM_Base::valid_cap_contexts() |
|
32 | + */ |
|
33 | + protected $_cap_context_on_event_model = null; |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * @param string $path_to_event_model |
|
38 | - * @param string $cap_context_on_event_model capability context on event |
|
39 | - * model when creating |
|
40 | - * restrictions. Eg, although we |
|
41 | - * may want capability |
|
42 | - * restrictions relating to |
|
43 | - * deleting datetimes, they don't |
|
44 | - * need to be able to DELETE |
|
45 | - * EVENTS, they just need to be |
|
46 | - * able to EDIT EVENTS in order |
|
47 | - * to DELETE DATETIMES. If none |
|
48 | - * if provided, assumed to be the |
|
49 | - * same as on the primary model. |
|
50 | - */ |
|
51 | - public function __construct( |
|
52 | - string $path_to_event_model, |
|
53 | - string $cap_context_on_event_model = '' |
|
54 | - ) { |
|
55 | - if (substr($path_to_event_model, -1, 1) != '.') { |
|
56 | - $path_to_event_model .= '.'; |
|
57 | - } |
|
58 | - $this->_path_to_event_model = $path_to_event_model; |
|
59 | - $this->_cap_context_on_event_model = $cap_context_on_event_model; |
|
60 | - } |
|
36 | + /** |
|
37 | + * @param string $path_to_event_model |
|
38 | + * @param string $cap_context_on_event_model capability context on event |
|
39 | + * model when creating |
|
40 | + * restrictions. Eg, although we |
|
41 | + * may want capability |
|
42 | + * restrictions relating to |
|
43 | + * deleting datetimes, they don't |
|
44 | + * need to be able to DELETE |
|
45 | + * EVENTS, they just need to be |
|
46 | + * able to EDIT EVENTS in order |
|
47 | + * to DELETE DATETIMES. If none |
|
48 | + * if provided, assumed to be the |
|
49 | + * same as on the primary model. |
|
50 | + */ |
|
51 | + public function __construct( |
|
52 | + string $path_to_event_model, |
|
53 | + string $cap_context_on_event_model = '' |
|
54 | + ) { |
|
55 | + if (substr($path_to_event_model, -1, 1) != '.') { |
|
56 | + $path_to_event_model .= '.'; |
|
57 | + } |
|
58 | + $this->_path_to_event_model = $path_to_event_model; |
|
59 | + $this->_cap_context_on_event_model = $cap_context_on_event_model; |
|
60 | + } |
|
61 | 61 | |
62 | 62 | |
63 | - /** |
|
64 | - * Returns `$this->_cap_context_on_event_model`, the relevant action |
|
65 | - * ("read", |
|
66 | - * "read_admin", "edit" or "delete") for the EVENT related to this model. |
|
67 | - * |
|
68 | - * @return string one of EEM_Base::valid_cap_contexts() |
|
69 | - * @throws EE_Error |
|
70 | - * @see EE_Restriction_Generator_Event_Related_Protected::__construct() |
|
71 | - */ |
|
72 | - protected function action_for_event(): ?string |
|
73 | - { |
|
74 | - if ($this->_cap_context_on_event_model) { |
|
75 | - return $this->_cap_context_on_event_model; |
|
76 | - } else { |
|
77 | - return $this->action(); |
|
78 | - } |
|
79 | - } |
|
63 | + /** |
|
64 | + * Returns `$this->_cap_context_on_event_model`, the relevant action |
|
65 | + * ("read", |
|
66 | + * "read_admin", "edit" or "delete") for the EVENT related to this model. |
|
67 | + * |
|
68 | + * @return string one of EEM_Base::valid_cap_contexts() |
|
69 | + * @throws EE_Error |
|
70 | + * @see EE_Restriction_Generator_Event_Related_Protected::__construct() |
|
71 | + */ |
|
72 | + protected function action_for_event(): ?string |
|
73 | + { |
|
74 | + if ($this->_cap_context_on_event_model) { |
|
75 | + return $this->_cap_context_on_event_model; |
|
76 | + } else { |
|
77 | + return $this->action(); |
|
78 | + } |
|
79 | + } |
|
80 | 80 | |
81 | 81 | |
82 | - /** |
|
83 | - * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[] |
|
84 | - * @throws EE_Error |
|
85 | - * @throws EE_Error |
|
86 | - */ |
|
87 | - protected function _generate_restrictions(): array |
|
88 | - { |
|
89 | - // if there are no standard caps for this model, then for now |
|
90 | - // all we know if they need the default cap to access this |
|
91 | - if (! $this->model()->cap_slug()) { |
|
92 | - return [ |
|
93 | - self::get_default_restrictions_cap( |
|
94 | - ) => new EE_Return_None_Where_Conditions(), |
|
95 | - ]; |
|
96 | - } |
|
82 | + /** |
|
83 | + * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[] |
|
84 | + * @throws EE_Error |
|
85 | + * @throws EE_Error |
|
86 | + */ |
|
87 | + protected function _generate_restrictions(): array |
|
88 | + { |
|
89 | + // if there are no standard caps for this model, then for now |
|
90 | + // all we know if they need the default cap to access this |
|
91 | + if (! $this->model()->cap_slug()) { |
|
92 | + return [ |
|
93 | + self::get_default_restrictions_cap( |
|
94 | + ) => new EE_Return_None_Where_Conditions(), |
|
95 | + ]; |
|
96 | + } |
|
97 | 97 | |
98 | - $event_model = EEM_Event::instance(); |
|
99 | - return [ |
|
100 | - // first: basically access to non-defaults is essentially |
|
101 | - // controlled by which events are accessible |
|
102 | - // if they don't have the basic event cap, |
|
103 | - // they can't access ANY non-default items |
|
104 | - EE_Restriction_Generator_Base::get_cap_name( |
|
105 | - $event_model, |
|
106 | - $this->action_for_event() |
|
107 | - ) => new EE_Return_None_Where_Conditions(), |
|
108 | - // if they don't have the others event cap, |
|
109 | - // they can't access others' non-default items |
|
110 | - EE_Restriction_Generator_Base::get_cap_name( |
|
111 | - $event_model, |
|
112 | - $this->action_for_event() . '_others' |
|
113 | - ) => new EE_Default_Where_Conditions( |
|
114 | - [ |
|
115 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
116 | - ] |
|
117 | - ), |
|
118 | - // if they have basic and others, but not private, |
|
119 | - // they can't access others' private non-default items |
|
120 | - EE_Restriction_Generator_Base::get_cap_name( |
|
121 | - $event_model, |
|
122 | - $this->action_for_event() . '_private' |
|
123 | - ) => new EE_Default_Where_Conditions( |
|
124 | - [ |
|
125 | - 'OR*no_' . |
|
126 | - EE_Restriction_Generator_Base::get_cap_name( |
|
127 | - $event_model, |
|
128 | - $this->action_for_event() . '_private' |
|
129 | - ) => $this->addPublishedPostConditions( |
|
130 | - [ |
|
131 | - $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
132 | - ], |
|
133 | - false, |
|
134 | - $this->_path_to_event_model |
|
135 | - ) |
|
136 | - ] |
|
137 | - ), |
|
138 | - ]; |
|
139 | - } |
|
98 | + $event_model = EEM_Event::instance(); |
|
99 | + return [ |
|
100 | + // first: basically access to non-defaults is essentially |
|
101 | + // controlled by which events are accessible |
|
102 | + // if they don't have the basic event cap, |
|
103 | + // they can't access ANY non-default items |
|
104 | + EE_Restriction_Generator_Base::get_cap_name( |
|
105 | + $event_model, |
|
106 | + $this->action_for_event() |
|
107 | + ) => new EE_Return_None_Where_Conditions(), |
|
108 | + // if they don't have the others event cap, |
|
109 | + // they can't access others' non-default items |
|
110 | + EE_Restriction_Generator_Base::get_cap_name( |
|
111 | + $event_model, |
|
112 | + $this->action_for_event() . '_others' |
|
113 | + ) => new EE_Default_Where_Conditions( |
|
114 | + [ |
|
115 | + $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
116 | + ] |
|
117 | + ), |
|
118 | + // if they have basic and others, but not private, |
|
119 | + // they can't access others' private non-default items |
|
120 | + EE_Restriction_Generator_Base::get_cap_name( |
|
121 | + $event_model, |
|
122 | + $this->action_for_event() . '_private' |
|
123 | + ) => new EE_Default_Where_Conditions( |
|
124 | + [ |
|
125 | + 'OR*no_' . |
|
126 | + EE_Restriction_Generator_Base::get_cap_name( |
|
127 | + $event_model, |
|
128 | + $this->action_for_event() . '_private' |
|
129 | + ) => $this->addPublishedPostConditions( |
|
130 | + [ |
|
131 | + $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER, |
|
132 | + ], |
|
133 | + false, |
|
134 | + $this->_path_to_event_model |
|
135 | + ) |
|
136 | + ] |
|
137 | + ), |
|
138 | + ]; |
|
139 | + } |
|
140 | 140 | } |