@@ -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 | class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base |
34 | 34 | { |
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', '<=') && version_compare($version_string, '4.8.0', '>=')) { |
|
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', '<=') && version_compare($version_string, '4.8.0', '>=')) { |
|
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 '', |
@@ -267,9 +267,9 @@ discard block |
||
267 | 267 | PRIMARY KEY (LIN_ID), |
268 | 268 | KEY LIN_code (LIN_code(191)), |
269 | 269 | KEY TXN_ID (TXN_ID)"; |
270 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
271 | - $table_name = 'esp_log'; |
|
272 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
270 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
271 | + $table_name = 'esp_log'; |
|
272 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
273 | 273 | LOG_time datetime DEFAULT NULL, |
274 | 274 | OBJ_ID varchar(45) DEFAULT NULL, |
275 | 275 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -280,12 +280,12 @@ discard block |
||
280 | 280 | KEY LOG_time (LOG_time), |
281 | 281 | KEY OBJ (OBJ_type,OBJ_ID), |
282 | 282 | KEY LOG_type (LOG_type)"; |
283 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
284 | - $table_name = 'esp_message'; |
|
285 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to'); |
|
286 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from'); |
|
287 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject'); |
|
288 | - $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
283 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
284 | + $table_name = 'esp_message'; |
|
285 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to'); |
|
286 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from'); |
|
287 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject'); |
|
288 | + $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
289 | 289 | GRP_ID int(10) unsigned NULL, |
290 | 290 | MSG_token varchar(255) NULL, |
291 | 291 | TXN_ID int(10) unsigned NULL, |
@@ -317,18 +317,18 @@ discard block |
||
317 | 317 | KEY STS_ID (STS_ID), |
318 | 318 | KEY MSG_created (MSG_created), |
319 | 319 | KEY MSG_modified (MSG_modified)"; |
320 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
321 | - $table_name = 'esp_message_template'; |
|
322 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
320 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
321 | + $table_name = 'esp_message_template'; |
|
322 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
323 | 323 | GRP_ID int(10) unsigned NOT NULL, |
324 | 324 | MTP_context varchar(50) NOT NULL, |
325 | 325 | MTP_template_field varchar(30) NOT NULL, |
326 | 326 | MTP_content text NOT NULL, |
327 | 327 | PRIMARY KEY (MTP_ID), |
328 | 328 | KEY GRP_ID (GRP_ID)"; |
329 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
330 | - $table_name = 'esp_message_template_group'; |
|
331 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
329 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
330 | + $table_name = 'esp_message_template_group'; |
|
331 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
332 | 332 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
333 | 333 | MTP_name varchar(245) NOT NULL DEFAULT '', |
334 | 334 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
341 | 341 | PRIMARY KEY (GRP_ID), |
342 | 342 | KEY MTP_user_id (MTP_user_id)"; |
343 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
344 | - $table_name = 'esp_payment'; |
|
345 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
343 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
344 | + $table_name = 'esp_payment'; |
|
345 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
346 | 346 | TXN_ID int(10) unsigned DEFAULT NULL, |
347 | 347 | STS_ID varchar(3) DEFAULT NULL, |
348 | 348 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -359,9 +359,9 @@ discard block |
||
359 | 359 | PRIMARY KEY (PAY_ID), |
360 | 360 | KEY PAY_timestamp (PAY_timestamp), |
361 | 361 | KEY TXN_ID (TXN_ID)"; |
362 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
363 | - $table_name = 'esp_payment_method'; |
|
364 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
362 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
363 | + $table_name = 'esp_payment_method'; |
|
364 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
365 | 365 | PMD_type varchar(124) DEFAULT NULL, |
366 | 366 | PMD_name varchar(255) DEFAULT NULL, |
367 | 367 | PMD_desc text, |
@@ -377,24 +377,24 @@ discard block |
||
377 | 377 | PRIMARY KEY (PMD_ID), |
378 | 378 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
379 | 379 | KEY PMD_type (PMD_type)"; |
380 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
381 | - $table_name = "esp_ticket_price"; |
|
382 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
380 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
381 | + $table_name = "esp_ticket_price"; |
|
382 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
383 | 383 | TKT_ID int(10) unsigned NOT NULL, |
384 | 384 | PRC_ID int(10) unsigned NOT NULL, |
385 | 385 | PRIMARY KEY (TKP_ID), |
386 | 386 | KEY TKT_ID (TKT_ID), |
387 | 387 | KEY PRC_ID (PRC_ID)"; |
388 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
389 | - $table_name = "esp_ticket_template"; |
|
390 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
388 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
389 | + $table_name = "esp_ticket_template"; |
|
390 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
391 | 391 | TTM_name varchar(45) NOT NULL, |
392 | 392 | TTM_description text, |
393 | 393 | TTM_file varchar(45), |
394 | 394 | PRIMARY KEY (TTM_ID)"; |
395 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
396 | - $table_name = 'esp_question'; |
|
397 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
395 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
396 | + $table_name = 'esp_question'; |
|
397 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
398 | 398 | QST_display_text text NOT NULL, |
399 | 399 | QST_admin_label varchar(255) NOT NULL, |
400 | 400 | QST_system varchar(25) DEFAULT NULL, |
@@ -408,18 +408,18 @@ discard block |
||
408 | 408 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
409 | 409 | PRIMARY KEY (QST_ID), |
410 | 410 | KEY QST_order (QST_order)'; |
411 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
412 | - $table_name = 'esp_question_group_question'; |
|
413 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
411 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
412 | + $table_name = 'esp_question_group_question'; |
|
413 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
414 | 414 | QSG_ID int(10) unsigned NOT NULL, |
415 | 415 | QST_ID int(10) unsigned NOT NULL, |
416 | 416 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
417 | 417 | PRIMARY KEY (QGQ_ID), |
418 | 418 | KEY QST_ID (QST_ID), |
419 | 419 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
420 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
421 | - $table_name = 'esp_question_option'; |
|
422 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
420 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
421 | + $table_name = 'esp_question_option'; |
|
422 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
423 | 423 | QSO_value varchar(255) NOT NULL, |
424 | 424 | QSO_desc text NOT NULL, |
425 | 425 | QST_ID int(10) unsigned NOT NULL, |
@@ -429,9 +429,9 @@ discard block |
||
429 | 429 | PRIMARY KEY (QSO_ID), |
430 | 430 | KEY QST_ID (QST_ID), |
431 | 431 | KEY QSO_order (QSO_order)"; |
432 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
433 | - $table_name = 'esp_registration'; |
|
434 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
432 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
433 | + $table_name = 'esp_registration'; |
|
434 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
435 | 435 | EVT_ID bigint(20) unsigned NOT NULL, |
436 | 436 | ATT_ID bigint(20) unsigned NOT NULL, |
437 | 437 | TXN_ID int(10) unsigned NOT NULL, |
@@ -455,18 +455,18 @@ discard block |
||
455 | 455 | KEY TKT_ID (TKT_ID), |
456 | 456 | KEY EVT_ID (EVT_ID), |
457 | 457 | KEY STS_ID (STS_ID)"; |
458 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
459 | - $table_name = 'esp_registration_payment'; |
|
460 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
458 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
459 | + $table_name = 'esp_registration_payment'; |
|
460 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
461 | 461 | REG_ID int(10) unsigned NOT NULL, |
462 | 462 | PAY_ID int(10) unsigned NULL, |
463 | 463 | RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
464 | 464 | PRIMARY KEY (RPY_ID), |
465 | 465 | KEY REG_ID (REG_ID), |
466 | 466 | KEY PAY_ID (PAY_ID)"; |
467 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
468 | - $table_name = 'esp_state'; |
|
469 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
467 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
468 | + $table_name = 'esp_state'; |
|
469 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
470 | 470 | CNT_ISO varchar(2) NOT NULL, |
471 | 471 | STA_abbrev varchar(24) NOT NULL, |
472 | 472 | STA_name varchar(100) NOT NULL, |
@@ -474,9 +474,9 @@ discard block |
||
474 | 474 | PRIMARY KEY (STA_ID), |
475 | 475 | KEY STA_abbrev (STA_abbrev), |
476 | 476 | KEY CNT_ISO (CNT_ISO)"; |
477 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
478 | - $table_name = 'esp_status'; |
|
479 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
477 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
478 | + $table_name = 'esp_status'; |
|
479 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
480 | 480 | STS_code varchar(45) NOT NULL, |
481 | 481 | STS_type varchar(45) NOT NULL, |
482 | 482 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -484,9 +484,9 @@ discard block |
||
484 | 484 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
485 | 485 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
486 | 486 | KEY STS_type (STS_type)"; |
487 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
488 | - $table_name = 'esp_transaction'; |
|
489 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
487 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
488 | + $table_name = 'esp_transaction'; |
|
489 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
490 | 490 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
491 | 491 | TXN_total decimal(12,3) DEFAULT '0.00', |
492 | 492 | TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00', |
@@ -498,9 +498,9 @@ discard block |
||
498 | 498 | PRIMARY KEY (TXN_ID), |
499 | 499 | KEY TXN_timestamp (TXN_timestamp), |
500 | 500 | KEY STS_ID (STS_ID)"; |
501 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
502 | - $table_name = 'esp_venue_meta'; |
|
503 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
501 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
502 | + $table_name = 'esp_venue_meta'; |
|
503 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
504 | 504 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
505 | 505 | VNU_address varchar(255) DEFAULT NULL, |
506 | 506 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -519,10 +519,10 @@ discard block |
||
519 | 519 | KEY VNU_ID (VNU_ID), |
520 | 520 | KEY STA_ID (STA_ID), |
521 | 521 | KEY CNT_ISO (CNT_ISO)"; |
522 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
523 | - //modified tables |
|
524 | - $table_name = "esp_price"; |
|
525 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
522 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
523 | + //modified tables |
|
524 | + $table_name = "esp_price"; |
|
525 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
526 | 526 | PRT_ID tinyint(3) unsigned NOT NULL, |
527 | 527 | PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
528 | 528 | PRC_name varchar(245) NOT NULL, |
@@ -535,9 +535,9 @@ discard block |
||
535 | 535 | PRC_parent int(10) unsigned DEFAULT 0, |
536 | 536 | PRIMARY KEY (PRC_ID), |
537 | 537 | KEY PRT_ID (PRT_ID)"; |
538 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
539 | - $table_name = "esp_price_type"; |
|
540 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
538 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
539 | + $table_name = "esp_price_type"; |
|
540 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
541 | 541 | PRT_name varchar(45) NOT NULL, |
542 | 542 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
543 | 543 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -546,9 +546,9 @@ discard block |
||
546 | 546 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
547 | 547 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
548 | 548 | PRIMARY KEY (PRT_ID)"; |
549 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
550 | - $table_name = "esp_ticket"; |
|
551 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
549 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
550 | + $table_name = "esp_ticket"; |
|
551 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
552 | 552 | TTM_ID int(10) unsigned NOT NULL, |
553 | 553 | TKT_name varchar(245) NOT NULL DEFAULT '', |
554 | 554 | TKT_description text NOT NULL, |
@@ -571,9 +571,9 @@ discard block |
||
571 | 571 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
572 | 572 | PRIMARY KEY (TKT_ID), |
573 | 573 | KEY TKT_start_date (TKT_start_date)"; |
574 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
575 | - $table_name = 'esp_question_group'; |
|
576 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
574 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
575 | + $table_name = 'esp_question_group'; |
|
576 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
577 | 577 | QSG_name varchar(255) NOT NULL, |
578 | 578 | QSG_identifier varchar(100) NOT NULL, |
579 | 579 | QSG_desc text NULL, |
@@ -586,138 +586,138 @@ discard block |
||
586 | 586 | PRIMARY KEY (QSG_ID), |
587 | 587 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
588 | 588 | KEY QSG_order (QSG_order)'; |
589 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
590 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
591 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
592 | - //(because many need to convert old string states to foreign keys into the states table) |
|
593 | - $script_4_1_defaults->insert_default_states(); |
|
594 | - $script_4_1_defaults->insert_default_countries(); |
|
595 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
596 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
597 | - $script_4_5_defaults->insert_default_price_types(); |
|
598 | - $script_4_5_defaults->insert_default_prices(); |
|
599 | - $script_4_5_defaults->insert_default_tickets(); |
|
600 | - /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
601 | - $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
602 | - $script_4_6_defaults->add_default_admin_only_payments(); |
|
603 | - $script_4_6_defaults->insert_default_currencies(); |
|
604 | - /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
605 | - $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
606 | - $script_4_8_defaults->verify_new_countries(); |
|
607 | - $script_4_8_defaults->verify_new_currencies(); |
|
608 | - $this->verify_db_collations(); |
|
609 | - $this->verify_db_collations_again(); |
|
610 | - return true; |
|
611 | - } |
|
589 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
590 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
591 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
592 | + //(because many need to convert old string states to foreign keys into the states table) |
|
593 | + $script_4_1_defaults->insert_default_states(); |
|
594 | + $script_4_1_defaults->insert_default_countries(); |
|
595 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
596 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
597 | + $script_4_5_defaults->insert_default_price_types(); |
|
598 | + $script_4_5_defaults->insert_default_prices(); |
|
599 | + $script_4_5_defaults->insert_default_tickets(); |
|
600 | + /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
601 | + $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
602 | + $script_4_6_defaults->add_default_admin_only_payments(); |
|
603 | + $script_4_6_defaults->insert_default_currencies(); |
|
604 | + /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
605 | + $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
606 | + $script_4_8_defaults->verify_new_countries(); |
|
607 | + $script_4_8_defaults->verify_new_currencies(); |
|
608 | + $this->verify_db_collations(); |
|
609 | + $this->verify_db_collations_again(); |
|
610 | + return true; |
|
611 | + } |
|
612 | 612 | |
613 | 613 | |
614 | 614 | |
615 | - /** |
|
616 | - * @return boolean |
|
617 | - */ |
|
618 | - public function schema_changes_after_migration() |
|
619 | - { |
|
620 | - return true; |
|
621 | - } |
|
615 | + /** |
|
616 | + * @return boolean |
|
617 | + */ |
|
618 | + public function schema_changes_after_migration() |
|
619 | + { |
|
620 | + return true; |
|
621 | + } |
|
622 | 622 | |
623 | 623 | |
624 | 624 | |
625 | - public function migration_page_hooks() |
|
626 | - { |
|
627 | - } |
|
625 | + public function migration_page_hooks() |
|
626 | + { |
|
627 | + } |
|
628 | 628 | |
629 | 629 | |
630 | 630 | |
631 | - /** |
|
632 | - * Verify all EE4 models' tables use utf8mb4 collation |
|
633 | - * |
|
634 | - * @return void |
|
635 | - */ |
|
636 | - public function verify_db_collations() |
|
637 | - { |
|
638 | - if (get_option('ee_verified_db_collations', false)) { |
|
639 | - return; |
|
640 | - } |
|
641 | - // grab tables from each model |
|
642 | - $tables_to_check = array(); |
|
643 | - foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
644 | - if (method_exists($model_name, 'instance')) { |
|
645 | - $model_obj = call_user_func(array($model_name, 'instance')); |
|
646 | - if ($model_obj instanceof EEM_Base) { |
|
647 | - foreach ($model_obj->get_tables() as $table) { |
|
648 | - if ( |
|
649 | - strpos($table->get_table_name(), 'esp_') |
|
650 | - && (is_main_site()//for main tables, verify global tables |
|
651 | - || ! $table->is_global()//if not the main site, then only verify non-global tables (avoid doubling up) |
|
652 | - ) |
|
653 | - && function_exists('maybe_convert_table_to_utf8mb4') |
|
654 | - ) { |
|
655 | - $tables_to_check[] = $table->get_table_name(); |
|
656 | - } |
|
657 | - } |
|
658 | - } |
|
659 | - } |
|
660 | - } |
|
661 | - //and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active |
|
662 | - //when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead |
|
663 | - //of hard-coding this |
|
664 | - $addon_tables = array( |
|
665 | - //mailchimp |
|
666 | - 'esp_event_mailchimp_list_group', |
|
667 | - 'esp_event_question_mailchimp_field', |
|
668 | - //multisite |
|
669 | - 'esp_blog_meta', |
|
670 | - //people |
|
671 | - 'esp_people_to_post', |
|
672 | - //promotions |
|
673 | - 'esp_promotion', |
|
674 | - 'esp_promotion_object', |
|
675 | - ); |
|
676 | - foreach ($addon_tables as $table_name) { |
|
677 | - $tables_to_check[] = $table_name; |
|
678 | - } |
|
679 | - $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
680 | - //ok and now let's remember this was done (without needing to check the db schemas all over again) |
|
681 | - add_option('ee_verified_db_collations', true, null, 'no'); |
|
682 | - //seeing how this ran with the fix from 10435, no need to check again |
|
683 | - add_option('ee_verified_db_collations_again',true,null,'no'); |
|
684 | - } |
|
631 | + /** |
|
632 | + * Verify all EE4 models' tables use utf8mb4 collation |
|
633 | + * |
|
634 | + * @return void |
|
635 | + */ |
|
636 | + public function verify_db_collations() |
|
637 | + { |
|
638 | + if (get_option('ee_verified_db_collations', false)) { |
|
639 | + return; |
|
640 | + } |
|
641 | + // grab tables from each model |
|
642 | + $tables_to_check = array(); |
|
643 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
644 | + if (method_exists($model_name, 'instance')) { |
|
645 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
646 | + if ($model_obj instanceof EEM_Base) { |
|
647 | + foreach ($model_obj->get_tables() as $table) { |
|
648 | + if ( |
|
649 | + strpos($table->get_table_name(), 'esp_') |
|
650 | + && (is_main_site()//for main tables, verify global tables |
|
651 | + || ! $table->is_global()//if not the main site, then only verify non-global tables (avoid doubling up) |
|
652 | + ) |
|
653 | + && function_exists('maybe_convert_table_to_utf8mb4') |
|
654 | + ) { |
|
655 | + $tables_to_check[] = $table->get_table_name(); |
|
656 | + } |
|
657 | + } |
|
658 | + } |
|
659 | + } |
|
660 | + } |
|
661 | + //and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active |
|
662 | + //when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead |
|
663 | + //of hard-coding this |
|
664 | + $addon_tables = array( |
|
665 | + //mailchimp |
|
666 | + 'esp_event_mailchimp_list_group', |
|
667 | + 'esp_event_question_mailchimp_field', |
|
668 | + //multisite |
|
669 | + 'esp_blog_meta', |
|
670 | + //people |
|
671 | + 'esp_people_to_post', |
|
672 | + //promotions |
|
673 | + 'esp_promotion', |
|
674 | + 'esp_promotion_object', |
|
675 | + ); |
|
676 | + foreach ($addon_tables as $table_name) { |
|
677 | + $tables_to_check[] = $table_name; |
|
678 | + } |
|
679 | + $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
680 | + //ok and now let's remember this was done (without needing to check the db schemas all over again) |
|
681 | + add_option('ee_verified_db_collations', true, null, 'no'); |
|
682 | + //seeing how this ran with the fix from 10435, no need to check again |
|
683 | + add_option('ee_verified_db_collations_again',true,null,'no'); |
|
684 | + } |
|
685 | 685 | |
686 | 686 | |
687 | 687 | |
688 | - /** |
|
689 | - * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435 |
|
690 | - * which meant some DB collations might not have been updated |
|
691 | - * @return void |
|
692 | - */ |
|
693 | - public function verify_db_collations_again(){ |
|
694 | - if (get_option('ee_verified_db_collations_again', false)) { |
|
695 | - return; |
|
696 | - } |
|
697 | - $tables_to_check = array( |
|
698 | - 'esp_attendee_meta', |
|
699 | - 'esp_message' |
|
700 | - ); |
|
701 | - $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
702 | - add_option('ee_verified_db_collations_again',true,null,'no'); |
|
703 | - } |
|
688 | + /** |
|
689 | + * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435 |
|
690 | + * which meant some DB collations might not have been updated |
|
691 | + * @return void |
|
692 | + */ |
|
693 | + public function verify_db_collations_again(){ |
|
694 | + if (get_option('ee_verified_db_collations_again', false)) { |
|
695 | + return; |
|
696 | + } |
|
697 | + $tables_to_check = array( |
|
698 | + 'esp_attendee_meta', |
|
699 | + 'esp_message' |
|
700 | + ); |
|
701 | + $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
702 | + add_option('ee_verified_db_collations_again',true,null,'no'); |
|
703 | + } |
|
704 | 704 | |
705 | 705 | |
706 | 706 | |
707 | - /** |
|
708 | - * Runs maybe_convert_table_to_utf8mb4 on the specified tables |
|
709 | - * @param $tables_to_check |
|
710 | - * @return boolean true if logic ran, false if it didn't |
|
711 | - */ |
|
712 | - protected function _verify_db_collations_for_tables($tables_to_check) |
|
713 | - { |
|
714 | - foreach ($tables_to_check as $table_name) { |
|
715 | - $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
|
716 | - if ( ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name ) |
|
717 | - && $this->_get_table_analysis()->tableExists($table_name) |
|
718 | - ) { |
|
719 | - maybe_convert_table_to_utf8mb4($table_name); |
|
720 | - } |
|
721 | - } |
|
722 | - } |
|
707 | + /** |
|
708 | + * Runs maybe_convert_table_to_utf8mb4 on the specified tables |
|
709 | + * @param $tables_to_check |
|
710 | + * @return boolean true if logic ran, false if it didn't |
|
711 | + */ |
|
712 | + protected function _verify_db_collations_for_tables($tables_to_check) |
|
713 | + { |
|
714 | + foreach ($tables_to_check as $table_name) { |
|
715 | + $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
|
716 | + if ( ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name ) |
|
717 | + && $this->_get_table_analysis()->tableExists($table_name) |
|
718 | + ) { |
|
719 | + maybe_convert_table_to_utf8mb4($table_name); |
|
720 | + } |
|
721 | + } |
|
722 | + } |
|
723 | 723 | } |
724 | 724 | \ No newline at end of file |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | $stages = glob(EE_CORE . 'data_migration_scripts/4_6_0_stages/*'); |
15 | 15 | $class_to_filepath = array(); |
16 | 16 | foreach ($stages as $filepath) { |
17 | - $matches = array(); |
|
18 | - preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
19 | - $class_to_filepath[$matches[1]] = $filepath; |
|
17 | + $matches = array(); |
|
18 | + preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
19 | + $class_to_filepath[$matches[1]] = $filepath; |
|
20 | 20 | } |
21 | 21 | //give addons a chance to autoload their stages too |
22 | 22 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_6_0__autoloaded_stages', $class_to_filepath); |
@@ -35,69 +35,69 @@ discard block |
||
35 | 35 | class EE_DMS_Core_4_6_0 extends EE_Data_Migration_Script_Base |
36 | 36 | { |
37 | 37 | |
38 | - /** |
|
39 | - * return EE_DMS_Core_4_6_0 |
|
40 | - * |
|
41 | - * @param TableManager $table_manager |
|
42 | - * @param TableAnalysis $table_analysis |
|
43 | - */ |
|
44 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
45 | - { |
|
46 | - $this->_pretty_name = __("Data Update to Event Espresso 4.6.0", "event_espresso"); |
|
47 | - $this->_priority = 10; |
|
48 | - $this->_migration_stages = array( |
|
49 | - new EE_DMS_4_6_0_gateways(), |
|
50 | - new EE_DMS_4_6_0_question_types(), |
|
51 | - new EE_DMS_4_6_0_country_system_question(), |
|
52 | - new EE_DMS_4_6_0_state_system_question(), |
|
53 | - new EE_DMS_4_6_0_billing_info(), |
|
54 | - new EE_DMS_4_6_0_transactions(), |
|
55 | - new EE_DMS_4_6_0_payments(), |
|
56 | - new EE_DMS_4_6_0_invoice_settings(), |
|
57 | - ); |
|
58 | - parent::__construct($table_manager, $table_analysis); |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * @param array $version_array |
|
65 | - * @return bool |
|
66 | - */ |
|
67 | - public function can_migrate_from_version($version_array) |
|
68 | - { |
|
69 | - $version_string = $version_array['Core']; |
|
70 | - if (version_compare($version_string, '4.6.0', '<=') && version_compare($version_string, '4.5.0', '>=')) { |
|
38 | + /** |
|
39 | + * return EE_DMS_Core_4_6_0 |
|
40 | + * |
|
41 | + * @param TableManager $table_manager |
|
42 | + * @param TableAnalysis $table_analysis |
|
43 | + */ |
|
44 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
45 | + { |
|
46 | + $this->_pretty_name = __("Data Update to Event Espresso 4.6.0", "event_espresso"); |
|
47 | + $this->_priority = 10; |
|
48 | + $this->_migration_stages = array( |
|
49 | + new EE_DMS_4_6_0_gateways(), |
|
50 | + new EE_DMS_4_6_0_question_types(), |
|
51 | + new EE_DMS_4_6_0_country_system_question(), |
|
52 | + new EE_DMS_4_6_0_state_system_question(), |
|
53 | + new EE_DMS_4_6_0_billing_info(), |
|
54 | + new EE_DMS_4_6_0_transactions(), |
|
55 | + new EE_DMS_4_6_0_payments(), |
|
56 | + new EE_DMS_4_6_0_invoice_settings(), |
|
57 | + ); |
|
58 | + parent::__construct($table_manager, $table_analysis); |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * @param array $version_array |
|
65 | + * @return bool |
|
66 | + */ |
|
67 | + public function can_migrate_from_version($version_array) |
|
68 | + { |
|
69 | + $version_string = $version_array['Core']; |
|
70 | + if (version_compare($version_string, '4.6.0', '<=') && version_compare($version_string, '4.5.0', '>=')) { |
|
71 | 71 | // echo "$version_string can be migrated from"; |
72 | - return true; |
|
73 | - } elseif ( ! $version_string) { |
|
72 | + return true; |
|
73 | + } elseif ( ! $version_string) { |
|
74 | 74 | // echo "no version string provided: $version_string"; |
75 | - //no version string provided... this must be pre 4.3 |
|
76 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
77 | - } else { |
|
75 | + //no version string provided... this must be pre 4.3 |
|
76 | + return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
77 | + } else { |
|
78 | 78 | // echo "$version_string doesnt apply"; |
79 | - return false; |
|
80 | - } |
|
81 | - } |
|
79 | + return false; |
|
80 | + } |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | 84 | |
85 | - /** |
|
86 | - * @return bool |
|
87 | - */ |
|
88 | - public function schema_changes_before_migration() |
|
89 | - { |
|
90 | - //relies on 4.1's EEH_Activation::create_table |
|
91 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
92 | - $table_name = 'esp_answer'; |
|
93 | - $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
85 | + /** |
|
86 | + * @return bool |
|
87 | + */ |
|
88 | + public function schema_changes_before_migration() |
|
89 | + { |
|
90 | + //relies on 4.1's EEH_Activation::create_table |
|
91 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
92 | + $table_name = 'esp_answer'; |
|
93 | + $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
94 | 94 | REG_ID INT UNSIGNED NOT NULL, |
95 | 95 | QST_ID INT UNSIGNED NOT NULL, |
96 | 96 | ANS_value TEXT NOT NULL, |
97 | 97 | PRIMARY KEY (ANS_ID)"; |
98 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
99 | - $table_name = 'esp_attendee_meta'; |
|
100 | - $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
98 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
99 | + $table_name = 'esp_attendee_meta'; |
|
100 | + $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
101 | 101 | ATT_ID BIGINT(20) UNSIGNED NOT NULL, |
102 | 102 | ATT_fname VARCHAR(45) NOT NULL, |
103 | 103 | ATT_lname VARCHAR(45) NOT NULL, |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | KEY ATT_fname (ATT_fname), |
114 | 114 | KEY ATT_lname (ATT_lname), |
115 | 115 | KEY ATT_email (ATT_email)"; |
116 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
117 | - $table_name = 'esp_country'; |
|
118 | - $sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
|
116 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
117 | + $table_name = 'esp_country'; |
|
118 | + $sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
|
119 | 119 | CNT_ISO3 VARCHAR(3) COLLATE utf8_bin NOT NULL, |
120 | 120 | RGN_ID TINYINT(3) UNSIGNED DEFAULT NULL, |
121 | 121 | CNT_name VARCHAR(45) COLLATE utf8_bin NOT NULL, |
@@ -131,24 +131,24 @@ discard block |
||
131 | 131 | CNT_is_EU TINYINT(1) DEFAULT '0', |
132 | 132 | CNT_active TINYINT(1) DEFAULT '0', |
133 | 133 | PRIMARY KEY (CNT_ISO)"; |
134 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
135 | - $table_name = 'esp_currency'; |
|
136 | - $sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL, |
|
134 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
135 | + $table_name = 'esp_currency'; |
|
136 | + $sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL, |
|
137 | 137 | CUR_single VARCHAR(45) COLLATE utf8_bin DEFAULT 'dollar', |
138 | 138 | CUR_plural VARCHAR(45) COLLATE utf8_bin DEFAULT 'dollars', |
139 | 139 | CUR_sign VARCHAR(45) COLLATE utf8_bin DEFAULT '$', |
140 | 140 | CUR_dec_plc VARCHAR(1) COLLATE utf8_bin NOT NULL DEFAULT '2', |
141 | 141 | CUR_active TINYINT(1) DEFAULT '0', |
142 | 142 | PRIMARY KEY (CUR_code)"; |
143 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
144 | - $table_name = 'esp_currency_payment_method'; |
|
145 | - $sql = "CPM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
143 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
144 | + $table_name = 'esp_currency_payment_method'; |
|
145 | + $sql = "CPM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
146 | 146 | CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL, |
147 | 147 | PMD_ID INT(11) NOT NULL, |
148 | 148 | PRIMARY KEY (CPM_ID)"; |
149 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
150 | - $table_name = 'esp_datetime'; |
|
151 | - $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
149 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
150 | + $table_name = 'esp_datetime'; |
|
151 | + $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
152 | 152 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
153 | 153 | DTT_name VARCHAR(255) NOT NULL DEFAULT '', |
154 | 154 | DTT_description TEXT NOT NULL, |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | PRIMARY KEY (DTT_ID), |
164 | 164 | KEY EVT_ID (EVT_ID), |
165 | 165 | KEY DTT_is_primary (DTT_is_primary)"; |
166 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
167 | - $table_name = 'esp_event_meta'; |
|
168 | - $sql = " |
|
166 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
167 | + $table_name = 'esp_event_meta'; |
|
168 | + $sql = " |
|
169 | 169 | EVTM_ID INT NOT NULL AUTO_INCREMENT, |
170 | 170 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
171 | 171 | EVT_display_desc TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
@@ -180,31 +180,31 @@ discard block |
||
180 | 180 | EVT_external_URL VARCHAR(200) NULL, |
181 | 181 | EVT_donations TINYINT(1) NULL, |
182 | 182 | PRIMARY KEY (EVTM_ID)"; |
183 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
184 | - $table_name = 'esp_event_question_group'; |
|
185 | - $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
183 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
184 | + $table_name = 'esp_event_question_group'; |
|
185 | + $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
186 | 186 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
187 | 187 | QSG_ID INT UNSIGNED NOT NULL, |
188 | 188 | EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
189 | 189 | PRIMARY KEY (EQG_ID)"; |
190 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
191 | - $table_name = 'esp_event_venue'; |
|
192 | - $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
190 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
191 | + $table_name = 'esp_event_venue'; |
|
192 | + $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
193 | 193 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
194 | 194 | VNU_ID BIGINT(20) UNSIGNED NOT NULL, |
195 | 195 | EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
196 | 196 | PRIMARY KEY (EVV_ID)"; |
197 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | - $table_name = 'esp_extra_meta'; |
|
199 | - $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
197 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | + $table_name = 'esp_extra_meta'; |
|
199 | + $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
200 | 200 | OBJ_ID INT(11) DEFAULT NULL, |
201 | 201 | EXM_type VARCHAR(45) DEFAULT NULL, |
202 | 202 | EXM_key VARCHAR(45) DEFAULT NULL, |
203 | 203 | EXM_value TEXT, |
204 | 204 | PRIMARY KEY (EXM_ID)"; |
205 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
206 | - $table_name = 'esp_line_item'; |
|
207 | - $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
205 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
206 | + $table_name = 'esp_line_item'; |
|
207 | + $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
208 | 208 | LIN_code VARCHAR(245) NOT NULL DEFAULT '', |
209 | 209 | TXN_ID INT(11) DEFAULT NULL, |
210 | 210 | LIN_name VARCHAR(245) NOT NULL DEFAULT '', |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | OBJ_ID INT(11) DEFAULT NULL, |
221 | 221 | OBJ_type VARCHAR(45)DEFAULT NULL, |
222 | 222 | PRIMARY KEY (LIN_ID)"; |
223 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
224 | - $table_name = 'esp_log'; |
|
225 | - $sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
223 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
224 | + $table_name = 'esp_log'; |
|
225 | + $sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
226 | 226 | LOG_time DATETIME DEFAULT NULL, |
227 | 227 | OBJ_ID VARCHAR(45) DEFAULT NULL, |
228 | 228 | OBJ_type VARCHAR(45) DEFAULT NULL, |
@@ -230,19 +230,19 @@ discard block |
||
230 | 230 | LOG_message TEXT, |
231 | 231 | LOG_wp_user INT(11) DEFAULT NULL, |
232 | 232 | PRIMARY KEY (LOG_ID)"; |
233 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
234 | - $table_name = 'esp_message_template'; |
|
235 | - $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
233 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
234 | + $table_name = 'esp_message_template'; |
|
235 | + $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
236 | 236 | GRP_ID INT(10) UNSIGNED NOT NULL, |
237 | 237 | MTP_context VARCHAR(50) NOT NULL, |
238 | 238 | MTP_template_field VARCHAR(30) NOT NULL, |
239 | 239 | MTP_content TEXT NOT NULL, |
240 | 240 | PRIMARY KEY (MTP_ID), |
241 | 241 | KEY GRP_ID (GRP_ID)"; |
242 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
243 | - $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
244 | - $table_name = 'esp_message_template_group'; |
|
245 | - $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
242 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
243 | + $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
244 | + $table_name = 'esp_message_template_group'; |
|
245 | + $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
246 | 246 | MTP_user_id INT(10) NOT NULL DEFAULT '1', |
247 | 247 | MTP_name VARCHAR(245) NOT NULL DEFAULT '', |
248 | 248 | MTP_description VARCHAR(245) NOT NULL DEFAULT '', |
@@ -254,17 +254,17 @@ discard block |
||
254 | 254 | MTP_is_active TINYINT(1) NOT NULL DEFAULT '1', |
255 | 255 | PRIMARY KEY (GRP_ID), |
256 | 256 | KEY MTP_user_id (MTP_user_id)"; |
257 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
258 | - $table_name = 'esp_event_message_template'; |
|
259 | - $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
257 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
258 | + $table_name = 'esp_event_message_template'; |
|
259 | + $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
260 | 260 | EVT_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, |
261 | 261 | GRP_ID INT(10) UNSIGNED NOT NULL DEFAULT 0, |
262 | 262 | PRIMARY KEY (EMT_ID), |
263 | 263 | KEY EVT_ID (EVT_ID), |
264 | 264 | KEY GRP_ID (GRP_ID)"; |
265 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
266 | - $table_name = 'esp_payment'; |
|
267 | - $sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
265 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
266 | + $table_name = 'esp_payment'; |
|
267 | + $sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
268 | 268 | TXN_ID INT(10) UNSIGNED DEFAULT NULL, |
269 | 269 | STS_ID VARCHAR(3) COLLATE utf8_bin DEFAULT NULL, |
270 | 270 | PAY_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -281,9 +281,9 @@ discard block |
||
281 | 281 | PRIMARY KEY (PAY_ID), |
282 | 282 | KEY TXN_ID (TXN_ID), |
283 | 283 | KEY PAY_timestamp (PAY_timestamp)"; |
284 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
285 | - $table_name = 'esp_payment_method'; |
|
286 | - $sql = "PMD_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
284 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
285 | + $table_name = 'esp_payment_method'; |
|
286 | + $sql = "PMD_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
287 | 287 | PMD_type VARCHAR(124) DEFAULT NULL, |
288 | 288 | PMD_name VARCHAR(255) DEFAULT NULL, |
289 | 289 | PMD_desc TEXT, |
@@ -298,28 +298,28 @@ discard block |
||
298 | 298 | PMD_scope VARCHAR(255) NULL DEFAULT 'frontend', |
299 | 299 | PRIMARY KEY (PMD_ID), |
300 | 300 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug)"; |
301 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
302 | - $table_name = "esp_ticket_price"; |
|
303 | - $sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
301 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
302 | + $table_name = "esp_ticket_price"; |
|
303 | + $sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
304 | 304 | TKT_ID INT(10) UNSIGNED NOT NULL, |
305 | 305 | PRC_ID INT(10) UNSIGNED NOT NULL, |
306 | 306 | PRIMARY KEY (TKP_ID)"; |
307 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
308 | - $table_name = "esp_datetime_ticket"; |
|
309 | - $sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
307 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
308 | + $table_name = "esp_datetime_ticket"; |
|
309 | + $sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
310 | 310 | DTT_ID INT(10) UNSIGNED NOT NULL, |
311 | 311 | TKT_ID INT(10) UNSIGNED NOT NULL, |
312 | 312 | PRIMARY KEY (DTK_ID)"; |
313 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
314 | - $table_name = "esp_ticket_template"; |
|
315 | - $sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
313 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
314 | + $table_name = "esp_ticket_template"; |
|
315 | + $sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
316 | 316 | TTM_name VARCHAR(45) NOT NULL, |
317 | 317 | TTM_description TEXT, |
318 | 318 | TTM_file VARCHAR(45), |
319 | 319 | PRIMARY KEY (TTM_ID)"; |
320 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
321 | - $table_name = 'esp_question'; |
|
322 | - $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
320 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
321 | + $table_name = 'esp_question'; |
|
322 | + $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
323 | 323 | QST_display_text TEXT NOT NULL, |
324 | 324 | QST_admin_label VARCHAR(255) NOT NULL, |
325 | 325 | QST_system VARCHAR(25) DEFAULT NULL, |
@@ -331,25 +331,25 @@ discard block |
||
331 | 331 | QST_wp_user BIGINT UNSIGNED NULL, |
332 | 332 | QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0, |
333 | 333 | PRIMARY KEY (QST_ID)'; |
334 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
335 | - $table_name = 'esp_question_group_question'; |
|
336 | - $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
334 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
335 | + $table_name = 'esp_question_group_question'; |
|
336 | + $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
337 | 337 | QSG_ID INT UNSIGNED NOT NULL, |
338 | 338 | QST_ID INT UNSIGNED NOT NULL, |
339 | 339 | QGQ_order INT UNSIGNED NOT NULL DEFAULT 0, |
340 | 340 | PRIMARY KEY (QGQ_ID) "; |
341 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
342 | - $table_name = 'esp_question_option'; |
|
343 | - $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
341 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
342 | + $table_name = 'esp_question_option'; |
|
343 | + $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
344 | 344 | QSO_value VARCHAR(255) NOT NULL, |
345 | 345 | QSO_desc TEXT NOT NULL, |
346 | 346 | QST_ID INT UNSIGNED NOT NULL, |
347 | 347 | QSO_order INT UNSIGNED NOT NULL DEFAULT 0, |
348 | 348 | QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
349 | 349 | PRIMARY KEY (QSO_ID)"; |
350 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
351 | - $table_name = 'esp_registration'; |
|
352 | - $sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
350 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
351 | + $table_name = 'esp_registration'; |
|
352 | + $sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
353 | 353 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
354 | 354 | ATT_ID BIGINT(20) UNSIGNED NOT NULL, |
355 | 355 | TXN_ID INT(10) UNSIGNED NOT NULL, |
@@ -372,25 +372,25 @@ discard block |
||
372 | 372 | KEY STS_ID (STS_ID), |
373 | 373 | KEY REG_url_link (REG_url_link), |
374 | 374 | KEY REG_code (REG_code)"; |
375 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
376 | - $table_name = 'esp_checkin'; |
|
377 | - $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
375 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
376 | + $table_name = 'esp_checkin'; |
|
377 | + $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
378 | 378 | REG_ID INT(10) UNSIGNED NOT NULL, |
379 | 379 | DTT_ID INT(10) UNSIGNED NOT NULL, |
380 | 380 | CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
381 | 381 | CHK_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
382 | 382 | PRIMARY KEY (CHK_ID)"; |
383 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
384 | - $table_name = 'esp_state'; |
|
385 | - $sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
383 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
384 | + $table_name = 'esp_state'; |
|
385 | + $sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
386 | 386 | CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
387 | 387 | STA_abbrev VARCHAR(24) COLLATE utf8_bin NOT NULL, |
388 | 388 | STA_name VARCHAR(100) COLLATE utf8_bin NOT NULL, |
389 | 389 | STA_active TINYINT(1) DEFAULT '1', |
390 | 390 | PRIMARY KEY (STA_ID)"; |
391 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
392 | - $table_name = 'esp_status'; |
|
393 | - $sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL, |
|
391 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
392 | + $table_name = 'esp_status'; |
|
393 | + $sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL, |
|
394 | 394 | STS_code VARCHAR(45) COLLATE utf8_bin NOT NULL, |
395 | 395 | STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL, |
396 | 396 | STS_can_edit TINYINT(1) NOT NULL DEFAULT 0, |
@@ -398,9 +398,9 @@ discard block |
||
398 | 398 | STS_open TINYINT(1) NOT NULL DEFAULT 1, |
399 | 399 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
400 | 400 | KEY STS_type (STS_type)"; |
401 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
402 | - $table_name = 'esp_transaction'; |
|
403 | - $sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
401 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
402 | + $table_name = 'esp_transaction'; |
|
403 | + $sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
404 | 404 | TXN_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
405 | 405 | TXN_total DECIMAL(10,3) DEFAULT '0.00', |
406 | 406 | TXN_paid DECIMAL(10,3) NOT NULL DEFAULT '0.00', |
@@ -412,9 +412,9 @@ discard block |
||
412 | 412 | PRIMARY KEY (TXN_ID), |
413 | 413 | KEY TXN_timestamp (TXN_timestamp), |
414 | 414 | KEY STS_ID (STS_ID)"; |
415 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
416 | - $table_name = 'esp_venue_meta'; |
|
417 | - $sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
415 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
416 | + $table_name = 'esp_venue_meta'; |
|
417 | + $sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
418 | 418 | VNU_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, |
419 | 419 | VNU_address VARCHAR(255) DEFAULT NULL, |
420 | 420 | VNU_address2 VARCHAR(255) DEFAULT NULL, |
@@ -432,10 +432,10 @@ discard block |
||
432 | 432 | PRIMARY KEY (VNUM_ID), |
433 | 433 | KEY STA_ID (STA_ID), |
434 | 434 | KEY CNT_ISO (CNT_ISO)"; |
435 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
436 | - //modified tables |
|
437 | - $table_name = "esp_price"; |
|
438 | - $sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
435 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
436 | + //modified tables |
|
437 | + $table_name = "esp_price"; |
|
438 | + $sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
439 | 439 | PRT_ID TINYINT(3) UNSIGNED NOT NULL, |
440 | 440 | PRC_amount DECIMAL(10,3) NOT NULL DEFAULT '0.00', |
441 | 441 | PRC_name VARCHAR(245) NOT NULL, |
@@ -447,9 +447,9 @@ discard block |
||
447 | 447 | PRC_wp_user BIGINT UNSIGNED NULL, |
448 | 448 | PRC_parent INT(10) UNSIGNED DEFAULT 0, |
449 | 449 | PRIMARY KEY (PRC_ID)"; |
450 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
451 | - $table_name = "esp_price_type"; |
|
452 | - $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
450 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
451 | + $table_name = "esp_price_type"; |
|
452 | + $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
453 | 453 | PRT_name VARCHAR(45) NOT NULL, |
454 | 454 | PBT_ID TINYINT(3) UNSIGNED NOT NULL DEFAULT '1', |
455 | 455 | PRT_is_percent TINYINT(1) NOT NULL DEFAULT '0', |
@@ -458,9 +458,9 @@ discard block |
||
458 | 458 | PRT_deleted TINYINT(1) NOT NULL DEFAULT '0', |
459 | 459 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
460 | 460 | PRIMARY KEY (PRT_ID)"; |
461 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
462 | - $table_name = "esp_ticket"; |
|
463 | - $sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
461 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
462 | + $table_name = "esp_ticket"; |
|
463 | + $sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
464 | 464 | TTM_ID INT(10) UNSIGNED NOT NULL, |
465 | 465 | TKT_name VARCHAR(245) NOT NULL DEFAULT '', |
466 | 466 | TKT_description TEXT NOT NULL, |
@@ -481,10 +481,10 @@ discard block |
||
481 | 481 | TKT_parent INT(10) UNSIGNED DEFAULT '0', |
482 | 482 | TKT_deleted TINYINT(1) NOT NULL DEFAULT '0', |
483 | 483 | PRIMARY KEY (TKT_ID)"; |
484 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
485 | - $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
486 | - $table_name = 'esp_question_group'; |
|
487 | - $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
484 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
485 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
486 | + $table_name = 'esp_question_group'; |
|
487 | + $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
488 | 488 | QSG_name VARCHAR(255) NOT NULL, |
489 | 489 | QSG_identifier VARCHAR(100) NOT NULL, |
490 | 490 | QSG_desc TEXT NULL, |
@@ -496,119 +496,119 @@ discard block |
||
496 | 496 | QSG_wp_user BIGINT UNSIGNED NULL, |
497 | 497 | PRIMARY KEY (QSG_ID), |
498 | 498 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
499 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
500 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
501 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
502 | - //(because many need to convert old string states to foreign keys into the states table) |
|
503 | - $script_4_1_defaults->insert_default_states(); |
|
504 | - $script_4_1_defaults->insert_default_countries(); |
|
505 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
506 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
507 | - $script_4_5_defaults->insert_default_price_types(); |
|
508 | - $script_4_5_defaults->insert_default_prices(); |
|
509 | - $script_4_5_defaults->insert_default_tickets(); |
|
510 | - //setting up the config wp option pretty well counts as a 'schema change', or at least should happen here |
|
511 | - EE_Config::instance()->update_espresso_config(false, true); |
|
512 | - $this->add_default_admin_only_payments(); |
|
513 | - $this->insert_default_currencies(); |
|
514 | - return true; |
|
515 | - } |
|
516 | - |
|
517 | - |
|
518 | - |
|
519 | - /** |
|
520 | - * @return boolean |
|
521 | - */ |
|
522 | - public function schema_changes_after_migration() |
|
523 | - { |
|
524 | - return true; |
|
525 | - } |
|
526 | - |
|
527 | - |
|
528 | - |
|
529 | - public function migration_page_hooks() |
|
530 | - { |
|
531 | - } |
|
532 | - |
|
533 | - |
|
534 | - |
|
535 | - public function add_default_admin_only_payments() |
|
536 | - { |
|
537 | - global $wpdb; |
|
538 | - $table_name = $wpdb->prefix . "esp_payment_method"; |
|
539 | - $user_id = EEH_Activation::get_default_creator_id(); |
|
540 | - if ($this->_get_table_analysis()->tableExists($table_name)) { |
|
541 | - $SQL = "SELECT COUNT( * ) FROM $table_name"; |
|
542 | - $existing_payment_methods = $wpdb->get_var($SQL); |
|
543 | - $default_admin_only_payment_methods = apply_filters( |
|
544 | - 'FHEE__EEH_Activation__add_default_admin_only_payments__default_admin_only_payment_methods', |
|
545 | - array( |
|
546 | - __("Bank", 'event_espresso') => __("Bank Draft", 'event_espresso'), |
|
547 | - __("Cash", 'event_espresso') => __("Cash Delivered Physically", 'event_espresso'), |
|
548 | - __("Check", 'event_espresso') => __("Paper Check", 'event_espresso'), |
|
549 | - __("Credit Card", 'event_espresso') => __("Offline Credit Card Payment", 'event_espresso'), |
|
550 | - __("Debit Card", 'event_espresso') => __("Offline Debit Payment", 'event_espresso'), |
|
551 | - __("Invoice", 'event_espresso') => __("Invoice received with monies included", |
|
552 | - 'event_espresso'), |
|
553 | - __("Money Order", 'event_espresso') => '', |
|
554 | - __("Paypal", 'event_espresso') => __("Paypal eCheck, Invoice, etc", 'event_espresso'), |
|
555 | - __('Other', 'event_espresso') => __('Other method of payment', 'event_espresso'), |
|
556 | - )); |
|
557 | - //make sure we hae payment method records for the following |
|
558 | - //so admins can record payments for them from the admin page |
|
559 | - foreach ($default_admin_only_payment_methods as $nicename => $description) { |
|
560 | - $slug = sanitize_key($nicename); |
|
561 | - //check that such a payment method exists |
|
562 | - $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug)); |
|
563 | - if ( ! $exists) { |
|
564 | - $values = array( |
|
565 | - 'PMD_type' => 'Admin_Only', |
|
566 | - 'PMD_name' => $nicename, |
|
567 | - 'PMD_admin_name' => $nicename, |
|
568 | - 'PMD_admin_desc' => $description, |
|
569 | - 'PMD_slug' => $slug, |
|
570 | - 'PMD_wp_user' => $user_id, |
|
571 | - 'PMD_scope' => serialize(array('ADMIN')), |
|
572 | - ); |
|
573 | - $success = $wpdb->insert( |
|
574 | - $table_name, |
|
575 | - $values, |
|
576 | - array( |
|
577 | - '%s',//PMD_type |
|
578 | - '%s',//PMD_name |
|
579 | - '%s',//PMD_admin_name |
|
580 | - '%s',//PMD_admin_desc |
|
581 | - '%s',//PMD_slug |
|
582 | - '%d',//PMD_wp_user |
|
583 | - '%s',//PMD_scope |
|
584 | - ) |
|
585 | - ); |
|
586 | - if ( ! $success) { |
|
587 | - $this->add_error(sprintf(__("Could not insert new admin-only payment method with values %s during migration", |
|
588 | - "event_espresso"), $this->_json_encode($values))); |
|
589 | - } |
|
590 | - } |
|
591 | - } |
|
592 | - } |
|
593 | - } |
|
594 | - |
|
595 | - |
|
596 | - |
|
597 | - /** |
|
598 | - * insert_default_countries |
|
599 | - * |
|
600 | - * @static |
|
601 | - * @return void |
|
602 | - */ |
|
603 | - public function insert_default_currencies() |
|
604 | - { |
|
605 | - global $wpdb; |
|
606 | - $currency_table = $wpdb->prefix . "esp_currency"; |
|
607 | - if ($this->_get_table_analysis()->tableExists($currency_table)) { |
|
608 | - $SQL = "SELECT COUNT('CUR_code') FROM $currency_table"; |
|
609 | - $countries = $wpdb->get_var($SQL); |
|
610 | - if ( ! $countries) { |
|
611 | - $SQL = "INSERT INTO $currency_table |
|
499 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
500 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
501 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
502 | + //(because many need to convert old string states to foreign keys into the states table) |
|
503 | + $script_4_1_defaults->insert_default_states(); |
|
504 | + $script_4_1_defaults->insert_default_countries(); |
|
505 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
506 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
507 | + $script_4_5_defaults->insert_default_price_types(); |
|
508 | + $script_4_5_defaults->insert_default_prices(); |
|
509 | + $script_4_5_defaults->insert_default_tickets(); |
|
510 | + //setting up the config wp option pretty well counts as a 'schema change', or at least should happen here |
|
511 | + EE_Config::instance()->update_espresso_config(false, true); |
|
512 | + $this->add_default_admin_only_payments(); |
|
513 | + $this->insert_default_currencies(); |
|
514 | + return true; |
|
515 | + } |
|
516 | + |
|
517 | + |
|
518 | + |
|
519 | + /** |
|
520 | + * @return boolean |
|
521 | + */ |
|
522 | + public function schema_changes_after_migration() |
|
523 | + { |
|
524 | + return true; |
|
525 | + } |
|
526 | + |
|
527 | + |
|
528 | + |
|
529 | + public function migration_page_hooks() |
|
530 | + { |
|
531 | + } |
|
532 | + |
|
533 | + |
|
534 | + |
|
535 | + public function add_default_admin_only_payments() |
|
536 | + { |
|
537 | + global $wpdb; |
|
538 | + $table_name = $wpdb->prefix . "esp_payment_method"; |
|
539 | + $user_id = EEH_Activation::get_default_creator_id(); |
|
540 | + if ($this->_get_table_analysis()->tableExists($table_name)) { |
|
541 | + $SQL = "SELECT COUNT( * ) FROM $table_name"; |
|
542 | + $existing_payment_methods = $wpdb->get_var($SQL); |
|
543 | + $default_admin_only_payment_methods = apply_filters( |
|
544 | + 'FHEE__EEH_Activation__add_default_admin_only_payments__default_admin_only_payment_methods', |
|
545 | + array( |
|
546 | + __("Bank", 'event_espresso') => __("Bank Draft", 'event_espresso'), |
|
547 | + __("Cash", 'event_espresso') => __("Cash Delivered Physically", 'event_espresso'), |
|
548 | + __("Check", 'event_espresso') => __("Paper Check", 'event_espresso'), |
|
549 | + __("Credit Card", 'event_espresso') => __("Offline Credit Card Payment", 'event_espresso'), |
|
550 | + __("Debit Card", 'event_espresso') => __("Offline Debit Payment", 'event_espresso'), |
|
551 | + __("Invoice", 'event_espresso') => __("Invoice received with monies included", |
|
552 | + 'event_espresso'), |
|
553 | + __("Money Order", 'event_espresso') => '', |
|
554 | + __("Paypal", 'event_espresso') => __("Paypal eCheck, Invoice, etc", 'event_espresso'), |
|
555 | + __('Other', 'event_espresso') => __('Other method of payment', 'event_espresso'), |
|
556 | + )); |
|
557 | + //make sure we hae payment method records for the following |
|
558 | + //so admins can record payments for them from the admin page |
|
559 | + foreach ($default_admin_only_payment_methods as $nicename => $description) { |
|
560 | + $slug = sanitize_key($nicename); |
|
561 | + //check that such a payment method exists |
|
562 | + $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug)); |
|
563 | + if ( ! $exists) { |
|
564 | + $values = array( |
|
565 | + 'PMD_type' => 'Admin_Only', |
|
566 | + 'PMD_name' => $nicename, |
|
567 | + 'PMD_admin_name' => $nicename, |
|
568 | + 'PMD_admin_desc' => $description, |
|
569 | + 'PMD_slug' => $slug, |
|
570 | + 'PMD_wp_user' => $user_id, |
|
571 | + 'PMD_scope' => serialize(array('ADMIN')), |
|
572 | + ); |
|
573 | + $success = $wpdb->insert( |
|
574 | + $table_name, |
|
575 | + $values, |
|
576 | + array( |
|
577 | + '%s',//PMD_type |
|
578 | + '%s',//PMD_name |
|
579 | + '%s',//PMD_admin_name |
|
580 | + '%s',//PMD_admin_desc |
|
581 | + '%s',//PMD_slug |
|
582 | + '%d',//PMD_wp_user |
|
583 | + '%s',//PMD_scope |
|
584 | + ) |
|
585 | + ); |
|
586 | + if ( ! $success) { |
|
587 | + $this->add_error(sprintf(__("Could not insert new admin-only payment method with values %s during migration", |
|
588 | + "event_espresso"), $this->_json_encode($values))); |
|
589 | + } |
|
590 | + } |
|
591 | + } |
|
592 | + } |
|
593 | + } |
|
594 | + |
|
595 | + |
|
596 | + |
|
597 | + /** |
|
598 | + * insert_default_countries |
|
599 | + * |
|
600 | + * @static |
|
601 | + * @return void |
|
602 | + */ |
|
603 | + public function insert_default_currencies() |
|
604 | + { |
|
605 | + global $wpdb; |
|
606 | + $currency_table = $wpdb->prefix . "esp_currency"; |
|
607 | + if ($this->_get_table_analysis()->tableExists($currency_table)) { |
|
608 | + $SQL = "SELECT COUNT('CUR_code') FROM $currency_table"; |
|
609 | + $countries = $wpdb->get_var($SQL); |
|
610 | + if ( ! $countries) { |
|
611 | + $SQL = "INSERT INTO $currency_table |
|
612 | 612 | ( CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active) VALUES |
613 | 613 | ( 'EUR', 'Euro', 'Euros', '€', 2,1), |
614 | 614 | ( 'AED', 'Dirham', 'Dirhams', 'د.إ',2,1), |
@@ -762,10 +762,10 @@ discard block |
||
762 | 762 | ( 'ZAR', 'Rand', 'Rands', 'R', 2,1), |
763 | 763 | ( 'ZMK', 'Kwacha', 'Kwachas', '', 2,1), |
764 | 764 | ( 'ZWD', 'Dollar', 'Dollars', 'Z$', 2,1);"; |
765 | - $wpdb->query($SQL); |
|
766 | - } |
|
767 | - } |
|
768 | - } |
|
765 | + $wpdb->query($SQL); |
|
766 | + } |
|
767 | + } |
|
768 | + } |
|
769 | 769 | |
770 | 770 | } |
771 | 771 |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @param array $query_params like EEM_Base::get_all |
207 | 207 | * @param string $field_to_sum |
208 | - * @return int |
|
208 | + * @return double |
|
209 | 209 | */ |
210 | 210 | public function sum_deleted($query_params = null, $field_to_sum = null) |
211 | 211 | { |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
271 | 271 | * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
272 | 272 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
273 | - * @return boolean success |
|
273 | + * @return integer success |
|
274 | 274 | */ |
275 | 275 | public function delete_permanently($query_params = array(), $allow_blocking = true) |
276 | 276 | { |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | require_once(EE_MODELS . 'EEM_Base.model.php'); |
5 | 5 | |
@@ -32,362 +32,362 @@ discard block |
||
32 | 32 | abstract class EEM_Soft_Delete_Base extends EEM_Base |
33 | 33 | { |
34 | 34 | |
35 | - /** |
|
36 | - * @param null $timezone |
|
37 | - */ |
|
38 | - protected function __construct($timezone = null) |
|
39 | - { |
|
40 | - if (! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
41 | - $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions(); |
|
42 | - } |
|
43 | - parent::__construct($timezone); |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * Searches for field on this model of type 'deleted_flag'. if it is found, |
|
50 | - * returns it's name. |
|
51 | - * |
|
52 | - * @return string |
|
53 | - * @throws EE_Error |
|
54 | - */ |
|
55 | - public function deleted_field_name() |
|
56 | - { |
|
57 | - $field = $this->get_a_field_of_type('EE_Trashed_Flag_Field'); |
|
58 | - if ($field) { |
|
59 | - return $field->get_name(); |
|
60 | - } else { |
|
61 | - throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', |
|
62 | - 'event_espresso'), get_class($this), get_class($this))); |
|
63 | - } |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * Gets one item that's been deleted, according to $query_params |
|
70 | - * |
|
71 | - * @param array $query_params like EEM_Base::get_all's $query_params |
|
72 | - * @return EE_Soft_Delete_Base_Class |
|
73 | - */ |
|
74 | - public function get_one_deleted($query_params = array()) |
|
75 | - { |
|
76 | - $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
77 | - return parent::get_one($query_params); |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * Gets one item from the DB, regardless of whether it's been soft-deleted or not |
|
84 | - * |
|
85 | - * @param array $query_params like EEM_base::get_all's $query_params |
|
86 | - * @return EE_Soft_Delete_Base_Class |
|
87 | - */ |
|
88 | - public function get_one_deleted_or_undeleted($query_params = array()) |
|
89 | - { |
|
90 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
91 | - return parent::get_one($query_params); |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * Gets the item indicated by its ID. But if it's soft-deleted, pretends it doesn't exist. |
|
98 | - * |
|
99 | - * @param int|string $id |
|
100 | - * @return EE_Soft_Delete_Base_Class |
|
101 | - */ |
|
102 | - public function get_one_by_ID_but_ignore_deleted($id) |
|
103 | - { |
|
104 | - return $this->get_one( |
|
105 | - $this->alter_query_params_to_restrict_by_ID( |
|
106 | - $id, |
|
107 | - array('default_where_conditions' => 'default') |
|
108 | - ) |
|
109 | - ); |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * Counts all the deleted/trashed items |
|
116 | - * |
|
117 | - * @param array $query_params like EEM_Base::get_all |
|
118 | - * @param string $field_to_count |
|
119 | - * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
|
120 | - * @return int |
|
121 | - */ |
|
122 | - public function count_deleted($query_params = null, $field_to_count = null, $distinct = false) |
|
123 | - { |
|
124 | - $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
125 | - return parent::count($query_params, $field_to_count, $distinct); |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * Alters the query params so that only trashed/soft-deleted items are considered |
|
132 | - * |
|
133 | - * @param array $query_params like EEM_Base::get_all's $query_params |
|
134 | - * @return array like EEM_Base::get_all's $query_params |
|
135 | - */ |
|
136 | - protected function _alter_query_params_so_only_trashed_items_included($query_params) |
|
137 | - { |
|
138 | - $deletedFlagFieldName = $this->deleted_field_name(); |
|
139 | - $query_params[0][$deletedFlagFieldName] = true; |
|
140 | - return $query_params; |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - |
|
145 | - /** |
|
146 | - * Alters the query params so that only trashed/soft-deleted items are considered |
|
147 | - * |
|
148 | - * @param array $query_params like EEM_Base::get_all's $query_params |
|
149 | - * @return array like EEM_Base::get_all's $query_params |
|
150 | - */ |
|
151 | - public function alter_query_params_so_only_trashed_items_included($query_params) |
|
152 | - { |
|
153 | - return $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
154 | - } |
|
155 | - |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * Alters the query params so each item's deleted status is ignored. |
|
160 | - * |
|
161 | - * @param array $query_params |
|
162 | - * @return array |
|
163 | - */ |
|
164 | - public function alter_query_params_so_deleted_and_undeleted_items_included($query_params = array()) |
|
165 | - { |
|
166 | - return $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * Alters the query params so each item's deleted status is ignored. |
|
173 | - * |
|
174 | - * @param array $query_params |
|
175 | - * @return array |
|
176 | - */ |
|
177 | - protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) |
|
178 | - { |
|
179 | - if (! isset($query_params['default_where_conditions'])) { |
|
180 | - $query_params['default_where_conditions'] = 'minimum'; |
|
181 | - } |
|
182 | - return $query_params; |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - |
|
187 | - /** |
|
188 | - * Counts all deleted and undeleted items |
|
189 | - * |
|
190 | - * @param array $query_params like EEM_Base::get_all |
|
191 | - * @param string $field_to_count |
|
192 | - * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
|
193 | - * @return int |
|
194 | - */ |
|
195 | - public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = false) |
|
196 | - { |
|
197 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
198 | - return parent::count($query_params, $field_to_count, $distinct); |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - |
|
203 | - /** |
|
204 | - * Sum all the deleted items. |
|
205 | - * |
|
206 | - * @param array $query_params like EEM_Base::get_all |
|
207 | - * @param string $field_to_sum |
|
208 | - * @return int |
|
209 | - */ |
|
210 | - public function sum_deleted($query_params = null, $field_to_sum = null) |
|
211 | - { |
|
212 | - $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
213 | - return parent::sum($query_params, $field_to_sum); |
|
214 | - } |
|
215 | - |
|
216 | - |
|
217 | - |
|
218 | - /** |
|
219 | - * Sums all the deleted and undeleted items. |
|
220 | - * |
|
221 | - * @param array $query_params lik eEEM_Base::get_all |
|
222 | - * @param string $field_to_sum |
|
223 | - * @return int |
|
224 | - */ |
|
225 | - public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null) |
|
226 | - { |
|
227 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
228 | - parent::sum($query_params, $field_to_sum); |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - |
|
233 | - /** |
|
234 | - * Gets all deleted and undeleted mode objects from the db that meet the criteria, regardless of |
|
235 | - * whether they've been soft-deleted or not |
|
236 | - * |
|
237 | - * @param array $query_params like EEM_Base::get_all |
|
238 | - * @return EE_Soft_Delete_Base_Class[] |
|
239 | - */ |
|
240 | - public function get_all_deleted_and_undeleted($query_params = array()) |
|
241 | - { |
|
242 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
243 | - return parent::get_all($query_params); |
|
244 | - } |
|
245 | - |
|
246 | - |
|
247 | - |
|
248 | - /** |
|
249 | - * For 'soft deletable' models, gets all which ARE deleted, according to conditions specified in $query_params. |
|
250 | - * |
|
251 | - * @param array $query_params like EEM_Base::get_all |
|
252 | - * @return EE_Soft_Delete_Base_Class[] |
|
253 | - */ |
|
254 | - public function get_all_deleted($query_params = array()) |
|
255 | - { |
|
256 | - $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
257 | - return parent::get_all($query_params); |
|
258 | - } |
|
259 | - |
|
260 | - |
|
261 | - |
|
262 | - /** |
|
263 | - * Permanently deletes the selected rows. When selecting rows for deletion, ignores |
|
264 | - * whether they've been soft-deleted or not. (ie, you don't have to soft-delete objects |
|
265 | - * before you can permanently delete them). |
|
266 | - * Because this will cause a real deletion, related models may block this deletion (ie, add an error |
|
267 | - * and abort the delete) |
|
268 | - * |
|
269 | - * @param array $query_params like EEM_Base::get_all |
|
270 | - * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
|
271 | - * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
|
272 | - * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
|
273 | - * @return boolean success |
|
274 | - */ |
|
275 | - public function delete_permanently($query_params = array(), $allow_blocking = true) |
|
276 | - { |
|
277 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
278 | - return parent::delete_permanently($query_params, $allow_blocking); |
|
279 | - } |
|
280 | - |
|
281 | - |
|
282 | - |
|
283 | - /** |
|
284 | - * Restores a particular item by its ID (primary key). Ignores the fact whether the item |
|
285 | - * has been soft-deleted or not. |
|
286 | - * |
|
287 | - * @param mixed $ID int if primary key is an int, string otherwise |
|
288 | - * @return boolean success |
|
289 | - */ |
|
290 | - public function restore_by_ID($ID = false) |
|
291 | - { |
|
292 | - return $this->delete_or_restore_by_ID(false, $ID); |
|
293 | - } |
|
294 | - |
|
295 | - |
|
296 | - |
|
297 | - /** |
|
298 | - * For deleting or restoring a particular item. Note that this model is a SOFT-DELETABLE model! However, |
|
299 | - * this function will ignore whether the items have been soft-deleted or not. |
|
300 | - * |
|
301 | - * @param boolean $delete true for delete, false for restore |
|
302 | - * @param mixed $ID int if primary key is an int, string otherwise |
|
303 | - * @return boolean |
|
304 | - */ |
|
305 | - public function delete_or_restore_by_ID($delete = true, $ID = false) |
|
306 | - { |
|
307 | - if (! $ID) { |
|
308 | - return false; |
|
309 | - } |
|
310 | - if ( |
|
311 | - $this->delete_or_restore( |
|
312 | - $delete, |
|
313 | - $this->alter_query_params_to_restrict_by_ID($ID) |
|
314 | - ) |
|
315 | - ) { |
|
316 | - return true; |
|
317 | - } else { |
|
318 | - return false; |
|
319 | - } |
|
320 | - } |
|
321 | - |
|
322 | - |
|
323 | - |
|
324 | - /** |
|
325 | - * Overrides parent's 'delete' method to instead do a soft delete on all rows that |
|
326 | - * meet the criteria in $where_col_n_values. This particular function ignores whether the items have been soft-deleted or not. |
|
327 | - * Note: because this item will be soft-deleted only, |
|
328 | - * doesn't block because of model dependencies |
|
329 | - * |
|
330 | - * @param array $query_params like EEM_Base::get_all |
|
331 | - * @param bool $block_deletes |
|
332 | - * @return boolean |
|
333 | - */ |
|
334 | - public function delete($query_params = array(), $block_deletes = false) |
|
335 | - { |
|
336 | - //no matter what, we WON'T block soft deletes. |
|
337 | - return $this->delete_or_restore(true, $query_params); |
|
338 | - } |
|
339 | - |
|
340 | - |
|
341 | - |
|
342 | - /** |
|
343 | - * 'Un-deletes' the chosen items. Note that this model is a SOFT-DELETABLE model! That means that, by default, trashed/soft-deleted |
|
344 | - * items are ignored in queries. However, this particular function ignores whether the items have been soft-deleted or not. |
|
345 | - * |
|
346 | - * @param array $query_params like EEM_Base::get_all |
|
347 | - * @return boolean |
|
348 | - */ |
|
349 | - public function restore($query_params = array()) |
|
350 | - { |
|
351 | - return $this->delete_or_restore(false, $query_params); |
|
352 | - } |
|
353 | - |
|
354 | - |
|
355 | - |
|
356 | - /** |
|
357 | - * Performs deletes or restores on items. Both soft-deleted and non-soft-deleted items considered. |
|
358 | - * |
|
359 | - * @param boolean $delete true to indicate deletion, false to indicate restoration |
|
360 | - * @param array $query_params like EEM_Base::get_all |
|
361 | - * @return boolean |
|
362 | - */ |
|
363 | - function delete_or_restore($delete = true, $query_params = array()) |
|
364 | - { |
|
365 | - $deletedFlagFieldName = $this->deleted_field_name(); |
|
366 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
367 | - if ($this->update(array($deletedFlagFieldName => $delete), $query_params)) { |
|
368 | - return true; |
|
369 | - } else { |
|
370 | - return false; |
|
371 | - } |
|
372 | - } |
|
373 | - |
|
374 | - |
|
375 | - |
|
376 | - /** |
|
377 | - * Updates all the items of this model which match the $query params, regardless of whether |
|
378 | - * they've been soft-deleted or not |
|
379 | - * |
|
380 | - * @param array $fields_n_values like EEM_Base::update's $fields_n_value |
|
381 | - * @param array $query_params like EEM_base::get_all's $query_params |
|
382 | - * @param boolean $keep_model_objs_in_sync if TRUE, makes sure we ALSO update model objects |
|
383 | - * in this model's entity map according to $fields_n_values that match $query_params. This |
|
384 | - * obviously has some overhead, so you can disable it by setting this to FALSE, but |
|
385 | - * be aware that model objects being used could get out-of-sync with the database |
|
386 | - * @return int number of items updated |
|
387 | - */ |
|
388 | - public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = true) |
|
389 | - { |
|
390 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
391 | - return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
392 | - } |
|
35 | + /** |
|
36 | + * @param null $timezone |
|
37 | + */ |
|
38 | + protected function __construct($timezone = null) |
|
39 | + { |
|
40 | + if (! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
41 | + $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions(); |
|
42 | + } |
|
43 | + parent::__construct($timezone); |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * Searches for field on this model of type 'deleted_flag'. if it is found, |
|
50 | + * returns it's name. |
|
51 | + * |
|
52 | + * @return string |
|
53 | + * @throws EE_Error |
|
54 | + */ |
|
55 | + public function deleted_field_name() |
|
56 | + { |
|
57 | + $field = $this->get_a_field_of_type('EE_Trashed_Flag_Field'); |
|
58 | + if ($field) { |
|
59 | + return $field->get_name(); |
|
60 | + } else { |
|
61 | + throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', |
|
62 | + 'event_espresso'), get_class($this), get_class($this))); |
|
63 | + } |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * Gets one item that's been deleted, according to $query_params |
|
70 | + * |
|
71 | + * @param array $query_params like EEM_Base::get_all's $query_params |
|
72 | + * @return EE_Soft_Delete_Base_Class |
|
73 | + */ |
|
74 | + public function get_one_deleted($query_params = array()) |
|
75 | + { |
|
76 | + $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
77 | + return parent::get_one($query_params); |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * Gets one item from the DB, regardless of whether it's been soft-deleted or not |
|
84 | + * |
|
85 | + * @param array $query_params like EEM_base::get_all's $query_params |
|
86 | + * @return EE_Soft_Delete_Base_Class |
|
87 | + */ |
|
88 | + public function get_one_deleted_or_undeleted($query_params = array()) |
|
89 | + { |
|
90 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
91 | + return parent::get_one($query_params); |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * Gets the item indicated by its ID. But if it's soft-deleted, pretends it doesn't exist. |
|
98 | + * |
|
99 | + * @param int|string $id |
|
100 | + * @return EE_Soft_Delete_Base_Class |
|
101 | + */ |
|
102 | + public function get_one_by_ID_but_ignore_deleted($id) |
|
103 | + { |
|
104 | + return $this->get_one( |
|
105 | + $this->alter_query_params_to_restrict_by_ID( |
|
106 | + $id, |
|
107 | + array('default_where_conditions' => 'default') |
|
108 | + ) |
|
109 | + ); |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * Counts all the deleted/trashed items |
|
116 | + * |
|
117 | + * @param array $query_params like EEM_Base::get_all |
|
118 | + * @param string $field_to_count |
|
119 | + * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
|
120 | + * @return int |
|
121 | + */ |
|
122 | + public function count_deleted($query_params = null, $field_to_count = null, $distinct = false) |
|
123 | + { |
|
124 | + $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
125 | + return parent::count($query_params, $field_to_count, $distinct); |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * Alters the query params so that only trashed/soft-deleted items are considered |
|
132 | + * |
|
133 | + * @param array $query_params like EEM_Base::get_all's $query_params |
|
134 | + * @return array like EEM_Base::get_all's $query_params |
|
135 | + */ |
|
136 | + protected function _alter_query_params_so_only_trashed_items_included($query_params) |
|
137 | + { |
|
138 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
139 | + $query_params[0][$deletedFlagFieldName] = true; |
|
140 | + return $query_params; |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + |
|
145 | + /** |
|
146 | + * Alters the query params so that only trashed/soft-deleted items are considered |
|
147 | + * |
|
148 | + * @param array $query_params like EEM_Base::get_all's $query_params |
|
149 | + * @return array like EEM_Base::get_all's $query_params |
|
150 | + */ |
|
151 | + public function alter_query_params_so_only_trashed_items_included($query_params) |
|
152 | + { |
|
153 | + return $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
154 | + } |
|
155 | + |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * Alters the query params so each item's deleted status is ignored. |
|
160 | + * |
|
161 | + * @param array $query_params |
|
162 | + * @return array |
|
163 | + */ |
|
164 | + public function alter_query_params_so_deleted_and_undeleted_items_included($query_params = array()) |
|
165 | + { |
|
166 | + return $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * Alters the query params so each item's deleted status is ignored. |
|
173 | + * |
|
174 | + * @param array $query_params |
|
175 | + * @return array |
|
176 | + */ |
|
177 | + protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) |
|
178 | + { |
|
179 | + if (! isset($query_params['default_where_conditions'])) { |
|
180 | + $query_params['default_where_conditions'] = 'minimum'; |
|
181 | + } |
|
182 | + return $query_params; |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + |
|
187 | + /** |
|
188 | + * Counts all deleted and undeleted items |
|
189 | + * |
|
190 | + * @param array $query_params like EEM_Base::get_all |
|
191 | + * @param string $field_to_count |
|
192 | + * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
|
193 | + * @return int |
|
194 | + */ |
|
195 | + public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = false) |
|
196 | + { |
|
197 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
198 | + return parent::count($query_params, $field_to_count, $distinct); |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + |
|
203 | + /** |
|
204 | + * Sum all the deleted items. |
|
205 | + * |
|
206 | + * @param array $query_params like EEM_Base::get_all |
|
207 | + * @param string $field_to_sum |
|
208 | + * @return int |
|
209 | + */ |
|
210 | + public function sum_deleted($query_params = null, $field_to_sum = null) |
|
211 | + { |
|
212 | + $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
213 | + return parent::sum($query_params, $field_to_sum); |
|
214 | + } |
|
215 | + |
|
216 | + |
|
217 | + |
|
218 | + /** |
|
219 | + * Sums all the deleted and undeleted items. |
|
220 | + * |
|
221 | + * @param array $query_params lik eEEM_Base::get_all |
|
222 | + * @param string $field_to_sum |
|
223 | + * @return int |
|
224 | + */ |
|
225 | + public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null) |
|
226 | + { |
|
227 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
228 | + parent::sum($query_params, $field_to_sum); |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + |
|
233 | + /** |
|
234 | + * Gets all deleted and undeleted mode objects from the db that meet the criteria, regardless of |
|
235 | + * whether they've been soft-deleted or not |
|
236 | + * |
|
237 | + * @param array $query_params like EEM_Base::get_all |
|
238 | + * @return EE_Soft_Delete_Base_Class[] |
|
239 | + */ |
|
240 | + public function get_all_deleted_and_undeleted($query_params = array()) |
|
241 | + { |
|
242 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
243 | + return parent::get_all($query_params); |
|
244 | + } |
|
245 | + |
|
246 | + |
|
247 | + |
|
248 | + /** |
|
249 | + * For 'soft deletable' models, gets all which ARE deleted, according to conditions specified in $query_params. |
|
250 | + * |
|
251 | + * @param array $query_params like EEM_Base::get_all |
|
252 | + * @return EE_Soft_Delete_Base_Class[] |
|
253 | + */ |
|
254 | + public function get_all_deleted($query_params = array()) |
|
255 | + { |
|
256 | + $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
257 | + return parent::get_all($query_params); |
|
258 | + } |
|
259 | + |
|
260 | + |
|
261 | + |
|
262 | + /** |
|
263 | + * Permanently deletes the selected rows. When selecting rows for deletion, ignores |
|
264 | + * whether they've been soft-deleted or not. (ie, you don't have to soft-delete objects |
|
265 | + * before you can permanently delete them). |
|
266 | + * Because this will cause a real deletion, related models may block this deletion (ie, add an error |
|
267 | + * and abort the delete) |
|
268 | + * |
|
269 | + * @param array $query_params like EEM_Base::get_all |
|
270 | + * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
|
271 | + * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
|
272 | + * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
|
273 | + * @return boolean success |
|
274 | + */ |
|
275 | + public function delete_permanently($query_params = array(), $allow_blocking = true) |
|
276 | + { |
|
277 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
278 | + return parent::delete_permanently($query_params, $allow_blocking); |
|
279 | + } |
|
280 | + |
|
281 | + |
|
282 | + |
|
283 | + /** |
|
284 | + * Restores a particular item by its ID (primary key). Ignores the fact whether the item |
|
285 | + * has been soft-deleted or not. |
|
286 | + * |
|
287 | + * @param mixed $ID int if primary key is an int, string otherwise |
|
288 | + * @return boolean success |
|
289 | + */ |
|
290 | + public function restore_by_ID($ID = false) |
|
291 | + { |
|
292 | + return $this->delete_or_restore_by_ID(false, $ID); |
|
293 | + } |
|
294 | + |
|
295 | + |
|
296 | + |
|
297 | + /** |
|
298 | + * For deleting or restoring a particular item. Note that this model is a SOFT-DELETABLE model! However, |
|
299 | + * this function will ignore whether the items have been soft-deleted or not. |
|
300 | + * |
|
301 | + * @param boolean $delete true for delete, false for restore |
|
302 | + * @param mixed $ID int if primary key is an int, string otherwise |
|
303 | + * @return boolean |
|
304 | + */ |
|
305 | + public function delete_or_restore_by_ID($delete = true, $ID = false) |
|
306 | + { |
|
307 | + if (! $ID) { |
|
308 | + return false; |
|
309 | + } |
|
310 | + if ( |
|
311 | + $this->delete_or_restore( |
|
312 | + $delete, |
|
313 | + $this->alter_query_params_to_restrict_by_ID($ID) |
|
314 | + ) |
|
315 | + ) { |
|
316 | + return true; |
|
317 | + } else { |
|
318 | + return false; |
|
319 | + } |
|
320 | + } |
|
321 | + |
|
322 | + |
|
323 | + |
|
324 | + /** |
|
325 | + * Overrides parent's 'delete' method to instead do a soft delete on all rows that |
|
326 | + * meet the criteria in $where_col_n_values. This particular function ignores whether the items have been soft-deleted or not. |
|
327 | + * Note: because this item will be soft-deleted only, |
|
328 | + * doesn't block because of model dependencies |
|
329 | + * |
|
330 | + * @param array $query_params like EEM_Base::get_all |
|
331 | + * @param bool $block_deletes |
|
332 | + * @return boolean |
|
333 | + */ |
|
334 | + public function delete($query_params = array(), $block_deletes = false) |
|
335 | + { |
|
336 | + //no matter what, we WON'T block soft deletes. |
|
337 | + return $this->delete_or_restore(true, $query_params); |
|
338 | + } |
|
339 | + |
|
340 | + |
|
341 | + |
|
342 | + /** |
|
343 | + * 'Un-deletes' the chosen items. Note that this model is a SOFT-DELETABLE model! That means that, by default, trashed/soft-deleted |
|
344 | + * items are ignored in queries. However, this particular function ignores whether the items have been soft-deleted or not. |
|
345 | + * |
|
346 | + * @param array $query_params like EEM_Base::get_all |
|
347 | + * @return boolean |
|
348 | + */ |
|
349 | + public function restore($query_params = array()) |
|
350 | + { |
|
351 | + return $this->delete_or_restore(false, $query_params); |
|
352 | + } |
|
353 | + |
|
354 | + |
|
355 | + |
|
356 | + /** |
|
357 | + * Performs deletes or restores on items. Both soft-deleted and non-soft-deleted items considered. |
|
358 | + * |
|
359 | + * @param boolean $delete true to indicate deletion, false to indicate restoration |
|
360 | + * @param array $query_params like EEM_Base::get_all |
|
361 | + * @return boolean |
|
362 | + */ |
|
363 | + function delete_or_restore($delete = true, $query_params = array()) |
|
364 | + { |
|
365 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
366 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
367 | + if ($this->update(array($deletedFlagFieldName => $delete), $query_params)) { |
|
368 | + return true; |
|
369 | + } else { |
|
370 | + return false; |
|
371 | + } |
|
372 | + } |
|
373 | + |
|
374 | + |
|
375 | + |
|
376 | + /** |
|
377 | + * Updates all the items of this model which match the $query params, regardless of whether |
|
378 | + * they've been soft-deleted or not |
|
379 | + * |
|
380 | + * @param array $fields_n_values like EEM_Base::update's $fields_n_value |
|
381 | + * @param array $query_params like EEM_base::get_all's $query_params |
|
382 | + * @param boolean $keep_model_objs_in_sync if TRUE, makes sure we ALSO update model objects |
|
383 | + * in this model's entity map according to $fields_n_values that match $query_params. This |
|
384 | + * obviously has some overhead, so you can disable it by setting this to FALSE, but |
|
385 | + * be aware that model objects being used could get out-of-sync with the database |
|
386 | + * @return int number of items updated |
|
387 | + */ |
|
388 | + public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = true) |
|
389 | + { |
|
390 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
391 | + return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
392 | + } |
|
393 | 393 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | -require_once(EE_MODELS . 'EEM_Base.model.php'); |
|
4 | +require_once(EE_MODELS.'EEM_Base.model.php'); |
|
5 | 5 | |
6 | 6 | |
7 | 7 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | protected function __construct($timezone = null) |
39 | 39 | { |
40 | - if (! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
40 | + if ( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
41 | 41 | $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions(); |
42 | 42 | } |
43 | 43 | parent::__construct($timezone); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) |
178 | 178 | { |
179 | - if (! isset($query_params['default_where_conditions'])) { |
|
179 | + if ( ! isset($query_params['default_where_conditions'])) { |
|
180 | 180 | $query_params['default_where_conditions'] = 'minimum'; |
181 | 181 | } |
182 | 182 | return $query_params; |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | */ |
305 | 305 | public function delete_or_restore_by_ID($delete = true, $ID = false) |
306 | 306 | { |
307 | - if (! $ID) { |
|
307 | + if ( ! $ID) { |
|
308 | 308 | return false; |
309 | 309 | } |
310 | 310 | if ( |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -26,55 +26,55 @@ discard block |
||
26 | 26 | { |
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * Overrides parent _delete() so that we do soft deletes. |
|
31 | - * |
|
32 | - * @return bool|int |
|
33 | - */ |
|
34 | - protected function _delete() |
|
35 | - { |
|
36 | - return $this->delete_or_restore(); |
|
37 | - } |
|
29 | + /** |
|
30 | + * Overrides parent _delete() so that we do soft deletes. |
|
31 | + * |
|
32 | + * @return bool|int |
|
33 | + */ |
|
34 | + protected function _delete() |
|
35 | + { |
|
36 | + return $this->delete_or_restore(); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * Deletes or restores this object. |
|
43 | - * |
|
44 | - * @param bool $delete true=>delete, false=>restore |
|
45 | - * @return bool|int |
|
46 | - */ |
|
47 | - public function delete_or_restore($delete = true) |
|
48 | - { |
|
49 | - /** |
|
50 | - * Called just before trashing (soft delete) or restoring a trashed item. |
|
51 | - * |
|
52 | - * @param EE_Base_Class $model_object about to be trashed or restored |
|
53 | - * @param bool $delete true the item is being trashed, false the item is being restored. |
|
54 | - */ |
|
55 | - do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__before', $this, $delete); |
|
56 | - $model = $this->get_model(); |
|
57 | - $result = $model->delete_or_restore_by_ID($delete, $this->ID()); |
|
58 | - /** |
|
59 | - * Called just after trashing (soft delete) or restoring a trashed item. |
|
60 | - * |
|
61 | - * @param EE_Base_Class $model_object that was just trashed or restored. |
|
62 | - * @param bool $delete true the item is being trashed, false the item is being restored. |
|
63 | - * @param bool|int $result |
|
64 | - */ |
|
65 | - do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__after', $this, $delete, $result); |
|
66 | - return $result; |
|
67 | - } |
|
41 | + /** |
|
42 | + * Deletes or restores this object. |
|
43 | + * |
|
44 | + * @param bool $delete true=>delete, false=>restore |
|
45 | + * @return bool|int |
|
46 | + */ |
|
47 | + public function delete_or_restore($delete = true) |
|
48 | + { |
|
49 | + /** |
|
50 | + * Called just before trashing (soft delete) or restoring a trashed item. |
|
51 | + * |
|
52 | + * @param EE_Base_Class $model_object about to be trashed or restored |
|
53 | + * @param bool $delete true the item is being trashed, false the item is being restored. |
|
54 | + */ |
|
55 | + do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__before', $this, $delete); |
|
56 | + $model = $this->get_model(); |
|
57 | + $result = $model->delete_or_restore_by_ID($delete, $this->ID()); |
|
58 | + /** |
|
59 | + * Called just after trashing (soft delete) or restoring a trashed item. |
|
60 | + * |
|
61 | + * @param EE_Base_Class $model_object that was just trashed or restored. |
|
62 | + * @param bool $delete true the item is being trashed, false the item is being restored. |
|
63 | + * @param bool|int $result |
|
64 | + */ |
|
65 | + do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__after', $this, $delete, $result); |
|
66 | + return $result; |
|
67 | + } |
|
68 | 68 | |
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * Performs a restoration (un-deletes) this object |
|
73 | - * |
|
74 | - * @return bool|int |
|
75 | - */ |
|
76 | - public function restore() |
|
77 | - { |
|
78 | - return $this->delete_or_restore(false); |
|
79 | - } |
|
71 | + /** |
|
72 | + * Performs a restoration (un-deletes) this object |
|
73 | + * |
|
74 | + * @return bool|int |
|
75 | + */ |
|
76 | + public function restore() |
|
77 | + { |
|
78 | + return $this->delete_or_restore(false); |
|
79 | + } |
|
80 | 80 | } |
81 | 81 | \ No newline at end of file |
@@ -1,4 +1,4 @@ |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | 4 | /** |
@@ -14,12 +14,12 @@ discard block |
||
14 | 14 | * @param int | \EE_Event $event |
15 | 15 | * @return bool |
16 | 16 | */ |
17 | -function is_espresso_event( $event = NULL ) { |
|
18 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
17 | +function is_espresso_event($event = NULL) { |
|
18 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
19 | 19 | // extract EE_Event object from passed param regardless of what it is (within reason of course) |
20 | - $event = EEH_Event_View::get_event( $event ); |
|
20 | + $event = EEH_Event_View::get_event($event); |
|
21 | 21 | // do we have a valid event ? |
22 | - return $event instanceof EE_Event ? TRUE : FALSE; |
|
22 | + return $event instanceof EE_Event ? TRUE : FALSE; |
|
23 | 23 | } |
24 | 24 | return FALSE; |
25 | 25 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @return bool |
32 | 32 | */ |
33 | 33 | function is_espresso_event_single() { |
34 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
34 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
35 | 35 | global $wp_query; |
36 | 36 | // return conditionals set by CPTs |
37 | 37 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_single : FALSE; |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @return bool |
47 | 47 | */ |
48 | 48 | function is_espresso_event_archive() { |
49 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
49 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
50 | 50 | global $wp_query; |
51 | 51 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_archive : FALSE; |
52 | 52 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @return bool |
61 | 61 | */ |
62 | 62 | function is_espresso_event_taxonomy() { |
63 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
63 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
64 | 64 | global $wp_query; |
65 | 65 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_taxonomy : FALSE; |
66 | 66 | } |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | * @param int | \EE_Venue $venue |
75 | 75 | * @return bool |
76 | 76 | */ |
77 | -function is_espresso_venue( $venue = NULL ) { |
|
78 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
77 | +function is_espresso_venue($venue = NULL) { |
|
78 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
79 | 79 | // extract EE_Venue object from passed param regardless of what it is (within reason of course) |
80 | - $venue = EEH_Venue_View::get_venue( $venue, FALSE ); |
|
80 | + $venue = EEH_Venue_View::get_venue($venue, FALSE); |
|
81 | 81 | // do we have a valid event ? |
82 | 82 | return $venue instanceof EE_Venue ? TRUE : FALSE; |
83 | 83 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @return bool |
92 | 92 | */ |
93 | 93 | function is_espresso_venue_single() { |
94 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
94 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
95 | 95 | global $wp_query; |
96 | 96 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_single : FALSE; |
97 | 97 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @return bool |
106 | 106 | */ |
107 | 107 | function is_espresso_venue_archive() { |
108 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
108 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
109 | 109 | global $wp_query; |
110 | 110 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_archive : FALSE; |
111 | 111 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @return bool |
120 | 120 | */ |
121 | 121 | function is_espresso_venue_taxonomy() { |
122 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
122 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
123 | 123 | global $wp_query; |
124 | 124 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_taxonomy : FALSE; |
125 | 125 | } |
@@ -133,12 +133,12 @@ discard block |
||
133 | 133 | * @param $conditional_tag |
134 | 134 | * @return bool |
135 | 135 | */ |
136 | -function can_use_espresso_conditionals( $conditional_tag ) { |
|
137 | - if ( ! did_action( 'AHEE__EE_System__initialize' )) { |
|
136 | +function can_use_espresso_conditionals($conditional_tag) { |
|
137 | + if ( ! did_action('AHEE__EE_System__initialize')) { |
|
138 | 138 | EE_Error::doing_it_wrong( |
139 | 139 | __FUNCTION__, |
140 | 140 | sprintf( |
141 | - __( 'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.','event_espresso'), |
|
141 | + __('The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.', 'event_espresso'), |
|
142 | 142 | $conditional_tag |
143 | 143 | ), |
144 | 144 | '4.4.0' |
@@ -153,13 +153,13 @@ discard block |
||
153 | 153 | |
154 | 154 | /*************************** Event Queries ***************************/ |
155 | 155 | |
156 | -if ( ! function_exists( 'espresso_get_events' )) { |
|
156 | +if ( ! function_exists('espresso_get_events')) { |
|
157 | 157 | /** |
158 | 158 | * espresso_get_events |
159 | 159 | * @param array $params |
160 | 160 | * @return array |
161 | 161 | */ |
162 | - function espresso_get_events( $params = array() ) { |
|
162 | + function espresso_get_events($params = array()) { |
|
163 | 163 | //set default params |
164 | 164 | $default_espresso_events_params = array( |
165 | 165 | 'limit' => 10, |
@@ -170,18 +170,18 @@ discard block |
||
170 | 170 | 'sort' => 'ASC' |
171 | 171 | ); |
172 | 172 | // allow the defaults to be filtered |
173 | - $default_espresso_events_params = apply_filters( 'espresso_get_events__default_espresso_events_params', $default_espresso_events_params ); |
|
173 | + $default_espresso_events_params = apply_filters('espresso_get_events__default_espresso_events_params', $default_espresso_events_params); |
|
174 | 174 | // grab params and merge with defaults, then extract |
175 | - $params = array_merge( $default_espresso_events_params, $params ); |
|
175 | + $params = array_merge($default_espresso_events_params, $params); |
|
176 | 176 | // run the query |
177 | - $events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery( $params ); |
|
177 | + $events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery($params); |
|
178 | 178 | // assign results to a variable so we can return it |
179 | 179 | $events = $events_query->have_posts() ? $events_query->posts : array(); |
180 | 180 | // but first reset the query and postdata |
181 | 181 | wp_reset_query(); |
182 | 182 | wp_reset_postdata(); |
183 | 183 | EED_Events_Archive::remove_all_events_archive_filters(); |
184 | - unset( $events_query ); |
|
184 | + unset($events_query); |
|
185 | 185 | return $events; |
186 | 186 | } |
187 | 187 | } |
@@ -195,32 +195,32 @@ discard block |
||
195 | 195 | * espresso_load_ticket_selector |
196 | 196 | */ |
197 | 197 | function espresso_load_ticket_selector() { |
198 | - EE_Registry::instance()->load_file( EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module' ); |
|
198 | + EE_Registry::instance()->load_file(EE_MODULES.'ticket_selector', 'EED_Ticket_Selector', 'module'); |
|
199 | 199 | } |
200 | 200 | |
201 | -if ( ! function_exists( 'espresso_ticket_selector' )) { |
|
201 | +if ( ! function_exists('espresso_ticket_selector')) { |
|
202 | 202 | /** |
203 | 203 | * espresso_ticket_selector |
204 | 204 | * @param null $event |
205 | 205 | */ |
206 | - function espresso_ticket_selector( $event = NULL ) { |
|
207 | - if ( ! apply_filters( 'FHEE_disable_espresso_ticket_selector', FALSE ) ) { |
|
206 | + function espresso_ticket_selector($event = NULL) { |
|
207 | + if ( ! apply_filters('FHEE_disable_espresso_ticket_selector', FALSE)) { |
|
208 | 208 | espresso_load_ticket_selector(); |
209 | - echo EED_Ticket_Selector::display_ticket_selector( $event ); |
|
209 | + echo EED_Ticket_Selector::display_ticket_selector($event); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | } |
213 | 213 | |
214 | 214 | |
215 | - if ( ! function_exists( 'espresso_view_details_btn' )) { |
|
215 | + if ( ! function_exists('espresso_view_details_btn')) { |
|
216 | 216 | /** |
217 | 217 | * espresso_view_details_btn |
218 | 218 | * @param null $event |
219 | 219 | */ |
220 | - function espresso_view_details_btn( $event = NULL ) { |
|
221 | - if ( ! apply_filters( 'FHEE_disable_espresso_view_details_btn', FALSE ) ) { |
|
220 | + function espresso_view_details_btn($event = NULL) { |
|
221 | + if ( ! apply_filters('FHEE_disable_espresso_view_details_btn', FALSE)) { |
|
222 | 222 | espresso_load_ticket_selector(); |
223 | - echo EED_Ticket_Selector::display_ticket_selector( $event, TRUE ); |
|
223 | + echo EED_Ticket_Selector::display_ticket_selector($event, TRUE); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | |
231 | 231 | /*************************** EEH_Event_View ***************************/ |
232 | 232 | |
233 | -if ( ! function_exists( 'espresso_load_event_list_assets' )) { |
|
233 | +if ( ! function_exists('espresso_load_event_list_assets')) { |
|
234 | 234 | /** |
235 | 235 | * espresso_load_event_list_assets |
236 | 236 | * ensures that event list styles and scripts are loaded |
@@ -239,13 +239,13 @@ discard block |
||
239 | 239 | */ |
240 | 240 | function espresso_load_event_list_assets() { |
241 | 241 | $event_list = EED_Events_Archive::instance(); |
242 | - add_action( 'AHEE__EE_System__initialize_last', array( $event_list, 'load_event_list_assets' ), 10 ); |
|
243 | - add_filter( 'FHEE_enable_default_espresso_css', '__return_true' ); |
|
242 | + add_action('AHEE__EE_System__initialize_last', array($event_list, 'load_event_list_assets'), 10); |
|
243 | + add_filter('FHEE_enable_default_espresso_css', '__return_true'); |
|
244 | 244 | } |
245 | 245 | } |
246 | 246 | |
247 | 247 | |
248 | -if ( ! function_exists( 'espresso_event_reg_button' )) { |
|
248 | +if ( ! function_exists('espresso_event_reg_button')) { |
|
249 | 249 | /** |
250 | 250 | * espresso_event_reg_button |
251 | 251 | * returns the "Register Now" button if event is active, |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | * @param bool $EVT_ID |
258 | 258 | * @return string |
259 | 259 | */ |
260 | - function espresso_event_reg_button( $btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE ) { |
|
261 | - $event_status = EEH_Event_View::event_active_status( $EVT_ID ); |
|
262 | - switch ( $event_status ) { |
|
260 | + function espresso_event_reg_button($btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE) { |
|
261 | + $event_status = EEH_Event_View::event_active_status($EVT_ID); |
|
262 | + switch ($event_status) { |
|
263 | 263 | case EE_Datetime::sold_out : |
264 | 264 | $btn_text = __('Sold Out', 'event_espresso'); |
265 | 265 | $class = 'ee-pink'; |
@@ -275,10 +275,10 @@ discard block |
||
275 | 275 | case EE_Datetime::upcoming : |
276 | 276 | case EE_Datetime::active : |
277 | 277 | default : |
278 | - $btn_text =! empty( $btn_text_if_active ) ? $btn_text_if_active : __( 'Register Now', 'event_espresso' ); |
|
278 | + $btn_text = ! empty($btn_text_if_active) ? $btn_text_if_active : __('Register Now', 'event_espresso'); |
|
279 | 279 | $class = 'ee-green'; |
280 | 280 | } |
281 | - if ( $event_status < 1 && ! empty( $btn_text_if_inactive )) { |
|
281 | + if ($event_status < 1 && ! empty($btn_text_if_inactive)) { |
|
282 | 282 | $btn_text = $btn_text_if_inactive; |
283 | 283 | $class = 'ee-grey'; |
284 | 284 | } |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | |
293 | 293 | |
294 | 294 | |
295 | -if ( ! function_exists( 'espresso_display_ticket_selector' )) { |
|
295 | +if ( ! function_exists('espresso_display_ticket_selector')) { |
|
296 | 296 | /** |
297 | 297 | * espresso_display_ticket_selector |
298 | 298 | * whether or not to display the Ticket Selector for an event |
@@ -300,14 +300,14 @@ discard block |
||
300 | 300 | * @param bool $EVT_ID |
301 | 301 | * @return boolean |
302 | 302 | */ |
303 | - function espresso_display_ticket_selector( $EVT_ID = FALSE ) { |
|
304 | - return EEH_Event_View::display_ticket_selector( $EVT_ID ); |
|
303 | + function espresso_display_ticket_selector($EVT_ID = FALSE) { |
|
304 | + return EEH_Event_View::display_ticket_selector($EVT_ID); |
|
305 | 305 | } |
306 | 306 | } |
307 | 307 | |
308 | 308 | |
309 | 309 | |
310 | -if ( ! function_exists( 'espresso_event_status_banner' )) { |
|
310 | +if ( ! function_exists('espresso_event_status_banner')) { |
|
311 | 311 | /** |
312 | 312 | * espresso_event_status |
313 | 313 | * returns a banner showing the event status if it is sold out, expired, or inactive |
@@ -315,13 +315,13 @@ discard block |
||
315 | 315 | * @param bool $EVT_ID |
316 | 316 | * @return string |
317 | 317 | */ |
318 | - function espresso_event_status_banner( $EVT_ID = FALSE ) { |
|
319 | - return EEH_Event_View::event_status( $EVT_ID ); |
|
318 | + function espresso_event_status_banner($EVT_ID = FALSE) { |
|
319 | + return EEH_Event_View::event_status($EVT_ID); |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
323 | 323 | |
324 | -if ( ! function_exists( 'espresso_event_status' )) { |
|
324 | +if ( ! function_exists('espresso_event_status')) { |
|
325 | 325 | /** |
326 | 326 | * espresso_event_status |
327 | 327 | * returns the event status if it is sold out, expired, or inactive |
@@ -330,17 +330,17 @@ discard block |
||
330 | 330 | * @param bool $echo |
331 | 331 | * @return string |
332 | 332 | */ |
333 | - function espresso_event_status( $EVT_ID = 0, $echo = TRUE ) { |
|
334 | - if ( $echo ) { |
|
335 | - echo EEH_Event_View::event_active_status( $EVT_ID ); |
|
333 | + function espresso_event_status($EVT_ID = 0, $echo = TRUE) { |
|
334 | + if ($echo) { |
|
335 | + echo EEH_Event_View::event_active_status($EVT_ID); |
|
336 | 336 | return ''; |
337 | 337 | } |
338 | - return EEH_Event_View::event_active_status( $EVT_ID ); |
|
338 | + return EEH_Event_View::event_active_status($EVT_ID); |
|
339 | 339 | } |
340 | 340 | } |
341 | 341 | |
342 | 342 | |
343 | -if ( ! function_exists( 'espresso_event_categories' )) { |
|
343 | +if ( ! function_exists('espresso_event_categories')) { |
|
344 | 344 | /** |
345 | 345 | * espresso_event_categories |
346 | 346 | * returns the terms associated with an event |
@@ -350,17 +350,17 @@ discard block |
||
350 | 350 | * @param bool $echo |
351 | 351 | * @return string |
352 | 352 | */ |
353 | - function espresso_event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE ) { |
|
354 | - if ( $echo ) { |
|
355 | - echo EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized ); |
|
353 | + function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) { |
|
354 | + if ($echo) { |
|
355 | + echo EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); |
|
356 | 356 | return ''; |
357 | 357 | } |
358 | - return EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized ); |
|
358 | + return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); |
|
359 | 359 | } |
360 | 360 | } |
361 | 361 | |
362 | 362 | |
363 | -if ( ! function_exists( 'espresso_event_tickets_available' )) { |
|
363 | +if ( ! function_exists('espresso_event_tickets_available')) { |
|
364 | 364 | /** |
365 | 365 | * espresso_event_tickets_available |
366 | 366 | * returns the ticket types available for purchase for an event |
@@ -370,26 +370,26 @@ discard block |
||
370 | 370 | * @param bool $format |
371 | 371 | * @return string |
372 | 372 | */ |
373 | - function espresso_event_tickets_available( $EVT_ID = 0, $echo = TRUE, $format = TRUE ) { |
|
374 | - $tickets = EEH_Event_View::event_tickets_available( $EVT_ID ); |
|
375 | - if ( is_array( $tickets ) && ! empty( $tickets )) { |
|
373 | + function espresso_event_tickets_available($EVT_ID = 0, $echo = TRUE, $format = TRUE) { |
|
374 | + $tickets = EEH_Event_View::event_tickets_available($EVT_ID); |
|
375 | + if (is_array($tickets) && ! empty($tickets)) { |
|
376 | 376 | // if formatting then $html will be a string, else it will be an array of ticket objects |
377 | - $html = $format ? '<ul id="ee-event-tickets-ul-' . $EVT_ID . '" class="ee-event-tickets-ul">' : array(); |
|
378 | - foreach ( $tickets as $ticket ) { |
|
379 | - if ( $ticket instanceof EE_Ticket ) { |
|
380 | - if ( $format ) { |
|
381 | - $html .= '<li id="ee-event-tickets-li-' . $ticket->ID() . '" class="ee-event-tickets-li">'; |
|
382 | - $html .= $ticket->name() . ' ' . EEH_Template::format_currency( $ticket->get_ticket_total_with_taxes() ); |
|
377 | + $html = $format ? '<ul id="ee-event-tickets-ul-'.$EVT_ID.'" class="ee-event-tickets-ul">' : array(); |
|
378 | + foreach ($tickets as $ticket) { |
|
379 | + if ($ticket instanceof EE_Ticket) { |
|
380 | + if ($format) { |
|
381 | + $html .= '<li id="ee-event-tickets-li-'.$ticket->ID().'" class="ee-event-tickets-li">'; |
|
382 | + $html .= $ticket->name().' '.EEH_Template::format_currency($ticket->get_ticket_total_with_taxes()); |
|
383 | 383 | $html .= '</li>'; |
384 | 384 | } else { |
385 | 385 | $html[] = $ticket; |
386 | 386 | } |
387 | 387 | } |
388 | 388 | } |
389 | - if ( $format ) { |
|
389 | + if ($format) { |
|
390 | 390 | $html .= '</ul>'; |
391 | 391 | } |
392 | - if ( $echo && ! $format ) { |
|
392 | + if ($echo && ! $format) { |
|
393 | 393 | echo $html; |
394 | 394 | return ''; |
395 | 395 | } |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
402 | -if ( ! function_exists( 'espresso_event_date_obj' )) { |
|
402 | +if ( ! function_exists('espresso_event_date_obj')) { |
|
403 | 403 | /** |
404 | 404 | * espresso_event_date_obj |
405 | 405 | * returns the primary date object for an event |
@@ -407,13 +407,13 @@ discard block |
||
407 | 407 | * @param bool $EVT_ID |
408 | 408 | * @return object |
409 | 409 | */ |
410 | - function espresso_event_date_obj( $EVT_ID = FALSE ) { |
|
411 | - return EEH_Event_View::get_primary_date_obj( $EVT_ID ); |
|
410 | + function espresso_event_date_obj($EVT_ID = FALSE) { |
|
411 | + return EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
412 | 412 | } |
413 | 413 | } |
414 | 414 | |
415 | 415 | |
416 | -if ( ! function_exists( 'espresso_event_date' )) { |
|
416 | +if ( ! function_exists('espresso_event_date')) { |
|
417 | 417 | /** |
418 | 418 | * espresso_event_date |
419 | 419 | * returns the primary date for an event |
@@ -424,22 +424,22 @@ discard block |
||
424 | 424 | * @param bool $echo |
425 | 425 | * @return string |
426 | 426 | */ |
427 | - function espresso_event_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) { |
|
428 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
429 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
430 | - $date_format = apply_filters( 'FHEE__espresso_event_date__date_format', $date_format ); |
|
431 | - $time_format = apply_filters( 'FHEE__espresso_event_date__time_format', $time_format ); |
|
432 | - if($echo){ |
|
433 | - echo EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID ); |
|
427 | + function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) { |
|
428 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
429 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
430 | + $date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format); |
|
431 | + $time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format); |
|
432 | + if ($echo) { |
|
433 | + echo EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); |
|
434 | 434 | return ''; |
435 | 435 | } |
436 | - return EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID ); |
|
436 | + return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); |
|
437 | 437 | |
438 | 438 | } |
439 | 439 | } |
440 | 440 | |
441 | 441 | |
442 | -if ( ! function_exists( 'espresso_list_of_event_dates' )) { |
|
442 | +if ( ! function_exists('espresso_list_of_event_dates')) { |
|
443 | 443 | /** |
444 | 444 | * espresso_list_of_event_dates |
445 | 445 | * returns a unordered list of dates for an event |
@@ -454,40 +454,40 @@ discard block |
||
454 | 454 | * @param null $limit |
455 | 455 | * @return string |
456 | 456 | */ |
457 | - function espresso_list_of_event_dates( $EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL ) { |
|
458 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
459 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
460 | - $date_format = apply_filters( 'FHEE__espresso_list_of_event_dates__date_format', $date_format ); |
|
461 | - $time_format = apply_filters( 'FHEE__espresso_list_of_event_dates__time_format', $time_format ); |
|
462 | - $datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, $show_expired, FALSE, $limit ); |
|
463 | - if ( ! $format ) { |
|
464 | - return apply_filters( 'FHEE__espresso_list_of_event_dates__datetimes', $datetimes ); |
|
457 | + function espresso_list_of_event_dates($EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL) { |
|
458 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
459 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
460 | + $date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format); |
|
461 | + $time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format); |
|
462 | + $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, FALSE, $limit); |
|
463 | + if ( ! $format) { |
|
464 | + return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes); |
|
465 | 465 | } |
466 | 466 | //d( $datetimes ); |
467 | - if ( is_array( $datetimes ) && ! empty( $datetimes )) { |
|
467 | + if (is_array($datetimes) && ! empty($datetimes)) { |
|
468 | 468 | global $post; |
469 | - $html = $format ? '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="ee-event-datetimes-ul ee-clearfix">' : ''; |
|
470 | - foreach ( $datetimes as $datetime ) { |
|
471 | - if ( $datetime instanceof EE_Datetime ) { |
|
472 | - $html .= '<li id="ee-event-datetimes-li-' . $datetime->ID(); |
|
473 | - $html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-' . $datetime->get_active_status() . '">'; |
|
469 | + $html = $format ? '<ul id="ee-event-datetimes-ul-'.$post->ID.'" class="ee-event-datetimes-ul ee-clearfix">' : ''; |
|
470 | + foreach ($datetimes as $datetime) { |
|
471 | + if ($datetime instanceof EE_Datetime) { |
|
472 | + $html .= '<li id="ee-event-datetimes-li-'.$datetime->ID(); |
|
473 | + $html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-'.$datetime->get_active_status().'">'; |
|
474 | 474 | $datetime_name = $datetime->name(); |
475 | - $html .= ! empty( $datetime_name ) ? '<strong>' . $datetime_name . '</strong>' : ''; |
|
476 | - $html .= ! empty( $datetime_name ) && $add_breaks ? '<br />' : ''; |
|
477 | - $html .= '<span class="dashicons dashicons-calendar"></span><span class="ee-event-datetimes-li-daterange">' . $datetime->date_range( $date_format ) . '</span><br/>'; |
|
478 | - $html .= '<span class="dashicons dashicons-clock"></span><span class="ee-event-datetimes-li-timerange">' . $datetime->time_range( $time_format ) . '</span>'; |
|
475 | + $html .= ! empty($datetime_name) ? '<strong>'.$datetime_name.'</strong>' : ''; |
|
476 | + $html .= ! empty($datetime_name) && $add_breaks ? '<br />' : ''; |
|
477 | + $html .= '<span class="dashicons dashicons-calendar"></span><span class="ee-event-datetimes-li-daterange">'.$datetime->date_range($date_format).'</span><br/>'; |
|
478 | + $html .= '<span class="dashicons dashicons-clock"></span><span class="ee-event-datetimes-li-timerange">'.$datetime->time_range($time_format).'</span>'; |
|
479 | 479 | $datetime_description = $datetime->description(); |
480 | - $html .= ! empty( $datetime_description ) && $add_breaks ? '<br />' : ''; |
|
481 | - $html .= ! empty( $datetime_description ) ? ' - ' . $datetime_description : ''; |
|
482 | - $html = apply_filters( 'FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime ); |
|
480 | + $html .= ! empty($datetime_description) && $add_breaks ? '<br />' : ''; |
|
481 | + $html .= ! empty($datetime_description) ? ' - '.$datetime_description : ''; |
|
482 | + $html = apply_filters('FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime); |
|
483 | 483 | $html .= '</li>'; |
484 | 484 | } |
485 | 485 | } |
486 | 486 | $html .= $format ? '</ul>' : ''; |
487 | 487 | } else { |
488 | - $html = $format ? '<p><span class="dashicons dashicons-marker pink-text"></span>' . __( 'There are no upcoming dates for this event.', 'event_espresso' ) . '</p><br/>' : ''; |
|
488 | + $html = $format ? '<p><span class="dashicons dashicons-marker pink-text"></span>'.__('There are no upcoming dates for this event.', 'event_espresso').'</p><br/>' : ''; |
|
489 | 489 | } |
490 | - if ( $echo ) { |
|
490 | + if ($echo) { |
|
491 | 491 | echo $html; |
492 | 492 | return ''; |
493 | 493 | } |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | } |
497 | 497 | |
498 | 498 | |
499 | -if ( ! function_exists( 'espresso_event_end_date' )) { |
|
499 | +if ( ! function_exists('espresso_event_end_date')) { |
|
500 | 500 | /** |
501 | 501 | * espresso_event_end_date |
502 | 502 | * returns the last date for an event |
@@ -507,20 +507,20 @@ discard block |
||
507 | 507 | * @param bool $echo |
508 | 508 | * @return string |
509 | 509 | */ |
510 | - function espresso_event_end_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) { |
|
511 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
512 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
513 | - $date_format = apply_filters( 'FHEE__espresso_event_end_date__date_format', $date_format ); |
|
514 | - $time_format = apply_filters( 'FHEE__espresso_event_end_date__time_format', $time_format ); |
|
515 | - if($echo){ |
|
516 | - echo EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID ); |
|
510 | + function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) { |
|
511 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
512 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
513 | + $date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format); |
|
514 | + $time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format); |
|
515 | + if ($echo) { |
|
516 | + echo EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); |
|
517 | 517 | return ''; |
518 | 518 | } |
519 | - return EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID ); |
|
519 | + return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); |
|
520 | 520 | } |
521 | 521 | } |
522 | 522 | |
523 | -if ( ! function_exists( 'espresso_event_date_range' )) { |
|
523 | +if ( ! function_exists('espresso_event_date_range')) { |
|
524 | 524 | /** |
525 | 525 | * espresso_event_date_range |
526 | 526 | * returns the first and last chronologically ordered dates for an event (if different) |
@@ -533,31 +533,31 @@ discard block |
||
533 | 533 | * @param bool $echo |
534 | 534 | * @return string |
535 | 535 | */ |
536 | - function espresso_event_date_range( $date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE ) { |
|
536 | + function espresso_event_date_range($date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE) { |
|
537 | 537 | // set and filter date and time formats when a range is returned |
538 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
539 | - $date_format = apply_filters( 'FHEE__espresso_event_date_range__date_format', $date_format ); |
|
538 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
539 | + $date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format); |
|
540 | 540 | // get the start and end date with NO time portion |
541 | - $the_event_date = EEH_Event_View::the_earliest_event_date( $date_format, '', $EVT_ID ); |
|
542 | - $the_event_end_date = EEH_Event_View::the_latest_event_date( $date_format, '', $EVT_ID ); |
|
541 | + $the_event_date = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID); |
|
542 | + $the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID); |
|
543 | 543 | // now we can determine if date range spans more than one day |
544 | - if ( $the_event_date != $the_event_end_date ) { |
|
545 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
546 | - $time_format = apply_filters( 'FHEE__espresso_event_date_range__time_format', $time_format ); |
|
544 | + if ($the_event_date != $the_event_end_date) { |
|
545 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
546 | + $time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format); |
|
547 | 547 | $html = sprintf( |
548 | - __( '%1$s - %2$s', 'event_espresso' ), |
|
549 | - EEH_Event_View::the_earliest_event_date( $date_format, $time_format, $EVT_ID ), |
|
550 | - EEH_Event_View::the_latest_event_date( $date_format, $time_format, $EVT_ID ) |
|
548 | + __('%1$s - %2$s', 'event_espresso'), |
|
549 | + EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID), |
|
550 | + EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID) |
|
551 | 551 | ); |
552 | 552 | } else { |
553 | 553 | // set and filter date and time formats when only a single datetime is returned |
554 | - $single_date_format = ! empty( $single_date_format ) ? $single_date_format : get_option( 'date_format' ); |
|
555 | - $single_time_format = ! empty( $single_time_format ) ? $single_time_format : get_option( 'time_format' ); |
|
556 | - $single_date_format = apply_filters( 'FHEE__espresso_event_date_range__single_date_format', $single_date_format ); |
|
557 | - $single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', $single_time_format ); |
|
558 | - $html = EEH_Event_View::the_earliest_event_date( $single_date_format, $single_time_format, $EVT_ID ); |
|
554 | + $single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format'); |
|
555 | + $single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format'); |
|
556 | + $single_date_format = apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format); |
|
557 | + $single_time_format = apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format); |
|
558 | + $html = EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID); |
|
559 | 559 | } |
560 | - if ( $echo ) { |
|
560 | + if ($echo) { |
|
561 | 561 | echo $html; |
562 | 562 | return ''; |
563 | 563 | } |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | } |
567 | 567 | |
568 | 568 | |
569 | -if ( ! function_exists( 'espresso_event_date_as_calendar_page' )) { |
|
569 | +if ( ! function_exists('espresso_event_date_as_calendar_page')) { |
|
570 | 570 | /** |
571 | 571 | * espresso_event_date_as_calendar_page |
572 | 572 | * returns the primary date for an event, stylized to appear as the page of a calendar |
@@ -574,15 +574,15 @@ discard block |
||
574 | 574 | * @param bool $EVT_ID |
575 | 575 | * @return string |
576 | 576 | */ |
577 | - function espresso_event_date_as_calendar_page( $EVT_ID = FALSE ) { |
|
578 | - EEH_Event_View::event_date_as_calendar_page( $EVT_ID ); |
|
577 | + function espresso_event_date_as_calendar_page($EVT_ID = FALSE) { |
|
578 | + EEH_Event_View::event_date_as_calendar_page($EVT_ID); |
|
579 | 579 | } |
580 | 580 | } |
581 | 581 | |
582 | 582 | |
583 | 583 | |
584 | 584 | |
585 | -if ( ! function_exists( 'espresso_event_link_url' )) { |
|
585 | +if ( ! function_exists('espresso_event_link_url')) { |
|
586 | 586 | /** |
587 | 587 | * espresso_event_link_url |
588 | 588 | * |
@@ -590,18 +590,18 @@ discard block |
||
590 | 590 | * @param bool $echo |
591 | 591 | * @return string |
592 | 592 | */ |
593 | - function espresso_event_link_url( $EVT_ID = 0, $echo = TRUE ) { |
|
594 | - if ( $echo ) { |
|
595 | - echo EEH_Event_View::event_link_url( $EVT_ID ); |
|
593 | + function espresso_event_link_url($EVT_ID = 0, $echo = TRUE) { |
|
594 | + if ($echo) { |
|
595 | + echo EEH_Event_View::event_link_url($EVT_ID); |
|
596 | 596 | return ''; |
597 | 597 | } |
598 | - return EEH_Event_View::event_link_url( $EVT_ID ); |
|
598 | + return EEH_Event_View::event_link_url($EVT_ID); |
|
599 | 599 | } |
600 | 600 | } |
601 | 601 | |
602 | 602 | |
603 | 603 | |
604 | -if ( ! function_exists( 'espresso_event_has_content_or_excerpt' )) { |
|
604 | +if ( ! function_exists('espresso_event_has_content_or_excerpt')) { |
|
605 | 605 | /** |
606 | 606 | * espresso_event_has_content_or_excerpt |
607 | 607 | * |
@@ -609,15 +609,15 @@ discard block |
||
609 | 609 | * @param bool $EVT_ID |
610 | 610 | * @return boolean |
611 | 611 | */ |
612 | - function espresso_event_has_content_or_excerpt( $EVT_ID = FALSE ) { |
|
613 | - return EEH_Event_View::event_has_content_or_excerpt( $EVT_ID ); |
|
612 | + function espresso_event_has_content_or_excerpt($EVT_ID = FALSE) { |
|
613 | + return EEH_Event_View::event_has_content_or_excerpt($EVT_ID); |
|
614 | 614 | } |
615 | 615 | } |
616 | 616 | |
617 | 617 | |
618 | 618 | |
619 | 619 | |
620 | -if ( ! function_exists( 'espresso_event_content_or_excerpt' )) { |
|
620 | +if ( ! function_exists('espresso_event_content_or_excerpt')) { |
|
621 | 621 | /** |
622 | 622 | * espresso_event_content_or_excerpt |
623 | 623 | * |
@@ -626,18 +626,18 @@ discard block |
||
626 | 626 | * @param bool $echo |
627 | 627 | * @return string |
628 | 628 | */ |
629 | - function espresso_event_content_or_excerpt( $num_words = 55, $more = NULL, $echo = TRUE ) { |
|
630 | - if ( $echo ) { |
|
631 | - echo EEH_Event_View::event_content_or_excerpt( $num_words, $more ); |
|
629 | + function espresso_event_content_or_excerpt($num_words = 55, $more = NULL, $echo = TRUE) { |
|
630 | + if ($echo) { |
|
631 | + echo EEH_Event_View::event_content_or_excerpt($num_words, $more); |
|
632 | 632 | return ''; |
633 | 633 | } |
634 | - return EEH_Event_View::event_content_or_excerpt( $num_words, $more ); |
|
634 | + return EEH_Event_View::event_content_or_excerpt($num_words, $more); |
|
635 | 635 | } |
636 | 636 | } |
637 | 637 | |
638 | 638 | |
639 | 639 | |
640 | -if ( ! function_exists( 'espresso_event_phone' )) { |
|
640 | +if ( ! function_exists('espresso_event_phone')) { |
|
641 | 641 | /** |
642 | 642 | * espresso_event_phone |
643 | 643 | * |
@@ -645,18 +645,18 @@ discard block |
||
645 | 645 | * @param bool $echo |
646 | 646 | * @return string |
647 | 647 | */ |
648 | - function espresso_event_phone( $EVT_ID = 0, $echo = TRUE ) { |
|
649 | - if ( $echo ) { |
|
650 | - echo EEH_Event_View::event_phone( $EVT_ID ); |
|
648 | + function espresso_event_phone($EVT_ID = 0, $echo = TRUE) { |
|
649 | + if ($echo) { |
|
650 | + echo EEH_Event_View::event_phone($EVT_ID); |
|
651 | 651 | return ''; |
652 | 652 | } |
653 | - return EEH_Event_View::event_phone( $EVT_ID ); |
|
653 | + return EEH_Event_View::event_phone($EVT_ID); |
|
654 | 654 | } |
655 | 655 | } |
656 | 656 | |
657 | 657 | |
658 | 658 | |
659 | -if ( ! function_exists( 'espresso_edit_event_link' )) { |
|
659 | +if ( ! function_exists('espresso_edit_event_link')) { |
|
660 | 660 | /** |
661 | 661 | * espresso_edit_event_link |
662 | 662 | * returns a link to edit an event |
@@ -665,39 +665,39 @@ discard block |
||
665 | 665 | * @param bool $echo |
666 | 666 | * @return string |
667 | 667 | */ |
668 | - function espresso_edit_event_link( $EVT_ID = 0, $echo = TRUE ) { |
|
669 | - if ( $echo ) { |
|
670 | - echo EEH_Event_View::edit_event_link( $EVT_ID ); |
|
668 | + function espresso_edit_event_link($EVT_ID = 0, $echo = TRUE) { |
|
669 | + if ($echo) { |
|
670 | + echo EEH_Event_View::edit_event_link($EVT_ID); |
|
671 | 671 | return ''; |
672 | 672 | } |
673 | - return EEH_Event_View::edit_event_link( $EVT_ID ); |
|
673 | + return EEH_Event_View::edit_event_link($EVT_ID); |
|
674 | 674 | } |
675 | 675 | } |
676 | 676 | |
677 | 677 | |
678 | -if ( ! function_exists( 'espresso_organization_name' )) { |
|
678 | +if ( ! function_exists('espresso_organization_name')) { |
|
679 | 679 | /** |
680 | 680 | * espresso_organization_name |
681 | 681 | * @param bool $echo |
682 | 682 | * @return string |
683 | 683 | */ |
684 | 684 | function espresso_organization_name($echo = TRUE) { |
685 | - if($echo){ |
|
686 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'name' ); |
|
685 | + if ($echo) { |
|
686 | + echo EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
687 | 687 | return ''; |
688 | 688 | } |
689 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'name' ); |
|
689 | + return EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
690 | 690 | } |
691 | 691 | } |
692 | 692 | |
693 | -if ( ! function_exists( 'espresso_organization_address' )) { |
|
693 | +if ( ! function_exists('espresso_organization_address')) { |
|
694 | 694 | /** |
695 | 695 | * espresso_organization_address |
696 | 696 | * @param string $type |
697 | 697 | * @return string |
698 | 698 | */ |
699 | - function espresso_organization_address( $type = 'inline' ) { |
|
700 | - if ( EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ) { |
|
699 | + function espresso_organization_address($type = 'inline') { |
|
700 | + if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) { |
|
701 | 701 | $address = new EventEspresso\core\domain\entities\GenericAddress( |
702 | 702 | EE_Registry::instance()->CFG->organization->address_1, |
703 | 703 | EE_Registry::instance()->CFG->organization->address_2, |
@@ -706,129 +706,129 @@ discard block |
||
706 | 706 | EE_Registry::instance()->CFG->organization->zip, |
707 | 707 | EE_Registry::instance()->CFG->organization->CNT_ISO |
708 | 708 | ); |
709 | - return EEH_Address::format( $address, $type ); |
|
709 | + return EEH_Address::format($address, $type); |
|
710 | 710 | } |
711 | 711 | return ''; |
712 | 712 | } |
713 | 713 | } |
714 | 714 | |
715 | -if ( ! function_exists( 'espresso_organization_email' )) { |
|
715 | +if ( ! function_exists('espresso_organization_email')) { |
|
716 | 716 | /** |
717 | 717 | * espresso_organization_email |
718 | 718 | * @param bool $echo |
719 | 719 | * @return string |
720 | 720 | */ |
721 | - function espresso_organization_email( $echo = TRUE ) { |
|
722 | - if($echo){ |
|
723 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'email' ); |
|
721 | + function espresso_organization_email($echo = TRUE) { |
|
722 | + if ($echo) { |
|
723 | + echo EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
724 | 724 | return ''; |
725 | 725 | } |
726 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'email' ); |
|
726 | + return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
727 | 727 | } |
728 | 728 | } |
729 | 729 | |
730 | -if ( ! function_exists( 'espresso_organization_logo_url' )) { |
|
730 | +if ( ! function_exists('espresso_organization_logo_url')) { |
|
731 | 731 | /** |
732 | 732 | * espresso_organization_logo_url |
733 | 733 | * @param bool $echo |
734 | 734 | * @return string |
735 | 735 | */ |
736 | - function espresso_organization_logo_url( $echo = TRUE ) { |
|
737 | - if($echo){ |
|
738 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ); |
|
736 | + function espresso_organization_logo_url($echo = TRUE) { |
|
737 | + if ($echo) { |
|
738 | + echo EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
739 | 739 | return ''; |
740 | 740 | } |
741 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ); |
|
741 | + return EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
742 | 742 | } |
743 | 743 | } |
744 | 744 | |
745 | -if ( ! function_exists( 'espresso_organization_facebook' )) { |
|
745 | +if ( ! function_exists('espresso_organization_facebook')) { |
|
746 | 746 | /** |
747 | 747 | * espresso_organization_facebook |
748 | 748 | * @param bool $echo |
749 | 749 | * @return string |
750 | 750 | */ |
751 | - function espresso_organization_facebook( $echo = TRUE ) { |
|
752 | - if($echo){ |
|
753 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ); |
|
751 | + function espresso_organization_facebook($echo = TRUE) { |
|
752 | + if ($echo) { |
|
753 | + echo EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
754 | 754 | return ''; |
755 | 755 | } |
756 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ); |
|
756 | + return EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
757 | 757 | } |
758 | 758 | } |
759 | 759 | |
760 | -if ( ! function_exists( 'espresso_organization_twitter' )) { |
|
760 | +if ( ! function_exists('espresso_organization_twitter')) { |
|
761 | 761 | /** |
762 | 762 | * espresso_organization_twitter |
763 | 763 | * @param bool $echo |
764 | 764 | * @return string |
765 | 765 | */ |
766 | - function espresso_organization_twitter( $echo = TRUE ) { |
|
767 | - if($echo){ |
|
768 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ); |
|
766 | + function espresso_organization_twitter($echo = TRUE) { |
|
767 | + if ($echo) { |
|
768 | + echo EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
769 | 769 | return ''; |
770 | 770 | } |
771 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ); |
|
771 | + return EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
772 | 772 | } |
773 | 773 | } |
774 | 774 | |
775 | -if ( ! function_exists( 'espresso_organization_linkedin' )) { |
|
775 | +if ( ! function_exists('espresso_organization_linkedin')) { |
|
776 | 776 | /** |
777 | 777 | * espresso_organization_linkedin |
778 | 778 | * @param bool $echo |
779 | 779 | * @return string |
780 | 780 | */ |
781 | - function espresso_organization_linkedin( $echo = TRUE ) { |
|
782 | - if($echo){ |
|
783 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' ); |
|
781 | + function espresso_organization_linkedin($echo = TRUE) { |
|
782 | + if ($echo) { |
|
783 | + echo EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
784 | 784 | return ''; |
785 | 785 | } |
786 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' ); |
|
786 | + return EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
787 | 787 | } |
788 | 788 | } |
789 | 789 | |
790 | -if ( ! function_exists( 'espresso_organization_pinterest' )) { |
|
790 | +if ( ! function_exists('espresso_organization_pinterest')) { |
|
791 | 791 | /** |
792 | 792 | * espresso_organization_pinterest |
793 | 793 | * @param bool $echo |
794 | 794 | * @return string |
795 | 795 | */ |
796 | - function espresso_organization_pinterest( $echo = TRUE ) { |
|
797 | - if($echo){ |
|
798 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' ); |
|
796 | + function espresso_organization_pinterest($echo = TRUE) { |
|
797 | + if ($echo) { |
|
798 | + echo EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
799 | 799 | return ''; |
800 | 800 | } |
801 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' ); |
|
801 | + return EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
802 | 802 | } |
803 | 803 | } |
804 | 804 | |
805 | -if ( ! function_exists( 'espresso_organization_google' )) { |
|
805 | +if ( ! function_exists('espresso_organization_google')) { |
|
806 | 806 | /** |
807 | 807 | * espresso_organization_google |
808 | 808 | * @param bool $echo |
809 | 809 | * @return string |
810 | 810 | */ |
811 | - function espresso_organization_google( $echo = TRUE ) { |
|
812 | - if($echo){ |
|
813 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'google' ); |
|
811 | + function espresso_organization_google($echo = TRUE) { |
|
812 | + if ($echo) { |
|
813 | + echo EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
814 | 814 | return ''; |
815 | 815 | } |
816 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'google' ); |
|
816 | + return EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
817 | 817 | } |
818 | 818 | } |
819 | 819 | |
820 | -if ( ! function_exists( 'espresso_organization_instagram' )) { |
|
820 | +if ( ! function_exists('espresso_organization_instagram')) { |
|
821 | 821 | /** |
822 | 822 | * espresso_organization_instagram |
823 | 823 | * @param bool $echo |
824 | 824 | * @return string |
825 | 825 | */ |
826 | - function espresso_organization_instagram( $echo = TRUE ) { |
|
827 | - if($echo){ |
|
828 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' ); |
|
826 | + function espresso_organization_instagram($echo = TRUE) { |
|
827 | + if ($echo) { |
|
828 | + echo EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
829 | 829 | return ''; |
830 | 830 | } |
831 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' ); |
|
831 | + return EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
832 | 832 | } |
833 | 833 | } |
834 | 834 | |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | |
839 | 839 | |
840 | 840 | |
841 | -if ( ! function_exists( 'espresso_event_venues' )) { |
|
841 | +if ( ! function_exists('espresso_event_venues')) { |
|
842 | 842 | /** |
843 | 843 | * espresso_event_venues |
844 | 844 | * |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | |
853 | 853 | |
854 | 854 | |
855 | -if ( ! function_exists( 'espresso_venue_id' )) { |
|
855 | +if ( ! function_exists('espresso_venue_id')) { |
|
856 | 856 | /** |
857 | 857 | * espresso_venue_name |
858 | 858 | * |
@@ -860,15 +860,15 @@ discard block |
||
860 | 860 | * @param int $EVT_ID |
861 | 861 | * @return string |
862 | 862 | */ |
863 | - function espresso_venue_id( $EVT_ID = 0 ) { |
|
864 | - $venue = EEH_Venue_View::get_venue( $EVT_ID ); |
|
863 | + function espresso_venue_id($EVT_ID = 0) { |
|
864 | + $venue = EEH_Venue_View::get_venue($EVT_ID); |
|
865 | 865 | return $venue instanceof EE_Venue ? $venue->ID() : 0; |
866 | 866 | } |
867 | 867 | } |
868 | 868 | |
869 | 869 | |
870 | 870 | |
871 | -if ( ! function_exists( 'espresso_is_venue_private' ) ) { |
|
871 | +if ( ! function_exists('espresso_is_venue_private')) { |
|
872 | 872 | /** |
873 | 873 | * Return whether a venue is private or not. |
874 | 874 | * @see EEH_Venue_View::get_venue() for more info on expected return results. |
@@ -877,45 +877,45 @@ discard block |
||
877 | 877 | * |
878 | 878 | * @return bool | null |
879 | 879 | */ |
880 | - function espresso_is_venue_private( $VNU_ID = 0 ) { |
|
881 | - return EEH_Venue_View::is_venue_private( $VNU_ID ); |
|
880 | + function espresso_is_venue_private($VNU_ID = 0) { |
|
881 | + return EEH_Venue_View::is_venue_private($VNU_ID); |
|
882 | 882 | } |
883 | 883 | } |
884 | 884 | |
885 | 885 | |
886 | 886 | |
887 | -if ( ! function_exists( 'espresso_venue_is_password_protected' ) ) { |
|
887 | +if ( ! function_exists('espresso_venue_is_password_protected')) { |
|
888 | 888 | /** |
889 | 889 | * returns true or false if a venue is password protected or not |
890 | 890 | * |
891 | 891 | * @param int $VNU_ID optional, the venue id to check. |
892 | 892 | * @return string |
893 | 893 | */ |
894 | - function espresso_venue_is_password_protected( $VNU_ID = 0 ) { |
|
895 | - EE_Registry::instance()->load_helper( 'Venue_View' ); |
|
896 | - return EEH_Venue_View::is_venue_password_protected( $VNU_ID ); |
|
894 | + function espresso_venue_is_password_protected($VNU_ID = 0) { |
|
895 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
896 | + return EEH_Venue_View::is_venue_password_protected($VNU_ID); |
|
897 | 897 | } |
898 | 898 | } |
899 | 899 | |
900 | 900 | |
901 | 901 | |
902 | -if ( ! function_exists( 'espresso_password_protected_venue_form' ) ) { |
|
902 | +if ( ! function_exists('espresso_password_protected_venue_form')) { |
|
903 | 903 | /** |
904 | 904 | * Returns a password form if venue is password protected. |
905 | 905 | * |
906 | 906 | * @param int $VNU_ID optional, the venue id to check. |
907 | 907 | * @return string |
908 | 908 | */ |
909 | - function espresso_password_protected_venue_form( $VNU_ID = 0 ) { |
|
910 | - EE_Registry::instance()->load_helper( 'Venue_View' ); |
|
911 | - return EEH_Venue_View::password_protected_venue_form( $VNU_ID ); |
|
909 | + function espresso_password_protected_venue_form($VNU_ID = 0) { |
|
910 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
911 | + return EEH_Venue_View::password_protected_venue_form($VNU_ID); |
|
912 | 912 | } |
913 | 913 | } |
914 | 914 | |
915 | 915 | |
916 | 916 | |
917 | 917 | |
918 | -if ( ! function_exists( 'espresso_venue_name' )) { |
|
918 | +if ( ! function_exists('espresso_venue_name')) { |
|
919 | 919 | /** |
920 | 920 | * espresso_venue_name |
921 | 921 | * |
@@ -925,19 +925,19 @@ discard block |
||
925 | 925 | * @param bool $echo |
926 | 926 | * @return string |
927 | 927 | */ |
928 | - function espresso_venue_name( $VNU_ID = 0, $link_to = 'details', $echo = TRUE ) { |
|
929 | - if($echo){ |
|
930 | - echo EEH_Venue_View::venue_name( $link_to, $VNU_ID ); |
|
928 | + function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = TRUE) { |
|
929 | + if ($echo) { |
|
930 | + echo EEH_Venue_View::venue_name($link_to, $VNU_ID); |
|
931 | 931 | return ''; |
932 | 932 | } |
933 | - return EEH_Venue_View::venue_name( $link_to, $VNU_ID ); |
|
933 | + return EEH_Venue_View::venue_name($link_to, $VNU_ID); |
|
934 | 934 | } |
935 | 935 | } |
936 | 936 | |
937 | 937 | |
938 | 938 | |
939 | 939 | |
940 | -if ( ! function_exists( 'espresso_venue_link' )) { |
|
940 | +if ( ! function_exists('espresso_venue_link')) { |
|
941 | 941 | /** |
942 | 942 | * espresso_venue_link |
943 | 943 | * |
@@ -946,14 +946,14 @@ discard block |
||
946 | 946 | * @param string $text |
947 | 947 | * @return string |
948 | 948 | */ |
949 | - function espresso_venue_link( $VNU_ID = 0, $text = '' ) { |
|
950 | - return EEH_Venue_View::venue_details_link( $VNU_ID, $text ); |
|
949 | + function espresso_venue_link($VNU_ID = 0, $text = '') { |
|
950 | + return EEH_Venue_View::venue_details_link($VNU_ID, $text); |
|
951 | 951 | } |
952 | 952 | } |
953 | 953 | |
954 | 954 | |
955 | 955 | |
956 | -if ( ! function_exists( 'espresso_venue_description' )) { |
|
956 | +if ( ! function_exists('espresso_venue_description')) { |
|
957 | 957 | /** |
958 | 958 | * espresso_venue_description |
959 | 959 | * |
@@ -962,17 +962,17 @@ discard block |
||
962 | 962 | * @param bool $echo |
963 | 963 | * @return string |
964 | 964 | */ |
965 | - function espresso_venue_description( $VNU_ID = FALSE, $echo = TRUE ) { |
|
966 | - if($echo){ |
|
967 | - echo EEH_Venue_View::venue_description( $VNU_ID ); |
|
965 | + function espresso_venue_description($VNU_ID = FALSE, $echo = TRUE) { |
|
966 | + if ($echo) { |
|
967 | + echo EEH_Venue_View::venue_description($VNU_ID); |
|
968 | 968 | return ''; |
969 | 969 | } |
970 | - return EEH_Venue_View::venue_description( $VNU_ID ); |
|
970 | + return EEH_Venue_View::venue_description($VNU_ID); |
|
971 | 971 | } |
972 | 972 | } |
973 | 973 | |
974 | 974 | |
975 | -if ( ! function_exists( 'espresso_venue_excerpt' )) { |
|
975 | +if ( ! function_exists('espresso_venue_excerpt')) { |
|
976 | 976 | /** |
977 | 977 | * espresso_venue_excerpt |
978 | 978 | * |
@@ -981,18 +981,18 @@ discard block |
||
981 | 981 | * @param bool $echo |
982 | 982 | * @return string |
983 | 983 | */ |
984 | - function espresso_venue_excerpt( $VNU_ID = 0, $echo = TRUE ) { |
|
985 | - if ( $echo ) { |
|
986 | - echo EEH_Venue_View::venue_excerpt( $VNU_ID ); |
|
984 | + function espresso_venue_excerpt($VNU_ID = 0, $echo = TRUE) { |
|
985 | + if ($echo) { |
|
986 | + echo EEH_Venue_View::venue_excerpt($VNU_ID); |
|
987 | 987 | return ''; |
988 | 988 | } |
989 | - return EEH_Venue_View::venue_excerpt( $VNU_ID ); |
|
989 | + return EEH_Venue_View::venue_excerpt($VNU_ID); |
|
990 | 990 | } |
991 | 991 | } |
992 | 992 | |
993 | 993 | |
994 | 994 | |
995 | -if ( ! function_exists( 'espresso_venue_categories' )) { |
|
995 | +if ( ! function_exists('espresso_venue_categories')) { |
|
996 | 996 | /** |
997 | 997 | * espresso_venue_categories |
998 | 998 | * returns the terms associated with a venue |
@@ -1002,17 +1002,17 @@ discard block |
||
1002 | 1002 | * @param bool $echo |
1003 | 1003 | * @return string |
1004 | 1004 | */ |
1005 | - function espresso_venue_categories( $VNU_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE ) { |
|
1006 | - if ( $echo ) { |
|
1007 | - echo EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized ); |
|
1005 | + function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) { |
|
1006 | + if ($echo) { |
|
1007 | + echo EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); |
|
1008 | 1008 | return ''; |
1009 | 1009 | } |
1010 | - return EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized ); |
|
1010 | + return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); |
|
1011 | 1011 | } |
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | |
1015 | -if ( ! function_exists( 'espresso_venue_address' )) { |
|
1015 | +if ( ! function_exists('espresso_venue_address')) { |
|
1016 | 1016 | /** |
1017 | 1017 | * espresso_venue_address |
1018 | 1018 | * returns a formatted block of html for displaying a venue's address |
@@ -1022,17 +1022,17 @@ discard block |
||
1022 | 1022 | * @param bool $echo |
1023 | 1023 | * @return string |
1024 | 1024 | */ |
1025 | - function espresso_venue_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) { |
|
1026 | - if ( $echo ) { |
|
1027 | - echo EEH_Venue_View::venue_address( $type, $VNU_ID ); |
|
1025 | + function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) { |
|
1026 | + if ($echo) { |
|
1027 | + echo EEH_Venue_View::venue_address($type, $VNU_ID); |
|
1028 | 1028 | return ''; |
1029 | 1029 | } |
1030 | - return EEH_Venue_View::venue_address( $type, $VNU_ID ); |
|
1030 | + return EEH_Venue_View::venue_address($type, $VNU_ID); |
|
1031 | 1031 | } |
1032 | 1032 | } |
1033 | 1033 | |
1034 | 1034 | |
1035 | -if ( ! function_exists( 'espresso_venue_raw_address' )) { |
|
1035 | +if ( ! function_exists('espresso_venue_raw_address')) { |
|
1036 | 1036 | /** |
1037 | 1037 | * espresso_venue_address |
1038 | 1038 | * returns an UN-formatted string containing a venue's address |
@@ -1042,17 +1042,17 @@ discard block |
||
1042 | 1042 | * @param bool $echo |
1043 | 1043 | * @return string |
1044 | 1044 | */ |
1045 | - function espresso_venue_raw_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) { |
|
1046 | - if ( $echo ) { |
|
1047 | - echo EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE ); |
|
1045 | + function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) { |
|
1046 | + if ($echo) { |
|
1047 | + echo EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE); |
|
1048 | 1048 | return ''; |
1049 | 1049 | } |
1050 | - return EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE ); |
|
1050 | + return EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE); |
|
1051 | 1051 | } |
1052 | 1052 | } |
1053 | 1053 | |
1054 | 1054 | |
1055 | -if ( ! function_exists( 'espresso_venue_has_address' )) { |
|
1055 | +if ( ! function_exists('espresso_venue_has_address')) { |
|
1056 | 1056 | /** |
1057 | 1057 | * espresso_venue_has_address |
1058 | 1058 | * returns TRUE or FALSE if a Venue has address information |
@@ -1060,13 +1060,13 @@ discard block |
||
1060 | 1060 | * @param int $VNU_ID |
1061 | 1061 | * @return bool |
1062 | 1062 | */ |
1063 | - function espresso_venue_has_address( $VNU_ID = 0 ) { |
|
1064 | - return EEH_Venue_View::venue_has_address( $VNU_ID ); |
|
1063 | + function espresso_venue_has_address($VNU_ID = 0) { |
|
1064 | + return EEH_Venue_View::venue_has_address($VNU_ID); |
|
1065 | 1065 | } |
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | |
1069 | -if ( ! function_exists( 'espresso_venue_gmap' )) { |
|
1069 | +if ( ! function_exists('espresso_venue_gmap')) { |
|
1070 | 1070 | /** |
1071 | 1071 | * espresso_venue_gmap |
1072 | 1072 | * returns a google map for the venue address |
@@ -1077,17 +1077,17 @@ discard block |
||
1077 | 1077 | * @param bool $echo |
1078 | 1078 | * @return string |
1079 | 1079 | */ |
1080 | - function espresso_venue_gmap( $VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE ) { |
|
1081 | - if ( $echo ) { |
|
1082 | - echo EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap ); |
|
1080 | + function espresso_venue_gmap($VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE) { |
|
1081 | + if ($echo) { |
|
1082 | + echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); |
|
1083 | 1083 | return ''; |
1084 | 1084 | } |
1085 | - return EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap ); |
|
1085 | + return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); |
|
1086 | 1086 | } |
1087 | 1087 | } |
1088 | 1088 | |
1089 | 1089 | |
1090 | -if ( ! function_exists( 'espresso_venue_phone' )) { |
|
1090 | +if ( ! function_exists('espresso_venue_phone')) { |
|
1091 | 1091 | /** |
1092 | 1092 | * espresso_venue_phone |
1093 | 1093 | * |
@@ -1095,18 +1095,18 @@ discard block |
||
1095 | 1095 | * @param bool $echo |
1096 | 1096 | * @return string |
1097 | 1097 | */ |
1098 | - function espresso_venue_phone( $VNU_ID = 0, $echo = TRUE ) { |
|
1099 | - if ( $echo ) { |
|
1100 | - echo EEH_Venue_View::venue_phone( $VNU_ID ); |
|
1098 | + function espresso_venue_phone($VNU_ID = 0, $echo = TRUE) { |
|
1099 | + if ($echo) { |
|
1100 | + echo EEH_Venue_View::venue_phone($VNU_ID); |
|
1101 | 1101 | return ''; |
1102 | 1102 | } |
1103 | - return EEH_Venue_View::venue_phone( $VNU_ID ); |
|
1103 | + return EEH_Venue_View::venue_phone($VNU_ID); |
|
1104 | 1104 | } |
1105 | 1105 | } |
1106 | 1106 | |
1107 | 1107 | |
1108 | 1108 | |
1109 | -if ( ! function_exists( 'espresso_venue_website' )) { |
|
1109 | +if ( ! function_exists('espresso_venue_website')) { |
|
1110 | 1110 | /** |
1111 | 1111 | * espresso_venue_website |
1112 | 1112 | * |
@@ -1114,18 +1114,18 @@ discard block |
||
1114 | 1114 | * @param bool $echo |
1115 | 1115 | * @return string |
1116 | 1116 | */ |
1117 | - function espresso_venue_website( $VNU_ID = 0, $echo = TRUE ) { |
|
1118 | - if ( $echo ) { |
|
1119 | - echo EEH_Venue_View::venue_website_link( $VNU_ID ); |
|
1117 | + function espresso_venue_website($VNU_ID = 0, $echo = TRUE) { |
|
1118 | + if ($echo) { |
|
1119 | + echo EEH_Venue_View::venue_website_link($VNU_ID); |
|
1120 | 1120 | return ''; |
1121 | 1121 | } |
1122 | - return EEH_Venue_View::venue_website_link( $VNU_ID ); |
|
1122 | + return EEH_Venue_View::venue_website_link($VNU_ID); |
|
1123 | 1123 | } |
1124 | 1124 | } |
1125 | 1125 | |
1126 | 1126 | |
1127 | 1127 | |
1128 | -if ( ! function_exists( 'espresso_edit_venue_link' )) { |
|
1128 | +if ( ! function_exists('espresso_edit_venue_link')) { |
|
1129 | 1129 | /** |
1130 | 1130 | * espresso_edit_venue_link |
1131 | 1131 | * |
@@ -1133,12 +1133,12 @@ discard block |
||
1133 | 1133 | * @param bool $echo |
1134 | 1134 | * @return string |
1135 | 1135 | */ |
1136 | - function espresso_edit_venue_link( $VNU_ID = 0, $echo = TRUE ) { |
|
1137 | - if($echo){ |
|
1138 | - echo EEH_Venue_View::edit_venue_link( $VNU_ID ); |
|
1136 | + function espresso_edit_venue_link($VNU_ID = 0, $echo = TRUE) { |
|
1137 | + if ($echo) { |
|
1138 | + echo EEH_Venue_View::edit_venue_link($VNU_ID); |
|
1139 | 1139 | return ''; |
1140 | 1140 | } |
1141 | - return EEH_Venue_View::edit_venue_link( $VNU_ID ); |
|
1141 | + return EEH_Venue_View::edit_venue_link($VNU_ID); |
|
1142 | 1142 | } |
1143 | 1143 | } |
1144 | 1144 |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * can_use_espresso_conditionals |
131 | 131 | * tests whether the Espresso Conditional tags like is_espresso_event_single() can be called |
132 | 132 | * |
133 | - * @param $conditional_tag |
|
133 | + * @param string $conditional_tag |
|
134 | 134 | * @return bool |
135 | 135 | */ |
136 | 136 | function can_use_espresso_conditionals( $conditional_tag ) { |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | if ( ! function_exists( 'espresso_ticket_selector' )) { |
202 | 202 | /** |
203 | 203 | * espresso_ticket_selector |
204 | - * @param null $event |
|
204 | + * @param EE_Event $event |
|
205 | 205 | */ |
206 | 206 | function espresso_ticket_selector( $event = NULL ) { |
207 | 207 | if ( ! apply_filters( 'FHEE_disable_espresso_ticket_selector', FALSE ) ) { |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | /** |
843 | 843 | * espresso_event_venues |
844 | 844 | * |
845 | - * @return array all venues related to an event |
|
845 | + * @return EE_Venue[] all venues related to an event |
|
846 | 846 | */ |
847 | 847 | function espresso_event_venues() { |
848 | 848 | return EEH_Venue_View::get_event_venues(); |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | * |
876 | 876 | * @param int $VNU_ID optional, the venue id to check. |
877 | 877 | * |
878 | - * @return bool | null |
|
878 | + * @return null|boolean | null |
|
879 | 879 | */ |
880 | 880 | function espresso_is_venue_private( $VNU_ID = 0 ) { |
881 | 881 | return EEH_Venue_View::is_venue_private( $VNU_ID ); |
@@ -889,7 +889,7 @@ discard block |
||
889 | 889 | * returns true or false if a venue is password protected or not |
890 | 890 | * |
891 | 891 | * @param int $VNU_ID optional, the venue id to check. |
892 | - * @return string |
|
892 | + * @return boolean |
|
893 | 893 | */ |
894 | 894 | function espresso_venue_is_password_protected( $VNU_ID = 0 ) { |
895 | 895 | EE_Registry::instance()->load_helper( 'Venue_View' ); |
@@ -11,7 +11,7 @@ |
||
11 | 11 | */ |
12 | 12 | function ee_recurse_into_array_for_display($data) { |
13 | 13 | if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {//is_object($incomplete_class) actually returns false, hence why we check for it |
14 | - $data = json_decode(json_encode($data), true); |
|
14 | + $data = json_decode(json_encode($data), true); |
|
15 | 15 | } |
16 | 16 | if (is_array($data)) { |
17 | 17 | if (EEH_Array::is_associative_array($data)) { |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | ?> |
24 | 24 | <tr> |
25 | 25 | <td> |
26 | - <?php echo $data_key;?> |
|
26 | + <?php echo $data_key; ?> |
|
27 | 27 | </td> |
28 | 28 | <td> |
29 | - <?php ee_recurse_into_array_for_display($data_values);?> |
|
29 | + <?php ee_recurse_into_array_for_display($data_values); ?> |
|
30 | 30 | </td> |
31 | 31 | </tr> |
32 | 32 | <?php |
@@ -40,19 +40,19 @@ discard block |
||
40 | 40 | <ul> |
41 | 41 | <?php |
42 | 42 | foreach ($data as $datum) { |
43 | - echo "<li>";ee_recurse_into_array_for_display($datum);echo "</li>"; |
|
43 | + echo "<li>"; ee_recurse_into_array_for_display($datum); echo "</li>"; |
|
44 | 44 | }?> |
45 | 45 | </ul> |
46 | 46 | <?php |
47 | 47 | } |
48 | - }else { |
|
48 | + } else { |
|
49 | 49 | //simple value |
50 | 50 | echo $data; |
51 | 51 | } |
52 | 52 | } |
53 | 53 | ?> |
54 | 54 | <h1> |
55 | - <?php _e("System Information", "event_espresso");?> <a href="<?php echo $download_system_status_url;?>" class="button-secondary"><?php esc_html_e( 'Download to File', 'event_espresso' );?></a> |
|
55 | + <?php _e("System Information", "event_espresso"); ?> <a href="<?php echo $download_system_status_url; ?>" class="button-secondary"><?php esc_html_e('Download to File', 'event_espresso'); ?></a> |
|
56 | 56 | </h1> |
57 | 57 | <div class="padding"> |
58 | 58 |
@@ -151,7 +151,7 @@ |
||
151 | 151 | * This provides a count of events using this custom template |
152 | 152 | * |
153 | 153 | * @param EE_Message_Template_Group $item message_template group data |
154 | - * @return string column output |
|
154 | + * @return integer column output |
|
155 | 155 | */ |
156 | 156 | public function column_events($item) |
157 | 157 | { |
@@ -12,246 +12,246 @@ |
||
12 | 12 | class Custom_Messages_Template_List_Table extends Messages_Template_List_Table |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * Setup initial data. |
|
17 | - */ |
|
18 | - protected function _setup_data() |
|
19 | - { |
|
20 | - $this->_data = $this->get_admin_page()->get_message_templates( |
|
21 | - $this->_per_page, |
|
22 | - $this->_view, |
|
23 | - false, |
|
24 | - false, |
|
25 | - false |
|
26 | - ); |
|
27 | - $this->_all_data_count = $this->get_admin_page()->get_message_templates( |
|
28 | - $this->_per_page, |
|
29 | - $this->_view, |
|
30 | - true, |
|
31 | - true, |
|
32 | - false |
|
33 | - ); |
|
34 | - } |
|
15 | + /** |
|
16 | + * Setup initial data. |
|
17 | + */ |
|
18 | + protected function _setup_data() |
|
19 | + { |
|
20 | + $this->_data = $this->get_admin_page()->get_message_templates( |
|
21 | + $this->_per_page, |
|
22 | + $this->_view, |
|
23 | + false, |
|
24 | + false, |
|
25 | + false |
|
26 | + ); |
|
27 | + $this->_all_data_count = $this->get_admin_page()->get_message_templates( |
|
28 | + $this->_per_page, |
|
29 | + $this->_view, |
|
30 | + true, |
|
31 | + true, |
|
32 | + false |
|
33 | + ); |
|
34 | + } |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * Set initial properties |
|
39 | - */ |
|
40 | - protected function _set_properties() |
|
41 | - { |
|
42 | - parent::_set_properties(); |
|
43 | - $this->_wp_list_args = array( |
|
44 | - 'singular' => esc_html__('Message Template Group', 'event_espresso'), |
|
45 | - 'plural' => esc_html__('Message Template', 'event_espresso'), |
|
46 | - 'ajax' => true, //for now, |
|
47 | - 'screen' => $this->get_admin_page()->get_current_screen()->id, |
|
48 | - ); |
|
37 | + /** |
|
38 | + * Set initial properties |
|
39 | + */ |
|
40 | + protected function _set_properties() |
|
41 | + { |
|
42 | + parent::_set_properties(); |
|
43 | + $this->_wp_list_args = array( |
|
44 | + 'singular' => esc_html__('Message Template Group', 'event_espresso'), |
|
45 | + 'plural' => esc_html__('Message Template', 'event_espresso'), |
|
46 | + 'ajax' => true, //for now, |
|
47 | + 'screen' => $this->get_admin_page()->get_current_screen()->id, |
|
48 | + ); |
|
49 | 49 | |
50 | - $this->_columns = array_merge( |
|
51 | - array( |
|
52 | - 'cb' => '<input type="checkbox" />', |
|
53 | - 'name' => esc_html__('Template Name', 'event_espresso'), |
|
54 | - ), |
|
55 | - $this->_columns, |
|
56 | - array( |
|
57 | - 'events' => esc_html__('Events', 'event_espresso'), |
|
58 | - 'actions' => '' |
|
59 | - ) |
|
60 | - ); |
|
61 | - } |
|
50 | + $this->_columns = array_merge( |
|
51 | + array( |
|
52 | + 'cb' => '<input type="checkbox" />', |
|
53 | + 'name' => esc_html__('Template Name', 'event_espresso'), |
|
54 | + ), |
|
55 | + $this->_columns, |
|
56 | + array( |
|
57 | + 'events' => esc_html__('Events', 'event_espresso'), |
|
58 | + 'actions' => '' |
|
59 | + ) |
|
60 | + ); |
|
61 | + } |
|
62 | 62 | |
63 | 63 | |
64 | - /** |
|
65 | - * Custom message for when there are no items found. |
|
66 | - * |
|
67 | - * @since 4.3.0 |
|
68 | - */ |
|
69 | - public function no_items() |
|
70 | - { |
|
71 | - if ($this->_view !== 'trashed') { |
|
72 | - printf( |
|
73 | - esc_html__( |
|
74 | - '%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.', |
|
75 | - 'event_espresso' |
|
76 | - ), |
|
77 | - '<strong>', |
|
78 | - '</strong>' |
|
79 | - ); |
|
80 | - } else { |
|
81 | - parent::no_items(); |
|
82 | - } |
|
83 | - } |
|
64 | + /** |
|
65 | + * Custom message for when there are no items found. |
|
66 | + * |
|
67 | + * @since 4.3.0 |
|
68 | + */ |
|
69 | + public function no_items() |
|
70 | + { |
|
71 | + if ($this->_view !== 'trashed') { |
|
72 | + printf( |
|
73 | + esc_html__( |
|
74 | + '%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.', |
|
75 | + 'event_espresso' |
|
76 | + ), |
|
77 | + '<strong>', |
|
78 | + '</strong>' |
|
79 | + ); |
|
80 | + } else { |
|
81 | + parent::no_items(); |
|
82 | + } |
|
83 | + } |
|
84 | 84 | |
85 | 85 | |
86 | - /** |
|
87 | - * @param EE_Message_Template_Group $item |
|
88 | - * @return string |
|
89 | - */ |
|
90 | - public function column_cb($item) |
|
91 | - { |
|
92 | - return sprintf('<input type="checkbox" name="checkbox[%s]" value="1" />', $item->GRP_ID()); |
|
93 | - } |
|
86 | + /** |
|
87 | + * @param EE_Message_Template_Group $item |
|
88 | + * @return string |
|
89 | + */ |
|
90 | + public function column_cb($item) |
|
91 | + { |
|
92 | + return sprintf('<input type="checkbox" name="checkbox[%s]" value="1" />', $item->GRP_ID()); |
|
93 | + } |
|
94 | 94 | |
95 | 95 | |
96 | - /** |
|
97 | - * @param EE_Message_Template_Group $item |
|
98 | - * @return string |
|
99 | - */ |
|
100 | - public function column_name($item) |
|
101 | - { |
|
102 | - return '<p>' . $item->name() . '</p>'; |
|
103 | - } |
|
96 | + /** |
|
97 | + * @param EE_Message_Template_Group $item |
|
98 | + * @return string |
|
99 | + */ |
|
100 | + public function column_name($item) |
|
101 | + { |
|
102 | + return '<p>' . $item->name() . '</p>'; |
|
103 | + } |
|
104 | 104 | |
105 | 105 | |
106 | - /** |
|
107 | - * @param EE_Message_Template_Group $item |
|
108 | - * @return string |
|
109 | - */ |
|
110 | - public function column_actions($item) |
|
111 | - { |
|
112 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
113 | - 'ee_edit_messages', |
|
114 | - 'espresso_messages_add_new_message_template' |
|
115 | - )) { |
|
116 | - $create_args = array( |
|
117 | - 'GRP_ID' => $item->ID(), |
|
118 | - 'messenger' => $item->messenger(), |
|
119 | - 'message_type' => $item->message_type(), |
|
120 | - 'action' => 'add_new_message_template', |
|
121 | - ); |
|
122 | - $create_link = EE_Admin_Page::add_query_args_and_nonce($create_args, EE_MSG_ADMIN_URL); |
|
123 | - return sprintf( |
|
124 | - '<p><a href="%s" class="button button-small">%s</a></p>', |
|
125 | - $create_link, |
|
126 | - esc_html__('Create Custom', 'event_espresso') |
|
127 | - ); |
|
128 | - } |
|
129 | - return ''; |
|
130 | - } |
|
106 | + /** |
|
107 | + * @param EE_Message_Template_Group $item |
|
108 | + * @return string |
|
109 | + */ |
|
110 | + public function column_actions($item) |
|
111 | + { |
|
112 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
113 | + 'ee_edit_messages', |
|
114 | + 'espresso_messages_add_new_message_template' |
|
115 | + )) { |
|
116 | + $create_args = array( |
|
117 | + 'GRP_ID' => $item->ID(), |
|
118 | + 'messenger' => $item->messenger(), |
|
119 | + 'message_type' => $item->message_type(), |
|
120 | + 'action' => 'add_new_message_template', |
|
121 | + ); |
|
122 | + $create_link = EE_Admin_Page::add_query_args_and_nonce($create_args, EE_MSG_ADMIN_URL); |
|
123 | + return sprintf( |
|
124 | + '<p><a href="%s" class="button button-small">%s</a></p>', |
|
125 | + $create_link, |
|
126 | + esc_html__('Create Custom', 'event_espresso') |
|
127 | + ); |
|
128 | + } |
|
129 | + return ''; |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * Set the view counts on the _views property |
|
134 | - */ |
|
135 | - protected function _add_view_counts() |
|
136 | - { |
|
137 | - foreach ($this->_views as $view => $args) { |
|
138 | - $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates( |
|
139 | - $this->_per_page, |
|
140 | - $view, |
|
141 | - true, |
|
142 | - true, |
|
143 | - false |
|
144 | - ); |
|
145 | - } |
|
146 | - } |
|
132 | + /** |
|
133 | + * Set the view counts on the _views property |
|
134 | + */ |
|
135 | + protected function _add_view_counts() |
|
136 | + { |
|
137 | + foreach ($this->_views as $view => $args) { |
|
138 | + $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates( |
|
139 | + $this->_per_page, |
|
140 | + $view, |
|
141 | + true, |
|
142 | + true, |
|
143 | + false |
|
144 | + ); |
|
145 | + } |
|
146 | + } |
|
147 | 147 | |
148 | 148 | |
149 | - /** |
|
150 | - * column_events |
|
151 | - * This provides a count of events using this custom template |
|
152 | - * |
|
153 | - * @param EE_Message_Template_Group $item message_template group data |
|
154 | - * @return string column output |
|
155 | - */ |
|
156 | - public function column_events($item) |
|
157 | - { |
|
158 | - return $item->count_events(); |
|
159 | - } |
|
149 | + /** |
|
150 | + * column_events |
|
151 | + * This provides a count of events using this custom template |
|
152 | + * |
|
153 | + * @param EE_Message_Template_Group $item message_template group data |
|
154 | + * @return string column output |
|
155 | + */ |
|
156 | + public function column_events($item) |
|
157 | + { |
|
158 | + return $item->count_events(); |
|
159 | + } |
|
160 | 160 | |
161 | 161 | |
162 | - /** |
|
163 | - * Add additional actions for custom message template list view. |
|
164 | - * @param EE_Message_Template_Group $item |
|
165 | - * @return array |
|
166 | - * @throws EE_Error |
|
167 | - */ |
|
168 | - protected function _get_actions_for_messenger_column(EE_Message_Template_Group $item) |
|
169 | - { |
|
170 | - $actions = parent::_get_actions_for_messenger_column($item); |
|
162 | + /** |
|
163 | + * Add additional actions for custom message template list view. |
|
164 | + * @param EE_Message_Template_Group $item |
|
165 | + * @return array |
|
166 | + * @throws EE_Error |
|
167 | + */ |
|
168 | + protected function _get_actions_for_messenger_column(EE_Message_Template_Group $item) |
|
169 | + { |
|
170 | + $actions = parent::_get_actions_for_messenger_column($item); |
|
171 | 171 | |
172 | - //add additional actions for trash/restore etc. |
|
173 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'trash_message_template', |
|
174 | - 'id' => $item->GRP_ID(), |
|
175 | - 'noheader' => true, |
|
176 | - ), EE_MSG_ADMIN_URL); |
|
177 | - // restore link |
|
178 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'restore_message_template', |
|
179 | - 'id' => $item->GRP_ID(), |
|
180 | - 'noheader' => true, |
|
181 | - ), EE_MSG_ADMIN_URL); |
|
182 | - // delete price link |
|
183 | - $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'delete_message_template', |
|
184 | - 'id' => $item->GRP_ID(), |
|
185 | - 'noheader' => true, |
|
186 | - ), EE_MSG_ADMIN_URL); |
|
172 | + //add additional actions for trash/restore etc. |
|
173 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'trash_message_template', |
|
174 | + 'id' => $item->GRP_ID(), |
|
175 | + 'noheader' => true, |
|
176 | + ), EE_MSG_ADMIN_URL); |
|
177 | + // restore link |
|
178 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'restore_message_template', |
|
179 | + 'id' => $item->GRP_ID(), |
|
180 | + 'noheader' => true, |
|
181 | + ), EE_MSG_ADMIN_URL); |
|
182 | + // delete price link |
|
183 | + $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'delete_message_template', |
|
184 | + 'id' => $item->GRP_ID(), |
|
185 | + 'noheader' => true, |
|
186 | + ), EE_MSG_ADMIN_URL); |
|
187 | 187 | |
188 | - if (! $item->get('MTP_deleted') |
|
189 | - && EE_Registry::instance()->CAP->current_user_can( |
|
190 | - 'ee_delete_message', |
|
191 | - 'espresso_messages_trash_message_template', |
|
192 | - $item->ID() |
|
193 | - ) |
|
194 | - ) { |
|
195 | - $actions['trash'] = '<a href="' |
|
196 | - . $trash_lnk_url |
|
197 | - . '" title="' |
|
198 | - . esc_attr__('Move Template Group to Trash', 'event_espresso') |
|
199 | - . '">' |
|
200 | - . esc_html__('Move to Trash', 'event_espresso') |
|
201 | - . '</a>'; |
|
202 | - } else { |
|
203 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
204 | - 'ee_delete_message', |
|
205 | - 'espresso_messages_restore_message_template', |
|
206 | - $item->ID() |
|
207 | - )) { |
|
208 | - $actions['restore'] = '<a href="' |
|
209 | - . $restore_lnk_url |
|
210 | - . '" title="' |
|
211 | - . esc_attr__('Restore Message Template', 'event_espresso') |
|
212 | - . '">' |
|
213 | - . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
214 | - } |
|
188 | + if (! $item->get('MTP_deleted') |
|
189 | + && EE_Registry::instance()->CAP->current_user_can( |
|
190 | + 'ee_delete_message', |
|
191 | + 'espresso_messages_trash_message_template', |
|
192 | + $item->ID() |
|
193 | + ) |
|
194 | + ) { |
|
195 | + $actions['trash'] = '<a href="' |
|
196 | + . $trash_lnk_url |
|
197 | + . '" title="' |
|
198 | + . esc_attr__('Move Template Group to Trash', 'event_espresso') |
|
199 | + . '">' |
|
200 | + . esc_html__('Move to Trash', 'event_espresso') |
|
201 | + . '</a>'; |
|
202 | + } else { |
|
203 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
204 | + 'ee_delete_message', |
|
205 | + 'espresso_messages_restore_message_template', |
|
206 | + $item->ID() |
|
207 | + )) { |
|
208 | + $actions['restore'] = '<a href="' |
|
209 | + . $restore_lnk_url |
|
210 | + . '" title="' |
|
211 | + . esc_attr__('Restore Message Template', 'event_espresso') |
|
212 | + . '">' |
|
213 | + . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
214 | + } |
|
215 | 215 | |
216 | - if ($this->_view === 'trashed' |
|
217 | - && EE_Registry::instance()->CAP->current_user_can( |
|
218 | - 'ee_delete_message', |
|
219 | - 'espresso_messages_delete_message_template', |
|
220 | - $item->ID() |
|
221 | - )) { |
|
222 | - $actions['delete'] = '<a href="' |
|
223 | - . $delete_lnk_url |
|
224 | - . '" title="' |
|
225 | - . esc_attr__('Delete Template Group Permanently', 'event_espresso') |
|
226 | - . '">' |
|
227 | - . esc_html__('Delete Permanently', 'event_espresso') |
|
228 | - . '</a>'; |
|
229 | - } |
|
230 | - } |
|
231 | - return $actions; |
|
232 | - } |
|
216 | + if ($this->_view === 'trashed' |
|
217 | + && EE_Registry::instance()->CAP->current_user_can( |
|
218 | + 'ee_delete_message', |
|
219 | + 'espresso_messages_delete_message_template', |
|
220 | + $item->ID() |
|
221 | + )) { |
|
222 | + $actions['delete'] = '<a href="' |
|
223 | + . $delete_lnk_url |
|
224 | + . '" title="' |
|
225 | + . esc_attr__('Delete Template Group Permanently', 'event_espresso') |
|
226 | + . '">' |
|
227 | + . esc_html__('Delete Permanently', 'event_espresso') |
|
228 | + . '</a>'; |
|
229 | + } |
|
230 | + } |
|
231 | + return $actions; |
|
232 | + } |
|
233 | 233 | |
234 | 234 | |
235 | - /** |
|
236 | - * Generate dropdown filter select input for messengers |
|
237 | - * @param bool $global |
|
238 | - * @return string |
|
239 | - * @throws EE_Error |
|
240 | - */ |
|
241 | - protected function _get_messengers_dropdown_filter($global = true) |
|
242 | - { |
|
243 | - return parent::_get_messengers_dropdown_filter(false); |
|
244 | - } |
|
235 | + /** |
|
236 | + * Generate dropdown filter select input for messengers |
|
237 | + * @param bool $global |
|
238 | + * @return string |
|
239 | + * @throws EE_Error |
|
240 | + */ |
|
241 | + protected function _get_messengers_dropdown_filter($global = true) |
|
242 | + { |
|
243 | + return parent::_get_messengers_dropdown_filter(false); |
|
244 | + } |
|
245 | 245 | |
246 | 246 | |
247 | - /** |
|
248 | - * Generate dropdown filter select input for message types |
|
249 | - * @param bool $global |
|
250 | - * @return string |
|
251 | - * @throws EE_Error |
|
252 | - */ |
|
253 | - protected function _get_message_types_dropdown_filter($global = true) |
|
254 | - { |
|
255 | - return parent::_get_message_types_dropdown_filter(false); |
|
256 | - } |
|
247 | + /** |
|
248 | + * Generate dropdown filter select input for message types |
|
249 | + * @param bool $global |
|
250 | + * @return string |
|
251 | + * @throws EE_Error |
|
252 | + */ |
|
253 | + protected function _get_message_types_dropdown_filter($global = true) |
|
254 | + { |
|
255 | + return parent::_get_message_types_dropdown_filter(false); |
|
256 | + } |
|
257 | 257 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | */ |
18 | 18 | protected function _setup_data() |
19 | 19 | { |
20 | - $this->_data = $this->get_admin_page()->get_message_templates( |
|
20 | + $this->_data = $this->get_admin_page()->get_message_templates( |
|
21 | 21 | $this->_per_page, |
22 | 22 | $this->_view, |
23 | 23 | false, |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function column_name($item) |
101 | 101 | { |
102 | - return '<p>' . $item->name() . '</p>'; |
|
102 | + return '<p>'.$item->name().'</p>'; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | 'noheader' => true, |
186 | 186 | ), EE_MSG_ADMIN_URL); |
187 | 187 | |
188 | - if (! $item->get('MTP_deleted') |
|
188 | + if ( ! $item->get('MTP_deleted') |
|
189 | 189 | && EE_Registry::instance()->CAP->current_user_can( |
190 | 190 | 'ee_delete_message', |
191 | 191 | 'espresso_messages_trash_message_template', |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | . '" title="' |
211 | 211 | . esc_attr__('Restore Message Template', 'event_espresso') |
212 | 212 | . '">' |
213 | - . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
213 | + . esc_html__('Restore', 'event_espresso').'</a>'; |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | if ($this->_view === 'trashed' |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | protected function _setup_data() |
29 | 29 | { |
30 | - $this->_data = $this->get_admin_page()->get_message_templates( |
|
30 | + $this->_data = $this->get_admin_page()->get_message_templates( |
|
31 | 31 | $this->_per_page, |
32 | 32 | $this->_view, |
33 | 33 | false |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | 'ajax' => true, //for now, |
53 | 53 | 'screen' => $this->get_admin_page()->get_current_screen()->id, |
54 | 54 | ); |
55 | - $this->_columns = array( |
|
55 | + $this->_columns = array( |
|
56 | 56 | //'cb' => '<input type="checkbox" />', //no deleting default (global) templates! |
57 | 57 | 'message_type' => esc_html__('Message Type', 'event_espresso'), |
58 | 58 | 'messenger' => esc_html__('Messenger', 'event_espresso'), |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $message_type = $item->message_type_obj(); |
81 | 81 | $messenger = $item->messenger_obj(); |
82 | 82 | |
83 | - if (! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) { |
|
83 | + if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) { |
|
84 | 84 | echo ''; |
85 | 85 | return; |
86 | 86 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function column_description($item) |
158 | 158 | { |
159 | - return '<p>' . $item->message_type_obj()->description . '</p>'; |
|
159 | + return '<p>'.$item->message_type_obj()->description.'</p>'; |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | { |
269 | 269 | $edit_url = ''; |
270 | 270 | // edit link but only if item isn't trashed. |
271 | - if (! $item->get('MTP_deleted') |
|
271 | + if ( ! $item->get('MTP_deleted') |
|
272 | 272 | && EE_Registry::instance()->CAP->current_user_can( |
273 | 273 | 'ee_edit_message', |
274 | 274 | 'espresso_messages_edit_message_template', |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | protected function _get_context_links(EE_Message_Template_Group $item) |
296 | 296 | { |
297 | 297 | //first check if we even show the context links or not. |
298 | - if (! EE_Registry::instance()->CAP->current_user_can( |
|
298 | + if ( ! EE_Registry::instance()->CAP->current_user_can( |
|
299 | 299 | 'ee_edit_message', |
300 | 300 | 'espresso_messages_edit_message_template', |
301 | 301 | $item->ID() |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | && $context_templates[$context]['to'] instanceof EE_Message_Template |
315 | 315 | ? $context_templates[$context]['to']->get('MTP_content') |
316 | 316 | : null; |
317 | - $inactive = empty($mtp_to) |
|
317 | + $inactive = empty($mtp_to) |
|
318 | 318 | && ! empty($context_templates[$context]['to']) |
319 | 319 | ? ' class="mtp-inactive"' |
320 | 320 | : ''; |
@@ -324,15 +324,15 @@ discard block |
||
324 | 324 | 'id' => $item->GRP_ID(), |
325 | 325 | 'context' => $context, |
326 | 326 | ), EE_MSG_ADMIN_URL); |
327 | - $ctxt[] = '<a' . $inactive |
|
328 | - . ' href="' . $edit_link . '"' |
|
329 | - . ' class="' . $item->message_type() . '-' . $context . '-edit-link"' |
|
330 | - . ' title="' . esc_attr__('Edit Context', 'event_espresso') . '">' |
|
327 | + $ctxt[] = '<a'.$inactive |
|
328 | + . ' href="'.$edit_link.'"' |
|
329 | + . ' class="'.$item->message_type().'-'.$context.'-edit-link"' |
|
330 | + . ' title="'.esc_attr__('Edit Context', 'event_espresso').'">' |
|
331 | 331 | . $context_title |
332 | 332 | . '</a>'; |
333 | 333 | } |
334 | 334 | |
335 | - return sprintf('<strong>%s:</strong> ', ucwords($c_label['plural'])) . implode(' | ', $ctxt); |
|
335 | + return sprintf('<strong>%s:</strong> ', ucwords($c_label['plural'])).implode(' | ', $ctxt); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | |
@@ -346,8 +346,8 @@ discard block |
||
346 | 346 | { |
347 | 347 | $edit_url = $this->_get_edit_url($item); |
348 | 348 | return $edit_url |
349 | - ? '<a href="' . $edit_url . '"' |
|
350 | - . ' title="' . esc_attr__('Edit Template Group', 'event_espresso') . '">' |
|
349 | + ? '<a href="'.$edit_url.'"' |
|
350 | + . ' title="'.esc_attr__('Edit Template Group', 'event_espresso').'">' |
|
351 | 351 | . ucwords($item->messenger_obj()->label['singular']) |
352 | 352 | . '</a>' |
353 | 353 | : ucwords($item->messenger_obj()->label['singular']); |
@@ -365,9 +365,9 @@ discard block |
||
365 | 365 | $actions = array(); |
366 | 366 | if ($edit_url = $this->_get_edit_url($item)) { |
367 | 367 | $actions = array( |
368 | - 'edit' => '<a href="' . $edit_url . '"' |
|
369 | - . ' class="' . $item->message_type() . '-edit-link"' |
|
370 | - . ' title="' . esc_attr__('Edit Template Group', 'event_espresso') . '">' |
|
368 | + 'edit' => '<a href="'.$edit_url.'"' |
|
369 | + . ' class="'.$item->message_type().'-edit-link"' |
|
370 | + . ' title="'.esc_attr__('Edit Template Group', 'event_espresso').'">' |
|
371 | 371 | . esc_html__('Edit', 'event_espresso') |
372 | 372 | . '</a>' |
373 | 373 | ); |
@@ -13,370 +13,370 @@ |
||
13 | 13 | { |
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * @return Messages_Admin_Page |
|
18 | - */ |
|
19 | - public function get_admin_page() |
|
20 | - { |
|
21 | - return $this->_admin_page; |
|
22 | - } |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * Setup data object |
|
27 | - */ |
|
28 | - protected function _setup_data() |
|
29 | - { |
|
30 | - $this->_data = $this->get_admin_page()->get_message_templates( |
|
31 | - $this->_per_page, |
|
32 | - $this->_view, |
|
33 | - false |
|
34 | - ); |
|
35 | - $this->_all_data_count = $this->get_admin_page()->get_message_templates( |
|
36 | - $this->_per_page, |
|
37 | - $this->_view, |
|
38 | - true, |
|
39 | - true |
|
40 | - ); |
|
41 | - } |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * Set internal properties |
|
46 | - */ |
|
47 | - protected function _set_properties() |
|
48 | - { |
|
49 | - $this->_wp_list_args = array( |
|
50 | - 'singular' => esc_html__('Message Template Group', 'event_espresso'), |
|
51 | - 'plural' => esc_html__('Message Template', 'event_espresso'), |
|
52 | - 'ajax' => true, //for now, |
|
53 | - 'screen' => $this->get_admin_page()->get_current_screen()->id, |
|
54 | - ); |
|
55 | - $this->_columns = array( |
|
56 | - //'cb' => '<input type="checkbox" />', //no deleting default (global) templates! |
|
57 | - 'message_type' => esc_html__('Message Type', 'event_espresso'), |
|
58 | - 'messenger' => esc_html__('Messenger', 'event_espresso'), |
|
59 | - 'description' => esc_html__('Description', 'event_espresso'), |
|
60 | - ); |
|
61 | - |
|
62 | - $this->_sortable_columns = array( |
|
63 | - 'messenger' => array('MTP_messenger' => true), |
|
64 | - ); |
|
65 | - |
|
66 | - $this->_hidden_columns = array(); |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * Overriding the single_row method from parent to verify whether the $item has an accessible |
|
72 | - * message_type or messenger object before generating the row. |
|
73 | - * |
|
74 | - * @param EE_Message_Template_Group $item |
|
75 | - * @return string |
|
76 | - * @throws EE_Error |
|
77 | - */ |
|
78 | - public function single_row($item) |
|
79 | - { |
|
80 | - $message_type = $item->message_type_obj(); |
|
81 | - $messenger = $item->messenger_obj(); |
|
82 | - |
|
83 | - if (! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) { |
|
84 | - echo ''; |
|
85 | - return; |
|
86 | - } |
|
87 | - |
|
88 | - parent::single_row($item); |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * @return array |
|
94 | - * @throws EE_Error |
|
95 | - */ |
|
96 | - protected function _get_table_filters() |
|
97 | - { |
|
98 | - $filters = array(); |
|
99 | - |
|
100 | - //get select inputs |
|
101 | - $select_inputs = array( |
|
102 | - $this->_get_messengers_dropdown_filter(), |
|
103 | - $this->_get_message_types_dropdown_filter(), |
|
104 | - ); |
|
105 | - |
|
106 | - //set filters to select inputs if they aren't empty |
|
107 | - foreach ($select_inputs as $select_input) { |
|
108 | - if ($select_input) { |
|
109 | - $filters[] = $select_input; |
|
110 | - } |
|
111 | - } |
|
112 | - return $filters; |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * We're just removing the search box for message templates, not needed. |
|
117 | - * |
|
118 | - * @param string $text |
|
119 | - * @param string $input_id |
|
120 | - * @return string ; |
|
121 | - */ |
|
122 | - public function search_box($text, $input_id) |
|
123 | - { |
|
124 | - return ''; |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * Add counts to the _views property |
|
130 | - */ |
|
131 | - protected function _add_view_counts() |
|
132 | - { |
|
133 | - foreach ($this->_views as $view => $args) { |
|
134 | - $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates( |
|
135 | - $this->_per_page, |
|
136 | - $view, |
|
137 | - true, |
|
138 | - true |
|
139 | - ); |
|
140 | - } |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * @param EE_Message_Template_Group $item |
|
146 | - * @return string |
|
147 | - */ |
|
148 | - public function column_cb($item) |
|
149 | - { |
|
150 | - return ''; |
|
151 | - } |
|
152 | - |
|
153 | - |
|
154 | - /** |
|
155 | - * @param EE_Message_Template_Group $item |
|
156 | - * @return string |
|
157 | - * @throws EE_Error |
|
158 | - */ |
|
159 | - public function column_description($item) |
|
160 | - { |
|
161 | - return '<p>' . $item->message_type_obj()->description . '</p>'; |
|
162 | - } |
|
163 | - |
|
164 | - |
|
165 | - /** |
|
166 | - * @param EE_Message_Template_Group $item |
|
167 | - * @return string |
|
168 | - * @throws EE_Error |
|
169 | - */ |
|
170 | - public function column_messenger($item) |
|
171 | - { |
|
172 | - //Return the name contents |
|
173 | - return sprintf( |
|
174 | - '%1$s <span style="color:silver">(id:%2$s)</span><br />%3$s%4$s', |
|
175 | - /* $1%s */ |
|
176 | - $this->_get_name_link_for_messenger($item), |
|
177 | - /* $2%s */ |
|
178 | - $item->GRP_ID(), |
|
179 | - /* %4$s */ |
|
180 | - $this->_get_context_links($item), |
|
181 | - /* $3%s */ |
|
182 | - $this->row_actions($this->_get_actions_for_messenger_column($item)) |
|
183 | - ); |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * column_message_type |
|
188 | - * |
|
189 | - * @param EE_Message_Template_Group $item message info for the row |
|
190 | - * @return string message_type name |
|
191 | - * @throws EE_Error |
|
192 | - */ |
|
193 | - public function column_message_type($item) |
|
194 | - { |
|
195 | - return ucwords($item->message_type_obj()->label['singular']); |
|
196 | - } |
|
197 | - |
|
198 | - |
|
199 | - /** |
|
200 | - * Generate dropdown filter select input for messengers |
|
201 | - * |
|
202 | - * @param bool $global |
|
203 | - * @return string |
|
204 | - * @throws EE_Error |
|
205 | - */ |
|
206 | - protected function _get_messengers_dropdown_filter($global = true) |
|
207 | - { |
|
208 | - $messenger_options = array(); |
|
209 | - $active_message_template_groups_grouped_by_messenger = EEM_Message_Template_Group::instance()->get_all( |
|
210 | - array( |
|
211 | - array( |
|
212 | - 'MTP_is_active' => true, |
|
213 | - 'MTP_is_global' => $global, |
|
214 | - ), |
|
215 | - 'group_by' => 'MTP_messenger', |
|
216 | - ) |
|
217 | - ); |
|
218 | - |
|
219 | - foreach ($active_message_template_groups_grouped_by_messenger as $active_message_template_group) { |
|
220 | - if ($active_message_template_group instanceof EE_Message_Template_Group) { |
|
221 | - $messenger = $active_message_template_group->messenger_obj(); |
|
222 | - $messenger_label = $messenger instanceof EE_messenger |
|
223 | - ? $messenger->label['singular'] |
|
224 | - : $active_message_template_group->messenger(); |
|
225 | - $messenger_options[$active_message_template_group->messenger()] = ucwords($messenger_label); |
|
226 | - } |
|
227 | - } |
|
228 | - return $this->get_admin_page()->get_messengers_select_input($messenger_options); |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - /** |
|
233 | - * Generate dropdown filter select input for message types |
|
234 | - * |
|
235 | - * @param bool $global |
|
236 | - * @return string |
|
237 | - * @throws EE_Error |
|
238 | - */ |
|
239 | - protected function _get_message_types_dropdown_filter($global = true) |
|
240 | - { |
|
241 | - $message_type_options = array(); |
|
242 | - $active_message_template_groups_grouped_by_message_type = EEM_Message_Template_Group::instance()->get_all( |
|
243 | - array( |
|
244 | - array( |
|
245 | - 'MTP_is_active' => true, |
|
246 | - 'MTP_is_global' => true, |
|
247 | - ), |
|
248 | - 'group_by' => 'MTP_message_type', |
|
249 | - ) |
|
250 | - ); |
|
251 | - |
|
252 | - foreach ($active_message_template_groups_grouped_by_message_type as $active_message_template_group) { |
|
253 | - if ($active_message_template_group instanceof EE_Message_Template_Group) { |
|
254 | - $message_type = $active_message_template_group->message_type_obj(); |
|
255 | - $message_type_label = $message_type instanceof EE_message_type |
|
256 | - ? $message_type->label['singular'] |
|
257 | - : $active_message_template_group->message_type(); |
|
258 | - $message_type_options[$active_message_template_group->message_type()] = ucwords($message_type_label); |
|
259 | - } |
|
260 | - } |
|
261 | - return $this->get_admin_page()->get_message_types_select_input($message_type_options); |
|
262 | - } |
|
263 | - |
|
264 | - |
|
265 | - /** |
|
266 | - * Return the edit url for the message template group. |
|
267 | - * @param EE_Message_Template_Group $item |
|
268 | - * @return string |
|
269 | - * @throws EE_Error |
|
270 | - */ |
|
271 | - protected function _get_edit_url(EE_Message_Template_Group $item) |
|
272 | - { |
|
273 | - $edit_url = ''; |
|
274 | - // edit link but only if item isn't trashed. |
|
275 | - if (! $item->get('MTP_deleted') |
|
276 | - && EE_Registry::instance()->CAP->current_user_can( |
|
277 | - 'ee_edit_message', |
|
278 | - 'espresso_messages_edit_message_template', |
|
279 | - $item->ID() |
|
280 | - )) { |
|
281 | - $edit_url = EE_Admin_Page::add_query_args_and_nonce( |
|
282 | - array( |
|
283 | - 'action' => 'edit_message_template', |
|
284 | - 'id' => $item->GRP_ID(), |
|
285 | - ), |
|
286 | - EE_MSG_ADMIN_URL |
|
287 | - ); |
|
288 | - } |
|
289 | - return $edit_url; |
|
290 | - } |
|
291 | - |
|
292 | - |
|
293 | - /** |
|
294 | - * Get the context link string for the messenger column. |
|
295 | - * @param EE_Message_Template_Group $item |
|
296 | - * @return string |
|
297 | - * @throws EE_Error |
|
298 | - */ |
|
299 | - protected function _get_context_links(EE_Message_Template_Group $item) |
|
300 | - { |
|
301 | - //first check if we even show the context links or not. |
|
302 | - if (! EE_Registry::instance()->CAP->current_user_can( |
|
303 | - 'ee_edit_message', |
|
304 | - 'espresso_messages_edit_message_template', |
|
305 | - $item->ID() |
|
306 | - ) |
|
307 | - || $item->get('MTP_deleted') |
|
308 | - ) { |
|
309 | - return ''; |
|
310 | - } |
|
311 | - //we want to display the contexts in here so we need to set them up |
|
312 | - $c_label = $item->context_label(); |
|
313 | - $c_configs = $item->contexts_config(); |
|
314 | - $ctxt = array(); |
|
315 | - $context_templates = $item->context_templates(); |
|
316 | - foreach ($context_templates as $context => $template_fields) { |
|
317 | - $mtp_to = ! empty($context_templates[$context]['to']) |
|
318 | - && $context_templates[$context]['to'] instanceof EE_Message_Template |
|
319 | - ? $context_templates[$context]['to']->get('MTP_content') |
|
320 | - : null; |
|
321 | - $inactive = empty($mtp_to) |
|
322 | - && ! empty($context_templates[$context]['to']) |
|
323 | - ? ' class="mtp-inactive"' |
|
324 | - : ''; |
|
325 | - $context_title = ucwords($c_configs[$context]['label']); |
|
326 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce(array( |
|
327 | - 'action' => 'edit_message_template', |
|
328 | - 'id' => $item->GRP_ID(), |
|
329 | - 'context' => $context, |
|
330 | - ), EE_MSG_ADMIN_URL); |
|
331 | - $ctxt[] = '<a' . $inactive |
|
332 | - . ' href="' . $edit_link . '"' |
|
333 | - . ' class="' . $item->message_type() . '-' . $context . '-edit-link"' |
|
334 | - . ' title="' . esc_attr__('Edit Context', 'event_espresso') . '">' |
|
335 | - . $context_title |
|
336 | - . '</a>'; |
|
337 | - } |
|
338 | - |
|
339 | - return sprintf('<strong>%s:</strong> ', ucwords($c_label['plural'])) . implode(' | ', $ctxt); |
|
340 | - } |
|
341 | - |
|
342 | - |
|
343 | - /** |
|
344 | - * Get the Name string from the messenger column (linked to edit if the context allows for that). |
|
345 | - * @param EE_Message_Template_Group $item |
|
346 | - * @return string |
|
347 | - * @throws EE_Error |
|
348 | - */ |
|
349 | - protected function _get_name_link_for_messenger(EE_Message_Template_Group $item) |
|
350 | - { |
|
351 | - $edit_url = $this->_get_edit_url($item); |
|
352 | - return $edit_url |
|
353 | - ? '<a href="' . $edit_url . '"' |
|
354 | - . ' title="' . esc_attr__('Edit Template Group', 'event_espresso') . '">' |
|
355 | - . ucwords($item->messenger_obj()->label['singular']) |
|
356 | - . '</a>' |
|
357 | - : ucwords($item->messenger_obj()->label['singular']); |
|
358 | - } |
|
359 | - |
|
360 | - |
|
361 | - /** |
|
362 | - * Return the actions array for the messenger column. |
|
363 | - * @param EE_Message_Template_Group $item |
|
364 | - * @return array |
|
365 | - * @throws EE_Error |
|
366 | - */ |
|
367 | - protected function _get_actions_for_messenger_column(EE_Message_Template_Group $item) |
|
368 | - { |
|
369 | - $actions = array(); |
|
370 | - if ($edit_url = $this->_get_edit_url($item)) { |
|
371 | - $actions = array( |
|
372 | - 'edit' => '<a href="' . $edit_url . '"' |
|
373 | - . ' class="' . $item->message_type() . '-edit-link"' |
|
374 | - . ' title="' . esc_attr__('Edit Template Group', 'event_espresso') . '">' |
|
375 | - . esc_html__('Edit', 'event_espresso') |
|
376 | - . '</a>' |
|
377 | - ); |
|
378 | - } |
|
379 | - return $actions; |
|
380 | - } |
|
16 | + /** |
|
17 | + * @return Messages_Admin_Page |
|
18 | + */ |
|
19 | + public function get_admin_page() |
|
20 | + { |
|
21 | + return $this->_admin_page; |
|
22 | + } |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * Setup data object |
|
27 | + */ |
|
28 | + protected function _setup_data() |
|
29 | + { |
|
30 | + $this->_data = $this->get_admin_page()->get_message_templates( |
|
31 | + $this->_per_page, |
|
32 | + $this->_view, |
|
33 | + false |
|
34 | + ); |
|
35 | + $this->_all_data_count = $this->get_admin_page()->get_message_templates( |
|
36 | + $this->_per_page, |
|
37 | + $this->_view, |
|
38 | + true, |
|
39 | + true |
|
40 | + ); |
|
41 | + } |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * Set internal properties |
|
46 | + */ |
|
47 | + protected function _set_properties() |
|
48 | + { |
|
49 | + $this->_wp_list_args = array( |
|
50 | + 'singular' => esc_html__('Message Template Group', 'event_espresso'), |
|
51 | + 'plural' => esc_html__('Message Template', 'event_espresso'), |
|
52 | + 'ajax' => true, //for now, |
|
53 | + 'screen' => $this->get_admin_page()->get_current_screen()->id, |
|
54 | + ); |
|
55 | + $this->_columns = array( |
|
56 | + //'cb' => '<input type="checkbox" />', //no deleting default (global) templates! |
|
57 | + 'message_type' => esc_html__('Message Type', 'event_espresso'), |
|
58 | + 'messenger' => esc_html__('Messenger', 'event_espresso'), |
|
59 | + 'description' => esc_html__('Description', 'event_espresso'), |
|
60 | + ); |
|
61 | + |
|
62 | + $this->_sortable_columns = array( |
|
63 | + 'messenger' => array('MTP_messenger' => true), |
|
64 | + ); |
|
65 | + |
|
66 | + $this->_hidden_columns = array(); |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * Overriding the single_row method from parent to verify whether the $item has an accessible |
|
72 | + * message_type or messenger object before generating the row. |
|
73 | + * |
|
74 | + * @param EE_Message_Template_Group $item |
|
75 | + * @return string |
|
76 | + * @throws EE_Error |
|
77 | + */ |
|
78 | + public function single_row($item) |
|
79 | + { |
|
80 | + $message_type = $item->message_type_obj(); |
|
81 | + $messenger = $item->messenger_obj(); |
|
82 | + |
|
83 | + if (! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) { |
|
84 | + echo ''; |
|
85 | + return; |
|
86 | + } |
|
87 | + |
|
88 | + parent::single_row($item); |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * @return array |
|
94 | + * @throws EE_Error |
|
95 | + */ |
|
96 | + protected function _get_table_filters() |
|
97 | + { |
|
98 | + $filters = array(); |
|
99 | + |
|
100 | + //get select inputs |
|
101 | + $select_inputs = array( |
|
102 | + $this->_get_messengers_dropdown_filter(), |
|
103 | + $this->_get_message_types_dropdown_filter(), |
|
104 | + ); |
|
105 | + |
|
106 | + //set filters to select inputs if they aren't empty |
|
107 | + foreach ($select_inputs as $select_input) { |
|
108 | + if ($select_input) { |
|
109 | + $filters[] = $select_input; |
|
110 | + } |
|
111 | + } |
|
112 | + return $filters; |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * We're just removing the search box for message templates, not needed. |
|
117 | + * |
|
118 | + * @param string $text |
|
119 | + * @param string $input_id |
|
120 | + * @return string ; |
|
121 | + */ |
|
122 | + public function search_box($text, $input_id) |
|
123 | + { |
|
124 | + return ''; |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * Add counts to the _views property |
|
130 | + */ |
|
131 | + protected function _add_view_counts() |
|
132 | + { |
|
133 | + foreach ($this->_views as $view => $args) { |
|
134 | + $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates( |
|
135 | + $this->_per_page, |
|
136 | + $view, |
|
137 | + true, |
|
138 | + true |
|
139 | + ); |
|
140 | + } |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * @param EE_Message_Template_Group $item |
|
146 | + * @return string |
|
147 | + */ |
|
148 | + public function column_cb($item) |
|
149 | + { |
|
150 | + return ''; |
|
151 | + } |
|
152 | + |
|
153 | + |
|
154 | + /** |
|
155 | + * @param EE_Message_Template_Group $item |
|
156 | + * @return string |
|
157 | + * @throws EE_Error |
|
158 | + */ |
|
159 | + public function column_description($item) |
|
160 | + { |
|
161 | + return '<p>' . $item->message_type_obj()->description . '</p>'; |
|
162 | + } |
|
163 | + |
|
164 | + |
|
165 | + /** |
|
166 | + * @param EE_Message_Template_Group $item |
|
167 | + * @return string |
|
168 | + * @throws EE_Error |
|
169 | + */ |
|
170 | + public function column_messenger($item) |
|
171 | + { |
|
172 | + //Return the name contents |
|
173 | + return sprintf( |
|
174 | + '%1$s <span style="color:silver">(id:%2$s)</span><br />%3$s%4$s', |
|
175 | + /* $1%s */ |
|
176 | + $this->_get_name_link_for_messenger($item), |
|
177 | + /* $2%s */ |
|
178 | + $item->GRP_ID(), |
|
179 | + /* %4$s */ |
|
180 | + $this->_get_context_links($item), |
|
181 | + /* $3%s */ |
|
182 | + $this->row_actions($this->_get_actions_for_messenger_column($item)) |
|
183 | + ); |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * column_message_type |
|
188 | + * |
|
189 | + * @param EE_Message_Template_Group $item message info for the row |
|
190 | + * @return string message_type name |
|
191 | + * @throws EE_Error |
|
192 | + */ |
|
193 | + public function column_message_type($item) |
|
194 | + { |
|
195 | + return ucwords($item->message_type_obj()->label['singular']); |
|
196 | + } |
|
197 | + |
|
198 | + |
|
199 | + /** |
|
200 | + * Generate dropdown filter select input for messengers |
|
201 | + * |
|
202 | + * @param bool $global |
|
203 | + * @return string |
|
204 | + * @throws EE_Error |
|
205 | + */ |
|
206 | + protected function _get_messengers_dropdown_filter($global = true) |
|
207 | + { |
|
208 | + $messenger_options = array(); |
|
209 | + $active_message_template_groups_grouped_by_messenger = EEM_Message_Template_Group::instance()->get_all( |
|
210 | + array( |
|
211 | + array( |
|
212 | + 'MTP_is_active' => true, |
|
213 | + 'MTP_is_global' => $global, |
|
214 | + ), |
|
215 | + 'group_by' => 'MTP_messenger', |
|
216 | + ) |
|
217 | + ); |
|
218 | + |
|
219 | + foreach ($active_message_template_groups_grouped_by_messenger as $active_message_template_group) { |
|
220 | + if ($active_message_template_group instanceof EE_Message_Template_Group) { |
|
221 | + $messenger = $active_message_template_group->messenger_obj(); |
|
222 | + $messenger_label = $messenger instanceof EE_messenger |
|
223 | + ? $messenger->label['singular'] |
|
224 | + : $active_message_template_group->messenger(); |
|
225 | + $messenger_options[$active_message_template_group->messenger()] = ucwords($messenger_label); |
|
226 | + } |
|
227 | + } |
|
228 | + return $this->get_admin_page()->get_messengers_select_input($messenger_options); |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + /** |
|
233 | + * Generate dropdown filter select input for message types |
|
234 | + * |
|
235 | + * @param bool $global |
|
236 | + * @return string |
|
237 | + * @throws EE_Error |
|
238 | + */ |
|
239 | + protected function _get_message_types_dropdown_filter($global = true) |
|
240 | + { |
|
241 | + $message_type_options = array(); |
|
242 | + $active_message_template_groups_grouped_by_message_type = EEM_Message_Template_Group::instance()->get_all( |
|
243 | + array( |
|
244 | + array( |
|
245 | + 'MTP_is_active' => true, |
|
246 | + 'MTP_is_global' => true, |
|
247 | + ), |
|
248 | + 'group_by' => 'MTP_message_type', |
|
249 | + ) |
|
250 | + ); |
|
251 | + |
|
252 | + foreach ($active_message_template_groups_grouped_by_message_type as $active_message_template_group) { |
|
253 | + if ($active_message_template_group instanceof EE_Message_Template_Group) { |
|
254 | + $message_type = $active_message_template_group->message_type_obj(); |
|
255 | + $message_type_label = $message_type instanceof EE_message_type |
|
256 | + ? $message_type->label['singular'] |
|
257 | + : $active_message_template_group->message_type(); |
|
258 | + $message_type_options[$active_message_template_group->message_type()] = ucwords($message_type_label); |
|
259 | + } |
|
260 | + } |
|
261 | + return $this->get_admin_page()->get_message_types_select_input($message_type_options); |
|
262 | + } |
|
263 | + |
|
264 | + |
|
265 | + /** |
|
266 | + * Return the edit url for the message template group. |
|
267 | + * @param EE_Message_Template_Group $item |
|
268 | + * @return string |
|
269 | + * @throws EE_Error |
|
270 | + */ |
|
271 | + protected function _get_edit_url(EE_Message_Template_Group $item) |
|
272 | + { |
|
273 | + $edit_url = ''; |
|
274 | + // edit link but only if item isn't trashed. |
|
275 | + if (! $item->get('MTP_deleted') |
|
276 | + && EE_Registry::instance()->CAP->current_user_can( |
|
277 | + 'ee_edit_message', |
|
278 | + 'espresso_messages_edit_message_template', |
|
279 | + $item->ID() |
|
280 | + )) { |
|
281 | + $edit_url = EE_Admin_Page::add_query_args_and_nonce( |
|
282 | + array( |
|
283 | + 'action' => 'edit_message_template', |
|
284 | + 'id' => $item->GRP_ID(), |
|
285 | + ), |
|
286 | + EE_MSG_ADMIN_URL |
|
287 | + ); |
|
288 | + } |
|
289 | + return $edit_url; |
|
290 | + } |
|
291 | + |
|
292 | + |
|
293 | + /** |
|
294 | + * Get the context link string for the messenger column. |
|
295 | + * @param EE_Message_Template_Group $item |
|
296 | + * @return string |
|
297 | + * @throws EE_Error |
|
298 | + */ |
|
299 | + protected function _get_context_links(EE_Message_Template_Group $item) |
|
300 | + { |
|
301 | + //first check if we even show the context links or not. |
|
302 | + if (! EE_Registry::instance()->CAP->current_user_can( |
|
303 | + 'ee_edit_message', |
|
304 | + 'espresso_messages_edit_message_template', |
|
305 | + $item->ID() |
|
306 | + ) |
|
307 | + || $item->get('MTP_deleted') |
|
308 | + ) { |
|
309 | + return ''; |
|
310 | + } |
|
311 | + //we want to display the contexts in here so we need to set them up |
|
312 | + $c_label = $item->context_label(); |
|
313 | + $c_configs = $item->contexts_config(); |
|
314 | + $ctxt = array(); |
|
315 | + $context_templates = $item->context_templates(); |
|
316 | + foreach ($context_templates as $context => $template_fields) { |
|
317 | + $mtp_to = ! empty($context_templates[$context]['to']) |
|
318 | + && $context_templates[$context]['to'] instanceof EE_Message_Template |
|
319 | + ? $context_templates[$context]['to']->get('MTP_content') |
|
320 | + : null; |
|
321 | + $inactive = empty($mtp_to) |
|
322 | + && ! empty($context_templates[$context]['to']) |
|
323 | + ? ' class="mtp-inactive"' |
|
324 | + : ''; |
|
325 | + $context_title = ucwords($c_configs[$context]['label']); |
|
326 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce(array( |
|
327 | + 'action' => 'edit_message_template', |
|
328 | + 'id' => $item->GRP_ID(), |
|
329 | + 'context' => $context, |
|
330 | + ), EE_MSG_ADMIN_URL); |
|
331 | + $ctxt[] = '<a' . $inactive |
|
332 | + . ' href="' . $edit_link . '"' |
|
333 | + . ' class="' . $item->message_type() . '-' . $context . '-edit-link"' |
|
334 | + . ' title="' . esc_attr__('Edit Context', 'event_espresso') . '">' |
|
335 | + . $context_title |
|
336 | + . '</a>'; |
|
337 | + } |
|
338 | + |
|
339 | + return sprintf('<strong>%s:</strong> ', ucwords($c_label['plural'])) . implode(' | ', $ctxt); |
|
340 | + } |
|
341 | + |
|
342 | + |
|
343 | + /** |
|
344 | + * Get the Name string from the messenger column (linked to edit if the context allows for that). |
|
345 | + * @param EE_Message_Template_Group $item |
|
346 | + * @return string |
|
347 | + * @throws EE_Error |
|
348 | + */ |
|
349 | + protected function _get_name_link_for_messenger(EE_Message_Template_Group $item) |
|
350 | + { |
|
351 | + $edit_url = $this->_get_edit_url($item); |
|
352 | + return $edit_url |
|
353 | + ? '<a href="' . $edit_url . '"' |
|
354 | + . ' title="' . esc_attr__('Edit Template Group', 'event_espresso') . '">' |
|
355 | + . ucwords($item->messenger_obj()->label['singular']) |
|
356 | + . '</a>' |
|
357 | + : ucwords($item->messenger_obj()->label['singular']); |
|
358 | + } |
|
359 | + |
|
360 | + |
|
361 | + /** |
|
362 | + * Return the actions array for the messenger column. |
|
363 | + * @param EE_Message_Template_Group $item |
|
364 | + * @return array |
|
365 | + * @throws EE_Error |
|
366 | + */ |
|
367 | + protected function _get_actions_for_messenger_column(EE_Message_Template_Group $item) |
|
368 | + { |
|
369 | + $actions = array(); |
|
370 | + if ($edit_url = $this->_get_edit_url($item)) { |
|
371 | + $actions = array( |
|
372 | + 'edit' => '<a href="' . $edit_url . '"' |
|
373 | + . ' class="' . $item->message_type() . '-edit-link"' |
|
374 | + . ' title="' . esc_attr__('Edit Template Group', 'event_espresso') . '">' |
|
375 | + . esc_html__('Edit', 'event_espresso') |
|
376 | + . '</a>' |
|
377 | + ); |
|
378 | + } |
|
379 | + return $actions; |
|
380 | + } |
|
381 | 381 | } |
382 | 382 |
@@ -21,59 +21,59 @@ |
||
21 | 21 | { |
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * the actual shortcode tag that gets registered with WordPress |
|
26 | - * |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - public function getTag() |
|
30 | - { |
|
31 | - return 'ESPRESSO_CHECKOUT'; |
|
32 | - } |
|
33 | - |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * the time in seconds to cache the results of the processShortcode() method |
|
38 | - * 0 means the processShortcode() results will NOT be cached at all |
|
39 | - * |
|
40 | - * @return int |
|
41 | - */ |
|
42 | - public function cacheExpiration() |
|
43 | - { |
|
44 | - return 0; |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
50 | - * this may be required for shortcodes that utilize a corresponding module, |
|
51 | - * and need to enqueue assets for that module |
|
52 | - * |
|
53 | - * @return void |
|
54 | - * @throws \EE_Error |
|
55 | - */ |
|
56 | - public function initializeShortcode() |
|
57 | - { |
|
58 | - global $wp_query; |
|
59 | - EED_Single_Page_Checkout::init($wp_query); |
|
60 | - $this->shortcodeHasBeenInitialized(); |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * callback that runs when the shortcode is encountered in post content. |
|
67 | - * IMPORTANT !!! |
|
68 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
69 | - * |
|
70 | - * @param array $attributes |
|
71 | - * @return string |
|
72 | - */ |
|
73 | - public function processShortcode($attributes = array()) |
|
74 | - { |
|
75 | - return EE_Registry::instance()->REQ->get_output(); |
|
76 | - } |
|
24 | + /** |
|
25 | + * the actual shortcode tag that gets registered with WordPress |
|
26 | + * |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + public function getTag() |
|
30 | + { |
|
31 | + return 'ESPRESSO_CHECKOUT'; |
|
32 | + } |
|
33 | + |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * the time in seconds to cache the results of the processShortcode() method |
|
38 | + * 0 means the processShortcode() results will NOT be cached at all |
|
39 | + * |
|
40 | + * @return int |
|
41 | + */ |
|
42 | + public function cacheExpiration() |
|
43 | + { |
|
44 | + return 0; |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
50 | + * this may be required for shortcodes that utilize a corresponding module, |
|
51 | + * and need to enqueue assets for that module |
|
52 | + * |
|
53 | + * @return void |
|
54 | + * @throws \EE_Error |
|
55 | + */ |
|
56 | + public function initializeShortcode() |
|
57 | + { |
|
58 | + global $wp_query; |
|
59 | + EED_Single_Page_Checkout::init($wp_query); |
|
60 | + $this->shortcodeHasBeenInitialized(); |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * callback that runs when the shortcode is encountered in post content. |
|
67 | + * IMPORTANT !!! |
|
68 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
69 | + * |
|
70 | + * @param array $attributes |
|
71 | + * @return string |
|
72 | + */ |
|
73 | + public function processShortcode($attributes = array()) |
|
74 | + { |
|
75 | + return EE_Registry::instance()->REQ->get_output(); |
|
76 | + } |
|
77 | 77 | |
78 | 78 | |
79 | 79 |