Completed
Branch BUG-10267-spco-submit-submit-s... (5896c9)
by
unknown
14:21 queued 16s
created
core/data_migration_scripts/EE_DMS_Core_4_9_0.dms.php 2 patches
Spacing   +8 added lines, -8 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_9_0_stages/*');
12
+$stages = glob(EE_CORE.'data_migration_scripts/4_9_0_stages/*');
13 13
 $class_to_filepath = array();
14 14
 foreach ($stages as $filepath) {
15 15
     $matches = array();
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         } elseif ( ! $version_string) {
68 68
             //			echo "no version string provided: $version_string";
69 69
             //no version string provided... this must be pre 4.3
70
-            return false;//changed mind. dont want people thinking they should migrate yet because they cant
70
+            return false; //changed mind. dont want people thinking they should migrate yet because they cant
71 71
         } else {
72 72
             //			echo "$version_string doesnt apply";
73 73
             return false;
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      */
82 82
     public function schema_changes_before_migration()
83 83
     {
84
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
84
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
85 85
         $now_in_mysql = current_time('mysql', true);
86 86
         $table_name = 'esp_answer';
87 87
         $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
             'esp_promotion_object',
671 671
         );
672 672
         foreach ($addon_tables as $table_name) {
673
-            if($this->_table_analysis->tableExists( $table_name )){
673
+            if ($this->_table_analysis->tableExists($table_name)) {
674 674
                 $tables_to_check[] = $table_name;
675 675
             }
676 676
         }
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
         //ok and now let's remember this was done (without needing to check the db schemas all over again)
679 679
         add_option('ee_verified_db_collations', true, null, 'no');
680 680
         //seeing how this ran with the fix from 10435, no need to check again
681
-        add_option('ee_verified_db_collations_again',true,null,'no');
681
+        add_option('ee_verified_db_collations_again', true, null, 'no');
682 682
     }
683 683
 
684 684
 
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
      * which meant some DB collations might not have been updated
689 689
      * @return void
690 690
      */
691
-    public function verify_db_collations_again(){
691
+    public function verify_db_collations_again() {
692 692
         if (get_option('ee_verified_db_collations_again', false)) {
693 693
             return;
694 694
         }
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
             'esp_message'
698 698
         );
699 699
         $this->_verify_db_collations_for_tables(array_unique($tables_to_check));
700
-        add_option('ee_verified_db_collations_again',true,null,'no');
700
+        add_option('ee_verified_db_collations_again', true, null, 'no');
701 701
     }
702 702
 
703 703
 
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
     {
713 713
         foreach ($tables_to_check as $table_name) {
714 714
             $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name);
715
-            if ( ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name ) ) {
715
+            if ( ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name)) {
716 716
                 maybe_convert_table_to_utf8mb4($table_name);
717 717
             }
718 718
         }
Please login to merge, or discard this patch.
Indentation   +278 added lines, -278 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
 $stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*');
13 13
 $class_to_filepath = array();
14 14
 foreach ($stages as $filepath) {
15
-    $matches = array();
16
-    preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches);
17
-    $class_to_filepath[$matches[1]] = $filepath;
15
+	$matches = array();
16
+	preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches);
17
+	$class_to_filepath[$matches[1]] = $filepath;
18 18
 }
19 19
 //give addons a chance to autoload their stages too
20 20
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath);
@@ -33,68 +33,68 @@  discard block
 block discarded – undo
33 33
 class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base
34 34
 {
35 35
 
36
-    /**
37
-     * return EE_DMS_Core_4_9_0
38
-     *
39
-     * @param TableManager  $table_manager
40
-     * @param TableAnalysis $table_analysis
41
-     */
42
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
43
-    {
44
-        $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso");
45
-        $this->_priority = 10;
46
-        $this->_migration_stages = array(
47
-            new EE_DMS_4_9_0_Email_System_Question(),
48
-            new EE_DMS_4_9_0_Answers_With_No_Registration(),
49
-        );
50
-        parent::__construct($table_manager, $table_analysis);
51
-    }
36
+	/**
37
+	 * return EE_DMS_Core_4_9_0
38
+	 *
39
+	 * @param TableManager  $table_manager
40
+	 * @param TableAnalysis $table_analysis
41
+	 */
42
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
43
+	{
44
+		$this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso");
45
+		$this->_priority = 10;
46
+		$this->_migration_stages = array(
47
+			new EE_DMS_4_9_0_Email_System_Question(),
48
+			new EE_DMS_4_9_0_Answers_With_No_Registration(),
49
+		);
50
+		parent::__construct($table_manager, $table_analysis);
51
+	}
52 52
 
53 53
 
54 54
 
55
-    /**
56
-     * Whether to migrate or not.
57
-     *
58
-     * @param array $version_array
59
-     * @return bool
60
-     */
61
-    public function can_migrate_from_version($version_array)
62
-    {
63
-        $version_string = $version_array['Core'];
64
-        if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) {
65
-            //			echo "$version_string can be migrated from";
66
-            return true;
67
-        } elseif ( ! $version_string) {
68
-            //			echo "no version string provided: $version_string";
69
-            //no version string provided... this must be pre 4.3
70
-            return false;//changed mind. dont want people thinking they should migrate yet because they cant
71
-        } else {
72
-            //			echo "$version_string doesnt apply";
73
-            return false;
74
-        }
75
-    }
55
+	/**
56
+	 * Whether to migrate or not.
57
+	 *
58
+	 * @param array $version_array
59
+	 * @return bool
60
+	 */
61
+	public function can_migrate_from_version($version_array)
62
+	{
63
+		$version_string = $version_array['Core'];
64
+		if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) {
65
+			//			echo "$version_string can be migrated from";
66
+			return true;
67
+		} elseif ( ! $version_string) {
68
+			//			echo "no version string provided: $version_string";
69
+			//no version string provided... this must be pre 4.3
70
+			return false;//changed mind. dont want people thinking they should migrate yet because they cant
71
+		} else {
72
+			//			echo "$version_string doesnt apply";
73
+			return false;
74
+		}
75
+	}
76 76
 
77 77
 
78 78
 
79
-    /**
80
-     * @return bool
81
-     */
82
-    public function schema_changes_before_migration()
83
-    {
84
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
85
-        $now_in_mysql = current_time('mysql', true);
86
-        $table_name = 'esp_answer';
87
-        $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
79
+	/**
80
+	 * @return bool
81
+	 */
82
+	public function schema_changes_before_migration()
83
+	{
84
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
85
+		$now_in_mysql = current_time('mysql', true);
86
+		$table_name = 'esp_answer';
87
+		$sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
88 88
 					REG_ID int(10) unsigned NOT NULL,
89 89
 					QST_ID int(10) unsigned NOT NULL,
90 90
 					ANS_value text NOT NULL,
91 91
 					PRIMARY KEY  (ANS_ID),
92 92
 					KEY REG_ID (REG_ID),
93 93
 					KEY QST_ID (QST_ID)";
94
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
95
-        $table_name = 'esp_attendee_meta';
96
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email');
97
-        $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
94
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
95
+		$table_name = 'esp_attendee_meta';
96
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email');
97
+		$sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
98 98
 				ATT_ID bigint(20) unsigned NOT NULL,
99 99
 				ATT_fname varchar(45) NOT NULL,
100 100
 				ATT_lname varchar(45) NOT NULL,
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
 				KEY ATT_email (ATT_email(191)),
112 112
 				KEY ATT_lname (ATT_lname),
113 113
 				KEY ATT_fname (ATT_fname)";
114
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
115
-        $table_name = 'esp_checkin';
116
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
114
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
115
+		$table_name = 'esp_checkin';
116
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
117 117
 				REG_ID int(10) unsigned NOT NULL,
118 118
 				DTT_ID int(10) unsigned NOT NULL,
119 119
 				CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
 				PRIMARY KEY  (CHK_ID),
122 122
 				KEY REG_ID (REG_ID),
123 123
 				KEY DTT_ID (DTT_ID)";
124
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
125
-        $table_name = 'esp_country';
126
-        $sql = "CNT_ISO varchar(2) NOT NULL,
124
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
125
+		$table_name = 'esp_country';
126
+		$sql = "CNT_ISO varchar(2) NOT NULL,
127 127
 				CNT_ISO3 varchar(3) NOT NULL,
128 128
 				RGN_ID tinyint(3) unsigned DEFAULT NULL,
129 129
 				CNT_name varchar(45) NOT NULL,
@@ -139,25 +139,25 @@  discard block
 block discarded – undo
139 139
 				CNT_is_EU tinyint(1) DEFAULT '0',
140 140
 				CNT_active tinyint(1) DEFAULT '0',
141 141
 				PRIMARY KEY  (CNT_ISO)";
142
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
143
-        $table_name = 'esp_currency';
144
-        $sql = "CUR_code varchar(6) NOT NULL,
142
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
143
+		$table_name = 'esp_currency';
144
+		$sql = "CUR_code varchar(6) NOT NULL,
145 145
 				CUR_single varchar(45) DEFAULT 'dollar',
146 146
 				CUR_plural varchar(45) DEFAULT 'dollars',
147 147
 				CUR_sign varchar(45) DEFAULT '$',
148 148
 				CUR_dec_plc varchar(1) NOT NULL DEFAULT '2',
149 149
 				CUR_active tinyint(1) DEFAULT '0',
150 150
 				PRIMARY KEY  (CUR_code)";
151
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
152
-        $table_name = 'esp_currency_payment_method';
153
-        $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
151
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
152
+		$table_name = 'esp_currency_payment_method';
153
+		$sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
154 154
 				CUR_code varchar(6) NOT NULL,
155 155
 				PMD_ID int(11) NOT NULL,
156 156
 				PRIMARY KEY  (CPM_ID),
157 157
 				KEY PMD_ID (PMD_ID)";
158
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
159
-        $table_name = 'esp_datetime';
160
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
158
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
159
+		$table_name = 'esp_datetime';
160
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
161 161
 				EVT_ID bigint(20) unsigned NOT NULL,
162 162
 				DTT_name varchar(255) NOT NULL DEFAULT '',
163 163
 				DTT_description text NOT NULL,
@@ -174,25 +174,25 @@  discard block
 block discarded – undo
174 174
 				KEY DTT_EVT_start (DTT_EVT_start),
175 175
 				KEY EVT_ID (EVT_ID),
176 176
 				KEY DTT_is_primary (DTT_is_primary)";
177
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
178
-        $table_name = "esp_datetime_ticket";
179
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
177
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
178
+		$table_name = "esp_datetime_ticket";
179
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
180 180
 				DTT_ID int(10) unsigned NOT NULL,
181 181
 				TKT_ID int(10) unsigned NOT NULL,
182 182
 				PRIMARY KEY  (DTK_ID),
183 183
 				KEY DTT_ID (DTT_ID),
184 184
 				KEY TKT_ID (TKT_ID)";
185
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
186
-        $table_name = 'esp_event_message_template';
187
-        $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
185
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
186
+		$table_name = 'esp_event_message_template';
187
+		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
188 188
 				EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0,
189 189
 				GRP_ID int(10) unsigned NOT NULL DEFAULT 0,
190 190
 				PRIMARY KEY  (EMT_ID),
191 191
 				KEY EVT_ID (EVT_ID),
192 192
 				KEY GRP_ID (GRP_ID)";
193
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
194
-        $table_name = 'esp_event_meta';
195
-        $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
193
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
194
+		$table_name = 'esp_event_meta';
195
+		$sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
196 196
 				EVT_ID bigint(20) unsigned NOT NULL,
197 197
 				EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
198 198
 				EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -207,34 +207,34 @@  discard block
 block discarded – undo
207 207
 				EVT_donations tinyint(1) NULL,
208 208
 				PRIMARY KEY  (EVTM_ID),
209 209
 				KEY EVT_ID (EVT_ID)";
210
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
211
-        $table_name = 'esp_event_question_group';
212
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
210
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
211
+		$table_name = 'esp_event_question_group';
212
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
213 213
 				EVT_ID bigint(20) unsigned NOT NULL,
214 214
 				QSG_ID int(10) unsigned NOT NULL,
215 215
 				EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
216 216
 				PRIMARY KEY  (EQG_ID),
217 217
 				KEY EVT_ID (EVT_ID),
218 218
 				KEY QSG_ID (QSG_ID)";
219
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
220
-        $table_name = 'esp_event_venue';
221
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
219
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
220
+		$table_name = 'esp_event_venue';
221
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
222 222
 				EVT_ID bigint(20) unsigned NOT NULL,
223 223
 				VNU_ID bigint(20) unsigned NOT NULL,
224 224
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
225 225
 				PRIMARY KEY  (EVV_ID)";
226
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
227
-        $table_name = 'esp_extra_meta';
228
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
226
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
227
+		$table_name = 'esp_extra_meta';
228
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
229 229
 				OBJ_ID int(11) DEFAULT NULL,
230 230
 				EXM_type varchar(45) DEFAULT NULL,
231 231
 				EXM_key varchar(45) DEFAULT NULL,
232 232
 				EXM_value text,
233 233
 				PRIMARY KEY  (EXM_ID),
234 234
 				KEY EXM_type (EXM_type,OBJ_ID,EXM_key)";
235
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
236
-        $table_name = 'esp_extra_join';
237
-        $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
235
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
236
+		$table_name = 'esp_extra_join';
237
+		$sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
238 238
 				EXJ_first_model_id varchar(6) NOT NULL,
239 239
 				EXJ_first_model_name varchar(20) NOT NULL,
240 240
 				EXJ_second_model_id varchar(6) NOT NULL,
@@ -242,9 +242,9 @@  discard block
 block discarded – undo
242 242
 				PRIMARY KEY  (EXJ_ID),
243 243
 				KEY first_model (EXJ_first_model_name,EXJ_first_model_id),
244 244
 				KEY second_model (EXJ_second_model_name,EXJ_second_model_id)";
245
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
246
-        $table_name = 'esp_line_item';
247
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
245
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
246
+		$table_name = 'esp_line_item';
247
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
248 248
 				LIN_code varchar(245) NOT NULL DEFAULT '',
249 249
 				TXN_ID int(11) DEFAULT NULL,
250 250
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -263,9 +263,9 @@  discard block
 block discarded – undo
263 263
 				PRIMARY KEY  (LIN_ID),
264 264
 				KEY LIN_code (LIN_code(191)),
265 265
 				KEY TXN_ID (TXN_ID)";
266
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
267
-        $table_name = 'esp_log';
268
-        $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
266
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
267
+		$table_name = 'esp_log';
268
+		$sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
269 269
 				LOG_time datetime DEFAULT NULL,
270 270
 				OBJ_ID varchar(45) DEFAULT NULL,
271 271
 				OBJ_type varchar(45) DEFAULT NULL,
@@ -276,12 +276,12 @@  discard block
 block discarded – undo
276 276
 				KEY LOG_time (LOG_time),
277 277
 				KEY OBJ (OBJ_type,OBJ_ID),
278 278
 				KEY LOG_type (LOG_type)";
279
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
280
-        $table_name = 'esp_message';
281
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to');
282
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from');
283
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject');
284
-        $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
279
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
280
+		$table_name = 'esp_message';
281
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to');
282
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from');
283
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject');
284
+		$sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
285 285
 				GRP_ID int(10) unsigned NULL,
286 286
 				MSG_token varchar(255) NULL,
287 287
 				TXN_ID int(10) unsigned NULL,
@@ -313,18 +313,18 @@  discard block
 block discarded – undo
313 313
 				KEY STS_ID (STS_ID),
314 314
 				KEY MSG_created (MSG_created),
315 315
 				KEY MSG_modified (MSG_modified)";
316
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
317
-        $table_name = 'esp_message_template';
318
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
316
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
317
+		$table_name = 'esp_message_template';
318
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
319 319
 				GRP_ID int(10) unsigned NOT NULL,
320 320
 				MTP_context varchar(50) NOT NULL,
321 321
 				MTP_template_field varchar(30) NOT NULL,
322 322
 				MTP_content text NOT NULL,
323 323
 				PRIMARY KEY  (MTP_ID),
324 324
 				KEY GRP_ID (GRP_ID)";
325
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
326
-        $table_name = 'esp_message_template_group';
327
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
325
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
326
+		$table_name = 'esp_message_template_group';
327
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
328 328
 				MTP_user_id int(10) NOT NULL DEFAULT '1',
329 329
 				MTP_name varchar(245) NOT NULL DEFAULT '',
330 330
 				MTP_description varchar(245) NOT NULL DEFAULT '',
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
 				MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
337 337
 				PRIMARY KEY  (GRP_ID),
338 338
 				KEY MTP_user_id (MTP_user_id)";
339
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
340
-        $table_name = 'esp_payment';
341
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
339
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
340
+		$table_name = 'esp_payment';
341
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
342 342
 				TXN_ID int(10) unsigned DEFAULT NULL,
343 343
 				STS_ID varchar(3) DEFAULT NULL,
344 344
 				PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -355,9 +355,9 @@  discard block
 block discarded – undo
355 355
 				PRIMARY KEY  (PAY_ID),
356 356
 				KEY PAY_timestamp (PAY_timestamp),
357 357
 				KEY TXN_ID (TXN_ID)";
358
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
359
-        $table_name = 'esp_payment_method';
360
-        $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
358
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
359
+		$table_name = 'esp_payment_method';
360
+		$sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
361 361
 				PMD_type varchar(124) DEFAULT NULL,
362 362
 				PMD_name varchar(255) DEFAULT NULL,
363 363
 				PMD_desc text,
@@ -373,24 +373,24 @@  discard block
 block discarded – undo
373 373
 				PRIMARY KEY  (PMD_ID),
374 374
 				UNIQUE KEY PMD_slug_UNIQUE (PMD_slug),
375 375
 				KEY PMD_type (PMD_type)";
376
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
377
-        $table_name = "esp_ticket_price";
378
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
376
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
377
+		$table_name = "esp_ticket_price";
378
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
379 379
 				TKT_ID int(10) unsigned NOT NULL,
380 380
 				PRC_ID int(10) unsigned NOT NULL,
381 381
 				PRIMARY KEY  (TKP_ID),
382 382
 				KEY TKT_ID (TKT_ID),
383 383
 				KEY PRC_ID (PRC_ID)";
384
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
385
-        $table_name = "esp_ticket_template";
386
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
384
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
385
+		$table_name = "esp_ticket_template";
386
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
387 387
 				TTM_name varchar(45) NOT NULL,
388 388
 				TTM_description text,
389 389
 				TTM_file varchar(45),
390 390
 				PRIMARY KEY  (TTM_ID)";
391
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
392
-        $table_name = 'esp_question';
393
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
391
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
392
+		$table_name = 'esp_question';
393
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
394 394
 				QST_display_text text NOT NULL,
395 395
 				QST_admin_label varchar(255) NOT NULL,
396 396
 				QST_system varchar(25) DEFAULT NULL,
@@ -404,18 +404,18 @@  discard block
 block discarded – undo
404 404
 				QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0,
405 405
 				PRIMARY KEY  (QST_ID),
406 406
 				KEY QST_order (QST_order)';
407
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
408
-        $table_name = 'esp_question_group_question';
409
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
407
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
408
+		$table_name = 'esp_question_group_question';
409
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
410 410
 				QSG_ID int(10) unsigned NOT NULL,
411 411
 				QST_ID int(10) unsigned NOT NULL,
412 412
 				QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
413 413
 				PRIMARY KEY  (QGQ_ID),
414 414
 				KEY QST_ID (QST_ID),
415 415
 				KEY QSG_ID_order (QSG_ID,QGQ_order)";
416
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
417
-        $table_name = 'esp_question_option';
418
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
416
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
417
+		$table_name = 'esp_question_option';
418
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
419 419
 				QSO_value varchar(255) NOT NULL,
420 420
 				QSO_desc text NOT NULL,
421 421
 				QST_ID int(10) unsigned NOT NULL,
@@ -425,9 +425,9 @@  discard block
 block discarded – undo
425 425
 				PRIMARY KEY  (QSO_ID),
426 426
 				KEY QST_ID (QST_ID),
427 427
 				KEY QSO_order (QSO_order)";
428
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
429
-        $table_name = 'esp_registration';
430
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
428
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
429
+		$table_name = 'esp_registration';
430
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
431 431
 				EVT_ID bigint(20) unsigned NOT NULL,
432 432
 				ATT_ID bigint(20) unsigned NOT NULL,
433 433
 				TXN_ID int(10) unsigned NOT NULL,
@@ -451,18 +451,18 @@  discard block
 block discarded – undo
451 451
 				KEY TKT_ID (TKT_ID),
452 452
 				KEY EVT_ID (EVT_ID),
453 453
 				KEY STS_ID (STS_ID)";
454
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
455
-        $table_name = 'esp_registration_payment';
456
-        $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
454
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
455
+		$table_name = 'esp_registration_payment';
456
+		$sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
457 457
 					  REG_ID int(10) unsigned NOT NULL,
458 458
 					  PAY_ID int(10) unsigned NULL,
459 459
 					  RPY_amount decimal(10,3) NOT NULL DEFAULT '0.00',
460 460
 					  PRIMARY KEY  (RPY_ID),
461 461
 					  KEY REG_ID (REG_ID),
462 462
 					  KEY PAY_ID (PAY_ID)";
463
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
464
-        $table_name = 'esp_state';
465
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
463
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
464
+		$table_name = 'esp_state';
465
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
466 466
 				CNT_ISO varchar(2) NOT NULL,
467 467
 				STA_abbrev varchar(24) NOT NULL,
468 468
 				STA_name varchar(100) NOT NULL,
@@ -470,9 +470,9 @@  discard block
 block discarded – undo
470 470
 				PRIMARY KEY  (STA_ID),
471 471
 				KEY STA_abbrev (STA_abbrev),
472 472
 				KEY CNT_ISO (CNT_ISO)";
473
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
474
-        $table_name = 'esp_status';
475
-        $sql = "STS_ID varchar(3) NOT NULL,
473
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
474
+		$table_name = 'esp_status';
475
+		$sql = "STS_ID varchar(3) NOT NULL,
476 476
 				STS_code varchar(45) NOT NULL,
477 477
 				STS_type varchar(45) NOT NULL,
478 478
 				STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -480,9 +480,9 @@  discard block
 block discarded – undo
480 480
 				STS_open tinyint(1) NOT NULL DEFAULT 1,
481 481
 				UNIQUE KEY STS_ID_UNIQUE (STS_ID),
482 482
 				KEY STS_type (STS_type)";
483
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
484
-        $table_name = 'esp_transaction';
485
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
483
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
484
+		$table_name = 'esp_transaction';
485
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
486 486
 				TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
487 487
 				TXN_total decimal(10,3) DEFAULT '0.00',
488 488
 				TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00',
@@ -494,9 +494,9 @@  discard block
 block discarded – undo
494 494
 				PRIMARY KEY  (TXN_ID),
495 495
 				KEY TXN_timestamp (TXN_timestamp),
496 496
 				KEY STS_ID (STS_ID)";
497
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
498
-        $table_name = 'esp_venue_meta';
499
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
497
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
498
+		$table_name = 'esp_venue_meta';
499
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
500 500
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
501 501
 			VNU_address varchar(255) DEFAULT NULL,
502 502
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -515,10 +515,10 @@  discard block
 block discarded – undo
515 515
 			KEY VNU_ID (VNU_ID),
516 516
 			KEY STA_ID (STA_ID),
517 517
 			KEY CNT_ISO (CNT_ISO)";
518
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
519
-        //modified tables
520
-        $table_name = "esp_price";
521
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
518
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
519
+		//modified tables
520
+		$table_name = "esp_price";
521
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
522 522
 				PRT_ID tinyint(3) unsigned NOT NULL,
523 523
 				PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00',
524 524
 				PRC_name varchar(245) NOT NULL,
@@ -531,9 +531,9 @@  discard block
 block discarded – undo
531 531
 				PRC_parent int(10) unsigned DEFAULT 0,
532 532
 				PRIMARY KEY  (PRC_ID),
533 533
 				KEY PRT_ID (PRT_ID)";
534
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
535
-        $table_name = "esp_price_type";
536
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
534
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
535
+		$table_name = "esp_price_type";
536
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
537 537
 				PRT_name varchar(45) NOT NULL,
538 538
 				PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
539 539
 				PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -542,9 +542,9 @@  discard block
 block discarded – undo
542 542
 				PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
543 543
 				UNIQUE KEY PRT_name_UNIQUE (PRT_name),
544 544
 				PRIMARY KEY  (PRT_ID)";
545
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
546
-        $table_name = "esp_ticket";
547
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
545
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
546
+		$table_name = "esp_ticket";
547
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
548 548
 				TTM_ID int(10) unsigned NOT NULL,
549 549
 				TKT_name varchar(245) NOT NULL DEFAULT '',
550 550
 				TKT_description text NOT NULL,
@@ -567,9 +567,9 @@  discard block
 block discarded – undo
567 567
 				TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
568 568
 				PRIMARY KEY  (TKT_ID),
569 569
 				KEY TKT_start_date (TKT_start_date)";
570
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
571
-        $table_name = 'esp_question_group';
572
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
570
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
571
+		$table_name = 'esp_question_group';
572
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
573 573
 				QSG_name varchar(255) NOT NULL,
574 574
 				QSG_identifier varchar(100) NOT NULL,
575 575
 				QSG_desc text NULL,
@@ -582,138 +582,138 @@  discard block
 block discarded – undo
582 582
 				PRIMARY KEY  (QSG_ID),
583 583
 				UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier),
584 584
 				KEY QSG_order (QSG_order)';
585
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
586
-        /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
587
-        $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
588
-        //(because many need to convert old string states to foreign keys into the states table)
589
-        $script_4_1_defaults->insert_default_states();
590
-        $script_4_1_defaults->insert_default_countries();
591
-        /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
592
-        $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
593
-        $script_4_5_defaults->insert_default_price_types();
594
-        $script_4_5_defaults->insert_default_prices();
595
-        $script_4_5_defaults->insert_default_tickets();
596
-        /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
597
-        $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
598
-        $script_4_6_defaults->add_default_admin_only_payments();
599
-        $script_4_6_defaults->insert_default_currencies();
600
-        /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */
601
-        $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0');
602
-        $script_4_8_defaults->verify_new_countries();
603
-        $script_4_8_defaults->verify_new_currencies();
604
-        $this->verify_db_collations();
605
-        $this->verify_db_collations_again();
606
-        return true;
607
-    }
585
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
586
+		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
587
+		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
588
+		//(because many need to convert old string states to foreign keys into the states table)
589
+		$script_4_1_defaults->insert_default_states();
590
+		$script_4_1_defaults->insert_default_countries();
591
+		/** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
592
+		$script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
593
+		$script_4_5_defaults->insert_default_price_types();
594
+		$script_4_5_defaults->insert_default_prices();
595
+		$script_4_5_defaults->insert_default_tickets();
596
+		/** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
597
+		$script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
598
+		$script_4_6_defaults->add_default_admin_only_payments();
599
+		$script_4_6_defaults->insert_default_currencies();
600
+		/** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */
601
+		$script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0');
602
+		$script_4_8_defaults->verify_new_countries();
603
+		$script_4_8_defaults->verify_new_currencies();
604
+		$this->verify_db_collations();
605
+		$this->verify_db_collations_again();
606
+		return true;
607
+	}
608 608
 
