Completed
Branch FET/event-question-group-refac... (7e8a15)
by
unknown
27:06 queued 18:26
created
core/data_migration_scripts/EE_DMS_Core_4_9_0.dms.php 1 patch
Indentation   +304 added lines, -304 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
 $stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*');
16 16
 $class_to_filepath = array();
17 17
 foreach ($stages as $filepath) {
18
-    $matches = array();
19
-    preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20
-    $class_to_filepath[ $matches[1] ] = $filepath;
18
+	$matches = array();
19
+	preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20
+	$class_to_filepath[ $matches[1] ] = $filepath;
21 21
 }
22 22
 // give addons a chance to autoload their stages too
23 23
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath);
@@ -36,68 +36,68 @@  discard block
 block discarded – undo
36 36
 class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base
37 37
 {
38 38
 
39
-    /**
40
-     * return EE_DMS_Core_4_9_0
41
-     *
42
-     * @param TableManager  $table_manager
43
-     * @param TableAnalysis $table_analysis
44
-     */
45
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
46
-    {
47
-        $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso");
48
-        $this->_priority = 10;
49
-        $this->_migration_stages = array(
50
-            new EE_DMS_4_9_0_Email_System_Question(),
51
-            new EE_DMS_4_9_0_Answers_With_No_Registration(),
52
-        );
53
-        parent::__construct($table_manager, $table_analysis);
54
-    }
39
+	/**
40
+	 * return EE_DMS_Core_4_9_0
41
+	 *
42
+	 * @param TableManager  $table_manager
43
+	 * @param TableAnalysis $table_analysis
44
+	 */
45
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
46
+	{
47
+		$this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso");
48
+		$this->_priority = 10;
49
+		$this->_migration_stages = array(
50
+			new EE_DMS_4_9_0_Email_System_Question(),
51
+			new EE_DMS_4_9_0_Answers_With_No_Registration(),
52
+		);
53
+		parent::__construct($table_manager, $table_analysis);
54
+	}
55 55
 
56 56
 
57 57
 
58
-    /**
59
-     * Whether to migrate or not.
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 (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) {
68
-            //          echo "$version_string can be migrated from";
69
-            return true;
70
-        } elseif (! $version_string) {
71
-            //          echo "no version string provided: $version_string";
72
-            // no version string provided... this must be pre 4.3
73
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
74
-        } else {
75
-            //          echo "$version_string doesnt apply";
76
-            return false;
77
-        }
78
-    }
58
+	/**
59
+	 * Whether to migrate or not.
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 (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) {
68
+			//          echo "$version_string can be migrated from";
69
+			return true;
70
+		} elseif (! $version_string) {
71
+			//          echo "no version string provided: $version_string";
72
+			// no version string provided... this must be pre 4.3
73
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
74
+		} else {
75
+			//          echo "$version_string doesnt apply";
76
+			return false;
77
+		}
78
+	}
79 79
 
80 80
 
81 81
 
82
-    /**
83
-     * @return bool
84
-     */
85
-    public function schema_changes_before_migration()
86
-    {
87
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
88
-        $now_in_mysql = current_time('mysql', true);
89
-        $table_name = 'esp_answer';
90
-        $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
82
+	/**
83
+	 * @return bool
84
+	 */
85
+	public function schema_changes_before_migration()
86
+	{
87
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
88
+		$now_in_mysql = current_time('mysql', true);
89
+		$table_name = 'esp_answer';
90
+		$sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
91 91
 					REG_ID int(10) unsigned NOT NULL,
92 92
 					QST_ID int(10) unsigned NOT NULL,
93 93
 					ANS_value text NOT NULL,
94 94
 					PRIMARY KEY  (ANS_ID),
95 95
 					KEY REG_ID (REG_ID),
96 96
 					KEY QST_ID (QST_ID)";
97
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
98
-        $table_name = 'esp_attendee_meta';
99
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email');
100
-        $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
97
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
98
+		$table_name = 'esp_attendee_meta';
99
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email');
100
+		$sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
101 101
 				ATT_ID bigint(20) unsigned NOT NULL,
102 102
 				ATT_fname varchar(45) NOT NULL,
103 103
 				ATT_lname varchar(45) NOT NULL,
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
 				KEY ATT_email (ATT_email(191)),
115 115
 				KEY ATT_lname (ATT_lname),
116 116
 				KEY ATT_fname (ATT_fname)";
117
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
118
-        $table_name = 'esp_checkin';
119
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
117
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
118
+		$table_name = 'esp_checkin';
119
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
120 120
 				REG_ID int(10) unsigned NOT NULL,
121 121
 				DTT_ID int(10) unsigned NOT NULL,
122 122
 				CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
 				PRIMARY KEY  (CHK_ID),
125 125
 				KEY REG_ID (REG_ID),
126 126
 				KEY DTT_ID (DTT_ID)";
127
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
128
-        $table_name = 'esp_country';
129
-        $sql = "CNT_ISO varchar(2) NOT NULL,
127
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
128
+		$table_name = 'esp_country';
129
+		$sql = "CNT_ISO varchar(2) NOT NULL,
130 130
 				CNT_ISO3 varchar(3) NOT NULL,
131 131
 				RGN_ID tinyint(3) unsigned DEFAULT NULL,
132 132
 				CNT_name varchar(45) NOT NULL,
@@ -142,29 +142,29 @@  discard block
 block discarded – undo
142 142
 				CNT_is_EU tinyint(1) DEFAULT '0',
143 143
 				CNT_active tinyint(1) DEFAULT '0',
144 144
 				PRIMARY KEY  (CNT_ISO)";
145
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
146
-        $table_name = 'esp_currency';
147
-        $sql = "CUR_code varchar(6) NOT NULL,
145
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
146
+		$table_name = 'esp_currency';
147
+		$sql = "CUR_code varchar(6) NOT NULL,
148 148
 				CUR_single varchar(45) DEFAULT 'dollar',
149 149
 				CUR_plural varchar(45) DEFAULT 'dollars',
150 150
 				CUR_sign varchar(45) DEFAULT '$',
151 151
 				CUR_dec_plc varchar(1) NOT NULL DEFAULT '2',
152 152
 				CUR_active tinyint(1) DEFAULT '0',
153 153
 				PRIMARY KEY  (CUR_code)";
154
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
155
-        // note: although this table is no longer in use,
156
-        // it hasn't been removed because then queries to the model will have errors.
157
-        // but you should expect this table and its corresponding model to be removed in
158
-        // the next few months
159
-        $table_name = 'esp_currency_payment_method';
160
-        $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
154
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
155
+		// note: although this table is no longer in use,
156
+		// it hasn't been removed because then queries to the model will have errors.
157
+		// but you should expect this table and its corresponding model to be removed in
158
+		// the next few months
159
+		$table_name = 'esp_currency_payment_method';
160
+		$sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
161 161
 				CUR_code varchar(6) NOT NULL,
162 162
 				PMD_ID int(11) NOT NULL,
163 163
 				PRIMARY KEY  (CPM_ID),
164 164
 				KEY PMD_ID (PMD_ID)";
165
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
166
-        $table_name = 'esp_datetime';
167
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
165
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
166
+		$table_name = 'esp_datetime';
167
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
168 168
 				EVT_ID bigint(20) unsigned NOT NULL,
169 169
 				DTT_name varchar(255) NOT NULL DEFAULT '',
170 170
 				DTT_description text NOT NULL,
@@ -181,25 +181,25 @@  discard block
 block discarded – undo
181 181
 				KEY DTT_EVT_start (DTT_EVT_start),
182 182
 				KEY EVT_ID (EVT_ID),
183 183
 				KEY DTT_is_primary (DTT_is_primary)";
184
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
185
-        $table_name = "esp_datetime_ticket";
186
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
184
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
185
+		$table_name = "esp_datetime_ticket";
186
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
187 187
 				DTT_ID int(10) unsigned NOT NULL,
188 188
 				TKT_ID int(10) unsigned NOT NULL,
189 189
 				PRIMARY KEY  (DTK_ID),
190 190
 				KEY DTT_ID (DTT_ID),
191 191
 				KEY TKT_ID (TKT_ID)";
192
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
193
-        $table_name = 'esp_event_message_template';
194
-        $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
192
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
193
+		$table_name = 'esp_event_message_template';
194
+		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
195 195
 				EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0,
196 196
 				GRP_ID int(10) unsigned NOT NULL DEFAULT 0,
197 197
 				PRIMARY KEY  (EMT_ID),
198 198
 				KEY EVT_ID (EVT_ID),
199 199
 				KEY GRP_ID (GRP_ID)";
200
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
201
-        $table_name = 'esp_event_meta';
202
-        $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
200
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
201
+		$table_name = 'esp_event_meta';
202
+		$sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
203 203
 				EVT_ID bigint(20) unsigned NOT NULL,
204 204
 				EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
205 205
 				EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -214,34 +214,34 @@  discard block
 block discarded – undo
214 214
 				EVT_donations tinyint(1) NULL,
215 215
 				PRIMARY KEY  (EVTM_ID),
216 216
 				KEY EVT_ID (EVT_ID)";
217
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
218
-        $table_name = 'esp_event_question_group';
219
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
217
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
218
+		$table_name = 'esp_event_question_group';
219
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
220 220
 				EVT_ID bigint(20) unsigned NOT NULL,
221 221
 				QSG_ID int(10) unsigned NOT NULL,
222 222
 				EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
223 223
 				PRIMARY KEY  (EQG_ID),
224 224
 				KEY EVT_ID (EVT_ID),
225 225
 				KEY QSG_ID (QSG_ID)";
226
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
227
-        $table_name = 'esp_event_venue';
228
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
226
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
227
+		$table_name = 'esp_event_venue';
228
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
229 229
 				EVT_ID bigint(20) unsigned NOT NULL,
230 230
 				VNU_ID bigint(20) unsigned NOT NULL,
231 231
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
232 232
 				PRIMARY KEY  (EVV_ID)";
233
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
234
-        $table_name = 'esp_extra_meta';
235
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
233
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
234
+		$table_name = 'esp_extra_meta';
235
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
236 236
 				OBJ_ID int(11) DEFAULT NULL,
237 237
 				EXM_type varchar(45) DEFAULT NULL,
238 238
 				EXM_key varchar(45) DEFAULT NULL,
239 239
 				EXM_value text,
240 240
 				PRIMARY KEY  (EXM_ID),
241 241
 				KEY EXM_type (EXM_type,OBJ_ID,EXM_key)";
242
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
243
-        $table_name = 'esp_extra_join';
244
-        $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
242
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
243
+		$table_name = 'esp_extra_join';
244
+		$sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
245 245
 				EXJ_first_model_id varchar(6) NOT NULL,
246 246
 				EXJ_first_model_name varchar(20) NOT NULL,
247 247
 				EXJ_second_model_id varchar(6) NOT NULL,
@@ -249,9 +249,9 @@  discard block
 block discarded – undo
249 249
 				PRIMARY KEY  (EXJ_ID),
250 250
 				KEY first_model (EXJ_first_model_name,EXJ_first_model_id),
251 251
 				KEY second_model (EXJ_second_model_name,EXJ_second_model_id)";
252
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
253
-        $table_name = 'esp_line_item';
254
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
252
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
253
+		$table_name = 'esp_line_item';
254
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
255 255
 				LIN_code varchar(245) NOT NULL DEFAULT '',
256 256
 				TXN_ID int(11) DEFAULT NULL,
257 257
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
 				KEY txn_type_timestamp (TXN_ID,LIN_type,LIN_timestamp),
273 273
 				KEY txn_obj_id_obj_type (TXN_ID,OBJ_ID,OBJ_type),
274 274
 				KEY obj_id_obj_type (OBJ_ID,OBJ_type)";
275
-        $this->_get_table_manager()->dropIndex('esp_line_item', 'TXN_ID');
276
-        $this->_get_table_manager()->dropIndex('esp_line_item', 'LIN_code');
277
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
278
-        $table_name = 'esp_log';
279
-        $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
275
+		$this->_get_table_manager()->dropIndex('esp_line_item', 'TXN_ID');
276
+		$this->_get_table_manager()->dropIndex('esp_line_item', 'LIN_code');
277
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
278
+		$table_name = 'esp_log';
279
+		$sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
280 280
 				LOG_time datetime DEFAULT NULL,
281 281
 				OBJ_ID varchar(45) DEFAULT NULL,
282 282
 				OBJ_type varchar(45) DEFAULT NULL,
@@ -287,12 +287,12 @@  discard block
 block discarded – undo
287 287
 				KEY LOG_time (LOG_time),
288 288
 				KEY OBJ (OBJ_type,OBJ_ID),
289 289
 				KEY LOG_type (LOG_type)";
290
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
291
-        $table_name = 'esp_message';
292
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to');
293
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from');
294
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject');
295
-        $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
290
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
291
+		$table_name = 'esp_message';
292
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to');
293
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from');
294
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject');
295
+		$sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
296 296
 				GRP_ID int(10) unsigned NULL,
297 297
 				MSG_token varchar(255) NULL,
298 298
 				TXN_ID int(10) unsigned NULL,
@@ -324,18 +324,18 @@  discard block
 block discarded – undo
324 324
 				KEY STS_ID (STS_ID),
325 325
 				KEY MSG_created (MSG_created),
326 326
 				KEY MSG_modified (MSG_modified)";
327
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
328
-        $table_name = 'esp_message_template';
329
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
327
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
328
+		$table_name = 'esp_message_template';
329
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
330 330
 				GRP_ID int(10) unsigned NOT NULL,
331 331
 				MTP_context varchar(50) NOT NULL,
332 332
 				MTP_template_field varchar(30) NOT NULL,
333 333
 				MTP_content text NOT NULL,
334 334
 				PRIMARY KEY  (MTP_ID),
335 335
 				KEY GRP_ID (GRP_ID)";
336
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
337
-        $table_name = 'esp_message_template_group';
338
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
336
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
337
+		$table_name = 'esp_message_template_group';
338
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
339 339
 				MTP_user_id int(10) NOT NULL DEFAULT '1',
340 340
 				MTP_name varchar(245) NOT NULL DEFAULT '',
341 341
 				MTP_description varchar(245) NOT NULL DEFAULT '',
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
 				MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
348 348
 				PRIMARY KEY  (GRP_ID),
349 349
 				KEY MTP_user_id (MTP_user_id)";
350
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
351
-        $table_name = 'esp_payment';
352
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
350
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
351
+		$table_name = 'esp_payment';
352
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
353 353
 				TXN_ID int(10) unsigned DEFAULT NULL,
354 354
 				STS_ID varchar(3) DEFAULT NULL,
355 355
 				PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -366,9 +366,9 @@  discard block
 block discarded – undo
366 366
 				PRIMARY KEY  (PAY_ID),
367 367
 				KEY PAY_timestamp (PAY_timestamp),
368 368
 				KEY TXN_ID (TXN_ID)";
369
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
370
-        $table_name = 'esp_payment_method';
371
-        $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
369
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
370
+		$table_name = 'esp_payment_method';
371
+		$sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
372 372
 				PMD_type varchar(124) DEFAULT NULL,
373 373
 				PMD_name varchar(255) DEFAULT NULL,
374 374
 				PMD_desc text,
@@ -384,24 +384,24 @@  discard block
 block discarded – undo
384 384
 				PRIMARY KEY  (PMD_ID),
385 385
 				UNIQUE KEY PMD_slug_UNIQUE (PMD_slug),
386 386
 				KEY PMD_type (PMD_type)";
387
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
388
-        $table_name = "esp_ticket_price";
389
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
387
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
388
+		$table_name = "esp_ticket_price";
389
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
390 390
 				TKT_ID int(10) unsigned NOT NULL,
391 391
 				PRC_ID int(10) unsigned NOT NULL,
392 392
 				PRIMARY KEY  (TKP_ID),
393 393
 				KEY TKT_ID (TKT_ID),
394 394
 				KEY PRC_ID (PRC_ID)";
395
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
396
-        $table_name = "esp_ticket_template";
397
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
395
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
396
+		$table_name = "esp_ticket_template";
397
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
398 398
 				TTM_name varchar(45) NOT NULL,
399 399
 				TTM_description text,
400 400
 				TTM_file varchar(45),
401 401
 				PRIMARY KEY  (TTM_ID)";
402
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
403
-        $table_name = 'esp_question';
404
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
402
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
403
+		$table_name = 'esp_question';
404
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
405 405
 				QST_display_text text NOT NULL,
406 406
 				QST_admin_label varchar(255) NOT NULL,
407 407
 				QST_system varchar(25) DEFAULT NULL,
@@ -415,18 +415,18 @@  discard block
 block discarded – undo
415 415
 				QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0,
416 416
 				PRIMARY KEY  (QST_ID),
417 417
 				KEY QST_order (QST_order)';
418
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
419
-        $table_name = 'esp_question_group_question';
420
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
418
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
419
+		$table_name = 'esp_question_group_question';
420
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
421 421
 				QSG_ID int(10) unsigned NOT NULL,
422 422
 				QST_ID int(10) unsigned NOT NULL,
423 423
 				QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
424 424
 				PRIMARY KEY  (QGQ_ID),
425 425
 				KEY QST_ID (QST_ID),
426 426
 				KEY QSG_ID_order (QSG_ID,QGQ_order)";
427
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
428
-        $table_name = 'esp_question_option';
429
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
427
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
428
+		$table_name = 'esp_question_option';
429
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
430 430
 				QSO_value varchar(255) NOT NULL,
431 431
 				QSO_desc text NOT NULL,
432 432
 				QST_ID int(10) unsigned NOT NULL,
@@ -436,9 +436,9 @@  discard block
 block discarded – undo
436 436
 				PRIMARY KEY  (QSO_ID),
437 437
 				KEY QST_ID (QST_ID),
438 438
 				KEY QSO_order (QSO_order)";
439
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
440
-        $table_name = 'esp_registration';
441
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
439
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
440
+		$table_name = 'esp_registration';
441
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
442 442
 				EVT_ID bigint(20) unsigned NOT NULL,
443 443
 				ATT_ID bigint(20) unsigned NOT NULL,
444 444
 				TXN_ID int(10) unsigned NOT NULL,
@@ -462,18 +462,18 @@  discard block
 block discarded – undo
462 462
 				KEY TKT_ID (TKT_ID),
463 463
 				KEY EVT_ID (EVT_ID),
464 464
 				KEY STS_ID (STS_ID)";
465
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
466
-        $table_name = 'esp_registration_payment';
467
-        $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
465
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
466
+		$table_name = 'esp_registration_payment';
467
+		$sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
468 468
 					  REG_ID int(10) unsigned NOT NULL,
469 469
 					  PAY_ID int(10) unsigned NULL,
470 470
 					  RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00',
471 471
 					  PRIMARY KEY  (RPY_ID),
472 472
 					  KEY REG_ID (REG_ID),
473 473
 					  KEY PAY_ID (PAY_ID)";
474
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
475
-        $table_name = 'esp_state';
476
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
474
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
475
+		$table_name = 'esp_state';
476
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
477 477
 				CNT_ISO varchar(2) NOT NULL,
478 478
 				STA_abbrev varchar(24) NOT NULL,
479 479
 				STA_name varchar(100) NOT NULL,
@@ -481,9 +481,9 @@  discard block
 block discarded – undo
481 481
 				PRIMARY KEY  (STA_ID),
482 482
 				KEY STA_abbrev (STA_abbrev),
483 483
 				KEY CNT_ISO (CNT_ISO)";
484
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
485
-        $table_name = 'esp_status';
486
-        $sql = "STS_ID varchar(3) NOT NULL,
484
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
485
+		$table_name = 'esp_status';
486
+		$sql = "STS_ID varchar(3) NOT NULL,
487 487
 				STS_code varchar(45) NOT NULL,
488 488
 				STS_type varchar(45) NOT NULL,
489 489
 				STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -491,9 +491,9 @@  discard block
 block discarded – undo
491 491
 				STS_open tinyint(1) NOT NULL DEFAULT 1,
492 492
 				UNIQUE KEY STS_ID_UNIQUE (STS_ID),
493 493
 				KEY STS_type (STS_type)";
494
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
495
-        $table_name = 'esp_transaction';
496
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
494
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
495
+		$table_name = 'esp_transaction';
496
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
497 497
 				TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
498 498
 				TXN_total decimal(12,3) DEFAULT '0.00',
499 499
 				TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00',
@@ -505,9 +505,9 @@  discard block
 block discarded – undo
505 505
 				PRIMARY KEY  (TXN_ID),
506 506
 				KEY TXN_timestamp (TXN_timestamp),
507 507
 				KEY STS_ID (STS_ID)";
508
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
509
-        $table_name = 'esp_venue_meta';
510
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
508
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
509
+		$table_name = 'esp_venue_meta';
510
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
511 511
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
512 512
 			VNU_address varchar(255) DEFAULT NULL,
513 513
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -526,10 +526,10 @@  discard block
 block discarded – undo
526 526
 			KEY VNU_ID (VNU_ID),
527 527
 			KEY STA_ID (STA_ID),
528 528
 			KEY CNT_ISO (CNT_ISO)";
529
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
530
-        // modified tables
531
-        $table_name = "esp_price";
532
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
529
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
530
+		// modified tables
531
+		$table_name = "esp_price";
532
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
533 533
 				PRT_ID tinyint(3) unsigned NOT NULL,
534 534
 				PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00',
535 535
 				PRC_name varchar(245) NOT NULL,
@@ -542,9 +542,9 @@  discard block
 block discarded – undo
542 542
 				PRC_parent int(10) unsigned DEFAULT 0,
543 543
 				PRIMARY KEY  (PRC_ID),
544 544
 				KEY PRT_ID (PRT_ID)";
545
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
546
-        $table_name = "esp_price_type";
547
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
545
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
546
+		$table_name = "esp_price_type";
547
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
548 548
 				PRT_name varchar(45) NOT NULL,
549 549
 				PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
550 550
 				PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -553,9 +553,9 @@  discard block
 block discarded – undo
553 553
 				PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
554 554
 				UNIQUE KEY PRT_name_UNIQUE (PRT_name),
555 555
 				PRIMARY KEY  (PRT_ID)";
556
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
557
-        $table_name = "esp_ticket";
558
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
556
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
557
+		$table_name = "esp_ticket";
558
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
559 559
 				TTM_ID int(10) unsigned NOT NULL,
560 560
 				TKT_name varchar(245) NOT NULL DEFAULT '',
561 561
 				TKT_description text NOT NULL,
@@ -578,9 +578,9 @@  discard block
 block discarded – undo
578 578
 				TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
579 579
 				PRIMARY KEY  (TKT_ID),
580 580
 				KEY TKT_start_date (TKT_start_date)";
581
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
582
-        $table_name = 'esp_question_group';
583
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
581
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
582
+		$table_name = 'esp_question_group';
583
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
584 584
 				QSG_name varchar(255) NOT NULL,
585 585
 				QSG_identifier varchar(100) NOT NULL,
586 586
 				QSG_desc text NULL,
@@ -593,159 +593,159 @@  discard block
 block discarded – undo
593 593
 				PRIMARY KEY  (QSG_ID),
594 594
 				UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier),
595 595
 				KEY QSG_order (QSG_order)';
596
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
597
-        $this->insert_default_data();
598
-        return true;
599
-    }
596
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
597
+		$this->insert_default_data();
598
+		return true;
599
+	}
600 600
 
