@@ -14,11 +14,11 @@ discard block |
||
| 14 | 14 | $stages = glob(EE_CORE . 'data_migration_scripts/4_3_0_stages/*'); |
| 15 | 15 | $class_to_filepath = array(); |
| 16 | 16 | if (! empty($stages)) { |
| 17 | - foreach ($stages as $filepath) { |
|
| 18 | - $matches = array(); |
|
| 19 | - preg_match('~4_3_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
| 20 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
| 21 | - } |
|
| 17 | + foreach ($stages as $filepath) { |
|
| 18 | + $matches = array(); |
|
| 19 | + preg_match('~4_3_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
| 20 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
| 21 | + } |
|
| 22 | 22 | } |
| 23 | 23 | // give addons a chance to autoload their stages too |
| 24 | 24 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_3_0__autoloaded_stages', $class_to_filepath); |
@@ -31,56 +31,56 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * EE_DMS_Core_4_3_0 constructor. |
|
| 36 | - * |
|
| 37 | - * @param TableManager $table_manager |
|
| 38 | - * @param TableAnalysis $table_analysis |
|
| 39 | - */ |
|
| 40 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
| 41 | - { |
|
| 42 | - $this->_pretty_name = __("Data Update to Event Espresso 4.3.0", "event_espresso"); |
|
| 43 | - $this->_priority = 10; |
|
| 44 | - $this->_migration_stages = array( |
|
| 45 | - new EE_DMS_4_3_0_question_option_order(), |
|
| 46 | - new EE_DMS_4_3_0_event_message_templates(), |
|
| 47 | - ); |
|
| 48 | - parent::__construct($table_manager, $table_analysis); |
|
| 49 | - } |
|
| 34 | + /** |
|
| 35 | + * EE_DMS_Core_4_3_0 constructor. |
|
| 36 | + * |
|
| 37 | + * @param TableManager $table_manager |
|
| 38 | + * @param TableAnalysis $table_analysis |
|
| 39 | + */ |
|
| 40 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
| 41 | + { |
|
| 42 | + $this->_pretty_name = __("Data Update to Event Espresso 4.3.0", "event_espresso"); |
|
| 43 | + $this->_priority = 10; |
|
| 44 | + $this->_migration_stages = array( |
|
| 45 | + new EE_DMS_4_3_0_question_option_order(), |
|
| 46 | + new EE_DMS_4_3_0_event_message_templates(), |
|
| 47 | + ); |
|
| 48 | + parent::__construct($table_manager, $table_analysis); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | |
| 53 | - public function can_migrate_from_version($version_array) |
|
| 54 | - { |
|
| 55 | - $version_string = $version_array['Core']; |
|
| 56 | - if (version_compare($version_string, '4.3.0.decaf', '<') && version_compare($version_string, '4.2.0.decaf', '>=')) { |
|
| 53 | + public function can_migrate_from_version($version_array) |
|
| 54 | + { |
|
| 55 | + $version_string = $version_array['Core']; |
|
| 56 | + if (version_compare($version_string, '4.3.0.decaf', '<') && version_compare($version_string, '4.2.0.decaf', '>=')) { |
|
| 57 | 57 | // echo "$version_string can be migrated fro"; |
| 58 | - return true; |
|
| 59 | - } elseif (! $version_string) { |
|
| 58 | + return true; |
|
| 59 | + } elseif (! $version_string) { |
|
| 60 | 60 | // echo "no version string provided: $version_string"; |
| 61 | - // no version string provided... this must be pre 4.2 |
|
| 62 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 63 | - } else { |
|
| 61 | + // no version string provided... this must be pre 4.2 |
|
| 62 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 63 | + } else { |
|
| 64 | 64 | // echo "$version_string doesnt apply"; |
| 65 | - return false; |
|
| 66 | - } |
|
| 67 | - } |
|
| 65 | + return false; |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | 69 | |
| 70 | 70 | |
| 71 | - public function schema_changes_before_migration() |
|
| 72 | - { |
|
| 73 | - // relies on 4.1's EEH_Activation::create_table |
|
| 74 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 75 | - $table_name = 'esp_answer'; |
|
| 76 | - $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 71 | + public function schema_changes_before_migration() |
|
| 72 | + { |
|
| 73 | + // relies on 4.1's EEH_Activation::create_table |
|
| 74 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 75 | + $table_name = 'esp_answer'; |
|
| 76 | + $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 77 | 77 | REG_ID int(10) unsigned NOT NULL, |
| 78 | 78 | QST_ID int(10) unsigned NOT NULL, |
| 79 | 79 | ANS_value text NOT NULL, |
| 80 | 80 | PRIMARY KEY (ANS_ID)"; |
| 81 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 82 | - $table_name = 'esp_attendee_meta'; |
|
| 83 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 81 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 82 | + $table_name = 'esp_attendee_meta'; |
|
| 83 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 84 | 84 | ATT_ID bigint(20) unsigned NOT NULL, |
| 85 | 85 | ATT_fname varchar(45) NOT NULL, |
| 86 | 86 | ATT_lname varchar(45) NOT NULL, |
@@ -96,9 +96,9 @@ discard block |
||
| 96 | 96 | KEY ATT_fname (ATT_fname), |
| 97 | 97 | KEY ATT_lname (ATT_lname), |
| 98 | 98 | KEY ATT_email (ATT_email(191))"; |
| 99 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 100 | - $table_name = 'esp_country'; |
|
| 101 | - $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
| 99 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 100 | + $table_name = 'esp_country'; |
|
| 101 | + $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
| 102 | 102 | CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL, |
| 103 | 103 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
| 104 | 104 | CNT_name varchar(45) COLLATE utf8_bin NOT NULL, |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | CNT_is_EU tinyint(1) DEFAULT '0', |
| 115 | 115 | CNT_active tinyint(1) DEFAULT '0', |
| 116 | 116 | PRIMARY KEY (CNT_ISO)"; |
| 117 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 118 | - $table_name = 'esp_datetime'; |
|
| 119 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 117 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 118 | + $table_name = 'esp_datetime'; |
|
| 119 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 120 | 120 | EVT_ID bigint(20) unsigned NOT NULL, |
| 121 | 121 | DTT_name varchar(255) NOT NULL DEFAULT '', |
| 122 | 122 | DTT_description text NOT NULL, |
@@ -131,9 +131,9 @@ discard block |
||
| 131 | 131 | PRIMARY KEY (DTT_ID), |
| 132 | 132 | KEY EVT_ID (EVT_ID), |
| 133 | 133 | KEY DTT_is_primary (DTT_is_primary)"; |
| 134 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 135 | - $table_name = 'esp_event_meta'; |
|
| 136 | - $sql = " |
|
| 134 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 135 | + $table_name = 'esp_event_meta'; |
|
| 136 | + $sql = " |
|
| 137 | 137 | EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
| 138 | 138 | EVT_ID bigint(20) unsigned NOT NULL, |
| 139 | 139 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -148,31 +148,31 @@ discard block |
||
| 148 | 148 | EVT_external_URL varchar(200) NULL, |
| 149 | 149 | EVT_donations tinyint(1) NULL, |
| 150 | 150 | PRIMARY KEY (EVTM_ID)"; |
| 151 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 152 | - $table_name = 'esp_event_question_group'; |
|
| 153 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 151 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 152 | + $table_name = 'esp_event_question_group'; |
|
| 153 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 154 | 154 | EVT_ID bigint(20) unsigned NOT NULL, |
| 155 | 155 | QSG_ID int(10) unsigned NOT NULL, |
| 156 | 156 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
| 157 | 157 | PRIMARY KEY (EQG_ID)"; |
| 158 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 159 | - $table_name = 'esp_event_venue'; |
|
| 160 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 158 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 159 | + $table_name = 'esp_event_venue'; |
|
| 160 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 161 | 161 | EVT_ID bigint(20) unsigned NOT NULL, |
| 162 | 162 | VNU_ID bigint(20) unsigned NOT NULL, |
| 163 | 163 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
| 164 | 164 | PRIMARY KEY (EVV_ID)"; |
| 165 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 166 | - $table_name = 'esp_extra_meta'; |
|
| 167 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 165 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 166 | + $table_name = 'esp_extra_meta'; |
|
| 167 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 168 | 168 | OBJ_ID int(11) DEFAULT NULL, |
| 169 | 169 | EXM_type varchar(45) DEFAULT NULL, |
| 170 | 170 | EXM_key varchar(45) DEFAULT NULL, |
| 171 | 171 | EXM_value text, |
| 172 | 172 | PRIMARY KEY (EXM_ID)"; |
| 173 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 174 | - $table_name = 'esp_line_item'; |
|
| 175 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 173 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 174 | + $table_name = 'esp_line_item'; |
|
| 175 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 176 | 176 | LIN_code varchar(245) NOT NULL DEFAULT '', |
| 177 | 177 | TXN_ID int(11) DEFAULT NULL, |
| 178 | 178 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -188,19 +188,19 @@ discard block |
||
| 188 | 188 | OBJ_ID int(11) DEFAULT NULL, |
| 189 | 189 | OBJ_type varchar(45)DEFAULT NULL, |
| 190 | 190 | PRIMARY KEY (LIN_ID)"; |
| 191 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 192 | - $table_name = 'esp_message_template'; |
|
| 193 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 191 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 192 | + $table_name = 'esp_message_template'; |
|
| 193 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 194 | 194 | GRP_ID int(10) unsigned NOT NULL, |
| 195 | 195 | MTP_context varchar(50) NOT NULL, |
| 196 | 196 | MTP_template_field varchar(30) NOT NULL, |
| 197 | 197 | MTP_content text NOT NULL, |
| 198 | 198 | PRIMARY KEY (MTP_ID), |
| 199 | 199 | KEY GRP_ID (GRP_ID)"; |
| 200 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 201 | - $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
| 202 | - $table_name = 'esp_message_template_group'; |
|
| 203 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 200 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 201 | + $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
| 202 | + $table_name = 'esp_message_template_group'; |
|
| 203 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 204 | 204 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
| 205 | 205 | MTP_name varchar(245) NOT NULL DEFAULT '', |
| 206 | 206 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -212,17 +212,17 @@ discard block |
||
| 212 | 212 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
| 213 | 213 | PRIMARY KEY (GRP_ID), |
| 214 | 214 | KEY MTP_user_id (MTP_user_id)"; |
| 215 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 216 | - $table_name = 'esp_event_message_template'; |
|
| 217 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 215 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 216 | + $table_name = 'esp_event_message_template'; |
|
| 217 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 218 | 218 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
| 219 | 219 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
| 220 | 220 | PRIMARY KEY (EMT_ID), |
| 221 | 221 | KEY EVT_ID (EVT_ID), |
| 222 | 222 | KEY GRP_ID (GRP_ID)"; |
| 223 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 224 | - $table_name = 'esp_payment'; |
|
| 225 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 223 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 224 | + $table_name = 'esp_payment'; |
|
| 225 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 226 | 226 | TXN_ID int(10) unsigned DEFAULT NULL, |
| 227 | 227 | STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL, |
| 228 | 228 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -238,9 +238,9 @@ discard block |
||
| 238 | 238 | PRIMARY KEY (PAY_ID), |
| 239 | 239 | KEY TXN_ID (TXN_ID), |
| 240 | 240 | KEY PAY_timestamp (PAY_timestamp)"; |
| 241 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 242 | - $table_name = "esp_ticket"; |
|
| 243 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 241 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 242 | + $table_name = "esp_ticket"; |
|
| 243 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 244 | 244 | TTM_ID int(10) unsigned NOT NULL, |
| 245 | 245 | TKT_name varchar(245) NOT NULL DEFAULT '', |
| 246 | 246 | TKT_description text NOT NULL, |
@@ -260,28 +260,28 @@ discard block |
||
| 260 | 260 | TKT_parent int(10) unsigned DEFAULT '0', |
| 261 | 261 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
| 262 | 262 | PRIMARY KEY (TKT_ID)"; |
| 263 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 264 | - $table_name = "esp_ticket_price"; |
|
| 265 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 263 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 264 | + $table_name = "esp_ticket_price"; |
|
| 265 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 266 | 266 | TKT_ID int(10) unsigned NOT NULL, |
| 267 | 267 | PRC_ID int(10) unsigned NOT NULL, |
| 268 | 268 | PRIMARY KEY (TKP_ID)"; |
| 269 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 270 | - $table_name = "esp_datetime_ticket"; |
|
| 271 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 269 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 270 | + $table_name = "esp_datetime_ticket"; |
|
| 271 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 272 | 272 | DTT_ID int(10) unsigned NOT NULL, |
| 273 | 273 | TKT_ID int(10) unsigned NOT NULL, |
| 274 | 274 | PRIMARY KEY (DTK_ID)"; |
| 275 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 276 | - $table_name = "esp_ticket_template"; |
|
| 277 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 275 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 276 | + $table_name = "esp_ticket_template"; |
|
| 277 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 278 | 278 | TTM_name varchar(45) NOT NULL, |
| 279 | 279 | TTM_description text, |
| 280 | 280 | TTM_file varchar(45), |
| 281 | 281 | PRIMARY KEY (TTM_ID)"; |
| 282 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 283 | - $table_name = "esp_price"; |
|
| 284 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 282 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 283 | + $table_name = "esp_price"; |
|
| 284 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 285 | 285 | PRT_ID tinyint(3) unsigned NOT NULL, |
| 286 | 286 | PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
| 287 | 287 | PRC_name varchar(245) NOT NULL, |
@@ -292,9 +292,9 @@ discard block |
||
| 292 | 292 | PRC_order tinyint(3) unsigned NOT NULL DEFAULT '0', |
| 293 | 293 | PRC_parent int(10) unsigned DEFAULT 0, |
| 294 | 294 | PRIMARY KEY (PRC_ID)"; |
| 295 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 296 | - $table_name = "esp_price_type"; |
|
| 297 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
| 295 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 296 | + $table_name = "esp_price_type"; |
|
| 297 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
| 298 | 298 | PRT_name varchar(45) NOT NULL, |
| 299 | 299 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
| 300 | 300 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -302,9 +302,9 @@ discard block |
||
| 302 | 302 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
| 303 | 303 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
| 304 | 304 | PRIMARY KEY (PRT_ID)"; |
| 305 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 306 | - $table_name = 'esp_question'; |
|
| 307 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 305 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 306 | + $table_name = 'esp_question'; |
|
| 307 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 308 | 308 | QST_display_text text NOT NULL, |
| 309 | 309 | QST_admin_label varchar(255) NOT NULL, |
| 310 | 310 | QST_system varchar(25) DEFAULT NULL, |
@@ -316,10 +316,10 @@ discard block |
||
| 316 | 316 | QST_wp_user bigint(20) unsigned NULL, |
| 317 | 317 | QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
| 318 | 318 | PRIMARY KEY (QST_ID)'; |
| 319 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 320 | - $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
| 321 | - $table_name = 'esp_question_group'; |
|
| 322 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 319 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 320 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
| 321 | + $table_name = 'esp_question_group'; |
|
| 322 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 323 | 323 | QSG_name varchar(255) NOT NULL, |
| 324 | 324 | QSG_identifier varchar(100) NOT NULL, |
| 325 | 325 | QSG_desc text NULL, |
@@ -330,25 +330,25 @@ discard block |
||
| 330 | 330 | QSG_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
| 331 | 331 | PRIMARY KEY (QSG_ID), |
| 332 | 332 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
| 333 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 334 | - $table_name = 'esp_question_group_question'; |
|
| 335 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 333 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 334 | + $table_name = 'esp_question_group_question'; |
|
| 335 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 336 | 336 | QSG_ID int(10) unsigned NOT NULL, |
| 337 | 337 | QST_ID int(10) unsigned NOT NULL, |
| 338 | 338 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
| 339 | 339 | PRIMARY KEY (QGQ_ID) "; |
| 340 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 341 | - $table_name = 'esp_question_option'; |
|
| 342 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 340 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 341 | + $table_name = 'esp_question_option'; |
|
| 342 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 343 | 343 | QSO_value varchar(255) NOT NULL, |
| 344 | 344 | QSO_desc text NOT NULL, |
| 345 | 345 | QST_ID int(10) unsigned NOT NULL, |
| 346 | 346 | QSO_order int(10) unsigned NOT NULL DEFAULT 0, |
| 347 | 347 | QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
| 348 | 348 | PRIMARY KEY (QSO_ID)"; |
| 349 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 350 | - $table_name = 'esp_registration'; |
|
| 351 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 349 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 350 | + $table_name = 'esp_registration'; |
|
| 351 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 352 | 352 | EVT_ID bigint(20) unsigned NOT NULL, |
| 353 | 353 | ATT_ID bigint(20) unsigned NOT NULL, |
| 354 | 354 | TXN_ID int(10) unsigned NOT NULL, |
@@ -371,25 +371,25 @@ discard block |
||
| 371 | 371 | KEY STS_ID (STS_ID), |
| 372 | 372 | KEY REG_url_link (REG_url_link), |
| 373 | 373 | KEY REG_code (REG_code)"; |
| 374 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 375 | - $table_name = 'esp_checkin'; |
|
| 376 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 374 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 375 | + $table_name = 'esp_checkin'; |
|
| 376 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 377 | 377 | REG_ID int(10) unsigned NOT NULL, |
| 378 | 378 | DTT_ID int(10) unsigned NOT NULL, |
| 379 | 379 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
| 380 | 380 | CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
| 381 | 381 | PRIMARY KEY (CHK_ID)"; |
| 382 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 383 | - $table_name = 'esp_state'; |
|
| 384 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
| 382 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 383 | + $table_name = 'esp_state'; |
|
| 384 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
| 385 | 385 | CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
| 386 | 386 | STA_abbrev varchar(6) COLLATE utf8_bin NOT NULL, |
| 387 | 387 | STA_name varchar(100) COLLATE utf8_bin NOT NULL, |
| 388 | 388 | STA_active tinyint(1) DEFAULT '1', |
| 389 | 389 | PRIMARY KEY (STA_ID)"; |
| 390 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 391 | - $table_name = 'esp_status'; |
|
| 392 | - $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
| 390 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 391 | + $table_name = 'esp_status'; |
|
| 392 | + $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
| 393 | 393 | STS_code varchar(45) COLLATE utf8_bin NOT NULL, |
| 394 | 394 | STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL, |
| 395 | 395 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -397,9 +397,9 @@ discard block |
||
| 397 | 397 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
| 398 | 398 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
| 399 | 399 | KEY STS_type (STS_type)"; |
| 400 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 401 | - $table_name = 'esp_transaction'; |
|
| 402 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 400 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 401 | + $table_name = 'esp_transaction'; |
|
| 402 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 403 | 403 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
| 404 | 404 | TXN_total decimal(10,3) DEFAULT '0.00', |
| 405 | 405 | TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00', |
@@ -409,9 +409,9 @@ discard block |
||
| 409 | 409 | PRIMARY KEY (TXN_ID), |
| 410 | 410 | KEY TXN_timestamp (TXN_timestamp), |
| 411 | 411 | KEY STS_ID (STS_ID)"; |
| 412 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 413 | - $table_name = 'esp_venue_meta'; |
|
| 414 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 412 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 413 | + $table_name = 'esp_venue_meta'; |
|
| 414 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 415 | 415 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
| 416 | 416 | VNU_address varchar(255) DEFAULT NULL, |
| 417 | 417 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -429,77 +429,77 @@ discard block |
||
| 429 | 429 | PRIMARY KEY (VNUM_ID), |
| 430 | 430 | KEY STA_ID (STA_ID), |
| 431 | 431 | KEY CNT_ISO (CNT_ISO)"; |
| 432 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 433 | - $script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
| 434 | - // setting up the DEFAULT stats and countries is also essential for the data migrations to run |
|
| 435 | - // (because many need to convert old string states to foreign keys into the states table) |
|
| 436 | - $script_with_defaults->insert_default_states(); |
|
| 437 | - $script_with_defaults->insert_default_countries(); |
|
| 438 | - // setting up DEFAULT prices, price types, and tickets is also essential for the price migrations |
|
| 439 | - $script_with_defaults->insert_default_price_types(); |
|
| 440 | - $script_with_defaults->insert_default_prices(); |
|
| 441 | - // but the schema on the tickets table has changed since 4.1, so use our DEFAULT ticket method instead of 4.1's |
|
| 442 | - $this->insert_default_tickets(); |
|
| 443 | - // setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre |
|
| 444 | - EE_Config::instance()->update_espresso_config(false, true); |
|
| 445 | - return true; |
|
| 446 | - } |
|
| 432 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 433 | + $script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
| 434 | + // setting up the DEFAULT stats and countries is also essential for the data migrations to run |
|
| 435 | + // (because many need to convert old string states to foreign keys into the states table) |
|
| 436 | + $script_with_defaults->insert_default_states(); |
|
| 437 | + $script_with_defaults->insert_default_countries(); |
|
| 438 | + // setting up DEFAULT prices, price types, and tickets is also essential for the price migrations |
|
| 439 | + $script_with_defaults->insert_default_price_types(); |
|
| 440 | + $script_with_defaults->insert_default_prices(); |
|
| 441 | + // but the schema on the tickets table has changed since 4.1, so use our DEFAULT ticket method instead of 4.1's |
|
| 442 | + $this->insert_default_tickets(); |
|
| 443 | + // setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre |
|
| 444 | + EE_Config::instance()->update_espresso_config(false, true); |
|
| 445 | + return true; |
|
| 446 | + } |
|
| 447 | 447 | |
| 448 | 448 | |
| 449 | 449 | |
| 450 | - /** |
|
| 451 | - * @return boolean |
|
| 452 | - */ |
|
| 453 | - public function schema_changes_after_migration() |
|
| 454 | - { |
|
| 455 | - return true; |
|
| 456 | - } |
|
| 450 | + /** |
|
| 451 | + * @return boolean |
|
| 452 | + */ |
|
| 453 | + public function schema_changes_after_migration() |
|
| 454 | + { |
|
| 455 | + return true; |
|
| 456 | + } |
|
| 457 | 457 | |
| 458 | 458 | |
| 459 | 459 | |
| 460 | - public function migration_page_hooks() |
|
| 461 | - { |
|
| 462 | - } |
|
| 460 | + public function migration_page_hooks() |
|
| 461 | + { |
|
| 462 | + } |
|
| 463 | 463 | |
| 464 | 464 | |
| 465 | 465 | |
| 466 | - /** |
|
| 467 | - * insert DEFAULT ticket |
|
| 468 | - * Almost identical to EE_DMS_Core_4_1_0::insert_default_tickets, except is aware of the TKT_required field |
|
| 469 | - * |
|
| 470 | - * @access public |
|
| 471 | - * @static |
|
| 472 | - * @return void |
|
| 473 | - */ |
|
| 474 | - public function insert_default_tickets() |
|
| 475 | - { |
|
| 476 | - global $wpdb; |
|
| 477 | - $ticket_table = $wpdb->prefix . "esp_ticket"; |
|
| 478 | - if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
|
| 479 | - $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
| 480 | - $tickets_exist = $wpdb->get_var($SQL); |
|
| 481 | - if (! $tickets_exist) { |
|
| 482 | - $SQL = "INSERT INTO $ticket_table |
|
| 466 | + /** |
|
| 467 | + * insert DEFAULT ticket |
|
| 468 | + * Almost identical to EE_DMS_Core_4_1_0::insert_default_tickets, except is aware of the TKT_required field |
|
| 469 | + * |
|
| 470 | + * @access public |
|
| 471 | + * @static |
|
| 472 | + * @return void |
|
| 473 | + */ |
|
| 474 | + public function insert_default_tickets() |
|
| 475 | + { |
|
| 476 | + global $wpdb; |
|
| 477 | + $ticket_table = $wpdb->prefix . "esp_ticket"; |
|
| 478 | + if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
|
| 479 | + $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
| 480 | + $tickets_exist = $wpdb->get_var($SQL); |
|
| 481 | + if (! $tickets_exist) { |
|
| 482 | + $SQL = "INSERT INTO $ticket_table |
|
| 483 | 483 | ( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_required, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_deleted ) VALUES |
| 484 | 484 | ( 1, 0, '" |
| 485 | - . __("Free Ticket", "event_espresso") |
|
| 486 | - . "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);"; |
|
| 487 | - $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL); |
|
| 488 | - $wpdb->query($SQL); |
|
| 489 | - } |
|
| 490 | - } |
|
| 491 | - $ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
| 492 | - if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
|
| 493 | - $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
| 494 | - $ticket_prc_exist = $wpdb->get_var($SQL); |
|
| 495 | - if (! $ticket_prc_exist) { |
|
| 496 | - $SQL = "INSERT INTO $ticket_price_table |
|
| 485 | + . __("Free Ticket", "event_espresso") |
|
| 486 | + . "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);"; |
|
| 487 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL); |
|
| 488 | + $wpdb->query($SQL); |
|
| 489 | + } |
|
| 490 | + } |
|
| 491 | + $ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
| 492 | + if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
|
| 493 | + $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
| 494 | + $ticket_prc_exist = $wpdb->get_var($SQL); |
|
| 495 | + if (! $ticket_prc_exist) { |
|
| 496 | + $SQL = "INSERT INTO $ticket_price_table |
|
| 497 | 497 | ( TKP_ID, TKT_ID, PRC_ID ) VALUES |
| 498 | 498 | ( 1, 1, 1 ) |
| 499 | 499 | "; |
| 500 | - $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL); |
|
| 501 | - $wpdb->query($SQL); |
|
| 502 | - } |
|
| 503 | - } |
|
| 504 | - } |
|
| 500 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL); |
|
| 501 | + $wpdb->query($SQL); |
|
| 502 | + } |
|
| 503 | + } |
|
| 504 | + } |
|
| 505 | 505 | } |
@@ -11,13 +11,13 @@ discard block |
||
| 11 | 11 | // unfortunately, this needs to be done upon INCLUSION of this file, |
| 12 | 12 | // instead of construction, because it only gets constructed on first page load |
| 13 | 13 | // (all other times it gets resurrected from a wordpress option) |
| 14 | -$stages = glob(EE_CORE . 'data_migration_scripts/4_3_0_stages/*'); |
|
| 14 | +$stages = glob(EE_CORE.'data_migration_scripts/4_3_0_stages/*'); |
|
| 15 | 15 | $class_to_filepath = array(); |
| 16 | -if (! empty($stages)) { |
|
| 16 | +if ( ! empty($stages)) { |
|
| 17 | 17 | foreach ($stages as $filepath) { |
| 18 | 18 | $matches = array(); |
| 19 | 19 | preg_match('~4_3_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
| 20 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
| 20 | + $class_to_filepath[$matches[1]] = $filepath; |
|
| 21 | 21 | } |
| 22 | 22 | } |
| 23 | 23 | // give addons a chance to autoload their stages too |
@@ -56,10 +56,10 @@ discard block |
||
| 56 | 56 | if (version_compare($version_string, '4.3.0.decaf', '<') && version_compare($version_string, '4.2.0.decaf', '>=')) { |
| 57 | 57 | // echo "$version_string can be migrated fro"; |
| 58 | 58 | return true; |
| 59 | - } elseif (! $version_string) { |
|
| 59 | + } elseif ( ! $version_string) { |
|
| 60 | 60 | // echo "no version string provided: $version_string"; |
| 61 | 61 | // no version string provided... this must be pre 4.2 |
| 62 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 62 | + return false; // changed mind. dont want people thinking they should migrate yet because they cant |
|
| 63 | 63 | } else { |
| 64 | 64 | // echo "$version_string doesnt apply"; |
| 65 | 65 | return false; |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | public function schema_changes_before_migration() |
| 72 | 72 | { |
| 73 | 73 | // relies on 4.1's EEH_Activation::create_table |
| 74 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 74 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
| 75 | 75 | $table_name = 'esp_answer'; |
| 76 | 76 | $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
| 77 | 77 | REG_ID int(10) unsigned NOT NULL, |
@@ -474,11 +474,11 @@ discard block |
||
| 474 | 474 | public function insert_default_tickets() |
| 475 | 475 | { |
| 476 | 476 | global $wpdb; |
| 477 | - $ticket_table = $wpdb->prefix . "esp_ticket"; |
|
| 477 | + $ticket_table = $wpdb->prefix."esp_ticket"; |
|
| 478 | 478 | if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
| 479 | - $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
| 479 | + $SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table; |
|
| 480 | 480 | $tickets_exist = $wpdb->get_var($SQL); |
| 481 | - if (! $tickets_exist) { |
|
| 481 | + if ( ! $tickets_exist) { |
|
| 482 | 482 | $SQL = "INSERT INTO $ticket_table |
| 483 | 483 | ( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_required, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_deleted ) VALUES |
| 484 | 484 | ( 1, 0, '" |
@@ -488,11 +488,11 @@ discard block |
||
| 488 | 488 | $wpdb->query($SQL); |
| 489 | 489 | } |
| 490 | 490 | } |
| 491 | - $ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
| 491 | + $ticket_price_table = $wpdb->prefix."esp_ticket_price"; |
|
| 492 | 492 | if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
| 493 | - $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
| 493 | + $SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table; |
|
| 494 | 494 | $ticket_prc_exist = $wpdb->get_var($SQL); |
| 495 | - if (! $ticket_prc_exist) { |
|
| 495 | + if ( ! $ticket_prc_exist) { |
|
| 496 | 496 | $SQL = "INSERT INTO $ticket_price_table |
| 497 | 497 | ( TKP_ID, TKT_ID, PRC_ID ) VALUES |
| 498 | 498 | ( 1, 1, 1 ) |
@@ -14,9 +14,9 @@ discard block |
||
| 14 | 14 | $stages = glob(EE_CORE . 'data_migration_scripts/4_6_0_stages/*'); |
| 15 | 15 | $class_to_filepath = array(); |
| 16 | 16 | foreach ($stages as $filepath) { |
| 17 | - $matches = array(); |
|
| 18 | - preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
| 19 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
| 17 | + $matches = array(); |
|
| 18 | + preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
| 19 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
| 20 | 20 | } |
| 21 | 21 | // give addons a chance to autoload their stages too |
| 22 | 22 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_6_0__autoloaded_stages', $class_to_filepath); |
@@ -35,69 +35,69 @@ discard block |
||
| 35 | 35 | class EE_DMS_Core_4_6_0 extends EE_Data_Migration_Script_Base |
| 36 | 36 | { |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * return EE_DMS_Core_4_6_0 |
|
| 40 | - * |
|
| 41 | - * @param TableManager $table_manager |
|
| 42 | - * @param TableAnalysis $table_analysis |
|
| 43 | - */ |
|
| 44 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
| 45 | - { |
|
| 46 | - $this->_pretty_name = __("Data Update to Event Espresso 4.6.0", "event_espresso"); |
|
| 47 | - $this->_priority = 10; |
|
| 48 | - $this->_migration_stages = array( |
|
| 49 | - new EE_DMS_4_6_0_gateways(), |
|
| 50 | - new EE_DMS_4_6_0_question_types(), |
|
| 51 | - new EE_DMS_4_6_0_country_system_question(), |
|
| 52 | - new EE_DMS_4_6_0_state_system_question(), |
|
| 53 | - new EE_DMS_4_6_0_billing_info(), |
|
| 54 | - new EE_DMS_4_6_0_transactions(), |
|
| 55 | - new EE_DMS_4_6_0_payments(), |
|
| 56 | - new EE_DMS_4_6_0_invoice_settings(), |
|
| 57 | - ); |
|
| 58 | - parent::__construct($table_manager, $table_analysis); |
|
| 59 | - } |
|
| 38 | + /** |
|
| 39 | + * return EE_DMS_Core_4_6_0 |
|
| 40 | + * |
|
| 41 | + * @param TableManager $table_manager |
|
| 42 | + * @param TableAnalysis $table_analysis |
|
| 43 | + */ |
|
| 44 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
| 45 | + { |
|
| 46 | + $this->_pretty_name = __("Data Update to Event Espresso 4.6.0", "event_espresso"); |
|
| 47 | + $this->_priority = 10; |
|
| 48 | + $this->_migration_stages = array( |
|
| 49 | + new EE_DMS_4_6_0_gateways(), |
|
| 50 | + new EE_DMS_4_6_0_question_types(), |
|
| 51 | + new EE_DMS_4_6_0_country_system_question(), |
|
| 52 | + new EE_DMS_4_6_0_state_system_question(), |
|
| 53 | + new EE_DMS_4_6_0_billing_info(), |
|
| 54 | + new EE_DMS_4_6_0_transactions(), |
|
| 55 | + new EE_DMS_4_6_0_payments(), |
|
| 56 | + new EE_DMS_4_6_0_invoice_settings(), |
|
| 57 | + ); |
|
| 58 | + parent::__construct($table_manager, $table_analysis); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | 61 | |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @param array $version_array |
|
| 65 | - * @return bool |
|
| 66 | - */ |
|
| 67 | - public function can_migrate_from_version($version_array) |
|
| 68 | - { |
|
| 69 | - $version_string = $version_array['Core']; |
|
| 70 | - if (version_compare($version_string, '4.6.0.decaf', '<') && version_compare($version_string, '4.5.0.decaf', '>=')) { |
|
| 63 | + /** |
|
| 64 | + * @param array $version_array |
|
| 65 | + * @return bool |
|
| 66 | + */ |
|
| 67 | + public function can_migrate_from_version($version_array) |
|
| 68 | + { |
|
| 69 | + $version_string = $version_array['Core']; |
|
| 70 | + if (version_compare($version_string, '4.6.0.decaf', '<') && version_compare($version_string, '4.5.0.decaf', '>=')) { |
|
| 71 | 71 | // echo "$version_string can be migrated from"; |
| 72 | - return true; |
|
| 73 | - } elseif (! $version_string) { |
|
| 72 | + return true; |
|
| 73 | + } elseif (! $version_string) { |
|
| 74 | 74 | // echo "no version string provided: $version_string"; |
| 75 | - // no version string provided... this must be pre 4.3 |
|
| 76 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 77 | - } else { |
|
| 75 | + // no version string provided... this must be pre 4.3 |
|
| 76 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 77 | + } else { |
|
| 78 | 78 | // echo "$version_string doesnt apply"; |
| 79 | - return false; |
|
| 80 | - } |
|
| 81 | - } |
|
| 79 | + return false; |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | 83 | |
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * @return bool |
|
| 87 | - */ |
|
| 88 | - public function schema_changes_before_migration() |
|
| 89 | - { |
|
| 90 | - // relies on 4.1's EEH_Activation::create_table |
|
| 91 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 92 | - $table_name = 'esp_answer'; |
|
| 93 | - $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 85 | + /** |
|
| 86 | + * @return bool |
|
| 87 | + */ |
|
| 88 | + public function schema_changes_before_migration() |
|
| 89 | + { |
|
| 90 | + // relies on 4.1's EEH_Activation::create_table |
|
| 91 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 92 | + $table_name = 'esp_answer'; |
|
| 93 | + $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 94 | 94 | REG_ID int(10) unsigned NOT NULL, |
| 95 | 95 | QST_ID int(10) unsigned NOT NULL, |
| 96 | 96 | ANS_value text NOT NULL, |
| 97 | 97 | PRIMARY KEY (ANS_ID)"; |
| 98 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 99 | - $table_name = 'esp_attendee_meta'; |
|
| 100 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 98 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 99 | + $table_name = 'esp_attendee_meta'; |
|
| 100 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 101 | 101 | ATT_ID bigint(20) unsigned NOT NULL, |
| 102 | 102 | ATT_fname varchar(45) NOT NULL, |
| 103 | 103 | ATT_lname varchar(45) NOT NULL, |
@@ -113,9 +113,9 @@ discard block |
||
| 113 | 113 | KEY ATT_fname (ATT_fname), |
| 114 | 114 | KEY ATT_lname (ATT_lname), |
| 115 | 115 | KEY ATT_email (ATT_email(191))"; |
| 116 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 117 | - $table_name = 'esp_country'; |
|
| 118 | - $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
| 116 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 117 | + $table_name = 'esp_country'; |
|
| 118 | + $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
| 119 | 119 | CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL, |
| 120 | 120 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
| 121 | 121 | CNT_name varchar(45) COLLATE utf8_bin NOT NULL, |
@@ -131,24 +131,24 @@ discard block |
||
| 131 | 131 | CNT_is_EU tinyint(1) DEFAULT '0', |
| 132 | 132 | CNT_active tinyint(1) DEFAULT '0', |
| 133 | 133 | PRIMARY KEY (CNT_ISO)"; |
| 134 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 135 | - $table_name = 'esp_currency'; |
|
| 136 | - $sql = "CUR_code varchar(6) COLLATE utf8_bin NOT NULL, |
|
| 134 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 135 | + $table_name = 'esp_currency'; |
|
| 136 | + $sql = "CUR_code varchar(6) COLLATE utf8_bin NOT NULL, |
|
| 137 | 137 | CUR_single varchar(45) COLLATE utf8_bin DEFAULT 'dollar', |
| 138 | 138 | CUR_plural varchar(45) COLLATE utf8_bin DEFAULT 'dollars', |
| 139 | 139 | CUR_sign varchar(45) COLLATE utf8_bin DEFAULT '$', |
| 140 | 140 | CUR_dec_plc varchar(1) COLLATE utf8_bin NOT NULL DEFAULT '2', |
| 141 | 141 | CUR_active tinyint(1) DEFAULT '0', |
| 142 | 142 | PRIMARY KEY (CUR_code)"; |
| 143 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 144 | - $table_name = 'esp_currency_payment_method'; |
|
| 145 | - $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 143 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 144 | + $table_name = 'esp_currency_payment_method'; |
|
| 145 | + $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 146 | 146 | CUR_code varchar(6) COLLATE utf8_bin NOT NULL, |
| 147 | 147 | PMD_ID int(11) NOT NULL, |
| 148 | 148 | PRIMARY KEY (CPM_ID)"; |
| 149 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 150 | - $table_name = 'esp_datetime'; |
|
| 151 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 149 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 150 | + $table_name = 'esp_datetime'; |
|
| 151 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 152 | 152 | EVT_ID bigint(20) unsigned NOT NULL, |
| 153 | 153 | DTT_name varchar(255) NOT NULL DEFAULT '', |
| 154 | 154 | DTT_description text NOT NULL, |
@@ -163,9 +163,9 @@ discard block |
||
| 163 | 163 | PRIMARY KEY (DTT_ID), |
| 164 | 164 | KEY EVT_ID (EVT_ID), |
| 165 | 165 | KEY DTT_is_primary (DTT_is_primary)"; |
| 166 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 167 | - $table_name = 'esp_event_meta'; |
|
| 168 | - $sql = " |
|
| 166 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 167 | + $table_name = 'esp_event_meta'; |
|
| 168 | + $sql = " |
|
| 169 | 169 | EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
| 170 | 170 | EVT_ID bigint(20) unsigned NOT NULL, |
| 171 | 171 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -180,31 +180,31 @@ discard block |
||
| 180 | 180 | EVT_external_URL varchar(200) NULL, |
| 181 | 181 | EVT_donations tinyint(1) NULL, |
| 182 | 182 | PRIMARY KEY (EVTM_ID)"; |
| 183 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 184 | - $table_name = 'esp_event_question_group'; |
|
| 185 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 183 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 184 | + $table_name = 'esp_event_question_group'; |
|
| 185 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 186 | 186 | EVT_ID bigint(20) unsigned NOT NULL, |
| 187 | 187 | QSG_ID int(10) unsigned NOT NULL, |
| 188 | 188 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
| 189 | 189 | PRIMARY KEY (EQG_ID)"; |
| 190 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 191 | - $table_name = 'esp_event_venue'; |
|
| 192 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 190 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 191 | + $table_name = 'esp_event_venue'; |
|
| 192 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 193 | 193 | EVT_ID bigint(20) unsigned NOT NULL, |
| 194 | 194 | VNU_ID bigint(20) unsigned NOT NULL, |
| 195 | 195 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
| 196 | 196 | PRIMARY KEY (EVV_ID)"; |
| 197 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 198 | - $table_name = 'esp_extra_meta'; |
|
| 199 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 197 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 198 | + $table_name = 'esp_extra_meta'; |
|
| 199 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 200 | 200 | OBJ_ID int(11) DEFAULT NULL, |
| 201 | 201 | EXM_type varchar(45) DEFAULT NULL, |
| 202 | 202 | EXM_key varchar(45) DEFAULT NULL, |
| 203 | 203 | EXM_value text, |
| 204 | 204 | PRIMARY KEY (EXM_ID)"; |
| 205 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 206 | - $table_name = 'esp_line_item'; |
|
| 207 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 205 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 206 | + $table_name = 'esp_line_item'; |
|
| 207 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 208 | 208 | LIN_code varchar(245) NOT NULL DEFAULT '', |
| 209 | 209 | TXN_ID int(11) DEFAULT NULL, |
| 210 | 210 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -220,9 +220,9 @@ discard block |
||
| 220 | 220 | OBJ_ID int(11) DEFAULT NULL, |
| 221 | 221 | OBJ_type varchar(45)DEFAULT NULL, |
| 222 | 222 | PRIMARY KEY (LIN_ID)"; |
| 223 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 224 | - $table_name = 'esp_log'; |
|
| 225 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 223 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 224 | + $table_name = 'esp_log'; |
|
| 225 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 226 | 226 | LOG_time datetime DEFAULT NULL, |
| 227 | 227 | OBJ_ID varchar(45) DEFAULT NULL, |
| 228 | 228 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -230,19 +230,19 @@ discard block |
||
| 230 | 230 | LOG_message text, |
| 231 | 231 | LOG_wp_user int(11) DEFAULT NULL, |
| 232 | 232 | PRIMARY KEY (LOG_ID)"; |
| 233 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 234 | - $table_name = 'esp_message_template'; |
|
| 235 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 233 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 234 | + $table_name = 'esp_message_template'; |
|
| 235 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 236 | 236 | GRP_ID int(10) unsigned NOT NULL, |
| 237 | 237 | MTP_context varchar(50) NOT NULL, |
| 238 | 238 | MTP_template_field varchar(30) NOT NULL, |
| 239 | 239 | MTP_content text NOT NULL, |
| 240 | 240 | PRIMARY KEY (MTP_ID), |
| 241 | 241 | KEY GRP_ID (GRP_ID)"; |
| 242 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 243 | - $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
| 244 | - $table_name = 'esp_message_template_group'; |
|
| 245 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 242 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 243 | + $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
| 244 | + $table_name = 'esp_message_template_group'; |
|
| 245 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 246 | 246 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
| 247 | 247 | MTP_name varchar(245) NOT NULL DEFAULT '', |
| 248 | 248 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -254,17 +254,17 @@ discard block |
||
| 254 | 254 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
| 255 | 255 | PRIMARY KEY (GRP_ID), |
| 256 | 256 | KEY MTP_user_id (MTP_user_id)"; |
| 257 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 258 | - $table_name = 'esp_event_message_template'; |
|
| 259 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 257 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 258 | + $table_name = 'esp_event_message_template'; |
|
| 259 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 260 | 260 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
| 261 | 261 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
| 262 | 262 | PRIMARY KEY (EMT_ID), |
| 263 | 263 | KEY EVT_ID (EVT_ID), |
| 264 | 264 | KEY GRP_ID (GRP_ID)"; |
| 265 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 266 | - $table_name = 'esp_payment'; |
|
| 267 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 265 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 266 | + $table_name = 'esp_payment'; |
|
| 267 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 268 | 268 | TXN_ID int(10) unsigned DEFAULT NULL, |
| 269 | 269 | STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL, |
| 270 | 270 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -281,9 +281,9 @@ discard block |
||
| 281 | 281 | PRIMARY KEY (PAY_ID), |
| 282 | 282 | KEY TXN_ID (TXN_ID), |
| 283 | 283 | KEY PAY_timestamp (PAY_timestamp)"; |
| 284 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 285 | - $table_name = 'esp_payment_method'; |
|
| 286 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 284 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 285 | + $table_name = 'esp_payment_method'; |
|
| 286 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 287 | 287 | PMD_type varchar(124) DEFAULT NULL, |
| 288 | 288 | PMD_name varchar(255) DEFAULT NULL, |
| 289 | 289 | PMD_desc text, |
@@ -298,28 +298,28 @@ discard block |
||
| 298 | 298 | PMD_scope varchar(255) NULL DEFAULT 'frontend', |
| 299 | 299 | PRIMARY KEY (PMD_ID), |
| 300 | 300 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug)"; |
| 301 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 302 | - $table_name = "esp_ticket_price"; |
|
| 303 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 301 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 302 | + $table_name = "esp_ticket_price"; |
|
| 303 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 304 | 304 | TKT_ID int(10) unsigned NOT NULL, |
| 305 | 305 | PRC_ID int(10) unsigned NOT NULL, |
| 306 | 306 | PRIMARY KEY (TKP_ID)"; |
| 307 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 308 | - $table_name = "esp_datetime_ticket"; |
|
| 309 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 307 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 308 | + $table_name = "esp_datetime_ticket"; |
|
| 309 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 310 | 310 | DTT_ID int(10) unsigned NOT NULL, |
| 311 | 311 | TKT_ID int(10) unsigned NOT NULL, |
| 312 | 312 | PRIMARY KEY (DTK_ID)"; |
| 313 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 314 | - $table_name = "esp_ticket_template"; |
|
| 315 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 313 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 314 | + $table_name = "esp_ticket_template"; |
|
| 315 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 316 | 316 | TTM_name varchar(45) NOT NULL, |
| 317 | 317 | TTM_description text, |
| 318 | 318 | TTM_file varchar(45), |
| 319 | 319 | PRIMARY KEY (TTM_ID)"; |
| 320 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 321 | - $table_name = 'esp_question'; |
|
| 322 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 320 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 321 | + $table_name = 'esp_question'; |
|
| 322 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 323 | 323 | QST_display_text text NOT NULL, |
| 324 | 324 | QST_admin_label varchar(255) NOT NULL, |
| 325 | 325 | QST_system varchar(25) DEFAULT NULL, |
@@ -331,25 +331,25 @@ discard block |
||
| 331 | 331 | QST_wp_user bigint(20) unsigned NULL, |
| 332 | 332 | QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
| 333 | 333 | PRIMARY KEY (QST_ID)'; |
| 334 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 335 | - $table_name = 'esp_question_group_question'; |
|
| 336 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 334 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 335 | + $table_name = 'esp_question_group_question'; |
|
| 336 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 337 | 337 | QSG_ID int(10) unsigned NOT NULL, |
| 338 | 338 | QST_ID int(10) unsigned NOT NULL, |
| 339 | 339 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
| 340 | 340 | PRIMARY KEY (QGQ_ID) "; |
| 341 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 342 | - $table_name = 'esp_question_option'; |
|
| 343 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 341 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 342 | + $table_name = 'esp_question_option'; |
|
| 343 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 344 | 344 | QSO_value varchar(255) NOT NULL, |
| 345 | 345 | QSO_desc text NOT NULL, |
| 346 | 346 | QST_ID int(10) unsigned NOT NULL, |
| 347 | 347 | QSO_order int(10) unsigned NOT NULL DEFAULT 0, |
| 348 | 348 | QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
| 349 | 349 | PRIMARY KEY (QSO_ID)"; |
| 350 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 351 | - $table_name = 'esp_registration'; |
|
| 352 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 350 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 351 | + $table_name = 'esp_registration'; |
|
| 352 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 353 | 353 | EVT_ID bigint(20) unsigned NOT NULL, |
| 354 | 354 | ATT_ID bigint(20) unsigned NOT NULL, |
| 355 | 355 | TXN_ID int(10) unsigned NOT NULL, |
@@ -372,25 +372,25 @@ discard block |
||
| 372 | 372 | KEY STS_ID (STS_ID), |
| 373 | 373 | KEY REG_url_link (REG_url_link), |
| 374 | 374 | KEY REG_code (REG_code)"; |
| 375 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 376 | - $table_name = 'esp_checkin'; |
|
| 377 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 375 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 376 | + $table_name = 'esp_checkin'; |
|
| 377 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 378 | 378 | REG_ID int(10) unsigned NOT NULL, |
| 379 | 379 | DTT_ID int(10) unsigned NOT NULL, |
| 380 | 380 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
| 381 | 381 | CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
| 382 | 382 | PRIMARY KEY (CHK_ID)"; |
| 383 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 384 | - $table_name = 'esp_state'; |
|
| 385 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
| 383 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 384 | + $table_name = 'esp_state'; |
|
| 385 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
| 386 | 386 | CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
| 387 | 387 | STA_abbrev varchar(24) COLLATE utf8_bin NOT NULL, |
| 388 | 388 | STA_name varchar(100) COLLATE utf8_bin NOT NULL, |
| 389 | 389 | STA_active tinyint(1) DEFAULT '1', |
| 390 | 390 | PRIMARY KEY (STA_ID)"; |
| 391 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 392 | - $table_name = 'esp_status'; |
|
| 393 | - $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
| 391 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 392 | + $table_name = 'esp_status'; |
|
| 393 | + $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
| 394 | 394 | STS_code varchar(45) COLLATE utf8_bin NOT NULL, |
| 395 | 395 | STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL, |
| 396 | 396 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -398,9 +398,9 @@ discard block |
||
| 398 | 398 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
| 399 | 399 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
| 400 | 400 | KEY STS_type (STS_type)"; |
| 401 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 402 | - $table_name = 'esp_transaction'; |
|
| 403 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 401 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 402 | + $table_name = 'esp_transaction'; |
|
| 403 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 404 | 404 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
| 405 | 405 | TXN_total decimal(10,3) DEFAULT '0.00', |
| 406 | 406 | TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00', |
@@ -412,9 +412,9 @@ discard block |
||
| 412 | 412 | PRIMARY KEY (TXN_ID), |
| 413 | 413 | KEY TXN_timestamp (TXN_timestamp), |
| 414 | 414 | KEY STS_ID (STS_ID)"; |
| 415 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 416 | - $table_name = 'esp_venue_meta'; |
|
| 417 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 415 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 416 | + $table_name = 'esp_venue_meta'; |
|
| 417 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 418 | 418 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
| 419 | 419 | VNU_address varchar(255) DEFAULT NULL, |
| 420 | 420 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -432,10 +432,10 @@ discard block |
||
| 432 | 432 | PRIMARY KEY (VNUM_ID), |
| 433 | 433 | KEY STA_ID (STA_ID), |
| 434 | 434 | KEY CNT_ISO (CNT_ISO)"; |
| 435 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 436 | - // modified tables |
|
| 437 | - $table_name = "esp_price"; |
|
| 438 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 435 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 436 | + // modified tables |
|
| 437 | + $table_name = "esp_price"; |
|
| 438 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 439 | 439 | PRT_ID tinyint(3) unsigned NOT NULL, |
| 440 | 440 | PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
| 441 | 441 | PRC_name varchar(245) NOT NULL, |
@@ -447,9 +447,9 @@ discard block |
||
| 447 | 447 | PRC_wp_user bigint(20) unsigned NULL, |
| 448 | 448 | PRC_parent int(10) unsigned DEFAULT 0, |
| 449 | 449 | PRIMARY KEY (PRC_ID)"; |
| 450 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 451 | - $table_name = "esp_price_type"; |
|
| 452 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
| 450 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 451 | + $table_name = "esp_price_type"; |
|
| 452 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
| 453 | 453 | PRT_name varchar(45) NOT NULL, |
| 454 | 454 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
| 455 | 455 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -458,9 +458,9 @@ discard block |
||
| 458 | 458 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
| 459 | 459 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
| 460 | 460 | PRIMARY KEY (PRT_ID)"; |
| 461 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 462 | - $table_name = "esp_ticket"; |
|
| 463 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 461 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 462 | + $table_name = "esp_ticket"; |
|
| 463 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 464 | 464 | TTM_ID int(10) unsigned NOT NULL, |
| 465 | 465 | TKT_name varchar(245) NOT NULL DEFAULT '', |
| 466 | 466 | TKT_description text NOT NULL, |
@@ -481,10 +481,10 @@ discard block |
||
| 481 | 481 | TKT_parent int(10) unsigned DEFAULT '0', |
| 482 | 482 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
| 483 | 483 | PRIMARY KEY (TKT_ID)"; |
| 484 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 485 | - $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
| 486 | - $table_name = 'esp_question_group'; |
|
| 487 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 484 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 485 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
| 486 | + $table_name = 'esp_question_group'; |
|
| 487 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 488 | 488 | QSG_name varchar(255) NOT NULL, |
| 489 | 489 | QSG_identifier varchar(100) NOT NULL, |
| 490 | 490 | QSG_desc text NULL, |
@@ -496,124 +496,124 @@ discard block |
||
| 496 | 496 | QSG_wp_user bigint(20) unsigned NULL, |
| 497 | 497 | PRIMARY KEY (QSG_ID), |
| 498 | 498 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
| 499 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 500 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
| 501 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
| 502 | - // (because many need to convert old string states to foreign keys into the states table) |
|
| 503 | - $script_4_1_defaults->insert_default_states(); |
|
| 504 | - $script_4_1_defaults->insert_default_countries(); |
|
| 505 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
| 506 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
| 507 | - $script_4_5_defaults->insert_default_price_types(); |
|
| 508 | - $script_4_5_defaults->insert_default_prices(); |
|
| 509 | - $script_4_5_defaults->insert_default_tickets(); |
|
| 510 | - // setting up the config wp option pretty well counts as a 'schema change', or at least should happen here |
|
| 511 | - EE_Config::instance()->update_espresso_config(false, true); |
|
| 512 | - $this->add_default_admin_only_payments(); |
|
| 513 | - $this->insert_default_currencies(); |
|
| 514 | - return true; |
|
| 515 | - } |
|
| 499 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 500 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
| 501 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
| 502 | + // (because many need to convert old string states to foreign keys into the states table) |
|
| 503 | + $script_4_1_defaults->insert_default_states(); |
|
| 504 | + $script_4_1_defaults->insert_default_countries(); |
|
| 505 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
| 506 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
| 507 | + $script_4_5_defaults->insert_default_price_types(); |
|
| 508 | + $script_4_5_defaults->insert_default_prices(); |
|
| 509 | + $script_4_5_defaults->insert_default_tickets(); |
|
| 510 | + // setting up the config wp option pretty well counts as a 'schema change', or at least should happen here |
|
| 511 | + EE_Config::instance()->update_espresso_config(false, true); |
|
| 512 | + $this->add_default_admin_only_payments(); |
|
| 513 | + $this->insert_default_currencies(); |
|
| 514 | + return true; |
|
| 515 | + } |
|
| 516 | 516 | |
| 517 | 517 | |
| 518 | 518 | |
| 519 | - /** |
|
| 520 | - * @return boolean |
|
| 521 | - */ |
|
| 522 | - public function schema_changes_after_migration() |
|
| 523 | - { |
|
| 524 | - return true; |
|
| 525 | - } |
|
| 519 | + /** |
|
| 520 | + * @return boolean |
|
| 521 | + */ |
|
| 522 | + public function schema_changes_after_migration() |
|
| 523 | + { |
|
| 524 | + return true; |
|
| 525 | + } |
|
| 526 | 526 | |
| 527 | 527 | |
| 528 | 528 | |
| 529 | - public function migration_page_hooks() |
|
| 530 | - { |
|
| 531 | - } |
|
| 529 | + public function migration_page_hooks() |
|
| 530 | + { |
|
| 531 | + } |
|
| 532 | 532 | |
| 533 | 533 | |
| 534 | 534 | |
| 535 | - public function add_default_admin_only_payments() |
|
| 536 | - { |
|
| 537 | - global $wpdb; |
|
| 538 | - $table_name = $wpdb->prefix . "esp_payment_method"; |
|
| 539 | - $user_id = EEH_Activation::get_default_creator_id(); |
|
| 540 | - if ($this->_get_table_analysis()->tableExists($table_name)) { |
|
| 541 | - $SQL = "SELECT COUNT( * ) FROM $table_name"; |
|
| 542 | - $existing_payment_methods = $wpdb->get_var($SQL); |
|
| 543 | - $default_admin_only_payment_methods = apply_filters( |
|
| 544 | - 'FHEE__EEH_Activation__add_default_admin_only_payments__default_admin_only_payment_methods', |
|
| 545 | - array( |
|
| 546 | - (string) __("Bank", 'event_espresso') => __("Bank Draft", 'event_espresso'), |
|
| 547 | - (string) __("Cash", 'event_espresso') => __("Cash Delivered Physically", 'event_espresso'), |
|
| 548 | - (string) __("Check", 'event_espresso') => __("Paper Check", 'event_espresso'), |
|
| 549 | - (string) __("Credit Card", 'event_espresso') => __("Offline Credit Card Payment", 'event_espresso'), |
|
| 550 | - (string) __("Debit Card", 'event_espresso') => __("Offline Debit Payment", 'event_espresso'), |
|
| 551 | - (string) __("Invoice", 'event_espresso') => __( |
|
| 552 | - "Invoice received with monies included", |
|
| 553 | - 'event_espresso' |
|
| 554 | - ), |
|
| 555 | - (string) __("Money Order", 'event_espresso') => '', |
|
| 556 | - (string) __("Paypal", 'event_espresso') => __("Paypal eCheck, Invoice, etc", 'event_espresso'), |
|
| 557 | - (string) __('Other', 'event_espresso') => __('Other method of payment', 'event_espresso'), |
|
| 558 | - ) |
|
| 559 | - ); |
|
| 560 | - // make sure we hae payment method records for the following |
|
| 561 | - // so admins can record payments for them from the admin page |
|
| 562 | - foreach ($default_admin_only_payment_methods as $nicename => $description) { |
|
| 563 | - $slug = sanitize_key($nicename); |
|
| 564 | - // check that such a payment method exists |
|
| 565 | - $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug)); |
|
| 566 | - if (! $exists) { |
|
| 567 | - $values = array( |
|
| 568 | - 'PMD_type' => 'Admin_Only', |
|
| 569 | - 'PMD_name' => $nicename, |
|
| 570 | - 'PMD_admin_name' => $nicename, |
|
| 571 | - 'PMD_admin_desc' => $description, |
|
| 572 | - 'PMD_slug' => $slug, |
|
| 573 | - 'PMD_wp_user' => $user_id, |
|
| 574 | - 'PMD_scope' => serialize(array('ADMIN')), |
|
| 575 | - ); |
|
| 576 | - $success = $wpdb->insert( |
|
| 577 | - $table_name, |
|
| 578 | - $values, |
|
| 579 | - array( |
|
| 580 | - '%s',// PMD_type |
|
| 581 | - '%s',// PMD_name |
|
| 582 | - '%s',// PMD_admin_name |
|
| 583 | - '%s',// PMD_admin_desc |
|
| 584 | - '%s',// PMD_slug |
|
| 585 | - '%d',// PMD_wp_user |
|
| 586 | - '%s',// PMD_scope |
|
| 587 | - ) |
|
| 588 | - ); |
|
| 589 | - if (! $success) { |
|
| 590 | - $this->add_error(sprintf(__( |
|
| 591 | - "Could not insert new admin-only payment method with values %s during migration", |
|
| 592 | - "event_espresso" |
|
| 593 | - ), $this->_json_encode($values))); |
|
| 594 | - } |
|
| 595 | - } |
|
| 596 | - } |
|
| 597 | - } |
|
| 598 | - } |
|
| 535 | + public function add_default_admin_only_payments() |
|
| 536 | + { |
|
| 537 | + global $wpdb; |
|
| 538 | + $table_name = $wpdb->prefix . "esp_payment_method"; |
|
| 539 | + $user_id = EEH_Activation::get_default_creator_id(); |
|
| 540 | + if ($this->_get_table_analysis()->tableExists($table_name)) { |
|
| 541 | + $SQL = "SELECT COUNT( * ) FROM $table_name"; |
|
| 542 | + $existing_payment_methods = $wpdb->get_var($SQL); |
|
| 543 | + $default_admin_only_payment_methods = apply_filters( |
|
| 544 | + 'FHEE__EEH_Activation__add_default_admin_only_payments__default_admin_only_payment_methods', |
|
| 545 | + array( |
|
| 546 | + (string) __("Bank", 'event_espresso') => __("Bank Draft", 'event_espresso'), |
|
| 547 | + (string) __("Cash", 'event_espresso') => __("Cash Delivered Physically", 'event_espresso'), |
|
| 548 | + (string) __("Check", 'event_espresso') => __("Paper Check", 'event_espresso'), |
|
| 549 | + (string) __("Credit Card", 'event_espresso') => __("Offline Credit Card Payment", 'event_espresso'), |
|
| 550 | + (string) __("Debit Card", 'event_espresso') => __("Offline Debit Payment", 'event_espresso'), |
|
| 551 | + (string) __("Invoice", 'event_espresso') => __( |
|
| 552 | + "Invoice received with monies included", |
|
| 553 | + 'event_espresso' |
|
| 554 | + ), |
|
| 555 | + (string) __("Money Order", 'event_espresso') => '', |
|
| 556 | + (string) __("Paypal", 'event_espresso') => __("Paypal eCheck, Invoice, etc", 'event_espresso'), |
|
| 557 | + (string) __('Other', 'event_espresso') => __('Other method of payment', 'event_espresso'), |
|
| 558 | + ) |
|
| 559 | + ); |
|
| 560 | + // make sure we hae payment method records for the following |
|
| 561 | + // so admins can record payments for them from the admin page |
|
| 562 | + foreach ($default_admin_only_payment_methods as $nicename => $description) { |
|
| 563 | + $slug = sanitize_key($nicename); |
|
| 564 | + // check that such a payment method exists |
|
| 565 | + $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug)); |
|
| 566 | + if (! $exists) { |
|
| 567 | + $values = array( |
|
| 568 | + 'PMD_type' => 'Admin_Only', |
|
| 569 | + 'PMD_name' => $nicename, |
|
| 570 | + 'PMD_admin_name' => $nicename, |
|
| 571 | + 'PMD_admin_desc' => $description, |
|
| 572 | + 'PMD_slug' => $slug, |
|
| 573 | + 'PMD_wp_user' => $user_id, |
|
| 574 | + 'PMD_scope' => serialize(array('ADMIN')), |
|
| 575 | + ); |
|
| 576 | + $success = $wpdb->insert( |
|
| 577 | + $table_name, |
|
| 578 | + $values, |
|
| 579 | + array( |
|
| 580 | + '%s',// PMD_type |
|
| 581 | + '%s',// PMD_name |
|
| 582 | + '%s',// PMD_admin_name |
|
| 583 | + '%s',// PMD_admin_desc |
|
| 584 | + '%s',// PMD_slug |
|
| 585 | + '%d',// PMD_wp_user |
|
| 586 | + '%s',// PMD_scope |
|
| 587 | + ) |
|
| 588 | + ); |
|
| 589 | + if (! $success) { |
|
| 590 | + $this->add_error(sprintf(__( |
|
| 591 | + "Could not insert new admin-only payment method with values %s during migration", |
|
| 592 | + "event_espresso" |
|
| 593 | + ), $this->_json_encode($values))); |
|
| 594 | + } |
|
| 595 | + } |
|
| 596 | + } |
|
| 597 | + } |
|
| 598 | + } |
|
| 599 | 599 | |
| 600 | 600 | |
| 601 | 601 | |
| 602 | - /** |
|
| 603 | - * insert_default_countries |
|
| 604 | - * |
|
| 605 | - * @static |
|
| 606 | - * @return void |
|
| 607 | - */ |
|
| 608 | - public function insert_default_currencies() |
|
| 609 | - { |
|
| 610 | - global $wpdb; |
|
| 611 | - $currency_table = $wpdb->prefix . "esp_currency"; |
|
| 612 | - if ($this->_get_table_analysis()->tableExists($currency_table)) { |
|
| 613 | - $SQL = "SELECT COUNT('CUR_code') FROM $currency_table"; |
|
| 614 | - $countries = $wpdb->get_var($SQL); |
|
| 615 | - if (! $countries) { |
|
| 616 | - $SQL = "INSERT INTO $currency_table |
|
| 602 | + /** |
|
| 603 | + * insert_default_countries |
|
| 604 | + * |
|
| 605 | + * @static |
|
| 606 | + * @return void |
|
| 607 | + */ |
|
| 608 | + public function insert_default_currencies() |
|
| 609 | + { |
|
| 610 | + global $wpdb; |
|
| 611 | + $currency_table = $wpdb->prefix . "esp_currency"; |
|
| 612 | + if ($this->_get_table_analysis()->tableExists($currency_table)) { |
|
| 613 | + $SQL = "SELECT COUNT('CUR_code') FROM $currency_table"; |
|
| 614 | + $countries = $wpdb->get_var($SQL); |
|
| 615 | + if (! $countries) { |
|
| 616 | + $SQL = "INSERT INTO $currency_table |
|
| 617 | 617 | ( CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active) VALUES |
| 618 | 618 | ( 'EUR', 'Euro', 'Euros', '€', 2,1), |
| 619 | 619 | ( 'AED', 'Dirham', 'Dirhams', 'د.إ',2,1), |
@@ -767,8 +767,8 @@ discard block |
||
| 767 | 767 | ( 'ZAR', 'Rand', 'Rands', 'R', 2,1), |
| 768 | 768 | ( 'ZMK', 'Kwacha', 'Kwachas', '', 2,1), |
| 769 | 769 | ( 'ZWD', 'Dollar', 'Dollars', 'Z$', 2,1);"; |
| 770 | - $wpdb->query($SQL); |
|
| 771 | - } |
|
| 772 | - } |
|
| 773 | - } |
|
| 770 | + $wpdb->query($SQL); |
|
| 771 | + } |
|
| 772 | + } |
|
| 773 | + } |
|
| 774 | 774 | } |
@@ -11,12 +11,12 @@ discard block |
||
| 11 | 11 | // unfortunately, this needs to be done upon INCLUSION of this file, |
| 12 | 12 | // instead of construction, because it only gets constructed on first page load |
| 13 | 13 | // (all other times it gets resurrected from a wordpress option) |
| 14 | -$stages = glob(EE_CORE . 'data_migration_scripts/4_6_0_stages/*'); |
|
| 14 | +$stages = glob(EE_CORE.'data_migration_scripts/4_6_0_stages/*'); |
|
| 15 | 15 | $class_to_filepath = array(); |
| 16 | 16 | foreach ($stages as $filepath) { |
| 17 | 17 | $matches = array(); |
| 18 | 18 | preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
| 19 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
| 19 | + $class_to_filepath[$matches[1]] = $filepath; |
|
| 20 | 20 | } |
| 21 | 21 | // give addons a chance to autoload their stages too |
| 22 | 22 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_6_0__autoloaded_stages', $class_to_filepath); |
@@ -70,10 +70,10 @@ discard block |
||
| 70 | 70 | if (version_compare($version_string, '4.6.0.decaf', '<') && version_compare($version_string, '4.5.0.decaf', '>=')) { |
| 71 | 71 | // echo "$version_string can be migrated from"; |
| 72 | 72 | return true; |
| 73 | - } elseif (! $version_string) { |
|
| 73 | + } elseif ( ! $version_string) { |
|
| 74 | 74 | // echo "no version string provided: $version_string"; |
| 75 | 75 | // no version string provided... this must be pre 4.3 |
| 76 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 76 | + return false; // changed mind. dont want people thinking they should migrate yet because they cant |
|
| 77 | 77 | } else { |
| 78 | 78 | // echo "$version_string doesnt apply"; |
| 79 | 79 | return false; |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | public function schema_changes_before_migration() |
| 89 | 89 | { |
| 90 | 90 | // relies on 4.1's EEH_Activation::create_table |
| 91 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 91 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
| 92 | 92 | $table_name = 'esp_answer'; |
| 93 | 93 | $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
| 94 | 94 | REG_ID int(10) unsigned NOT NULL, |
@@ -535,7 +535,7 @@ discard block |
||
| 535 | 535 | public function add_default_admin_only_payments() |
| 536 | 536 | { |
| 537 | 537 | global $wpdb; |
| 538 | - $table_name = $wpdb->prefix . "esp_payment_method"; |
|
| 538 | + $table_name = $wpdb->prefix."esp_payment_method"; |
|
| 539 | 539 | $user_id = EEH_Activation::get_default_creator_id(); |
| 540 | 540 | if ($this->_get_table_analysis()->tableExists($table_name)) { |
| 541 | 541 | $SQL = "SELECT COUNT( * ) FROM $table_name"; |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | $slug = sanitize_key($nicename); |
| 564 | 564 | // check that such a payment method exists |
| 565 | 565 | $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug)); |
| 566 | - if (! $exists) { |
|
| 566 | + if ( ! $exists) { |
|
| 567 | 567 | $values = array( |
| 568 | 568 | 'PMD_type' => 'Admin_Only', |
| 569 | 569 | 'PMD_name' => $nicename, |
@@ -577,16 +577,16 @@ discard block |
||
| 577 | 577 | $table_name, |
| 578 | 578 | $values, |
| 579 | 579 | array( |
| 580 | - '%s',// PMD_type |
|
| 581 | - '%s',// PMD_name |
|
| 582 | - '%s',// PMD_admin_name |
|
| 583 | - '%s',// PMD_admin_desc |
|
| 584 | - '%s',// PMD_slug |
|
| 585 | - '%d',// PMD_wp_user |
|
| 586 | - '%s',// PMD_scope |
|
| 580 | + '%s', // PMD_type |
|
| 581 | + '%s', // PMD_name |
|
| 582 | + '%s', // PMD_admin_name |
|
| 583 | + '%s', // PMD_admin_desc |
|
| 584 | + '%s', // PMD_slug |
|
| 585 | + '%d', // PMD_wp_user |
|
| 586 | + '%s', // PMD_scope |
|
| 587 | 587 | ) |
| 588 | 588 | ); |
| 589 | - if (! $success) { |
|
| 589 | + if ( ! $success) { |
|
| 590 | 590 | $this->add_error(sprintf(__( |
| 591 | 591 | "Could not insert new admin-only payment method with values %s during migration", |
| 592 | 592 | "event_espresso" |
@@ -608,11 +608,11 @@ discard block |
||
| 608 | 608 | public function insert_default_currencies() |
| 609 | 609 | { |
| 610 | 610 | global $wpdb; |
| 611 | - $currency_table = $wpdb->prefix . "esp_currency"; |
|
| 611 | + $currency_table = $wpdb->prefix."esp_currency"; |
|
| 612 | 612 | if ($this->_get_table_analysis()->tableExists($currency_table)) { |
| 613 | 613 | $SQL = "SELECT COUNT('CUR_code') FROM $currency_table"; |
| 614 | 614 | $countries = $wpdb->get_var($SQL); |
| 615 | - if (! $countries) { |
|
| 615 | + if ( ! $countries) { |
|
| 616 | 616 | $SQL = "INSERT INTO $currency_table |
| 617 | 617 | ( CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active) VALUES |
| 618 | 618 | ( 'EUR', 'Euro', 'Euros', '€', 2,1), |
@@ -9,7 +9,6 @@ discard block |
||
| 9 | 9 | * and recalculates esp_registration.REG_final_price to actually be the final price |
| 10 | 10 | * for that registration (before this it was just the ticket's price, NOT including |
| 11 | 11 | * taxes or other price modifiers) |
| 12 | - |
|
| 13 | 12 | */ |
| 14 | 13 | // make sure we have all the stages loaded too |
| 15 | 14 | // unfortunately, this needs to be done upon INCLUSION of this file, |
@@ -18,9 +17,9 @@ discard block |
||
| 18 | 17 | $stages = glob(EE_CORE . 'data_migration_scripts/4_7_0_stages/*'); |
| 19 | 18 | $class_to_filepath = array(); |
| 20 | 19 | foreach ($stages as $filepath) { |
| 21 | - $matches = array(); |
|
| 22 | - preg_match('~4_7_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
| 23 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
| 20 | + $matches = array(); |
|
| 21 | + preg_match('~4_7_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
| 22 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
| 24 | 23 | } |
| 25 | 24 | // give addons a chance to autoload their stages too |
| 26 | 25 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_7_0__autoloaded_stages', $class_to_filepath); |
@@ -39,71 +38,71 @@ discard block |
||
| 39 | 38 | class EE_DMS_Core_4_7_0 extends EE_Data_Migration_Script_Base |
| 40 | 39 | { |
| 41 | 40 | |
| 42 | - /** |
|
| 43 | - * return EE_DMS_Core_4_7_0 |
|
| 44 | - * |
|
| 45 | - * @param TableManager $table_manager |
|
| 46 | - * @param TableAnalysis $table_analysis |
|
| 47 | - */ |
|
| 48 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
| 49 | - { |
|
| 50 | - $this->_pretty_name = __("Data Update to Event Espresso 4.7.0", "event_espresso"); |
|
| 51 | - $this->_priority = 10; |
|
| 52 | - $this->_migration_stages = array( |
|
| 53 | - new EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price(), |
|
| 54 | - new EE_DMS_4_7_0_Registration_Payments(), |
|
| 55 | - ); |
|
| 56 | - parent::__construct($table_manager, $table_analysis); |
|
| 57 | - } |
|
| 41 | + /** |
|
| 42 | + * return EE_DMS_Core_4_7_0 |
|
| 43 | + * |
|
| 44 | + * @param TableManager $table_manager |
|
| 45 | + * @param TableAnalysis $table_analysis |
|
| 46 | + */ |
|
| 47 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
| 48 | + { |
|
| 49 | + $this->_pretty_name = __("Data Update to Event Espresso 4.7.0", "event_espresso"); |
|
| 50 | + $this->_priority = 10; |
|
| 51 | + $this->_migration_stages = array( |
|
| 52 | + new EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price(), |
|
| 53 | + new EE_DMS_4_7_0_Registration_Payments(), |
|
| 54 | + ); |
|
| 55 | + parent::__construct($table_manager, $table_analysis); |
|
| 56 | + } |
|
| 58 | 57 | |
| 59 | 58 | |
| 60 | 59 | |
| 61 | - /** |
|
| 62 | - * @param array $version_array |
|
| 63 | - * @return bool |
|
| 64 | - */ |
|
| 65 | - public function can_migrate_from_version($version_array) |
|
| 66 | - { |
|
| 67 | - $version_string = $version_array['Core']; |
|
| 68 | - if (( |
|
| 69 | - version_compare($version_string, '4.7.0.decaf', '<') |
|
| 70 | - && version_compare($version_string, '4.6.0.decaf', '>=') |
|
| 71 | - ) |
|
| 72 | - || ( |
|
| 73 | - version_compare($version_string, '4.7.0.decaf', '>=') |
|
| 74 | - && ! $this->_get_table_analysis()->tableExists('esp_registration_payment') |
|
| 75 | - && $this->_get_table_analysis()->tableExists('esp_registration') |
|
| 76 | - ) |
|
| 77 | - ) { |
|
| 78 | - return true; |
|
| 79 | - } elseif (! $version_string) { |
|
| 80 | - // no version string provided... this must be pre 4.3 |
|
| 81 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 82 | - } else { |
|
| 83 | - return false; |
|
| 84 | - } |
|
| 85 | - } |
|
| 60 | + /** |
|
| 61 | + * @param array $version_array |
|
| 62 | + * @return bool |
|
| 63 | + */ |
|
| 64 | + public function can_migrate_from_version($version_array) |
|
| 65 | + { |
|
| 66 | + $version_string = $version_array['Core']; |
|
| 67 | + if (( |
|
| 68 | + version_compare($version_string, '4.7.0.decaf', '<') |
|
| 69 | + && version_compare($version_string, '4.6.0.decaf', '>=') |
|
| 70 | + ) |
|
| 71 | + || ( |
|
| 72 | + version_compare($version_string, '4.7.0.decaf', '>=') |
|
| 73 | + && ! $this->_get_table_analysis()->tableExists('esp_registration_payment') |
|
| 74 | + && $this->_get_table_analysis()->tableExists('esp_registration') |
|
| 75 | + ) |
|
| 76 | + ) { |
|
| 77 | + return true; |
|
| 78 | + } elseif (! $version_string) { |
|
| 79 | + // no version string provided... this must be pre 4.3 |
|
| 80 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 81 | + } else { |
|
| 82 | + return false; |
|
| 83 | + } |
|
| 84 | + } |
|
| 86 | 85 | |
| 87 | 86 | |
| 88 | 87 | |
| 89 | - /** |
|
| 90 | - * @return bool |
|
| 91 | - */ |
|
| 92 | - public function schema_changes_before_migration() |
|
| 93 | - { |
|
| 94 | - // relies on 4.1's EEH_Activation::create_table |
|
| 95 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 96 | - $table_name = 'esp_answer'; |
|
| 97 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 88 | + /** |
|
| 89 | + * @return bool |
|
| 90 | + */ |
|
| 91 | + public function schema_changes_before_migration() |
|
| 92 | + { |
|
| 93 | + // relies on 4.1's EEH_Activation::create_table |
|
| 94 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 95 | + $table_name = 'esp_answer'; |
|
| 96 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 98 | 97 | REG_ID int(10) unsigned NOT NULL, |
| 99 | 98 | QST_ID int(10) unsigned NOT NULL, |
| 100 | 99 | ANS_value text NOT NULL, |
| 101 | 100 | PRIMARY KEY (ANS_ID), |
| 102 | 101 | KEY REG_ID (REG_ID), |
| 103 | 102 | KEY QST_ID (QST_ID)"; |
| 104 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 105 | - $table_name = 'esp_attendee_meta'; |
|
| 106 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 103 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 104 | + $table_name = 'esp_attendee_meta'; |
|
| 105 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 107 | 106 | ATT_ID bigint(20) unsigned NOT NULL, |
| 108 | 107 | ATT_fname varchar(45) NOT NULL, |
| 109 | 108 | ATT_lname varchar(45) NOT NULL, |
@@ -120,9 +119,9 @@ discard block |
||
| 120 | 119 | KEY ATT_email (ATT_email(191)), |
| 121 | 120 | KEY ATT_lname (ATT_lname), |
| 122 | 121 | KEY ATT_fname (ATT_fname)"; |
| 123 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 124 | - $table_name = 'esp_country'; |
|
| 125 | - $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
| 122 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 123 | + $table_name = 'esp_country'; |
|
| 124 | + $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
| 126 | 125 | CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL, |
| 127 | 126 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
| 128 | 127 | CNT_name varchar(45) COLLATE utf8_bin NOT NULL, |
@@ -138,25 +137,25 @@ discard block |
||
| 138 | 137 | CNT_is_EU tinyint(1) DEFAULT '0', |
| 139 | 138 | CNT_active tinyint(1) DEFAULT '0', |
| 140 | 139 | PRIMARY KEY (CNT_ISO)"; |
| 141 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 142 | - $table_name = 'esp_currency'; |
|
| 143 | - $sql = "CUR_code varchar(6) COLLATE utf8_bin NOT NULL, |
|
| 140 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 141 | + $table_name = 'esp_currency'; |
|
| 142 | + $sql = "CUR_code varchar(6) COLLATE utf8_bin NOT NULL, |
|
| 144 | 143 | CUR_single varchar(45) COLLATE utf8_bin DEFAULT 'dollar', |
| 145 | 144 | CUR_plural varchar(45) COLLATE utf8_bin DEFAULT 'dollars', |
| 146 | 145 | CUR_sign varchar(45) COLLATE utf8_bin DEFAULT '$', |
| 147 | 146 | CUR_dec_plc varchar(1) COLLATE utf8_bin NOT NULL DEFAULT '2', |
| 148 | 147 | CUR_active tinyint(1) DEFAULT '0', |
| 149 | 148 | PRIMARY KEY (CUR_code)"; |
| 150 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 151 | - $table_name = 'esp_currency_payment_method'; |
|
| 152 | - $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 149 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 150 | + $table_name = 'esp_currency_payment_method'; |
|
| 151 | + $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 153 | 152 | CUR_code varchar(6) COLLATE utf8_bin NOT NULL, |
| 154 | 153 | PMD_ID int(11) NOT NULL, |
| 155 | 154 | PRIMARY KEY (CPM_ID), |
| 156 | 155 | KEY PMD_ID (PMD_ID)"; |
| 157 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 158 | - $table_name = 'esp_datetime'; |
|
| 159 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 156 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 157 | + $table_name = 'esp_datetime'; |
|
| 158 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 160 | 159 | EVT_ID bigint(20) unsigned NOT NULL, |
| 161 | 160 | DTT_name varchar(255) NOT NULL DEFAULT '', |
| 162 | 161 | DTT_description text NOT NULL, |
@@ -172,9 +171,9 @@ discard block |
||
| 172 | 171 | KEY DTT_EVT_start (DTT_EVT_start), |
| 173 | 172 | KEY EVT_ID (EVT_ID), |
| 174 | 173 | KEY DTT_is_primary (DTT_is_primary)"; |
| 175 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 176 | - $table_name = 'esp_event_meta'; |
|
| 177 | - $sql = " |
|
| 174 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 175 | + $table_name = 'esp_event_meta'; |
|
| 176 | + $sql = " |
|
| 178 | 177 | EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
| 179 | 178 | EVT_ID bigint(20) unsigned NOT NULL, |
| 180 | 179 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -190,34 +189,34 @@ discard block |
||
| 190 | 189 | EVT_donations tinyint(1) NULL, |
| 191 | 190 | PRIMARY KEY (EVTM_ID), |
| 192 | 191 | KEY EVT_ID (EVT_ID)"; |
| 193 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 194 | - $table_name = 'esp_event_question_group'; |
|
| 195 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 192 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 193 | + $table_name = 'esp_event_question_group'; |
|
| 194 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 196 | 195 | EVT_ID bigint(20) unsigned NOT NULL, |
| 197 | 196 | QSG_ID int(10) unsigned NOT NULL, |
| 198 | 197 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
| 199 | 198 | PRIMARY KEY (EQG_ID), |
| 200 | 199 | KEY EVT_ID (EVT_ID), |
| 201 | 200 | KEY QSG_ID (QSG_ID)"; |
| 202 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 203 | - $table_name = 'esp_event_venue'; |
|
| 204 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 201 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 202 | + $table_name = 'esp_event_venue'; |
|
| 203 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 205 | 204 | EVT_ID bigint(20) unsigned NOT NULL, |
| 206 | 205 | VNU_ID bigint(20) unsigned NOT NULL, |
| 207 | 206 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
| 208 | 207 | PRIMARY KEY (EVV_ID)"; |
| 209 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 210 | - $table_name = 'esp_extra_meta'; |
|
| 211 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 208 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 209 | + $table_name = 'esp_extra_meta'; |
|
| 210 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 212 | 211 | OBJ_ID int(11) DEFAULT NULL, |
| 213 | 212 | EXM_type varchar(45) DEFAULT NULL, |
| 214 | 213 | EXM_key varchar(45) DEFAULT NULL, |
| 215 | 214 | EXM_value text, |
| 216 | 215 | PRIMARY KEY (EXM_ID), |
| 217 | 216 | KEY EXM_type (EXM_type, OBJ_ID, EXM_key(45))"; |
| 218 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 219 | - $table_name = 'esp_line_item'; |
|
| 220 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 217 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 218 | + $table_name = 'esp_line_item'; |
|
| 219 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 221 | 220 | LIN_code varchar(245) NOT NULL DEFAULT '', |
| 222 | 221 | TXN_ID int(11) DEFAULT NULL, |
| 223 | 222 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -235,9 +234,9 @@ discard block |
||
| 235 | 234 | PRIMARY KEY (LIN_ID), |
| 236 | 235 | KEY LIN_code (LIN_code(191)), |
| 237 | 236 | KEY TXN_ID (TXN_ID)"; |
| 238 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 239 | - $table_name = 'esp_log'; |
|
| 240 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 237 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 238 | + $table_name = 'esp_log'; |
|
| 239 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 241 | 240 | LOG_time datetime DEFAULT NULL, |
| 242 | 241 | OBJ_ID varchar(45) DEFAULT NULL, |
| 243 | 242 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -248,18 +247,18 @@ discard block |
||
| 248 | 247 | KEY LOG_time (LOG_time), |
| 249 | 248 | KEY OBJ (OBJ_type,OBJ_ID), |
| 250 | 249 | KEY LOG_type (LOG_type)"; |
| 251 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 252 | - $table_name = 'esp_message_template'; |
|
| 253 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 250 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 251 | + $table_name = 'esp_message_template'; |
|
| 252 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 254 | 253 | GRP_ID int(10) unsigned NOT NULL, |
| 255 | 254 | MTP_context varchar(50) NOT NULL, |
| 256 | 255 | MTP_template_field varchar(30) NOT NULL, |
| 257 | 256 | MTP_content text NOT NULL, |
| 258 | 257 | PRIMARY KEY (MTP_ID), |
| 259 | 258 | KEY GRP_ID (GRP_ID)"; |
| 260 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 261 | - $table_name = 'esp_message_template_group'; |
|
| 262 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 259 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 260 | + $table_name = 'esp_message_template_group'; |
|
| 261 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 263 | 262 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
| 264 | 263 | MTP_name varchar(245) NOT NULL DEFAULT '', |
| 265 | 264 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -271,17 +270,17 @@ discard block |
||
| 271 | 270 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
| 272 | 271 | PRIMARY KEY (GRP_ID), |
| 273 | 272 | KEY MTP_user_id (MTP_user_id)"; |
| 274 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 275 | - $table_name = 'esp_event_message_template'; |
|
| 276 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 273 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 274 | + $table_name = 'esp_event_message_template'; |
|
| 275 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 277 | 276 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
| 278 | 277 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
| 279 | 278 | PRIMARY KEY (EMT_ID), |
| 280 | 279 | KEY EVT_ID (EVT_ID), |
| 281 | 280 | KEY GRP_ID (GRP_ID)"; |
| 282 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 283 | - $table_name = 'esp_payment'; |
|
| 284 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 281 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 282 | + $table_name = 'esp_payment'; |
|
| 283 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 285 | 284 | TXN_ID int(10) unsigned DEFAULT NULL, |
| 286 | 285 | STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL, |
| 287 | 286 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -298,9 +297,9 @@ discard block |
||
| 298 | 297 | PRIMARY KEY (PAY_ID), |
| 299 | 298 | KEY PAY_timestamp (PAY_timestamp), |
| 300 | 299 | KEY TXN_ID (TXN_ID)"; |
| 301 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 302 | - $table_name = 'esp_payment_method'; |
|
| 303 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 300 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 301 | + $table_name = 'esp_payment_method'; |
|
| 302 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 304 | 303 | PMD_type varchar(124) DEFAULT NULL, |
| 305 | 304 | PMD_name varchar(255) DEFAULT NULL, |
| 306 | 305 | PMD_desc text, |
@@ -316,32 +315,32 @@ discard block |
||
| 316 | 315 | PRIMARY KEY (PMD_ID), |
| 317 | 316 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
| 318 | 317 | KEY PMD_type (PMD_type)"; |
| 319 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 320 | - $table_name = "esp_ticket_price"; |
|
| 321 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 318 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 319 | + $table_name = "esp_ticket_price"; |
|
| 320 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 322 | 321 | TKT_ID int(10) unsigned NOT NULL, |
| 323 | 322 | PRC_ID int(10) unsigned NOT NULL, |
| 324 | 323 | PRIMARY KEY (TKP_ID), |
| 325 | 324 | KEY TKT_ID (TKT_ID), |
| 326 | 325 | KEY PRC_ID (PRC_ID)"; |
| 327 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 328 | - $table_name = "esp_datetime_ticket"; |
|
| 329 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 326 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 327 | + $table_name = "esp_datetime_ticket"; |
|
| 328 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 330 | 329 | DTT_ID int(10) unsigned NOT NULL, |
| 331 | 330 | TKT_ID int(10) unsigned NOT NULL, |
| 332 | 331 | PRIMARY KEY (DTK_ID), |
| 333 | 332 | KEY DTT_ID (DTT_ID), |
| 334 | 333 | KEY TKT_ID (TKT_ID)"; |
| 335 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 336 | - $table_name = "esp_ticket_template"; |
|
| 337 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 334 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 335 | + $table_name = "esp_ticket_template"; |
|
| 336 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 338 | 337 | TTM_name varchar(45) NOT NULL, |
| 339 | 338 | TTM_description text, |
| 340 | 339 | TTM_file varchar(45), |
| 341 | 340 | PRIMARY KEY (TTM_ID)"; |
| 342 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 343 | - $table_name = 'esp_question'; |
|
| 344 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 341 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 342 | + $table_name = 'esp_question'; |
|
| 343 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 345 | 344 | QST_display_text text NOT NULL, |
| 346 | 345 | QST_admin_label varchar(255) NOT NULL, |
| 347 | 346 | QST_system varchar(25) DEFAULT NULL, |
@@ -354,18 +353,18 @@ discard block |
||
| 354 | 353 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
| 355 | 354 | PRIMARY KEY (QST_ID), |
| 356 | 355 | KEY QST_order (QST_order)'; |
| 357 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 358 | - $table_name = 'esp_question_group_question'; |
|
| 359 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 356 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 357 | + $table_name = 'esp_question_group_question'; |
|
| 358 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 360 | 359 | QSG_ID int(10) unsigned NOT NULL, |
| 361 | 360 | QST_ID int(10) unsigned NOT NULL, |
| 362 | 361 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
| 363 | 362 | PRIMARY KEY (QGQ_ID), |
| 364 | 363 | KEY QST_ID (QST_ID), |
| 365 | 364 | KEY QSG_ID_order (QSG_ID, QGQ_order)"; |
| 366 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 367 | - $table_name = 'esp_question_option'; |
|
| 368 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 365 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 366 | + $table_name = 'esp_question_option'; |
|
| 367 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 369 | 368 | QSO_value varchar(255) NOT NULL, |
| 370 | 369 | QSO_desc text NOT NULL, |
| 371 | 370 | QST_ID int(10) unsigned NOT NULL, |
@@ -374,9 +373,9 @@ discard block |
||
| 374 | 373 | PRIMARY KEY (QSO_ID), |
| 375 | 374 | KEY QST_ID (QST_ID), |
| 376 | 375 | KEY QSO_order (QSO_order)"; |
| 377 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 378 | - $table_name = 'esp_registration'; |
|
| 379 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 376 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 377 | + $table_name = 'esp_registration'; |
|
| 378 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 380 | 379 | EVT_ID bigint(20) unsigned NOT NULL, |
| 381 | 380 | ATT_ID bigint(20) unsigned NOT NULL, |
| 382 | 381 | TXN_ID int(10) unsigned NOT NULL, |
@@ -400,18 +399,18 @@ discard block |
||
| 400 | 399 | KEY TKT_ID (TKT_ID), |
| 401 | 400 | KEY EVT_ID (EVT_ID), |
| 402 | 401 | KEY STS_ID (STS_ID)"; |
| 403 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 404 | - $table_name = 'esp_registration_payment'; |
|
| 405 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 402 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 403 | + $table_name = 'esp_registration_payment'; |
|
| 404 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 406 | 405 | REG_ID int(10) unsigned NOT NULL, |
| 407 | 406 | PAY_ID int(10) unsigned NULL, |
| 408 | 407 | RPY_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
| 409 | 408 | PRIMARY KEY (RPY_ID), |
| 410 | 409 | KEY REG_ID (REG_ID), |
| 411 | 410 | KEY PAY_ID (PAY_ID)"; |
| 412 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 413 | - $table_name = 'esp_checkin'; |
|
| 414 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 411 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 412 | + $table_name = 'esp_checkin'; |
|
| 413 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 415 | 414 | REG_ID int(10) unsigned NOT NULL, |
| 416 | 415 | DTT_ID int(10) unsigned NOT NULL, |
| 417 | 416 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -419,9 +418,9 @@ discard block |
||
| 419 | 418 | PRIMARY KEY (CHK_ID), |
| 420 | 419 | KEY REG_ID (REG_ID), |
| 421 | 420 | KEY DTT_ID (DTT_ID)"; |
| 422 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 423 | - $table_name = 'esp_state'; |
|
| 424 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
| 421 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 422 | + $table_name = 'esp_state'; |
|
| 423 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
| 425 | 424 | CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
| 426 | 425 | STA_abbrev varchar(24) COLLATE utf8_bin NOT NULL, |
| 427 | 426 | STA_name varchar(100) COLLATE utf8_bin NOT NULL, |
@@ -429,9 +428,9 @@ discard block |
||
| 429 | 428 | PRIMARY KEY (STA_ID), |
| 430 | 429 | KEY STA_abbrev (STA_abbrev), |
| 431 | 430 | KEY CNT_ISO (CNT_ISO)"; |
| 432 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 433 | - $table_name = 'esp_status'; |
|
| 434 | - $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
| 431 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 432 | + $table_name = 'esp_status'; |
|
| 433 | + $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
| 435 | 434 | STS_code varchar(45) COLLATE utf8_bin NOT NULL, |
| 436 | 435 | STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL, |
| 437 | 436 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -439,9 +438,9 @@ discard block |
||
| 439 | 438 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
| 440 | 439 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
| 441 | 440 | KEY STS_type (STS_type)"; |
| 442 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 443 | - $table_name = 'esp_transaction'; |
|
| 444 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 441 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 442 | + $table_name = 'esp_transaction'; |
|
| 443 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 445 | 444 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
| 446 | 445 | TXN_total decimal(10,3) DEFAULT '0.00', |
| 447 | 446 | TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00', |
@@ -453,9 +452,9 @@ discard block |
||
| 453 | 452 | PRIMARY KEY (TXN_ID), |
| 454 | 453 | KEY TXN_timestamp (TXN_timestamp), |
| 455 | 454 | KEY STS_ID (STS_ID)"; |
| 456 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 457 | - $table_name = 'esp_venue_meta'; |
|
| 458 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 455 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 456 | + $table_name = 'esp_venue_meta'; |
|
| 457 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 459 | 458 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
| 460 | 459 | VNU_address varchar(255) DEFAULT NULL, |
| 461 | 460 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -474,10 +473,10 @@ discard block |
||
| 474 | 473 | KEY VNU_ID (VNU_ID), |
| 475 | 474 | KEY STA_ID (STA_ID), |
| 476 | 475 | KEY CNT_ISO (CNT_ISO)"; |
| 477 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 478 | - // modified tables |
|
| 479 | - $table_name = "esp_price"; |
|
| 480 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 476 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 477 | + // modified tables |
|
| 478 | + $table_name = "esp_price"; |
|
| 479 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 481 | 480 | PRT_ID tinyint(3) unsigned NOT NULL, |
| 482 | 481 | PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
| 483 | 482 | PRC_name varchar(245) NOT NULL, |
@@ -490,9 +489,9 @@ discard block |
||
| 490 | 489 | PRC_parent int(10) unsigned DEFAULT 0, |
| 491 | 490 | PRIMARY KEY (PRC_ID), |
| 492 | 491 | KEY PRT_ID (PRT_ID)"; |
| 493 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 494 | - $table_name = "esp_price_type"; |
|
| 495 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
| 492 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 493 | + $table_name = "esp_price_type"; |
|
| 494 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
| 496 | 495 | PRT_name varchar(45) NOT NULL, |
| 497 | 496 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
| 498 | 497 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -501,9 +500,9 @@ discard block |
||
| 501 | 500 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
| 502 | 501 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
| 503 | 502 | PRIMARY KEY (PRT_ID)"; |
| 504 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 505 | - $table_name = "esp_ticket"; |
|
| 506 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 503 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 504 | + $table_name = "esp_ticket"; |
|
| 505 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 507 | 506 | TTM_ID int(10) unsigned NOT NULL, |
| 508 | 507 | TKT_name varchar(245) NOT NULL DEFAULT '', |
| 509 | 508 | TKT_description text NOT NULL, |
@@ -525,9 +524,9 @@ discard block |
||
| 525 | 524 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
| 526 | 525 | PRIMARY KEY (TKT_ID), |
| 527 | 526 | KEY TKT_start_date (TKT_start_date)"; |
| 528 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 529 | - $table_name = 'esp_question_group'; |
|
| 530 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 527 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 528 | + $table_name = 'esp_question_group'; |
|
| 529 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 531 | 530 | QSG_name varchar(255) NOT NULL, |
| 532 | 531 | QSG_identifier varchar(100) NOT NULL, |
| 533 | 532 | QSG_desc text NULL, |
@@ -540,38 +539,38 @@ discard block |
||
| 540 | 539 | PRIMARY KEY (QSG_ID), |
| 541 | 540 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
| 542 | 541 | KEY QSG_order (QSG_order)'; |
| 543 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 544 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
| 545 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
| 546 | - // (because many need to convert old string states to foreign keys into the states table) |
|
| 547 | - $script_4_1_defaults->insert_default_states(); |
|
| 548 | - $script_4_1_defaults->insert_default_countries(); |
|
| 549 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
| 550 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
| 551 | - $script_4_5_defaults->insert_default_price_types(); |
|
| 552 | - $script_4_5_defaults->insert_default_prices(); |
|
| 553 | - $script_4_5_defaults->insert_default_tickets(); |
|
| 554 | - /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
| 555 | - $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
| 556 | - $script_4_6_defaults->add_default_admin_only_payments(); |
|
| 557 | - $script_4_6_defaults->insert_default_currencies(); |
|
| 558 | - return true; |
|
| 559 | - } |
|
| 542 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 543 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
| 544 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
| 545 | + // (because many need to convert old string states to foreign keys into the states table) |
|
| 546 | + $script_4_1_defaults->insert_default_states(); |
|
| 547 | + $script_4_1_defaults->insert_default_countries(); |
|
| 548 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
| 549 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
| 550 | + $script_4_5_defaults->insert_default_price_types(); |
|
| 551 | + $script_4_5_defaults->insert_default_prices(); |
|
| 552 | + $script_4_5_defaults->insert_default_tickets(); |
|
| 553 | + /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
| 554 | + $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
| 555 | + $script_4_6_defaults->add_default_admin_only_payments(); |
|
| 556 | + $script_4_6_defaults->insert_default_currencies(); |
|
| 557 | + return true; |
|
| 558 | + } |
|
| 560 | 559 | |
| 561 | 560 | |
| 562 | 561 | |
| 563 | - /** |
|
| 564 | - * @return boolean |
|
| 565 | - */ |
|
| 566 | - public function schema_changes_after_migration() |
|
| 567 | - { |
|
| 568 | - return true; |
|
| 569 | - } |
|
| 562 | + /** |
|
| 563 | + * @return boolean |
|
| 564 | + */ |
|
| 565 | + public function schema_changes_after_migration() |
|
| 566 | + { |
|
| 567 | + return true; |
|
| 568 | + } |
|
| 570 | 569 | |
| 571 | 570 | |
| 572 | 571 | |
| 573 | - public function migration_page_hooks() |
|
| 574 | - { |
|
| 575 | - } |
|
| 572 | + public function migration_page_hooks() |
|
| 573 | + { |
|
| 574 | + } |
|
| 576 | 575 | } |
| 577 | 576 | // end of file: /core/data_migration_scripts/EE_DMS_Core_4_7_0.dms.php |
@@ -15,11 +15,11 @@ discard block |
||
| 15 | 15 | $stages = glob(EE_CORE . 'data_migration_scripts/4_2_0_stages/*'); |
| 16 | 16 | $class_to_filepath = array(); |
| 17 | 17 | if (! empty($stages)) { |
| 18 | - foreach ($stages as $filepath) { |
|
| 19 | - $matches = array(); |
|
| 20 | - preg_match('~4_2_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
| 21 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
| 22 | - } |
|
| 18 | + foreach ($stages as $filepath) { |
|
| 19 | + $matches = array(); |
|
| 20 | + preg_match('~4_2_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
| 21 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
| 22 | + } |
|
| 23 | 23 | } |
| 24 | 24 | // give addons a chance to autoload their stages too |
| 25 | 25 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_2_0__autoloaded_stages', $class_to_filepath); |
@@ -32,57 +32,57 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * EE_DMS_Core_4_2_0 constructor. |
|
| 37 | - * |
|
| 38 | - * @param TableManager $table_manager |
|
| 39 | - * @param TableAnalysis $table_analysis |
|
| 40 | - */ |
|
| 41 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
| 42 | - { |
|
| 43 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.2.0", "event_espresso"); |
|
| 44 | - $this->_priority = 10; |
|
| 45 | - $this->_migration_stages = array( |
|
| 46 | - new EE_DMS_4_2_0_question_group_questions(), |
|
| 47 | - new EE_DMS_4_2_0_datetime_fields(), |
|
| 48 | - ); |
|
| 49 | - parent::__construct($table_manager, $table_analysis); |
|
| 50 | - } |
|
| 35 | + /** |
|
| 36 | + * EE_DMS_Core_4_2_0 constructor. |
|
| 37 | + * |
|
| 38 | + * @param TableManager $table_manager |
|
| 39 | + * @param TableAnalysis $table_analysis |
|
| 40 | + */ |
|
| 41 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
| 42 | + { |
|
| 43 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.2.0", "event_espresso"); |
|
| 44 | + $this->_priority = 10; |
|
| 45 | + $this->_migration_stages = array( |
|
| 46 | + new EE_DMS_4_2_0_question_group_questions(), |
|
| 47 | + new EE_DMS_4_2_0_datetime_fields(), |
|
| 48 | + ); |
|
| 49 | + parent::__construct($table_manager, $table_analysis); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | |
| 54 | - public function can_migrate_from_version($version_array) |
|
| 55 | - { |
|
| 56 | - $version_string = $version_array['Core']; |
|
| 57 | - if (version_compare($version_string, '4.2.0.decaf', '<') && version_compare($version_string, '4.1.0.decaf', '>=')) { |
|
| 54 | + public function can_migrate_from_version($version_array) |
|
| 55 | + { |
|
| 56 | + $version_string = $version_array['Core']; |
|
| 57 | + if (version_compare($version_string, '4.2.0.decaf', '<') && version_compare($version_string, '4.1.0.decaf', '>=')) { |
|
| 58 | 58 | // echo "$version_string can be migrated fro"; |
| 59 | - return true; |
|
| 60 | - } elseif (! $version_string) { |
|
| 59 | + return true; |
|
| 60 | + } elseif (! $version_string) { |
|
| 61 | 61 | // echo "no version string provided: $version_string"; |
| 62 | - // no version string provided... this must be pre 4.1 |
|
| 63 | - // because since 4.1 we're |
|
| 64 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 65 | - } else { |
|
| 62 | + // no version string provided... this must be pre 4.1 |
|
| 63 | + // because since 4.1 we're |
|
| 64 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 65 | + } else { |
|
| 66 | 66 | // echo "$version_string doesnt apply"; |
| 67 | - return false; |
|
| 68 | - } |
|
| 69 | - } |
|
| 67 | + return false; |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | 71 | |
| 72 | 72 | |
| 73 | - public function schema_changes_before_migration() |
|
| 74 | - { |
|
| 75 | - // relies on 4.1's EEH_Activation::create_table |
|
| 76 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 77 | - $table_name = 'esp_answer'; |
|
| 78 | - $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 73 | + public function schema_changes_before_migration() |
|
| 74 | + { |
|
| 75 | + // relies on 4.1's EEH_Activation::create_table |
|
| 76 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 77 | + $table_name = 'esp_answer'; |
|
| 78 | + $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 79 | 79 | REG_ID int(10) unsigned NOT NULL, |
| 80 | 80 | QST_ID int(10) unsigned NOT NULL, |
| 81 | 81 | ANS_value text NOT NULL, |
| 82 | 82 | PRIMARY KEY (ANS_ID)"; |
| 83 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 84 | - $table_name = 'esp_attendee_meta'; |
|
| 85 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 83 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 84 | + $table_name = 'esp_attendee_meta'; |
|
| 85 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 86 | 86 | ATT_ID bigint(20) unsigned NOT NULL, |
| 87 | 87 | ATT_fname varchar(45) NOT NULL, |
| 88 | 88 | ATT_lname varchar(45) NOT NULL, |
@@ -98,9 +98,9 @@ discard block |
||
| 98 | 98 | KEY ATT_fname (ATT_fname), |
| 99 | 99 | KEY ATT_lname (ATT_lname), |
| 100 | 100 | KEY ATT_email (ATT_email(191))"; |
| 101 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 102 | - $table_name = 'esp_country'; |
|
| 103 | - $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
| 101 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 102 | + $table_name = 'esp_country'; |
|
| 103 | + $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
| 104 | 104 | CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL, |
| 105 | 105 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
| 106 | 106 | CNT_name varchar(45) COLLATE utf8_bin NOT NULL, |
@@ -116,9 +116,9 @@ discard block |
||
| 116 | 116 | CNT_is_EU tinyint(1) DEFAULT '0', |
| 117 | 117 | CNT_active tinyint(1) DEFAULT '0', |
| 118 | 118 | PRIMARY KEY (CNT_ISO)"; |
| 119 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 120 | - $table_name = 'esp_datetime'; |
|
| 121 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 119 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 120 | + $table_name = 'esp_datetime'; |
|
| 121 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 122 | 122 | EVT_ID bigint(20) unsigned NOT NULL, |
| 123 | 123 | DTT_name varchar(255) NOT NULL DEFAULT '', |
| 124 | 124 | DTT_description text NOT NULL, |
@@ -133,9 +133,9 @@ discard block |
||
| 133 | 133 | PRIMARY KEY (DTT_ID), |
| 134 | 134 | KEY EVT_ID (EVT_ID), |
| 135 | 135 | KEY DTT_is_primary (DTT_is_primary)"; |
| 136 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 137 | - $table_name = 'esp_event_meta'; |
|
| 138 | - $sql = " |
|
| 136 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 137 | + $table_name = 'esp_event_meta'; |
|
| 138 | + $sql = " |
|
| 139 | 139 | EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
| 140 | 140 | EVT_ID bigint(20) unsigned NOT NULL, |
| 141 | 141 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -150,31 +150,31 @@ discard block |
||
| 150 | 150 | EVT_external_URL varchar(200) NULL, |
| 151 | 151 | EVT_donations tinyint(1) NULL, |
| 152 | 152 | PRIMARY KEY (EVTM_ID)"; |
| 153 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 154 | - $table_name = 'esp_event_question_group'; |
|
| 155 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 153 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 154 | + $table_name = 'esp_event_question_group'; |
|
| 155 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 156 | 156 | EVT_ID bigint(20) unsigned NOT NULL, |
| 157 | 157 | QSG_ID int(10) unsigned NOT NULL, |
| 158 | 158 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
| 159 | 159 | PRIMARY KEY (EQG_ID)"; |
| 160 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 161 | - $table_name = 'esp_event_venue'; |
|
| 162 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 160 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 161 | + $table_name = 'esp_event_venue'; |
|
| 162 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 163 | 163 | EVT_ID bigint(20) unsigned NOT NULL, |
| 164 | 164 | VNU_ID bigint(20) unsigned NOT NULL, |
| 165 | 165 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
| 166 | 166 | PRIMARY KEY (EVV_ID)"; |
| 167 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 168 | - $table_name = 'esp_extra_meta'; |
|
| 169 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 167 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 168 | + $table_name = 'esp_extra_meta'; |
|
| 169 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 170 | 170 | OBJ_ID int(11) DEFAULT NULL, |
| 171 | 171 | EXM_type varchar(45) DEFAULT NULL, |
| 172 | 172 | EXM_key varchar(45) DEFAULT NULL, |
| 173 | 173 | EXM_value text, |
| 174 | 174 | PRIMARY KEY (EXM_ID)"; |
| 175 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 176 | - $table_name = 'esp_line_item'; |
|
| 177 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 175 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 176 | + $table_name = 'esp_line_item'; |
|
| 177 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 178 | 178 | LIN_code varchar(245) NOT NULL DEFAULT '', |
| 179 | 179 | TXN_ID int(11) DEFAULT NULL, |
| 180 | 180 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -190,18 +190,18 @@ discard block |
||
| 190 | 190 | OBJ_ID int(11) DEFAULT NULL, |
| 191 | 191 | OBJ_type varchar(45)DEFAULT NULL, |
| 192 | 192 | PRIMARY KEY (LIN_ID)"; |
| 193 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 194 | - $table_name = 'esp_message_template'; |
|
| 195 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 193 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 194 | + $table_name = 'esp_message_template'; |
|
| 195 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 196 | 196 | GRP_ID int(10) unsigned NOT NULL, |
| 197 | 197 | MTP_context varchar(50) NOT NULL, |
| 198 | 198 | MTP_template_field varchar(30) NOT NULL, |
| 199 | 199 | MTP_content text NOT NULL, |
| 200 | 200 | PRIMARY KEY (MTP_ID), |
| 201 | 201 | KEY GRP_ID (GRP_ID)"; |
| 202 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 203 | - $table_name = 'esp_message_template_group'; |
|
| 204 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 202 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 203 | + $table_name = 'esp_message_template_group'; |
|
| 204 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 205 | 205 | EVT_ID bigint(20) unsigned DEFAULT NULL, |
| 206 | 206 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
| 207 | 207 | MTP_messenger varchar(30) NOT NULL, |
@@ -213,9 +213,9 @@ discard block |
||
| 213 | 213 | PRIMARY KEY (GRP_ID), |
| 214 | 214 | KEY EVT_ID (EVT_ID), |
| 215 | 215 | KEY MTP_user_id (MTP_user_id)"; |
| 216 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 217 | - $table_name = 'esp_payment'; |
|
| 218 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 216 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 217 | + $table_name = 'esp_payment'; |
|
| 218 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 219 | 219 | TXN_ID int(10) unsigned DEFAULT NULL, |
| 220 | 220 | STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL, |
| 221 | 221 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -231,9 +231,9 @@ discard block |
||
| 231 | 231 | PRIMARY KEY (PAY_ID), |
| 232 | 232 | KEY TXN_ID (TXN_ID), |
| 233 | 233 | KEY PAY_timestamp (PAY_timestamp)"; |
| 234 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 235 | - $table_name = "esp_ticket"; |
|
| 236 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 234 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 235 | + $table_name = "esp_ticket"; |
|
| 236 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 237 | 237 | TTM_ID int(10) unsigned NOT NULL, |
| 238 | 238 | TKT_name varchar(245) NOT NULL DEFAULT '', |
| 239 | 239 | TKT_description text NOT NULL, |
@@ -252,28 +252,28 @@ discard block |
||
| 252 | 252 | TKT_parent int(10) unsigned DEFAULT '0', |
| 253 | 253 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
| 254 | 254 | PRIMARY KEY (TKT_ID)"; |
| 255 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 256 | - $table_name = "esp_ticket_price"; |
|
| 257 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 255 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 256 | + $table_name = "esp_ticket_price"; |
|
| 257 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 258 | 258 | TKT_ID int(10) unsigned NOT NULL, |
| 259 | 259 | PRC_ID int(10) unsigned NOT NULL, |
| 260 | 260 | PRIMARY KEY (TKP_ID)"; |
| 261 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 262 | - $table_name = "esp_datetime_ticket"; |
|
| 263 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 261 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 262 | + $table_name = "esp_datetime_ticket"; |
|
| 263 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 264 | 264 | DTT_ID int(10) unsigned NOT NULL, |
| 265 | 265 | TKT_ID int(10) unsigned NOT NULL, |
| 266 | 266 | PRIMARY KEY (DTK_ID)"; |
| 267 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 268 | - $table_name = "esp_ticket_template"; |
|
| 269 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 267 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 268 | + $table_name = "esp_ticket_template"; |
|
| 269 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 270 | 270 | TTM_name varchar(45) NOT NULL, |
| 271 | 271 | TTM_description text, |
| 272 | 272 | TTM_file varchar(45), |
| 273 | 273 | PRIMARY KEY (TTM_ID)"; |
| 274 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 275 | - $table_name = "esp_price"; |
|
| 276 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 274 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 275 | + $table_name = "esp_price"; |
|
| 276 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 277 | 277 | PRT_ID tinyint(3) unsigned NOT NULL, |
| 278 | 278 | PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
| 279 | 279 | PRC_name varchar(245) NOT NULL, |
@@ -284,9 +284,9 @@ discard block |
||
| 284 | 284 | PRC_order tinyint(3) unsigned NOT NULL DEFAULT '0', |
| 285 | 285 | PRC_parent int(10) unsigned DEFAULT 0, |
| 286 | 286 | PRIMARY KEY (PRC_ID)"; |
| 287 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 288 | - $table_name = "esp_price_type"; |
|
| 289 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
| 287 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 288 | + $table_name = "esp_price_type"; |
|
| 289 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
| 290 | 290 | PRT_name varchar(45) NOT NULL, |
| 291 | 291 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
| 292 | 292 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -294,9 +294,9 @@ discard block |
||
| 294 | 294 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
| 295 | 295 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
| 296 | 296 | PRIMARY KEY (PRT_ID)"; |
| 297 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 298 | - $table_name = 'esp_question'; |
|
| 299 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 297 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 298 | + $table_name = 'esp_question'; |
|
| 299 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 300 | 300 | QST_display_text text NOT NULL, |
| 301 | 301 | QST_admin_label varchar(255) NOT NULL, |
| 302 | 302 | QST_system varchar(25) DEFAULT NULL, |
@@ -308,10 +308,10 @@ discard block |
||
| 308 | 308 | QST_wp_user bigint(20) unsigned NULL, |
| 309 | 309 | QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
| 310 | 310 | PRIMARY KEY (QST_ID)'; |
| 311 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 312 | - $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
| 313 | - $table_name = 'esp_question_group'; |
|
| 314 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 311 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 312 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
| 313 | + $table_name = 'esp_question_group'; |
|
| 314 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 315 | 315 | QSG_name varchar(255) NOT NULL, |
| 316 | 316 | QSG_identifier varchar(100) NOT NULL, |
| 317 | 317 | QSG_desc text NULL, |
@@ -322,24 +322,24 @@ discard block |
||
| 322 | 322 | QSG_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
| 323 | 323 | PRIMARY KEY (QSG_ID), |
| 324 | 324 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
| 325 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 326 | - $table_name = 'esp_question_group_question'; |
|
| 327 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 325 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 326 | + $table_name = 'esp_question_group_question'; |
|
| 327 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 328 | 328 | QSG_ID int(10) unsigned NOT NULL, |
| 329 | 329 | QST_ID int(10) unsigned NOT NULL, |
| 330 | 330 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
| 331 | 331 | PRIMARY KEY (QGQ_ID) "; |
| 332 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 333 | - $table_name = 'esp_question_option'; |
|
| 334 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 332 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 333 | + $table_name = 'esp_question_option'; |
|
| 334 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 335 | 335 | QSO_value varchar(255) NOT NULL, |
| 336 | 336 | QSO_desc text NOT NULL, |
| 337 | 337 | QST_ID int(10) unsigned NOT NULL, |
| 338 | 338 | QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
| 339 | 339 | PRIMARY KEY (QSO_ID)"; |
| 340 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 341 | - $table_name = 'esp_registration'; |
|
| 342 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 340 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 341 | + $table_name = 'esp_registration'; |
|
| 342 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 343 | 343 | EVT_ID bigint(20) unsigned NOT NULL, |
| 344 | 344 | ATT_ID bigint(20) unsigned NOT NULL, |
| 345 | 345 | TXN_ID int(10) unsigned NOT NULL, |
@@ -362,25 +362,25 @@ discard block |
||
| 362 | 362 | KEY STS_ID (STS_ID), |
| 363 | 363 | KEY REG_url_link (REG_url_link), |
| 364 | 364 | KEY REG_code (REG_code)"; |
| 365 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 366 | - $table_name = 'esp_checkin'; |
|
| 367 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 365 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 366 | + $table_name = 'esp_checkin'; |
|
| 367 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 368 | 368 | REG_ID int(10) unsigned NOT NULL, |
| 369 | 369 | DTT_ID int(10) unsigned NOT NULL, |
| 370 | 370 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
| 371 | 371 | CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
| 372 | 372 | PRIMARY KEY (CHK_ID)"; |
| 373 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 374 | - $table_name = 'esp_state'; |
|
| 375 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
| 373 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 374 | + $table_name = 'esp_state'; |
|
| 375 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
| 376 | 376 | CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
| 377 | 377 | STA_abbrev varchar(6) COLLATE utf8_bin NOT NULL, |
| 378 | 378 | STA_name varchar(100) COLLATE utf8_bin NOT NULL, |
| 379 | 379 | STA_active tinyint(1) DEFAULT '1', |
| 380 | 380 | PRIMARY KEY (STA_ID)"; |
| 381 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 382 | - $table_name = 'esp_status'; |
|
| 383 | - $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
| 381 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 382 | + $table_name = 'esp_status'; |
|
| 383 | + $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
| 384 | 384 | STS_code varchar(45) COLLATE utf8_bin NOT NULL, |
| 385 | 385 | STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL, |
| 386 | 386 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -388,9 +388,9 @@ discard block |
||
| 388 | 388 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
| 389 | 389 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
| 390 | 390 | KEY STS_type (STS_type)"; |
| 391 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 392 | - $table_name = 'esp_transaction'; |
|
| 393 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 391 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 392 | + $table_name = 'esp_transaction'; |
|
| 393 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 394 | 394 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
| 395 | 395 | TXN_total decimal(10,3) DEFAULT '0.00', |
| 396 | 396 | TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00', |
@@ -400,9 +400,9 @@ discard block |
||
| 400 | 400 | PRIMARY KEY (TXN_ID), |
| 401 | 401 | KEY TXN_timestamp (TXN_timestamp), |
| 402 | 402 | KEY STS_ID (STS_ID)"; |
| 403 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 404 | - $table_name = 'esp_venue_meta'; |
|
| 405 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 403 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 404 | + $table_name = 'esp_venue_meta'; |
|
| 405 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 406 | 406 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
| 407 | 407 | VNU_address varchar(255) DEFAULT NULL, |
| 408 | 408 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -420,36 +420,36 @@ discard block |
||
| 420 | 420 | PRIMARY KEY (VNUM_ID), |
| 421 | 421 | KEY STA_ID (STA_ID), |
| 422 | 422 | KEY CNT_ISO (CNT_ISO)"; |
| 423 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 424 | - $script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
| 425 | - // setting up the DEFAULT stats and countries is also essential for the data migrations to run |
|
| 426 | - // (because many need to convert old string states to foreign keys into the states table) |
|
| 427 | - $script_with_defaults->insert_default_states(); |
|
| 428 | - $script_with_defaults->insert_default_countries(); |
|
| 429 | - // setting up DEFAULT prices, price types, and tickets is also essential for the price migrations |
|
| 430 | - $script_with_defaults->insert_default_price_types(); |
|
| 431 | - $script_with_defaults->insert_default_prices(); |
|
| 432 | - $script_with_defaults->insert_default_tickets(); |
|
| 433 | - // setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre |
|
| 434 | - EE_Config::instance()->update_espresso_config(false, true); |
|
| 435 | - return true; |
|
| 436 | - } |
|
| 423 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 424 | + $script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
| 425 | + // setting up the DEFAULT stats and countries is also essential for the data migrations to run |
|
| 426 | + // (because many need to convert old string states to foreign keys into the states table) |
|
| 427 | + $script_with_defaults->insert_default_states(); |
|
| 428 | + $script_with_defaults->insert_default_countries(); |
|
| 429 | + // setting up DEFAULT prices, price types, and tickets is also essential for the price migrations |
|
| 430 | + $script_with_defaults->insert_default_price_types(); |
|
| 431 | + $script_with_defaults->insert_default_prices(); |
|
| 432 | + $script_with_defaults->insert_default_tickets(); |
|
| 433 | + // setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre |
|
| 434 | + EE_Config::instance()->update_espresso_config(false, true); |
|
| 435 | + return true; |
|
| 436 | + } |
|
| 437 | 437 | |
| 438 | 438 | |
| 439 | 439 | |
| 440 | - /** |
|
| 441 | - * We COULD clean up the esp_question.QST_order field here. We'll leave it for now |
|
| 442 | - * |
|
| 443 | - * @return boolean |
|
| 444 | - */ |
|
| 445 | - public function schema_changes_after_migration() |
|
| 446 | - { |
|
| 447 | - return true; |
|
| 448 | - } |
|
| 440 | + /** |
|
| 441 | + * We COULD clean up the esp_question.QST_order field here. We'll leave it for now |
|
| 442 | + * |
|
| 443 | + * @return boolean |
|
| 444 | + */ |
|
| 445 | + public function schema_changes_after_migration() |
|
| 446 | + { |
|
| 447 | + return true; |
|
| 448 | + } |
|
| 449 | 449 | |
| 450 | 450 | |
| 451 | 451 | |
| 452 | - public function migration_page_hooks() |
|
| 453 | - { |
|
| 454 | - } |
|
| 452 | + public function migration_page_hooks() |
|
| 453 | + { |
|
| 454 | + } |
|
| 455 | 455 | } |
@@ -12,13 +12,13 @@ discard block |
||
| 12 | 12 | // unfortunately, this needs to be done upon INCLUSION of this file, |
| 13 | 13 | // instead of construction, because it only gets constructed on first page load |
| 14 | 14 | // (all other times it gets resurrected from a wordpress option) |
| 15 | -$stages = glob(EE_CORE . 'data_migration_scripts/4_2_0_stages/*'); |
|
| 15 | +$stages = glob(EE_CORE.'data_migration_scripts/4_2_0_stages/*'); |
|
| 16 | 16 | $class_to_filepath = array(); |
| 17 | -if (! empty($stages)) { |
|
| 17 | +if ( ! empty($stages)) { |
|
| 18 | 18 | foreach ($stages as $filepath) { |
| 19 | 19 | $matches = array(); |
| 20 | 20 | preg_match('~4_2_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
| 21 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
| 21 | + $class_to_filepath[$matches[1]] = $filepath; |
|
| 22 | 22 | } |
| 23 | 23 | } |
| 24 | 24 | // give addons a chance to autoload their stages too |
@@ -57,11 +57,11 @@ discard block |
||
| 57 | 57 | if (version_compare($version_string, '4.2.0.decaf', '<') && version_compare($version_string, '4.1.0.decaf', '>=')) { |
| 58 | 58 | // echo "$version_string can be migrated fro"; |
| 59 | 59 | return true; |
| 60 | - } elseif (! $version_string) { |
|
| 60 | + } elseif ( ! $version_string) { |
|
| 61 | 61 | // echo "no version string provided: $version_string"; |
| 62 | 62 | // no version string provided... this must be pre 4.1 |
| 63 | 63 | // because since 4.1 we're |
| 64 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 64 | + return false; // changed mind. dont want people thinking they should migrate yet because they cant |
|
| 65 | 65 | } else { |
| 66 | 66 | // echo "$version_string doesnt apply"; |
| 67 | 67 | return false; |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | public function schema_changes_before_migration() |
| 74 | 74 | { |
| 75 | 75 | // relies on 4.1's EEH_Activation::create_table |
| 76 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 76 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
| 77 | 77 | $table_name = 'esp_answer'; |
| 78 | 78 | $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
| 79 | 79 | REG_ID int(10) unsigned NOT NULL, |
@@ -33,526 +33,526 @@ |
||
| 33 | 33 | class ProcessTicketSelector |
| 34 | 34 | { |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var EE_Cart $cart |
|
| 38 | - */ |
|
| 39 | - private $cart; |
|
| 36 | + /** |
|
| 37 | + * @var EE_Cart $cart |
|
| 38 | + */ |
|
| 39 | + private $cart; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @var EE_Core_Config $core_config |
|
| 43 | - */ |
|
| 44 | - private $core_config; |
|
| 41 | + /** |
|
| 42 | + * @var EE_Core_Config $core_config |
|
| 43 | + */ |
|
| 44 | + private $core_config; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @var Request $request |
|
| 48 | - */ |
|
| 49 | - private $request; |
|
| 46 | + /** |
|
| 47 | + * @var Request $request |
|
| 48 | + */ |
|
| 49 | + private $request; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @var EE_Session $session |
|
| 53 | - */ |
|
| 54 | - private $session; |
|
| 51 | + /** |
|
| 52 | + * @var EE_Session $session |
|
| 53 | + */ |
|
| 54 | + private $session; |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @var EEM_Ticket $ticket_model |
|
| 58 | - */ |
|
| 59 | - private $ticket_model; |
|
| 56 | + /** |
|
| 57 | + * @var EEM_Ticket $ticket_model |
|
| 58 | + */ |
|
| 59 | + private $ticket_model; |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * @var TicketDatetimeAvailabilityTracker $tracker |
|
| 63 | - */ |
|
| 64 | - private $tracker; |
|
| 61 | + /** |
|
| 62 | + * @var TicketDatetimeAvailabilityTracker $tracker |
|
| 63 | + */ |
|
| 64 | + private $tracker; |
|
| 65 | 65 | |
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * ProcessTicketSelector constructor. |
|
| 69 | - * NOTE: PLZ use the Loader to instantiate this class if need be |
|
| 70 | - * so that all dependencies get injected correctly (which will happen automatically) |
|
| 71 | - * Null values for parameters are only for backwards compatibility but will be removed later on. |
|
| 72 | - * |
|
| 73 | - * @param EE_Core_Config $core_config |
|
| 74 | - * @param Request $request |
|
| 75 | - * @param EE_Session $session |
|
| 76 | - * @param EEM_Ticket $ticket_model |
|
| 77 | - * @param TicketDatetimeAvailabilityTracker $tracker |
|
| 78 | - * @throws InvalidArgumentException |
|
| 79 | - * @throws InvalidDataTypeException |
|
| 80 | - * @throws InvalidInterfaceException |
|
| 81 | - */ |
|
| 82 | - public function __construct( |
|
| 83 | - EE_Core_Config $core_config = null, |
|
| 84 | - Request $request = null, |
|
| 85 | - EE_Session $session = null, |
|
| 86 | - EEM_Ticket $ticket_model = null, |
|
| 87 | - TicketDatetimeAvailabilityTracker $tracker = null |
|
| 88 | - ) { |
|
| 89 | - /** @var LoaderInterface $loader */ |
|
| 90 | - $loader = LoaderFactory::getLoader(); |
|
| 91 | - $this->core_config = $core_config instanceof EE_Core_Config |
|
| 92 | - ? $core_config |
|
| 93 | - : $loader->getShared('EE_Core_Config'); |
|
| 94 | - $this->request = $request instanceof Request |
|
| 95 | - ? $request |
|
| 96 | - : $loader->getShared('EventEspresso\core\services\request\Request'); |
|
| 97 | - $this->session = $session instanceof EE_Session |
|
| 98 | - ? $session |
|
| 99 | - : $loader->getShared('EE_Session'); |
|
| 100 | - $this->ticket_model = $ticket_model instanceof EEM_Ticket |
|
| 101 | - ? $ticket_model |
|
| 102 | - : $loader->getShared('EEM_Ticket'); |
|
| 103 | - $this->tracker = $tracker instanceof TicketDatetimeAvailabilityTracker |
|
| 104 | - ? $tracker |
|
| 105 | - : $loader->getShared('EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'); |
|
| 106 | - } |
|
| 67 | + /** |
|
| 68 | + * ProcessTicketSelector constructor. |
|
| 69 | + * NOTE: PLZ use the Loader to instantiate this class if need be |
|
| 70 | + * so that all dependencies get injected correctly (which will happen automatically) |
|
| 71 | + * Null values for parameters are only for backwards compatibility but will be removed later on. |
|
| 72 | + * |
|
| 73 | + * @param EE_Core_Config $core_config |
|
| 74 | + * @param Request $request |
|
| 75 | + * @param EE_Session $session |
|
| 76 | + * @param EEM_Ticket $ticket_model |
|
| 77 | + * @param TicketDatetimeAvailabilityTracker $tracker |
|
| 78 | + * @throws InvalidArgumentException |
|
| 79 | + * @throws InvalidDataTypeException |
|
| 80 | + * @throws InvalidInterfaceException |
|
| 81 | + */ |
|
| 82 | + public function __construct( |
|
| 83 | + EE_Core_Config $core_config = null, |
|
| 84 | + Request $request = null, |
|
| 85 | + EE_Session $session = null, |
|
| 86 | + EEM_Ticket $ticket_model = null, |
|
| 87 | + TicketDatetimeAvailabilityTracker $tracker = null |
|
| 88 | + ) { |
|
| 89 | + /** @var LoaderInterface $loader */ |
|
| 90 | + $loader = LoaderFactory::getLoader(); |
|
| 91 | + $this->core_config = $core_config instanceof EE_Core_Config |
|
| 92 | + ? $core_config |
|
| 93 | + : $loader->getShared('EE_Core_Config'); |
|
| 94 | + $this->request = $request instanceof Request |
|
| 95 | + ? $request |
|
| 96 | + : $loader->getShared('EventEspresso\core\services\request\Request'); |
|
| 97 | + $this->session = $session instanceof EE_Session |
|
| 98 | + ? $session |
|
| 99 | + : $loader->getShared('EE_Session'); |
|
| 100 | + $this->ticket_model = $ticket_model instanceof EEM_Ticket |
|
| 101 | + ? $ticket_model |
|
| 102 | + : $loader->getShared('EEM_Ticket'); |
|
| 103 | + $this->tracker = $tracker instanceof TicketDatetimeAvailabilityTracker |
|
| 104 | + ? $tracker |
|
| 105 | + : $loader->getShared('EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * cancelTicketSelections |
|
| 111 | - * |
|
| 112 | - * @return bool |
|
| 113 | - * @throws EE_Error |
|
| 114 | - * @throws InvalidArgumentException |
|
| 115 | - * @throws InvalidInterfaceException |
|
| 116 | - * @throws InvalidDataTypeException |
|
| 117 | - */ |
|
| 118 | - public function cancelTicketSelections() |
|
| 119 | - { |
|
| 120 | - // check nonce |
|
| 121 | - if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) { |
|
| 122 | - return false; |
|
| 123 | - } |
|
| 124 | - $this->session->clear_session(__CLASS__, __FUNCTION__); |
|
| 125 | - if ($this->request->requestParamIsSet('event_id')) { |
|
| 126 | - EEH_URL::safeRedirectAndExit( |
|
| 127 | - EEH_Event_View::event_link_url( |
|
| 128 | - $this->request->getRequestParam('event_id') |
|
| 129 | - ) |
|
| 130 | - ); |
|
| 131 | - } |
|
| 132 | - EEH_URL::safeRedirectAndExit( |
|
| 133 | - site_url('/' . $this->core_config->event_cpt_slug . '/') |
|
| 134 | - ); |
|
| 135 | - return true; |
|
| 136 | - } |
|
| 109 | + /** |
|
| 110 | + * cancelTicketSelections |
|
| 111 | + * |
|
| 112 | + * @return bool |
|
| 113 | + * @throws EE_Error |
|
| 114 | + * @throws InvalidArgumentException |
|
| 115 | + * @throws InvalidInterfaceException |
|
| 116 | + * @throws InvalidDataTypeException |
|
| 117 | + */ |
|
| 118 | + public function cancelTicketSelections() |
|
| 119 | + { |
|
| 120 | + // check nonce |
|
| 121 | + if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) { |
|
| 122 | + return false; |
|
| 123 | + } |
|
| 124 | + $this->session->clear_session(__CLASS__, __FUNCTION__); |
|
| 125 | + if ($this->request->requestParamIsSet('event_id')) { |
|
| 126 | + EEH_URL::safeRedirectAndExit( |
|
| 127 | + EEH_Event_View::event_link_url( |
|
| 128 | + $this->request->getRequestParam('event_id') |
|
| 129 | + ) |
|
| 130 | + ); |
|
| 131 | + } |
|
| 132 | + EEH_URL::safeRedirectAndExit( |
|
| 133 | + site_url('/' . $this->core_config->event_cpt_slug . '/') |
|
| 134 | + ); |
|
| 135 | + return true; |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | 138 | |
| 139 | - /** |
|
| 140 | - * processTicketSelectorNonce |
|
| 141 | - * |
|
| 142 | - * @param string $nonce_name |
|
| 143 | - * @param string $id |
|
| 144 | - * @return bool |
|
| 145 | - */ |
|
| 146 | - private function processTicketSelectorNonce($nonce_name, $id = '') |
|
| 147 | - { |
|
| 148 | - $nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce"; |
|
| 149 | - if (! $this->request->isAdmin() |
|
| 150 | - && ( |
|
| 151 | - ! $this->request->is_set($nonce_name_with_id) |
|
| 152 | - || ! wp_verify_nonce( |
|
| 153 | - $this->request->get($nonce_name_with_id), |
|
| 154 | - $nonce_name |
|
| 155 | - ) |
|
| 156 | - ) |
|
| 157 | - ) { |
|
| 158 | - EE_Error::add_error( |
|
| 159 | - sprintf( |
|
| 160 | - esc_html__( |
|
| 161 | - 'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', |
|
| 162 | - 'event_espresso' |
|
| 163 | - ), |
|
| 164 | - '<br/>' |
|
| 165 | - ), |
|
| 166 | - __FILE__, |
|
| 167 | - __FUNCTION__, |
|
| 168 | - __LINE__ |
|
| 169 | - ); |
|
| 170 | - return false; |
|
| 171 | - } |
|
| 172 | - return true; |
|
| 173 | - } |
|
| 139 | + /** |
|
| 140 | + * processTicketSelectorNonce |
|
| 141 | + * |
|
| 142 | + * @param string $nonce_name |
|
| 143 | + * @param string $id |
|
| 144 | + * @return bool |
|
| 145 | + */ |
|
| 146 | + private function processTicketSelectorNonce($nonce_name, $id = '') |
|
| 147 | + { |
|
| 148 | + $nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce"; |
|
| 149 | + if (! $this->request->isAdmin() |
|
| 150 | + && ( |
|
| 151 | + ! $this->request->is_set($nonce_name_with_id) |
|
| 152 | + || ! wp_verify_nonce( |
|
| 153 | + $this->request->get($nonce_name_with_id), |
|
| 154 | + $nonce_name |
|
| 155 | + ) |
|
| 156 | + ) |
|
| 157 | + ) { |
|
| 158 | + EE_Error::add_error( |
|
| 159 | + sprintf( |
|
| 160 | + esc_html__( |
|
| 161 | + 'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', |
|
| 162 | + 'event_espresso' |
|
| 163 | + ), |
|
| 164 | + '<br/>' |
|
| 165 | + ), |
|
| 166 | + __FILE__, |
|
| 167 | + __FUNCTION__, |
|
| 168 | + __LINE__ |
|
| 169 | + ); |
|
| 170 | + return false; |
|
| 171 | + } |
|
| 172 | + return true; |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | 175 | |
| 176 | - /** |
|
| 177 | - * process_ticket_selections |
|
| 178 | - * |
|
| 179 | - * @return array|bool |
|
| 180 | - * @throws EE_Error |
|
| 181 | - * @throws InvalidArgumentException |
|
| 182 | - * @throws InvalidDataTypeException |
|
| 183 | - * @throws InvalidInterfaceException |
|
| 184 | - */ |
|
| 185 | - public function processTicketSelections() |
|
| 186 | - { |
|
| 187 | - do_action('EED_Ticket_Selector__process_ticket_selections__before'); |
|
| 188 | - if ($this->request->isBot()) { |
|
| 189 | - EEH_URL::safeRedirectAndExit( |
|
| 190 | - apply_filters( |
|
| 191 | - 'FHEE__EE_Ticket_Selector__process_ticket_selections__bot_redirect_url', |
|
| 192 | - site_url() |
|
| 193 | - ) |
|
| 194 | - ); |
|
| 195 | - } |
|
| 196 | - // do we have an event id? |
|
| 197 | - $id = $this->getEventId(); |
|
| 198 | - // we should really only have 1 registration in the works now |
|
| 199 | - // (ie, no MER) so unless otherwise requested, clear the session |
|
| 200 | - if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) { |
|
| 201 | - $this->session->clear_session(__CLASS__, __FUNCTION__); |
|
| 202 | - } |
|
| 203 | - // validate/sanitize/filter data |
|
| 204 | - $valid = apply_filters( |
|
| 205 | - 'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data', |
|
| 206 | - $this->validatePostData($id) |
|
| 207 | - ); |
|
| 208 | - // check total tickets ordered vs max number of attendees that can register |
|
| 209 | - if (! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) { |
|
| 210 | - $this->maxAttendeesViolation($valid); |
|
| 211 | - } else { |
|
| 212 | - // all data appears to be valid |
|
| 213 | - if ($this->processSuccessfulCart($this->addTicketsToCart($valid))) { |
|
| 214 | - return true; |
|
| 215 | - } |
|
| 216 | - } |
|
| 217 | - // die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT |
|
| 218 | - // at this point, just return if registration is being made from admin |
|
| 219 | - if ($this->request->isAdmin() || $this->request->isFrontAjax()) { |
|
| 220 | - return false; |
|
| 221 | - } |
|
| 222 | - if ($valid['return_url']) { |
|
| 223 | - EEH_URL::safeRedirectAndExit($valid['return_url']); |
|
| 224 | - } |
|
| 225 | - if ($id) { |
|
| 226 | - EEH_URL::safeRedirectAndExit(get_permalink($id)); |
|
| 227 | - } |
|
| 228 | - echo EE_Error::get_notices(); |
|
| 229 | - return false; |
|
| 230 | - } |
|
| 176 | + /** |
|
| 177 | + * process_ticket_selections |
|
| 178 | + * |
|
| 179 | + * @return array|bool |
|
| 180 | + * @throws EE_Error |
|
| 181 | + * @throws InvalidArgumentException |
|
| 182 | + * @throws InvalidDataTypeException |
|
| 183 | + * @throws InvalidInterfaceException |
|
| 184 | + */ |
|
| 185 | + public function processTicketSelections() |
|
| 186 | + { |
|
| 187 | + do_action('EED_Ticket_Selector__process_ticket_selections__before'); |
|
| 188 | + if ($this->request->isBot()) { |
|
| 189 | + EEH_URL::safeRedirectAndExit( |
|
| 190 | + apply_filters( |
|
| 191 | + 'FHEE__EE_Ticket_Selector__process_ticket_selections__bot_redirect_url', |
|
| 192 | + site_url() |
|
| 193 | + ) |
|
| 194 | + ); |
|
| 195 | + } |
|
| 196 | + // do we have an event id? |
|
| 197 | + $id = $this->getEventId(); |
|
| 198 | + // we should really only have 1 registration in the works now |
|
| 199 | + // (ie, no MER) so unless otherwise requested, clear the session |
|
| 200 | + if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) { |
|
| 201 | + $this->session->clear_session(__CLASS__, __FUNCTION__); |
|
| 202 | + } |
|
| 203 | + // validate/sanitize/filter data |
|
| 204 | + $valid = apply_filters( |
|
| 205 | + 'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data', |
|
| 206 | + $this->validatePostData($id) |
|
| 207 | + ); |
|
| 208 | + // check total tickets ordered vs max number of attendees that can register |
|
| 209 | + if (! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) { |
|
| 210 | + $this->maxAttendeesViolation($valid); |
|
| 211 | + } else { |
|
| 212 | + // all data appears to be valid |
|
| 213 | + if ($this->processSuccessfulCart($this->addTicketsToCart($valid))) { |
|
| 214 | + return true; |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | + // die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT |
|
| 218 | + // at this point, just return if registration is being made from admin |
|
| 219 | + if ($this->request->isAdmin() || $this->request->isFrontAjax()) { |
|
| 220 | + return false; |
|
| 221 | + } |
|
| 222 | + if ($valid['return_url']) { |
|
| 223 | + EEH_URL::safeRedirectAndExit($valid['return_url']); |
|
| 224 | + } |
|
| 225 | + if ($id) { |
|
| 226 | + EEH_URL::safeRedirectAndExit(get_permalink($id)); |
|
| 227 | + } |
|
| 228 | + echo EE_Error::get_notices(); |
|
| 229 | + return false; |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | 232 | |
| 233 | - /** |
|
| 234 | - * @return int |
|
| 235 | - */ |
|
| 236 | - private function getEventId() |
|
| 237 | - { |
|
| 238 | - // do we have an event id? |
|
| 239 | - if (! $this->request->requestParamIsSet('tkt-slctr-event-id')) { |
|
| 240 | - // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
|
| 241 | - EE_Error::add_error( |
|
| 242 | - sprintf( |
|
| 243 | - esc_html__( |
|
| 244 | - 'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', |
|
| 245 | - 'event_espresso' |
|
| 246 | - ), |
|
| 247 | - '<br/>' |
|
| 248 | - ), |
|
| 249 | - __FILE__, |
|
| 250 | - __FUNCTION__, |
|
| 251 | - __LINE__ |
|
| 252 | - ); |
|
| 253 | - } |
|
| 254 | - // if event id is valid |
|
| 255 | - return absint($this->request->getRequestParam('tkt-slctr-event-id')); |
|
| 256 | - } |
|
| 233 | + /** |
|
| 234 | + * @return int |
|
| 235 | + */ |
|
| 236 | + private function getEventId() |
|
| 237 | + { |
|
| 238 | + // do we have an event id? |
|
| 239 | + if (! $this->request->requestParamIsSet('tkt-slctr-event-id')) { |
|
| 240 | + // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
|
| 241 | + EE_Error::add_error( |
|
| 242 | + sprintf( |
|
| 243 | + esc_html__( |
|
| 244 | + 'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', |
|
| 245 | + 'event_espresso' |
|
| 246 | + ), |
|
| 247 | + '<br/>' |
|
| 248 | + ), |
|
| 249 | + __FILE__, |
|
| 250 | + __FUNCTION__, |
|
| 251 | + __LINE__ |
|
| 252 | + ); |
|
| 253 | + } |
|
| 254 | + // if event id is valid |
|
| 255 | + return absint($this->request->getRequestParam('tkt-slctr-event-id')); |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | 258 | |
| 259 | - /** |
|
| 260 | - * validate_post_data |
|
| 261 | - * |
|
| 262 | - * @param int $id |
|
| 263 | - * @return array |
|
| 264 | - */ |
|
| 265 | - private function validatePostData($id = 0) |
|
| 266 | - { |
|
| 267 | - if (! $id) { |
|
| 268 | - EE_Error::add_error( |
|
| 269 | - esc_html__('The event id provided was not valid.', 'event_espresso'), |
|
| 270 | - __FILE__, |
|
| 271 | - __FUNCTION__, |
|
| 272 | - __LINE__ |
|
| 273 | - ); |
|
| 274 | - return array(); |
|
| 275 | - } |
|
| 276 | - // start with an empty array() |
|
| 277 | - $valid_data = array(); |
|
| 278 | - // grab valid id |
|
| 279 | - $valid_data['id'] = $id; |
|
| 280 | - // array of other form names |
|
| 281 | - $inputs_to_clean = array( |
|
| 282 | - 'event_id' => 'tkt-slctr-event-id', |
|
| 283 | - 'max_atndz' => 'tkt-slctr-max-atndz-', |
|
| 284 | - 'rows' => 'tkt-slctr-rows-', |
|
| 285 | - 'qty' => 'tkt-slctr-qty-', |
|
| 286 | - 'ticket_id' => 'tkt-slctr-ticket-id-', |
|
| 287 | - 'return_url' => 'tkt-slctr-return-url-', |
|
| 288 | - ); |
|
| 289 | - // let's track the total number of tickets ordered.' |
|
| 290 | - $valid_data['total_tickets'] = 0; |
|
| 291 | - // cycle through $inputs_to_clean array |
|
| 292 | - foreach ($inputs_to_clean as $what => $input_to_clean) { |
|
| 293 | - // check for POST data |
|
| 294 | - if ($this->request->requestParamIsSet($input_to_clean . $id)) { |
|
| 295 | - // grab value |
|
| 296 | - $input_value = $this->request->getRequestParam($input_to_clean . $id); |
|
| 297 | - switch ($what) { |
|
| 298 | - // integers |
|
| 299 | - case 'event_id': |
|
| 300 | - $valid_data[ $what ] = absint($input_value); |
|
| 301 | - // get event via the event id we put in the form |
|
| 302 | - break; |
|
| 303 | - case 'rows': |
|
| 304 | - case 'max_atndz': |
|
| 305 | - $valid_data[ $what ] = absint($input_value); |
|
| 306 | - break; |
|
| 307 | - // arrays of integers |
|
| 308 | - case 'qty': |
|
| 309 | - /** @var array $row_qty */ |
|
| 310 | - $row_qty = $input_value; |
|
| 311 | - // if qty is coming from a radio button input, then we need to assemble an array of rows |
|
| 312 | - if (! is_array($row_qty)) { |
|
| 313 | - /** @var string $row_qty */ |
|
| 314 | - // get number of rows |
|
| 315 | - $rows = $this->request->requestParamIsSet('tkt-slctr-rows-' . $id) |
|
| 316 | - ? absint($this->request->getRequestParam('tkt-slctr-rows-' . $id)) |
|
| 317 | - : 1; |
|
| 318 | - // explode integers by the dash |
|
| 319 | - $row_qty = explode('-', $row_qty); |
|
| 320 | - $row = isset($row_qty[0]) ? absint($row_qty[0]) : 1; |
|
| 321 | - $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0; |
|
| 322 | - $row_qty = array($row => $qty); |
|
| 323 | - for ($x = 1; $x <= $rows; $x++) { |
|
| 324 | - if (! isset($row_qty[ $x ])) { |
|
| 325 | - $row_qty[ $x ] = 0; |
|
| 326 | - } |
|
| 327 | - } |
|
| 328 | - } |
|
| 329 | - ksort($row_qty); |
|
| 330 | - // cycle thru values |
|
| 331 | - foreach ($row_qty as $qty) { |
|
| 332 | - $qty = absint($qty); |
|
| 333 | - // sanitize as integers |
|
| 334 | - $valid_data[ $what ][] = $qty; |
|
| 335 | - $valid_data['total_tickets'] += $qty; |
|
| 336 | - } |
|
| 337 | - break; |
|
| 338 | - // array of integers |
|
| 339 | - case 'ticket_id': |
|
| 340 | - // cycle thru values |
|
| 341 | - foreach ((array) $input_value as $key => $value) { |
|
| 342 | - // allow only integers |
|
| 343 | - $valid_data[ $what ][ $key ] = absint($value); |
|
| 344 | - } |
|
| 345 | - break; |
|
| 346 | - case 'return_url': |
|
| 347 | - // grab and sanitize return-url |
|
| 348 | - $input_value = esc_url_raw($input_value); |
|
| 349 | - // was the request coming from an iframe ? if so, then: |
|
| 350 | - if (strpos($input_value, 'event_list=iframe')) { |
|
| 351 | - // get anchor fragment |
|
| 352 | - $input_value = explode('#', $input_value); |
|
| 353 | - $input_value = end($input_value); |
|
| 354 | - // use event list url instead, but append anchor |
|
| 355 | - $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value; |
|
| 356 | - } |
|
| 357 | - $valid_data[ $what ] = $input_value; |
|
| 358 | - break; |
|
| 359 | - } // end switch $what |
|
| 360 | - } |
|
| 361 | - } // end foreach $inputs_to_clean |
|
| 362 | - return $valid_data; |
|
| 363 | - } |
|
| 259 | + /** |
|
| 260 | + * validate_post_data |
|
| 261 | + * |
|
| 262 | + * @param int $id |
|
| 263 | + * @return array |
|
| 264 | + */ |
|
| 265 | + private function validatePostData($id = 0) |
|
| 266 | + { |
|
| 267 | + if (! $id) { |
|
| 268 | + EE_Error::add_error( |
|
| 269 | + esc_html__('The event id provided was not valid.', 'event_espresso'), |
|
| 270 | + __FILE__, |
|
| 271 | + __FUNCTION__, |
|
| 272 | + __LINE__ |
|
| 273 | + ); |
|
| 274 | + return array(); |
|
| 275 | + } |
|
| 276 | + // start with an empty array() |
|
| 277 | + $valid_data = array(); |
|
| 278 | + // grab valid id |
|
| 279 | + $valid_data['id'] = $id; |
|
| 280 | + // array of other form names |
|
| 281 | + $inputs_to_clean = array( |
|
| 282 | + 'event_id' => 'tkt-slctr-event-id', |
|
| 283 | + 'max_atndz' => 'tkt-slctr-max-atndz-', |
|
| 284 | + 'rows' => 'tkt-slctr-rows-', |
|
| 285 | + 'qty' => 'tkt-slctr-qty-', |
|
| 286 | + 'ticket_id' => 'tkt-slctr-ticket-id-', |
|
| 287 | + 'return_url' => 'tkt-slctr-return-url-', |
|
| 288 | + ); |
|
| 289 | + // let's track the total number of tickets ordered.' |
|
| 290 | + $valid_data['total_tickets'] = 0; |
|
| 291 | + // cycle through $inputs_to_clean array |
|
| 292 | + foreach ($inputs_to_clean as $what => $input_to_clean) { |
|
| 293 | + // check for POST data |
|
| 294 | + if ($this->request->requestParamIsSet($input_to_clean . $id)) { |
|
| 295 | + // grab value |
|
| 296 | + $input_value = $this->request->getRequestParam($input_to_clean . $id); |
|
| 297 | + switch ($what) { |
|
| 298 | + // integers |
|
| 299 | + case 'event_id': |
|
| 300 | + $valid_data[ $what ] = absint($input_value); |
|
| 301 | + // get event via the event id we put in the form |
|
| 302 | + break; |
|
| 303 | + case 'rows': |
|
| 304 | + case 'max_atndz': |
|
| 305 | + $valid_data[ $what ] = absint($input_value); |
|
| 306 | + break; |
|
| 307 | + // arrays of integers |
|
| 308 | + case 'qty': |
|
| 309 | + /** @var array $row_qty */ |
|
| 310 | + $row_qty = $input_value; |
|
| 311 | + // if qty is coming from a radio button input, then we need to assemble an array of rows |
|
| 312 | + if (! is_array($row_qty)) { |
|
| 313 | + /** @var string $row_qty */ |
|
| 314 | + // get number of rows |
|
| 315 | + $rows = $this->request->requestParamIsSet('tkt-slctr-rows-' . $id) |
|
| 316 | + ? absint($this->request->getRequestParam('tkt-slctr-rows-' . $id)) |
|
| 317 | + : 1; |
|
| 318 | + // explode integers by the dash |
|
| 319 | + $row_qty = explode('-', $row_qty); |
|
| 320 | + $row = isset($row_qty[0]) ? absint($row_qty[0]) : 1; |
|
| 321 | + $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0; |
|
| 322 | + $row_qty = array($row => $qty); |
|
| 323 | + for ($x = 1; $x <= $rows; $x++) { |
|
| 324 | + if (! isset($row_qty[ $x ])) { |
|
| 325 | + $row_qty[ $x ] = 0; |
|
| 326 | + } |
|
| 327 | + } |
|
| 328 | + } |
|
| 329 | + ksort($row_qty); |
|
| 330 | + // cycle thru values |
|
| 331 | + foreach ($row_qty as $qty) { |
|
| 332 | + $qty = absint($qty); |
|
| 333 | + // sanitize as integers |
|
| 334 | + $valid_data[ $what ][] = $qty; |
|
| 335 | + $valid_data['total_tickets'] += $qty; |
|
| 336 | + } |
|
| 337 | + break; |
|
| 338 | + // array of integers |
|
| 339 | + case 'ticket_id': |
|
| 340 | + // cycle thru values |
|
| 341 | + foreach ((array) $input_value as $key => $value) { |
|
| 342 | + // allow only integers |
|
| 343 | + $valid_data[ $what ][ $key ] = absint($value); |
|
| 344 | + } |
|
| 345 | + break; |
|
| 346 | + case 'return_url': |
|
| 347 | + // grab and sanitize return-url |
|
| 348 | + $input_value = esc_url_raw($input_value); |
|
| 349 | + // was the request coming from an iframe ? if so, then: |
|
| 350 | + if (strpos($input_value, 'event_list=iframe')) { |
|
| 351 | + // get anchor fragment |
|
| 352 | + $input_value = explode('#', $input_value); |
|
| 353 | + $input_value = end($input_value); |
|
| 354 | + // use event list url instead, but append anchor |
|
| 355 | + $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value; |
|
| 356 | + } |
|
| 357 | + $valid_data[ $what ] = $input_value; |
|
| 358 | + break; |
|
| 359 | + } // end switch $what |
|
| 360 | + } |
|
| 361 | + } // end foreach $inputs_to_clean |
|
| 362 | + return $valid_data; |
|
| 363 | + } |
|
| 364 | 364 | |
| 365 | 365 | |
| 366 | - /** |
|
| 367 | - * @param array $valid |
|
| 368 | - */ |
|
| 369 | - private function maxAttendeesViolation(array $valid) |
|
| 370 | - { |
|
| 371 | - // ordering too many tickets !!! |
|
| 372 | - $total_tickets_string = esc_html( |
|
| 373 | - _n( |
|
| 374 | - 'You have attempted to purchase %s ticket.', |
|
| 375 | - 'You have attempted to purchase %s tickets.', |
|
| 376 | - $valid['total_tickets'], |
|
| 377 | - 'event_espresso' |
|
| 378 | - ) |
|
| 379 | - ); |
|
| 380 | - $limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']); |
|
| 381 | - // dev only message |
|
| 382 | - $max_attendees_string = esc_html( |
|
| 383 | - _n( |
|
| 384 | - 'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', |
|
| 385 | - 'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', |
|
| 386 | - $valid['max_atndz'], |
|
| 387 | - 'event_espresso' |
|
| 388 | - ) |
|
| 389 | - ); |
|
| 390 | - $limit_error_2 = sprintf($max_attendees_string, $valid['max_atndz'], $valid['max_atndz']); |
|
| 391 | - EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__); |
|
| 392 | - } |
|
| 366 | + /** |
|
| 367 | + * @param array $valid |
|
| 368 | + */ |
|
| 369 | + private function maxAttendeesViolation(array $valid) |
|
| 370 | + { |
|
| 371 | + // ordering too many tickets !!! |
|
| 372 | + $total_tickets_string = esc_html( |
|
| 373 | + _n( |
|
| 374 | + 'You have attempted to purchase %s ticket.', |
|
| 375 | + 'You have attempted to purchase %s tickets.', |
|
| 376 | + $valid['total_tickets'], |
|
| 377 | + 'event_espresso' |
|
| 378 | + ) |
|
| 379 | + ); |
|
| 380 | + $limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']); |
|
| 381 | + // dev only message |
|
| 382 | + $max_attendees_string = esc_html( |
|
| 383 | + _n( |
|
| 384 | + 'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', |
|
| 385 | + 'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', |
|
| 386 | + $valid['max_atndz'], |
|
| 387 | + 'event_espresso' |
|
| 388 | + ) |
|
| 389 | + ); |
|
| 390 | + $limit_error_2 = sprintf($max_attendees_string, $valid['max_atndz'], $valid['max_atndz']); |
|
| 391 | + EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__); |
|
| 392 | + } |
|
| 393 | 393 | |
| 394 | 394 | |
| 395 | - /** |
|
| 396 | - * @param array $valid |
|
| 397 | - * @return int |
|
| 398 | - * @throws EE_Error |
|
| 399 | - * @throws InvalidArgumentException |
|
| 400 | - * @throws InvalidDataTypeException |
|
| 401 | - * @throws InvalidInterfaceException |
|
| 402 | - */ |
|
| 403 | - private function addTicketsToCart(array $valid) |
|
| 404 | - { |
|
| 405 | - $tickets_added = 0; |
|
| 406 | - $tickets_selected = false; |
|
| 407 | - if (! empty($valid) && $valid['total_tickets'] > 0) { |
|
| 408 | - // load cart using factory because we don't want to do so until actually needed |
|
| 409 | - $this->cart = CartFactory::getCart(); |
|
| 410 | - // cycle thru the number of data rows sent from the event listing |
|
| 411 | - for ($x = 0; $x < $valid['rows']; $x++) { |
|
| 412 | - // does this row actually contain a ticket quantity? |
|
| 413 | - if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) { |
|
| 414 | - // YES we have a ticket quantity |
|
| 415 | - $tickets_selected = true; |
|
| 416 | - $valid_ticket = false; |
|
| 417 | - // \EEH_Debug_Tools::printr( |
|
| 418 | - // $valid['ticket_id'][ $x ], |
|
| 419 | - // '$valid[\'ticket_id\'][ $x ]', |
|
| 420 | - // __FILE__, __LINE__ |
|
| 421 | - // ); |
|
| 422 | - if (isset($valid['ticket_id'][ $x ])) { |
|
| 423 | - // get ticket via the ticket id we put in the form |
|
| 424 | - $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][ $x ]); |
|
| 425 | - if ($ticket instanceof EE_Ticket) { |
|
| 426 | - $valid_ticket = true; |
|
| 427 | - $tickets_added += $this->addTicketToCart( |
|
| 428 | - $ticket, |
|
| 429 | - $valid['qty'][ $x ] |
|
| 430 | - ); |
|
| 431 | - } |
|
| 432 | - } |
|
| 433 | - if ($valid_ticket !== true) { |
|
| 434 | - // nothing added to cart retrieved |
|
| 435 | - EE_Error::add_error( |
|
| 436 | - sprintf( |
|
| 437 | - esc_html__( |
|
| 438 | - 'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', |
|
| 439 | - 'event_espresso' |
|
| 440 | - ), |
|
| 441 | - '<br/>' |
|
| 442 | - ), |
|
| 443 | - __FILE__, |
|
| 444 | - __FUNCTION__, |
|
| 445 | - __LINE__ |
|
| 446 | - ); |
|
| 447 | - } |
|
| 448 | - if (EE_Error::has_error()) { |
|
| 449 | - break; |
|
| 450 | - } |
|
| 451 | - } |
|
| 452 | - } |
|
| 453 | - } |
|
| 454 | - do_action( |
|
| 455 | - 'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart', |
|
| 456 | - $this->cart, |
|
| 457 | - $this |
|
| 458 | - ); |
|
| 459 | - if (! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) { |
|
| 460 | - // no ticket quantities were selected |
|
| 461 | - EE_Error::add_error( |
|
| 462 | - esc_html__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), |
|
| 463 | - __FILE__, |
|
| 464 | - __FUNCTION__, |
|
| 465 | - __LINE__ |
|
| 466 | - ); |
|
| 467 | - } |
|
| 468 | - return $tickets_added; |
|
| 469 | - } |
|
| 395 | + /** |
|
| 396 | + * @param array $valid |
|
| 397 | + * @return int |
|
| 398 | + * @throws EE_Error |
|
| 399 | + * @throws InvalidArgumentException |
|
| 400 | + * @throws InvalidDataTypeException |
|
| 401 | + * @throws InvalidInterfaceException |
|
| 402 | + */ |
|
| 403 | + private function addTicketsToCart(array $valid) |
|
| 404 | + { |
|
| 405 | + $tickets_added = 0; |
|
| 406 | + $tickets_selected = false; |
|
| 407 | + if (! empty($valid) && $valid['total_tickets'] > 0) { |
|
| 408 | + // load cart using factory because we don't want to do so until actually needed |
|
| 409 | + $this->cart = CartFactory::getCart(); |
|
| 410 | + // cycle thru the number of data rows sent from the event listing |
|
| 411 | + for ($x = 0; $x < $valid['rows']; $x++) { |
|
| 412 | + // does this row actually contain a ticket quantity? |
|
| 413 | + if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) { |
|
| 414 | + // YES we have a ticket quantity |
|
| 415 | + $tickets_selected = true; |
|
| 416 | + $valid_ticket = false; |
|
| 417 | + // \EEH_Debug_Tools::printr( |
|
| 418 | + // $valid['ticket_id'][ $x ], |
|
| 419 | + // '$valid[\'ticket_id\'][ $x ]', |
|
| 420 | + // __FILE__, __LINE__ |
|
| 421 | + // ); |
|
| 422 | + if (isset($valid['ticket_id'][ $x ])) { |
|
| 423 | + // get ticket via the ticket id we put in the form |
|
| 424 | + $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][ $x ]); |
|
| 425 | + if ($ticket instanceof EE_Ticket) { |
|
| 426 | + $valid_ticket = true; |
|
| 427 | + $tickets_added += $this->addTicketToCart( |
|
| 428 | + $ticket, |
|
| 429 | + $valid['qty'][ $x ] |
|
| 430 | + ); |
|
| 431 | + } |
|
| 432 | + } |
|
| 433 | + if ($valid_ticket !== true) { |
|
| 434 | + // nothing added to cart retrieved |
|
| 435 | + EE_Error::add_error( |
|
| 436 | + sprintf( |
|
| 437 | + esc_html__( |
|
| 438 | + 'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', |
|
| 439 | + 'event_espresso' |
|
| 440 | + ), |
|
| 441 | + '<br/>' |
|
| 442 | + ), |
|
| 443 | + __FILE__, |
|
| 444 | + __FUNCTION__, |
|
| 445 | + __LINE__ |
|
| 446 | + ); |
|
| 447 | + } |
|
| 448 | + if (EE_Error::has_error()) { |
|
| 449 | + break; |
|
| 450 | + } |
|
| 451 | + } |
|
| 452 | + } |
|
| 453 | + } |
|
| 454 | + do_action( |
|
| 455 | + 'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart', |
|
| 456 | + $this->cart, |
|
| 457 | + $this |
|
| 458 | + ); |
|
| 459 | + if (! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) { |
|
| 460 | + // no ticket quantities were selected |
|
| 461 | + EE_Error::add_error( |
|
| 462 | + esc_html__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), |
|
| 463 | + __FILE__, |
|
| 464 | + __FUNCTION__, |
|
| 465 | + __LINE__ |
|
| 466 | + ); |
|
| 467 | + } |
|
| 468 | + return $tickets_added; |
|
| 469 | + } |
|
| 470 | 470 | |
| 471 | 471 | |
| 472 | - /** |
|
| 473 | - * adds a ticket to the cart |
|
| 474 | - * |
|
| 475 | - * @param EE_Ticket $ticket |
|
| 476 | - * @param int $qty |
|
| 477 | - * @return TRUE on success, FALSE on fail |
|
| 478 | - * @throws InvalidArgumentException |
|
| 479 | - * @throws InvalidInterfaceException |
|
| 480 | - * @throws InvalidDataTypeException |
|
| 481 | - * @throws EE_Error |
|
| 482 | - */ |
|
| 483 | - private function addTicketToCart(EE_Ticket $ticket, $qty = 1) |
|
| 484 | - { |
|
| 485 | - // get the number of spaces left for this datetime ticket |
|
| 486 | - $available_spaces = $this->tracker->ticketDatetimeAvailability($ticket); |
|
| 487 | - // compare available spaces against the number of tickets being purchased |
|
| 488 | - if ($available_spaces >= $qty) { |
|
| 489 | - // allow addons to prevent a ticket from being added to cart |
|
| 490 | - if (! apply_filters( |
|
| 491 | - 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', |
|
| 492 | - true, |
|
| 493 | - $ticket, |
|
| 494 | - $qty, |
|
| 495 | - $available_spaces |
|
| 496 | - )) { |
|
| 497 | - return false; |
|
| 498 | - } |
|
| 499 | - $qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket)); |
|
| 500 | - // add event to cart |
|
| 501 | - if ($this->cart->add_ticket_to_cart($ticket, $qty)) { |
|
| 502 | - $this->tracker->recalculateTicketDatetimeAvailability($ticket, $qty); |
|
| 503 | - return true; |
|
| 504 | - } |
|
| 505 | - return false; |
|
| 506 | - } |
|
| 507 | - $this->tracker->processAvailabilityError($ticket, $qty, $this->cart->all_ticket_quantity_count()); |
|
| 508 | - return false; |
|
| 509 | - } |
|
| 472 | + /** |
|
| 473 | + * adds a ticket to the cart |
|
| 474 | + * |
|
| 475 | + * @param EE_Ticket $ticket |
|
| 476 | + * @param int $qty |
|
| 477 | + * @return TRUE on success, FALSE on fail |
|
| 478 | + * @throws InvalidArgumentException |
|
| 479 | + * @throws InvalidInterfaceException |
|
| 480 | + * @throws InvalidDataTypeException |
|
| 481 | + * @throws EE_Error |
|
| 482 | + */ |
|
| 483 | + private function addTicketToCart(EE_Ticket $ticket, $qty = 1) |
|
| 484 | + { |
|
| 485 | + // get the number of spaces left for this datetime ticket |
|
| 486 | + $available_spaces = $this->tracker->ticketDatetimeAvailability($ticket); |
|
| 487 | + // compare available spaces against the number of tickets being purchased |
|
| 488 | + if ($available_spaces >= $qty) { |
|
| 489 | + // allow addons to prevent a ticket from being added to cart |
|
| 490 | + if (! apply_filters( |
|
| 491 | + 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', |
|
| 492 | + true, |
|
| 493 | + $ticket, |
|
| 494 | + $qty, |
|
| 495 | + $available_spaces |
|
| 496 | + )) { |
|
| 497 | + return false; |
|
| 498 | + } |
|
| 499 | + $qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket)); |
|
| 500 | + // add event to cart |
|
| 501 | + if ($this->cart->add_ticket_to_cart($ticket, $qty)) { |
|
| 502 | + $this->tracker->recalculateTicketDatetimeAvailability($ticket, $qty); |
|
| 503 | + return true; |
|
| 504 | + } |
|
| 505 | + return false; |
|
| 506 | + } |
|
| 507 | + $this->tracker->processAvailabilityError($ticket, $qty, $this->cart->all_ticket_quantity_count()); |
|
| 508 | + return false; |
|
| 509 | + } |
|
| 510 | 510 | |
| 511 | 511 | |
| 512 | - /** |
|
| 513 | - * @param $tickets_added |
|
| 514 | - * @return bool |
|
| 515 | - * @throws InvalidInterfaceException |
|
| 516 | - * @throws InvalidDataTypeException |
|
| 517 | - * @throws EE_Error |
|
| 518 | - * @throws InvalidArgumentException |
|
| 519 | - */ |
|
| 520 | - private function processSuccessfulCart($tickets_added) |
|
| 521 | - { |
|
| 522 | - // exit('KILL REDIRECT BEFORE CART UPDATE'); // <<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE |
|
| 523 | - if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) { |
|
| 524 | - // make sure cart is loaded |
|
| 525 | - if (! $this->cart instanceof EE_Cart) { |
|
| 526 | - $this->cart = CartFactory::getCart(); |
|
| 527 | - } |
|
| 528 | - do_action( |
|
| 529 | - 'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', |
|
| 530 | - $this->cart, |
|
| 531 | - $this |
|
| 532 | - ); |
|
| 533 | - $this->cart->recalculate_all_cart_totals(); |
|
| 534 | - $this->cart->save_cart(false); |
|
| 535 | - // exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<< OR HERE TO KILL REDIRECT AFTER CART UPDATE |
|
| 536 | - // just return TRUE for registrations being made from admin |
|
| 537 | - if ($this->request->isAdmin() || $this->request->isFrontAjax()) { |
|
| 538 | - return true; |
|
| 539 | - } |
|
| 540 | - EEH_URL::safeRedirectAndExit( |
|
| 541 | - apply_filters( |
|
| 542 | - 'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', |
|
| 543 | - $this->core_config->reg_page_url() |
|
| 544 | - ) |
|
| 545 | - ); |
|
| 546 | - } |
|
| 547 | - if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) { |
|
| 548 | - // nothing added to cart |
|
| 549 | - EE_Error::add_attention( |
|
| 550 | - esc_html__('No tickets were added for the event', 'event_espresso'), |
|
| 551 | - __FILE__, |
|
| 552 | - __FUNCTION__, |
|
| 553 | - __LINE__ |
|
| 554 | - ); |
|
| 555 | - } |
|
| 556 | - return false; |
|
| 557 | - } |
|
| 512 | + /** |
|
| 513 | + * @param $tickets_added |
|
| 514 | + * @return bool |
|
| 515 | + * @throws InvalidInterfaceException |
|
| 516 | + * @throws InvalidDataTypeException |
|
| 517 | + * @throws EE_Error |
|
| 518 | + * @throws InvalidArgumentException |
|
| 519 | + */ |
|
| 520 | + private function processSuccessfulCart($tickets_added) |
|
| 521 | + { |
|
| 522 | + // exit('KILL REDIRECT BEFORE CART UPDATE'); // <<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE |
|
| 523 | + if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) { |
|
| 524 | + // make sure cart is loaded |
|
| 525 | + if (! $this->cart instanceof EE_Cart) { |
|
| 526 | + $this->cart = CartFactory::getCart(); |
|
| 527 | + } |
|
| 528 | + do_action( |
|
| 529 | + 'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', |
|
| 530 | + $this->cart, |
|
| 531 | + $this |
|
| 532 | + ); |
|
| 533 | + $this->cart->recalculate_all_cart_totals(); |
|
| 534 | + $this->cart->save_cart(false); |
|
| 535 | + // exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<< OR HERE TO KILL REDIRECT AFTER CART UPDATE |
|
| 536 | + // just return TRUE for registrations being made from admin |
|
| 537 | + if ($this->request->isAdmin() || $this->request->isFrontAjax()) { |
|
| 538 | + return true; |
|
| 539 | + } |
|
| 540 | + EEH_URL::safeRedirectAndExit( |
|
| 541 | + apply_filters( |
|
| 542 | + 'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', |
|
| 543 | + $this->core_config->reg_page_url() |
|
| 544 | + ) |
|
| 545 | + ); |
|
| 546 | + } |
|
| 547 | + if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) { |
|
| 548 | + // nothing added to cart |
|
| 549 | + EE_Error::add_attention( |
|
| 550 | + esc_html__('No tickets were added for the event', 'event_espresso'), |
|
| 551 | + __FILE__, |
|
| 552 | + __FUNCTION__, |
|
| 553 | + __LINE__ |
|
| 554 | + ); |
|
| 555 | + } |
|
| 556 | + return false; |
|
| 557 | + } |
|
| 558 | 558 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | public function cancelTicketSelections() |
| 119 | 119 | { |
| 120 | 120 | // check nonce |
| 121 | - if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) { |
|
| 121 | + if ( ! $this->processTicketSelectorNonce('cancel_ticket_selections')) { |
|
| 122 | 122 | return false; |
| 123 | 123 | } |
| 124 | 124 | $this->session->clear_session(__CLASS__, __FUNCTION__); |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | ); |
| 131 | 131 | } |
| 132 | 132 | EEH_URL::safeRedirectAndExit( |
| 133 | - site_url('/' . $this->core_config->event_cpt_slug . '/') |
|
| 133 | + site_url('/'.$this->core_config->event_cpt_slug.'/') |
|
| 134 | 134 | ); |
| 135 | 135 | return true; |
| 136 | 136 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | private function processTicketSelectorNonce($nonce_name, $id = '') |
| 147 | 147 | { |
| 148 | 148 | $nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce"; |
| 149 | - if (! $this->request->isAdmin() |
|
| 149 | + if ( ! $this->request->isAdmin() |
|
| 150 | 150 | && ( |
| 151 | 151 | ! $this->request->is_set($nonce_name_with_id) |
| 152 | 152 | || ! wp_verify_nonce( |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | $this->validatePostData($id) |
| 207 | 207 | ); |
| 208 | 208 | // check total tickets ordered vs max number of attendees that can register |
| 209 | - if (! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) { |
|
| 209 | + if ( ! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) { |
|
| 210 | 210 | $this->maxAttendeesViolation($valid); |
| 211 | 211 | } else { |
| 212 | 212 | // all data appears to be valid |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | private function getEventId() |
| 237 | 237 | { |
| 238 | 238 | // do we have an event id? |
| 239 | - if (! $this->request->requestParamIsSet('tkt-slctr-event-id')) { |
|
| 239 | + if ( ! $this->request->requestParamIsSet('tkt-slctr-event-id')) { |
|
| 240 | 240 | // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
| 241 | 241 | EE_Error::add_error( |
| 242 | 242 | sprintf( |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | */ |
| 265 | 265 | private function validatePostData($id = 0) |
| 266 | 266 | { |
| 267 | - if (! $id) { |
|
| 267 | + if ( ! $id) { |
|
| 268 | 268 | EE_Error::add_error( |
| 269 | 269 | esc_html__('The event id provided was not valid.', 'event_espresso'), |
| 270 | 270 | __FILE__, |
@@ -291,29 +291,29 @@ discard block |
||
| 291 | 291 | // cycle through $inputs_to_clean array |
| 292 | 292 | foreach ($inputs_to_clean as $what => $input_to_clean) { |
| 293 | 293 | // check for POST data |
| 294 | - if ($this->request->requestParamIsSet($input_to_clean . $id)) { |
|
| 294 | + if ($this->request->requestParamIsSet($input_to_clean.$id)) { |
|
| 295 | 295 | // grab value |
| 296 | - $input_value = $this->request->getRequestParam($input_to_clean . $id); |
|
| 296 | + $input_value = $this->request->getRequestParam($input_to_clean.$id); |
|
| 297 | 297 | switch ($what) { |
| 298 | 298 | // integers |
| 299 | 299 | case 'event_id': |
| 300 | - $valid_data[ $what ] = absint($input_value); |
|
| 300 | + $valid_data[$what] = absint($input_value); |
|
| 301 | 301 | // get event via the event id we put in the form |
| 302 | 302 | break; |
| 303 | 303 | case 'rows': |
| 304 | 304 | case 'max_atndz': |
| 305 | - $valid_data[ $what ] = absint($input_value); |
|
| 305 | + $valid_data[$what] = absint($input_value); |
|
| 306 | 306 | break; |
| 307 | 307 | // arrays of integers |
| 308 | 308 | case 'qty': |
| 309 | 309 | /** @var array $row_qty */ |
| 310 | 310 | $row_qty = $input_value; |
| 311 | 311 | // if qty is coming from a radio button input, then we need to assemble an array of rows |
| 312 | - if (! is_array($row_qty)) { |
|
| 312 | + if ( ! is_array($row_qty)) { |
|
| 313 | 313 | /** @var string $row_qty */ |
| 314 | 314 | // get number of rows |
| 315 | - $rows = $this->request->requestParamIsSet('tkt-slctr-rows-' . $id) |
|
| 316 | - ? absint($this->request->getRequestParam('tkt-slctr-rows-' . $id)) |
|
| 315 | + $rows = $this->request->requestParamIsSet('tkt-slctr-rows-'.$id) |
|
| 316 | + ? absint($this->request->getRequestParam('tkt-slctr-rows-'.$id)) |
|
| 317 | 317 | : 1; |
| 318 | 318 | // explode integers by the dash |
| 319 | 319 | $row_qty = explode('-', $row_qty); |
@@ -321,8 +321,8 @@ discard block |
||
| 321 | 321 | $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0; |
| 322 | 322 | $row_qty = array($row => $qty); |
| 323 | 323 | for ($x = 1; $x <= $rows; $x++) { |
| 324 | - if (! isset($row_qty[ $x ])) { |
|
| 325 | - $row_qty[ $x ] = 0; |
|
| 324 | + if ( ! isset($row_qty[$x])) { |
|
| 325 | + $row_qty[$x] = 0; |
|
| 326 | 326 | } |
| 327 | 327 | } |
| 328 | 328 | } |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | foreach ($row_qty as $qty) { |
| 332 | 332 | $qty = absint($qty); |
| 333 | 333 | // sanitize as integers |
| 334 | - $valid_data[ $what ][] = $qty; |
|
| 334 | + $valid_data[$what][] = $qty; |
|
| 335 | 335 | $valid_data['total_tickets'] += $qty; |
| 336 | 336 | } |
| 337 | 337 | break; |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | // cycle thru values |
| 341 | 341 | foreach ((array) $input_value as $key => $value) { |
| 342 | 342 | // allow only integers |
| 343 | - $valid_data[ $what ][ $key ] = absint($value); |
|
| 343 | + $valid_data[$what][$key] = absint($value); |
|
| 344 | 344 | } |
| 345 | 345 | break; |
| 346 | 346 | case 'return_url': |
@@ -352,9 +352,9 @@ discard block |
||
| 352 | 352 | $input_value = explode('#', $input_value); |
| 353 | 353 | $input_value = end($input_value); |
| 354 | 354 | // use event list url instead, but append anchor |
| 355 | - $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value; |
|
| 355 | + $input_value = EEH_Event_View::event_archive_url().'#'.$input_value; |
|
| 356 | 356 | } |
| 357 | - $valid_data[ $what ] = $input_value; |
|
| 357 | + $valid_data[$what] = $input_value; |
|
| 358 | 358 | break; |
| 359 | 359 | } // end switch $what |
| 360 | 360 | } |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | ) |
| 389 | 389 | ); |
| 390 | 390 | $limit_error_2 = sprintf($max_attendees_string, $valid['max_atndz'], $valid['max_atndz']); |
| 391 | - EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__); |
|
| 391 | + EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__); |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | |
@@ -404,13 +404,13 @@ discard block |
||
| 404 | 404 | { |
| 405 | 405 | $tickets_added = 0; |
| 406 | 406 | $tickets_selected = false; |
| 407 | - if (! empty($valid) && $valid['total_tickets'] > 0) { |
|
| 407 | + if ( ! empty($valid) && $valid['total_tickets'] > 0) { |
|
| 408 | 408 | // load cart using factory because we don't want to do so until actually needed |
| 409 | 409 | $this->cart = CartFactory::getCart(); |
| 410 | 410 | // cycle thru the number of data rows sent from the event listing |
| 411 | 411 | for ($x = 0; $x < $valid['rows']; $x++) { |
| 412 | 412 | // does this row actually contain a ticket quantity? |
| 413 | - if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) { |
|
| 413 | + if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) { |
|
| 414 | 414 | // YES we have a ticket quantity |
| 415 | 415 | $tickets_selected = true; |
| 416 | 416 | $valid_ticket = false; |
@@ -419,14 +419,14 @@ discard block |
||
| 419 | 419 | // '$valid[\'ticket_id\'][ $x ]', |
| 420 | 420 | // __FILE__, __LINE__ |
| 421 | 421 | // ); |
| 422 | - if (isset($valid['ticket_id'][ $x ])) { |
|
| 422 | + if (isset($valid['ticket_id'][$x])) { |
|
| 423 | 423 | // get ticket via the ticket id we put in the form |
| 424 | - $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][ $x ]); |
|
| 424 | + $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][$x]); |
|
| 425 | 425 | if ($ticket instanceof EE_Ticket) { |
| 426 | 426 | $valid_ticket = true; |
| 427 | 427 | $tickets_added += $this->addTicketToCart( |
| 428 | 428 | $ticket, |
| 429 | - $valid['qty'][ $x ] |
|
| 429 | + $valid['qty'][$x] |
|
| 430 | 430 | ); |
| 431 | 431 | } |
| 432 | 432 | } |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | $this->cart, |
| 457 | 457 | $this |
| 458 | 458 | ); |
| 459 | - if (! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) { |
|
| 459 | + if ( ! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) { |
|
| 460 | 460 | // no ticket quantities were selected |
| 461 | 461 | EE_Error::add_error( |
| 462 | 462 | esc_html__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | // compare available spaces against the number of tickets being purchased |
| 488 | 488 | if ($available_spaces >= $qty) { |
| 489 | 489 | // allow addons to prevent a ticket from being added to cart |
| 490 | - if (! apply_filters( |
|
| 490 | + if ( ! apply_filters( |
|
| 491 | 491 | 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', |
| 492 | 492 | true, |
| 493 | 493 | $ticket, |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | // exit('KILL REDIRECT BEFORE CART UPDATE'); // <<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE |
| 523 | 523 | if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) { |
| 524 | 524 | // make sure cart is loaded |
| 525 | - if (! $this->cart instanceof EE_Cart) { |
|
| 525 | + if ( ! $this->cart instanceof EE_Cart) { |
|
| 526 | 526 | $this->cart = CartFactory::getCart(); |
| 527 | 527 | } |
| 528 | 528 | do_action( |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | ) |
| 545 | 545 | ); |
| 546 | 546 | } |
| 547 | - if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) { |
|
| 547 | + if ( ! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) { |
|
| 548 | 548 | // nothing added to cart |
| 549 | 549 | EE_Error::add_attention( |
| 550 | 550 | esc_html__('No tickets were added for the event', 'event_espresso'), |
@@ -12,2893 +12,2893 @@ |
||
| 12 | 12 | class EE_SPCO_Reg_Step_Payment_Options extends EE_SPCO_Reg_Step |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @access protected |
|
| 17 | - * @var EE_Line_Item_Display $Line_Item_Display |
|
| 18 | - */ |
|
| 19 | - protected $line_item_display; |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * @access protected |
|
| 23 | - * @var boolean $handle_IPN_in_this_request |
|
| 24 | - */ |
|
| 25 | - protected $handle_IPN_in_this_request = false; |
|
| 26 | - |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
| 30 | - * |
|
| 31 | - * @access public |
|
| 32 | - * @return void |
|
| 33 | - */ |
|
| 34 | - public static function set_hooks() |
|
| 35 | - { |
|
| 36 | - add_filter( |
|
| 37 | - 'FHEE__SPCO__EE_Line_Item_Filter_Collection', |
|
| 38 | - array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters') |
|
| 39 | - ); |
|
| 40 | - add_action( |
|
| 41 | - 'wp_ajax_switch_spco_billing_form', |
|
| 42 | - array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form') |
|
| 43 | - ); |
|
| 44 | - add_action( |
|
| 45 | - 'wp_ajax_nopriv_switch_spco_billing_form', |
|
| 46 | - array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form') |
|
| 47 | - ); |
|
| 48 | - add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')); |
|
| 49 | - add_action( |
|
| 50 | - 'wp_ajax_nopriv_save_payer_details', |
|
| 51 | - array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details') |
|
| 52 | - ); |
|
| 53 | - add_action( |
|
| 54 | - 'wp_ajax_get_transaction_details_for_gateways', |
|
| 55 | - array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
| 56 | - ); |
|
| 57 | - add_action( |
|
| 58 | - 'wp_ajax_nopriv_get_transaction_details_for_gateways', |
|
| 59 | - array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
| 60 | - ); |
|
| 61 | - add_filter( |
|
| 62 | - 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
|
| 63 | - array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'), |
|
| 64 | - 10, |
|
| 65 | - 1 |
|
| 66 | - ); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * ajax switch_spco_billing_form |
|
| 72 | - * |
|
| 73 | - * @throws \EE_Error |
|
| 74 | - */ |
|
| 75 | - public static function switch_spco_billing_form() |
|
| 76 | - { |
|
| 77 | - EED_Single_Page_Checkout::process_ajax_request('switch_payment_method'); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * ajax save_payer_details |
|
| 83 | - * |
|
| 84 | - * @throws \EE_Error |
|
| 85 | - */ |
|
| 86 | - public static function save_payer_details() |
|
| 87 | - { |
|
| 88 | - EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax'); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * ajax get_transaction_details |
|
| 94 | - * |
|
| 95 | - * @throws \EE_Error |
|
| 96 | - */ |
|
| 97 | - public static function get_transaction_details() |
|
| 98 | - { |
|
| 99 | - EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways'); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * bypass_recaptcha_for_load_payment_method |
|
| 105 | - * |
|
| 106 | - * @access public |
|
| 107 | - * @return array |
|
| 108 | - * @throws InvalidArgumentException |
|
| 109 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 110 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 111 | - */ |
|
| 112 | - public static function bypass_recaptcha_for_load_payment_method() |
|
| 113 | - { |
|
| 114 | - return array( |
|
| 115 | - 'EESID' => EE_Registry::instance()->SSN->id(), |
|
| 116 | - 'step' => 'payment_options', |
|
| 117 | - 'action' => 'spco_billing_form', |
|
| 118 | - ); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * class constructor |
|
| 124 | - * |
|
| 125 | - * @access public |
|
| 126 | - * @param EE_Checkout $checkout |
|
| 127 | - */ |
|
| 128 | - public function __construct(EE_Checkout $checkout) |
|
| 129 | - { |
|
| 130 | - $this->_slug = 'payment_options'; |
|
| 131 | - $this->_name = esc_html__('Payment Options', 'event_espresso'); |
|
| 132 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . '/payment_options_main.template.php'; |
|
| 133 | - $this->checkout = $checkout; |
|
| 134 | - $this->_reset_success_message(); |
|
| 135 | - $this->set_instructions( |
|
| 136 | - esc_html__( |
|
| 137 | - 'Please select a method of payment and provide any necessary billing information before proceeding.', |
|
| 138 | - 'event_espresso' |
|
| 139 | - ) |
|
| 140 | - ); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * @return null |
|
| 146 | - */ |
|
| 147 | - public function line_item_display() |
|
| 148 | - { |
|
| 149 | - return $this->line_item_display; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * @param null $line_item_display |
|
| 155 | - */ |
|
| 156 | - public function set_line_item_display($line_item_display) |
|
| 157 | - { |
|
| 158 | - $this->line_item_display = $line_item_display; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * @return boolean |
|
| 164 | - */ |
|
| 165 | - public function handle_IPN_in_this_request() |
|
| 166 | - { |
|
| 167 | - return $this->handle_IPN_in_this_request; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * @param boolean $handle_IPN_in_this_request |
|
| 173 | - */ |
|
| 174 | - public function set_handle_IPN_in_this_request($handle_IPN_in_this_request) |
|
| 175 | - { |
|
| 176 | - $this->handle_IPN_in_this_request = filter_var($handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN); |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * translate_js_strings |
|
| 182 | - * |
|
| 183 | - * @return void |
|
| 184 | - */ |
|
| 185 | - public function translate_js_strings() |
|
| 186 | - { |
|
| 187 | - EE_Registry::$i18n_js_strings['no_payment_method'] = esc_html__( |
|
| 188 | - 'Please select a method of payment in order to continue.', |
|
| 189 | - 'event_espresso' |
|
| 190 | - ); |
|
| 191 | - EE_Registry::$i18n_js_strings['invalid_payment_method'] = esc_html__( |
|
| 192 | - 'A valid method of payment could not be determined. Please refresh the page and try again.', |
|
| 193 | - 'event_espresso' |
|
| 194 | - ); |
|
| 195 | - EE_Registry::$i18n_js_strings['forwarding_to_offsite'] = esc_html__( |
|
| 196 | - 'Forwarding to Secure Payment Provider.', |
|
| 197 | - 'event_espresso' |
|
| 198 | - ); |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * enqueue_styles_and_scripts |
|
| 204 | - * |
|
| 205 | - * @return void |
|
| 206 | - * @throws EE_Error |
|
| 207 | - * @throws InvalidArgumentException |
|
| 208 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 209 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 210 | - */ |
|
| 211 | - public function enqueue_styles_and_scripts() |
|
| 212 | - { |
|
| 213 | - $transaction = $this->checkout->transaction; |
|
| 214 | - // if the transaction isn't set or nothing is owed on it, don't enqueue any JS |
|
| 215 | - if (! $transaction instanceof EE_Transaction || EEH_Money::compare_floats($transaction->remaining(), 0)) { |
|
| 216 | - return; |
|
| 217 | - } |
|
| 218 | - foreach (EEM_Payment_Method::instance()->get_all_for_transaction( |
|
| 219 | - $transaction, |
|
| 220 | - EEM_Payment_Method::scope_cart |
|
| 221 | - ) as $payment_method) { |
|
| 222 | - $type_obj = $payment_method->type_obj(); |
|
| 223 | - if ($type_obj instanceof EE_PMT_Base) { |
|
| 224 | - $billing_form = $type_obj->generate_new_billing_form($transaction); |
|
| 225 | - if ($billing_form instanceof EE_Form_Section_Proper) { |
|
| 226 | - $billing_form->enqueue_js(); |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - |
|
| 233 | - /** |
|
| 234 | - * initialize_reg_step |
|
| 235 | - * |
|
| 236 | - * @return bool |
|
| 237 | - * @throws EE_Error |
|
| 238 | - * @throws InvalidArgumentException |
|
| 239 | - * @throws ReflectionException |
|
| 240 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 241 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 242 | - */ |
|
| 243 | - public function initialize_reg_step() |
|
| 244 | - { |
|
| 245 | - // TODO: if /when we implement donations, then this will need overriding |
|
| 246 | - if (// don't need payment options for: |
|
| 247 | - // registrations made via the admin |
|
| 248 | - // completed transactions |
|
| 249 | - // overpaid transactions |
|
| 250 | - // $ 0.00 transactions(no payment required) |
|
| 251 | - ! $this->checkout->payment_required() |
|
| 252 | - // but do NOT remove if current action being called belongs to this reg step |
|
| 253 | - && ! is_callable(array($this, $this->checkout->action)) |
|
| 254 | - && ! $this->completed() |
|
| 255 | - ) { |
|
| 256 | - // and if so, then we no longer need the Payment Options step |
|
| 257 | - if ($this->is_current_step()) { |
|
| 258 | - $this->checkout->generate_reg_form = false; |
|
| 259 | - } |
|
| 260 | - $this->checkout->remove_reg_step($this->_slug); |
|
| 261 | - // DEBUG LOG |
|
| 262 | - // $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
|
| 263 | - return false; |
|
| 264 | - } |
|
| 265 | - // load EEM_Payment_Method |
|
| 266 | - EE_Registry::instance()->load_model('Payment_Method'); |
|
| 267 | - // get all active payment methods |
|
| 268 | - $this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( |
|
| 269 | - $this->checkout->transaction, |
|
| 270 | - EEM_Payment_Method::scope_cart |
|
| 271 | - ); |
|
| 272 | - return true; |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - |
|
| 276 | - /** |
|
| 277 | - * @return EE_Form_Section_Proper |
|
| 278 | - * @throws EE_Error |
|
| 279 | - * @throws InvalidArgumentException |
|
| 280 | - * @throws ReflectionException |
|
| 281 | - * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 282 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 283 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 284 | - * @throws \EventEspresso\core\exceptions\InvalidStatusException |
|
| 285 | - */ |
|
| 286 | - public function generate_reg_form() |
|
| 287 | - { |
|
| 288 | - // reset in case someone changes their mind |
|
| 289 | - $this->_reset_selected_method_of_payment(); |
|
| 290 | - // set some defaults |
|
| 291 | - $this->checkout->selected_method_of_payment = 'payments_closed'; |
|
| 292 | - $registrations_requiring_payment = array(); |
|
| 293 | - $registrations_for_free_events = array(); |
|
| 294 | - $registrations_requiring_pre_approval = array(); |
|
| 295 | - $sold_out_events = array(); |
|
| 296 | - $insufficient_spaces_available = array(); |
|
| 297 | - $no_payment_required = true; |
|
| 298 | - // loop thru registrations to gather info |
|
| 299 | - $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
| 300 | - $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space( |
|
| 301 | - $registrations, |
|
| 302 | - $this->checkout->revisit |
|
| 303 | - ); |
|
| 304 | - foreach ($registrations as $REG_ID => $registration) { |
|
| 305 | - /** @var $registration EE_Registration */ |
|
| 306 | - // has this registration lost it's space ? |
|
| 307 | - if (isset($ejected_registrations[ $REG_ID ])) { |
|
| 308 | - if ($registration->event()->is_sold_out() || $registration->event()->is_sold_out(true)) { |
|
| 309 | - $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
| 310 | - } else { |
|
| 311 | - $insufficient_spaces_available[ $registration->event()->ID() ] = $registration->event(); |
|
| 312 | - } |
|
| 313 | - continue; |
|
| 314 | - } |
|
| 315 | - // event requires admin approval |
|
| 316 | - if ($registration->status_ID() === EEM_Registration::status_id_not_approved) { |
|
| 317 | - // add event to list of events with pre-approval reg status |
|
| 318 | - $registrations_requiring_pre_approval[ $REG_ID ] = $registration; |
|
| 319 | - do_action( |
|
| 320 | - 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval', |
|
| 321 | - $registration->event(), |
|
| 322 | - $this |
|
| 323 | - ); |
|
| 324 | - continue; |
|
| 325 | - } |
|
| 326 | - if ($this->checkout->revisit |
|
| 327 | - && $registration->status_ID() !== EEM_Registration::status_id_approved |
|
| 328 | - && ( |
|
| 329 | - $registration->event()->is_sold_out() |
|
| 330 | - || $registration->event()->is_sold_out(true) |
|
| 331 | - ) |
|
| 332 | - ) { |
|
| 333 | - // add event to list of events that are sold out |
|
| 334 | - $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
| 335 | - do_action( |
|
| 336 | - 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
|
| 337 | - $registration->event(), |
|
| 338 | - $this |
|
| 339 | - ); |
|
| 340 | - continue; |
|
| 341 | - } |
|
| 342 | - // are they allowed to pay now and is there monies owing? |
|
| 343 | - if ($registration->owes_monies_and_can_pay()) { |
|
| 344 | - $registrations_requiring_payment[ $REG_ID ] = $registration; |
|
| 345 | - do_action( |
|
| 346 | - 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment', |
|
| 347 | - $registration->event(), |
|
| 348 | - $this |
|
| 349 | - ); |
|
| 350 | - } elseif (! $this->checkout->revisit |
|
| 351 | - && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
|
| 352 | - && $registration->ticket()->is_free() |
|
| 353 | - ) { |
|
| 354 | - $registrations_for_free_events[ $registration->ticket()->ID() ] = $registration; |
|
| 355 | - } |
|
| 356 | - } |
|
| 357 | - $subsections = array(); |
|
| 358 | - // now decide which template to load |
|
| 359 | - if (! empty($sold_out_events)) { |
|
| 360 | - $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events); |
|
| 361 | - } |
|
| 362 | - if (! empty($insufficient_spaces_available)) { |
|
| 363 | - $subsections['insufficient_space'] = $this->_insufficient_spaces_available( |
|
| 364 | - $insufficient_spaces_available |
|
| 365 | - ); |
|
| 366 | - } |
|
| 367 | - if (! empty($registrations_requiring_pre_approval)) { |
|
| 368 | - $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval( |
|
| 369 | - $registrations_requiring_pre_approval |
|
| 370 | - ); |
|
| 371 | - } |
|
| 372 | - if (! empty($registrations_for_free_events)) { |
|
| 373 | - $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events); |
|
| 374 | - } |
|
| 375 | - if (! empty($registrations_requiring_payment)) { |
|
| 376 | - if ($this->checkout->amount_owing > 0) { |
|
| 377 | - // autoload Line_Item_Display classes |
|
| 378 | - EEH_Autoloader::register_line_item_filter_autoloaders(); |
|
| 379 | - $line_item_filter_processor = new EE_Line_Item_Filter_Processor( |
|
| 380 | - apply_filters( |
|
| 381 | - 'FHEE__SPCO__EE_Line_Item_Filter_Collection', |
|
| 382 | - new EE_Line_Item_Filter_Collection() |
|
| 383 | - ), |
|
| 384 | - $this->checkout->cart->get_grand_total() |
|
| 385 | - ); |
|
| 386 | - /** @var EE_Line_Item $filtered_line_item_tree */ |
|
| 387 | - $filtered_line_item_tree = $line_item_filter_processor->process(); |
|
| 388 | - EEH_Autoloader::register_line_item_display_autoloaders(); |
|
| 389 | - $this->set_line_item_display(new EE_Line_Item_Display('spco')); |
|
| 390 | - $subsections['payment_options'] = $this->_display_payment_options( |
|
| 391 | - $this->line_item_display->display_line_item( |
|
| 392 | - $filtered_line_item_tree, |
|
| 393 | - array('registrations' => $registrations) |
|
| 394 | - ) |
|
| 395 | - ); |
|
| 396 | - $this->checkout->amount_owing = $filtered_line_item_tree->total(); |
|
| 397 | - $this->_apply_registration_payments_to_amount_owing($registrations); |
|
| 398 | - } |
|
| 399 | - $no_payment_required = false; |
|
| 400 | - } else { |
|
| 401 | - $this->_hide_reg_step_submit_button_if_revisit(); |
|
| 402 | - } |
|
| 403 | - $this->_save_selected_method_of_payment(); |
|
| 404 | - |
|
| 405 | - $subsections['default_hidden_inputs'] = $this->reg_step_hidden_inputs(); |
|
| 406 | - $subsections['extra_hidden_inputs'] = $this->_extra_hidden_inputs($no_payment_required); |
|
| 407 | - |
|
| 408 | - return new EE_Form_Section_Proper( |
|
| 409 | - array( |
|
| 410 | - 'name' => $this->reg_form_name(), |
|
| 411 | - 'html_id' => $this->reg_form_name(), |
|
| 412 | - 'subsections' => $subsections, |
|
| 413 | - 'layout_strategy' => new EE_No_Layout(), |
|
| 414 | - ) |
|
| 415 | - ); |
|
| 416 | - } |
|
| 417 | - |
|
| 418 | - |
|
| 419 | - /** |
|
| 420 | - * add line item filters required for this reg step |
|
| 421 | - * these filters are applied via this line in EE_SPCO_Reg_Step_Payment_Options::set_hooks(): |
|
| 422 | - * add_filter( 'FHEE__SPCO__EE_Line_Item_Filter_Collection', array( 'EE_SPCO_Reg_Step_Payment_Options', |
|
| 423 | - * 'add_spco_line_item_filters' ) ); so any code that wants to use the same set of filters during the |
|
| 424 | - * payment options reg step, can apply these filters via the following: apply_filters( |
|
| 425 | - * 'FHEE__SPCO__EE_Line_Item_Filter_Collection', new EE_Line_Item_Filter_Collection() ) or to an existing |
|
| 426 | - * filter collection by passing that instead of instantiating a new collection |
|
| 427 | - * |
|
| 428 | - * @param \EE_Line_Item_Filter_Collection $line_item_filter_collection |
|
| 429 | - * @return EE_Line_Item_Filter_Collection |
|
| 430 | - * @throws EE_Error |
|
| 431 | - * @throws InvalidArgumentException |
|
| 432 | - * @throws ReflectionException |
|
| 433 | - * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 434 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 435 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 436 | - * @throws \EventEspresso\core\exceptions\InvalidStatusException |
|
| 437 | - */ |
|
| 438 | - public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) |
|
| 439 | - { |
|
| 440 | - if (! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
| 441 | - return $line_item_filter_collection; |
|
| 442 | - } |
|
| 443 | - if (! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout) { |
|
| 444 | - return $line_item_filter_collection; |
|
| 445 | - } |
|
| 446 | - if (! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction) { |
|
| 447 | - return $line_item_filter_collection; |
|
| 448 | - } |
|
| 449 | - $line_item_filter_collection->add( |
|
| 450 | - new EE_Billable_Line_Item_Filter( |
|
| 451 | - EE_SPCO_Reg_Step_Payment_Options::remove_ejected_registrations( |
|
| 452 | - EE_Registry::instance()->SSN->checkout()->transaction->registrations( |
|
| 453 | - EE_Registry::instance()->SSN->checkout()->reg_cache_where_params |
|
| 454 | - ) |
|
| 455 | - ) |
|
| 456 | - ) |
|
| 457 | - ); |
|
| 458 | - $line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter()); |
|
| 459 | - return $line_item_filter_collection; |
|
| 460 | - } |
|
| 461 | - |
|
| 462 | - |
|
| 463 | - /** |
|
| 464 | - * remove_ejected_registrations |
|
| 465 | - * if a registrant has lost their potential space at an event due to lack of payment, |
|
| 466 | - * then this method removes them from the list of registrations being paid for during this request |
|
| 467 | - * |
|
| 468 | - * @param \EE_Registration[] $registrations |
|
| 469 | - * @return EE_Registration[] |
|
| 470 | - * @throws EE_Error |
|
| 471 | - * @throws InvalidArgumentException |
|
| 472 | - * @throws ReflectionException |
|
| 473 | - * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 474 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 475 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 476 | - * @throws \EventEspresso\core\exceptions\InvalidStatusException |
|
| 477 | - */ |
|
| 478 | - public static function remove_ejected_registrations(array $registrations) |
|
| 479 | - { |
|
| 480 | - $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space( |
|
| 481 | - $registrations, |
|
| 482 | - EE_Registry::instance()->SSN->checkout()->revisit |
|
| 483 | - ); |
|
| 484 | - foreach ($registrations as $REG_ID => $registration) { |
|
| 485 | - // has this registration lost it's space ? |
|
| 486 | - if (isset($ejected_registrations[ $REG_ID ])) { |
|
| 487 | - unset($registrations[ $REG_ID ]); |
|
| 488 | - continue; |
|
| 489 | - } |
|
| 490 | - } |
|
| 491 | - return $registrations; |
|
| 492 | - } |
|
| 493 | - |
|
| 494 | - |
|
| 495 | - /** |
|
| 496 | - * find_registrations_that_lost_their_space |
|
| 497 | - * If a registrant chooses an offline payment method like Invoice, |
|
| 498 | - * then no space is reserved for them at the event until they fully pay fo that site |
|
| 499 | - * (unless the event's default reg status is set to APPROVED) |
|
| 500 | - * if a registrant then later returns to pay, but the number of spaces available has been reduced due to sales, |
|
| 501 | - * then this method will determine which registrations have lost the ability to complete the reg process. |
|
| 502 | - * |
|
| 503 | - * @param \EE_Registration[] $registrations |
|
| 504 | - * @param bool $revisit |
|
| 505 | - * @return array |
|
| 506 | - * @throws EE_Error |
|
| 507 | - * @throws InvalidArgumentException |
|
| 508 | - * @throws ReflectionException |
|
| 509 | - * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 510 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 511 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 512 | - * @throws \EventEspresso\core\exceptions\InvalidStatusException |
|
| 513 | - */ |
|
| 514 | - public static function find_registrations_that_lost_their_space(array $registrations, $revisit = false) |
|
| 515 | - { |
|
| 516 | - // registrations per event |
|
| 517 | - $event_reg_count = array(); |
|
| 518 | - // spaces left per event |
|
| 519 | - $event_spaces_remaining = array(); |
|
| 520 | - // tickets left sorted by ID |
|
| 521 | - $tickets_remaining = array(); |
|
| 522 | - // registrations that have lost their space |
|
| 523 | - $ejected_registrations = array(); |
|
| 524 | - foreach ($registrations as $REG_ID => $registration) { |
|
| 525 | - if ($registration->status_ID() === EEM_Registration::status_id_approved |
|
| 526 | - || apply_filters( |
|
| 527 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options__find_registrations_that_lost_their_space__allow_reg_payment', |
|
| 528 | - false, |
|
| 529 | - $registration, |
|
| 530 | - $revisit |
|
| 531 | - ) |
|
| 532 | - ) { |
|
| 533 | - continue; |
|
| 534 | - } |
|
| 535 | - $EVT_ID = $registration->event_ID(); |
|
| 536 | - $ticket = $registration->ticket(); |
|
| 537 | - if (! isset($tickets_remaining[ $ticket->ID() ])) { |
|
| 538 | - $tickets_remaining[ $ticket->ID() ] = $ticket->remaining(); |
|
| 539 | - } |
|
| 540 | - if ($tickets_remaining[ $ticket->ID() ] > 0) { |
|
| 541 | - if (! isset($event_reg_count[ $EVT_ID ])) { |
|
| 542 | - $event_reg_count[ $EVT_ID ] = 0; |
|
| 543 | - } |
|
| 544 | - $event_reg_count[ $EVT_ID ]++; |
|
| 545 | - if (! isset($event_spaces_remaining[ $EVT_ID ])) { |
|
| 546 | - $event_spaces_remaining[ $EVT_ID ] = $registration->event()->spaces_remaining_for_sale(); |
|
| 547 | - } |
|
| 548 | - } |
|
| 549 | - if ($revisit |
|
| 550 | - && ($tickets_remaining[ $ticket->ID() ] === 0 |
|
| 551 | - || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ] |
|
| 552 | - ) |
|
| 553 | - ) { |
|
| 554 | - $ejected_registrations[ $REG_ID ] = $registration->event(); |
|
| 555 | - if ($registration->status_ID() !== EEM_Registration::status_id_wait_list) { |
|
| 556 | - /** @type EE_Registration_Processor $registration_processor */ |
|
| 557 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
| 558 | - // at this point, we should have enough details about the registrant to consider the registration |
|
| 559 | - // NOT incomplete |
|
| 560 | - $registration_processor->manually_update_registration_status( |
|
| 561 | - $registration, |
|
| 562 | - EEM_Registration::status_id_wait_list |
|
| 563 | - ); |
|
| 564 | - } |
|
| 565 | - } |
|
| 566 | - } |
|
| 567 | - return $ejected_registrations; |
|
| 568 | - } |
|
| 569 | - |
|
| 570 | - |
|
| 571 | - /** |
|
| 572 | - * _hide_reg_step_submit_button |
|
| 573 | - * removes the html for the reg step submit button |
|
| 574 | - * by replacing it with an empty string via filter callback |
|
| 575 | - * |
|
| 576 | - * @return void |
|
| 577 | - */ |
|
| 578 | - protected function _adjust_registration_status_if_event_old_sold() |
|
| 579 | - { |
|
| 580 | - } |
|
| 581 | - |
|
| 582 | - |
|
| 583 | - /** |
|
| 584 | - * _hide_reg_step_submit_button |
|
| 585 | - * removes the html for the reg step submit button |
|
| 586 | - * by replacing it with an empty string via filter callback |
|
| 587 | - * |
|
| 588 | - * @return void |
|
| 589 | - */ |
|
| 590 | - protected function _hide_reg_step_submit_button_if_revisit() |
|
| 591 | - { |
|
| 592 | - if ($this->checkout->revisit) { |
|
| 593 | - add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string'); |
|
| 594 | - } |
|
| 595 | - } |
|
| 596 | - |
|
| 597 | - |
|
| 598 | - /** |
|
| 599 | - * sold_out_events |
|
| 600 | - * displays notices regarding events that have sold out since hte registrant first signed up |
|
| 601 | - * |
|
| 602 | - * @param \EE_Event[] $sold_out_events_array |
|
| 603 | - * @return \EE_Form_Section_Proper |
|
| 604 | - * @throws \EE_Error |
|
| 605 | - */ |
|
| 606 | - private function _sold_out_events($sold_out_events_array = array()) |
|
| 607 | - { |
|
| 608 | - // set some defaults |
|
| 609 | - $this->checkout->selected_method_of_payment = 'events_sold_out'; |
|
| 610 | - $sold_out_events = ''; |
|
| 611 | - foreach ($sold_out_events_array as $sold_out_event) { |
|
| 612 | - $sold_out_events .= EEH_HTML::li( |
|
| 613 | - EEH_HTML::span( |
|
| 614 | - ' ' . $sold_out_event->name(), |
|
| 615 | - '', |
|
| 616 | - 'dashicons dashicons-marker ee-icon-size-16 pink-text' |
|
| 617 | - ) |
|
| 618 | - ); |
|
| 619 | - } |
|
| 620 | - return new EE_Form_Section_Proper( |
|
| 621 | - array( |
|
| 622 | - 'layout_strategy' => new EE_Template_Layout( |
|
| 623 | - array( |
|
| 624 | - 'layout_template_file' => SPCO_REG_STEPS_PATH |
|
| 625 | - . $this->_slug |
|
| 626 | - . '/sold_out_events.template.php', |
|
| 627 | - 'template_args' => apply_filters( |
|
| 628 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
|
| 629 | - array( |
|
| 630 | - 'sold_out_events' => $sold_out_events, |
|
| 631 | - 'sold_out_events_msg' => apply_filters( |
|
| 632 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__sold_out_events_msg', |
|
| 633 | - sprintf( |
|
| 634 | - esc_html__( |
|
| 635 | - 'It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.%3$s%3$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%2$s', |
|
| 636 | - 'event_espresso' |
|
| 637 | - ), |
|
| 638 | - '<strong>', |
|
| 639 | - '</strong>', |
|
| 640 | - '<br />' |
|
| 641 | - ) |
|
| 642 | - ), |
|
| 643 | - ) |
|
| 644 | - ), |
|
| 645 | - ) |
|
| 646 | - ), |
|
| 647 | - ) |
|
| 648 | - ); |
|
| 649 | - } |
|
| 650 | - |
|
| 651 | - |
|
| 652 | - /** |
|
| 653 | - * _insufficient_spaces_available |
|
| 654 | - * displays notices regarding events that do not have enough remaining spaces |
|
| 655 | - * to satisfy the current number of registrations looking to pay |
|
| 656 | - * |
|
| 657 | - * @param \EE_Event[] $insufficient_spaces_events_array |
|
| 658 | - * @return \EE_Form_Section_Proper |
|
| 659 | - * @throws \EE_Error |
|
| 660 | - */ |
|
| 661 | - private function _insufficient_spaces_available($insufficient_spaces_events_array = array()) |
|
| 662 | - { |
|
| 663 | - // set some defaults |
|
| 664 | - $this->checkout->selected_method_of_payment = 'invoice'; |
|
| 665 | - $insufficient_space_events = ''; |
|
| 666 | - foreach ($insufficient_spaces_events_array as $event) { |
|
| 667 | - if ($event instanceof EE_Event) { |
|
| 668 | - $insufficient_space_events .= EEH_HTML::li( |
|
| 669 | - EEH_HTML::span(' ' . $event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text') |
|
| 670 | - ); |
|
| 671 | - } |
|
| 672 | - } |
|
| 673 | - return new EE_Form_Section_Proper( |
|
| 674 | - array( |
|
| 675 | - 'subsections' => array( |
|
| 676 | - 'default_hidden_inputs' => $this->reg_step_hidden_inputs(), |
|
| 677 | - 'extra_hidden_inputs' => $this->_extra_hidden_inputs(), |
|
| 678 | - ), |
|
| 679 | - 'layout_strategy' => new EE_Template_Layout( |
|
| 680 | - array( |
|
| 681 | - 'layout_template_file' => SPCO_REG_STEPS_PATH |
|
| 682 | - . $this->_slug |
|
| 683 | - . '/sold_out_events.template.php', |
|
| 684 | - 'template_args' => apply_filters( |
|
| 685 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options___insufficient_spaces_available__template_args', |
|
| 686 | - array( |
|
| 687 | - 'sold_out_events' => $insufficient_space_events, |
|
| 688 | - 'sold_out_events_msg' => apply_filters( |
|
| 689 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options___insufficient_spaces_available__insufficient_space_msg', |
|
| 690 | - esc_html__( |
|
| 691 | - 'It appears that the event you were about to make a payment for has sold additional tickets since you first registered, and there are no longer enough spaces left to accommodate your selections. You may continue to pay and secure the available space(s) remaining, or simply cancel if you no longer wish to purchase. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', |
|
| 692 | - 'event_espresso' |
|
| 693 | - ) |
|
| 694 | - ), |
|
| 695 | - ) |
|
| 696 | - ), |
|
| 697 | - ) |
|
| 698 | - ), |
|
| 699 | - ) |
|
| 700 | - ); |
|
| 701 | - } |
|
| 702 | - |
|
| 703 | - |
|
| 704 | - /** |
|
| 705 | - * registrations_requiring_pre_approval |
|
| 706 | - * |
|
| 707 | - * @param array $registrations_requiring_pre_approval |
|
| 708 | - * @return EE_Form_Section_Proper |
|
| 709 | - * @throws EE_Error |
|
| 710 | - * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 711 | - */ |
|
| 712 | - private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array()) |
|
| 713 | - { |
|
| 714 | - $events_requiring_pre_approval = array(); |
|
| 715 | - foreach ($registrations_requiring_pre_approval as $registration) { |
|
| 716 | - if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) { |
|
| 717 | - $events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li( |
|
| 718 | - EEH_HTML::span( |
|
| 719 | - '', |
|
| 720 | - '', |
|
| 721 | - 'dashicons dashicons-marker ee-icon-size-16 orange-text' |
|
| 722 | - ) |
|
| 723 | - . EEH_HTML::span($registration->event()->name(), '', 'orange-text') |
|
| 724 | - ); |
|
| 725 | - } |
|
| 726 | - } |
|
| 727 | - return new EE_Form_Section_Proper( |
|
| 728 | - array( |
|
| 729 | - 'layout_strategy' => new EE_Template_Layout( |
|
| 730 | - array( |
|
| 731 | - 'layout_template_file' => SPCO_REG_STEPS_PATH |
|
| 732 | - . $this->_slug |
|
| 733 | - . '/events_requiring_pre_approval.template.php', // layout_template |
|
| 734 | - 'template_args' => apply_filters( |
|
| 735 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
|
| 736 | - array( |
|
| 737 | - 'events_requiring_pre_approval' => implode('', $events_requiring_pre_approval), |
|
| 738 | - 'events_requiring_pre_approval_msg' => apply_filters( |
|
| 739 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg', |
|
| 740 | - esc_html__( |
|
| 741 | - 'The following events do not require payment at this time and will not be billed during this transaction. Billing will only occur after the attendee has been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.', |
|
| 742 | - 'event_espresso' |
|
| 743 | - ) |
|
| 744 | - ), |
|
| 745 | - ) |
|
| 746 | - ), |
|
| 747 | - ) |
|
| 748 | - ), |
|
| 749 | - ) |
|
| 750 | - ); |
|
| 751 | - } |
|
| 752 | - |
|
| 753 | - |
|
| 754 | - /** |
|
| 755 | - * _no_payment_required |
|
| 756 | - * |
|
| 757 | - * @param \EE_Event[] $registrations_for_free_events |
|
| 758 | - * @return \EE_Form_Section_Proper |
|
| 759 | - * @throws \EE_Error |
|
| 760 | - */ |
|
| 761 | - private function _no_payment_required($registrations_for_free_events = array()) |
|
| 762 | - { |
|
| 763 | - // set some defaults |
|
| 764 | - $this->checkout->selected_method_of_payment = 'no_payment_required'; |
|
| 765 | - // generate no_payment_required form |
|
| 766 | - return new EE_Form_Section_Proper( |
|
| 767 | - array( |
|
| 768 | - 'layout_strategy' => new EE_Template_Layout( |
|
| 769 | - array( |
|
| 770 | - 'layout_template_file' => SPCO_REG_STEPS_PATH |
|
| 771 | - . $this->_slug |
|
| 772 | - . '/no_payment_required.template.php', // layout_template |
|
| 773 | - 'template_args' => apply_filters( |
|
| 774 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options___no_payment_required__template_args', |
|
| 775 | - array( |
|
| 776 | - 'revisit' => $this->checkout->revisit, |
|
| 777 | - 'registrations' => array(), |
|
| 778 | - 'ticket_count' => array(), |
|
| 779 | - 'registrations_for_free_events' => $registrations_for_free_events, |
|
| 780 | - 'no_payment_required_msg' => EEH_HTML::p( |
|
| 781 | - esc_html__('This is a free event, so no billing will occur.', 'event_espresso') |
|
| 782 | - ), |
|
| 783 | - ) |
|
| 784 | - ), |
|
| 785 | - ) |
|
| 786 | - ), |
|
| 787 | - ) |
|
| 788 | - ); |
|
| 789 | - } |
|
| 790 | - |
|
| 791 | - |
|
| 792 | - /** |
|
| 793 | - * _display_payment_options |
|
| 794 | - * |
|
| 795 | - * @param string $transaction_details |
|
| 796 | - * @return EE_Form_Section_Proper |
|
| 797 | - * @throws EE_Error |
|
| 798 | - * @throws InvalidArgumentException |
|
| 799 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 800 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 801 | - */ |
|
| 802 | - private function _display_payment_options($transaction_details = '') |
|
| 803 | - { |
|
| 804 | - // has method_of_payment been set by no-js user? |
|
| 805 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(); |
|
| 806 | - // build payment options form |
|
| 807 | - return apply_filters( |
|
| 808 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__payment_options_form', |
|
| 809 | - new EE_Form_Section_Proper( |
|
| 810 | - array( |
|
| 811 | - 'subsections' => array( |
|
| 812 | - 'before_payment_options' => apply_filters( |
|
| 813 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options', |
|
| 814 | - new EE_Form_Section_Proper( |
|
| 815 | - array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
| 816 | - ) |
|
| 817 | - ), |
|
| 818 | - 'payment_options' => $this->_setup_payment_options(), |
|
| 819 | - 'after_payment_options' => apply_filters( |
|
| 820 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options', |
|
| 821 | - new EE_Form_Section_Proper( |
|
| 822 | - array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
| 823 | - ) |
|
| 824 | - ), |
|
| 825 | - ), |
|
| 826 | - 'layout_strategy' => new EE_Template_Layout( |
|
| 827 | - array( |
|
| 828 | - 'layout_template_file' => $this->_template, |
|
| 829 | - 'template_args' => apply_filters( |
|
| 830 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__template_args', |
|
| 831 | - array( |
|
| 832 | - 'reg_count' => $this->line_item_display->total_items(), |
|
| 833 | - 'transaction_details' => $transaction_details, |
|
| 834 | - 'available_payment_methods' => array(), |
|
| 835 | - ) |
|
| 836 | - ), |
|
| 837 | - ) |
|
| 838 | - ), |
|
| 839 | - ) |
|
| 840 | - ) |
|
| 841 | - ); |
|
| 842 | - } |
|
| 843 | - |
|
| 844 | - |
|
| 845 | - /** |
|
| 846 | - * _extra_hidden_inputs |
|
| 847 | - * |
|
| 848 | - * @param bool $no_payment_required |
|
| 849 | - * @return \EE_Form_Section_Proper |
|
| 850 | - * @throws \EE_Error |
|
| 851 | - */ |
|
| 852 | - private function _extra_hidden_inputs($no_payment_required = true) |
|
| 853 | - { |
|
| 854 | - return new EE_Form_Section_Proper( |
|
| 855 | - array( |
|
| 856 | - 'html_id' => 'ee-' . $this->slug() . '-extra-hidden-inputs', |
|
| 857 | - 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
| 858 | - 'subsections' => array( |
|
| 859 | - 'spco_no_payment_required' => new EE_Hidden_Input( |
|
| 860 | - array( |
|
| 861 | - 'normalization_strategy' => new EE_Boolean_Normalization(), |
|
| 862 | - 'html_name' => 'spco_no_payment_required', |
|
| 863 | - 'html_id' => 'spco-no-payment-required-payment_options', |
|
| 864 | - 'default' => $no_payment_required, |
|
| 865 | - ) |
|
| 866 | - ), |
|
| 867 | - 'spco_transaction_id' => new EE_Fixed_Hidden_Input( |
|
| 868 | - array( |
|
| 869 | - 'normalization_strategy' => new EE_Int_Normalization(), |
|
| 870 | - 'html_name' => 'spco_transaction_id', |
|
| 871 | - 'html_id' => 'spco-transaction-id', |
|
| 872 | - 'default' => $this->checkout->transaction->ID(), |
|
| 873 | - ) |
|
| 874 | - ), |
|
| 875 | - ), |
|
| 876 | - ) |
|
| 877 | - ); |
|
| 878 | - } |
|
| 879 | - |
|
| 880 | - |
|
| 881 | - /** |
|
| 882 | - * _apply_registration_payments_to_amount_owing |
|
| 883 | - * |
|
| 884 | - * @access protected |
|
| 885 | - * @param array $registrations |
|
| 886 | - * @throws EE_Error |
|
| 887 | - */ |
|
| 888 | - protected function _apply_registration_payments_to_amount_owing(array $registrations) |
|
| 889 | - { |
|
| 890 | - $payments = array(); |
|
| 891 | - foreach ($registrations as $registration) { |
|
| 892 | - if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
| 893 | - $payments += $registration->registration_payments(); |
|
| 894 | - } |
|
| 895 | - } |
|
| 896 | - if (! empty($payments)) { |
|
| 897 | - foreach ($payments as $payment) { |
|
| 898 | - if ($payment instanceof EE_Registration_Payment) { |
|
| 899 | - $this->checkout->amount_owing -= $payment->amount(); |
|
| 900 | - } |
|
| 901 | - } |
|
| 902 | - } |
|
| 903 | - } |
|
| 904 | - |
|
| 905 | - |
|
| 906 | - /** |
|
| 907 | - * _reset_selected_method_of_payment |
|
| 908 | - * |
|
| 909 | - * @access private |
|
| 910 | - * @param bool $force_reset |
|
| 911 | - * @return void |
|
| 912 | - * @throws InvalidArgumentException |
|
| 913 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 914 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 915 | - */ |
|
| 916 | - private function _reset_selected_method_of_payment($force_reset = false) |
|
| 917 | - { |
|
| 918 | - $reset_payment_method = $force_reset |
|
| 919 | - ? true |
|
| 920 | - : sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', false)); |
|
| 921 | - if ($reset_payment_method) { |
|
| 922 | - $this->checkout->selected_method_of_payment = null; |
|
| 923 | - $this->checkout->payment_method = null; |
|
| 924 | - $this->checkout->billing_form = null; |
|
| 925 | - $this->_save_selected_method_of_payment(); |
|
| 926 | - } |
|
| 927 | - } |
|
| 928 | - |
|
| 929 | - |
|
| 930 | - /** |
|
| 931 | - * _save_selected_method_of_payment |
|
| 932 | - * stores the selected_method_of_payment in the session |
|
| 933 | - * so that it's available for all subsequent requests including AJAX |
|
| 934 | - * |
|
| 935 | - * @access private |
|
| 936 | - * @param string $selected_method_of_payment |
|
| 937 | - * @return void |
|
| 938 | - * @throws InvalidArgumentException |
|
| 939 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 940 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 941 | - */ |
|
| 942 | - private function _save_selected_method_of_payment($selected_method_of_payment = '') |
|
| 943 | - { |
|
| 944 | - $selected_method_of_payment = ! empty($selected_method_of_payment) |
|
| 945 | - ? $selected_method_of_payment |
|
| 946 | - : $this->checkout->selected_method_of_payment; |
|
| 947 | - EE_Registry::instance()->SSN->set_session_data( |
|
| 948 | - array('selected_method_of_payment' => $selected_method_of_payment) |
|
| 949 | - ); |
|
| 950 | - } |
|
| 951 | - |
|
| 952 | - |
|
| 953 | - /** |
|
| 954 | - * _setup_payment_options |
|
| 955 | - * |
|
| 956 | - * @return EE_Form_Section_Proper |
|
| 957 | - * @throws EE_Error |
|
| 958 | - * @throws InvalidArgumentException |
|
| 959 | - * @throws ReflectionException |
|
| 960 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 961 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 962 | - */ |
|
| 963 | - public function _setup_payment_options() |
|
| 964 | - { |
|
| 965 | - // load payment method classes |
|
| 966 | - $this->checkout->available_payment_methods = $this->_get_available_payment_methods(); |
|
| 967 | - if (empty($this->checkout->available_payment_methods)) { |
|
| 968 | - EE_Error::add_error( |
|
| 969 | - apply_filters( |
|
| 970 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options___setup_payment_options__error_message_no_payment_methods', |
|
| 971 | - sprintf( |
|
| 972 | - esc_html__( |
|
| 973 | - 'Sorry, you cannot complete your purchase because a payment method is not active.%1$s Please contact %2$s for assistance and provide a description of the problem.', |
|
| 974 | - 'event_espresso' |
|
| 975 | - ), |
|
| 976 | - '<br>', |
|
| 977 | - EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 978 | - ) |
|
| 979 | - ), |
|
| 980 | - __FILE__, |
|
| 981 | - __FUNCTION__, |
|
| 982 | - __LINE__ |
|
| 983 | - ); |
|
| 984 | - } |
|
| 985 | - // switch up header depending on number of available payment methods |
|
| 986 | - $payment_method_header = count($this->checkout->available_payment_methods) > 1 |
|
| 987 | - ? apply_filters( |
|
| 988 | - 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
|
| 989 | - esc_html__('Please Select Your Method of Payment', 'event_espresso') |
|
| 990 | - ) |
|
| 991 | - : apply_filters( |
|
| 992 | - 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
|
| 993 | - esc_html__('Method of Payment', 'event_espresso') |
|
| 994 | - ); |
|
| 995 | - $available_payment_methods = array( |
|
| 996 | - // display the "Payment Method" header |
|
| 997 | - 'payment_method_header' => new EE_Form_Section_HTML( |
|
| 998 | - apply_filters( |
|
| 999 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options___setup_payment_options__payment_method_header', |
|
| 1000 | - EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr'), |
|
| 1001 | - $payment_method_header |
|
| 1002 | - ) |
|
| 1003 | - ), |
|
| 1004 | - ); |
|
| 1005 | - // the list of actual payment methods ( invoice, paypal, etc ) in a ( slug => HTML ) format |
|
| 1006 | - $available_payment_method_options = array(); |
|
| 1007 | - $default_payment_method_option = array(); |
|
| 1008 | - // additional instructions to be displayed and hidden below payment methods (adding a clearing div to start) |
|
| 1009 | - $payment_methods_billing_info = array( |
|
| 1010 | - new EE_Form_Section_HTML( |
|
| 1011 | - EEH_HTML::div('<br />', '', '', 'clear:both;') |
|
| 1012 | - ), |
|
| 1013 | - ); |
|
| 1014 | - // loop through payment methods |
|
| 1015 | - foreach ($this->checkout->available_payment_methods as $payment_method) { |
|
| 1016 | - if ($payment_method instanceof EE_Payment_Method) { |
|
| 1017 | - $payment_method_button = EEH_HTML::img( |
|
| 1018 | - $payment_method->button_url(), |
|
| 1019 | - $payment_method->name(), |
|
| 1020 | - 'spco-payment-method-' . $payment_method->slug() . '-btn-img', |
|
| 1021 | - 'spco-payment-method-btn-img' |
|
| 1022 | - ); |
|
| 1023 | - // check if any payment methods are set as default |
|
| 1024 | - // if payment method is already selected OR nothing is selected and this payment method should be |
|
| 1025 | - // open_by_default |
|
| 1026 | - if (($this->checkout->selected_method_of_payment === $payment_method->slug()) |
|
| 1027 | - || (! $this->checkout->selected_method_of_payment && $payment_method->open_by_default()) |
|
| 1028 | - ) { |
|
| 1029 | - $this->checkout->selected_method_of_payment = $payment_method->slug(); |
|
| 1030 | - $this->_save_selected_method_of_payment(); |
|
| 1031 | - $default_payment_method_option[ $payment_method->slug() ] = $payment_method_button; |
|
| 1032 | - } else { |
|
| 1033 | - $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
|
| 1034 | - } |
|
| 1035 | - $payment_methods_billing_info[ $payment_method->slug( |
|
| 1036 | - ) . '-info' ] = $this->_payment_method_billing_info( |
|
| 1037 | - $payment_method |
|
| 1038 | - ); |
|
| 1039 | - } |
|
| 1040 | - } |
|
| 1041 | - // prepend available_payment_method_options with default_payment_method_option so that it appears first in list |
|
| 1042 | - // of PMs |
|
| 1043 | - $available_payment_method_options = $default_payment_method_option + $available_payment_method_options; |
|
| 1044 | - // now generate the actual form inputs |
|
| 1045 | - $available_payment_methods['available_payment_methods'] = $this->_available_payment_method_inputs( |
|
| 1046 | - $available_payment_method_options |
|
| 1047 | - ); |
|
| 1048 | - $available_payment_methods += $payment_methods_billing_info; |
|
| 1049 | - // build the available payment methods form |
|
| 1050 | - return new EE_Form_Section_Proper( |
|
| 1051 | - array( |
|
| 1052 | - 'html_id' => 'spco-available-methods-of-payment-dv', |
|
| 1053 | - 'subsections' => $available_payment_methods, |
|
| 1054 | - 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
| 1055 | - ) |
|
| 1056 | - ); |
|
| 1057 | - } |
|
| 1058 | - |
|
| 1059 | - |
|
| 1060 | - /** |
|
| 1061 | - * _get_available_payment_methods |
|
| 1062 | - * |
|
| 1063 | - * @return EE_Payment_Method[] |
|
| 1064 | - * @throws EE_Error |
|
| 1065 | - * @throws InvalidArgumentException |
|
| 1066 | - * @throws ReflectionException |
|
| 1067 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1068 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1069 | - */ |
|
| 1070 | - protected function _get_available_payment_methods() |
|
| 1071 | - { |
|
| 1072 | - if (! empty($this->checkout->available_payment_methods)) { |
|
| 1073 | - return $this->checkout->available_payment_methods; |
|
| 1074 | - } |
|
| 1075 | - $available_payment_methods = array(); |
|
| 1076 | - // load EEM_Payment_Method |
|
| 1077 | - EE_Registry::instance()->load_model('Payment_Method'); |
|
| 1078 | - /** @type EEM_Payment_Method $EEM_Payment_Method */ |
|
| 1079 | - $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
|
| 1080 | - // get all active payment methods |
|
| 1081 | - $payment_methods = $EEM_Payment_Method->get_all_for_transaction( |
|
| 1082 | - $this->checkout->transaction, |
|
| 1083 | - EEM_Payment_Method::scope_cart |
|
| 1084 | - ); |
|
| 1085 | - foreach ($payment_methods as $payment_method) { |
|
| 1086 | - if ($payment_method instanceof EE_Payment_Method) { |
|
| 1087 | - $available_payment_methods[ $payment_method->slug() ] = $payment_method; |
|
| 1088 | - } |
|
| 1089 | - } |
|
| 1090 | - return $available_payment_methods; |
|
| 1091 | - } |
|
| 1092 | - |
|
| 1093 | - |
|
| 1094 | - /** |
|
| 1095 | - * _available_payment_method_inputs |
|
| 1096 | - * |
|
| 1097 | - * @access private |
|
| 1098 | - * @param array $available_payment_method_options |
|
| 1099 | - * @return \EE_Form_Section_Proper |
|
| 1100 | - */ |
|
| 1101 | - private function _available_payment_method_inputs($available_payment_method_options = array()) |
|
| 1102 | - { |
|
| 1103 | - // generate inputs |
|
| 1104 | - return new EE_Form_Section_Proper( |
|
| 1105 | - array( |
|
| 1106 | - 'html_id' => 'ee-available-payment-method-inputs', |
|
| 1107 | - 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
| 1108 | - 'subsections' => array( |
|
| 1109 | - '' => new EE_Radio_Button_Input( |
|
| 1110 | - $available_payment_method_options, |
|
| 1111 | - array( |
|
| 1112 | - 'html_name' => 'selected_method_of_payment', |
|
| 1113 | - 'html_class' => 'spco-payment-method', |
|
| 1114 | - 'default' => $this->checkout->selected_method_of_payment, |
|
| 1115 | - 'label_size' => 11, |
|
| 1116 | - 'enforce_label_size' => true, |
|
| 1117 | - ) |
|
| 1118 | - ), |
|
| 1119 | - ), |
|
| 1120 | - ) |
|
| 1121 | - ); |
|
| 1122 | - } |
|
| 1123 | - |
|
| 1124 | - |
|
| 1125 | - /** |
|
| 1126 | - * _payment_method_billing_info |
|
| 1127 | - * |
|
| 1128 | - * @access private |
|
| 1129 | - * @param EE_Payment_Method $payment_method |
|
| 1130 | - * @return EE_Form_Section_Proper |
|
| 1131 | - * @throws EE_Error |
|
| 1132 | - * @throws InvalidArgumentException |
|
| 1133 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1134 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1135 | - */ |
|
| 1136 | - private function _payment_method_billing_info(EE_Payment_Method $payment_method) |
|
| 1137 | - { |
|
| 1138 | - $currently_selected = $this->checkout->selected_method_of_payment === $payment_method->slug() |
|
| 1139 | - ? true |
|
| 1140 | - : false; |
|
| 1141 | - // generate the billing form for payment method |
|
| 1142 | - $billing_form = $currently_selected |
|
| 1143 | - ? $this->_get_billing_form_for_payment_method($payment_method) |
|
| 1144 | - : new EE_Form_Section_HTML(); |
|
| 1145 | - $this->checkout->billing_form = $currently_selected |
|
| 1146 | - ? $billing_form |
|
| 1147 | - : $this->checkout->billing_form; |
|
| 1148 | - // it's all in the details |
|
| 1149 | - $info_html = EEH_HTML::h3( |
|
| 1150 | - esc_html__('Important information regarding your payment', 'event_espresso'), |
|
| 1151 | - '', |
|
| 1152 | - 'spco-payment-method-hdr' |
|
| 1153 | - ); |
|
| 1154 | - // add some info regarding the step, either from what's saved in the admin, |
|
| 1155 | - // or a default string depending on whether the PM has a billing form or not |
|
| 1156 | - if ($payment_method->description()) { |
|
| 1157 | - $payment_method_info = $payment_method->description(); |
|
| 1158 | - } elseif ($billing_form instanceof EE_Billing_Info_Form) { |
|
| 1159 | - $payment_method_info = sprintf( |
|
| 1160 | - esc_html__( |
|
| 1161 | - 'Please provide the following billing information, then click the "%1$s" button below in order to proceed.', |
|
| 1162 | - 'event_espresso' |
|
| 1163 | - ), |
|
| 1164 | - $this->submit_button_text() |
|
| 1165 | - ); |
|
| 1166 | - } else { |
|
| 1167 | - $payment_method_info = sprintf( |
|
| 1168 | - esc_html__('Please click the "%1$s" button below in order to proceed.', 'event_espresso'), |
|
| 1169 | - $this->submit_button_text() |
|
| 1170 | - ); |
|
| 1171 | - } |
|
| 1172 | - $info_html .= EEH_HTML::div( |
|
| 1173 | - apply_filters( |
|
| 1174 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options___payment_method_billing_info__payment_method_info', |
|
| 1175 | - $payment_method_info |
|
| 1176 | - ), |
|
| 1177 | - '', |
|
| 1178 | - 'spco-payment-method-desc ee-attention' |
|
| 1179 | - ); |
|
| 1180 | - return new EE_Form_Section_Proper( |
|
| 1181 | - array( |
|
| 1182 | - 'html_id' => 'spco-payment-method-info-' . $payment_method->slug(), |
|
| 1183 | - 'html_class' => 'spco-payment-method-info-dv', |
|
| 1184 | - // only display the selected or default PM |
|
| 1185 | - 'html_style' => $currently_selected ? '' : 'display:none;', |
|
| 1186 | - 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
| 1187 | - 'subsections' => array( |
|
| 1188 | - 'info' => new EE_Form_Section_HTML($info_html), |
|
| 1189 | - 'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML(), |
|
| 1190 | - ), |
|
| 1191 | - ) |
|
| 1192 | - ); |
|
| 1193 | - } |
|
| 1194 | - |
|
| 1195 | - |
|
| 1196 | - /** |
|
| 1197 | - * get_billing_form_html_for_payment_method |
|
| 1198 | - * |
|
| 1199 | - * @access public |
|
| 1200 | - * @return string |
|
| 1201 | - * @throws EE_Error |
|
| 1202 | - * @throws InvalidArgumentException |
|
| 1203 | - * @throws ReflectionException |
|
| 1204 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1205 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1206 | - */ |
|
| 1207 | - public function get_billing_form_html_for_payment_method() |
|
| 1208 | - { |
|
| 1209 | - // how have they chosen to pay? |
|
| 1210 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
| 1211 | - $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
|
| 1212 | - if (! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
| 1213 | - return false; |
|
| 1214 | - } |
|
| 1215 | - if (apply_filters( |
|
| 1216 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
|
| 1217 | - false |
|
| 1218 | - )) { |
|
| 1219 | - EE_Error::add_success( |
|
| 1220 | - apply_filters( |
|
| 1221 | - 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
|
| 1222 | - sprintf( |
|
| 1223 | - esc_html__( |
|
| 1224 | - 'You have selected "%s" as your method of payment. Please note the important payment information below.', |
|
| 1225 | - 'event_espresso' |
|
| 1226 | - ), |
|
| 1227 | - $this->checkout->payment_method->name() |
|
| 1228 | - ) |
|
| 1229 | - ) |
|
| 1230 | - ); |
|
| 1231 | - } |
|
| 1232 | - // now generate billing form for selected method of payment |
|
| 1233 | - $payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
| 1234 | - // fill form with attendee info if applicable |
|
| 1235 | - if ($payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form |
|
| 1236 | - && $this->checkout->transaction_has_primary_registrant() |
|
| 1237 | - ) { |
|
| 1238 | - $payment_method_billing_form->populate_from_attendee( |
|
| 1239 | - $this->checkout->transaction->primary_registration()->attendee() |
|
| 1240 | - ); |
|
| 1241 | - } |
|
| 1242 | - // and debug content |
|
| 1243 | - if ($payment_method_billing_form instanceof EE_Billing_Info_Form |
|
| 1244 | - && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
| 1245 | - ) { |
|
| 1246 | - $payment_method_billing_form = |
|
| 1247 | - $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
|
| 1248 | - $payment_method_billing_form |
|
| 1249 | - ); |
|
| 1250 | - } |
|
| 1251 | - $billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper |
|
| 1252 | - ? $payment_method_billing_form->get_html() |
|
| 1253 | - : ''; |
|
| 1254 | - $this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info)); |
|
| 1255 | - // localize validation rules for main form |
|
| 1256 | - $this->checkout->current_step->reg_form->localize_validation_rules(); |
|
| 1257 | - $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
| 1258 | - return true; |
|
| 1259 | - } |
|
| 1260 | - |
|
| 1261 | - |
|
| 1262 | - /** |
|
| 1263 | - * _get_billing_form_for_payment_method |
|
| 1264 | - * |
|
| 1265 | - * @access private |
|
| 1266 | - * @param EE_Payment_Method $payment_method |
|
| 1267 | - * @return EE_Billing_Info_Form|EE_Form_Section_HTML |
|
| 1268 | - * @throws EE_Error |
|
| 1269 | - * @throws InvalidArgumentException |
|
| 1270 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1271 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1272 | - */ |
|
| 1273 | - private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method) |
|
| 1274 | - { |
|
| 1275 | - $billing_form = $payment_method->type_obj()->billing_form( |
|
| 1276 | - $this->checkout->transaction, |
|
| 1277 | - array('amount_owing' => $this->checkout->amount_owing) |
|
| 1278 | - ); |
|
| 1279 | - if ($billing_form instanceof EE_Billing_Info_Form) { |
|
| 1280 | - if (apply_filters( |
|
| 1281 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
|
| 1282 | - false |
|
| 1283 | - ) |
|
| 1284 | - && EE_Registry::instance()->REQ->is_set('payment_method') |
|
| 1285 | - ) { |
|
| 1286 | - EE_Error::add_success( |
|
| 1287 | - apply_filters( |
|
| 1288 | - 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
|
| 1289 | - sprintf( |
|
| 1290 | - esc_html__( |
|
| 1291 | - 'You have selected "%s" as your method of payment. Please note the important payment information below.', |
|
| 1292 | - 'event_espresso' |
|
| 1293 | - ), |
|
| 1294 | - $payment_method->name() |
|
| 1295 | - ) |
|
| 1296 | - ) |
|
| 1297 | - ); |
|
| 1298 | - } |
|
| 1299 | - return apply_filters( |
|
| 1300 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', |
|
| 1301 | - $billing_form, |
|
| 1302 | - $payment_method |
|
| 1303 | - ); |
|
| 1304 | - } |
|
| 1305 | - // no actual billing form, so return empty HTML form section |
|
| 1306 | - return new EE_Form_Section_HTML(); |
|
| 1307 | - } |
|
| 1308 | - |
|
| 1309 | - |
|
| 1310 | - /** |
|
| 1311 | - * _get_selected_method_of_payment |
|
| 1312 | - * |
|
| 1313 | - * @access private |
|
| 1314 | - * @param boolean $required whether to throw an error if the "selected_method_of_payment" |
|
| 1315 | - * is not found in the incoming request |
|
| 1316 | - * @param string $request_param |
|
| 1317 | - * @return NULL|string |
|
| 1318 | - * @throws EE_Error |
|
| 1319 | - * @throws InvalidArgumentException |
|
| 1320 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1321 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1322 | - */ |
|
| 1323 | - private function _get_selected_method_of_payment( |
|
| 1324 | - $required = false, |
|
| 1325 | - $request_param = 'selected_method_of_payment' |
|
| 1326 | - ) { |
|
| 1327 | - // is selected_method_of_payment set in the request ? |
|
| 1328 | - $selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, false); |
|
| 1329 | - if ($selected_method_of_payment) { |
|
| 1330 | - // sanitize it |
|
| 1331 | - $selected_method_of_payment = is_array($selected_method_of_payment) |
|
| 1332 | - ? array_shift($selected_method_of_payment) |
|
| 1333 | - : $selected_method_of_payment; |
|
| 1334 | - $selected_method_of_payment = sanitize_text_field($selected_method_of_payment); |
|
| 1335 | - // store it in the session so that it's available for all subsequent requests including AJAX |
|
| 1336 | - $this->_save_selected_method_of_payment($selected_method_of_payment); |
|
| 1337 | - } else { |
|
| 1338 | - // or is is set in the session ? |
|
| 1339 | - $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data( |
|
| 1340 | - 'selected_method_of_payment' |
|
| 1341 | - ); |
|
| 1342 | - } |
|
| 1343 | - // do ya really really gotta have it? |
|
| 1344 | - if (empty($selected_method_of_payment) && $required) { |
|
| 1345 | - EE_Error::add_error( |
|
| 1346 | - sprintf( |
|
| 1347 | - esc_html__( |
|
| 1348 | - 'The selected method of payment could not be determined.%sPlease ensure that you have selected one before proceeding.%sIf you continue to experience difficulties, then refresh your browser and try again, or contact %s for assistance.', |
|
| 1349 | - 'event_espresso' |
|
| 1350 | - ), |
|
| 1351 | - '<br/>', |
|
| 1352 | - '<br/>', |
|
| 1353 | - EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 1354 | - ), |
|
| 1355 | - __FILE__, |
|
| 1356 | - __FUNCTION__, |
|
| 1357 | - __LINE__ |
|
| 1358 | - ); |
|
| 1359 | - return null; |
|
| 1360 | - } |
|
| 1361 | - return $selected_method_of_payment; |
|
| 1362 | - } |
|
| 1363 | - |
|
| 1364 | - |
|
| 1365 | - |
|
| 1366 | - |
|
| 1367 | - |
|
| 1368 | - |
|
| 1369 | - /********************************************************************************************************/ |
|
| 1370 | - /*********************************** SWITCH PAYMENT METHOD ************************************/ |
|
| 1371 | - /********************************************************************************************************/ |
|
| 1372 | - /** |
|
| 1373 | - * switch_payment_method |
|
| 1374 | - * |
|
| 1375 | - * @access public |
|
| 1376 | - * @return string |
|
| 1377 | - * @throws EE_Error |
|
| 1378 | - * @throws InvalidArgumentException |
|
| 1379 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1380 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1381 | - */ |
|
| 1382 | - public function switch_payment_method() |
|
| 1383 | - { |
|
| 1384 | - if (! $this->_verify_payment_method_is_set()) { |
|
| 1385 | - return false; |
|
| 1386 | - } |
|
| 1387 | - if (apply_filters( |
|
| 1388 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
|
| 1389 | - false |
|
| 1390 | - )) { |
|
| 1391 | - EE_Error::add_success( |
|
| 1392 | - apply_filters( |
|
| 1393 | - 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
|
| 1394 | - sprintf( |
|
| 1395 | - esc_html__( |
|
| 1396 | - 'You have selected "%s" as your method of payment. Please note the important payment information below.', |
|
| 1397 | - 'event_espresso' |
|
| 1398 | - ), |
|
| 1399 | - $this->checkout->payment_method->name() |
|
| 1400 | - ) |
|
| 1401 | - ) |
|
| 1402 | - ); |
|
| 1403 | - } |
|
| 1404 | - // generate billing form for selected method of payment if it hasn't been done already |
|
| 1405 | - if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
| 1406 | - $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
|
| 1407 | - $this->checkout->payment_method |
|
| 1408 | - ); |
|
| 1409 | - } |
|
| 1410 | - // fill form with attendee info if applicable |
|
| 1411 | - if (apply_filters( |
|
| 1412 | - 'FHEE__populate_billing_form_fields_from_attendee', |
|
| 1413 | - ( |
|
| 1414 | - $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form |
|
| 1415 | - && $this->checkout->transaction_has_primary_registrant() |
|
| 1416 | - ), |
|
| 1417 | - $this->checkout->billing_form, |
|
| 1418 | - $this->checkout->transaction |
|
| 1419 | - ) |
|
| 1420 | - ) { |
|
| 1421 | - $this->checkout->billing_form->populate_from_attendee( |
|
| 1422 | - $this->checkout->transaction->primary_registration()->attendee() |
|
| 1423 | - ); |
|
| 1424 | - } |
|
| 1425 | - // and debug content |
|
| 1426 | - if ($this->checkout->billing_form instanceof EE_Billing_Info_Form |
|
| 1427 | - && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
| 1428 | - ) { |
|
| 1429 | - $this->checkout->billing_form = |
|
| 1430 | - $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
|
| 1431 | - $this->checkout->billing_form |
|
| 1432 | - ); |
|
| 1433 | - } |
|
| 1434 | - // get html and validation rules for form |
|
| 1435 | - if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) { |
|
| 1436 | - $this->checkout->json_response->set_return_data( |
|
| 1437 | - array('payment_method_info' => $this->checkout->billing_form->get_html()) |
|
| 1438 | - ); |
|
| 1439 | - // localize validation rules for main form |
|
| 1440 | - $this->checkout->billing_form->localize_validation_rules(true); |
|
| 1441 | - $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
| 1442 | - } else { |
|
| 1443 | - $this->checkout->json_response->set_return_data(array('payment_method_info' => '')); |
|
| 1444 | - } |
|
| 1445 | - // prevents advancement to next step |
|
| 1446 | - $this->checkout->continue_reg = false; |
|
| 1447 | - return true; |
|
| 1448 | - } |
|
| 1449 | - |
|
| 1450 | - |
|
| 1451 | - /** |
|
| 1452 | - * _verify_payment_method_is_set |
|
| 1453 | - * |
|
| 1454 | - * @return bool |
|
| 1455 | - * @throws EE_Error |
|
| 1456 | - * @throws InvalidArgumentException |
|
| 1457 | - * @throws ReflectionException |
|
| 1458 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1459 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1460 | - */ |
|
| 1461 | - protected function _verify_payment_method_is_set() |
|
| 1462 | - { |
|
| 1463 | - // generate billing form for selected method of payment if it hasn't been done already |
|
| 1464 | - if (empty($this->checkout->selected_method_of_payment)) { |
|
| 1465 | - // how have they chosen to pay? |
|
| 1466 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
| 1467 | - } else { |
|
| 1468 | - // choose your own adventure based on method_of_payment |
|
| 1469 | - switch ($this->checkout->selected_method_of_payment) { |
|
| 1470 | - case 'events_sold_out': |
|
| 1471 | - EE_Error::add_attention( |
|
| 1472 | - apply_filters( |
|
| 1473 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__sold_out_events_msg', |
|
| 1474 | - esc_html__( |
|
| 1475 | - 'It appears that the event you were about to make a payment for has sold out since this form first loaded. Please contact the event administrator if you believe this is an error.', |
|
| 1476 | - 'event_espresso' |
|
| 1477 | - ) |
|
| 1478 | - ), |
|
| 1479 | - __FILE__, |
|
| 1480 | - __FUNCTION__, |
|
| 1481 | - __LINE__ |
|
| 1482 | - ); |
|
| 1483 | - return false; |
|
| 1484 | - break; |
|
| 1485 | - case 'payments_closed': |
|
| 1486 | - EE_Error::add_attention( |
|
| 1487 | - apply_filters( |
|
| 1488 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__payments_closed_msg', |
|
| 1489 | - esc_html__( |
|
| 1490 | - 'It appears that the event you were about to make a payment for is not accepting payments at this time. Please contact the event administrator if you believe this is an error.', |
|
| 1491 | - 'event_espresso' |
|
| 1492 | - ) |
|
| 1493 | - ), |
|
| 1494 | - __FILE__, |
|
| 1495 | - __FUNCTION__, |
|
| 1496 | - __LINE__ |
|
| 1497 | - ); |
|
| 1498 | - return false; |
|
| 1499 | - break; |
|
| 1500 | - case 'no_payment_required': |
|
| 1501 | - EE_Error::add_attention( |
|
| 1502 | - apply_filters( |
|
| 1503 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__no_payment_required_msg', |
|
| 1504 | - esc_html__( |
|
| 1505 | - 'It appears that the event you were about to make a payment for does not require payment. Please contact the event administrator if you believe this is an error.', |
|
| 1506 | - 'event_espresso' |
|
| 1507 | - ) |
|
| 1508 | - ), |
|
| 1509 | - __FILE__, |
|
| 1510 | - __FUNCTION__, |
|
| 1511 | - __LINE__ |
|
| 1512 | - ); |
|
| 1513 | - return false; |
|
| 1514 | - break; |
|
| 1515 | - default: |
|
| 1516 | - } |
|
| 1517 | - } |
|
| 1518 | - // verify payment method |
|
| 1519 | - if (! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
| 1520 | - // get payment method for selected method of payment |
|
| 1521 | - $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
|
| 1522 | - } |
|
| 1523 | - return $this->checkout->payment_method instanceof EE_Payment_Method ? true : false; |
|
| 1524 | - } |
|
| 1525 | - |
|
| 1526 | - |
|
| 1527 | - |
|
| 1528 | - /********************************************************************************************************/ |
|
| 1529 | - /*************************************** SAVE PAYER DETAILS ****************************************/ |
|
| 1530 | - /********************************************************************************************************/ |
|
| 1531 | - /** |
|
| 1532 | - * save_payer_details_via_ajax |
|
| 1533 | - * |
|
| 1534 | - * @return void |
|
| 1535 | - * @throws EE_Error |
|
| 1536 | - * @throws InvalidArgumentException |
|
| 1537 | - * @throws ReflectionException |
|
| 1538 | - * @throws RuntimeException |
|
| 1539 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1540 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1541 | - */ |
|
| 1542 | - public function save_payer_details_via_ajax() |
|
| 1543 | - { |
|
| 1544 | - if (! $this->_verify_payment_method_is_set()) { |
|
| 1545 | - return; |
|
| 1546 | - } |
|
| 1547 | - // generate billing form for selected method of payment if it hasn't been done already |
|
| 1548 | - if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
| 1549 | - $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
|
| 1550 | - $this->checkout->payment_method |
|
| 1551 | - ); |
|
| 1552 | - } |
|
| 1553 | - // generate primary attendee from payer info if applicable |
|
| 1554 | - if (! $this->checkout->transaction_has_primary_registrant()) { |
|
| 1555 | - $attendee = $this->_create_attendee_from_request_data(); |
|
| 1556 | - if ($attendee instanceof EE_Attendee) { |
|
| 1557 | - foreach ($this->checkout->transaction->registrations() as $registration) { |
|
| 1558 | - if ($registration->is_primary_registrant()) { |
|
| 1559 | - $this->checkout->primary_attendee_obj = $attendee; |
|
| 1560 | - $registration->_add_relation_to($attendee, 'Attendee'); |
|
| 1561 | - $registration->set_attendee_id($attendee->ID()); |
|
| 1562 | - $registration->update_cache_after_object_save('Attendee', $attendee); |
|
| 1563 | - } |
|
| 1564 | - } |
|
| 1565 | - } |
|
| 1566 | - } |
|
| 1567 | - } |
|
| 1568 | - |
|
| 1569 | - |
|
| 1570 | - /** |
|
| 1571 | - * create_attendee_from_request_data |
|
| 1572 | - * uses info from alternate GET or POST data (such as AJAX) to create a new attendee |
|
| 1573 | - * |
|
| 1574 | - * @return EE_Attendee |
|
| 1575 | - * @throws EE_Error |
|
| 1576 | - * @throws InvalidArgumentException |
|
| 1577 | - * @throws ReflectionException |
|
| 1578 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1579 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1580 | - */ |
|
| 1581 | - protected function _create_attendee_from_request_data() |
|
| 1582 | - { |
|
| 1583 | - // get State ID |
|
| 1584 | - $STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : ''; |
|
| 1585 | - if (! empty($STA_ID)) { |
|
| 1586 | - // can we get state object from name ? |
|
| 1587 | - EE_Registry::instance()->load_model('State'); |
|
| 1588 | - $state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID'); |
|
| 1589 | - $STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID; |
|
| 1590 | - } |
|
| 1591 | - // get Country ISO |
|
| 1592 | - $CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : ''; |
|
| 1593 | - if (! empty($CNT_ISO)) { |
|
| 1594 | - // can we get country object from name ? |
|
| 1595 | - EE_Registry::instance()->load_model('Country'); |
|
| 1596 | - $country = EEM_Country::instance()->get_col( |
|
| 1597 | - array(array('CNT_name' => $CNT_ISO), 'limit' => 1), |
|
| 1598 | - 'CNT_ISO' |
|
| 1599 | - ); |
|
| 1600 | - $CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO; |
|
| 1601 | - } |
|
| 1602 | - // grab attendee data |
|
| 1603 | - $attendee_data = array( |
|
| 1604 | - 'ATT_fname' => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '', |
|
| 1605 | - 'ATT_lname' => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '', |
|
| 1606 | - 'ATT_email' => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '', |
|
| 1607 | - 'ATT_address' => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '', |
|
| 1608 | - 'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '', |
|
| 1609 | - 'ATT_city' => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '', |
|
| 1610 | - 'STA_ID' => $STA_ID, |
|
| 1611 | - 'CNT_ISO' => $CNT_ISO, |
|
| 1612 | - 'ATT_zip' => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '', |
|
| 1613 | - 'ATT_phone' => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '', |
|
| 1614 | - ); |
|
| 1615 | - // validate the email address since it is the most important piece of info |
|
| 1616 | - if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] !== $_REQUEST['email']) { |
|
| 1617 | - EE_Error::add_error( |
|
| 1618 | - esc_html__('An invalid email address was submitted.', 'event_espresso'), |
|
| 1619 | - __FILE__, |
|
| 1620 | - __FUNCTION__, |
|
| 1621 | - __LINE__ |
|
| 1622 | - ); |
|
| 1623 | - } |
|
| 1624 | - // does this attendee already exist in the db ? we're searching using a combination of first name, last name, |
|
| 1625 | - // AND email address |
|
| 1626 | - if (! empty($attendee_data['ATT_fname']) |
|
| 1627 | - && ! empty($attendee_data['ATT_lname']) |
|
| 1628 | - && ! empty($attendee_data['ATT_email']) |
|
| 1629 | - ) { |
|
| 1630 | - $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( |
|
| 1631 | - array( |
|
| 1632 | - 'ATT_fname' => $attendee_data['ATT_fname'], |
|
| 1633 | - 'ATT_lname' => $attendee_data['ATT_lname'], |
|
| 1634 | - 'ATT_email' => $attendee_data['ATT_email'], |
|
| 1635 | - ) |
|
| 1636 | - ); |
|
| 1637 | - if ($existing_attendee instanceof EE_Attendee) { |
|
| 1638 | - return $existing_attendee; |
|
| 1639 | - } |
|
| 1640 | - } |
|
| 1641 | - // no existing attendee? kk let's create a new one |
|
| 1642 | - // kinda lame, but we need a first and last name to create an attendee, so use the email address if those |
|
| 1643 | - // don't exist |
|
| 1644 | - $attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname']) |
|
| 1645 | - ? $attendee_data['ATT_fname'] |
|
| 1646 | - : $attendee_data['ATT_email']; |
|
| 1647 | - $attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname']) |
|
| 1648 | - ? $attendee_data['ATT_lname'] |
|
| 1649 | - : $attendee_data['ATT_email']; |
|
| 1650 | - return EE_Attendee::new_instance($attendee_data); |
|
| 1651 | - } |
|
| 1652 | - |
|
| 1653 | - |
|
| 1654 | - |
|
| 1655 | - /********************************************************************************************************/ |
|
| 1656 | - /**************************************** PROCESS REG STEP *****************************************/ |
|
| 1657 | - /********************************************************************************************************/ |
|
| 1658 | - /** |
|
| 1659 | - * process_reg_step |
|
| 1660 | - * |
|
| 1661 | - * @return bool |
|
| 1662 | - * @throws EE_Error |
|
| 1663 | - * @throws InvalidArgumentException |
|
| 1664 | - * @throws ReflectionException |
|
| 1665 | - * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 1666 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1667 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1668 | - * @throws \EventEspresso\core\exceptions\InvalidStatusException |
|
| 1669 | - */ |
|
| 1670 | - public function process_reg_step() |
|
| 1671 | - { |
|
| 1672 | - // how have they chosen to pay? |
|
| 1673 | - $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() |
|
| 1674 | - ? 'no_payment_required' |
|
| 1675 | - : $this->_get_selected_method_of_payment(true); |
|
| 1676 | - // choose your own adventure based on method_of_payment |
|
| 1677 | - switch ($this->checkout->selected_method_of_payment) { |
|
| 1678 | - case 'events_sold_out': |
|
| 1679 | - $this->checkout->redirect = true; |
|
| 1680 | - $this->checkout->redirect_url = $this->checkout->cancel_page_url; |
|
| 1681 | - $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
| 1682 | - // mark this reg step as completed |
|
| 1683 | - $this->set_completed(); |
|
| 1684 | - return false; |
|
| 1685 | - break; |
|
| 1686 | - |
|
| 1687 | - case 'payments_closed': |
|
| 1688 | - if (apply_filters( |
|
| 1689 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', |
|
| 1690 | - false |
|
| 1691 | - )) { |
|
| 1692 | - EE_Error::add_success( |
|
| 1693 | - esc_html__('no payment required at this time.', 'event_espresso'), |
|
| 1694 | - __FILE__, |
|
| 1695 | - __FUNCTION__, |
|
| 1696 | - __LINE__ |
|
| 1697 | - ); |
|
| 1698 | - } |
|
| 1699 | - // mark this reg step as completed |
|
| 1700 | - $this->set_completed(); |
|
| 1701 | - return true; |
|
| 1702 | - break; |
|
| 1703 | - |
|
| 1704 | - case 'no_payment_required': |
|
| 1705 | - if (apply_filters( |
|
| 1706 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', |
|
| 1707 | - false |
|
| 1708 | - )) { |
|
| 1709 | - EE_Error::add_success( |
|
| 1710 | - esc_html__('no payment required.', 'event_espresso'), |
|
| 1711 | - __FILE__, |
|
| 1712 | - __FUNCTION__, |
|
| 1713 | - __LINE__ |
|
| 1714 | - ); |
|
| 1715 | - } |
|
| 1716 | - // mark this reg step as completed |
|
| 1717 | - $this->set_completed(); |
|
| 1718 | - return true; |
|
| 1719 | - break; |
|
| 1720 | - |
|
| 1721 | - default: |
|
| 1722 | - $registrations = EE_Registry::instance()->SSN->checkout()->transaction->registrations( |
|
| 1723 | - EE_Registry::instance()->SSN->checkout()->reg_cache_where_params |
|
| 1724 | - ); |
|
| 1725 | - $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space( |
|
| 1726 | - $registrations, |
|
| 1727 | - EE_Registry::instance()->SSN->checkout()->revisit |
|
| 1728 | - ); |
|
| 1729 | - // calculate difference between the two arrays |
|
| 1730 | - $registrations = array_diff($registrations, $ejected_registrations); |
|
| 1731 | - if (empty($registrations)) { |
|
| 1732 | - $this->_redirect_because_event_sold_out(); |
|
| 1733 | - return false; |
|
| 1734 | - } |
|
| 1735 | - $payment_successful = $this->_process_payment(); |
|
| 1736 | - if ($payment_successful) { |
|
| 1737 | - $this->checkout->continue_reg = true; |
|
| 1738 | - $this->_maybe_set_completed($this->checkout->payment_method); |
|
| 1739 | - } else { |
|
| 1740 | - $this->checkout->continue_reg = false; |
|
| 1741 | - } |
|
| 1742 | - return $payment_successful; |
|
| 1743 | - } |
|
| 1744 | - } |
|
| 1745 | - |
|
| 1746 | - |
|
| 1747 | - /** |
|
| 1748 | - * _redirect_because_event_sold_out |
|
| 1749 | - * |
|
| 1750 | - * @access protected |
|
| 1751 | - * @return void |
|
| 1752 | - */ |
|
| 1753 | - protected function _redirect_because_event_sold_out() |
|
| 1754 | - { |
|
| 1755 | - $this->checkout->continue_reg = false; |
|
| 1756 | - // set redirect URL |
|
| 1757 | - $this->checkout->redirect_url = add_query_arg( |
|
| 1758 | - array('e_reg_url_link' => $this->checkout->reg_url_link), |
|
| 1759 | - $this->checkout->current_step->reg_step_url() |
|
| 1760 | - ); |
|
| 1761 | - $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
| 1762 | - } |
|
| 1763 | - |
|
| 1764 | - |
|
| 1765 | - /** |
|
| 1766 | - * _maybe_set_completed |
|
| 1767 | - * |
|
| 1768 | - * @access protected |
|
| 1769 | - * @param \EE_Payment_Method $payment_method |
|
| 1770 | - * @return void |
|
| 1771 | - * @throws \EE_Error |
|
| 1772 | - */ |
|
| 1773 | - protected function _maybe_set_completed(EE_Payment_Method $payment_method) |
|
| 1774 | - { |
|
| 1775 | - switch ($payment_method->type_obj()->payment_occurs()) { |
|
| 1776 | - case EE_PMT_Base::offsite: |
|
| 1777 | - break; |
|
| 1778 | - case EE_PMT_Base::onsite: |
|
| 1779 | - case EE_PMT_Base::offline: |
|
| 1780 | - // mark this reg step as completed |
|
| 1781 | - $this->set_completed(); |
|
| 1782 | - break; |
|
| 1783 | - } |
|
| 1784 | - } |
|
| 1785 | - |
|
| 1786 | - |
|
| 1787 | - /** |
|
| 1788 | - * update_reg_step |
|
| 1789 | - * this is the final step after a user revisits the site to retry a payment |
|
| 1790 | - * |
|
| 1791 | - * @return bool |
|
| 1792 | - * @throws EE_Error |
|
| 1793 | - * @throws InvalidArgumentException |
|
| 1794 | - * @throws ReflectionException |
|
| 1795 | - * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 1796 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1797 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1798 | - * @throws \EventEspresso\core\exceptions\InvalidStatusException |
|
| 1799 | - */ |
|
| 1800 | - public function update_reg_step() |
|
| 1801 | - { |
|
| 1802 | - $success = true; |
|
| 1803 | - // if payment required |
|
| 1804 | - if ($this->checkout->transaction->total() > 0) { |
|
| 1805 | - do_action( |
|
| 1806 | - 'AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', |
|
| 1807 | - $this->checkout->transaction |
|
| 1808 | - ); |
|
| 1809 | - // attempt payment via payment method |
|
| 1810 | - $success = $this->process_reg_step(); |
|
| 1811 | - } |
|
| 1812 | - if ($success && ! $this->checkout->redirect) { |
|
| 1813 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( |
|
| 1814 | - $this->checkout->transaction->ID() |
|
| 1815 | - ); |
|
| 1816 | - // set return URL |
|
| 1817 | - $this->checkout->redirect_url = add_query_arg( |
|
| 1818 | - array('e_reg_url_link' => $this->checkout->reg_url_link), |
|
| 1819 | - $this->checkout->thank_you_page_url |
|
| 1820 | - ); |
|
| 1821 | - } |
|
| 1822 | - return $success; |
|
| 1823 | - } |
|
| 1824 | - |
|
| 1825 | - |
|
| 1826 | - /** |
|
| 1827 | - * _process_payment |
|
| 1828 | - * |
|
| 1829 | - * @access private |
|
| 1830 | - * @return bool |
|
| 1831 | - * @throws EE_Error |
|
| 1832 | - * @throws InvalidArgumentException |
|
| 1833 | - * @throws ReflectionException |
|
| 1834 | - * @throws RuntimeException |
|
| 1835 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1836 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1837 | - */ |
|
| 1838 | - private function _process_payment() |
|
| 1839 | - { |
|
| 1840 | - // basically confirm that the event hasn't sold out since they hit the page |
|
| 1841 | - if (! $this->_last_second_ticket_verifications()) { |
|
| 1842 | - return false; |
|
| 1843 | - } |
|
| 1844 | - // ya gotta make a choice man |
|
| 1845 | - if (empty($this->checkout->selected_method_of_payment)) { |
|
| 1846 | - $this->checkout->json_response->set_plz_select_method_of_payment( |
|
| 1847 | - esc_html__('Please select a method of payment before proceeding.', 'event_espresso') |
|
| 1848 | - ); |
|
| 1849 | - return false; |
|
| 1850 | - } |
|
| 1851 | - // get EE_Payment_Method object |
|
| 1852 | - if (! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
| 1853 | - return false; |
|
| 1854 | - } |
|
| 1855 | - // setup billing form |
|
| 1856 | - if ($this->checkout->payment_method->is_on_site()) { |
|
| 1857 | - $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
|
| 1858 | - $this->checkout->payment_method |
|
| 1859 | - ); |
|
| 1860 | - // bad billing form ? |
|
| 1861 | - if (! $this->_billing_form_is_valid()) { |
|
| 1862 | - return false; |
|
| 1863 | - } |
|
| 1864 | - } |
|
| 1865 | - // ensure primary registrant has been fully processed |
|
| 1866 | - if (! $this->_setup_primary_registrant_prior_to_payment()) { |
|
| 1867 | - return false; |
|
| 1868 | - } |
|
| 1869 | - // if session is close to expiring (under 10 minutes by default) |
|
| 1870 | - if ((time() - EE_Registry::instance()->SSN->expiration()) < EE_Registry::instance()->SSN->extension()) { |
|
| 1871 | - // add some time to session expiration so that payment can be completed |
|
| 1872 | - EE_Registry::instance()->SSN->extend_expiration(); |
|
| 1873 | - } |
|
| 1874 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
| 1875 | - // $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
| 1876 | - // in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations |
|
| 1877 | - // for events with a default reg status of Approved |
|
| 1878 | - // $transaction_processor->toggle_registration_statuses_for_default_approved_events( |
|
| 1879 | - // $this->checkout->transaction, $this->checkout->reg_cache_where_params |
|
| 1880 | - // ); |
|
| 1881 | - // attempt payment |
|
| 1882 | - $payment = $this->_attempt_payment($this->checkout->payment_method); |
|
| 1883 | - // process results |
|
| 1884 | - $payment = $this->_validate_payment($payment); |
|
| 1885 | - $payment = $this->_post_payment_processing($payment); |
|
| 1886 | - // verify payment |
|
| 1887 | - if ($payment instanceof EE_Payment) { |
|
| 1888 | - // store that for later |
|
| 1889 | - $this->checkout->payment = $payment; |
|
| 1890 | - // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
|
| 1891 | - $this->checkout->transaction->toggle_failed_transaction_status(); |
|
| 1892 | - $payment_status = $payment->status(); |
|
| 1893 | - if ($payment_status === EEM_Payment::status_id_approved |
|
| 1894 | - || $payment_status === EEM_Payment::status_id_pending |
|
| 1895 | - ) { |
|
| 1896 | - return true; |
|
| 1897 | - } else { |
|
| 1898 | - return false; |
|
| 1899 | - } |
|
| 1900 | - } elseif ($payment === true) { |
|
| 1901 | - // please note that offline payment methods will NOT make a payment, |
|
| 1902 | - // but instead just mark themselves as the PMD_ID on the transaction, and return true |
|
| 1903 | - $this->checkout->payment = $payment; |
|
| 1904 | - return true; |
|
| 1905 | - } |
|
| 1906 | - // where's my money? |
|
| 1907 | - return false; |
|
| 1908 | - } |
|
| 1909 | - |
|
| 1910 | - |
|
| 1911 | - /** |
|
| 1912 | - * _last_second_ticket_verifications |
|
| 1913 | - * |
|
| 1914 | - * @access public |
|
| 1915 | - * @return bool |
|
| 1916 | - * @throws EE_Error |
|
| 1917 | - */ |
|
| 1918 | - protected function _last_second_ticket_verifications() |
|
| 1919 | - { |
|
| 1920 | - // don't bother re-validating if not a return visit |
|
| 1921 | - if (! $this->checkout->revisit) { |
|
| 1922 | - return true; |
|
| 1923 | - } |
|
| 1924 | - $registrations = $this->checkout->transaction->registrations(); |
|
| 1925 | - if (empty($registrations)) { |
|
| 1926 | - return false; |
|
| 1927 | - } |
|
| 1928 | - foreach ($registrations as $registration) { |
|
| 1929 | - if ($registration instanceof EE_Registration && ! $registration->is_approved()) { |
|
| 1930 | - $event = $registration->event_obj(); |
|
| 1931 | - if ($event instanceof EE_Event && $event->is_sold_out(true)) { |
|
| 1932 | - EE_Error::add_error( |
|
| 1933 | - apply_filters( |
|
| 1934 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options___last_second_ticket_verifications__sold_out_events_msg', |
|
| 1935 | - sprintf( |
|
| 1936 | - esc_html__( |
|
| 1937 | - 'It appears that the %1$s event that you were about to make a payment for has sold out since you first registered and/or arrived at this page. Please refresh the page and try again. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', |
|
| 1938 | - 'event_espresso' |
|
| 1939 | - ), |
|
| 1940 | - $event->name() |
|
| 1941 | - ) |
|
| 1942 | - ), |
|
| 1943 | - __FILE__, |
|
| 1944 | - __FUNCTION__, |
|
| 1945 | - __LINE__ |
|
| 1946 | - ); |
|
| 1947 | - return false; |
|
| 1948 | - } |
|
| 1949 | - } |
|
| 1950 | - } |
|
| 1951 | - return true; |
|
| 1952 | - } |
|
| 1953 | - |
|
| 1954 | - |
|
| 1955 | - /** |
|
| 1956 | - * redirect_form |
|
| 1957 | - * |
|
| 1958 | - * @access public |
|
| 1959 | - * @return bool |
|
| 1960 | - * @throws EE_Error |
|
| 1961 | - * @throws InvalidArgumentException |
|
| 1962 | - * @throws ReflectionException |
|
| 1963 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1964 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1965 | - */ |
|
| 1966 | - public function redirect_form() |
|
| 1967 | - { |
|
| 1968 | - $payment_method_billing_info = $this->_payment_method_billing_info( |
|
| 1969 | - $this->_get_payment_method_for_selected_method_of_payment() |
|
| 1970 | - ); |
|
| 1971 | - $html = $payment_method_billing_info->get_html(); |
|
| 1972 | - $html .= $this->checkout->redirect_form; |
|
| 1973 | - EE_Registry::instance()->REQ->add_output($html); |
|
| 1974 | - return true; |
|
| 1975 | - } |
|
| 1976 | - |
|
| 1977 | - |
|
| 1978 | - /** |
|
| 1979 | - * _billing_form_is_valid |
|
| 1980 | - * |
|
| 1981 | - * @access private |
|
| 1982 | - * @return bool |
|
| 1983 | - * @throws \EE_Error |
|
| 1984 | - */ |
|
| 1985 | - private function _billing_form_is_valid() |
|
| 1986 | - { |
|
| 1987 | - if (! $this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
| 1988 | - return true; |
|
| 1989 | - } |
|
| 1990 | - if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) { |
|
| 1991 | - if ($this->checkout->billing_form->was_submitted()) { |
|
| 1992 | - $this->checkout->billing_form->receive_form_submission(); |
|
| 1993 | - if ($this->checkout->billing_form->is_valid()) { |
|
| 1994 | - return true; |
|
| 1995 | - } |
|
| 1996 | - $validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated(); |
|
| 1997 | - $error_strings = array(); |
|
| 1998 | - foreach ($validation_errors as $validation_error) { |
|
| 1999 | - if ($validation_error instanceof EE_Validation_Error) { |
|
| 2000 | - $form_section = $validation_error->get_form_section(); |
|
| 2001 | - if ($form_section instanceof EE_Form_Input_Base) { |
|
| 2002 | - $label = $form_section->html_label_text(); |
|
| 2003 | - } elseif ($form_section instanceof EE_Form_Section_Base) { |
|
| 2004 | - $label = $form_section->name(); |
|
| 2005 | - } else { |
|
| 2006 | - $label = esc_html__('Validation Error', 'event_espresso'); |
|
| 2007 | - } |
|
| 2008 | - $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage()); |
|
| 2009 | - } |
|
| 2010 | - } |
|
| 2011 | - EE_Error::add_error( |
|
| 2012 | - sprintf( |
|
| 2013 | - esc_html__( |
|
| 2014 | - 'One or more billing form inputs are invalid and require correction before proceeding. %1$s %2$s', |
|
| 2015 | - 'event_espresso' |
|
| 2016 | - ), |
|
| 2017 | - '<br/>', |
|
| 2018 | - implode('<br/>', $error_strings) |
|
| 2019 | - ), |
|
| 2020 | - __FILE__, |
|
| 2021 | - __FUNCTION__, |
|
| 2022 | - __LINE__ |
|
| 2023 | - ); |
|
| 2024 | - } else { |
|
| 2025 | - EE_Error::add_error( |
|
| 2026 | - esc_html__( |
|
| 2027 | - 'The billing form was not submitted or something prevented it\'s submission.', |
|
| 2028 | - 'event_espresso' |
|
| 2029 | - ), |
|
| 2030 | - __FILE__, |
|
| 2031 | - __FUNCTION__, |
|
| 2032 | - __LINE__ |
|
| 2033 | - ); |
|
| 2034 | - } |
|
| 2035 | - } else { |
|
| 2036 | - EE_Error::add_error( |
|
| 2037 | - esc_html__( |
|
| 2038 | - 'The submitted billing form is invalid possibly due to a technical reason.', |
|
| 2039 | - 'event_espresso' |
|
| 2040 | - ), |
|
| 2041 | - __FILE__, |
|
| 2042 | - __FUNCTION__, |
|
| 2043 | - __LINE__ |
|
| 2044 | - ); |
|
| 2045 | - } |
|
| 2046 | - return false; |
|
| 2047 | - } |
|
| 2048 | - |
|
| 2049 | - |
|
| 2050 | - /** |
|
| 2051 | - * _setup_primary_registrant_prior_to_payment |
|
| 2052 | - * ensures that the primary registrant has a valid attendee object created with the critical details populated |
|
| 2053 | - * (first & last name & email) and that both the transaction object and primary registration object have been saved |
|
| 2054 | - * plz note that any other registrations will NOT be saved at this point (because they may not have any details |
|
| 2055 | - * yet) |
|
| 2056 | - * |
|
| 2057 | - * @access private |
|
| 2058 | - * @return bool |
|
| 2059 | - * @throws EE_Error |
|
| 2060 | - * @throws InvalidArgumentException |
|
| 2061 | - * @throws ReflectionException |
|
| 2062 | - * @throws RuntimeException |
|
| 2063 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2064 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2065 | - */ |
|
| 2066 | - private function _setup_primary_registrant_prior_to_payment() |
|
| 2067 | - { |
|
| 2068 | - // check if transaction has a primary registrant and that it has a related Attendee object |
|
| 2069 | - // if not, then we need to at least gather some primary registrant data before attempting payment |
|
| 2070 | - if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form |
|
| 2071 | - && ! $this->checkout->transaction_has_primary_registrant() |
|
| 2072 | - && ! $this->_capture_primary_registration_data_from_billing_form() |
|
| 2073 | - ) { |
|
| 2074 | - return false; |
|
| 2075 | - } |
|
| 2076 | - // because saving an object clears it's cache, we need to do the chevy shuffle |
|
| 2077 | - // grab the primary_registration object |
|
| 2078 | - $primary_registration = $this->checkout->transaction->primary_registration(); |
|
| 2079 | - // at this point we'll consider a TXN to not have been failed |
|
| 2080 | - $this->checkout->transaction->toggle_failed_transaction_status(); |
|
| 2081 | - // save the TXN ( which clears cached copy of primary_registration) |
|
| 2082 | - $this->checkout->transaction->save(); |
|
| 2083 | - // grab TXN ID and save it to the primary_registration |
|
| 2084 | - $primary_registration->set_transaction_id($this->checkout->transaction->ID()); |
|
| 2085 | - // save what we have so far |
|
| 2086 | - $primary_registration->save(); |
|
| 2087 | - return true; |
|
| 2088 | - } |
|
| 2089 | - |
|
| 2090 | - |
|
| 2091 | - /** |
|
| 2092 | - * _capture_primary_registration_data_from_billing_form |
|
| 2093 | - * |
|
| 2094 | - * @access private |
|
| 2095 | - * @return bool |
|
| 2096 | - * @throws EE_Error |
|
| 2097 | - * @throws InvalidArgumentException |
|
| 2098 | - * @throws ReflectionException |
|
| 2099 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2100 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2101 | - */ |
|
| 2102 | - private function _capture_primary_registration_data_from_billing_form() |
|
| 2103 | - { |
|
| 2104 | - // convert billing form data into an attendee |
|
| 2105 | - $this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data(); |
|
| 2106 | - if (! $this->checkout->primary_attendee_obj instanceof EE_Attendee) { |
|
| 2107 | - EE_Error::add_error( |
|
| 2108 | - sprintf( |
|
| 2109 | - esc_html__( |
|
| 2110 | - 'The billing form details could not be used for attendee details due to a technical issue.%sPlease try again or contact %s for assistance.', |
|
| 2111 | - 'event_espresso' |
|
| 2112 | - ), |
|
| 2113 | - '<br/>', |
|
| 2114 | - EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2115 | - ), |
|
| 2116 | - __FILE__, |
|
| 2117 | - __FUNCTION__, |
|
| 2118 | - __LINE__ |
|
| 2119 | - ); |
|
| 2120 | - return false; |
|
| 2121 | - } |
|
| 2122 | - $primary_registration = $this->checkout->transaction->primary_registration(); |
|
| 2123 | - if (! $primary_registration instanceof EE_Registration) { |
|
| 2124 | - EE_Error::add_error( |
|
| 2125 | - sprintf( |
|
| 2126 | - esc_html__( |
|
| 2127 | - 'The primary registrant for this transaction could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', |
|
| 2128 | - 'event_espresso' |
|
| 2129 | - ), |
|
| 2130 | - '<br/>', |
|
| 2131 | - EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2132 | - ), |
|
| 2133 | - __FILE__, |
|
| 2134 | - __FUNCTION__, |
|
| 2135 | - __LINE__ |
|
| 2136 | - ); |
|
| 2137 | - return false; |
|
| 2138 | - } |
|
| 2139 | - if (! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee') |
|
| 2140 | - instanceof |
|
| 2141 | - EE_Attendee |
|
| 2142 | - ) { |
|
| 2143 | - EE_Error::add_error( |
|
| 2144 | - sprintf( |
|
| 2145 | - esc_html__( |
|
| 2146 | - 'The primary registrant could not be associated with this transaction due to a technical issue.%sPlease try again or contact %s for assistance.', |
|
| 2147 | - 'event_espresso' |
|
| 2148 | - ), |
|
| 2149 | - '<br/>', |
|
| 2150 | - EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2151 | - ), |
|
| 2152 | - __FILE__, |
|
| 2153 | - __FUNCTION__, |
|
| 2154 | - __LINE__ |
|
| 2155 | - ); |
|
| 2156 | - return false; |
|
| 2157 | - } |
|
| 2158 | - /** @type EE_Registration_Processor $registration_processor */ |
|
| 2159 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
| 2160 | - // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
|
| 2161 | - $registration_processor->toggle_incomplete_registration_status_to_default($primary_registration); |
|
| 2162 | - return true; |
|
| 2163 | - } |
|
| 2164 | - |
|
| 2165 | - |
|
| 2166 | - /** |
|
| 2167 | - * _get_payment_method_for_selected_method_of_payment |
|
| 2168 | - * retrieves a valid payment method |
|
| 2169 | - * |
|
| 2170 | - * @access public |
|
| 2171 | - * @return EE_Payment_Method |
|
| 2172 | - * @throws EE_Error |
|
| 2173 | - * @throws InvalidArgumentException |
|
| 2174 | - * @throws ReflectionException |
|
| 2175 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2176 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2177 | - */ |
|
| 2178 | - private function _get_payment_method_for_selected_method_of_payment() |
|
| 2179 | - { |
|
| 2180 | - if ($this->checkout->selected_method_of_payment === 'events_sold_out') { |
|
| 2181 | - $this->_redirect_because_event_sold_out(); |
|
| 2182 | - return null; |
|
| 2183 | - } |
|
| 2184 | - // get EE_Payment_Method object |
|
| 2185 | - if (isset($this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ])) { |
|
| 2186 | - $payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ]; |
|
| 2187 | - } else { |
|
| 2188 | - // load EEM_Payment_Method |
|
| 2189 | - EE_Registry::instance()->load_model('Payment_Method'); |
|
| 2190 | - /** @type EEM_Payment_Method $EEM_Payment_Method */ |
|
| 2191 | - $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
|
| 2192 | - $payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment); |
|
| 2193 | - } |
|
| 2194 | - // verify $payment_method |
|
| 2195 | - if (! $payment_method instanceof EE_Payment_Method) { |
|
| 2196 | - // not a payment |
|
| 2197 | - EE_Error::add_error( |
|
| 2198 | - sprintf( |
|
| 2199 | - esc_html__( |
|
| 2200 | - 'The selected method of payment could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', |
|
| 2201 | - 'event_espresso' |
|
| 2202 | - ), |
|
| 2203 | - '<br/>', |
|
| 2204 | - EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2205 | - ), |
|
| 2206 | - __FILE__, |
|
| 2207 | - __FUNCTION__, |
|
| 2208 | - __LINE__ |
|
| 2209 | - ); |
|
| 2210 | - return null; |
|
| 2211 | - } |
|
| 2212 | - // and verify it has a valid Payment_Method Type object |
|
| 2213 | - if (! $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
| 2214 | - // not a payment |
|
| 2215 | - EE_Error::add_error( |
|
| 2216 | - sprintf( |
|
| 2217 | - esc_html__( |
|
| 2218 | - 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', |
|
| 2219 | - 'event_espresso' |
|
| 2220 | - ), |
|
| 2221 | - '<br/>', |
|
| 2222 | - EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2223 | - ), |
|
| 2224 | - __FILE__, |
|
| 2225 | - __FUNCTION__, |
|
| 2226 | - __LINE__ |
|
| 2227 | - ); |
|
| 2228 | - return null; |
|
| 2229 | - } |
|
| 2230 | - return $payment_method; |
|
| 2231 | - } |
|
| 2232 | - |
|
| 2233 | - |
|
| 2234 | - /** |
|
| 2235 | - * _attempt_payment |
|
| 2236 | - * |
|
| 2237 | - * @access private |
|
| 2238 | - * @type EE_Payment_Method $payment_method |
|
| 2239 | - * @return mixed EE_Payment | boolean |
|
| 2240 | - * @throws EE_Error |
|
| 2241 | - * @throws InvalidArgumentException |
|
| 2242 | - * @throws ReflectionException |
|
| 2243 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2244 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2245 | - */ |
|
| 2246 | - private function _attempt_payment(EE_Payment_Method $payment_method) |
|
| 2247 | - { |
|
| 2248 | - $payment = null; |
|
| 2249 | - $this->checkout->transaction->save(); |
|
| 2250 | - $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
| 2251 | - if (! $payment_processor instanceof EE_Payment_Processor) { |
|
| 2252 | - return false; |
|
| 2253 | - } |
|
| 2254 | - try { |
|
| 2255 | - $payment_processor->set_revisit($this->checkout->revisit); |
|
| 2256 | - // generate payment object |
|
| 2257 | - $payment = $payment_processor->process_payment( |
|
| 2258 | - $payment_method, |
|
| 2259 | - $this->checkout->transaction, |
|
| 2260 | - $this->checkout->amount_owing, |
|
| 2261 | - $this->checkout->billing_form, |
|
| 2262 | - $this->_get_return_url($payment_method), |
|
| 2263 | - 'CART', |
|
| 2264 | - $this->checkout->admin_request, |
|
| 2265 | - true, |
|
| 2266 | - $this->reg_step_url() |
|
| 2267 | - ); |
|
| 2268 | - } catch (Exception $e) { |
|
| 2269 | - $this->_handle_payment_processor_exception($e); |
|
| 2270 | - } |
|
| 2271 | - return $payment; |
|
| 2272 | - } |
|
| 2273 | - |
|
| 2274 | - |
|
| 2275 | - /** |
|
| 2276 | - * _handle_payment_processor_exception |
|
| 2277 | - * |
|
| 2278 | - * @access protected |
|
| 2279 | - * @param \Exception $e |
|
| 2280 | - * @return void |
|
| 2281 | - * @throws EE_Error |
|
| 2282 | - * @throws InvalidArgumentException |
|
| 2283 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2284 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2285 | - */ |
|
| 2286 | - protected function _handle_payment_processor_exception(Exception $e) |
|
| 2287 | - { |
|
| 2288 | - EE_Error::add_error( |
|
| 2289 | - sprintf( |
|
| 2290 | - esc_html__( |
|
| 2291 | - 'The payment could not br processed due to a technical issue.%1$sPlease try again or contact %2$s for assistance.||The following Exception was thrown in %4$s on line %5$s:%1$s%3$s', |
|
| 2292 | - 'event_espresso' |
|
| 2293 | - ), |
|
| 2294 | - '<br/>', |
|
| 2295 | - EE_Registry::instance()->CFG->organization->get_pretty('email'), |
|
| 2296 | - $e->getMessage(), |
|
| 2297 | - $e->getFile(), |
|
| 2298 | - $e->getLine() |
|
| 2299 | - ), |
|
| 2300 | - __FILE__, |
|
| 2301 | - __FUNCTION__, |
|
| 2302 | - __LINE__ |
|
| 2303 | - ); |
|
| 2304 | - } |
|
| 2305 | - |
|
| 2306 | - |
|
| 2307 | - /** |
|
| 2308 | - * _get_return_url |
|
| 2309 | - * |
|
| 2310 | - * @access protected |
|
| 2311 | - * @param \EE_Payment_Method $payment_method |
|
| 2312 | - * @return string |
|
| 2313 | - * @throws \EE_Error |
|
| 2314 | - */ |
|
| 2315 | - protected function _get_return_url(EE_Payment_Method $payment_method) |
|
| 2316 | - { |
|
| 2317 | - $return_url = ''; |
|
| 2318 | - switch ($payment_method->type_obj()->payment_occurs()) { |
|
| 2319 | - case EE_PMT_Base::offsite: |
|
| 2320 | - $return_url = add_query_arg( |
|
| 2321 | - array( |
|
| 2322 | - 'action' => 'process_gateway_response', |
|
| 2323 | - 'selected_method_of_payment' => $this->checkout->selected_method_of_payment, |
|
| 2324 | - 'spco_txn' => $this->checkout->transaction->ID(), |
|
| 2325 | - ), |
|
| 2326 | - $this->reg_step_url() |
|
| 2327 | - ); |
|
| 2328 | - break; |
|
| 2329 | - case EE_PMT_Base::onsite: |
|
| 2330 | - case EE_PMT_Base::offline: |
|
| 2331 | - $return_url = $this->checkout->next_step->reg_step_url(); |
|
| 2332 | - break; |
|
| 2333 | - } |
|
| 2334 | - return $return_url; |
|
| 2335 | - } |
|
| 2336 | - |
|
| 2337 | - |
|
| 2338 | - /** |
|
| 2339 | - * _validate_payment |
|
| 2340 | - * |
|
| 2341 | - * @access private |
|
| 2342 | - * @param EE_Payment $payment |
|
| 2343 | - * @return EE_Payment|FALSE |
|
| 2344 | - * @throws EE_Error |
|
| 2345 | - * @throws InvalidArgumentException |
|
| 2346 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2347 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2348 | - */ |
|
| 2349 | - private function _validate_payment($payment = null) |
|
| 2350 | - { |
|
| 2351 | - if ($this->checkout->payment_method->is_off_line()) { |
|
| 2352 | - return true; |
|
| 2353 | - } |
|
| 2354 | - // verify payment object |
|
| 2355 | - if (! $payment instanceof EE_Payment) { |
|
| 2356 | - // not a payment |
|
| 2357 | - EE_Error::add_error( |
|
| 2358 | - sprintf( |
|
| 2359 | - esc_html__( |
|
| 2360 | - 'A valid payment was not generated due to a technical issue.%1$sPlease try again or contact %2$s for assistance.', |
|
| 2361 | - 'event_espresso' |
|
| 2362 | - ), |
|
| 2363 | - '<br/>', |
|
| 2364 | - EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2365 | - ), |
|
| 2366 | - __FILE__, |
|
| 2367 | - __FUNCTION__, |
|
| 2368 | - __LINE__ |
|
| 2369 | - ); |
|
| 2370 | - return false; |
|
| 2371 | - } |
|
| 2372 | - return $payment; |
|
| 2373 | - } |
|
| 2374 | - |
|
| 2375 | - |
|
| 2376 | - /** |
|
| 2377 | - * _post_payment_processing |
|
| 2378 | - * |
|
| 2379 | - * @access private |
|
| 2380 | - * @param EE_Payment|bool $payment |
|
| 2381 | - * @return bool |
|
| 2382 | - * @throws EE_Error |
|
| 2383 | - * @throws InvalidArgumentException |
|
| 2384 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2385 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2386 | - */ |
|
| 2387 | - private function _post_payment_processing($payment = null) |
|
| 2388 | - { |
|
| 2389 | - // Off-Line payment? |
|
| 2390 | - if ($payment === true) { |
|
| 2391 | - // $this->_setup_redirect_for_next_step(); |
|
| 2392 | - return true; |
|
| 2393 | - // On-Site payment? |
|
| 2394 | - } elseif ($this->checkout->payment_method->is_on_site()) { |
|
| 2395 | - if (! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) { |
|
| 2396 | - // $this->_setup_redirect_for_next_step(); |
|
| 2397 | - $this->checkout->continue_reg = false; |
|
| 2398 | - } |
|
| 2399 | - // Off-Site payment? |
|
| 2400 | - } elseif ($this->checkout->payment_method->is_off_site()) { |
|
| 2401 | - // if a payment object was made and it specifies a redirect url, then we'll setup that redirect info |
|
| 2402 | - if ($payment instanceof EE_Payment && $payment->redirect_url()) { |
|
| 2403 | - do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()'); |
|
| 2404 | - $this->checkout->redirect = true; |
|
| 2405 | - $this->checkout->redirect_form = $payment->redirect_form(); |
|
| 2406 | - $this->checkout->redirect_url = $this->reg_step_url('redirect_form'); |
|
| 2407 | - // set JSON response |
|
| 2408 | - $this->checkout->json_response->set_redirect_form($this->checkout->redirect_form); |
|
| 2409 | - // and lastly, let's bump the payment status to pending |
|
| 2410 | - $payment->set_status(EEM_Payment::status_id_pending); |
|
| 2411 | - $payment->save(); |
|
| 2412 | - } else { |
|
| 2413 | - // we couldn't redirect the user. Let's tell them why. |
|
| 2414 | - $error_message = sprintf( |
|
| 2415 | - esc_html__( |
|
| 2416 | - 'It appears the Off Site Payment Method was not configured properly.%sPlease try again or contact %s for assistance.', |
|
| 2417 | - 'event_espresso' |
|
| 2418 | - ), |
|
| 2419 | - '<br/>', |
|
| 2420 | - EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2421 | - ); |
|
| 2422 | - if ($payment instanceof EE_Payment && $payment->gateway_response()) { |
|
| 2423 | - $error_message = $error_message . '<br/>' . $payment->gateway_response(); |
|
| 2424 | - } |
|
| 2425 | - $this->checkout->continue_reg = false; |
|
| 2426 | - EE_Error::add_error( |
|
| 2427 | - $error_message, |
|
| 2428 | - __FILE__, |
|
| 2429 | - __FUNCTION__, |
|
| 2430 | - __LINE__ |
|
| 2431 | - ); |
|
| 2432 | - } |
|
| 2433 | - } else { |
|
| 2434 | - // ummm ya... not Off-Line, not On-Site, not off-Site ???? |
|
| 2435 | - $this->checkout->continue_reg = false; |
|
| 2436 | - return false; |
|
| 2437 | - } |
|
| 2438 | - return $payment; |
|
| 2439 | - } |
|
| 2440 | - |
|
| 2441 | - |
|
| 2442 | - /** |
|
| 2443 | - * _process_payment_status |
|
| 2444 | - * |
|
| 2445 | - * @access private |
|
| 2446 | - * @type EE_Payment $payment |
|
| 2447 | - * @param string $payment_occurs |
|
| 2448 | - * @return bool |
|
| 2449 | - * @throws EE_Error |
|
| 2450 | - * @throws InvalidArgumentException |
|
| 2451 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2452 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2453 | - */ |
|
| 2454 | - private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) |
|
| 2455 | - { |
|
| 2456 | - // off-line payment? carry on |
|
| 2457 | - if ($payment_occurs === EE_PMT_Base::offline) { |
|
| 2458 | - return true; |
|
| 2459 | - } |
|
| 2460 | - // verify payment validity |
|
| 2461 | - if ($payment instanceof EE_Payment) { |
|
| 2462 | - do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()'); |
|
| 2463 | - $msg = $payment->gateway_response(); |
|
| 2464 | - // check results |
|
| 2465 | - switch ($payment->status()) { |
|
| 2466 | - // good payment |
|
| 2467 | - case EEM_Payment::status_id_approved: |
|
| 2468 | - EE_Error::add_success( |
|
| 2469 | - esc_html__('Your payment was processed successfully.', 'event_espresso'), |
|
| 2470 | - __FILE__, |
|
| 2471 | - __FUNCTION__, |
|
| 2472 | - __LINE__ |
|
| 2473 | - ); |
|
| 2474 | - return true; |
|
| 2475 | - break; |
|
| 2476 | - // slow payment |
|
| 2477 | - case EEM_Payment::status_id_pending: |
|
| 2478 | - if (empty($msg)) { |
|
| 2479 | - $msg = esc_html__( |
|
| 2480 | - 'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', |
|
| 2481 | - 'event_espresso' |
|
| 2482 | - ); |
|
| 2483 | - } |
|
| 2484 | - EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2485 | - return true; |
|
| 2486 | - break; |
|
| 2487 | - // don't wanna payment |
|
| 2488 | - case EEM_Payment::status_id_cancelled: |
|
| 2489 | - if (empty($msg)) { |
|
| 2490 | - $msg = _n( |
|
| 2491 | - 'Payment cancelled. Please try again.', |
|
| 2492 | - 'Payment cancelled. Please try again or select another method of payment.', |
|
| 2493 | - count($this->checkout->available_payment_methods), |
|
| 2494 | - 'event_espresso' |
|
| 2495 | - ); |
|
| 2496 | - } |
|
| 2497 | - EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2498 | - return false; |
|
| 2499 | - break; |
|
| 2500 | - // not enough payment |
|
| 2501 | - case EEM_Payment::status_id_declined: |
|
| 2502 | - if (empty($msg)) { |
|
| 2503 | - $msg = _n( |
|
| 2504 | - 'We\'re sorry but your payment was declined. Please try again.', |
|
| 2505 | - 'We\'re sorry but your payment was declined. Please try again or select another method of payment.', |
|
| 2506 | - count($this->checkout->available_payment_methods), |
|
| 2507 | - 'event_espresso' |
|
| 2508 | - ); |
|
| 2509 | - } |
|
| 2510 | - EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2511 | - return false; |
|
| 2512 | - break; |
|
| 2513 | - // bad payment |
|
| 2514 | - case EEM_Payment::status_id_failed: |
|
| 2515 | - if (! empty($msg)) { |
|
| 2516 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2517 | - return false; |
|
| 2518 | - } |
|
| 2519 | - // default to error below |
|
| 2520 | - break; |
|
| 2521 | - } |
|
| 2522 | - } |
|
| 2523 | - // off-site payment gateway responses are too unreliable, so let's just assume that |
|
| 2524 | - // the payment processing is just running slower than the registrant's request |
|
| 2525 | - if ($payment_occurs === EE_PMT_Base::offsite) { |
|
| 2526 | - return true; |
|
| 2527 | - } |
|
| 2528 | - EE_Error::add_error( |
|
| 2529 | - sprintf( |
|
| 2530 | - esc_html__( |
|
| 2531 | - 'Your payment could not be processed successfully due to a technical issue.%sPlease try again or contact %s for assistance.', |
|
| 2532 | - 'event_espresso' |
|
| 2533 | - ), |
|
| 2534 | - '<br/>', |
|
| 2535 | - EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2536 | - ), |
|
| 2537 | - __FILE__, |
|
| 2538 | - __FUNCTION__, |
|
| 2539 | - __LINE__ |
|
| 2540 | - ); |
|
| 2541 | - return false; |
|
| 2542 | - } |
|
| 2543 | - |
|
| 2544 | - |
|
| 2545 | - |
|
| 2546 | - |
|
| 2547 | - |
|
| 2548 | - |
|
| 2549 | - /********************************************************************************************************/ |
|
| 2550 | - /********************************** PROCESS GATEWAY RESPONSE **********************************/ |
|
| 2551 | - /********************************************************************************************************/ |
|
| 2552 | - /** |
|
| 2553 | - * process_gateway_response |
|
| 2554 | - * this is the return point for Off-Site Payment Methods |
|
| 2555 | - * It will attempt to "handle the IPN" if it appears that this has not already occurred, |
|
| 2556 | - * otherwise, it will load up the last payment made for the TXN. |
|
| 2557 | - * If the payment retrieved looks good, it will then either: |
|
| 2558 | - * complete the current step and allow advancement to the next reg step |
|
| 2559 | - * or present the payment options again |
|
| 2560 | - * |
|
| 2561 | - * @access private |
|
| 2562 | - * @return EE_Payment|FALSE |
|
| 2563 | - * @throws EE_Error |
|
| 2564 | - * @throws InvalidArgumentException |
|
| 2565 | - * @throws ReflectionException |
|
| 2566 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2567 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2568 | - * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
|
| 2569 | - */ |
|
| 2570 | - public function process_gateway_response() |
|
| 2571 | - { |
|
| 2572 | - $payment = null; |
|
| 2573 | - // how have they chosen to pay? |
|
| 2574 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
| 2575 | - // get EE_Payment_Method object |
|
| 2576 | - if (! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
| 2577 | - $this->checkout->continue_reg = false; |
|
| 2578 | - return false; |
|
| 2579 | - } |
|
| 2580 | - if (! $this->checkout->payment_method->is_off_site()) { |
|
| 2581 | - return false; |
|
| 2582 | - } |
|
| 2583 | - $this->_validate_offsite_return(); |
|
| 2584 | - // DEBUG LOG |
|
| 2585 | - // $this->checkout->log( |
|
| 2586 | - // __CLASS__, |
|
| 2587 | - // __FUNCTION__, |
|
| 2588 | - // __LINE__, |
|
| 2589 | - // array( |
|
| 2590 | - // 'selected_method_of_payment' => $this->checkout->selected_method_of_payment, |
|
| 2591 | - // 'payment_method' => $this->checkout->payment_method, |
|
| 2592 | - // ), |
|
| 2593 | - // true |
|
| 2594 | - // ); |
|
| 2595 | - // verify TXN |
|
| 2596 | - if ($this->checkout->transaction instanceof EE_Transaction) { |
|
| 2597 | - $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
|
| 2598 | - if (! $gateway instanceof EE_Offsite_Gateway) { |
|
| 2599 | - $this->checkout->continue_reg = false; |
|
| 2600 | - return false; |
|
| 2601 | - } |
|
| 2602 | - $payment = $this->_process_off_site_payment($gateway); |
|
| 2603 | - $payment = $this->_process_cancelled_payments($payment); |
|
| 2604 | - $payment = $this->_validate_payment($payment); |
|
| 2605 | - // if payment was not declined by the payment gateway or cancelled by the registrant |
|
| 2606 | - if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) { |
|
| 2607 | - // $this->_setup_redirect_for_next_step(); |
|
| 2608 | - // store that for later |
|
| 2609 | - $this->checkout->payment = $payment; |
|
| 2610 | - // mark this reg step as completed, as long as gateway doesn't use a separate IPN request, |
|
| 2611 | - // because we will complete this step during the IPN processing then |
|
| 2612 | - if ($gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request()) { |
|
| 2613 | - $this->set_completed(); |
|
| 2614 | - } |
|
| 2615 | - return true; |
|
| 2616 | - } |
|
| 2617 | - } |
|
| 2618 | - // DEBUG LOG |
|
| 2619 | - // $this->checkout->log( |
|
| 2620 | - // __CLASS__, |
|
| 2621 | - // __FUNCTION__, |
|
| 2622 | - // __LINE__, |
|
| 2623 | - // array('payment' => $payment) |
|
| 2624 | - // ); |
|
| 2625 | - $this->checkout->continue_reg = false; |
|
| 2626 | - return false; |
|
| 2627 | - } |
|
| 2628 | - |
|
| 2629 | - |
|
| 2630 | - /** |
|
| 2631 | - * _validate_return |
|
| 2632 | - * |
|
| 2633 | - * @access private |
|
| 2634 | - * @return void |
|
| 2635 | - * @throws EE_Error |
|
| 2636 | - * @throws InvalidArgumentException |
|
| 2637 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2638 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2639 | - * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
|
| 2640 | - */ |
|
| 2641 | - private function _validate_offsite_return() |
|
| 2642 | - { |
|
| 2643 | - $TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0); |
|
| 2644 | - if ($TXN_ID !== $this->checkout->transaction->ID()) { |
|
| 2645 | - // Houston... we might have a problem |
|
| 2646 | - $invalid_TXN = false; |
|
| 2647 | - // first gather some info |
|
| 2648 | - $valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
| 2649 | - $primary_registrant = $valid_TXN instanceof EE_Transaction |
|
| 2650 | - ? $valid_TXN->primary_registration() |
|
| 2651 | - : null; |
|
| 2652 | - // let's start by retrieving the cart for this TXN |
|
| 2653 | - $cart = $this->checkout->get_cart_for_transaction($this->checkout->transaction); |
|
| 2654 | - if ($cart instanceof EE_Cart) { |
|
| 2655 | - // verify that the current cart has tickets |
|
| 2656 | - $tickets = $cart->get_tickets(); |
|
| 2657 | - if (empty($tickets)) { |
|
| 2658 | - $invalid_TXN = true; |
|
| 2659 | - } |
|
| 2660 | - } else { |
|
| 2661 | - $invalid_TXN = true; |
|
| 2662 | - } |
|
| 2663 | - $valid_TXN_SID = $primary_registrant instanceof EE_Registration |
|
| 2664 | - ? $primary_registrant->session_ID() |
|
| 2665 | - : null; |
|
| 2666 | - // validate current Session ID and compare against valid TXN session ID |
|
| 2667 | - if ($invalid_TXN // if this is already true, then skip other checks |
|
| 2668 | - || EE_Session::instance()->id() === null |
|
| 2669 | - || ( |
|
| 2670 | - // WARNING !!! |
|
| 2671 | - // this could be PayPal sending back duplicate requests (ya they do that) |
|
| 2672 | - // or it **could** mean someone is simply registering AGAIN after having just done so |
|
| 2673 | - // so now we need to determine if this current TXN looks valid or not |
|
| 2674 | - // and whether this reg step has even been started ? |
|
| 2675 | - EE_Session::instance()->id() === $valid_TXN_SID |
|
| 2676 | - // really? you're half way through this reg step, but you never started it ? |
|
| 2677 | - && $this->checkout->transaction->reg_step_completed($this->slug()) === false |
|
| 2678 | - ) |
|
| 2679 | - ) { |
|
| 2680 | - $invalid_TXN = true; |
|
| 2681 | - } |
|
| 2682 | - if ($invalid_TXN) { |
|
| 2683 | - // is the valid TXN completed ? |
|
| 2684 | - if ($valid_TXN instanceof EE_Transaction) { |
|
| 2685 | - // has this step even been started ? |
|
| 2686 | - $reg_step_completed = $valid_TXN->reg_step_completed($this->slug()); |
|
| 2687 | - if ($reg_step_completed !== false && $reg_step_completed !== true) { |
|
| 2688 | - // so it **looks** like this is a double request from PayPal |
|
| 2689 | - // so let's try to pick up where we left off |
|
| 2690 | - $this->checkout->transaction = $valid_TXN; |
|
| 2691 | - $this->checkout->refresh_all_entities(true); |
|
| 2692 | - return; |
|
| 2693 | - } |
|
| 2694 | - } |
|
| 2695 | - // you appear to be lost? |
|
| 2696 | - $this->_redirect_wayward_request($primary_registrant); |
|
| 2697 | - } |
|
| 2698 | - } |
|
| 2699 | - } |
|
| 2700 | - |
|
| 2701 | - |
|
| 2702 | - /** |
|
| 2703 | - * _redirect_wayward_request |
|
| 2704 | - * |
|
| 2705 | - * @access private |
|
| 2706 | - * @param \EE_Registration|null $primary_registrant |
|
| 2707 | - * @return bool |
|
| 2708 | - * @throws EE_Error |
|
| 2709 | - * @throws InvalidArgumentException |
|
| 2710 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2711 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2712 | - */ |
|
| 2713 | - private function _redirect_wayward_request(EE_Registration $primary_registrant) |
|
| 2714 | - { |
|
| 2715 | - if (! $primary_registrant instanceof EE_Registration) { |
|
| 2716 | - // try redirecting based on the current TXN |
|
| 2717 | - $primary_registrant = $this->checkout->transaction instanceof EE_Transaction |
|
| 2718 | - ? $this->checkout->transaction->primary_registration() |
|
| 2719 | - : null; |
|
| 2720 | - } |
|
| 2721 | - if (! $primary_registrant instanceof EE_Registration) { |
|
| 2722 | - EE_Error::add_error( |
|
| 2723 | - sprintf( |
|
| 2724 | - esc_html__( |
|
| 2725 | - 'Invalid information was received from the Off-Site Payment Processor and your Transaction details could not be retrieved from the database.%1$sPlease try again or contact %2$s for assistance.', |
|
| 2726 | - 'event_espresso' |
|
| 2727 | - ), |
|
| 2728 | - '<br/>', |
|
| 2729 | - EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2730 | - ), |
|
| 2731 | - __FILE__, |
|
| 2732 | - __FUNCTION__, |
|
| 2733 | - __LINE__ |
|
| 2734 | - ); |
|
| 2735 | - return false; |
|
| 2736 | - } |
|
| 2737 | - // make sure transaction is not locked |
|
| 2738 | - $this->checkout->transaction->unlock(); |
|
| 2739 | - wp_safe_redirect( |
|
| 2740 | - add_query_arg( |
|
| 2741 | - array( |
|
| 2742 | - 'e_reg_url_link' => $primary_registrant->reg_url_link(), |
|
| 2743 | - ), |
|
| 2744 | - $this->checkout->thank_you_page_url |
|
| 2745 | - ) |
|
| 2746 | - ); |
|
| 2747 | - exit(); |
|
| 2748 | - } |
|
| 2749 | - |
|
| 2750 | - |
|
| 2751 | - /** |
|
| 2752 | - * _process_off_site_payment |
|
| 2753 | - * |
|
| 2754 | - * @access private |
|
| 2755 | - * @param \EE_Offsite_Gateway $gateway |
|
| 2756 | - * @return EE_Payment |
|
| 2757 | - * @throws EE_Error |
|
| 2758 | - * @throws InvalidArgumentException |
|
| 2759 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2760 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2761 | - */ |
|
| 2762 | - private function _process_off_site_payment(EE_Offsite_Gateway $gateway) |
|
| 2763 | - { |
|
| 2764 | - try { |
|
| 2765 | - $request_data = \EE_Registry::instance()->REQ->params(); |
|
| 2766 | - // if gateway uses_separate_IPN_request, then we don't have to process the IPN manually |
|
| 2767 | - $this->set_handle_IPN_in_this_request( |
|
| 2768 | - $gateway->handle_IPN_in_this_request($request_data, false) |
|
| 2769 | - ); |
|
| 2770 | - if ($this->handle_IPN_in_this_request()) { |
|
| 2771 | - // get payment details and process results |
|
| 2772 | - /** @type EE_Payment_Processor $payment_processor */ |
|
| 2773 | - $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
| 2774 | - $payment = $payment_processor->process_ipn( |
|
| 2775 | - $request_data, |
|
| 2776 | - $this->checkout->transaction, |
|
| 2777 | - $this->checkout->payment_method, |
|
| 2778 | - true, |
|
| 2779 | - false |
|
| 2780 | - ); |
|
| 2781 | - // $payment_source = 'process_ipn'; |
|
| 2782 | - } else { |
|
| 2783 | - $payment = $this->checkout->transaction->last_payment(); |
|
| 2784 | - // $payment_source = 'last_payment'; |
|
| 2785 | - } |
|
| 2786 | - } catch (Exception $e) { |
|
| 2787 | - // let's just eat the exception and try to move on using any previously set payment info |
|
| 2788 | - $payment = $this->checkout->transaction->last_payment(); |
|
| 2789 | - // $payment_source = 'last_payment after Exception'; |
|
| 2790 | - // but if we STILL don't have a payment object |
|
| 2791 | - if (! $payment instanceof EE_Payment) { |
|
| 2792 | - // then we'll object ! ( not object like a thing... but object like what a lawyer says ! ) |
|
| 2793 | - $this->_handle_payment_processor_exception($e); |
|
| 2794 | - } |
|
| 2795 | - } |
|
| 2796 | - // DEBUG LOG |
|
| 2797 | - // $this->checkout->log( |
|
| 2798 | - // __CLASS__, |
|
| 2799 | - // __FUNCTION__, |
|
| 2800 | - // __LINE__, |
|
| 2801 | - // array( |
|
| 2802 | - // 'process_ipn_payment' => $payment, |
|
| 2803 | - // 'payment_source' => $payment_source, |
|
| 2804 | - // ) |
|
| 2805 | - // ); |
|
| 2806 | - return $payment; |
|
| 2807 | - } |
|
| 2808 | - |
|
| 2809 | - |
|
| 2810 | - /** |
|
| 2811 | - * _process_cancelled_payments |
|
| 2812 | - * just makes sure that the payment status gets updated correctly |
|
| 2813 | - * so tha tan error isn't generated during payment validation |
|
| 2814 | - * |
|
| 2815 | - * @access private |
|
| 2816 | - * @param EE_Payment $payment |
|
| 2817 | - * @return EE_Payment | FALSE |
|
| 2818 | - * @throws \EE_Error |
|
| 2819 | - */ |
|
| 2820 | - private function _process_cancelled_payments($payment = null) |
|
| 2821 | - { |
|
| 2822 | - if ($payment instanceof EE_Payment |
|
| 2823 | - && isset($_REQUEST['ee_cancel_payment']) |
|
| 2824 | - && $payment->status() === EEM_Payment::status_id_failed |
|
| 2825 | - ) { |
|
| 2826 | - $payment->set_status(EEM_Payment::status_id_cancelled); |
|
| 2827 | - } |
|
| 2828 | - return $payment; |
|
| 2829 | - } |
|
| 2830 | - |
|
| 2831 | - |
|
| 2832 | - /** |
|
| 2833 | - * get_transaction_details_for_gateways |
|
| 2834 | - * |
|
| 2835 | - * @access public |
|
| 2836 | - * @return int |
|
| 2837 | - * @throws EE_Error |
|
| 2838 | - * @throws InvalidArgumentException |
|
| 2839 | - * @throws ReflectionException |
|
| 2840 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2841 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2842 | - */ |
|
| 2843 | - public function get_transaction_details_for_gateways() |
|
| 2844 | - { |
|
| 2845 | - $txn_details = array(); |
|
| 2846 | - // ya gotta make a choice man |
|
| 2847 | - if (empty($this->checkout->selected_method_of_payment)) { |
|
| 2848 | - $txn_details = array( |
|
| 2849 | - 'error' => esc_html__('Please select a method of payment before proceeding.', 'event_espresso'), |
|
| 2850 | - ); |
|
| 2851 | - } |
|
| 2852 | - // get EE_Payment_Method object |
|
| 2853 | - if (empty($txn_details) |
|
| 2854 | - && |
|
| 2855 | - ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() |
|
| 2856 | - ) { |
|
| 2857 | - $txn_details = array( |
|
| 2858 | - 'selected_method_of_payment' => $this->checkout->selected_method_of_payment, |
|
| 2859 | - 'error' => esc_html__( |
|
| 2860 | - 'A valid Payment Method could not be determined.', |
|
| 2861 | - 'event_espresso' |
|
| 2862 | - ), |
|
| 2863 | - ); |
|
| 2864 | - } |
|
| 2865 | - if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) { |
|
| 2866 | - $return_url = $this->_get_return_url($this->checkout->payment_method); |
|
| 2867 | - $txn_details = array( |
|
| 2868 | - 'TXN_ID' => $this->checkout->transaction->ID(), |
|
| 2869 | - 'TXN_timestamp' => $this->checkout->transaction->datetime(), |
|
| 2870 | - 'TXN_total' => $this->checkout->transaction->total(), |
|
| 2871 | - 'TXN_paid' => $this->checkout->transaction->paid(), |
|
| 2872 | - 'TXN_reg_steps' => $this->checkout->transaction->reg_steps(), |
|
| 2873 | - 'STS_ID' => $this->checkout->transaction->status_ID(), |
|
| 2874 | - 'PMD_ID' => $this->checkout->transaction->payment_method_ID(), |
|
| 2875 | - 'payment_amount' => $this->checkout->amount_owing, |
|
| 2876 | - 'return_url' => $return_url, |
|
| 2877 | - 'cancel_url' => add_query_arg(array('ee_cancel_payment' => true), $return_url), |
|
| 2878 | - 'notify_url' => EE_Config::instance()->core->txn_page_url( |
|
| 2879 | - array( |
|
| 2880 | - 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link(), |
|
| 2881 | - 'ee_payment_method' => $this->checkout->payment_method->slug(), |
|
| 2882 | - ) |
|
| 2883 | - ), |
|
| 2884 | - ); |
|
| 2885 | - } |
|
| 2886 | - echo wp_json_encode($txn_details); |
|
| 2887 | - exit(); |
|
| 2888 | - } |
|
| 2889 | - |
|
| 2890 | - |
|
| 2891 | - /** |
|
| 2892 | - * __sleep |
|
| 2893 | - * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon |
|
| 2894 | - * serialization EE_Checkout will handle the reimplementation of itself upon waking, but we won't bother with the |
|
| 2895 | - * reg form, because if needed, it will be regenerated anyways |
|
| 2896 | - * |
|
| 2897 | - * @return array |
|
| 2898 | - */ |
|
| 2899 | - public function __sleep() |
|
| 2900 | - { |
|
| 2901 | - // remove the reg form and the checkout |
|
| 2902 | - return array_diff(array_keys(get_object_vars($this)), array('reg_form', 'checkout', 'line_item_display')); |
|
| 2903 | - } |
|
| 15 | + /** |
|
| 16 | + * @access protected |
|
| 17 | + * @var EE_Line_Item_Display $Line_Item_Display |
|
| 18 | + */ |
|
| 19 | + protected $line_item_display; |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * @access protected |
|
| 23 | + * @var boolean $handle_IPN_in_this_request |
|
| 24 | + */ |
|
| 25 | + protected $handle_IPN_in_this_request = false; |
|
| 26 | + |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
| 30 | + * |
|
| 31 | + * @access public |
|
| 32 | + * @return void |
|
| 33 | + */ |
|
| 34 | + public static function set_hooks() |
|
| 35 | + { |
|
| 36 | + add_filter( |
|
| 37 | + 'FHEE__SPCO__EE_Line_Item_Filter_Collection', |
|
| 38 | + array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters') |
|
| 39 | + ); |
|
| 40 | + add_action( |
|
| 41 | + 'wp_ajax_switch_spco_billing_form', |
|
| 42 | + array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form') |
|
| 43 | + ); |
|
| 44 | + add_action( |
|
| 45 | + 'wp_ajax_nopriv_switch_spco_billing_form', |
|
| 46 | + array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form') |
|
| 47 | + ); |
|
| 48 | + add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')); |
|
| 49 | + add_action( |
|
| 50 | + 'wp_ajax_nopriv_save_payer_details', |
|
| 51 | + array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details') |
|
| 52 | + ); |
|
| 53 | + add_action( |
|
| 54 | + 'wp_ajax_get_transaction_details_for_gateways', |
|
| 55 | + array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
| 56 | + ); |
|
| 57 | + add_action( |
|
| 58 | + 'wp_ajax_nopriv_get_transaction_details_for_gateways', |
|
| 59 | + array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
| 60 | + ); |
|
| 61 | + add_filter( |
|
| 62 | + 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
|
| 63 | + array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'), |
|
| 64 | + 10, |
|
| 65 | + 1 |
|
| 66 | + ); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * ajax switch_spco_billing_form |
|
| 72 | + * |
|
| 73 | + * @throws \EE_Error |
|
| 74 | + */ |
|
| 75 | + public static function switch_spco_billing_form() |
|
| 76 | + { |
|
| 77 | + EED_Single_Page_Checkout::process_ajax_request('switch_payment_method'); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * ajax save_payer_details |
|
| 83 | + * |
|
| 84 | + * @throws \EE_Error |
|
| 85 | + */ |
|
| 86 | + public static function save_payer_details() |
|
| 87 | + { |
|
| 88 | + EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax'); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * ajax get_transaction_details |
|
| 94 | + * |
|
| 95 | + * @throws \EE_Error |
|
| 96 | + */ |
|
| 97 | + public static function get_transaction_details() |
|
| 98 | + { |
|
| 99 | + EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways'); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * bypass_recaptcha_for_load_payment_method |
|
| 105 | + * |
|
| 106 | + * @access public |
|
| 107 | + * @return array |
|
| 108 | + * @throws InvalidArgumentException |
|
| 109 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 110 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 111 | + */ |
|
| 112 | + public static function bypass_recaptcha_for_load_payment_method() |
|
| 113 | + { |
|
| 114 | + return array( |
|
| 115 | + 'EESID' => EE_Registry::instance()->SSN->id(), |
|
| 116 | + 'step' => 'payment_options', |
|
| 117 | + 'action' => 'spco_billing_form', |
|
| 118 | + ); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * class constructor |
|
| 124 | + * |
|
| 125 | + * @access public |
|
| 126 | + * @param EE_Checkout $checkout |
|
| 127 | + */ |
|
| 128 | + public function __construct(EE_Checkout $checkout) |
|
| 129 | + { |
|
| 130 | + $this->_slug = 'payment_options'; |
|
| 131 | + $this->_name = esc_html__('Payment Options', 'event_espresso'); |
|
| 132 | + $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . '/payment_options_main.template.php'; |
|
| 133 | + $this->checkout = $checkout; |
|
| 134 | + $this->_reset_success_message(); |
|
| 135 | + $this->set_instructions( |
|
| 136 | + esc_html__( |
|
| 137 | + 'Please select a method of payment and provide any necessary billing information before proceeding.', |
|
| 138 | + 'event_espresso' |
|
| 139 | + ) |
|
| 140 | + ); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * @return null |
|
| 146 | + */ |
|
| 147 | + public function line_item_display() |
|
| 148 | + { |
|
| 149 | + return $this->line_item_display; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * @param null $line_item_display |
|
| 155 | + */ |
|
| 156 | + public function set_line_item_display($line_item_display) |
|
| 157 | + { |
|
| 158 | + $this->line_item_display = $line_item_display; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + |
|
| 162 | + /** |
|
| 163 | + * @return boolean |
|
| 164 | + */ |
|
| 165 | + public function handle_IPN_in_this_request() |
|
| 166 | + { |
|
| 167 | + return $this->handle_IPN_in_this_request; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * @param boolean $handle_IPN_in_this_request |
|
| 173 | + */ |
|
| 174 | + public function set_handle_IPN_in_this_request($handle_IPN_in_this_request) |
|
| 175 | + { |
|
| 176 | + $this->handle_IPN_in_this_request = filter_var($handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN); |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + |
|
| 180 | + /** |
|
| 181 | + * translate_js_strings |
|
| 182 | + * |
|
| 183 | + * @return void |
|
| 184 | + */ |
|
| 185 | + public function translate_js_strings() |
|
| 186 | + { |
|
| 187 | + EE_Registry::$i18n_js_strings['no_payment_method'] = esc_html__( |
|
| 188 | + 'Please select a method of payment in order to continue.', |
|
| 189 | + 'event_espresso' |
|
| 190 | + ); |
|
| 191 | + EE_Registry::$i18n_js_strings['invalid_payment_method'] = esc_html__( |
|
| 192 | + 'A valid method of payment could not be determined. Please refresh the page and try again.', |
|
| 193 | + 'event_espresso' |
|
| 194 | + ); |
|
| 195 | + EE_Registry::$i18n_js_strings['forwarding_to_offsite'] = esc_html__( |
|
| 196 | + 'Forwarding to Secure Payment Provider.', |
|
| 197 | + 'event_espresso' |
|
| 198 | + ); |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * enqueue_styles_and_scripts |
|
| 204 | + * |
|
| 205 | + * @return void |
|
| 206 | + * @throws EE_Error |
|
| 207 | + * @throws InvalidArgumentException |
|
| 208 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 209 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 210 | + */ |
|
| 211 | + public function enqueue_styles_and_scripts() |
|
| 212 | + { |
|
| 213 | + $transaction = $this->checkout->transaction; |
|
| 214 | + // if the transaction isn't set or nothing is owed on it, don't enqueue any JS |
|
| 215 | + if (! $transaction instanceof EE_Transaction || EEH_Money::compare_floats($transaction->remaining(), 0)) { |
|
| 216 | + return; |
|
| 217 | + } |
|
| 218 | + foreach (EEM_Payment_Method::instance()->get_all_for_transaction( |
|
| 219 | + $transaction, |
|
| 220 | + EEM_Payment_Method::scope_cart |
|
| 221 | + ) as $payment_method) { |
|
| 222 | + $type_obj = $payment_method->type_obj(); |
|
| 223 | + if ($type_obj instanceof EE_PMT_Base) { |
|
| 224 | + $billing_form = $type_obj->generate_new_billing_form($transaction); |
|
| 225 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
| 226 | + $billing_form->enqueue_js(); |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + |
|
| 233 | + /** |
|
| 234 | + * initialize_reg_step |
|
| 235 | + * |
|
| 236 | + * @return bool |
|
| 237 | + * @throws EE_Error |
|
| 238 | + * @throws InvalidArgumentException |
|
| 239 | + * @throws ReflectionException |
|
| 240 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 241 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 242 | + */ |
|
| 243 | + public function initialize_reg_step() |
|
| 244 | + { |
|
| 245 | + // TODO: if /when we implement donations, then this will need overriding |
|
| 246 | + if (// don't need payment options for: |
|
| 247 | + // registrations made via the admin |
|
| 248 | + // completed transactions |
|
| 249 | + // overpaid transactions |
|
| 250 | + // $ 0.00 transactions(no payment required) |
|
| 251 | + ! $this->checkout->payment_required() |
|
| 252 | + // but do NOT remove if current action being called belongs to this reg step |
|
| 253 | + && ! is_callable(array($this, $this->checkout->action)) |
|
| 254 | + && ! $this->completed() |
|
| 255 | + ) { |
|
| 256 | + // and if so, then we no longer need the Payment Options step |
|
| 257 | + if ($this->is_current_step()) { |
|
| 258 | + $this->checkout->generate_reg_form = false; |
|
| 259 | + } |
|
| 260 | + $this->checkout->remove_reg_step($this->_slug); |
|
| 261 | + // DEBUG LOG |
|
| 262 | + // $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
|
| 263 | + return false; |
|
| 264 | + } |
|
| 265 | + // load EEM_Payment_Method |
|
| 266 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
| 267 | + // get all active payment methods |
|
| 268 | + $this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( |
|
| 269 | + $this->checkout->transaction, |
|
| 270 | + EEM_Payment_Method::scope_cart |
|
| 271 | + ); |
|
| 272 | + return true; |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + |
|
| 276 | + /** |
|
| 277 | + * @return EE_Form_Section_Proper |
|
| 278 | + * @throws EE_Error |
|
| 279 | + * @throws InvalidArgumentException |
|
| 280 | + * @throws ReflectionException |
|
| 281 | + * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 282 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 283 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 284 | + * @throws \EventEspresso\core\exceptions\InvalidStatusException |
|
| 285 | + */ |
|
| 286 | + public function generate_reg_form() |
|
| 287 | + { |
|
| 288 | + // reset in case someone changes their mind |
|
| 289 | + $this->_reset_selected_method_of_payment(); |
|
| 290 | + // set some defaults |
|
| 291 | + $this->checkout->selected_method_of_payment = 'payments_closed'; |
|
| 292 | + $registrations_requiring_payment = array(); |
|
| 293 | + $registrations_for_free_events = array(); |
|
| 294 | + $registrations_requiring_pre_approval = array(); |
|
| 295 | + $sold_out_events = array(); |
|
| 296 | + $insufficient_spaces_available = array(); |
|
| 297 | + $no_payment_required = true; |
|
| 298 | + // loop thru registrations to gather info |
|
| 299 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
| 300 | + $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space( |
|
| 301 | + $registrations, |
|
| 302 | + $this->checkout->revisit |
|
| 303 | + ); |
|
| 304 | + foreach ($registrations as $REG_ID => $registration) { |
|
| 305 | + /** @var $registration EE_Registration */ |
|
| 306 | + // has this registration lost it's space ? |
|
| 307 | + if (isset($ejected_registrations[ $REG_ID ])) { |
|
| 308 | + if ($registration->event()->is_sold_out() || $registration->event()->is_sold_out(true)) { |
|
| 309 | + $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
| 310 | + } else { |
|
| 311 | + $insufficient_spaces_available[ $registration->event()->ID() ] = $registration->event(); |
|
| 312 | + } |
|
| 313 | + continue; |
|
| 314 | + } |
|
| 315 | + // event requires admin approval |
|
| 316 | + if ($registration->status_ID() === EEM_Registration::status_id_not_approved) { |
|
| 317 | + // add event to list of events with pre-approval reg status |
|
| 318 | + $registrations_requiring_pre_approval[ $REG_ID ] = $registration; |
|
| 319 | + do_action( |
|
| 320 | + 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval', |
|
| 321 | + $registration->event(), |
|
| 322 | + $this |
|
| 323 | + ); |
|
| 324 | + continue; |
|
| 325 | + } |
|
| 326 | + if ($this->checkout->revisit |
|
| 327 | + && $registration->status_ID() !== EEM_Registration::status_id_approved |
|
| 328 | + && ( |
|
| 329 | + $registration->event()->is_sold_out() |
|
| 330 | + || $registration->event()->is_sold_out(true) |
|
| 331 | + ) |
|
| 332 | + ) { |
|
| 333 | + // add event to list of events that are sold out |
|
| 334 | + $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
| 335 | + do_action( |
|
| 336 | + 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
|
| 337 | + $registration->event(), |
|
| 338 | + $this |
|
| 339 | + ); |
|
| 340 | + continue; |
|
| 341 | + } |
|
| 342 | + // are they allowed to pay now and is there monies owing? |
|
| 343 | + if ($registration->owes_monies_and_can_pay()) { |
|
| 344 | + $registrations_requiring_payment[ $REG_ID ] = $registration; |
|
| 345 | + do_action( |
|
| 346 | + 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment', |
|
| 347 | + $registration->event(), |
|
| 348 | + $this |
|
| 349 | + ); |
|
| 350 | + } elseif (! $this->checkout->revisit |
|
| 351 | + && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
|
| 352 | + && $registration->ticket()->is_free() |
|
| 353 | + ) { |
|
| 354 | + $registrations_for_free_events[ $registration->ticket()->ID() ] = $registration; |
|
| 355 | + } |
|
| 356 | + } |
|
| 357 | + $subsections = array(); |
|
| 358 | + // now decide which template to load |
|
| 359 | + if (! empty($sold_out_events)) { |
|
| 360 | + $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events); |
|
| 361 | + } |
|
| 362 | + if (! empty($insufficient_spaces_available)) { |
|
| 363 | + $subsections['insufficient_space'] = $this->_insufficient_spaces_available( |
|
| 364 | + $insufficient_spaces_available |
|
| 365 | + ); |
|
| 366 | + } |
|
| 367 | + if (! empty($registrations_requiring_pre_approval)) { |
|
| 368 | + $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval( |
|
| 369 | + $registrations_requiring_pre_approval |
|
| 370 | + ); |
|
| 371 | + } |
|
| 372 | + if (! empty($registrations_for_free_events)) { |
|
| 373 | + $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events); |
|
| 374 | + } |
|
| 375 | + if (! empty($registrations_requiring_payment)) { |
|
| 376 | + if ($this->checkout->amount_owing > 0) { |
|
| 377 | + // autoload Line_Item_Display classes |
|
| 378 | + EEH_Autoloader::register_line_item_filter_autoloaders(); |
|
| 379 | + $line_item_filter_processor = new EE_Line_Item_Filter_Processor( |
|
| 380 | + apply_filters( |
|
| 381 | + 'FHEE__SPCO__EE_Line_Item_Filter_Collection', |
|
| 382 | + new EE_Line_Item_Filter_Collection() |
|
| 383 | + ), |
|
| 384 | + $this->checkout->cart->get_grand_total() |
|
| 385 | + ); |
|
| 386 | + /** @var EE_Line_Item $filtered_line_item_tree */ |
|
| 387 | + $filtered_line_item_tree = $line_item_filter_processor->process(); |
|
| 388 | + EEH_Autoloader::register_line_item_display_autoloaders(); |
|
| 389 | + $this->set_line_item_display(new EE_Line_Item_Display('spco')); |
|
| 390 | + $subsections['payment_options'] = $this->_display_payment_options( |
|
| 391 | + $this->line_item_display->display_line_item( |
|
| 392 | + $filtered_line_item_tree, |
|
| 393 | + array('registrations' => $registrations) |
|
| 394 | + ) |
|
| 395 | + ); |
|
| 396 | + $this->checkout->amount_owing = $filtered_line_item_tree->total(); |
|
| 397 | + $this->_apply_registration_payments_to_amount_owing($registrations); |
|
| 398 | + } |
|
| 399 | + $no_payment_required = false; |
|
| 400 | + } else { |
|
| 401 | + $this->_hide_reg_step_submit_button_if_revisit(); |
|
| 402 | + } |
|
| 403 | + $this->_save_selected_method_of_payment(); |
|
| 404 | + |
|
| 405 | + $subsections['default_hidden_inputs'] = $this->reg_step_hidden_inputs(); |
|
| 406 | + $subsections['extra_hidden_inputs'] = $this->_extra_hidden_inputs($no_payment_required); |
|
| 407 | + |
|
| 408 | + return new EE_Form_Section_Proper( |
|
| 409 | + array( |
|
| 410 | + 'name' => $this->reg_form_name(), |
|
| 411 | + 'html_id' => $this->reg_form_name(), |
|
| 412 | + 'subsections' => $subsections, |
|
| 413 | + 'layout_strategy' => new EE_No_Layout(), |
|
| 414 | + ) |
|
| 415 | + ); |
|
| 416 | + } |
|
| 417 | + |
|
| 418 | + |
|
| 419 | + /** |
|
| 420 | + * add line item filters required for this reg step |
|
| 421 | + * these filters are applied via this line in EE_SPCO_Reg_Step_Payment_Options::set_hooks(): |
|
| 422 | + * add_filter( 'FHEE__SPCO__EE_Line_Item_Filter_Collection', array( 'EE_SPCO_Reg_Step_Payment_Options', |
|
| 423 | + * 'add_spco_line_item_filters' ) ); so any code that wants to use the same set of filters during the |
|
| 424 | + * payment options reg step, can apply these filters via the following: apply_filters( |
|
| 425 | + * 'FHEE__SPCO__EE_Line_Item_Filter_Collection', new EE_Line_Item_Filter_Collection() ) or to an existing |
|
| 426 | + * filter collection by passing that instead of instantiating a new collection |
|
| 427 | + * |
|
| 428 | + * @param \EE_Line_Item_Filter_Collection $line_item_filter_collection |
|
| 429 | + * @return EE_Line_Item_Filter_Collection |
|
| 430 | + * @throws EE_Error |
|
| 431 | + * @throws InvalidArgumentException |
|
| 432 | + * @throws ReflectionException |
|
| 433 | + * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 434 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 435 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 436 | + * @throws \EventEspresso\core\exceptions\InvalidStatusException |
|
| 437 | + */ |
|
| 438 | + public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) |
|
| 439 | + { |
|
| 440 | + if (! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
| 441 | + return $line_item_filter_collection; |
|
| 442 | + } |
|
| 443 | + if (! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout) { |
|
| 444 | + return $line_item_filter_collection; |
|
| 445 | + } |
|
| 446 | + if (! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction) { |
|
| 447 | + return $line_item_filter_collection; |
|
| 448 | + } |
|
| 449 | + $line_item_filter_collection->add( |
|
| 450 | + new EE_Billable_Line_Item_Filter( |
|
| 451 | + EE_SPCO_Reg_Step_Payment_Options::remove_ejected_registrations( |
|
| 452 | + EE_Registry::instance()->SSN->checkout()->transaction->registrations( |
|
| 453 | + EE_Registry::instance()->SSN->checkout()->reg_cache_where_params |
|
| 454 | + ) |
|
| 455 | + ) |
|
| 456 | + ) |
|
| 457 | + ); |
|
| 458 | + $line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter()); |
|
| 459 | + return $line_item_filter_collection; |
|
| 460 | + } |
|
| 461 | + |
|
| 462 | + |
|
| 463 | + /** |
|
| 464 | + * remove_ejected_registrations |
|
| 465 | + * if a registrant has lost their potential space at an event due to lack of payment, |
|
| 466 | + * then this method removes them from the list of registrations being paid for during this request |
|
| 467 | + * |
|
| 468 | + * @param \EE_Registration[] $registrations |
|
| 469 | + * @return EE_Registration[] |
|
| 470 | + * @throws EE_Error |
|
| 471 | + * @throws InvalidArgumentException |
|
| 472 | + * @throws ReflectionException |
|
| 473 | + * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 474 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 475 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 476 | + * @throws \EventEspresso\core\exceptions\InvalidStatusException |
|
| 477 | + */ |
|
| 478 | + public static function remove_ejected_registrations(array $registrations) |
|
| 479 | + { |
|
| 480 | + $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space( |
|
| 481 | + $registrations, |
|
| 482 | + EE_Registry::instance()->SSN->checkout()->revisit |
|
| 483 | + ); |
|
| 484 | + foreach ($registrations as $REG_ID => $registration) { |
|
| 485 | + // has this registration lost it's space ? |
|
| 486 | + if (isset($ejected_registrations[ $REG_ID ])) { |
|
| 487 | + unset($registrations[ $REG_ID ]); |
|
| 488 | + continue; |
|
| 489 | + } |
|
| 490 | + } |
|
| 491 | + return $registrations; |
|
| 492 | + } |
|
| 493 | + |
|
| 494 | + |
|
| 495 | + /** |
|
| 496 | + * find_registrations_that_lost_their_space |
|
| 497 | + * If a registrant chooses an offline payment method like Invoice, |
|
| 498 | + * then no space is reserved for them at the event until they fully pay fo that site |
|
| 499 | + * (unless the event's default reg status is set to APPROVED) |
|
| 500 | + * if a registrant then later returns to pay, but the number of spaces available has been reduced due to sales, |
|
| 501 | + * then this method will determine which registrations have lost the ability to complete the reg process. |
|
| 502 | + * |
|
| 503 | + * @param \EE_Registration[] $registrations |
|
| 504 | + * @param bool $revisit |
|
| 505 | + * @return array |
|
| 506 | + * @throws EE_Error |
|
| 507 | + * @throws InvalidArgumentException |
|
| 508 | + * @throws ReflectionException |
|
| 509 | + * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 510 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 511 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 512 | + * @throws \EventEspresso\core\exceptions\InvalidStatusException |
|
| 513 | + */ |
|
| 514 | + public static function find_registrations_that_lost_their_space(array $registrations, $revisit = false) |
|
| 515 | + { |
|
| 516 | + // registrations per event |
|
| 517 | + $event_reg_count = array(); |
|
| 518 | + // spaces left per event |
|
| 519 | + $event_spaces_remaining = array(); |
|
| 520 | + // tickets left sorted by ID |
|
| 521 | + $tickets_remaining = array(); |
|
| 522 | + // registrations that have lost their space |
|
| 523 | + $ejected_registrations = array(); |
|
| 524 | + foreach ($registrations as $REG_ID => $registration) { |
|
| 525 | + if ($registration->status_ID() === EEM_Registration::status_id_approved |
|
| 526 | + || apply_filters( |
|
| 527 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options__find_registrations_that_lost_their_space__allow_reg_payment', |
|
| 528 | + false, |
|
| 529 | + $registration, |
|
| 530 | + $revisit |
|
| 531 | + ) |
|
| 532 | + ) { |
|
| 533 | + continue; |
|
| 534 | + } |
|
| 535 | + $EVT_ID = $registration->event_ID(); |
|
| 536 | + $ticket = $registration->ticket(); |
|
| 537 | + if (! isset($tickets_remaining[ $ticket->ID() ])) { |
|
| 538 | + $tickets_remaining[ $ticket->ID() ] = $ticket->remaining(); |
|
| 539 | + } |
|
| 540 | + if ($tickets_remaining[ $ticket->ID() ] > 0) { |
|
| 541 | + if (! isset($event_reg_count[ $EVT_ID ])) { |
|
| 542 | + $event_reg_count[ $EVT_ID ] = 0; |
|
| 543 | + } |
|
| 544 | + $event_reg_count[ $EVT_ID ]++; |
|
| 545 | + if (! isset($event_spaces_remaining[ $EVT_ID ])) { |
|
| 546 | + $event_spaces_remaining[ $EVT_ID ] = $registration->event()->spaces_remaining_for_sale(); |
|
| 547 | + } |
|
| 548 | + } |
|
| 549 | + if ($revisit |
|
| 550 | + && ($tickets_remaining[ $ticket->ID() ] === 0 |
|
| 551 | + || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ] |
|
| 552 | + ) |
|
| 553 | + ) { |
|
| 554 | + $ejected_registrations[ $REG_ID ] = $registration->event(); |
|
| 555 | + if ($registration->status_ID() !== EEM_Registration::status_id_wait_list) { |
|
| 556 | + /** @type EE_Registration_Processor $registration_processor */ |
|
| 557 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
| 558 | + // at this point, we should have enough details about the registrant to consider the registration |
|
| 559 | + // NOT incomplete |
|
| 560 | + $registration_processor->manually_update_registration_status( |
|
| 561 | + $registration, |
|
| 562 | + EEM_Registration::status_id_wait_list |
|
| 563 | + ); |
|
| 564 | + } |
|
| 565 | + } |
|
| 566 | + } |
|
| 567 | + return $ejected_registrations; |
|
| 568 | + } |
|
| 569 | + |
|
| 570 | + |
|
| 571 | + /** |
|
| 572 | + * _hide_reg_step_submit_button |
|
| 573 | + * removes the html for the reg step submit button |
|
| 574 | + * by replacing it with an empty string via filter callback |
|
| 575 | + * |
|
| 576 | + * @return void |
|
| 577 | + */ |
|
| 578 | + protected function _adjust_registration_status_if_event_old_sold() |
|
| 579 | + { |
|
| 580 | + } |
|
| 581 | + |
|
| 582 | + |
|
| 583 | + /** |
|
| 584 | + * _hide_reg_step_submit_button |
|
| 585 | + * removes the html for the reg step submit button |
|
| 586 | + * by replacing it with an empty string via filter callback |
|
| 587 | + * |
|
| 588 | + * @return void |
|
| 589 | + */ |
|
| 590 | + protected function _hide_reg_step_submit_button_if_revisit() |
|
| 591 | + { |
|
| 592 | + if ($this->checkout->revisit) { |
|
| 593 | + add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string'); |
|
| 594 | + } |
|
| 595 | + } |
|
| 596 | + |
|
| 597 | + |
|
| 598 | + /** |
|
| 599 | + * sold_out_events |
|
| 600 | + * displays notices regarding events that have sold out since hte registrant first signed up |
|
| 601 | + * |
|
| 602 | + * @param \EE_Event[] $sold_out_events_array |
|
| 603 | + * @return \EE_Form_Section_Proper |
|
| 604 | + * @throws \EE_Error |
|
| 605 | + */ |
|
| 606 | + private function _sold_out_events($sold_out_events_array = array()) |
|
| 607 | + { |
|
| 608 | + // set some defaults |
|
| 609 | + $this->checkout->selected_method_of_payment = 'events_sold_out'; |
|
| 610 | + $sold_out_events = ''; |
|
| 611 | + foreach ($sold_out_events_array as $sold_out_event) { |
|
| 612 | + $sold_out_events .= EEH_HTML::li( |
|
| 613 | + EEH_HTML::span( |
|
| 614 | + ' ' . $sold_out_event->name(), |
|
| 615 | + '', |
|
| 616 | + 'dashicons dashicons-marker ee-icon-size-16 pink-text' |
|
| 617 | + ) |
|
| 618 | + ); |
|
| 619 | + } |
|
| 620 | + return new EE_Form_Section_Proper( |
|
| 621 | + array( |
|
| 622 | + 'layout_strategy' => new EE_Template_Layout( |
|
| 623 | + array( |
|
| 624 | + 'layout_template_file' => SPCO_REG_STEPS_PATH |
|
| 625 | + . $this->_slug |
|
| 626 | + . '/sold_out_events.template.php', |
|
| 627 | + 'template_args' => apply_filters( |
|
| 628 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
|
| 629 | + array( |
|
| 630 | + 'sold_out_events' => $sold_out_events, |
|
| 631 | + 'sold_out_events_msg' => apply_filters( |
|
| 632 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__sold_out_events_msg', |
|
| 633 | + sprintf( |
|
| 634 | + esc_html__( |
|
| 635 | + 'It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.%3$s%3$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%2$s', |
|
| 636 | + 'event_espresso' |
|
| 637 | + ), |
|
| 638 | + '<strong>', |
|
| 639 | + '</strong>', |
|
| 640 | + '<br />' |
|
| 641 | + ) |
|
| 642 | + ), |
|
| 643 | + ) |
|
| 644 | + ), |
|
| 645 | + ) |
|
| 646 | + ), |
|
| 647 | + ) |
|
| 648 | + ); |
|
| 649 | + } |
|
| 650 | + |
|
| 651 | + |
|
| 652 | + /** |
|
| 653 | + * _insufficient_spaces_available |
|
| 654 | + * displays notices regarding events that do not have enough remaining spaces |
|
| 655 | + * to satisfy the current number of registrations looking to pay |
|
| 656 | + * |
|
| 657 | + * @param \EE_Event[] $insufficient_spaces_events_array |
|
| 658 | + * @return \EE_Form_Section_Proper |
|
| 659 | + * @throws \EE_Error |
|
| 660 | + */ |
|
| 661 | + private function _insufficient_spaces_available($insufficient_spaces_events_array = array()) |
|
| 662 | + { |
|
| 663 | + // set some defaults |
|
| 664 | + $this->checkout->selected_method_of_payment = 'invoice'; |
|
| 665 | + $insufficient_space_events = ''; |
|
| 666 | + foreach ($insufficient_spaces_events_array as $event) { |
|
| 667 | + if ($event instanceof EE_Event) { |
|
| 668 | + $insufficient_space_events .= EEH_HTML::li( |
|
| 669 | + EEH_HTML::span(' ' . $event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text') |
|
| 670 | + ); |
|
| 671 | + } |
|
| 672 | + } |
|
| 673 | + return new EE_Form_Section_Proper( |
|
| 674 | + array( |
|
| 675 | + 'subsections' => array( |
|
| 676 | + 'default_hidden_inputs' => $this->reg_step_hidden_inputs(), |
|
| 677 | + 'extra_hidden_inputs' => $this->_extra_hidden_inputs(), |
|
| 678 | + ), |
|
| 679 | + 'layout_strategy' => new EE_Template_Layout( |
|
| 680 | + array( |
|
| 681 | + 'layout_template_file' => SPCO_REG_STEPS_PATH |
|
| 682 | + . $this->_slug |
|
| 683 | + . '/sold_out_events.template.php', |
|
| 684 | + 'template_args' => apply_filters( |
|
| 685 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options___insufficient_spaces_available__template_args', |
|
| 686 | + array( |
|
| 687 | + 'sold_out_events' => $insufficient_space_events, |
|
| 688 | + 'sold_out_events_msg' => apply_filters( |
|
| 689 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options___insufficient_spaces_available__insufficient_space_msg', |
|
| 690 | + esc_html__( |
|
| 691 | + 'It appears that the event you were about to make a payment for has sold additional tickets since you first registered, and there are no longer enough spaces left to accommodate your selections. You may continue to pay and secure the available space(s) remaining, or simply cancel if you no longer wish to purchase. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', |
|
| 692 | + 'event_espresso' |
|
| 693 | + ) |
|
| 694 | + ), |
|
| 695 | + ) |
|
| 696 | + ), |
|
| 697 | + ) |
|
| 698 | + ), |
|
| 699 | + ) |
|
| 700 | + ); |
|
| 701 | + } |
|
| 702 | + |
|
| 703 | + |
|
| 704 | + /** |
|
| 705 | + * registrations_requiring_pre_approval |
|
| 706 | + * |
|
| 707 | + * @param array $registrations_requiring_pre_approval |
|
| 708 | + * @return EE_Form_Section_Proper |
|
| 709 | + * @throws EE_Error |
|
| 710 | + * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 711 | + */ |
|
| 712 | + private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array()) |
|
| 713 | + { |
|
| 714 | + $events_requiring_pre_approval = array(); |
|
| 715 | + foreach ($registrations_requiring_pre_approval as $registration) { |
|
| 716 | + if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) { |
|
| 717 | + $events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li( |
|
| 718 | + EEH_HTML::span( |
|
| 719 | + '', |
|
| 720 | + '', |
|
| 721 | + 'dashicons dashicons-marker ee-icon-size-16 orange-text' |
|
| 722 | + ) |
|
| 723 | + . EEH_HTML::span($registration->event()->name(), '', 'orange-text') |
|
| 724 | + ); |
|
| 725 | + } |
|
| 726 | + } |
|
| 727 | + return new EE_Form_Section_Proper( |
|
| 728 | + array( |
|
| 729 | + 'layout_strategy' => new EE_Template_Layout( |
|
| 730 | + array( |
|
| 731 | + 'layout_template_file' => SPCO_REG_STEPS_PATH |
|
| 732 | + . $this->_slug |
|
| 733 | + . '/events_requiring_pre_approval.template.php', // layout_template |
|
| 734 | + 'template_args' => apply_filters( |
|
| 735 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
|
| 736 | + array( |
|
| 737 | + 'events_requiring_pre_approval' => implode('', $events_requiring_pre_approval), |
|
| 738 | + 'events_requiring_pre_approval_msg' => apply_filters( |
|
| 739 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg', |
|
| 740 | + esc_html__( |
|
| 741 | + 'The following events do not require payment at this time and will not be billed during this transaction. Billing will only occur after the attendee has been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.', |
|
| 742 | + 'event_espresso' |
|
| 743 | + ) |
|
| 744 | + ), |
|
| 745 | + ) |
|
| 746 | + ), |
|
| 747 | + ) |
|
| 748 | + ), |
|
| 749 | + ) |
|
| 750 | + ); |
|
| 751 | + } |
|
| 752 | + |
|
| 753 | + |
|
| 754 | + /** |
|
| 755 | + * _no_payment_required |
|
| 756 | + * |
|
| 757 | + * @param \EE_Event[] $registrations_for_free_events |
|
| 758 | + * @return \EE_Form_Section_Proper |
|
| 759 | + * @throws \EE_Error |
|
| 760 | + */ |
|
| 761 | + private function _no_payment_required($registrations_for_free_events = array()) |
|
| 762 | + { |
|
| 763 | + // set some defaults |
|
| 764 | + $this->checkout->selected_method_of_payment = 'no_payment_required'; |
|
| 765 | + // generate no_payment_required form |
|
| 766 | + return new EE_Form_Section_Proper( |
|
| 767 | + array( |
|
| 768 | + 'layout_strategy' => new EE_Template_Layout( |
|
| 769 | + array( |
|
| 770 | + 'layout_template_file' => SPCO_REG_STEPS_PATH |
|
| 771 | + . $this->_slug |
|
| 772 | + . '/no_payment_required.template.php', // layout_template |
|
| 773 | + 'template_args' => apply_filters( |
|
| 774 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options___no_payment_required__template_args', |
|
| 775 | + array( |
|
| 776 | + 'revisit' => $this->checkout->revisit, |
|
| 777 | + 'registrations' => array(), |
|
| 778 | + 'ticket_count' => array(), |
|
| 779 | + 'registrations_for_free_events' => $registrations_for_free_events, |
|
| 780 | + 'no_payment_required_msg' => EEH_HTML::p( |
|
| 781 | + esc_html__('This is a free event, so no billing will occur.', 'event_espresso') |
|
| 782 | + ), |
|
| 783 | + ) |
|
| 784 | + ), |
|
| 785 | + ) |
|
| 786 | + ), |
|
| 787 | + ) |
|
| 788 | + ); |
|
| 789 | + } |
|
| 790 | + |
|
| 791 | + |
|
| 792 | + /** |
|
| 793 | + * _display_payment_options |
|
| 794 | + * |
|
| 795 | + * @param string $transaction_details |
|
| 796 | + * @return EE_Form_Section_Proper |
|
| 797 | + * @throws EE_Error |
|
| 798 | + * @throws InvalidArgumentException |
|
| 799 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 800 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 801 | + */ |
|
| 802 | + private function _display_payment_options($transaction_details = '') |
|
| 803 | + { |
|
| 804 | + // has method_of_payment been set by no-js user? |
|
| 805 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(); |
|
| 806 | + // build payment options form |
|
| 807 | + return apply_filters( |
|
| 808 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__payment_options_form', |
|
| 809 | + new EE_Form_Section_Proper( |
|
| 810 | + array( |
|
| 811 | + 'subsections' => array( |
|
| 812 | + 'before_payment_options' => apply_filters( |
|
| 813 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options', |
|
| 814 | + new EE_Form_Section_Proper( |
|
| 815 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
| 816 | + ) |
|
| 817 | + ), |
|
| 818 | + 'payment_options' => $this->_setup_payment_options(), |
|
| 819 | + 'after_payment_options' => apply_filters( |
|
| 820 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options', |
|
| 821 | + new EE_Form_Section_Proper( |
|
| 822 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
| 823 | + ) |
|
| 824 | + ), |
|
| 825 | + ), |
|
| 826 | + 'layout_strategy' => new EE_Template_Layout( |
|
| 827 | + array( |
|
| 828 | + 'layout_template_file' => $this->_template, |
|
| 829 | + 'template_args' => apply_filters( |
|
| 830 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__template_args', |
|
| 831 | + array( |
|
| 832 | + 'reg_count' => $this->line_item_display->total_items(), |
|
| 833 | + 'transaction_details' => $transaction_details, |
|
| 834 | + 'available_payment_methods' => array(), |
|
| 835 | + ) |
|
| 836 | + ), |
|
| 837 | + ) |
|
| 838 | + ), |
|
| 839 | + ) |
|
| 840 | + ) |
|
| 841 | + ); |
|
| 842 | + } |
|
| 843 | + |
|
| 844 | + |
|
| 845 | + /** |
|
| 846 | + * _extra_hidden_inputs |
|
| 847 | + * |
|
| 848 | + * @param bool $no_payment_required |
|
| 849 | + * @return \EE_Form_Section_Proper |
|
| 850 | + * @throws \EE_Error |
|
| 851 | + */ |
|
| 852 | + private function _extra_hidden_inputs($no_payment_required = true) |
|
| 853 | + { |
|
| 854 | + return new EE_Form_Section_Proper( |
|
| 855 | + array( |
|
| 856 | + 'html_id' => 'ee-' . $this->slug() . '-extra-hidden-inputs', |
|
| 857 | + 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
| 858 | + 'subsections' => array( |
|
| 859 | + 'spco_no_payment_required' => new EE_Hidden_Input( |
|
| 860 | + array( |
|
| 861 | + 'normalization_strategy' => new EE_Boolean_Normalization(), |
|
| 862 | + 'html_name' => 'spco_no_payment_required', |
|
| 863 | + 'html_id' => 'spco-no-payment-required-payment_options', |
|
| 864 | + 'default' => $no_payment_required, |
|
| 865 | + ) |
|
| 866 | + ), |
|
| 867 | + 'spco_transaction_id' => new EE_Fixed_Hidden_Input( |
|
| 868 | + array( |
|
| 869 | + 'normalization_strategy' => new EE_Int_Normalization(), |
|
| 870 | + 'html_name' => 'spco_transaction_id', |
|
| 871 | + 'html_id' => 'spco-transaction-id', |
|
| 872 | + 'default' => $this->checkout->transaction->ID(), |
|
| 873 | + ) |
|
| 874 | + ), |
|
| 875 | + ), |
|
| 876 | + ) |
|
| 877 | + ); |
|
| 878 | + } |
|
| 879 | + |
|
| 880 | + |
|
| 881 | + /** |
|
| 882 | + * _apply_registration_payments_to_amount_owing |
|
| 883 | + * |
|
| 884 | + * @access protected |
|
| 885 | + * @param array $registrations |
|
| 886 | + * @throws EE_Error |
|
| 887 | + */ |
|
| 888 | + protected function _apply_registration_payments_to_amount_owing(array $registrations) |
|
| 889 | + { |
|
| 890 | + $payments = array(); |
|
| 891 | + foreach ($registrations as $registration) { |
|
| 892 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
| 893 | + $payments += $registration->registration_payments(); |
|
| 894 | + } |
|
| 895 | + } |
|
| 896 | + if (! empty($payments)) { |
|
| 897 | + foreach ($payments as $payment) { |
|
| 898 | + if ($payment instanceof EE_Registration_Payment) { |
|
| 899 | + $this->checkout->amount_owing -= $payment->amount(); |
|
| 900 | + } |
|
| 901 | + } |
|
| 902 | + } |
|
| 903 | + } |
|
| 904 | + |
|
| 905 | + |
|
| 906 | + /** |
|
| 907 | + * _reset_selected_method_of_payment |
|
| 908 | + * |
|
| 909 | + * @access private |
|
| 910 | + * @param bool $force_reset |
|
| 911 | + * @return void |
|
| 912 | + * @throws InvalidArgumentException |
|
| 913 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 914 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 915 | + */ |
|
| 916 | + private function _reset_selected_method_of_payment($force_reset = false) |
|
| 917 | + { |
|
| 918 | + $reset_payment_method = $force_reset |
|
| 919 | + ? true |
|
| 920 | + : sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', false)); |
|
| 921 | + if ($reset_payment_method) { |
|
| 922 | + $this->checkout->selected_method_of_payment = null; |
|
| 923 | + $this->checkout->payment_method = null; |
|
| 924 | + $this->checkout->billing_form = null; |
|
| 925 | + $this->_save_selected_method_of_payment(); |
|
| 926 | + } |
|
| 927 | + } |
|
| 928 | + |
|
| 929 | + |
|
| 930 | + /** |
|
| 931 | + * _save_selected_method_of_payment |
|
| 932 | + * stores the selected_method_of_payment in the session |
|
| 933 | + * so that it's available for all subsequent requests including AJAX |
|
| 934 | + * |
|
| 935 | + * @access private |
|
| 936 | + * @param string $selected_method_of_payment |
|
| 937 | + * @return void |
|
| 938 | + * @throws InvalidArgumentException |
|
| 939 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 940 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 941 | + */ |
|
| 942 | + private function _save_selected_method_of_payment($selected_method_of_payment = '') |
|
| 943 | + { |
|
| 944 | + $selected_method_of_payment = ! empty($selected_method_of_payment) |
|
| 945 | + ? $selected_method_of_payment |
|
| 946 | + : $this->checkout->selected_method_of_payment; |
|
| 947 | + EE_Registry::instance()->SSN->set_session_data( |
|
| 948 | + array('selected_method_of_payment' => $selected_method_of_payment) |
|
| 949 | + ); |
|
| 950 | + } |
|
| 951 | + |
|
| 952 | + |
|
| 953 | + /** |
|
| 954 | + * _setup_payment_options |
|
| 955 | + * |
|
| 956 | + * @return EE_Form_Section_Proper |
|
| 957 | + * @throws EE_Error |
|
| 958 | + * @throws InvalidArgumentException |
|
| 959 | + * @throws ReflectionException |
|
| 960 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 961 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 962 | + */ |
|
| 963 | + public function _setup_payment_options() |
|
| 964 | + { |
|
| 965 | + // load payment method classes |
|
| 966 | + $this->checkout->available_payment_methods = $this->_get_available_payment_methods(); |
|
| 967 | + if (empty($this->checkout->available_payment_methods)) { |
|
| 968 | + EE_Error::add_error( |
|
| 969 | + apply_filters( |
|
| 970 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options___setup_payment_options__error_message_no_payment_methods', |
|
| 971 | + sprintf( |
|
| 972 | + esc_html__( |
|
| 973 | + 'Sorry, you cannot complete your purchase because a payment method is not active.%1$s Please contact %2$s for assistance and provide a description of the problem.', |
|
| 974 | + 'event_espresso' |
|
| 975 | + ), |
|
| 976 | + '<br>', |
|
| 977 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 978 | + ) |
|
| 979 | + ), |
|
| 980 | + __FILE__, |
|
| 981 | + __FUNCTION__, |
|
| 982 | + __LINE__ |
|
| 983 | + ); |
|
| 984 | + } |
|
| 985 | + // switch up header depending on number of available payment methods |
|
| 986 | + $payment_method_header = count($this->checkout->available_payment_methods) > 1 |
|
| 987 | + ? apply_filters( |
|
| 988 | + 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
|
| 989 | + esc_html__('Please Select Your Method of Payment', 'event_espresso') |
|
| 990 | + ) |
|
| 991 | + : apply_filters( |
|
| 992 | + 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
|
| 993 | + esc_html__('Method of Payment', 'event_espresso') |
|
| 994 | + ); |
|
| 995 | + $available_payment_methods = array( |
|
| 996 | + // display the "Payment Method" header |
|
| 997 | + 'payment_method_header' => new EE_Form_Section_HTML( |
|
| 998 | + apply_filters( |
|
| 999 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options___setup_payment_options__payment_method_header', |
|
| 1000 | + EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr'), |
|
| 1001 | + $payment_method_header |
|
| 1002 | + ) |
|
| 1003 | + ), |
|
| 1004 | + ); |
|
| 1005 | + // the list of actual payment methods ( invoice, paypal, etc ) in a ( slug => HTML ) format |
|
| 1006 | + $available_payment_method_options = array(); |
|
| 1007 | + $default_payment_method_option = array(); |
|
| 1008 | + // additional instructions to be displayed and hidden below payment methods (adding a clearing div to start) |
|
| 1009 | + $payment_methods_billing_info = array( |
|
| 1010 | + new EE_Form_Section_HTML( |
|
| 1011 | + EEH_HTML::div('<br />', '', '', 'clear:both;') |
|
| 1012 | + ), |
|
| 1013 | + ); |
|
| 1014 | + // loop through payment methods |
|
| 1015 | + foreach ($this->checkout->available_payment_methods as $payment_method) { |
|
| 1016 | + if ($payment_method instanceof EE_Payment_Method) { |
|
| 1017 | + $payment_method_button = EEH_HTML::img( |
|
| 1018 | + $payment_method->button_url(), |
|
| 1019 | + $payment_method->name(), |
|
| 1020 | + 'spco-payment-method-' . $payment_method->slug() . '-btn-img', |
|
| 1021 | + 'spco-payment-method-btn-img' |
|
| 1022 | + ); |
|
| 1023 | + // check if any payment methods are set as default |
|
| 1024 | + // if payment method is already selected OR nothing is selected and this payment method should be |
|
| 1025 | + // open_by_default |
|
| 1026 | + if (($this->checkout->selected_method_of_payment === $payment_method->slug()) |
|
| 1027 | + || (! $this->checkout->selected_method_of_payment && $payment_method->open_by_default()) |
|
| 1028 | + ) { |
|
| 1029 | + $this->checkout->selected_method_of_payment = $payment_method->slug(); |
|
| 1030 | + $this->_save_selected_method_of_payment(); |
|
| 1031 | + $default_payment_method_option[ $payment_method->slug() ] = $payment_method_button; |
|
| 1032 | + } else { |
|
| 1033 | + $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
|
| 1034 | + } |
|
| 1035 | + $payment_methods_billing_info[ $payment_method->slug( |
|
| 1036 | + ) . '-info' ] = $this->_payment_method_billing_info( |
|
| 1037 | + $payment_method |
|
| 1038 | + ); |
|
| 1039 | + } |
|
| 1040 | + } |
|
| 1041 | + // prepend available_payment_method_options with default_payment_method_option so that it appears first in list |
|
| 1042 | + // of PMs |
|
| 1043 | + $available_payment_method_options = $default_payment_method_option + $available_payment_method_options; |
|
| 1044 | + // now generate the actual form inputs |
|
| 1045 | + $available_payment_methods['available_payment_methods'] = $this->_available_payment_method_inputs( |
|
| 1046 | + $available_payment_method_options |
|
| 1047 | + ); |
|
| 1048 | + $available_payment_methods += $payment_methods_billing_info; |
|
| 1049 | + // build the available payment methods form |
|
| 1050 | + return new EE_Form_Section_Proper( |
|
| 1051 | + array( |
|
| 1052 | + 'html_id' => 'spco-available-methods-of-payment-dv', |
|
| 1053 | + 'subsections' => $available_payment_methods, |
|
| 1054 | + 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
| 1055 | + ) |
|
| 1056 | + ); |
|
| 1057 | + } |
|
| 1058 | + |
|
| 1059 | + |
|
| 1060 | + /** |
|
| 1061 | + * _get_available_payment_methods |
|
| 1062 | + * |
|
| 1063 | + * @return EE_Payment_Method[] |
|
| 1064 | + * @throws EE_Error |
|
| 1065 | + * @throws InvalidArgumentException |
|
| 1066 | + * @throws ReflectionException |
|
| 1067 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1068 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1069 | + */ |
|
| 1070 | + protected function _get_available_payment_methods() |
|
| 1071 | + { |
|
| 1072 | + if (! empty($this->checkout->available_payment_methods)) { |
|
| 1073 | + return $this->checkout->available_payment_methods; |
|
| 1074 | + } |
|
| 1075 | + $available_payment_methods = array(); |
|
| 1076 | + // load EEM_Payment_Method |
|
| 1077 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
| 1078 | + /** @type EEM_Payment_Method $EEM_Payment_Method */ |
|
| 1079 | + $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
|
| 1080 | + // get all active payment methods |
|
| 1081 | + $payment_methods = $EEM_Payment_Method->get_all_for_transaction( |
|
| 1082 | + $this->checkout->transaction, |
|
| 1083 | + EEM_Payment_Method::scope_cart |
|
| 1084 | + ); |
|
| 1085 | + foreach ($payment_methods as $payment_method) { |
|
| 1086 | + if ($payment_method instanceof EE_Payment_Method) { |
|
| 1087 | + $available_payment_methods[ $payment_method->slug() ] = $payment_method; |
|
| 1088 | + } |
|
| 1089 | + } |
|
| 1090 | + return $available_payment_methods; |
|
| 1091 | + } |
|
| 1092 | + |
|
| 1093 | + |
|
| 1094 | + /** |
|
| 1095 | + * _available_payment_method_inputs |
|
| 1096 | + * |
|
| 1097 | + * @access private |
|
| 1098 | + * @param array $available_payment_method_options |
|
| 1099 | + * @return \EE_Form_Section_Proper |
|
| 1100 | + */ |
|
| 1101 | + private function _available_payment_method_inputs($available_payment_method_options = array()) |
|
| 1102 | + { |
|
| 1103 | + // generate inputs |
|
| 1104 | + return new EE_Form_Section_Proper( |
|
| 1105 | + array( |
|
| 1106 | + 'html_id' => 'ee-available-payment-method-inputs', |
|
| 1107 | + 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
| 1108 | + 'subsections' => array( |
|
| 1109 | + '' => new EE_Radio_Button_Input( |
|
| 1110 | + $available_payment_method_options, |
|
| 1111 | + array( |
|
| 1112 | + 'html_name' => 'selected_method_of_payment', |
|
| 1113 | + 'html_class' => 'spco-payment-method', |
|
| 1114 | + 'default' => $this->checkout->selected_method_of_payment, |
|
| 1115 | + 'label_size' => 11, |
|
| 1116 | + 'enforce_label_size' => true, |
|
| 1117 | + ) |
|
| 1118 | + ), |
|
| 1119 | + ), |
|
| 1120 | + ) |
|
| 1121 | + ); |
|
| 1122 | + } |
|
| 1123 | + |
|
| 1124 | + |
|
| 1125 | + /** |
|
| 1126 | + * _payment_method_billing_info |
|
| 1127 | + * |
|
| 1128 | + * @access private |
|
| 1129 | + * @param EE_Payment_Method $payment_method |
|
| 1130 | + * @return EE_Form_Section_Proper |
|
| 1131 | + * @throws EE_Error |
|
| 1132 | + * @throws InvalidArgumentException |
|
| 1133 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1134 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1135 | + */ |
|
| 1136 | + private function _payment_method_billing_info(EE_Payment_Method $payment_method) |
|
| 1137 | + { |
|
| 1138 | + $currently_selected = $this->checkout->selected_method_of_payment === $payment_method->slug() |
|
| 1139 | + ? true |
|
| 1140 | + : false; |
|
| 1141 | + // generate the billing form for payment method |
|
| 1142 | + $billing_form = $currently_selected |
|
| 1143 | + ? $this->_get_billing_form_for_payment_method($payment_method) |
|
| 1144 | + : new EE_Form_Section_HTML(); |
|
| 1145 | + $this->checkout->billing_form = $currently_selected |
|
| 1146 | + ? $billing_form |
|
| 1147 | + : $this->checkout->billing_form; |
|
| 1148 | + // it's all in the details |
|
| 1149 | + $info_html = EEH_HTML::h3( |
|
| 1150 | + esc_html__('Important information regarding your payment', 'event_espresso'), |
|
| 1151 | + '', |
|
| 1152 | + 'spco-payment-method-hdr' |
|
| 1153 | + ); |
|
| 1154 | + // add some info regarding the step, either from what's saved in the admin, |
|
| 1155 | + // or a default string depending on whether the PM has a billing form or not |
|
| 1156 | + if ($payment_method->description()) { |
|
| 1157 | + $payment_method_info = $payment_method->description(); |
|
| 1158 | + } elseif ($billing_form instanceof EE_Billing_Info_Form) { |
|
| 1159 | + $payment_method_info = sprintf( |
|
| 1160 | + esc_html__( |
|
| 1161 | + 'Please provide the following billing information, then click the "%1$s" button below in order to proceed.', |
|
| 1162 | + 'event_espresso' |
|
| 1163 | + ), |
|
| 1164 | + $this->submit_button_text() |
|
| 1165 | + ); |
|
| 1166 | + } else { |
|
| 1167 | + $payment_method_info = sprintf( |
|
| 1168 | + esc_html__('Please click the "%1$s" button below in order to proceed.', 'event_espresso'), |
|
| 1169 | + $this->submit_button_text() |
|
| 1170 | + ); |
|
| 1171 | + } |
|
| 1172 | + $info_html .= EEH_HTML::div( |
|
| 1173 | + apply_filters( |
|
| 1174 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options___payment_method_billing_info__payment_method_info', |
|
| 1175 | + $payment_method_info |
|
| 1176 | + ), |
|
| 1177 | + '', |
|
| 1178 | + 'spco-payment-method-desc ee-attention' |
|
| 1179 | + ); |
|
| 1180 | + return new EE_Form_Section_Proper( |
|
| 1181 | + array( |
|
| 1182 | + 'html_id' => 'spco-payment-method-info-' . $payment_method->slug(), |
|
| 1183 | + 'html_class' => 'spco-payment-method-info-dv', |
|
| 1184 | + // only display the selected or default PM |
|
| 1185 | + 'html_style' => $currently_selected ? '' : 'display:none;', |
|
| 1186 | + 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
| 1187 | + 'subsections' => array( |
|
| 1188 | + 'info' => new EE_Form_Section_HTML($info_html), |
|
| 1189 | + 'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML(), |
|
| 1190 | + ), |
|
| 1191 | + ) |
|
| 1192 | + ); |
|
| 1193 | + } |
|
| 1194 | + |
|
| 1195 | + |
|
| 1196 | + /** |
|
| 1197 | + * get_billing_form_html_for_payment_method |
|
| 1198 | + * |
|
| 1199 | + * @access public |
|
| 1200 | + * @return string |
|
| 1201 | + * @throws EE_Error |
|
| 1202 | + * @throws InvalidArgumentException |
|
| 1203 | + * @throws ReflectionException |
|
| 1204 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1205 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1206 | + */ |
|
| 1207 | + public function get_billing_form_html_for_payment_method() |
|
| 1208 | + { |
|
| 1209 | + // how have they chosen to pay? |
|
| 1210 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
| 1211 | + $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
|
| 1212 | + if (! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
| 1213 | + return false; |
|
| 1214 | + } |
|
| 1215 | + if (apply_filters( |
|
| 1216 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
|
| 1217 | + false |
|
| 1218 | + )) { |
|
| 1219 | + EE_Error::add_success( |
|
| 1220 | + apply_filters( |
|
| 1221 | + 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
|
| 1222 | + sprintf( |
|
| 1223 | + esc_html__( |
|
| 1224 | + 'You have selected "%s" as your method of payment. Please note the important payment information below.', |
|
| 1225 | + 'event_espresso' |
|
| 1226 | + ), |
|
| 1227 | + $this->checkout->payment_method->name() |
|
| 1228 | + ) |
|
| 1229 | + ) |
|
| 1230 | + ); |
|
| 1231 | + } |
|
| 1232 | + // now generate billing form for selected method of payment |
|
| 1233 | + $payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
| 1234 | + // fill form with attendee info if applicable |
|
| 1235 | + if ($payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form |
|
| 1236 | + && $this->checkout->transaction_has_primary_registrant() |
|
| 1237 | + ) { |
|
| 1238 | + $payment_method_billing_form->populate_from_attendee( |
|
| 1239 | + $this->checkout->transaction->primary_registration()->attendee() |
|
| 1240 | + ); |
|
| 1241 | + } |
|
| 1242 | + // and debug content |
|
| 1243 | + if ($payment_method_billing_form instanceof EE_Billing_Info_Form |
|
| 1244 | + && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
| 1245 | + ) { |
|
| 1246 | + $payment_method_billing_form = |
|
| 1247 | + $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
|
| 1248 | + $payment_method_billing_form |
|
| 1249 | + ); |
|
| 1250 | + } |
|
| 1251 | + $billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper |
|
| 1252 | + ? $payment_method_billing_form->get_html() |
|
| 1253 | + : ''; |
|
| 1254 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info)); |
|
| 1255 | + // localize validation rules for main form |
|
| 1256 | + $this->checkout->current_step->reg_form->localize_validation_rules(); |
|
| 1257 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
| 1258 | + return true; |
|
| 1259 | + } |
|
| 1260 | + |
|
| 1261 | + |
|
| 1262 | + /** |
|
| 1263 | + * _get_billing_form_for_payment_method |
|
| 1264 | + * |
|
| 1265 | + * @access private |
|
| 1266 | + * @param EE_Payment_Method $payment_method |
|
| 1267 | + * @return EE_Billing_Info_Form|EE_Form_Section_HTML |
|
| 1268 | + * @throws EE_Error |
|
| 1269 | + * @throws InvalidArgumentException |
|
| 1270 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1271 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1272 | + */ |
|
| 1273 | + private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method) |
|
| 1274 | + { |
|
| 1275 | + $billing_form = $payment_method->type_obj()->billing_form( |
|
| 1276 | + $this->checkout->transaction, |
|
| 1277 | + array('amount_owing' => $this->checkout->amount_owing) |
|
| 1278 | + ); |
|
| 1279 | + if ($billing_form instanceof EE_Billing_Info_Form) { |
|
| 1280 | + if (apply_filters( |
|
| 1281 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
|
| 1282 | + false |
|
| 1283 | + ) |
|
| 1284 | + && EE_Registry::instance()->REQ->is_set('payment_method') |
|
| 1285 | + ) { |
|
| 1286 | + EE_Error::add_success( |
|
| 1287 | + apply_filters( |
|
| 1288 | + 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
|
| 1289 | + sprintf( |
|
| 1290 | + esc_html__( |
|
| 1291 | + 'You have selected "%s" as your method of payment. Please note the important payment information below.', |
|
| 1292 | + 'event_espresso' |
|
| 1293 | + ), |
|
| 1294 | + $payment_method->name() |
|
| 1295 | + ) |
|
| 1296 | + ) |
|
| 1297 | + ); |
|
| 1298 | + } |
|
| 1299 | + return apply_filters( |
|
| 1300 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', |
|
| 1301 | + $billing_form, |
|
| 1302 | + $payment_method |
|
| 1303 | + ); |
|
| 1304 | + } |
|
| 1305 | + // no actual billing form, so return empty HTML form section |
|
| 1306 | + return new EE_Form_Section_HTML(); |
|
| 1307 | + } |
|
| 1308 | + |
|
| 1309 | + |
|
| 1310 | + /** |
|
| 1311 | + * _get_selected_method_of_payment |
|
| 1312 | + * |
|
| 1313 | + * @access private |
|
| 1314 | + * @param boolean $required whether to throw an error if the "selected_method_of_payment" |
|
| 1315 | + * is not found in the incoming request |
|
| 1316 | + * @param string $request_param |
|
| 1317 | + * @return NULL|string |
|
| 1318 | + * @throws EE_Error |
|
| 1319 | + * @throws InvalidArgumentException |
|
| 1320 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1321 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1322 | + */ |
|
| 1323 | + private function _get_selected_method_of_payment( |
|
| 1324 | + $required = false, |
|
| 1325 | + $request_param = 'selected_method_of_payment' |
|
| 1326 | + ) { |
|
| 1327 | + // is selected_method_of_payment set in the request ? |
|
| 1328 | + $selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, false); |
|
| 1329 | + if ($selected_method_of_payment) { |
|
| 1330 | + // sanitize it |
|
| 1331 | + $selected_method_of_payment = is_array($selected_method_of_payment) |
|
| 1332 | + ? array_shift($selected_method_of_payment) |
|
| 1333 | + : $selected_method_of_payment; |
|
| 1334 | + $selected_method_of_payment = sanitize_text_field($selected_method_of_payment); |
|
| 1335 | + // store it in the session so that it's available for all subsequent requests including AJAX |
|
| 1336 | + $this->_save_selected_method_of_payment($selected_method_of_payment); |
|
| 1337 | + } else { |
|
| 1338 | + // or is is set in the session ? |
|
| 1339 | + $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data( |
|
| 1340 | + 'selected_method_of_payment' |
|
| 1341 | + ); |
|
| 1342 | + } |
|
| 1343 | + // do ya really really gotta have it? |
|
| 1344 | + if (empty($selected_method_of_payment) && $required) { |
|
| 1345 | + EE_Error::add_error( |
|
| 1346 | + sprintf( |
|
| 1347 | + esc_html__( |
|
| 1348 | + 'The selected method of payment could not be determined.%sPlease ensure that you have selected one before proceeding.%sIf you continue to experience difficulties, then refresh your browser and try again, or contact %s for assistance.', |
|
| 1349 | + 'event_espresso' |
|
| 1350 | + ), |
|
| 1351 | + '<br/>', |
|
| 1352 | + '<br/>', |
|
| 1353 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 1354 | + ), |
|
| 1355 | + __FILE__, |
|
| 1356 | + __FUNCTION__, |
|
| 1357 | + __LINE__ |
|
| 1358 | + ); |
|
| 1359 | + return null; |
|
| 1360 | + } |
|
| 1361 | + return $selected_method_of_payment; |
|
| 1362 | + } |
|
| 1363 | + |
|
| 1364 | + |
|
| 1365 | + |
|
| 1366 | + |
|
| 1367 | + |
|
| 1368 | + |
|
| 1369 | + /********************************************************************************************************/ |
|
| 1370 | + /*********************************** SWITCH PAYMENT METHOD ************************************/ |
|
| 1371 | + /********************************************************************************************************/ |
|
| 1372 | + /** |
|
| 1373 | + * switch_payment_method |
|
| 1374 | + * |
|
| 1375 | + * @access public |
|
| 1376 | + * @return string |
|
| 1377 | + * @throws EE_Error |
|
| 1378 | + * @throws InvalidArgumentException |
|
| 1379 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1380 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1381 | + */ |
|
| 1382 | + public function switch_payment_method() |
|
| 1383 | + { |
|
| 1384 | + if (! $this->_verify_payment_method_is_set()) { |
|
| 1385 | + return false; |
|
| 1386 | + } |
|
| 1387 | + if (apply_filters( |
|
| 1388 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
|
| 1389 | + false |
|
| 1390 | + )) { |
|
| 1391 | + EE_Error::add_success( |
|
| 1392 | + apply_filters( |
|
| 1393 | + 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
|
| 1394 | + sprintf( |
|
| 1395 | + esc_html__( |
|
| 1396 | + 'You have selected "%s" as your method of payment. Please note the important payment information below.', |
|
| 1397 | + 'event_espresso' |
|
| 1398 | + ), |
|
| 1399 | + $this->checkout->payment_method->name() |
|
| 1400 | + ) |
|
| 1401 | + ) |
|
| 1402 | + ); |
|
| 1403 | + } |
|
| 1404 | + // generate billing form for selected method of payment if it hasn't been done already |
|
| 1405 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
| 1406 | + $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
|
| 1407 | + $this->checkout->payment_method |
|
| 1408 | + ); |
|
| 1409 | + } |
|
| 1410 | + // fill form with attendee info if applicable |
|
| 1411 | + if (apply_filters( |
|
| 1412 | + 'FHEE__populate_billing_form_fields_from_attendee', |
|
| 1413 | + ( |
|
| 1414 | + $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form |
|
| 1415 | + && $this->checkout->transaction_has_primary_registrant() |
|
| 1416 | + ), |
|
| 1417 | + $this->checkout->billing_form, |
|
| 1418 | + $this->checkout->transaction |
|
| 1419 | + ) |
|
| 1420 | + ) { |
|
| 1421 | + $this->checkout->billing_form->populate_from_attendee( |
|
| 1422 | + $this->checkout->transaction->primary_registration()->attendee() |
|
| 1423 | + ); |
|
| 1424 | + } |
|
| 1425 | + // and debug content |
|
| 1426 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form |
|
| 1427 | + && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
| 1428 | + ) { |
|
| 1429 | + $this->checkout->billing_form = |
|
| 1430 | + $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
|
| 1431 | + $this->checkout->billing_form |
|
| 1432 | + ); |
|
| 1433 | + } |
|
| 1434 | + // get html and validation rules for form |
|
| 1435 | + if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) { |
|
| 1436 | + $this->checkout->json_response->set_return_data( |
|
| 1437 | + array('payment_method_info' => $this->checkout->billing_form->get_html()) |
|
| 1438 | + ); |
|
| 1439 | + // localize validation rules for main form |
|
| 1440 | + $this->checkout->billing_form->localize_validation_rules(true); |
|
| 1441 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
| 1442 | + } else { |
|
| 1443 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => '')); |
|
| 1444 | + } |
|
| 1445 | + // prevents advancement to next step |
|
| 1446 | + $this->checkout->continue_reg = false; |
|
| 1447 | + return true; |
|
| 1448 | + } |
|
| 1449 | + |
|
| 1450 | + |
|
| 1451 | + /** |
|
| 1452 | + * _verify_payment_method_is_set |
|
| 1453 | + * |
|
| 1454 | + * @return bool |
|
| 1455 | + * @throws EE_Error |
|
| 1456 | + * @throws InvalidArgumentException |
|
| 1457 | + * @throws ReflectionException |
|
| 1458 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1459 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1460 | + */ |
|
| 1461 | + protected function _verify_payment_method_is_set() |
|
| 1462 | + { |
|
| 1463 | + // generate billing form for selected method of payment if it hasn't been done already |
|
| 1464 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
| 1465 | + // how have they chosen to pay? |
|
| 1466 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
| 1467 | + } else { |
|
| 1468 | + // choose your own adventure based on method_of_payment |
|
| 1469 | + switch ($this->checkout->selected_method_of_payment) { |
|
| 1470 | + case 'events_sold_out': |
|
| 1471 | + EE_Error::add_attention( |
|
| 1472 | + apply_filters( |
|
| 1473 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__sold_out_events_msg', |
|
| 1474 | + esc_html__( |
|
| 1475 | + 'It appears that the event you were about to make a payment for has sold out since this form first loaded. Please contact the event administrator if you believe this is an error.', |
|
| 1476 | + 'event_espresso' |
|
| 1477 | + ) |
|
| 1478 | + ), |
|
| 1479 | + __FILE__, |
|
| 1480 | + __FUNCTION__, |
|
| 1481 | + __LINE__ |
|
| 1482 | + ); |
|
| 1483 | + return false; |
|
| 1484 | + break; |
|
| 1485 | + case 'payments_closed': |
|
| 1486 | + EE_Error::add_attention( |
|
| 1487 | + apply_filters( |
|
| 1488 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__payments_closed_msg', |
|
| 1489 | + esc_html__( |
|
| 1490 | + 'It appears that the event you were about to make a payment for is not accepting payments at this time. Please contact the event administrator if you believe this is an error.', |
|
| 1491 | + 'event_espresso' |
|
| 1492 | + ) |
|
| 1493 | + ), |
|
| 1494 | + __FILE__, |
|
| 1495 | + __FUNCTION__, |
|
| 1496 | + __LINE__ |
|
| 1497 | + ); |
|
| 1498 | + return false; |
|
| 1499 | + break; |
|
| 1500 | + case 'no_payment_required': |
|
| 1501 | + EE_Error::add_attention( |
|
| 1502 | + apply_filters( |
|
| 1503 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__no_payment_required_msg', |
|
| 1504 | + esc_html__( |
|
| 1505 | + 'It appears that the event you were about to make a payment for does not require payment. Please contact the event administrator if you believe this is an error.', |
|
| 1506 | + 'event_espresso' |
|
| 1507 | + ) |
|
| 1508 | + ), |
|
| 1509 | + __FILE__, |
|
| 1510 | + __FUNCTION__, |
|
| 1511 | + __LINE__ |
|
| 1512 | + ); |
|
| 1513 | + return false; |
|
| 1514 | + break; |
|
| 1515 | + default: |
|
| 1516 | + } |
|
| 1517 | + } |
|
| 1518 | + // verify payment method |
|
| 1519 | + if (! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
| 1520 | + // get payment method for selected method of payment |
|
| 1521 | + $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
|
| 1522 | + } |
|
| 1523 | + return $this->checkout->payment_method instanceof EE_Payment_Method ? true : false; |
|
| 1524 | + } |
|
| 1525 | + |
|
| 1526 | + |
|
| 1527 | + |
|
| 1528 | + /********************************************************************************************************/ |
|
| 1529 | + /*************************************** SAVE PAYER DETAILS ****************************************/ |
|
| 1530 | + /********************************************************************************************************/ |
|
| 1531 | + /** |
|
| 1532 | + * save_payer_details_via_ajax |
|
| 1533 | + * |
|
| 1534 | + * @return void |
|
| 1535 | + * @throws EE_Error |
|
| 1536 | + * @throws InvalidArgumentException |
|
| 1537 | + * @throws ReflectionException |
|
| 1538 | + * @throws RuntimeException |
|
| 1539 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1540 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1541 | + */ |
|
| 1542 | + public function save_payer_details_via_ajax() |
|
| 1543 | + { |
|
| 1544 | + if (! $this->_verify_payment_method_is_set()) { |
|
| 1545 | + return; |
|
| 1546 | + } |
|
| 1547 | + // generate billing form for selected method of payment if it hasn't been done already |
|
| 1548 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
| 1549 | + $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
|
| 1550 | + $this->checkout->payment_method |
|
| 1551 | + ); |
|
| 1552 | + } |
|
| 1553 | + // generate primary attendee from payer info if applicable |
|
| 1554 | + if (! $this->checkout->transaction_has_primary_registrant()) { |
|
| 1555 | + $attendee = $this->_create_attendee_from_request_data(); |
|
| 1556 | + if ($attendee instanceof EE_Attendee) { |
|
| 1557 | + foreach ($this->checkout->transaction->registrations() as $registration) { |
|
| 1558 | + if ($registration->is_primary_registrant()) { |
|
| 1559 | + $this->checkout->primary_attendee_obj = $attendee; |
|
| 1560 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
| 1561 | + $registration->set_attendee_id($attendee->ID()); |
|
| 1562 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
| 1563 | + } |
|
| 1564 | + } |
|
| 1565 | + } |
|
| 1566 | + } |
|
| 1567 | + } |
|
| 1568 | + |
|
| 1569 | + |
|
| 1570 | + /** |
|
| 1571 | + * create_attendee_from_request_data |
|
| 1572 | + * uses info from alternate GET or POST data (such as AJAX) to create a new attendee |
|
| 1573 | + * |
|
| 1574 | + * @return EE_Attendee |
|
| 1575 | + * @throws EE_Error |
|
| 1576 | + * @throws InvalidArgumentException |
|
| 1577 | + * @throws ReflectionException |
|
| 1578 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1579 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1580 | + */ |
|
| 1581 | + protected function _create_attendee_from_request_data() |
|
| 1582 | + { |
|
| 1583 | + // get State ID |
|
| 1584 | + $STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : ''; |
|
| 1585 | + if (! empty($STA_ID)) { |
|
| 1586 | + // can we get state object from name ? |
|
| 1587 | + EE_Registry::instance()->load_model('State'); |
|
| 1588 | + $state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID'); |
|
| 1589 | + $STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID; |
|
| 1590 | + } |
|
| 1591 | + // get Country ISO |
|
| 1592 | + $CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : ''; |
|
| 1593 | + if (! empty($CNT_ISO)) { |
|
| 1594 | + // can we get country object from name ? |
|
| 1595 | + EE_Registry::instance()->load_model('Country'); |
|
| 1596 | + $country = EEM_Country::instance()->get_col( |
|
| 1597 | + array(array('CNT_name' => $CNT_ISO), 'limit' => 1), |
|
| 1598 | + 'CNT_ISO' |
|
| 1599 | + ); |
|
| 1600 | + $CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO; |
|
| 1601 | + } |
|
| 1602 | + // grab attendee data |
|
| 1603 | + $attendee_data = array( |
|
| 1604 | + 'ATT_fname' => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '', |
|
| 1605 | + 'ATT_lname' => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '', |
|
| 1606 | + 'ATT_email' => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '', |
|
| 1607 | + 'ATT_address' => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '', |
|
| 1608 | + 'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '', |
|
| 1609 | + 'ATT_city' => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '', |
|
| 1610 | + 'STA_ID' => $STA_ID, |
|
| 1611 | + 'CNT_ISO' => $CNT_ISO, |
|
| 1612 | + 'ATT_zip' => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '', |
|
| 1613 | + 'ATT_phone' => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '', |
|
| 1614 | + ); |
|
| 1615 | + // validate the email address since it is the most important piece of info |
|
| 1616 | + if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] !== $_REQUEST['email']) { |
|
| 1617 | + EE_Error::add_error( |
|
| 1618 | + esc_html__('An invalid email address was submitted.', 'event_espresso'), |
|
| 1619 | + __FILE__, |
|
| 1620 | + __FUNCTION__, |
|
| 1621 | + __LINE__ |
|
| 1622 | + ); |
|
| 1623 | + } |
|
| 1624 | + // does this attendee already exist in the db ? we're searching using a combination of first name, last name, |
|
| 1625 | + // AND email address |
|
| 1626 | + if (! empty($attendee_data['ATT_fname']) |
|
| 1627 | + && ! empty($attendee_data['ATT_lname']) |
|
| 1628 | + && ! empty($attendee_data['ATT_email']) |
|
| 1629 | + ) { |
|
| 1630 | + $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( |
|
| 1631 | + array( |
|
| 1632 | + 'ATT_fname' => $attendee_data['ATT_fname'], |
|
| 1633 | + 'ATT_lname' => $attendee_data['ATT_lname'], |
|
| 1634 | + 'ATT_email' => $attendee_data['ATT_email'], |
|
| 1635 | + ) |
|
| 1636 | + ); |
|
| 1637 | + if ($existing_attendee instanceof EE_Attendee) { |
|
| 1638 | + return $existing_attendee; |
|
| 1639 | + } |
|
| 1640 | + } |
|
| 1641 | + // no existing attendee? kk let's create a new one |
|
| 1642 | + // kinda lame, but we need a first and last name to create an attendee, so use the email address if those |
|
| 1643 | + // don't exist |
|
| 1644 | + $attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname']) |
|
| 1645 | + ? $attendee_data['ATT_fname'] |
|
| 1646 | + : $attendee_data['ATT_email']; |
|
| 1647 | + $attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname']) |
|
| 1648 | + ? $attendee_data['ATT_lname'] |
|
| 1649 | + : $attendee_data['ATT_email']; |
|
| 1650 | + return EE_Attendee::new_instance($attendee_data); |
|
| 1651 | + } |
|
| 1652 | + |
|
| 1653 | + |
|
| 1654 | + |
|
| 1655 | + /********************************************************************************************************/ |
|
| 1656 | + /**************************************** PROCESS REG STEP *****************************************/ |
|
| 1657 | + /********************************************************************************************************/ |
|
| 1658 | + /** |
|
| 1659 | + * process_reg_step |
|
| 1660 | + * |
|
| 1661 | + * @return bool |
|
| 1662 | + * @throws EE_Error |
|
| 1663 | + * @throws InvalidArgumentException |
|
| 1664 | + * @throws ReflectionException |
|
| 1665 | + * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 1666 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1667 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1668 | + * @throws \EventEspresso\core\exceptions\InvalidStatusException |
|
| 1669 | + */ |
|
| 1670 | + public function process_reg_step() |
|
| 1671 | + { |
|
| 1672 | + // how have they chosen to pay? |
|
| 1673 | + $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() |
|
| 1674 | + ? 'no_payment_required' |
|
| 1675 | + : $this->_get_selected_method_of_payment(true); |
|
| 1676 | + // choose your own adventure based on method_of_payment |
|
| 1677 | + switch ($this->checkout->selected_method_of_payment) { |
|
| 1678 | + case 'events_sold_out': |
|
| 1679 | + $this->checkout->redirect = true; |
|
| 1680 | + $this->checkout->redirect_url = $this->checkout->cancel_page_url; |
|
| 1681 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
| 1682 | + // mark this reg step as completed |
|
| 1683 | + $this->set_completed(); |
|
| 1684 | + return false; |
|
| 1685 | + break; |
|
| 1686 | + |
|
| 1687 | + case 'payments_closed': |
|
| 1688 | + if (apply_filters( |
|
| 1689 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', |
|
| 1690 | + false |
|
| 1691 | + )) { |
|
| 1692 | + EE_Error::add_success( |
|
| 1693 | + esc_html__('no payment required at this time.', 'event_espresso'), |
|
| 1694 | + __FILE__, |
|
| 1695 | + __FUNCTION__, |
|
| 1696 | + __LINE__ |
|
| 1697 | + ); |
|
| 1698 | + } |
|
| 1699 | + // mark this reg step as completed |
|
| 1700 | + $this->set_completed(); |
|
| 1701 | + return true; |
|
| 1702 | + break; |
|
| 1703 | + |
|
| 1704 | + case 'no_payment_required': |
|
| 1705 | + if (apply_filters( |
|
| 1706 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', |
|
| 1707 | + false |
|
| 1708 | + )) { |
|
| 1709 | + EE_Error::add_success( |
|
| 1710 | + esc_html__('no payment required.', 'event_espresso'), |
|
| 1711 | + __FILE__, |
|
| 1712 | + __FUNCTION__, |
|
| 1713 | + __LINE__ |
|
| 1714 | + ); |
|
| 1715 | + } |
|
| 1716 | + // mark this reg step as completed |
|
| 1717 | + $this->set_completed(); |
|
| 1718 | + return true; |
|
| 1719 | + break; |
|
| 1720 | + |
|
| 1721 | + default: |
|
| 1722 | + $registrations = EE_Registry::instance()->SSN->checkout()->transaction->registrations( |
|
| 1723 | + EE_Registry::instance()->SSN->checkout()->reg_cache_where_params |
|
| 1724 | + ); |
|
| 1725 | + $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space( |
|
| 1726 | + $registrations, |
|
| 1727 | + EE_Registry::instance()->SSN->checkout()->revisit |
|
| 1728 | + ); |
|
| 1729 | + // calculate difference between the two arrays |
|
| 1730 | + $registrations = array_diff($registrations, $ejected_registrations); |
|
| 1731 | + if (empty($registrations)) { |
|
| 1732 | + $this->_redirect_because_event_sold_out(); |
|
| 1733 | + return false; |
|
| 1734 | + } |
|
| 1735 | + $payment_successful = $this->_process_payment(); |
|
| 1736 | + if ($payment_successful) { |
|
| 1737 | + $this->checkout->continue_reg = true; |
|
| 1738 | + $this->_maybe_set_completed($this->checkout->payment_method); |
|
| 1739 | + } else { |
|
| 1740 | + $this->checkout->continue_reg = false; |
|
| 1741 | + } |
|
| 1742 | + return $payment_successful; |
|
| 1743 | + } |
|
| 1744 | + } |
|
| 1745 | + |
|
| 1746 | + |
|
| 1747 | + /** |
|
| 1748 | + * _redirect_because_event_sold_out |
|
| 1749 | + * |
|
| 1750 | + * @access protected |
|
| 1751 | + * @return void |
|
| 1752 | + */ |
|
| 1753 | + protected function _redirect_because_event_sold_out() |
|
| 1754 | + { |
|
| 1755 | + $this->checkout->continue_reg = false; |
|
| 1756 | + // set redirect URL |
|
| 1757 | + $this->checkout->redirect_url = add_query_arg( |
|
| 1758 | + array('e_reg_url_link' => $this->checkout->reg_url_link), |
|
| 1759 | + $this->checkout->current_step->reg_step_url() |
|
| 1760 | + ); |
|
| 1761 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
| 1762 | + } |
|
| 1763 | + |
|
| 1764 | + |
|
| 1765 | + /** |
|
| 1766 | + * _maybe_set_completed |
|
| 1767 | + * |
|
| 1768 | + * @access protected |
|
| 1769 | + * @param \EE_Payment_Method $payment_method |
|
| 1770 | + * @return void |
|
| 1771 | + * @throws \EE_Error |
|
| 1772 | + */ |
|
| 1773 | + protected function _maybe_set_completed(EE_Payment_Method $payment_method) |
|
| 1774 | + { |
|
| 1775 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
| 1776 | + case EE_PMT_Base::offsite: |
|
| 1777 | + break; |
|
| 1778 | + case EE_PMT_Base::onsite: |
|
| 1779 | + case EE_PMT_Base::offline: |
|
| 1780 | + // mark this reg step as completed |
|
| 1781 | + $this->set_completed(); |
|
| 1782 | + break; |
|
| 1783 | + } |
|
| 1784 | + } |
|
| 1785 | + |
|
| 1786 | + |
|
| 1787 | + /** |
|
| 1788 | + * update_reg_step |
|
| 1789 | + * this is the final step after a user revisits the site to retry a payment |
|
| 1790 | + * |
|
| 1791 | + * @return bool |
|
| 1792 | + * @throws EE_Error |
|
| 1793 | + * @throws InvalidArgumentException |
|
| 1794 | + * @throws ReflectionException |
|
| 1795 | + * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 1796 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1797 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1798 | + * @throws \EventEspresso\core\exceptions\InvalidStatusException |
|
| 1799 | + */ |
|
| 1800 | + public function update_reg_step() |
|
| 1801 | + { |
|
| 1802 | + $success = true; |
|
| 1803 | + // if payment required |
|
| 1804 | + if ($this->checkout->transaction->total() > 0) { |
|
| 1805 | + do_action( |
|
| 1806 | + 'AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', |
|
| 1807 | + $this->checkout->transaction |
|
| 1808 | + ); |
|
| 1809 | + // attempt payment via payment method |
|
| 1810 | + $success = $this->process_reg_step(); |
|
| 1811 | + } |
|
| 1812 | + if ($success && ! $this->checkout->redirect) { |
|
| 1813 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( |
|
| 1814 | + $this->checkout->transaction->ID() |
|
| 1815 | + ); |
|
| 1816 | + // set return URL |
|
| 1817 | + $this->checkout->redirect_url = add_query_arg( |
|
| 1818 | + array('e_reg_url_link' => $this->checkout->reg_url_link), |
|
| 1819 | + $this->checkout->thank_you_page_url |
|
| 1820 | + ); |
|
| 1821 | + } |
|
| 1822 | + return $success; |
|
| 1823 | + } |
|
| 1824 | + |
|
| 1825 | + |
|
| 1826 | + /** |
|
| 1827 | + * _process_payment |
|
| 1828 | + * |
|
| 1829 | + * @access private |
|
| 1830 | + * @return bool |
|
| 1831 | + * @throws EE_Error |
|
| 1832 | + * @throws InvalidArgumentException |
|
| 1833 | + * @throws ReflectionException |
|
| 1834 | + * @throws RuntimeException |
|
| 1835 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1836 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1837 | + */ |
|
| 1838 | + private function _process_payment() |
|
| 1839 | + { |
|
| 1840 | + // basically confirm that the event hasn't sold out since they hit the page |
|
| 1841 | + if (! $this->_last_second_ticket_verifications()) { |
|
| 1842 | + return false; |
|
| 1843 | + } |
|
| 1844 | + // ya gotta make a choice man |
|
| 1845 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
| 1846 | + $this->checkout->json_response->set_plz_select_method_of_payment( |
|
| 1847 | + esc_html__('Please select a method of payment before proceeding.', 'event_espresso') |
|
| 1848 | + ); |
|
| 1849 | + return false; |
|
| 1850 | + } |
|
| 1851 | + // get EE_Payment_Method object |
|
| 1852 | + if (! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
| 1853 | + return false; |
|
| 1854 | + } |
|
| 1855 | + // setup billing form |
|
| 1856 | + if ($this->checkout->payment_method->is_on_site()) { |
|
| 1857 | + $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
|
| 1858 | + $this->checkout->payment_method |
|
| 1859 | + ); |
|
| 1860 | + // bad billing form ? |
|
| 1861 | + if (! $this->_billing_form_is_valid()) { |
|
| 1862 | + return false; |
|
| 1863 | + } |
|
| 1864 | + } |
|
| 1865 | + // ensure primary registrant has been fully processed |
|
| 1866 | + if (! $this->_setup_primary_registrant_prior_to_payment()) { |
|
| 1867 | + return false; |
|
| 1868 | + } |
|
| 1869 | + // if session is close to expiring (under 10 minutes by default) |
|
| 1870 | + if ((time() - EE_Registry::instance()->SSN->expiration()) < EE_Registry::instance()->SSN->extension()) { |
|
| 1871 | + // add some time to session expiration so that payment can be completed |
|
| 1872 | + EE_Registry::instance()->SSN->extend_expiration(); |
|
| 1873 | + } |
|
| 1874 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
| 1875 | + // $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
| 1876 | + // in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations |
|
| 1877 | + // for events with a default reg status of Approved |
|
| 1878 | + // $transaction_processor->toggle_registration_statuses_for_default_approved_events( |
|
| 1879 | + // $this->checkout->transaction, $this->checkout->reg_cache_where_params |
|
| 1880 | + // ); |
|
| 1881 | + // attempt payment |
|
| 1882 | + $payment = $this->_attempt_payment($this->checkout->payment_method); |
|
| 1883 | + // process results |
|
| 1884 | + $payment = $this->_validate_payment($payment); |
|
| 1885 | + $payment = $this->_post_payment_processing($payment); |
|
| 1886 | + // verify payment |
|
| 1887 | + if ($payment instanceof EE_Payment) { |
|
| 1888 | + // store that for later |
|
| 1889 | + $this->checkout->payment = $payment; |
|
| 1890 | + // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
|
| 1891 | + $this->checkout->transaction->toggle_failed_transaction_status(); |
|
| 1892 | + $payment_status = $payment->status(); |
|
| 1893 | + if ($payment_status === EEM_Payment::status_id_approved |
|
| 1894 | + || $payment_status === EEM_Payment::status_id_pending |
|
| 1895 | + ) { |
|
| 1896 | + return true; |
|
| 1897 | + } else { |
|
| 1898 | + return false; |
|
| 1899 | + } |
|
| 1900 | + } elseif ($payment === true) { |
|
| 1901 | + // please note that offline payment methods will NOT make a payment, |
|
| 1902 | + // but instead just mark themselves as the PMD_ID on the transaction, and return true |
|
| 1903 | + $this->checkout->payment = $payment; |
|
| 1904 | + return true; |
|
| 1905 | + } |
|
| 1906 | + // where's my money? |
|
| 1907 | + return false; |
|
| 1908 | + } |
|
| 1909 | + |
|
| 1910 | + |
|
| 1911 | + /** |
|
| 1912 | + * _last_second_ticket_verifications |
|
| 1913 | + * |
|
| 1914 | + * @access public |
|
| 1915 | + * @return bool |
|
| 1916 | + * @throws EE_Error |
|
| 1917 | + */ |
|
| 1918 | + protected function _last_second_ticket_verifications() |
|
| 1919 | + { |
|
| 1920 | + // don't bother re-validating if not a return visit |
|
| 1921 | + if (! $this->checkout->revisit) { |
|
| 1922 | + return true; |
|
| 1923 | + } |
|
| 1924 | + $registrations = $this->checkout->transaction->registrations(); |
|
| 1925 | + if (empty($registrations)) { |
|
| 1926 | + return false; |
|
| 1927 | + } |
|
| 1928 | + foreach ($registrations as $registration) { |
|
| 1929 | + if ($registration instanceof EE_Registration && ! $registration->is_approved()) { |
|
| 1930 | + $event = $registration->event_obj(); |
|
| 1931 | + if ($event instanceof EE_Event && $event->is_sold_out(true)) { |
|
| 1932 | + EE_Error::add_error( |
|
| 1933 | + apply_filters( |
|
| 1934 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options___last_second_ticket_verifications__sold_out_events_msg', |
|
| 1935 | + sprintf( |
|
| 1936 | + esc_html__( |
|
| 1937 | + 'It appears that the %1$s event that you were about to make a payment for has sold out since you first registered and/or arrived at this page. Please refresh the page and try again. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', |
|
| 1938 | + 'event_espresso' |
|
| 1939 | + ), |
|
| 1940 | + $event->name() |
|
| 1941 | + ) |
|
| 1942 | + ), |
|
| 1943 | + __FILE__, |
|
| 1944 | + __FUNCTION__, |
|
| 1945 | + __LINE__ |
|
| 1946 | + ); |
|
| 1947 | + return false; |
|
| 1948 | + } |
|
| 1949 | + } |
|
| 1950 | + } |
|
| 1951 | + return true; |
|
| 1952 | + } |
|
| 1953 | + |
|
| 1954 | + |
|
| 1955 | + /** |
|
| 1956 | + * redirect_form |
|
| 1957 | + * |
|
| 1958 | + * @access public |
|
| 1959 | + * @return bool |
|
| 1960 | + * @throws EE_Error |
|
| 1961 | + * @throws InvalidArgumentException |
|
| 1962 | + * @throws ReflectionException |
|
| 1963 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 1964 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 1965 | + */ |
|
| 1966 | + public function redirect_form() |
|
| 1967 | + { |
|
| 1968 | + $payment_method_billing_info = $this->_payment_method_billing_info( |
|
| 1969 | + $this->_get_payment_method_for_selected_method_of_payment() |
|
| 1970 | + ); |
|
| 1971 | + $html = $payment_method_billing_info->get_html(); |
|
| 1972 | + $html .= $this->checkout->redirect_form; |
|
| 1973 | + EE_Registry::instance()->REQ->add_output($html); |
|
| 1974 | + return true; |
|
| 1975 | + } |
|
| 1976 | + |
|
| 1977 | + |
|
| 1978 | + /** |
|
| 1979 | + * _billing_form_is_valid |
|
| 1980 | + * |
|
| 1981 | + * @access private |
|
| 1982 | + * @return bool |
|
| 1983 | + * @throws \EE_Error |
|
| 1984 | + */ |
|
| 1985 | + private function _billing_form_is_valid() |
|
| 1986 | + { |
|
| 1987 | + if (! $this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
| 1988 | + return true; |
|
| 1989 | + } |
|
| 1990 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) { |
|
| 1991 | + if ($this->checkout->billing_form->was_submitted()) { |
|
| 1992 | + $this->checkout->billing_form->receive_form_submission(); |
|
| 1993 | + if ($this->checkout->billing_form->is_valid()) { |
|
| 1994 | + return true; |
|
| 1995 | + } |
|
| 1996 | + $validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated(); |
|
| 1997 | + $error_strings = array(); |
|
| 1998 | + foreach ($validation_errors as $validation_error) { |
|
| 1999 | + if ($validation_error instanceof EE_Validation_Error) { |
|
| 2000 | + $form_section = $validation_error->get_form_section(); |
|
| 2001 | + if ($form_section instanceof EE_Form_Input_Base) { |
|
| 2002 | + $label = $form_section->html_label_text(); |
|
| 2003 | + } elseif ($form_section instanceof EE_Form_Section_Base) { |
|
| 2004 | + $label = $form_section->name(); |
|
| 2005 | + } else { |
|
| 2006 | + $label = esc_html__('Validation Error', 'event_espresso'); |
|
| 2007 | + } |
|
| 2008 | + $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage()); |
|
| 2009 | + } |
|
| 2010 | + } |
|
| 2011 | + EE_Error::add_error( |
|
| 2012 | + sprintf( |
|
| 2013 | + esc_html__( |
|
| 2014 | + 'One or more billing form inputs are invalid and require correction before proceeding. %1$s %2$s', |
|
| 2015 | + 'event_espresso' |
|
| 2016 | + ), |
|
| 2017 | + '<br/>', |
|
| 2018 | + implode('<br/>', $error_strings) |
|
| 2019 | + ), |
|
| 2020 | + __FILE__, |
|
| 2021 | + __FUNCTION__, |
|
| 2022 | + __LINE__ |
|
| 2023 | + ); |
|
| 2024 | + } else { |
|
| 2025 | + EE_Error::add_error( |
|
| 2026 | + esc_html__( |
|
| 2027 | + 'The billing form was not submitted or something prevented it\'s submission.', |
|
| 2028 | + 'event_espresso' |
|
| 2029 | + ), |
|
| 2030 | + __FILE__, |
|
| 2031 | + __FUNCTION__, |
|
| 2032 | + __LINE__ |
|
| 2033 | + ); |
|
| 2034 | + } |
|
| 2035 | + } else { |
|
| 2036 | + EE_Error::add_error( |
|
| 2037 | + esc_html__( |
|
| 2038 | + 'The submitted billing form is invalid possibly due to a technical reason.', |
|
| 2039 | + 'event_espresso' |
|
| 2040 | + ), |
|
| 2041 | + __FILE__, |
|
| 2042 | + __FUNCTION__, |
|
| 2043 | + __LINE__ |
|
| 2044 | + ); |
|
| 2045 | + } |
|
| 2046 | + return false; |
|
| 2047 | + } |
|
| 2048 | + |
|
| 2049 | + |
|
| 2050 | + /** |
|
| 2051 | + * _setup_primary_registrant_prior_to_payment |
|
| 2052 | + * ensures that the primary registrant has a valid attendee object created with the critical details populated |
|
| 2053 | + * (first & last name & email) and that both the transaction object and primary registration object have been saved |
|
| 2054 | + * plz note that any other registrations will NOT be saved at this point (because they may not have any details |
|
| 2055 | + * yet) |
|
| 2056 | + * |
|
| 2057 | + * @access private |
|
| 2058 | + * @return bool |
|
| 2059 | + * @throws EE_Error |
|
| 2060 | + * @throws InvalidArgumentException |
|
| 2061 | + * @throws ReflectionException |
|
| 2062 | + * @throws RuntimeException |
|
| 2063 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2064 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2065 | + */ |
|
| 2066 | + private function _setup_primary_registrant_prior_to_payment() |
|
| 2067 | + { |
|
| 2068 | + // check if transaction has a primary registrant and that it has a related Attendee object |
|
| 2069 | + // if not, then we need to at least gather some primary registrant data before attempting payment |
|
| 2070 | + if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form |
|
| 2071 | + && ! $this->checkout->transaction_has_primary_registrant() |
|
| 2072 | + && ! $this->_capture_primary_registration_data_from_billing_form() |
|
| 2073 | + ) { |
|
| 2074 | + return false; |
|
| 2075 | + } |
|
| 2076 | + // because saving an object clears it's cache, we need to do the chevy shuffle |
|
| 2077 | + // grab the primary_registration object |
|
| 2078 | + $primary_registration = $this->checkout->transaction->primary_registration(); |
|
| 2079 | + // at this point we'll consider a TXN to not have been failed |
|
| 2080 | + $this->checkout->transaction->toggle_failed_transaction_status(); |
|
| 2081 | + // save the TXN ( which clears cached copy of primary_registration) |
|
| 2082 | + $this->checkout->transaction->save(); |
|
| 2083 | + // grab TXN ID and save it to the primary_registration |
|
| 2084 | + $primary_registration->set_transaction_id($this->checkout->transaction->ID()); |
|
| 2085 | + // save what we have so far |
|
| 2086 | + $primary_registration->save(); |
|
| 2087 | + return true; |
|
| 2088 | + } |
|
| 2089 | + |
|
| 2090 | + |
|
| 2091 | + /** |
|
| 2092 | + * _capture_primary_registration_data_from_billing_form |
|
| 2093 | + * |
|
| 2094 | + * @access private |
|
| 2095 | + * @return bool |
|
| 2096 | + * @throws EE_Error |
|
| 2097 | + * @throws InvalidArgumentException |
|
| 2098 | + * @throws ReflectionException |
|
| 2099 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2100 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2101 | + */ |
|
| 2102 | + private function _capture_primary_registration_data_from_billing_form() |
|
| 2103 | + { |
|
| 2104 | + // convert billing form data into an attendee |
|
| 2105 | + $this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data(); |
|
| 2106 | + if (! $this->checkout->primary_attendee_obj instanceof EE_Attendee) { |
|
| 2107 | + EE_Error::add_error( |
|
| 2108 | + sprintf( |
|
| 2109 | + esc_html__( |
|
| 2110 | + 'The billing form details could not be used for attendee details due to a technical issue.%sPlease try again or contact %s for assistance.', |
|
| 2111 | + 'event_espresso' |
|
| 2112 | + ), |
|
| 2113 | + '<br/>', |
|
| 2114 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2115 | + ), |
|
| 2116 | + __FILE__, |
|
| 2117 | + __FUNCTION__, |
|
| 2118 | + __LINE__ |
|
| 2119 | + ); |
|
| 2120 | + return false; |
|
| 2121 | + } |
|
| 2122 | + $primary_registration = $this->checkout->transaction->primary_registration(); |
|
| 2123 | + if (! $primary_registration instanceof EE_Registration) { |
|
| 2124 | + EE_Error::add_error( |
|
| 2125 | + sprintf( |
|
| 2126 | + esc_html__( |
|
| 2127 | + 'The primary registrant for this transaction could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', |
|
| 2128 | + 'event_espresso' |
|
| 2129 | + ), |
|
| 2130 | + '<br/>', |
|
| 2131 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2132 | + ), |
|
| 2133 | + __FILE__, |
|
| 2134 | + __FUNCTION__, |
|
| 2135 | + __LINE__ |
|
| 2136 | + ); |
|
| 2137 | + return false; |
|
| 2138 | + } |
|
| 2139 | + if (! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee') |
|
| 2140 | + instanceof |
|
| 2141 | + EE_Attendee |
|
| 2142 | + ) { |
|
| 2143 | + EE_Error::add_error( |
|
| 2144 | + sprintf( |
|
| 2145 | + esc_html__( |
|
| 2146 | + 'The primary registrant could not be associated with this transaction due to a technical issue.%sPlease try again or contact %s for assistance.', |
|
| 2147 | + 'event_espresso' |
|
| 2148 | + ), |
|
| 2149 | + '<br/>', |
|
| 2150 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2151 | + ), |
|
| 2152 | + __FILE__, |
|
| 2153 | + __FUNCTION__, |
|
| 2154 | + __LINE__ |
|
| 2155 | + ); |
|
| 2156 | + return false; |
|
| 2157 | + } |
|
| 2158 | + /** @type EE_Registration_Processor $registration_processor */ |
|
| 2159 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
| 2160 | + // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
|
| 2161 | + $registration_processor->toggle_incomplete_registration_status_to_default($primary_registration); |
|
| 2162 | + return true; |
|
| 2163 | + } |
|
| 2164 | + |
|
| 2165 | + |
|
| 2166 | + /** |
|
| 2167 | + * _get_payment_method_for_selected_method_of_payment |
|
| 2168 | + * retrieves a valid payment method |
|
| 2169 | + * |
|
| 2170 | + * @access public |
|
| 2171 | + * @return EE_Payment_Method |
|
| 2172 | + * @throws EE_Error |
|
| 2173 | + * @throws InvalidArgumentException |
|
| 2174 | + * @throws ReflectionException |
|
| 2175 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2176 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2177 | + */ |
|
| 2178 | + private function _get_payment_method_for_selected_method_of_payment() |
|
| 2179 | + { |
|
| 2180 | + if ($this->checkout->selected_method_of_payment === 'events_sold_out') { |
|
| 2181 | + $this->_redirect_because_event_sold_out(); |
|
| 2182 | + return null; |
|
| 2183 | + } |
|
| 2184 | + // get EE_Payment_Method object |
|
| 2185 | + if (isset($this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ])) { |
|
| 2186 | + $payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ]; |
|
| 2187 | + } else { |
|
| 2188 | + // load EEM_Payment_Method |
|
| 2189 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
| 2190 | + /** @type EEM_Payment_Method $EEM_Payment_Method */ |
|
| 2191 | + $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
|
| 2192 | + $payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment); |
|
| 2193 | + } |
|
| 2194 | + // verify $payment_method |
|
| 2195 | + if (! $payment_method instanceof EE_Payment_Method) { |
|
| 2196 | + // not a payment |
|
| 2197 | + EE_Error::add_error( |
|
| 2198 | + sprintf( |
|
| 2199 | + esc_html__( |
|
| 2200 | + 'The selected method of payment could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', |
|
| 2201 | + 'event_espresso' |
|
| 2202 | + ), |
|
| 2203 | + '<br/>', |
|
| 2204 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2205 | + ), |
|
| 2206 | + __FILE__, |
|
| 2207 | + __FUNCTION__, |
|
| 2208 | + __LINE__ |
|
| 2209 | + ); |
|
| 2210 | + return null; |
|
| 2211 | + } |
|
| 2212 | + // and verify it has a valid Payment_Method Type object |
|
| 2213 | + if (! $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
| 2214 | + // not a payment |
|
| 2215 | + EE_Error::add_error( |
|
| 2216 | + sprintf( |
|
| 2217 | + esc_html__( |
|
| 2218 | + 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', |
|
| 2219 | + 'event_espresso' |
|
| 2220 | + ), |
|
| 2221 | + '<br/>', |
|
| 2222 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2223 | + ), |
|
| 2224 | + __FILE__, |
|
| 2225 | + __FUNCTION__, |
|
| 2226 | + __LINE__ |
|
| 2227 | + ); |
|
| 2228 | + return null; |
|
| 2229 | + } |
|
| 2230 | + return $payment_method; |
|
| 2231 | + } |
|
| 2232 | + |
|
| 2233 | + |
|
| 2234 | + /** |
|
| 2235 | + * _attempt_payment |
|
| 2236 | + * |
|
| 2237 | + * @access private |
|
| 2238 | + * @type EE_Payment_Method $payment_method |
|
| 2239 | + * @return mixed EE_Payment | boolean |
|
| 2240 | + * @throws EE_Error |
|
| 2241 | + * @throws InvalidArgumentException |
|
| 2242 | + * @throws ReflectionException |
|
| 2243 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2244 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2245 | + */ |
|
| 2246 | + private function _attempt_payment(EE_Payment_Method $payment_method) |
|
| 2247 | + { |
|
| 2248 | + $payment = null; |
|
| 2249 | + $this->checkout->transaction->save(); |
|
| 2250 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
| 2251 | + if (! $payment_processor instanceof EE_Payment_Processor) { |
|
| 2252 | + return false; |
|
| 2253 | + } |
|
| 2254 | + try { |
|
| 2255 | + $payment_processor->set_revisit($this->checkout->revisit); |
|
| 2256 | + // generate payment object |
|
| 2257 | + $payment = $payment_processor->process_payment( |
|
| 2258 | + $payment_method, |
|
| 2259 | + $this->checkout->transaction, |
|
| 2260 | + $this->checkout->amount_owing, |
|
| 2261 | + $this->checkout->billing_form, |
|
| 2262 | + $this->_get_return_url($payment_method), |
|
| 2263 | + 'CART', |
|
| 2264 | + $this->checkout->admin_request, |
|
| 2265 | + true, |
|
| 2266 | + $this->reg_step_url() |
|
| 2267 | + ); |
|
| 2268 | + } catch (Exception $e) { |
|
| 2269 | + $this->_handle_payment_processor_exception($e); |
|
| 2270 | + } |
|
| 2271 | + return $payment; |
|
| 2272 | + } |
|
| 2273 | + |
|
| 2274 | + |
|
| 2275 | + /** |
|
| 2276 | + * _handle_payment_processor_exception |
|
| 2277 | + * |
|
| 2278 | + * @access protected |
|
| 2279 | + * @param \Exception $e |
|
| 2280 | + * @return void |
|
| 2281 | + * @throws EE_Error |
|
| 2282 | + * @throws InvalidArgumentException |
|
| 2283 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2284 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2285 | + */ |
|
| 2286 | + protected function _handle_payment_processor_exception(Exception $e) |
|
| 2287 | + { |
|
| 2288 | + EE_Error::add_error( |
|
| 2289 | + sprintf( |
|
| 2290 | + esc_html__( |
|
| 2291 | + 'The payment could not br processed due to a technical issue.%1$sPlease try again or contact %2$s for assistance.||The following Exception was thrown in %4$s on line %5$s:%1$s%3$s', |
|
| 2292 | + 'event_espresso' |
|
| 2293 | + ), |
|
| 2294 | + '<br/>', |
|
| 2295 | + EE_Registry::instance()->CFG->organization->get_pretty('email'), |
|
| 2296 | + $e->getMessage(), |
|
| 2297 | + $e->getFile(), |
|
| 2298 | + $e->getLine() |
|
| 2299 | + ), |
|
| 2300 | + __FILE__, |
|
| 2301 | + __FUNCTION__, |
|
| 2302 | + __LINE__ |
|
| 2303 | + ); |
|
| 2304 | + } |
|
| 2305 | + |
|
| 2306 | + |
|
| 2307 | + /** |
|
| 2308 | + * _get_return_url |
|
| 2309 | + * |
|
| 2310 | + * @access protected |
|
| 2311 | + * @param \EE_Payment_Method $payment_method |
|
| 2312 | + * @return string |
|
| 2313 | + * @throws \EE_Error |
|
| 2314 | + */ |
|
| 2315 | + protected function _get_return_url(EE_Payment_Method $payment_method) |
|
| 2316 | + { |
|
| 2317 | + $return_url = ''; |
|
| 2318 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
| 2319 | + case EE_PMT_Base::offsite: |
|
| 2320 | + $return_url = add_query_arg( |
|
| 2321 | + array( |
|
| 2322 | + 'action' => 'process_gateway_response', |
|
| 2323 | + 'selected_method_of_payment' => $this->checkout->selected_method_of_payment, |
|
| 2324 | + 'spco_txn' => $this->checkout->transaction->ID(), |
|
| 2325 | + ), |
|
| 2326 | + $this->reg_step_url() |
|
| 2327 | + ); |
|
| 2328 | + break; |
|
| 2329 | + case EE_PMT_Base::onsite: |
|
| 2330 | + case EE_PMT_Base::offline: |
|
| 2331 | + $return_url = $this->checkout->next_step->reg_step_url(); |
|
| 2332 | + break; |
|
| 2333 | + } |
|
| 2334 | + return $return_url; |
|
| 2335 | + } |
|
| 2336 | + |
|
| 2337 | + |
|
| 2338 | + /** |
|
| 2339 | + * _validate_payment |
|
| 2340 | + * |
|
| 2341 | + * @access private |
|
| 2342 | + * @param EE_Payment $payment |
|
| 2343 | + * @return EE_Payment|FALSE |
|
| 2344 | + * @throws EE_Error |
|
| 2345 | + * @throws InvalidArgumentException |
|
| 2346 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2347 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2348 | + */ |
|
| 2349 | + private function _validate_payment($payment = null) |
|
| 2350 | + { |
|
| 2351 | + if ($this->checkout->payment_method->is_off_line()) { |
|
| 2352 | + return true; |
|
| 2353 | + } |
|
| 2354 | + // verify payment object |
|
| 2355 | + if (! $payment instanceof EE_Payment) { |
|
| 2356 | + // not a payment |
|
| 2357 | + EE_Error::add_error( |
|
| 2358 | + sprintf( |
|
| 2359 | + esc_html__( |
|
| 2360 | + 'A valid payment was not generated due to a technical issue.%1$sPlease try again or contact %2$s for assistance.', |
|
| 2361 | + 'event_espresso' |
|
| 2362 | + ), |
|
| 2363 | + '<br/>', |
|
| 2364 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2365 | + ), |
|
| 2366 | + __FILE__, |
|
| 2367 | + __FUNCTION__, |
|
| 2368 | + __LINE__ |
|
| 2369 | + ); |
|
| 2370 | + return false; |
|
| 2371 | + } |
|
| 2372 | + return $payment; |
|
| 2373 | + } |
|
| 2374 | + |
|
| 2375 | + |
|
| 2376 | + /** |
|
| 2377 | + * _post_payment_processing |
|
| 2378 | + * |
|
| 2379 | + * @access private |
|
| 2380 | + * @param EE_Payment|bool $payment |
|
| 2381 | + * @return bool |
|
| 2382 | + * @throws EE_Error |
|
| 2383 | + * @throws InvalidArgumentException |
|
| 2384 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2385 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2386 | + */ |
|
| 2387 | + private function _post_payment_processing($payment = null) |
|
| 2388 | + { |
|
| 2389 | + // Off-Line payment? |
|
| 2390 | + if ($payment === true) { |
|
| 2391 | + // $this->_setup_redirect_for_next_step(); |
|
| 2392 | + return true; |
|
| 2393 | + // On-Site payment? |
|
| 2394 | + } elseif ($this->checkout->payment_method->is_on_site()) { |
|
| 2395 | + if (! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) { |
|
| 2396 | + // $this->_setup_redirect_for_next_step(); |
|
| 2397 | + $this->checkout->continue_reg = false; |
|
| 2398 | + } |
|
| 2399 | + // Off-Site payment? |
|
| 2400 | + } elseif ($this->checkout->payment_method->is_off_site()) { |
|
| 2401 | + // if a payment object was made and it specifies a redirect url, then we'll setup that redirect info |
|
| 2402 | + if ($payment instanceof EE_Payment && $payment->redirect_url()) { |
|
| 2403 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()'); |
|
| 2404 | + $this->checkout->redirect = true; |
|
| 2405 | + $this->checkout->redirect_form = $payment->redirect_form(); |
|
| 2406 | + $this->checkout->redirect_url = $this->reg_step_url('redirect_form'); |
|
| 2407 | + // set JSON response |
|
| 2408 | + $this->checkout->json_response->set_redirect_form($this->checkout->redirect_form); |
|
| 2409 | + // and lastly, let's bump the payment status to pending |
|
| 2410 | + $payment->set_status(EEM_Payment::status_id_pending); |
|
| 2411 | + $payment->save(); |
|
| 2412 | + } else { |
|
| 2413 | + // we couldn't redirect the user. Let's tell them why. |
|
| 2414 | + $error_message = sprintf( |
|
| 2415 | + esc_html__( |
|
| 2416 | + 'It appears the Off Site Payment Method was not configured properly.%sPlease try again or contact %s for assistance.', |
|
| 2417 | + 'event_espresso' |
|
| 2418 | + ), |
|
| 2419 | + '<br/>', |
|
| 2420 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2421 | + ); |
|
| 2422 | + if ($payment instanceof EE_Payment && $payment->gateway_response()) { |
|
| 2423 | + $error_message = $error_message . '<br/>' . $payment->gateway_response(); |
|
| 2424 | + } |
|
| 2425 | + $this->checkout->continue_reg = false; |
|
| 2426 | + EE_Error::add_error( |
|
| 2427 | + $error_message, |
|
| 2428 | + __FILE__, |
|
| 2429 | + __FUNCTION__, |
|
| 2430 | + __LINE__ |
|
| 2431 | + ); |
|
| 2432 | + } |
|
| 2433 | + } else { |
|
| 2434 | + // ummm ya... not Off-Line, not On-Site, not off-Site ???? |
|
| 2435 | + $this->checkout->continue_reg = false; |
|
| 2436 | + return false; |
|
| 2437 | + } |
|
| 2438 | + return $payment; |
|
| 2439 | + } |
|
| 2440 | + |
|
| 2441 | + |
|
| 2442 | + /** |
|
| 2443 | + * _process_payment_status |
|
| 2444 | + * |
|
| 2445 | + * @access private |
|
| 2446 | + * @type EE_Payment $payment |
|
| 2447 | + * @param string $payment_occurs |
|
| 2448 | + * @return bool |
|
| 2449 | + * @throws EE_Error |
|
| 2450 | + * @throws InvalidArgumentException |
|
| 2451 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2452 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2453 | + */ |
|
| 2454 | + private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) |
|
| 2455 | + { |
|
| 2456 | + // off-line payment? carry on |
|
| 2457 | + if ($payment_occurs === EE_PMT_Base::offline) { |
|
| 2458 | + return true; |
|
| 2459 | + } |
|
| 2460 | + // verify payment validity |
|
| 2461 | + if ($payment instanceof EE_Payment) { |
|
| 2462 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()'); |
|
| 2463 | + $msg = $payment->gateway_response(); |
|
| 2464 | + // check results |
|
| 2465 | + switch ($payment->status()) { |
|
| 2466 | + // good payment |
|
| 2467 | + case EEM_Payment::status_id_approved: |
|
| 2468 | + EE_Error::add_success( |
|
| 2469 | + esc_html__('Your payment was processed successfully.', 'event_espresso'), |
|
| 2470 | + __FILE__, |
|
| 2471 | + __FUNCTION__, |
|
| 2472 | + __LINE__ |
|
| 2473 | + ); |
|
| 2474 | + return true; |
|
| 2475 | + break; |
|
| 2476 | + // slow payment |
|
| 2477 | + case EEM_Payment::status_id_pending: |
|
| 2478 | + if (empty($msg)) { |
|
| 2479 | + $msg = esc_html__( |
|
| 2480 | + 'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', |
|
| 2481 | + 'event_espresso' |
|
| 2482 | + ); |
|
| 2483 | + } |
|
| 2484 | + EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2485 | + return true; |
|
| 2486 | + break; |
|
| 2487 | + // don't wanna payment |
|
| 2488 | + case EEM_Payment::status_id_cancelled: |
|
| 2489 | + if (empty($msg)) { |
|
| 2490 | + $msg = _n( |
|
| 2491 | + 'Payment cancelled. Please try again.', |
|
| 2492 | + 'Payment cancelled. Please try again or select another method of payment.', |
|
| 2493 | + count($this->checkout->available_payment_methods), |
|
| 2494 | + 'event_espresso' |
|
| 2495 | + ); |
|
| 2496 | + } |
|
| 2497 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2498 | + return false; |
|
| 2499 | + break; |
|
| 2500 | + // not enough payment |
|
| 2501 | + case EEM_Payment::status_id_declined: |
|
| 2502 | + if (empty($msg)) { |
|
| 2503 | + $msg = _n( |
|
| 2504 | + 'We\'re sorry but your payment was declined. Please try again.', |
|
| 2505 | + 'We\'re sorry but your payment was declined. Please try again or select another method of payment.', |
|
| 2506 | + count($this->checkout->available_payment_methods), |
|
| 2507 | + 'event_espresso' |
|
| 2508 | + ); |
|
| 2509 | + } |
|
| 2510 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2511 | + return false; |
|
| 2512 | + break; |
|
| 2513 | + // bad payment |
|
| 2514 | + case EEM_Payment::status_id_failed: |
|
| 2515 | + if (! empty($msg)) { |
|
| 2516 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2517 | + return false; |
|
| 2518 | + } |
|
| 2519 | + // default to error below |
|
| 2520 | + break; |
|
| 2521 | + } |
|
| 2522 | + } |
|
| 2523 | + // off-site payment gateway responses are too unreliable, so let's just assume that |
|
| 2524 | + // the payment processing is just running slower than the registrant's request |
|
| 2525 | + if ($payment_occurs === EE_PMT_Base::offsite) { |
|
| 2526 | + return true; |
|
| 2527 | + } |
|
| 2528 | + EE_Error::add_error( |
|
| 2529 | + sprintf( |
|
| 2530 | + esc_html__( |
|
| 2531 | + 'Your payment could not be processed successfully due to a technical issue.%sPlease try again or contact %s for assistance.', |
|
| 2532 | + 'event_espresso' |
|
| 2533 | + ), |
|
| 2534 | + '<br/>', |
|
| 2535 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2536 | + ), |
|
| 2537 | + __FILE__, |
|
| 2538 | + __FUNCTION__, |
|
| 2539 | + __LINE__ |
|
| 2540 | + ); |
|
| 2541 | + return false; |
|
| 2542 | + } |
|
| 2543 | + |
|
| 2544 | + |
|
| 2545 | + |
|
| 2546 | + |
|
| 2547 | + |
|
| 2548 | + |
|
| 2549 | + /********************************************************************************************************/ |
|
| 2550 | + /********************************** PROCESS GATEWAY RESPONSE **********************************/ |
|
| 2551 | + /********************************************************************************************************/ |
|
| 2552 | + /** |
|
| 2553 | + * process_gateway_response |
|
| 2554 | + * this is the return point for Off-Site Payment Methods |
|
| 2555 | + * It will attempt to "handle the IPN" if it appears that this has not already occurred, |
|
| 2556 | + * otherwise, it will load up the last payment made for the TXN. |
|
| 2557 | + * If the payment retrieved looks good, it will then either: |
|
| 2558 | + * complete the current step and allow advancement to the next reg step |
|
| 2559 | + * or present the payment options again |
|
| 2560 | + * |
|
| 2561 | + * @access private |
|
| 2562 | + * @return EE_Payment|FALSE |
|
| 2563 | + * @throws EE_Error |
|
| 2564 | + * @throws InvalidArgumentException |
|
| 2565 | + * @throws ReflectionException |
|
| 2566 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2567 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2568 | + * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
|
| 2569 | + */ |
|
| 2570 | + public function process_gateway_response() |
|
| 2571 | + { |
|
| 2572 | + $payment = null; |
|
| 2573 | + // how have they chosen to pay? |
|
| 2574 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
| 2575 | + // get EE_Payment_Method object |
|
| 2576 | + if (! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
| 2577 | + $this->checkout->continue_reg = false; |
|
| 2578 | + return false; |
|
| 2579 | + } |
|
| 2580 | + if (! $this->checkout->payment_method->is_off_site()) { |
|
| 2581 | + return false; |
|
| 2582 | + } |
|
| 2583 | + $this->_validate_offsite_return(); |
|
| 2584 | + // DEBUG LOG |
|
| 2585 | + // $this->checkout->log( |
|
| 2586 | + // __CLASS__, |
|
| 2587 | + // __FUNCTION__, |
|
| 2588 | + // __LINE__, |
|
| 2589 | + // array( |
|
| 2590 | + // 'selected_method_of_payment' => $this->checkout->selected_method_of_payment, |
|
| 2591 | + // 'payment_method' => $this->checkout->payment_method, |
|
| 2592 | + // ), |
|
| 2593 | + // true |
|
| 2594 | + // ); |
|
| 2595 | + // verify TXN |
|
| 2596 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
| 2597 | + $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
|
| 2598 | + if (! $gateway instanceof EE_Offsite_Gateway) { |
|
| 2599 | + $this->checkout->continue_reg = false; |
|
| 2600 | + return false; |
|
| 2601 | + } |
|
| 2602 | + $payment = $this->_process_off_site_payment($gateway); |
|
| 2603 | + $payment = $this->_process_cancelled_payments($payment); |
|
| 2604 | + $payment = $this->_validate_payment($payment); |
|
| 2605 | + // if payment was not declined by the payment gateway or cancelled by the registrant |
|
| 2606 | + if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) { |
|
| 2607 | + // $this->_setup_redirect_for_next_step(); |
|
| 2608 | + // store that for later |
|
| 2609 | + $this->checkout->payment = $payment; |
|
| 2610 | + // mark this reg step as completed, as long as gateway doesn't use a separate IPN request, |
|
| 2611 | + // because we will complete this step during the IPN processing then |
|
| 2612 | + if ($gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request()) { |
|
| 2613 | + $this->set_completed(); |
|
| 2614 | + } |
|
| 2615 | + return true; |
|
| 2616 | + } |
|
| 2617 | + } |
|
| 2618 | + // DEBUG LOG |
|
| 2619 | + // $this->checkout->log( |
|
| 2620 | + // __CLASS__, |
|
| 2621 | + // __FUNCTION__, |
|
| 2622 | + // __LINE__, |
|
| 2623 | + // array('payment' => $payment) |
|
| 2624 | + // ); |
|
| 2625 | + $this->checkout->continue_reg = false; |
|
| 2626 | + return false; |
|
| 2627 | + } |
|
| 2628 | + |
|
| 2629 | + |
|
| 2630 | + /** |
|
| 2631 | + * _validate_return |
|
| 2632 | + * |
|
| 2633 | + * @access private |
|
| 2634 | + * @return void |
|
| 2635 | + * @throws EE_Error |
|
| 2636 | + * @throws InvalidArgumentException |
|
| 2637 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2638 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2639 | + * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
|
| 2640 | + */ |
|
| 2641 | + private function _validate_offsite_return() |
|
| 2642 | + { |
|
| 2643 | + $TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0); |
|
| 2644 | + if ($TXN_ID !== $this->checkout->transaction->ID()) { |
|
| 2645 | + // Houston... we might have a problem |
|
| 2646 | + $invalid_TXN = false; |
|
| 2647 | + // first gather some info |
|
| 2648 | + $valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
| 2649 | + $primary_registrant = $valid_TXN instanceof EE_Transaction |
|
| 2650 | + ? $valid_TXN->primary_registration() |
|
| 2651 | + : null; |
|
| 2652 | + // let's start by retrieving the cart for this TXN |
|
| 2653 | + $cart = $this->checkout->get_cart_for_transaction($this->checkout->transaction); |
|
| 2654 | + if ($cart instanceof EE_Cart) { |
|
| 2655 | + // verify that the current cart has tickets |
|
| 2656 | + $tickets = $cart->get_tickets(); |
|
| 2657 | + if (empty($tickets)) { |
|
| 2658 | + $invalid_TXN = true; |
|
| 2659 | + } |
|
| 2660 | + } else { |
|
| 2661 | + $invalid_TXN = true; |
|
| 2662 | + } |
|
| 2663 | + $valid_TXN_SID = $primary_registrant instanceof EE_Registration |
|
| 2664 | + ? $primary_registrant->session_ID() |
|
| 2665 | + : null; |
|
| 2666 | + // validate current Session ID and compare against valid TXN session ID |
|
| 2667 | + if ($invalid_TXN // if this is already true, then skip other checks |
|
| 2668 | + || EE_Session::instance()->id() === null |
|
| 2669 | + || ( |
|
| 2670 | + // WARNING !!! |
|
| 2671 | + // this could be PayPal sending back duplicate requests (ya they do that) |
|
| 2672 | + // or it **could** mean someone is simply registering AGAIN after having just done so |
|
| 2673 | + // so now we need to determine if this current TXN looks valid or not |
|
| 2674 | + // and whether this reg step has even been started ? |
|
| 2675 | + EE_Session::instance()->id() === $valid_TXN_SID |
|
| 2676 | + // really? you're half way through this reg step, but you never started it ? |
|
| 2677 | + && $this->checkout->transaction->reg_step_completed($this->slug()) === false |
|
| 2678 | + ) |
|
| 2679 | + ) { |
|
| 2680 | + $invalid_TXN = true; |
|
| 2681 | + } |
|
| 2682 | + if ($invalid_TXN) { |
|
| 2683 | + // is the valid TXN completed ? |
|
| 2684 | + if ($valid_TXN instanceof EE_Transaction) { |
|
| 2685 | + // has this step even been started ? |
|
| 2686 | + $reg_step_completed = $valid_TXN->reg_step_completed($this->slug()); |
|
| 2687 | + if ($reg_step_completed !== false && $reg_step_completed !== true) { |
|
| 2688 | + // so it **looks** like this is a double request from PayPal |
|
| 2689 | + // so let's try to pick up where we left off |
|
| 2690 | + $this->checkout->transaction = $valid_TXN; |
|
| 2691 | + $this->checkout->refresh_all_entities(true); |
|
| 2692 | + return; |
|
| 2693 | + } |
|
| 2694 | + } |
|
| 2695 | + // you appear to be lost? |
|
| 2696 | + $this->_redirect_wayward_request($primary_registrant); |
|
| 2697 | + } |
|
| 2698 | + } |
|
| 2699 | + } |
|
| 2700 | + |
|
| 2701 | + |
|
| 2702 | + /** |
|
| 2703 | + * _redirect_wayward_request |
|
| 2704 | + * |
|
| 2705 | + * @access private |
|
| 2706 | + * @param \EE_Registration|null $primary_registrant |
|
| 2707 | + * @return bool |
|
| 2708 | + * @throws EE_Error |
|
| 2709 | + * @throws InvalidArgumentException |
|
| 2710 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2711 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2712 | + */ |
|
| 2713 | + private function _redirect_wayward_request(EE_Registration $primary_registrant) |
|
| 2714 | + { |
|
| 2715 | + if (! $primary_registrant instanceof EE_Registration) { |
|
| 2716 | + // try redirecting based on the current TXN |
|
| 2717 | + $primary_registrant = $this->checkout->transaction instanceof EE_Transaction |
|
| 2718 | + ? $this->checkout->transaction->primary_registration() |
|
| 2719 | + : null; |
|
| 2720 | + } |
|
| 2721 | + if (! $primary_registrant instanceof EE_Registration) { |
|
| 2722 | + EE_Error::add_error( |
|
| 2723 | + sprintf( |
|
| 2724 | + esc_html__( |
|
| 2725 | + 'Invalid information was received from the Off-Site Payment Processor and your Transaction details could not be retrieved from the database.%1$sPlease try again or contact %2$s for assistance.', |
|
| 2726 | + 'event_espresso' |
|
| 2727 | + ), |
|
| 2728 | + '<br/>', |
|
| 2729 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
| 2730 | + ), |
|
| 2731 | + __FILE__, |
|
| 2732 | + __FUNCTION__, |
|
| 2733 | + __LINE__ |
|
| 2734 | + ); |
|
| 2735 | + return false; |
|
| 2736 | + } |
|
| 2737 | + // make sure transaction is not locked |
|
| 2738 | + $this->checkout->transaction->unlock(); |
|
| 2739 | + wp_safe_redirect( |
|
| 2740 | + add_query_arg( |
|
| 2741 | + array( |
|
| 2742 | + 'e_reg_url_link' => $primary_registrant->reg_url_link(), |
|
| 2743 | + ), |
|
| 2744 | + $this->checkout->thank_you_page_url |
|
| 2745 | + ) |
|
| 2746 | + ); |
|
| 2747 | + exit(); |
|
| 2748 | + } |
|
| 2749 | + |
|
| 2750 | + |
|
| 2751 | + /** |
|
| 2752 | + * _process_off_site_payment |
|
| 2753 | + * |
|
| 2754 | + * @access private |
|
| 2755 | + * @param \EE_Offsite_Gateway $gateway |
|
| 2756 | + * @return EE_Payment |
|
| 2757 | + * @throws EE_Error |
|
| 2758 | + * @throws InvalidArgumentException |
|
| 2759 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2760 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2761 | + */ |
|
| 2762 | + private function _process_off_site_payment(EE_Offsite_Gateway $gateway) |
|
| 2763 | + { |
|
| 2764 | + try { |
|
| 2765 | + $request_data = \EE_Registry::instance()->REQ->params(); |
|
| 2766 | + // if gateway uses_separate_IPN_request, then we don't have to process the IPN manually |
|
| 2767 | + $this->set_handle_IPN_in_this_request( |
|
| 2768 | + $gateway->handle_IPN_in_this_request($request_data, false) |
|
| 2769 | + ); |
|
| 2770 | + if ($this->handle_IPN_in_this_request()) { |
|
| 2771 | + // get payment details and process results |
|
| 2772 | + /** @type EE_Payment_Processor $payment_processor */ |
|
| 2773 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
| 2774 | + $payment = $payment_processor->process_ipn( |
|
| 2775 | + $request_data, |
|
| 2776 | + $this->checkout->transaction, |
|
| 2777 | + $this->checkout->payment_method, |
|
| 2778 | + true, |
|
| 2779 | + false |
|
| 2780 | + ); |
|
| 2781 | + // $payment_source = 'process_ipn'; |
|
| 2782 | + } else { |
|
| 2783 | + $payment = $this->checkout->transaction->last_payment(); |
|
| 2784 | + // $payment_source = 'last_payment'; |
|
| 2785 | + } |
|
| 2786 | + } catch (Exception $e) { |
|
| 2787 | + // let's just eat the exception and try to move on using any previously set payment info |
|
| 2788 | + $payment = $this->checkout->transaction->last_payment(); |
|
| 2789 | + // $payment_source = 'last_payment after Exception'; |
|
| 2790 | + // but if we STILL don't have a payment object |
|
| 2791 | + if (! $payment instanceof EE_Payment) { |
|
| 2792 | + // then we'll object ! ( not object like a thing... but object like what a lawyer says ! ) |
|
| 2793 | + $this->_handle_payment_processor_exception($e); |
|
| 2794 | + } |
|
| 2795 | + } |
|
| 2796 | + // DEBUG LOG |
|
| 2797 | + // $this->checkout->log( |
|
| 2798 | + // __CLASS__, |
|
| 2799 | + // __FUNCTION__, |
|
| 2800 | + // __LINE__, |
|
| 2801 | + // array( |
|
| 2802 | + // 'process_ipn_payment' => $payment, |
|
| 2803 | + // 'payment_source' => $payment_source, |
|
| 2804 | + // ) |
|
| 2805 | + // ); |
|
| 2806 | + return $payment; |
|
| 2807 | + } |
|
| 2808 | + |
|
| 2809 | + |
|
| 2810 | + /** |
|
| 2811 | + * _process_cancelled_payments |
|
| 2812 | + * just makes sure that the payment status gets updated correctly |
|
| 2813 | + * so tha tan error isn't generated during payment validation |
|
| 2814 | + * |
|
| 2815 | + * @access private |
|
| 2816 | + * @param EE_Payment $payment |
|
| 2817 | + * @return EE_Payment | FALSE |
|
| 2818 | + * @throws \EE_Error |
|
| 2819 | + */ |
|
| 2820 | + private function _process_cancelled_payments($payment = null) |
|
| 2821 | + { |
|
| 2822 | + if ($payment instanceof EE_Payment |
|
| 2823 | + && isset($_REQUEST['ee_cancel_payment']) |
|
| 2824 | + && $payment->status() === EEM_Payment::status_id_failed |
|
| 2825 | + ) { |
|
| 2826 | + $payment->set_status(EEM_Payment::status_id_cancelled); |
|
| 2827 | + } |
|
| 2828 | + return $payment; |
|
| 2829 | + } |
|
| 2830 | + |
|
| 2831 | + |
|
| 2832 | + /** |
|
| 2833 | + * get_transaction_details_for_gateways |
|
| 2834 | + * |
|
| 2835 | + * @access public |
|
| 2836 | + * @return int |
|
| 2837 | + * @throws EE_Error |
|
| 2838 | + * @throws InvalidArgumentException |
|
| 2839 | + * @throws ReflectionException |
|
| 2840 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2841 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2842 | + */ |
|
| 2843 | + public function get_transaction_details_for_gateways() |
|
| 2844 | + { |
|
| 2845 | + $txn_details = array(); |
|
| 2846 | + // ya gotta make a choice man |
|
| 2847 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
| 2848 | + $txn_details = array( |
|
| 2849 | + 'error' => esc_html__('Please select a method of payment before proceeding.', 'event_espresso'), |
|
| 2850 | + ); |
|
| 2851 | + } |
|
| 2852 | + // get EE_Payment_Method object |
|
| 2853 | + if (empty($txn_details) |
|
| 2854 | + && |
|
| 2855 | + ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() |
|
| 2856 | + ) { |
|
| 2857 | + $txn_details = array( |
|
| 2858 | + 'selected_method_of_payment' => $this->checkout->selected_method_of_payment, |
|
| 2859 | + 'error' => esc_html__( |
|
| 2860 | + 'A valid Payment Method could not be determined.', |
|
| 2861 | + 'event_espresso' |
|
| 2862 | + ), |
|
| 2863 | + ); |
|
| 2864 | + } |
|
| 2865 | + if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) { |
|
| 2866 | + $return_url = $this->_get_return_url($this->checkout->payment_method); |
|
| 2867 | + $txn_details = array( |
|
| 2868 | + 'TXN_ID' => $this->checkout->transaction->ID(), |
|
| 2869 | + 'TXN_timestamp' => $this->checkout->transaction->datetime(), |
|
| 2870 | + 'TXN_total' => $this->checkout->transaction->total(), |
|
| 2871 | + 'TXN_paid' => $this->checkout->transaction->paid(), |
|
| 2872 | + 'TXN_reg_steps' => $this->checkout->transaction->reg_steps(), |
|
| 2873 | + 'STS_ID' => $this->checkout->transaction->status_ID(), |
|
| 2874 | + 'PMD_ID' => $this->checkout->transaction->payment_method_ID(), |
|
| 2875 | + 'payment_amount' => $this->checkout->amount_owing, |
|
| 2876 | + 'return_url' => $return_url, |
|
| 2877 | + 'cancel_url' => add_query_arg(array('ee_cancel_payment' => true), $return_url), |
|
| 2878 | + 'notify_url' => EE_Config::instance()->core->txn_page_url( |
|
| 2879 | + array( |
|
| 2880 | + 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link(), |
|
| 2881 | + 'ee_payment_method' => $this->checkout->payment_method->slug(), |
|
| 2882 | + ) |
|
| 2883 | + ), |
|
| 2884 | + ); |
|
| 2885 | + } |
|
| 2886 | + echo wp_json_encode($txn_details); |
|
| 2887 | + exit(); |
|
| 2888 | + } |
|
| 2889 | + |
|
| 2890 | + |
|
| 2891 | + /** |
|
| 2892 | + * __sleep |
|
| 2893 | + * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon |
|
| 2894 | + * serialization EE_Checkout will handle the reimplementation of itself upon waking, but we won't bother with the |
|
| 2895 | + * reg form, because if needed, it will be regenerated anyways |
|
| 2896 | + * |
|
| 2897 | + * @return array |
|
| 2898 | + */ |
|
| 2899 | + public function __sleep() |
|
| 2900 | + { |
|
| 2901 | + // remove the reg form and the checkout |
|
| 2902 | + return array_diff(array_keys(get_object_vars($this)), array('reg_form', 'checkout', 'line_item_display')); |
|
| 2903 | + } |
|
| 2904 | 2904 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | { |
| 130 | 130 | $this->_slug = 'payment_options'; |
| 131 | 131 | $this->_name = esc_html__('Payment Options', 'event_espresso'); |
| 132 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . '/payment_options_main.template.php'; |
|
| 132 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.'/payment_options_main.template.php'; |
|
| 133 | 133 | $this->checkout = $checkout; |
| 134 | 134 | $this->_reset_success_message(); |
| 135 | 135 | $this->set_instructions( |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | { |
| 213 | 213 | $transaction = $this->checkout->transaction; |
| 214 | 214 | // if the transaction isn't set or nothing is owed on it, don't enqueue any JS |
| 215 | - if (! $transaction instanceof EE_Transaction || EEH_Money::compare_floats($transaction->remaining(), 0)) { |
|
| 215 | + if ( ! $transaction instanceof EE_Transaction || EEH_Money::compare_floats($transaction->remaining(), 0)) { |
|
| 216 | 216 | return; |
| 217 | 217 | } |
| 218 | 218 | foreach (EEM_Payment_Method::instance()->get_all_for_transaction( |
@@ -304,18 +304,18 @@ discard block |
||
| 304 | 304 | foreach ($registrations as $REG_ID => $registration) { |
| 305 | 305 | /** @var $registration EE_Registration */ |
| 306 | 306 | // has this registration lost it's space ? |
| 307 | - if (isset($ejected_registrations[ $REG_ID ])) { |
|
| 307 | + if (isset($ejected_registrations[$REG_ID])) { |
|
| 308 | 308 | if ($registration->event()->is_sold_out() || $registration->event()->is_sold_out(true)) { |
| 309 | - $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
| 309 | + $sold_out_events[$registration->event()->ID()] = $registration->event(); |
|
| 310 | 310 | } else { |
| 311 | - $insufficient_spaces_available[ $registration->event()->ID() ] = $registration->event(); |
|
| 311 | + $insufficient_spaces_available[$registration->event()->ID()] = $registration->event(); |
|
| 312 | 312 | } |
| 313 | 313 | continue; |
| 314 | 314 | } |
| 315 | 315 | // event requires admin approval |
| 316 | 316 | if ($registration->status_ID() === EEM_Registration::status_id_not_approved) { |
| 317 | 317 | // add event to list of events with pre-approval reg status |
| 318 | - $registrations_requiring_pre_approval[ $REG_ID ] = $registration; |
|
| 318 | + $registrations_requiring_pre_approval[$REG_ID] = $registration; |
|
| 319 | 319 | do_action( |
| 320 | 320 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval', |
| 321 | 321 | $registration->event(), |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | ) |
| 332 | 332 | ) { |
| 333 | 333 | // add event to list of events that are sold out |
| 334 | - $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
| 334 | + $sold_out_events[$registration->event()->ID()] = $registration->event(); |
|
| 335 | 335 | do_action( |
| 336 | 336 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
| 337 | 337 | $registration->event(), |
@@ -341,38 +341,38 @@ discard block |
||
| 341 | 341 | } |
| 342 | 342 | // are they allowed to pay now and is there monies owing? |
| 343 | 343 | if ($registration->owes_monies_and_can_pay()) { |
| 344 | - $registrations_requiring_payment[ $REG_ID ] = $registration; |
|
| 344 | + $registrations_requiring_payment[$REG_ID] = $registration; |
|
| 345 | 345 | do_action( |
| 346 | 346 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment', |
| 347 | 347 | $registration->event(), |
| 348 | 348 | $this |
| 349 | 349 | ); |
| 350 | - } elseif (! $this->checkout->revisit |
|
| 350 | + } elseif ( ! $this->checkout->revisit |
|
| 351 | 351 | && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
| 352 | 352 | && $registration->ticket()->is_free() |
| 353 | 353 | ) { |
| 354 | - $registrations_for_free_events[ $registration->ticket()->ID() ] = $registration; |
|
| 354 | + $registrations_for_free_events[$registration->ticket()->ID()] = $registration; |
|
| 355 | 355 | } |
| 356 | 356 | } |
| 357 | 357 | $subsections = array(); |
| 358 | 358 | // now decide which template to load |
| 359 | - if (! empty($sold_out_events)) { |
|
| 359 | + if ( ! empty($sold_out_events)) { |
|
| 360 | 360 | $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events); |
| 361 | 361 | } |
| 362 | - if (! empty($insufficient_spaces_available)) { |
|
| 362 | + if ( ! empty($insufficient_spaces_available)) { |
|
| 363 | 363 | $subsections['insufficient_space'] = $this->_insufficient_spaces_available( |
| 364 | 364 | $insufficient_spaces_available |
| 365 | 365 | ); |
| 366 | 366 | } |
| 367 | - if (! empty($registrations_requiring_pre_approval)) { |
|
| 367 | + if ( ! empty($registrations_requiring_pre_approval)) { |
|
| 368 | 368 | $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval( |
| 369 | 369 | $registrations_requiring_pre_approval |
| 370 | 370 | ); |
| 371 | 371 | } |
| 372 | - if (! empty($registrations_for_free_events)) { |
|
| 372 | + if ( ! empty($registrations_for_free_events)) { |
|
| 373 | 373 | $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events); |
| 374 | 374 | } |
| 375 | - if (! empty($registrations_requiring_payment)) { |
|
| 375 | + if ( ! empty($registrations_requiring_payment)) { |
|
| 376 | 376 | if ($this->checkout->amount_owing > 0) { |
| 377 | 377 | // autoload Line_Item_Display classes |
| 378 | 378 | EEH_Autoloader::register_line_item_filter_autoloaders(); |
@@ -437,13 +437,13 @@ discard block |
||
| 437 | 437 | */ |
| 438 | 438 | public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) |
| 439 | 439 | { |
| 440 | - if (! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
| 440 | + if ( ! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
| 441 | 441 | return $line_item_filter_collection; |
| 442 | 442 | } |
| 443 | - if (! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout) { |
|
| 443 | + if ( ! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout) { |
|
| 444 | 444 | return $line_item_filter_collection; |
| 445 | 445 | } |
| 446 | - if (! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction) { |
|
| 446 | + if ( ! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction) { |
|
| 447 | 447 | return $line_item_filter_collection; |
| 448 | 448 | } |
| 449 | 449 | $line_item_filter_collection->add( |
@@ -483,8 +483,8 @@ discard block |
||
| 483 | 483 | ); |
| 484 | 484 | foreach ($registrations as $REG_ID => $registration) { |
| 485 | 485 | // has this registration lost it's space ? |
| 486 | - if (isset($ejected_registrations[ $REG_ID ])) { |
|
| 487 | - unset($registrations[ $REG_ID ]); |
|
| 486 | + if (isset($ejected_registrations[$REG_ID])) { |
|
| 487 | + unset($registrations[$REG_ID]); |
|
| 488 | 488 | continue; |
| 489 | 489 | } |
| 490 | 490 | } |
@@ -534,24 +534,24 @@ discard block |
||
| 534 | 534 | } |
| 535 | 535 | $EVT_ID = $registration->event_ID(); |
| 536 | 536 | $ticket = $registration->ticket(); |
| 537 | - if (! isset($tickets_remaining[ $ticket->ID() ])) { |
|
| 538 | - $tickets_remaining[ $ticket->ID() ] = $ticket->remaining(); |
|
| 537 | + if ( ! isset($tickets_remaining[$ticket->ID()])) { |
|
| 538 | + $tickets_remaining[$ticket->ID()] = $ticket->remaining(); |
|
| 539 | 539 | } |
| 540 | - if ($tickets_remaining[ $ticket->ID() ] > 0) { |
|
| 541 | - if (! isset($event_reg_count[ $EVT_ID ])) { |
|
| 542 | - $event_reg_count[ $EVT_ID ] = 0; |
|
| 540 | + if ($tickets_remaining[$ticket->ID()] > 0) { |
|
| 541 | + if ( ! isset($event_reg_count[$EVT_ID])) { |
|
| 542 | + $event_reg_count[$EVT_ID] = 0; |
|
| 543 | 543 | } |
| 544 | - $event_reg_count[ $EVT_ID ]++; |
|
| 545 | - if (! isset($event_spaces_remaining[ $EVT_ID ])) { |
|
| 546 | - $event_spaces_remaining[ $EVT_ID ] = $registration->event()->spaces_remaining_for_sale(); |
|
| 544 | + $event_reg_count[$EVT_ID]++; |
|
| 545 | + if ( ! isset($event_spaces_remaining[$EVT_ID])) { |
|
| 546 | + $event_spaces_remaining[$EVT_ID] = $registration->event()->spaces_remaining_for_sale(); |
|
| 547 | 547 | } |
| 548 | 548 | } |
| 549 | 549 | if ($revisit |
| 550 | - && ($tickets_remaining[ $ticket->ID() ] === 0 |
|
| 551 | - || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ] |
|
| 550 | + && ($tickets_remaining[$ticket->ID()] === 0 |
|
| 551 | + || $event_reg_count[$EVT_ID] > $event_spaces_remaining[$EVT_ID] |
|
| 552 | 552 | ) |
| 553 | 553 | ) { |
| 554 | - $ejected_registrations[ $REG_ID ] = $registration->event(); |
|
| 554 | + $ejected_registrations[$REG_ID] = $registration->event(); |
|
| 555 | 555 | if ($registration->status_ID() !== EEM_Registration::status_id_wait_list) { |
| 556 | 556 | /** @type EE_Registration_Processor $registration_processor */ |
| 557 | 557 | $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
@@ -611,7 +611,7 @@ discard block |
||
| 611 | 611 | foreach ($sold_out_events_array as $sold_out_event) { |
| 612 | 612 | $sold_out_events .= EEH_HTML::li( |
| 613 | 613 | EEH_HTML::span( |
| 614 | - ' ' . $sold_out_event->name(), |
|
| 614 | + ' '.$sold_out_event->name(), |
|
| 615 | 615 | '', |
| 616 | 616 | 'dashicons dashicons-marker ee-icon-size-16 pink-text' |
| 617 | 617 | ) |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | foreach ($insufficient_spaces_events_array as $event) { |
| 667 | 667 | if ($event instanceof EE_Event) { |
| 668 | 668 | $insufficient_space_events .= EEH_HTML::li( |
| 669 | - EEH_HTML::span(' ' . $event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text') |
|
| 669 | + EEH_HTML::span(' '.$event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text') |
|
| 670 | 670 | ); |
| 671 | 671 | } |
| 672 | 672 | } |
@@ -714,7 +714,7 @@ discard block |
||
| 714 | 714 | $events_requiring_pre_approval = array(); |
| 715 | 715 | foreach ($registrations_requiring_pre_approval as $registration) { |
| 716 | 716 | if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) { |
| 717 | - $events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li( |
|
| 717 | + $events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li( |
|
| 718 | 718 | EEH_HTML::span( |
| 719 | 719 | '', |
| 720 | 720 | '', |
@@ -853,7 +853,7 @@ discard block |
||
| 853 | 853 | { |
| 854 | 854 | return new EE_Form_Section_Proper( |
| 855 | 855 | array( |
| 856 | - 'html_id' => 'ee-' . $this->slug() . '-extra-hidden-inputs', |
|
| 856 | + 'html_id' => 'ee-'.$this->slug().'-extra-hidden-inputs', |
|
| 857 | 857 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
| 858 | 858 | 'subsections' => array( |
| 859 | 859 | 'spco_no_payment_required' => new EE_Hidden_Input( |
@@ -893,7 +893,7 @@ discard block |
||
| 893 | 893 | $payments += $registration->registration_payments(); |
| 894 | 894 | } |
| 895 | 895 | } |
| 896 | - if (! empty($payments)) { |
|
| 896 | + if ( ! empty($payments)) { |
|
| 897 | 897 | foreach ($payments as $payment) { |
| 898 | 898 | if ($payment instanceof EE_Registration_Payment) { |
| 899 | 899 | $this->checkout->amount_owing -= $payment->amount(); |
@@ -1017,23 +1017,23 @@ discard block |
||
| 1017 | 1017 | $payment_method_button = EEH_HTML::img( |
| 1018 | 1018 | $payment_method->button_url(), |
| 1019 | 1019 | $payment_method->name(), |
| 1020 | - 'spco-payment-method-' . $payment_method->slug() . '-btn-img', |
|
| 1020 | + 'spco-payment-method-'.$payment_method->slug().'-btn-img', |
|
| 1021 | 1021 | 'spco-payment-method-btn-img' |
| 1022 | 1022 | ); |
| 1023 | 1023 | // check if any payment methods are set as default |
| 1024 | 1024 | // if payment method is already selected OR nothing is selected and this payment method should be |
| 1025 | 1025 | // open_by_default |
| 1026 | 1026 | if (($this->checkout->selected_method_of_payment === $payment_method->slug()) |
| 1027 | - || (! $this->checkout->selected_method_of_payment && $payment_method->open_by_default()) |
|
| 1027 | + || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default()) |
|
| 1028 | 1028 | ) { |
| 1029 | 1029 | $this->checkout->selected_method_of_payment = $payment_method->slug(); |
| 1030 | 1030 | $this->_save_selected_method_of_payment(); |
| 1031 | - $default_payment_method_option[ $payment_method->slug() ] = $payment_method_button; |
|
| 1031 | + $default_payment_method_option[$payment_method->slug()] = $payment_method_button; |
|
| 1032 | 1032 | } else { |
| 1033 | - $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
|
| 1033 | + $available_payment_method_options[$payment_method->slug()] = $payment_method_button; |
|
| 1034 | 1034 | } |
| 1035 | - $payment_methods_billing_info[ $payment_method->slug( |
|
| 1036 | - ) . '-info' ] = $this->_payment_method_billing_info( |
|
| 1035 | + $payment_methods_billing_info[$payment_method->slug( |
|
| 1036 | + ).'-info'] = $this->_payment_method_billing_info( |
|
| 1037 | 1037 | $payment_method |
| 1038 | 1038 | ); |
| 1039 | 1039 | } |
@@ -1069,7 +1069,7 @@ discard block |
||
| 1069 | 1069 | */ |
| 1070 | 1070 | protected function _get_available_payment_methods() |
| 1071 | 1071 | { |
| 1072 | - if (! empty($this->checkout->available_payment_methods)) { |
|
| 1072 | + if ( ! empty($this->checkout->available_payment_methods)) { |
|
| 1073 | 1073 | return $this->checkout->available_payment_methods; |
| 1074 | 1074 | } |
| 1075 | 1075 | $available_payment_methods = array(); |
@@ -1084,7 +1084,7 @@ discard block |
||
| 1084 | 1084 | ); |
| 1085 | 1085 | foreach ($payment_methods as $payment_method) { |
| 1086 | 1086 | if ($payment_method instanceof EE_Payment_Method) { |
| 1087 | - $available_payment_methods[ $payment_method->slug() ] = $payment_method; |
|
| 1087 | + $available_payment_methods[$payment_method->slug()] = $payment_method; |
|
| 1088 | 1088 | } |
| 1089 | 1089 | } |
| 1090 | 1090 | return $available_payment_methods; |
@@ -1179,7 +1179,7 @@ discard block |
||
| 1179 | 1179 | ); |
| 1180 | 1180 | return new EE_Form_Section_Proper( |
| 1181 | 1181 | array( |
| 1182 | - 'html_id' => 'spco-payment-method-info-' . $payment_method->slug(), |
|
| 1182 | + 'html_id' => 'spco-payment-method-info-'.$payment_method->slug(), |
|
| 1183 | 1183 | 'html_class' => 'spco-payment-method-info-dv', |
| 1184 | 1184 | // only display the selected or default PM |
| 1185 | 1185 | 'html_style' => $currently_selected ? '' : 'display:none;', |
@@ -1209,7 +1209,7 @@ discard block |
||
| 1209 | 1209 | // how have they chosen to pay? |
| 1210 | 1210 | $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
| 1211 | 1211 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
| 1212 | - if (! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
| 1212 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
| 1213 | 1213 | return false; |
| 1214 | 1214 | } |
| 1215 | 1215 | if (apply_filters( |
@@ -1381,7 +1381,7 @@ discard block |
||
| 1381 | 1381 | */ |
| 1382 | 1382 | public function switch_payment_method() |
| 1383 | 1383 | { |
| 1384 | - if (! $this->_verify_payment_method_is_set()) { |
|
| 1384 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
| 1385 | 1385 | return false; |
| 1386 | 1386 | } |
| 1387 | 1387 | if (apply_filters( |
@@ -1516,7 +1516,7 @@ discard block |
||
| 1516 | 1516 | } |
| 1517 | 1517 | } |
| 1518 | 1518 | // verify payment method |
| 1519 | - if (! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
| 1519 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
| 1520 | 1520 | // get payment method for selected method of payment |
| 1521 | 1521 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
| 1522 | 1522 | } |
@@ -1541,7 +1541,7 @@ discard block |
||
| 1541 | 1541 | */ |
| 1542 | 1542 | public function save_payer_details_via_ajax() |
| 1543 | 1543 | { |
| 1544 | - if (! $this->_verify_payment_method_is_set()) { |
|
| 1544 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
| 1545 | 1545 | return; |
| 1546 | 1546 | } |
| 1547 | 1547 | // generate billing form for selected method of payment if it hasn't been done already |
@@ -1551,7 +1551,7 @@ discard block |
||
| 1551 | 1551 | ); |
| 1552 | 1552 | } |
| 1553 | 1553 | // generate primary attendee from payer info if applicable |
| 1554 | - if (! $this->checkout->transaction_has_primary_registrant()) { |
|
| 1554 | + if ( ! $this->checkout->transaction_has_primary_registrant()) { |
|
| 1555 | 1555 | $attendee = $this->_create_attendee_from_request_data(); |
| 1556 | 1556 | if ($attendee instanceof EE_Attendee) { |
| 1557 | 1557 | foreach ($this->checkout->transaction->registrations() as $registration) { |
@@ -1582,7 +1582,7 @@ discard block |
||
| 1582 | 1582 | { |
| 1583 | 1583 | // get State ID |
| 1584 | 1584 | $STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : ''; |
| 1585 | - if (! empty($STA_ID)) { |
|
| 1585 | + if ( ! empty($STA_ID)) { |
|
| 1586 | 1586 | // can we get state object from name ? |
| 1587 | 1587 | EE_Registry::instance()->load_model('State'); |
| 1588 | 1588 | $state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID'); |
@@ -1590,7 +1590,7 @@ discard block |
||
| 1590 | 1590 | } |
| 1591 | 1591 | // get Country ISO |
| 1592 | 1592 | $CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : ''; |
| 1593 | - if (! empty($CNT_ISO)) { |
|
| 1593 | + if ( ! empty($CNT_ISO)) { |
|
| 1594 | 1594 | // can we get country object from name ? |
| 1595 | 1595 | EE_Registry::instance()->load_model('Country'); |
| 1596 | 1596 | $country = EEM_Country::instance()->get_col( |
@@ -1623,7 +1623,7 @@ discard block |
||
| 1623 | 1623 | } |
| 1624 | 1624 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, |
| 1625 | 1625 | // AND email address |
| 1626 | - if (! empty($attendee_data['ATT_fname']) |
|
| 1626 | + if ( ! empty($attendee_data['ATT_fname']) |
|
| 1627 | 1627 | && ! empty($attendee_data['ATT_lname']) |
| 1628 | 1628 | && ! empty($attendee_data['ATT_email']) |
| 1629 | 1629 | ) { |
@@ -1838,7 +1838,7 @@ discard block |
||
| 1838 | 1838 | private function _process_payment() |
| 1839 | 1839 | { |
| 1840 | 1840 | // basically confirm that the event hasn't sold out since they hit the page |
| 1841 | - if (! $this->_last_second_ticket_verifications()) { |
|
| 1841 | + if ( ! $this->_last_second_ticket_verifications()) { |
|
| 1842 | 1842 | return false; |
| 1843 | 1843 | } |
| 1844 | 1844 | // ya gotta make a choice man |
@@ -1849,7 +1849,7 @@ discard block |
||
| 1849 | 1849 | return false; |
| 1850 | 1850 | } |
| 1851 | 1851 | // get EE_Payment_Method object |
| 1852 | - if (! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
| 1852 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
| 1853 | 1853 | return false; |
| 1854 | 1854 | } |
| 1855 | 1855 | // setup billing form |
@@ -1858,12 +1858,12 @@ discard block |
||
| 1858 | 1858 | $this->checkout->payment_method |
| 1859 | 1859 | ); |
| 1860 | 1860 | // bad billing form ? |
| 1861 | - if (! $this->_billing_form_is_valid()) { |
|
| 1861 | + if ( ! $this->_billing_form_is_valid()) { |
|
| 1862 | 1862 | return false; |
| 1863 | 1863 | } |
| 1864 | 1864 | } |
| 1865 | 1865 | // ensure primary registrant has been fully processed |
| 1866 | - if (! $this->_setup_primary_registrant_prior_to_payment()) { |
|
| 1866 | + if ( ! $this->_setup_primary_registrant_prior_to_payment()) { |
|
| 1867 | 1867 | return false; |
| 1868 | 1868 | } |
| 1869 | 1869 | // if session is close to expiring (under 10 minutes by default) |
@@ -1918,7 +1918,7 @@ discard block |
||
| 1918 | 1918 | protected function _last_second_ticket_verifications() |
| 1919 | 1919 | { |
| 1920 | 1920 | // don't bother re-validating if not a return visit |
| 1921 | - if (! $this->checkout->revisit) { |
|
| 1921 | + if ( ! $this->checkout->revisit) { |
|
| 1922 | 1922 | return true; |
| 1923 | 1923 | } |
| 1924 | 1924 | $registrations = $this->checkout->transaction->registrations(); |
@@ -1984,7 +1984,7 @@ discard block |
||
| 1984 | 1984 | */ |
| 1985 | 1985 | private function _billing_form_is_valid() |
| 1986 | 1986 | { |
| 1987 | - if (! $this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
| 1987 | + if ( ! $this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
| 1988 | 1988 | return true; |
| 1989 | 1989 | } |
| 1990 | 1990 | if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) { |
@@ -2103,7 +2103,7 @@ discard block |
||
| 2103 | 2103 | { |
| 2104 | 2104 | // convert billing form data into an attendee |
| 2105 | 2105 | $this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data(); |
| 2106 | - if (! $this->checkout->primary_attendee_obj instanceof EE_Attendee) { |
|
| 2106 | + if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) { |
|
| 2107 | 2107 | EE_Error::add_error( |
| 2108 | 2108 | sprintf( |
| 2109 | 2109 | esc_html__( |
@@ -2120,7 +2120,7 @@ discard block |
||
| 2120 | 2120 | return false; |
| 2121 | 2121 | } |
| 2122 | 2122 | $primary_registration = $this->checkout->transaction->primary_registration(); |
| 2123 | - if (! $primary_registration instanceof EE_Registration) { |
|
| 2123 | + if ( ! $primary_registration instanceof EE_Registration) { |
|
| 2124 | 2124 | EE_Error::add_error( |
| 2125 | 2125 | sprintf( |
| 2126 | 2126 | esc_html__( |
@@ -2136,7 +2136,7 @@ discard block |
||
| 2136 | 2136 | ); |
| 2137 | 2137 | return false; |
| 2138 | 2138 | } |
| 2139 | - if (! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee') |
|
| 2139 | + if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee') |
|
| 2140 | 2140 | instanceof |
| 2141 | 2141 | EE_Attendee |
| 2142 | 2142 | ) { |
@@ -2182,8 +2182,8 @@ discard block |
||
| 2182 | 2182 | return null; |
| 2183 | 2183 | } |
| 2184 | 2184 | // get EE_Payment_Method object |
| 2185 | - if (isset($this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ])) { |
|
| 2186 | - $payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ]; |
|
| 2185 | + if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) { |
|
| 2186 | + $payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment]; |
|
| 2187 | 2187 | } else { |
| 2188 | 2188 | // load EEM_Payment_Method |
| 2189 | 2189 | EE_Registry::instance()->load_model('Payment_Method'); |
@@ -2192,7 +2192,7 @@ discard block |
||
| 2192 | 2192 | $payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment); |
| 2193 | 2193 | } |
| 2194 | 2194 | // verify $payment_method |
| 2195 | - if (! $payment_method instanceof EE_Payment_Method) { |
|
| 2195 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
| 2196 | 2196 | // not a payment |
| 2197 | 2197 | EE_Error::add_error( |
| 2198 | 2198 | sprintf( |
@@ -2210,7 +2210,7 @@ discard block |
||
| 2210 | 2210 | return null; |
| 2211 | 2211 | } |
| 2212 | 2212 | // and verify it has a valid Payment_Method Type object |
| 2213 | - if (! $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
| 2213 | + if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
| 2214 | 2214 | // not a payment |
| 2215 | 2215 | EE_Error::add_error( |
| 2216 | 2216 | sprintf( |
@@ -2248,7 +2248,7 @@ discard block |
||
| 2248 | 2248 | $payment = null; |
| 2249 | 2249 | $this->checkout->transaction->save(); |
| 2250 | 2250 | $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
| 2251 | - if (! $payment_processor instanceof EE_Payment_Processor) { |
|
| 2251 | + if ( ! $payment_processor instanceof EE_Payment_Processor) { |
|
| 2252 | 2252 | return false; |
| 2253 | 2253 | } |
| 2254 | 2254 | try { |
@@ -2352,7 +2352,7 @@ discard block |
||
| 2352 | 2352 | return true; |
| 2353 | 2353 | } |
| 2354 | 2354 | // verify payment object |
| 2355 | - if (! $payment instanceof EE_Payment) { |
|
| 2355 | + if ( ! $payment instanceof EE_Payment) { |
|
| 2356 | 2356 | // not a payment |
| 2357 | 2357 | EE_Error::add_error( |
| 2358 | 2358 | sprintf( |
@@ -2392,7 +2392,7 @@ discard block |
||
| 2392 | 2392 | return true; |
| 2393 | 2393 | // On-Site payment? |
| 2394 | 2394 | } elseif ($this->checkout->payment_method->is_on_site()) { |
| 2395 | - if (! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) { |
|
| 2395 | + if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) { |
|
| 2396 | 2396 | // $this->_setup_redirect_for_next_step(); |
| 2397 | 2397 | $this->checkout->continue_reg = false; |
| 2398 | 2398 | } |
@@ -2420,7 +2420,7 @@ discard block |
||
| 2420 | 2420 | EE_Registry::instance()->CFG->organization->get_pretty('email') |
| 2421 | 2421 | ); |
| 2422 | 2422 | if ($payment instanceof EE_Payment && $payment->gateway_response()) { |
| 2423 | - $error_message = $error_message . '<br/>' . $payment->gateway_response(); |
|
| 2423 | + $error_message = $error_message.'<br/>'.$payment->gateway_response(); |
|
| 2424 | 2424 | } |
| 2425 | 2425 | $this->checkout->continue_reg = false; |
| 2426 | 2426 | EE_Error::add_error( |
@@ -2512,7 +2512,7 @@ discard block |
||
| 2512 | 2512 | break; |
| 2513 | 2513 | // bad payment |
| 2514 | 2514 | case EEM_Payment::status_id_failed: |
| 2515 | - if (! empty($msg)) { |
|
| 2515 | + if ( ! empty($msg)) { |
|
| 2516 | 2516 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
| 2517 | 2517 | return false; |
| 2518 | 2518 | } |
@@ -2573,11 +2573,11 @@ discard block |
||
| 2573 | 2573 | // how have they chosen to pay? |
| 2574 | 2574 | $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
| 2575 | 2575 | // get EE_Payment_Method object |
| 2576 | - if (! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
| 2576 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
| 2577 | 2577 | $this->checkout->continue_reg = false; |
| 2578 | 2578 | return false; |
| 2579 | 2579 | } |
| 2580 | - if (! $this->checkout->payment_method->is_off_site()) { |
|
| 2580 | + if ( ! $this->checkout->payment_method->is_off_site()) { |
|
| 2581 | 2581 | return false; |
| 2582 | 2582 | } |
| 2583 | 2583 | $this->_validate_offsite_return(); |
@@ -2595,7 +2595,7 @@ discard block |
||
| 2595 | 2595 | // verify TXN |
| 2596 | 2596 | if ($this->checkout->transaction instanceof EE_Transaction) { |
| 2597 | 2597 | $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
| 2598 | - if (! $gateway instanceof EE_Offsite_Gateway) { |
|
| 2598 | + if ( ! $gateway instanceof EE_Offsite_Gateway) { |
|
| 2599 | 2599 | $this->checkout->continue_reg = false; |
| 2600 | 2600 | return false; |
| 2601 | 2601 | } |
@@ -2712,13 +2712,13 @@ discard block |
||
| 2712 | 2712 | */ |
| 2713 | 2713 | private function _redirect_wayward_request(EE_Registration $primary_registrant) |
| 2714 | 2714 | { |
| 2715 | - if (! $primary_registrant instanceof EE_Registration) { |
|
| 2715 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
| 2716 | 2716 | // try redirecting based on the current TXN |
| 2717 | 2717 | $primary_registrant = $this->checkout->transaction instanceof EE_Transaction |
| 2718 | 2718 | ? $this->checkout->transaction->primary_registration() |
| 2719 | 2719 | : null; |
| 2720 | 2720 | } |
| 2721 | - if (! $primary_registrant instanceof EE_Registration) { |
|
| 2721 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
| 2722 | 2722 | EE_Error::add_error( |
| 2723 | 2723 | sprintf( |
| 2724 | 2724 | esc_html__( |
@@ -2788,7 +2788,7 @@ discard block |
||
| 2788 | 2788 | $payment = $this->checkout->transaction->last_payment(); |
| 2789 | 2789 | // $payment_source = 'last_payment after Exception'; |
| 2790 | 2790 | // but if we STILL don't have a payment object |
| 2791 | - if (! $payment instanceof EE_Payment) { |
|
| 2791 | + if ( ! $payment instanceof EE_Payment) { |
|
| 2792 | 2792 | // then we'll object ! ( not object like a thing... but object like what a lawyer says ! ) |
| 2793 | 2793 | $this->_handle_payment_processor_exception($e); |
| 2794 | 2794 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | { |
| 50 | 50 | $this->_slug = 'attendee_information'; |
| 51 | 51 | $this->_name = esc_html__('Attendee Information', 'event_espresso'); |
| 52 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . '/attendee_info_main.template.php'; |
|
| 52 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.'/attendee_info_main.template.php'; |
|
| 53 | 53 | $this->checkout = $checkout; |
| 54 | 54 | $this->_reset_success_message(); |
| 55 | 55 | $this->set_instructions( |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | ); |
| 144 | 144 | |
| 145 | 145 | // if this isn't a revisit, and they have the privacy consent box enalbed, add it |
| 146 | - if (! $this->checkout->revisit && $reg_config->isConsentCheckboxEnabled()) { |
|
| 146 | + if ( ! $this->checkout->revisit && $reg_config->isConsentCheckboxEnabled()) { |
|
| 147 | 147 | $extra_inputs_section->add_subsections( |
| 148 | 148 | array( |
| 149 | 149 | 'consent_box' => new EE_Form_Section_Proper( |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | 'layout_strategy' => |
| 152 | 152 | new EE_Template_Layout( |
| 153 | 153 | array( |
| 154 | - 'input_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . '/privacy_consent.template.php', |
|
| 154 | + 'input_template_file' => SPCO_REG_STEPS_PATH.$this->_slug.'/privacy_consent.template.php', |
|
| 155 | 155 | ) |
| 156 | 156 | ), |
| 157 | 157 | 'subsections' => array( |
@@ -189,13 +189,13 @@ discard block |
||
| 189 | 189 | if ($registration instanceof EE_Registration |
| 190 | 190 | && $this->checkout->visit_allows_processing_of_this_registration($registration) |
| 191 | 191 | ) { |
| 192 | - $subsections[ $registration->reg_url_link() ] = $this->_registrations_reg_form($registration); |
|
| 193 | - if (! $this->checkout->admin_request) { |
|
| 194 | - $template_args['registrations'][ $registration->reg_url_link() ] = $registration; |
|
| 195 | - $template_args['ticket_count'][ $registration->ticket()->ID() ] = isset( |
|
| 196 | - $template_args['ticket_count'][ $registration->ticket()->ID() ] |
|
| 192 | + $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration); |
|
| 193 | + if ( ! $this->checkout->admin_request) { |
|
| 194 | + $template_args['registrations'][$registration->reg_url_link()] = $registration; |
|
| 195 | + $template_args['ticket_count'][$registration->ticket()->ID()] = isset( |
|
| 196 | + $template_args['ticket_count'][$registration->ticket()->ID()] |
|
| 197 | 197 | ) |
| 198 | - ? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1 |
|
| 198 | + ? $template_args['ticket_count'][$registration->ticket()->ID()] + 1 |
|
| 199 | 199 | : 1; |
| 200 | 200 | $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
| 201 | 201 | $this->checkout->cart->get_grand_total(), |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | $ticket_line_item = is_array($ticket_line_item) |
| 206 | 206 | ? reset($ticket_line_item) |
| 207 | 207 | : $ticket_line_item; |
| 208 | - $template_args['ticket_line_item'][ $registration->ticket()->ID() ] = |
|
| 208 | + $template_args['ticket_line_item'][$registration->ticket()->ID()] = |
|
| 209 | 209 | $Line_Item_Display->display_line_item($ticket_line_item); |
| 210 | 210 | } |
| 211 | 211 | if ($registration->is_primary_registrant()) { |
@@ -218,10 +218,10 @@ discard block |
||
| 218 | 218 | ? $this->_copy_attendee_info_form() |
| 219 | 219 | : $this->_auto_copy_attendee_info(); |
| 220 | 220 | // generate hidden input |
| 221 | - if (isset($subsections[ $primary_registrant ]) |
|
| 222 | - && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
| 221 | + if (isset($subsections[$primary_registrant]) |
|
| 222 | + && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper |
|
| 223 | 223 | ) { |
| 224 | - $subsections[ $primary_registrant ]->add_subsections( |
|
| 224 | + $subsections[$primary_registrant]->add_subsections( |
|
| 225 | 225 | $copy_options, |
| 226 | 226 | 'primary_registrant', |
| 227 | 227 | false |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | if ($question_groups) { |
| 289 | 289 | // array of params to pass to parent constructor |
| 290 | 290 | $form_args = array( |
| 291 | - 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
| 291 | + 'html_id' => 'ee-registration-'.$registration->reg_url_link(), |
|
| 292 | 292 | 'html_class' => 'ee-reg-form-attendee-dv', |
| 293 | 293 | 'html_style' => $this->checkout->admin_request |
| 294 | 294 | ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | ); |
| 311 | 311 | foreach ($question_groups as $question_group) { |
| 312 | 312 | if ($question_group instanceof EE_Question_Group) { |
| 313 | - $form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form( |
|
| 313 | + $form_args['subsections'][$question_group->identifier()] = $this->_question_group_reg_form( |
|
| 314 | 314 | $registration, |
| 315 | 315 | $question_group |
| 316 | 316 | ); |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | // generate hidden input |
| 357 | 357 | return new EE_Hidden_Input( |
| 358 | 358 | array( |
| 359 | - 'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(), |
|
| 359 | + 'html_id' => 'additional-attendee-reg-info-'.$registration->reg_url_link(), |
|
| 360 | 360 | 'default' => $additional_attendee_reg_info, |
| 361 | 361 | ) |
| 362 | 362 | ); |
@@ -377,12 +377,12 @@ discard block |
||
| 377 | 377 | { |
| 378 | 378 | // array of params to pass to parent constructor |
| 379 | 379 | $form_args = array( |
| 380 | - 'html_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' . $registration->ID(), |
|
| 380 | + 'html_id' => 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-'.$registration->ID(), |
|
| 381 | 381 | 'html_class' => $this->checkout->admin_request |
| 382 | 382 | ? 'form-table ee-reg-form-qstn-grp-dv' |
| 383 | 383 | : 'ee-reg-form-qstn-grp-dv', |
| 384 | - 'html_label_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' |
|
| 385 | - . $registration->ID() . '-lbl', |
|
| 384 | + 'html_label_id' => 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-' |
|
| 385 | + . $registration->ID().'-lbl', |
|
| 386 | 386 | 'subsections' => array( |
| 387 | 387 | 'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group), |
| 388 | 388 | ), |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | // where params |
| 394 | 394 | $query_params = array('QST_deleted' => 0); |
| 395 | 395 | // don't load admin only questions on the frontend |
| 396 | - if (! $this->checkout->admin_request) { |
|
| 396 | + if ( ! $this->checkout->admin_request) { |
|
| 397 | 397 | $query_params['QST_admin_only'] = array('!=', true); |
| 398 | 398 | } |
| 399 | 399 | $questions = $question_group->get_many_related( |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | $identifier = $question->is_system_question() |
| 428 | 428 | ? $question->system_ID() |
| 429 | 429 | : $question->ID(); |
| 430 | - $form_args['subsections'][ $identifier ] = $this->reg_form_question($registration, $question); |
|
| 430 | + $form_args['subsections'][$identifier] = $this->reg_form_question($registration, $question); |
|
| 431 | 431 | } |
| 432 | 432 | } |
| 433 | 433 | $form_args['subsections'] = apply_filters( |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | { |
| 540 | 540 | return new EE_Form_Section_HTML( |
| 541 | 541 | EEH_Template::locate_template( |
| 542 | - SPCO_REG_STEPS_PATH . $this->_slug . '/_auto_copy_attendee_info.template.php', |
|
| 542 | + SPCO_REG_STEPS_PATH.$this->_slug.'/_auto_copy_attendee_info.template.php', |
|
| 543 | 543 | apply_filters( |
| 544 | 544 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', |
| 545 | 545 | array() |
@@ -572,17 +572,17 @@ discard block |
||
| 572 | 572 | if ($registration->ticket()->ID() !== $prev_ticket) { |
| 573 | 573 | $item_name = $registration->ticket()->name(); |
| 574 | 574 | $item_name .= $registration->ticket()->description() !== '' |
| 575 | - ? ' - ' . $registration->ticket()->description() |
|
| 575 | + ? ' - '.$registration->ticket()->description() |
|
| 576 | 576 | : ''; |
| 577 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID( |
|
| 578 | - ) . ']' ] = |
|
| 577 | + $copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-'.$registration->ticket()->ID( |
|
| 578 | + ).']'] = |
|
| 579 | 579 | new EE_Form_Section_HTML( |
| 580 | - '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>' |
|
| 580 | + '<h6 class="spco-copy-attendee-event-hdr">'.$item_name.'</h6>' |
|
| 581 | 581 | ); |
| 582 | 582 | $prev_ticket = $registration->ticket()->ID(); |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] = |
|
| 585 | + $copy_attendee_info_inputs['spco_copy_attendee_chk['.$registration->ID().']'] = |
|
| 586 | 586 | new EE_Checkbox_Multi_Input( |
| 587 | 587 | array( |
| 588 | 588 | $registration->ID() => sprintf( |
@@ -591,7 +591,7 @@ discard block |
||
| 591 | 591 | ), |
| 592 | 592 | ), |
| 593 | 593 | array( |
| 594 | - 'html_id' => 'spco-copy-attendee-chk-' . $registration->reg_url_link(), |
|
| 594 | + 'html_id' => 'spco-copy-attendee-chk-'.$registration->reg_url_link(), |
|
| 595 | 595 | 'html_class' => 'spco-copy-attendee-chk ee-do-not-validate', |
| 596 | 596 | 'display_html_label_text' => false, |
| 597 | 597 | ) |
@@ -656,14 +656,14 @@ discard block |
||
| 656 | 656 | } |
| 657 | 657 | // verify instance |
| 658 | 658 | if ($answer instanceof EE_Answer) { |
| 659 | - if (! empty($answer_value)) { |
|
| 659 | + if ( ! empty($answer_value)) { |
|
| 660 | 660 | $answer->set('ANS_value', $answer_value); |
| 661 | 661 | } |
| 662 | 662 | $answer->cache('Question', $question); |
| 663 | 663 | // remember system ID had a bug where sometimes it could be null |
| 664 | 664 | $answer_cache_id = $question->is_system_question() |
| 665 | - ? $question->system_ID() . '-' . $registration->reg_url_link() |
|
| 666 | - : $question->ID() . '-' . $registration->reg_url_link(); |
|
| 665 | + ? $question->system_ID().'-'.$registration->reg_url_link() |
|
| 666 | + : $question->ID().'-'.$registration->reg_url_link(); |
|
| 667 | 667 | $registration->cache('Answer', $answer, $answer_cache_id); |
| 668 | 668 | } |
| 669 | 669 | return $this->_generate_question_input($registration, $question, $answer); |
@@ -686,7 +686,7 @@ discard block |
||
| 686 | 686 | $identifier = $question->is_system_question() |
| 687 | 687 | ? $question->system_ID() |
| 688 | 688 | : $question->ID(); |
| 689 | - $this->_required_questions[ $identifier ] = $question->required() ? true : false; |
|
| 689 | + $this->_required_questions[$identifier] = $question->required() ? true : false; |
|
| 690 | 690 | add_filter( |
| 691 | 691 | 'FHEE__EE_Question__generate_form_input__country_options', |
| 692 | 692 | array($this, 'use_cached_countries_for_form_input'), |
@@ -700,17 +700,17 @@ discard block |
||
| 700 | 700 | 4 |
| 701 | 701 | ); |
| 702 | 702 | $input_constructor_args = array( |
| 703 | - 'html_name' => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']', |
|
| 704 | - 'html_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
| 705 | - 'html_class' => 'ee-reg-qstn ee-reg-qstn-' . $identifier, |
|
| 706 | - 'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
| 703 | + 'html_name' => 'ee_reg_qstn['.$registration->ID().']['.$identifier.']', |
|
| 704 | + 'html_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier, |
|
| 705 | + 'html_class' => 'ee-reg-qstn ee-reg-qstn-'.$identifier, |
|
| 706 | + 'html_label_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier, |
|
| 707 | 707 | 'html_label_class' => 'ee-reg-qstn', |
| 708 | 708 | ); |
| 709 | 709 | $input_constructor_args['html_label_id'] .= '-lbl'; |
| 710 | 710 | if ($answer instanceof EE_Answer && $answer->ID()) { |
| 711 | - $input_constructor_args['html_name'] .= '[' . $answer->ID() . ']'; |
|
| 712 | - $input_constructor_args['html_id'] .= '-' . $answer->ID(); |
|
| 713 | - $input_constructor_args['html_label_id'] .= '-' . $answer->ID(); |
|
| 711 | + $input_constructor_args['html_name'] .= '['.$answer->ID().']'; |
|
| 712 | + $input_constructor_args['html_id'] .= '-'.$answer->ID(); |
|
| 713 | + $input_constructor_args['html_label_id'] .= '-'.$answer->ID(); |
|
| 714 | 714 | } |
| 715 | 715 | $form_input = $question->generate_form_input( |
| 716 | 716 | $registration, |
@@ -754,10 +754,10 @@ discard block |
||
| 754 | 754 | $countries = $this->checkout->action === 'process_reg_step' |
| 755 | 755 | ? EEM_Country::instance()->get_all_countries() |
| 756 | 756 | : EEM_Country::instance()->get_all_active_countries(); |
| 757 | - if (! empty($countries)) { |
|
| 757 | + if ( ! empty($countries)) { |
|
| 758 | 758 | foreach ($countries as $country) { |
| 759 | 759 | if ($country instanceof EE_Country) { |
| 760 | - $country_options[ $country->ID() ] = $country->name(); |
|
| 760 | + $country_options[$country->ID()] = $country->name(); |
|
| 761 | 761 | } |
| 762 | 762 | } |
| 763 | 763 | } |
@@ -804,10 +804,10 @@ discard block |
||
| 804 | 804 | $states = $this->checkout->action === 'process_reg_step' |
| 805 | 805 | ? EEM_State::instance()->get_all_states() |
| 806 | 806 | : EEM_State::instance()->get_all_active_states(); |
| 807 | - if (! empty($states)) { |
|
| 807 | + if ( ! empty($states)) { |
|
| 808 | 808 | foreach ($states as $state) { |
| 809 | 809 | if ($state instanceof EE_State) { |
| 810 | - $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name(); |
|
| 810 | + $state_options[$state->country()->name()][$state->ID()] = $state->name(); |
|
| 811 | 811 | } |
| 812 | 812 | } |
| 813 | 813 | } |
@@ -854,7 +854,7 @@ discard block |
||
| 854 | 854 | ); |
| 855 | 855 | return false; |
| 856 | 856 | } |
| 857 | - if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
| 857 | + if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
| 858 | 858 | EE_Error::add_error( |
| 859 | 859 | esc_html__( |
| 860 | 860 | 'A valid transaction could not be initiated for processing your registrations.', |
@@ -881,7 +881,7 @@ discard block |
||
| 881 | 881 | '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.', |
| 882 | 882 | 'event_espresso' |
| 883 | 883 | ), |
| 884 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
| 884 | + '<a href="'.get_post_type_archive_link('espresso_events').'" >', |
|
| 885 | 885 | '</a>', |
| 886 | 886 | '<br />' |
| 887 | 887 | ); |
@@ -901,7 +901,7 @@ discard block |
||
| 901 | 901 | // but return immediately if the previous step exited early due to errors |
| 902 | 902 | return false; |
| 903 | 903 | } |
| 904 | - if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
| 904 | + if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
| 905 | 905 | // generate a correctly translated string for all possible singular/plural combinations |
| 906 | 906 | if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
| 907 | 907 | $error_msg = sprintf( |
@@ -984,7 +984,7 @@ discard block |
||
| 984 | 984 | // grab the saved registrations from the transaction |
| 985 | 985 | foreach ($registrations as $registration) { |
| 986 | 986 | // verify EE_Registration object |
| 987 | - if (! $registration instanceof EE_Registration) { |
|
| 987 | + if ( ! $registration instanceof EE_Registration) { |
|
| 988 | 988 | EE_Error::add_error( |
| 989 | 989 | esc_html__( |
| 990 | 990 | 'An invalid Registration object was discovered when attempting to process your registration information.', |
@@ -999,12 +999,12 @@ discard block |
||
| 999 | 999 | /** @var string $reg_url_link */ |
| 1000 | 1000 | $reg_url_link = $registration->reg_url_link(); |
| 1001 | 1001 | // reg_url_link exists ? |
| 1002 | - if (! empty($reg_url_link)) { |
|
| 1002 | + if ( ! empty($reg_url_link)) { |
|
| 1003 | 1003 | // should this registration be processed during this visit ? |
| 1004 | 1004 | if ($this->checkout->visit_allows_processing_of_this_registration($registration)) { |
| 1005 | 1005 | // if NOT revisiting, then let's save the registration now, |
| 1006 | 1006 | // so that we have a REG_ID to use when generating other objects |
| 1007 | - if (! $this->checkout->revisit) { |
|
| 1007 | + if ( ! $this->checkout->revisit) { |
|
| 1008 | 1008 | $registration->save(); |
| 1009 | 1009 | } |
| 1010 | 1010 | /** |
@@ -1028,18 +1028,18 @@ discard block |
||
| 1028 | 1028 | |
| 1029 | 1029 | // Houston, we have a registration! |
| 1030 | 1030 | $att_nmbr++; |
| 1031 | - $this->_attendee_data[ $reg_url_link ] = array(); |
|
| 1031 | + $this->_attendee_data[$reg_url_link] = array(); |
|
| 1032 | 1032 | // grab any existing related answer objects |
| 1033 | 1033 | $this->_registration_answers = $registration->answers(); |
| 1034 | 1034 | // unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ); |
| 1035 | - if (isset($valid_data[ $reg_url_link ])) { |
|
| 1035 | + if (isset($valid_data[$reg_url_link])) { |
|
| 1036 | 1036 | // do we need to copy basic info from primary attendee ? |
| 1037 | - $copy_primary = isset($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) |
|
| 1038 | - && absint($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) === 0; |
|
| 1037 | + $copy_primary = isset($valid_data[$reg_url_link]['additional_attendee_reg_info']) |
|
| 1038 | + && absint($valid_data[$reg_url_link]['additional_attendee_reg_info']) === 0; |
|
| 1039 | 1039 | // filter form input data for this registration |
| 1040 | - $valid_data[ $reg_url_link ] = (array) apply_filters( |
|
| 1040 | + $valid_data[$reg_url_link] = (array) apply_filters( |
|
| 1041 | 1041 | 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
| 1042 | - $valid_data[ $reg_url_link ] |
|
| 1042 | + $valid_data[$reg_url_link] |
|
| 1043 | 1043 | ); |
| 1044 | 1044 | if (isset($valid_data['primary_attendee'])) { |
| 1045 | 1045 | $primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee']) |
@@ -1048,12 +1048,12 @@ discard block |
||
| 1048 | 1048 | unset($valid_data['primary_attendee']); |
| 1049 | 1049 | } |
| 1050 | 1050 | // now loop through our array of valid post data && process attendee reg forms |
| 1051 | - foreach ($valid_data[ $reg_url_link ] as $form_section => $form_inputs) { |
|
| 1052 | - if (! in_array($form_section, $non_input_form_sections, true)) { |
|
| 1051 | + foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) { |
|
| 1052 | + if ( ! in_array($form_section, $non_input_form_sections, true)) { |
|
| 1053 | 1053 | foreach ($form_inputs as $form_input => $input_value) { |
| 1054 | 1054 | // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ ); |
| 1055 | 1055 | // check for critical inputs |
| 1056 | - if (! $this->_verify_critical_attendee_details_are_set_and_validate_email( |
|
| 1056 | + if ( ! $this->_verify_critical_attendee_details_are_set_and_validate_email( |
|
| 1057 | 1057 | $form_input, |
| 1058 | 1058 | $input_value |
| 1059 | 1059 | ) |
@@ -1065,15 +1065,15 @@ discard block |
||
| 1065 | 1065 | && ! empty($input_value) |
| 1066 | 1066 | && $reg_url_link === $primary_registrant['line_item_id'] |
| 1067 | 1067 | ) { |
| 1068 | - $primary_registrant[ $form_input ] = $input_value; |
|
| 1068 | + $primary_registrant[$form_input] = $input_value; |
|
| 1069 | 1069 | } elseif ($copy_primary |
| 1070 | 1070 | && $input_value === null |
| 1071 | - && isset($primary_registrant[ $form_input ]) |
|
| 1071 | + && isset($primary_registrant[$form_input]) |
|
| 1072 | 1072 | ) { |
| 1073 | - $input_value = $primary_registrant[ $form_input ]; |
|
| 1073 | + $input_value = $primary_registrant[$form_input]; |
|
| 1074 | 1074 | } |
| 1075 | 1075 | // now attempt to save the input data |
| 1076 | - if (! $this->_save_registration_form_input( |
|
| 1076 | + if ( ! $this->_save_registration_form_input( |
|
| 1077 | 1077 | $registration, |
| 1078 | 1078 | $form_input, |
| 1079 | 1079 | $input_value |
@@ -1109,15 +1109,15 @@ discard block |
||
| 1109 | 1109 | $attendee = $this->checkout->primary_attendee_obj; |
| 1110 | 1110 | } else { |
| 1111 | 1111 | // ensure critical details are set for additional attendees |
| 1112 | - $this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1 |
|
| 1112 | + $this->_attendee_data[$reg_url_link] = $att_nmbr > 1 |
|
| 1113 | 1113 | ? $this->_copy_critical_attendee_details_from_primary_registrant( |
| 1114 | - $this->_attendee_data[ $reg_url_link ] |
|
| 1114 | + $this->_attendee_data[$reg_url_link] |
|
| 1115 | 1115 | ) |
| 1116 | - : $this->_attendee_data[ $reg_url_link ]; |
|
| 1116 | + : $this->_attendee_data[$reg_url_link]; |
|
| 1117 | 1117 | // execute create attendee command (which may return an existing attendee) |
| 1118 | 1118 | $attendee = EE_Registry::instance()->BUS->execute( |
| 1119 | 1119 | new CreateAttendeeCommand( |
| 1120 | - $this->_attendee_data[ $reg_url_link ], |
|
| 1120 | + $this->_attendee_data[$reg_url_link], |
|
| 1121 | 1121 | $registration |
| 1122 | 1122 | ) |
| 1123 | 1123 | ); |
@@ -1130,7 +1130,7 @@ discard block |
||
| 1130 | 1130 | // add relation to registration, set attendee ID, and cache attendee |
| 1131 | 1131 | $this->_associate_attendee_with_registration($registration, $attendee); |
| 1132 | 1132 | // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ ); |
| 1133 | - if (! $registration->attendee() instanceof EE_Attendee) { |
|
| 1133 | + if ( ! $registration->attendee() instanceof EE_Attendee) { |
|
| 1134 | 1134 | EE_Error::add_error( |
| 1135 | 1135 | sprintf( |
| 1136 | 1136 | esc_html_x( |
@@ -1180,7 +1180,7 @@ discard block |
||
| 1180 | 1180 | __LINE__ |
| 1181 | 1181 | ); |
| 1182 | 1182 | // remove malformed data |
| 1183 | - unset($valid_data[ $reg_url_link ]); |
|
| 1183 | + unset($valid_data[$reg_url_link]); |
|
| 1184 | 1184 | return false; |
| 1185 | 1185 | } |
| 1186 | 1186 | } // end of foreach ( $this->checkout->transaction->registrations() as $registration ) |
@@ -1226,10 +1226,10 @@ discard block |
||
| 1226 | 1226 | * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477 |
| 1227 | 1227 | */ |
| 1228 | 1228 | $answer_cache_id = $this->checkout->reg_url_link |
| 1229 | - ? $form_input . '-' . $registration->reg_url_link() |
|
| 1229 | + ? $form_input.'-'.$registration->reg_url_link() |
|
| 1230 | 1230 | : $form_input; |
| 1231 | - $answer_is_obj = isset($this->_registration_answers[ $answer_cache_id ]) |
|
| 1232 | - && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer; |
|
| 1231 | + $answer_is_obj = isset($this->_registration_answers[$answer_cache_id]) |
|
| 1232 | + && $this->_registration_answers[$answer_cache_id] instanceof EE_Answer; |
|
| 1233 | 1233 | // rename form_inputs if they are EE_Attendee properties |
| 1234 | 1234 | switch ((string) $form_input) { |
| 1235 | 1235 | case 'state': |
@@ -1245,28 +1245,28 @@ discard block |
||
| 1245 | 1245 | break; |
| 1246 | 1246 | |
| 1247 | 1247 | default: |
| 1248 | - $ATT_input = 'ATT_' . $form_input; |
|
| 1248 | + $ATT_input = 'ATT_'.$form_input; |
|
| 1249 | 1249 | // EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ ); |
| 1250 | 1250 | $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false; |
| 1251 | - $form_input = $attendee_property ? 'ATT_' . $form_input : $form_input; |
|
| 1251 | + $form_input = $attendee_property ? 'ATT_'.$form_input : $form_input; |
|
| 1252 | 1252 | } |
| 1253 | 1253 | // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ ); |
| 1254 | 1254 | // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ ); |
| 1255 | 1255 | // EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ ); |
| 1256 | 1256 | // if this form input has a corresponding attendee property |
| 1257 | 1257 | if ($attendee_property) { |
| 1258 | - $this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value; |
|
| 1258 | + $this->_attendee_data[$registration->reg_url_link()][$form_input] = $input_value; |
|
| 1259 | 1259 | if ($answer_is_obj) { |
| 1260 | 1260 | // and delete the corresponding answer since we won't be storing this data in that object |
| 1261 | - $registration->_remove_relation_to($this->_registration_answers[ $answer_cache_id ], 'Answer'); |
|
| 1262 | - $this->_registration_answers[ $answer_cache_id ]->delete_permanently(); |
|
| 1261 | + $registration->_remove_relation_to($this->_registration_answers[$answer_cache_id], 'Answer'); |
|
| 1262 | + $this->_registration_answers[$answer_cache_id]->delete_permanently(); |
|
| 1263 | 1263 | } |
| 1264 | 1264 | return true; |
| 1265 | 1265 | } |
| 1266 | 1266 | if ($answer_is_obj) { |
| 1267 | 1267 | // save this data to the answer object |
| 1268 | - $this->_registration_answers[ $answer_cache_id ]->set_value($input_value); |
|
| 1269 | - $result = $this->_registration_answers[ $answer_cache_id ]->save(); |
|
| 1268 | + $this->_registration_answers[$answer_cache_id]->set_value($input_value); |
|
| 1269 | + $result = $this->_registration_answers[$answer_cache_id]->save(); |
|
| 1270 | 1270 | return $result !== false; |
| 1271 | 1271 | } |
| 1272 | 1272 | foreach ($this->_registration_answers as $answer) { |
@@ -1293,7 +1293,7 @@ discard block |
||
| 1293 | 1293 | ) { |
| 1294 | 1294 | if (empty($input_value)) { |
| 1295 | 1295 | // if the form input isn't marked as being required, then just return |
| 1296 | - if (! isset($this->_required_questions[ $form_input ]) || ! $this->_required_questions[ $form_input ]) { |
|
| 1296 | + if ( ! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) { |
|
| 1297 | 1297 | return true; |
| 1298 | 1298 | } |
| 1299 | 1299 | switch ($form_input) { |
@@ -1404,10 +1404,10 @@ discard block |
||
| 1404 | 1404 | $critical_attendee_details = array_merge($critical_attendee_details, $address_details); |
| 1405 | 1405 | } |
| 1406 | 1406 | foreach ($critical_attendee_details as $critical_attendee_detail) { |
| 1407 | - if (! isset($attendee_data[ $critical_attendee_detail ]) |
|
| 1408 | - || empty($attendee_data[ $critical_attendee_detail ]) |
|
| 1407 | + if ( ! isset($attendee_data[$critical_attendee_detail]) |
|
| 1408 | + || empty($attendee_data[$critical_attendee_detail]) |
|
| 1409 | 1409 | ) { |
| 1410 | - $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get( |
|
| 1410 | + $attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get( |
|
| 1411 | 1411 | $critical_attendee_detail |
| 1412 | 1412 | ); |
| 1413 | 1413 | } |
@@ -18,1432 +18,1432 @@ |
||
| 18 | 18 | class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @type bool $_print_copy_info |
|
| 23 | - */ |
|
| 24 | - private $_print_copy_info = false; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * @type array $_attendee_data |
|
| 28 | - */ |
|
| 29 | - private $_attendee_data = array(); |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @type array $_required_questions |
|
| 33 | - */ |
|
| 34 | - private $_required_questions = array(); |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @type array $_registration_answers |
|
| 38 | - */ |
|
| 39 | - private $_registration_answers = array(); |
|
| 40 | - |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * class constructor |
|
| 44 | - * |
|
| 45 | - * @access public |
|
| 46 | - * @param EE_Checkout $checkout |
|
| 47 | - */ |
|
| 48 | - public function __construct(EE_Checkout $checkout) |
|
| 49 | - { |
|
| 50 | - $this->_slug = 'attendee_information'; |
|
| 51 | - $this->_name = esc_html__('Attendee Information', 'event_espresso'); |
|
| 52 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . '/attendee_info_main.template.php'; |
|
| 53 | - $this->checkout = $checkout; |
|
| 54 | - $this->_reset_success_message(); |
|
| 55 | - $this->set_instructions( |
|
| 56 | - esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso') |
|
| 57 | - ); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - |
|
| 61 | - public function translate_js_strings() |
|
| 62 | - { |
|
| 63 | - EE_Registry::$i18n_js_strings['required_field'] = esc_html__( |
|
| 64 | - ' is a required question.', |
|
| 65 | - 'event_espresso' |
|
| 66 | - ); |
|
| 67 | - EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__( |
|
| 68 | - ' is a required question. Please enter a value for at least one of the options.', |
|
| 69 | - 'event_espresso' |
|
| 70 | - ); |
|
| 71 | - EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__( |
|
| 72 | - 'Please answer all required questions correctly before proceeding.', |
|
| 73 | - 'event_espresso' |
|
| 74 | - ); |
|
| 75 | - EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf( |
|
| 76 | - esc_html_x( |
|
| 77 | - 'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.', |
|
| 78 | - 'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.', |
|
| 79 | - 'event_espresso' |
|
| 80 | - ), |
|
| 81 | - '<br/>' |
|
| 82 | - ); |
|
| 83 | - EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__( |
|
| 84 | - 'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.', |
|
| 85 | - 'event_espresso' |
|
| 86 | - ); |
|
| 87 | - EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__( |
|
| 88 | - 'You must enter a valid email address.', |
|
| 89 | - 'event_espresso' |
|
| 90 | - ); |
|
| 91 | - EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__( |
|
| 92 | - 'You must enter a valid email address and answer all other required questions before you can proceed.', |
|
| 93 | - 'event_espresso' |
|
| 94 | - ); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - |
|
| 98 | - public function enqueue_styles_and_scripts() |
|
| 99 | - { |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * @return boolean |
|
| 105 | - */ |
|
| 106 | - public function initialize_reg_step() |
|
| 107 | - { |
|
| 108 | - return true; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * @return EE_Form_Section_Proper |
|
| 114 | - * @throws DomainException |
|
| 115 | - * @throws EE_Error |
|
| 116 | - * @throws InvalidArgumentException |
|
| 117 | - * @throws ReflectionException |
|
| 118 | - * @throws EntityNotFoundException |
|
| 119 | - * @throws InvalidDataTypeException |
|
| 120 | - * @throws InvalidInterfaceException |
|
| 121 | - */ |
|
| 122 | - public function generate_reg_form() |
|
| 123 | - { |
|
| 124 | - /** |
|
| 125 | - * @var $reg_config EE_Registration_Config |
|
| 126 | - */ |
|
| 127 | - $reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config'); |
|
| 21 | + /** |
|
| 22 | + * @type bool $_print_copy_info |
|
| 23 | + */ |
|
| 24 | + private $_print_copy_info = false; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @type array $_attendee_data |
|
| 28 | + */ |
|
| 29 | + private $_attendee_data = array(); |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @type array $_required_questions |
|
| 33 | + */ |
|
| 34 | + private $_required_questions = array(); |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @type array $_registration_answers |
|
| 38 | + */ |
|
| 39 | + private $_registration_answers = array(); |
|
| 40 | + |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * class constructor |
|
| 44 | + * |
|
| 45 | + * @access public |
|
| 46 | + * @param EE_Checkout $checkout |
|
| 47 | + */ |
|
| 48 | + public function __construct(EE_Checkout $checkout) |
|
| 49 | + { |
|
| 50 | + $this->_slug = 'attendee_information'; |
|
| 51 | + $this->_name = esc_html__('Attendee Information', 'event_espresso'); |
|
| 52 | + $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . '/attendee_info_main.template.php'; |
|
| 53 | + $this->checkout = $checkout; |
|
| 54 | + $this->_reset_success_message(); |
|
| 55 | + $this->set_instructions( |
|
| 56 | + esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso') |
|
| 57 | + ); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + |
|
| 61 | + public function translate_js_strings() |
|
| 62 | + { |
|
| 63 | + EE_Registry::$i18n_js_strings['required_field'] = esc_html__( |
|
| 64 | + ' is a required question.', |
|
| 65 | + 'event_espresso' |
|
| 66 | + ); |
|
| 67 | + EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__( |
|
| 68 | + ' is a required question. Please enter a value for at least one of the options.', |
|
| 69 | + 'event_espresso' |
|
| 70 | + ); |
|
| 71 | + EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__( |
|
| 72 | + 'Please answer all required questions correctly before proceeding.', |
|
| 73 | + 'event_espresso' |
|
| 74 | + ); |
|
| 75 | + EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf( |
|
| 76 | + esc_html_x( |
|
| 77 | + 'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.', |
|
| 78 | + 'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.', |
|
| 79 | + 'event_espresso' |
|
| 80 | + ), |
|
| 81 | + '<br/>' |
|
| 82 | + ); |
|
| 83 | + EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__( |
|
| 84 | + 'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.', |
|
| 85 | + 'event_espresso' |
|
| 86 | + ); |
|
| 87 | + EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__( |
|
| 88 | + 'You must enter a valid email address.', |
|
| 89 | + 'event_espresso' |
|
| 90 | + ); |
|
| 91 | + EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__( |
|
| 92 | + 'You must enter a valid email address and answer all other required questions before you can proceed.', |
|
| 93 | + 'event_espresso' |
|
| 94 | + ); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + |
|
| 98 | + public function enqueue_styles_and_scripts() |
|
| 99 | + { |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * @return boolean |
|
| 105 | + */ |
|
| 106 | + public function initialize_reg_step() |
|
| 107 | + { |
|
| 108 | + return true; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * @return EE_Form_Section_Proper |
|
| 114 | + * @throws DomainException |
|
| 115 | + * @throws EE_Error |
|
| 116 | + * @throws InvalidArgumentException |
|
| 117 | + * @throws ReflectionException |
|
| 118 | + * @throws EntityNotFoundException |
|
| 119 | + * @throws InvalidDataTypeException |
|
| 120 | + * @throws InvalidInterfaceException |
|
| 121 | + */ |
|
| 122 | + public function generate_reg_form() |
|
| 123 | + { |
|
| 124 | + /** |
|
| 125 | + * @var $reg_config EE_Registration_Config |
|
| 126 | + */ |
|
| 127 | + $reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config'); |
|
| 128 | 128 | |
| 129 | - $this->_print_copy_info = $reg_config->copyAttendeeInfo(); |
|
| 130 | - $primary_registrant = null; |
|
| 131 | - // autoload Line_Item_Display classes |
|
| 132 | - EEH_Autoloader::register_line_item_display_autoloaders(); |
|
| 133 | - $Line_Item_Display = new EE_Line_Item_Display(); |
|
| 134 | - // calculate taxes |
|
| 135 | - $Line_Item_Display->display_line_item( |
|
| 136 | - $this->checkout->cart->get_grand_total(), |
|
| 137 | - array('set_tax_rate' => true) |
|
| 138 | - ); |
|
| 139 | - /** @var $subsections EE_Form_Section_Proper[] */ |
|
| 140 | - $extra_inputs_section = $this->reg_step_hidden_inputs(); |
|
| 141 | - $subsections = array( |
|
| 142 | - 'default_hidden_inputs' => $extra_inputs_section, |
|
| 143 | - ); |
|
| 144 | - |
|
| 145 | - // if this isn't a revisit, and they have the privacy consent box enalbed, add it |
|
| 146 | - if (! $this->checkout->revisit && $reg_config->isConsentCheckboxEnabled()) { |
|
| 147 | - $extra_inputs_section->add_subsections( |
|
| 148 | - array( |
|
| 149 | - 'consent_box' => new EE_Form_Section_Proper( |
|
| 150 | - array( |
|
| 151 | - 'layout_strategy' => |
|
| 152 | - new EE_Template_Layout( |
|
| 153 | - array( |
|
| 154 | - 'input_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . '/privacy_consent.template.php', |
|
| 155 | - ) |
|
| 156 | - ), |
|
| 157 | - 'subsections' => array( |
|
| 158 | - 'consent' => new EE_Checkbox_Multi_Input( |
|
| 159 | - array( |
|
| 160 | - 'consent' => $reg_config->getConsentCheckboxLabelText(), |
|
| 161 | - ), |
|
| 162 | - array( |
|
| 163 | - 'required' => true, |
|
| 164 | - 'required_validation_error_message' => esc_html__( |
|
| 165 | - 'You must consent to these terms in order to register.', |
|
| 166 | - 'event_espresso' |
|
| 167 | - ), |
|
| 168 | - 'html_label_text' => '', |
|
| 169 | - ) |
|
| 170 | - ), |
|
| 171 | - ), |
|
| 172 | - ) |
|
| 173 | - ), |
|
| 174 | - ), |
|
| 175 | - null, |
|
| 176 | - false |
|
| 177 | - ); |
|
| 178 | - } |
|
| 179 | - $template_args = array( |
|
| 180 | - 'revisit' => $this->checkout->revisit, |
|
| 181 | - 'registrations' => array(), |
|
| 182 | - 'ticket_count' => array(), |
|
| 183 | - ); |
|
| 184 | - // grab the saved registrations from the transaction |
|
| 185 | - $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
| 186 | - if ($registrations) { |
|
| 187 | - foreach ($registrations as $registration) { |
|
| 188 | - // can this registration be processed during this visit ? |
|
| 189 | - if ($registration instanceof EE_Registration |
|
| 190 | - && $this->checkout->visit_allows_processing_of_this_registration($registration) |
|
| 191 | - ) { |
|
| 192 | - $subsections[ $registration->reg_url_link() ] = $this->_registrations_reg_form($registration); |
|
| 193 | - if (! $this->checkout->admin_request) { |
|
| 194 | - $template_args['registrations'][ $registration->reg_url_link() ] = $registration; |
|
| 195 | - $template_args['ticket_count'][ $registration->ticket()->ID() ] = isset( |
|
| 196 | - $template_args['ticket_count'][ $registration->ticket()->ID() ] |
|
| 197 | - ) |
|
| 198 | - ? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1 |
|
| 199 | - : 1; |
|
| 200 | - $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
| 201 | - $this->checkout->cart->get_grand_total(), |
|
| 202 | - 'Ticket', |
|
| 203 | - array($registration->ticket()->ID()) |
|
| 204 | - ); |
|
| 205 | - $ticket_line_item = is_array($ticket_line_item) |
|
| 206 | - ? reset($ticket_line_item) |
|
| 207 | - : $ticket_line_item; |
|
| 208 | - $template_args['ticket_line_item'][ $registration->ticket()->ID() ] = |
|
| 209 | - $Line_Item_Display->display_line_item($ticket_line_item); |
|
| 210 | - } |
|
| 211 | - if ($registration->is_primary_registrant()) { |
|
| 212 | - $primary_registrant = $registration->reg_url_link(); |
|
| 213 | - } |
|
| 214 | - } |
|
| 215 | - } |
|
| 216 | - if ($primary_registrant && ! $this->checkout->admin_request && count($registrations) > 1) { |
|
| 217 | - $copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info |
|
| 218 | - ? $this->_copy_attendee_info_form() |
|
| 219 | - : $this->_auto_copy_attendee_info(); |
|
| 220 | - // generate hidden input |
|
| 221 | - if (isset($subsections[ $primary_registrant ]) |
|
| 222 | - && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
| 223 | - ) { |
|
| 224 | - $subsections[ $primary_registrant ]->add_subsections( |
|
| 225 | - $copy_options, |
|
| 226 | - 'primary_registrant', |
|
| 227 | - false |
|
| 228 | - ); |
|
| 229 | - } |
|
| 230 | - } |
|
| 231 | - } |
|
| 232 | - return new EE_Form_Section_Proper( |
|
| 233 | - array( |
|
| 234 | - 'name' => $this->reg_form_name(), |
|
| 235 | - 'html_id' => $this->reg_form_name(), |
|
| 236 | - 'subsections' => $subsections, |
|
| 237 | - 'layout_strategy' => $this->checkout->admin_request |
|
| 238 | - ? |
|
| 239 | - new EE_Div_Per_Section_Layout() |
|
| 240 | - : |
|
| 241 | - new EE_Template_Layout( |
|
| 242 | - array( |
|
| 243 | - 'layout_template_file' => $this->_template, // layout_template |
|
| 244 | - 'template_args' => $template_args, |
|
| 245 | - ) |
|
| 246 | - ), |
|
| 247 | - ) |
|
| 248 | - ); |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * @param EE_Registration $registration |
|
| 254 | - * @return EE_Form_Section_Base |
|
| 255 | - * @throws EE_Error |
|
| 256 | - * @throws InvalidArgumentException |
|
| 257 | - * @throws EntityNotFoundException |
|
| 258 | - * @throws InvalidDataTypeException |
|
| 259 | - * @throws InvalidInterfaceException |
|
| 260 | - * @throws ReflectionException |
|
| 261 | - */ |
|
| 262 | - private function _registrations_reg_form(EE_Registration $registration) |
|
| 263 | - { |
|
| 264 | - static $attendee_nmbr = 1; |
|
| 265 | - $form_args = array(); |
|
| 266 | - // verify that registration has valid event |
|
| 267 | - if ($registration->event() instanceof EE_Event) { |
|
| 268 | - $field_name = 'Event_Question_Group.' |
|
| 269 | - . EEM_Event_Question_Group::instance()->fieldNameForContext( |
|
| 270 | - $registration->is_primary_registrant() |
|
| 271 | - ); |
|
| 272 | - $question_groups = $registration->event()->question_groups( |
|
| 273 | - apply_filters( |
|
| 274 | - // @codingStandardsIgnoreStart |
|
| 275 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__question_groups_query_parameters', |
|
| 276 | - // @codingStandardsIgnoreEnd |
|
| 277 | - [ |
|
| 278 | - [ |
|
| 279 | - 'Event.EVT_ID' => $registration->event()->ID(), |
|
| 280 | - $field_name => true, |
|
| 281 | - ], |
|
| 282 | - 'order_by' => ['QSG_order' => 'ASC'], |
|
| 283 | - ], |
|
| 284 | - $registration, |
|
| 285 | - $this |
|
| 286 | - ) |
|
| 287 | - ); |
|
| 288 | - if ($question_groups) { |
|
| 289 | - // array of params to pass to parent constructor |
|
| 290 | - $form_args = array( |
|
| 291 | - 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
| 292 | - 'html_class' => 'ee-reg-form-attendee-dv', |
|
| 293 | - 'html_style' => $this->checkout->admin_request |
|
| 294 | - ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
|
| 295 | - : '', |
|
| 296 | - 'subsections' => array(), |
|
| 297 | - 'layout_strategy' => new EE_Fieldset_Section_Layout( |
|
| 298 | - array( |
|
| 299 | - 'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text', |
|
| 300 | - 'legend_text' => sprintf( |
|
| 301 | - esc_html_x( |
|
| 302 | - 'Attendee %d', |
|
| 303 | - 'Attendee 123', |
|
| 304 | - 'event_espresso' |
|
| 305 | - ), |
|
| 306 | - $attendee_nmbr |
|
| 307 | - ), |
|
| 308 | - ) |
|
| 309 | - ), |
|
| 310 | - ); |
|
| 311 | - foreach ($question_groups as $question_group) { |
|
| 312 | - if ($question_group instanceof EE_Question_Group) { |
|
| 313 | - $form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form( |
|
| 314 | - $registration, |
|
| 315 | - $question_group |
|
| 316 | - ); |
|
| 317 | - } |
|
| 318 | - } |
|
| 319 | - // add hidden input |
|
| 320 | - $form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input( |
|
| 321 | - $registration |
|
| 322 | - ); |
|
| 323 | - |
|
| 324 | - /** |
|
| 325 | - * @var $reg_config EE_Registration_Config |
|
| 326 | - */ |
|
| 327 | - $reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config'); |
|
| 328 | - |
|
| 329 | - // if we have question groups for additional attendees, then display the copy options |
|
| 330 | - $this->_print_copy_info = $attendee_nmbr > 1 ? $reg_config->copyAttendeeInfo() : false; |
|
| 331 | - if ($registration->is_primary_registrant()) { |
|
| 332 | - // generate hidden input |
|
| 333 | - $form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs( |
|
| 334 | - $registration |
|
| 335 | - ); |
|
| 336 | - } |
|
| 337 | - } |
|
| 338 | - } |
|
| 339 | - $attendee_nmbr++; |
|
| 340 | - return ! empty($form_args) |
|
| 341 | - ? new EE_Form_Section_Proper($form_args) |
|
| 342 | - : new EE_Form_Section_HTML(); |
|
| 343 | - } |
|
| 344 | - |
|
| 345 | - |
|
| 346 | - /** |
|
| 347 | - * @param EE_Registration $registration |
|
| 348 | - * @param bool $additional_attendee_reg_info |
|
| 349 | - * @return EE_Form_Input_Base |
|
| 350 | - * @throws EE_Error |
|
| 351 | - */ |
|
| 352 | - private function _additional_attendee_reg_info_input( |
|
| 353 | - EE_Registration $registration, |
|
| 354 | - $additional_attendee_reg_info = true |
|
| 355 | - ) { |
|
| 356 | - // generate hidden input |
|
| 357 | - return new EE_Hidden_Input( |
|
| 358 | - array( |
|
| 359 | - 'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(), |
|
| 360 | - 'default' => $additional_attendee_reg_info, |
|
| 361 | - ) |
|
| 362 | - ); |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - |
|
| 366 | - /** |
|
| 367 | - * @param EE_Registration $registration |
|
| 368 | - * @param EE_Question_Group $question_group |
|
| 369 | - * @return EE_Form_Section_Proper |
|
| 370 | - * @throws EE_Error |
|
| 371 | - * @throws InvalidArgumentException |
|
| 372 | - * @throws InvalidDataTypeException |
|
| 373 | - * @throws InvalidInterfaceException |
|
| 374 | - * @throws ReflectionException |
|
| 375 | - */ |
|
| 376 | - private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group) |
|
| 377 | - { |
|
| 378 | - // array of params to pass to parent constructor |
|
| 379 | - $form_args = array( |
|
| 380 | - 'html_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' . $registration->ID(), |
|
| 381 | - 'html_class' => $this->checkout->admin_request |
|
| 382 | - ? 'form-table ee-reg-form-qstn-grp-dv' |
|
| 383 | - : 'ee-reg-form-qstn-grp-dv', |
|
| 384 | - 'html_label_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' |
|
| 385 | - . $registration->ID() . '-lbl', |
|
| 386 | - 'subsections' => array( |
|
| 387 | - 'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group), |
|
| 388 | - ), |
|
| 389 | - 'layout_strategy' => $this->checkout->admin_request |
|
| 390 | - ? new EE_Admin_Two_Column_Layout() |
|
| 391 | - : new EE_Div_Per_Section_Layout(), |
|
| 392 | - ); |
|
| 393 | - // where params |
|
| 394 | - $query_params = array('QST_deleted' => 0); |
|
| 395 | - // don't load admin only questions on the frontend |
|
| 396 | - if (! $this->checkout->admin_request) { |
|
| 397 | - $query_params['QST_admin_only'] = array('!=', true); |
|
| 398 | - } |
|
| 399 | - $questions = $question_group->get_many_related( |
|
| 400 | - 'Question', |
|
| 401 | - apply_filters( |
|
| 402 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__related_questions_query_params', |
|
| 403 | - array( |
|
| 404 | - $query_params, |
|
| 405 | - 'order_by' => array( |
|
| 406 | - 'Question_Group_Question.QGQ_order' => 'ASC', |
|
| 407 | - ), |
|
| 408 | - ), |
|
| 409 | - $question_group, |
|
| 410 | - $registration, |
|
| 411 | - $this |
|
| 412 | - ) |
|
| 413 | - ); |
|
| 414 | - // filter for additional content before questions |
|
| 415 | - $form_args['subsections']['reg_form_questions_before'] = new EE_Form_Section_HTML( |
|
| 416 | - apply_filters( |
|
| 417 | - 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', |
|
| 418 | - '', |
|
| 419 | - $registration, |
|
| 420 | - $question_group, |
|
| 421 | - $this |
|
| 422 | - ) |
|
| 423 | - ); |
|
| 424 | - // loop thru questions |
|
| 425 | - foreach ($questions as $question) { |
|
| 426 | - if ($question instanceof EE_Question) { |
|
| 427 | - $identifier = $question->is_system_question() |
|
| 428 | - ? $question->system_ID() |
|
| 429 | - : $question->ID(); |
|
| 430 | - $form_args['subsections'][ $identifier ] = $this->reg_form_question($registration, $question); |
|
| 431 | - } |
|
| 432 | - } |
|
| 433 | - $form_args['subsections'] = apply_filters( |
|
| 434 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array', |
|
| 435 | - $form_args['subsections'], |
|
| 436 | - $registration, |
|
| 437 | - $question_group, |
|
| 438 | - $this |
|
| 439 | - ); |
|
| 440 | - // filter for additional content after questions |
|
| 441 | - $form_args['subsections']['reg_form_questions_after'] = new EE_Form_Section_HTML( |
|
| 442 | - apply_filters( |
|
| 443 | - 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', |
|
| 444 | - '', |
|
| 445 | - $registration, |
|
| 446 | - $question_group, |
|
| 447 | - $this |
|
| 448 | - ) |
|
| 449 | - ); |
|
| 450 | - // d($form_args); |
|
| 451 | - $question_group_reg_form = new EE_Form_Section_Proper($form_args); |
|
| 452 | - return apply_filters( |
|
| 453 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
|
| 454 | - $question_group_reg_form, |
|
| 455 | - $registration, |
|
| 456 | - $question_group, |
|
| 457 | - $this |
|
| 458 | - ); |
|
| 459 | - } |
|
| 460 | - |
|
| 461 | - |
|
| 462 | - /** |
|
| 463 | - * @param EE_Question_Group $question_group |
|
| 464 | - * @return EE_Form_Section_HTML |
|
| 465 | - */ |
|
| 466 | - private function _question_group_header(EE_Question_Group $question_group) |
|
| 467 | - { |
|
| 468 | - $html = ''; |
|
| 469 | - // group_name |
|
| 470 | - if ($question_group->show_group_name() && $question_group->name() !== '') { |
|
| 471 | - if ($this->checkout->admin_request) { |
|
| 472 | - $html .= EEH_HTML::br(); |
|
| 473 | - $html .= EEH_HTML::h3( |
|
| 474 | - $question_group->name(), |
|
| 475 | - '', |
|
| 476 | - 'ee-reg-form-qstn-grp-title title', |
|
| 477 | - 'font-size: 1.3em; padding-left:0;' |
|
| 478 | - ); |
|
| 479 | - } else { |
|
| 480 | - $html .= EEH_HTML::h4( |
|
| 481 | - $question_group->name(), |
|
| 482 | - '', |
|
| 483 | - 'ee-reg-form-qstn-grp-title section-title' |
|
| 484 | - ); |
|
| 485 | - } |
|
| 486 | - } |
|
| 487 | - // group_desc |
|
| 488 | - if ($question_group->show_group_desc() && $question_group->desc() !== '') { |
|
| 489 | - $html .= EEH_HTML::p( |
|
| 490 | - $question_group->desc(), |
|
| 491 | - '', |
|
| 492 | - $this->checkout->admin_request |
|
| 493 | - ? 'ee-reg-form-qstn-grp-desc-pg' |
|
| 494 | - : 'ee-reg-form-qstn-grp-desc-pg small-text lt-grey-text' |
|
| 495 | - ); |
|
| 496 | - } |
|
| 497 | - return new EE_Form_Section_HTML($html); |
|
| 498 | - } |
|
| 499 | - |
|
| 500 | - |
|
| 501 | - /** |
|
| 502 | - * @return EE_Form_Section_Proper |
|
| 503 | - * @throws EE_Error |
|
| 504 | - * @throws InvalidArgumentException |
|
| 505 | - * @throws ReflectionException |
|
| 506 | - * @throws InvalidDataTypeException |
|
| 507 | - * @throws InvalidInterfaceException |
|
| 508 | - */ |
|
| 509 | - private function _copy_attendee_info_form() |
|
| 510 | - { |
|
| 511 | - // array of params to pass to parent constructor |
|
| 512 | - return new EE_Form_Section_Proper( |
|
| 513 | - array( |
|
| 514 | - 'subsections' => $this->_copy_attendee_info_inputs(), |
|
| 515 | - 'layout_strategy' => new EE_Template_Layout( |
|
| 516 | - array( |
|
| 517 | - 'layout_template_file' => SPCO_REG_STEPS_PATH |
|
| 518 | - . $this->_slug |
|
| 519 | - . '/copy_attendee_info.template.php', |
|
| 520 | - 'begin_template_file' => null, |
|
| 521 | - 'input_template_file' => null, |
|
| 522 | - 'subsection_template_file' => null, |
|
| 523 | - 'end_template_file' => null, |
|
| 524 | - ) |
|
| 525 | - ), |
|
| 526 | - ) |
|
| 527 | - ); |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - |
|
| 531 | - /** |
|
| 532 | - * @return EE_Form_Section_HTML |
|
| 533 | - * @throws DomainException |
|
| 534 | - * @throws InvalidArgumentException |
|
| 535 | - * @throws InvalidDataTypeException |
|
| 536 | - * @throws InvalidInterfaceException |
|
| 537 | - */ |
|
| 538 | - private function _auto_copy_attendee_info() |
|
| 539 | - { |
|
| 540 | - return new EE_Form_Section_HTML( |
|
| 541 | - EEH_Template::locate_template( |
|
| 542 | - SPCO_REG_STEPS_PATH . $this->_slug . '/_auto_copy_attendee_info.template.php', |
|
| 543 | - apply_filters( |
|
| 544 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', |
|
| 545 | - array() |
|
| 546 | - ), |
|
| 547 | - true, |
|
| 548 | - true |
|
| 549 | - ) |
|
| 550 | - ); |
|
| 551 | - } |
|
| 552 | - |
|
| 553 | - |
|
| 554 | - /** |
|
| 555 | - * @return array |
|
| 556 | - * @throws EE_Error |
|
| 557 | - * @throws InvalidArgumentException |
|
| 558 | - * @throws ReflectionException |
|
| 559 | - * @throws InvalidDataTypeException |
|
| 560 | - * @throws InvalidInterfaceException |
|
| 561 | - */ |
|
| 562 | - private function _copy_attendee_info_inputs() |
|
| 563 | - { |
|
| 564 | - $copy_attendee_info_inputs = array(); |
|
| 565 | - $prev_ticket = null; |
|
| 566 | - // grab the saved registrations from the transaction |
|
| 567 | - $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
| 568 | - foreach ($registrations as $registration) { |
|
| 569 | - // for all attendees other than the primary attendee |
|
| 570 | - if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) { |
|
| 571 | - // if this is a new ticket OR if this is the very first additional attendee after the primary attendee |
|
| 572 | - if ($registration->ticket()->ID() !== $prev_ticket) { |
|
| 573 | - $item_name = $registration->ticket()->name(); |
|
| 574 | - $item_name .= $registration->ticket()->description() !== '' |
|
| 575 | - ? ' - ' . $registration->ticket()->description() |
|
| 576 | - : ''; |
|
| 577 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID( |
|
| 578 | - ) . ']' ] = |
|
| 579 | - new EE_Form_Section_HTML( |
|
| 580 | - '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>' |
|
| 581 | - ); |
|
| 582 | - $prev_ticket = $registration->ticket()->ID(); |
|
| 583 | - } |
|
| 584 | - |
|
| 585 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] = |
|
| 586 | - new EE_Checkbox_Multi_Input( |
|
| 587 | - array( |
|
| 588 | - $registration->ID() => sprintf( |
|
| 589 | - esc_html_x('Attendee #%s', 'Attendee #123', 'event_espresso'), |
|
| 590 | - $registration->count() |
|
| 591 | - ), |
|
| 592 | - ), |
|
| 593 | - array( |
|
| 594 | - 'html_id' => 'spco-copy-attendee-chk-' . $registration->reg_url_link(), |
|
| 595 | - 'html_class' => 'spco-copy-attendee-chk ee-do-not-validate', |
|
| 596 | - 'display_html_label_text' => false, |
|
| 597 | - ) |
|
| 598 | - ); |
|
| 599 | - } |
|
| 600 | - } |
|
| 601 | - return $copy_attendee_info_inputs; |
|
| 602 | - } |
|
| 603 | - |
|
| 604 | - |
|
| 605 | - /** |
|
| 606 | - * @param EE_Registration $registration |
|
| 607 | - * @return EE_Form_Input_Base |
|
| 608 | - * @throws EE_Error |
|
| 609 | - */ |
|
| 610 | - private function _additional_primary_registrant_inputs(EE_Registration $registration) |
|
| 611 | - { |
|
| 612 | - // generate hidden input |
|
| 613 | - return new EE_Hidden_Input( |
|
| 614 | - array( |
|
| 615 | - 'html_id' => 'primary_registrant', |
|
| 616 | - 'default' => $registration->reg_url_link(), |
|
| 617 | - ) |
|
| 618 | - ); |
|
| 619 | - } |
|
| 620 | - |
|
| 621 | - |
|
| 622 | - /** |
|
| 623 | - * @param EE_Registration $registration |
|
| 624 | - * @param EE_Question $question |
|
| 625 | - * @return EE_Form_Input_Base |
|
| 626 | - * @throws EE_Error |
|
| 627 | - * @throws InvalidArgumentException |
|
| 628 | - * @throws InvalidDataTypeException |
|
| 629 | - * @throws InvalidInterfaceException |
|
| 630 | - * @throws ReflectionException |
|
| 631 | - */ |
|
| 632 | - public function reg_form_question(EE_Registration $registration, EE_Question $question) |
|
| 633 | - { |
|
| 634 | - |
|
| 635 | - // if this question was for an attendee detail, then check for that answer |
|
| 636 | - $answer_value = EEM_Answer::instance()->get_attendee_property_answer_value( |
|
| 637 | - $registration, |
|
| 638 | - $question->system_ID() |
|
| 639 | - ); |
|
| 640 | - $answer = $answer_value === null |
|
| 641 | - ? EEM_Answer::instance()->get_one( |
|
| 642 | - array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())) |
|
| 643 | - ) |
|
| 644 | - : null; |
|
| 645 | - // if NOT returning to edit an existing registration |
|
| 646 | - // OR if this question is for an attendee property |
|
| 647 | - // OR we still don't have an EE_Answer object |
|
| 648 | - if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) { |
|
| 649 | - // create an EE_Answer object for storing everything in |
|
| 650 | - $answer = EE_Answer::new_instance( |
|
| 651 | - array( |
|
| 652 | - 'QST_ID' => $question->ID(), |
|
| 653 | - 'REG_ID' => $registration->ID(), |
|
| 654 | - ) |
|
| 655 | - ); |
|
| 656 | - } |
|
| 657 | - // verify instance |
|
| 658 | - if ($answer instanceof EE_Answer) { |
|
| 659 | - if (! empty($answer_value)) { |
|
| 660 | - $answer->set('ANS_value', $answer_value); |
|
| 661 | - } |
|
| 662 | - $answer->cache('Question', $question); |
|
| 663 | - // remember system ID had a bug where sometimes it could be null |
|
| 664 | - $answer_cache_id = $question->is_system_question() |
|
| 665 | - ? $question->system_ID() . '-' . $registration->reg_url_link() |
|
| 666 | - : $question->ID() . '-' . $registration->reg_url_link(); |
|
| 667 | - $registration->cache('Answer', $answer, $answer_cache_id); |
|
| 668 | - } |
|
| 669 | - return $this->_generate_question_input($registration, $question, $answer); |
|
| 670 | - } |
|
| 671 | - |
|
| 672 | - |
|
| 673 | - /** |
|
| 674 | - * @param EE_Registration $registration |
|
| 675 | - * @param EE_Question $question |
|
| 676 | - * @param $answer |
|
| 677 | - * @return EE_Form_Input_Base |
|
| 678 | - * @throws EE_Error |
|
| 679 | - * @throws InvalidArgumentException |
|
| 680 | - * @throws ReflectionException |
|
| 681 | - * @throws InvalidDataTypeException |
|
| 682 | - * @throws InvalidInterfaceException |
|
| 683 | - */ |
|
| 684 | - private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer) |
|
| 685 | - { |
|
| 686 | - $identifier = $question->is_system_question() |
|
| 687 | - ? $question->system_ID() |
|
| 688 | - : $question->ID(); |
|
| 689 | - $this->_required_questions[ $identifier ] = $question->required() ? true : false; |
|
| 690 | - add_filter( |
|
| 691 | - 'FHEE__EE_Question__generate_form_input__country_options', |
|
| 692 | - array($this, 'use_cached_countries_for_form_input'), |
|
| 693 | - 10, |
|
| 694 | - 4 |
|
| 695 | - ); |
|
| 696 | - add_filter( |
|
| 697 | - 'FHEE__EE_Question__generate_form_input__state_options', |
|
| 698 | - array($this, 'use_cached_states_for_form_input'), |
|
| 699 | - 10, |
|
| 700 | - 4 |
|
| 701 | - ); |
|
| 702 | - $input_constructor_args = array( |
|
| 703 | - 'html_name' => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']', |
|
| 704 | - 'html_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
| 705 | - 'html_class' => 'ee-reg-qstn ee-reg-qstn-' . $identifier, |
|
| 706 | - 'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
| 707 | - 'html_label_class' => 'ee-reg-qstn', |
|
| 708 | - ); |
|
| 709 | - $input_constructor_args['html_label_id'] .= '-lbl'; |
|
| 710 | - if ($answer instanceof EE_Answer && $answer->ID()) { |
|
| 711 | - $input_constructor_args['html_name'] .= '[' . $answer->ID() . ']'; |
|
| 712 | - $input_constructor_args['html_id'] .= '-' . $answer->ID(); |
|
| 713 | - $input_constructor_args['html_label_id'] .= '-' . $answer->ID(); |
|
| 714 | - } |
|
| 715 | - $form_input = $question->generate_form_input( |
|
| 716 | - $registration, |
|
| 717 | - $answer, |
|
| 718 | - $input_constructor_args |
|
| 719 | - ); |
|
| 720 | - remove_filter( |
|
| 721 | - 'FHEE__EE_Question__generate_form_input__country_options', |
|
| 722 | - array($this, 'use_cached_countries_for_form_input') |
|
| 723 | - ); |
|
| 724 | - remove_filter( |
|
| 725 | - 'FHEE__EE_Question__generate_form_input__state_options', |
|
| 726 | - array($this, 'use_cached_states_for_form_input') |
|
| 727 | - ); |
|
| 728 | - return $form_input; |
|
| 729 | - } |
|
| 730 | - |
|
| 731 | - |
|
| 732 | - /** |
|
| 733 | - * Gets the list of countries for the form input |
|
| 734 | - * |
|
| 735 | - * @param array|null $countries_list |
|
| 736 | - * @param EE_Question $question |
|
| 737 | - * @param EE_Registration $registration |
|
| 738 | - * @param EE_Answer $answer |
|
| 739 | - * @return array 2d keys are country IDs, values are their names |
|
| 740 | - * @throws EE_Error |
|
| 741 | - * @throws InvalidArgumentException |
|
| 742 | - * @throws InvalidDataTypeException |
|
| 743 | - * @throws InvalidInterfaceException |
|
| 744 | - * @throws ReflectionException |
|
| 745 | - */ |
|
| 746 | - public function use_cached_countries_for_form_input( |
|
| 747 | - $countries_list, |
|
| 748 | - EE_Question $question = null, |
|
| 749 | - EE_Registration $registration = null, |
|
| 750 | - EE_Answer $answer = null |
|
| 751 | - ) { |
|
| 752 | - $country_options = array('' => ''); |
|
| 753 | - // get possibly cached list of countries |
|
| 754 | - $countries = $this->checkout->action === 'process_reg_step' |
|
| 755 | - ? EEM_Country::instance()->get_all_countries() |
|
| 756 | - : EEM_Country::instance()->get_all_active_countries(); |
|
| 757 | - if (! empty($countries)) { |
|
| 758 | - foreach ($countries as $country) { |
|
| 759 | - if ($country instanceof EE_Country) { |
|
| 760 | - $country_options[ $country->ID() ] = $country->name(); |
|
| 761 | - } |
|
| 762 | - } |
|
| 763 | - } |
|
| 764 | - if ($question instanceof EE_Question && $registration instanceof EE_Registration) { |
|
| 765 | - $answer = EEM_Answer::instance()->get_one( |
|
| 766 | - array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())) |
|
| 767 | - ); |
|
| 768 | - } else { |
|
| 769 | - $answer = EE_Answer::new_instance(); |
|
| 770 | - } |
|
| 771 | - $country_options = apply_filters( |
|
| 772 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', |
|
| 773 | - $country_options, |
|
| 774 | - $this, |
|
| 775 | - $registration, |
|
| 776 | - $question, |
|
| 777 | - $answer |
|
| 778 | - ); |
|
| 779 | - return $country_options; |
|
| 780 | - } |
|
| 781 | - |
|
| 782 | - |
|
| 783 | - /** |
|
| 784 | - * Gets the list of states for the form input |
|
| 785 | - * |
|
| 786 | - * @param array|null $states_list |
|
| 787 | - * @param EE_Question $question |
|
| 788 | - * @param EE_Registration $registration |
|
| 789 | - * @param EE_Answer $answer |
|
| 790 | - * @return array 2d keys are state IDs, values are their names |
|
| 791 | - * @throws EE_Error |
|
| 792 | - * @throws InvalidArgumentException |
|
| 793 | - * @throws InvalidDataTypeException |
|
| 794 | - * @throws InvalidInterfaceException |
|
| 795 | - * @throws ReflectionException |
|
| 796 | - */ |
|
| 797 | - public function use_cached_states_for_form_input( |
|
| 798 | - $states_list, |
|
| 799 | - EE_Question $question = null, |
|
| 800 | - EE_Registration $registration = null, |
|
| 801 | - EE_Answer $answer = null |
|
| 802 | - ) { |
|
| 803 | - $state_options = array('' => array('' => '')); |
|
| 804 | - $states = $this->checkout->action === 'process_reg_step' |
|
| 805 | - ? EEM_State::instance()->get_all_states() |
|
| 806 | - : EEM_State::instance()->get_all_active_states(); |
|
| 807 | - if (! empty($states)) { |
|
| 808 | - foreach ($states as $state) { |
|
| 809 | - if ($state instanceof EE_State) { |
|
| 810 | - $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name(); |
|
| 811 | - } |
|
| 812 | - } |
|
| 813 | - } |
|
| 814 | - $state_options = apply_filters( |
|
| 815 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', |
|
| 816 | - $state_options, |
|
| 817 | - $this, |
|
| 818 | - $registration, |
|
| 819 | - $question, |
|
| 820 | - $answer |
|
| 821 | - ); |
|
| 822 | - return $state_options; |
|
| 823 | - } |
|
| 824 | - |
|
| 825 | - |
|
| 826 | - /********************************************************************************************************/ |
|
| 827 | - /**************************************** PROCESS REG STEP ****************************************/ |
|
| 828 | - /********************************************************************************************************/ |
|
| 829 | - |
|
| 830 | - |
|
| 831 | - /** |
|
| 832 | - * @return bool |
|
| 833 | - * @throws EE_Error |
|
| 834 | - * @throws InvalidArgumentException |
|
| 835 | - * @throws ReflectionException |
|
| 836 | - * @throws RuntimeException |
|
| 837 | - * @throws InvalidDataTypeException |
|
| 838 | - * @throws InvalidInterfaceException |
|
| 839 | - */ |
|
| 840 | - public function process_reg_step() |
|
| 841 | - { |
|
| 842 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 843 | - // grab validated data from form |
|
| 844 | - $valid_data = $this->checkout->current_step->valid_data(); |
|
| 845 | - // EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
|
| 846 | - // EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ ); |
|
| 847 | - // if we don't have any $valid_data then something went TERRIBLY WRONG !!! |
|
| 848 | - if (empty($valid_data)) { |
|
| 849 | - EE_Error::add_error( |
|
| 850 | - esc_html__('No valid question responses were received.', 'event_espresso'), |
|
| 851 | - __FILE__, |
|
| 852 | - __FUNCTION__, |
|
| 853 | - __LINE__ |
|
| 854 | - ); |
|
| 855 | - return false; |
|
| 856 | - } |
|
| 857 | - if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
| 858 | - EE_Error::add_error( |
|
| 859 | - esc_html__( |
|
| 860 | - 'A valid transaction could not be initiated for processing your registrations.', |
|
| 861 | - 'event_espresso' |
|
| 862 | - ), |
|
| 863 | - __FILE__, |
|
| 864 | - __FUNCTION__, |
|
| 865 | - __LINE__ |
|
| 866 | - ); |
|
| 867 | - return false; |
|
| 868 | - } |
|
| 869 | - // get cached registrations |
|
| 870 | - $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
| 871 | - // verify we got the goods |
|
| 872 | - if (empty($registrations)) { |
|
| 873 | - // combine the old translated string with a new one, in order to not break translations |
|
| 874 | - $error_message = esc_html__( |
|
| 875 | - 'Your form data could not be applied to any valid registrations.', |
|
| 876 | - 'event_espresso' |
|
| 877 | - ) |
|
| 878 | - . sprintf( |
|
| 879 | - esc_html_x( |
|
| 880 | - '%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
| 881 | - '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
| 882 | - 'event_espresso' |
|
| 883 | - ), |
|
| 884 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
| 885 | - '</a>', |
|
| 886 | - '<br />' |
|
| 887 | - ); |
|
| 888 | - EE_Error::add_error( |
|
| 889 | - $error_message, |
|
| 890 | - __FILE__, |
|
| 891 | - __FUNCTION__, |
|
| 892 | - __LINE__ |
|
| 893 | - ); |
|
| 894 | - return false; |
|
| 895 | - } |
|
| 896 | - // extract attendee info from form data and save to model objects |
|
| 897 | - $registrations_processed = $this->_process_registrations($registrations, $valid_data); |
|
| 898 | - // if first pass thru SPCO, |
|
| 899 | - // then let's check processed registrations against the total number of tickets in the cart |
|
| 900 | - if ($registrations_processed === false) { |
|
| 901 | - // but return immediately if the previous step exited early due to errors |
|
| 902 | - return false; |
|
| 903 | - } |
|
| 904 | - if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
| 905 | - // generate a correctly translated string for all possible singular/plural combinations |
|
| 906 | - if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
|
| 907 | - $error_msg = sprintf( |
|
| 908 | - esc_html_x( |
|
| 909 | - 'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', |
|
| 910 | - 'There was 1 ticket in the Event Queue, but 2 registrations were processed', |
|
| 911 | - 'event_espresso' |
|
| 912 | - ), |
|
| 913 | - $this->checkout->total_ticket_count, |
|
| 914 | - $registrations_processed |
|
| 915 | - ); |
|
| 916 | - } elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) { |
|
| 917 | - $error_msg = sprintf( |
|
| 918 | - esc_html_x( |
|
| 919 | - 'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', |
|
| 920 | - 'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed', |
|
| 921 | - 'event_espresso' |
|
| 922 | - ), |
|
| 923 | - $this->checkout->total_ticket_count, |
|
| 924 | - $registrations_processed |
|
| 925 | - ); |
|
| 926 | - } else { |
|
| 927 | - $error_msg = sprintf( |
|
| 928 | - esc_html__( |
|
| 929 | - 'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed', |
|
| 930 | - 'event_espresso' |
|
| 931 | - ), |
|
| 932 | - $this->checkout->total_ticket_count, |
|
| 933 | - $registrations_processed |
|
| 934 | - ); |
|
| 935 | - } |
|
| 936 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 937 | - return false; |
|
| 938 | - } |
|
| 939 | - // mark this reg step as completed |
|
| 940 | - $this->set_completed(); |
|
| 941 | - $this->_set_success_message( |
|
| 942 | - esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso') |
|
| 943 | - ); |
|
| 944 | - // do action in case a plugin wants to do something with the data submitted in step 1. |
|
| 945 | - // passes EE_Single_Page_Checkout, and it's posted data |
|
| 946 | - do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data); |
|
| 947 | - return true; |
|
| 948 | - } |
|
| 949 | - |
|
| 950 | - |
|
| 951 | - /** |
|
| 952 | - * _process_registrations |
|
| 953 | - * |
|
| 954 | - * @param EE_Registration[] $registrations |
|
| 955 | - * @param array[][] $valid_data |
|
| 956 | - * @return bool|int |
|
| 957 | - * @throws EntityNotFoundException |
|
| 958 | - * @throws EE_Error |
|
| 959 | - * @throws InvalidArgumentException |
|
| 960 | - * @throws ReflectionException |
|
| 961 | - * @throws RuntimeException |
|
| 962 | - * @throws InvalidDataTypeException |
|
| 963 | - * @throws InvalidInterfaceException |
|
| 964 | - */ |
|
| 965 | - private function _process_registrations($registrations = array(), $valid_data = array()) |
|
| 966 | - { |
|
| 967 | - // load resources and set some defaults |
|
| 968 | - EE_Registry::instance()->load_model('Attendee'); |
|
| 969 | - // holder for primary registrant attendee object |
|
| 970 | - $this->checkout->primary_attendee_obj = null; |
|
| 971 | - // array for tracking reg form data for the primary registrant |
|
| 972 | - $primary_registrant = array( |
|
| 973 | - 'line_item_id' => null, |
|
| 974 | - ); |
|
| 975 | - $copy_primary = false; |
|
| 976 | - // reg form sections that do not contain inputs |
|
| 977 | - $non_input_form_sections = array( |
|
| 978 | - 'primary_registrant', |
|
| 979 | - 'additional_attendee_reg_info', |
|
| 980 | - 'spco_copy_attendee_chk', |
|
| 981 | - ); |
|
| 982 | - // attendee counter |
|
| 983 | - $att_nmbr = 0; |
|
| 984 | - // grab the saved registrations from the transaction |
|
| 985 | - foreach ($registrations as $registration) { |
|
| 986 | - // verify EE_Registration object |
|
| 987 | - if (! $registration instanceof EE_Registration) { |
|
| 988 | - EE_Error::add_error( |
|
| 989 | - esc_html__( |
|
| 990 | - 'An invalid Registration object was discovered when attempting to process your registration information.', |
|
| 991 | - 'event_espresso' |
|
| 992 | - ), |
|
| 993 | - __FILE__, |
|
| 994 | - __FUNCTION__, |
|
| 995 | - __LINE__ |
|
| 996 | - ); |
|
| 997 | - return false; |
|
| 998 | - } |
|
| 999 | - /** @var string $reg_url_link */ |
|
| 1000 | - $reg_url_link = $registration->reg_url_link(); |
|
| 1001 | - // reg_url_link exists ? |
|
| 1002 | - if (! empty($reg_url_link)) { |
|
| 1003 | - // should this registration be processed during this visit ? |
|
| 1004 | - if ($this->checkout->visit_allows_processing_of_this_registration($registration)) { |
|
| 1005 | - // if NOT revisiting, then let's save the registration now, |
|
| 1006 | - // so that we have a REG_ID to use when generating other objects |
|
| 1007 | - if (! $this->checkout->revisit) { |
|
| 1008 | - $registration->save(); |
|
| 1009 | - } |
|
| 1010 | - /** |
|
| 1011 | - * This allows plugins to trigger a fail on processing of a |
|
| 1012 | - * registration for any conditions they may have for it to pass. |
|
| 1013 | - * |
|
| 1014 | - * @var bool if true is returned by the plugin then the |
|
| 1015 | - * registration processing is halted. |
|
| 1016 | - */ |
|
| 1017 | - if (apply_filters( |
|
| 1018 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process', |
|
| 1019 | - false, |
|
| 1020 | - $att_nmbr, |
|
| 1021 | - $registration, |
|
| 1022 | - $registrations, |
|
| 1023 | - $valid_data, |
|
| 1024 | - $this |
|
| 1025 | - )) { |
|
| 1026 | - return false; |
|
| 1027 | - } |
|
| 1028 | - |
|
| 1029 | - // Houston, we have a registration! |
|
| 1030 | - $att_nmbr++; |
|
| 1031 | - $this->_attendee_data[ $reg_url_link ] = array(); |
|
| 1032 | - // grab any existing related answer objects |
|
| 1033 | - $this->_registration_answers = $registration->answers(); |
|
| 1034 | - // unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ); |
|
| 1035 | - if (isset($valid_data[ $reg_url_link ])) { |
|
| 1036 | - // do we need to copy basic info from primary attendee ? |
|
| 1037 | - $copy_primary = isset($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) |
|
| 1038 | - && absint($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) === 0; |
|
| 1039 | - // filter form input data for this registration |
|
| 1040 | - $valid_data[ $reg_url_link ] = (array) apply_filters( |
|
| 1041 | - 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
|
| 1042 | - $valid_data[ $reg_url_link ] |
|
| 1043 | - ); |
|
| 1044 | - if (isset($valid_data['primary_attendee'])) { |
|
| 1045 | - $primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee']) |
|
| 1046 | - ? $valid_data['primary_attendee'] |
|
| 1047 | - : false; |
|
| 1048 | - unset($valid_data['primary_attendee']); |
|
| 1049 | - } |
|
| 1050 | - // now loop through our array of valid post data && process attendee reg forms |
|
| 1051 | - foreach ($valid_data[ $reg_url_link ] as $form_section => $form_inputs) { |
|
| 1052 | - if (! in_array($form_section, $non_input_form_sections, true)) { |
|
| 1053 | - foreach ($form_inputs as $form_input => $input_value) { |
|
| 1054 | - // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ ); |
|
| 1055 | - // check for critical inputs |
|
| 1056 | - if (! $this->_verify_critical_attendee_details_are_set_and_validate_email( |
|
| 1057 | - $form_input, |
|
| 1058 | - $input_value |
|
| 1059 | - ) |
|
| 1060 | - ) { |
|
| 1061 | - return false; |
|
| 1062 | - } |
|
| 1063 | - // store a bit of data about the primary attendee |
|
| 1064 | - if ($att_nmbr === 1 |
|
| 1065 | - && ! empty($input_value) |
|
| 1066 | - && $reg_url_link === $primary_registrant['line_item_id'] |
|
| 1067 | - ) { |
|
| 1068 | - $primary_registrant[ $form_input ] = $input_value; |
|
| 1069 | - } elseif ($copy_primary |
|
| 1070 | - && $input_value === null |
|
| 1071 | - && isset($primary_registrant[ $form_input ]) |
|
| 1072 | - ) { |
|
| 1073 | - $input_value = $primary_registrant[ $form_input ]; |
|
| 1074 | - } |
|
| 1075 | - // now attempt to save the input data |
|
| 1076 | - if (! $this->_save_registration_form_input( |
|
| 1077 | - $registration, |
|
| 1078 | - $form_input, |
|
| 1079 | - $input_value |
|
| 1080 | - ) |
|
| 1081 | - ) { |
|
| 1082 | - EE_Error::add_error( |
|
| 1083 | - sprintf( |
|
| 1084 | - esc_html_x( |
|
| 1085 | - 'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"', |
|
| 1086 | - 'Unable to save registration form data for the form input: "form input name" with the submitted value: "form input value"', |
|
| 1087 | - 'event_espresso' |
|
| 1088 | - ), |
|
| 1089 | - $form_input, |
|
| 1090 | - $input_value |
|
| 1091 | - ), |
|
| 1092 | - __FILE__, |
|
| 1093 | - __FUNCTION__, |
|
| 1094 | - __LINE__ |
|
| 1095 | - ); |
|
| 1096 | - return false; |
|
| 1097 | - } |
|
| 1098 | - } |
|
| 1099 | - } |
|
| 1100 | - } // end of foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs ) |
|
| 1101 | - } |
|
| 1102 | - // EEH_Debug_Tools::printr( $this->_attendee_data, '$this->_attendee_data', __FILE__, __LINE__ ); |
|
| 1103 | - // this registration does not require additional attendee information ? |
|
| 1104 | - if ($copy_primary |
|
| 1105 | - && $att_nmbr > 1 |
|
| 1106 | - && $this->checkout->primary_attendee_obj instanceof EE_Attendee |
|
| 1107 | - ) { |
|
| 1108 | - // just copy the primary registrant |
|
| 1109 | - $attendee = $this->checkout->primary_attendee_obj; |
|
| 1110 | - } else { |
|
| 1111 | - // ensure critical details are set for additional attendees |
|
| 1112 | - $this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1 |
|
| 1113 | - ? $this->_copy_critical_attendee_details_from_primary_registrant( |
|
| 1114 | - $this->_attendee_data[ $reg_url_link ] |
|
| 1115 | - ) |
|
| 1116 | - : $this->_attendee_data[ $reg_url_link ]; |
|
| 1117 | - // execute create attendee command (which may return an existing attendee) |
|
| 1118 | - $attendee = EE_Registry::instance()->BUS->execute( |
|
| 1119 | - new CreateAttendeeCommand( |
|
| 1120 | - $this->_attendee_data[ $reg_url_link ], |
|
| 1121 | - $registration |
|
| 1122 | - ) |
|
| 1123 | - ); |
|
| 1124 | - // who's #1 ? |
|
| 1125 | - if ($att_nmbr === 1) { |
|
| 1126 | - $this->checkout->primary_attendee_obj = $attendee; |
|
| 1127 | - } |
|
| 1128 | - } |
|
| 1129 | - // EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ ); |
|
| 1130 | - // add relation to registration, set attendee ID, and cache attendee |
|
| 1131 | - $this->_associate_attendee_with_registration($registration, $attendee); |
|
| 1132 | - // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ ); |
|
| 1133 | - if (! $registration->attendee() instanceof EE_Attendee) { |
|
| 1134 | - EE_Error::add_error( |
|
| 1135 | - sprintf( |
|
| 1136 | - esc_html_x( |
|
| 1137 | - 'Registration %s has an invalid or missing Attendee object.', |
|
| 1138 | - 'Registration 123-456-789 has an invalid or missing Attendee object.', |
|
| 1139 | - 'event_espresso' |
|
| 1140 | - ), |
|
| 1141 | - $reg_url_link |
|
| 1142 | - ), |
|
| 1143 | - __FILE__, |
|
| 1144 | - __FUNCTION__, |
|
| 1145 | - __LINE__ |
|
| 1146 | - ); |
|
| 1147 | - return false; |
|
| 1148 | - } |
|
| 1149 | - /** @type EE_Registration_Processor $registration_processor */ |
|
| 1150 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
| 1151 | - // at this point, we should have enough details about the registrant to consider the registration |
|
| 1152 | - // NOT incomplete |
|
| 1153 | - $registration_processor->toggle_incomplete_registration_status_to_default( |
|
| 1154 | - $registration, |
|
| 1155 | - false, |
|
| 1156 | - new Context( |
|
| 1157 | - 'spco_reg_step_attendee_information_process_registrations', |
|
| 1158 | - esc_html__( |
|
| 1159 | - 'Finished populating registration with details from the registration form after submitting the Attendee Information Reg Step.', |
|
| 1160 | - 'event_espresso' |
|
| 1161 | - ) |
|
| 1162 | - ) |
|
| 1163 | - ); |
|
| 1164 | - // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to |
|
| 1165 | - // abandoned |
|
| 1166 | - $this->checkout->transaction->toggle_failed_transaction_status(); |
|
| 1167 | - // if we've gotten this far, then let's save what we have |
|
| 1168 | - $registration->save(); |
|
| 1169 | - // add relation between TXN and registration |
|
| 1170 | - $this->_associate_registration_with_transaction($registration); |
|
| 1171 | - } |
|
| 1172 | - } else { |
|
| 1173 | - EE_Error::add_error( |
|
| 1174 | - esc_html__( |
|
| 1175 | - 'An invalid or missing line item ID was encountered while attempting to process the registration form.', |
|
| 1176 | - 'event_espresso' |
|
| 1177 | - ), |
|
| 1178 | - __FILE__, |
|
| 1179 | - __FUNCTION__, |
|
| 1180 | - __LINE__ |
|
| 1181 | - ); |
|
| 1182 | - // remove malformed data |
|
| 1183 | - unset($valid_data[ $reg_url_link ]); |
|
| 1184 | - return false; |
|
| 1185 | - } |
|
| 1186 | - } // end of foreach ( $this->checkout->transaction->registrations() as $registration ) |
|
| 1187 | - return $att_nmbr; |
|
| 1188 | - } |
|
| 1189 | - |
|
| 1190 | - |
|
| 1191 | - /** |
|
| 1192 | - * _save_registration_form_input |
|
| 1193 | - * |
|
| 1194 | - * @param EE_Registration $registration |
|
| 1195 | - * @param string $form_input |
|
| 1196 | - * @param string $input_value |
|
| 1197 | - * @return bool |
|
| 1198 | - * @throws EE_Error |
|
| 1199 | - * @throws InvalidArgumentException |
|
| 1200 | - * @throws InvalidDataTypeException |
|
| 1201 | - * @throws InvalidInterfaceException |
|
| 1202 | - * @throws ReflectionException |
|
| 1203 | - */ |
|
| 1204 | - private function _save_registration_form_input( |
|
| 1205 | - EE_Registration $registration, |
|
| 1206 | - $form_input = '', |
|
| 1207 | - $input_value = '' |
|
| 1208 | - ) { |
|
| 1209 | - // \EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 ); |
|
| 1210 | - // \EEH_Debug_Tools::printr( $form_input, '$form_input', __FILE__, __LINE__ ); |
|
| 1211 | - // \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ ); |
|
| 1212 | - // allow for plugins to hook in and do their own processing of the form input. |
|
| 1213 | - // For plugins to bypass normal processing here, they just need to return a boolean value. |
|
| 1214 | - if (apply_filters( |
|
| 1215 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input', |
|
| 1216 | - false, |
|
| 1217 | - $registration, |
|
| 1218 | - $form_input, |
|
| 1219 | - $input_value, |
|
| 1220 | - $this |
|
| 1221 | - )) { |
|
| 1222 | - return true; |
|
| 1223 | - } |
|
| 1224 | - /* |
|
| 129 | + $this->_print_copy_info = $reg_config->copyAttendeeInfo(); |
|
| 130 | + $primary_registrant = null; |
|
| 131 | + // autoload Line_Item_Display classes |
|
| 132 | + EEH_Autoloader::register_line_item_display_autoloaders(); |
|
| 133 | + $Line_Item_Display = new EE_Line_Item_Display(); |
|
| 134 | + // calculate taxes |
|
| 135 | + $Line_Item_Display->display_line_item( |
|
| 136 | + $this->checkout->cart->get_grand_total(), |
|
| 137 | + array('set_tax_rate' => true) |
|
| 138 | + ); |
|
| 139 | + /** @var $subsections EE_Form_Section_Proper[] */ |
|
| 140 | + $extra_inputs_section = $this->reg_step_hidden_inputs(); |
|
| 141 | + $subsections = array( |
|
| 142 | + 'default_hidden_inputs' => $extra_inputs_section, |
|
| 143 | + ); |
|
| 144 | + |
|
| 145 | + // if this isn't a revisit, and they have the privacy consent box enalbed, add it |
|
| 146 | + if (! $this->checkout->revisit && $reg_config->isConsentCheckboxEnabled()) { |
|
| 147 | + $extra_inputs_section->add_subsections( |
|
| 148 | + array( |
|
| 149 | + 'consent_box' => new EE_Form_Section_Proper( |
|
| 150 | + array( |
|
| 151 | + 'layout_strategy' => |
|
| 152 | + new EE_Template_Layout( |
|
| 153 | + array( |
|
| 154 | + 'input_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . '/privacy_consent.template.php', |
|
| 155 | + ) |
|
| 156 | + ), |
|
| 157 | + 'subsections' => array( |
|
| 158 | + 'consent' => new EE_Checkbox_Multi_Input( |
|
| 159 | + array( |
|
| 160 | + 'consent' => $reg_config->getConsentCheckboxLabelText(), |
|
| 161 | + ), |
|
| 162 | + array( |
|
| 163 | + 'required' => true, |
|
| 164 | + 'required_validation_error_message' => esc_html__( |
|
| 165 | + 'You must consent to these terms in order to register.', |
|
| 166 | + 'event_espresso' |
|
| 167 | + ), |
|
| 168 | + 'html_label_text' => '', |
|
| 169 | + ) |
|
| 170 | + ), |
|
| 171 | + ), |
|
| 172 | + ) |
|
| 173 | + ), |
|
| 174 | + ), |
|
| 175 | + null, |
|
| 176 | + false |
|
| 177 | + ); |
|
| 178 | + } |
|
| 179 | + $template_args = array( |
|
| 180 | + 'revisit' => $this->checkout->revisit, |
|
| 181 | + 'registrations' => array(), |
|
| 182 | + 'ticket_count' => array(), |
|
| 183 | + ); |
|
| 184 | + // grab the saved registrations from the transaction |
|
| 185 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
| 186 | + if ($registrations) { |
|
| 187 | + foreach ($registrations as $registration) { |
|
| 188 | + // can this registration be processed during this visit ? |
|
| 189 | + if ($registration instanceof EE_Registration |
|
| 190 | + && $this->checkout->visit_allows_processing_of_this_registration($registration) |
|
| 191 | + ) { |
|
| 192 | + $subsections[ $registration->reg_url_link() ] = $this->_registrations_reg_form($registration); |
|
| 193 | + if (! $this->checkout->admin_request) { |
|
| 194 | + $template_args['registrations'][ $registration->reg_url_link() ] = $registration; |
|
| 195 | + $template_args['ticket_count'][ $registration->ticket()->ID() ] = isset( |
|
| 196 | + $template_args['ticket_count'][ $registration->ticket()->ID() ] |
|
| 197 | + ) |
|
| 198 | + ? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1 |
|
| 199 | + : 1; |
|
| 200 | + $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
| 201 | + $this->checkout->cart->get_grand_total(), |
|
| 202 | + 'Ticket', |
|
| 203 | + array($registration->ticket()->ID()) |
|
| 204 | + ); |
|
| 205 | + $ticket_line_item = is_array($ticket_line_item) |
|
| 206 | + ? reset($ticket_line_item) |
|
| 207 | + : $ticket_line_item; |
|
| 208 | + $template_args['ticket_line_item'][ $registration->ticket()->ID() ] = |
|
| 209 | + $Line_Item_Display->display_line_item($ticket_line_item); |
|
| 210 | + } |
|
| 211 | + if ($registration->is_primary_registrant()) { |
|
| 212 | + $primary_registrant = $registration->reg_url_link(); |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | + } |
|
| 216 | + if ($primary_registrant && ! $this->checkout->admin_request && count($registrations) > 1) { |
|
| 217 | + $copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info |
|
| 218 | + ? $this->_copy_attendee_info_form() |
|
| 219 | + : $this->_auto_copy_attendee_info(); |
|
| 220 | + // generate hidden input |
|
| 221 | + if (isset($subsections[ $primary_registrant ]) |
|
| 222 | + && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
| 223 | + ) { |
|
| 224 | + $subsections[ $primary_registrant ]->add_subsections( |
|
| 225 | + $copy_options, |
|
| 226 | + 'primary_registrant', |
|
| 227 | + false |
|
| 228 | + ); |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | + } |
|
| 232 | + return new EE_Form_Section_Proper( |
|
| 233 | + array( |
|
| 234 | + 'name' => $this->reg_form_name(), |
|
| 235 | + 'html_id' => $this->reg_form_name(), |
|
| 236 | + 'subsections' => $subsections, |
|
| 237 | + 'layout_strategy' => $this->checkout->admin_request |
|
| 238 | + ? |
|
| 239 | + new EE_Div_Per_Section_Layout() |
|
| 240 | + : |
|
| 241 | + new EE_Template_Layout( |
|
| 242 | + array( |
|
| 243 | + 'layout_template_file' => $this->_template, // layout_template |
|
| 244 | + 'template_args' => $template_args, |
|
| 245 | + ) |
|
| 246 | + ), |
|
| 247 | + ) |
|
| 248 | + ); |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * @param EE_Registration $registration |
|
| 254 | + * @return EE_Form_Section_Base |
|
| 255 | + * @throws EE_Error |
|
| 256 | + * @throws InvalidArgumentException |
|
| 257 | + * @throws EntityNotFoundException |
|
| 258 | + * @throws InvalidDataTypeException |
|
| 259 | + * @throws InvalidInterfaceException |
|
| 260 | + * @throws ReflectionException |
|
| 261 | + */ |
|
| 262 | + private function _registrations_reg_form(EE_Registration $registration) |
|
| 263 | + { |
|
| 264 | + static $attendee_nmbr = 1; |
|
| 265 | + $form_args = array(); |
|
| 266 | + // verify that registration has valid event |
|
| 267 | + if ($registration->event() instanceof EE_Event) { |
|
| 268 | + $field_name = 'Event_Question_Group.' |
|
| 269 | + . EEM_Event_Question_Group::instance()->fieldNameForContext( |
|
| 270 | + $registration->is_primary_registrant() |
|
| 271 | + ); |
|
| 272 | + $question_groups = $registration->event()->question_groups( |
|
| 273 | + apply_filters( |
|
| 274 | + // @codingStandardsIgnoreStart |
|
| 275 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__question_groups_query_parameters', |
|
| 276 | + // @codingStandardsIgnoreEnd |
|
| 277 | + [ |
|
| 278 | + [ |
|
| 279 | + 'Event.EVT_ID' => $registration->event()->ID(), |
|
| 280 | + $field_name => true, |
|
| 281 | + ], |
|
| 282 | + 'order_by' => ['QSG_order' => 'ASC'], |
|
| 283 | + ], |
|
| 284 | + $registration, |
|
| 285 | + $this |
|
| 286 | + ) |
|
| 287 | + ); |
|
| 288 | + if ($question_groups) { |
|
| 289 | + // array of params to pass to parent constructor |
|
| 290 | + $form_args = array( |
|
| 291 | + 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
| 292 | + 'html_class' => 'ee-reg-form-attendee-dv', |
|
| 293 | + 'html_style' => $this->checkout->admin_request |
|
| 294 | + ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
|
| 295 | + : '', |
|
| 296 | + 'subsections' => array(), |
|
| 297 | + 'layout_strategy' => new EE_Fieldset_Section_Layout( |
|
| 298 | + array( |
|
| 299 | + 'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text', |
|
| 300 | + 'legend_text' => sprintf( |
|
| 301 | + esc_html_x( |
|
| 302 | + 'Attendee %d', |
|
| 303 | + 'Attendee 123', |
|
| 304 | + 'event_espresso' |
|
| 305 | + ), |
|
| 306 | + $attendee_nmbr |
|
| 307 | + ), |
|
| 308 | + ) |
|
| 309 | + ), |
|
| 310 | + ); |
|
| 311 | + foreach ($question_groups as $question_group) { |
|
| 312 | + if ($question_group instanceof EE_Question_Group) { |
|
| 313 | + $form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form( |
|
| 314 | + $registration, |
|
| 315 | + $question_group |
|
| 316 | + ); |
|
| 317 | + } |
|
| 318 | + } |
|
| 319 | + // add hidden input |
|
| 320 | + $form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input( |
|
| 321 | + $registration |
|
| 322 | + ); |
|
| 323 | + |
|
| 324 | + /** |
|
| 325 | + * @var $reg_config EE_Registration_Config |
|
| 326 | + */ |
|
| 327 | + $reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config'); |
|
| 328 | + |
|
| 329 | + // if we have question groups for additional attendees, then display the copy options |
|
| 330 | + $this->_print_copy_info = $attendee_nmbr > 1 ? $reg_config->copyAttendeeInfo() : false; |
|
| 331 | + if ($registration->is_primary_registrant()) { |
|
| 332 | + // generate hidden input |
|
| 333 | + $form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs( |
|
| 334 | + $registration |
|
| 335 | + ); |
|
| 336 | + } |
|
| 337 | + } |
|
| 338 | + } |
|
| 339 | + $attendee_nmbr++; |
|
| 340 | + return ! empty($form_args) |
|
| 341 | + ? new EE_Form_Section_Proper($form_args) |
|
| 342 | + : new EE_Form_Section_HTML(); |
|
| 343 | + } |
|
| 344 | + |
|
| 345 | + |
|
| 346 | + /** |
|
| 347 | + * @param EE_Registration $registration |
|
| 348 | + * @param bool $additional_attendee_reg_info |
|
| 349 | + * @return EE_Form_Input_Base |
|
| 350 | + * @throws EE_Error |
|
| 351 | + */ |
|
| 352 | + private function _additional_attendee_reg_info_input( |
|
| 353 | + EE_Registration $registration, |
|
| 354 | + $additional_attendee_reg_info = true |
|
| 355 | + ) { |
|
| 356 | + // generate hidden input |
|
| 357 | + return new EE_Hidden_Input( |
|
| 358 | + array( |
|
| 359 | + 'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(), |
|
| 360 | + 'default' => $additional_attendee_reg_info, |
|
| 361 | + ) |
|
| 362 | + ); |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + |
|
| 366 | + /** |
|
| 367 | + * @param EE_Registration $registration |
|
| 368 | + * @param EE_Question_Group $question_group |
|
| 369 | + * @return EE_Form_Section_Proper |
|
| 370 | + * @throws EE_Error |
|
| 371 | + * @throws InvalidArgumentException |
|
| 372 | + * @throws InvalidDataTypeException |
|
| 373 | + * @throws InvalidInterfaceException |
|
| 374 | + * @throws ReflectionException |
|
| 375 | + */ |
|
| 376 | + private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group) |
|
| 377 | + { |
|
| 378 | + // array of params to pass to parent constructor |
|
| 379 | + $form_args = array( |
|
| 380 | + 'html_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' . $registration->ID(), |
|
| 381 | + 'html_class' => $this->checkout->admin_request |
|
| 382 | + ? 'form-table ee-reg-form-qstn-grp-dv' |
|
| 383 | + : 'ee-reg-form-qstn-grp-dv', |
|
| 384 | + 'html_label_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' |
|
| 385 | + . $registration->ID() . '-lbl', |
|
| 386 | + 'subsections' => array( |
|
| 387 | + 'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group), |
|
| 388 | + ), |
|
| 389 | + 'layout_strategy' => $this->checkout->admin_request |
|
| 390 | + ? new EE_Admin_Two_Column_Layout() |
|
| 391 | + : new EE_Div_Per_Section_Layout(), |
|
| 392 | + ); |
|
| 393 | + // where params |
|
| 394 | + $query_params = array('QST_deleted' => 0); |
|
| 395 | + // don't load admin only questions on the frontend |
|
| 396 | + if (! $this->checkout->admin_request) { |
|
| 397 | + $query_params['QST_admin_only'] = array('!=', true); |
|
| 398 | + } |
|
| 399 | + $questions = $question_group->get_many_related( |
|
| 400 | + 'Question', |
|
| 401 | + apply_filters( |
|
| 402 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__related_questions_query_params', |
|
| 403 | + array( |
|
| 404 | + $query_params, |
|
| 405 | + 'order_by' => array( |
|
| 406 | + 'Question_Group_Question.QGQ_order' => 'ASC', |
|
| 407 | + ), |
|
| 408 | + ), |
|
| 409 | + $question_group, |
|
| 410 | + $registration, |
|
| 411 | + $this |
|
| 412 | + ) |
|
| 413 | + ); |
|
| 414 | + // filter for additional content before questions |
|
| 415 | + $form_args['subsections']['reg_form_questions_before'] = new EE_Form_Section_HTML( |
|
| 416 | + apply_filters( |
|
| 417 | + 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', |
|
| 418 | + '', |
|
| 419 | + $registration, |
|
| 420 | + $question_group, |
|
| 421 | + $this |
|
| 422 | + ) |
|
| 423 | + ); |
|
| 424 | + // loop thru questions |
|
| 425 | + foreach ($questions as $question) { |
|
| 426 | + if ($question instanceof EE_Question) { |
|
| 427 | + $identifier = $question->is_system_question() |
|
| 428 | + ? $question->system_ID() |
|
| 429 | + : $question->ID(); |
|
| 430 | + $form_args['subsections'][ $identifier ] = $this->reg_form_question($registration, $question); |
|
| 431 | + } |
|
| 432 | + } |
|
| 433 | + $form_args['subsections'] = apply_filters( |
|
| 434 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array', |
|
| 435 | + $form_args['subsections'], |
|
| 436 | + $registration, |
|
| 437 | + $question_group, |
|
| 438 | + $this |
|
| 439 | + ); |
|
| 440 | + // filter for additional content after questions |
|
| 441 | + $form_args['subsections']['reg_form_questions_after'] = new EE_Form_Section_HTML( |
|
| 442 | + apply_filters( |
|
| 443 | + 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', |
|
| 444 | + '', |
|
| 445 | + $registration, |
|
| 446 | + $question_group, |
|
| 447 | + $this |
|
| 448 | + ) |
|
| 449 | + ); |
|
| 450 | + // d($form_args); |
|
| 451 | + $question_group_reg_form = new EE_Form_Section_Proper($form_args); |
|
| 452 | + return apply_filters( |
|
| 453 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
|
| 454 | + $question_group_reg_form, |
|
| 455 | + $registration, |
|
| 456 | + $question_group, |
|
| 457 | + $this |
|
| 458 | + ); |
|
| 459 | + } |
|
| 460 | + |
|
| 461 | + |
|
| 462 | + /** |
|
| 463 | + * @param EE_Question_Group $question_group |
|
| 464 | + * @return EE_Form_Section_HTML |
|
| 465 | + */ |
|
| 466 | + private function _question_group_header(EE_Question_Group $question_group) |
|
| 467 | + { |
|
| 468 | + $html = ''; |
|
| 469 | + // group_name |
|
| 470 | + if ($question_group->show_group_name() && $question_group->name() !== '') { |
|
| 471 | + if ($this->checkout->admin_request) { |
|
| 472 | + $html .= EEH_HTML::br(); |
|
| 473 | + $html .= EEH_HTML::h3( |
|
| 474 | + $question_group->name(), |
|
| 475 | + '', |
|
| 476 | + 'ee-reg-form-qstn-grp-title title', |
|
| 477 | + 'font-size: 1.3em; padding-left:0;' |
|
| 478 | + ); |
|
| 479 | + } else { |
|
| 480 | + $html .= EEH_HTML::h4( |
|
| 481 | + $question_group->name(), |
|
| 482 | + '', |
|
| 483 | + 'ee-reg-form-qstn-grp-title section-title' |
|
| 484 | + ); |
|
| 485 | + } |
|
| 486 | + } |
|
| 487 | + // group_desc |
|
| 488 | + if ($question_group->show_group_desc() && $question_group->desc() !== '') { |
|
| 489 | + $html .= EEH_HTML::p( |
|
| 490 | + $question_group->desc(), |
|
| 491 | + '', |
|
| 492 | + $this->checkout->admin_request |
|
| 493 | + ? 'ee-reg-form-qstn-grp-desc-pg' |
|
| 494 | + : 'ee-reg-form-qstn-grp-desc-pg small-text lt-grey-text' |
|
| 495 | + ); |
|
| 496 | + } |
|
| 497 | + return new EE_Form_Section_HTML($html); |
|
| 498 | + } |
|
| 499 | + |
|
| 500 | + |
|
| 501 | + /** |
|
| 502 | + * @return EE_Form_Section_Proper |
|
| 503 | + * @throws EE_Error |
|
| 504 | + * @throws InvalidArgumentException |
|
| 505 | + * @throws ReflectionException |
|
| 506 | + * @throws InvalidDataTypeException |
|
| 507 | + * @throws InvalidInterfaceException |
|
| 508 | + */ |
|
| 509 | + private function _copy_attendee_info_form() |
|
| 510 | + { |
|
| 511 | + // array of params to pass to parent constructor |
|
| 512 | + return new EE_Form_Section_Proper( |
|
| 513 | + array( |
|
| 514 | + 'subsections' => $this->_copy_attendee_info_inputs(), |
|
| 515 | + 'layout_strategy' => new EE_Template_Layout( |
|
| 516 | + array( |
|
| 517 | + 'layout_template_file' => SPCO_REG_STEPS_PATH |
|
| 518 | + . $this->_slug |
|
| 519 | + . '/copy_attendee_info.template.php', |
|
| 520 | + 'begin_template_file' => null, |
|
| 521 | + 'input_template_file' => null, |
|
| 522 | + 'subsection_template_file' => null, |
|
| 523 | + 'end_template_file' => null, |
|
| 524 | + ) |
|
| 525 | + ), |
|
| 526 | + ) |
|
| 527 | + ); |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + |
|
| 531 | + /** |
|
| 532 | + * @return EE_Form_Section_HTML |
|
| 533 | + * @throws DomainException |
|
| 534 | + * @throws InvalidArgumentException |
|
| 535 | + * @throws InvalidDataTypeException |
|
| 536 | + * @throws InvalidInterfaceException |
|
| 537 | + */ |
|
| 538 | + private function _auto_copy_attendee_info() |
|
| 539 | + { |
|
| 540 | + return new EE_Form_Section_HTML( |
|
| 541 | + EEH_Template::locate_template( |
|
| 542 | + SPCO_REG_STEPS_PATH . $this->_slug . '/_auto_copy_attendee_info.template.php', |
|
| 543 | + apply_filters( |
|
| 544 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', |
|
| 545 | + array() |
|
| 546 | + ), |
|
| 547 | + true, |
|
| 548 | + true |
|
| 549 | + ) |
|
| 550 | + ); |
|
| 551 | + } |
|
| 552 | + |
|
| 553 | + |
|
| 554 | + /** |
|
| 555 | + * @return array |
|
| 556 | + * @throws EE_Error |
|
| 557 | + * @throws InvalidArgumentException |
|
| 558 | + * @throws ReflectionException |
|
| 559 | + * @throws InvalidDataTypeException |
|
| 560 | + * @throws InvalidInterfaceException |
|
| 561 | + */ |
|
| 562 | + private function _copy_attendee_info_inputs() |
|
| 563 | + { |
|
| 564 | + $copy_attendee_info_inputs = array(); |
|
| 565 | + $prev_ticket = null; |
|
| 566 | + // grab the saved registrations from the transaction |
|
| 567 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
| 568 | + foreach ($registrations as $registration) { |
|
| 569 | + // for all attendees other than the primary attendee |
|
| 570 | + if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) { |
|
| 571 | + // if this is a new ticket OR if this is the very first additional attendee after the primary attendee |
|
| 572 | + if ($registration->ticket()->ID() !== $prev_ticket) { |
|
| 573 | + $item_name = $registration->ticket()->name(); |
|
| 574 | + $item_name .= $registration->ticket()->description() !== '' |
|
| 575 | + ? ' - ' . $registration->ticket()->description() |
|
| 576 | + : ''; |
|
| 577 | + $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID( |
|
| 578 | + ) . ']' ] = |
|
| 579 | + new EE_Form_Section_HTML( |
|
| 580 | + '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>' |
|
| 581 | + ); |
|
| 582 | + $prev_ticket = $registration->ticket()->ID(); |
|
| 583 | + } |
|
| 584 | + |
|
| 585 | + $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] = |
|
| 586 | + new EE_Checkbox_Multi_Input( |
|
| 587 | + array( |
|
| 588 | + $registration->ID() => sprintf( |
|
| 589 | + esc_html_x('Attendee #%s', 'Attendee #123', 'event_espresso'), |
|
| 590 | + $registration->count() |
|
| 591 | + ), |
|
| 592 | + ), |
|
| 593 | + array( |
|
| 594 | + 'html_id' => 'spco-copy-attendee-chk-' . $registration->reg_url_link(), |
|
| 595 | + 'html_class' => 'spco-copy-attendee-chk ee-do-not-validate', |
|
| 596 | + 'display_html_label_text' => false, |
|
| 597 | + ) |
|
| 598 | + ); |
|
| 599 | + } |
|
| 600 | + } |
|
| 601 | + return $copy_attendee_info_inputs; |
|
| 602 | + } |
|
| 603 | + |
|
| 604 | + |
|
| 605 | + /** |
|
| 606 | + * @param EE_Registration $registration |
|
| 607 | + * @return EE_Form_Input_Base |
|
| 608 | + * @throws EE_Error |
|
| 609 | + */ |
|
| 610 | + private function _additional_primary_registrant_inputs(EE_Registration $registration) |
|
| 611 | + { |
|
| 612 | + // generate hidden input |
|
| 613 | + return new EE_Hidden_Input( |
|
| 614 | + array( |
|
| 615 | + 'html_id' => 'primary_registrant', |
|
| 616 | + 'default' => $registration->reg_url_link(), |
|
| 617 | + ) |
|
| 618 | + ); |
|
| 619 | + } |
|
| 620 | + |
|
| 621 | + |
|
| 622 | + /** |
|
| 623 | + * @param EE_Registration $registration |
|
| 624 | + * @param EE_Question $question |
|
| 625 | + * @return EE_Form_Input_Base |
|
| 626 | + * @throws EE_Error |
|
| 627 | + * @throws InvalidArgumentException |
|
| 628 | + * @throws InvalidDataTypeException |
|
| 629 | + * @throws InvalidInterfaceException |
|
| 630 | + * @throws ReflectionException |
|
| 631 | + */ |
|
| 632 | + public function reg_form_question(EE_Registration $registration, EE_Question $question) |
|
| 633 | + { |
|
| 634 | + |
|
| 635 | + // if this question was for an attendee detail, then check for that answer |
|
| 636 | + $answer_value = EEM_Answer::instance()->get_attendee_property_answer_value( |
|
| 637 | + $registration, |
|
| 638 | + $question->system_ID() |
|
| 639 | + ); |
|
| 640 | + $answer = $answer_value === null |
|
| 641 | + ? EEM_Answer::instance()->get_one( |
|
| 642 | + array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())) |
|
| 643 | + ) |
|
| 644 | + : null; |
|
| 645 | + // if NOT returning to edit an existing registration |
|
| 646 | + // OR if this question is for an attendee property |
|
| 647 | + // OR we still don't have an EE_Answer object |
|
| 648 | + if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) { |
|
| 649 | + // create an EE_Answer object for storing everything in |
|
| 650 | + $answer = EE_Answer::new_instance( |
|
| 651 | + array( |
|
| 652 | + 'QST_ID' => $question->ID(), |
|
| 653 | + 'REG_ID' => $registration->ID(), |
|
| 654 | + ) |
|
| 655 | + ); |
|
| 656 | + } |
|
| 657 | + // verify instance |
|
| 658 | + if ($answer instanceof EE_Answer) { |
|
| 659 | + if (! empty($answer_value)) { |
|
| 660 | + $answer->set('ANS_value', $answer_value); |
|
| 661 | + } |
|
| 662 | + $answer->cache('Question', $question); |
|
| 663 | + // remember system ID had a bug where sometimes it could be null |
|
| 664 | + $answer_cache_id = $question->is_system_question() |
|
| 665 | + ? $question->system_ID() . '-' . $registration->reg_url_link() |
|
| 666 | + : $question->ID() . '-' . $registration->reg_url_link(); |
|
| 667 | + $registration->cache('Answer', $answer, $answer_cache_id); |
|
| 668 | + } |
|
| 669 | + return $this->_generate_question_input($registration, $question, $answer); |
|
| 670 | + } |
|
| 671 | + |
|
| 672 | + |
|
| 673 | + /** |
|
| 674 | + * @param EE_Registration $registration |
|
| 675 | + * @param EE_Question $question |
|
| 676 | + * @param $answer |
|
| 677 | + * @return EE_Form_Input_Base |
|
| 678 | + * @throws EE_Error |
|
| 679 | + * @throws InvalidArgumentException |
|
| 680 | + * @throws ReflectionException |
|
| 681 | + * @throws InvalidDataTypeException |
|
| 682 | + * @throws InvalidInterfaceException |
|
| 683 | + */ |
|
| 684 | + private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer) |
|
| 685 | + { |
|
| 686 | + $identifier = $question->is_system_question() |
|
| 687 | + ? $question->system_ID() |
|
| 688 | + : $question->ID(); |
|
| 689 | + $this->_required_questions[ $identifier ] = $question->required() ? true : false; |
|
| 690 | + add_filter( |
|
| 691 | + 'FHEE__EE_Question__generate_form_input__country_options', |
|
| 692 | + array($this, 'use_cached_countries_for_form_input'), |
|
| 693 | + 10, |
|
| 694 | + 4 |
|
| 695 | + ); |
|
| 696 | + add_filter( |
|
| 697 | + 'FHEE__EE_Question__generate_form_input__state_options', |
|
| 698 | + array($this, 'use_cached_states_for_form_input'), |
|
| 699 | + 10, |
|
| 700 | + 4 |
|
| 701 | + ); |
|
| 702 | + $input_constructor_args = array( |
|
| 703 | + 'html_name' => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']', |
|
| 704 | + 'html_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
| 705 | + 'html_class' => 'ee-reg-qstn ee-reg-qstn-' . $identifier, |
|
| 706 | + 'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
| 707 | + 'html_label_class' => 'ee-reg-qstn', |
|
| 708 | + ); |
|
| 709 | + $input_constructor_args['html_label_id'] .= '-lbl'; |
|
| 710 | + if ($answer instanceof EE_Answer && $answer->ID()) { |
|
| 711 | + $input_constructor_args['html_name'] .= '[' . $answer->ID() . ']'; |
|
| 712 | + $input_constructor_args['html_id'] .= '-' . $answer->ID(); |
|
| 713 | + $input_constructor_args['html_label_id'] .= '-' . $answer->ID(); |
|
| 714 | + } |
|
| 715 | + $form_input = $question->generate_form_input( |
|
| 716 | + $registration, |
|
| 717 | + $answer, |
|
| 718 | + $input_constructor_args |
|
| 719 | + ); |
|
| 720 | + remove_filter( |
|
| 721 | + 'FHEE__EE_Question__generate_form_input__country_options', |
|
| 722 | + array($this, 'use_cached_countries_for_form_input') |
|
| 723 | + ); |
|
| 724 | + remove_filter( |
|
| 725 | + 'FHEE__EE_Question__generate_form_input__state_options', |
|
| 726 | + array($this, 'use_cached_states_for_form_input') |
|
| 727 | + ); |
|
| 728 | + return $form_input; |
|
| 729 | + } |
|
| 730 | + |
|
| 731 | + |
|
| 732 | + /** |
|
| 733 | + * Gets the list of countries for the form input |
|
| 734 | + * |
|
| 735 | + * @param array|null $countries_list |
|
| 736 | + * @param EE_Question $question |
|
| 737 | + * @param EE_Registration $registration |
|
| 738 | + * @param EE_Answer $answer |
|
| 739 | + * @return array 2d keys are country IDs, values are their names |
|
| 740 | + * @throws EE_Error |
|
| 741 | + * @throws InvalidArgumentException |
|
| 742 | + * @throws InvalidDataTypeException |
|
| 743 | + * @throws InvalidInterfaceException |
|
| 744 | + * @throws ReflectionException |
|
| 745 | + */ |
|
| 746 | + public function use_cached_countries_for_form_input( |
|
| 747 | + $countries_list, |
|
| 748 | + EE_Question $question = null, |
|
| 749 | + EE_Registration $registration = null, |
|
| 750 | + EE_Answer $answer = null |
|
| 751 | + ) { |
|
| 752 | + $country_options = array('' => ''); |
|
| 753 | + // get possibly cached list of countries |
|
| 754 | + $countries = $this->checkout->action === 'process_reg_step' |
|
| 755 | + ? EEM_Country::instance()->get_all_countries() |
|
| 756 | + : EEM_Country::instance()->get_all_active_countries(); |
|
| 757 | + if (! empty($countries)) { |
|
| 758 | + foreach ($countries as $country) { |
|
| 759 | + if ($country instanceof EE_Country) { |
|
| 760 | + $country_options[ $country->ID() ] = $country->name(); |
|
| 761 | + } |
|
| 762 | + } |
|
| 763 | + } |
|
| 764 | + if ($question instanceof EE_Question && $registration instanceof EE_Registration) { |
|
| 765 | + $answer = EEM_Answer::instance()->get_one( |
|
| 766 | + array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())) |
|
| 767 | + ); |
|
| 768 | + } else { |
|
| 769 | + $answer = EE_Answer::new_instance(); |
|
| 770 | + } |
|
| 771 | + $country_options = apply_filters( |
|
| 772 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', |
|
| 773 | + $country_options, |
|
| 774 | + $this, |
|
| 775 | + $registration, |
|
| 776 | + $question, |
|
| 777 | + $answer |
|
| 778 | + ); |
|
| 779 | + return $country_options; |
|
| 780 | + } |
|
| 781 | + |
|
| 782 | + |
|
| 783 | + /** |
|
| 784 | + * Gets the list of states for the form input |
|
| 785 | + * |
|
| 786 | + * @param array|null $states_list |
|
| 787 | + * @param EE_Question $question |
|
| 788 | + * @param EE_Registration $registration |
|
| 789 | + * @param EE_Answer $answer |
|
| 790 | + * @return array 2d keys are state IDs, values are their names |
|
| 791 | + * @throws EE_Error |
|
| 792 | + * @throws InvalidArgumentException |
|
| 793 | + * @throws InvalidDataTypeException |
|
| 794 | + * @throws InvalidInterfaceException |
|
| 795 | + * @throws ReflectionException |
|
| 796 | + */ |
|
| 797 | + public function use_cached_states_for_form_input( |
|
| 798 | + $states_list, |
|
| 799 | + EE_Question $question = null, |
|
| 800 | + EE_Registration $registration = null, |
|
| 801 | + EE_Answer $answer = null |
|
| 802 | + ) { |
|
| 803 | + $state_options = array('' => array('' => '')); |
|
| 804 | + $states = $this->checkout->action === 'process_reg_step' |
|
| 805 | + ? EEM_State::instance()->get_all_states() |
|
| 806 | + : EEM_State::instance()->get_all_active_states(); |
|
| 807 | + if (! empty($states)) { |
|
| 808 | + foreach ($states as $state) { |
|
| 809 | + if ($state instanceof EE_State) { |
|
| 810 | + $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name(); |
|
| 811 | + } |
|
| 812 | + } |
|
| 813 | + } |
|
| 814 | + $state_options = apply_filters( |
|
| 815 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', |
|
| 816 | + $state_options, |
|
| 817 | + $this, |
|
| 818 | + $registration, |
|
| 819 | + $question, |
|
| 820 | + $answer |
|
| 821 | + ); |
|
| 822 | + return $state_options; |
|
| 823 | + } |
|
| 824 | + |
|
| 825 | + |
|
| 826 | + /********************************************************************************************************/ |
|
| 827 | + /**************************************** PROCESS REG STEP ****************************************/ |
|
| 828 | + /********************************************************************************************************/ |
|
| 829 | + |
|
| 830 | + |
|
| 831 | + /** |
|
| 832 | + * @return bool |
|
| 833 | + * @throws EE_Error |
|
| 834 | + * @throws InvalidArgumentException |
|
| 835 | + * @throws ReflectionException |
|
| 836 | + * @throws RuntimeException |
|
| 837 | + * @throws InvalidDataTypeException |
|
| 838 | + * @throws InvalidInterfaceException |
|
| 839 | + */ |
|
| 840 | + public function process_reg_step() |
|
| 841 | + { |
|
| 842 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 843 | + // grab validated data from form |
|
| 844 | + $valid_data = $this->checkout->current_step->valid_data(); |
|
| 845 | + // EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
|
| 846 | + // EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ ); |
|
| 847 | + // if we don't have any $valid_data then something went TERRIBLY WRONG !!! |
|
| 848 | + if (empty($valid_data)) { |
|
| 849 | + EE_Error::add_error( |
|
| 850 | + esc_html__('No valid question responses were received.', 'event_espresso'), |
|
| 851 | + __FILE__, |
|
| 852 | + __FUNCTION__, |
|
| 853 | + __LINE__ |
|
| 854 | + ); |
|
| 855 | + return false; |
|
| 856 | + } |
|
| 857 | + if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
| 858 | + EE_Error::add_error( |
|
| 859 | + esc_html__( |
|
| 860 | + 'A valid transaction could not be initiated for processing your registrations.', |
|
| 861 | + 'event_espresso' |
|
| 862 | + ), |
|
| 863 | + __FILE__, |
|
| 864 | + __FUNCTION__, |
|
| 865 | + __LINE__ |
|
| 866 | + ); |
|
| 867 | + return false; |
|
| 868 | + } |
|
| 869 | + // get cached registrations |
|
| 870 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
| 871 | + // verify we got the goods |
|
| 872 | + if (empty($registrations)) { |
|
| 873 | + // combine the old translated string with a new one, in order to not break translations |
|
| 874 | + $error_message = esc_html__( |
|
| 875 | + 'Your form data could not be applied to any valid registrations.', |
|
| 876 | + 'event_espresso' |
|
| 877 | + ) |
|
| 878 | + . sprintf( |
|
| 879 | + esc_html_x( |
|
| 880 | + '%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
| 881 | + '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
| 882 | + 'event_espresso' |
|
| 883 | + ), |
|
| 884 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
| 885 | + '</a>', |
|
| 886 | + '<br />' |
|
| 887 | + ); |
|
| 888 | + EE_Error::add_error( |
|
| 889 | + $error_message, |
|
| 890 | + __FILE__, |
|
| 891 | + __FUNCTION__, |
|
| 892 | + __LINE__ |
|
| 893 | + ); |
|
| 894 | + return false; |
|
| 895 | + } |
|
| 896 | + // extract attendee info from form data and save to model objects |
|
| 897 | + $registrations_processed = $this->_process_registrations($registrations, $valid_data); |
|
| 898 | + // if first pass thru SPCO, |
|
| 899 | + // then let's check processed registrations against the total number of tickets in the cart |
|
| 900 | + if ($registrations_processed === false) { |
|
| 901 | + // but return immediately if the previous step exited early due to errors |
|
| 902 | + return false; |
|
| 903 | + } |
|
| 904 | + if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
| 905 | + // generate a correctly translated string for all possible singular/plural combinations |
|
| 906 | + if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
|
| 907 | + $error_msg = sprintf( |
|
| 908 | + esc_html_x( |
|
| 909 | + 'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', |
|
| 910 | + 'There was 1 ticket in the Event Queue, but 2 registrations were processed', |
|
| 911 | + 'event_espresso' |
|
| 912 | + ), |
|
| 913 | + $this->checkout->total_ticket_count, |
|
| 914 | + $registrations_processed |
|
| 915 | + ); |
|
| 916 | + } elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) { |
|
| 917 | + $error_msg = sprintf( |
|
| 918 | + esc_html_x( |
|
| 919 | + 'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', |
|
| 920 | + 'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed', |
|
| 921 | + 'event_espresso' |
|
| 922 | + ), |
|
| 923 | + $this->checkout->total_ticket_count, |
|
| 924 | + $registrations_processed |
|
| 925 | + ); |
|
| 926 | + } else { |
|
| 927 | + $error_msg = sprintf( |
|
| 928 | + esc_html__( |
|
| 929 | + 'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed', |
|
| 930 | + 'event_espresso' |
|
| 931 | + ), |
|
| 932 | + $this->checkout->total_ticket_count, |
|
| 933 | + $registrations_processed |
|
| 934 | + ); |
|
| 935 | + } |
|
| 936 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 937 | + return false; |
|
| 938 | + } |
|
| 939 | + // mark this reg step as completed |
|
| 940 | + $this->set_completed(); |
|
| 941 | + $this->_set_success_message( |
|
| 942 | + esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso') |
|
| 943 | + ); |
|
| 944 | + // do action in case a plugin wants to do something with the data submitted in step 1. |
|
| 945 | + // passes EE_Single_Page_Checkout, and it's posted data |
|
| 946 | + do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data); |
|
| 947 | + return true; |
|
| 948 | + } |
|
| 949 | + |
|
| 950 | + |
|
| 951 | + /** |
|
| 952 | + * _process_registrations |
|
| 953 | + * |
|
| 954 | + * @param EE_Registration[] $registrations |
|
| 955 | + * @param array[][] $valid_data |
|
| 956 | + * @return bool|int |
|
| 957 | + * @throws EntityNotFoundException |
|
| 958 | + * @throws EE_Error |
|
| 959 | + * @throws InvalidArgumentException |
|
| 960 | + * @throws ReflectionException |
|
| 961 | + * @throws RuntimeException |
|
| 962 | + * @throws InvalidDataTypeException |
|
| 963 | + * @throws InvalidInterfaceException |
|
| 964 | + */ |
|
| 965 | + private function _process_registrations($registrations = array(), $valid_data = array()) |
|
| 966 | + { |
|
| 967 | + // load resources and set some defaults |
|
| 968 | + EE_Registry::instance()->load_model('Attendee'); |
|
| 969 | + // holder for primary registrant attendee object |
|
| 970 | + $this->checkout->primary_attendee_obj = null; |
|
| 971 | + // array for tracking reg form data for the primary registrant |
|
| 972 | + $primary_registrant = array( |
|
| 973 | + 'line_item_id' => null, |
|
| 974 | + ); |
|
| 975 | + $copy_primary = false; |
|
| 976 | + // reg form sections that do not contain inputs |
|
| 977 | + $non_input_form_sections = array( |
|
| 978 | + 'primary_registrant', |
|
| 979 | + 'additional_attendee_reg_info', |
|
| 980 | + 'spco_copy_attendee_chk', |
|
| 981 | + ); |
|
| 982 | + // attendee counter |
|
| 983 | + $att_nmbr = 0; |
|
| 984 | + // grab the saved registrations from the transaction |
|
| 985 | + foreach ($registrations as $registration) { |
|
| 986 | + // verify EE_Registration object |
|
| 987 | + if (! $registration instanceof EE_Registration) { |
|
| 988 | + EE_Error::add_error( |
|
| 989 | + esc_html__( |
|
| 990 | + 'An invalid Registration object was discovered when attempting to process your registration information.', |
|
| 991 | + 'event_espresso' |
|
| 992 | + ), |
|
| 993 | + __FILE__, |
|
| 994 | + __FUNCTION__, |
|
| 995 | + __LINE__ |
|
| 996 | + ); |
|
| 997 | + return false; |
|
| 998 | + } |
|
| 999 | + /** @var string $reg_url_link */ |
|
| 1000 | + $reg_url_link = $registration->reg_url_link(); |
|
| 1001 | + // reg_url_link exists ? |
|
| 1002 | + if (! empty($reg_url_link)) { |
|
| 1003 | + // should this registration be processed during this visit ? |
|
| 1004 | + if ($this->checkout->visit_allows_processing_of_this_registration($registration)) { |
|
| 1005 | + // if NOT revisiting, then let's save the registration now, |
|
| 1006 | + // so that we have a REG_ID to use when generating other objects |
|
| 1007 | + if (! $this->checkout->revisit) { |
|
| 1008 | + $registration->save(); |
|
| 1009 | + } |
|
| 1010 | + /** |
|
| 1011 | + * This allows plugins to trigger a fail on processing of a |
|
| 1012 | + * registration for any conditions they may have for it to pass. |
|
| 1013 | + * |
|
| 1014 | + * @var bool if true is returned by the plugin then the |
|
| 1015 | + * registration processing is halted. |
|
| 1016 | + */ |
|
| 1017 | + if (apply_filters( |
|
| 1018 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process', |
|
| 1019 | + false, |
|
| 1020 | + $att_nmbr, |
|
| 1021 | + $registration, |
|
| 1022 | + $registrations, |
|
| 1023 | + $valid_data, |
|
| 1024 | + $this |
|
| 1025 | + )) { |
|
| 1026 | + return false; |
|
| 1027 | + } |
|
| 1028 | + |
|
| 1029 | + // Houston, we have a registration! |
|
| 1030 | + $att_nmbr++; |
|
| 1031 | + $this->_attendee_data[ $reg_url_link ] = array(); |
|
| 1032 | + // grab any existing related answer objects |
|
| 1033 | + $this->_registration_answers = $registration->answers(); |
|
| 1034 | + // unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ); |
|
| 1035 | + if (isset($valid_data[ $reg_url_link ])) { |
|
| 1036 | + // do we need to copy basic info from primary attendee ? |
|
| 1037 | + $copy_primary = isset($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) |
|
| 1038 | + && absint($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) === 0; |
|
| 1039 | + // filter form input data for this registration |
|
| 1040 | + $valid_data[ $reg_url_link ] = (array) apply_filters( |
|
| 1041 | + 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
|
| 1042 | + $valid_data[ $reg_url_link ] |
|
| 1043 | + ); |
|
| 1044 | + if (isset($valid_data['primary_attendee'])) { |
|
| 1045 | + $primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee']) |
|
| 1046 | + ? $valid_data['primary_attendee'] |
|
| 1047 | + : false; |
|
| 1048 | + unset($valid_data['primary_attendee']); |
|
| 1049 | + } |
|
| 1050 | + // now loop through our array of valid post data && process attendee reg forms |
|
| 1051 | + foreach ($valid_data[ $reg_url_link ] as $form_section => $form_inputs) { |
|
| 1052 | + if (! in_array($form_section, $non_input_form_sections, true)) { |
|
| 1053 | + foreach ($form_inputs as $form_input => $input_value) { |
|
| 1054 | + // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ ); |
|
| 1055 | + // check for critical inputs |
|
| 1056 | + if (! $this->_verify_critical_attendee_details_are_set_and_validate_email( |
|
| 1057 | + $form_input, |
|
| 1058 | + $input_value |
|
| 1059 | + ) |
|
| 1060 | + ) { |
|
| 1061 | + return false; |
|
| 1062 | + } |
|
| 1063 | + // store a bit of data about the primary attendee |
|
| 1064 | + if ($att_nmbr === 1 |
|
| 1065 | + && ! empty($input_value) |
|
| 1066 | + && $reg_url_link === $primary_registrant['line_item_id'] |
|
| 1067 | + ) { |
|
| 1068 | + $primary_registrant[ $form_input ] = $input_value; |
|
| 1069 | + } elseif ($copy_primary |
|
| 1070 | + && $input_value === null |
|
| 1071 | + && isset($primary_registrant[ $form_input ]) |
|
| 1072 | + ) { |
|
| 1073 | + $input_value = $primary_registrant[ $form_input ]; |
|
| 1074 | + } |
|
| 1075 | + // now attempt to save the input data |
|
| 1076 | + if (! $this->_save_registration_form_input( |
|
| 1077 | + $registration, |
|
| 1078 | + $form_input, |
|
| 1079 | + $input_value |
|
| 1080 | + ) |
|
| 1081 | + ) { |
|
| 1082 | + EE_Error::add_error( |
|
| 1083 | + sprintf( |
|
| 1084 | + esc_html_x( |
|
| 1085 | + 'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"', |
|
| 1086 | + 'Unable to save registration form data for the form input: "form input name" with the submitted value: "form input value"', |
|
| 1087 | + 'event_espresso' |
|
| 1088 | + ), |
|
| 1089 | + $form_input, |
|
| 1090 | + $input_value |
|
| 1091 | + ), |
|
| 1092 | + __FILE__, |
|
| 1093 | + __FUNCTION__, |
|
| 1094 | + __LINE__ |
|
| 1095 | + ); |
|
| 1096 | + return false; |
|
| 1097 | + } |
|
| 1098 | + } |
|
| 1099 | + } |
|
| 1100 | + } // end of foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs ) |
|
| 1101 | + } |
|
| 1102 | + // EEH_Debug_Tools::printr( $this->_attendee_data, '$this->_attendee_data', __FILE__, __LINE__ ); |
|
| 1103 | + // this registration does not require additional attendee information ? |
|
| 1104 | + if ($copy_primary |
|
| 1105 | + && $att_nmbr > 1 |
|
| 1106 | + && $this->checkout->primary_attendee_obj instanceof EE_Attendee |
|
| 1107 | + ) { |
|
| 1108 | + // just copy the primary registrant |
|
| 1109 | + $attendee = $this->checkout->primary_attendee_obj; |
|
| 1110 | + } else { |
|
| 1111 | + // ensure critical details are set for additional attendees |
|
| 1112 | + $this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1 |
|
| 1113 | + ? $this->_copy_critical_attendee_details_from_primary_registrant( |
|
| 1114 | + $this->_attendee_data[ $reg_url_link ] |
|
| 1115 | + ) |
|
| 1116 | + : $this->_attendee_data[ $reg_url_link ]; |
|
| 1117 | + // execute create attendee command (which may return an existing attendee) |
|
| 1118 | + $attendee = EE_Registry::instance()->BUS->execute( |
|
| 1119 | + new CreateAttendeeCommand( |
|
| 1120 | + $this->_attendee_data[ $reg_url_link ], |
|
| 1121 | + $registration |
|
| 1122 | + ) |
|
| 1123 | + ); |
|
| 1124 | + // who's #1 ? |
|
| 1125 | + if ($att_nmbr === 1) { |
|
| 1126 | + $this->checkout->primary_attendee_obj = $attendee; |
|
| 1127 | + } |
|
| 1128 | + } |
|
| 1129 | + // EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ ); |
|
| 1130 | + // add relation to registration, set attendee ID, and cache attendee |
|
| 1131 | + $this->_associate_attendee_with_registration($registration, $attendee); |
|
| 1132 | + // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ ); |
|
| 1133 | + if (! $registration->attendee() instanceof EE_Attendee) { |
|
| 1134 | + EE_Error::add_error( |
|
| 1135 | + sprintf( |
|
| 1136 | + esc_html_x( |
|
| 1137 | + 'Registration %s has an invalid or missing Attendee object.', |
|
| 1138 | + 'Registration 123-456-789 has an invalid or missing Attendee object.', |
|
| 1139 | + 'event_espresso' |
|
| 1140 | + ), |
|
| 1141 | + $reg_url_link |
|
| 1142 | + ), |
|
| 1143 | + __FILE__, |
|
| 1144 | + __FUNCTION__, |
|
| 1145 | + __LINE__ |
|
| 1146 | + ); |
|
| 1147 | + return false; |
|
| 1148 | + } |
|
| 1149 | + /** @type EE_Registration_Processor $registration_processor */ |
|
| 1150 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
| 1151 | + // at this point, we should have enough details about the registrant to consider the registration |
|
| 1152 | + // NOT incomplete |
|
| 1153 | + $registration_processor->toggle_incomplete_registration_status_to_default( |
|
| 1154 | + $registration, |
|
| 1155 | + false, |
|
| 1156 | + new Context( |
|
| 1157 | + 'spco_reg_step_attendee_information_process_registrations', |
|
| 1158 | + esc_html__( |
|
| 1159 | + 'Finished populating registration with details from the registration form after submitting the Attendee Information Reg Step.', |
|
| 1160 | + 'event_espresso' |
|
| 1161 | + ) |
|
| 1162 | + ) |
|
| 1163 | + ); |
|
| 1164 | + // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to |
|
| 1165 | + // abandoned |
|
| 1166 | + $this->checkout->transaction->toggle_failed_transaction_status(); |
|
| 1167 | + // if we've gotten this far, then let's save what we have |
|
| 1168 | + $registration->save(); |
|
| 1169 | + // add relation between TXN and registration |
|
| 1170 | + $this->_associate_registration_with_transaction($registration); |
|
| 1171 | + } |
|
| 1172 | + } else { |
|
| 1173 | + EE_Error::add_error( |
|
| 1174 | + esc_html__( |
|
| 1175 | + 'An invalid or missing line item ID was encountered while attempting to process the registration form.', |
|
| 1176 | + 'event_espresso' |
|
| 1177 | + ), |
|
| 1178 | + __FILE__, |
|
| 1179 | + __FUNCTION__, |
|
| 1180 | + __LINE__ |
|
| 1181 | + ); |
|
| 1182 | + // remove malformed data |
|
| 1183 | + unset($valid_data[ $reg_url_link ]); |
|
| 1184 | + return false; |
|
| 1185 | + } |
|
| 1186 | + } // end of foreach ( $this->checkout->transaction->registrations() as $registration ) |
|
| 1187 | + return $att_nmbr; |
|
| 1188 | + } |
|
| 1189 | + |
|
| 1190 | + |
|
| 1191 | + /** |
|
| 1192 | + * _save_registration_form_input |
|
| 1193 | + * |
|
| 1194 | + * @param EE_Registration $registration |
|
| 1195 | + * @param string $form_input |
|
| 1196 | + * @param string $input_value |
|
| 1197 | + * @return bool |
|
| 1198 | + * @throws EE_Error |
|
| 1199 | + * @throws InvalidArgumentException |
|
| 1200 | + * @throws InvalidDataTypeException |
|
| 1201 | + * @throws InvalidInterfaceException |
|
| 1202 | + * @throws ReflectionException |
|
| 1203 | + */ |
|
| 1204 | + private function _save_registration_form_input( |
|
| 1205 | + EE_Registration $registration, |
|
| 1206 | + $form_input = '', |
|
| 1207 | + $input_value = '' |
|
| 1208 | + ) { |
|
| 1209 | + // \EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 ); |
|
| 1210 | + // \EEH_Debug_Tools::printr( $form_input, '$form_input', __FILE__, __LINE__ ); |
|
| 1211 | + // \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ ); |
|
| 1212 | + // allow for plugins to hook in and do their own processing of the form input. |
|
| 1213 | + // For plugins to bypass normal processing here, they just need to return a boolean value. |
|
| 1214 | + if (apply_filters( |
|
| 1215 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input', |
|
| 1216 | + false, |
|
| 1217 | + $registration, |
|
| 1218 | + $form_input, |
|
| 1219 | + $input_value, |
|
| 1220 | + $this |
|
| 1221 | + )) { |
|
| 1222 | + return true; |
|
| 1223 | + } |
|
| 1224 | + /* |
|
| 1225 | 1225 | * $answer_cache_id is the key used to find the EE_Answer we want |
| 1226 | 1226 | * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477 |
| 1227 | 1227 | */ |
| 1228 | - $answer_cache_id = $this->checkout->reg_url_link |
|
| 1229 | - ? $form_input . '-' . $registration->reg_url_link() |
|
| 1230 | - : $form_input; |
|
| 1231 | - $answer_is_obj = isset($this->_registration_answers[ $answer_cache_id ]) |
|
| 1232 | - && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer; |
|
| 1233 | - // rename form_inputs if they are EE_Attendee properties |
|
| 1234 | - switch ((string) $form_input) { |
|
| 1235 | - case 'state': |
|
| 1236 | - case 'STA_ID': |
|
| 1237 | - $attendee_property = true; |
|
| 1238 | - $form_input = 'STA_ID'; |
|
| 1239 | - break; |
|
| 1240 | - |
|
| 1241 | - case 'country': |
|
| 1242 | - case 'CNT_ISO': |
|
| 1243 | - $attendee_property = true; |
|
| 1244 | - $form_input = 'CNT_ISO'; |
|
| 1245 | - break; |
|
| 1246 | - |
|
| 1247 | - default: |
|
| 1248 | - $ATT_input = 'ATT_' . $form_input; |
|
| 1249 | - // EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ ); |
|
| 1250 | - $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false; |
|
| 1251 | - $form_input = $attendee_property ? 'ATT_' . $form_input : $form_input; |
|
| 1252 | - } |
|
| 1253 | - // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ ); |
|
| 1254 | - // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ ); |
|
| 1255 | - // EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ ); |
|
| 1256 | - // if this form input has a corresponding attendee property |
|
| 1257 | - if ($attendee_property) { |
|
| 1258 | - $this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value; |
|
| 1259 | - if ($answer_is_obj) { |
|
| 1260 | - // and delete the corresponding answer since we won't be storing this data in that object |
|
| 1261 | - $registration->_remove_relation_to($this->_registration_answers[ $answer_cache_id ], 'Answer'); |
|
| 1262 | - $this->_registration_answers[ $answer_cache_id ]->delete_permanently(); |
|
| 1263 | - } |
|
| 1264 | - return true; |
|
| 1265 | - } |
|
| 1266 | - if ($answer_is_obj) { |
|
| 1267 | - // save this data to the answer object |
|
| 1268 | - $this->_registration_answers[ $answer_cache_id ]->set_value($input_value); |
|
| 1269 | - $result = $this->_registration_answers[ $answer_cache_id ]->save(); |
|
| 1270 | - return $result !== false; |
|
| 1271 | - } |
|
| 1272 | - foreach ($this->_registration_answers as $answer) { |
|
| 1273 | - if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) { |
|
| 1274 | - $answer->set_value($input_value); |
|
| 1275 | - $result = $answer->save(); |
|
| 1276 | - return $result !== false; |
|
| 1277 | - } |
|
| 1278 | - } |
|
| 1279 | - return false; |
|
| 1280 | - } |
|
| 1281 | - |
|
| 1282 | - |
|
| 1283 | - /** |
|
| 1284 | - * _verify_critical_attendee_details_are_set |
|
| 1285 | - * |
|
| 1286 | - * @param string $form_input |
|
| 1287 | - * @param string $input_value |
|
| 1288 | - * @return boolean |
|
| 1289 | - */ |
|
| 1290 | - private function _verify_critical_attendee_details_are_set_and_validate_email( |
|
| 1291 | - $form_input = '', |
|
| 1292 | - $input_value = '' |
|
| 1293 | - ) { |
|
| 1294 | - if (empty($input_value)) { |
|
| 1295 | - // if the form input isn't marked as being required, then just return |
|
| 1296 | - if (! isset($this->_required_questions[ $form_input ]) || ! $this->_required_questions[ $form_input ]) { |
|
| 1297 | - return true; |
|
| 1298 | - } |
|
| 1299 | - switch ($form_input) { |
|
| 1300 | - case 'fname': |
|
| 1301 | - EE_Error::add_error( |
|
| 1302 | - esc_html__('First Name is a required value.', 'event_espresso'), |
|
| 1303 | - __FILE__, |
|
| 1304 | - __FUNCTION__, |
|
| 1305 | - __LINE__ |
|
| 1306 | - ); |
|
| 1307 | - return false; |
|
| 1308 | - break; |
|
| 1309 | - case 'lname': |
|
| 1310 | - EE_Error::add_error( |
|
| 1311 | - esc_html__('Last Name is a required value.', 'event_espresso'), |
|
| 1312 | - __FILE__, |
|
| 1313 | - __FUNCTION__, |
|
| 1314 | - __LINE__ |
|
| 1315 | - ); |
|
| 1316 | - return false; |
|
| 1317 | - break; |
|
| 1318 | - case 'email': |
|
| 1319 | - EE_Error::add_error( |
|
| 1320 | - esc_html__('Please enter a valid email address.', 'event_espresso'), |
|
| 1321 | - __FILE__, |
|
| 1322 | - __FUNCTION__, |
|
| 1323 | - __LINE__ |
|
| 1324 | - ); |
|
| 1325 | - return false; |
|
| 1326 | - break; |
|
| 1327 | - } |
|
| 1328 | - } |
|
| 1329 | - return true; |
|
| 1330 | - } |
|
| 1331 | - |
|
| 1332 | - |
|
| 1333 | - /** |
|
| 1334 | - * _associate_attendee_with_registration |
|
| 1335 | - * |
|
| 1336 | - * @param EE_Registration $registration |
|
| 1337 | - * @param EE_Attendee $attendee |
|
| 1338 | - * @return void |
|
| 1339 | - * @throws EE_Error |
|
| 1340 | - * @throws InvalidArgumentException |
|
| 1341 | - * @throws ReflectionException |
|
| 1342 | - * @throws RuntimeException |
|
| 1343 | - * @throws InvalidDataTypeException |
|
| 1344 | - * @throws InvalidInterfaceException |
|
| 1345 | - */ |
|
| 1346 | - private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee) |
|
| 1347 | - { |
|
| 1348 | - // add relation to attendee |
|
| 1349 | - $registration->_add_relation_to($attendee, 'Attendee'); |
|
| 1350 | - $registration->set_attendee_id($attendee->ID()); |
|
| 1351 | - $registration->update_cache_after_object_save('Attendee', $attendee); |
|
| 1352 | - } |
|
| 1353 | - |
|
| 1354 | - |
|
| 1355 | - /** |
|
| 1356 | - * _associate_registration_with_transaction |
|
| 1357 | - * |
|
| 1358 | - * @param EE_Registration $registration |
|
| 1359 | - * @return void |
|
| 1360 | - * @throws EE_Error |
|
| 1361 | - * @throws InvalidArgumentException |
|
| 1362 | - * @throws ReflectionException |
|
| 1363 | - * @throws InvalidDataTypeException |
|
| 1364 | - * @throws InvalidInterfaceException |
|
| 1365 | - */ |
|
| 1366 | - private function _associate_registration_with_transaction(EE_Registration $registration) |
|
| 1367 | - { |
|
| 1368 | - // add relation to registration |
|
| 1369 | - $this->checkout->transaction->_add_relation_to($registration, 'Registration'); |
|
| 1370 | - $this->checkout->transaction->update_cache_after_object_save('Registration', $registration); |
|
| 1371 | - } |
|
| 1372 | - |
|
| 1373 | - |
|
| 1374 | - /** |
|
| 1375 | - * _copy_critical_attendee_details_from_primary_registrant |
|
| 1376 | - * ensures that all attendees at least have data for first name, last name, and email address |
|
| 1377 | - * |
|
| 1378 | - * @param array $attendee_data |
|
| 1379 | - * @return array |
|
| 1380 | - * @throws EE_Error |
|
| 1381 | - * @throws InvalidArgumentException |
|
| 1382 | - * @throws ReflectionException |
|
| 1383 | - * @throws InvalidDataTypeException |
|
| 1384 | - * @throws InvalidInterfaceException |
|
| 1385 | - */ |
|
| 1386 | - private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array()) |
|
| 1387 | - { |
|
| 1388 | - // bare minimum critical details include first name, last name, email address |
|
| 1389 | - $critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email'); |
|
| 1390 | - // add address info to critical details? |
|
| 1391 | - if (apply_filters( |
|
| 1392 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details', |
|
| 1393 | - false |
|
| 1394 | - )) { |
|
| 1395 | - $address_details = array( |
|
| 1396 | - 'ATT_address', |
|
| 1397 | - 'ATT_address2', |
|
| 1398 | - 'ATT_city', |
|
| 1399 | - 'STA_ID', |
|
| 1400 | - 'CNT_ISO', |
|
| 1401 | - 'ATT_zip', |
|
| 1402 | - 'ATT_phone', |
|
| 1403 | - ); |
|
| 1404 | - $critical_attendee_details = array_merge($critical_attendee_details, $address_details); |
|
| 1405 | - } |
|
| 1406 | - foreach ($critical_attendee_details as $critical_attendee_detail) { |
|
| 1407 | - if (! isset($attendee_data[ $critical_attendee_detail ]) |
|
| 1408 | - || empty($attendee_data[ $critical_attendee_detail ]) |
|
| 1409 | - ) { |
|
| 1410 | - $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get( |
|
| 1411 | - $critical_attendee_detail |
|
| 1412 | - ); |
|
| 1413 | - } |
|
| 1414 | - } |
|
| 1415 | - return $attendee_data; |
|
| 1416 | - } |
|
| 1417 | - |
|
| 1418 | - |
|
| 1419 | - /** |
|
| 1420 | - * update_reg_step |
|
| 1421 | - * this is the final step after a user revisits the site to edit their attendee information |
|
| 1422 | - * this gets called AFTER the process_reg_step() method above |
|
| 1423 | - * |
|
| 1424 | - * @return bool |
|
| 1425 | - * @throws EE_Error |
|
| 1426 | - * @throws InvalidArgumentException |
|
| 1427 | - * @throws ReflectionException |
|
| 1428 | - * @throws RuntimeException |
|
| 1429 | - * @throws InvalidDataTypeException |
|
| 1430 | - * @throws InvalidInterfaceException |
|
| 1431 | - */ |
|
| 1432 | - public function update_reg_step() |
|
| 1433 | - { |
|
| 1434 | - // save everything |
|
| 1435 | - if ($this->process_reg_step()) { |
|
| 1436 | - $this->checkout->redirect = true; |
|
| 1437 | - $this->checkout->redirect_url = add_query_arg( |
|
| 1438 | - array( |
|
| 1439 | - 'e_reg_url_link' => $this->checkout->reg_url_link, |
|
| 1440 | - 'revisit' => true, |
|
| 1441 | - ), |
|
| 1442 | - $this->checkout->thank_you_page_url |
|
| 1443 | - ); |
|
| 1444 | - $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
| 1445 | - return true; |
|
| 1446 | - } |
|
| 1447 | - return false; |
|
| 1448 | - } |
|
| 1228 | + $answer_cache_id = $this->checkout->reg_url_link |
|
| 1229 | + ? $form_input . '-' . $registration->reg_url_link() |
|
| 1230 | + : $form_input; |
|
| 1231 | + $answer_is_obj = isset($this->_registration_answers[ $answer_cache_id ]) |
|
| 1232 | + && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer; |
|
| 1233 | + // rename form_inputs if they are EE_Attendee properties |
|
| 1234 | + switch ((string) $form_input) { |
|
| 1235 | + case 'state': |
|
| 1236 | + case 'STA_ID': |
|
| 1237 | + $attendee_property = true; |
|
| 1238 | + $form_input = 'STA_ID'; |
|
| 1239 | + break; |
|
| 1240 | + |
|
| 1241 | + case 'country': |
|
| 1242 | + case 'CNT_ISO': |
|
| 1243 | + $attendee_property = true; |
|
| 1244 | + $form_input = 'CNT_ISO'; |
|
| 1245 | + break; |
|
| 1246 | + |
|
| 1247 | + default: |
|
| 1248 | + $ATT_input = 'ATT_' . $form_input; |
|
| 1249 | + // EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ ); |
|
| 1250 | + $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false; |
|
| 1251 | + $form_input = $attendee_property ? 'ATT_' . $form_input : $form_input; |
|
| 1252 | + } |
|
| 1253 | + // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ ); |
|
| 1254 | + // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ ); |
|
| 1255 | + // EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ ); |
|
| 1256 | + // if this form input has a corresponding attendee property |
|
| 1257 | + if ($attendee_property) { |
|
| 1258 | + $this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value; |
|
| 1259 | + if ($answer_is_obj) { |
|
| 1260 | + // and delete the corresponding answer since we won't be storing this data in that object |
|
| 1261 | + $registration->_remove_relation_to($this->_registration_answers[ $answer_cache_id ], 'Answer'); |
|
| 1262 | + $this->_registration_answers[ $answer_cache_id ]->delete_permanently(); |
|
| 1263 | + } |
|
| 1264 | + return true; |
|
| 1265 | + } |
|
| 1266 | + if ($answer_is_obj) { |
|
| 1267 | + // save this data to the answer object |
|
| 1268 | + $this->_registration_answers[ $answer_cache_id ]->set_value($input_value); |
|
| 1269 | + $result = $this->_registration_answers[ $answer_cache_id ]->save(); |
|
| 1270 | + return $result !== false; |
|
| 1271 | + } |
|
| 1272 | + foreach ($this->_registration_answers as $answer) { |
|
| 1273 | + if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) { |
|
| 1274 | + $answer->set_value($input_value); |
|
| 1275 | + $result = $answer->save(); |
|
| 1276 | + return $result !== false; |
|
| 1277 | + } |
|
| 1278 | + } |
|
| 1279 | + return false; |
|
| 1280 | + } |
|
| 1281 | + |
|
| 1282 | + |
|
| 1283 | + /** |
|
| 1284 | + * _verify_critical_attendee_details_are_set |
|
| 1285 | + * |
|
| 1286 | + * @param string $form_input |
|
| 1287 | + * @param string $input_value |
|
| 1288 | + * @return boolean |
|
| 1289 | + */ |
|
| 1290 | + private function _verify_critical_attendee_details_are_set_and_validate_email( |
|
| 1291 | + $form_input = '', |
|
| 1292 | + $input_value = '' |
|
| 1293 | + ) { |
|
| 1294 | + if (empty($input_value)) { |
|
| 1295 | + // if the form input isn't marked as being required, then just return |
|
| 1296 | + if (! isset($this->_required_questions[ $form_input ]) || ! $this->_required_questions[ $form_input ]) { |
|
| 1297 | + return true; |
|
| 1298 | + } |
|
| 1299 | + switch ($form_input) { |
|
| 1300 | + case 'fname': |
|
| 1301 | + EE_Error::add_error( |
|
| 1302 | + esc_html__('First Name is a required value.', 'event_espresso'), |
|
| 1303 | + __FILE__, |
|
| 1304 | + __FUNCTION__, |
|
| 1305 | + __LINE__ |
|
| 1306 | + ); |
|
| 1307 | + return false; |
|
| 1308 | + break; |
|
| 1309 | + case 'lname': |
|
| 1310 | + EE_Error::add_error( |
|
| 1311 | + esc_html__('Last Name is a required value.', 'event_espresso'), |
|
| 1312 | + __FILE__, |
|
| 1313 | + __FUNCTION__, |
|
| 1314 | + __LINE__ |
|
| 1315 | + ); |
|
| 1316 | + return false; |
|
| 1317 | + break; |
|
| 1318 | + case 'email': |
|
| 1319 | + EE_Error::add_error( |
|
| 1320 | + esc_html__('Please enter a valid email address.', 'event_espresso'), |
|
| 1321 | + __FILE__, |
|
| 1322 | + __FUNCTION__, |
|
| 1323 | + __LINE__ |
|
| 1324 | + ); |
|
| 1325 | + return false; |
|
| 1326 | + break; |
|
| 1327 | + } |
|
| 1328 | + } |
|
| 1329 | + return true; |
|
| 1330 | + } |
|
| 1331 | + |
|
| 1332 | + |
|
| 1333 | + /** |
|
| 1334 | + * _associate_attendee_with_registration |
|
| 1335 | + * |
|
| 1336 | + * @param EE_Registration $registration |
|
| 1337 | + * @param EE_Attendee $attendee |
|
| 1338 | + * @return void |
|
| 1339 | + * @throws EE_Error |
|
| 1340 | + * @throws InvalidArgumentException |
|
| 1341 | + * @throws ReflectionException |
|
| 1342 | + * @throws RuntimeException |
|
| 1343 | + * @throws InvalidDataTypeException |
|
| 1344 | + * @throws InvalidInterfaceException |
|
| 1345 | + */ |
|
| 1346 | + private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee) |
|
| 1347 | + { |
|
| 1348 | + // add relation to attendee |
|
| 1349 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
| 1350 | + $registration->set_attendee_id($attendee->ID()); |
|
| 1351 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
| 1352 | + } |
|
| 1353 | + |
|
| 1354 | + |
|
| 1355 | + /** |
|
| 1356 | + * _associate_registration_with_transaction |
|
| 1357 | + * |
|
| 1358 | + * @param EE_Registration $registration |
|
| 1359 | + * @return void |
|
| 1360 | + * @throws EE_Error |
|
| 1361 | + * @throws InvalidArgumentException |
|
| 1362 | + * @throws ReflectionException |
|
| 1363 | + * @throws InvalidDataTypeException |
|
| 1364 | + * @throws InvalidInterfaceException |
|
| 1365 | + */ |
|
| 1366 | + private function _associate_registration_with_transaction(EE_Registration $registration) |
|
| 1367 | + { |
|
| 1368 | + // add relation to registration |
|
| 1369 | + $this->checkout->transaction->_add_relation_to($registration, 'Registration'); |
|
| 1370 | + $this->checkout->transaction->update_cache_after_object_save('Registration', $registration); |
|
| 1371 | + } |
|
| 1372 | + |
|
| 1373 | + |
|
| 1374 | + /** |
|
| 1375 | + * _copy_critical_attendee_details_from_primary_registrant |
|
| 1376 | + * ensures that all attendees at least have data for first name, last name, and email address |
|
| 1377 | + * |
|
| 1378 | + * @param array $attendee_data |
|
| 1379 | + * @return array |
|
| 1380 | + * @throws EE_Error |
|
| 1381 | + * @throws InvalidArgumentException |
|
| 1382 | + * @throws ReflectionException |
|
| 1383 | + * @throws InvalidDataTypeException |
|
| 1384 | + * @throws InvalidInterfaceException |
|
| 1385 | + */ |
|
| 1386 | + private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array()) |
|
| 1387 | + { |
|
| 1388 | + // bare minimum critical details include first name, last name, email address |
|
| 1389 | + $critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email'); |
|
| 1390 | + // add address info to critical details? |
|
| 1391 | + if (apply_filters( |
|
| 1392 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details', |
|
| 1393 | + false |
|
| 1394 | + )) { |
|
| 1395 | + $address_details = array( |
|
| 1396 | + 'ATT_address', |
|
| 1397 | + 'ATT_address2', |
|
| 1398 | + 'ATT_city', |
|
| 1399 | + 'STA_ID', |
|
| 1400 | + 'CNT_ISO', |
|
| 1401 | + 'ATT_zip', |
|
| 1402 | + 'ATT_phone', |
|
| 1403 | + ); |
|
| 1404 | + $critical_attendee_details = array_merge($critical_attendee_details, $address_details); |
|
| 1405 | + } |
|
| 1406 | + foreach ($critical_attendee_details as $critical_attendee_detail) { |
|
| 1407 | + if (! isset($attendee_data[ $critical_attendee_detail ]) |
|
| 1408 | + || empty($attendee_data[ $critical_attendee_detail ]) |
|
| 1409 | + ) { |
|
| 1410 | + $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get( |
|
| 1411 | + $critical_attendee_detail |
|
| 1412 | + ); |
|
| 1413 | + } |
|
| 1414 | + } |
|
| 1415 | + return $attendee_data; |
|
| 1416 | + } |
|
| 1417 | + |
|
| 1418 | + |
|
| 1419 | + /** |
|
| 1420 | + * update_reg_step |
|
| 1421 | + * this is the final step after a user revisits the site to edit their attendee information |
|
| 1422 | + * this gets called AFTER the process_reg_step() method above |
|
| 1423 | + * |
|
| 1424 | + * @return bool |
|
| 1425 | + * @throws EE_Error |
|
| 1426 | + * @throws InvalidArgumentException |
|
| 1427 | + * @throws ReflectionException |
|
| 1428 | + * @throws RuntimeException |
|
| 1429 | + * @throws InvalidDataTypeException |
|
| 1430 | + * @throws InvalidInterfaceException |
|
| 1431 | + */ |
|
| 1432 | + public function update_reg_step() |
|
| 1433 | + { |
|
| 1434 | + // save everything |
|
| 1435 | + if ($this->process_reg_step()) { |
|
| 1436 | + $this->checkout->redirect = true; |
|
| 1437 | + $this->checkout->redirect_url = add_query_arg( |
|
| 1438 | + array( |
|
| 1439 | + 'e_reg_url_link' => $this->checkout->reg_url_link, |
|
| 1440 | + 'revisit' => true, |
|
| 1441 | + ), |
|
| 1442 | + $this->checkout->thank_you_page_url |
|
| 1443 | + ); |
|
| 1444 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
| 1445 | + return true; |
|
| 1446 | + } |
|
| 1447 | + return false; |
|
| 1448 | + } |
|
| 1449 | 1449 | } |
@@ -15,9 +15,9 @@ discard block |
||
| 15 | 15 | $stages = glob(EE_CORE . 'data_migration_scripts/4_10_0_stages/*'); |
| 16 | 16 | $class_to_filepath = []; |
| 17 | 17 | foreach ($stages as $filepath) { |
| 18 | - $matches = []; |
|
| 19 | - preg_match('~4_10_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
| 20 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
| 18 | + $matches = []; |
|
| 19 | + preg_match('~4_10_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
| 20 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
| 21 | 21 | } |
| 22 | 22 | // give addons a chance to autoload their stages too |
| 23 | 23 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_10_0__autoloaded_stages', $class_to_filepath); |
@@ -35,66 +35,66 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | class EE_DMS_Core_4_10_0 extends EE_Data_Migration_Script_Base |
| 37 | 37 | { |
| 38 | - /** |
|
| 39 | - * |
|
| 40 | - * @param TableManager $table_manager |
|
| 41 | - * @param TableAnalysis $table_analysis |
|
| 42 | - */ |
|
| 43 | - public function __construct( |
|
| 44 | - TableManager $table_manager = null, |
|
| 45 | - TableAnalysis $table_analysis = null, |
|
| 46 | - EE_DMS_Core_4_9_0 $dms_4_9 |
|
| 47 | - ) { |
|
| 48 | - $this->previous_dms = $dms_4_9; |
|
| 49 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.10.0", "event_espresso"); |
|
| 50 | - $this->_priority = 10; |
|
| 51 | - $this->_migration_stages = array( |
|
| 52 | - new EE_DMS_4_10_0_Event_Question_Group(), |
|
| 53 | - ); |
|
| 54 | - parent::__construct($table_manager, $table_analysis); |
|
| 55 | - } |
|
| 38 | + /** |
|
| 39 | + * |
|
| 40 | + * @param TableManager $table_manager |
|
| 41 | + * @param TableAnalysis $table_analysis |
|
| 42 | + */ |
|
| 43 | + public function __construct( |
|
| 44 | + TableManager $table_manager = null, |
|
| 45 | + TableAnalysis $table_analysis = null, |
|
| 46 | + EE_DMS_Core_4_9_0 $dms_4_9 |
|
| 47 | + ) { |
|
| 48 | + $this->previous_dms = $dms_4_9; |
|
| 49 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.10.0", "event_espresso"); |
|
| 50 | + $this->_priority = 10; |
|
| 51 | + $this->_migration_stages = array( |
|
| 52 | + new EE_DMS_4_10_0_Event_Question_Group(), |
|
| 53 | + ); |
|
| 54 | + parent::__construct($table_manager, $table_analysis); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | 57 | |
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Whether to migrate or not. |
|
| 61 | - * |
|
| 62 | - * @param array $version_array |
|
| 63 | - * @return bool |
|
| 64 | - */ |
|
| 65 | - public function can_migrate_from_version($version_array) |
|
| 66 | - { |
|
| 67 | - $version_string = $version_array['Core']; |
|
| 68 | - if (version_compare($version_string, '4.10.0.decaf', '<') && version_compare($version_string, '4.9.0.decaf', '>=')) { |
|
| 69 | - return true; |
|
| 70 | - } elseif (! $version_string) { |
|
| 71 | - // echo "no version string provided: $version_string"; |
|
| 72 | - // no version string provided... this must be pre 4.3 |
|
| 73 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 74 | - } |
|
| 75 | - return false; |
|
| 76 | - } |
|
| 59 | + /** |
|
| 60 | + * Whether to migrate or not. |
|
| 61 | + * |
|
| 62 | + * @param array $version_array |
|
| 63 | + * @return bool |
|
| 64 | + */ |
|
| 65 | + public function can_migrate_from_version($version_array) |
|
| 66 | + { |
|
| 67 | + $version_string = $version_array['Core']; |
|
| 68 | + if (version_compare($version_string, '4.10.0.decaf', '<') && version_compare($version_string, '4.9.0.decaf', '>=')) { |
|
| 69 | + return true; |
|
| 70 | + } elseif (! $version_string) { |
|
| 71 | + // echo "no version string provided: $version_string"; |
|
| 72 | + // no version string provided... this must be pre 4.3 |
|
| 73 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 74 | + } |
|
| 75 | + return false; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | 78 | |
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * @return bool |
|
| 82 | - */ |
|
| 83 | - public function schema_changes_before_migration() |
|
| 84 | - { |
|
| 85 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 86 | - $now_in_mysql = current_time('mysql', true); |
|
| 87 | - $table_name = 'esp_answer'; |
|
| 88 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 80 | + /** |
|
| 81 | + * @return bool |
|
| 82 | + */ |
|
| 83 | + public function schema_changes_before_migration() |
|
| 84 | + { |
|
| 85 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 86 | + $now_in_mysql = current_time('mysql', true); |
|
| 87 | + $table_name = 'esp_answer'; |
|
| 88 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 89 | 89 | REG_ID int(10) unsigned NOT NULL, |
| 90 | 90 | QST_ID int(10) unsigned NOT NULL, |
| 91 | 91 | ANS_value text NOT NULL, |
| 92 | 92 | PRIMARY KEY (ANS_ID), |
| 93 | 93 | KEY REG_ID (REG_ID), |
| 94 | 94 | KEY QST_ID (QST_ID)"; |
| 95 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 96 | - $table_name = 'esp_attendee_meta'; |
|
| 97 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 95 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 96 | + $table_name = 'esp_attendee_meta'; |
|
| 97 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 98 | 98 | ATT_ID bigint(20) unsigned NOT NULL, |
| 99 | 99 | ATT_fname varchar(45) NOT NULL, |
| 100 | 100 | ATT_lname varchar(45) NOT NULL, |
@@ -111,9 +111,9 @@ discard block |
||
| 111 | 111 | KEY ATT_email (ATT_email(191)), |
| 112 | 112 | KEY ATT_lname (ATT_lname), |
| 113 | 113 | KEY ATT_fname (ATT_fname)"; |
| 114 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 115 | - $table_name = 'esp_checkin'; |
|
| 116 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 114 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 115 | + $table_name = 'esp_checkin'; |
|
| 116 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 117 | 117 | REG_ID int(10) unsigned NOT NULL, |
| 118 | 118 | DTT_ID int(10) unsigned NOT NULL, |
| 119 | 119 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -121,9 +121,9 @@ discard block |
||
| 121 | 121 | PRIMARY KEY (CHK_ID), |
| 122 | 122 | KEY REG_ID (REG_ID), |
| 123 | 123 | KEY DTT_ID (DTT_ID)"; |
| 124 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 125 | - $table_name = 'esp_country'; |
|
| 126 | - $sql = "CNT_ISO varchar(2) NOT NULL, |
|
| 124 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 125 | + $table_name = 'esp_country'; |
|
| 126 | + $sql = "CNT_ISO varchar(2) NOT NULL, |
|
| 127 | 127 | CNT_ISO3 varchar(3) NOT NULL, |
| 128 | 128 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
| 129 | 129 | CNT_name varchar(45) NOT NULL, |
@@ -139,29 +139,29 @@ discard block |
||
| 139 | 139 | CNT_is_EU tinyint(1) DEFAULT '0', |
| 140 | 140 | CNT_active tinyint(1) DEFAULT '0', |
| 141 | 141 | PRIMARY KEY (CNT_ISO)"; |
| 142 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 143 | - $table_name = 'esp_currency'; |
|
| 144 | - $sql = "CUR_code varchar(6) NOT NULL, |
|
| 142 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 143 | + $table_name = 'esp_currency'; |
|
| 144 | + $sql = "CUR_code varchar(6) NOT NULL, |
|
| 145 | 145 | CUR_single varchar(45) DEFAULT 'dollar', |
| 146 | 146 | CUR_plural varchar(45) DEFAULT 'dollars', |
| 147 | 147 | CUR_sign varchar(45) DEFAULT '$', |
| 148 | 148 | CUR_dec_plc varchar(1) NOT NULL DEFAULT '2', |
| 149 | 149 | CUR_active tinyint(1) DEFAULT '0', |
| 150 | 150 | PRIMARY KEY (CUR_code)"; |
| 151 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 152 | - // note: although this table is no longer in use, |
|
| 153 | - // it hasn't been removed because then queries to the model will have errors. |
|
| 154 | - // but you should expect this table and its corresponding model to be removed in |
|
| 155 | - // the next few months |
|
| 156 | - $table_name = 'esp_currency_payment_method'; |
|
| 157 | - $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 151 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 152 | + // note: although this table is no longer in use, |
|
| 153 | + // it hasn't been removed because then queries to the model will have errors. |
|
| 154 | + // but you should expect this table and its corresponding model to be removed in |
|
| 155 | + // the next few months |
|
| 156 | + $table_name = 'esp_currency_payment_method'; |
|
| 157 | + $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 158 | 158 | CUR_code varchar(6) NOT NULL, |
| 159 | 159 | PMD_ID int(11) NOT NULL, |
| 160 | 160 | PRIMARY KEY (CPM_ID), |
| 161 | 161 | KEY PMD_ID (PMD_ID)"; |
| 162 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 163 | - $table_name = 'esp_datetime'; |
|
| 164 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 162 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 163 | + $table_name = 'esp_datetime'; |
|
| 164 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 165 | 165 | EVT_ID bigint(20) unsigned NOT NULL, |
| 166 | 166 | DTT_name varchar(255) NOT NULL DEFAULT '', |
| 167 | 167 | DTT_description text NOT NULL, |
@@ -178,25 +178,25 @@ discard block |
||
| 178 | 178 | KEY DTT_EVT_start (DTT_EVT_start), |
| 179 | 179 | KEY EVT_ID (EVT_ID), |
| 180 | 180 | KEY DTT_is_primary (DTT_is_primary)"; |
| 181 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 182 | - $table_name = "esp_datetime_ticket"; |
|
| 183 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 181 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 182 | + $table_name = "esp_datetime_ticket"; |
|
| 183 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 184 | 184 | DTT_ID int(10) unsigned NOT NULL, |
| 185 | 185 | TKT_ID int(10) unsigned NOT NULL, |
| 186 | 186 | PRIMARY KEY (DTK_ID), |
| 187 | 187 | KEY DTT_ID (DTT_ID), |
| 188 | 188 | KEY TKT_ID (TKT_ID)"; |
| 189 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 190 | - $table_name = 'esp_event_message_template'; |
|
| 191 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 189 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 190 | + $table_name = 'esp_event_message_template'; |
|
| 191 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 192 | 192 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
| 193 | 193 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
| 194 | 194 | PRIMARY KEY (EMT_ID), |
| 195 | 195 | KEY EVT_ID (EVT_ID), |
| 196 | 196 | KEY GRP_ID (GRP_ID)"; |
| 197 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 198 | - $table_name = 'esp_event_meta'; |
|
| 199 | - $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
| 197 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 198 | + $table_name = 'esp_event_meta'; |
|
| 199 | + $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
| 200 | 200 | EVT_ID bigint(20) unsigned NOT NULL, |
| 201 | 201 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
| 202 | 202 | EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -211,9 +211,9 @@ discard block |
||
| 211 | 211 | EVT_donations tinyint(1) NULL, |
| 212 | 212 | PRIMARY KEY (EVTM_ID), |
| 213 | 213 | KEY EVT_ID (EVT_ID)"; |
| 214 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 215 | - $table_name = 'esp_event_question_group'; |
|
| 216 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 214 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 215 | + $table_name = 'esp_event_question_group'; |
|
| 216 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 217 | 217 | EVT_ID bigint(20) unsigned NOT NULL, |
| 218 | 218 | QSG_ID int(10) unsigned NOT NULL, |
| 219 | 219 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
@@ -221,25 +221,25 @@ discard block |
||
| 221 | 221 | PRIMARY KEY (EQG_ID), |
| 222 | 222 | KEY EVT_ID (EVT_ID), |
| 223 | 223 | KEY QSG_ID (QSG_ID)"; |
| 224 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 225 | - $table_name = 'esp_event_venue'; |
|
| 226 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 224 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 225 | + $table_name = 'esp_event_venue'; |
|
| 226 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 227 | 227 | EVT_ID bigint(20) unsigned NOT NULL, |
| 228 | 228 | VNU_ID bigint(20) unsigned NOT NULL, |
| 229 | 229 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
| 230 | 230 | PRIMARY KEY (EVV_ID)"; |
| 231 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 232 | - $table_name = 'esp_extra_meta'; |
|
| 233 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 231 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 232 | + $table_name = 'esp_extra_meta'; |
|
| 233 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 234 | 234 | OBJ_ID int(11) DEFAULT NULL, |
| 235 | 235 | EXM_type varchar(45) DEFAULT NULL, |
| 236 | 236 | EXM_key varchar(45) DEFAULT NULL, |
| 237 | 237 | EXM_value text, |
| 238 | 238 | PRIMARY KEY (EXM_ID), |
| 239 | 239 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
| 240 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 241 | - $table_name = 'esp_extra_join'; |
|
| 242 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 240 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 241 | + $table_name = 'esp_extra_join'; |
|
| 242 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 243 | 243 | EXJ_first_model_id varchar(6) NOT NULL, |
| 244 | 244 | EXJ_first_model_name varchar(20) NOT NULL, |
| 245 | 245 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -247,9 +247,9 @@ discard block |
||
| 247 | 247 | PRIMARY KEY (EXJ_ID), |
| 248 | 248 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
| 249 | 249 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
| 250 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 251 | - $table_name = 'esp_line_item'; |
|
| 252 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 250 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 251 | + $table_name = 'esp_line_item'; |
|
| 252 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 253 | 253 | LIN_code varchar(245) NOT NULL DEFAULT '', |
| 254 | 254 | TXN_ID int(11) DEFAULT NULL, |
| 255 | 255 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -270,9 +270,9 @@ discard block |
||
| 270 | 270 | KEY txn_type_timestamp (TXN_ID,LIN_type,LIN_timestamp), |
| 271 | 271 | KEY txn_obj_id_obj_type (TXN_ID,OBJ_ID,OBJ_type), |
| 272 | 272 | KEY obj_id_obj_type (OBJ_ID,OBJ_type)"; |
| 273 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 274 | - $table_name = 'esp_log'; |
|
| 275 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 273 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 274 | + $table_name = 'esp_log'; |
|
| 275 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 276 | 276 | LOG_time datetime DEFAULT NULL, |
| 277 | 277 | OBJ_ID varchar(45) DEFAULT NULL, |
| 278 | 278 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -283,9 +283,9 @@ discard block |
||
| 283 | 283 | KEY LOG_time (LOG_time), |
| 284 | 284 | KEY OBJ (OBJ_type,OBJ_ID), |
| 285 | 285 | KEY LOG_type (LOG_type)"; |
| 286 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 287 | - $table_name = 'esp_message'; |
|
| 288 | - $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 286 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 287 | + $table_name = 'esp_message'; |
|
| 288 | + $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 289 | 289 | GRP_ID int(10) unsigned NULL, |
| 290 | 290 | MSG_token varchar(255) NULL, |
| 291 | 291 | TXN_ID int(10) unsigned NULL, |
@@ -317,18 +317,18 @@ discard block |
||
| 317 | 317 | KEY STS_ID (STS_ID), |
| 318 | 318 | KEY MSG_created (MSG_created), |
| 319 | 319 | KEY MSG_modified (MSG_modified)"; |
| 320 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 321 | - $table_name = 'esp_message_template'; |
|
| 322 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 320 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 321 | + $table_name = 'esp_message_template'; |
|
| 322 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 323 | 323 | GRP_ID int(10) unsigned NOT NULL, |
| 324 | 324 | MTP_context varchar(50) NOT NULL, |
| 325 | 325 | MTP_template_field varchar(30) NOT NULL, |
| 326 | 326 | MTP_content text NOT NULL, |
| 327 | 327 | PRIMARY KEY (MTP_ID), |
| 328 | 328 | KEY GRP_ID (GRP_ID)"; |
| 329 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 330 | - $table_name = 'esp_message_template_group'; |
|
| 331 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 329 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 330 | + $table_name = 'esp_message_template_group'; |
|
| 331 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 332 | 332 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
| 333 | 333 | MTP_name varchar(245) NOT NULL DEFAULT '', |
| 334 | 334 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -340,9 +340,9 @@ discard block |
||
| 340 | 340 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
| 341 | 341 | PRIMARY KEY (GRP_ID), |
| 342 | 342 | KEY MTP_user_id (MTP_user_id)"; |
| 343 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 344 | - $table_name = 'esp_payment'; |
|
| 345 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 343 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 344 | + $table_name = 'esp_payment'; |
|
| 345 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 346 | 346 | TXN_ID int(10) unsigned DEFAULT NULL, |
| 347 | 347 | STS_ID varchar(3) DEFAULT NULL, |
| 348 | 348 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -359,9 +359,9 @@ discard block |
||
| 359 | 359 | PRIMARY KEY (PAY_ID), |
| 360 | 360 | KEY PAY_timestamp (PAY_timestamp), |
| 361 | 361 | KEY TXN_ID (TXN_ID)"; |
| 362 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 363 | - $table_name = 'esp_payment_method'; |
|
| 364 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 362 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 363 | + $table_name = 'esp_payment_method'; |
|
| 364 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 365 | 365 | PMD_type varchar(124) DEFAULT NULL, |
| 366 | 366 | PMD_name varchar(255) DEFAULT NULL, |
| 367 | 367 | PMD_desc text, |
@@ -377,24 +377,24 @@ discard block |
||
| 377 | 377 | PRIMARY KEY (PMD_ID), |
| 378 | 378 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
| 379 | 379 | KEY PMD_type (PMD_type)"; |
| 380 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 381 | - $table_name = "esp_ticket_price"; |
|
| 382 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 380 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 381 | + $table_name = "esp_ticket_price"; |
|
| 382 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 383 | 383 | TKT_ID int(10) unsigned NOT NULL, |
| 384 | 384 | PRC_ID int(10) unsigned NOT NULL, |
| 385 | 385 | PRIMARY KEY (TKP_ID), |
| 386 | 386 | KEY TKT_ID (TKT_ID), |
| 387 | 387 | KEY PRC_ID (PRC_ID)"; |
| 388 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 389 | - $table_name = "esp_ticket_template"; |
|
| 390 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 388 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 389 | + $table_name = "esp_ticket_template"; |
|
| 390 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 391 | 391 | TTM_name varchar(45) NOT NULL, |
| 392 | 392 | TTM_description text, |
| 393 | 393 | TTM_file varchar(45), |
| 394 | 394 | PRIMARY KEY (TTM_ID)"; |
| 395 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 396 | - $table_name = 'esp_question'; |
|
| 397 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 395 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 396 | + $table_name = 'esp_question'; |
|
| 397 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 398 | 398 | QST_display_text text NOT NULL, |
| 399 | 399 | QST_admin_label varchar(255) NOT NULL, |
| 400 | 400 | QST_system varchar(25) DEFAULT NULL, |
@@ -408,18 +408,18 @@ discard block |
||
| 408 | 408 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
| 409 | 409 | PRIMARY KEY (QST_ID), |
| 410 | 410 | KEY QST_order (QST_order)'; |
| 411 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 412 | - $table_name = 'esp_question_group_question'; |
|
| 413 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 411 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 412 | + $table_name = 'esp_question_group_question'; |
|
| 413 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 414 | 414 | QSG_ID int(10) unsigned NOT NULL, |
| 415 | 415 | QST_ID int(10) unsigned NOT NULL, |
| 416 | 416 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
| 417 | 417 | PRIMARY KEY (QGQ_ID), |
| 418 | 418 | KEY QST_ID (QST_ID), |
| 419 | 419 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
| 420 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 421 | - $table_name = 'esp_question_option'; |
|
| 422 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 420 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 421 | + $table_name = 'esp_question_option'; |
|
| 422 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 423 | 423 | QSO_value varchar(255) NOT NULL, |
| 424 | 424 | QSO_desc text NOT NULL, |
| 425 | 425 | QST_ID int(10) unsigned NOT NULL, |
@@ -429,9 +429,9 @@ discard block |
||
| 429 | 429 | PRIMARY KEY (QSO_ID), |
| 430 | 430 | KEY QST_ID (QST_ID), |
| 431 | 431 | KEY QSO_order (QSO_order)"; |
| 432 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 433 | - $table_name = 'esp_registration'; |
|
| 434 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 432 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 433 | + $table_name = 'esp_registration'; |
|
| 434 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 435 | 435 | EVT_ID bigint(20) unsigned NOT NULL, |
| 436 | 436 | ATT_ID bigint(20) unsigned NOT NULL, |
| 437 | 437 | TXN_ID int(10) unsigned NOT NULL, |
@@ -455,18 +455,18 @@ discard block |
||
| 455 | 455 | KEY TKT_ID (TKT_ID), |
| 456 | 456 | KEY EVT_ID (EVT_ID), |
| 457 | 457 | KEY STS_ID (STS_ID)"; |
| 458 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 459 | - $table_name = 'esp_registration_payment'; |
|
| 460 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 458 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 459 | + $table_name = 'esp_registration_payment'; |
|
| 460 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 461 | 461 | REG_ID int(10) unsigned NOT NULL, |
| 462 | 462 | PAY_ID int(10) unsigned NULL, |
| 463 | 463 | RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
| 464 | 464 | PRIMARY KEY (RPY_ID), |
| 465 | 465 | KEY REG_ID (REG_ID), |
| 466 | 466 | KEY PAY_ID (PAY_ID)"; |
| 467 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 468 | - $table_name = 'esp_state'; |
|
| 469 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
| 467 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 468 | + $table_name = 'esp_state'; |
|
| 469 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
| 470 | 470 | CNT_ISO varchar(2) NOT NULL, |
| 471 | 471 | STA_abbrev varchar(24) NOT NULL, |
| 472 | 472 | STA_name varchar(100) NOT NULL, |
@@ -474,9 +474,9 @@ discard block |
||
| 474 | 474 | PRIMARY KEY (STA_ID), |
| 475 | 475 | KEY STA_abbrev (STA_abbrev), |
| 476 | 476 | KEY CNT_ISO (CNT_ISO)"; |
| 477 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 478 | - $table_name = 'esp_status'; |
|
| 479 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
| 477 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 478 | + $table_name = 'esp_status'; |
|
| 479 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
| 480 | 480 | STS_code varchar(45) NOT NULL, |
| 481 | 481 | STS_type varchar(45) NOT NULL, |
| 482 | 482 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -484,9 +484,9 @@ discard block |
||
| 484 | 484 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
| 485 | 485 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
| 486 | 486 | KEY STS_type (STS_type)"; |
| 487 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 488 | - $table_name = 'esp_transaction'; |
|
| 489 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 487 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 488 | + $table_name = 'esp_transaction'; |
|
| 489 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 490 | 490 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
| 491 | 491 | TXN_total decimal(12,3) DEFAULT '0.00', |
| 492 | 492 | TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00', |
@@ -498,9 +498,9 @@ discard block |
||
| 498 | 498 | PRIMARY KEY (TXN_ID), |
| 499 | 499 | KEY TXN_timestamp (TXN_timestamp), |
| 500 | 500 | KEY STS_ID (STS_ID)"; |
| 501 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 502 | - $table_name = 'esp_venue_meta'; |
|
| 503 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 501 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 502 | + $table_name = 'esp_venue_meta'; |
|
| 503 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 504 | 504 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
| 505 | 505 | VNU_address varchar(255) DEFAULT NULL, |
| 506 | 506 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -519,10 +519,10 @@ discard block |
||
| 519 | 519 | KEY VNU_ID (VNU_ID), |
| 520 | 520 | KEY STA_ID (STA_ID), |
| 521 | 521 | KEY CNT_ISO (CNT_ISO)"; |
| 522 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 523 | - // modified tables |
|
| 524 | - $table_name = "esp_price"; |
|
| 525 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 522 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 523 | + // modified tables |
|
| 524 | + $table_name = "esp_price"; |
|
| 525 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 526 | 526 | PRT_ID tinyint(3) unsigned NOT NULL, |
| 527 | 527 | PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
| 528 | 528 | PRC_name varchar(245) NOT NULL, |
@@ -535,9 +535,9 @@ discard block |
||
| 535 | 535 | PRC_parent int(10) unsigned DEFAULT 0, |
| 536 | 536 | PRIMARY KEY (PRC_ID), |
| 537 | 537 | KEY PRT_ID (PRT_ID)"; |
| 538 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 539 | - $table_name = "esp_price_type"; |
|
| 540 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
| 538 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 539 | + $table_name = "esp_price_type"; |
|
| 540 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
| 541 | 541 | PRT_name varchar(45) NOT NULL, |
| 542 | 542 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
| 543 | 543 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -546,9 +546,9 @@ discard block |
||
| 546 | 546 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
| 547 | 547 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
| 548 | 548 | PRIMARY KEY (PRT_ID)"; |
| 549 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 550 | - $table_name = "esp_ticket"; |
|
| 551 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 549 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 550 | + $table_name = "esp_ticket"; |
|
| 551 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 552 | 552 | TTM_ID int(10) unsigned NOT NULL, |
| 553 | 553 | TKT_name varchar(245) NOT NULL DEFAULT '', |
| 554 | 554 | TKT_description text NOT NULL, |
@@ -571,9 +571,9 @@ discard block |
||
| 571 | 571 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
| 572 | 572 | PRIMARY KEY (TKT_ID), |
| 573 | 573 | KEY TKT_start_date (TKT_start_date)"; |
| 574 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 575 | - $table_name = 'esp_question_group'; |
|
| 576 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 574 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 575 | + $table_name = 'esp_question_group'; |
|
| 576 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 577 | 577 | QSG_name varchar(255) NOT NULL, |
| 578 | 578 | QSG_identifier varchar(100) NOT NULL, |
| 579 | 579 | QSG_desc text NULL, |
@@ -586,38 +586,38 @@ discard block |
||
| 586 | 586 | PRIMARY KEY (QSG_ID), |
| 587 | 587 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
| 588 | 588 | KEY QSG_order (QSG_order)'; |
| 589 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 590 | - $this->insert_default_data(); |
|
| 591 | - return true; |
|
| 592 | - } |
|
| 589 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 590 | + $this->insert_default_data(); |
|
| 591 | + return true; |
|
| 592 | + } |
|
| 593 | 593 | |
| 594 | - /** |
|
| 595 | - * Inserts default data on new installs |
|
| 596 | - * @since 4.10.0.p |
|
| 597 | - * @throws EE_Error |
|
| 598 | - * @throws InvalidArgumentException |
|
| 599 | - * @throws ReflectionException |
|
| 600 | - * @throws InvalidDataTypeException |
|
| 601 | - * @throws InvalidInterfaceException |
|
| 602 | - */ |
|
| 603 | - public function insert_default_data() |
|
| 604 | - { |
|
| 605 | - $this->previous_dms->insert_default_data(); |
|
| 606 | - } |
|
| 594 | + /** |
|
| 595 | + * Inserts default data on new installs |
|
| 596 | + * @since 4.10.0.p |
|
| 597 | + * @throws EE_Error |
|
| 598 | + * @throws InvalidArgumentException |
|
| 599 | + * @throws ReflectionException |
|
| 600 | + * @throws InvalidDataTypeException |
|
| 601 | + * @throws InvalidInterfaceException |
|
| 602 | + */ |
|
| 603 | + public function insert_default_data() |
|
| 604 | + { |
|
| 605 | + $this->previous_dms->insert_default_data(); |
|
| 606 | + } |
|
| 607 | 607 | |
| 608 | 608 | |
| 609 | 609 | |
| 610 | - /** |
|
| 611 | - * @return boolean |
|
| 612 | - */ |
|
| 613 | - public function schema_changes_after_migration() |
|
| 614 | - { |
|
| 615 | - return true; |
|
| 616 | - } |
|
| 610 | + /** |
|
| 611 | + * @return boolean |
|
| 612 | + */ |
|
| 613 | + public function schema_changes_after_migration() |
|
| 614 | + { |
|
| 615 | + return true; |
|
| 616 | + } |
|
| 617 | 617 | |
| 618 | 618 | |
| 619 | 619 | |
| 620 | - public function migration_page_hooks() |
|
| 621 | - { |
|
| 622 | - } |
|
| 620 | + public function migration_page_hooks() |
|
| 621 | + { |
|
| 622 | + } |
|
| 623 | 623 | } |
@@ -12,12 +12,12 @@ discard block |
||
| 12 | 12 | // unfortunately, this needs to be done upon INCLUSION of this file, |
| 13 | 13 | // instead of construction, because it only gets constructed on first page load |
| 14 | 14 | // (all other times it gets resurrected from a wordpress option) |
| 15 | -$stages = glob(EE_CORE . 'data_migration_scripts/4_10_0_stages/*'); |
|
| 15 | +$stages = glob(EE_CORE.'data_migration_scripts/4_10_0_stages/*'); |
|
| 16 | 16 | $class_to_filepath = []; |
| 17 | 17 | foreach ($stages as $filepath) { |
| 18 | 18 | $matches = []; |
| 19 | 19 | preg_match('~4_10_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
| 20 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
| 20 | + $class_to_filepath[$matches[1]] = $filepath; |
|
| 21 | 21 | } |
| 22 | 22 | // give addons a chance to autoload their stages too |
| 23 | 23 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_10_0__autoloaded_stages', $class_to_filepath); |
@@ -67,10 +67,10 @@ discard block |
||
| 67 | 67 | $version_string = $version_array['Core']; |
| 68 | 68 | if (version_compare($version_string, '4.10.0.decaf', '<') && version_compare($version_string, '4.9.0.decaf', '>=')) { |
| 69 | 69 | return true; |
| 70 | - } elseif (! $version_string) { |
|
| 70 | + } elseif ( ! $version_string) { |
|
| 71 | 71 | // echo "no version string provided: $version_string"; |
| 72 | 72 | // no version string provided... this must be pre 4.3 |
| 73 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 73 | + return false; // changed mind. dont want people thinking they should migrate yet because they cant |
|
| 74 | 74 | } |
| 75 | 75 | return false; |
| 76 | 76 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public function schema_changes_before_migration() |
| 84 | 84 | { |
| 85 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 85 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
| 86 | 86 | $now_in_mysql = current_time('mysql', true); |
| 87 | 87 | $table_name = 'esp_answer'; |
| 88 | 88 | $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
@@ -14,2537 +14,2537 @@ discard block |
||
| 14 | 14 | final class EE_Config implements ResettableInterface |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - const OPTION_NAME = 'ee_config'; |
|
| 18 | - |
|
| 19 | - const LOG_NAME = 'ee_config_log'; |
|
| 20 | - |
|
| 21 | - const LOG_LENGTH = 100; |
|
| 22 | - |
|
| 23 | - const ADDON_OPTION_NAMES = 'ee_config_option_names'; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * instance of the EE_Config object |
|
| 27 | - * |
|
| 28 | - * @var EE_Config $_instance |
|
| 29 | - * @access private |
|
| 30 | - */ |
|
| 31 | - private static $_instance; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @var boolean $_logging_enabled |
|
| 35 | - */ |
|
| 36 | - private static $_logging_enabled = false; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
| 40 | - */ |
|
| 41 | - private $legacy_shortcodes_manager; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * An StdClass whose property names are addon slugs, |
|
| 45 | - * and values are their config classes |
|
| 46 | - * |
|
| 47 | - * @var StdClass |
|
| 48 | - */ |
|
| 49 | - public $addons; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * @var EE_Admin_Config |
|
| 53 | - */ |
|
| 54 | - public $admin; |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * @var EE_Core_Config |
|
| 58 | - */ |
|
| 59 | - public $core; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * @var EE_Currency_Config |
|
| 63 | - */ |
|
| 64 | - public $currency; |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * @var EE_Organization_Config |
|
| 68 | - */ |
|
| 69 | - public $organization; |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * @var EE_Registration_Config |
|
| 73 | - */ |
|
| 74 | - public $registration; |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @var EE_Template_Config |
|
| 78 | - */ |
|
| 79 | - public $template_settings; |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * Holds EE environment values. |
|
| 83 | - * |
|
| 84 | - * @var EE_Environment_Config |
|
| 85 | - */ |
|
| 86 | - public $environment; |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * settings pertaining to Google maps |
|
| 90 | - * |
|
| 91 | - * @var EE_Map_Config |
|
| 92 | - */ |
|
| 93 | - public $map_settings; |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * settings pertaining to Taxes |
|
| 97 | - * |
|
| 98 | - * @var EE_Tax_Config |
|
| 99 | - */ |
|
| 100 | - public $tax_settings; |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * Settings pertaining to global messages settings. |
|
| 104 | - * |
|
| 105 | - * @var EE_Messages_Config |
|
| 106 | - */ |
|
| 107 | - public $messages; |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * @deprecated |
|
| 111 | - * @var EE_Gateway_Config |
|
| 112 | - */ |
|
| 113 | - public $gateway; |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * @var array $_addon_option_names |
|
| 117 | - * @access private |
|
| 118 | - */ |
|
| 119 | - private $_addon_option_names = array(); |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * @var array $_module_route_map |
|
| 123 | - * @access private |
|
| 124 | - */ |
|
| 125 | - private static $_module_route_map = array(); |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * @var array $_module_forward_map |
|
| 129 | - * @access private |
|
| 130 | - */ |
|
| 131 | - private static $_module_forward_map = array(); |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * @var array $_module_view_map |
|
| 135 | - * @access private |
|
| 136 | - */ |
|
| 137 | - private static $_module_view_map = array(); |
|
| 138 | - |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * @singleton method used to instantiate class object |
|
| 142 | - * @access public |
|
| 143 | - * @return EE_Config instance |
|
| 144 | - */ |
|
| 145 | - public static function instance() |
|
| 146 | - { |
|
| 147 | - // check if class object is instantiated, and instantiated properly |
|
| 148 | - if (! self::$_instance instanceof EE_Config) { |
|
| 149 | - self::$_instance = new self(); |
|
| 150 | - } |
|
| 151 | - return self::$_instance; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Resets the config |
|
| 157 | - * |
|
| 158 | - * @param bool $hard_reset if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE |
|
| 159 | - * (default) leaves the database alone, and merely resets the EE_Config object to |
|
| 160 | - * reflect its state in the database |
|
| 161 | - * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave |
|
| 162 | - * $_instance as NULL. Useful in case you want to forget about the old instance on |
|
| 163 | - * EE_Config, but might not be ready to instantiate EE_Config currently (eg if the |
|
| 164 | - * site was put into maintenance mode) |
|
| 165 | - * @return EE_Config |
|
| 166 | - */ |
|
| 167 | - public static function reset($hard_reset = false, $reinstantiate = true) |
|
| 168 | - { |
|
| 169 | - if (self::$_instance instanceof EE_Config) { |
|
| 170 | - if ($hard_reset) { |
|
| 171 | - self::$_instance->legacy_shortcodes_manager = null; |
|
| 172 | - self::$_instance->_addon_option_names = array(); |
|
| 173 | - self::$_instance->_initialize_config(); |
|
| 174 | - self::$_instance->update_espresso_config(); |
|
| 175 | - } |
|
| 176 | - self::$_instance->update_addon_option_names(); |
|
| 177 | - } |
|
| 178 | - self::$_instance = null; |
|
| 179 | - // we don't need to reset the static properties imo because those should |
|
| 180 | - // only change when a module is added or removed. Currently we don't |
|
| 181 | - // support removing a module during a request when it previously existed |
|
| 182 | - if ($reinstantiate) { |
|
| 183 | - return self::instance(); |
|
| 184 | - } else { |
|
| 185 | - return null; |
|
| 186 | - } |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * class constructor |
|
| 192 | - * |
|
| 193 | - * @access private |
|
| 194 | - */ |
|
| 195 | - private function __construct() |
|
| 196 | - { |
|
| 197 | - do_action('AHEE__EE_Config__construct__begin', $this); |
|
| 198 | - EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false); |
|
| 199 | - // setup empty config classes |
|
| 200 | - $this->_initialize_config(); |
|
| 201 | - // load existing EE site settings |
|
| 202 | - $this->_load_core_config(); |
|
| 203 | - // confirm everything loaded correctly and set filtered defaults if not |
|
| 204 | - $this->_verify_config(); |
|
| 205 | - // register shortcodes and modules |
|
| 206 | - add_action( |
|
| 207 | - 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
| 208 | - array($this, 'register_shortcodes_and_modules'), |
|
| 209 | - 999 |
|
| 210 | - ); |
|
| 211 | - // initialize shortcodes and modules |
|
| 212 | - add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules')); |
|
| 213 | - // register widgets |
|
| 214 | - add_action('widgets_init', array($this, 'widgets_init'), 10); |
|
| 215 | - // shutdown |
|
| 216 | - add_action('shutdown', array($this, 'shutdown'), 10); |
|
| 217 | - // construct__end hook |
|
| 218 | - do_action('AHEE__EE_Config__construct__end', $this); |
|
| 219 | - // hardcoded hack |
|
| 220 | - $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * @return boolean |
|
| 226 | - */ |
|
| 227 | - public static function logging_enabled() |
|
| 228 | - { |
|
| 229 | - return self::$_logging_enabled; |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - |
|
| 233 | - /** |
|
| 234 | - * use to get the current theme if needed from static context |
|
| 235 | - * |
|
| 236 | - * @return string current theme set. |
|
| 237 | - */ |
|
| 238 | - public static function get_current_theme() |
|
| 239 | - { |
|
| 240 | - return isset(self::$_instance->template_settings->current_espresso_theme) |
|
| 241 | - ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
| 242 | - } |
|
| 243 | - |
|
| 244 | - |
|
| 245 | - /** |
|
| 246 | - * _initialize_config |
|
| 247 | - * |
|
| 248 | - * @access private |
|
| 249 | - * @return void |
|
| 250 | - */ |
|
| 251 | - private function _initialize_config() |
|
| 252 | - { |
|
| 253 | - EE_Config::trim_log(); |
|
| 254 | - // set defaults |
|
| 255 | - $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array()); |
|
| 256 | - $this->addons = new stdClass(); |
|
| 257 | - // set _module_route_map |
|
| 258 | - EE_Config::$_module_route_map = array(); |
|
| 259 | - // set _module_forward_map |
|
| 260 | - EE_Config::$_module_forward_map = array(); |
|
| 261 | - // set _module_view_map |
|
| 262 | - EE_Config::$_module_view_map = array(); |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * load core plugin configuration |
|
| 268 | - * |
|
| 269 | - * @access private |
|
| 270 | - * @return void |
|
| 271 | - */ |
|
| 272 | - private function _load_core_config() |
|
| 273 | - { |
|
| 274 | - // load_core_config__start hook |
|
| 275 | - do_action('AHEE__EE_Config___load_core_config__start', $this); |
|
| 276 | - $espresso_config = $this->get_espresso_config(); |
|
| 277 | - foreach ($espresso_config as $config => $settings) { |
|
| 278 | - // load_core_config__start hook |
|
| 279 | - $settings = apply_filters( |
|
| 280 | - 'FHEE__EE_Config___load_core_config__config_settings', |
|
| 281 | - $settings, |
|
| 282 | - $config, |
|
| 283 | - $this |
|
| 284 | - ); |
|
| 285 | - if (is_object($settings) && property_exists($this, $config)) { |
|
| 286 | - $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings); |
|
| 287 | - // call configs populate method to ensure any defaults are set for empty values. |
|
| 288 | - if (method_exists($settings, 'populate')) { |
|
| 289 | - $this->{$config}->populate(); |
|
| 290 | - } |
|
| 291 | - if (method_exists($settings, 'do_hooks')) { |
|
| 292 | - $this->{$config}->do_hooks(); |
|
| 293 | - } |
|
| 294 | - } |
|
| 295 | - } |
|
| 296 | - if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) { |
|
| 297 | - $this->update_espresso_config(); |
|
| 298 | - } |
|
| 299 | - // load_core_config__end hook |
|
| 300 | - do_action('AHEE__EE_Config___load_core_config__end', $this); |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - |
|
| 304 | - /** |
|
| 305 | - * _verify_config |
|
| 306 | - * |
|
| 307 | - * @access protected |
|
| 308 | - * @return void |
|
| 309 | - */ |
|
| 310 | - protected function _verify_config() |
|
| 311 | - { |
|
| 312 | - $this->core = $this->core instanceof EE_Core_Config |
|
| 313 | - ? $this->core |
|
| 314 | - : new EE_Core_Config(); |
|
| 315 | - $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core); |
|
| 316 | - $this->organization = $this->organization instanceof EE_Organization_Config |
|
| 317 | - ? $this->organization |
|
| 318 | - : new EE_Organization_Config(); |
|
| 319 | - $this->organization = apply_filters( |
|
| 320 | - 'FHEE__EE_Config___initialize_config__organization', |
|
| 321 | - $this->organization |
|
| 322 | - ); |
|
| 323 | - $this->currency = $this->currency instanceof EE_Currency_Config |
|
| 324 | - ? $this->currency |
|
| 325 | - : new EE_Currency_Config(); |
|
| 326 | - $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency); |
|
| 327 | - $this->registration = $this->registration instanceof EE_Registration_Config |
|
| 328 | - ? $this->registration |
|
| 329 | - : new EE_Registration_Config(); |
|
| 330 | - $this->registration = apply_filters( |
|
| 331 | - 'FHEE__EE_Config___initialize_config__registration', |
|
| 332 | - $this->registration |
|
| 333 | - ); |
|
| 334 | - $this->admin = $this->admin instanceof EE_Admin_Config |
|
| 335 | - ? $this->admin |
|
| 336 | - : new EE_Admin_Config(); |
|
| 337 | - $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin); |
|
| 338 | - $this->template_settings = $this->template_settings instanceof EE_Template_Config |
|
| 339 | - ? $this->template_settings |
|
| 340 | - : new EE_Template_Config(); |
|
| 341 | - $this->template_settings = apply_filters( |
|
| 342 | - 'FHEE__EE_Config___initialize_config__template_settings', |
|
| 343 | - $this->template_settings |
|
| 344 | - ); |
|
| 345 | - $this->map_settings = $this->map_settings instanceof EE_Map_Config |
|
| 346 | - ? $this->map_settings |
|
| 347 | - : new EE_Map_Config(); |
|
| 348 | - $this->map_settings = apply_filters( |
|
| 349 | - 'FHEE__EE_Config___initialize_config__map_settings', |
|
| 350 | - $this->map_settings |
|
| 351 | - ); |
|
| 352 | - $this->environment = $this->environment instanceof EE_Environment_Config |
|
| 353 | - ? $this->environment |
|
| 354 | - : new EE_Environment_Config(); |
|
| 355 | - $this->environment = apply_filters( |
|
| 356 | - 'FHEE__EE_Config___initialize_config__environment', |
|
| 357 | - $this->environment |
|
| 358 | - ); |
|
| 359 | - $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config |
|
| 360 | - ? $this->tax_settings |
|
| 361 | - : new EE_Tax_Config(); |
|
| 362 | - $this->tax_settings = apply_filters( |
|
| 363 | - 'FHEE__EE_Config___initialize_config__tax_settings', |
|
| 364 | - $this->tax_settings |
|
| 365 | - ); |
|
| 366 | - $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages); |
|
| 367 | - $this->messages = $this->messages instanceof EE_Messages_Config |
|
| 368 | - ? $this->messages |
|
| 369 | - : new EE_Messages_Config(); |
|
| 370 | - $this->gateway = $this->gateway instanceof EE_Gateway_Config |
|
| 371 | - ? $this->gateway |
|
| 372 | - : new EE_Gateway_Config(); |
|
| 373 | - $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway); |
|
| 374 | - $this->legacy_shortcodes_manager = null; |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - |
|
| 378 | - /** |
|
| 379 | - * get_espresso_config |
|
| 380 | - * |
|
| 381 | - * @access public |
|
| 382 | - * @return array of espresso config stuff |
|
| 383 | - */ |
|
| 384 | - public function get_espresso_config() |
|
| 385 | - { |
|
| 386 | - // grab espresso configuration |
|
| 387 | - return apply_filters( |
|
| 388 | - 'FHEE__EE_Config__get_espresso_config__CFG', |
|
| 389 | - get_option(EE_Config::OPTION_NAME, array()) |
|
| 390 | - ); |
|
| 391 | - } |
|
| 392 | - |
|
| 393 | - |
|
| 394 | - /** |
|
| 395 | - * double_check_config_comparison |
|
| 396 | - * |
|
| 397 | - * @access public |
|
| 398 | - * @param string $option |
|
| 399 | - * @param $old_value |
|
| 400 | - * @param $value |
|
| 401 | - */ |
|
| 402 | - public function double_check_config_comparison($option = '', $old_value, $value) |
|
| 403 | - { |
|
| 404 | - // make sure we're checking the ee config |
|
| 405 | - if ($option === EE_Config::OPTION_NAME) { |
|
| 406 | - // run a loose comparison of the old value against the new value for type and properties, |
|
| 407 | - // but NOT exact instance like WP update_option does (ie: NOT type safe comparison) |
|
| 408 | - if ($value != $old_value) { |
|
| 409 | - // if they are NOT the same, then remove the hook, |
|
| 410 | - // which means the subsequent update results will be based solely on the update query results |
|
| 411 | - // the reason we do this is because, as stated above, |
|
| 412 | - // WP update_option performs an exact instance comparison (===) on any update values passed to it |
|
| 413 | - // this happens PRIOR to serialization and any subsequent update. |
|
| 414 | - // If values are found to match their previous old value, |
|
| 415 | - // then WP bails before performing any update. |
|
| 416 | - // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version |
|
| 417 | - // it just pulled from the db, with the one being passed to it (which will not match). |
|
| 418 | - // HOWEVER, once the object is serialized and passed off to MySQL to update, |
|
| 419 | - // MySQL MAY ALSO NOT perform the update because |
|
| 420 | - // the string it sees in the db looks the same as the new one it has been passed!!! |
|
| 421 | - // This results in the query returning an "affected rows" value of ZERO, |
|
| 422 | - // which gets returned immediately by WP update_option and looks like an error. |
|
| 423 | - remove_action('update_option', array($this, 'check_config_updated')); |
|
| 424 | - } |
|
| 425 | - } |
|
| 426 | - } |
|
| 427 | - |
|
| 428 | - |
|
| 429 | - /** |
|
| 430 | - * update_espresso_config |
|
| 431 | - * |
|
| 432 | - * @access public |
|
| 433 | - */ |
|
| 434 | - protected function _reset_espresso_addon_config() |
|
| 435 | - { |
|
| 436 | - $this->_addon_option_names = array(); |
|
| 437 | - foreach ($this->addons as $addon_name => $addon_config_obj) { |
|
| 438 | - $addon_config_obj = maybe_unserialize($addon_config_obj); |
|
| 439 | - if ($addon_config_obj instanceof EE_Config_Base) { |
|
| 440 | - $this->update_config('addons', $addon_name, $addon_config_obj, false); |
|
| 441 | - } |
|
| 442 | - $this->addons->{$addon_name} = null; |
|
| 443 | - } |
|
| 444 | - } |
|
| 445 | - |
|
| 446 | - |
|
| 447 | - /** |
|
| 448 | - * update_espresso_config |
|
| 449 | - * |
|
| 450 | - * @access public |
|
| 451 | - * @param bool $add_success |
|
| 452 | - * @param bool $add_error |
|
| 453 | - * @return bool |
|
| 454 | - */ |
|
| 455 | - public function update_espresso_config($add_success = false, $add_error = true) |
|
| 456 | - { |
|
| 457 | - // don't allow config updates during WP heartbeats |
|
| 458 | - if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
| 459 | - return false; |
|
| 460 | - } |
|
| 461 | - // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
|
| 462 | - // $clone = clone( self::$_instance ); |
|
| 463 | - // self::$_instance = NULL; |
|
| 464 | - do_action('AHEE__EE_Config__update_espresso_config__begin', $this); |
|
| 465 | - $this->_reset_espresso_addon_config(); |
|
| 466 | - // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
|
| 467 | - // but BEFORE the actual update occurs |
|
| 468 | - add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3); |
|
| 469 | - // don't want to persist legacy_shortcodes_manager, but don't want to lose it either |
|
| 470 | - $legacy_shortcodes_manager = $this->legacy_shortcodes_manager; |
|
| 471 | - $this->legacy_shortcodes_manager = null; |
|
| 472 | - // now update "ee_config" |
|
| 473 | - $saved = update_option(EE_Config::OPTION_NAME, $this); |
|
| 474 | - $this->legacy_shortcodes_manager = $legacy_shortcodes_manager; |
|
| 475 | - EE_Config::log(EE_Config::OPTION_NAME); |
|
| 476 | - // if not saved... check if the hook we just added still exists; |
|
| 477 | - // if it does, it means one of two things: |
|
| 478 | - // that update_option bailed at the($value === $old_value) conditional, |
|
| 479 | - // or... |
|
| 480 | - // the db update query returned 0 rows affected |
|
| 481 | - // (probably because the data value was the same from it's perspective) |
|
| 482 | - // so the existence of the hook means that a negative result from update_option is NOT an error, |
|
| 483 | - // but just means no update occurred, so don't display an error to the user. |
|
| 484 | - // BUT... if update_option returns FALSE, AND the hook is missing, |
|
| 485 | - // then it means that something truly went wrong |
|
| 486 | - $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved; |
|
| 487 | - // remove our action since we don't want it in the system anymore |
|
| 488 | - remove_action('update_option', array($this, 'double_check_config_comparison'), 1); |
|
| 489 | - do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved); |
|
| 490 | - // self::$_instance = $clone; |
|
| 491 | - // unset( $clone ); |
|
| 492 | - // if config remains the same or was updated successfully |
|
| 493 | - if ($saved) { |
|
| 494 | - if ($add_success) { |
|
| 495 | - EE_Error::add_success( |
|
| 496 | - __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), |
|
| 497 | - __FILE__, |
|
| 498 | - __FUNCTION__, |
|
| 499 | - __LINE__ |
|
| 500 | - ); |
|
| 501 | - } |
|
| 502 | - return true; |
|
| 503 | - } else { |
|
| 504 | - if ($add_error) { |
|
| 505 | - EE_Error::add_error( |
|
| 506 | - __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), |
|
| 507 | - __FILE__, |
|
| 508 | - __FUNCTION__, |
|
| 509 | - __LINE__ |
|
| 510 | - ); |
|
| 511 | - } |
|
| 512 | - return false; |
|
| 513 | - } |
|
| 514 | - } |
|
| 515 | - |
|
| 516 | - |
|
| 517 | - /** |
|
| 518 | - * _verify_config_params |
|
| 519 | - * |
|
| 520 | - * @access private |
|
| 521 | - * @param string $section |
|
| 522 | - * @param string $name |
|
| 523 | - * @param string $config_class |
|
| 524 | - * @param EE_Config_Base $config_obj |
|
| 525 | - * @param array $tests_to_run |
|
| 526 | - * @param bool $display_errors |
|
| 527 | - * @return bool TRUE on success, FALSE on fail |
|
| 528 | - */ |
|
| 529 | - private function _verify_config_params( |
|
| 530 | - $section = '', |
|
| 531 | - $name = '', |
|
| 532 | - $config_class = '', |
|
| 533 | - $config_obj = null, |
|
| 534 | - $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8), |
|
| 535 | - $display_errors = true |
|
| 536 | - ) { |
|
| 537 | - try { |
|
| 538 | - foreach ($tests_to_run as $test) { |
|
| 539 | - switch ($test) { |
|
| 540 | - // TEST #1 : check that section was set |
|
| 541 | - case 1: |
|
| 542 | - if (empty($section)) { |
|
| 543 | - if ($display_errors) { |
|
| 544 | - throw new EE_Error( |
|
| 545 | - sprintf( |
|
| 546 | - __( |
|
| 547 | - 'No configuration section has been provided while attempting to save "%s".', |
|
| 548 | - 'event_espresso' |
|
| 549 | - ), |
|
| 550 | - $config_class |
|
| 551 | - ) |
|
| 552 | - ); |
|
| 553 | - } |
|
| 554 | - return false; |
|
| 555 | - } |
|
| 556 | - break; |
|
| 557 | - // TEST #2 : check that settings section exists |
|
| 558 | - case 2: |
|
| 559 | - if (! isset($this->{$section})) { |
|
| 560 | - if ($display_errors) { |
|
| 561 | - throw new EE_Error( |
|
| 562 | - sprintf( |
|
| 563 | - __('The "%s" configuration section does not exist.', 'event_espresso'), |
|
| 564 | - $section |
|
| 565 | - ) |
|
| 566 | - ); |
|
| 567 | - } |
|
| 568 | - return false; |
|
| 569 | - } |
|
| 570 | - break; |
|
| 571 | - // TEST #3 : check that section is the proper format |
|
| 572 | - case 3: |
|
| 573 | - if (! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
| 574 | - ) { |
|
| 575 | - if ($display_errors) { |
|
| 576 | - throw new EE_Error( |
|
| 577 | - sprintf( |
|
| 578 | - __( |
|
| 579 | - 'The "%s" configuration settings have not been formatted correctly.', |
|
| 580 | - 'event_espresso' |
|
| 581 | - ), |
|
| 582 | - $section |
|
| 583 | - ) |
|
| 584 | - ); |
|
| 585 | - } |
|
| 586 | - return false; |
|
| 587 | - } |
|
| 588 | - break; |
|
| 589 | - // TEST #4 : check that config section name has been set |
|
| 590 | - case 4: |
|
| 591 | - if (empty($name)) { |
|
| 592 | - if ($display_errors) { |
|
| 593 | - throw new EE_Error( |
|
| 594 | - __( |
|
| 595 | - 'No name has been provided for the specific configuration section.', |
|
| 596 | - 'event_espresso' |
|
| 597 | - ) |
|
| 598 | - ); |
|
| 599 | - } |
|
| 600 | - return false; |
|
| 601 | - } |
|
| 602 | - break; |
|
| 603 | - // TEST #5 : check that a config class name has been set |
|
| 604 | - case 5: |
|
| 605 | - if (empty($config_class)) { |
|
| 606 | - if ($display_errors) { |
|
| 607 | - throw new EE_Error( |
|
| 608 | - __( |
|
| 609 | - 'No class name has been provided for the specific configuration section.', |
|
| 610 | - 'event_espresso' |
|
| 611 | - ) |
|
| 612 | - ); |
|
| 613 | - } |
|
| 614 | - return false; |
|
| 615 | - } |
|
| 616 | - break; |
|
| 617 | - // TEST #6 : verify config class is accessible |
|
| 618 | - case 6: |
|
| 619 | - if (! class_exists($config_class)) { |
|
| 620 | - if ($display_errors) { |
|
| 621 | - throw new EE_Error( |
|
| 622 | - sprintf( |
|
| 623 | - __( |
|
| 624 | - 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', |
|
| 625 | - 'event_espresso' |
|
| 626 | - ), |
|
| 627 | - $config_class |
|
| 628 | - ) |
|
| 629 | - ); |
|
| 630 | - } |
|
| 631 | - return false; |
|
| 632 | - } |
|
| 633 | - break; |
|
| 634 | - // TEST #7 : check that config has even been set |
|
| 635 | - case 7: |
|
| 636 | - if (! isset($this->{$section}->{$name})) { |
|
| 637 | - if ($display_errors) { |
|
| 638 | - throw new EE_Error( |
|
| 639 | - sprintf( |
|
| 640 | - __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'), |
|
| 641 | - $section, |
|
| 642 | - $name |
|
| 643 | - ) |
|
| 644 | - ); |
|
| 645 | - } |
|
| 646 | - return false; |
|
| 647 | - } else { |
|
| 648 | - // and make sure it's not serialized |
|
| 649 | - $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name}); |
|
| 650 | - } |
|
| 651 | - break; |
|
| 652 | - // TEST #8 : check that config is the requested type |
|
| 653 | - case 8: |
|
| 654 | - if (! $this->{$section}->{$name} instanceof $config_class) { |
|
| 655 | - if ($display_errors) { |
|
| 656 | - throw new EE_Error( |
|
| 657 | - sprintf( |
|
| 658 | - __( |
|
| 659 | - 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', |
|
| 660 | - 'event_espresso' |
|
| 661 | - ), |
|
| 662 | - $section, |
|
| 663 | - $name, |
|
| 664 | - $config_class |
|
| 665 | - ) |
|
| 666 | - ); |
|
| 667 | - } |
|
| 668 | - return false; |
|
| 669 | - } |
|
| 670 | - break; |
|
| 671 | - // TEST #9 : verify config object |
|
| 672 | - case 9: |
|
| 673 | - if (! $config_obj instanceof EE_Config_Base) { |
|
| 674 | - if ($display_errors) { |
|
| 675 | - throw new EE_Error( |
|
| 676 | - sprintf( |
|
| 677 | - __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'), |
|
| 678 | - print_r($config_obj, true) |
|
| 679 | - ) |
|
| 680 | - ); |
|
| 681 | - } |
|
| 682 | - return false; |
|
| 683 | - } |
|
| 684 | - break; |
|
| 685 | - } |
|
| 686 | - } |
|
| 687 | - } catch (EE_Error $e) { |
|
| 688 | - $e->get_error(); |
|
| 689 | - } |
|
| 690 | - // you have successfully run the gauntlet |
|
| 691 | - return true; |
|
| 692 | - } |
|
| 693 | - |
|
| 694 | - |
|
| 695 | - /** |
|
| 696 | - * _generate_config_option_name |
|
| 697 | - * |
|
| 698 | - * @access protected |
|
| 699 | - * @param string $section |
|
| 700 | - * @param string $name |
|
| 701 | - * @return string |
|
| 702 | - */ |
|
| 703 | - private function _generate_config_option_name($section = '', $name = '') |
|
| 704 | - { |
|
| 705 | - return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name)); |
|
| 706 | - } |
|
| 707 | - |
|
| 708 | - |
|
| 709 | - /** |
|
| 710 | - * _set_config_class |
|
| 711 | - * ensures that a config class is set, either from a passed config class or one generated from the config name |
|
| 712 | - * |
|
| 713 | - * @access private |
|
| 714 | - * @param string $config_class |
|
| 715 | - * @param string $name |
|
| 716 | - * @return string |
|
| 717 | - */ |
|
| 718 | - private function _set_config_class($config_class = '', $name = '') |
|
| 719 | - { |
|
| 720 | - return ! empty($config_class) |
|
| 721 | - ? $config_class |
|
| 722 | - : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config'; |
|
| 723 | - } |
|
| 724 | - |
|
| 725 | - |
|
| 726 | - /** |
|
| 727 | - * set_config |
|
| 728 | - * |
|
| 729 | - * @access protected |
|
| 730 | - * @param string $section |
|
| 731 | - * @param string $name |
|
| 732 | - * @param string $config_class |
|
| 733 | - * @param EE_Config_Base $config_obj |
|
| 734 | - * @return EE_Config_Base |
|
| 735 | - */ |
|
| 736 | - public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) |
|
| 737 | - { |
|
| 738 | - // ensure config class is set to something |
|
| 739 | - $config_class = $this->_set_config_class($config_class, $name); |
|
| 740 | - // run tests 1-4, 6, and 7 to verify all config params are set and valid |
|
| 741 | - if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
| 742 | - return null; |
|
| 743 | - } |
|
| 744 | - $config_option_name = $this->_generate_config_option_name($section, $name); |
|
| 745 | - // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
|
| 746 | - if (! isset($this->_addon_option_names[ $config_option_name ])) { |
|
| 747 | - $this->_addon_option_names[ $config_option_name ] = $config_class; |
|
| 748 | - $this->update_addon_option_names(); |
|
| 749 | - } |
|
| 750 | - // verify the incoming config object but suppress errors |
|
| 751 | - if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
| 752 | - $config_obj = new $config_class(); |
|
| 753 | - } |
|
| 754 | - if (get_option($config_option_name)) { |
|
| 755 | - EE_Config::log($config_option_name); |
|
| 756 | - update_option($config_option_name, $config_obj); |
|
| 757 | - $this->{$section}->{$name} = $config_obj; |
|
| 758 | - return $this->{$section}->{$name}; |
|
| 759 | - } else { |
|
| 760 | - // create a wp-option for this config |
|
| 761 | - if (add_option($config_option_name, $config_obj, '', 'no')) { |
|
| 762 | - $this->{$section}->{$name} = maybe_unserialize($config_obj); |
|
| 763 | - return $this->{$section}->{$name}; |
|
| 764 | - } else { |
|
| 765 | - EE_Error::add_error( |
|
| 766 | - sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class), |
|
| 767 | - __FILE__, |
|
| 768 | - __FUNCTION__, |
|
| 769 | - __LINE__ |
|
| 770 | - ); |
|
| 771 | - return null; |
|
| 772 | - } |
|
| 773 | - } |
|
| 774 | - } |
|
| 775 | - |
|
| 776 | - |
|
| 777 | - /** |
|
| 778 | - * update_config |
|
| 779 | - * Important: the config object must ALREADY be set, otherwise this will produce an error. |
|
| 780 | - * |
|
| 781 | - * @access public |
|
| 782 | - * @param string $section |
|
| 783 | - * @param string $name |
|
| 784 | - * @param EE_Config_Base|string $config_obj |
|
| 785 | - * @param bool $throw_errors |
|
| 786 | - * @return bool |
|
| 787 | - */ |
|
| 788 | - public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) |
|
| 789 | - { |
|
| 790 | - // don't allow config updates during WP heartbeats |
|
| 791 | - if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
| 792 | - return false; |
|
| 793 | - } |
|
| 794 | - $config_obj = maybe_unserialize($config_obj); |
|
| 795 | - // get class name of the incoming object |
|
| 796 | - $config_class = get_class($config_obj); |
|
| 797 | - // run tests 1-5 and 9 to verify config |
|
| 798 | - if (! $this->_verify_config_params( |
|
| 799 | - $section, |
|
| 800 | - $name, |
|
| 801 | - $config_class, |
|
| 802 | - $config_obj, |
|
| 803 | - array(1, 2, 3, 4, 7, 9) |
|
| 804 | - ) |
|
| 805 | - ) { |
|
| 806 | - return false; |
|
| 807 | - } |
|
| 808 | - $config_option_name = $this->_generate_config_option_name($section, $name); |
|
| 809 | - // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array |
|
| 810 | - if (! isset($this->_addon_option_names[ $config_option_name ])) { |
|
| 811 | - // save new config to db |
|
| 812 | - if ($this->set_config($section, $name, $config_class, $config_obj)) { |
|
| 813 | - return true; |
|
| 814 | - } |
|
| 815 | - } else { |
|
| 816 | - // first check if the record already exists |
|
| 817 | - $existing_config = get_option($config_option_name); |
|
| 818 | - $config_obj = serialize($config_obj); |
|
| 819 | - // just return if db record is already up to date (NOT type safe comparison) |
|
| 820 | - if ($existing_config == $config_obj) { |
|
| 821 | - $this->{$section}->{$name} = $config_obj; |
|
| 822 | - return true; |
|
| 823 | - } elseif (update_option($config_option_name, $config_obj)) { |
|
| 824 | - EE_Config::log($config_option_name); |
|
| 825 | - // update wp-option for this config class |
|
| 826 | - $this->{$section}->{$name} = $config_obj; |
|
| 827 | - return true; |
|
| 828 | - } elseif ($throw_errors) { |
|
| 829 | - EE_Error::add_error( |
|
| 830 | - sprintf( |
|
| 831 | - __( |
|
| 832 | - 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', |
|
| 833 | - 'event_espresso' |
|
| 834 | - ), |
|
| 835 | - $config_class, |
|
| 836 | - 'EE_Config->' . $section . '->' . $name |
|
| 837 | - ), |
|
| 838 | - __FILE__, |
|
| 839 | - __FUNCTION__, |
|
| 840 | - __LINE__ |
|
| 841 | - ); |
|
| 842 | - } |
|
| 843 | - } |
|
| 844 | - return false; |
|
| 845 | - } |
|
| 846 | - |
|
| 847 | - |
|
| 848 | - /** |
|
| 849 | - * get_config |
|
| 850 | - * |
|
| 851 | - * @access public |
|
| 852 | - * @param string $section |
|
| 853 | - * @param string $name |
|
| 854 | - * @param string $config_class |
|
| 855 | - * @return mixed EE_Config_Base | NULL |
|
| 856 | - */ |
|
| 857 | - public function get_config($section = '', $name = '', $config_class = '') |
|
| 858 | - { |
|
| 859 | - // ensure config class is set to something |
|
| 860 | - $config_class = $this->_set_config_class($config_class, $name); |
|
| 861 | - // run tests 1-4, 6 and 7 to verify that all params have been set |
|
| 862 | - if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
| 863 | - return null; |
|
| 864 | - } |
|
| 865 | - // now test if the requested config object exists, but suppress errors |
|
| 866 | - if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) { |
|
| 867 | - // config already exists, so pass it back |
|
| 868 | - return $this->{$section}->{$name}; |
|
| 869 | - } |
|
| 870 | - // load config option from db if it exists |
|
| 871 | - $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name)); |
|
| 872 | - // verify the newly retrieved config object, but suppress errors |
|
| 873 | - if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
| 874 | - // config is good, so set it and pass it back |
|
| 875 | - $this->{$section}->{$name} = $config_obj; |
|
| 876 | - return $this->{$section}->{$name}; |
|
| 877 | - } |
|
| 878 | - // oops! $config_obj is not already set and does not exist in the db, so create a new one |
|
| 879 | - $config_obj = $this->set_config($section, $name, $config_class); |
|
| 880 | - // verify the newly created config object |
|
| 881 | - if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) { |
|
| 882 | - return $this->{$section}->{$name}; |
|
| 883 | - } else { |
|
| 884 | - EE_Error::add_error( |
|
| 885 | - sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class), |
|
| 886 | - __FILE__, |
|
| 887 | - __FUNCTION__, |
|
| 888 | - __LINE__ |
|
| 889 | - ); |
|
| 890 | - } |
|
| 891 | - return null; |
|
| 892 | - } |
|
| 893 | - |
|
| 894 | - |
|
| 895 | - /** |
|
| 896 | - * get_config_option |
|
| 897 | - * |
|
| 898 | - * @access public |
|
| 899 | - * @param string $config_option_name |
|
| 900 | - * @return mixed EE_Config_Base | FALSE |
|
| 901 | - */ |
|
| 902 | - public function get_config_option($config_option_name = '') |
|
| 903 | - { |
|
| 904 | - // retrieve the wp-option for this config class. |
|
| 905 | - $config_option = maybe_unserialize(get_option($config_option_name, array())); |
|
| 906 | - if (empty($config_option)) { |
|
| 907 | - EE_Config::log($config_option_name . '-NOT-FOUND'); |
|
| 908 | - } |
|
| 909 | - return $config_option; |
|
| 910 | - } |
|
| 911 | - |
|
| 912 | - |
|
| 913 | - /** |
|
| 914 | - * log |
|
| 915 | - * |
|
| 916 | - * @param string $config_option_name |
|
| 917 | - */ |
|
| 918 | - public static function log($config_option_name = '') |
|
| 919 | - { |
|
| 920 | - if (EE_Config::logging_enabled() && ! empty($config_option_name)) { |
|
| 921 | - $config_log = get_option(EE_Config::LOG_NAME, array()); |
|
| 922 | - // copy incoming $_REQUEST and sanitize it so we can save it |
|
| 923 | - $_request = $_REQUEST; |
|
| 924 | - array_walk_recursive($_request, 'sanitize_text_field'); |
|
| 925 | - $config_log[ (string) microtime(true) ] = array( |
|
| 926 | - 'config_name' => $config_option_name, |
|
| 927 | - 'request' => $_request, |
|
| 928 | - ); |
|
| 929 | - update_option(EE_Config::LOG_NAME, $config_log); |
|
| 930 | - } |
|
| 931 | - } |
|
| 932 | - |
|
| 933 | - |
|
| 934 | - /** |
|
| 935 | - * trim_log |
|
| 936 | - * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH |
|
| 937 | - */ |
|
| 938 | - public static function trim_log() |
|
| 939 | - { |
|
| 940 | - if (! EE_Config::logging_enabled()) { |
|
| 941 | - return; |
|
| 942 | - } |
|
| 943 | - $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array())); |
|
| 944 | - $log_length = count($config_log); |
|
| 945 | - if ($log_length > EE_Config::LOG_LENGTH) { |
|
| 946 | - ksort($config_log); |
|
| 947 | - $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true); |
|
| 948 | - update_option(EE_Config::LOG_NAME, $config_log); |
|
| 949 | - } |
|
| 950 | - } |
|
| 951 | - |
|
| 952 | - |
|
| 953 | - /** |
|
| 954 | - * get_page_for_posts |
|
| 955 | - * if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the |
|
| 956 | - * wp-option "page_for_posts", or "posts" if no page is selected |
|
| 957 | - * |
|
| 958 | - * @access public |
|
| 959 | - * @return string |
|
| 960 | - */ |
|
| 961 | - public static function get_page_for_posts() |
|
| 962 | - { |
|
| 963 | - $page_for_posts = get_option('page_for_posts'); |
|
| 964 | - if (! $page_for_posts) { |
|
| 965 | - return 'posts'; |
|
| 966 | - } |
|
| 967 | - /** @type WPDB $wpdb */ |
|
| 968 | - global $wpdb; |
|
| 969 | - $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
| 970 | - return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts)); |
|
| 971 | - } |
|
| 972 | - |
|
| 973 | - |
|
| 974 | - /** |
|
| 975 | - * register_shortcodes_and_modules. |
|
| 976 | - * At this point, it's too early to tell if we're maintenance mode or not. |
|
| 977 | - * In fact, this is where we give modules a chance to let core know they exist |
|
| 978 | - * so they can help trigger maintenance mode if it's needed |
|
| 979 | - * |
|
| 980 | - * @access public |
|
| 981 | - * @return void |
|
| 982 | - */ |
|
| 983 | - public function register_shortcodes_and_modules() |
|
| 984 | - { |
|
| 985 | - // allow modules to set hooks for the rest of the system |
|
| 986 | - EE_Registry::instance()->modules = $this->_register_modules(); |
|
| 987 | - } |
|
| 988 | - |
|
| 989 | - |
|
| 990 | - /** |
|
| 991 | - * initialize_shortcodes_and_modules |
|
| 992 | - * meaning they can start adding their hooks to get stuff done |
|
| 993 | - * |
|
| 994 | - * @access public |
|
| 995 | - * @return void |
|
| 996 | - */ |
|
| 997 | - public function initialize_shortcodes_and_modules() |
|
| 998 | - { |
|
| 999 | - // allow modules to set hooks for the rest of the system |
|
| 1000 | - $this->_initialize_modules(); |
|
| 1001 | - } |
|
| 1002 | - |
|
| 1003 | - |
|
| 1004 | - /** |
|
| 1005 | - * widgets_init |
|
| 1006 | - * |
|
| 1007 | - * @access private |
|
| 1008 | - * @return void |
|
| 1009 | - */ |
|
| 1010 | - public function widgets_init() |
|
| 1011 | - { |
|
| 1012 | - // only init widgets on admin pages when not in complete maintenance, and |
|
| 1013 | - // on frontend when not in any maintenance mode |
|
| 1014 | - if (! EE_Maintenance_Mode::instance()->level() |
|
| 1015 | - || ( |
|
| 1016 | - is_admin() |
|
| 1017 | - && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance |
|
| 1018 | - ) |
|
| 1019 | - ) { |
|
| 1020 | - // grab list of installed widgets |
|
| 1021 | - $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR); |
|
| 1022 | - // filter list of modules to register |
|
| 1023 | - $widgets_to_register = apply_filters( |
|
| 1024 | - 'FHEE__EE_Config__register_widgets__widgets_to_register', |
|
| 1025 | - $widgets_to_register |
|
| 1026 | - ); |
|
| 1027 | - if (! empty($widgets_to_register)) { |
|
| 1028 | - // cycle thru widget folders |
|
| 1029 | - foreach ($widgets_to_register as $widget_path) { |
|
| 1030 | - // add to list of installed widget modules |
|
| 1031 | - EE_Config::register_ee_widget($widget_path); |
|
| 1032 | - } |
|
| 1033 | - } |
|
| 1034 | - // filter list of installed modules |
|
| 1035 | - EE_Registry::instance()->widgets = apply_filters( |
|
| 1036 | - 'FHEE__EE_Config__register_widgets__installed_widgets', |
|
| 1037 | - EE_Registry::instance()->widgets |
|
| 1038 | - ); |
|
| 1039 | - } |
|
| 1040 | - } |
|
| 1041 | - |
|
| 1042 | - |
|
| 1043 | - /** |
|
| 1044 | - * register_ee_widget - makes core aware of this widget |
|
| 1045 | - * |
|
| 1046 | - * @access public |
|
| 1047 | - * @param string $widget_path - full path up to and including widget folder |
|
| 1048 | - * @return void |
|
| 1049 | - */ |
|
| 1050 | - public static function register_ee_widget($widget_path = null) |
|
| 1051 | - { |
|
| 1052 | - do_action('AHEE__EE_Config__register_widget__begin', $widget_path); |
|
| 1053 | - $widget_ext = '.widget.php'; |
|
| 1054 | - // make all separators match |
|
| 1055 | - $widget_path = rtrim(str_replace('\\', DS, $widget_path), DS); |
|
| 1056 | - // does the file path INCLUDE the actual file name as part of the path ? |
|
| 1057 | - if (strpos($widget_path, $widget_ext) !== false) { |
|
| 1058 | - // grab and shortcode file name from directory name and break apart at dots |
|
| 1059 | - $file_name = explode('.', basename($widget_path)); |
|
| 1060 | - // take first segment from file name pieces and remove class prefix if it exists |
|
| 1061 | - $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0]; |
|
| 1062 | - // sanitize shortcode directory name |
|
| 1063 | - $widget = sanitize_key($widget); |
|
| 1064 | - // now we need to rebuild the shortcode path |
|
| 1065 | - $widget_path = explode('/', $widget_path); |
|
| 1066 | - // remove last segment |
|
| 1067 | - array_pop($widget_path); |
|
| 1068 | - // glue it back together |
|
| 1069 | - $widget_path = implode(DS, $widget_path); |
|
| 1070 | - } else { |
|
| 1071 | - // grab and sanitize widget directory name |
|
| 1072 | - $widget = sanitize_key(basename($widget_path)); |
|
| 1073 | - } |
|
| 1074 | - // create classname from widget directory name |
|
| 1075 | - $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
|
| 1076 | - // add class prefix |
|
| 1077 | - $widget_class = 'EEW_' . $widget; |
|
| 1078 | - // does the widget exist ? |
|
| 1079 | - if (! is_readable($widget_path . '/' . $widget_class . $widget_ext)) { |
|
| 1080 | - $msg = sprintf( |
|
| 1081 | - __( |
|
| 1082 | - 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
|
| 1083 | - 'event_espresso' |
|
| 1084 | - ), |
|
| 1085 | - $widget_class, |
|
| 1086 | - $widget_path . '/' . $widget_class . $widget_ext |
|
| 1087 | - ); |
|
| 1088 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1089 | - return; |
|
| 1090 | - } |
|
| 1091 | - // load the widget class file |
|
| 1092 | - require_once($widget_path . '/' . $widget_class . $widget_ext); |
|
| 1093 | - // verify that class exists |
|
| 1094 | - if (! class_exists($widget_class)) { |
|
| 1095 | - $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
|
| 1096 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1097 | - return; |
|
| 1098 | - } |
|
| 1099 | - register_widget($widget_class); |
|
| 1100 | - // add to array of registered widgets |
|
| 1101 | - EE_Registry::instance()->widgets->{$widget_class} = $widget_path . '/' . $widget_class . $widget_ext; |
|
| 1102 | - } |
|
| 1103 | - |
|
| 1104 | - |
|
| 1105 | - /** |
|
| 1106 | - * _register_modules |
|
| 1107 | - * |
|
| 1108 | - * @access private |
|
| 1109 | - * @return array |
|
| 1110 | - */ |
|
| 1111 | - private function _register_modules() |
|
| 1112 | - { |
|
| 1113 | - // grab list of installed modules |
|
| 1114 | - $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR); |
|
| 1115 | - // filter list of modules to register |
|
| 1116 | - $modules_to_register = apply_filters( |
|
| 1117 | - 'FHEE__EE_Config__register_modules__modules_to_register', |
|
| 1118 | - $modules_to_register |
|
| 1119 | - ); |
|
| 1120 | - if (! empty($modules_to_register)) { |
|
| 1121 | - // loop through folders |
|
| 1122 | - foreach ($modules_to_register as $module_path) { |
|
| 1123 | - /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
|
| 1124 | - if ($module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
| 1125 | - && $module_path !== EE_MODULES . 'gateways' |
|
| 1126 | - ) { |
|
| 1127 | - // add to list of installed modules |
|
| 1128 | - EE_Config::register_module($module_path); |
|
| 1129 | - } |
|
| 1130 | - } |
|
| 1131 | - } |
|
| 1132 | - // filter list of installed modules |
|
| 1133 | - return apply_filters( |
|
| 1134 | - 'FHEE__EE_Config___register_modules__installed_modules', |
|
| 1135 | - EE_Registry::instance()->modules |
|
| 1136 | - ); |
|
| 1137 | - } |
|
| 1138 | - |
|
| 1139 | - |
|
| 1140 | - /** |
|
| 1141 | - * register_module - makes core aware of this module |
|
| 1142 | - * |
|
| 1143 | - * @access public |
|
| 1144 | - * @param string $module_path - full path up to and including module folder |
|
| 1145 | - * @return bool |
|
| 1146 | - */ |
|
| 1147 | - public static function register_module($module_path = null) |
|
| 1148 | - { |
|
| 1149 | - do_action('AHEE__EE_Config__register_module__begin', $module_path); |
|
| 1150 | - $module_ext = '.module.php'; |
|
| 1151 | - // make all separators match |
|
| 1152 | - $module_path = str_replace(array('\\', '/'), '/', $module_path); |
|
| 1153 | - // does the file path INCLUDE the actual file name as part of the path ? |
|
| 1154 | - if (strpos($module_path, $module_ext) !== false) { |
|
| 1155 | - // grab and shortcode file name from directory name and break apart at dots |
|
| 1156 | - $module_file = explode('.', basename($module_path)); |
|
| 1157 | - // now we need to rebuild the shortcode path |
|
| 1158 | - $module_path = explode('/', $module_path); |
|
| 1159 | - // remove last segment |
|
| 1160 | - array_pop($module_path); |
|
| 1161 | - // glue it back together |
|
| 1162 | - $module_path = implode('/', $module_path) . '/'; |
|
| 1163 | - // take first segment from file name pieces and sanitize it |
|
| 1164 | - $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
|
| 1165 | - // ensure class prefix is added |
|
| 1166 | - $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module; |
|
| 1167 | - } else { |
|
| 1168 | - // we need to generate the filename based off of the folder name |
|
| 1169 | - // grab and sanitize module name |
|
| 1170 | - $module = strtolower(basename($module_path)); |
|
| 1171 | - $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
|
| 1172 | - // like trailingslashit() |
|
| 1173 | - $module_path = rtrim($module_path, '/') . '/'; |
|
| 1174 | - // create classname from module directory name |
|
| 1175 | - $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
|
| 1176 | - // add class prefix |
|
| 1177 | - $module_class = 'EED_' . $module; |
|
| 1178 | - } |
|
| 1179 | - // does the module exist ? |
|
| 1180 | - if (! is_readable($module_path . '/' . $module_class . $module_ext)) { |
|
| 1181 | - $msg = sprintf( |
|
| 1182 | - __( |
|
| 1183 | - 'The requested %s module file could not be found or is not readable due to file permissions.', |
|
| 1184 | - 'event_espresso' |
|
| 1185 | - ), |
|
| 1186 | - $module |
|
| 1187 | - ); |
|
| 1188 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1189 | - return false; |
|
| 1190 | - } |
|
| 1191 | - // load the module class file |
|
| 1192 | - require_once($module_path . $module_class . $module_ext); |
|
| 1193 | - // verify that class exists |
|
| 1194 | - if (! class_exists($module_class)) { |
|
| 1195 | - $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
| 1196 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1197 | - return false; |
|
| 1198 | - } |
|
| 1199 | - // add to array of registered modules |
|
| 1200 | - EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
| 1201 | - do_action( |
|
| 1202 | - 'AHEE__EE_Config__register_module__complete', |
|
| 1203 | - $module_class, |
|
| 1204 | - EE_Registry::instance()->modules->{$module_class} |
|
| 1205 | - ); |
|
| 1206 | - return true; |
|
| 1207 | - } |
|
| 1208 | - |
|
| 1209 | - |
|
| 1210 | - /** |
|
| 1211 | - * _initialize_modules |
|
| 1212 | - * allow modules to set hooks for the rest of the system |
|
| 1213 | - * |
|
| 1214 | - * @access private |
|
| 1215 | - * @return void |
|
| 1216 | - */ |
|
| 1217 | - private function _initialize_modules() |
|
| 1218 | - { |
|
| 1219 | - // cycle thru shortcode folders |
|
| 1220 | - foreach (EE_Registry::instance()->modules as $module_class => $module_path) { |
|
| 1221 | - // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
| 1222 | - // which set hooks ? |
|
| 1223 | - if (is_admin()) { |
|
| 1224 | - // fire immediately |
|
| 1225 | - call_user_func(array($module_class, 'set_hooks_admin')); |
|
| 1226 | - } else { |
|
| 1227 | - // delay until other systems are online |
|
| 1228 | - add_action( |
|
| 1229 | - 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
| 1230 | - array($module_class, 'set_hooks') |
|
| 1231 | - ); |
|
| 1232 | - } |
|
| 1233 | - } |
|
| 1234 | - } |
|
| 1235 | - |
|
| 1236 | - |
|
| 1237 | - /** |
|
| 1238 | - * register_route - adds module method routes to route_map |
|
| 1239 | - * |
|
| 1240 | - * @access public |
|
| 1241 | - * @param string $route - "pretty" public alias for module method |
|
| 1242 | - * @param string $module - module name (classname without EED_ prefix) |
|
| 1243 | - * @param string $method_name - the actual module method to be routed to |
|
| 1244 | - * @param string $key - url param key indicating a route is being called |
|
| 1245 | - * @return bool |
|
| 1246 | - */ |
|
| 1247 | - public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee') |
|
| 1248 | - { |
|
| 1249 | - do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
|
| 1250 | - $module = str_replace('EED_', '', $module); |
|
| 1251 | - $module_class = 'EED_' . $module; |
|
| 1252 | - if (! isset(EE_Registry::instance()->modules->{$module_class})) { |
|
| 1253 | - $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
|
| 1254 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1255 | - return false; |
|
| 1256 | - } |
|
| 1257 | - if (empty($route)) { |
|
| 1258 | - $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
|
| 1259 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1260 | - return false; |
|
| 1261 | - } |
|
| 1262 | - if (! method_exists('EED_' . $module, $method_name)) { |
|
| 1263 | - $msg = sprintf( |
|
| 1264 | - __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
|
| 1265 | - $route |
|
| 1266 | - ); |
|
| 1267 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1268 | - return false; |
|
| 1269 | - } |
|
| 1270 | - EE_Config::$_module_route_map[ (string) $key ][ (string) $route ] = array('EED_' . $module, $method_name); |
|
| 1271 | - return true; |
|
| 1272 | - } |
|
| 1273 | - |
|
| 1274 | - |
|
| 1275 | - /** |
|
| 1276 | - * get_route - get module method route |
|
| 1277 | - * |
|
| 1278 | - * @access public |
|
| 1279 | - * @param string $route - "pretty" public alias for module method |
|
| 1280 | - * @param string $key - url param key indicating a route is being called |
|
| 1281 | - * @return string |
|
| 1282 | - */ |
|
| 1283 | - public static function get_route($route = null, $key = 'ee') |
|
| 1284 | - { |
|
| 1285 | - do_action('AHEE__EE_Config__get_route__begin', $route); |
|
| 1286 | - $route = (string) apply_filters('FHEE__EE_Config__get_route', $route); |
|
| 1287 | - if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) { |
|
| 1288 | - return EE_Config::$_module_route_map[ $key ][ $route ]; |
|
| 1289 | - } |
|
| 1290 | - return null; |
|
| 1291 | - } |
|
| 1292 | - |
|
| 1293 | - |
|
| 1294 | - /** |
|
| 1295 | - * get_routes - get ALL module method routes |
|
| 1296 | - * |
|
| 1297 | - * @access public |
|
| 1298 | - * @return array |
|
| 1299 | - */ |
|
| 1300 | - public static function get_routes() |
|
| 1301 | - { |
|
| 1302 | - return EE_Config::$_module_route_map; |
|
| 1303 | - } |
|
| 1304 | - |
|
| 1305 | - |
|
| 1306 | - /** |
|
| 1307 | - * register_forward - allows modules to forward request to another module for further processing |
|
| 1308 | - * |
|
| 1309 | - * @access public |
|
| 1310 | - * @param string $route - "pretty" public alias for module method |
|
| 1311 | - * @param integer $status - integer value corresponding to status constant strings set in module parent |
|
| 1312 | - * class, allows different forwards to be served based on status |
|
| 1313 | - * @param array|string $forward - function name or array( class, method ) |
|
| 1314 | - * @param string $key - url param key indicating a route is being called |
|
| 1315 | - * @return bool |
|
| 1316 | - */ |
|
| 1317 | - public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee') |
|
| 1318 | - { |
|
| 1319 | - do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
|
| 1320 | - if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) { |
|
| 1321 | - $msg = sprintf( |
|
| 1322 | - __('The module route %s for this forward has not been registered.', 'event_espresso'), |
|
| 1323 | - $route |
|
| 1324 | - ); |
|
| 1325 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1326 | - return false; |
|
| 1327 | - } |
|
| 1328 | - if (empty($forward)) { |
|
| 1329 | - $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
|
| 1330 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1331 | - return false; |
|
| 1332 | - } |
|
| 1333 | - if (is_array($forward)) { |
|
| 1334 | - if (! isset($forward[1])) { |
|
| 1335 | - $msg = sprintf( |
|
| 1336 | - __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
|
| 1337 | - $route |
|
| 1338 | - ); |
|
| 1339 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1340 | - return false; |
|
| 1341 | - } |
|
| 1342 | - if (! method_exists($forward[0], $forward[1])) { |
|
| 1343 | - $msg = sprintf( |
|
| 1344 | - __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
| 1345 | - $forward[1], |
|
| 1346 | - $route |
|
| 1347 | - ); |
|
| 1348 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1349 | - return false; |
|
| 1350 | - } |
|
| 1351 | - } elseif (! function_exists($forward)) { |
|
| 1352 | - $msg = sprintf( |
|
| 1353 | - __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
| 1354 | - $forward, |
|
| 1355 | - $route |
|
| 1356 | - ); |
|
| 1357 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1358 | - return false; |
|
| 1359 | - } |
|
| 1360 | - EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward; |
|
| 1361 | - return true; |
|
| 1362 | - } |
|
| 1363 | - |
|
| 1364 | - |
|
| 1365 | - /** |
|
| 1366 | - * get_forward - get forwarding route |
|
| 1367 | - * |
|
| 1368 | - * @access public |
|
| 1369 | - * @param string $route - "pretty" public alias for module method |
|
| 1370 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
| 1371 | - * allows different forwards to be served based on status |
|
| 1372 | - * @param string $key - url param key indicating a route is being called |
|
| 1373 | - * @return string |
|
| 1374 | - */ |
|
| 1375 | - public static function get_forward($route = null, $status = 0, $key = 'ee') |
|
| 1376 | - { |
|
| 1377 | - do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
|
| 1378 | - if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) { |
|
| 1379 | - return apply_filters( |
|
| 1380 | - 'FHEE__EE_Config__get_forward', |
|
| 1381 | - EE_Config::$_module_forward_map[ $key ][ $route ][ $status ], |
|
| 1382 | - $route, |
|
| 1383 | - $status |
|
| 1384 | - ); |
|
| 1385 | - } |
|
| 1386 | - return null; |
|
| 1387 | - } |
|
| 1388 | - |
|
| 1389 | - |
|
| 1390 | - /** |
|
| 1391 | - * register_forward - allows modules to specify different view templates for different method routes and status |
|
| 1392 | - * results |
|
| 1393 | - * |
|
| 1394 | - * @access public |
|
| 1395 | - * @param string $route - "pretty" public alias for module method |
|
| 1396 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
| 1397 | - * allows different views to be served based on status |
|
| 1398 | - * @param string $view |
|
| 1399 | - * @param string $key - url param key indicating a route is being called |
|
| 1400 | - * @return bool |
|
| 1401 | - */ |
|
| 1402 | - public static function register_view($route = null, $status = 0, $view = null, $key = 'ee') |
|
| 1403 | - { |
|
| 1404 | - do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
|
| 1405 | - if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) { |
|
| 1406 | - $msg = sprintf( |
|
| 1407 | - __('The module route %s for this view has not been registered.', 'event_espresso'), |
|
| 1408 | - $route |
|
| 1409 | - ); |
|
| 1410 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1411 | - return false; |
|
| 1412 | - } |
|
| 1413 | - if (! is_readable($view)) { |
|
| 1414 | - $msg = sprintf( |
|
| 1415 | - __( |
|
| 1416 | - 'The %s view file could not be found or is not readable due to file permissions.', |
|
| 1417 | - 'event_espresso' |
|
| 1418 | - ), |
|
| 1419 | - $view |
|
| 1420 | - ); |
|
| 1421 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1422 | - return false; |
|
| 1423 | - } |
|
| 1424 | - EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view; |
|
| 1425 | - return true; |
|
| 1426 | - } |
|
| 1427 | - |
|
| 1428 | - |
|
| 1429 | - /** |
|
| 1430 | - * get_view - get view for route and status |
|
| 1431 | - * |
|
| 1432 | - * @access public |
|
| 1433 | - * @param string $route - "pretty" public alias for module method |
|
| 1434 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
| 1435 | - * allows different views to be served based on status |
|
| 1436 | - * @param string $key - url param key indicating a route is being called |
|
| 1437 | - * @return string |
|
| 1438 | - */ |
|
| 1439 | - public static function get_view($route = null, $status = 0, $key = 'ee') |
|
| 1440 | - { |
|
| 1441 | - do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
|
| 1442 | - if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) { |
|
| 1443 | - return apply_filters( |
|
| 1444 | - 'FHEE__EE_Config__get_view', |
|
| 1445 | - EE_Config::$_module_view_map[ $key ][ $route ][ $status ], |
|
| 1446 | - $route, |
|
| 1447 | - $status |
|
| 1448 | - ); |
|
| 1449 | - } |
|
| 1450 | - return null; |
|
| 1451 | - } |
|
| 1452 | - |
|
| 1453 | - |
|
| 1454 | - public function update_addon_option_names() |
|
| 1455 | - { |
|
| 1456 | - update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names); |
|
| 1457 | - } |
|
| 1458 | - |
|
| 1459 | - |
|
| 1460 | - public function shutdown() |
|
| 1461 | - { |
|
| 1462 | - $this->update_addon_option_names(); |
|
| 1463 | - } |
|
| 1464 | - |
|
| 1465 | - |
|
| 1466 | - /** |
|
| 1467 | - * @return LegacyShortcodesManager |
|
| 1468 | - */ |
|
| 1469 | - public static function getLegacyShortcodesManager() |
|
| 1470 | - { |
|
| 1471 | - |
|
| 1472 | - if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) { |
|
| 1473 | - EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager( |
|
| 1474 | - EE_Registry::instance() |
|
| 1475 | - ); |
|
| 1476 | - } |
|
| 1477 | - return EE_Config::instance()->legacy_shortcodes_manager; |
|
| 1478 | - } |
|
| 1479 | - |
|
| 1480 | - |
|
| 1481 | - /** |
|
| 1482 | - * register_shortcode - makes core aware of this shortcode |
|
| 1483 | - * |
|
| 1484 | - * @deprecated 4.9.26 |
|
| 1485 | - * @param string $shortcode_path - full path up to and including shortcode folder |
|
| 1486 | - * @return bool |
|
| 1487 | - */ |
|
| 1488 | - public static function register_shortcode($shortcode_path = null) |
|
| 1489 | - { |
|
| 1490 | - EE_Error::doing_it_wrong( |
|
| 1491 | - __METHOD__, |
|
| 1492 | - __( |
|
| 1493 | - 'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.', |
|
| 1494 | - 'event_espresso' |
|
| 1495 | - ), |
|
| 1496 | - '4.9.26' |
|
| 1497 | - ); |
|
| 1498 | - return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path); |
|
| 1499 | - } |
|
| 1500 | -} |
|
| 1501 | - |
|
| 1502 | -/** |
|
| 1503 | - * Base class used for config classes. These classes should generally not have |
|
| 1504 | - * magic functions in use, except we'll allow them to magically set and get stuff... |
|
| 1505 | - * basically, they should just be well-defined stdClasses |
|
| 1506 | - */ |
|
| 1507 | -class EE_Config_Base |
|
| 1508 | -{ |
|
| 1509 | - |
|
| 1510 | - /** |
|
| 1511 | - * Utility function for escaping the value of a property and returning. |
|
| 1512 | - * |
|
| 1513 | - * @param string $property property name (checks to see if exists). |
|
| 1514 | - * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
| 1515 | - * @throws \EE_Error |
|
| 1516 | - */ |
|
| 1517 | - public function get_pretty($property) |
|
| 1518 | - { |
|
| 1519 | - if (! property_exists($this, $property)) { |
|
| 1520 | - throw new EE_Error( |
|
| 1521 | - sprintf( |
|
| 1522 | - __( |
|
| 1523 | - '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', |
|
| 1524 | - 'event_espresso' |
|
| 1525 | - ), |
|
| 1526 | - get_class($this), |
|
| 1527 | - $property |
|
| 1528 | - ) |
|
| 1529 | - ); |
|
| 1530 | - } |
|
| 1531 | - // just handling escaping of strings for now. |
|
| 1532 | - if (is_string($this->{$property})) { |
|
| 1533 | - return stripslashes($this->{$property}); |
|
| 1534 | - } |
|
| 1535 | - return $this->{$property}; |
|
| 1536 | - } |
|
| 1537 | - |
|
| 1538 | - |
|
| 1539 | - public function populate() |
|
| 1540 | - { |
|
| 1541 | - // grab defaults via a new instance of this class. |
|
| 1542 | - $class_name = get_class($this); |
|
| 1543 | - $defaults = new $class_name; |
|
| 1544 | - // loop through the properties for this class and see if they are set. If they are NOT, then grab the |
|
| 1545 | - // default from our $defaults object. |
|
| 1546 | - foreach (get_object_vars($defaults) as $property => $value) { |
|
| 1547 | - if ($this->{$property} === null) { |
|
| 1548 | - $this->{$property} = $value; |
|
| 1549 | - } |
|
| 1550 | - } |
|
| 1551 | - // cleanup |
|
| 1552 | - unset($defaults); |
|
| 1553 | - } |
|
| 1554 | - |
|
| 1555 | - |
|
| 1556 | - /** |
|
| 1557 | - * __isset |
|
| 1558 | - * |
|
| 1559 | - * @param $a |
|
| 1560 | - * @return bool |
|
| 1561 | - */ |
|
| 1562 | - public function __isset($a) |
|
| 1563 | - { |
|
| 1564 | - return false; |
|
| 1565 | - } |
|
| 1566 | - |
|
| 1567 | - |
|
| 1568 | - /** |
|
| 1569 | - * __unset |
|
| 1570 | - * |
|
| 1571 | - * @param $a |
|
| 1572 | - * @return bool |
|
| 1573 | - */ |
|
| 1574 | - public function __unset($a) |
|
| 1575 | - { |
|
| 1576 | - return false; |
|
| 1577 | - } |
|
| 1578 | - |
|
| 1579 | - |
|
| 1580 | - /** |
|
| 1581 | - * __clone |
|
| 1582 | - */ |
|
| 1583 | - public function __clone() |
|
| 1584 | - { |
|
| 1585 | - } |
|
| 1586 | - |
|
| 1587 | - |
|
| 1588 | - /** |
|
| 1589 | - * __wakeup |
|
| 1590 | - */ |
|
| 1591 | - public function __wakeup() |
|
| 1592 | - { |
|
| 1593 | - } |
|
| 1594 | - |
|
| 1595 | - |
|
| 1596 | - /** |
|
| 1597 | - * __destruct |
|
| 1598 | - */ |
|
| 1599 | - public function __destruct() |
|
| 1600 | - { |
|
| 1601 | - } |
|
| 1602 | -} |
|
| 1603 | - |
|
| 1604 | -/** |
|
| 1605 | - * Class for defining what's in the EE_Config relating to registration settings |
|
| 1606 | - */ |
|
| 1607 | -class EE_Core_Config extends EE_Config_Base |
|
| 1608 | -{ |
|
| 1609 | - |
|
| 1610 | - const OPTION_NAME_UXIP = 'ee_ueip_optin'; |
|
| 1611 | - |
|
| 1612 | - |
|
| 1613 | - public $current_blog_id; |
|
| 1614 | - |
|
| 1615 | - public $ee_ueip_optin; |
|
| 1616 | - |
|
| 1617 | - public $ee_ueip_has_notified; |
|
| 1618 | - |
|
| 1619 | - /** |
|
| 1620 | - * Not to be confused with the 4 critical page variables (See |
|
| 1621 | - * get_critical_pages_array()), this is just an array of wp posts that have EE |
|
| 1622 | - * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode |
|
| 1623 | - * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array. |
|
| 1624 | - * |
|
| 1625 | - * @var array |
|
| 1626 | - */ |
|
| 1627 | - public $post_shortcodes; |
|
| 1628 | - |
|
| 1629 | - public $module_route_map; |
|
| 1630 | - |
|
| 1631 | - public $module_forward_map; |
|
| 1632 | - |
|
| 1633 | - public $module_view_map; |
|
| 1634 | - |
|
| 1635 | - /** |
|
| 1636 | - * The next 4 vars are the IDs of critical EE pages. |
|
| 1637 | - * |
|
| 1638 | - * @var int |
|
| 1639 | - */ |
|
| 1640 | - public $reg_page_id; |
|
| 1641 | - |
|
| 1642 | - public $txn_page_id; |
|
| 1643 | - |
|
| 1644 | - public $thank_you_page_id; |
|
| 1645 | - |
|
| 1646 | - public $cancel_page_id; |
|
| 1647 | - |
|
| 1648 | - /** |
|
| 1649 | - * The next 4 vars are the URLs of critical EE pages. |
|
| 1650 | - * |
|
| 1651 | - * @var int |
|
| 1652 | - */ |
|
| 1653 | - public $reg_page_url; |
|
| 1654 | - |
|
| 1655 | - public $txn_page_url; |
|
| 1656 | - |
|
| 1657 | - public $thank_you_page_url; |
|
| 1658 | - |
|
| 1659 | - public $cancel_page_url; |
|
| 1660 | - |
|
| 1661 | - /** |
|
| 1662 | - * The next vars relate to the custom slugs for EE CPT routes |
|
| 1663 | - */ |
|
| 1664 | - public $event_cpt_slug; |
|
| 1665 | - |
|
| 1666 | - /** |
|
| 1667 | - * This caches the _ee_ueip_option in case this config is reset in the same |
|
| 1668 | - * request across blog switches in a multisite context. |
|
| 1669 | - * Avoids extra queries to the db for this option. |
|
| 1670 | - * |
|
| 1671 | - * @var bool |
|
| 1672 | - */ |
|
| 1673 | - public static $ee_ueip_option; |
|
| 1674 | - |
|
| 1675 | - |
|
| 1676 | - /** |
|
| 1677 | - * class constructor |
|
| 1678 | - * |
|
| 1679 | - * @access public |
|
| 1680 | - */ |
|
| 1681 | - public function __construct() |
|
| 1682 | - { |
|
| 1683 | - // set default organization settings |
|
| 1684 | - $this->current_blog_id = get_current_blog_id(); |
|
| 1685 | - $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id; |
|
| 1686 | - $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin(); |
|
| 1687 | - $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true; |
|
| 1688 | - $this->post_shortcodes = array(); |
|
| 1689 | - $this->module_route_map = array(); |
|
| 1690 | - $this->module_forward_map = array(); |
|
| 1691 | - $this->module_view_map = array(); |
|
| 1692 | - // critical EE page IDs |
|
| 1693 | - $this->reg_page_id = 0; |
|
| 1694 | - $this->txn_page_id = 0; |
|
| 1695 | - $this->thank_you_page_id = 0; |
|
| 1696 | - $this->cancel_page_id = 0; |
|
| 1697 | - // critical EE page URLs |
|
| 1698 | - $this->reg_page_url = ''; |
|
| 1699 | - $this->txn_page_url = ''; |
|
| 1700 | - $this->thank_you_page_url = ''; |
|
| 1701 | - $this->cancel_page_url = ''; |
|
| 1702 | - // cpt slugs |
|
| 1703 | - $this->event_cpt_slug = __('events', 'event_espresso'); |
|
| 1704 | - // ueip constant check |
|
| 1705 | - if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) { |
|
| 1706 | - $this->ee_ueip_optin = false; |
|
| 1707 | - $this->ee_ueip_has_notified = true; |
|
| 1708 | - } |
|
| 1709 | - } |
|
| 1710 | - |
|
| 1711 | - |
|
| 1712 | - /** |
|
| 1713 | - * @return array |
|
| 1714 | - */ |
|
| 1715 | - public function get_critical_pages_array() |
|
| 1716 | - { |
|
| 1717 | - return array( |
|
| 1718 | - $this->reg_page_id, |
|
| 1719 | - $this->txn_page_id, |
|
| 1720 | - $this->thank_you_page_id, |
|
| 1721 | - $this->cancel_page_id, |
|
| 1722 | - ); |
|
| 1723 | - } |
|
| 1724 | - |
|
| 1725 | - |
|
| 1726 | - /** |
|
| 1727 | - * @return array |
|
| 1728 | - */ |
|
| 1729 | - public function get_critical_pages_shortcodes_array() |
|
| 1730 | - { |
|
| 1731 | - return array( |
|
| 1732 | - $this->reg_page_id => 'ESPRESSO_CHECKOUT', |
|
| 1733 | - $this->txn_page_id => 'ESPRESSO_TXN_PAGE', |
|
| 1734 | - $this->thank_you_page_id => 'ESPRESSO_THANK_YOU', |
|
| 1735 | - $this->cancel_page_id => 'ESPRESSO_CANCELLED', |
|
| 1736 | - ); |
|
| 1737 | - } |
|
| 1738 | - |
|
| 1739 | - |
|
| 1740 | - /** |
|
| 1741 | - * gets/returns URL for EE reg_page |
|
| 1742 | - * |
|
| 1743 | - * @access public |
|
| 1744 | - * @return string |
|
| 1745 | - */ |
|
| 1746 | - public function reg_page_url() |
|
| 1747 | - { |
|
| 1748 | - if (! $this->reg_page_url) { |
|
| 1749 | - $this->reg_page_url = add_query_arg( |
|
| 1750 | - array('uts' => time()), |
|
| 1751 | - get_permalink($this->reg_page_id) |
|
| 1752 | - ) . '#checkout'; |
|
| 1753 | - } |
|
| 1754 | - return $this->reg_page_url; |
|
| 1755 | - } |
|
| 1756 | - |
|
| 1757 | - |
|
| 1758 | - /** |
|
| 1759 | - * gets/returns URL for EE txn_page |
|
| 1760 | - * |
|
| 1761 | - * @param array $query_args like what gets passed to |
|
| 1762 | - * add_query_arg() as the first argument |
|
| 1763 | - * @access public |
|
| 1764 | - * @return string |
|
| 1765 | - */ |
|
| 1766 | - public function txn_page_url($query_args = array()) |
|
| 1767 | - { |
|
| 1768 | - if (! $this->txn_page_url) { |
|
| 1769 | - $this->txn_page_url = get_permalink($this->txn_page_id); |
|
| 1770 | - } |
|
| 1771 | - if ($query_args) { |
|
| 1772 | - return add_query_arg($query_args, $this->txn_page_url); |
|
| 1773 | - } else { |
|
| 1774 | - return $this->txn_page_url; |
|
| 1775 | - } |
|
| 1776 | - } |
|
| 1777 | - |
|
| 1778 | - |
|
| 1779 | - /** |
|
| 1780 | - * gets/returns URL for EE thank_you_page |
|
| 1781 | - * |
|
| 1782 | - * @param array $query_args like what gets passed to |
|
| 1783 | - * add_query_arg() as the first argument |
|
| 1784 | - * @access public |
|
| 1785 | - * @return string |
|
| 1786 | - */ |
|
| 1787 | - public function thank_you_page_url($query_args = array()) |
|
| 1788 | - { |
|
| 1789 | - if (! $this->thank_you_page_url) { |
|
| 1790 | - $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
|
| 1791 | - } |
|
| 1792 | - if ($query_args) { |
|
| 1793 | - return add_query_arg($query_args, $this->thank_you_page_url); |
|
| 1794 | - } else { |
|
| 1795 | - return $this->thank_you_page_url; |
|
| 1796 | - } |
|
| 1797 | - } |
|
| 1798 | - |
|
| 1799 | - |
|
| 1800 | - /** |
|
| 1801 | - * gets/returns URL for EE cancel_page |
|
| 1802 | - * |
|
| 1803 | - * @access public |
|
| 1804 | - * @return string |
|
| 1805 | - */ |
|
| 1806 | - public function cancel_page_url() |
|
| 1807 | - { |
|
| 1808 | - if (! $this->cancel_page_url) { |
|
| 1809 | - $this->cancel_page_url = get_permalink($this->cancel_page_id); |
|
| 1810 | - } |
|
| 1811 | - return $this->cancel_page_url; |
|
| 1812 | - } |
|
| 1813 | - |
|
| 1814 | - |
|
| 1815 | - /** |
|
| 1816 | - * Resets all critical page urls to their original state. Used primarily by the __sleep() magic method currently. |
|
| 1817 | - * |
|
| 1818 | - * @since 4.7.5 |
|
| 1819 | - */ |
|
| 1820 | - protected function _reset_urls() |
|
| 1821 | - { |
|
| 1822 | - $this->reg_page_url = ''; |
|
| 1823 | - $this->txn_page_url = ''; |
|
| 1824 | - $this->cancel_page_url = ''; |
|
| 1825 | - $this->thank_you_page_url = ''; |
|
| 1826 | - } |
|
| 1827 | - |
|
| 1828 | - |
|
| 1829 | - /** |
|
| 1830 | - * Used to return what the optin value is set for the EE User Experience Program. |
|
| 1831 | - * This accounts for multisite and this value being requested for a subsite. In multisite, the value is set |
|
| 1832 | - * on the main site only. |
|
| 1833 | - * |
|
| 1834 | - * @return bool |
|
| 1835 | - */ |
|
| 1836 | - protected function _get_main_ee_ueip_optin() |
|
| 1837 | - { |
|
| 1838 | - // if this is the main site then we can just bypass our direct query. |
|
| 1839 | - if (is_main_site()) { |
|
| 1840 | - return get_option(self::OPTION_NAME_UXIP, false); |
|
| 1841 | - } |
|
| 1842 | - // is this already cached for this request? If so use it. |
|
| 1843 | - if (EE_Core_Config::$ee_ueip_option !== null) { |
|
| 1844 | - return EE_Core_Config::$ee_ueip_option; |
|
| 1845 | - } |
|
| 1846 | - global $wpdb; |
|
| 1847 | - $current_network_main_site = is_multisite() ? get_current_site() : null; |
|
| 1848 | - $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
|
| 1849 | - $option = self::OPTION_NAME_UXIP; |
|
| 1850 | - // set correct table for query |
|
| 1851 | - $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options'; |
|
| 1852 | - // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
|
| 1853 | - // get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be |
|
| 1854 | - // re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
|
| 1855 | - // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
|
| 1856 | - // for the purpose of caching. |
|
| 1857 | - $pre = apply_filters('pre_option_' . $option, false, $option); |
|
| 1858 | - if (false !== $pre) { |
|
| 1859 | - EE_Core_Config::$ee_ueip_option = $pre; |
|
| 1860 | - return EE_Core_Config::$ee_ueip_option; |
|
| 1861 | - } |
|
| 1862 | - $row = $wpdb->get_row( |
|
| 1863 | - $wpdb->prepare( |
|
| 1864 | - "SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", |
|
| 1865 | - $option |
|
| 1866 | - ) |
|
| 1867 | - ); |
|
| 1868 | - if (is_object($row)) { |
|
| 1869 | - $value = $row->option_value; |
|
| 1870 | - } else { // option does not exist so use default. |
|
| 1871 | - EE_Core_Config::$ee_ueip_option = apply_filters('default_option_' . $option, false, $option); |
|
| 1872 | - return EE_Core_Config::$ee_ueip_option; |
|
| 1873 | - } |
|
| 1874 | - EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option); |
|
| 1875 | - return EE_Core_Config::$ee_ueip_option; |
|
| 1876 | - } |
|
| 1877 | - |
|
| 1878 | - |
|
| 1879 | - /** |
|
| 1880 | - * Utility function for escaping the value of a property and returning. |
|
| 1881 | - * |
|
| 1882 | - * @param string $property property name (checks to see if exists). |
|
| 1883 | - * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
| 1884 | - * @throws \EE_Error |
|
| 1885 | - */ |
|
| 1886 | - public function get_pretty($property) |
|
| 1887 | - { |
|
| 1888 | - if ($property === self::OPTION_NAME_UXIP) { |
|
| 1889 | - return $this->ee_ueip_optin ? 'yes' : 'no'; |
|
| 1890 | - } |
|
| 1891 | - return parent::get_pretty($property); |
|
| 1892 | - } |
|
| 1893 | - |
|
| 1894 | - |
|
| 1895 | - /** |
|
| 1896 | - * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values |
|
| 1897 | - * on the object. |
|
| 1898 | - * |
|
| 1899 | - * @return array |
|
| 1900 | - */ |
|
| 1901 | - public function __sleep() |
|
| 1902 | - { |
|
| 1903 | - // reset all url properties |
|
| 1904 | - $this->_reset_urls(); |
|
| 1905 | - // return what to save to db |
|
| 1906 | - return array_keys(get_object_vars($this)); |
|
| 1907 | - } |
|
| 1908 | -} |
|
| 1909 | - |
|
| 1910 | -/** |
|
| 1911 | - * Config class for storing info on the Organization |
|
| 1912 | - */ |
|
| 1913 | -class EE_Organization_Config extends EE_Config_Base |
|
| 1914 | -{ |
|
| 1915 | - |
|
| 1916 | - /** |
|
| 1917 | - * @var string $name |
|
| 1918 | - * eg EE4.1 |
|
| 1919 | - */ |
|
| 1920 | - public $name; |
|
| 1921 | - |
|
| 1922 | - /** |
|
| 1923 | - * @var string $address_1 |
|
| 1924 | - * eg 123 Onna Road |
|
| 1925 | - */ |
|
| 1926 | - public $address_1 = ''; |
|
| 1927 | - |
|
| 1928 | - /** |
|
| 1929 | - * @var string $address_2 |
|
| 1930 | - * eg PO Box 123 |
|
| 1931 | - */ |
|
| 1932 | - public $address_2 = ''; |
|
| 1933 | - |
|
| 1934 | - /** |
|
| 1935 | - * @var string $city |
|
| 1936 | - * eg Inna City |
|
| 1937 | - */ |
|
| 1938 | - public $city = ''; |
|
| 1939 | - |
|
| 1940 | - /** |
|
| 1941 | - * @var int $STA_ID |
|
| 1942 | - * eg 4 |
|
| 1943 | - */ |
|
| 1944 | - public $STA_ID = 0; |
|
| 1945 | - |
|
| 1946 | - /** |
|
| 1947 | - * @var string $CNT_ISO |
|
| 1948 | - * eg US |
|
| 1949 | - */ |
|
| 1950 | - public $CNT_ISO = ''; |
|
| 1951 | - |
|
| 1952 | - /** |
|
| 1953 | - * @var string $zip |
|
| 1954 | - * eg 12345 or V1A 2B3 |
|
| 1955 | - */ |
|
| 1956 | - public $zip = ''; |
|
| 1957 | - |
|
| 1958 | - /** |
|
| 1959 | - * @var string $email |
|
| 1960 | - * eg [email protected] |
|
| 1961 | - */ |
|
| 1962 | - public $email; |
|
| 1963 | - |
|
| 1964 | - /** |
|
| 1965 | - * @var string $phone |
|
| 1966 | - * eg. 111-111-1111 |
|
| 1967 | - */ |
|
| 1968 | - public $phone = ''; |
|
| 1969 | - |
|
| 1970 | - /** |
|
| 1971 | - * @var string $vat |
|
| 1972 | - * VAT/Tax Number |
|
| 1973 | - */ |
|
| 1974 | - public $vat = ''; |
|
| 1975 | - |
|
| 1976 | - /** |
|
| 1977 | - * @var string $logo_url |
|
| 1978 | - * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg |
|
| 1979 | - */ |
|
| 1980 | - public $logo_url = ''; |
|
| 1981 | - |
|
| 1982 | - /** |
|
| 1983 | - * The below are all various properties for holding links to organization social network profiles |
|
| 1984 | - * |
|
| 1985 | - * @var string |
|
| 1986 | - */ |
|
| 1987 | - /** |
|
| 1988 | - * facebook (facebook.com/profile.name) |
|
| 1989 | - * |
|
| 1990 | - * @var string |
|
| 1991 | - */ |
|
| 1992 | - public $facebook = ''; |
|
| 1993 | - |
|
| 1994 | - /** |
|
| 1995 | - * twitter (twitter.com/twitter_handle) |
|
| 1996 | - * |
|
| 1997 | - * @var string |
|
| 1998 | - */ |
|
| 1999 | - public $twitter = ''; |
|
| 2000 | - |
|
| 2001 | - /** |
|
| 2002 | - * linkedin (linkedin.com/in/profile_name) |
|
| 2003 | - * |
|
| 2004 | - * @var string |
|
| 2005 | - */ |
|
| 2006 | - public $linkedin = ''; |
|
| 2007 | - |
|
| 2008 | - /** |
|
| 2009 | - * pinterest (www.pinterest.com/profile_name) |
|
| 2010 | - * |
|
| 2011 | - * @var string |
|
| 2012 | - */ |
|
| 2013 | - public $pinterest = ''; |
|
| 2014 | - |
|
| 2015 | - /** |
|
| 2016 | - * google+ (google.com/+profileName) |
|
| 2017 | - * |
|
| 2018 | - * @var string |
|
| 2019 | - */ |
|
| 2020 | - public $google = ''; |
|
| 2021 | - |
|
| 2022 | - /** |
|
| 2023 | - * instagram (instagram.com/handle) |
|
| 2024 | - * |
|
| 2025 | - * @var string |
|
| 2026 | - */ |
|
| 2027 | - public $instagram = ''; |
|
| 2028 | - |
|
| 2029 | - |
|
| 2030 | - /** |
|
| 2031 | - * class constructor |
|
| 2032 | - * |
|
| 2033 | - * @access public |
|
| 2034 | - */ |
|
| 2035 | - public function __construct() |
|
| 2036 | - { |
|
| 2037 | - // set default organization settings |
|
| 2038 | - // decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded |
|
| 2039 | - $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); |
|
| 2040 | - $this->email = get_bloginfo('admin_email'); |
|
| 2041 | - } |
|
| 2042 | -} |
|
| 2043 | - |
|
| 2044 | -/** |
|
| 2045 | - * Class for defining what's in the EE_Config relating to currency |
|
| 2046 | - */ |
|
| 2047 | -class EE_Currency_Config extends EE_Config_Base |
|
| 2048 | -{ |
|
| 2049 | - |
|
| 2050 | - /** |
|
| 2051 | - * @var string $code |
|
| 2052 | - * eg 'US' |
|
| 2053 | - */ |
|
| 2054 | - public $code; |
|
| 2055 | - |
|
| 2056 | - /** |
|
| 2057 | - * @var string $name |
|
| 2058 | - * eg 'Dollar' |
|
| 2059 | - */ |
|
| 2060 | - public $name; |
|
| 2061 | - |
|
| 2062 | - /** |
|
| 2063 | - * plural name |
|
| 2064 | - * |
|
| 2065 | - * @var string $plural |
|
| 2066 | - * eg 'Dollars' |
|
| 2067 | - */ |
|
| 2068 | - public $plural; |
|
| 2069 | - |
|
| 2070 | - /** |
|
| 2071 | - * currency sign |
|
| 2072 | - * |
|
| 2073 | - * @var string $sign |
|
| 2074 | - * eg '$' |
|
| 2075 | - */ |
|
| 2076 | - public $sign; |
|
| 2077 | - |
|
| 2078 | - /** |
|
| 2079 | - * Whether the currency sign should come before the number or not |
|
| 2080 | - * |
|
| 2081 | - * @var boolean $sign_b4 |
|
| 2082 | - */ |
|
| 2083 | - public $sign_b4; |
|
| 2084 | - |
|
| 2085 | - /** |
|
| 2086 | - * How many digits should come after the decimal place |
|
| 2087 | - * |
|
| 2088 | - * @var int $dec_plc |
|
| 2089 | - */ |
|
| 2090 | - public $dec_plc; |
|
| 2091 | - |
|
| 2092 | - /** |
|
| 2093 | - * Symbol to use for decimal mark |
|
| 2094 | - * |
|
| 2095 | - * @var string $dec_mrk |
|
| 2096 | - * eg '.' |
|
| 2097 | - */ |
|
| 2098 | - public $dec_mrk; |
|
| 2099 | - |
|
| 2100 | - /** |
|
| 2101 | - * Symbol to use for thousands |
|
| 2102 | - * |
|
| 2103 | - * @var string $thsnds |
|
| 2104 | - * eg ',' |
|
| 2105 | - */ |
|
| 2106 | - public $thsnds; |
|
| 2107 | - |
|
| 2108 | - |
|
| 2109 | - /** |
|
| 2110 | - * class constructor |
|
| 2111 | - * |
|
| 2112 | - * @access public |
|
| 2113 | - * @param string $CNT_ISO |
|
| 2114 | - * @throws \EE_Error |
|
| 2115 | - */ |
|
| 2116 | - public function __construct($CNT_ISO = '') |
|
| 2117 | - { |
|
| 2118 | - /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */ |
|
| 2119 | - $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
| 2120 | - // get country code from organization settings or use default |
|
| 2121 | - $ORG_CNT = isset(EE_Registry::instance()->CFG->organization) |
|
| 2122 | - && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config |
|
| 2123 | - ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
| 2124 | - : ''; |
|
| 2125 | - // but override if requested |
|
| 2126 | - $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
|
| 2127 | - // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
|
| 2128 | - if (! empty($CNT_ISO) |
|
| 2129 | - && EE_Maintenance_Mode::instance()->models_can_query() |
|
| 2130 | - && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table()) |
|
| 2131 | - ) { |
|
| 2132 | - // retrieve the country settings from the db, just in case they have been customized |
|
| 2133 | - $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
|
| 2134 | - if ($country instanceof EE_Country) { |
|
| 2135 | - $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
| 2136 | - $this->name = $country->currency_name_single(); // Dollar |
|
| 2137 | - $this->plural = $country->currency_name_plural(); // Dollars |
|
| 2138 | - $this->sign = $country->currency_sign(); // currency sign: $ |
|
| 2139 | - $this->sign_b4 = $country->currency_sign_before( |
|
| 2140 | - ); // currency sign before or after: $TRUE or FALSE$ |
|
| 2141 | - $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
| 2142 | - $this->dec_mrk = $country->currency_decimal_mark( |
|
| 2143 | - ); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 2144 | - $this->thsnds = $country->currency_thousands_separator( |
|
| 2145 | - ); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 2146 | - } |
|
| 2147 | - } |
|
| 2148 | - // fallback to hardcoded defaults, in case the above failed |
|
| 2149 | - if (empty($this->code)) { |
|
| 2150 | - // set default currency settings |
|
| 2151 | - $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
| 2152 | - $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
| 2153 | - $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
| 2154 | - $this->sign = '$'; // currency sign: $ |
|
| 2155 | - $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
| 2156 | - $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
| 2157 | - $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 2158 | - $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 2159 | - } |
|
| 2160 | - } |
|
| 2161 | -} |
|
| 2162 | - |
|
| 2163 | -/** |
|
| 2164 | - * Class for defining what's in the EE_Config relating to registration settings |
|
| 2165 | - */ |
|
| 2166 | -class EE_Registration_Config extends EE_Config_Base |
|
| 2167 | -{ |
|
| 2168 | - |
|
| 2169 | - /** |
|
| 2170 | - * Default registration status |
|
| 2171 | - * |
|
| 2172 | - * @var string $default_STS_ID |
|
| 2173 | - * eg 'RPP' |
|
| 2174 | - */ |
|
| 2175 | - public $default_STS_ID; |
|
| 2176 | - |
|
| 2177 | - /** |
|
| 2178 | - * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of |
|
| 2179 | - * registrations) |
|
| 2180 | - * |
|
| 2181 | - * @var int |
|
| 2182 | - */ |
|
| 2183 | - public $default_maximum_number_of_tickets; |
|
| 2184 | - |
|
| 2185 | - /** |
|
| 2186 | - * level of validation to apply to email addresses |
|
| 2187 | - * |
|
| 2188 | - * @var string $email_validation_level |
|
| 2189 | - * options: 'basic', 'wp_default', 'i18n', 'i18n_dns' |
|
| 2190 | - */ |
|
| 2191 | - public $email_validation_level; |
|
| 2192 | - |
|
| 2193 | - /** |
|
| 2194 | - * whether or not to show alternate payment options during the reg process if payment status is pending |
|
| 2195 | - * |
|
| 2196 | - * @var boolean $show_pending_payment_options |
|
| 2197 | - */ |
|
| 2198 | - public $show_pending_payment_options; |
|
| 2199 | - |
|
| 2200 | - /** |
|
| 2201 | - * Whether to skip the registration confirmation page |
|
| 2202 | - * |
|
| 2203 | - * @var boolean $skip_reg_confirmation |
|
| 2204 | - */ |
|
| 2205 | - public $skip_reg_confirmation; |
|
| 2206 | - |
|
| 2207 | - /** |
|
| 2208 | - * an array of SPCO reg steps where: |
|
| 2209 | - * the keys denotes the reg step order |
|
| 2210 | - * each element consists of an array with the following elements: |
|
| 2211 | - * "file_path" => the file path to the EE_SPCO_Reg_Step class |
|
| 2212 | - * "class_name" => the specific EE_SPCO_Reg_Step child class name |
|
| 2213 | - * "slug" => the URL param used to trigger the reg step |
|
| 2214 | - * |
|
| 2215 | - * @var array $reg_steps |
|
| 2216 | - */ |
|
| 2217 | - public $reg_steps; |
|
| 2218 | - |
|
| 2219 | - /** |
|
| 2220 | - * Whether registration confirmation should be the last page of SPCO |
|
| 2221 | - * |
|
| 2222 | - * @var boolean $reg_confirmation_last |
|
| 2223 | - */ |
|
| 2224 | - public $reg_confirmation_last; |
|
| 2225 | - |
|
| 2226 | - /** |
|
| 2227 | - * Whether or not to enable the EE Bot Trap |
|
| 2228 | - * |
|
| 2229 | - * @var boolean $use_bot_trap |
|
| 2230 | - */ |
|
| 2231 | - public $use_bot_trap; |
|
| 2232 | - |
|
| 2233 | - /** |
|
| 2234 | - * Whether or not to encrypt some data sent by the EE Bot Trap |
|
| 2235 | - * |
|
| 2236 | - * @var boolean $use_encryption |
|
| 2237 | - */ |
|
| 2238 | - public $use_encryption; |
|
| 2239 | - |
|
| 2240 | - /** |
|
| 2241 | - * Whether or not to use ReCaptcha |
|
| 2242 | - * |
|
| 2243 | - * @var boolean $use_captcha |
|
| 2244 | - */ |
|
| 2245 | - public $use_captcha; |
|
| 2246 | - |
|
| 2247 | - /** |
|
| 2248 | - * ReCaptcha Theme |
|
| 2249 | - * |
|
| 2250 | - * @var string $recaptcha_theme |
|
| 2251 | - * options: 'dark', 'light', 'invisible' |
|
| 2252 | - */ |
|
| 2253 | - public $recaptcha_theme; |
|
| 2254 | - |
|
| 2255 | - /** |
|
| 2256 | - * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha. |
|
| 2257 | - * |
|
| 2258 | - * @var string $recaptcha_badge |
|
| 2259 | - * options: 'bottomright', 'bottomleft', 'inline' |
|
| 2260 | - */ |
|
| 2261 | - public $recaptcha_badge; |
|
| 17 | + const OPTION_NAME = 'ee_config'; |
|
| 18 | + |
|
| 19 | + const LOG_NAME = 'ee_config_log'; |
|
| 20 | + |
|
| 21 | + const LOG_LENGTH = 100; |
|
| 22 | + |
|
| 23 | + const ADDON_OPTION_NAMES = 'ee_config_option_names'; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * instance of the EE_Config object |
|
| 27 | + * |
|
| 28 | + * @var EE_Config $_instance |
|
| 29 | + * @access private |
|
| 30 | + */ |
|
| 31 | + private static $_instance; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @var boolean $_logging_enabled |
|
| 35 | + */ |
|
| 36 | + private static $_logging_enabled = false; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
| 40 | + */ |
|
| 41 | + private $legacy_shortcodes_manager; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * An StdClass whose property names are addon slugs, |
|
| 45 | + * and values are their config classes |
|
| 46 | + * |
|
| 47 | + * @var StdClass |
|
| 48 | + */ |
|
| 49 | + public $addons; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * @var EE_Admin_Config |
|
| 53 | + */ |
|
| 54 | + public $admin; |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * @var EE_Core_Config |
|
| 58 | + */ |
|
| 59 | + public $core; |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * @var EE_Currency_Config |
|
| 63 | + */ |
|
| 64 | + public $currency; |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * @var EE_Organization_Config |
|
| 68 | + */ |
|
| 69 | + public $organization; |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @var EE_Registration_Config |
|
| 73 | + */ |
|
| 74 | + public $registration; |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @var EE_Template_Config |
|
| 78 | + */ |
|
| 79 | + public $template_settings; |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * Holds EE environment values. |
|
| 83 | + * |
|
| 84 | + * @var EE_Environment_Config |
|
| 85 | + */ |
|
| 86 | + public $environment; |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * settings pertaining to Google maps |
|
| 90 | + * |
|
| 91 | + * @var EE_Map_Config |
|
| 92 | + */ |
|
| 93 | + public $map_settings; |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * settings pertaining to Taxes |
|
| 97 | + * |
|
| 98 | + * @var EE_Tax_Config |
|
| 99 | + */ |
|
| 100 | + public $tax_settings; |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * Settings pertaining to global messages settings. |
|
| 104 | + * |
|
| 105 | + * @var EE_Messages_Config |
|
| 106 | + */ |
|
| 107 | + public $messages; |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * @deprecated |
|
| 111 | + * @var EE_Gateway_Config |
|
| 112 | + */ |
|
| 113 | + public $gateway; |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * @var array $_addon_option_names |
|
| 117 | + * @access private |
|
| 118 | + */ |
|
| 119 | + private $_addon_option_names = array(); |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * @var array $_module_route_map |
|
| 123 | + * @access private |
|
| 124 | + */ |
|
| 125 | + private static $_module_route_map = array(); |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * @var array $_module_forward_map |
|
| 129 | + * @access private |
|
| 130 | + */ |
|
| 131 | + private static $_module_forward_map = array(); |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * @var array $_module_view_map |
|
| 135 | + * @access private |
|
| 136 | + */ |
|
| 137 | + private static $_module_view_map = array(); |
|
| 138 | + |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * @singleton method used to instantiate class object |
|
| 142 | + * @access public |
|
| 143 | + * @return EE_Config instance |
|
| 144 | + */ |
|
| 145 | + public static function instance() |
|
| 146 | + { |
|
| 147 | + // check if class object is instantiated, and instantiated properly |
|
| 148 | + if (! self::$_instance instanceof EE_Config) { |
|
| 149 | + self::$_instance = new self(); |
|
| 150 | + } |
|
| 151 | + return self::$_instance; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Resets the config |
|
| 157 | + * |
|
| 158 | + * @param bool $hard_reset if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE |
|
| 159 | + * (default) leaves the database alone, and merely resets the EE_Config object to |
|
| 160 | + * reflect its state in the database |
|
| 161 | + * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave |
|
| 162 | + * $_instance as NULL. Useful in case you want to forget about the old instance on |
|
| 163 | + * EE_Config, but might not be ready to instantiate EE_Config currently (eg if the |
|
| 164 | + * site was put into maintenance mode) |
|
| 165 | + * @return EE_Config |
|
| 166 | + */ |
|
| 167 | + public static function reset($hard_reset = false, $reinstantiate = true) |
|
| 168 | + { |
|
| 169 | + if (self::$_instance instanceof EE_Config) { |
|
| 170 | + if ($hard_reset) { |
|
| 171 | + self::$_instance->legacy_shortcodes_manager = null; |
|
| 172 | + self::$_instance->_addon_option_names = array(); |
|
| 173 | + self::$_instance->_initialize_config(); |
|
| 174 | + self::$_instance->update_espresso_config(); |
|
| 175 | + } |
|
| 176 | + self::$_instance->update_addon_option_names(); |
|
| 177 | + } |
|
| 178 | + self::$_instance = null; |
|
| 179 | + // we don't need to reset the static properties imo because those should |
|
| 180 | + // only change when a module is added or removed. Currently we don't |
|
| 181 | + // support removing a module during a request when it previously existed |
|
| 182 | + if ($reinstantiate) { |
|
| 183 | + return self::instance(); |
|
| 184 | + } else { |
|
| 185 | + return null; |
|
| 186 | + } |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * class constructor |
|
| 192 | + * |
|
| 193 | + * @access private |
|
| 194 | + */ |
|
| 195 | + private function __construct() |
|
| 196 | + { |
|
| 197 | + do_action('AHEE__EE_Config__construct__begin', $this); |
|
| 198 | + EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false); |
|
| 199 | + // setup empty config classes |
|
| 200 | + $this->_initialize_config(); |
|
| 201 | + // load existing EE site settings |
|
| 202 | + $this->_load_core_config(); |
|
| 203 | + // confirm everything loaded correctly and set filtered defaults if not |
|
| 204 | + $this->_verify_config(); |
|
| 205 | + // register shortcodes and modules |
|
| 206 | + add_action( |
|
| 207 | + 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
| 208 | + array($this, 'register_shortcodes_and_modules'), |
|
| 209 | + 999 |
|
| 210 | + ); |
|
| 211 | + // initialize shortcodes and modules |
|
| 212 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules')); |
|
| 213 | + // register widgets |
|
| 214 | + add_action('widgets_init', array($this, 'widgets_init'), 10); |
|
| 215 | + // shutdown |
|
| 216 | + add_action('shutdown', array($this, 'shutdown'), 10); |
|
| 217 | + // construct__end hook |
|
| 218 | + do_action('AHEE__EE_Config__construct__end', $this); |
|
| 219 | + // hardcoded hack |
|
| 220 | + $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * @return boolean |
|
| 226 | + */ |
|
| 227 | + public static function logging_enabled() |
|
| 228 | + { |
|
| 229 | + return self::$_logging_enabled; |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + |
|
| 233 | + /** |
|
| 234 | + * use to get the current theme if needed from static context |
|
| 235 | + * |
|
| 236 | + * @return string current theme set. |
|
| 237 | + */ |
|
| 238 | + public static function get_current_theme() |
|
| 239 | + { |
|
| 240 | + return isset(self::$_instance->template_settings->current_espresso_theme) |
|
| 241 | + ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
| 242 | + } |
|
| 243 | + |
|
| 244 | + |
|
| 245 | + /** |
|
| 246 | + * _initialize_config |
|
| 247 | + * |
|
| 248 | + * @access private |
|
| 249 | + * @return void |
|
| 250 | + */ |
|
| 251 | + private function _initialize_config() |
|
| 252 | + { |
|
| 253 | + EE_Config::trim_log(); |
|
| 254 | + // set defaults |
|
| 255 | + $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array()); |
|
| 256 | + $this->addons = new stdClass(); |
|
| 257 | + // set _module_route_map |
|
| 258 | + EE_Config::$_module_route_map = array(); |
|
| 259 | + // set _module_forward_map |
|
| 260 | + EE_Config::$_module_forward_map = array(); |
|
| 261 | + // set _module_view_map |
|
| 262 | + EE_Config::$_module_view_map = array(); |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + |
|
| 266 | + /** |
|
| 267 | + * load core plugin configuration |
|
| 268 | + * |
|
| 269 | + * @access private |
|
| 270 | + * @return void |
|
| 271 | + */ |
|
| 272 | + private function _load_core_config() |
|
| 273 | + { |
|
| 274 | + // load_core_config__start hook |
|
| 275 | + do_action('AHEE__EE_Config___load_core_config__start', $this); |
|
| 276 | + $espresso_config = $this->get_espresso_config(); |
|
| 277 | + foreach ($espresso_config as $config => $settings) { |
|
| 278 | + // load_core_config__start hook |
|
| 279 | + $settings = apply_filters( |
|
| 280 | + 'FHEE__EE_Config___load_core_config__config_settings', |
|
| 281 | + $settings, |
|
| 282 | + $config, |
|
| 283 | + $this |
|
| 284 | + ); |
|
| 285 | + if (is_object($settings) && property_exists($this, $config)) { |
|
| 286 | + $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings); |
|
| 287 | + // call configs populate method to ensure any defaults are set for empty values. |
|
| 288 | + if (method_exists($settings, 'populate')) { |
|
| 289 | + $this->{$config}->populate(); |
|
| 290 | + } |
|
| 291 | + if (method_exists($settings, 'do_hooks')) { |
|
| 292 | + $this->{$config}->do_hooks(); |
|
| 293 | + } |
|
| 294 | + } |
|
| 295 | + } |
|
| 296 | + if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) { |
|
| 297 | + $this->update_espresso_config(); |
|
| 298 | + } |
|
| 299 | + // load_core_config__end hook |
|
| 300 | + do_action('AHEE__EE_Config___load_core_config__end', $this); |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + |
|
| 304 | + /** |
|
| 305 | + * _verify_config |
|
| 306 | + * |
|
| 307 | + * @access protected |
|
| 308 | + * @return void |
|
| 309 | + */ |
|
| 310 | + protected function _verify_config() |
|
| 311 | + { |
|
| 312 | + $this->core = $this->core instanceof EE_Core_Config |
|
| 313 | + ? $this->core |
|
| 314 | + : new EE_Core_Config(); |
|
| 315 | + $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core); |
|
| 316 | + $this->organization = $this->organization instanceof EE_Organization_Config |
|
| 317 | + ? $this->organization |
|
| 318 | + : new EE_Organization_Config(); |
|
| 319 | + $this->organization = apply_filters( |
|
| 320 | + 'FHEE__EE_Config___initialize_config__organization', |
|
| 321 | + $this->organization |
|
| 322 | + ); |
|
| 323 | + $this->currency = $this->currency instanceof EE_Currency_Config |
|
| 324 | + ? $this->currency |
|
| 325 | + : new EE_Currency_Config(); |
|
| 326 | + $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency); |
|
| 327 | + $this->registration = $this->registration instanceof EE_Registration_Config |
|
| 328 | + ? $this->registration |
|
| 329 | + : new EE_Registration_Config(); |
|
| 330 | + $this->registration = apply_filters( |
|
| 331 | + 'FHEE__EE_Config___initialize_config__registration', |
|
| 332 | + $this->registration |
|
| 333 | + ); |
|
| 334 | + $this->admin = $this->admin instanceof EE_Admin_Config |
|
| 335 | + ? $this->admin |
|
| 336 | + : new EE_Admin_Config(); |
|
| 337 | + $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin); |
|
| 338 | + $this->template_settings = $this->template_settings instanceof EE_Template_Config |
|
| 339 | + ? $this->template_settings |
|
| 340 | + : new EE_Template_Config(); |
|
| 341 | + $this->template_settings = apply_filters( |
|
| 342 | + 'FHEE__EE_Config___initialize_config__template_settings', |
|
| 343 | + $this->template_settings |
|
| 344 | + ); |
|
| 345 | + $this->map_settings = $this->map_settings instanceof EE_Map_Config |
|
| 346 | + ? $this->map_settings |
|
| 347 | + : new EE_Map_Config(); |
|
| 348 | + $this->map_settings = apply_filters( |
|
| 349 | + 'FHEE__EE_Config___initialize_config__map_settings', |
|
| 350 | + $this->map_settings |
|
| 351 | + ); |
|
| 352 | + $this->environment = $this->environment instanceof EE_Environment_Config |
|
| 353 | + ? $this->environment |
|
| 354 | + : new EE_Environment_Config(); |
|
| 355 | + $this->environment = apply_filters( |
|
| 356 | + 'FHEE__EE_Config___initialize_config__environment', |
|
| 357 | + $this->environment |
|
| 358 | + ); |
|
| 359 | + $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config |
|
| 360 | + ? $this->tax_settings |
|
| 361 | + : new EE_Tax_Config(); |
|
| 362 | + $this->tax_settings = apply_filters( |
|
| 363 | + 'FHEE__EE_Config___initialize_config__tax_settings', |
|
| 364 | + $this->tax_settings |
|
| 365 | + ); |
|
| 366 | + $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages); |
|
| 367 | + $this->messages = $this->messages instanceof EE_Messages_Config |
|
| 368 | + ? $this->messages |
|
| 369 | + : new EE_Messages_Config(); |
|
| 370 | + $this->gateway = $this->gateway instanceof EE_Gateway_Config |
|
| 371 | + ? $this->gateway |
|
| 372 | + : new EE_Gateway_Config(); |
|
| 373 | + $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway); |
|
| 374 | + $this->legacy_shortcodes_manager = null; |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + |
|
| 378 | + /** |
|
| 379 | + * get_espresso_config |
|
| 380 | + * |
|
| 381 | + * @access public |
|
| 382 | + * @return array of espresso config stuff |
|
| 383 | + */ |
|
| 384 | + public function get_espresso_config() |
|
| 385 | + { |
|
| 386 | + // grab espresso configuration |
|
| 387 | + return apply_filters( |
|
| 388 | + 'FHEE__EE_Config__get_espresso_config__CFG', |
|
| 389 | + get_option(EE_Config::OPTION_NAME, array()) |
|
| 390 | + ); |
|
| 391 | + } |
|
| 392 | + |
|
| 393 | + |
|
| 394 | + /** |
|
| 395 | + * double_check_config_comparison |
|
| 396 | + * |
|
| 397 | + * @access public |
|
| 398 | + * @param string $option |
|
| 399 | + * @param $old_value |
|
| 400 | + * @param $value |
|
| 401 | + */ |
|
| 402 | + public function double_check_config_comparison($option = '', $old_value, $value) |
|
| 403 | + { |
|
| 404 | + // make sure we're checking the ee config |
|
| 405 | + if ($option === EE_Config::OPTION_NAME) { |
|
| 406 | + // run a loose comparison of the old value against the new value for type and properties, |
|
| 407 | + // but NOT exact instance like WP update_option does (ie: NOT type safe comparison) |
|
| 408 | + if ($value != $old_value) { |
|
| 409 | + // if they are NOT the same, then remove the hook, |
|
| 410 | + // which means the subsequent update results will be based solely on the update query results |
|
| 411 | + // the reason we do this is because, as stated above, |
|
| 412 | + // WP update_option performs an exact instance comparison (===) on any update values passed to it |
|
| 413 | + // this happens PRIOR to serialization and any subsequent update. |
|
| 414 | + // If values are found to match their previous old value, |
|
| 415 | + // then WP bails before performing any update. |
|
| 416 | + // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version |
|
| 417 | + // it just pulled from the db, with the one being passed to it (which will not match). |
|
| 418 | + // HOWEVER, once the object is serialized and passed off to MySQL to update, |
|
| 419 | + // MySQL MAY ALSO NOT perform the update because |
|
| 420 | + // the string it sees in the db looks the same as the new one it has been passed!!! |
|
| 421 | + // This results in the query returning an "affected rows" value of ZERO, |
|
| 422 | + // which gets returned immediately by WP update_option and looks like an error. |
|
| 423 | + remove_action('update_option', array($this, 'check_config_updated')); |
|
| 424 | + } |
|
| 425 | + } |
|
| 426 | + } |
|
| 427 | + |
|
| 428 | + |
|
| 429 | + /** |
|
| 430 | + * update_espresso_config |
|
| 431 | + * |
|
| 432 | + * @access public |
|
| 433 | + */ |
|
| 434 | + protected function _reset_espresso_addon_config() |
|
| 435 | + { |
|
| 436 | + $this->_addon_option_names = array(); |
|
| 437 | + foreach ($this->addons as $addon_name => $addon_config_obj) { |
|
| 438 | + $addon_config_obj = maybe_unserialize($addon_config_obj); |
|
| 439 | + if ($addon_config_obj instanceof EE_Config_Base) { |
|
| 440 | + $this->update_config('addons', $addon_name, $addon_config_obj, false); |
|
| 441 | + } |
|
| 442 | + $this->addons->{$addon_name} = null; |
|
| 443 | + } |
|
| 444 | + } |
|
| 445 | + |
|
| 446 | + |
|
| 447 | + /** |
|
| 448 | + * update_espresso_config |
|
| 449 | + * |
|
| 450 | + * @access public |
|
| 451 | + * @param bool $add_success |
|
| 452 | + * @param bool $add_error |
|
| 453 | + * @return bool |
|
| 454 | + */ |
|
| 455 | + public function update_espresso_config($add_success = false, $add_error = true) |
|
| 456 | + { |
|
| 457 | + // don't allow config updates during WP heartbeats |
|
| 458 | + if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
| 459 | + return false; |
|
| 460 | + } |
|
| 461 | + // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
|
| 462 | + // $clone = clone( self::$_instance ); |
|
| 463 | + // self::$_instance = NULL; |
|
| 464 | + do_action('AHEE__EE_Config__update_espresso_config__begin', $this); |
|
| 465 | + $this->_reset_espresso_addon_config(); |
|
| 466 | + // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
|
| 467 | + // but BEFORE the actual update occurs |
|
| 468 | + add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3); |
|
| 469 | + // don't want to persist legacy_shortcodes_manager, but don't want to lose it either |
|
| 470 | + $legacy_shortcodes_manager = $this->legacy_shortcodes_manager; |
|
| 471 | + $this->legacy_shortcodes_manager = null; |
|
| 472 | + // now update "ee_config" |
|
| 473 | + $saved = update_option(EE_Config::OPTION_NAME, $this); |
|
| 474 | + $this->legacy_shortcodes_manager = $legacy_shortcodes_manager; |
|
| 475 | + EE_Config::log(EE_Config::OPTION_NAME); |
|
| 476 | + // if not saved... check if the hook we just added still exists; |
|
| 477 | + // if it does, it means one of two things: |
|
| 478 | + // that update_option bailed at the($value === $old_value) conditional, |
|
| 479 | + // or... |
|
| 480 | + // the db update query returned 0 rows affected |
|
| 481 | + // (probably because the data value was the same from it's perspective) |
|
| 482 | + // so the existence of the hook means that a negative result from update_option is NOT an error, |
|
| 483 | + // but just means no update occurred, so don't display an error to the user. |
|
| 484 | + // BUT... if update_option returns FALSE, AND the hook is missing, |
|
| 485 | + // then it means that something truly went wrong |
|
| 486 | + $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved; |
|
| 487 | + // remove our action since we don't want it in the system anymore |
|
| 488 | + remove_action('update_option', array($this, 'double_check_config_comparison'), 1); |
|
| 489 | + do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved); |
|
| 490 | + // self::$_instance = $clone; |
|
| 491 | + // unset( $clone ); |
|
| 492 | + // if config remains the same or was updated successfully |
|
| 493 | + if ($saved) { |
|
| 494 | + if ($add_success) { |
|
| 495 | + EE_Error::add_success( |
|
| 496 | + __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), |
|
| 497 | + __FILE__, |
|
| 498 | + __FUNCTION__, |
|
| 499 | + __LINE__ |
|
| 500 | + ); |
|
| 501 | + } |
|
| 502 | + return true; |
|
| 503 | + } else { |
|
| 504 | + if ($add_error) { |
|
| 505 | + EE_Error::add_error( |
|
| 506 | + __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), |
|
| 507 | + __FILE__, |
|
| 508 | + __FUNCTION__, |
|
| 509 | + __LINE__ |
|
| 510 | + ); |
|
| 511 | + } |
|
| 512 | + return false; |
|
| 513 | + } |
|
| 514 | + } |
|
| 515 | + |
|
| 516 | + |
|
| 517 | + /** |
|
| 518 | + * _verify_config_params |
|
| 519 | + * |
|
| 520 | + * @access private |
|
| 521 | + * @param string $section |
|
| 522 | + * @param string $name |
|
| 523 | + * @param string $config_class |
|
| 524 | + * @param EE_Config_Base $config_obj |
|
| 525 | + * @param array $tests_to_run |
|
| 526 | + * @param bool $display_errors |
|
| 527 | + * @return bool TRUE on success, FALSE on fail |
|
| 528 | + */ |
|
| 529 | + private function _verify_config_params( |
|
| 530 | + $section = '', |
|
| 531 | + $name = '', |
|
| 532 | + $config_class = '', |
|
| 533 | + $config_obj = null, |
|
| 534 | + $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8), |
|
| 535 | + $display_errors = true |
|
| 536 | + ) { |
|
| 537 | + try { |
|
| 538 | + foreach ($tests_to_run as $test) { |
|
| 539 | + switch ($test) { |
|
| 540 | + // TEST #1 : check that section was set |
|
| 541 | + case 1: |
|
| 542 | + if (empty($section)) { |
|
| 543 | + if ($display_errors) { |
|
| 544 | + throw new EE_Error( |
|
| 545 | + sprintf( |
|
| 546 | + __( |
|
| 547 | + 'No configuration section has been provided while attempting to save "%s".', |
|
| 548 | + 'event_espresso' |
|
| 549 | + ), |
|
| 550 | + $config_class |
|
| 551 | + ) |
|
| 552 | + ); |
|
| 553 | + } |
|
| 554 | + return false; |
|
| 555 | + } |
|
| 556 | + break; |
|
| 557 | + // TEST #2 : check that settings section exists |
|
| 558 | + case 2: |
|
| 559 | + if (! isset($this->{$section})) { |
|
| 560 | + if ($display_errors) { |
|
| 561 | + throw new EE_Error( |
|
| 562 | + sprintf( |
|
| 563 | + __('The "%s" configuration section does not exist.', 'event_espresso'), |
|
| 564 | + $section |
|
| 565 | + ) |
|
| 566 | + ); |
|
| 567 | + } |
|
| 568 | + return false; |
|
| 569 | + } |
|
| 570 | + break; |
|
| 571 | + // TEST #3 : check that section is the proper format |
|
| 572 | + case 3: |
|
| 573 | + if (! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
| 574 | + ) { |
|
| 575 | + if ($display_errors) { |
|
| 576 | + throw new EE_Error( |
|
| 577 | + sprintf( |
|
| 578 | + __( |
|
| 579 | + 'The "%s" configuration settings have not been formatted correctly.', |
|
| 580 | + 'event_espresso' |
|
| 581 | + ), |
|
| 582 | + $section |
|
| 583 | + ) |
|
| 584 | + ); |
|
| 585 | + } |
|
| 586 | + return false; |
|
| 587 | + } |
|
| 588 | + break; |
|
| 589 | + // TEST #4 : check that config section name has been set |
|
| 590 | + case 4: |
|
| 591 | + if (empty($name)) { |
|
| 592 | + if ($display_errors) { |
|
| 593 | + throw new EE_Error( |
|
| 594 | + __( |
|
| 595 | + 'No name has been provided for the specific configuration section.', |
|
| 596 | + 'event_espresso' |
|
| 597 | + ) |
|
| 598 | + ); |
|
| 599 | + } |
|
| 600 | + return false; |
|
| 601 | + } |
|
| 602 | + break; |
|
| 603 | + // TEST #5 : check that a config class name has been set |
|
| 604 | + case 5: |
|
| 605 | + if (empty($config_class)) { |
|
| 606 | + if ($display_errors) { |
|
| 607 | + throw new EE_Error( |
|
| 608 | + __( |
|
| 609 | + 'No class name has been provided for the specific configuration section.', |
|
| 610 | + 'event_espresso' |
|
| 611 | + ) |
|
| 612 | + ); |
|
| 613 | + } |
|
| 614 | + return false; |
|
| 615 | + } |
|
| 616 | + break; |
|
| 617 | + // TEST #6 : verify config class is accessible |
|
| 618 | + case 6: |
|
| 619 | + if (! class_exists($config_class)) { |
|
| 620 | + if ($display_errors) { |
|
| 621 | + throw new EE_Error( |
|
| 622 | + sprintf( |
|
| 623 | + __( |
|
| 624 | + 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', |
|
| 625 | + 'event_espresso' |
|
| 626 | + ), |
|
| 627 | + $config_class |
|
| 628 | + ) |
|
| 629 | + ); |
|
| 630 | + } |
|
| 631 | + return false; |
|
| 632 | + } |
|
| 633 | + break; |
|
| 634 | + // TEST #7 : check that config has even been set |
|
| 635 | + case 7: |
|
| 636 | + if (! isset($this->{$section}->{$name})) { |
|
| 637 | + if ($display_errors) { |
|
| 638 | + throw new EE_Error( |
|
| 639 | + sprintf( |
|
| 640 | + __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'), |
|
| 641 | + $section, |
|
| 642 | + $name |
|
| 643 | + ) |
|
| 644 | + ); |
|
| 645 | + } |
|
| 646 | + return false; |
|
| 647 | + } else { |
|
| 648 | + // and make sure it's not serialized |
|
| 649 | + $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name}); |
|
| 650 | + } |
|
| 651 | + break; |
|
| 652 | + // TEST #8 : check that config is the requested type |
|
| 653 | + case 8: |
|
| 654 | + if (! $this->{$section}->{$name} instanceof $config_class) { |
|
| 655 | + if ($display_errors) { |
|
| 656 | + throw new EE_Error( |
|
| 657 | + sprintf( |
|
| 658 | + __( |
|
| 659 | + 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', |
|
| 660 | + 'event_espresso' |
|
| 661 | + ), |
|
| 662 | + $section, |
|
| 663 | + $name, |
|
| 664 | + $config_class |
|
| 665 | + ) |
|
| 666 | + ); |
|
| 667 | + } |
|
| 668 | + return false; |
|
| 669 | + } |
|
| 670 | + break; |
|
| 671 | + // TEST #9 : verify config object |
|
| 672 | + case 9: |
|
| 673 | + if (! $config_obj instanceof EE_Config_Base) { |
|
| 674 | + if ($display_errors) { |
|
| 675 | + throw new EE_Error( |
|
| 676 | + sprintf( |
|
| 677 | + __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'), |
|
| 678 | + print_r($config_obj, true) |
|
| 679 | + ) |
|
| 680 | + ); |
|
| 681 | + } |
|
| 682 | + return false; |
|
| 683 | + } |
|
| 684 | + break; |
|
| 685 | + } |
|
| 686 | + } |
|
| 687 | + } catch (EE_Error $e) { |
|
| 688 | + $e->get_error(); |
|
| 689 | + } |
|
| 690 | + // you have successfully run the gauntlet |
|
| 691 | + return true; |
|
| 692 | + } |
|
| 693 | + |
|
| 694 | + |
|
| 695 | + /** |
|
| 696 | + * _generate_config_option_name |
|
| 697 | + * |
|
| 698 | + * @access protected |
|
| 699 | + * @param string $section |
|
| 700 | + * @param string $name |
|
| 701 | + * @return string |
|
| 702 | + */ |
|
| 703 | + private function _generate_config_option_name($section = '', $name = '') |
|
| 704 | + { |
|
| 705 | + return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name)); |
|
| 706 | + } |
|
| 707 | + |
|
| 708 | + |
|
| 709 | + /** |
|
| 710 | + * _set_config_class |
|
| 711 | + * ensures that a config class is set, either from a passed config class or one generated from the config name |
|
| 712 | + * |
|
| 713 | + * @access private |
|
| 714 | + * @param string $config_class |
|
| 715 | + * @param string $name |
|
| 716 | + * @return string |
|
| 717 | + */ |
|
| 718 | + private function _set_config_class($config_class = '', $name = '') |
|
| 719 | + { |
|
| 720 | + return ! empty($config_class) |
|
| 721 | + ? $config_class |
|
| 722 | + : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config'; |
|
| 723 | + } |
|
| 724 | + |
|
| 725 | + |
|
| 726 | + /** |
|
| 727 | + * set_config |
|
| 728 | + * |
|
| 729 | + * @access protected |
|
| 730 | + * @param string $section |
|
| 731 | + * @param string $name |
|
| 732 | + * @param string $config_class |
|
| 733 | + * @param EE_Config_Base $config_obj |
|
| 734 | + * @return EE_Config_Base |
|
| 735 | + */ |
|
| 736 | + public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) |
|
| 737 | + { |
|
| 738 | + // ensure config class is set to something |
|
| 739 | + $config_class = $this->_set_config_class($config_class, $name); |
|
| 740 | + // run tests 1-4, 6, and 7 to verify all config params are set and valid |
|
| 741 | + if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
| 742 | + return null; |
|
| 743 | + } |
|
| 744 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
| 745 | + // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
|
| 746 | + if (! isset($this->_addon_option_names[ $config_option_name ])) { |
|
| 747 | + $this->_addon_option_names[ $config_option_name ] = $config_class; |
|
| 748 | + $this->update_addon_option_names(); |
|
| 749 | + } |
|
| 750 | + // verify the incoming config object but suppress errors |
|
| 751 | + if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
| 752 | + $config_obj = new $config_class(); |
|
| 753 | + } |
|
| 754 | + if (get_option($config_option_name)) { |
|
| 755 | + EE_Config::log($config_option_name); |
|
| 756 | + update_option($config_option_name, $config_obj); |
|
| 757 | + $this->{$section}->{$name} = $config_obj; |
|
| 758 | + return $this->{$section}->{$name}; |
|
| 759 | + } else { |
|
| 760 | + // create a wp-option for this config |
|
| 761 | + if (add_option($config_option_name, $config_obj, '', 'no')) { |
|
| 762 | + $this->{$section}->{$name} = maybe_unserialize($config_obj); |
|
| 763 | + return $this->{$section}->{$name}; |
|
| 764 | + } else { |
|
| 765 | + EE_Error::add_error( |
|
| 766 | + sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class), |
|
| 767 | + __FILE__, |
|
| 768 | + __FUNCTION__, |
|
| 769 | + __LINE__ |
|
| 770 | + ); |
|
| 771 | + return null; |
|
| 772 | + } |
|
| 773 | + } |
|
| 774 | + } |
|
| 775 | + |
|
| 776 | + |
|
| 777 | + /** |
|
| 778 | + * update_config |
|
| 779 | + * Important: the config object must ALREADY be set, otherwise this will produce an error. |
|
| 780 | + * |
|
| 781 | + * @access public |
|
| 782 | + * @param string $section |
|
| 783 | + * @param string $name |
|
| 784 | + * @param EE_Config_Base|string $config_obj |
|
| 785 | + * @param bool $throw_errors |
|
| 786 | + * @return bool |
|
| 787 | + */ |
|
| 788 | + public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) |
|
| 789 | + { |
|
| 790 | + // don't allow config updates during WP heartbeats |
|
| 791 | + if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
| 792 | + return false; |
|
| 793 | + } |
|
| 794 | + $config_obj = maybe_unserialize($config_obj); |
|
| 795 | + // get class name of the incoming object |
|
| 796 | + $config_class = get_class($config_obj); |
|
| 797 | + // run tests 1-5 and 9 to verify config |
|
| 798 | + if (! $this->_verify_config_params( |
|
| 799 | + $section, |
|
| 800 | + $name, |
|
| 801 | + $config_class, |
|
| 802 | + $config_obj, |
|
| 803 | + array(1, 2, 3, 4, 7, 9) |
|
| 804 | + ) |
|
| 805 | + ) { |
|
| 806 | + return false; |
|
| 807 | + } |
|
| 808 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
| 809 | + // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array |
|
| 810 | + if (! isset($this->_addon_option_names[ $config_option_name ])) { |
|
| 811 | + // save new config to db |
|
| 812 | + if ($this->set_config($section, $name, $config_class, $config_obj)) { |
|
| 813 | + return true; |
|
| 814 | + } |
|
| 815 | + } else { |
|
| 816 | + // first check if the record already exists |
|
| 817 | + $existing_config = get_option($config_option_name); |
|
| 818 | + $config_obj = serialize($config_obj); |
|
| 819 | + // just return if db record is already up to date (NOT type safe comparison) |
|
| 820 | + if ($existing_config == $config_obj) { |
|
| 821 | + $this->{$section}->{$name} = $config_obj; |
|
| 822 | + return true; |
|
| 823 | + } elseif (update_option($config_option_name, $config_obj)) { |
|
| 824 | + EE_Config::log($config_option_name); |
|
| 825 | + // update wp-option for this config class |
|
| 826 | + $this->{$section}->{$name} = $config_obj; |
|
| 827 | + return true; |
|
| 828 | + } elseif ($throw_errors) { |
|
| 829 | + EE_Error::add_error( |
|
| 830 | + sprintf( |
|
| 831 | + __( |
|
| 832 | + 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', |
|
| 833 | + 'event_espresso' |
|
| 834 | + ), |
|
| 835 | + $config_class, |
|
| 836 | + 'EE_Config->' . $section . '->' . $name |
|
| 837 | + ), |
|
| 838 | + __FILE__, |
|
| 839 | + __FUNCTION__, |
|
| 840 | + __LINE__ |
|
| 841 | + ); |
|
| 842 | + } |
|
| 843 | + } |
|
| 844 | + return false; |
|
| 845 | + } |
|
| 846 | + |
|
| 847 | + |
|
| 848 | + /** |
|
| 849 | + * get_config |
|
| 850 | + * |
|
| 851 | + * @access public |
|
| 852 | + * @param string $section |
|
| 853 | + * @param string $name |
|
| 854 | + * @param string $config_class |
|
| 855 | + * @return mixed EE_Config_Base | NULL |
|
| 856 | + */ |
|
| 857 | + public function get_config($section = '', $name = '', $config_class = '') |
|
| 858 | + { |
|
| 859 | + // ensure config class is set to something |
|
| 860 | + $config_class = $this->_set_config_class($config_class, $name); |
|
| 861 | + // run tests 1-4, 6 and 7 to verify that all params have been set |
|
| 862 | + if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
| 863 | + return null; |
|
| 864 | + } |
|
| 865 | + // now test if the requested config object exists, but suppress errors |
|
| 866 | + if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) { |
|
| 867 | + // config already exists, so pass it back |
|
| 868 | + return $this->{$section}->{$name}; |
|
| 869 | + } |
|
| 870 | + // load config option from db if it exists |
|
| 871 | + $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name)); |
|
| 872 | + // verify the newly retrieved config object, but suppress errors |
|
| 873 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
| 874 | + // config is good, so set it and pass it back |
|
| 875 | + $this->{$section}->{$name} = $config_obj; |
|
| 876 | + return $this->{$section}->{$name}; |
|
| 877 | + } |
|
| 878 | + // oops! $config_obj is not already set and does not exist in the db, so create a new one |
|
| 879 | + $config_obj = $this->set_config($section, $name, $config_class); |
|
| 880 | + // verify the newly created config object |
|
| 881 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) { |
|
| 882 | + return $this->{$section}->{$name}; |
|
| 883 | + } else { |
|
| 884 | + EE_Error::add_error( |
|
| 885 | + sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class), |
|
| 886 | + __FILE__, |
|
| 887 | + __FUNCTION__, |
|
| 888 | + __LINE__ |
|
| 889 | + ); |
|
| 890 | + } |
|
| 891 | + return null; |
|
| 892 | + } |
|
| 893 | + |
|
| 894 | + |
|
| 895 | + /** |
|
| 896 | + * get_config_option |
|
| 897 | + * |
|
| 898 | + * @access public |
|
| 899 | + * @param string $config_option_name |
|
| 900 | + * @return mixed EE_Config_Base | FALSE |
|
| 901 | + */ |
|
| 902 | + public function get_config_option($config_option_name = '') |
|
| 903 | + { |
|
| 904 | + // retrieve the wp-option for this config class. |
|
| 905 | + $config_option = maybe_unserialize(get_option($config_option_name, array())); |
|
| 906 | + if (empty($config_option)) { |
|
| 907 | + EE_Config::log($config_option_name . '-NOT-FOUND'); |
|
| 908 | + } |
|
| 909 | + return $config_option; |
|
| 910 | + } |
|
| 911 | + |
|
| 912 | + |
|
| 913 | + /** |
|
| 914 | + * log |
|
| 915 | + * |
|
| 916 | + * @param string $config_option_name |
|
| 917 | + */ |
|
| 918 | + public static function log($config_option_name = '') |
|
| 919 | + { |
|
| 920 | + if (EE_Config::logging_enabled() && ! empty($config_option_name)) { |
|
| 921 | + $config_log = get_option(EE_Config::LOG_NAME, array()); |
|
| 922 | + // copy incoming $_REQUEST and sanitize it so we can save it |
|
| 923 | + $_request = $_REQUEST; |
|
| 924 | + array_walk_recursive($_request, 'sanitize_text_field'); |
|
| 925 | + $config_log[ (string) microtime(true) ] = array( |
|
| 926 | + 'config_name' => $config_option_name, |
|
| 927 | + 'request' => $_request, |
|
| 928 | + ); |
|
| 929 | + update_option(EE_Config::LOG_NAME, $config_log); |
|
| 930 | + } |
|
| 931 | + } |
|
| 932 | + |
|
| 933 | + |
|
| 934 | + /** |
|
| 935 | + * trim_log |
|
| 936 | + * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH |
|
| 937 | + */ |
|
| 938 | + public static function trim_log() |
|
| 939 | + { |
|
| 940 | + if (! EE_Config::logging_enabled()) { |
|
| 941 | + return; |
|
| 942 | + } |
|
| 943 | + $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array())); |
|
| 944 | + $log_length = count($config_log); |
|
| 945 | + if ($log_length > EE_Config::LOG_LENGTH) { |
|
| 946 | + ksort($config_log); |
|
| 947 | + $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true); |
|
| 948 | + update_option(EE_Config::LOG_NAME, $config_log); |
|
| 949 | + } |
|
| 950 | + } |
|
| 951 | + |
|
| 952 | + |
|
| 953 | + /** |
|
| 954 | + * get_page_for_posts |
|
| 955 | + * if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the |
|
| 956 | + * wp-option "page_for_posts", or "posts" if no page is selected |
|
| 957 | + * |
|
| 958 | + * @access public |
|
| 959 | + * @return string |
|
| 960 | + */ |
|
| 961 | + public static function get_page_for_posts() |
|
| 962 | + { |
|
| 963 | + $page_for_posts = get_option('page_for_posts'); |
|
| 964 | + if (! $page_for_posts) { |
|
| 965 | + return 'posts'; |
|
| 966 | + } |
|
| 967 | + /** @type WPDB $wpdb */ |
|
| 968 | + global $wpdb; |
|
| 969 | + $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
| 970 | + return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts)); |
|
| 971 | + } |
|
| 972 | + |
|
| 973 | + |
|
| 974 | + /** |
|
| 975 | + * register_shortcodes_and_modules. |
|
| 976 | + * At this point, it's too early to tell if we're maintenance mode or not. |
|
| 977 | + * In fact, this is where we give modules a chance to let core know they exist |
|
| 978 | + * so they can help trigger maintenance mode if it's needed |
|
| 979 | + * |
|
| 980 | + * @access public |
|
| 981 | + * @return void |
|
| 982 | + */ |
|
| 983 | + public function register_shortcodes_and_modules() |
|
| 984 | + { |
|
| 985 | + // allow modules to set hooks for the rest of the system |
|
| 986 | + EE_Registry::instance()->modules = $this->_register_modules(); |
|
| 987 | + } |
|
| 988 | + |
|
| 989 | + |
|
| 990 | + /** |
|
| 991 | + * initialize_shortcodes_and_modules |
|
| 992 | + * meaning they can start adding their hooks to get stuff done |
|
| 993 | + * |
|
| 994 | + * @access public |
|
| 995 | + * @return void |
|
| 996 | + */ |
|
| 997 | + public function initialize_shortcodes_and_modules() |
|
| 998 | + { |
|
| 999 | + // allow modules to set hooks for the rest of the system |
|
| 1000 | + $this->_initialize_modules(); |
|
| 1001 | + } |
|
| 1002 | + |
|
| 1003 | + |
|
| 1004 | + /** |
|
| 1005 | + * widgets_init |
|
| 1006 | + * |
|
| 1007 | + * @access private |
|
| 1008 | + * @return void |
|
| 1009 | + */ |
|
| 1010 | + public function widgets_init() |
|
| 1011 | + { |
|
| 1012 | + // only init widgets on admin pages when not in complete maintenance, and |
|
| 1013 | + // on frontend when not in any maintenance mode |
|
| 1014 | + if (! EE_Maintenance_Mode::instance()->level() |
|
| 1015 | + || ( |
|
| 1016 | + is_admin() |
|
| 1017 | + && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance |
|
| 1018 | + ) |
|
| 1019 | + ) { |
|
| 1020 | + // grab list of installed widgets |
|
| 1021 | + $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR); |
|
| 1022 | + // filter list of modules to register |
|
| 1023 | + $widgets_to_register = apply_filters( |
|
| 1024 | + 'FHEE__EE_Config__register_widgets__widgets_to_register', |
|
| 1025 | + $widgets_to_register |
|
| 1026 | + ); |
|
| 1027 | + if (! empty($widgets_to_register)) { |
|
| 1028 | + // cycle thru widget folders |
|
| 1029 | + foreach ($widgets_to_register as $widget_path) { |
|
| 1030 | + // add to list of installed widget modules |
|
| 1031 | + EE_Config::register_ee_widget($widget_path); |
|
| 1032 | + } |
|
| 1033 | + } |
|
| 1034 | + // filter list of installed modules |
|
| 1035 | + EE_Registry::instance()->widgets = apply_filters( |
|
| 1036 | + 'FHEE__EE_Config__register_widgets__installed_widgets', |
|
| 1037 | + EE_Registry::instance()->widgets |
|
| 1038 | + ); |
|
| 1039 | + } |
|
| 1040 | + } |
|
| 1041 | + |
|
| 1042 | + |
|
| 1043 | + /** |
|
| 1044 | + * register_ee_widget - makes core aware of this widget |
|
| 1045 | + * |
|
| 1046 | + * @access public |
|
| 1047 | + * @param string $widget_path - full path up to and including widget folder |
|
| 1048 | + * @return void |
|
| 1049 | + */ |
|
| 1050 | + public static function register_ee_widget($widget_path = null) |
|
| 1051 | + { |
|
| 1052 | + do_action('AHEE__EE_Config__register_widget__begin', $widget_path); |
|
| 1053 | + $widget_ext = '.widget.php'; |
|
| 1054 | + // make all separators match |
|
| 1055 | + $widget_path = rtrim(str_replace('\\', DS, $widget_path), DS); |
|
| 1056 | + // does the file path INCLUDE the actual file name as part of the path ? |
|
| 1057 | + if (strpos($widget_path, $widget_ext) !== false) { |
|
| 1058 | + // grab and shortcode file name from directory name and break apart at dots |
|
| 1059 | + $file_name = explode('.', basename($widget_path)); |
|
| 1060 | + // take first segment from file name pieces and remove class prefix if it exists |
|
| 1061 | + $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0]; |
|
| 1062 | + // sanitize shortcode directory name |
|
| 1063 | + $widget = sanitize_key($widget); |
|
| 1064 | + // now we need to rebuild the shortcode path |
|
| 1065 | + $widget_path = explode('/', $widget_path); |
|
| 1066 | + // remove last segment |
|
| 1067 | + array_pop($widget_path); |
|
| 1068 | + // glue it back together |
|
| 1069 | + $widget_path = implode(DS, $widget_path); |
|
| 1070 | + } else { |
|
| 1071 | + // grab and sanitize widget directory name |
|
| 1072 | + $widget = sanitize_key(basename($widget_path)); |
|
| 1073 | + } |
|
| 1074 | + // create classname from widget directory name |
|
| 1075 | + $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
|
| 1076 | + // add class prefix |
|
| 1077 | + $widget_class = 'EEW_' . $widget; |
|
| 1078 | + // does the widget exist ? |
|
| 1079 | + if (! is_readable($widget_path . '/' . $widget_class . $widget_ext)) { |
|
| 1080 | + $msg = sprintf( |
|
| 1081 | + __( |
|
| 1082 | + 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
|
| 1083 | + 'event_espresso' |
|
| 1084 | + ), |
|
| 1085 | + $widget_class, |
|
| 1086 | + $widget_path . '/' . $widget_class . $widget_ext |
|
| 1087 | + ); |
|
| 1088 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1089 | + return; |
|
| 1090 | + } |
|
| 1091 | + // load the widget class file |
|
| 1092 | + require_once($widget_path . '/' . $widget_class . $widget_ext); |
|
| 1093 | + // verify that class exists |
|
| 1094 | + if (! class_exists($widget_class)) { |
|
| 1095 | + $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
|
| 1096 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1097 | + return; |
|
| 1098 | + } |
|
| 1099 | + register_widget($widget_class); |
|
| 1100 | + // add to array of registered widgets |
|
| 1101 | + EE_Registry::instance()->widgets->{$widget_class} = $widget_path . '/' . $widget_class . $widget_ext; |
|
| 1102 | + } |
|
| 1103 | + |
|
| 1104 | + |
|
| 1105 | + /** |
|
| 1106 | + * _register_modules |
|
| 1107 | + * |
|
| 1108 | + * @access private |
|
| 1109 | + * @return array |
|
| 1110 | + */ |
|
| 1111 | + private function _register_modules() |
|
| 1112 | + { |
|
| 1113 | + // grab list of installed modules |
|
| 1114 | + $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR); |
|
| 1115 | + // filter list of modules to register |
|
| 1116 | + $modules_to_register = apply_filters( |
|
| 1117 | + 'FHEE__EE_Config__register_modules__modules_to_register', |
|
| 1118 | + $modules_to_register |
|
| 1119 | + ); |
|
| 1120 | + if (! empty($modules_to_register)) { |
|
| 1121 | + // loop through folders |
|
| 1122 | + foreach ($modules_to_register as $module_path) { |
|
| 1123 | + /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
|
| 1124 | + if ($module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
| 1125 | + && $module_path !== EE_MODULES . 'gateways' |
|
| 1126 | + ) { |
|
| 1127 | + // add to list of installed modules |
|
| 1128 | + EE_Config::register_module($module_path); |
|
| 1129 | + } |
|
| 1130 | + } |
|
| 1131 | + } |
|
| 1132 | + // filter list of installed modules |
|
| 1133 | + return apply_filters( |
|
| 1134 | + 'FHEE__EE_Config___register_modules__installed_modules', |
|
| 1135 | + EE_Registry::instance()->modules |
|
| 1136 | + ); |
|
| 1137 | + } |
|
| 1138 | + |
|
| 1139 | + |
|
| 1140 | + /** |
|
| 1141 | + * register_module - makes core aware of this module |
|
| 1142 | + * |
|
| 1143 | + * @access public |
|
| 1144 | + * @param string $module_path - full path up to and including module folder |
|
| 1145 | + * @return bool |
|
| 1146 | + */ |
|
| 1147 | + public static function register_module($module_path = null) |
|
| 1148 | + { |
|
| 1149 | + do_action('AHEE__EE_Config__register_module__begin', $module_path); |
|
| 1150 | + $module_ext = '.module.php'; |
|
| 1151 | + // make all separators match |
|
| 1152 | + $module_path = str_replace(array('\\', '/'), '/', $module_path); |
|
| 1153 | + // does the file path INCLUDE the actual file name as part of the path ? |
|
| 1154 | + if (strpos($module_path, $module_ext) !== false) { |
|
| 1155 | + // grab and shortcode file name from directory name and break apart at dots |
|
| 1156 | + $module_file = explode('.', basename($module_path)); |
|
| 1157 | + // now we need to rebuild the shortcode path |
|
| 1158 | + $module_path = explode('/', $module_path); |
|
| 1159 | + // remove last segment |
|
| 1160 | + array_pop($module_path); |
|
| 1161 | + // glue it back together |
|
| 1162 | + $module_path = implode('/', $module_path) . '/'; |
|
| 1163 | + // take first segment from file name pieces and sanitize it |
|
| 1164 | + $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
|
| 1165 | + // ensure class prefix is added |
|
| 1166 | + $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module; |
|
| 1167 | + } else { |
|
| 1168 | + // we need to generate the filename based off of the folder name |
|
| 1169 | + // grab and sanitize module name |
|
| 1170 | + $module = strtolower(basename($module_path)); |
|
| 1171 | + $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
|
| 1172 | + // like trailingslashit() |
|
| 1173 | + $module_path = rtrim($module_path, '/') . '/'; |
|
| 1174 | + // create classname from module directory name |
|
| 1175 | + $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
|
| 1176 | + // add class prefix |
|
| 1177 | + $module_class = 'EED_' . $module; |
|
| 1178 | + } |
|
| 1179 | + // does the module exist ? |
|
| 1180 | + if (! is_readable($module_path . '/' . $module_class . $module_ext)) { |
|
| 1181 | + $msg = sprintf( |
|
| 1182 | + __( |
|
| 1183 | + 'The requested %s module file could not be found or is not readable due to file permissions.', |
|
| 1184 | + 'event_espresso' |
|
| 1185 | + ), |
|
| 1186 | + $module |
|
| 1187 | + ); |
|
| 1188 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1189 | + return false; |
|
| 1190 | + } |
|
| 1191 | + // load the module class file |
|
| 1192 | + require_once($module_path . $module_class . $module_ext); |
|
| 1193 | + // verify that class exists |
|
| 1194 | + if (! class_exists($module_class)) { |
|
| 1195 | + $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
| 1196 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1197 | + return false; |
|
| 1198 | + } |
|
| 1199 | + // add to array of registered modules |
|
| 1200 | + EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
| 1201 | + do_action( |
|
| 1202 | + 'AHEE__EE_Config__register_module__complete', |
|
| 1203 | + $module_class, |
|
| 1204 | + EE_Registry::instance()->modules->{$module_class} |
|
| 1205 | + ); |
|
| 1206 | + return true; |
|
| 1207 | + } |
|
| 1208 | + |
|
| 1209 | + |
|
| 1210 | + /** |
|
| 1211 | + * _initialize_modules |
|
| 1212 | + * allow modules to set hooks for the rest of the system |
|
| 1213 | + * |
|
| 1214 | + * @access private |
|
| 1215 | + * @return void |
|
| 1216 | + */ |
|
| 1217 | + private function _initialize_modules() |
|
| 1218 | + { |
|
| 1219 | + // cycle thru shortcode folders |
|
| 1220 | + foreach (EE_Registry::instance()->modules as $module_class => $module_path) { |
|
| 1221 | + // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
| 1222 | + // which set hooks ? |
|
| 1223 | + if (is_admin()) { |
|
| 1224 | + // fire immediately |
|
| 1225 | + call_user_func(array($module_class, 'set_hooks_admin')); |
|
| 1226 | + } else { |
|
| 1227 | + // delay until other systems are online |
|
| 1228 | + add_action( |
|
| 1229 | + 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
| 1230 | + array($module_class, 'set_hooks') |
|
| 1231 | + ); |
|
| 1232 | + } |
|
| 1233 | + } |
|
| 1234 | + } |
|
| 1235 | + |
|
| 1236 | + |
|
| 1237 | + /** |
|
| 1238 | + * register_route - adds module method routes to route_map |
|
| 1239 | + * |
|
| 1240 | + * @access public |
|
| 1241 | + * @param string $route - "pretty" public alias for module method |
|
| 1242 | + * @param string $module - module name (classname without EED_ prefix) |
|
| 1243 | + * @param string $method_name - the actual module method to be routed to |
|
| 1244 | + * @param string $key - url param key indicating a route is being called |
|
| 1245 | + * @return bool |
|
| 1246 | + */ |
|
| 1247 | + public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee') |
|
| 1248 | + { |
|
| 1249 | + do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
|
| 1250 | + $module = str_replace('EED_', '', $module); |
|
| 1251 | + $module_class = 'EED_' . $module; |
|
| 1252 | + if (! isset(EE_Registry::instance()->modules->{$module_class})) { |
|
| 1253 | + $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
|
| 1254 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1255 | + return false; |
|
| 1256 | + } |
|
| 1257 | + if (empty($route)) { |
|
| 1258 | + $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
|
| 1259 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1260 | + return false; |
|
| 1261 | + } |
|
| 1262 | + if (! method_exists('EED_' . $module, $method_name)) { |
|
| 1263 | + $msg = sprintf( |
|
| 1264 | + __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
|
| 1265 | + $route |
|
| 1266 | + ); |
|
| 1267 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1268 | + return false; |
|
| 1269 | + } |
|
| 1270 | + EE_Config::$_module_route_map[ (string) $key ][ (string) $route ] = array('EED_' . $module, $method_name); |
|
| 1271 | + return true; |
|
| 1272 | + } |
|
| 1273 | + |
|
| 1274 | + |
|
| 1275 | + /** |
|
| 1276 | + * get_route - get module method route |
|
| 1277 | + * |
|
| 1278 | + * @access public |
|
| 1279 | + * @param string $route - "pretty" public alias for module method |
|
| 1280 | + * @param string $key - url param key indicating a route is being called |
|
| 1281 | + * @return string |
|
| 1282 | + */ |
|
| 1283 | + public static function get_route($route = null, $key = 'ee') |
|
| 1284 | + { |
|
| 1285 | + do_action('AHEE__EE_Config__get_route__begin', $route); |
|
| 1286 | + $route = (string) apply_filters('FHEE__EE_Config__get_route', $route); |
|
| 1287 | + if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) { |
|
| 1288 | + return EE_Config::$_module_route_map[ $key ][ $route ]; |
|
| 1289 | + } |
|
| 1290 | + return null; |
|
| 1291 | + } |
|
| 1292 | + |
|
| 1293 | + |
|
| 1294 | + /** |
|
| 1295 | + * get_routes - get ALL module method routes |
|
| 1296 | + * |
|
| 1297 | + * @access public |
|
| 1298 | + * @return array |
|
| 1299 | + */ |
|
| 1300 | + public static function get_routes() |
|
| 1301 | + { |
|
| 1302 | + return EE_Config::$_module_route_map; |
|
| 1303 | + } |
|
| 1304 | + |
|
| 1305 | + |
|
| 1306 | + /** |
|
| 1307 | + * register_forward - allows modules to forward request to another module for further processing |
|
| 1308 | + * |
|
| 1309 | + * @access public |
|
| 1310 | + * @param string $route - "pretty" public alias for module method |
|
| 1311 | + * @param integer $status - integer value corresponding to status constant strings set in module parent |
|
| 1312 | + * class, allows different forwards to be served based on status |
|
| 1313 | + * @param array|string $forward - function name or array( class, method ) |
|
| 1314 | + * @param string $key - url param key indicating a route is being called |
|
| 1315 | + * @return bool |
|
| 1316 | + */ |
|
| 1317 | + public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee') |
|
| 1318 | + { |
|
| 1319 | + do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
|
| 1320 | + if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) { |
|
| 1321 | + $msg = sprintf( |
|
| 1322 | + __('The module route %s for this forward has not been registered.', 'event_espresso'), |
|
| 1323 | + $route |
|
| 1324 | + ); |
|
| 1325 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1326 | + return false; |
|
| 1327 | + } |
|
| 1328 | + if (empty($forward)) { |
|
| 1329 | + $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
|
| 1330 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1331 | + return false; |
|
| 1332 | + } |
|
| 1333 | + if (is_array($forward)) { |
|
| 1334 | + if (! isset($forward[1])) { |
|
| 1335 | + $msg = sprintf( |
|
| 1336 | + __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
|
| 1337 | + $route |
|
| 1338 | + ); |
|
| 1339 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1340 | + return false; |
|
| 1341 | + } |
|
| 1342 | + if (! method_exists($forward[0], $forward[1])) { |
|
| 1343 | + $msg = sprintf( |
|
| 1344 | + __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
| 1345 | + $forward[1], |
|
| 1346 | + $route |
|
| 1347 | + ); |
|
| 1348 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1349 | + return false; |
|
| 1350 | + } |
|
| 1351 | + } elseif (! function_exists($forward)) { |
|
| 1352 | + $msg = sprintf( |
|
| 1353 | + __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
| 1354 | + $forward, |
|
| 1355 | + $route |
|
| 1356 | + ); |
|
| 1357 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1358 | + return false; |
|
| 1359 | + } |
|
| 1360 | + EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward; |
|
| 1361 | + return true; |
|
| 1362 | + } |
|
| 1363 | + |
|
| 1364 | + |
|
| 1365 | + /** |
|
| 1366 | + * get_forward - get forwarding route |
|
| 1367 | + * |
|
| 1368 | + * @access public |
|
| 1369 | + * @param string $route - "pretty" public alias for module method |
|
| 1370 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
| 1371 | + * allows different forwards to be served based on status |
|
| 1372 | + * @param string $key - url param key indicating a route is being called |
|
| 1373 | + * @return string |
|
| 1374 | + */ |
|
| 1375 | + public static function get_forward($route = null, $status = 0, $key = 'ee') |
|
| 1376 | + { |
|
| 1377 | + do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
|
| 1378 | + if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) { |
|
| 1379 | + return apply_filters( |
|
| 1380 | + 'FHEE__EE_Config__get_forward', |
|
| 1381 | + EE_Config::$_module_forward_map[ $key ][ $route ][ $status ], |
|
| 1382 | + $route, |
|
| 1383 | + $status |
|
| 1384 | + ); |
|
| 1385 | + } |
|
| 1386 | + return null; |
|
| 1387 | + } |
|
| 1388 | + |
|
| 1389 | + |
|
| 1390 | + /** |
|
| 1391 | + * register_forward - allows modules to specify different view templates for different method routes and status |
|
| 1392 | + * results |
|
| 1393 | + * |
|
| 1394 | + * @access public |
|
| 1395 | + * @param string $route - "pretty" public alias for module method |
|
| 1396 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
| 1397 | + * allows different views to be served based on status |
|
| 1398 | + * @param string $view |
|
| 1399 | + * @param string $key - url param key indicating a route is being called |
|
| 1400 | + * @return bool |
|
| 1401 | + */ |
|
| 1402 | + public static function register_view($route = null, $status = 0, $view = null, $key = 'ee') |
|
| 1403 | + { |
|
| 1404 | + do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
|
| 1405 | + if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) { |
|
| 1406 | + $msg = sprintf( |
|
| 1407 | + __('The module route %s for this view has not been registered.', 'event_espresso'), |
|
| 1408 | + $route |
|
| 1409 | + ); |
|
| 1410 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1411 | + return false; |
|
| 1412 | + } |
|
| 1413 | + if (! is_readable($view)) { |
|
| 1414 | + $msg = sprintf( |
|
| 1415 | + __( |
|
| 1416 | + 'The %s view file could not be found or is not readable due to file permissions.', |
|
| 1417 | + 'event_espresso' |
|
| 1418 | + ), |
|
| 1419 | + $view |
|
| 1420 | + ); |
|
| 1421 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1422 | + return false; |
|
| 1423 | + } |
|
| 1424 | + EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view; |
|
| 1425 | + return true; |
|
| 1426 | + } |
|
| 1427 | + |
|
| 1428 | + |
|
| 1429 | + /** |
|
| 1430 | + * get_view - get view for route and status |
|
| 1431 | + * |
|
| 1432 | + * @access public |
|
| 1433 | + * @param string $route - "pretty" public alias for module method |
|
| 1434 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
| 1435 | + * allows different views to be served based on status |
|
| 1436 | + * @param string $key - url param key indicating a route is being called |
|
| 1437 | + * @return string |
|
| 1438 | + */ |
|
| 1439 | + public static function get_view($route = null, $status = 0, $key = 'ee') |
|
| 1440 | + { |
|
| 1441 | + do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
|
| 1442 | + if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) { |
|
| 1443 | + return apply_filters( |
|
| 1444 | + 'FHEE__EE_Config__get_view', |
|
| 1445 | + EE_Config::$_module_view_map[ $key ][ $route ][ $status ], |
|
| 1446 | + $route, |
|
| 1447 | + $status |
|
| 1448 | + ); |
|
| 1449 | + } |
|
| 1450 | + return null; |
|
| 1451 | + } |
|
| 1452 | + |
|
| 1453 | + |
|
| 1454 | + public function update_addon_option_names() |
|
| 1455 | + { |
|
| 1456 | + update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names); |
|
| 1457 | + } |
|
| 1458 | + |
|
| 1459 | + |
|
| 1460 | + public function shutdown() |
|
| 1461 | + { |
|
| 1462 | + $this->update_addon_option_names(); |
|
| 1463 | + } |
|
| 1464 | + |
|
| 1465 | + |
|
| 1466 | + /** |
|
| 1467 | + * @return LegacyShortcodesManager |
|
| 1468 | + */ |
|
| 1469 | + public static function getLegacyShortcodesManager() |
|
| 1470 | + { |
|
| 1471 | + |
|
| 1472 | + if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) { |
|
| 1473 | + EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager( |
|
| 1474 | + EE_Registry::instance() |
|
| 1475 | + ); |
|
| 1476 | + } |
|
| 1477 | + return EE_Config::instance()->legacy_shortcodes_manager; |
|
| 1478 | + } |
|
| 1479 | + |
|
| 1480 | + |
|
| 1481 | + /** |
|
| 1482 | + * register_shortcode - makes core aware of this shortcode |
|
| 1483 | + * |
|
| 1484 | + * @deprecated 4.9.26 |
|
| 1485 | + * @param string $shortcode_path - full path up to and including shortcode folder |
|
| 1486 | + * @return bool |
|
| 1487 | + */ |
|
| 1488 | + public static function register_shortcode($shortcode_path = null) |
|
| 1489 | + { |
|
| 1490 | + EE_Error::doing_it_wrong( |
|
| 1491 | + __METHOD__, |
|
| 1492 | + __( |
|
| 1493 | + 'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.', |
|
| 1494 | + 'event_espresso' |
|
| 1495 | + ), |
|
| 1496 | + '4.9.26' |
|
| 1497 | + ); |
|
| 1498 | + return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path); |
|
| 1499 | + } |
|
| 1500 | +} |
|
| 2262 | 1501 | |
| 2263 | - /** |
|
| 2264 | - * ReCaptcha Type |
|
| 2265 | - * |
|
| 2266 | - * @var string $recaptcha_type |
|
| 2267 | - * options: 'audio', 'image' |
|
| 2268 | - */ |
|
| 2269 | - public $recaptcha_type; |
|
| 1502 | +/** |
|
| 1503 | + * Base class used for config classes. These classes should generally not have |
|
| 1504 | + * magic functions in use, except we'll allow them to magically set and get stuff... |
|
| 1505 | + * basically, they should just be well-defined stdClasses |
|
| 1506 | + */ |
|
| 1507 | +class EE_Config_Base |
|
| 1508 | +{ |
|
| 2270 | 1509 | |
| 2271 | - /** |
|
| 2272 | - * ReCaptcha language |
|
| 2273 | - * |
|
| 2274 | - * @var string $recaptcha_language |
|
| 2275 | - * eg 'en' |
|
| 2276 | - */ |
|
| 2277 | - public $recaptcha_language; |
|
| 1510 | + /** |
|
| 1511 | + * Utility function for escaping the value of a property and returning. |
|
| 1512 | + * |
|
| 1513 | + * @param string $property property name (checks to see if exists). |
|
| 1514 | + * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
| 1515 | + * @throws \EE_Error |
|
| 1516 | + */ |
|
| 1517 | + public function get_pretty($property) |
|
| 1518 | + { |
|
| 1519 | + if (! property_exists($this, $property)) { |
|
| 1520 | + throw new EE_Error( |
|
| 1521 | + sprintf( |
|
| 1522 | + __( |
|
| 1523 | + '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', |
|
| 1524 | + 'event_espresso' |
|
| 1525 | + ), |
|
| 1526 | + get_class($this), |
|
| 1527 | + $property |
|
| 1528 | + ) |
|
| 1529 | + ); |
|
| 1530 | + } |
|
| 1531 | + // just handling escaping of strings for now. |
|
| 1532 | + if (is_string($this->{$property})) { |
|
| 1533 | + return stripslashes($this->{$property}); |
|
| 1534 | + } |
|
| 1535 | + return $this->{$property}; |
|
| 1536 | + } |
|
| 1537 | + |
|
| 1538 | + |
|
| 1539 | + public function populate() |
|
| 1540 | + { |
|
| 1541 | + // grab defaults via a new instance of this class. |
|
| 1542 | + $class_name = get_class($this); |
|
| 1543 | + $defaults = new $class_name; |
|
| 1544 | + // loop through the properties for this class and see if they are set. If they are NOT, then grab the |
|
| 1545 | + // default from our $defaults object. |
|
| 1546 | + foreach (get_object_vars($defaults) as $property => $value) { |
|
| 1547 | + if ($this->{$property} === null) { |
|
| 1548 | + $this->{$property} = $value; |
|
| 1549 | + } |
|
| 1550 | + } |
|
| 1551 | + // cleanup |
|
| 1552 | + unset($defaults); |
|
| 1553 | + } |
|
| 1554 | + |
|
| 1555 | + |
|
| 1556 | + /** |
|
| 1557 | + * __isset |
|
| 1558 | + * |
|
| 1559 | + * @param $a |
|
| 1560 | + * @return bool |
|
| 1561 | + */ |
|
| 1562 | + public function __isset($a) |
|
| 1563 | + { |
|
| 1564 | + return false; |
|
| 1565 | + } |
|
| 1566 | + |
|
| 1567 | + |
|
| 1568 | + /** |
|
| 1569 | + * __unset |
|
| 1570 | + * |
|
| 1571 | + * @param $a |
|
| 1572 | + * @return bool |
|
| 1573 | + */ |
|
| 1574 | + public function __unset($a) |
|
| 1575 | + { |
|
| 1576 | + return false; |
|
| 1577 | + } |
|
| 1578 | + |
|
| 1579 | + |
|
| 1580 | + /** |
|
| 1581 | + * __clone |
|
| 1582 | + */ |
|
| 1583 | + public function __clone() |
|
| 1584 | + { |
|
| 1585 | + } |
|
| 1586 | + |
|
| 1587 | + |
|
| 1588 | + /** |
|
| 1589 | + * __wakeup |
|
| 1590 | + */ |
|
| 1591 | + public function __wakeup() |
|
| 1592 | + { |
|
| 1593 | + } |
|
| 1594 | + |
|
| 1595 | + |
|
| 1596 | + /** |
|
| 1597 | + * __destruct |
|
| 1598 | + */ |
|
| 1599 | + public function __destruct() |
|
| 1600 | + { |
|
| 1601 | + } |
|
| 1602 | +} |
|
| 2278 | 1603 | |
| 2279 | - /** |
|
| 2280 | - * ReCaptcha public key |
|
| 2281 | - * |
|
| 2282 | - * @var string $recaptcha_publickey |
|
| 2283 | - */ |
|
| 2284 | - public $recaptcha_publickey; |
|
| 1604 | +/** |
|
| 1605 | + * Class for defining what's in the EE_Config relating to registration settings |
|
| 1606 | + */ |
|
| 1607 | +class EE_Core_Config extends EE_Config_Base |
|
| 1608 | +{ |
|
| 2285 | 1609 | |
| 2286 | - /** |
|
| 2287 | - * ReCaptcha private key |
|
| 2288 | - * |
|
| 2289 | - * @var string $recaptcha_privatekey |
|
| 2290 | - */ |
|
| 2291 | - public $recaptcha_privatekey; |
|
| 1610 | + const OPTION_NAME_UXIP = 'ee_ueip_optin'; |
|
| 1611 | + |
|
| 1612 | + |
|
| 1613 | + public $current_blog_id; |
|
| 1614 | + |
|
| 1615 | + public $ee_ueip_optin; |
|
| 1616 | + |
|
| 1617 | + public $ee_ueip_has_notified; |
|
| 1618 | + |
|
| 1619 | + /** |
|
| 1620 | + * Not to be confused with the 4 critical page variables (See |
|
| 1621 | + * get_critical_pages_array()), this is just an array of wp posts that have EE |
|
| 1622 | + * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode |
|
| 1623 | + * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array. |
|
| 1624 | + * |
|
| 1625 | + * @var array |
|
| 1626 | + */ |
|
| 1627 | + public $post_shortcodes; |
|
| 1628 | + |
|
| 1629 | + public $module_route_map; |
|
| 1630 | + |
|
| 1631 | + public $module_forward_map; |
|
| 1632 | + |
|
| 1633 | + public $module_view_map; |
|
| 1634 | + |
|
| 1635 | + /** |
|
| 1636 | + * The next 4 vars are the IDs of critical EE pages. |
|
| 1637 | + * |
|
| 1638 | + * @var int |
|
| 1639 | + */ |
|
| 1640 | + public $reg_page_id; |
|
| 1641 | + |
|
| 1642 | + public $txn_page_id; |
|
| 1643 | + |
|
| 1644 | + public $thank_you_page_id; |
|
| 1645 | + |
|
| 1646 | + public $cancel_page_id; |
|
| 1647 | + |
|
| 1648 | + /** |
|
| 1649 | + * The next 4 vars are the URLs of critical EE pages. |
|
| 1650 | + * |
|
| 1651 | + * @var int |
|
| 1652 | + */ |
|
| 1653 | + public $reg_page_url; |
|
| 1654 | + |
|
| 1655 | + public $txn_page_url; |
|
| 1656 | + |
|
| 1657 | + public $thank_you_page_url; |
|
| 1658 | + |
|
| 1659 | + public $cancel_page_url; |
|
| 1660 | + |
|
| 1661 | + /** |
|
| 1662 | + * The next vars relate to the custom slugs for EE CPT routes |
|
| 1663 | + */ |
|
| 1664 | + public $event_cpt_slug; |
|
| 1665 | + |
|
| 1666 | + /** |
|
| 1667 | + * This caches the _ee_ueip_option in case this config is reset in the same |
|
| 1668 | + * request across blog switches in a multisite context. |
|
| 1669 | + * Avoids extra queries to the db for this option. |
|
| 1670 | + * |
|
| 1671 | + * @var bool |
|
| 1672 | + */ |
|
| 1673 | + public static $ee_ueip_option; |
|
| 1674 | + |
|
| 1675 | + |
|
| 1676 | + /** |
|
| 1677 | + * class constructor |
|
| 1678 | + * |
|
| 1679 | + * @access public |
|
| 1680 | + */ |
|
| 1681 | + public function __construct() |
|
| 1682 | + { |
|
| 1683 | + // set default organization settings |
|
| 1684 | + $this->current_blog_id = get_current_blog_id(); |
|
| 1685 | + $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id; |
|
| 1686 | + $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin(); |
|
| 1687 | + $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true; |
|
| 1688 | + $this->post_shortcodes = array(); |
|
| 1689 | + $this->module_route_map = array(); |
|
| 1690 | + $this->module_forward_map = array(); |
|
| 1691 | + $this->module_view_map = array(); |
|
| 1692 | + // critical EE page IDs |
|
| 1693 | + $this->reg_page_id = 0; |
|
| 1694 | + $this->txn_page_id = 0; |
|
| 1695 | + $this->thank_you_page_id = 0; |
|
| 1696 | + $this->cancel_page_id = 0; |
|
| 1697 | + // critical EE page URLs |
|
| 1698 | + $this->reg_page_url = ''; |
|
| 1699 | + $this->txn_page_url = ''; |
|
| 1700 | + $this->thank_you_page_url = ''; |
|
| 1701 | + $this->cancel_page_url = ''; |
|
| 1702 | + // cpt slugs |
|
| 1703 | + $this->event_cpt_slug = __('events', 'event_espresso'); |
|
| 1704 | + // ueip constant check |
|
| 1705 | + if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) { |
|
| 1706 | + $this->ee_ueip_optin = false; |
|
| 1707 | + $this->ee_ueip_has_notified = true; |
|
| 1708 | + } |
|
| 1709 | + } |
|
| 1710 | + |
|
| 1711 | + |
|
| 1712 | + /** |
|
| 1713 | + * @return array |
|
| 1714 | + */ |
|
| 1715 | + public function get_critical_pages_array() |
|
| 1716 | + { |
|
| 1717 | + return array( |
|
| 1718 | + $this->reg_page_id, |
|
| 1719 | + $this->txn_page_id, |
|
| 1720 | + $this->thank_you_page_id, |
|
| 1721 | + $this->cancel_page_id, |
|
| 1722 | + ); |
|
| 1723 | + } |
|
| 1724 | + |
|
| 1725 | + |
|
| 1726 | + /** |
|
| 1727 | + * @return array |
|
| 1728 | + */ |
|
| 1729 | + public function get_critical_pages_shortcodes_array() |
|
| 1730 | + { |
|
| 1731 | + return array( |
|
| 1732 | + $this->reg_page_id => 'ESPRESSO_CHECKOUT', |
|
| 1733 | + $this->txn_page_id => 'ESPRESSO_TXN_PAGE', |
|
| 1734 | + $this->thank_you_page_id => 'ESPRESSO_THANK_YOU', |
|
| 1735 | + $this->cancel_page_id => 'ESPRESSO_CANCELLED', |
|
| 1736 | + ); |
|
| 1737 | + } |
|
| 1738 | + |
|
| 1739 | + |
|
| 1740 | + /** |
|
| 1741 | + * gets/returns URL for EE reg_page |
|
| 1742 | + * |
|
| 1743 | + * @access public |
|
| 1744 | + * @return string |
|
| 1745 | + */ |
|
| 1746 | + public function reg_page_url() |
|
| 1747 | + { |
|
| 1748 | + if (! $this->reg_page_url) { |
|
| 1749 | + $this->reg_page_url = add_query_arg( |
|
| 1750 | + array('uts' => time()), |
|
| 1751 | + get_permalink($this->reg_page_id) |
|
| 1752 | + ) . '#checkout'; |
|
| 1753 | + } |
|
| 1754 | + return $this->reg_page_url; |
|
| 1755 | + } |
|
| 1756 | + |
|
| 1757 | + |
|
| 1758 | + /** |
|
| 1759 | + * gets/returns URL for EE txn_page |
|
| 1760 | + * |
|
| 1761 | + * @param array $query_args like what gets passed to |
|
| 1762 | + * add_query_arg() as the first argument |
|
| 1763 | + * @access public |
|
| 1764 | + * @return string |
|
| 1765 | + */ |
|
| 1766 | + public function txn_page_url($query_args = array()) |
|
| 1767 | + { |
|
| 1768 | + if (! $this->txn_page_url) { |
|
| 1769 | + $this->txn_page_url = get_permalink($this->txn_page_id); |
|
| 1770 | + } |
|
| 1771 | + if ($query_args) { |
|
| 1772 | + return add_query_arg($query_args, $this->txn_page_url); |
|
| 1773 | + } else { |
|
| 1774 | + return $this->txn_page_url; |
|
| 1775 | + } |
|
| 1776 | + } |
|
| 1777 | + |
|
| 1778 | + |
|
| 1779 | + /** |
|
| 1780 | + * gets/returns URL for EE thank_you_page |
|
| 1781 | + * |
|
| 1782 | + * @param array $query_args like what gets passed to |
|
| 1783 | + * add_query_arg() as the first argument |
|
| 1784 | + * @access public |
|
| 1785 | + * @return string |
|
| 1786 | + */ |
|
| 1787 | + public function thank_you_page_url($query_args = array()) |
|
| 1788 | + { |
|
| 1789 | + if (! $this->thank_you_page_url) { |
|
| 1790 | + $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
|
| 1791 | + } |
|
| 1792 | + if ($query_args) { |
|
| 1793 | + return add_query_arg($query_args, $this->thank_you_page_url); |
|
| 1794 | + } else { |
|
| 1795 | + return $this->thank_you_page_url; |
|
| 1796 | + } |
|
| 1797 | + } |
|
| 1798 | + |
|
| 1799 | + |
|
| 1800 | + /** |
|
| 1801 | + * gets/returns URL for EE cancel_page |
|
| 1802 | + * |
|
| 1803 | + * @access public |
|
| 1804 | + * @return string |
|
| 1805 | + */ |
|
| 1806 | + public function cancel_page_url() |
|
| 1807 | + { |
|
| 1808 | + if (! $this->cancel_page_url) { |
|
| 1809 | + $this->cancel_page_url = get_permalink($this->cancel_page_id); |
|
| 1810 | + } |
|
| 1811 | + return $this->cancel_page_url; |
|
| 1812 | + } |
|
| 1813 | + |
|
| 1814 | + |
|
| 1815 | + /** |
|
| 1816 | + * Resets all critical page urls to their original state. Used primarily by the __sleep() magic method currently. |
|
| 1817 | + * |
|
| 1818 | + * @since 4.7.5 |
|
| 1819 | + */ |
|
| 1820 | + protected function _reset_urls() |
|
| 1821 | + { |
|
| 1822 | + $this->reg_page_url = ''; |
|
| 1823 | + $this->txn_page_url = ''; |
|
| 1824 | + $this->cancel_page_url = ''; |
|
| 1825 | + $this->thank_you_page_url = ''; |
|
| 1826 | + } |
|
| 1827 | + |
|
| 1828 | + |
|
| 1829 | + /** |
|
| 1830 | + * Used to return what the optin value is set for the EE User Experience Program. |
|
| 1831 | + * This accounts for multisite and this value being requested for a subsite. In multisite, the value is set |
|
| 1832 | + * on the main site only. |
|
| 1833 | + * |
|
| 1834 | + * @return bool |
|
| 1835 | + */ |
|
| 1836 | + protected function _get_main_ee_ueip_optin() |
|
| 1837 | + { |
|
| 1838 | + // if this is the main site then we can just bypass our direct query. |
|
| 1839 | + if (is_main_site()) { |
|
| 1840 | + return get_option(self::OPTION_NAME_UXIP, false); |
|
| 1841 | + } |
|
| 1842 | + // is this already cached for this request? If so use it. |
|
| 1843 | + if (EE_Core_Config::$ee_ueip_option !== null) { |
|
| 1844 | + return EE_Core_Config::$ee_ueip_option; |
|
| 1845 | + } |
|
| 1846 | + global $wpdb; |
|
| 1847 | + $current_network_main_site = is_multisite() ? get_current_site() : null; |
|
| 1848 | + $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
|
| 1849 | + $option = self::OPTION_NAME_UXIP; |
|
| 1850 | + // set correct table for query |
|
| 1851 | + $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options'; |
|
| 1852 | + // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
|
| 1853 | + // get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be |
|
| 1854 | + // re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
|
| 1855 | + // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
|
| 1856 | + // for the purpose of caching. |
|
| 1857 | + $pre = apply_filters('pre_option_' . $option, false, $option); |
|
| 1858 | + if (false !== $pre) { |
|
| 1859 | + EE_Core_Config::$ee_ueip_option = $pre; |
|
| 1860 | + return EE_Core_Config::$ee_ueip_option; |
|
| 1861 | + } |
|
| 1862 | + $row = $wpdb->get_row( |
|
| 1863 | + $wpdb->prepare( |
|
| 1864 | + "SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", |
|
| 1865 | + $option |
|
| 1866 | + ) |
|
| 1867 | + ); |
|
| 1868 | + if (is_object($row)) { |
|
| 1869 | + $value = $row->option_value; |
|
| 1870 | + } else { // option does not exist so use default. |
|
| 1871 | + EE_Core_Config::$ee_ueip_option = apply_filters('default_option_' . $option, false, $option); |
|
| 1872 | + return EE_Core_Config::$ee_ueip_option; |
|
| 1873 | + } |
|
| 1874 | + EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option); |
|
| 1875 | + return EE_Core_Config::$ee_ueip_option; |
|
| 1876 | + } |
|
| 1877 | + |
|
| 1878 | + |
|
| 1879 | + /** |
|
| 1880 | + * Utility function for escaping the value of a property and returning. |
|
| 1881 | + * |
|
| 1882 | + * @param string $property property name (checks to see if exists). |
|
| 1883 | + * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
| 1884 | + * @throws \EE_Error |
|
| 1885 | + */ |
|
| 1886 | + public function get_pretty($property) |
|
| 1887 | + { |
|
| 1888 | + if ($property === self::OPTION_NAME_UXIP) { |
|
| 1889 | + return $this->ee_ueip_optin ? 'yes' : 'no'; |
|
| 1890 | + } |
|
| 1891 | + return parent::get_pretty($property); |
|
| 1892 | + } |
|
| 1893 | + |
|
| 1894 | + |
|
| 1895 | + /** |
|
| 1896 | + * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values |
|
| 1897 | + * on the object. |
|
| 1898 | + * |
|
| 1899 | + * @return array |
|
| 1900 | + */ |
|
| 1901 | + public function __sleep() |
|
| 1902 | + { |
|
| 1903 | + // reset all url properties |
|
| 1904 | + $this->_reset_urls(); |
|
| 1905 | + // return what to save to db |
|
| 1906 | + return array_keys(get_object_vars($this)); |
|
| 1907 | + } |
|
| 1908 | +} |
|
| 2292 | 1909 | |
| 2293 | - /** |
|
| 2294 | - * array of form names protected by ReCaptcha |
|
| 2295 | - * |
|
| 2296 | - * @var array $recaptcha_protected_forms |
|
| 2297 | - */ |
|
| 2298 | - public $recaptcha_protected_forms; |
|
| 1910 | +/** |
|
| 1911 | + * Config class for storing info on the Organization |
|
| 1912 | + */ |
|
| 1913 | +class EE_Organization_Config extends EE_Config_Base |
|
| 1914 | +{ |
|
| 2299 | 1915 | |
| 2300 | - /** |
|
| 2301 | - * ReCaptcha width |
|
| 2302 | - * |
|
| 2303 | - * @var int $recaptcha_width |
|
| 2304 | - * @deprecated |
|
| 2305 | - */ |
|
| 2306 | - public $recaptcha_width; |
|
| 1916 | + /** |
|
| 1917 | + * @var string $name |
|
| 1918 | + * eg EE4.1 |
|
| 1919 | + */ |
|
| 1920 | + public $name; |
|
| 1921 | + |
|
| 1922 | + /** |
|
| 1923 | + * @var string $address_1 |
|
| 1924 | + * eg 123 Onna Road |
|
| 1925 | + */ |
|
| 1926 | + public $address_1 = ''; |
|
| 1927 | + |
|
| 1928 | + /** |
|
| 1929 | + * @var string $address_2 |
|
| 1930 | + * eg PO Box 123 |
|
| 1931 | + */ |
|
| 1932 | + public $address_2 = ''; |
|
| 1933 | + |
|
| 1934 | + /** |
|
| 1935 | + * @var string $city |
|
| 1936 | + * eg Inna City |
|
| 1937 | + */ |
|
| 1938 | + public $city = ''; |
|
| 1939 | + |
|
| 1940 | + /** |
|
| 1941 | + * @var int $STA_ID |
|
| 1942 | + * eg 4 |
|
| 1943 | + */ |
|
| 1944 | + public $STA_ID = 0; |
|
| 1945 | + |
|
| 1946 | + /** |
|
| 1947 | + * @var string $CNT_ISO |
|
| 1948 | + * eg US |
|
| 1949 | + */ |
|
| 1950 | + public $CNT_ISO = ''; |
|
| 1951 | + |
|
| 1952 | + /** |
|
| 1953 | + * @var string $zip |
|
| 1954 | + * eg 12345 or V1A 2B3 |
|
| 1955 | + */ |
|
| 1956 | + public $zip = ''; |
|
| 1957 | + |
|
| 1958 | + /** |
|
| 1959 | + * @var string $email |
|
| 1960 | + * eg [email protected] |
|
| 1961 | + */ |
|
| 1962 | + public $email; |
|
| 1963 | + |
|
| 1964 | + /** |
|
| 1965 | + * @var string $phone |
|
| 1966 | + * eg. 111-111-1111 |
|
| 1967 | + */ |
|
| 1968 | + public $phone = ''; |
|
| 1969 | + |
|
| 1970 | + /** |
|
| 1971 | + * @var string $vat |
|
| 1972 | + * VAT/Tax Number |
|
| 1973 | + */ |
|
| 1974 | + public $vat = ''; |
|
| 1975 | + |
|
| 1976 | + /** |
|
| 1977 | + * @var string $logo_url |
|
| 1978 | + * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg |
|
| 1979 | + */ |
|
| 1980 | + public $logo_url = ''; |
|
| 1981 | + |
|
| 1982 | + /** |
|
| 1983 | + * The below are all various properties for holding links to organization social network profiles |
|
| 1984 | + * |
|
| 1985 | + * @var string |
|
| 1986 | + */ |
|
| 1987 | + /** |
|
| 1988 | + * facebook (facebook.com/profile.name) |
|
| 1989 | + * |
|
| 1990 | + * @var string |
|
| 1991 | + */ |
|
| 1992 | + public $facebook = ''; |
|
| 1993 | + |
|
| 1994 | + /** |
|
| 1995 | + * twitter (twitter.com/twitter_handle) |
|
| 1996 | + * |
|
| 1997 | + * @var string |
|
| 1998 | + */ |
|
| 1999 | + public $twitter = ''; |
|
| 2000 | + |
|
| 2001 | + /** |
|
| 2002 | + * linkedin (linkedin.com/in/profile_name) |
|
| 2003 | + * |
|
| 2004 | + * @var string |
|
| 2005 | + */ |
|
| 2006 | + public $linkedin = ''; |
|
| 2007 | + |
|
| 2008 | + /** |
|
| 2009 | + * pinterest (www.pinterest.com/profile_name) |
|
| 2010 | + * |
|
| 2011 | + * @var string |
|
| 2012 | + */ |
|
| 2013 | + public $pinterest = ''; |
|
| 2014 | + |
|
| 2015 | + /** |
|
| 2016 | + * google+ (google.com/+profileName) |
|
| 2017 | + * |
|
| 2018 | + * @var string |
|
| 2019 | + */ |
|
| 2020 | + public $google = ''; |
|
| 2021 | + |
|
| 2022 | + /** |
|
| 2023 | + * instagram (instagram.com/handle) |
|
| 2024 | + * |
|
| 2025 | + * @var string |
|
| 2026 | + */ |
|
| 2027 | + public $instagram = ''; |
|
| 2028 | + |
|
| 2029 | + |
|
| 2030 | + /** |
|
| 2031 | + * class constructor |
|
| 2032 | + * |
|
| 2033 | + * @access public |
|
| 2034 | + */ |
|
| 2035 | + public function __construct() |
|
| 2036 | + { |
|
| 2037 | + // set default organization settings |
|
| 2038 | + // decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded |
|
| 2039 | + $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); |
|
| 2040 | + $this->email = get_bloginfo('admin_email'); |
|
| 2041 | + } |
|
| 2042 | +} |
|
| 2307 | 2043 | |
| 2308 | - /** |
|
| 2309 | - * Whether or not invalid attempts to directly access the registration checkout page should be tracked. |
|
| 2310 | - * |
|
| 2311 | - * @var boolean $track_invalid_checkout_access |
|
| 2312 | - */ |
|
| 2313 | - protected $track_invalid_checkout_access = true; |
|
| 2044 | +/** |
|
| 2045 | + * Class for defining what's in the EE_Config relating to currency |
|
| 2046 | + */ |
|
| 2047 | +class EE_Currency_Config extends EE_Config_Base |
|
| 2048 | +{ |
|
| 2314 | 2049 | |
| 2315 | - /** |
|
| 2316 | - * Whether or not to show the privacy policy consent checkbox |
|
| 2317 | - * |
|
| 2318 | - * @var bool |
|
| 2319 | - */ |
|
| 2320 | - public $consent_checkbox_enabled; |
|
| 2050 | + /** |
|
| 2051 | + * @var string $code |
|
| 2052 | + * eg 'US' |
|
| 2053 | + */ |
|
| 2054 | + public $code; |
|
| 2055 | + |
|
| 2056 | + /** |
|
| 2057 | + * @var string $name |
|
| 2058 | + * eg 'Dollar' |
|
| 2059 | + */ |
|
| 2060 | + public $name; |
|
| 2061 | + |
|
| 2062 | + /** |
|
| 2063 | + * plural name |
|
| 2064 | + * |
|
| 2065 | + * @var string $plural |
|
| 2066 | + * eg 'Dollars' |
|
| 2067 | + */ |
|
| 2068 | + public $plural; |
|
| 2069 | + |
|
| 2070 | + /** |
|
| 2071 | + * currency sign |
|
| 2072 | + * |
|
| 2073 | + * @var string $sign |
|
| 2074 | + * eg '$' |
|
| 2075 | + */ |
|
| 2076 | + public $sign; |
|
| 2077 | + |
|
| 2078 | + /** |
|
| 2079 | + * Whether the currency sign should come before the number or not |
|
| 2080 | + * |
|
| 2081 | + * @var boolean $sign_b4 |
|
| 2082 | + */ |
|
| 2083 | + public $sign_b4; |
|
| 2084 | + |
|
| 2085 | + /** |
|
| 2086 | + * How many digits should come after the decimal place |
|
| 2087 | + * |
|
| 2088 | + * @var int $dec_plc |
|
| 2089 | + */ |
|
| 2090 | + public $dec_plc; |
|
| 2091 | + |
|
| 2092 | + /** |
|
| 2093 | + * Symbol to use for decimal mark |
|
| 2094 | + * |
|
| 2095 | + * @var string $dec_mrk |
|
| 2096 | + * eg '.' |
|
| 2097 | + */ |
|
| 2098 | + public $dec_mrk; |
|
| 2099 | + |
|
| 2100 | + /** |
|
| 2101 | + * Symbol to use for thousands |
|
| 2102 | + * |
|
| 2103 | + * @var string $thsnds |
|
| 2104 | + * eg ',' |
|
| 2105 | + */ |
|
| 2106 | + public $thsnds; |
|
| 2107 | + |
|
| 2108 | + |
|
| 2109 | + /** |
|
| 2110 | + * class constructor |
|
| 2111 | + * |
|
| 2112 | + * @access public |
|
| 2113 | + * @param string $CNT_ISO |
|
| 2114 | + * @throws \EE_Error |
|
| 2115 | + */ |
|
| 2116 | + public function __construct($CNT_ISO = '') |
|
| 2117 | + { |
|
| 2118 | + /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */ |
|
| 2119 | + $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
| 2120 | + // get country code from organization settings or use default |
|
| 2121 | + $ORG_CNT = isset(EE_Registry::instance()->CFG->organization) |
|
| 2122 | + && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config |
|
| 2123 | + ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
| 2124 | + : ''; |
|
| 2125 | + // but override if requested |
|
| 2126 | + $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
|
| 2127 | + // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
|
| 2128 | + if (! empty($CNT_ISO) |
|
| 2129 | + && EE_Maintenance_Mode::instance()->models_can_query() |
|
| 2130 | + && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table()) |
|
| 2131 | + ) { |
|
| 2132 | + // retrieve the country settings from the db, just in case they have been customized |
|
| 2133 | + $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
|
| 2134 | + if ($country instanceof EE_Country) { |
|
| 2135 | + $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
| 2136 | + $this->name = $country->currency_name_single(); // Dollar |
|
| 2137 | + $this->plural = $country->currency_name_plural(); // Dollars |
|
| 2138 | + $this->sign = $country->currency_sign(); // currency sign: $ |
|
| 2139 | + $this->sign_b4 = $country->currency_sign_before( |
|
| 2140 | + ); // currency sign before or after: $TRUE or FALSE$ |
|
| 2141 | + $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
| 2142 | + $this->dec_mrk = $country->currency_decimal_mark( |
|
| 2143 | + ); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 2144 | + $this->thsnds = $country->currency_thousands_separator( |
|
| 2145 | + ); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 2146 | + } |
|
| 2147 | + } |
|
| 2148 | + // fallback to hardcoded defaults, in case the above failed |
|
| 2149 | + if (empty($this->code)) { |
|
| 2150 | + // set default currency settings |
|
| 2151 | + $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
| 2152 | + $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
| 2153 | + $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
| 2154 | + $this->sign = '$'; // currency sign: $ |
|
| 2155 | + $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
| 2156 | + $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
| 2157 | + $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 2158 | + $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 2159 | + } |
|
| 2160 | + } |
|
| 2161 | +} |
|
| 2321 | 2162 | |
| 2322 | - /** |
|
| 2323 | - * Label text to show on the checkbox |
|
| 2324 | - * |
|
| 2325 | - * @var string |
|
| 2326 | - */ |
|
| 2327 | - public $consent_checkbox_label_text; |
|
| 2163 | +/** |
|
| 2164 | + * Class for defining what's in the EE_Config relating to registration settings |
|
| 2165 | + */ |
|
| 2166 | +class EE_Registration_Config extends EE_Config_Base |
|
| 2167 | +{ |
|
| 2328 | 2168 | |
| 2329 | - /* |
|
| 2169 | + /** |
|
| 2170 | + * Default registration status |
|
| 2171 | + * |
|
| 2172 | + * @var string $default_STS_ID |
|
| 2173 | + * eg 'RPP' |
|
| 2174 | + */ |
|
| 2175 | + public $default_STS_ID; |
|
| 2176 | + |
|
| 2177 | + /** |
|
| 2178 | + * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of |
|
| 2179 | + * registrations) |
|
| 2180 | + * |
|
| 2181 | + * @var int |
|
| 2182 | + */ |
|
| 2183 | + public $default_maximum_number_of_tickets; |
|
| 2184 | + |
|
| 2185 | + /** |
|
| 2186 | + * level of validation to apply to email addresses |
|
| 2187 | + * |
|
| 2188 | + * @var string $email_validation_level |
|
| 2189 | + * options: 'basic', 'wp_default', 'i18n', 'i18n_dns' |
|
| 2190 | + */ |
|
| 2191 | + public $email_validation_level; |
|
| 2192 | + |
|
| 2193 | + /** |
|
| 2194 | + * whether or not to show alternate payment options during the reg process if payment status is pending |
|
| 2195 | + * |
|
| 2196 | + * @var boolean $show_pending_payment_options |
|
| 2197 | + */ |
|
| 2198 | + public $show_pending_payment_options; |
|
| 2199 | + |
|
| 2200 | + /** |
|
| 2201 | + * Whether to skip the registration confirmation page |
|
| 2202 | + * |
|
| 2203 | + * @var boolean $skip_reg_confirmation |
|
| 2204 | + */ |
|
| 2205 | + public $skip_reg_confirmation; |
|
| 2206 | + |
|
| 2207 | + /** |
|
| 2208 | + * an array of SPCO reg steps where: |
|
| 2209 | + * the keys denotes the reg step order |
|
| 2210 | + * each element consists of an array with the following elements: |
|
| 2211 | + * "file_path" => the file path to the EE_SPCO_Reg_Step class |
|
| 2212 | + * "class_name" => the specific EE_SPCO_Reg_Step child class name |
|
| 2213 | + * "slug" => the URL param used to trigger the reg step |
|
| 2214 | + * |
|
| 2215 | + * @var array $reg_steps |
|
| 2216 | + */ |
|
| 2217 | + public $reg_steps; |
|
| 2218 | + |
|
| 2219 | + /** |
|
| 2220 | + * Whether registration confirmation should be the last page of SPCO |
|
| 2221 | + * |
|
| 2222 | + * @var boolean $reg_confirmation_last |
|
| 2223 | + */ |
|
| 2224 | + public $reg_confirmation_last; |
|
| 2225 | + |
|
| 2226 | + /** |
|
| 2227 | + * Whether or not to enable the EE Bot Trap |
|
| 2228 | + * |
|
| 2229 | + * @var boolean $use_bot_trap |
|
| 2230 | + */ |
|
| 2231 | + public $use_bot_trap; |
|
| 2232 | + |
|
| 2233 | + /** |
|
| 2234 | + * Whether or not to encrypt some data sent by the EE Bot Trap |
|
| 2235 | + * |
|
| 2236 | + * @var boolean $use_encryption |
|
| 2237 | + */ |
|
| 2238 | + public $use_encryption; |
|
| 2239 | + |
|
| 2240 | + /** |
|
| 2241 | + * Whether or not to use ReCaptcha |
|
| 2242 | + * |
|
| 2243 | + * @var boolean $use_captcha |
|
| 2244 | + */ |
|
| 2245 | + public $use_captcha; |
|
| 2246 | + |
|
| 2247 | + /** |
|
| 2248 | + * ReCaptcha Theme |
|
| 2249 | + * |
|
| 2250 | + * @var string $recaptcha_theme |
|
| 2251 | + * options: 'dark', 'light', 'invisible' |
|
| 2252 | + */ |
|
| 2253 | + public $recaptcha_theme; |
|
| 2254 | + |
|
| 2255 | + /** |
|
| 2256 | + * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha. |
|
| 2257 | + * |
|
| 2258 | + * @var string $recaptcha_badge |
|
| 2259 | + * options: 'bottomright', 'bottomleft', 'inline' |
|
| 2260 | + */ |
|
| 2261 | + public $recaptcha_badge; |
|
| 2262 | + |
|
| 2263 | + /** |
|
| 2264 | + * ReCaptcha Type |
|
| 2265 | + * |
|
| 2266 | + * @var string $recaptcha_type |
|
| 2267 | + * options: 'audio', 'image' |
|
| 2268 | + */ |
|
| 2269 | + public $recaptcha_type; |
|
| 2270 | + |
|
| 2271 | + /** |
|
| 2272 | + * ReCaptcha language |
|
| 2273 | + * |
|
| 2274 | + * @var string $recaptcha_language |
|
| 2275 | + * eg 'en' |
|
| 2276 | + */ |
|
| 2277 | + public $recaptcha_language; |
|
| 2278 | + |
|
| 2279 | + /** |
|
| 2280 | + * ReCaptcha public key |
|
| 2281 | + * |
|
| 2282 | + * @var string $recaptcha_publickey |
|
| 2283 | + */ |
|
| 2284 | + public $recaptcha_publickey; |
|
| 2285 | + |
|
| 2286 | + /** |
|
| 2287 | + * ReCaptcha private key |
|
| 2288 | + * |
|
| 2289 | + * @var string $recaptcha_privatekey |
|
| 2290 | + */ |
|
| 2291 | + public $recaptcha_privatekey; |
|
| 2292 | + |
|
| 2293 | + /** |
|
| 2294 | + * array of form names protected by ReCaptcha |
|
| 2295 | + * |
|
| 2296 | + * @var array $recaptcha_protected_forms |
|
| 2297 | + */ |
|
| 2298 | + public $recaptcha_protected_forms; |
|
| 2299 | + |
|
| 2300 | + /** |
|
| 2301 | + * ReCaptcha width |
|
| 2302 | + * |
|
| 2303 | + * @var int $recaptcha_width |
|
| 2304 | + * @deprecated |
|
| 2305 | + */ |
|
| 2306 | + public $recaptcha_width; |
|
| 2307 | + |
|
| 2308 | + /** |
|
| 2309 | + * Whether or not invalid attempts to directly access the registration checkout page should be tracked. |
|
| 2310 | + * |
|
| 2311 | + * @var boolean $track_invalid_checkout_access |
|
| 2312 | + */ |
|
| 2313 | + protected $track_invalid_checkout_access = true; |
|
| 2314 | + |
|
| 2315 | + /** |
|
| 2316 | + * Whether or not to show the privacy policy consent checkbox |
|
| 2317 | + * |
|
| 2318 | + * @var bool |
|
| 2319 | + */ |
|
| 2320 | + public $consent_checkbox_enabled; |
|
| 2321 | + |
|
| 2322 | + /** |
|
| 2323 | + * Label text to show on the checkbox |
|
| 2324 | + * |
|
| 2325 | + * @var string |
|
| 2326 | + */ |
|
| 2327 | + public $consent_checkbox_label_text; |
|
| 2328 | + |
|
| 2329 | + /* |
|
| 2330 | 2330 | * String describing how long to keep payment logs. Passed into DateTime constructor |
| 2331 | 2331 | * @var string |
| 2332 | 2332 | */ |
| 2333 | - public $gateway_log_lifespan = '1 week'; |
|
| 2334 | - |
|
| 2335 | - /** |
|
| 2336 | - * Enable copy attendee info at form |
|
| 2337 | - * |
|
| 2338 | - * @var boolean $enable_copy_attendee |
|
| 2339 | - */ |
|
| 2340 | - protected $copy_attendee_info = true; |
|
| 2341 | - |
|
| 2342 | - |
|
| 2343 | - /** |
|
| 2344 | - * class constructor |
|
| 2345 | - * |
|
| 2346 | - * @access public |
|
| 2347 | - */ |
|
| 2348 | - public function __construct() |
|
| 2349 | - { |
|
| 2350 | - // set default registration settings |
|
| 2351 | - $this->default_STS_ID = EEM_Registration::status_id_pending_payment; |
|
| 2352 | - $this->email_validation_level = 'wp_default'; |
|
| 2353 | - $this->show_pending_payment_options = true; |
|
| 2354 | - $this->skip_reg_confirmation = true; |
|
| 2355 | - $this->reg_steps = array(); |
|
| 2356 | - $this->reg_confirmation_last = false; |
|
| 2357 | - $this->use_bot_trap = true; |
|
| 2358 | - $this->use_encryption = true; |
|
| 2359 | - $this->use_captcha = false; |
|
| 2360 | - $this->recaptcha_theme = 'light'; |
|
| 2361 | - $this->recaptcha_badge = 'bottomleft'; |
|
| 2362 | - $this->recaptcha_type = 'image'; |
|
| 2363 | - $this->recaptcha_language = 'en'; |
|
| 2364 | - $this->recaptcha_publickey = null; |
|
| 2365 | - $this->recaptcha_privatekey = null; |
|
| 2366 | - $this->recaptcha_protected_forms = array(); |
|
| 2367 | - $this->recaptcha_width = 500; |
|
| 2368 | - $this->default_maximum_number_of_tickets = 10; |
|
| 2369 | - $this->consent_checkbox_enabled = false; |
|
| 2370 | - $this->consent_checkbox_label_text = ''; |
|
| 2371 | - $this->gateway_log_lifespan = '7 days'; |
|
| 2372 | - $this->copy_attendee_info = true; |
|
| 2373 | - } |
|
| 2374 | - |
|
| 2375 | - |
|
| 2376 | - /** |
|
| 2377 | - * This is called by the config loader and hooks are initialized AFTER the config has been populated. |
|
| 2378 | - * |
|
| 2379 | - * @since 4.8.8.rc.019 |
|
| 2380 | - */ |
|
| 2381 | - public function do_hooks() |
|
| 2382 | - { |
|
| 2383 | - add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event')); |
|
| 2384 | - add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event')); |
|
| 2385 | - add_action('setup_theme', array($this, 'setDefaultCheckboxLabelText')); |
|
| 2386 | - } |
|
| 2387 | - |
|
| 2388 | - |
|
| 2389 | - /** |
|
| 2390 | - * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the |
|
| 2391 | - * EVT_default_registration_status field matches the config setting for default_STS_ID. |
|
| 2392 | - */ |
|
| 2393 | - public function set_default_reg_status_on_EEM_Event() |
|
| 2394 | - { |
|
| 2395 | - EEM_Event::set_default_reg_status($this->default_STS_ID); |
|
| 2396 | - } |
|
| 2397 | - |
|
| 2398 | - |
|
| 2399 | - /** |
|
| 2400 | - * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field |
|
| 2401 | - * for Events matches the config setting for default_maximum_number_of_tickets |
|
| 2402 | - */ |
|
| 2403 | - public function set_default_max_ticket_on_EEM_Event() |
|
| 2404 | - { |
|
| 2405 | - EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets); |
|
| 2406 | - } |
|
| 2407 | - |
|
| 2408 | - |
|
| 2409 | - /** |
|
| 2410 | - * Sets the default consent checkbox text. This needs to be done a bit later than when EE_Registration_Config is |
|
| 2411 | - * constructed because that happens before we can get the privacy policy page's permalink. |
|
| 2412 | - * |
|
| 2413 | - * @throws InvalidArgumentException |
|
| 2414 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2415 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2416 | - */ |
|
| 2417 | - public function setDefaultCheckboxLabelText() |
|
| 2418 | - { |
|
| 2419 | - if ($this->getConsentCheckboxLabelText() === null |
|
| 2420 | - || $this->getConsentCheckboxLabelText() === '') { |
|
| 2421 | - $opening_a_tag = ''; |
|
| 2422 | - $closing_a_tag = ''; |
|
| 2423 | - if (function_exists('get_privacy_policy_url')) { |
|
| 2424 | - $privacy_page_url = get_privacy_policy_url(); |
|
| 2425 | - if (! empty($privacy_page_url)) { |
|
| 2426 | - $opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">'; |
|
| 2427 | - $closing_a_tag = '</a>'; |
|
| 2428 | - } |
|
| 2429 | - } |
|
| 2430 | - $loader = LoaderFactory::getLoader(); |
|
| 2431 | - $org_config = $loader->getShared('EE_Organization_Config'); |
|
| 2432 | - /** |
|
| 2433 | - * @var $org_config EE_Organization_Config |
|
| 2434 | - */ |
|
| 2435 | - |
|
| 2436 | - $this->setConsentCheckboxLabelText( |
|
| 2437 | - sprintf( |
|
| 2438 | - esc_html__( |
|
| 2439 | - 'I consent to %1$s storing and using my personal information, according to their %2$sprivacy policy%3$s.', |
|
| 2440 | - 'event_espresso' |
|
| 2441 | - ), |
|
| 2442 | - $org_config->name, |
|
| 2443 | - $opening_a_tag, |
|
| 2444 | - $closing_a_tag |
|
| 2445 | - ) |
|
| 2446 | - ); |
|
| 2447 | - } |
|
| 2448 | - } |
|
| 2449 | - |
|
| 2450 | - |
|
| 2451 | - /** |
|
| 2452 | - * @return boolean |
|
| 2453 | - */ |
|
| 2454 | - public function track_invalid_checkout_access() |
|
| 2455 | - { |
|
| 2456 | - return $this->track_invalid_checkout_access; |
|
| 2457 | - } |
|
| 2458 | - |
|
| 2459 | - |
|
| 2460 | - /** |
|
| 2461 | - * @param boolean $track_invalid_checkout_access |
|
| 2462 | - */ |
|
| 2463 | - public function set_track_invalid_checkout_access($track_invalid_checkout_access) |
|
| 2464 | - { |
|
| 2465 | - $this->track_invalid_checkout_access = filter_var( |
|
| 2466 | - $track_invalid_checkout_access, |
|
| 2467 | - FILTER_VALIDATE_BOOLEAN |
|
| 2468 | - ); |
|
| 2469 | - } |
|
| 2470 | - |
|
| 2471 | - /** |
|
| 2472 | - * @return boolean |
|
| 2473 | - */ |
|
| 2474 | - public function copyAttendeeInfo() |
|
| 2475 | - { |
|
| 2476 | - return $this->copy_attendee_info; |
|
| 2477 | - } |
|
| 2478 | - |
|
| 2479 | - |
|
| 2480 | - /** |
|
| 2481 | - * @param boolean $copy_attendee_info |
|
| 2482 | - */ |
|
| 2483 | - public function setCopyAttendeeInfo($copy_attendee_info) |
|
| 2484 | - { |
|
| 2485 | - $this->copy_attendee_info = filter_var( |
|
| 2486 | - $copy_attendee_info, |
|
| 2487 | - FILTER_VALIDATE_BOOLEAN |
|
| 2488 | - ); |
|
| 2489 | - } |
|
| 2490 | - |
|
| 2491 | - |
|
| 2492 | - /** |
|
| 2493 | - * Gets the options to make availalbe for the gateway log lifespan |
|
| 2494 | - * @return array |
|
| 2495 | - */ |
|
| 2496 | - public function gatewayLogLifespanOptions() |
|
| 2497 | - { |
|
| 2498 | - return (array) apply_filters( |
|
| 2499 | - 'FHEE_EE_Admin_Config__gatewayLogLifespanOptions', |
|
| 2500 | - array( |
|
| 2501 | - '1 second' => esc_html__('Don\'t Log At All', 'event_espresso'), |
|
| 2502 | - '1 day' => esc_html__('1 Day', 'event_espresso'), |
|
| 2503 | - '7 days' => esc_html__('7 Days', 'event_espresso'), |
|
| 2504 | - '14 days' => esc_html__('14 Days', 'event_espresso'), |
|
| 2505 | - '30 days' => esc_html__('30 Days', 'event_espresso') |
|
| 2506 | - ) |
|
| 2507 | - ); |
|
| 2508 | - } |
|
| 2509 | - |
|
| 2510 | - |
|
| 2511 | - /** |
|
| 2512 | - * @return bool |
|
| 2513 | - */ |
|
| 2514 | - public function isConsentCheckboxEnabled() |
|
| 2515 | - { |
|
| 2516 | - return $this->consent_checkbox_enabled; |
|
| 2517 | - } |
|
| 2518 | - |
|
| 2519 | - |
|
| 2520 | - /** |
|
| 2521 | - * @param bool $consent_checkbox_enabled |
|
| 2522 | - */ |
|
| 2523 | - public function setConsentCheckboxEnabled($consent_checkbox_enabled) |
|
| 2524 | - { |
|
| 2525 | - $this->consent_checkbox_enabled = filter_var( |
|
| 2526 | - $consent_checkbox_enabled, |
|
| 2527 | - FILTER_VALIDATE_BOOLEAN |
|
| 2528 | - ); |
|
| 2529 | - } |
|
| 2530 | - |
|
| 2531 | - |
|
| 2532 | - /** |
|
| 2533 | - * @return string |
|
| 2534 | - */ |
|
| 2535 | - public function getConsentCheckboxLabelText() |
|
| 2536 | - { |
|
| 2537 | - return $this->consent_checkbox_label_text; |
|
| 2538 | - } |
|
| 2539 | - |
|
| 2540 | - |
|
| 2541 | - /** |
|
| 2542 | - * @param string $consent_checkbox_label_text |
|
| 2543 | - */ |
|
| 2544 | - public function setConsentCheckboxLabelText($consent_checkbox_label_text) |
|
| 2545 | - { |
|
| 2546 | - $this->consent_checkbox_label_text = (string) $consent_checkbox_label_text; |
|
| 2547 | - } |
|
| 2333 | + public $gateway_log_lifespan = '1 week'; |
|
| 2334 | + |
|
| 2335 | + /** |
|
| 2336 | + * Enable copy attendee info at form |
|
| 2337 | + * |
|
| 2338 | + * @var boolean $enable_copy_attendee |
|
| 2339 | + */ |
|
| 2340 | + protected $copy_attendee_info = true; |
|
| 2341 | + |
|
| 2342 | + |
|
| 2343 | + /** |
|
| 2344 | + * class constructor |
|
| 2345 | + * |
|
| 2346 | + * @access public |
|
| 2347 | + */ |
|
| 2348 | + public function __construct() |
|
| 2349 | + { |
|
| 2350 | + // set default registration settings |
|
| 2351 | + $this->default_STS_ID = EEM_Registration::status_id_pending_payment; |
|
| 2352 | + $this->email_validation_level = 'wp_default'; |
|
| 2353 | + $this->show_pending_payment_options = true; |
|
| 2354 | + $this->skip_reg_confirmation = true; |
|
| 2355 | + $this->reg_steps = array(); |
|
| 2356 | + $this->reg_confirmation_last = false; |
|
| 2357 | + $this->use_bot_trap = true; |
|
| 2358 | + $this->use_encryption = true; |
|
| 2359 | + $this->use_captcha = false; |
|
| 2360 | + $this->recaptcha_theme = 'light'; |
|
| 2361 | + $this->recaptcha_badge = 'bottomleft'; |
|
| 2362 | + $this->recaptcha_type = 'image'; |
|
| 2363 | + $this->recaptcha_language = 'en'; |
|
| 2364 | + $this->recaptcha_publickey = null; |
|
| 2365 | + $this->recaptcha_privatekey = null; |
|
| 2366 | + $this->recaptcha_protected_forms = array(); |
|
| 2367 | + $this->recaptcha_width = 500; |
|
| 2368 | + $this->default_maximum_number_of_tickets = 10; |
|
| 2369 | + $this->consent_checkbox_enabled = false; |
|
| 2370 | + $this->consent_checkbox_label_text = ''; |
|
| 2371 | + $this->gateway_log_lifespan = '7 days'; |
|
| 2372 | + $this->copy_attendee_info = true; |
|
| 2373 | + } |
|
| 2374 | + |
|
| 2375 | + |
|
| 2376 | + /** |
|
| 2377 | + * This is called by the config loader and hooks are initialized AFTER the config has been populated. |
|
| 2378 | + * |
|
| 2379 | + * @since 4.8.8.rc.019 |
|
| 2380 | + */ |
|
| 2381 | + public function do_hooks() |
|
| 2382 | + { |
|
| 2383 | + add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event')); |
|
| 2384 | + add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event')); |
|
| 2385 | + add_action('setup_theme', array($this, 'setDefaultCheckboxLabelText')); |
|
| 2386 | + } |
|
| 2387 | + |
|
| 2388 | + |
|
| 2389 | + /** |
|
| 2390 | + * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the |
|
| 2391 | + * EVT_default_registration_status field matches the config setting for default_STS_ID. |
|
| 2392 | + */ |
|
| 2393 | + public function set_default_reg_status_on_EEM_Event() |
|
| 2394 | + { |
|
| 2395 | + EEM_Event::set_default_reg_status($this->default_STS_ID); |
|
| 2396 | + } |
|
| 2397 | + |
|
| 2398 | + |
|
| 2399 | + /** |
|
| 2400 | + * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field |
|
| 2401 | + * for Events matches the config setting for default_maximum_number_of_tickets |
|
| 2402 | + */ |
|
| 2403 | + public function set_default_max_ticket_on_EEM_Event() |
|
| 2404 | + { |
|
| 2405 | + EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets); |
|
| 2406 | + } |
|
| 2407 | + |
|
| 2408 | + |
|
| 2409 | + /** |
|
| 2410 | + * Sets the default consent checkbox text. This needs to be done a bit later than when EE_Registration_Config is |
|
| 2411 | + * constructed because that happens before we can get the privacy policy page's permalink. |
|
| 2412 | + * |
|
| 2413 | + * @throws InvalidArgumentException |
|
| 2414 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 2415 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 2416 | + */ |
|
| 2417 | + public function setDefaultCheckboxLabelText() |
|
| 2418 | + { |
|
| 2419 | + if ($this->getConsentCheckboxLabelText() === null |
|
| 2420 | + || $this->getConsentCheckboxLabelText() === '') { |
|
| 2421 | + $opening_a_tag = ''; |
|
| 2422 | + $closing_a_tag = ''; |
|
| 2423 | + if (function_exists('get_privacy_policy_url')) { |
|
| 2424 | + $privacy_page_url = get_privacy_policy_url(); |
|
| 2425 | + if (! empty($privacy_page_url)) { |
|
| 2426 | + $opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">'; |
|
| 2427 | + $closing_a_tag = '</a>'; |
|
| 2428 | + } |
|
| 2429 | + } |
|
| 2430 | + $loader = LoaderFactory::getLoader(); |
|
| 2431 | + $org_config = $loader->getShared('EE_Organization_Config'); |
|
| 2432 | + /** |
|
| 2433 | + * @var $org_config EE_Organization_Config |
|
| 2434 | + */ |
|
| 2435 | + |
|
| 2436 | + $this->setConsentCheckboxLabelText( |
|
| 2437 | + sprintf( |
|
| 2438 | + esc_html__( |
|
| 2439 | + 'I consent to %1$s storing and using my personal information, according to their %2$sprivacy policy%3$s.', |
|
| 2440 | + 'event_espresso' |
|
| 2441 | + ), |
|
| 2442 | + $org_config->name, |
|
| 2443 | + $opening_a_tag, |
|
| 2444 | + $closing_a_tag |
|
| 2445 | + ) |
|
| 2446 | + ); |
|
| 2447 | + } |
|
| 2448 | + } |
|
| 2449 | + |
|
| 2450 | + |
|
| 2451 | + /** |
|
| 2452 | + * @return boolean |
|
| 2453 | + */ |
|
| 2454 | + public function track_invalid_checkout_access() |
|
| 2455 | + { |
|
| 2456 | + return $this->track_invalid_checkout_access; |
|
| 2457 | + } |
|
| 2458 | + |
|
| 2459 | + |
|
| 2460 | + /** |
|
| 2461 | + * @param boolean $track_invalid_checkout_access |
|
| 2462 | + */ |
|
| 2463 | + public function set_track_invalid_checkout_access($track_invalid_checkout_access) |
|
| 2464 | + { |
|
| 2465 | + $this->track_invalid_checkout_access = filter_var( |
|
| 2466 | + $track_invalid_checkout_access, |
|
| 2467 | + FILTER_VALIDATE_BOOLEAN |
|
| 2468 | + ); |
|
| 2469 | + } |
|
| 2470 | + |
|
| 2471 | + /** |
|
| 2472 | + * @return boolean |
|
| 2473 | + */ |
|
| 2474 | + public function copyAttendeeInfo() |
|
| 2475 | + { |
|
| 2476 | + return $this->copy_attendee_info; |
|
| 2477 | + } |
|
| 2478 | + |
|
| 2479 | + |
|
| 2480 | + /** |
|
| 2481 | + * @param boolean $copy_attendee_info |
|
| 2482 | + */ |
|
| 2483 | + public function setCopyAttendeeInfo($copy_attendee_info) |
|
| 2484 | + { |
|
| 2485 | + $this->copy_attendee_info = filter_var( |
|
| 2486 | + $copy_attendee_info, |
|
| 2487 | + FILTER_VALIDATE_BOOLEAN |
|
| 2488 | + ); |
|
| 2489 | + } |
|
| 2490 | + |
|
| 2491 | + |
|
| 2492 | + /** |
|
| 2493 | + * Gets the options to make availalbe for the gateway log lifespan |
|
| 2494 | + * @return array |
|
| 2495 | + */ |
|
| 2496 | + public function gatewayLogLifespanOptions() |
|
| 2497 | + { |
|
| 2498 | + return (array) apply_filters( |
|
| 2499 | + 'FHEE_EE_Admin_Config__gatewayLogLifespanOptions', |
|
| 2500 | + array( |
|
| 2501 | + '1 second' => esc_html__('Don\'t Log At All', 'event_espresso'), |
|
| 2502 | + '1 day' => esc_html__('1 Day', 'event_espresso'), |
|
| 2503 | + '7 days' => esc_html__('7 Days', 'event_espresso'), |
|
| 2504 | + '14 days' => esc_html__('14 Days', 'event_espresso'), |
|
| 2505 | + '30 days' => esc_html__('30 Days', 'event_espresso') |
|
| 2506 | + ) |
|
| 2507 | + ); |
|
| 2508 | + } |
|
| 2509 | + |
|
| 2510 | + |
|
| 2511 | + /** |
|
| 2512 | + * @return bool |
|
| 2513 | + */ |
|
| 2514 | + public function isConsentCheckboxEnabled() |
|
| 2515 | + { |
|
| 2516 | + return $this->consent_checkbox_enabled; |
|
| 2517 | + } |
|
| 2518 | + |
|
| 2519 | + |
|
| 2520 | + /** |
|
| 2521 | + * @param bool $consent_checkbox_enabled |
|
| 2522 | + */ |
|
| 2523 | + public function setConsentCheckboxEnabled($consent_checkbox_enabled) |
|
| 2524 | + { |
|
| 2525 | + $this->consent_checkbox_enabled = filter_var( |
|
| 2526 | + $consent_checkbox_enabled, |
|
| 2527 | + FILTER_VALIDATE_BOOLEAN |
|
| 2528 | + ); |
|
| 2529 | + } |
|
| 2530 | + |
|
| 2531 | + |
|
| 2532 | + /** |
|
| 2533 | + * @return string |
|
| 2534 | + */ |
|
| 2535 | + public function getConsentCheckboxLabelText() |
|
| 2536 | + { |
|
| 2537 | + return $this->consent_checkbox_label_text; |
|
| 2538 | + } |
|
| 2539 | + |
|
| 2540 | + |
|
| 2541 | + /** |
|
| 2542 | + * @param string $consent_checkbox_label_text |
|
| 2543 | + */ |
|
| 2544 | + public function setConsentCheckboxLabelText($consent_checkbox_label_text) |
|
| 2545 | + { |
|
| 2546 | + $this->consent_checkbox_label_text = (string) $consent_checkbox_label_text; |
|
| 2547 | + } |
|
| 2548 | 2548 | } |
| 2549 | 2549 | |
| 2550 | 2550 | /** |
@@ -2553,151 +2553,151 @@ discard block |
||
| 2553 | 2553 | class EE_Admin_Config extends EE_Config_Base |
| 2554 | 2554 | { |
| 2555 | 2555 | |
| 2556 | - /** |
|
| 2557 | - * @var boolean $use_personnel_manager |
|
| 2558 | - */ |
|
| 2559 | - public $use_personnel_manager; |
|
| 2560 | - |
|
| 2561 | - /** |
|
| 2562 | - * @var boolean $use_dashboard_widget |
|
| 2563 | - */ |
|
| 2564 | - public $use_dashboard_widget; |
|
| 2565 | - |
|
| 2566 | - /** |
|
| 2567 | - * @var int $events_in_dashboard |
|
| 2568 | - */ |
|
| 2569 | - public $events_in_dashboard; |
|
| 2570 | - |
|
| 2571 | - /** |
|
| 2572 | - * @var boolean $use_event_timezones |
|
| 2573 | - */ |
|
| 2574 | - public $use_event_timezones; |
|
| 2575 | - |
|
| 2576 | - /** |
|
| 2577 | - * @var string $log_file_name |
|
| 2578 | - */ |
|
| 2579 | - public $log_file_name; |
|
| 2580 | - |
|
| 2581 | - /** |
|
| 2582 | - * @var string $debug_file_name |
|
| 2583 | - */ |
|
| 2584 | - public $debug_file_name; |
|
| 2585 | - |
|
| 2586 | - /** |
|
| 2587 | - * @var boolean $use_remote_logging |
|
| 2588 | - */ |
|
| 2589 | - public $use_remote_logging; |
|
| 2590 | - |
|
| 2591 | - /** |
|
| 2592 | - * @var string $remote_logging_url |
|
| 2593 | - */ |
|
| 2594 | - public $remote_logging_url; |
|
| 2595 | - |
|
| 2596 | - /** |
|
| 2597 | - * @var boolean $show_reg_footer |
|
| 2598 | - */ |
|
| 2599 | - public $show_reg_footer; |
|
| 2600 | - |
|
| 2601 | - /** |
|
| 2602 | - * @var string $affiliate_id |
|
| 2603 | - */ |
|
| 2604 | - public $affiliate_id; |
|
| 2605 | - |
|
| 2606 | - /** |
|
| 2607 | - * help tours on or off (global setting) |
|
| 2608 | - * |
|
| 2609 | - * @var boolean |
|
| 2610 | - */ |
|
| 2611 | - public $help_tour_activation; |
|
| 2612 | - |
|
| 2613 | - /** |
|
| 2614 | - * adds extra layer of encoding to session data to prevent serialization errors |
|
| 2615 | - * but is incompatible with some server configuration errors |
|
| 2616 | - * if you get "500 internal server errors" during registration, try turning this on |
|
| 2617 | - * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off |
|
| 2618 | - * |
|
| 2619 | - * @var boolean $encode_session_data |
|
| 2620 | - */ |
|
| 2621 | - private $encode_session_data = false; |
|
| 2622 | - |
|
| 2623 | - |
|
| 2624 | - /** |
|
| 2625 | - * class constructor |
|
| 2626 | - * |
|
| 2627 | - * @access public |
|
| 2628 | - */ |
|
| 2629 | - public function __construct() |
|
| 2630 | - { |
|
| 2631 | - // set default general admin settings |
|
| 2632 | - $this->use_personnel_manager = true; |
|
| 2633 | - $this->use_dashboard_widget = true; |
|
| 2634 | - $this->events_in_dashboard = 30; |
|
| 2635 | - $this->use_event_timezones = false; |
|
| 2636 | - $this->use_remote_logging = false; |
|
| 2637 | - $this->remote_logging_url = null; |
|
| 2638 | - $this->show_reg_footer = apply_filters( |
|
| 2639 | - 'FHEE__EE_Admin_Config__show_reg_footer__default', |
|
| 2640 | - false |
|
| 2641 | - ); |
|
| 2642 | - $this->affiliate_id = 'default'; |
|
| 2643 | - $this->help_tour_activation = true; |
|
| 2644 | - $this->encode_session_data = false; |
|
| 2645 | - } |
|
| 2646 | - |
|
| 2647 | - |
|
| 2648 | - /** |
|
| 2649 | - * @param bool $reset |
|
| 2650 | - * @return string |
|
| 2651 | - */ |
|
| 2652 | - public function log_file_name($reset = false) |
|
| 2653 | - { |
|
| 2654 | - if (empty($this->log_file_name) || $reset) { |
|
| 2655 | - $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
| 2656 | - EE_Config::instance()->update_espresso_config(false, false); |
|
| 2657 | - } |
|
| 2658 | - return $this->log_file_name; |
|
| 2659 | - } |
|
| 2660 | - |
|
| 2661 | - |
|
| 2662 | - /** |
|
| 2663 | - * @param bool $reset |
|
| 2664 | - * @return string |
|
| 2665 | - */ |
|
| 2666 | - public function debug_file_name($reset = false) |
|
| 2667 | - { |
|
| 2668 | - if (empty($this->debug_file_name) || $reset) { |
|
| 2669 | - $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
| 2670 | - EE_Config::instance()->update_espresso_config(false, false); |
|
| 2671 | - } |
|
| 2672 | - return $this->debug_file_name; |
|
| 2673 | - } |
|
| 2674 | - |
|
| 2675 | - |
|
| 2676 | - /** |
|
| 2677 | - * @return string |
|
| 2678 | - */ |
|
| 2679 | - public function affiliate_id() |
|
| 2680 | - { |
|
| 2681 | - return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default'; |
|
| 2682 | - } |
|
| 2683 | - |
|
| 2684 | - |
|
| 2685 | - /** |
|
| 2686 | - * @return boolean |
|
| 2687 | - */ |
|
| 2688 | - public function encode_session_data() |
|
| 2689 | - { |
|
| 2690 | - return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
| 2691 | - } |
|
| 2692 | - |
|
| 2693 | - |
|
| 2694 | - /** |
|
| 2695 | - * @param boolean $encode_session_data |
|
| 2696 | - */ |
|
| 2697 | - public function set_encode_session_data($encode_session_data) |
|
| 2698 | - { |
|
| 2699 | - $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
| 2700 | - } |
|
| 2556 | + /** |
|
| 2557 | + * @var boolean $use_personnel_manager |
|
| 2558 | + */ |
|
| 2559 | + public $use_personnel_manager; |
|
| 2560 | + |
|
| 2561 | + /** |
|
| 2562 | + * @var boolean $use_dashboard_widget |
|
| 2563 | + */ |
|
| 2564 | + public $use_dashboard_widget; |
|
| 2565 | + |
|
| 2566 | + /** |
|
| 2567 | + * @var int $events_in_dashboard |
|
| 2568 | + */ |
|
| 2569 | + public $events_in_dashboard; |
|
| 2570 | + |
|
| 2571 | + /** |
|
| 2572 | + * @var boolean $use_event_timezones |
|
| 2573 | + */ |
|
| 2574 | + public $use_event_timezones; |
|
| 2575 | + |
|
| 2576 | + /** |
|
| 2577 | + * @var string $log_file_name |
|
| 2578 | + */ |
|
| 2579 | + public $log_file_name; |
|
| 2580 | + |
|
| 2581 | + /** |
|
| 2582 | + * @var string $debug_file_name |
|
| 2583 | + */ |
|
| 2584 | + public $debug_file_name; |
|
| 2585 | + |
|
| 2586 | + /** |
|
| 2587 | + * @var boolean $use_remote_logging |
|
| 2588 | + */ |
|
| 2589 | + public $use_remote_logging; |
|
| 2590 | + |
|
| 2591 | + /** |
|
| 2592 | + * @var string $remote_logging_url |
|
| 2593 | + */ |
|
| 2594 | + public $remote_logging_url; |
|
| 2595 | + |
|
| 2596 | + /** |
|
| 2597 | + * @var boolean $show_reg_footer |
|
| 2598 | + */ |
|
| 2599 | + public $show_reg_footer; |
|
| 2600 | + |
|
| 2601 | + /** |
|
| 2602 | + * @var string $affiliate_id |
|
| 2603 | + */ |
|
| 2604 | + public $affiliate_id; |
|
| 2605 | + |
|
| 2606 | + /** |
|
| 2607 | + * help tours on or off (global setting) |
|
| 2608 | + * |
|
| 2609 | + * @var boolean |
|
| 2610 | + */ |
|
| 2611 | + public $help_tour_activation; |
|
| 2612 | + |
|
| 2613 | + /** |
|
| 2614 | + * adds extra layer of encoding to session data to prevent serialization errors |
|
| 2615 | + * but is incompatible with some server configuration errors |
|
| 2616 | + * if you get "500 internal server errors" during registration, try turning this on |
|
| 2617 | + * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off |
|
| 2618 | + * |
|
| 2619 | + * @var boolean $encode_session_data |
|
| 2620 | + */ |
|
| 2621 | + private $encode_session_data = false; |
|
| 2622 | + |
|
| 2623 | + |
|
| 2624 | + /** |
|
| 2625 | + * class constructor |
|
| 2626 | + * |
|
| 2627 | + * @access public |
|
| 2628 | + */ |
|
| 2629 | + public function __construct() |
|
| 2630 | + { |
|
| 2631 | + // set default general admin settings |
|
| 2632 | + $this->use_personnel_manager = true; |
|
| 2633 | + $this->use_dashboard_widget = true; |
|
| 2634 | + $this->events_in_dashboard = 30; |
|
| 2635 | + $this->use_event_timezones = false; |
|
| 2636 | + $this->use_remote_logging = false; |
|
| 2637 | + $this->remote_logging_url = null; |
|
| 2638 | + $this->show_reg_footer = apply_filters( |
|
| 2639 | + 'FHEE__EE_Admin_Config__show_reg_footer__default', |
|
| 2640 | + false |
|
| 2641 | + ); |
|
| 2642 | + $this->affiliate_id = 'default'; |
|
| 2643 | + $this->help_tour_activation = true; |
|
| 2644 | + $this->encode_session_data = false; |
|
| 2645 | + } |
|
| 2646 | + |
|
| 2647 | + |
|
| 2648 | + /** |
|
| 2649 | + * @param bool $reset |
|
| 2650 | + * @return string |
|
| 2651 | + */ |
|
| 2652 | + public function log_file_name($reset = false) |
|
| 2653 | + { |
|
| 2654 | + if (empty($this->log_file_name) || $reset) { |
|
| 2655 | + $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
| 2656 | + EE_Config::instance()->update_espresso_config(false, false); |
|
| 2657 | + } |
|
| 2658 | + return $this->log_file_name; |
|
| 2659 | + } |
|
| 2660 | + |
|
| 2661 | + |
|
| 2662 | + /** |
|
| 2663 | + * @param bool $reset |
|
| 2664 | + * @return string |
|
| 2665 | + */ |
|
| 2666 | + public function debug_file_name($reset = false) |
|
| 2667 | + { |
|
| 2668 | + if (empty($this->debug_file_name) || $reset) { |
|
| 2669 | + $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
| 2670 | + EE_Config::instance()->update_espresso_config(false, false); |
|
| 2671 | + } |
|
| 2672 | + return $this->debug_file_name; |
|
| 2673 | + } |
|
| 2674 | + |
|
| 2675 | + |
|
| 2676 | + /** |
|
| 2677 | + * @return string |
|
| 2678 | + */ |
|
| 2679 | + public function affiliate_id() |
|
| 2680 | + { |
|
| 2681 | + return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default'; |
|
| 2682 | + } |
|
| 2683 | + |
|
| 2684 | + |
|
| 2685 | + /** |
|
| 2686 | + * @return boolean |
|
| 2687 | + */ |
|
| 2688 | + public function encode_session_data() |
|
| 2689 | + { |
|
| 2690 | + return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
| 2691 | + } |
|
| 2692 | + |
|
| 2693 | + |
|
| 2694 | + /** |
|
| 2695 | + * @param boolean $encode_session_data |
|
| 2696 | + */ |
|
| 2697 | + public function set_encode_session_data($encode_session_data) |
|
| 2698 | + { |
|
| 2699 | + $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
| 2700 | + } |
|
| 2701 | 2701 | } |
| 2702 | 2702 | |
| 2703 | 2703 | /** |
@@ -2706,70 +2706,70 @@ discard block |
||
| 2706 | 2706 | class EE_Template_Config extends EE_Config_Base |
| 2707 | 2707 | { |
| 2708 | 2708 | |
| 2709 | - /** |
|
| 2710 | - * @var boolean $enable_default_style |
|
| 2711 | - */ |
|
| 2712 | - public $enable_default_style; |
|
| 2713 | - |
|
| 2714 | - /** |
|
| 2715 | - * @var string $custom_style_sheet |
|
| 2716 | - */ |
|
| 2717 | - public $custom_style_sheet; |
|
| 2718 | - |
|
| 2719 | - /** |
|
| 2720 | - * @var boolean $display_address_in_regform |
|
| 2721 | - */ |
|
| 2722 | - public $display_address_in_regform; |
|
| 2723 | - |
|
| 2724 | - /** |
|
| 2725 | - * @var int $display_description_on_multi_reg_page |
|
| 2726 | - */ |
|
| 2727 | - public $display_description_on_multi_reg_page; |
|
| 2728 | - |
|
| 2729 | - /** |
|
| 2730 | - * @var boolean $use_custom_templates |
|
| 2731 | - */ |
|
| 2732 | - public $use_custom_templates; |
|
| 2733 | - |
|
| 2734 | - /** |
|
| 2735 | - * @var string $current_espresso_theme |
|
| 2736 | - */ |
|
| 2737 | - public $current_espresso_theme; |
|
| 2738 | - |
|
| 2739 | - /** |
|
| 2740 | - * @var EE_Ticket_Selector_Config $EED_Ticket_Selector |
|
| 2741 | - */ |
|
| 2742 | - public $EED_Ticket_Selector; |
|
| 2743 | - |
|
| 2744 | - /** |
|
| 2745 | - * @var EE_Event_Single_Config $EED_Event_Single |
|
| 2746 | - */ |
|
| 2747 | - public $EED_Event_Single; |
|
| 2748 | - |
|
| 2749 | - /** |
|
| 2750 | - * @var EE_Events_Archive_Config $EED_Events_Archive |
|
| 2751 | - */ |
|
| 2752 | - public $EED_Events_Archive; |
|
| 2753 | - |
|
| 2754 | - |
|
| 2755 | - /** |
|
| 2756 | - * class constructor |
|
| 2757 | - * |
|
| 2758 | - * @access public |
|
| 2759 | - */ |
|
| 2760 | - public function __construct() |
|
| 2761 | - { |
|
| 2762 | - // set default template settings |
|
| 2763 | - $this->enable_default_style = true; |
|
| 2764 | - $this->custom_style_sheet = null; |
|
| 2765 | - $this->display_address_in_regform = true; |
|
| 2766 | - $this->display_description_on_multi_reg_page = false; |
|
| 2767 | - $this->use_custom_templates = false; |
|
| 2768 | - $this->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
| 2769 | - $this->EED_Event_Single = null; |
|
| 2770 | - $this->EED_Events_Archive = null; |
|
| 2771 | - $this->EED_Ticket_Selector = null; |
|
| 2772 | - } |
|
| 2709 | + /** |
|
| 2710 | + * @var boolean $enable_default_style |
|
| 2711 | + */ |
|
| 2712 | + public $enable_default_style; |
|
| 2713 | + |
|
| 2714 | + /** |
|
| 2715 | + * @var string $custom_style_sheet |
|
| 2716 | + */ |
|
| 2717 | + public $custom_style_sheet; |
|
| 2718 | + |
|
| 2719 | + /** |
|
| 2720 | + * @var boolean $display_address_in_regform |
|
| 2721 | + */ |
|
| 2722 | + public $display_address_in_regform; |
|
| 2723 | + |
|
| 2724 | + /** |
|
| 2725 | + * @var int $display_description_on_multi_reg_page |
|
| 2726 | + */ |
|
| 2727 | + public $display_description_on_multi_reg_page; |
|
| 2728 | + |
|
| 2729 | + /** |
|
| 2730 | + * @var boolean $use_custom_templates |
|
| 2731 | + */ |
|
| 2732 | + public $use_custom_templates; |
|
| 2733 | + |
|
| 2734 | + /** |
|
| 2735 | + * @var string $current_espresso_theme |
|
| 2736 | + */ |
|
| 2737 | + public $current_espresso_theme; |
|
| 2738 | + |
|
| 2739 | + /** |
|
| 2740 | + * @var EE_Ticket_Selector_Config $EED_Ticket_Selector |
|
| 2741 | + */ |
|
| 2742 | + public $EED_Ticket_Selector; |
|
| 2743 | + |
|
| 2744 | + /** |
|
| 2745 | + * @var EE_Event_Single_Config $EED_Event_Single |
|
| 2746 | + */ |
|
| 2747 | + public $EED_Event_Single; |
|
| 2748 | + |
|
| 2749 | + /** |
|
| 2750 | + * @var EE_Events_Archive_Config $EED_Events_Archive |
|
| 2751 | + */ |
|
| 2752 | + public $EED_Events_Archive; |
|
| 2753 | + |
|
| 2754 | + |
|
| 2755 | + /** |
|
| 2756 | + * class constructor |
|
| 2757 | + * |
|
| 2758 | + * @access public |
|
| 2759 | + */ |
|
| 2760 | + public function __construct() |
|
| 2761 | + { |
|
| 2762 | + // set default template settings |
|
| 2763 | + $this->enable_default_style = true; |
|
| 2764 | + $this->custom_style_sheet = null; |
|
| 2765 | + $this->display_address_in_regform = true; |
|
| 2766 | + $this->display_description_on_multi_reg_page = false; |
|
| 2767 | + $this->use_custom_templates = false; |
|
| 2768 | + $this->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
| 2769 | + $this->EED_Event_Single = null; |
|
| 2770 | + $this->EED_Events_Archive = null; |
|
| 2771 | + $this->EED_Ticket_Selector = null; |
|
| 2772 | + } |
|
| 2773 | 2773 | } |
| 2774 | 2774 | |
| 2775 | 2775 | /** |
@@ -2778,114 +2778,114 @@ discard block |
||
| 2778 | 2778 | class EE_Map_Config extends EE_Config_Base |
| 2779 | 2779 | { |
| 2780 | 2780 | |
| 2781 | - /** |
|
| 2782 | - * @var boolean $use_google_maps |
|
| 2783 | - */ |
|
| 2784 | - public $use_google_maps; |
|
| 2785 | - |
|
| 2786 | - /** |
|
| 2787 | - * @var string $api_key |
|
| 2788 | - */ |
|
| 2789 | - public $google_map_api_key; |
|
| 2790 | - |
|
| 2791 | - /** |
|
| 2792 | - * @var int $event_details_map_width |
|
| 2793 | - */ |
|
| 2794 | - public $event_details_map_width; |
|
| 2795 | - |
|
| 2796 | - /** |
|
| 2797 | - * @var int $event_details_map_height |
|
| 2798 | - */ |
|
| 2799 | - public $event_details_map_height; |
|
| 2800 | - |
|
| 2801 | - /** |
|
| 2802 | - * @var int $event_details_map_zoom |
|
| 2803 | - */ |
|
| 2804 | - public $event_details_map_zoom; |
|
| 2805 | - |
|
| 2806 | - /** |
|
| 2807 | - * @var boolean $event_details_display_nav |
|
| 2808 | - */ |
|
| 2809 | - public $event_details_display_nav; |
|
| 2810 | - |
|
| 2811 | - /** |
|
| 2812 | - * @var boolean $event_details_nav_size |
|
| 2813 | - */ |
|
| 2814 | - public $event_details_nav_size; |
|
| 2815 | - |
|
| 2816 | - /** |
|
| 2817 | - * @var string $event_details_control_type |
|
| 2818 | - */ |
|
| 2819 | - public $event_details_control_type; |
|
| 2820 | - |
|
| 2821 | - /** |
|
| 2822 | - * @var string $event_details_map_align |
|
| 2823 | - */ |
|
| 2824 | - public $event_details_map_align; |
|
| 2825 | - |
|
| 2826 | - /** |
|
| 2827 | - * @var int $event_list_map_width |
|
| 2828 | - */ |
|
| 2829 | - public $event_list_map_width; |
|
| 2830 | - |
|
| 2831 | - /** |
|
| 2832 | - * @var int $event_list_map_height |
|
| 2833 | - */ |
|
| 2834 | - public $event_list_map_height; |
|
| 2835 | - |
|
| 2836 | - /** |
|
| 2837 | - * @var int $event_list_map_zoom |
|
| 2838 | - */ |
|
| 2839 | - public $event_list_map_zoom; |
|
| 2840 | - |
|
| 2841 | - /** |
|
| 2842 | - * @var boolean $event_list_display_nav |
|
| 2843 | - */ |
|
| 2844 | - public $event_list_display_nav; |
|
| 2845 | - |
|
| 2846 | - /** |
|
| 2847 | - * @var boolean $event_list_nav_size |
|
| 2848 | - */ |
|
| 2849 | - public $event_list_nav_size; |
|
| 2850 | - |
|
| 2851 | - /** |
|
| 2852 | - * @var string $event_list_control_type |
|
| 2853 | - */ |
|
| 2854 | - public $event_list_control_type; |
|
| 2855 | - |
|
| 2856 | - /** |
|
| 2857 | - * @var string $event_list_map_align |
|
| 2858 | - */ |
|
| 2859 | - public $event_list_map_align; |
|
| 2860 | - |
|
| 2861 | - |
|
| 2862 | - /** |
|
| 2863 | - * class constructor |
|
| 2864 | - * |
|
| 2865 | - * @access public |
|
| 2866 | - */ |
|
| 2867 | - public function __construct() |
|
| 2868 | - { |
|
| 2869 | - // set default map settings |
|
| 2870 | - $this->use_google_maps = true; |
|
| 2871 | - $this->google_map_api_key = ''; |
|
| 2872 | - // for event details pages (reg page) |
|
| 2873 | - $this->event_details_map_width = 585; // ee_map_width_single |
|
| 2874 | - $this->event_details_map_height = 362; // ee_map_height_single |
|
| 2875 | - $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
| 2876 | - $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
| 2877 | - $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
| 2878 | - $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
| 2879 | - $this->event_details_map_align = 'center'; // ee_map_align_single |
|
| 2880 | - // for event list pages |
|
| 2881 | - $this->event_list_map_width = 300; // ee_map_width |
|
| 2882 | - $this->event_list_map_height = 185; // ee_map_height |
|
| 2883 | - $this->event_list_map_zoom = 12; // ee_map_zoom |
|
| 2884 | - $this->event_list_display_nav = false; // ee_map_nav_display |
|
| 2885 | - $this->event_list_nav_size = true; // ee_map_nav_size |
|
| 2886 | - $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
| 2887 | - $this->event_list_map_align = 'center'; // ee_map_align |
|
| 2888 | - } |
|
| 2781 | + /** |
|
| 2782 | + * @var boolean $use_google_maps |
|
| 2783 | + */ |
|
| 2784 | + public $use_google_maps; |
|
| 2785 | + |
|
| 2786 | + /** |
|
| 2787 | + * @var string $api_key |
|
| 2788 | + */ |
|
| 2789 | + public $google_map_api_key; |
|
| 2790 | + |
|
| 2791 | + /** |
|
| 2792 | + * @var int $event_details_map_width |
|
| 2793 | + */ |
|
| 2794 | + public $event_details_map_width; |
|
| 2795 | + |
|
| 2796 | + /** |
|
| 2797 | + * @var int $event_details_map_height |
|
| 2798 | + */ |
|
| 2799 | + public $event_details_map_height; |
|
| 2800 | + |
|
| 2801 | + /** |
|
| 2802 | + * @var int $event_details_map_zoom |
|
| 2803 | + */ |
|
| 2804 | + public $event_details_map_zoom; |
|
| 2805 | + |
|
| 2806 | + /** |
|
| 2807 | + * @var boolean $event_details_display_nav |
|
| 2808 | + */ |
|
| 2809 | + public $event_details_display_nav; |
|
| 2810 | + |
|
| 2811 | + /** |
|
| 2812 | + * @var boolean $event_details_nav_size |
|
| 2813 | + */ |
|
| 2814 | + public $event_details_nav_size; |
|
| 2815 | + |
|
| 2816 | + /** |
|
| 2817 | + * @var string $event_details_control_type |
|
| 2818 | + */ |
|
| 2819 | + public $event_details_control_type; |
|
| 2820 | + |
|
| 2821 | + /** |
|
| 2822 | + * @var string $event_details_map_align |
|
| 2823 | + */ |
|
| 2824 | + public $event_details_map_align; |
|
| 2825 | + |
|
| 2826 | + /** |
|
| 2827 | + * @var int $event_list_map_width |
|
| 2828 | + */ |
|
| 2829 | + public $event_list_map_width; |
|
| 2830 | + |
|
| 2831 | + /** |
|
| 2832 | + * @var int $event_list_map_height |
|
| 2833 | + */ |
|
| 2834 | + public $event_list_map_height; |
|
| 2835 | + |
|
| 2836 | + /** |
|
| 2837 | + * @var int $event_list_map_zoom |
|
| 2838 | + */ |
|
| 2839 | + public $event_list_map_zoom; |
|
| 2840 | + |
|
| 2841 | + /** |
|
| 2842 | + * @var boolean $event_list_display_nav |
|
| 2843 | + */ |
|
| 2844 | + public $event_list_display_nav; |
|
| 2845 | + |
|
| 2846 | + /** |
|
| 2847 | + * @var boolean $event_list_nav_size |
|
| 2848 | + */ |
|
| 2849 | + public $event_list_nav_size; |
|
| 2850 | + |
|
| 2851 | + /** |
|
| 2852 | + * @var string $event_list_control_type |
|
| 2853 | + */ |
|
| 2854 | + public $event_list_control_type; |
|
| 2855 | + |
|
| 2856 | + /** |
|
| 2857 | + * @var string $event_list_map_align |
|
| 2858 | + */ |
|
| 2859 | + public $event_list_map_align; |
|
| 2860 | + |
|
| 2861 | + |
|
| 2862 | + /** |
|
| 2863 | + * class constructor |
|
| 2864 | + * |
|
| 2865 | + * @access public |
|
| 2866 | + */ |
|
| 2867 | + public function __construct() |
|
| 2868 | + { |
|
| 2869 | + // set default map settings |
|
| 2870 | + $this->use_google_maps = true; |
|
| 2871 | + $this->google_map_api_key = ''; |
|
| 2872 | + // for event details pages (reg page) |
|
| 2873 | + $this->event_details_map_width = 585; // ee_map_width_single |
|
| 2874 | + $this->event_details_map_height = 362; // ee_map_height_single |
|
| 2875 | + $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
| 2876 | + $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
| 2877 | + $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
| 2878 | + $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
| 2879 | + $this->event_details_map_align = 'center'; // ee_map_align_single |
|
| 2880 | + // for event list pages |
|
| 2881 | + $this->event_list_map_width = 300; // ee_map_width |
|
| 2882 | + $this->event_list_map_height = 185; // ee_map_height |
|
| 2883 | + $this->event_list_map_zoom = 12; // ee_map_zoom |
|
| 2884 | + $this->event_list_display_nav = false; // ee_map_nav_display |
|
| 2885 | + $this->event_list_nav_size = true; // ee_map_nav_size |
|
| 2886 | + $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
| 2887 | + $this->event_list_map_align = 'center'; // ee_map_align |
|
| 2888 | + } |
|
| 2889 | 2889 | } |
| 2890 | 2890 | |
| 2891 | 2891 | /** |
@@ -2894,46 +2894,46 @@ discard block |
||
| 2894 | 2894 | class EE_Events_Archive_Config extends EE_Config_Base |
| 2895 | 2895 | { |
| 2896 | 2896 | |
| 2897 | - public $display_status_banner; |
|
| 2897 | + public $display_status_banner; |
|
| 2898 | 2898 | |
| 2899 | - public $display_description; |
|
| 2899 | + public $display_description; |
|
| 2900 | 2900 | |
| 2901 | - public $display_ticket_selector; |
|
| 2901 | + public $display_ticket_selector; |
|
| 2902 | 2902 | |
| 2903 | - public $display_datetimes; |
|
| 2903 | + public $display_datetimes; |
|
| 2904 | 2904 | |
| 2905 | - public $display_venue; |
|
| 2905 | + public $display_venue; |
|
| 2906 | 2906 | |
| 2907 | - public $display_expired_events; |
|
| 2907 | + public $display_expired_events; |
|
| 2908 | 2908 | |
| 2909 | - public $use_sortable_display_order; |
|
| 2909 | + public $use_sortable_display_order; |
|
| 2910 | 2910 | |
| 2911 | - public $display_order_tickets; |
|
| 2911 | + public $display_order_tickets; |
|
| 2912 | 2912 | |
| 2913 | - public $display_order_datetimes; |
|
| 2913 | + public $display_order_datetimes; |
|
| 2914 | 2914 | |
| 2915 | - public $display_order_event; |
|
| 2915 | + public $display_order_event; |
|
| 2916 | 2916 | |
| 2917 | - public $display_order_venue; |
|
| 2917 | + public $display_order_venue; |
|
| 2918 | 2918 | |
| 2919 | 2919 | |
| 2920 | - /** |
|
| 2921 | - * class constructor |
|
| 2922 | - */ |
|
| 2923 | - public function __construct() |
|
| 2924 | - { |
|
| 2925 | - $this->display_status_banner = 0; |
|
| 2926 | - $this->display_description = 1; |
|
| 2927 | - $this->display_ticket_selector = 0; |
|
| 2928 | - $this->display_datetimes = 1; |
|
| 2929 | - $this->display_venue = 0; |
|
| 2930 | - $this->display_expired_events = 0; |
|
| 2931 | - $this->use_sortable_display_order = false; |
|
| 2932 | - $this->display_order_tickets = 100; |
|
| 2933 | - $this->display_order_datetimes = 110; |
|
| 2934 | - $this->display_order_event = 120; |
|
| 2935 | - $this->display_order_venue = 130; |
|
| 2936 | - } |
|
| 2920 | + /** |
|
| 2921 | + * class constructor |
|
| 2922 | + */ |
|
| 2923 | + public function __construct() |
|
| 2924 | + { |
|
| 2925 | + $this->display_status_banner = 0; |
|
| 2926 | + $this->display_description = 1; |
|
| 2927 | + $this->display_ticket_selector = 0; |
|
| 2928 | + $this->display_datetimes = 1; |
|
| 2929 | + $this->display_venue = 0; |
|
| 2930 | + $this->display_expired_events = 0; |
|
| 2931 | + $this->use_sortable_display_order = false; |
|
| 2932 | + $this->display_order_tickets = 100; |
|
| 2933 | + $this->display_order_datetimes = 110; |
|
| 2934 | + $this->display_order_event = 120; |
|
| 2935 | + $this->display_order_venue = 130; |
|
| 2936 | + } |
|
| 2937 | 2937 | } |
| 2938 | 2938 | |
| 2939 | 2939 | /** |
@@ -2942,34 +2942,34 @@ discard block |
||
| 2942 | 2942 | class EE_Event_Single_Config extends EE_Config_Base |
| 2943 | 2943 | { |
| 2944 | 2944 | |
| 2945 | - public $display_status_banner_single; |
|
| 2945 | + public $display_status_banner_single; |
|
| 2946 | 2946 | |
| 2947 | - public $display_venue; |
|
| 2947 | + public $display_venue; |
|
| 2948 | 2948 | |
| 2949 | - public $use_sortable_display_order; |
|
| 2949 | + public $use_sortable_display_order; |
|
| 2950 | 2950 | |
| 2951 | - public $display_order_tickets; |
|
| 2951 | + public $display_order_tickets; |
|
| 2952 | 2952 | |
| 2953 | - public $display_order_datetimes; |
|
| 2953 | + public $display_order_datetimes; |
|
| 2954 | 2954 | |
| 2955 | - public $display_order_event; |
|
| 2955 | + public $display_order_event; |
|
| 2956 | 2956 | |
| 2957 | - public $display_order_venue; |
|
| 2957 | + public $display_order_venue; |
|
| 2958 | 2958 | |
| 2959 | 2959 | |
| 2960 | - /** |
|
| 2961 | - * class constructor |
|
| 2962 | - */ |
|
| 2963 | - public function __construct() |
|
| 2964 | - { |
|
| 2965 | - $this->display_status_banner_single = 0; |
|
| 2966 | - $this->display_venue = 1; |
|
| 2967 | - $this->use_sortable_display_order = false; |
|
| 2968 | - $this->display_order_tickets = 100; |
|
| 2969 | - $this->display_order_datetimes = 110; |
|
| 2970 | - $this->display_order_event = 120; |
|
| 2971 | - $this->display_order_venue = 130; |
|
| 2972 | - } |
|
| 2960 | + /** |
|
| 2961 | + * class constructor |
|
| 2962 | + */ |
|
| 2963 | + public function __construct() |
|
| 2964 | + { |
|
| 2965 | + $this->display_status_banner_single = 0; |
|
| 2966 | + $this->display_venue = 1; |
|
| 2967 | + $this->use_sortable_display_order = false; |
|
| 2968 | + $this->display_order_tickets = 100; |
|
| 2969 | + $this->display_order_datetimes = 110; |
|
| 2970 | + $this->display_order_event = 120; |
|
| 2971 | + $this->display_order_venue = 130; |
|
| 2972 | + } |
|
| 2973 | 2973 | } |
| 2974 | 2974 | |
| 2975 | 2975 | /** |
@@ -2978,172 +2978,172 @@ discard block |
||
| 2978 | 2978 | class EE_Ticket_Selector_Config extends EE_Config_Base |
| 2979 | 2979 | { |
| 2980 | 2980 | |
| 2981 | - /** |
|
| 2982 | - * constant to indicate that a datetime selector should NEVER be shown for ticket selectors |
|
| 2983 | - */ |
|
| 2984 | - const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector'; |
|
| 2985 | - |
|
| 2986 | - /** |
|
| 2987 | - * constant to indicate that a datetime selector should only be shown for ticket selectors |
|
| 2988 | - * when the number of datetimes for the event matches the value set for $datetime_selector_threshold |
|
| 2989 | - */ |
|
| 2990 | - const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector'; |
|
| 2991 | - |
|
| 2992 | - /** |
|
| 2993 | - * @var boolean $show_ticket_sale_columns |
|
| 2994 | - */ |
|
| 2995 | - public $show_ticket_sale_columns; |
|
| 2996 | - |
|
| 2997 | - /** |
|
| 2998 | - * @var boolean $show_ticket_details |
|
| 2999 | - */ |
|
| 3000 | - public $show_ticket_details; |
|
| 3001 | - |
|
| 3002 | - /** |
|
| 3003 | - * @var boolean $show_expired_tickets |
|
| 3004 | - */ |
|
| 3005 | - public $show_expired_tickets; |
|
| 3006 | - |
|
| 3007 | - /** |
|
| 3008 | - * whether or not to display a dropdown box populated with event datetimes |
|
| 3009 | - * that toggles which tickets are displayed for a ticket selector. |
|
| 3010 | - * uses one of the *_DATETIME_SELECTOR constants defined above |
|
| 3011 | - * |
|
| 3012 | - * @var string $show_datetime_selector |
|
| 3013 | - */ |
|
| 3014 | - private $show_datetime_selector = 'no_datetime_selector'; |
|
| 3015 | - |
|
| 3016 | - /** |
|
| 3017 | - * the number of datetimes an event has to have before conditionally displaying a datetime selector |
|
| 3018 | - * |
|
| 3019 | - * @var int $datetime_selector_threshold |
|
| 3020 | - */ |
|
| 3021 | - private $datetime_selector_threshold = 3; |
|
| 3022 | - |
|
| 3023 | - /** |
|
| 3024 | - * determines the maximum number of "checked" dates in the date and time filter |
|
| 3025 | - * |
|
| 3026 | - * @var int $datetime_selector_checked |
|
| 3027 | - */ |
|
| 3028 | - private $datetime_selector_max_checked = 10; |
|
| 3029 | - |
|
| 3030 | - |
|
| 3031 | - /** |
|
| 3032 | - * class constructor |
|
| 3033 | - */ |
|
| 3034 | - public function __construct() |
|
| 3035 | - { |
|
| 3036 | - $this->show_ticket_sale_columns = true; |
|
| 3037 | - $this->show_ticket_details = true; |
|
| 3038 | - $this->show_expired_tickets = true; |
|
| 3039 | - $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
| 3040 | - $this->datetime_selector_threshold = 3; |
|
| 3041 | - $this->datetime_selector_max_checked = 10; |
|
| 3042 | - } |
|
| 3043 | - |
|
| 3044 | - |
|
| 3045 | - /** |
|
| 3046 | - * returns true if a datetime selector should be displayed |
|
| 3047 | - * |
|
| 3048 | - * @param array $datetimes |
|
| 3049 | - * @return bool |
|
| 3050 | - */ |
|
| 3051 | - public function showDatetimeSelector(array $datetimes) |
|
| 3052 | - { |
|
| 3053 | - // if the settings are NOT: don't show OR below threshold, THEN active = true |
|
| 3054 | - return ! ( |
|
| 3055 | - $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
| 3056 | - || ( |
|
| 3057 | - $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR |
|
| 3058 | - && count($datetimes) < $this->getDatetimeSelectorThreshold() |
|
| 3059 | - ) |
|
| 3060 | - ); |
|
| 3061 | - } |
|
| 3062 | - |
|
| 3063 | - |
|
| 3064 | - /** |
|
| 3065 | - * @return string |
|
| 3066 | - */ |
|
| 3067 | - public function getShowDatetimeSelector() |
|
| 3068 | - { |
|
| 3069 | - return $this->show_datetime_selector; |
|
| 3070 | - } |
|
| 3071 | - |
|
| 3072 | - |
|
| 3073 | - /** |
|
| 3074 | - * @param bool $keys_only |
|
| 3075 | - * @return array |
|
| 3076 | - */ |
|
| 3077 | - public function getShowDatetimeSelectorOptions($keys_only = true) |
|
| 3078 | - { |
|
| 3079 | - return $keys_only |
|
| 3080 | - ? array( |
|
| 3081 | - \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
| 3082 | - \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR, |
|
| 3083 | - ) |
|
| 3084 | - : array( |
|
| 3085 | - \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__( |
|
| 3086 | - 'Do not show date & time filter', |
|
| 3087 | - 'event_espresso' |
|
| 3088 | - ), |
|
| 3089 | - \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR => esc_html__( |
|
| 3090 | - 'Maybe show date & time filter', |
|
| 3091 | - 'event_espresso' |
|
| 3092 | - ), |
|
| 3093 | - ); |
|
| 3094 | - } |
|
| 3095 | - |
|
| 3096 | - |
|
| 3097 | - /** |
|
| 3098 | - * @param string $show_datetime_selector |
|
| 3099 | - */ |
|
| 3100 | - public function setShowDatetimeSelector($show_datetime_selector) |
|
| 3101 | - { |
|
| 3102 | - $this->show_datetime_selector = in_array( |
|
| 3103 | - $show_datetime_selector, |
|
| 3104 | - $this->getShowDatetimeSelectorOptions(), |
|
| 3105 | - true |
|
| 3106 | - ) |
|
| 3107 | - ? $show_datetime_selector |
|
| 3108 | - : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
| 3109 | - } |
|
| 3110 | - |
|
| 3111 | - |
|
| 3112 | - /** |
|
| 3113 | - * @return int |
|
| 3114 | - */ |
|
| 3115 | - public function getDatetimeSelectorThreshold() |
|
| 3116 | - { |
|
| 3117 | - return $this->datetime_selector_threshold; |
|
| 3118 | - } |
|
| 3119 | - |
|
| 3120 | - |
|
| 3121 | - /** |
|
| 3122 | - * @param int $datetime_selector_threshold |
|
| 3123 | - */ |
|
| 3124 | - public function setDatetimeSelectorThreshold($datetime_selector_threshold) |
|
| 3125 | - { |
|
| 3126 | - $datetime_selector_threshold = absint($datetime_selector_threshold); |
|
| 3127 | - $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3; |
|
| 3128 | - } |
|
| 3129 | - |
|
| 3130 | - |
|
| 3131 | - /** |
|
| 3132 | - * @return int |
|
| 3133 | - */ |
|
| 3134 | - public function getDatetimeSelectorMaxChecked() |
|
| 3135 | - { |
|
| 3136 | - return $this->datetime_selector_max_checked; |
|
| 3137 | - } |
|
| 3138 | - |
|
| 3139 | - |
|
| 3140 | - /** |
|
| 3141 | - * @param int $datetime_selector_max_checked |
|
| 3142 | - */ |
|
| 3143 | - public function setDatetimeSelectorMaxChecked($datetime_selector_max_checked) |
|
| 3144 | - { |
|
| 3145 | - $this->datetime_selector_max_checked = absint($datetime_selector_max_checked); |
|
| 3146 | - } |
|
| 2981 | + /** |
|
| 2982 | + * constant to indicate that a datetime selector should NEVER be shown for ticket selectors |
|
| 2983 | + */ |
|
| 2984 | + const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector'; |
|
| 2985 | + |
|
| 2986 | + /** |
|
| 2987 | + * constant to indicate that a datetime selector should only be shown for ticket selectors |
|
| 2988 | + * when the number of datetimes for the event matches the value set for $datetime_selector_threshold |
|
| 2989 | + */ |
|
| 2990 | + const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector'; |
|
| 2991 | + |
|
| 2992 | + /** |
|
| 2993 | + * @var boolean $show_ticket_sale_columns |
|
| 2994 | + */ |
|
| 2995 | + public $show_ticket_sale_columns; |
|
| 2996 | + |
|
| 2997 | + /** |
|
| 2998 | + * @var boolean $show_ticket_details |
|
| 2999 | + */ |
|
| 3000 | + public $show_ticket_details; |
|
| 3001 | + |
|
| 3002 | + /** |
|
| 3003 | + * @var boolean $show_expired_tickets |
|
| 3004 | + */ |
|
| 3005 | + public $show_expired_tickets; |
|
| 3006 | + |
|
| 3007 | + /** |
|
| 3008 | + * whether or not to display a dropdown box populated with event datetimes |
|
| 3009 | + * that toggles which tickets are displayed for a ticket selector. |
|
| 3010 | + * uses one of the *_DATETIME_SELECTOR constants defined above |
|
| 3011 | + * |
|
| 3012 | + * @var string $show_datetime_selector |
|
| 3013 | + */ |
|
| 3014 | + private $show_datetime_selector = 'no_datetime_selector'; |
|
| 3015 | + |
|
| 3016 | + /** |
|
| 3017 | + * the number of datetimes an event has to have before conditionally displaying a datetime selector |
|
| 3018 | + * |
|
| 3019 | + * @var int $datetime_selector_threshold |
|
| 3020 | + */ |
|
| 3021 | + private $datetime_selector_threshold = 3; |
|
| 3022 | + |
|
| 3023 | + /** |
|
| 3024 | + * determines the maximum number of "checked" dates in the date and time filter |
|
| 3025 | + * |
|
| 3026 | + * @var int $datetime_selector_checked |
|
| 3027 | + */ |
|
| 3028 | + private $datetime_selector_max_checked = 10; |
|
| 3029 | + |
|
| 3030 | + |
|
| 3031 | + /** |
|
| 3032 | + * class constructor |
|
| 3033 | + */ |
|
| 3034 | + public function __construct() |
|
| 3035 | + { |
|
| 3036 | + $this->show_ticket_sale_columns = true; |
|
| 3037 | + $this->show_ticket_details = true; |
|
| 3038 | + $this->show_expired_tickets = true; |
|
| 3039 | + $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
| 3040 | + $this->datetime_selector_threshold = 3; |
|
| 3041 | + $this->datetime_selector_max_checked = 10; |
|
| 3042 | + } |
|
| 3043 | + |
|
| 3044 | + |
|
| 3045 | + /** |
|
| 3046 | + * returns true if a datetime selector should be displayed |
|
| 3047 | + * |
|
| 3048 | + * @param array $datetimes |
|
| 3049 | + * @return bool |
|
| 3050 | + */ |
|
| 3051 | + public function showDatetimeSelector(array $datetimes) |
|
| 3052 | + { |
|
| 3053 | + // if the settings are NOT: don't show OR below threshold, THEN active = true |
|
| 3054 | + return ! ( |
|
| 3055 | + $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
| 3056 | + || ( |
|
| 3057 | + $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR |
|
| 3058 | + && count($datetimes) < $this->getDatetimeSelectorThreshold() |
|
| 3059 | + ) |
|
| 3060 | + ); |
|
| 3061 | + } |
|
| 3062 | + |
|
| 3063 | + |
|
| 3064 | + /** |
|
| 3065 | + * @return string |
|
| 3066 | + */ |
|
| 3067 | + public function getShowDatetimeSelector() |
|
| 3068 | + { |
|
| 3069 | + return $this->show_datetime_selector; |
|
| 3070 | + } |
|
| 3071 | + |
|
| 3072 | + |
|
| 3073 | + /** |
|
| 3074 | + * @param bool $keys_only |
|
| 3075 | + * @return array |
|
| 3076 | + */ |
|
| 3077 | + public function getShowDatetimeSelectorOptions($keys_only = true) |
|
| 3078 | + { |
|
| 3079 | + return $keys_only |
|
| 3080 | + ? array( |
|
| 3081 | + \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
| 3082 | + \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR, |
|
| 3083 | + ) |
|
| 3084 | + : array( |
|
| 3085 | + \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__( |
|
| 3086 | + 'Do not show date & time filter', |
|
| 3087 | + 'event_espresso' |
|
| 3088 | + ), |
|
| 3089 | + \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR => esc_html__( |
|
| 3090 | + 'Maybe show date & time filter', |
|
| 3091 | + 'event_espresso' |
|
| 3092 | + ), |
|
| 3093 | + ); |
|
| 3094 | + } |
|
| 3095 | + |
|
| 3096 | + |
|
| 3097 | + /** |
|
| 3098 | + * @param string $show_datetime_selector |
|
| 3099 | + */ |
|
| 3100 | + public function setShowDatetimeSelector($show_datetime_selector) |
|
| 3101 | + { |
|
| 3102 | + $this->show_datetime_selector = in_array( |
|
| 3103 | + $show_datetime_selector, |
|
| 3104 | + $this->getShowDatetimeSelectorOptions(), |
|
| 3105 | + true |
|
| 3106 | + ) |
|
| 3107 | + ? $show_datetime_selector |
|
| 3108 | + : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
| 3109 | + } |
|
| 3110 | + |
|
| 3111 | + |
|
| 3112 | + /** |
|
| 3113 | + * @return int |
|
| 3114 | + */ |
|
| 3115 | + public function getDatetimeSelectorThreshold() |
|
| 3116 | + { |
|
| 3117 | + return $this->datetime_selector_threshold; |
|
| 3118 | + } |
|
| 3119 | + |
|
| 3120 | + |
|
| 3121 | + /** |
|
| 3122 | + * @param int $datetime_selector_threshold |
|
| 3123 | + */ |
|
| 3124 | + public function setDatetimeSelectorThreshold($datetime_selector_threshold) |
|
| 3125 | + { |
|
| 3126 | + $datetime_selector_threshold = absint($datetime_selector_threshold); |
|
| 3127 | + $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3; |
|
| 3128 | + } |
|
| 3129 | + |
|
| 3130 | + |
|
| 3131 | + /** |
|
| 3132 | + * @return int |
|
| 3133 | + */ |
|
| 3134 | + public function getDatetimeSelectorMaxChecked() |
|
| 3135 | + { |
|
| 3136 | + return $this->datetime_selector_max_checked; |
|
| 3137 | + } |
|
| 3138 | + |
|
| 3139 | + |
|
| 3140 | + /** |
|
| 3141 | + * @param int $datetime_selector_max_checked |
|
| 3142 | + */ |
|
| 3143 | + public function setDatetimeSelectorMaxChecked($datetime_selector_max_checked) |
|
| 3144 | + { |
|
| 3145 | + $this->datetime_selector_max_checked = absint($datetime_selector_max_checked); |
|
| 3146 | + } |
|
| 3147 | 3147 | } |
| 3148 | 3148 | |
| 3149 | 3149 | /** |
@@ -3156,86 +3156,86 @@ discard block |
||
| 3156 | 3156 | class EE_Environment_Config extends EE_Config_Base |
| 3157 | 3157 | { |
| 3158 | 3158 | |
| 3159 | - /** |
|
| 3160 | - * Hold any php environment variables that we want to track. |
|
| 3161 | - * |
|
| 3162 | - * @var stdClass; |
|
| 3163 | - */ |
|
| 3164 | - public $php; |
|
| 3165 | - |
|
| 3166 | - |
|
| 3167 | - /** |
|
| 3168 | - * constructor |
|
| 3169 | - */ |
|
| 3170 | - public function __construct() |
|
| 3171 | - { |
|
| 3172 | - $this->php = new stdClass(); |
|
| 3173 | - $this->_set_php_values(); |
|
| 3174 | - } |
|
| 3175 | - |
|
| 3176 | - |
|
| 3177 | - /** |
|
| 3178 | - * This sets the php environment variables. |
|
| 3179 | - * |
|
| 3180 | - * @since 4.4.0 |
|
| 3181 | - * @return void |
|
| 3182 | - */ |
|
| 3183 | - protected function _set_php_values() |
|
| 3184 | - { |
|
| 3185 | - $this->php->max_input_vars = ini_get('max_input_vars'); |
|
| 3186 | - $this->php->version = phpversion(); |
|
| 3187 | - } |
|
| 3188 | - |
|
| 3189 | - |
|
| 3190 | - /** |
|
| 3191 | - * helper method for determining whether input_count is |
|
| 3192 | - * reaching the potential maximum the server can handle |
|
| 3193 | - * according to max_input_vars |
|
| 3194 | - * |
|
| 3195 | - * @param int $input_count the count of input vars. |
|
| 3196 | - * @return array { |
|
| 3197 | - * An array that represents whether available space and if no available space the error |
|
| 3198 | - * message. |
|
| 3199 | - * @type bool $has_space whether more inputs can be added. |
|
| 3200 | - * @type string $msg Any message to be displayed. |
|
| 3201 | - * } |
|
| 3202 | - */ |
|
| 3203 | - public function max_input_vars_limit_check($input_count = 0) |
|
| 3204 | - { |
|
| 3205 | - if (! empty($this->php->max_input_vars) |
|
| 3206 | - && ($input_count >= $this->php->max_input_vars) |
|
| 3207 | - ) { |
|
| 3208 | - // check the server setting because the config value could be stale |
|
| 3209 | - $max_input_vars = ini_get('max_input_vars'); |
|
| 3210 | - if ($input_count >= $max_input_vars) { |
|
| 3211 | - return sprintf( |
|
| 3212 | - esc_html__( |
|
| 3213 | - 'The maximum number of inputs on this page has been exceeded. You cannot make edits to this page because of your server\'s PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.%1$sPlease contact your web host and ask them to raise the "max_input_vars" limit.', |
|
| 3214 | - 'event_espresso' |
|
| 3215 | - ), |
|
| 3216 | - '<br>', |
|
| 3217 | - $input_count, |
|
| 3218 | - $max_input_vars |
|
| 3219 | - ); |
|
| 3220 | - } else { |
|
| 3221 | - return ''; |
|
| 3222 | - } |
|
| 3223 | - } else { |
|
| 3224 | - return ''; |
|
| 3225 | - } |
|
| 3226 | - } |
|
| 3227 | - |
|
| 3228 | - |
|
| 3229 | - /** |
|
| 3230 | - * The purpose of this method is just to force rechecking php values so if they've changed, they get updated. |
|
| 3231 | - * |
|
| 3232 | - * @since 4.4.1 |
|
| 3233 | - * @return void |
|
| 3234 | - */ |
|
| 3235 | - public function recheck_values() |
|
| 3236 | - { |
|
| 3237 | - $this->_set_php_values(); |
|
| 3238 | - } |
|
| 3159 | + /** |
|
| 3160 | + * Hold any php environment variables that we want to track. |
|
| 3161 | + * |
|
| 3162 | + * @var stdClass; |
|
| 3163 | + */ |
|
| 3164 | + public $php; |
|
| 3165 | + |
|
| 3166 | + |
|
| 3167 | + /** |
|
| 3168 | + * constructor |
|
| 3169 | + */ |
|
| 3170 | + public function __construct() |
|
| 3171 | + { |
|
| 3172 | + $this->php = new stdClass(); |
|
| 3173 | + $this->_set_php_values(); |
|
| 3174 | + } |
|
| 3175 | + |
|
| 3176 | + |
|
| 3177 | + /** |
|
| 3178 | + * This sets the php environment variables. |
|
| 3179 | + * |
|
| 3180 | + * @since 4.4.0 |
|
| 3181 | + * @return void |
|
| 3182 | + */ |
|
| 3183 | + protected function _set_php_values() |
|
| 3184 | + { |
|
| 3185 | + $this->php->max_input_vars = ini_get('max_input_vars'); |
|
| 3186 | + $this->php->version = phpversion(); |
|
| 3187 | + } |
|
| 3188 | + |
|
| 3189 | + |
|
| 3190 | + /** |
|
| 3191 | + * helper method for determining whether input_count is |
|
| 3192 | + * reaching the potential maximum the server can handle |
|
| 3193 | + * according to max_input_vars |
|
| 3194 | + * |
|
| 3195 | + * @param int $input_count the count of input vars. |
|
| 3196 | + * @return array { |
|
| 3197 | + * An array that represents whether available space and if no available space the error |
|
| 3198 | + * message. |
|
| 3199 | + * @type bool $has_space whether more inputs can be added. |
|
| 3200 | + * @type string $msg Any message to be displayed. |
|
| 3201 | + * } |
|
| 3202 | + */ |
|
| 3203 | + public function max_input_vars_limit_check($input_count = 0) |
|
| 3204 | + { |
|
| 3205 | + if (! empty($this->php->max_input_vars) |
|
| 3206 | + && ($input_count >= $this->php->max_input_vars) |
|
| 3207 | + ) { |
|
| 3208 | + // check the server setting because the config value could be stale |
|
| 3209 | + $max_input_vars = ini_get('max_input_vars'); |
|
| 3210 | + if ($input_count >= $max_input_vars) { |
|
| 3211 | + return sprintf( |
|
| 3212 | + esc_html__( |
|
| 3213 | + 'The maximum number of inputs on this page has been exceeded. You cannot make edits to this page because of your server\'s PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.%1$sPlease contact your web host and ask them to raise the "max_input_vars" limit.', |
|
| 3214 | + 'event_espresso' |
|
| 3215 | + ), |
|
| 3216 | + '<br>', |
|
| 3217 | + $input_count, |
|
| 3218 | + $max_input_vars |
|
| 3219 | + ); |
|
| 3220 | + } else { |
|
| 3221 | + return ''; |
|
| 3222 | + } |
|
| 3223 | + } else { |
|
| 3224 | + return ''; |
|
| 3225 | + } |
|
| 3226 | + } |
|
| 3227 | + |
|
| 3228 | + |
|
| 3229 | + /** |
|
| 3230 | + * The purpose of this method is just to force rechecking php values so if they've changed, they get updated. |
|
| 3231 | + * |
|
| 3232 | + * @since 4.4.1 |
|
| 3233 | + * @return void |
|
| 3234 | + */ |
|
| 3235 | + public function recheck_values() |
|
| 3236 | + { |
|
| 3237 | + $this->_set_php_values(); |
|
| 3238 | + } |
|
| 3239 | 3239 | } |
| 3240 | 3240 | |
| 3241 | 3241 | /** |
@@ -3248,21 +3248,21 @@ discard block |
||
| 3248 | 3248 | class EE_Tax_Config extends EE_Config_Base |
| 3249 | 3249 | { |
| 3250 | 3250 | |
| 3251 | - /* |
|
| 3251 | + /* |
|
| 3252 | 3252 | * flag to indicate whether or not to display ticket prices with the taxes included |
| 3253 | 3253 | * |
| 3254 | 3254 | * @var boolean $prices_displayed_including_taxes |
| 3255 | 3255 | */ |
| 3256 | - public $prices_displayed_including_taxes; |
|
| 3256 | + public $prices_displayed_including_taxes; |
|
| 3257 | 3257 | |
| 3258 | 3258 | |
| 3259 | - /** |
|
| 3260 | - * class constructor |
|
| 3261 | - */ |
|
| 3262 | - public function __construct() |
|
| 3263 | - { |
|
| 3264 | - $this->prices_displayed_including_taxes = true; |
|
| 3265 | - } |
|
| 3259 | + /** |
|
| 3260 | + * class constructor |
|
| 3261 | + */ |
|
| 3262 | + public function __construct() |
|
| 3263 | + { |
|
| 3264 | + $this->prices_displayed_including_taxes = true; |
|
| 3265 | + } |
|
| 3266 | 3266 | } |
| 3267 | 3267 | |
| 3268 | 3268 | /** |
@@ -3276,19 +3276,19 @@ discard block |
||
| 3276 | 3276 | class EE_Messages_Config extends EE_Config_Base |
| 3277 | 3277 | { |
| 3278 | 3278 | |
| 3279 | - /** |
|
| 3280 | - * This is an integer representing the deletion threshold in months for when old messages will get deleted. |
|
| 3281 | - * A value of 0 represents never deleting. Default is 0. |
|
| 3282 | - * |
|
| 3283 | - * @var integer |
|
| 3284 | - */ |
|
| 3285 | - public $delete_threshold; |
|
| 3279 | + /** |
|
| 3280 | + * This is an integer representing the deletion threshold in months for when old messages will get deleted. |
|
| 3281 | + * A value of 0 represents never deleting. Default is 0. |
|
| 3282 | + * |
|
| 3283 | + * @var integer |
|
| 3284 | + */ |
|
| 3285 | + public $delete_threshold; |
|
| 3286 | 3286 | |
| 3287 | 3287 | |
| 3288 | - public function __construct() |
|
| 3289 | - { |
|
| 3290 | - $this->delete_threshold = 0; |
|
| 3291 | - } |
|
| 3288 | + public function __construct() |
|
| 3289 | + { |
|
| 3290 | + $this->delete_threshold = 0; |
|
| 3291 | + } |
|
| 3292 | 3292 | } |
| 3293 | 3293 | |
| 3294 | 3294 | /** |
@@ -3299,31 +3299,31 @@ discard block |
||
| 3299 | 3299 | class EE_Gateway_Config extends EE_Config_Base |
| 3300 | 3300 | { |
| 3301 | 3301 | |
| 3302 | - /** |
|
| 3303 | - * Array with keys that are payment gateways slugs, and values are arrays |
|
| 3304 | - * with any config info the gateway wants to store |
|
| 3305 | - * |
|
| 3306 | - * @var array |
|
| 3307 | - */ |
|
| 3308 | - public $payment_settings; |
|
| 3309 | - |
|
| 3310 | - /** |
|
| 3311 | - * Where keys are gateway slugs, and values are booleans indicating whether or not |
|
| 3312 | - * the gateway is stored in the uploads directory |
|
| 3313 | - * |
|
| 3314 | - * @var array |
|
| 3315 | - */ |
|
| 3316 | - public $active_gateways; |
|
| 3317 | - |
|
| 3318 | - |
|
| 3319 | - /** |
|
| 3320 | - * class constructor |
|
| 3321 | - * |
|
| 3322 | - * @deprecated |
|
| 3323 | - */ |
|
| 3324 | - public function __construct() |
|
| 3325 | - { |
|
| 3326 | - $this->payment_settings = array(); |
|
| 3327 | - $this->active_gateways = array('Invoice' => false); |
|
| 3328 | - } |
|
| 3302 | + /** |
|
| 3303 | + * Array with keys that are payment gateways slugs, and values are arrays |
|
| 3304 | + * with any config info the gateway wants to store |
|
| 3305 | + * |
|
| 3306 | + * @var array |
|
| 3307 | + */ |
|
| 3308 | + public $payment_settings; |
|
| 3309 | + |
|
| 3310 | + /** |
|
| 3311 | + * Where keys are gateway slugs, and values are booleans indicating whether or not |
|
| 3312 | + * the gateway is stored in the uploads directory |
|
| 3313 | + * |
|
| 3314 | + * @var array |
|
| 3315 | + */ |
|
| 3316 | + public $active_gateways; |
|
| 3317 | + |
|
| 3318 | + |
|
| 3319 | + /** |
|
| 3320 | + * class constructor |
|
| 3321 | + * |
|
| 3322 | + * @deprecated |
|
| 3323 | + */ |
|
| 3324 | + public function __construct() |
|
| 3325 | + { |
|
| 3326 | + $this->payment_settings = array(); |
|
| 3327 | + $this->active_gateways = array('Invoice' => false); |
|
| 3328 | + } |
|
| 3329 | 3329 | } |