609 609
 
610 610
 
611
-    /**
612
-     * @return boolean
613
-     */
614
-    public function schema_changes_after_migration()
615
-    {
616
-        return true;
617
-    }
611
+	/**
612
+	 * @return boolean
613
+	 */
614
+	public function schema_changes_after_migration()
615
+	{
616
+		return true;
617
+	}
618 618
 
619 619
 
620 620
 
621
-    public function migration_page_hooks()
622
-    {
623
-    }
621
+	public function migration_page_hooks()
622
+	{
623
+	}
624 624
 
625 625
 
626 626
 
627
-    /**
628
-     * Verify all EE4 models' tables use utf8mb4 collation
629
-     *
630
-     * @return void
631
-     */
632
-    public function verify_db_collations()
633
-    {
634
-        if (get_option('ee_verified_db_collations', false)) {
635
-            return;
636
-        }
637
-        // grab tables from each model
638
-        $tables_to_check = array();
639
-        foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
640
-            if (method_exists($model_name, 'instance')) {
641
-                $model_obj = call_user_func(array($model_name, 'instance'));
642
-                if ($model_obj instanceof EEM_Base) {
643
-                    foreach ($model_obj->get_tables() as $table) {
644
-                        if (
645
-                            strpos($table->get_table_name(), 'esp_')
646
-                            && (is_main_site()//for main tables, verify global tables
647
-                                || ! $table->is_global()//if not the main site, then only verify non-global tables (avoid doubling up)
648
-                            )
649
-                            && function_exists('maybe_convert_table_to_utf8mb4')
650
-                        ) {
651
-                            $tables_to_check[] = $table->get_table_name();
652
-                        }
653
-                    }
654
-                }
655
-            }
656
-        }
657
-        //and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active
658
-        //when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead
659
-        //of hard-coding this
660
-        $addon_tables = array(
661
-            //mailchimp
662
-            'esp_event_mailchimp_list_group',
663
-            'esp_event_question_mailchimp_field',
664
-            //multisite
665
-            'esp_blog_meta',
666
-            //people
667
-            'esp_people_to_post',
668
-            //promotions
669
-            'esp_promotion',
670
-            'esp_promotion_object',
671
-        );
672
-        foreach ($addon_tables as $table_name) {
673
-            if($this->_table_analysis->tableExists( $table_name )){
674
-                $tables_to_check[] = $table_name;
675
-            }
676
-        }
677
-        $this->_verify_db_collations_for_tables(array_unique($tables_to_check));
678
-        //ok and now let's remember this was done (without needing to check the db schemas all over again)
679
-        add_option('ee_verified_db_collations', true, null, 'no');
680
-        //seeing how this ran with the fix from 10435, no need to check again
681
-        add_option('ee_verified_db_collations_again',true,null,'no');
682
-    }
627
+	/**
628
+	 * Verify all EE4 models' tables use utf8mb4 collation
629
+	 *
630
+	 * @return void
631
+	 */
632
+	public function verify_db_collations()
633
+	{
634
+		if (get_option('ee_verified_db_collations', false)) {
635
+			return;
636
+		}
637
+		// grab tables from each model
638
+		$tables_to_check = array();
639
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
640
+			if (method_exists($model_name, 'instance')) {
641
+				$model_obj = call_user_func(array($model_name, 'instance'));
642
+				if ($model_obj instanceof EEM_Base) {
643
+					foreach ($model_obj->get_tables() as $table) {
644
+						if (
645
+							strpos($table->get_table_name(), 'esp_')
646
+							&& (is_main_site()//for main tables, verify global tables
647
+								|| ! $table->is_global()//if not the main site, then only verify non-global tables (avoid doubling up)
648
+							)
649
+							&& function_exists('maybe_convert_table_to_utf8mb4')
650
+						) {
651
+							$tables_to_check[] = $table->get_table_name();
652
+						}
653
+					}
654
+				}
655
+			}
656
+		}
657
+		//and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active
658
+		//when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead
659
+		//of hard-coding this
660
+		$addon_tables = array(
661
+			//mailchimp
662
+			'esp_event_mailchimp_list_group',
663
+			'esp_event_question_mailchimp_field',
664
+			//multisite
665
+			'esp_blog_meta',
666
+			//people
667
+			'esp_people_to_post',
668
+			//promotions
669
+			'esp_promotion',
670
+			'esp_promotion_object',
671
+		);
672
+		foreach ($addon_tables as $table_name) {
673
+			if($this->_table_analysis->tableExists( $table_name )){
674
+				$tables_to_check[] = $table_name;
675
+			}
676
+		}
677
+		$this->_verify_db_collations_for_tables(array_unique($tables_to_check));
678
+		//ok and now let's remember this was done (without needing to check the db schemas all over again)
679
+		add_option('ee_verified_db_collations', true, null, 'no');
680
+		//seeing how this ran with the fix from 10435, no need to check again
681
+		add_option('ee_verified_db_collations_again',true,null,'no');
682
+	}
683 683
 
684 684
 
685 685
 
686
-    /**
687
-     * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435
688
-     * which meant some DB collations might not have been updated
689
-     * @return void
690
-     */
691
-    public function verify_db_collations_again(){
692
-        if (get_option('ee_verified_db_collations_again', false)) {
693
-            return;
694
-        }
695
-        $tables_to_check = array(
696
-            'esp_attendee_meta',
697
-            'esp_message'
698
-        );
699
-        $this->_verify_db_collations_for_tables(array_unique($tables_to_check));
700
-        add_option('ee_verified_db_collations_again',true,null,'no');
701
-    }
686
+	/**
687
+	 * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435
688
+	 * which meant some DB collations might not have been updated
689
+	 * @return void
690
+	 */
691
+	public function verify_db_collations_again(){
692
+		if (get_option('ee_verified_db_collations_again', false)) {
693
+			return;
694
+		}
695
+		$tables_to_check = array(
696
+			'esp_attendee_meta',
697
+			'esp_message'
698
+		);
699
+		$this->_verify_db_collations_for_tables(array_unique($tables_to_check));
700
+		add_option('ee_verified_db_collations_again',true,null,'no');
701
+	}
702 702
 
703 703
 
704 704
 
705
-    /**
706
-     * Runs maybe_convert_table_to_utf8mb4 on the specified tables
707
-     * @param $tables_to_check
708
-     * @return boolean true if logic ran, false if it didn't
709
-     */
710
-    protected function _verify_db_collations_for_tables($tables_to_check)
711
-    {
712
-        foreach ($tables_to_check as $table_name) {
713
-            $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name);
714
-            if ( ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name ) ) {
715
-                maybe_convert_table_to_utf8mb4($table_name);
716
-            }
717
-        }
718
-    }
705
+	/**
706
+	 * Runs maybe_convert_table_to_utf8mb4 on the specified tables
707
+	 * @param $tables_to_check
708
+	 * @return boolean true if logic ran, false if it didn't
709
+	 */
710
+	protected function _verify_db_collations_for_tables($tables_to_check)
711
+	{
712
+		foreach ($tables_to_check as $table_name) {
713
+			$table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name);
714
+			if ( ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name ) ) {
715
+				maybe_convert_table_to_utf8mb4($table_name);
716
+			}
717
+		}
718
+	}
719 719
 }
720 720
\ No newline at end of file
Please login to merge, or discard this patch.
core/services/database/TableAnalysis.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -105,29 +105,29 @@
 block discarded – undo
105 105
 
106 106
 
107 107
 
108
-    /**
109
-     * @param $table_name
110
-     * @param $index_name
111
-     * @return array of columns used on that index, Each entry is an object with the following properties {
112
-     *  @type string Table
113
-     *  @type string Non_unique "0" or "1"
114
-     *  @type string Key_name
115
-     *  @type string Seq_in_index
116
-     *  @type string Column_name
117
-     *  @type string Collation
118
-     *  @type string Cardinality
119
-     *  @type string Sub_part on a column, usually this is just the number of characters from this column to use in indexing
120
-     *  @type string|null Packed
121
-     *  @type string Null
122
-     *  @type string Index_type
123
-     *  @type string Comment
124
-     *  @type string Index_comment
125
-     * }
126
-     */
108
+	/**
109
+	 * @param $table_name
110
+	 * @param $index_name
111
+	 * @return array of columns used on that index, Each entry is an object with the following properties {
112
+	 *  @type string Table
113
+	 *  @type string Non_unique "0" or "1"
114
+	 *  @type string Key_name
115
+	 *  @type string Seq_in_index
116
+	 *  @type string Column_name
117
+	 *  @type string Collation
118
+	 *  @type string Cardinality
119
+	 *  @type string Sub_part on a column, usually this is just the number of characters from this column to use in indexing
120
+	 *  @type string|null Packed
121
+	 *  @type string Null
122
+	 *  @type string Index_type
123
+	 *  @type string Comment
124
+	 *  @type string Index_comment
125
+	 * }
126
+	 */
127 127
 	public function showIndexes($table_name, $index_name){
128
-	    global $wpdb;
129
-        $table_name = $this->ensureTableNameHasPrefix($table_name);
130
-        $index_exists_query = "SHOW INDEX FROM {$table_name} WHERE Key_name = '{$index_name}'";
131
-        return $wpdb->get_results($index_exists_query);
132
-    }
128
+		global $wpdb;
129
+		$table_name = $this->ensureTableNameHasPrefix($table_name);
130
+		$index_exists_query = "SHOW INDEX FROM {$table_name} WHERE Key_name = '{$index_name}'";
131
+		return $wpdb->get_results($index_exists_query);
132
+	}
133 133
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
 	 * @param string $table_name
25 25
 	 * @return string $tableName, having ensured it has the wpdb prefix on the front
26 26
 	 */
27
-	public function ensureTableNameHasPrefix( $table_name )
27
+	public function ensureTableNameHasPrefix($table_name)
28 28
 	{
29 29
 		global $wpdb;
30
-		return strpos( $table_name, $wpdb->base_prefix ) === 0 ? $table_name : $wpdb->prefix . $table_name;
30
+		return strpos($table_name, $wpdb->base_prefix) === 0 ? $table_name : $wpdb->prefix.$table_name;
31 31
 	}
32 32
 
33 33
 
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 	 * @param string $table_name
40 40
 	 * @return bool
41 41
 	 */