601
-    /**
602
-     * Inserts default data after parent was called.
603
-     * @since $VID:$
604
-     * @throws EE_Error
605
-     * @throws InvalidArgumentException
606
-     * @throws ReflectionException
607
-     * @throws InvalidDataTypeException
608
-     * @throws InvalidInterfaceException
609
-     */
610
-    public function insert_default_data()
611
-    {
612
-        /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
613
-        $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
614
-        // (because many need to convert old string states to foreign keys into the states table)
615
-        $script_4_1_defaults->insert_default_states();
616
-        $script_4_1_defaults->insert_default_countries();
617
-        /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
618
-        $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
619
-        $script_4_5_defaults->insert_default_price_types();
620
-        $script_4_5_defaults->insert_default_prices();
621
-        $script_4_5_defaults->insert_default_tickets();
622
-        /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
623
-        $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
624
-        $script_4_6_defaults->add_default_admin_only_payments();
625
-        $script_4_6_defaults->insert_default_currencies();
626
-        /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */
627
-        $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0');
628
-        $script_4_8_defaults->verify_new_countries();
629
-        $script_4_8_defaults->verify_new_currencies();
630
-        $this->verify_db_collations();
631
-        $this->verify_db_collations_again();
632
-    }
601
+	/**
602
+	 * Inserts default data after parent was called.
603
+	 * @since $VID:$
604
+	 * @throws EE_Error
605
+	 * @throws InvalidArgumentException
606
+	 * @throws ReflectionException
607
+	 * @throws InvalidDataTypeException
608
+	 * @throws InvalidInterfaceException
609
+	 */
610
+	public function insert_default_data()
611
+	{
612
+		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
613
+		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
614
+		// (because many need to convert old string states to foreign keys into the states table)
615
+		$script_4_1_defaults->insert_default_states();
616
+		$script_4_1_defaults->insert_default_countries();
617
+		/** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
618
+		$script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
619
+		$script_4_5_defaults->insert_default_price_types();
620
+		$script_4_5_defaults->insert_default_prices();
621
+		$script_4_5_defaults->insert_default_tickets();
622
+		/** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
623
+		$script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
624
+		$script_4_6_defaults->add_default_admin_only_payments();
625
+		$script_4_6_defaults->insert_default_currencies();
626
+		/** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */
627
+		$script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0');
628
+		$script_4_8_defaults->verify_new_countries();
629
+		$script_4_8_defaults->verify_new_currencies();
630
+		$this->verify_db_collations();
631
+		$this->verify_db_collations_again();
632
+	}
633 633
 
634 634
 
635 635
 
636
-    /**
637
-     * @return boolean
638
-     */
639
-    public function schema_changes_after_migration()
640
-    {
641
-        return true;
642
-    }
636
+	/**
637
+	 * @return boolean
638
+	 */
639
+	public function schema_changes_after_migration()
640
+	{
641
+		return true;
642
+	}
643 643
 
644 644
 
645 645
 
646
-    public function migration_page_hooks()
647
-    {
648
-    }
646
+	public function migration_page_hooks()
647
+	{
648
+	}
649 649
 
650 650
 
651 651
 
652
-    /**
653
-     * Verify all EE4 models' tables use utf8mb4 collation
654
-     *
655
-     * @return void
656
-     */
657
-    public function verify_db_collations()
658
-    {
659
-        global $wpdb;
660
-        // double-check we haven't already done it or that that the DB doesn't support utf8mb4
661
-        if ('utf8mb4' !== $wpdb->charset
662
-            || get_option('ee_verified_db_collations', false)) {
663
-            return;
664
-        }
665
-        // grab tables from each model
666
-        $tables_to_check = array();
667
-        foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
668
-            if (method_exists($model_name, 'instance')) {
669
-                $model_obj = call_user_func(array($model_name, 'instance'));
670
-                if ($model_obj instanceof EEM_Base) {
671
-                    foreach ($model_obj->get_tables() as $table) {
672
-                        if (strpos($table->get_table_name(), 'esp_')
673
-                            && (is_main_site()// for main tables, verify global tables
674
-                                || ! $table->is_global()// if not the main site, then only verify non-global tables (avoid doubling up)
675
-                            )
676
-                            && function_exists('maybe_convert_table_to_utf8mb4')
677
-                        ) {
678
-                            $tables_to_check[] = $table->get_table_name();
679
-                        }
680
-                    }
681
-                }
682
-            }
683
-        }
684
-        // and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active
685
-        // when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead
686
-        // of hard-coding this
687
-        $addon_tables = array(
688
-            // mailchimp
689
-            'esp_event_mailchimp_list_group',
690
-            'esp_event_question_mailchimp_field',
691
-            // multisite
692
-            'esp_blog_meta',
693
-            // people
694
-            'esp_people_to_post',
695
-            // promotions
696
-            'esp_promotion',
697
-            'esp_promotion_object',
698
-        );
699
-        foreach ($addon_tables as $table_name) {
700
-                $tables_to_check[] = $table_name;
701
-        }
702
-        $this->_verify_db_collations_for_tables(array_unique($tables_to_check));
703
-        // ok and now let's remember this was done (without needing to check the db schemas all over again)
704
-        add_option('ee_verified_db_collations', true, null, 'no');
705
-        // seeing how this ran with the fix from 10435, no need to check again
706
-        add_option('ee_verified_db_collations_again', true, null, 'no');
707
-    }
652
+	/**
653
+	 * Verify all EE4 models' tables use utf8mb4 collation
654
+	 *
655
+	 * @return void
656
+	 */
657
+	public function verify_db_collations()
658
+	{
659
+		global $wpdb;
660
+		// double-check we haven't already done it or that that the DB doesn't support utf8mb4
661
+		if ('utf8mb4' !== $wpdb->charset
662
+			|| get_option('ee_verified_db_collations', false)) {
663
+			return;
664
+		}
665
+		// grab tables from each model
666
+		$tables_to_check = array();
667
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
668
+			if (method_exists($model_name, 'instance')) {
669
+				$model_obj = call_user_func(array($model_name, 'instance'));
670
+				if ($model_obj instanceof EEM_Base) {
671
+					foreach ($model_obj->get_tables() as $table) {
672
+						if (strpos($table->get_table_name(), 'esp_')
673
+							&& (is_main_site()// for main tables, verify global tables
674
+								|| ! $table->is_global()// if not the main site, then only verify non-global tables (avoid doubling up)
675
+							)
676
+							&& function_exists('maybe_convert_table_to_utf8mb4')
677
+						) {
678
+							$tables_to_check[] = $table->get_table_name();
679
+						}
680
+					}
681
+				}
682
+			}
683
+		}
684
+		// and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active
685
+		// when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead
686
+		// of hard-coding this
687
+		$addon_tables = array(
688
+			// mailchimp
689
+			'esp_event_mailchimp_list_group',
690
+			'esp_event_question_mailchimp_field',
691
+			// multisite
692
+			'esp_blog_meta',
693
+			// people
694
+			'esp_people_to_post',
695
+			// promotions
696
+			'esp_promotion',
697
+			'esp_promotion_object',
698
+		);
699
+		foreach ($addon_tables as $table_name) {
700
+				$tables_to_check[] = $table_name;
701
+		}
702
+		$this->_verify_db_collations_for_tables(array_unique($tables_to_check));
703
+		// ok and now let's remember this was done (without needing to check the db schemas all over again)
704
+		add_option('ee_verified_db_collations', true, null, 'no');
705
+		// seeing how this ran with the fix from 10435, no need to check again
706
+		add_option('ee_verified_db_collations_again', true, null, 'no');
707
+	}
708 708
 
709 709
 
710 710
 
711
-    /**
712
-     * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435
713
-     * which meant some DB collations might not have been updated
714
-     * @return void
715
-     */
716
-    public function verify_db_collations_again()
717
-    {
718
-        global $wpdb;
719
-        // double-check we haven't already done this or that the DB doesn't support it
720
-        // compare to how WordPress' upgrade_430() function does this check
721
-        if ('utf8mb4' !== $wpdb->charset
722
-            || get_option('ee_verified_db_collations_again', false)) {
723
-            return;
724
-        }
725
-        $tables_to_check = array(
726
-            'esp_attendee_meta',
727
-            'esp_message'
728
-        );
729
-        $this->_verify_db_collations_for_tables(array_unique($tables_to_check));
730
-        add_option('ee_verified_db_collations_again', true, null, 'no');
731
-    }
711
+	/**
712
+	 * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435
713
+	 * which meant some DB collations might not have been updated
714
+	 * @return void
715
+	 */
716
+	public function verify_db_collations_again()
717
+	{
718
+		global $wpdb;
719
+		// double-check we haven't already done this or that the DB doesn't support it
720
+		// compare to how WordPress' upgrade_430() function does this check
721
+		if ('utf8mb4' !== $wpdb->charset
722
+			|| get_option('ee_verified_db_collations_again', false)) {
723
+			return;
724
+		}
725
+		$tables_to_check = array(
726
+			'esp_attendee_meta',
727
+			'esp_message'
728
+		);
729
+		$this->_verify_db_collations_for_tables(array_unique($tables_to_check));
730
+		add_option('ee_verified_db_collations_again', true, null, 'no');
731
+	}
732 732
 
733 733
 
734 734
 
735
-    /**
736
-     * Runs maybe_convert_table_to_utf8mb4 on the specified tables
737
-     * @param $tables_to_check
738
-     * @return boolean true if logic ran, false if it didn't
739
-     */
740
-    protected function _verify_db_collations_for_tables($tables_to_check)
741
-    {
742
-        foreach ($tables_to_check as $table_name) {
743
-            $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name);
744
-            if (! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name)
745
-                && $this->_get_table_analysis()->tableExists($table_name)
746
-            ) {
747
-                maybe_convert_table_to_utf8mb4($table_name);
748
-            }
749
-        }
750
-    }
735
+	/**
736
+	 * Runs maybe_convert_table_to_utf8mb4 on the specified tables
737
+	 * @param $tables_to_check
738
+	 * @return boolean true if logic ran, false if it didn't
739
+	 */
740
+	protected function _verify_db_collations_for_tables($tables_to_check)
741
+	{
742
+		foreach ($tables_to_check as $table_name) {
743
+			$table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name);
744
+			if (! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name)
745
+				&& $this->_get_table_analysis()->tableExists($table_name)
746
+			) {
747
+				maybe_convert_table_to_utf8mb4($table_name);
748
+			}
749
+		}
750
+	}
751 751
 }
Please login to merge, or discard this patch.
4_1_0_stages/EE_DMS_4_1_0_event_question_group.dmsstage.php 2 patches
Indentation   +104 added lines, -106 removed lines patch added patch discarded remove patch
@@ -16,15 +16,13 @@  discard block
 block discarded – undo
16 16
             'EQG_primary'=>new EE_Boolean_Field('EQG_primary', __('Flag indicating question is only for primary attendees','event_espresso'), false, false)
17 17
         )
18 18
     );
19
-
20
-
21 19
  *
22 20
  */
23 21
 class EE_DMS_4_1_0_event_question_group extends EE_Data_Migration_Script_Stage_Table
24 22
 {
25
-    private $_new_table;
26
-    public function _migrate_old_row($old_row)
27
-    {
23
+	private $_new_table;
24
+	public function _migrate_old_row($old_row)
25
+	{
28 26
 //      $txn_id = $this->get_migration_script()->get_mapping_new_pk($this->_old_table, $old_row['id'], $this->_new_transaction_table);
29 27
 //          if ( ! $txn_id ){
30 28
 //              $this->add_error(sprintf(__("Could not find the transaction for the 3.1 attendee %d from row %s", "event_espresso"),$old_row['id'],$this->_json_encode($old_row)));
@@ -34,8 +32,8 @@  discard block
 block discarded – undo
34 32
 //          $new_line_items = $this->_insert_new_line_items($txn,$old_row);
35 33
 //          $this->get_migration_script()->set_mapping($this->_old_table,$old_row['id'],$this->_new_line_table,$new_line_items);
36 34
 
37
-            $this->_insert_new_event_question_groups($old_row);
38
-    }
35
+			$this->_insert_new_event_question_groups($old_row);
36
+	}
39 37
 //  function _migration_step($num_items=50){
40 38
 //      global $wpdb;
41 39
 //      $start_at_record = $this->count_records_migrated();
@@ -55,109 +53,109 @@  discard block
 block discarded – undo
55 53
 //      $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table);
56 54
 //      return $count;
57 55
 //  }
58
-    public function __construct()
59
-    {
60
-        global $wpdb;
61
-        $this->_old_table = $wpdb->prefix."events_detail";
62
-        $this->_extra_where_sql = 'WHERE event_status!="D"';
63
-        $this->_new_table = $wpdb->prefix."esp_event_question_group";
64
-        $this->_pretty_name = __("Question Groups in each Event", "event_espresso");
65
-        parent::__construct();
66
-    }
56
+	public function __construct()
57
+	{
58
+		global $wpdb;
59
+		$this->_old_table = $wpdb->prefix."events_detail";
60
+		$this->_extra_where_sql = 'WHERE event_status!="D"';
61
+		$this->_new_table = $wpdb->prefix."esp_event_question_group";
62
+		$this->_pretty_name = __("Question Groups in each Event", "event_espresso");
63
+		parent::__construct();
64
+	}
67 65
 
68
-    /**
69
-     * Attempts to insert a new question group inthe new format given an old one
70
-     * @global type $wpdb
71
-     * @param array $old_event
72
-     * @return void
73
-     */
74
-    private function _insert_new_event_question_groups($old_event)
75
-    {
76
-        $new_event_question_group_ids = array();
77
-        $question_groups_for_primary = maybe_unserialize($old_event['question_groups']);
78
-        if (is_array($question_groups_for_primary)) {
79
-            foreach ($question_groups_for_primary as $old_question_group_id) {
80
-                $new_id = $this->_insert_event_question_group($old_event, $old_question_group_id, true);
81
-                if ($new_id) {
82
-                    $new_event_question_group_ids[] = $new_id;
83
-                }
84
-            }
85
-        }
86
-        $event_meta = maybe_unserialize($old_event['event_meta']);
87
-        if (isset($event_meta['add_attendee_question_groups'])) {
88
-            if (is_array($event_meta['add_attendee_question_groups'])) {
89
-                foreach ($event_meta['add_attendee_question_groups'] as $old_question_group_id) {
90
-                    $new_id = $this->_insert_event_question_group($old_event, $old_question_group_id, false);
91
-                    if ($new_id) {
92
-                        $new_event_question_group_ids[] = $new_id;
93
-                    }
94
-                }
95
-            }
96
-        }
66
+	/**
67
+	 * Attempts to insert a new question group inthe new format given an old one
68
+	 * @global type $wpdb
69
+	 * @param array $old_event
70
+	 * @return void
71
+	 */
72
+	private function _insert_new_event_question_groups($old_event)
73
+	{
74
+		$new_event_question_group_ids = array();
75
+		$question_groups_for_primary = maybe_unserialize($old_event['question_groups']);
76
+		if (is_array($question_groups_for_primary)) {
77
+			foreach ($question_groups_for_primary as $old_question_group_id) {
78
+				$new_id = $this->_insert_event_question_group($old_event, $old_question_group_id, true);
79
+				if ($new_id) {
80
+					$new_event_question_group_ids[] = $new_id;
81
+				}
82
+			}
83
+		}
84
+		$event_meta = maybe_unserialize($old_event['event_meta']);
85
+		if (isset($event_meta['add_attendee_question_groups'])) {
86
+			if (is_array($event_meta['add_attendee_question_groups'])) {
87
+				foreach ($event_meta['add_attendee_question_groups'] as $old_question_group_id) {
88
+					$new_id = $this->_insert_event_question_group($old_event, $old_question_group_id, false);
89
+					if ($new_id) {
90
+						$new_event_question_group_ids[] = $new_id;
91
+					}
92
+				}
93
+			}
94
+		}
97 95
 
98 96
 
99
-        $this->get_migration_script()->set_mapping($this->_old_table, $old_event['id'], $this->_new_table, $new_event_question_group_ids);
100
-    }
97
+		$this->get_migration_script()->set_mapping($this->_old_table, $old_event['id'], $this->_new_table, $new_event_question_group_ids);
98
+	}
101 99
 
102
-    private function _insert_event_question_group($old_event, $old_question_group_id, $primary)
103
-    {
104
-        global $wpdb;
105
-        $new_question_group_id = $this->get_migration_script()->get_mapping_new_pk(
106
-            $wpdb->prefix . "events_qst_group",
107
-            intval($old_question_group_id),
108
-            $wpdb->prefix . "esp_question_group"
109
-        );
100
+	private function _insert_event_question_group($old_event, $old_question_group_id, $primary)
101
+	{
102
+		global $wpdb;
103
+		$new_question_group_id = $this->get_migration_script()->get_mapping_new_pk(
104
+			$wpdb->prefix . "events_qst_group",
105
+			intval($old_question_group_id),
106
+			$wpdb->prefix . "esp_question_group"
107
+		);
110 108
 
111
-        if (! $new_question_group_id) {
112
-            $this->add_error(
113
-                sprintf(
114
-                    // translators: %s question ID, %s event ID
115
-                    __("Could not find 4.1 question ID for 3.1 question id #%s on event $%s", "event_espresso"),
116
-                    $old_question_group_id,
117
-                    $old_event['id']
118
-                )
119
-            );
120
-            return 0;
121
-        }
122
-        $new_event_id = $this->get_migration_script()->get_mapping_new_pk(
123
-            $wpdb->prefix . "events_detail",
124
-            intval($old_event['id']),
125
-            $wpdb->posts
126
-        );
127
-        if (! $new_question_group_id) {
128
-            $this->add_error(
129
-                sprintf(
130
-                    // translators: %s event ID
131
-                    __("Could not find 4.1 event 3.1 event id #%s", "event_espresso"),
132
-                    $old_event['id']
133
-                )
134
-            );
135
-            return 0;
136
-        }
137
-        $cols_n_values = array(
138
-            'EVT_ID'=>$new_event_id,
139
-            'QSG_ID'=>$new_question_group_id,
140
-            EEM_Event_Question_Group::instance()->field_name_for_category($primary) => true
141
-        );
109
+		if (! $new_question_group_id) {
110
+			$this->add_error(
111
+				sprintf(
112
+					// translators: %s question ID, %s event ID
113
+					__("Could not find 4.1 question ID for 3.1 question id #%s on event $%s", "event_espresso"),
114
+					$old_question_group_id,
115
+					$old_event['id']
116
+				)
117
+			);
118
+			return 0;
119
+		}
120
+		$new_event_id = $this->get_migration_script()->get_mapping_new_pk(
121
+			$wpdb->prefix . "events_detail",
122
+			intval($old_event['id']),
123
+			$wpdb->posts
124
+		);
125
+		if (! $new_question_group_id) {
126
+			$this->add_error(
127
+				sprintf(
128
+					// translators: %s event ID
129
+					__("Could not find 4.1 event 3.1 event id #%s", "event_espresso"),
130
+					$old_event['id']
131
+				)
132
+			);
133
+			return 0;
134
+		}
135
+		$cols_n_values = array(
136
+			'EVT_ID'=>$new_event_id,
137
+			'QSG_ID'=>$new_question_group_id,
138
+			EEM_Event_Question_Group::instance()->field_name_for_category($primary) => true
139
+		);
142 140
 
143
-        $datatypes = array(
144
-            '%d',// EVT_ID
145
-            '%d',// QSG_ID
146
-            '%d',// EQG_primary or EQG_additional
147
-        );
148
-        $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes);
149
-        if (! $success) {
150
-            $this->add_error(
151
-                $this->get_migration_script()->_create_error_message_for_db_insertion(
152
-                    $this->_old_table,
153
-                    $old_event,
154
-                    $this->_new_table,
155
-                    $cols_n_values,
156
-                    $datatypes
157
-                )
158
-            );
159
-            return 0;
160
-        }
161
-        return $wpdb->insert_id;
162
-    }
141
+		$datatypes = array(
142
+			'%d',// EVT_ID
143
+			'%d',// QSG_ID
144
+			'%d',// EQG_primary or EQG_additional
145
+		);
146
+		$success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes);
147
+		if (! $success) {
148
+			$this->add_error(
149
+				$this->get_migration_script()->_create_error_message_for_db_insertion(
150
+					$this->_old_table,
151
+					$old_event,
152
+					$this->_new_table,
153
+					$cols_n_values,
154
+					$datatypes
155
+				)
156
+			);
157
+			return 0;
158
+		}
159
+		return $wpdb->insert_id;
160
+	}
163 161
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -103,12 +103,12 @@  discard block
 block discarded – undo
