@@ -16,9 +16,9 @@ discard block |
||
16 | 16 | $stages = glob(EE_CORE . 'data_migration_scripts/4_5_0_stages/*'); |
17 | 17 | $class_to_filepath = array(); |
18 | 18 | foreach ($stages as $filepath) { |
19 | - $matches = array(); |
|
20 | - preg_match('~4_5_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
21 | - $class_to_filepath[$matches[1]] = $filepath; |
|
19 | + $matches = array(); |
|
20 | + preg_match('~4_5_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
21 | + $class_to_filepath[$matches[1]] = $filepath; |
|
22 | 22 | } |
23 | 23 | //give addons a chance to autoload their stages too |
24 | 24 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_5_0__autoloaded_stages', $class_to_filepath); |
@@ -31,66 +31,66 @@ discard block |
||
31 | 31 | |
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * EE_DMS_Core_4_5_0 constructor. |
|
36 | - * |
|
37 | - * @param TableManager $table_manager |
|
38 | - * @param TableAnalysis $table_analysis |
|
39 | - */ |
|
40 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
41 | - { |
|
42 | - $this->_pretty_name = __("Data Migration to Event Espresso 4.5.0.P", "event_espresso"); |
|
43 | - $this->_priority = 10; |
|
44 | - $this->_migration_stages = array( |
|
45 | - new EE_DMS_4_5_0_update_wp_user_for_tickets(), |
|
46 | - new EE_DMS_4_5_0_update_wp_user_for_prices(), |
|
47 | - new EE_DMS_4_5_0_update_wp_user_for_price_types(), |
|
48 | - new EE_DMS_4_5_0_update_wp_user_for_question_groups(), |
|
49 | - new EE_DMS_4_5_0_invoice_settings(), |
|
50 | - ); |
|
51 | - parent::__construct($table_manager, $table_analysis); |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - |
|
56 | - public function can_migrate_from_version($version_array) |
|
57 | - { |
|
58 | - $version_string = $version_array['Core']; |
|
59 | - if (version_compare($version_string, '4.5.0', '<=') && version_compare($version_string, '4.3.0', '>=')) { |
|
34 | + /** |
|
35 | + * EE_DMS_Core_4_5_0 constructor. |
|
36 | + * |
|
37 | + * @param TableManager $table_manager |
|
38 | + * @param TableAnalysis $table_analysis |
|
39 | + */ |
|
40 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
41 | + { |
|
42 | + $this->_pretty_name = __("Data Migration to Event Espresso 4.5.0.P", "event_espresso"); |
|
43 | + $this->_priority = 10; |
|
44 | + $this->_migration_stages = array( |
|
45 | + new EE_DMS_4_5_0_update_wp_user_for_tickets(), |
|
46 | + new EE_DMS_4_5_0_update_wp_user_for_prices(), |
|
47 | + new EE_DMS_4_5_0_update_wp_user_for_price_types(), |
|
48 | + new EE_DMS_4_5_0_update_wp_user_for_question_groups(), |
|
49 | + new EE_DMS_4_5_0_invoice_settings(), |
|
50 | + ); |
|
51 | + parent::__construct($table_manager, $table_analysis); |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + |
|
56 | + public function can_migrate_from_version($version_array) |
|
57 | + { |
|
58 | + $version_string = $version_array['Core']; |
|
59 | + if (version_compare($version_string, '4.5.0', '<=') && version_compare($version_string, '4.3.0', '>=')) { |
|
60 | 60 | // echo "$version_string can be migrated from"; |
61 | - return true; |
|
62 | - } elseif ( ! $version_string) { |
|
61 | + return true; |
|
62 | + } elseif ( ! $version_string) { |
|
63 | 63 | // echo "no version string provided: $version_string"; |
64 | - //no version string provided... this must be pre 4.3 |
|
65 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
66 | - } else { |
|
64 | + //no version string provided... this must be pre 4.3 |
|
65 | + return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
66 | + } else { |
|
67 | 67 | // echo "$version_string doesnt apply"; |
68 | - return false; |
|
69 | - } |
|
70 | - } |
|
68 | + return false; |
|
69 | + } |
|
70 | + } |
|
71 | 71 | |
72 | 72 | |
73 | 73 | |
74 | - public function pretty_name() |
|
75 | - { |
|
76 | - return __("Core Data Migration to version 4.5.0", "event_espresso"); |
|
77 | - } |
|
74 | + public function pretty_name() |
|
75 | + { |
|
76 | + return __("Core Data Migration to version 4.5.0", "event_espresso"); |
|
77 | + } |
|
78 | 78 | |
79 | 79 | |
80 | 80 | |
81 | - public function schema_changes_before_migration() |
|
82 | - { |
|
83 | - //relies on 4.1's EEH_Activation::create_table |
|
84 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
85 | - $table_name = 'esp_answer'; |
|
86 | - $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
81 | + public function schema_changes_before_migration() |
|
82 | + { |
|
83 | + //relies on 4.1's EEH_Activation::create_table |
|
84 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
85 | + $table_name = 'esp_answer'; |
|
86 | + $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
87 | 87 | REG_ID INT UNSIGNED NOT NULL, |
88 | 88 | QST_ID INT UNSIGNED NOT NULL, |
89 | 89 | ANS_value TEXT NOT NULL, |
90 | 90 | PRIMARY KEY (ANS_ID)"; |
91 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
92 | - $table_name = 'esp_attendee_meta'; |
|
93 | - $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
91 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
92 | + $table_name = 'esp_attendee_meta'; |
|
93 | + $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
94 | 94 | ATT_ID BIGINT(20) UNSIGNED NOT NULL, |
95 | 95 | ATT_fname VARCHAR(45) NOT NULL, |
96 | 96 | ATT_lname VARCHAR(45) NOT NULL, |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | KEY ATT_fname (ATT_fname), |
107 | 107 | KEY ATT_lname (ATT_lname), |
108 | 108 | KEY ATT_email (ATT_email)"; |
109 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
110 | - $table_name = 'esp_country'; |
|
111 | - $sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
|
109 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
110 | + $table_name = 'esp_country'; |
|
111 | + $sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
|
112 | 112 | CNT_ISO3 VARCHAR(3) COLLATE utf8_bin NOT NULL, |
113 | 113 | RGN_ID TINYINT(3) UNSIGNED DEFAULT NULL, |
114 | 114 | CNT_name VARCHAR(45) COLLATE utf8_bin NOT NULL, |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | CNT_is_EU TINYINT(1) DEFAULT '0', |
125 | 125 | CNT_active TINYINT(1) DEFAULT '0', |
126 | 126 | PRIMARY KEY (CNT_ISO)"; |
127 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
128 | - $table_name = 'esp_datetime'; |
|
129 | - $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
127 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
128 | + $table_name = 'esp_datetime'; |
|
129 | + $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
130 | 130 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
131 | 131 | DTT_name VARCHAR(255) NOT NULL DEFAULT '', |
132 | 132 | DTT_description TEXT NOT NULL, |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | PRIMARY KEY (DTT_ID), |
142 | 142 | KEY EVT_ID (EVT_ID), |
143 | 143 | KEY DTT_is_primary (DTT_is_primary)"; |
144 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
145 | - $table_name = 'esp_event_meta'; |
|
146 | - $sql = " |
|
144 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
145 | + $table_name = 'esp_event_meta'; |
|
146 | + $sql = " |
|
147 | 147 | EVTM_ID INT NOT NULL AUTO_INCREMENT, |
148 | 148 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
149 | 149 | EVT_display_desc TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
@@ -158,31 +158,31 @@ discard block |
||
158 | 158 | EVT_external_URL VARCHAR(200) NULL, |
159 | 159 | EVT_donations TINYINT(1) NULL, |
160 | 160 | PRIMARY KEY (EVTM_ID)"; |
161 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
162 | - $table_name = 'esp_event_question_group'; |
|
163 | - $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
161 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
162 | + $table_name = 'esp_event_question_group'; |
|
163 | + $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
164 | 164 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
165 | 165 | QSG_ID INT UNSIGNED NOT NULL, |
166 | 166 | EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
167 | 167 | PRIMARY KEY (EQG_ID)"; |
168 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
169 | - $table_name = 'esp_event_venue'; |
|
170 | - $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
168 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
169 | + $table_name = 'esp_event_venue'; |
|
170 | + $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
171 | 171 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
172 | 172 | VNU_ID BIGINT(20) UNSIGNED NOT NULL, |
173 | 173 | EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
174 | 174 | PRIMARY KEY (EVV_ID)"; |
175 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
176 | - $table_name = 'esp_extra_meta'; |
|
177 | - $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
175 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
176 | + $table_name = 'esp_extra_meta'; |
|
177 | + $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
178 | 178 | OBJ_ID INT(11) DEFAULT NULL, |
179 | 179 | EXM_type VARCHAR(45) DEFAULT NULL, |
180 | 180 | EXM_key VARCHAR(45) DEFAULT NULL, |
181 | 181 | EXM_value TEXT, |
182 | 182 | PRIMARY KEY (EXM_ID)"; |
183 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
184 | - $table_name = 'esp_line_item'; |
|
185 | - $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
183 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
184 | + $table_name = 'esp_line_item'; |
|
185 | + $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
186 | 186 | LIN_code VARCHAR(245) NOT NULL DEFAULT '', |
187 | 187 | TXN_ID INT(11) DEFAULT NULL, |
188 | 188 | LIN_name VARCHAR(245) NOT NULL DEFAULT '', |
@@ -198,19 +198,19 @@ discard block |
||
198 | 198 | OBJ_ID INT(11) DEFAULT NULL, |
199 | 199 | OBJ_type VARCHAR(45)DEFAULT NULL, |
200 | 200 | PRIMARY KEY (LIN_ID)"; |
201 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
202 | - $table_name = 'esp_message_template'; |
|
203 | - $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
201 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
202 | + $table_name = 'esp_message_template'; |
|
203 | + $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
204 | 204 | GRP_ID INT(10) UNSIGNED NOT NULL, |
205 | 205 | MTP_context VARCHAR(50) NOT NULL, |
206 | 206 | MTP_template_field VARCHAR(30) NOT NULL, |
207 | 207 | MTP_content TEXT NOT NULL, |
208 | 208 | PRIMARY KEY (MTP_ID), |
209 | 209 | KEY GRP_ID (GRP_ID)"; |
210 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
211 | - $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
212 | - $table_name = 'esp_message_template_group'; |
|
213 | - $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
210 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
211 | + $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
212 | + $table_name = 'esp_message_template_group'; |
|
213 | + $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
214 | 214 | MTP_user_id INT(10) NOT NULL DEFAULT '1', |
215 | 215 | MTP_name VARCHAR(245) NOT NULL DEFAULT '', |
216 | 216 | MTP_description VARCHAR(245) NOT NULL DEFAULT '', |
@@ -222,17 +222,17 @@ discard block |
||
222 | 222 | MTP_is_active TINYINT(1) NOT NULL DEFAULT '1', |
223 | 223 | PRIMARY KEY (GRP_ID), |
224 | 224 | KEY MTP_user_id (MTP_user_id)"; |
225 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
226 | - $table_name = 'esp_event_message_template'; |
|
227 | - $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
225 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
226 | + $table_name = 'esp_event_message_template'; |
|
227 | + $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
228 | 228 | EVT_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, |
229 | 229 | GRP_ID INT(10) UNSIGNED NOT NULL DEFAULT 0, |
230 | 230 | PRIMARY KEY (EMT_ID), |
231 | 231 | KEY EVT_ID (EVT_ID), |
232 | 232 | KEY GRP_ID (GRP_ID)"; |
233 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
234 | - $table_name = 'esp_payment'; |
|
235 | - $sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
233 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
234 | + $table_name = 'esp_payment'; |
|
235 | + $sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
236 | 236 | TXN_ID INT(10) UNSIGNED DEFAULT NULL, |
237 | 237 | STS_ID VARCHAR(3) COLLATE utf8_bin DEFAULT NULL, |
238 | 238 | PAY_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -248,28 +248,28 @@ discard block |
||
248 | 248 | PRIMARY KEY (PAY_ID), |
249 | 249 | KEY TXN_ID (TXN_ID), |
250 | 250 | KEY PAY_timestamp (PAY_timestamp)"; |
251 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
252 | - $table_name = "esp_ticket_price"; |
|
253 | - $sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
251 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
252 | + $table_name = "esp_ticket_price"; |
|
253 | + $sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
254 | 254 | TKT_ID INT(10) UNSIGNED NOT NULL, |
255 | 255 | PRC_ID INT(10) UNSIGNED NOT NULL, |
256 | 256 | PRIMARY KEY (TKP_ID)"; |
257 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
258 | - $table_name = "esp_datetime_ticket"; |
|
259 | - $sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
257 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
258 | + $table_name = "esp_datetime_ticket"; |
|
259 | + $sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
260 | 260 | DTT_ID INT(10) UNSIGNED NOT NULL, |
261 | 261 | TKT_ID INT(10) UNSIGNED NOT NULL, |
262 | 262 | PRIMARY KEY (DTK_ID)"; |
263 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
264 | - $table_name = "esp_ticket_template"; |
|
265 | - $sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
263 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
264 | + $table_name = "esp_ticket_template"; |
|
265 | + $sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
266 | 266 | TTM_name VARCHAR(45) NOT NULL, |
267 | 267 | TTM_description TEXT, |
268 | 268 | TTM_file VARCHAR(45), |
269 | 269 | PRIMARY KEY (TTM_ID)"; |
270 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
271 | - $table_name = 'esp_question'; |
|
272 | - $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
270 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
271 | + $table_name = 'esp_question'; |
|
272 | + $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
273 | 273 | QST_display_text TEXT NOT NULL, |
274 | 274 | QST_admin_label VARCHAR(255) NOT NULL, |
275 | 275 | QST_system VARCHAR(25) DEFAULT NULL, |
@@ -281,25 +281,25 @@ discard block |
||
281 | 281 | QST_wp_user BIGINT UNSIGNED NULL, |
282 | 282 | QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0, |
283 | 283 | PRIMARY KEY (QST_ID)'; |
284 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
285 | - $table_name = 'esp_question_group_question'; |
|
286 | - $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
284 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
285 | + $table_name = 'esp_question_group_question'; |
|
286 | + $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
287 | 287 | QSG_ID INT UNSIGNED NOT NULL, |
288 | 288 | QST_ID INT UNSIGNED NOT NULL, |
289 | 289 | QGQ_order INT UNSIGNED NOT NULL DEFAULT 0, |
290 | 290 | PRIMARY KEY (QGQ_ID) "; |
291 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
292 | - $table_name = 'esp_question_option'; |
|
293 | - $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
291 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
292 | + $table_name = 'esp_question_option'; |
|
293 | + $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
294 | 294 | QSO_value VARCHAR(255) NOT NULL, |
295 | 295 | QSO_desc TEXT NOT NULL, |
296 | 296 | QST_ID INT UNSIGNED NOT NULL, |
297 | 297 | QSO_order INT UNSIGNED NOT NULL DEFAULT 0, |
298 | 298 | QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
299 | 299 | PRIMARY KEY (QSO_ID)"; |
300 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
301 | - $table_name = 'esp_registration'; |
|
302 | - $sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
300 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
301 | + $table_name = 'esp_registration'; |
|
302 | + $sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
303 | 303 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
304 | 304 | ATT_ID BIGINT(20) UNSIGNED NOT NULL, |
305 | 305 | TXN_ID INT(10) UNSIGNED NOT NULL, |
@@ -322,25 +322,25 @@ discard block |
||
322 | 322 | KEY STS_ID (STS_ID), |
323 | 323 | KEY REG_url_link (REG_url_link), |
324 | 324 | KEY REG_code (REG_code)"; |
325 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
326 | - $table_name = 'esp_checkin'; |
|
327 | - $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
325 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
326 | + $table_name = 'esp_checkin'; |
|
327 | + $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
328 | 328 | REG_ID INT(10) UNSIGNED NOT NULL, |
329 | 329 | DTT_ID INT(10) UNSIGNED NOT NULL, |
330 | 330 | CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
331 | 331 | CHK_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
332 | 332 | PRIMARY KEY (CHK_ID)"; |
333 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
334 | - $table_name = 'esp_state'; |
|
335 | - $sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
333 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
334 | + $table_name = 'esp_state'; |
|
335 | + $sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
336 | 336 | CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
337 | 337 | STA_abbrev VARCHAR(6) COLLATE utf8_bin NOT NULL, |
338 | 338 | STA_name VARCHAR(100) COLLATE utf8_bin NOT NULL, |
339 | 339 | STA_active TINYINT(1) DEFAULT '1', |
340 | 340 | PRIMARY KEY (STA_ID)"; |
341 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
342 | - $table_name = 'esp_status'; |
|
343 | - $sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL, |
|
341 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
342 | + $table_name = 'esp_status'; |
|
343 | + $sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL, |
|
344 | 344 | STS_code VARCHAR(45) COLLATE utf8_bin NOT NULL, |
345 | 345 | STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL, |
346 | 346 | STS_can_edit TINYINT(1) NOT NULL DEFAULT 0, |
@@ -348,9 +348,9 @@ discard block |
||
348 | 348 | STS_open TINYINT(1) NOT NULL DEFAULT 1, |
349 | 349 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
350 | 350 | KEY STS_type (STS_type)"; |
351 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
352 | - $table_name = 'esp_transaction'; |
|
353 | - $sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
351 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
352 | + $table_name = 'esp_transaction'; |
|
353 | + $sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
354 | 354 | TXN_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
355 | 355 | TXN_total DECIMAL(10,3) DEFAULT '0.00', |
356 | 356 | TXN_paid DECIMAL(10,3) NOT NULL DEFAULT '0.00', |
@@ -361,9 +361,9 @@ discard block |
||
361 | 361 | PRIMARY KEY (TXN_ID), |
362 | 362 | KEY TXN_timestamp (TXN_timestamp), |
363 | 363 | KEY STS_ID (STS_ID)"; |
364 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
365 | - $table_name = 'esp_venue_meta'; |
|
366 | - $sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
364 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
365 | + $table_name = 'esp_venue_meta'; |
|
366 | + $sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
367 | 367 | VNU_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, |
368 | 368 | VNU_address VARCHAR(255) DEFAULT NULL, |
369 | 369 | VNU_address2 VARCHAR(255) DEFAULT NULL, |
@@ -381,10 +381,10 @@ discard block |
||
381 | 381 | PRIMARY KEY (VNUM_ID), |
382 | 382 | KEY STA_ID (STA_ID), |
383 | 383 | KEY CNT_ISO (CNT_ISO)"; |
384 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
385 | - //modified tables |
|
386 | - $table_name = "esp_price"; |
|
387 | - $sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
384 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
385 | + //modified tables |
|
386 | + $table_name = "esp_price"; |
|
387 | + $sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
388 | 388 | PRT_ID TINYINT(3) UNSIGNED NOT NULL, |
389 | 389 | PRC_amount DECIMAL(10,3) NOT NULL DEFAULT '0.00', |
390 | 390 | PRC_name VARCHAR(245) NOT NULL, |
@@ -396,9 +396,9 @@ discard block |
||
396 | 396 | PRC_wp_user BIGINT UNSIGNED NULL, |
397 | 397 | PRC_parent INT(10) UNSIGNED DEFAULT 0, |
398 | 398 | PRIMARY KEY (PRC_ID)"; |
399 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
400 | - $table_name = "esp_price_type"; |
|
401 | - $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
399 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
400 | + $table_name = "esp_price_type"; |
|
401 | + $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
402 | 402 | PRT_name VARCHAR(45) NOT NULL, |
403 | 403 | PBT_ID TINYINT(3) UNSIGNED NOT NULL DEFAULT '1', |
404 | 404 | PRT_is_percent TINYINT(1) NOT NULL DEFAULT '0', |
@@ -407,9 +407,9 @@ discard block |
||
407 | 407 | PRT_deleted TINYINT(1) NOT NULL DEFAULT '0', |
408 | 408 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
409 | 409 | PRIMARY KEY (PRT_ID)"; |
410 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
411 | - $table_name = "esp_ticket"; |
|
412 | - $sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
410 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
411 | + $table_name = "esp_ticket"; |
|
412 | + $sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
413 | 413 | TTM_ID INT(10) UNSIGNED NOT NULL, |
414 | 414 | TKT_name VARCHAR(245) NOT NULL DEFAULT '', |
415 | 415 | TKT_description TEXT NOT NULL, |
@@ -430,10 +430,10 @@ discard block |
||
430 | 430 | TKT_parent INT(10) UNSIGNED DEFAULT '0', |
431 | 431 | TKT_deleted TINYINT(1) NOT NULL DEFAULT '0', |
432 | 432 | PRIMARY KEY (TKT_ID)"; |
433 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
434 | - $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
435 | - $table_name = 'esp_question_group'; |
|
436 | - $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
433 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
434 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
435 | + $table_name = 'esp_question_group'; |
|
436 | + $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
437 | 437 | QSG_name VARCHAR(255) NOT NULL, |
438 | 438 | QSG_identifier VARCHAR(100) NOT NULL, |
439 | 439 | QSG_desc TEXT NULL, |
@@ -445,135 +445,135 @@ discard block |
||
445 | 445 | QSG_wp_user BIGINT UNSIGNED NULL, |
446 | 446 | PRIMARY KEY (QSG_ID), |
447 | 447 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
448 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
449 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
450 | - //(because many need to convert old string states to foreign keys into the states table) |
|
451 | - $script_4_1_defaults->insert_default_states(); |
|
452 | - $script_4_1_defaults->insert_default_countries(); |
|
453 | - //schema on price, price_types and tickets has changed so use the DEFAULT method in here instead of 4.1's and later. |
|
454 | - $this->insert_default_price_types(); |
|
455 | - $this->insert_default_prices(); |
|
456 | - $this->insert_default_tickets(); |
|
457 | - //setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre |
|
458 | - EE_Config::instance()->update_espresso_config(false, true); |
|
459 | - return true; |
|
460 | - } |
|
461 | - |
|
462 | - |
|
463 | - |
|
464 | - /** |
|
465 | - * @return boolean |
|
466 | - */ |
|
467 | - public function schema_changes_after_migration() |
|
468 | - { |
|
469 | - return true; |
|
470 | - } |
|
471 | - |
|
472 | - |
|
473 | - |
|
474 | - public function migration_page_hooks() |
|
475 | - { |
|
476 | - } |
|
477 | - |
|
478 | - |
|
479 | - |
|
480 | - /** |
|
481 | - * insert_default_price_types |
|
482 | - * |
|
483 | - * @since 4.5.0 |
|
484 | - * @return void |
|
485 | - */ |
|
486 | - public function insert_default_price_types() |
|
487 | - { |
|
488 | - global $wpdb; |
|
489 | - $price_type_table = $wpdb->prefix . "esp_price_type"; |
|
490 | - if ($this->_get_table_analysis()->tableExists($price_type_table)) { |
|
491 | - $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table; |
|
492 | - $price_types_exist = $wpdb->get_var($SQL); |
|
493 | - if ( ! $price_types_exist) { |
|
494 | - $user_id = EEH_Activation::get_default_creator_id(); |
|
495 | - $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_wp_user, PRT_deleted ) VALUES |
|
448 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
449 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
450 | + //(because many need to convert old string states to foreign keys into the states table) |
|
451 | + $script_4_1_defaults->insert_default_states(); |
|
452 | + $script_4_1_defaults->insert_default_countries(); |
|
453 | + //schema on price, price_types and tickets has changed so use the DEFAULT method in here instead of 4.1's and later. |
|
454 | + $this->insert_default_price_types(); |
|
455 | + $this->insert_default_prices(); |
|
456 | + $this->insert_default_tickets(); |
|
457 | + //setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre |
|
458 | + EE_Config::instance()->update_espresso_config(false, true); |
|
459 | + return true; |
|
460 | + } |
|
461 | + |
|
462 | + |
|
463 | + |
|
464 | + /** |
|
465 | + * @return boolean |
|
466 | + */ |
|
467 | + public function schema_changes_after_migration() |
|
468 | + { |
|
469 | + return true; |
|
470 | + } |
|
471 | + |
|
472 | + |
|
473 | + |
|
474 | + public function migration_page_hooks() |
|
475 | + { |
|
476 | + } |
|
477 | + |
|
478 | + |
|
479 | + |
|
480 | + /** |
|
481 | + * insert_default_price_types |
|
482 | + * |
|
483 | + * @since 4.5.0 |
|
484 | + * @return void |
|
485 | + */ |
|
486 | + public function insert_default_price_types() |
|
487 | + { |
|
488 | + global $wpdb; |
|
489 | + $price_type_table = $wpdb->prefix . "esp_price_type"; |
|
490 | + if ($this->_get_table_analysis()->tableExists($price_type_table)) { |
|
491 | + $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table; |
|
492 | + $price_types_exist = $wpdb->get_var($SQL); |
|
493 | + if ( ! $price_types_exist) { |
|
494 | + $user_id = EEH_Activation::get_default_creator_id(); |
|
495 | + $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_wp_user, PRT_deleted ) VALUES |
|
496 | 496 | (1, '" . __('Base Price', 'event_espresso') . "', 1, 0, 0, $user_id, 0), |
497 | 497 | (2, '" . __('Percent Discount', 'event_espresso') . "', 2, 1, 20, $user_id, 0), |
498 | 498 | (3, '" . __('Dollar Discount', 'event_espresso') . "', 2, 0, 30, $user_id, 0), |
499 | 499 | (4, '" . __('Percent Surcharge', 'event_espresso') . "', 3, 1, 40, $user_id, 0), |
500 | 500 | (5, '" . __('Dollar Surcharge', 'event_espresso') . "', 3, 0, 50, $user_id, 0);"; |
501 | - $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_price_types__SQL', $SQL); |
|
502 | - $wpdb->query($SQL); |
|
503 | - } |
|
504 | - } |
|
505 | - } |
|
506 | - |
|
507 | - |
|
508 | - |
|
509 | - /** |
|
510 | - * insert DEFAULT prices. |
|
511 | - * If we're INSTALLING 4.x CAF, then we add a few extra DEFAULT prices |
|
512 | - * when EEH_Activaion's initialize_db_content is called via ahook in |
|
513 | - * EE_Brewing_regular |
|
514 | - * |
|
515 | - * @since 4.5.0 |
|
516 | - * @return void |
|
517 | - */ |
|
518 | - public function insert_default_prices() |
|
519 | - { |
|
520 | - global $wpdb; |
|
521 | - $price_table = $wpdb->prefix . "esp_price"; |
|
522 | - if ($this->_get_table_analysis()->tableExists($price_table)) { |
|
523 | - $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table; |
|
524 | - $prices_exist = $wpdb->get_var($SQL); |
|
525 | - if ( ! $prices_exist) { |
|
526 | - $user_id = EEH_Activation::get_default_creator_id(); |
|
527 | - $SQL = "INSERT INTO $price_table |
|
501 | + $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_price_types__SQL', $SQL); |
|
502 | + $wpdb->query($SQL); |
|
503 | + } |
|
504 | + } |
|
505 | + } |
|
506 | + |
|
507 | + |
|
508 | + |
|
509 | + /** |
|
510 | + * insert DEFAULT prices. |
|
511 | + * If we're INSTALLING 4.x CAF, then we add a few extra DEFAULT prices |
|
512 | + * when EEH_Activaion's initialize_db_content is called via ahook in |
|
513 | + * EE_Brewing_regular |
|
514 | + * |
|
515 | + * @since 4.5.0 |
|
516 | + * @return void |
|
517 | + */ |
|
518 | + public function insert_default_prices() |
|
519 | + { |
|
520 | + global $wpdb; |
|
521 | + $price_table = $wpdb->prefix . "esp_price"; |
|
522 | + if ($this->_get_table_analysis()->tableExists($price_table)) { |
|
523 | + $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table; |
|
524 | + $prices_exist = $wpdb->get_var($SQL); |
|
525 | + if ( ! $prices_exist) { |
|
526 | + $user_id = EEH_Activation::get_default_creator_id(); |
|
527 | + $SQL = "INSERT INTO $price_table |
|
528 | 528 | (PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc, PRC_is_default, PRC_overrides, PRC_wp_user, PRC_order, PRC_deleted, PRC_parent ) VALUES |
529 | 529 | (1, 1, '0.00', 'Free Admission', '', 1, NULL, $user_id, 0, 0, 0);"; |
530 | - $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_prices__SQL', $SQL); |
|
531 | - $wpdb->query($SQL); |
|
532 | - } |
|
533 | - } |
|
534 | - } |
|
535 | - |
|
536 | - |
|
537 | - |
|
538 | - /** |
|
539 | - * insert DEFAULT ticket |
|
540 | - * Almost identical to EE_DMS_Core_4_3_0::insert_default_tickets, except is aware of the TKT_wp_user field |
|
541 | - * |
|
542 | - * @since 4.5.0 |
|
543 | - * @return void |
|
544 | - */ |
|
545 | - public function insert_default_tickets() |
|
546 | - { |
|
547 | - global $wpdb; |
|
548 | - $ticket_table = $wpdb->prefix . "esp_ticket"; |
|
549 | - if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
|
550 | - $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
551 | - $tickets_exist = $wpdb->get_var($SQL); |
|
552 | - if ( ! $tickets_exist) { |
|
553 | - $user_id = EEH_Activation::get_default_creator_id(); |
|
554 | - $SQL = "INSERT INTO $ticket_table |
|
530 | + $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_prices__SQL', $SQL); |
|
531 | + $wpdb->query($SQL); |
|
532 | + } |
|
533 | + } |
|
534 | + } |
|
535 | + |
|
536 | + |
|
537 | + |
|
538 | + /** |
|
539 | + * insert DEFAULT ticket |
|
540 | + * Almost identical to EE_DMS_Core_4_3_0::insert_default_tickets, except is aware of the TKT_wp_user field |
|
541 | + * |
|
542 | + * @since 4.5.0 |
|
543 | + * @return void |
|
544 | + */ |
|
545 | + public function insert_default_tickets() |
|
546 | + { |
|
547 | + global $wpdb; |
|
548 | + $ticket_table = $wpdb->prefix . "esp_ticket"; |
|
549 | + if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
|
550 | + $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
551 | + $tickets_exist = $wpdb->get_var($SQL); |
|
552 | + if ( ! $tickets_exist) { |
|
553 | + $user_id = EEH_Activation::get_default_creator_id(); |
|
554 | + $SQL = "INSERT INTO $ticket_table |
|
555 | 555 | ( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_required, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_wp_user, TKT_deleted ) VALUES |
556 | 556 | ( 1, 0, '" |
557 | - . __("Free Ticket", "event_espresso") |
|
558 | - . "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, $user_id, 0);"; |
|
559 | - $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL', $SQL); |
|
560 | - $wpdb->query($SQL); |
|
561 | - } |
|
562 | - } |
|
563 | - $ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
564 | - if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
|
565 | - $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
566 | - $ticket_prc_exist = $wpdb->get_var($SQL); |
|
567 | - if ( ! $ticket_prc_exist) { |
|
568 | - $SQL = "INSERT INTO $ticket_price_table |
|
557 | + . __("Free Ticket", "event_espresso") |
|
558 | + . "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, $user_id, 0);"; |
|
559 | + $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL', $SQL); |
|
560 | + $wpdb->query($SQL); |
|
561 | + } |
|
562 | + } |
|
563 | + $ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
564 | + if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
|
565 | + $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
566 | + $ticket_prc_exist = $wpdb->get_var($SQL); |
|
567 | + if ( ! $ticket_prc_exist) { |
|
568 | + $SQL = "INSERT INTO $ticket_price_table |
|
569 | 569 | ( TKP_ID, TKT_ID, PRC_ID ) VALUES |
570 | 570 | ( 1, 1, 1 ) |
571 | 571 | "; |
572 | - $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL__ticket_price', $SQL); |
|
573 | - $wpdb->query($SQL); |
|
574 | - } |
|
575 | - } |
|
576 | - } |
|
572 | + $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL__ticket_price', $SQL); |
|
573 | + $wpdb->query($SQL); |
|
574 | + } |
|
575 | + } |
|
576 | + } |
|
577 | 577 | |
578 | 578 | } |
579 | 579 |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | //unfortunately, this needs to be done upon INCLUSION of this file, |
14 | 14 | //instead of construction, because it only gets constructed on first page load |
15 | 15 | //(all other times it gets resurrected from a wordpress option) |
16 | -$stages = glob(EE_CORE . 'data_migration_scripts/4_5_0_stages/*'); |
|
16 | +$stages = glob(EE_CORE.'data_migration_scripts/4_5_0_stages/*'); |
|
17 | 17 | $class_to_filepath = array(); |
18 | 18 | foreach ($stages as $filepath) { |
19 | 19 | $matches = array(); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | } elseif ( ! $version_string) { |
63 | 63 | // echo "no version string provided: $version_string"; |
64 | 64 | //no version string provided... this must be pre 4.3 |
65 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
65 | + return false; //changed mind. dont want people thinking they should migrate yet because they cant |
|
66 | 66 | } else { |
67 | 67 | // echo "$version_string doesnt apply"; |
68 | 68 | return false; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | public function schema_changes_before_migration() |
82 | 82 | { |
83 | 83 | //relies on 4.1's EEH_Activation::create_table |
84 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
84 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
85 | 85 | $table_name = 'esp_answer'; |
86 | 86 | $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
87 | 87 | REG_ID INT UNSIGNED NOT NULL, |
@@ -486,18 +486,18 @@ discard block |
||
486 | 486 | public function insert_default_price_types() |
487 | 487 | { |
488 | 488 | global $wpdb; |
489 | - $price_type_table = $wpdb->prefix . "esp_price_type"; |
|
489 | + $price_type_table = $wpdb->prefix."esp_price_type"; |
|
490 | 490 | if ($this->_get_table_analysis()->tableExists($price_type_table)) { |
491 | - $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table; |
|
491 | + $SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table; |
|
492 | 492 | $price_types_exist = $wpdb->get_var($SQL); |
493 | 493 | if ( ! $price_types_exist) { |
494 | 494 | $user_id = EEH_Activation::get_default_creator_id(); |
495 | 495 | $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_wp_user, PRT_deleted ) VALUES |
496 | - (1, '" . __('Base Price', 'event_espresso') . "', 1, 0, 0, $user_id, 0), |
|
497 | - (2, '" . __('Percent Discount', 'event_espresso') . "', 2, 1, 20, $user_id, 0), |
|
498 | - (3, '" . __('Dollar Discount', 'event_espresso') . "', 2, 0, 30, $user_id, 0), |
|
499 | - (4, '" . __('Percent Surcharge', 'event_espresso') . "', 3, 1, 40, $user_id, 0), |
|
500 | - (5, '" . __('Dollar Surcharge', 'event_espresso') . "', 3, 0, 50, $user_id, 0);"; |
|
496 | + (1, '".__('Base Price', 'event_espresso')."', 1, 0, 0, $user_id, 0), |
|
497 | + (2, '".__('Percent Discount', 'event_espresso')."', 2, 1, 20, $user_id, 0), |
|
498 | + (3, '".__('Dollar Discount', 'event_espresso')."', 2, 0, 30, $user_id, 0), |
|
499 | + (4, '".__('Percent Surcharge', 'event_espresso')."', 3, 1, 40, $user_id, 0), |
|
500 | + (5, '".__('Dollar Surcharge', 'event_espresso')."', 3, 0, 50, $user_id, 0);"; |
|
501 | 501 | $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_price_types__SQL', $SQL); |
502 | 502 | $wpdb->query($SQL); |
503 | 503 | } |
@@ -518,9 +518,9 @@ discard block |
||
518 | 518 | public function insert_default_prices() |
519 | 519 | { |
520 | 520 | global $wpdb; |
521 | - $price_table = $wpdb->prefix . "esp_price"; |
|
521 | + $price_table = $wpdb->prefix."esp_price"; |
|
522 | 522 | if ($this->_get_table_analysis()->tableExists($price_table)) { |
523 | - $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table; |
|
523 | + $SQL = 'SELECT COUNT(PRC_ID) FROM '.$price_table; |
|
524 | 524 | $prices_exist = $wpdb->get_var($SQL); |
525 | 525 | if ( ! $prices_exist) { |
526 | 526 | $user_id = EEH_Activation::get_default_creator_id(); |
@@ -545,9 +545,9 @@ discard block |
||
545 | 545 | public function insert_default_tickets() |
546 | 546 | { |
547 | 547 | global $wpdb; |
548 | - $ticket_table = $wpdb->prefix . "esp_ticket"; |
|
548 | + $ticket_table = $wpdb->prefix."esp_ticket"; |
|
549 | 549 | if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
550 | - $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
550 | + $SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table; |
|
551 | 551 | $tickets_exist = $wpdb->get_var($SQL); |
552 | 552 | if ( ! $tickets_exist) { |
553 | 553 | $user_id = EEH_Activation::get_default_creator_id(); |
@@ -560,9 +560,9 @@ discard block |
||
560 | 560 | $wpdb->query($SQL); |
561 | 561 | } |
562 | 562 | } |
563 | - $ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
563 | + $ticket_price_table = $wpdb->prefix."esp_ticket_price"; |
|
564 | 564 | if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
565 | - $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
565 | + $SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table; |
|
566 | 566 | $ticket_prc_exist = $wpdb->get_var($SQL); |
567 | 567 | if ( ! $ticket_prc_exist) { |
568 | 568 | $SQL = "INSERT INTO $ticket_price_table |
@@ -9,7 +9,6 @@ discard block |
||
9 | 9 | * and recalculates esp_registration.REG_final_price to actually be the final price |
10 | 10 | * for that registration (before this it was just the ticket's price, NOT including |
11 | 11 | * taxes or other price modifiers) |
12 | - |
|
13 | 12 | */ |
14 | 13 | // make sure we have all the stages loaded too |
15 | 14 | // unfortunately, this needs to be done upon INCLUSION of this file, |
@@ -18,9 +17,9 @@ discard block |
||
18 | 17 | $stages = glob(EE_CORE . 'data_migration_scripts/4_7_0_stages/*'); |
19 | 18 | $class_to_filepath = array(); |
20 | 19 | foreach ($stages as $filepath) { |
21 | - $matches = array(); |
|
22 | - preg_match('~4_7_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
23 | - $class_to_filepath[$matches[1]] = $filepath; |
|
20 | + $matches = array(); |
|
21 | + preg_match('~4_7_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
22 | + $class_to_filepath[$matches[1]] = $filepath; |
|
24 | 23 | } |
25 | 24 | //give addons a chance to autoload their stages too |
26 | 25 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_7_0__autoloaded_stages', $class_to_filepath); |
@@ -39,82 +38,82 @@ discard block |
||
39 | 38 | class EE_DMS_Core_4_7_0 extends EE_Data_Migration_Script_Base |
40 | 39 | { |
41 | 40 | |
42 | - /** |
|
43 | - * return EE_DMS_Core_4_7_0 |
|
44 | - * |
|
45 | - * @param TableManager $table_manager |
|
46 | - * @param TableAnalysis $table_analysis |
|
47 | - */ |
|
48 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
49 | - { |
|
50 | - $this->_pretty_name = __("Data Migration to Event Espresso 4.7.0.p", "event_espresso"); |
|
51 | - $this->_priority = 10; |
|
52 | - $this->_migration_stages = array( |
|
53 | - new EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price(), |
|
54 | - new EE_DMS_4_7_0_Registration_Payments(), |
|
55 | - ); |
|
56 | - parent::__construct($table_manager, $table_analysis); |
|
57 | - } |
|
41 | + /** |
|
42 | + * return EE_DMS_Core_4_7_0 |
|
43 | + * |
|
44 | + * @param TableManager $table_manager |
|
45 | + * @param TableAnalysis $table_analysis |
|
46 | + */ |
|
47 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
48 | + { |
|
49 | + $this->_pretty_name = __("Data Migration to Event Espresso 4.7.0.p", "event_espresso"); |
|
50 | + $this->_priority = 10; |
|
51 | + $this->_migration_stages = array( |
|
52 | + new EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price(), |
|
53 | + new EE_DMS_4_7_0_Registration_Payments(), |
|
54 | + ); |
|
55 | + parent::__construct($table_manager, $table_analysis); |
|
56 | + } |
|
58 | 57 | |
59 | 58 | |
60 | 59 | |
61 | - /** |
|
62 | - * @param array $version_array |
|
63 | - * @return bool |
|
64 | - */ |
|
65 | - public function can_migrate_from_version($version_array) |
|
66 | - { |
|
67 | - $version_string = $version_array['Core']; |
|
68 | - if ( |
|
69 | - ( |
|
70 | - version_compare($version_string, '4.7.0', '<=') |
|
71 | - && version_compare($version_string, '4.6.0', '>=') |
|
72 | - ) |
|
73 | - || ( |
|
74 | - version_compare($version_string, '4.7.0', '>=') |
|
75 | - && ! $this->_get_table_analysis()->tableExists('esp_registration_payment') |
|
76 | - && $this->_get_table_analysis()->tableExists('esp_registration') |
|
77 | - ) |
|
78 | - ) { |
|
79 | - return true; |
|
80 | - } elseif ( ! $version_string) { |
|
81 | - //no version string provided... this must be pre 4.3 |
|
82 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
83 | - } else { |
|
84 | - return false; |
|
85 | - } |
|
86 | - } |
|
60 | + /** |
|
61 | + * @param array $version_array |
|
62 | + * @return bool |
|
63 | + */ |
|
64 | + public function can_migrate_from_version($version_array) |
|
65 | + { |
|
66 | + $version_string = $version_array['Core']; |
|
67 | + if ( |
|
68 | + ( |
|
69 | + version_compare($version_string, '4.7.0', '<=') |
|
70 | + && version_compare($version_string, '4.6.0', '>=') |
|
71 | + ) |
|
72 | + || ( |
|
73 | + version_compare($version_string, '4.7.0', '>=') |
|
74 | + && ! $this->_get_table_analysis()->tableExists('esp_registration_payment') |
|
75 | + && $this->_get_table_analysis()->tableExists('esp_registration') |
|
76 | + ) |
|
77 | + ) { |
|
78 | + return true; |
|
79 | + } elseif ( ! $version_string) { |
|
80 | + //no version string provided... this must be pre 4.3 |
|
81 | + return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
82 | + } else { |
|
83 | + return false; |
|
84 | + } |
|
85 | + } |
|
87 | 86 | |
88 | 87 | |
89 | 88 | |
90 | - /** |
|
91 | - * @return string|void |
|
92 | - */ |
|
93 | - public function pretty_name() |
|
94 | - { |
|
95 | - return __("Core Data Migration to version 4.7.0", "event_espresso"); |
|
96 | - } |
|
89 | + /** |
|
90 | + * @return string|void |
|
91 | + */ |
|
92 | + public function pretty_name() |
|
93 | + { |
|
94 | + return __("Core Data Migration to version 4.7.0", "event_espresso"); |
|
95 | + } |
|
97 | 96 | |
98 | 97 | |
99 | 98 | |
100 | - /** |
|
101 | - * @return bool |
|
102 | - */ |
|
103 | - public function schema_changes_before_migration() |
|
104 | - { |
|
105 | - //relies on 4.1's EEH_Activation::create_table |
|
106 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
107 | - $table_name = 'esp_answer'; |
|
108 | - $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
99 | + /** |
|
100 | + * @return bool |
|
101 | + */ |
|
102 | + public function schema_changes_before_migration() |
|
103 | + { |
|
104 | + //relies on 4.1's EEH_Activation::create_table |
|
105 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
106 | + $table_name = 'esp_answer'; |
|
107 | + $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
109 | 108 | REG_ID INT UNSIGNED NOT NULL, |
110 | 109 | QST_ID INT UNSIGNED NOT NULL, |
111 | 110 | ANS_value TEXT NOT NULL, |
112 | 111 | PRIMARY KEY (ANS_ID), |
113 | 112 | KEY REG_ID (REG_ID), |
114 | 113 | KEY QST_ID (QST_ID)"; |
115 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
116 | - $table_name = 'esp_attendee_meta'; |
|
117 | - $sql = "ATTM_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_attendee_meta'; |
|
116 | + $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
118 | 117 | ATT_ID BIGINT(20) UNSIGNED NOT NULL, |
119 | 118 | ATT_fname VARCHAR(45) NOT NULL, |
120 | 119 | ATT_lname VARCHAR(45) NOT NULL, |
@@ -131,9 +130,9 @@ discard block |
||
131 | 130 | KEY ATT_email (ATT_email), |
132 | 131 | KEY ATT_lname (ATT_lname), |
133 | 132 | KEY ATT_fname (ATT_fname)"; |
134 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
135 | - $table_name = 'esp_country'; |
|
136 | - $sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
|
133 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
134 | + $table_name = 'esp_country'; |
|
135 | + $sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
|
137 | 136 | CNT_ISO3 VARCHAR(3) COLLATE utf8_bin NOT NULL, |
138 | 137 | RGN_ID TINYINT(3) UNSIGNED DEFAULT NULL, |
139 | 138 | CNT_name VARCHAR(45) COLLATE utf8_bin NOT NULL, |
@@ -149,25 +148,25 @@ discard block |
||
149 | 148 | CNT_is_EU TINYINT(1) DEFAULT '0', |
150 | 149 | CNT_active TINYINT(1) DEFAULT '0', |
151 | 150 | PRIMARY KEY (CNT_ISO)"; |
152 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
153 | - $table_name = 'esp_currency'; |
|
154 | - $sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL, |
|
151 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
152 | + $table_name = 'esp_currency'; |
|
153 | + $sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL, |
|
155 | 154 | CUR_single VARCHAR(45) COLLATE utf8_bin DEFAULT 'dollar', |
156 | 155 | CUR_plural VARCHAR(45) COLLATE utf8_bin DEFAULT 'dollars', |
157 | 156 | CUR_sign VARCHAR(45) COLLATE utf8_bin DEFAULT '$', |
158 | 157 | CUR_dec_plc VARCHAR(1) COLLATE utf8_bin NOT NULL DEFAULT '2', |
159 | 158 | CUR_active TINYINT(1) DEFAULT '0', |
160 | 159 | PRIMARY KEY (CUR_code)"; |
161 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
162 | - $table_name = 'esp_currency_payment_method'; |
|
163 | - $sql = "CPM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
160 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
161 | + $table_name = 'esp_currency_payment_method'; |
|
162 | + $sql = "CPM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
164 | 163 | CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL, |
165 | 164 | PMD_ID INT(11) NOT NULL, |
166 | 165 | PRIMARY KEY (CPM_ID), |
167 | 166 | KEY PMD_ID (PMD_ID)"; |
168 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
169 | - $table_name = 'esp_datetime'; |
|
170 | - $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
167 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
168 | + $table_name = 'esp_datetime'; |
|
169 | + $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
171 | 170 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
172 | 171 | DTT_name VARCHAR(255) NOT NULL DEFAULT '', |
173 | 172 | DTT_description TEXT NOT NULL, |
@@ -183,9 +182,9 @@ discard block |
||
183 | 182 | KEY DTT_EVT_start (DTT_EVT_start), |
184 | 183 | KEY EVT_ID (EVT_ID), |
185 | 184 | KEY DTT_is_primary (DTT_is_primary)"; |
186 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
187 | - $table_name = 'esp_event_meta'; |
|
188 | - $sql = " |
|
185 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
186 | + $table_name = 'esp_event_meta'; |
|
187 | + $sql = " |
|
189 | 188 | EVTM_ID INT NOT NULL AUTO_INCREMENT, |
190 | 189 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
191 | 190 | EVT_display_desc TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
@@ -201,34 +200,34 @@ discard block |
||
201 | 200 | EVT_donations TINYINT(1) NULL, |
202 | 201 | PRIMARY KEY (EVTM_ID), |
203 | 202 | KEY EVT_ID (EVT_ID)"; |
204 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
205 | - $table_name = 'esp_event_question_group'; |
|
206 | - $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
203 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
204 | + $table_name = 'esp_event_question_group'; |
|
205 | + $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
207 | 206 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
208 | 207 | QSG_ID INT UNSIGNED NOT NULL, |
209 | 208 | EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
210 | 209 | PRIMARY KEY (EQG_ID), |
211 | 210 | KEY EVT_ID (EVT_ID), |
212 | 211 | KEY QSG_ID (QSG_ID)"; |
213 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
214 | - $table_name = 'esp_event_venue'; |
|
215 | - $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
212 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
213 | + $table_name = 'esp_event_venue'; |
|
214 | + $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
216 | 215 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
217 | 216 | VNU_ID BIGINT(20) UNSIGNED NOT NULL, |
218 | 217 | EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
219 | 218 | PRIMARY KEY (EVV_ID)"; |
220 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
221 | - $table_name = 'esp_extra_meta'; |
|
222 | - $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
219 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
220 | + $table_name = 'esp_extra_meta'; |
|
221 | + $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
223 | 222 | OBJ_ID INT(11) DEFAULT NULL, |
224 | 223 | EXM_type VARCHAR(45) DEFAULT NULL, |
225 | 224 | EXM_key VARCHAR(45) DEFAULT NULL, |
226 | 225 | EXM_value TEXT, |
227 | 226 | PRIMARY KEY (EXM_ID), |
228 | 227 | KEY EXM_type (EXM_type, OBJ_ID, EXM_key(45))"; |
229 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
230 | - $table_name = 'esp_line_item'; |
|
231 | - $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
228 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
229 | + $table_name = 'esp_line_item'; |
|
230 | + $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
232 | 231 | LIN_code VARCHAR(245) NOT NULL DEFAULT '', |
233 | 232 | TXN_ID INT(11) DEFAULT NULL, |
234 | 233 | LIN_name VARCHAR(245) NOT NULL DEFAULT '', |
@@ -246,9 +245,9 @@ discard block |
||
246 | 245 | PRIMARY KEY (LIN_ID), |
247 | 246 | KEY LIN_code (LIN_code(191)), |
248 | 247 | KEY TXN_ID (TXN_ID)"; |
249 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
250 | - $table_name = 'esp_log'; |
|
251 | - $sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
248 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
249 | + $table_name = 'esp_log'; |
|
250 | + $sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
252 | 251 | LOG_time DATETIME DEFAULT NULL, |
253 | 252 | OBJ_ID VARCHAR(45) DEFAULT NULL, |
254 | 253 | OBJ_type VARCHAR(45) DEFAULT NULL, |
@@ -259,18 +258,18 @@ discard block |
||
259 | 258 | KEY LOG_time (LOG_time), |
260 | 259 | KEY OBJ (OBJ_type,OBJ_ID), |
261 | 260 | KEY LOG_type (LOG_type)"; |
262 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
263 | - $table_name = 'esp_message_template'; |
|
264 | - $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
261 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
262 | + $table_name = 'esp_message_template'; |
|
263 | + $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
265 | 264 | GRP_ID INT(10) UNSIGNED NOT NULL, |
266 | 265 | MTP_context VARCHAR(50) NOT NULL, |
267 | 266 | MTP_template_field VARCHAR(30) NOT NULL, |
268 | 267 | MTP_content TEXT NOT NULL, |
269 | 268 | PRIMARY KEY (MTP_ID), |
270 | 269 | KEY GRP_ID (GRP_ID)"; |
271 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
272 | - $table_name = 'esp_message_template_group'; |
|
273 | - $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
270 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
271 | + $table_name = 'esp_message_template_group'; |
|
272 | + $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
274 | 273 | MTP_user_id INT(10) NOT NULL DEFAULT '1', |
275 | 274 | MTP_name VARCHAR(245) NOT NULL DEFAULT '', |
276 | 275 | MTP_description VARCHAR(245) NOT NULL DEFAULT '', |
@@ -282,17 +281,17 @@ discard block |
||
282 | 281 | MTP_is_active TINYINT(1) NOT NULL DEFAULT '1', |
283 | 282 | PRIMARY KEY (GRP_ID), |
284 | 283 | KEY MTP_user_id (MTP_user_id)"; |
285 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
286 | - $table_name = 'esp_event_message_template'; |
|
287 | - $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
284 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
285 | + $table_name = 'esp_event_message_template'; |
|
286 | + $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
288 | 287 | EVT_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, |
289 | 288 | GRP_ID INT(10) UNSIGNED NOT NULL DEFAULT 0, |
290 | 289 | PRIMARY KEY (EMT_ID), |
291 | 290 | KEY EVT_ID (EVT_ID), |
292 | 291 | KEY GRP_ID (GRP_ID)"; |
293 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
294 | - $table_name = 'esp_payment'; |
|
295 | - $sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
292 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
293 | + $table_name = 'esp_payment'; |
|
294 | + $sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
296 | 295 | TXN_ID INT(10) UNSIGNED DEFAULT NULL, |
297 | 296 | STS_ID VARCHAR(3) COLLATE utf8_bin DEFAULT NULL, |
298 | 297 | PAY_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -309,9 +308,9 @@ discard block |
||
309 | 308 | PRIMARY KEY (PAY_ID), |
310 | 309 | KEY PAY_timestamp (PAY_timestamp), |
311 | 310 | KEY TXN_ID (TXN_ID)"; |
312 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
313 | - $table_name = 'esp_payment_method'; |
|
314 | - $sql = "PMD_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
311 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
312 | + $table_name = 'esp_payment_method'; |
|
313 | + $sql = "PMD_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
315 | 314 | PMD_type VARCHAR(124) DEFAULT NULL, |
316 | 315 | PMD_name VARCHAR(255) DEFAULT NULL, |
317 | 316 | PMD_desc TEXT, |
@@ -327,32 +326,32 @@ discard block |
||
327 | 326 | PRIMARY KEY (PMD_ID), |
328 | 327 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
329 | 328 | KEY PMD_type (PMD_type)"; |
330 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
331 | - $table_name = "esp_ticket_price"; |
|
332 | - $sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
329 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
330 | + $table_name = "esp_ticket_price"; |
|
331 | + $sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
333 | 332 | TKT_ID INT(10) UNSIGNED NOT NULL, |
334 | 333 | PRC_ID INT(10) UNSIGNED NOT NULL, |
335 | 334 | PRIMARY KEY (TKP_ID), |
336 | 335 | KEY TKT_ID (TKT_ID), |
337 | 336 | KEY PRC_ID (PRC_ID)"; |
338 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
339 | - $table_name = "esp_datetime_ticket"; |
|
340 | - $sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
337 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
338 | + $table_name = "esp_datetime_ticket"; |
|
339 | + $sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
341 | 340 | DTT_ID INT(10) UNSIGNED NOT NULL, |
342 | 341 | TKT_ID INT(10) UNSIGNED NOT NULL, |
343 | 342 | PRIMARY KEY (DTK_ID), |
344 | 343 | KEY DTT_ID (DTT_ID), |
345 | 344 | KEY TKT_ID (TKT_ID)"; |
346 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
347 | - $table_name = "esp_ticket_template"; |
|
348 | - $sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
345 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
346 | + $table_name = "esp_ticket_template"; |
|
347 | + $sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
349 | 348 | TTM_name VARCHAR(45) NOT NULL, |
350 | 349 | TTM_description TEXT, |
351 | 350 | TTM_file VARCHAR(45), |
352 | 351 | PRIMARY KEY (TTM_ID)"; |
353 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
354 | - $table_name = 'esp_question'; |
|
355 | - $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
352 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
353 | + $table_name = 'esp_question'; |
|
354 | + $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
356 | 355 | QST_display_text TEXT NOT NULL, |
357 | 356 | QST_admin_label VARCHAR(255) NOT NULL, |
358 | 357 | QST_system VARCHAR(25) DEFAULT NULL, |
@@ -365,18 +364,18 @@ discard block |
||
365 | 364 | QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0, |
366 | 365 | PRIMARY KEY (QST_ID), |
367 | 366 | KEY QST_order (QST_order)'; |
368 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
369 | - $table_name = 'esp_question_group_question'; |
|
370 | - $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
367 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
368 | + $table_name = 'esp_question_group_question'; |
|
369 | + $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
371 | 370 | QSG_ID INT UNSIGNED NOT NULL, |
372 | 371 | QST_ID INT UNSIGNED NOT NULL, |
373 | 372 | QGQ_order INT UNSIGNED NOT NULL DEFAULT 0, |
374 | 373 | PRIMARY KEY (QGQ_ID), |
375 | 374 | KEY QST_ID (QST_ID), |
376 | 375 | KEY QSG_ID_order (QSG_ID, QGQ_order)"; |
377 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
378 | - $table_name = 'esp_question_option'; |
|
379 | - $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
376 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
377 | + $table_name = 'esp_question_option'; |
|
378 | + $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
380 | 379 | QSO_value VARCHAR(255) NOT NULL, |
381 | 380 | QSO_desc TEXT NOT NULL, |
382 | 381 | QST_ID INT UNSIGNED NOT NULL, |
@@ -385,9 +384,9 @@ discard block |
||
385 | 384 | PRIMARY KEY (QSO_ID), |
386 | 385 | KEY QST_ID (QST_ID), |
387 | 386 | KEY QSO_order (QSO_order)"; |
388 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
389 | - $table_name = 'esp_registration'; |
|
390 | - $sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
387 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
388 | + $table_name = 'esp_registration'; |
|
389 | + $sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
391 | 390 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
392 | 391 | ATT_ID BIGINT(20) UNSIGNED NOT NULL, |
393 | 392 | TXN_ID INT(10) UNSIGNED NOT NULL, |
@@ -411,18 +410,18 @@ discard block |
||
411 | 410 | KEY TKT_ID (TKT_ID), |
412 | 411 | KEY EVT_ID (EVT_ID), |
413 | 412 | KEY STS_ID (STS_ID)"; |
414 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
415 | - $table_name = 'esp_registration_payment'; |
|
416 | - $sql = "RPY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
413 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
414 | + $table_name = 'esp_registration_payment'; |
|
415 | + $sql = "RPY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
417 | 416 | REG_ID INT(10) UNSIGNED NOT NULL, |
418 | 417 | PAY_ID INT(10) UNSIGNED NULL, |
419 | 418 | RPY_amount DECIMAL(10,3) NOT NULL DEFAULT '0.00', |
420 | 419 | PRIMARY KEY (RPY_ID), |
421 | 420 | KEY REG_ID (REG_ID), |
422 | 421 | KEY PAY_ID (PAY_ID)"; |
423 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
424 | - $table_name = 'esp_checkin'; |
|
425 | - $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
422 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
423 | + $table_name = 'esp_checkin'; |
|
424 | + $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
426 | 425 | REG_ID INT(10) UNSIGNED NOT NULL, |
427 | 426 | DTT_ID INT(10) UNSIGNED NOT NULL, |
428 | 427 | CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
@@ -430,9 +429,9 @@ discard block |
||
430 | 429 | PRIMARY KEY (CHK_ID), |
431 | 430 | KEY REG_ID (REG_ID), |
432 | 431 | KEY DTT_ID (DTT_ID)"; |
433 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
434 | - $table_name = 'esp_state'; |
|
435 | - $sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
432 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
433 | + $table_name = 'esp_state'; |
|
434 | + $sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
436 | 435 | CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
437 | 436 | STA_abbrev VARCHAR(24) COLLATE utf8_bin NOT NULL, |
438 | 437 | STA_name VARCHAR(100) COLLATE utf8_bin NOT NULL, |
@@ -440,9 +439,9 @@ discard block |
||
440 | 439 | PRIMARY KEY (STA_ID), |
441 | 440 | KEY STA_abbrev (STA_abbrev), |
442 | 441 | KEY CNT_ISO (CNT_ISO)"; |
443 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
444 | - $table_name = 'esp_status'; |
|
445 | - $sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL, |
|
442 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
443 | + $table_name = 'esp_status'; |
|
444 | + $sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL, |
|
446 | 445 | STS_code VARCHAR(45) COLLATE utf8_bin NOT NULL, |
447 | 446 | STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL, |
448 | 447 | STS_can_edit TINYINT(1) NOT NULL DEFAULT 0, |
@@ -450,9 +449,9 @@ discard block |
||
450 | 449 | STS_open TINYINT(1) NOT NULL DEFAULT 1, |
451 | 450 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
452 | 451 | KEY STS_type (STS_type)"; |
453 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
454 | - $table_name = 'esp_transaction'; |
|
455 | - $sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
452 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
453 | + $table_name = 'esp_transaction'; |
|
454 | + $sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
456 | 455 | TXN_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
457 | 456 | TXN_total DECIMAL(10,3) DEFAULT '0.00', |
458 | 457 | TXN_paid DECIMAL(10,3) NOT NULL DEFAULT '0.00', |
@@ -464,9 +463,9 @@ discard block |
||
464 | 463 | PRIMARY KEY (TXN_ID), |
465 | 464 | KEY TXN_timestamp (TXN_timestamp), |
466 | 465 | KEY STS_ID (STS_ID)"; |
467 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
468 | - $table_name = 'esp_venue_meta'; |
|
469 | - $sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
466 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
467 | + $table_name = 'esp_venue_meta'; |
|
468 | + $sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
470 | 469 | VNU_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, |
471 | 470 | VNU_address VARCHAR(255) DEFAULT NULL, |
472 | 471 | VNU_address2 VARCHAR(255) DEFAULT NULL, |
@@ -485,10 +484,10 @@ discard block |
||
485 | 484 | KEY VNU_ID (VNU_ID), |
486 | 485 | KEY STA_ID (STA_ID), |
487 | 486 | KEY CNT_ISO (CNT_ISO)"; |
488 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
489 | - //modified tables |
|
490 | - $table_name = "esp_price"; |
|
491 | - $sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
487 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
488 | + //modified tables |
|
489 | + $table_name = "esp_price"; |
|
490 | + $sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
492 | 491 | PRT_ID TINYINT(3) UNSIGNED NOT NULL, |
493 | 492 | PRC_amount DECIMAL(10,3) NOT NULL DEFAULT '0.00', |
494 | 493 | PRC_name VARCHAR(245) NOT NULL, |
@@ -501,9 +500,9 @@ discard block |
||
501 | 500 | PRC_parent INT(10) UNSIGNED DEFAULT 0, |
502 | 501 | PRIMARY KEY (PRC_ID), |
503 | 502 | KEY PRT_ID (PRT_ID)"; |
504 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
505 | - $table_name = "esp_price_type"; |
|
506 | - $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
503 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
504 | + $table_name = "esp_price_type"; |
|
505 | + $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
507 | 506 | PRT_name VARCHAR(45) NOT NULL, |
508 | 507 | PBT_ID TINYINT(3) UNSIGNED NOT NULL DEFAULT '1', |
509 | 508 | PRT_is_percent TINYINT(1) NOT NULL DEFAULT '0', |
@@ -512,9 +511,9 @@ discard block |
||
512 | 511 | PRT_deleted TINYINT(1) NOT NULL DEFAULT '0', |
513 | 512 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
514 | 513 | PRIMARY KEY (PRT_ID)"; |
515 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
516 | - $table_name = "esp_ticket"; |
|
517 | - $sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
514 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
515 | + $table_name = "esp_ticket"; |
|
516 | + $sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
518 | 517 | TTM_ID INT(10) UNSIGNED NOT NULL, |
519 | 518 | TKT_name VARCHAR(245) NOT NULL DEFAULT '', |
520 | 519 | TKT_description TEXT NOT NULL, |
@@ -536,9 +535,9 @@ discard block |
||
536 | 535 | TKT_deleted TINYINT(1) NOT NULL DEFAULT '0', |
537 | 536 | PRIMARY KEY (TKT_ID), |
538 | 537 | KEY TKT_start_date (TKT_start_date)"; |
539 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
540 | - $table_name = 'esp_question_group'; |
|
541 | - $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
538 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
539 | + $table_name = 'esp_question_group'; |
|
540 | + $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
542 | 541 | QSG_name VARCHAR(255) NOT NULL, |
543 | 542 | QSG_identifier VARCHAR(100) NOT NULL, |
544 | 543 | QSG_desc TEXT NULL, |
@@ -551,38 +550,38 @@ discard block |
||
551 | 550 | PRIMARY KEY (QSG_ID), |
552 | 551 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
553 | 552 | KEY QSG_order (QSG_order)'; |
554 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
555 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
556 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
557 | - //(because many need to convert old string states to foreign keys into the states table) |
|
558 | - $script_4_1_defaults->insert_default_states(); |
|
559 | - $script_4_1_defaults->insert_default_countries(); |
|
560 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
561 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
562 | - $script_4_5_defaults->insert_default_price_types(); |
|
563 | - $script_4_5_defaults->insert_default_prices(); |
|
564 | - $script_4_5_defaults->insert_default_tickets(); |
|
565 | - /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
566 | - $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
567 | - $script_4_6_defaults->add_default_admin_only_payments(); |
|
568 | - $script_4_6_defaults->insert_default_currencies(); |
|
569 | - return true; |
|
570 | - } |
|
553 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
554 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
555 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
556 | + //(because many need to convert old string states to foreign keys into the states table) |
|
557 | + $script_4_1_defaults->insert_default_states(); |
|
558 | + $script_4_1_defaults->insert_default_countries(); |
|
559 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
560 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
561 | + $script_4_5_defaults->insert_default_price_types(); |
|
562 | + $script_4_5_defaults->insert_default_prices(); |
|
563 | + $script_4_5_defaults->insert_default_tickets(); |
|
564 | + /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
565 | + $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
566 | + $script_4_6_defaults->add_default_admin_only_payments(); |
|
567 | + $script_4_6_defaults->insert_default_currencies(); |
|
568 | + return true; |
|
569 | + } |
|
571 | 570 | |
572 | 571 | |
573 | 572 | |
574 | - /** |
|
575 | - * @return boolean |
|
576 | - */ |
|
577 | - public function schema_changes_after_migration() |
|
578 | - { |
|
579 | - return true; |
|
580 | - } |
|
573 | + /** |
|
574 | + * @return boolean |
|
575 | + */ |
|
576 | + public function schema_changes_after_migration() |
|
577 | + { |
|
578 | + return true; |
|
579 | + } |
|
581 | 580 | |
582 | 581 | |
583 | 582 | |
584 | - public function migration_page_hooks() |
|
585 | - { |
|
586 | - } |
|
583 | + public function migration_page_hooks() |
|
584 | + { |
|
585 | + } |
|
587 | 586 | } |
588 | 587 | // end of file: /core/data_migration_scripts/EE_DMS_Core_4_7_0.dms.php |
589 | 588 | \ No newline at end of file |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | // unfortunately, this needs to be done upon INCLUSION of this file, |
16 | 16 | // instead of construction, because it only gets constructed on first page load |
17 | 17 | // (all other times it gets resurrected from a wordpress option) |
18 | -$stages = glob(EE_CORE . 'data_migration_scripts/4_7_0_stages/*'); |
|
18 | +$stages = glob(EE_CORE.'data_migration_scripts/4_7_0_stages/*'); |
|
19 | 19 | $class_to_filepath = array(); |
20 | 20 | foreach ($stages as $filepath) { |
21 | 21 | $matches = array(); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | return true; |
80 | 80 | } elseif ( ! $version_string) { |
81 | 81 | //no version string provided... this must be pre 4.3 |
82 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
82 | + return false; //changed mind. dont want people thinking they should migrate yet because they cant |
|
83 | 83 | } else { |
84 | 84 | return false; |
85 | 85 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | public function schema_changes_before_migration() |
104 | 104 | { |
105 | 105 | //relies on 4.1's EEH_Activation::create_table |
106 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
106 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
107 | 107 | $table_name = 'esp_answer'; |
108 | 108 | $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
109 | 109 | REG_ID INT UNSIGNED NOT NULL, |
@@ -1430,7 +1430,7 @@ discard block |
||
1430 | 1430 | * This just returns whatever is set as the _event object property |
1431 | 1431 | * //todo this will become obsolete once the models are in place |
1432 | 1432 | * |
1433 | - * @return object |
|
1433 | + * @return EE_Event |
|
1434 | 1434 | */ |
1435 | 1435 | public function get_event_object() |
1436 | 1436 | { |
@@ -2375,7 +2375,7 @@ discard block |
||
2375 | 2375 | |
2376 | 2376 | |
2377 | 2377 | /** |
2378 | - * @return mixed |
|
2378 | + * @return string |
|
2379 | 2379 | */ |
2380 | 2380 | protected function _category_details_content() |
2381 | 2381 | { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('NO direct script access allowed'); |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -16,2557 +16,2557 @@ discard block |
||
16 | 16 | class Events_Admin_Page extends EE_Admin_Page_CPT |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * This will hold the event object for event_details screen. |
|
21 | - * |
|
22 | - * @access protected |
|
23 | - * @var EE_Event $_event |
|
24 | - */ |
|
25 | - protected $_event; |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * This will hold the category object for category_details screen. |
|
30 | - * |
|
31 | - * @var stdClass $_category |
|
32 | - */ |
|
33 | - protected $_category; |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * This will hold the event model instance |
|
38 | - * |
|
39 | - * @var EEM_Event $_event_model |
|
40 | - */ |
|
41 | - protected $_event_model; |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * @var EE_Event |
|
46 | - */ |
|
47 | - protected $_cpt_model_obj = false; |
|
48 | - |
|
49 | - |
|
50 | - protected function _init_page_props() |
|
51 | - { |
|
52 | - $this->page_slug = EVENTS_PG_SLUG; |
|
53 | - $this->page_label = EVENTS_LABEL; |
|
54 | - $this->_admin_base_url = EVENTS_ADMIN_URL; |
|
55 | - $this->_admin_base_path = EVENTS_ADMIN; |
|
56 | - $this->_cpt_model_names = array( |
|
57 | - 'create_new' => 'EEM_Event', |
|
58 | - 'edit' => 'EEM_Event', |
|
59 | - ); |
|
60 | - $this->_cpt_edit_routes = array( |
|
61 | - 'espresso_events' => 'edit', |
|
62 | - ); |
|
63 | - add_action( |
|
64 | - 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', |
|
65 | - array($this, 'verify_event_edit') |
|
66 | - ); |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - protected function _ajax_hooks() |
|
71 | - { |
|
72 | - //todo: all hooks for events ajax goes in here. |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - protected function _define_page_props() |
|
77 | - { |
|
78 | - $this->_admin_page_title = EVENTS_LABEL; |
|
79 | - $this->_labels = array( |
|
80 | - 'buttons' => array( |
|
81 | - 'add' => esc_html__('Add New Event', 'event_espresso'), |
|
82 | - 'edit' => esc_html__('Edit Event', 'event_espresso'), |
|
83 | - 'delete' => esc_html__('Delete Event', 'event_espresso'), |
|
84 | - 'add_category' => esc_html__('Add New Category', 'event_espresso'), |
|
85 | - 'edit_category' => esc_html__('Edit Category', 'event_espresso'), |
|
86 | - 'delete_category' => esc_html__('Delete Category', 'event_espresso'), |
|
87 | - ), |
|
88 | - 'editor_title' => array( |
|
89 | - 'espresso_events' => esc_html__('Enter event title here', 'event_espresso'), |
|
90 | - ), |
|
91 | - 'publishbox' => array( |
|
92 | - 'create_new' => esc_html__('Save New Event', 'event_espresso'), |
|
93 | - 'edit' => esc_html__('Update Event', 'event_espresso'), |
|
94 | - 'add_category' => esc_html__('Save New Category', 'event_espresso'), |
|
95 | - 'edit_category' => esc_html__('Update Category', 'event_espresso'), |
|
96 | - 'template_settings' => esc_html__('Update Settings', 'event_espresso'), |
|
97 | - ), |
|
98 | - ); |
|
99 | - } |
|
100 | - |
|
101 | - |
|
102 | - protected function _set_page_routes() |
|
103 | - { |
|
104 | - //load formatter helper |
|
105 | - //load field generator helper |
|
106 | - //is there a evt_id in the request? |
|
107 | - $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
108 | - ? $this->_req_data['EVT_ID'] : 0; |
|
109 | - $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
110 | - $this->_page_routes = array( |
|
111 | - 'default' => array( |
|
112 | - 'func' => '_events_overview_list_table', |
|
113 | - 'capability' => 'ee_read_events', |
|
114 | - ), |
|
115 | - 'create_new' => array( |
|
116 | - 'func' => '_create_new_cpt_item', |
|
117 | - 'capability' => 'ee_edit_events', |
|
118 | - ), |
|
119 | - 'edit' => array( |
|
120 | - 'func' => '_edit_cpt_item', |
|
121 | - 'capability' => 'ee_edit_event', |
|
122 | - 'obj_id' => $evt_id, |
|
123 | - ), |
|
124 | - 'copy_event' => array( |
|
125 | - 'func' => '_copy_events', |
|
126 | - 'capability' => 'ee_edit_event', |
|
127 | - 'obj_id' => $evt_id, |
|
128 | - 'noheader' => true, |
|
129 | - ), |
|
130 | - 'trash_event' => array( |
|
131 | - 'func' => '_trash_or_restore_event', |
|
132 | - 'args' => array('event_status' => 'trash'), |
|
133 | - 'capability' => 'ee_delete_event', |
|
134 | - 'obj_id' => $evt_id, |
|
135 | - 'noheader' => true, |
|
136 | - ), |
|
137 | - 'trash_events' => array( |
|
138 | - 'func' => '_trash_or_restore_events', |
|
139 | - 'args' => array('event_status' => 'trash'), |
|
140 | - 'capability' => 'ee_delete_events', |
|
141 | - 'noheader' => true, |
|
142 | - ), |
|
143 | - 'restore_event' => array( |
|
144 | - 'func' => '_trash_or_restore_event', |
|
145 | - 'args' => array('event_status' => 'draft'), |
|
146 | - 'capability' => 'ee_delete_event', |
|
147 | - 'obj_id' => $evt_id, |
|
148 | - 'noheader' => true, |
|
149 | - ), |
|
150 | - 'restore_events' => array( |
|
151 | - 'func' => '_trash_or_restore_events', |
|
152 | - 'args' => array('event_status' => 'draft'), |
|
153 | - 'capability' => 'ee_delete_events', |
|
154 | - 'noheader' => true, |
|
155 | - ), |
|
156 | - 'delete_event' => array( |
|
157 | - 'func' => '_delete_event', |
|
158 | - 'capability' => 'ee_delete_event', |
|
159 | - 'obj_id' => $evt_id, |
|
160 | - 'noheader' => true, |
|
161 | - ), |
|
162 | - 'delete_events' => array( |
|
163 | - 'func' => '_delete_events', |
|
164 | - 'capability' => 'ee_delete_events', |
|
165 | - 'noheader' => true, |
|
166 | - ), |
|
167 | - 'view_report' => array( |
|
168 | - 'func' => '_view_report', |
|
169 | - 'capablity' => 'ee_edit_events', |
|
170 | - ), |
|
171 | - 'default_event_settings' => array( |
|
172 | - 'func' => '_default_event_settings', |
|
173 | - 'capability' => 'manage_options', |
|
174 | - ), |
|
175 | - 'update_default_event_settings' => array( |
|
176 | - 'func' => '_update_default_event_settings', |
|
177 | - 'capability' => 'manage_options', |
|
178 | - 'noheader' => true, |
|
179 | - ), |
|
180 | - 'template_settings' => array( |
|
181 | - 'func' => '_template_settings', |
|
182 | - 'capability' => 'manage_options', |
|
183 | - ), |
|
184 | - //event category tab related |
|
185 | - 'add_category' => array( |
|
186 | - 'func' => '_category_details', |
|
187 | - 'capability' => 'ee_edit_event_category', |
|
188 | - 'args' => array('add'), |
|
189 | - ), |
|
190 | - 'edit_category' => array( |
|
191 | - 'func' => '_category_details', |
|
192 | - 'capability' => 'ee_edit_event_category', |
|
193 | - 'args' => array('edit'), |
|
194 | - ), |
|
195 | - 'delete_categories' => array( |
|
196 | - 'func' => '_delete_categories', |
|
197 | - 'capability' => 'ee_delete_event_category', |
|
198 | - 'noheader' => true, |
|
199 | - ), |
|
200 | - 'delete_category' => array( |
|
201 | - 'func' => '_delete_categories', |
|
202 | - 'capability' => 'ee_delete_event_category', |
|
203 | - 'noheader' => true, |
|
204 | - ), |
|
205 | - 'insert_category' => array( |
|
206 | - 'func' => '_insert_or_update_category', |
|
207 | - 'args' => array('new_category' => true), |
|
208 | - 'capability' => 'ee_edit_event_category', |
|
209 | - 'noheader' => true, |
|
210 | - ), |
|
211 | - 'update_category' => array( |
|
212 | - 'func' => '_insert_or_update_category', |
|
213 | - 'args' => array('new_category' => false), |
|
214 | - 'capability' => 'ee_edit_event_category', |
|
215 | - 'noheader' => true, |
|
216 | - ), |
|
217 | - 'category_list' => array( |
|
218 | - 'func' => '_category_list_table', |
|
219 | - 'capability' => 'ee_manage_event_categories', |
|
220 | - ), |
|
221 | - ); |
|
222 | - } |
|
223 | - |
|
224 | - |
|
225 | - protected function _set_page_config() |
|
226 | - { |
|
227 | - $this->_page_config = array( |
|
228 | - 'default' => array( |
|
229 | - 'nav' => array( |
|
230 | - 'label' => esc_html__('Overview', 'event_espresso'), |
|
231 | - 'order' => 10, |
|
232 | - ), |
|
233 | - 'list_table' => 'Events_Admin_List_Table', |
|
234 | - 'help_tabs' => array( |
|
235 | - 'events_overview_help_tab' => array( |
|
236 | - 'title' => esc_html__('Events Overview', 'event_espresso'), |
|
237 | - 'filename' => 'events_overview', |
|
238 | - ), |
|
239 | - 'events_overview_table_column_headings_help_tab' => array( |
|
240 | - 'title' => esc_html__('Events Overview Table Column Headings', 'event_espresso'), |
|
241 | - 'filename' => 'events_overview_table_column_headings', |
|
242 | - ), |
|
243 | - 'events_overview_filters_help_tab' => array( |
|
244 | - 'title' => esc_html__('Events Overview Filters', 'event_espresso'), |
|
245 | - 'filename' => 'events_overview_filters', |
|
246 | - ), |
|
247 | - 'events_overview_view_help_tab' => array( |
|
248 | - 'title' => esc_html__('Events Overview Views', 'event_espresso'), |
|
249 | - 'filename' => 'events_overview_views', |
|
250 | - ), |
|
251 | - 'events_overview_other_help_tab' => array( |
|
252 | - 'title' => esc_html__('Events Overview Other', 'event_espresso'), |
|
253 | - 'filename' => 'events_overview_other', |
|
254 | - ), |
|
255 | - ), |
|
256 | - 'help_tour' => array( |
|
257 | - 'Event_Overview_Help_Tour', |
|
258 | - //'New_Features_Test_Help_Tour' for testing multiple help tour |
|
259 | - ), |
|
260 | - 'qtips' => array( |
|
261 | - 'EE_Event_List_Table_Tips', |
|
262 | - ), |
|
263 | - 'require_nonce' => false, |
|
264 | - ), |
|
265 | - 'create_new' => array( |
|
266 | - 'nav' => array( |
|
267 | - 'label' => esc_html__('Add Event', 'event_espresso'), |
|
268 | - 'order' => 5, |
|
269 | - 'persistent' => false, |
|
270 | - ), |
|
271 | - 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
272 | - 'help_tabs' => array( |
|
273 | - 'event_editor_help_tab' => array( |
|
274 | - 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
275 | - 'filename' => 'event_editor', |
|
276 | - ), |
|
277 | - 'event_editor_title_richtexteditor_help_tab' => array( |
|
278 | - 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
279 | - 'filename' => 'event_editor_title_richtexteditor', |
|
280 | - ), |
|
281 | - 'event_editor_venue_details_help_tab' => array( |
|
282 | - 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
283 | - 'filename' => 'event_editor_venue_details', |
|
284 | - ), |
|
285 | - 'event_editor_event_datetimes_help_tab' => array( |
|
286 | - 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
287 | - 'filename' => 'event_editor_event_datetimes', |
|
288 | - ), |
|
289 | - 'event_editor_event_tickets_help_tab' => array( |
|
290 | - 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
291 | - 'filename' => 'event_editor_event_tickets', |
|
292 | - ), |
|
293 | - 'event_editor_event_registration_options_help_tab' => array( |
|
294 | - 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
295 | - 'filename' => 'event_editor_event_registration_options', |
|
296 | - ), |
|
297 | - 'event_editor_tags_categories_help_tab' => array( |
|
298 | - 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
299 | - 'filename' => 'event_editor_tags_categories', |
|
300 | - ), |
|
301 | - 'event_editor_questions_registrants_help_tab' => array( |
|
302 | - 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
303 | - 'filename' => 'event_editor_questions_registrants', |
|
304 | - ), |
|
305 | - 'event_editor_save_new_event_help_tab' => array( |
|
306 | - 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
307 | - 'filename' => 'event_editor_save_new_event', |
|
308 | - ), |
|
309 | - 'event_editor_other_help_tab' => array( |
|
310 | - 'title' => esc_html__('Event Other', 'event_espresso'), |
|
311 | - 'filename' => 'event_editor_other', |
|
312 | - ), |
|
313 | - ), |
|
314 | - 'help_tour' => array( |
|
315 | - 'Event_Editor_Help_Tour', |
|
316 | - ), |
|
317 | - 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
318 | - 'require_nonce' => false, |
|
319 | - ), |
|
320 | - 'edit' => array( |
|
321 | - 'nav' => array( |
|
322 | - 'label' => esc_html__('Edit Event', 'event_espresso'), |
|
323 | - 'order' => 5, |
|
324 | - 'persistent' => false, |
|
325 | - 'url' => isset($this->_req_data['post']) |
|
326 | - ? EE_Admin_Page::add_query_args_and_nonce( |
|
327 | - array('post' => $this->_req_data['post'], 'action' => 'edit'), |
|
328 | - $this->_current_page_view_url |
|
329 | - ) |
|
330 | - : $this->_admin_base_url, |
|
331 | - ), |
|
332 | - 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
333 | - 'help_tabs' => array( |
|
334 | - 'event_editor_help_tab' => array( |
|
335 | - 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
336 | - 'filename' => 'event_editor', |
|
337 | - ), |
|
338 | - 'event_editor_title_richtexteditor_help_tab' => array( |
|
339 | - 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
340 | - 'filename' => 'event_editor_title_richtexteditor', |
|
341 | - ), |
|
342 | - 'event_editor_venue_details_help_tab' => array( |
|
343 | - 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
344 | - 'filename' => 'event_editor_venue_details', |
|
345 | - ), |
|
346 | - 'event_editor_event_datetimes_help_tab' => array( |
|
347 | - 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
348 | - 'filename' => 'event_editor_event_datetimes', |
|
349 | - ), |
|
350 | - 'event_editor_event_tickets_help_tab' => array( |
|
351 | - 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
352 | - 'filename' => 'event_editor_event_tickets', |
|
353 | - ), |
|
354 | - 'event_editor_event_registration_options_help_tab' => array( |
|
355 | - 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
356 | - 'filename' => 'event_editor_event_registration_options', |
|
357 | - ), |
|
358 | - 'event_editor_tags_categories_help_tab' => array( |
|
359 | - 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
360 | - 'filename' => 'event_editor_tags_categories', |
|
361 | - ), |
|
362 | - 'event_editor_questions_registrants_help_tab' => array( |
|
363 | - 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
364 | - 'filename' => 'event_editor_questions_registrants', |
|
365 | - ), |
|
366 | - 'event_editor_save_new_event_help_tab' => array( |
|
367 | - 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
368 | - 'filename' => 'event_editor_save_new_event', |
|
369 | - ), |
|
370 | - 'event_editor_other_help_tab' => array( |
|
371 | - 'title' => esc_html__('Event Other', 'event_espresso'), |
|
372 | - 'filename' => 'event_editor_other', |
|
373 | - ), |
|
374 | - ), |
|
375 | - /*'help_tour' => array( |
|
19 | + /** |
|
20 | + * This will hold the event object for event_details screen. |
|
21 | + * |
|
22 | + * @access protected |
|
23 | + * @var EE_Event $_event |
|
24 | + */ |
|
25 | + protected $_event; |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * This will hold the category object for category_details screen. |
|
30 | + * |
|
31 | + * @var stdClass $_category |
|
32 | + */ |
|
33 | + protected $_category; |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * This will hold the event model instance |
|
38 | + * |
|
39 | + * @var EEM_Event $_event_model |
|
40 | + */ |
|
41 | + protected $_event_model; |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * @var EE_Event |
|
46 | + */ |
|
47 | + protected $_cpt_model_obj = false; |
|
48 | + |
|
49 | + |
|
50 | + protected function _init_page_props() |
|
51 | + { |
|
52 | + $this->page_slug = EVENTS_PG_SLUG; |
|
53 | + $this->page_label = EVENTS_LABEL; |
|
54 | + $this->_admin_base_url = EVENTS_ADMIN_URL; |
|
55 | + $this->_admin_base_path = EVENTS_ADMIN; |
|
56 | + $this->_cpt_model_names = array( |
|
57 | + 'create_new' => 'EEM_Event', |
|
58 | + 'edit' => 'EEM_Event', |
|
59 | + ); |
|
60 | + $this->_cpt_edit_routes = array( |
|
61 | + 'espresso_events' => 'edit', |
|
62 | + ); |
|
63 | + add_action( |
|
64 | + 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', |
|
65 | + array($this, 'verify_event_edit') |
|
66 | + ); |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + protected function _ajax_hooks() |
|
71 | + { |
|
72 | + //todo: all hooks for events ajax goes in here. |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + protected function _define_page_props() |
|
77 | + { |
|
78 | + $this->_admin_page_title = EVENTS_LABEL; |
|
79 | + $this->_labels = array( |
|
80 | + 'buttons' => array( |
|
81 | + 'add' => esc_html__('Add New Event', 'event_espresso'), |
|
82 | + 'edit' => esc_html__('Edit Event', 'event_espresso'), |
|
83 | + 'delete' => esc_html__('Delete Event', 'event_espresso'), |
|
84 | + 'add_category' => esc_html__('Add New Category', 'event_espresso'), |
|
85 | + 'edit_category' => esc_html__('Edit Category', 'event_espresso'), |
|
86 | + 'delete_category' => esc_html__('Delete Category', 'event_espresso'), |
|
87 | + ), |
|
88 | + 'editor_title' => array( |
|
89 | + 'espresso_events' => esc_html__('Enter event title here', 'event_espresso'), |
|
90 | + ), |
|
91 | + 'publishbox' => array( |
|
92 | + 'create_new' => esc_html__('Save New Event', 'event_espresso'), |
|
93 | + 'edit' => esc_html__('Update Event', 'event_espresso'), |
|
94 | + 'add_category' => esc_html__('Save New Category', 'event_espresso'), |
|
95 | + 'edit_category' => esc_html__('Update Category', 'event_espresso'), |
|
96 | + 'template_settings' => esc_html__('Update Settings', 'event_espresso'), |
|
97 | + ), |
|
98 | + ); |
|
99 | + } |
|
100 | + |
|
101 | + |
|
102 | + protected function _set_page_routes() |
|
103 | + { |
|
104 | + //load formatter helper |
|
105 | + //load field generator helper |
|
106 | + //is there a evt_id in the request? |
|
107 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
108 | + ? $this->_req_data['EVT_ID'] : 0; |
|
109 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
110 | + $this->_page_routes = array( |
|
111 | + 'default' => array( |
|
112 | + 'func' => '_events_overview_list_table', |
|
113 | + 'capability' => 'ee_read_events', |
|
114 | + ), |
|
115 | + 'create_new' => array( |
|
116 | + 'func' => '_create_new_cpt_item', |
|
117 | + 'capability' => 'ee_edit_events', |
|
118 | + ), |
|
119 | + 'edit' => array( |
|
120 | + 'func' => '_edit_cpt_item', |
|
121 | + 'capability' => 'ee_edit_event', |
|
122 | + 'obj_id' => $evt_id, |
|
123 | + ), |
|
124 | + 'copy_event' => array( |
|
125 | + 'func' => '_copy_events', |
|
126 | + 'capability' => 'ee_edit_event', |
|
127 | + 'obj_id' => $evt_id, |
|
128 | + 'noheader' => true, |
|
129 | + ), |
|
130 | + 'trash_event' => array( |
|
131 | + 'func' => '_trash_or_restore_event', |
|
132 | + 'args' => array('event_status' => 'trash'), |
|
133 | + 'capability' => 'ee_delete_event', |
|
134 | + 'obj_id' => $evt_id, |
|
135 | + 'noheader' => true, |
|
136 | + ), |
|
137 | + 'trash_events' => array( |
|
138 | + 'func' => '_trash_or_restore_events', |
|
139 | + 'args' => array('event_status' => 'trash'), |
|
140 | + 'capability' => 'ee_delete_events', |
|
141 | + 'noheader' => true, |
|
142 | + ), |
|
143 | + 'restore_event' => array( |
|
144 | + 'func' => '_trash_or_restore_event', |
|
145 | + 'args' => array('event_status' => 'draft'), |
|
146 | + 'capability' => 'ee_delete_event', |
|
147 | + 'obj_id' => $evt_id, |
|
148 | + 'noheader' => true, |
|
149 | + ), |
|
150 | + 'restore_events' => array( |
|
151 | + 'func' => '_trash_or_restore_events', |
|
152 | + 'args' => array('event_status' => 'draft'), |
|
153 | + 'capability' => 'ee_delete_events', |
|
154 | + 'noheader' => true, |
|
155 | + ), |
|
156 | + 'delete_event' => array( |
|
157 | + 'func' => '_delete_event', |
|
158 | + 'capability' => 'ee_delete_event', |
|
159 | + 'obj_id' => $evt_id, |
|
160 | + 'noheader' => true, |
|
161 | + ), |
|
162 | + 'delete_events' => array( |
|
163 | + 'func' => '_delete_events', |
|
164 | + 'capability' => 'ee_delete_events', |
|
165 | + 'noheader' => true, |
|
166 | + ), |
|
167 | + 'view_report' => array( |
|
168 | + 'func' => '_view_report', |
|
169 | + 'capablity' => 'ee_edit_events', |
|
170 | + ), |
|
171 | + 'default_event_settings' => array( |
|
172 | + 'func' => '_default_event_settings', |
|
173 | + 'capability' => 'manage_options', |
|
174 | + ), |
|
175 | + 'update_default_event_settings' => array( |
|
176 | + 'func' => '_update_default_event_settings', |
|
177 | + 'capability' => 'manage_options', |
|
178 | + 'noheader' => true, |
|
179 | + ), |
|
180 | + 'template_settings' => array( |
|
181 | + 'func' => '_template_settings', |
|
182 | + 'capability' => 'manage_options', |
|
183 | + ), |
|
184 | + //event category tab related |
|
185 | + 'add_category' => array( |
|
186 | + 'func' => '_category_details', |
|
187 | + 'capability' => 'ee_edit_event_category', |
|
188 | + 'args' => array('add'), |
|
189 | + ), |
|
190 | + 'edit_category' => array( |
|
191 | + 'func' => '_category_details', |
|
192 | + 'capability' => 'ee_edit_event_category', |
|
193 | + 'args' => array('edit'), |
|
194 | + ), |
|
195 | + 'delete_categories' => array( |
|
196 | + 'func' => '_delete_categories', |
|
197 | + 'capability' => 'ee_delete_event_category', |
|
198 | + 'noheader' => true, |
|
199 | + ), |
|
200 | + 'delete_category' => array( |
|
201 | + 'func' => '_delete_categories', |
|
202 | + 'capability' => 'ee_delete_event_category', |
|
203 | + 'noheader' => true, |
|
204 | + ), |
|
205 | + 'insert_category' => array( |
|
206 | + 'func' => '_insert_or_update_category', |
|
207 | + 'args' => array('new_category' => true), |
|
208 | + 'capability' => 'ee_edit_event_category', |
|
209 | + 'noheader' => true, |
|
210 | + ), |
|
211 | + 'update_category' => array( |
|
212 | + 'func' => '_insert_or_update_category', |
|
213 | + 'args' => array('new_category' => false), |
|
214 | + 'capability' => 'ee_edit_event_category', |
|
215 | + 'noheader' => true, |
|
216 | + ), |
|
217 | + 'category_list' => array( |
|
218 | + 'func' => '_category_list_table', |
|
219 | + 'capability' => 'ee_manage_event_categories', |
|
220 | + ), |
|
221 | + ); |
|
222 | + } |
|
223 | + |
|
224 | + |
|
225 | + protected function _set_page_config() |
|
226 | + { |
|
227 | + $this->_page_config = array( |
|
228 | + 'default' => array( |
|
229 | + 'nav' => array( |
|
230 | + 'label' => esc_html__('Overview', 'event_espresso'), |
|
231 | + 'order' => 10, |
|
232 | + ), |
|
233 | + 'list_table' => 'Events_Admin_List_Table', |
|
234 | + 'help_tabs' => array( |
|
235 | + 'events_overview_help_tab' => array( |
|
236 | + 'title' => esc_html__('Events Overview', 'event_espresso'), |
|
237 | + 'filename' => 'events_overview', |
|
238 | + ), |
|
239 | + 'events_overview_table_column_headings_help_tab' => array( |
|
240 | + 'title' => esc_html__('Events Overview Table Column Headings', 'event_espresso'), |
|
241 | + 'filename' => 'events_overview_table_column_headings', |
|
242 | + ), |
|
243 | + 'events_overview_filters_help_tab' => array( |
|
244 | + 'title' => esc_html__('Events Overview Filters', 'event_espresso'), |
|
245 | + 'filename' => 'events_overview_filters', |
|
246 | + ), |
|
247 | + 'events_overview_view_help_tab' => array( |
|
248 | + 'title' => esc_html__('Events Overview Views', 'event_espresso'), |
|
249 | + 'filename' => 'events_overview_views', |
|
250 | + ), |
|
251 | + 'events_overview_other_help_tab' => array( |
|
252 | + 'title' => esc_html__('Events Overview Other', 'event_espresso'), |
|
253 | + 'filename' => 'events_overview_other', |
|
254 | + ), |
|
255 | + ), |
|
256 | + 'help_tour' => array( |
|
257 | + 'Event_Overview_Help_Tour', |
|
258 | + //'New_Features_Test_Help_Tour' for testing multiple help tour |
|
259 | + ), |
|
260 | + 'qtips' => array( |
|
261 | + 'EE_Event_List_Table_Tips', |
|
262 | + ), |
|
263 | + 'require_nonce' => false, |
|
264 | + ), |
|
265 | + 'create_new' => array( |
|
266 | + 'nav' => array( |
|
267 | + 'label' => esc_html__('Add Event', 'event_espresso'), |
|
268 | + 'order' => 5, |
|
269 | + 'persistent' => false, |
|
270 | + ), |
|
271 | + 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
272 | + 'help_tabs' => array( |
|
273 | + 'event_editor_help_tab' => array( |
|
274 | + 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
275 | + 'filename' => 'event_editor', |
|
276 | + ), |
|
277 | + 'event_editor_title_richtexteditor_help_tab' => array( |
|
278 | + 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
279 | + 'filename' => 'event_editor_title_richtexteditor', |
|
280 | + ), |
|
281 | + 'event_editor_venue_details_help_tab' => array( |
|
282 | + 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
283 | + 'filename' => 'event_editor_venue_details', |
|
284 | + ), |
|
285 | + 'event_editor_event_datetimes_help_tab' => array( |
|
286 | + 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
287 | + 'filename' => 'event_editor_event_datetimes', |
|
288 | + ), |
|
289 | + 'event_editor_event_tickets_help_tab' => array( |
|
290 | + 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
291 | + 'filename' => 'event_editor_event_tickets', |
|
292 | + ), |
|
293 | + 'event_editor_event_registration_options_help_tab' => array( |
|
294 | + 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
295 | + 'filename' => 'event_editor_event_registration_options', |
|
296 | + ), |
|
297 | + 'event_editor_tags_categories_help_tab' => array( |
|
298 | + 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
299 | + 'filename' => 'event_editor_tags_categories', |
|
300 | + ), |
|
301 | + 'event_editor_questions_registrants_help_tab' => array( |
|
302 | + 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
303 | + 'filename' => 'event_editor_questions_registrants', |
|
304 | + ), |
|
305 | + 'event_editor_save_new_event_help_tab' => array( |
|
306 | + 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
307 | + 'filename' => 'event_editor_save_new_event', |
|
308 | + ), |
|
309 | + 'event_editor_other_help_tab' => array( |
|
310 | + 'title' => esc_html__('Event Other', 'event_espresso'), |
|
311 | + 'filename' => 'event_editor_other', |
|
312 | + ), |
|
313 | + ), |
|
314 | + 'help_tour' => array( |
|
315 | + 'Event_Editor_Help_Tour', |
|
316 | + ), |
|
317 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
318 | + 'require_nonce' => false, |
|
319 | + ), |
|
320 | + 'edit' => array( |
|
321 | + 'nav' => array( |
|
322 | + 'label' => esc_html__('Edit Event', 'event_espresso'), |
|
323 | + 'order' => 5, |
|
324 | + 'persistent' => false, |
|
325 | + 'url' => isset($this->_req_data['post']) |
|
326 | + ? EE_Admin_Page::add_query_args_and_nonce( |
|
327 | + array('post' => $this->_req_data['post'], 'action' => 'edit'), |
|
328 | + $this->_current_page_view_url |
|
329 | + ) |
|
330 | + : $this->_admin_base_url, |
|
331 | + ), |
|
332 | + 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
333 | + 'help_tabs' => array( |
|
334 | + 'event_editor_help_tab' => array( |
|
335 | + 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
336 | + 'filename' => 'event_editor', |
|
337 | + ), |
|
338 | + 'event_editor_title_richtexteditor_help_tab' => array( |
|
339 | + 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
340 | + 'filename' => 'event_editor_title_richtexteditor', |
|
341 | + ), |
|
342 | + 'event_editor_venue_details_help_tab' => array( |
|
343 | + 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
344 | + 'filename' => 'event_editor_venue_details', |
|
345 | + ), |
|
346 | + 'event_editor_event_datetimes_help_tab' => array( |
|
347 | + 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
348 | + 'filename' => 'event_editor_event_datetimes', |
|
349 | + ), |
|
350 | + 'event_editor_event_tickets_help_tab' => array( |
|
351 | + 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
352 | + 'filename' => 'event_editor_event_tickets', |
|
353 | + ), |
|
354 | + 'event_editor_event_registration_options_help_tab' => array( |
|
355 | + 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
356 | + 'filename' => 'event_editor_event_registration_options', |
|
357 | + ), |
|
358 | + 'event_editor_tags_categories_help_tab' => array( |
|
359 | + 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
360 | + 'filename' => 'event_editor_tags_categories', |
|
361 | + ), |
|
362 | + 'event_editor_questions_registrants_help_tab' => array( |
|
363 | + 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
364 | + 'filename' => 'event_editor_questions_registrants', |
|
365 | + ), |
|
366 | + 'event_editor_save_new_event_help_tab' => array( |
|
367 | + 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
368 | + 'filename' => 'event_editor_save_new_event', |
|
369 | + ), |
|
370 | + 'event_editor_other_help_tab' => array( |
|
371 | + 'title' => esc_html__('Event Other', 'event_espresso'), |
|
372 | + 'filename' => 'event_editor_other', |
|
373 | + ), |
|
374 | + ), |
|
375 | + /*'help_tour' => array( |
|
376 | 376 | 'Event_Edit_Help_Tour' |
377 | 377 | ),*/ |
378 | - 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
379 | - 'require_nonce' => false, |
|
380 | - ), |
|
381 | - 'default_event_settings' => array( |
|
382 | - 'nav' => array( |
|
383 | - 'label' => esc_html__('Default Settings', 'event_espresso'), |
|
384 | - 'order' => 40, |
|
385 | - ), |
|
386 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
387 | - 'labels' => array( |
|
388 | - 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
389 | - ), |
|
390 | - 'help_tabs' => array( |
|
391 | - 'default_settings_help_tab' => array( |
|
392 | - 'title' => esc_html__('Default Event Settings', 'event_espresso'), |
|
393 | - 'filename' => 'events_default_settings', |
|
394 | - ), |
|
395 | - 'default_settings_status_help_tab' => array( |
|
396 | - 'title' => esc_html__('Default Registration Status', 'event_espresso'), |
|
397 | - 'filename' => 'events_default_settings_status', |
|
398 | - ), |
|
399 | - ), |
|
400 | - 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
401 | - 'require_nonce' => false, |
|
402 | - ), |
|
403 | - //template settings |
|
404 | - 'template_settings' => array( |
|
405 | - 'nav' => array( |
|
406 | - 'label' => esc_html__('Templates', 'event_espresso'), |
|
407 | - 'order' => 30, |
|
408 | - ), |
|
409 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
410 | - 'help_tabs' => array( |
|
411 | - 'general_settings_templates_help_tab' => array( |
|
412 | - 'title' => esc_html__('Templates', 'event_espresso'), |
|
413 | - 'filename' => 'general_settings_templates', |
|
414 | - ), |
|
415 | - ), |
|
416 | - 'help_tour' => array('Templates_Help_Tour'), |
|
417 | - 'require_nonce' => false, |
|
418 | - ), |
|
419 | - //event category stuff |
|
420 | - 'add_category' => array( |
|
421 | - 'nav' => array( |
|
422 | - 'label' => esc_html__('Add Category', 'event_espresso'), |
|
423 | - 'order' => 15, |
|
424 | - 'persistent' => false, |
|
425 | - ), |
|
426 | - 'help_tabs' => array( |
|
427 | - 'add_category_help_tab' => array( |
|
428 | - 'title' => esc_html__('Add New Event Category', 'event_espresso'), |
|
429 | - 'filename' => 'events_add_category', |
|
430 | - ), |
|
431 | - ), |
|
432 | - 'help_tour' => array('Event_Add_Category_Help_Tour'), |
|
433 | - 'metaboxes' => array('_publish_post_box'), |
|
434 | - 'require_nonce' => false, |
|
435 | - ), |
|
436 | - 'edit_category' => array( |
|
437 | - 'nav' => array( |
|
438 | - 'label' => esc_html__('Edit Category', 'event_espresso'), |
|
439 | - 'order' => 15, |
|
440 | - 'persistent' => false, |
|
441 | - 'url' => isset($this->_req_data['EVT_CAT_ID']) |
|
442 | - ? add_query_arg( |
|
443 | - array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), |
|
444 | - $this->_current_page_view_url |
|
445 | - ) |
|
446 | - : $this->_admin_base_url, |
|
447 | - ), |
|
448 | - 'help_tabs' => array( |
|
449 | - 'edit_category_help_tab' => array( |
|
450 | - 'title' => esc_html__('Edit Event Category', 'event_espresso'), |
|
451 | - 'filename' => 'events_edit_category', |
|
452 | - ), |
|
453 | - ), |
|
454 | - /*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/ |
|
455 | - 'metaboxes' => array('_publish_post_box'), |
|
456 | - 'require_nonce' => false, |
|
457 | - ), |
|
458 | - 'category_list' => array( |
|
459 | - 'nav' => array( |
|
460 | - 'label' => esc_html__('Categories', 'event_espresso'), |
|
461 | - 'order' => 20, |
|
462 | - ), |
|
463 | - 'list_table' => 'Event_Categories_Admin_List_Table', |
|
464 | - 'help_tabs' => array( |
|
465 | - 'events_categories_help_tab' => array( |
|
466 | - 'title' => esc_html__('Event Categories', 'event_espresso'), |
|
467 | - 'filename' => 'events_categories', |
|
468 | - ), |
|
469 | - 'events_categories_table_column_headings_help_tab' => array( |
|
470 | - 'title' => esc_html__('Event Categories Table Column Headings', 'event_espresso'), |
|
471 | - 'filename' => 'events_categories_table_column_headings', |
|
472 | - ), |
|
473 | - 'events_categories_view_help_tab' => array( |
|
474 | - 'title' => esc_html__('Event Categories Views', 'event_espresso'), |
|
475 | - 'filename' => 'events_categories_views', |
|
476 | - ), |
|
477 | - 'events_categories_other_help_tab' => array( |
|
478 | - 'title' => esc_html__('Event Categories Other', 'event_espresso'), |
|
479 | - 'filename' => 'events_categories_other', |
|
480 | - ), |
|
481 | - ), |
|
482 | - 'help_tour' => array( |
|
483 | - 'Event_Categories_Help_Tour', |
|
484 | - ), |
|
485 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
486 | - 'require_nonce' => false, |
|
487 | - ), |
|
488 | - ); |
|
489 | - } |
|
490 | - |
|
491 | - |
|
492 | - protected function _add_screen_options() |
|
493 | - { |
|
494 | - //todo |
|
495 | - } |
|
496 | - |
|
497 | - |
|
498 | - protected function _add_screen_options_default() |
|
499 | - { |
|
500 | - $this->_per_page_screen_option(); |
|
501 | - } |
|
502 | - |
|
503 | - |
|
504 | - protected function _add_screen_options_category_list() |
|
505 | - { |
|
506 | - $page_title = $this->_admin_page_title; |
|
507 | - $this->_admin_page_title = esc_html__('Categories', 'event_espresso'); |
|
508 | - $this->_per_page_screen_option(); |
|
509 | - $this->_admin_page_title = $page_title; |
|
510 | - } |
|
511 | - |
|
512 | - |
|
513 | - protected function _add_feature_pointers() |
|
514 | - { |
|
515 | - //todo |
|
516 | - } |
|
517 | - |
|
518 | - |
|
519 | - public function load_scripts_styles() |
|
520 | - { |
|
521 | - wp_register_style( |
|
522 | - 'events-admin-css', |
|
523 | - EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
524 | - array(), |
|
525 | - EVENT_ESPRESSO_VERSION |
|
526 | - ); |
|
527 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
528 | - wp_enqueue_style('events-admin-css'); |
|
529 | - wp_enqueue_style('ee-cat-admin'); |
|
530 | - //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
|
531 | - //registers for all views |
|
532 | - //scripts |
|
533 | - wp_register_script( |
|
534 | - 'event_editor_js', |
|
535 | - EVENTS_ASSETS_URL . 'event_editor.js', |
|
536 | - array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), |
|
537 | - EVENT_ESPRESSO_VERSION, |
|
538 | - true |
|
539 | - ); |
|
540 | - } |
|
541 | - |
|
542 | - |
|
543 | - /** |
|
544 | - * enqueuing scripts and styles specific to this view |
|
545 | - * |
|
546 | - * @return void |
|
547 | - */ |
|
548 | - public function load_scripts_styles_create_new() |
|
549 | - { |
|
550 | - $this->load_scripts_styles_edit(); |
|
551 | - } |
|
552 | - |
|
553 | - |
|
554 | - /** |
|
555 | - * enqueuing scripts and styles specific to this view |
|
556 | - * |
|
557 | - * @return void |
|
558 | - */ |
|
559 | - public function load_scripts_styles_edit() |
|
560 | - { |
|
561 | - //styles |
|
562 | - wp_enqueue_style('espresso-ui-theme'); |
|
563 | - wp_register_style( |
|
564 | - 'event-editor-css', |
|
565 | - EVENTS_ASSETS_URL . 'event-editor.css', |
|
566 | - array('ee-admin-css'), |
|
567 | - EVENT_ESPRESSO_VERSION |
|
568 | - ); |
|
569 | - wp_enqueue_style('event-editor-css'); |
|
570 | - //scripts |
|
571 | - wp_register_script( |
|
572 | - 'event-datetime-metabox', |
|
573 | - EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
574 | - array('event_editor_js', 'ee-datepicker'), |
|
575 | - EVENT_ESPRESSO_VERSION |
|
576 | - ); |
|
577 | - wp_enqueue_script('event-datetime-metabox'); |
|
578 | - } |
|
579 | - |
|
580 | - |
|
581 | - public function load_scripts_styles_add_category() |
|
582 | - { |
|
583 | - $this->load_scripts_styles_edit_category(); |
|
584 | - } |
|
585 | - |
|
586 | - |
|
587 | - public function load_scripts_styles_edit_category() |
|
588 | - { |
|
589 | - } |
|
590 | - |
|
591 | - |
|
592 | - protected function _set_list_table_views_category_list() |
|
593 | - { |
|
594 | - $this->_views = array( |
|
595 | - 'all' => array( |
|
596 | - 'slug' => 'all', |
|
597 | - 'label' => esc_html__('All', 'event_espresso'), |
|
598 | - 'count' => 0, |
|
599 | - 'bulk_action' => array( |
|
600 | - 'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'), |
|
601 | - ), |
|
602 | - ), |
|
603 | - ); |
|
604 | - } |
|
605 | - |
|
606 | - |
|
607 | - public function admin_init() |
|
608 | - { |
|
609 | - EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__( |
|
610 | - 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
611 | - 'event_espresso' |
|
612 | - ); |
|
613 | - } |
|
614 | - |
|
615 | - |
|
616 | - //nothing needed for events with these methods. |
|
617 | - public function admin_notices() |
|
618 | - { |
|
619 | - } |
|
620 | - |
|
621 | - |
|
622 | - public function admin_footer_scripts() |
|
623 | - { |
|
624 | - } |
|
625 | - |
|
626 | - |
|
627 | - /** |
|
628 | - * Call this function to verify if an event is public and has tickets for sale. If it does, then we need to show a |
|
629 | - * warning (via EE_Error::add_error()); |
|
630 | - * |
|
631 | - * @param EE_Event $event Event object |
|
632 | - * |
|
633 | - * @access public |
|
634 | - * @return void |
|
635 | - */ |
|
636 | - public function verify_event_edit($event = null) |
|
637 | - { |
|
638 | - // no event? |
|
639 | - if (empty($event)) { |
|
640 | - // set event |
|
641 | - $event = $this->_cpt_model_obj; |
|
642 | - } |
|
643 | - // STILL no event? |
|
644 | - if (empty ($event)) { |
|
645 | - return; |
|
646 | - } |
|
647 | - $orig_status = $event->status(); |
|
648 | - // first check if event is active. |
|
649 | - if ( |
|
650 | - $orig_status === EEM_Event::cancelled |
|
651 | - || $orig_status === EEM_Event::postponed |
|
652 | - || $event->is_expired() |
|
653 | - || $event->is_inactive() |
|
654 | - ) { |
|
655 | - return; |
|
656 | - } |
|
657 | - //made it here so it IS active... next check that any of the tickets are sold. |
|
658 | - if ($event->is_sold_out(true)) { |
|
659 | - if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) { |
|
660 | - EE_Error::add_attention( |
|
661 | - sprintf( |
|
662 | - esc_html__( |
|
663 | - 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', |
|
664 | - 'event_espresso' |
|
665 | - ), |
|
666 | - EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence') |
|
667 | - ) |
|
668 | - ); |
|
669 | - } |
|
378 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
379 | + 'require_nonce' => false, |
|
380 | + ), |
|
381 | + 'default_event_settings' => array( |
|
382 | + 'nav' => array( |
|
383 | + 'label' => esc_html__('Default Settings', 'event_espresso'), |
|
384 | + 'order' => 40, |
|
385 | + ), |
|
386 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
387 | + 'labels' => array( |
|
388 | + 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
389 | + ), |
|
390 | + 'help_tabs' => array( |
|
391 | + 'default_settings_help_tab' => array( |
|
392 | + 'title' => esc_html__('Default Event Settings', 'event_espresso'), |
|
393 | + 'filename' => 'events_default_settings', |
|
394 | + ), |
|
395 | + 'default_settings_status_help_tab' => array( |
|
396 | + 'title' => esc_html__('Default Registration Status', 'event_espresso'), |
|
397 | + 'filename' => 'events_default_settings_status', |
|
398 | + ), |
|
399 | + ), |
|
400 | + 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
401 | + 'require_nonce' => false, |
|
402 | + ), |
|
403 | + //template settings |
|
404 | + 'template_settings' => array( |
|
405 | + 'nav' => array( |
|
406 | + 'label' => esc_html__('Templates', 'event_espresso'), |
|
407 | + 'order' => 30, |
|
408 | + ), |
|
409 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
410 | + 'help_tabs' => array( |
|
411 | + 'general_settings_templates_help_tab' => array( |
|
412 | + 'title' => esc_html__('Templates', 'event_espresso'), |
|
413 | + 'filename' => 'general_settings_templates', |
|
414 | + ), |
|
415 | + ), |
|
416 | + 'help_tour' => array('Templates_Help_Tour'), |
|
417 | + 'require_nonce' => false, |
|
418 | + ), |
|
419 | + //event category stuff |
|
420 | + 'add_category' => array( |
|
421 | + 'nav' => array( |
|
422 | + 'label' => esc_html__('Add Category', 'event_espresso'), |
|
423 | + 'order' => 15, |
|
424 | + 'persistent' => false, |
|
425 | + ), |
|
426 | + 'help_tabs' => array( |
|
427 | + 'add_category_help_tab' => array( |
|
428 | + 'title' => esc_html__('Add New Event Category', 'event_espresso'), |
|
429 | + 'filename' => 'events_add_category', |
|
430 | + ), |
|
431 | + ), |
|
432 | + 'help_tour' => array('Event_Add_Category_Help_Tour'), |
|
433 | + 'metaboxes' => array('_publish_post_box'), |
|
434 | + 'require_nonce' => false, |
|
435 | + ), |
|
436 | + 'edit_category' => array( |
|
437 | + 'nav' => array( |
|
438 | + 'label' => esc_html__('Edit Category', 'event_espresso'), |
|
439 | + 'order' => 15, |
|
440 | + 'persistent' => false, |
|
441 | + 'url' => isset($this->_req_data['EVT_CAT_ID']) |
|
442 | + ? add_query_arg( |
|
443 | + array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), |
|
444 | + $this->_current_page_view_url |
|
445 | + ) |
|
446 | + : $this->_admin_base_url, |
|
447 | + ), |
|
448 | + 'help_tabs' => array( |
|
449 | + 'edit_category_help_tab' => array( |
|
450 | + 'title' => esc_html__('Edit Event Category', 'event_espresso'), |
|
451 | + 'filename' => 'events_edit_category', |
|
452 | + ), |
|
453 | + ), |
|
454 | + /*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/ |
|
455 | + 'metaboxes' => array('_publish_post_box'), |
|
456 | + 'require_nonce' => false, |
|
457 | + ), |
|
458 | + 'category_list' => array( |
|
459 | + 'nav' => array( |
|
460 | + 'label' => esc_html__('Categories', 'event_espresso'), |
|
461 | + 'order' => 20, |
|
462 | + ), |
|
463 | + 'list_table' => 'Event_Categories_Admin_List_Table', |
|
464 | + 'help_tabs' => array( |
|
465 | + 'events_categories_help_tab' => array( |
|
466 | + 'title' => esc_html__('Event Categories', 'event_espresso'), |
|
467 | + 'filename' => 'events_categories', |
|
468 | + ), |
|
469 | + 'events_categories_table_column_headings_help_tab' => array( |
|
470 | + 'title' => esc_html__('Event Categories Table Column Headings', 'event_espresso'), |
|
471 | + 'filename' => 'events_categories_table_column_headings', |
|
472 | + ), |
|
473 | + 'events_categories_view_help_tab' => array( |
|
474 | + 'title' => esc_html__('Event Categories Views', 'event_espresso'), |
|
475 | + 'filename' => 'events_categories_views', |
|
476 | + ), |
|
477 | + 'events_categories_other_help_tab' => array( |
|
478 | + 'title' => esc_html__('Event Categories Other', 'event_espresso'), |
|
479 | + 'filename' => 'events_categories_other', |
|
480 | + ), |
|
481 | + ), |
|
482 | + 'help_tour' => array( |
|
483 | + 'Event_Categories_Help_Tour', |
|
484 | + ), |
|
485 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
486 | + 'require_nonce' => false, |
|
487 | + ), |
|
488 | + ); |
|
489 | + } |
|
490 | + |
|
491 | + |
|
492 | + protected function _add_screen_options() |
|
493 | + { |
|
494 | + //todo |
|
495 | + } |
|
496 | + |
|
497 | + |
|
498 | + protected function _add_screen_options_default() |
|
499 | + { |
|
500 | + $this->_per_page_screen_option(); |
|
501 | + } |
|
502 | + |
|
503 | + |
|
504 | + protected function _add_screen_options_category_list() |
|
505 | + { |
|
506 | + $page_title = $this->_admin_page_title; |
|
507 | + $this->_admin_page_title = esc_html__('Categories', 'event_espresso'); |
|
508 | + $this->_per_page_screen_option(); |
|
509 | + $this->_admin_page_title = $page_title; |
|
510 | + } |
|
511 | + |
|
512 | + |
|
513 | + protected function _add_feature_pointers() |
|
514 | + { |
|
515 | + //todo |
|
516 | + } |
|
517 | + |
|
518 | + |
|
519 | + public function load_scripts_styles() |
|
520 | + { |
|
521 | + wp_register_style( |
|
522 | + 'events-admin-css', |
|
523 | + EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
524 | + array(), |
|
525 | + EVENT_ESPRESSO_VERSION |
|
526 | + ); |
|
527 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
528 | + wp_enqueue_style('events-admin-css'); |
|
529 | + wp_enqueue_style('ee-cat-admin'); |
|
530 | + //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
|
531 | + //registers for all views |
|
532 | + //scripts |
|
533 | + wp_register_script( |
|
534 | + 'event_editor_js', |
|
535 | + EVENTS_ASSETS_URL . 'event_editor.js', |
|
536 | + array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), |
|
537 | + EVENT_ESPRESSO_VERSION, |
|
538 | + true |
|
539 | + ); |
|
540 | + } |
|
541 | + |
|
542 | + |
|
543 | + /** |
|
544 | + * enqueuing scripts and styles specific to this view |
|
545 | + * |
|
546 | + * @return void |
|
547 | + */ |
|
548 | + public function load_scripts_styles_create_new() |
|
549 | + { |
|
550 | + $this->load_scripts_styles_edit(); |
|
551 | + } |
|
552 | + |
|
553 | + |
|
554 | + /** |
|
555 | + * enqueuing scripts and styles specific to this view |
|
556 | + * |
|
557 | + * @return void |
|
558 | + */ |
|
559 | + public function load_scripts_styles_edit() |
|
560 | + { |
|
561 | + //styles |
|
562 | + wp_enqueue_style('espresso-ui-theme'); |
|
563 | + wp_register_style( |
|
564 | + 'event-editor-css', |
|
565 | + EVENTS_ASSETS_URL . 'event-editor.css', |
|
566 | + array('ee-admin-css'), |
|
567 | + EVENT_ESPRESSO_VERSION |
|
568 | + ); |
|
569 | + wp_enqueue_style('event-editor-css'); |
|
570 | + //scripts |
|
571 | + wp_register_script( |
|
572 | + 'event-datetime-metabox', |
|
573 | + EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
574 | + array('event_editor_js', 'ee-datepicker'), |
|
575 | + EVENT_ESPRESSO_VERSION |
|
576 | + ); |
|
577 | + wp_enqueue_script('event-datetime-metabox'); |
|
578 | + } |
|
579 | + |
|
580 | + |
|
581 | + public function load_scripts_styles_add_category() |
|
582 | + { |
|
583 | + $this->load_scripts_styles_edit_category(); |
|
584 | + } |
|
585 | + |
|
586 | + |
|
587 | + public function load_scripts_styles_edit_category() |
|
588 | + { |
|
589 | + } |
|
590 | + |
|
591 | + |
|
592 | + protected function _set_list_table_views_category_list() |
|
593 | + { |
|
594 | + $this->_views = array( |
|
595 | + 'all' => array( |
|
596 | + 'slug' => 'all', |
|
597 | + 'label' => esc_html__('All', 'event_espresso'), |
|
598 | + 'count' => 0, |
|
599 | + 'bulk_action' => array( |
|
600 | + 'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'), |
|
601 | + ), |
|
602 | + ), |
|
603 | + ); |
|
604 | + } |
|
605 | + |
|
606 | + |
|
607 | + public function admin_init() |
|
608 | + { |
|
609 | + EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__( |
|
610 | + 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
611 | + 'event_espresso' |
|
612 | + ); |
|
613 | + } |
|
614 | + |
|
615 | + |
|
616 | + //nothing needed for events with these methods. |
|
617 | + public function admin_notices() |
|
618 | + { |
|
619 | + } |
|
620 | + |
|
621 | + |
|
622 | + public function admin_footer_scripts() |
|
623 | + { |
|
624 | + } |
|
625 | + |
|
626 | + |
|
627 | + /** |
|
628 | + * Call this function to verify if an event is public and has tickets for sale. If it does, then we need to show a |
|
629 | + * warning (via EE_Error::add_error()); |
|
630 | + * |
|
631 | + * @param EE_Event $event Event object |
|
632 | + * |
|
633 | + * @access public |
|
634 | + * @return void |
|
635 | + */ |
|
636 | + public function verify_event_edit($event = null) |
|
637 | + { |
|
638 | + // no event? |
|
639 | + if (empty($event)) { |
|
640 | + // set event |
|
641 | + $event = $this->_cpt_model_obj; |
|
642 | + } |
|
643 | + // STILL no event? |
|
644 | + if (empty ($event)) { |
|
645 | + return; |
|
646 | + } |
|
647 | + $orig_status = $event->status(); |
|
648 | + // first check if event is active. |
|
649 | + if ( |
|
650 | + $orig_status === EEM_Event::cancelled |
|
651 | + || $orig_status === EEM_Event::postponed |
|
652 | + || $event->is_expired() |
|
653 | + || $event->is_inactive() |
|
654 | + ) { |
|
655 | + return; |
|
656 | + } |
|
657 | + //made it here so it IS active... next check that any of the tickets are sold. |
|
658 | + if ($event->is_sold_out(true)) { |
|
659 | + if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) { |
|
660 | + EE_Error::add_attention( |
|
661 | + sprintf( |
|
662 | + esc_html__( |
|
663 | + 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', |
|
664 | + 'event_espresso' |
|
665 | + ), |
|
666 | + EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence') |
|
667 | + ) |
|
668 | + ); |
|
669 | + } |
|
670 | 670 | |
671 | - return; |
|
672 | - } else if ($orig_status === EEM_Event::sold_out) { |
|
673 | - EE_Error::add_attention( |
|
674 | - sprintf( |
|
675 | - esc_html__( |
|
676 | - 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
677 | - 'event_espresso' |
|
678 | - ), |
|
679 | - EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
680 | - ) |
|
681 | - ); |
|
682 | - } |
|
683 | - //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
|
684 | - if ( ! $event->tickets_on_sale()) { |
|
685 | - return; |
|
686 | - } |
|
687 | - //made it here so show warning |
|
688 | - $this->_edit_event_warning(); |
|
689 | - } |
|
690 | - |
|
691 | - |
|
692 | - /** |
|
693 | - * This is the text used for when an event is being edited that is public and has tickets for sale. |
|
694 | - * When needed, hook this into a EE_Error::add_error() notice. |
|
695 | - * |
|
696 | - * @access protected |
|
697 | - * @return void |
|
698 | - */ |
|
699 | - protected function _edit_event_warning() |
|
700 | - { |
|
701 | - // we don't want to add warnings during these requests |
|
702 | - if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') { |
|
703 | - return; |
|
704 | - } |
|
705 | - EE_Error::add_attention( |
|
706 | - esc_html__( |
|
707 | - 'Please be advised that this event has been published and is open for registrations on your website. If you update any registration-related details (i.e. custom questions, messages, tickets, datetimes, etc.) while a registration is in process, the registration process could be interrupted and result in errors for the person registering and potentially incorrect registration or transaction data inside Event Espresso. We recommend editing events during a period of slow traffic, or even temporarily changing the status of an event to "Draft" until your edits are complete.', |
|
708 | - 'event_espresso' |
|
709 | - ) |
|
710 | - ); |
|
711 | - } |
|
712 | - |
|
713 | - |
|
714 | - /** |
|
715 | - * When a user is creating a new event, notify them if they haven't set their timezone. |
|
716 | - * Otherwise, do the normal logic |
|
717 | - * @return string |
|
718 | - */ |
|
719 | - protected function _create_new_cpt_item() |
|
720 | - { |
|
721 | - $gmt_offset = get_option('gmt_offset'); |
|
722 | - //only nag them about setting their timezone if it's their first event, and they haven't already done it |
|
723 | - if ($gmt_offset === '0' && ! EEM_Event::instance()->exists(array())) { |
|
724 | - EE_Error::add_attention( |
|
725 | - sprintf( |
|
726 | - __('Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city |
|
671 | + return; |
|
672 | + } else if ($orig_status === EEM_Event::sold_out) { |
|
673 | + EE_Error::add_attention( |
|
674 | + sprintf( |
|
675 | + esc_html__( |
|
676 | + 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
677 | + 'event_espresso' |
|
678 | + ), |
|
679 | + EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
680 | + ) |
|
681 | + ); |
|
682 | + } |
|
683 | + //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
|
684 | + if ( ! $event->tickets_on_sale()) { |
|
685 | + return; |
|
686 | + } |
|
687 | + //made it here so show warning |
|
688 | + $this->_edit_event_warning(); |
|
689 | + } |
|
690 | + |
|
691 | + |
|
692 | + /** |
|
693 | + * This is the text used for when an event is being edited that is public and has tickets for sale. |
|
694 | + * When needed, hook this into a EE_Error::add_error() notice. |
|
695 | + * |
|
696 | + * @access protected |
|
697 | + * @return void |
|
698 | + */ |
|
699 | + protected function _edit_event_warning() |
|
700 | + { |
|
701 | + // we don't want to add warnings during these requests |
|
702 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') { |
|
703 | + return; |
|
704 | + } |
|
705 | + EE_Error::add_attention( |
|
706 | + esc_html__( |
|
707 | + 'Please be advised that this event has been published and is open for registrations on your website. If you update any registration-related details (i.e. custom questions, messages, tickets, datetimes, etc.) while a registration is in process, the registration process could be interrupted and result in errors for the person registering and potentially incorrect registration or transaction data inside Event Espresso. We recommend editing events during a period of slow traffic, or even temporarily changing the status of an event to "Draft" until your edits are complete.', |
|
708 | + 'event_espresso' |
|
709 | + ) |
|
710 | + ); |
|
711 | + } |
|
712 | + |
|
713 | + |
|
714 | + /** |
|
715 | + * When a user is creating a new event, notify them if they haven't set their timezone. |
|
716 | + * Otherwise, do the normal logic |
|
717 | + * @return string |
|
718 | + */ |
|
719 | + protected function _create_new_cpt_item() |
|
720 | + { |
|
721 | + $gmt_offset = get_option('gmt_offset'); |
|
722 | + //only nag them about setting their timezone if it's their first event, and they haven't already done it |
|
723 | + if ($gmt_offset === '0' && ! EEM_Event::instance()->exists(array())) { |
|
724 | + EE_Error::add_attention( |
|
725 | + sprintf( |
|
726 | + __('Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city |
|
727 | 727 | or region near you before you create an event. Your timezone can be updated through the %1$sGeneral Settings%2$s page.'), |
728 | - '<a href="' . admin_url('options-general.php') . '">', |
|
729 | - '</a>' |
|
730 | - ), |
|
731 | - __FILE__, |
|
732 | - __FUNCTION__, |
|
733 | - __LINE__ |
|
734 | - ); |
|
735 | - } |
|
728 | + '<a href="' . admin_url('options-general.php') . '">', |
|
729 | + '</a>' |
|
730 | + ), |
|
731 | + __FILE__, |
|
732 | + __FUNCTION__, |
|
733 | + __LINE__ |
|
734 | + ); |
|
735 | + } |
|
736 | 736 | |
737 | - return parent::_create_new_cpt_item(); |
|
738 | - } |
|
739 | - |
|
740 | - |
|
741 | - protected function _set_list_table_views_default() |
|
742 | - { |
|
743 | - $this->_views = array( |
|
744 | - 'all' => array( |
|
745 | - 'slug' => 'all', |
|
746 | - 'label' => esc_html__('View All Events', 'event_espresso'), |
|
747 | - 'count' => 0, |
|
748 | - 'bulk_action' => array( |
|
749 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
750 | - ), |
|
751 | - ), |
|
752 | - 'draft' => array( |
|
753 | - 'slug' => 'draft', |
|
754 | - 'label' => esc_html__('Draft', 'event_espresso'), |
|
755 | - 'count' => 0, |
|
756 | - 'bulk_action' => array( |
|
757 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
758 | - ), |
|
759 | - ), |
|
760 | - ); |
|
761 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
762 | - $this->_views['trash'] = array( |
|
763 | - 'slug' => 'trash', |
|
764 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
765 | - 'count' => 0, |
|
766 | - 'bulk_action' => array( |
|
767 | - 'restore_events' => esc_html__('Restore From Trash', 'event_espresso'), |
|
768 | - 'delete_events' => esc_html__('Delete Permanently', 'event_espresso'), |
|
769 | - ), |
|
770 | - ); |
|
771 | - } |
|
772 | - } |
|
773 | - |
|
774 | - |
|
775 | - /** |
|
776 | - * @return array |
|
777 | - */ |
|
778 | - protected function _event_legend_items() |
|
779 | - { |
|
780 | - $items = array( |
|
781 | - 'view_details' => array( |
|
782 | - 'class' => 'dashicons dashicons-search', |
|
783 | - 'desc' => esc_html__('View Event', 'event_espresso'), |
|
784 | - ), |
|
785 | - 'edit_event' => array( |
|
786 | - 'class' => 'ee-icon ee-icon-calendar-edit', |
|
787 | - 'desc' => esc_html__('Edit Event Details', 'event_espresso'), |
|
788 | - ), |
|
789 | - 'view_attendees' => array( |
|
790 | - 'class' => 'dashicons dashicons-groups', |
|
791 | - 'desc' => esc_html__('View Registrations for Event', 'event_espresso'), |
|
792 | - ), |
|
793 | - ); |
|
794 | - $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
795 | - $statuses = array( |
|
796 | - 'sold_out_status' => array( |
|
797 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
798 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
|
799 | - ), |
|
800 | - 'active_status' => array( |
|
801 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
802 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
|
803 | - ), |
|
804 | - 'upcoming_status' => array( |
|
805 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
806 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
|
807 | - ), |
|
808 | - 'postponed_status' => array( |
|
809 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
810 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
|
811 | - ), |
|
812 | - 'cancelled_status' => array( |
|
813 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
814 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
|
815 | - ), |
|
816 | - 'expired_status' => array( |
|
817 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
818 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
|
819 | - ), |
|
820 | - 'inactive_status' => array( |
|
821 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
822 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
|
823 | - ), |
|
824 | - ); |
|
825 | - $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
737 | + return parent::_create_new_cpt_item(); |
|
738 | + } |
|
739 | + |
|
740 | + |
|
741 | + protected function _set_list_table_views_default() |
|
742 | + { |
|
743 | + $this->_views = array( |
|
744 | + 'all' => array( |
|
745 | + 'slug' => 'all', |
|
746 | + 'label' => esc_html__('View All Events', 'event_espresso'), |
|
747 | + 'count' => 0, |
|
748 | + 'bulk_action' => array( |
|
749 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
750 | + ), |
|
751 | + ), |
|
752 | + 'draft' => array( |
|
753 | + 'slug' => 'draft', |
|
754 | + 'label' => esc_html__('Draft', 'event_espresso'), |
|
755 | + 'count' => 0, |
|
756 | + 'bulk_action' => array( |
|
757 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
758 | + ), |
|
759 | + ), |
|
760 | + ); |
|
761 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
762 | + $this->_views['trash'] = array( |
|
763 | + 'slug' => 'trash', |
|
764 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
765 | + 'count' => 0, |
|
766 | + 'bulk_action' => array( |
|
767 | + 'restore_events' => esc_html__('Restore From Trash', 'event_espresso'), |
|
768 | + 'delete_events' => esc_html__('Delete Permanently', 'event_espresso'), |
|
769 | + ), |
|
770 | + ); |
|
771 | + } |
|
772 | + } |
|
773 | + |
|
774 | + |
|
775 | + /** |
|
776 | + * @return array |
|
777 | + */ |
|
778 | + protected function _event_legend_items() |
|
779 | + { |
|
780 | + $items = array( |
|
781 | + 'view_details' => array( |
|
782 | + 'class' => 'dashicons dashicons-search', |
|
783 | + 'desc' => esc_html__('View Event', 'event_espresso'), |
|
784 | + ), |
|
785 | + 'edit_event' => array( |
|
786 | + 'class' => 'ee-icon ee-icon-calendar-edit', |
|
787 | + 'desc' => esc_html__('Edit Event Details', 'event_espresso'), |
|
788 | + ), |
|
789 | + 'view_attendees' => array( |
|
790 | + 'class' => 'dashicons dashicons-groups', |
|
791 | + 'desc' => esc_html__('View Registrations for Event', 'event_espresso'), |
|
792 | + ), |
|
793 | + ); |
|
794 | + $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
795 | + $statuses = array( |
|
796 | + 'sold_out_status' => array( |
|
797 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
798 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
|
799 | + ), |
|
800 | + 'active_status' => array( |
|
801 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
802 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
|
803 | + ), |
|
804 | + 'upcoming_status' => array( |
|
805 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
806 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
|
807 | + ), |
|
808 | + 'postponed_status' => array( |
|
809 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
810 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
|
811 | + ), |
|
812 | + 'cancelled_status' => array( |
|
813 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
814 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
|
815 | + ), |
|
816 | + 'expired_status' => array( |
|
817 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
818 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
|
819 | + ), |
|
820 | + 'inactive_status' => array( |
|
821 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
822 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
|
823 | + ), |
|
824 | + ); |
|
825 | + $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
826 | 826 | |
827 | - return array_merge($items, $statuses); |
|
828 | - } |
|
829 | - |
|
830 | - |
|
831 | - /** |
|
832 | - * _event_model |
|
833 | - * |
|
834 | - * @return EEM_Event |
|
835 | - */ |
|
836 | - private function _event_model() |
|
837 | - { |
|
838 | - if ( ! $this->_event_model instanceof EEM_Event) { |
|
839 | - $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
840 | - } |
|
827 | + return array_merge($items, $statuses); |
|
828 | + } |
|
829 | + |
|
830 | + |
|
831 | + /** |
|
832 | + * _event_model |
|
833 | + * |
|
834 | + * @return EEM_Event |
|
835 | + */ |
|
836 | + private function _event_model() |
|
837 | + { |
|
838 | + if ( ! $this->_event_model instanceof EEM_Event) { |
|
839 | + $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
840 | + } |
|
841 | 841 | |
842 | - return $this->_event_model; |
|
843 | - } |
|
844 | - |
|
845 | - |
|
846 | - /** |
|
847 | - * Adds extra buttons to the WP CPT permalink field row. |
|
848 | - * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter. |
|
849 | - * |
|
850 | - * @param string $return the current html |
|
851 | - * @param int $id the post id for the page |
|
852 | - * @param string $new_title What the title is |
|
853 | - * @param string $new_slug what the slug is |
|
854 | - * |
|
855 | - * @return string The new html string for the permalink area |
|
856 | - */ |
|
857 | - public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
858 | - { |
|
859 | - //make sure this is only when editing |
|
860 | - if ( ! empty($id)) { |
|
861 | - $post = get_post($id); |
|
862 | - $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' |
|
863 | - . esc_html__('Shortcode', 'event_espresso') |
|
864 | - . '</a> '; |
|
865 | - $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' |
|
866 | - . $post->ID |
|
867 | - . ']">'; |
|
868 | - } |
|
842 | + return $this->_event_model; |
|
843 | + } |
|
844 | + |
|
845 | + |
|
846 | + /** |
|
847 | + * Adds extra buttons to the WP CPT permalink field row. |
|
848 | + * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter. |
|
849 | + * |
|
850 | + * @param string $return the current html |
|
851 | + * @param int $id the post id for the page |
|
852 | + * @param string $new_title What the title is |
|
853 | + * @param string $new_slug what the slug is |
|
854 | + * |
|
855 | + * @return string The new html string for the permalink area |
|
856 | + */ |
|
857 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
858 | + { |
|
859 | + //make sure this is only when editing |
|
860 | + if ( ! empty($id)) { |
|
861 | + $post = get_post($id); |
|
862 | + $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' |
|
863 | + . esc_html__('Shortcode', 'event_espresso') |
|
864 | + . '</a> '; |
|
865 | + $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' |
|
866 | + . $post->ID |
|
867 | + . ']">'; |
|
868 | + } |
|
869 | 869 | |
870 | - return $return; |
|
871 | - } |
|
872 | - |
|
873 | - |
|
874 | - /** |
|
875 | - * _events_overview_list_table |
|
876 | - * This contains the logic for showing the events_overview list |
|
877 | - * |
|
878 | - * @access protected |
|
879 | - * @return void |
|
880 | - * @throws \EE_Error |
|
881 | - */ |
|
882 | - protected function _events_overview_list_table() |
|
883 | - { |
|
884 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
885 | - $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table']) |
|
886 | - ? (array)$this->_template_args['after_list_table'] |
|
887 | - : array(); |
|
888 | - $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br() |
|
889 | - . EEH_Template::get_button_or_link( |
|
890 | - get_post_type_archive_link('espresso_events'), |
|
891 | - esc_html__("View Event Archive Page", "event_espresso"), |
|
892 | - 'button' |
|
893 | - ); |
|
894 | - $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items()); |
|
895 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
896 | - 'create_new', |
|
897 | - 'add', |
|
898 | - array(), |
|
899 | - 'add-new-h2' |
|
900 | - ); |
|
901 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
902 | - } |
|
903 | - |
|
904 | - |
|
905 | - /** |
|
906 | - * this allows for extra misc actions in the default WP publish box |
|
907 | - * |
|
908 | - * @return void |
|
909 | - */ |
|
910 | - public function extra_misc_actions_publish_box() |
|
911 | - { |
|
912 | - $this->_generate_publish_box_extra_content(); |
|
913 | - } |
|
914 | - |
|
915 | - |
|
916 | - /** |
|
917 | - * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been |
|
918 | - * saved. Child classes are required to declare this method. Typically you would use this to save any additional |
|
919 | - * data. |
|
920 | - * |
|
921 | - * Keep in mind also that "save_post" runs on EVERY post update to the database. |
|
922 | - * ALSO very important. When a post transitions from scheduled to published, the save_post action is fired but you |
|
923 | - * will NOT have any _POST data containing any extra info you may have from other meta saves. So MAKE sure that |
|
924 | - * you handle this accordingly. |
|
925 | - * |
|
926 | - * @access protected |
|
927 | - * @abstract |
|
928 | - * |
|
929 | - * @param string $post_id The ID of the cpt that was saved (so you can link relationally) |
|
930 | - * @param object $post The post object of the cpt that was saved. |
|
931 | - * |
|
932 | - * @return void |
|
933 | - */ |
|
934 | - protected function _insert_update_cpt_item($post_id, $post) |
|
935 | - { |
|
936 | - if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
937 | - //get out we're not processing an event save. |
|
938 | - return; |
|
939 | - } |
|
940 | - $event_values = array( |
|
941 | - 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
942 | - 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
943 | - 'EVT_additional_limit' => min( |
|
944 | - apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
945 | - ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null |
|
946 | - ), |
|
947 | - 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) |
|
948 | - ? $this->_req_data['EVT_default_registration_status'] |
|
949 | - : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
950 | - 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
951 | - 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
952 | - 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) |
|
953 | - ? $this->_req_data['timezone_string'] : null, |
|
954 | - 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) |
|
955 | - ? $this->_req_data['externalURL'] : null, |
|
956 | - 'EVT_phone' => ! empty($this->_req_data['event_phone']) |
|
957 | - ? $this->_req_data['event_phone'] : null, |
|
958 | - ); |
|
959 | - //update event |
|
960 | - $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
961 | - //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id! |
|
962 | - $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
963 | - $event = $this->_event_model()->get_one(array($get_one_where)); |
|
964 | - //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
|
965 | - $event_update_callbacks = apply_filters( |
|
966 | - 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
967 | - array(array($this, '_default_venue_update'), array($this, '_default_tickets_update')) |
|
968 | - ); |
|
969 | - $att_success = true; |
|
970 | - foreach ($event_update_callbacks as $e_callback) { |
|
971 | - $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
972 | - $att_success = ! $att_success ? $att_success |
|
973 | - : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
974 | - } |
|
975 | - //any errors? |
|
976 | - if ($success && false === $att_success) { |
|
977 | - EE_Error::add_error( |
|
978 | - esc_html__( |
|
979 | - 'Event Details saved successfully but something went wrong with saving attachments.', |
|
980 | - 'event_espresso' |
|
981 | - ), |
|
982 | - __FILE__, |
|
983 | - __FUNCTION__, |
|
984 | - __LINE__ |
|
985 | - ); |
|
986 | - } else if ($success === false) { |
|
987 | - EE_Error::add_error( |
|
988 | - esc_html__('Event Details did not save successfully.', 'event_espresso'), |
|
989 | - __FILE__, |
|
990 | - __FUNCTION__, |
|
991 | - __LINE__ |
|
992 | - ); |
|
993 | - } |
|
994 | - } |
|
995 | - |
|
996 | - |
|
997 | - /** |
|
998 | - * @see parent::restore_item() |
|
999 | - * |
|
1000 | - * @param int $post_id |
|
1001 | - * @param int $revision_id |
|
1002 | - */ |
|
1003 | - protected function _restore_cpt_item($post_id, $revision_id) |
|
1004 | - { |
|
1005 | - //copy existing event meta to new post |
|
1006 | - $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
|
1007 | - if ($post_evt instanceof EE_Event) { |
|
1008 | - //meta revision restore |
|
1009 | - $post_evt->restore_revision($revision_id); |
|
1010 | - //related objs restore |
|
1011 | - $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
1012 | - } |
|
1013 | - } |
|
1014 | - |
|
1015 | - |
|
1016 | - /** |
|
1017 | - * Attach the venue to the Event |
|
1018 | - * |
|
1019 | - * @param \EE_Event $evtobj Event Object to add the venue to |
|
1020 | - * @param array $data The request data from the form |
|
1021 | - * |
|
1022 | - * @return bool Success or fail. |
|
1023 | - */ |
|
1024 | - protected function _default_venue_update(\EE_Event $evtobj, $data) |
|
1025 | - { |
|
1026 | - require_once(EE_MODELS . 'EEM_Venue.model.php'); |
|
1027 | - $venue_model = EE_Registry::instance()->load_model('Venue'); |
|
1028 | - $rows_affected = null; |
|
1029 | - $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
1030 | - // very important. If we don't have a venue name... |
|
1031 | - // then we'll get out because not necessary to create empty venue |
|
1032 | - if (empty($data['venue_title'])) { |
|
1033 | - return false; |
|
1034 | - } |
|
1035 | - $venue_array = array( |
|
1036 | - 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
|
1037 | - 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : null, |
|
1038 | - 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : null, |
|
1039 | - 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null, |
|
1040 | - 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] |
|
1041 | - : null, |
|
1042 | - 'VNU_address' => ! empty($data['address']) ? $data['address'] : null, |
|
1043 | - 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : null, |
|
1044 | - 'VNU_city' => ! empty($data['city']) ? $data['city'] : null, |
|
1045 | - 'STA_ID' => ! empty($data['state']) ? $data['state'] : null, |
|
1046 | - 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : null, |
|
1047 | - 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : null, |
|
1048 | - 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : null, |
|
1049 | - 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null, |
|
1050 | - 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : null, |
|
1051 | - 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null, |
|
1052 | - 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : null, |
|
1053 | - 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
1054 | - 'status' => 'publish', |
|
1055 | - ); |
|
1056 | - //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
|
1057 | - if ( ! empty($venue_id)) { |
|
1058 | - $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
1059 | - $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
1060 | - //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present. |
|
1061 | - $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
870 | + return $return; |
|
871 | + } |
|
872 | + |
|
873 | + |
|
874 | + /** |
|
875 | + * _events_overview_list_table |
|
876 | + * This contains the logic for showing the events_overview list |
|
877 | + * |
|
878 | + * @access protected |
|
879 | + * @return void |
|
880 | + * @throws \EE_Error |
|
881 | + */ |
|
882 | + protected function _events_overview_list_table() |
|
883 | + { |
|
884 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
885 | + $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table']) |
|
886 | + ? (array)$this->_template_args['after_list_table'] |
|
887 | + : array(); |
|
888 | + $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br() |
|
889 | + . EEH_Template::get_button_or_link( |
|
890 | + get_post_type_archive_link('espresso_events'), |
|
891 | + esc_html__("View Event Archive Page", "event_espresso"), |
|
892 | + 'button' |
|
893 | + ); |
|
894 | + $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items()); |
|
895 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
896 | + 'create_new', |
|
897 | + 'add', |
|
898 | + array(), |
|
899 | + 'add-new-h2' |
|
900 | + ); |
|
901 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
902 | + } |
|
903 | + |
|
904 | + |
|
905 | + /** |
|
906 | + * this allows for extra misc actions in the default WP publish box |
|
907 | + * |
|
908 | + * @return void |
|
909 | + */ |
|
910 | + public function extra_misc_actions_publish_box() |
|
911 | + { |
|
912 | + $this->_generate_publish_box_extra_content(); |
|
913 | + } |
|
914 | + |
|
915 | + |
|
916 | + /** |
|
917 | + * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been |
|
918 | + * saved. Child classes are required to declare this method. Typically you would use this to save any additional |
|
919 | + * data. |
|
920 | + * |
|
921 | + * Keep in mind also that "save_post" runs on EVERY post update to the database. |
|
922 | + * ALSO very important. When a post transitions from scheduled to published, the save_post action is fired but you |
|
923 | + * will NOT have any _POST data containing any extra info you may have from other meta saves. So MAKE sure that |
|
924 | + * you handle this accordingly. |
|
925 | + * |
|
926 | + * @access protected |
|
927 | + * @abstract |
|
928 | + * |
|
929 | + * @param string $post_id The ID of the cpt that was saved (so you can link relationally) |
|
930 | + * @param object $post The post object of the cpt that was saved. |
|
931 | + * |
|
932 | + * @return void |
|
933 | + */ |
|
934 | + protected function _insert_update_cpt_item($post_id, $post) |
|
935 | + { |
|
936 | + if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
937 | + //get out we're not processing an event save. |
|
938 | + return; |
|
939 | + } |
|
940 | + $event_values = array( |
|
941 | + 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
942 | + 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
943 | + 'EVT_additional_limit' => min( |
|
944 | + apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
945 | + ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null |
|
946 | + ), |
|
947 | + 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) |
|
948 | + ? $this->_req_data['EVT_default_registration_status'] |
|
949 | + : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
950 | + 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
951 | + 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
952 | + 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) |
|
953 | + ? $this->_req_data['timezone_string'] : null, |
|
954 | + 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) |
|
955 | + ? $this->_req_data['externalURL'] : null, |
|
956 | + 'EVT_phone' => ! empty($this->_req_data['event_phone']) |
|
957 | + ? $this->_req_data['event_phone'] : null, |
|
958 | + ); |
|
959 | + //update event |
|
960 | + $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
961 | + //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id! |
|
962 | + $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
963 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
964 | + //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
|
965 | + $event_update_callbacks = apply_filters( |
|
966 | + 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
967 | + array(array($this, '_default_venue_update'), array($this, '_default_tickets_update')) |
|
968 | + ); |
|
969 | + $att_success = true; |
|
970 | + foreach ($event_update_callbacks as $e_callback) { |
|
971 | + $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
972 | + $att_success = ! $att_success ? $att_success |
|
973 | + : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
974 | + } |
|
975 | + //any errors? |
|
976 | + if ($success && false === $att_success) { |
|
977 | + EE_Error::add_error( |
|
978 | + esc_html__( |
|
979 | + 'Event Details saved successfully but something went wrong with saving attachments.', |
|
980 | + 'event_espresso' |
|
981 | + ), |
|
982 | + __FILE__, |
|
983 | + __FUNCTION__, |
|
984 | + __LINE__ |
|
985 | + ); |
|
986 | + } else if ($success === false) { |
|
987 | + EE_Error::add_error( |
|
988 | + esc_html__('Event Details did not save successfully.', 'event_espresso'), |
|
989 | + __FILE__, |
|
990 | + __FUNCTION__, |
|
991 | + __LINE__ |
|
992 | + ); |
|
993 | + } |
|
994 | + } |
|
995 | + |
|
996 | + |
|
997 | + /** |
|
998 | + * @see parent::restore_item() |
|
999 | + * |
|
1000 | + * @param int $post_id |
|
1001 | + * @param int $revision_id |
|
1002 | + */ |
|
1003 | + protected function _restore_cpt_item($post_id, $revision_id) |
|
1004 | + { |
|
1005 | + //copy existing event meta to new post |
|
1006 | + $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
|
1007 | + if ($post_evt instanceof EE_Event) { |
|
1008 | + //meta revision restore |
|
1009 | + $post_evt->restore_revision($revision_id); |
|
1010 | + //related objs restore |
|
1011 | + $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
1012 | + } |
|
1013 | + } |
|
1014 | + |
|
1015 | + |
|
1016 | + /** |
|
1017 | + * Attach the venue to the Event |
|
1018 | + * |
|
1019 | + * @param \EE_Event $evtobj Event Object to add the venue to |
|
1020 | + * @param array $data The request data from the form |
|
1021 | + * |
|
1022 | + * @return bool Success or fail. |
|
1023 | + */ |
|
1024 | + protected function _default_venue_update(\EE_Event $evtobj, $data) |
|
1025 | + { |
|
1026 | + require_once(EE_MODELS . 'EEM_Venue.model.php'); |
|
1027 | + $venue_model = EE_Registry::instance()->load_model('Venue'); |
|
1028 | + $rows_affected = null; |
|
1029 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
1030 | + // very important. If we don't have a venue name... |
|
1031 | + // then we'll get out because not necessary to create empty venue |
|
1032 | + if (empty($data['venue_title'])) { |
|
1033 | + return false; |
|
1034 | + } |
|
1035 | + $venue_array = array( |
|
1036 | + 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
|
1037 | + 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : null, |
|
1038 | + 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : null, |
|
1039 | + 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null, |
|
1040 | + 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] |
|
1041 | + : null, |
|
1042 | + 'VNU_address' => ! empty($data['address']) ? $data['address'] : null, |
|
1043 | + 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : null, |
|
1044 | + 'VNU_city' => ! empty($data['city']) ? $data['city'] : null, |
|
1045 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : null, |
|
1046 | + 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : null, |
|
1047 | + 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : null, |
|
1048 | + 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : null, |
|
1049 | + 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null, |
|
1050 | + 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : null, |
|
1051 | + 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null, |
|
1052 | + 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : null, |
|
1053 | + 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
1054 | + 'status' => 'publish', |
|
1055 | + ); |
|
1056 | + //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
|
1057 | + if ( ! empty($venue_id)) { |
|
1058 | + $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
1059 | + $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
1060 | + //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present. |
|
1061 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1062 | 1062 | |
1063 | - return $rows_affected > 0 ? true : false; |
|
1064 | - } else { |
|
1065 | - //we insert the venue |
|
1066 | - $venue_id = $venue_model->insert($venue_array); |
|
1067 | - $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1063 | + return $rows_affected > 0 ? true : false; |
|
1064 | + } else { |
|
1065 | + //we insert the venue |
|
1066 | + $venue_id = $venue_model->insert($venue_array); |
|
1067 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1068 | 1068 | |
1069 | - return ! empty($venue_id) ? true : false; |
|
1070 | - } |
|
1071 | - //when we have the ancestor come in it's already been handled by the revision save. |
|
1072 | - } |
|
1073 | - |
|
1074 | - |
|
1075 | - /** |
|
1076 | - * Handles saving everything related to Tickets (datetimes, tickets, prices) |
|
1077 | - * |
|
1078 | - * @param EE_Event $evtobj The Event object we're attaching data to |
|
1079 | - * @param array $data The request data from the form |
|
1080 | - * |
|
1081 | - * @return array |
|
1082 | - */ |
|
1083 | - protected function _default_tickets_update(EE_Event $evtobj, $data) |
|
1084 | - { |
|
1085 | - $success = true; |
|
1086 | - $saved_dtt = null; |
|
1087 | - $saved_tickets = array(); |
|
1088 | - $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1089 | - foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
1090 | - //trim all values to ensure any excess whitespace is removed. |
|
1091 | - $dtt = array_map('trim', $dtt); |
|
1092 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] |
|
1093 | - : $dtt['DTT_EVT_start']; |
|
1094 | - $datetime_values = array( |
|
1095 | - 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null, |
|
1096 | - 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
|
1097 | - 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
|
1098 | - 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
1099 | - 'DTT_order' => $row, |
|
1100 | - ); |
|
1101 | - //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
|
1102 | - if ( ! empty($dtt['DTT_ID'])) { |
|
1103 | - $DTM = EE_Registry::instance() |
|
1104 | - ->load_model('Datetime', array($evtobj->get_timezone())) |
|
1105 | - ->get_one_by_ID($dtt['DTT_ID']); |
|
1106 | - $DTM->set_date_format($incoming_date_formats[0]); |
|
1107 | - $DTM->set_time_format($incoming_date_formats[1]); |
|
1108 | - foreach ($datetime_values as $field => $value) { |
|
1109 | - $DTM->set($field, $value); |
|
1110 | - } |
|
1111 | - //make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. We need to do this so we dont' TRASH the parent DTT. |
|
1112 | - $saved_dtts[$DTM->ID()] = $DTM; |
|
1113 | - } else { |
|
1114 | - $DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values), false, false); |
|
1115 | - $DTM->set_date_format($incoming_date_formats[0]); |
|
1116 | - $DTM->set_time_format($incoming_date_formats[1]); |
|
1117 | - $DTM->set_timezone($evtobj->get_timezone()); |
|
1118 | - foreach ($datetime_values as $field => $value) { |
|
1119 | - $DTM->set($field, $value); |
|
1120 | - } |
|
1121 | - } |
|
1122 | - $DTM->save(); |
|
1123 | - $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
1124 | - //load DTT helper |
|
1125 | - //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
|
1126 | - if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
1127 | - $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
1128 | - $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
|
1129 | - $DTT->save(); |
|
1130 | - } |
|
1131 | - //now we got to make sure we add the new DTT_ID to the $saved_dtts array because it is possible there was a new one created for the autosave. |
|
1132 | - $saved_dtt = $DTT; |
|
1133 | - $success = ! $success ? $success : $DTT; |
|
1134 | - //if ANY of these updates fail then we want the appropriate global error message. |
|
1135 | - // //todo this is actually sucky we need a better error message but this is what it is for now. |
|
1136 | - } |
|
1137 | - //no dtts get deleted so we don't do any of that logic here. |
|
1138 | - //update tickets next |
|
1139 | - $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
1140 | - foreach ($data['edit_tickets'] as $row => $tkt) { |
|
1141 | - $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1142 | - $update_prices = false; |
|
1143 | - $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) |
|
1144 | - ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1145 | - // trim inputs to ensure any excess whitespace is removed. |
|
1146 | - $tkt = array_map('trim', $tkt); |
|
1147 | - if (empty($tkt['TKT_start_date'])) { |
|
1148 | - //let's use now in the set timezone. |
|
1149 | - $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
1150 | - $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]); |
|
1151 | - } |
|
1152 | - if (empty($tkt['TKT_end_date'])) { |
|
1153 | - //use the start date of the first datetime |
|
1154 | - $dtt = $evtobj->first_datetime(); |
|
1155 | - $tkt['TKT_end_date'] = $dtt->start_date_and_time( |
|
1156 | - $incoming_date_formats[0], |
|
1157 | - $incoming_date_formats[1] |
|
1158 | - ); |
|
1159 | - } |
|
1160 | - $TKT_values = array( |
|
1161 | - 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null, |
|
1162 | - 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
1163 | - 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
1164 | - 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
1165 | - 'TKT_start_date' => $tkt['TKT_start_date'], |
|
1166 | - 'TKT_end_date' => $tkt['TKT_end_date'], |
|
1167 | - 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1168 | - 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1169 | - 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
1170 | - 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
1171 | - 'TKT_row' => $row, |
|
1172 | - 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
1173 | - 'TKT_price' => $ticket_price, |
|
1174 | - ); |
|
1175 | - //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
|
1176 | - if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
1177 | - $TKT_values['TKT_ID'] = 0; |
|
1178 | - $TKT_values['TKT_is_default'] = 0; |
|
1179 | - $TKT_values['TKT_price'] = $ticket_price; |
|
1180 | - $update_prices = true; |
|
1181 | - } |
|
1182 | - //if we have a TKT_ID then we need to get that existing TKT_obj and update it |
|
1183 | - //we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified. |
|
1184 | - //keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
|
1185 | - if ( ! empty($tkt['TKT_ID'])) { |
|
1186 | - $TKT = EE_Registry::instance() |
|
1187 | - ->load_model('Ticket', array($evtobj->get_timezone())) |
|
1188 | - ->get_one_by_ID($tkt['TKT_ID']); |
|
1189 | - if ($TKT instanceof EE_Ticket) { |
|
1190 | - $ticket_sold = $TKT->count_related( |
|
1191 | - 'Registration', |
|
1192 | - array( |
|
1193 | - array( |
|
1194 | - 'STS_ID' => array( |
|
1195 | - 'NOT IN', |
|
1196 | - array(EEM_Registration::status_id_incomplete), |
|
1197 | - ), |
|
1198 | - ), |
|
1199 | - ) |
|
1200 | - ) > 0 ? true : false; |
|
1201 | - //let's just check the total price for the existing ticket and determine if it matches the new total price. if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket. |
|
1202 | - $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') |
|
1203 | - && ! $TKT->get( |
|
1204 | - 'TKT_deleted' |
|
1205 | - ) ? true : false; |
|
1206 | - $TKT->set_date_format($incoming_date_formats[0]); |
|
1207 | - $TKT->set_time_format($incoming_date_formats[1]); |
|
1208 | - //set new values |
|
1209 | - foreach ($TKT_values as $field => $value) { |
|
1210 | - if ($field == 'TKT_qty') { |
|
1211 | - $TKT->set_qty($value); |
|
1212 | - } else { |
|
1213 | - $TKT->set($field, $value); |
|
1214 | - } |
|
1215 | - } |
|
1216 | - //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
|
1217 | - if ($create_new_TKT) { |
|
1218 | - //archive the old ticket first |
|
1219 | - $TKT->set('TKT_deleted', 1); |
|
1220 | - $TKT->save(); |
|
1221 | - //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
|
1222 | - $saved_tickets[$TKT->ID()] = $TKT; |
|
1223 | - //create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it. |
|
1224 | - $TKT = clone $TKT; |
|
1225 | - $TKT->set('TKT_ID', 0); |
|
1226 | - $TKT->set('TKT_deleted', 0); |
|
1227 | - $TKT->set('TKT_price', $ticket_price); |
|
1228 | - $TKT->set('TKT_sold', 0); |
|
1229 | - //now we need to make sure that $new prices are created as well and attached to new ticket. |
|
1230 | - $update_prices = true; |
|
1231 | - } |
|
1232 | - //make sure price is set if it hasn't been already |
|
1233 | - $TKT->set('TKT_price', $ticket_price); |
|
1234 | - } |
|
1235 | - } else { |
|
1236 | - //no TKT_id so a new TKT |
|
1237 | - $TKT_values['TKT_price'] = $ticket_price; |
|
1238 | - $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, |
|
1239 | - false); |
|
1240 | - if ($TKT instanceof EE_Ticket) { |
|
1241 | - //need to reset values to properly account for the date formats |
|
1242 | - $TKT->set_date_format($incoming_date_formats[0]); |
|
1243 | - $TKT->set_time_format($incoming_date_formats[1]); |
|
1244 | - $TKT->set_timezone($evtobj->get_timezone()); |
|
1245 | - //set new values |
|
1246 | - foreach ($TKT_values as $field => $value) { |
|
1247 | - if ($field == 'TKT_qty') { |
|
1248 | - $TKT->set_qty($value); |
|
1249 | - } else { |
|
1250 | - $TKT->set($field, $value); |
|
1251 | - } |
|
1252 | - } |
|
1253 | - $update_prices = true; |
|
1254 | - } |
|
1255 | - } |
|
1256 | - // cap ticket qty by datetime reg limits |
|
1257 | - $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
1258 | - //update ticket. |
|
1259 | - $TKT->save(); |
|
1260 | - //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
|
1261 | - if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
1262 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
1263 | - $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
|
1264 | - $TKT->save(); |
|
1265 | - } |
|
1266 | - //initially let's add the ticket to the dtt |
|
1267 | - $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
1268 | - $saved_tickets[$TKT->ID()] = $TKT; |
|
1269 | - //add prices to ticket |
|
1270 | - $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
1271 | - } |
|
1272 | - //however now we need to handle permanently deleting tickets via the ui. Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db. |
|
1273 | - $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1274 | - $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
1275 | - foreach ($tickets_removed as $id) { |
|
1276 | - $id = absint($id); |
|
1277 | - //get the ticket for this id |
|
1278 | - $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
|
1279 | - //need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold) |
|
1280 | - $dtts = $tkt_to_remove->get_many_related('Datetime'); |
|
1281 | - foreach ($dtts as $dtt) { |
|
1282 | - $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
|
1283 | - } |
|
1284 | - //need to do the same for prices (except these prices can also be deleted because again, tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
|
1285 | - $tkt_to_remove->delete_related_permanently('Price'); |
|
1286 | - //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
|
1287 | - $tkt_to_remove->delete_permanently(); |
|
1288 | - } |
|
1069 | + return ! empty($venue_id) ? true : false; |
|
1070 | + } |
|
1071 | + //when we have the ancestor come in it's already been handled by the revision save. |
|
1072 | + } |
|
1073 | + |
|
1074 | + |
|
1075 | + /** |
|
1076 | + * Handles saving everything related to Tickets (datetimes, tickets, prices) |
|
1077 | + * |
|
1078 | + * @param EE_Event $evtobj The Event object we're attaching data to |
|
1079 | + * @param array $data The request data from the form |
|
1080 | + * |
|
1081 | + * @return array |
|
1082 | + */ |
|
1083 | + protected function _default_tickets_update(EE_Event $evtobj, $data) |
|
1084 | + { |
|
1085 | + $success = true; |
|
1086 | + $saved_dtt = null; |
|
1087 | + $saved_tickets = array(); |
|
1088 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1089 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
1090 | + //trim all values to ensure any excess whitespace is removed. |
|
1091 | + $dtt = array_map('trim', $dtt); |
|
1092 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] |
|
1093 | + : $dtt['DTT_EVT_start']; |
|
1094 | + $datetime_values = array( |
|
1095 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null, |
|
1096 | + 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
|
1097 | + 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
|
1098 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
1099 | + 'DTT_order' => $row, |
|
1100 | + ); |
|
1101 | + //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
|
1102 | + if ( ! empty($dtt['DTT_ID'])) { |
|
1103 | + $DTM = EE_Registry::instance() |
|
1104 | + ->load_model('Datetime', array($evtobj->get_timezone())) |
|
1105 | + ->get_one_by_ID($dtt['DTT_ID']); |
|
1106 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
1107 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
1108 | + foreach ($datetime_values as $field => $value) { |
|
1109 | + $DTM->set($field, $value); |
|
1110 | + } |
|
1111 | + //make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. We need to do this so we dont' TRASH the parent DTT. |
|
1112 | + $saved_dtts[$DTM->ID()] = $DTM; |
|
1113 | + } else { |
|
1114 | + $DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values), false, false); |
|
1115 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
1116 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
1117 | + $DTM->set_timezone($evtobj->get_timezone()); |
|
1118 | + foreach ($datetime_values as $field => $value) { |
|
1119 | + $DTM->set($field, $value); |
|
1120 | + } |
|
1121 | + } |
|
1122 | + $DTM->save(); |
|
1123 | + $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
1124 | + //load DTT helper |
|
1125 | + //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
|
1126 | + if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
1127 | + $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
1128 | + $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
|
1129 | + $DTT->save(); |
|
1130 | + } |
|
1131 | + //now we got to make sure we add the new DTT_ID to the $saved_dtts array because it is possible there was a new one created for the autosave. |
|
1132 | + $saved_dtt = $DTT; |
|
1133 | + $success = ! $success ? $success : $DTT; |
|
1134 | + //if ANY of these updates fail then we want the appropriate global error message. |
|
1135 | + // //todo this is actually sucky we need a better error message but this is what it is for now. |
|
1136 | + } |
|
1137 | + //no dtts get deleted so we don't do any of that logic here. |
|
1138 | + //update tickets next |
|
1139 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
1140 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
1141 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1142 | + $update_prices = false; |
|
1143 | + $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) |
|
1144 | + ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1145 | + // trim inputs to ensure any excess whitespace is removed. |
|
1146 | + $tkt = array_map('trim', $tkt); |
|
1147 | + if (empty($tkt['TKT_start_date'])) { |
|
1148 | + //let's use now in the set timezone. |
|
1149 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
1150 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]); |
|
1151 | + } |
|
1152 | + if (empty($tkt['TKT_end_date'])) { |
|
1153 | + //use the start date of the first datetime |
|
1154 | + $dtt = $evtobj->first_datetime(); |
|
1155 | + $tkt['TKT_end_date'] = $dtt->start_date_and_time( |
|
1156 | + $incoming_date_formats[0], |
|
1157 | + $incoming_date_formats[1] |
|
1158 | + ); |
|
1159 | + } |
|
1160 | + $TKT_values = array( |
|
1161 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null, |
|
1162 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
1163 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
1164 | + 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
1165 | + 'TKT_start_date' => $tkt['TKT_start_date'], |
|
1166 | + 'TKT_end_date' => $tkt['TKT_end_date'], |
|
1167 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1168 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1169 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
1170 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
1171 | + 'TKT_row' => $row, |
|
1172 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
1173 | + 'TKT_price' => $ticket_price, |
|
1174 | + ); |
|
1175 | + //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
|
1176 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
1177 | + $TKT_values['TKT_ID'] = 0; |
|
1178 | + $TKT_values['TKT_is_default'] = 0; |
|
1179 | + $TKT_values['TKT_price'] = $ticket_price; |
|
1180 | + $update_prices = true; |
|
1181 | + } |
|
1182 | + //if we have a TKT_ID then we need to get that existing TKT_obj and update it |
|
1183 | + //we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified. |
|
1184 | + //keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
|
1185 | + if ( ! empty($tkt['TKT_ID'])) { |
|
1186 | + $TKT = EE_Registry::instance() |
|
1187 | + ->load_model('Ticket', array($evtobj->get_timezone())) |
|
1188 | + ->get_one_by_ID($tkt['TKT_ID']); |
|
1189 | + if ($TKT instanceof EE_Ticket) { |
|
1190 | + $ticket_sold = $TKT->count_related( |
|
1191 | + 'Registration', |
|
1192 | + array( |
|
1193 | + array( |
|
1194 | + 'STS_ID' => array( |
|
1195 | + 'NOT IN', |
|
1196 | + array(EEM_Registration::status_id_incomplete), |
|
1197 | + ), |
|
1198 | + ), |
|
1199 | + ) |
|
1200 | + ) > 0 ? true : false; |
|
1201 | + //let's just check the total price for the existing ticket and determine if it matches the new total price. if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket. |
|
1202 | + $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') |
|
1203 | + && ! $TKT->get( |
|
1204 | + 'TKT_deleted' |
|
1205 | + ) ? true : false; |
|
1206 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1207 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1208 | + //set new values |
|
1209 | + foreach ($TKT_values as $field => $value) { |
|
1210 | + if ($field == 'TKT_qty') { |
|
1211 | + $TKT->set_qty($value); |
|
1212 | + } else { |
|
1213 | + $TKT->set($field, $value); |
|
1214 | + } |
|
1215 | + } |
|
1216 | + //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
|
1217 | + if ($create_new_TKT) { |
|
1218 | + //archive the old ticket first |
|
1219 | + $TKT->set('TKT_deleted', 1); |
|
1220 | + $TKT->save(); |
|
1221 | + //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
|
1222 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1223 | + //create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it. |
|
1224 | + $TKT = clone $TKT; |
|
1225 | + $TKT->set('TKT_ID', 0); |
|
1226 | + $TKT->set('TKT_deleted', 0); |
|
1227 | + $TKT->set('TKT_price', $ticket_price); |
|
1228 | + $TKT->set('TKT_sold', 0); |
|
1229 | + //now we need to make sure that $new prices are created as well and attached to new ticket. |
|
1230 | + $update_prices = true; |
|
1231 | + } |
|
1232 | + //make sure price is set if it hasn't been already |
|
1233 | + $TKT->set('TKT_price', $ticket_price); |
|
1234 | + } |
|
1235 | + } else { |
|
1236 | + //no TKT_id so a new TKT |
|
1237 | + $TKT_values['TKT_price'] = $ticket_price; |
|
1238 | + $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, |
|
1239 | + false); |
|
1240 | + if ($TKT instanceof EE_Ticket) { |
|
1241 | + //need to reset values to properly account for the date formats |
|
1242 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1243 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1244 | + $TKT->set_timezone($evtobj->get_timezone()); |
|
1245 | + //set new values |
|
1246 | + foreach ($TKT_values as $field => $value) { |
|
1247 | + if ($field == 'TKT_qty') { |
|
1248 | + $TKT->set_qty($value); |
|
1249 | + } else { |
|
1250 | + $TKT->set($field, $value); |
|
1251 | + } |
|
1252 | + } |
|
1253 | + $update_prices = true; |
|
1254 | + } |
|
1255 | + } |
|
1256 | + // cap ticket qty by datetime reg limits |
|
1257 | + $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
1258 | + //update ticket. |
|
1259 | + $TKT->save(); |
|
1260 | + //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
|
1261 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
1262 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
1263 | + $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
|
1264 | + $TKT->save(); |
|
1265 | + } |
|
1266 | + //initially let's add the ticket to the dtt |
|
1267 | + $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
1268 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1269 | + //add prices to ticket |
|
1270 | + $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
1271 | + } |
|
1272 | + //however now we need to handle permanently deleting tickets via the ui. Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db. |
|
1273 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1274 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
1275 | + foreach ($tickets_removed as $id) { |
|
1276 | + $id = absint($id); |
|
1277 | + //get the ticket for this id |
|
1278 | + $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
|
1279 | + //need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold) |
|
1280 | + $dtts = $tkt_to_remove->get_many_related('Datetime'); |
|
1281 | + foreach ($dtts as $dtt) { |
|
1282 | + $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
|
1283 | + } |
|
1284 | + //need to do the same for prices (except these prices can also be deleted because again, tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
|
1285 | + $tkt_to_remove->delete_related_permanently('Price'); |
|
1286 | + //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
|
1287 | + $tkt_to_remove->delete_permanently(); |
|
1288 | + } |
|
1289 | 1289 | |
1290 | - return array($saved_dtt, $saved_tickets); |
|
1291 | - } |
|
1292 | - |
|
1293 | - |
|
1294 | - /** |
|
1295 | - * This attaches a list of given prices to a ticket. |
|
1296 | - * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change |
|
1297 | - * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old |
|
1298 | - * price info and prices are automatically "archived" via the ticket. |
|
1299 | - * |
|
1300 | - * @access private |
|
1301 | - * |
|
1302 | - * @param array $prices Array of prices from the form. |
|
1303 | - * @param EE_Ticket $ticket EE_Ticket object that prices are being attached to. |
|
1304 | - * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
|
1305 | - * |
|
1306 | - * @return void |
|
1307 | - */ |
|
1308 | - private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false) |
|
1309 | - { |
|
1310 | - foreach ($prices as $row => $prc) { |
|
1311 | - $PRC_values = array( |
|
1312 | - 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null, |
|
1313 | - 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null, |
|
1314 | - 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
1315 | - 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
1316 | - 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
1317 | - 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
|
1318 | - 'PRC_order' => $row, |
|
1319 | - ); |
|
1320 | - if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
1321 | - $PRC_values['PRC_ID'] = 0; |
|
1322 | - $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false); |
|
1323 | - } else { |
|
1324 | - $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
1325 | - //update this price with new values |
|
1326 | - foreach ($PRC_values as $field => $newprc) { |
|
1327 | - $PRC->set($field, $newprc); |
|
1328 | - } |
|
1329 | - $PRC->save(); |
|
1330 | - } |
|
1331 | - $ticket->_add_relation_to($PRC, 'Price'); |
|
1332 | - } |
|
1333 | - } |
|
1334 | - |
|
1335 | - |
|
1336 | - /** |
|
1337 | - * Add in our autosave ajax handlers |
|
1338 | - * |
|
1339 | - * @return void |
|
1340 | - */ |
|
1341 | - protected function _ee_autosave_create_new() |
|
1342 | - { |
|
1343 | - // $this->_ee_autosave_edit(); |
|
1344 | - } |
|
1345 | - |
|
1346 | - |
|
1347 | - protected function _ee_autosave_edit() |
|
1348 | - { |
|
1349 | - return; //TEMPORARILY EXITING CAUSE THIS IS A TODO |
|
1350 | - } |
|
1351 | - |
|
1352 | - |
|
1353 | - /** |
|
1354 | - * _generate_publish_box_extra_content |
|
1355 | - * |
|
1356 | - * @access private |
|
1357 | - * @return void |
|
1358 | - */ |
|
1359 | - private function _generate_publish_box_extra_content() |
|
1360 | - { |
|
1361 | - //load formatter helper |
|
1362 | - //args for getting related registrations |
|
1363 | - $approved_query_args = array( |
|
1364 | - array( |
|
1365 | - 'REG_deleted' => 0, |
|
1366 | - 'STS_ID' => EEM_Registration::status_id_approved |
|
1367 | - ) |
|
1368 | - ); |
|
1369 | - $not_approved_query_args = array( |
|
1370 | - array( |
|
1371 | - 'REG_deleted' => 0, |
|
1372 | - 'STS_ID' => EEM_Registration::status_id_not_approved, |
|
1373 | - ), |
|
1374 | - ); |
|
1375 | - $pending_payment_query_args = array( |
|
1376 | - array( |
|
1377 | - 'REG_deleted' => 0, |
|
1378 | - 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
1379 | - ), |
|
1380 | - ); |
|
1381 | - // publish box |
|
1382 | - $publish_box_extra_args = array( |
|
1383 | - 'view_approved_reg_url' => add_query_arg( |
|
1384 | - array( |
|
1385 | - 'action' => 'default', |
|
1386 | - 'event_id' => $this->_cpt_model_obj->ID(), |
|
1387 | - '_reg_status' => EEM_Registration::status_id_approved, |
|
1388 | - ), |
|
1389 | - REG_ADMIN_URL |
|
1390 | - ), |
|
1391 | - 'view_not_approved_reg_url' => add_query_arg( |
|
1392 | - array( |
|
1393 | - 'action' => 'default', |
|
1394 | - 'event_id' => $this->_cpt_model_obj->ID(), |
|
1395 | - '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1396 | - ), |
|
1397 | - REG_ADMIN_URL |
|
1398 | - ), |
|
1399 | - 'view_pending_payment_reg_url' => add_query_arg( |
|
1400 | - array( |
|
1401 | - 'action' => 'default', |
|
1402 | - 'event_id' => $this->_cpt_model_obj->ID(), |
|
1403 | - '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
1404 | - ), |
|
1405 | - REG_ADMIN_URL |
|
1406 | - ), |
|
1407 | - 'approved_regs' => $this->_cpt_model_obj->count_related( |
|
1408 | - 'Registration', |
|
1409 | - $approved_query_args |
|
1410 | - ), |
|
1411 | - 'not_approved_regs' => $this->_cpt_model_obj->count_related( |
|
1412 | - 'Registration', |
|
1413 | - $not_approved_query_args |
|
1414 | - ), |
|
1415 | - 'pending_payment_regs' => $this->_cpt_model_obj->count_related( |
|
1416 | - 'Registration', |
|
1417 | - $pending_payment_query_args |
|
1418 | - ), |
|
1419 | - 'misc_pub_section_class' => apply_filters( |
|
1420 | - 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
|
1421 | - 'misc-pub-section' |
|
1422 | - ), |
|
1423 | - //'email_attendees_url' => add_query_arg( |
|
1424 | - // array( |
|
1425 | - // 'event_admin_reports' => 'event_newsletter', |
|
1426 | - // 'event_id' => $this->_cpt_model_obj->id |
|
1427 | - // ), |
|
1428 | - // 'admin.php?page=espresso_registrations' |
|
1429 | - //), |
|
1430 | - ); |
|
1431 | - ob_start(); |
|
1432 | - do_action( |
|
1433 | - 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
|
1434 | - $this->_cpt_model_obj |
|
1435 | - ); |
|
1436 | - $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
1437 | - // load template |
|
1438 | - EEH_Template::display_template( |
|
1439 | - EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
1440 | - $publish_box_extra_args |
|
1441 | - ); |
|
1442 | - } |
|
1443 | - |
|
1444 | - |
|
1445 | - /** |
|
1446 | - * This just returns whatever is set as the _event object property |
|
1447 | - * //todo this will become obsolete once the models are in place |
|
1448 | - * |
|
1449 | - * @return object |
|
1450 | - */ |
|
1451 | - public function get_event_object() |
|
1452 | - { |
|
1453 | - return $this->_cpt_model_obj; |
|
1454 | - } |
|
1455 | - |
|
1456 | - |
|
1457 | - |
|
1458 | - |
|
1459 | - /** METABOXES * */ |
|
1460 | - |
|
1461 | - |
|
1462 | - /** |
|
1463 | - * _register_event_editor_meta_boxes |
|
1464 | - * add all metaboxes related to the event_editor |
|
1465 | - * |
|
1466 | - * @return void |
|
1467 | - */ |
|
1468 | - protected function _register_event_editor_meta_boxes() |
|
1469 | - { |
|
1470 | - $this->verify_cpt_object(); |
|
1471 | - add_meta_box( |
|
1472 | - 'espresso_event_editor_tickets', |
|
1473 | - esc_html__('Event Datetime & Ticket', 'event_espresso'), |
|
1474 | - array($this, 'ticket_metabox'), |
|
1475 | - $this->page_slug, |
|
1476 | - 'normal', |
|
1477 | - 'high' |
|
1478 | - ); |
|
1479 | - add_meta_box( |
|
1480 | - 'espresso_event_editor_event_options', |
|
1481 | - esc_html__('Event Registration Options', 'event_espresso'), |
|
1482 | - array($this, 'registration_options_meta_box'), |
|
1483 | - $this->page_slug, |
|
1484 | - 'side', |
|
1485 | - 'default' |
|
1486 | - ); |
|
1487 | - // NOTE: if you're looking for other metaboxes in here, |
|
1488 | - // where a metabox has a related management page in the admin |
|
1489 | - // you will find it setup in the related management page's "_Hooks" file. |
|
1490 | - // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php". |
|
1491 | - } |
|
1492 | - |
|
1493 | - |
|
1494 | - public function ticket_metabox() |
|
1495 | - { |
|
1496 | - $existing_datetime_ids = $existing_ticket_ids = array(); |
|
1497 | - //defaults for template args |
|
1498 | - $template_args = array( |
|
1499 | - 'existing_datetime_ids' => '', |
|
1500 | - 'event_datetime_help_link' => '', |
|
1501 | - 'ticket_options_help_link' => '', |
|
1502 | - 'time' => null, |
|
1503 | - 'ticket_rows' => '', |
|
1504 | - 'existing_ticket_ids' => '', |
|
1505 | - 'total_ticket_rows' => 1, |
|
1506 | - 'ticket_js_structure' => '', |
|
1507 | - 'trash_icon' => 'ee-lock-icon', |
|
1508 | - 'disabled' => '', |
|
1509 | - ); |
|
1510 | - $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null; |
|
1511 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1512 | - /** |
|
1513 | - * 1. Start with retrieving Datetimes |
|
1514 | - * 2. Fore each datetime get related tickets |
|
1515 | - * 3. For each ticket get related prices |
|
1516 | - */ |
|
1517 | - $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
1518 | - /** @type EE_Datetime $first_datetime */ |
|
1519 | - $first_datetime = reset($times); |
|
1520 | - //do we get related tickets? |
|
1521 | - if ($first_datetime instanceof EE_Datetime |
|
1522 | - && $first_datetime->ID() !== 0 |
|
1523 | - ) { |
|
1524 | - $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
|
1525 | - $template_args['time'] = $first_datetime; |
|
1526 | - $related_tickets = $first_datetime->tickets( |
|
1527 | - array( |
|
1528 | - array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
1529 | - 'default_where_conditions' => 'none', |
|
1530 | - ) |
|
1531 | - ); |
|
1532 | - if ( ! empty($related_tickets)) { |
|
1533 | - $template_args['total_ticket_rows'] = count($related_tickets); |
|
1534 | - $row = 0; |
|
1535 | - foreach ($related_tickets as $ticket) { |
|
1536 | - $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
|
1537 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row); |
|
1538 | - $row++; |
|
1539 | - } |
|
1540 | - } else { |
|
1541 | - $template_args['total_ticket_rows'] = 1; |
|
1542 | - /** @type EE_Ticket $ticket */ |
|
1543 | - $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
|
1544 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
1545 | - } |
|
1546 | - } else { |
|
1547 | - $template_args['time'] = $times[0]; |
|
1548 | - /** @type EE_Ticket $ticket */ |
|
1549 | - $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
|
1550 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
1551 | - // NOTE: we're just sending the first default row |
|
1552 | - // (decaf can't manage default tickets so this should be sufficient); |
|
1553 | - } |
|
1554 | - $template_args['event_datetime_help_link'] = $this->_get_help_tab_link( |
|
1555 | - 'event_editor_event_datetimes_help_tab' |
|
1556 | - ); |
|
1557 | - $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
|
1558 | - $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
1559 | - $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
1560 | - $template_args['ticket_js_structure'] = $this->_get_ticket_row( |
|
1561 | - EE_Registry::instance()->load_model('Ticket')->create_default_object(), |
|
1562 | - true |
|
1563 | - ); |
|
1564 | - $template = apply_filters( |
|
1565 | - 'FHEE__Events_Admin_Page__ticket_metabox__template', |
|
1566 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
1567 | - ); |
|
1568 | - EEH_Template::display_template($template, $template_args); |
|
1569 | - } |
|
1570 | - |
|
1571 | - |
|
1572 | - /** |
|
1573 | - * Setup an individual ticket form for the decaf event editor page |
|
1574 | - * |
|
1575 | - * @access private |
|
1576 | - * |
|
1577 | - * @param EE_Ticket $ticket the ticket object |
|
1578 | - * @param boolean $skeleton whether we're generating a skeleton for js manipulation |
|
1579 | - * @param int $row |
|
1580 | - * |
|
1581 | - * @return string generated html for the ticket row. |
|
1582 | - */ |
|
1583 | - private function _get_ticket_row($ticket, $skeleton = false, $row = 0) |
|
1584 | - { |
|
1585 | - $template_args = array( |
|
1586 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1587 | - 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
|
1588 | - : '', |
|
1589 | - 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
|
1590 | - 'TKT_ID' => $ticket->get('TKT_ID'), |
|
1591 | - 'TKT_name' => $ticket->get('TKT_name'), |
|
1592 | - 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
|
1593 | - 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
|
1594 | - 'TKT_is_default' => $ticket->get('TKT_is_default'), |
|
1595 | - 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
1596 | - 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
|
1597 | - 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
|
1598 | - 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) |
|
1599 | - && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) |
|
1600 | - ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1601 | - 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' |
|
1602 | - : ' disabled=disabled', |
|
1603 | - ); |
|
1604 | - $price = $ticket->ID() !== 0 |
|
1605 | - ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) |
|
1606 | - : EE_Registry::instance()->load_model('Price')->create_default_object(); |
|
1607 | - $price_args = array( |
|
1608 | - 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
|
1609 | - 'PRC_amount' => $price->get('PRC_amount'), |
|
1610 | - 'PRT_ID' => $price->get('PRT_ID'), |
|
1611 | - 'PRC_ID' => $price->get('PRC_ID'), |
|
1612 | - 'PRC_is_default' => $price->get('PRC_is_default'), |
|
1613 | - ); |
|
1614 | - //make sure we have default start and end dates if skeleton |
|
1615 | - //handle rows that should NOT be empty |
|
1616 | - if (empty($template_args['TKT_start_date'])) { |
|
1617 | - //if empty then the start date will be now. |
|
1618 | - $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
|
1619 | - } |
|
1620 | - if (empty($template_args['TKT_end_date'])) { |
|
1621 | - //get the earliest datetime (if present); |
|
1622 | - $earliest_dtt = $this->_cpt_model_obj->ID() > 0 |
|
1623 | - ? $this->_cpt_model_obj->get_first_related( |
|
1624 | - 'Datetime', |
|
1625 | - array('order_by' => array('DTT_EVT_start' => 'ASC')) |
|
1626 | - ) |
|
1627 | - : null; |
|
1628 | - if ( ! empty($earliest_dtt)) { |
|
1629 | - $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
|
1630 | - } else { |
|
1631 | - $template_args['TKT_end_date'] = date( |
|
1632 | - 'Y-m-d h:i a', |
|
1633 | - mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")) |
|
1634 | - ); |
|
1635 | - } |
|
1636 | - } |
|
1637 | - $template_args = array_merge($template_args, $price_args); |
|
1638 | - $template = apply_filters( |
|
1639 | - 'FHEE__Events_Admin_Page__get_ticket_row__template', |
|
1640 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
1641 | - $ticket |
|
1642 | - ); |
|
1290 | + return array($saved_dtt, $saved_tickets); |
|
1291 | + } |
|
1292 | + |
|
1293 | + |
|
1294 | + /** |
|
1295 | + * This attaches a list of given prices to a ticket. |
|
1296 | + * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change |
|
1297 | + * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old |
|
1298 | + * price info and prices are automatically "archived" via the ticket. |
|
1299 | + * |
|
1300 | + * @access private |
|
1301 | + * |
|
1302 | + * @param array $prices Array of prices from the form. |
|
1303 | + * @param EE_Ticket $ticket EE_Ticket object that prices are being attached to. |
|
1304 | + * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
|
1305 | + * |
|
1306 | + * @return void |
|
1307 | + */ |
|
1308 | + private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false) |
|
1309 | + { |
|
1310 | + foreach ($prices as $row => $prc) { |
|
1311 | + $PRC_values = array( |
|
1312 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null, |
|
1313 | + 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null, |
|
1314 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
1315 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
1316 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
1317 | + 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
|
1318 | + 'PRC_order' => $row, |
|
1319 | + ); |
|
1320 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
1321 | + $PRC_values['PRC_ID'] = 0; |
|
1322 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false); |
|
1323 | + } else { |
|
1324 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
1325 | + //update this price with new values |
|
1326 | + foreach ($PRC_values as $field => $newprc) { |
|
1327 | + $PRC->set($field, $newprc); |
|
1328 | + } |
|
1329 | + $PRC->save(); |
|
1330 | + } |
|
1331 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
1332 | + } |
|
1333 | + } |
|
1334 | + |
|
1335 | + |
|
1336 | + /** |
|
1337 | + * Add in our autosave ajax handlers |
|
1338 | + * |
|
1339 | + * @return void |
|
1340 | + */ |
|
1341 | + protected function _ee_autosave_create_new() |
|
1342 | + { |
|
1343 | + // $this->_ee_autosave_edit(); |
|
1344 | + } |
|
1345 | + |
|
1346 | + |
|
1347 | + protected function _ee_autosave_edit() |
|
1348 | + { |
|
1349 | + return; //TEMPORARILY EXITING CAUSE THIS IS A TODO |
|
1350 | + } |
|
1351 | + |
|
1352 | + |
|
1353 | + /** |
|
1354 | + * _generate_publish_box_extra_content |
|
1355 | + * |
|
1356 | + * @access private |
|
1357 | + * @return void |
|
1358 | + */ |
|
1359 | + private function _generate_publish_box_extra_content() |
|
1360 | + { |
|
1361 | + //load formatter helper |
|
1362 | + //args for getting related registrations |
|
1363 | + $approved_query_args = array( |
|
1364 | + array( |
|
1365 | + 'REG_deleted' => 0, |
|
1366 | + 'STS_ID' => EEM_Registration::status_id_approved |
|
1367 | + ) |
|
1368 | + ); |
|
1369 | + $not_approved_query_args = array( |
|
1370 | + array( |
|
1371 | + 'REG_deleted' => 0, |
|
1372 | + 'STS_ID' => EEM_Registration::status_id_not_approved, |
|
1373 | + ), |
|
1374 | + ); |
|
1375 | + $pending_payment_query_args = array( |
|
1376 | + array( |
|
1377 | + 'REG_deleted' => 0, |
|
1378 | + 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
1379 | + ), |
|
1380 | + ); |
|
1381 | + // publish box |
|
1382 | + $publish_box_extra_args = array( |
|
1383 | + 'view_approved_reg_url' => add_query_arg( |
|
1384 | + array( |
|
1385 | + 'action' => 'default', |
|
1386 | + 'event_id' => $this->_cpt_model_obj->ID(), |
|
1387 | + '_reg_status' => EEM_Registration::status_id_approved, |
|
1388 | + ), |
|
1389 | + REG_ADMIN_URL |
|
1390 | + ), |
|
1391 | + 'view_not_approved_reg_url' => add_query_arg( |
|
1392 | + array( |
|
1393 | + 'action' => 'default', |
|
1394 | + 'event_id' => $this->_cpt_model_obj->ID(), |
|
1395 | + '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1396 | + ), |
|
1397 | + REG_ADMIN_URL |
|
1398 | + ), |
|
1399 | + 'view_pending_payment_reg_url' => add_query_arg( |
|
1400 | + array( |
|
1401 | + 'action' => 'default', |
|
1402 | + 'event_id' => $this->_cpt_model_obj->ID(), |
|
1403 | + '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
1404 | + ), |
|
1405 | + REG_ADMIN_URL |
|
1406 | + ), |
|
1407 | + 'approved_regs' => $this->_cpt_model_obj->count_related( |
|
1408 | + 'Registration', |
|
1409 | + $approved_query_args |
|
1410 | + ), |
|
1411 | + 'not_approved_regs' => $this->_cpt_model_obj->count_related( |
|
1412 | + 'Registration', |
|
1413 | + $not_approved_query_args |
|
1414 | + ), |
|
1415 | + 'pending_payment_regs' => $this->_cpt_model_obj->count_related( |
|
1416 | + 'Registration', |
|
1417 | + $pending_payment_query_args |
|
1418 | + ), |
|
1419 | + 'misc_pub_section_class' => apply_filters( |
|
1420 | + 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
|
1421 | + 'misc-pub-section' |
|
1422 | + ), |
|
1423 | + //'email_attendees_url' => add_query_arg( |
|
1424 | + // array( |
|
1425 | + // 'event_admin_reports' => 'event_newsletter', |
|
1426 | + // 'event_id' => $this->_cpt_model_obj->id |
|
1427 | + // ), |
|
1428 | + // 'admin.php?page=espresso_registrations' |
|
1429 | + //), |
|
1430 | + ); |
|
1431 | + ob_start(); |
|
1432 | + do_action( |
|
1433 | + 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
|
1434 | + $this->_cpt_model_obj |
|
1435 | + ); |
|
1436 | + $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
1437 | + // load template |
|
1438 | + EEH_Template::display_template( |
|
1439 | + EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
1440 | + $publish_box_extra_args |
|
1441 | + ); |
|
1442 | + } |
|
1443 | + |
|
1444 | + |
|
1445 | + /** |
|
1446 | + * This just returns whatever is set as the _event object property |
|
1447 | + * //todo this will become obsolete once the models are in place |
|
1448 | + * |
|
1449 | + * @return object |
|
1450 | + */ |
|
1451 | + public function get_event_object() |
|
1452 | + { |
|
1453 | + return $this->_cpt_model_obj; |
|
1454 | + } |
|
1455 | + |
|
1456 | + |
|
1457 | + |
|
1458 | + |
|
1459 | + /** METABOXES * */ |
|
1460 | + |
|
1461 | + |
|
1462 | + /** |
|
1463 | + * _register_event_editor_meta_boxes |
|
1464 | + * add all metaboxes related to the event_editor |
|
1465 | + * |
|
1466 | + * @return void |
|
1467 | + */ |
|
1468 | + protected function _register_event_editor_meta_boxes() |
|
1469 | + { |
|
1470 | + $this->verify_cpt_object(); |
|
1471 | + add_meta_box( |
|
1472 | + 'espresso_event_editor_tickets', |
|
1473 | + esc_html__('Event Datetime & Ticket', 'event_espresso'), |
|
1474 | + array($this, 'ticket_metabox'), |
|
1475 | + $this->page_slug, |
|
1476 | + 'normal', |
|
1477 | + 'high' |
|
1478 | + ); |
|
1479 | + add_meta_box( |
|
1480 | + 'espresso_event_editor_event_options', |
|
1481 | + esc_html__('Event Registration Options', 'event_espresso'), |
|
1482 | + array($this, 'registration_options_meta_box'), |
|
1483 | + $this->page_slug, |
|
1484 | + 'side', |
|
1485 | + 'default' |
|
1486 | + ); |
|
1487 | + // NOTE: if you're looking for other metaboxes in here, |
|
1488 | + // where a metabox has a related management page in the admin |
|
1489 | + // you will find it setup in the related management page's "_Hooks" file. |
|
1490 | + // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php". |
|
1491 | + } |
|
1492 | + |
|
1493 | + |
|
1494 | + public function ticket_metabox() |
|
1495 | + { |
|
1496 | + $existing_datetime_ids = $existing_ticket_ids = array(); |
|
1497 | + //defaults for template args |
|
1498 | + $template_args = array( |
|
1499 | + 'existing_datetime_ids' => '', |
|
1500 | + 'event_datetime_help_link' => '', |
|
1501 | + 'ticket_options_help_link' => '', |
|
1502 | + 'time' => null, |
|
1503 | + 'ticket_rows' => '', |
|
1504 | + 'existing_ticket_ids' => '', |
|
1505 | + 'total_ticket_rows' => 1, |
|
1506 | + 'ticket_js_structure' => '', |
|
1507 | + 'trash_icon' => 'ee-lock-icon', |
|
1508 | + 'disabled' => '', |
|
1509 | + ); |
|
1510 | + $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null; |
|
1511 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1512 | + /** |
|
1513 | + * 1. Start with retrieving Datetimes |
|
1514 | + * 2. Fore each datetime get related tickets |
|
1515 | + * 3. For each ticket get related prices |
|
1516 | + */ |
|
1517 | + $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
1518 | + /** @type EE_Datetime $first_datetime */ |
|
1519 | + $first_datetime = reset($times); |
|
1520 | + //do we get related tickets? |
|
1521 | + if ($first_datetime instanceof EE_Datetime |
|
1522 | + && $first_datetime->ID() !== 0 |
|
1523 | + ) { |
|
1524 | + $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
|
1525 | + $template_args['time'] = $first_datetime; |
|
1526 | + $related_tickets = $first_datetime->tickets( |
|
1527 | + array( |
|
1528 | + array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
1529 | + 'default_where_conditions' => 'none', |
|
1530 | + ) |
|
1531 | + ); |
|
1532 | + if ( ! empty($related_tickets)) { |
|
1533 | + $template_args['total_ticket_rows'] = count($related_tickets); |
|
1534 | + $row = 0; |
|
1535 | + foreach ($related_tickets as $ticket) { |
|
1536 | + $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
|
1537 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row); |
|
1538 | + $row++; |
|
1539 | + } |
|
1540 | + } else { |
|
1541 | + $template_args['total_ticket_rows'] = 1; |
|
1542 | + /** @type EE_Ticket $ticket */ |
|
1543 | + $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
|
1544 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
1545 | + } |
|
1546 | + } else { |
|
1547 | + $template_args['time'] = $times[0]; |
|
1548 | + /** @type EE_Ticket $ticket */ |
|
1549 | + $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
|
1550 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
1551 | + // NOTE: we're just sending the first default row |
|
1552 | + // (decaf can't manage default tickets so this should be sufficient); |
|
1553 | + } |
|
1554 | + $template_args['event_datetime_help_link'] = $this->_get_help_tab_link( |
|
1555 | + 'event_editor_event_datetimes_help_tab' |
|
1556 | + ); |
|
1557 | + $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
|
1558 | + $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
1559 | + $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
1560 | + $template_args['ticket_js_structure'] = $this->_get_ticket_row( |
|
1561 | + EE_Registry::instance()->load_model('Ticket')->create_default_object(), |
|
1562 | + true |
|
1563 | + ); |
|
1564 | + $template = apply_filters( |
|
1565 | + 'FHEE__Events_Admin_Page__ticket_metabox__template', |
|
1566 | + EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
1567 | + ); |
|
1568 | + EEH_Template::display_template($template, $template_args); |
|
1569 | + } |
|
1570 | + |
|
1571 | + |
|
1572 | + /** |
|
1573 | + * Setup an individual ticket form for the decaf event editor page |
|
1574 | + * |
|
1575 | + * @access private |
|
1576 | + * |
|
1577 | + * @param EE_Ticket $ticket the ticket object |
|
1578 | + * @param boolean $skeleton whether we're generating a skeleton for js manipulation |
|
1579 | + * @param int $row |
|
1580 | + * |
|
1581 | + * @return string generated html for the ticket row. |
|
1582 | + */ |
|
1583 | + private function _get_ticket_row($ticket, $skeleton = false, $row = 0) |
|
1584 | + { |
|
1585 | + $template_args = array( |
|
1586 | + 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1587 | + 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
|
1588 | + : '', |
|
1589 | + 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
|
1590 | + 'TKT_ID' => $ticket->get('TKT_ID'), |
|
1591 | + 'TKT_name' => $ticket->get('TKT_name'), |
|
1592 | + 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
|
1593 | + 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
|
1594 | + 'TKT_is_default' => $ticket->get('TKT_is_default'), |
|
1595 | + 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
1596 | + 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
|
1597 | + 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
|
1598 | + 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) |
|
1599 | + && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) |
|
1600 | + ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1601 | + 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' |
|
1602 | + : ' disabled=disabled', |
|
1603 | + ); |
|
1604 | + $price = $ticket->ID() !== 0 |
|
1605 | + ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) |
|
1606 | + : EE_Registry::instance()->load_model('Price')->create_default_object(); |
|
1607 | + $price_args = array( |
|
1608 | + 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
|
1609 | + 'PRC_amount' => $price->get('PRC_amount'), |
|
1610 | + 'PRT_ID' => $price->get('PRT_ID'), |
|
1611 | + 'PRC_ID' => $price->get('PRC_ID'), |
|
1612 | + 'PRC_is_default' => $price->get('PRC_is_default'), |
|
1613 | + ); |
|
1614 | + //make sure we have default start and end dates if skeleton |
|
1615 | + //handle rows that should NOT be empty |
|
1616 | + if (empty($template_args['TKT_start_date'])) { |
|
1617 | + //if empty then the start date will be now. |
|
1618 | + $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
|
1619 | + } |
|
1620 | + if (empty($template_args['TKT_end_date'])) { |
|
1621 | + //get the earliest datetime (if present); |
|
1622 | + $earliest_dtt = $this->_cpt_model_obj->ID() > 0 |
|
1623 | + ? $this->_cpt_model_obj->get_first_related( |
|
1624 | + 'Datetime', |
|
1625 | + array('order_by' => array('DTT_EVT_start' => 'ASC')) |
|
1626 | + ) |
|
1627 | + : null; |
|
1628 | + if ( ! empty($earliest_dtt)) { |
|
1629 | + $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
|
1630 | + } else { |
|
1631 | + $template_args['TKT_end_date'] = date( |
|
1632 | + 'Y-m-d h:i a', |
|
1633 | + mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")) |
|
1634 | + ); |
|
1635 | + } |
|
1636 | + } |
|
1637 | + $template_args = array_merge($template_args, $price_args); |
|
1638 | + $template = apply_filters( |
|
1639 | + 'FHEE__Events_Admin_Page__get_ticket_row__template', |
|
1640 | + EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
1641 | + $ticket |
|
1642 | + ); |
|
1643 | 1643 | |
1644 | - return EEH_Template::display_template($template, $template_args, true); |
|
1645 | - } |
|
1646 | - |
|
1647 | - |
|
1648 | - public function registration_options_meta_box() |
|
1649 | - { |
|
1650 | - $yes_no_values = array( |
|
1651 | - array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
1652 | - array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
1653 | - ); |
|
1654 | - $default_reg_status_values = EEM_Registration::reg_status_array( |
|
1655 | - array( |
|
1656 | - EEM_Registration::status_id_cancelled, |
|
1657 | - EEM_Registration::status_id_declined, |
|
1658 | - EEM_Registration::status_id_incomplete, |
|
1659 | - ), |
|
1660 | - true |
|
1661 | - ); |
|
1662 | - //$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active()); |
|
1663 | - $template_args['_event'] = $this->_cpt_model_obj; |
|
1664 | - $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
1665 | - $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
1666 | - $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
1667 | - 'default_reg_status', |
|
1668 | - $default_reg_status_values, |
|
1669 | - $this->_cpt_model_obj->default_registration_status() |
|
1670 | - ); |
|
1671 | - $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
1672 | - 'display_desc', |
|
1673 | - $yes_no_values, |
|
1674 | - $this->_cpt_model_obj->display_description() |
|
1675 | - ); |
|
1676 | - $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
1677 | - 'display_ticket_selector', |
|
1678 | - $yes_no_values, |
|
1679 | - $this->_cpt_model_obj->display_ticket_selector(), |
|
1680 | - '', |
|
1681 | - '', |
|
1682 | - false |
|
1683 | - ); |
|
1684 | - $template_args['additional_registration_options'] = apply_filters( |
|
1685 | - 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
1686 | - '', |
|
1687 | - $template_args, |
|
1688 | - $yes_no_values, |
|
1689 | - $default_reg_status_values |
|
1690 | - ); |
|
1691 | - EEH_Template::display_template( |
|
1692 | - EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
1693 | - $template_args |
|
1694 | - ); |
|
1695 | - } |
|
1696 | - |
|
1697 | - |
|
1698 | - /** |
|
1699 | - * _get_events() |
|
1700 | - * This method simply returns all the events (for the given _view and paging) |
|
1701 | - * |
|
1702 | - * @access public |
|
1703 | - * |
|
1704 | - * @param int $per_page count of items per page (20 default); |
|
1705 | - * @param int $current_page what is the current page being viewed. |
|
1706 | - * @param bool $count if TRUE then we just return a count of ALL events matching the given _view. |
|
1707 | - * If FALSE then we return an array of event objects |
|
1708 | - * that match the given _view and paging parameters. |
|
1709 | - * |
|
1710 | - * @return array an array of event objects. |
|
1711 | - */ |
|
1712 | - public function get_events($per_page = 10, $current_page = 1, $count = false) |
|
1713 | - { |
|
1714 | - $EEME = $this->_event_model(); |
|
1715 | - $offset = ($current_page - 1) * $per_page; |
|
1716 | - $limit = $count ? null : $offset . ',' . $per_page; |
|
1717 | - $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
|
1718 | - $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
|
1719 | - if (isset($this->_req_data['month_range'])) { |
|
1720 | - $pieces = explode(' ', $this->_req_data['month_range'], 3); |
|
1721 | - $month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1722 | - $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1723 | - } |
|
1724 | - $where = array(); |
|
1725 | - $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
1726 | - //determine what post_status our condition will have for the query. |
|
1727 | - switch ($status) { |
|
1728 | - case 'month' : |
|
1729 | - case 'today' : |
|
1730 | - case null : |
|
1731 | - case 'all' : |
|
1732 | - break; |
|
1733 | - case 'draft' : |
|
1734 | - $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
1735 | - break; |
|
1736 | - default : |
|
1737 | - $where['status'] = $status; |
|
1738 | - } |
|
1739 | - //categories? |
|
1740 | - $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
1741 | - ? $this->_req_data['EVT_CAT'] : null; |
|
1742 | - if ( ! empty ($category)) { |
|
1743 | - $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1744 | - $where['Term_Taxonomy.term_id'] = $category; |
|
1745 | - } |
|
1746 | - //date where conditions |
|
1747 | - $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
1748 | - if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
|
1749 | - $DateTime = new DateTime( |
|
1750 | - $year_r . '-' . $month_r . '-01 00:00:00', |
|
1751 | - new DateTimeZone(EEM_Datetime::instance()->get_timezone()) |
|
1752 | - ); |
|
1753 | - $start = $DateTime->format(implode(' ', $start_formats)); |
|
1754 | - $end = $DateTime->setDate($year_r, $month_r, |
|
1755 | - $DateTime->format('t'))->setTime(23, 59, 59)->format( |
|
1756 | - implode(' ', $start_formats) |
|
1757 | - ); |
|
1758 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1759 | - } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
|
1760 | - $DateTime = new DateTime('now', |
|
1761 | - new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1762 | - $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1763 | - $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1764 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1765 | - } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
1766 | - $now = date('Y-m-01'); |
|
1767 | - $DateTime = new DateTime($now, |
|
1768 | - new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1769 | - $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1770 | - $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t')) |
|
1771 | - ->setTime(23, 59, 59) |
|
1772 | - ->format(implode(' ', $start_formats)); |
|
1773 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1774 | - } |
|
1775 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1776 | - $where['EVT_wp_user'] = get_current_user_id(); |
|
1777 | - } else { |
|
1778 | - if ( ! isset($where['status'])) { |
|
1779 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
1780 | - $where['OR'] = array( |
|
1781 | - 'status*restrict_private' => array('!=', 'private'), |
|
1782 | - 'AND' => array( |
|
1783 | - 'status*inclusive' => array('=', 'private'), |
|
1784 | - 'EVT_wp_user' => get_current_user_id(), |
|
1785 | - ), |
|
1786 | - ); |
|
1787 | - } |
|
1788 | - } |
|
1789 | - } |
|
1790 | - if (isset($this->_req_data['EVT_wp_user'])) { |
|
1791 | - if ($this->_req_data['EVT_wp_user'] != get_current_user_id() |
|
1792 | - && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events') |
|
1793 | - ) { |
|
1794 | - $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
|
1795 | - } |
|
1796 | - } |
|
1797 | - //search query handling |
|
1798 | - if (isset($this->_req_data['s'])) { |
|
1799 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1800 | - $where['OR'] = array( |
|
1801 | - 'EVT_name' => array('LIKE', $search_string), |
|
1802 | - 'EVT_desc' => array('LIKE', $search_string), |
|
1803 | - 'EVT_short_desc' => array('LIKE', $search_string), |
|
1804 | - ); |
|
1805 | - } |
|
1806 | - $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
1807 | - $query_params = apply_filters( |
|
1808 | - 'FHEE__Events_Admin_Page__get_events__query_params', |
|
1809 | - array( |
|
1810 | - $where, |
|
1811 | - 'limit' => $limit, |
|
1812 | - 'order_by' => $orderby, |
|
1813 | - 'order' => $order, |
|
1814 | - 'group_by' => 'EVT_ID', |
|
1815 | - ), |
|
1816 | - $this->_req_data |
|
1817 | - ); |
|
1818 | - //let's first check if we have special requests coming in. |
|
1819 | - if (isset($this->_req_data['active_status'])) { |
|
1820 | - switch ($this->_req_data['active_status']) { |
|
1821 | - case 'upcoming' : |
|
1822 | - return $EEME->get_upcoming_events($query_params, $count); |
|
1823 | - break; |
|
1824 | - case 'expired' : |
|
1825 | - return $EEME->get_expired_events($query_params, $count); |
|
1826 | - break; |
|
1827 | - case 'active' : |
|
1828 | - return $EEME->get_active_events($query_params, $count); |
|
1829 | - break; |
|
1830 | - case 'inactive' : |
|
1831 | - return $EEME->get_inactive_events($query_params, $count); |
|
1832 | - break; |
|
1833 | - } |
|
1834 | - } |
|
1835 | - $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
1644 | + return EEH_Template::display_template($template, $template_args, true); |
|
1645 | + } |
|
1646 | + |
|
1647 | + |
|
1648 | + public function registration_options_meta_box() |
|
1649 | + { |
|
1650 | + $yes_no_values = array( |
|
1651 | + array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
1652 | + array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
1653 | + ); |
|
1654 | + $default_reg_status_values = EEM_Registration::reg_status_array( |
|
1655 | + array( |
|
1656 | + EEM_Registration::status_id_cancelled, |
|
1657 | + EEM_Registration::status_id_declined, |
|
1658 | + EEM_Registration::status_id_incomplete, |
|
1659 | + ), |
|
1660 | + true |
|
1661 | + ); |
|
1662 | + //$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active()); |
|
1663 | + $template_args['_event'] = $this->_cpt_model_obj; |
|
1664 | + $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
1665 | + $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
1666 | + $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
1667 | + 'default_reg_status', |
|
1668 | + $default_reg_status_values, |
|
1669 | + $this->_cpt_model_obj->default_registration_status() |
|
1670 | + ); |
|
1671 | + $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
1672 | + 'display_desc', |
|
1673 | + $yes_no_values, |
|
1674 | + $this->_cpt_model_obj->display_description() |
|
1675 | + ); |
|
1676 | + $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
1677 | + 'display_ticket_selector', |
|
1678 | + $yes_no_values, |
|
1679 | + $this->_cpt_model_obj->display_ticket_selector(), |
|
1680 | + '', |
|
1681 | + '', |
|
1682 | + false |
|
1683 | + ); |
|
1684 | + $template_args['additional_registration_options'] = apply_filters( |
|
1685 | + 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
1686 | + '', |
|
1687 | + $template_args, |
|
1688 | + $yes_no_values, |
|
1689 | + $default_reg_status_values |
|
1690 | + ); |
|
1691 | + EEH_Template::display_template( |
|
1692 | + EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
1693 | + $template_args |
|
1694 | + ); |
|
1695 | + } |
|
1696 | + |
|
1697 | + |
|
1698 | + /** |
|
1699 | + * _get_events() |
|
1700 | + * This method simply returns all the events (for the given _view and paging) |
|
1701 | + * |
|
1702 | + * @access public |
|
1703 | + * |
|
1704 | + * @param int $per_page count of items per page (20 default); |
|
1705 | + * @param int $current_page what is the current page being viewed. |
|
1706 | + * @param bool $count if TRUE then we just return a count of ALL events matching the given _view. |
|
1707 | + * If FALSE then we return an array of event objects |
|
1708 | + * that match the given _view and paging parameters. |
|
1709 | + * |
|
1710 | + * @return array an array of event objects. |
|
1711 | + */ |
|
1712 | + public function get_events($per_page = 10, $current_page = 1, $count = false) |
|
1713 | + { |
|
1714 | + $EEME = $this->_event_model(); |
|
1715 | + $offset = ($current_page - 1) * $per_page; |
|
1716 | + $limit = $count ? null : $offset . ',' . $per_page; |
|
1717 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
|
1718 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
|
1719 | + if (isset($this->_req_data['month_range'])) { |
|
1720 | + $pieces = explode(' ', $this->_req_data['month_range'], 3); |
|
1721 | + $month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1722 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1723 | + } |
|
1724 | + $where = array(); |
|
1725 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
1726 | + //determine what post_status our condition will have for the query. |
|
1727 | + switch ($status) { |
|
1728 | + case 'month' : |
|
1729 | + case 'today' : |
|
1730 | + case null : |
|
1731 | + case 'all' : |
|
1732 | + break; |
|
1733 | + case 'draft' : |
|
1734 | + $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
1735 | + break; |
|
1736 | + default : |
|
1737 | + $where['status'] = $status; |
|
1738 | + } |
|
1739 | + //categories? |
|
1740 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
1741 | + ? $this->_req_data['EVT_CAT'] : null; |
|
1742 | + if ( ! empty ($category)) { |
|
1743 | + $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1744 | + $where['Term_Taxonomy.term_id'] = $category; |
|
1745 | + } |
|
1746 | + //date where conditions |
|
1747 | + $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
1748 | + if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
|
1749 | + $DateTime = new DateTime( |
|
1750 | + $year_r . '-' . $month_r . '-01 00:00:00', |
|
1751 | + new DateTimeZone(EEM_Datetime::instance()->get_timezone()) |
|
1752 | + ); |
|
1753 | + $start = $DateTime->format(implode(' ', $start_formats)); |
|
1754 | + $end = $DateTime->setDate($year_r, $month_r, |
|
1755 | + $DateTime->format('t'))->setTime(23, 59, 59)->format( |
|
1756 | + implode(' ', $start_formats) |
|
1757 | + ); |
|
1758 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1759 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
|
1760 | + $DateTime = new DateTime('now', |
|
1761 | + new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1762 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1763 | + $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1764 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1765 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
1766 | + $now = date('Y-m-01'); |
|
1767 | + $DateTime = new DateTime($now, |
|
1768 | + new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1769 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1770 | + $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t')) |
|
1771 | + ->setTime(23, 59, 59) |
|
1772 | + ->format(implode(' ', $start_formats)); |
|
1773 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1774 | + } |
|
1775 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1776 | + $where['EVT_wp_user'] = get_current_user_id(); |
|
1777 | + } else { |
|
1778 | + if ( ! isset($where['status'])) { |
|
1779 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
1780 | + $where['OR'] = array( |
|
1781 | + 'status*restrict_private' => array('!=', 'private'), |
|
1782 | + 'AND' => array( |
|
1783 | + 'status*inclusive' => array('=', 'private'), |
|
1784 | + 'EVT_wp_user' => get_current_user_id(), |
|
1785 | + ), |
|
1786 | + ); |
|
1787 | + } |
|
1788 | + } |
|
1789 | + } |
|
1790 | + if (isset($this->_req_data['EVT_wp_user'])) { |
|
1791 | + if ($this->_req_data['EVT_wp_user'] != get_current_user_id() |
|
1792 | + && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events') |
|
1793 | + ) { |
|
1794 | + $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
|
1795 | + } |
|
1796 | + } |
|
1797 | + //search query handling |
|
1798 | + if (isset($this->_req_data['s'])) { |
|
1799 | + $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1800 | + $where['OR'] = array( |
|
1801 | + 'EVT_name' => array('LIKE', $search_string), |
|
1802 | + 'EVT_desc' => array('LIKE', $search_string), |
|
1803 | + 'EVT_short_desc' => array('LIKE', $search_string), |
|
1804 | + ); |
|
1805 | + } |
|
1806 | + $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
1807 | + $query_params = apply_filters( |
|
1808 | + 'FHEE__Events_Admin_Page__get_events__query_params', |
|
1809 | + array( |
|
1810 | + $where, |
|
1811 | + 'limit' => $limit, |
|
1812 | + 'order_by' => $orderby, |
|
1813 | + 'order' => $order, |
|
1814 | + 'group_by' => 'EVT_ID', |
|
1815 | + ), |
|
1816 | + $this->_req_data |
|
1817 | + ); |
|
1818 | + //let's first check if we have special requests coming in. |
|
1819 | + if (isset($this->_req_data['active_status'])) { |
|
1820 | + switch ($this->_req_data['active_status']) { |
|
1821 | + case 'upcoming' : |
|
1822 | + return $EEME->get_upcoming_events($query_params, $count); |
|
1823 | + break; |
|
1824 | + case 'expired' : |
|
1825 | + return $EEME->get_expired_events($query_params, $count); |
|
1826 | + break; |
|
1827 | + case 'active' : |
|
1828 | + return $EEME->get_active_events($query_params, $count); |
|
1829 | + break; |
|
1830 | + case 'inactive' : |
|
1831 | + return $EEME->get_inactive_events($query_params, $count); |
|
1832 | + break; |
|
1833 | + } |
|
1834 | + } |
|
1835 | + $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
1836 | 1836 | |
1837 | - return $events; |
|
1838 | - } |
|
1839 | - |
|
1840 | - |
|
1841 | - /** |
|
1842 | - * handling for WordPress CPT actions (trash, restore, delete) |
|
1843 | - * |
|
1844 | - * @param string $post_id |
|
1845 | - */ |
|
1846 | - public function trash_cpt_item($post_id) |
|
1847 | - { |
|
1848 | - $this->_req_data['EVT_ID'] = $post_id; |
|
1849 | - $this->_trash_or_restore_event('trash', false); |
|
1850 | - } |
|
1851 | - |
|
1852 | - |
|
1853 | - /** |
|
1854 | - * @param string $post_id |
|
1855 | - */ |
|
1856 | - public function restore_cpt_item($post_id) |
|
1857 | - { |
|
1858 | - $this->_req_data['EVT_ID'] = $post_id; |
|
1859 | - $this->_trash_or_restore_event('draft', false); |
|
1860 | - } |
|
1861 | - |
|
1862 | - |
|
1863 | - /** |
|
1864 | - * @param string $post_id |
|
1865 | - */ |
|
1866 | - public function delete_cpt_item($post_id) |
|
1867 | - { |
|
1868 | - $this->_req_data['EVT_ID'] = $post_id; |
|
1869 | - $this->_delete_event(false); |
|
1870 | - } |
|
1871 | - |
|
1872 | - |
|
1873 | - /** |
|
1874 | - * _trash_or_restore_event |
|
1875 | - * |
|
1876 | - * @access protected |
|
1877 | - * |
|
1878 | - * @param string $event_status |
|
1879 | - * @param bool $redirect_after |
|
1880 | - */ |
|
1881 | - protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true) |
|
1882 | - { |
|
1883 | - //determine the event id and set to array. |
|
1884 | - $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false; |
|
1885 | - // loop thru events |
|
1886 | - if ($EVT_ID) { |
|
1887 | - // clean status |
|
1888 | - $event_status = sanitize_key($event_status); |
|
1889 | - // grab status |
|
1890 | - if ( ! empty($event_status)) { |
|
1891 | - $success = $this->_change_event_status($EVT_ID, $event_status); |
|
1892 | - } else { |
|
1893 | - $success = false; |
|
1894 | - $msg = esc_html__( |
|
1895 | - 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
1896 | - 'event_espresso' |
|
1897 | - ); |
|
1898 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1899 | - } |
|
1900 | - } else { |
|
1901 | - $success = false; |
|
1902 | - $msg = esc_html__( |
|
1903 | - 'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.', |
|
1904 | - 'event_espresso' |
|
1905 | - ); |
|
1906 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1907 | - } |
|
1908 | - $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
1909 | - if ($redirect_after) { |
|
1910 | - $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
|
1911 | - } |
|
1912 | - } |
|
1913 | - |
|
1914 | - |
|
1915 | - /** |
|
1916 | - * _trash_or_restore_events |
|
1917 | - * |
|
1918 | - * @access protected |
|
1919 | - * |
|
1920 | - * @param string $event_status |
|
1921 | - * |
|
1922 | - * @return void |
|
1923 | - */ |
|
1924 | - protected function _trash_or_restore_events($event_status = 'trash') |
|
1925 | - { |
|
1926 | - // clean status |
|
1927 | - $event_status = sanitize_key($event_status); |
|
1928 | - // grab status |
|
1929 | - if ( ! empty($event_status)) { |
|
1930 | - $success = true; |
|
1931 | - //determine the event id and set to array. |
|
1932 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
1933 | - // loop thru events |
|
1934 | - foreach ($EVT_IDs as $EVT_ID) { |
|
1935 | - if ($EVT_ID = absint($EVT_ID)) { |
|
1936 | - $results = $this->_change_event_status($EVT_ID, $event_status); |
|
1937 | - $success = $results !== false ? $success : false; |
|
1938 | - } else { |
|
1939 | - $msg = sprintf( |
|
1940 | - esc_html__( |
|
1941 | - 'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.', |
|
1942 | - 'event_espresso' |
|
1943 | - ), |
|
1944 | - $EVT_ID |
|
1945 | - ); |
|
1946 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1947 | - $success = false; |
|
1948 | - } |
|
1949 | - } |
|
1950 | - } else { |
|
1951 | - $success = false; |
|
1952 | - $msg = esc_html__( |
|
1953 | - 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
1954 | - 'event_espresso' |
|
1955 | - ); |
|
1956 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1957 | - } |
|
1958 | - // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
1959 | - $success = $success ? 2 : false; |
|
1960 | - $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
1961 | - $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default')); |
|
1962 | - } |
|
1963 | - |
|
1964 | - |
|
1965 | - /** |
|
1966 | - * _trash_or_restore_events |
|
1967 | - * |
|
1968 | - * @access private |
|
1969 | - * |
|
1970 | - * @param int $EVT_ID |
|
1971 | - * @param string $event_status |
|
1972 | - * |
|
1973 | - * @return bool |
|
1974 | - */ |
|
1975 | - private function _change_event_status($EVT_ID = 0, $event_status = '') |
|
1976 | - { |
|
1977 | - // grab event id |
|
1978 | - if ( ! $EVT_ID) { |
|
1979 | - $msg = esc_html__( |
|
1980 | - 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
1981 | - 'event_espresso' |
|
1982 | - ); |
|
1983 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1837 | + return $events; |
|
1838 | + } |
|
1839 | + |
|
1840 | + |
|
1841 | + /** |
|
1842 | + * handling for WordPress CPT actions (trash, restore, delete) |
|
1843 | + * |
|
1844 | + * @param string $post_id |
|
1845 | + */ |
|
1846 | + public function trash_cpt_item($post_id) |
|
1847 | + { |
|
1848 | + $this->_req_data['EVT_ID'] = $post_id; |
|
1849 | + $this->_trash_or_restore_event('trash', false); |
|
1850 | + } |
|
1851 | + |
|
1852 | + |
|
1853 | + /** |
|
1854 | + * @param string $post_id |
|
1855 | + */ |
|
1856 | + public function restore_cpt_item($post_id) |
|
1857 | + { |
|
1858 | + $this->_req_data['EVT_ID'] = $post_id; |
|
1859 | + $this->_trash_or_restore_event('draft', false); |
|
1860 | + } |
|
1861 | + |
|
1862 | + |
|
1863 | + /** |
|
1864 | + * @param string $post_id |
|
1865 | + */ |
|
1866 | + public function delete_cpt_item($post_id) |
|
1867 | + { |
|
1868 | + $this->_req_data['EVT_ID'] = $post_id; |
|
1869 | + $this->_delete_event(false); |
|
1870 | + } |
|
1871 | + |
|
1872 | + |
|
1873 | + /** |
|
1874 | + * _trash_or_restore_event |
|
1875 | + * |
|
1876 | + * @access protected |
|
1877 | + * |
|
1878 | + * @param string $event_status |
|
1879 | + * @param bool $redirect_after |
|
1880 | + */ |
|
1881 | + protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true) |
|
1882 | + { |
|
1883 | + //determine the event id and set to array. |
|
1884 | + $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false; |
|
1885 | + // loop thru events |
|
1886 | + if ($EVT_ID) { |
|
1887 | + // clean status |
|
1888 | + $event_status = sanitize_key($event_status); |
|
1889 | + // grab status |
|
1890 | + if ( ! empty($event_status)) { |
|
1891 | + $success = $this->_change_event_status($EVT_ID, $event_status); |
|
1892 | + } else { |
|
1893 | + $success = false; |
|
1894 | + $msg = esc_html__( |
|
1895 | + 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
1896 | + 'event_espresso' |
|
1897 | + ); |
|
1898 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1899 | + } |
|
1900 | + } else { |
|
1901 | + $success = false; |
|
1902 | + $msg = esc_html__( |
|
1903 | + 'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.', |
|
1904 | + 'event_espresso' |
|
1905 | + ); |
|
1906 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1907 | + } |
|
1908 | + $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
1909 | + if ($redirect_after) { |
|
1910 | + $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
|
1911 | + } |
|
1912 | + } |
|
1913 | + |
|
1914 | + |
|
1915 | + /** |
|
1916 | + * _trash_or_restore_events |
|
1917 | + * |
|
1918 | + * @access protected |
|
1919 | + * |
|
1920 | + * @param string $event_status |
|
1921 | + * |
|
1922 | + * @return void |
|
1923 | + */ |
|
1924 | + protected function _trash_or_restore_events($event_status = 'trash') |
|
1925 | + { |
|
1926 | + // clean status |
|
1927 | + $event_status = sanitize_key($event_status); |
|
1928 | + // grab status |
|
1929 | + if ( ! empty($event_status)) { |
|
1930 | + $success = true; |
|
1931 | + //determine the event id and set to array. |
|
1932 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
1933 | + // loop thru events |
|
1934 | + foreach ($EVT_IDs as $EVT_ID) { |
|
1935 | + if ($EVT_ID = absint($EVT_ID)) { |
|
1936 | + $results = $this->_change_event_status($EVT_ID, $event_status); |
|
1937 | + $success = $results !== false ? $success : false; |
|
1938 | + } else { |
|
1939 | + $msg = sprintf( |
|
1940 | + esc_html__( |
|
1941 | + 'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.', |
|
1942 | + 'event_espresso' |
|
1943 | + ), |
|
1944 | + $EVT_ID |
|
1945 | + ); |
|
1946 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1947 | + $success = false; |
|
1948 | + } |
|
1949 | + } |
|
1950 | + } else { |
|
1951 | + $success = false; |
|
1952 | + $msg = esc_html__( |
|
1953 | + 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
1954 | + 'event_espresso' |
|
1955 | + ); |
|
1956 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1957 | + } |
|
1958 | + // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
1959 | + $success = $success ? 2 : false; |
|
1960 | + $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
1961 | + $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default')); |
|
1962 | + } |
|
1963 | + |
|
1964 | + |
|
1965 | + /** |
|
1966 | + * _trash_or_restore_events |
|
1967 | + * |
|
1968 | + * @access private |
|
1969 | + * |
|
1970 | + * @param int $EVT_ID |
|
1971 | + * @param string $event_status |
|
1972 | + * |
|
1973 | + * @return bool |
|
1974 | + */ |
|
1975 | + private function _change_event_status($EVT_ID = 0, $event_status = '') |
|
1976 | + { |
|
1977 | + // grab event id |
|
1978 | + if ( ! $EVT_ID) { |
|
1979 | + $msg = esc_html__( |
|
1980 | + 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
1981 | + 'event_espresso' |
|
1982 | + ); |
|
1983 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1984 | 1984 | |
1985 | - return false; |
|
1986 | - } |
|
1987 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1988 | - // clean status |
|
1989 | - $event_status = sanitize_key($event_status); |
|
1990 | - // grab status |
|
1991 | - if (empty($event_status)) { |
|
1992 | - $msg = esc_html__( |
|
1993 | - 'An error occurred. No Event Status or an invalid Event Status was received.', |
|
1994 | - 'event_espresso' |
|
1995 | - ); |
|
1996 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1985 | + return false; |
|
1986 | + } |
|
1987 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1988 | + // clean status |
|
1989 | + $event_status = sanitize_key($event_status); |
|
1990 | + // grab status |
|
1991 | + if (empty($event_status)) { |
|
1992 | + $msg = esc_html__( |
|
1993 | + 'An error occurred. No Event Status or an invalid Event Status was received.', |
|
1994 | + 'event_espresso' |
|
1995 | + ); |
|
1996 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1997 | 1997 | |
1998 | - return false; |
|
1999 | - } |
|
2000 | - // was event trashed or restored ? |
|
2001 | - switch ($event_status) { |
|
2002 | - case 'draft' : |
|
2003 | - $action = 'restored from the trash'; |
|
2004 | - $hook = 'AHEE_event_restored_from_trash'; |
|
2005 | - break; |
|
2006 | - case 'trash' : |
|
2007 | - $action = 'moved to the trash'; |
|
2008 | - $hook = 'AHEE_event_moved_to_trash'; |
|
2009 | - break; |
|
2010 | - default : |
|
2011 | - $action = 'updated'; |
|
2012 | - $hook = false; |
|
2013 | - } |
|
2014 | - //use class to change status |
|
2015 | - $this->_cpt_model_obj->set_status($event_status); |
|
2016 | - $success = $this->_cpt_model_obj->save(); |
|
2017 | - if ($success === false) { |
|
2018 | - $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
|
2019 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1998 | + return false; |
|
1999 | + } |
|
2000 | + // was event trashed or restored ? |
|
2001 | + switch ($event_status) { |
|
2002 | + case 'draft' : |
|
2003 | + $action = 'restored from the trash'; |
|
2004 | + $hook = 'AHEE_event_restored_from_trash'; |
|
2005 | + break; |
|
2006 | + case 'trash' : |
|
2007 | + $action = 'moved to the trash'; |
|
2008 | + $hook = 'AHEE_event_moved_to_trash'; |
|
2009 | + break; |
|
2010 | + default : |
|
2011 | + $action = 'updated'; |
|
2012 | + $hook = false; |
|
2013 | + } |
|
2014 | + //use class to change status |
|
2015 | + $this->_cpt_model_obj->set_status($event_status); |
|
2016 | + $success = $this->_cpt_model_obj->save(); |
|
2017 | + if ($success === false) { |
|
2018 | + $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
|
2019 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2020 | 2020 | |
2021 | - return false; |
|
2022 | - } |
|
2023 | - if ($hook) { |
|
2024 | - do_action($hook); |
|
2025 | - } |
|
2021 | + return false; |
|
2022 | + } |
|
2023 | + if ($hook) { |
|
2024 | + do_action($hook); |
|
2025 | + } |
|
2026 | 2026 | |
2027 | - return true; |
|
2028 | - } |
|
2029 | - |
|
2030 | - |
|
2031 | - /** |
|
2032 | - * _delete_event |
|
2033 | - * |
|
2034 | - * @access protected |
|
2035 | - * |
|
2036 | - * @param bool $redirect_after |
|
2037 | - */ |
|
2038 | - protected function _delete_event($redirect_after = true) |
|
2039 | - { |
|
2040 | - //determine the event id and set to array. |
|
2041 | - $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null; |
|
2042 | - $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
2043 | - // loop thru events |
|
2044 | - if ($EVT_ID) { |
|
2045 | - $success = $this->_permanently_delete_event($EVT_ID); |
|
2046 | - // get list of events with no prices |
|
2047 | - $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
2048 | - // remove this event from the list of events with no prices |
|
2049 | - if (isset($espresso_no_ticket_prices[$EVT_ID])) { |
|
2050 | - unset($espresso_no_ticket_prices[$EVT_ID]); |
|
2051 | - } |
|
2052 | - update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
2053 | - } else { |
|
2054 | - $success = false; |
|
2055 | - $msg = esc_html__( |
|
2056 | - 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
2057 | - 'event_espresso' |
|
2058 | - ); |
|
2059 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2060 | - } |
|
2061 | - if ($redirect_after) { |
|
2062 | - $this->_redirect_after_action( |
|
2063 | - $success, |
|
2064 | - 'Event', |
|
2065 | - 'deleted', |
|
2066 | - array('action' => 'default', 'status' => 'trash') |
|
2067 | - ); |
|
2068 | - } |
|
2069 | - } |
|
2070 | - |
|
2071 | - |
|
2072 | - /** |
|
2073 | - * _delete_events |
|
2074 | - * |
|
2075 | - * @access protected |
|
2076 | - * @return void |
|
2077 | - */ |
|
2078 | - protected function _delete_events() |
|
2079 | - { |
|
2080 | - $success = true; |
|
2081 | - // get list of events with no prices |
|
2082 | - $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
2083 | - //determine the event id and set to array. |
|
2084 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
2085 | - // loop thru events |
|
2086 | - foreach ($EVT_IDs as $EVT_ID) { |
|
2087 | - $EVT_ID = absint($EVT_ID); |
|
2088 | - if ($EVT_ID) { |
|
2089 | - $results = $this->_permanently_delete_event($EVT_ID); |
|
2090 | - $success = $results !== false ? $success : false; |
|
2091 | - // remove this event from the list of events with no prices |
|
2092 | - unset($espresso_no_ticket_prices[$EVT_ID]); |
|
2093 | - } else { |
|
2094 | - $success = false; |
|
2095 | - $msg = esc_html__( |
|
2096 | - 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
2097 | - 'event_espresso' |
|
2098 | - ); |
|
2099 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2100 | - } |
|
2101 | - } |
|
2102 | - update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
2103 | - // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
2104 | - $success = $success ? 2 : false; |
|
2105 | - $this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default')); |
|
2106 | - } |
|
2107 | - |
|
2108 | - |
|
2109 | - /** |
|
2110 | - * _permanently_delete_event |
|
2111 | - * |
|
2112 | - * @access private |
|
2113 | - * |
|
2114 | - * @param int $EVT_ID |
|
2115 | - * |
|
2116 | - * @return bool |
|
2117 | - */ |
|
2118 | - private function _permanently_delete_event($EVT_ID = 0) |
|
2119 | - { |
|
2120 | - // grab event id |
|
2121 | - if ( ! $EVT_ID) { |
|
2122 | - $msg = esc_html__( |
|
2123 | - 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
2124 | - 'event_espresso' |
|
2125 | - ); |
|
2126 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2027 | + return true; |
|
2028 | + } |
|
2029 | + |
|
2030 | + |
|
2031 | + /** |
|
2032 | + * _delete_event |
|
2033 | + * |
|
2034 | + * @access protected |
|
2035 | + * |
|
2036 | + * @param bool $redirect_after |
|
2037 | + */ |
|
2038 | + protected function _delete_event($redirect_after = true) |
|
2039 | + { |
|
2040 | + //determine the event id and set to array. |
|
2041 | + $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null; |
|
2042 | + $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
2043 | + // loop thru events |
|
2044 | + if ($EVT_ID) { |
|
2045 | + $success = $this->_permanently_delete_event($EVT_ID); |
|
2046 | + // get list of events with no prices |
|
2047 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
2048 | + // remove this event from the list of events with no prices |
|
2049 | + if (isset($espresso_no_ticket_prices[$EVT_ID])) { |
|
2050 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
2051 | + } |
|
2052 | + update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
2053 | + } else { |
|
2054 | + $success = false; |
|
2055 | + $msg = esc_html__( |
|
2056 | + 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
2057 | + 'event_espresso' |
|
2058 | + ); |
|
2059 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2060 | + } |
|
2061 | + if ($redirect_after) { |
|
2062 | + $this->_redirect_after_action( |
|
2063 | + $success, |
|
2064 | + 'Event', |
|
2065 | + 'deleted', |
|
2066 | + array('action' => 'default', 'status' => 'trash') |
|
2067 | + ); |
|
2068 | + } |
|
2069 | + } |
|
2070 | + |
|
2071 | + |
|
2072 | + /** |
|
2073 | + * _delete_events |
|
2074 | + * |
|
2075 | + * @access protected |
|
2076 | + * @return void |
|
2077 | + */ |
|
2078 | + protected function _delete_events() |
|
2079 | + { |
|
2080 | + $success = true; |
|
2081 | + // get list of events with no prices |
|
2082 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
2083 | + //determine the event id and set to array. |
|
2084 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
2085 | + // loop thru events |
|
2086 | + foreach ($EVT_IDs as $EVT_ID) { |
|
2087 | + $EVT_ID = absint($EVT_ID); |
|
2088 | + if ($EVT_ID) { |
|
2089 | + $results = $this->_permanently_delete_event($EVT_ID); |
|
2090 | + $success = $results !== false ? $success : false; |
|
2091 | + // remove this event from the list of events with no prices |
|
2092 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
2093 | + } else { |
|
2094 | + $success = false; |
|
2095 | + $msg = esc_html__( |
|
2096 | + 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
2097 | + 'event_espresso' |
|
2098 | + ); |
|
2099 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2100 | + } |
|
2101 | + } |
|
2102 | + update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
2103 | + // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
2104 | + $success = $success ? 2 : false; |
|
2105 | + $this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default')); |
|
2106 | + } |
|
2107 | + |
|
2108 | + |
|
2109 | + /** |
|
2110 | + * _permanently_delete_event |
|
2111 | + * |
|
2112 | + * @access private |
|
2113 | + * |
|
2114 | + * @param int $EVT_ID |
|
2115 | + * |
|
2116 | + * @return bool |
|
2117 | + */ |
|
2118 | + private function _permanently_delete_event($EVT_ID = 0) |
|
2119 | + { |
|
2120 | + // grab event id |
|
2121 | + if ( ! $EVT_ID) { |
|
2122 | + $msg = esc_html__( |
|
2123 | + 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
2124 | + 'event_espresso' |
|
2125 | + ); |
|
2126 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2127 | 2127 | |
2128 | - return false; |
|
2129 | - } |
|
2130 | - if ( |
|
2131 | - ! $this->_cpt_model_obj instanceof EE_Event |
|
2132 | - || $this->_cpt_model_obj->ID() !== $EVT_ID |
|
2133 | - ) { |
|
2134 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
2135 | - } |
|
2136 | - if ( ! $this->_cpt_model_obj instanceof EE_Event) { |
|
2137 | - return false; |
|
2138 | - } |
|
2139 | - //need to delete related tickets and prices first. |
|
2140 | - $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
|
2141 | - foreach ($datetimes as $datetime) { |
|
2142 | - $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
|
2143 | - $tickets = $datetime->get_many_related('Ticket'); |
|
2144 | - foreach ($tickets as $ticket) { |
|
2145 | - $ticket->_remove_relation_to($datetime, 'Datetime'); |
|
2146 | - $ticket->delete_related_permanently('Price'); |
|
2147 | - $ticket->delete_permanently(); |
|
2148 | - } |
|
2149 | - $datetime->delete(); |
|
2150 | - } |
|
2151 | - //what about related venues or terms? |
|
2152 | - $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
|
2153 | - foreach ($venues as $venue) { |
|
2154 | - $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
|
2155 | - } |
|
2156 | - //any attached question groups? |
|
2157 | - $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
|
2158 | - if ( ! empty($question_groups)) { |
|
2159 | - foreach ($question_groups as $question_group) { |
|
2160 | - $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
|
2161 | - } |
|
2162 | - } |
|
2163 | - //Message Template Groups |
|
2164 | - $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
2165 | - /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
|
2166 | - $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
|
2167 | - foreach ($term_taxonomies as $term_taxonomy) { |
|
2168 | - $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
|
2169 | - } |
|
2170 | - $success = $this->_cpt_model_obj->delete_permanently(); |
|
2171 | - // did it all go as planned ? |
|
2172 | - if ($success) { |
|
2173 | - $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID); |
|
2174 | - EE_Error::add_success($msg); |
|
2175 | - } else { |
|
2176 | - $msg = sprintf( |
|
2177 | - esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'), |
|
2178 | - $EVT_ID |
|
2179 | - ); |
|
2180 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2128 | + return false; |
|
2129 | + } |
|
2130 | + if ( |
|
2131 | + ! $this->_cpt_model_obj instanceof EE_Event |
|
2132 | + || $this->_cpt_model_obj->ID() !== $EVT_ID |
|
2133 | + ) { |
|
2134 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
2135 | + } |
|
2136 | + if ( ! $this->_cpt_model_obj instanceof EE_Event) { |
|
2137 | + return false; |
|
2138 | + } |
|
2139 | + //need to delete related tickets and prices first. |
|
2140 | + $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
|
2141 | + foreach ($datetimes as $datetime) { |
|
2142 | + $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
|
2143 | + $tickets = $datetime->get_many_related('Ticket'); |
|
2144 | + foreach ($tickets as $ticket) { |
|
2145 | + $ticket->_remove_relation_to($datetime, 'Datetime'); |
|
2146 | + $ticket->delete_related_permanently('Price'); |
|
2147 | + $ticket->delete_permanently(); |
|
2148 | + } |
|
2149 | + $datetime->delete(); |
|
2150 | + } |
|
2151 | + //what about related venues or terms? |
|
2152 | + $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
|
2153 | + foreach ($venues as $venue) { |
|
2154 | + $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
|
2155 | + } |
|
2156 | + //any attached question groups? |
|
2157 | + $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
|
2158 | + if ( ! empty($question_groups)) { |
|
2159 | + foreach ($question_groups as $question_group) { |
|
2160 | + $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
|
2161 | + } |
|
2162 | + } |
|
2163 | + //Message Template Groups |
|
2164 | + $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
2165 | + /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
|
2166 | + $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
|
2167 | + foreach ($term_taxonomies as $term_taxonomy) { |
|
2168 | + $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
|
2169 | + } |
|
2170 | + $success = $this->_cpt_model_obj->delete_permanently(); |
|
2171 | + // did it all go as planned ? |
|
2172 | + if ($success) { |
|
2173 | + $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID); |
|
2174 | + EE_Error::add_success($msg); |
|
2175 | + } else { |
|
2176 | + $msg = sprintf( |
|
2177 | + esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'), |
|
2178 | + $EVT_ID |
|
2179 | + ); |
|
2180 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2181 | 2181 | |
2182 | - return false; |
|
2183 | - } |
|
2184 | - do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); |
|
2182 | + return false; |
|
2183 | + } |
|
2184 | + do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); |
|
2185 | 2185 | |
2186 | - return true; |
|
2187 | - } |
|
2188 | - |
|
2189 | - |
|
2190 | - /** |
|
2191 | - * get total number of events |
|
2192 | - * |
|
2193 | - * @access public |
|
2194 | - * @return int |
|
2195 | - */ |
|
2196 | - public function total_events() |
|
2197 | - { |
|
2198 | - $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
2186 | + return true; |
|
2187 | + } |
|
2188 | + |
|
2189 | + |
|
2190 | + /** |
|
2191 | + * get total number of events |
|
2192 | + * |
|
2193 | + * @access public |
|
2194 | + * @return int |
|
2195 | + */ |
|
2196 | + public function total_events() |
|
2197 | + { |
|
2198 | + $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
2199 | 2199 | |
2200 | - return $count; |
|
2201 | - } |
|
2202 | - |
|
2203 | - |
|
2204 | - /** |
|
2205 | - * get total number of draft events |
|
2206 | - * |
|
2207 | - * @access public |
|
2208 | - * @return int |
|
2209 | - */ |
|
2210 | - public function total_events_draft() |
|
2211 | - { |
|
2212 | - $where = array( |
|
2213 | - 'status' => array('IN', array('draft', 'auto-draft')), |
|
2214 | - ); |
|
2215 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2200 | + return $count; |
|
2201 | + } |
|
2202 | + |
|
2203 | + |
|
2204 | + /** |
|
2205 | + * get total number of draft events |
|
2206 | + * |
|
2207 | + * @access public |
|
2208 | + * @return int |
|
2209 | + */ |
|
2210 | + public function total_events_draft() |
|
2211 | + { |
|
2212 | + $where = array( |
|
2213 | + 'status' => array('IN', array('draft', 'auto-draft')), |
|
2214 | + ); |
|
2215 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2216 | 2216 | |
2217 | - return $count; |
|
2218 | - } |
|
2219 | - |
|
2220 | - |
|
2221 | - /** |
|
2222 | - * get total number of trashed events |
|
2223 | - * |
|
2224 | - * @access public |
|
2225 | - * @return int |
|
2226 | - */ |
|
2227 | - public function total_trashed_events() |
|
2228 | - { |
|
2229 | - $where = array( |
|
2230 | - 'status' => 'trash', |
|
2231 | - ); |
|
2232 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2217 | + return $count; |
|
2218 | + } |
|
2219 | + |
|
2220 | + |
|
2221 | + /** |
|
2222 | + * get total number of trashed events |
|
2223 | + * |
|
2224 | + * @access public |
|
2225 | + * @return int |
|
2226 | + */ |
|
2227 | + public function total_trashed_events() |
|
2228 | + { |
|
2229 | + $where = array( |
|
2230 | + 'status' => 'trash', |
|
2231 | + ); |
|
2232 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2233 | 2233 | |
2234 | - return $count; |
|
2235 | - } |
|
2236 | - |
|
2237 | - |
|
2238 | - /** |
|
2239 | - * _default_event_settings |
|
2240 | - * This generates the Default Settings Tab |
|
2241 | - * |
|
2242 | - * @return void |
|
2243 | - */ |
|
2244 | - protected function _default_event_settings() |
|
2245 | - { |
|
2246 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
2247 | - $this->_template_args['reg_status_array'] = EEM_Registration::reg_status_array( |
|
2248 | - // exclude array |
|
2249 | - array( |
|
2250 | - EEM_Registration::status_id_cancelled, |
|
2251 | - EEM_Registration::status_id_declined, |
|
2252 | - EEM_Registration::status_id_incomplete, |
|
2253 | - EEM_Registration::status_id_wait_list, |
|
2254 | - ), |
|
2255 | - // translated |
|
2256 | - true |
|
2257 | - ); |
|
2258 | - $this->_template_args['default_reg_status'] = isset( |
|
2259 | - EE_Registry::instance()->CFG->registration->default_STS_ID |
|
2260 | - ) && in_array( |
|
2261 | - EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
2262 | - $this->_template_args['reg_status_array'] |
|
2263 | - ) |
|
2264 | - ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) |
|
2265 | - : EEM_Registration::status_id_pending_payment; |
|
2266 | - $this->_set_add_edit_form_tags('update_default_event_settings'); |
|
2267 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
2268 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
2269 | - EVENTS_TEMPLATE_PATH . 'event_settings.template.php', |
|
2270 | - $this->_template_args, |
|
2271 | - true |
|
2272 | - ); |
|
2273 | - $this->display_admin_page_with_sidebar(); |
|
2274 | - } |
|
2275 | - |
|
2276 | - |
|
2277 | - /** |
|
2278 | - * _update_default_event_settings |
|
2279 | - * |
|
2280 | - * @access protected |
|
2281 | - * @return void |
|
2282 | - */ |
|
2283 | - protected function _update_default_event_settings() |
|
2284 | - { |
|
2285 | - EE_Config::instance()->registration->default_STS_ID = isset($this->_req_data['default_reg_status']) |
|
2286 | - ? sanitize_text_field($this->_req_data['default_reg_status']) |
|
2287 | - : EEM_Registration::status_id_pending_payment; |
|
2288 | - $what = 'Default Event Settings'; |
|
2289 | - $success = $this->_update_espresso_configuration( |
|
2290 | - $what, |
|
2291 | - EE_Config::instance(), |
|
2292 | - __FILE__, |
|
2293 | - __FUNCTION__, |
|
2294 | - __LINE__ |
|
2295 | - ); |
|
2296 | - $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default_event_settings')); |
|
2297 | - } |
|
2298 | - |
|
2299 | - |
|
2300 | - /************* Templates *************/ |
|
2301 | - |
|
2302 | - |
|
2303 | - protected function _template_settings() |
|
2304 | - { |
|
2305 | - $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso'); |
|
2306 | - $this->_template_args['preview_img'] = '<img src="' |
|
2307 | - . EVENTS_ASSETS_URL |
|
2308 | - . DS |
|
2309 | - . 'images' |
|
2310 | - . DS |
|
2311 | - . 'caffeinated_template_features.jpg" alt="' |
|
2312 | - . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
|
2313 | - . '" />'; |
|
2314 | - $this->_template_args['preview_text'] = '<strong>' . esc_html__( |
|
2315 | - 'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', |
|
2316 | - 'event_espresso' |
|
2317 | - ) . '</strong>'; |
|
2318 | - $this->display_admin_caf_preview_page('template_settings_tab'); |
|
2319 | - } |
|
2320 | - |
|
2321 | - |
|
2322 | - /** Event Category Stuff **/ |
|
2323 | - /** |
|
2324 | - * set the _category property with the category object for the loaded page. |
|
2325 | - * |
|
2326 | - * @access private |
|
2327 | - * @return void |
|
2328 | - */ |
|
2329 | - private function _set_category_object() |
|
2330 | - { |
|
2331 | - if (isset($this->_category->id) && ! empty($this->_category->id)) { |
|
2332 | - return; |
|
2333 | - } //already have the category object so get out. |
|
2334 | - //set default category object |
|
2335 | - $this->_set_empty_category_object(); |
|
2336 | - //only set if we've got an id |
|
2337 | - if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
2338 | - return; |
|
2339 | - } |
|
2340 | - $category_id = absint($this->_req_data['EVT_CAT_ID']); |
|
2341 | - $term = get_term($category_id, 'espresso_event_categories'); |
|
2342 | - if ( ! empty($term)) { |
|
2343 | - $this->_category->category_name = $term->name; |
|
2344 | - $this->_category->category_identifier = $term->slug; |
|
2345 | - $this->_category->category_desc = $term->description; |
|
2346 | - $this->_category->id = $term->term_id; |
|
2347 | - $this->_category->parent = $term->parent; |
|
2348 | - } |
|
2349 | - } |
|
2350 | - |
|
2351 | - |
|
2352 | - private function _set_empty_category_object() |
|
2353 | - { |
|
2354 | - $this->_category = new stdClass(); |
|
2355 | - $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2356 | - $this->_category->id = $this->_category->parent = 0; |
|
2357 | - } |
|
2358 | - |
|
2359 | - |
|
2360 | - protected function _category_list_table() |
|
2361 | - { |
|
2362 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2363 | - $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
|
2364 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
2365 | - 'add_category', |
|
2366 | - 'add_category', |
|
2367 | - array(), |
|
2368 | - 'add-new-h2' |
|
2369 | - ); |
|
2370 | - $this->display_admin_list_table_page_with_sidebar(); |
|
2371 | - } |
|
2372 | - |
|
2373 | - |
|
2374 | - /** |
|
2375 | - * @param $view |
|
2376 | - */ |
|
2377 | - protected function _category_details($view) |
|
2378 | - { |
|
2379 | - //load formatter helper |
|
2380 | - //load field generator helper |
|
2381 | - $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
|
2382 | - $this->_set_add_edit_form_tags($route); |
|
2383 | - $this->_set_category_object(); |
|
2384 | - $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
2385 | - $delete_action = 'delete_category'; |
|
2386 | - //custom redirect |
|
2387 | - $redirect = EE_Admin_Page::add_query_args_and_nonce( |
|
2388 | - array('action' => 'category_list'), |
|
2389 | - $this->_admin_base_url |
|
2390 | - ); |
|
2391 | - $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
2392 | - //take care of contents |
|
2393 | - $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
|
2394 | - $this->display_admin_page_with_sidebar(); |
|
2395 | - } |
|
2396 | - |
|
2397 | - |
|
2398 | - /** |
|
2399 | - * @return mixed |
|
2400 | - */ |
|
2401 | - protected function _category_details_content() |
|
2402 | - { |
|
2403 | - $editor_args['category_desc'] = array( |
|
2404 | - 'type' => 'wp_editor', |
|
2405 | - 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
|
2406 | - 'class' => 'my_editor_custom', |
|
2407 | - 'wpeditor_args' => array('media_buttons' => false), |
|
2408 | - ); |
|
2409 | - $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
2410 | - $all_terms = get_terms( |
|
2411 | - array('espresso_event_categories'), |
|
2412 | - array('hide_empty' => 0, 'exclude' => array($this->_category->id)) |
|
2413 | - ); |
|
2414 | - //setup category select for term parents. |
|
2415 | - $category_select_values[] = array( |
|
2416 | - 'text' => esc_html__('No Parent', 'event_espresso'), |
|
2417 | - 'id' => 0, |
|
2418 | - ); |
|
2419 | - foreach ($all_terms as $term) { |
|
2420 | - $category_select_values[] = array( |
|
2421 | - 'text' => $term->name, |
|
2422 | - 'id' => $term->term_id, |
|
2423 | - ); |
|
2424 | - } |
|
2425 | - $category_select = EEH_Form_Fields::select_input( |
|
2426 | - 'category_parent', |
|
2427 | - $category_select_values, |
|
2428 | - $this->_category->parent |
|
2429 | - ); |
|
2430 | - $template_args = array( |
|
2431 | - 'category' => $this->_category, |
|
2432 | - 'category_select' => $category_select, |
|
2433 | - 'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), |
|
2434 | - 'category_desc_editor' => $_wp_editor['category_desc']['field'], |
|
2435 | - 'disable' => '', |
|
2436 | - 'disabled_message' => false, |
|
2437 | - ); |
|
2438 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2234 | + return $count; |
|
2235 | + } |
|
2236 | + |
|
2237 | + |
|
2238 | + /** |
|
2239 | + * _default_event_settings |
|
2240 | + * This generates the Default Settings Tab |
|
2241 | + * |
|
2242 | + * @return void |
|
2243 | + */ |
|
2244 | + protected function _default_event_settings() |
|
2245 | + { |
|
2246 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
2247 | + $this->_template_args['reg_status_array'] = EEM_Registration::reg_status_array( |
|
2248 | + // exclude array |
|
2249 | + array( |
|
2250 | + EEM_Registration::status_id_cancelled, |
|
2251 | + EEM_Registration::status_id_declined, |
|
2252 | + EEM_Registration::status_id_incomplete, |
|
2253 | + EEM_Registration::status_id_wait_list, |
|
2254 | + ), |
|
2255 | + // translated |
|
2256 | + true |
|
2257 | + ); |
|
2258 | + $this->_template_args['default_reg_status'] = isset( |
|
2259 | + EE_Registry::instance()->CFG->registration->default_STS_ID |
|
2260 | + ) && in_array( |
|
2261 | + EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
2262 | + $this->_template_args['reg_status_array'] |
|
2263 | + ) |
|
2264 | + ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) |
|
2265 | + : EEM_Registration::status_id_pending_payment; |
|
2266 | + $this->_set_add_edit_form_tags('update_default_event_settings'); |
|
2267 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
2268 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
2269 | + EVENTS_TEMPLATE_PATH . 'event_settings.template.php', |
|
2270 | + $this->_template_args, |
|
2271 | + true |
|
2272 | + ); |
|
2273 | + $this->display_admin_page_with_sidebar(); |
|
2274 | + } |
|
2275 | + |
|
2276 | + |
|
2277 | + /** |
|
2278 | + * _update_default_event_settings |
|
2279 | + * |
|
2280 | + * @access protected |
|
2281 | + * @return void |
|
2282 | + */ |
|
2283 | + protected function _update_default_event_settings() |
|
2284 | + { |
|
2285 | + EE_Config::instance()->registration->default_STS_ID = isset($this->_req_data['default_reg_status']) |
|
2286 | + ? sanitize_text_field($this->_req_data['default_reg_status']) |
|
2287 | + : EEM_Registration::status_id_pending_payment; |
|
2288 | + $what = 'Default Event Settings'; |
|
2289 | + $success = $this->_update_espresso_configuration( |
|
2290 | + $what, |
|
2291 | + EE_Config::instance(), |
|
2292 | + __FILE__, |
|
2293 | + __FUNCTION__, |
|
2294 | + __LINE__ |
|
2295 | + ); |
|
2296 | + $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default_event_settings')); |
|
2297 | + } |
|
2298 | + |
|
2299 | + |
|
2300 | + /************* Templates *************/ |
|
2301 | + |
|
2302 | + |
|
2303 | + protected function _template_settings() |
|
2304 | + { |
|
2305 | + $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso'); |
|
2306 | + $this->_template_args['preview_img'] = '<img src="' |
|
2307 | + . EVENTS_ASSETS_URL |
|
2308 | + . DS |
|
2309 | + . 'images' |
|
2310 | + . DS |
|
2311 | + . 'caffeinated_template_features.jpg" alt="' |
|
2312 | + . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
|
2313 | + . '" />'; |
|
2314 | + $this->_template_args['preview_text'] = '<strong>' . esc_html__( |
|
2315 | + 'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', |
|
2316 | + 'event_espresso' |
|
2317 | + ) . '</strong>'; |
|
2318 | + $this->display_admin_caf_preview_page('template_settings_tab'); |
|
2319 | + } |
|
2320 | + |
|
2321 | + |
|
2322 | + /** Event Category Stuff **/ |
|
2323 | + /** |
|
2324 | + * set the _category property with the category object for the loaded page. |
|
2325 | + * |
|
2326 | + * @access private |
|
2327 | + * @return void |
|
2328 | + */ |
|
2329 | + private function _set_category_object() |
|
2330 | + { |
|
2331 | + if (isset($this->_category->id) && ! empty($this->_category->id)) { |
|
2332 | + return; |
|
2333 | + } //already have the category object so get out. |
|
2334 | + //set default category object |
|
2335 | + $this->_set_empty_category_object(); |
|
2336 | + //only set if we've got an id |
|
2337 | + if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
2338 | + return; |
|
2339 | + } |
|
2340 | + $category_id = absint($this->_req_data['EVT_CAT_ID']); |
|
2341 | + $term = get_term($category_id, 'espresso_event_categories'); |
|
2342 | + if ( ! empty($term)) { |
|
2343 | + $this->_category->category_name = $term->name; |
|
2344 | + $this->_category->category_identifier = $term->slug; |
|
2345 | + $this->_category->category_desc = $term->description; |
|
2346 | + $this->_category->id = $term->term_id; |
|
2347 | + $this->_category->parent = $term->parent; |
|
2348 | + } |
|
2349 | + } |
|
2350 | + |
|
2351 | + |
|
2352 | + private function _set_empty_category_object() |
|
2353 | + { |
|
2354 | + $this->_category = new stdClass(); |
|
2355 | + $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2356 | + $this->_category->id = $this->_category->parent = 0; |
|
2357 | + } |
|
2358 | + |
|
2359 | + |
|
2360 | + protected function _category_list_table() |
|
2361 | + { |
|
2362 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2363 | + $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
|
2364 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
2365 | + 'add_category', |
|
2366 | + 'add_category', |
|
2367 | + array(), |
|
2368 | + 'add-new-h2' |
|
2369 | + ); |
|
2370 | + $this->display_admin_list_table_page_with_sidebar(); |
|
2371 | + } |
|
2372 | + |
|
2373 | + |
|
2374 | + /** |
|
2375 | + * @param $view |
|
2376 | + */ |
|
2377 | + protected function _category_details($view) |
|
2378 | + { |
|
2379 | + //load formatter helper |
|
2380 | + //load field generator helper |
|
2381 | + $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
|
2382 | + $this->_set_add_edit_form_tags($route); |
|
2383 | + $this->_set_category_object(); |
|
2384 | + $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
2385 | + $delete_action = 'delete_category'; |
|
2386 | + //custom redirect |
|
2387 | + $redirect = EE_Admin_Page::add_query_args_and_nonce( |
|
2388 | + array('action' => 'category_list'), |
|
2389 | + $this->_admin_base_url |
|
2390 | + ); |
|
2391 | + $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
2392 | + //take care of contents |
|
2393 | + $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
|
2394 | + $this->display_admin_page_with_sidebar(); |
|
2395 | + } |
|
2396 | + |
|
2397 | + |
|
2398 | + /** |
|
2399 | + * @return mixed |
|
2400 | + */ |
|
2401 | + protected function _category_details_content() |
|
2402 | + { |
|
2403 | + $editor_args['category_desc'] = array( |
|
2404 | + 'type' => 'wp_editor', |
|
2405 | + 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
|
2406 | + 'class' => 'my_editor_custom', |
|
2407 | + 'wpeditor_args' => array('media_buttons' => false), |
|
2408 | + ); |
|
2409 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
2410 | + $all_terms = get_terms( |
|
2411 | + array('espresso_event_categories'), |
|
2412 | + array('hide_empty' => 0, 'exclude' => array($this->_category->id)) |
|
2413 | + ); |
|
2414 | + //setup category select for term parents. |
|
2415 | + $category_select_values[] = array( |
|
2416 | + 'text' => esc_html__('No Parent', 'event_espresso'), |
|
2417 | + 'id' => 0, |
|
2418 | + ); |
|
2419 | + foreach ($all_terms as $term) { |
|
2420 | + $category_select_values[] = array( |
|
2421 | + 'text' => $term->name, |
|
2422 | + 'id' => $term->term_id, |
|
2423 | + ); |
|
2424 | + } |
|
2425 | + $category_select = EEH_Form_Fields::select_input( |
|
2426 | + 'category_parent', |
|
2427 | + $category_select_values, |
|
2428 | + $this->_category->parent |
|
2429 | + ); |
|
2430 | + $template_args = array( |
|
2431 | + 'category' => $this->_category, |
|
2432 | + 'category_select' => $category_select, |
|
2433 | + 'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), |
|
2434 | + 'category_desc_editor' => $_wp_editor['category_desc']['field'], |
|
2435 | + 'disable' => '', |
|
2436 | + 'disabled_message' => false, |
|
2437 | + ); |
|
2438 | + $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2439 | 2439 | |
2440 | - return EEH_Template::display_template($template, $template_args, true); |
|
2441 | - } |
|
2442 | - |
|
2443 | - |
|
2444 | - protected function _delete_categories() |
|
2445 | - { |
|
2446 | - $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID'] |
|
2447 | - : (array)$this->_req_data['category_id']; |
|
2448 | - foreach ($cat_ids as $cat_id) { |
|
2449 | - $this->_delete_category($cat_id); |
|
2450 | - } |
|
2451 | - //doesn't matter what page we're coming from... we're going to the same place after delete. |
|
2452 | - $query_args = array( |
|
2453 | - 'action' => 'category_list', |
|
2454 | - ); |
|
2455 | - $this->_redirect_after_action(0, '', '', $query_args); |
|
2456 | - } |
|
2457 | - |
|
2458 | - |
|
2459 | - /** |
|
2460 | - * @param $cat_id |
|
2461 | - */ |
|
2462 | - protected function _delete_category($cat_id) |
|
2463 | - { |
|
2464 | - $cat_id = absint($cat_id); |
|
2465 | - wp_delete_term($cat_id, 'espresso_event_categories'); |
|
2466 | - } |
|
2467 | - |
|
2468 | - |
|
2469 | - /** |
|
2470 | - * @param $new_category |
|
2471 | - */ |
|
2472 | - protected function _insert_or_update_category($new_category) |
|
2473 | - { |
|
2474 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true); |
|
2475 | - $success = 0; //we already have a success message so lets not send another. |
|
2476 | - if ($cat_id) { |
|
2477 | - $query_args = array( |
|
2478 | - 'action' => 'edit_category', |
|
2479 | - 'EVT_CAT_ID' => $cat_id, |
|
2480 | - ); |
|
2481 | - } else { |
|
2482 | - $query_args = array('action' => 'add_category'); |
|
2483 | - } |
|
2484 | - $this->_redirect_after_action($success, '', '', $query_args, true); |
|
2485 | - } |
|
2486 | - |
|
2487 | - |
|
2488 | - /** |
|
2489 | - * @param bool $update |
|
2490 | - * |
|
2491 | - * @return bool|mixed|string |
|
2492 | - */ |
|
2493 | - private function _insert_category($update = false) |
|
2494 | - { |
|
2495 | - $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
|
2496 | - $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
2497 | - $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
2498 | - $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
2499 | - if (empty($category_name)) { |
|
2500 | - $msg = esc_html__('You must add a name for the category.', 'event_espresso'); |
|
2501 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2440 | + return EEH_Template::display_template($template, $template_args, true); |
|
2441 | + } |
|
2442 | + |
|
2443 | + |
|
2444 | + protected function _delete_categories() |
|
2445 | + { |
|
2446 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID'] |
|
2447 | + : (array)$this->_req_data['category_id']; |
|
2448 | + foreach ($cat_ids as $cat_id) { |
|
2449 | + $this->_delete_category($cat_id); |
|
2450 | + } |
|
2451 | + //doesn't matter what page we're coming from... we're going to the same place after delete. |
|
2452 | + $query_args = array( |
|
2453 | + 'action' => 'category_list', |
|
2454 | + ); |
|
2455 | + $this->_redirect_after_action(0, '', '', $query_args); |
|
2456 | + } |
|
2457 | + |
|
2458 | + |
|
2459 | + /** |
|
2460 | + * @param $cat_id |
|
2461 | + */ |
|
2462 | + protected function _delete_category($cat_id) |
|
2463 | + { |
|
2464 | + $cat_id = absint($cat_id); |
|
2465 | + wp_delete_term($cat_id, 'espresso_event_categories'); |
|
2466 | + } |
|
2467 | + |
|
2468 | + |
|
2469 | + /** |
|
2470 | + * @param $new_category |
|
2471 | + */ |
|
2472 | + protected function _insert_or_update_category($new_category) |
|
2473 | + { |
|
2474 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true); |
|
2475 | + $success = 0; //we already have a success message so lets not send another. |
|
2476 | + if ($cat_id) { |
|
2477 | + $query_args = array( |
|
2478 | + 'action' => 'edit_category', |
|
2479 | + 'EVT_CAT_ID' => $cat_id, |
|
2480 | + ); |
|
2481 | + } else { |
|
2482 | + $query_args = array('action' => 'add_category'); |
|
2483 | + } |
|
2484 | + $this->_redirect_after_action($success, '', '', $query_args, true); |
|
2485 | + } |
|
2486 | + |
|
2487 | + |
|
2488 | + /** |
|
2489 | + * @param bool $update |
|
2490 | + * |
|
2491 | + * @return bool|mixed|string |
|
2492 | + */ |
|
2493 | + private function _insert_category($update = false) |
|
2494 | + { |
|
2495 | + $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
|
2496 | + $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
2497 | + $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
2498 | + $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
2499 | + if (empty($category_name)) { |
|
2500 | + $msg = esc_html__('You must add a name for the category.', 'event_espresso'); |
|
2501 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2502 | 2502 | |
2503 | - return false; |
|
2504 | - } |
|
2505 | - $term_args = array( |
|
2506 | - 'name' => $category_name, |
|
2507 | - 'description' => $category_desc, |
|
2508 | - 'parent' => $category_parent, |
|
2509 | - ); |
|
2510 | - //was the category_identifier input disabled? |
|
2511 | - if (isset($this->_req_data['category_identifier'])) { |
|
2512 | - $term_args['slug'] = $this->_req_data['category_identifier']; |
|
2513 | - } |
|
2514 | - $insert_ids = $update |
|
2515 | - ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) |
|
2516 | - : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
2517 | - if ( ! is_array($insert_ids)) { |
|
2518 | - $msg = esc_html__( |
|
2519 | - 'An error occurred and the category has not been saved to the database.', |
|
2520 | - 'event_espresso' |
|
2521 | - ); |
|
2522 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2523 | - } else { |
|
2524 | - $cat_id = $insert_ids['term_id']; |
|
2525 | - $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name); |
|
2526 | - EE_Error::add_success($msg); |
|
2527 | - } |
|
2503 | + return false; |
|
2504 | + } |
|
2505 | + $term_args = array( |
|
2506 | + 'name' => $category_name, |
|
2507 | + 'description' => $category_desc, |
|
2508 | + 'parent' => $category_parent, |
|
2509 | + ); |
|
2510 | + //was the category_identifier input disabled? |
|
2511 | + if (isset($this->_req_data['category_identifier'])) { |
|
2512 | + $term_args['slug'] = $this->_req_data['category_identifier']; |
|
2513 | + } |
|
2514 | + $insert_ids = $update |
|
2515 | + ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) |
|
2516 | + : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
2517 | + if ( ! is_array($insert_ids)) { |
|
2518 | + $msg = esc_html__( |
|
2519 | + 'An error occurred and the category has not been saved to the database.', |
|
2520 | + 'event_espresso' |
|
2521 | + ); |
|
2522 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2523 | + } else { |
|
2524 | + $cat_id = $insert_ids['term_id']; |
|
2525 | + $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name); |
|
2526 | + EE_Error::add_success($msg); |
|
2527 | + } |
|
2528 | 2528 | |
2529 | - return $cat_id; |
|
2530 | - } |
|
2531 | - |
|
2532 | - |
|
2533 | - /** |
|
2534 | - * @param int $per_page |
|
2535 | - * @param int $current_page |
|
2536 | - * @param bool $count |
|
2537 | - * |
|
2538 | - * @return \EE_Base_Class[]|int |
|
2539 | - */ |
|
2540 | - public function get_categories($per_page = 10, $current_page = 1, $count = false) |
|
2541 | - { |
|
2542 | - //testing term stuff |
|
2543 | - $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2544 | - $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
2545 | - $limit = ($current_page - 1) * $per_page; |
|
2546 | - $where = array('taxonomy' => 'espresso_event_categories'); |
|
2547 | - if (isset($this->_req_data['s'])) { |
|
2548 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2549 | - $where['OR'] = array( |
|
2550 | - 'Term.name' => array('LIKE', $sstr), |
|
2551 | - 'description' => array('LIKE', $sstr), |
|
2552 | - ); |
|
2553 | - } |
|
2554 | - $query_params = array( |
|
2555 | - $where, |
|
2556 | - 'order_by' => array($orderby => $order), |
|
2557 | - 'limit' => $limit . ',' . $per_page, |
|
2558 | - 'force_join' => array('Term'), |
|
2559 | - ); |
|
2560 | - $categories = $count |
|
2561 | - ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') |
|
2562 | - : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
2529 | + return $cat_id; |
|
2530 | + } |
|
2531 | + |
|
2532 | + |
|
2533 | + /** |
|
2534 | + * @param int $per_page |
|
2535 | + * @param int $current_page |
|
2536 | + * @param bool $count |
|
2537 | + * |
|
2538 | + * @return \EE_Base_Class[]|int |
|
2539 | + */ |
|
2540 | + public function get_categories($per_page = 10, $current_page = 1, $count = false) |
|
2541 | + { |
|
2542 | + //testing term stuff |
|
2543 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2544 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
2545 | + $limit = ($current_page - 1) * $per_page; |
|
2546 | + $where = array('taxonomy' => 'espresso_event_categories'); |
|
2547 | + if (isset($this->_req_data['s'])) { |
|
2548 | + $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2549 | + $where['OR'] = array( |
|
2550 | + 'Term.name' => array('LIKE', $sstr), |
|
2551 | + 'description' => array('LIKE', $sstr), |
|
2552 | + ); |
|
2553 | + } |
|
2554 | + $query_params = array( |
|
2555 | + $where, |
|
2556 | + 'order_by' => array($orderby => $order), |
|
2557 | + 'limit' => $limit . ',' . $per_page, |
|
2558 | + 'force_join' => array('Term'), |
|
2559 | + ); |
|
2560 | + $categories = $count |
|
2561 | + ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') |
|
2562 | + : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
2563 | 2563 | |
2564 | - return $categories; |
|
2565 | - } |
|
2564 | + return $categories; |
|
2565 | + } |
|
2566 | 2566 | |
2567 | 2567 | |
2568 | 2568 | |
2569 | - /* end category stuff */ |
|
2570 | - /**************/ |
|
2569 | + /* end category stuff */ |
|
2570 | + /**************/ |
|
2571 | 2571 | } |
2572 | 2572 | //end class Events_Admin_Page |
@@ -520,11 +520,11 @@ discard block |
||
520 | 520 | { |
521 | 521 | wp_register_style( |
522 | 522 | 'events-admin-css', |
523 | - EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
523 | + EVENTS_ASSETS_URL.'events-admin-page.css', |
|
524 | 524 | array(), |
525 | 525 | EVENT_ESPRESSO_VERSION |
526 | 526 | ); |
527 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
527 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
528 | 528 | wp_enqueue_style('events-admin-css'); |
529 | 529 | wp_enqueue_style('ee-cat-admin'); |
530 | 530 | //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | //scripts |
533 | 533 | wp_register_script( |
534 | 534 | 'event_editor_js', |
535 | - EVENTS_ASSETS_URL . 'event_editor.js', |
|
535 | + EVENTS_ASSETS_URL.'event_editor.js', |
|
536 | 536 | array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), |
537 | 537 | EVENT_ESPRESSO_VERSION, |
538 | 538 | true |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | wp_enqueue_style('espresso-ui-theme'); |
563 | 563 | wp_register_style( |
564 | 564 | 'event-editor-css', |
565 | - EVENTS_ASSETS_URL . 'event-editor.css', |
|
565 | + EVENTS_ASSETS_URL.'event-editor.css', |
|
566 | 566 | array('ee-admin-css'), |
567 | 567 | EVENT_ESPRESSO_VERSION |
568 | 568 | ); |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | //scripts |
571 | 571 | wp_register_script( |
572 | 572 | 'event-datetime-metabox', |
573 | - EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
573 | + EVENTS_ASSETS_URL.'event-datetime-metabox.js', |
|
574 | 574 | array('event_editor_js', 'ee-datepicker'), |
575 | 575 | EVENT_ESPRESSO_VERSION |
576 | 576 | ); |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | sprintf( |
726 | 726 | __('Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city |
727 | 727 | or region near you before you create an event. Your timezone can be updated through the %1$sGeneral Settings%2$s page.'), |
728 | - '<a href="' . admin_url('options-general.php') . '">', |
|
728 | + '<a href="'.admin_url('options-general.php').'">', |
|
729 | 729 | '</a>' |
730 | 730 | ), |
731 | 731 | __FILE__, |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | */ |
778 | 778 | protected function _event_legend_items() |
779 | 779 | { |
780 | - $items = array( |
|
780 | + $items = array( |
|
781 | 781 | 'view_details' => array( |
782 | 782 | 'class' => 'dashicons dashicons-search', |
783 | 783 | 'desc' => esc_html__('View Event', 'event_espresso'), |
@@ -794,31 +794,31 @@ discard block |
||
794 | 794 | $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
795 | 795 | $statuses = array( |
796 | 796 | 'sold_out_status' => array( |
797 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
797 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out, |
|
798 | 798 | 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
799 | 799 | ), |
800 | 800 | 'active_status' => array( |
801 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
801 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active, |
|
802 | 802 | 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
803 | 803 | ), |
804 | 804 | 'upcoming_status' => array( |
805 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
805 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming, |
|
806 | 806 | 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
807 | 807 | ), |
808 | 808 | 'postponed_status' => array( |
809 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
809 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed, |
|
810 | 810 | 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
811 | 811 | ), |
812 | 812 | 'cancelled_status' => array( |
813 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
813 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled, |
|
814 | 814 | 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
815 | 815 | ), |
816 | 816 | 'expired_status' => array( |
817 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
817 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired, |
|
818 | 818 | 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
819 | 819 | ), |
820 | 820 | 'inactive_status' => array( |
821 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
821 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive, |
|
822 | 822 | 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
823 | 823 | ), |
824 | 824 | ); |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | { |
884 | 884 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
885 | 885 | $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table']) |
886 | - ? (array)$this->_template_args['after_list_table'] |
|
886 | + ? (array) $this->_template_args['after_list_table'] |
|
887 | 887 | : array(); |
888 | 888 | $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br() |
889 | 889 | . EEH_Template::get_button_or_link( |
@@ -891,8 +891,8 @@ discard block |
||
891 | 891 | esc_html__("View Event Archive Page", "event_espresso"), |
892 | 892 | 'button' |
893 | 893 | ); |
894 | - $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items()); |
|
895 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
894 | + $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items()); |
|
895 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
896 | 896 | 'create_new', |
897 | 897 | 'add', |
898 | 898 | array(), |
@@ -966,7 +966,7 @@ discard block |
||
966 | 966 | 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
967 | 967 | array(array($this, '_default_venue_update'), array($this, '_default_tickets_update')) |
968 | 968 | ); |
969 | - $att_success = true; |
|
969 | + $att_success = true; |
|
970 | 970 | foreach ($event_update_callbacks as $e_callback) { |
971 | 971 | $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
972 | 972 | $att_success = ! $att_success ? $att_success |
@@ -1023,7 +1023,7 @@ discard block |
||
1023 | 1023 | */ |
1024 | 1024 | protected function _default_venue_update(\EE_Event $evtobj, $data) |
1025 | 1025 | { |
1026 | - require_once(EE_MODELS . 'EEM_Venue.model.php'); |
|
1026 | + require_once(EE_MODELS.'EEM_Venue.model.php'); |
|
1027 | 1027 | $venue_model = EE_Registry::instance()->load_model('Venue'); |
1028 | 1028 | $rows_affected = null; |
1029 | 1029 | $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | if (empty($tkt['TKT_start_date'])) { |
1148 | 1148 | //let's use now in the set timezone. |
1149 | 1149 | $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
1150 | - $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]); |
|
1150 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]); |
|
1151 | 1151 | } |
1152 | 1152 | if (empty($tkt['TKT_end_date'])) { |
1153 | 1153 | //use the start date of the first datetime |
@@ -1360,13 +1360,13 @@ discard block |
||
1360 | 1360 | { |
1361 | 1361 | //load formatter helper |
1362 | 1362 | //args for getting related registrations |
1363 | - $approved_query_args = array( |
|
1363 | + $approved_query_args = array( |
|
1364 | 1364 | array( |
1365 | 1365 | 'REG_deleted' => 0, |
1366 | 1366 | 'STS_ID' => EEM_Registration::status_id_approved |
1367 | 1367 | ) |
1368 | 1368 | ); |
1369 | - $not_approved_query_args = array( |
|
1369 | + $not_approved_query_args = array( |
|
1370 | 1370 | array( |
1371 | 1371 | 'REG_deleted' => 0, |
1372 | 1372 | 'STS_ID' => EEM_Registration::status_id_not_approved, |
@@ -1436,7 +1436,7 @@ discard block |
||
1436 | 1436 | $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
1437 | 1437 | // load template |
1438 | 1438 | EEH_Template::display_template( |
1439 | - EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
1439 | + EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', |
|
1440 | 1440 | $publish_box_extra_args |
1441 | 1441 | ); |
1442 | 1442 | } |
@@ -1507,7 +1507,7 @@ discard block |
||
1507 | 1507 | 'trash_icon' => 'ee-lock-icon', |
1508 | 1508 | 'disabled' => '', |
1509 | 1509 | ); |
1510 | - $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null; |
|
1510 | + $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null; |
|
1511 | 1511 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
1512 | 1512 | /** |
1513 | 1513 | * 1. Start with retrieving Datetimes |
@@ -1561,9 +1561,9 @@ discard block |
||
1561 | 1561 | EE_Registry::instance()->load_model('Ticket')->create_default_object(), |
1562 | 1562 | true |
1563 | 1563 | ); |
1564 | - $template = apply_filters( |
|
1564 | + $template = apply_filters( |
|
1565 | 1565 | 'FHEE__Events_Admin_Page__ticket_metabox__template', |
1566 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
1566 | + EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php' |
|
1567 | 1567 | ); |
1568 | 1568 | EEH_Template::display_template($template, $template_args); |
1569 | 1569 | } |
@@ -1583,7 +1583,7 @@ discard block |
||
1583 | 1583 | private function _get_ticket_row($ticket, $skeleton = false, $row = 0) |
1584 | 1584 | { |
1585 | 1585 | $template_args = array( |
1586 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1586 | + 'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(), |
|
1587 | 1587 | 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
1588 | 1588 | : '', |
1589 | 1589 | 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
@@ -1637,7 +1637,7 @@ discard block |
||
1637 | 1637 | $template_args = array_merge($template_args, $price_args); |
1638 | 1638 | $template = apply_filters( |
1639 | 1639 | 'FHEE__Events_Admin_Page__get_ticket_row__template', |
1640 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
1640 | + EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', |
|
1641 | 1641 | $ticket |
1642 | 1642 | ); |
1643 | 1643 | |
@@ -1647,7 +1647,7 @@ discard block |
||
1647 | 1647 | |
1648 | 1648 | public function registration_options_meta_box() |
1649 | 1649 | { |
1650 | - $yes_no_values = array( |
|
1650 | + $yes_no_values = array( |
|
1651 | 1651 | array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
1652 | 1652 | array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
1653 | 1653 | ); |
@@ -1668,12 +1668,12 @@ discard block |
||
1668 | 1668 | $default_reg_status_values, |
1669 | 1669 | $this->_cpt_model_obj->default_registration_status() |
1670 | 1670 | ); |
1671 | - $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
1671 | + $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
1672 | 1672 | 'display_desc', |
1673 | 1673 | $yes_no_values, |
1674 | 1674 | $this->_cpt_model_obj->display_description() |
1675 | 1675 | ); |
1676 | - $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
1676 | + $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
1677 | 1677 | 'display_ticket_selector', |
1678 | 1678 | $yes_no_values, |
1679 | 1679 | $this->_cpt_model_obj->display_ticket_selector(), |
@@ -1689,7 +1689,7 @@ discard block |
||
1689 | 1689 | $default_reg_status_values |
1690 | 1690 | ); |
1691 | 1691 | EEH_Template::display_template( |
1692 | - EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
1692 | + EVENTS_TEMPLATE_PATH.'event_registration_options.template.php', |
|
1693 | 1693 | $template_args |
1694 | 1694 | ); |
1695 | 1695 | } |
@@ -1713,7 +1713,7 @@ discard block |
||
1713 | 1713 | { |
1714 | 1714 | $EEME = $this->_event_model(); |
1715 | 1715 | $offset = ($current_page - 1) * $per_page; |
1716 | - $limit = $count ? null : $offset . ',' . $per_page; |
|
1716 | + $limit = $count ? null : $offset.','.$per_page; |
|
1717 | 1717 | $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
1718 | 1718 | $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
1719 | 1719 | if (isset($this->_req_data['month_range'])) { |
@@ -1746,8 +1746,8 @@ discard block |
||
1746 | 1746 | //date where conditions |
1747 | 1747 | $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
1748 | 1748 | if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
1749 | - $DateTime = new DateTime( |
|
1750 | - $year_r . '-' . $month_r . '-01 00:00:00', |
|
1749 | + $DateTime = new DateTime( |
|
1750 | + $year_r.'-'.$month_r.'-01 00:00:00', |
|
1751 | 1751 | new DateTimeZone(EEM_Datetime::instance()->get_timezone()) |
1752 | 1752 | ); |
1753 | 1753 | $start = $DateTime->format(implode(' ', $start_formats)); |
@@ -1796,7 +1796,7 @@ discard block |
||
1796 | 1796 | } |
1797 | 1797 | //search query handling |
1798 | 1798 | if (isset($this->_req_data['s'])) { |
1799 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1799 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
1800 | 1800 | $where['OR'] = array( |
1801 | 1801 | 'EVT_name' => array('LIKE', $search_string), |
1802 | 1802 | 'EVT_desc' => array('LIKE', $search_string), |
@@ -1929,7 +1929,7 @@ discard block |
||
1929 | 1929 | if ( ! empty($event_status)) { |
1930 | 1930 | $success = true; |
1931 | 1931 | //determine the event id and set to array. |
1932 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
1932 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
|
1933 | 1933 | // loop thru events |
1934 | 1934 | foreach ($EVT_IDs as $EVT_ID) { |
1935 | 1935 | if ($EVT_ID = absint($EVT_ID)) { |
@@ -2081,7 +2081,7 @@ discard block |
||
2081 | 2081 | // get list of events with no prices |
2082 | 2082 | $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
2083 | 2083 | //determine the event id and set to array. |
2084 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
2084 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
|
2085 | 2085 | // loop thru events |
2086 | 2086 | foreach ($EVT_IDs as $EVT_ID) { |
2087 | 2087 | $EVT_ID = absint($EVT_ID); |
@@ -2266,7 +2266,7 @@ discard block |
||
2266 | 2266 | $this->_set_add_edit_form_tags('update_default_event_settings'); |
2267 | 2267 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
2268 | 2268 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
2269 | - EVENTS_TEMPLATE_PATH . 'event_settings.template.php', |
|
2269 | + EVENTS_TEMPLATE_PATH.'event_settings.template.php', |
|
2270 | 2270 | $this->_template_args, |
2271 | 2271 | true |
2272 | 2272 | ); |
@@ -2311,10 +2311,10 @@ discard block |
||
2311 | 2311 | . 'caffeinated_template_features.jpg" alt="' |
2312 | 2312 | . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
2313 | 2313 | . '" />'; |
2314 | - $this->_template_args['preview_text'] = '<strong>' . esc_html__( |
|
2314 | + $this->_template_args['preview_text'] = '<strong>'.esc_html__( |
|
2315 | 2315 | 'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', |
2316 | 2316 | 'event_espresso' |
2317 | - ) . '</strong>'; |
|
2317 | + ).'</strong>'; |
|
2318 | 2318 | $this->display_admin_caf_preview_page('template_settings_tab'); |
2319 | 2319 | } |
2320 | 2320 | |
@@ -2361,7 +2361,7 @@ discard block |
||
2361 | 2361 | { |
2362 | 2362 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
2363 | 2363 | $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
2364 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
2364 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
2365 | 2365 | 'add_category', |
2366 | 2366 | 'add_category', |
2367 | 2367 | array(), |
@@ -2427,7 +2427,7 @@ discard block |
||
2427 | 2427 | $category_select_values, |
2428 | 2428 | $this->_category->parent |
2429 | 2429 | ); |
2430 | - $template_args = array( |
|
2430 | + $template_args = array( |
|
2431 | 2431 | 'category' => $this->_category, |
2432 | 2432 | 'category_select' => $category_select, |
2433 | 2433 | 'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), |
@@ -2435,7 +2435,7 @@ discard block |
||
2435 | 2435 | 'disable' => '', |
2436 | 2436 | 'disabled_message' => false, |
2437 | 2437 | ); |
2438 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2438 | + $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php'; |
|
2439 | 2439 | |
2440 | 2440 | return EEH_Template::display_template($template, $template_args, true); |
2441 | 2441 | } |
@@ -2443,8 +2443,8 @@ discard block |
||
2443 | 2443 | |
2444 | 2444 | protected function _delete_categories() |
2445 | 2445 | { |
2446 | - $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID'] |
|
2447 | - : (array)$this->_req_data['category_id']; |
|
2446 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID'] |
|
2447 | + : (array) $this->_req_data['category_id']; |
|
2448 | 2448 | foreach ($cat_ids as $cat_id) { |
2449 | 2449 | $this->_delete_category($cat_id); |
2450 | 2450 | } |
@@ -2545,7 +2545,7 @@ discard block |
||
2545 | 2545 | $limit = ($current_page - 1) * $per_page; |
2546 | 2546 | $where = array('taxonomy' => 'espresso_event_categories'); |
2547 | 2547 | if (isset($this->_req_data['s'])) { |
2548 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2548 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
2549 | 2549 | $where['OR'] = array( |
2550 | 2550 | 'Term.name' => array('LIKE', $sstr), |
2551 | 2551 | 'description' => array('LIKE', $sstr), |
@@ -2554,10 +2554,10 @@ discard block |
||
2554 | 2554 | $query_params = array( |
2555 | 2555 | $where, |
2556 | 2556 | 'order_by' => array($orderby => $order), |
2557 | - 'limit' => $limit . ',' . $per_page, |
|
2557 | + 'limit' => $limit.','.$per_page, |
|
2558 | 2558 | 'force_join' => array('Term'), |
2559 | 2559 | ); |
2560 | - $categories = $count |
|
2560 | + $categories = $count |
|
2561 | 2561 | ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') |
2562 | 2562 | : EEM_Term_Taxonomy::instance()->get_all($query_params); |
2563 | 2563 |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | * @param $template |
337 | 337 | * @param $template_args |
338 | 338 | * |
339 | - * @return mixed |
|
339 | + * @return string |
|
340 | 340 | */ |
341 | 341 | public function add_additional_datetime_button($template, $template_args) |
342 | 342 | { |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | * @param $template |
353 | 353 | * @param $template_args |
354 | 354 | * |
355 | - * @return mixed |
|
355 | + * @return string |
|
356 | 356 | */ |
357 | 357 | public function add_datetime_clone_button($template, $template_args) |
358 | 358 | { |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * @param $template |
369 | 369 | * @param $template_args |
370 | 370 | * |
371 | - * @return mixed |
|
371 | + * @return string |
|
372 | 372 | */ |
373 | 373 | public function datetime_timezones_template($template, $template_args) |
374 | 374 | { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('NO direct script access allowed'); |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -16,1218 +16,1218 @@ discard block |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * Extend_Events_Admin_Page constructor. |
|
21 | - * |
|
22 | - * @param bool $routing |
|
23 | - */ |
|
24 | - public function __construct($routing = true) |
|
25 | - { |
|
26 | - parent::__construct($routing); |
|
27 | - if ( ! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
28 | - define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
29 | - define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
30 | - define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
31 | - } |
|
32 | - } |
|
33 | - |
|
34 | - |
|
35 | - protected function _extend_page_config() |
|
36 | - { |
|
37 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
38 | - //is there a evt_id in the request? |
|
39 | - $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
40 | - ? $this->_req_data['EVT_ID'] |
|
41 | - : 0; |
|
42 | - $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
43 | - //tkt_id? |
|
44 | - $tkt_id = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID']) |
|
45 | - ? $this->_req_data['TKT_ID'] |
|
46 | - : 0; |
|
47 | - $new_page_routes = array( |
|
48 | - 'duplicate_event' => array( |
|
49 | - 'func' => '_duplicate_event', |
|
50 | - 'capability' => 'ee_edit_event', |
|
51 | - 'obj_id' => $evt_id, |
|
52 | - 'noheader' => true, |
|
53 | - ), |
|
54 | - 'ticket_list_table' => array( |
|
55 | - 'func' => '_tickets_overview_list_table', |
|
56 | - 'capability' => 'ee_read_default_tickets', |
|
57 | - ), |
|
58 | - 'trash_ticket' => array( |
|
59 | - 'func' => '_trash_or_restore_ticket', |
|
60 | - 'capability' => 'ee_delete_default_ticket', |
|
61 | - 'obj_id' => $tkt_id, |
|
62 | - 'noheader' => true, |
|
63 | - 'args' => array('trash' => true), |
|
64 | - ), |
|
65 | - 'trash_tickets' => array( |
|
66 | - 'func' => '_trash_or_restore_ticket', |
|
67 | - 'capability' => 'ee_delete_default_tickets', |
|
68 | - 'noheader' => true, |
|
69 | - 'args' => array('trash' => true), |
|
70 | - ), |
|
71 | - 'restore_ticket' => array( |
|
72 | - 'func' => '_trash_or_restore_ticket', |
|
73 | - 'capability' => 'ee_delete_default_ticket', |
|
74 | - 'obj_id' => $tkt_id, |
|
75 | - 'noheader' => true, |
|
76 | - ), |
|
77 | - 'restore_tickets' => array( |
|
78 | - 'func' => '_trash_or_restore_ticket', |
|
79 | - 'capability' => 'ee_delete_default_tickets', |
|
80 | - 'noheader' => true, |
|
81 | - ), |
|
82 | - 'delete_ticket' => array( |
|
83 | - 'func' => '_delete_ticket', |
|
84 | - 'capability' => 'ee_delete_default_ticket', |
|
85 | - 'obj_id' => $tkt_id, |
|
86 | - 'noheader' => true, |
|
87 | - ), |
|
88 | - 'delete_tickets' => array( |
|
89 | - 'func' => '_delete_ticket', |
|
90 | - 'capability' => 'ee_delete_default_tickets', |
|
91 | - 'noheader' => true, |
|
92 | - ), |
|
93 | - 'import_page' => array( |
|
94 | - 'func' => '_import_page', |
|
95 | - 'capability' => 'import', |
|
96 | - ), |
|
97 | - 'import' => array( |
|
98 | - 'func' => '_import_events', |
|
99 | - 'capability' => 'import', |
|
100 | - 'noheader' => true, |
|
101 | - ), |
|
102 | - 'import_events' => array( |
|
103 | - 'func' => '_import_events', |
|
104 | - 'capability' => 'import', |
|
105 | - 'noheader' => true, |
|
106 | - ), |
|
107 | - 'export_events' => array( |
|
108 | - 'func' => '_events_export', |
|
109 | - 'capability' => 'export', |
|
110 | - 'noheader' => true, |
|
111 | - ), |
|
112 | - 'export_categories' => array( |
|
113 | - 'func' => '_categories_export', |
|
114 | - 'capability' => 'export', |
|
115 | - 'noheader' => true, |
|
116 | - ), |
|
117 | - 'sample_export_file' => array( |
|
118 | - 'func' => '_sample_export_file', |
|
119 | - 'capability' => 'export', |
|
120 | - 'noheader' => true, |
|
121 | - ), |
|
122 | - 'update_template_settings' => array( |
|
123 | - 'func' => '_update_template_settings', |
|
124 | - 'capability' => 'manage_options', |
|
125 | - 'noheader' => true, |
|
126 | - ), |
|
127 | - ); |
|
128 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
129 | - //partial route/config override |
|
130 | - $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes; |
|
131 | - $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
132 | - $this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
133 | - $this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
134 | - $this->_page_config['edit']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
135 | - $this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table'; |
|
136 | - //add tickets tab but only if there are more than one default ticket! |
|
137 | - $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
138 | - array(array('TKT_is_default' => 1)), |
|
139 | - 'TKT_ID', |
|
140 | - true |
|
141 | - ); |
|
142 | - if ($tkt_count > 1) { |
|
143 | - $new_page_config = array( |
|
144 | - 'ticket_list_table' => array( |
|
145 | - 'nav' => array( |
|
146 | - 'label' => esc_html__('Default Tickets', 'event_espresso'), |
|
147 | - 'order' => 60, |
|
148 | - ), |
|
149 | - 'list_table' => 'Tickets_List_Table', |
|
150 | - 'require_nonce' => false, |
|
151 | - ), |
|
152 | - ); |
|
153 | - } |
|
154 | - //template settings |
|
155 | - $new_page_config['template_settings'] = array( |
|
156 | - 'nav' => array( |
|
157 | - 'label' => esc_html__('Templates', 'event_espresso'), |
|
158 | - 'order' => 30, |
|
159 | - ), |
|
160 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
161 | - 'help_tabs' => array( |
|
162 | - 'general_settings_templates_help_tab' => array( |
|
163 | - 'title' => esc_html__('Templates', 'event_espresso'), |
|
164 | - 'filename' => 'general_settings_templates', |
|
165 | - ), |
|
166 | - ), |
|
167 | - 'help_tour' => array('Templates_Help_Tour'), |
|
168 | - 'require_nonce' => false, |
|
169 | - ); |
|
170 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
171 | - //add filters and actions |
|
172 | - //modifying _views |
|
173 | - add_filter( |
|
174 | - 'FHEE_event_datetime_metabox_add_additional_date_time_template', |
|
175 | - array($this, 'add_additional_datetime_button'), |
|
176 | - 10, |
|
177 | - 2 |
|
178 | - ); |
|
179 | - add_filter( |
|
180 | - 'FHEE_event_datetime_metabox_clone_button_template', |
|
181 | - array($this, 'add_datetime_clone_button'), |
|
182 | - 10, |
|
183 | - 2 |
|
184 | - ); |
|
185 | - add_filter( |
|
186 | - 'FHEE_event_datetime_metabox_timezones_template', |
|
187 | - array($this, 'datetime_timezones_template'), |
|
188 | - 10, |
|
189 | - 2 |
|
190 | - ); |
|
191 | - //filters for event list table |
|
192 | - add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2); |
|
193 | - add_filter( |
|
194 | - 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
195 | - array($this, 'extra_list_table_actions'), |
|
196 | - 10, |
|
197 | - 2 |
|
198 | - ); |
|
199 | - //legend item |
|
200 | - add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items')); |
|
201 | - add_action('admin_init', array($this, 'admin_init')); |
|
202 | - //heartbeat stuff |
|
203 | - add_filter('heartbeat_received', array($this, 'heartbeat_response'), 10, 2); |
|
204 | - } |
|
205 | - |
|
206 | - |
|
207 | - /** |
|
208 | - * admin_init |
|
209 | - */ |
|
210 | - public function admin_init() |
|
211 | - { |
|
212 | - EE_Registry::$i18n_js_strings = array_merge( |
|
213 | - EE_Registry::$i18n_js_strings, |
|
214 | - array( |
|
215 | - 'image_confirm' => esc_html__( |
|
216 | - 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
217 | - 'event_espresso' |
|
218 | - ), |
|
219 | - 'event_starts_on' => esc_html__('Event Starts on', 'event_espresso'), |
|
220 | - 'event_ends_on' => esc_html__('Event Ends on', 'event_espresso'), |
|
221 | - 'event_datetime_actions' => esc_html__('Actions', 'event_espresso'), |
|
222 | - 'event_clone_dt_msg' => esc_html__('Clone this Event Date and Time', 'event_espresso'), |
|
223 | - 'remove_event_dt_msg' => esc_html__('Remove this Event Time', 'event_espresso'), |
|
224 | - ) |
|
225 | - ); |
|
226 | - } |
|
227 | - |
|
228 | - |
|
229 | - /** |
|
230 | - * This will be used to listen for any heartbeat data packages coming via the WordPress heartbeat API and handle |
|
231 | - * accordingly. |
|
232 | - * |
|
233 | - * @param array $response The existing heartbeat response array. |
|
234 | - * @param array $data The incoming data package. |
|
235 | - * |
|
236 | - * @return array possibly appended response. |
|
237 | - */ |
|
238 | - public function heartbeat_response($response, $data) |
|
239 | - { |
|
240 | - /** |
|
241 | - * check whether count of tickets is approaching the potential |
|
242 | - * limits for the server. |
|
243 | - */ |
|
244 | - if ( ! empty($data['input_count'])) { |
|
245 | - $response['max_input_vars_check'] = EE_Registry::instance()->CFG->environment->max_input_vars_limit_check( |
|
246 | - $data['input_count'] |
|
247 | - ); |
|
248 | - } |
|
19 | + /** |
|
20 | + * Extend_Events_Admin_Page constructor. |
|
21 | + * |
|
22 | + * @param bool $routing |
|
23 | + */ |
|
24 | + public function __construct($routing = true) |
|
25 | + { |
|
26 | + parent::__construct($routing); |
|
27 | + if ( ! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
28 | + define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
29 | + define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
30 | + define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
31 | + } |
|
32 | + } |
|
33 | + |
|
34 | + |
|
35 | + protected function _extend_page_config() |
|
36 | + { |
|
37 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
38 | + //is there a evt_id in the request? |
|
39 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
40 | + ? $this->_req_data['EVT_ID'] |
|
41 | + : 0; |
|
42 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
43 | + //tkt_id? |
|
44 | + $tkt_id = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID']) |
|
45 | + ? $this->_req_data['TKT_ID'] |
|
46 | + : 0; |
|
47 | + $new_page_routes = array( |
|
48 | + 'duplicate_event' => array( |
|
49 | + 'func' => '_duplicate_event', |
|
50 | + 'capability' => 'ee_edit_event', |
|
51 | + 'obj_id' => $evt_id, |
|
52 | + 'noheader' => true, |
|
53 | + ), |
|
54 | + 'ticket_list_table' => array( |
|
55 | + 'func' => '_tickets_overview_list_table', |
|
56 | + 'capability' => 'ee_read_default_tickets', |
|
57 | + ), |
|
58 | + 'trash_ticket' => array( |
|
59 | + 'func' => '_trash_or_restore_ticket', |
|
60 | + 'capability' => 'ee_delete_default_ticket', |
|
61 | + 'obj_id' => $tkt_id, |
|
62 | + 'noheader' => true, |
|
63 | + 'args' => array('trash' => true), |
|
64 | + ), |
|
65 | + 'trash_tickets' => array( |
|
66 | + 'func' => '_trash_or_restore_ticket', |
|
67 | + 'capability' => 'ee_delete_default_tickets', |
|
68 | + 'noheader' => true, |
|
69 | + 'args' => array('trash' => true), |
|
70 | + ), |
|
71 | + 'restore_ticket' => array( |
|
72 | + 'func' => '_trash_or_restore_ticket', |
|
73 | + 'capability' => 'ee_delete_default_ticket', |
|
74 | + 'obj_id' => $tkt_id, |
|
75 | + 'noheader' => true, |
|
76 | + ), |
|
77 | + 'restore_tickets' => array( |
|
78 | + 'func' => '_trash_or_restore_ticket', |
|
79 | + 'capability' => 'ee_delete_default_tickets', |
|
80 | + 'noheader' => true, |
|
81 | + ), |
|
82 | + 'delete_ticket' => array( |
|
83 | + 'func' => '_delete_ticket', |
|
84 | + 'capability' => 'ee_delete_default_ticket', |
|
85 | + 'obj_id' => $tkt_id, |
|
86 | + 'noheader' => true, |
|
87 | + ), |
|
88 | + 'delete_tickets' => array( |
|
89 | + 'func' => '_delete_ticket', |
|
90 | + 'capability' => 'ee_delete_default_tickets', |
|
91 | + 'noheader' => true, |
|
92 | + ), |
|
93 | + 'import_page' => array( |
|
94 | + 'func' => '_import_page', |
|
95 | + 'capability' => 'import', |
|
96 | + ), |
|
97 | + 'import' => array( |
|
98 | + 'func' => '_import_events', |
|
99 | + 'capability' => 'import', |
|
100 | + 'noheader' => true, |
|
101 | + ), |
|
102 | + 'import_events' => array( |
|
103 | + 'func' => '_import_events', |
|
104 | + 'capability' => 'import', |
|
105 | + 'noheader' => true, |
|
106 | + ), |
|
107 | + 'export_events' => array( |
|
108 | + 'func' => '_events_export', |
|
109 | + 'capability' => 'export', |
|
110 | + 'noheader' => true, |
|
111 | + ), |
|
112 | + 'export_categories' => array( |
|
113 | + 'func' => '_categories_export', |
|
114 | + 'capability' => 'export', |
|
115 | + 'noheader' => true, |
|
116 | + ), |
|
117 | + 'sample_export_file' => array( |
|
118 | + 'func' => '_sample_export_file', |
|
119 | + 'capability' => 'export', |
|
120 | + 'noheader' => true, |
|
121 | + ), |
|
122 | + 'update_template_settings' => array( |
|
123 | + 'func' => '_update_template_settings', |
|
124 | + 'capability' => 'manage_options', |
|
125 | + 'noheader' => true, |
|
126 | + ), |
|
127 | + ); |
|
128 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
129 | + //partial route/config override |
|
130 | + $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes; |
|
131 | + $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
132 | + $this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
133 | + $this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
134 | + $this->_page_config['edit']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
135 | + $this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table'; |
|
136 | + //add tickets tab but only if there are more than one default ticket! |
|
137 | + $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
138 | + array(array('TKT_is_default' => 1)), |
|
139 | + 'TKT_ID', |
|
140 | + true |
|
141 | + ); |
|
142 | + if ($tkt_count > 1) { |
|
143 | + $new_page_config = array( |
|
144 | + 'ticket_list_table' => array( |
|
145 | + 'nav' => array( |
|
146 | + 'label' => esc_html__('Default Tickets', 'event_espresso'), |
|
147 | + 'order' => 60, |
|
148 | + ), |
|
149 | + 'list_table' => 'Tickets_List_Table', |
|
150 | + 'require_nonce' => false, |
|
151 | + ), |
|
152 | + ); |
|
153 | + } |
|
154 | + //template settings |
|
155 | + $new_page_config['template_settings'] = array( |
|
156 | + 'nav' => array( |
|
157 | + 'label' => esc_html__('Templates', 'event_espresso'), |
|
158 | + 'order' => 30, |
|
159 | + ), |
|
160 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
161 | + 'help_tabs' => array( |
|
162 | + 'general_settings_templates_help_tab' => array( |
|
163 | + 'title' => esc_html__('Templates', 'event_espresso'), |
|
164 | + 'filename' => 'general_settings_templates', |
|
165 | + ), |
|
166 | + ), |
|
167 | + 'help_tour' => array('Templates_Help_Tour'), |
|
168 | + 'require_nonce' => false, |
|
169 | + ); |
|
170 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
171 | + //add filters and actions |
|
172 | + //modifying _views |
|
173 | + add_filter( |
|
174 | + 'FHEE_event_datetime_metabox_add_additional_date_time_template', |
|
175 | + array($this, 'add_additional_datetime_button'), |
|
176 | + 10, |
|
177 | + 2 |
|
178 | + ); |
|
179 | + add_filter( |
|
180 | + 'FHEE_event_datetime_metabox_clone_button_template', |
|
181 | + array($this, 'add_datetime_clone_button'), |
|
182 | + 10, |
|
183 | + 2 |
|
184 | + ); |
|
185 | + add_filter( |
|
186 | + 'FHEE_event_datetime_metabox_timezones_template', |
|
187 | + array($this, 'datetime_timezones_template'), |
|
188 | + 10, |
|
189 | + 2 |
|
190 | + ); |
|
191 | + //filters for event list table |
|
192 | + add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2); |
|
193 | + add_filter( |
|
194 | + 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
195 | + array($this, 'extra_list_table_actions'), |
|
196 | + 10, |
|
197 | + 2 |
|
198 | + ); |
|
199 | + //legend item |
|
200 | + add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items')); |
|
201 | + add_action('admin_init', array($this, 'admin_init')); |
|
202 | + //heartbeat stuff |
|
203 | + add_filter('heartbeat_received', array($this, 'heartbeat_response'), 10, 2); |
|
204 | + } |
|
205 | + |
|
206 | + |
|
207 | + /** |
|
208 | + * admin_init |
|
209 | + */ |
|
210 | + public function admin_init() |
|
211 | + { |
|
212 | + EE_Registry::$i18n_js_strings = array_merge( |
|
213 | + EE_Registry::$i18n_js_strings, |
|
214 | + array( |
|
215 | + 'image_confirm' => esc_html__( |
|
216 | + 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
217 | + 'event_espresso' |
|
218 | + ), |
|
219 | + 'event_starts_on' => esc_html__('Event Starts on', 'event_espresso'), |
|
220 | + 'event_ends_on' => esc_html__('Event Ends on', 'event_espresso'), |
|
221 | + 'event_datetime_actions' => esc_html__('Actions', 'event_espresso'), |
|
222 | + 'event_clone_dt_msg' => esc_html__('Clone this Event Date and Time', 'event_espresso'), |
|
223 | + 'remove_event_dt_msg' => esc_html__('Remove this Event Time', 'event_espresso'), |
|
224 | + ) |
|
225 | + ); |
|
226 | + } |
|
227 | + |
|
228 | + |
|
229 | + /** |
|
230 | + * This will be used to listen for any heartbeat data packages coming via the WordPress heartbeat API and handle |
|
231 | + * accordingly. |
|
232 | + * |
|
233 | + * @param array $response The existing heartbeat response array. |
|
234 | + * @param array $data The incoming data package. |
|
235 | + * |
|
236 | + * @return array possibly appended response. |
|
237 | + */ |
|
238 | + public function heartbeat_response($response, $data) |
|
239 | + { |
|
240 | + /** |
|
241 | + * check whether count of tickets is approaching the potential |
|
242 | + * limits for the server. |
|
243 | + */ |
|
244 | + if ( ! empty($data['input_count'])) { |
|
245 | + $response['max_input_vars_check'] = EE_Registry::instance()->CFG->environment->max_input_vars_limit_check( |
|
246 | + $data['input_count'] |
|
247 | + ); |
|
248 | + } |
|
249 | 249 | |
250 | - return $response; |
|
251 | - } |
|
252 | - |
|
253 | - |
|
254 | - protected function _add_screen_options_ticket_list_table() |
|
255 | - { |
|
256 | - $this->_per_page_screen_option(); |
|
257 | - } |
|
258 | - |
|
259 | - |
|
260 | - /** |
|
261 | - * @param string $return |
|
262 | - * @param int $id |
|
263 | - * @param string $new_title |
|
264 | - * @param string $new_slug |
|
265 | - * |
|
266 | - * @return string |
|
267 | - */ |
|
268 | - public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
269 | - { |
|
270 | - $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug); |
|
271 | - //make sure this is only when editing |
|
272 | - if ( ! empty($id)) { |
|
273 | - $href = EE_Admin_Page::add_query_args_and_nonce( |
|
274 | - array('action' => 'duplicate_event', 'EVT_ID' => $id), |
|
275 | - $this->_admin_base_url |
|
276 | - ); |
|
277 | - $title = esc_attr__('Duplicate Event', 'event_espresso'); |
|
278 | - $return .= '<a href="' |
|
279 | - . $href |
|
280 | - . '" title="' |
|
281 | - . $title |
|
282 | - . '" id="ee-duplicate-event-button" class="button button-small" value="duplicate_event">' |
|
283 | - . $title |
|
284 | - . '</button>'; |
|
285 | - } |
|
250 | + return $response; |
|
251 | + } |
|
252 | + |
|
253 | + |
|
254 | + protected function _add_screen_options_ticket_list_table() |
|
255 | + { |
|
256 | + $this->_per_page_screen_option(); |
|
257 | + } |
|
258 | + |
|
259 | + |
|
260 | + /** |
|
261 | + * @param string $return |
|
262 | + * @param int $id |
|
263 | + * @param string $new_title |
|
264 | + * @param string $new_slug |
|
265 | + * |
|
266 | + * @return string |
|
267 | + */ |
|
268 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
269 | + { |
|
270 | + $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug); |
|
271 | + //make sure this is only when editing |
|
272 | + if ( ! empty($id)) { |
|
273 | + $href = EE_Admin_Page::add_query_args_and_nonce( |
|
274 | + array('action' => 'duplicate_event', 'EVT_ID' => $id), |
|
275 | + $this->_admin_base_url |
|
276 | + ); |
|
277 | + $title = esc_attr__('Duplicate Event', 'event_espresso'); |
|
278 | + $return .= '<a href="' |
|
279 | + . $href |
|
280 | + . '" title="' |
|
281 | + . $title |
|
282 | + . '" id="ee-duplicate-event-button" class="button button-small" value="duplicate_event">' |
|
283 | + . $title |
|
284 | + . '</button>'; |
|
285 | + } |
|
286 | 286 | |
287 | - return $return; |
|
288 | - } |
|
289 | - |
|
290 | - |
|
291 | - public function _set_list_table_views_ticket_list_table() |
|
292 | - { |
|
293 | - $this->_views = array( |
|
294 | - 'all' => array( |
|
295 | - 'slug' => 'all', |
|
296 | - 'label' => esc_html__('All', 'event_espresso'), |
|
297 | - 'count' => 0, |
|
298 | - 'bulk_action' => array( |
|
299 | - 'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'), |
|
300 | - ), |
|
301 | - ), |
|
302 | - 'trashed' => array( |
|
303 | - 'slug' => 'trashed', |
|
304 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
305 | - 'count' => 0, |
|
306 | - 'bulk_action' => array( |
|
307 | - 'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'), |
|
308 | - 'delete_tickets' => esc_html__('Delete Permanently', 'event_espresso'), |
|
309 | - ), |
|
310 | - ), |
|
311 | - ); |
|
312 | - } |
|
313 | - |
|
314 | - |
|
315 | - public function load_scripts_styles_edit() |
|
316 | - { |
|
317 | - wp_register_script( |
|
318 | - 'ee-event-editor-heartbeat', |
|
319 | - EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', |
|
320 | - array('ee_admin_js', 'heartbeat'), |
|
321 | - EVENT_ESPRESSO_VERSION, |
|
322 | - true |
|
323 | - ); |
|
324 | - /** |
|
325 | - * load accounting js. |
|
326 | - */ |
|
327 | - add_filter('FHEE_load_accounting_js', '__return_true'); |
|
328 | - //styles |
|
329 | - wp_enqueue_style('espresso-ui-theme'); |
|
330 | - wp_enqueue_script('event_editor_js'); |
|
331 | - wp_enqueue_script('ee-event-editor-heartbeat'); |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - /** |
|
336 | - * @param $template |
|
337 | - * @param $template_args |
|
338 | - * |
|
339 | - * @return mixed |
|
340 | - */ |
|
341 | - public function add_additional_datetime_button($template, $template_args) |
|
342 | - { |
|
343 | - return EEH_Template::display_template( |
|
344 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php', |
|
345 | - $template_args, |
|
346 | - true |
|
347 | - ); |
|
348 | - } |
|
349 | - |
|
350 | - |
|
351 | - /** |
|
352 | - * @param $template |
|
353 | - * @param $template_args |
|
354 | - * |
|
355 | - * @return mixed |
|
356 | - */ |
|
357 | - public function add_datetime_clone_button($template, $template_args) |
|
358 | - { |
|
359 | - return EEH_Template::display_template( |
|
360 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php', |
|
361 | - $template_args, |
|
362 | - true |
|
363 | - ); |
|
364 | - } |
|
365 | - |
|
366 | - |
|
367 | - /** |
|
368 | - * @param $template |
|
369 | - * @param $template_args |
|
370 | - * |
|
371 | - * @return mixed |
|
372 | - */ |
|
373 | - public function datetime_timezones_template($template, $template_args) |
|
374 | - { |
|
375 | - return EEH_Template::display_template( |
|
376 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php', |
|
377 | - $template_args, |
|
378 | - true |
|
379 | - ); |
|
380 | - } |
|
381 | - |
|
382 | - |
|
383 | - protected function _set_list_table_views_default() |
|
384 | - { |
|
385 | - parent::_set_list_table_views_default(); |
|
386 | - $new_views = array( |
|
387 | - 'today' => array( |
|
388 | - 'slug' => 'today', |
|
389 | - 'label' => esc_html__('Today', 'event_espresso'), |
|
390 | - 'count' => $this->total_events_today(), |
|
391 | - 'bulk_action' => array( |
|
392 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
393 | - ), |
|
394 | - ), |
|
395 | - 'month' => array( |
|
396 | - 'slug' => 'month', |
|
397 | - 'label' => esc_html__('This Month', 'event_espresso'), |
|
398 | - 'count' => $this->total_events_this_month(), |
|
399 | - 'bulk_action' => array( |
|
400 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
401 | - ), |
|
402 | - ), |
|
403 | - ); |
|
404 | - $this->_views = array_merge($this->_views, $new_views); |
|
405 | - } |
|
406 | - |
|
407 | - |
|
408 | - /** |
|
409 | - * @param array $action_links |
|
410 | - * @param \EE_Event $event |
|
411 | - * |
|
412 | - * @return array |
|
413 | - */ |
|
414 | - public function extra_list_table_actions(array $action_links, \EE_Event $event) |
|
415 | - { |
|
416 | - if ( |
|
417 | - EE_Registry::instance()->CAP->current_user_can( |
|
418 | - 'ee_read_registrations', |
|
419 | - 'espresso_registrations_reports', |
|
420 | - $event->ID() |
|
421 | - ) |
|
422 | - ) { |
|
423 | - $reports_query_args = array( |
|
424 | - 'action' => 'reports', |
|
425 | - 'EVT_ID' => $event->ID(), |
|
426 | - ); |
|
427 | - $reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL); |
|
428 | - $action_links[] = '<a href="' |
|
429 | - . $reports_link |
|
430 | - . '" title="' |
|
431 | - . esc_attr__('View Report', 'event_espresso') |
|
432 | - . '"><div class="dashicons dashicons-chart-bar"></div></a>' |
|
433 | - . "\n\t"; |
|
434 | - } |
|
435 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
436 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
437 | - $action_links[] = EEH_MSG_Template::get_message_action_link( |
|
438 | - 'see_notifications_for', |
|
439 | - null, |
|
440 | - array('EVT_ID' => $event->ID()) |
|
441 | - ); |
|
442 | - } |
|
287 | + return $return; |
|
288 | + } |
|
289 | + |
|
290 | + |
|
291 | + public function _set_list_table_views_ticket_list_table() |
|
292 | + { |
|
293 | + $this->_views = array( |
|
294 | + 'all' => array( |
|
295 | + 'slug' => 'all', |
|
296 | + 'label' => esc_html__('All', 'event_espresso'), |
|
297 | + 'count' => 0, |
|
298 | + 'bulk_action' => array( |
|
299 | + 'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'), |
|
300 | + ), |
|
301 | + ), |
|
302 | + 'trashed' => array( |
|
303 | + 'slug' => 'trashed', |
|
304 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
305 | + 'count' => 0, |
|
306 | + 'bulk_action' => array( |
|
307 | + 'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'), |
|
308 | + 'delete_tickets' => esc_html__('Delete Permanently', 'event_espresso'), |
|
309 | + ), |
|
310 | + ), |
|
311 | + ); |
|
312 | + } |
|
313 | + |
|
314 | + |
|
315 | + public function load_scripts_styles_edit() |
|
316 | + { |
|
317 | + wp_register_script( |
|
318 | + 'ee-event-editor-heartbeat', |
|
319 | + EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', |
|
320 | + array('ee_admin_js', 'heartbeat'), |
|
321 | + EVENT_ESPRESSO_VERSION, |
|
322 | + true |
|
323 | + ); |
|
324 | + /** |
|
325 | + * load accounting js. |
|
326 | + */ |
|
327 | + add_filter('FHEE_load_accounting_js', '__return_true'); |
|
328 | + //styles |
|
329 | + wp_enqueue_style('espresso-ui-theme'); |
|
330 | + wp_enqueue_script('event_editor_js'); |
|
331 | + wp_enqueue_script('ee-event-editor-heartbeat'); |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + /** |
|
336 | + * @param $template |
|
337 | + * @param $template_args |
|
338 | + * |
|
339 | + * @return mixed |
|
340 | + */ |
|
341 | + public function add_additional_datetime_button($template, $template_args) |
|
342 | + { |
|
343 | + return EEH_Template::display_template( |
|
344 | + EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php', |
|
345 | + $template_args, |
|
346 | + true |
|
347 | + ); |
|
348 | + } |
|
349 | + |
|
350 | + |
|
351 | + /** |
|
352 | + * @param $template |
|
353 | + * @param $template_args |
|
354 | + * |
|
355 | + * @return mixed |
|
356 | + */ |
|
357 | + public function add_datetime_clone_button($template, $template_args) |
|
358 | + { |
|
359 | + return EEH_Template::display_template( |
|
360 | + EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php', |
|
361 | + $template_args, |
|
362 | + true |
|
363 | + ); |
|
364 | + } |
|
365 | + |
|
366 | + |
|
367 | + /** |
|
368 | + * @param $template |
|
369 | + * @param $template_args |
|
370 | + * |
|
371 | + * @return mixed |
|
372 | + */ |
|
373 | + public function datetime_timezones_template($template, $template_args) |
|
374 | + { |
|
375 | + return EEH_Template::display_template( |
|
376 | + EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php', |
|
377 | + $template_args, |
|
378 | + true |
|
379 | + ); |
|
380 | + } |
|
381 | + |
|
382 | + |
|
383 | + protected function _set_list_table_views_default() |
|
384 | + { |
|
385 | + parent::_set_list_table_views_default(); |
|
386 | + $new_views = array( |
|
387 | + 'today' => array( |
|
388 | + 'slug' => 'today', |
|
389 | + 'label' => esc_html__('Today', 'event_espresso'), |
|
390 | + 'count' => $this->total_events_today(), |
|
391 | + 'bulk_action' => array( |
|
392 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
393 | + ), |
|
394 | + ), |
|
395 | + 'month' => array( |
|
396 | + 'slug' => 'month', |
|
397 | + 'label' => esc_html__('This Month', 'event_espresso'), |
|
398 | + 'count' => $this->total_events_this_month(), |
|
399 | + 'bulk_action' => array( |
|
400 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
401 | + ), |
|
402 | + ), |
|
403 | + ); |
|
404 | + $this->_views = array_merge($this->_views, $new_views); |
|
405 | + } |
|
406 | + |
|
407 | + |
|
408 | + /** |
|
409 | + * @param array $action_links |
|
410 | + * @param \EE_Event $event |
|
411 | + * |
|
412 | + * @return array |
|
413 | + */ |
|
414 | + public function extra_list_table_actions(array $action_links, \EE_Event $event) |
|
415 | + { |
|
416 | + if ( |
|
417 | + EE_Registry::instance()->CAP->current_user_can( |
|
418 | + 'ee_read_registrations', |
|
419 | + 'espresso_registrations_reports', |
|
420 | + $event->ID() |
|
421 | + ) |
|
422 | + ) { |
|
423 | + $reports_query_args = array( |
|
424 | + 'action' => 'reports', |
|
425 | + 'EVT_ID' => $event->ID(), |
|
426 | + ); |
|
427 | + $reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL); |
|
428 | + $action_links[] = '<a href="' |
|
429 | + . $reports_link |
|
430 | + . '" title="' |
|
431 | + . esc_attr__('View Report', 'event_espresso') |
|
432 | + . '"><div class="dashicons dashicons-chart-bar"></div></a>' |
|
433 | + . "\n\t"; |
|
434 | + } |
|
435 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
436 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
437 | + $action_links[] = EEH_MSG_Template::get_message_action_link( |
|
438 | + 'see_notifications_for', |
|
439 | + null, |
|
440 | + array('EVT_ID' => $event->ID()) |
|
441 | + ); |
|
442 | + } |
|
443 | 443 | |
444 | - return $action_links; |
|
445 | - } |
|
446 | - |
|
447 | - |
|
448 | - /** |
|
449 | - * @param $items |
|
450 | - * |
|
451 | - * @return mixed |
|
452 | - */ |
|
453 | - public function additional_legend_items($items) |
|
454 | - { |
|
455 | - if ( |
|
456 | - EE_Registry::instance()->CAP->current_user_can( |
|
457 | - 'ee_read_registrations', |
|
458 | - 'espresso_registrations_reports' |
|
459 | - ) |
|
460 | - ) { |
|
461 | - $items['reports'] = array( |
|
462 | - 'class' => 'dashicons dashicons-chart-bar', |
|
463 | - 'desc' => esc_html__('Event Reports', 'event_espresso'), |
|
464 | - ); |
|
465 | - } |
|
466 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
467 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
468 | - if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
469 | - $items['view_related_messages'] = array( |
|
470 | - 'class' => $related_for_icon['css_class'], |
|
471 | - 'desc' => $related_for_icon['label'], |
|
472 | - ); |
|
473 | - } |
|
474 | - } |
|
444 | + return $action_links; |
|
445 | + } |
|
446 | + |
|
447 | + |
|
448 | + /** |
|
449 | + * @param $items |
|
450 | + * |
|
451 | + * @return mixed |
|
452 | + */ |
|
453 | + public function additional_legend_items($items) |
|
454 | + { |
|
455 | + if ( |
|
456 | + EE_Registry::instance()->CAP->current_user_can( |
|
457 | + 'ee_read_registrations', |
|
458 | + 'espresso_registrations_reports' |
|
459 | + ) |
|
460 | + ) { |
|
461 | + $items['reports'] = array( |
|
462 | + 'class' => 'dashicons dashicons-chart-bar', |
|
463 | + 'desc' => esc_html__('Event Reports', 'event_espresso'), |
|
464 | + ); |
|
465 | + } |
|
466 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
467 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
468 | + if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
469 | + $items['view_related_messages'] = array( |
|
470 | + 'class' => $related_for_icon['css_class'], |
|
471 | + 'desc' => $related_for_icon['label'], |
|
472 | + ); |
|
473 | + } |
|
474 | + } |
|
475 | 475 | |
476 | - return $items; |
|
477 | - } |
|
478 | - |
|
479 | - |
|
480 | - /** |
|
481 | - * This is the callback method for the duplicate event route |
|
482 | - * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them |
|
483 | - * into a new event. We add a hook so that any plugins that add extra event details can hook into this |
|
484 | - * action. Note that the dupe will have **DUPLICATE** as its title and slug. |
|
485 | - * After duplication the redirect is to the new event edit page. |
|
486 | - * |
|
487 | - * @return void |
|
488 | - * @access protected |
|
489 | - * @throws EE_Error If EE_Event is not available with given ID |
|
490 | - */ |
|
491 | - protected function _duplicate_event() |
|
492 | - { |
|
493 | - // first make sure the ID for the event is in the request. |
|
494 | - // If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?) |
|
495 | - if ( ! isset($this->_req_data['EVT_ID'])) { |
|
496 | - EE_Error::add_error( |
|
497 | - esc_html__( |
|
498 | - 'In order to duplicate an event an Event ID is required. None was given.', |
|
499 | - 'event_espresso' |
|
500 | - ), |
|
501 | - __FILE__, |
|
502 | - __FUNCTION__, |
|
503 | - __LINE__ |
|
504 | - ); |
|
505 | - $this->_redirect_after_action(false, '', '', array(), true); |
|
476 | + return $items; |
|
477 | + } |
|
478 | + |
|
479 | + |
|
480 | + /** |
|
481 | + * This is the callback method for the duplicate event route |
|
482 | + * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them |
|
483 | + * into a new event. We add a hook so that any plugins that add extra event details can hook into this |
|
484 | + * action. Note that the dupe will have **DUPLICATE** as its title and slug. |
|
485 | + * After duplication the redirect is to the new event edit page. |
|
486 | + * |
|
487 | + * @return void |
|
488 | + * @access protected |
|
489 | + * @throws EE_Error If EE_Event is not available with given ID |
|
490 | + */ |
|
491 | + protected function _duplicate_event() |
|
492 | + { |
|
493 | + // first make sure the ID for the event is in the request. |
|
494 | + // If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?) |
|
495 | + if ( ! isset($this->_req_data['EVT_ID'])) { |
|
496 | + EE_Error::add_error( |
|
497 | + esc_html__( |
|
498 | + 'In order to duplicate an event an Event ID is required. None was given.', |
|
499 | + 'event_espresso' |
|
500 | + ), |
|
501 | + __FILE__, |
|
502 | + __FUNCTION__, |
|
503 | + __LINE__ |
|
504 | + ); |
|
505 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
506 | 506 | |
507 | - return; |
|
508 | - } |
|
509 | - //k we've got EVT_ID so let's use that to get the event we'll duplicate |
|
510 | - $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']); |
|
511 | - if ( ! $orig_event instanceof EE_Event) { |
|
512 | - throw new EE_Error( |
|
513 | - sprintf( |
|
514 | - esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), |
|
515 | - $this->_req_data['EVT_ID'] |
|
516 | - ) |
|
517 | - ); |
|
518 | - } |
|
519 | - //k now let's clone the $orig_event before getting relations |
|
520 | - $new_event = clone $orig_event; |
|
521 | - //original datetimes |
|
522 | - $orig_datetimes = $orig_event->get_many_related('Datetime'); |
|
523 | - //other original relations |
|
524 | - $orig_ven = $orig_event->get_many_related('Venue'); |
|
525 | - //reset the ID and modify other details to make it clear this is a dupe |
|
526 | - $new_event->set('EVT_ID', 0); |
|
527 | - $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso'); |
|
528 | - $new_event->set('EVT_name', $new_name); |
|
529 | - $new_event->set( |
|
530 | - 'EVT_slug', |
|
531 | - wp_unique_post_slug( |
|
532 | - sanitize_title($orig_event->name()), |
|
533 | - 0, |
|
534 | - 'publish', |
|
535 | - 'espresso_events', |
|
536 | - 0 |
|
537 | - ) |
|
538 | - ); |
|
539 | - $new_event->set('status', 'draft'); |
|
540 | - //duplicate discussion settings |
|
541 | - $new_event->set('comment_status', $orig_event->get('comment_status')); |
|
542 | - $new_event->set('ping_status', $orig_event->get('ping_status')); |
|
543 | - //save the new event |
|
544 | - $new_event->save(); |
|
545 | - //venues |
|
546 | - foreach ($orig_ven as $ven) { |
|
547 | - $new_event->_add_relation_to($ven, 'Venue'); |
|
548 | - } |
|
549 | - $new_event->save(); |
|
550 | - //now we need to get the question group relations and handle that |
|
551 | - //first primary question groups |
|
552 | - $orig_primary_qgs = $orig_event->get_many_related( |
|
553 | - 'Question_Group', |
|
554 | - array(array('Event_Question_Group.EQG_primary' => 1)) |
|
555 | - ); |
|
556 | - if ( ! empty($orig_primary_qgs)) { |
|
557 | - foreach ($orig_primary_qgs as $id => $obj) { |
|
558 | - if ($obj instanceof EE_Question_Group) { |
|
559 | - $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 1)); |
|
560 | - } |
|
561 | - } |
|
562 | - } |
|
563 | - //next additional attendee question groups |
|
564 | - $orig_additional_qgs = $orig_event->get_many_related( |
|
565 | - 'Question_Group', |
|
566 | - array(array('Event_Question_Group.EQG_primary' => 0)) |
|
567 | - ); |
|
568 | - if ( ! empty($orig_additional_qgs)) { |
|
569 | - foreach ($orig_additional_qgs as $id => $obj) { |
|
570 | - if ($obj instanceof EE_Question_Group) { |
|
571 | - $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 0)); |
|
572 | - } |
|
573 | - } |
|
574 | - } |
|
575 | - //now save |
|
576 | - $new_event->save(); |
|
577 | - //k now that we have the new event saved we can loop through the datetimes and start adding relations. |
|
578 | - $cloned_tickets = array(); |
|
579 | - foreach ($orig_datetimes as $orig_dtt) { |
|
580 | - if ( ! $orig_dtt instanceof EE_Datetime) { |
|
581 | - continue; |
|
582 | - } |
|
583 | - $new_dtt = clone $orig_dtt; |
|
584 | - $orig_tkts = $orig_dtt->tickets(); |
|
585 | - //save new dtt then add to event |
|
586 | - $new_dtt->set('DTT_ID', 0); |
|
587 | - $new_dtt->set('DTT_sold', 0); |
|
588 | - $new_dtt->save(); |
|
589 | - $new_event->_add_relation_to($new_dtt, 'Datetime'); |
|
590 | - $new_event->save(); |
|
591 | - //now let's get the ticket relations setup. |
|
592 | - foreach ((array)$orig_tkts as $orig_tkt) { |
|
593 | - //it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
|
594 | - if ( ! $orig_tkt instanceof EE_Ticket) { |
|
595 | - continue; |
|
596 | - } |
|
597 | - //is this ticket archived? If it is then let's skip |
|
598 | - if ($orig_tkt->get('TKT_deleted')) { |
|
599 | - continue; |
|
600 | - } |
|
601 | - // does this original ticket already exist in the clone_tickets cache? |
|
602 | - // If so we'll just use the new ticket from it. |
|
603 | - if (isset($cloned_tickets[$orig_tkt->ID()])) { |
|
604 | - $new_tkt = $cloned_tickets[$orig_tkt->ID()]; |
|
605 | - } else { |
|
606 | - $new_tkt = clone $orig_tkt; |
|
607 | - //get relations on the $orig_tkt that we need to setup. |
|
608 | - $orig_prices = $orig_tkt->prices(); |
|
609 | - $new_tkt->set('TKT_ID', 0); |
|
610 | - $new_tkt->set('TKT_sold', 0); |
|
611 | - $new_tkt->save(); //make sure new ticket has ID. |
|
612 | - //price relations on new ticket need to be setup. |
|
613 | - foreach ($orig_prices as $orig_price) { |
|
614 | - $new_price = clone $orig_price; |
|
615 | - $new_price->set('PRC_ID', 0); |
|
616 | - $new_price->save(); |
|
617 | - $new_tkt->_add_relation_to($new_price, 'Price'); |
|
618 | - $new_tkt->save(); |
|
619 | - } |
|
620 | - } |
|
621 | - // k now we can add the new ticket as a relation to the new datetime |
|
622 | - // and make sure its added to our cached $cloned_tickets array |
|
623 | - // for use with later datetimes that have the same ticket. |
|
624 | - $new_dtt->_add_relation_to($new_tkt, 'Ticket'); |
|
625 | - $new_dtt->save(); |
|
626 | - $cloned_tickets[$orig_tkt->ID()] = $new_tkt; |
|
627 | - } |
|
628 | - } |
|
629 | - //clone taxonomy information |
|
630 | - $taxonomies_to_clone_with = apply_filters( |
|
631 | - 'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', |
|
632 | - array('espresso_event_categories', 'espresso_event_type', 'post_tag') |
|
633 | - ); |
|
634 | - //get terms for original event (notice) |
|
635 | - $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with); |
|
636 | - //loop through terms and add them to new event. |
|
637 | - foreach ($orig_terms as $term) { |
|
638 | - wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true); |
|
639 | - } |
|
640 | - do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event); |
|
641 | - //now let's redirect to the edit page for this duplicated event if we have a new event id. |
|
642 | - if ($new_event->ID()) { |
|
643 | - $redirect_args = array( |
|
644 | - 'post' => $new_event->ID(), |
|
645 | - 'action' => 'edit', |
|
646 | - ); |
|
647 | - EE_Error::add_success( |
|
648 | - esc_html__( |
|
649 | - 'Event successfully duplicated. Please review the details below and make any necessary edits', |
|
650 | - 'event_espresso' |
|
651 | - ) |
|
652 | - ); |
|
653 | - } else { |
|
654 | - $redirect_args = array( |
|
655 | - 'action' => 'default', |
|
656 | - ); |
|
657 | - EE_Error::add_error( |
|
658 | - esc_html__('Not able to duplicate event. Something went wrong.', 'event_espresso'), |
|
659 | - __FILE__, |
|
660 | - __FUNCTION__, |
|
661 | - __LINE__ |
|
662 | - ); |
|
663 | - } |
|
664 | - $this->_redirect_after_action(false, '', '', $redirect_args, true); |
|
665 | - } |
|
666 | - |
|
667 | - |
|
668 | - protected function _import_page() |
|
669 | - { |
|
670 | - $title = esc_html__('Import', 'event_espresso'); |
|
671 | - $intro = esc_html__( |
|
672 | - 'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ', |
|
673 | - 'event_espresso' |
|
674 | - ); |
|
675 | - $form_url = EVENTS_ADMIN_URL; |
|
676 | - $action = 'import_events'; |
|
677 | - $type = 'csv'; |
|
678 | - $this->_template_args['form'] = EE_Import::instance()->upload_form($title, $intro, $form_url, |
|
679 | - $action, $type); |
|
680 | - $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
681 | - array('action' => 'sample_export_file'), |
|
682 | - $this->_admin_base_url |
|
683 | - ); |
|
684 | - $content = EEH_Template::display_template( |
|
685 | - EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php', |
|
686 | - $this->_template_args, |
|
687 | - true |
|
688 | - ); |
|
689 | - $this->_template_args['admin_page_content'] = $content; |
|
690 | - $this->display_admin_page_with_sidebar(); |
|
691 | - } |
|
692 | - |
|
693 | - |
|
694 | - /** |
|
695 | - * _import_events |
|
696 | - * This handles displaying the screen and running imports for importing events. |
|
697 | - * |
|
698 | - * @return void |
|
699 | - */ |
|
700 | - protected function _import_events() |
|
701 | - { |
|
702 | - require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
703 | - $success = EE_Import::instance()->import(); |
|
704 | - $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true); |
|
705 | - } |
|
706 | - |
|
707 | - |
|
708 | - /** |
|
709 | - * _events_export |
|
710 | - * Will export all (or just the given event) to a Excel compatible file. |
|
711 | - * |
|
712 | - * @access protected |
|
713 | - * @return void |
|
714 | - */ |
|
715 | - protected function _events_export() |
|
716 | - { |
|
717 | - if (isset($this->_req_data['EVT_ID'])) { |
|
718 | - $event_ids = $this->_req_data['EVT_ID']; |
|
719 | - } elseif (isset($this->_req_data['EVT_IDs'])) { |
|
720 | - $event_ids = $this->_req_data['EVT_IDs']; |
|
721 | - } else { |
|
722 | - $event_ids = null; |
|
723 | - } |
|
724 | - //todo: I don't like doing this but it'll do until we modify EE_Export Class. |
|
725 | - $new_request_args = array( |
|
726 | - 'export' => 'report', |
|
727 | - 'action' => 'all_event_data', |
|
728 | - 'EVT_ID' => $event_ids, |
|
729 | - ); |
|
730 | - $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
731 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
732 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
733 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
734 | - $EE_Export->export(); |
|
735 | - } |
|
736 | - } |
|
737 | - |
|
738 | - |
|
739 | - /** |
|
740 | - * handle category exports() |
|
741 | - * |
|
742 | - * @return void |
|
743 | - */ |
|
744 | - protected function _categories_export() |
|
745 | - { |
|
746 | - //todo: I don't like doing this but it'll do until we modify EE_Export Class. |
|
747 | - $new_request_args = array( |
|
748 | - 'export' => 'report', |
|
749 | - 'action' => 'categories', |
|
750 | - 'category_ids' => $this->_req_data['EVT_CAT_ID'], |
|
751 | - ); |
|
752 | - $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
753 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
754 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
755 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
756 | - $EE_Export->export(); |
|
757 | - } |
|
758 | - } |
|
759 | - |
|
760 | - |
|
761 | - /** |
|
762 | - * Creates a sample CSV file for importing |
|
763 | - */ |
|
764 | - protected function _sample_export_file() |
|
765 | - { |
|
507 | + return; |
|
508 | + } |
|
509 | + //k we've got EVT_ID so let's use that to get the event we'll duplicate |
|
510 | + $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']); |
|
511 | + if ( ! $orig_event instanceof EE_Event) { |
|
512 | + throw new EE_Error( |
|
513 | + sprintf( |
|
514 | + esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), |
|
515 | + $this->_req_data['EVT_ID'] |
|
516 | + ) |
|
517 | + ); |
|
518 | + } |
|
519 | + //k now let's clone the $orig_event before getting relations |
|
520 | + $new_event = clone $orig_event; |
|
521 | + //original datetimes |
|
522 | + $orig_datetimes = $orig_event->get_many_related('Datetime'); |
|
523 | + //other original relations |
|
524 | + $orig_ven = $orig_event->get_many_related('Venue'); |
|
525 | + //reset the ID and modify other details to make it clear this is a dupe |
|
526 | + $new_event->set('EVT_ID', 0); |
|
527 | + $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso'); |
|
528 | + $new_event->set('EVT_name', $new_name); |
|
529 | + $new_event->set( |
|
530 | + 'EVT_slug', |
|
531 | + wp_unique_post_slug( |
|
532 | + sanitize_title($orig_event->name()), |
|
533 | + 0, |
|
534 | + 'publish', |
|
535 | + 'espresso_events', |
|
536 | + 0 |
|
537 | + ) |
|
538 | + ); |
|
539 | + $new_event->set('status', 'draft'); |
|
540 | + //duplicate discussion settings |
|
541 | + $new_event->set('comment_status', $orig_event->get('comment_status')); |
|
542 | + $new_event->set('ping_status', $orig_event->get('ping_status')); |
|
543 | + //save the new event |
|
544 | + $new_event->save(); |
|
545 | + //venues |
|
546 | + foreach ($orig_ven as $ven) { |
|
547 | + $new_event->_add_relation_to($ven, 'Venue'); |
|
548 | + } |
|
549 | + $new_event->save(); |
|
550 | + //now we need to get the question group relations and handle that |
|
551 | + //first primary question groups |
|
552 | + $orig_primary_qgs = $orig_event->get_many_related( |
|
553 | + 'Question_Group', |
|
554 | + array(array('Event_Question_Group.EQG_primary' => 1)) |
|
555 | + ); |
|
556 | + if ( ! empty($orig_primary_qgs)) { |
|
557 | + foreach ($orig_primary_qgs as $id => $obj) { |
|
558 | + if ($obj instanceof EE_Question_Group) { |
|
559 | + $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 1)); |
|
560 | + } |
|
561 | + } |
|
562 | + } |
|
563 | + //next additional attendee question groups |
|
564 | + $orig_additional_qgs = $orig_event->get_many_related( |
|
565 | + 'Question_Group', |
|
566 | + array(array('Event_Question_Group.EQG_primary' => 0)) |
|
567 | + ); |
|
568 | + if ( ! empty($orig_additional_qgs)) { |
|
569 | + foreach ($orig_additional_qgs as $id => $obj) { |
|
570 | + if ($obj instanceof EE_Question_Group) { |
|
571 | + $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 0)); |
|
572 | + } |
|
573 | + } |
|
574 | + } |
|
575 | + //now save |
|
576 | + $new_event->save(); |
|
577 | + //k now that we have the new event saved we can loop through the datetimes and start adding relations. |
|
578 | + $cloned_tickets = array(); |
|
579 | + foreach ($orig_datetimes as $orig_dtt) { |
|
580 | + if ( ! $orig_dtt instanceof EE_Datetime) { |
|
581 | + continue; |
|
582 | + } |
|
583 | + $new_dtt = clone $orig_dtt; |
|
584 | + $orig_tkts = $orig_dtt->tickets(); |
|
585 | + //save new dtt then add to event |
|
586 | + $new_dtt->set('DTT_ID', 0); |
|
587 | + $new_dtt->set('DTT_sold', 0); |
|
588 | + $new_dtt->save(); |
|
589 | + $new_event->_add_relation_to($new_dtt, 'Datetime'); |
|
590 | + $new_event->save(); |
|
591 | + //now let's get the ticket relations setup. |
|
592 | + foreach ((array)$orig_tkts as $orig_tkt) { |
|
593 | + //it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
|
594 | + if ( ! $orig_tkt instanceof EE_Ticket) { |
|
595 | + continue; |
|
596 | + } |
|
597 | + //is this ticket archived? If it is then let's skip |
|
598 | + if ($orig_tkt->get('TKT_deleted')) { |
|
599 | + continue; |
|
600 | + } |
|
601 | + // does this original ticket already exist in the clone_tickets cache? |
|
602 | + // If so we'll just use the new ticket from it. |
|
603 | + if (isset($cloned_tickets[$orig_tkt->ID()])) { |
|
604 | + $new_tkt = $cloned_tickets[$orig_tkt->ID()]; |
|
605 | + } else { |
|
606 | + $new_tkt = clone $orig_tkt; |
|
607 | + //get relations on the $orig_tkt that we need to setup. |
|
608 | + $orig_prices = $orig_tkt->prices(); |
|
609 | + $new_tkt->set('TKT_ID', 0); |
|
610 | + $new_tkt->set('TKT_sold', 0); |
|
611 | + $new_tkt->save(); //make sure new ticket has ID. |
|
612 | + //price relations on new ticket need to be setup. |
|
613 | + foreach ($orig_prices as $orig_price) { |
|
614 | + $new_price = clone $orig_price; |
|
615 | + $new_price->set('PRC_ID', 0); |
|
616 | + $new_price->save(); |
|
617 | + $new_tkt->_add_relation_to($new_price, 'Price'); |
|
618 | + $new_tkt->save(); |
|
619 | + } |
|
620 | + } |
|
621 | + // k now we can add the new ticket as a relation to the new datetime |
|
622 | + // and make sure its added to our cached $cloned_tickets array |
|
623 | + // for use with later datetimes that have the same ticket. |
|
624 | + $new_dtt->_add_relation_to($new_tkt, 'Ticket'); |
|
625 | + $new_dtt->save(); |
|
626 | + $cloned_tickets[$orig_tkt->ID()] = $new_tkt; |
|
627 | + } |
|
628 | + } |
|
629 | + //clone taxonomy information |
|
630 | + $taxonomies_to_clone_with = apply_filters( |
|
631 | + 'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', |
|
632 | + array('espresso_event_categories', 'espresso_event_type', 'post_tag') |
|
633 | + ); |
|
634 | + //get terms for original event (notice) |
|
635 | + $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with); |
|
636 | + //loop through terms and add them to new event. |
|
637 | + foreach ($orig_terms as $term) { |
|
638 | + wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true); |
|
639 | + } |
|
640 | + do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event); |
|
641 | + //now let's redirect to the edit page for this duplicated event if we have a new event id. |
|
642 | + if ($new_event->ID()) { |
|
643 | + $redirect_args = array( |
|
644 | + 'post' => $new_event->ID(), |
|
645 | + 'action' => 'edit', |
|
646 | + ); |
|
647 | + EE_Error::add_success( |
|
648 | + esc_html__( |
|
649 | + 'Event successfully duplicated. Please review the details below and make any necessary edits', |
|
650 | + 'event_espresso' |
|
651 | + ) |
|
652 | + ); |
|
653 | + } else { |
|
654 | + $redirect_args = array( |
|
655 | + 'action' => 'default', |
|
656 | + ); |
|
657 | + EE_Error::add_error( |
|
658 | + esc_html__('Not able to duplicate event. Something went wrong.', 'event_espresso'), |
|
659 | + __FILE__, |
|
660 | + __FUNCTION__, |
|
661 | + __LINE__ |
|
662 | + ); |
|
663 | + } |
|
664 | + $this->_redirect_after_action(false, '', '', $redirect_args, true); |
|
665 | + } |
|
666 | + |
|
667 | + |
|
668 | + protected function _import_page() |
|
669 | + { |
|
670 | + $title = esc_html__('Import', 'event_espresso'); |
|
671 | + $intro = esc_html__( |
|
672 | + 'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ', |
|
673 | + 'event_espresso' |
|
674 | + ); |
|
675 | + $form_url = EVENTS_ADMIN_URL; |
|
676 | + $action = 'import_events'; |
|
677 | + $type = 'csv'; |
|
678 | + $this->_template_args['form'] = EE_Import::instance()->upload_form($title, $intro, $form_url, |
|
679 | + $action, $type); |
|
680 | + $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
681 | + array('action' => 'sample_export_file'), |
|
682 | + $this->_admin_base_url |
|
683 | + ); |
|
684 | + $content = EEH_Template::display_template( |
|
685 | + EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php', |
|
686 | + $this->_template_args, |
|
687 | + true |
|
688 | + ); |
|
689 | + $this->_template_args['admin_page_content'] = $content; |
|
690 | + $this->display_admin_page_with_sidebar(); |
|
691 | + } |
|
692 | + |
|
693 | + |
|
694 | + /** |
|
695 | + * _import_events |
|
696 | + * This handles displaying the screen and running imports for importing events. |
|
697 | + * |
|
698 | + * @return void |
|
699 | + */ |
|
700 | + protected function _import_events() |
|
701 | + { |
|
702 | + require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
703 | + $success = EE_Import::instance()->import(); |
|
704 | + $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true); |
|
705 | + } |
|
706 | + |
|
707 | + |
|
708 | + /** |
|
709 | + * _events_export |
|
710 | + * Will export all (or just the given event) to a Excel compatible file. |
|
711 | + * |
|
712 | + * @access protected |
|
713 | + * @return void |
|
714 | + */ |
|
715 | + protected function _events_export() |
|
716 | + { |
|
717 | + if (isset($this->_req_data['EVT_ID'])) { |
|
718 | + $event_ids = $this->_req_data['EVT_ID']; |
|
719 | + } elseif (isset($this->_req_data['EVT_IDs'])) { |
|
720 | + $event_ids = $this->_req_data['EVT_IDs']; |
|
721 | + } else { |
|
722 | + $event_ids = null; |
|
723 | + } |
|
724 | + //todo: I don't like doing this but it'll do until we modify EE_Export Class. |
|
725 | + $new_request_args = array( |
|
726 | + 'export' => 'report', |
|
727 | + 'action' => 'all_event_data', |
|
728 | + 'EVT_ID' => $event_ids, |
|
729 | + ); |
|
730 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
731 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
732 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
733 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
734 | + $EE_Export->export(); |
|
735 | + } |
|
736 | + } |
|
737 | + |
|
738 | + |
|
739 | + /** |
|
740 | + * handle category exports() |
|
741 | + * |
|
742 | + * @return void |
|
743 | + */ |
|
744 | + protected function _categories_export() |
|
745 | + { |
|
746 | + //todo: I don't like doing this but it'll do until we modify EE_Export Class. |
|
747 | + $new_request_args = array( |
|
748 | + 'export' => 'report', |
|
749 | + 'action' => 'categories', |
|
750 | + 'category_ids' => $this->_req_data['EVT_CAT_ID'], |
|
751 | + ); |
|
752 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
753 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
754 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
755 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
756 | + $EE_Export->export(); |
|
757 | + } |
|
758 | + } |
|
759 | + |
|
760 | + |
|
761 | + /** |
|
762 | + * Creates a sample CSV file for importing |
|
763 | + */ |
|
764 | + protected function _sample_export_file() |
|
765 | + { |
|
766 | 766 | // require_once(EE_CLASSES . 'EE_Export.class.php'); |
767 | - EE_Export::instance()->export_sample(); |
|
768 | - } |
|
769 | - |
|
770 | - |
|
771 | - /************* Template Settings *************/ |
|
772 | - protected function _template_settings() |
|
773 | - { |
|
774 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
775 | - /** |
|
776 | - * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
777 | - * from General_Settings_Admin_Page to here. |
|
778 | - */ |
|
779 | - $this->_template_args = apply_filters( |
|
780 | - 'FHEE__General_Settings_Admin_Page__template_settings__template_args', |
|
781 | - $this->_template_args |
|
782 | - ); |
|
783 | - $this->_set_add_edit_form_tags('update_template_settings'); |
|
784 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
785 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
786 | - EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', |
|
787 | - $this->_template_args, |
|
788 | - true |
|
789 | - ); |
|
790 | - $this->display_admin_page_with_sidebar(); |
|
791 | - } |
|
792 | - |
|
793 | - |
|
794 | - protected function _update_template_settings() |
|
795 | - { |
|
796 | - /** |
|
797 | - * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
798 | - * from General_Settings_Admin_Page to here. |
|
799 | - */ |
|
800 | - EE_Registry::instance()->CFG->template_settings = apply_filters( |
|
801 | - 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
802 | - EE_Registry::instance()->CFG->template_settings, |
|
803 | - $this->_req_data |
|
804 | - ); |
|
805 | - //update custom post type slugs and detect if we need to flush rewrite rules |
|
806 | - $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug; |
|
807 | - EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug']) |
|
808 | - ? EE_Registry::instance()->CFG->core->event_cpt_slug |
|
809 | - : sanitize_title_with_dashes($this->_req_data['event_cpt_slug']); |
|
810 | - $what = 'Template Settings'; |
|
811 | - $success = $this->_update_espresso_configuration( |
|
812 | - $what, |
|
813 | - EE_Registry::instance()->CFG->template_settings, |
|
814 | - __FILE__, |
|
815 | - __FUNCTION__, |
|
816 | - __LINE__ |
|
817 | - ); |
|
818 | - if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) { |
|
819 | - update_option('ee_flush_rewrite_rules', true); |
|
820 | - } |
|
821 | - $this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings')); |
|
822 | - } |
|
823 | - |
|
824 | - |
|
825 | - /** |
|
826 | - * _premium_event_editor_meta_boxes |
|
827 | - * add all metaboxes related to the event_editor |
|
828 | - * |
|
829 | - * @access protected |
|
830 | - * @return void |
|
831 | - */ |
|
832 | - protected function _premium_event_editor_meta_boxes() |
|
833 | - { |
|
834 | - $this->verify_cpt_object(); |
|
835 | - add_meta_box( |
|
836 | - 'espresso_event_editor_event_options', |
|
837 | - esc_html__('Event Registration Options', 'event_espresso'), |
|
838 | - array($this, 'registration_options_meta_box'), |
|
839 | - $this->page_slug, |
|
840 | - 'side', |
|
841 | - 'core' |
|
842 | - ); |
|
843 | - } |
|
844 | - |
|
845 | - |
|
846 | - /** |
|
847 | - * override caf metabox |
|
848 | - * |
|
849 | - * @return void |
|
850 | - */ |
|
851 | - public function registration_options_meta_box() |
|
852 | - { |
|
853 | - $yes_no_values = array( |
|
854 | - array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
855 | - array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
856 | - ); |
|
857 | - $default_reg_status_values = EEM_Registration::reg_status_array( |
|
858 | - array( |
|
859 | - EEM_Registration::status_id_cancelled, |
|
860 | - EEM_Registration::status_id_declined, |
|
861 | - EEM_Registration::status_id_incomplete, |
|
862 | - EEM_Registration::status_id_wait_list, |
|
863 | - ), |
|
864 | - true |
|
865 | - ); |
|
866 | - $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
867 | - $template_args['_event'] = $this->_cpt_model_obj; |
|
868 | - $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
869 | - $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
870 | - 'default_reg_status', |
|
871 | - $default_reg_status_values, |
|
872 | - $this->_cpt_model_obj->default_registration_status() |
|
873 | - ); |
|
874 | - $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
875 | - 'display_desc', |
|
876 | - $yes_no_values, |
|
877 | - $this->_cpt_model_obj->display_description() |
|
878 | - ); |
|
879 | - $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
880 | - 'display_ticket_selector', |
|
881 | - $yes_no_values, |
|
882 | - $this->_cpt_model_obj->display_ticket_selector(), |
|
883 | - '', |
|
884 | - '', |
|
885 | - false |
|
886 | - ); |
|
887 | - $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input( |
|
888 | - 'EVT_default_registration_status', |
|
889 | - $default_reg_status_values, |
|
890 | - $this->_cpt_model_obj->default_registration_status() |
|
891 | - ); |
|
892 | - $template_args['additional_registration_options'] = apply_filters( |
|
893 | - 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
894 | - '', |
|
895 | - $template_args, |
|
896 | - $yes_no_values, |
|
897 | - $default_reg_status_values |
|
898 | - ); |
|
899 | - EEH_Template::display_template( |
|
900 | - EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
901 | - $template_args |
|
902 | - ); |
|
903 | - } |
|
904 | - |
|
905 | - |
|
906 | - |
|
907 | - /** |
|
908 | - * wp_list_table_mods for caf |
|
909 | - * ============================ |
|
910 | - */ |
|
911 | - /** |
|
912 | - * hook into list table filters and provide filters for caffeinated list table |
|
913 | - * |
|
914 | - * @param array $old_filters any existing filters present |
|
915 | - * @param array $list_table_obj the list table object |
|
916 | - * |
|
917 | - * @return array new filters |
|
918 | - */ |
|
919 | - public function list_table_filters($old_filters, $list_table_obj) |
|
920 | - { |
|
921 | - $filters = array(); |
|
922 | - //first month/year filters |
|
923 | - $filters[] = $this->espresso_event_months_dropdown(); |
|
924 | - $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
925 | - //active status dropdown |
|
926 | - if ($status !== 'draft') { |
|
927 | - $filters[] = $this->active_status_dropdown( |
|
928 | - isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : '' |
|
929 | - ); |
|
930 | - } |
|
931 | - //category filter |
|
932 | - $filters[] = $this->category_dropdown(); |
|
767 | + EE_Export::instance()->export_sample(); |
|
768 | + } |
|
769 | + |
|
770 | + |
|
771 | + /************* Template Settings *************/ |
|
772 | + protected function _template_settings() |
|
773 | + { |
|
774 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
775 | + /** |
|
776 | + * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
777 | + * from General_Settings_Admin_Page to here. |
|
778 | + */ |
|
779 | + $this->_template_args = apply_filters( |
|
780 | + 'FHEE__General_Settings_Admin_Page__template_settings__template_args', |
|
781 | + $this->_template_args |
|
782 | + ); |
|
783 | + $this->_set_add_edit_form_tags('update_template_settings'); |
|
784 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
785 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
786 | + EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', |
|
787 | + $this->_template_args, |
|
788 | + true |
|
789 | + ); |
|
790 | + $this->display_admin_page_with_sidebar(); |
|
791 | + } |
|
792 | + |
|
793 | + |
|
794 | + protected function _update_template_settings() |
|
795 | + { |
|
796 | + /** |
|
797 | + * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
798 | + * from General_Settings_Admin_Page to here. |
|
799 | + */ |
|
800 | + EE_Registry::instance()->CFG->template_settings = apply_filters( |
|
801 | + 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
802 | + EE_Registry::instance()->CFG->template_settings, |
|
803 | + $this->_req_data |
|
804 | + ); |
|
805 | + //update custom post type slugs and detect if we need to flush rewrite rules |
|
806 | + $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug; |
|
807 | + EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug']) |
|
808 | + ? EE_Registry::instance()->CFG->core->event_cpt_slug |
|
809 | + : sanitize_title_with_dashes($this->_req_data['event_cpt_slug']); |
|
810 | + $what = 'Template Settings'; |
|
811 | + $success = $this->_update_espresso_configuration( |
|
812 | + $what, |
|
813 | + EE_Registry::instance()->CFG->template_settings, |
|
814 | + __FILE__, |
|
815 | + __FUNCTION__, |
|
816 | + __LINE__ |
|
817 | + ); |
|
818 | + if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) { |
|
819 | + update_option('ee_flush_rewrite_rules', true); |
|
820 | + } |
|
821 | + $this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings')); |
|
822 | + } |
|
823 | + |
|
824 | + |
|
825 | + /** |
|
826 | + * _premium_event_editor_meta_boxes |
|
827 | + * add all metaboxes related to the event_editor |
|
828 | + * |
|
829 | + * @access protected |
|
830 | + * @return void |
|
831 | + */ |
|
832 | + protected function _premium_event_editor_meta_boxes() |
|
833 | + { |
|
834 | + $this->verify_cpt_object(); |
|
835 | + add_meta_box( |
|
836 | + 'espresso_event_editor_event_options', |
|
837 | + esc_html__('Event Registration Options', 'event_espresso'), |
|
838 | + array($this, 'registration_options_meta_box'), |
|
839 | + $this->page_slug, |
|
840 | + 'side', |
|
841 | + 'core' |
|
842 | + ); |
|
843 | + } |
|
844 | + |
|
845 | + |
|
846 | + /** |
|
847 | + * override caf metabox |
|
848 | + * |
|
849 | + * @return void |
|
850 | + */ |
|
851 | + public function registration_options_meta_box() |
|
852 | + { |
|
853 | + $yes_no_values = array( |
|
854 | + array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
855 | + array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
856 | + ); |
|
857 | + $default_reg_status_values = EEM_Registration::reg_status_array( |
|
858 | + array( |
|
859 | + EEM_Registration::status_id_cancelled, |
|
860 | + EEM_Registration::status_id_declined, |
|
861 | + EEM_Registration::status_id_incomplete, |
|
862 | + EEM_Registration::status_id_wait_list, |
|
863 | + ), |
|
864 | + true |
|
865 | + ); |
|
866 | + $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
867 | + $template_args['_event'] = $this->_cpt_model_obj; |
|
868 | + $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
869 | + $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
870 | + 'default_reg_status', |
|
871 | + $default_reg_status_values, |
|
872 | + $this->_cpt_model_obj->default_registration_status() |
|
873 | + ); |
|
874 | + $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
875 | + 'display_desc', |
|
876 | + $yes_no_values, |
|
877 | + $this->_cpt_model_obj->display_description() |
|
878 | + ); |
|
879 | + $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
880 | + 'display_ticket_selector', |
|
881 | + $yes_no_values, |
|
882 | + $this->_cpt_model_obj->display_ticket_selector(), |
|
883 | + '', |
|
884 | + '', |
|
885 | + false |
|
886 | + ); |
|
887 | + $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input( |
|
888 | + 'EVT_default_registration_status', |
|
889 | + $default_reg_status_values, |
|
890 | + $this->_cpt_model_obj->default_registration_status() |
|
891 | + ); |
|
892 | + $template_args['additional_registration_options'] = apply_filters( |
|
893 | + 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
894 | + '', |
|
895 | + $template_args, |
|
896 | + $yes_no_values, |
|
897 | + $default_reg_status_values |
|
898 | + ); |
|
899 | + EEH_Template::display_template( |
|
900 | + EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
901 | + $template_args |
|
902 | + ); |
|
903 | + } |
|
904 | + |
|
905 | + |
|
906 | + |
|
907 | + /** |
|
908 | + * wp_list_table_mods for caf |
|
909 | + * ============================ |
|
910 | + */ |
|
911 | + /** |
|
912 | + * hook into list table filters and provide filters for caffeinated list table |
|
913 | + * |
|
914 | + * @param array $old_filters any existing filters present |
|
915 | + * @param array $list_table_obj the list table object |
|
916 | + * |
|
917 | + * @return array new filters |
|
918 | + */ |
|
919 | + public function list_table_filters($old_filters, $list_table_obj) |
|
920 | + { |
|
921 | + $filters = array(); |
|
922 | + //first month/year filters |
|
923 | + $filters[] = $this->espresso_event_months_dropdown(); |
|
924 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
925 | + //active status dropdown |
|
926 | + if ($status !== 'draft') { |
|
927 | + $filters[] = $this->active_status_dropdown( |
|
928 | + isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : '' |
|
929 | + ); |
|
930 | + } |
|
931 | + //category filter |
|
932 | + $filters[] = $this->category_dropdown(); |
|
933 | 933 | |
934 | - return array_merge($old_filters, $filters); |
|
935 | - } |
|
936 | - |
|
937 | - |
|
938 | - /** |
|
939 | - * espresso_event_months_dropdown |
|
940 | - * |
|
941 | - * @access public |
|
942 | - * @return string dropdown listing month/year selections for events. |
|
943 | - */ |
|
944 | - public function espresso_event_months_dropdown() |
|
945 | - { |
|
946 | - // what we need to do is get all PRIMARY datetimes for all events to filter on. |
|
947 | - // Note we need to include any other filters that are set! |
|
948 | - $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
949 | - //categories? |
|
950 | - $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
951 | - ? $this->_req_data['EVT_CAT'] |
|
952 | - : null; |
|
953 | - //active status? |
|
954 | - $active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null; |
|
955 | - $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
|
934 | + return array_merge($old_filters, $filters); |
|
935 | + } |
|
936 | + |
|
937 | + |
|
938 | + /** |
|
939 | + * espresso_event_months_dropdown |
|
940 | + * |
|
941 | + * @access public |
|
942 | + * @return string dropdown listing month/year selections for events. |
|
943 | + */ |
|
944 | + public function espresso_event_months_dropdown() |
|
945 | + { |
|
946 | + // what we need to do is get all PRIMARY datetimes for all events to filter on. |
|
947 | + // Note we need to include any other filters that are set! |
|
948 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
949 | + //categories? |
|
950 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
951 | + ? $this->_req_data['EVT_CAT'] |
|
952 | + : null; |
|
953 | + //active status? |
|
954 | + $active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null; |
|
955 | + $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
|
956 | 956 | |
957 | - return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status); |
|
958 | - } |
|
959 | - |
|
960 | - |
|
961 | - /** |
|
962 | - * returns a list of "active" statuses on the event |
|
963 | - * |
|
964 | - * @param string $current_value whatever the current active status is |
|
965 | - * |
|
966 | - * @return string |
|
967 | - */ |
|
968 | - public function active_status_dropdown($current_value = '') |
|
969 | - { |
|
970 | - $select_name = 'active_status'; |
|
971 | - $values = array( |
|
972 | - 'none' => esc_html__('Show Active/Inactive', 'event_espresso'), |
|
973 | - 'active' => esc_html__('Active', 'event_espresso'), |
|
974 | - 'upcoming' => esc_html__('Upcoming', 'event_espresso'), |
|
975 | - 'expired' => esc_html__('Expired', 'event_espresso'), |
|
976 | - 'inactive' => esc_html__('Inactive', 'event_espresso'), |
|
977 | - ); |
|
978 | - $id = 'id="espresso-active-status-dropdown-filter"'; |
|
979 | - $class = 'wide'; |
|
957 | + return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status); |
|
958 | + } |
|
959 | + |
|
960 | + |
|
961 | + /** |
|
962 | + * returns a list of "active" statuses on the event |
|
963 | + * |
|
964 | + * @param string $current_value whatever the current active status is |
|
965 | + * |
|
966 | + * @return string |
|
967 | + */ |
|
968 | + public function active_status_dropdown($current_value = '') |
|
969 | + { |
|
970 | + $select_name = 'active_status'; |
|
971 | + $values = array( |
|
972 | + 'none' => esc_html__('Show Active/Inactive', 'event_espresso'), |
|
973 | + 'active' => esc_html__('Active', 'event_espresso'), |
|
974 | + 'upcoming' => esc_html__('Upcoming', 'event_espresso'), |
|
975 | + 'expired' => esc_html__('Expired', 'event_espresso'), |
|
976 | + 'inactive' => esc_html__('Inactive', 'event_espresso'), |
|
977 | + ); |
|
978 | + $id = 'id="espresso-active-status-dropdown-filter"'; |
|
979 | + $class = 'wide'; |
|
980 | 980 | |
981 | - return EEH_Form_Fields::select_input($select_name, $values, $current_value, $id, $class); |
|
982 | - } |
|
983 | - |
|
984 | - |
|
985 | - /** |
|
986 | - * output a dropdown of the categories for the category filter on the event admin list table |
|
987 | - * |
|
988 | - * @access public |
|
989 | - * @return string html |
|
990 | - */ |
|
991 | - public function category_dropdown() |
|
992 | - { |
|
993 | - $cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
981 | + return EEH_Form_Fields::select_input($select_name, $values, $current_value, $id, $class); |
|
982 | + } |
|
983 | + |
|
984 | + |
|
985 | + /** |
|
986 | + * output a dropdown of the categories for the category filter on the event admin list table |
|
987 | + * |
|
988 | + * @access public |
|
989 | + * @return string html |
|
990 | + */ |
|
991 | + public function category_dropdown() |
|
992 | + { |
|
993 | + $cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
994 | 994 | |
995 | - return EEH_Form_Fields::generate_event_category_dropdown($cur_cat); |
|
996 | - } |
|
997 | - |
|
998 | - |
|
999 | - /** |
|
1000 | - * get total number of events today |
|
1001 | - * |
|
1002 | - * @access public |
|
1003 | - * @return int |
|
1004 | - */ |
|
1005 | - public function total_events_today() |
|
1006 | - { |
|
1007 | - $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1008 | - 'DTT_EVT_start', |
|
1009 | - date('Y-m-d') . ' 00:00:00', |
|
1010 | - 'Y-m-d H:i:s', |
|
1011 | - 'UTC' |
|
1012 | - ); |
|
1013 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1014 | - 'DTT_EVT_start', |
|
1015 | - date('Y-m-d') . ' 23:59:59', |
|
1016 | - 'Y-m-d H:i:s', |
|
1017 | - 'UTC' |
|
1018 | - ); |
|
1019 | - $where = array( |
|
1020 | - 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)), |
|
1021 | - ); |
|
1022 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
995 | + return EEH_Form_Fields::generate_event_category_dropdown($cur_cat); |
|
996 | + } |
|
997 | + |
|
998 | + |
|
999 | + /** |
|
1000 | + * get total number of events today |
|
1001 | + * |
|
1002 | + * @access public |
|
1003 | + * @return int |
|
1004 | + */ |
|
1005 | + public function total_events_today() |
|
1006 | + { |
|
1007 | + $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1008 | + 'DTT_EVT_start', |
|
1009 | + date('Y-m-d') . ' 00:00:00', |
|
1010 | + 'Y-m-d H:i:s', |
|
1011 | + 'UTC' |
|
1012 | + ); |
|
1013 | + $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1014 | + 'DTT_EVT_start', |
|
1015 | + date('Y-m-d') . ' 23:59:59', |
|
1016 | + 'Y-m-d H:i:s', |
|
1017 | + 'UTC' |
|
1018 | + ); |
|
1019 | + $where = array( |
|
1020 | + 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)), |
|
1021 | + ); |
|
1022 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
1023 | 1023 | |
1024 | - return $count; |
|
1025 | - } |
|
1026 | - |
|
1027 | - |
|
1028 | - /** |
|
1029 | - * get total number of events this month |
|
1030 | - * |
|
1031 | - * @access public |
|
1032 | - * @return int |
|
1033 | - */ |
|
1034 | - public function total_events_this_month() |
|
1035 | - { |
|
1036 | - //Dates |
|
1037 | - $this_year_r = date('Y'); |
|
1038 | - $this_month_r = date('m'); |
|
1039 | - $days_this_month = date('t'); |
|
1040 | - $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1041 | - 'DTT_EVT_start', |
|
1042 | - $this_year_r . '-' . $this_month_r . '-01 00:00:00', |
|
1043 | - 'Y-m-d H:i:s', |
|
1044 | - 'UTC' |
|
1045 | - ); |
|
1046 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1047 | - 'DTT_EVT_start', |
|
1048 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', |
|
1049 | - 'Y-m-d H:i:s', |
|
1050 | - 'UTC' |
|
1051 | - ); |
|
1052 | - $where = array( |
|
1053 | - 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)), |
|
1054 | - ); |
|
1055 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
1024 | + return $count; |
|
1025 | + } |
|
1026 | + |
|
1027 | + |
|
1028 | + /** |
|
1029 | + * get total number of events this month |
|
1030 | + * |
|
1031 | + * @access public |
|
1032 | + * @return int |
|
1033 | + */ |
|
1034 | + public function total_events_this_month() |
|
1035 | + { |
|
1036 | + //Dates |
|
1037 | + $this_year_r = date('Y'); |
|
1038 | + $this_month_r = date('m'); |
|
1039 | + $days_this_month = date('t'); |
|
1040 | + $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1041 | + 'DTT_EVT_start', |
|
1042 | + $this_year_r . '-' . $this_month_r . '-01 00:00:00', |
|
1043 | + 'Y-m-d H:i:s', |
|
1044 | + 'UTC' |
|
1045 | + ); |
|
1046 | + $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1047 | + 'DTT_EVT_start', |
|
1048 | + $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', |
|
1049 | + 'Y-m-d H:i:s', |
|
1050 | + 'UTC' |
|
1051 | + ); |
|
1052 | + $where = array( |
|
1053 | + 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)), |
|
1054 | + ); |
|
1055 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
1056 | 1056 | |
1057 | - return $count; |
|
1058 | - } |
|
1059 | - |
|
1060 | - |
|
1061 | - /** DEFAULT TICKETS STUFF **/ |
|
1062 | - public function _tickets_overview_list_table() |
|
1063 | - { |
|
1064 | - $this->_search_btn_label = esc_html__('Tickets', 'event_espresso'); |
|
1065 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
1066 | - } |
|
1067 | - |
|
1068 | - |
|
1069 | - /** |
|
1070 | - * @param int $per_page |
|
1071 | - * @param bool $count |
|
1072 | - * @param bool $trashed |
|
1073 | - * |
|
1074 | - * @return \EE_Soft_Delete_Base_Class[]|int |
|
1075 | - */ |
|
1076 | - public function get_default_tickets($per_page = 10, $count = false, $trashed = false) |
|
1077 | - { |
|
1078 | - $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby']; |
|
1079 | - $order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order']; |
|
1080 | - switch ($orderby) { |
|
1081 | - case 'TKT_name' : |
|
1082 | - $orderby = array('TKT_name' => $order); |
|
1083 | - break; |
|
1084 | - case 'TKT_price' : |
|
1085 | - $orderby = array('TKT_price' => $order); |
|
1086 | - break; |
|
1087 | - case 'TKT_uses' : |
|
1088 | - $orderby = array('TKT_uses' => $order); |
|
1089 | - break; |
|
1090 | - case 'TKT_min' : |
|
1091 | - $orderby = array('TKT_min' => $order); |
|
1092 | - break; |
|
1093 | - case 'TKT_max' : |
|
1094 | - $orderby = array('TKT_max' => $order); |
|
1095 | - break; |
|
1096 | - case 'TKT_qty' : |
|
1097 | - $orderby = array('TKT_qty' => $order); |
|
1098 | - break; |
|
1099 | - } |
|
1100 | - $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
1101 | - ? $this->_req_data['paged'] |
|
1102 | - : 1; |
|
1103 | - $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
1104 | - ? $this->_req_data['perpage'] |
|
1105 | - : $per_page; |
|
1106 | - $_where = array( |
|
1107 | - 'TKT_is_default' => 1, |
|
1108 | - 'TKT_deleted' => $trashed, |
|
1109 | - ); |
|
1110 | - $offset = ($current_page - 1) * $per_page; |
|
1111 | - $limit = array($offset, $per_page); |
|
1112 | - if (isset($this->_req_data['s'])) { |
|
1113 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1114 | - $_where['OR'] = array( |
|
1115 | - 'TKT_name' => array('LIKE', $sstr), |
|
1116 | - 'TKT_description' => array('LIKE', $sstr), |
|
1117 | - ); |
|
1118 | - } |
|
1119 | - $query_params = array( |
|
1120 | - $_where, |
|
1121 | - 'order_by' => $orderby, |
|
1122 | - 'limit' => $limit, |
|
1123 | - 'group_by' => 'TKT_ID', |
|
1124 | - ); |
|
1125 | - if ($count) { |
|
1126 | - return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where)); |
|
1127 | - } else { |
|
1128 | - return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params); |
|
1129 | - } |
|
1130 | - } |
|
1131 | - |
|
1132 | - |
|
1133 | - /** |
|
1134 | - * @param bool $trash |
|
1135 | - */ |
|
1136 | - protected function _trash_or_restore_ticket($trash = false) |
|
1137 | - { |
|
1138 | - $success = 1; |
|
1139 | - $TKT = EEM_Ticket::instance(); |
|
1140 | - //checkboxes? |
|
1141 | - if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1142 | - //if array has more than one element then success message should be plural |
|
1143 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
1144 | - //cycle thru the boxes |
|
1145 | - while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1146 | - if ($trash) { |
|
1147 | - if ( ! $TKT->delete_by_ID($TKT_ID)) { |
|
1148 | - $success = 0; |
|
1149 | - } |
|
1150 | - } else { |
|
1151 | - if ( ! $TKT->restore_by_ID($TKT_ID)) { |
|
1152 | - $success = 0; |
|
1153 | - } |
|
1154 | - } |
|
1155 | - } |
|
1156 | - } else { |
|
1157 | - //grab single id and trash |
|
1158 | - $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
1159 | - if ($trash) { |
|
1160 | - if ( ! $TKT->delete_by_ID($TKT_ID)) { |
|
1161 | - $success = 0; |
|
1162 | - } |
|
1163 | - } else { |
|
1164 | - if ( ! $TKT->restore_by_ID($TKT_ID)) { |
|
1165 | - $success = 0; |
|
1166 | - } |
|
1167 | - } |
|
1168 | - } |
|
1169 | - $action_desc = $trash ? 'moved to the trash' : 'restored'; |
|
1170 | - $query_args = array( |
|
1171 | - 'action' => 'ticket_list_table', |
|
1172 | - 'status' => $trash ? '' : 'trashed', |
|
1173 | - ); |
|
1174 | - $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
1175 | - } |
|
1176 | - |
|
1177 | - |
|
1178 | - protected function _delete_ticket() |
|
1179 | - { |
|
1180 | - $success = 1; |
|
1181 | - //checkboxes? |
|
1182 | - if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1183 | - //if array has more than one element then success message should be plural |
|
1184 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
1185 | - //cycle thru the boxes |
|
1186 | - while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1187 | - //delete |
|
1188 | - if ( ! $this->_delete_the_ticket($TKT_ID)) { |
|
1189 | - $success = 0; |
|
1190 | - } |
|
1191 | - } |
|
1192 | - } else { |
|
1193 | - //grab single id and trash |
|
1194 | - $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
1195 | - if ( ! $this->_delete_the_ticket($TKT_ID)) { |
|
1196 | - $success = 0; |
|
1197 | - } |
|
1198 | - } |
|
1199 | - $action_desc = 'deleted'; |
|
1200 | - $query_args = array( |
|
1201 | - 'action' => 'ticket_list_table', |
|
1202 | - 'status' => 'trashed', |
|
1203 | - ); |
|
1204 | - //fail safe. If the default ticket count === 1 then we need to redirect to event overview. |
|
1205 | - if (EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
1206 | - array(array('TKT_is_default' => 1)), |
|
1207 | - 'TKT_ID', |
|
1208 | - true |
|
1209 | - ) |
|
1210 | - ) { |
|
1211 | - $query_args = array(); |
|
1212 | - } |
|
1213 | - $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
1214 | - } |
|
1215 | - |
|
1216 | - |
|
1217 | - /** |
|
1218 | - * @param int $TKT_ID |
|
1219 | - * |
|
1220 | - * @return bool|int |
|
1221 | - */ |
|
1222 | - protected function _delete_the_ticket($TKT_ID) |
|
1223 | - { |
|
1224 | - $tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID); |
|
1225 | - $tkt->_remove_relations('Datetime'); |
|
1226 | - //delete all related prices first |
|
1227 | - $tkt->delete_related_permanently('Price'); |
|
1057 | + return $count; |
|
1058 | + } |
|
1059 | + |
|
1060 | + |
|
1061 | + /** DEFAULT TICKETS STUFF **/ |
|
1062 | + public function _tickets_overview_list_table() |
|
1063 | + { |
|
1064 | + $this->_search_btn_label = esc_html__('Tickets', 'event_espresso'); |
|
1065 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
1066 | + } |
|
1067 | + |
|
1068 | + |
|
1069 | + /** |
|
1070 | + * @param int $per_page |
|
1071 | + * @param bool $count |
|
1072 | + * @param bool $trashed |
|
1073 | + * |
|
1074 | + * @return \EE_Soft_Delete_Base_Class[]|int |
|
1075 | + */ |
|
1076 | + public function get_default_tickets($per_page = 10, $count = false, $trashed = false) |
|
1077 | + { |
|
1078 | + $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby']; |
|
1079 | + $order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order']; |
|
1080 | + switch ($orderby) { |
|
1081 | + case 'TKT_name' : |
|
1082 | + $orderby = array('TKT_name' => $order); |
|
1083 | + break; |
|
1084 | + case 'TKT_price' : |
|
1085 | + $orderby = array('TKT_price' => $order); |
|
1086 | + break; |
|
1087 | + case 'TKT_uses' : |
|
1088 | + $orderby = array('TKT_uses' => $order); |
|
1089 | + break; |
|
1090 | + case 'TKT_min' : |
|
1091 | + $orderby = array('TKT_min' => $order); |
|
1092 | + break; |
|
1093 | + case 'TKT_max' : |
|
1094 | + $orderby = array('TKT_max' => $order); |
|
1095 | + break; |
|
1096 | + case 'TKT_qty' : |
|
1097 | + $orderby = array('TKT_qty' => $order); |
|
1098 | + break; |
|
1099 | + } |
|
1100 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
1101 | + ? $this->_req_data['paged'] |
|
1102 | + : 1; |
|
1103 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
1104 | + ? $this->_req_data['perpage'] |
|
1105 | + : $per_page; |
|
1106 | + $_where = array( |
|
1107 | + 'TKT_is_default' => 1, |
|
1108 | + 'TKT_deleted' => $trashed, |
|
1109 | + ); |
|
1110 | + $offset = ($current_page - 1) * $per_page; |
|
1111 | + $limit = array($offset, $per_page); |
|
1112 | + if (isset($this->_req_data['s'])) { |
|
1113 | + $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1114 | + $_where['OR'] = array( |
|
1115 | + 'TKT_name' => array('LIKE', $sstr), |
|
1116 | + 'TKT_description' => array('LIKE', $sstr), |
|
1117 | + ); |
|
1118 | + } |
|
1119 | + $query_params = array( |
|
1120 | + $_where, |
|
1121 | + 'order_by' => $orderby, |
|
1122 | + 'limit' => $limit, |
|
1123 | + 'group_by' => 'TKT_ID', |
|
1124 | + ); |
|
1125 | + if ($count) { |
|
1126 | + return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where)); |
|
1127 | + } else { |
|
1128 | + return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params); |
|
1129 | + } |
|
1130 | + } |
|
1131 | + |
|
1132 | + |
|
1133 | + /** |
|
1134 | + * @param bool $trash |
|
1135 | + */ |
|
1136 | + protected function _trash_or_restore_ticket($trash = false) |
|
1137 | + { |
|
1138 | + $success = 1; |
|
1139 | + $TKT = EEM_Ticket::instance(); |
|
1140 | + //checkboxes? |
|
1141 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1142 | + //if array has more than one element then success message should be plural |
|
1143 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
1144 | + //cycle thru the boxes |
|
1145 | + while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1146 | + if ($trash) { |
|
1147 | + if ( ! $TKT->delete_by_ID($TKT_ID)) { |
|
1148 | + $success = 0; |
|
1149 | + } |
|
1150 | + } else { |
|
1151 | + if ( ! $TKT->restore_by_ID($TKT_ID)) { |
|
1152 | + $success = 0; |
|
1153 | + } |
|
1154 | + } |
|
1155 | + } |
|
1156 | + } else { |
|
1157 | + //grab single id and trash |
|
1158 | + $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
1159 | + if ($trash) { |
|
1160 | + if ( ! $TKT->delete_by_ID($TKT_ID)) { |
|
1161 | + $success = 0; |
|
1162 | + } |
|
1163 | + } else { |
|
1164 | + if ( ! $TKT->restore_by_ID($TKT_ID)) { |
|
1165 | + $success = 0; |
|
1166 | + } |
|
1167 | + } |
|
1168 | + } |
|
1169 | + $action_desc = $trash ? 'moved to the trash' : 'restored'; |
|
1170 | + $query_args = array( |
|
1171 | + 'action' => 'ticket_list_table', |
|
1172 | + 'status' => $trash ? '' : 'trashed', |
|
1173 | + ); |
|
1174 | + $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
1175 | + } |
|
1176 | + |
|
1177 | + |
|
1178 | + protected function _delete_ticket() |
|
1179 | + { |
|
1180 | + $success = 1; |
|
1181 | + //checkboxes? |
|
1182 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1183 | + //if array has more than one element then success message should be plural |
|
1184 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
1185 | + //cycle thru the boxes |
|
1186 | + while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1187 | + //delete |
|
1188 | + if ( ! $this->_delete_the_ticket($TKT_ID)) { |
|
1189 | + $success = 0; |
|
1190 | + } |
|
1191 | + } |
|
1192 | + } else { |
|
1193 | + //grab single id and trash |
|
1194 | + $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
1195 | + if ( ! $this->_delete_the_ticket($TKT_ID)) { |
|
1196 | + $success = 0; |
|
1197 | + } |
|
1198 | + } |
|
1199 | + $action_desc = 'deleted'; |
|
1200 | + $query_args = array( |
|
1201 | + 'action' => 'ticket_list_table', |
|
1202 | + 'status' => 'trashed', |
|
1203 | + ); |
|
1204 | + //fail safe. If the default ticket count === 1 then we need to redirect to event overview. |
|
1205 | + if (EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
1206 | + array(array('TKT_is_default' => 1)), |
|
1207 | + 'TKT_ID', |
|
1208 | + true |
|
1209 | + ) |
|
1210 | + ) { |
|
1211 | + $query_args = array(); |
|
1212 | + } |
|
1213 | + $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
1214 | + } |
|
1215 | + |
|
1216 | + |
|
1217 | + /** |
|
1218 | + * @param int $TKT_ID |
|
1219 | + * |
|
1220 | + * @return bool|int |
|
1221 | + */ |
|
1222 | + protected function _delete_the_ticket($TKT_ID) |
|
1223 | + { |
|
1224 | + $tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID); |
|
1225 | + $tkt->_remove_relations('Datetime'); |
|
1226 | + //delete all related prices first |
|
1227 | + $tkt->delete_related_permanently('Price'); |
|
1228 | 1228 | |
1229 | - return $tkt->delete_permanently(); |
|
1230 | - } |
|
1229 | + return $tkt->delete_permanently(); |
|
1230 | + } |
|
1231 | 1231 | |
1232 | 1232 | |
1233 | 1233 | } |
@@ -25,16 +25,16 @@ discard block |
||
25 | 25 | { |
26 | 26 | parent::__construct($routing); |
27 | 27 | if ( ! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
28 | - define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
29 | - define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
30 | - define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
28 | + define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'events/templates/'); |
|
29 | + define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'events/assets/'); |
|
30 | + define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'events/assets/'); |
|
31 | 31 | } |
32 | 32 | } |
33 | 33 | |
34 | 34 | |
35 | 35 | protected function _extend_page_config() |
36 | 36 | { |
37 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
37 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'events'; |
|
38 | 38 | //is there a evt_id in the request? |
39 | 39 | $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
40 | 40 | ? $this->_req_data['EVT_ID'] |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | 'help_tour' => array('Templates_Help_Tour'), |
168 | 168 | 'require_nonce' => false, |
169 | 169 | ); |
170 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
170 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
171 | 171 | //add filters and actions |
172 | 172 | //modifying _views |
173 | 173 | add_filter( |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug); |
271 | 271 | //make sure this is only when editing |
272 | 272 | if ( ! empty($id)) { |
273 | - $href = EE_Admin_Page::add_query_args_and_nonce( |
|
273 | + $href = EE_Admin_Page::add_query_args_and_nonce( |
|
274 | 274 | array('action' => 'duplicate_event', 'EVT_ID' => $id), |
275 | 275 | $this->_admin_base_url |
276 | 276 | ); |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | { |
317 | 317 | wp_register_script( |
318 | 318 | 'ee-event-editor-heartbeat', |
319 | - EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', |
|
319 | + EVENTS_CAF_ASSETS_URL.'event-editor-heartbeat.js', |
|
320 | 320 | array('ee_admin_js', 'heartbeat'), |
321 | 321 | EVENT_ESPRESSO_VERSION, |
322 | 322 | true |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | public function add_additional_datetime_button($template, $template_args) |
342 | 342 | { |
343 | 343 | return EEH_Template::display_template( |
344 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php', |
|
344 | + EVENTS_CAF_TEMPLATE_PATH.'event_datetime_add_additional_time.template.php', |
|
345 | 345 | $template_args, |
346 | 346 | true |
347 | 347 | ); |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | public function add_datetime_clone_button($template, $template_args) |
358 | 358 | { |
359 | 359 | return EEH_Template::display_template( |
360 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php', |
|
360 | + EVENTS_CAF_TEMPLATE_PATH.'event_datetime_metabox_clone_button.template.php', |
|
361 | 361 | $template_args, |
362 | 362 | true |
363 | 363 | ); |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | public function datetime_timezones_template($template, $template_args) |
374 | 374 | { |
375 | 375 | return EEH_Template::display_template( |
376 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php', |
|
376 | + EVENTS_CAF_TEMPLATE_PATH.'event_datetime_timezones.template.php', |
|
377 | 377 | $template_args, |
378 | 378 | true |
379 | 379 | ); |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | protected function _set_list_table_views_default() |
384 | 384 | { |
385 | 385 | parent::_set_list_table_views_default(); |
386 | - $new_views = array( |
|
386 | + $new_views = array( |
|
387 | 387 | 'today' => array( |
388 | 388 | 'slug' => 'today', |
389 | 389 | 'label' => esc_html__('Today', 'event_espresso'), |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | $orig_ven = $orig_event->get_many_related('Venue'); |
525 | 525 | //reset the ID and modify other details to make it clear this is a dupe |
526 | 526 | $new_event->set('EVT_ID', 0); |
527 | - $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso'); |
|
527 | + $new_name = $new_event->name().' '.esc_html__('**DUPLICATE**', 'event_espresso'); |
|
528 | 528 | $new_event->set('EVT_name', $new_name); |
529 | 529 | $new_event->set( |
530 | 530 | 'EVT_slug', |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | $new_event->_add_relation_to($new_dtt, 'Datetime'); |
590 | 590 | $new_event->save(); |
591 | 591 | //now let's get the ticket relations setup. |
592 | - foreach ((array)$orig_tkts as $orig_tkt) { |
|
592 | + foreach ((array) $orig_tkts as $orig_tkt) { |
|
593 | 593 | //it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
594 | 594 | if ( ! $orig_tkt instanceof EE_Ticket) { |
595 | 595 | continue; |
@@ -681,8 +681,8 @@ discard block |
||
681 | 681 | array('action' => 'sample_export_file'), |
682 | 682 | $this->_admin_base_url |
683 | 683 | ); |
684 | - $content = EEH_Template::display_template( |
|
685 | - EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php', |
|
684 | + $content = EEH_Template::display_template( |
|
685 | + EVENTS_CAF_TEMPLATE_PATH.'import_page.template.php', |
|
686 | 686 | $this->_template_args, |
687 | 687 | true |
688 | 688 | ); |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | */ |
700 | 700 | protected function _import_events() |
701 | 701 | { |
702 | - require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
702 | + require_once(EE_CLASSES.'EE_Import.class.php'); |
|
703 | 703 | $success = EE_Import::instance()->import(); |
704 | 704 | $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true); |
705 | 705 | } |
@@ -727,9 +727,9 @@ discard block |
||
727 | 727 | 'action' => 'all_event_data', |
728 | 728 | 'EVT_ID' => $event_ids, |
729 | 729 | ); |
730 | - $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
731 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
732 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
730 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
731 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
732 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
733 | 733 | $EE_Export = EE_Export::instance($this->_req_data); |
734 | 734 | $EE_Export->export(); |
735 | 735 | } |
@@ -749,9 +749,9 @@ discard block |
||
749 | 749 | 'action' => 'categories', |
750 | 750 | 'category_ids' => $this->_req_data['EVT_CAT_ID'], |
751 | 751 | ); |
752 | - $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
753 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
754 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
752 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
753 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
754 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
755 | 755 | $EE_Export = EE_Export::instance($this->_req_data); |
756 | 756 | $EE_Export->export(); |
757 | 757 | } |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | $this->_set_add_edit_form_tags('update_template_settings'); |
784 | 784 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
785 | 785 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
786 | - EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', |
|
786 | + EVENTS_CAF_TEMPLATE_PATH.'template_settings.template.php', |
|
787 | 787 | $this->_template_args, |
788 | 788 | true |
789 | 789 | ); |
@@ -850,11 +850,11 @@ discard block |
||
850 | 850 | */ |
851 | 851 | public function registration_options_meta_box() |
852 | 852 | { |
853 | - $yes_no_values = array( |
|
853 | + $yes_no_values = array( |
|
854 | 854 | array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
855 | 855 | array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
856 | 856 | ); |
857 | - $default_reg_status_values = EEM_Registration::reg_status_array( |
|
857 | + $default_reg_status_values = EEM_Registration::reg_status_array( |
|
858 | 858 | array( |
859 | 859 | EEM_Registration::status_id_cancelled, |
860 | 860 | EEM_Registration::status_id_declined, |
@@ -871,12 +871,12 @@ discard block |
||
871 | 871 | $default_reg_status_values, |
872 | 872 | $this->_cpt_model_obj->default_registration_status() |
873 | 873 | ); |
874 | - $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
874 | + $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
875 | 875 | 'display_desc', |
876 | 876 | $yes_no_values, |
877 | 877 | $this->_cpt_model_obj->display_description() |
878 | 878 | ); |
879 | - $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
879 | + $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
880 | 880 | 'display_ticket_selector', |
881 | 881 | $yes_no_values, |
882 | 882 | $this->_cpt_model_obj->display_ticket_selector(), |
@@ -897,7 +897,7 @@ discard block |
||
897 | 897 | $default_reg_status_values |
898 | 898 | ); |
899 | 899 | EEH_Template::display_template( |
900 | - EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
900 | + EVENTS_CAF_TEMPLATE_PATH.'event_registration_options.template.php', |
|
901 | 901 | $template_args |
902 | 902 | ); |
903 | 903 | } |
@@ -1006,13 +1006,13 @@ discard block |
||
1006 | 1006 | { |
1007 | 1007 | $start = EEM_Datetime::instance()->convert_datetime_for_query( |
1008 | 1008 | 'DTT_EVT_start', |
1009 | - date('Y-m-d') . ' 00:00:00', |
|
1009 | + date('Y-m-d').' 00:00:00', |
|
1010 | 1010 | 'Y-m-d H:i:s', |
1011 | 1011 | 'UTC' |
1012 | 1012 | ); |
1013 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1013 | + $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1014 | 1014 | 'DTT_EVT_start', |
1015 | - date('Y-m-d') . ' 23:59:59', |
|
1015 | + date('Y-m-d').' 23:59:59', |
|
1016 | 1016 | 'Y-m-d H:i:s', |
1017 | 1017 | 'UTC' |
1018 | 1018 | ); |
@@ -1039,13 +1039,13 @@ discard block |
||
1039 | 1039 | $days_this_month = date('t'); |
1040 | 1040 | $start = EEM_Datetime::instance()->convert_datetime_for_query( |
1041 | 1041 | 'DTT_EVT_start', |
1042 | - $this_year_r . '-' . $this_month_r . '-01 00:00:00', |
|
1042 | + $this_year_r.'-'.$this_month_r.'-01 00:00:00', |
|
1043 | 1043 | 'Y-m-d H:i:s', |
1044 | 1044 | 'UTC' |
1045 | 1045 | ); |
1046 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1046 | + $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1047 | 1047 | 'DTT_EVT_start', |
1048 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', |
|
1048 | + $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' 23:59:59', |
|
1049 | 1049 | 'Y-m-d H:i:s', |
1050 | 1050 | 'UTC' |
1051 | 1051 | ); |
@@ -1110,7 +1110,7 @@ discard block |
||
1110 | 1110 | $offset = ($current_page - 1) * $per_page; |
1111 | 1111 | $limit = array($offset, $per_page); |
1112 | 1112 | if (isset($this->_req_data['s'])) { |
1113 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1113 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
1114 | 1114 | $_where['OR'] = array( |
1115 | 1115 | 'TKT_name' => array('LIKE', $sstr), |
1116 | 1116 | 'TKT_description' => array('LIKE', $sstr), |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'ABSPATH' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('ABSPATH')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /* |
5 | 5 | Plugin Name: Event Espresso |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @link {@link http://www.eventespresso.com} |
40 | 40 | * @since 4.0 |
41 | 41 | */ |
42 | -if ( function_exists( 'espresso_version' ) ) { |
|
42 | +if (function_exists('espresso_version')) { |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * espresso_duplicate_plugin_error |
@@ -56,15 +56,15 @@ discard block |
||
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin( plugin_basename( __FILE__ ) ); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | 60 | } |
61 | - add_action( 'admin_notices', 'espresso_duplicate_plugin_error', 1 ); |
|
61 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
62 | 62 | |
63 | 63 | } else { |
64 | 64 | |
65 | - define( 'EE_MIN_PHP_VER_REQUIRED', '5.3.0' ); |
|
65 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.0'); |
|
66 | 66 | |
67 | - if ( ! version_compare( PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=' ) ) { |
|
67 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * espresso_minimum_php_version_error |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | </p> |
91 | 91 | </div> |
92 | 92 | <?php |
93 | - espresso_deactivate_plugin( plugin_basename( __FILE__ ) ); |
|
93 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
94 | 94 | } |
95 | - add_action( 'admin_notices', 'espresso_minimum_php_version_error', 1 ); |
|
95 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
96 | 96 | |
97 | 97 | } else { |
98 | 98 | |
@@ -103,99 +103,99 @@ discard block |
||
103 | 103 | * @return string |
104 | 104 | */ |
105 | 105 | function espresso_version() { |
106 | - return apply_filters( 'FHEE__espresso__espresso_version', '4.9.22.rc.007' ); |
|
106 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.22.rc.007'); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | // define versions |
110 | - define( 'EVENT_ESPRESSO_VERSION', espresso_version() ); |
|
111 | - define( 'EE_MIN_WP_VER_REQUIRED', '4.1' ); |
|
112 | - define( 'EE_MIN_WP_VER_RECOMMENDED', '4.4.2' ); |
|
113 | - define( 'EE_MIN_PHP_VER_RECOMMENDED', '5.4.44' ); |
|
114 | - define( 'EVENT_ESPRESSO_MAIN_FILE', __FILE__ ); |
|
110 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
111 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
112 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
113 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
114 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
115 | 115 | |
116 | 116 | //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
117 | - if ( ! defined( 'DS' ) ) { |
|
118 | - define( 'DS', '/' ); |
|
117 | + if ( ! defined('DS')) { |
|
118 | + define('DS', '/'); |
|
119 | 119 | } |
120 | - if ( ! defined( 'PS' ) ) { |
|
121 | - define( 'PS', PATH_SEPARATOR ); |
|
120 | + if ( ! defined('PS')) { |
|
121 | + define('PS', PATH_SEPARATOR); |
|
122 | 122 | } |
123 | - if ( ! defined( 'SP' ) ) { |
|
124 | - define( 'SP', ' ' ); |
|
123 | + if ( ! defined('SP')) { |
|
124 | + define('SP', ' '); |
|
125 | 125 | } |
126 | - if ( ! defined( 'EENL' ) ) { |
|
127 | - define( 'EENL', "\n" ); |
|
126 | + if ( ! defined('EENL')) { |
|
127 | + define('EENL', "\n"); |
|
128 | 128 | } |
129 | - define( 'EE_SUPPORT_EMAIL', '[email protected]' ); |
|
129 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
130 | 130 | // define the plugin directory and URL |
131 | - define( 'EE_PLUGIN_BASENAME', plugin_basename( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
132 | - define( 'EE_PLUGIN_DIR_PATH', plugin_dir_path( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
133 | - define( 'EE_PLUGIN_DIR_URL', plugin_dir_url( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
131 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
132 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
133 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
134 | 134 | // main root folder paths |
135 | - define( 'EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS ); |
|
136 | - define( 'EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS ); |
|
137 | - define( 'EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS ); |
|
138 | - define( 'EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS ); |
|
139 | - define( 'EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS ); |
|
140 | - define( 'EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS ); |
|
141 | - define( 'EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS ); |
|
142 | - define( 'EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS ); |
|
135 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH.'admin_pages'.DS); |
|
136 | + define('EE_CORE', EE_PLUGIN_DIR_PATH.'core'.DS); |
|
137 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH.'modules'.DS); |
|
138 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH.'public'.DS); |
|
139 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH.'shortcodes'.DS); |
|
140 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH.'widgets'.DS); |
|
141 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH.'payment_methods'.DS); |
|
142 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH.'caffeinated'.DS); |
|
143 | 143 | // core system paths |
144 | - define( 'EE_ADMIN', EE_CORE . 'admin' . DS ); |
|
145 | - define( 'EE_CPTS', EE_CORE . 'CPTs' . DS ); |
|
146 | - define( 'EE_CLASSES', EE_CORE . 'db_classes' . DS ); |
|
147 | - define( 'EE_INTERFACES', EE_CORE . 'interfaces' . DS ); |
|
148 | - define( 'EE_BUSINESS', EE_CORE . 'business' . DS ); |
|
149 | - define( 'EE_MODELS', EE_CORE . 'db_models' . DS ); |
|
150 | - define( 'EE_HELPERS', EE_CORE . 'helpers' . DS ); |
|
151 | - define( 'EE_LIBRARIES', EE_CORE . 'libraries' . DS ); |
|
152 | - define( 'EE_TEMPLATES', EE_CORE . 'templates' . DS ); |
|
153 | - define( 'EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS ); |
|
154 | - define( 'EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS ); |
|
155 | - define( 'EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS ); |
|
144 | + define('EE_ADMIN', EE_CORE.'admin'.DS); |
|
145 | + define('EE_CPTS', EE_CORE.'CPTs'.DS); |
|
146 | + define('EE_CLASSES', EE_CORE.'db_classes'.DS); |
|
147 | + define('EE_INTERFACES', EE_CORE.'interfaces'.DS); |
|
148 | + define('EE_BUSINESS', EE_CORE.'business'.DS); |
|
149 | + define('EE_MODELS', EE_CORE.'db_models'.DS); |
|
150 | + define('EE_HELPERS', EE_CORE.'helpers'.DS); |
|
151 | + define('EE_LIBRARIES', EE_CORE.'libraries'.DS); |
|
152 | + define('EE_TEMPLATES', EE_CORE.'templates'.DS); |
|
153 | + define('EE_THIRD_PARTY', EE_CORE.'third_party_libs'.DS); |
|
154 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES.'global_assets'.DS); |
|
155 | + define('EE_FORM_SECTIONS', EE_LIBRARIES.'form_sections'.DS); |
|
156 | 156 | // gateways |
157 | - define( 'EE_GATEWAYS', EE_MODULES . 'gateways' . DS ); |
|
158 | - define( 'EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS ); |
|
157 | + define('EE_GATEWAYS', EE_MODULES.'gateways'.DS); |
|
158 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL.'modules'.DS.'gateways'.DS); |
|
159 | 159 | // asset URL paths |
160 | - define( 'EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS ); |
|
161 | - define( 'EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS ); |
|
162 | - define( 'EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS ); |
|
163 | - define( 'EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS ); |
|
164 | - define( 'EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/' ); |
|
165 | - define( 'EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/' ); |
|
160 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL.'core'.DS.'templates'.DS); |
|
161 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL.'global_assets'.DS); |
|
162 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL.'images'.DS); |
|
163 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL.'core'.DS.'third_party_libs'.DS); |
|
164 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL.'core/helpers/assets/'); |
|
165 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL.'core/libraries/'); |
|
166 | 166 | // define upload paths |
167 | 167 | $uploads = wp_upload_dir(); |
168 | 168 | // define the uploads directory and URL |
169 | - define( 'EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS ); |
|
170 | - define( 'EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS ); |
|
169 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'].DS.'espresso'.DS); |
|
170 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'].DS.'espresso'.DS); |
|
171 | 171 | // define the templates directory and URL |
172 | - define( 'EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS ); |
|
173 | - define( 'EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS ); |
|
172 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'].DS.'espresso'.DS.'templates'.DS); |
|
173 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'].DS.'espresso'.DS.'templates'.DS); |
|
174 | 174 | // define the gateway directory and URL |
175 | - define( 'EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS ); |
|
176 | - define( 'EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS ); |
|
175 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'].DS.'espresso'.DS.'gateways'.DS); |
|
176 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'].DS.'espresso'.DS.'gateways'.DS); |
|
177 | 177 | // languages folder/path |
178 | - define( 'EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS ); |
|
179 | - define( 'EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS ); |
|
178 | + define('EE_LANGUAGES_SAFE_LOC', '..'.DS.'uploads'.DS.'espresso'.DS.'languages'.DS); |
|
179 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'languages'.DS); |
|
180 | 180 | //check for dompdf fonts in uploads |
181 | - if ( file_exists( EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ) ) { |
|
182 | - define( 'DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ); |
|
181 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS)) { |
|
182 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS); |
|
183 | 183 | } |
184 | 184 | //ajax constants |
185 | 185 | define( |
186 | 186 | 'EE_FRONT_AJAX', |
187 | - isset( $_REQUEST['ee_front_ajax'] ) || isset( $_REQUEST['data']['ee_front_ajax'] ) ? true : false |
|
187 | + isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
188 | 188 | ); |
189 | 189 | define( |
190 | 190 | 'EE_ADMIN_AJAX', |
191 | - isset( $_REQUEST['ee_admin_ajax'] ) || isset( $_REQUEST['data']['ee_admin_ajax'] ) ? true : false |
|
191 | + isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
192 | 192 | ); |
193 | 193 | //just a handy constant occasionally needed for finding values representing infinity in the DB |
194 | 194 | //you're better to use this than its straight value (currently -1) in case you ever |
195 | 195 | //want to change its default value! or find when -1 means infinity |
196 | - define( 'EE_INF_IN_DB', -1 ); |
|
197 | - define( 'EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX ); |
|
198 | - define( 'EE_DEBUG', false ); |
|
196 | + define('EE_INF_IN_DB', -1); |
|
197 | + define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
198 | + define('EE_DEBUG', false); |
|
199 | 199 | |
200 | 200 | |
201 | 201 | /** |
@@ -203,9 +203,9 @@ discard block |
||
203 | 203 | * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
204 | 204 | */ |
205 | 205 | function espresso_plugin_activation() { |
206 | - update_option( 'ee_espresso_activation', true ); |
|
206 | + update_option('ee_espresso_activation', true); |
|
207 | 207 | } |
208 | - register_activation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation' ); |
|
208 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
209 | 209 | |
210 | 210 | |
211 | 211 | |
@@ -215,15 +215,15 @@ discard block |
||
215 | 215 | */ |
216 | 216 | function espresso_load_error_handling() { |
217 | 217 | // load debugging tools |
218 | - if ( WP_DEBUG === true && is_readable( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ) ) { |
|
219 | - require_once( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ); |
|
218 | + if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) { |
|
219 | + require_once(EE_HELPERS.'EEH_Debug_Tools.helper.php'); |
|
220 | 220 | EEH_Debug_Tools::instance(); |
221 | 221 | } |
222 | 222 | // load error handling |
223 | - if ( is_readable( EE_CORE . 'EE_Error.core.php' ) ) { |
|
224 | - require_once( EE_CORE . 'EE_Error.core.php' ); |
|
223 | + if (is_readable(EE_CORE.'EE_Error.core.php')) { |
|
224 | + require_once(EE_CORE.'EE_Error.core.php'); |
|
225 | 225 | } else { |
226 | - wp_die( esc_html__( 'The EE_Error core class could not be loaded.', 'event_espresso' ) ); |
|
226 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
227 | 227 | } |
228 | 228 | } |
229 | 229 | |
@@ -237,16 +237,16 @@ discard block |
||
237 | 237 | * @param string $full_path_to_file |
238 | 238 | * @throws EE_Error |
239 | 239 | */ |
240 | - function espresso_load_required( $classname, $full_path_to_file ) { |
|
240 | + function espresso_load_required($classname, $full_path_to_file) { |
|
241 | 241 | static $error_handling_loaded = false; |
242 | - if ( ! $error_handling_loaded ) { |
|
242 | + if ( ! $error_handling_loaded) { |
|
243 | 243 | espresso_load_error_handling(); |
244 | 244 | $error_handling_loaded = true; |
245 | 245 | } |
246 | - if ( is_readable( $full_path_to_file ) ) { |
|
247 | - require_once( $full_path_to_file ); |
|
246 | + if (is_readable($full_path_to_file)) { |
|
247 | + require_once($full_path_to_file); |
|
248 | 248 | } else { |
249 | - throw new EE_Error ( |
|
249 | + throw new EE_Error( |
|
250 | 250 | sprintf( |
251 | 251 | esc_html__( |
252 | 252 | 'The %s class file could not be located or is not readable due to file permissions.', |
@@ -258,15 +258,15 @@ discard block |
||
258 | 258 | } |
259 | 259 | } |
260 | 260 | |
261 | - espresso_load_required( 'EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' ); |
|
262 | - espresso_load_required( 'EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' ); |
|
263 | - espresso_load_required( 'EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php' ); |
|
261 | + espresso_load_required('EEH_Base', EE_CORE.'helpers'.DS.'EEH_Base.helper.php'); |
|
262 | + espresso_load_required('EEH_File', EE_CORE.'helpers'.DS.'EEH_File.helper.php'); |
|
263 | + espresso_load_required('EE_Bootstrap', EE_CORE.'EE_Bootstrap.core.php'); |
|
264 | 264 | new EE_Bootstrap(); |
265 | 265 | |
266 | 266 | } |
267 | 267 | } |
268 | 268 | |
269 | -if ( ! function_exists( 'espresso_deactivate_plugin' ) ) { |
|
269 | +if ( ! function_exists('espresso_deactivate_plugin')) { |
|
270 | 270 | |
271 | 271 | /** |
272 | 272 | * deactivate_plugin |
@@ -276,12 +276,12 @@ discard block |
||
276 | 276 | * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
277 | 277 | * @return void |
278 | 278 | */ |
279 | - function espresso_deactivate_plugin( $plugin_basename = '' ) { |
|
280 | - if ( ! function_exists( 'deactivate_plugins' ) ) { |
|
281 | - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
279 | + function espresso_deactivate_plugin($plugin_basename = '') { |
|
280 | + if ( ! function_exists('deactivate_plugins')) { |
|
281 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
282 | 282 | } |
283 | - unset( $_GET['activate'], $_REQUEST['activate'] ); |
|
284 | - deactivate_plugins( $plugin_basename ); |
|
283 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
284 | + deactivate_plugins($plugin_basename); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | } |
@@ -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_CPT_Base.model.php'); |
5 | 5 | |
@@ -17,451 +17,451 @@ discard block |
||
17 | 17 | class EEM_Event extends EEM_CPT_Base |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * constant used by status(), indicating that no more tickets can be purchased for any of the datetimes for the |
|
22 | - * event |
|
23 | - */ |
|
24 | - const sold_out = 'sold_out'; |
|
25 | - |
|
26 | - /** |
|
27 | - * constant used by status(), indicating that upcoming event dates have been postponed (may be pushed to a later |
|
28 | - * date) |
|
29 | - */ |
|
30 | - const postponed = 'postponed'; |
|
31 | - |
|
32 | - /** |
|
33 | - * constant used by status(), indicating that the event will no longer occur |
|
34 | - */ |
|
35 | - const cancelled = 'cancelled'; |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * @var string |
|
40 | - */ |
|
41 | - protected static $_default_reg_status = null; |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * private instance of the Event object |
|
46 | - * @var EEM_Event |
|
47 | - */ |
|
48 | - protected static $_instance = null; |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * This function is a singleton method used to instantiate the EEM_Event object |
|
53 | - * |
|
54 | - * @access public |
|
55 | - * |
|
56 | - * @param string $timezone |
|
57 | - * |
|
58 | - * @return EEM_Event |
|
59 | - */ |
|
60 | - public static function instance($timezone = null) |
|
61 | - { |
|
62 | - |
|
63 | - // check if instance of EEM_Event already exists |
|
64 | - if ( ! self::$_instance instanceof EEM_Event) { |
|
65 | - // instantiate Espresso_model |
|
66 | - self::$_instance = new self($timezone); |
|
67 | - } |
|
68 | - //we might have a timezone set, let set_timezone decide what to do with it |
|
69 | - self::$_instance->set_timezone($timezone); |
|
70 | - |
|
71 | - // EEM_Event object |
|
72 | - return self::$_instance; |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * Adds a relationship to Term_Taxonomy for each CPT_Base |
|
78 | - * |
|
79 | - * @param string $timezone |
|
80 | - * |
|
81 | - * @return EEM_Event |
|
82 | - */ |
|
83 | - protected function __construct($timezone = null) |
|
84 | - { |
|
85 | - |
|
86 | - EE_Registry::instance()->load_model('Registration'); |
|
87 | - |
|
88 | - $this->singular_item = __('Event', 'event_espresso'); |
|
89 | - $this->plural_item = __('Events', 'event_espresso'); |
|
90 | - |
|
91 | - // to remove Cancelled events from the frontend, copy the following filter to your functions.php file |
|
92 | - // add_filter( 'AFEE__EEM_Event__construct___custom_stati__cancelled__Public', '__return_false' ); |
|
93 | - // to remove Postponed events from the frontend, copy the following filter to your functions.php file |
|
94 | - // add_filter( 'AFEE__EEM_Event__construct___custom_stati__postponed__Public', '__return_false' ); |
|
95 | - // to remove Sold Out events from the frontend, copy the following filter to your functions.php file |
|
96 | - // add_filter( 'AFEE__EEM_Event__construct___custom_stati__sold_out__Public', '__return_false' ); |
|
97 | - |
|
98 | - $this->_custom_stati = apply_filters( |
|
99 | - 'AFEE__EEM_Event__construct___custom_stati', |
|
100 | - array( |
|
101 | - EEM_Event::cancelled => array( |
|
102 | - 'label' => __('Cancelled', 'event_espresso'), |
|
103 | - 'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__cancelled__Public', true) |
|
104 | - ), |
|
105 | - EEM_Event::postponed => array( |
|
106 | - 'label' => __('Postponed', 'event_espresso'), |
|
107 | - 'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__postponed__Public', true) |
|
108 | - ), |
|
109 | - EEM_Event::sold_out => array( |
|
110 | - 'label' => __('Sold Out', 'event_espresso'), |
|
111 | - 'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__sold_out__Public', true) |
|
112 | - ) |
|
113 | - ) |
|
114 | - ); |
|
115 | - |
|
116 | - self::$_default_reg_status = empty(self::$_default_reg_status) ? EEM_Registration::status_id_pending_payment : self::$_default_reg_status; |
|
117 | - |
|
118 | - $this->_tables = array( |
|
119 | - 'Event_CPT' => new EE_Primary_Table('posts', 'ID'), |
|
120 | - 'Event_Meta' => new EE_Secondary_Table('esp_event_meta', 'EVTM_ID', 'EVT_ID') |
|
121 | - ); |
|
122 | - |
|
123 | - $this->_fields = array( |
|
124 | - 'Event_CPT' => array( |
|
125 | - 'EVT_ID' => new EE_Primary_Key_Int_Field('ID', __('Post ID for Event', 'event_espresso')), |
|
126 | - 'EVT_name' => new EE_Plain_Text_Field('post_title', __('Event Name', 'event_espresso'), false, |
|
127 | - ''), |
|
128 | - 'EVT_desc' => new EE_Post_Content_Field('post_content', __('Event Description', 'event_espresso'), |
|
129 | - false, ''), |
|
130 | - 'EVT_slug' => new EE_Slug_Field('post_name', __('Event Slug', 'event_espresso'), false, ''), |
|
131 | - 'EVT_created' => new EE_Datetime_Field('post_date', __('Date/Time Event Created', 'event_espresso'), |
|
132 | - false, EE_Datetime_Field::now), |
|
133 | - 'EVT_short_desc' => new EE_Simple_HTML_Field('post_excerpt', |
|
134 | - __('Event Short Description', 'event_espresso'), false, ''), |
|
135 | - 'EVT_modified' => new EE_Datetime_Field('post_modified', |
|
136 | - __('Date/Time Event Modified', 'event_espresso'), false, EE_Datetime_Field::now), |
|
137 | - 'EVT_wp_user' => new EE_WP_User_Field('post_author', __('Event Creator ID', 'event_espresso'), |
|
138 | - false), |
|
139 | - 'parent' => new EE_Integer_Field('post_parent', __('Event Parent ID', 'event_espresso'), false, |
|
140 | - 0), |
|
141 | - 'EVT_order' => new EE_Integer_Field('menu_order', __('Event Menu Order', 'event_espresso'), false, |
|
142 | - 1), |
|
143 | - 'post_type' => new EE_WP_Post_Type_Field('espresso_events'), |
|
144 | - // EE_Plain_Text_Field( 'post_type', __( 'Event Post Type', 'event_espresso' ), FALSE, 'espresso_events' ), |
|
145 | - 'status' => new EE_WP_Post_Status_Field('post_status', __('Event Status', 'event_espresso'), |
|
146 | - false, 'draft', $this->_custom_stati) |
|
147 | - ), |
|
148 | - 'Event_Meta' => array( |
|
149 | - 'EVTM_ID' => new EE_DB_Only_Float_Field('EVTM_ID', |
|
150 | - __('Event Meta Row ID', 'event_espresso'), false), |
|
151 | - 'EVT_ID_fk' => new EE_DB_Only_Int_Field('EVT_ID', |
|
152 | - __('Foreign key to Event ID from Event Meta table', 'event_espresso'), false), |
|
153 | - 'EVT_display_desc' => new EE_Boolean_Field('EVT_display_desc', |
|
154 | - __('Display Description Flag', 'event_espresso'), false, 1), |
|
155 | - 'EVT_display_ticket_selector' => new EE_Boolean_Field('EVT_display_ticket_selector', |
|
156 | - __('Display Ticket Selector Flag', 'event_espresso'), false, 1), |
|
157 | - 'EVT_visible_on' => new EE_Datetime_Field('EVT_visible_on', |
|
158 | - __('Event Visible Date', 'event_espresso'), true, EE_Datetime_Field::now), |
|
159 | - 'EVT_additional_limit' => new EE_Integer_Field('EVT_additional_limit', |
|
160 | - __('Limit of Additional Registrations on Same Transaction', 'event_espresso'), true, 10), |
|
161 | - 'EVT_default_registration_status' => new EE_Enum_Text_Field( |
|
162 | - 'EVT_default_registration_status', |
|
163 | - __('Default Registration Status on this Event', 'event_espresso'), false, |
|
164 | - EEM_Event::$_default_reg_status, EEM_Registration::reg_status_array() |
|
165 | - ), |
|
166 | - 'EVT_member_only' => new EE_Boolean_Field('EVT_member_only', |
|
167 | - __('Member-Only Event Flag', 'event_espresso'), false, false), |
|
168 | - 'EVT_phone' => new EE_Plain_Text_Field('EVT_phone', |
|
169 | - __('Event Phone Number', 'event_espresso'), false), |
|
170 | - 'EVT_allow_overflow' => new EE_Boolean_Field('EVT_allow_overflow', |
|
171 | - __('Allow Overflow on Event', 'event_espresso'), false, false), |
|
172 | - 'EVT_timezone_string' => new EE_Plain_Text_Field('EVT_timezone_string', |
|
173 | - __('Timezone (name) for Event times', 'event_espresso'), false), |
|
174 | - 'EVT_external_URL' => new EE_Plain_Text_Field('EVT_external_URL', |
|
175 | - __('URL of Event Page if hosted elsewhere', 'event_espresso'), true), |
|
176 | - 'EVT_donations' => new EE_Boolean_Field('EVT_donations', |
|
177 | - __('Accept Donations?', 'event_espresso'), false, false) |
|
20 | + /** |
|
21 | + * constant used by status(), indicating that no more tickets can be purchased for any of the datetimes for the |
|
22 | + * event |
|
23 | + */ |
|
24 | + const sold_out = 'sold_out'; |
|
25 | + |
|
26 | + /** |
|
27 | + * constant used by status(), indicating that upcoming event dates have been postponed (may be pushed to a later |
|
28 | + * date) |
|
29 | + */ |
|
30 | + const postponed = 'postponed'; |
|
31 | + |
|
32 | + /** |
|
33 | + * constant used by status(), indicating that the event will no longer occur |
|
34 | + */ |
|
35 | + const cancelled = 'cancelled'; |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * @var string |
|
40 | + */ |
|
41 | + protected static $_default_reg_status = null; |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * private instance of the Event object |
|
46 | + * @var EEM_Event |
|
47 | + */ |
|
48 | + protected static $_instance = null; |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * This function is a singleton method used to instantiate the EEM_Event object |
|
53 | + * |
|
54 | + * @access public |
|
55 | + * |
|
56 | + * @param string $timezone |
|
57 | + * |
|
58 | + * @return EEM_Event |
|
59 | + */ |
|
60 | + public static function instance($timezone = null) |
|
61 | + { |
|
62 | + |
|
63 | + // check if instance of EEM_Event already exists |
|
64 | + if ( ! self::$_instance instanceof EEM_Event) { |
|
65 | + // instantiate Espresso_model |
|
66 | + self::$_instance = new self($timezone); |
|
67 | + } |
|
68 | + //we might have a timezone set, let set_timezone decide what to do with it |
|
69 | + self::$_instance->set_timezone($timezone); |
|
70 | + |
|
71 | + // EEM_Event object |
|
72 | + return self::$_instance; |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * Adds a relationship to Term_Taxonomy for each CPT_Base |
|
78 | + * |
|
79 | + * @param string $timezone |
|
80 | + * |
|
81 | + * @return EEM_Event |
|
82 | + */ |
|
83 | + protected function __construct($timezone = null) |
|
84 | + { |
|
85 | + |
|
86 | + EE_Registry::instance()->load_model('Registration'); |
|
87 | + |
|
88 | + $this->singular_item = __('Event', 'event_espresso'); |
|
89 | + $this->plural_item = __('Events', 'event_espresso'); |
|
90 | + |
|
91 | + // to remove Cancelled events from the frontend, copy the following filter to your functions.php file |
|
92 | + // add_filter( 'AFEE__EEM_Event__construct___custom_stati__cancelled__Public', '__return_false' ); |
|
93 | + // to remove Postponed events from the frontend, copy the following filter to your functions.php file |
|
94 | + // add_filter( 'AFEE__EEM_Event__construct___custom_stati__postponed__Public', '__return_false' ); |
|
95 | + // to remove Sold Out events from the frontend, copy the following filter to your functions.php file |
|
96 | + // add_filter( 'AFEE__EEM_Event__construct___custom_stati__sold_out__Public', '__return_false' ); |
|
97 | + |
|
98 | + $this->_custom_stati = apply_filters( |
|
99 | + 'AFEE__EEM_Event__construct___custom_stati', |
|
100 | + array( |
|
101 | + EEM_Event::cancelled => array( |
|
102 | + 'label' => __('Cancelled', 'event_espresso'), |
|
103 | + 'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__cancelled__Public', true) |
|
104 | + ), |
|
105 | + EEM_Event::postponed => array( |
|
106 | + 'label' => __('Postponed', 'event_espresso'), |
|
107 | + 'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__postponed__Public', true) |
|
108 | + ), |
|
109 | + EEM_Event::sold_out => array( |
|
110 | + 'label' => __('Sold Out', 'event_espresso'), |
|
111 | + 'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__sold_out__Public', true) |
|
112 | + ) |
|
113 | + ) |
|
114 | + ); |
|
115 | + |
|
116 | + self::$_default_reg_status = empty(self::$_default_reg_status) ? EEM_Registration::status_id_pending_payment : self::$_default_reg_status; |
|
117 | + |
|
118 | + $this->_tables = array( |
|
119 | + 'Event_CPT' => new EE_Primary_Table('posts', 'ID'), |
|
120 | + 'Event_Meta' => new EE_Secondary_Table('esp_event_meta', 'EVTM_ID', 'EVT_ID') |
|
121 | + ); |
|
122 | + |
|
123 | + $this->_fields = array( |
|
124 | + 'Event_CPT' => array( |
|
125 | + 'EVT_ID' => new EE_Primary_Key_Int_Field('ID', __('Post ID for Event', 'event_espresso')), |
|
126 | + 'EVT_name' => new EE_Plain_Text_Field('post_title', __('Event Name', 'event_espresso'), false, |
|
127 | + ''), |
|
128 | + 'EVT_desc' => new EE_Post_Content_Field('post_content', __('Event Description', 'event_espresso'), |
|
129 | + false, ''), |
|
130 | + 'EVT_slug' => new EE_Slug_Field('post_name', __('Event Slug', 'event_espresso'), false, ''), |
|
131 | + 'EVT_created' => new EE_Datetime_Field('post_date', __('Date/Time Event Created', 'event_espresso'), |
|
132 | + false, EE_Datetime_Field::now), |
|
133 | + 'EVT_short_desc' => new EE_Simple_HTML_Field('post_excerpt', |
|
134 | + __('Event Short Description', 'event_espresso'), false, ''), |
|
135 | + 'EVT_modified' => new EE_Datetime_Field('post_modified', |
|
136 | + __('Date/Time Event Modified', 'event_espresso'), false, EE_Datetime_Field::now), |
|
137 | + 'EVT_wp_user' => new EE_WP_User_Field('post_author', __('Event Creator ID', 'event_espresso'), |
|
138 | + false), |
|
139 | + 'parent' => new EE_Integer_Field('post_parent', __('Event Parent ID', 'event_espresso'), false, |
|
140 | + 0), |
|
141 | + 'EVT_order' => new EE_Integer_Field('menu_order', __('Event Menu Order', 'event_espresso'), false, |
|
142 | + 1), |
|
143 | + 'post_type' => new EE_WP_Post_Type_Field('espresso_events'), |
|
144 | + // EE_Plain_Text_Field( 'post_type', __( 'Event Post Type', 'event_espresso' ), FALSE, 'espresso_events' ), |
|
145 | + 'status' => new EE_WP_Post_Status_Field('post_status', __('Event Status', 'event_espresso'), |
|
146 | + false, 'draft', $this->_custom_stati) |
|
147 | + ), |
|
148 | + 'Event_Meta' => array( |
|
149 | + 'EVTM_ID' => new EE_DB_Only_Float_Field('EVTM_ID', |
|
150 | + __('Event Meta Row ID', 'event_espresso'), false), |
|
151 | + 'EVT_ID_fk' => new EE_DB_Only_Int_Field('EVT_ID', |
|
152 | + __('Foreign key to Event ID from Event Meta table', 'event_espresso'), false), |
|
153 | + 'EVT_display_desc' => new EE_Boolean_Field('EVT_display_desc', |
|
154 | + __('Display Description Flag', 'event_espresso'), false, 1), |
|
155 | + 'EVT_display_ticket_selector' => new EE_Boolean_Field('EVT_display_ticket_selector', |
|
156 | + __('Display Ticket Selector Flag', 'event_espresso'), false, 1), |
|
157 | + 'EVT_visible_on' => new EE_Datetime_Field('EVT_visible_on', |
|
158 | + __('Event Visible Date', 'event_espresso'), true, EE_Datetime_Field::now), |
|
159 | + 'EVT_additional_limit' => new EE_Integer_Field('EVT_additional_limit', |
|
160 | + __('Limit of Additional Registrations on Same Transaction', 'event_espresso'), true, 10), |
|
161 | + 'EVT_default_registration_status' => new EE_Enum_Text_Field( |
|
162 | + 'EVT_default_registration_status', |
|
163 | + __('Default Registration Status on this Event', 'event_espresso'), false, |
|
164 | + EEM_Event::$_default_reg_status, EEM_Registration::reg_status_array() |
|
165 | + ), |
|
166 | + 'EVT_member_only' => new EE_Boolean_Field('EVT_member_only', |
|
167 | + __('Member-Only Event Flag', 'event_espresso'), false, false), |
|
168 | + 'EVT_phone' => new EE_Plain_Text_Field('EVT_phone', |
|
169 | + __('Event Phone Number', 'event_espresso'), false), |
|
170 | + 'EVT_allow_overflow' => new EE_Boolean_Field('EVT_allow_overflow', |
|
171 | + __('Allow Overflow on Event', 'event_espresso'), false, false), |
|
172 | + 'EVT_timezone_string' => new EE_Plain_Text_Field('EVT_timezone_string', |
|
173 | + __('Timezone (name) for Event times', 'event_espresso'), false), |
|
174 | + 'EVT_external_URL' => new EE_Plain_Text_Field('EVT_external_URL', |
|
175 | + __('URL of Event Page if hosted elsewhere', 'event_espresso'), true), |
|
176 | + 'EVT_donations' => new EE_Boolean_Field('EVT_donations', |
|
177 | + __('Accept Donations?', 'event_espresso'), false, false) |
|
178 | 178 | |
179 | - ) |
|
180 | - ); |
|
181 | - |
|
182 | - $this->_model_relations = array( |
|
183 | - 'Registration' => new EE_Has_Many_Relation(), |
|
184 | - 'Datetime' => new EE_Has_Many_Relation(), |
|
185 | - 'Question_Group' => new EE_HABTM_Relation('Event_Question_Group'), |
|
186 | - 'Venue' => new EE_HABTM_Relation('Event_Venue'), |
|
187 | - 'Term_Relationship' => new EE_Has_Many_Relation(), |
|
188 | - 'Term_Taxonomy' => new EE_HABTM_Relation('Term_Relationship'), |
|
189 | - 'Message_Template_Group' => new EE_HABTM_Relation('Event_Message_Template'), |
|
190 | - 'Attendee' => new EE_HABTM_Relation('Registration'), |
|
191 | - 'WP_User' => new EE_Belongs_To_Relation(), |
|
192 | - ); |
|
193 | - //this model is generally available for reading |
|
194 | - $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
195 | - parent::__construct($timezone); |
|
196 | - } |
|
197 | - |
|
198 | - |
|
199 | - /** |
|
200 | - * @param string $default_reg_status |
|
201 | - */ |
|
202 | - public static function set_default_reg_status($default_reg_status) |
|
203 | - { |
|
204 | - self::$_default_reg_status = $default_reg_status; |
|
205 | - //if EEM_Event has already been instantiated, then we need to reset the `EVT_default_reg_status` field to use the new default. |
|
206 | - if (self::$_instance instanceof EEM_Event) { |
|
207 | - self::$_instance->_fields['Event_Meta']['EVT_default_registration_status'] = new EE_Enum_Text_Field( |
|
208 | - 'EVT_default_registration_status', __('Default Registration Status on this Event', 'event_espresso'), |
|
209 | - false, $default_reg_status, EEM_Registration::reg_status_array() |
|
210 | - ); |
|
211 | - self::$_instance->_fields['Event_Meta']['EVT_default_registration_status']->_construct_finalize('Event_Meta', |
|
212 | - 'EVT_default_registration_status', 'EEM_Event'); |
|
213 | - } |
|
214 | - } |
|
215 | - |
|
216 | - |
|
217 | - /** |
|
218 | - * get_question_groups |
|
219 | - * |
|
220 | - * @access public |
|
221 | - * @return array |
|
222 | - */ |
|
223 | - public function get_all_question_groups() |
|
224 | - { |
|
225 | - return EE_Registry::instance()->load_model('Question_Group')->get_all(array( |
|
226 | - array('QSG_deleted' => false), |
|
227 | - 'order_by' => array('QSG_order' => 'ASC') |
|
228 | - )); |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - /** |
|
233 | - * get_question_groups |
|
234 | - * |
|
235 | - * @access public |
|
236 | - * |
|
237 | - * @param int $EVT_ID |
|
238 | - * |
|
239 | - * @return array |
|
240 | - */ |
|
241 | - public function get_all_event_question_groups($EVT_ID = 0) |
|
242 | - { |
|
243 | - if ( ! isset($EVT_ID) || ! absint($EVT_ID)) { |
|
244 | - EE_Error::add_error(__('An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', |
|
245 | - 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
179 | + ) |
|
180 | + ); |
|
181 | + |
|
182 | + $this->_model_relations = array( |
|
183 | + 'Registration' => new EE_Has_Many_Relation(), |
|
184 | + 'Datetime' => new EE_Has_Many_Relation(), |
|
185 | + 'Question_Group' => new EE_HABTM_Relation('Event_Question_Group'), |
|
186 | + 'Venue' => new EE_HABTM_Relation('Event_Venue'), |
|
187 | + 'Term_Relationship' => new EE_Has_Many_Relation(), |
|
188 | + 'Term_Taxonomy' => new EE_HABTM_Relation('Term_Relationship'), |
|
189 | + 'Message_Template_Group' => new EE_HABTM_Relation('Event_Message_Template'), |
|
190 | + 'Attendee' => new EE_HABTM_Relation('Registration'), |
|
191 | + 'WP_User' => new EE_Belongs_To_Relation(), |
|
192 | + ); |
|
193 | + //this model is generally available for reading |
|
194 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
195 | + parent::__construct($timezone); |
|
196 | + } |
|
197 | + |
|
198 | + |
|
199 | + /** |
|
200 | + * @param string $default_reg_status |
|
201 | + */ |
|
202 | + public static function set_default_reg_status($default_reg_status) |
|
203 | + { |
|
204 | + self::$_default_reg_status = $default_reg_status; |
|
205 | + //if EEM_Event has already been instantiated, then we need to reset the `EVT_default_reg_status` field to use the new default. |
|
206 | + if (self::$_instance instanceof EEM_Event) { |
|
207 | + self::$_instance->_fields['Event_Meta']['EVT_default_registration_status'] = new EE_Enum_Text_Field( |
|
208 | + 'EVT_default_registration_status', __('Default Registration Status on this Event', 'event_espresso'), |
|
209 | + false, $default_reg_status, EEM_Registration::reg_status_array() |
|
210 | + ); |
|
211 | + self::$_instance->_fields['Event_Meta']['EVT_default_registration_status']->_construct_finalize('Event_Meta', |
|
212 | + 'EVT_default_registration_status', 'EEM_Event'); |
|
213 | + } |
|
214 | + } |
|
215 | + |
|
216 | + |
|
217 | + /** |
|
218 | + * get_question_groups |
|
219 | + * |
|
220 | + * @access public |
|
221 | + * @return array |
|
222 | + */ |
|
223 | + public function get_all_question_groups() |
|
224 | + { |
|
225 | + return EE_Registry::instance()->load_model('Question_Group')->get_all(array( |
|
226 | + array('QSG_deleted' => false), |
|
227 | + 'order_by' => array('QSG_order' => 'ASC') |
|
228 | + )); |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + /** |
|
233 | + * get_question_groups |
|
234 | + * |
|
235 | + * @access public |
|
236 | + * |
|
237 | + * @param int $EVT_ID |
|
238 | + * |
|
239 | + * @return array |
|
240 | + */ |
|
241 | + public function get_all_event_question_groups($EVT_ID = 0) |
|
242 | + { |
|
243 | + if ( ! isset($EVT_ID) || ! absint($EVT_ID)) { |
|
244 | + EE_Error::add_error(__('An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', |
|
245 | + 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
246 | 246 | |
247 | - return false; |
|
248 | - } |
|
249 | - |
|
250 | - return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(array( |
|
251 | - array('EVT_ID' => $EVT_ID) |
|
252 | - )); |
|
253 | - } |
|
254 | - |
|
255 | - |
|
256 | - /** |
|
257 | - * get_question_groups |
|
258 | - * |
|
259 | - * @access public |
|
260 | - * |
|
261 | - * @param int $EVT_ID |
|
262 | - * @param boolean $for_primary_attendee |
|
263 | - * |
|
264 | - * @return array |
|
265 | - */ |
|
266 | - public function get_event_question_groups($EVT_ID = 0, $for_primary_attendee = true) |
|
267 | - { |
|
268 | - if ( ! isset($EVT_ID) || ! absint($EVT_ID)) { |
|
269 | - EE_Error::add_error(__('An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', |
|
270 | - 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
247 | + return false; |
|
248 | + } |
|
249 | + |
|
250 | + return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(array( |
|
251 | + array('EVT_ID' => $EVT_ID) |
|
252 | + )); |
|
253 | + } |
|
254 | + |
|
255 | + |
|
256 | + /** |
|
257 | + * get_question_groups |
|
258 | + * |
|
259 | + * @access public |
|
260 | + * |
|
261 | + * @param int $EVT_ID |
|
262 | + * @param boolean $for_primary_attendee |
|
263 | + * |
|
264 | + * @return array |
|
265 | + */ |
|
266 | + public function get_event_question_groups($EVT_ID = 0, $for_primary_attendee = true) |
|
267 | + { |
|
268 | + if ( ! isset($EVT_ID) || ! absint($EVT_ID)) { |
|
269 | + EE_Error::add_error(__('An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', |
|
270 | + 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
271 | 271 | |
272 | - return false; |
|
273 | - } |
|
274 | - |
|
275 | - return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(array( |
|
276 | - array('EVT_ID' => $EVT_ID, 'EQG_primary' => $for_primary_attendee) |
|
277 | - )); |
|
278 | - } |
|
279 | - |
|
280 | - |
|
281 | - /** |
|
282 | - * get_question_groups |
|
283 | - * |
|
284 | - * @access public |
|
285 | - * |
|
286 | - * @param int $EVT_ID |
|
287 | - * @param EE_Registration $registration |
|
288 | - * |
|
289 | - * @return array |
|
290 | - */ |
|
291 | - public function get_question_groups_for_event($EVT_ID = 0, EE_Registration $registration) |
|
292 | - { |
|
293 | - |
|
294 | - if ( ! isset($EVT_ID) || ! absint($EVT_ID)) { |
|
295 | - EE_Error::add_error(__('An error occurred. No Question Groups could be retrieved because an Event ID was not received.', |
|
296 | - 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
272 | + return false; |
|
273 | + } |
|
274 | + |
|
275 | + return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(array( |
|
276 | + array('EVT_ID' => $EVT_ID, 'EQG_primary' => $for_primary_attendee) |
|
277 | + )); |
|
278 | + } |
|
279 | + |
|
280 | + |
|
281 | + /** |
|
282 | + * get_question_groups |
|
283 | + * |
|
284 | + * @access public |
|
285 | + * |
|
286 | + * @param int $EVT_ID |
|
287 | + * @param EE_Registration $registration |
|
288 | + * |
|
289 | + * @return array |
|
290 | + */ |
|
291 | + public function get_question_groups_for_event($EVT_ID = 0, EE_Registration $registration) |
|
292 | + { |
|
293 | + |
|
294 | + if ( ! isset($EVT_ID) || ! absint($EVT_ID)) { |
|
295 | + EE_Error::add_error(__('An error occurred. No Question Groups could be retrieved because an Event ID was not received.', |
|
296 | + 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
297 | 297 | |
298 | - return false; |
|
299 | - } |
|
300 | - |
|
301 | - $where_params = array( |
|
302 | - 'Event_Question_Group.EVT_ID' => $EVT_ID, |
|
303 | - 'Event_Question_Group.EQG_primary' => $registration->count() == 1 ? true : false, |
|
304 | - 'QSG_deleted' => false |
|
305 | - ); |
|
306 | - |
|
307 | - return EE_Registry::instance()->load_model('Question_Group')->get_all(array( |
|
308 | - $where_params, |
|
309 | - 'order_by' => array('QSG_order' => 'ASC') |
|
310 | - )); |
|
311 | - |
|
312 | - } |
|
313 | - |
|
314 | - |
|
315 | - /** |
|
316 | - * get_question_target_db_column |
|
317 | - * |
|
318 | - * @access public |
|
319 | - * |
|
320 | - * @param string $QSG_IDs csv list of $QSG IDs |
|
321 | - * |
|
322 | - * @return array |
|
323 | - */ |
|
324 | - public function get_questions_in_groups($QSG_IDs = '') |
|
325 | - { |
|
326 | - |
|
327 | - if (empty($QSG_IDs)) { |
|
328 | - EE_Error::add_error(__('An error occurred. No Question Group IDs were received.', 'event_espresso'), |
|
329 | - __FILE__, __FUNCTION__, __LINE__); |
|
298 | + return false; |
|
299 | + } |
|
300 | + |
|
301 | + $where_params = array( |
|
302 | + 'Event_Question_Group.EVT_ID' => $EVT_ID, |
|
303 | + 'Event_Question_Group.EQG_primary' => $registration->count() == 1 ? true : false, |
|
304 | + 'QSG_deleted' => false |
|
305 | + ); |
|
306 | + |
|
307 | + return EE_Registry::instance()->load_model('Question_Group')->get_all(array( |
|
308 | + $where_params, |
|
309 | + 'order_by' => array('QSG_order' => 'ASC') |
|
310 | + )); |
|
311 | + |
|
312 | + } |
|
313 | + |
|
314 | + |
|
315 | + /** |
|
316 | + * get_question_target_db_column |
|
317 | + * |
|
318 | + * @access public |
|
319 | + * |
|
320 | + * @param string $QSG_IDs csv list of $QSG IDs |
|
321 | + * |
|
322 | + * @return array |
|
323 | + */ |
|
324 | + public function get_questions_in_groups($QSG_IDs = '') |
|
325 | + { |
|
326 | + |
|
327 | + if (empty($QSG_IDs)) { |
|
328 | + EE_Error::add_error(__('An error occurred. No Question Group IDs were received.', 'event_espresso'), |
|
329 | + __FILE__, __FUNCTION__, __LINE__); |
|
330 | 330 | |
331 | - return false; |
|
332 | - } |
|
333 | - |
|
334 | - return EE_Registry::instance()->load_model('Question')->get_all(array( |
|
335 | - array( |
|
336 | - 'Question_Group.QSG_ID' => array('IN', $QSG_IDs), |
|
337 | - 'QST_deleted' => false, |
|
338 | - 'QST_admin_only' => is_admin() |
|
339 | - ), |
|
340 | - 'order_by' => 'QST_order' |
|
341 | - )); |
|
342 | - |
|
343 | - } |
|
344 | - |
|
345 | - |
|
346 | - /** |
|
347 | - * get_options_for_question |
|
348 | - * |
|
349 | - * @access public |
|
350 | - * |
|
351 | - * @param string $QST_IDs csv list of $QST IDs |
|
352 | - * |
|
353 | - * @return array |
|
354 | - */ |
|
355 | - public function get_options_for_question($QST_IDs) |
|
356 | - { |
|
357 | - |
|
358 | - if (empty($QST_IDs)) { |
|
359 | - EE_Error::add_error(__('An error occurred. No Question IDs were received.', 'event_espresso'), __FILE__, |
|
360 | - __FUNCTION__, __LINE__); |
|
331 | + return false; |
|
332 | + } |
|
333 | + |
|
334 | + return EE_Registry::instance()->load_model('Question')->get_all(array( |
|
335 | + array( |
|
336 | + 'Question_Group.QSG_ID' => array('IN', $QSG_IDs), |
|
337 | + 'QST_deleted' => false, |
|
338 | + 'QST_admin_only' => is_admin() |
|
339 | + ), |
|
340 | + 'order_by' => 'QST_order' |
|
341 | + )); |
|
342 | + |
|
343 | + } |
|
344 | + |
|
345 | + |
|
346 | + /** |
|
347 | + * get_options_for_question |
|
348 | + * |
|
349 | + * @access public |
|
350 | + * |
|
351 | + * @param string $QST_IDs csv list of $QST IDs |
|
352 | + * |
|
353 | + * @return array |
|
354 | + */ |
|
355 | + public function get_options_for_question($QST_IDs) |
|
356 | + { |
|
357 | + |
|
358 | + if (empty($QST_IDs)) { |
|
359 | + EE_Error::add_error(__('An error occurred. No Question IDs were received.', 'event_espresso'), __FILE__, |
|
360 | + __FUNCTION__, __LINE__); |
|
361 | 361 | |
362 | - return false; |
|
363 | - } |
|
364 | - |
|
365 | - return EE_Registry::instance()->load_model('Question_Option')->get_all(array( |
|
366 | - array( |
|
367 | - 'Question.QST_ID' => array('IN', $QST_IDs), |
|
368 | - 'QSO_deleted' => false |
|
369 | - ), |
|
370 | - 'order_by' => 'QSO_ID' |
|
371 | - )); |
|
372 | - |
|
373 | - } |
|
374 | - |
|
375 | - |
|
376 | - /** |
|
377 | - * _get_question_target_db_column |
|
378 | - * @deprecated as of 4.8.32.rc.001. Instead consider using |
|
379 | - * EE_Registration_Custom_Questions_Form located in |
|
380 | - * admin_pages/registrations/form_sections/EE_Registration_Custom_Questions_Form.form.php |
|
381 | - * @access public |
|
382 | - * |
|
383 | - * @param EE_Registration $registration (so existing answers for registration are included) |
|
384 | - * @param int $EVT_ID so all question groups are included for event (not just answers from |
|
385 | - * registration). |
|
386 | - * |
|
387 | - * @throws EE_Error |
|
388 | - * @return array |
|
389 | - */ |
|
390 | - public function assemble_array_of_groups_questions_and_options(EE_Registration $registration, $EVT_ID = 0) |
|
391 | - { |
|
392 | - |
|
393 | - if (empty($EVT_ID)) { |
|
394 | - throw new EE_Error(__('An error occurred. No EVT_ID is included. Needed to know which question groups to retrieve.', |
|
395 | - 'event_espresso')); |
|
396 | - } |
|
397 | - |
|
398 | - $questions = array(); |
|
399 | - |
|
400 | - // get all question groups for event |
|
401 | - $qgs = $this->get_question_groups_for_event($EVT_ID, $registration); |
|
402 | - if ( ! empty($qgs)) { |
|
403 | - foreach ($qgs as $qg) { |
|
404 | - $qsts = $qg->questions(); |
|
405 | - $questions[$qg->ID()] = $qg->model_field_array(); |
|
406 | - $questions[$qg->ID()]['QSG_questions'] = array(); |
|
407 | - foreach ($qsts as $qst) { |
|
408 | - if ($qst->is_system_question()) { |
|
409 | - continue; |
|
410 | - } |
|
411 | - $answer = EEM_Answer::instance()->get_one(array( |
|
412 | - array( |
|
413 | - 'QST_ID' => $qst->ID(), |
|
414 | - 'REG_ID' => $registration->ID() |
|
415 | - ) |
|
416 | - )); |
|
417 | - $answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object(); |
|
418 | - $qst_name = $qstn_id = $qst->ID(); |
|
419 | - $ans_id = $answer->ID(); |
|
420 | - $qst_name = ! empty($ans_id) ? '[' . $qst_name . '][' . $ans_id . ']' : '[' . $qst_name . ']'; |
|
421 | - $input_name = ''; |
|
422 | - $input_id = sanitize_key($qst->display_text()); |
|
423 | - $input_class = ''; |
|
424 | - $questions[$qg->ID()]['QSG_questions'][$qst->ID()] = $qst->model_field_array(); |
|
425 | - $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_name'] = 'qstn' . $input_name . $qst_name; |
|
426 | - $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_id'] = $input_id . '-' . $qstn_id; |
|
427 | - $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_class'] = $input_class; |
|
428 | - $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'] = array(); |
|
429 | - $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['qst_obj'] = $qst; |
|
430 | - $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['ans_obj'] = $answer; |
|
431 | - //leave responses as-is, don't convert stuff into html entities please! |
|
432 | - $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['htmlentities'] = false; |
|
433 | - if ($qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN') { |
|
434 | - $QSOs = $qst->options(true, $answer->value()); |
|
435 | - if (is_array($QSOs)) { |
|
436 | - foreach ($QSOs as $QSO_ID => $QSO) { |
|
437 | - $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'][$QSO_ID] = $QSO->model_field_array(); |
|
438 | - } |
|
439 | - } |
|
440 | - } |
|
362 | + return false; |
|
363 | + } |
|
364 | + |
|
365 | + return EE_Registry::instance()->load_model('Question_Option')->get_all(array( |
|
366 | + array( |
|
367 | + 'Question.QST_ID' => array('IN', $QST_IDs), |
|
368 | + 'QSO_deleted' => false |
|
369 | + ), |
|
370 | + 'order_by' => 'QSO_ID' |
|
371 | + )); |
|
372 | + |
|
373 | + } |
|
374 | + |
|
375 | + |
|
376 | + /** |
|
377 | + * _get_question_target_db_column |
|
378 | + * @deprecated as of 4.8.32.rc.001. Instead consider using |
|
379 | + * EE_Registration_Custom_Questions_Form located in |
|
380 | + * admin_pages/registrations/form_sections/EE_Registration_Custom_Questions_Form.form.php |
|
381 | + * @access public |
|
382 | + * |
|
383 | + * @param EE_Registration $registration (so existing answers for registration are included) |
|
384 | + * @param int $EVT_ID so all question groups are included for event (not just answers from |
|
385 | + * registration). |
|
386 | + * |
|
387 | + * @throws EE_Error |
|
388 | + * @return array |
|
389 | + */ |
|
390 | + public function assemble_array_of_groups_questions_and_options(EE_Registration $registration, $EVT_ID = 0) |
|
391 | + { |
|
392 | + |
|
393 | + if (empty($EVT_ID)) { |
|
394 | + throw new EE_Error(__('An error occurred. No EVT_ID is included. Needed to know which question groups to retrieve.', |
|
395 | + 'event_espresso')); |
|
396 | + } |
|
397 | + |
|
398 | + $questions = array(); |
|
399 | + |
|
400 | + // get all question groups for event |
|
401 | + $qgs = $this->get_question_groups_for_event($EVT_ID, $registration); |
|
402 | + if ( ! empty($qgs)) { |
|
403 | + foreach ($qgs as $qg) { |
|
404 | + $qsts = $qg->questions(); |
|
405 | + $questions[$qg->ID()] = $qg->model_field_array(); |
|
406 | + $questions[$qg->ID()]['QSG_questions'] = array(); |
|
407 | + foreach ($qsts as $qst) { |
|
408 | + if ($qst->is_system_question()) { |
|
409 | + continue; |
|
410 | + } |
|
411 | + $answer = EEM_Answer::instance()->get_one(array( |
|
412 | + array( |
|
413 | + 'QST_ID' => $qst->ID(), |
|
414 | + 'REG_ID' => $registration->ID() |
|
415 | + ) |
|
416 | + )); |
|
417 | + $answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object(); |
|
418 | + $qst_name = $qstn_id = $qst->ID(); |
|
419 | + $ans_id = $answer->ID(); |
|
420 | + $qst_name = ! empty($ans_id) ? '[' . $qst_name . '][' . $ans_id . ']' : '[' . $qst_name . ']'; |
|
421 | + $input_name = ''; |
|
422 | + $input_id = sanitize_key($qst->display_text()); |
|
423 | + $input_class = ''; |
|
424 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()] = $qst->model_field_array(); |
|
425 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_name'] = 'qstn' . $input_name . $qst_name; |
|
426 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_id'] = $input_id . '-' . $qstn_id; |
|
427 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_class'] = $input_class; |
|
428 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'] = array(); |
|
429 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['qst_obj'] = $qst; |
|
430 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['ans_obj'] = $answer; |
|
431 | + //leave responses as-is, don't convert stuff into html entities please! |
|
432 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['htmlentities'] = false; |
|
433 | + if ($qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN') { |
|
434 | + $QSOs = $qst->options(true, $answer->value()); |
|
435 | + if (is_array($QSOs)) { |
|
436 | + foreach ($QSOs as $QSO_ID => $QSO) { |
|
437 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'][$QSO_ID] = $QSO->model_field_array(); |
|
438 | + } |
|
439 | + } |
|
440 | + } |
|
441 | 441 | |
442 | - } |
|
443 | - } |
|
444 | - } |
|
445 | - |
|
446 | - return $questions; |
|
447 | - } |
|
448 | - |
|
449 | - |
|
450 | - /** |
|
451 | - * _get_question_target_db_column |
|
452 | - * |
|
453 | - * @access private |
|
454 | - * |
|
455 | - * @param $QST |
|
456 | - * |
|
457 | - * @return string string |
|
458 | - */ |
|
459 | - private function _generate_question_input_name($QST) |
|
460 | - { |
|
461 | - |
|
462 | - if ($QST->QST_system) { |
|
463 | - $qst_name = $QST->QST_system; |
|
464 | - /* switch( $QST->QST_system ) { |
|
442 | + } |
|
443 | + } |
|
444 | + } |
|
445 | + |
|
446 | + return $questions; |
|
447 | + } |
|
448 | + |
|
449 | + |
|
450 | + /** |
|
451 | + * _get_question_target_db_column |
|
452 | + * |
|
453 | + * @access private |
|
454 | + * |
|
455 | + * @param $QST |
|
456 | + * |
|
457 | + * @return string string |
|
458 | + */ |
|
459 | + private function _generate_question_input_name($QST) |
|
460 | + { |
|
461 | + |
|
462 | + if ($QST->QST_system) { |
|
463 | + $qst_name = $QST->QST_system; |
|
464 | + /* switch( $QST->QST_system ) { |
|
465 | 465 | |
466 | 466 | case 1 : |
467 | 467 | $qst_name = $QST->QST_ID . '-fname'; |
@@ -505,261 +505,261 @@ discard block |
||
505 | 505 | |
506 | 506 | }*/ |
507 | 507 | |
508 | - } else { |
|
509 | - //$qst_name = $QST->QST_ID . '-' . str_replace( array( ' ', '-', '.' ), '_', strtolower( $QST->QST_display_text )); |
|
510 | - $qst_name = $QST->QST_ID; |
|
511 | - } |
|
512 | - |
|
513 | - return $qst_name; |
|
514 | - } |
|
515 | - |
|
516 | - |
|
517 | - /** |
|
518 | - * Gets all events that are published and have event start time earlier than now and an event end time later than |
|
519 | - * now |
|
520 | - * |
|
521 | - * @access public |
|
522 | - * |
|
523 | - * @param array $query_params An array of query params to further filter on (note that status and DTT_EVT_start |
|
524 | - * and DTT_EVT_end will be overridden) |
|
525 | - * @param bool $count whether to return the count or not (default FALSE) |
|
526 | - * |
|
527 | - * @return array EE_Event objects |
|
528 | - */ |
|
529 | - public function get_active_events($query_params, $count = false) |
|
530 | - { |
|
531 | - if (array_key_exists(0, $query_params)) { |
|
532 | - $where_params = $query_params[0]; |
|
533 | - unset($query_params[0]); |
|
534 | - } else { |
|
535 | - $where_params = array(); |
|
536 | - } |
|
537 | - |
|
538 | - //if we have count make sure we don't include group by |
|
539 | - if ($count && isset($query_params['group_by'])) { |
|
540 | - unset($query_params['group_by']); |
|
541 | - } |
|
542 | - |
|
543 | - //let's add specific query_params for active_events - keep in mind this will override any sent status in the query AND any date queries. |
|
544 | - $where_params['status'] = array( 'IN', array( 'publish', EEM_Event::sold_out ) ); |
|
545 | - //if already have where params for DTT_EVT_start or DTT_EVT_end then append these conditions |
|
546 | - if (isset($where_params['Datetime.DTT_EVT_start'])) { |
|
547 | - $where_params['Datetime.DTT_EVT_start******'] = array( |
|
548 | - '<', |
|
549 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start') |
|
550 | - ); |
|
551 | - } else { |
|
552 | - $where_params['Datetime.DTT_EVT_start'] = array( |
|
553 | - '<', |
|
554 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start') |
|
555 | - ); |
|
556 | - } |
|
557 | - |
|
558 | - if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
559 | - $where_params['Datetime.DTT_EVT_end*****'] = array( |
|
560 | - '>', |
|
561 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end') |
|
562 | - ); |
|
563 | - } else { |
|
564 | - $where_params['Datetime.DTT_EVT_end'] = array( |
|
565 | - '>', |
|
566 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end') |
|
567 | - ); |
|
568 | - } |
|
569 | - $query_params[0] = $where_params; |
|
570 | - |
|
571 | - // don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY" |
|
572 | - return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params); |
|
573 | - } |
|
574 | - |
|
575 | - |
|
576 | - /** |
|
577 | - * get all events that are published and have an event start time later than now |
|
578 | - * |
|
579 | - * @access public |
|
580 | - * |
|
581 | - * @param array $query_params An array of query params to further filter on (Note that status and DTT_EVT_start |
|
582 | - * will be overridden) |
|
583 | - * @param bool $count whether to return the count or not (default FALSE) |
|
584 | - * |
|
585 | - * @return array EE_Event objects |
|
586 | - */ |
|
587 | - public function get_upcoming_events($query_params, $count = false) |
|
588 | - { |
|
589 | - if (array_key_exists(0, $query_params)) { |
|
590 | - $where_params = $query_params[0]; |
|
591 | - unset($query_params[0]); |
|
592 | - } else { |
|
593 | - $where_params = array(); |
|
594 | - } |
|
595 | - |
|
596 | - //if we have count make sure we don't include group by |
|
597 | - if ($count && isset($query_params['group_by'])) { |
|
598 | - unset($query_params['group_by']); |
|
599 | - } |
|
600 | - |
|
601 | - //let's add specific query_params for active_events - keep in mind this will override any sent status in the query AND any date queries. |
|
602 | - $where_params['status'] = array( 'IN', array( 'publish', EEM_Event::sold_out ) ); |
|
603 | - //if there are already query_params matching DTT_EVT_start then we need to modify that to add them. |
|
604 | - if (isset($where_params['Datetime.DTT_EVT_start'])) { |
|
605 | - $where_params['Datetime.DTT_EVT_start*****'] = array( |
|
606 | - '>', |
|
607 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start') |
|
608 | - ); |
|
609 | - } else { |
|
610 | - $where_params['Datetime.DTT_EVT_start'] = array( |
|
611 | - '>', |
|
612 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start') |
|
613 | - ); |
|
614 | - } |
|
615 | - $query_params[0] = $where_params; |
|
616 | - |
|
617 | - // don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY" |
|
618 | - return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params); |
|
619 | - } |
|
620 | - |
|
621 | - |
|
622 | - /** |
|
623 | - * This only returns events that are expired. They may still be published but all their datetimes have expired. |
|
624 | - * |
|
625 | - * @access public |
|
626 | - * |
|
627 | - * @param array $query_params An array of query params to further filter on (note that status and DTT_EVT_end will |
|
628 | - * be overridden) |
|
629 | - * @param bool $count whether to return the count or not (default FALSE) |
|
630 | - * |
|
631 | - * @return array EE_Event objects |
|
632 | - */ |
|
633 | - public function get_expired_events($query_params, $count = false) |
|
634 | - { |
|
635 | - |
|
636 | - $where_params = isset($query_params[0]) ? $query_params[0] : array(); |
|
637 | - |
|
638 | - //if we have count make sure we don't include group by |
|
639 | - if ($count && isset($query_params['group_by'])) { |
|
640 | - unset($query_params['group_by']); |
|
641 | - } |
|
642 | - |
|
643 | - //let's add specific query_params for active_events - keep in mind this will override any sent status in the query AND any date queries. |
|
644 | - if (isset($where_params['status'])) { |
|
645 | - unset($where_params['status']); |
|
646 | - } |
|
647 | - $exclude_query = $query_params; |
|
648 | - if (isset($exclude_query[0])) { |
|
649 | - unset($exclude_query[0]); |
|
650 | - } |
|
651 | - $exclude_query[0] = array( |
|
652 | - 'Datetime.DTT_EVT_end' => array( |
|
653 | - '>', |
|
654 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end') |
|
655 | - ) |
|
656 | - ); |
|
657 | - //first get all events that have datetimes where its not expired. |
|
658 | - $event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Event_CPT.ID'); |
|
659 | - $event_ids = array_keys($event_ids); |
|
660 | - |
|
661 | - //if we have any additional query_params, let's add them to the 'AND' condition |
|
662 | - $and_condition = array( |
|
663 | - 'Datetime.DTT_EVT_end' => array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')), |
|
664 | - 'EVT_ID' => array('NOT IN', $event_ids) |
|
665 | - ); |
|
666 | - |
|
667 | - if (isset($where_params['OR'])) { |
|
668 | - $and_condition['OR'] = $where_params['OR']; |
|
669 | - unset($where_params['OR']); |
|
670 | - } |
|
671 | - |
|
672 | - if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
673 | - $and_condition['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end']; |
|
674 | - unset($where_params['Datetime.DTT_EVT_end']); |
|
675 | - } |
|
676 | - |
|
677 | - if (isset($where_params['Datetime.DTT_EVT_start'])) { |
|
678 | - $and_condition['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start']; |
|
679 | - unset($where_params['Datetime.DTT_EVT_start']); |
|
680 | - } |
|
681 | - |
|
682 | - //merge remaining $where params with the and conditions. |
|
683 | - $where_params['AND'] = array_merge($and_condition, $where_params); |
|
684 | - $query_params[0] = $where_params; |
|
685 | - |
|
686 | - // don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY" |
|
687 | - return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params); |
|
688 | - } |
|
689 | - |
|
690 | - |
|
691 | - /** |
|
692 | - * This basically just returns the events that do not have the publish status. |
|
693 | - * |
|
694 | - * @param array $query_params An array of query params to further filter on (note that status will be |
|
695 | - * overwritten) |
|
696 | - * @param boolean $count whether to return the count or not (default FALSE) |
|
697 | - * |
|
698 | - * @return EE_Event[] array of EE_Event objects |
|
699 | - */ |
|
700 | - public function get_inactive_events($query_params, $count = false) |
|
701 | - { |
|
702 | - $where_params = isset($query_params[0]) ? $query_params[0] : array(); |
|
703 | - |
|
704 | - //let's add in specific query_params for inactive events. |
|
705 | - if (isset($where_params['status'])) { |
|
706 | - unset($where_params['status']); |
|
707 | - } |
|
708 | - |
|
709 | - //if we have count make sure we don't include group by |
|
710 | - if ($count && isset($query_params['group_by'])) { |
|
711 | - unset($query_params['group_by']); |
|
712 | - } |
|
713 | - |
|
714 | - //if we have any additional query_params, let's add them to the 'AND' condition |
|
715 | - $where_params['AND']['status'] = array('!=', 'publish'); |
|
716 | - |
|
717 | - if (isset($where_params['OR'])) { |
|
718 | - $where_params['AND']['OR'] = $where_params['OR']; |
|
719 | - unset($where_params['OR']); |
|
720 | - } |
|
721 | - |
|
722 | - if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
723 | - $where_params['AND']['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end']; |
|
724 | - unset($where_params['Datetime.DTT_EVT_end']); |
|
725 | - } |
|
726 | - |
|
727 | - if (isset($where_params['Datetime.DTT_EVT_start'])) { |
|
728 | - $where_params['AND']['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start']; |
|
729 | - unset($where_params['Datetime.DTT_EVT_start']); |
|
730 | - } |
|
731 | - |
|
732 | - $query_params[0] = $where_params; |
|
733 | - |
|
734 | - // don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY" |
|
735 | - return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params); |
|
736 | - } |
|
737 | - |
|
738 | - |
|
739 | - /** |
|
740 | - * This is just injecting into the parent add_relationship_to so we do special handling on price relationships |
|
741 | - * because we don't want to override any existing global default prices but instead insert NEW prices that get |
|
742 | - * attached to the event. See parent for param descriptions |
|
743 | - */ |
|
744 | - public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) |
|
745 | - { |
|
746 | - |
|
747 | - if ($relationName == 'Price') { |
|
748 | - //let's get the PRC object for the given ID to make sure that we aren't dealing with a default |
|
749 | - $prc_chk = $this->get_related_model_obj($relationName)->ensure_is_obj($other_model_id_or_obj); |
|
750 | - //if EVT_ID = 0, then this is a default |
|
751 | - if ($prc_chk->get('EVT_ID') == 0) { |
|
752 | - //let's set the prc_id as 0 so we force an insert on the add_relation_to carried out by relation |
|
753 | - $prc_chk->set('PRC_ID', 0); |
|
754 | - } |
|
508 | + } else { |
|
509 | + //$qst_name = $QST->QST_ID . '-' . str_replace( array( ' ', '-', '.' ), '_', strtolower( $QST->QST_display_text )); |
|
510 | + $qst_name = $QST->QST_ID; |
|
511 | + } |
|
512 | + |
|
513 | + return $qst_name; |
|
514 | + } |
|
515 | + |
|
516 | + |
|
517 | + /** |
|
518 | + * Gets all events that are published and have event start time earlier than now and an event end time later than |
|
519 | + * now |
|
520 | + * |
|
521 | + * @access public |
|
522 | + * |
|
523 | + * @param array $query_params An array of query params to further filter on (note that status and DTT_EVT_start |
|
524 | + * and DTT_EVT_end will be overridden) |
|
525 | + * @param bool $count whether to return the count or not (default FALSE) |
|
526 | + * |
|
527 | + * @return array EE_Event objects |
|
528 | + */ |
|
529 | + public function get_active_events($query_params, $count = false) |
|
530 | + { |
|
531 | + if (array_key_exists(0, $query_params)) { |
|
532 | + $where_params = $query_params[0]; |
|
533 | + unset($query_params[0]); |
|
534 | + } else { |
|
535 | + $where_params = array(); |
|
536 | + } |
|
537 | + |
|
538 | + //if we have count make sure we don't include group by |
|
539 | + if ($count && isset($query_params['group_by'])) { |
|
540 | + unset($query_params['group_by']); |
|
541 | + } |
|
542 | + |
|
543 | + //let's add specific query_params for active_events - keep in mind this will override any sent status in the query AND any date queries. |
|
544 | + $where_params['status'] = array( 'IN', array( 'publish', EEM_Event::sold_out ) ); |
|
545 | + //if already have where params for DTT_EVT_start or DTT_EVT_end then append these conditions |
|
546 | + if (isset($where_params['Datetime.DTT_EVT_start'])) { |
|
547 | + $where_params['Datetime.DTT_EVT_start******'] = array( |
|
548 | + '<', |
|
549 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start') |
|
550 | + ); |
|
551 | + } else { |
|
552 | + $where_params['Datetime.DTT_EVT_start'] = array( |
|
553 | + '<', |
|
554 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start') |
|
555 | + ); |
|
556 | + } |
|
557 | + |
|
558 | + if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
559 | + $where_params['Datetime.DTT_EVT_end*****'] = array( |
|
560 | + '>', |
|
561 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end') |
|
562 | + ); |
|
563 | + } else { |
|
564 | + $where_params['Datetime.DTT_EVT_end'] = array( |
|
565 | + '>', |
|
566 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end') |
|
567 | + ); |
|
568 | + } |
|
569 | + $query_params[0] = $where_params; |
|
570 | + |
|
571 | + // don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY" |
|
572 | + return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params); |
|
573 | + } |
|
574 | + |
|
575 | + |
|
576 | + /** |
|
577 | + * get all events that are published and have an event start time later than now |
|
578 | + * |
|
579 | + * @access public |
|
580 | + * |
|
581 | + * @param array $query_params An array of query params to further filter on (Note that status and DTT_EVT_start |
|
582 | + * will be overridden) |
|
583 | + * @param bool $count whether to return the count or not (default FALSE) |
|
584 | + * |
|
585 | + * @return array EE_Event objects |
|
586 | + */ |
|
587 | + public function get_upcoming_events($query_params, $count = false) |
|
588 | + { |
|
589 | + if (array_key_exists(0, $query_params)) { |
|
590 | + $where_params = $query_params[0]; |
|
591 | + unset($query_params[0]); |
|
592 | + } else { |
|
593 | + $where_params = array(); |
|
594 | + } |
|
595 | + |
|
596 | + //if we have count make sure we don't include group by |
|
597 | + if ($count && isset($query_params['group_by'])) { |
|
598 | + unset($query_params['group_by']); |
|
599 | + } |
|
600 | + |
|
601 | + //let's add specific query_params for active_events - keep in mind this will override any sent status in the query AND any date queries. |
|
602 | + $where_params['status'] = array( 'IN', array( 'publish', EEM_Event::sold_out ) ); |
|
603 | + //if there are already query_params matching DTT_EVT_start then we need to modify that to add them. |
|
604 | + if (isset($where_params['Datetime.DTT_EVT_start'])) { |
|
605 | + $where_params['Datetime.DTT_EVT_start*****'] = array( |
|
606 | + '>', |
|
607 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start') |
|
608 | + ); |
|
609 | + } else { |
|
610 | + $where_params['Datetime.DTT_EVT_start'] = array( |
|
611 | + '>', |
|
612 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start') |
|
613 | + ); |
|
614 | + } |
|
615 | + $query_params[0] = $where_params; |
|
616 | + |
|
617 | + // don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY" |
|
618 | + return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params); |
|
619 | + } |
|
620 | + |
|
621 | + |
|
622 | + /** |
|
623 | + * This only returns events that are expired. They may still be published but all their datetimes have expired. |
|
624 | + * |
|
625 | + * @access public |
|
626 | + * |
|
627 | + * @param array $query_params An array of query params to further filter on (note that status and DTT_EVT_end will |
|
628 | + * be overridden) |
|
629 | + * @param bool $count whether to return the count or not (default FALSE) |
|
630 | + * |
|
631 | + * @return array EE_Event objects |
|
632 | + */ |
|
633 | + public function get_expired_events($query_params, $count = false) |
|
634 | + { |
|
635 | + |
|
636 | + $where_params = isset($query_params[0]) ? $query_params[0] : array(); |
|
637 | + |
|
638 | + //if we have count make sure we don't include group by |
|
639 | + if ($count && isset($query_params['group_by'])) { |
|
640 | + unset($query_params['group_by']); |
|
641 | + } |
|
642 | + |
|
643 | + //let's add specific query_params for active_events - keep in mind this will override any sent status in the query AND any date queries. |
|
644 | + if (isset($where_params['status'])) { |
|
645 | + unset($where_params['status']); |
|
646 | + } |
|
647 | + $exclude_query = $query_params; |
|
648 | + if (isset($exclude_query[0])) { |
|
649 | + unset($exclude_query[0]); |
|
650 | + } |
|
651 | + $exclude_query[0] = array( |
|
652 | + 'Datetime.DTT_EVT_end' => array( |
|
653 | + '>', |
|
654 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end') |
|
655 | + ) |
|
656 | + ); |
|
657 | + //first get all events that have datetimes where its not expired. |
|
658 | + $event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Event_CPT.ID'); |
|
659 | + $event_ids = array_keys($event_ids); |
|
660 | + |
|
661 | + //if we have any additional query_params, let's add them to the 'AND' condition |
|
662 | + $and_condition = array( |
|
663 | + 'Datetime.DTT_EVT_end' => array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')), |
|
664 | + 'EVT_ID' => array('NOT IN', $event_ids) |
|
665 | + ); |
|
666 | + |
|
667 | + if (isset($where_params['OR'])) { |
|
668 | + $and_condition['OR'] = $where_params['OR']; |
|
669 | + unset($where_params['OR']); |
|
670 | + } |
|
671 | + |
|
672 | + if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
673 | + $and_condition['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end']; |
|
674 | + unset($where_params['Datetime.DTT_EVT_end']); |
|
675 | + } |
|
676 | + |
|
677 | + if (isset($where_params['Datetime.DTT_EVT_start'])) { |
|
678 | + $and_condition['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start']; |
|
679 | + unset($where_params['Datetime.DTT_EVT_start']); |
|
680 | + } |
|
681 | + |
|
682 | + //merge remaining $where params with the and conditions. |
|
683 | + $where_params['AND'] = array_merge($and_condition, $where_params); |
|
684 | + $query_params[0] = $where_params; |
|
685 | + |
|
686 | + // don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY" |
|
687 | + return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params); |
|
688 | + } |
|
689 | + |
|
690 | + |
|
691 | + /** |
|
692 | + * This basically just returns the events that do not have the publish status. |
|
693 | + * |
|
694 | + * @param array $query_params An array of query params to further filter on (note that status will be |
|
695 | + * overwritten) |
|
696 | + * @param boolean $count whether to return the count or not (default FALSE) |
|
697 | + * |
|
698 | + * @return EE_Event[] array of EE_Event objects |
|
699 | + */ |
|
700 | + public function get_inactive_events($query_params, $count = false) |
|
701 | + { |
|
702 | + $where_params = isset($query_params[0]) ? $query_params[0] : array(); |
|
703 | + |
|
704 | + //let's add in specific query_params for inactive events. |
|
705 | + if (isset($where_params['status'])) { |
|
706 | + unset($where_params['status']); |
|
707 | + } |
|
708 | + |
|
709 | + //if we have count make sure we don't include group by |
|
710 | + if ($count && isset($query_params['group_by'])) { |
|
711 | + unset($query_params['group_by']); |
|
712 | + } |
|
713 | + |
|
714 | + //if we have any additional query_params, let's add them to the 'AND' condition |
|
715 | + $where_params['AND']['status'] = array('!=', 'publish'); |
|
716 | + |
|
717 | + if (isset($where_params['OR'])) { |
|
718 | + $where_params['AND']['OR'] = $where_params['OR']; |
|
719 | + unset($where_params['OR']); |
|
720 | + } |
|
721 | + |
|
722 | + if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
723 | + $where_params['AND']['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end']; |
|
724 | + unset($where_params['Datetime.DTT_EVT_end']); |
|
725 | + } |
|
726 | + |
|
727 | + if (isset($where_params['Datetime.DTT_EVT_start'])) { |
|
728 | + $where_params['AND']['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start']; |
|
729 | + unset($where_params['Datetime.DTT_EVT_start']); |
|
730 | + } |
|
731 | + |
|
732 | + $query_params[0] = $where_params; |
|
733 | + |
|
734 | + // don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY" |
|
735 | + return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params); |
|
736 | + } |
|
737 | + |
|
738 | + |
|
739 | + /** |
|
740 | + * This is just injecting into the parent add_relationship_to so we do special handling on price relationships |
|
741 | + * because we don't want to override any existing global default prices but instead insert NEW prices that get |
|
742 | + * attached to the event. See parent for param descriptions |
|
743 | + */ |
|
744 | + public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) |
|
745 | + { |
|
746 | + |
|
747 | + if ($relationName == 'Price') { |
|
748 | + //let's get the PRC object for the given ID to make sure that we aren't dealing with a default |
|
749 | + $prc_chk = $this->get_related_model_obj($relationName)->ensure_is_obj($other_model_id_or_obj); |
|
750 | + //if EVT_ID = 0, then this is a default |
|
751 | + if ($prc_chk->get('EVT_ID') == 0) { |
|
752 | + //let's set the prc_id as 0 so we force an insert on the add_relation_to carried out by relation |
|
753 | + $prc_chk->set('PRC_ID', 0); |
|
754 | + } |
|
755 | 755 | |
756 | - //run parent |
|
757 | - return parent::add_relationship_to($id_or_obj, $prc_chk, $relationName, $where_query); |
|
758 | - } |
|
756 | + //run parent |
|
757 | + return parent::add_relationship_to($id_or_obj, $prc_chk, $relationName, $where_query); |
|
758 | + } |
|
759 | 759 | |
760 | - //otherwise carry on as normal |
|
761 | - return parent::add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query); |
|
762 | - } |
|
760 | + //otherwise carry on as normal |
|
761 | + return parent::add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query); |
|
762 | + } |
|
763 | 763 | |
764 | 764 | |
765 | 765 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | -require_once(EE_MODELS . 'EEM_CPT_Base.model.php'); |
|
4 | +require_once(EE_MODELS.'EEM_CPT_Base.model.php'); |
|
5 | 5 | |
6 | 6 | /** |
7 | 7 | * |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | if ($qst->is_system_question()) { |
409 | 409 | continue; |
410 | 410 | } |
411 | - $answer = EEM_Answer::instance()->get_one(array( |
|
411 | + $answer = EEM_Answer::instance()->get_one(array( |
|
412 | 412 | array( |
413 | 413 | 'QST_ID' => $qst->ID(), |
414 | 414 | 'REG_ID' => $registration->ID() |
@@ -417,13 +417,13 @@ discard block |
||
417 | 417 | $answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object(); |
418 | 418 | $qst_name = $qstn_id = $qst->ID(); |
419 | 419 | $ans_id = $answer->ID(); |
420 | - $qst_name = ! empty($ans_id) ? '[' . $qst_name . '][' . $ans_id . ']' : '[' . $qst_name . ']'; |
|
420 | + $qst_name = ! empty($ans_id) ? '['.$qst_name.']['.$ans_id.']' : '['.$qst_name.']'; |
|
421 | 421 | $input_name = ''; |
422 | 422 | $input_id = sanitize_key($qst->display_text()); |
423 | 423 | $input_class = ''; |
424 | 424 | $questions[$qg->ID()]['QSG_questions'][$qst->ID()] = $qst->model_field_array(); |
425 | - $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_name'] = 'qstn' . $input_name . $qst_name; |
|
426 | - $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_id'] = $input_id . '-' . $qstn_id; |
|
425 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_name'] = 'qstn'.$input_name.$qst_name; |
|
426 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_id'] = $input_id.'-'.$qstn_id; |
|
427 | 427 | $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_class'] = $input_class; |
428 | 428 | $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'] = array(); |
429 | 429 | $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['qst_obj'] = $qst; |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | } |
542 | 542 | |
543 | 543 | //let's add specific query_params for active_events - keep in mind this will override any sent status in the query AND any date queries. |
544 | - $where_params['status'] = array( 'IN', array( 'publish', EEM_Event::sold_out ) ); |
|
544 | + $where_params['status'] = array('IN', array('publish', EEM_Event::sold_out)); |
|
545 | 545 | //if already have where params for DTT_EVT_start or DTT_EVT_end then append these conditions |
546 | 546 | if (isset($where_params['Datetime.DTT_EVT_start'])) { |
547 | 547 | $where_params['Datetime.DTT_EVT_start******'] = array( |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | } |
600 | 600 | |
601 | 601 | //let's add specific query_params for active_events - keep in mind this will override any sent status in the query AND any date queries. |
602 | - $where_params['status'] = array( 'IN', array( 'publish', EEM_Event::sold_out ) ); |
|
602 | + $where_params['status'] = array('IN', array('publish', EEM_Event::sold_out)); |
|
603 | 603 | //if there are already query_params matching DTT_EVT_start then we need to modify that to add them. |
604 | 604 | if (isset($where_params['Datetime.DTT_EVT_start'])) { |
605 | 605 | $where_params['Datetime.DTT_EVT_start*****'] = array( |
@@ -16,149 +16,149 @@ |
||
16 | 16 | class DatetimeSelector |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var \EE_Event $event |
|
21 | - */ |
|
22 | - protected $event; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var \EE_Ticket[] $tickets |
|
26 | - */ |
|
27 | - protected $tickets; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var \EE_Datetime[] $datetimes |
|
31 | - */ |
|
32 | - protected $datetimes; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var \EE_Ticket_Selector_Config $template_settings |
|
36 | - */ |
|
37 | - protected $template_settings; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var boolean $active |
|
41 | - */ |
|
42 | - protected $active = false; |
|
43 | - |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * DatetimeSelector constructor. |
|
48 | - * |
|
49 | - * @param \EE_Event $event |
|
50 | - * @param \EE_Ticket[] $tickets |
|
51 | - * @param \EE_Ticket_Selector_Config $template_settings |
|
52 | - * @throws \EE_Error |
|
53 | - */ |
|
54 | - public function __construct(\EE_Event $event, array $tickets, \EE_Ticket_Selector_Config $template_settings) |
|
55 | - { |
|
56 | - $this->event = $event; |
|
57 | - $this->tickets = $tickets; |
|
58 | - $this->template_settings = $template_settings; |
|
59 | - $this->datetimes = $this->getAllDatetimesForAllTicket($tickets); |
|
60 | - $this->active = $this->template_settings->showDatetimeSelector($this->datetimes); |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * @param \EE_Ticket[] $tickets |
|
67 | - * @return array |
|
68 | - * @throws \EE_Error |
|
69 | - */ |
|
70 | - protected function getAllDatetimesForAllTicket($tickets = array()) |
|
71 | - { |
|
72 | - $datetimes = array(); |
|
73 | - foreach ($tickets as $ticket) { |
|
74 | - $datetimes = $this->getTicketDatetimes($ticket, $datetimes); |
|
75 | - } |
|
76 | - return $datetimes; |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * @param \EE_Ticket $ticket |
|
83 | - * @param \EE_Datetime[] $datetimes |
|
84 | - * @return \EE_Datetime[] |
|
85 | - * @throws \EE_Error |
|
86 | - */ |
|
87 | - protected function getTicketDatetimes(\EE_Ticket $ticket, $datetimes = array()) |
|
88 | - { |
|
89 | - $ticket_datetimes = $ticket->datetimes(); |
|
90 | - foreach ($ticket_datetimes as $ticket_datetime) { |
|
91 | - if ( ! $ticket_datetime instanceof \EE_Datetime) { |
|
92 | - continue; |
|
93 | - } |
|
94 | - $datetimes[ $ticket_datetime->ID() ] = $ticket_datetime; |
|
95 | - } |
|
96 | - return $datetimes; |
|
97 | - } |
|
98 | - |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * @param \EE_Ticket $ticket |
|
103 | - * @return string |
|
104 | - * @throws \EE_Error |
|
105 | - */ |
|
106 | - public function getTicketDatetimeClasses( \EE_Ticket $ticket ) { |
|
107 | - if ( ! $this->active) { |
|
108 | - return ''; |
|
109 | - } |
|
110 | - $ticket_datetimes = $this->getTicketDatetimes($ticket); |
|
111 | - $classes = ''; |
|
112 | - foreach ($this->datetimes as $datetime) { |
|
113 | - if ( ! $datetime instanceof \EE_Datetime || ! in_array($datetime, $ticket_datetimes)) { |
|
114 | - continue; |
|
115 | - } |
|
116 | - $classes .= ' ee-ticket-datetimes-' . $datetime->date_range('Y_m_d', '-'); |
|
117 | - } |
|
118 | - $classes .= ' ee-hidden-ticket-tr'; |
|
119 | - return $classes; |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * @param string $date_format |
|
126 | - * @return string |
|
127 | - * @throws \EE_Error |
|
128 | - */ |
|
129 | - public function getDatetimeSelector($date_format = 'Y-m-d') { |
|
130 | - if ( ! $this->active) { |
|
131 | - return ''; |
|
132 | - } |
|
133 | - $html = \EEH_HTML::div('', '', 'datetime_selector-dv'); |
|
134 | - $html .= \EEH_HTML::label( |
|
135 | - \EEH_HTML::span('', '', 'dashicons dashicons-calendar-alt') . esc_html__('Datetimes', 'event_espresso'), |
|
136 | - '', 'datetime_selector-lbl' |
|
137 | - ); |
|
138 | - $html .= \EEH_HTML::div( '', '', 'select-wrap-dv' ); |
|
139 | - $html .= "\n" . '<select name="datetime_selector-' . $this->event->ID() . '"'; |
|
140 | - $html .= ' id="datetime-selector-' . $this->event->ID() . '"'; |
|
141 | - $html .= ' class="ticket-selector-datetime-selector-slct"'; |
|
142 | - $html .= ' data-tkt_slctr_evt="' . $this->event->ID() . '">'; |
|
143 | - $html .= "\n" |
|
144 | - . '<option value="0">' |
|
145 | - . esc_html__('- please select a datetime -', 'event_espresso') |
|
146 | - . '</option>'; |
|
147 | - // offer ticket quantities from the min to the max |
|
148 | - foreach ($this->datetimes as $datetime) { |
|
149 | - if ( ! $datetime instanceof \EE_Datetime) { |
|
150 | - continue; |
|
151 | - } |
|
152 | - $html .= "\n" . '<option value="' . $datetime->date_range('Y_m_d', '-') . '">'; |
|
153 | - $html .= $datetime->date_range($date_format); |
|
154 | - $html .= '</option>'; |
|
155 | - } |
|
156 | - $html .= "\n</select>"; |
|
157 | - $html .= \EEH_HTML::divx('', 'select-wrap-dv'); |
|
158 | - $html .= \EEH_HTML::br(); |
|
159 | - $html .= \EEH_HTML::divx('', 'datetime_selector-dv'); |
|
160 | - return $html; |
|
161 | - } |
|
19 | + /** |
|
20 | + * @var \EE_Event $event |
|
21 | + */ |
|
22 | + protected $event; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var \EE_Ticket[] $tickets |
|
26 | + */ |
|
27 | + protected $tickets; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var \EE_Datetime[] $datetimes |
|
31 | + */ |
|
32 | + protected $datetimes; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var \EE_Ticket_Selector_Config $template_settings |
|
36 | + */ |
|
37 | + protected $template_settings; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var boolean $active |
|
41 | + */ |
|
42 | + protected $active = false; |
|
43 | + |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * DatetimeSelector constructor. |
|
48 | + * |
|
49 | + * @param \EE_Event $event |
|
50 | + * @param \EE_Ticket[] $tickets |
|
51 | + * @param \EE_Ticket_Selector_Config $template_settings |
|
52 | + * @throws \EE_Error |
|
53 | + */ |
|
54 | + public function __construct(\EE_Event $event, array $tickets, \EE_Ticket_Selector_Config $template_settings) |
|
55 | + { |
|
56 | + $this->event = $event; |
|
57 | + $this->tickets = $tickets; |
|
58 | + $this->template_settings = $template_settings; |
|
59 | + $this->datetimes = $this->getAllDatetimesForAllTicket($tickets); |
|
60 | + $this->active = $this->template_settings->showDatetimeSelector($this->datetimes); |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * @param \EE_Ticket[] $tickets |
|
67 | + * @return array |
|
68 | + * @throws \EE_Error |
|
69 | + */ |
|
70 | + protected function getAllDatetimesForAllTicket($tickets = array()) |
|
71 | + { |
|
72 | + $datetimes = array(); |
|
73 | + foreach ($tickets as $ticket) { |
|
74 | + $datetimes = $this->getTicketDatetimes($ticket, $datetimes); |
|
75 | + } |
|
76 | + return $datetimes; |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * @param \EE_Ticket $ticket |
|
83 | + * @param \EE_Datetime[] $datetimes |
|
84 | + * @return \EE_Datetime[] |
|
85 | + * @throws \EE_Error |
|
86 | + */ |
|
87 | + protected function getTicketDatetimes(\EE_Ticket $ticket, $datetimes = array()) |
|
88 | + { |
|
89 | + $ticket_datetimes = $ticket->datetimes(); |
|
90 | + foreach ($ticket_datetimes as $ticket_datetime) { |
|
91 | + if ( ! $ticket_datetime instanceof \EE_Datetime) { |
|
92 | + continue; |
|
93 | + } |
|
94 | + $datetimes[ $ticket_datetime->ID() ] = $ticket_datetime; |
|
95 | + } |
|
96 | + return $datetimes; |
|
97 | + } |
|
98 | + |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * @param \EE_Ticket $ticket |
|
103 | + * @return string |
|
104 | + * @throws \EE_Error |
|
105 | + */ |
|
106 | + public function getTicketDatetimeClasses( \EE_Ticket $ticket ) { |
|
107 | + if ( ! $this->active) { |
|
108 | + return ''; |
|
109 | + } |
|
110 | + $ticket_datetimes = $this->getTicketDatetimes($ticket); |
|
111 | + $classes = ''; |
|
112 | + foreach ($this->datetimes as $datetime) { |
|
113 | + if ( ! $datetime instanceof \EE_Datetime || ! in_array($datetime, $ticket_datetimes)) { |
|
114 | + continue; |
|
115 | + } |
|
116 | + $classes .= ' ee-ticket-datetimes-' . $datetime->date_range('Y_m_d', '-'); |
|
117 | + } |
|
118 | + $classes .= ' ee-hidden-ticket-tr'; |
|
119 | + return $classes; |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * @param string $date_format |
|
126 | + * @return string |
|
127 | + * @throws \EE_Error |
|
128 | + */ |
|
129 | + public function getDatetimeSelector($date_format = 'Y-m-d') { |
|
130 | + if ( ! $this->active) { |
|
131 | + return ''; |
|
132 | + } |
|
133 | + $html = \EEH_HTML::div('', '', 'datetime_selector-dv'); |
|
134 | + $html .= \EEH_HTML::label( |
|
135 | + \EEH_HTML::span('', '', 'dashicons dashicons-calendar-alt') . esc_html__('Datetimes', 'event_espresso'), |
|
136 | + '', 'datetime_selector-lbl' |
|
137 | + ); |
|
138 | + $html .= \EEH_HTML::div( '', '', 'select-wrap-dv' ); |
|
139 | + $html .= "\n" . '<select name="datetime_selector-' . $this->event->ID() . '"'; |
|
140 | + $html .= ' id="datetime-selector-' . $this->event->ID() . '"'; |
|
141 | + $html .= ' class="ticket-selector-datetime-selector-slct"'; |
|
142 | + $html .= ' data-tkt_slctr_evt="' . $this->event->ID() . '">'; |
|
143 | + $html .= "\n" |
|
144 | + . '<option value="0">' |
|
145 | + . esc_html__('- please select a datetime -', 'event_espresso') |
|
146 | + . '</option>'; |
|
147 | + // offer ticket quantities from the min to the max |
|
148 | + foreach ($this->datetimes as $datetime) { |
|
149 | + if ( ! $datetime instanceof \EE_Datetime) { |
|
150 | + continue; |
|
151 | + } |
|
152 | + $html .= "\n" . '<option value="' . $datetime->date_range('Y_m_d', '-') . '">'; |
|
153 | + $html .= $datetime->date_range($date_format); |
|
154 | + $html .= '</option>'; |
|
155 | + } |
|
156 | + $html .= "\n</select>"; |
|
157 | + $html .= \EEH_HTML::divx('', 'select-wrap-dv'); |
|
158 | + $html .= \EEH_HTML::br(); |
|
159 | + $html .= \EEH_HTML::divx('', 'datetime_selector-dv'); |
|
160 | + return $html; |
|
161 | + } |
|
162 | 162 | |
163 | 163 | |
164 | 164 |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | if ( ! $ticket_datetime instanceof \EE_Datetime) { |
92 | 92 | continue; |
93 | 93 | } |
94 | - $datetimes[ $ticket_datetime->ID() ] = $ticket_datetime; |
|
94 | + $datetimes[$ticket_datetime->ID()] = $ticket_datetime; |
|
95 | 95 | } |
96 | 96 | return $datetimes; |
97 | 97 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @return string |
104 | 104 | * @throws \EE_Error |
105 | 105 | */ |
106 | - public function getTicketDatetimeClasses( \EE_Ticket $ticket ) { |
|
106 | + public function getTicketDatetimeClasses(\EE_Ticket $ticket) { |
|
107 | 107 | if ( ! $this->active) { |
108 | 108 | return ''; |
109 | 109 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | if ( ! $datetime instanceof \EE_Datetime || ! in_array($datetime, $ticket_datetimes)) { |
114 | 114 | continue; |
115 | 115 | } |
116 | - $classes .= ' ee-ticket-datetimes-' . $datetime->date_range('Y_m_d', '-'); |
|
116 | + $classes .= ' ee-ticket-datetimes-'.$datetime->date_range('Y_m_d', '-'); |
|
117 | 117 | } |
118 | 118 | $classes .= ' ee-hidden-ticket-tr'; |
119 | 119 | return $classes; |
@@ -132,14 +132,14 @@ discard block |
||
132 | 132 | } |
133 | 133 | $html = \EEH_HTML::div('', '', 'datetime_selector-dv'); |
134 | 134 | $html .= \EEH_HTML::label( |
135 | - \EEH_HTML::span('', '', 'dashicons dashicons-calendar-alt') . esc_html__('Datetimes', 'event_espresso'), |
|
135 | + \EEH_HTML::span('', '', 'dashicons dashicons-calendar-alt').esc_html__('Datetimes', 'event_espresso'), |
|
136 | 136 | '', 'datetime_selector-lbl' |
137 | 137 | ); |
138 | - $html .= \EEH_HTML::div( '', '', 'select-wrap-dv' ); |
|
139 | - $html .= "\n" . '<select name="datetime_selector-' . $this->event->ID() . '"'; |
|
140 | - $html .= ' id="datetime-selector-' . $this->event->ID() . '"'; |
|
138 | + $html .= \EEH_HTML::div('', '', 'select-wrap-dv'); |
|
139 | + $html .= "\n".'<select name="datetime_selector-'.$this->event->ID().'"'; |
|
140 | + $html .= ' id="datetime-selector-'.$this->event->ID().'"'; |
|
141 | 141 | $html .= ' class="ticket-selector-datetime-selector-slct"'; |
142 | - $html .= ' data-tkt_slctr_evt="' . $this->event->ID() . '">'; |
|
142 | + $html .= ' data-tkt_slctr_evt="'.$this->event->ID().'">'; |
|
143 | 143 | $html .= "\n" |
144 | 144 | . '<option value="0">' |
145 | 145 | . esc_html__('- please select a datetime -', 'event_espresso') |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | if ( ! $datetime instanceof \EE_Datetime) { |
150 | 150 | continue; |
151 | 151 | } |
152 | - $html .= "\n" . '<option value="' . $datetime->date_range('Y_m_d', '-') . '">'; |
|
152 | + $html .= "\n".'<option value="'.$datetime->date_range('Y_m_d', '-').'">'; |
|
153 | 153 | $html .= $datetime->date_range($date_format); |
154 | 154 | $html .= '</option>'; |
155 | 155 | } |