42
-	public function tableIsEmpty( $table_name )
42
+	public function tableIsEmpty($table_name)
43 43
 	{
44 44
 		global $wpdb;
45
-		$table_name = $this->ensureTableNameHasPrefix( $table_name );
46
-		if ( $this->tableExists( $table_name ) ) {
47
-			$count = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" );
48
-			return absint( $count ) === 0 ? true : false;
45
+		$table_name = $this->ensureTableNameHasPrefix($table_name);
46
+		if ($this->tableExists($table_name)) {
47
+			$count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name");
48
+			return absint($count) === 0 ? true : false;
49 49
 		}
50 50
 		return false;
51 51
 	}
@@ -60,24 +60,24 @@  discard block
 block discarded – undo
60 60
 	 * @param $table_name
61 61
 	 * @return bool
62 62
 	 */
63
-	public function tableExists( $table_name )
63
+	public function tableExists($table_name)
64 64
 	{
65 65
 		global $wpdb, $EZSQL_ERROR;
66
-		$table_name = $this->ensureTableNameHasPrefix( $table_name );
66
+		$table_name = $this->ensureTableNameHasPrefix($table_name);
67 67
 		//ignore if this causes an sql error
68 68
 		$old_error = $wpdb->last_error;
69 69
 		$old_suppress_errors = $wpdb->suppress_errors();
70
-		$old_show_errors_value = $wpdb->show_errors( FALSE );
70
+		$old_show_errors_value = $wpdb->show_errors(FALSE);
71 71
 		$ezsql_error_cache = $EZSQL_ERROR;
72
-		$wpdb->get_results( "SELECT * from $table_name LIMIT 1");
73
-		$wpdb->show_errors( $old_show_errors_value );
74
-		$wpdb->suppress_errors( $old_suppress_errors );
72
+		$wpdb->get_results("SELECT * from $table_name LIMIT 1");
73
+		$wpdb->show_errors($old_show_errors_value);
74
+		$wpdb->suppress_errors($old_suppress_errors);
75 75
 		$new_error = $wpdb->last_error;
76 76
 		$wpdb->last_error = $old_error;
77 77
 		$EZSQL_ERROR = $ezsql_error_cache;
78 78
 		//if there was a table doesn't exist error
79
-		if( ! empty( $new_error ) ) {
80
-			if(
79
+		if ( ! empty($new_error)) {
80
+			if (
81 81
 				in_array(
82 82
 					\EEH_Activation::last_wpdb_error_code(),
83 83
 					array(
@@ -87,14 +87,14 @@  discard block
 block discarded – undo
87 87
 					)
88 88
 				)
89 89
 				||
90
-				preg_match( '~^Table .* doesn\'t exist~', $new_error ) //in case not using mysql and error codes aren't reliable, just check for this error string
90
+				preg_match('~^Table .* doesn\'t exist~', $new_error) //in case not using mysql and error codes aren't reliable, just check for this error string
91 91
 			) {
92 92
 				return false;
93 93
 			} else {
94 94
 				//log this because that's weird. Just use the normal PHP error log
95 95
 				error_log(
96 96
 					sprintf(
97
-						__( 'Event Espresso error detected when checking if table existed: %1$s (it wasn\'t just that the table didn\'t exist either)', 'event_espresso' ),
97
+						__('Event Espresso error detected when checking if table existed: %1$s (it wasn\'t just that the table didn\'t exist either)', 'event_espresso'),
98 98
 					$new_error
99 99
 					)
100 100
 				);
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      *  @type string Index_comment
125 125
      * }
126 126
      */
127
-	public function showIndexes($table_name, $index_name){
127
+	public function showIndexes($table_name, $index_name) {
128 128
 	    global $wpdb;
129 129
         $table_name = $this->ensureTableNameHasPrefix($table_name);
130 130
         $index_exists_query = "SHOW INDEX FROM {$table_name} WHERE Key_name = '{$index_name}'";
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -390,43 +390,43 @@
 block discarded – undo
390 390
 			),
391 391
 			'EE_Data_Migration_Class_Base' => array(
392 392
 				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
393
-                'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
393
+				'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
394 394
 			),
395 395
 			'EE_DMS_Core_4_1_0' => array(
396 396
 				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
397
-                'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
397
+				'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
398 398
 			),
399 399
 			'EE_DMS_Core_4_2_0' => array(
400 400
 				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
401
-                'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
401
+				'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
402 402
 			),
403 403
 			'EE_DMS_Core_4_3_0' => array(
404 404
 				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
405
-                'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
405
+				'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
406 406
 			),
407 407
 			'EE_DMS_Core_4_4_0' => array(
408 408
 				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
409
-                'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
409
+				'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
410 410
 			),
411 411
 			'EE_DMS_Core_4_5_0' => array(
412 412
 				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
413
-                'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
413
+				'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
414 414
 			),
415 415
 			'EE_DMS_Core_4_6_0' => array(
416 416
 				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
417
-                'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
417
+				'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
418 418
 			),
419 419
 			'EE_DMS_Core_4_7_0' => array(
420 420
 				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
421
-                'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
421
+				'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
422 422
 			),
423 423
 			'EE_DMS_Core_4_8_0' => array(
424 424
 				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
425
-                'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
425
+				'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
426 426
 			),
427 427
 			'EE_DMS_Core_4_9_0' => array(
428 428
 				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
429
-                'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
429
+				'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
430 430
 			),
431 431
 		);
432 432
 	}
Please login to merge, or discard this patch.
core/services/assets/Registry.php 2 patches
Indentation   +214 added lines, -214 removed lines patch added patch discarded remove patch
@@ -16,222 +16,222 @@
 block discarded – undo
16 16
 class Registry
17 17
 {
18 18
 
19
-    /**
20
-     * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
21
-     * @var array
22
-     */
23
-    protected $jsdata = array();
24
-
25
-
26
-    /**
27
-     * Registry constructor.
28
-     * Hooking into WP actions for script registry.
29
-     */
30
-    public function __construct()
31
-    {
32
-        add_action('wp_enqueue_scripts', array($this, 'scripts'), 100);
33
-        add_action('admin_enqueue_scripts', array($this, 'scripts'), 100);
34
-    }
35
-
36
-
37
-    /**
38
-     * Callback for the WP script actions.
39
-     * Used to register globally accessible core scripts.
40
-     * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency.
41
-     */
42
-    public function scripts()
43
-    {
44
-        global $wp_version;
45
-        wp_register_script(
46
-            'eejs-core',
47
-            EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js',
48
-            array(),
49
-            espresso_version(),
50
-            true
51
-        );
52
-        //only run this if WordPress 4.4.0 > is in use.
53
-        if (version_compare($wp_version, '4.4.0', '>')) {
54
-            //js.api
55
-            wp_register_script(
56
-                'eejs-api',
57
-                EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
58
-                array('underscore', 'eejs-core'),
59
-                espresso_version(),
60
-                true
61
-            );
62
-            $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/'));
63
-
64
-            wp_localize_script('eejs-core', 'eejs', array('data' => $this->jsdata));
65
-        }
66
-    }
67
-
68
-
69
-    /**
70
-     * Used to add data to eejs.data object.
71
-     *
72
-     * Note:  Overriding existing data is not allowed.
73
-     *
74
-     * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
75
-     * If the data you add is something like this:
76
-     *
77
-     *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
78
-     *
79
-     * It will be exposed in the page source as:
80
-     *
81
-     *  eejs.data.my_plugin_data.foo == gar
82
-     *
83
-     * @param string       $key   Key used to access your data
84
-     * @param string|array $value Value to attach to key
85
-     * @throws InvalidArgumentException
86
-     */
87
-    public function addData($key, $value)
88
-    {
89
-        if ($this->verifyDataNotExisting($key)) {
90
-            $this->jsdata[$key] = $value;
91
-        }
92
-    }
93
-
94
-
95
-    /**
96
-     * Similar to addData except this allows for users to push values to an existing key where the values on key are
97
-     * elements in an array.
98
-     *
99
-     * When you use this method, the value you include will be appended to the end of an array on $key.
100
-     *
101
-     * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript object
102
-     * like this,
103
-     *
104
-     * eejs.data.test = [
105
-     *     my_data,
106
-     * ]
107
-     *
108
-     * If there has already been a scalar value attached to the data object given key, then
109
-     * this will throw an exception.
110
-     *
111
-     * @param string $key          Key to attach data to.
112
-     * @param string|array $value  Value being registered.
113
-     * @throws InvalidArgumentException
114
-     */
115
-    public function pushData($key, $value)
116
-    {
117
-        if (isset($this->jsdata[$key])
118
-            && ! is_array($this->jsdata[$key])
119
-        ) {
120
-            throw new invalidArgumentException(
121
-                sprintf(
122
-                    __(
123
-                        'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
19
+	/**
20
+	 * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
21
+	 * @var array
22
+	 */
23
+	protected $jsdata = array();
24
+
25
+
26
+	/**
27
+	 * Registry constructor.
28
+	 * Hooking into WP actions for script registry.
29
+	 */
30
+	public function __construct()
31
+	{
32
+		add_action('wp_enqueue_scripts', array($this, 'scripts'), 100);
33
+		add_action('admin_enqueue_scripts', array($this, 'scripts'), 100);
34
+	}
35
+
36
+
37
+	/**
38
+	 * Callback for the WP script actions.
39
+	 * Used to register globally accessible core scripts.
40
+	 * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency.
41
+	 */
42
+	public function scripts()
43
+	{
44
+		global $wp_version;
45
+		wp_register_script(
46
+			'eejs-core',
47
+			EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js',
48
+			array(),
49
+			espresso_version(),
50
+			true
51
+		);
52
+		//only run this if WordPress 4.4.0 > is in use.
53
+		if (version_compare($wp_version, '4.4.0', '>')) {
54
+			//js.api
55
+			wp_register_script(
56
+				'eejs-api',
57
+				EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
58
+				array('underscore', 'eejs-core'),
59
+				espresso_version(),
60
+				true
61
+			);
62
+			$this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/'));
63
+
64
+			wp_localize_script('eejs-core', 'eejs', array('data' => $this->jsdata));
65
+		}
66
+	}
67
+
68
+
69
+	/**
70
+	 * Used to add data to eejs.data object.
71
+	 *
72
+	 * Note:  Overriding existing data is not allowed.
73
+	 *
74
+	 * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
75
+	 * If the data you add is something like this:
76
+	 *
77
+	 *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
78
+	 *
79
+	 * It will be exposed in the page source as:
80
+	 *
81
+	 *  eejs.data.my_plugin_data.foo == gar
82
+	 *
83
+	 * @param string       $key   Key used to access your data
84
+	 * @param string|array $value Value to attach to key
85
+	 * @throws InvalidArgumentException
86
+	 */
87
+	public function addData($key, $value)
88
+	{
89
+		if ($this->verifyDataNotExisting($key)) {
90
+			$this->jsdata[$key] = $value;
91
+		}
92
+	}
93
+
94
+
95
+	/**
96
+	 * Similar to addData except this allows for users to push values to an existing key where the values on key are
97
+	 * elements in an array.
98
+	 *
99
+	 * When you use this method, the value you include will be appended to the end of an array on $key.
100
+	 *
101
+	 * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript object
102
+	 * like this,
103
+	 *
104
+	 * eejs.data.test = [
105
+	 *     my_data,
106
+	 * ]
107
+	 *
108
+	 * If there has already been a scalar value attached to the data object given key, then
109
+	 * this will throw an exception.
110
+	 *
111
+	 * @param string $key          Key to attach data to.
112
+	 * @param string|array $value  Value being registered.
113
+	 * @throws InvalidArgumentException
114
+	 */
115
+	public function pushData($key, $value)
116
+	{
117
+		if (isset($this->jsdata[$key])
118
+			&& ! is_array($this->jsdata[$key])
119
+		) {
120
+			throw new invalidArgumentException(
121
+				sprintf(
122
+					__(
123
+						'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
124 124
                          push values to this data element when it is an array.',
125
-                        'event_espresso'
126
-                    ),
127
-                    $key,
128
-                    __METHOD__
129
-                )
130
-            );
131
-        }
132
-
133
-        $this->jsdata[$key][] = $value;
134
-    }
135
-
136
-
137
-    /**
138
-     * Used to set content used by javascript for a template.
139
-     * Note: Overrides of existing registered templates are not allowed.
140
-     *
141
-     * @param string $template_reference
142
-     * @param string $template_content
143
-     * @throws InvalidArgumentException
144
-     */
145
-    public function addTemplate($template_reference, $template_content)
146
-    {
147
-        if (! isset($this->jsdata['templates'])) {
148
-            $this->jsdata['templates'] = array();
149
-        }
150
-
151
-        //no overrides allowed.
152
-        if (isset($this->jsdata['templates'][$template_reference])) {
153
-            throw new invalidArgumentException(
154
-                sprintf(
155
-                    __(
156
-                        'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
157
-                        'event_espresso'
158
-                    ),
159
-                    $template_reference
160
-                )
161
-            );
162
-        } else {
163
-            $this->jsdata['templates'][$template_reference] = $template_content;
164
-        }
165
-    }
166
-
167
-
168
-    /**
169
-     * Retrieve the template content already registered for the given reference.
170
-     * @param string $template_reference
171
-     * @return string
172
-     */
173
-    public function getTemplate($template_reference)
174
-    {
175
-        return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference])
176
-            ? $this->jsdata['templates'][$template_reference]
177
-            : '';
178
-    }
179
-
180
-
181
-    /**
182
-     * Retrieve registered data.
183
-     *
184
-     * @param string $key           Name of key to attach data to.
185
-     * @return mixed                If there is no for the given key, then false is returned.
186
-     */
187
-    public function getData($key)
188
-    {
189
-        return isset($this->jsdata[$key])
190
-            ? $this->jsdata[$key]
191
-            : false;
192
-    }
193
-
194
-
195
-
196
-
197
-    /**
198
-     * Verifies whether the given data exists already on the jsdata array.
199
-     *
200
-     * Overriding data is not allowed.
201
-     *
202
-     * @param string       $key          Index for data.
203
-     * @return bool        If valid then return true.
204
-     * @throws InvalidArgumentException if data already exists.
205
-     */
206
-    protected function verifyDataNotExisting($key)
207
-    {
208
-        if (isset($this->jsdata[$key])) {
209
-            if (is_array($this->jsdata[$key])) {
210
-                throw new InvalidArgumentException(
211
-                    sprintf(
212
-                        __(
213
-                            'The value for %1$s already exists in the Registry::eejs object.
125
+						'event_espresso'
126
+					),
127
+					$key,
128
+					__METHOD__
129
+				)
130
+			);
131
+		}
132
+
133
+		$this->jsdata[$key][] = $value;
134
+	}
135
+
136
+
137
+	/**
138
+	 * Used to set content used by javascript for a template.
139
+	 * Note: Overrides of existing registered templates are not allowed.
140
+	 *
141
+	 * @param string $template_reference
142
+	 * @param string $template_content
143
+	 * @throws InvalidArgumentException
144
+	 */
145
+	public function addTemplate($template_reference, $template_content)
146
+	{
147
+		if (! isset($this->jsdata['templates'])) {
148
+			$this->jsdata['templates'] = array();
149
+		}
150
+
151
+		//no overrides allowed.
152
+		if (isset($this->jsdata['templates'][$template_reference])) {
153
+			throw new invalidArgumentException(
154
+				sprintf(
155
+					__(
156
+						'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
157
+						'event_espresso'
158
+					),
159
+					$template_reference
160
+				)
161
+			);
162
+		} else {
163
+			$this->jsdata['templates'][$template_reference] = $template_content;
164
+		}
165
+	}
166
+
167
+
168
+	/**
169
+	 * Retrieve the template content already registered for the given reference.
170
+	 * @param string $template_reference
171
+	 * @return string
172
+	 */
173
+	public function getTemplate($template_reference)
174
+	{
175
+		return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference])
176
+			? $this->jsdata['templates'][$template_reference]
177
+			: '';
178
+	}
179
+
180
+
181
+	/**
182
+	 * Retrieve registered data.
183
+	 *
184
+	 * @param string $key           Name of key to attach data to.
185
+	 * @return mixed                If there is no for the given key, then false is returned.
186
+	 */
187
+	public function getData($key)
188
+	{
189
+		return isset($this->jsdata[$key])
190
+			? $this->jsdata[$key]
191
+			: false;
192
+	}
193
+
194
+
195
+
196
+
197
+	/**
198
+	 * Verifies whether the given data exists already on the jsdata array.
199
+	 *
200
+	 * Overriding data is not allowed.
201
+	 *
202
+	 * @param string       $key          Index for data.
203
+	 * @return bool        If valid then return true.
204
+	 * @throws InvalidArgumentException if data already exists.
205
+	 */
206
+	protected function verifyDataNotExisting($key)
207
+	{
208
+		if (isset($this->jsdata[$key])) {
209
+			if (is_array($this->jsdata[$key])) {
210
+				throw new InvalidArgumentException(
211
+					sprintf(
212
+						__(
213
+							'The value for %1$s already exists in the Registry::eejs object.
214 214
                             Overrides are not allowed. Since the value of this data is an array, you may want to use the
215 215
                             %2$s method to push your value to the array.',
216
-                            'event_espresso'
217
-                        ),
218
-                        $key,
219
-                        'pushData()'
220
-                    )
221
-                );
222
-            } else {
223
-                throw new InvalidArgumentException(
224
-                    sprintf(
225
-                        __(
226
-                            'The value for %1$s already exists in the Registry::eejs object. Overrides are not
216
+							'event_espresso'
217
+						),
218
+						$key,
219
+						'pushData()'
220
+					)
221
+				);
222
+			} else {
223
+				throw new InvalidArgumentException(
224
+					sprintf(
225
+						__(
226
+							'The value for %1$s already exists in the Registry::eejs object. Overrides are not
227 227
                             allowed.  Consider attaching your value to a different key',
228
-                            'event_espresso'
229
-                        ),
230
-                        $key
231
-                    )
232
-                );
233
-            }
234
-        }
235
-        return true;
236
-    }
228
+							'event_espresso'
229
+						),
230
+						$key
231
+					)
232
+				);
233
+			}
234
+		}
235
+		return true;
236
+	}
237 237
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
         global $wp_version;
45 45
         wp_register_script(
46 46
             'eejs-core',
47
-            EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js',
47
+            EE_PLUGIN_DIR_URL.'core/services/assets/core_assets/eejs-core.js',
48 48
             array(),
49 49
             espresso_version(),
50 50
             true
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
             //js.api
55 55
             wp_register_script(
56 56
                 'eejs-api',
57
-                EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
57
+                EE_LIBRARIES_URL.'rest_api/assets/js/eejs-api.min.js',
58 58
                 array('underscore', 'eejs-core'),
59 59
                 espresso_version(),
60 60
                 true
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      */
145 145
     public function addTemplate($template_reference, $template_content)
146 146
     {
147
-        if (! isset($this->jsdata['templates'])) {
147
+        if ( ! isset($this->jsdata['templates'])) {
148 148
             $this->jsdata['templates'] = array();
149 149
         }
150 150
 
Please login to merge, or discard this patch.
modules/ticket_selector/DisplayTicketSelector.php 2 patches
Indentation   +659 added lines, -659 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 namespace EventEspresso\modules\ticket_selector;
3 3
 
4 4
 if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-    exit( 'No direct script access allowed' );
5
+	exit( 'No direct script access allowed' );
6 6
 }
7 7
 
8 8
 
@@ -19,667 +19,667 @@  discard block
 block discarded – undo
19 19
 class DisplayTicketSelector
20 20
 {
21 21
 
22
-    /**
23
-     * event that ticket selector is being generated for
24
-     *
25
-     * @access protected
26
-     * @var \EE_Event $event
27
-     */
28
-    protected $event;
29
-
30
-    /**
31
-     * Used to flag when the ticket selector is being called from an external iframe.
32
-     *
33
-     * @var bool $iframe
34
-     */
35
-    protected $iframe = false;
36
-
37
-    /**
38
-     * max attendees that can register for event at one time
39
-     *
40
-     * @var int $max_attendees
41
-     */
42
-    private $max_attendees = EE_INF;
43
-
44
-    /**
45
-     *@var string $date_format
46
-     */
47
-    private $date_format = '';
48
-
49
-    /**
50
-     *@var string $time_format
51
-     */
52
-    private $time_format = '';
53
-
54
-
55
-
56
-    /**
57
-     * DisplayTicketSelector constructor.
58
-     */
59
-    public function __construct()
60
-    {
61
-        $this->date_format = apply_filters(
62
-            'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format',
63
-            get_option('date_format')
64
-        );
65
-        $this->time_format = apply_filters(
66
-            'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format',
67
-            get_option('time_format')
68
-        );
69
-    }
70
-
71
-
72
-
73
-    /**
74
-     * @param boolean $iframe
75
-     */
76
-    public function setIframe( $iframe = true )
77
-    {
78
-        $this->iframe = filter_var( $iframe, FILTER_VALIDATE_BOOLEAN );
79
-    }
80
-
81
-
82
-
83
-    /**
84
-     * finds and sets the \EE_Event object for use throughout class
85
-     *
86
-     * @param    mixed $event
87
-     * @return    bool
88
-     */
89
-    protected function setEvent( $event = null )
90
-    {
91
-        if ( $event === null ) {
92
-            global $post;
93
-            $event = $post;
94
-        }
95
-        if ( $event instanceof \EE_Event ) {
96
-            $this->event = $event;
97
-        } else if ( $event instanceof \WP_Post ) {
98
-            if ( isset( $event->EE_Event ) && $event->EE_Event instanceof \EE_Event ) {
99
-                $this->event = $event->EE_Event;
100
-            } else if ( $event->post_type === 'espresso_events' ) {
101
-                $event->EE_Event = \EEM_Event::instance()->instantiate_class_from_post_object( $event );
102
-                $this->event = $event->EE_Event;
103
-            }
104
-        } else {
105
-            $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' );
106
-            $dev_msg = $user_msg . __(
107
-                    'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.',
108
-                    'event_espresso'
109
-                );
110
-            \EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ );
111
-            return false;
112
-        }
113
-        return true;
114
-    }
115
-
116
-
117
-
118
-    /**
119
-     * @return int
120
-     */
121
-    public function getMaxAttendees()
122
-    {
123
-        return $this->max_attendees;
124
-    }
125
-
126
-
127
-
128
-    /**
129
-     * @param int $max_attendees
130
-     */
131
-    public function setMaxAttendees($max_attendees)
132
-    {
133
-        $this->max_attendees = absint(
134
-            apply_filters(
135
-                'FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets',
136
-                $max_attendees
137
-            )
138
-        );
139
-    }
140
-
141
-
142
-
143
-    /**
144
-     * creates buttons for selecting number of attendees for an event
145
-     *
146
-     * @param \WP_Post|int $event
147
-     * @param bool         $view_details
148
-     * @return string
149
-     * @throws \EE_Error
150
-     */
151
-    public function display( $event = null, $view_details = false )
152
-    {
153
-        // reset filter for displaying submit button
154
-        remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
155
-        // poke and prod incoming event till it tells us what it is
156
-        if ( ! $this->setEvent( $event ) ) {
157
-            return false;
158
-        }
159
-        // begin gathering template arguments by getting event status
160
-        $template_args = array( 'event_status' => $this->event->get_active_status() );
161
-        if ( $this->activeEventAndShowTicketSelector($event, $template_args['event_status'], $view_details) ) {
162
-            return ! is_single() ? $this->displayViewDetailsButton() : '';
163
-        }
164
-        // filter the maximum qty that can appear in the Ticket Selector qty dropdowns
165
-        $this->setMaxAttendees($this->event->additional_limit());
166
-        if ($this->getMaxAttendees() < 1) {
167
-            return $this->ticketSalesClosedMessage();
168
-        }
169
-        // is the event expired ?
170
-        $template_args['event_is_expired'] = $this->event->is_expired();
171
-        if ( $template_args[ 'event_is_expired' ] ) {
172
-            return $this->expiredEventMessage();
173
-        }
174
-        // get all tickets for this event ordered by the datetime
175
-        $tickets = $this->getTickets();
176
-        if (count($tickets) < 1) {
177
-            return $this->noTicketAvailableMessage();
178
-        }
179
-        // redirecting to another site for registration ??
180
-        $external_url = (string) $this->event->external_url();
181
-        // if redirecting to another site for registration, then we don't load the TS
182
-        $ticket_selector = $external_url
183
-            ? $this->externalEventRegistration()
184
-            : $this->loadTicketSelector($tickets,$template_args);
185
-        // now set up the form (but not for the admin)
186
-        $ticket_selector = ! is_admin()
187
-            ? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector
188
-            : $ticket_selector;
189
-        // submit button and form close tag
190
-        $ticket_selector .= ! is_admin() ? $this->displaySubmitButton($external_url) : '';
191
-        return $ticket_selector;
192
-    }
193
-
194
-
195
-
196
-    /**
197
-     * displayTicketSelector
198
-     * examines the event properties and determines whether a Ticket Selector should be displayed
199
-     *
200
-     * @param \WP_Post|int $event
201
-     * @param string       $_event_active_status
202
-     * @param bool         $view_details
203
-     * @return bool
204
-     * @throws \EE_Error
205
-     */
206
-    protected function activeEventAndShowTicketSelector($event, $_event_active_status, $view_details)
207
-    {
208
-        $event_post = $this->event instanceof \EE_Event ? $this->event->ID() : $event;
209
-        return ! is_admin()
210
-               && (
211
-                   ! $this->event->display_ticket_selector()
212
-                   || $view_details
213
-                   || post_password_required($event_post)
214
-                   || (
215
-                       $_event_active_status !== \EE_Datetime::active
216
-                       && $_event_active_status !== \EE_Datetime::upcoming
217
-                       && $_event_active_status !== \EE_Datetime::sold_out
218
-                       && ! (
219
-                           $_event_active_status === \EE_Datetime::inactive
220
-                           && is_user_logged_in()
221
-                       )
222
-                   )
223
-               );
224
-    }
225
-
226
-
227
-
228
-    /**
229
-     * noTicketAvailableMessage
230
-     * notice displayed if event is expired
231
-     *
232
-     * @return string
233
-     * @throws \EE_Error
234
-     */
235
-    protected function expiredEventMessage()
236
-    {
237
-        return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__(
238
-            'We\'re sorry, but all tickets sales have ended because the event is expired.',
239
-            'event_espresso'
240
-        ) . '</span></div>';
241
-    }
242
-
243
-
244
-
245
-    /**
246
-     * noTicketAvailableMessage
247
-     * notice displayed if event has no more tickets available
248
-     *
249
-     * @return string
250
-     * @throws \EE_Error
251
-     */
252
-    protected function noTicketAvailableMessage()
253
-    {
254
-        $no_ticket_available_msg = esc_html__( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' );
255
-        if (current_user_can('edit_post', $this->event->ID())) {
256
-            $no_ticket_available_msg .= sprintf(
257
-                esc_html__(
258
-                    '%1$sNote to Event Admin:%2$sNo tickets were found for this event. This effectively turns off ticket sales. Please ensure that at least one ticket is available for if you want people to be able to register.%3$s(click to edit this event)%4$s',
259
-                    'event_espresso'
260
-                ),
261
-                '<div class="ee-attention" style="text-align: left;"><b>',
262
-                '</b><br />',
263
-                '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">',
264
-                '</a></span></div>'
265
-            );
266
-        }
267
-        return '
22
+	/**
23
+	 * event that ticket selector is being generated for
24
+	 *
25
+	 * @access protected
26
+	 * @var \EE_Event $event
27
+	 */
28
+	protected $event;
29
+
30
+	/**
31
+	 * Used to flag when the ticket selector is being called from an external iframe.
32
+	 *
33
+	 * @var bool $iframe
34
+	 */
35
+	protected $iframe = false;
36
+
37
+	/**
38
+	 * max attendees that can register for event at one time
39
+	 *
40
+	 * @var int $max_attendees
41
+	 */
42
+	private $max_attendees = EE_INF;
43
+
44
+	/**
45
+	 *@var string $date_format
46
+	 */
47
+	private $date_format = '';
48
+
49
+	/**
50
+	 *@var string $time_format
51
+	 */
52
+	private $time_format = '';
53
+
54
+
55
+
56
+	/**
57
+	 * DisplayTicketSelector constructor.
58
+	 */
59
+	public function __construct()
60
+	{
61
+		$this->date_format = apply_filters(
62
+			'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format',
63
+			get_option('date_format')
64
+		);
65
+		$this->time_format = apply_filters(
66
+			'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format',
67
+			get_option('time_format')
68
+		);
69
+	}
70
+
71
+
72
+
73
+	/**
74
+	 * @param boolean $iframe
75
+	 */
76
+	public function setIframe( $iframe = true )
77
+	{
78
+		$this->iframe = filter_var( $iframe, FILTER_VALIDATE_BOOLEAN );
79
+	}
80
+
81
+
82
+
83
+	/**
84
+	 * finds and sets the \EE_Event object for use throughout class
85
+	 *
86
+	 * @param    mixed $event
87
+	 * @return    bool
88
+	 */
89
+	protected function setEvent( $event = null )
90
+	{
91
+		if ( $event === null ) {
92
+			global $post;
93
+			$event = $post;
94
+		}
95
+		if ( $event instanceof \EE_Event ) {
96
+			$this->event = $event;
97
+		} else if ( $event instanceof \WP_Post ) {
98
+			if ( isset( $event->EE_Event ) && $event->EE_Event instanceof \EE_Event ) {
99
+				$this->event = $event->EE_Event;
100
+			} else if ( $event->post_type === 'espresso_events' ) {
101
+				$event->EE_Event = \EEM_Event::instance()->instantiate_class_from_post_object( $event );
102
+				$this->event = $event->EE_Event;
103
+			}
104
+		} else {
105
+			$user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' );
106
+			$dev_msg = $user_msg . __(
107
+					'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.',
108
+					'event_espresso'
109
+				);
110
+			\EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ );
111
+			return false;
112
+		}
113
+		return true;
114
+	}
115
+
116
+
117
+
118
+	/**
119
+	 * @return int
120
+	 */
121
+	public function getMaxAttendees()
122
+	{
123
+		return $this->max_attendees;
124
+	}
125
+
126
+
127
+
128
+	/**
129
+	 * @param int $max_attendees
130
+	 */
131
+	public function setMaxAttendees($max_attendees)
132
+	{
133
+		$this->max_attendees = absint(
134
+			apply_filters(
135
+				'FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets',
136
+				$max_attendees
137
+			)
138
+		);
139
+	}
140
+
141
+
142
+
143
+	/**
144
+	 * creates buttons for selecting number of attendees for an event
145
+	 *
146
+	 * @param \WP_Post|int $event
147
+	 * @param bool         $view_details
148
+	 * @return string
149
+	 * @throws \EE_Error
150
+	 */
151
+	public function display( $event = null, $view_details = false )
152
+	{
153
+		// reset filter for displaying submit button
154
+		remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
155
+		// poke and prod incoming event till it tells us what it is
156
+		if ( ! $this->setEvent( $event ) ) {
157
+			return false;
158
+		}
159
+		// begin gathering template arguments by getting event status
160
+		$template_args = array( 'event_status' => $this->event->get_active_status() );
161
+		if ( $this->activeEventAndShowTicketSelector($event, $template_args['event_status'], $view_details) ) {
162
+			return ! is_single() ? $this->displayViewDetailsButton() : '';
163
+		}
164
+		// filter the maximum qty that can appear in the Ticket Selector qty dropdowns
165
+		$this->setMaxAttendees($this->event->additional_limit());
166
+		if ($this->getMaxAttendees() < 1) {
167
+			return $this->ticketSalesClosedMessage();
168
+		}
169
+		// is the event expired ?
170
+		$template_args['event_is_expired'] = $this->event->is_expired();
171
+		if ( $template_args[ 'event_is_expired' ] ) {
172
+			return $this->expiredEventMessage();
173
+		}
174
+		// get all tickets for this event ordered by the datetime
175
+		$tickets = $this->getTickets();
176
+		if (count($tickets) < 1) {
177
+			return $this->noTicketAvailableMessage();
178
+		}
179
+		// redirecting to another site for registration ??
180
+		$external_url = (string) $this->event->external_url();
181
+		// if redirecting to another site for registration, then we don't load the TS
182
+		$ticket_selector = $external_url
183
+			? $this->externalEventRegistration()
184
+			: $this->loadTicketSelector($tickets,$template_args);
185
+		// now set up the form (but not for the admin)
186
+		$ticket_selector = ! is_admin()
187
+			? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector
188
+			: $ticket_selector;
189
+		// submit button and form close tag
190
+		$ticket_selector .= ! is_admin() ? $this->displaySubmitButton($external_url) : '';
191
+		return $ticket_selector;
192
+	}
193
+
194
+
195
+
196
+	/**
197
+	 * displayTicketSelector
198
+	 * examines the event properties and determines whether a Ticket Selector should be displayed
199
+	 *
200
+	 * @param \WP_Post|int $event
201
+	 * @param string       $_event_active_status
202
+	 * @param bool         $view_details
203
+	 * @return bool
204
+	 * @throws \EE_Error
205
+	 */
206
+	protected function activeEventAndShowTicketSelector($event, $_event_active_status, $view_details)
207
+	{
208
+		$event_post = $this->event instanceof \EE_Event ? $this->event->ID() : $event;
209
+		return ! is_admin()
210
+			   && (
211
+				   ! $this->event->display_ticket_selector()
212
+				   || $view_details
213
+				   || post_password_required($event_post)
214
+				   || (
215
+					   $_event_active_status !== \EE_Datetime::active
216
+					   && $_event_active_status !== \EE_Datetime::upcoming
217
+					   && $_event_active_status !== \EE_Datetime::sold_out
218
+					   && ! (
219
+						   $_event_active_status === \EE_Datetime::inactive
220
+						   && is_user_logged_in()
221
+					   )
222
+				   )
223
+			   );
224
+	}
225
+
226
+
227
+
228
+	/**
229
+	 * noTicketAvailableMessage
230
+	 * notice displayed if event is expired
231
+	 *
232
+	 * @return string
233
+	 * @throws \EE_Error
234
+	 */
235
+	protected function expiredEventMessage()
236
+	{
237
+		return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__(
238
+			'We\'re sorry, but all tickets sales have ended because the event is expired.',
239
+			'event_espresso'
240
+		) . '</span></div>';
241
+	}
242
+
243
+
244
+
245
+	/**
246
+	 * noTicketAvailableMessage
247
+	 * notice displayed if event has no more tickets available
248
+	 *
249
+	 * @return string
250
+	 * @throws \EE_Error
251
+	 */
252
+	protected function noTicketAvailableMessage()
253
+	{
254
+		$no_ticket_available_msg = esc_html__( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' );
255
+		if (current_user_can('edit_post', $this->event->ID())) {
256
+			$no_ticket_available_msg .= sprintf(
257
+				esc_html__(
258
+					'%1$sNote to Event Admin:%2$sNo tickets were found for this event. This effectively turns off ticket sales. Please ensure that at least one ticket is available for if you want people to be able to register.%3$s(click to edit this event)%4$s',
259
+					'event_espresso'
260
+				),
261
+				'<div class="ee-attention" style="text-align: left;"><b>',
262
+				'</b><br />',
263
+				'<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">',
264
+				'</a></span></div>'
265
+			);
266
+		}
267
+		return '
268 268
             <div class="ee-event-expired-notice">
269 269
                 <span class="important-notice">' . $no_ticket_available_msg . '</span>
270 270
             </div>';
271
-    }
272
-
273
-
274
-
275
-    /**
276
-     * ticketSalesClosed
277
-     * notice displayed if event ticket sales are turned off
278
-     *
279
-     * @return string
280
-     * @throws \EE_Error
281
-     */
282
-    protected function ticketSalesClosedMessage()
283
-    {
284
-        $sales_closed_msg = esc_html__(
285
-            'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.',
286
-            'event_espresso'
287
-        );
288
-        if (current_user_can('edit_post', $this->event->ID())) {
289
-            $sales_closed_msg .= sprintf(
290
-                esc_html__(
291
-                    '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s',
292
-                    'event_espresso'
293
-                ),
294
-                '<div class="ee-attention" style="text-align: left;"><b>',
295
-                '</b><br />',
296
-                '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">',
297
-                '</a></span></div>'
298
-            );
299
-        }
300
-        return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>';
301
-    }
302
-
303
-
304
-
305
-    /**
306
-     * getTickets
307
-     *
308
-     * @return \EE_Base_Class[]|\EE_Ticket[]
309
-     * @throws \EE_Error
310
-     */
311
-    protected function getTickets()
312
-    {
313
-        $ticket_query_args = array(
314
-            array('Datetime.EVT_ID' => $this->event->ID()),
315
-            'order_by' => array(
316
-                'TKT_order'              => 'ASC',
317
-                'TKT_required'           => 'DESC',
318
-                'TKT_start_date'         => 'ASC',
319
-                'TKT_end_date'           => 'ASC',
320
-                'Datetime.DTT_EVT_start' => 'DESC',
321
-            ),
322
-        );
323
-        if ( ! \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) {
324
-            //use the correct applicable time query depending on what version of core is being run.
325
-            $current_time = method_exists('EEM_Datetime', 'current_time_for_query')
326
-                ? time()
327
-                : current_time('timestamp');
328
-            $ticket_query_args[0]['TKT_end_date'] = array('>', $current_time);
329
-        }
330
-        return \EEM_Ticket::instance()->get_all($ticket_query_args);
331
-    }
332
-
333
-
334
-
335
-    /**
336
-     * loadTicketSelector
337
-     * begins to assemble template arguments
338
-     * and decides whether to load a "simple" ticket selector, or the standard
339
-     *
340
-     * @param \EE_Ticket[] $tickets
341
-     * @param array $template_args
342
-     * @return string
343
-     * @throws \EE_Error
344
-     */
345
-    protected function loadTicketSelector(array $tickets, array $template_args)
346
-    {
347
-        $template_args['event'] = $this->event;
348
-        $template_args['EVT_ID'] = $this->event->ID();
349
-        $template_args['event_is_expired'] = $this->event->is_expired();
350
-        $template_args['max_atndz'] = $this->getMaxAttendees();
351
-        $template_args['date_format'] = $this->date_format;
352
-        $template_args['time_format'] = $this->time_format;
353
-        /**
354
-         * Filters the anchor ID used when redirecting to the Ticket Selector if no quantity selected
355
-         *
356
-         * @since 4.9.13
357
-         * @param     string  '#tkt-slctr-tbl-' . $EVT_ID The html ID to anchor to
358
-         * @param int $EVT_ID The Event ID
359
-         */
360
-        $template_args['anchor_id'] = apply_filters(
361
-            'FHEE__EE_Ticket_Selector__redirect_anchor_id',
362
-            '#tkt-slctr-tbl-' . $this->event->ID(),
363
-            $this->event->ID()
364
-        );
365
-        $template_args['tickets'] = $tickets;
366
-        $template_args['ticket_count'] = count($tickets);
367
-        $ticket_selector = $this->simpleTicketSelector( $tickets, $template_args);
368
-        return $ticket_selector instanceof TicketSelectorSimple
369
-            ? $ticket_selector
370
-            : new TicketSelectorStandard(
371
-                $this->event,
372
-                $tickets,
373
-                $this->getMaxAttendees(),
374
-                $template_args,
375
-                $this->date_format,
376
-                $this->time_format
377
-            );
378
-    }
379
-
380
-
381
-
382
-    /**
383
-     * simpleTicketSelector
384
-     * there's one ticket, and max attendees is set to one,
385
-     * so if the event is free, then this is a "simple" ticket selector
386
-     * a.k.a. "Dude Where's my Ticket Selector?"
387
-     *
388
-     * @param \EE_Ticket[] $tickets
389
-     * @param array  $template_args
390
-     * @return string
391
-     * @throws \EE_Error
392
-     */
393
-    protected function simpleTicketSelector($tickets, array $template_args)
394
-    {
395
-        // if there is only ONE ticket with a max qty of ONE
396
-        if (count($tickets) > 1 || $this->getMaxAttendees() !== 1) {
397
-            return '';
398
-        }
399
-        /** @var \EE_Ticket $ticket */
400
-        $ticket = reset($tickets);
401
-        // if the ticket is free... then not much need for the ticket selector
402
-        if (
403
-            apply_filters(
404
-                'FHEE__ticket_selector_chart_template__hide_ticket_selector',
405
-                $ticket->is_free(),
406
-                $this->event->ID()
407
-            )
408
-        ) {
409
-            return new TicketSelectorSimple(
410
-                $this->event,
411
-                $ticket,
412
-                $this->getMaxAttendees(),
413
-                $template_args
414
-            );
415
-        }
416
-        return '';
417
-    }
418
-
419
-
420
-
421
-    /**
422
-     * externalEventRegistration
423
-     *
424
-     * @return string
425
-     */
426
-    public function externalEventRegistration()
427
-    {
428
-        // if not we still need to trigger the display of the submit button
429
-        add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
430
-        //display notice to admin that registration is external
431
-        return is_admin()
432
-            ? esc_html__(
433
-                'Registration is at an external URL for this event.',
434
-                'event_espresso'
435
-            )
436
-            : '';
437
-    }
438
-
439
-
440
-
441
-    /**
442
-     * formOpen
443
-     *
444
-     * @param        int    $ID
445
-     * @param        string $external_url
446
-     * @return        string
447
-     */
448
-    public function formOpen( $ID = 0, $external_url = '' )
449
-    {
450
-        // if redirecting, we don't need any anything else
451
-        if ( $external_url ) {
452
-            $html = '<form method="GET" action="' . \EEH_URL::refactor_url($external_url) . '"';
453
-            // open link in new window ?
454
-            $html .= apply_filters(
455
-                'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank',
456
-                false
457
-            )
458
-                ? ' target="_blank"'
459
-                : '';
460
-            $html .= '>';
461
-            $query_args = \EEH_URL::get_query_string( $external_url );
462
-            foreach ( (array)$query_args as $query_arg => $value ) {
463
-                $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">';
464
-            }
465
-            return $html;
466
-        }
467
-        // if there is no submit button, then don't start building a form
468
-        // because the "View Details" button will build its own form
469
-        if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
470
-            return '';
471
-        }
472
-        $checkout_url = \EEH_Event_View::event_link_url( $ID );
473
-        if ( ! $checkout_url ) {
474
-            \EE_Error::add_error(
475
-                esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
476
-                __FILE__,
477
-                __FUNCTION__,
478
-                __LINE__
479
-            );
480
-        }
481
-        // set no cache headers and constants
482
-        \EE_System::do_not_cache();
483
-        $extra_params = $this->iframe ? ' target="_blank"' : '';
484
-        $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>';
485
-        $html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce_' . $ID, true, false );
486
-        $html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
487
-        $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event );
488
-        return $html;
489
-    }
490
-
491
-
492
-
493
-    /**
494
-     * displaySubmitButton
495
-     *
496
-     * @param  string $external_url
497
-     * @return string
498
-     * @throws \EE_Error
499
-     */
500
-    public function displaySubmitButton($external_url = '')
501
-    {
502
-        $html = '';
503
-        if ( ! is_admin()) {
504
-            // standard TS displayed with submit button, ie: "Register Now"
505
-            if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
506
-                $html .= $this->displayRegisterNowButton();
507
-                $html .= empty($external_url)
508
-                    ? $this->ticketSelectorEndDiv()
509
-                    : $this->clearTicketSelector();
510
-                $html .= '<br/>' . $this->formClose();
511
-            } else if ($this->getMaxAttendees() === 1) {
512
-                // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1)
513
-                if ($this->event->is_sold_out()) {
514
-                    // then instead of a View Details or Submit button, just display a "Sold Out" message
515
-                    $html .= apply_filters(
516
-                        'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg',
517
-                        sprintf(
518
-                            __(
519
-                                '%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s',
520
-                                'event_espresso'
521
-                            ),
522
-                            '<p class="no-ticket-selector-msg clear-float">',
523
-                            $this->event->name(),
524
-                            '</p>',
525
-                            '<br />'
526
-                        ),
527
-                        $this->event
528
-                    );
529
-                    if (
530
-                    apply_filters(
531
-                        'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
532
-                        false,
533
-                        $this->event
534
-                    )
535
-                    ) {
536
-                        $html .= $this->displayRegisterNowButton();
537
-                    }
538
-                    // sold out DWMTS event, no TS, no submit or view details button, but has additional content
539
-                    $html .= $this->ticketSelectorEndDiv();
540
-                } else if (
541
-                    apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false)
542
-                    && ! is_single()
543
-                ) {
544
-                    // this is a "Dude Where's my Ticket Selector?" (DWMTS) type event,
545
-                    // but no tickets are available, so display event's "View Details" button.
546
-                    // it is being viewed via somewhere other than a single post
547
-                    $html .= $this->displayViewDetailsButton(true);
548
-                }
549
-            } else if (is_archive()) {
550
-                // event list, no tickets available so display event's "View Details" button
551
-                $html .= $this->ticketSelectorEndDiv();
552
-                $html .= $this->displayViewDetailsButton();
553
-            } else {
554
-                if (
555
-                apply_filters(
556
-                    'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
557
-                    false,
558
-                    $this->event
559
-                )
560
-                ) {
561
-                    $html .= $this->displayRegisterNowButton();
562
-                }
563
-                // no submit or view details button, and no additional content
564
-                $html .= $this->ticketSelectorEndDiv();
565
-            }
566
-            if ( ! $this->iframe && ! is_archive()) {
567
-                $html .= \EEH_Template::powered_by_event_espresso('', '', array('utm_content' => 'ticket_selector'));
568
-            }
569
-        }
570
-        return $html;
571
-    }
572
-
573
-
574
-
575
-    /**
576
-     * @return string
577
-     * @throws \EE_Error
578
-     */
579
-    public function displayRegisterNowButton()
580
-    {
581
-        $btn_text = apply_filters(
582
-            'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text',
583
-            __('Register Now', 'event_espresso'),
584
-            $this->event
585
-        );
586
-        $external_url = $this->event->external_url();
587
-        $html = \EEH_HTML::div(
588
-            '', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap'
589
-        );
590
-        $html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"';
591
-        $html .= ' class="ticket-selector-submit-btn ';
592
-        $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"';
593
-        $html .= ' type="submit" value="' . $btn_text . '" />';
594
-        $html .= \EEH_HTML::divx();
595
-        $html .= apply_filters(
596
-            'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
597
-            '',
598
-            $this->event
599
-        );
600
-        return $html;
601
-    }
602
-
603
-
604
-    /**
605
-     * displayViewDetailsButton
606
-     *
607
-     * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event
608
-     *                    (ie: $_max_atndz === 1) where there are no available tickets,
609
-     *                    either because they are sold out, expired, or not yet on sale.
610
-     *                    In this case, we need to close the form BEFORE adding any closing divs
611
-     * @return string
612
-     * @throws \EE_Error
613
-     */
614
-    public function displayViewDetailsButton( $DWMTS = false )
615
-    {
616
-        if ( ! $this->event->get_permalink() ) {
617
-            \EE_Error::add_error(
618
-                esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
619
-                __FILE__, __FUNCTION__, __LINE__
620
-            );
621
-        }
622
-        $view_details_btn = '<form method="POST" action="';
623
-        $view_details_btn .= apply_filters(
624
-            'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_url',
625
-            $this->event->get_permalink(),
626
-            $this->event
627
-        );
628
-        $view_details_btn .= '">';
629
-        $btn_text = apply_filters(
630
-            'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text',
631
-            esc_html__('View Details', 'event_espresso'),
632
-            $this->event
633
-        );
634
-        $view_details_btn .= '<input id="ticket-selector-submit-'
635
-                             . $this->event->ID()
636
-                             . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'
637
-                             . $btn_text
638
-                             . '" />';
639
-        $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event );
640
-        if ($DWMTS) {
641
-            $view_details_btn .= $this->formClose();
642
-            $view_details_btn .= $this->ticketSelectorEndDiv();
643
-            $view_details_btn .= '<br/>';
644
-        } else {
645
-            $view_details_btn .= $this->clearTicketSelector();
646
-            $view_details_btn .= '<br/>';
647
-            $view_details_btn .= $this->formClose();
648
-        }
649
-        return $view_details_btn;
650
-    }
651
-
652
-
653
-
654
-    /**
655
-     * @return string
656
-     */
657
-    public function ticketSelectorEndDiv()
658
-    {
659
-        return '<div class="clear"></div></div>';
660
-    }
661
-
662
-
663
-
664
-    /**
665
-     * @return string
666
-     */
667
-    public function clearTicketSelector()
668
-    {
669
-        // standard TS displayed, appears after a "Register Now" or "view Details" button
670
-        return '<div class="clear"></div>';
671
-    }
672
-
673
-
674
-
675
-    /**
676
-     * @access        public
677
-     * @return        string
678
-     */
679
-    public function formClose()
680
-    {
681
-        return '</form>';
682
-    }
271
+	}
272
+
273
+
274
+
275
+	/**
276
+	 * ticketSalesClosed
277
+	 * notice displayed if event ticket sales are turned off
278
+	 *
279
+	 * @return string
280
+	 * @throws \EE_Error
281
+	 */
282
+	protected function ticketSalesClosedMessage()
283
+	{
284
+		$sales_closed_msg = esc_html__(
285
+			'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.',
286
+			'event_espresso'
287
+		);
288
+		if (current_user_can('edit_post', $this->event->ID())) {
289
+			$sales_closed_msg .= sprintf(
290
+				esc_html__(
291
+					'%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s',
292
+					'event_espresso'
293
+				),
294
+				'<div class="ee-attention" style="text-align: left;"><b>',
295
+				'</b><br />',
296
+				'<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">',
297
+				'</a></span></div>'
298
+			);
299
+		}
300
+		return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>';
301
+	}
302
+
303
+
304
+
305
+	/**
306
+	 * getTickets
307
+	 *
308
+	 * @return \EE_Base_Class[]|\EE_Ticket[]
309
+	 * @throws \EE_Error
310
+	 */
311
+	protected function getTickets()
312
+	{
313
+		$ticket_query_args = array(
314
+			array('Datetime.EVT_ID' => $this->event->ID()),
315
+			'order_by' => array(
316
+				'TKT_order'              => 'ASC',
317
+				'TKT_required'           => 'DESC',
318
+				'TKT_start_date'         => 'ASC',
319
+				'TKT_end_date'           => 'ASC',
320
+				'Datetime.DTT_EVT_start' => 'DESC',
321
+			),
322
+		);
323
+		if ( ! \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) {
324
+			//use the correct applicable time query depending on what version of core is being run.
325
+			$current_time = method_exists('EEM_Datetime', 'current_time_for_query')
326
+				? time()
327
+				: current_time('timestamp');
328
+			$ticket_query_args[0]['TKT_end_date'] = array('>', $current_time);
329
+		}
330
+		return \EEM_Ticket::instance()->get_all($ticket_query_args);
331
+	}
332
+
333
+
334
+
335
+	/**
336
+	 * loadTicketSelector
337
+	 * begins to assemble template arguments
338
+	 * and decides whether to load a "simple" ticket selector, or the standard
339
+	 *
340
+	 * @param \EE_Ticket[] $tickets
341
+	 * @param array $template_args
342
+	 * @return string
343
+	 * @throws \EE_Error
344
+	 */
345
+	protected function loadTicketSelector(array $tickets, array $template_args)
346
+	{
347
+		$template_args['event'] = $this->event;
348
+		$template_args['EVT_ID'] = $this->event->ID();
349
+		$template_args['event_is_expired'] = $this->event->is_expired();
350
+		$template_args['max_atndz'] = $this->getMaxAttendees();
351
+		$template_args['date_format'] = $this->date_format;
352
+		$template_args['time_format'] = $this->time_format;
353
+		/**
354
+		 * Filters the anchor ID used when redirecting to the Ticket Selector if no quantity selected
355
+		 *
356
+		 * @since 4.9.13
357
+		 * @param     string  '#tkt-slctr-tbl-' . $EVT_ID The html ID to anchor to
358
+		 * @param int $EVT_ID The Event ID
359
+		 */
360
+		$template_args['anchor_id'] = apply_filters(
361
+			'FHEE__EE_Ticket_Selector__redirect_anchor_id',
362
+			'#tkt-slctr-tbl-' . $this->event->ID(),
363
+			$this->event->ID()
364
+		);
365
+		$template_args['tickets'] = $tickets;
366
+		$template_args['ticket_count'] = count($tickets);
367
+		$ticket_selector = $this->simpleTicketSelector( $tickets, $template_args);
368
+		return $ticket_selector instanceof TicketSelectorSimple
369
+			? $ticket_selector
370
+			: new TicketSelectorStandard(
371
+				$this->event,
372
+				$tickets,
373
+				$this->getMaxAttendees(),
374
+				$template_args,
375
+				$this->date_format,
376
+				$this->time_format
377
+			);
378
+	}
379
+
380
+
381
+
382
+	/**
383
+	 * simpleTicketSelector
384
+	 * there's one ticket, and max attendees is set to one,
385
+	 * so if the event is free, then this is a "simple" ticket selector
386
+	 * a.k.a. "Dude Where's my Ticket Selector?"
387
+	 *
388
+	 * @param \EE_Ticket[] $tickets
389
+	 * @param array  $template_args
390
+	 * @return string
391
+	 * @throws \EE_Error
392
+	 */
393
+	protected function simpleTicketSelector($tickets, array $template_args)
394
+	{
395
+		// if there is only ONE ticket with a max qty of ONE
396
+		if (count($tickets) > 1 || $this->getMaxAttendees() !== 1) {
397
+			return '';
398
+		}
399
+		/** @var \EE_Ticket $ticket */
400
+		$ticket = reset($tickets);
401
+		// if the ticket is free... then not much need for the ticket selector
402
+		if (
403
+			apply_filters(
404
+				'FHEE__ticket_selector_chart_template__hide_ticket_selector',
405
+				$ticket->is_free(),
406
+				$this->event->ID()
407
+			)
408
+		) {
409
+			return new TicketSelectorSimple(
410
+				$this->event,
411
+				$ticket,
412
+				$this->getMaxAttendees(),
413
+				$template_args
414
+			);
415
+		}
416
+		return '';
417
+	}
418
+
419
+
420
+
421
+	/**
422
+	 * externalEventRegistration
423
+	 *
424
+	 * @return string
425
+	 */
426
+	public function externalEventRegistration()
427
+	{
428
+		// if not we still need to trigger the display of the submit button
429
+		add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
430
+		//display notice to admin that registration is external
431
+		return is_admin()
432
+			? esc_html__(
433
+				'Registration is at an external URL for this event.',
434
+				'event_espresso'
435
+			)
436
+			: '';
437
+	}
438
+
439
+
440
+
441
+	/**
442
+	 * formOpen
443
+	 *
444
+	 * @param        int    $ID
445
+	 * @param        string $external_url
446
+	 * @return        string
447
+	 */
448
+	public function formOpen( $ID = 0, $external_url = '' )
449
+	{
450
+		// if redirecting, we don't need any anything else
451
+		if ( $external_url ) {
452
+			$html = '<form method="GET" action="' . \EEH_URL::refactor_url($external_url) . '"';
453
+			// open link in new window ?
454
+			$html .= apply_filters(
455
+				'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank',
456
+				false
457
+			)
458
+				? ' target="_blank"'
459
+				: '';
460
+			$html .= '>';
461
+			$query_args = \EEH_URL::get_query_string( $external_url );
462
+			foreach ( (array)$query_args as $query_arg => $value ) {
463
+				$html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">';
464
+			}
465
+			return $html;
466
+		}
467
+		// if there is no submit button, then don't start building a form
468
+		// because the "View Details" button will build its own form
469
+		if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
470
+			return '';
471
+		}
472
+		$checkout_url = \EEH_Event_View::event_link_url( $ID );
473
+		if ( ! $checkout_url ) {
474
+			\EE_Error::add_error(
475
+				esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
476
+				__FILE__,
477
+				__FUNCTION__,
478
+				__LINE__
479
+			);
480
+		}
481
+		// set no cache headers and constants
482
+		\EE_System::do_not_cache();
483
+		$extra_params = $this->iframe ? ' target="_blank"' : '';
484
+		$html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>';
485
+		$html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce_' . $ID, true, false );
486
+		$html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
487
+		$html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event );
488
+		return $html;
489
+	}
490
+
491
+
492
+
493
+	/**
494
+	 * displaySubmitButton
495
+	 *
496
+	 * @param  string $external_url
497
+	 * @return string
498
+	 * @throws \EE_Error
499
+	 */
500
+	public function displaySubmitButton($external_url = '')
501
+	{
502
+		$html = '';
503
+		if ( ! is_admin()) {
504
+			// standard TS displayed with submit button, ie: "Register Now"
505
+			if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
506
+				$html .= $this->displayRegisterNowButton();
507
+				$html .= empty($external_url)
508
+					? $this->ticketSelectorEndDiv()
509
+					: $this->clearTicketSelector();
510
+				$html .= '<br/>' . $this->formClose();
511
+			} else if ($this->getMaxAttendees() === 1) {
512
+				// its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1)
513
+				if ($this->event->is_sold_out()) {
514
+					// then instead of a View Details or Submit button, just display a "Sold Out" message
515
+					$html .= apply_filters(
516
+						'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg',
517
+						sprintf(
518
+							__(
519
+								'%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s',
520
+								'event_espresso'
521
+							),
522
+							'<p class="no-ticket-selector-msg clear-float">',
523
+							$this->event->name(),
524
+							'</p>',
525
+							'<br />'
526
+						),
527
+						$this->event
528
+					);
529
+					if (
530
+					apply_filters(
531
+						'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
532
+						false,
533
+						$this->event
534
+					)
535
+					) {
536
+						$html .= $this->displayRegisterNowButton();
537
+					}
538
+					// sold out DWMTS event, no TS, no submit or view details button, but has additional content
539
+					$html .= $this->ticketSelectorEndDiv();
540
+				} else if (
541
+					apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false)
542
+					&& ! is_single()
543
+				) {
544
+					// this is a "Dude Where's my Ticket Selector?" (DWMTS) type event,
545
+					// but no tickets are available, so display event's "View Details" button.
546
+					// it is being viewed via somewhere other than a single post
547
+					$html .= $this->displayViewDetailsButton(true);
548
+				}
549
+			} else if (is_archive()) {
550
+				// event list, no tickets available so display event's "View Details" button
551
+				$html .= $this->ticketSelectorEndDiv();
552
+				$html .= $this->displayViewDetailsButton();
553
+			} else {
554
+				if (
555
+				apply_filters(
556
+					'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
557
+					false,
558
+					$this->event
559
+				)
560
+				) {
561
+					$html .= $this->displayRegisterNowButton();
562
+				}
563
+				// no submit or view details button, and no additional content
564
+				$html .= $this->ticketSelectorEndDiv();
565
+			}
566
+			if ( ! $this->iframe && ! is_archive()) {
567
+				$html .= \EEH_Template::powered_by_event_espresso('', '', array('utm_content' => 'ticket_selector'));
568
+			}
569
+		}
570
+		return $html;
571
+	}
572
+
573
+
574
+
575
+	/**
576
+	 * @return string
577
+	 * @throws \EE_Error
578
+	 */
579
+	public function displayRegisterNowButton()
580
+	{
581
+		$btn_text = apply_filters(
582
+			'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text',
583
+			__('Register Now', 'event_espresso'),
584
+			$this->event
585
+		);
586
+		$external_url = $this->event->external_url();
587
+		$html = \EEH_HTML::div(
588
+			'', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap'
589
+		);
590
+		$html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"';
591
+		$html .= ' class="ticket-selector-submit-btn ';
592
+		$html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"';
593
+		$html .= ' type="submit" value="' . $btn_text . '" />';
594
+		$html .= \EEH_HTML::divx();
595
+		$html .= apply_filters(
596
+			'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
597
+			'',
598
+			$this->event
599
+		);
600
+		return $html;
601
+	}
602
+
603
+
604
+	/**
605
+	 * displayViewDetailsButton
606
+	 *
607
+	 * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event
608
+	 *                    (ie: $_max_atndz === 1) where there are no available tickets,
609
+	 *                    either because they are sold out, expired, or not yet on sale.
610
+	 *                    In this case, we need to close the form BEFORE adding any closing divs
611
+	 * @return string
612
+	 * @throws \EE_Error
613
+	 */
614
+	public function displayViewDetailsButton( $DWMTS = false )
615
+	{
616
+		if ( ! $this->event->get_permalink() ) {
617
+			\EE_Error::add_error(
618
+				esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
619
+				__FILE__, __FUNCTION__, __LINE__
620
+			);
621
+		}
622
+		$view_details_btn = '<form method="POST" action="';
623
+		$view_details_btn .= apply_filters(
624
+			'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_url',
625
+			$this->event->get_permalink(),
626
+			$this->event
627
+		);
628
+		$view_details_btn .= '">';
629
+		$btn_text = apply_filters(
630
+			'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text',
631
+			esc_html__('View Details', 'event_espresso'),
632
+			$this->event
633
+		);
634
+		$view_details_btn .= '<input id="ticket-selector-submit-'
635
+							 . $this->event->ID()
636
+							 . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'
637
+							 . $btn_text
638
+							 . '" />';
639
+		$view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event );
640
+		if ($DWMTS) {
641
+			$view_details_btn .= $this->formClose();
642
+			$view_details_btn .= $this->ticketSelectorEndDiv();
643
+			$view_details_btn .= '<br/>';
644
+		} else {
645
+			$view_details_btn .= $this->clearTicketSelector();
646
+			$view_details_btn .= '<br/>';
647
+			$view_details_btn .= $this->formClose();
648
+		}
649
+		return $view_details_btn;
650
+	}
651
+
652
+
653
+
654
+	/**
655
+	 * @return string
656
+	 */
657
+	public function ticketSelectorEndDiv()
658
+	{
659
+		return '<div class="clear"></div></div>';
660
+	}
661
+
662
+
663
+
664
+	/**
665
+	 * @return string
666
+	 */
667
+	public function clearTicketSelector()
668
+	{
669
+		// standard TS displayed, appears after a "Register Now" or "view Details" button
670
+		return '<div class="clear"></div>';
671
+	}
672
+
673
+
674
+
675
+	/**
676
+	 * @access        public
677
+	 * @return        string
678
+	 */
679
+	public function formClose()
680
+	{
681
+		return '</form>';
682
+	}
683 683
 