103 103
     {
104 104
         global $wpdb;
105 105
         $new_question_group_id = $this->get_migration_script()->get_mapping_new_pk(
106
-            $wpdb->prefix . "events_qst_group",
106
+            $wpdb->prefix."events_qst_group",
107 107
             intval($old_question_group_id),
108
-            $wpdb->prefix . "esp_question_group"
108
+            $wpdb->prefix."esp_question_group"
109 109
         );
110 110
 
111
-        if (! $new_question_group_id) {
111
+        if ( ! $new_question_group_id) {
112 112
             $this->add_error(
113 113
                 sprintf(
114 114
                     // translators: %s question ID, %s event ID
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
             return 0;
121 121
         }
122 122
         $new_event_id = $this->get_migration_script()->get_mapping_new_pk(
123
-            $wpdb->prefix . "events_detail",
123
+            $wpdb->prefix."events_detail",
124 124
             intval($old_event['id']),
125 125
             $wpdb->posts
126 126
         );
127
-        if (! $new_question_group_id) {
127
+        if ( ! $new_question_group_id) {
128 128
             $this->add_error(
129 129
                 sprintf(
130 130
                     // translators: %s event ID
@@ -141,12 +141,12 @@  discard block
 block discarded – undo
141 141
         );
142 142
 
143 143
         $datatypes = array(
144
-            '%d',// EVT_ID
145
-            '%d',// QSG_ID
146
-            '%d',// EQG_primary or EQG_additional
144
+            '%d', // EVT_ID
145
+            '%d', // QSG_ID
146
+            '%d', // EQG_primary or EQG_additional
147 147
         );
148 148
         $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes);
149
-        if (! $success) {
149
+        if ( ! $success) {
150 150
             $this->add_error(
151 151
                 $this->get_migration_script()->_create_error_message_for_db_insertion(
152 152
                     $this->_old_table,
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_10_0.dms.php 2 patches
Indentation   +201 added lines, -201 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
16 16
 $stages = glob(EE_CORE . 'data_migration_scripts/4_10_0_stages/*');
17 17
 $class_to_filepath = [];
18 18
 foreach ($stages as $filepath) {
19
-    $matches = [];
20
-    preg_match('~4_10_0_stages/(.*).dmsstage.php~', $filepath, $matches);
21
-    $class_to_filepath[ $matches[1] ] = $filepath;
19
+	$matches = [];
20
+	preg_match('~4_10_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_10_0__autoloaded_stages', $class_to_filepath);
@@ -36,78 +36,78 @@  discard block
 block discarded – undo
36 36
  */
37 37
 class EE_DMS_Core_4_10_0 extends EE_Data_Migration_Script_Base
38 38
 {
39
-    /**
40
-     * @var EE_DMS_Core_4_9_0
41
-     */
42
-    protected $dms_4_9;
39
+	/**
40
+	 * @var EE_DMS_Core_4_9_0
41
+	 */
42
+	protected $dms_4_9;
43 43
 
44
-    /**
45
-     *
46
-     * @param TableManager  $table_manager
47
-     * @param TableAnalysis $table_analysis
48
-     */
49
-    public function __construct(
50
-        TableManager $table_manager = null,
51
-        TableAnalysis $table_analysis = null,
52
-        EE_DMS_Core_4_9_0 $dms_4_9
53
-    ) {
54
-        if (! $dms_4_9 instanceof EE_DMS_Core_4_9_0) {
55
-            $dms_4_9 = LoaderFactory::getLoader()->getShared('EE_DMS_Core_4_9_0');
56
-        }
57
-        $this->dms_4_9 = $dms_4_9;
58
-        $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.10.0", "event_espresso");
59
-        $this->_priority = 10;
60
-        $this->_migration_stages = array(
61
-            new EE_DMS_4_10_0_Event_Question_Group(),
62
-        );
63
-        parent::__construct($table_manager, $table_analysis);
64
-    }
44
+	/**
45
+	 *
46
+	 * @param TableManager  $table_manager
47
+	 * @param TableAnalysis $table_analysis
48
+	 */
49
+	public function __construct(
50
+		TableManager $table_manager = null,
51
+		TableAnalysis $table_analysis = null,
52
+		EE_DMS_Core_4_9_0 $dms_4_9
53
+	) {
54
+		if (! $dms_4_9 instanceof EE_DMS_Core_4_9_0) {
55
+			$dms_4_9 = LoaderFactory::getLoader()->getShared('EE_DMS_Core_4_9_0');
56
+		}
57
+		$this->dms_4_9 = $dms_4_9;
58
+		$this->_pretty_name = esc_html__("Data Update to Event Espresso 4.10.0", "event_espresso");
59
+		$this->_priority = 10;
60
+		$this->_migration_stages = array(
61
+			new EE_DMS_4_10_0_Event_Question_Group(),
62
+		);
63
+		parent::__construct($table_manager, $table_analysis);
64
+	}
65 65
 
66 66
 
67 67
 
68
-    /**
69
-     * Whether to migrate or not.
70
-     *
71
-     * @param array $version_array
72
-     * @return bool
73
-     */
74
-    public function can_migrate_from_version($version_array)
75
-    {
76
-        $version_string = $version_array['Core'];
77
-        if (version_compare($version_string, '4.10.0.rc.000', '<') && version_compare($version_string, '4.9.0', '>=')) {
78
-            //          echo "$version_string can be migrated from";
79
-            return true;
80
-        } elseif (! $version_string) {
81
-            //          echo "no version string provided: $version_string";
82
-            // no version string provided... this must be pre 4.3
83
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
84
-        } else {
85
-            //          echo "$version_string doesnt apply";
86
-            return false;
87
-        }
88
-    }
68
+	/**
69
+	 * Whether to migrate or not.
70
+	 *
71
+	 * @param array $version_array
72
+	 * @return bool
73
+	 */
74
+	public function can_migrate_from_version($version_array)
75
+	{
76
+		$version_string = $version_array['Core'];
77
+		if (version_compare($version_string, '4.10.0.rc.000', '<') && version_compare($version_string, '4.9.0', '>=')) {
78
+			//          echo "$version_string can be migrated from";
79
+			return true;
80
+		} elseif (! $version_string) {
81
+			//          echo "no version string provided: $version_string";
82
+			// no version string provided... this must be pre 4.3
83
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
84
+		} else {
85
+			//          echo "$version_string doesnt apply";
86
+			return false;
87
+		}
88
+	}
89 89
 
90 90
 
91 91
 
92
-    /**
93
-     * @return bool
94
-     */
95
-    public function schema_changes_before_migration()
96
-    {
97
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
98
-        $now_in_mysql = current_time('mysql', true);
99
-        $table_name = 'esp_answer';
100
-        $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
92
+	/**
93
+	 * @return bool
94
+	 */
95
+	public function schema_changes_before_migration()
96
+	{
97
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
98
+		$now_in_mysql = current_time('mysql', true);
99
+		$table_name = 'esp_answer';
100
+		$sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
101 101
 					REG_ID int(10) unsigned NOT NULL,
102 102
 					QST_ID int(10) unsigned NOT NULL,
103 103
 					ANS_value text NOT NULL,
104 104
 					PRIMARY KEY  (ANS_ID),
105 105
 					KEY REG_ID (REG_ID),
106 106
 					KEY QST_ID (QST_ID)";
107
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
108
-        $table_name = 'esp_attendee_meta';
109
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email');
110
-        $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
107
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
108
+		$table_name = 'esp_attendee_meta';
109
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email');
110
+		$sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
111 111
 				ATT_ID bigint(20) unsigned NOT NULL,
112 112
 				ATT_fname varchar(45) NOT NULL,
113 113
 				ATT_lname varchar(45) NOT NULL,
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
 				KEY ATT_email (ATT_email(191)),
125 125
 				KEY ATT_lname (ATT_lname),
126 126
 				KEY ATT_fname (ATT_fname)";
127
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
128
-        $table_name = 'esp_checkin';
129
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
127
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
128
+		$table_name = 'esp_checkin';
129
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
130 130
 				REG_ID int(10) unsigned NOT NULL,
131 131
 				DTT_ID int(10) unsigned NOT NULL,
132 132
 				CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
 				PRIMARY KEY  (CHK_ID),
135 135
 				KEY REG_ID (REG_ID),
136 136
 				KEY DTT_ID (DTT_ID)";
137
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
138
-        $table_name = 'esp_country';
139
-        $sql = "CNT_ISO varchar(2) NOT NULL,
137
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
138
+		$table_name = 'esp_country';
139
+		$sql = "CNT_ISO varchar(2) NOT NULL,
140 140
 				CNT_ISO3 varchar(3) NOT NULL,
141 141
 				RGN_ID tinyint(3) unsigned DEFAULT NULL,
142 142
 				CNT_name varchar(45) NOT NULL,
@@ -152,29 +152,29 @@  discard block
 block discarded – undo
152 152
 				CNT_is_EU tinyint(1) DEFAULT '0',
153 153
 				CNT_active tinyint(1) DEFAULT '0',
154 154
 				PRIMARY KEY  (CNT_ISO)";
155
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
156
-        $table_name = 'esp_currency';
157
-        $sql = "CUR_code varchar(6) NOT NULL,
155
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
156
+		$table_name = 'esp_currency';
157
+		$sql = "CUR_code varchar(6) NOT NULL,
158 158
 				CUR_single varchar(45) DEFAULT 'dollar',
159 159
 				CUR_plural varchar(45) DEFAULT 'dollars',
160 160
 				CUR_sign varchar(45) DEFAULT '$',
161 161
 				CUR_dec_plc varchar(1) NOT NULL DEFAULT '2',
162 162
 				CUR_active tinyint(1) DEFAULT '0',
163 163
 				PRIMARY KEY  (CUR_code)";
164
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
165
-        // note: although this table is no longer in use,
166
-        // it hasn't been removed because then queries to the model will have errors.
167
-        // but you should expect this table and its corresponding model to be removed in
168
-        // the next few months
169
-        $table_name = 'esp_currency_payment_method';
170
-        $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
164
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
165
+		// note: although this table is no longer in use,
166
+		// it hasn't been removed because then queries to the model will have errors.
167
+		// but you should expect this table and its corresponding model to be removed in
168
+		// the next few months
169
+		$table_name = 'esp_currency_payment_method';
170
+		$sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
171 171
 				CUR_code varchar(6) NOT NULL,
172 172
 				PMD_ID int(11) NOT NULL,
173 173
 				PRIMARY KEY  (CPM_ID),
174 174
 				KEY PMD_ID (PMD_ID)";
175
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
176
-        $table_name = 'esp_datetime';
177
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
175
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
176
+		$table_name = 'esp_datetime';
177
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
178 178
 				EVT_ID bigint(20) unsigned NOT NULL,
179 179
 				DTT_name varchar(255) NOT NULL DEFAULT '',
180 180
 				DTT_description text NOT NULL,
@@ -191,25 +191,25 @@  discard block
 block discarded – undo
191 191
 				KEY DTT_EVT_start (DTT_EVT_start),
192 192
 				KEY EVT_ID (EVT_ID),
193 193
 				KEY DTT_is_primary (DTT_is_primary)";
194
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
195
-        $table_name = "esp_datetime_ticket";
196
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
194
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
195
+		$table_name = "esp_datetime_ticket";
196
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
197 197
 				DTT_ID int(10) unsigned NOT NULL,
198 198
 				TKT_ID int(10) unsigned NOT NULL,
199 199
 				PRIMARY KEY  (DTK_ID),
200 200
 				KEY DTT_ID (DTT_ID),
201 201
 				KEY TKT_ID (TKT_ID)";
202
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
203
-        $table_name = 'esp_event_message_template';
204
-        $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
202
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
203
+		$table_name = 'esp_event_message_template';
204
+		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
205 205
 				EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0,
206 206
 				GRP_ID int(10) unsigned NOT NULL DEFAULT 0,
207 207
 				PRIMARY KEY  (EMT_ID),
208 208
 				KEY EVT_ID (EVT_ID),
209 209
 				KEY GRP_ID (GRP_ID)";
210
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
211
-        $table_name = 'esp_event_meta';
212
-        $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
210
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
211
+		$table_name = 'esp_event_meta';
212
+		$sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
213 213
 				EVT_ID bigint(20) unsigned NOT NULL,
214 214
 				EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
215 215
 				EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -224,9 +224,9 @@  discard block
 block discarded – undo
224 224
 				EVT_donations tinyint(1) NULL,
225 225
 				PRIMARY KEY  (EVTM_ID),
226 226
 				KEY EVT_ID (EVT_ID)";
227
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
228
-        $table_name = 'esp_event_question_group';
229
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
227
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
228
+		$table_name = 'esp_event_question_group';
229
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
230 230
 				EVT_ID bigint(20) unsigned NOT NULL,
231 231
 				QSG_ID int(10) unsigned NOT NULL,
232 232
 				EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
@@ -234,25 +234,25 @@  discard block
 block discarded – undo
234 234
 				PRIMARY KEY  (EQG_ID),
235 235
 				KEY EVT_ID (EVT_ID),
236 236
 				KEY QSG_ID (QSG_ID)";
237
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
238
-        $table_name = 'esp_event_venue';
239
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
237
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
238
+		$table_name = 'esp_event_venue';
239
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
240 240
 				EVT_ID bigint(20) unsigned NOT NULL,
241 241
 				VNU_ID bigint(20) unsigned NOT NULL,
242 242
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
243 243
 				PRIMARY KEY  (EVV_ID)";
244
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
245
-        $table_name = 'esp_extra_meta';
246
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
244
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
245
+		$table_name = 'esp_extra_meta';
246
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
247 247
 				OBJ_ID int(11) DEFAULT NULL,
248 248
 				EXM_type varchar(45) DEFAULT NULL,
249 249
 				EXM_key varchar(45) DEFAULT NULL,
250 250
 				EXM_value text,
251 251
 				PRIMARY KEY  (EXM_ID),
252 252
 				KEY EXM_type (EXM_type,OBJ_ID,EXM_key)";
253
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
254
-        $table_name = 'esp_extra_join';
255
-        $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
253
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
254
+		$table_name = 'esp_extra_join';
255
+		$sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
256 256
 				EXJ_first_model_id varchar(6) NOT NULL,
257 257
 				EXJ_first_model_name varchar(20) NOT NULL,
258 258
 				EXJ_second_model_id varchar(6) NOT NULL,
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
 				PRIMARY KEY  (EXJ_ID),
261 261
 				KEY first_model (EXJ_first_model_name,EXJ_first_model_id),
262 262
 				KEY second_model (EXJ_second_model_name,EXJ_second_model_id)";
263
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
264
-        $table_name = 'esp_line_item';
265
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
263
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
264
+		$table_name = 'esp_line_item';
265
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
266 266
 				LIN_code varchar(245) NOT NULL DEFAULT '',
267 267
 				TXN_ID int(11) DEFAULT NULL,
268 268
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -283,11 +283,11 @@  discard block
 block discarded – undo
283 283
 				KEY txn_type_timestamp (TXN_ID,LIN_type,LIN_timestamp),
284 284
 				KEY txn_obj_id_obj_type (TXN_ID,OBJ_ID,OBJ_type),
285 285
 				KEY obj_id_obj_type (OBJ_ID,OBJ_type)";
286
-        $this->_get_table_manager()->dropIndex('esp_line_item', 'TXN_ID');
287
-        $this->_get_table_manager()->dropIndex('esp_line_item', 'LIN_code');
288
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
289
-        $table_name = 'esp_log';
290
-        $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
286
+		$this->_get_table_manager()->dropIndex('esp_line_item', 'TXN_ID');
287
+		$this->_get_table_manager()->dropIndex('esp_line_item', 'LIN_code');
288
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
289
+		$table_name = 'esp_log';
290
+		$sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
291 291
 				LOG_time datetime DEFAULT NULL,
292 292
 				OBJ_ID varchar(45) DEFAULT NULL,
293 293
 				OBJ_type varchar(45) DEFAULT NULL,
@@ -298,12 +298,12 @@  discard block
 block discarded – undo
298 298
 				KEY LOG_time (LOG_time),
299 299
 				KEY OBJ (OBJ_type,OBJ_ID),
300 300
 				KEY LOG_type (LOG_type)";
301
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
302
-        $table_name = 'esp_message';
303
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to');
304
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from');
305
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject');
306
-        $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
301
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
302
+		$table_name = 'esp_message';
303
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to');
304
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from');
305
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject');
306
+		$sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
307 307
 				GRP_ID int(10) unsigned NULL,
308 308
 				MSG_token varchar(255) NULL,
309 309
 				TXN_ID int(10) unsigned NULL,
@@ -335,18 +335,18 @@  discard block
 block discarded – undo
335 335
 				KEY STS_ID (STS_ID),
336 336
 				KEY MSG_created (MSG_created),
337 337
 				KEY MSG_modified (MSG_modified)";
338
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
339
-        $table_name = 'esp_message_template';
340
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
338
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
339
+		$table_name = 'esp_message_template';
340
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
341 341
 				GRP_ID int(10) unsigned NOT NULL,
342 342
 				MTP_context varchar(50) NOT NULL,
343 343
 				MTP_template_field varchar(30) NOT NULL,
344 344
 				MTP_content text NOT NULL,
345 345
 				PRIMARY KEY  (MTP_ID),
346 346
 				KEY GRP_ID (GRP_ID)";
347
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
348
-        $table_name = 'esp_message_template_group';
349
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
347
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
348
+		$table_name = 'esp_message_template_group';
349
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
350 350
 				MTP_user_id int(10) NOT NULL DEFAULT '1',
351 351
 				MTP_name varchar(245) NOT NULL DEFAULT '',
352 352
 				MTP_description varchar(245) NOT NULL DEFAULT '',
@@ -358,9 +358,9 @@  discard block
 block discarded – undo
358 358
 				MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
359 359
 				PRIMARY KEY  (GRP_ID),
360 360
 				KEY MTP_user_id (MTP_user_id)";
361
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
362
-        $table_name = 'esp_payment';
363
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
361
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
362
+		$table_name = 'esp_payment';
363
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
364 364
 				TXN_ID int(10) unsigned DEFAULT NULL,
365 365
 				STS_ID varchar(3) DEFAULT NULL,
366 366
 				PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -377,9 +377,9 @@  discard block
 block discarded – undo
377 377
 				PRIMARY KEY  (PAY_ID),
378 378
 				KEY PAY_timestamp (PAY_timestamp),
379 379
 				KEY TXN_ID (TXN_ID)";
380
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
381
-        $table_name = 'esp_payment_method';
382
-        $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
380
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
381
+		$table_name = 'esp_payment_method';
382
+		$sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
383 383
 				PMD_type varchar(124) DEFAULT NULL,
384 384
 				PMD_name varchar(255) DEFAULT NULL,
385 385
 				PMD_desc text,
@@ -395,24 +395,24 @@  discard block
 block discarded – undo
395 395
 				PRIMARY KEY  (PMD_ID),
396 396
 				UNIQUE KEY PMD_slug_UNIQUE (PMD_slug),
397 397
 				KEY PMD_type (PMD_type)";
398
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
399
-        $table_name = "esp_ticket_price";
400
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
398
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
399
+		$table_name = "esp_ticket_price";
400
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
401 401
 				TKT_ID int(10) unsigned NOT NULL,
402 402
 				PRC_ID int(10) unsigned NOT NULL,
403 403
 				PRIMARY KEY  (TKP_ID),
404 404
 				KEY TKT_ID (TKT_ID),
405 405
 				KEY PRC_ID (PRC_ID)";
406
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
407
-        $table_name = "esp_ticket_template";
408
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
406
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
407
+		$table_name = "esp_ticket_template";
408
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
409 409
 				TTM_name varchar(45) NOT NULL,
410 410
 				TTM_description text,
411 411
 				TTM_file varchar(45),
412 412
 				PRIMARY KEY  (TTM_ID)";
413
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
414
-        $table_name = 'esp_question';
415
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
413
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
414
+		$table_name = 'esp_question';
415
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
416 416
 				QST_display_text text NOT NULL,
417 417
 				QST_admin_label varchar(255) NOT NULL,
418 418
 				QST_system varchar(25) DEFAULT NULL,
@@ -426,18 +426,18 @@  discard block
 block discarded – undo
426 426
 				QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0,
427 427
 				PRIMARY KEY  (QST_ID),
428 428
 				KEY QST_order (QST_order)';
429
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
430
-        $table_name = 'esp_question_group_question';
431
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
429
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
430
+		$table_name = 'esp_question_group_question';
431
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
432 432
 				QSG_ID int(10) unsigned NOT NULL,
433 433
 				QST_ID int(10) unsigned NOT NULL,
434 434
 				QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
435 435
 				PRIMARY KEY  (QGQ_ID),
436 436
 				KEY QST_ID (QST_ID),
437 437
 				KEY QSG_ID_order (QSG_ID,QGQ_order)";
438
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
439
-        $table_name = 'esp_question_option';
440
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
438
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
439
+		$table_name = 'esp_question_option';
440
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
441 441
 				QSO_value varchar(255) NOT NULL,
442 442
 				QSO_desc text NOT NULL,
443 443
 				QST_ID int(10) unsigned NOT NULL,
@@ -447,9 +447,9 @@  discard block
 block discarded – undo
447 447
 				PRIMARY KEY  (QSO_ID),
448 448
 				KEY QST_ID (QST_ID),
449 449
 				KEY QSO_order (QSO_order)";
450
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
451
-        $table_name = 'esp_registration';
452
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
450
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
451
+		$table_name = 'esp_registration';
452
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
453 453
 				EVT_ID bigint(20) unsigned NOT NULL,
454 454
 				ATT_ID bigint(20) unsigned NOT NULL,
455 455
 				TXN_ID int(10) unsigned NOT NULL,
@@ -473,18 +473,18 @@  discard block
 block discarded – undo
473 473
 				KEY TKT_ID (TKT_ID),
474 474
 				KEY EVT_ID (EVT_ID),
475 475
 				KEY STS_ID (STS_ID)";
476
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
477
-        $table_name = 'esp_registration_payment';
478
-        $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
476
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
477
+		$table_name = 'esp_registration_payment';
478
+		$sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
479 479
 					  REG_ID int(10) unsigned NOT NULL,
480 480
 					  PAY_ID int(10) unsigned NULL,
481 481
 					  RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00',
482 482
 					  PRIMARY KEY  (RPY_ID),
483 483
 					  KEY REG_ID (REG_ID),
484 484
 					  KEY PAY_ID (PAY_ID)";
485
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
486
-        $table_name = 'esp_state';
487
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
485
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
486
+		$table_name = 'esp_state';
487
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
488 488
 				CNT_ISO varchar(2) NOT NULL,
489 489
 				STA_abbrev varchar(24) NOT NULL,
490 490
 				STA_name varchar(100) NOT NULL,
@@ -492,9 +492,9 @@  discard block
 block discarded – undo
492 492
 				PRIMARY KEY  (STA_ID),
493 493
 				KEY STA_abbrev (STA_abbrev),
494 494
 				KEY CNT_ISO (CNT_ISO)";
495
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
496
-        $table_name = 'esp_status';
497
-        $sql = "STS_ID varchar(3) NOT NULL,
495
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
496
+		$table_name = 'esp_status';
497
+		$sql = "STS_ID varchar(3) NOT NULL,
498 498
 				STS_code varchar(45) NOT NULL,
499 499
 				STS_type varchar(45) NOT NULL,
500 500
 				STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -502,9 +502,9 @@  discard block
 block discarded – undo
502 502
 				STS_open tinyint(1) NOT NULL DEFAULT 1,
503 503
 				UNIQUE KEY STS_ID_UNIQUE (STS_ID),
504 504
 				KEY STS_type (STS_type)";
505
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
506
-        $table_name = 'esp_transaction';
507
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
505
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
506
+		$table_name = 'esp_transaction';
507
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
508 508
 				TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
509 509
 				TXN_total decimal(12,3) DEFAULT '0.00',
510 510
 				TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00',
@@ -516,9 +516,9 @@  discard block
 block discarded – undo
516 516
 				PRIMARY KEY  (TXN_ID),
517 517
 				KEY TXN_timestamp (TXN_timestamp),
518 518
 				KEY STS_ID (STS_ID)";
519
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
520
-        $table_name = 'esp_venue_meta';
521
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
519
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
520
+		$table_name = 'esp_venue_meta';
521
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
522 522
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
523 523
 			VNU_address varchar(255) DEFAULT NULL,
524 524
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -537,10 +537,10 @@  discard block
 block discarded – undo
537 537
 			KEY VNU_ID (VNU_ID),
538 538
 			KEY STA_ID (STA_ID),
539 539
 			KEY CNT_ISO (CNT_ISO)";
540
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
541
-        // modified tables
542
-        $table_name = "esp_price";
543
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
540
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
541
+		// modified tables
542
+		$table_name = "esp_price";
543
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
544 544
 				PRT_ID tinyint(3) unsigned NOT NULL,
545 545
 				PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00',
546 546
 				PRC_name varchar(245) NOT NULL,
@@ -553,9 +553,9 @@  discard block
 block discarded – undo
553 553
 				PRC_parent int(10) unsigned DEFAULT 0,
554 554
 				PRIMARY KEY  (PRC_ID),
555 555
 				KEY PRT_ID (PRT_ID)";
556
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
557
-        $table_name = "esp_price_type";
558
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
556
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
557
+		$table_name = "esp_price_type";
558
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
559 559
 				PRT_name varchar(45) NOT NULL,
560 560
 				PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
561 561
 				PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -564,9 +564,9 @@  discard block
 block discarded – undo
564 564
 				PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
565 565
 				UNIQUE KEY PRT_name_UNIQUE (PRT_name),
566 566
 				PRIMARY KEY  (PRT_ID)";
567
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
568
-        $table_name = "esp_ticket";
569
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
567
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
568
+		$table_name = "esp_ticket";
569
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
570 570
 				TTM_ID int(10) unsigned NOT NULL,
571 571
 				TKT_name varchar(245) NOT NULL DEFAULT '',
572 572
 				TKT_description text NOT NULL,
@@ -589,9 +589,9 @@  discard block
 block discarded – undo
589 589
 				TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
590 590
 				PRIMARY KEY  (TKT_ID),
591 591
 				KEY TKT_start_date (TKT_start_date)";
592
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
593
-        $table_name = 'esp_question_group';
594
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
592
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
593
+		$table_name = 'esp_question_group';
594
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
595 595
 				QSG_name varchar(255) NOT NULL,
596 596
 				QSG_identifier varchar(100) NOT NULL,
597 597
 				QSG_desc text NULL,
@@ -604,38 +604,38 @@  discard block
 block discarded – undo
604 604
 				PRIMARY KEY  (QSG_ID),
605 605
 				UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier),
606 606
 				KEY QSG_order (QSG_order)';
607
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
608
-        $this->insert_default_data();
609
-        return true;
610
-    }
607
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
608
+		$this->insert_default_data();
609
+		return true;
610
+	}
611 611
 
612
-    /**
613
-     * Inserts default data on new installs
614
-     * @since $VID:$
615
-     * @throws EE_Error
616
-     * @throws InvalidArgumentException
617
-     * @throws ReflectionException
618
-     * @throws InvalidDataTypeException
619
-     * @throws InvalidInterfaceException
620
-     */
621
-    public function insert_default_data()
622
-    {
623
-        $this->dms_4_9->insert_default_data();
624
-    }
612
+	/**
613
+	 * Inserts default data on new installs
614
+	 * @since $VID:$
615
+	 * @throws EE_Error
616
+	 * @throws InvalidArgumentException
617
+	 * @throws ReflectionException
618
+	 * @throws InvalidDataTypeException
619
+	 * @throws InvalidInterfaceException
620
+	 */
621
+	public function insert_default_data()
622
+	{
623
+		$this->dms_4_9->insert_default_data();
624
+	}
625 625
 
626 626
 
627 627
 
628
-    /**
629
-     * @return boolean
630
-     */
631
-    public function schema_changes_after_migration()
632
-    {
633
-        return true;
634
-    }
628
+	/**
629
+	 * @return boolean
630
+	 */
631
+	public function schema_changes_after_migration()
632
+	{
633
+		return true;
634
+	}
635 635
 
636 636
 
637 637
 
638
-    public function migration_page_hooks()
639
-    {
640
-    }
638
+	public function migration_page_hooks()
639
+	{
640
+	}
641 641
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,12 +13,12 @@  discard block
 block discarded – undo
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_10_0_stages/*');
16
+$stages = glob(EE_CORE.'data_migration_scripts/4_10_0_stages/*');
17 17
 $class_to_filepath = [];
18 18
 foreach ($stages as $filepath) {
19 19
     $matches = [];
20 20
     preg_match('~4_10_0_stages/(.*).dmsstage.php~', $filepath, $matches);
21
-    $class_to_filepath[ $matches[1] ] = $filepath;
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_10_0__autoloaded_stages', $class_to_filepath);
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         TableAnalysis $table_analysis = null,
52 52
         EE_DMS_Core_4_9_0 $dms_4_9
53 53
     ) {
54
-        if (! $dms_4_9 instanceof EE_DMS_Core_4_9_0) {
54
+        if ( ! $dms_4_9 instanceof EE_DMS_Core_4_9_0) {
55 55
             $dms_4_9 = LoaderFactory::getLoader()->getShared('EE_DMS_Core_4_9_0');
56 56
         }
57 57
         $this->dms_4_9 = $dms_4_9;
@@ -77,10 +77,10 @@  discard block
 block discarded – undo
77 77
         if (version_compare($version_string, '4.10.0.rc.000', '<') && version_compare($version_string, '4.9.0', '>=')) {
78 78
             //          echo "$version_string can be migrated from";
79 79
             return true;
80
-        } elseif (! $version_string) {
80
+        } elseif ( ! $version_string) {
81 81
             //          echo "no version string provided: $version_string";
82 82
             // no version string provided... this must be pre 4.3
83
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
83
+            return false; // changed mind. dont want people thinking they should migrate yet because they cant
84 84
         } else {
85 85
             //          echo "$version_string doesnt apply";
86 86
             return false;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
      */
95 95
     public function schema_changes_before_migration()
96 96
     {
97
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
97
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
98 98
         $now_in_mysql = current_time('mysql', true);
99 99
         $table_name = 'esp_answer';
100 100
         $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
Please login to merge, or discard this patch.
core/db_models/EEM_Event_Question_Group.model.php 2 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -7,46 +7,46 @@
 block discarded – undo
7 7
  */
8 8
 class EEM_Event_Question_Group extends EEM_Base
9 9
 {
10
-    // private instance of the Attendee object
11
-    protected static $_instance = null;
10
+	// private instance of the Attendee object
11
+	protected static $_instance = null;
12 12
 
13
-    protected function __construct($timezone = null)
14
-    {
15
-        $this->singular_item = __('Event to Question Group Link', 'event_espresso');
16
-        $this->plural_item = __('Event to Question Group Links', 'event_espresso');
17
-        $this->_tables = array(
18
-            'Event_Question_Group'=>new EE_Primary_Table('esp_event_question_group', 'EQG_ID')
19
-        );
20
-        $this->_fields = array(
21
-            'Event_Question_Group'=>array(
22
-                'EQG_ID'=>new EE_Primary_Key_Int_Field('EQG_ID', __('Event to Question Group Link ID', 'event_espresso')),
23
-                'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'),
24
-                'QSG_ID'=>new EE_Foreign_Key_Int_Field('QSG_ID', __('Question Group Id', 'event_espresso'), false, 0, 'Question_Group'),
25
-                'EQG_primary'=>new EE_Boolean_Field('EQG_primary', __('Flag indicating question is only for primary attendees', 'event_espresso'), false, false),
26
-                'EQG_additional'=>new EE_Boolean_Field('EQG_additional', __('Flag indicating question is only for additional attendees', 'event_espresso'), false, false)
27
-            )
28
-        );
29
-        $this->_model_relations = array(
30
-            'Event'=>new EE_Belongs_To_Relation(),
31
-            'Question_Group'=>new EE_Belongs_To_Relation()
32
-        );
33
-        // this model is generally available for reading
34
-        $path_to_event = 'Event';
35
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public($path_to_event);
36
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event);
37
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event);
38
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event, EEM_Base::caps_edit);
39
-        parent::__construct($timezone);
40
-    }
13
+	protected function __construct($timezone = null)
14
+	{
15
+		$this->singular_item = __('Event to Question Group Link', 'event_espresso');
16
+		$this->plural_item = __('Event to Question Group Links', 'event_espresso');
17
+		$this->_tables = array(
18
+			'Event_Question_Group'=>new EE_Primary_Table('esp_event_question_group', 'EQG_ID')
19
+		);
20
+		$this->_fields = array(
21
+			'Event_Question_Group'=>array(
22
+				'EQG_ID'=>new EE_Primary_Key_Int_Field('EQG_ID', __('Event to Question Group Link ID', 'event_espresso')),
23
+				'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'),
24
+				'QSG_ID'=>new EE_Foreign_Key_Int_Field('QSG_ID', __('Question Group Id', 'event_espresso'), false, 0, 'Question_Group'),
25
+				'EQG_primary'=>new EE_Boolean_Field('EQG_primary', __('Flag indicating question is only for primary attendees', 'event_espresso'), false, false),
26
+				'EQG_additional'=>new EE_Boolean_Field('EQG_additional', __('Flag indicating question is only for additional attendees', 'event_espresso'), false, false)
27
+			)
28
+		);
29
+		$this->_model_relations = array(
30
+			'Event'=>new EE_Belongs_To_Relation(),
31
+			'Question_Group'=>new EE_Belongs_To_Relation()
32
+		);
33
+		// this model is generally available for reading
34
+		$path_to_event = 'Event';
35
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public($path_to_event);
36
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event);
37
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event);
38
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event, EEM_Base::caps_edit);
39
+		parent::__construct($timezone);
40
+	}
41 41
 
42
-    /**
43
-     * Decides whether to use the 'EQG_primary' or newer 'EQG_additional' for use in queries, based on whether
44
-     * this is concerning primary attendees or additional attendees.
45
-     * @since $VID:$
46
-     * @param $for_primary_attendees
47
-     * @return string
48
-     */
49
-    public function field_name_for_category($for_primary_attendees) {
50
-        return $for_primary_attendees ? 'EQG_primary' : 'EQG_additional';
51
-    }
42
+	/**
43
+	 * Decides whether to use the 'EQG_primary' or newer 'EQG_additional' for use in queries, based on whether
44
+	 * this is concerning primary attendees or additional attendees.
45
+	 * @since $VID:$
46
+	 * @param $for_primary_attendees
47
+	 * @return string
48
+	 */
49
+	public function field_name_for_category($for_primary_attendees) {
50
+		return $for_primary_attendees ? 'EQG_primary' : 'EQG_additional';
51
+	}
52 52
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@
 block discarded – undo
32 32
         );
33 33
         // this model is generally available for reading
34 34
         $path_to_event = 'Event';
35
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public($path_to_event);
36
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event);
37
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event);
38
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event, EEM_Base::caps_edit);
35
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public($path_to_event);
36
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event);
37
+        $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event);
38
+        $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event, EEM_Base::caps_edit);
39 39
         parent::__construct($timezone);
