Completed
Branch BUG-10059-allow-multiple-invoi... (76c0cc)
by
unknown
40:24 queued 26:41
created
core/data_migration_scripts/EE_DMS_Core_4_1_0.dms.php 3 patches
Doc Comments   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1421,7 +1421,6 @@  discard block
 block discarded – undo
1421 1421
      * Makes sure the 3.1's image url is converted to an image attachment post to the 4.1 CPT event
1422 1422
      * and sets it as the featured image on the CPT event
1423 1423
      *
1424
-     * @param type                            $old_event
1425 1424
      * @param type                            $new_cpt_id
1426 1425
      * @param  EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added
1427 1426
      * @return boolean whether or not we had to do the big job of creating an image attachment
@@ -1483,7 +1482,7 @@  discard block
 block discarded – undo
1483 1482
      * we download it to our uploads directory so that it can be properly processed (eg, creates different sizes of
1484 1483
      * thumbnails)
1485 1484
      *
1486
-     * @param type                           $guid
1485
+     * @param string                           $guid
1487 1486
      * @param EE_Data_Migration_Script_Stage $migration_stage
1488 1487
      * @return int
1489 1488
      */
@@ -1571,7 +1570,7 @@  discard block
 block discarded – undo
1571 1570
      * Returns a mysql-formatted DATETIME in UTC time, given a $DATETIME_string
1572 1571
      * (and optionally a timezone; if none is given, the wp DEFAULT is used)
1573 1572
      *
1574
-     * @param EE_Data_Migration_Script_base $stage
1573
+     * @param EE_Data_Migration_Script_Stage $stage
1575 1574
      * @param array                         $row_of_data , the row from the DB (as an array) we're trying to find the
1576 1575
      *                                                   UTC time for
1577 1576
      * @param string                        $DATETIME_string
Please login to merge, or discard this patch.
Indentation   +1127 added lines, -1127 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@  discard block
 block discarded – undo
12 12
 $stages = glob(EE_CORE . 'data_migration_scripts/4_1_0_stages/*');
13 13
 $class_to_filepath = array();
14 14
 if ( ! empty($stages)) {
15
-    foreach ($stages as $filepath) {
16
-        $matches = array();
17
-        preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches);
18
-        $class_to_filepath[$matches[1]] = $filepath;
19
-    }
15
+	foreach ($stages as $filepath) {
16
+		$matches = array();
17
+		preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches);
18
+		$class_to_filepath[$matches[1]] = $filepath;
19
+	}
20 20
 }
21 21
 //give addons a chance to autoload their stages too
22 22
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_1_0__autoloaded_stages', $class_to_filepath);
@@ -44,98 +44,98 @@  discard block
 block discarded – undo
44 44
 
45 45
 
46 46
 
47
-    /**
48
-     * EE_DMS_Core_4_1_0 constructor.
49
-     *
50
-     * @param TableManager  $table_manager
51
-     * @param TableAnalysis $table_analysis
52
-     */
53
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
54
-    {
55
-        $this->_pretty_name = __("Data Migration to Event Espresso 4.1.0P", "event_espresso");
56
-        $this->_priority = 10;
57
-        $this->_migration_stages = array(
58
-                new EE_DMS_4_1_0_org_options(),
59
-                new EE_DMS_4_1_0_shortcodes(),
60
-                new EE_DMS_4_1_0_gateways(),
61
-                new EE_DMS_4_1_0_events(),
62
-                new EE_DMS_4_1_0_prices(),
63
-                new EE_DMS_4_1_0_category_details(),
64
-                new EE_DMS_4_1_0_event_category(),
65
-                new EE_DMS_4_1_0_venues(),
66
-                new EE_DMS_4_1_0_event_venue(),
67
-                new EE_DMS_4_1_0_question_groups(),
68
-                new EE_DMS_4_1_0_questions(),
69
-                new EE_DMS_4_1_0_question_group_question(),
70
-                new EE_DMS_4_1_0_event_question_group(),
71
-                new EE_DMS_4_1_0_attendees(),
72
-                new EE_DMS_4_1_0_line_items(),
73
-                new EE_DMS_4_1_0_answers(),
74
-                new EE_DMS_4_1_0_checkins(),
75
-        );
76
-        parent::__construct($table_manager, $table_analysis);
77
-    }
78
-
79
-
80
-
81
-    /**
82
-     * Checks if this 3.1 Check-in table exists. If it doesn't we can't migrate Check-ins
83
-     *
84
-     * @global wpdb $wpdb
85
-     * @return boolean
86
-     */
87
-    private function _checkin_table_exists()
88
-    {
89
-        global $wpdb;
90
-        $results = $wpdb->get_results("SHOW TABLES LIKE '" . $wpdb->prefix . "events_attendee_checkin" . "'");
91
-        if ($results) {
92
-            return true;
93
-        } else {
94
-            return false;
95
-        }
96
-    }
97
-
98
-
99
-
100
-    public function can_migrate_from_version($version_array)
101
-    {
102
-        $version_string = $version_array['Core'];
103
-        if (version_compare($version_string, '4.0.0', '<=') && version_compare($version_string, '3.1.26', '>=')) {
47
+	/**
48
+	 * EE_DMS_Core_4_1_0 constructor.
49
+	 *
50
+	 * @param TableManager  $table_manager
51
+	 * @param TableAnalysis $table_analysis
52
+	 */
53
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
54
+	{
55
+		$this->_pretty_name = __("Data Migration to Event Espresso 4.1.0P", "event_espresso");
56
+		$this->_priority = 10;
57
+		$this->_migration_stages = array(
58
+				new EE_DMS_4_1_0_org_options(),
59
+				new EE_DMS_4_1_0_shortcodes(),
60
+				new EE_DMS_4_1_0_gateways(),
61
+				new EE_DMS_4_1_0_events(),
62
+				new EE_DMS_4_1_0_prices(),
63
+				new EE_DMS_4_1_0_category_details(),
64
+				new EE_DMS_4_1_0_event_category(),
65
+				new EE_DMS_4_1_0_venues(),
66
+				new EE_DMS_4_1_0_event_venue(),
67
+				new EE_DMS_4_1_0_question_groups(),
68
+				new EE_DMS_4_1_0_questions(),
69
+				new EE_DMS_4_1_0_question_group_question(),
70
+				new EE_DMS_4_1_0_event_question_group(),
71
+				new EE_DMS_4_1_0_attendees(),
72
+				new EE_DMS_4_1_0_line_items(),
73
+				new EE_DMS_4_1_0_answers(),
74
+				new EE_DMS_4_1_0_checkins(),
75
+		);
76
+		parent::__construct($table_manager, $table_analysis);
77
+	}
78
+
79
+
80
+
81
+	/**
82
+	 * Checks if this 3.1 Check-in table exists. If it doesn't we can't migrate Check-ins
83
+	 *
84
+	 * @global wpdb $wpdb
85
+	 * @return boolean
86
+	 */
87
+	private function _checkin_table_exists()
88
+	{
89
+		global $wpdb;
90
+		$results = $wpdb->get_results("SHOW TABLES LIKE '" . $wpdb->prefix . "events_attendee_checkin" . "'");
91
+		if ($results) {
92
+			return true;
93
+		} else {
94
+			return false;
95
+		}
96
+	}
97
+
98
+
99
+
100
+	public function can_migrate_from_version($version_array)
101
+	{
102
+		$version_string = $version_array['Core'];
103
+		if (version_compare($version_string, '4.0.0', '<=') && version_compare($version_string, '3.1.26', '>=')) {
104 104
 //			echo "$version_string can be migrated fro";
105
-            return true;
106
-        } elseif ( ! $version_string) {
105
+			return true;
106
+		} elseif ( ! $version_string) {
107 107
 //			echo "no version string provided: $version_string";
108
-            //no version string provided... this must be pre 4.1
109
-            //because since 4.1 we're
110
-            return false;//changed mind. dont want people thinking they should migrate yet because they cant
111
-        } else {
108
+			//no version string provided... this must be pre 4.1
109
+			//because since 4.1 we're
110
+			return false;//changed mind. dont want people thinking they should migrate yet because they cant
111
+		} else {
112 112
 //			echo "$version_string doesnt apply";
113
-            return false;
114
-        }
115
-    }
113
+			return false;
114
+		}
115
+	}
116 116
 
117 117
 
118 118
 
119
-    public function pretty_name()
120
-    {
121
-        return __("Core Data Migration to version 4.1.0", "event_espresso");
122
-    }
119
+	public function pretty_name()
120
+	{
121
+		return __("Core Data Migration to version 4.1.0", "event_espresso");
122
+	}
123 123
 
124 124
 
125 125
 
126
-    public function schema_changes_before_migration()
127
-    {
128
-        //relies on 4.1's EEH_Activation::create_table
129
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
130
-        $table_name = 'esp_answer';
131
-        $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
126
+	public function schema_changes_before_migration()
127
+	{
128
+		//relies on 4.1's EEH_Activation::create_table
129
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
130
+		$table_name = 'esp_answer';
131
+		$sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
132 132
 					REG_ID INT UNSIGNED NOT NULL,
133 133
 					QST_ID INT UNSIGNED NOT NULL,
134 134
 					ANS_value TEXT NOT NULL,
135 135
 					PRIMARY KEY  (ANS_ID)";
136
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
137
-        $table_name = 'esp_attendee_meta';
138
-        $sql = "ATTM_ID INT(10) UNSIGNED NOT	NULL AUTO_INCREMENT,
136
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
137
+		$table_name = 'esp_attendee_meta';
138
+		$sql = "ATTM_ID INT(10) UNSIGNED NOT	NULL AUTO_INCREMENT,
139 139
 						ATT_ID BIGINT(20) UNSIGNED NOT NULL,
140 140
 						ATT_fname VARCHAR(45) NOT NULL,
141 141
 						ATT_lname VARCHAR(45) NOT	NULL,
@@ -151,9 +151,9 @@  discard block
 block discarded – undo
151 151
 								KEY ATT_fname (ATT_fname),
152 152
 								KEY ATT_lname (ATT_lname),
153 153
 								KEY ATT_email (ATT_email)";
154
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
155
-        $table_name = 'esp_country';
156
-        $sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL,
154
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
155
+		$table_name = 'esp_country';
156
+		$sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL,
157 157
 					  CNT_ISO3 VARCHAR(3) COLLATE utf8_bin NOT NULL,
158 158
 					  RGN_ID TINYINT(3) UNSIGNED DEFAULT NULL,
159 159
 					  CNT_name VARCHAR(45) COLLATE utf8_bin NOT NULL,
@@ -169,9 +169,9 @@  discard block
 block discarded – undo
169 169
 					  CNT_is_EU TINYINT(1) DEFAULT '0',
170 170
 					  CNT_active TINYINT(1) DEFAULT '0',
171 171
 					  PRIMARY KEY  (CNT_ISO)";
172
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
173
-        $table_name = 'esp_datetime';
174
-        $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
172
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
173
+		$table_name = 'esp_datetime';
174
+		$sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
175 175
 				  EVT_ID BIGINT(20) UNSIGNED NOT NULL,
176 176
 				  DTT_EVT_start DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
177 177
 				  DTT_EVT_end DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -184,9 +184,9 @@  discard block
 block discarded – undo
184 184
 						PRIMARY KEY  (DTT_ID),
185 185
 						KEY EVT_ID (EVT_ID),
186 186
 						KEY DTT_is_primary (DTT_is_primary)";
187
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
188
-        $table_name = 'esp_event_meta';
189
-        $sql = "
187
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
188
+		$table_name = 'esp_event_meta';
189
+		$sql = "
190 190
 			EVTM_ID INT NOT NULL AUTO_INCREMENT,
191 191
 			EVT_ID BIGINT(20) UNSIGNED NOT NULL,
192 192
 			EVT_display_desc TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
@@ -201,31 +201,31 @@  discard block
 block discarded – undo
201 201
 			EVT_external_URL VARCHAR(200) NULL,
202 202
 			EVT_donations TINYINT(1) NULL,
203 203
 			PRIMARY KEY  (EVTM_ID)";
204
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
205
-        $table_name = 'esp_event_question_group';
206
-        $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
204
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
205
+		$table_name = 'esp_event_question_group';
206
+		$sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
207 207
 					EVT_ID BIGINT(20) UNSIGNED NOT NULL,
208 208
 					QSG_ID INT UNSIGNED NOT NULL,
209 209
 					EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
210 210
 					PRIMARY KEY  (EQG_ID)";
211
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
212
-        $table_name = 'esp_event_venue';
213
-        $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
211
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
212
+		$table_name = 'esp_event_venue';
213
+		$sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
214 214
 				EVT_ID BIGINT(20) UNSIGNED NOT NULL,
215 215
 				VNU_ID BIGINT(20) UNSIGNED NOT NULL,
216 216
 				EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
217 217
 				PRIMARY KEY  (EVV_ID)";
218
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
219
-        $table_name = 'esp_extra_meta';
220
-        $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
218
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
219
+		$table_name = 'esp_extra_meta';
220
+		$sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
221 221
 				OBJ_ID INT(11) DEFAULT NULL,
222 222
 				EXM_type VARCHAR(45) DEFAULT NULL,
223 223
 				EXM_key VARCHAR(45) DEFAULT NULL,
224 224
 				EXM_value TEXT,
225 225
 				PRIMARY KEY  (EXM_ID)";
226
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
227
-        $table_name = 'esp_line_item';
228
-        $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
226
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
227
+		$table_name = 'esp_line_item';
228
+		$sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
229 229
 				LIN_code VARCHAR(245) NOT NULL DEFAULT '',
230 230
 				TXN_ID INT(11) DEFAULT NULL,
231 231
 				LIN_name VARCHAR(245) NOT NULL DEFAULT '',
@@ -241,18 +241,18 @@  discard block
 block discarded – undo
241 241
 				OBJ_ID INT(11) DEFAULT NULL,
242 242
 				OBJ_type VARCHAR(45)DEFAULT NULL,
243 243
 				PRIMARY KEY  (LIN_ID)";
244
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
245
-        $table_name = 'esp_message_template';
246
-        $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
244
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
245
+		$table_name = 'esp_message_template';
246
+		$sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
247 247
 					GRP_ID INT(10) UNSIGNED NOT NULL,
248 248
 					MTP_context VARCHAR(50) NOT NULL,
249 249
 					MTP_template_field VARCHAR(30) NOT NULL,
250 250
 					MTP_content TEXT NOT NULL,
251 251
 					PRIMARY KEY  (MTP_ID),
252 252
 					KEY GRP_ID (GRP_ID)";
253
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
254
-        $table_name = 'esp_message_template_group';
255
-        $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
253
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
254
+		$table_name = 'esp_message_template_group';
255
+		$sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
256 256
 					EVT_ID BIGINT(20) UNSIGNED DEFAULT NULL,
257 257
 					MTP_user_id INT(10) NOT NULL DEFAULT '1',
258 258
 					MTP_messenger VARCHAR(30) NOT NULL,
@@ -264,9 +264,9 @@  discard block
 block discarded – undo
264 264
 					PRIMARY KEY  (GRP_ID),
265 265
 					KEY EVT_ID (EVT_ID),
266 266
 					KEY MTP_user_id (MTP_user_id)";
267
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
268
-        $table_name = 'esp_payment';
269
-        $sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
267
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
268
+		$table_name = 'esp_payment';
269
+		$sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
270 270
 					TXN_ID INT(10) UNSIGNED DEFAULT NULL,
271 271
 					STS_ID VARCHAR(3) COLLATE utf8_bin DEFAULT NULL,
272 272
 					PAY_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -282,9 +282,9 @@  discard block
 block discarded – undo
282 282
 					PRIMARY KEY  (PAY_ID),
283 283
 					KEY TXN_ID (TXN_ID),
284 284
 					KEY PAY_timestamp (PAY_timestamp)";
285
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
286
-        $table_name = "esp_ticket";
287
-        $sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
285
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
286
+		$table_name = "esp_ticket";
287
+		$sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
288 288
 					  TTM_ID INT(10) UNSIGNED NOT NULL,
289 289
 					  TKT_name VARCHAR(245) NOT NULL DEFAULT '',
290 290
 					  TKT_description TEXT NOT NULL,
@@ -303,28 +303,28 @@  discard block
 block discarded – undo
303 303
 					  TKT_parent INT(10) UNSIGNED DEFAULT '0',
304 304
 					  TKT_deleted TINYINT(1) NOT NULL DEFAULT '0',
305 305
 					  PRIMARY KEY  (TKT_ID)";
306
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
307
-        $table_name = "esp_ticket_price";
308
-        $sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
306
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
307
+		$table_name = "esp_ticket_price";
308
+		$sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
309 309
 					  TKT_ID INT(10) UNSIGNED NOT NULL,
310 310
 					  PRC_ID INT(10) UNSIGNED NOT NULL,
311 311
 					  PRIMARY KEY  (TKP_ID)";
312
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
313
-        $table_name = "esp_datetime_ticket";
314
-        $sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
312
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
313
+		$table_name = "esp_datetime_ticket";
314
+		$sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
315 315
 					  DTT_ID INT(10) UNSIGNED NOT NULL,
316 316
 					  TKT_ID INT(10) UNSIGNED NOT NULL,
317 317
 					  PRIMARY KEY  (DTK_ID)";
318
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
319
-        $table_name = "esp_ticket_template";
320
-        $sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
318
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
319
+		$table_name = "esp_ticket_template";
320
+		$sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
321 321
 					  TTM_name VARCHAR(45) NOT NULL,
322 322
 					  TTM_description TEXT,
323 323
 					  TTM_file VARCHAR(45),
324 324
 					  PRIMARY KEY  (TTM_ID)";
325
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
326
-        $table_name = "esp_price";
327
-        $sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
325
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
326
+		$table_name = "esp_price";
327
+		$sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
328 328
 					  PRT_ID TINYINT(3) UNSIGNED NOT NULL,
329 329
 					  PRC_amount DECIMAL(10,3) NOT NULL DEFAULT '0.00',
330 330
 					  PRC_name VARCHAR(245) NOT NULL,
@@ -335,9 +335,9 @@  discard block
 block discarded – undo
335 335
 					  PRC_order TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
336 336
 					  PRC_parent INT(10) UNSIGNED DEFAULT 0,
337 337
 					  PRIMARY KEY  (PRC_ID)";
338
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
339
-        $table_name = "esp_price_type";
340
-        $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
338
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
339
+		$table_name = "esp_price_type";
340
+		$sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
341 341
 				  PRT_name VARCHAR(45) NOT NULL,
342 342
 				  PBT_ID TINYINT(3) UNSIGNED NOT NULL DEFAULT '1',
343 343
 				  PRT_is_percent TINYINT(1) NOT NULL DEFAULT '0',
@@ -345,9 +345,9 @@  discard block
 block discarded – undo
345 345
 				  PRT_deleted TINYINT(1) NOT NULL DEFAULT '0',
346 346
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
347 347
 				  PRIMARY KEY  (PRT_ID)";
348
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
349
-        $table_name = 'esp_question';
350
-        $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
348
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
349
+		$table_name = 'esp_question';
350
+		$sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
351 351
 					QST_display_text TEXT NOT NULL,
352 352
 					QST_admin_label VARCHAR(255) NOT NULL,
353 353
 					QST_system VARCHAR(25) DEFAULT NULL,
@@ -359,10 +359,10 @@  discard block
 block discarded – undo
359 359
 					QST_wp_user BIGINT UNSIGNED NULL,
360 360
 					QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0,
361 361
 					PRIMARY KEY  (QST_ID)';
362
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
363
-        $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
364
-        $table_name = 'esp_question_group';
365
-        $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
362
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
363
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
364
+		$table_name = 'esp_question_group';
365
+		$sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
366 366
 					QSG_name VARCHAR(255) NOT NULL,
367 367
 					QSG_identifier VARCHAR(100) NOT NULL,
368 368
 					QSG_desc TEXT NULL,
@@ -373,23 +373,23 @@  discard block
 block discarded – undo
373 373
 					QSG_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
374 374
 					PRIMARY KEY  (QSG_ID),
375 375
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
376
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
377
-        $table_name = 'esp_question_group_question';
378
-        $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
376
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
377
+		$table_name = 'esp_question_group_question';
378
+		$sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
379 379
 					QSG_ID INT UNSIGNED NOT NULL,
380 380
 					QST_ID INT UNSIGNED NOT NULL,
381 381
 					PRIMARY KEY  (QGQ_ID) ";
382
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
383
-        $table_name = 'esp_question_option';
384
-        $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
382
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
383
+		$table_name = 'esp_question_option';
384
+		$sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
385 385
 					QSO_value VARCHAR(255) NOT NULL,
386 386
 					QSO_desc TEXT NOT NULL,
387 387
 					QST_ID INT UNSIGNED NOT NULL,
388 388
 					QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
389 389
 					PRIMARY KEY  (QSO_ID)";
390
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
391
-        $table_name = 'esp_registration';
392
-        $sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
390
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
391
+		$table_name = 'esp_registration';
392
+		$sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
393 393
 					  EVT_ID BIGINT(20) UNSIGNED NOT NULL,
394 394
 					  ATT_ID BIGINT(20) UNSIGNED NOT NULL,
395 395
 					  TXN_ID INT(10) UNSIGNED NOT NULL,
@@ -412,25 +412,25 @@  discard block
 block discarded – undo
412 412
 					  KEY STS_ID (STS_ID),
413 413
 					  KEY REG_url_link (REG_url_link),
414 414
 					  KEY REG_code (REG_code)";
415
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
416
-        $table_name = 'esp_checkin';
417
-        $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
415
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
416
+		$table_name = 'esp_checkin';
417
+		$sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
418 418
 					REG_ID INT(10) UNSIGNED NOT NULL,
419 419
 					DTT_ID INT(10) UNSIGNED NOT NULL,
420 420
 					CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
421 421
 					CHK_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
422 422
 					PRIMARY KEY  (CHK_ID)";
423
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
424
-        $table_name = 'esp_state';
425
-        $sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT,
423
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
424
+		$table_name = 'esp_state';
425
+		$sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT,
426 426
 					  CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL,
427 427
 					  STA_abbrev VARCHAR(6) COLLATE utf8_bin NOT NULL,
428 428
 					  STA_name VARCHAR(100) COLLATE utf8_bin NOT NULL,
429 429
 					  STA_active TINYINT(1) DEFAULT '1',
430 430
 					  PRIMARY KEY  (STA_ID)";
431
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
432
-        $table_name = 'esp_status';
433
-        $sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL,
431
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
432
+		$table_name = 'esp_status';
433
+		$sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL,
434 434
 					  STS_code VARCHAR(45) COLLATE utf8_bin NOT NULL,
435 435
 					  STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL,
436 436
 					  STS_can_edit TINYINT(1) NOT NULL DEFAULT 0,
@@ -438,9 +438,9 @@  discard block
 block discarded – undo
438 438
 					  STS_open TINYINT(1) NOT NULL DEFAULT 1,
439 439
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
440 440
 					  KEY STS_type (STS_type)";
441
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
442
-        $table_name = 'esp_transaction';
443
-        $sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
441
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
442
+		$table_name = 'esp_transaction';
443
+		$sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
444 444
 					  TXN_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
445 445
 					  TXN_total DECIMAL(10,3) DEFAULT '0.00',
446 446
 					  TXN_paid DECIMAL(10,3) NOT NULL DEFAULT '0.00',
@@ -450,9 +450,9 @@  discard block
 block discarded – undo
450 450
 					  PRIMARY KEY  (TXN_ID),
451 451
 					  KEY TXN_timestamp (TXN_timestamp),
452 452
 					  KEY STS_ID (STS_ID)";
453
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
454
-        $table_name = 'esp_venue_meta';
455
-        $sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT,
453
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
454
+		$table_name = 'esp_venue_meta';
455
+		$sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT,
456 456
 			VNU_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
457 457
 			VNU_address VARCHAR(255) DEFAULT NULL,
458 458
 			VNU_address2 VARCHAR(255) DEFAULT NULL,
@@ -470,52 +470,52 @@  discard block
 block discarded – undo
470 470
 			PRIMARY KEY  (VNUM_ID),
471 471
 			KEY STA_ID (STA_ID),
472 472
 			KEY CNT_ISO (CNT_ISO)";
473
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
474
-        //setting up the DEFAULT stats and countries is also essential for the data migrations to run
475
-        //(because many need to convert old string states to foreign keys into the states table)
476
-        $this->insert_default_states();
477
-        $this->insert_default_countries();
478
-        //setting up DEFAULT prices, price types, and tickets is also essential for the price migrations
479
-        $this->insert_default_price_types();
480
-        $this->insert_default_prices();
481
-        $this->insert_default_tickets();
482
-        //setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
483
-        EE_Config::instance()->update_espresso_config(false, true);
484
-        return true;
485
-    }
486
-
487
-
488
-
489
-    /**
490
-     * Yes we could have cleaned up the ee3 tables here. But just in case someone
491
-     * didn't backup their DB, and decides they want ot keep using EE3, we'll
492
-     * leave them for now. Mayeb remove them in 4.5 or something.
493
-     *
494
-     * @return boolean
495
-     */
496
-    public function schema_changes_after_migration()
497
-    {
498
-        return true;
499
-    }
500
-
501
-
502
-
503
-    /**
504
-     * insert_default_states
505
-     *
506
-     * @access public
507
-     * @static
508
-     * @return void
509
-     */
510
-    public function insert_default_states()
511
-    {
512
-        global $wpdb;
513
-        $state_table = $wpdb->prefix . "esp_state";
514
-        if ($this->_get_table_analysis()->tableExists($state_table)) {
515
-            $SQL = "SELECT COUNT('STA_ID') FROM " . $state_table;
516
-            $states = $wpdb->get_var($SQL);
517
-            if ( ! $states) {
518
-                $SQL = "INSERT INTO " . $state_table . "
473
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
474
+		//setting up the DEFAULT stats and countries is also essential for the data migrations to run
475
+		//(because many need to convert old string states to foreign keys into the states table)
476
+		$this->insert_default_states();
477
+		$this->insert_default_countries();
478
+		//setting up DEFAULT prices, price types, and tickets is also essential for the price migrations
479
+		$this->insert_default_price_types();
480
+		$this->insert_default_prices();
481
+		$this->insert_default_tickets();
482
+		//setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
483
+		EE_Config::instance()->update_espresso_config(false, true);
484
+		return true;
485
+	}
486
+
487
+
488
+
489
+	/**
490
+	 * Yes we could have cleaned up the ee3 tables here. But just in case someone
491
+	 * didn't backup their DB, and decides they want ot keep using EE3, we'll
492
+	 * leave them for now. Mayeb remove them in 4.5 or something.
493
+	 *
494
+	 * @return boolean
495
+	 */
496
+	public function schema_changes_after_migration()
497
+	{
498
+		return true;
499
+	}
500
+
501
+
502
+
503
+	/**
504
+	 * insert_default_states
505
+	 *
506
+	 * @access public
507
+	 * @static
508
+	 * @return void
509
+	 */
510
+	public function insert_default_states()
511
+	{
512
+		global $wpdb;
513
+		$state_table = $wpdb->prefix . "esp_state";
514
+		if ($this->_get_table_analysis()->tableExists($state_table)) {
515
+			$SQL = "SELECT COUNT('STA_ID') FROM " . $state_table;
516
+			$states = $wpdb->get_var($SQL);
517
+			if ( ! $states) {
518
+				$SQL = "INSERT INTO " . $state_table . "
519 519
 				(STA_ID, CNT_ISO, STA_abbrev, STA_name, STA_active) VALUES
520 520
 				(1, 'US', 'AK', 'Alaska', 1),
521 521
 				(2, 'US', 'AL', 'Alabama', 1),
@@ -586,29 +586,29 @@  discard block
 block discarded – undo
586 586
 				(67, 'CA', 'PE', 'Prince Edward Island', 1),
587 587
 				(68, 'CA', 'QC', 'Quebec', 1),
588 588
 				(69, 'CA', 'SK', 'Saskatchewan', 1);";
589
-                $wpdb->query($SQL);
590
-            }
591
-        }
592
-    }
593
-
594
-
595
-
596
-    /**
597
-     * insert_default_countries
598
-     *
599
-     * @access public
600
-     * @static
601
-     * @return void
602
-     */
603
-    public function insert_default_countries()
604
-    {
605
-        global $wpdb;
606
-        $country_table = $wpdb->prefix . "esp_country";
607
-        if ($this->_get_table_analysis()->tableExists($country_table)) {
608
-            $SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table;
609
-            $countries = $wpdb->get_var($SQL);
610
-            if ( ! $countries) {
611
-                $SQL = "INSERT INTO " . $country_table . "
589
+				$wpdb->query($SQL);
590
+			}
591
+		}
592
+	}
593
+
594
+
595
+
596
+	/**
597
+	 * insert_default_countries
598
+	 *
599
+	 * @access public
600
+	 * @static
601
+	 * @return void
602
+	 */
603
+	public function insert_default_countries()
604
+	{
605
+		global $wpdb;
606
+		$country_table = $wpdb->prefix . "esp_country";
607
+		if ($this->_get_table_analysis()->tableExists($country_table)) {
608
+			$SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table;
609
+			$countries = $wpdb->get_var($SQL);
610
+			if ( ! $countries) {
611
+				$SQL = "INSERT INTO " . $country_table . "
612 612
 				(CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active) VALUES
613 613
 				('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
614 614
 				('AE', 'ARE', 0, 'United Arab Emirates', 'AED', 'Dirham', 'Dirhams', 'د.إ', 1, 2, '+971', 0, 0),
@@ -836,924 +836,924 @@  discard block
 block discarded – undo
836 836
 				('ZA', 'ZAF', 0, 'South Africa', 'ZAR', 'Rand', 'Rands', 'R', 1, 2, '+27', 0, 0),
837 837
 				('ZM', 'ZMB', 0, 'Zambia', 'ZMK', 'Kwacha', 'Kwachas', '', 1, 2, '+260', 0, 0),
838 838
 				('ZW', 'ZWE', 0, 'Zimbabwe', 'ZWD', 'Dollar', 'Dollars', 'Z$', 1, 2, '+263', 0, 0);";
839
-                $wpdb->query($SQL);
840
-            }
841
-        }
842
-    }
843
-
844
-
845
-
846
-    /**
847
-     * insert_default_price_types
848
-     *
849
-     * @access public
850
-     * @static
851
-     * @return void
852
-     */
853
-    public function insert_default_price_types()
854
-    {
855
-        global $wpdb;
856
-        $price_type_table = $wpdb->prefix . "esp_price_type";
857
-        if ($this->_get_table_analysis()->tableExists($price_type_table)) {
858
-            $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
859
-            $price_types_exist = $wpdb->get_var($SQL);
860
-            if ( ! $price_types_exist) {
861
-                $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES
839
+				$wpdb->query($SQL);
840
+			}
841
+		}
842
+	}
843
+
844
+
845
+
846
+	/**
847
+	 * insert_default_price_types
848
+	 *
849
+	 * @access public
850
+	 * @static
851
+	 * @return void
852
+	 */
853
+	public function insert_default_price_types()
854
+	{
855
+		global $wpdb;
856
+		$price_type_table = $wpdb->prefix . "esp_price_type";
857
+		if ($this->_get_table_analysis()->tableExists($price_type_table)) {
858
+			$SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
859
+			$price_types_exist = $wpdb->get_var($SQL);
860
+			if ( ! $price_types_exist) {
861
+				$SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES
862 862
 							(1, '" . __('Base Price', 'event_espresso') . "', 1,  0, 0, 0),
863 863
 							(2, '" . __('Percent Discount', 'event_espresso') . "', 2,  1, 20, 0),
864 864
 							(3, '" . __('Fixed Discount', 'event_espresso') . "', 2,  0, 30, 0),
865 865
 							(4, '" . __('Percent Surcharge', 'event_espresso') . "', 3,  1, 40, 0),
866 866
 							(5, '" . __('Fixed Surcharge', 'event_espresso') . "', 3,  0, 50, 0);";
867
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL);
868
-                $wpdb->query($SQL);
869
-            }
870
-        }
871
-    }
872
-
873
-
874
-
875
-    /**
876
-     * insert_default_prices. We assume we're upgrading to regular here.
877
-     * If we're INSTALLING 4.1 CAF, then we add a few extra DEFAULT prices
878
-     * when EEH_Activaion's initialize_db_content is called via  ahook in
879
-     * EE_BRewing_regular
880
-     *
881
-     * @access public
882
-     * @static
883
-     * @return void
884
-     */
885
-    public function insert_default_prices()
886
-    {
887
-        global $wpdb;
888
-        $price_table = $wpdb->prefix . "esp_price";
889
-        if ($this->_get_table_analysis()->tableExists($price_table)) {
890
-            $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table;
891
-            $prices_exist = $wpdb->get_var($SQL);
892
-            if ( ! $prices_exist) {
893
-                $SQL = "INSERT INTO $price_table
867
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL);
868
+				$wpdb->query($SQL);
869
+			}
870
+		}
871
+	}
872
+
873
+
874
+
875
+	/**
876
+	 * insert_default_prices. We assume we're upgrading to regular here.
877
+	 * If we're INSTALLING 4.1 CAF, then we add a few extra DEFAULT prices
878
+	 * when EEH_Activaion's initialize_db_content is called via  ahook in
879
+	 * EE_BRewing_regular
880
+	 *
881
+	 * @access public
882
+	 * @static
883
+	 * @return void
884
+	 */
885
+	public function insert_default_prices()
886
+	{
887
+		global $wpdb;
888
+		$price_table = $wpdb->prefix . "esp_price";
889
+		if ($this->_get_table_analysis()->tableExists($price_table)) {
890
+			$SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table;
891
+			$prices_exist = $wpdb->get_var($SQL);
892
+			if ( ! $prices_exist) {
893
+				$SQL = "INSERT INTO $price_table
894 894
 							(PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc,  PRC_is_default, PRC_overrides, PRC_order, PRC_deleted, PRC_parent ) VALUES
895 895
 							(1, 1, '0.00', 'Free Admission', '', 1, NULL, 0, 0, 0);";
896
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL);
897
-                $wpdb->query($SQL);
898
-            }
899
-        }
900
-    }
901
-
902
-
903
-
904
-    /**
905
-     * insert DEFAULT ticket
906
-     *
907
-     * @access public
908
-     * @static
909
-     * @return void
910
-     */
911
-    public function insert_default_tickets()
912
-    {
913
-        global $wpdb;
914
-        $ticket_table = $wpdb->prefix . "esp_ticket";
915
-        if ($this->_get_table_analysis()->tableExists($ticket_table)) {
916
-            $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
917
-            $tickets_exist = $wpdb->get_var($SQL);
918
-            if ( ! $tickets_exist) {
919
-                $SQL = "INSERT INTO $ticket_table
896
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL);
897
+				$wpdb->query($SQL);
898
+			}
899
+		}
900
+	}
901
+
902
+
903
+
904
+	/**
905
+	 * insert DEFAULT ticket
906
+	 *
907
+	 * @access public
908
+	 * @static
909
+	 * @return void
910
+	 */
911
+	public function insert_default_tickets()
912
+	{
913
+		global $wpdb;
914
+		$ticket_table = $wpdb->prefix . "esp_ticket";
915
+		if ($this->_get_table_analysis()->tableExists($ticket_table)) {
916
+			$SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
917
+			$tickets_exist = $wpdb->get_var($SQL);
918
+			if ( ! $tickets_exist) {
919
+				$SQL = "INSERT INTO $ticket_table
920 920
 					( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_deleted ) VALUES
921 921
 					( 1, 0, '"
922
-                       . __("Free Ticket", "event_espresso")
923
-                       . "', '', 100, 0, -1, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);";
924
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL);
925
-                $wpdb->query($SQL);
926
-            }
927
-        }
928
-        $ticket_price_table = $wpdb->prefix . "esp_ticket_price";
929
-        if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
930
-            $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
931
-            $ticket_prc_exist = $wpdb->get_var($SQL);
932
-            if ( ! $ticket_prc_exist) {
933
-                $SQL = "INSERT INTO $ticket_price_table
922
+					   . __("Free Ticket", "event_espresso")
923
+					   . "', '', 100, 0, -1, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);";
924
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL);
925
+				$wpdb->query($SQL);
926
+			}
927
+		}
928
+		$ticket_price_table = $wpdb->prefix . "esp_ticket_price";
929
+		if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
930
+			$SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
931
+			$ticket_prc_exist = $wpdb->get_var($SQL);
932
+			if ( ! $ticket_prc_exist) {
933
+				$SQL = "INSERT INTO $ticket_price_table
934 934
 				( TKP_ID, TKT_ID, PRC_ID ) VALUES
935 935
 				( 1, 1, 1 )
936 936
 				";
937
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL);
938
-                $wpdb->query($SQL);
939
-            }
940
-        }
941
-    }
942
-
943
-
944
-
945
-    /**
946
-     * Gets a country entry as an array, or creates one if none is found. Much like EEM_Country::instance()->get_one(),
947
-     * but is independent of outside code which can change in future versions of EE. Also, $country_name CAN be a 3.1
948
-     * country ID (int), a 2-letter ISO, 3-letter ISO, or name
949
-     *
950
-     * @global type  $wpdb
951
-     * @param string $country_name
952
-     * @return array where keys are columns, values are column values
953
-     */
954
-    public function get_or_create_country($country_name)
955
-    {
956
-        if ( ! $country_name) {
957
-            throw new EE_Error(__("Could not get a country because country name is blank", "event_espresso"));
958
-        }
959
-        global $wpdb;
960
-        $country_table = $wpdb->prefix . "esp_country";
961
-        if (is_int($country_name)) {
962
-            $country_name = $this->get_iso_from_3_1_country_id($country_name);
963
-        }
964
-        $country = $wpdb->get_row($wpdb->prepare("SELECT * FROM $country_table WHERE
937
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL);
938
+				$wpdb->query($SQL);
939
+			}
940
+		}
941
+	}
942
+
943
+
944
+
945
+	/**
946
+	 * Gets a country entry as an array, or creates one if none is found. Much like EEM_Country::instance()->get_one(),
947
+	 * but is independent of outside code which can change in future versions of EE. Also, $country_name CAN be a 3.1
948
+	 * country ID (int), a 2-letter ISO, 3-letter ISO, or name
949
+	 *
950
+	 * @global type  $wpdb
951
+	 * @param string $country_name
952
+	 * @return array where keys are columns, values are column values
953
+	 */
954
+	public function get_or_create_country($country_name)
955
+	{
956
+		if ( ! $country_name) {
957
+			throw new EE_Error(__("Could not get a country because country name is blank", "event_espresso"));
958
+		}
959
+		global $wpdb;
960
+		$country_table = $wpdb->prefix . "esp_country";
961
+		if (is_int($country_name)) {
962
+			$country_name = $this->get_iso_from_3_1_country_id($country_name);
963
+		}
964
+		$country = $wpdb->get_row($wpdb->prepare("SELECT * FROM $country_table WHERE
965 965
 			CNT_ISO LIKE %s OR
966 966
 			CNT_ISO3 LIKE %s OR
967 967
 			CNT_name LIKE %s LIMIT 1", $country_name, $country_name, $country_name), ARRAY_A);
968
-        if ( ! $country) {
969
-            //insert a new one then
970
-            $cols_n_values = array(
971
-                    'CNT_ISO'         => $this->_find_available_country_iso(2),
972
-                    'CNT_ISO3'        => $this->_find_available_country_iso(3),
973
-                    'RGN_ID'          => 0,
974
-                    'CNT_name'        => $country_name,
975
-                    'CNT_cur_code'    => 'USD',
976
-                    'CNT_cur_single'  => 'Dollar',
977
-                    'CNT_cur_plural'  => 'Dollars',
978
-                    'CNT_cur_sign'    => '&#36;',
979
-                    'CNT_cur_sign_b4' => true,
980
-                    'CNT_cur_dec_plc' => 2,
981
-                    'CNT_cur_dec_mrk' => '.',
982
-                    'CNT_cur_thsnds'  => ',',
983
-                    'CNT_tel_code'    => '+1',
984
-                    'CNT_is_EU'       => false,
985
-                    'CNT_active'      => true,
986
-            );
987
-            $data_types = array(
988
-                    '%s',//CNT_ISO
989
-                    '%s',//CNT_ISO3
990
-                    '%d',//RGN_ID
991
-                    '%s',//CNT_name
992
-                    '%s',//CNT_cur_code
993
-                    '%s',//CNT_cur_single
994
-                    '%s',//CNT_cur_plural
995
-                    '%s',//CNT_cur_sign
996
-                    '%d',//CNT_cur_sign_b4
997
-                    '%d',//CNT_cur_dec_plc
998
-                    '%s',//CNT_cur_dec_mrk
999
-                    '%s',//CNT_cur_thsnds
1000
-                    '%s',//CNT_tel_code
1001
-                    '%d',//CNT_is_EU
1002
-                    '%d',//CNT_active
1003
-            );
1004
-            $success = $wpdb->insert($country_table,
1005
-                    $cols_n_values,
1006
-                    $data_types);
1007
-            if ( ! $success) {
1008
-                throw new EE_Error($this->_create_error_message_for_db_insertion('N/A',
1009
-                        array('country_id' => $country_name), $country_table, $cols_n_values, $data_types));
1010
-            }
1011
-            $country = $cols_n_values;
1012
-        }
1013
-        return $country;
1014
-    }
1015
-
1016
-
1017
-
1018
-    /**
1019
-     * finds a country iso which hasnt been used yet
1020
-     *
1021
-     * @global type $wpdb
1022
-     * @return string
1023
-     */
1024
-    private function _find_available_country_iso($num_letters = 2)
1025
-    {
1026
-        global $wpdb;
1027
-        $country_table = $wpdb->prefix . "esp_country";
1028
-        $attempts = 0;
1029
-        do {
1030
-            $current_iso = strtoupper(wp_generate_password($num_letters, false));
1031
-            $country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM "
1032
-                                                                   . $country_table
1033
-                                                                   . " WHERE CNT_ISO=%s", $current_iso));
1034
-            $attempts++;
1035
-            //keep going until we find an available country code, or we arbitrarily
1036
-            //decide we've tried this enough. Somehow they have way too many countries
1037
-            //(probably because they're mis-using the EE3 country_id like a custom question)
1038
-        } while (intval($country_with_that_iso) && $attempts < 200);
1039
-        return $current_iso;
1040
-    }
1041
-
1042
-
1043
-
1044
-    /**
1045
-     * Gets a state entry as an array, or creates one if none is found. Much like EEM_State::instance()->get_one(), but
1046
-     * is independent of outside code which can change in future versions of EE
1047
-     *
1048
-     * @global type  $wpdb
1049
-     * @param string $state_name
1050
-     * @return array where keys are columns, values are column values
1051
-     */
1052
-    public function get_or_create_state($state_name, $country_name = '')
1053
-    {
1054
-        if ( ! $state_name) {
1055
-            throw new EE_Error(__("Could not get-or-create state because no state name was provided",
1056
-                    "event_espresso"));
1057
-        }
1058
-        try {
1059
-            $country = $this->get_or_create_country($country_name);
1060
-            $country_iso = $country['CNT_ISO'];
1061
-        } catch (EE_Error $e) {
1062
-            $country_iso = $this->get_default_country_iso();
1063
-        }
1064
-        global $wpdb;
1065
-        $state_table = $wpdb->prefix . "esp_state";
1066
-        $state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE
968
+		if ( ! $country) {
969
+			//insert a new one then
970
+			$cols_n_values = array(
971
+					'CNT_ISO'         => $this->_find_available_country_iso(2),
972
+					'CNT_ISO3'        => $this->_find_available_country_iso(3),
973
+					'RGN_ID'          => 0,
974
+					'CNT_name'        => $country_name,
975
+					'CNT_cur_code'    => 'USD',
976
+					'CNT_cur_single'  => 'Dollar',
977
+					'CNT_cur_plural'  => 'Dollars',
978
+					'CNT_cur_sign'    => '&#36;',
979
+					'CNT_cur_sign_b4' => true,
980
+					'CNT_cur_dec_plc' => 2,
981
+					'CNT_cur_dec_mrk' => '.',
982
+					'CNT_cur_thsnds'  => ',',
983
+					'CNT_tel_code'    => '+1',
984
+					'CNT_is_EU'       => false,
985
+					'CNT_active'      => true,
986
+			);
987
+			$data_types = array(
988
+					'%s',//CNT_ISO
989
+					'%s',//CNT_ISO3
990
+					'%d',//RGN_ID
991
+					'%s',//CNT_name
992
+					'%s',//CNT_cur_code
993
+					'%s',//CNT_cur_single
994
+					'%s',//CNT_cur_plural
995
+					'%s',//CNT_cur_sign
996
+					'%d',//CNT_cur_sign_b4
997
+					'%d',//CNT_cur_dec_plc
998
+					'%s',//CNT_cur_dec_mrk
999
+					'%s',//CNT_cur_thsnds
1000
+					'%s',//CNT_tel_code
1001
+					'%d',//CNT_is_EU
1002
+					'%d',//CNT_active
1003
+			);
1004
+			$success = $wpdb->insert($country_table,
1005
+					$cols_n_values,
1006
+					$data_types);
1007
+			if ( ! $success) {
1008
+				throw new EE_Error($this->_create_error_message_for_db_insertion('N/A',
1009
+						array('country_id' => $country_name), $country_table, $cols_n_values, $data_types));
1010
+			}
1011
+			$country = $cols_n_values;
1012
+		}
1013
+		return $country;
1014
+	}
1015
+
1016
+
1017
+
1018
+	/**
1019
+	 * finds a country iso which hasnt been used yet
1020
+	 *
1021
+	 * @global type $wpdb
1022
+	 * @return string
1023
+	 */
1024
+	private function _find_available_country_iso($num_letters = 2)
1025
+	{
1026
+		global $wpdb;
1027
+		$country_table = $wpdb->prefix . "esp_country";
1028
+		$attempts = 0;
1029
+		do {
1030
+			$current_iso = strtoupper(wp_generate_password($num_letters, false));
1031
+			$country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM "
1032
+																   . $country_table
1033
+																   . " WHERE CNT_ISO=%s", $current_iso));
1034
+			$attempts++;
1035
+			//keep going until we find an available country code, or we arbitrarily
1036
+			//decide we've tried this enough. Somehow they have way too many countries
1037
+			//(probably because they're mis-using the EE3 country_id like a custom question)
1038
+		} while (intval($country_with_that_iso) && $attempts < 200);
1039
+		return $current_iso;
1040
+	}
1041
+
1042
+
1043
+
1044
+	/**
1045
+	 * Gets a state entry as an array, or creates one if none is found. Much like EEM_State::instance()->get_one(), but
1046
+	 * is independent of outside code which can change in future versions of EE
1047
+	 *
1048
+	 * @global type  $wpdb
1049
+	 * @param string $state_name
1050
+	 * @return array where keys are columns, values are column values
1051
+	 */
1052
+	public function get_or_create_state($state_name, $country_name = '')
1053
+	{
1054
+		if ( ! $state_name) {
1055
+			throw new EE_Error(__("Could not get-or-create state because no state name was provided",
1056
+					"event_espresso"));
1057
+		}
1058
+		try {
1059
+			$country = $this->get_or_create_country($country_name);
1060
+			$country_iso = $country['CNT_ISO'];
1061
+		} catch (EE_Error $e) {
1062
+			$country_iso = $this->get_default_country_iso();
1063
+		}
1064
+		global $wpdb;
1065
+		$state_table = $wpdb->prefix . "esp_state";
1066
+		$state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE
1067 1067
 			(STA_abbrev LIKE %s OR
1068 1068
 			STA_name LIKE %s) AND
1069 1069
 			CNT_ISO LIKE %s LIMIT 1", $state_name, $state_name, $country_iso), ARRAY_A);
1070
-        if ( ! $state) {
1071
-            //insert a new one then
1072
-            $cols_n_values = array(
1073
-                    'CNT_ISO'    => $country_iso,
1074
-                    'STA_abbrev' => substr($state_name, 0, 6),
1075
-                    'STA_name'   => $state_name,
1076
-                    'STA_active' => true,
1077
-            );
1078
-            $data_types = array(
1079
-                    '%s',//CNT_ISO
1080
-                    '%s',//STA_abbrev
1081
-                    '%s',//STA_name
1082
-                    '%d',//STA_active
1083
-            );
1084
-            $success = $wpdb->insert($state_table, $cols_n_values, $data_types);
1085
-            if ( ! $success) {
1086
-                throw new EE_Error($this->_create_error_message_for_db_insertion('N/A',
1087
-                        array('state' => $state_name, 'country_id' => $country_name), $state_table, $cols_n_values,
1088
-                        $data_types));
1089
-            }
1090
-            $state = $cols_n_values;
1091
-            $state['STA_ID'] = $wpdb->insert_id;
1092
-        }
1093
-        return $state;
1094
-    }
1095
-
1096
-
1097
-
1098
-    /**
1099
-     * Fixes times like "5:00 PM" into the expected 24-hour format "17:00".
1100
-     * THis is actually just copied from the 3.1 JSON API because it needed to do the exact same thing
1101
-     *
1102
-     * @param type $timeString
1103
-     * @return string in the php DATETIME format: "G:i" (24-hour format hour with leading zeros, a colon, and minutes
1104
-     *                with leading zeros)
1105
-     */
1106
-    public function convertTimeFromAMPM($timeString)
1107
-    {
1108
-        $matches = array();
1109
-        preg_match("~(\\d*):(\\d*)~", $timeString, $matches);
1110
-        if ( ! $matches || count($matches) < 3) {
1111
-            $hour = '00';
1112
-            $minutes = '00';
1113
-        } else {
1114
-            $hour = intval($matches[1]);
1115
-            $minutes = $matches[2];
1116
-        }
1117
-        if (strpos($timeString, 'PM') || strpos($timeString, 'pm')) {
1118
-            $hour = intval($hour) + 12;
1119
-        }
1120
-        $hour = str_pad("$hour", 2, '0', STR_PAD_LEFT);
1121
-        $minutes = str_pad("$minutes", 2, '0', STR_PAD_LEFT);
1122
-        return "$hour:$minutes";
1123
-    }
1124
-
1125
-
1126
-
1127
-    /**
1128
-     * Gets the ISO3 fora country given its 3.1 country ID.
1129
-     *
1130
-     * @param int $country_id
1131
-     * @return string the country's ISO3 code
1132
-     */
1133
-    public function get_iso_from_3_1_country_id($country_id)
1134
-    {
1135
-        $old_countries = array(
1136
-                array(64, 'United States', 'US', 'USA', 1),
1137
-                array(15, 'Australia', 'AU', 'AUS', 1),
1138
-                array(39, 'Canada', 'CA', 'CAN', 1),
1139
-                array(171, 'United Kingdom', 'GB', 'GBR', 1),
1140
-                array(70, 'France', 'FR', 'FRA', 2),
1141
-                array(111, 'Italy', 'IT', 'ITA', 2),
1142
-                array(63, 'Spain', 'ES', 'ESP', 2),
1143
-                array(1, 'Afghanistan', 'AF', 'AFG', 1),
1144
-                array(2, 'Albania', 'AL', 'ALB', 1),
1145
-                array(3, 'Germany', 'DE', 'DEU', 2),
1146
-                array(198, 'Switzerland', 'CH', 'CHE', 1),
1147
-                array(87, 'Netherlands', 'NL', 'NLD', 2),
1148
-                array(197, 'Sweden', 'SE', 'SWE', 1),
1149
-                array(230, 'Akrotiri and Dhekelia', 'CY', 'CYP', 2),
1150
-                array(4, 'Andorra', 'AD', 'AND', 2),
1151
-                array(5, 'Angola', 'AO', 'AGO', 1),
1152
-                array(6, 'Anguilla', 'AI', 'AIA', 1),
1153
-                array(7, 'Antarctica', 'AQ', 'ATA', 1),
1154
-                array(8, 'Antigua and Barbuda', 'AG', 'ATG', 1),
1155
-                array(10, 'Saudi Arabia', 'SA', 'SAU', 1),
1156
-                array(11, 'Algeria', 'DZ', 'DZA', 1),
1157
-                array(12, 'Argentina', 'AR', 'ARG', 1),
1158
-                array(13, 'Armenia', 'AM', 'ARM', 1),
1159
-                array(14, 'Aruba', 'AW', 'ABW', 1),
1160
-                array(16, 'Austria', 'AT', 'AUT', 2),
1161
-                array(17, 'Azerbaijan', 'AZ', 'AZE', 1),
1162
-                array(18, 'Bahamas', 'BS', 'BHS', 1),
1163
-                array(19, 'Bahrain', 'BH', 'BHR', 1),
1164
-                array(20, 'Bangladesh', 'BD', 'BGD', 1),
1165
-                array(21, 'Barbados', 'BB', 'BRB', 1),
1166
-                array(22, 'Belgium ', 'BE', 'BEL', 2),
1167
-                array(23, 'Belize', 'BZ', 'BLZ', 1),
1168
-                array(24, 'Benin', 'BJ', 'BEN', 1),
1169
-                array(25, 'Bermudas', 'BM', 'BMU', 1),
1170
-                array(26, 'Belarus', 'BY', 'BLR', 1),
1171
-                array(27, 'Bolivia', 'BO', 'BOL', 1),
1172
-                array(28, 'Bosnia and Herzegovina', 'BA', 'BIH', 1),
1173
-                array(29, 'Botswana', 'BW', 'BWA', 1),
1174
-                array(96, 'Bouvet Island', 'BV', 'BVT', 1),
1175
-                array(30, 'Brazil', 'BR', 'BRA', 1),
1176
-                array(31, 'Brunei', 'BN', 'BRN', 1),
1177
-                array(32, 'Bulgaria', 'BG', 'BGR', 1),
1178
-                array(33, 'Burkina Faso', 'BF', 'BFA', 1),
1179
-                array(34, 'Burundi', 'BI', 'BDI', 1),
1180
-                array(35, 'Bhutan', 'BT', 'BTN', 1),
1181
-                array(36, 'Cape Verde', 'CV', 'CPV', 1),
1182
-                array(37, 'Cambodia', 'KH', 'KHM', 1),
1183
-                array(38, 'Cameroon', 'CM', 'CMR', 1),
1184
-                array(98, 'Cayman Islands', 'KY', 'CYM', 1),
1185
-                array(172, 'Central African Republic', 'CF', 'CAF', 1),
1186
-                array(40, 'Chad', 'TD', 'TCD', 1),
1187
-                array(41, 'Chile', 'CL', 'CHL', 1),
1188
-                array(42, 'China', 'CN', 'CHN', 1),
1189
-                array(105, 'Christmas Island', 'CX', 'CXR', 1),
1190
-                array(43, 'Cyprus', 'CY', 'CYP', 2),
1191
-                array(99, 'Cocos Island', 'CC', 'CCK', 1),
1192
-                array(100, 'Cook Islands', 'CK', 'COK', 1),
1193
-                array(44, 'Colombia', 'CO', 'COL', 1),
1194
-                array(45, 'Comoros', 'KM', 'COM', 1),
1195
-                array(46, 'Congo', 'CG', 'COG', 1),
1196
-                array(47, 'North Korea', 'KP', 'PRK', 1),
1197
-                array(50, 'Costa Rica', 'CR', 'CRI', 1),
1198
-                array(51, 'Croatia', 'HR', 'HRV', 1),
1199
-                array(52, 'Cuba', 'CU', 'CUB', 1),
1200
-                array(173, 'Czech Republic', 'CZ', 'CZE', 1),
1201
-                array(53, 'Denmark', 'DK', 'DNK', 1),
1202
-                array(54, 'Djibouti', 'DJ', 'DJI', 1),
1203
-                array(55, 'Dominica', 'DM', 'DMA', 1),
1204
-                array(174, 'Dominican Republic', 'DO', 'DOM', 1),
1205
-                array(56, 'Ecuador', 'EC', 'ECU', 1),
1206
-                array(57, 'Egypt', 'EG', 'EGY', 1),
1207
-                array(58, 'El Salvador', 'SV', 'SLV', 1),
1208
-                array(60, 'Eritrea', 'ER', 'ERI', 1),
1209
-                array(61, 'Slovakia', 'SK', 'SVK', 2),
1210
-                array(62, 'Slovenia', 'SI', 'SVN', 2),
1211
-                array(65, 'Estonia', 'EE', 'EST', 2),
1212
-                array(66, 'Ethiopia', 'ET', 'ETH', 1),
1213
-                array(102, 'Faroe islands', 'FO', 'FRO', 1),
1214
-                array(103, 'Falkland Islands', 'FK', 'FLK', 1),
1215
-                array(67, 'Fiji', 'FJ', 'FJI', 1),
1216
-                array(69, 'Finland', 'FI', 'FIN', 2),
1217
-                array(71, 'Gabon', 'GA', 'GAB', 1),
1218
-                array(72, 'Gambia', 'GM', 'GMB', 1),
1219
-                array(73, 'Georgia', 'GE', 'GEO', 1),
1220
-                array(74, 'Ghana', 'GH', 'GHA', 1),
1221
-                array(75, 'Gibraltar', 'GI', 'GIB', 1),
1222
-                array(76, 'Greece', 'GR', 'GRC', 2),
1223
-                array(77, 'Grenada', 'GD', 'GRD', 1),
1224
-                array(78, 'Greenland', 'GL', 'GRL', 1),
1225
-                array(79, 'Guadeloupe', 'GP', 'GLP', 1),
1226
-                array(80, 'Guam', 'GU', 'GUM', 1),
1227
-                array(81, 'Guatemala', 'GT', 'GTM', 1),
1228
-                array(82, 'Guinea', 'GN', 'GIN', 1),
1229
-                array(83, 'Equatorial Guinea', 'GQ', 'GNQ', 1),
1230
-                array(84, 'Guinea-Bissau', 'GW', 'GNB', 1),
1231
-                array(85, 'Guyana', 'GY', 'GUY', 1),
1232
-                array(86, 'Haiti', 'HT', 'HTI', 1),
1233
-                array(88, 'Honduras', 'HN', 'HND', 1),
1234
-                array(89, 'Hong Kong', 'HK', 'HKG', 1),
1235
-                array(90, 'Hungary', 'HU', 'HUN', 1),
1236
-                array(91, 'India', 'IN', 'IND', 1),
1237
-                array(205, 'British Indian Ocean Territory', 'IO', 'IOT', 1),
1238
-                array(92, 'Indonesia', 'ID', 'IDN', 1),
1239
-                array(93, 'Iraq', 'IQ', 'IRQ', 1),
1240
-                array(94, 'Iran', 'IR', 'IRN', 1),
1241
-                array(95, 'Ireland', 'IE', 'IRL', 2),
1242
-                array(97, 'Iceland', 'IS', 'ISL', 1),
1243
-                array(110, 'Israel', 'IL', 'ISR', 1),
1244
-                array(49, 'Ivory Coast ', 'CI', 'CIV', 1),
1245
-                array(112, 'Jamaica', 'JM', 'JAM', 1),
1246
-                array(113, 'Japan', 'JP', 'JPN', 1),
1247
-                array(114, 'Jordan', 'JO', 'JOR', 1),
1248
-                array(115, 'Kazakhstan', 'KZ', 'KAZ', 1),
1249
-                array(116, 'Kenya', 'KE', 'KEN', 1),
1250
-                array(117, 'Kyrgyzstan', 'KG', 'KGZ', 1),
1251
-                array(118, 'Kiribati', 'KI', 'KIR', 1),
1252
-                array(48, 'South Korea', 'KR', 'KOR', 1),
1253
-                array(228, 'Kosovo', 'XK', 'XKV', 2),
1254
-                // there is no official ISO code for Kosovo yet (http://geonames.wordpress.com/2010/03/08/xk-country-code-for-kosovo/) so using a temporary country code and a modified 3 character code for ISO code -- this should be updated if/when Kosovo gets its own ISO code
1255
-                array(119, 'Kuwait', 'KW', 'KWT', 1),
1256
-                array(120, 'Laos', 'LA', 'LAO', 1),
1257
-                array(121, 'Latvia', 'LV', 'LVA', 2),
1258
-                array(122, 'Lesotho', 'LS', 'LSO', 1),
1259
-                array(123, 'Lebanon', 'LB', 'LBN', 1),
1260
-                array(124, 'Liberia', 'LR', 'LBR', 1),
1261
-                array(125, 'Libya', 'LY', 'LBY', 1),
1262
-                array(126, 'Liechtenstein', 'LI', 'LIE', 1),
1263
-                array(127, 'Lithuania', 'LT', 'LTU', 2),
1264
-                array(128, 'Luxemburg', 'LU', 'LUX', 2),
1265
-                array(129, 'Macao', 'MO', 'MAC', 1),
1266
-                array(130, 'Macedonia', 'MK', 'MKD', 1),
1267
-                array(131, 'Madagascar', 'MG', 'MDG', 1),
1268
-                array(132, 'Malaysia', 'MY', 'MYS', 1),
1269
-                array(133, 'Malawi', 'MW', 'MWI', 1),
1270
-                array(134, 'Maldivas', 'MV', 'MDV', 1),
1271
-                array(135, 'Mali', 'ML', 'MLI', 1),
1272
-                array(136, 'Malta', 'MT', 'MLT', 2),
1273
-                array(101, 'Northern Marianas', 'MP', 'MNP', 1),
1274
-                array(137, 'Morocco', 'MA', 'MAR', 1),
1275
-                array(104, 'Marshall islands', 'MH', 'MHL', 1),
1276
-                array(138, 'Martinique', 'MQ', 'MTQ', 1),
1277
-                array(139, 'Mauritius', 'MU', 'MUS', 1),
1278
-                array(140, 'Mauritania', 'MR', 'MRT', 1),
1279
-                array(141, 'Mayote', 'YT', 'MYT', 2),
1280
-                array(142, 'Mexico', 'MX', 'MEX', 1),
1281
-                array(143, 'Micronesia', 'FM', 'FSM', 1),
1282
-                array(144, 'Moldova', 'MD', 'MDA', 1),
1283
-                array(145, 'Monaco', 'MC', 'MCO', 2),
1284
-                array(146, 'Mongolia', 'MN', 'MNG', 1),
1285
-                array(147, 'Montserrat', 'MS', 'MSR', 1),
1286
-                array(227, 'Montenegro', 'ME', 'MNE', 2),
1287
-                array(148, 'Mozambique', 'MZ', 'MOZ', 1),
1288
-                array(149, 'Myanmar', 'MM', 'MMR', 1),
1289
-                array(150, 'Namibia', 'NA', 'NAM', 1),
1290
-                array(151, 'Nauru', 'NR', 'NRU', 1),
1291
-                array(152, 'Nepal', 'NP', 'NPL', 1),
1292
-                array(9, 'Netherlands Antilles', 'AN', 'ANT', 1),
1293
-                array(153, 'Nicaragua', 'NI', 'NIC', 1),
1294
-                array(154, 'Niger', 'NE', 'NER', 1),
1295
-                array(155, 'Nigeria', 'NG', 'NGA', 1),
1296
-                array(156, 'Niue', 'NU', 'NIU', 1),
1297
-                array(157, 'Norway', 'NO', 'NOR', 1),
1298
-                array(158, 'New Caledonia', 'NC', 'NCL', 1),
1299
-                array(159, 'New Zealand', 'NZ', 'NZL', 1),
1300
-                array(160, 'Oman', 'OM', 'OMN', 1),
1301
-                array(161, 'Pakistan', 'PK', 'PAK', 1),
1302
-                array(162, 'Palau', 'PW', 'PLW', 1),
1303
-                array(163, 'Panama', 'PA', 'PAN', 1),
1304
-                array(164, 'Papua New Guinea', 'PG', 'PNG', 1),
1305
-                array(165, 'Paraguay', 'PY', 'PRY', 1),
1306
-                array(166, 'Peru', 'PE', 'PER', 1),
1307
-                array(68, 'Philippines', 'PH', 'PHL', 1),
1308
-                array(167, 'Poland', 'PL', 'POL', 1),
1309
-                array(168, 'Portugal', 'PT', 'PRT', 2),
1310
-                array(169, 'Puerto Rico', 'PR', 'PRI', 1),
1311
-                array(170, 'Qatar', 'QA', 'QAT', 1),
1312
-                array(176, 'Rwanda', 'RW', 'RWA', 1),
1313
-                array(177, 'Romania', 'RO', 'ROM', 2),
1314
-                array(178, 'Russia', 'RU', 'RUS', 1),
1315
-                array(229, 'Saint Pierre and Miquelon', 'PM', 'SPM', 2),
1316
-                array(180, 'Samoa', 'WS', 'WSM', 1),
1317
-                array(181, 'American Samoa', 'AS', 'ASM', 1),
1318
-                array(183, 'San Marino', 'SM', 'SMR', 2),
1319
-                array(184, 'Saint Vincent and the Grenadines', 'VC', 'VCT', 1),
1320
-                array(185, 'Saint Helena', 'SH', 'SHN', 1),
1321
-                array(186, 'Saint Lucia', 'LC', 'LCA', 1),
1322
-                array(188, 'Senegal', 'SN', 'SEN', 1),
1323
-                array(189, 'Seychelles', 'SC', 'SYC', 1),
1324
-                array(190, 'Sierra Leona', 'SL', 'SLE', 1),
1325
-                array(191, 'Singapore', 'SG', 'SGP', 1),
1326
-                array(192, 'Syria', 'SY', 'SYR', 1),
1327
-                array(193, 'Somalia', 'SO', 'SOM', 1),
1328
-                array(194, 'Sri Lanka', 'LK', 'LKA', 1),
1329
-                array(195, 'South Africa', 'ZA', 'ZAF', 1),
1330
-                array(196, 'Sudan', 'SD', 'SDN', 1),
1331
-                array(199, 'Suriname', 'SR', 'SUR', 1),
1332
-                array(200, 'Swaziland', 'SZ', 'SWZ', 1),
1333
-                array(201, 'Thailand', 'TH', 'THA', 1),
1334
-                array(202, 'Taiwan', 'TW', 'TWN', 1),
1335
-                array(203, 'Tanzania', 'TZ', 'TZA', 1),
1336
-                array(204, 'Tajikistan', 'TJ', 'TJK', 1),
1337
-                array(206, 'Timor-Leste', 'TL', 'TLS', 1),
1338
-                array(207, 'Togo', 'TG', 'TGO', 1),
1339
-                array(208, 'Tokelau', 'TK', 'TKL', 1),
1340
-                array(209, 'Tonga', 'TO', 'TON', 1),
1341
-                array(210, 'Trinidad and Tobago', 'TT', 'TTO', 1),
1342
-                array(211, 'Tunisia', 'TN', 'TUN', 1),
1343
-                array(212, 'Turkmenistan', 'TM', 'TKM', 1),
1344
-                array(213, 'Turkey', 'TR', 'TUR', 1),
1345
-                array(214, 'Tuvalu', 'TV', 'TUV', 1),
1346
-                array(215, 'Ukraine', 'UA', 'UKR', 1),
1347
-                array(216, 'Uganda', 'UG', 'UGA', 1),
1348
-                array(59, 'United Arab Emirates', 'AE', 'ARE', 1),
1349
-                array(217, 'Uruguay', 'UY', 'URY', 1),
1350
-                array(218, 'Uzbekistan', 'UZ', 'UZB', 1),
1351
-                array(219, 'Vanuatu', 'VU', 'VUT', 1),
1352
-                array(220, 'Vatican City', 'VA', 'VAT', 2),
1353
-                array(221, 'Venezuela', 'VE', 'VEN', 1),
1354
-                array(222, 'Vietnam', 'VN', 'VNM', 1),
1355
-                array(108, 'Virgin Islands', 'VI', 'VIR', 1),
1356
-                array(223, 'Yemen', 'YE', 'YEM', 1),
1357
-                array(225, 'Zambia', 'ZM', 'ZMB', 1),
1358
-                array(226, 'Zimbabwe', 'ZW', 'ZWE', 1),
1359
-        );
1360
-        $country_iso = 'US';
1361
-        foreach ($old_countries as $country_array) {
1362
-            //note: index 0 is the 3.1 country ID
1363
-            if ($country_array[0] == $country_id) {
1364
-                //note: index 2 is the ISO
1365
-                $country_iso = $country_array[2];
1366
-                break;
1367
-            }
1368
-        }
1369
-        return $country_iso;
1370
-    }
1371
-
1372
-
1373
-
1374
-    /**
1375
-     * Gets the ISO3 for the
1376
-     *
1377
-     * @return string
1378
-     */
1379
-    public function get_default_country_iso()
1380
-    {
1381
-        $old_org_options = get_option('events_organization_settings');
1382
-        $iso = $this->get_iso_from_3_1_country_id($old_org_options['organization_country']);
1383
-        return $iso;
1384
-    }
1385
-
1386
-
1387
-
1388
-    /**
1389
-     * Converst a 3.1 payment status to its equivalent 4.1 regisration status
1390
-     *
1391
-     * @param string  $payment_status                   possible value for 3.1's evens_attendee.payment_status
1392
-     * @param boolean $this_thing_required_pre_approval whether the thing we're considering (the general setting's
1393
-     *                                                  DEFAULT payment status, the event's DEFAULT payment status, or
1394
-     *                                                  the attendee's payment status) required pre-approval.
1395
-     * @return string STS_ID for use in 4.1
1396
-     */
1397
-    public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false)
1398
-    {
1399
-        //EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455
1400
-        if ($this_thing_required_pre_approval) {
1401
-            return 'RNA';
1402
-        } else {
1403
-            $mapping = $default_reg_stati_conversions = array(
1404
-                    'Completed'        => 'RAP',
1405
-                    ''                 => 'RPP',
1406
-                    'Incomplete'       => 'RPP',
1407
-                    'Pending'          => 'RAP',
1408
-                    //stati that only occurred on 3.1 attendees:
1409
-                    'Payment Declined' => 'RPP',
1410
-                    'Not Completed'    => 'RPP',
1411
-                    'Cancelled'        => 'RPP',
1412
-                    'Declined'         => 'RPP',
1413
-            );
1414
-        }
1415
-        return isset($mapping[$payment_status]) ? $mapping[$payment_status] : 'RNA';
1416
-    }
1417
-
1418
-
1419
-
1420
-    /**
1421
-     * Makes sure the 3.1's image url is converted to an image attachment post to the 4.1 CPT event
1422
-     * and sets it as the featured image on the CPT event
1423
-     *
1424
-     * @param type                            $old_event
1425
-     * @param type                            $new_cpt_id
1426
-     * @param  EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added
1427
-     * @return boolean whether or not we had to do the big job of creating an image attachment
1428
-     */
1429
-    public function convert_image_url_to_attachment_and_attach_to_post(
1430
-            $guid,
1431
-            $new_cpt_id,
1432
-            EE_Data_Migration_Script_Stage $migration_stage
1433
-    ) {
1434
-        $created_attachment_post = false;
1435
-        $guid = $this->_get_original_guid($guid);
1436
-        if ($guid) {
1437
-            //check for an existing attachment post with this guid
1438
-            $attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid);
1439
-            if ( ! $attachment_post_id) {
1440
-                //post thumbnail with that GUID doesn't exist, we should create one
1441
-                $attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage);
1442
-                $created_attachment_post = true;
1443
-            }
1444
-            //double-check we actually have an attachment post
1445
-            if ($attachment_post_id) {
1446
-                update_post_meta($new_cpt_id, '_thumbnail_id', $attachment_post_id);
1447
-            } else {
1448
-                $migration_stage->add_error(sprintf(__("Could not update event image %s for CPT with ID %d, but attachments post ID is %d",
1449
-                        "event_espresso"), $guid, $new_cpt_id, $attachment_post_id));
1450
-            }
1451
-        }
1452
-        return $created_attachment_post;
1453
-    }
1454
-
1455
-
1456
-
1457
-    /**
1458
-     * In 3.1, the event thumbnail image DOESN'T point to the orignal image, but instead
1459
-     * to a large thumbnail (which has nearly the same GUID, except it adds "-{width}x{height}" before the filetype,
1460
-     * or whatever dimensions it is. Eg 'http://mysite.com/image1-300x400.jpg' instead of
1461
-     * 'http://mysite.com/image1.jpg' ). This function attempts to strip that off and get the original file, if it
1462
-     * exists
1463
-     *
1464
-     * @param string $guid_in_old_event
1465
-     * @return string either the original guid, or $guid_in_old_event if we couldn't figure out what the original was
1466
-     */
1467
-    private function _get_original_guid($guid_in_old_event)
1468
-    {
1469
-        $original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1);
1470
-        //do a head request to verify the file exists
1471
-        $head_response = wp_remote_head($original_guid);
1472
-        if ( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') {
1473
-            return $original_guid;
1474
-        } else {
1475
-            return $guid_in_old_event;
1476
-        }
1477
-    }
1478
-
1479
-
1480
-
1481
-    /**
1482
-     * Creates an image attachment post for the GUID. If the GUID points to a remote image,
1483
-     * we download it to our uploads directory so that it can be properly processed (eg, creates different sizes of
1484
-     * thumbnails)
1485
-     *
1486
-     * @param type                           $guid
1487
-     * @param EE_Data_Migration_Script_Stage $migration_stage
1488
-     * @return int
1489
-     */
1490
-    private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage)
1491
-    {
1492
-        if ( ! $guid) {
1493
-            $migration_stage->add_error(sprintf(__("Cannot create image attachment for a blank GUID!",
1494
-                    "event_espresso")));
1495
-            return 0;
1496
-        }
1497
-        $wp_filetype = wp_check_filetype(basename($guid), null);
1498
-        $wp_upload_dir = wp_upload_dir();
1499
-        //if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local
1500
-        if (strpos($guid, $wp_upload_dir['url']) === false) {
1501
-            //image is located remotely. download it and place it in the uploads directory
1502
-            if ( ! is_readable($guid)) {
1503
-                $migration_stage->add_error(sprintf(__("Could not create image attachment from non-existent file: %s",
1504
-                        "event_espresso"), $guid));
1505
-                return 0;
1506
-            }
1507
-            $contents = file_get_contents($guid);
1508
-            if ($contents === false) {
1509
-                $migration_stage->add_error(sprintf(__("Could not read image at %s, and therefore couldnt create an attachment post for it.",
1510
-                        "event_espresso"), $guid));
1511
-                return false;
1512
-            }
1513
-            $local_filepath = $wp_upload_dir['path'] . DS . basename($guid);
1514
-            $savefile = fopen($local_filepath, 'w');
1515
-            fwrite($savefile, $contents);
1516
-            fclose($savefile);
1517
-            $guid = str_replace($wp_upload_dir['path'], $wp_upload_dir['url'], $local_filepath);
1518
-        } else {
1519
-            $local_filepath = str_replace($wp_upload_dir['url'], $wp_upload_dir['path'], $guid);
1520
-        }
1521
-        $attachment = array(
1522
-                'guid'           => $guid,
1523
-                'post_mime_type' => $wp_filetype['type'],
1524
-                'post_title'     => preg_replace('/\.[^.]+$/', '', basename($guid)),
1525
-                'post_content'   => '',
1526
-                'post_status'    => 'inherit',
1527
-        );
1528
-        $attach_id = wp_insert_attachment($attachment, $guid);
1529
-        if ( ! $attach_id) {
1530
-            $migration_stage->add_error(sprintf(__("Could not create image attachment post from image '%s'. Attachment data was %s.",
1531
-                    "event_espresso"), $guid, $this->_json_encode($attachment)));
1532
-            return $attach_id;
1533
-        }
1534
-        // you must first include the image.php file
1535
-        // for the function wp_generate_attachment_metadata() to work
1536
-        require_once(ABSPATH . 'wp-admin/includes/image.php');
1537
-        $attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath);
1538
-        if ( ! $attach_data) {
1539
-            $migration_stage->add_error(sprintf(__("Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.",
1540
-                    "event_espresso"), $attach_id, $local_filepath, $guid));
1541
-            return $attach_id;
1542
-        }
1543
-        $metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data);
1544
-        if ( ! $metadata_save_result) {
1545
-            $migration_stage->add_error(sprintf(__("Could not update attachment metadata for attachment %d with data %s",
1546
-                    "event_espresso"), $attach_id, $this->_json_encode($attach_data)));
1547
-        }
1548
-        return $attach_id;
1549
-    }
1550
-
1551
-
1552
-
1553
-    /**
1554
-     * Finds the attachment post containing info about an image attachment given the GUID (link to the image itself),
1555
-     * and returns its ID.
1556
-     *
1557
-     * @global type  $wpdb
1558
-     * @param string $guid
1559
-     * @return int
1560
-     */
1561
-    private function _get_image_attachment_id_by_GUID($guid)
1562
-    {
1563
-        global $wpdb;
1564
-        $attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1", $guid));
1565
-        return $attachment_id;
1566
-    }
1567
-
1568
-
1569
-
1570
-    /**
1571
-     * Returns a mysql-formatted DATETIME in UTC time, given a $DATETIME_string
1572
-     * (and optionally a timezone; if none is given, the wp DEFAULT is used)
1573
-     *
1574
-     * @param EE_Data_Migration_Script_base $stage
1575
-     * @param array                         $row_of_data , the row from the DB (as an array) we're trying to find the
1576
-     *                                                   UTC time for
1577
-     * @param string                        $DATETIME_string
1578
-     * @param string                        $timezone
1579
-     * @return string
1580
-     */
1581
-    public function convert_date_string_to_utc(
1582
-            EE_Data_Migration_Script_Stage $stage,
1583
-            $row_of_data,
1584
-            $DATETIME_string,
1585
-            $timezone = null
1586
-    ) {
1587
-        $original_tz = $timezone;
1588
-        if ( ! $timezone) {
1589
-            $timezone = $this->_get_wp_timezone();
1590
-        }
1591
-        if ( ! $timezone) {
1592
-            $stage->add_error(sprintf(__("Could not find timezone given %s for %s", "event_espresso"), $original_tz,
1593
-                    $row_of_data));
1594
-            $timezone = 'UTC';
1595
-        }
1596
-        try {
1597
-            $date_obj = new DateTime($DATETIME_string, new DateTimeZone($timezone));
1598
-            $date_obj->setTimezone(new DateTimeZone('UTC'));
1599
-        } catch (Exception $e) {
1600
-            $stage->add_error(sprintf(__("Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.",
1601
-                    "event_espresso"), $DATETIME_string, $timezone));
1602
-            $date_obj = new DateTime();
1603
-        }
1604
-        return $date_obj->format('Y-m-d H:i:s');
1605
-    }
1606
-
1607
-
1608
-
1609
-    /**
1610
-     * Gets the DEFAULT timezone string from wordpress (even if they set a gmt offset)
1611
-     *
1612
-     * @return string
1613
-     */
1614
-    private function _get_wp_timezone()
1615
-    {
1616
-        $timezone = empty($timezone) ? get_option('timezone_string') : $timezone;
1617
-        //if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter
1618
-        if (empty($timezone)) {
1619
-            //let's get a the WordPress UTC offset
1620
-            $offset = get_option('gmt_offset');
1621
-            $timezone = $this->timezone_convert_to_string_from_offset($offset);
1622
-        }
1623
-        return $timezone;
1624
-    }
1625
-
1626
-
1627
-
1628
-    /**
1629
-     * Gets the wordpress timezone string from a UTC offset
1630
-     *
1631
-     * @param int $offset
1632
-     * @return boolean
1633
-     */
1634
-    private function timezone_convert_to_string_from_offset($offset)
1635
-    {
1636
-        //shamelessly taken from bottom comment at http://ca1.php.net/manual/en/function.timezone-name-from-abbr.php because timezone_name_from_abbr() did NOT work as expected - its not reliable
1637
-        $offset *= 3600; // convert hour offset to seconds
1638
-        $abbrarray = timezone_abbreviations_list();
1639
-        foreach ($abbrarray as $abbr) {
1640
-            foreach ($abbr as $city) {
1641
-                if ($city['offset'] == $offset) {
1642
-                    return $city['timezone_id'];
1643
-                }
1644
-            }
1645
-        }
1646
-        return false;
1647
-    }
1648
-
1649
-
1650
-
1651
-    public function migration_page_hooks()
1652
-    {
1653
-        add_filter(
1654
-                'FHEE__ee_migration_page__header',
1655
-                array($this, '_migrate_page_hook_simplify_version_strings'),
1656
-                10,
1657
-                3
1658
-        );
1659
-        add_filter(
1660
-                'FHEE__ee_migration_page__p_after_header',
1661
-                array($this, '_migration_page_hook_simplify_next_db_state'),
1662
-                10,
1663
-                2
1664
-        );
1665
-        add_filter(
1666
-                'FHEE__ee_migration_page__option_1_main',
1667
-                array($this, '_migrate_page_hook_simplify_version_strings'),
1668
-                10,
1669
-                3
1670
-        );
1671
-        add_filter(
1672
-                'FHEE__ee_migration_page__option_1_button_text',
1673
-                array($this, '_migrate_page_hook_simplify_version_strings'),
1674
-                10,
1675
-                3
1676
-        );
1677
-        add_action(
1678
-                'AHEE__ee_migration_page__option_1_extra_details',
1679
-                array($this, '_migration_page_hook_option_1_extra_details'),
1680
-                10,
1681
-                3
1682
-        );
1683
-        add_filter(
1684
-                'FHEE__ee_migration_page__option_2_main',
1685
-                array($this, '_migrate_page_hook_simplify_version_strings'),
1686
-                10,
1687
-                4
1688
-        );
1689
-        add_filter(
1690
-                'FHEE__ee_migration_page__option_2_button_text',
1691
-                array($this, '_migration_page_hook_simplify_next_db_state'),
1692
-                10,
1693
-                2
1694
-        );
1695
-        add_filter(
1696
-                'FHEE__ee_migration_page__option_2_details',
1697
-                array($this, '_migration_page_hook_simplify_next_db_state'),
1698
-                10,
1699
-                2
1700
-        );
1701
-        add_action(
1702
-                'AHEE__ee_migration_page__after_migration_options_table',
1703
-                array($this, '_migration_page_hook_after_migration_options_table')
1704
-        );
1705
-        add_filter(
1706
-                'FHEE__ee_migration_page__done_migration_header',
1707
-                array($this, '_migration_page_hook_simplify_next_db_state'),
1708
-                10,
1709
-                2
1710
-        );
1711
-        add_filter(
1712
-                'FHEE__ee_migration_page__p_after_done_migration_header',
1713
-                array($this, '_migration_page_hook_simplify_next_db_state'),
1714
-                10,
1715
-                2
1716
-        );
1717
-    }
1718
-
1719
-
1720
-
1721
-    public function _migrate_page_hook_simplify_version_strings(
1722
-            $old_content,
1723
-            $current_db_state,
1724
-            $next_db_state,
1725
-            $ultimate_db_state = null
1726
-    ) {
1727
-        return str_replace(array($current_db_state, $next_db_state, $ultimate_db_state),
1728
-                array(__('EE3', 'event_espresso'), __('EE4', 'event_espresso'), __("EE4", 'event_espresso')),
1729
-                $old_content);
1730
-    }
1731
-
1732
-
1733
-
1734
-    public function _migration_page_hook_simplify_next_db_state($old_content, $next_db_state)
1735
-    {
1736
-        return str_replace($next_db_state, __("EE4", 'event_espresso'), $old_content);
1737
-    }
1738
-
1739
-
1740
-
1741
-    public function _migration_page_hook_option_1_extra_details()
1742
-    {
1743
-        ?>
1070
+		if ( ! $state) {
1071
+			//insert a new one then
1072
+			$cols_n_values = array(
1073
+					'CNT_ISO'    => $country_iso,
1074
+					'STA_abbrev' => substr($state_name, 0, 6),
1075
+					'STA_name'   => $state_name,
1076
+					'STA_active' => true,
1077
+			);
1078
+			$data_types = array(
1079
+					'%s',//CNT_ISO
1080
+					'%s',//STA_abbrev
1081
+					'%s',//STA_name
1082
+					'%d',//STA_active
1083
+			);
1084
+			$success = $wpdb->insert($state_table, $cols_n_values, $data_types);
1085
+			if ( ! $success) {
1086
+				throw new EE_Error($this->_create_error_message_for_db_insertion('N/A',
1087
+						array('state' => $state_name, 'country_id' => $country_name), $state_table, $cols_n_values,
1088
+						$data_types));
1089
+			}
1090
+			$state = $cols_n_values;
1091
+			$state['STA_ID'] = $wpdb->insert_id;
1092
+		}
1093
+		return $state;
1094
+	}
1095
+
1096
+
1097
+
1098
+	/**
1099
+	 * Fixes times like "5:00 PM" into the expected 24-hour format "17:00".
1100
+	 * THis is actually just copied from the 3.1 JSON API because it needed to do the exact same thing
1101
+	 *
1102
+	 * @param type $timeString
1103
+	 * @return string in the php DATETIME format: "G:i" (24-hour format hour with leading zeros, a colon, and minutes
1104
+	 *                with leading zeros)
1105
+	 */
1106
+	public function convertTimeFromAMPM($timeString)
1107
+	{
1108
+		$matches = array();
1109
+		preg_match("~(\\d*):(\\d*)~", $timeString, $matches);
1110
+		if ( ! $matches || count($matches) < 3) {
1111
+			$hour = '00';
1112
+			$minutes = '00';
1113
+		} else {
1114
+			$hour = intval($matches[1]);
1115
+			$minutes = $matches[2];
1116
+		}
1117
+		if (strpos($timeString, 'PM') || strpos($timeString, 'pm')) {
1118
+			$hour = intval($hour) + 12;
1119
+		}
1120
+		$hour = str_pad("$hour", 2, '0', STR_PAD_LEFT);
1121
+		$minutes = str_pad("$minutes", 2, '0', STR_PAD_LEFT);
1122
+		return "$hour:$minutes";
1123
+	}
1124
+
1125
+
1126
+
1127
+	/**
1128
+	 * Gets the ISO3 fora country given its 3.1 country ID.
1129
+	 *
1130
+	 * @param int $country_id
1131
+	 * @return string the country's ISO3 code
1132
+	 */
1133
+	public function get_iso_from_3_1_country_id($country_id)
1134
+	{
1135
+		$old_countries = array(
1136
+				array(64, 'United States', 'US', 'USA', 1),
1137
+				array(15, 'Australia', 'AU', 'AUS', 1),
1138
+				array(39, 'Canada', 'CA', 'CAN', 1),
1139
+				array(171, 'United Kingdom', 'GB', 'GBR', 1),
1140
+				array(70, 'France', 'FR', 'FRA', 2),
1141
+				array(111, 'Italy', 'IT', 'ITA', 2),
1142
+				array(63, 'Spain', 'ES', 'ESP', 2),
1143
+				array(1, 'Afghanistan', 'AF', 'AFG', 1),
1144
+				array(2, 'Albania', 'AL', 'ALB', 1),
1145
+				array(3, 'Germany', 'DE', 'DEU', 2),
1146
+				array(198, 'Switzerland', 'CH', 'CHE', 1),
1147
+				array(87, 'Netherlands', 'NL', 'NLD', 2),
1148
+				array(197, 'Sweden', 'SE', 'SWE', 1),
1149
+				array(230, 'Akrotiri and Dhekelia', 'CY', 'CYP', 2),
1150
+				array(4, 'Andorra', 'AD', 'AND', 2),
1151
+				array(5, 'Angola', 'AO', 'AGO', 1),
1152
+				array(6, 'Anguilla', 'AI', 'AIA', 1),
1153
+				array(7, 'Antarctica', 'AQ', 'ATA', 1),
1154
+				array(8, 'Antigua and Barbuda', 'AG', 'ATG', 1),
1155
+				array(10, 'Saudi Arabia', 'SA', 'SAU', 1),
1156
+				array(11, 'Algeria', 'DZ', 'DZA', 1),
1157
+				array(12, 'Argentina', 'AR', 'ARG', 1),
1158
+				array(13, 'Armenia', 'AM', 'ARM', 1),
1159
+				array(14, 'Aruba', 'AW', 'ABW', 1),
1160
+				array(16, 'Austria', 'AT', 'AUT', 2),
1161
+				array(17, 'Azerbaijan', 'AZ', 'AZE', 1),
1162
+				array(18, 'Bahamas', 'BS', 'BHS', 1),
1163
+				array(19, 'Bahrain', 'BH', 'BHR', 1),
1164
+				array(20, 'Bangladesh', 'BD', 'BGD', 1),
1165
+				array(21, 'Barbados', 'BB', 'BRB', 1),
1166
+				array(22, 'Belgium ', 'BE', 'BEL', 2),
1167
+				array(23, 'Belize', 'BZ', 'BLZ', 1),
1168
+				array(24, 'Benin', 'BJ', 'BEN', 1),
1169
+				array(25, 'Bermudas', 'BM', 'BMU', 1),
1170
+				array(26, 'Belarus', 'BY', 'BLR', 1),
1171
+				array(27, 'Bolivia', 'BO', 'BOL', 1),
1172
+				array(28, 'Bosnia and Herzegovina', 'BA', 'BIH', 1),
1173
+				array(29, 'Botswana', 'BW', 'BWA', 1),
1174
+				array(96, 'Bouvet Island', 'BV', 'BVT', 1),
1175
+				array(30, 'Brazil', 'BR', 'BRA', 1),
1176
+				array(31, 'Brunei', 'BN', 'BRN', 1),
1177
+				array(32, 'Bulgaria', 'BG', 'BGR', 1),
1178
+				array(33, 'Burkina Faso', 'BF', 'BFA', 1),
1179
+				array(34, 'Burundi', 'BI', 'BDI', 1),
1180
+				array(35, 'Bhutan', 'BT', 'BTN', 1),
1181
+				array(36, 'Cape Verde', 'CV', 'CPV', 1),
1182
+				array(37, 'Cambodia', 'KH', 'KHM', 1),
1183
+				array(38, 'Cameroon', 'CM', 'CMR', 1),
1184
+				array(98, 'Cayman Islands', 'KY', 'CYM', 1),
1185
+				array(172, 'Central African Republic', 'CF', 'CAF', 1),
1186
+				array(40, 'Chad', 'TD', 'TCD', 1),
1187
+				array(41, 'Chile', 'CL', 'CHL', 1),
1188
+				array(42, 'China', 'CN', 'CHN', 1),
1189
+				array(105, 'Christmas Island', 'CX', 'CXR', 1),
1190
+				array(43, 'Cyprus', 'CY', 'CYP', 2),
1191
+				array(99, 'Cocos Island', 'CC', 'CCK', 1),
1192
+				array(100, 'Cook Islands', 'CK', 'COK', 1),
1193
+				array(44, 'Colombia', 'CO', 'COL', 1),
1194
+				array(45, 'Comoros', 'KM', 'COM', 1),
1195
+				array(46, 'Congo', 'CG', 'COG', 1),
1196
+				array(47, 'North Korea', 'KP', 'PRK', 1),
1197
+				array(50, 'Costa Rica', 'CR', 'CRI', 1),
1198
+				array(51, 'Croatia', 'HR', 'HRV', 1),
1199
+				array(52, 'Cuba', 'CU', 'CUB', 1),
1200
+				array(173, 'Czech Republic', 'CZ', 'CZE', 1),
1201
+				array(53, 'Denmark', 'DK', 'DNK', 1),
1202
+				array(54, 'Djibouti', 'DJ', 'DJI', 1),
1203
+				array(55, 'Dominica', 'DM', 'DMA', 1),
1204
+				array(174, 'Dominican Republic', 'DO', 'DOM', 1),
1205
+				array(56, 'Ecuador', 'EC', 'ECU', 1),
1206
+				array(57, 'Egypt', 'EG', 'EGY', 1),
1207
+				array(58, 'El Salvador', 'SV', 'SLV', 1),
1208
+				array(60, 'Eritrea', 'ER', 'ERI', 1),
1209
+				array(61, 'Slovakia', 'SK', 'SVK', 2),
1210
+				array(62, 'Slovenia', 'SI', 'SVN', 2),
1211
+				array(65, 'Estonia', 'EE', 'EST', 2),
1212
+				array(66, 'Ethiopia', 'ET', 'ETH', 1),
1213
+				array(102, 'Faroe islands', 'FO', 'FRO', 1),
1214
+				array(103, 'Falkland Islands', 'FK', 'FLK', 1),
1215
+				array(67, 'Fiji', 'FJ', 'FJI', 1),
1216
+				array(69, 'Finland', 'FI', 'FIN', 2),
1217
+				array(71, 'Gabon', 'GA', 'GAB', 1),
1218
+				array(72, 'Gambia', 'GM', 'GMB', 1),
1219
+				array(73, 'Georgia', 'GE', 'GEO', 1),
1220
+				array(74, 'Ghana', 'GH', 'GHA', 1),
1221
+				array(75, 'Gibraltar', 'GI', 'GIB', 1),
1222
+				array(76, 'Greece', 'GR', 'GRC', 2),
1223
+				array(77, 'Grenada', 'GD', 'GRD', 1),
1224
+				array(78, 'Greenland', 'GL', 'GRL', 1),
1225
+				array(79, 'Guadeloupe', 'GP', 'GLP', 1),
1226
+				array(80, 'Guam', 'GU', 'GUM', 1),
1227
+				array(81, 'Guatemala', 'GT', 'GTM', 1),
1228
+				array(82, 'Guinea', 'GN', 'GIN', 1),
1229
+				array(83, 'Equatorial Guinea', 'GQ', 'GNQ', 1),
1230
+				array(84, 'Guinea-Bissau', 'GW', 'GNB', 1),
1231
+				array(85, 'Guyana', 'GY', 'GUY', 1),
1232
+				array(86, 'Haiti', 'HT', 'HTI', 1),
1233
+				array(88, 'Honduras', 'HN', 'HND', 1),
1234
+				array(89, 'Hong Kong', 'HK', 'HKG', 1),
1235
+				array(90, 'Hungary', 'HU', 'HUN', 1),
1236
+				array(91, 'India', 'IN', 'IND', 1),
1237
+				array(205, 'British Indian Ocean Territory', 'IO', 'IOT', 1),
1238
+				array(92, 'Indonesia', 'ID', 'IDN', 1),
1239
+				array(93, 'Iraq', 'IQ', 'IRQ', 1),
1240
+				array(94, 'Iran', 'IR', 'IRN', 1),
1241
+				array(95, 'Ireland', 'IE', 'IRL', 2),
1242
+				array(97, 'Iceland', 'IS', 'ISL', 1),
1243
+				array(110, 'Israel', 'IL', 'ISR', 1),
1244
+				array(49, 'Ivory Coast ', 'CI', 'CIV', 1),
1245
+				array(112, 'Jamaica', 'JM', 'JAM', 1),
1246
+				array(113, 'Japan', 'JP', 'JPN', 1),
1247
+				array(114, 'Jordan', 'JO', 'JOR', 1),
1248
+				array(115, 'Kazakhstan', 'KZ', 'KAZ', 1),
1249
+				array(116, 'Kenya', 'KE', 'KEN', 1),
1250
+				array(117, 'Kyrgyzstan', 'KG', 'KGZ', 1),
1251
+				array(118, 'Kiribati', 'KI', 'KIR', 1),
1252
+				array(48, 'South Korea', 'KR', 'KOR', 1),
1253
+				array(228, 'Kosovo', 'XK', 'XKV', 2),
1254
+				// there is no official ISO code for Kosovo yet (http://geonames.wordpress.com/2010/03/08/xk-country-code-for-kosovo/) so using a temporary country code and a modified 3 character code for ISO code -- this should be updated if/when Kosovo gets its own ISO code
1255
+				array(119, 'Kuwait', 'KW', 'KWT', 1),
1256
+				array(120, 'Laos', 'LA', 'LAO', 1),
1257
+				array(121, 'Latvia', 'LV', 'LVA', 2),
1258
+				array(122, 'Lesotho', 'LS', 'LSO', 1),
1259
+				array(123, 'Lebanon', 'LB', 'LBN', 1),
1260
+				array(124, 'Liberia', 'LR', 'LBR', 1),
1261
+				array(125, 'Libya', 'LY', 'LBY', 1),
1262
+				array(126, 'Liechtenstein', 'LI', 'LIE', 1),
1263
+				array(127, 'Lithuania', 'LT', 'LTU', 2),
1264
+				array(128, 'Luxemburg', 'LU', 'LUX', 2),
1265
+				array(129, 'Macao', 'MO', 'MAC', 1),
1266
+				array(130, 'Macedonia', 'MK', 'MKD', 1),
1267
+				array(131, 'Madagascar', 'MG', 'MDG', 1),
1268
+				array(132, 'Malaysia', 'MY', 'MYS', 1),
1269
+				array(133, 'Malawi', 'MW', 'MWI', 1),
1270
+				array(134, 'Maldivas', 'MV', 'MDV', 1),
1271
+				array(135, 'Mali', 'ML', 'MLI', 1),
1272
+				array(136, 'Malta', 'MT', 'MLT', 2),
1273
+				array(101, 'Northern Marianas', 'MP', 'MNP', 1),
1274
+				array(137, 'Morocco', 'MA', 'MAR', 1),
1275
+				array(104, 'Marshall islands', 'MH', 'MHL', 1),
1276
+				array(138, 'Martinique', 'MQ', 'MTQ', 1),
1277
+				array(139, 'Mauritius', 'MU', 'MUS', 1),
1278
+				array(140, 'Mauritania', 'MR', 'MRT', 1),
1279
+				array(141, 'Mayote', 'YT', 'MYT', 2),
1280
+				array(142, 'Mexico', 'MX', 'MEX', 1),
1281
+				array(143, 'Micronesia', 'FM', 'FSM', 1),
1282
+				array(144, 'Moldova', 'MD', 'MDA', 1),
1283
+				array(145, 'Monaco', 'MC', 'MCO', 2),
1284
+				array(146, 'Mongolia', 'MN', 'MNG', 1),
1285
+				array(147, 'Montserrat', 'MS', 'MSR', 1),
1286
+				array(227, 'Montenegro', 'ME', 'MNE', 2),
1287
+				array(148, 'Mozambique', 'MZ', 'MOZ', 1),
1288
+				array(149, 'Myanmar', 'MM', 'MMR', 1),
1289
+				array(150, 'Namibia', 'NA', 'NAM', 1),
1290
+				array(151, 'Nauru', 'NR', 'NRU', 1),
1291
+				array(152, 'Nepal', 'NP', 'NPL', 1),
1292
+				array(9, 'Netherlands Antilles', 'AN', 'ANT', 1),
1293
+				array(153, 'Nicaragua', 'NI', 'NIC', 1),
1294
+				array(154, 'Niger', 'NE', 'NER', 1),
1295
+				array(155, 'Nigeria', 'NG', 'NGA', 1),
1296
+				array(156, 'Niue', 'NU', 'NIU', 1),
1297
+				array(157, 'Norway', 'NO', 'NOR', 1),
1298
+				array(158, 'New Caledonia', 'NC', 'NCL', 1),
1299
+				array(159, 'New Zealand', 'NZ', 'NZL', 1),
1300
+				array(160, 'Oman', 'OM', 'OMN', 1),
1301
+				array(161, 'Pakistan', 'PK', 'PAK', 1),
1302
+				array(162, 'Palau', 'PW', 'PLW', 1),
1303
+				array(163, 'Panama', 'PA', 'PAN', 1),
1304
+				array(164, 'Papua New Guinea', 'PG', 'PNG', 1),
1305
+				array(165, 'Paraguay', 'PY', 'PRY', 1),
1306
+				array(166, 'Peru', 'PE', 'PER', 1),
1307
+				array(68, 'Philippines', 'PH', 'PHL', 1),
1308
+				array(167, 'Poland', 'PL', 'POL', 1),
1309
+				array(168, 'Portugal', 'PT', 'PRT', 2),
1310
+				array(169, 'Puerto Rico', 'PR', 'PRI', 1),
1311
+				array(170, 'Qatar', 'QA', 'QAT', 1),
1312
+				array(176, 'Rwanda', 'RW', 'RWA', 1),
1313
+				array(177, 'Romania', 'RO', 'ROM', 2),
1314
+				array(178, 'Russia', 'RU', 'RUS', 1),
1315
+				array(229, 'Saint Pierre and Miquelon', 'PM', 'SPM', 2),
1316
+				array(180, 'Samoa', 'WS', 'WSM', 1),
1317
+				array(181, 'American Samoa', 'AS', 'ASM', 1),
1318
+				array(183, 'San Marino', 'SM', 'SMR', 2),
1319
+				array(184, 'Saint Vincent and the Grenadines', 'VC', 'VCT', 1),
1320
+				array(185, 'Saint Helena', 'SH', 'SHN', 1),
1321
+				array(186, 'Saint Lucia', 'LC', 'LCA', 1),
1322
+				array(188, 'Senegal', 'SN', 'SEN', 1),
1323
+				array(189, 'Seychelles', 'SC', 'SYC', 1),
1324
+				array(190, 'Sierra Leona', 'SL', 'SLE', 1),
1325
+				array(191, 'Singapore', 'SG', 'SGP', 1),
1326
+				array(192, 'Syria', 'SY', 'SYR', 1),
1327
+				array(193, 'Somalia', 'SO', 'SOM', 1),
1328
+				array(194, 'Sri Lanka', 'LK', 'LKA', 1),
1329
+				array(195, 'South Africa', 'ZA', 'ZAF', 1),
1330
+				array(196, 'Sudan', 'SD', 'SDN', 1),
1331
+				array(199, 'Suriname', 'SR', 'SUR', 1),
1332
+				array(200, 'Swaziland', 'SZ', 'SWZ', 1),
1333
+				array(201, 'Thailand', 'TH', 'THA', 1),
1334
+				array(202, 'Taiwan', 'TW', 'TWN', 1),
1335
+				array(203, 'Tanzania', 'TZ', 'TZA', 1),
1336
+				array(204, 'Tajikistan', 'TJ', 'TJK', 1),
1337
+				array(206, 'Timor-Leste', 'TL', 'TLS', 1),
1338
+				array(207, 'Togo', 'TG', 'TGO', 1),
1339
+				array(208, 'Tokelau', 'TK', 'TKL', 1),
1340
+				array(209, 'Tonga', 'TO', 'TON', 1),
1341
+				array(210, 'Trinidad and Tobago', 'TT', 'TTO', 1),
1342
+				array(211, 'Tunisia', 'TN', 'TUN', 1),
1343
+				array(212, 'Turkmenistan', 'TM', 'TKM', 1),
1344
+				array(213, 'Turkey', 'TR', 'TUR', 1),
1345
+				array(214, 'Tuvalu', 'TV', 'TUV', 1),
1346
+				array(215, 'Ukraine', 'UA', 'UKR', 1),
1347
+				array(216, 'Uganda', 'UG', 'UGA', 1),
1348
+				array(59, 'United Arab Emirates', 'AE', 'ARE', 1),
1349
+				array(217, 'Uruguay', 'UY', 'URY', 1),
1350
+				array(218, 'Uzbekistan', 'UZ', 'UZB', 1),
1351
+				array(219, 'Vanuatu', 'VU', 'VUT', 1),
1352
+				array(220, 'Vatican City', 'VA', 'VAT', 2),
1353
+				array(221, 'Venezuela', 'VE', 'VEN', 1),
1354
+				array(222, 'Vietnam', 'VN', 'VNM', 1),
1355
+				array(108, 'Virgin Islands', 'VI', 'VIR', 1),
1356
+				array(223, 'Yemen', 'YE', 'YEM', 1),
1357
+				array(225, 'Zambia', 'ZM', 'ZMB', 1),
1358
+				array(226, 'Zimbabwe', 'ZW', 'ZWE', 1),
1359
+		);
1360
+		$country_iso = 'US';
1361
+		foreach ($old_countries as $country_array) {
1362
+			//note: index 0 is the 3.1 country ID
1363
+			if ($country_array[0] == $country_id) {
1364
+				//note: index 2 is the ISO
1365
+				$country_iso = $country_array[2];
1366
+				break;
1367
+			}
1368
+		}
1369
+		return $country_iso;
1370
+	}
1371
+
1372
+
1373
+
1374
+	/**
1375
+	 * Gets the ISO3 for the
1376
+	 *
1377
+	 * @return string
1378
+	 */
1379
+	public function get_default_country_iso()
1380
+	{
1381
+		$old_org_options = get_option('events_organization_settings');
1382
+		$iso = $this->get_iso_from_3_1_country_id($old_org_options['organization_country']);
1383
+		return $iso;
1384
+	}
1385
+
1386
+
1387
+
1388
+	/**
1389
+	 * Converst a 3.1 payment status to its equivalent 4.1 regisration status
1390
+	 *
1391
+	 * @param string  $payment_status                   possible value for 3.1's evens_attendee.payment_status
1392
+	 * @param boolean $this_thing_required_pre_approval whether the thing we're considering (the general setting's
1393
+	 *                                                  DEFAULT payment status, the event's DEFAULT payment status, or
1394
+	 *                                                  the attendee's payment status) required pre-approval.
1395
+	 * @return string STS_ID for use in 4.1
1396
+	 */
1397
+	public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false)
1398
+	{
1399
+		//EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455
1400
+		if ($this_thing_required_pre_approval) {
1401
+			return 'RNA';
1402
+		} else {
1403
+			$mapping = $default_reg_stati_conversions = array(
1404
+					'Completed'        => 'RAP',
1405
+					''                 => 'RPP',
1406
+					'Incomplete'       => 'RPP',
1407
+					'Pending'          => 'RAP',
1408
+					//stati that only occurred on 3.1 attendees:
1409
+					'Payment Declined' => 'RPP',
1410
+					'Not Completed'    => 'RPP',
1411
+					'Cancelled'        => 'RPP',
1412
+					'Declined'         => 'RPP',
1413
+			);
1414
+		}
1415
+		return isset($mapping[$payment_status]) ? $mapping[$payment_status] : 'RNA';
1416
+	}
1417
+
1418
+
1419
+
1420
+	/**
1421
+	 * Makes sure the 3.1's image url is converted to an image attachment post to the 4.1 CPT event
1422
+	 * and sets it as the featured image on the CPT event
1423
+	 *
1424
+	 * @param type                            $old_event
1425
+	 * @param type                            $new_cpt_id
1426
+	 * @param  EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added
1427
+	 * @return boolean whether or not we had to do the big job of creating an image attachment
1428
+	 */
1429
+	public function convert_image_url_to_attachment_and_attach_to_post(
1430
+			$guid,
1431
+			$new_cpt_id,
1432
+			EE_Data_Migration_Script_Stage $migration_stage
1433
+	) {
1434
+		$created_attachment_post = false;
1435
+		$guid = $this->_get_original_guid($guid);
1436
+		if ($guid) {
1437
+			//check for an existing attachment post with this guid
1438
+			$attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid);
1439
+			if ( ! $attachment_post_id) {
1440
+				//post thumbnail with that GUID doesn't exist, we should create one
1441
+				$attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage);
1442
+				$created_attachment_post = true;
1443
+			}
1444
+			//double-check we actually have an attachment post
1445
+			if ($attachment_post_id) {
1446
+				update_post_meta($new_cpt_id, '_thumbnail_id', $attachment_post_id);
1447
+			} else {
1448
+				$migration_stage->add_error(sprintf(__("Could not update event image %s for CPT with ID %d, but attachments post ID is %d",
1449
+						"event_espresso"), $guid, $new_cpt_id, $attachment_post_id));
1450
+			}
1451
+		}
1452
+		return $created_attachment_post;
1453
+	}
1454
+
1455
+
1456
+
1457
+	/**
1458
+	 * In 3.1, the event thumbnail image DOESN'T point to the orignal image, but instead
1459
+	 * to a large thumbnail (which has nearly the same GUID, except it adds "-{width}x{height}" before the filetype,
1460
+	 * or whatever dimensions it is. Eg 'http://mysite.com/image1-300x400.jpg' instead of
1461
+	 * 'http://mysite.com/image1.jpg' ). This function attempts to strip that off and get the original file, if it
1462
+	 * exists
1463
+	 *
1464
+	 * @param string $guid_in_old_event
1465
+	 * @return string either the original guid, or $guid_in_old_event if we couldn't figure out what the original was
1466
+	 */
1467
+	private function _get_original_guid($guid_in_old_event)
1468
+	{
1469
+		$original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1);
1470
+		//do a head request to verify the file exists
1471
+		$head_response = wp_remote_head($original_guid);
1472
+		if ( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') {
1473
+			return $original_guid;
1474
+		} else {
1475
+			return $guid_in_old_event;
1476
+		}
1477
+	}
1478
+
1479
+
1480
+
1481
+	/**
1482
+	 * Creates an image attachment post for the GUID. If the GUID points to a remote image,
1483
+	 * we download it to our uploads directory so that it can be properly processed (eg, creates different sizes of
1484
+	 * thumbnails)
1485
+	 *
1486
+	 * @param type                           $guid
1487
+	 * @param EE_Data_Migration_Script_Stage $migration_stage
1488
+	 * @return int
1489
+	 */
1490
+	private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage)
1491
+	{
1492
+		if ( ! $guid) {
1493
+			$migration_stage->add_error(sprintf(__("Cannot create image attachment for a blank GUID!",
1494
+					"event_espresso")));
1495
+			return 0;
1496
+		}
1497
+		$wp_filetype = wp_check_filetype(basename($guid), null);
1498
+		$wp_upload_dir = wp_upload_dir();
1499
+		//if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local
1500
+		if (strpos($guid, $wp_upload_dir['url']) === false) {
1501
+			//image is located remotely. download it and place it in the uploads directory
1502
+			if ( ! is_readable($guid)) {
1503
+				$migration_stage->add_error(sprintf(__("Could not create image attachment from non-existent file: %s",
1504
+						"event_espresso"), $guid));
1505
+				return 0;
1506
+			}
1507
+			$contents = file_get_contents($guid);
1508
+			if ($contents === false) {
1509
+				$migration_stage->add_error(sprintf(__("Could not read image at %s, and therefore couldnt create an attachment post for it.",
1510
+						"event_espresso"), $guid));
1511
+				return false;
1512
+			}
1513
+			$local_filepath = $wp_upload_dir['path'] . DS . basename($guid);
1514
+			$savefile = fopen($local_filepath, 'w');
1515
+			fwrite($savefile, $contents);
1516
+			fclose($savefile);
1517
+			$guid = str_replace($wp_upload_dir['path'], $wp_upload_dir['url'], $local_filepath);
1518
+		} else {
1519
+			$local_filepath = str_replace($wp_upload_dir['url'], $wp_upload_dir['path'], $guid);
1520
+		}
1521
+		$attachment = array(
1522
+				'guid'           => $guid,
1523
+				'post_mime_type' => $wp_filetype['type'],
1524
+				'post_title'     => preg_replace('/\.[^.]+$/', '', basename($guid)),
1525
+				'post_content'   => '',
1526
+				'post_status'    => 'inherit',
1527
+		);
1528
+		$attach_id = wp_insert_attachment($attachment, $guid);
1529
+		if ( ! $attach_id) {
1530
+			$migration_stage->add_error(sprintf(__("Could not create image attachment post from image '%s'. Attachment data was %s.",
1531
+					"event_espresso"), $guid, $this->_json_encode($attachment)));
1532
+			return $attach_id;
1533
+		}
1534
+		// you must first include the image.php file
1535
+		// for the function wp_generate_attachment_metadata() to work
1536
+		require_once(ABSPATH . 'wp-admin/includes/image.php');
1537
+		$attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath);
1538
+		if ( ! $attach_data) {
1539
+			$migration_stage->add_error(sprintf(__("Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.",
1540
+					"event_espresso"), $attach_id, $local_filepath, $guid));
1541
+			return $attach_id;
1542
+		}
1543
+		$metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data);
1544
+		if ( ! $metadata_save_result) {
1545
+			$migration_stage->add_error(sprintf(__("Could not update attachment metadata for attachment %d with data %s",
1546
+					"event_espresso"), $attach_id, $this->_json_encode($attach_data)));
1547
+		}
1548
+		return $attach_id;
1549
+	}
1550
+
1551
+
1552
+
1553
+	/**
1554
+	 * Finds the attachment post containing info about an image attachment given the GUID (link to the image itself),
1555
+	 * and returns its ID.
1556
+	 *
1557
+	 * @global type  $wpdb
1558
+	 * @param string $guid
1559
+	 * @return int
1560
+	 */
1561
+	private function _get_image_attachment_id_by_GUID($guid)
1562
+	{
1563
+		global $wpdb;
1564
+		$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1", $guid));
1565
+		return $attachment_id;
1566
+	}
1567
+
1568
+
1569
+
1570
+	/**
1571
+	 * Returns a mysql-formatted DATETIME in UTC time, given a $DATETIME_string
1572
+	 * (and optionally a timezone; if none is given, the wp DEFAULT is used)
1573
+	 *
1574
+	 * @param EE_Data_Migration_Script_base $stage
1575
+	 * @param array                         $row_of_data , the row from the DB (as an array) we're trying to find the
1576
+	 *                                                   UTC time for
1577
+	 * @param string                        $DATETIME_string
1578
+	 * @param string                        $timezone
1579
+	 * @return string
1580
+	 */
1581
+	public function convert_date_string_to_utc(
1582
+			EE_Data_Migration_Script_Stage $stage,
1583
+			$row_of_data,
1584
+			$DATETIME_string,
1585
+			$timezone = null
1586
+	) {
1587
+		$original_tz = $timezone;
1588
+		if ( ! $timezone) {
1589
+			$timezone = $this->_get_wp_timezone();
1590
+		}
1591
+		if ( ! $timezone) {
1592
+			$stage->add_error(sprintf(__("Could not find timezone given %s for %s", "event_espresso"), $original_tz,
1593
+					$row_of_data));
1594
+			$timezone = 'UTC';
1595
+		}
1596
+		try {
1597
+			$date_obj = new DateTime($DATETIME_string, new DateTimeZone($timezone));
1598
+			$date_obj->setTimezone(new DateTimeZone('UTC'));
1599
+		} catch (Exception $e) {
1600
+			$stage->add_error(sprintf(__("Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.",
1601
+					"event_espresso"), $DATETIME_string, $timezone));
1602
+			$date_obj = new DateTime();
1603
+		}
1604
+		return $date_obj->format('Y-m-d H:i:s');
1605
+	}
1606
+
1607
+
1608
+
1609
+	/**
1610
+	 * Gets the DEFAULT timezone string from wordpress (even if they set a gmt offset)
1611
+	 *
1612
+	 * @return string
1613
+	 */
1614
+	private function _get_wp_timezone()
1615
+	{
1616
+		$timezone = empty($timezone) ? get_option('timezone_string') : $timezone;
1617
+		//if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter
1618
+		if (empty($timezone)) {
1619
+			//let's get a the WordPress UTC offset
1620
+			$offset = get_option('gmt_offset');
1621
+			$timezone = $this->timezone_convert_to_string_from_offset($offset);
1622
+		}
1623
+		return $timezone;
1624
+	}
1625
+
1626
+
1627
+
1628
+	/**
1629
+	 * Gets the wordpress timezone string from a UTC offset
1630
+	 *
1631
+	 * @param int $offset
1632
+	 * @return boolean
1633
+	 */
1634
+	private function timezone_convert_to_string_from_offset($offset)
1635
+	{
1636
+		//shamelessly taken from bottom comment at http://ca1.php.net/manual/en/function.timezone-name-from-abbr.php because timezone_name_from_abbr() did NOT work as expected - its not reliable
1637
+		$offset *= 3600; // convert hour offset to seconds
1638
+		$abbrarray = timezone_abbreviations_list();
1639
+		foreach ($abbrarray as $abbr) {
1640
+			foreach ($abbr as $city) {
1641
+				if ($city['offset'] == $offset) {
1642
+					return $city['timezone_id'];
1643
+				}
1644
+			}
1645
+		}
1646
+		return false;
1647
+	}
1648
+
1649
+
1650
+
1651
+	public function migration_page_hooks()
1652
+	{
1653
+		add_filter(
1654
+				'FHEE__ee_migration_page__header',
1655
+				array($this, '_migrate_page_hook_simplify_version_strings'),
1656
+				10,
1657
+				3
1658
+		);
1659
+		add_filter(
1660
+				'FHEE__ee_migration_page__p_after_header',
1661
+				array($this, '_migration_page_hook_simplify_next_db_state'),
1662
+				10,
1663
+				2
1664
+		);
1665
+		add_filter(
1666
+				'FHEE__ee_migration_page__option_1_main',
1667
+				array($this, '_migrate_page_hook_simplify_version_strings'),
1668
+				10,
1669
+				3
1670
+		);
1671
+		add_filter(
1672
+				'FHEE__ee_migration_page__option_1_button_text',
1673
+				array($this, '_migrate_page_hook_simplify_version_strings'),
1674
+				10,
1675
+				3
1676
+		);
1677
+		add_action(
1678
+				'AHEE__ee_migration_page__option_1_extra_details',
1679
+				array($this, '_migration_page_hook_option_1_extra_details'),
1680
+				10,
1681
+				3
1682
+		);
1683
+		add_filter(
1684
+				'FHEE__ee_migration_page__option_2_main',
1685
+				array($this, '_migrate_page_hook_simplify_version_strings'),
1686
+				10,
1687
+				4
1688
+		);
1689
+		add_filter(
1690
+				'FHEE__ee_migration_page__option_2_button_text',
1691
+				array($this, '_migration_page_hook_simplify_next_db_state'),
1692
+				10,
1693
+				2
1694
+		);
1695
+		add_filter(
1696
+				'FHEE__ee_migration_page__option_2_details',
1697
+				array($this, '_migration_page_hook_simplify_next_db_state'),
1698
+				10,
1699
+				2
1700
+		);
1701
+		add_action(
1702
+				'AHEE__ee_migration_page__after_migration_options_table',
1703
+				array($this, '_migration_page_hook_after_migration_options_table')
1704
+		);
1705
+		add_filter(
1706
+				'FHEE__ee_migration_page__done_migration_header',
1707
+				array($this, '_migration_page_hook_simplify_next_db_state'),
1708
+				10,
1709
+				2
1710
+		);
1711
+		add_filter(
1712
+				'FHEE__ee_migration_page__p_after_done_migration_header',
1713
+				array($this, '_migration_page_hook_simplify_next_db_state'),
1714
+				10,
1715
+				2
1716
+		);
1717
+	}
1718
+
1719
+
1720
+
1721
+	public function _migrate_page_hook_simplify_version_strings(
1722
+			$old_content,
1723
+			$current_db_state,
1724
+			$next_db_state,
1725
+			$ultimate_db_state = null
1726
+	) {
1727
+		return str_replace(array($current_db_state, $next_db_state, $ultimate_db_state),
1728
+				array(__('EE3', 'event_espresso'), __('EE4', 'event_espresso'), __("EE4", 'event_espresso')),
1729
+				$old_content);
1730
+	}
1731
+
1732
+
1733
+
1734
+	public function _migration_page_hook_simplify_next_db_state($old_content, $next_db_state)
1735
+	{
1736
+		return str_replace($next_db_state, __("EE4", 'event_espresso'), $old_content);
1737
+	}
1738
+
1739
+
1740
+
1741
+	public function _migration_page_hook_option_1_extra_details()
1742
+	{
1743
+		?>
1744 1744
         <p><?php printf(__("Note: many of your EE3 shortcodes will be changed to EE4 shortcodes during this migration (among many other things). Should you revert to EE3, then you should restore to your backup or manually change the EE4 shortcodes back to their EE3 equivalents",
1745
-            "event_espresso")); ?></p><?php
1746
-    }
1745
+			"event_espresso")); ?></p><?php
1746
+	}
1747 1747
 
1748 1748
 
1749 1749
 
1750
-    public function _migration_page_hook_after_migration_options_table()
1751
-    {
1752
-        ?><p class="ee-attention">
1750
+	public function _migration_page_hook_after_migration_options_table()
1751
+	{
1752
+		?><p class="ee-attention">
1753 1753
         <strong><span class="reminder-spn"><?php _e("Important note to those using Event Espresso 3 addons: ",
1754
-                        "event_espresso"); ?></span></strong>
1754
+						"event_espresso"); ?></span></strong>
1755 1755
         <br/><?php _e("Unless an addon's description on our website explicitly states that it is compatible with EE4, you should consider it incompatible and know that it WILL NOT WORK correctly with this new version of Event Espresso 4 (EE4). As well, any data for incompatible addons will NOT BE MIGRATED until an updated EE4 compatible version of the addon is available. If you want, or need to keep using your EE3 addons, you should simply continue using EE3 until EE4 compatible versions of your addons become available. To continue using EE3 for now, just deactivate EE4 and reactivate EE3.",
1756
-            "event_espresso"); ?>
1756
+			"event_espresso"); ?>
1757 1757
         </p><?php
1758
-    }
1758
+	}
1759 1759
 }
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 //unfortunately, this needs to be done upon INCLUSION of this file,
10 10
 //instead of construction, because it only gets constructed on first page load
11 11
 //(all other times it gets resurrected from a wordpress option)
12
-$stages = glob(EE_CORE . 'data_migration_scripts/4_1_0_stages/*');
12
+$stages = glob(EE_CORE.'data_migration_scripts/4_1_0_stages/*');
13 13
 $class_to_filepath = array();
14 14
 if ( ! empty($stages)) {
15 15
     foreach ($stages as $filepath) {
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     private function _checkin_table_exists()
88 88
     {
89 89
         global $wpdb;
90
-        $results = $wpdb->get_results("SHOW TABLES LIKE '" . $wpdb->prefix . "events_attendee_checkin" . "'");
90
+        $results = $wpdb->get_results("SHOW TABLES LIKE '".$wpdb->prefix."events_attendee_checkin"."'");
91 91
         if ($results) {
92 92
             return true;
93 93
         } else {
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 //			echo "no version string provided: $version_string";
108 108
             //no version string provided... this must be pre 4.1
109 109
             //because since 4.1 we're
110
-            return false;//changed mind. dont want people thinking they should migrate yet because they cant
110
+            return false; //changed mind. dont want people thinking they should migrate yet because they cant
111 111
         } else {
112 112
 //			echo "$version_string doesnt apply";
113 113
             return false;
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     public function schema_changes_before_migration()
127 127
     {
128 128
         //relies on 4.1's EEH_Activation::create_table
129
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
129
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
130 130
         $table_name = 'esp_answer';
131 131
         $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
132 132
 					REG_ID INT UNSIGNED NOT NULL,
@@ -510,12 +510,12 @@  discard block
 block discarded – undo
510 510
     public function insert_default_states()
511 511
     {
512 512
         global $wpdb;
513
-        $state_table = $wpdb->prefix . "esp_state";
513
+        $state_table = $wpdb->prefix."esp_state";
514 514
         if ($this->_get_table_analysis()->tableExists($state_table)) {
515
-            $SQL = "SELECT COUNT('STA_ID') FROM " . $state_table;
515
+            $SQL = "SELECT COUNT('STA_ID') FROM ".$state_table;
516 516
             $states = $wpdb->get_var($SQL);
517 517
             if ( ! $states) {
518
-                $SQL = "INSERT INTO " . $state_table . "
518
+                $SQL = "INSERT INTO ".$state_table."
519 519
 				(STA_ID, CNT_ISO, STA_abbrev, STA_name, STA_active) VALUES
520 520
 				(1, 'US', 'AK', 'Alaska', 1),
521 521
 				(2, 'US', 'AL', 'Alabama', 1),
@@ -603,12 +603,12 @@  discard block
 block discarded – undo
603 603
     public function insert_default_countries()
604 604
     {
605 605
         global $wpdb;
606
-        $country_table = $wpdb->prefix . "esp_country";
606
+        $country_table = $wpdb->prefix."esp_country";
607 607
         if ($this->_get_table_analysis()->tableExists($country_table)) {
608
-            $SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table;
608
+            $SQL = "SELECT COUNT('CNT_ISO') FROM ".$country_table;
609 609
             $countries = $wpdb->get_var($SQL);
610 610
             if ( ! $countries) {
611
-                $SQL = "INSERT INTO " . $country_table . "
611
+                $SQL = "INSERT INTO ".$country_table."
612 612
 				(CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active) VALUES
613 613
 				('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
614 614
 				('AE', 'ARE', 0, 'United Arab Emirates', 'AED', 'Dirham', 'Dirhams', 'د.إ', 1, 2, '+971', 0, 0),
@@ -853,17 +853,17 @@  discard block
 block discarded – undo
853 853
     public function insert_default_price_types()
854 854
     {
855 855
         global $wpdb;
856
-        $price_type_table = $wpdb->prefix . "esp_price_type";
856
+        $price_type_table = $wpdb->prefix."esp_price_type";
857 857
         if ($this->_get_table_analysis()->tableExists($price_type_table)) {
858
-            $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
858
+            $SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table;
859 859
             $price_types_exist = $wpdb->get_var($SQL);
860 860
             if ( ! $price_types_exist) {
861 861
                 $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES
862
-							(1, '" . __('Base Price', 'event_espresso') . "', 1,  0, 0, 0),
863
-							(2, '" . __('Percent Discount', 'event_espresso') . "', 2,  1, 20, 0),
864
-							(3, '" . __('Fixed Discount', 'event_espresso') . "', 2,  0, 30, 0),
865
-							(4, '" . __('Percent Surcharge', 'event_espresso') . "', 3,  1, 40, 0),
866
-							(5, '" . __('Fixed Surcharge', 'event_espresso') . "', 3,  0, 50, 0);";
862
+							(1, '".__('Base Price', 'event_espresso')."', 1,  0, 0, 0),
863
+							(2, '" . __('Percent Discount', 'event_espresso')."', 2,  1, 20, 0),
864
+							(3, '" . __('Fixed Discount', 'event_espresso')."', 2,  0, 30, 0),
865
+							(4, '" . __('Percent Surcharge', 'event_espresso')."', 3,  1, 40, 0),
866
+							(5, '" . __('Fixed Surcharge', 'event_espresso')."', 3,  0, 50, 0);";
867 867
                 $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL);
868 868
                 $wpdb->query($SQL);
869 869
             }
@@ -885,9 +885,9 @@  discard block
 block discarded – undo
885 885
     public function insert_default_prices()
886 886
     {
887 887
         global $wpdb;
888
-        $price_table = $wpdb->prefix . "esp_price";
888
+        $price_table = $wpdb->prefix."esp_price";
889 889
         if ($this->_get_table_analysis()->tableExists($price_table)) {
890
-            $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table;
890
+            $SQL = 'SELECT COUNT(PRC_ID) FROM '.$price_table;
891 891
             $prices_exist = $wpdb->get_var($SQL);
892 892
             if ( ! $prices_exist) {
893 893
                 $SQL = "INSERT INTO $price_table
@@ -911,9 +911,9 @@  discard block
 block discarded – undo
911 911
     public function insert_default_tickets()
912 912
     {
913 913
         global $wpdb;
914
-        $ticket_table = $wpdb->prefix . "esp_ticket";
914
+        $ticket_table = $wpdb->prefix."esp_ticket";
915 915
         if ($this->_get_table_analysis()->tableExists($ticket_table)) {
916
-            $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
916
+            $SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table;
917 917
             $tickets_exist = $wpdb->get_var($SQL);
918 918
             if ( ! $tickets_exist) {
919 919
                 $SQL = "INSERT INTO $ticket_table
@@ -925,9 +925,9 @@  discard block
 block discarded – undo
925 925
                 $wpdb->query($SQL);
926 926
             }
927 927
         }
928
-        $ticket_price_table = $wpdb->prefix . "esp_ticket_price";
928
+        $ticket_price_table = $wpdb->prefix."esp_ticket_price";
929 929
         if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
930
-            $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
930
+            $SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table;
931 931
             $ticket_prc_exist = $wpdb->get_var($SQL);
932 932
             if ( ! $ticket_prc_exist) {
933 933
                 $SQL = "INSERT INTO $ticket_price_table
@@ -957,7 +957,7 @@  discard block
 block discarded – undo
957 957
             throw new EE_Error(__("Could not get a country because country name is blank", "event_espresso"));
958 958
         }
959 959
         global $wpdb;
960
-        $country_table = $wpdb->prefix . "esp_country";
960
+        $country_table = $wpdb->prefix."esp_country";
961 961
         if (is_int($country_name)) {
962 962
             $country_name = $this->get_iso_from_3_1_country_id($country_name);
963 963
         }
@@ -985,21 +985,21 @@  discard block
 block discarded – undo
985 985
                     'CNT_active'      => true,
986 986
             );
987 987
             $data_types = array(
988
-                    '%s',//CNT_ISO
989
-                    '%s',//CNT_ISO3
990
-                    '%d',//RGN_ID
991
-                    '%s',//CNT_name
992
-                    '%s',//CNT_cur_code
993
-                    '%s',//CNT_cur_single
994
-                    '%s',//CNT_cur_plural
995
-                    '%s',//CNT_cur_sign
996
-                    '%d',//CNT_cur_sign_b4
997
-                    '%d',//CNT_cur_dec_plc
998
-                    '%s',//CNT_cur_dec_mrk
999
-                    '%s',//CNT_cur_thsnds
1000
-                    '%s',//CNT_tel_code
1001
-                    '%d',//CNT_is_EU
1002
-                    '%d',//CNT_active
988
+                    '%s', //CNT_ISO
989
+                    '%s', //CNT_ISO3
990
+                    '%d', //RGN_ID
991
+                    '%s', //CNT_name
992
+                    '%s', //CNT_cur_code
993
+                    '%s', //CNT_cur_single
994
+                    '%s', //CNT_cur_plural
995
+                    '%s', //CNT_cur_sign
996
+                    '%d', //CNT_cur_sign_b4
997
+                    '%d', //CNT_cur_dec_plc
998
+                    '%s', //CNT_cur_dec_mrk
999
+                    '%s', //CNT_cur_thsnds
1000
+                    '%s', //CNT_tel_code
1001
+                    '%d', //CNT_is_EU
1002
+                    '%d', //CNT_active
1003 1003
             );
1004 1004
             $success = $wpdb->insert($country_table,
1005 1005
                     $cols_n_values,
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
     private function _find_available_country_iso($num_letters = 2)
1025 1025
     {
1026 1026
         global $wpdb;
1027
-        $country_table = $wpdb->prefix . "esp_country";
1027
+        $country_table = $wpdb->prefix."esp_country";
1028 1028
         $attempts = 0;
1029 1029
         do {
1030 1030
             $current_iso = strtoupper(wp_generate_password($num_letters, false));
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
             //keep going until we find an available country code, or we arbitrarily
1036 1036
             //decide we've tried this enough. Somehow they have way too many countries
1037 1037
             //(probably because they're mis-using the EE3 country_id like a custom question)
1038
-        } while (intval($country_with_that_iso) && $attempts < 200);
1038
+        }while (intval($country_with_that_iso) && $attempts < 200);
1039 1039
         return $current_iso;
1040 1040
     }
1041 1041
 
@@ -1062,7 +1062,7 @@  discard block
 block discarded – undo
1062 1062
             $country_iso = $this->get_default_country_iso();
1063 1063
         }
1064 1064
         global $wpdb;
1065
-        $state_table = $wpdb->prefix . "esp_state";
1065
+        $state_table = $wpdb->prefix."esp_state";
1066 1066
         $state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE
1067 1067
 			(STA_abbrev LIKE %s OR
1068 1068
 			STA_name LIKE %s) AND
@@ -1076,10 +1076,10 @@  discard block
 block discarded – undo
1076 1076
                     'STA_active' => true,
1077 1077
             );
1078 1078
             $data_types = array(
1079
-                    '%s',//CNT_ISO
1080
-                    '%s',//STA_abbrev
1081
-                    '%s',//STA_name
1082
-                    '%d',//STA_active
1079
+                    '%s', //CNT_ISO
1080
+                    '%s', //STA_abbrev
1081
+                    '%s', //STA_name
1082
+                    '%d', //STA_active
1083 1083
             );
1084 1084
             $success = $wpdb->insert($state_table, $cols_n_values, $data_types);
1085 1085
             if ( ! $success) {
@@ -1510,7 +1510,7 @@  discard block
 block discarded – undo
1510 1510
                         "event_espresso"), $guid));
1511 1511
                 return false;
1512 1512
             }
1513
-            $local_filepath = $wp_upload_dir['path'] . DS . basename($guid);
1513
+            $local_filepath = $wp_upload_dir['path'].DS.basename($guid);
1514 1514
             $savefile = fopen($local_filepath, 'w');
1515 1515
             fwrite($savefile, $contents);
1516 1516
             fclose($savefile);
@@ -1533,7 +1533,7 @@  discard block
 block discarded – undo
1533 1533
         }
1534 1534
         // you must first include the image.php file
1535 1535
         // for the function wp_generate_attachment_metadata() to work
1536
-        require_once(ABSPATH . 'wp-admin/includes/image.php');
1536
+        require_once(ABSPATH.'wp-admin/includes/image.php');
1537 1537
         $attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath);
1538 1538
         if ( ! $attach_data) {
1539 1539
             $migration_stage->add_error(sprintf(__("Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.",
Please login to merge, or discard this patch.
core/EE_Capabilities.core.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
      * @since                        4.5.0
806 806
      *
807 807
      * @param string $meta_cap   What meta capability is this mapping.
808
-     * @param array  $map_values array {
808
+     * @param string[]  $map_values array {
809 809
      *                           //array of values that MUST match a count of 4.  It's okay to send an empty string for
810 810
      *                           capabilities that don't get mapped to.
811 811
      *
@@ -880,8 +880,8 @@  discard block
 block discarded – undo
880 880
      * @since 4.6.x
881 881
      *
882 882
      * @param $caps
883
-     * @param $cap
884
-     * @param $user_id
883
+     * @param string $cap
884
+     * @param integer $user_id
885 885
      * @param $args
886 886
      *
887 887
      * @return array
Please login to merge, or discard this patch.
Indentation   +1031 added lines, -1031 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @subpackage core, capabilities
9 9
  */
10 10
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
11
-    exit('No direct script access allowed');
11
+	exit('No direct script access allowed');
12 12
 }
13 13
 
14 14
 
@@ -27,751 +27,751 @@  discard block
 block discarded – undo
27 27
 {
28 28
     
29 29
     
30
-    /**
31
-     * instance of EE_Capabilities object
32
-     *
33
-     * @var EE_Capabilities
34
-     */
35
-    private static $_instance = null;
30
+	/**
31
+	 * instance of EE_Capabilities object
32
+	 *
33
+	 * @var EE_Capabilities
34
+	 */
35
+	private static $_instance = null;
36 36
     
37 37
     
38
-    /**
39
-     * This is a map of caps that correspond to a default WP_Role.
40
-     * Array is indexed by Role and values are ee capabilities.
41
-     *
42
-     * @since 4.5.0
43
-     *
44
-     * @var array
45
-     */
46
-    private $_caps_map = array();
38
+	/**
39
+	 * This is a map of caps that correspond to a default WP_Role.
40
+	 * Array is indexed by Role and values are ee capabilities.
41
+	 *
42
+	 * @since 4.5.0
43
+	 *
44
+	 * @var array
45
+	 */
46
+	private $_caps_map = array();
47 47
     
48 48
     
49
-    /**
50
-     * This used to hold an array of EE_Meta_Capability_Map objects that define the granular capabilities mapped to for
51
-     * a user depending on context.
52
-     *
53
-     * @var EE_Meta_Capability_Map[]
54
-     */
55
-    private $_meta_caps = array();
49
+	/**
50
+	 * This used to hold an array of EE_Meta_Capability_Map objects that define the granular capabilities mapped to for
51
+	 * a user depending on context.
52
+	 *
53
+	 * @var EE_Meta_Capability_Map[]
54
+	 */
55
+	private $_meta_caps = array();
56 56
     
57
-    /**
58
-     * the name of the wp option used to store caps previously initialized
59
-     */
60
-    const option_name = 'ee_caps_initialized';
57
+	/**
58
+	 * the name of the wp option used to store caps previously initialized
59
+	 */
60
+	const option_name = 'ee_caps_initialized';
61 61
     
62 62
     
63
-    /**
64
-     * singleton method used to instantiate class object
65
-     *
66
-     * @since 4.5.0
67
-     *
68
-     * @return EE_Capabilities
69
-     */
70
-    public static function instance()
71
-    {
72
-        //check if instantiated, and if not do so.
73
-        if ( ! self::$_instance instanceof EE_Capabilities) {
74
-            self::$_instance = new self();
75
-        }
63
+	/**
64
+	 * singleton method used to instantiate class object
65
+	 *
66
+	 * @since 4.5.0
67
+	 *
68
+	 * @return EE_Capabilities
69
+	 */
70
+	public static function instance()
71
+	{
72
+		//check if instantiated, and if not do so.
73
+		if ( ! self::$_instance instanceof EE_Capabilities) {
74
+			self::$_instance = new self();
75
+		}
76 76
         
77
-        return self::$_instance;
78
-    }
77
+		return self::$_instance;
78
+	}
79 79
     
80 80
     
81
-    /**
82
-     * private constructor
83
-     *
84
-     * @since 4.5.0
85
-     *
86
-     * @return \EE_Capabilities
87
-     */
88
-    private function __construct()
89
-    {
90
-    }
81
+	/**
82
+	 * private constructor
83
+	 *
84
+	 * @since 4.5.0
85
+	 *
86
+	 * @return \EE_Capabilities
87
+	 */
88
+	private function __construct()
89
+	{
90
+	}
91 91
     
92 92
     
93
-    /**
94
-     * This delays the initialization of the capabilities class until EE_System core is loaded and ready.
95
-     *
96
-     * @param bool $reset allows for resetting the default capabilities saved on roles.  Note that this doesn't
97
-     *                    actually REMOVE any capabilities from existing roles, it just resaves defaults roles and
98
-     *                    ensures that they are up to date.
99
-     *
100
-     *
101
-     * @since 4.5.0
102
-     * @return void
103
-     */
104
-    public function init_caps($reset = false)
105
-    {
106
-        if (EE_Maintenance_Mode::instance()->models_can_query()) {
107
-            $this->_caps_map = $this->_init_caps_map();
108
-            $this->init_role_caps($reset);
109
-            $this->_set_meta_caps();
110
-        }
111
-    }
93
+	/**
94
+	 * This delays the initialization of the capabilities class until EE_System core is loaded and ready.
95
+	 *
96
+	 * @param bool $reset allows for resetting the default capabilities saved on roles.  Note that this doesn't
97
+	 *                    actually REMOVE any capabilities from existing roles, it just resaves defaults roles and
98
+	 *                    ensures that they are up to date.
99
+	 *
100
+	 *
101
+	 * @since 4.5.0
102
+	 * @return void
103
+	 */
104
+	public function init_caps($reset = false)
105
+	{
106
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
107
+			$this->_caps_map = $this->_init_caps_map();
108
+			$this->init_role_caps($reset);
109
+			$this->_set_meta_caps();
110
+		}
111
+	}
112 112
     
113 113
     
114
-    /**
115
-     * This sets the meta caps property.
116
-     * @since 4.5.0
117
-     *
118
-     * @return void
119
-     */
120
-    private function _set_meta_caps()
121
-    {
122
-        //make sure we're only ever initializing the default _meta_caps array once if it's empty.
123
-        $this->_meta_caps = $this->_get_default_meta_caps_array();
114
+	/**
115
+	 * This sets the meta caps property.
116
+	 * @since 4.5.0
117
+	 *
118
+	 * @return void
119
+	 */
120
+	private function _set_meta_caps()
121
+	{
122
+		//make sure we're only ever initializing the default _meta_caps array once if it's empty.
123
+		$this->_meta_caps = $this->_get_default_meta_caps_array();
124 124
         
125
-        $this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps);
125
+		$this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps);
126 126
         
127
-        //add filter for map_meta_caps but only if models can query.
128
-        if (EE_Maintenance_Mode::instance()->models_can_query() && ! has_filter('map_meta_cap',
129
-                array($this, 'map_meta_caps'))
130
-        ) {
131
-            add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4);
132
-        }
133
-    }
127
+		//add filter for map_meta_caps but only if models can query.
128
+		if (EE_Maintenance_Mode::instance()->models_can_query() && ! has_filter('map_meta_cap',
129
+				array($this, 'map_meta_caps'))
130
+		) {
131
+			add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4);
132
+		}
133
+	}
134 134
     
135 135
     
136
-    /**
137
-     * This builds and returns the default meta_caps array only once.
138
-     *
139
-     * @since  4.8.28.rc.012
140
-     * @return array
141
-     */
142
-    private function _get_default_meta_caps_array()
143
-    {
144
-        static $default_meta_caps = array();
145
-        if (empty($default_meta_caps)) {
146
-            $default_meta_caps = array(
147
-                //edits
148
-                new EE_Meta_Capability_Map_Edit('ee_edit_event',
149
-                    array('Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events')),
150
-                new EE_Meta_Capability_Map_Edit('ee_edit_venue',
151
-                    array('Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues')),
152
-                new EE_Meta_Capability_Map_Edit('ee_edit_registration',
153
-                    array('Registration', '', 'ee_edit_others_registrations', '')),
154
-                new EE_Meta_Capability_Map_Edit('ee_edit_checkin',
155
-                    array('Registration', '', 'ee_edit_others_checkins', '')),
156
-                new EE_Meta_Capability_Map_Messages_Cap('ee_edit_message',
157
-                    array('Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages')),
158
-                new EE_Meta_Capability_Map_Edit('ee_edit_default_ticket',
159
-                    array('Ticket', '', 'ee_edit_others_default_tickets', '')),
160
-                new EE_Meta_Capability_Map_Registration_Form_Cap('ee_edit_question',
161
-                    array('Question', '', '', 'ee_edit_system_questions')),
162
-                new EE_Meta_Capability_Map_Registration_Form_Cap('ee_edit_question_group',
163
-                    array('Question_Group', '', '', 'ee_edit_system_question_groups')),
164
-                new EE_Meta_Capability_Map_Edit('ee_edit_payment_method',
165
-                    array('Payment_Method', '', 'ee_edit_others_payment_methods', '')),
166
-                //reads
167
-                new EE_Meta_Capability_Map_Read('ee_read_event',
168
-                    array('Event', '', 'ee_read_others_events', 'ee_read_private_events')),
169
-                new EE_Meta_Capability_Map_Read('ee_read_venue',
170
-                    array('Venue', '', 'ee_read_others_venues', 'ee_read_private_venues')),
171
-                new EE_Meta_Capability_Map_Read('ee_read_registration',
172
-                    array('Registration', '', '', 'ee_edit_others_registrations')),
173
-                new EE_Meta_Capability_Map_Read('ee_read_checkin',
174
-                    array('Registration', '', '', 'ee_read_others_checkins')),
175
-                new EE_Meta_Capability_Map_Messages_Cap('ee_read_message',
176
-                    array('Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages')),
177
-                new EE_Meta_Capability_Map_Read('ee_read_default_ticket',
178
-                    array('Ticket', '', '', 'ee_read_others_default_tickets')),
179
-                new EE_Meta_Capability_Map_Read('ee_read_payment_method',
180
-                    array('Payment_Method', '', '', 'ee_read_others_payment_methods')),
136
+	/**
137
+	 * This builds and returns the default meta_caps array only once.
138
+	 *
139
+	 * @since  4.8.28.rc.012
140
+	 * @return array
141
+	 */
142
+	private function _get_default_meta_caps_array()
143
+	{
144
+		static $default_meta_caps = array();
145
+		if (empty($default_meta_caps)) {
146
+			$default_meta_caps = array(
147
+				//edits
148
+				new EE_Meta_Capability_Map_Edit('ee_edit_event',
149
+					array('Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events')),
150
+				new EE_Meta_Capability_Map_Edit('ee_edit_venue',
151
+					array('Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues')),
152
+				new EE_Meta_Capability_Map_Edit('ee_edit_registration',
153
+					array('Registration', '', 'ee_edit_others_registrations', '')),
154
+				new EE_Meta_Capability_Map_Edit('ee_edit_checkin',
155
+					array('Registration', '', 'ee_edit_others_checkins', '')),
156
+				new EE_Meta_Capability_Map_Messages_Cap('ee_edit_message',
157
+					array('Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages')),
158
+				new EE_Meta_Capability_Map_Edit('ee_edit_default_ticket',
159
+					array('Ticket', '', 'ee_edit_others_default_tickets', '')),
160
+				new EE_Meta_Capability_Map_Registration_Form_Cap('ee_edit_question',
161
+					array('Question', '', '', 'ee_edit_system_questions')),
162
+				new EE_Meta_Capability_Map_Registration_Form_Cap('ee_edit_question_group',
163
+					array('Question_Group', '', '', 'ee_edit_system_question_groups')),
164
+				new EE_Meta_Capability_Map_Edit('ee_edit_payment_method',
165
+					array('Payment_Method', '', 'ee_edit_others_payment_methods', '')),
166
+				//reads
167
+				new EE_Meta_Capability_Map_Read('ee_read_event',
168
+					array('Event', '', 'ee_read_others_events', 'ee_read_private_events')),
169
+				new EE_Meta_Capability_Map_Read('ee_read_venue',
170
+					array('Venue', '', 'ee_read_others_venues', 'ee_read_private_venues')),
171
+				new EE_Meta_Capability_Map_Read('ee_read_registration',
172
+					array('Registration', '', '', 'ee_edit_others_registrations')),
173
+				new EE_Meta_Capability_Map_Read('ee_read_checkin',
174
+					array('Registration', '', '', 'ee_read_others_checkins')),
175
+				new EE_Meta_Capability_Map_Messages_Cap('ee_read_message',
176
+					array('Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages')),
177
+				new EE_Meta_Capability_Map_Read('ee_read_default_ticket',
178
+					array('Ticket', '', '', 'ee_read_others_default_tickets')),
179
+				new EE_Meta_Capability_Map_Read('ee_read_payment_method',
180
+					array('Payment_Method', '', '', 'ee_read_others_payment_methods')),
181 181
                 
182
-                //deletes
183
-                new EE_Meta_Capability_Map_Delete('ee_delete_event', array(
184
-                    'Event',
185
-                    'ee_delete_published_events',
186
-                    'ee_delete_others_events',
187
-                    'ee_delete_private_events'
188
-                )),
189
-                new EE_Meta_Capability_Map_Delete('ee_delete_venue', array(
190
-                    'Venue',
191
-                    'ee_delete_published_venues',
192
-                    'ee_delete_others_venues',
193
-                    'ee_delete_private_venues'
194
-                )),
195
-                new EE_Meta_Capability_Map_Delete('ee_delete_registration',
196
-                    array('Registration', '', 'ee_delete_others_registrations', '')),
197
-                new EE_Meta_Capability_Map_Delete('ee_delete_checkin',
198
-                    array('Registration', '', 'ee_delete_others_checkins', '')),
199
-                new EE_Meta_Capability_Map_Messages_Cap('ee_delete_message',
200
-                    array('Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages')),
201
-                new EE_Meta_Capability_Map_Delete('ee_delete_default_ticket',
202
-                    array('Ticket', '', 'ee_delete_others_default_tickets', '')),
203
-                new EE_Meta_Capability_Map_Registration_Form_Cap('ee_delete_question',
204
-                    array('Question', '', '', 'delete_system_questions')),
205
-                new EE_Meta_Capability_Map_Registration_Form_Cap('ee_delete_question_group',
206
-                    array('Question_Group', '', '', 'delete_system_question_groups')),
207
-                new EE_Meta_Capability_Map_Delete('ee_delete_payment_method',
208
-                    array('Payment_Method', '', 'ee_delete_others_payment_methods', '')),
209
-            );
210
-        }
182
+				//deletes
183
+				new EE_Meta_Capability_Map_Delete('ee_delete_event', array(
184
+					'Event',
185
+					'ee_delete_published_events',
186
+					'ee_delete_others_events',
187
+					'ee_delete_private_events'
188
+				)),
189
+				new EE_Meta_Capability_Map_Delete('ee_delete_venue', array(
190
+					'Venue',
191
+					'ee_delete_published_venues',
192
+					'ee_delete_others_venues',
193
+					'ee_delete_private_venues'
194
+				)),
195
+				new EE_Meta_Capability_Map_Delete('ee_delete_registration',
196
+					array('Registration', '', 'ee_delete_others_registrations', '')),
197
+				new EE_Meta_Capability_Map_Delete('ee_delete_checkin',
198
+					array('Registration', '', 'ee_delete_others_checkins', '')),
199
+				new EE_Meta_Capability_Map_Messages_Cap('ee_delete_message',
200
+					array('Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages')),
201
+				new EE_Meta_Capability_Map_Delete('ee_delete_default_ticket',
202
+					array('Ticket', '', 'ee_delete_others_default_tickets', '')),
203
+				new EE_Meta_Capability_Map_Registration_Form_Cap('ee_delete_question',
204
+					array('Question', '', '', 'delete_system_questions')),
205
+				new EE_Meta_Capability_Map_Registration_Form_Cap('ee_delete_question_group',
206
+					array('Question_Group', '', '', 'delete_system_question_groups')),
207
+				new EE_Meta_Capability_Map_Delete('ee_delete_payment_method',
208
+					array('Payment_Method', '', 'ee_delete_others_payment_methods', '')),
209
+			);
210
+		}
211 211
         
212
-        return $default_meta_caps;
213
-    }
212
+		return $default_meta_caps;
213
+	}
214 214
     
215 215
     
216
-    /**
217
-     * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
218
-     * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
219
-     *
220
-     * The actual logic is carried out by implementer classes in their definition of _map_meta_caps.
221
-     *
222
-     * @since 4.5.0
223
-     * @see   wp-includes/capabilities.php
224
-     *
225
-     * @param array  $caps    actual users capabilities
226
-     * @param string $cap     initial capability name that is being checked (the "map" key)
227
-     * @param int    $user_id The user id
228
-     * @param array  $args    Adds context to the cap. Typically the object ID.
229
-     *
230
-     * @return array   actual users capabilities
231
-     */
232
-    public function map_meta_caps($caps, $cap, $user_id, $args)
233
-    {
234
-        if (did_action('AHEE__EE_System__load_espresso_addons__complete')) {
235
-            //loop through our _meta_caps array
236
-            foreach ($this->_meta_caps as $meta_map) {
237
-                if (! $meta_map instanceof EE_Meta_Capability_Map) {
238
-                    continue;
239
-                }
240
-                $meta_map->ensure_is_model();
216
+	/**
217
+	 * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
218
+	 * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
219
+	 *
220
+	 * The actual logic is carried out by implementer classes in their definition of _map_meta_caps.
221
+	 *
222
+	 * @since 4.5.0
223
+	 * @see   wp-includes/capabilities.php
224
+	 *
225
+	 * @param array  $caps    actual users capabilities
226
+	 * @param string $cap     initial capability name that is being checked (the "map" key)
227
+	 * @param int    $user_id The user id
228
+	 * @param array  $args    Adds context to the cap. Typically the object ID.
229
+	 *
230
+	 * @return array   actual users capabilities
231
+	 */
232
+	public function map_meta_caps($caps, $cap, $user_id, $args)
233
+	{
234
+		if (did_action('AHEE__EE_System__load_espresso_addons__complete')) {
235
+			//loop through our _meta_caps array
236
+			foreach ($this->_meta_caps as $meta_map) {
237
+				if (! $meta_map instanceof EE_Meta_Capability_Map) {
238
+					continue;
239
+				}
240
+				$meta_map->ensure_is_model();
241 241
                 
242
-                $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args);
243
-            }
244
-        }
242
+				$caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args);
243
+			}
244
+		}
245 245
         
246
-        return $caps;
247
-    }
246
+		return $caps;
247
+	}
248 248
     
249 249
     
250
-    /**
251
-     * This sets up and returns the initial capabilities map for Event Espresso
252
-     *
253
-     * @since 4.5.0
254
-     *
255
-     * @return array
256
-     */
257
-    private function _init_caps_map()
258
-    {
259
-        $caps = array(
260
-            'administrator'           => array(
261
-                //basic access
262
-                'ee_read_ee',
263
-                //gateways
264
-                /**
265
-                 * note that with payment method capabilities, although we've implemented
266
-                 * capability mapping which will be used for accessing payment methods owned by
267
-                 * other users.  This is not fully implemented yet in the payment method ui.
268
-                 * Currently only the "plural" caps are in active use. (Specific payment method caps are in use as well).
269
-                 **/
270
-                'ee_manage_gateways',
271
-                'ee_read_payment_method',
272
-                'ee_read_payment_methods',
273
-                'ee_read_others_payment_methods',
274
-                'ee_edit_payment_method',
275
-                'ee_edit_payment_methods',
276
-                'ee_edit_others_payment_methods',
277
-                'ee_delete_payment_method',
278
-                'ee_delete_payment_methods',
279
-                //events
280
-                'ee_publish_events',
281
-                'ee_read_private_events',
282
-                'ee_read_others_events',
283
-                'ee_read_event',
284
-                'ee_read_events',
285
-                'ee_edit_event',
286
-                'ee_edit_events',
287
-                'ee_edit_published_events',
288
-                'ee_edit_others_events',
289
-                'ee_edit_private_events',
290
-                'ee_delete_published_events',
291
-                'ee_delete_private_events',
292
-                'ee_delete_event',
293
-                'ee_delete_events',
294
-                'ee_delete_others_events',
295
-                //event categories
296
-                'ee_manage_event_categories',
297
-                'ee_edit_event_category',
298
-                'ee_delete_event_category',
299
-                'ee_assign_event_category',
300
-                //venues
301
-                'ee_publish_venues',
302
-                'ee_read_venue',
303
-                'ee_read_venues',
304
-                'ee_read_others_venues',
305
-                'ee_read_private_venues',
306
-                'ee_edit_venue',
307
-                'ee_edit_venues',
308
-                'ee_edit_others_venues',
309
-                'ee_edit_published_venues',
310
-                'ee_edit_private_venues',
311
-                'ee_delete_venue',
312
-                'ee_delete_venues',
313
-                'ee_delete_others_venues',
314
-                'ee_delete_private_venues',
315
-                'ee_delete_published_venues',
316
-                //venue categories
317
-                'ee_manage_venue_categories',
318
-                'ee_edit_venue_category',
319
-                'ee_delete_venue_category',
320
-                'ee_assign_venue_category',
321
-                //contacts
322
-                'ee_read_contact',
323
-                'ee_read_contacts',
324
-                'ee_edit_contact',
325
-                'ee_edit_contacts',
326
-                'ee_delete_contact',
327
-                'ee_delete_contacts',
328
-                //registrations
329
-                'ee_read_registration',
330
-                'ee_read_registrations',
331
-                'ee_read_others_registrations',
332
-                'ee_edit_registration',
333
-                'ee_edit_registrations',
334
-                'ee_edit_others_registrations',
335
-                'ee_delete_registration',
336
-                'ee_delete_registrations',
337
-                //checkins
338
-                'ee_read_checkin',
339
-                'ee_read_others_checkins',
340
-                'ee_read_checkins',
341
-                'ee_edit_checkin',
342
-                'ee_edit_checkins',
343
-                'ee_edit_others_checkins',
344
-                'ee_delete_checkin',
345
-                'ee_delete_checkins',
346
-                'ee_delete_others_checkins',
347
-                //transactions && payments
348
-                'ee_read_transaction',
349
-                'ee_read_transactions',
350
-                'ee_edit_payments',
351
-                'ee_delete_payments',
352
-                //messages
353
-                'ee_read_message',
354
-                'ee_read_messages',
355
-                'ee_read_others_messages',
356
-                'ee_read_global_messages',
357
-                'ee_edit_global_messages',
358
-                'ee_edit_message',
359
-                'ee_edit_messages',
360
-                'ee_edit_others_messages',
361
-                'ee_delete_message',
362
-                'ee_delete_messages',
363
-                'ee_delete_others_messages',
364
-                'ee_delete_global_messages',
365
-                'ee_send_message',
366
-                //tickets
367
-                'ee_read_default_ticket',
368
-                'ee_read_default_tickets',
369
-                'ee_read_others_default_tickets',
370
-                'ee_edit_default_ticket',
371
-                'ee_edit_default_tickets',
372
-                'ee_edit_others_default_tickets',
373
-                'ee_delete_default_ticket',
374
-                'ee_delete_default_tickets',
375
-                'ee_delete_others_default_tickets',
376
-                //prices
377
-                'ee_edit_default_price',
378
-                'ee_edit_default_prices',
379
-                'ee_delete_default_price',
380
-                'ee_delete_default_prices',
381
-                'ee_edit_default_price_type',
382
-                'ee_edit_default_price_types',
383
-                'ee_delete_default_price_type',
384
-                'ee_delete_default_price_types',
385
-                'ee_read_default_prices',
386
-                'ee_read_default_price_types',
387
-                //registration form
388
-                'ee_edit_question',
389
-                'ee_edit_questions',
390
-                'ee_edit_system_questions',
391
-                'ee_read_questions',
392
-                'ee_delete_question',
393
-                'ee_delete_questions',
394
-                'ee_edit_question_group',
395
-                'ee_edit_question_groups',
396
-                'ee_read_question_groups',
397
-                'ee_edit_system_question_groups',
398
-                'ee_delete_question_group',
399
-                'ee_delete_question_groups',
400
-                //event_type taxonomy
401
-                'ee_assign_event_type',
402
-                'ee_manage_event_types',
403
-                'ee_edit_event_type',
404
-                'ee_delete_event_type',
405
-            ),
406
-            'ee_events_administrator' => array(
407
-                //core wp caps
408
-                'read',
409
-                'read_private_pages',
410
-                'read_private_posts',
411
-                'edit_users',
412
-                'edit_posts',
413
-                'edit_pages',
414
-                'edit_published_posts',
415
-                'edit_published_pages',
416
-                'edit_private_pages',
417
-                'edit_private_posts',
418
-                'edit_others_posts',
419
-                'edit_others_pages',
420
-                'publish_posts',
421
-                'publish_pages',
422
-                'delete_posts',
423
-                'delete_pages',
424
-                'delete_private_pages',
425
-                'delete_private_posts',
426
-                'delete_published_pages',
427
-                'delete_published_posts',
428
-                'delete_others_posts',
429
-                'delete_others_pages',
430
-                'manage_categories',
431
-                'manage_links',
432
-                'moderate_comments',
433
-                'unfiltered_html',
434
-                'upload_files',
435
-                'export',
436
-                'import',
437
-                'list_users',
438
-                'level_1', //required if user with this role shows up in author dropdowns
439
-                //basic ee access
440
-                'ee_read_ee',
441
-                //events
442
-                'ee_publish_events',
443
-                'ee_read_private_events',
444
-                'ee_read_others_events',
445
-                'ee_read_event',
446
-                'ee_read_events',
447
-                'ee_edit_event',
448
-                'ee_edit_events',
449
-                'ee_edit_published_events',
450
-                'ee_edit_others_events',
451
-                'ee_edit_private_events',
452
-                'ee_delete_published_events',
453
-                'ee_delete_private_events',
454
-                'ee_delete_event',
455
-                'ee_delete_events',
456
-                'ee_delete_others_events',
457
-                //event categories
458
-                'ee_manage_event_categories',
459
-                'ee_edit_event_category',
460
-                'ee_delete_event_category',
461
-                'ee_assign_event_category',
462
-                //venues
463
-                'ee_publish_venues',
464
-                'ee_read_venue',
465
-                'ee_read_venues',
466
-                'ee_read_others_venues',
467
-                'ee_read_private_venues',
468
-                'ee_edit_venue',
469
-                'ee_edit_venues',
470
-                'ee_edit_others_venues',
471
-                'ee_edit_published_venues',
472
-                'ee_edit_private_venues',
473
-                'ee_delete_venue',
474
-                'ee_delete_venues',
475
-                'ee_delete_others_venues',
476
-                'ee_delete_private_venues',
477
-                'ee_delete_published_venues',
478
-                //venue categories
479
-                'ee_manage_venue_categories',
480
-                'ee_edit_venue_category',
481
-                'ee_delete_venue_category',
482
-                'ee_assign_venue_category',
483
-                //contacts
484
-                'ee_read_contact',
485
-                'ee_read_contacts',
486
-                'ee_edit_contact',
487
-                'ee_edit_contacts',
488
-                'ee_delete_contact',
489
-                'ee_delete_contacts',
490
-                //registrations
491
-                'ee_read_registration',
492
-                'ee_read_registrations',
493
-                'ee_read_others_registrations',
494
-                'ee_edit_registration',
495
-                'ee_edit_registrations',
496
-                'ee_edit_others_registrations',
497
-                'ee_delete_registration',
498
-                'ee_delete_registrations',
499
-                //checkins
500
-                'ee_read_checkin',
501
-                'ee_read_others_checkins',
502
-                'ee_read_checkins',
503
-                'ee_edit_checkin',
504
-                'ee_edit_checkins',
505
-                'ee_edit_others_checkins',
506
-                'ee_delete_checkin',
507
-                'ee_delete_checkins',
508
-                'ee_delete_others_checkins',
509
-                //transactions && payments
510
-                'ee_read_transaction',
511
-                'ee_read_transactions',
512
-                'ee_edit_payments',
513
-                'ee_delete_payments',
514
-                //messages
515
-                'ee_read_message',
516
-                'ee_read_messages',
517
-                'ee_read_others_messages',
518
-                'ee_read_global_messages',
519
-                'ee_edit_global_messages',
520
-                'ee_edit_message',
521
-                'ee_edit_messages',
522
-                'ee_edit_others_messages',
523
-                'ee_delete_message',
524
-                'ee_delete_messages',
525
-                'ee_delete_others_messages',
526
-                'ee_delete_global_messages',
527
-                'ee_send_message',
528
-                //tickets
529
-                'ee_read_default_ticket',
530
-                'ee_read_default_tickets',
531
-                'ee_read_others_default_tickets',
532
-                'ee_edit_default_ticket',
533
-                'ee_edit_default_tickets',
534
-                'ee_edit_others_default_tickets',
535
-                'ee_delete_default_ticket',
536
-                'ee_delete_default_tickets',
537
-                'ee_delete_others_default_tickets',
538
-                //prices
539
-                'ee_edit_default_price',
540
-                'ee_edit_default_prices',
541
-                'ee_delete_default_price',
542
-                'ee_delete_default_prices',
543
-                'ee_edit_default_price_type',
544
-                'ee_edit_default_price_types',
545
-                'ee_delete_default_price_type',
546
-                'ee_delete_default_price_types',
547
-                'ee_read_default_prices',
548
-                'ee_read_default_price_types',
549
-                //registration form
550
-                'ee_edit_question',
551
-                'ee_edit_questions',
552
-                'ee_edit_system_questions',
553
-                'ee_read_questions',
554
-                'ee_delete_question',
555
-                'ee_delete_questions',
556
-                'ee_edit_question_group',
557
-                'ee_edit_question_groups',
558
-                'ee_read_question_groups',
559
-                'ee_edit_system_question_groups',
560
-                'ee_delete_question_group',
561
-                'ee_delete_question_groups',
562
-                //event_type taxonomy
563
-                'ee_assign_event_type',
564
-                'ee_manage_event_types',
565
-                'ee_edit_event_type',
566
-                'ee_delete_event_type',
567
-            )
568
-        );
250
+	/**
251
+	 * This sets up and returns the initial capabilities map for Event Espresso
252
+	 *
253
+	 * @since 4.5.0
254
+	 *
255
+	 * @return array
256
+	 */
257
+	private function _init_caps_map()
258
+	{
259
+		$caps = array(
260
+			'administrator'           => array(
261
+				//basic access
262
+				'ee_read_ee',
263
+				//gateways
264
+				/**
265
+				 * note that with payment method capabilities, although we've implemented
266
+				 * capability mapping which will be used for accessing payment methods owned by
267
+				 * other users.  This is not fully implemented yet in the payment method ui.
268
+				 * Currently only the "plural" caps are in active use. (Specific payment method caps are in use as well).
269
+				 **/
270
+				'ee_manage_gateways',
271
+				'ee_read_payment_method',
272
+				'ee_read_payment_methods',
273
+				'ee_read_others_payment_methods',
274
+				'ee_edit_payment_method',
275
+				'ee_edit_payment_methods',
276
+				'ee_edit_others_payment_methods',
277
+				'ee_delete_payment_method',
278
+				'ee_delete_payment_methods',
279
+				//events
280
+				'ee_publish_events',
281
+				'ee_read_private_events',
282
+				'ee_read_others_events',
283
+				'ee_read_event',
284
+				'ee_read_events',
285
+				'ee_edit_event',
286
+				'ee_edit_events',
287
+				'ee_edit_published_events',
288
+				'ee_edit_others_events',
289
+				'ee_edit_private_events',
290
+				'ee_delete_published_events',
291
+				'ee_delete_private_events',
292
+				'ee_delete_event',
293
+				'ee_delete_events',
294
+				'ee_delete_others_events',
295
+				//event categories
296
+				'ee_manage_event_categories',
297
+				'ee_edit_event_category',
298
+				'ee_delete_event_category',
299
+				'ee_assign_event_category',
300
+				//venues
301
+				'ee_publish_venues',
302
+				'ee_read_venue',
303
+				'ee_read_venues',
304
+				'ee_read_others_venues',
305
+				'ee_read_private_venues',
306
+				'ee_edit_venue',
307
+				'ee_edit_venues',
308
+				'ee_edit_others_venues',
309
+				'ee_edit_published_venues',
310
+				'ee_edit_private_venues',
311
+				'ee_delete_venue',
312
+				'ee_delete_venues',
313
+				'ee_delete_others_venues',
314
+				'ee_delete_private_venues',
315
+				'ee_delete_published_venues',
316
+				//venue categories
317
+				'ee_manage_venue_categories',
318
+				'ee_edit_venue_category',
319
+				'ee_delete_venue_category',
320
+				'ee_assign_venue_category',
321
+				//contacts
322
+				'ee_read_contact',
323
+				'ee_read_contacts',
324
+				'ee_edit_contact',
325
+				'ee_edit_contacts',
326
+				'ee_delete_contact',
327
+				'ee_delete_contacts',
328
+				//registrations
329
+				'ee_read_registration',
330
+				'ee_read_registrations',
331
+				'ee_read_others_registrations',
332
+				'ee_edit_registration',
333
+				'ee_edit_registrations',
334
+				'ee_edit_others_registrations',
335
+				'ee_delete_registration',
336
+				'ee_delete_registrations',
337
+				//checkins
338
+				'ee_read_checkin',
339
+				'ee_read_others_checkins',
340
+				'ee_read_checkins',
341
+				'ee_edit_checkin',
342
+				'ee_edit_checkins',
343
+				'ee_edit_others_checkins',
344
+				'ee_delete_checkin',
345
+				'ee_delete_checkins',
346
+				'ee_delete_others_checkins',
347
+				//transactions && payments
348
+				'ee_read_transaction',
349
+				'ee_read_transactions',
350
+				'ee_edit_payments',
351
+				'ee_delete_payments',
352
+				//messages
353
+				'ee_read_message',
354
+				'ee_read_messages',
355
+				'ee_read_others_messages',
356
+				'ee_read_global_messages',
357
+				'ee_edit_global_messages',
358
+				'ee_edit_message',
359
+				'ee_edit_messages',
360
+				'ee_edit_others_messages',
361
+				'ee_delete_message',
362
+				'ee_delete_messages',
363
+				'ee_delete_others_messages',
364
+				'ee_delete_global_messages',
365
+				'ee_send_message',
366
+				//tickets
367
+				'ee_read_default_ticket',
368
+				'ee_read_default_tickets',
369
+				'ee_read_others_default_tickets',
370
+				'ee_edit_default_ticket',
371
+				'ee_edit_default_tickets',
372
+				'ee_edit_others_default_tickets',
373
+				'ee_delete_default_ticket',
374
+				'ee_delete_default_tickets',
375
+				'ee_delete_others_default_tickets',
376
+				//prices
377
+				'ee_edit_default_price',
378
+				'ee_edit_default_prices',
379
+				'ee_delete_default_price',
380
+				'ee_delete_default_prices',
381
+				'ee_edit_default_price_type',
382
+				'ee_edit_default_price_types',
383
+				'ee_delete_default_price_type',
384
+				'ee_delete_default_price_types',
385
+				'ee_read_default_prices',
386
+				'ee_read_default_price_types',
387
+				//registration form
388
+				'ee_edit_question',
389
+				'ee_edit_questions',
390
+				'ee_edit_system_questions',
391
+				'ee_read_questions',
392
+				'ee_delete_question',
393
+				'ee_delete_questions',
394
+				'ee_edit_question_group',
395
+				'ee_edit_question_groups',
396
+				'ee_read_question_groups',
397
+				'ee_edit_system_question_groups',
398
+				'ee_delete_question_group',
399
+				'ee_delete_question_groups',
400
+				//event_type taxonomy
401
+				'ee_assign_event_type',
402
+				'ee_manage_event_types',
403
+				'ee_edit_event_type',
404
+				'ee_delete_event_type',
405
+			),
406
+			'ee_events_administrator' => array(
407
+				//core wp caps
408
+				'read',
409
+				'read_private_pages',
410
+				'read_private_posts',
411
+				'edit_users',
412
+				'edit_posts',
413
+				'edit_pages',
414
+				'edit_published_posts',
415
+				'edit_published_pages',
416
+				'edit_private_pages',
417
+				'edit_private_posts',
418
+				'edit_others_posts',
419
+				'edit_others_pages',
420
+				'publish_posts',
421
+				'publish_pages',
422
+				'delete_posts',
423
+				'delete_pages',
424
+				'delete_private_pages',
425
+				'delete_private_posts',
426
+				'delete_published_pages',
427
+				'delete_published_posts',
428
+				'delete_others_posts',
429
+				'delete_others_pages',
430
+				'manage_categories',
431
+				'manage_links',
432
+				'moderate_comments',
433
+				'unfiltered_html',
434
+				'upload_files',
435
+				'export',
436
+				'import',
437
+				'list_users',
438
+				'level_1', //required if user with this role shows up in author dropdowns
439
+				//basic ee access
440
+				'ee_read_ee',
441
+				//events
442
+				'ee_publish_events',
443
+				'ee_read_private_events',
444
+				'ee_read_others_events',
445
+				'ee_read_event',
446
+				'ee_read_events',
447
+				'ee_edit_event',
448
+				'ee_edit_events',
449
+				'ee_edit_published_events',
450
+				'ee_edit_others_events',
451
+				'ee_edit_private_events',
452
+				'ee_delete_published_events',
453
+				'ee_delete_private_events',
454
+				'ee_delete_event',
455
+				'ee_delete_events',
456
+				'ee_delete_others_events',
457
+				//event categories
458
+				'ee_manage_event_categories',
459
+				'ee_edit_event_category',
460
+				'ee_delete_event_category',
461
+				'ee_assign_event_category',
462
+				//venues
463
+				'ee_publish_venues',
464
+				'ee_read_venue',
465
+				'ee_read_venues',
466
+				'ee_read_others_venues',
467
+				'ee_read_private_venues',
468
+				'ee_edit_venue',
469
+				'ee_edit_venues',
470
+				'ee_edit_others_venues',
471
+				'ee_edit_published_venues',
472
+				'ee_edit_private_venues',
473
+				'ee_delete_venue',
474
+				'ee_delete_venues',
475
+				'ee_delete_others_venues',
476
+				'ee_delete_private_venues',
477
+				'ee_delete_published_venues',
478
+				//venue categories
479
+				'ee_manage_venue_categories',
480
+				'ee_edit_venue_category',
481
+				'ee_delete_venue_category',
482
+				'ee_assign_venue_category',
483
+				//contacts
484
+				'ee_read_contact',
485
+				'ee_read_contacts',
486
+				'ee_edit_contact',
487
+				'ee_edit_contacts',
488
+				'ee_delete_contact',
489
+				'ee_delete_contacts',
490
+				//registrations
491
+				'ee_read_registration',
492
+				'ee_read_registrations',
493
+				'ee_read_others_registrations',
494
+				'ee_edit_registration',
495
+				'ee_edit_registrations',
496
+				'ee_edit_others_registrations',
497
+				'ee_delete_registration',
498
+				'ee_delete_registrations',
499
+				//checkins
500
+				'ee_read_checkin',
501
+				'ee_read_others_checkins',
502
+				'ee_read_checkins',
503
+				'ee_edit_checkin',
504
+				'ee_edit_checkins',
505
+				'ee_edit_others_checkins',
506
+				'ee_delete_checkin',
507
+				'ee_delete_checkins',
508
+				'ee_delete_others_checkins',
509
+				//transactions && payments
510
+				'ee_read_transaction',
511
+				'ee_read_transactions',
512
+				'ee_edit_payments',
513
+				'ee_delete_payments',
514
+				//messages
515
+				'ee_read_message',
516
+				'ee_read_messages',
517
+				'ee_read_others_messages',
518
+				'ee_read_global_messages',
519
+				'ee_edit_global_messages',
520
+				'ee_edit_message',
521
+				'ee_edit_messages',
522
+				'ee_edit_others_messages',
523
+				'ee_delete_message',
524
+				'ee_delete_messages',
525
+				'ee_delete_others_messages',
526
+				'ee_delete_global_messages',
527
+				'ee_send_message',
528
+				//tickets
529
+				'ee_read_default_ticket',
530
+				'ee_read_default_tickets',
531
+				'ee_read_others_default_tickets',
532
+				'ee_edit_default_ticket',
533
+				'ee_edit_default_tickets',
534
+				'ee_edit_others_default_tickets',
535
+				'ee_delete_default_ticket',
536
+				'ee_delete_default_tickets',
537
+				'ee_delete_others_default_tickets',
538
+				//prices
539
+				'ee_edit_default_price',
540
+				'ee_edit_default_prices',
541
+				'ee_delete_default_price',
542
+				'ee_delete_default_prices',
543
+				'ee_edit_default_price_type',
544
+				'ee_edit_default_price_types',
545
+				'ee_delete_default_price_type',
546
+				'ee_delete_default_price_types',
547
+				'ee_read_default_prices',
548
+				'ee_read_default_price_types',
549
+				//registration form
550
+				'ee_edit_question',
551
+				'ee_edit_questions',
552
+				'ee_edit_system_questions',
553
+				'ee_read_questions',
554
+				'ee_delete_question',
555
+				'ee_delete_questions',
556
+				'ee_edit_question_group',
557
+				'ee_edit_question_groups',
558
+				'ee_read_question_groups',
559
+				'ee_edit_system_question_groups',
560
+				'ee_delete_question_group',
561
+				'ee_delete_question_groups',
562
+				//event_type taxonomy
563
+				'ee_assign_event_type',
564
+				'ee_manage_event_types',
565
+				'ee_edit_event_type',
566
+				'ee_delete_event_type',
567
+			)
568
+		);
569 569
         
570
-        $caps = apply_filters('FHEE__EE_Capabilities__init_caps_map__caps', $caps);
570
+		$caps = apply_filters('FHEE__EE_Capabilities__init_caps_map__caps', $caps);
571 571
         
572
-        return $caps;
573
-    }
572
+		return $caps;
573
+	}
574 574
     
575 575
     
576
-    /**
577
-     * This adds all the default caps to roles as registered in the _caps_map property.
578
-     *
579
-     * @since 4.5.0
580
-     *
581
-     * @param bool  $reset      allows for resetting the default capabilities saved on roles.  Note that this doesn't
582
-     *                          actually REMOVE any capabilities from existing roles, it just resaves defaults roles
583
-     *                          and ensures that they are up to date.
584
-     * @param array $custom_map Optional.  Can be used to send a custom map of roles and capabilities for setting them
585
-     *                          up.  Note that this should ONLY be called on activation hook or some other one-time
586
-     *                          task otherwise the caps will be added on every request.
587
-     *
588
-     * @return void
589
-     */
590
-    public function init_role_caps($reset = false, $custom_map = array())
591
-    {
576
+	/**
577
+	 * This adds all the default caps to roles as registered in the _caps_map property.
578
+	 *
579
+	 * @since 4.5.0
580
+	 *
581
+	 * @param bool  $reset      allows for resetting the default capabilities saved on roles.  Note that this doesn't
582
+	 *                          actually REMOVE any capabilities from existing roles, it just resaves defaults roles
583
+	 *                          and ensures that they are up to date.
584
+	 * @param array $custom_map Optional.  Can be used to send a custom map of roles and capabilities for setting them
585
+	 *                          up.  Note that this should ONLY be called on activation hook or some other one-time
586
+	 *                          task otherwise the caps will be added on every request.
587
+	 *
588
+	 * @return void
589
+	 */
590
+	public function init_role_caps($reset = false, $custom_map = array())
591
+	{
592 592
         
593
-        $caps_map = empty($custom_map) ? $this->_caps_map : $custom_map;
593
+		$caps_map = empty($custom_map) ? $this->_caps_map : $custom_map;
594 594
         
595
-        //first let's determine if these caps have already been set.
596
-        $caps_set_before = get_option(self::option_name, array());
597
-        //if not reset, see what caps are new for each role. if they're new, add them.
598
-        foreach ($caps_map as $role => $caps_for_role) {
599
-            foreach ($caps_for_role as $cap) {
600
-                //first check we haven't already added this cap before, or it's a reset
601
-                if ($reset || ! isset($caps_set_before[$role]) || ! in_array($cap, $caps_set_before[$role])) {
602
-                    if ($this->add_cap_to_role($role, $cap)) {
603
-                        $caps_set_before[$role][] = $cap;
604
-                    }
605
-                }
606
-            }
607
-        }
595
+		//first let's determine if these caps have already been set.
596
+		$caps_set_before = get_option(self::option_name, array());
597
+		//if not reset, see what caps are new for each role. if they're new, add them.
598
+		foreach ($caps_map as $role => $caps_for_role) {
599
+			foreach ($caps_for_role as $cap) {
600
+				//first check we haven't already added this cap before, or it's a reset
601
+				if ($reset || ! isset($caps_set_before[$role]) || ! in_array($cap, $caps_set_before[$role])) {
602
+					if ($this->add_cap_to_role($role, $cap)) {
603
+						$caps_set_before[$role][] = $cap;
604
+					}
605
+				}
606
+			}
607
+		}
608 608
         
609
-        //now let's just save the cap that has been set.
610
-        update_option(self::option_name, $caps_set_before);
611
-        do_action('AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before);
612
-    }
609
+		//now let's just save the cap that has been set.
610
+		update_option(self::option_name, $caps_set_before);
611
+		do_action('AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before);
612
+	}
613 613
     
614 614
     
615
-    /**
616
-     * This method sets a capability on a role.  Note this should only be done on activation, or if you have something
617
-     * specific to prevent the cap from being added on every page load (adding caps are persistent to the db). Note.
618
-     * this is a wrapper for $wp_role->add_cap()
619
-     *
620
-     * @see   wp-includes/capabilities.php
621
-     *
622
-     * @since 4.5.0
623
-     *
624
-     * @param string $role  A WordPress role the capability is being added to
625
-     * @param string $cap   The capability being added to the role
626
-     * @param bool   $grant Whether to grant access to this cap on this role.
627
-     *
628
-     * @return bool
629
-     */
630
-    public function add_cap_to_role($role, $cap, $grant = true)
631
-    {
632
-        $role_object = get_role($role);
633
-        //if the role isn't available then we create it.
634
-        if ( ! $role_object instanceof WP_Role) {
635
-            //if a plugin wants to create a specific role name then they should create the role before
636
-            //EE_Capabilities does.  Otherwise this function will create the role name from the slug:
637
-            // - removes any `ee_` namespacing from the start of the slug.
638
-            // - replaces `_` with ` ` (empty space).
639
-            // - sentence case on the resulting string.
640
-            $role_label  = ucwords(str_replace('_', ' ', str_replace('ee_', '', $role)));
641
-            $role_object = add_role($role, $role_label);
642
-        }
643
-        if ($role_object instanceof WP_Role) {
644
-            $role_object->add_cap($cap, $grant);
615
+	/**
616
+	 * This method sets a capability on a role.  Note this should only be done on activation, or if you have something
617
+	 * specific to prevent the cap from being added on every page load (adding caps are persistent to the db). Note.
618
+	 * this is a wrapper for $wp_role->add_cap()
619
+	 *
620
+	 * @see   wp-includes/capabilities.php
621
+	 *
622
+	 * @since 4.5.0
623
+	 *
624
+	 * @param string $role  A WordPress role the capability is being added to
625
+	 * @param string $cap   The capability being added to the role
626
+	 * @param bool   $grant Whether to grant access to this cap on this role.
627
+	 *
628
+	 * @return bool
629
+	 */
630
+	public function add_cap_to_role($role, $cap, $grant = true)
631
+	{
632
+		$role_object = get_role($role);
633
+		//if the role isn't available then we create it.
634
+		if ( ! $role_object instanceof WP_Role) {
635
+			//if a plugin wants to create a specific role name then they should create the role before
636
+			//EE_Capabilities does.  Otherwise this function will create the role name from the slug:
637
+			// - removes any `ee_` namespacing from the start of the slug.
638
+			// - replaces `_` with ` ` (empty space).
639
+			// - sentence case on the resulting string.
640
+			$role_label  = ucwords(str_replace('_', ' ', str_replace('ee_', '', $role)));
641
+			$role_object = add_role($role, $role_label);
642
+		}
643
+		if ($role_object instanceof WP_Role) {
644
+			$role_object->add_cap($cap, $grant);
645 645
             
646
-            return true;
647
-        }
646
+			return true;
647
+		}
648 648
         
649
-        return false;
650
-    }
649
+		return false;
650
+	}
651 651
     
652 652
     
653
-    /**
654
-     * Functions similarly to add_cap_to_role except removes cap from given role.
655
-     * Wrapper for $wp_role->remove_cap()
656
-     *
657
-     * @see   wp-includes/capabilities.php
658
-     * @since 4.5.0
659
-     *
660
-     * @param string $role A WordPress role the capability is being removed from.
661
-     * @param string $cap  The capability being removed
662
-     *
663
-     * @return void
664
-     */
665
-    public function remove_cap_from_role($role, $cap)
666
-    {
667
-        $role = get_role($role);
668
-        if ($role instanceof WP_Role) {
669
-            $role->remove_cap($cap);
670
-        }
671
-    }
653
+	/**
654
+	 * Functions similarly to add_cap_to_role except removes cap from given role.
655
+	 * Wrapper for $wp_role->remove_cap()
656
+	 *
657
+	 * @see   wp-includes/capabilities.php
658
+	 * @since 4.5.0
659
+	 *
660
+	 * @param string $role A WordPress role the capability is being removed from.
661
+	 * @param string $cap  The capability being removed
662
+	 *
663
+	 * @return void
664
+	 */
665
+	public function remove_cap_from_role($role, $cap)
666
+	{
667
+		$role = get_role($role);
668
+		if ($role instanceof WP_Role) {
669
+			$role->remove_cap($cap);
670
+		}
671
+	}
672 672
     
673 673
     
674
-    /**
675
-     * Wrapper for the native WP current_user_can() method.
676
-     * This is provided as a handy method for a couple things:
677
-     * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to
678
-     * write those filters wherever current_user_can is called).
679
-     * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters )
680
-     *
681
-     * @since 4.5.0
682
-     *
683
-     * @param string $cap     The cap being checked.
684
-     * @param string $context The context where the current_user_can is being called from.
685
-     * @param int    $id      Optional. Id for item where current_user_can is being called from (used in map_meta_cap()
686
-     *                        filters.
687
-     *
688
-     * @return bool  Whether user can or not.
689
-     */
690
-    public function current_user_can($cap, $context, $id = 0)
691
-    {
692
-        //apply filters (both a global on just the cap, and context specific.  Global overrides context specific)
693
-        $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id);
694
-        $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap,
695
-            $id);
674
+	/**
675
+	 * Wrapper for the native WP current_user_can() method.
676
+	 * This is provided as a handy method for a couple things:
677
+	 * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to
678
+	 * write those filters wherever current_user_can is called).
679
+	 * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters )
680
+	 *
681
+	 * @since 4.5.0
682
+	 *
683
+	 * @param string $cap     The cap being checked.
684
+	 * @param string $context The context where the current_user_can is being called from.
685
+	 * @param int    $id      Optional. Id for item where current_user_can is being called from (used in map_meta_cap()
686
+	 *                        filters.
687
+	 *
688
+	 * @return bool  Whether user can or not.
689
+	 */
690
+	public function current_user_can($cap, $context, $id = 0)
691
+	{
692
+		//apply filters (both a global on just the cap, and context specific.  Global overrides context specific)
693
+		$filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id);
694
+		$filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap,
695
+			$id);
696 696
         
697
-        return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap);
698
-    }
697
+		return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap);
698
+	}
699 699
     
700 700
     
701
-    /**
702
-     * This is a wrapper for the WP user_can() function and follows the same style as the other wrappers in this class.
703
-     *
704
-     * @param int|WP_User $user    Either the user_id or a WP_User object
705
-     * @param string      $cap     The capability string being checked
706
-     * @param string      $context The context where the user_can is being called from (used in filters).
707
-     * @param int         $id      Optional. Id for item where user_can is being called from ( used in map_meta_cap()
708
-     *                             filters)
709
-     *
710
-     * @return bool Whether user can or not.
711
-     */
712
-    public function user_can($user, $cap, $context, $id = 0)
713
-    {
714
-        //apply filters (both a global on just the cap, and context specific.  Global overrides context specific)
715
-        $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id);
716
-        $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user,
717
-            $id);
701
+	/**
702
+	 * This is a wrapper for the WP user_can() function and follows the same style as the other wrappers in this class.
703
+	 *
704
+	 * @param int|WP_User $user    Either the user_id or a WP_User object
705
+	 * @param string      $cap     The capability string being checked
706
+	 * @param string      $context The context where the user_can is being called from (used in filters).
707
+	 * @param int         $id      Optional. Id for item where user_can is being called from ( used in map_meta_cap()
708
+	 *                             filters)
709
+	 *
710
+	 * @return bool Whether user can or not.
711
+	 */
712
+	public function user_can($user, $cap, $context, $id = 0)
713
+	{
714
+		//apply filters (both a global on just the cap, and context specific.  Global overrides context specific)
715
+		$filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id);
716
+		$filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user,
717
+			$id);
718 718
         
719
-        return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap);
720
-    }
719
+		return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap);
720
+	}
721 721
     
722 722
     
723
-    /**
724
-     * Wrapper for the native WP current_user_can_for_blog() method.
725
-     * This is provided as a handy method for a couple things:
726
-     * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to
727
-     * write those filters wherever current_user_can is called).
728
-     * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters )
729
-     *
730
-     * @since 4.5.0
731
-     *
732
-     * @param int    $blog_id The blog id that is being checked for.
733
-     * @param string $cap     The cap being checked.
734
-     * @param string $context The context where the current_user_can is being called from.
735
-     * @param int    $id      Optional. Id for item where current_user_can is being called from (used in map_meta_cap()
736
-     *                        filters.
737
-     *
738
-     * @return bool  Whether user can or not.
739
-     */
740
-    public function current_user_can_for_blog($blog_id, $cap, $context, $id = 0)
741
-    {
742
-        $user_can = ! empty($id) ? current_user_can_for_blog($blog_id, $cap, $id) : current_user_can($blog_id, $cap);
723
+	/**
724
+	 * Wrapper for the native WP current_user_can_for_blog() method.
725
+	 * This is provided as a handy method for a couple things:
726
+	 * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to
727
+	 * write those filters wherever current_user_can is called).
728
+	 * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters )
729
+	 *
730
+	 * @since 4.5.0
731
+	 *
732
+	 * @param int    $blog_id The blog id that is being checked for.
733
+	 * @param string $cap     The cap being checked.
734
+	 * @param string $context The context where the current_user_can is being called from.
735
+	 * @param int    $id      Optional. Id for item where current_user_can is being called from (used in map_meta_cap()
736
+	 *                        filters.
737
+	 *
738
+	 * @return bool  Whether user can or not.
739
+	 */
740
+	public function current_user_can_for_blog($blog_id, $cap, $context, $id = 0)
741
+	{
742
+		$user_can = ! empty($id) ? current_user_can_for_blog($blog_id, $cap, $id) : current_user_can($blog_id, $cap);
743 743
         
744
-        //apply filters (both a global on just the cap, and context specific.  Global overrides context specific)
745
-        $user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, $user_can,
746
-            $blog_id, $cap, $id);
747
-        $user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can', $user_can, $context,
748
-            $blog_id, $cap, $id);
744
+		//apply filters (both a global on just the cap, and context specific.  Global overrides context specific)
745
+		$user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, $user_can,
746
+			$blog_id, $cap, $id);
747
+		$user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can', $user_can, $context,
748
+			$blog_id, $cap, $id);
749 749
         
750
-        return $user_can;
751
-    }
750
+		return $user_can;
751
+	}
752 752
     
753 753
     
754
-    /**
755
-     * This helper method just returns an array of registered EE capabilities.
756
-     * Note this array is filtered.  It is assumed that all available EE capabilities are assigned to the administrator
757
-     * role.
758
-     *
759
-     * @since 4.5.0
760
-     *
761
-     * @param string $role If empty then the entire role/capability map is returned.  Otherwise just the capabilities
762
-     *                     for the given role are returned.
763
-     *
764
-     * @return array
765
-     */
766
-    public function get_ee_capabilities($role = 'administrator')
767
-    {
768
-        $capabilities = $this->_init_caps_map();
769
-        if (empty($role)) {
770
-            return $capabilities;
771
-        }
754
+	/**
755
+	 * This helper method just returns an array of registered EE capabilities.
756
+	 * Note this array is filtered.  It is assumed that all available EE capabilities are assigned to the administrator
757
+	 * role.
758
+	 *
759
+	 * @since 4.5.0
760
+	 *
761
+	 * @param string $role If empty then the entire role/capability map is returned.  Otherwise just the capabilities
762
+	 *                     for the given role are returned.
763
+	 *
764
+	 * @return array
765
+	 */
766
+	public function get_ee_capabilities($role = 'administrator')
767
+	{
768
+		$capabilities = $this->_init_caps_map();
769
+		if (empty($role)) {
770
+			return $capabilities;
771
+		}
772 772
         
773
-        return isset($capabilities[$role]) ? $capabilities[$role] : array();
774
-    }
773
+		return isset($capabilities[$role]) ? $capabilities[$role] : array();
774
+	}
775 775
 }
776 776
 
777 777
 
@@ -787,126 +787,126 @@  discard block
 block discarded – undo
787 787
  */
788 788
 abstract class EE_Meta_Capability_Map
789 789
 {
790
-    public $meta_cap;
791
-    /**
792
-     * @var EEM_Base
793
-     */
794
-    protected $_model;
795
-    protected $_model_name;
796
-    public $published_cap = '';
797
-    public $others_cap = '';
798
-    public $private_cap = '';
790
+	public $meta_cap;
791
+	/**
792
+	 * @var EEM_Base
793
+	 */
794
+	protected $_model;
795
+	protected $_model_name;
796
+	public $published_cap = '';
797
+	public $others_cap = '';
798
+	public $private_cap = '';
799 799
     
800 800
     
801
-    /**
802
-     * constructor.
803
-     * Receives the setup arguments for the map.
804
-     *
805
-     * @since                        4.5.0
806
-     *
807
-     * @param string $meta_cap   What meta capability is this mapping.
808
-     * @param array  $map_values array {
809
-     *                           //array of values that MUST match a count of 4.  It's okay to send an empty string for
810
-     *                           capabilities that don't get mapped to.
811
-     *
812
-     * @type         $map_values [0] string A string representing the model name. Required.  String's
813
-     *                               should always be used when Menu Maps are registered via the
814
-     *                               plugin API as models are not allowed to be instantiated when
815
-     *                               in maintenance mode 2 (migrations).
816
-     * @type         $map_values [1] string represents the capability used for published. Optional.
817
-     * @type         $map_values [2] string represents the capability used for "others". Optional.
818
-     * @type         $map_values [3] string represents the capability used for private. Optional.
819
-     *                               }
820
-     * @throws EE_Error
821
-     */
822
-    public function __construct($meta_cap, $map_values)
823
-    {
824
-        $this->meta_cap = $meta_cap;
825
-        //verify there are four args in the $map_values array;
826
-        if (count($map_values) !== 4) {
827
-            throw new EE_Error(sprintf(__('Incoming $map_values array should have a count of four values in it.  This is what was given: %s',
828
-                'event_espresso'), '<br>' . print_r($map_values, true)));
829
-        }
801
+	/**
802
+	 * constructor.
803
+	 * Receives the setup arguments for the map.
804
+	 *
805
+	 * @since                        4.5.0
806
+	 *
807
+	 * @param string $meta_cap   What meta capability is this mapping.
808
+	 * @param array  $map_values array {
809
+	 *                           //array of values that MUST match a count of 4.  It's okay to send an empty string for
810
+	 *                           capabilities that don't get mapped to.
811
+	 *
812
+	 * @type         $map_values [0] string A string representing the model name. Required.  String's
813
+	 *                               should always be used when Menu Maps are registered via the
814
+	 *                               plugin API as models are not allowed to be instantiated when
815
+	 *                               in maintenance mode 2 (migrations).
816
+	 * @type         $map_values [1] string represents the capability used for published. Optional.
817
+	 * @type         $map_values [2] string represents the capability used for "others". Optional.
818
+	 * @type         $map_values [3] string represents the capability used for private. Optional.
819
+	 *                               }
820
+	 * @throws EE_Error
821
+	 */
822
+	public function __construct($meta_cap, $map_values)
823
+	{
824
+		$this->meta_cap = $meta_cap;
825
+		//verify there are four args in the $map_values array;
826
+		if (count($map_values) !== 4) {
827
+			throw new EE_Error(sprintf(__('Incoming $map_values array should have a count of four values in it.  This is what was given: %s',
828
+				'event_espresso'), '<br>' . print_r($map_values, true)));
829
+		}
830 830
         
831
-        //set properties
832
-        $this->_model        = null;
833
-        $this->_model_name   = $map_values[0];
834
-        $this->published_cap = (string)$map_values[1];
835
-        $this->others_cap    = (string)$map_values[2];
836
-        $this->private_cap   = (string)$map_values[3];
837
-    }
831
+		//set properties
832
+		$this->_model        = null;
833
+		$this->_model_name   = $map_values[0];
834
+		$this->published_cap = (string)$map_values[1];
835
+		$this->others_cap    = (string)$map_values[2];
836
+		$this->private_cap   = (string)$map_values[3];
837
+	}
838 838
     
839
-    /**
840
-     * Makes it so this object stops filtering caps
841
-     */
842
-    public function remove_filters()
843
-    {
844
-        remove_filter('map_meta_cap', array($this, 'map_meta_caps'), 10);
845
-    }
839
+	/**
840
+	 * Makes it so this object stops filtering caps
841
+	 */
842
+	public function remove_filters()
843
+	{
844
+		remove_filter('map_meta_cap', array($this, 'map_meta_caps'), 10);
845
+	}
846 846
     
847 847
     
848
-    /**
849
-     * This method ensures that the $model property is converted from the model name string to a proper EEM_Base class
850
-     *
851
-     * @since 4.5.0
852
-     * @throws EE_Error
853
-     *
854
-     * @return void
855
-     */
856
-    public function ensure_is_model()
857
-    {
858
-        //is it already instantiated?
859
-        if ($this->_model instanceof EEM_Base) {
860
-            return;
861
-        }
848
+	/**
849
+	 * This method ensures that the $model property is converted from the model name string to a proper EEM_Base class
850
+	 *
851
+	 * @since 4.5.0
852
+	 * @throws EE_Error
853
+	 *
854
+	 * @return void
855
+	 */
856
+	public function ensure_is_model()
857
+	{
858
+		//is it already instantiated?
859
+		if ($this->_model instanceof EEM_Base) {
860
+			return;
861
+		}
862 862
         
863
-        //ensure model name is string
864
-        $this->_model_name = (string)$this->_model_name;
865
-        //error proof if the name has EEM in it
866
-        $this->_model_name = str_replace('EEM', '', $this->_model_name);
863
+		//ensure model name is string
864
+		$this->_model_name = (string)$this->_model_name;
865
+		//error proof if the name has EEM in it
866
+		$this->_model_name = str_replace('EEM', '', $this->_model_name);
867 867
         
868
-        $this->_model = EE_Registry::instance()->load_model($this->_model_name);
868
+		$this->_model = EE_Registry::instance()->load_model($this->_model_name);
869 869
         
870
-        if ( ! $this->_model instanceof EEM_Base) {
871
-            throw new EE_Error(sprintf(__('This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class.   Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s',
872
-                'event_espresso'), get_class($this), $this->_model));
873
-        }
874
-    }
870
+		if ( ! $this->_model instanceof EEM_Base) {
871
+			throw new EE_Error(sprintf(__('This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class.   Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s',
872
+				'event_espresso'), get_class($this), $this->_model));
873
+		}
874
+	}
875 875
     
876 876
     
877
-    /**
878
-     *
879
-     * @see   EE_Meta_Capability_Map::_map_meta_caps() for docs on params.
880
-     * @since 4.6.x
881
-     *
882
-     * @param $caps
883
-     * @param $cap
884
-     * @param $user_id
885
-     * @param $args
886
-     *
887
-     * @return array
888
-     */
889
-    public function map_meta_caps($caps, $cap, $user_id, $args)
890
-    {
891
-        return $this->_map_meta_caps($caps, $cap, $user_id, $args);
892
-    }
877
+	/**
878
+	 *
879
+	 * @see   EE_Meta_Capability_Map::_map_meta_caps() for docs on params.
880
+	 * @since 4.6.x
881
+	 *
882
+	 * @param $caps
883
+	 * @param $cap
884
+	 * @param $user_id
885
+	 * @param $args
886
+	 *
887
+	 * @return array
888
+	 */
889
+	public function map_meta_caps($caps, $cap, $user_id, $args)
890
+	{
891
+		return $this->_map_meta_caps($caps, $cap, $user_id, $args);
892
+	}
893 893
     
894 894
     
895
-    /**
896
-     * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
897
-     * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
898
-     *
899
-     * @since 4.5.0
900
-     * @see   wp-includes/capabilities.php
901
-     *
902
-     * @param array  $caps    actual users capabilities
903
-     * @param string $cap     initial capability name that is being checked (the "map" key)
904
-     * @param int    $user_id The user id
905
-     * @param array  $args    Adds context to the cap. Typically the object ID.
906
-     *
907
-     * @return array   actual users capabilities
908
-     */
909
-    abstract protected function _map_meta_caps($caps, $cap, $user_id, $args);
895
+	/**
896
+	 * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
897
+	 * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
898
+	 *
899
+	 * @since 4.5.0
900
+	 * @see   wp-includes/capabilities.php
901
+	 *
902
+	 * @param array  $caps    actual users capabilities
903
+	 * @param string $cap     initial capability name that is being checked (the "map" key)
904
+	 * @param int    $user_id The user id
905
+	 * @param array  $args    Adds context to the cap. Typically the object ID.
906
+	 *
907
+	 * @return array   actual users capabilities
908
+	 */
909
+	abstract protected function _map_meta_caps($caps, $cap, $user_id, $args);
910 910
 }
911 911
 
912 912
 
@@ -922,81 +922,81 @@  discard block
 block discarded – undo
922 922
 class EE_Meta_Capability_Map_Edit extends EE_Meta_Capability_Map
923 923
 {
924 924
     
925
-    /**
926
-     * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
927
-     * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
928
-     *
929
-     * @since 4.5.0
930
-     * @see   wp-includes/capabilities.php
931
-     *
932
-     * @param array  $caps    actual users capabilities
933
-     * @param string $cap     initial capability name that is being checked (the "map" key)
934
-     * @param int    $user_id The user id
935
-     * @param array  $args    Adds context to the cap. Typically the object ID.
936
-     *
937
-     * @return array   actual users capabilities
938
-     */
939
-    protected function _map_meta_caps($caps, $cap, $user_id, $args)
940
-    {
941
-        //only process if we're checking our mapped_cap
942
-        if ($cap !== $this->meta_cap) {
943
-            return $caps;
944
-        }
925
+	/**
926
+	 * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
927
+	 * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
928
+	 *
929
+	 * @since 4.5.0
930
+	 * @see   wp-includes/capabilities.php
931
+	 *
932
+	 * @param array  $caps    actual users capabilities
933
+	 * @param string $cap     initial capability name that is being checked (the "map" key)
934
+	 * @param int    $user_id The user id
935
+	 * @param array  $args    Adds context to the cap. Typically the object ID.
936
+	 *
937
+	 * @return array   actual users capabilities
938
+	 */
939
+	protected function _map_meta_caps($caps, $cap, $user_id, $args)
940
+	{
941
+		//only process if we're checking our mapped_cap
942
+		if ($cap !== $this->meta_cap) {
943
+			return $caps;
944
+		}
945 945
         
946
-        $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null;
946
+		$obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null;
947 947
         
948
-        //if no obj then let's just do cap
949
-        if ( ! $obj instanceof EE_Base_Class) {
950
-            $caps[] = $cap;
948
+		//if no obj then let's just do cap
949
+		if ( ! $obj instanceof EE_Base_Class) {
950
+			$caps[] = $cap;
951 951
             
952
-            return $caps;
953
-        }
952
+			return $caps;
953
+		}
954 954
         
955
-        if ($obj instanceof EE_CPT_Base) {
956
-            //if the item author is set and the user is the author...
957
-            if ($obj->wp_user() && $user_id == $obj->wp_user()) {
958
-                if (empty($this->published_cap)) {
959
-                    $caps[] = $cap;
960
-                } else {
961
-                    //if obj is published...
962
-                    if ($obj->status() == 'publish') {
963
-                        $caps[] = $this->published_cap;
964
-                    } else {
965
-                        $caps[] = $cap;
966
-                    }
967
-                }
968
-            } else {
969
-                //the user is trying to edit someone else's obj
970
-                if ( ! empty($this->others_cap)) {
971
-                    $caps[] = $this->others_cap;
972
-                }
973
-                if ( ! empty($this->published_cap) && $obj->status() == 'publish') {
974
-                    $caps[] = $this->published_cap;
975
-                } elseif ( ! empty($this->private_cap) && $obj->status() == 'private') {
976
-                    $caps[] = $this->private_cap;
977
-                }
978
-            }
979
-        } else {
980
-            //not a cpt object so handled differently
981
-            $has_cap = false;
982
-            try {
983
-                $has_cap = method_exists($obj, 'wp_user') && $obj->wp_user() && $user_id == $obj->wp_user();
984
-            } catch (Exception $e) {
985
-                if (WP_DEBUG) {
986
-                    EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
987
-                }
988
-            }
989
-            if ($has_cap) {
990
-                $caps[] = $cap;
991
-            } else {
992
-                if ( ! empty($this->others_cap)) {
993
-                    $caps[] = $this->others_cap;
994
-                }
995
-            }
996
-        }
955
+		if ($obj instanceof EE_CPT_Base) {
956
+			//if the item author is set and the user is the author...
957
+			if ($obj->wp_user() && $user_id == $obj->wp_user()) {
958
+				if (empty($this->published_cap)) {
959
+					$caps[] = $cap;
960
+				} else {
961
+					//if obj is published...
962
+					if ($obj->status() == 'publish') {
963
+						$caps[] = $this->published_cap;
964
+					} else {
965
+						$caps[] = $cap;
966
+					}
967
+				}
968
+			} else {
969
+				//the user is trying to edit someone else's obj
970
+				if ( ! empty($this->others_cap)) {
971
+					$caps[] = $this->others_cap;
972
+				}
973
+				if ( ! empty($this->published_cap) && $obj->status() == 'publish') {
974
+					$caps[] = $this->published_cap;
975
+				} elseif ( ! empty($this->private_cap) && $obj->status() == 'private') {
976
+					$caps[] = $this->private_cap;
977
+				}
978
+			}
979
+		} else {
980
+			//not a cpt object so handled differently
981
+			$has_cap = false;
982
+			try {
983
+				$has_cap = method_exists($obj, 'wp_user') && $obj->wp_user() && $user_id == $obj->wp_user();
984
+			} catch (Exception $e) {
985
+				if (WP_DEBUG) {
986
+					EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
987
+				}
988
+			}
989
+			if ($has_cap) {
990
+				$caps[] = $cap;
991
+			} else {
992
+				if ( ! empty($this->others_cap)) {
993
+					$caps[] = $this->others_cap;
994
+				}
995
+			}
996
+		}
997 997
         
998
-        return $caps;
999
-    }
998
+		return $caps;
999
+	}
1000 1000
 }
1001 1001
 
1002 1002
 
@@ -1013,24 +1013,24 @@  discard block
 block discarded – undo
1013 1013
 class EE_Meta_Capability_Map_Delete extends EE_Meta_Capability_Map_Edit
1014 1014
 {
1015 1015
     
1016
-    /**
1017
-     * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
1018
-     * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
1019
-     *
1020
-     * @since 4.5.0
1021
-     * @see   wp-includes/capabilities.php
1022
-     *
1023
-     * @param array  $caps    actual users capabilities
1024
-     * @param string $cap     initial capability name that is being checked (the "map" key)
1025
-     * @param int    $user_id The user id
1026
-     * @param array  $args    Adds context to the cap. Typically the object ID.
1027
-     *
1028
-     * @return array   actual users capabilities
1029
-     */
1030
-    protected function _map_meta_caps($caps, $cap, $user_id, $args)
1031
-    {
1032
-        return parent::_map_meta_caps($caps, $cap, $user_id, $args);
1033
-    }
1016
+	/**
1017
+	 * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
1018
+	 * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
1019
+	 *
1020
+	 * @since 4.5.0
1021
+	 * @see   wp-includes/capabilities.php
1022
+	 *
1023
+	 * @param array  $caps    actual users capabilities
1024
+	 * @param string $cap     initial capability name that is being checked (the "map" key)
1025
+	 * @param int    $user_id The user id
1026
+	 * @param array  $args    Adds context to the cap. Typically the object ID.
1027
+	 *
1028
+	 * @return array   actual users capabilities
1029
+	 */
1030
+	protected function _map_meta_caps($caps, $cap, $user_id, $args)
1031
+	{
1032
+		return parent::_map_meta_caps($caps, $cap, $user_id, $args);
1033
+	}
1034 1034
 }
1035 1035
 
1036 1036
 
@@ -1046,78 +1046,78 @@  discard block
 block discarded – undo
1046 1046
 class EE_Meta_Capability_Map_Read extends EE_Meta_Capability_Map
1047 1047
 {
1048 1048
     
1049
-    /**
1050
-     * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
1051
-     * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
1052
-     *
1053
-     * @since 4.5.0
1054
-     * @see   wp-includes/capabilities.php
1055
-     *
1056
-     * @param array  $caps    actual users capabilities
1057
-     * @param string $cap     initial capability name that is being checked (the "map" key)
1058
-     * @param int    $user_id The user id
1059
-     * @param array  $args    Adds context to the cap. Typically the object ID.
1060
-     *
1061
-     * @return array   actual users capabilities
1062
-     */
1063
-    protected function _map_meta_caps($caps, $cap, $user_id, $args)
1064
-    {
1065
-        //only process if we're checking our mapped cap;
1066
-        if ($cap !== $this->meta_cap) {
1067
-            return $caps;
1068
-        }
1049
+	/**
1050
+	 * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
1051
+	 * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
1052
+	 *
1053
+	 * @since 4.5.0
1054
+	 * @see   wp-includes/capabilities.php
1055
+	 *
1056
+	 * @param array  $caps    actual users capabilities
1057
+	 * @param string $cap     initial capability name that is being checked (the "map" key)
1058
+	 * @param int    $user_id The user id
1059
+	 * @param array  $args    Adds context to the cap. Typically the object ID.
1060
+	 *
1061
+	 * @return array   actual users capabilities
1062
+	 */
1063
+	protected function _map_meta_caps($caps, $cap, $user_id, $args)
1064
+	{
1065
+		//only process if we're checking our mapped cap;
1066
+		if ($cap !== $this->meta_cap) {
1067
+			return $caps;
1068
+		}
1069 1069
         
1070
-        $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null;
1070
+		$obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null;
1071 1071
         
1072
-        //if no obj then let's just do cap
1073
-        if ( ! $obj instanceof EE_Base_Class) {
1074
-            $caps[] = $cap;
1072
+		//if no obj then let's just do cap
1073
+		if ( ! $obj instanceof EE_Base_Class) {
1074
+			$caps[] = $cap;
1075 1075
             
1076
-            return $caps;
1077
-        }
1076
+			return $caps;
1077
+		}
1078 1078
         
1079
-        if ($obj instanceof EE_CPT_Base) {
1080
-            $status_obj = get_post_status_object($obj->status());
1081
-            if ($status_obj->public) {
1082
-                $caps[] = $cap;
1079
+		if ($obj instanceof EE_CPT_Base) {
1080
+			$status_obj = get_post_status_object($obj->status());
1081
+			if ($status_obj->public) {
1082
+				$caps[] = $cap;
1083 1083
                 
1084
-                return $caps;
1085
-            }
1084
+				return $caps;
1085
+			}
1086 1086
             
1087
-            //if the item author is set and the user is the author...
1088
-            if ($obj->wp_user() && $user_id == $obj->wp_user()) {
1089
-                $caps[] = $cap;
1090
-            } elseif ($status_obj->private && ! empty($this->private_cap)) {
1091
-                //the user is trying to view someone else's obj
1092
-                $caps[] = $this->private_cap;
1093
-            } elseif ( ! empty($this->others_cap)) {
1094
-                $caps[] = $this->others_cap;
1095
-            } else {
1096
-                $caps[] = $cap;
1097
-            }
1098
-        } else {
1099
-            //not a cpt object so handled differently
1100
-            $has_cap = false;
1101
-            try {
1102
-                $has_cap = method_exists($obj, 'wp_user') && $obj->wp_user() && $user_id == $obj->wp_user();
1103
-            } catch (Exception $e) {
1104
-                if (WP_DEBUG) {
1105
-                    EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1106
-                }
1107
-            }
1108
-            if ($has_cap) {
1109
-                $caps[] = $cap;
1110
-            } elseif ( ! empty($this->private_cap)) {
1111
-                $caps[] = $this->private_cap;
1112
-            } elseif ( ! empty($this->others_cap)) {
1113
-                $caps[] = $this->others_cap;
1114
-            } else {
1115
-                $caps[] = $cap;
1116
-            }
1117
-        }
1087
+			//if the item author is set and the user is the author...
1088
+			if ($obj->wp_user() && $user_id == $obj->wp_user()) {
1089
+				$caps[] = $cap;
1090
+			} elseif ($status_obj->private && ! empty($this->private_cap)) {
1091
+				//the user is trying to view someone else's obj
1092
+				$caps[] = $this->private_cap;
1093
+			} elseif ( ! empty($this->others_cap)) {
1094
+				$caps[] = $this->others_cap;
1095
+			} else {
1096
+				$caps[] = $cap;
1097
+			}
1098
+		} else {
1099
+			//not a cpt object so handled differently
1100
+			$has_cap = false;
1101
+			try {
1102
+				$has_cap = method_exists($obj, 'wp_user') && $obj->wp_user() && $user_id == $obj->wp_user();
1103
+			} catch (Exception $e) {
1104
+				if (WP_DEBUG) {
1105
+					EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1106
+				}
1107
+			}
1108
+			if ($has_cap) {
1109
+				$caps[] = $cap;
1110
+			} elseif ( ! empty($this->private_cap)) {
1111
+				$caps[] = $this->private_cap;
1112
+			} elseif ( ! empty($this->others_cap)) {
1113
+				$caps[] = $this->others_cap;
1114
+			} else {
1115
+				$caps[] = $cap;
1116
+			}
1117
+		}
1118 1118
         
1119
-        return $caps;
1120
-    }
1119
+		return $caps;
1120
+	}
1121 1121
 }
1122 1122
 
1123 1123
 
@@ -1134,54 +1134,54 @@  discard block
 block discarded – undo
1134 1134
 class EE_Meta_Capability_Map_Messages_Cap extends EE_Meta_Capability_Map
1135 1135
 {
1136 1136
     
1137
-    /**
1138
-     * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
1139
-     * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
1140
-     *
1141
-     * @since 4.5.0
1142
-     * @see   wp-includes/capabilities.php
1143
-     *
1144
-     * @param array  $caps    actual users capabilities
1145
-     * @param string $cap     initial capability name that is being checked (the "map" key)
1146
-     * @param int    $user_id The user id
1147
-     * @param array  $args    Adds context to the cap. Typically the object ID.
1148
-     *
1149
-     * @return array   actual users capabilities
1150
-     */
1151
-    protected function _map_meta_caps($caps, $cap, $user_id, $args)
1152
-    {
1153
-        //only process if we're checking our mapped_cap
1154
-        if ($cap !== $this->meta_cap) {
1155
-            return $caps;
1156
-        }
1137
+	/**
1138
+	 * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
1139
+	 * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
1140
+	 *
1141
+	 * @since 4.5.0
1142
+	 * @see   wp-includes/capabilities.php
1143
+	 *
1144
+	 * @param array  $caps    actual users capabilities
1145
+	 * @param string $cap     initial capability name that is being checked (the "map" key)
1146
+	 * @param int    $user_id The user id
1147
+	 * @param array  $args    Adds context to the cap. Typically the object ID.
1148
+	 *
1149
+	 * @return array   actual users capabilities
1150
+	 */
1151
+	protected function _map_meta_caps($caps, $cap, $user_id, $args)
1152
+	{
1153
+		//only process if we're checking our mapped_cap
1154
+		if ($cap !== $this->meta_cap) {
1155
+			return $caps;
1156
+		}
1157 1157
         
1158
-        $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null;
1158
+		$obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null;
1159 1159
         
1160
-        //if no obj then let's just do cap
1161
-        if ( ! $obj instanceof EE_Message_Template_Group) {
1162
-            $caps[] = $cap;
1160
+		//if no obj then let's just do cap
1161
+		if ( ! $obj instanceof EE_Message_Template_Group) {
1162
+			$caps[] = $cap;
1163 1163
             
1164
-            return $caps;
1165
-        }
1164
+			return $caps;
1165
+		}
1166 1166
         
1167
-        $is_global = $obj->is_global();
1167
+		$is_global = $obj->is_global();
1168 1168
         
1169
-        if ($obj->wp_user() && $user_id == $obj->wp_user()) {
1170
-            if ($is_global) {
1171
-                $caps[] = $this->private_cap;
1172
-            } else {
1173
-                $caps[] = $cap;
1174
-            }
1175
-        } else {
1176
-            if ($is_global) {
1177
-                $caps[] = $this->private_cap;
1178
-            } else {
1179
-                $caps[] = $this->others_cap;
1180
-            }
1181
-        }
1169
+		if ($obj->wp_user() && $user_id == $obj->wp_user()) {
1170
+			if ($is_global) {
1171
+				$caps[] = $this->private_cap;
1172
+			} else {
1173
+				$caps[] = $cap;
1174
+			}
1175
+		} else {
1176
+			if ($is_global) {
1177
+				$caps[] = $this->private_cap;
1178
+			} else {
1179
+				$caps[] = $this->others_cap;
1180
+			}
1181
+		}
1182 1182
         
1183
-        return $caps;
1184
-    }
1183
+		return $caps;
1184
+	}
1185 1185
 }
1186 1186
 
1187 1187
 
@@ -1198,45 +1198,45 @@  discard block
 block discarded – undo
1198 1198
 class EE_Meta_Capability_Map_Registration_Form_Cap extends EE_Meta_Capability_Map
1199 1199
 {
1200 1200
     
1201
-    /**
1202
-     * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
1203
-     * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
1204
-     *
1205
-     * @since 4.5.0
1206
-     * @see   wp-includes/capabilities.php
1207
-     *
1208
-     * @param array  $caps    actual users capabilities
1209
-     * @param string $cap     initial capability name that is being checked (the "map" key)
1210
-     * @param int    $user_id The user id
1211
-     * @param array  $args    Adds context to the cap. Typically the object ID.
1212
-     *
1213
-     * @return array   actual users capabilities
1214
-     */
1215
-    protected function _map_meta_caps($caps, $cap, $user_id, $args)
1216
-    {
1217
-        //only process if we're checking our mapped_cap
1218
-        if ($cap !== $this->meta_cap) {
1219
-            return $caps;
1220
-        }
1201
+	/**
1202
+	 * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a
1203
+	 * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected.
1204
+	 *
1205
+	 * @since 4.5.0
1206
+	 * @see   wp-includes/capabilities.php
1207
+	 *
1208
+	 * @param array  $caps    actual users capabilities
1209
+	 * @param string $cap     initial capability name that is being checked (the "map" key)
1210
+	 * @param int    $user_id The user id
1211
+	 * @param array  $args    Adds context to the cap. Typically the object ID.
1212
+	 *
1213
+	 * @return array   actual users capabilities
1214
+	 */
1215
+	protected function _map_meta_caps($caps, $cap, $user_id, $args)
1216
+	{
1217
+		//only process if we're checking our mapped_cap
1218
+		if ($cap !== $this->meta_cap) {
1219
+			return $caps;
1220
+		}
1221 1221
         
1222
-        $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null;
1222
+		$obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null;
1223 1223
         
1224
-        //if no obj then let's just do cap
1225
-        if ( ! $obj instanceof EE_Base_Class) {
1226
-            $caps[] = $cap;
1224
+		//if no obj then let's just do cap
1225
+		if ( ! $obj instanceof EE_Base_Class) {
1226
+			$caps[] = $cap;
1227 1227
             
1228
-            return $caps;
1229
-        }
1228
+			return $caps;
1229
+		}
1230 1230
         
1231
-        $is_system = $obj instanceof EE_Question_Group ? $obj->system_group() : false;
1232
-        $is_system = $obj instanceof EE_Question ? $obj->is_system_question() : $is_system;
1231
+		$is_system = $obj instanceof EE_Question_Group ? $obj->system_group() : false;
1232
+		$is_system = $obj instanceof EE_Question ? $obj->is_system_question() : $is_system;
1233 1233
         
1234
-        if ($is_system) {
1235
-            $caps[] = $this->private_cap;
1236
-        } else {
1237
-            $caps[] = $cap;
1238
-        }
1234
+		if ($is_system) {
1235
+			$caps[] = $this->private_cap;
1236
+		} else {
1237
+			$caps[] = $cap;
1238
+		}
1239 1239
         
1240
-        return $caps;
1241
-    }
1240
+		return $caps;
1241
+	}
1242 1242
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
         if (did_action('AHEE__EE_System__load_espresso_addons__complete')) {
235 235
             //loop through our _meta_caps array
236 236
             foreach ($this->_meta_caps as $meta_map) {
237
-                if (! $meta_map instanceof EE_Meta_Capability_Map) {
237
+                if ( ! $meta_map instanceof EE_Meta_Capability_Map) {
238 238
                     continue;
239 239
                 }
240 240
                 $meta_map->ensure_is_model();
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
     public function current_user_can($cap, $context, $id = 0)
691 691
     {
692 692
         //apply filters (both a global on just the cap, and context specific.  Global overrides context specific)
693
-        $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id);
693
+        $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__'.$context, $cap, $id);
694 694
         $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap,
695 695
             $id);
696 696
         
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
     public function user_can($user, $cap, $context, $id = 0)
713 713
     {
714 714
         //apply filters (both a global on just the cap, and context specific.  Global overrides context specific)
715
-        $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id);
715
+        $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__'.$context, $cap, $user, $id);
716 716
         $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user,
717 717
             $id);
718 718
         
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
         $user_can = ! empty($id) ? current_user_can_for_blog($blog_id, $cap, $id) : current_user_can($blog_id, $cap);
743 743
         
744 744
         //apply filters (both a global on just the cap, and context specific.  Global overrides context specific)
745
-        $user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, $user_can,
745
+        $user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can__'.$context, $user_can,
746 746
             $blog_id, $cap, $id);
747 747
         $user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can', $user_can, $context,
748 748
             $blog_id, $cap, $id);
@@ -825,15 +825,15 @@  discard block
 block discarded – undo
825 825
         //verify there are four args in the $map_values array;
826 826
         if (count($map_values) !== 4) {
827 827
             throw new EE_Error(sprintf(__('Incoming $map_values array should have a count of four values in it.  This is what was given: %s',
828
-                'event_espresso'), '<br>' . print_r($map_values, true)));
828
+                'event_espresso'), '<br>'.print_r($map_values, true)));
829 829
         }
830 830
         
831 831
         //set properties
832 832
         $this->_model        = null;
833 833
         $this->_model_name   = $map_values[0];
834
-        $this->published_cap = (string)$map_values[1];
835
-        $this->others_cap    = (string)$map_values[2];
836
-        $this->private_cap   = (string)$map_values[3];
834
+        $this->published_cap = (string) $map_values[1];
835
+        $this->others_cap    = (string) $map_values[2];
836
+        $this->private_cap   = (string) $map_values[3];
837 837
     }
838 838
     
839 839
     /**
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
         }
862 862
         
863 863
         //ensure model name is string
864
-        $this->_model_name = (string)$this->_model_name;
864
+        $this->_model_name = (string) $this->_model_name;
865 865
         //error proof if the name has EEM in it
866 866
         $this->_model_name = str_replace('EEM', '', $this->_model_name);
867 867
         
Please login to merge, or discard this patch.
admin_pages/transactions/Transactions_Admin_Page.core.php 3 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1612,7 +1612,7 @@  discard block
 block discarded – undo
1612 1612
      * @param \EE_Payment     $payment
1613 1613
      * @param array           $REG_IDs
1614 1614
      *
1615
-     * @return bool
1615
+     * @return boolean|null
1616 1616
      */
1617 1617
     protected function _update_registration_payments(
1618 1618
         EE_Transaction $transaction,
@@ -1821,6 +1821,7 @@  discard block
 block discarded – undo
1821 1821
      * @access protected
1822 1822
      *
1823 1823
      * @param \EE_Payment | null $payment
1824
+     * @param EE_Payment $payment
1824 1825
      */
1825 1826
     protected function _maybe_send_notifications($payment = null)
1826 1827
     {
Please login to merge, or discard this patch.
Indentation   +1951 added lines, -1951 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 /**
@@ -27,1975 +27,1975 @@  discard block
 block discarded – undo
27 27
 class Transactions_Admin_Page extends EE_Admin_Page
28 28
 {
29 29
     
30
-    /**
31
-     * @var EE_Transaction
32
-     */
33
-    private $_transaction;
34
-    
35
-    /**
36
-     * @var EE_Session
37
-     */
38
-    private $_session;
39
-    
40
-    /**
41
-     * @var array $_txn_status
42
-     */
43
-    private static $_txn_status;
44
-    
45
-    /**
46
-     * @var array $_pay_status
47
-     */
48
-    private static $_pay_status;
49
-    
50
-    /**
51
-     * @var array $_existing_reg_payment_REG_IDs
52
-     */
53
-    protected $_existing_reg_payment_REG_IDs = null;
54
-    
55
-    
56
-    /**
57
-     * @Constructor
58
-     * @access public
59
-     *
60
-     * @param bool $routing
61
-     *
62
-     * @return Transactions_Admin_Page
63
-     */
64
-    public function __construct($routing = true)
65
-    {
66
-        parent::__construct($routing);
67
-    }
68
-    
69
-    
70
-    /**
71
-     *    _init_page_props
72
-     * @return void
73
-     */
74
-    protected function _init_page_props()
75
-    {
76
-        $this->page_slug        = TXN_PG_SLUG;
77
-        $this->page_label       = esc_html__('Transactions', 'event_espresso');
78
-        $this->_admin_base_url  = TXN_ADMIN_URL;
79
-        $this->_admin_base_path = TXN_ADMIN;
80
-    }
81
-    
82
-    
83
-    /**
84
-     *    _ajax_hooks
85
-     * @return void
86
-     */
87
-    protected function _ajax_hooks()
88
-    {
89
-        add_action('wp_ajax_espresso_apply_payment', array($this, 'apply_payments_or_refunds'));
90
-        add_action('wp_ajax_espresso_apply_refund', array($this, 'apply_payments_or_refunds'));
91
-        add_action('wp_ajax_espresso_delete_payment', array($this, 'delete_payment'));
92
-    }
93
-    
94
-    
95
-    /**
96
-     *    _define_page_props
97
-     * @return void
98
-     */
99
-    protected function _define_page_props()
100
-    {
101
-        $this->_admin_page_title = $this->page_label;
102
-        $this->_labels           = array(
103
-            'buttons' => array(
104
-                'add'    => esc_html__('Add New Transaction', 'event_espresso'),
105
-                'edit'   => esc_html__('Edit Transaction', 'event_espresso'),
106
-                'delete' => esc_html__('Delete Transaction', 'event_espresso'),
107
-            )
108
-        );
109
-    }
110
-    
111
-    
112
-    /**
113
-     *        grab url requests and route them
114
-     * @access private
115
-     * @return void
116
-     */
117
-    public function _set_page_routes()
118
-    {
119
-        
120
-        $this->_set_transaction_status_array();
121
-        
122
-        $txn_id = ! empty($this->_req_data['TXN_ID']) && ! is_array($this->_req_data['TXN_ID']) ? $this->_req_data['TXN_ID'] : 0;
123
-        
124
-        $this->_page_routes = array(
30
+	/**
31
+	 * @var EE_Transaction
32
+	 */
33
+	private $_transaction;
34
+    
35
+	/**
36
+	 * @var EE_Session
37
+	 */
38
+	private $_session;
39
+    
40
+	/**
41
+	 * @var array $_txn_status
42
+	 */
43
+	private static $_txn_status;
44
+    
45
+	/**
46
+	 * @var array $_pay_status
47
+	 */
48
+	private static $_pay_status;
49
+    
50
+	/**
51
+	 * @var array $_existing_reg_payment_REG_IDs
52
+	 */
53
+	protected $_existing_reg_payment_REG_IDs = null;
54
+    
55
+    
56
+	/**
57
+	 * @Constructor
58
+	 * @access public
59
+	 *
60
+	 * @param bool $routing
61
+	 *
62
+	 * @return Transactions_Admin_Page
63
+	 */
64
+	public function __construct($routing = true)
65
+	{
66
+		parent::__construct($routing);
67
+	}
68
+    
69
+    
70
+	/**
71
+	 *    _init_page_props
72
+	 * @return void
73
+	 */
74
+	protected function _init_page_props()
75
+	{
76
+		$this->page_slug        = TXN_PG_SLUG;
77
+		$this->page_label       = esc_html__('Transactions', 'event_espresso');
78
+		$this->_admin_base_url  = TXN_ADMIN_URL;
79
+		$this->_admin_base_path = TXN_ADMIN;
80
+	}
81
+    
82
+    
83
+	/**
84
+	 *    _ajax_hooks
85
+	 * @return void
86
+	 */
87
+	protected function _ajax_hooks()
88
+	{
89
+		add_action('wp_ajax_espresso_apply_payment', array($this, 'apply_payments_or_refunds'));
90
+		add_action('wp_ajax_espresso_apply_refund', array($this, 'apply_payments_or_refunds'));
91
+		add_action('wp_ajax_espresso_delete_payment', array($this, 'delete_payment'));
92
+	}
93
+    
94
+    
95
+	/**
96
+	 *    _define_page_props
97
+	 * @return void
98
+	 */
99
+	protected function _define_page_props()
100
+	{
101
+		$this->_admin_page_title = $this->page_label;
102
+		$this->_labels           = array(
103
+			'buttons' => array(
104
+				'add'    => esc_html__('Add New Transaction', 'event_espresso'),
105
+				'edit'   => esc_html__('Edit Transaction', 'event_espresso'),
106
+				'delete' => esc_html__('Delete Transaction', 'event_espresso'),
107
+			)
108
+		);
109
+	}
110
+    
111
+    
112
+	/**
113
+	 *        grab url requests and route them
114
+	 * @access private
115
+	 * @return void
116
+	 */
117
+	public function _set_page_routes()
118
+	{
119
+        
120
+		$this->_set_transaction_status_array();
121
+        
122
+		$txn_id = ! empty($this->_req_data['TXN_ID']) && ! is_array($this->_req_data['TXN_ID']) ? $this->_req_data['TXN_ID'] : 0;
123
+        
124
+		$this->_page_routes = array(
125 125
             
126
-            'default' => array(
127
-                'func'       => '_transactions_overview_list_table',
128
-                'capability' => 'ee_read_transactions'
129
-            ),
126
+			'default' => array(
127
+				'func'       => '_transactions_overview_list_table',
128
+				'capability' => 'ee_read_transactions'
129
+			),
130 130
             
131
-            'view_transaction' => array(
132
-                'func'       => '_transaction_details',
133
-                'capability' => 'ee_read_transaction',
134
-                'obj_id'     => $txn_id
135
-            ),
131
+			'view_transaction' => array(
132
+				'func'       => '_transaction_details',
133
+				'capability' => 'ee_read_transaction',
134
+				'obj_id'     => $txn_id
135
+			),
136 136
             
137
-            'send_payment_reminder' => array(
138
-                'func'       => '_send_payment_reminder',
139
-                'noheader'   => true,
140
-                'capability' => 'ee_send_message'
141
-            ),
137
+			'send_payment_reminder' => array(
138
+				'func'       => '_send_payment_reminder',
139
+				'noheader'   => true,
140
+				'capability' => 'ee_send_message'
141
+			),
142 142
             
143
-            'espresso_apply_payment' => array(
144
-                'func'       => 'apply_payments_or_refunds',
145
-                'noheader'   => true,
146
-                'capability' => 'ee_edit_payments'
147
-            ),
143
+			'espresso_apply_payment' => array(
144
+				'func'       => 'apply_payments_or_refunds',
145
+				'noheader'   => true,
146
+				'capability' => 'ee_edit_payments'
147
+			),
148 148
             
149
-            'espresso_apply_refund' => array(
150
-                'func'       => 'apply_payments_or_refunds',
151
-                'noheader'   => true,
152
-                'capability' => 'ee_edit_payments'
153
-            ),
149
+			'espresso_apply_refund' => array(
150
+				'func'       => 'apply_payments_or_refunds',
151
+				'noheader'   => true,
152
+				'capability' => 'ee_edit_payments'
153
+			),
154 154
             
155
-            'espresso_delete_payment' => array(
156
-                'func'       => 'delete_payment',
157
-                'noheader'   => true,
158
-                'capability' => 'ee_delete_payments'
159
-            ),
160
-        
161
-        );
162
-        
163
-    }
164
-    
165
-    
166
-    protected function _set_page_config()
167
-    {
168
-        $this->_page_config = array(
169
-            'default'          => array(
170
-                'nav'           => array(
171
-                    'label' => esc_html__('Overview', 'event_espresso'),
172
-                    'order' => 10
173
-                ),
174
-                'list_table'    => 'EE_Admin_Transactions_List_Table',
175
-                'help_tabs'     => array(
176
-                    'transactions_overview_help_tab'                       => array(
177
-                        'title'    => esc_html__('Transactions Overview', 'event_espresso'),
178
-                        'filename' => 'transactions_overview'
179
-                    ),
180
-                    'transactions_overview_table_column_headings_help_tab' => array(
181
-                        'title'    => esc_html__('Transactions Table Column Headings', 'event_espresso'),
182
-                        'filename' => 'transactions_overview_table_column_headings'
183
-                    ),
184
-                    'transactions_overview_views_filters_help_tab'         => array(
185
-                        'title'    => esc_html__('Transaction Views & Filters & Search', 'event_espresso'),
186
-                        'filename' => 'transactions_overview_views_filters_search'
187
-                    ),
188
-                ),
189
-                'help_tour'     => array('Transactions_Overview_Help_Tour'),
190
-                /**
191
-                 * commented out because currently we are not displaying tips for transaction list table status but this
192
-                 * may change in a later iteration so want to keep the code for then.
193
-                 */
194
-                //'qtips' => array( 'Transactions_List_Table_Tips' ),
195
-                'require_nonce' => false
196
-            ),
197
-            'view_transaction' => array(
198
-                'nav'       => array(
199
-                    'label'      => esc_html__('View Transaction', 'event_espresso'),
200
-                    'order'      => 5,
201
-                    'url'        => isset($this->_req_data['TXN_ID']) ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID']),
202
-                        $this->_current_page_view_url) : $this->_admin_base_url,
203
-                    'persistent' => false
204
-                ),
205
-                'help_tabs' => array(
206
-                    'transactions_view_transaction_help_tab'                                              => array(
207
-                        'title'    => esc_html__('View Transaction', 'event_espresso'),
208
-                        'filename' => 'transactions_view_transaction'
209
-                    ),
210
-                    'transactions_view_transaction_transaction_details_table_help_tab'                    => array(
211
-                        'title'    => esc_html__('Transaction Details Table', 'event_espresso'),
212
-                        'filename' => 'transactions_view_transaction_transaction_details_table'
213
-                    ),
214
-                    'transactions_view_transaction_attendees_registered_help_tab'                         => array(
215
-                        'title'    => esc_html__('Attendees Registered', 'event_espresso'),
216
-                        'filename' => 'transactions_view_transaction_attendees_registered'
217
-                    ),
218
-                    'transactions_view_transaction_views_primary_registrant_billing_information_help_tab' => array(
219
-                        'title'    => esc_html__('Primary Registrant & Billing Information', 'event_espresso'),
220
-                        'filename' => 'transactions_view_transaction_primary_registrant_billing_information'
221
-                    ),
222
-                ),
223
-                'qtips'     => array('Transaction_Details_Tips'),
224
-                'help_tour' => array('Transaction_Details_Help_Tour'),
225
-                'metaboxes' => array('_transaction_details_metaboxes'),
155
+			'espresso_delete_payment' => array(
156
+				'func'       => 'delete_payment',
157
+				'noheader'   => true,
158
+				'capability' => 'ee_delete_payments'
159
+			),
160
+        
161
+		);
162
+        
163
+	}
164
+    
165
+    
166
+	protected function _set_page_config()
167
+	{
168
+		$this->_page_config = array(
169
+			'default'          => array(
170
+				'nav'           => array(
171
+					'label' => esc_html__('Overview', 'event_espresso'),
172
+					'order' => 10
173
+				),
174
+				'list_table'    => 'EE_Admin_Transactions_List_Table',
175
+				'help_tabs'     => array(
176
+					'transactions_overview_help_tab'                       => array(
177
+						'title'    => esc_html__('Transactions Overview', 'event_espresso'),
178
+						'filename' => 'transactions_overview'
179
+					),
180
+					'transactions_overview_table_column_headings_help_tab' => array(
181
+						'title'    => esc_html__('Transactions Table Column Headings', 'event_espresso'),
182
+						'filename' => 'transactions_overview_table_column_headings'
183
+					),
184
+					'transactions_overview_views_filters_help_tab'         => array(
185
+						'title'    => esc_html__('Transaction Views & Filters & Search', 'event_espresso'),
186
+						'filename' => 'transactions_overview_views_filters_search'
187
+					),
188
+				),
189
+				'help_tour'     => array('Transactions_Overview_Help_Tour'),
190
+				/**
191
+				 * commented out because currently we are not displaying tips for transaction list table status but this
192
+				 * may change in a later iteration so want to keep the code for then.
193
+				 */
194
+				//'qtips' => array( 'Transactions_List_Table_Tips' ),
195
+				'require_nonce' => false
196
+			),
197
+			'view_transaction' => array(
198
+				'nav'       => array(
199
+					'label'      => esc_html__('View Transaction', 'event_espresso'),
200
+					'order'      => 5,
201
+					'url'        => isset($this->_req_data['TXN_ID']) ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID']),
202
+						$this->_current_page_view_url) : $this->_admin_base_url,
203
+					'persistent' => false
204
+				),
205
+				'help_tabs' => array(
206
+					'transactions_view_transaction_help_tab'                                              => array(
207
+						'title'    => esc_html__('View Transaction', 'event_espresso'),
208
+						'filename' => 'transactions_view_transaction'
209
+					),
210
+					'transactions_view_transaction_transaction_details_table_help_tab'                    => array(
211
+						'title'    => esc_html__('Transaction Details Table', 'event_espresso'),
212
+						'filename' => 'transactions_view_transaction_transaction_details_table'
213
+					),
214
+					'transactions_view_transaction_attendees_registered_help_tab'                         => array(
215
+						'title'    => esc_html__('Attendees Registered', 'event_espresso'),
216
+						'filename' => 'transactions_view_transaction_attendees_registered'
217
+					),
218
+					'transactions_view_transaction_views_primary_registrant_billing_information_help_tab' => array(
219
+						'title'    => esc_html__('Primary Registrant & Billing Information', 'event_espresso'),
220
+						'filename' => 'transactions_view_transaction_primary_registrant_billing_information'
221
+					),
222
+				),
223
+				'qtips'     => array('Transaction_Details_Tips'),
224
+				'help_tour' => array('Transaction_Details_Help_Tour'),
225
+				'metaboxes' => array('_transaction_details_metaboxes'),
226 226
                 
227
-                'require_nonce' => false
228
-            )
229
-        );
230
-    }
231
-    
232
-    
233
-    /**
234
-     * The below methods aren't used by this class currently
235
-     */
236
-    protected function _add_screen_options()
237
-    {
238
-    }
239
-    
240
-    protected function _add_feature_pointers()
241
-    {
242
-    }
243
-    
244
-    public function admin_init()
245
-    {
246
-        // IF a registration was JUST added via the admin...
247
-        if (
248
-        isset(
249
-            $this->_req_data['redirect_from'],
250
-            $this->_req_data['EVT_ID'],
251
-            $this->_req_data['event_name']
252
-        )
253
-        ) {
254
-            // then set a cookie so that we can block any attempts to use
255
-            // the back button as a way to enter another registration.
256
-            setcookie('ee_registration_added', $this->_req_data['EVT_ID'], time() + WEEK_IN_SECONDS, '/');
257
-            // and update the global
258
-            $_COOKIE['ee_registration_added'] = $this->_req_data['EVT_ID'];
259
-        }
260
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = esc_html__('An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
261
-            'event_espresso');
262
-        EE_Registry::$i18n_js_strings['error_occurred']          = esc_html__('An error occurred! Please refresh the page and try again.',
263
-            'event_espresso');
264
-        EE_Registry::$i18n_js_strings['txn_status_array']        = self::$_txn_status;
265
-        EE_Registry::$i18n_js_strings['pay_status_array']        = self::$_pay_status;
266
-        EE_Registry::$i18n_js_strings['payments_total']          = esc_html__('Payments Total', 'event_espresso');
267
-        EE_Registry::$i18n_js_strings['transaction_overpaid']    = esc_html__('This transaction has been overpaid ! Payments Total',
268
-            'event_espresso');
269
-    }
270
-    
271
-    public function admin_notices()
272
-    {
273
-    }
274
-    
275
-    public function admin_footer_scripts()
276
-    {
277
-    }
278
-    
279
-    
280
-    /**
281
-     * _set_transaction_status_array
282
-     * sets list of transaction statuses
283
-     *
284
-     * @access private
285
-     * @return void
286
-     */
287
-    private function _set_transaction_status_array()
288
-    {
289
-        self::$_txn_status = EEM_Transaction::instance()->status_array(true);
290
-    }
291
-    
292
-    
293
-    /**
294
-     * get_transaction_status_array
295
-     * return the transaction status array for wp_list_table
296
-     *
297
-     * @access public
298
-     * @return array
299
-     */
300
-    public function get_transaction_status_array()
301
-    {
302
-        return self::$_txn_status;
303
-    }
304
-    
305
-    
306
-    /**
307
-     *    get list of payment statuses
308
-     *
309
-     * @access private
310
-     * @return void
311
-     */
312
-    private function _get_payment_status_array()
313
-    {
314
-        self::$_pay_status                      = EEM_Payment::instance()->status_array(true);
315
-        $this->_template_args['payment_status'] = self::$_pay_status;
316
-        
317
-    }
318
-    
319
-    
320
-    /**
321
-     *    _add_screen_options_default
322
-     *
323
-     * @access protected
324
-     * @return void
325
-     */
326
-    protected function _add_screen_options_default()
327
-    {
328
-        $this->_per_page_screen_option();
329
-    }
330
-    
331
-    
332
-    /**
333
-     * load_scripts_styles
334
-     *
335
-     * @access public
336
-     * @return void
337
-     */
338
-    public function load_scripts_styles()
339
-    {
340
-        //enqueue style
341
-        wp_register_style('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.css', array(),
342
-            EVENT_ESPRESSO_VERSION);
343
-        wp_enqueue_style('espresso_txn');
344
-        
345
-        //scripts
346
-        add_filter('FHEE_load_accounting_js', '__return_true');
347
-        
348
-        //scripts
349
-        wp_register_script('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.js', array(
350
-            'ee_admin_js',
351
-            'ee-datepicker',
352
-            'jquery-ui-datepicker',
353
-            'jquery-ui-draggable',
354
-            'ee-dialog',
355
-            'ee-accounting',
356
-            'ee-serialize-full-array'
357
-        ), EVENT_ESPRESSO_VERSION, true);
358
-        wp_enqueue_script('espresso_txn');
359
-        
360
-    }
361
-    
362
-    
363
-    /**
364
-     *    load_scripts_styles_view_transaction
365
-     *
366
-     * @access public
367
-     * @return void
368
-     */
369
-    public function load_scripts_styles_view_transaction()
370
-    {
371
-        //styles
372
-        wp_enqueue_style('espresso-ui-theme');
373
-    }
374
-    
375
-    
376
-    /**
377
-     *    load_scripts_styles_default
378
-     *
379
-     * @access public
380
-     * @return void
381
-     */
382
-    public function load_scripts_styles_default()
383
-    {
384
-        //styles
385
-        wp_enqueue_style('espresso-ui-theme');
386
-    }
387
-    
388
-    
389
-    /**
390
-     *    _set_list_table_views_default
391
-     *
392
-     * @access protected
393
-     * @return void
394
-     */
395
-    protected function _set_list_table_views_default()
396
-    {
397
-        $this->_views = array(
398
-            'all'       => array(
399
-                'slug'  => 'all',
400
-                'label' => esc_html__('View All Transactions', 'event_espresso'),
401
-                'count' => 0
402
-            ),
403
-            'abandoned' => array(
404
-                'slug'  => 'abandoned',
405
-                'label' => esc_html__('Abandoned Transactions', 'event_espresso'),
406
-                'count' => 0
407
-            ),
408
-            'failed'    => array(
409
-                'slug'  => 'failed',
410
-                'label' => esc_html__('Failed Transactions', 'event_espresso'),
411
-                'count' => 0
412
-            )
413
-        );
414
-    }
415
-    
416
-    
417
-    /**
418
-     * _set_transaction_object
419
-     * This sets the _transaction property for the transaction details screen
420
-     *
421
-     * @access private
422
-     * @return void
423
-     */
424
-    private function _set_transaction_object()
425
-    {
426
-        if (is_object($this->_transaction)) {
427
-            return;
428
-        } //get out we've already set the object
429
-        
430
-        $TXN = EEM_Transaction::instance();
431
-        
432
-        $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : false;
433
-        
434
-        //get transaction object
435
-        $this->_transaction = $TXN->get_one_by_ID($TXN_ID);
436
-        $this->_session     = ! empty($this->_transaction) ? $this->_transaction->get('TXN_session_data') : null;
437
-        $this->_transaction->verify_abandoned_transaction_status();
438
-        
439
-        if (empty($this->_transaction)) {
440
-            $error_msg = esc_html__('An error occurred and the details for Transaction ID #',
441
-                    'event_espresso') . $TXN_ID . esc_html__(' could not be retrieved.', 'event_espresso');
442
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
443
-        }
444
-    }
445
-    
446
-    
447
-    /**
448
-     *    _transaction_legend_items
449
-     *
450
-     * @access protected
451
-     * @return array
452
-     */
453
-    protected function _transaction_legend_items()
454
-    {
455
-        EE_Registry::instance()->load_helper('MSG_Template');
456
-        $items = array();
457
-        
458
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
459
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
460
-            if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
461
-                $items['view_related_messages'] = array(
462
-                    'class' => $related_for_icon['css_class'],
463
-                    'desc'  => $related_for_icon['label'],
464
-                );
465
-            }
466
-        }
467
-        
468
-        $items = apply_filters(
469
-            'FHEE__Transactions_Admin_Page___transaction_legend_items__items',
470
-            array_merge($items,
471
-                array(
472
-                    'view_details'      => array(
473
-                        'class' => 'dashicons dashicons-cart',
474
-                        'desc'  => esc_html__('View Transaction Details', 'event_espresso')
475
-                    ),
476
-                    'view_invoice'      => array(
477
-                        'class' => 'dashicons dashicons-media-spreadsheet',
478
-                        'desc'  => esc_html__('View Transaction Invoice', 'event_espresso')
479
-                    ),
480
-                    'view_receipt'      => array(
481
-                        'class' => 'dashicons dashicons-media-default',
482
-                        'desc'  => esc_html__('View Transaction Receipt', 'event_espresso')
483
-                    ),
484
-                    'view_registration' => array(
485
-                        'class' => 'dashicons dashicons-clipboard',
486
-                        'desc'  => esc_html__('View Registration Details', 'event_espresso')
487
-                    )
488
-                )
489
-            )
490
-        );
491
-        
492
-        if (EE_Registry::instance()->CAP->current_user_can('ee_send_message',
493
-            'espresso_transactions_send_payment_reminder')
494
-        ) {
495
-            if (EEH_MSG_Template::is_mt_active('payment_reminder')) {
496
-                $items['send_payment_reminder'] = array(
497
-                    'class' => 'dashicons dashicons-email-alt',
498
-                    'desc'  => esc_html__('Send Payment Reminder', 'event_espresso')
499
-                );
500
-            } else {
501
-                $items['blank*'] = array(
502
-                    'class' => '',
503
-                    'desc'  => ''
504
-                );
505
-            }
506
-        } else {
507
-            $items['blank*'] = array(
508
-                'class' => '',
509
-                'desc'  => ''
510
-            );
511
-        }
512
-        $more_items = apply_filters(
513
-            'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items',
514
-            array(
515
-                'overpaid'   => array(
516
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code,
517
-                    'desc'  => EEH_Template::pretty_status(EEM_Transaction::overpaid_status_code, false, 'sentence')
518
-                ),
519
-                'complete'   => array(
520
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code,
521
-                    'desc'  => EEH_Template::pretty_status(EEM_Transaction::complete_status_code, false, 'sentence')
522
-                ),
523
-                'incomplete' => array(
524
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code,
525
-                    'desc'  => EEH_Template::pretty_status(EEM_Transaction::incomplete_status_code, false, 'sentence')
526
-                ),
527
-                'abandoned'  => array(
528
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code,
529
-                    'desc'  => EEH_Template::pretty_status(EEM_Transaction::abandoned_status_code, false, 'sentence')
530
-                ),
531
-                'failed'     => array(
532
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code,
533
-                    'desc'  => EEH_Template::pretty_status(EEM_Transaction::failed_status_code, false, 'sentence')
534
-                )
535
-            )
536
-        );
537
-        
538
-        return array_merge($items, $more_items);
539
-    }
540
-    
541
-    
542
-    /**
543
-     *    _transactions_overview_list_table
544
-     *
545
-     * @access protected
546
-     * @return void
547
-     */
548
-    protected function _transactions_overview_list_table()
549
-    {
550
-        $this->_admin_page_title                   = esc_html__('Transactions', 'event_espresso');
551
-        $event                                     = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']) : null;
552
-        $this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf(esc_html__('%sViewing Transactions for the Event: %s%s',
553
-            'event_espresso'), '<h3>',
554
-            '<a href="' . EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()),
555
-                EVENTS_ADMIN_URL) . '" title="' . esc_attr__('Click to Edit event',
556
-                'event_espresso') . '">' . $event->get('EVT_name') . '</a>', '</h3>') : '';
557
-        $this->_template_args['after_list_table']  = $this->_display_legend($this->_transaction_legend_items());
558
-        $this->display_admin_list_table_page_with_no_sidebar();
559
-    }
560
-    
561
-    
562
-    /**
563
-     *    _transaction_details
564
-     * generates HTML for the View Transaction Details Admin page
565
-     *
566
-     * @access protected
567
-     * @return void
568
-     */
569
-    protected function _transaction_details()
570
-    {
571
-        do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction);
572
-        
573
-        $this->_set_transaction_status_array();
574
-        
575
-        $this->_template_args                      = array();
576
-        $this->_template_args['transactions_page'] = $this->_wp_page_slug;
577
-        
578
-        $this->_set_transaction_object();
579
-        
580
-        $primary_registration = $this->_transaction->primary_registration();
581
-        $attendee             = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : null;
582
-        
583
-        $this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID();
584
-        $this->_template_args['txn_nmbr']['label'] = esc_html__('Transaction Number', 'event_espresso');
585
-        
586
-        $this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp');
587
-        $this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso');
588
-        
589
-        $this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->get('STS_ID')];
590
-        $this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso');
591
-        $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID');
592
-        
593
-        $this->_template_args['grand_total'] = $this->_transaction->get('TXN_total');
594
-        $this->_template_args['total_paid']  = $this->_transaction->get('TXN_paid');
595
-        
596
-        if (
597
-            $attendee instanceof EE_Attendee
598
-            && EE_Registry::instance()->CAP->current_user_can(
599
-                'ee_send_message',
600
-                'espresso_transactions_send_payment_reminder'
601
-            )
602
-        ) {
603
-            $this->_template_args['send_payment_reminder_button'] =
604
-                EEH_MSG_Template::is_mt_active('payment_reminder')
605
-                && $this->_transaction->get('STS_ID') != EEM_Transaction::complete_status_code
606
-                && $this->_transaction->get('STS_ID') != EEM_Transaction::overpaid_status_code
607
-                    ? EEH_Template::get_button_or_link(
608
-                    EE_Admin_Page::add_query_args_and_nonce(
609
-                        array(
610
-                            'action'      => 'send_payment_reminder',
611
-                            'TXN_ID'      => $this->_transaction->ID(),
612
-                            'redirect_to' => 'view_transaction'
613
-                        ),
614
-                        TXN_ADMIN_URL
615
-                    ),
616
-                    __(' Send Payment Reminder', 'event_espresso'),
617
-                    'button secondary-button right',
618
-                    'dashicons dashicons-email-alt'
619
-                )
620
-                    : '';
621
-        } else {
622
-            $this->_template_args['send_payment_reminder_button'] = '';
623
-        }
624
-        
625
-        $amount_due                         = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid');
626
-        $this->_template_args['amount_due'] = EEH_Template::format_currency($amount_due, true);
627
-        if (EE_Registry::instance()->CFG->currency->sign_b4) {
628
-            $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign . $this->_template_args['amount_due'];
629
-        } else {
630
-            $this->_template_args['amount_due'] = $this->_template_args['amount_due'] . EE_Registry::instance()->CFG->currency->sign;
631
-        }
632
-        $this->_template_args['amount_due_class'] = '';
633
-        
634
-        if ($this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total')) {
635
-            // paid in full
636
-            $this->_template_args['amount_due'] = false;
637
-        } elseif ($this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total')) {
638
-            // overpaid
639
-            $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
640
-        } elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') > 0)) {
641
-            // monies owing
642
-            $this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn';
643
-        } elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') == 0)) {
644
-            // no payments made yet
645
-            $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
646
-        } elseif ($this->_transaction->get('TXN_total') == 0) {
647
-            // free event
648
-            $this->_template_args['amount_due'] = false;
649
-        }
650
-        
651
-        $payment_method = $this->_transaction->payment_method();
652
-        
653
-        $this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method
654
-            ? $payment_method->admin_name()
655
-            : esc_html__('Unknown', 'event_espresso');
656
-        
657
-        $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
658
-        // link back to overview
659
-        $this->_template_args['txn_overview_url'] = ! empty ($_SERVER['HTTP_REFERER'])
660
-            ? $_SERVER['HTTP_REFERER']
661
-            : TXN_ADMIN_URL;
662
-        
663
-        
664
-        // next link
665
-        $next_txn                                 = $this->_transaction->next(
666
-            null,
667
-            array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
668
-            'TXN_ID'
669
-        );
670
-        $this->_template_args['next_transaction'] = $next_txn
671
-            ? $this->_next_link(
672
-                EE_Admin_Page::add_query_args_and_nonce(
673
-                    array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']),
674
-                    TXN_ADMIN_URL
675
-                ),
676
-                'dashicons dashicons-arrow-right ee-icon-size-22'
677
-            )
678
-            : '';
679
-        // previous link
680
-        $previous_txn                                 = $this->_transaction->previous(
681
-            null,
682
-            array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
683
-            'TXN_ID'
684
-        );
685
-        $this->_template_args['previous_transaction'] = $previous_txn
686
-            ? $this->_previous_link(
687
-                EE_Admin_Page::add_query_args_and_nonce(
688
-                    array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']),
689
-                    TXN_ADMIN_URL
690
-                ),
691
-                'dashicons dashicons-arrow-left ee-icon-size-22'
692
-            )
693
-            : '';
694
-        
695
-        // were we just redirected here after adding a new registration ???
696
-        if (
697
-        isset(
698
-            $this->_req_data['redirect_from'],
699
-            $this->_req_data['EVT_ID'],
700
-            $this->_req_data['event_name']
701
-        )
702
-        ) {
703
-            if (
704
-            EE_Registry::instance()->CAP->current_user_can(
705
-                'ee_edit_registrations',
706
-                'espresso_registrations_new_registration',
707
-                $this->_req_data['EVT_ID']
708
-            )
709
-            ) {
710
-                $this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="';
711
-                $this->_admin_page_title .= EE_Admin_Page::add_query_args_and_nonce(
712
-                    array(
713
-                        'page'     => 'espresso_registrations',
714
-                        'action'   => 'new_registration',
715
-                        'return'   => 'default',
716
-                        'TXN_ID'   => $this->_transaction->ID(),
717
-                        'event_id' => $this->_req_data['EVT_ID'],
718
-                    ),
719
-                    REG_ADMIN_URL
720
-                );
721
-                $this->_admin_page_title .= '">';
227
+				'require_nonce' => false
228
+			)
229
+		);
230
+	}
231
+    
232
+    
233
+	/**
234
+	 * The below methods aren't used by this class currently
235
+	 */
236
+	protected function _add_screen_options()
237
+	{
238
+	}
239
+    
240
+	protected function _add_feature_pointers()
241
+	{
242
+	}
243
+    
244
+	public function admin_init()
245
+	{
246
+		// IF a registration was JUST added via the admin...
247
+		if (
248
+		isset(
249
+			$this->_req_data['redirect_from'],
250
+			$this->_req_data['EVT_ID'],
251
+			$this->_req_data['event_name']
252
+		)
253
+		) {
254
+			// then set a cookie so that we can block any attempts to use
255
+			// the back button as a way to enter another registration.
256
+			setcookie('ee_registration_added', $this->_req_data['EVT_ID'], time() + WEEK_IN_SECONDS, '/');
257
+			// and update the global
258
+			$_COOKIE['ee_registration_added'] = $this->_req_data['EVT_ID'];
259
+		}
260
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = esc_html__('An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
261
+			'event_espresso');
262
+		EE_Registry::$i18n_js_strings['error_occurred']          = esc_html__('An error occurred! Please refresh the page and try again.',
263
+			'event_espresso');
264
+		EE_Registry::$i18n_js_strings['txn_status_array']        = self::$_txn_status;
265
+		EE_Registry::$i18n_js_strings['pay_status_array']        = self::$_pay_status;
266
+		EE_Registry::$i18n_js_strings['payments_total']          = esc_html__('Payments Total', 'event_espresso');
267
+		EE_Registry::$i18n_js_strings['transaction_overpaid']    = esc_html__('This transaction has been overpaid ! Payments Total',
268
+			'event_espresso');
269
+	}
270
+    
271
+	public function admin_notices()
272
+	{
273
+	}
274
+    
275
+	public function admin_footer_scripts()
276
+	{
277
+	}
278
+    
279
+    
280
+	/**
281
+	 * _set_transaction_status_array
282
+	 * sets list of transaction statuses
283
+	 *
284
+	 * @access private
285
+	 * @return void
286
+	 */
287
+	private function _set_transaction_status_array()
288
+	{
289
+		self::$_txn_status = EEM_Transaction::instance()->status_array(true);
290
+	}
291
+    
292
+    
293
+	/**
294
+	 * get_transaction_status_array
295
+	 * return the transaction status array for wp_list_table
296
+	 *
297
+	 * @access public
298
+	 * @return array
299
+	 */
300
+	public function get_transaction_status_array()
301
+	{
302
+		return self::$_txn_status;
303
+	}
304
+    
305
+    
306
+	/**
307
+	 *    get list of payment statuses
308
+	 *
309
+	 * @access private
310
+	 * @return void
311
+	 */
312
+	private function _get_payment_status_array()
313
+	{
314
+		self::$_pay_status                      = EEM_Payment::instance()->status_array(true);
315
+		$this->_template_args['payment_status'] = self::$_pay_status;
316
+        
317
+	}
318
+    
319
+    
320
+	/**
321
+	 *    _add_screen_options_default
322
+	 *
323
+	 * @access protected
324
+	 * @return void
325
+	 */
326
+	protected function _add_screen_options_default()
327
+	{
328
+		$this->_per_page_screen_option();
329
+	}
330
+    
331
+    
332
+	/**
333
+	 * load_scripts_styles
334
+	 *
335
+	 * @access public
336
+	 * @return void
337
+	 */
338
+	public function load_scripts_styles()
339
+	{
340
+		//enqueue style
341
+		wp_register_style('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.css', array(),
342
+			EVENT_ESPRESSO_VERSION);
343
+		wp_enqueue_style('espresso_txn');
344
+        
345
+		//scripts
346
+		add_filter('FHEE_load_accounting_js', '__return_true');
347
+        
348
+		//scripts
349
+		wp_register_script('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.js', array(
350
+			'ee_admin_js',
351
+			'ee-datepicker',
352
+			'jquery-ui-datepicker',
353
+			'jquery-ui-draggable',
354
+			'ee-dialog',
355
+			'ee-accounting',
356
+			'ee-serialize-full-array'
357
+		), EVENT_ESPRESSO_VERSION, true);
358
+		wp_enqueue_script('espresso_txn');
359
+        
360
+	}
361
+    
362
+    
363
+	/**
364
+	 *    load_scripts_styles_view_transaction
365
+	 *
366
+	 * @access public
367
+	 * @return void
368
+	 */
369
+	public function load_scripts_styles_view_transaction()
370
+	{
371
+		//styles
372
+		wp_enqueue_style('espresso-ui-theme');
373
+	}
374
+    
375
+    
376
+	/**
377
+	 *    load_scripts_styles_default
378
+	 *
379
+	 * @access public
380
+	 * @return void
381
+	 */
382
+	public function load_scripts_styles_default()
383
+	{
384
+		//styles
385
+		wp_enqueue_style('espresso-ui-theme');
386
+	}
387
+    
388
+    
389
+	/**
390
+	 *    _set_list_table_views_default
391
+	 *
392
+	 * @access protected
393
+	 * @return void
394
+	 */
395
+	protected function _set_list_table_views_default()
396
+	{
397
+		$this->_views = array(
398
+			'all'       => array(
399
+				'slug'  => 'all',
400
+				'label' => esc_html__('View All Transactions', 'event_espresso'),
401
+				'count' => 0
402
+			),
403
+			'abandoned' => array(
404
+				'slug'  => 'abandoned',
405
+				'label' => esc_html__('Abandoned Transactions', 'event_espresso'),
406
+				'count' => 0
407
+			),
408
+			'failed'    => array(
409
+				'slug'  => 'failed',
410
+				'label' => esc_html__('Failed Transactions', 'event_espresso'),
411
+				'count' => 0
412
+			)
413
+		);
414
+	}
415
+    
416
+    
417
+	/**
418
+	 * _set_transaction_object
419
+	 * This sets the _transaction property for the transaction details screen
420
+	 *
421
+	 * @access private
422
+	 * @return void
423
+	 */
424
+	private function _set_transaction_object()
425
+	{
426
+		if (is_object($this->_transaction)) {
427
+			return;
428
+		} //get out we've already set the object
429
+        
430
+		$TXN = EEM_Transaction::instance();
431
+        
432
+		$TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : false;
433
+        
434
+		//get transaction object
435
+		$this->_transaction = $TXN->get_one_by_ID($TXN_ID);
436
+		$this->_session     = ! empty($this->_transaction) ? $this->_transaction->get('TXN_session_data') : null;
437
+		$this->_transaction->verify_abandoned_transaction_status();
438
+        
439
+		if (empty($this->_transaction)) {
440
+			$error_msg = esc_html__('An error occurred and the details for Transaction ID #',
441
+					'event_espresso') . $TXN_ID . esc_html__(' could not be retrieved.', 'event_espresso');
442
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
443
+		}
444
+	}
445
+    
446
+    
447
+	/**
448
+	 *    _transaction_legend_items
449
+	 *
450
+	 * @access protected
451
+	 * @return array
452
+	 */
453
+	protected function _transaction_legend_items()
454
+	{
455
+		EE_Registry::instance()->load_helper('MSG_Template');
456
+		$items = array();
457
+        
458
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
459
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
460
+			if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
461
+				$items['view_related_messages'] = array(
462
+					'class' => $related_for_icon['css_class'],
463
+					'desc'  => $related_for_icon['label'],
464
+				);
465
+			}
466
+		}
467
+        
468
+		$items = apply_filters(
469
+			'FHEE__Transactions_Admin_Page___transaction_legend_items__items',
470
+			array_merge($items,
471
+				array(
472
+					'view_details'      => array(
473
+						'class' => 'dashicons dashicons-cart',
474
+						'desc'  => esc_html__('View Transaction Details', 'event_espresso')
475
+					),
476
+					'view_invoice'      => array(
477
+						'class' => 'dashicons dashicons-media-spreadsheet',
478
+						'desc'  => esc_html__('View Transaction Invoice', 'event_espresso')
479
+					),
480
+					'view_receipt'      => array(
481
+						'class' => 'dashicons dashicons-media-default',
482
+						'desc'  => esc_html__('View Transaction Receipt', 'event_espresso')
483
+					),
484
+					'view_registration' => array(
485
+						'class' => 'dashicons dashicons-clipboard',
486
+						'desc'  => esc_html__('View Registration Details', 'event_espresso')
487
+					)
488
+				)
489
+			)
490
+		);
491
+        
492
+		if (EE_Registry::instance()->CAP->current_user_can('ee_send_message',
493
+			'espresso_transactions_send_payment_reminder')
494
+		) {
495
+			if (EEH_MSG_Template::is_mt_active('payment_reminder')) {
496
+				$items['send_payment_reminder'] = array(
497
+					'class' => 'dashicons dashicons-email-alt',
498
+					'desc'  => esc_html__('Send Payment Reminder', 'event_espresso')
499
+				);
500
+			} else {
501
+				$items['blank*'] = array(
502
+					'class' => '',
503
+					'desc'  => ''
504
+				);
505
+			}
506
+		} else {
507
+			$items['blank*'] = array(
508
+				'class' => '',
509
+				'desc'  => ''
510
+			);
511
+		}
512
+		$more_items = apply_filters(
513
+			'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items',
514
+			array(
515
+				'overpaid'   => array(
516
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code,
517
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::overpaid_status_code, false, 'sentence')
518
+				),
519
+				'complete'   => array(
520
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code,
521
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::complete_status_code, false, 'sentence')
522
+				),
523
+				'incomplete' => array(
524
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code,
525
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::incomplete_status_code, false, 'sentence')
526
+				),
527
+				'abandoned'  => array(
528
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code,
529
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::abandoned_status_code, false, 'sentence')
530
+				),
531
+				'failed'     => array(
532
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code,
533
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::failed_status_code, false, 'sentence')
534
+				)
535
+			)
536
+		);
537
+        
538
+		return array_merge($items, $more_items);
539
+	}
540
+    
541
+    
542
+	/**
543
+	 *    _transactions_overview_list_table
544
+	 *
545
+	 * @access protected
546
+	 * @return void
547
+	 */
548
+	protected function _transactions_overview_list_table()
549
+	{
550
+		$this->_admin_page_title                   = esc_html__('Transactions', 'event_espresso');
551
+		$event                                     = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']) : null;
552
+		$this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf(esc_html__('%sViewing Transactions for the Event: %s%s',
553
+			'event_espresso'), '<h3>',
554
+			'<a href="' . EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()),
555
+				EVENTS_ADMIN_URL) . '" title="' . esc_attr__('Click to Edit event',
556
+				'event_espresso') . '">' . $event->get('EVT_name') . '</a>', '</h3>') : '';
557
+		$this->_template_args['after_list_table']  = $this->_display_legend($this->_transaction_legend_items());
558
+		$this->display_admin_list_table_page_with_no_sidebar();
559
+	}
560
+    
561
+    
562
+	/**
563
+	 *    _transaction_details
564
+	 * generates HTML for the View Transaction Details Admin page
565
+	 *
566
+	 * @access protected
567
+	 * @return void
568
+	 */
569
+	protected function _transaction_details()
570
+	{
571
+		do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction);
572
+        
573
+		$this->_set_transaction_status_array();
574
+        
575
+		$this->_template_args                      = array();
576
+		$this->_template_args['transactions_page'] = $this->_wp_page_slug;
577
+        
578
+		$this->_set_transaction_object();
579
+        
580
+		$primary_registration = $this->_transaction->primary_registration();
581
+		$attendee             = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : null;
582
+        
583
+		$this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID();
584
+		$this->_template_args['txn_nmbr']['label'] = esc_html__('Transaction Number', 'event_espresso');
585
+        
586
+		$this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp');
587
+		$this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso');
588
+        
589
+		$this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->get('STS_ID')];
590
+		$this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso');
591
+		$this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID');
592
+        
593
+		$this->_template_args['grand_total'] = $this->_transaction->get('TXN_total');
594
+		$this->_template_args['total_paid']  = $this->_transaction->get('TXN_paid');
595
+        
596
+		if (
597
+			$attendee instanceof EE_Attendee
598
+			&& EE_Registry::instance()->CAP->current_user_can(
599
+				'ee_send_message',
600
+				'espresso_transactions_send_payment_reminder'
601
+			)
602
+		) {
603
+			$this->_template_args['send_payment_reminder_button'] =
604
+				EEH_MSG_Template::is_mt_active('payment_reminder')
605
+				&& $this->_transaction->get('STS_ID') != EEM_Transaction::complete_status_code
606
+				&& $this->_transaction->get('STS_ID') != EEM_Transaction::overpaid_status_code
607
+					? EEH_Template::get_button_or_link(
608
+					EE_Admin_Page::add_query_args_and_nonce(
609
+						array(
610
+							'action'      => 'send_payment_reminder',
611
+							'TXN_ID'      => $this->_transaction->ID(),
612
+							'redirect_to' => 'view_transaction'
613
+						),
614
+						TXN_ADMIN_URL
615
+					),
616
+					__(' Send Payment Reminder', 'event_espresso'),
617
+					'button secondary-button right',
618
+					'dashicons dashicons-email-alt'
619
+				)
620
+					: '';
621
+		} else {
622
+			$this->_template_args['send_payment_reminder_button'] = '';
623
+		}
624
+        
625
+		$amount_due                         = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid');
626
+		$this->_template_args['amount_due'] = EEH_Template::format_currency($amount_due, true);
627
+		if (EE_Registry::instance()->CFG->currency->sign_b4) {
628
+			$this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign . $this->_template_args['amount_due'];
629
+		} else {
630
+			$this->_template_args['amount_due'] = $this->_template_args['amount_due'] . EE_Registry::instance()->CFG->currency->sign;
631
+		}
632
+		$this->_template_args['amount_due_class'] = '';
633
+        
634
+		if ($this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total')) {
635
+			// paid in full
636
+			$this->_template_args['amount_due'] = false;
637
+		} elseif ($this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total')) {
638
+			// overpaid
639
+			$this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
640
+		} elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') > 0)) {
641
+			// monies owing
642
+			$this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn';
643
+		} elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') == 0)) {
644
+			// no payments made yet
645
+			$this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
646
+		} elseif ($this->_transaction->get('TXN_total') == 0) {
647
+			// free event
648
+			$this->_template_args['amount_due'] = false;
649
+		}
650
+        
651
+		$payment_method = $this->_transaction->payment_method();
652
+        
653
+		$this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method
654
+			? $payment_method->admin_name()
655
+			: esc_html__('Unknown', 'event_espresso');
656
+        
657
+		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
658
+		// link back to overview
659
+		$this->_template_args['txn_overview_url'] = ! empty ($_SERVER['HTTP_REFERER'])
660
+			? $_SERVER['HTTP_REFERER']
661
+			: TXN_ADMIN_URL;
662
+        
663
+        
664
+		// next link
665
+		$next_txn                                 = $this->_transaction->next(
666
+			null,
667
+			array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
668
+			'TXN_ID'
669
+		);
670
+		$this->_template_args['next_transaction'] = $next_txn
671
+			? $this->_next_link(
672
+				EE_Admin_Page::add_query_args_and_nonce(
673
+					array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']),
674
+					TXN_ADMIN_URL
675
+				),
676
+				'dashicons dashicons-arrow-right ee-icon-size-22'
677
+			)
678
+			: '';
679
+		// previous link
680
+		$previous_txn                                 = $this->_transaction->previous(
681
+			null,
682
+			array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
683
+			'TXN_ID'
684
+		);
685
+		$this->_template_args['previous_transaction'] = $previous_txn
686
+			? $this->_previous_link(
687
+				EE_Admin_Page::add_query_args_and_nonce(
688
+					array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']),
689
+					TXN_ADMIN_URL
690
+				),
691
+				'dashicons dashicons-arrow-left ee-icon-size-22'
692
+			)
693
+			: '';
694
+        
695
+		// were we just redirected here after adding a new registration ???
696
+		if (
697
+		isset(
698
+			$this->_req_data['redirect_from'],
699
+			$this->_req_data['EVT_ID'],
700
+			$this->_req_data['event_name']
701
+		)
702
+		) {
703
+			if (
704
+			EE_Registry::instance()->CAP->current_user_can(
705
+				'ee_edit_registrations',
706
+				'espresso_registrations_new_registration',
707
+				$this->_req_data['EVT_ID']
708
+			)
709
+			) {
710
+				$this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="';
711
+				$this->_admin_page_title .= EE_Admin_Page::add_query_args_and_nonce(
712
+					array(
713
+						'page'     => 'espresso_registrations',
714
+						'action'   => 'new_registration',
715
+						'return'   => 'default',
716
+						'TXN_ID'   => $this->_transaction->ID(),
717
+						'event_id' => $this->_req_data['EVT_ID'],
718
+					),
719
+					REG_ADMIN_URL
720
+				);
721
+				$this->_admin_page_title .= '">';
722 722
                 
723
-                $this->_admin_page_title .= sprintf(
724
-                    esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso'),
725
-                    htmlentities(urldecode($this->_req_data['event_name']), ENT_QUOTES, 'UTF-8')
726
-                );
727
-                $this->_admin_page_title .= '</a>';
728
-            }
729
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
730
-        }
731
-        // grab messages at the last second
732
-        $this->_template_args['notices'] = EE_Error::get_notices();
733
-        // path to template
734
-        $template_path                             = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
735
-        $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path,
736
-            $this->_template_args, true);
737
-        
738
-        // the details template wrapper
739
-        $this->display_admin_page_with_sidebar();
740
-        
741
-    }
742
-    
743
-    
744
-    /**
745
-     *        _transaction_details_metaboxes
746
-     *
747
-     * @access protected
748
-     * @return void
749
-     */
750
-    protected function _transaction_details_metaboxes()
751
-    {
752
-        
753
-        $this->_set_transaction_object();
754
-        
755
-        add_meta_box('edit-txn-details-mbox', esc_html__('Transaction Details', 'event_espresso'),
756
-            array($this, 'txn_details_meta_box'), $this->_wp_page_slug, 'normal', 'high');
757
-        add_meta_box(
758
-            'edit-txn-attendees-mbox',
759
-            esc_html__('Attendees Registered in this Transaction', 'event_espresso'),
760
-            array($this, 'txn_attendees_meta_box'),
761
-            $this->_wp_page_slug,
762
-            'normal',
763
-            'high',
764
-            array('TXN_ID' => $this->_transaction->ID())
765
-        );
766
-        add_meta_box('edit-txn-registrant-mbox', esc_html__('Primary Contact', 'event_espresso'),
767
-            array($this, 'txn_registrant_side_meta_box'), $this->_wp_page_slug, 'side', 'high');
768
-        add_meta_box('edit-txn-billing-info-mbox', esc_html__('Billing Information', 'event_espresso'),
769
-            array($this, 'txn_billing_info_side_meta_box'), $this->_wp_page_slug, 'side', 'high');
770
-        
771
-    }
772
-    
773
-    
774
-    /**
775
-     * txn_details_meta_box
776
-     * generates HTML for the Transaction main meta box
777
-     *
778
-     * @access public
779
-     * @return void
780
-     */
781
-    public function txn_details_meta_box()
782
-    {
783
-        
784
-        $this->_set_transaction_object();
785
-        $this->_template_args['TXN_ID']   = $this->_transaction->ID();
786
-        $this->_template_args['attendee'] = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->attendee() : null;
787
-        
788
-        //get line table
789
-        EEH_Autoloader::register_line_item_display_autoloaders();
790
-        $Line_Item_Display                       = new EE_Line_Item_Display('admin_table',
791
-            'EE_Admin_Table_Line_Item_Display_Strategy');
792
-        $this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item($this->_transaction->total_line_item());
793
-        $this->_template_args['REG_code']        = $this->_transaction->get_first_related('Registration')->get('REG_code');
794
-        
795
-        // process taxes
796
-        $taxes                         = $this->_transaction->get_many_related('Line_Item',
797
-            array(array('LIN_type' => EEM_Line_Item::type_tax)));
798
-        $this->_template_args['taxes'] = ! empty($taxes) ? $taxes : false;
799
-        
800
-        $this->_template_args['grand_total']     = EEH_Template::format_currency($this->_transaction->get('TXN_total'),
801
-            false, false);
802
-        $this->_template_args['grand_raw_total'] = $this->_transaction->get('TXN_total');
803
-        $this->_template_args['TXN_status']      = $this->_transaction->get('STS_ID');
723
+				$this->_admin_page_title .= sprintf(
724
+					esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso'),
725
+					htmlentities(urldecode($this->_req_data['event_name']), ENT_QUOTES, 'UTF-8')
726
+				);
727
+				$this->_admin_page_title .= '</a>';
728
+			}
729
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
730
+		}
731
+		// grab messages at the last second
732
+		$this->_template_args['notices'] = EE_Error::get_notices();
733
+		// path to template
734
+		$template_path                             = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
735
+		$this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path,
736
+			$this->_template_args, true);
737
+        
738
+		// the details template wrapper
739
+		$this->display_admin_page_with_sidebar();
740
+        
741
+	}
742
+    
743
+    
744
+	/**
745
+	 *        _transaction_details_metaboxes
746
+	 *
747
+	 * @access protected
748
+	 * @return void
749
+	 */
750
+	protected function _transaction_details_metaboxes()
751
+	{
752
+        
753
+		$this->_set_transaction_object();
754
+        
755
+		add_meta_box('edit-txn-details-mbox', esc_html__('Transaction Details', 'event_espresso'),
756
+			array($this, 'txn_details_meta_box'), $this->_wp_page_slug, 'normal', 'high');
757
+		add_meta_box(
758
+			'edit-txn-attendees-mbox',
759
+			esc_html__('Attendees Registered in this Transaction', 'event_espresso'),
760
+			array($this, 'txn_attendees_meta_box'),
761
+			$this->_wp_page_slug,
762
+			'normal',
763
+			'high',
764
+			array('TXN_ID' => $this->_transaction->ID())
765
+		);
766
+		add_meta_box('edit-txn-registrant-mbox', esc_html__('Primary Contact', 'event_espresso'),
767
+			array($this, 'txn_registrant_side_meta_box'), $this->_wp_page_slug, 'side', 'high');
768
+		add_meta_box('edit-txn-billing-info-mbox', esc_html__('Billing Information', 'event_espresso'),
769
+			array($this, 'txn_billing_info_side_meta_box'), $this->_wp_page_slug, 'side', 'high');
770
+        
771
+	}
772
+    
773
+    
774
+	/**
775
+	 * txn_details_meta_box
776
+	 * generates HTML for the Transaction main meta box
777
+	 *
778
+	 * @access public
779
+	 * @return void
780
+	 */
781
+	public function txn_details_meta_box()
782
+	{
783
+        
784
+		$this->_set_transaction_object();
785
+		$this->_template_args['TXN_ID']   = $this->_transaction->ID();
786
+		$this->_template_args['attendee'] = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->attendee() : null;
787
+        
788
+		//get line table
789
+		EEH_Autoloader::register_line_item_display_autoloaders();
790
+		$Line_Item_Display                       = new EE_Line_Item_Display('admin_table',
791
+			'EE_Admin_Table_Line_Item_Display_Strategy');
792
+		$this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item($this->_transaction->total_line_item());
793
+		$this->_template_args['REG_code']        = $this->_transaction->get_first_related('Registration')->get('REG_code');
794
+        
795
+		// process taxes
796
+		$taxes                         = $this->_transaction->get_many_related('Line_Item',
797
+			array(array('LIN_type' => EEM_Line_Item::type_tax)));
798
+		$this->_template_args['taxes'] = ! empty($taxes) ? $taxes : false;
799
+        
800
+		$this->_template_args['grand_total']     = EEH_Template::format_currency($this->_transaction->get('TXN_total'),
801
+			false, false);
802
+		$this->_template_args['grand_raw_total'] = $this->_transaction->get('TXN_total');
803
+		$this->_template_args['TXN_status']      = $this->_transaction->get('STS_ID');
804 804
 
805 805
 //		$txn_status_class = 'status-' . $this->_transaction->get('STS_ID');
806 806
         
807
-        // process payment details
808
-        $payments = $this->_transaction->get_many_related('Payment');
809
-        if ( ! empty($payments)) {
810
-            $this->_template_args['payments']              = $payments;
811
-            $this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments);
812
-        } else {
813
-            $this->_template_args['payments']              = false;
814
-            $this->_template_args['existing_reg_payments'] = array();
815
-        }
816
-        
817
-        $this->_template_args['edit_payment_url']   = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL);
818
-        $this->_template_args['delete_payment_url'] = add_query_arg(array('action' => 'espresso_delete_payment'),
819
-            TXN_ADMIN_URL);
820
-        
821
-        if (isset($txn_details['invoice_number'])) {
822
-            $this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code'];
823
-            $this->_template_args['txn_details']['invoice_number']['label'] = esc_html__('Invoice Number',
824
-                'event_espresso');
825
-        }
826
-        
827
-        $this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction->get_first_related('Registration')->get('REG_session');
828
-        $this->_template_args['txn_details']['registration_session']['label'] = esc_html__('Registration Session',
829
-            'event_espresso');
830
-        
831
-        $this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '';
832
-        $this->_template_args['txn_details']['ip_address']['label'] = esc_html__('Transaction placed from IP',
833
-            'event_espresso');
834
-        
835
-        $this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '';
836
-        $this->_template_args['txn_details']['user_agent']['label'] = esc_html__('Registrant User Agent',
837
-            'event_espresso');
838
-        
839
-        $reg_steps = '<ul>';
840
-        foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) {
841
-            if ($reg_step_status === true) {
842
-                $reg_steps .= '<li style="color:#70cc50">' . sprintf(esc_html__('%1$s : Completed', 'event_espresso'),
843
-                        ucwords(str_replace('_', ' ', $reg_step))) . '</li>';
844
-            } else if (is_numeric($reg_step_status) && $reg_step_status !== false) {
845
-                $reg_steps .= '<li style="color:#2EA2CC">' . sprintf(
846
-                        esc_html__('%1$s : Initiated %2$s', 'event_espresso'),
847
-                        ucwords(str_replace('_', ' ', $reg_step)),
848
-                        date(get_option('date_format') . ' ' . get_option('time_format'),
849
-                            ($reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS)))
850
-                    ) . '</li>';
851
-            } else {
852
-                $reg_steps .= '<li style="color:#E76700">' . sprintf(esc_html__('%1$s : Never Initiated',
853
-                        'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))) . '</li>';
854
-            }
855
-        }
856
-        $reg_steps .= '</ul>';
857
-        $this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps;
858
-        $this->_template_args['txn_details']['reg_steps']['label'] = esc_html__('Registration Step Progress',
859
-            'event_espresso');
860
-        
861
-        
862
-        $this->_get_registrations_to_apply_payment_to();
863
-        $this->_get_payment_methods($payments);
864
-        $this->_get_payment_status_array();
865
-        $this->_get_reg_status_selection(); //sets up the template args for the reg status array for the transaction.
866
-        
867
-        $this->_template_args['transaction_form_url']    = add_query_arg(array(
868
-            'action'  => 'edit_transaction',
869
-            'process' => 'transaction'
870
-        ), TXN_ADMIN_URL);
871
-        $this->_template_args['apply_payment_form_url']  = add_query_arg(array(
872
-            'page'   => 'espresso_transactions',
873
-            'action' => 'espresso_apply_payment'
874
-        ), WP_AJAX_URL);
875
-        $this->_template_args['delete_payment_form_url'] = add_query_arg(array(
876
-            'page'   => 'espresso_transactions',
877
-            'action' => 'espresso_delete_payment'
878
-        ), WP_AJAX_URL);
879
-        
880
-        // 'espresso_delete_payment_nonce'
881
-        
882
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
883
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
884
-        
885
-    }
886
-    
887
-    
888
-    /**
889
-     * _get_registration_payment_IDs
890
-     *
891
-     *    generates an array of Payment IDs and their corresponding Registration IDs
892
-     *
893
-     * @access protected
894
-     *
895
-     * @param EE_Payment[] $payments
896
-     *
897
-     * @return array
898
-     */
899
-    protected function _get_registration_payment_IDs($payments = array())
900
-    {
901
-        $existing_reg_payments = array();
902
-        // get all reg payments for these payments
903
-        $reg_payments = EEM_Registration_Payment::instance()->get_all(array(
904
-            array(
905
-                'PAY_ID' => array(
906
-                    'IN',
907
-                    array_keys($payments)
908
-                )
909
-            )
910
-        ));
911
-        if ( ! empty($reg_payments)) {
912
-            foreach ($payments as $payment) {
913
-                if ( ! $payment instanceof EE_Payment) {
914
-                    continue;
915
-                } else if ( ! isset($existing_reg_payments[$payment->ID()])) {
916
-                    $existing_reg_payments[$payment->ID()] = array();
917
-                }
918
-                foreach ($reg_payments as $reg_payment) {
919
-                    if ($reg_payment instanceof EE_Registration_Payment && $reg_payment->payment_ID() === $payment->ID()) {
920
-                        $existing_reg_payments[$payment->ID()][] = $reg_payment->registration_ID();
921
-                    }
922
-                }
923
-            }
924
-        }
925
-        
926
-        return $existing_reg_payments;
927
-    }
928
-    
929
-    
930
-    /**
931
-     * _get_registrations_to_apply_payment_to
932
-     *    generates HTML for displaying a series of checkboxes in the admin payment modal window
933
-     * which allows the admin to only apply the payment to the specific registrations
934
-     *
935
-     * @access protected
936
-     * @return void
937
-     * @throws \EE_Error
938
-     */
939
-    protected function _get_registrations_to_apply_payment_to()
940
-    {
941
-        // we want any registration with an active status (ie: not deleted or cancelled)
942
-        $query_params                      = array(
943
-            array(
944
-                'STS_ID' => array(
945
-                    'IN',
946
-                    array(
947
-                        EEM_Registration::status_id_approved,
948
-                        EEM_Registration::status_id_pending_payment,
949
-                        EEM_Registration::status_id_not_approved,
950
-                    )
951
-                )
952
-            )
953
-        );
954
-        $registrations_to_apply_payment_to = EEH_HTML::br() . EEH_HTML::div(
955
-                '', 'txn-admin-apply-payment-to-registrations-dv', '', 'clear: both; margin: 1.5em 0 0; display: none;'
956
-            );
957
-        $registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap');
958
-        $registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl');
959
-        $registrations_to_apply_payment_to .= EEH_HTML::thead(
960
-            EEH_HTML::tr(
961
-                EEH_HTML::th(esc_html__('ID', 'event_espresso')) .
962
-                EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) .
963
-                EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) .
964
-                EEH_HTML::th(esc_html__('Event', 'event_espresso')) .
965
-                EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') .
966
-                EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') .
967
-                EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr')
968
-            )
969
-        );
970
-        $registrations_to_apply_payment_to .= EEH_HTML::tbody();
971
-        // get registrations for TXN
972
-        $registrations = $this->_transaction->registrations($query_params);
973
-        foreach ($registrations as $registration) {
974
-            if ($registration instanceof EE_Registration) {
975
-                $attendee_name = $registration->attendee() instanceof EE_Attendee
976
-                    ? $registration->attendee()->full_name()
977
-                    : esc_html__('Unknown Attendee', 'event_espresso');
978
-                $owing         = $registration->final_price() - $registration->paid();
979
-                $taxable       = $registration->ticket()->taxable()
980
-                    ? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>'
981
-                    : '';
982
-                $checked       = empty($existing_reg_payments) || in_array($registration->ID(), $existing_reg_payments)
983
-                    ? ' checked="checked"'
984
-                    : '';
985
-                $disabled      = $registration->final_price() > 0 ? '' : ' disabled';
986
-                $registrations_to_apply_payment_to .= EEH_HTML::tr(
987
-                    EEH_HTML::td($registration->ID()) .
988
-                    EEH_HTML::td($attendee_name) .
989
-                    EEH_HTML::td(
990
-                        $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable
991
-                    ) .
992
-                    EEH_HTML::td($registration->event_name()) .
993
-                    EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') .
994
-                    EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr') .
995
-                    EEH_HTML::td(
996
-                        '<input type="checkbox" value="' . $registration->ID()
997
-                        . '" name="txn_admin_payment[registrations]"'
998
-                        . $checked . $disabled . '>',
999
-                        '', 'jst-cntr'
1000
-                    ),
1001
-                    'apply-payment-registration-row-' . $registration->ID()
1002
-                );
1003
-            }
1004
-        }
1005
-        $registrations_to_apply_payment_to .= EEH_HTML::tbodyx();
1006
-        $registrations_to_apply_payment_to .= EEH_HTML::tablex();
1007
-        $registrations_to_apply_payment_to .= EEH_HTML::divx();
1008
-        $registrations_to_apply_payment_to .= EEH_HTML::p(
1009
-            esc_html__(
1010
-                'The payment will only be applied to the registrations that have a check mark in their corresponding check box. Checkboxes for free registrations have been disabled.',
1011
-                'event_espresso'
1012
-            ),
1013
-            '', 'clear description'
1014
-        );
1015
-        $registrations_to_apply_payment_to .= EEH_HTML::divx();
1016
-        $this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to;
1017
-    }
1018
-    
1019
-    
1020
-    /**
1021
-     * _get_reg_status_selection
1022
-     *
1023
-     * @todo   this will need to be adjusted either once MER comes along OR we move default reg status to tickets
1024
-     *         instead of events.
1025
-     * @access protected
1026
-     * @return void
1027
-     */
1028
-    protected function _get_reg_status_selection()
1029
-    {
1030
-        //first get all possible statuses
1031
-        $statuses = EEM_Registration::reg_status_array(array(), true);
1032
-        //let's add a "don't change" option.
1033
-        $status_array['NAN']                                 = esc_html__('Leave the Same', 'event_espresso');
1034
-        $status_array                                        = array_merge($status_array, $statuses);
1035
-        $this->_template_args['status_change_select']        = EEH_Form_Fields::select_input('txn_reg_status_change[reg_status]',
1036
-            $status_array, 'NAN', 'id="txn-admin-payment-reg-status-inp"', 'txn-reg-status-change-reg-status');
1037
-        $this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input('delete_txn_reg_status_change[reg_status]',
1038
-            $status_array, 'NAN', 'delete-txn-admin-payment-reg-status-inp', 'delete-txn-reg-status-change-reg-status');
1039
-        
1040
-    }
1041
-    
1042
-    
1043
-    /**
1044
-     *    _get_payment_methods
1045
-     * Gets all the payment methods available generally, or the ones that are already
1046
-     * selected on these payments (in case their payment methods are no longer active).
1047
-     * Has the side-effect of updating the template args' payment_methods item
1048
-     * @access private
1049
-     *
1050
-     * @param EE_Payment[] to show on this page
1051
-     *
1052
-     * @return void
1053
-     */
1054
-    private function _get_payment_methods($payments = array())
1055
-    {
1056
-        $payment_methods_of_payments = array();
1057
-        foreach ($payments as $payment) {
1058
-            if ($payment instanceof EE_Payment) {
1059
-                $payment_methods_of_payments[] = $payment->get('PMD_ID');
1060
-            }
1061
-        }
1062
-        if ($payment_methods_of_payments) {
1063
-            $query_args = array(
1064
-                array(
1065
-                    'OR*payment_method_for_payment' => array(
1066
-                        'PMD_ID'    => array('IN', $payment_methods_of_payments),
1067
-                        'PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%')
1068
-                    )
1069
-                )
1070
-            );
1071
-        } else {
1072
-            $query_args = array(array('PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%')));
1073
-        }
1074
-        $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args);
1075
-    }
1076
-    
1077
-    
1078
-    /**
1079
-     * txn_attendees_meta_box
1080
-     *    generates HTML for the Attendees Transaction main meta box
1081
-     *
1082
-     * @access public
1083
-     *
1084
-     * @param WP_Post $post
1085
-     * @param array   $metabox
1086
-     *
1087
-     * @return void
1088
-     */
1089
-    public function txn_attendees_meta_box($post, $metabox = array('args' => array()))
1090
-    {
1091
-        
1092
-        extract($metabox['args']);
1093
-        $this->_template_args['post']            = $post;
1094
-        $this->_template_args['event_attendees'] = array();
1095
-        // process items in cart
1096
-        $line_items = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => 'line-item')));
1097
-        if ( ! empty($line_items)) {
1098
-            foreach ($line_items as $item) {
1099
-                if ($item instanceof EE_Line_Item) {
1100
-                    switch ($item->OBJ_type()) {
807
+		// process payment details
808
+		$payments = $this->_transaction->get_many_related('Payment');
809
+		if ( ! empty($payments)) {
810
+			$this->_template_args['payments']              = $payments;
811
+			$this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments);
812
+		} else {
813
+			$this->_template_args['payments']              = false;
814
+			$this->_template_args['existing_reg_payments'] = array();
815
+		}
816
+        
817
+		$this->_template_args['edit_payment_url']   = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL);
818
+		$this->_template_args['delete_payment_url'] = add_query_arg(array('action' => 'espresso_delete_payment'),
819
+			TXN_ADMIN_URL);
820
+        
821
+		if (isset($txn_details['invoice_number'])) {
822
+			$this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code'];
823
+			$this->_template_args['txn_details']['invoice_number']['label'] = esc_html__('Invoice Number',
824
+				'event_espresso');
825
+		}
826
+        
827
+		$this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction->get_first_related('Registration')->get('REG_session');
828
+		$this->_template_args['txn_details']['registration_session']['label'] = esc_html__('Registration Session',
829
+			'event_espresso');
830
+        
831
+		$this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '';
832
+		$this->_template_args['txn_details']['ip_address']['label'] = esc_html__('Transaction placed from IP',
833
+			'event_espresso');
834
+        
835
+		$this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '';
836
+		$this->_template_args['txn_details']['user_agent']['label'] = esc_html__('Registrant User Agent',
837
+			'event_espresso');
838
+        
839
+		$reg_steps = '<ul>';
840
+		foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) {
841
+			if ($reg_step_status === true) {
842
+				$reg_steps .= '<li style="color:#70cc50">' . sprintf(esc_html__('%1$s : Completed', 'event_espresso'),
843
+						ucwords(str_replace('_', ' ', $reg_step))) . '</li>';
844
+			} else if (is_numeric($reg_step_status) && $reg_step_status !== false) {
845
+				$reg_steps .= '<li style="color:#2EA2CC">' . sprintf(
846
+						esc_html__('%1$s : Initiated %2$s', 'event_espresso'),
847
+						ucwords(str_replace('_', ' ', $reg_step)),
848
+						date(get_option('date_format') . ' ' . get_option('time_format'),
849
+							($reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS)))
850
+					) . '</li>';
851
+			} else {
852
+				$reg_steps .= '<li style="color:#E76700">' . sprintf(esc_html__('%1$s : Never Initiated',
853
+						'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))) . '</li>';
854
+			}
855
+		}
856
+		$reg_steps .= '</ul>';
857
+		$this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps;
858
+		$this->_template_args['txn_details']['reg_steps']['label'] = esc_html__('Registration Step Progress',
859
+			'event_espresso');
860
+        
861
+        
862
+		$this->_get_registrations_to_apply_payment_to();
863
+		$this->_get_payment_methods($payments);
864
+		$this->_get_payment_status_array();
865
+		$this->_get_reg_status_selection(); //sets up the template args for the reg status array for the transaction.
866
+        
867
+		$this->_template_args['transaction_form_url']    = add_query_arg(array(
868
+			'action'  => 'edit_transaction',
869
+			'process' => 'transaction'
870
+		), TXN_ADMIN_URL);
871
+		$this->_template_args['apply_payment_form_url']  = add_query_arg(array(
872
+			'page'   => 'espresso_transactions',
873
+			'action' => 'espresso_apply_payment'
874
+		), WP_AJAX_URL);
875
+		$this->_template_args['delete_payment_form_url'] = add_query_arg(array(
876
+			'page'   => 'espresso_transactions',
877
+			'action' => 'espresso_delete_payment'
878
+		), WP_AJAX_URL);
879
+        
880
+		// 'espresso_delete_payment_nonce'
881
+        
882
+		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
883
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
884
+        
885
+	}
886
+    
887
+    
888
+	/**
889
+	 * _get_registration_payment_IDs
890
+	 *
891
+	 *    generates an array of Payment IDs and their corresponding Registration IDs
892
+	 *
893
+	 * @access protected
894
+	 *
895
+	 * @param EE_Payment[] $payments
896
+	 *
897
+	 * @return array
898
+	 */
899
+	protected function _get_registration_payment_IDs($payments = array())
900
+	{
901
+		$existing_reg_payments = array();
902
+		// get all reg payments for these payments
903
+		$reg_payments = EEM_Registration_Payment::instance()->get_all(array(
904
+			array(
905
+				'PAY_ID' => array(
906
+					'IN',
907
+					array_keys($payments)
908
+				)
909
+			)
910
+		));
911
+		if ( ! empty($reg_payments)) {
912
+			foreach ($payments as $payment) {
913
+				if ( ! $payment instanceof EE_Payment) {
914
+					continue;
915
+				} else if ( ! isset($existing_reg_payments[$payment->ID()])) {
916
+					$existing_reg_payments[$payment->ID()] = array();
917
+				}
918
+				foreach ($reg_payments as $reg_payment) {
919
+					if ($reg_payment instanceof EE_Registration_Payment && $reg_payment->payment_ID() === $payment->ID()) {
920
+						$existing_reg_payments[$payment->ID()][] = $reg_payment->registration_ID();
921
+					}
922
+				}
923
+			}
924
+		}
925
+        
926
+		return $existing_reg_payments;
927
+	}
928
+    
929
+    
930
+	/**
931
+	 * _get_registrations_to_apply_payment_to
932
+	 *    generates HTML for displaying a series of checkboxes in the admin payment modal window
933
+	 * which allows the admin to only apply the payment to the specific registrations
934
+	 *
935
+	 * @access protected
936
+	 * @return void
937
+	 * @throws \EE_Error
938
+	 */
939
+	protected function _get_registrations_to_apply_payment_to()
940
+	{
941
+		// we want any registration with an active status (ie: not deleted or cancelled)
942
+		$query_params                      = array(
943
+			array(
944
+				'STS_ID' => array(
945
+					'IN',
946
+					array(
947
+						EEM_Registration::status_id_approved,
948
+						EEM_Registration::status_id_pending_payment,
949
+						EEM_Registration::status_id_not_approved,
950
+					)
951
+				)
952
+			)
953
+		);
954
+		$registrations_to_apply_payment_to = EEH_HTML::br() . EEH_HTML::div(
955
+				'', 'txn-admin-apply-payment-to-registrations-dv', '', 'clear: both; margin: 1.5em 0 0; display: none;'
956
+			);
957
+		$registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap');
958
+		$registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl');
959
+		$registrations_to_apply_payment_to .= EEH_HTML::thead(
960
+			EEH_HTML::tr(
961
+				EEH_HTML::th(esc_html__('ID', 'event_espresso')) .
962
+				EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) .
963
+				EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) .
964
+				EEH_HTML::th(esc_html__('Event', 'event_espresso')) .
965
+				EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') .
966
+				EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') .
967
+				EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr')
968
+			)
969
+		);
970
+		$registrations_to_apply_payment_to .= EEH_HTML::tbody();
971
+		// get registrations for TXN
972
+		$registrations = $this->_transaction->registrations($query_params);
973
+		foreach ($registrations as $registration) {
974
+			if ($registration instanceof EE_Registration) {
975
+				$attendee_name = $registration->attendee() instanceof EE_Attendee
976
+					? $registration->attendee()->full_name()
977
+					: esc_html__('Unknown Attendee', 'event_espresso');
978
+				$owing         = $registration->final_price() - $registration->paid();
979
+				$taxable       = $registration->ticket()->taxable()
980
+					? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>'
981
+					: '';
982
+				$checked       = empty($existing_reg_payments) || in_array($registration->ID(), $existing_reg_payments)
983
+					? ' checked="checked"'
984
+					: '';
985
+				$disabled      = $registration->final_price() > 0 ? '' : ' disabled';
986
+				$registrations_to_apply_payment_to .= EEH_HTML::tr(
987
+					EEH_HTML::td($registration->ID()) .
988
+					EEH_HTML::td($attendee_name) .
989
+					EEH_HTML::td(
990
+						$registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable
991
+					) .
992
+					EEH_HTML::td($registration->event_name()) .
993
+					EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') .
994
+					EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr') .
995
+					EEH_HTML::td(
996
+						'<input type="checkbox" value="' . $registration->ID()
997
+						. '" name="txn_admin_payment[registrations]"'
998
+						. $checked . $disabled . '>',
999
+						'', 'jst-cntr'
1000
+					),
1001
+					'apply-payment-registration-row-' . $registration->ID()
1002
+				);
1003
+			}
1004
+		}
1005
+		$registrations_to_apply_payment_to .= EEH_HTML::tbodyx();
1006
+		$registrations_to_apply_payment_to .= EEH_HTML::tablex();
1007
+		$registrations_to_apply_payment_to .= EEH_HTML::divx();
1008
+		$registrations_to_apply_payment_to .= EEH_HTML::p(
1009
+			esc_html__(
1010
+				'The payment will only be applied to the registrations that have a check mark in their corresponding check box. Checkboxes for free registrations have been disabled.',
1011
+				'event_espresso'
1012
+			),
1013
+			'', 'clear description'
1014
+		);
1015
+		$registrations_to_apply_payment_to .= EEH_HTML::divx();
1016
+		$this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to;
1017
+	}
1018
+    
1019
+    
1020
+	/**
1021
+	 * _get_reg_status_selection
1022
+	 *
1023
+	 * @todo   this will need to be adjusted either once MER comes along OR we move default reg status to tickets
1024
+	 *         instead of events.
1025
+	 * @access protected
1026
+	 * @return void
1027
+	 */
1028
+	protected function _get_reg_status_selection()
1029
+	{
1030
+		//first get all possible statuses
1031
+		$statuses = EEM_Registration::reg_status_array(array(), true);
1032
+		//let's add a "don't change" option.
1033
+		$status_array['NAN']                                 = esc_html__('Leave the Same', 'event_espresso');
1034
+		$status_array                                        = array_merge($status_array, $statuses);
1035
+		$this->_template_args['status_change_select']        = EEH_Form_Fields::select_input('txn_reg_status_change[reg_status]',
1036
+			$status_array, 'NAN', 'id="txn-admin-payment-reg-status-inp"', 'txn-reg-status-change-reg-status');
1037
+		$this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input('delete_txn_reg_status_change[reg_status]',
1038
+			$status_array, 'NAN', 'delete-txn-admin-payment-reg-status-inp', 'delete-txn-reg-status-change-reg-status');
1039
+        
1040
+	}
1041
+    
1042
+    
1043
+	/**
1044
+	 *    _get_payment_methods
1045
+	 * Gets all the payment methods available generally, or the ones that are already
1046
+	 * selected on these payments (in case their payment methods are no longer active).
1047
+	 * Has the side-effect of updating the template args' payment_methods item
1048
+	 * @access private
1049
+	 *
1050
+	 * @param EE_Payment[] to show on this page
1051
+	 *
1052
+	 * @return void
1053
+	 */
1054
+	private function _get_payment_methods($payments = array())
1055
+	{
1056
+		$payment_methods_of_payments = array();
1057
+		foreach ($payments as $payment) {
1058
+			if ($payment instanceof EE_Payment) {
1059
+				$payment_methods_of_payments[] = $payment->get('PMD_ID');
1060
+			}
1061
+		}
1062
+		if ($payment_methods_of_payments) {
1063
+			$query_args = array(
1064
+				array(
1065
+					'OR*payment_method_for_payment' => array(
1066
+						'PMD_ID'    => array('IN', $payment_methods_of_payments),
1067
+						'PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%')
1068
+					)
1069
+				)
1070
+			);
1071
+		} else {
1072
+			$query_args = array(array('PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%')));
1073
+		}
1074
+		$this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args);
1075
+	}
1076
+    
1077
+    
1078
+	/**
1079
+	 * txn_attendees_meta_box
1080
+	 *    generates HTML for the Attendees Transaction main meta box
1081
+	 *
1082
+	 * @access public
1083
+	 *
1084
+	 * @param WP_Post $post
1085
+	 * @param array   $metabox
1086
+	 *
1087
+	 * @return void
1088
+	 */
1089
+	public function txn_attendees_meta_box($post, $metabox = array('args' => array()))
1090
+	{
1091
+        
1092
+		extract($metabox['args']);
1093
+		$this->_template_args['post']            = $post;
1094
+		$this->_template_args['event_attendees'] = array();
1095
+		// process items in cart
1096
+		$line_items = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => 'line-item')));
1097
+		if ( ! empty($line_items)) {
1098
+			foreach ($line_items as $item) {
1099
+				if ($item instanceof EE_Line_Item) {
1100
+					switch ($item->OBJ_type()) {
1101 1101
                         
1102
-                        case 'Event' :
1103
-                            break;
1102
+						case 'Event' :
1103
+							break;
1104 1104
                         
1105
-                        case 'Ticket' :
1106
-                            $ticket = $item->ticket();
1107
-                            //right now we're only handling tickets here.  Cause its expected that only tickets will have attendees right?
1108
-                            if ( ! $ticket instanceof EE_Ticket) {
1109
-                                continue;
1110
-                            }
1111
-                            try {
1112
-                                $event_name = $ticket->get_event_name();
1113
-                            } catch (Exception $e) {
1114
-                                EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1115
-                                $event_name = esc_html__('Unknown Event', 'event_espresso');
1116
-                            }
1117
-                            $event_name .= ' - ' . $item->get('LIN_name');
1118
-                            $ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price'));
1119
-                            // now get all of the registrations for this transaction that use this ticket
1120
-                            $registrations = $ticket->get_many_related('Registration',
1121
-                                array(array('TXN_ID' => $this->_transaction->ID())));
1122
-                            foreach ($registrations as $registration) {
1123
-                                if ( ! $registration instanceof EE_Registration) {
1124
-                                    continue;
1125
-                                }
1126
-                                $this->_template_args['event_attendees'][$registration->ID()]['STS_ID']            = $registration->status_ID();
1127
-                                $this->_template_args['event_attendees'][$registration->ID()]['att_num']           = $registration->count();
1128
-                                $this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] = $event_name;
1129
-                                $this->_template_args['event_attendees'][$registration->ID()]['ticket_price']      = $ticket_price;
1130
-                                // attendee info
1131
-                                $attendee = $registration->get_first_related('Attendee');
1132
-                                if ($attendee instanceof EE_Attendee) {
1133
-                                    $this->_template_args['event_attendees'][$registration->ID()]['att_id']   = $attendee->ID();
1134
-                                    $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = $attendee->full_name();
1135
-                                    $this->_template_args['event_attendees'][$registration->ID()]['email']    = '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name . esc_html__(' Event',
1136
-                                            'event_espresso') . '">' . $attendee->email() . '</a>';
1137
-                                    $this->_template_args['event_attendees'][$registration->ID()]['address']  = EEH_Address::format($attendee,
1138
-                                        'inline', false, false);
1139
-                                } else {
1140
-                                    $this->_template_args['event_attendees'][$registration->ID()]['att_id']   = '';
1141
-                                    $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = '';
1142
-                                    $this->_template_args['event_attendees'][$registration->ID()]['email']    = '';
1143
-                                    $this->_template_args['event_attendees'][$registration->ID()]['address']  = '';
1144
-                                }
1145
-                            }
1146
-                            break;
1105
+						case 'Ticket' :
1106
+							$ticket = $item->ticket();
1107
+							//right now we're only handling tickets here.  Cause its expected that only tickets will have attendees right?
1108
+							if ( ! $ticket instanceof EE_Ticket) {
1109
+								continue;
1110
+							}
1111
+							try {
1112
+								$event_name = $ticket->get_event_name();
1113
+							} catch (Exception $e) {
1114
+								EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1115
+								$event_name = esc_html__('Unknown Event', 'event_espresso');
1116
+							}
1117
+							$event_name .= ' - ' . $item->get('LIN_name');
1118
+							$ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price'));
1119
+							// now get all of the registrations for this transaction that use this ticket
1120
+							$registrations = $ticket->get_many_related('Registration',
1121
+								array(array('TXN_ID' => $this->_transaction->ID())));
1122
+							foreach ($registrations as $registration) {
1123
+								if ( ! $registration instanceof EE_Registration) {
1124
+									continue;
1125
+								}
1126
+								$this->_template_args['event_attendees'][$registration->ID()]['STS_ID']            = $registration->status_ID();
1127
+								$this->_template_args['event_attendees'][$registration->ID()]['att_num']           = $registration->count();
1128
+								$this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] = $event_name;
1129
+								$this->_template_args['event_attendees'][$registration->ID()]['ticket_price']      = $ticket_price;
1130
+								// attendee info
1131
+								$attendee = $registration->get_first_related('Attendee');
1132
+								if ($attendee instanceof EE_Attendee) {
1133
+									$this->_template_args['event_attendees'][$registration->ID()]['att_id']   = $attendee->ID();
1134
+									$this->_template_args['event_attendees'][$registration->ID()]['attendee'] = $attendee->full_name();
1135
+									$this->_template_args['event_attendees'][$registration->ID()]['email']    = '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name . esc_html__(' Event',
1136
+											'event_espresso') . '">' . $attendee->email() . '</a>';
1137
+									$this->_template_args['event_attendees'][$registration->ID()]['address']  = EEH_Address::format($attendee,
1138
+										'inline', false, false);
1139
+								} else {
1140
+									$this->_template_args['event_attendees'][$registration->ID()]['att_id']   = '';
1141
+									$this->_template_args['event_attendees'][$registration->ID()]['attendee'] = '';
1142
+									$this->_template_args['event_attendees'][$registration->ID()]['email']    = '';
1143
+									$this->_template_args['event_attendees'][$registration->ID()]['address']  = '';
1144
+								}
1145
+							}
1146
+							break;
1147 1147
                         
1148
-                    }
1149
-                }
1150
-            }
1148
+					}
1149
+				}
1150
+			}
1151 1151
             
1152
-            $this->_template_args['transaction_form_url'] = add_query_arg(array(
1153
-                'action'  => 'edit_transaction',
1154
-                'process' => 'attendees'
1155
-            ), TXN_ADMIN_URL);
1156
-            echo EEH_Template::display_template(TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php',
1157
-                $this->_template_args, true);
1152
+			$this->_template_args['transaction_form_url'] = add_query_arg(array(
1153
+				'action'  => 'edit_transaction',
1154
+				'process' => 'attendees'
1155
+			), TXN_ADMIN_URL);
1156
+			echo EEH_Template::display_template(TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php',
1157
+				$this->_template_args, true);
1158 1158
             
1159
-        } else {
1160
-            echo sprintf(
1161
-                esc_html__('%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s',
1162
-                    'event_espresso'),
1163
-                '<p class="important-notice">',
1164
-                '</p>'
1165
-            );
1166
-        }
1167
-    }
1168
-    
1169
-    
1170
-    /**
1171
-     * txn_registrant_side_meta_box
1172
-     * generates HTML for the Edit Transaction side meta box
1173
-     *
1174
-     * @access public
1175
-     * @throws \EE_Error
1176
-     * @return void
1177
-     */
1178
-    public function txn_registrant_side_meta_box()
1179
-    {
1180
-        $primary_att = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->get_first_related('Attendee') : null;
1181
-        if ( ! $primary_att instanceof EE_Attendee) {
1182
-            $this->_template_args['no_attendee_message'] = esc_html__('There is no attached contact for this transaction.  The transaction either failed due to an error or was abandoned.',
1183
-                'event_espresso');
1184
-            $primary_att                                 = EEM_Attendee::instance()->create_default_object();
1185
-        }
1186
-        $this->_template_args['ATT_ID']            = $primary_att->ID();
1187
-        $this->_template_args['prime_reg_fname']   = $primary_att->fname();
1188
-        $this->_template_args['prime_reg_lname']   = $primary_att->lname();
1189
-        $this->_template_args['prime_reg_email']   = $primary_att->email();
1190
-        $this->_template_args['prime_reg_phone']   = $primary_att->phone();
1191
-        $this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(array(
1192
-            'action' => 'edit_attendee',
1193
-            'post'   => $primary_att->ID()
1194
-        ), REG_ADMIN_URL);
1195
-        // get formatted address for registrant
1196
-        $this->_template_args['formatted_address'] = EEH_Address::format($primary_att);
1197
-        echo EEH_Template::display_template(TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php',
1198
-            $this->_template_args, true);
1199
-    }
1200
-    
1201
-    
1202
-    /**
1203
-     * txn_billing_info_side_meta_box
1204
-     *    generates HTML for the Edit Transaction side meta box
1205
-     *
1206
-     * @access public
1207
-     * @return void
1208
-     */
1209
-    public function txn_billing_info_side_meta_box()
1210
-    {
1211
-        
1212
-        $this->_template_args['billing_form']     = $this->_transaction->billing_info();
1213
-        $this->_template_args['billing_form_url'] = add_query_arg(
1214
-            array('action' => 'edit_transaction', 'process' => 'billing'),
1215
-            TXN_ADMIN_URL
1216
-        );
1217
-        
1218
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php';
1219
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);/**/
1220
-    }
1221
-    
1222
-    
1223
-    /**
1224
-     * apply_payments_or_refunds
1225
-     *    registers a payment or refund made towards a transaction
1226
-     *
1227
-     * @access public
1228
-     * @return void
1229
-     */
1230
-    public function apply_payments_or_refunds()
1231
-    {
1232
-        $json_response_data = array('return_data' => false);
1233
-        $valid_data         = $this->_validate_payment_request_data();
1234
-        if ( ! empty($valid_data)) {
1235
-            $PAY_ID = $valid_data['PAY_ID'];
1236
-            //save  the new payment
1237
-            $payment = $this->_create_payment_from_request_data($valid_data);
1238
-            // get the TXN for this payment
1239
-            $transaction = $payment->transaction();
1240
-            // verify transaction
1241
-            if ($transaction instanceof EE_Transaction) {
1242
-                // calculate_total_payments_and_update_status
1243
-                $this->_process_transaction_payments($transaction);
1244
-                $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment);
1245
-                $this->_remove_existing_registration_payments($payment, $PAY_ID);
1246
-                // apply payment to registrations (if applicable)
1247
-                if ( ! empty($REG_IDs)) {
1248
-                    $this->_update_registration_payments($transaction, $payment, $REG_IDs);
1249
-                    $this->_maybe_send_notifications();
1250
-                    // now process status changes for the same registrations
1251
-                    $this->_process_registration_status_change($transaction, $REG_IDs);
1252
-                }
1253
-                $this->_maybe_send_notifications($payment);
1254
-                //prepare to render page
1255
-                $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs);
1256
-                do_action('AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', $transaction,
1257
-                    $payment);
1258
-            } else {
1259
-                EE_Error::add_error(
1260
-                    esc_html__('A valid Transaction for this payment could not be retrieved.', 'event_espresso'),
1261
-                    __FILE__, __FUNCTION__, __LINE__
1262
-                );
1263
-            }
1264
-        } else {
1265
-            EE_Error::add_error(esc_html__('The payment form data could not be processed. Please try again.',
1266
-                'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1267
-        }
1268
-        
1269
-        $notices              = EE_Error::get_notices(false, false, false);
1270
-        $this->_template_args = array(
1271
-            'data'    => $json_response_data,
1272
-            'error'   => $notices['errors'],
1273
-            'success' => $notices['success']
1274
-        );
1275
-        $this->_return_json();
1276
-    }
1277
-    
1278
-    
1279
-    /**
1280
-     * _validate_payment_request_data
1281
-     *
1282
-     * @return array
1283
-     */
1284
-    protected function _validate_payment_request_data()
1285
-    {
1286
-        if ( ! isset($this->_req_data['txn_admin_payment'])) {
1287
-            return false;
1288
-        }
1289
-        $payment_form = $this->_generate_payment_form_section();
1290
-        try {
1291
-            if ($payment_form->was_submitted()) {
1292
-                $payment_form->receive_form_submission();
1293
-                if ( ! $payment_form->is_valid()) {
1294
-                    $submission_error_messages = array();
1295
-                    foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) {
1296
-                        if ($validation_error instanceof EE_Validation_Error) {
1297
-                            $submission_error_messages[] = sprintf(
1298
-                                _x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'),
1299
-                                $validation_error->get_form_section()->html_label_text(),
1300
-                                $validation_error->getMessage()
1301
-                            );
1302
-                        }
1303
-                    }
1304
-                    EE_Error::add_error(join('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__);
1159
+		} else {
1160
+			echo sprintf(
1161
+				esc_html__('%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s',
1162
+					'event_espresso'),
1163
+				'<p class="important-notice">',
1164
+				'</p>'
1165
+			);
1166
+		}
1167
+	}
1168
+    
1169
+    
1170
+	/**
1171
+	 * txn_registrant_side_meta_box
1172
+	 * generates HTML for the Edit Transaction side meta box
1173
+	 *
1174
+	 * @access public
1175
+	 * @throws \EE_Error
1176
+	 * @return void
1177
+	 */
1178
+	public function txn_registrant_side_meta_box()
1179
+	{
1180
+		$primary_att = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->get_first_related('Attendee') : null;
1181
+		if ( ! $primary_att instanceof EE_Attendee) {
1182
+			$this->_template_args['no_attendee_message'] = esc_html__('There is no attached contact for this transaction.  The transaction either failed due to an error or was abandoned.',
1183
+				'event_espresso');
1184
+			$primary_att                                 = EEM_Attendee::instance()->create_default_object();
1185
+		}
1186
+		$this->_template_args['ATT_ID']            = $primary_att->ID();
1187
+		$this->_template_args['prime_reg_fname']   = $primary_att->fname();
1188
+		$this->_template_args['prime_reg_lname']   = $primary_att->lname();
1189
+		$this->_template_args['prime_reg_email']   = $primary_att->email();
1190
+		$this->_template_args['prime_reg_phone']   = $primary_att->phone();
1191
+		$this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(array(
1192
+			'action' => 'edit_attendee',
1193
+			'post'   => $primary_att->ID()
1194
+		), REG_ADMIN_URL);
1195
+		// get formatted address for registrant
1196
+		$this->_template_args['formatted_address'] = EEH_Address::format($primary_att);
1197
+		echo EEH_Template::display_template(TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php',
1198
+			$this->_template_args, true);
1199
+	}
1200
+    
1201
+    
1202
+	/**
1203
+	 * txn_billing_info_side_meta_box
1204
+	 *    generates HTML for the Edit Transaction side meta box
1205
+	 *
1206
+	 * @access public
1207
+	 * @return void
1208
+	 */
1209
+	public function txn_billing_info_side_meta_box()
1210
+	{
1211
+        
1212
+		$this->_template_args['billing_form']     = $this->_transaction->billing_info();
1213
+		$this->_template_args['billing_form_url'] = add_query_arg(
1214
+			array('action' => 'edit_transaction', 'process' => 'billing'),
1215
+			TXN_ADMIN_URL
1216
+		);
1217
+        
1218
+		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php';
1219
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);/**/
1220
+	}
1221
+    
1222
+    
1223
+	/**
1224
+	 * apply_payments_or_refunds
1225
+	 *    registers a payment or refund made towards a transaction
1226
+	 *
1227
+	 * @access public
1228
+	 * @return void
1229
+	 */
1230
+	public function apply_payments_or_refunds()
1231
+	{
1232
+		$json_response_data = array('return_data' => false);
1233
+		$valid_data         = $this->_validate_payment_request_data();
1234
+		if ( ! empty($valid_data)) {
1235
+			$PAY_ID = $valid_data['PAY_ID'];
1236
+			//save  the new payment
1237
+			$payment = $this->_create_payment_from_request_data($valid_data);
1238
+			// get the TXN for this payment
1239
+			$transaction = $payment->transaction();
1240
+			// verify transaction
1241
+			if ($transaction instanceof EE_Transaction) {
1242
+				// calculate_total_payments_and_update_status
1243
+				$this->_process_transaction_payments($transaction);
1244
+				$REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment);
1245
+				$this->_remove_existing_registration_payments($payment, $PAY_ID);
1246
+				// apply payment to registrations (if applicable)
1247
+				if ( ! empty($REG_IDs)) {
1248
+					$this->_update_registration_payments($transaction, $payment, $REG_IDs);
1249
+					$this->_maybe_send_notifications();
1250
+					// now process status changes for the same registrations
1251
+					$this->_process_registration_status_change($transaction, $REG_IDs);
1252
+				}
1253
+				$this->_maybe_send_notifications($payment);
1254
+				//prepare to render page
1255
+				$json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs);
1256
+				do_action('AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', $transaction,
1257
+					$payment);
1258
+			} else {
1259
+				EE_Error::add_error(
1260
+					esc_html__('A valid Transaction for this payment could not be retrieved.', 'event_espresso'),
1261
+					__FILE__, __FUNCTION__, __LINE__
1262
+				);
1263
+			}
1264
+		} else {
1265
+			EE_Error::add_error(esc_html__('The payment form data could not be processed. Please try again.',
1266
+				'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1267
+		}
1268
+        
1269
+		$notices              = EE_Error::get_notices(false, false, false);
1270
+		$this->_template_args = array(
1271
+			'data'    => $json_response_data,
1272
+			'error'   => $notices['errors'],
1273
+			'success' => $notices['success']
1274
+		);
1275
+		$this->_return_json();
1276
+	}
1277
+    
1278
+    
1279
+	/**
1280
+	 * _validate_payment_request_data
1281
+	 *
1282
+	 * @return array
1283
+	 */
1284
+	protected function _validate_payment_request_data()
1285
+	{
1286
+		if ( ! isset($this->_req_data['txn_admin_payment'])) {
1287
+			return false;
1288
+		}
1289
+		$payment_form = $this->_generate_payment_form_section();
1290
+		try {
1291
+			if ($payment_form->was_submitted()) {
1292
+				$payment_form->receive_form_submission();
1293
+				if ( ! $payment_form->is_valid()) {
1294
+					$submission_error_messages = array();
1295
+					foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) {
1296
+						if ($validation_error instanceof EE_Validation_Error) {
1297
+							$submission_error_messages[] = sprintf(
1298
+								_x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'),
1299
+								$validation_error->get_form_section()->html_label_text(),
1300
+								$validation_error->getMessage()
1301
+							);
1302
+						}
1303
+					}
1304
+					EE_Error::add_error(join('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__);
1305 1305
                     
1306
-                    return array();
1307
-                }
1308
-            }
1309
-        } catch (EE_Error $e) {
1310
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1306
+					return array();
1307
+				}
1308
+			}
1309
+		} catch (EE_Error $e) {
1310
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1311 1311
             
1312
-            return array();
1313
-        }
1314
-        
1315
-        return $payment_form->valid_data();
1316
-    }
1317
-    
1318
-    
1319
-    /**
1320
-     * _generate_payment_form_section
1321
-     *
1322
-     * @return EE_Form_Section_Proper
1323
-     */
1324
-    protected function _generate_payment_form_section()
1325
-    {
1326
-        return new EE_Form_Section_Proper(
1327
-            array(
1328
-                'name'        => 'txn_admin_payment',
1329
-                'subsections' => array(
1330
-                    'PAY_ID'          => new EE_Text_Input(
1331
-                        array(
1332
-                            'default'               => 0,
1333
-                            'required'              => false,
1334
-                            'html_label_text'       => esc_html__('Payment ID', 'event_espresso'),
1335
-                            'validation_strategies' => array(new EE_Int_Normalization())
1336
-                        )
1337
-                    ),
1338
-                    'TXN_ID'          => new EE_Text_Input(
1339
-                        array(
1340
-                            'default'               => 0,
1341
-                            'required'              => true,
1342
-                            'html_label_text'       => esc_html__('Transaction ID', 'event_espresso'),
1343
-                            'validation_strategies' => array(new EE_Int_Normalization())
1344
-                        )
1345
-                    ),
1346
-                    'type'            => new EE_Text_Input(
1347
-                        array(
1348
-                            'default'               => 1,
1349
-                            'required'              => true,
1350
-                            'html_label_text'       => esc_html__('Payment or Refund', 'event_espresso'),
1351
-                            'validation_strategies' => array(new EE_Int_Normalization())
1352
-                        )
1353
-                    ),
1354
-                    'amount'          => new EE_Text_Input(
1355
-                        array(
1356
-                            'default'               => 0,
1357
-                            'required'              => true,
1358
-                            'html_label_text'       => esc_html__('Payment amount', 'event_espresso'),
1359
-                            'validation_strategies' => array(new EE_Float_Normalization())
1360
-                        )
1361
-                    ),
1362
-                    'status'          => new EE_Text_Input(
1363
-                        array(
1364
-                            'default'         => EEM_Payment::status_id_approved,
1365
-                            'required'        => true,
1366
-                            'html_label_text' => esc_html__('Payment status', 'event_espresso'),
1367
-                        )
1368
-                    ),
1369
-                    'PMD_ID'          => new EE_Text_Input(
1370
-                        array(
1371
-                            'default'               => 2,
1372
-                            'required'              => true,
1373
-                            'html_label_text'       => esc_html__('Payment Method', 'event_espresso'),
1374
-                            'validation_strategies' => array(new EE_Int_Normalization())
1375
-                        )
1376
-                    ),
1377
-                    'date'            => new EE_Text_Input(
1378
-                        array(
1379
-                            'default'         => time(),
1380
-                            'required'        => true,
1381
-                            'html_label_text' => esc_html__('Payment date', 'event_espresso'),
1382
-                        )
1383
-                    ),
1384
-                    'txn_id_chq_nmbr' => new EE_Text_Input(
1385
-                        array(
1386
-                            'default'               => '',
1387
-                            'required'              => false,
1388
-                            'html_label_text'       => esc_html__('Transaction or Cheque Number', 'event_espresso'),
1389
-                            'validation_strategies' => array(
1390
-                                new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'),
1391
-                                    100),
1392
-                            )
1393
-                        )
1394
-                    ),
1395
-                    'po_number'       => new EE_Text_Input(
1396
-                        array(
1397
-                            'default'               => '',
1398
-                            'required'              => false,
1399
-                            'html_label_text'       => esc_html__('Purchase Order Number', 'event_espresso'),
1400
-                            'validation_strategies' => array(
1401
-                                new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'),
1402
-                                    100),
1403
-                            )
1404
-                        )
1405
-                    ),
1406
-                    'accounting'      => new EE_Text_Input(
1407
-                        array(
1408
-                            'default'               => '',
1409
-                            'required'              => false,
1410
-                            'html_label_text'       => esc_html__('Extra Field for Accounting', 'event_espresso'),
1411
-                            'validation_strategies' => array(
1412
-                                new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'),
1413
-                                    100),
1414
-                            )
1415
-                        )
1416
-                    ),
1417
-                )
1418
-            )
1419
-        );
1420
-    }
1421
-    
1422
-    
1423
-    /**
1424
-     * _create_payment_from_request_data
1425
-     *
1426
-     * @param array $valid_data
1427
-     *
1428
-     * @return EE_Payment
1429
-     */
1430
-    protected function _create_payment_from_request_data($valid_data)
1431
-    {
1432
-        $PAY_ID = $valid_data['PAY_ID'];
1433
-        // get payment amount
1434
-        $amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0;
1435
-        // payments have a type value of 1 and refunds have a type value of -1
1436
-        // so multiplying amount by type will give a positive value for payments, and negative values for refunds
1437
-        $amount = $valid_data['type'] < 0 ? $amount * -1 : $amount;
1438
-        // for some reason the date string coming in has extra spaces between the date and time.  This fixes that.
1439
-        $date    = $valid_data['date'] ? preg_replace('/\s+/', ' ', $valid_data['date']) : date('Y-m-d g:i a',
1440
-            current_time('timestamp'));
1441
-        $payment = EE_Payment::new_instance(
1442
-            array(
1443
-                'TXN_ID'              => $valid_data['TXN_ID'],
1444
-                'STS_ID'              => $valid_data['status'],
1445
-                'PAY_timestamp'       => $date,
1446
-                'PAY_source'          => EEM_Payment_Method::scope_admin,
1447
-                'PMD_ID'              => $valid_data['PMD_ID'],
1448
-                'PAY_amount'          => $amount,
1449
-                'PAY_txn_id_chq_nmbr' => $valid_data['txn_id_chq_nmbr'],
1450
-                'PAY_po_number'       => $valid_data['po_number'],
1451
-                'PAY_extra_accntng'   => $valid_data['accounting'],
1452
-                'PAY_details'         => $valid_data,
1453
-                'PAY_ID'              => $PAY_ID
1454
-            ),
1455
-            '',
1456
-            array('Y-m-d', 'g:i a')
1457
-        );
1458
-        
1459
-        if ( ! $payment->save()) {
1460
-            EE_Error::add_error(
1461
-                sprintf(
1462
-                    esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'),
1463
-                    $payment->ID()
1464
-                ),
1465
-                __FILE__, __FUNCTION__, __LINE__
1466
-            );
1467
-        }
1468
-        
1469
-        return $payment;
1470
-    }
1471
-    
1472
-    
1473
-    /**
1474
-     * _process_transaction_payments
1475
-     *
1476
-     * @param \EE_Transaction $transaction
1477
-     *
1478
-     * @return array
1479
-     */
1480
-    protected function _process_transaction_payments(EE_Transaction $transaction)
1481
-    {
1482
-        /** @type EE_Transaction_Payments $transaction_payments */
1483
-        $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1484
-        //update the transaction with this payment
1485
-        if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) {
1486
-            EE_Error::add_success(esc_html__('The payment has been processed successfully.', 'event_espresso'),
1487
-                __FILE__, __FUNCTION__, __LINE__);
1488
-        } else {
1489
-            EE_Error::add_error(
1490
-                esc_html__('The payment was processed successfully but the amount paid for the transaction was not updated.',
1491
-                    'event_espresso')
1492
-                , __FILE__, __FUNCTION__, __LINE__
1493
-            );
1494
-        }
1495
-    }
1496
-    
1497
-    
1498
-    /**
1499
-     * _get_REG_IDs_to_apply_payment_to
1500
-     *
1501
-     * returns a list of registration IDs that the payment will apply to
1502
-     *
1503
-     * @param \EE_Payment $payment
1504
-     *
1505
-     * @return array
1506
-     */
1507
-    protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment)
1508
-    {
1509
-        $REG_IDs = array();
1510
-        // grab array of IDs for specific registrations to apply changes to
1511
-        if (isset($this->_req_data['txn_admin_payment']['registrations'])) {
1512
-            $REG_IDs = (array)$this->_req_data['txn_admin_payment']['registrations'];
1513
-        }
1514
-        //nothing specified ? then get all reg IDs
1515
-        if (empty($REG_IDs)) {
1516
-            $registrations = $payment->transaction()->registrations();
1517
-            $REG_IDs       = ! empty($registrations) ? array_keys($registrations) : $this->_get_existing_reg_payment_REG_IDs($payment);
1518
-        }
1519
-        
1520
-        // ensure that REG_IDs are integers and NOT strings
1521
-        return array_map('intval', $REG_IDs);
1522
-    }
1523
-    
1524
-    
1525
-    /**
1526
-     * @return array
1527
-     */
1528
-    public function existing_reg_payment_REG_IDs()
1529
-    {
1530
-        return $this->_existing_reg_payment_REG_IDs;
1531
-    }
1532
-    
1533
-    
1534
-    /**
1535
-     * @param array $existing_reg_payment_REG_IDs
1536
-     */
1537
-    public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null)
1538
-    {
1539
-        $this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs;
1540
-    }
1541
-    
1542
-    
1543
-    /**
1544
-     * _get_existing_reg_payment_REG_IDs
1545
-     *
1546
-     * returns a list of registration IDs that the payment is currently related to
1547
-     * as recorded in the database
1548
-     *
1549
-     * @param \EE_Payment $payment
1550
-     *
1551
-     * @return array
1552
-     */
1553
-    protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment)
1554
-    {
1555
-        if ($this->existing_reg_payment_REG_IDs() === null) {
1556
-            // let's get any existing reg payment records for this payment
1557
-            $existing_reg_payment_REG_IDs = $payment->get_many_related('Registration');
1558
-            // but we only want the REG IDs, so grab the array keys
1559
-            $existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs) ? array_keys($existing_reg_payment_REG_IDs) : array();
1560
-            $this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs);
1561
-        }
1562
-        
1563
-        return $this->existing_reg_payment_REG_IDs();
1564
-    }
1565
-    
1566
-    
1567
-    /**
1568
-     * _remove_existing_registration_payments
1569
-     *
1570
-     * this calculates the difference between existing relations
1571
-     * to the supplied payment and the new list registration IDs,
1572
-     * removes any related registrations that no longer apply,
1573
-     * and then updates the registration paid fields
1574
-     *
1575
-     * @param \EE_Payment $payment
1576
-     * @param int         $PAY_ID
1577
-     *
1578
-     * @return bool;
1579
-     */
1580
-    protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0)
1581
-    {
1582
-        // newly created payments will have nothing recorded for $PAY_ID
1583
-        if ($PAY_ID == 0) {
1584
-            return false;
1585
-        }
1586
-        $existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
1587
-        if (empty($existing_reg_payment_REG_IDs)) {
1588
-            return false;
1589
-        }
1590
-        /** @type EE_Transaction_Payments $transaction_payments */
1591
-        $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1592
-        
1593
-        return $transaction_payments->delete_registration_payments_and_update_registrations(
1594
-            $payment,
1595
-            array(
1596
-                array(
1597
-                    'PAY_ID' => $payment->ID(),
1598
-                    'REG_ID' => array('IN', $existing_reg_payment_REG_IDs),
1599
-                )
1600
-            )
1601
-        );
1602
-    }
1603
-    
1604
-    
1605
-    /**
1606
-     * _update_registration_payments
1607
-     *
1608
-     * this applies the payments to the selected registrations
1609
-     * but only if they have not already been paid for
1610
-     *
1611
-     * @param  EE_Transaction $transaction
1612
-     * @param \EE_Payment     $payment
1613
-     * @param array           $REG_IDs
1614
-     *
1615
-     * @return bool
1616
-     */
1617
-    protected function _update_registration_payments(
1618
-        EE_Transaction $transaction,
1619
-        EE_Payment $payment,
1620
-        $REG_IDs = array()
1621
-    ) {
1622
-        // we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments()
1623
-        // so let's do that using our set of REG_IDs from the form
1624
-        $registration_query_where_params = array(
1625
-            'REG_ID' => array('IN', $REG_IDs)
1626
-        );
1627
-        // but add in some conditions regarding payment,
1628
-        // so that we don't apply payments to registrations that are free or have already been paid for
1629
-        // but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative )
1630
-        if ( ! $payment->is_a_refund()) {
1631
-            $registration_query_where_params['REG_final_price']  = array('!=', 0);
1632
-            $registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true);
1633
-        }
1634
-        //EEH_Debug_Tools::printr( $registration_query_where_params, '$registration_query_where_params', __FILE__, __LINE__ );
1635
-        $registrations = $transaction->registrations(array($registration_query_where_params));
1636
-        if ( ! empty($registrations)) {
1637
-            /** @type EE_Payment_Processor $payment_processor */
1638
-            $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
1639
-            $payment_processor->process_registration_payments($transaction, $payment, $registrations);
1640
-        }
1641
-    }
1642
-    
1643
-    
1644
-    /**
1645
-     * _process_registration_status_change
1646
-     *
1647
-     * This processes requested registration status changes for all the registrations
1648
-     * on a given transaction and (optionally) sends out notifications for the changes.
1649
-     *
1650
-     * @param  EE_Transaction $transaction
1651
-     * @param array           $REG_IDs
1652
-     *
1653
-     * @return bool
1654
-     */
1655
-    protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array())
1656
-    {
1657
-        // first if there is no change in status then we get out.
1658
-        if (
1659
-            ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['reg_status'])
1660
-            || $this->_req_data['txn_reg_status_change']['reg_status'] == 'NAN'
1661
-        ) {
1662
-            //no error message, no change requested, just nothing to do man.
1663
-            return false;
1664
-        }
1665
-        /** @type EE_Transaction_Processor $transaction_processor */
1666
-        $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1667
-        
1668
-        // made it here dude?  Oh WOW.  K, let's take care of changing the statuses
1669
-        return $transaction_processor->manually_update_registration_statuses(
1670
-            $transaction,
1671
-            sanitize_text_field($this->_req_data['txn_reg_status_change']['reg_status']),
1672
-            array(array('REG_ID' => array('IN', $REG_IDs)))
1673
-        );
1674
-    }
1675
-    
1676
-    
1677
-    /**
1678
-     * _build_payment_json_response
1679
-     *
1680
-     * @access public
1681
-     *
1682
-     * @param \EE_Payment $payment
1683
-     * @param array       $REG_IDs
1684
-     * @param bool | null $delete_txn_reg_status_change
1685
-     *
1686
-     * @return array
1687
-     */
1688
-    protected function _build_payment_json_response(
1689
-        EE_Payment $payment,
1690
-        $REG_IDs = array(),
1691
-        $delete_txn_reg_status_change = null
1692
-    ) {
1693
-        // was the payment deleted ?
1694
-        if (is_bool($delete_txn_reg_status_change)) {
1695
-            return array(
1696
-                'PAY_ID'                       => $payment->ID(),
1697
-                'amount'                       => $payment->amount(),
1698
-                'total_paid'                   => $payment->transaction()->paid(),
1699
-                'txn_status'                   => $payment->transaction()->status_ID(),
1700
-                'pay_status'                   => $payment->STS_ID(),
1701
-                'registrations'                => $this->_registration_payment_data_array($REG_IDs),
1702
-                'delete_txn_reg_status_change' => $delete_txn_reg_status_change,
1703
-            );
1704
-        } else {
1705
-            $this->_get_payment_status_array();
1312
+			return array();
1313
+		}
1314
+        
1315
+		return $payment_form->valid_data();
1316
+	}
1317
+    
1318
+    
1319
+	/**
1320
+	 * _generate_payment_form_section
1321
+	 *
1322
+	 * @return EE_Form_Section_Proper
1323
+	 */
1324
+	protected function _generate_payment_form_section()
1325
+	{
1326
+		return new EE_Form_Section_Proper(
1327
+			array(
1328
+				'name'        => 'txn_admin_payment',
1329
+				'subsections' => array(
1330
+					'PAY_ID'          => new EE_Text_Input(
1331
+						array(
1332
+							'default'               => 0,
1333
+							'required'              => false,
1334
+							'html_label_text'       => esc_html__('Payment ID', 'event_espresso'),
1335
+							'validation_strategies' => array(new EE_Int_Normalization())
1336
+						)
1337
+					),
1338
+					'TXN_ID'          => new EE_Text_Input(
1339
+						array(
1340
+							'default'               => 0,
1341
+							'required'              => true,
1342
+							'html_label_text'       => esc_html__('Transaction ID', 'event_espresso'),
1343
+							'validation_strategies' => array(new EE_Int_Normalization())
1344
+						)
1345
+					),
1346
+					'type'            => new EE_Text_Input(
1347
+						array(
1348
+							'default'               => 1,
1349
+							'required'              => true,
1350
+							'html_label_text'       => esc_html__('Payment or Refund', 'event_espresso'),
1351
+							'validation_strategies' => array(new EE_Int_Normalization())
1352
+						)
1353
+					),
1354
+					'amount'          => new EE_Text_Input(
1355
+						array(
1356
+							'default'               => 0,
1357
+							'required'              => true,
1358
+							'html_label_text'       => esc_html__('Payment amount', 'event_espresso'),
1359
+							'validation_strategies' => array(new EE_Float_Normalization())
1360
+						)
1361
+					),
1362
+					'status'          => new EE_Text_Input(
1363
+						array(
1364
+							'default'         => EEM_Payment::status_id_approved,
1365
+							'required'        => true,
1366
+							'html_label_text' => esc_html__('Payment status', 'event_espresso'),
1367
+						)
1368
+					),
1369
+					'PMD_ID'          => new EE_Text_Input(
1370
+						array(
1371
+							'default'               => 2,
1372
+							'required'              => true,
1373
+							'html_label_text'       => esc_html__('Payment Method', 'event_espresso'),
1374
+							'validation_strategies' => array(new EE_Int_Normalization())
1375
+						)
1376
+					),
1377
+					'date'            => new EE_Text_Input(
1378
+						array(
1379
+							'default'         => time(),
1380
+							'required'        => true,
1381
+							'html_label_text' => esc_html__('Payment date', 'event_espresso'),
1382
+						)
1383
+					),
1384
+					'txn_id_chq_nmbr' => new EE_Text_Input(
1385
+						array(
1386
+							'default'               => '',
1387
+							'required'              => false,
1388
+							'html_label_text'       => esc_html__('Transaction or Cheque Number', 'event_espresso'),
1389
+							'validation_strategies' => array(
1390
+								new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'),
1391
+									100),
1392
+							)
1393
+						)
1394
+					),
1395
+					'po_number'       => new EE_Text_Input(
1396
+						array(
1397
+							'default'               => '',
1398
+							'required'              => false,
1399
+							'html_label_text'       => esc_html__('Purchase Order Number', 'event_espresso'),
1400
+							'validation_strategies' => array(
1401
+								new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'),
1402
+									100),
1403
+							)
1404
+						)
1405
+					),
1406
+					'accounting'      => new EE_Text_Input(
1407
+						array(
1408
+							'default'               => '',
1409
+							'required'              => false,
1410
+							'html_label_text'       => esc_html__('Extra Field for Accounting', 'event_espresso'),
1411
+							'validation_strategies' => array(
1412
+								new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'),
1413
+									100),
1414
+							)
1415
+						)
1416
+					),
1417
+				)
1418
+			)
1419
+		);
1420
+	}
1421
+    
1422
+    
1423
+	/**
1424
+	 * _create_payment_from_request_data
1425
+	 *
1426
+	 * @param array $valid_data
1427
+	 *
1428
+	 * @return EE_Payment
1429
+	 */
1430
+	protected function _create_payment_from_request_data($valid_data)
1431
+	{
1432
+		$PAY_ID = $valid_data['PAY_ID'];
1433
+		// get payment amount
1434
+		$amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0;
1435
+		// payments have a type value of 1 and refunds have a type value of -1
1436
+		// so multiplying amount by type will give a positive value for payments, and negative values for refunds
1437
+		$amount = $valid_data['type'] < 0 ? $amount * -1 : $amount;
1438
+		// for some reason the date string coming in has extra spaces between the date and time.  This fixes that.
1439
+		$date    = $valid_data['date'] ? preg_replace('/\s+/', ' ', $valid_data['date']) : date('Y-m-d g:i a',
1440
+			current_time('timestamp'));
1441
+		$payment = EE_Payment::new_instance(
1442
+			array(
1443
+				'TXN_ID'              => $valid_data['TXN_ID'],
1444
+				'STS_ID'              => $valid_data['status'],
1445
+				'PAY_timestamp'       => $date,
1446
+				'PAY_source'          => EEM_Payment_Method::scope_admin,
1447
+				'PMD_ID'              => $valid_data['PMD_ID'],
1448
+				'PAY_amount'          => $amount,
1449
+				'PAY_txn_id_chq_nmbr' => $valid_data['txn_id_chq_nmbr'],
1450
+				'PAY_po_number'       => $valid_data['po_number'],
1451
+				'PAY_extra_accntng'   => $valid_data['accounting'],
1452
+				'PAY_details'         => $valid_data,
1453
+				'PAY_ID'              => $PAY_ID
1454
+			),
1455
+			'',
1456
+			array('Y-m-d', 'g:i a')
1457
+		);
1458
+        
1459
+		if ( ! $payment->save()) {
1460
+			EE_Error::add_error(
1461
+				sprintf(
1462
+					esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'),
1463
+					$payment->ID()
1464
+				),
1465
+				__FILE__, __FUNCTION__, __LINE__
1466
+			);
1467
+		}
1468
+        
1469
+		return $payment;
1470
+	}
1471
+    
1472
+    
1473
+	/**
1474
+	 * _process_transaction_payments
1475
+	 *
1476
+	 * @param \EE_Transaction $transaction
1477
+	 *
1478
+	 * @return array
1479
+	 */
1480
+	protected function _process_transaction_payments(EE_Transaction $transaction)
1481
+	{
1482
+		/** @type EE_Transaction_Payments $transaction_payments */
1483
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1484
+		//update the transaction with this payment
1485
+		if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) {
1486
+			EE_Error::add_success(esc_html__('The payment has been processed successfully.', 'event_espresso'),
1487
+				__FILE__, __FUNCTION__, __LINE__);
1488
+		} else {
1489
+			EE_Error::add_error(
1490
+				esc_html__('The payment was processed successfully but the amount paid for the transaction was not updated.',
1491
+					'event_espresso')
1492
+				, __FILE__, __FUNCTION__, __LINE__
1493
+			);
1494
+		}
1495
+	}
1496
+    
1497
+    
1498
+	/**
1499
+	 * _get_REG_IDs_to_apply_payment_to
1500
+	 *
1501
+	 * returns a list of registration IDs that the payment will apply to
1502
+	 *
1503
+	 * @param \EE_Payment $payment
1504
+	 *
1505
+	 * @return array
1506
+	 */
1507
+	protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment)
1508
+	{
1509
+		$REG_IDs = array();
1510
+		// grab array of IDs for specific registrations to apply changes to
1511
+		if (isset($this->_req_data['txn_admin_payment']['registrations'])) {
1512
+			$REG_IDs = (array)$this->_req_data['txn_admin_payment']['registrations'];
1513
+		}
1514
+		//nothing specified ? then get all reg IDs
1515
+		if (empty($REG_IDs)) {
1516
+			$registrations = $payment->transaction()->registrations();
1517
+			$REG_IDs       = ! empty($registrations) ? array_keys($registrations) : $this->_get_existing_reg_payment_REG_IDs($payment);
1518
+		}
1519
+        
1520
+		// ensure that REG_IDs are integers and NOT strings
1521
+		return array_map('intval', $REG_IDs);
1522
+	}
1523
+    
1524
+    
1525
+	/**
1526
+	 * @return array
1527
+	 */
1528
+	public function existing_reg_payment_REG_IDs()
1529
+	{
1530
+		return $this->_existing_reg_payment_REG_IDs;
1531
+	}
1532
+    
1533
+    
1534
+	/**
1535
+	 * @param array $existing_reg_payment_REG_IDs
1536
+	 */
1537
+	public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null)
1538
+	{
1539
+		$this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs;
1540
+	}
1541
+    
1542
+    
1543
+	/**
1544
+	 * _get_existing_reg_payment_REG_IDs
1545
+	 *
1546
+	 * returns a list of registration IDs that the payment is currently related to
1547
+	 * as recorded in the database
1548
+	 *
1549
+	 * @param \EE_Payment $payment
1550
+	 *
1551
+	 * @return array
1552
+	 */
1553
+	protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment)
1554
+	{
1555
+		if ($this->existing_reg_payment_REG_IDs() === null) {
1556
+			// let's get any existing reg payment records for this payment
1557
+			$existing_reg_payment_REG_IDs = $payment->get_many_related('Registration');
1558
+			// but we only want the REG IDs, so grab the array keys
1559
+			$existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs) ? array_keys($existing_reg_payment_REG_IDs) : array();
1560
+			$this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs);
1561
+		}
1562
+        
1563
+		return $this->existing_reg_payment_REG_IDs();
1564
+	}
1565
+    
1566
+    
1567
+	/**
1568
+	 * _remove_existing_registration_payments
1569
+	 *
1570
+	 * this calculates the difference between existing relations
1571
+	 * to the supplied payment and the new list registration IDs,
1572
+	 * removes any related registrations that no longer apply,
1573
+	 * and then updates the registration paid fields
1574
+	 *
1575
+	 * @param \EE_Payment $payment
1576
+	 * @param int         $PAY_ID
1577
+	 *
1578
+	 * @return bool;
1579
+	 */
1580
+	protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0)
1581
+	{
1582
+		// newly created payments will have nothing recorded for $PAY_ID
1583
+		if ($PAY_ID == 0) {
1584
+			return false;
1585
+		}
1586
+		$existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
1587
+		if (empty($existing_reg_payment_REG_IDs)) {
1588
+			return false;
1589
+		}
1590
+		/** @type EE_Transaction_Payments $transaction_payments */
1591
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1592
+        
1593
+		return $transaction_payments->delete_registration_payments_and_update_registrations(
1594
+			$payment,
1595
+			array(
1596
+				array(
1597
+					'PAY_ID' => $payment->ID(),
1598
+					'REG_ID' => array('IN', $existing_reg_payment_REG_IDs),
1599
+				)
1600
+			)
1601
+		);
1602
+	}
1603
+    
1604
+    
1605
+	/**
1606
+	 * _update_registration_payments
1607
+	 *
1608
+	 * this applies the payments to the selected registrations
1609
+	 * but only if they have not already been paid for
1610
+	 *
1611
+	 * @param  EE_Transaction $transaction
1612
+	 * @param \EE_Payment     $payment
1613
+	 * @param array           $REG_IDs
1614
+	 *
1615
+	 * @return bool
1616
+	 */
1617
+	protected function _update_registration_payments(
1618
+		EE_Transaction $transaction,
1619
+		EE_Payment $payment,
1620
+		$REG_IDs = array()
1621
+	) {
1622
+		// we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments()
1623
+		// so let's do that using our set of REG_IDs from the form
1624
+		$registration_query_where_params = array(
1625
+			'REG_ID' => array('IN', $REG_IDs)
1626
+		);
1627
+		// but add in some conditions regarding payment,
1628
+		// so that we don't apply payments to registrations that are free or have already been paid for
1629
+		// but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative )
1630
+		if ( ! $payment->is_a_refund()) {
1631
+			$registration_query_where_params['REG_final_price']  = array('!=', 0);
1632
+			$registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true);
1633
+		}
1634
+		//EEH_Debug_Tools::printr( $registration_query_where_params, '$registration_query_where_params', __FILE__, __LINE__ );
1635
+		$registrations = $transaction->registrations(array($registration_query_where_params));
1636
+		if ( ! empty($registrations)) {
1637
+			/** @type EE_Payment_Processor $payment_processor */
1638
+			$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
1639
+			$payment_processor->process_registration_payments($transaction, $payment, $registrations);
1640
+		}
1641
+	}
1642
+    
1643
+    
1644
+	/**
1645
+	 * _process_registration_status_change
1646
+	 *
1647
+	 * This processes requested registration status changes for all the registrations
1648
+	 * on a given transaction and (optionally) sends out notifications for the changes.
1649
+	 *
1650
+	 * @param  EE_Transaction $transaction
1651
+	 * @param array           $REG_IDs
1652
+	 *
1653
+	 * @return bool
1654
+	 */
1655
+	protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array())
1656
+	{
1657
+		// first if there is no change in status then we get out.
1658
+		if (
1659
+			! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['reg_status'])
1660
+			|| $this->_req_data['txn_reg_status_change']['reg_status'] == 'NAN'
1661
+		) {
1662
+			//no error message, no change requested, just nothing to do man.
1663
+			return false;
1664
+		}
1665
+		/** @type EE_Transaction_Processor $transaction_processor */
1666
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1667
+        
1668
+		// made it here dude?  Oh WOW.  K, let's take care of changing the statuses
1669
+		return $transaction_processor->manually_update_registration_statuses(
1670
+			$transaction,
1671
+			sanitize_text_field($this->_req_data['txn_reg_status_change']['reg_status']),
1672
+			array(array('REG_ID' => array('IN', $REG_IDs)))
1673
+		);
1674
+	}
1675
+    
1676
+    
1677
+	/**
1678
+	 * _build_payment_json_response
1679
+	 *
1680
+	 * @access public
1681
+	 *
1682
+	 * @param \EE_Payment $payment
1683
+	 * @param array       $REG_IDs
1684
+	 * @param bool | null $delete_txn_reg_status_change
1685
+	 *
1686
+	 * @return array
1687
+	 */
1688
+	protected function _build_payment_json_response(
1689
+		EE_Payment $payment,
1690
+		$REG_IDs = array(),
1691
+		$delete_txn_reg_status_change = null
1692
+	) {
1693
+		// was the payment deleted ?
1694
+		if (is_bool($delete_txn_reg_status_change)) {
1695
+			return array(
1696
+				'PAY_ID'                       => $payment->ID(),
1697
+				'amount'                       => $payment->amount(),
1698
+				'total_paid'                   => $payment->transaction()->paid(),
1699
+				'txn_status'                   => $payment->transaction()->status_ID(),
1700
+				'pay_status'                   => $payment->STS_ID(),
1701
+				'registrations'                => $this->_registration_payment_data_array($REG_IDs),
1702
+				'delete_txn_reg_status_change' => $delete_txn_reg_status_change,
1703
+			);
1704
+		} else {
1705
+			$this->_get_payment_status_array();
1706 1706
             
1707
-            return array(
1708
-                'amount'           => $payment->amount(),
1709
-                'total_paid'       => $payment->transaction()->paid(),
1710
-                'txn_status'       => $payment->transaction()->status_ID(),
1711
-                'pay_status'       => $payment->STS_ID(),
1712
-                'PAY_ID'           => $payment->ID(),
1713
-                'STS_ID'           => $payment->STS_ID(),
1714
-                'status'           => self::$_pay_status[$payment->STS_ID()],
1715
-                'date'             => $payment->timestamp('Y-m-d', 'h:i a'),
1716
-                'method'           => strtoupper($payment->source()),
1717
-                'PM_ID'            => $payment->payment_method() ? $payment->payment_method()->ID() : 1,
1718
-                'gateway'          => $payment->payment_method() ? $payment->payment_method()->admin_name() : esc_html__("Unknown",
1719
-                    'event_espresso'),
1720
-                'gateway_response' => $payment->gateway_response(),
1721
-                'txn_id_chq_nmbr'  => $payment->txn_id_chq_nmbr(),
1722
-                'po_number'        => $payment->po_number(),
1723
-                'extra_accntng'    => $payment->extra_accntng(),
1724
-                'registrations'    => $this->_registration_payment_data_array($REG_IDs),
1725
-            );
1726
-        }
1727
-    }
1728
-    
1729
-    
1730
-    /**
1731
-     * delete_payment
1732
-     *    delete a payment or refund made towards a transaction
1733
-     *
1734
-     * @access public
1735
-     * @return void
1736
-     */
1737
-    public function delete_payment()
1738
-    {
1739
-        $json_response_data = array('return_data' => false);
1740
-        $PAY_ID             = isset($this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID']) ? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID']) : 0;
1741
-        if ($PAY_ID) {
1742
-            $delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change']) ? $this->_req_data['delete_txn_reg_status_change'] : false;
1743
-            $payment                      = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
1744
-            if ($payment instanceof EE_Payment) {
1745
-                $REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
1746
-                /** @type EE_Transaction_Payments $transaction_payments */
1747
-                $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1748
-                if ($transaction_payments->delete_payment_and_update_transaction($payment)) {
1749
-                    $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs,
1750
-                        $delete_txn_reg_status_change);
1751
-                    if ($delete_txn_reg_status_change) {
1752
-                        $this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change;
1753
-                        //MAKE sure we also add the delete_txn_req_status_change to the
1754
-                        //$_REQUEST global because that's how messages will be looking for it.
1755
-                        $_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change;
1756
-                        $this->_maybe_send_notifications();
1757
-                        $this->_process_registration_status_change($payment->transaction(), $REG_IDs);
1758
-                    }
1759
-                }
1760
-            } else {
1761
-                EE_Error::add_error(
1762
-                    esc_html__('Valid Payment data could not be retrieved from the database.', 'event_espresso'),
1763
-                    __FILE__, __FUNCTION__, __LINE__
1764
-                );
1765
-            }
1766
-        } else {
1767
-            EE_Error::add_error(
1768
-                esc_html__('A valid Payment ID was not received, therefore payment form data could not be loaded.',
1769
-                    'event_espresso'),
1770
-                __FILE__, __FUNCTION__, __LINE__
1771
-            );
1772
-        }
1773
-        $notices              = EE_Error::get_notices(false, false, false);
1774
-        $this->_template_args = array(
1775
-            'data'      => $json_response_data,
1776
-            'success'   => $notices['success'],
1777
-            'error'     => $notices['errors'],
1778
-            'attention' => $notices['attention']
1779
-        );
1780
-        $this->_return_json();
1781
-    }
1782
-    
1783
-    
1784
-    /**
1785
-     * _registration_payment_data_array
1786
-     * adds info for 'owing' and 'paid' for each registration to the json response
1787
-     *
1788
-     * @access protected
1789
-     *
1790
-     * @param array $REG_IDs
1791
-     *
1792
-     * @return array
1793
-     */
1794
-    protected function _registration_payment_data_array($REG_IDs)
1795
-    {
1796
-        $registration_payment_data = array();
1797
-        //if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows.
1798
-        if ( ! empty($REG_IDs)) {
1799
-            $registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs))));
1800
-            foreach ($registrations as $registration) {
1801
-                if ($registration instanceof EE_Registration) {
1802
-                    $registration_payment_data[$registration->ID()] = array(
1803
-                        'paid'  => $registration->pretty_paid(),
1804
-                        'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()),
1805
-                    );
1806
-                }
1807
-            }
1808
-        }
1809
-        
1810
-        return $registration_payment_data;
1811
-    }
1812
-    
1813
-    
1814
-    /**
1815
-     * _maybe_send_notifications
1816
-     *
1817
-     * determines whether or not the admin has indicated that notifications should be sent.
1818
-     * If so, will toggle a filter switch for delivering registration notices.
1819
-     * If passed an EE_Payment object, then it will trigger payment notifications instead.
1820
-     *
1821
-     * @access protected
1822
-     *
1823
-     * @param \EE_Payment | null $payment
1824
-     */
1825
-    protected function _maybe_send_notifications($payment = null)
1826
-    {
1827
-        switch ($payment instanceof EE_Payment) {
1828
-            // payment notifications
1829
-            case true :
1830
-                if (
1831
-                    isset(
1832
-                        $this->_req_data['txn_payments'],
1833
-                        $this->_req_data['txn_payments']['send_notifications']
1834
-                    ) &&
1835
-                    filter_var($this->_req_data['txn_payments']['send_notifications'], FILTER_VALIDATE_BOOLEAN)
1836
-                ) {
1837
-                    $this->_process_payment_notification($payment);
1838
-                }
1839
-                break;
1840
-            // registration notifications
1841
-            case false :
1842
-                if (
1843
-                    isset(
1844
-                        $this->_req_data['txn_reg_status_change'],
1845
-                        $this->_req_data['txn_reg_status_change']['send_notifications']
1846
-                    ) &&
1847
-                    filter_var($this->_req_data['txn_reg_status_change']['send_notifications'], FILTER_VALIDATE_BOOLEAN)
1848
-                ) {
1849
-                    add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
1850
-                }
1851
-                break;
1852
-        }
1853
-    }
1854
-    
1855
-    
1856
-    /**
1857
-     * _send_payment_reminder
1858
-     *    generates HTML for the View Transaction Details Admin page
1859
-     *
1860
-     * @access protected
1861
-     * @return void
1862
-     */
1863
-    protected function _send_payment_reminder()
1864
-    {
1865
-        $TXN_ID      = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : false;
1866
-        $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
1867
-        $query_args  = isset($this->_req_data['redirect_to']) ? array(
1868
-            'action' => $this->_req_data['redirect_to'],
1869
-            'TXN_ID' => $this->_req_data['TXN_ID']
1870
-        ) : array();
1871
-        do_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder',
1872
-            $transaction);
1873
-        $this->_redirect_after_action(false, esc_html__('payment reminder', 'event_espresso'),
1874
-            esc_html__('sent', 'event_espresso'), $query_args, true);
1875
-    }
1876
-    
1877
-    
1878
-    /**
1879
-     *  get_transactions
1880
-     *    get transactions for given parameters (used by list table)
1881
-     *
1882
-     * @param  int     $perpage how many transactions displayed per page
1883
-     * @param  boolean $count   return the count or objects
1884
-     * @param string   $view
1885
-     *
1886
-     * @return mixed int = count || array of transaction objects
1887
-     */
1888
-    public function get_transactions($perpage, $count = false, $view = '')
1889
-    {
1890
-        
1891
-        $TXN = EEM_Transaction::instance();
1892
-        
1893
-        $start_date = isset($this->_req_data['txn-filter-start-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) : date('m/d/Y',
1894
-            strtotime('-10 year'));
1895
-        $end_date   = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y');
1896
-        
1897
-        //make sure our timestamps start and end right at the boundaries for each day
1898
-        $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
1899
-        $end_date   = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
1900
-        
1901
-        
1902
-        //convert to timestamps
1903
-        $start_date = strtotime($start_date);
1904
-        $end_date   = strtotime($end_date);
1905
-        
1906
-        //makes sure start date is the lowest value and vice versa
1907
-        $start_date = min($start_date, $end_date);
1908
-        $end_date   = max($start_date, $end_date);
1909
-        
1910
-        //convert to correct format for query
1911
-        $start_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp',
1912
-            date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s');
1913
-        $end_date   = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp',
1914
-            date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s');
1915
-        
1916
-        
1917
-        //set orderby
1918
-        $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
1919
-        
1920
-        switch ($this->_req_data['orderby']) {
1921
-            case 'TXN_ID':
1922
-                $orderby = 'TXN_ID';
1923
-                break;
1924
-            case 'ATT_fname':
1925
-                $orderby = 'Registration.Attendee.ATT_fname';
1926
-                break;
1927
-            case 'event_name':
1928
-                $orderby = 'Registration.Event.EVT_name';
1929
-                break;
1930
-            default: //'TXN_timestamp'
1931
-                $orderby = 'TXN_timestamp';
1932
-        }
1933
-        
1934
-        $sort         = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC';
1935
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
1936
-        $per_page     = isset($perpage) && ! empty($perpage) ? $perpage : 10;
1937
-        $per_page     = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
1938
-        
1939
-        $offset = ($current_page - 1) * $per_page;
1940
-        $limit  = array($offset, $per_page);
1941
-        
1942
-        $_where = array(
1943
-            'TXN_timestamp'          => array('BETWEEN', array($start_date, $end_date)),
1944
-            'Registration.REG_count' => 1
1945
-        );
1946
-        
1947
-        if (isset($this->_req_data['EVT_ID'])) {
1948
-            $_where['Registration.EVT_ID'] = $this->_req_data['EVT_ID'];
1949
-        }
1950
-        
1951
-        if (isset($this->_req_data['s'])) {
1952
-            $search_string = '%' . $this->_req_data['s'] . '%';
1953
-            $_where['OR']  = array(
1954
-                'Registration.Event.EVT_name'         => array('LIKE', $search_string),
1955
-                'Registration.Event.EVT_desc'         => array('LIKE', $search_string),
1956
-                'Registration.Event.EVT_short_desc'   => array('LIKE', $search_string),
1957
-                'Registration.Attendee.ATT_full_name' => array('LIKE', $search_string),
1958
-                'Registration.Attendee.ATT_fname'     => array('LIKE', $search_string),
1959
-                'Registration.Attendee.ATT_lname'     => array('LIKE', $search_string),
1960
-                'Registration.Attendee.ATT_short_bio' => array('LIKE', $search_string),
1961
-                'Registration.Attendee.ATT_email'     => array('LIKE', $search_string),
1962
-                'Registration.Attendee.ATT_address'   => array('LIKE', $search_string),
1963
-                'Registration.Attendee.ATT_address2'  => array('LIKE', $search_string),
1964
-                'Registration.Attendee.ATT_city'      => array('LIKE', $search_string),
1965
-                'Registration.REG_final_price'        => array('LIKE', $search_string),
1966
-                'Registration.REG_code'               => array('LIKE', $search_string),
1967
-                'Registration.REG_count'              => array('LIKE', $search_string),
1968
-                'Registration.REG_group_size'         => array('LIKE', $search_string),
1969
-                'Registration.Ticket.TKT_name'        => array('LIKE', $search_string),
1970
-                'Registration.Ticket.TKT_description' => array('LIKE', $search_string),
1971
-                'Payment.PAY_source'                  => array('LIKE', $search_string),
1972
-                'Payment.Payment_Method.PMD_name'     => array('LIKE', $search_string),
1973
-                'TXN_session_data'                    => array('LIKE', $search_string),
1974
-                'Payment.PAY_txn_id_chq_nmbr'         => array('LIKE', $search_string)
1975
-            );
1976
-        }
1977
-        
1978
-        //failed transactions
1979
-        $failed    = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'failed' && ! $count) || ($count && $view == 'failed') ? true : false;
1980
-        $abandoned = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'abandoned' && ! $count) || ($count && $view == 'abandoned') ? true : false;
1981
-        
1982
-        if ($failed) {
1983
-            $_where['STS_ID'] = EEM_Transaction::failed_status_code;
1984
-        } else if ($abandoned) {
1985
-            $_where['STS_ID'] = EEM_Transaction::abandoned_status_code;
1986
-        } else {
1987
-            $_where['STS_ID']  = array('!=', EEM_Transaction::failed_status_code);
1988
-            $_where['STS_ID*'] = array('!=', EEM_Transaction::abandoned_status_code);
1989
-        }
1990
-        
1991
-        $query_params = array($_where, 'order_by' => array($orderby => $sort), 'limit' => $limit);
1992
-        
1993
-        $transactions = $count ? $TXN->count(array($_where), 'TXN_ID', true) : $TXN->get_all($query_params);
1994
-        
1995
-        
1996
-        return $transactions;
1997
-        
1998
-    }
1707
+			return array(
1708
+				'amount'           => $payment->amount(),
1709
+				'total_paid'       => $payment->transaction()->paid(),
1710
+				'txn_status'       => $payment->transaction()->status_ID(),
1711
+				'pay_status'       => $payment->STS_ID(),
1712
+				'PAY_ID'           => $payment->ID(),
1713
+				'STS_ID'           => $payment->STS_ID(),
1714
+				'status'           => self::$_pay_status[$payment->STS_ID()],
1715
+				'date'             => $payment->timestamp('Y-m-d', 'h:i a'),
1716
+				'method'           => strtoupper($payment->source()),
1717
+				'PM_ID'            => $payment->payment_method() ? $payment->payment_method()->ID() : 1,
1718
+				'gateway'          => $payment->payment_method() ? $payment->payment_method()->admin_name() : esc_html__("Unknown",
1719
+					'event_espresso'),
1720
+				'gateway_response' => $payment->gateway_response(),
1721
+				'txn_id_chq_nmbr'  => $payment->txn_id_chq_nmbr(),
1722
+				'po_number'        => $payment->po_number(),
1723
+				'extra_accntng'    => $payment->extra_accntng(),
1724
+				'registrations'    => $this->_registration_payment_data_array($REG_IDs),
1725
+			);
1726
+		}
1727
+	}
1728
+    
1729
+    
1730
+	/**
1731
+	 * delete_payment
1732
+	 *    delete a payment or refund made towards a transaction
1733
+	 *
1734
+	 * @access public
1735
+	 * @return void
1736
+	 */
1737
+	public function delete_payment()
1738
+	{
1739
+		$json_response_data = array('return_data' => false);
1740
+		$PAY_ID             = isset($this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID']) ? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID']) : 0;
1741
+		if ($PAY_ID) {
1742
+			$delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change']) ? $this->_req_data['delete_txn_reg_status_change'] : false;
1743
+			$payment                      = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
1744
+			if ($payment instanceof EE_Payment) {
1745
+				$REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
1746
+				/** @type EE_Transaction_Payments $transaction_payments */
1747
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1748
+				if ($transaction_payments->delete_payment_and_update_transaction($payment)) {
1749
+					$json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs,
1750
+						$delete_txn_reg_status_change);
1751
+					if ($delete_txn_reg_status_change) {
1752
+						$this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change;
1753
+						//MAKE sure we also add the delete_txn_req_status_change to the
1754
+						//$_REQUEST global because that's how messages will be looking for it.
1755
+						$_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change;
1756
+						$this->_maybe_send_notifications();
1757
+						$this->_process_registration_status_change($payment->transaction(), $REG_IDs);
1758
+					}
1759
+				}
1760
+			} else {
1761
+				EE_Error::add_error(
1762
+					esc_html__('Valid Payment data could not be retrieved from the database.', 'event_espresso'),
1763
+					__FILE__, __FUNCTION__, __LINE__
1764
+				);
1765
+			}
1766
+		} else {
1767
+			EE_Error::add_error(
1768
+				esc_html__('A valid Payment ID was not received, therefore payment form data could not be loaded.',
1769
+					'event_espresso'),
1770
+				__FILE__, __FUNCTION__, __LINE__
1771
+			);
1772
+		}
1773
+		$notices              = EE_Error::get_notices(false, false, false);
1774
+		$this->_template_args = array(
1775
+			'data'      => $json_response_data,
1776
+			'success'   => $notices['success'],
1777
+			'error'     => $notices['errors'],
1778
+			'attention' => $notices['attention']
1779
+		);
1780
+		$this->_return_json();
1781
+	}
1782
+    
1783
+    
1784
+	/**
1785
+	 * _registration_payment_data_array
1786
+	 * adds info for 'owing' and 'paid' for each registration to the json response
1787
+	 *
1788
+	 * @access protected
1789
+	 *
1790
+	 * @param array $REG_IDs
1791
+	 *
1792
+	 * @return array
1793
+	 */
1794
+	protected function _registration_payment_data_array($REG_IDs)
1795
+	{
1796
+		$registration_payment_data = array();
1797
+		//if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows.
1798
+		if ( ! empty($REG_IDs)) {
1799
+			$registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs))));
1800
+			foreach ($registrations as $registration) {
1801
+				if ($registration instanceof EE_Registration) {
1802
+					$registration_payment_data[$registration->ID()] = array(
1803
+						'paid'  => $registration->pretty_paid(),
1804
+						'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()),
1805
+					);
1806
+				}
1807
+			}
1808
+		}
1809
+        
1810
+		return $registration_payment_data;
1811
+	}
1812
+    
1813
+    
1814
+	/**
1815
+	 * _maybe_send_notifications
1816
+	 *
1817
+	 * determines whether or not the admin has indicated that notifications should be sent.
1818
+	 * If so, will toggle a filter switch for delivering registration notices.
1819
+	 * If passed an EE_Payment object, then it will trigger payment notifications instead.
1820
+	 *
1821
+	 * @access protected
1822
+	 *
1823
+	 * @param \EE_Payment | null $payment
1824
+	 */
1825
+	protected function _maybe_send_notifications($payment = null)
1826
+	{
1827
+		switch ($payment instanceof EE_Payment) {
1828
+			// payment notifications
1829
+			case true :
1830
+				if (
1831
+					isset(
1832
+						$this->_req_data['txn_payments'],
1833
+						$this->_req_data['txn_payments']['send_notifications']
1834
+					) &&
1835
+					filter_var($this->_req_data['txn_payments']['send_notifications'], FILTER_VALIDATE_BOOLEAN)
1836
+				) {
1837
+					$this->_process_payment_notification($payment);
1838
+				}
1839
+				break;
1840
+			// registration notifications
1841
+			case false :
1842
+				if (
1843
+					isset(
1844
+						$this->_req_data['txn_reg_status_change'],
1845
+						$this->_req_data['txn_reg_status_change']['send_notifications']
1846
+					) &&
1847
+					filter_var($this->_req_data['txn_reg_status_change']['send_notifications'], FILTER_VALIDATE_BOOLEAN)
1848
+				) {
1849
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
1850
+				}
1851
+				break;
1852
+		}
1853
+	}
1854
+    
1855
+    
1856
+	/**
1857
+	 * _send_payment_reminder
1858
+	 *    generates HTML for the View Transaction Details Admin page
1859
+	 *
1860
+	 * @access protected
1861
+	 * @return void
1862
+	 */
1863
+	protected function _send_payment_reminder()
1864
+	{
1865
+		$TXN_ID      = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : false;
1866
+		$transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
1867
+		$query_args  = isset($this->_req_data['redirect_to']) ? array(
1868
+			'action' => $this->_req_data['redirect_to'],
1869
+			'TXN_ID' => $this->_req_data['TXN_ID']
1870
+		) : array();
1871
+		do_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder',
1872
+			$transaction);
1873
+		$this->_redirect_after_action(false, esc_html__('payment reminder', 'event_espresso'),
1874
+			esc_html__('sent', 'event_espresso'), $query_args, true);
1875
+	}
1876
+    
1877
+    
1878
+	/**
1879
+	 *  get_transactions
1880
+	 *    get transactions for given parameters (used by list table)
1881
+	 *
1882
+	 * @param  int     $perpage how many transactions displayed per page
1883
+	 * @param  boolean $count   return the count or objects
1884
+	 * @param string   $view
1885
+	 *
1886
+	 * @return mixed int = count || array of transaction objects
1887
+	 */
1888
+	public function get_transactions($perpage, $count = false, $view = '')
1889
+	{
1890
+        
1891
+		$TXN = EEM_Transaction::instance();
1892
+        
1893
+		$start_date = isset($this->_req_data['txn-filter-start-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) : date('m/d/Y',
1894
+			strtotime('-10 year'));
1895
+		$end_date   = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y');
1896
+        
1897
+		//make sure our timestamps start and end right at the boundaries for each day
1898
+		$start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
1899
+		$end_date   = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
1900
+        
1901
+        
1902
+		//convert to timestamps
1903
+		$start_date = strtotime($start_date);
1904
+		$end_date   = strtotime($end_date);
1905
+        
1906
+		//makes sure start date is the lowest value and vice versa
1907
+		$start_date = min($start_date, $end_date);
1908
+		$end_date   = max($start_date, $end_date);
1909
+        
1910
+		//convert to correct format for query
1911
+		$start_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp',
1912
+			date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s');
1913
+		$end_date   = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp',
1914
+			date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s');
1915
+        
1916
+        
1917
+		//set orderby
1918
+		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
1919
+        
1920
+		switch ($this->_req_data['orderby']) {
1921
+			case 'TXN_ID':
1922
+				$orderby = 'TXN_ID';
1923
+				break;
1924
+			case 'ATT_fname':
1925
+				$orderby = 'Registration.Attendee.ATT_fname';
1926
+				break;
1927
+			case 'event_name':
1928
+				$orderby = 'Registration.Event.EVT_name';
1929
+				break;
1930
+			default: //'TXN_timestamp'
1931
+				$orderby = 'TXN_timestamp';
1932
+		}
1933
+        
1934
+		$sort         = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC';
1935
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
1936
+		$per_page     = isset($perpage) && ! empty($perpage) ? $perpage : 10;
1937
+		$per_page     = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
1938
+        
1939
+		$offset = ($current_page - 1) * $per_page;
1940
+		$limit  = array($offset, $per_page);
1941
+        
1942
+		$_where = array(
1943
+			'TXN_timestamp'          => array('BETWEEN', array($start_date, $end_date)),
1944
+			'Registration.REG_count' => 1
1945
+		);
1946
+        
1947
+		if (isset($this->_req_data['EVT_ID'])) {
1948
+			$_where['Registration.EVT_ID'] = $this->_req_data['EVT_ID'];
1949
+		}
1950
+        
1951
+		if (isset($this->_req_data['s'])) {
1952
+			$search_string = '%' . $this->_req_data['s'] . '%';
1953
+			$_where['OR']  = array(
1954
+				'Registration.Event.EVT_name'         => array('LIKE', $search_string),
1955
+				'Registration.Event.EVT_desc'         => array('LIKE', $search_string),
1956
+				'Registration.Event.EVT_short_desc'   => array('LIKE', $search_string),
1957
+				'Registration.Attendee.ATT_full_name' => array('LIKE', $search_string),
1958
+				'Registration.Attendee.ATT_fname'     => array('LIKE', $search_string),
1959
+				'Registration.Attendee.ATT_lname'     => array('LIKE', $search_string),
1960
+				'Registration.Attendee.ATT_short_bio' => array('LIKE', $search_string),
1961
+				'Registration.Attendee.ATT_email'     => array('LIKE', $search_string),
1962
+				'Registration.Attendee.ATT_address'   => array('LIKE', $search_string),
1963
+				'Registration.Attendee.ATT_address2'  => array('LIKE', $search_string),
1964
+				'Registration.Attendee.ATT_city'      => array('LIKE', $search_string),
1965
+				'Registration.REG_final_price'        => array('LIKE', $search_string),
1966
+				'Registration.REG_code'               => array('LIKE', $search_string),
1967
+				'Registration.REG_count'              => array('LIKE', $search_string),
1968
+				'Registration.REG_group_size'         => array('LIKE', $search_string),
1969
+				'Registration.Ticket.TKT_name'        => array('LIKE', $search_string),
1970
+				'Registration.Ticket.TKT_description' => array('LIKE', $search_string),
1971
+				'Payment.PAY_source'                  => array('LIKE', $search_string),
1972
+				'Payment.Payment_Method.PMD_name'     => array('LIKE', $search_string),
1973
+				'TXN_session_data'                    => array('LIKE', $search_string),
1974
+				'Payment.PAY_txn_id_chq_nmbr'         => array('LIKE', $search_string)
1975
+			);
1976
+		}
1977
+        
1978
+		//failed transactions
1979
+		$failed    = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'failed' && ! $count) || ($count && $view == 'failed') ? true : false;
1980
+		$abandoned = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'abandoned' && ! $count) || ($count && $view == 'abandoned') ? true : false;
1981
+        
1982
+		if ($failed) {
1983
+			$_where['STS_ID'] = EEM_Transaction::failed_status_code;
1984
+		} else if ($abandoned) {
1985
+			$_where['STS_ID'] = EEM_Transaction::abandoned_status_code;
1986
+		} else {
1987
+			$_where['STS_ID']  = array('!=', EEM_Transaction::failed_status_code);
1988
+			$_where['STS_ID*'] = array('!=', EEM_Transaction::abandoned_status_code);
1989
+		}
1990
+        
1991
+		$query_params = array($_where, 'order_by' => array($orderby => $sort), 'limit' => $limit);
1992
+        
1993
+		$transactions = $count ? $TXN->count(array($_where), 'TXN_ID', true) : $TXN->get_all($query_params);
1994
+        
1995
+        
1996
+		return $transactions;
1997
+        
1998
+	}
1999 1999
     
2000 2000
     
2001 2001
 }
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
     public function load_scripts_styles()
339 339
     {
340 340
         //enqueue style
341
-        wp_register_style('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.css', array(),
341
+        wp_register_style('espresso_txn', TXN_ASSETS_URL.'espresso_transactions_admin.css', array(),
342 342
             EVENT_ESPRESSO_VERSION);
343 343
         wp_enqueue_style('espresso_txn');
344 344
         
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
         add_filter('FHEE_load_accounting_js', '__return_true');
347 347
         
348 348
         //scripts
349
-        wp_register_script('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.js', array(
349
+        wp_register_script('espresso_txn', TXN_ASSETS_URL.'espresso_transactions_admin.js', array(
350 350
             'ee_admin_js',
351 351
             'ee-datepicker',
352 352
             'jquery-ui-datepicker',
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
         
439 439
         if (empty($this->_transaction)) {
440 440
             $error_msg = esc_html__('An error occurred and the details for Transaction ID #',
441
-                    'event_espresso') . $TXN_ID . esc_html__(' could not be retrieved.', 'event_espresso');
441
+                    'event_espresso').$TXN_ID.esc_html__(' could not be retrieved.', 'event_espresso');
442 442
             EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
443 443
         }
444 444
     }
@@ -513,23 +513,23 @@  discard block
 block discarded – undo
513 513
             'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items',
514 514
             array(
515 515
                 'overpaid'   => array(
516
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code,
516
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::overpaid_status_code,
517 517
                     'desc'  => EEH_Template::pretty_status(EEM_Transaction::overpaid_status_code, false, 'sentence')
518 518
                 ),
519 519
                 'complete'   => array(
520
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code,
520
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::complete_status_code,
521 521
                     'desc'  => EEH_Template::pretty_status(EEM_Transaction::complete_status_code, false, 'sentence')
522 522
                 ),
523 523
                 'incomplete' => array(
524
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code,
524
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::incomplete_status_code,
525 525
                     'desc'  => EEH_Template::pretty_status(EEM_Transaction::incomplete_status_code, false, 'sentence')
526 526
                 ),
527 527
                 'abandoned'  => array(
528
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code,
528
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::abandoned_status_code,
529 529
                     'desc'  => EEH_Template::pretty_status(EEM_Transaction::abandoned_status_code, false, 'sentence')
530 530
                 ),
531 531
                 'failed'     => array(
532
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code,
532
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::failed_status_code,
533 533
                     'desc'  => EEH_Template::pretty_status(EEM_Transaction::failed_status_code, false, 'sentence')
534 534
                 )
535 535
             )
@@ -551,10 +551,10 @@  discard block
 block discarded – undo
551 551
         $event                                     = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']) : null;
552 552
         $this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf(esc_html__('%sViewing Transactions for the Event: %s%s',
553 553
             'event_espresso'), '<h3>',
554
-            '<a href="' . EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()),
555
-                EVENTS_ADMIN_URL) . '" title="' . esc_attr__('Click to Edit event',
556
-                'event_espresso') . '">' . $event->get('EVT_name') . '</a>', '</h3>') : '';
557
-        $this->_template_args['after_list_table']  = $this->_display_legend($this->_transaction_legend_items());
554
+            '<a href="'.EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()),
555
+                EVENTS_ADMIN_URL).'" title="'.esc_attr__('Click to Edit event',
556
+                'event_espresso').'">'.$event->get('EVT_name').'</a>', '</h3>') : '';
557
+        $this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items());
558 558
         $this->display_admin_list_table_page_with_no_sidebar();
559 559
     }
560 560
     
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
         
589 589
         $this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->get('STS_ID')];
590 590
         $this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso');
591
-        $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID');
591
+        $this->_template_args['txn_status']['class'] = 'status-'.$this->_transaction->get('STS_ID');
592 592
         
593 593
         $this->_template_args['grand_total'] = $this->_transaction->get('TXN_total');
594 594
         $this->_template_args['total_paid']  = $this->_transaction->get('TXN_paid');
@@ -625,9 +625,9 @@  discard block
 block discarded – undo
625 625
         $amount_due                         = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid');
626 626
         $this->_template_args['amount_due'] = EEH_Template::format_currency($amount_due, true);
627 627
         if (EE_Registry::instance()->CFG->currency->sign_b4) {
628
-            $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign . $this->_template_args['amount_due'];
628
+            $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign.$this->_template_args['amount_due'];
629 629
         } else {
630
-            $this->_template_args['amount_due'] = $this->_template_args['amount_due'] . EE_Registry::instance()->CFG->currency->sign;
630
+            $this->_template_args['amount_due'] = $this->_template_args['amount_due'].EE_Registry::instance()->CFG->currency->sign;
631 631
         }
632 632
         $this->_template_args['amount_due_class'] = '';
633 633
         
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
         
663 663
         
664 664
         // next link
665
-        $next_txn                                 = $this->_transaction->next(
665
+        $next_txn = $this->_transaction->next(
666 666
             null,
667 667
             array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
668 668
             'TXN_ID'
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
             )
678 678
             : '';
679 679
         // previous link
680
-        $previous_txn                                 = $this->_transaction->previous(
680
+        $previous_txn = $this->_transaction->previous(
681 681
             null,
682 682
             array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
683 683
             'TXN_ID'
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
         // grab messages at the last second
732 732
         $this->_template_args['notices'] = EE_Error::get_notices();
733 733
         // path to template
734
-        $template_path                             = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
734
+        $template_path                             = TXN_TEMPLATE_PATH.'txn_admin_details_header.template.php';
735 735
         $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path,
736 736
             $this->_template_args, true);
737 737
         
@@ -839,18 +839,18 @@  discard block
 block discarded – undo
839 839
         $reg_steps = '<ul>';
840 840
         foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) {
841 841
             if ($reg_step_status === true) {
842
-                $reg_steps .= '<li style="color:#70cc50">' . sprintf(esc_html__('%1$s : Completed', 'event_espresso'),
843
-                        ucwords(str_replace('_', ' ', $reg_step))) . '</li>';
842
+                $reg_steps .= '<li style="color:#70cc50">'.sprintf(esc_html__('%1$s : Completed', 'event_espresso'),
843
+                        ucwords(str_replace('_', ' ', $reg_step))).'</li>';
844 844
             } else if (is_numeric($reg_step_status) && $reg_step_status !== false) {
845
-                $reg_steps .= '<li style="color:#2EA2CC">' . sprintf(
845
+                $reg_steps .= '<li style="color:#2EA2CC">'.sprintf(
846 846
                         esc_html__('%1$s : Initiated %2$s', 'event_espresso'),
847 847
                         ucwords(str_replace('_', ' ', $reg_step)),
848
-                        date(get_option('date_format') . ' ' . get_option('time_format'),
848
+                        date(get_option('date_format').' '.get_option('time_format'),
849 849
                             ($reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS)))
850
-                    ) . '</li>';
850
+                    ).'</li>';
851 851
             } else {
852
-                $reg_steps .= '<li style="color:#E76700">' . sprintf(esc_html__('%1$s : Never Initiated',
853
-                        'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))) . '</li>';
852
+                $reg_steps .= '<li style="color:#E76700">'.sprintf(esc_html__('%1$s : Never Initiated',
853
+                        'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))).'</li>';
854 854
             }
855 855
         }
856 856
         $reg_steps .= '</ul>';
@@ -864,11 +864,11 @@  discard block
 block discarded – undo
864 864
         $this->_get_payment_status_array();
865 865
         $this->_get_reg_status_selection(); //sets up the template args for the reg status array for the transaction.
866 866
         
867
-        $this->_template_args['transaction_form_url']    = add_query_arg(array(
867
+        $this->_template_args['transaction_form_url'] = add_query_arg(array(
868 868
             'action'  => 'edit_transaction',
869 869
             'process' => 'transaction'
870 870
         ), TXN_ADMIN_URL);
871
-        $this->_template_args['apply_payment_form_url']  = add_query_arg(array(
871
+        $this->_template_args['apply_payment_form_url'] = add_query_arg(array(
872 872
             'page'   => 'espresso_transactions',
873 873
             'action' => 'espresso_apply_payment'
874 874
         ), WP_AJAX_URL);
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
         
880 880
         // 'espresso_delete_payment_nonce'
881 881
         
882
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
882
+        $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_txn_details.template.php';
883 883
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
884 884
         
885 885
     }
@@ -939,7 +939,7 @@  discard block
 block discarded – undo
939 939
     protected function _get_registrations_to_apply_payment_to()
940 940
     {
941 941
         // we want any registration with an active status (ie: not deleted or cancelled)
942
-        $query_params                      = array(
942
+        $query_params = array(
943 943
             array(
944 944
                 'STS_ID' => array(
945 945
                     'IN',
@@ -951,19 +951,19 @@  discard block
 block discarded – undo
951 951
                 )
952 952
             )
953 953
         );
954
-        $registrations_to_apply_payment_to = EEH_HTML::br() . EEH_HTML::div(
954
+        $registrations_to_apply_payment_to = EEH_HTML::br().EEH_HTML::div(
955 955
                 '', 'txn-admin-apply-payment-to-registrations-dv', '', 'clear: both; margin: 1.5em 0 0; display: none;'
956 956
             );
957
-        $registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap');
957
+        $registrations_to_apply_payment_to .= EEH_HTML::br().EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap');
958 958
         $registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl');
959 959
         $registrations_to_apply_payment_to .= EEH_HTML::thead(
960 960
             EEH_HTML::tr(
961
-                EEH_HTML::th(esc_html__('ID', 'event_espresso')) .
962
-                EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) .
963
-                EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) .
964
-                EEH_HTML::th(esc_html__('Event', 'event_espresso')) .
965
-                EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') .
966
-                EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') .
961
+                EEH_HTML::th(esc_html__('ID', 'event_espresso')).
962
+                EEH_HTML::th(esc_html__('Registrant', 'event_espresso')).
963
+                EEH_HTML::th(esc_html__('Ticket', 'event_espresso')).
964
+                EEH_HTML::th(esc_html__('Event', 'event_espresso')).
965
+                EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr').
966
+                EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr').
967 967
                 EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr')
968 968
             )
969 969
         );
@@ -977,28 +977,28 @@  discard block
 block discarded – undo
977 977
                     : esc_html__('Unknown Attendee', 'event_espresso');
978 978
                 $owing         = $registration->final_price() - $registration->paid();
979 979
                 $taxable       = $registration->ticket()->taxable()
980
-                    ? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>'
980
+                    ? ' <span class="smaller-text lt-grey-text"> '.esc_html__('+ tax', 'event_espresso').'</span>'
981 981
                     : '';
982 982
                 $checked       = empty($existing_reg_payments) || in_array($registration->ID(), $existing_reg_payments)
983 983
                     ? ' checked="checked"'
984 984
                     : '';
985 985
                 $disabled      = $registration->final_price() > 0 ? '' : ' disabled';
986 986
                 $registrations_to_apply_payment_to .= EEH_HTML::tr(
987
-                    EEH_HTML::td($registration->ID()) .
988
-                    EEH_HTML::td($attendee_name) .
987
+                    EEH_HTML::td($registration->ID()).
988
+                    EEH_HTML::td($attendee_name).
989 989
                     EEH_HTML::td(
990
-                        $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable
991
-                    ) .
992
-                    EEH_HTML::td($registration->event_name()) .
993
-                    EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') .
994
-                    EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr') .
990
+                        $registration->ticket()->name().' : '.$registration->ticket()->pretty_price().$taxable
991
+                    ).
992
+                    EEH_HTML::td($registration->event_name()).
993
+                    EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr').
994
+                    EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr').
995 995
                     EEH_HTML::td(
996
-                        '<input type="checkbox" value="' . $registration->ID()
996
+                        '<input type="checkbox" value="'.$registration->ID()
997 997
                         . '" name="txn_admin_payment[registrations]"'
998
-                        . $checked . $disabled . '>',
998
+                        . $checked.$disabled.'>',
999 999
                         '', 'jst-cntr'
1000 1000
                     ),
1001
-                    'apply-payment-registration-row-' . $registration->ID()
1001
+                    'apply-payment-registration-row-'.$registration->ID()
1002 1002
                 );
1003 1003
             }
1004 1004
         }
@@ -1064,12 +1064,12 @@  discard block
 block discarded – undo
1064 1064
                 array(
1065 1065
                     'OR*payment_method_for_payment' => array(
1066 1066
                         'PMD_ID'    => array('IN', $payment_methods_of_payments),
1067
-                        'PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%')
1067
+                        'PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%')
1068 1068
                     )
1069 1069
                 )
1070 1070
             );
1071 1071
         } else {
1072
-            $query_args = array(array('PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%')));
1072
+            $query_args = array(array('PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%')));
1073 1073
         }
1074 1074
         $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args);
1075 1075
     }
@@ -1114,7 +1114,7 @@  discard block
 block discarded – undo
1114 1114
                                 EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1115 1115
                                 $event_name = esc_html__('Unknown Event', 'event_espresso');
1116 1116
                             }
1117
-                            $event_name .= ' - ' . $item->get('LIN_name');
1117
+                            $event_name .= ' - '.$item->get('LIN_name');
1118 1118
                             $ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price'));
1119 1119
                             // now get all of the registrations for this transaction that use this ticket
1120 1120
                             $registrations = $ticket->get_many_related('Registration',
@@ -1132,8 +1132,8 @@  discard block
 block discarded – undo
1132 1132
                                 if ($attendee instanceof EE_Attendee) {
1133 1133
                                     $this->_template_args['event_attendees'][$registration->ID()]['att_id']   = $attendee->ID();
1134 1134
                                     $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = $attendee->full_name();
1135
-                                    $this->_template_args['event_attendees'][$registration->ID()]['email']    = '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name . esc_html__(' Event',
1136
-                                            'event_espresso') . '">' . $attendee->email() . '</a>';
1135
+                                    $this->_template_args['event_attendees'][$registration->ID()]['email']    = '<a href="mailto:'.$attendee->email().'?subject='.$event_name.esc_html__(' Event',
1136
+                                            'event_espresso').'">'.$attendee->email().'</a>';
1137 1137
                                     $this->_template_args['event_attendees'][$registration->ID()]['address']  = EEH_Address::format($attendee,
1138 1138
                                         'inline', false, false);
1139 1139
                                 } else {
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
                 'action'  => 'edit_transaction',
1154 1154
                 'process' => 'attendees'
1155 1155
             ), TXN_ADMIN_URL);
1156
-            echo EEH_Template::display_template(TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php',
1156
+            echo EEH_Template::display_template(TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_attendees.template.php',
1157 1157
                 $this->_template_args, true);
1158 1158
             
1159 1159
         } else {
@@ -1194,7 +1194,7 @@  discard block
 block discarded – undo
1194 1194
         ), REG_ADMIN_URL);
1195 1195
         // get formatted address for registrant
1196 1196
         $this->_template_args['formatted_address'] = EEH_Address::format($primary_att);
1197
-        echo EEH_Template::display_template(TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php',
1197
+        echo EEH_Template::display_template(TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_registrant.template.php',
1198 1198
             $this->_template_args, true);
1199 1199
     }
1200 1200
     
@@ -1215,8 +1215,8 @@  discard block
 block discarded – undo
1215 1215
             TXN_ADMIN_URL
1216 1216
         );
1217 1217
         
1218
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php';
1219
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);/**/
1218
+        $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_billing_info.template.php';
1219
+        echo EEH_Template::display_template($template_path, $this->_template_args, true); /**/
1220 1220
     }
1221 1221
     
1222 1222
     
@@ -1509,7 +1509,7 @@  discard block
 block discarded – undo
1509 1509
         $REG_IDs = array();
1510 1510
         // grab array of IDs for specific registrations to apply changes to
1511 1511
         if (isset($this->_req_data['txn_admin_payment']['registrations'])) {
1512
-            $REG_IDs = (array)$this->_req_data['txn_admin_payment']['registrations'];
1512
+            $REG_IDs = (array) $this->_req_data['txn_admin_payment']['registrations'];
1513 1513
         }
1514 1514
         //nothing specified ? then get all reg IDs
1515 1515
         if (empty($REG_IDs)) {
@@ -1895,8 +1895,8 @@  discard block
 block discarded – undo
1895 1895
         $end_date   = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y');
1896 1896
         
1897 1897
         //make sure our timestamps start and end right at the boundaries for each day
1898
-        $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
1899
-        $end_date   = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
1898
+        $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00';
1899
+        $end_date   = date('Y-m-d', strtotime($end_date)).' 23:59:59';
1900 1900
         
1901 1901
         
1902 1902
         //convert to timestamps
@@ -1949,7 +1949,7 @@  discard block
 block discarded – undo
1949 1949
         }
1950 1950
         
1951 1951
         if (isset($this->_req_data['s'])) {
1952
-            $search_string = '%' . $this->_req_data['s'] . '%';
1952
+            $search_string = '%'.$this->_req_data['s'].'%';
1953 1953
             $_where['OR']  = array(
1954 1954
                 'Registration.Event.EVT_name'         => array('LIKE', $search_string),
1955 1955
                 'Registration.Event.EVT_desc'         => array('LIKE', $search_string),
Please login to merge, or discard this patch.
admin/extend/transactions/Extend_Transactions_Admin_Page.core.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -198,7 +198,7 @@
 block discarded – undo
198 198
      *
199 199
      * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
200 200
      *
201
-     * @return int
201
+     * @return string
202 202
      */
203 203
     private function _revenue_per_event_report($period = '-1 month')
204 204
     {
Please login to merge, or discard this patch.
Indentation   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -32,219 +32,219 @@  discard block
 block discarded – undo
32 32
 {
33 33
     
34 34
     
35
-    /**
36
-     * This is used to hold the reports template data which is setup early in the request.
37
-     * @type array
38
-     */
39
-    protected $_reports_template_data = array();
40
-    
41
-    /**
42
-     * @Constructor
43
-     * @access public
44
-     *
45
-     * @param bool $routing
46
-     *
47
-     * @return \Extend_Transactions_Admin_Page
48
-     */
49
-    public function __construct($routing = true)
50
-    {
51
-        parent::__construct($routing);
52
-        define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/');
53
-        define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/');
54
-        define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/');
55
-    }
56
-    
57
-    
58
-    /**
59
-     *    _extend_page_config
60
-     *
61
-     * @access protected
62
-     * @return void
63
-     */
64
-    protected function _extend_page_config()
65
-    {
66
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions';
67
-        
68
-        $new_page_routes = array(
69
-            'reports' => array(
70
-                'func'       => '_transaction_reports',
71
-                'capability' => 'ee_read_transactions'
72
-            )
73
-        );
74
-        
75
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
76
-        
77
-        $new_page_config    = array(
78
-            'reports' => array(
79
-                'nav'           => array(
80
-                    'label' => __('Reports', 'event_espresso'),
81
-                    'order' => 20
82
-                ),
83
-                'help_tabs'     => array(
84
-                    'transactions_reports_help_tab' => array(
85
-                        'title'    => __('Transaction Reports', 'event_espresso'),
86
-                        'filename' => 'transactions_reports'
87
-                    )
88
-                ),
89
-                /*'help_tour' => array( 'Transaction_Reports_Help_Tour' ),*/
90
-                'require_nonce' => false
91
-            )
92
-        );
93
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
94
-    }
95
-    
96
-    
97
-    /**
98
-     *    load_scripts_styles_reports
99
-     *
100
-     * @access public
101
-     * @return void
102
-     */
103
-    public function load_scripts_styles_reports()
104
-    {
105
-        wp_register_script('ee-txn-reports-js', TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js',
106
-            array('google-charts'), EVENT_ESPRESSO_VERSION, true);
107
-        wp_enqueue_script('ee-txn-reports-js');
108
-        $this->_transaction_reports_js_setup();
109
-        EE_Registry::$i18n_js_strings['currency_format'] = EEH_Money::get_format_for_google_charts();
110
-    }
111
-    
112
-    
113
-    /**
114
-     * This is called when javascript is being enqueued to setup the various data needed for the reports js.
115
-     * Also $this->{$_reports_template_data} property is set for later usage by the _transaction_reports method.
116
-     */
117
-    protected function _transaction_reports_js_setup()
118
-    {
119
-        $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_day_report();
120
-        $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_event_report();
121
-    }
122
-    
123
-    
124
-    /**
125
-     * _transaction_reports
126
-     *    generates Business Reports regarding Transactions
127
-     *
128
-     * @return void
129
-     */
130
-    protected function _transaction_reports()
131
-    {
132
-        $template_path                              = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
133
-        $this->_admin_page_title                    = __('Transactions', 'event_espresso');
134
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path,
135
-            $this->_reports_template_data, true);
136
-        
137
-        // the final template wrapper
138
-        $this->display_admin_page_with_no_sidebar();
139
-    }
140
-    
141
-    
142
-    /**
143
-     * _revenue_per_day_report
144
-     * generates Business Report showing Total Revenue per Day.
145
-     *
146
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
147
-     *
148
-     * @return string
149
-     */
150
-    private function _revenue_per_day_report($period = '-1 month')
151
-    {
152
-        
153
-        $report_ID = 'txn-admin-revenue-per-day-report-dv';
154
-        
155
-        $TXN = EEM_Transaction::instance();
156
-        
157
-        $results  = $TXN->get_revenue_per_day_report($period);
158
-        $results  = (array)$results;
159
-        $revenue  = array();
160
-        $subtitle = '';
161
-        
162
-        if ($results) {
163
-            $revenue[] = array(
164
-                __('Date (only shows dates that have a revenue greater than 1)', 'event_espresso'),
165
-                __('Total Revenue', 'event_espresso')
166
-            );
167
-            foreach ($results as $result) {
168
-                $revenue[] = array($result->txnDate, (float)$result->revenue);
169
-            }
35
+	/**
36
+	 * This is used to hold the reports template data which is setup early in the request.
37
+	 * @type array
38
+	 */
39
+	protected $_reports_template_data = array();
40
+    
41
+	/**
42
+	 * @Constructor
43
+	 * @access public
44
+	 *
45
+	 * @param bool $routing
46
+	 *
47
+	 * @return \Extend_Transactions_Admin_Page
48
+	 */
49
+	public function __construct($routing = true)
50
+	{
51
+		parent::__construct($routing);
52
+		define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/');
53
+		define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/');
54
+		define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/');
55
+	}
56
+    
57
+    
58
+	/**
59
+	 *    _extend_page_config
60
+	 *
61
+	 * @access protected
62
+	 * @return void
63
+	 */
64
+	protected function _extend_page_config()
65
+	{
66
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions';
67
+        
68
+		$new_page_routes = array(
69
+			'reports' => array(
70
+				'func'       => '_transaction_reports',
71
+				'capability' => 'ee_read_transactions'
72
+			)
73
+		);
74
+        
75
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
76
+        
77
+		$new_page_config    = array(
78
+			'reports' => array(
79
+				'nav'           => array(
80
+					'label' => __('Reports', 'event_espresso'),
81
+					'order' => 20
82
+				),
83
+				'help_tabs'     => array(
84
+					'transactions_reports_help_tab' => array(
85
+						'title'    => __('Transaction Reports', 'event_espresso'),
86
+						'filename' => 'transactions_reports'
87
+					)
88
+				),
89
+				/*'help_tour' => array( 'Transaction_Reports_Help_Tour' ),*/
90
+				'require_nonce' => false
91
+			)
92
+		);
93
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
94
+	}
95
+    
96
+    
97
+	/**
98
+	 *    load_scripts_styles_reports
99
+	 *
100
+	 * @access public
101
+	 * @return void
102
+	 */
103
+	public function load_scripts_styles_reports()
104
+	{
105
+		wp_register_script('ee-txn-reports-js', TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js',
106
+			array('google-charts'), EVENT_ESPRESSO_VERSION, true);
107
+		wp_enqueue_script('ee-txn-reports-js');
108
+		$this->_transaction_reports_js_setup();
109
+		EE_Registry::$i18n_js_strings['currency_format'] = EEH_Money::get_format_for_google_charts();
110
+	}
111
+    
112
+    
113
+	/**
114
+	 * This is called when javascript is being enqueued to setup the various data needed for the reports js.
115
+	 * Also $this->{$_reports_template_data} property is set for later usage by the _transaction_reports method.
116
+	 */
117
+	protected function _transaction_reports_js_setup()
118
+	{
119
+		$this->_reports_template_data['admin_reports'][] = $this->_revenue_per_day_report();
120
+		$this->_reports_template_data['admin_reports'][] = $this->_revenue_per_event_report();
121
+	}
122
+    
123
+    
124
+	/**
125
+	 * _transaction_reports
126
+	 *    generates Business Reports regarding Transactions
127
+	 *
128
+	 * @return void
129
+	 */
130
+	protected function _transaction_reports()
131
+	{
132
+		$template_path                              = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
133
+		$this->_admin_page_title                    = __('Transactions', 'event_espresso');
134
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path,
135
+			$this->_reports_template_data, true);
136
+        
137
+		// the final template wrapper
138
+		$this->display_admin_page_with_no_sidebar();
139
+	}
140
+    
141
+    
142
+	/**
143
+	 * _revenue_per_day_report
144
+	 * generates Business Report showing Total Revenue per Day.
145
+	 *
146
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
147
+	 *
148
+	 * @return string
149
+	 */
150
+	private function _revenue_per_day_report($period = '-1 month')
151
+	{
152
+        
153
+		$report_ID = 'txn-admin-revenue-per-day-report-dv';
154
+        
155
+		$TXN = EEM_Transaction::instance();
156
+        
157
+		$results  = $TXN->get_revenue_per_day_report($period);
158
+		$results  = (array)$results;
159
+		$revenue  = array();
160
+		$subtitle = '';
161
+        
162
+		if ($results) {
163
+			$revenue[] = array(
164
+				__('Date (only shows dates that have a revenue greater than 1)', 'event_espresso'),
165
+				__('Total Revenue', 'event_espresso')
166
+			);
167
+			foreach ($results as $result) {
168
+				$revenue[] = array($result->txnDate, (float)$result->revenue);
169
+			}
170 170
             
171
-            //setup the date range.
172
-            $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
173
-            $ending_date    = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
174
-            $subtitle       = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'),
175
-                $beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d'));
176
-        }
177
-        
178
-        $report_title = esc_html__('Total Revenue per Day', 'event_espresso');
179
-        
180
-        $report_params = array(
181
-            'title'     => $report_title,
182
-            'subtitle'  => $subtitle,
183
-            'id'        => $report_ID,
184
-            'revenue'   => $revenue,
185
-            'noResults' => empty($revenue) || count($revenue) === 1,
186
-            'noTxnMsg'  => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'),
187
-                '<h2>' . $report_title . '</h2><p>', '</p>')
188
-        );
189
-        wp_localize_script('ee-txn-reports-js', 'txnRevPerDay', $report_params);
190
-        
191
-        return $report_ID;
192
-    }
193
-    
194
-    
195
-    /**
196
-     * _revenue_per_event_report
197
-     * generates Business Report showing total revenue per event.
198
-     *
199
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
200
-     *
201
-     * @return int
202
-     */
203
-    private function _revenue_per_event_report($period = '-1 month')
204
-    {
205
-        
206
-        $report_ID = 'txn-admin-revenue-per-event-report-dv';
207
-        
208
-        $TXN      = EEM_Transaction::instance();
209
-        $results  = $TXN->get_revenue_per_event_report($period);
210
-        $results  = (array)$results;
211
-        $revenue  = array();
212
-        $subtitle = '';
213
-        
214
-        if ($results) {
215
-            $revenue[] = array(
216
-                __('Event (only events that have a revenue greater than 1 are shown)', 'event_espresso'),
217
-                __('Total Revenue', 'event_espresso')
218
-            );
219
-            foreach ($results as $result) {
220
-                if ($result->revenue > 1) {
221
-                    $event_name = stripslashes(html_entity_decode($result->event_name, ENT_QUOTES, 'UTF-8'));
222
-                    $event_name = wp_trim_words($event_name, 5, '...');
223
-                    $revenue[]  = array($event_name, (float)$result->revenue);
224
-                }
225
-            }
171
+			//setup the date range.
172
+			$beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
173
+			$ending_date    = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
174
+			$subtitle       = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'),
175
+				$beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d'));
176
+		}
177
+        
178
+		$report_title = esc_html__('Total Revenue per Day', 'event_espresso');
179
+        
180
+		$report_params = array(
181
+			'title'     => $report_title,
182
+			'subtitle'  => $subtitle,
183
+			'id'        => $report_ID,
184
+			'revenue'   => $revenue,
185
+			'noResults' => empty($revenue) || count($revenue) === 1,
186
+			'noTxnMsg'  => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'),
187
+				'<h2>' . $report_title . '</h2><p>', '</p>')
188
+		);
189
+		wp_localize_script('ee-txn-reports-js', 'txnRevPerDay', $report_params);
190
+        
191
+		return $report_ID;
192
+	}
193
+    
194
+    
195
+	/**
196
+	 * _revenue_per_event_report
197
+	 * generates Business Report showing total revenue per event.
198
+	 *
199
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
200
+	 *
201
+	 * @return int
202
+	 */
203
+	private function _revenue_per_event_report($period = '-1 month')
204
+	{
205
+        
206
+		$report_ID = 'txn-admin-revenue-per-event-report-dv';
207
+        
208
+		$TXN      = EEM_Transaction::instance();
209
+		$results  = $TXN->get_revenue_per_event_report($period);
210
+		$results  = (array)$results;
211
+		$revenue  = array();
212
+		$subtitle = '';
213
+        
214
+		if ($results) {
215
+			$revenue[] = array(
216
+				__('Event (only events that have a revenue greater than 1 are shown)', 'event_espresso'),
217
+				__('Total Revenue', 'event_espresso')
218
+			);
219
+			foreach ($results as $result) {
220
+				if ($result->revenue > 1) {
221
+					$event_name = stripslashes(html_entity_decode($result->event_name, ENT_QUOTES, 'UTF-8'));
222
+					$event_name = wp_trim_words($event_name, 5, '...');
223
+					$revenue[]  = array($event_name, (float)$result->revenue);
224
+				}
225
+			}
226 226
             
227
-            //setup the date range.
228
-            $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
229
-            $ending_date    = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
230
-            $subtitle       = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'),
231
-                $beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d'));
232
-        }
233
-        
234
-        $report_title = esc_html__('Total Revenue per Event', 'event_espresso');
235
-        
236
-        $report_params = array(
237
-            'title'     => $report_title,
238
-            'subtitle'  => $subtitle,
239
-            'id'        => $report_ID,
240
-            'revenue'   => $revenue,
241
-            'noResults' => empty($revenue),
242
-            'noTxnMsg'  => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'),
243
-                '<h2>' . $report_title . '</h2><p>', '</p>')
244
-        );
245
-        wp_localize_script('ee-txn-reports-js', 'txnRevPerEvent', $report_params);
246
-        
247
-        return $report_ID;
248
-    }
227
+			//setup the date range.
228
+			$beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
229
+			$ending_date    = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
230
+			$subtitle       = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'),
231
+				$beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d'));
232
+		}
233
+        
234
+		$report_title = esc_html__('Total Revenue per Event', 'event_espresso');
235
+        
236
+		$report_params = array(
237
+			'title'     => $report_title,
238
+			'subtitle'  => $subtitle,
239
+			'id'        => $report_ID,
240
+			'revenue'   => $revenue,
241
+			'noResults' => empty($revenue),
242
+			'noTxnMsg'  => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'),
243
+				'<h2>' . $report_title . '</h2><p>', '</p>')
244
+		);
245
+		wp_localize_script('ee-txn-reports-js', 'txnRevPerEvent', $report_params);
246
+        
247
+		return $report_ID;
248
+	}
249 249
     
250 250
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
     public function __construct($routing = true)
50 50
     {
51 51
         parent::__construct($routing);
52
-        define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/');
53
-        define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/');
54
-        define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/');
52
+        define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'transactions/templates/');
53
+        define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'transactions/assets/');
54
+        define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'transactions/assets/');
55 55
     }
56 56
     
57 57
     
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      */
64 64
     protected function _extend_page_config()
65 65
     {
66
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions';
66
+        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'transactions';
67 67
         
68 68
         $new_page_routes = array(
69 69
             'reports' => array(
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      */
103 103
     public function load_scripts_styles_reports()
104 104
     {
105
-        wp_register_script('ee-txn-reports-js', TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js',
105
+        wp_register_script('ee-txn-reports-js', TXN_CAF_ASSETS_URL.'ee-transaction-admin-reports.js',
106 106
             array('google-charts'), EVENT_ESPRESSO_VERSION, true);
107 107
         wp_enqueue_script('ee-txn-reports-js');
108 108
         $this->_transaction_reports_js_setup();
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
      */
130 130
     protected function _transaction_reports()
131 131
     {
132
-        $template_path                              = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
132
+        $template_path                              = EE_ADMIN_TEMPLATE.'admin_reports.template.php';
133 133
         $this->_admin_page_title                    = __('Transactions', 'event_espresso');
134 134
         $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path,
135 135
             $this->_reports_template_data, true);
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         $TXN = EEM_Transaction::instance();
156 156
         
157 157
         $results  = $TXN->get_revenue_per_day_report($period);
158
-        $results  = (array)$results;
158
+        $results  = (array) $results;
159 159
         $revenue  = array();
160 160
         $subtitle = '';
161 161
         
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
                 __('Total Revenue', 'event_espresso')
166 166
             );
167 167
             foreach ($results as $result) {
168
-                $revenue[] = array($result->txnDate, (float)$result->revenue);
168
+                $revenue[] = array($result->txnDate, (float) $result->revenue);
169 169
             }
170 170
             
171 171
             //setup the date range.
172
-            $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
172
+            $beginning_date = new DateTime('now'.$period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
173 173
             $ending_date    = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
174 174
             $subtitle       = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'),
175 175
                 $beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d'));
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
             'revenue'   => $revenue,
185 185
             'noResults' => empty($revenue) || count($revenue) === 1,
186 186
             'noTxnMsg'  => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'),
187
-                '<h2>' . $report_title . '</h2><p>', '</p>')
187
+                '<h2>'.$report_title.'</h2><p>', '</p>')
188 188
         );
189 189
         wp_localize_script('ee-txn-reports-js', 'txnRevPerDay', $report_params);
190 190
         
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
         
208 208
         $TXN      = EEM_Transaction::instance();
209 209
         $results  = $TXN->get_revenue_per_event_report($period);
210
-        $results  = (array)$results;
210
+        $results  = (array) $results;
211 211
         $revenue  = array();
212 212
         $subtitle = '';
213 213
         
@@ -220,12 +220,12 @@  discard block
 block discarded – undo
220 220
                 if ($result->revenue > 1) {
221 221
                     $event_name = stripslashes(html_entity_decode($result->event_name, ENT_QUOTES, 'UTF-8'));
222 222
                     $event_name = wp_trim_words($event_name, 5, '...');
223
-                    $revenue[]  = array($event_name, (float)$result->revenue);
223
+                    $revenue[]  = array($event_name, (float) $result->revenue);
224 224
                 }
225 225
             }
226 226
             
227 227
             //setup the date range.
228
-            $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
228
+            $beginning_date = new DateTime('now'.$period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
229 229
             $ending_date    = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
230 230
             $subtitle       = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'),
231 231
                 $beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d'));
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
             'revenue'   => $revenue,
241 241
             'noResults' => empty($revenue),
242 242
             'noTxnMsg'  => sprintf(__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso'),
243
-                '<h2>' . $report_title . '</h2><p>', '</p>')
243
+                '<h2>'.$report_title.'</h2><p>', '</p>')
244 244
         );
245 245
         wp_localize_script('ee-txn-reports-js', 'txnRevPerEvent', $report_params);
246 246
         
Please login to merge, or discard this patch.
core/db_models/EEM_Transaction.model.php 2 patches
Indentation   +296 added lines, -296 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 require_once(EE_MODELS . 'EEM_Base.model.php');
5 5
 
@@ -15,192 +15,192 @@  discard block
 block discarded – undo
15 15
 class EEM_Transaction extends EEM_Base
16 16
 {
17 17
     
18
-    // private instance of the Transaction object
19
-    protected static $_instance;
18
+	// private instance of the Transaction object
19
+	protected static $_instance;
20 20
     
21
-    /**
22
-     * Status ID(STS_ID on esp_status table) to indicate the transaction is complete,
23
-     * but payment is pending. This is the state for transactions where payment is promised
24
-     * from an offline gateway.
25
-     */
26
-    //	const open_status_code = 'TPN';
21
+	/**
22
+	 * Status ID(STS_ID on esp_status table) to indicate the transaction is complete,
23
+	 * but payment is pending. This is the state for transactions where payment is promised
24
+	 * from an offline gateway.
25
+	 */
26
+	//	const open_status_code = 'TPN';
27 27
     
28
-    /**
29
-     * Status ID(STS_ID on esp_status table) to indicate the transaction failed,
30
-     * either due to a technical reason (server or computer crash during registration),
31
-     *  or some other reason that prevent the collection of any useful contact information from any of the registrants
32
-     */
33
-    const failed_status_code = 'TFL';
28
+	/**
29
+	 * Status ID(STS_ID on esp_status table) to indicate the transaction failed,
30
+	 * either due to a technical reason (server or computer crash during registration),
31
+	 *  or some other reason that prevent the collection of any useful contact information from any of the registrants
32
+	 */
33
+	const failed_status_code = 'TFL';
34 34
     
35
-    /**
36
-     * Status ID(STS_ID on esp_status table) to indicate the transaction was abandoned,
37
-     * either due to a technical reason (server or computer crash during registration),
38
-     * or due to an abandoned cart after registrant chose not to complete the registration process
39
-     * HOWEVER...
40
-     * an abandoned TXN differs from a failed TXN in that it was able to capture contact information for at least one
41
-     * registrant
42
-     */
43
-    const abandoned_status_code = 'TAB';
35
+	/**
36
+	 * Status ID(STS_ID on esp_status table) to indicate the transaction was abandoned,
37
+	 * either due to a technical reason (server or computer crash during registration),
38
+	 * or due to an abandoned cart after registrant chose not to complete the registration process
39
+	 * HOWEVER...
40
+	 * an abandoned TXN differs from a failed TXN in that it was able to capture contact information for at least one
41
+	 * registrant
42
+	 */
43
+	const abandoned_status_code = 'TAB';
44 44
     
45
-    /**
46
-     * Status ID(STS_ID on esp_status table) to indicate an incomplete transaction,
47
-     * meaning that monies are still owing: TXN_paid < TXN_total
48
-     */
49
-    const incomplete_status_code = 'TIN';
45
+	/**
46
+	 * Status ID(STS_ID on esp_status table) to indicate an incomplete transaction,
47
+	 * meaning that monies are still owing: TXN_paid < TXN_total
48
+	 */
49
+	const incomplete_status_code = 'TIN';
50 50
     
51
-    /**
52
-     * Status ID (STS_ID on esp_status table) to indicate a complete transaction.
53
-     * meaning that NO monies are owing: TXN_paid == TXN_total
54
-     */
55
-    const complete_status_code = 'TCM';
51
+	/**
52
+	 * Status ID (STS_ID on esp_status table) to indicate a complete transaction.
53
+	 * meaning that NO monies are owing: TXN_paid == TXN_total
54
+	 */
55
+	const complete_status_code = 'TCM';
56 56
     
57
-    /**
58
-     *  Status ID(STS_ID on esp_status table) to indicate the transaction is overpaid.
59
-     *  This is the same as complete, but site admins actually owe clients the moneys!  TXN_paid > TXN_total
60
-     */
61
-    const overpaid_status_code = 'TOP';
57
+	/**
58
+	 *  Status ID(STS_ID on esp_status table) to indicate the transaction is overpaid.
59
+	 *  This is the same as complete, but site admins actually owe clients the moneys!  TXN_paid > TXN_total
60
+	 */
61
+	const overpaid_status_code = 'TOP';
62 62
     
63 63
     
64
-    /**
65
-     *    private constructor to prevent direct creation
66
-     *
67
-     * @Constructor
68
-     * @access protected
69
-     *
70
-     * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any
71
-     *                         incoming timezone data that gets saved). Note this just sends the timezone info to the
72
-     *                         date time model field objects.  Default is NULL (and will be assumed using the set
73
-     *                         timezone in the 'timezone_string' wp option)
74
-     *
75
-     * @return EEM_Transaction
76
-     * @throws \EE_Error
77
-     */
78
-    protected function __construct($timezone)
79
-    {
80
-        $this->singular_item = __('Transaction', 'event_espresso');
81
-        $this->plural_item   = __('Transactions', 'event_espresso');
64
+	/**
65
+	 *    private constructor to prevent direct creation
66
+	 *
67
+	 * @Constructor
68
+	 * @access protected
69
+	 *
70
+	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any
71
+	 *                         incoming timezone data that gets saved). Note this just sends the timezone info to the
72
+	 *                         date time model field objects.  Default is NULL (and will be assumed using the set
73
+	 *                         timezone in the 'timezone_string' wp option)
74
+	 *
75
+	 * @return EEM_Transaction
76
+	 * @throws \EE_Error
77
+	 */
78
+	protected function __construct($timezone)
79
+	{
80
+		$this->singular_item = __('Transaction', 'event_espresso');
81
+		$this->plural_item   = __('Transactions', 'event_espresso');
82 82
         
83
-        $this->_tables                 = array(
84
-            'TransactionTable' => new EE_Primary_Table('esp_transaction', 'TXN_ID')
85
-        );
86
-        $this->_fields                 = array(
87
-            'TransactionTable' => array(
88
-                'TXN_ID'           => new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')),
89
-                'TXN_timestamp'    => new EE_Datetime_Field('TXN_timestamp',
90
-                    __('date when transaction was created', 'event_espresso'), false, EE_Datetime_Field::now,
91
-                    $timezone),
92
-                'TXN_total'        => new EE_Money_Field('TXN_total',
93
-                    __('Total value of Transaction', 'event_espresso'), false, 0),
94
-                'TXN_paid'         => new EE_Money_Field('TXN_paid',
95
-                    __('Amount paid towards transaction to date', 'event_espresso'), false, 0),
96
-                'STS_ID'           => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'),
97
-                    false, EEM_Transaction::failed_status_code, 'Status'),
98
-                'TXN_session_data' => new EE_Serialized_Text_Field('TXN_session_data',
99
-                    __('Serialized session data', 'event_espresso'), true, ''),
100
-                'TXN_hash_salt'    => new EE_Plain_Text_Field('TXN_hash_salt',
101
-                    __('Transaction Hash Salt', 'event_espresso'), true, ''),
102
-                'PMD_ID'           => new EE_Foreign_Key_Int_Field('PMD_ID',
103
-                    __("Last Used Payment Method", 'event_espresso'), true, null, 'Payment_Method'),
104
-                'TXN_reg_steps'    => new EE_Serialized_Text_Field('TXN_reg_steps',
105
-                    __('Registration Steps', 'event_espresso'), false, array()),
106
-            )
107
-        );
108
-        $this->_model_relations        = array(
109
-            'Registration'   => new EE_Has_Many_Relation(),
110
-            'Payment'        => new EE_Has_Many_Relation(),
111
-            'Status'         => new EE_Belongs_To_Relation(),
112
-            'Line_Item'      => new EE_Has_Many_Relation(false),
113
-            //you can delete a transaction without needing to delete its line items
114
-            'Payment_Method' => new EE_Belongs_To_Relation(),
115
-            'Message'        => new EE_Has_Many_Relation()
116
-        );
117
-        $this->_model_chain_to_wp_user = 'Registration.Event';
118
-        parent::__construct($timezone);
83
+		$this->_tables                 = array(
84
+			'TransactionTable' => new EE_Primary_Table('esp_transaction', 'TXN_ID')
85
+		);
86
+		$this->_fields                 = array(
87
+			'TransactionTable' => array(
88
+				'TXN_ID'           => new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')),
89
+				'TXN_timestamp'    => new EE_Datetime_Field('TXN_timestamp',
90
+					__('date when transaction was created', 'event_espresso'), false, EE_Datetime_Field::now,
91
+					$timezone),
92
+				'TXN_total'        => new EE_Money_Field('TXN_total',
93
+					__('Total value of Transaction', 'event_espresso'), false, 0),
94
+				'TXN_paid'         => new EE_Money_Field('TXN_paid',
95
+					__('Amount paid towards transaction to date', 'event_espresso'), false, 0),
96
+				'STS_ID'           => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'),
97
+					false, EEM_Transaction::failed_status_code, 'Status'),
98
+				'TXN_session_data' => new EE_Serialized_Text_Field('TXN_session_data',
99
+					__('Serialized session data', 'event_espresso'), true, ''),
100
+				'TXN_hash_salt'    => new EE_Plain_Text_Field('TXN_hash_salt',
101
+					__('Transaction Hash Salt', 'event_espresso'), true, ''),
102
+				'PMD_ID'           => new EE_Foreign_Key_Int_Field('PMD_ID',
103
+					__("Last Used Payment Method", 'event_espresso'), true, null, 'Payment_Method'),
104
+				'TXN_reg_steps'    => new EE_Serialized_Text_Field('TXN_reg_steps',
105
+					__('Registration Steps', 'event_espresso'), false, array()),
106
+			)
107
+		);
108
+		$this->_model_relations        = array(
109
+			'Registration'   => new EE_Has_Many_Relation(),
110
+			'Payment'        => new EE_Has_Many_Relation(),
111
+			'Status'         => new EE_Belongs_To_Relation(),
112
+			'Line_Item'      => new EE_Has_Many_Relation(false),
113
+			//you can delete a transaction without needing to delete its line items
114
+			'Payment_Method' => new EE_Belongs_To_Relation(),
115
+			'Message'        => new EE_Has_Many_Relation()
116
+		);
117
+		$this->_model_chain_to_wp_user = 'Registration.Event';
118
+		parent::__construct($timezone);
119 119
         
120
-    }
120
+	}
121 121
     
122 122
     
123
-    /**
124
-     *    txn_status_array
125
-     * get list of transaction statuses
126
-     *
127
-     * @access public
128
-     * @return array
129
-     */
130
-    public static function txn_status_array()
131
-    {
132
-        return apply_filters(
133
-            'FHEE__EEM_Transaction__txn_status_array',
134
-            array(
135
-                EEM_Transaction::overpaid_status_code,
136
-                EEM_Transaction::complete_status_code,
137
-                EEM_Transaction::incomplete_status_code,
138
-                EEM_Transaction::abandoned_status_code,
139
-                EEM_Transaction::failed_status_code,
140
-            )
141
-        );
142
-    }
123
+	/**
124
+	 *    txn_status_array
125
+	 * get list of transaction statuses
126
+	 *
127
+	 * @access public
128
+	 * @return array
129
+	 */
130
+	public static function txn_status_array()
131
+	{
132
+		return apply_filters(
133
+			'FHEE__EEM_Transaction__txn_status_array',
134
+			array(
135
+				EEM_Transaction::overpaid_status_code,
136
+				EEM_Transaction::complete_status_code,
137
+				EEM_Transaction::incomplete_status_code,
138
+				EEM_Transaction::abandoned_status_code,
139
+				EEM_Transaction::failed_status_code,
140
+			)
141
+		);
142
+	}
143 143
     
144
-    /**
145
-     *        get the revenue per day  for the Transaction Admin page Reports Tab
146
-     *
147
-     * @access        public
148
-     *
149
-     * @param string $period
150
-     *
151
-     * @return \stdClass[]
152
-     */
153
-    public function get_revenue_per_day_report($period = '-1 month')
154
-    {
155
-        $sql_date = $this->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', strtotime($period)),
156
-            'Y-m-d H:i:s', 'UTC');
144
+	/**
145
+	 *        get the revenue per day  for the Transaction Admin page Reports Tab
146
+	 *
147
+	 * @access        public
148
+	 *
149
+	 * @param string $period
150
+	 *
151
+	 * @return \stdClass[]
152
+	 */
153
+	public function get_revenue_per_day_report($period = '-1 month')
154
+	{
155
+		$sql_date = $this->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', strtotime($period)),
156
+			'Y-m-d H:i:s', 'UTC');
157 157
         
158
-        $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'TXN_timestamp');
158
+		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'TXN_timestamp');
159 159
         
160
-        return $this->_get_all_wpdb_results(
161
-            array(
162
-                array(
163
-                    'TXN_timestamp' => array('>=', $sql_date)
164
-                ),
165
-                'group_by' => 'txnDate',
166
-                'order_by' => array('TXN_timestamp' => 'ASC')
167
-            ),
168
-            OBJECT,
169
-            array(
170
-                'txnDate' => array('DATE(' . $query_interval . ')', '%s'),
171
-                'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d')
172
-            )
173
-        );
174
-    }
160
+		return $this->_get_all_wpdb_results(
161
+			array(
162
+				array(
163
+					'TXN_timestamp' => array('>=', $sql_date)
164
+				),
165
+				'group_by' => 'txnDate',
166
+				'order_by' => array('TXN_timestamp' => 'ASC')
167
+			),
168
+			OBJECT,
169
+			array(
170
+				'txnDate' => array('DATE(' . $query_interval . ')', '%s'),
171
+				'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d')
172
+			)
173
+		);
174
+	}
175 175
     
176 176
     
177
-    /**
178
-     *        get the revenue per event  for the Transaction Admin page Reports Tab
179
-     *
180
-     * @access        public
181
-     *
182
-     * @param string $period
183
-     *
184
-     * @throws \EE_Error
185
-     * @return mixed
186
-     */
187
-    public function get_revenue_per_event_report($period = '-1 month')
188
-    {
189
-        global $wpdb;
190
-        $transaction_table       = $wpdb->prefix . 'esp_transaction';
191
-        $registration_table      = $wpdb->prefix . 'esp_registration';
192
-        $event_table             = $wpdb->posts;
193
-        $payment_table           = $wpdb->prefix . 'esp_payment';
194
-        $sql_date                = date('Y-m-d H:i:s', strtotime($period));
195
-        $approved_payment_status = EEM_Payment::status_id_approved;
196
-        $extra_event_on_join     = '';
197
-        //exclude events not authored by user if permissions in effect
198
-        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
199
-            $extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id();
200
-        }
177
+	/**
178
+	 *        get the revenue per event  for the Transaction Admin page Reports Tab
179
+	 *
180
+	 * @access        public
181
+	 *
182
+	 * @param string $period
183
+	 *
184
+	 * @throws \EE_Error
185
+	 * @return mixed
186
+	 */
187
+	public function get_revenue_per_event_report($period = '-1 month')
188
+	{
189
+		global $wpdb;
190
+		$transaction_table       = $wpdb->prefix . 'esp_transaction';
191
+		$registration_table      = $wpdb->prefix . 'esp_registration';
192
+		$event_table             = $wpdb->posts;
193
+		$payment_table           = $wpdb->prefix . 'esp_payment';
194
+		$sql_date                = date('Y-m-d H:i:s', strtotime($period));
195
+		$approved_payment_status = EEM_Payment::status_id_approved;
196
+		$extra_event_on_join     = '';
197
+		//exclude events not authored by user if permissions in effect
198
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
199
+			$extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id();
200
+		}
201 201
         
202
-        return $wpdb->get_results(
203
-            "SELECT
202
+		return $wpdb->get_results(
203
+			"SELECT
204 204
 			Transaction_Event.event_name AS event_name,
205 205
 			SUM(Transaction_Event.paid) AS revenue
206 206
 			FROM
@@ -220,151 +220,151 @@  discard block
 block discarded – undo
220 220
 							$extra_event_on_join
221 221
 				) AS Transaction_Event
222 222
 			GROUP BY event_name",
223
-            OBJECT
224
-        );
225
-    }
223
+			OBJECT
224
+		);
225
+	}
226 226
     
227 227
     
228
-    /**
229
-     * Gets the current transaction given the reg_url_link, or assumes the reg_url_link is in the
230
-     * $_REQUEST global variable. Either way, tries to find the current transaction (through
231
-     * the registration pointed to by reg_url_link), if not returns null
232
-     *
233
-     * @param string $reg_url_link
234
-     *
235
-     * @return EE_Transaction
236
-     */
237
-    public function get_transaction_from_reg_url_link($reg_url_link = '')
238
-    {
239
-        return $this->get_one(array(
240
-            array(
241
-                'Registration.REG_url_link' => ! empty($reg_url_link) ? $reg_url_link : EE_Registry::instance()->REQ->get('e_reg_url_link',
242
-                    '')
243
-            )
244
-        ));
245
-    }
228
+	/**
229
+	 * Gets the current transaction given the reg_url_link, or assumes the reg_url_link is in the
230
+	 * $_REQUEST global variable. Either way, tries to find the current transaction (through
231
+	 * the registration pointed to by reg_url_link), if not returns null
232
+	 *
233
+	 * @param string $reg_url_link
234
+	 *
235
+	 * @return EE_Transaction
236
+	 */
237
+	public function get_transaction_from_reg_url_link($reg_url_link = '')
238
+	{
239
+		return $this->get_one(array(
240
+			array(
241
+				'Registration.REG_url_link' => ! empty($reg_url_link) ? $reg_url_link : EE_Registry::instance()->REQ->get('e_reg_url_link',
242
+					'')
243
+			)
244
+		));
245
+	}
246 246
     
247 247
     
248
-    /**
249
-     * Updates the provided EE_Transaction with all the applicable payments
250
-     * (or fetch the EE_Transaction from its ID)
251
-     *
252
-     * @deprecated
253
-     *
254
-     * @param EE_Transaction|int $transaction_obj_or_id
255
-     * @param boolean            $save_txn whether or not to save the transaction during this function call
256
-     *
257
-     * @return boolean
258
-     * @throws \EE_Error
259
-     */
260
-    public function update_based_on_payments($transaction_obj_or_id, $save_txn = true)
261
-    {
262
-        EE_Error::doing_it_wrong(
263
-            __CLASS__ . '::' . __FUNCTION__,
264
-            sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
265
-                'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'),
266
-            '4.6.0'
267
-        );
268
-        /** @type EE_Transaction_Processor $transaction_processor */
269
-        $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
248
+	/**
249
+	 * Updates the provided EE_Transaction with all the applicable payments
250
+	 * (or fetch the EE_Transaction from its ID)
251
+	 *
252
+	 * @deprecated
253
+	 *
254
+	 * @param EE_Transaction|int $transaction_obj_or_id
255
+	 * @param boolean            $save_txn whether or not to save the transaction during this function call
256
+	 *
257
+	 * @return boolean
258
+	 * @throws \EE_Error
259
+	 */
260
+	public function update_based_on_payments($transaction_obj_or_id, $save_txn = true)
261
+	{
262
+		EE_Error::doing_it_wrong(
263
+			__CLASS__ . '::' . __FUNCTION__,
264
+			sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
265
+				'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'),
266
+			'4.6.0'
267
+		);
268
+		/** @type EE_Transaction_Processor $transaction_processor */
269
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
270 270
         
271
-        return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment(
272
-            $this->ensure_is_obj($transaction_obj_or_id)
273
-        );
274
-    }
271
+		return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment(
272
+			$this->ensure_is_obj($transaction_obj_or_id)
273
+		);
274
+	}
275 275
     
276
-    /**
277
-     * Deletes "junk" transactions that were probably added by bots. There might be TONS
278
-     * of these, so we are very careful to NOT select (which the models do even when deleting),
279
-     * and so we only use wpdb directly and NOT do any joins.
280
-     * The downside to this approach is that is addons are listening for object deletions
281
-     * on EEM_Base::delete() they won't be notified of this.
282
-     * @global WPDB $wpdb
283
-     * @return mixed
284
-     */
285
-    public function delete_junk_transactions()
286
-    {
287
-        /** @type WPDB $wpdb */
288
-        global $wpdb;
289
-        $deleted             = false;
290
-        $time_to_leave_alone = apply_filters(
291
-            'FHEE__EEM_Transaction__delete_junk_transactions__time_to_leave_alone', WEEK_IN_SECONDS
292
-        );
276
+	/**
277
+	 * Deletes "junk" transactions that were probably added by bots. There might be TONS
278
+	 * of these, so we are very careful to NOT select (which the models do even when deleting),
279
+	 * and so we only use wpdb directly and NOT do any joins.
280
+	 * The downside to this approach is that is addons are listening for object deletions
281
+	 * on EEM_Base::delete() they won't be notified of this.
282
+	 * @global WPDB $wpdb
283
+	 * @return mixed
284
+	 */
285
+	public function delete_junk_transactions()
286
+	{
287
+		/** @type WPDB $wpdb */
288
+		global $wpdb;
289
+		$deleted             = false;
290
+		$time_to_leave_alone = apply_filters(
291
+			'FHEE__EEM_Transaction__delete_junk_transactions__time_to_leave_alone', WEEK_IN_SECONDS
292
+		);
293 293
         
294 294
         
295
-        /**
296
-         * This allows code to filter the query arguments used for retrieving the transaction IDs to delete.
297
-         * Useful for plugins that want to exclude transactions matching certain query parameters.
298
-         * The query parameters should be in the format accepted by the EEM_Base model queries.
299
-         */
300
-        $ids_query = apply_filters(
301
-            'FHEE__EEM_Transaction__delete_junk_transactions__initial_query_args',
302
-            array(
303
-                0 => array(
304
-                    'STS_ID'        => EEM_Transaction::failed_status_code,
305
-                    'TXN_timestamp' => array('<', time() - $time_to_leave_alone)
306
-                )
307
-            ),
308
-            $time_to_leave_alone
309
-        );
295
+		/**
296
+		 * This allows code to filter the query arguments used for retrieving the transaction IDs to delete.
297
+		 * Useful for plugins that want to exclude transactions matching certain query parameters.
298
+		 * The query parameters should be in the format accepted by the EEM_Base model queries.
299
+		 */
300
+		$ids_query = apply_filters(
301
+			'FHEE__EEM_Transaction__delete_junk_transactions__initial_query_args',
302
+			array(
303
+				0 => array(
304
+					'STS_ID'        => EEM_Transaction::failed_status_code,
305
+					'TXN_timestamp' => array('<', time() - $time_to_leave_alone)
306
+				)
307
+			),
308
+			$time_to_leave_alone
309
+		);
310 310
         
311 311
         
312
-        /**
313
-         * This filter is for when code needs to filter the list of transaction ids that represent transactions
314
-         * about to be deleted based on some other criteria that isn't easily done via the query args filter.
315
-         */
316
-        $txn_ids = apply_filters(
317
-            'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete',
318
-            EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'),
319
-            $time_to_leave_alone
320
-        );
321
-        //now that we have the ids to delete
322
-        if ( ! empty($txn_ids) && is_array($txn_ids)) {
323
-            // first, make sure these TXN's are removed the "ee_locked_transactions" array
324
-            EEM_Transaction::unset_locked_transactions($txn_ids);
325
-            // let's get deletin'...
326
-            // Why no wpdb->prepare?  Because the data is trusted.
327
-            // We got the ids from the original query to get them FROM
328
-            // the db (which is sanitized) so no need to prepare them again.
329
-            $query   = '
312
+		/**
313
+		 * This filter is for when code needs to filter the list of transaction ids that represent transactions
314
+		 * about to be deleted based on some other criteria that isn't easily done via the query args filter.
315
+		 */
316
+		$txn_ids = apply_filters(
317
+			'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete',
318
+			EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'),
319
+			$time_to_leave_alone
320
+		);
321
+		//now that we have the ids to delete
322
+		if ( ! empty($txn_ids) && is_array($txn_ids)) {
323
+			// first, make sure these TXN's are removed the "ee_locked_transactions" array
324
+			EEM_Transaction::unset_locked_transactions($txn_ids);
325
+			// let's get deletin'...
326
+			// Why no wpdb->prepare?  Because the data is trusted.
327
+			// We got the ids from the original query to get them FROM
328
+			// the db (which is sanitized) so no need to prepare them again.
329
+			$query   = '
330 330
 				DELETE
331 331
 				FROM ' . $this->table() . '
332 332
 				WHERE
333 333
 					TXN_ID IN ( ' . implode(",", $txn_ids) . ')';
334
-            $deleted = $wpdb->query($query);
335
-        }
336
-        if ($deleted) {
337
-            /**
338
-             * Allows code to do something after the transactions have been deleted.
339
-             */
340
-            do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids);
341
-        }
334
+			$deleted = $wpdb->query($query);
335
+		}
336
+		if ($deleted) {
337
+			/**
338
+			 * Allows code to do something after the transactions have been deleted.
339
+			 */
340
+			do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids);
341
+		}
342 342
         
343
-        return $deleted;
344
-    }
343
+		return $deleted;
344
+	}
345 345
     
346 346
     
347
-    /**
348
-     * @param array $transaction_IDs
349
-     *
350
-     * @return bool
351
-     */
352
-    public static function unset_locked_transactions(array $transaction_IDs)
353
-    {
354
-        $locked_transactions = get_option('ee_locked_transactions', array());
355
-        $update              = false;
356
-        foreach ($transaction_IDs as $TXN_ID) {
357
-            if (isset($locked_transactions[$TXN_ID])) {
358
-                unset($locked_transactions[$TXN_ID]);
359
-                $update = true;
360
-            }
361
-        }
362
-        if ($update) {
363
-            update_option('ee_locked_transactions', $locked_transactions);
364
-        }
347
+	/**
348
+	 * @param array $transaction_IDs
349
+	 *
350
+	 * @return bool
351
+	 */
352
+	public static function unset_locked_transactions(array $transaction_IDs)
353
+	{
354
+		$locked_transactions = get_option('ee_locked_transactions', array());
355
+		$update              = false;
356
+		foreach ($transaction_IDs as $TXN_ID) {
357
+			if (isset($locked_transactions[$TXN_ID])) {
358
+				unset($locked_transactions[$TXN_ID]);
359
+				$update = true;
360
+			}
361
+		}
362
+		if ($update) {
363
+			update_option('ee_locked_transactions', $locked_transactions);
364
+		}
365 365
         
366
-        return $update;
367
-    }
366
+		return $update;
367
+	}
368 368
     
369 369
     
370 370
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2 2
     exit('No direct script access allowed');
3 3
 }
4
-require_once(EE_MODELS . 'EEM_Base.model.php');
4
+require_once(EE_MODELS.'EEM_Base.model.php');
5 5
 
6 6
 /**
7 7
  *
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
                     __('Registration Steps', 'event_espresso'), false, array()),
106 106
             )
107 107
         );
108
-        $this->_model_relations        = array(
108
+        $this->_model_relations = array(
109 109
             'Registration'   => new EE_Has_Many_Relation(),
110 110
             'Payment'        => new EE_Has_Many_Relation(),
111 111
             'Status'         => new EE_Belongs_To_Relation(),
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
             ),
168 168
             OBJECT,
169 169
             array(
170
-                'txnDate' => array('DATE(' . $query_interval . ')', '%s'),
170
+                'txnDate' => array('DATE('.$query_interval.')', '%s'),
171 171
                 'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d')
172 172
             )
173 173
         );
@@ -187,16 +187,16 @@  discard block
 block discarded – undo
187 187
     public function get_revenue_per_event_report($period = '-1 month')
188 188
     {
189 189
         global $wpdb;
190
-        $transaction_table       = $wpdb->prefix . 'esp_transaction';
191
-        $registration_table      = $wpdb->prefix . 'esp_registration';
190
+        $transaction_table       = $wpdb->prefix.'esp_transaction';
191
+        $registration_table      = $wpdb->prefix.'esp_registration';
192 192
         $event_table             = $wpdb->posts;
193
-        $payment_table           = $wpdb->prefix . 'esp_payment';
193
+        $payment_table           = $wpdb->prefix.'esp_payment';
194 194
         $sql_date                = date('Y-m-d H:i:s', strtotime($period));
195 195
         $approved_payment_status = EEM_Payment::status_id_approved;
196 196
         $extra_event_on_join     = '';
197 197
         //exclude events not authored by user if permissions in effect
198 198
         if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
199
-            $extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id();
199
+            $extra_event_on_join = ' AND Event.post_author = '.get_current_user_id();
200 200
         }
201 201
         
202 202
         return $wpdb->get_results(
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
     public function update_based_on_payments($transaction_obj_or_id, $save_txn = true)
261 261
     {
262 262
         EE_Error::doing_it_wrong(
263
-            __CLASS__ . '::' . __FUNCTION__,
263
+            __CLASS__.'::'.__FUNCTION__,
264 264
             sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
265 265
                 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'),
266 266
             '4.6.0'
@@ -326,11 +326,11 @@  discard block
 block discarded – undo
326 326
             // Why no wpdb->prepare?  Because the data is trusted.
327 327
             // We got the ids from the original query to get them FROM
328 328
             // the db (which is sanitized) so no need to prepare them again.
329
-            $query   = '
329
+            $query = '
330 330
 				DELETE
331
-				FROM ' . $this->table() . '
331
+				FROM ' . $this->table().'
332 332
 				WHERE
333
-					TXN_ID IN ( ' . implode(",", $txn_ids) . ')';
333
+					TXN_ID IN ( ' . implode(",", $txn_ids).')';
334 334
             $deleted = $wpdb->query($query);
335 335
         }
336 336
         if ($deleted) {
Please login to merge, or discard this patch.
templates/reg_admin_details_side_meta_box_registrant.template.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
     <?php if ( ! empty($create_link)) : ?>
34 34
         <a class="button button-small" href="<?php echo $create_link; ?>"
35 35
            title="<?php esc_attr_e('This registration shares the contact details for the primary registration in this group.  If you\'d like this registration to have its own details, you can do so by clicking this button',
36
-               'event_espresso'); ?>">
36
+			   'event_espresso'); ?>">
37 37
             <span class="ee-icon ee-icon-user-add-new"></span><?php echo $create_label; ?>
38 38
         </a>
39 39
     <?php endif; ?>
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
     <p class="clearfix">
3 3
         <span class="admin-side-mbox-label-spn lt-grey-txt float-left">
4 4
             <?php _e('Name', 'event_espresso'); ?>
5
-        </span><?php echo $fname . ' ' . $lname; ?>
5
+        </span><?php echo $fname.' '.$lname; ?>
6 6
     </p>
7 7
     <p class="clearfix">
8 8
         <span class="admin-side-mbox-label-spn lt-grey-txt float-left"><?php _e('Email', 'event_espresso'); ?></span><a
Please login to merge, or discard this patch.
libraries/messages/data_class/EE_Messages_Preview_incoming_data.class.php 2 patches
Indentation   +553 added lines, -553 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4
-    exit('NO direct script access allowed');
4
+	exit('NO direct script access allowed');
5 5
 }
6 6
 
7 7
 /**
@@ -24,585 +24,585 @@  discard block
 block discarded – undo
24 24
 class EE_Messages_Preview_incoming_data extends EE_Messages_incoming_data
25 25
 {
26 26
     
27
-    //some specific properties we need for this class
28
-    private $_events = array();
29
-    private $_attendees = array();
30
-    private $_registrations = array();
27
+	//some specific properties we need for this class
28
+	private $_events = array();
29
+	private $_attendees = array();
30
+	private $_registrations = array();
31 31
     
32 32
     
33
-    /**
34
-     * For the constructor of this special preview class.  We're either looking for an event id or empty data.  If we
35
-     * have an event id (or ids) then we'll use that as the source for the "dummy" data.  If the data is empty then
36
-     * we'll get the first three published events from the users database and use that as a source.
37
-     *
38
-     * @param array $data
39
-     */
40
-    public function __construct($data = array())
41
-    {
42
-        $this->_data = isset($data['event_ids']) ? $data['event_ids'] : array();
43
-        $this->_setup_attendees_events();
44
-        parent::__construct($data);
45
-    }
33
+	/**
34
+	 * For the constructor of this special preview class.  We're either looking for an event id or empty data.  If we
35
+	 * have an event id (or ids) then we'll use that as the source for the "dummy" data.  If the data is empty then
36
+	 * we'll get the first three published events from the users database and use that as a source.
37
+	 *
38
+	 * @param array $data
39
+	 */
40
+	public function __construct($data = array())
41
+	{
42
+		$this->_data = isset($data['event_ids']) ? $data['event_ids'] : array();
43
+		$this->_setup_attendees_events();
44
+		parent::__construct($data);
45
+	}
46 46
     
47 47
     
48
-    /**
49
-     * Returns database safe representation of the data later used to when instantiating this object.
50
-     *
51
-     * @param array $data The incoming data to be prepped.
52
-     *
53
-     * @return array   The prepped data for db
54
-     */
55
-    static public function convert_data_for_persistent_storage($data)
56
-    {
57
-        return $data;
58
-    }
48
+	/**
49
+	 * Returns database safe representation of the data later used to when instantiating this object.
50
+	 *
51
+	 * @param array $data The incoming data to be prepped.
52
+	 *
53
+	 * @return array   The prepped data for db
54
+	 */
55
+	static public function convert_data_for_persistent_storage($data)
56
+	{
57
+		return $data;
58
+	}
59 59
     
60 60
     
61
-    /**
62
-     * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage
63
-     * can be sent into this method and converted back into the format used for instantiating with this data handler.
64
-     *
65
-     * @param array $data
66
-     *
67
-     * @return array
68
-     */
69
-    static public function convert_data_from_persistent_storage($data)
70
-    {
71
-        return $data;
72
-    }
61
+	/**
62
+	 * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage
63
+	 * can be sent into this method and converted back into the format used for instantiating with this data handler.
64
+	 *
65
+	 * @param array $data
66
+	 *
67
+	 * @return array
68
+	 */
69
+	static public function convert_data_from_persistent_storage($data)
70
+	{
71
+		return $data;
72
+	}
73 73
     
74 74
     
75
-    /**
76
-     * This will just setup the _events property in the expected format.
77
-     *
78
-     * @throws \EE_Error
79
-     */
80
-    private function _setup_attendees_events()
81
-    {
82
-        
83
-        //setup some attendee objects
84
-        $attendees = $this->_get_some_attendees();
85
-        
86
-        //if empty $data we'll do a query to get some events from the server. otherwise we'll retrieve the event data for the given ids.
87
-        $events = $this->_get_some_events($this->_data);
88
-        
89
-        $answers_n_questions = $this->_get_some_q_and_as();
90
-        
91
-        if (count($events) < 1) {
92
-            throw new EE_Error(__('We can\'t generate a preview for you because there are no active events in your database',
93
-                'event_espresso'));
94
-        }
95
-        
96
-        
97
-        //now let's loop and set up the _events property.  At the same time we'll set up attendee properties.
98
-        
99
-        
100
-        //we'll actually use the generated line_item identifiers for our loop
101
-        $dtts = $tkts = array();
102
-        foreach ($events as $id => $event) {
103
-            if ( ! $event instanceof EE_Event) {
104
-                continue;
105
-            }
106
-            $this->_events[$id]['ID']       = $id;
107
-            $this->_events[$id]['name']     = $event->get('EVT_name');
108
-            $datetime                       = $event->get_first_related('Datetime');
109
-            $tickets                        = $datetime instanceof EE_Datetime ? $datetime->get_many_related('Ticket',
110
-                array('default_where_conditions' => 'none')) : array();
111
-            $this->_events[$id]['event']    = $event;
112
-            $this->_events[$id]['reg_objs'] = array();
113
-            $this->_events[$id]['tkt_objs'] = $tickets;
114
-            $this->_events[$id]['dtt_objs'] = array();
75
+	/**
76
+	 * This will just setup the _events property in the expected format.
77
+	 *
78
+	 * @throws \EE_Error
79
+	 */
80
+	private function _setup_attendees_events()
81
+	{
82
+        
83
+		//setup some attendee objects
84
+		$attendees = $this->_get_some_attendees();
85
+        
86
+		//if empty $data we'll do a query to get some events from the server. otherwise we'll retrieve the event data for the given ids.
87
+		$events = $this->_get_some_events($this->_data);
88
+        
89
+		$answers_n_questions = $this->_get_some_q_and_as();
90
+        
91
+		if (count($events) < 1) {
92
+			throw new EE_Error(__('We can\'t generate a preview for you because there are no active events in your database',
93
+				'event_espresso'));
94
+		}
95
+        
96
+        
97
+		//now let's loop and set up the _events property.  At the same time we'll set up attendee properties.
98
+        
99
+        
100
+		//we'll actually use the generated line_item identifiers for our loop
101
+		$dtts = $tkts = array();
102
+		foreach ($events as $id => $event) {
103
+			if ( ! $event instanceof EE_Event) {
104
+				continue;
105
+			}
106
+			$this->_events[$id]['ID']       = $id;
107
+			$this->_events[$id]['name']     = $event->get('EVT_name');
108
+			$datetime                       = $event->get_first_related('Datetime');
109
+			$tickets                        = $datetime instanceof EE_Datetime ? $datetime->get_many_related('Ticket',
110
+				array('default_where_conditions' => 'none')) : array();
111
+			$this->_events[$id]['event']    = $event;
112
+			$this->_events[$id]['reg_objs'] = array();
113
+			$this->_events[$id]['tkt_objs'] = $tickets;
114
+			$this->_events[$id]['dtt_objs'] = array();
115 115
             
116
-            $dttcache = array();
117
-            $tkts     = array();
118
-            foreach ($tickets as $ticket) {
119
-                if ( ! $ticket instanceof EE_Ticket) {
120
-                    continue;
121
-                }
122
-                $reldatetime                     = $ticket->datetimes();
123
-                $tkts[$ticket->ID()]             = array();
124
-                $tkts[$ticket->ID()]['ticket']   = $ticket;
125
-                $tkts[$ticket->ID()]['dtt_objs'] = $reldatetime;
126
-                $tkts[$ticket->ID()]['att_objs'] = $attendees;
127
-                $tkts[$ticket->ID()]['count']    = count($attendees);
128
-                $tkts[$ticket->ID()]['EE_Event'] = $event;
129
-                foreach ($reldatetime as $datetime) {
130
-                    if ($datetime instanceof EE_Datetime && ! isset($dtts[$datetime->ID()])) {
131
-                        $this->_events[$id]['dtt_objs'][$datetime->ID()] = $datetime;
132
-                        $dtts[$datetime->ID()]['datetime']               = $datetime;
133
-                        $dtts[$datetime->ID()]['tkt_objs'][]             = $ticket;
134
-                        $dtts[$datetime->ID()]['evt_objs'][]             = $event;
135
-                        $dttcache[$datetime->ID()]                       = $datetime;
136
-                    }
137
-                }
138
-            }
116
+			$dttcache = array();
117
+			$tkts     = array();
118
+			foreach ($tickets as $ticket) {
119
+				if ( ! $ticket instanceof EE_Ticket) {
120
+					continue;
121
+				}
122
+				$reldatetime                     = $ticket->datetimes();
123
+				$tkts[$ticket->ID()]             = array();
124
+				$tkts[$ticket->ID()]['ticket']   = $ticket;
125
+				$tkts[$ticket->ID()]['dtt_objs'] = $reldatetime;
126
+				$tkts[$ticket->ID()]['att_objs'] = $attendees;
127
+				$tkts[$ticket->ID()]['count']    = count($attendees);
128
+				$tkts[$ticket->ID()]['EE_Event'] = $event;
129
+				foreach ($reldatetime as $datetime) {
130
+					if ($datetime instanceof EE_Datetime && ! isset($dtts[$datetime->ID()])) {
131
+						$this->_events[$id]['dtt_objs'][$datetime->ID()] = $datetime;
132
+						$dtts[$datetime->ID()]['datetime']               = $datetime;
133
+						$dtts[$datetime->ID()]['tkt_objs'][]             = $ticket;
134
+						$dtts[$datetime->ID()]['evt_objs'][]             = $event;
135
+						$dttcache[$datetime->ID()]                       = $datetime;
136
+					}
137
+				}
138
+			}
139 139
             
140
-            $this->_events[$id]['total_attendees'] = count($attendees);
141
-            $this->_events[$id]['att_objs']        = $attendees;
140
+			$this->_events[$id]['total_attendees'] = count($attendees);
141
+			$this->_events[$id]['att_objs']        = $attendees;
142 142
             
143
-            //let's also setup the dummy attendees property!
144
-            foreach ($attendees as $att_key => $attendee) {
145
-                if ( ! $attendee instanceof EE_Attendee) {
146
-                    continue;
147
-                }
148
-                $this->_attendees[$att_key]['line_ref'][] = $id;  //so later it can be determined what events this attendee registered for!
149
-                $this->_attendees[$att_key]['evt_objs'][] = $event;
150
-                $this->_attendees[$att_key]['att_obj']    = $attendee;
151
-                //$this->_attendees[$att_key]['registration_id'] = 0;
152
-                $this->_attendees[$att_key]['attendee_email'] = $attendee->email();
153
-                $this->_attendees[$att_key]['tkt_objs']       = $tickets;
154
-                if ($att_key == 999999991) {
155
-                    $this->_attendees[$att_key]['ans_objs'][999]  = $answers_n_questions['answers'][999];
156
-                    $this->_attendees[$att_key]['ans_objs'][1002] = $answers_n_questions['answers'][1002];
157
-                    $this->_attendees[$att_key]['ans_objs'][1005] = $answers_n_questions['answers'][1005];
158
-                } elseif ($att_key == 999999992) {
159
-                    $this->_attendees[$att_key]['ans_objs'][1000] = $answers_n_questions['answers'][1000];
160
-                    $this->_attendees[$att_key]['ans_objs'][1003] = $answers_n_questions['answers'][1003];
161
-                    $this->_attendees[$att_key]['ans_objs'][1006] = $answers_n_questions['answers'][1006];
162
-                } elseif ($att_key == 999999993) {
163
-                    $this->_attendees[$att_key]['ans_objs'][1001] = $answers_n_questions['answers'][1001];
164
-                    $this->_attendees[$att_key]['ans_objs'][1004] = $answers_n_questions['answers'][1004];
165
-                    $this->_attendees[$att_key]['ans_objs'][1007] = $answers_n_questions['answers'][1007];
166
-                }
167
-            }
168
-        }
169
-        
170
-        $this->tickets            = $tkts;
171
-        $this->datetimes          = $dtts;
172
-        $this->answers            = $answers_n_questions['answers'];
173
-        $this->questions          = $answers_n_questions['questions'];
174
-        $this->total_ticket_count = count($tkts) * count($this->_attendees);
175
-        
176
-    }
143
+			//let's also setup the dummy attendees property!
144
+			foreach ($attendees as $att_key => $attendee) {
145
+				if ( ! $attendee instanceof EE_Attendee) {
146
+					continue;
147
+				}
148
+				$this->_attendees[$att_key]['line_ref'][] = $id;  //so later it can be determined what events this attendee registered for!
149
+				$this->_attendees[$att_key]['evt_objs'][] = $event;
150
+				$this->_attendees[$att_key]['att_obj']    = $attendee;
151
+				//$this->_attendees[$att_key]['registration_id'] = 0;
152
+				$this->_attendees[$att_key]['attendee_email'] = $attendee->email();
153
+				$this->_attendees[$att_key]['tkt_objs']       = $tickets;
154
+				if ($att_key == 999999991) {
155
+					$this->_attendees[$att_key]['ans_objs'][999]  = $answers_n_questions['answers'][999];
156
+					$this->_attendees[$att_key]['ans_objs'][1002] = $answers_n_questions['answers'][1002];
157
+					$this->_attendees[$att_key]['ans_objs'][1005] = $answers_n_questions['answers'][1005];
158
+				} elseif ($att_key == 999999992) {
159
+					$this->_attendees[$att_key]['ans_objs'][1000] = $answers_n_questions['answers'][1000];
160
+					$this->_attendees[$att_key]['ans_objs'][1003] = $answers_n_questions['answers'][1003];
161
+					$this->_attendees[$att_key]['ans_objs'][1006] = $answers_n_questions['answers'][1006];
162
+				} elseif ($att_key == 999999993) {
163
+					$this->_attendees[$att_key]['ans_objs'][1001] = $answers_n_questions['answers'][1001];
164
+					$this->_attendees[$att_key]['ans_objs'][1004] = $answers_n_questions['answers'][1004];
165
+					$this->_attendees[$att_key]['ans_objs'][1007] = $answers_n_questions['answers'][1007];
166
+				}
167
+			}
168
+		}
169
+        
170
+		$this->tickets            = $tkts;
171
+		$this->datetimes          = $dtts;
172
+		$this->answers            = $answers_n_questions['answers'];
173
+		$this->questions          = $answers_n_questions['questions'];
174
+		$this->total_ticket_count = count($tkts) * count($this->_attendees);
175
+        
176
+	}
177 177
     
178 178
     
179
-    /**
180
-     * This just returns an array of dummy attendee objects that we'll use to attach to events for our preview data
181
-     *
182
-     * @access private
183
-     * @return array an array of attendee objects
184
-     */
185
-    private function _get_some_attendees()
186
-    {
187
-        //let's just setup a dummy array of various attendee details
188
-        $dummy_attendees = array(
189
-            0 => array(
190
-                'Luke',
191
-                'Skywalker',
192
-                '[email protected]',
193
-                '804 Bantha Dr.',
194
-                'Complex 8',
195
-                'Mos Eisley',
196
-                32,
197
-                'US',
198
-                'f0r3e',
199
-                '222-333-4763',
200
-                false,
201
-                '999999991'
202
-            ),
203
-            1 => array(
204
-                'Princess',
205
-                'Leia',
206
-                '[email protected]',
207
-                '1456 Valley Way Boulevard',
208
-                'Suite 9',
209
-                'Alderaan',
210
-                15,
211
-                'US',
212
-                'c1h2c',
213
-                '78-123-111-1111',
214
-                false,
215
-                '999999992'
216
-            ),
217
-            2 => array(
218
-                'Yoda',
219
-                'I Am',
220
-                '[email protected]',
221
-                '4th Tree',
222
-                '5th Knot',
223
-                'Marsh',
224
-                22,
225
-                'US',
226
-                'l18n',
227
-                '999-999-9999',
228
-                false,
229
-                '999999993'
230
-            ),
231
-        );
232
-        
233
-        //let's generate the attendee objects
234
-        $attendees = array();
235
-        $var_array = array(
236
-            'fname',
237
-            'lname',
238
-            'email',
239
-            'address',
240
-            'address2',
241
-            'city',
242
-            'staid',
243
-            'cntry',
244
-            'zip',
245
-            'phone',
246
-            'deleted',
247
-            'attid'
248
-        );
249
-        
250
-        //EE_Registry::instance()->load_class( 'Attendee', array(), FALSE, false, TRUE );
251
-        foreach ($dummy_attendees as $dummy) {
252
-            $att = array_combine($var_array, $dummy);
253
-            extract($att);
254
-            /** @var $fname string */
255
-            /** @var $lname string */
256
-            /** @var $address string */
257
-            /** @var $address2 string */
258
-            /** @var $city string */
259
-            /** @var $staid string */
260
-            /** @var $cntry string */
261
-            /** @var $zip string */
262
-            /** @var $email string */
263
-            /** @var $phone string */
264
-            /** @var $attid string */
265
-            $attendees[$attid] = EE_Attendee::new_instance(
266
-                array(
267
-                    'ATT_fname'    => $fname,
268
-                    'ATT_lname'    => $lname,
269
-                    'ATT_address'  => $address,
270
-                    'ATT_address2' => $address2,
271
-                    'ATT_city'     => $city,
272
-                    'STA_ID'       => $staid,
273
-                    'CNT_ISO'      => $cntry,
274
-                    'ATT_zip'      => $zip,
275
-                    'ATT_email'    => $email,
276
-                    'ATT_phone'    => $phone,
277
-                    'ATT_ID'       => $attid
278
-                )
279
-            );
280
-        }
281
-        
282
-        return $attendees;
283
-    }
179
+	/**
180
+	 * This just returns an array of dummy attendee objects that we'll use to attach to events for our preview data
181
+	 *
182
+	 * @access private
183
+	 * @return array an array of attendee objects
184
+	 */
185
+	private function _get_some_attendees()
186
+	{
187
+		//let's just setup a dummy array of various attendee details
188
+		$dummy_attendees = array(
189
+			0 => array(
190
+				'Luke',
191
+				'Skywalker',
192
+				'[email protected]',
193
+				'804 Bantha Dr.',
194
+				'Complex 8',
195
+				'Mos Eisley',
196
+				32,
197
+				'US',
198
+				'f0r3e',
199
+				'222-333-4763',
200
+				false,
201
+				'999999991'
202
+			),
203
+			1 => array(
204
+				'Princess',
205
+				'Leia',
206
+				'[email protected]',
207
+				'1456 Valley Way Boulevard',
208
+				'Suite 9',
209
+				'Alderaan',
210
+				15,
211
+				'US',
212
+				'c1h2c',
213
+				'78-123-111-1111',
214
+				false,
215
+				'999999992'
216
+			),
217
+			2 => array(
218
+				'Yoda',
219
+				'I Am',
220
+				'[email protected]',
221
+				'4th Tree',
222
+				'5th Knot',
223
+				'Marsh',
224
+				22,
225
+				'US',
226
+				'l18n',
227
+				'999-999-9999',
228
+				false,
229
+				'999999993'
230
+			),
231
+		);
232
+        
233
+		//let's generate the attendee objects
234
+		$attendees = array();
235
+		$var_array = array(
236
+			'fname',
237
+			'lname',
238
+			'email',
239
+			'address',
240
+			'address2',
241
+			'city',
242
+			'staid',
243
+			'cntry',
244
+			'zip',
245
+			'phone',
246
+			'deleted',
247
+			'attid'
248
+		);
249
+        
250
+		//EE_Registry::instance()->load_class( 'Attendee', array(), FALSE, false, TRUE );
251
+		foreach ($dummy_attendees as $dummy) {
252
+			$att = array_combine($var_array, $dummy);
253
+			extract($att);
254
+			/** @var $fname string */
255
+			/** @var $lname string */
256
+			/** @var $address string */
257
+			/** @var $address2 string */
258
+			/** @var $city string */
259
+			/** @var $staid string */
260
+			/** @var $cntry string */
261
+			/** @var $zip string */
262
+			/** @var $email string */
263
+			/** @var $phone string */
264
+			/** @var $attid string */
265
+			$attendees[$attid] = EE_Attendee::new_instance(
266
+				array(
267
+					'ATT_fname'    => $fname,
268
+					'ATT_lname'    => $lname,
269
+					'ATT_address'  => $address,
270
+					'ATT_address2' => $address2,
271
+					'ATT_city'     => $city,
272
+					'STA_ID'       => $staid,
273
+					'CNT_ISO'      => $cntry,
274
+					'ATT_zip'      => $zip,
275
+					'ATT_email'    => $email,
276
+					'ATT_phone'    => $phone,
277
+					'ATT_ID'       => $attid
278
+				)
279
+			);
280
+		}
281
+        
282
+		return $attendees;
283
+	}
284 284
     
285 285
     
286
-    /**
287
-     * Return an array of dummy question objects indexed by answer id and dummy answer objects indexed by answer id.
288
-     * This will be used in our dummy data setup
289
-     * @return array
290
-     */
291
-    private function _get_some_q_and_as()
292
-    {
293
-        
294
-        
295
-        $quests_array = array(
296
-            0 => array(
297
-                555,
298
-                __('What is your favorite planet?', 'event_espresso'),
299
-                0
300
-            ),
301
-            1 => array(
302
-                556,
303
-                __('What is your favorite food?', 'event_espresso'),
304
-                0
305
-            ),
306
-            2 => array(
307
-                557,
308
-                __('How many lightyears have you travelled', 'event_espresso'),
309
-                0
310
-            )
311
-        );
312
-        
313
-        
314
-        $ans_array = array(
315
-            0 => array(
316
-                999,
317
-                555,
318
-                'Tattoine'
319
-            ),
320
-            1 => array(
321
-                1000,
322
-                555,
323
-                'Alderaan'
324
-            ),
325
-            2 => array(
326
-                1001,
327
-                555,
328
-                'Dantooine'
329
-            ),
330
-            3 => array(
331
-                1002,
332
-                556,
333
-                'Fish Fingers'
334
-            ),
335
-            4 => array(
336
-                1003,
337
-                556,
338
-                'Sushi'
339
-            ),
340
-            5 => array(
341
-                1004,
342
-                556,
343
-                'Water'
344
-            ),
345
-            6 => array(
346
-                1005,
347
-                557,
348
-                'A lot',
349
-            ),
350
-            7 => array(
351
-                1006,
352
-                557,
353
-                "That's none of your business."
354
-            ),
355
-            8 => array(
356
-                1007,
357
-                557,
358
-                "People less travel me then."
359
-            )
360
-        );
361
-        
362
-        $qst_columns = array('QST_ID', 'QST_display_text', 'QST_system');
363
-        $ans_columns = array('ANS_ID', 'QST_ID', 'ANS_value');
364
-        
365
-        //EE_Registry::instance()->load_class( 'Question', array(), FALSE, TRUE, TRUE );
366
-        //EE_Registry::instance()->load_class( 'Answer', array(), FALSE, TRUE, TRUE );
367
-        
368
-        $qsts = array();
369
-        //first the questions
370
-        foreach ($quests_array as $qst) {
371
-            $qstobj                  = array_combine($qst_columns, $qst);
372
-            $qsts[$qstobj['QST_ID']] = EE_Question::new_instance($qstobj);
373
-        }
374
-        
375
-        //now the answers (and we'll setup our arrays)
376
-        $q_n_as = array();
377
-        foreach ($ans_array as $ans) {
378
-            $ansobj                             = array_combine($ans_columns, $ans);
379
-            $ansobj                             = EE_Answer::new_instance($ansobj);
380
-            $q_n_as['answers'][$ansobj->ID()]   = $ansobj;
381
-            $q_n_as['questions'][$ansobj->ID()] = $qsts[$ansobj->get('QST_ID')];
382
-        }
383
-        
384
-        return $q_n_as;
385
-        
386
-    }
286
+	/**
287
+	 * Return an array of dummy question objects indexed by answer id and dummy answer objects indexed by answer id.
288
+	 * This will be used in our dummy data setup
289
+	 * @return array
290
+	 */
291
+	private function _get_some_q_and_as()
292
+	{
293
+        
294
+        
295
+		$quests_array = array(
296
+			0 => array(
297
+				555,
298
+				__('What is your favorite planet?', 'event_espresso'),
299
+				0
300
+			),
301
+			1 => array(
302
+				556,
303
+				__('What is your favorite food?', 'event_espresso'),
304
+				0
305
+			),
306
+			2 => array(
307
+				557,
308
+				__('How many lightyears have you travelled', 'event_espresso'),
309
+				0
310
+			)
311
+		);
312
+        
313
+        
314
+		$ans_array = array(
315
+			0 => array(
316
+				999,
317
+				555,
318
+				'Tattoine'
319
+			),
320
+			1 => array(
321
+				1000,
322
+				555,
323
+				'Alderaan'
324
+			),
325
+			2 => array(
326
+				1001,
327
+				555,
328
+				'Dantooine'
329
+			),
330
+			3 => array(
331
+				1002,
332
+				556,
333
+				'Fish Fingers'
334
+			),
335
+			4 => array(
336
+				1003,
337
+				556,
338
+				'Sushi'
339
+			),
340
+			5 => array(
341
+				1004,
342
+				556,
343
+				'Water'
344
+			),
345
+			6 => array(
346
+				1005,
347
+				557,
348
+				'A lot',
349
+			),
350
+			7 => array(
351
+				1006,
352
+				557,
353
+				"That's none of your business."
354
+			),
355
+			8 => array(
356
+				1007,
357
+				557,
358
+				"People less travel me then."
359
+			)
360
+		);
361
+        
362
+		$qst_columns = array('QST_ID', 'QST_display_text', 'QST_system');
363
+		$ans_columns = array('ANS_ID', 'QST_ID', 'ANS_value');
364
+        
365
+		//EE_Registry::instance()->load_class( 'Question', array(), FALSE, TRUE, TRUE );
366
+		//EE_Registry::instance()->load_class( 'Answer', array(), FALSE, TRUE, TRUE );
367
+        
368
+		$qsts = array();
369
+		//first the questions
370
+		foreach ($quests_array as $qst) {
371
+			$qstobj                  = array_combine($qst_columns, $qst);
372
+			$qsts[$qstobj['QST_ID']] = EE_Question::new_instance($qstobj);
373
+		}
374
+        
375
+		//now the answers (and we'll setup our arrays)
376
+		$q_n_as = array();
377
+		foreach ($ans_array as $ans) {
378
+			$ansobj                             = array_combine($ans_columns, $ans);
379
+			$ansobj                             = EE_Answer::new_instance($ansobj);
380
+			$q_n_as['answers'][$ansobj->ID()]   = $ansobj;
381
+			$q_n_as['questions'][$ansobj->ID()] = $qsts[$ansobj->get('QST_ID')];
382
+		}
383
+        
384
+		return $q_n_as;
385
+        
386
+	}
387 387
     
388 388
     
389
-    /**
390
-     * Return an array of event objects from the database
391
-     *
392
-     * If event ids are not included then we'll just retrieve the first published event from the database.
393
-     *
394
-     * @param  array $event_ids if set, this will be an array of event ids to obtain events for.
395
-     *
396
-     * @return array    An array of event objects from the db.
397
-     */
398
-    private function _get_some_events($event_ids = array())
399
-    {
400
-        
401
-        //HEY, if we have an evt_id then we want to make sure we use that for the preview (because a specific event template is being viewed);
402
-        $event_ids = isset($_REQUEST['evt_id']) && ! empty($_REQUEST['evt_id'])
403
-            ? array($_REQUEST['evt_id'])
404
-            : $event_ids;
405
-        
406
-        $limit = ! empty($event_ids)
407
-            ? null
408
-            : apply_filters('FHEE__EE_Messages_Preview_incoming_data___get_some_events__limit', '0,1');
409
-        
410
-        $where = ! empty($event_ids)
411
-            ? array(
412
-                'EVT_ID'                 => array('IN', $event_ids),
413
-                'Datetime.Ticket.TKT_ID' => array('>', 1)
414
-            )
415
-            : array('Datetime.Ticket.TKT_ID' => array('>', 1));
416
-        
417
-        $events = EE_Registry::instance()->load_model('Event')->get_all(array($where, 'limit' => $limit));
418
-        
419
-        return $events;
420
-    }
389
+	/**
390
+	 * Return an array of event objects from the database
391
+	 *
392
+	 * If event ids are not included then we'll just retrieve the first published event from the database.
393
+	 *
394
+	 * @param  array $event_ids if set, this will be an array of event ids to obtain events for.
395
+	 *
396
+	 * @return array    An array of event objects from the db.
397
+	 */
398
+	private function _get_some_events($event_ids = array())
399
+	{
400
+        
401
+		//HEY, if we have an evt_id then we want to make sure we use that for the preview (because a specific event template is being viewed);
402
+		$event_ids = isset($_REQUEST['evt_id']) && ! empty($_REQUEST['evt_id'])
403
+			? array($_REQUEST['evt_id'])
404
+			: $event_ids;
405
+        
406
+		$limit = ! empty($event_ids)
407
+			? null
408
+			: apply_filters('FHEE__EE_Messages_Preview_incoming_data___get_some_events__limit', '0,1');
409
+        
410
+		$where = ! empty($event_ids)
411
+			? array(
412
+				'EVT_ID'                 => array('IN', $event_ids),
413
+				'Datetime.Ticket.TKT_ID' => array('>', 1)
414
+			)
415
+			: array('Datetime.Ticket.TKT_ID' => array('>', 1));
416
+        
417
+		$events = EE_Registry::instance()->load_model('Event')->get_all(array($where, 'limit' => $limit));
418
+        
419
+		return $events;
420
+	}
421 421
     
422 422
     
423
-    protected function _setup_data()
424
-    {
425
-        
426
-        //need to figure out the running total for test purposes so... we're going to create a temp cart and add the tickets to it!
427
-        if (EE_Registry::instance()->SSN instanceof EE_Session) {
428
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
429
-            $session = EE_Registry::instance()->SSN;
430
-        } else {
431
-            $session = EE_Registry::instance()->load_core('Session');
432
-        }
433
-        $cart = EE_Cart::instance(null, $session);
434
-        
435
-        
436
-        //add tickets to cart
437
-        foreach ($this->tickets as $ticket) {
438
-            $cart->add_ticket_to_cart($ticket['ticket']);
439
-        }
440
-        
441
-        
442
-        //setup txn property
443
-        $this->txn = EE_Transaction::new_instance(
444
-            array(
445
-                'TXN_timestamp'    => time(), //unix timestamp
446
-                'TXN_total'        => 0, //txn_total
447
-                'TXN_paid'         => 0, //txn_paid
448
-                'STS_ID'           => EEM_Transaction::incomplete_status_code, //sts_id
449
-                'TXN_session_data' => null, //dump of txn session object (we're just going to leave blank here)
450
-                'TXN_hash_salt'    => null, //hash salt blank as well
451
-                'TXN_ID'           => 999999
452
-            )
453
-        );
454
-        
455
-        
456
-        //setup reg_objects
457
-        //note we're setting up a reg object for each attendee in each event but ALSO adding to the reg_object array.
458
-        $this->reg_objs = array();
459
-        $regid          = 9999990;
460
-        foreach ($this->_attendees as $key => $attendee) {
461
-            //note we need to setup reg_objects for each event this attendee belongs to
462
-            $regatt = $attendee['att_obj'] instanceof EE_Attendee ? $attendee['att_obj']->ID() : null;
463
-            $regtxn = $this->txn->ID();
464
-            $regcnt = 1;
465
-            foreach ($attendee['line_ref'] as $evtid) {
466
-                foreach ($this->_events[$evtid]['tkt_objs'] as $ticket) {
467
-                    if ( ! $ticket instanceof EE_Ticket) {
468
-                        continue;
469
-                    }
470
-                    $reg_array                                        = array(
471
-                        'EVT_ID'           => $evtid,
472
-                        'ATT_ID'           => $regatt,
473
-                        'TXN_ID'           => $regtxn,
474
-                        'TKT_ID'           => $ticket->ID(),
475
-                        'STS_ID'           => EEM_Registration::status_id_pending_payment,
476
-                        'REG_date'         => time(),
477
-                        'REG_final_price'  => $ticket->get('TKT_price'),
478
-                        'REG_session'      => 'dummy_session_id',
479
-                        'REG_code'         => $regid . '-dummy-generated-code',
480
-                        'REG_url_link'     => $regcnt . '-daafpapasdlfakasdfpqasdfasdf',
481
-                        'REG_count'        => $regcnt,
482
-                        'REG_group_size'   => $this->_events[$evtid]['total_attendees'],
483
-                        'REG_att_is_going' => true,
484
-                        'REG_ID'           => $regid
485
-                    );
486
-                    $REG_OBJ                                          = EE_Registration::new_instance($reg_array);
487
-                    $this->_attendees[$key]['reg_objs'][$regid]       = $REG_OBJ;
488
-                    $this->_events[$evtid]['reg_objs'][]              = $REG_OBJ;
489
-                    $this->reg_objs[]                                 = $REG_OBJ;
490
-                    $this->tickets[$ticket->ID()]['reg_objs'][$regid] = $REG_OBJ;
423
+	protected function _setup_data()
424
+	{
425
+        
426
+		//need to figure out the running total for test purposes so... we're going to create a temp cart and add the tickets to it!
427
+		if (EE_Registry::instance()->SSN instanceof EE_Session) {
428
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
429
+			$session = EE_Registry::instance()->SSN;
430
+		} else {
431
+			$session = EE_Registry::instance()->load_core('Session');
432
+		}
433
+		$cart = EE_Cart::instance(null, $session);
434
+        
435
+        
436
+		//add tickets to cart
437
+		foreach ($this->tickets as $ticket) {
438
+			$cart->add_ticket_to_cart($ticket['ticket']);
439
+		}
440
+        
441
+        
442
+		//setup txn property
443
+		$this->txn = EE_Transaction::new_instance(
444
+			array(
445
+				'TXN_timestamp'    => time(), //unix timestamp
446
+				'TXN_total'        => 0, //txn_total
447
+				'TXN_paid'         => 0, //txn_paid
448
+				'STS_ID'           => EEM_Transaction::incomplete_status_code, //sts_id
449
+				'TXN_session_data' => null, //dump of txn session object (we're just going to leave blank here)
450
+				'TXN_hash_salt'    => null, //hash salt blank as well
451
+				'TXN_ID'           => 999999
452
+			)
453
+		);
454
+        
455
+        
456
+		//setup reg_objects
457
+		//note we're setting up a reg object for each attendee in each event but ALSO adding to the reg_object array.
458
+		$this->reg_objs = array();
459
+		$regid          = 9999990;
460
+		foreach ($this->_attendees as $key => $attendee) {
461
+			//note we need to setup reg_objects for each event this attendee belongs to
462
+			$regatt = $attendee['att_obj'] instanceof EE_Attendee ? $attendee['att_obj']->ID() : null;
463
+			$regtxn = $this->txn->ID();
464
+			$regcnt = 1;
465
+			foreach ($attendee['line_ref'] as $evtid) {
466
+				foreach ($this->_events[$evtid]['tkt_objs'] as $ticket) {
467
+					if ( ! $ticket instanceof EE_Ticket) {
468
+						continue;
469
+					}
470
+					$reg_array                                        = array(
471
+						'EVT_ID'           => $evtid,
472
+						'ATT_ID'           => $regatt,
473
+						'TXN_ID'           => $regtxn,
474
+						'TKT_ID'           => $ticket->ID(),
475
+						'STS_ID'           => EEM_Registration::status_id_pending_payment,
476
+						'REG_date'         => time(),
477
+						'REG_final_price'  => $ticket->get('TKT_price'),
478
+						'REG_session'      => 'dummy_session_id',
479
+						'REG_code'         => $regid . '-dummy-generated-code',
480
+						'REG_url_link'     => $regcnt . '-daafpapasdlfakasdfpqasdfasdf',
481
+						'REG_count'        => $regcnt,
482
+						'REG_group_size'   => $this->_events[$evtid]['total_attendees'],
483
+						'REG_att_is_going' => true,
484
+						'REG_ID'           => $regid
485
+					);
486
+					$REG_OBJ                                          = EE_Registration::new_instance($reg_array);
487
+					$this->_attendees[$key]['reg_objs'][$regid]       = $REG_OBJ;
488
+					$this->_events[$evtid]['reg_objs'][]              = $REG_OBJ;
489
+					$this->reg_objs[]                                 = $REG_OBJ;
490
+					$this->tickets[$ticket->ID()]['reg_objs'][$regid] = $REG_OBJ;
491 491
                     
492
-                    $regcnt++;
493
-                    $regid++;
494
-                }
495
-            }
496
-        }
497
-        
498
-        
499
-        //setup line items!
500
-        $line_item_total = EEH_Line_Item::create_total_line_item($this->txn);
501
-        
502
-        //add tickets
503
-        foreach ($this->tickets as $tktid => $item) {
504
-            $qty    = $item['count'];
505
-            $ticket = $item['ticket'];
506
-            EEH_Line_Item::add_ticket_purchase($line_item_total, $ticket, $qty);
507
-        }
508
-        
509
-        $shipping_line_item = EE_Line_Item::new_instance(array(
510
-            'LIN_name'       => __('Shipping Surcharge', 'event_espresso'),
511
-            'LIN_desc'       => __('Sent via Millenium Falcon', 'event_espresso'),
512
-            'LIN_unit_price' => 20,
513
-            'LIN_quantity'   => 1,
514
-            'LIN_is_taxable' => true,
515
-            'LIN_total'      => 20,
516
-            'LIN_type'       => EEM_Line_Item::type_line_item
517
-        ));
518
-        EEH_Line_Item::add_item($line_item_total, $shipping_line_item);
519
-        $this->additional_line_items = array($shipping_line_item);
520
-        
521
-        //now let's add taxes
522
-        EEH_Line_Item::apply_taxes($line_item_total);
523
-        
524
-        //now we should be able to get the items we need from this object
525
-        $event_line_items = EEH_Line_Item::get_pre_tax_subtotal($line_item_total)->children();
526
-        $line_items       = array();
527
-        foreach ($event_line_items as $line_id => $line_item) {
528
-            if ( ! $line_item instanceof EE_Line_Item || $line_item->OBJ_type() !== 'Event') {
529
-                continue;
530
-            }
531
-            $ticket_line_items = EEH_Line_Item::get_ticket_line_items($line_item);
532
-            foreach ($ticket_line_items as $ticket_line_id => $ticket_line_item) {
533
-                if ( ! $ticket_line_item instanceof EE_Line_Item) {
534
-                    continue;
535
-                }
536
-                $this->tickets[$ticket_line_item->OBJ_ID()]['line_item']      = $ticket_line_item;
537
-                $this->tickets[$ticket_line_item->OBJ_ID()]['sub_line_items'] = $ticket_line_item->children();
538
-                $line_items[$ticket_line_item->ID()]['children']              = $ticket_line_item->children();
539
-                $line_items[$ticket_line_item->ID()]['EE_Ticket']             = $this->tickets[$ticket_line_item->OBJ_ID()]['ticket'];
540
-            }
541
-        }
542
-        
543
-        $this->line_items_with_children = $line_items;
544
-        $this->tax_line_items           = $line_item_total->tax_descendants();
545
-        
546
-        //add proper total to transaction object.
547
-        $grand_total                 = $line_item_total->recalculate_total_including_taxes();
548
-        $this->grand_total_line_item = $line_item_total;
549
-        $this->txn->set_total($grand_total);
550
-        
551
-        
552
-        //add additional details for each registration
553
-        foreach ($this->reg_objs as $reg) {
554
-            if ( ! $reg instanceof EE_Registration) {
555
-                continue;
556
-            }
557
-            $this->_registrations[$reg->ID()]['tkt_obj']  = $this->tickets[$reg->get('TKT_ID')]['ticket'];
558
-            $this->_registrations[$reg->ID()]['evt_obj']  = $this->_events[$reg->get('EVT_ID')]['event'];
559
-            $this->_registrations[$reg->ID()]['reg_obj']  = $reg;
560
-            $this->_registrations[$reg->ID()]['ans_objs'] = $this->_attendees[$reg->get('ATT_ID')]['ans_objs'];
561
-            $this->_registrations[$reg->ID()]['att_obj']  = $this->_attendees[$reg->get('ATT_ID')]['att_obj'];
562
-            $this->_registrations[$reg->ID()]['dtt_objs'] = $this->tickets[$reg->get('TKT_ID')]['dtt_objs'];
563
-        }
564
-        
565
-        
566
-        //events and attendees
567
-        $this->events        = $this->_events;
568
-        $this->attendees     = $this->_attendees;
569
-        $this->registrations = $this->_registrations;
570
-        
571
-        $attendees_to_shift = $this->_attendees;
572
-        
573
-        //setup primary attendee property
574
-        $this->primary_attendee_data = array(
575
-            'fname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee
576
-                ? $this->_attendees[999999991]['att_obj']->fname()
577
-                : '',
492
+					$regcnt++;
493
+					$regid++;
494
+				}
495
+			}
496
+		}
497
+        
498
+        
499
+		//setup line items!
500
+		$line_item_total = EEH_Line_Item::create_total_line_item($this->txn);
501
+        
502
+		//add tickets
503
+		foreach ($this->tickets as $tktid => $item) {
504
+			$qty    = $item['count'];
505
+			$ticket = $item['ticket'];
506
+			EEH_Line_Item::add_ticket_purchase($line_item_total, $ticket, $qty);
507
+		}
508
+        
509
+		$shipping_line_item = EE_Line_Item::new_instance(array(
510
+			'LIN_name'       => __('Shipping Surcharge', 'event_espresso'),
511
+			'LIN_desc'       => __('Sent via Millenium Falcon', 'event_espresso'),
512
+			'LIN_unit_price' => 20,
513
+			'LIN_quantity'   => 1,
514
+			'LIN_is_taxable' => true,
515
+			'LIN_total'      => 20,
516
+			'LIN_type'       => EEM_Line_Item::type_line_item
517
+		));
518
+		EEH_Line_Item::add_item($line_item_total, $shipping_line_item);
519
+		$this->additional_line_items = array($shipping_line_item);
520
+        
521
+		//now let's add taxes
522
+		EEH_Line_Item::apply_taxes($line_item_total);
523
+        
524
+		//now we should be able to get the items we need from this object
525
+		$event_line_items = EEH_Line_Item::get_pre_tax_subtotal($line_item_total)->children();
526
+		$line_items       = array();
527
+		foreach ($event_line_items as $line_id => $line_item) {
528
+			if ( ! $line_item instanceof EE_Line_Item || $line_item->OBJ_type() !== 'Event') {
529
+				continue;
530
+			}
531
+			$ticket_line_items = EEH_Line_Item::get_ticket_line_items($line_item);
532
+			foreach ($ticket_line_items as $ticket_line_id => $ticket_line_item) {
533
+				if ( ! $ticket_line_item instanceof EE_Line_Item) {
534
+					continue;
535
+				}
536
+				$this->tickets[$ticket_line_item->OBJ_ID()]['line_item']      = $ticket_line_item;
537
+				$this->tickets[$ticket_line_item->OBJ_ID()]['sub_line_items'] = $ticket_line_item->children();
538
+				$line_items[$ticket_line_item->ID()]['children']              = $ticket_line_item->children();
539
+				$line_items[$ticket_line_item->ID()]['EE_Ticket']             = $this->tickets[$ticket_line_item->OBJ_ID()]['ticket'];
540
+			}
541
+		}
542
+        
543
+		$this->line_items_with_children = $line_items;
544
+		$this->tax_line_items           = $line_item_total->tax_descendants();
545
+        
546
+		//add proper total to transaction object.
547
+		$grand_total                 = $line_item_total->recalculate_total_including_taxes();
548
+		$this->grand_total_line_item = $line_item_total;
549
+		$this->txn->set_total($grand_total);
550
+        
551
+        
552
+		//add additional details for each registration
553
+		foreach ($this->reg_objs as $reg) {
554
+			if ( ! $reg instanceof EE_Registration) {
555
+				continue;
556
+			}
557
+			$this->_registrations[$reg->ID()]['tkt_obj']  = $this->tickets[$reg->get('TKT_ID')]['ticket'];
558
+			$this->_registrations[$reg->ID()]['evt_obj']  = $this->_events[$reg->get('EVT_ID')]['event'];
559
+			$this->_registrations[$reg->ID()]['reg_obj']  = $reg;
560
+			$this->_registrations[$reg->ID()]['ans_objs'] = $this->_attendees[$reg->get('ATT_ID')]['ans_objs'];
561
+			$this->_registrations[$reg->ID()]['att_obj']  = $this->_attendees[$reg->get('ATT_ID')]['att_obj'];
562
+			$this->_registrations[$reg->ID()]['dtt_objs'] = $this->tickets[$reg->get('TKT_ID')]['dtt_objs'];
563
+		}
564
+        
565
+        
566
+		//events and attendees
567
+		$this->events        = $this->_events;
568
+		$this->attendees     = $this->_attendees;
569
+		$this->registrations = $this->_registrations;
570
+        
571
+		$attendees_to_shift = $this->_attendees;
572
+        
573
+		//setup primary attendee property
574
+		$this->primary_attendee_data = array(
575
+			'fname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee
576
+				? $this->_attendees[999999991]['att_obj']->fname()
577
+				: '',
578 578
             
579
-            'lname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee
580
-                ? $this->_attendees[999999991]['att_obj']->lname()
581
-                : '',
579
+			'lname' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee
580
+				? $this->_attendees[999999991]['att_obj']->lname()
581
+				: '',
582 582
             
583
-            'email' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee
584
-                ? $this->_attendees[999999991]['att_obj']->email()
585
-                : '',
583
+			'email' => $this->_attendees[999999991]['att_obj'] instanceof EE_Attendee
584
+				? $this->_attendees[999999991]['att_obj']->email()
585
+				: '',
586 586
             
587
-            'att_obj' => $this->_attendees[999999991]['att_obj'],
587
+			'att_obj' => $this->_attendees[999999991]['att_obj'],
588 588
             
589
-            'reg_obj' => array_shift($attendees_to_shift[999999991]['reg_objs'])
590
-        );
589
+			'reg_obj' => array_shift($attendees_to_shift[999999991]['reg_objs'])
590
+		);
591 591
         
592
-        //reg_info property
593
-        //note this isn't referenced by any shortcode parsers so we'll ignore for now.
594
-        $this->reg_info = array();
592
+		//reg_info property
593
+		//note this isn't referenced by any shortcode parsers so we'll ignore for now.
594
+		$this->reg_info = array();
595 595
         
596
-        //let's set a reg_obj for messengers expecting one.
597
-        $this->reg_obj = array_pop($this->_attendees[999999991]['reg_objs']);
596
+		//let's set a reg_obj for messengers expecting one.
597
+		$this->reg_obj = array_pop($this->_attendees[999999991]['reg_objs']);
598 598
         
599 599
         
600
-        //the below are just dummy items.
601
-        $this->user_id     = 1;
602
-        $this->ip_address  = '192.0.2.1';
603
-        $this->user_agent  = '';
604
-        $this->init_access = time();
605
-        $this->last_access = time();
606
-    }
600
+		//the below are just dummy items.
601
+		$this->user_id     = 1;
602
+		$this->ip_address  = '192.0.2.1';
603
+		$this->user_agent  = '';
604
+		$this->init_access = time();
605
+		$this->last_access = time();
606
+	}
607 607
     
608 608
 } //end EE_Messages_Preview_incoming_data class
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
                 if ( ! $attendee instanceof EE_Attendee) {
146 146
                     continue;
147 147
                 }
148
-                $this->_attendees[$att_key]['line_ref'][] = $id;  //so later it can be determined what events this attendee registered for!
148
+                $this->_attendees[$att_key]['line_ref'][] = $id; //so later it can be determined what events this attendee registered for!
149 149
                 $this->_attendees[$att_key]['evt_objs'][] = $event;
150 150
                 $this->_attendees[$att_key]['att_obj']    = $attendee;
151 151
                 //$this->_attendees[$att_key]['registration_id'] = 0;
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
                     if ( ! $ticket instanceof EE_Ticket) {
468 468
                         continue;
469 469
                     }
470
-                    $reg_array                                        = array(
470
+                    $reg_array = array(
471 471
                         'EVT_ID'           => $evtid,
472 472
                         'ATT_ID'           => $regatt,
473 473
                         'TXN_ID'           => $regtxn,
@@ -476,8 +476,8 @@  discard block
 block discarded – undo
476 476
                         'REG_date'         => time(),
477 477
                         'REG_final_price'  => $ticket->get('TKT_price'),
478 478
                         'REG_session'      => 'dummy_session_id',
479
-                        'REG_code'         => $regid . '-dummy-generated-code',
480
-                        'REG_url_link'     => $regcnt . '-daafpapasdlfakasdfpqasdfasdf',
479
+                        'REG_code'         => $regid.'-dummy-generated-code',
480
+                        'REG_url_link'     => $regcnt.'-daafpapasdlfakasdfpqasdfasdf',
481 481
                         'REG_count'        => $regcnt,
482 482
                         'REG_group_size'   => $this->_events[$evtid]['total_attendees'],
483 483
                         'REG_att_is_going' => true,
Please login to merge, or discard this patch.
caffeinated/core/libraries/shortcodes/EE_Question_Shortcodes.lib.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4
-    exit('NO direct script access allowed');
4
+	exit('NO direct script access allowed');
5 5
 }
6 6
 
7 7
 /**
@@ -36,82 +36,82 @@  discard block
 block discarded – undo
36 36
 {
37 37
     
38 38
     
39
-    /**
40
-     * _init_props
41
-     *
42
-     * @access protected
43
-     * @return void
44
-     */
45
-    protected function _init_props()
46
-    {
47
-        $this->label       = __('Attendee Shortcodes', 'event_espresso');
48
-        $this->description = __('All shortcodes specific to attendee related data', 'event_espresso');
49
-        $this->_shortcodes = array(
50
-            '[QUESTION]' => __('Will parse to a question.', 'event_espresso'),
51
-            '[ANSWER]'   => __('Will parse to the answer for a question', 'event_espresso')
52
-        );
53
-    }
39
+	/**
40
+	 * _init_props
41
+	 *
42
+	 * @access protected
43
+	 * @return void
44
+	 */
45
+	protected function _init_props()
46
+	{
47
+		$this->label       = __('Attendee Shortcodes', 'event_espresso');
48
+		$this->description = __('All shortcodes specific to attendee related data', 'event_espresso');
49
+		$this->_shortcodes = array(
50
+			'[QUESTION]' => __('Will parse to a question.', 'event_espresso'),
51
+			'[ANSWER]'   => __('Will parse to the answer for a question', 'event_espresso')
52
+		);
53
+	}
54 54
     
55 55
     
56
-    /**
57
-     * This method will give parsing instructions for each shortcode defined in the _shortcodes array.  Child methods
58
-     * will have to take care of handling.
59
-     *
60
-     * @access protected
61
-     *
62
-     * @param string $shortcode the shortcode to be parsed.
63
-     *
64
-     * @return string parsed shortcode
65
-     */
66
-    protected function _parser($shortcode)
67
-    {
56
+	/**
57
+	 * This method will give parsing instructions for each shortcode defined in the _shortcodes array.  Child methods
58
+	 * will have to take care of handling.
59
+	 *
60
+	 * @access protected
61
+	 *
62
+	 * @param string $shortcode the shortcode to be parsed.
63
+	 *
64
+	 * @return string parsed shortcode
65
+	 */
66
+	protected function _parser($shortcode)
67
+	{
68 68
         
69
-        if ( ! $this->_data instanceof EE_Answer || ! isset($this->_extra_data['data']) || ! $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
70
-            return '';
71
-        }
69
+		if ( ! $this->_data instanceof EE_Answer || ! isset($this->_extra_data['data']) || ! $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
70
+			return '';
71
+		}
72 72
         
73
-        switch ($shortcode) {
73
+		switch ($shortcode) {
74 74
             
75
-            case '[QUESTION]' :
76
-                $question = isset($this->_extra_data['data']->questions[$this->_data->ID()]) ? $this->_extra_data['data']->questions[$this->_data->ID()] : $this->_data->question();
77
-                if ( ! $question instanceof EE_Question) {
78
-                    return ''; //get out because we can't figure out what the question is.
79
-                }
75
+			case '[QUESTION]' :
76
+				$question = isset($this->_extra_data['data']->questions[$this->_data->ID()]) ? $this->_extra_data['data']->questions[$this->_data->ID()] : $this->_data->question();
77
+				if ( ! $question instanceof EE_Question) {
78
+					return ''; //get out because we can't figure out what the question is.
79
+				}
80 80
                 
81
-                return $question->get_pretty('QST_display_text', 'no_wpautop');
82
-                break;
81
+				return $question->get_pretty('QST_display_text', 'no_wpautop');
82
+				break;
83 83
             
84
-            case '[ANSWER]' :
85
-                //need to get the question to determine the type of question (some questions require translation of the answer).
86
-                $question = isset($this->_extra_data['data']->questions[$this->_data->ID()]) ? $this->_extra_data['data']->questions[$this->_data->ID()] : $this->_data->question();
87
-                if ( ! $question instanceof EE_Question) {
88
-                    return ''; //get out cause we can't figure out what the question type is!
89
-                }
84
+			case '[ANSWER]' :
85
+				//need to get the question to determine the type of question (some questions require translation of the answer).
86
+				$question = isset($this->_extra_data['data']->questions[$this->_data->ID()]) ? $this->_extra_data['data']->questions[$this->_data->ID()] : $this->_data->question();
87
+				if ( ! $question instanceof EE_Question) {
88
+					return ''; //get out cause we can't figure out what the question type is!
89
+				}
90 90
                 
91
-                //what we show for the answer depends on the question type!
92
-                switch ($question->get('QST_type')) {
91
+				//what we show for the answer depends on the question type!
92
+				switch ($question->get('QST_type')) {
93 93
                     
94
-                    case 'STATE' :
95
-                        $state  = EEM_State::instance()->get_one_by_ID($this->_data->get('ANS_value'));
96
-                        $answer = $state instanceof EE_State ? $state->name() : '';
97
-                        break;
94
+					case 'STATE' :
95
+						$state  = EEM_State::instance()->get_one_by_ID($this->_data->get('ANS_value'));
96
+						$answer = $state instanceof EE_State ? $state->name() : '';
97
+						break;
98 98
                     
99
-                    case 'COUNTRY' :
100
-                        $country = EEM_Country::instance()->get_one_by_ID($this->_data->get('ANS_value'));
101
-                        $answer  = $country instanceof EE_Country ? $country->name() : '';
102
-                        break;
99
+					case 'COUNTRY' :
100
+						$country = EEM_Country::instance()->get_one_by_ID($this->_data->get('ANS_value'));
101
+						$answer  = $country instanceof EE_Country ? $country->name() : '';
102
+						break;
103 103
                     
104
-                    default :
105
-                        $answer = $this->_data->get_pretty('ANS_value', 'no_wpautop');
106
-                        break;
107
-                }
104
+					default :
105
+						$answer = $this->_data->get_pretty('ANS_value', 'no_wpautop');
106
+						break;
107
+				}
108 108
                 
109
-                return $answer;
110
-                break;
109
+				return $answer;
110
+				break;
111 111
             
112
-        }
112
+		}
113 113
         
114
-        return '';
115
-    }
114
+		return '';
115
+	}
116 116
     
117 117
 } //end EE_Question_Shortcodes class
Please login to merge, or discard this patch.
caffeinated/EE_Caf_Messages.class.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@
 block discarded – undo
91 91
      *
92 92
      * @param  array $dir_ref original array of paths
93 93
      *
94
-     * @return array           appended paths
94
+     * @return string[]           appended paths
95 95
      */
96 96
     public function messages_autoload_paths($dir_ref)
97 97
     {
Please login to merge, or discard this patch.
Indentation   +631 added lines, -631 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @since           4.3.2
8 8
  */
9 9
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
10
-    exit('No direct script access allowed');
10
+	exit('No direct script access allowed');
11 11
 }
12 12
 
13 13
 /**
@@ -22,651 +22,651 @@  discard block
 block discarded – undo
22 22
 {
23 23
     
24 24
     
25
-    /**
26
-     * constructor.
27
-     */
28
-    public function __construct()
29
-    {
30
-        $this->_caf_hooks();
31
-    }
32
-    
33
-    
34
-    /**
35
-     * Contains all the hooks filters for setting up caffeinated messages functionality.
36
-     *
37
-     * @since 4.3.2
38
-     *
39
-     * @return void
40
-     */
41
-    private function _caf_hooks()
42
-    {
43
-        add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5);
44
-        add_filter('FHEE__EE_Email_messenger__get_validator_config', array($this, 'email_messenger_validator_config'),
45
-            5, 2);
46
-        add_filter('FHEE__EE_Email_messenger__get_template_fields', array($this, 'email_messenger_template_fields'), 5,
47
-            2);
48
-        add_filter('FHEE__EE_Html_messenger__get_template_fields', array($this, 'html_messenger_template_fields'), 5,
49
-            2);
50
-        add_filter('FHEE__EE_Html_messenger__get_validator_config', array($this, 'html_messenger_validator_config'), 5,
51
-            2);
52
-        add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2);
53
-        add_filter('FHEE__EE_Pdf_messenger__get_validator_config', array($this, 'pdf_messenger_validator_config'), 5,
54
-            2);
55
-        add_filter('FHEE__EE_Messages_Template_Pack__get_specific_template__contents',
56
-            array($this, 'new_default_templates'), 5, 7);
57
-        add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', array($this, 'message_types_valid_shortcodes'), 5,
58
-            2);
59
-        
60
-        //shortcode parsers
61
-        add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2);
62
-        add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5);
63
-        add_filter('FHEE__EE_Recipient_List_Shortcodes__shortcodes',
64
-            array($this, 'additional_recipient_details_shortcodes'), 5, 2);
65
-        add_filter('FHEE__EE_Recipient_List_Shortcodes__parser_after',
66
-            array($this, 'additional_recipient_details_parser'), 5, 5);
67
-        add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes',
68
-            array($this, 'additional_primary_registration_details_shortcodes'), 5, 2);
69
-        add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__parser_after',
70
-            array($this, 'additional_primary_registration_details_parser'), 5, 5);
71
-        
72
-        /**
73
-         * @since 4.2.0
74
-         */
75
-        add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2);
76
-        add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5);
77
-        
78
-        /**
79
-         * @since 4.3.0
80
-         */
81
-        //eat our own dog food!
82
-        add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types'));
83
-        add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes'));
84
-        do_action('EE_Brewing_Regular___messages_caf');
85
-    }
86
-    
87
-    
88
-    /**
89
-     * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the
90
-     * messages system.
91
-     *
92
-     * @param  array $dir_ref original array of paths
93
-     *
94
-     * @return array           appended paths
95
-     */
96
-    public function messages_autoload_paths($dir_ref)
97
-    {
98
-        $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/';
99
-        
100
-        return $dir_ref;
101
-    }
102
-    
103
-    
104
-    public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger)
105
-    {
106
-        $validator_config['attendee_list'] = array(
107
-            'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
108
-            'required'   => array('[ATTENDEE_LIST]')
109
-        );
110
-        $validator_config['question_list'] = array(
111
-            'shortcodes' => array('question'),
112
-            'required'   => array('[QUESTION_LIST]')
113
-        );
114
-        
115
-        return $validator_config;
116
-    }
117
-    
118
-    
119
-    public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger)
120
-    {
121
-        $validator_config['attendee_list'] = array(
122
-            'shortcodes' => array('attendee', 'question_list'),
123
-            'required'   => array('[ATTENDEE_LIST]')
124
-        );
125
-        $validator_config['question_list'] = array(
126
-            'shortcodes' => array('question'),
127
-            'required'   => array('[QUESTION_LIST]')
128
-        );
129
-        
130
-        return $validator_config;
131
-    }
132
-    
133
-    
134
-    public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger)
135
-    {
136
-        $validator_config['attendee_list'] = array(
137
-            'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
138
-            'required'   => array('[ATTENDEE_LIST]')
139
-        );
140
-        $validator_config['question_list'] = array(
141
-            'shortcodes' => array('question'),
142
-            'required'   => array('[QUESTION_LIST]')
143
-        );
144
-        
145
-        return $validator_config;
146
-    }
147
-    
148
-    
149
-    public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger)
150
-    {
151
-        $template_fields['extra']['content']['question_list'] = array(
152
-            'input'               => 'textarea',
153
-            'label'               => '[QUESTION_LIST]',
154
-            'type'                => 'string',
155
-            'required'            => true,
156
-            'validation'          => true,
157
-            'format'              => '%s',
158
-            'css_class'           => 'large-text',
159
-            'rows'                => '5',
160
-            'shortcodes_required' => array('[QUESTION_LIST]')
161
-        );
162
-        
163
-        return $template_fields;
164
-    }
165
-    
166
-    
167
-    public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger)
168
-    {
169
-        $template_fields['extra']['content']['question_list'] = array(
170
-            'input'               => 'textarea',
171
-            'label'               => '[QUESTION_LIST]',
172
-            'type'                => 'string',
173
-            'required'            => true,
174
-            'validation'          => true,
175
-            'format'              => '%s',
176
-            'css_class'           => 'large-text',
177
-            'rows'                => '5',
178
-            'shortcodes_required' => array('[QUESTION_LIST]')
179
-        );
180
-        
181
-        return $template_fields;
182
-    }
183
-    
184
-    
185
-    public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger)
186
-    {
187
-        $template_fields['extra']['content']['question_list'] = array(
188
-            'input'               => 'textarea',
189
-            'label'               => '[QUESTION_LIST]',
190
-            'type'                => 'string',
191
-            'required'            => true,
192
-            'validation'          => true,
193
-            'format'              => '%s',
194
-            'css_class'           => 'large-text',
195
-            'rows'                => '5',
196
-            'shortcodes_required' => array('[QUESTION_LIST]')
197
-        );
198
-        
199
-        return $template_fields;
200
-    }
201
-    
202
-    
203
-    public function new_default_templates(
204
-        $contents,
205
-        $actual_path,
206
-        EE_messenger $messenger,
207
-        EE_message_type $message_type,
208
-        $field,
209
-        $context,
210
-        EE_Messages_Template_Pack $template_pack
211
-    ) {
212
-        
213
-        //we're only modifying templates for the default template pack
214
-        if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) {
215
-            return $contents;
216
-        }
217
-        
218
-        //the template file name we're replacing contents for.
219
-        $template_file_prefix = $field . '_' . $context;
220
-        $msg_prefix           = $messenger->name . '_' . $message_type->name . '_';
221
-        
222
-        $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/';
223
-        
224
-        if ($messenger->name == 'email' && $message_type->name == 'registration') {
25
+	/**
26
+	 * constructor.
27
+	 */
28
+	public function __construct()
29
+	{
30
+		$this->_caf_hooks();
31
+	}
32
+    
33
+    
34
+	/**
35
+	 * Contains all the hooks filters for setting up caffeinated messages functionality.
36
+	 *
37
+	 * @since 4.3.2
38
+	 *
39
+	 * @return void
40
+	 */
41
+	private function _caf_hooks()
42
+	{
43
+		add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5);
44
+		add_filter('FHEE__EE_Email_messenger__get_validator_config', array($this, 'email_messenger_validator_config'),
45
+			5, 2);
46
+		add_filter('FHEE__EE_Email_messenger__get_template_fields', array($this, 'email_messenger_template_fields'), 5,
47
+			2);
48
+		add_filter('FHEE__EE_Html_messenger__get_template_fields', array($this, 'html_messenger_template_fields'), 5,
49
+			2);
50
+		add_filter('FHEE__EE_Html_messenger__get_validator_config', array($this, 'html_messenger_validator_config'), 5,
51
+			2);
52
+		add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2);
53
+		add_filter('FHEE__EE_Pdf_messenger__get_validator_config', array($this, 'pdf_messenger_validator_config'), 5,
54
+			2);
55
+		add_filter('FHEE__EE_Messages_Template_Pack__get_specific_template__contents',
56
+			array($this, 'new_default_templates'), 5, 7);
57
+		add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', array($this, 'message_types_valid_shortcodes'), 5,
58
+			2);
59
+        
60
+		//shortcode parsers
61
+		add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2);
62
+		add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5);
63
+		add_filter('FHEE__EE_Recipient_List_Shortcodes__shortcodes',
64
+			array($this, 'additional_recipient_details_shortcodes'), 5, 2);
65
+		add_filter('FHEE__EE_Recipient_List_Shortcodes__parser_after',
66
+			array($this, 'additional_recipient_details_parser'), 5, 5);
67
+		add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes',
68
+			array($this, 'additional_primary_registration_details_shortcodes'), 5, 2);
69
+		add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__parser_after',
70
+			array($this, 'additional_primary_registration_details_parser'), 5, 5);
71
+        
72
+		/**
73
+		 * @since 4.2.0
74
+		 */
75
+		add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2);
76
+		add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5);
77
+        
78
+		/**
79
+		 * @since 4.3.0
80
+		 */
81
+		//eat our own dog food!
82
+		add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types'));
83
+		add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes'));
84
+		do_action('EE_Brewing_Regular___messages_caf');
85
+	}
86
+    
87
+    
88
+	/**
89
+	 * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the
90
+	 * messages system.
91
+	 *
92
+	 * @param  array $dir_ref original array of paths
93
+	 *
94
+	 * @return array           appended paths
95
+	 */
96
+	public function messages_autoload_paths($dir_ref)
97
+	{
98
+		$dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/';
99
+        
100
+		return $dir_ref;
101
+	}
102
+    
103
+    
104
+	public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger)
105
+	{
106
+		$validator_config['attendee_list'] = array(
107
+			'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
108
+			'required'   => array('[ATTENDEE_LIST]')
109
+		);
110
+		$validator_config['question_list'] = array(
111
+			'shortcodes' => array('question'),
112
+			'required'   => array('[QUESTION_LIST]')
113
+		);
114
+        
115
+		return $validator_config;
116
+	}
117
+    
118
+    
119
+	public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger)
120
+	{
121
+		$validator_config['attendee_list'] = array(
122
+			'shortcodes' => array('attendee', 'question_list'),
123
+			'required'   => array('[ATTENDEE_LIST]')
124
+		);
125
+		$validator_config['question_list'] = array(
126
+			'shortcodes' => array('question'),
127
+			'required'   => array('[QUESTION_LIST]')
128
+		);
129
+        
130
+		return $validator_config;
131
+	}
132
+    
133
+    
134
+	public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger)
135
+	{
136
+		$validator_config['attendee_list'] = array(
137
+			'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
138
+			'required'   => array('[ATTENDEE_LIST]')
139
+		);
140
+		$validator_config['question_list'] = array(
141
+			'shortcodes' => array('question'),
142
+			'required'   => array('[QUESTION_LIST]')
143
+		);
144
+        
145
+		return $validator_config;
146
+	}
147
+    
148
+    
149
+	public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger)
150
+	{
151
+		$template_fields['extra']['content']['question_list'] = array(
152
+			'input'               => 'textarea',
153
+			'label'               => '[QUESTION_LIST]',
154
+			'type'                => 'string',
155
+			'required'            => true,
156
+			'validation'          => true,
157
+			'format'              => '%s',
158
+			'css_class'           => 'large-text',
159
+			'rows'                => '5',
160
+			'shortcodes_required' => array('[QUESTION_LIST]')
161
+		);
162
+        
163
+		return $template_fields;
164
+	}
165
+    
166
+    
167
+	public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger)
168
+	{
169
+		$template_fields['extra']['content']['question_list'] = array(
170
+			'input'               => 'textarea',
171
+			'label'               => '[QUESTION_LIST]',
172
+			'type'                => 'string',
173
+			'required'            => true,
174
+			'validation'          => true,
175
+			'format'              => '%s',
176
+			'css_class'           => 'large-text',
177
+			'rows'                => '5',
178
+			'shortcodes_required' => array('[QUESTION_LIST]')
179
+		);
180
+        
181
+		return $template_fields;
182
+	}
183
+    
184
+    
185
+	public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger)
186
+	{
187
+		$template_fields['extra']['content']['question_list'] = array(
188
+			'input'               => 'textarea',
189
+			'label'               => '[QUESTION_LIST]',
190
+			'type'                => 'string',
191
+			'required'            => true,
192
+			'validation'          => true,
193
+			'format'              => '%s',
194
+			'css_class'           => 'large-text',
195
+			'rows'                => '5',
196
+			'shortcodes_required' => array('[QUESTION_LIST]')
197
+		);
198
+        
199
+		return $template_fields;
200
+	}
201
+    
202
+    
203
+	public function new_default_templates(
204
+		$contents,
205
+		$actual_path,
206
+		EE_messenger $messenger,
207
+		EE_message_type $message_type,
208
+		$field,
209
+		$context,
210
+		EE_Messages_Template_Pack $template_pack
211
+	) {
212
+        
213
+		//we're only modifying templates for the default template pack
214
+		if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) {
215
+			return $contents;
216
+		}
217
+        
218
+		//the template file name we're replacing contents for.
219
+		$template_file_prefix = $field . '_' . $context;
220
+		$msg_prefix           = $messenger->name . '_' . $message_type->name . '_';
221
+        
222
+		$base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/';
223
+        
224
+		if ($messenger->name == 'email' && $message_type->name == 'registration') {
225 225
             
226
-            switch ($template_file_prefix) {
226
+			switch ($template_file_prefix) {
227 227
                 
228
-                case 'question_list_admin' :
229
-                case 'question_list_attendee' :
230
-                case 'question_list_primary_attendee' :
231
-                    $path     = $base_path . $msg_prefix . 'question_list.template.php';
232
-                    $contents = EEH_Template::display_template($path, array(), true);
233
-                    break;
228
+				case 'question_list_admin' :
229
+				case 'question_list_attendee' :
230
+				case 'question_list_primary_attendee' :
231
+					$path     = $base_path . $msg_prefix . 'question_list.template.php';
232
+					$contents = EEH_Template::display_template($path, array(), true);
233
+					break;
234 234
                 
235
-                case 'attendee_list_primary_attendee' :
236
-                    $path     = $base_path . $msg_prefix . 'attendee_list.template.php';
237
-                    $contents = EEH_Template::display_template($path, array(), true);
238
-                    break;
235
+				case 'attendee_list_primary_attendee' :
236
+					$path     = $base_path . $msg_prefix . 'attendee_list.template.php';
237
+					$contents = EEH_Template::display_template($path, array(), true);
238
+					break;
239 239
                 
240
-                case 'attendee_list_admin' :
241
-                    $path     = $base_path . $msg_prefix . 'attendee_list_admin.template.php';
242
-                    $contents = EEH_Template::display_template($path,
243
-                        array(), true);
244
-                    break;
240
+				case 'attendee_list_admin' :
241
+					$path     = $base_path . $msg_prefix . 'attendee_list_admin.template.php';
242
+					$contents = EEH_Template::display_template($path,
243
+						array(), true);
244
+					break;
245 245
                 
246
-                case 'attendee_list_attendee' :
247
-                    $contents = '';
248
-                    break;
246
+				case 'attendee_list_attendee' :
247
+					$contents = '';
248
+					break;
249 249
                 
250
-                case 'event_list_attendee' :
251
-                    $path     = $base_path . $msg_prefix . 'event_list_attendee.template.php';
252
-                    $contents = EEH_Template::display_template($path, array(), true);
253
-                    break;
254
-            }
255
-        } elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') {
256
-            switch ($template_file_prefix) {
250
+				case 'event_list_attendee' :
251
+					$path     = $base_path . $msg_prefix . 'event_list_attendee.template.php';
252
+					$contents = EEH_Template::display_template($path, array(), true);
253
+					break;
254
+			}
255
+		} elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') {
256
+			switch ($template_file_prefix) {
257 257
                 
258
-                case 'content_attendee' :
259
-                    $path     = $base_path . $msg_prefix . 'content.template.php';
260
-                    $contents = EEH_Template::display_template($path, array(), true);
261
-                    break;
258
+				case 'content_attendee' :
259
+					$path     = $base_path . $msg_prefix . 'content.template.php';
260
+					$contents = EEH_Template::display_template($path, array(), true);
261
+					break;
262 262
                 
263
-                case 'newsletter_content_attendee' :
264
-                    $path     = $base_path . $msg_prefix . 'newsletter_content.template.php';
265
-                    $contents = EEH_Template::display_template($path, array(), true);
266
-                    break;
263
+				case 'newsletter_content_attendee' :
264
+					$path     = $base_path . $msg_prefix . 'newsletter_content.template.php';
265
+					$contents = EEH_Template::display_template($path, array(), true);
266
+					break;
267 267
                 
268
-                case 'newsletter_subject_attendee' :
269
-                    $path     = $base_path . $msg_prefix . 'subject.template.php';
270
-                    $contents = EEH_Template::display_template($path, array(), true);
271
-                    break;
272
-            }
273
-        } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') {
274
-            switch ($template_file_prefix) {
275
-                case 'attendee_list_purchaser' :
276
-                    $path     = $base_path . $msg_prefix . 'attendee_list.template.php';
277
-                    $contents = EEH_Template::display_template($path, array(), true);
278
-                    break;
279
-            }
280
-        }
281
-        
282
-        return $contents;
283
-        
284
-    }
285
-    
286
-    
287
-    public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg)
288
-    {
289
-        //make sure question_list and question are ONLY added for the core message types.  Any other message types will have to explicitly set question_list as a valid shortcode.
290
-        $include_with = array(
291
-            'registration',
292
-            'cancelled_registration',
293
-            'declined_registration',
294
-            'not_approved_registration',
295
-            'payment_declined',
296
-            'payment_failed',
297
-            'payment_cancelled',
298
-            'payment',
299
-            'payment_reminder',
300
-            'pending_approval',
301
-            'registration_summary',
302
-            'invoice',
303
-            'receipt'
304
-        );
305
-        if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) {
306
-            $contexts = array_keys($msg->get_contexts());
307
-            foreach ($contexts as $context) {
308
-                $valid_shortcodes[$context][] = 'question_list';
309
-                $valid_shortcodes[$context][] = 'question';
310
-            }
311
-        }
312
-        
313
-        return $valid_shortcodes;
314
-    }
315
-    
316
-    
317
-    public function additional_attendee_shortcodes($shortcodes, $shortcode_parser)
318
-    {
319
-        $shortcodes['[ANSWER_*]'] = __('This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.',
320
-            'event_espresso');
321
-        
322
-        return $shortcodes;
323
-    }
324
-    
325
-    
326
-    public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
327
-    {
328
-        
329
-        if (strpos($shortcode,
330
-                '[ANSWER_*') === false || ! isset($extra_data['data']->questions) || ! isset($extra_data['data']->registrations)
331
-        ) {
332
-            return $parsed;
333
-        }
334
-        
335
-        //let's get the question from the code.
336
-        $shortcode = str_replace('[ANSWER_*', '', $shortcode);
337
-        $shortcode = trim(str_replace(']', '', $shortcode));
338
-        
339
-        $registration = $data instanceof EE_Registration ? $data : null;
340
-        $registration = ! $registration instanceof EE_Registration && is_array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration;
341
-        
342
-        $aee = $data instanceof EE_Messages_Addressee ? $data : null;
343
-        $aee = ! $aee instanceof EE_Messages_Addressee && is_array($extra_data) && isset($extra_data['data']) ? $extra_data['data'] : $aee;
344
-        
345
-        if ( ! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) {
346
-            return $parsed;
347
-        }
348
-        
349
-        //now let's figure out which question has this text.
350
-        foreach ($aee->questions as $ansid => $question) {
351
-            if (
352
-                $question instanceof EE_Question
353
-                && trim($question->display_text()) == trim($shortcode)
354
-                && isset($aee->registrations[$registration->ID()]['ans_objs'][$ansid])
355
-            ) {
356
-                return $aee->registrations[$registration->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value',
357
-                    'no_wpautop');
358
-            }
359
-        }
360
-        
361
-        //nothing!
362
-        return $parsed;
363
-    }
364
-    
365
-    
366
-    /**
367
-     * Callback for additional shortcodes filter for adding additional datetime shortcodes.
368
-     *
369
-     * @since  4.2
370
-     *
371
-     * @param  array                  $shortcodes         array of shortcodes and
372
-     *                                                    descriptions
373
-     * @param  EE_Datetime_Shortcodes $shortcode_parser   EE_Shortcodes object
374
-     *
375
-     * @return array                                        array of shortcodes and
376
-     *                                                        descriptions
377
-     */
378
-    public function additional_datetime_shortcodes($shortcodes, $shortcode_parser)
379
-    {
380
-        $shortcodes['[DTT_NAME]']          = __('This will be parsed to the Title given for a Datetime',
381
-            'event_espresso');
382
-        $shortcodes['[DTT_DESCRIPTION]']   = __('This will be parsed to the description for a Datetime',
383
-            'event_espresso');
384
-        $shortcodes['[DTT_NAME_OR_DATES]'] = __('When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.',
385
-            'event_espresso');
386
-        
387
-        return $shortcodes;
388
-    }
389
-    
390
-    
391
-    /**
392
-     * Callback for additional shortcodes parser filter used for adding parser for new
393
-     * Datetime shortcodes
394
-     *
395
-     * @since  4.2
396
-     *
397
-     * @param  string                 $parsed     The finished parsed string for the given shortcode.
398
-     * @param  string                 $shortcode  The shortcode being parsed.
399
-     * @param  object                 $data       The incoming data object for the Shortcode Parser.
400
-     * @param  object                 $extra_data The incoming extra date object for the Shortcode
401
-     *                                            Parser.
402
-     * @param  EE_Datetime_Shortcodes $shortcode_parser
403
-     *
404
-     * @return string                   The new parsed string.
405
-     */
406
-    public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
407
-    {
408
-        
409
-        if ( ! $data instanceof EE_Datetime) {
410
-            return ''; //get out because we can only parse with the datetime object.
411
-        }
412
-        
413
-        switch ($shortcode) {
414
-            case '[DTT_NAME]' :
415
-                return $data->name();
416
-                break;
417
-            case '[DTT_DESCRIPTION]' :
418
-                return $data->description();
419
-                break;
420
-            case '[DTT_NAME_OR_DATES]' :
421
-                return $data->get_dtt_display_name(true);
422
-                break;
423
-            default :
424
-                return $parsed;
425
-                break;
426
-        }
427
-    }
428
-    
429
-    
430
-    public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser)
431
-    {
432
-        $shortcodes['[RECIPIENT_QUESTION_LIST]'] = __('This is used to indicate where you want the list of questions and answers to show for the person receiving the message.',
433
-            'event_espresso');
434
-        
435
-        return $shortcodes;
436
-    }
437
-    
438
-    
439
-    public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
440
-    {
441
-        
442
-        if (array($data) && ! isset($data['data'])) {
443
-            return $parsed;
444
-        }
445
-        
446
-        $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
447
-        $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
448
-        
449
-        if ( ! $recipient instanceof EE_Messages_Addressee) {
450
-            return $parsed;
451
-        }
452
-        
453
-        switch ($shortcode) {
454
-            case '[RECIPIENT_QUESTION_LIST]' :
455
-                $att                       = $recipient->att_obj;
456
-                $registrations_on_attendee = $att instanceof EE_Attendee ? $recipient->attendees[$att->ID()]['reg_objs'] : array();
457
-                $registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee;
458
-                $answers                   = array();
268
+				case 'newsletter_subject_attendee' :
269
+					$path     = $base_path . $msg_prefix . 'subject.template.php';
270
+					$contents = EEH_Template::display_template($path, array(), true);
271
+					break;
272
+			}
273
+		} elseif ($messenger->name == 'html' && $message_type->name == 'receipt') {
274
+			switch ($template_file_prefix) {
275
+				case 'attendee_list_purchaser' :
276
+					$path     = $base_path . $msg_prefix . 'attendee_list.template.php';
277
+					$contents = EEH_Template::display_template($path, array(), true);
278
+					break;
279
+			}
280
+		}
281
+        
282
+		return $contents;
283
+        
284
+	}
285
+    
286
+    
287
+	public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg)
288
+	{
289
+		//make sure question_list and question are ONLY added for the core message types.  Any other message types will have to explicitly set question_list as a valid shortcode.
290
+		$include_with = array(
291
+			'registration',
292
+			'cancelled_registration',
293
+			'declined_registration',
294
+			'not_approved_registration',
295
+			'payment_declined',
296
+			'payment_failed',
297
+			'payment_cancelled',
298
+			'payment',
299
+			'payment_reminder',
300
+			'pending_approval',
301
+			'registration_summary',
302
+			'invoice',
303
+			'receipt'
304
+		);
305
+		if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) {
306
+			$contexts = array_keys($msg->get_contexts());
307
+			foreach ($contexts as $context) {
308
+				$valid_shortcodes[$context][] = 'question_list';
309
+				$valid_shortcodes[$context][] = 'question';
310
+			}
311
+		}
312
+        
313
+		return $valid_shortcodes;
314
+	}
315
+    
316
+    
317
+	public function additional_attendee_shortcodes($shortcodes, $shortcode_parser)
318
+	{
319
+		$shortcodes['[ANSWER_*]'] = __('This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.',
320
+			'event_espresso');
321
+        
322
+		return $shortcodes;
323
+	}
324
+    
325
+    
326
+	public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
327
+	{
328
+        
329
+		if (strpos($shortcode,
330
+				'[ANSWER_*') === false || ! isset($extra_data['data']->questions) || ! isset($extra_data['data']->registrations)
331
+		) {
332
+			return $parsed;
333
+		}
334
+        
335
+		//let's get the question from the code.
336
+		$shortcode = str_replace('[ANSWER_*', '', $shortcode);
337
+		$shortcode = trim(str_replace(']', '', $shortcode));
338
+        
339
+		$registration = $data instanceof EE_Registration ? $data : null;
340
+		$registration = ! $registration instanceof EE_Registration && is_array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration;
341
+        
342
+		$aee = $data instanceof EE_Messages_Addressee ? $data : null;
343
+		$aee = ! $aee instanceof EE_Messages_Addressee && is_array($extra_data) && isset($extra_data['data']) ? $extra_data['data'] : $aee;
344
+        
345
+		if ( ! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) {
346
+			return $parsed;
347
+		}
348
+        
349
+		//now let's figure out which question has this text.
350
+		foreach ($aee->questions as $ansid => $question) {
351
+			if (
352
+				$question instanceof EE_Question
353
+				&& trim($question->display_text()) == trim($shortcode)
354
+				&& isset($aee->registrations[$registration->ID()]['ans_objs'][$ansid])
355
+			) {
356
+				return $aee->registrations[$registration->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value',
357
+					'no_wpautop');
358
+			}
359
+		}
360
+        
361
+		//nothing!
362
+		return $parsed;
363
+	}
364
+    
365
+    
366
+	/**
367
+	 * Callback for additional shortcodes filter for adding additional datetime shortcodes.
368
+	 *
369
+	 * @since  4.2
370
+	 *
371
+	 * @param  array                  $shortcodes         array of shortcodes and
372
+	 *                                                    descriptions
373
+	 * @param  EE_Datetime_Shortcodes $shortcode_parser   EE_Shortcodes object
374
+	 *
375
+	 * @return array                                        array of shortcodes and
376
+	 *                                                        descriptions
377
+	 */
378
+	public function additional_datetime_shortcodes($shortcodes, $shortcode_parser)
379
+	{
380
+		$shortcodes['[DTT_NAME]']          = __('This will be parsed to the Title given for a Datetime',
381
+			'event_espresso');
382
+		$shortcodes['[DTT_DESCRIPTION]']   = __('This will be parsed to the description for a Datetime',
383
+			'event_espresso');
384
+		$shortcodes['[DTT_NAME_OR_DATES]'] = __('When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.',
385
+			'event_espresso');
386
+        
387
+		return $shortcodes;
388
+	}
389
+    
390
+    
391
+	/**
392
+	 * Callback for additional shortcodes parser filter used for adding parser for new
393
+	 * Datetime shortcodes
394
+	 *
395
+	 * @since  4.2
396
+	 *
397
+	 * @param  string                 $parsed     The finished parsed string for the given shortcode.
398
+	 * @param  string                 $shortcode  The shortcode being parsed.
399
+	 * @param  object                 $data       The incoming data object for the Shortcode Parser.
400
+	 * @param  object                 $extra_data The incoming extra date object for the Shortcode
401
+	 *                                            Parser.
402
+	 * @param  EE_Datetime_Shortcodes $shortcode_parser
403
+	 *
404
+	 * @return string                   The new parsed string.
405
+	 */
406
+	public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
407
+	{
408
+        
409
+		if ( ! $data instanceof EE_Datetime) {
410
+			return ''; //get out because we can only parse with the datetime object.
411
+		}
412
+        
413
+		switch ($shortcode) {
414
+			case '[DTT_NAME]' :
415
+				return $data->name();
416
+				break;
417
+			case '[DTT_DESCRIPTION]' :
418
+				return $data->description();
419
+				break;
420
+			case '[DTT_NAME_OR_DATES]' :
421
+				return $data->get_dtt_display_name(true);
422
+				break;
423
+			default :
424
+				return $parsed;
425
+				break;
426
+		}
427
+	}
428
+    
429
+    
430
+	public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser)
431
+	{
432
+		$shortcodes['[RECIPIENT_QUESTION_LIST]'] = __('This is used to indicate where you want the list of questions and answers to show for the person receiving the message.',
433
+			'event_espresso');
434
+        
435
+		return $shortcodes;
436
+	}
437
+    
438
+    
439
+	public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
440
+	{
441
+        
442
+		if (array($data) && ! isset($data['data'])) {
443
+			return $parsed;
444
+		}
445
+        
446
+		$recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
447
+		$recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
448
+        
449
+		if ( ! $recipient instanceof EE_Messages_Addressee) {
450
+			return $parsed;
451
+		}
452
+        
453
+		switch ($shortcode) {
454
+			case '[RECIPIENT_QUESTION_LIST]' :
455
+				$att                       = $recipient->att_obj;
456
+				$registrations_on_attendee = $att instanceof EE_Attendee ? $recipient->attendees[$att->ID()]['reg_objs'] : array();
457
+				$registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee;
458
+				$answers                   = array();
459 459
                 
460
-                $template         = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list'];
461
-                $valid_shortcodes = array('question');
460
+				$template         = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list'];
461
+				$valid_shortcodes = array('question');
462 462
                 
463
-                //if the context is main_content then get all answers for all registrations on this attendee
464
-                if ($data['data'] instanceof EE_Messages_Addressee) {
465
-                    foreach ($registrations_on_attendee as $reg) {
466
-                        if ($reg instanceof EE_Registration) {
467
-                            $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array();
468
-                            foreach ($anss as $ans) {
469
-                                if ($ans instanceof EE_Answer) {
470
-                                    $answers[$ans->ID()] = $ans;
471
-                                }
472
-                            }
473
-                        }
474
-                    }
475
-                }
463
+				//if the context is main_content then get all answers for all registrations on this attendee
464
+				if ($data['data'] instanceof EE_Messages_Addressee) {
465
+					foreach ($registrations_on_attendee as $reg) {
466
+						if ($reg instanceof EE_Registration) {
467
+							$anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array();
468
+							foreach ($anss as $ans) {
469
+								if ($ans instanceof EE_Answer) {
470
+									$answers[$ans->ID()] = $ans;
471
+								}
472
+							}
473
+						}
474
+					}
475
+				}
476 476
                 
477
-                //if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event.
478
-                if ($data['data'] instanceof EE_Event) {
479
-                    $event = $data['data'];
480
-                    foreach ($registrations_on_attendee as $reg) {
481
-                        if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
482
-                            $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array();
483
-                            foreach ($anss as $ans) {
484
-                                if ($ans instanceof EE_Answer) {
485
-                                    $answers[$ans->ID()] = $ans;
486
-                                }
487
-                            }
488
-                        }
489
-                    }
490
-                }
477
+				//if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event.
478
+				if ($data['data'] instanceof EE_Event) {
479
+					$event = $data['data'];
480
+					foreach ($registrations_on_attendee as $reg) {
481
+						if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
482
+							$anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array();
483
+							foreach ($anss as $ans) {
484
+								if ($ans instanceof EE_Answer) {
485
+									$answers[$ans->ID()] = $ans;
486
+								}
487
+							}
488
+						}
489
+					}
490
+				}
491 491
                 
492
-                $question_list    = '';
493
-                $shortcode_helper = $shortcode_parser->get_shortcode_helper();
494
-                foreach ($answers as $answer) {
495
-                    if ($answer instanceof EE_Answer) {
496
-                        $question = $answer->question();
497
-                        if ( ! $question instanceof EE_Question || ($question instanceof EE_Question && $question->admin_only())) {
498
-                            continue;
499
-                        }
500
-                        $question_list .= $shortcode_helper->parse_question_list_template($template, $answer,
501
-                            $valid_shortcodes, $extra_data);
502
-                    }
503
-                }
492
+				$question_list    = '';
493
+				$shortcode_helper = $shortcode_parser->get_shortcode_helper();
494
+				foreach ($answers as $answer) {
495
+					if ($answer instanceof EE_Answer) {
496
+						$question = $answer->question();
497
+						if ( ! $question instanceof EE_Question || ($question instanceof EE_Question && $question->admin_only())) {
498
+							continue;
499
+						}
500
+						$question_list .= $shortcode_helper->parse_question_list_template($template, $answer,
501
+							$valid_shortcodes, $extra_data);
502
+					}
503
+				}
504 504
                 
505
-                return $question_list;
506
-                break;
505
+				return $question_list;
506
+				break;
507 507
             
508
-            default :
509
-                return $parsed;
510
-                break;
511
-        }
512
-    }
513
-    
514
-    
515
-    public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser)
516
-    {
517
-        $shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = __('This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field',
518
-            'event_espresso');
519
-        
520
-        return $shortcodes;
521
-    }
522
-    
523
-    
524
-    public function additional_primary_registration_details_parser(
525
-        $parsed,
526
-        $shortcode,
527
-        $data,
528
-        $extra_data,
529
-        $shortcode_parser
530
-    ) {
531
-        if (array($data) && ! isset($data['data'])) {
532
-            return $parsed;
533
-        }
534
-        
535
-        $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
536
-        $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
537
-        
538
-        if ( ! $recipient instanceof EE_Messages_Addressee) {
539
-            return $parsed;
540
-        }
541
-        
542
-        $send_data = ! $data['data'] instanceof EE_Messages_Addressee ? $extra_data : $data;
543
-        
544
-        switch ($shortcode) {
545
-            case '[RECIPIENT_QUESTION_LIST]' :
546
-                if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
547
-                    return '';
548
-                }
549
-                $registration     = $recipient->primary_reg_obj;
550
-                $template         = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list'];
551
-                $valid_shortcodes = array('question');
552
-                $shortcode_helper = $shortcode_parser->get_shortcode_helper();
553
-                $answers          = $recipient->registrations[$registration->ID()]['ans_objs'];
554
-                $question_list    = '';
555
-                foreach ($answers as $answer) {
556
-                    if ($answer instanceof EE_Answer) {
557
-                        $question = $answer->question();
558
-                        if ($question instanceof EE_Question and $question->admin_only()) {
559
-                            continue;
560
-                        }
561
-                        $question_list .= $shortcode_helper->parse_question_list_template($template, $answer,
562
-                            $valid_shortcodes, $send_data);
563
-                    }
564
-                }
508
+			default :
509
+				return $parsed;
510
+				break;
511
+		}
512
+	}
513
+    
514
+    
515
+	public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser)
516
+	{
517
+		$shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = __('This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field',
518
+			'event_espresso');
519
+        
520
+		return $shortcodes;
521
+	}
522
+    
523
+    
524
+	public function additional_primary_registration_details_parser(
525
+		$parsed,
526
+		$shortcode,
527
+		$data,
528
+		$extra_data,
529
+		$shortcode_parser
530
+	) {
531
+		if (array($data) && ! isset($data['data'])) {
532
+			return $parsed;
533
+		}
534
+        
535
+		$recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
536
+		$recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
537
+        
538
+		if ( ! $recipient instanceof EE_Messages_Addressee) {
539
+			return $parsed;
540
+		}
541
+        
542
+		$send_data = ! $data['data'] instanceof EE_Messages_Addressee ? $extra_data : $data;
543
+        
544
+		switch ($shortcode) {
545
+			case '[RECIPIENT_QUESTION_LIST]' :
546
+				if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
547
+					return '';
548
+				}
549
+				$registration     = $recipient->primary_reg_obj;
550
+				$template         = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list'];
551
+				$valid_shortcodes = array('question');
552
+				$shortcode_helper = $shortcode_parser->get_shortcode_helper();
553
+				$answers          = $recipient->registrations[$registration->ID()]['ans_objs'];
554
+				$question_list    = '';
555
+				foreach ($answers as $answer) {
556
+					if ($answer instanceof EE_Answer) {
557
+						$question = $answer->question();
558
+						if ($question instanceof EE_Question and $question->admin_only()) {
559
+							continue;
560
+						}
561
+						$question_list .= $shortcode_helper->parse_question_list_template($template, $answer,
562
+							$valid_shortcodes, $send_data);
563
+					}
564
+				}
565 565
                 
566
-                return $question_list;
567
-                break;
566
+				return $question_list;
567
+				break;
568 568
             
569
-            default :
570
-                return $parsed;
571
-                break;
572
-        }
573
-    }
574
-    
575
-    
576
-    /**
577
-     * Takes care of registering the  message types that are only available in caffeinated EE.
578
-     *
579
-     * @since   4.3.2
580
-     *
581
-     * @return  void
582
-     */
583
-    public function register_caf_message_types()
584
-    {
585
-        //register newsletter message type
586
-        $setup_args = array(
587
-            'mtfilename'                  => 'EE_Newsletter_message_type.class.php',
588
-            'autoloadpaths'               => array(
589
-                EE_CAF_LIBRARIES . 'messages/message_type/newsletter/'
590
-            ),
591
-            'messengers_to_activate_with' => array('email'),
592
-            'messengers_to_validate_with' => array('email')
593
-        );
594
-        EE_Register_Message_Type::register('newsletter', $setup_args);
595
-        
596
-        //register payment reminder message type
597
-        $setup_args = array(
598
-            'mtfilename'                  => 'EE_Payment_Reminder_message_type.class.php',
599
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
600
-            'messengers_to_activate_with' => array('email'),
601
-            'messengers_to_validate_with' => array('email')
602
-        );
603
-        EE_Register_Message_Type::register('payment_reminder', $setup_args);
604
-        
605
-        //register payment declined message type
606
-        $setup_args = array(
607
-            'mtfilename'                  => 'EE_Payment_Declined_message_type.class.php',
608
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
609
-            'messengers_to_activate_with' => array('email'),
610
-            'messengers_to_validate_with' => array('email')
611
-        );
612
-        EE_Register_Message_Type::register('payment_declined', $setup_args);
613
-        
614
-        //register registration declined message type
615
-        $setup_args = array(
616
-            'mtfilename'                  => 'EE_Declined_Registration_message_type.class.php',
617
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
618
-            'messengers_to_activate_with' => array('email'),
619
-            'messengers_to_validate_with' => array('email')
620
-        );
621
-        EE_Register_Message_Type::register('declined_registration', $setup_args);
622
-        
623
-        //register registration cancelled message type
624
-        $setup_args = array(
625
-            'mtfilename'                  => 'EE_Cancelled_Registration_message_type.class.php',
626
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
627
-            'messengers_to_activate_with' => array('email'),
628
-            'messengers_to_validate_with' => array('email')
629
-        );
630
-        EE_Register_Message_Type::register('cancelled_registration', $setup_args);
631
-        
632
-        
633
-        //register payment failed message type
634
-        $setup_args = array(
635
-            'mtfilename'                  => 'EE_Payment_Failed_message_type.class.php',
636
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
637
-            'messengers_to_activate_with' => array('email'),
638
-            'messengers_to_validate_with' => array('email')
639
-        );
640
-        EE_Register_Message_Type::register('payment_failed', $setup_args);
641
-        
642
-        //register payment declined message type
643
-        $setup_args = array(
644
-            'mtfilename'                  => 'EE_Payment_Cancelled_message_type.class.php',
645
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
646
-            'messengers_to_activate_with' => array('email'),
647
-            'messengers_to_validate_with' => array('email')
648
-        );
649
-        EE_Register_Message_Type::register('payment_cancelled', $setup_args);
650
-    }
651
-    
652
-    
653
-    /**
654
-     * Takes care of registering the  shortcode libraries implemented with caffeinated EE and set up related items.
655
-     *
656
-     * @since   4.3.2
657
-     *
658
-     * @return void
659
-     */
660
-    public function register_caf_shortcodes()
661
-    {
662
-        $setup_args = array(
663
-            'autoloadpaths'                 => array(
664
-                EE_CAF_LIBRARIES . 'shortcodes/'
665
-            ),
666
-            'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
667
-            'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
668
-            'list_type_shortcodes'          => array('[NEWSLETTER_CONTENT]')
669
-        );
670
-        EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args);
671
-    }
569
+			default :
570
+				return $parsed;
571
+				break;
572
+		}
573
+	}
574
+    
575
+    
576
+	/**
577
+	 * Takes care of registering the  message types that are only available in caffeinated EE.
578
+	 *
579
+	 * @since   4.3.2
580
+	 *
581
+	 * @return  void
582
+	 */
583
+	public function register_caf_message_types()
584
+	{
585
+		//register newsletter message type
586
+		$setup_args = array(
587
+			'mtfilename'                  => 'EE_Newsletter_message_type.class.php',
588
+			'autoloadpaths'               => array(
589
+				EE_CAF_LIBRARIES . 'messages/message_type/newsletter/'
590
+			),
591
+			'messengers_to_activate_with' => array('email'),
592
+			'messengers_to_validate_with' => array('email')
593
+		);
594
+		EE_Register_Message_Type::register('newsletter', $setup_args);
595
+        
596
+		//register payment reminder message type
597
+		$setup_args = array(
598
+			'mtfilename'                  => 'EE_Payment_Reminder_message_type.class.php',
599
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
600
+			'messengers_to_activate_with' => array('email'),
601
+			'messengers_to_validate_with' => array('email')
602
+		);
603
+		EE_Register_Message_Type::register('payment_reminder', $setup_args);
604
+        
605
+		//register payment declined message type
606
+		$setup_args = array(
607
+			'mtfilename'                  => 'EE_Payment_Declined_message_type.class.php',
608
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
609
+			'messengers_to_activate_with' => array('email'),
610
+			'messengers_to_validate_with' => array('email')
611
+		);
612
+		EE_Register_Message_Type::register('payment_declined', $setup_args);
613
+        
614
+		//register registration declined message type
615
+		$setup_args = array(
616
+			'mtfilename'                  => 'EE_Declined_Registration_message_type.class.php',
617
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
618
+			'messengers_to_activate_with' => array('email'),
619
+			'messengers_to_validate_with' => array('email')
620
+		);
621
+		EE_Register_Message_Type::register('declined_registration', $setup_args);
622
+        
623
+		//register registration cancelled message type
624
+		$setup_args = array(
625
+			'mtfilename'                  => 'EE_Cancelled_Registration_message_type.class.php',
626
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
627
+			'messengers_to_activate_with' => array('email'),
628
+			'messengers_to_validate_with' => array('email')
629
+		);
630
+		EE_Register_Message_Type::register('cancelled_registration', $setup_args);
631
+        
632
+        
633
+		//register payment failed message type
634
+		$setup_args = array(
635
+			'mtfilename'                  => 'EE_Payment_Failed_message_type.class.php',
636
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
637
+			'messengers_to_activate_with' => array('email'),
638
+			'messengers_to_validate_with' => array('email')
639
+		);
640
+		EE_Register_Message_Type::register('payment_failed', $setup_args);
641
+        
642
+		//register payment declined message type
643
+		$setup_args = array(
644
+			'mtfilename'                  => 'EE_Payment_Cancelled_message_type.class.php',
645
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
646
+			'messengers_to_activate_with' => array('email'),
647
+			'messengers_to_validate_with' => array('email')
648
+		);
649
+		EE_Register_Message_Type::register('payment_cancelled', $setup_args);
650
+	}
651
+    
652
+    
653
+	/**
654
+	 * Takes care of registering the  shortcode libraries implemented with caffeinated EE and set up related items.
655
+	 *
656
+	 * @since   4.3.2
657
+	 *
658
+	 * @return void
659
+	 */
660
+	public function register_caf_shortcodes()
661
+	{
662
+		$setup_args = array(
663
+			'autoloadpaths'                 => array(
664
+				EE_CAF_LIBRARIES . 'shortcodes/'
665
+			),
666
+			'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
667
+			'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
668
+			'list_type_shortcodes'          => array('[NEWSLETTER_CONTENT]')
669
+		);
670
+		EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args);
671
+	}
672 672
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      */
96 96
     public function messages_autoload_paths($dir_ref)
97 97
     {
98
-        $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/';
98
+        $dir_ref[] = EE_CAF_LIBRARIES.'shortcodes/';
99 99
         
100 100
         return $dir_ref;
101 101
     }
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
         }
217 217
         
218 218
         //the template file name we're replacing contents for.
219
-        $template_file_prefix = $field . '_' . $context;
220
-        $msg_prefix           = $messenger->name . '_' . $message_type->name . '_';
219
+        $template_file_prefix = $field.'_'.$context;
220
+        $msg_prefix           = $messenger->name.'_'.$message_type->name.'_';
221 221
         
222
-        $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/';
222
+        $base_path = EE_CAF_LIBRARIES.'messages/defaults/default/';
223 223
         
224 224
         if ($messenger->name == 'email' && $message_type->name == 'registration') {
225 225
             
@@ -228,17 +228,17 @@  discard block
 block discarded – undo
228 228
                 case 'question_list_admin' :
229 229
                 case 'question_list_attendee' :
230 230
                 case 'question_list_primary_attendee' :
231
-                    $path     = $base_path . $msg_prefix . 'question_list.template.php';
231
+                    $path     = $base_path.$msg_prefix.'question_list.template.php';
232 232
                     $contents = EEH_Template::display_template($path, array(), true);
233 233
                     break;
234 234
                 
235 235
                 case 'attendee_list_primary_attendee' :
236
-                    $path     = $base_path . $msg_prefix . 'attendee_list.template.php';
236
+                    $path     = $base_path.$msg_prefix.'attendee_list.template.php';
237 237
                     $contents = EEH_Template::display_template($path, array(), true);
238 238
                     break;
239 239
                 
240 240
                 case 'attendee_list_admin' :
241
-                    $path     = $base_path . $msg_prefix . 'attendee_list_admin.template.php';
241
+                    $path     = $base_path.$msg_prefix.'attendee_list_admin.template.php';
242 242
                     $contents = EEH_Template::display_template($path,
243 243
                         array(), true);
244 244
                     break;
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
                     break;
249 249
                 
250 250
                 case 'event_list_attendee' :
251
-                    $path     = $base_path . $msg_prefix . 'event_list_attendee.template.php';
251
+                    $path     = $base_path.$msg_prefix.'event_list_attendee.template.php';
252 252
                     $contents = EEH_Template::display_template($path, array(), true);
253 253
                     break;
254 254
             }
@@ -256,24 +256,24 @@  discard block
 block discarded – undo
256 256
             switch ($template_file_prefix) {
257 257
                 
258 258
                 case 'content_attendee' :
259
-                    $path     = $base_path . $msg_prefix . 'content.template.php';
259
+                    $path     = $base_path.$msg_prefix.'content.template.php';
260 260
                     $contents = EEH_Template::display_template($path, array(), true);
261 261
                     break;
262 262
                 
263 263
                 case 'newsletter_content_attendee' :
264
-                    $path     = $base_path . $msg_prefix . 'newsletter_content.template.php';
264
+                    $path     = $base_path.$msg_prefix.'newsletter_content.template.php';
265 265
                     $contents = EEH_Template::display_template($path, array(), true);
266 266
                     break;
267 267
                 
268 268
                 case 'newsletter_subject_attendee' :
269
-                    $path     = $base_path . $msg_prefix . 'subject.template.php';
269
+                    $path     = $base_path.$msg_prefix.'subject.template.php';
270 270
                     $contents = EEH_Template::display_template($path, array(), true);
271 271
                     break;
272 272
             }
273 273
         } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') {
274 274
             switch ($template_file_prefix) {
275 275
                 case 'attendee_list_purchaser' :
276
-                    $path     = $base_path . $msg_prefix . 'attendee_list.template.php';
276
+                    $path     = $base_path.$msg_prefix.'attendee_list.template.php';
277 277
                     $contents = EEH_Template::display_template($path, array(), true);
278 278
                     break;
279 279
             }
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
         $setup_args = array(
587 587
             'mtfilename'                  => 'EE_Newsletter_message_type.class.php',
588 588
             'autoloadpaths'               => array(
589
-                EE_CAF_LIBRARIES . 'messages/message_type/newsletter/'
589
+                EE_CAF_LIBRARIES.'messages/message_type/newsletter/'
590 590
             ),
591 591
             'messengers_to_activate_with' => array('email'),
592 592
             'messengers_to_validate_with' => array('email')
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
         //register payment reminder message type
597 597
         $setup_args = array(
598 598
             'mtfilename'                  => 'EE_Payment_Reminder_message_type.class.php',
599
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
599
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/payment_reminder/'),
600 600
             'messengers_to_activate_with' => array('email'),
601 601
             'messengers_to_validate_with' => array('email')
602 602
         );
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
         //register payment declined message type
606 606
         $setup_args = array(
607 607
             'mtfilename'                  => 'EE_Payment_Declined_message_type.class.php',
608
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
608
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/payment_declined/'),
609 609
             'messengers_to_activate_with' => array('email'),
610 610
             'messengers_to_validate_with' => array('email')
611 611
         );
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
         //register registration declined message type
615 615
         $setup_args = array(
616 616
             'mtfilename'                  => 'EE_Declined_Registration_message_type.class.php',
617
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
617
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/declined_registration/'),
618 618
             'messengers_to_activate_with' => array('email'),
619 619
             'messengers_to_validate_with' => array('email')
620 620
         );
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
         //register registration cancelled message type
624 624
         $setup_args = array(
625 625
             'mtfilename'                  => 'EE_Cancelled_Registration_message_type.class.php',
626
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
626
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/cancelled_registration/'),
627 627
             'messengers_to_activate_with' => array('email'),
628 628
             'messengers_to_validate_with' => array('email')
629 629
         );
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
         //register payment failed message type
634 634
         $setup_args = array(
635 635
             'mtfilename'                  => 'EE_Payment_Failed_message_type.class.php',
636
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
636
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/payment_failed/'),
637 637
             'messengers_to_activate_with' => array('email'),
638 638
             'messengers_to_validate_with' => array('email')
639 639
         );
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
         //register payment declined message type
643 643
         $setup_args = array(
644 644
             'mtfilename'                  => 'EE_Payment_Cancelled_message_type.class.php',
645
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
645
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/payment_cancelled/'),
646 646
             'messengers_to_activate_with' => array('email'),
647 647
             'messengers_to_validate_with' => array('email')
648 648
         );
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
     {
662 662
         $setup_args = array(
663 663
             'autoloadpaths'                 => array(
664
-                EE_CAF_LIBRARIES . 'shortcodes/'
664
+                EE_CAF_LIBRARIES.'shortcodes/'
665 665
             ),
666 666
             'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
667 667
             'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
Please login to merge, or discard this patch.