684 684
 
685 685
 
Please login to merge, or discard this patch.
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\modules\ticket_selector;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-    exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+    exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
     /**
74 74
      * @param boolean $iframe
75 75
      */
76
-    public function setIframe( $iframe = true )
76
+    public function setIframe($iframe = true)
77 77
     {
78
-        $this->iframe = filter_var( $iframe, FILTER_VALIDATE_BOOLEAN );
78
+        $this->iframe = filter_var($iframe, FILTER_VALIDATE_BOOLEAN);
79 79
     }
80 80
 
81 81
 
@@ -86,28 +86,28 @@  discard block
 block discarded – undo
86 86
      * @param    mixed $event
87 87
      * @return    bool
88 88
      */
89
-    protected function setEvent( $event = null )
89
+    protected function setEvent($event = null)
90 90
     {
91
-        if ( $event === null ) {
91
+        if ($event === null) {
92 92
             global $post;
93 93
             $event = $post;
94 94
         }
95
-        if ( $event instanceof \EE_Event ) {
95
+        if ($event instanceof \EE_Event) {
96 96
             $this->event = $event;
97
-        } else if ( $event instanceof \WP_Post ) {
98
-            if ( isset( $event->EE_Event ) && $event->EE_Event instanceof \EE_Event ) {
97
+        } else if ($event instanceof \WP_Post) {
98
+            if (isset($event->EE_Event) && $event->EE_Event instanceof \EE_Event) {
99 99
                 $this->event = $event->EE_Event;
100
-            } else if ( $event->post_type === 'espresso_events' ) {
101
-                $event->EE_Event = \EEM_Event::instance()->instantiate_class_from_post_object( $event );
100
+            } else if ($event->post_type === 'espresso_events') {
101
+                $event->EE_Event = \EEM_Event::instance()->instantiate_class_from_post_object($event);
102 102
                 $this->event = $event->EE_Event;
103 103
             }
104 104
         } else {
105
-            $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' );
106
-            $dev_msg = $user_msg . __(
105
+            $user_msg = __('No Event object or an invalid Event object was supplied.', 'event_espresso');
106
+            $dev_msg = $user_msg.__(
107 107
                     'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.',
108 108
                     'event_espresso'
109 109
                 );
110
-            \EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ );
110
+            \EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
111 111
             return false;
112 112
         }
113 113
         return true;
@@ -148,17 +148,17 @@  discard block
 block discarded – undo
148 148
      * @return string
149 149
      * @throws \EE_Error
150 150
      */
151
-    public function display( $event = null, $view_details = false )
151
+    public function display($event = null, $view_details = false)
152 152
     {
153 153
         // reset filter for displaying submit button
154
-        remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
154
+        remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
155 155
         // poke and prod incoming event till it tells us what it is
156
-        if ( ! $this->setEvent( $event ) ) {
156
+        if ( ! $this->setEvent($event)) {
157 157
             return false;
158 158
         }
159 159
         // begin gathering template arguments by getting event status
160
-        $template_args = array( 'event_status' => $this->event->get_active_status() );
161
-        if ( $this->activeEventAndShowTicketSelector($event, $template_args['event_status'], $view_details) ) {
160
+        $template_args = array('event_status' => $this->event->get_active_status());
161
+        if ($this->activeEventAndShowTicketSelector($event, $template_args['event_status'], $view_details)) {
162 162
             return ! is_single() ? $this->displayViewDetailsButton() : '';
163 163
         }
164 164
         // filter the maximum qty that can appear in the Ticket Selector qty dropdowns
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         }
169 169
         // is the event expired ?
170 170
         $template_args['event_is_expired'] = $this->event->is_expired();
171
-        if ( $template_args[ 'event_is_expired' ] ) {
171
+        if ($template_args['event_is_expired']) {
172 172
             return $this->expiredEventMessage();
173 173
         }
174 174
         // get all tickets for this event ordered by the datetime
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
         // if redirecting to another site for registration, then we don't load the TS
182 182
         $ticket_selector = $external_url
183 183
             ? $this->externalEventRegistration()
184
-            : $this->loadTicketSelector($tickets,$template_args);
184
+            : $this->loadTicketSelector($tickets, $template_args);
185 185
         // now set up the form (but not for the admin)
186 186
         $ticket_selector = ! is_admin()
187
-            ? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector
187
+            ? $this->formOpen($this->event->ID(), $external_url).$ticket_selector
188 188
             : $ticket_selector;
189 189
         // submit button and form close tag
190 190
         $ticket_selector .= ! is_admin() ? $this->displaySubmitButton($external_url) : '';
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
      */
235 235
     protected function expiredEventMessage()
236 236
     {
237
-        return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__(
237
+        return '<div class="ee-event-expired-notice"><span class="important-notice">'.esc_html__(
238 238
             'We\'re sorry, but all tickets sales have ended because the event is expired.',
239 239
             'event_espresso'
240
-        ) . '</span></div>';
240
+        ).'</span></div>';
241 241
     }
242 242
 
243 243
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      */
252 252
     protected function noTicketAvailableMessage()
253 253
     {
254
-        $no_ticket_available_msg = esc_html__( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' );
254
+        $no_ticket_available_msg = esc_html__('We\'re sorry, but all ticket sales have ended.', 'event_espresso');
255 255
         if (current_user_can('edit_post', $this->event->ID())) {
256 256
             $no_ticket_available_msg .= sprintf(
257 257
                 esc_html__(
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
         }
267 267
         return '
268 268
             <div class="ee-event-expired-notice">
269
-                <span class="important-notice">' . $no_ticket_available_msg . '</span>
269
+                <span class="important-notice">' . $no_ticket_available_msg.'</span>
270 270
             </div>';
271 271
     }
272 272
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
                 '</a></span></div>'
298 298
             );
299 299
         }
300
-        return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>';
300
+        return '<p><span class="important-notice">'.$sales_closed_msg.'</span></p>';
301 301
     }
302 302
 
303 303
 
@@ -359,12 +359,12 @@  discard block
 block discarded – undo
359 359
          */
360 360
         $template_args['anchor_id'] = apply_filters(
361 361
             'FHEE__EE_Ticket_Selector__redirect_anchor_id',
362
-            '#tkt-slctr-tbl-' . $this->event->ID(),
362
+            '#tkt-slctr-tbl-'.$this->event->ID(),
363 363
             $this->event->ID()
364 364
         );
365 365
         $template_args['tickets'] = $tickets;
366 366
         $template_args['ticket_count'] = count($tickets);
367
-        $ticket_selector = $this->simpleTicketSelector( $tickets, $template_args);
367
+        $ticket_selector = $this->simpleTicketSelector($tickets, $template_args);
368 368
         return $ticket_selector instanceof TicketSelectorSimple
369 369
             ? $ticket_selector
370 370
             : new TicketSelectorStandard(
@@ -445,11 +445,11 @@  discard block
 block discarded – undo
445 445
      * @param        string $external_url
446 446
      * @return        string
447 447
      */
448
-    public function formOpen( $ID = 0, $external_url = '' )
448
+    public function formOpen($ID = 0, $external_url = '')
449 449
     {
450 450
         // if redirecting, we don't need any anything else
451
-        if ( $external_url ) {
452
-            $html = '<form method="GET" action="' . \EEH_URL::refactor_url($external_url) . '"';
451
+        if ($external_url) {
452
+            $html = '<form method="GET" action="'.\EEH_URL::refactor_url($external_url).'"';
453 453
             // open link in new window ?
454 454
             $html .= apply_filters(
455 455
                 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank',
@@ -458,21 +458,21 @@  discard block
 block discarded – undo
458 458
                 ? ' target="_blank"'
459 459
                 : '';
460 460
             $html .= '>';
461
-            $query_args = \EEH_URL::get_query_string( $external_url );
462
-            foreach ( (array)$query_args as $query_arg => $value ) {
463
-                $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">';
461
+            $query_args = \EEH_URL::get_query_string($external_url);
462
+            foreach ((array) $query_args as $query_arg => $value) {
463
+                $html .= '<input type="hidden" name="'.$query_arg.'" value="'.$value.'">';
464 464
             }
465 465
             return $html;
466 466
         }
467 467
         // if there is no submit button, then don't start building a form
468 468
         // because the "View Details" button will build its own form
469
-        if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
469
+        if ( ! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
470 470
             return '';
471 471
         }
472
-        $checkout_url = \EEH_Event_View::event_link_url( $ID );
473
-        if ( ! $checkout_url ) {
472
+        $checkout_url = \EEH_Event_View::event_link_url($ID);
473
+        if ( ! $checkout_url) {
474 474
             \EE_Error::add_error(
475
-                esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
475
+                esc_html__('The URL for the Event Details page could not be retrieved.', 'event_espresso'),
476 476
                 __FILE__,
477 477
                 __FUNCTION__,
478 478
                 __LINE__
@@ -481,10 +481,10 @@  discard block
 block discarded – undo
481 481
         // set no cache headers and constants
482 482
         \EE_System::do_not_cache();
483 483
         $extra_params = $this->iframe ? ' target="_blank"' : '';
484
-        $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>';
485
-        $html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce_' . $ID, true, false );
484
+        $html = '<form method="POST" action="'.$checkout_url.'"'.$extra_params.'>';
485
+        $html .= wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce_'.$ID, true, false);
486 486
         $html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
487
-        $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event );
487
+        $html = apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event);
488 488
         return $html;
489 489
     }
490 490
 
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
                 $html .= empty($external_url)
508 508
                     ? $this->ticketSelectorEndDiv()
509 509
                     : $this->clearTicketSelector();
510
-                $html .= '<br/>' . $this->formClose();
510
+                $html .= '<br/>'.$this->formClose();
511 511
             } else if ($this->getMaxAttendees() === 1) {
512 512
                 // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1)
513 513
                 if ($this->event->is_sold_out()) {
@@ -585,12 +585,12 @@  discard block
 block discarded – undo
585 585
         );
586 586
         $external_url = $this->event->external_url();
587 587
         $html = \EEH_HTML::div(
588
-            '', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap'
588
+            '', 'ticket-selector-submit-'.$this->event->ID().'-btn-wrap', 'ticket-selector-submit-btn-wrap'
589 589
         );
590
-        $html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"';
590
+        $html .= '<input id="ticket-selector-submit-'.$this->event->ID().'-btn"';
591 591
         $html .= ' class="ticket-selector-submit-btn ';
592 592
         $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"';
593
-        $html .= ' type="submit" value="' . $btn_text . '" />';
593
+        $html .= ' type="submit" value="'.$btn_text.'" />';
594 594
         $html .= \EEH_HTML::divx();
595 595
         $html .= apply_filters(
596 596
             'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
@@ -611,11 +611,11 @@  discard block
 block discarded – undo
611 611
      * @return string
612 612
      * @throws \EE_Error
613 613
      */
614
-    public function displayViewDetailsButton( $DWMTS = false )
614
+    public function displayViewDetailsButton($DWMTS = false)
615 615
     {
616
-        if ( ! $this->event->get_permalink() ) {
616
+        if ( ! $this->event->get_permalink()) {
617 617
             \EE_Error::add_error(
618
-                esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
618
+                esc_html__('The URL for the Event Details page could not be retrieved.', 'event_espresso'),
619 619
                 __FILE__, __FUNCTION__, __LINE__
620 620
             );
621 621
         }
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
                              . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'
637 637
                              . $btn_text
638 638
                              . '" />';
639
-        $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event );
639
+        $view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event);
640 640
         if ($DWMTS) {
641 641
             $view_details_btn .= $this->formClose();
642 642
             $view_details_btn .= $this->ticketSelectorEndDiv();
Please login to merge, or discard this patch.
modules/ticket_selector/EED_Ticket_Selector.module.php 2 patches
Indentation   +244 added lines, -244 removed lines patch added patch discarded remove patch
@@ -22,15 +22,15 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class EED_Ticket_Selector extends  EED_Module {
24 24
 
25
-    /**
26
-     * @var EventEspresso\modules\ticket_selector\DisplayTicketSelector $ticket_selector
27
-     */
28
-    private static $ticket_selector;
25
+	/**
26
+	 * @var EventEspresso\modules\ticket_selector\DisplayTicketSelector $ticket_selector
27
+	 */
28
+	private static $ticket_selector;
29 29
 
30
-    /**
31
-     * @var EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton $iframe_embed_button
32
-     */
33
-    private static $iframe_embed_button;
30
+	/**
31
+	 * @var EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton $iframe_embed_button
32
+	 */
33
+	private static $iframe_embed_button;
34 34
 
35 35
 
36 36
 
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
 		// routing
62 62
 		EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' );
63 63
 		EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' );
64
-        EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections');
65
-        add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 );
64
+		EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections');
65
+		add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 );
66 66
 		add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 );
67
-        add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'translate_js_strings' ), 0 );
68
-        add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 );
69
-        EED_Ticket_Selector::loadIframeAssets();
70
-    }
67
+		add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'translate_js_strings' ), 0 );
68
+		add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 );
69
+		EED_Ticket_Selector::loadIframeAssets();
70
+	}
71 71
 
72 72
 
73 73
 
@@ -86,16 +86,16 @@  discard block
 block discarded – undo
86 86
 			10
87 87
 		);
88 88
 
89
-        /**
90
-         * Make sure assets for the ticket selector are loaded on the espresso registrations route so  admin side
91
-         * registrations work.
92
-         */
89
+		/**
90
+		 * Make sure assets for the ticket selector are loaded on the espresso registrations route so  admin side
91
+		 * registrations work.
92
+		 */
93 93
 		add_action(
94
-		    'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_registrations__new_registration',
95
-            array('EED_Ticket_Selector', 'set_definitions'),
96
-            10
97
-        );
98
-    }
94
+			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_registrations__new_registration',
95
+			array('EED_Ticket_Selector', 'set_definitions'),
96
+			10
97
+		);
98
+	}
99 99
 