40 40
     }
41 41
 
Please login to merge, or discard this patch.
caffeinated/admin/extend/events/Extend_Events_Admin_Page.core.php 2 patches
Indentation   +1253 added lines, -1253 removed lines patch added patch discarded remove patch
@@ -16,1257 +16,1257 @@
 block discarded – undo
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
-    /**
36
-     * Sets routes.
37
-     */
38
-    protected function _extend_page_config()
39
-    {
40
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
41
-        // is there a evt_id in the request?
42
-        $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
43
-            ? $this->_req_data['EVT_ID']
44
-            : 0;
45
-        $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
46
-        // tkt_id?
47
-        $tkt_id = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID'])
48
-            ? $this->_req_data['TKT_ID']
49
-            : 0;
50
-        $new_page_routes = array(
51
-            'duplicate_event'          => array(
52
-                'func'       => '_duplicate_event',
53
-                'capability' => 'ee_edit_event',
54
-                'obj_id'     => $evt_id,
55
-                'noheader'   => true,
56
-            ),
57
-            'ticket_list_table'        => array(
58
-                'func'       => '_tickets_overview_list_table',
59
-                'capability' => 'ee_read_default_tickets',
60
-            ),
61
-            'trash_ticket'             => array(
62
-                'func'       => '_trash_or_restore_ticket',
63
-                'capability' => 'ee_delete_default_ticket',
64
-                'obj_id'     => $tkt_id,
65
-                'noheader'   => true,
66
-                'args'       => array('trash' => true),
67
-            ),
68
-            'trash_tickets'            => array(
69
-                'func'       => '_trash_or_restore_ticket',
70
-                'capability' => 'ee_delete_default_tickets',
71
-                'noheader'   => true,
72
-                'args'       => array('trash' => true),
73
-            ),
74
-            'restore_ticket'           => array(
75
-                'func'       => '_trash_or_restore_ticket',
76
-                'capability' => 'ee_delete_default_ticket',
77
-                'obj_id'     => $tkt_id,
78
-                'noheader'   => true,
79
-            ),
80
-            'restore_tickets'          => array(
81
-                'func'       => '_trash_or_restore_ticket',
82
-                'capability' => 'ee_delete_default_tickets',
83
-                'noheader'   => true,
84
-            ),
85
-            'delete_ticket'            => array(
86
-                'func'       => '_delete_ticket',
87
-                'capability' => 'ee_delete_default_ticket',
88
-                'obj_id'     => $tkt_id,
89
-                'noheader'   => true,
90
-            ),
91
-            'delete_tickets'           => array(
92
-                'func'       => '_delete_ticket',
93
-                'capability' => 'ee_delete_default_tickets',
94
-                'noheader'   => true,
95
-            ),
96
-            'import_page'              => array(
97
-                'func'       => '_import_page',
98
-                'capability' => 'import',
99
-            ),
100
-            'import'                   => array(
101
-                'func'       => '_import_events',
102
-                'capability' => 'import',
103
-                'noheader'   => true,
104
-            ),
105
-            'import_events'            => array(
106
-                'func'       => '_import_events',
107
-                'capability' => 'import',
108
-                'noheader'   => true,
109
-            ),
110
-            'export_events'            => array(
111
-                'func'       => '_events_export',
112
-                'capability' => 'export',
113
-                'noheader'   => true,
114
-            ),
115
-            'export_categories'        => array(
116
-                'func'       => '_categories_export',
117
-                'capability' => 'export',
118
-                'noheader'   => true,
119
-            ),
120
-            'sample_export_file'       => array(
121
-                'func'       => '_sample_export_file',
122
-                'capability' => 'export',
123
-                'noheader'   => true,
124
-            ),
125
-            'update_template_settings' => array(
126
-                'func'       => '_update_template_settings',
127
-                'capability' => 'manage_options',
128
-                'noheader'   => true,
129
-            ),
130
-        );
131
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
132
-        // partial route/config override
133
-        $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes;
134
-        $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes';
135
-        $this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips';
136
-        $this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips';
137
-        $this->_page_config['edit']['metaboxes'][] = '_premium_event_editor_meta_boxes';
138
-        $this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table';
139
-        // add tickets tab but only if there are more than one default ticket!
140
-        $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
141
-            array(array('TKT_is_default' => 1)),
142
-            'TKT_ID',
143
-            true
144
-        );
145
-        if ($tkt_count > 1) {
146
-            $new_page_config = array(
147
-                'ticket_list_table' => array(
148
-                    'nav'           => array(
149
-                        'label' => esc_html__('Default Tickets', 'event_espresso'),
150
-                        'order' => 60,
151
-                    ),
152
-                    'list_table'    => 'Tickets_List_Table',
153
-                    'require_nonce' => false,
154
-                ),
155
-            );
156
-        }
157
-        // template settings
158
-        $new_page_config['template_settings'] = array(
159
-            'nav'           => array(
160
-                'label' => esc_html__('Templates', 'event_espresso'),
161
-                'order' => 30,
162
-            ),
163
-            'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
164
-            'help_tabs'     => array(
165
-                'general_settings_templates_help_tab' => array(
166
-                    'title'    => esc_html__('Templates', 'event_espresso'),
167
-                    'filename' => 'general_settings_templates',
168
-                ),
169
-            ),
170
-            'help_tour'     => array('Templates_Help_Tour'),
171
-            'require_nonce' => false,
172
-        );
173
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
174
-        // add filters and actions
175
-        // modifying _views
176
-        add_filter(
177
-            'FHEE_event_datetime_metabox_add_additional_date_time_template',
178
-            array($this, 'add_additional_datetime_button'),
179
-            10,
180
-            2
181
-        );
182
-        add_filter(
183
-            'FHEE_event_datetime_metabox_clone_button_template',
184
-            array($this, 'add_datetime_clone_button'),
185
-            10,
186
-            2
187
-        );
188
-        add_filter(
189
-            'FHEE_event_datetime_metabox_timezones_template',
190
-            array($this, 'datetime_timezones_template'),
191
-            10,
192
-            2
193
-        );
194
-        // filters for event list table
195
-        add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2);
196
-        add_filter(
197
-            'FHEE__Events_Admin_List_Table__column_actions__action_links',
198
-            array($this, 'extra_list_table_actions'),
199
-            10,
200
-            2
201
-        );
202
-        // legend item
203
-        add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items'));
204
-        add_action('admin_init', array($this, 'admin_init'));
205
-    }
206
-
207
-
208
-    /**
209
-     * admin_init
210
-     */
211
-    public function admin_init()
212
-    {
213
-        EE_Registry::$i18n_js_strings = array_merge(
214
-            EE_Registry::$i18n_js_strings,
215
-            array(
216
-                'image_confirm'          => esc_html__(
217
-                    'Do you really want to delete this image? Please remember to update your event to complete the removal.',
218
-                    'event_espresso'
219
-                ),
220
-                'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
221
-                'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
222
-                'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
223
-                'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
224
-                'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
225
-            )
226
-        );
227
-    }
228
-
229
-
230
-    /**
231
-     * Add per page screen options to the default ticket list table view.
232
-     */
233
-    protected function _add_screen_options_ticket_list_table()
234
-    {
235
-        $this->_per_page_screen_option();
236
-    }
237
-
238
-
239
-    /**
240
-     * @param string $return
241
-     * @param int    $id
242
-     * @param string $new_title
243
-     * @param string $new_slug
244
-     * @return string
245
-     */
246
-    public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
247
-    {
248
-        $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
249
-        // make sure this is only when editing
250
-        if (! empty($id)) {
251
-            $href = EE_Admin_Page::add_query_args_and_nonce(
252
-                array('action' => 'duplicate_event', 'EVT_ID' => $id),
253
-                $this->_admin_base_url
254
-            );
255
-            $title = esc_attr__('Duplicate Event', 'event_espresso');
256
-            $return .= '<a href="'
257
-                       . $href
258
-                       . '" title="'
259
-                       . $title
260
-                       . '" id="ee-duplicate-event-button" class="button button-small"  value="duplicate_event">'
261
-                       . $title
262
-                       . '</a>';
263
-        }
264
-        return $return;
265
-    }
266
-
267
-
268
-    /**
269
-     * Set the list table views for the default ticket list table view.
270
-     */
271
-    public function _set_list_table_views_ticket_list_table()
272
-    {
273
-        $this->_views = array(
274
-            'all'     => array(
275
-                'slug'        => 'all',
276
-                'label'       => esc_html__('All', 'event_espresso'),
277
-                'count'       => 0,
278
-                'bulk_action' => array(
279
-                    'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
280
-                ),
281
-            ),
282
-            'trashed' => array(
283
-                'slug'        => 'trashed',
284
-                'label'       => esc_html__('Trash', 'event_espresso'),
285
-                'count'       => 0,
286
-                'bulk_action' => array(
287
-                    'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
288
-                    'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
289
-                ),
290
-            ),
291
-        );
292
-    }
293
-
294
-
295
-    /**
296
-     * Enqueue scripts and styles for the event editor.
297
-     */
298
-    public function load_scripts_styles_edit()
299
-    {
300
-        wp_register_script(
301
-            'ee-event-editor-heartbeat',
302
-            EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
303
-            array('ee_admin_js', 'heartbeat'),
304
-            EVENT_ESPRESSO_VERSION,
305
-            true
306
-        );
307
-        wp_enqueue_script('ee-accounting');
308
-        // styles
309
-        wp_enqueue_style('espresso-ui-theme');
310
-        wp_enqueue_script('event_editor_js');
311
-        wp_enqueue_script('ee-event-editor-heartbeat');
312
-    }
313
-
314
-
315
-    /**
316
-     * Returns template for the additional datetime.
317
-     *
318
-     * @param $template
319
-     * @param $template_args
320
-     * @return mixed
321
-     * @throws DomainException
322
-     */
323
-    public function add_additional_datetime_button($template, $template_args)
324
-    {
325
-        return EEH_Template::display_template(
326
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
327
-            $template_args,
328
-            true
329
-        );
330
-    }
331
-
332
-
333
-    /**
334
-     * Returns the template for cloning a datetime.
335
-     *
336
-     * @param $template
337
-     * @param $template_args
338
-     * @return mixed
339
-     * @throws DomainException
340
-     */
341
-    public function add_datetime_clone_button($template, $template_args)
342
-    {
343
-        return EEH_Template::display_template(
344
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
345
-            $template_args,
346
-            true
347
-        );
348
-    }
349
-
350
-
351
-    /**
352
-     * Returns the template for datetime timezones.
353
-     *
354
-     * @param $template
355
-     * @param $template_args
356
-     * @return mixed
357
-     * @throws DomainException
358
-     */
359
-    public function datetime_timezones_template($template, $template_args)
360
-    {
361
-        return EEH_Template::display_template(
362
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
363
-            $template_args,
364
-            true
365
-        );
366
-    }
367
-
368
-
369
-    /**
370
-     * Sets the views for the default list table view.
371
-     */
372
-    protected function _set_list_table_views_default()
373
-    {
374
-        parent::_set_list_table_views_default();
375
-        $new_views = array(
376
-            'today' => array(
377
-                'slug'        => 'today',
378
-                'label'       => esc_html__('Today', 'event_espresso'),
379
-                'count'       => $this->total_events_today(),
380
-                'bulk_action' => array(
381
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
382
-                ),
383
-            ),
384
-            'month' => array(
385
-                'slug'        => 'month',
386
-                'label'       => esc_html__('This Month', 'event_espresso'),
387
-                'count'       => $this->total_events_this_month(),
388
-                'bulk_action' => array(
389
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
390
-                ),
391
-            ),
392
-        );
393
-        $this->_views = array_merge($this->_views, $new_views);
394
-    }
395
-
396
-
397
-    /**
398
-     * Returns the extra action links for the default list table view.
399
-     *
400
-     * @param array     $action_links
401
-     * @param \EE_Event $event
402
-     * @return array
403
-     * @throws EE_Error
404
-     */
405
-    public function extra_list_table_actions(array $action_links, \EE_Event $event)
406
-    {
407
-        if (EE_Registry::instance()->CAP->current_user_can(
408
-            'ee_read_registrations',
409
-            'espresso_registrations_reports',
410
-            $event->ID()
411
-        )
412
-        ) {
413
-            $reports_query_args = array(
414
-                'action' => 'reports',
415
-                'EVT_ID' => $event->ID(),
416
-            );
417
-            $reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL);
418
-            $action_links[] = '<a href="'
419
-                              . $reports_link
420
-                              . '" title="'
421
-                              . esc_attr__('View Report', 'event_espresso')
422
-                              . '"><div class="dashicons dashicons-chart-bar"></div></a>'
423
-                              . "\n\t";
424
-        }
425
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
426
-            EE_Registry::instance()->load_helper('MSG_Template');
427
-            $action_links[] = EEH_MSG_Template::get_message_action_link(
428
-                'see_notifications_for',
429
-                null,
430
-                array('EVT_ID' => $event->ID())
431
-            );
432
-        }
433
-        return $action_links;
434
-    }
435
-
436
-
437
-    /**
438
-     * @param $items
439
-     * @return mixed
440
-     */
441
-    public function additional_legend_items($items)
442
-    {
443
-        if (EE_Registry::instance()->CAP->current_user_can(
444
-            'ee_read_registrations',
445
-            'espresso_registrations_reports'
446
-        )
447
-        ) {
448
-            $items['reports'] = array(
449
-                'class' => 'dashicons dashicons-chart-bar',
450
-                'desc'  => esc_html__('Event Reports', 'event_espresso'),
451
-            );
452
-        }
453
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
454
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
455
-            if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
456
-                $items['view_related_messages'] = array(
457
-                    'class' => $related_for_icon['css_class'],
458
-                    'desc'  => $related_for_icon['label'],
459
-                );
460
-            }
461
-        }
462
-        return $items;
463
-    }
464
-
465
-
466
-    /**
467
-     * This is the callback method for the duplicate event route
468
-     * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
469
-     * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
470
-     * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
471
-     * After duplication the redirect is to the new event edit page.
472
-     *
473
-     * @return void
474
-     * @access protected
475
-     * @throws EE_Error If EE_Event is not available with given ID
476
-     */
477
-    protected function _duplicate_event()
478
-    {
479
-        // first make sure the ID for the event is in the request.
480
-        //  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
481
-        if (! isset($this->_req_data['EVT_ID'])) {
482
-            EE_Error::add_error(
483
-                esc_html__(
484
-                    'In order to duplicate an event an Event ID is required.  None was given.',
485
-                    'event_espresso'
486
-                ),
487
-                __FILE__,
488
-                __FUNCTION__,
489
-                __LINE__
490
-            );
491
-            $this->_redirect_after_action(false, '', '', array(), true);
492
-            return;
493
-        }
494
-        // k we've got EVT_ID so let's use that to get the event we'll duplicate
495
-        $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
496
-        if (! $orig_event instanceof EE_Event) {
497
-            throw new EE_Error(
498
-                sprintf(
499
-                    esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
500
-                    $this->_req_data['EVT_ID']
501
-                )
502
-            );
503
-        }
504
-        // k now let's clone the $orig_event before getting relations
505
-        $new_event = clone $orig_event;
506
-        // original datetimes
507
-        $orig_datetimes = $orig_event->get_many_related('Datetime');
508
-        // other original relations
509
-        $orig_ven = $orig_event->get_many_related('Venue');
510
-        // reset the ID and modify other details to make it clear this is a dupe
511
-        $new_event->set('EVT_ID', 0);
512
-        $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
513
-        $new_event->set('EVT_name', $new_name);
514
-        $new_event->set(
515
-            'EVT_slug',
516
-            wp_unique_post_slug(
517
-                sanitize_title($orig_event->name()),
518
-                0,
519
-                'publish',
520
-                'espresso_events',
521
-                0
522
-            )
523
-        );
524
-        $new_event->set('status', 'draft');
525
-        // duplicate discussion settings
526
-        $new_event->set('comment_status', $orig_event->get('comment_status'));
527
-        $new_event->set('ping_status', $orig_event->get('ping_status'));
528
-        // save the new event
529
-        $new_event->save();
530
-        // venues
531
-        foreach ($orig_ven as $ven) {
532
-            $new_event->_add_relation_to($ven, 'Venue');
533
-        }
534
-        $new_event->save();
535
-        // now we need to get the question group relations and handle that
536
-        // first primary question groups
537
-        $orig_primary_qgs = $orig_event->get_many_related(
538
-            'Question_Group',
539
-            [['Event_Question_Group.EQG_primary' => true]]
540
-        );
541
-        if (! empty($orig_primary_qgs)) {
542
-            foreach ($orig_primary_qgs as $id => $obj) {
543
-                if ($obj instanceof EE_Question_Group) {
544
-                    $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
545
-                }
546
-            }
547
-        }
548
-        // next additional attendee question groups
549
-        $orig_additional_qgs = $orig_event->get_many_related(
550
-            'Question_Group',
551
-            [['Event_Question_Group.EQG_additional' => true]]
552
-        );
553
-        if (! empty($orig_additional_qgs)) {
554
-            foreach ($orig_additional_qgs as $id => $obj) {
555
-                if ($obj instanceof EE_Question_Group) {
556
-                    $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
557
-                }
558
-            }
559
-        }
560
-
561
-        $new_event->save();
562
-
563
-        // k now that we have the new event saved we can loop through the datetimes and start adding relations.
564
-        $cloned_tickets = array();
565
-        foreach ($orig_datetimes as $orig_dtt) {
566
-            if (! $orig_dtt instanceof EE_Datetime) {
567
-                continue;
568
-            }
569
-            $new_dtt = clone $orig_dtt;
570
-            $orig_tkts = $orig_dtt->tickets();
571
-            // save new dtt then add to event
572
-            $new_dtt->set('DTT_ID', 0);
573
-            $new_dtt->set('DTT_sold', 0);
574
-            $new_dtt->set_reserved(0);
575
-            $new_dtt->save();
576
-            $new_event->_add_relation_to($new_dtt, 'Datetime');
577
-            $new_event->save();
578
-            // now let's get the ticket relations setup.
579
-            foreach ((array) $orig_tkts as $orig_tkt) {
580
-                // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
581
-                if (! $orig_tkt instanceof EE_Ticket) {
582
-                    continue;
583
-                }
584
-                // is this ticket archived?  If it is then let's skip
585
-                if ($orig_tkt->get('TKT_deleted')) {
586
-                    continue;
587
-                }
588
-                // does this original ticket already exist in the clone_tickets cache?
589
-                //  If so we'll just use the new ticket from it.
590
-                if (isset($cloned_tickets[ $orig_tkt->ID() ])) {
591
-                    $new_tkt = $cloned_tickets[ $orig_tkt->ID() ];
592
-                } else {
593
-                    $new_tkt = clone $orig_tkt;
594
-                    // get relations on the $orig_tkt that we need to setup.
595
-                    $orig_prices = $orig_tkt->prices();
596
-                    $new_tkt->set('TKT_ID', 0);
597
-                    $new_tkt->set('TKT_sold', 0);
598
-                    $new_tkt->set('TKT_reserved', 0);
599
-                    $new_tkt->save(); // make sure new ticket has ID.
600
-                    // price relations on new ticket need to be setup.
601
-                    foreach ($orig_prices as $orig_price) {
602
-                        $new_price = clone $orig_price;
603
-                        $new_price->set('PRC_ID', 0);
604
-                        $new_price->save();
605
-                        $new_tkt->_add_relation_to($new_price, 'Price');
606
-                        $new_tkt->save();
607
-                    }
608
-
609
-                    do_action(
610
-                        'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after',
611
-                        $orig_tkt,
612
-                        $new_tkt,
613
-                        $orig_prices,
614
-                        $orig_event,
615
-                        $orig_dtt,
616
-                        $new_dtt
617
-                    );
618
-                }
619
-                // k now we can add the new ticket as a relation to the new datetime
620
-                // and make sure its added to our cached $cloned_tickets array
621
-                // for use with later datetimes that have the same ticket.
622
-                $new_dtt->_add_relation_to($new_tkt, 'Ticket');
623
-                $new_dtt->save();
624
-                $cloned_tickets[ $orig_tkt->ID() ] = $new_tkt;
625
-            }
626
-        }
627
-        // clone taxonomy information
628
-        $taxonomies_to_clone_with = apply_filters(
629
-            'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
630
-            array('espresso_event_categories', 'espresso_event_type', 'post_tag')
631
-        );
632
-        // get terms for original event (notice)
633
-        $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
634
-        // loop through terms and add them to new event.
635
-        foreach ($orig_terms as $term) {
636
-            wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
637
-        }
638
-
639
-        // duplicate other core WP_Post items for this event.
640
-        // post thumbnail (feature image).
641
-        $feature_image_id = get_post_thumbnail_id($orig_event->ID());
642
-        if ($feature_image_id) {
643
-            update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id);
644
-        }
645
-
646
-        // duplicate page_template setting
647
-        $page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true);
648
-        if ($page_template) {
649
-            update_post_meta($new_event->ID(), '_wp_page_template', $page_template);
650
-        }
651
-
652
-        do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
653
-        // now let's redirect to the edit page for this duplicated event if we have a new event id.
654
-        if ($new_event->ID()) {
655
-            $redirect_args = array(
656
-                'post'   => $new_event->ID(),
657
-                'action' => 'edit',
658
-            );
659
-            EE_Error::add_success(
660
-                esc_html__(
661
-                    'Event successfully duplicated.  Please review the details below and make any necessary edits',
662
-                    'event_espresso'
663
-                )
664
-            );
665
-        } else {
666
-            $redirect_args = array(
667
-                'action' => 'default',
668
-            );
669
-            EE_Error::add_error(
670
-                esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
671
-                __FILE__,
672
-                __FUNCTION__,
673
-                __LINE__
674
-            );
675
-        }
676
-        $this->_redirect_after_action(false, '', '', $redirect_args, true);
677
-    }
678
-
679
-
680
-    /**
681
-     * Generates output for the import page.
682
-     *
683
-     * @throws DomainException
684
-     */
685
-    protected function _import_page()
686
-    {
687
-        $title = esc_html__('Import', 'event_espresso');
688
-        $intro = esc_html__(
689
-            'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
690
-            'event_espresso'
691
-        );
692
-        $form_url = EVENTS_ADMIN_URL;
693
-        $action = 'import_events';
694
-        $type = 'csv';
695
-        $this->_template_args['form'] = EE_Import::instance()->upload_form(
696
-            $title,
697
-            $intro,
698
-            $form_url,
699
-            $action,
700
-            $type
701
-        );
702
-        $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce(
703
-            array('action' => 'sample_export_file'),
704
-            $this->_admin_base_url
705
-        );
706
-        $content = EEH_Template::display_template(
707
-            EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
708
-            $this->_template_args,
709
-            true
710
-        );
711
-        $this->_template_args['admin_page_content'] = $content;
712
-        $this->display_admin_page_with_sidebar();
713
-    }
714
-
715
-
716
-    /**
717
-     * _import_events
718
-     * This handles displaying the screen and running imports for importing events.
719
-     *
720
-     * @return void
721
-     */
722
-    protected function _import_events()
723
-    {
724
-        require_once(EE_CLASSES . 'EE_Import.class.php');
725
-        $success = EE_Import::instance()->import();
726
-        $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true);
727
-    }
728
-
729
-
730
-    /**
731
-     * _events_export
732
-     * Will export all (or just the given event) to a Excel compatible file.
733
-     *
734
-     * @access protected
735
-     * @return void
736
-     */
737
-    protected function _events_export()
738
-    {
739
-        if (isset($this->_req_data['EVT_ID'])) {
740
-            $event_ids = $this->_req_data['EVT_ID'];
741
-        } elseif (isset($this->_req_data['EVT_IDs'])) {
742
-            $event_ids = $this->_req_data['EVT_IDs'];
743
-        } else {
744
-            $event_ids = null;
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' => 'all_event_data',
750
-            'EVT_ID' => $event_ids,
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
-     * handle category exports()
763
-     *
764
-     * @return void
765
-     */
766
-    protected function _categories_export()
767
-    {
768
-        // todo: I don't like doing this but it'll do until we modify EE_Export Class.
769
-        $new_request_args = array(
770
-            'export'       => 'report',
771
-            'action'       => 'categories',
772
-            'category_ids' => $this->_req_data['EVT_CAT_ID'],
773
-        );
774
-        $this->_req_data = array_merge($this->_req_data, $new_request_args);
775
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
776
-            require_once(EE_CLASSES . 'EE_Export.class.php');
777
-            $EE_Export = EE_Export::instance($this->_req_data);
778
-            $EE_Export->export();
779
-        }
780
-    }
781
-
782
-
783
-    /**
784
-     * Creates a sample CSV file for importing
785
-     */
786
-    protected function _sample_export_file()
787
-    {
788
-        // require_once(EE_CLASSES . 'EE_Export.class.php');
789
-        EE_Export::instance()->export_sample();
790
-    }
791
-
792
-
793
-    /*************        Template Settings        *************/
794
-    /**
795
-     * Generates template settings page output
796
-     *
797
-     * @throws DomainException
798
-     * @throws EE_Error
799
-     */
800
-    protected function _template_settings()
801
-    {
802
-        $this->_template_args['values'] = $this->_yes_no_values;
803
-        /**
804
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
805
-         * from General_Settings_Admin_Page to here.
806
-         */
807
-        $this->_template_args = apply_filters(
808
-            'FHEE__General_Settings_Admin_Page__template_settings__template_args',
809
-            $this->_template_args
810
-        );
811
-        $this->_set_add_edit_form_tags('update_template_settings');
812
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
813
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
814
-            EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
815
-            $this->_template_args,
816
-            true
817
-        );
818
-        $this->display_admin_page_with_sidebar();
819
-    }
820
-
821
-
822
-    /**
823
-     * Handler for updating template settings.
824
-     *
825
-     * @throws InvalidInterfaceException
826
-     * @throws InvalidDataTypeException
827
-     * @throws InvalidArgumentException
828
-     */
829
-    protected function _update_template_settings()
830
-    {
831
-        /**
832
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
833
-         * from General_Settings_Admin_Page to here.
834
-         */
835
-        EE_Registry::instance()->CFG->template_settings = apply_filters(
836
-            'FHEE__General_Settings_Admin_Page__update_template_settings__data',
837
-            EE_Registry::instance()->CFG->template_settings,
838
-            $this->_req_data
839
-        );
840
-        // update custom post type slugs and detect if we need to flush rewrite rules
841
-        $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug;
842
-        EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug'])
843
-            ? EE_Registry::instance()->CFG->core->event_cpt_slug
844
-            : EEH_URL::slugify($this->_req_data['event_cpt_slug'], 'events');
845
-        $what = 'Template Settings';
846
-        $success = $this->_update_espresso_configuration(
847
-            $what,
848
-            EE_Registry::instance()->CFG->template_settings,
849
-            __FILE__,
850
-            __FUNCTION__,
851
-            __LINE__
852
-        );
853
-        if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) {
854
-            /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
855
-            $rewrite_rules = LoaderFactory::getLoader()->getShared(
856
-                'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
857
-            );
858
-            $rewrite_rules->flush();
859
-        }
860
-        $this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings'));
861
-    }
862
-
863
-
864
-    /**
865
-     * _premium_event_editor_meta_boxes
866
-     * add all metaboxes related to the event_editor
867
-     *
868
-     * @access protected
869
-     * @return void
870
-     * @throws EE_Error
871
-     */
872
-    protected function _premium_event_editor_meta_boxes()
873
-    {
874
-        $this->verify_cpt_object();
875
-        add_meta_box(
876
-            'espresso_event_editor_event_options',
877
-            esc_html__('Event Registration Options', 'event_espresso'),
878
-            array($this, 'registration_options_meta_box'),
879
-            $this->page_slug,
880
-            'side',
881
-            'core'
882
-        );
883
-    }
884
-
885
-
886
-    /**
887
-     * override caf metabox
888
-     *
889
-     * @return void
890
-     * @throws DomainException
891
-     */
892
-    public function registration_options_meta_box()
893
-    {
894
-        $yes_no_values = array(
895
-            array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
896
-            array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
897
-        );
898
-        $default_reg_status_values = EEM_Registration::reg_status_array(
899
-            array(
900
-                EEM_Registration::status_id_cancelled,
901
-                EEM_Registration::status_id_declined,
902
-                EEM_Registration::status_id_incomplete,
903
-                EEM_Registration::status_id_wait_list,
904
-            ),
905
-            true
906
-        );
907
-        $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);
908
-        $template_args['_event'] = $this->_cpt_model_obj;
909
-        $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
910
-        $template_args['default_registration_status'] = EEH_Form_Fields::select_input(
911
-            'default_reg_status',
912
-            $default_reg_status_values,
913
-            $this->_cpt_model_obj->default_registration_status()
914
-        );
915
-        $template_args['display_description'] = EEH_Form_Fields::select_input(
916
-            'display_desc',
917
-            $yes_no_values,
918
-            $this->_cpt_model_obj->display_description()
919
-        );
920
-        $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(
921
-            'display_ticket_selector',
922
-            $yes_no_values,
923
-            $this->_cpt_model_obj->display_ticket_selector(),
924
-            '',
925
-            '',
926
-            false
927
-        );
928
-        $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
929
-            'EVT_default_registration_status',
930
-            $default_reg_status_values,
931
-            $this->_cpt_model_obj->default_registration_status()
932
-        );
933
-        $template_args['additional_registration_options'] = apply_filters(
934
-            'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
935
-            '',
936
-            $template_args,
937
-            $yes_no_values,
938
-            $default_reg_status_values
939
-        );
940
-        EEH_Template::display_template(
941
-            EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
942
-            $template_args
943
-        );
944
-    }
945
-
946
-
947
-
948
-    /**
949
-     * wp_list_table_mods for caf
950
-     * ============================
951
-     */
952
-    /**
953
-     * hook into list table filters and provide filters for caffeinated list table
954
-     *
955
-     * @param  array $old_filters    any existing filters present
956
-     * @param  array $list_table_obj the list table object
957
-     * @return array                  new filters
958
-     */
959
-    public function list_table_filters($old_filters, $list_table_obj)
960
-    {
961
-        $filters = array();
962
-        // first month/year filters
963
-        $filters[] = $this->espresso_event_months_dropdown();
964
-        $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
965
-        // active status dropdown
966
-        if ($status !== 'draft') {
967
-            $filters[] = $this->active_status_dropdown(
968
-                isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : ''
969
-            );
970
-        }
971
-        // category filter
972
-        $filters[] = $this->category_dropdown();
973
-        return array_merge($old_filters, $filters);
974
-    }
975
-
976
-
977
-    /**
978
-     * espresso_event_months_dropdown
979
-     *
980
-     * @access public
981
-     * @return string                dropdown listing month/year selections for events.
982
-     */
983
-    public function espresso_event_months_dropdown()
984
-    {
985
-        // what we need to do is get all PRIMARY datetimes for all events to filter on.
986
-        // Note we need to include any other filters that are set!
987
-        $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
988
-        // categories?
989
-        $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
990
-            ? $this->_req_data['EVT_CAT']
991
-            : null;
992
-        // active status?
993
-        $active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null;
994
-        $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
995
-        return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status);
996
-    }
997
-
998
-
999
-    /**
1000
-     * returns a list of "active" statuses on the event
1001
-     *
1002
-     * @param  string $current_value whatever the current active status is
1003
-     * @return string
1004
-     */
1005
-    public function active_status_dropdown($current_value = '')
1006
-    {
1007
-        $select_name = 'active_status';
1008
-        $values = array(
1009
-            'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
1010
-            'active'   => esc_html__('Active', 'event_espresso'),
1011
-            'upcoming' => esc_html__('Upcoming', 'event_espresso'),
1012
-            'expired'  => esc_html__('Expired', 'event_espresso'),
1013
-            'inactive' => esc_html__('Inactive', 'event_espresso'),
1014
-        );
1015
-        $id = 'id="espresso-active-status-dropdown-filter"';
1016
-        $class = 'wide';
1017
-        return EEH_Form_Fields::select_input($select_name, $values, $current_value, $id, $class);
1018
-    }
1019
-
1020
-
1021
-    /**
1022
-     * output a dropdown of the categories for the category filter on the event admin list table
1023
-     *
1024
-     * @access  public
1025
-     * @return string html
1026
-     */
1027
-    public function category_dropdown()
1028
-    {
1029
-        $cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
1030
-        return EEH_Form_Fields::generate_event_category_dropdown($cur_cat);
1031
-    }
1032
-
1033
-
1034
-    /**
1035
-     * get total number of events today
1036
-     *
1037
-     * @access public
1038
-     * @return int
1039
-     * @throws EE_Error
1040
-     */
1041
-    public function total_events_today()
1042
-    {
1043
-        $start = EEM_Datetime::instance()->convert_datetime_for_query(
1044
-            'DTT_EVT_start',
1045
-            date('Y-m-d') . ' 00:00:00',
1046
-            'Y-m-d H:i:s',
1047
-            'UTC'
1048
-        );
1049
-        $end = EEM_Datetime::instance()->convert_datetime_for_query(
1050
-            'DTT_EVT_start',
1051
-            date('Y-m-d') . ' 23:59:59',
1052
-            'Y-m-d H:i:s',
1053
-            'UTC'
1054
-        );
1055
-        $where = array(
1056
-            'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1057
-        );
1058
-        $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1059
-        return $count;
1060
-    }
1061
-
1062
-
1063
-    /**
1064
-     * get total number of events this month
1065
-     *
1066
-     * @access public
1067
-     * @return int
1068
-     * @throws EE_Error
1069
-     */
1070
-    public function total_events_this_month()
1071
-    {
1072
-        // Dates
1073
-        $this_year_r = date('Y');
1074
-        $this_month_r = date('m');
1075
-        $days_this_month = date('t');
1076
-        $start = EEM_Datetime::instance()->convert_datetime_for_query(
1077
-            'DTT_EVT_start',
1078
-            $this_year_r . '-' . $this_month_r . '-01 00:00:00',
1079
-            'Y-m-d H:i:s',
1080
-            'UTC'
1081
-        );
1082
-        $end = EEM_Datetime::instance()->convert_datetime_for_query(
1083
-            'DTT_EVT_start',
1084
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1085
-            'Y-m-d H:i:s',
1086
-            'UTC'
1087
-        );
1088
-        $where = array(
1089
-            'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1090
-        );
1091
-        $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1092
-        return $count;
1093
-    }
1094
-
1095
-
1096
-    /** DEFAULT TICKETS STUFF **/
1097
-
1098
-    /**
1099
-     * Output default tickets list table view.
1100
-     */
1101
-    public function _tickets_overview_list_table()
1102
-    {
1103
-        $this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1104
-        $this->display_admin_list_table_page_with_no_sidebar();
1105
-    }
1106
-
1107
-
1108
-    /**
1109
-     * @param int  $per_page
1110
-     * @param bool $count
1111
-     * @param bool $trashed
1112
-     * @return \EE_Soft_Delete_Base_Class[]|int
1113
-     */
1114
-    public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1115
-    {
1116
-        $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby'];
1117
-        $order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order'];
1118
-        switch ($orderby) {
1119
-            case 'TKT_name':
1120
-                $orderby = array('TKT_name' => $order);
1121
-                break;
1122
-            case 'TKT_price':
1123
-                $orderby = array('TKT_price' => $order);
1124
-                break;
1125
-            case 'TKT_uses':
1126
-                $orderby = array('TKT_uses' => $order);
1127
-                break;
1128
-            case 'TKT_min':
1129
-                $orderby = array('TKT_min' => $order);
1130
-                break;
1131
-            case 'TKT_max':
1132
-                $orderby = array('TKT_max' => $order);
1133
-                break;
1134
-            case 'TKT_qty':
1135
-                $orderby = array('TKT_qty' => $order);
1136
-                break;
1137
-        }
1138
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
1139
-            ? $this->_req_data['paged']
1140
-            : 1;
1141
-        $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
1142
-            ? $this->_req_data['perpage']
1143
-            : $per_page;
1144
-        $_where = array(
1145
-            'TKT_is_default' => 1,
1146
-            'TKT_deleted'    => $trashed,
1147
-        );
1148
-        $offset = ($current_page - 1) * $per_page;
1149
-        $limit = array($offset, $per_page);
1150
-        if (isset($this->_req_data['s'])) {
1151
-            $sstr = '%' . $this->_req_data['s'] . '%';
1152
-            $_where['OR'] = array(
1153
-                'TKT_name'        => array('LIKE', $sstr),
1154
-                'TKT_description' => array('LIKE', $sstr),
1155
-            );
1156
-        }
1157
-        $query_params = array(
1158
-            $_where,
1159
-            'order_by' => $orderby,
1160
-            'limit'    => $limit,
1161
-            'group_by' => 'TKT_ID',
1162
-        );
1163
-        if ($count) {
1164
-            return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where));
1165
-        } else {
1166
-            return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params);
1167
-        }
1168
-    }
1169
-
1170
-
1171
-    /**
1172
-     * @param bool $trash
1173
-     * @throws EE_Error
1174
-     */
1175
-    protected function _trash_or_restore_ticket($trash = false)
1176
-    {
1177
-        $success = 1;
1178
-        $TKT = EEM_Ticket::instance();
1179
-        // checkboxes?
1180
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1181
-            // if array has more than one element then success message should be plural
1182
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1183
-            // cycle thru the boxes
1184
-            while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1185
-                if ($trash) {
1186
-                    if (! $TKT->delete_by_ID($TKT_ID)) {
1187
-                        $success = 0;
1188
-                    }
1189
-                } else {
1190
-                    if (! $TKT->restore_by_ID($TKT_ID)) {
1191
-                        $success = 0;
1192
-                    }
1193
-                }
1194
-            }
1195
-        } else {
1196
-            // grab single id and trash
1197
-            $TKT_ID = absint($this->_req_data['TKT_ID']);
1198
-            if ($trash) {
1199
-                if (! $TKT->delete_by_ID($TKT_ID)) {
1200
-                    $success = 0;
1201
-                }
1202
-            } else {
1203
-                if (! $TKT->restore_by_ID($TKT_ID)) {
1204
-                    $success = 0;
1205
-                }
1206
-            }
1207
-        }
1208
-        $action_desc = $trash ? 'moved to the trash' : 'restored';
1209
-        $query_args = array(
1210
-            'action' => 'ticket_list_table',
1211
-            'status' => $trash ? '' : 'trashed',
1212
-        );
1213
-        $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1214
-    }
1215
-
1216
-
1217
-    /**
1218
-     * Handles trashing default ticket.
1219
-     */
1220
-    protected function _delete_ticket()
1221
-    {
1222
-        $success = 1;
1223
-        // checkboxes?
1224
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1225
-            // if array has more than one element then success message should be plural
1226
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1227
-            // cycle thru the boxes
1228
-            while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1229
-                // delete
1230
-                if (! $this->_delete_the_ticket($TKT_ID)) {
1231
-                    $success = 0;
1232
-                }
1233
-            }
1234
-        } else {
1235
-            // grab single id and trash
1236
-            $TKT_ID = absint($this->_req_data['TKT_ID']);
1237
-            if (! $this->_delete_the_ticket($TKT_ID)) {
1238
-                $success = 0;
1239
-            }
1240
-        }
1241
-        $action_desc = 'deleted';
1242
-        $query_args = array(
1243
-            'action' => 'ticket_list_table',
1244
-            'status' => 'trashed',
1245
-        );
1246
-        // fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1247
-        if (EEM_Ticket::instance()->count_deleted_and_undeleted(
1248
-            array(array('TKT_is_default' => 1)),
1249
-            'TKT_ID',
1250
-            true
1251
-        )
1252
-        ) {
1253
-            $query_args = array();
1254
-        }
1255
-        $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1256
-    }
1257
-
1258
-
1259
-    /**
1260
-     * @param int $TKT_ID
1261
-     * @return bool|int
1262
-     * @throws EE_Error
1263
-     */
1264
-    protected function _delete_the_ticket($TKT_ID)
1265
-    {
1266
-        $tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1267
-        $tkt->_remove_relations('Datetime');
1268
-        // delete all related prices first
1269
-        $tkt->delete_related_permanently('Price');
1270
-        return $tkt->delete_permanently();
1271
-    }
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
+	/**
36
+	 * Sets routes.
37
+	 */
38
+	protected function _extend_page_config()
39
+	{
40
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
41
+		// is there a evt_id in the request?
42
+		$evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
43
+			? $this->_req_data['EVT_ID']
44
+			: 0;
45
+		$evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
46
+		// tkt_id?
47
+		$tkt_id = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID'])
48
+			? $this->_req_data['TKT_ID']
49
+			: 0;
50
+		$new_page_routes = array(
51
+			'duplicate_event'          => array(
52
+				'func'       => '_duplicate_event',
53
+				'capability' => 'ee_edit_event',
54
+				'obj_id'     => $evt_id,
55
+				'noheader'   => true,
56
+			),
57
+			'ticket_list_table'        => array(
58
+				'func'       => '_tickets_overview_list_table',
59
+				'capability' => 'ee_read_default_tickets',
60
+			),
61
+			'trash_ticket'             => array(
62
+				'func'       => '_trash_or_restore_ticket',
63
+				'capability' => 'ee_delete_default_ticket',
64
+				'obj_id'     => $tkt_id,
65
+				'noheader'   => true,
66
+				'args'       => array('trash' => true),
67
+			),
68
+			'trash_tickets'            => array(
69
+				'func'       => '_trash_or_restore_ticket',
70
+				'capability' => 'ee_delete_default_tickets',
71
+				'noheader'   => true,
72
+				'args'       => array('trash' => true),
73
+			),
74
+			'restore_ticket'           => array(
75
+				'func'       => '_trash_or_restore_ticket',
76
+				'capability' => 'ee_delete_default_ticket',
77
+				'obj_id'     => $tkt_id,
78
+				'noheader'   => true,
79
+			),
80
+			'restore_tickets'          => array(
81
+				'func'       => '_trash_or_restore_ticket',
82
+				'capability' => 'ee_delete_default_tickets',
83
+				'noheader'   => true,
84
+			),
85
+			'delete_ticket'            => array(
86
+				'func'       => '_delete_ticket',
87
+				'capability' => 'ee_delete_default_ticket',
88
+				'obj_id'     => $tkt_id,
89
+				'noheader'   => true,
90
+			),
91
+			'delete_tickets'           => array(
92
+				'func'       => '_delete_ticket',
93
+				'capability' => 'ee_delete_default_tickets',
94
+				'noheader'   => true,
95
+			),
96
+			'import_page'              => array(
97
+				'func'       => '_import_page',
98
+				'capability' => 'import',
99
+			),
100
+			'import'                   => array(
101
+				'func'       => '_import_events',
102
+				'capability' => 'import',
103
+				'noheader'   => true,
104
+			),
105
+			'import_events'            => array(
106
+				'func'       => '_import_events',
107
+				'capability' => 'import',
108
+				'noheader'   => true,
109
+			),
110
+			'export_events'            => array(
111
+				'func'       => '_events_export',
112
+				'capability' => 'export',
113
+				'noheader'   => true,
114
+			),
115
+			'export_categories'        => array(
116
+				'func'       => '_categories_export',
117
+				'capability' => 'export',
118
+				'noheader'   => true,
119
+			),
120
+			'sample_export_file'       => array(
121
+				'func'       => '_sample_export_file',
122
+				'capability' => 'export',
123
+				'noheader'   => true,
124
+			),
125
+			'update_template_settings' => array(
126
+				'func'       => '_update_template_settings',
127
+				'capability' => 'manage_options',
128
+				'noheader'   => true,
129
+			),
130
+		);
131
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
132
+		// partial route/config override
133
+		$this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes;
134
+		$this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes';
135
+		$this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips';
136
+		$this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips';
137
+		$this->_page_config['edit']['metaboxes'][] = '_premium_event_editor_meta_boxes';
138
+		$this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table';
139
+		// add tickets tab but only if there are more than one default ticket!
140
+		$tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
141
+			array(array('TKT_is_default' => 1)),
142
+			'TKT_ID',
143
+			true
144
+		);
145
+		if ($tkt_count > 1) {
146
+			$new_page_config = array(
147
+				'ticket_list_table' => array(
148
+					'nav'           => array(
149
+						'label' => esc_html__('Default Tickets', 'event_espresso'),
150
+						'order' => 60,
151
+					),
152
+					'list_table'    => 'Tickets_List_Table',
153
+					'require_nonce' => false,
154
+				),
155
+			);
156
+		}
157
+		// template settings
158
+		$new_page_config['template_settings'] = array(
159
+			'nav'           => array(
160
+				'label' => esc_html__('Templates', 'event_espresso'),
161
+				'order' => 30,
162
+			),
163
+			'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
164
+			'help_tabs'     => array(
165
+				'general_settings_templates_help_tab' => array(
166
+					'title'    => esc_html__('Templates', 'event_espresso'),
167
+					'filename' => 'general_settings_templates',
168
+				),
169
+			),
170
+			'help_tour'     => array('Templates_Help_Tour'),
171
+			'require_nonce' => false,
172
+		);
173
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
174
+		// add filters and actions
175
+		// modifying _views
176
+		add_filter(
177
+			'FHEE_event_datetime_metabox_add_additional_date_time_template',
178
+			array($this, 'add_additional_datetime_button'),
179
+			10,
180
+			2
181
+		);
182
+		add_filter(
183
+			'FHEE_event_datetime_metabox_clone_button_template',
184
+			array($this, 'add_datetime_clone_button'),
185
+			10,
186
+			2
187
+		);
188
+		add_filter(
189
+			'FHEE_event_datetime_metabox_timezones_template',
190
+			array($this, 'datetime_timezones_template'),
191
+			10,
192
+			2
193
+		);
194
+		// filters for event list table
195
+		add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2);
196
+		add_filter(
197
+			'FHEE__Events_Admin_List_Table__column_actions__action_links',
198
+			array($this, 'extra_list_table_actions'),
199
+			10,
200
+			2
201
+		);
202
+		// legend item
203
+		add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items'));
204
+		add_action('admin_init', array($this, 'admin_init'));
205
+	}
206
+
207
+
208
+	/**
209
+	 * admin_init
210
+	 */
211
+	public function admin_init()
212
+	{
213
+		EE_Registry::$i18n_js_strings = array_merge(
214
+			EE_Registry::$i18n_js_strings,
215
+			array(
216
+				'image_confirm'          => esc_html__(
217
+					'Do you really want to delete this image? Please remember to update your event to complete the removal.',
218
+					'event_espresso'
219
+				),
220
+				'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
221
+				'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
222
+				'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
223
+				'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
224
+				'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
225
+			)
226
+		);
227
+	}
228
+
229
+
230
+	/**
231
+	 * Add per page screen options to the default ticket list table view.
232
+	 */
233
+	protected function _add_screen_options_ticket_list_table()
234
+	{
235
+		$this->_per_page_screen_option();
236
+	}
237
+
238
+
239
+	/**
240
+	 * @param string $return
241
+	 * @param int    $id
242
+	 * @param string $new_title
243
+	 * @param string $new_slug
244
+	 * @return string
245
+	 */
246
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
247
+	{
248
+		$return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
249
+		// make sure this is only when editing
250
+		if (! empty($id)) {
251
+			$href = EE_Admin_Page::add_query_args_and_nonce(
252
+				array('action' => 'duplicate_event', 'EVT_ID' => $id),
253
+				$this->_admin_base_url
254
+			);
255
+			$title = esc_attr__('Duplicate Event', 'event_espresso');
256
+			$return .= '<a href="'
257
+					   . $href
258
+					   . '" title="'
259
+					   . $title
260
+					   . '" id="ee-duplicate-event-button" class="button button-small"  value="duplicate_event">'
261
+					   . $title
262
+					   . '</a>';
263
+		}
264
+		return $return;
265
+	}
266
+
267
+
268
+	/**
269
+	 * Set the list table views for the default ticket list table view.
270
+	 */
271
+	public function _set_list_table_views_ticket_list_table()
272
+	{
273
+		$this->_views = array(
274
+			'all'     => array(
275
+				'slug'        => 'all',
276
+				'label'       => esc_html__('All', 'event_espresso'),
277
+				'count'       => 0,
278
+				'bulk_action' => array(
279
+					'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
280
+				),
281
+			),
282
+			'trashed' => array(
283
+				'slug'        => 'trashed',
284
+				'label'       => esc_html__('Trash', 'event_espresso'),
285
+				'count'       => 0,
286
+				'bulk_action' => array(
287
+					'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
288
+					'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
289
+				),
290
+			),
291
+		);
292
+	}
293
+
294
+
295
+	/**
296
+	 * Enqueue scripts and styles for the event editor.
297
+	 */
298
+	public function load_scripts_styles_edit()
299
+	{
300
+		wp_register_script(
301
+			'ee-event-editor-heartbeat',
302
+			EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
303
+			array('ee_admin_js', 'heartbeat'),
304
+			EVENT_ESPRESSO_VERSION,
305
+			true
306
+		);
307
+		wp_enqueue_script('ee-accounting');
308
+		// styles
309
+		wp_enqueue_style('espresso-ui-theme');
310
+		wp_enqueue_script('event_editor_js');
311
+		wp_enqueue_script('ee-event-editor-heartbeat');
312
+	}
313
+
314
+
315
+	/**
316
+	 * Returns template for the additional datetime.
317
+	 *
318
+	 * @param $template
319
+	 * @param $template_args
320
+	 * @return mixed
321
+	 * @throws DomainException
322
+	 */
323
+	public function add_additional_datetime_button($template, $template_args)
324
+	{
325
+		return EEH_Template::display_template(
326
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
327
+			$template_args,
328
+			true
329
+		);
330
+	}
331
+
332
+
333
+	/**
334
+	 * Returns the template for cloning a datetime.
335
+	 *
336
+	 * @param $template
337
+	 * @param $template_args
338
+	 * @return mixed
339
+	 * @throws DomainException
340
+	 */
341
+	public function add_datetime_clone_button($template, $template_args)
342
+	{
343
+		return EEH_Template::display_template(
344
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
345
+			$template_args,
346
+			true
347
+		);
348
+	}
349
+
350
+
351
+	/**
352
+	 * Returns the template for datetime timezones.
353
+	 *
354
+	 * @param $template
355
+	 * @param $template_args
356
+	 * @return mixed
357
+	 * @throws DomainException
358
+	 */
359
+	public function datetime_timezones_template($template, $template_args)
360
+	{
361
+		return EEH_Template::display_template(
362
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
363
+			$template_args,
364
+			true
365
+		);
366
+	}
367
+
368
+
369
+	/**
370
+	 * Sets the views for the default list table view.
371
+	 */
372
+	protected function _set_list_table_views_default()
373
+	{
374
+		parent::_set_list_table_views_default();
375
+		$new_views = array(
376
+			'today' => array(
377
+				'slug'        => 'today',
378
+				'label'       => esc_html__('Today', 'event_espresso'),
379
+				'count'       => $this->total_events_today(),
380
+				'bulk_action' => array(
381
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
382
+				),
383
+			),
384
+			'month' => array(
385
+				'slug'        => 'month',
386
+				'label'       => esc_html__('This Month', 'event_espresso'),
387
+				'count'       => $this->total_events_this_month(),
388
+				'bulk_action' => array(
389
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
390
+				),
391
+			),
392
+		);
393
+		$this->_views = array_merge($this->_views, $new_views);
394
+	}
395
+
396
+
397
+	/**
398
+	 * Returns the extra action links for the default list table view.
399
+	 *
400
+	 * @param array     $action_links
401
+	 * @param \EE_Event $event
402
+	 * @return array
403
+	 * @throws EE_Error
404
+	 */
405
+	public function extra_list_table_actions(array $action_links, \EE_Event $event)
406
+	{
407
+		if (EE_Registry::instance()->CAP->current_user_can(
408
+			'ee_read_registrations',
409
+			'espresso_registrations_reports',
410
+			$event->ID()
411
+		)
412
+		) {
413
+			$reports_query_args = array(
414
+				'action' => 'reports',
415
+				'EVT_ID' => $event->ID(),
416
+			);
417
+			$reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL);
418
+			$action_links[] = '<a href="'
419
+							  . $reports_link
420
+							  . '" title="'
421
+							  . esc_attr__('View Report', 'event_espresso')
422
+							  . '"><div class="dashicons dashicons-chart-bar"></div></a>'
423
+							  . "\n\t";
424
+		}
425
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
426
+			EE_Registry::instance()->load_helper('MSG_Template');
427
+			$action_links[] = EEH_MSG_Template::get_message_action_link(
428
+				'see_notifications_for',
429
+				null,
430
+				array('EVT_ID' => $event->ID())
431
+			);
432
+		}
433
+		return $action_links;
434
+	}
435
+
436
+
437
+	/**
438
+	 * @param $items
439
+	 * @return mixed
440
+	 */
441
+	public function additional_legend_items($items)
442
+	{
443
+		if (EE_Registry::instance()->CAP->current_user_can(
444
+			'ee_read_registrations',
445
+			'espresso_registrations_reports'
446
+		)
447
+		) {
448
+			$items['reports'] = array(
449
+				'class' => 'dashicons dashicons-chart-bar',
450
+				'desc'  => esc_html__('Event Reports', 'event_espresso'),
451
+			);
452
+		}
453
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
454
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
455
+			if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
456
+				$items['view_related_messages'] = array(
457
+					'class' => $related_for_icon['css_class'],
458
+					'desc'  => $related_for_icon['label'],
459
+				);
460
+			}
461
+		}
462
+		return $items;
463
+	}
464
+
465
+
466
+	/**
467
+	 * This is the callback method for the duplicate event route
468
+	 * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
469
+	 * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
470
+	 * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
471
+	 * After duplication the redirect is to the new event edit page.
472
+	 *
473
+	 * @return void
474
+	 * @access protected
475
+	 * @throws EE_Error If EE_Event is not available with given ID
476
+	 */
477
+	protected function _duplicate_event()
478
+	{
479
+		// first make sure the ID for the event is in the request.
480
+		//  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
481
+		if (! isset($this->_req_data['EVT_ID'])) {
482
+			EE_Error::add_error(
483
+				esc_html__(
484
+					'In order to duplicate an event an Event ID is required.  None was given.',
485
+					'event_espresso'
486
+				),
487
+				__FILE__,
488
+				__FUNCTION__,
489
+				__LINE__
490
+			);
491
+			$this->_redirect_after_action(false, '', '', array(), true);
492
+			return;
493
+		}
494
+		// k we've got EVT_ID so let's use that to get the event we'll duplicate
495
+		$orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
496
+		if (! $orig_event instanceof EE_Event) {
497
+			throw new EE_Error(
498
+				sprintf(
499
+					esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
500
+					$this->_req_data['EVT_ID']
501
+				)
502
+			);
503
+		}
504
+		// k now let's clone the $orig_event before getting relations
505
+		$new_event = clone $orig_event;
506
+		// original datetimes
507
+		$orig_datetimes = $orig_event->get_many_related('Datetime');
508
+		// other original relations
509
+		$orig_ven = $orig_event->get_many_related('Venue');
510
+		// reset the ID and modify other details to make it clear this is a dupe
511
+		$new_event->set('EVT_ID', 0);
512
+		$new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
513
+		$new_event->set('EVT_name', $new_name);
514
+		$new_event->set(
515
+			'EVT_slug',
516
+			wp_unique_post_slug(
517
+				sanitize_title($orig_event->name()),
518
+				0,
519
+				'publish',
520
+				'espresso_events',
521
+				0
522
+			)
523
+		);
524
+		$new_event->set('status', 'draft');
525
+		// duplicate discussion settings
526
+		$new_event->set('comment_status', $orig_event->get('comment_status'));
527
+		$new_event->set('ping_status', $orig_event->get('ping_status'));
528
+		// save the new event
529
+		$new_event->save();
530
+		// venues
531
+		foreach ($orig_ven as $ven) {
532
+			$new_event->_add_relation_to($ven, 'Venue');
533
+		}
534
+		$new_event->save();
535
+		// now we need to get the question group relations and handle that
536
+		// first primary question groups
537
+		$orig_primary_qgs = $orig_event->get_many_related(
538
+			'Question_Group',
539
+			[['Event_Question_Group.EQG_primary' => true]]
540
+		);
541
+		if (! empty($orig_primary_qgs)) {
542
+			foreach ($orig_primary_qgs as $id => $obj) {
543
+				if ($obj instanceof EE_Question_Group) {
544
+					$new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
545
+				}
546
+			}
547
+		}
548
+		// next additional attendee question groups
549
+		$orig_additional_qgs = $orig_event->get_many_related(
550
+			'Question_Group',
551
+			[['Event_Question_Group.EQG_additional' => true]]
552
+		);
553
+		if (! empty($orig_additional_qgs)) {
554
+			foreach ($orig_additional_qgs as $id => $obj) {
555
+				if ($obj instanceof EE_Question_Group) {
556
+					$new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
557
+				}
558
+			}
559
+		}
560
+
561
+		$new_event->save();
562
+
563
+		// k now that we have the new event saved we can loop through the datetimes and start adding relations.
564
+		$cloned_tickets = array();
565
+		foreach ($orig_datetimes as $orig_dtt) {
566
+			if (! $orig_dtt instanceof EE_Datetime) {
567
+				continue;
568
+			}
569
+			$new_dtt = clone $orig_dtt;
570
+			$orig_tkts = $orig_dtt->tickets();
571
+			// save new dtt then add to event
572
+			$new_dtt->set('DTT_ID', 0);
573
+			$new_dtt->set('DTT_sold', 0);
574
+			$new_dtt->set_reserved(0);
575
+			$new_dtt->save();
576
+			$new_event->_add_relation_to($new_dtt, 'Datetime');
577
+			$new_event->save();
578
+			// now let's get the ticket relations setup.
579
+			foreach ((array) $orig_tkts as $orig_tkt) {
580
+				// it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
581
+				if (! $orig_tkt instanceof EE_Ticket) {
582
+					continue;
583
+				}
584
+				// is this ticket archived?  If it is then let's skip
585
+				if ($orig_tkt->get('TKT_deleted')) {
586
+					continue;
587
+				}
588
+				// does this original ticket already exist in the clone_tickets cache?
589
+				//  If so we'll just use the new ticket from it.
590
+				if (isset($cloned_tickets[ $orig_tkt->ID() ])) {
591
+					$new_tkt = $cloned_tickets[ $orig_tkt->ID() ];
592
+				} else {
593
+					$new_tkt = clone $orig_tkt;
594
+					// get relations on the $orig_tkt that we need to setup.
595
+					$orig_prices = $orig_tkt->prices();
596
+					$new_tkt->set('TKT_ID', 0);
597
+					$new_tkt->set('TKT_sold', 0);
598
+					$new_tkt->set('TKT_reserved', 0);
599
+					$new_tkt->save(); // make sure new ticket has ID.
600
+					// price relations on new ticket need to be setup.
601
+					foreach ($orig_prices as $orig_price) {
602
+						$new_price = clone $orig_price;
603
+						$new_price->set('PRC_ID', 0);
604
+						$new_price->save();
605
+						$new_tkt->_add_relation_to($new_price, 'Price');
606
+						$new_tkt->save();
607
+					}
608
+
609
+					do_action(
610
+						'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after',
611
+						$orig_tkt,
612
+						$new_tkt,
613
+						$orig_prices,
614
+						$orig_event,
615
+						$orig_dtt,
616
+						$new_dtt
617
+					);
618
+				}
619
+				// k now we can add the new ticket as a relation to the new datetime
620
+				// and make sure its added to our cached $cloned_tickets array
621
+				// for use with later datetimes that have the same ticket.
622
+				$new_dtt->_add_relation_to($new_tkt, 'Ticket');
623
+				$new_dtt->save();
624
+				$cloned_tickets[ $orig_tkt->ID() ] = $new_tkt;
625
+			}
626
+		}
627
+		// clone taxonomy information
628
+		$taxonomies_to_clone_with = apply_filters(
629
+			'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
630
+			array('espresso_event_categories', 'espresso_event_type', 'post_tag')
631
+		);
632
+		// get terms for original event (notice)
633
+		$orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
634
+		// loop through terms and add them to new event.
635
+		foreach ($orig_terms as $term) {
636
+			wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
637
+		}
638
+
639
+		// duplicate other core WP_Post items for this event.
640
+		// post thumbnail (feature image).
641
+		$feature_image_id = get_post_thumbnail_id($orig_event->ID());
642
+		if ($feature_image_id) {
643
+			update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id);
644
+		}
645
+
646
+		// duplicate page_template setting
647
+		$page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true);
648
+		if ($page_template) {
649
+			update_post_meta($new_event->ID(), '_wp_page_template', $page_template);
650
+		}
651
+
652
+		do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
653
+		// now let's redirect to the edit page for this duplicated event if we have a new event id.
654
+		if ($new_event->ID()) {
655
+			$redirect_args = array(
656
+				'post'   => $new_event->ID(),
657
+				'action' => 'edit',
658
+			);
659
+			EE_Error::add_success(
660
+				esc_html__(
661
+					'Event successfully duplicated.  Please review the details below and make any necessary edits',
662
+					'event_espresso'
663
+				)
664
+			);
665
+		} else {
666
+			$redirect_args = array(
667
+				'action' => 'default',
668
+			);
669
+			EE_Error::add_error(
670
+				esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
671
+				__FILE__,
672
+				__FUNCTION__,
673
+				__LINE__
674
+			);
675
+		}
676
+		$this->_redirect_after_action(false, '', '', $redirect_args, true);
677
+	}
678
+
679
+
680
+	/**
681
+	 * Generates output for the import page.
682
+	 *
683
+	 * @throws DomainException
684
+	 */
685
+	protected function _import_page()
686
+	{
687
+		$title = esc_html__('Import', 'event_espresso');
688
+		$intro = esc_html__(
689
+			'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
690
+			'event_espresso'
691
+		);
692
+		$form_url = EVENTS_ADMIN_URL;
693
+		$action = 'import_events';
694
+		$type = 'csv';
695
+		$this->_template_args['form'] = EE_Import::instance()->upload_form(
696
+			$title,
697
+			$intro,
698
+			$form_url,
699
+			$action,
700
+			$type
701
+		);
702
+		$this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce(
703
+			array('action' => 'sample_export_file'),
704
+			$this->_admin_base_url
705
+		);
706
+		$content = EEH_Template::display_template(
707
+			EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
708
+			$this->_template_args,
709
+			true
710
+		);
711
+		$this->_template_args['admin_page_content'] = $content;
712
+		$this->display_admin_page_with_sidebar();
713
+	}
714
+
715
+
716
+	/**
717
+	 * _import_events
718
+	 * This handles displaying the screen and running imports for importing events.
719
+	 *
720
+	 * @return void
721
+	 */
722
+	protected function _import_events()
723
+	{
724
+		require_once(EE_CLASSES . 'EE_Import.class.php');
725
+		$success = EE_Import::instance()->import();
726
+		$this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true);
727
+	}
728
+
729
+
730
+	/**
731
+	 * _events_export
732
+	 * Will export all (or just the given event) to a Excel compatible file.
733
+	 *
734
+	 * @access protected
735
+	 * @return void
736
+	 */
737
+	protected function _events_export()
738
+	{
739
+		if (isset($this->_req_data['EVT_ID'])) {
740
+			$event_ids = $this->_req_data['EVT_ID'];
741
+		} elseif (isset($this->_req_data['EVT_IDs'])) {
742
+			$event_ids = $this->_req_data['EVT_IDs'];
743
+		} else {
744
+			$event_ids = null;
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' => 'all_event_data',
750
+			'EVT_ID' => $event_ids,
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
+	 * handle category exports()
763
+	 *
764
+	 * @return void
765
+	 */
766
+	protected function _categories_export()
767
+	{
768
+		// todo: I don't like doing this but it'll do until we modify EE_Export Class.
769
+		$new_request_args = array(
770
+			'export'       => 'report',
771
+			'action'       => 'categories',
772
+			'category_ids' => $this->_req_data['EVT_CAT_ID'],
773
+		);
774
+		$this->_req_data = array_merge($this->_req_data, $new_request_args);
775
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
776
+			require_once(EE_CLASSES . 'EE_Export.class.php');
777
+			$EE_Export = EE_Export::instance($this->_req_data);
778
+			$EE_Export->export();
779
+		}
780
+	}
781
+
782
+
783
+	/**
784
+	 * Creates a sample CSV file for importing
785
+	 */
786
+	protected function _sample_export_file()
787
+	{
788
+		// require_once(EE_CLASSES . 'EE_Export.class.php');
789
+		EE_Export::instance()->export_sample();
790
+	}
791
+
792
+
793
+	/*************        Template Settings        *************/
794
+	/**
795
+	 * Generates template settings page output
796
+	 *
797
+	 * @throws DomainException
798
+	 * @throws EE_Error
799
+	 */
800
+	protected function _template_settings()
801
+	{
802
+		$this->_template_args['values'] = $this->_yes_no_values;
803
+		/**
804
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
805
+		 * from General_Settings_Admin_Page to here.
806
+		 */
807
+		$this->_template_args = apply_filters(
808
+			'FHEE__General_Settings_Admin_Page__template_settings__template_args',
809
+			$this->_template_args
810
+		);
811
+		$this->_set_add_edit_form_tags('update_template_settings');
812
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
813
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
814
+			EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
815
+			$this->_template_args,
816
+			true
817
+		);
818
+		$this->display_admin_page_with_sidebar();
819
+	}
820
+
821
+
822
+	/**
823
+	 * Handler for updating template settings.
824
+	 *
825
+	 * @throws InvalidInterfaceException
826
+	 * @throws InvalidDataTypeException
827
+	 * @throws InvalidArgumentException
828
+	 */
829
+	protected function _update_template_settings()
830
+	{
831
+		/**
832
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
833
+		 * from General_Settings_Admin_Page to here.
834
+		 */
835
+		EE_Registry::instance()->CFG->template_settings = apply_filters(
836
+			'FHEE__General_Settings_Admin_Page__update_template_settings__data',
837
+			EE_Registry::instance()->CFG->template_settings,
838
+			$this->_req_data
839
+		);
840
+		// update custom post type slugs and detect if we need to flush rewrite rules
841
+		$old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug;
842
+		EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug'])
843
+			? EE_Registry::instance()->CFG->core->event_cpt_slug
844
+			: EEH_URL::slugify($this->_req_data['event_cpt_slug'], 'events');
845
+		$what = 'Template Settings';
846
+		$success = $this->_update_espresso_configuration(
847
+			$what,
848
+			EE_Registry::instance()->CFG->template_settings,
849
+			__FILE__,
850
+			__FUNCTION__,
851
+			__LINE__
852
+		);
853
+		if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) {
854
+			/** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
855
+			$rewrite_rules = LoaderFactory::getLoader()->getShared(
856
+				'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
857
+			);
858
+			$rewrite_rules->flush();
859
+		}
860
+		$this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings'));
861
+	}
862
+
863
+
864
+	/**
865
+	 * _premium_event_editor_meta_boxes
866
+	 * add all metaboxes related to the event_editor
867
+	 *
868
+	 * @access protected
869
+	 * @return void
870
+	 * @throws EE_Error
871
+	 */
872
+	protected function _premium_event_editor_meta_boxes()
873
+	{
874
+		$this->verify_cpt_object();
875
+		add_meta_box(
876
+			'espresso_event_editor_event_options',
877
+			esc_html__('Event Registration Options', 'event_espresso'),
878
+			array($this, 'registration_options_meta_box'),
879
+			$this->page_slug,
880
+			'side',
881
+			'core'
882
+		);
883
+	}
884
+
885
+
886
+	/**
887
+	 * override caf metabox
888
+	 *
889
+	 * @return void
890
+	 * @throws DomainException
891
+	 */
892
+	public function registration_options_meta_box()
893
+	{
894
+		$yes_no_values = array(
895
+			array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
896
+			array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
897
+		);
898
+		$default_reg_status_values = EEM_Registration::reg_status_array(
899
+			array(
900
+				EEM_Registration::status_id_cancelled,
901
+				EEM_Registration::status_id_declined,
902
+				EEM_Registration::status_id_incomplete,
903
+				EEM_Registration::status_id_wait_list,
904
+			),
905
+			true
906
+		);
907
+		$template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);
908
+		$template_args['_event'] = $this->_cpt_model_obj;
909
+		$template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
910
+		$template_args['default_registration_status'] = EEH_Form_Fields::select_input(
911
+			'default_reg_status',
912
+			$default_reg_status_values,
913
+			$this->_cpt_model_obj->default_registration_status()
914
+		);
915
+		$template_args['display_description'] = EEH_Form_Fields::select_input(
916
+			'display_desc',
917
+			$yes_no_values,
918
+			$this->_cpt_model_obj->display_description()
919
+		);
920
+		$template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(
921
+			'display_ticket_selector',
922
+			$yes_no_values,
923
+			$this->_cpt_model_obj->display_ticket_selector(),
924
+			'',
925
+			'',
926
+			false
927
+		);
928
+		$template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
929
+			'EVT_default_registration_status',
930
+			$default_reg_status_values,
931
+			$this->_cpt_model_obj->default_registration_status()
932
+		);
933
+		$template_args['additional_registration_options'] = apply_filters(
934
+			'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
935
+			'',
936
+			$template_args,
937
+			$yes_no_values,
938
+			$default_reg_status_values
939
+		);
940
+		EEH_Template::display_template(
941
+			EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
942
+			$template_args
943
+		);
944
+	}
945
+
946
+
947
+
948
+	/**
949
+	 * wp_list_table_mods for caf
950
+	 * ============================
951
+	 */
952
+	/**
953
+	 * hook into list table filters and provide filters for caffeinated list table
954
+	 *
955
+	 * @param  array $old_filters    any existing filters present
956
+	 * @param  array $list_table_obj the list table object
957
+	 * @return array                  new filters
958
+	 */
959
+	public function list_table_filters($old_filters, $list_table_obj)
960
+	{
961
+		$filters = array();
962
+		// first month/year filters
963
+		$filters[] = $this->espresso_event_months_dropdown();
964
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
965
+		// active status dropdown
966
+		if ($status !== 'draft') {
967
+			$filters[] = $this->active_status_dropdown(
968
+				isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : ''
969
+			);
970
+		}
971
+		// category filter
972
+		$filters[] = $this->category_dropdown();
973
+		return array_merge($old_filters, $filters);
974
+	}
975
+
976
+
977
+	/**
978
+	 * espresso_event_months_dropdown
979
+	 *
980
+	 * @access public
981
+	 * @return string                dropdown listing month/year selections for events.
982
+	 */
983
+	public function espresso_event_months_dropdown()
984
+	{
985
+		// what we need to do is get all PRIMARY datetimes for all events to filter on.
986
+		// Note we need to include any other filters that are set!
987
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
988
+		// categories?
989
+		$category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
990
+			? $this->_req_data['EVT_CAT']
991
+			: null;
992
+		// active status?
993
+		$active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null;
994
+		$cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
995
+		return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status);
996
+	}
997
+
998
+
999
+	/**
1000
+	 * returns a list of "active" statuses on the event
1001
+	 *
1002
+	 * @param  string $current_value whatever the current active status is
1003
+	 * @return string
1004
+	 */
1005
+	public function active_status_dropdown($current_value = '')
1006
+	{
1007
+		$select_name = 'active_status';
1008
+		$values = array(
1009
+			'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
1010
+			'active'   => esc_html__('Active', 'event_espresso'),
1011
+			'upcoming' => esc_html__('Upcoming', 'event_espresso'),
1012
+			'expired'  => esc_html__('Expired', 'event_espresso'),
1013
+			'inactive' => esc_html__('Inactive', 'event_espresso'),
1014
+		);
1015
+		$id = 'id="espresso-active-status-dropdown-filter"';
1016
+		$class = 'wide';
1017
+		return EEH_Form_Fields::select_input($select_name, $values, $current_value, $id, $class);
1018
+	}
1019
+
1020
+
1021
+	/**
1022
+	 * output a dropdown of the categories for the category filter on the event admin list table
1023
+	 *
1024
+	 * @access  public
1025
+	 * @return string html
1026
+	 */
1027
+	public function category_dropdown()
1028
+	{
1029
+		$cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
1030
+		return EEH_Form_Fields::generate_event_category_dropdown($cur_cat);
1031
+	}
1032
+
1033
+
1034
+	/**
1035
+	 * get total number of events today
1036
+	 *
1037
+	 * @access public
1038
+	 * @return int
1039
+	 * @throws EE_Error
1040
+	 */
1041
+	public function total_events_today()
1042
+	{
1043
+		$start = EEM_Datetime::instance()->convert_datetime_for_query(
1044
+			'DTT_EVT_start',
1045
+			date('Y-m-d') . ' 00:00:00',
1046
+			'Y-m-d H:i:s',
1047
+			'UTC'
1048
+		);
1049
+		$end = EEM_Datetime::instance()->convert_datetime_for_query(
1050
+			'DTT_EVT_start',
1051
+			date('Y-m-d') . ' 23:59:59',
1052
+			'Y-m-d H:i:s',
1053
+			'UTC'
1054
+		);
1055
+		$where = array(
1056
+			'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1057
+		);
1058
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1059
+		return $count;
1060
+	}
1061
+
1062
+
1063
+	/**
1064
+	 * get total number of events this month
1065
+	 *
1066
+	 * @access public
1067
+	 * @return int
1068
+	 * @throws EE_Error
1069
+	 */
1070
+	public function total_events_this_month()
1071
+	{
1072
+		// Dates
1073
+		$this_year_r = date('Y');
1074
+		$this_month_r = date('m');
1075
+		$days_this_month = date('t');
1076
+		$start = EEM_Datetime::instance()->convert_datetime_for_query(
1077
+			'DTT_EVT_start',
1078
+			$this_year_r . '-' . $this_month_r . '-01 00:00:00',
1079
+			'Y-m-d H:i:s',
1080
+			'UTC'
1081
+		);
1082
+		$end = EEM_Datetime::instance()->convert_datetime_for_query(
1083
+			'DTT_EVT_start',
1084
+			$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1085
+			'Y-m-d H:i:s',
1086
+			'UTC'
1087
+		);
1088
+		$where = array(
1089
+			'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1090
+		);
1091
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1092
+		return $count;
1093
+	}
1094
+
1095
+
1096
+	/** DEFAULT TICKETS STUFF **/
1097
+
1098
+	/**
1099
+	 * Output default tickets list table view.
1100
+	 */
1101
+	public function _tickets_overview_list_table()
1102
+	{
1103
+		$this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1104
+		$this->display_admin_list_table_page_with_no_sidebar();
1105
+	}
1106
+
1107
+
1108
+	/**
1109
+	 * @param int  $per_page
1110
+	 * @param bool $count
1111
+	 * @param bool $trashed
1112
+	 * @return \EE_Soft_Delete_Base_Class[]|int
1113
+	 */
1114
+	public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1115
+	{
1116
+		$orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby'];
1117
+		$order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order'];
1118
+		switch ($orderby) {
1119
+			case 'TKT_name':
1120
+				$orderby = array('TKT_name' => $order);
1121
+				break;
1122
+			case 'TKT_price':
1123
+				$orderby = array('TKT_price' => $order);
1124
+				break;
1125
+			case 'TKT_uses':
1126
+				$orderby = array('TKT_uses' => $order);
1127
+				break;
1128
+			case 'TKT_min':
1129
+				$orderby = array('TKT_min' => $order);
1130
+				break;
1131
+			case 'TKT_max':
1132
+				$orderby = array('TKT_max' => $order);
1133
+				break;
1134
+			case 'TKT_qty':
1135
+				$orderby = array('TKT_qty' => $order);
1136
+				break;
1137
+		}
1138
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
1139
+			? $this->_req_data['paged']
1140
+			: 1;
1141
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
1142
+			? $this->_req_data['perpage']
1143
+			: $per_page;
1144
+		$_where = array(
1145
+			'TKT_is_default' => 1,
1146
+			'TKT_deleted'    => $trashed,
1147
+		);
1148
+		$offset = ($current_page - 1) * $per_page;
1149
+		$limit = array($offset, $per_page);
1150
+		if (isset($this->_req_data['s'])) {
1151
+			$sstr = '%' . $this->_req_data['s'] . '%';
1152
+			$_where['OR'] = array(
1153
+				'TKT_name'        => array('LIKE', $sstr),
1154
+				'TKT_description' => array('LIKE', $sstr),
1155
+			);
1156
+		}
1157
+		$query_params = array(
1158
+			$_where,
1159
+			'order_by' => $orderby,
1160
+			'limit'    => $limit,
1161
+			'group_by' => 'TKT_ID',
1162
+		);
1163
+		if ($count) {
1164
+			return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where));
1165
+		} else {
1166
+			return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params);
1167
+		}
1168
+	}
1169
+
1170
+
1171
+	/**
1172
+	 * @param bool $trash
1173
+	 * @throws EE_Error
1174
+	 */
1175
+	protected function _trash_or_restore_ticket($trash = false)
1176
+	{
1177
+		$success = 1;
1178
+		$TKT = EEM_Ticket::instance();
1179
+		// checkboxes?
1180
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1181
+			// if array has more than one element then success message should be plural
1182
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1183
+			// cycle thru the boxes
1184
+			while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1185
+				if ($trash) {
1186
+					if (! $TKT->delete_by_ID($TKT_ID)) {
1187
+						$success = 0;
1188
+					}
1189
+				} else {
1190
+					if (! $TKT->restore_by_ID($TKT_ID)) {
1191
+						$success = 0;
1192
+					}
1193
+				}
1194
+			}
1195
+		} else {
1196
+			// grab single id and trash
1197
+			$TKT_ID = absint($this->_req_data['TKT_ID']);
1198
+			if ($trash) {
1199
+				if (! $TKT->delete_by_ID($TKT_ID)) {
1200
+					$success = 0;
1201
+				}
1202
+			} else {
1203
+				if (! $TKT->restore_by_ID($TKT_ID)) {
1204
+					$success = 0;
1205
+				}
1206
+			}
1207
+		}
1208
+		$action_desc = $trash ? 'moved to the trash' : 'restored';
1209
+		$query_args = array(
1210
+			'action' => 'ticket_list_table',
1211
+			'status' => $trash ? '' : 'trashed',
1212
+		);
1213
+		$this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1214
+	}
1215
+
1216
+
1217
+	/**
1218
+	 * Handles trashing default ticket.
1219
+	 */
1220
+	protected function _delete_ticket()
1221
+	{
1222
+		$success = 1;
1223
+		// checkboxes?
1224
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1225
+			// if array has more than one element then success message should be plural
1226
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1227
+			// cycle thru the boxes
1228
+			while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1229
+				// delete
1230
+				if (! $this->_delete_the_ticket($TKT_ID)) {
1231
+					$success = 0;
1232
+				}
1233
+			}
1234
+		} else {
1235
+			// grab single id and trash
1236
+			$TKT_ID = absint($this->_req_data['TKT_ID']);
1237
+			if (! $this->_delete_the_ticket($TKT_ID)) {
1238
+				$success = 0;
1239
+			}
1240
+		}
1241
+		$action_desc = 'deleted';
1242
+		$query_args = array(
1243
+			'action' => 'ticket_list_table',
1244
+			'status' => 'trashed',
1245
+		);
1246
+		// fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1247
+		if (EEM_Ticket::instance()->count_deleted_and_undeleted(
1248
+			array(array('TKT_is_default' => 1)),
1249
+			'TKT_ID',
1250
+			true
1251
+		)
1252
+		) {
1253
+			$query_args = array();
1254
+		}
1255
+		$this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1256
+	}
1257
+
1258
+
1259
+	/**
1260
+	 * @param int $TKT_ID
1261
+	 * @return bool|int
1262
+	 * @throws EE_Error
1263
+	 */
1264
+	protected function _delete_the_ticket($TKT_ID)
1265
+	{
1266
+		$tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1267
+		$tkt->_remove_relations('Datetime');
1268
+		// delete all related prices first
1269
+		$tkt->delete_related_permanently('Price');
1270
+		return $tkt->delete_permanently();
1271
+	}
1272 1272
 }
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
     public function __construct($routing = true)