100 100
 
101 101
 
@@ -111,23 +111,23 @@  discard block
 block discarded – undo
111 111
 
112 112
 		//if config is not set, initialize
113 113
 		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) {
114
-            \EED_Ticket_Selector::instance()->set_config();
115
-            \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config();
114
+			\EED_Ticket_Selector::instance()->set_config();
115
+			\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config();
116 116
 		}
117 117
 	}
118 118
 
119 119
 
120 120
 
121 121
 	/**
122
-     * @return \EventEspresso\modules\ticket_selector\DisplayTicketSelector
123
-     */
124
-    public static function ticketSelector()
125
-    {
126
-        if ( ! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) {
127
-            EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector();
128
-        }
129
-        return EED_Ticket_Selector::$ticket_selector;
130
-    }
122
+	 * @return \EventEspresso\modules\ticket_selector\DisplayTicketSelector
123
+	 */
124
+	public static function ticketSelector()
125
+	{
126
+		if ( ! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) {
127
+			EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector();
128
+		}
129
+		return EED_Ticket_Selector::$ticket_selector;
130
+	}
131 131
 
132 132
 
133 133
 	/**
@@ -180,15 +180,15 @@  discard block
 block discarded – undo
180 180
 
181 181
 
182 182
 
183
-    /**
184
-     *    creates buttons for selecting number of attendees for an event
185
-     *
186
-     * @access    public
187
-     * @param    WP_Post|int $event
188
-     * @param    bool        $view_details
189
-     * @return    string
190
-     * @throws \EE_Error
191
-     */
183
+	/**
184
+	 *    creates buttons for selecting number of attendees for an event
185
+	 *
186
+	 * @access    public
187
+	 * @param    WP_Post|int $event
188
+	 * @param    bool        $view_details
189
+	 * @return    string
190
+	 * @throws \EE_Error
191
+	 */
192 192
 	public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) {
193 193
 		return EED_Ticket_Selector::ticketSelector()->display( $event, $view_details );
194 194
 	}
@@ -209,233 +209,233 @@  discard block
 block discarded – undo
209 209
 
210 210
 
211 211
 
212
-    /**
213
-     * cancel_ticket_selections
214
-     *
215
-     * @access        public
216
-     * @return        string
217
-     */
218
-    public static function cancel_ticket_selections()
219
-    {
220
-        $form = new ProcessTicketSelector();
221
-        return $form->cancelTicketSelections();
222
-    }
212
+	/**
213
+	 * cancel_ticket_selections
214
+	 *
215
+	 * @access        public
216
+	 * @return        string
217
+	 */
218
+	public static function cancel_ticket_selections()
219
+	{
220
+		$form = new ProcessTicketSelector();
221
+		return $form->cancelTicketSelections();
222
+	}
223 223
 
224 224
 
225 225
 
226 226
 	/**
227
-	* @return void
228
-	*/
227
+	 * @return void
228
+	 */
229 229
 	public static function translate_js_strings() {
230
-        EE_Registry::$i18n_js_strings['please_select_date_filter_notice'] = esc_html__(
231
-            'please select a datetime', 'event_espresso'
232
-        );
233
-    }
230
+		EE_Registry::$i18n_js_strings['please_select_date_filter_notice'] = esc_html__(
231
+			'please select a datetime', 'event_espresso'
232
+		);
233
+	}
234 234
 
235 235
 
236 236
 
237 237
 	/**
238
-	* 	load js
239
-	*
240
-	* 	@access 		public
241
-	* 	@return 		void
242
-	*/
238
+	 * 	load js
239
+	 *
240
+	 * 	@access 		public
241
+	 * 	@return 		void
242
+	 */
243 243
 	public static function load_tckt_slctr_assets() {
244 244
 		if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) {
245
-            // add some style
245
+			// add some style
246 246
 			wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css');
247 247
 			wp_enqueue_style('ticket_selector');
248 248
 			// make it dance
249 249
 			wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', array('espresso_core'), '', TRUE);
250 250
 			wp_enqueue_script('ticket_selector');
251
-            require_once( EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php');
252
-            \EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
253
-        }
251
+			require_once( EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php');
252
+			\EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
253
+		}
254
+	}
255
+
256
+
257
+
258
+	/**
259
+	 * @return void
260
+	 */
261
+	public static function loadIframeAssets()
262
+	{
263
+		// for event lists
264
+		add_filter(
265
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
266
+			array('EED_Ticket_Selector', 'iframeCss')
267
+		);
268
+		add_filter(
269
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
270
+			array('EED_Ticket_Selector', 'iframeJs')
271
+		);
272
+		// for ticket selectors
273
+		add_filter(
274
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
275
+			array('EED_Ticket_Selector', 'iframeCss')
276
+		);
277
+		add_filter(
278
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
279
+			array('EED_Ticket_Selector', 'iframeJs')
280
+		);
281
+	}
282
+
283
+
284
+
285
+	/**
286
+	 * Informs the rest of the forms system what CSS and JS is needed to display the input
287
+	 *
288
+	 * @param array $iframe_css
289
+	 * @return array
290
+	 */
291
+	public static function iframeCss(array $iframe_css)
292
+	{
293
+		$iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css';
294
+		return $iframe_css;
254 295
 	}
255 296
 
256 297
 
257 298
 
258
-    /**
259
-     * @return void
260
-     */
261
-    public static function loadIframeAssets()
262
-    {
263
-        // for event lists
264
-        add_filter(
265
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
266
-            array('EED_Ticket_Selector', 'iframeCss')
267
-        );
268
-        add_filter(
269
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
270
-            array('EED_Ticket_Selector', 'iframeJs')
271
-        );
272
-        // for ticket selectors
273
-        add_filter(
274
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
275
-            array('EED_Ticket_Selector', 'iframeCss')
276
-        );
277
-        add_filter(
278
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
279
-            array('EED_Ticket_Selector', 'iframeJs')
280
-        );
281
-    }
282
-
283
-
284
-
285
-    /**
286
-     * Informs the rest of the forms system what CSS and JS is needed to display the input
287
-     *
288
-     * @param array $iframe_css
289
-     * @return array
290
-     */
291
-    public static function iframeCss(array $iframe_css)
292
-    {
293
-        $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css';
294
-        return $iframe_css;
295
-    }
296
-
297
-
298
-
299
-    /**
300
-     * Informs the rest of the forms system what CSS and JS is needed to display the input
301
-     *
302
-     * @param array $iframe_js
303
-     * @return array
304
-     */
305
-    public static function iframeJs(array $iframe_js)
306
-    {
307
-        $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js';
308
-        return $iframe_js;
309
-    }
299
+	/**
300
+	 * Informs the rest of the forms system what CSS and JS is needed to display the input
301
+	 *
302
+	 * @param array $iframe_js
303
+	 * @return array
304
+	 */
305
+	public static function iframeJs(array $iframe_js)
306
+	{
307
+		$iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js';
308
+		return $iframe_js;
309
+	}
310 310
 
311 311
 
312 312
 	/****************************** DEPRECATED ******************************/
313 313
 
314 314
 
315 315
 
316
-    /**
317
-     * @deprecated
318
-     * @return string
319
-     * @throws \EE_Error
320
-     */
321
-    public static function display_view_details_btn()
322
-    {
323
-        // todo add doing_it_wrong() notice during next major version
324
-        return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton();
325
-    }
326
-
327
-
328
-
329
-    /**
330
-     * @deprecated
331
-     * @return string
332
-     * @throws \EE_Error
333
-     */
334
-    public static function display_ticket_selector_submit()
335
-    {
336
-        // todo add doing_it_wrong() notice during next major version
337
-        return EED_Ticket_Selector::ticketSelector()->displaySubmitButton();
338
-    }
339
-
340
-
341
-
342
-    /**
343
-     * @deprecated
344
-     * @param string $permalink_string
345
-     * @param int    $id
346
-     * @param string $new_title
347
-     * @param string $new_slug
348
-     * @return string
349
-     */
350
-    public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '')
351
-    {
352
-        // todo add doing_it_wrong() notice during next major version
353
-        if (
354
-        	\EE_Registry::instance()->REQ->get('page') === 'espresso_events'
355
-        	&& \EE_Registry::instance()->REQ->get('action') === 'edit'
356
-        ) {
357
-            $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
358
-            $iframe_embed_button->addEventEditorIframeEmbedButton();
359
-        }
360
-        return '';
361
-    }
362
-
363
-
364
-
365
-    /**
366
-     * @deprecated
367
-     * @param int    $ID
368
-     * @param string $external_url
369
-     * @return string
370
-     */
371
-    public static function ticket_selector_form_open($ID = 0, $external_url = '')
372
-    {
373
-        // todo add doing_it_wrong() notice during next major version
374
-        return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url);
375
-    }
376
-
377
-
378
-
379
-    /**
380
-     * @deprecated
381
-     * @return string
382
-     */
383
-    public static function ticket_selector_form_close()
384
-    {
385
-        // todo add doing_it_wrong() notice during next major version
386
-        return EED_Ticket_Selector::ticketSelector()->formClose();
387
-    }
388
-
389
-
390
-
391
-    /**
392
-     * @deprecated
393
-     * @return string
394
-     */
395
-    public static function no_tkt_slctr_end_dv()
396
-    {
397
-        // todo add doing_it_wrong() notice during next major version
398
-        return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv();
399
-    }
400
-
401
-
402
-
403
-    /**
404
-     * @deprecated 4.9.13
405
-     * @return string
406
-     */
407
-    public static function tkt_slctr_end_dv()
408
-    {
409
-        return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
410
-    }
411
-
412
-
413
-
414
-    /**
415
-     * @deprecated
416
-     * @return string
417
-     */
418
-    public static function clear_tkt_slctr()
419
-    {
420
-        return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
421
-    }
422
-
423
-
424
-
425
-    /**
426
-     * @deprecated
427
-     */
428
-    public static function load_tckt_slctr_assets_admin()
429
-    {
430
-        // todo add doing_it_wrong() notice during next major version
431
-	    if (
432
-		    \EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events'
433
-		    && \EE_Registry::instance()->REQ->get( 'action' ) === 'edit'
434
-	    ) {
435
-		    $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
436
-            $iframe_embed_button->embedButtonAssets();
437
-        }
438
-    }
316
+	/**
317
+	 * @deprecated
318
+	 * @return string
319
+	 * @throws \EE_Error
320
+	 */
321
+	public static function display_view_details_btn()
322
+	{
323
+		// todo add doing_it_wrong() notice during next major version
324
+		return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton();
325
+	}
326
+
327
+
328
+
329
+	/**
330
+	 * @deprecated
331
+	 * @return string
332
+	 * @throws \EE_Error
333
+	 */
334
+	public static function display_ticket_selector_submit()
335
+	{
336
+		// todo add doing_it_wrong() notice during next major version
337
+		return EED_Ticket_Selector::ticketSelector()->displaySubmitButton();
338
+	}
339
+
340
+
341
+
342
+	/**
343
+	 * @deprecated
344
+	 * @param string $permalink_string
345
+	 * @param int    $id
346
+	 * @param string $new_title
347
+	 * @param string $new_slug
348
+	 * @return string
349
+	 */
350
+	public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '')
351
+	{
352
+		// todo add doing_it_wrong() notice during next major version
353
+		if (
354
+			\EE_Registry::instance()->REQ->get('page') === 'espresso_events'
355
+			&& \EE_Registry::instance()->REQ->get('action') === 'edit'
356
+		) {
357
+			$iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
358
+			$iframe_embed_button->addEventEditorIframeEmbedButton();
359
+		}
360
+		return '';
361
+	}
362
+
363
+
364
+
365
+	/**
366
+	 * @deprecated
367
+	 * @param int    $ID
368
+	 * @param string $external_url
369
+	 * @return string
370
+	 */
371
+	public static function ticket_selector_form_open($ID = 0, $external_url = '')
372
+	{
373
+		// todo add doing_it_wrong() notice during next major version
374
+		return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url);
375
+	}
376
+
377
+
378
+
379
+	/**
380
+	 * @deprecated
381
+	 * @return string
382
+	 */
383
+	public static function ticket_selector_form_close()
384
+	{
385
+		// todo add doing_it_wrong() notice during next major version
386
+		return EED_Ticket_Selector::ticketSelector()->formClose();
387
+	}
388
+
389
+
390
+
391
+	/**
392
+	 * @deprecated
393
+	 * @return string
394
+	 */
395
+	public static function no_tkt_slctr_end_dv()
396
+	{
397
+		// todo add doing_it_wrong() notice during next major version
398
+		return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv();
399
+	}
400
+
401
+
402
+
403
+	/**
404
+	 * @deprecated 4.9.13
405
+	 * @return string
406
+	 */
407
+	public static function tkt_slctr_end_dv()
408
+	{
409
+		return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
410
+	}
411
+
412
+
413
+
414
+	/**
415
+	 * @deprecated
416
+	 * @return string
417
+	 */
418
+	public static function clear_tkt_slctr()
419
+	{
420
+		return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
421
+	}
422
+
423
+
424
+
425
+	/**
426
+	 * @deprecated
427
+	 */
428
+	public static function load_tckt_slctr_assets_admin()
429
+	{
430
+		// todo add doing_it_wrong() notice during next major version
431
+		if (
432
+			\EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events'
433
+			&& \EE_Registry::instance()->REQ->get( 'action' ) === 'edit'
434
+		) {
435
+			$iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
436
+			$iframe_embed_button->embedButtonAssets();
437
+		}
438
+	}
439 439
 
440 440
 
441 441
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 use EventEspresso\modules\ticket_selector\TicketSelectorIframe;
4 4
 use EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton;
5 5
 
6
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
7
-	exit( 'No direct script access allowed' );
6
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7
+	exit('No direct script access allowed');
8 8
 }
9 9
 
10 10
 
@@ -38,15 +38,15 @@  discard block
 block discarded – undo
38 38
 	 * @return EED_Ticket_Selector
39 39
 	 */
40 40
 	public static function instance() {
41
-		return parent::get_instance( __CLASS__ );
41
+		return parent::get_instance(__CLASS__);
42 42
 	}
43 43
 
44 44
 
45 45
 
46
-	protected function set_config(){
47
-		$this->set_config_section( 'template_settings' );
48
-		$this->set_config_class( 'EE_Ticket_Selector_Config' );
49
-		$this->set_config_name( 'EED_Ticket_Selector' );
46
+	protected function set_config() {
47
+		$this->set_config_section('template_settings');
48
+		$this->set_config_class('EE_Ticket_Selector_Config');
49
+		$this->set_config_name('EED_Ticket_Selector');
50 50
 	}
51 51
 
52 52
 
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
 	 */
60 60
 	public static function set_hooks() {
61 61
 		// routing
62
-		EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' );
63
-		EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' );
62
+		EE_Config::register_route('iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector');
63
+		EE_Config::register_route('process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections');
64 64
         EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections');
65
-        add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 );
66
-		add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 );
67
-        add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'translate_js_strings' ), 0 );
68
-        add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 );
65
+        add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2);
66
+		add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1);
67
+        add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'translate_js_strings'), 0);
68
+        add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10);
69 69
         EED_Ticket_Selector::loadIframeAssets();
70 70
     }
71 71
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 		// to load assets for "espresso_events" page on the "edit" route (action)
83 83
 		add_action(
84 84
 			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__edit',
85
-			array( 'EED_Ticket_Selector', 'ticket_selector_iframe_embed_button' ),
85
+			array('EED_Ticket_Selector', 'ticket_selector_iframe_embed_button'),
86 86
 			10
87 87
 		);
88 88
 
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 	 *  @return 	void
107 107
 	 */
108 108
 	public static function set_definitions() {
109
-		define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
110
-		define( 'TICKET_SELECTOR_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS );
109
+		define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
110
+		define('TICKET_SELECTOR_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS);
111 111
 
112 112
 		//if config is not set, initialize
113
-		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) {
113
+		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) {
114 114
             \EED_Ticket_Selector::instance()->set_config();
115 115
             \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config();
116 116
 		}
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 * 	@param	WP $WP
138 138
 	 * 	@return void
139 139
 	 */
140
-	public function run( $WP ) {}
140
+	public function run($WP) {}
141 141
 
142 142
 
143 143
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @return \EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton
146 146
 	 */
147 147
 	public static function getIframeEmbedButton() {
148
-		if ( ! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton ) {
148
+		if ( ! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton) {
149 149
 			self::$iframe_embed_button = new TicketSelectorIframeEmbedButton();
150 150
 		}
151 151
 		return self::$iframe_embed_button;
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
      * @return    string
190 190
      * @throws \EE_Error
191 191
      */
192
-	public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) {
193
-		return EED_Ticket_Selector::ticketSelector()->display( $event, $view_details );
192
+	public static function display_ticket_selector($event = NULL, $view_details = FALSE) {
193
+		return EED_Ticket_Selector::ticketSelector()->display($event, $view_details);
194 194
 	}
195 195
 
196 196
 
@@ -241,14 +241,14 @@  discard block
 block discarded – undo
241 241
 	* 	@return 		void
242 242
 	*/
243 243
 	public static function load_tckt_slctr_assets() {
244
-		if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) {
244
+		if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE)) {
245 245
             // add some style
246
-			wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css');
246
+			wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css');
247 247
 			wp_enqueue_style('ticket_selector');
248 248
 			// make it dance
249
-			wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', array('espresso_core'), '', TRUE);
249
+			wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL.'ticket_selector.js', array('espresso_core'), '', TRUE);
250 250
 			wp_enqueue_script('ticket_selector');
251
-            require_once( EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php');
251
+            require_once(EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php');
252 252
             \EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
253 253
         }
254 254
 	}
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
      */
291 291
     public static function iframeCss(array $iframe_css)
292 292
     {
293
-        $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css';
293
+        $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css';
294 294
         return $iframe_css;
295 295
     }
296 296
 
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
      */
305 305
     public static function iframeJs(array $iframe_js)
306 306
     {
307
-        $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js';
307
+        $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL.'ticket_selector.js';
308 308
         return $iframe_js;
309 309
     }
310 310
 
@@ -429,8 +429,8 @@  discard block
 block discarded – undo
429 429
     {
430 430
         // todo add doing_it_wrong() notice during next major version
431 431
 	    if (
432
-		    \EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events'
433
-		    && \EE_Registry::instance()->REQ->get( 'action' ) === 'edit'
432
+		    \EE_Registry::instance()->REQ->get('page') === 'espresso_events'
433
+		    && \EE_Registry::instance()->REQ->get('action') === 'edit'
434 434
 	    ) {
435 435
 		    $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
436 436
             $iframe_embed_button->embedButtonAssets();
Please login to merge, or discard this patch.
core/services/database/TableManager.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -239,7 +239,7 @@
 block discarded – undo
239 239
 *@param string $table_name
240 240
      * @param string $index_name
241 241
      * @param string $column_name if none is provided, we assume the column name matches the index (often true in EE)
242
-     * @param string|int $desired_index_size defaults to 191, the max for utf8mb4.
242
+     * @param integer $desired_index_size defaults to 191, the max for utf8mb4.
243 243
      *                   See https://events.codebasehq.com/redirect?https://make.wordpress.org/core/2015/04/02/the-utf8mb4-upgrade/
244 244
      * @return bool
245 245
      * @throws /EE_Error if table analysis object isn't defined
Please login to merge, or discard this patch.
Indentation   +239 added lines, -241 removed lines patch added patch discarded remove patch
@@ -17,249 +17,247 @@
 block discarded – undo
17 17
 class TableManager extends \EE_Base
18 18
 {
19 19
 
20
-    /**
21
-     * @var TableAnalysis $table_analysis
22
-     */
23
-    private $table_analysis;
24
-
25
-
26
-
27
-    /**
28
-     * TableManager constructor.
29
-     *
30
-     * @param TableAnalysis $TableAnalysis
31
-     */
32
-    public function __construct(TableAnalysis $TableAnalysis)
33
-    {
34
-        $this->table_analysis = $TableAnalysis;
35
-    }
36
-
37
-
38
-
39
-    /**
40
-     * Gets the injected table analyzer, or throws an exception
41
-     *
42
-     * @return TableAnalysis
43
-     * @throws \EE_Error
44
-     */
45
-    protected function getTableAnalysis()
46
-    {
47
-        if ($this->table_analysis instanceof TableAnalysis) {
48
-            return $this->table_analysis;
49
-        } else {
50
-            throw new \EE_Error(
51
-                sprintf(
52
-                    __('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
53
-                    get_class($this)
54
-                )
55
-            );
56
-        }
57
-    }
58
-
59
-
60
-
61
-    /**
62
-     * @param string $table_name which can optionally start with $wpdb->prefix or not
63
-     * @param string $column_name
64
-     * @param string $column_info
65
-     * @return bool|false|int
66
-     */
67
-    public function addColumn($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL')
68
-    {
69
-        if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', false)) {
70
-            return false;
71
-        }
72
-        global $wpdb;
73
-        $full_table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
74
-        $columns = $this->getTableColumns($table_name);
75
-        if ( ! in_array($column_name, $columns)) {
76
-            $alter_query = "ALTER TABLE {$full_table_name} ADD {$column_name} {$column_info}";
77
-            return $wpdb->query($alter_query);
78
-        }
79
-        return true;
80
-    }
81
-
82
-
83
-
84
-    /**
85
-     * Gets the name of all columns on the  table. $table_name can
86
-     * optionally start with $wpdb->prefix or not
87
-     *
88
-     * @global \wpdb $wpdb
89
-     * @param string $table_name
90
-     * @return array
91
-     */
92
-    public function getTableColumns($table_name)
93
-    {
94
-        global $wpdb;
95
-        $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
96
-        $field_array = array();
97
-        if ( ! empty($table_name)) {
98
-            $columns = $wpdb->get_results("SHOW COLUMNS FROM {$table_name} ");
99
-            if ($columns !== false) {
100
-                foreach ($columns as $column) {
101
-                    $field_array[] = $column->Field;
102
-                }
103
-            }
104
-        }
105
-        return $field_array;
106
-    }
107
-
108
-
109
-
110
-    /**
111
-     * Drops the specified table from the database. $table_name can
112
-     * optionally start with $wpdb->prefix or not
113
-     *
114
-     * @global \wpdb $wpdb
115
-     * @param string $table_name
116
-     * @return int
117
-     */
118
-    public function dropTable($table_name)
119
-    {
120
-        global $wpdb;
121
-        if ($this->getTableAnalysis()->tableExists($table_name)) {
122
-            $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
123
-            return $wpdb->query("DROP TABLE IF EXISTS {$table_name}");
124
-        }
125
-        return 0;
126
-    }
127
-
128
-
129
-
130
-    /**
131
-     * Drops all the tables mentioned in a single MYSQL query. Double-checks
132
-     * each table name provided has a wpdb prefix attached, and that it exists.
133
-     * Returns the list actually deleted
134
-     *
135
-     * @global WPDB $wpdb
136
-     * @param array $table_names
137
-     * @return array of table names which we deleted
138
-     */
139
-    public function dropTables($table_names)
140
-    {
141
-        $tables_to_delete = array();
142
-        foreach ($table_names as $table_name) {
143
-            $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
144
-            if ($this->getTableAnalysis()->tableExists($table_name)) {
145
-                $tables_to_delete[] = $table_name;
146
-            }
147
-        }
148
-        if( ! empty( $tables_to_delete ) ) {
149
-            global $wpdb;
150
-            $wpdb->query('DROP TABLE ' . implode(', ', $tables_to_delete));
151
-        }
152
-        return $tables_to_delete;
153
-    }
154
-
155
-
156
-
157
-    /**
158
-     * Drops the specified index from the specified table. $table_name can
159
-     * optionally start with $wpdb->prefix or not
160
-
161
-     *
20
+	/**
21
+	 * @var TableAnalysis $table_analysis
22
+	 */
23
+	private $table_analysis;
24
+
25
+
26
+
27
+	/**
28
+	 * TableManager constructor.
29
+	 *
30
+	 * @param TableAnalysis $TableAnalysis
31
+	 */
32
+	public function __construct(TableAnalysis $TableAnalysis)
33
+	{
34
+		$this->table_analysis = $TableAnalysis;
35
+	}
36
+
37
+
38
+
39
+	/**
40
+	 * Gets the injected table analyzer, or throws an exception
41
+	 *
42
+	 * @return TableAnalysis
43
+	 * @throws \EE_Error
44
+	 */
45
+	protected function getTableAnalysis()
46
+	{
47
+		if ($this->table_analysis instanceof TableAnalysis) {
48
+			return $this->table_analysis;
49
+		} else {
50
+			throw new \EE_Error(
51
+				sprintf(
52
+					__('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
53
+					get_class($this)
54
+				)
55
+			);
56
+		}
57
+	}
58
+
59
+
60
+
61
+	/**
62
+	 * @param string $table_name which can optionally start with $wpdb->prefix or not
63
+	 * @param string $column_name
64
+	 * @param string $column_info
65
+	 * @return bool|false|int
66
+	 */
67
+	public function addColumn($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL')
68
+	{
69
+		if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', false)) {
70
+			return false;
71
+		}
72
+		global $wpdb;
73
+		$full_table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
74
+		$columns = $this->getTableColumns($table_name);
75
+		if ( ! in_array($column_name, $columns)) {
76
+			$alter_query = "ALTER TABLE {$full_table_name} ADD {$column_name} {$column_info}";
77
+			return $wpdb->query($alter_query);
78
+		}
79
+		return true;
80
+	}
81
+
82
+
83
+
84
+	/**
85
+	 * Gets the name of all columns on the  table. $table_name can
86
+	 * optionally start with $wpdb->prefix or not
87
+	 *
88
+	 * @global \wpdb $wpdb
89
+	 * @param string $table_name
90
+	 * @return array
91
+	 */
92
+	public function getTableColumns($table_name)
93
+	{
94
+		global $wpdb;
95
+		$table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
96
+		$field_array = array();
97
+		if ( ! empty($table_name)) {
98
+			$columns = $wpdb->get_results("SHOW COLUMNS FROM {$table_name} ");
99
+			if ($columns !== false) {
100
+				foreach ($columns as $column) {
101
+					$field_array[] = $column->Field;
102
+				}
103
+			}
104
+		}
105
+		return $field_array;
106
+	}
107
+
108
+
109
+
110
+	/**
111
+	 * Drops the specified table from the database. $table_name can
112
+	 * optionally start with $wpdb->prefix or not
113
+	 *
114
+	 * @global \wpdb $wpdb
115
+	 * @param string $table_name
116
+	 * @return int
117
+	 */
118
+	public function dropTable($table_name)
119
+	{
120
+		global $wpdb;
121
+		if ($this->getTableAnalysis()->tableExists($table_name)) {
122
+			$table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
123
+			return $wpdb->query("DROP TABLE IF EXISTS {$table_name}");
124
+		}
125
+		return 0;
126
+	}
127
+
128
+
129
+
130
+	/**
131
+	 * Drops all the tables mentioned in a single MYSQL query. Double-checks
132
+	 * each table name provided has a wpdb prefix attached, and that it exists.
133
+	 * Returns the list actually deleted
134
+	 *
135
+	 * @global WPDB $wpdb
136
+	 * @param array $table_names
137
+	 * @return array of table names which we deleted
138
+	 */
139
+	public function dropTables($table_names)
140
+	{
141
+		$tables_to_delete = array();
142
+		foreach ($table_names as $table_name) {
143
+			$table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
144
+			if ($this->getTableAnalysis()->tableExists($table_name)) {
145
+				$tables_to_delete[] = $table_name;
146
+			}
147
+		}
148
+		if( ! empty( $tables_to_delete ) ) {
149
+			global $wpdb;
150
+			$wpdb->query('DROP TABLE ' . implode(', ', $tables_to_delete));
151
+		}
152
+		return $tables_to_delete;
153
+	}
154
+
155
+
156
+
157
+	/**
158
+	 * Drops the specified index from the specified table. $table_name can
159
+	 * optionally start with $wpdb->prefix or not
160
+	 *
162 161
 *@global \wpdb       $wpdb
163
-     * @param string $table_name
164
-     * @param string $index_name
165
-     * @return int
166
-     */
167
-    public function dropIndex($table_name, $index_name)
168
-    {
169
-        if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', false)) {
170
-            return false;
171
-        }
172
-        global $wpdb;
173
-        $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
174
-        $index_exists_query = "SHOW INDEX FROM {$table_name} WHERE key_name = '{$index_name}'";
175
-        if (
176
-            $this->getTableAnalysis()->tableExists($table_name)
177
-            && $wpdb->get_var($index_exists_query)
178
-               === $table_name //using get_var with the $index_exists_query returns the table's name
179
-        ) {
180
-            return $wpdb->query("ALTER TABLE {$table_name} DROP INDEX {$index_name}");
181
-        }
182
-        return 0;
183
-    }
184
-
185
-
186
-
187
-    /**
188
-     * Just creates the requested table. $table_name can
189
-     * optionally start with $wpdb->prefix or not
190
-
191
-     *
162
+	 * @param string $table_name
163
+	 * @param string $index_name
164
+	 * @return int
165
+	 */
166
+	public function dropIndex($table_name, $index_name)
167
+	{
168
+		if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', false)) {
169
+			return false;
170
+		}
171
+		global $wpdb;
172
+		$table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
173
+		$index_exists_query = "SHOW INDEX FROM {$table_name} WHERE key_name = '{$index_name}'";
174
+		if (
175
+			$this->getTableAnalysis()->tableExists($table_name)
176
+			&& $wpdb->get_var($index_exists_query)
177
+			   === $table_name //using get_var with the $index_exists_query returns the table's name
178
+		) {
179
+			return $wpdb->query("ALTER TABLE {$table_name} DROP INDEX {$index_name}");
180
+		}
181
+		return 0;
182
+	}
183
+
184
+
185
+
186
+	/**
187
+	 * Just creates the requested table. $table_name can
188
+	 * optionally start with $wpdb->prefix or not
189
+	 *
192 190
 *@param string       $table_name
193
-     * @param string $create_sql defining the table's columns and indexes
194
-     * @param string $engine     (no need to specify "ENGINE=", that's implied)
195
-     * @return void
196
-     * @throws \EE_Error
197
-     */
198
-    public function createTable($table_name, $create_sql, $engine = 'MyISAM')
199
-    {
200
-        // does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns )
201
-        if (preg_match('((((.*?))(,\s))+)', $create_sql, $valid_column_data)) {
202
-            $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
203
-            /** @var \wpdb $wpdb */
204
-            global $wpdb;
205
-            $SQL = "CREATE TABLE {$table_name} ( {$create_sql} ) ENGINE={$engine} " . $wpdb->get_charset_collate();
206
-
207
-            //get $wpdb to echo errors, but buffer them. This way at least WE know an error
208
-            //happened. And then we can choose to tell the end user
209
-            $old_show_errors_policy = $wpdb->show_errors(true);
210
-            $old_error_suppression_policy = $wpdb->suppress_errors(false);
211
-            ob_start();
212
-            dbDelta($SQL);
213
-            $output = ob_get_contents();
214
-            ob_end_clean();
215
-            $wpdb->show_errors($old_show_errors_policy);
216
-            $wpdb->suppress_errors($old_error_suppression_policy);
217
-            if ( ! empty($output)) {
218
-                throw new \EE_Error($output);
219
-            }
220
-        } else {
221
-            throw new \EE_Error(
222
-                sprintf(
223
-                    __('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s',
224
-                        'event_espresso'),
225
-                    '<br />',
226
-                    $create_sql
227
-                )
228
-            );
229
-        }
230
-    }
231
-
232
-
233
-
234
-    /**
235
-     * Drops the specified index if it's size differs from $desired_index_size.
236
-     * WordPress' dbdelta method doesn't automatically change index sizes, so this
237
-     * method can be used to only drop the index if needed, and afterwards dbdelta can be used as normal.
238
-     *
191
+	 * @param string $create_sql defining the table's columns and indexes
192
+	 * @param string $engine     (no need to specify "ENGINE=", that's implied)
193
+	 * @return void
194
+	 * @throws \EE_Error
195
+	 */
196
+	public function createTable($table_name, $create_sql, $engine = 'MyISAM')
197
+	{
198
+		// does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns )
199
+		if (preg_match('((((.*?))(,\s))+)', $create_sql, $valid_column_data)) {
200
+			$table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
201
+			/** @var \wpdb $wpdb */
202
+			global $wpdb;
203
+			$SQL = "CREATE TABLE {$table_name} ( {$create_sql} ) ENGINE={$engine} " . $wpdb->get_charset_collate();
204
+
205
+			//get $wpdb to echo errors, but buffer them. This way at least WE know an error
206
+			//happened. And then we can choose to tell the end user
207
+			$old_show_errors_policy = $wpdb->show_errors(true);
208
+			$old_error_suppression_policy = $wpdb->suppress_errors(false);
209
+			ob_start();
210
+			dbDelta($SQL);
211
+			$output = ob_get_contents();
212
+			ob_end_clean();
213
+			$wpdb->show_errors($old_show_errors_policy);
214
+			$wpdb->suppress_errors($old_error_suppression_policy);
215
+			if ( ! empty($output)) {
216
+				throw new \EE_Error($output);
217
+			}
218
+		} else {
219
+			throw new \EE_Error(
220
+				sprintf(
221
+					__('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s',
222
+						'event_espresso'),
223
+					'<br />',
224
+					$create_sql
225
+				)
226
+			);
227
+		}
228
+	}
229
+
230
+
231
+
232
+	/**
233
+	 * Drops the specified index if it's size differs from $desired_index_size.
234
+	 * WordPress' dbdelta method doesn't automatically change index sizes, so this
235
+	 * method can be used to only drop the index if needed, and afterwards dbdelta can be used as normal.
236
+	 *
239 237
 *@param string $table_name
240
-     * @param string $index_name
241
-     * @param string $column_name if none is provided, we assume the column name matches the index (often true in EE)
242
-     * @param string|int $desired_index_size defaults to 191, the max for utf8mb4.
243
-     *                   See https://events.codebasehq.com/redirect?https://make.wordpress.org/core/2015/04/02/the-utf8mb4-upgrade/
244
-     * @return bool
245
-     * @throws /EE_Error if table analysis object isn't defined
246
-     */
247
-    public function dropIndexIfSizeNot($table_name, $index_name, $column_name = null, $desired_index_size = 191)
248
-    {
249
-        if($column_name === null){
250
-            $column_name = $index_name;
251
-        }
252
-        $index_entries = $this->getTableAnalysis()->showIndexes($table_name,$index_name);
253
-        if(empty($index_entries)){
254
-            return false;
255
-        }
256
-        foreach($index_entries as $index_entry){
257
-            if( $column_name === $index_entry->Column_name
258
-                && (string)$desired_index_size !== $index_entry->Sub_part){
259
-                return $this->dropIndex($table_name,$index_name);
260
-            }
261
-        }
262
-        return false;
263
-    }
238
+	 * @param string $index_name
239
+	 * @param string $column_name if none is provided, we assume the column name matches the index (often true in EE)
240
+	 * @param string|int $desired_index_size defaults to 191, the max for utf8mb4.
241
+	 *                   See https://events.codebasehq.com/redirect?https://make.wordpress.org/core/2015/04/02/the-utf8mb4-upgrade/
242
+	 * @return bool
243
+	 * @throws /EE_Error if table analysis object isn't defined
244
+	 */
245
+	public function dropIndexIfSizeNot($table_name, $index_name, $column_name = null, $desired_index_size = 191)
246
+	{
247
+		if($column_name === null){
248
+			$column_name = $index_name;
249
+		}
250
+		$index_entries = $this->getTableAnalysis()->showIndexes($table_name,$index_name);
251
+		if(empty($index_entries)){
252
+			return false;
253
+		}
254
+		foreach($index_entries as $index_entry){
255
+			if( $column_name === $index_entry->Column_name
256
+				&& (string)$desired_index_size !== $index_entry->Sub_part){
257
+				return $this->dropIndex($table_name,$index_name);
258
+			}
259
+		}
260
+		return false;
261
+	}
264 262
 
265 263
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
                 $tables_to_delete[] = $table_name;
146 146
             }
147 147
         }
148
-        if( ! empty( $tables_to_delete ) ) {
148
+        if ( ! empty($tables_to_delete)) {
149 149
             global $wpdb;
150
-            $wpdb->query('DROP TABLE ' . implode(', ', $tables_to_delete));
150
+            $wpdb->query('DROP TABLE '.implode(', ', $tables_to_delete));
151 151
         }
152 152
         return $tables_to_delete;
153 153
     }
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
             $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
203 203
             /** @var \wpdb $wpdb */
204 204
             global $wpdb;
205
-            $SQL = "CREATE TABLE {$table_name} ( {$create_sql} ) ENGINE={$engine} " . $wpdb->get_charset_collate();
205
+            $SQL = "CREATE TABLE {$table_name} ( {$create_sql} ) ENGINE={$engine} ".$wpdb->get_charset_collate();
206 206
 
207 207
             //get $wpdb to echo errors, but buffer them. This way at least WE know an error
208 208
             //happened. And then we can choose to tell the end user
@@ -246,17 +246,17 @@  discard block
 block discarded – undo
246 246
      */
247 247
     public function dropIndexIfSizeNot($table_name, $index_name, $column_name = null, $desired_index_size = 191)
248 248
     {
249
-        if($column_name === null){
249
+        if ($column_name === null) {
250 250
             $column_name = $index_name;
251 251
         }
252
-        $index_entries = $this->getTableAnalysis()->showIndexes($table_name,$index_name);
253
-        if(empty($index_entries)){
252
+        $index_entries = $this->getTableAnalysis()->showIndexes($table_name, $index_name);
253
+        if (empty($index_entries)) {
254 254
             return false;
255 255
         }
256
-        foreach($index_entries as $index_entry){
257
-            if( $column_name === $index_entry->Column_name
258
-                && (string)$desired_index_size !== $index_entry->Sub_part){
259
-                return $this->dropIndex($table_name,$index_name);
256
+        foreach ($index_entries as $index_entry) {
257
+            if ($column_name === $index_entry->Column_name
258
+                && (string) $desired_index_size !== $index_entry->Sub_part) {
259
+                return $this->dropIndex($table_name, $index_name);
260 260
             }
261 261
         }
262 262
         return false;
Please login to merge, or discard this patch.
caffeinated/EE_Caf_Messages.class.php 2 patches
Indentation   +708 added lines, -708 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,729 +22,729 @@  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
-    /**
440
-     * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter).
441
-     *
442
-     * @param string         $parsed           The original parsed content for the shortcode
443
-     * @param string         $shortcode        The shortcode being parsed
444
-     * @param array          $data             The shortcode parser data array
445
-     * @param array          $extra_data       The shortcode parser extra data array
446
-     * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
447
-     *
448
-     * @return string
449
-     */
450
-    public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
451
-    {
452
-        
453
-        if (array($data) && ! isset($data['data'])) {
454
-            return $parsed;
455
-        }
456
-        
457
-        $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
458
-        $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
459
-        
460
-        if ( ! $recipient instanceof EE_Messages_Addressee) {
461
-            return $parsed;
462
-        }
463
-        
464
-        switch ($shortcode) {
465
-            case '[RECIPIENT_QUESTION_LIST]' :
466
-                $att                       = $recipient->att_obj;
467
-                $registrations_on_attendee = $att instanceof EE_Attendee ? $recipient->attendees[$att->ID()]['reg_objs'] : array();
468
-                $registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee;
469
-                $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
+	/**
440
+	 * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter).
441
+	 *
442
+	 * @param string         $parsed           The original parsed content for the shortcode
443
+	 * @param string         $shortcode        The shortcode being parsed
444
+	 * @param array          $data             The shortcode parser data array
445
+	 * @param array          $extra_data       The shortcode parser extra data array
446
+	 * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
447
+	 *
448
+	 * @return string
449
+	 */
450
+	public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
451
+	{
452
+        
453
+		if (array($data) && ! isset($data['data'])) {
454
+			return $parsed;
455
+		}
456
+        
457
+		$recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
458
+		$recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
459
+        
460
+		if ( ! $recipient instanceof EE_Messages_Addressee) {
461
+			return $parsed;
462
+		}
463
+        
464
+		switch ($shortcode) {
465
+			case '[RECIPIENT_QUESTION_LIST]' :
466
+				$att                       = $recipient->att_obj;
467
+				$registrations_on_attendee = $att instanceof EE_Attendee ? $recipient->attendees[$att->ID()]['reg_objs'] : array();
468
+				$registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee;
469
+				$answers                   = array();
470 470
                 
471
-                $template         = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list'];
472
-                $valid_shortcodes = array('question');
471
+				$template         = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list'];
472
+				$valid_shortcodes = array('question');
473 473
                 
474
-                //if the context is main_content then get all answers for all registrations on this attendee
475
-                if ($data['data'] instanceof EE_Messages_Addressee) {
474
+				//if the context is main_content then get all answers for all registrations on this attendee
475
+				if ($data['data'] instanceof EE_Messages_Addressee) {
476 476
                     
477
-                    foreach ($registrations_on_attendee as $reg) {
478
-                        if ($reg instanceof EE_Registration) {
479
-                            $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array();
480
-                            foreach ($anss as $ans) {
481
-                                if ($ans instanceof EE_Answer) {
482
-                                    $answers[$ans->ID()] = $ans;
483
-                                }
484
-                            }
485
-                        }
486
-                    }
487
-                }
477
+					foreach ($registrations_on_attendee as $reg) {
478
+						if ($reg instanceof EE_Registration) {
479
+							$anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array();
480
+							foreach ($anss as $ans) {
481
+								if ($ans instanceof EE_Answer) {
482
+									$answers[$ans->ID()] = $ans;
483
+								}
484
+							}
485
+						}
486
+					}
487
+				}
488 488
                 
489
-                //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.
490
-                if ($data['data'] instanceof EE_Event) {
491
-                    $event = $data['data'];
492
-                    foreach ($registrations_on_attendee as $reg) {
493
-                        if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
494
-                            $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array();
495
-                            foreach ($anss as $ans) {
496
-                                if ($ans instanceof EE_Answer) {
497
-                                    $answers[$ans->ID()] = $ans;
498
-                                }
499
-                            }
500
-                        }
501
-                    }
502
-                }
489
+				//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.
490
+				if ($data['data'] instanceof EE_Event) {
491
+					$event = $data['data'];
492
+					foreach ($registrations_on_attendee as $reg) {
493
+						if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
494
+							$anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array();
495
+							foreach ($anss as $ans) {
496
+								if ($ans instanceof EE_Answer) {
497
+									$answers[$ans->ID()] = $ans;
498
+								}
499
+							}
500
+						}
501
+					}
502
+				}
503 503
                 
504
-                $questions = $questions = isset($recipient->questions) ? $recipient->questions : array();
504
+				$questions = $questions = isset($recipient->questions) ? $recipient->questions : array();
505 505
                 
506
-                //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
507
-                //object on it.
508
-                if ( ! isset( $extra_data['data'] ) ) {
509
-                    $extra_data['data'] = $recipient;
510
-                }
506
+				//if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
507
+				//object on it.
508
+				if ( ! isset( $extra_data['data'] ) ) {
509
+					$extra_data['data'] = $recipient;
510
+				}
511 511
                 
512
-                return $this->_parse_question_list_for_primary_or_recipient_registration(
513
-                    $shortcode_parser,
514
-                    $questions,
515
-                    $answers,
516
-                    $template,
517
-                    $valid_shortcodes,
518
-                    $extra_data
519
-                );
520
-                break;
512
+				return $this->_parse_question_list_for_primary_or_recipient_registration(
513
+					$shortcode_parser,
514
+					$questions,
515
+					$answers,
516
+					$template,
517
+					$valid_shortcodes,
518
+					$extra_data
519
+				);
520
+				break;
521 521
             
522
-            default :
523
-                return $parsed;
524
-                break;
525
-        }
526
-    }
527
-    
528
-    
529
-    public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser)
530
-    {
531
-        $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',
532
-            'event_espresso');
533
-        
534
-        return $shortcodes;
535
-    }
536
-    
537
-    
538
-    /**
539
-     * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter).
540
-     *
541
-     * @param string         $parsed           The original parsed content for the shortcode
542
-     * @param string         $shortcode        The shortcode being parsed
543
-     * @param array          $data             The shortcode parser data array
544
-     * @param array          $extra_data       The shortcode parser extra data array
545
-     * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
546
-     *
547
-     * @return string
548
-     */
549
-    public function additional_primary_registration_details_parser(
550
-        $parsed,
551
-        $shortcode,
552
-        $data,
553
-        $extra_data,
554
-        $shortcode_parser
555
-    ) {
556
-        if (array($data) && ! isset($data['data'])) {
557
-            return $parsed;
558
-        }
559
-        
560
-        $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
561
-        $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
562
-        
563
-        if ( ! $recipient instanceof EE_Messages_Addressee) {
564
-            return $parsed;
565
-        }
566
-        
567
-        switch ($shortcode) {
568
-            case '[PRIMARY_REGISTRANT_QUESTION_LIST]' :
569
-                if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
570
-                    return '';
571
-                }
572
-                $registration     = $recipient->primary_reg_obj;
573
-                $template         = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list'];
574
-                $valid_shortcodes = array('question');
575
-                $answers          = $recipient->registrations[$registration->ID()]['ans_objs'];
576
-                $questions = isset($recipient->questions) ? $recipient->questions : array();
577
-                //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
578
-                //object on it.
579
-                if ( ! isset( $extra_data['data'] ) ){
580
-                    $extra_data['data'] = $recipient;
581
-                }
582
-                return $this->_parse_question_list_for_primary_or_recipient_registration(
583
-                    $shortcode_parser,
584
-                    $questions,
585
-                    $answers,
586
-                    $template,
587
-                    $valid_shortcodes,
588
-                    $extra_data
589
-                );
590
-                break;
522
+			default :
523
+				return $parsed;
524
+				break;
525
+		}
526
+	}
527
+    
528
+    
529
+	public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser)
530
+	{
531
+		$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',
532
+			'event_espresso');
533
+        
534
+		return $shortcodes;
535
+	}
536
+    
537
+    
538
+	/**
539
+	 * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter).
540
+	 *
541
+	 * @param string         $parsed           The original parsed content for the shortcode
542
+	 * @param string         $shortcode        The shortcode being parsed
543
+	 * @param array          $data             The shortcode parser data array
544
+	 * @param array          $extra_data       The shortcode parser extra data array
545
+	 * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
546
+	 *
547
+	 * @return string
548
+	 */
549
+	public function additional_primary_registration_details_parser(
550
+		$parsed,
551
+		$shortcode,
552
+		$data,
553
+		$extra_data,
554
+		$shortcode_parser
555
+	) {
556
+		if (array($data) && ! isset($data['data'])) {
557
+			return $parsed;
558
+		}
559
+        
560
+		$recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
561
+		$recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
562
+        
563
+		if ( ! $recipient instanceof EE_Messages_Addressee) {
564
+			return $parsed;
565
+		}
566
+        
567
+		switch ($shortcode) {
568
+			case '[PRIMARY_REGISTRANT_QUESTION_LIST]' :
569
+				if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
570
+					return '';
571
+				}
572
+				$registration     = $recipient->primary_reg_obj;
573
+				$template         = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list'];
574
+				$valid_shortcodes = array('question');
575
+				$answers          = $recipient->registrations[$registration->ID()]['ans_objs'];
576
+				$questions = isset($recipient->questions) ? $recipient->questions : array();
577
+				//if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
578
+				//object on it.
579
+				if ( ! isset( $extra_data['data'] ) ){
580
+					$extra_data['data'] = $recipient;
581
+				}
582
+				return $this->_parse_question_list_for_primary_or_recipient_registration(
583
+					$shortcode_parser,
584
+					$questions,
585
+					$answers,
586
+					$template,
587
+					$valid_shortcodes,
588
+					$extra_data
589
+				);
590
+				break;
591 591
             
592
-            default :
593
-                return $parsed;
594
-                break;
595
-        }
596
-    }
597
-    
598
-    
599
-    /**
600
-     * Takes care of registering the  message types that are only available in caffeinated EE.
601
-     *
602
-     * @since   4.3.2
603
-     *
604
-     * @return  void
605
-     */
606
-    public function register_caf_message_types()
607
-    {
608
-        //register newsletter message type
609
-        $setup_args = array(
610
-            'mtfilename'                  => 'EE_Newsletter_message_type.class.php',
611
-            'autoloadpaths'               => array(
612
-                EE_CAF_LIBRARIES . 'messages/message_type/newsletter/'
613
-            ),
614
-            'messengers_to_activate_with' => array('email'),
615
-            'messengers_to_validate_with' => array('email'),
616
-            'messengers_supporting_default_template_pack_with' => array('email')
617
-        );
618
-        EE_Register_Message_Type::register('newsletter', $setup_args);
619
-        
620
-        //register payment reminder message type
621
-        $setup_args = array(
622
-            'mtfilename'                  => 'EE_Payment_Reminder_message_type.class.php',
623
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
624
-            'messengers_to_activate_with' => array('email'),
625
-            'messengers_to_validate_with' => array('email'),
626
-            'messengers_supporting_default_template_pack_with' => array('email')
627
-        );
628
-        EE_Register_Message_Type::register('payment_reminder', $setup_args);
629
-        
630
-        //register payment declined message type
631
-        $setup_args = array(
632
-            'mtfilename'                  => 'EE_Payment_Declined_message_type.class.php',
633
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
634
-            'messengers_to_activate_with' => array('email'),
635
-            'messengers_to_validate_with' => array('email'),
636
-            'messengers_supporting_default_template_pack_with' => array('email')
637
-        );
638
-        EE_Register_Message_Type::register('payment_declined', $setup_args);
639
-        
640
-        //register registration declined message type
641
-        $setup_args = array(
642
-            'mtfilename'                  => 'EE_Declined_Registration_message_type.class.php',
643
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
644
-            'messengers_to_activate_with' => array('email'),
645
-            'messengers_to_validate_with' => array('email'),
646
-            'messengers_supporting_default_template_pack_with' => array('email')
647
-        );
648
-        EE_Register_Message_Type::register('declined_registration', $setup_args);
649
-        
650
-        //register registration cancelled message type
651
-        $setup_args = array(
652
-            'mtfilename'                  => 'EE_Cancelled_Registration_message_type.class.php',
653
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
654
-            'messengers_to_activate_with' => array('email'),
655
-            'messengers_to_validate_with' => array('email'),
656
-            'messengers_supporting_default_template_pack_with' => array('email')
657
-        );
658
-        EE_Register_Message_Type::register('cancelled_registration', $setup_args);
659
-        
660
-        
661
-        //register payment failed message type
662
-        $setup_args = array(
663
-            'mtfilename'                  => 'EE_Payment_Failed_message_type.class.php',
664
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
665
-            'messengers_to_activate_with' => array('email'),
666
-            'messengers_to_validate_with' => array('email'),
667
-            'messengers_supporting_default_template_pack_with' => array('email')
668
-        );
669
-        EE_Register_Message_Type::register('payment_failed', $setup_args);
670
-        
671
-        //register payment declined message type
672
-        $setup_args = array(
673
-            'mtfilename'                  => 'EE_Payment_Cancelled_message_type.class.php',
674
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
675
-            'messengers_to_activate_with' => array('email'),
676
-            'messengers_to_validate_with' => array('email'),
677
-            'messengers_supporting_default_template_pack_with' => array('email')
678
-        );
679
-        EE_Register_Message_Type::register('payment_cancelled', $setup_args);
680
-    }
681
-    
682
-    
683
-    /**
684
-     * Takes care of registering the  shortcode libraries implemented with caffeinated EE and set up related items.
685
-     *
686
-     * @since   4.3.2
687
-     *
688
-     * @return void
689
-     */
690
-    public function register_caf_shortcodes()
691
-    {
692
-        $setup_args = array(
693
-            'autoloadpaths'                 => array(
694
-                EE_CAF_LIBRARIES . 'shortcodes/'
695
-            ),
696
-            'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
697
-            'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
698
-            'list_type_shortcodes'          => array('[NEWSLETTER_CONTENT]')
699
-        );
700
-        EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args);
701
-    }
702
-    
703
-    
704
-    /**
705
-     * Parses a question list shortcode using given data and template
706
-     *
707
-     * @param \EE_Shortcodes $shortcode_parser
708
-     * @param EE_Question[]  $questions        An array of questions indexed by answer id.
709
-     * @param EE_Answer[]    $answers          An array of answer objects
710
-     * @param string         $template         Template content to be parsed.
711
-     * @param array          $valid_shortcodes Valid shortcodes for the template being parsed.
712
-     * @param array          $extra_data       Extra data that might be used when parsing the template.
713
-     */
714
-    protected function _parse_question_list_for_primary_or_recipient_registration(
715
-        $shortcode_parser,
716
-        $questions,
717
-        $answers,
718
-        $template,
719
-        $valid_shortcodes,
720
-        $extra_data
721
-    ) {
722
-        $question_list = '';
723
-        /** @var EEH_Parse_Shortcodes $shortcode_helper */
724
-        $shortcode_helper = $shortcode_parser->get_shortcode_helper();
725
-        foreach ($answers as $answer) {
726
-            if ($answer instanceof EE_Answer) {
727
-                //first see if the question is in our $questions array. If not then try to get from answer object.
728
-                $question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null;
729
-                $question = ! $question instanceof EE_Question ? $answer->question() : $question;
730
-                if (
731
-                    ! $question instanceof EE_Question
732
-                    || (
733
-                        $question instanceof EE_Question
734
-                        && $question->admin_only()
735
-                    )
736
-                ) {
737
-                    continue;
738
-                }
739
-                $question_list .= $shortcode_helper->parse_question_list_template(
740
-                    $template,
741
-                    $answer,
742
-                    $valid_shortcodes,
743
-                    $extra_data
744
-                );
745
-            }
746
-        }
747
-        
748
-        return $question_list;
749
-    }
592
+			default :
593
+				return $parsed;
594
+				break;
595
+		}
596
+	}
597
+    
598
+    
599
+	/**
600
+	 * Takes care of registering the  message types that are only available in caffeinated EE.
601
+	 *
602
+	 * @since   4.3.2
603
+	 *
604
+	 * @return  void
605
+	 */
606
+	public function register_caf_message_types()
607
+	{
608
+		//register newsletter message type
609
+		$setup_args = array(
610
+			'mtfilename'                  => 'EE_Newsletter_message_type.class.php',
611
+			'autoloadpaths'               => array(
612
+				EE_CAF_LIBRARIES . 'messages/message_type/newsletter/'
613
+			),
614
+			'messengers_to_activate_with' => array('email'),
615
+			'messengers_to_validate_with' => array('email'),
616
+			'messengers_supporting_default_template_pack_with' => array('email')
617
+		);
618
+		EE_Register_Message_Type::register('newsletter', $setup_args);
619
+        
620
+		//register payment reminder message type
621
+		$setup_args = array(
622
+			'mtfilename'                  => 'EE_Payment_Reminder_message_type.class.php',
623
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
624
+			'messengers_to_activate_with' => array('email'),
625
+			'messengers_to_validate_with' => array('email'),
626
+			'messengers_supporting_default_template_pack_with' => array('email')
627
+		);
628
+		EE_Register_Message_Type::register('payment_reminder', $setup_args);
629
+        
630
+		//register payment declined message type
631
+		$setup_args = array(
632
+			'mtfilename'                  => 'EE_Payment_Declined_message_type.class.php',
633
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
634
+			'messengers_to_activate_with' => array('email'),
635
+			'messengers_to_validate_with' => array('email'),
636
+			'messengers_supporting_default_template_pack_with' => array('email')
637
+		);
638
+		EE_Register_Message_Type::register('payment_declined', $setup_args);
639
+        
640
+		//register registration declined message type
641
+		$setup_args = array(
642
+			'mtfilename'                  => 'EE_Declined_Registration_message_type.class.php',
643
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
644
+			'messengers_to_activate_with' => array('email'),
645
+			'messengers_to_validate_with' => array('email'),
646
+			'messengers_supporting_default_template_pack_with' => array('email')
647
+		);
648
+		EE_Register_Message_Type::register('declined_registration', $setup_args);
649
+        
650
+		//register registration cancelled message type
651
+		$setup_args = array(
652
+			'mtfilename'                  => 'EE_Cancelled_Registration_message_type.class.php',
653
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
654
+			'messengers_to_activate_with' => array('email'),
655
+			'messengers_to_validate_with' => array('email'),
656
+			'messengers_supporting_default_template_pack_with' => array('email')
657
+		);
658
+		EE_Register_Message_Type::register('cancelled_registration', $setup_args);
659
+        
660
+        
661
+		//register payment failed message type
662
+		$setup_args = array(
663
+			'mtfilename'                  => 'EE_Payment_Failed_message_type.class.php',
664
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
665
+			'messengers_to_activate_with' => array('email'),
666
+			'messengers_to_validate_with' => array('email'),
667
+			'messengers_supporting_default_template_pack_with' => array('email')
668
+		);
669
+		EE_Register_Message_Type::register('payment_failed', $setup_args);
670
+        
671
+		//register payment declined message type
672
+		$setup_args = array(
673
+			'mtfilename'                  => 'EE_Payment_Cancelled_message_type.class.php',
674
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
675
+			'messengers_to_activate_with' => array('email'),
676
+			'messengers_to_validate_with' => array('email'),
677
+			'messengers_supporting_default_template_pack_with' => array('email')
678
+		);
679
+		EE_Register_Message_Type::register('payment_cancelled', $setup_args);
680
+	}
681
+    
682
+    
683
+	/**
684
+	 * Takes care of registering the  shortcode libraries implemented with caffeinated EE and set up related items.
685
+	 *
686
+	 * @since   4.3.2
687
+	 *
688
+	 * @return void
689
+	 */
690
+	public function register_caf_shortcodes()
691
+	{
692
+		$setup_args = array(
693
+			'autoloadpaths'                 => array(
694
+				EE_CAF_LIBRARIES . 'shortcodes/'
695
+			),
696
+			'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
697
+			'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
698
+			'list_type_shortcodes'          => array('[NEWSLETTER_CONTENT]')
699
+		);
700
+		EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args);
701
+	}
702
+    
703
+    
704
+	/**
705
+	 * Parses a question list shortcode using given data and template
706
+	 *
707
+	 * @param \EE_Shortcodes $shortcode_parser
708
+	 * @param EE_Question[]  $questions        An array of questions indexed by answer id.
709
+	 * @param EE_Answer[]    $answers          An array of answer objects
710
+	 * @param string         $template         Template content to be parsed.
711
+	 * @param array          $valid_shortcodes Valid shortcodes for the template being parsed.
712
+	 * @param array          $extra_data       Extra data that might be used when parsing the template.
713
+	 */
714
+	protected function _parse_question_list_for_primary_or_recipient_registration(
715
+		$shortcode_parser,
716
+		$questions,
717
+		$answers,
718
+		$template,
719
+		$valid_shortcodes,
720
+		$extra_data
721
+	) {
722
+		$question_list = '';
723
+		/** @var EEH_Parse_Shortcodes $shortcode_helper */
724
+		$shortcode_helper = $shortcode_parser->get_shortcode_helper();
725
+		foreach ($answers as $answer) {
726
+			if ($answer instanceof EE_Answer) {
727
+				//first see if the question is in our $questions array. If not then try to get from answer object.
728
+				$question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null;
729
+				$question = ! $question instanceof EE_Question ? $answer->question() : $question;
730
+				if (
731
+					! $question instanceof EE_Question
732
+					|| (
733
+						$question instanceof EE_Question
734
+						&& $question->admin_only()
735
+					)
736
+				) {
737
+					continue;
738
+				}
739
+				$question_list .= $shortcode_helper->parse_question_list_template(
740
+					$template,
741
+					$answer,
742
+					$valid_shortcodes,
743
+					$extra_data
744
+				);
745
+			}
746
+		}
747
+        
748
+		return $question_list;
749
+	}
750 750
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 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
             }
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
                 