25 25
     {
26 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/');
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 31
         }
32 32
     }
33 33
 
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      */
38 38
     protected function _extend_page_config()
39 39
     {
40
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
40
+        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'events';
41 41
         // is there a evt_id in the request?
42 42
         $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
43 43
             ? $this->_req_data['EVT_ID']
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
     {
248 248
         $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
249 249
         // make sure this is only when editing
250
-        if (! empty($id)) {
250
+        if ( ! empty($id)) {
251 251
             $href = EE_Admin_Page::add_query_args_and_nonce(
252 252
                 array('action' => 'duplicate_event', 'EVT_ID' => $id),
253 253
                 $this->_admin_base_url
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
     {
300 300
         wp_register_script(
301 301
             'ee-event-editor-heartbeat',
302
-            EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
302
+            EVENTS_CAF_ASSETS_URL.'event-editor-heartbeat.js',
303 303
             array('ee_admin_js', 'heartbeat'),
304 304
             EVENT_ESPRESSO_VERSION,
305 305
             true
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
     public function add_additional_datetime_button($template, $template_args)
324 324
     {
325 325
         return EEH_Template::display_template(
326
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
326
+            EVENTS_CAF_TEMPLATE_PATH.'event_datetime_add_additional_time.template.php',
327 327
             $template_args,
328 328
             true
329 329
         );
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
     public function add_datetime_clone_button($template, $template_args)
342 342
     {
343 343
         return EEH_Template::display_template(
344
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
344
+            EVENTS_CAF_TEMPLATE_PATH.'event_datetime_metabox_clone_button.template.php',
345 345
             $template_args,
346 346
             true
347 347
         );
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
     public function datetime_timezones_template($template, $template_args)
360 360
     {
361 361
         return EEH_Template::display_template(
362
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
362
+            EVENTS_CAF_TEMPLATE_PATH.'event_datetime_timezones.template.php',
363 363
             $template_args,
364 364
             true
365 365
         );
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
     {
479 479
         // first make sure the ID for the event is in the request.
480 480
         //  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
481
-        if (! isset($this->_req_data['EVT_ID'])) {
481
+        if ( ! isset($this->_req_data['EVT_ID'])) {
482 482
             EE_Error::add_error(
483 483
                 esc_html__(
484 484
                     'In order to duplicate an event an Event ID is required.  None was given.',
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
         }
494 494
         // k we've got EVT_ID so let's use that to get the event we'll duplicate
495 495
         $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
496
-        if (! $orig_event instanceof EE_Event) {
496
+        if ( ! $orig_event instanceof EE_Event) {
497 497
             throw new EE_Error(
498 498
                 sprintf(
499 499
                     esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
         $orig_ven = $orig_event->get_many_related('Venue');
510 510
         // reset the ID and modify other details to make it clear this is a dupe
511 511
         $new_event->set('EVT_ID', 0);
512
-        $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
512
+        $new_name = $new_event->name().' '.esc_html__('**DUPLICATE**', 'event_espresso');
513 513
         $new_event->set('EVT_name', $new_name);
514 514
         $new_event->set(
515 515
             'EVT_slug',
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
             'Question_Group',
539 539
             [['Event_Question_Group.EQG_primary' => true]]
540 540
         );
541
-        if (! empty($orig_primary_qgs)) {
541
+        if ( ! empty($orig_primary_qgs)) {
542 542
             foreach ($orig_primary_qgs as $id => $obj) {
543 543
                 if ($obj instanceof EE_Question_Group) {
544 544
                     $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
             'Question_Group',
551 551
             [['Event_Question_Group.EQG_additional' => true]]
552 552
         );
553
-        if (! empty($orig_additional_qgs)) {
553
+        if ( ! empty($orig_additional_qgs)) {
554 554
             foreach ($orig_additional_qgs as $id => $obj) {
555 555
                 if ($obj instanceof EE_Question_Group) {
556 556
                     $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
         // k now that we have the new event saved we can loop through the datetimes and start adding relations.
564 564
         $cloned_tickets = array();
565 565
         foreach ($orig_datetimes as $orig_dtt) {
566
-            if (! $orig_dtt instanceof EE_Datetime) {
566
+            if ( ! $orig_dtt instanceof EE_Datetime) {
567 567
                 continue;
568 568
             }
569 569
             $new_dtt = clone $orig_dtt;
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
             // now let's get the ticket relations setup.
579 579
             foreach ((array) $orig_tkts as $orig_tkt) {
580 580
                 // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
581
-                if (! $orig_tkt instanceof EE_Ticket) {
581
+                if ( ! $orig_tkt instanceof EE_Ticket) {
582 582
                     continue;
583 583
                 }
584 584
                 // is this ticket archived?  If it is then let's skip
@@ -587,8 +587,8 @@  discard block
 block discarded – undo
587 587
                 }
588 588
                 // does this original ticket already exist in the clone_tickets cache?
589 589
                 //  If so we'll just use the new ticket from it.
590
-                if (isset($cloned_tickets[ $orig_tkt->ID() ])) {
591
-                    $new_tkt = $cloned_tickets[ $orig_tkt->ID() ];
590
+                if (isset($cloned_tickets[$orig_tkt->ID()])) {
591
+                    $new_tkt = $cloned_tickets[$orig_tkt->ID()];
592 592
                 } else {
593 593
                     $new_tkt = clone $orig_tkt;
594 594
                     // get relations on the $orig_tkt that we need to setup.
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
                 // for use with later datetimes that have the same ticket.
622 622
                 $new_dtt->_add_relation_to($new_tkt, 'Ticket');
623 623
                 $new_dtt->save();
624
-                $cloned_tickets[ $orig_tkt->ID() ] = $new_tkt;
624
+                $cloned_tickets[$orig_tkt->ID()] = $new_tkt;
625 625
             }
626 626
         }
627 627
         // clone taxonomy information
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
             $this->_admin_base_url
705 705
         );
706 706
         $content = EEH_Template::display_template(
707
-            EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
707
+            EVENTS_CAF_TEMPLATE_PATH.'import_page.template.php',
708 708
             $this->_template_args,
709 709
             true
710 710
         );
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
      */
722 722
     protected function _import_events()
723 723
     {
724
-        require_once(EE_CLASSES . 'EE_Import.class.php');
724
+        require_once(EE_CLASSES.'EE_Import.class.php');
725 725
         $success = EE_Import::instance()->import();
726 726
         $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true);
727 727
     }
@@ -750,8 +750,8 @@  discard block
 block discarded – undo
750 750
             'EVT_ID' => $event_ids,
751 751
         );
752 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');
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
         }
@@ -772,8 +772,8 @@  discard block
 block discarded – undo
772 772
             'category_ids' => $this->_req_data['EVT_CAT_ID'],
773 773
         );
774 774
         $this->_req_data = array_merge($this->_req_data, $new_request_args);
775
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
776
-            require_once(EE_CLASSES . 'EE_Export.class.php');
775
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
776
+            require_once(EE_CLASSES.'EE_Export.class.php');
777 777
             $EE_Export = EE_Export::instance($this->_req_data);
778 778
             $EE_Export->export();
779 779
         }
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
         $this->_set_add_edit_form_tags('update_template_settings');
812 812
         $this->_set_publish_post_box_vars(null, false, false, null, false);
813 813
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
814
-            EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
814
+            EVENTS_CAF_TEMPLATE_PATH.'template_settings.template.php',
815 815
             $this->_template_args,
816 816
             true
817 817
         );
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
             $default_reg_status_values
939 939
         );
940 940
         EEH_Template::display_template(
941
-            EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
941
+            EVENTS_CAF_TEMPLATE_PATH.'event_registration_options.template.php',
942 942
             $template_args
943 943
         );
944 944
     }
@@ -1042,13 +1042,13 @@  discard block
 block discarded – undo
1042 1042
     {
1043 1043
         $start = EEM_Datetime::instance()->convert_datetime_for_query(
1044 1044
             'DTT_EVT_start',
1045
-            date('Y-m-d') . ' 00:00:00',
1045
+            date('Y-m-d').' 00:00:00',
1046 1046
             'Y-m-d H:i:s',
1047 1047
             'UTC'
1048 1048
         );
1049 1049
         $end = EEM_Datetime::instance()->convert_datetime_for_query(
1050 1050
             'DTT_EVT_start',
1051
-            date('Y-m-d') . ' 23:59:59',
1051
+            date('Y-m-d').' 23:59:59',
1052 1052
             'Y-m-d H:i:s',
1053 1053
             'UTC'
1054 1054
         );
@@ -1075,13 +1075,13 @@  discard block
 block discarded – undo
1075 1075
         $days_this_month = date('t');
1076 1076
         $start = EEM_Datetime::instance()->convert_datetime_for_query(
1077 1077
             'DTT_EVT_start',
1078
-            $this_year_r . '-' . $this_month_r . '-01 00:00:00',
1078
+            $this_year_r.'-'.$this_month_r.'-01 00:00:00',
1079 1079
             'Y-m-d H:i:s',
1080 1080
             'UTC'
1081 1081
         );
1082 1082
         $end = EEM_Datetime::instance()->convert_datetime_for_query(
1083 1083
             'DTT_EVT_start',
1084
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1084
+            $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' 23:59:59',
1085 1085
             'Y-m-d H:i:s',
1086 1086
             'UTC'
1087 1087
         );
@@ -1148,7 +1148,7 @@  discard block
 block discarded – undo
1148 1148
         $offset = ($current_page - 1) * $per_page;
1149 1149
         $limit = array($offset, $per_page);
1150 1150
         if (isset($this->_req_data['s'])) {
1151
-            $sstr = '%' . $this->_req_data['s'] . '%';
1151
+            $sstr = '%'.$this->_req_data['s'].'%';
1152 1152
             $_where['OR'] = array(
1153 1153
                 'TKT_name'        => array('LIKE', $sstr),
1154 1154
                 'TKT_description' => array('LIKE', $sstr),
@@ -1177,17 +1177,17 @@  discard block
 block discarded – undo
1177 1177
         $success = 1;
1178 1178
         $TKT = EEM_Ticket::instance();
1179 1179
         // checkboxes?
1180
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1180
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1181 1181
             // if array has more than one element then success message should be plural
1182 1182
             $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1183 1183
             // cycle thru the boxes
1184 1184
             while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1185 1185
                 if ($trash) {
1186
-                    if (! $TKT->delete_by_ID($TKT_ID)) {
1186
+                    if ( ! $TKT->delete_by_ID($TKT_ID)) {
1187 1187
                         $success = 0;
1188 1188
                     }
1189 1189
                 } else {
1190
-                    if (! $TKT->restore_by_ID($TKT_ID)) {
1190
+                    if ( ! $TKT->restore_by_ID($TKT_ID)) {
1191 1191
                         $success = 0;
1192 1192
                     }
1193 1193
                 }
@@ -1196,11 +1196,11 @@  discard block
 block discarded – undo
1196 1196
             // grab single id and trash
1197 1197
             $TKT_ID = absint($this->_req_data['TKT_ID']);
1198 1198
             if ($trash) {
1199
-                if (! $TKT->delete_by_ID($TKT_ID)) {
1199
+                if ( ! $TKT->delete_by_ID($TKT_ID)) {
1200 1200
                     $success = 0;
1201 1201
                 }
1202 1202
             } else {
1203
-                if (! $TKT->restore_by_ID($TKT_ID)) {
1203
+                if ( ! $TKT->restore_by_ID($TKT_ID)) {
1204 1204
                     $success = 0;
1205 1205
                 }
1206 1206
             }
@@ -1221,20 +1221,20 @@  discard block
 block discarded – undo
1221 1221
     {
1222 1222
         $success = 1;
1223 1223
         // checkboxes?
1224
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1224
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1225 1225
             // if array has more than one element then success message should be plural
1226 1226
             $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1227 1227
             // cycle thru the boxes
1228 1228
             while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1229 1229
                 // delete
1230
-                if (! $this->_delete_the_ticket($TKT_ID)) {
1230
+                if ( ! $this->_delete_the_ticket($TKT_ID)) {
1231 1231
                     $success = 0;
1232 1232
                 }
1233 1233
             }
1234 1234
         } else {
1235 1235
             // grab single id and trash
1236 1236
             $TKT_ID = absint($this->_req_data['TKT_ID']);
1237
-            if (! $this->_delete_the_ticket($TKT_ID)) {
1237
+            if ( ! $this->_delete_the_ticket($TKT_ID)) {
1238 1238
                 $success = 0;
1239 1239
             }
1240 1240
         }
Please login to merge, or discard this patch.
registration_form/espresso_events_Registration_Form_Hooks_Extend.class.php 2 patches
Indentation   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -16,208 +16,208 @@
 block discarded – undo
16 16
 class espresso_events_Registration_Form_Hooks_Extend extends espresso_events_Registration_Form_Hooks
17 17
 {
18 18
 
19
-    /**
20
-     * extending the properties set in espresso_events_Registration_From_Hooks
21
-     *
22
-     * @access protected
23
-     * @return void
24
-     */
25
-    protected function _extend_properties()
26
-    {
27
-        $this->_metaboxes = array_merge(
28
-            $this->_metaboxes,
29
-            array(
30
-                1 => array(
31
-                    'page_route' => array('create_new', 'edit'),
32
-                    'func'       => 'additional_questions',
33
-                    'label'      => esc_html__('Questions for Additional Registrants', 'event_espresso'),
34
-                    'priority'   => 'default',
35
-                    'context'    => 'side',
36
-                ),
37
-            )
38
-        );
39
-        $this->_scripts_styles = array(
40
-            'registers' => array(
41
-                'extended-event-editor' => array(
42
-                    'url'     => EE_CORE_CAF_ADMIN_EXTEND_URL
43
-                                 . 'registration_form/assets/event-editor-question-groups.js',
44
-                    'depends' => array('jquery'),
45
-                ),
46
-            ),
47
-            'enqueues'  => array(
48
-                'extended-event-editor' => array('edit', 'create_new'),
49
-            ),
50
-        );
51
-    }
52
-
53
-
54
-    /**
55
-     * @param Callable[] $callbacks
56
-     * @return array
57
-     */
58
-    public function modify_callbacks($callbacks)
59
-    {
60
-        $callbacks = parent::modify_callbacks($callbacks);
61
-        $callbacks[] = array($this, 'additional_question_group_update');
62
-        return $callbacks;
63
-    }
64
-
65
-
66
-    /**
67
-     * Call back hooked into revision restores.
68
-     *
69
-     * @param $post_id
70
-     * @param $revision_id
71
-     * @return EE_Base_Class|void
72
-     * @throws EE_Error
73
-     * @throws InvalidArgumentException
74
-     * @throws InvalidDataTypeException
75
-     * @throws InvalidInterfaceException
76
-     * @throws ReflectionException
77
-     */
78
-    public function restore_revision($post_id, $revision_id)
79
-    {
80
-        $post_evt = parent::restore_revision($post_id, $revision_id);
81
-
82
-        // restore revision for additional questions
83
-        $post_evt->restore_revision(
84
-            $revision_id,
85
-            ['Question_Group'],
86
-            [
87
-                'Question_Group' => ['Event_Question_Group.EQG_additional' => true],
88
-            ]
89
-        );
90
-    }
91
-
92
-
93
-    /**
94
-     * @param $post_id
95
-     * @param $post
96
-     * @throws EE_Error
97
-     * @throws InvalidArgumentException
98
-     * @throws InvalidDataTypeException
99
-     * @throws InvalidInterfaceException
100
-     */
101
-    public function additional_questions($post_id, $post)
102
-    {
103
-        $this->_event = $this->_adminpage_obj->get_event_object();
104
-        $event_id = $this->_event->ID();
105
-        ?>
19
+	/**
20
+	 * extending the properties set in espresso_events_Registration_From_Hooks
21
+	 *
22
+	 * @access protected
23
+	 * @return void
24
+	 */
25
+	protected function _extend_properties()
26
+	{
27
+		$this->_metaboxes = array_merge(
28
+			$this->_metaboxes,
29
+			array(
30
+				1 => array(
31
+					'page_route' => array('create_new', 'edit'),
32
+					'func'       => 'additional_questions',
33
+					'label'      => esc_html__('Questions for Additional Registrants', 'event_espresso'),
34
+					'priority'   => 'default',
35
+					'context'    => 'side',
36
+				),
37
+			)
38
+		);
39
+		$this->_scripts_styles = array(
40
+			'registers' => array(
41
+				'extended-event-editor' => array(
42
+					'url'     => EE_CORE_CAF_ADMIN_EXTEND_URL
43
+								 . 'registration_form/assets/event-editor-question-groups.js',
44
+					'depends' => array('jquery'),
45
+				),
46
+			),
47
+			'enqueues'  => array(
48
+				'extended-event-editor' => array('edit', 'create_new'),
49
+			),
50
+		);
51
+	}
52
+
53
+
54
+	/**
55
+	 * @param Callable[] $callbacks
56
+	 * @return array
57
+	 */
58
+	public function modify_callbacks($callbacks)
59
+	{
60
+		$callbacks = parent::modify_callbacks($callbacks);
61
+		$callbacks[] = array($this, 'additional_question_group_update');
62
+		return $callbacks;
63
+	}
64
+
65
+
66
+	/**
67
+	 * Call back hooked into revision restores.
68
+	 *
69
+	 * @param $post_id
70
+	 * @param $revision_id
71
+	 * @return EE_Base_Class|void
72
+	 * @throws EE_Error
73
+	 * @throws InvalidArgumentException
74
+	 * @throws InvalidDataTypeException
75
+	 * @throws InvalidInterfaceException
76
+	 * @throws ReflectionException
77
+	 */
78
+	public function restore_revision($post_id, $revision_id)
79
+	{
80
+		$post_evt = parent::restore_revision($post_id, $revision_id);
81
+
82
+		// restore revision for additional questions
83
+		$post_evt->restore_revision(
84
+			$revision_id,
85
+			['Question_Group'],
86
+			[
87
+				'Question_Group' => ['Event_Question_Group.EQG_additional' => true],
88
+			]
89
+		);
90
+	}
91
+
92
+
93
+	/**
94
+	 * @param $post_id
95
+	 * @param $post
96
+	 * @throws EE_Error
97
+	 * @throws InvalidArgumentException
98
+	 * @throws InvalidDataTypeException
99
+	 * @throws InvalidInterfaceException
100
+	 */
101
+	public function additional_questions($post_id, $post)
102
+	{
103
+		$this->_event = $this->_adminpage_obj->get_event_object();
104
+		$event_id = $this->_event->ID();
105
+		?>
106 106
         <div class="inside">
107 107
             <p><strong>
108 108
                     <?php _e('Question Groups', 'event_espresso'); ?>
109 109
                 </strong><br/>
110 110
                 <?php
111
-                printf(
112
-                    esc_html__(
113
-                        'Add a pre-populated %1$sgroup of questions%2$s to your event.',
114
-                        'event_espresso'
115
-                    ),
116
-                    '<a href="admin.php?page=espresso_registration_form" target="_blank">',
117
-                    '</a>'
118
-                );
119
-                ?>
111
+				printf(
112
+					esc_html__(
113
+						'Add a pre-populated %1$sgroup of questions%2$s to your event.',
114
+						'event_espresso'
115
+					),
116
+					'<a href="admin.php?page=espresso_registration_form" target="_blank">',
117
+					'</a>'
118
+				);
119
+				?>
120 120
             </p>
121 121
             <?php
122 122
 
123
-            $qsg_where['QSG_deleted'] = false;
124
-            $query_params = apply_filters(
125
-                'FHEE__espresso_events_Registration_Form_Hooks_Extend__additional_questions__question_group_query_parameters',
126
-                array($qsg_where, 'order_by' => array('QSG_order' => 'ASC'))
127
-            );
128
-            $QSGs = EEM_Question_Group::instance()->get_all($query_params);
129
-            $EQGs = ! empty($event_id)
130
-                ? $this->_event->get_many_related(
131
-                    'Question_Group',
132
-                    [['Event_Question_Group.EQG_additional' => true]]
133
-                )
134
-                : [];
135
-            $EQGids = array_keys($EQGs);
136
-
137
-            if (! empty($QSGs)) {
138
-                $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : '';
139
-                foreach ($QSGs as $QSG) {
140
-                    $checked = in_array($QSG->ID(), $EQGids, true) ? ' checked="checked" ' : '';
141
-                    $edit_link = EE_Admin_Page::add_query_args_and_nonce(
142
-                        array(
143
-                            'action' => 'edit_question_group',
144
-                            'QSG_ID' => $QSG->ID(),
145
-                        ),
146
-                        EE_FORMS_ADMIN_URL
147
-                    );
148
-
149
-                    $html .= '
123
+			$qsg_where['QSG_deleted'] = false;
124
+			$query_params = apply_filters(
125
+				'FHEE__espresso_events_Registration_Form_Hooks_Extend__additional_questions__question_group_query_parameters',
126
+				array($qsg_where, 'order_by' => array('QSG_order' => 'ASC'))
127
+			);
128
+			$QSGs = EEM_Question_Group::instance()->get_all($query_params);
129
+			$EQGs = ! empty($event_id)
130
+				? $this->_event->get_many_related(
131
+					'Question_Group',
132
+					[['Event_Question_Group.EQG_additional' => true]]
133
+				)
134
+				: [];
135
+			$EQGids = array_keys($EQGs);
136
+
137
+			if (! empty($QSGs)) {
138
+				$html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : '';
139
+				foreach ($QSGs as $QSG) {
140
+					$checked = in_array($QSG->ID(), $EQGids, true) ? ' checked="checked" ' : '';
141
+					$edit_link = EE_Admin_Page::add_query_args_and_nonce(
142
+						array(
143
+							'action' => 'edit_question_group',
144
+							'QSG_ID' => $QSG->ID(),
145
+						),
146
+						EE_FORMS_ADMIN_URL
147
+					);
148
+
149
+					$html .= '
150 150
 					<p id="event-question-group-' . $QSG->ID() . '">
151 151
 						<input value="' . $QSG->ID() . '"'
152
-                             . ' type="checkbox" name="add_attendee_question_groups[' . $QSG->ID() . ']"' . $checked . ' />
152
+							 . ' type="checkbox" name="add_attendee_question_groups[' . $QSG->ID() . ']"' . $checked . ' />
153 153
 						<a href="' . $edit_link . '" title="'
154
-                             . sprintf(
155
-                                 esc_attr__('Edit %s Group', 'event_espresso'),
156
-                                 $QSG->get('QSG_name')
157
-                             )
158
-                             . '" target="_blank">' . $QSG->get('QSG_name') . '</a>
154
+							 . sprintf(
155
+								 esc_attr__('Edit %s Group', 'event_espresso'),
156
+								 $QSG->get('QSG_name')
157
+							 )
158
+							 . '" target="_blank">' . $QSG->get('QSG_name') . '</a>
159 159
 					</p>';
160
-                    if ($QSG->ID() === 2) {
161
-                        $html .= '
160
+					if ($QSG->ID() === 2) {
161
+						$html .= '
162 162
 					<p id="question-group-requirements-notice-pg" class="important-notice small-text" style="display: none;">'
163
-                                 . esc_html__(
164
-                                     'The Personal Information question group is required whenever the Address Information question group is activated.',
165
-                                     'event_espresso'
166
-                                 )
167
-                                 . '</p>';
168
-                    }
169
-                }
170
-                $html .= count($QSGs) > 10 ? '</div>' : '';
171
-
172
-                echo $html;
173
-            } else {
174
-                esc_html_e(
175
-                    'There seems to be a problem with your questions. Please contact [email protected]',
176
-                    'event_espresso'
177
-                );
178
-            }
179
-            do_action('AHEE__espresso_events_Registration_Form_Hooks__additional_questions__after_content');
180
-            ?>
163
+								 . esc_html__(
164
+									 'The Personal Information question group is required whenever the Address Information question group is activated.',
165
+									 'event_espresso'
166
+								 )
167
+								 . '</p>';
168
+					}
169
+				}
170
+				$html .= count($QSGs) > 10 ? '</div>' : '';
171
+
172
+				echo $html;
173
+			} else {
174
+				esc_html_e(
175
+					'There seems to be a problem with your questions. Please contact [email protected]',
176
+					'event_espresso'
177
+				);
178
+			}
179
+			do_action('AHEE__espresso_events_Registration_Form_Hooks__additional_questions__after_content');
180
+			?>
181 181
         </div>
182 182
         <?php
183
-    }
184
-
185
-
186
-    public function additional_question_group_update($evtobj, $data)
187
-    {
188
-        $question_groups = ! empty($data['add_attendee_question_groups'])
189
-            ? (array) $data['add_attendee_question_groups']
190
-            : [];
191
-        $added_qgs = array_keys($question_groups);
192
-        $success = [];
193
-
194
-        // let's get all current question groups associated with this event.
195
-        $current_qgs = $evtobj->get_many_related(
196
-            'Question_Group',
197
-            [['Event_Question_Group.EQG_additional' => true]]
198
-        );
199
-        $current_qgs = array_keys($current_qgs); // we just want the ids
200
-
201
-        // now let's get the groups selected in the editor and update (IF we have data)
202
-        if (! empty($question_groups)) {
203
-            foreach ($question_groups as $qgid) {
204
-                // add to event
205
-                if ($qgid) {
206
-                    $qg = $evtobj->add_question_group($qgid, false);
207
-                }
208
-                $success[] = ! empty($qg) ? 1 : 0;
209
-            }
210
-        }
211
-
212
-        // wait a minute... are there question groups missing in the saved groups that ARE with the current event?
213
-        $removed_qgs = array_diff($current_qgs, $added_qgs);
214
-
215
-        foreach ($removed_qgs as $qgid) {
216
-            $qg = $evtobj->remove_question_group($qgid, false);
217
-            $success[] = ! empty($qg) ? 1 : 0;
218
-        }
219
-
220
-
221
-        return in_array(0, $success, true) ? false : true;
222
-    }
183
+	}
184
+
185
+
186
+	public function additional_question_group_update($evtobj, $data)
187
+	{
188
+		$question_groups = ! empty($data['add_attendee_question_groups'])
189
+			? (array) $data['add_attendee_question_groups']
190
+			: [];
191
+		$added_qgs = array_keys($question_groups);
192
+		$success = [];
193
+
194
+		// let's get all current question groups associated with this event.
195
+		$current_qgs = $evtobj->get_many_related(
196
+			'Question_Group',
197
+			[['Event_Question_Group.EQG_additional' => true]]
198
+		);
199
+		$current_qgs = array_keys($current_qgs); // we just want the ids
200
+
201
+		// now let's get the groups selected in the editor and update (IF we have data)
202
+		if (! empty($question_groups)) {
203
+			foreach ($question_groups as $qgid) {
204
+				// add to event
205
+				if ($qgid) {
206
+					$qg = $evtobj->add_question_group($qgid, false);
207
+				}
208
+				$success[] = ! empty($qg) ? 1 : 0;
209
+			}
210
+		}
211
+
212
+		// wait a minute... are there question groups missing in the saved groups that ARE with the current event?
213
+		$removed_qgs = array_diff($current_qgs, $added_qgs);
214
+
215
+		foreach ($removed_qgs as $qgid) {
216
+			$qg = $evtobj->remove_question_group($qgid, false);
217
+			$success[] = ! empty($qg) ? 1 : 0;
218
+		}
219
+
220
+
221
+		return in_array(0, $success, true) ? false : true;
222
+	}
223 223
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
                 : [];
135 135
             $EQGids = array_keys($EQGs);
136 136
 
137
-            if (! empty($QSGs)) {
137
+            if ( ! empty($QSGs)) {
138 138
                 $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : '';
139 139
                 foreach ($QSGs as $QSG) {
140 140
                     $checked = in_array($QSG->ID(), $EQGids, true) ? ' checked="checked" ' : '';
@@ -147,15 +147,15 @@  discard block
 block discarded – undo
147 147
                     );
148 148
 
149 149
                     $html .= '
150
-					<p id="event-question-group-' . $QSG->ID() . '">
151
-						<input value="' . $QSG->ID() . '"'
152
-                             . ' type="checkbox" name="add_attendee_question_groups[' . $QSG->ID() . ']"' . $checked . ' />
153
-						<a href="' . $edit_link . '" title="'
150
+					<p id="event-question-group-' . $QSG->ID().'">
151
+						<input value="' . $QSG->ID().'"'
152
+                             . ' type="checkbox" name="add_attendee_question_groups['.$QSG->ID().']"'.$checked.' />
153
+						<a href="' . $edit_link.'" title="'
154 154
                              . sprintf(
155 155
                                  esc_attr__('Edit %s Group', 'event_espresso'),
156 156
                                  $QSG->get('QSG_name')
157 157
                              )
158
-                             . '" target="_blank">' . $QSG->get('QSG_name') . '</a>
158
+                             . '" target="_blank">'.$QSG->get('QSG_name').'</a>
159 159
 					</p>';
160 160
                     if ($QSG->ID() === 2) {
161 161
                         $html .= '
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
         $current_qgs = array_keys($current_qgs); // we just want the ids
200 200
 
201 201
         // now let's get the groups selected in the editor and update (IF we have data)
202
-        if (! empty($question_groups)) {
202
+        if ( ! empty($question_groups)) {
203 203
             foreach ($question_groups as $qgid) {
204 204
                 // add to event
205 205
                 if ($qgid) {
Please login to merge, or discard this patch.