506 506
                 //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
507 507
                 //object on it.
508
-                if ( ! isset( $extra_data['data'] ) ) {
508
+                if ( ! isset($extra_data['data'])) {
509 509
                     $extra_data['data'] = $recipient;
510 510
                 }
511 511
                 
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
                 $questions = isset($recipient->questions) ? $recipient->questions : array();
577 577
                 //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
578 578
                 //object on it.
579
-                if ( ! isset( $extra_data['data'] ) ){
579
+                if ( ! isset($extra_data['data'])) {
580 580
                     $extra_data['data'] = $recipient;
581 581
                 }
582 582
                 return $this->_parse_question_list_for_primary_or_recipient_registration(
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
         $setup_args = array(
610 610
             'mtfilename'                  => 'EE_Newsletter_message_type.class.php',
611 611
             'autoloadpaths'               => array(
612
-                EE_CAF_LIBRARIES . 'messages/message_type/newsletter/'
612
+                EE_CAF_LIBRARIES.'messages/message_type/newsletter/'
613 613
             ),
614 614
             'messengers_to_activate_with' => array('email'),
615 615
             'messengers_to_validate_with' => array('email'),
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
         //register payment reminder message type
621 621
         $setup_args = array(
622 622
             'mtfilename'                  => 'EE_Payment_Reminder_message_type.class.php',
623
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
623
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/payment_reminder/'),
624 624
             'messengers_to_activate_with' => array('email'),
625 625
             'messengers_to_validate_with' => array('email'),
626 626
             'messengers_supporting_default_template_pack_with' => array('email')
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
         //register payment declined message type
631 631
         $setup_args = array(
632 632
             'mtfilename'                  => 'EE_Payment_Declined_message_type.class.php',
633
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
633
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/payment_declined/'),
634 634
             'messengers_to_activate_with' => array('email'),
635 635
             'messengers_to_validate_with' => array('email'),
636 636
             'messengers_supporting_default_template_pack_with' => array('email')
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
         //register registration declined message type
641 641
         $setup_args = array(
642 642
             'mtfilename'                  => 'EE_Declined_Registration_message_type.class.php',
643
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
643
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/declined_registration/'),
644 644
             'messengers_to_activate_with' => array('email'),
645 645
             'messengers_to_validate_with' => array('email'),
646 646
             'messengers_supporting_default_template_pack_with' => array('email')
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
         //register registration cancelled message type
651 651
         $setup_args = array(
652 652
             'mtfilename'                  => 'EE_Cancelled_Registration_message_type.class.php',
653
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
653
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/cancelled_registration/'),
654 654
             'messengers_to_activate_with' => array('email'),
655 655
             'messengers_to_validate_with' => array('email'),
656 656
             'messengers_supporting_default_template_pack_with' => array('email')
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
         //register payment failed message type
662 662
         $setup_args = array(
663 663
             'mtfilename'                  => 'EE_Payment_Failed_message_type.class.php',
664
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
664
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/payment_failed/'),
665 665
             'messengers_to_activate_with' => array('email'),
666 666
             'messengers_to_validate_with' => array('email'),
667 667
             'messengers_supporting_default_template_pack_with' => array('email')
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
         //register payment declined message type
672 672
         $setup_args = array(
673 673
             'mtfilename'                  => 'EE_Payment_Cancelled_message_type.class.php',
674
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
674
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/payment_cancelled/'),
675 675
             'messengers_to_activate_with' => array('email'),
676 676
             'messengers_to_validate_with' => array('email'),
677 677
             'messengers_supporting_default_template_pack_with' => array('email')
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
     {
692 692
         $setup_args = array(
693 693
             'autoloadpaths'                 => array(
694
-                EE_CAF_LIBRARIES . 'shortcodes/'
694
+                EE_CAF_LIBRARIES.'shortcodes/'
695 695
             ),
696 696
             'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
697 697
             'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
Please login to merge, or discard this patch.
core/db_models/EEM_Attendee.model.php 2 patches
Indentation   +316 added lines, -316 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,329 +15,329 @@  discard block
 block discarded – undo
15 15
 class EEM_Attendee extends EEM_CPT_Base
16 16
 {
17 17
 
18
-    // private instance of the Attendee object
19
-    protected static $_instance = null;
18
+	// private instance of the Attendee object
19
+	protected static $_instance = null;
20 20
 
21
-    /**
22
-     * QST_system for questions are strings not ints now,
23
-     * so these constants are deprecated.
24
-     * Please instead use the EEM_Attendee::system_question_* constants
25
-     *
26
-     * @deprecated
27
-     */
28
-    const fname_question_id = 1;
21
+	/**
22
+	 * QST_system for questions are strings not ints now,
23
+	 * so these constants are deprecated.
24
+	 * Please instead use the EEM_Attendee::system_question_* constants
25
+	 *
26
+	 * @deprecated
27
+	 */
28
+	const fname_question_id = 1;
29 29
 
30
-    /**
31
-     * @deprecated
32
-     */
33
-    const lname_question_id = 2;
30
+	/**
31
+	 * @deprecated
32
+	 */
33
+	const lname_question_id = 2;
34 34
 
35 35
 
36
-    /**
37
-     * @deprecated
38
-     */
39
-    const email_question_id = 3;
36
+	/**
37
+	 * @deprecated
38
+	 */
39
+	const email_question_id = 3;
40 40
 
41 41
 
42
-    /**
43
-     * @deprecated
44
-     */
45
-    const address_question_id = 4;
42
+	/**
43
+	 * @deprecated
44
+	 */
45
+	const address_question_id = 4;
46 46
 
47 47
 
48
-    /**
49
-     * @deprecated
50
-     */
51
-    const address2_question_id = 5;
52
-
53
-
54
-    /**
55
-     * @deprecated
56
-     */
57
-    const city_question_id = 6;
58
-
59
-
60
-    /**
61
-     * @deprecated
62
-     */
63
-    const state_question_id = 7;
64
-
65
-
66
-    /**
67
-     * @deprecated
68
-     */
69
-    const country_question_id = 8;
70
-
71
-
72
-    /**
73
-     * @deprecated
74
-     */
75
-    const zip_question_id = 9;
76
-
77
-
78
-    /**
79
-     * @deprecated
80
-     */
81
-    const phone_question_id = 10;
82
-
83
-    /**
84
-     * When looking for questions that correspond to attendee fields,
85
-     * look for the question with this QST_system value.
86
-     * These replace the old constants like EEM_Attendee::*_question_id
87
-     */
88
-    const system_question_fname    = 'fname';
89
-
90
-    const system_question_lname    = 'lname';
91
-
92
-    const system_question_email    = 'email';
93
-
94
-    const system_question_address  = 'address';
95
-
96
-    const system_question_address2 = 'address2';
97
-
98
-    const system_question_city     = 'city';
99
-
100
-    const system_question_state    = 'state';
101
-
102
-    const system_question_country  = 'country';
103
-
104
-    const system_question_zip      = 'zip';
105
-
106
-    const system_question_phone    = 'phone';
107
-
108
-    /**
109
-     * Keys are all the EEM_Attendee::system_question_* constants, which are
110
-     * also all the values of QST_system in the questions table, and values
111
-     * are their corresponding Attendee field names
112
-     *
113
-     * @var array
114
-     */
115
-    protected $_system_question_to_attendee_field_name = array(
116
-        EEM_Attendee::system_question_fname    => 'ATT_fname',
117
-        EEM_Attendee::system_question_lname    => 'ATT_lname',
118
-        EEM_Attendee::system_question_email    => 'ATT_email',
119
-        EEM_Attendee::system_question_address  => 'ATT_address',
120
-        EEM_Attendee::system_question_address2 => 'ATT_address2',
121
-        EEM_Attendee::system_question_city     => 'ATT_city',
122
-        EEM_Attendee::system_question_state    => 'STA_ID',
123
-        EEM_Attendee::system_question_country  => 'CNT_ISO',
124
-        EEM_Attendee::system_question_zip      => 'ATT_zip',
125
-        EEM_Attendee::system_question_phone    => 'ATT_phone',
126
-    );
127
-
128
-
129
-
130
-    /**
131
-     *        private constructor to prevent direct creation
132
-     *
133
-     * @Constructor
134
-     * @access protected
135
-     * @param null $timezone
136
-     */
137
-    protected function __construct($timezone = null)
138
-    {
139
-        $this->singular_item = __('Attendee', 'event_espresso');
140
-        $this->plural_item = __('Attendees', 'event_espresso');
141
-        $this->_tables = array(
142
-            'Attendee_CPT'  => new EE_Primary_Table('posts', 'ID'),
143
-            'Attendee_Meta' => new EE_Secondary_Table('esp_attendee_meta', 'ATTM_ID', 'ATT_ID'),
144
-        );
145
-        $this->_fields = array(
146
-            'Attendee_CPT'  => array(
147
-                'ATT_ID'        => new EE_Primary_Key_Int_Field('ID', __("Attendee ID", "event_espresso")),
148
-                'ATT_full_name' => new EE_Plain_Text_Field('post_title', __("Attendee Full Name", "event_espresso"),
149
-                    false, __("Unknown", "event_espresso")),
150
-                'ATT_bio'       => new EE_Post_Content_Field('post_content', __("Attendee Biography", "event_espresso"),
151
-                    false, __("No Biography Provided", "event_espresso")),
152
-                'ATT_slug'      => new EE_Slug_Field('post_name', __("Attendee URL Slug", "event_espresso"), false),
153
-                'ATT_created'   => new EE_Datetime_Field('post_date', __("Time Attendee Created", "event_espresso"),
154
-                    false, EE_Datetime_Field::now),
155
-                'ATT_short_bio' => new EE_Simple_HTML_Field('post_excerpt',
156
-                    __("Attendee Short Biography", "event_espresso"), true,
157
-                    __("No Biography Provided", "event_espresso")),
158
-                'ATT_modified'  => new EE_Datetime_Field('post_modified',
159
-                    __("Time Attendee Last Modified", "event_espresso"), false, EE_Datetime_Field::now),
160
-                'ATT_author'    => new EE_WP_User_Field('post_author',
161
-                    __("Creator ID of the first Event attended", "event_espresso"), false),
162
-                'ATT_parent'    => new EE_DB_Only_Int_Field('post_parent',
163
-                    __("Parent Attendee (unused)", "event_espresso"), false, 0),
164
-                'post_type'     => new EE_WP_Post_Type_Field('espresso_attendees'),
165
-                // EE_DB_Only_Text_Field('post_type', __("Post Type of Attendee", "event_espresso"), false,'espresso_attendees'),
166
-                'status'        => new EE_WP_Post_Status_Field('post_status', __('Attendee Status', 'event_espresso'),
167
-                    false, 'publish'),
168
-            ),
169
-            'Attendee_Meta' => array(
170
-                'ATTM_ID'      => new EE_DB_Only_Int_Field('ATTM_ID', __('Attendee Meta Row ID', 'event_espresso'),
171
-                    false),
172
-                'ATT_ID_fk'    => new EE_DB_Only_Int_Field('ATT_ID',
173
-                    __("Foreign Key to Attendee in Post Table", "event_espresso"), false),
174
-                'ATT_fname'    => new EE_Plain_Text_Field('ATT_fname', __('First Name', 'event_espresso'), true, ''),
175
-                'ATT_lname'    => new EE_Plain_Text_Field('ATT_lname', __('Last Name', 'event_espresso'), true, ''),
176
-                'ATT_address'  => new EE_Plain_Text_Field('ATT_address', __('Address Part 1', 'event_espresso'), true,
177
-                    ''),
178
-                'ATT_address2' => new EE_Plain_Text_Field('ATT_address2', __('Address Part 2', 'event_espresso'), true,
179
-                    ''),
180
-                'ATT_city'     => new EE_Plain_Text_Field('ATT_city', __('City', 'event_espresso'), true, ''),
181
-                'STA_ID'       => new EE_Foreign_Key_Int_Field('STA_ID', __('State', 'event_espresso'), true, 0,
182
-                    'State'),
183
-                'CNT_ISO'      => new EE_Foreign_Key_String_Field('CNT_ISO', __('Country', 'event_espresso'), true, '',
184
-                    'Country'),
185
-                'ATT_zip'      => new EE_Plain_Text_Field('ATT_zip', __('ZIP/Postal Code', 'event_espresso'), true, ''),
186
-                'ATT_email'    => new EE_Email_Field('ATT_email', __('Email Address', 'event_espresso'), true, ''),
187
-                'ATT_phone'    => new EE_Plain_Text_Field('ATT_phone', __('Phone', 'event_espresso'), true, ''),
188
-            ),
189
-        );
190
-        $this->_model_relations = array(
191
-            'Registration'      => new EE_Has_Many_Relation(),
192
-            'State'             => new EE_Belongs_To_Relation(),
193
-            'Country'           => new EE_Belongs_To_Relation(),
194
-            'Event'             => new EE_HABTM_Relation('Registration', false),
195
-            'WP_User'           => new EE_Belongs_To_Relation(),
196
-            'Message'           => new EE_Has_Many_Any_Relation(false),
197
-            //allow deletion of attendees even if they have messages in the queue for them.
198
-            'Term_Relationship' => new EE_Has_Many_Relation(),
199
-            'Term_Taxonomy'     => new EE_HABTM_Relation('Term_Relationship'),
200
-        );
201
-        $this->_caps_slug = 'contacts';
202
-        parent::__construct($timezone);
203
-    }
204
-
205
-
206
-
207
-    /**
208
-     * Gets the name of the field on the attendee model corresponding to the system question string
209
-     * which should be one of the keys from EEM_Attendee::_system_question_to_attendee_field_name
210
-     *
211
-     * @param string $system_question_string
212
-     * @return string|null if not found
213
-     */
214
-    public function get_attendee_field_for_system_question($system_question_string)
215
-    {
216
-        return isset($this->_system_question_to_attendee_field_name[$system_question_string])
217
-            ? $this->_system_question_to_attendee_field_name[$system_question_string] : null;
218
-    }
219
-
220
-
221
-
222
-    /**
223
-     * Gets mapping from esp_question.QST_system values to their corresponding attendee field names
224
-     * @return array
225
-     */
226
-    public function system_question_to_attendee_field_mapping(){
227
-        return $this->_system_question_to_attendee_field_name;
228
-    }
229
-
230
-
231
-
232
-    /**
233
-     * Gets all the attendees for a transaction (by using the esp_registration as a join table)
234
-     *
235
-     * @param EE_Transaction /int $transaction_id_or_obj EE_Transaction or its ID
236
-     * @return EE_Attendee[]
237
-     */
238
-    public function get_attendees_for_transaction($transaction_id_or_obj)
239
-    {
240
-        return $this->get_all(array(
241
-            array(
242
-                'Registration.Transaction.TXN_ID' => $transaction_id_or_obj instanceof EE_Transaction
243
-                    ? $transaction_id_or_obj->ID() : $transaction_id_or_obj,
244
-            ),
245
-        ));
246
-    }
247
-
248
-
249
-
250
-    /**
251
-     *        retrieve  a single attendee from db via their ID
252
-     *
253
-     * @access        public
254
-     * @param        $ATT_ID
255
-     * @return        mixed        array on success, FALSE on fail
256
-     * @deprecated
257
-     */
258
-    public function get_attendee_by_ID($ATT_ID = false)
259
-    {
260
-        // retrieve a particular EE_Attendee
261
-        return $this->get_one_by_ID($ATT_ID);
262
-    }
263
-
264
-
265
-
266
-    /**
267
-     *        retrieve  a single attendee from db via their ID
268
-     *
269
-     * @access        public
270
-     * @param        array $where_cols_n_values
271
-     * @return        mixed        array on success, FALSE on fail
272
-     */
273
-    public function get_attendee($where_cols_n_values = array())
274
-    {
275
-        if (empty($where_cols_n_values)) {
276
-            return false;
277
-        }
278
-        $attendee = $this->get_all(array($where_cols_n_values));
279
-        if ( ! empty($attendee)) {
280
-            return array_shift($attendee);
281
-        } else {
282
-            return false;
283
-        }
284
-    }
285
-
286
-
287
-
288
-    /**
289
-     *        Search for an existing Attendee record in the DB
290
-     *
291
-     * @access        public
292
-     * @param array $where_cols_n_values
293
-     * @return bool|mixed
294
-     */
295
-    public function find_existing_attendee($where_cols_n_values = null)
296
-    {
297
-        // search by combo of first and last names plus the email address
298
-        $attendee_data_keys = array(
299
-            'ATT_fname' => $this->_ATT_fname,
300
-            'ATT_lname' => $this->_ATT_lname,
301
-            'ATT_email' => $this->_ATT_email,
302
-        );
303
-        // no search params means attendee object already exists.
304
-        $where_cols_n_values = is_array($where_cols_n_values) && ! empty($where_cols_n_values) ? $where_cols_n_values
305
-            : $attendee_data_keys;
306
-        $valid_data = true;
307
-        // check for required values
308
-        $valid_data = isset($where_cols_n_values['ATT_fname']) && ! empty($where_cols_n_values['ATT_fname'])
309
-            ? $valid_data : false;
310
-        $valid_data = isset($where_cols_n_values['ATT_lname']) && ! empty($where_cols_n_values['ATT_lname'])
311
-            ? $valid_data : false;
312
-        $valid_data = isset($where_cols_n_values['ATT_email']) && ! empty($where_cols_n_values['ATT_email'])
313
-            ? $valid_data : false;
314
-        if ($valid_data) {
315
-            $attendee = $this->get_attendee($where_cols_n_values);
316
-            if ($attendee instanceof EE_Attendee) {
317
-                return $attendee;
318
-            }
319
-        }
320
-        return false;
321
-    }
322
-
323
-
324
-
325
-    /**
326
-     * Takes an incoming array of EE_Registration ids and sends back a list of corresponding non duplicate
327
-     * EE_Attendee objects.
328
-     *
329
-     * @since    4.3.0
330
-     * @param  array $ids array of EE_Registration ids
331
-     * @return  EE_Attendee[]
332
-     */
333
-    public function get_array_of_contacts_from_reg_ids($ids)
334
-    {
335
-        $ids = (array)$ids;
336
-        $_where = array(
337
-            'Registration.REG_ID' => array('in', $ids),
338
-        );
339
-        return $this->get_all(array($_where));
340
-    }
48
+	/**
49
+	 * @deprecated
50
+	 */
51
+	const address2_question_id = 5;
52
+
53
+
54
+	/**
55
+	 * @deprecated
56
+	 */
57
+	const city_question_id = 6;
58
+
59
+
60
+	/**
61
+	 * @deprecated
62
+	 */
63
+	const state_question_id = 7;
64
+
65
+
66
+	/**
67
+	 * @deprecated
68
+	 */
69
+	const country_question_id = 8;
70
+
71
+
72
+	/**
73
+	 * @deprecated
74
+	 */
75
+	const zip_question_id = 9;
76
+
77
+
78
+	/**
79
+	 * @deprecated
80
+	 */
81
+	const phone_question_id = 10;
82
+
83
+	/**
84
+	 * When looking for questions that correspond to attendee fields,
85
+	 * look for the question with this QST_system value.
86
+	 * These replace the old constants like EEM_Attendee::*_question_id
87
+	 */
88
+	const system_question_fname    = 'fname';
89
+
90
+	const system_question_lname    = 'lname';
91
+
92
+	const system_question_email    = 'email';
93
+
94
+	const system_question_address  = 'address';
95
+
96
+	const system_question_address2 = 'address2';
97
+
98
+	const system_question_city     = 'city';
99
+
100
+	const system_question_state    = 'state';
101
+
102
+	const system_question_country  = 'country';
103
+
104
+	const system_question_zip      = 'zip';
105
+
106
+	const system_question_phone    = 'phone';
107
+
108
+	/**
109
+	 * Keys are all the EEM_Attendee::system_question_* constants, which are
110
+	 * also all the values of QST_system in the questions table, and values
111
+	 * are their corresponding Attendee field names
112
+	 *
113
+	 * @var array
114
+	 */
115
+	protected $_system_question_to_attendee_field_name = array(
116
+		EEM_Attendee::system_question_fname    => 'ATT_fname',
117
+		EEM_Attendee::system_question_lname    => 'ATT_lname',
118
+		EEM_Attendee::system_question_email    => 'ATT_email',
119
+		EEM_Attendee::system_question_address  => 'ATT_address',
120
+		EEM_Attendee::system_question_address2 => 'ATT_address2',
121
+		EEM_Attendee::system_question_city     => 'ATT_city',
122
+		EEM_Attendee::system_question_state    => 'STA_ID',
123
+		EEM_Attendee::system_question_country  => 'CNT_ISO',
124
+		EEM_Attendee::system_question_zip      => 'ATT_zip',
125
+		EEM_Attendee::system_question_phone    => 'ATT_phone',
126
+	);
127
+
128
+
129
+
130
+	/**
131
+	 *        private constructor to prevent direct creation
132
+	 *
133
+	 * @Constructor
134
+	 * @access protected
135
+	 * @param null $timezone
136
+	 */
137
+	protected function __construct($timezone = null)
138
+	{
139
+		$this->singular_item = __('Attendee', 'event_espresso');
140
+		$this->plural_item = __('Attendees', 'event_espresso');
141
+		$this->_tables = array(
142
+			'Attendee_CPT'  => new EE_Primary_Table('posts', 'ID'),
143
+			'Attendee_Meta' => new EE_Secondary_Table('esp_attendee_meta', 'ATTM_ID', 'ATT_ID'),
144
+		);
145
+		$this->_fields = array(
146
+			'Attendee_CPT'  => array(
147
+				'ATT_ID'        => new EE_Primary_Key_Int_Field('ID', __("Attendee ID", "event_espresso")),
148
+				'ATT_full_name' => new EE_Plain_Text_Field('post_title', __("Attendee Full Name", "event_espresso"),
149
+					false, __("Unknown", "event_espresso")),
150
+				'ATT_bio'       => new EE_Post_Content_Field('post_content', __("Attendee Biography", "event_espresso"),
151
+					false, __("No Biography Provided", "event_espresso")),
152
+				'ATT_slug'      => new EE_Slug_Field('post_name', __("Attendee URL Slug", "event_espresso"), false),
153
+				'ATT_created'   => new EE_Datetime_Field('post_date', __("Time Attendee Created", "event_espresso"),
154
+					false, EE_Datetime_Field::now),
155
+				'ATT_short_bio' => new EE_Simple_HTML_Field('post_excerpt',
156
+					__("Attendee Short Biography", "event_espresso"), true,
157
+					__("No Biography Provided", "event_espresso")),
158
+				'ATT_modified'  => new EE_Datetime_Field('post_modified',
159
+					__("Time Attendee Last Modified", "event_espresso"), false, EE_Datetime_Field::now),
160
+				'ATT_author'    => new EE_WP_User_Field('post_author',
161
+					__("Creator ID of the first Event attended", "event_espresso"), false),
162
+				'ATT_parent'    => new EE_DB_Only_Int_Field('post_parent',
163
+					__("Parent Attendee (unused)", "event_espresso"), false, 0),
164
+				'post_type'     => new EE_WP_Post_Type_Field('espresso_attendees'),
165
+				// EE_DB_Only_Text_Field('post_type', __("Post Type of Attendee", "event_espresso"), false,'espresso_attendees'),
166
+				'status'        => new EE_WP_Post_Status_Field('post_status', __('Attendee Status', 'event_espresso'),
167
+					false, 'publish'),
168
+			),
169
+			'Attendee_Meta' => array(
170
+				'ATTM_ID'      => new EE_DB_Only_Int_Field('ATTM_ID', __('Attendee Meta Row ID', 'event_espresso'),
171
+					false),
172
+				'ATT_ID_fk'    => new EE_DB_Only_Int_Field('ATT_ID',
173
+					__("Foreign Key to Attendee in Post Table", "event_espresso"), false),
174
+				'ATT_fname'    => new EE_Plain_Text_Field('ATT_fname', __('First Name', 'event_espresso'), true, ''),
175
+				'ATT_lname'    => new EE_Plain_Text_Field('ATT_lname', __('Last Name', 'event_espresso'), true, ''),
176
+				'ATT_address'  => new EE_Plain_Text_Field('ATT_address', __('Address Part 1', 'event_espresso'), true,
177
+					''),
178
+				'ATT_address2' => new EE_Plain_Text_Field('ATT_address2', __('Address Part 2', 'event_espresso'), true,
179
+					''),
180
+				'ATT_city'     => new EE_Plain_Text_Field('ATT_city', __('City', 'event_espresso'), true, ''),
181
+				'STA_ID'       => new EE_Foreign_Key_Int_Field('STA_ID', __('State', 'event_espresso'), true, 0,
182
+					'State'),
183
+				'CNT_ISO'      => new EE_Foreign_Key_String_Field('CNT_ISO', __('Country', 'event_espresso'), true, '',
184
+					'Country'),
185
+				'ATT_zip'      => new EE_Plain_Text_Field('ATT_zip', __('ZIP/Postal Code', 'event_espresso'), true, ''),
186
+				'ATT_email'    => new EE_Email_Field('ATT_email', __('Email Address', 'event_espresso'), true, ''),
187
+				'ATT_phone'    => new EE_Plain_Text_Field('ATT_phone', __('Phone', 'event_espresso'), true, ''),
188
+			),
189
+		);
190
+		$this->_model_relations = array(
191
+			'Registration'      => new EE_Has_Many_Relation(),
192
+			'State'             => new EE_Belongs_To_Relation(),
193
+			'Country'           => new EE_Belongs_To_Relation(),
194
+			'Event'             => new EE_HABTM_Relation('Registration', false),
195
+			'WP_User'           => new EE_Belongs_To_Relation(),
196
+			'Message'           => new EE_Has_Many_Any_Relation(false),
197
+			//allow deletion of attendees even if they have messages in the queue for them.
198
+			'Term_Relationship' => new EE_Has_Many_Relation(),
199
+			'Term_Taxonomy'     => new EE_HABTM_Relation('Term_Relationship'),
200
+		);
201
+		$this->_caps_slug = 'contacts';
202
+		parent::__construct($timezone);
203
+	}
204
+
205
+
206
+
207
+	/**
208
+	 * Gets the name of the field on the attendee model corresponding to the system question string
209
+	 * which should be one of the keys from EEM_Attendee::_system_question_to_attendee_field_name
210
+	 *
211
+	 * @param string $system_question_string
212
+	 * @return string|null if not found
213
+	 */
214
+	public function get_attendee_field_for_system_question($system_question_string)
215
+	{
216
+		return isset($this->_system_question_to_attendee_field_name[$system_question_string])
217
+			? $this->_system_question_to_attendee_field_name[$system_question_string] : null;
218
+	}
219
+
220
+
221
+
222
+	/**
223
+	 * Gets mapping from esp_question.QST_system values to their corresponding attendee field names
224
+	 * @return array
225
+	 */
226
+	public function system_question_to_attendee_field_mapping(){
227
+		return $this->_system_question_to_attendee_field_name;
228
+	}
229
+
230
+
231
+
232
+	/**
233
+	 * Gets all the attendees for a transaction (by using the esp_registration as a join table)
234
+	 *
235
+	 * @param EE_Transaction /int $transaction_id_or_obj EE_Transaction or its ID
236
+	 * @return EE_Attendee[]
237
+	 */
238
+	public function get_attendees_for_transaction($transaction_id_or_obj)
239
+	{
240
+		return $this->get_all(array(
241
+			array(
242
+				'Registration.Transaction.TXN_ID' => $transaction_id_or_obj instanceof EE_Transaction
243
+					? $transaction_id_or_obj->ID() : $transaction_id_or_obj,
244
+			),
245
+		));
246
+	}
247
+
248
+
249
+
250
+	/**
251
+	 *        retrieve  a single attendee from db via their ID
252
+	 *
253
+	 * @access        public
254
+	 * @param        $ATT_ID
255
+	 * @return        mixed        array on success, FALSE on fail
256
+	 * @deprecated
257
+	 */
258
+	public function get_attendee_by_ID($ATT_ID = false)
259
+	{
260
+		// retrieve a particular EE_Attendee
261
+		return $this->get_one_by_ID($ATT_ID);
262
+	}
263
+
264
+
265
+
266
+	/**
267
+	 *        retrieve  a single attendee from db via their ID
268
+	 *
269
+	 * @access        public
270
+	 * @param        array $where_cols_n_values
271
+	 * @return        mixed        array on success, FALSE on fail
272
+	 */
273
+	public function get_attendee($where_cols_n_values = array())
274
+	{
275
+		if (empty($where_cols_n_values)) {
276
+			return false;
277
+		}
278
+		$attendee = $this->get_all(array($where_cols_n_values));
279
+		if ( ! empty($attendee)) {
280
+			return array_shift($attendee);
281
+		} else {
282
+			return false;
283
+		}
284
+	}
285
+
286
+
287
+
288
+	/**
289
+	 *        Search for an existing Attendee record in the DB
290
+	 *
291
+	 * @access        public
292
+	 * @param array $where_cols_n_values
293
+	 * @return bool|mixed
294
+	 */
295
+	public function find_existing_attendee($where_cols_n_values = null)
296
+	{
297
+		// search by combo of first and last names plus the email address
298
+		$attendee_data_keys = array(
299
+			'ATT_fname' => $this->_ATT_fname,
300
+			'ATT_lname' => $this->_ATT_lname,
301
+			'ATT_email' => $this->_ATT_email,
302
+		);
303
+		// no search params means attendee object already exists.
304
+		$where_cols_n_values = is_array($where_cols_n_values) && ! empty($where_cols_n_values) ? $where_cols_n_values
305
+			: $attendee_data_keys;
306
+		$valid_data = true;
307
+		// check for required values
308
+		$valid_data = isset($where_cols_n_values['ATT_fname']) && ! empty($where_cols_n_values['ATT_fname'])
309
+			? $valid_data : false;
310
+		$valid_data = isset($where_cols_n_values['ATT_lname']) && ! empty($where_cols_n_values['ATT_lname'])
311
+			? $valid_data : false;
312
+		$valid_data = isset($where_cols_n_values['ATT_email']) && ! empty($where_cols_n_values['ATT_email'])
313
+			? $valid_data : false;
314
+		if ($valid_data) {
315
+			$attendee = $this->get_attendee($where_cols_n_values);
316
+			if ($attendee instanceof EE_Attendee) {
317
+				return $attendee;
318
+			}
319
+		}
320
+		return false;
321
+	}
322
+
323
+
324
+
325
+	/**
326
+	 * Takes an incoming array of EE_Registration ids and sends back a list of corresponding non duplicate
327
+	 * EE_Attendee objects.
328
+	 *
329
+	 * @since    4.3.0
330
+	 * @param  array $ids array of EE_Registration ids
331
+	 * @return  EE_Attendee[]
332
+	 */
333
+	public function get_array_of_contacts_from_reg_ids($ids)
334
+	{
335
+		$ids = (array)$ids;
336
+		$_where = array(
337
+			'Registration.REG_ID' => array('in', $ids),
338
+		);
339
+		return $this->get_all(array($_where));
340
+	}
341 341
 
342 342
 
343 343
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 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
 
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
      * Gets mapping from esp_question.QST_system values to their corresponding attendee field names
224 224
      * @return array
225 225
      */
226
-    public function system_question_to_attendee_field_mapping(){
226
+    public function system_question_to_attendee_field_mapping() {
227 227
         return $this->_system_question_to_attendee_field_name;
228 228
     }
229 229
 
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
      */
333 333
     public function get_array_of_contacts_from_reg_ids($ids)
334 334
     {
335
-        $ids = (array)$ids;
335
+        $ids = (array) $ids;
336 336
         $_where = array(
337 337
             'Registration.REG_ID' => array('in', $ids),
338 338
         );
Please login to merge, or discard this patch.