@@ -13,755 +13,755 @@ |
||
| 13 | 13 | class EEM_Datetime extends EEM_Soft_Delete_Base |
| 14 | 14 | { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * @var EEM_Datetime $_instance |
|
| 18 | - */ |
|
| 19 | - protected static $_instance; |
|
| 20 | - |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * private constructor to prevent direct creation |
|
| 24 | - * |
|
| 25 | - * @param string $timezone A string representing the timezone we want to set for returned Date Time Strings |
|
| 26 | - * (and any incoming timezone data that gets saved). |
|
| 27 | - * Note this just sends the timezone info to the date time model field objects. |
|
| 28 | - * Default is NULL |
|
| 29 | - * (and will be assumed using the set timezone in the 'timezone_string' wp option) |
|
| 30 | - * @throws EE_Error |
|
| 31 | - * @throws InvalidArgumentException |
|
| 32 | - * @throws InvalidArgumentException |
|
| 33 | - */ |
|
| 34 | - protected function __construct($timezone) |
|
| 35 | - { |
|
| 36 | - $this->singular_item = esc_html__('Datetime', 'event_espresso'); |
|
| 37 | - $this->plural_item = esc_html__('Datetimes', 'event_espresso'); |
|
| 38 | - $this->_tables = array( |
|
| 39 | - 'Datetime' => new EE_Primary_Table('esp_datetime', 'DTT_ID'), |
|
| 40 | - ); |
|
| 41 | - $this->_fields = array( |
|
| 42 | - 'Datetime' => array( |
|
| 43 | - 'DTT_ID' => new EE_Primary_Key_Int_Field( |
|
| 44 | - 'DTT_ID', |
|
| 45 | - esc_html__('Datetime ID', 'event_espresso') |
|
| 46 | - ), |
|
| 47 | - 'EVT_ID' => new EE_Foreign_Key_Int_Field( |
|
| 48 | - 'EVT_ID', |
|
| 49 | - esc_html__('Event ID', 'event_espresso'), |
|
| 50 | - false, |
|
| 51 | - 0, |
|
| 52 | - 'Event' |
|
| 53 | - ), |
|
| 54 | - 'DTT_name' => new EE_Plain_Text_Field( |
|
| 55 | - 'DTT_name', |
|
| 56 | - esc_html__('Datetime Name', 'event_espresso'), |
|
| 57 | - false, |
|
| 58 | - '' |
|
| 59 | - ), |
|
| 60 | - 'DTT_description' => new EE_Post_Content_Field( |
|
| 61 | - 'DTT_description', |
|
| 62 | - esc_html__('Description for Datetime', 'event_espresso'), |
|
| 63 | - false, |
|
| 64 | - '' |
|
| 65 | - ), |
|
| 66 | - 'DTT_EVT_start' => new EE_Datetime_Field( |
|
| 67 | - 'DTT_EVT_start', |
|
| 68 | - esc_html__('Start time/date of Event', 'event_espresso'), |
|
| 69 | - false, |
|
| 70 | - EE_Datetime_Field::now, |
|
| 71 | - $timezone |
|
| 72 | - ), |
|
| 73 | - 'DTT_EVT_end' => new EE_Datetime_Field( |
|
| 74 | - 'DTT_EVT_end', |
|
| 75 | - esc_html__('End time/date of Event', 'event_espresso'), |
|
| 76 | - false, |
|
| 77 | - EE_Datetime_Field::now, |
|
| 78 | - $timezone |
|
| 79 | - ), |
|
| 80 | - 'DTT_reg_limit' => new EE_Infinite_Integer_Field( |
|
| 81 | - 'DTT_reg_limit', |
|
| 82 | - esc_html__('Registration Limit for this time', 'event_espresso'), |
|
| 83 | - true, |
|
| 84 | - EE_INF |
|
| 85 | - ), |
|
| 86 | - 'DTT_sold' => new EE_Integer_Field( |
|
| 87 | - 'DTT_sold', |
|
| 88 | - esc_html__('How many sales for this Datetime that have occurred', 'event_espresso'), |
|
| 89 | - true, |
|
| 90 | - 0 |
|
| 91 | - ), |
|
| 92 | - 'DTT_reserved' => new EE_Integer_Field( |
|
| 93 | - 'DTT_reserved', |
|
| 94 | - esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso'), |
|
| 95 | - false, |
|
| 96 | - 0 |
|
| 97 | - ), |
|
| 98 | - 'DTT_is_primary' => new EE_Boolean_Field( |
|
| 99 | - 'DTT_is_primary', |
|
| 100 | - esc_html__('Flag indicating datetime is primary one for event', 'event_espresso'), |
|
| 101 | - false, |
|
| 102 | - false |
|
| 103 | - ), |
|
| 104 | - 'DTT_order' => new EE_Integer_Field( |
|
| 105 | - 'DTT_order', |
|
| 106 | - esc_html__('The order in which the Datetime is displayed', 'event_espresso'), |
|
| 107 | - false, |
|
| 108 | - 0 |
|
| 109 | - ), |
|
| 110 | - 'DTT_parent' => new EE_Integer_Field( |
|
| 111 | - 'DTT_parent', |
|
| 112 | - esc_html__('Indicates what DTT_ID is the parent of this DTT_ID', 'event_espresso'), |
|
| 113 | - true, |
|
| 114 | - 0 |
|
| 115 | - ), |
|
| 116 | - 'DTT_deleted' => new EE_Trashed_Flag_Field( |
|
| 117 | - 'DTT_deleted', |
|
| 118 | - esc_html__('Flag indicating datetime is archived', 'event_espresso'), |
|
| 119 | - false, |
|
| 120 | - false |
|
| 121 | - ), |
|
| 122 | - ), |
|
| 123 | - ); |
|
| 124 | - $this->_model_relations = array( |
|
| 125 | - 'Ticket' => new EE_HABTM_Relation('Datetime_Ticket'), |
|
| 126 | - 'Event' => new EE_Belongs_To_Relation(), |
|
| 127 | - 'Checkin' => new EE_Has_Many_Relation(), |
|
| 128 | - 'Datetime_Ticket' => new EE_Has_Many_Relation(), |
|
| 129 | - ); |
|
| 130 | - $path_to_event_model = 'Event'; |
|
| 131 | - $this->model_chain_to_password = $path_to_event_model; |
|
| 132 | - $this->_model_chain_to_wp_user = $path_to_event_model; |
|
| 133 | - // this model is generally available for reading |
|
| 134 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( |
|
| 135 | - $path_to_event_model |
|
| 136 | - ); |
|
| 137 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
| 138 | - $path_to_event_model |
|
| 139 | - ); |
|
| 140 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
| 141 | - $path_to_event_model |
|
| 142 | - ); |
|
| 143 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
| 144 | - $path_to_event_model, |
|
| 145 | - EEM_Base::caps_edit |
|
| 146 | - ); |
|
| 147 | - parent::__construct($timezone); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * create new blank datetime |
|
| 153 | - * |
|
| 154 | - * @access public |
|
| 155 | - * @return EE_Datetime[] array on success, FALSE on fail |
|
| 156 | - * @throws EE_Error |
|
| 157 | - * @throws InvalidArgumentException |
|
| 158 | - * @throws InvalidDataTypeException |
|
| 159 | - * @throws ReflectionException |
|
| 160 | - * @throws InvalidInterfaceException |
|
| 161 | - */ |
|
| 162 | - public function create_new_blank_datetime() |
|
| 163 | - { |
|
| 164 | - // makes sure timezone is always set. |
|
| 165 | - $timezone_string = $this->get_timezone(); |
|
| 166 | - /** |
|
| 167 | - * Filters the initial start date for the new datetime. |
|
| 168 | - * Any time included in this value will be overridden later so use additional filters to modify the time. |
|
| 169 | - * |
|
| 170 | - * @param int $start_date Unixtimestamp representing now + 30 days in seconds. |
|
| 171 | - * @return int unixtimestamp |
|
| 172 | - */ |
|
| 173 | - $start_date = apply_filters( |
|
| 174 | - 'FHEE__EEM_Datetime__create_new_blank_datetime__start_date', |
|
| 175 | - $this->current_time_for_query('DTT_EVT_start', true) + MONTH_IN_SECONDS |
|
| 176 | - ); |
|
| 177 | - /** |
|
| 178 | - * Filters the initial end date for the new datetime. |
|
| 179 | - * Any time included in this value will be overridden later so use additional filters to modify the time. |
|
| 180 | - * |
|
| 181 | - * @param int $end_data Unixtimestamp representing now + 30 days in seconds. |
|
| 182 | - * @return int unixtimestamp |
|
| 183 | - */ |
|
| 184 | - $end_date = apply_filters( |
|
| 185 | - 'FHEE__EEM_Datetime__create_new_blank_datetime__end_date', |
|
| 186 | - $this->current_time_for_query('DTT_EVT_end', true) + MONTH_IN_SECONDS |
|
| 187 | - ); |
|
| 188 | - $blank_datetime = EE_Datetime::new_instance( |
|
| 189 | - array( |
|
| 190 | - 'DTT_EVT_start' => $start_date, |
|
| 191 | - 'DTT_EVT_end' => $end_date, |
|
| 192 | - 'DTT_order' => 1, |
|
| 193 | - 'DTT_reg_limit' => EE_INF, |
|
| 194 | - ), |
|
| 195 | - $timezone_string |
|
| 196 | - ); |
|
| 197 | - /** |
|
| 198 | - * Filters the initial start time and format for the new EE_Datetime instance. |
|
| 199 | - * |
|
| 200 | - * @param array $start_time An array having size 2. First element is the time, second element is the time |
|
| 201 | - * format. |
|
| 202 | - * @return array |
|
| 203 | - */ |
|
| 204 | - $start_time = apply_filters( |
|
| 205 | - 'FHEE__EEM_Datetime__create_new_blank_datetime__start_time', |
|
| 206 | - ['8am', 'ga'] |
|
| 207 | - ); |
|
| 208 | - /** |
|
| 209 | - * Filters the initial end time and format for the new EE_Datetime instance. |
|
| 210 | - * |
|
| 211 | - * @param array $end_time An array having size 2. First element is the time, second element is the time |
|
| 212 | - * format |
|
| 213 | - * @return array |
|
| 214 | - */ |
|
| 215 | - $end_time = apply_filters( |
|
| 216 | - 'FHEE__EEM_Datetime__create_new_blank_datetime__end_time', |
|
| 217 | - ['5pm', 'ga'] |
|
| 218 | - ); |
|
| 219 | - $this->validateStartAndEndTimeForBlankDate($start_time, $end_time); |
|
| 220 | - $blank_datetime->set_start_time( |
|
| 221 | - $this->convert_datetime_for_query( |
|
| 222 | - 'DTT_EVT_start', |
|
| 223 | - $start_time[0], |
|
| 224 | - $start_time[1], |
|
| 225 | - $timezone_string |
|
| 226 | - ) |
|
| 227 | - ); |
|
| 228 | - $blank_datetime->set_end_time( |
|
| 229 | - $this->convert_datetime_for_query( |
|
| 230 | - 'DTT_EVT_end', |
|
| 231 | - $end_time[0], |
|
| 232 | - $end_time[1], |
|
| 233 | - $timezone_string |
|
| 234 | - ) |
|
| 235 | - ); |
|
| 236 | - return array($blank_datetime); |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - |
|
| 240 | - /** |
|
| 241 | - * Validates whether the start_time and end_time are in the expected format. |
|
| 242 | - * @param array $start_time |
|
| 243 | - * @param array $end_time |
|
| 244 | - * @throws InvalidArgumentException |
|
| 245 | - * @throws InvalidDataTypeException |
|
| 246 | - */ |
|
| 247 | - private function validateStartAndEndTimeForBlankDate($start_time, $end_time) |
|
| 248 | - { |
|
| 249 | - if (! is_array($start_time)) { |
|
| 250 | - throw new InvalidDataTypeException('start_time', $start_time, 'array'); |
|
| 251 | - } |
|
| 252 | - if (! is_array($end_time)) { |
|
| 253 | - throw new InvalidDataTypeException('end_time', $end_time, 'array'); |
|
| 254 | - } |
|
| 255 | - if (count($start_time) !== 2) { |
|
| 256 | - throw new InvalidArgumentException( |
|
| 257 | - sprintf( |
|
| 258 | - 'The variable %1$s is expected to be an array with two elements. The first item in the ' |
|
| 259 | - . 'array should be a valid time string, the second item in the array should be a valid time format', |
|
| 260 | - '$start_time' |
|
| 261 | - ) |
|
| 262 | - ); |
|
| 263 | - } |
|
| 264 | - if (count($end_time) !== 2) { |
|
| 265 | - throw new InvalidArgumentException( |
|
| 266 | - sprintf( |
|
| 267 | - 'The variable %1$s is expected to be an array with two elements. The first item in the ' |
|
| 268 | - . 'array should be a valid time string, the second item in the array should be a valid time format', |
|
| 269 | - '$end_time' |
|
| 270 | - ) |
|
| 271 | - ); |
|
| 272 | - } |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - |
|
| 276 | - /** |
|
| 277 | - * get event start date from db |
|
| 278 | - * |
|
| 279 | - * @access public |
|
| 280 | - * @param int $EVT_ID |
|
| 281 | - * @return EE_Datetime[] array on success, FALSE on fail |
|
| 282 | - * @throws EE_Error |
|
| 283 | - */ |
|
| 284 | - public function get_all_event_dates($EVT_ID = 0) |
|
| 285 | - { |
|
| 286 | - if (! $EVT_ID) { // on add_new_event event_id gets set to 0 |
|
| 287 | - return $this->create_new_blank_datetime(); |
|
| 288 | - } |
|
| 289 | - $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
|
| 290 | - if (empty($results)) { |
|
| 291 | - return $this->create_new_blank_datetime(); |
|
| 292 | - } |
|
| 293 | - return $results; |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - |
|
| 297 | - /** |
|
| 298 | - * get all datetimes attached to an event ordered by the DTT_order field |
|
| 299 | - * |
|
| 300 | - * @public |
|
| 301 | - * @param int $EVT_ID event id |
|
| 302 | - * @param boolean $include_expired |
|
| 303 | - * @param boolean $include_deleted |
|
| 304 | - * @param int $limit If included then limit the count of results by |
|
| 305 | - * the given number |
|
| 306 | - * @return EE_Datetime[] |
|
| 307 | - * @throws EE_Error |
|
| 308 | - */ |
|
| 309 | - public function get_datetimes_for_event_ordered_by_DTT_order( |
|
| 310 | - $EVT_ID, |
|
| 311 | - $include_expired = true, |
|
| 312 | - $include_deleted = true, |
|
| 313 | - $limit = null |
|
| 314 | - ) { |
|
| 315 | - // sanitize EVT_ID |
|
| 316 | - $EVT_ID = absint($EVT_ID); |
|
| 317 | - $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
|
| 318 | - $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
| 319 | - $where_params = array('Event.EVT_ID' => $EVT_ID); |
|
| 320 | - $query_params = ! empty($limit) |
|
| 321 | - ? array( |
|
| 322 | - $where_params, |
|
| 323 | - 'limit' => $limit, |
|
| 324 | - 'order_by' => array('DTT_order' => 'ASC'), |
|
| 325 | - 'default_where_conditions' => 'none', |
|
| 326 | - ) |
|
| 327 | - : array( |
|
| 328 | - $where_params, |
|
| 329 | - 'order_by' => array('DTT_order' => 'ASC'), |
|
| 330 | - 'default_where_conditions' => 'none', |
|
| 331 | - ); |
|
| 332 | - if (! $include_expired) { |
|
| 333 | - $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true)); |
|
| 334 | - } |
|
| 335 | - if ($include_deleted) { |
|
| 336 | - $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
| 337 | - } |
|
| 338 | - /** @var EE_Datetime[] $result */ |
|
| 339 | - $result = $this->get_all($query_params); |
|
| 340 | - $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
| 341 | - return $result; |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - |
|
| 345 | - /** |
|
| 346 | - * Gets the datetimes for the event (with the given limit), and orders them by "importance". |
|
| 347 | - * By importance, we mean that the primary datetimes are most important (DEPRECATED FOR NOW), |
|
| 348 | - * and then the earlier datetimes are the most important. |
|
| 349 | - * Maybe we'll want this to take into account datetimes that haven't already passed, but we don't yet. |
|
| 350 | - * |
|
| 351 | - * @param int $EVT_ID |
|
| 352 | - * @param int $limit |
|
| 353 | - * @return EE_Datetime[]|EE_Base_Class[] |
|
| 354 | - * @throws EE_Error |
|
| 355 | - */ |
|
| 356 | - public function get_datetimes_for_event_ordered_by_importance($EVT_ID = 0, $limit = null) |
|
| 357 | - { |
|
| 358 | - return $this->get_all( |
|
| 359 | - array( |
|
| 360 | - array('Event.EVT_ID' => $EVT_ID), |
|
| 361 | - 'limit' => $limit, |
|
| 362 | - 'order_by' => array('DTT_EVT_start' => 'ASC'), |
|
| 363 | - 'default_where_conditions' => 'none', |
|
| 364 | - ) |
|
| 365 | - ); |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - |
|
| 369 | - /** |
|
| 370 | - * @param int $EVT_ID |
|
| 371 | - * @param boolean $include_expired |
|
| 372 | - * @param boolean $include_deleted |
|
| 373 | - * @return EE_Datetime |
|
| 374 | - * @throws EE_Error |
|
| 375 | - */ |
|
| 376 | - public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false, $include_deleted = false) |
|
| 377 | - { |
|
| 378 | - $results = $this->get_datetimes_for_event_ordered_by_start_time( |
|
| 379 | - $EVT_ID, |
|
| 380 | - $include_expired, |
|
| 381 | - $include_deleted, |
|
| 382 | - 1 |
|
| 383 | - ); |
|
| 384 | - if ($results) { |
|
| 385 | - return array_shift($results); |
|
| 386 | - } |
|
| 387 | - return null; |
|
| 388 | - } |
|
| 389 | - |
|
| 390 | - |
|
| 391 | - /** |
|
| 392 | - * Gets the 'primary' datetime for an event. |
|
| 393 | - * |
|
| 394 | - * @param int $EVT_ID |
|
| 395 | - * @param bool $try_to_exclude_expired |
|
| 396 | - * @param bool $try_to_exclude_deleted |
|
| 397 | - * @return \EE_Datetime |
|
| 398 | - * @throws EE_Error |
|
| 399 | - */ |
|
| 400 | - public function get_primary_datetime_for_event( |
|
| 401 | - $EVT_ID, |
|
| 402 | - $try_to_exclude_expired = true, |
|
| 403 | - $try_to_exclude_deleted = true |
|
| 404 | - ) { |
|
| 405 | - if ($try_to_exclude_expired) { |
|
| 406 | - $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false); |
|
| 407 | - if ($non_expired) { |
|
| 408 | - return $non_expired; |
|
| 409 | - } |
|
| 410 | - } |
|
| 411 | - if ($try_to_exclude_deleted) { |
|
| 412 | - $expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true); |
|
| 413 | - if ($expired_even) { |
|
| 414 | - return $expired_even; |
|
| 415 | - } |
|
| 416 | - } |
|
| 417 | - return $this->get_oldest_datetime_for_event($EVT_ID, true, true); |
|
| 418 | - } |
|
| 419 | - |
|
| 420 | - |
|
| 421 | - /** |
|
| 422 | - * Gets ALL the datetimes for an event (including trashed ones, for now), ordered |
|
| 423 | - * only by start date |
|
| 424 | - * |
|
| 425 | - * @param int $EVT_ID |
|
| 426 | - * @param boolean $include_expired |
|
| 427 | - * @param boolean $include_deleted |
|
| 428 | - * @param int $limit |
|
| 429 | - * @return EE_Datetime[] |
|
| 430 | - * @throws EE_Error |
|
| 431 | - */ |
|
| 432 | - public function get_datetimes_for_event_ordered_by_start_time( |
|
| 433 | - $EVT_ID, |
|
| 434 | - $include_expired = true, |
|
| 435 | - $include_deleted = true, |
|
| 436 | - $limit = null |
|
| 437 | - ) { |
|
| 438 | - // sanitize EVT_ID |
|
| 439 | - $EVT_ID = absint($EVT_ID); |
|
| 440 | - $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
|
| 441 | - $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
| 442 | - $query_params = array( |
|
| 443 | - array( |
|
| 444 | - 'Event.EVT_ID' => $EVT_ID |
|
| 445 | - ), |
|
| 446 | - 'order_by' => array( |
|
| 447 | - 'DTT_EVT_start' => 'asc' |
|
| 448 | - ), |
|
| 449 | - 'default_where_conditions' => EEM_Base::default_where_conditions_this_only |
|
| 450 | - ); |
|
| 451 | - if (! $include_expired) { |
|
| 452 | - $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true)); |
|
| 453 | - } |
|
| 454 | - if ($include_deleted) { |
|
| 455 | - $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
| 456 | - } |
|
| 457 | - if ($limit) { |
|
| 458 | - $query_params['limit'] = $limit; |
|
| 459 | - } |
|
| 460 | - /** @var EE_Datetime[] $result */ |
|
| 461 | - $result = $this->get_all($query_params); |
|
| 462 | - $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
| 463 | - return $result; |
|
| 464 | - } |
|
| 465 | - |
|
| 466 | - |
|
| 467 | - /** |
|
| 468 | - * Gets ALL the datetimes for an ticket (including trashed ones, for now), ordered |
|
| 469 | - * only by start date |
|
| 470 | - * |
|
| 471 | - * @param int $TKT_ID |
|
| 472 | - * @param boolean $include_expired |
|
| 473 | - * @param boolean $include_deleted |
|
| 474 | - * @param int $limit |
|
| 475 | - * @return EE_Datetime[] |
|
| 476 | - * @throws EE_Error |
|
| 477 | - */ |
|
| 478 | - public function get_datetimes_for_ticket_ordered_by_start_time( |
|
| 479 | - $TKT_ID, |
|
| 480 | - $include_expired = true, |
|
| 481 | - $include_deleted = true, |
|
| 482 | - $limit = null |
|
| 483 | - ) { |
|
| 484 | - // sanitize TKT_ID |
|
| 485 | - $TKT_ID = absint($TKT_ID); |
|
| 486 | - $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
|
| 487 | - $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
| 488 | - $query_params = array(array('Ticket.TKT_ID' => $TKT_ID), 'order_by' => array('DTT_EVT_start' => 'asc')); |
|
| 489 | - if (! $include_expired) { |
|
| 490 | - $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true)); |
|
| 491 | - } |
|
| 492 | - if ($include_deleted) { |
|
| 493 | - $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
| 494 | - } |
|
| 495 | - if ($limit) { |
|
| 496 | - $query_params['limit'] = $limit; |
|
| 497 | - } |
|
| 498 | - /** @var EE_Datetime[] $result */ |
|
| 499 | - $result = $this->get_all($query_params); |
|
| 500 | - $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
| 501 | - return $result; |
|
| 502 | - } |
|
| 503 | - |
|
| 504 | - |
|
| 505 | - /** |
|
| 506 | - * Gets all the datetimes for a ticket (including trashed ones, for now), ordered by the DTT_order for the |
|
| 507 | - * datetimes. |
|
| 508 | - * |
|
| 509 | - * @param int $TKT_ID ID of ticket to retrieve the datetimes for |
|
| 510 | - * @param boolean $include_expired whether to include expired datetimes or not |
|
| 511 | - * @param boolean $include_deleted whether to include trashed datetimes or not. |
|
| 512 | - * @param int|null $limit if null, no limit, if int then limit results by |
|
| 513 | - * that number |
|
| 514 | - * @return EE_Datetime[] |
|
| 515 | - * @throws EE_Error |
|
| 516 | - */ |
|
| 517 | - public function get_datetimes_for_ticket_ordered_by_DTT_order( |
|
| 518 | - $TKT_ID, |
|
| 519 | - $include_expired = true, |
|
| 520 | - $include_deleted = true, |
|
| 521 | - $limit = null |
|
| 522 | - ) { |
|
| 523 | - // sanitize id. |
|
| 524 | - $TKT_ID = absint($TKT_ID); |
|
| 525 | - $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
|
| 526 | - $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
| 527 | - $where_params = array('Ticket.TKT_ID' => $TKT_ID); |
|
| 528 | - $query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC')); |
|
| 529 | - if (! $include_expired) { |
|
| 530 | - $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true)); |
|
| 531 | - } |
|
| 532 | - if ($include_deleted) { |
|
| 533 | - $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
| 534 | - } |
|
| 535 | - if ($limit) { |
|
| 536 | - $query_params['limit'] = $limit; |
|
| 537 | - } |
|
| 538 | - /** @var EE_Datetime[] $result */ |
|
| 539 | - $result = $this->get_all($query_params); |
|
| 540 | - $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
| 541 | - return $result; |
|
| 542 | - } |
|
| 543 | - |
|
| 544 | - |
|
| 545 | - /** |
|
| 546 | - * Gets the most important datetime for a particular event (ie, the primary event usually. But if for some WACK |
|
| 547 | - * reason it doesn't exist, we consider the earliest event the most important) |
|
| 548 | - * |
|
| 549 | - * @param int $EVT_ID |
|
| 550 | - * @return EE_Datetime |
|
| 551 | - * @throws EE_Error |
|
| 552 | - */ |
|
| 553 | - public function get_most_important_datetime_for_event($EVT_ID) |
|
| 554 | - { |
|
| 555 | - $results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1); |
|
| 556 | - if ($results) { |
|
| 557 | - return array_shift($results); |
|
| 558 | - } |
|
| 559 | - return null; |
|
| 560 | - } |
|
| 561 | - |
|
| 562 | - |
|
| 563 | - /** |
|
| 564 | - * This returns a wpdb->results Array of all DTT month and years matching the incoming query params and |
|
| 565 | - * grouped by month and year. |
|
| 566 | - * |
|
| 567 | - * @param array $where_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions |
|
| 568 | - * @param string $evt_active_status A string representing the evt active status to filter the months by. |
|
| 569 | - * Can be: |
|
| 570 | - * - '' = no filter |
|
| 571 | - * - upcoming = Published events with at least one upcoming datetime. |
|
| 572 | - * - expired = Events with all datetimes expired. |
|
| 573 | - * - active = Events that are published and have at least one datetime that |
|
| 574 | - * starts before now and ends after now. |
|
| 575 | - * - inactive = Events that are either not published. |
|
| 576 | - * @return EE_Base_Class[] |
|
| 577 | - * @throws EE_Error |
|
| 578 | - * @throws InvalidArgumentException |
|
| 579 | - * @throws InvalidArgumentException |
|
| 580 | - */ |
|
| 581 | - public function get_dtt_months_and_years($where_params, $evt_active_status = '') |
|
| 582 | - { |
|
| 583 | - $current_time_for_DTT_EVT_start = $this->current_time_for_query('DTT_EVT_start'); |
|
| 584 | - $current_time_for_DTT_EVT_end = $this->current_time_for_query('DTT_EVT_end'); |
|
| 585 | - switch ($evt_active_status) { |
|
| 586 | - case 'upcoming': |
|
| 587 | - $where_params['Event.status'] = 'publish'; |
|
| 588 | - // if there are already query_params matching DTT_EVT_start then we need to modify that to add them. |
|
| 589 | - if (isset($where_params['DTT_EVT_start'])) { |
|
| 590 | - $where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start']; |
|
| 591 | - } |
|
| 592 | - $where_params['DTT_EVT_start'] = array('>', $current_time_for_DTT_EVT_start); |
|
| 593 | - break; |
|
| 594 | - case 'expired': |
|
| 595 | - if (isset($where_params['Event.status'])) { |
|
| 596 | - unset($where_params['Event.status']); |
|
| 597 | - } |
|
| 598 | - // get events to exclude |
|
| 599 | - $exclude_query[0] = array_merge( |
|
| 600 | - $where_params, |
|
| 601 | - array('DTT_EVT_end' => array('>', $current_time_for_DTT_EVT_end)) |
|
| 602 | - ); |
|
| 603 | - // first get all events that have datetimes where its not expired. |
|
| 604 | - $event_ids = $this->_get_all_wpdb_results( |
|
| 605 | - $exclude_query, |
|
| 606 | - OBJECT_K, |
|
| 607 | - 'Datetime.EVT_ID' |
|
| 608 | - ); |
|
| 609 | - $event_ids = array_keys($event_ids); |
|
| 610 | - if (isset($where_params['DTT_EVT_end'])) { |
|
| 611 | - $where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
|
| 612 | - } |
|
| 613 | - $where_params['DTT_EVT_end'] = array('<', $current_time_for_DTT_EVT_end); |
|
| 614 | - $where_params['Event.EVT_ID'] = array('NOT IN', $event_ids); |
|
| 615 | - break; |
|
| 616 | - case 'active': |
|
| 617 | - $where_params['Event.status'] = 'publish'; |
|
| 618 | - if (isset($where_params['DTT_EVT_start'])) { |
|
| 619 | - $where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start']; |
|
| 620 | - } |
|
| 621 | - if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
| 622 | - $where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end']; |
|
| 623 | - } |
|
| 624 | - $where_params['DTT_EVT_start'] = array('<', $current_time_for_DTT_EVT_start); |
|
| 625 | - $where_params['DTT_EVT_end'] = array('>', $current_time_for_DTT_EVT_end); |
|
| 626 | - break; |
|
| 627 | - case 'inactive': |
|
| 628 | - if (isset($where_params['Event.status'])) { |
|
| 629 | - unset($where_params['Event.status']); |
|
| 630 | - } |
|
| 631 | - if (isset($where_params['OR'])) { |
|
| 632 | - $where_params['AND']['OR'] = $where_params['OR']; |
|
| 633 | - } |
|
| 634 | - if (isset($where_params['DTT_EVT_end'])) { |
|
| 635 | - $where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
|
| 636 | - unset($where_params['DTT_EVT_end']); |
|
| 637 | - } |
|
| 638 | - if (isset($where_params['DTT_EVT_start'])) { |
|
| 639 | - $where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start']; |
|
| 640 | - unset($where_params['DTT_EVT_start']); |
|
| 641 | - } |
|
| 642 | - $where_params['AND']['Event.status'] = array('!=', 'publish'); |
|
| 643 | - break; |
|
| 644 | - } |
|
| 645 | - $query_params[0] = $where_params; |
|
| 646 | - $query_params['group_by'] = array('dtt_year', 'dtt_month'); |
|
| 647 | - $query_params['order_by'] = array('DTT_EVT_start' => 'DESC'); |
|
| 648 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( |
|
| 649 | - $this->get_timezone(), |
|
| 650 | - 'DTT_EVT_start' |
|
| 651 | - ); |
|
| 652 | - $columns_to_select = array( |
|
| 653 | - 'dtt_year' => array('YEAR(' . $query_interval . ')', '%s'), |
|
| 654 | - 'dtt_month' => array('MONTHNAME(' . $query_interval . ')', '%s'), |
|
| 655 | - 'dtt_month_num' => array('MONTH(' . $query_interval . ')', '%s'), |
|
| 656 | - ); |
|
| 657 | - return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
| 658 | - } |
|
| 659 | - |
|
| 660 | - |
|
| 661 | - /** |
|
| 662 | - * Updates the DTT_sold attribute on each datetime (based on the registrations |
|
| 663 | - * for the tickets for each datetime) |
|
| 664 | - * |
|
| 665 | - * @param EE_Base_Class[]|EE_Datetime[] $datetimes |
|
| 666 | - * @throws EE_Error |
|
| 667 | - */ |
|
| 668 | - public function update_sold($datetimes) |
|
| 669 | - { |
|
| 670 | - EE_Error::doing_it_wrong( |
|
| 671 | - __FUNCTION__, |
|
| 672 | - esc_html__( |
|
| 673 | - 'Please use \EEM_Ticket::update_tickets_sold() instead which will in turn correctly update both the Ticket AND Datetime counts.', |
|
| 674 | - 'event_espresso' |
|
| 675 | - ), |
|
| 676 | - '4.9.32.rc.005' |
|
| 677 | - ); |
|
| 678 | - foreach ($datetimes as $datetime) { |
|
| 679 | - $datetime->update_sold(); |
|
| 680 | - } |
|
| 681 | - } |
|
| 682 | - |
|
| 683 | - |
|
| 684 | - /** |
|
| 685 | - * Gets the total number of tickets available at a particular datetime |
|
| 686 | - * (does NOT take into account the datetime's spaces available) |
|
| 687 | - * |
|
| 688 | - * @param int $DTT_ID |
|
| 689 | - * @param array $query_params |
|
| 690 | - * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF, IF there are NO |
|
| 691 | - * tickets attached to datetime then FALSE is returned. |
|
| 692 | - */ |
|
| 693 | - public function sum_tickets_currently_available_at_datetime($DTT_ID, array $query_params = array()) |
|
| 694 | - { |
|
| 695 | - $datetime = $this->get_one_by_ID($DTT_ID); |
|
| 696 | - if ($datetime instanceof EE_Datetime) { |
|
| 697 | - return $datetime->tickets_remaining($query_params); |
|
| 698 | - } |
|
| 699 | - return 0; |
|
| 700 | - } |
|
| 701 | - |
|
| 702 | - |
|
| 703 | - /** |
|
| 704 | - * This returns an array of counts of datetimes in the database for each Datetime status that can be queried. |
|
| 705 | - * |
|
| 706 | - * @param array $stati_to_include If included you can restrict the statuses we return counts for by including the |
|
| 707 | - * stati you want counts for as values in the array. An empty array returns counts |
|
| 708 | - * for all valid stati. |
|
| 709 | - * @param array $query_params If included can be used to refine the conditions for returning the count (i.e. |
|
| 710 | - * only for Datetimes connected to a specific event, or specific ticket. |
|
| 711 | - * @return array The value returned is an array indexed by Datetime Status and the values are the counts. The |
|
| 712 | - * @throws EE_Error |
|
| 713 | - * stati used as index keys are: EE_Datetime::active EE_Datetime::upcoming |
|
| 714 | - * EE_Datetime::expired |
|
| 715 | - */ |
|
| 716 | - public function get_datetime_counts_by_status(array $stati_to_include = array(), array $query_params = array()) |
|
| 717 | - { |
|
| 718 | - // only accept where conditions for this query. |
|
| 719 | - $_where = isset($query_params[0]) ? $query_params[0] : array(); |
|
| 720 | - $status_query_args = array( |
|
| 721 | - EE_Datetime::active => array_merge( |
|
| 722 | - $_where, |
|
| 723 | - array('DTT_EVT_start' => array('<', time()), 'DTT_EVT_end' => array('>', time())) |
|
| 724 | - ), |
|
| 725 | - EE_Datetime::upcoming => array_merge( |
|
| 726 | - $_where, |
|
| 727 | - array('DTT_EVT_start' => array('>', time())) |
|
| 728 | - ), |
|
| 729 | - EE_Datetime::expired => array_merge( |
|
| 730 | - $_where, |
|
| 731 | - array('DTT_EVT_end' => array('<', time())) |
|
| 732 | - ), |
|
| 733 | - ); |
|
| 734 | - if (! empty($stati_to_include)) { |
|
| 735 | - foreach (array_keys($status_query_args) as $status) { |
|
| 736 | - if (! in_array($status, $stati_to_include, true)) { |
|
| 737 | - unset($status_query_args[ $status ]); |
|
| 738 | - } |
|
| 739 | - } |
|
| 740 | - } |
|
| 741 | - // loop through and query counts for each stati. |
|
| 742 | - $status_query_results = array(); |
|
| 743 | - foreach ($status_query_args as $status => $status_where_conditions) { |
|
| 744 | - $status_query_results[ $status ] = EEM_Datetime::count( |
|
| 745 | - array($status_where_conditions), |
|
| 746 | - 'DTT_ID', |
|
| 747 | - true |
|
| 748 | - ); |
|
| 749 | - } |
|
| 750 | - return $status_query_results; |
|
| 751 | - } |
|
| 752 | - |
|
| 753 | - |
|
| 754 | - /** |
|
| 755 | - * Returns the specific count for a given Datetime status matching any given query_params. |
|
| 756 | - * |
|
| 757 | - * @param string $status Valid string representation for Datetime status requested. (Defaults to Active). |
|
| 758 | - * @param array $query_params |
|
| 759 | - * @return int |
|
| 760 | - * @throws EE_Error |
|
| 761 | - */ |
|
| 762 | - public function get_datetime_count_for_status($status = EE_Datetime::active, array $query_params = array()) |
|
| 763 | - { |
|
| 764 | - $count = $this->get_datetime_counts_by_status(array($status), $query_params); |
|
| 765 | - return ! empty($count[ $status ]) ? $count[ $status ] : 0; |
|
| 766 | - } |
|
| 16 | + /** |
|
| 17 | + * @var EEM_Datetime $_instance |
|
| 18 | + */ |
|
| 19 | + protected static $_instance; |
|
| 20 | + |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * private constructor to prevent direct creation |
|
| 24 | + * |
|
| 25 | + * @param string $timezone A string representing the timezone we want to set for returned Date Time Strings |
|
| 26 | + * (and any incoming timezone data that gets saved). |
|
| 27 | + * Note this just sends the timezone info to the date time model field objects. |
|
| 28 | + * Default is NULL |
|
| 29 | + * (and will be assumed using the set timezone in the 'timezone_string' wp option) |
|
| 30 | + * @throws EE_Error |
|
| 31 | + * @throws InvalidArgumentException |
|
| 32 | + * @throws InvalidArgumentException |
|
| 33 | + */ |
|
| 34 | + protected function __construct($timezone) |
|
| 35 | + { |
|
| 36 | + $this->singular_item = esc_html__('Datetime', 'event_espresso'); |
|
| 37 | + $this->plural_item = esc_html__('Datetimes', 'event_espresso'); |
|
| 38 | + $this->_tables = array( |
|
| 39 | + 'Datetime' => new EE_Primary_Table('esp_datetime', 'DTT_ID'), |
|
| 40 | + ); |
|
| 41 | + $this->_fields = array( |
|
| 42 | + 'Datetime' => array( |
|
| 43 | + 'DTT_ID' => new EE_Primary_Key_Int_Field( |
|
| 44 | + 'DTT_ID', |
|
| 45 | + esc_html__('Datetime ID', 'event_espresso') |
|
| 46 | + ), |
|
| 47 | + 'EVT_ID' => new EE_Foreign_Key_Int_Field( |
|
| 48 | + 'EVT_ID', |
|
| 49 | + esc_html__('Event ID', 'event_espresso'), |
|
| 50 | + false, |
|
| 51 | + 0, |
|
| 52 | + 'Event' |
|
| 53 | + ), |
|
| 54 | + 'DTT_name' => new EE_Plain_Text_Field( |
|
| 55 | + 'DTT_name', |
|
| 56 | + esc_html__('Datetime Name', 'event_espresso'), |
|
| 57 | + false, |
|
| 58 | + '' |
|
| 59 | + ), |
|
| 60 | + 'DTT_description' => new EE_Post_Content_Field( |
|
| 61 | + 'DTT_description', |
|
| 62 | + esc_html__('Description for Datetime', 'event_espresso'), |
|
| 63 | + false, |
|
| 64 | + '' |
|
| 65 | + ), |
|
| 66 | + 'DTT_EVT_start' => new EE_Datetime_Field( |
|
| 67 | + 'DTT_EVT_start', |
|
| 68 | + esc_html__('Start time/date of Event', 'event_espresso'), |
|
| 69 | + false, |
|
| 70 | + EE_Datetime_Field::now, |
|
| 71 | + $timezone |
|
| 72 | + ), |
|
| 73 | + 'DTT_EVT_end' => new EE_Datetime_Field( |
|
| 74 | + 'DTT_EVT_end', |
|
| 75 | + esc_html__('End time/date of Event', 'event_espresso'), |
|
| 76 | + false, |
|
| 77 | + EE_Datetime_Field::now, |
|
| 78 | + $timezone |
|
| 79 | + ), |
|
| 80 | + 'DTT_reg_limit' => new EE_Infinite_Integer_Field( |
|
| 81 | + 'DTT_reg_limit', |
|
| 82 | + esc_html__('Registration Limit for this time', 'event_espresso'), |
|
| 83 | + true, |
|
| 84 | + EE_INF |
|
| 85 | + ), |
|
| 86 | + 'DTT_sold' => new EE_Integer_Field( |
|
| 87 | + 'DTT_sold', |
|
| 88 | + esc_html__('How many sales for this Datetime that have occurred', 'event_espresso'), |
|
| 89 | + true, |
|
| 90 | + 0 |
|
| 91 | + ), |
|
| 92 | + 'DTT_reserved' => new EE_Integer_Field( |
|
| 93 | + 'DTT_reserved', |
|
| 94 | + esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso'), |
|
| 95 | + false, |
|
| 96 | + 0 |
|
| 97 | + ), |
|
| 98 | + 'DTT_is_primary' => new EE_Boolean_Field( |
|
| 99 | + 'DTT_is_primary', |
|
| 100 | + esc_html__('Flag indicating datetime is primary one for event', 'event_espresso'), |
|
| 101 | + false, |
|
| 102 | + false |
|
| 103 | + ), |
|
| 104 | + 'DTT_order' => new EE_Integer_Field( |
|
| 105 | + 'DTT_order', |
|
| 106 | + esc_html__('The order in which the Datetime is displayed', 'event_espresso'), |
|
| 107 | + false, |
|
| 108 | + 0 |
|
| 109 | + ), |
|
| 110 | + 'DTT_parent' => new EE_Integer_Field( |
|
| 111 | + 'DTT_parent', |
|
| 112 | + esc_html__('Indicates what DTT_ID is the parent of this DTT_ID', 'event_espresso'), |
|
| 113 | + true, |
|
| 114 | + 0 |
|
| 115 | + ), |
|
| 116 | + 'DTT_deleted' => new EE_Trashed_Flag_Field( |
|
| 117 | + 'DTT_deleted', |
|
| 118 | + esc_html__('Flag indicating datetime is archived', 'event_espresso'), |
|
| 119 | + false, |
|
| 120 | + false |
|
| 121 | + ), |
|
| 122 | + ), |
|
| 123 | + ); |
|
| 124 | + $this->_model_relations = array( |
|
| 125 | + 'Ticket' => new EE_HABTM_Relation('Datetime_Ticket'), |
|
| 126 | + 'Event' => new EE_Belongs_To_Relation(), |
|
| 127 | + 'Checkin' => new EE_Has_Many_Relation(), |
|
| 128 | + 'Datetime_Ticket' => new EE_Has_Many_Relation(), |
|
| 129 | + ); |
|
| 130 | + $path_to_event_model = 'Event'; |
|
| 131 | + $this->model_chain_to_password = $path_to_event_model; |
|
| 132 | + $this->_model_chain_to_wp_user = $path_to_event_model; |
|
| 133 | + // this model is generally available for reading |
|
| 134 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( |
|
| 135 | + $path_to_event_model |
|
| 136 | + ); |
|
| 137 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
| 138 | + $path_to_event_model |
|
| 139 | + ); |
|
| 140 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
| 141 | + $path_to_event_model |
|
| 142 | + ); |
|
| 143 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
| 144 | + $path_to_event_model, |
|
| 145 | + EEM_Base::caps_edit |
|
| 146 | + ); |
|
| 147 | + parent::__construct($timezone); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * create new blank datetime |
|
| 153 | + * |
|
| 154 | + * @access public |
|
| 155 | + * @return EE_Datetime[] array on success, FALSE on fail |
|
| 156 | + * @throws EE_Error |
|
| 157 | + * @throws InvalidArgumentException |
|
| 158 | + * @throws InvalidDataTypeException |
|
| 159 | + * @throws ReflectionException |
|
| 160 | + * @throws InvalidInterfaceException |
|
| 161 | + */ |
|
| 162 | + public function create_new_blank_datetime() |
|
| 163 | + { |
|
| 164 | + // makes sure timezone is always set. |
|
| 165 | + $timezone_string = $this->get_timezone(); |
|
| 166 | + /** |
|
| 167 | + * Filters the initial start date for the new datetime. |
|
| 168 | + * Any time included in this value will be overridden later so use additional filters to modify the time. |
|
| 169 | + * |
|
| 170 | + * @param int $start_date Unixtimestamp representing now + 30 days in seconds. |
|
| 171 | + * @return int unixtimestamp |
|
| 172 | + */ |
|
| 173 | + $start_date = apply_filters( |
|
| 174 | + 'FHEE__EEM_Datetime__create_new_blank_datetime__start_date', |
|
| 175 | + $this->current_time_for_query('DTT_EVT_start', true) + MONTH_IN_SECONDS |
|
| 176 | + ); |
|
| 177 | + /** |
|
| 178 | + * Filters the initial end date for the new datetime. |
|
| 179 | + * Any time included in this value will be overridden later so use additional filters to modify the time. |
|
| 180 | + * |
|
| 181 | + * @param int $end_data Unixtimestamp representing now + 30 days in seconds. |
|
| 182 | + * @return int unixtimestamp |
|
| 183 | + */ |
|
| 184 | + $end_date = apply_filters( |
|
| 185 | + 'FHEE__EEM_Datetime__create_new_blank_datetime__end_date', |
|
| 186 | + $this->current_time_for_query('DTT_EVT_end', true) + MONTH_IN_SECONDS |
|
| 187 | + ); |
|
| 188 | + $blank_datetime = EE_Datetime::new_instance( |
|
| 189 | + array( |
|
| 190 | + 'DTT_EVT_start' => $start_date, |
|
| 191 | + 'DTT_EVT_end' => $end_date, |
|
| 192 | + 'DTT_order' => 1, |
|
| 193 | + 'DTT_reg_limit' => EE_INF, |
|
| 194 | + ), |
|
| 195 | + $timezone_string |
|
| 196 | + ); |
|
| 197 | + /** |
|
| 198 | + * Filters the initial start time and format for the new EE_Datetime instance. |
|
| 199 | + * |
|
| 200 | + * @param array $start_time An array having size 2. First element is the time, second element is the time |
|
| 201 | + * format. |
|
| 202 | + * @return array |
|
| 203 | + */ |
|
| 204 | + $start_time = apply_filters( |
|
| 205 | + 'FHEE__EEM_Datetime__create_new_blank_datetime__start_time', |
|
| 206 | + ['8am', 'ga'] |
|
| 207 | + ); |
|
| 208 | + /** |
|
| 209 | + * Filters the initial end time and format for the new EE_Datetime instance. |
|
| 210 | + * |
|
| 211 | + * @param array $end_time An array having size 2. First element is the time, second element is the time |
|
| 212 | + * format |
|
| 213 | + * @return array |
|
| 214 | + */ |
|
| 215 | + $end_time = apply_filters( |
|
| 216 | + 'FHEE__EEM_Datetime__create_new_blank_datetime__end_time', |
|
| 217 | + ['5pm', 'ga'] |
|
| 218 | + ); |
|
| 219 | + $this->validateStartAndEndTimeForBlankDate($start_time, $end_time); |
|
| 220 | + $blank_datetime->set_start_time( |
|
| 221 | + $this->convert_datetime_for_query( |
|
| 222 | + 'DTT_EVT_start', |
|
| 223 | + $start_time[0], |
|
| 224 | + $start_time[1], |
|
| 225 | + $timezone_string |
|
| 226 | + ) |
|
| 227 | + ); |
|
| 228 | + $blank_datetime->set_end_time( |
|
| 229 | + $this->convert_datetime_for_query( |
|
| 230 | + 'DTT_EVT_end', |
|
| 231 | + $end_time[0], |
|
| 232 | + $end_time[1], |
|
| 233 | + $timezone_string |
|
| 234 | + ) |
|
| 235 | + ); |
|
| 236 | + return array($blank_datetime); |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + |
|
| 240 | + /** |
|
| 241 | + * Validates whether the start_time and end_time are in the expected format. |
|
| 242 | + * @param array $start_time |
|
| 243 | + * @param array $end_time |
|
| 244 | + * @throws InvalidArgumentException |
|
| 245 | + * @throws InvalidDataTypeException |
|
| 246 | + */ |
|
| 247 | + private function validateStartAndEndTimeForBlankDate($start_time, $end_time) |
|
| 248 | + { |
|
| 249 | + if (! is_array($start_time)) { |
|
| 250 | + throw new InvalidDataTypeException('start_time', $start_time, 'array'); |
|
| 251 | + } |
|
| 252 | + if (! is_array($end_time)) { |
|
| 253 | + throw new InvalidDataTypeException('end_time', $end_time, 'array'); |
|
| 254 | + } |
|
| 255 | + if (count($start_time) !== 2) { |
|
| 256 | + throw new InvalidArgumentException( |
|
| 257 | + sprintf( |
|
| 258 | + 'The variable %1$s is expected to be an array with two elements. The first item in the ' |
|
| 259 | + . 'array should be a valid time string, the second item in the array should be a valid time format', |
|
| 260 | + '$start_time' |
|
| 261 | + ) |
|
| 262 | + ); |
|
| 263 | + } |
|
| 264 | + if (count($end_time) !== 2) { |
|
| 265 | + throw new InvalidArgumentException( |
|
| 266 | + sprintf( |
|
| 267 | + 'The variable %1$s is expected to be an array with two elements. The first item in the ' |
|
| 268 | + . 'array should be a valid time string, the second item in the array should be a valid time format', |
|
| 269 | + '$end_time' |
|
| 270 | + ) |
|
| 271 | + ); |
|
| 272 | + } |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + |
|
| 276 | + /** |
|
| 277 | + * get event start date from db |
|
| 278 | + * |
|
| 279 | + * @access public |
|
| 280 | + * @param int $EVT_ID |
|
| 281 | + * @return EE_Datetime[] array on success, FALSE on fail |
|
| 282 | + * @throws EE_Error |
|
| 283 | + */ |
|
| 284 | + public function get_all_event_dates($EVT_ID = 0) |
|
| 285 | + { |
|
| 286 | + if (! $EVT_ID) { // on add_new_event event_id gets set to 0 |
|
| 287 | + return $this->create_new_blank_datetime(); |
|
| 288 | + } |
|
| 289 | + $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
|
| 290 | + if (empty($results)) { |
|
| 291 | + return $this->create_new_blank_datetime(); |
|
| 292 | + } |
|
| 293 | + return $results; |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + |
|
| 297 | + /** |
|
| 298 | + * get all datetimes attached to an event ordered by the DTT_order field |
|
| 299 | + * |
|
| 300 | + * @public |
|
| 301 | + * @param int $EVT_ID event id |
|
| 302 | + * @param boolean $include_expired |
|
| 303 | + * @param boolean $include_deleted |
|
| 304 | + * @param int $limit If included then limit the count of results by |
|
| 305 | + * the given number |
|
| 306 | + * @return EE_Datetime[] |
|
| 307 | + * @throws EE_Error |
|
| 308 | + */ |
|
| 309 | + public function get_datetimes_for_event_ordered_by_DTT_order( |
|
| 310 | + $EVT_ID, |
|
| 311 | + $include_expired = true, |
|
| 312 | + $include_deleted = true, |
|
| 313 | + $limit = null |
|
| 314 | + ) { |
|
| 315 | + // sanitize EVT_ID |
|
| 316 | + $EVT_ID = absint($EVT_ID); |
|
| 317 | + $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
|
| 318 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
| 319 | + $where_params = array('Event.EVT_ID' => $EVT_ID); |
|
| 320 | + $query_params = ! empty($limit) |
|
| 321 | + ? array( |
|
| 322 | + $where_params, |
|
| 323 | + 'limit' => $limit, |
|
| 324 | + 'order_by' => array('DTT_order' => 'ASC'), |
|
| 325 | + 'default_where_conditions' => 'none', |
|
| 326 | + ) |
|
| 327 | + : array( |
|
| 328 | + $where_params, |
|
| 329 | + 'order_by' => array('DTT_order' => 'ASC'), |
|
| 330 | + 'default_where_conditions' => 'none', |
|
| 331 | + ); |
|
| 332 | + if (! $include_expired) { |
|
| 333 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true)); |
|
| 334 | + } |
|
| 335 | + if ($include_deleted) { |
|
| 336 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
| 337 | + } |
|
| 338 | + /** @var EE_Datetime[] $result */ |
|
| 339 | + $result = $this->get_all($query_params); |
|
| 340 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
| 341 | + return $result; |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + |
|
| 345 | + /** |
|
| 346 | + * Gets the datetimes for the event (with the given limit), and orders them by "importance". |
|
| 347 | + * By importance, we mean that the primary datetimes are most important (DEPRECATED FOR NOW), |
|
| 348 | + * and then the earlier datetimes are the most important. |
|
| 349 | + * Maybe we'll want this to take into account datetimes that haven't already passed, but we don't yet. |
|
| 350 | + * |
|
| 351 | + * @param int $EVT_ID |
|
| 352 | + * @param int $limit |
|
| 353 | + * @return EE_Datetime[]|EE_Base_Class[] |
|
| 354 | + * @throws EE_Error |
|
| 355 | + */ |
|
| 356 | + public function get_datetimes_for_event_ordered_by_importance($EVT_ID = 0, $limit = null) |
|
| 357 | + { |
|
| 358 | + return $this->get_all( |
|
| 359 | + array( |
|
| 360 | + array('Event.EVT_ID' => $EVT_ID), |
|
| 361 | + 'limit' => $limit, |
|
| 362 | + 'order_by' => array('DTT_EVT_start' => 'ASC'), |
|
| 363 | + 'default_where_conditions' => 'none', |
|
| 364 | + ) |
|
| 365 | + ); |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + |
|
| 369 | + /** |
|
| 370 | + * @param int $EVT_ID |
|
| 371 | + * @param boolean $include_expired |
|
| 372 | + * @param boolean $include_deleted |
|
| 373 | + * @return EE_Datetime |
|
| 374 | + * @throws EE_Error |
|
| 375 | + */ |
|
| 376 | + public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false, $include_deleted = false) |
|
| 377 | + { |
|
| 378 | + $results = $this->get_datetimes_for_event_ordered_by_start_time( |
|
| 379 | + $EVT_ID, |
|
| 380 | + $include_expired, |
|
| 381 | + $include_deleted, |
|
| 382 | + 1 |
|
| 383 | + ); |
|
| 384 | + if ($results) { |
|
| 385 | + return array_shift($results); |
|
| 386 | + } |
|
| 387 | + return null; |
|
| 388 | + } |
|
| 389 | + |
|
| 390 | + |
|
| 391 | + /** |
|
| 392 | + * Gets the 'primary' datetime for an event. |
|
| 393 | + * |
|
| 394 | + * @param int $EVT_ID |
|
| 395 | + * @param bool $try_to_exclude_expired |
|
| 396 | + * @param bool $try_to_exclude_deleted |
|
| 397 | + * @return \EE_Datetime |
|
| 398 | + * @throws EE_Error |
|
| 399 | + */ |
|
| 400 | + public function get_primary_datetime_for_event( |
|
| 401 | + $EVT_ID, |
|
| 402 | + $try_to_exclude_expired = true, |
|
| 403 | + $try_to_exclude_deleted = true |
|
| 404 | + ) { |
|
| 405 | + if ($try_to_exclude_expired) { |
|
| 406 | + $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false); |
|
| 407 | + if ($non_expired) { |
|
| 408 | + return $non_expired; |
|
| 409 | + } |
|
| 410 | + } |
|
| 411 | + if ($try_to_exclude_deleted) { |
|
| 412 | + $expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true); |
|
| 413 | + if ($expired_even) { |
|
| 414 | + return $expired_even; |
|
| 415 | + } |
|
| 416 | + } |
|
| 417 | + return $this->get_oldest_datetime_for_event($EVT_ID, true, true); |
|
| 418 | + } |
|
| 419 | + |
|
| 420 | + |
|
| 421 | + /** |
|
| 422 | + * Gets ALL the datetimes for an event (including trashed ones, for now), ordered |
|
| 423 | + * only by start date |
|
| 424 | + * |
|
| 425 | + * @param int $EVT_ID |
|
| 426 | + * @param boolean $include_expired |
|
| 427 | + * @param boolean $include_deleted |
|
| 428 | + * @param int $limit |
|
| 429 | + * @return EE_Datetime[] |
|
| 430 | + * @throws EE_Error |
|
| 431 | + */ |
|
| 432 | + public function get_datetimes_for_event_ordered_by_start_time( |
|
| 433 | + $EVT_ID, |
|
| 434 | + $include_expired = true, |
|
| 435 | + $include_deleted = true, |
|
| 436 | + $limit = null |
|
| 437 | + ) { |
|
| 438 | + // sanitize EVT_ID |
|
| 439 | + $EVT_ID = absint($EVT_ID); |
|
| 440 | + $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
|
| 441 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
| 442 | + $query_params = array( |
|
| 443 | + array( |
|
| 444 | + 'Event.EVT_ID' => $EVT_ID |
|
| 445 | + ), |
|
| 446 | + 'order_by' => array( |
|
| 447 | + 'DTT_EVT_start' => 'asc' |
|
| 448 | + ), |
|
| 449 | + 'default_where_conditions' => EEM_Base::default_where_conditions_this_only |
|
| 450 | + ); |
|
| 451 | + if (! $include_expired) { |
|
| 452 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true)); |
|
| 453 | + } |
|
| 454 | + if ($include_deleted) { |
|
| 455 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
| 456 | + } |
|
| 457 | + if ($limit) { |
|
| 458 | + $query_params['limit'] = $limit; |
|
| 459 | + } |
|
| 460 | + /** @var EE_Datetime[] $result */ |
|
| 461 | + $result = $this->get_all($query_params); |
|
| 462 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
| 463 | + return $result; |
|
| 464 | + } |
|
| 465 | + |
|
| 466 | + |
|
| 467 | + /** |
|
| 468 | + * Gets ALL the datetimes for an ticket (including trashed ones, for now), ordered |
|
| 469 | + * only by start date |
|
| 470 | + * |
|
| 471 | + * @param int $TKT_ID |
|
| 472 | + * @param boolean $include_expired |
|
| 473 | + * @param boolean $include_deleted |
|
| 474 | + * @param int $limit |
|
| 475 | + * @return EE_Datetime[] |
|
| 476 | + * @throws EE_Error |
|
| 477 | + */ |
|
| 478 | + public function get_datetimes_for_ticket_ordered_by_start_time( |
|
| 479 | + $TKT_ID, |
|
| 480 | + $include_expired = true, |
|
| 481 | + $include_deleted = true, |
|
| 482 | + $limit = null |
|
| 483 | + ) { |
|
| 484 | + // sanitize TKT_ID |
|
| 485 | + $TKT_ID = absint($TKT_ID); |
|
| 486 | + $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
|
| 487 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
| 488 | + $query_params = array(array('Ticket.TKT_ID' => $TKT_ID), 'order_by' => array('DTT_EVT_start' => 'asc')); |
|
| 489 | + if (! $include_expired) { |
|
| 490 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true)); |
|
| 491 | + } |
|
| 492 | + if ($include_deleted) { |
|
| 493 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
| 494 | + } |
|
| 495 | + if ($limit) { |
|
| 496 | + $query_params['limit'] = $limit; |
|
| 497 | + } |
|
| 498 | + /** @var EE_Datetime[] $result */ |
|
| 499 | + $result = $this->get_all($query_params); |
|
| 500 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
| 501 | + return $result; |
|
| 502 | + } |
|
| 503 | + |
|
| 504 | + |
|
| 505 | + /** |
|
| 506 | + * Gets all the datetimes for a ticket (including trashed ones, for now), ordered by the DTT_order for the |
|
| 507 | + * datetimes. |
|
| 508 | + * |
|
| 509 | + * @param int $TKT_ID ID of ticket to retrieve the datetimes for |
|
| 510 | + * @param boolean $include_expired whether to include expired datetimes or not |
|
| 511 | + * @param boolean $include_deleted whether to include trashed datetimes or not. |
|
| 512 | + * @param int|null $limit if null, no limit, if int then limit results by |
|
| 513 | + * that number |
|
| 514 | + * @return EE_Datetime[] |
|
| 515 | + * @throws EE_Error |
|
| 516 | + */ |
|
| 517 | + public function get_datetimes_for_ticket_ordered_by_DTT_order( |
|
| 518 | + $TKT_ID, |
|
| 519 | + $include_expired = true, |
|
| 520 | + $include_deleted = true, |
|
| 521 | + $limit = null |
|
| 522 | + ) { |
|
| 523 | + // sanitize id. |
|
| 524 | + $TKT_ID = absint($TKT_ID); |
|
| 525 | + $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
|
| 526 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
| 527 | + $where_params = array('Ticket.TKT_ID' => $TKT_ID); |
|
| 528 | + $query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC')); |
|
| 529 | + if (! $include_expired) { |
|
| 530 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true)); |
|
| 531 | + } |
|
| 532 | + if ($include_deleted) { |
|
| 533 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
| 534 | + } |
|
| 535 | + if ($limit) { |
|
| 536 | + $query_params['limit'] = $limit; |
|
| 537 | + } |
|
| 538 | + /** @var EE_Datetime[] $result */ |
|
| 539 | + $result = $this->get_all($query_params); |
|
| 540 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
| 541 | + return $result; |
|
| 542 | + } |
|
| 543 | + |
|
| 544 | + |
|
| 545 | + /** |
|
| 546 | + * Gets the most important datetime for a particular event (ie, the primary event usually. But if for some WACK |
|
| 547 | + * reason it doesn't exist, we consider the earliest event the most important) |
|
| 548 | + * |
|
| 549 | + * @param int $EVT_ID |
|
| 550 | + * @return EE_Datetime |
|
| 551 | + * @throws EE_Error |
|
| 552 | + */ |
|
| 553 | + public function get_most_important_datetime_for_event($EVT_ID) |
|
| 554 | + { |
|
| 555 | + $results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1); |
|
| 556 | + if ($results) { |
|
| 557 | + return array_shift($results); |
|
| 558 | + } |
|
| 559 | + return null; |
|
| 560 | + } |
|
| 561 | + |
|
| 562 | + |
|
| 563 | + /** |
|
| 564 | + * This returns a wpdb->results Array of all DTT month and years matching the incoming query params and |
|
| 565 | + * grouped by month and year. |
|
| 566 | + * |
|
| 567 | + * @param array $where_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions |
|
| 568 | + * @param string $evt_active_status A string representing the evt active status to filter the months by. |
|
| 569 | + * Can be: |
|
| 570 | + * - '' = no filter |
|
| 571 | + * - upcoming = Published events with at least one upcoming datetime. |
|
| 572 | + * - expired = Events with all datetimes expired. |
|
| 573 | + * - active = Events that are published and have at least one datetime that |
|
| 574 | + * starts before now and ends after now. |
|
| 575 | + * - inactive = Events that are either not published. |
|
| 576 | + * @return EE_Base_Class[] |
|
| 577 | + * @throws EE_Error |
|
| 578 | + * @throws InvalidArgumentException |
|
| 579 | + * @throws InvalidArgumentException |
|
| 580 | + */ |
|
| 581 | + public function get_dtt_months_and_years($where_params, $evt_active_status = '') |
|
| 582 | + { |
|
| 583 | + $current_time_for_DTT_EVT_start = $this->current_time_for_query('DTT_EVT_start'); |
|
| 584 | + $current_time_for_DTT_EVT_end = $this->current_time_for_query('DTT_EVT_end'); |
|
| 585 | + switch ($evt_active_status) { |
|
| 586 | + case 'upcoming': |
|
| 587 | + $where_params['Event.status'] = 'publish'; |
|
| 588 | + // if there are already query_params matching DTT_EVT_start then we need to modify that to add them. |
|
| 589 | + if (isset($where_params['DTT_EVT_start'])) { |
|
| 590 | + $where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start']; |
|
| 591 | + } |
|
| 592 | + $where_params['DTT_EVT_start'] = array('>', $current_time_for_DTT_EVT_start); |
|
| 593 | + break; |
|
| 594 | + case 'expired': |
|
| 595 | + if (isset($where_params['Event.status'])) { |
|
| 596 | + unset($where_params['Event.status']); |
|
| 597 | + } |
|
| 598 | + // get events to exclude |
|
| 599 | + $exclude_query[0] = array_merge( |
|
| 600 | + $where_params, |
|
| 601 | + array('DTT_EVT_end' => array('>', $current_time_for_DTT_EVT_end)) |
|
| 602 | + ); |
|
| 603 | + // first get all events that have datetimes where its not expired. |
|
| 604 | + $event_ids = $this->_get_all_wpdb_results( |
|
| 605 | + $exclude_query, |
|
| 606 | + OBJECT_K, |
|
| 607 | + 'Datetime.EVT_ID' |
|
| 608 | + ); |
|
| 609 | + $event_ids = array_keys($event_ids); |
|
| 610 | + if (isset($where_params['DTT_EVT_end'])) { |
|
| 611 | + $where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
|
| 612 | + } |
|
| 613 | + $where_params['DTT_EVT_end'] = array('<', $current_time_for_DTT_EVT_end); |
|
| 614 | + $where_params['Event.EVT_ID'] = array('NOT IN', $event_ids); |
|
| 615 | + break; |
|
| 616 | + case 'active': |
|
| 617 | + $where_params['Event.status'] = 'publish'; |
|
| 618 | + if (isset($where_params['DTT_EVT_start'])) { |
|
| 619 | + $where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start']; |
|
| 620 | + } |
|
| 621 | + if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
| 622 | + $where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end']; |
|
| 623 | + } |
|
| 624 | + $where_params['DTT_EVT_start'] = array('<', $current_time_for_DTT_EVT_start); |
|
| 625 | + $where_params['DTT_EVT_end'] = array('>', $current_time_for_DTT_EVT_end); |
|
| 626 | + break; |
|
| 627 | + case 'inactive': |
|
| 628 | + if (isset($where_params['Event.status'])) { |
|
| 629 | + unset($where_params['Event.status']); |
|
| 630 | + } |
|
| 631 | + if (isset($where_params['OR'])) { |
|
| 632 | + $where_params['AND']['OR'] = $where_params['OR']; |
|
| 633 | + } |
|
| 634 | + if (isset($where_params['DTT_EVT_end'])) { |
|
| 635 | + $where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
|
| 636 | + unset($where_params['DTT_EVT_end']); |
|
| 637 | + } |
|
| 638 | + if (isset($where_params['DTT_EVT_start'])) { |
|
| 639 | + $where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start']; |
|
| 640 | + unset($where_params['DTT_EVT_start']); |
|
| 641 | + } |
|
| 642 | + $where_params['AND']['Event.status'] = array('!=', 'publish'); |
|
| 643 | + break; |
|
| 644 | + } |
|
| 645 | + $query_params[0] = $where_params; |
|
| 646 | + $query_params['group_by'] = array('dtt_year', 'dtt_month'); |
|
| 647 | + $query_params['order_by'] = array('DTT_EVT_start' => 'DESC'); |
|
| 648 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( |
|
| 649 | + $this->get_timezone(), |
|
| 650 | + 'DTT_EVT_start' |
|
| 651 | + ); |
|
| 652 | + $columns_to_select = array( |
|
| 653 | + 'dtt_year' => array('YEAR(' . $query_interval . ')', '%s'), |
|
| 654 | + 'dtt_month' => array('MONTHNAME(' . $query_interval . ')', '%s'), |
|
| 655 | + 'dtt_month_num' => array('MONTH(' . $query_interval . ')', '%s'), |
|
| 656 | + ); |
|
| 657 | + return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
| 658 | + } |
|
| 659 | + |
|
| 660 | + |
|
| 661 | + /** |
|
| 662 | + * Updates the DTT_sold attribute on each datetime (based on the registrations |
|
| 663 | + * for the tickets for each datetime) |
|
| 664 | + * |
|
| 665 | + * @param EE_Base_Class[]|EE_Datetime[] $datetimes |
|
| 666 | + * @throws EE_Error |
|
| 667 | + */ |
|
| 668 | + public function update_sold($datetimes) |
|
| 669 | + { |
|
| 670 | + EE_Error::doing_it_wrong( |
|
| 671 | + __FUNCTION__, |
|
| 672 | + esc_html__( |
|
| 673 | + 'Please use \EEM_Ticket::update_tickets_sold() instead which will in turn correctly update both the Ticket AND Datetime counts.', |
|
| 674 | + 'event_espresso' |
|
| 675 | + ), |
|
| 676 | + '4.9.32.rc.005' |
|
| 677 | + ); |
|
| 678 | + foreach ($datetimes as $datetime) { |
|
| 679 | + $datetime->update_sold(); |
|
| 680 | + } |
|
| 681 | + } |
|
| 682 | + |
|
| 683 | + |
|
| 684 | + /** |
|
| 685 | + * Gets the total number of tickets available at a particular datetime |
|
| 686 | + * (does NOT take into account the datetime's spaces available) |
|
| 687 | + * |
|
| 688 | + * @param int $DTT_ID |
|
| 689 | + * @param array $query_params |
|
| 690 | + * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF, IF there are NO |
|
| 691 | + * tickets attached to datetime then FALSE is returned. |
|
| 692 | + */ |
|
| 693 | + public function sum_tickets_currently_available_at_datetime($DTT_ID, array $query_params = array()) |
|
| 694 | + { |
|
| 695 | + $datetime = $this->get_one_by_ID($DTT_ID); |
|
| 696 | + if ($datetime instanceof EE_Datetime) { |
|
| 697 | + return $datetime->tickets_remaining($query_params); |
|
| 698 | + } |
|
| 699 | + return 0; |
|
| 700 | + } |
|
| 701 | + |
|
| 702 | + |
|
| 703 | + /** |
|
| 704 | + * This returns an array of counts of datetimes in the database for each Datetime status that can be queried. |
|
| 705 | + * |
|
| 706 | + * @param array $stati_to_include If included you can restrict the statuses we return counts for by including the |
|
| 707 | + * stati you want counts for as values in the array. An empty array returns counts |
|
| 708 | + * for all valid stati. |
|
| 709 | + * @param array $query_params If included can be used to refine the conditions for returning the count (i.e. |
|
| 710 | + * only for Datetimes connected to a specific event, or specific ticket. |
|
| 711 | + * @return array The value returned is an array indexed by Datetime Status and the values are the counts. The |
|
| 712 | + * @throws EE_Error |
|
| 713 | + * stati used as index keys are: EE_Datetime::active EE_Datetime::upcoming |
|
| 714 | + * EE_Datetime::expired |
|
| 715 | + */ |
|
| 716 | + public function get_datetime_counts_by_status(array $stati_to_include = array(), array $query_params = array()) |
|
| 717 | + { |
|
| 718 | + // only accept where conditions for this query. |
|
| 719 | + $_where = isset($query_params[0]) ? $query_params[0] : array(); |
|
| 720 | + $status_query_args = array( |
|
| 721 | + EE_Datetime::active => array_merge( |
|
| 722 | + $_where, |
|
| 723 | + array('DTT_EVT_start' => array('<', time()), 'DTT_EVT_end' => array('>', time())) |
|
| 724 | + ), |
|
| 725 | + EE_Datetime::upcoming => array_merge( |
|
| 726 | + $_where, |
|
| 727 | + array('DTT_EVT_start' => array('>', time())) |
|
| 728 | + ), |
|
| 729 | + EE_Datetime::expired => array_merge( |
|
| 730 | + $_where, |
|
| 731 | + array('DTT_EVT_end' => array('<', time())) |
|
| 732 | + ), |
|
| 733 | + ); |
|
| 734 | + if (! empty($stati_to_include)) { |
|
| 735 | + foreach (array_keys($status_query_args) as $status) { |
|
| 736 | + if (! in_array($status, $stati_to_include, true)) { |
|
| 737 | + unset($status_query_args[ $status ]); |
|
| 738 | + } |
|
| 739 | + } |
|
| 740 | + } |
|
| 741 | + // loop through and query counts for each stati. |
|
| 742 | + $status_query_results = array(); |
|
| 743 | + foreach ($status_query_args as $status => $status_where_conditions) { |
|
| 744 | + $status_query_results[ $status ] = EEM_Datetime::count( |
|
| 745 | + array($status_where_conditions), |
|
| 746 | + 'DTT_ID', |
|
| 747 | + true |
|
| 748 | + ); |
|
| 749 | + } |
|
| 750 | + return $status_query_results; |
|
| 751 | + } |
|
| 752 | + |
|
| 753 | + |
|
| 754 | + /** |
|
| 755 | + * Returns the specific count for a given Datetime status matching any given query_params. |
|
| 756 | + * |
|
| 757 | + * @param string $status Valid string representation for Datetime status requested. (Defaults to Active). |
|
| 758 | + * @param array $query_params |
|
| 759 | + * @return int |
|
| 760 | + * @throws EE_Error |
|
| 761 | + */ |
|
| 762 | + public function get_datetime_count_for_status($status = EE_Datetime::active, array $query_params = array()) |
|
| 763 | + { |
|
| 764 | + $count = $this->get_datetime_counts_by_status(array($status), $query_params); |
|
| 765 | + return ! empty($count[ $status ]) ? $count[ $status ] : 0; |
|
| 766 | + } |
|
| 767 | 767 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | ), |
| 122 | 122 | ), |
| 123 | 123 | ); |
| 124 | - $this->_model_relations = array( |
|
| 124 | + $this->_model_relations = array( |
|
| 125 | 125 | 'Ticket' => new EE_HABTM_Relation('Datetime_Ticket'), |
| 126 | 126 | 'Event' => new EE_Belongs_To_Relation(), |
| 127 | 127 | 'Checkin' => new EE_Has_Many_Relation(), |
@@ -131,16 +131,16 @@ discard block |
||
| 131 | 131 | $this->model_chain_to_password = $path_to_event_model; |
| 132 | 132 | $this->_model_chain_to_wp_user = $path_to_event_model; |
| 133 | 133 | // this model is generally available for reading |
| 134 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( |
|
| 134 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public( |
|
| 135 | 135 | $path_to_event_model |
| 136 | 136 | ); |
| 137 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
| 137 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected( |
|
| 138 | 138 | $path_to_event_model |
| 139 | 139 | ); |
| 140 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
| 140 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected( |
|
| 141 | 141 | $path_to_event_model |
| 142 | 142 | ); |
| 143 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
| 143 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected( |
|
| 144 | 144 | $path_to_event_model, |
| 145 | 145 | EEM_Base::caps_edit |
| 146 | 146 | ); |
@@ -246,10 +246,10 @@ discard block |
||
| 246 | 246 | */ |
| 247 | 247 | private function validateStartAndEndTimeForBlankDate($start_time, $end_time) |
| 248 | 248 | { |
| 249 | - if (! is_array($start_time)) { |
|
| 249 | + if ( ! is_array($start_time)) { |
|
| 250 | 250 | throw new InvalidDataTypeException('start_time', $start_time, 'array'); |
| 251 | 251 | } |
| 252 | - if (! is_array($end_time)) { |
|
| 252 | + if ( ! is_array($end_time)) { |
|
| 253 | 253 | throw new InvalidDataTypeException('end_time', $end_time, 'array'); |
| 254 | 254 | } |
| 255 | 255 | if (count($start_time) !== 2) { |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | */ |
| 284 | 284 | public function get_all_event_dates($EVT_ID = 0) |
| 285 | 285 | { |
| 286 | - if (! $EVT_ID) { // on add_new_event event_id gets set to 0 |
|
| 286 | + if ( ! $EVT_ID) { // on add_new_event event_id gets set to 0 |
|
| 287 | 287 | return $this->create_new_blank_datetime(); |
| 288 | 288 | } |
| 289 | 289 | $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | 'order_by' => array('DTT_order' => 'ASC'), |
| 330 | 330 | 'default_where_conditions' => 'none', |
| 331 | 331 | ); |
| 332 | - if (! $include_expired) { |
|
| 332 | + if ( ! $include_expired) { |
|
| 333 | 333 | $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true)); |
| 334 | 334 | } |
| 335 | 335 | if ($include_deleted) { |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | ), |
| 449 | 449 | 'default_where_conditions' => EEM_Base::default_where_conditions_this_only |
| 450 | 450 | ); |
| 451 | - if (! $include_expired) { |
|
| 451 | + if ( ! $include_expired) { |
|
| 452 | 452 | $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true)); |
| 453 | 453 | } |
| 454 | 454 | if ($include_deleted) { |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
| 487 | 487 | $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
| 488 | 488 | $query_params = array(array('Ticket.TKT_ID' => $TKT_ID), 'order_by' => array('DTT_EVT_start' => 'asc')); |
| 489 | - if (! $include_expired) { |
|
| 489 | + if ( ! $include_expired) { |
|
| 490 | 490 | $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true)); |
| 491 | 491 | } |
| 492 | 492 | if ($include_deleted) { |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
| 527 | 527 | $where_params = array('Ticket.TKT_ID' => $TKT_ID); |
| 528 | 528 | $query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC')); |
| 529 | - if (! $include_expired) { |
|
| 529 | + if ( ! $include_expired) { |
|
| 530 | 530 | $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true)); |
| 531 | 531 | } |
| 532 | 532 | if ($include_deleted) { |
@@ -649,10 +649,10 @@ discard block |
||
| 649 | 649 | $this->get_timezone(), |
| 650 | 650 | 'DTT_EVT_start' |
| 651 | 651 | ); |
| 652 | - $columns_to_select = array( |
|
| 653 | - 'dtt_year' => array('YEAR(' . $query_interval . ')', '%s'), |
|
| 654 | - 'dtt_month' => array('MONTHNAME(' . $query_interval . ')', '%s'), |
|
| 655 | - 'dtt_month_num' => array('MONTH(' . $query_interval . ')', '%s'), |
|
| 652 | + $columns_to_select = array( |
|
| 653 | + 'dtt_year' => array('YEAR('.$query_interval.')', '%s'), |
|
| 654 | + 'dtt_month' => array('MONTHNAME('.$query_interval.')', '%s'), |
|
| 655 | + 'dtt_month_num' => array('MONTH('.$query_interval.')', '%s'), |
|
| 656 | 656 | ); |
| 657 | 657 | return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
| 658 | 658 | } |
@@ -731,17 +731,17 @@ discard block |
||
| 731 | 731 | array('DTT_EVT_end' => array('<', time())) |
| 732 | 732 | ), |
| 733 | 733 | ); |
| 734 | - if (! empty($stati_to_include)) { |
|
| 734 | + if ( ! empty($stati_to_include)) { |
|
| 735 | 735 | foreach (array_keys($status_query_args) as $status) { |
| 736 | - if (! in_array($status, $stati_to_include, true)) { |
|
| 737 | - unset($status_query_args[ $status ]); |
|
| 736 | + if ( ! in_array($status, $stati_to_include, true)) { |
|
| 737 | + unset($status_query_args[$status]); |
|
| 738 | 738 | } |
| 739 | 739 | } |
| 740 | 740 | } |
| 741 | 741 | // loop through and query counts for each stati. |
| 742 | 742 | $status_query_results = array(); |
| 743 | 743 | foreach ($status_query_args as $status => $status_where_conditions) { |
| 744 | - $status_query_results[ $status ] = EEM_Datetime::count( |
|
| 744 | + $status_query_results[$status] = EEM_Datetime::count( |
|
| 745 | 745 | array($status_where_conditions), |
| 746 | 746 | 'DTT_ID', |
| 747 | 747 | true |
@@ -762,6 +762,6 @@ discard block |
||
| 762 | 762 | public function get_datetime_count_for_status($status = EE_Datetime::active, array $query_params = array()) |
| 763 | 763 | { |
| 764 | 764 | $count = $this->get_datetime_counts_by_status(array($status), $query_params); |
| 765 | - return ! empty($count[ $status ]) ? $count[ $status ] : 0; |
|
| 765 | + return ! empty($count[$status]) ? $count[$status] : 0; |
|
| 766 | 766 | } |
| 767 | 767 | } |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | * If 1, true, or "primary" is passed in, returns EQG_primary. If 0, false, or "additional" is passed in, returns |
| 56 | 56 | * EQG_additional. |
| 57 | 57 | * @since 4.10.0.p |
| 58 | - * @param string|boolean|int $context |
|
| 58 | + * @param boolean $context |
|
| 59 | 59 | * @return string |
| 60 | 60 | */ |
| 61 | 61 | public function fieldNameForContext($context) |
@@ -7,72 +7,72 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class EEM_Event_Question_Group extends EEM_Base |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * Name of the field indicating an event should use the question group for the primary attendee |
|
| 12 | - */ |
|
| 13 | - const PRIMARY = 'EQG_primary'; |
|
| 10 | + /** |
|
| 11 | + * Name of the field indicating an event should use the question group for the primary attendee |
|
| 12 | + */ |
|
| 13 | + const PRIMARY = 'EQG_primary'; |
|
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Name of hte field indicating an event should use the question group for additional attendees |
|
| 17 | - */ |
|
| 18 | - const ADDITIONAL = 'EQG_additional'; |
|
| 15 | + /** |
|
| 16 | + * Name of hte field indicating an event should use the question group for additional attendees |
|
| 17 | + */ |
|
| 18 | + const ADDITIONAL = 'EQG_additional'; |
|
| 19 | 19 | |
| 20 | - // private instance of the Event_Question_Group object |
|
| 21 | - protected static $_instance = null; |
|
| 20 | + // private instance of the Event_Question_Group object |
|
| 21 | + protected static $_instance = null; |
|
| 22 | 22 | |
| 23 | - protected function __construct($timezone = null) |
|
| 24 | - { |
|
| 25 | - $this->singular_item = __('Event to Question Group Link', 'event_espresso'); |
|
| 26 | - $this->plural_item = __('Event to Question Group Links', 'event_espresso'); |
|
| 27 | - $this->_tables = array( |
|
| 28 | - 'Event_Question_Group'=>new EE_Primary_Table('esp_event_question_group', 'EQG_ID') |
|
| 29 | - ); |
|
| 30 | - $this->_fields = array( |
|
| 31 | - 'Event_Question_Group'=>array( |
|
| 32 | - 'EQG_ID'=>new EE_Primary_Key_Int_Field('EQG_ID', __('Event to Question Group Link ID', 'event_espresso')), |
|
| 33 | - 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
| 34 | - 'QSG_ID'=>new EE_Foreign_Key_Int_Field('QSG_ID', __('Question Group Id', 'event_espresso'), false, 0, 'Question_Group'), |
|
| 35 | - 'EQG_primary'=>new EE_Boolean_Field('EQG_primary', __('Flag indicating question is only for primary attendees', 'event_espresso'), false, false), |
|
| 36 | - 'EQG_additional'=>new EE_Boolean_Field('EQG_additional', __('Flag indicating question is only for additional attendees', 'event_espresso'), false, false) |
|
| 37 | - ) |
|
| 38 | - ); |
|
| 39 | - $this->_model_relations = array( |
|
| 40 | - 'Event'=>new EE_Belongs_To_Relation(), |
|
| 41 | - 'Question_Group'=>new EE_Belongs_To_Relation() |
|
| 42 | - ); |
|
| 43 | - // this model is generally available for reading |
|
| 44 | - $path_to_event = 'Event'; |
|
| 45 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public($path_to_event); |
|
| 46 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
| 47 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
| 48 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event, EEM_Base::caps_edit); |
|
| 49 | - parent::__construct($timezone); |
|
| 50 | - } |
|
| 23 | + protected function __construct($timezone = null) |
|
| 24 | + { |
|
| 25 | + $this->singular_item = __('Event to Question Group Link', 'event_espresso'); |
|
| 26 | + $this->plural_item = __('Event to Question Group Links', 'event_espresso'); |
|
| 27 | + $this->_tables = array( |
|
| 28 | + 'Event_Question_Group'=>new EE_Primary_Table('esp_event_question_group', 'EQG_ID') |
|
| 29 | + ); |
|
| 30 | + $this->_fields = array( |
|
| 31 | + 'Event_Question_Group'=>array( |
|
| 32 | + 'EQG_ID'=>new EE_Primary_Key_Int_Field('EQG_ID', __('Event to Question Group Link ID', 'event_espresso')), |
|
| 33 | + 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
| 34 | + 'QSG_ID'=>new EE_Foreign_Key_Int_Field('QSG_ID', __('Question Group Id', 'event_espresso'), false, 0, 'Question_Group'), |
|
| 35 | + 'EQG_primary'=>new EE_Boolean_Field('EQG_primary', __('Flag indicating question is only for primary attendees', 'event_espresso'), false, false), |
|
| 36 | + 'EQG_additional'=>new EE_Boolean_Field('EQG_additional', __('Flag indicating question is only for additional attendees', 'event_espresso'), false, false) |
|
| 37 | + ) |
|
| 38 | + ); |
|
| 39 | + $this->_model_relations = array( |
|
| 40 | + 'Event'=>new EE_Belongs_To_Relation(), |
|
| 41 | + 'Question_Group'=>new EE_Belongs_To_Relation() |
|
| 42 | + ); |
|
| 43 | + // this model is generally available for reading |
|
| 44 | + $path_to_event = 'Event'; |
|
| 45 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public($path_to_event); |
|
| 46 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
| 47 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event); |
|
| 48 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event, EEM_Base::caps_edit); |
|
| 49 | + parent::__construct($timezone); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Decides whether to use the 'EQG_primary' or newer 'EQG_additional' for use in queries, based on whether |
|
| 54 | - * this is concerning primary attendees or additional attendees. |
|
| 55 | - * If 1, true, or "primary" is passed in, returns EQG_primary. If 0, false, or "additional" is passed in, returns |
|
| 56 | - * EQG_additional. |
|
| 57 | - * @since 4.10.0.p |
|
| 58 | - * @param string|boolean|int $context |
|
| 59 | - * @return string |
|
| 60 | - */ |
|
| 61 | - public function fieldNameForContext($context) |
|
| 62 | - { |
|
| 63 | - // Basically do a strict switch statement. |
|
| 64 | - switch (true) { |
|
| 65 | - case $context === 'additional': |
|
| 66 | - case $context === false: |
|
| 67 | - case $context === 0: |
|
| 68 | - $field_name = EEM_Event_Question_Group::ADDITIONAL; |
|
| 69 | - break; |
|
| 70 | - case $context === 'primary': |
|
| 71 | - case $context === true: |
|
| 72 | - case $context === 1: |
|
| 73 | - default: |
|
| 74 | - $field_name = EEM_Event_Question_Group::PRIMARY; |
|
| 75 | - } |
|
| 76 | - return apply_filters('FHEE__EEM_Event_Question_Group__fieldNameForContext', $field_name, $context); |
|
| 77 | - } |
|
| 52 | + /** |
|
| 53 | + * Decides whether to use the 'EQG_primary' or newer 'EQG_additional' for use in queries, based on whether |
|
| 54 | + * this is concerning primary attendees or additional attendees. |
|
| 55 | + * If 1, true, or "primary" is passed in, returns EQG_primary. If 0, false, or "additional" is passed in, returns |
|
| 56 | + * EQG_additional. |
|
| 57 | + * @since 4.10.0.p |
|
| 58 | + * @param string|boolean|int $context |
|
| 59 | + * @return string |
|
| 60 | + */ |
|
| 61 | + public function fieldNameForContext($context) |
|
| 62 | + { |
|
| 63 | + // Basically do a strict switch statement. |
|
| 64 | + switch (true) { |
|
| 65 | + case $context === 'additional': |
|
| 66 | + case $context === false: |
|
| 67 | + case $context === 0: |
|
| 68 | + $field_name = EEM_Event_Question_Group::ADDITIONAL; |
|
| 69 | + break; |
|
| 70 | + case $context === 'primary': |
|
| 71 | + case $context === true: |
|
| 72 | + case $context === 1: |
|
| 73 | + default: |
|
| 74 | + $field_name = EEM_Event_Question_Group::PRIMARY; |
|
| 75 | + } |
|
| 76 | + return apply_filters('FHEE__EEM_Event_Question_Group__fieldNameForContext', $field_name, $context); |
|
| 77 | + } |
|
| 78 | 78 | } |
@@ -12,94 +12,94 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class EE_State_Select_Input extends EE_Select_Input |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * @var string the name of the EE_State field to use for option values in the HTML form input. |
|
| 17 | - */ |
|
| 18 | - protected $valueFieldName; |
|
| 15 | + /** |
|
| 16 | + * @var string the name of the EE_State field to use for option values in the HTML form input. |
|
| 17 | + */ |
|
| 18 | + protected $valueFieldName; |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @param EE_State[]|array|null $state_options. If a flat array of string is provided, |
|
| 22 | - * $input_settings['value_field_name'] is ignored. If an array of states is passed, that field will be used for |
|
| 23 | - * the keys (which will become the option values). If null or empty is passed, all active states will be used, |
|
| 24 | - * and $input_settings['value_field_name'] will again be used. * |
|
| 25 | - * @param array $input_settings same as parent, but also { |
|
| 26 | - * @type string $value_field_name the name of the field to use |
|
| 27 | - * for the HTML option values, ie, `STA_ID`, `STA_abbrev`, or `STA_name`. |
|
| 28 | - * } |
|
| 29 | - * @throws EE_Error |
|
| 30 | - * @throws InvalidArgumentException |
|
| 31 | - * @throws InvalidDataTypeException |
|
| 32 | - * @throws InvalidInterfaceException |
|
| 33 | - * @throws ReflectionException |
|
| 34 | - */ |
|
| 35 | - public function __construct($state_options, $input_settings = array()) |
|
| 36 | - { |
|
| 37 | - if (isset($input_settings['value_field_name'])) { |
|
| 38 | - $this->valueFieldName = $input_settings['value_field_name']; |
|
| 39 | - if (! EEM_State::instance()->has_field((string) $this->valueFieldName())) { |
|
| 40 | - throw new InvalidArgumentException( |
|
| 41 | - sprintf( |
|
| 42 | - esc_html__('An invalid state field "%1$s" was specified for the state input\'s option values.', 'event_espresso'), |
|
| 43 | - $this->valueFieldName() |
|
| 44 | - ) |
|
| 45 | - ); |
|
| 46 | - } |
|
| 47 | - } else { |
|
| 48 | - $this->valueFieldName = 'STA_ID'; |
|
| 49 | - } |
|
| 50 | - $state_options = apply_filters( |
|
| 51 | - 'FHEE__EE_State_Select_Input____construct__state_options', |
|
| 52 | - $this->get_state_answer_options($state_options), |
|
| 53 | - $this |
|
| 54 | - ); |
|
| 55 | - $input_settings['html_class'] = isset($input_settings['html_class']) |
|
| 56 | - ? $input_settings['html_class'] . ' ee-state-select-js' |
|
| 57 | - : 'ee-state-select-js'; |
|
| 58 | - parent::__construct($state_options, $input_settings); |
|
| 59 | - } |
|
| 20 | + /** |
|
| 21 | + * @param EE_State[]|array|null $state_options. If a flat array of string is provided, |
|
| 22 | + * $input_settings['value_field_name'] is ignored. If an array of states is passed, that field will be used for |
|
| 23 | + * the keys (which will become the option values). If null or empty is passed, all active states will be used, |
|
| 24 | + * and $input_settings['value_field_name'] will again be used. * |
|
| 25 | + * @param array $input_settings same as parent, but also { |
|
| 26 | + * @type string $value_field_name the name of the field to use |
|
| 27 | + * for the HTML option values, ie, `STA_ID`, `STA_abbrev`, or `STA_name`. |
|
| 28 | + * } |
|
| 29 | + * @throws EE_Error |
|
| 30 | + * @throws InvalidArgumentException |
|
| 31 | + * @throws InvalidDataTypeException |
|
| 32 | + * @throws InvalidInterfaceException |
|
| 33 | + * @throws ReflectionException |
|
| 34 | + */ |
|
| 35 | + public function __construct($state_options, $input_settings = array()) |
|
| 36 | + { |
|
| 37 | + if (isset($input_settings['value_field_name'])) { |
|
| 38 | + $this->valueFieldName = $input_settings['value_field_name']; |
|
| 39 | + if (! EEM_State::instance()->has_field((string) $this->valueFieldName())) { |
|
| 40 | + throw new InvalidArgumentException( |
|
| 41 | + sprintf( |
|
| 42 | + esc_html__('An invalid state field "%1$s" was specified for the state input\'s option values.', 'event_espresso'), |
|
| 43 | + $this->valueFieldName() |
|
| 44 | + ) |
|
| 45 | + ); |
|
| 46 | + } |
|
| 47 | + } else { |
|
| 48 | + $this->valueFieldName = 'STA_ID'; |
|
| 49 | + } |
|
| 50 | + $state_options = apply_filters( |
|
| 51 | + 'FHEE__EE_State_Select_Input____construct__state_options', |
|
| 52 | + $this->get_state_answer_options($state_options), |
|
| 53 | + $this |
|
| 54 | + ); |
|
| 55 | + $input_settings['html_class'] = isset($input_settings['html_class']) |
|
| 56 | + ? $input_settings['html_class'] . ' ee-state-select-js' |
|
| 57 | + : 'ee-state-select-js'; |
|
| 58 | + parent::__construct($state_options, $input_settings); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Returns the name of the state field used for the HTML option values. |
|
| 63 | - * @since 4.10.0.p |
|
| 64 | - * @return string |
|
| 65 | - */ |
|
| 66 | - public function valueFieldName() |
|
| 67 | - { |
|
| 68 | - return $this->valueFieldName; |
|
| 69 | - } |
|
| 61 | + /** |
|
| 62 | + * Returns the name of the state field used for the HTML option values. |
|
| 63 | + * @since 4.10.0.p |
|
| 64 | + * @return string |
|
| 65 | + */ |
|
| 66 | + public function valueFieldName() |
|
| 67 | + { |
|
| 68 | + return $this->valueFieldName; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * get_state_answer_options |
|
| 74 | - * |
|
| 75 | - * @param array $state_options |
|
| 76 | - * @return array |
|
| 77 | - * @throws EE_Error |
|
| 78 | - * @throws InvalidArgumentException |
|
| 79 | - * @throws ReflectionException |
|
| 80 | - * @throws InvalidDataTypeException |
|
| 81 | - * @throws InvalidInterfaceException |
|
| 82 | - */ |
|
| 83 | - public function get_state_answer_options($state_options = null) |
|
| 84 | - { |
|
| 85 | - // if passed something that is NOT an array |
|
| 86 | - if (! is_array($state_options) || empty($state_options)) { |
|
| 87 | - // get possibly cached list of states |
|
| 88 | - $states = EEM_State::instance()->get_all_active_states(); |
|
| 89 | - } |
|
| 90 | - if (is_array($state_options) && reset($state_options) instanceof EE_State) { |
|
| 91 | - $states = $state_options; |
|
| 92 | - $state_options = array(); |
|
| 93 | - } |
|
| 94 | - if (! empty($states)) { |
|
| 95 | - // set the default |
|
| 96 | - $state_options[''][''] = ''; |
|
| 97 | - foreach ($states as $state) { |
|
| 98 | - if ($state instanceof EE_State) { |
|
| 99 | - $state_options[ $state->country()->name() ][ $state->get($this->valueFieldName()) ] = $state->name(); |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - return $state_options; |
|
| 104 | - } |
|
| 72 | + /** |
|
| 73 | + * get_state_answer_options |
|
| 74 | + * |
|
| 75 | + * @param array $state_options |
|
| 76 | + * @return array |
|
| 77 | + * @throws EE_Error |
|
| 78 | + * @throws InvalidArgumentException |
|
| 79 | + * @throws ReflectionException |
|
| 80 | + * @throws InvalidDataTypeException |
|
| 81 | + * @throws InvalidInterfaceException |
|
| 82 | + */ |
|
| 83 | + public function get_state_answer_options($state_options = null) |
|
| 84 | + { |
|
| 85 | + // if passed something that is NOT an array |
|
| 86 | + if (! is_array($state_options) || empty($state_options)) { |
|
| 87 | + // get possibly cached list of states |
|
| 88 | + $states = EEM_State::instance()->get_all_active_states(); |
|
| 89 | + } |
|
| 90 | + if (is_array($state_options) && reset($state_options) instanceof EE_State) { |
|
| 91 | + $states = $state_options; |
|
| 92 | + $state_options = array(); |
|
| 93 | + } |
|
| 94 | + if (! empty($states)) { |
|
| 95 | + // set the default |
|
| 96 | + $state_options[''][''] = ''; |
|
| 97 | + foreach ($states as $state) { |
|
| 98 | + if ($state instanceof EE_State) { |
|
| 99 | + $state_options[ $state->country()->name() ][ $state->get($this->valueFieldName()) ] = $state->name(); |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + return $state_options; |
|
| 104 | + } |
|
| 105 | 105 | } |
@@ -14,172 +14,172 @@ |
||
| 14 | 14 | class EE_Billing_Attendee_Info_Form extends EE_Billing_Info_Form |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * |
|
| 19 | - * @param EE_Payment_Method $payment_method |
|
| 20 | - * @param array $options_array @see EE_Form_Section_Proper::__construct() |
|
| 21 | - */ |
|
| 22 | - public function __construct(EE_Payment_Method $payment_method, $options_array = array()) |
|
| 23 | - { |
|
| 24 | - $options_array['subsections'] = array_merge( |
|
| 25 | - array( |
|
| 26 | - 'first_name' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-fname', 'html_label_text' => __('First Name', 'event_espresso') )), |
|
| 27 | - 'last_name' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-lname', 'html_label_text' => __('Last Name', 'event_espresso') )), |
|
| 28 | - 'email' => new EE_Email_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-email', 'html_label_text' => __('Email', 'event_espresso') )), |
|
| 29 | - 'address' => new EE_Text_Input(array( 'html_label_text'=> __('Address', 'event_espresso'), 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-address' )), |
|
| 30 | - 'address2' => new EE_Text_Input(array( 'html_label_text'=> __('Address 2', 'event_espresso'), 'html_class' => 'ee-billing-qstn ee-billing-qstn-address2' )), |
|
| 31 | - 'city' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-city', 'html_label_text' => __('City', 'event_espresso') )), |
|
| 32 | - 'state' => apply_filters('FHEE__EE_Billing_Attendee_Info_Form__state_field', new EE_State_Select_Input(null, array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-state', 'html_label_text' => __('State', 'event_espresso') ))), |
|
| 33 | - 'country' => apply_filters('FHEE__EE_Billing_Attendee_Info_Form__country_field', new EE_Country_Select_Input(null, array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-country', 'html_label_text' => __('Country', 'event_espresso') ))), |
|
| 34 | - 'zip' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-zip', 'html_label_text' => __('Zip', 'event_espresso') )), |
|
| 35 | - 'phone' => new EE_Text_Input(array( 'html_class' => 'ee-billing-qstn ee-billing-qstn-phone', 'html_label_text' => __('Phone', 'event_espresso') )), |
|
| 36 | - ), |
|
| 37 | - isset($options_array['subsections']) ? $options_array['subsections'] : array() |
|
| 38 | - ); |
|
| 17 | + /** |
|
| 18 | + * |
|
| 19 | + * @param EE_Payment_Method $payment_method |
|
| 20 | + * @param array $options_array @see EE_Form_Section_Proper::__construct() |
|
| 21 | + */ |
|
| 22 | + public function __construct(EE_Payment_Method $payment_method, $options_array = array()) |
|
| 23 | + { |
|
| 24 | + $options_array['subsections'] = array_merge( |
|
| 25 | + array( |
|
| 26 | + 'first_name' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-fname', 'html_label_text' => __('First Name', 'event_espresso') )), |
|
| 27 | + 'last_name' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-lname', 'html_label_text' => __('Last Name', 'event_espresso') )), |
|
| 28 | + 'email' => new EE_Email_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-email', 'html_label_text' => __('Email', 'event_espresso') )), |
|
| 29 | + 'address' => new EE_Text_Input(array( 'html_label_text'=> __('Address', 'event_espresso'), 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-address' )), |
|
| 30 | + 'address2' => new EE_Text_Input(array( 'html_label_text'=> __('Address 2', 'event_espresso'), 'html_class' => 'ee-billing-qstn ee-billing-qstn-address2' )), |
|
| 31 | + 'city' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-city', 'html_label_text' => __('City', 'event_espresso') )), |
|
| 32 | + 'state' => apply_filters('FHEE__EE_Billing_Attendee_Info_Form__state_field', new EE_State_Select_Input(null, array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-state', 'html_label_text' => __('State', 'event_espresso') ))), |
|
| 33 | + 'country' => apply_filters('FHEE__EE_Billing_Attendee_Info_Form__country_field', new EE_Country_Select_Input(null, array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-country', 'html_label_text' => __('Country', 'event_espresso') ))), |
|
| 34 | + 'zip' => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-zip', 'html_label_text' => __('Zip', 'event_espresso') )), |
|
| 35 | + 'phone' => new EE_Text_Input(array( 'html_class' => 'ee-billing-qstn ee-billing-qstn-phone', 'html_label_text' => __('Phone', 'event_espresso') )), |
|
| 36 | + ), |
|
| 37 | + isset($options_array['subsections']) ? $options_array['subsections'] : array() |
|
| 38 | + ); |
|
| 39 | 39 | |
| 40 | - parent::__construct($payment_method, $options_array); |
|
| 41 | - } |
|
| 40 | + parent::__construct($payment_method, $options_array); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Sets the defaults for the billing form according to the attendee's details |
|
| 45 | - * @param EE_Attendee $attendee |
|
| 46 | - */ |
|
| 47 | - public function populate_from_attendee($attendee) |
|
| 48 | - { |
|
| 49 | - $attendee = EEM_Attendee::instance()->ensure_is_obj($attendee); |
|
| 43 | + /** |
|
| 44 | + * Sets the defaults for the billing form according to the attendee's details |
|
| 45 | + * @param EE_Attendee $attendee |
|
| 46 | + */ |
|
| 47 | + public function populate_from_attendee($attendee) |
|
| 48 | + { |
|
| 49 | + $attendee = EEM_Attendee::instance()->ensure_is_obj($attendee); |
|
| 50 | 50 | |
| 51 | - /** @var $attendee EE_Attendee */ |
|
| 52 | - $this->populate_defaults( |
|
| 53 | - apply_filters( |
|
| 54 | - 'FHEE__EE_Billing_Attendee_Info_Form__populate_from_attendee', |
|
| 55 | - array( |
|
| 56 | - 'first_name'=>$attendee->fname(), |
|
| 57 | - 'last_name'=>$attendee->lname(), |
|
| 58 | - 'email'=>$attendee->email(), |
|
| 59 | - 'address'=>$attendee->address(), |
|
| 60 | - 'address2'=>$attendee->address2(), |
|
| 61 | - 'city'=>$attendee->city(), |
|
| 62 | - 'state'=> $this->getAttendeeStateValueForForm($attendee), |
|
| 63 | - 'country'=> $attendee->country_ID(), |
|
| 64 | - 'zip'=>$attendee->zip(), |
|
| 65 | - 'phone'=>$attendee->phone(), |
|
| 66 | - ), |
|
| 67 | - $attendee, |
|
| 68 | - $this |
|
| 69 | - ) |
|
| 70 | - ); |
|
| 71 | - } |
|
| 51 | + /** @var $attendee EE_Attendee */ |
|
| 52 | + $this->populate_defaults( |
|
| 53 | + apply_filters( |
|
| 54 | + 'FHEE__EE_Billing_Attendee_Info_Form__populate_from_attendee', |
|
| 55 | + array( |
|
| 56 | + 'first_name'=>$attendee->fname(), |
|
| 57 | + 'last_name'=>$attendee->lname(), |
|
| 58 | + 'email'=>$attendee->email(), |
|
| 59 | + 'address'=>$attendee->address(), |
|
| 60 | + 'address2'=>$attendee->address2(), |
|
| 61 | + 'city'=>$attendee->city(), |
|
| 62 | + 'state'=> $this->getAttendeeStateValueForForm($attendee), |
|
| 63 | + 'country'=> $attendee->country_ID(), |
|
| 64 | + 'zip'=>$attendee->zip(), |
|
| 65 | + 'phone'=>$attendee->phone(), |
|
| 66 | + ), |
|
| 67 | + $attendee, |
|
| 68 | + $this |
|
| 69 | + ) |
|
| 70 | + ); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Gets the default value to use for the billing form's state value. |
|
| 75 | - * @since 4.10.0.p |
|
| 76 | - * @param EE_Attendee $attendee |
|
| 77 | - * @return string |
|
| 78 | - * @throws EE_Error2 |
|
| 79 | - */ |
|
| 80 | - protected function getAttendeeStateValueForForm(EE_Attendee $attendee) |
|
| 81 | - { |
|
| 82 | - // If the state input was removed, just return a blank string. |
|
| 83 | - if (! $this->has_subsection('state')) { |
|
| 84 | - return ''; |
|
| 85 | - } |
|
| 86 | - $state_input = $this->get_input('state', false); |
|
| 87 | - if ($state_input instanceof EE_State_Select_Input) { |
|
| 88 | - $state_field_to_use = $state_input->valueFieldName(); |
|
| 89 | - } else { |
|
| 90 | - $state_field_to_use = 'STA_ID'; |
|
| 91 | - } |
|
| 92 | - switch ($state_field_to_use) { |
|
| 93 | - case 'STA_abbrev': |
|
| 94 | - $state_value = $attendee->state_abbrev(); |
|
| 95 | - break; |
|
| 96 | - case 'STA_name': |
|
| 97 | - $state_value = $attendee->state_name(); |
|
| 98 | - break; |
|
| 99 | - default: |
|
| 100 | - $state_value = $attendee->state_ID(); |
|
| 101 | - } |
|
| 102 | - return $state_value; |
|
| 103 | - } |
|
| 73 | + /** |
|
| 74 | + * Gets the default value to use for the billing form's state value. |
|
| 75 | + * @since 4.10.0.p |
|
| 76 | + * @param EE_Attendee $attendee |
|
| 77 | + * @return string |
|
| 78 | + * @throws EE_Error2 |
|
| 79 | + */ |
|
| 80 | + protected function getAttendeeStateValueForForm(EE_Attendee $attendee) |
|
| 81 | + { |
|
| 82 | + // If the state input was removed, just return a blank string. |
|
| 83 | + if (! $this->has_subsection('state')) { |
|
| 84 | + return ''; |
|
| 85 | + } |
|
| 86 | + $state_input = $this->get_input('state', false); |
|
| 87 | + if ($state_input instanceof EE_State_Select_Input) { |
|
| 88 | + $state_field_to_use = $state_input->valueFieldName(); |
|
| 89 | + } else { |
|
| 90 | + $state_field_to_use = 'STA_ID'; |
|
| 91 | + } |
|
| 92 | + switch ($state_field_to_use) { |
|
| 93 | + case 'STA_abbrev': |
|
| 94 | + $state_value = $attendee->state_abbrev(); |
|
| 95 | + break; |
|
| 96 | + case 'STA_name': |
|
| 97 | + $state_value = $attendee->state_name(); |
|
| 98 | + break; |
|
| 99 | + default: |
|
| 100 | + $state_value = $attendee->state_ID(); |
|
| 101 | + } |
|
| 102 | + return $state_value; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | 105 | |
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * copy_billing_form_data_to_attendee |
|
| 109 | - * copies info from the billing form to the attendee's details |
|
| 110 | - * @param \EE_Attendee $attendee - the attendee object to copy details to |
|
| 111 | - * @return \EE_Attendee |
|
| 112 | - */ |
|
| 113 | - public function copy_billing_form_data_to_attendee(EE_Attendee $attendee) |
|
| 114 | - { |
|
| 115 | - // grab billing form data |
|
| 116 | - $data = $this->valid_data(); |
|
| 117 | - // copy first_name |
|
| 118 | - if (! empty($data['first_name'])) { |
|
| 119 | - $attendee->set_fname($data['first_name']); |
|
| 120 | - } |
|
| 121 | - // copy last_name |
|
| 122 | - if (! empty($data['last_name'])) { |
|
| 123 | - $attendee->set_lname($data['last_name']); |
|
| 124 | - } |
|
| 125 | - // copy email |
|
| 126 | - if (! empty($data['email'])) { |
|
| 127 | - $attendee->set_email($data['email']); |
|
| 128 | - } |
|
| 129 | - // copy address |
|
| 130 | - if (! empty($data['address'])) { |
|
| 131 | - $attendee->set_address($data['address']); |
|
| 132 | - } |
|
| 133 | - // copy address2 |
|
| 134 | - if (! empty($data['address2'])) { |
|
| 135 | - $attendee->set_address2($data['address2']); |
|
| 136 | - } |
|
| 137 | - // copy city |
|
| 138 | - if (! empty($data['city'])) { |
|
| 139 | - $attendee->set_city($data['city']); |
|
| 140 | - } |
|
| 141 | - // copy state |
|
| 142 | - if (! empty($data['state'])) { |
|
| 143 | - $attendee->set_state($data['state']); |
|
| 144 | - } |
|
| 145 | - // copy country |
|
| 146 | - if (! empty($data['country'])) { |
|
| 147 | - $attendee->set_country($data['country']); |
|
| 148 | - } |
|
| 149 | - // copy zip |
|
| 150 | - if (! empty($data['zip'])) { |
|
| 151 | - $attendee->set_zip($data['zip']); |
|
| 152 | - } |
|
| 153 | - // copy phone |
|
| 154 | - if (! empty($data['phone'])) { |
|
| 155 | - $attendee->set_phone($data['phone']); |
|
| 156 | - } |
|
| 157 | - return $attendee; |
|
| 158 | - } |
|
| 107 | + /** |
|
| 108 | + * copy_billing_form_data_to_attendee |
|
| 109 | + * copies info from the billing form to the attendee's details |
|
| 110 | + * @param \EE_Attendee $attendee - the attendee object to copy details to |
|
| 111 | + * @return \EE_Attendee |
|
| 112 | + */ |
|
| 113 | + public function copy_billing_form_data_to_attendee(EE_Attendee $attendee) |
|
| 114 | + { |
|
| 115 | + // grab billing form data |
|
| 116 | + $data = $this->valid_data(); |
|
| 117 | + // copy first_name |
|
| 118 | + if (! empty($data['first_name'])) { |
|
| 119 | + $attendee->set_fname($data['first_name']); |
|
| 120 | + } |
|
| 121 | + // copy last_name |
|
| 122 | + if (! empty($data['last_name'])) { |
|
| 123 | + $attendee->set_lname($data['last_name']); |
|
| 124 | + } |
|
| 125 | + // copy email |
|
| 126 | + if (! empty($data['email'])) { |
|
| 127 | + $attendee->set_email($data['email']); |
|
| 128 | + } |
|
| 129 | + // copy address |
|
| 130 | + if (! empty($data['address'])) { |
|
| 131 | + $attendee->set_address($data['address']); |
|
| 132 | + } |
|
| 133 | + // copy address2 |
|
| 134 | + if (! empty($data['address2'])) { |
|
| 135 | + $attendee->set_address2($data['address2']); |
|
| 136 | + } |
|
| 137 | + // copy city |
|
| 138 | + if (! empty($data['city'])) { |
|
| 139 | + $attendee->set_city($data['city']); |
|
| 140 | + } |
|
| 141 | + // copy state |
|
| 142 | + if (! empty($data['state'])) { |
|
| 143 | + $attendee->set_state($data['state']); |
|
| 144 | + } |
|
| 145 | + // copy country |
|
| 146 | + if (! empty($data['country'])) { |
|
| 147 | + $attendee->set_country($data['country']); |
|
| 148 | + } |
|
| 149 | + // copy zip |
|
| 150 | + if (! empty($data['zip'])) { |
|
| 151 | + $attendee->set_zip($data['zip']); |
|
| 152 | + } |
|
| 153 | + // copy phone |
|
| 154 | + if (! empty($data['phone'])) { |
|
| 155 | + $attendee->set_phone($data['phone']); |
|
| 156 | + } |
|
| 157 | + return $attendee; |
|
| 158 | + } |
|
| 159 | 159 | |
| 160 | 160 | |
| 161 | - /** |
|
| 162 | - * create_attendee_from_billing_form_data |
|
| 163 | - * uses info from the billing form to create a new attendee |
|
| 164 | - * @return \EE_Attendee |
|
| 165 | - */ |
|
| 166 | - public function create_attendee_from_billing_form_data() |
|
| 167 | - { |
|
| 168 | - // grab billing form data |
|
| 169 | - $data = $this->valid_data(); |
|
| 170 | - return EE_Attendee::new_instance(array( |
|
| 171 | - 'ATT_fname' => ! empty($data['first_name']) ? $data['first_name'] : '', |
|
| 172 | - 'ATT_lname' => ! empty($data['last_name']) ? $data['last_name'] : '', |
|
| 173 | - 'ATT_email' => ! empty($data['email']) ? $data['email'] : '', |
|
| 174 | - 'ATT_address' => ! empty($data['address']) ? $data['address'] : '', |
|
| 175 | - 'ATT_address2' => ! empty($data['address2']) ? $data['address2'] : '', |
|
| 176 | - 'ATT_city' => ! empty($data['city']) ? $data['city'] : '', |
|
| 177 | - 'STA_ID' => ! empty($data['state']) ? $data['state'] : '', |
|
| 178 | - 'CNT_ISO' => ! empty($data['country']) ? $data['country'] : '', |
|
| 179 | - 'ATT_zip' => ! empty($data['zip']) ? $data['zip'] : '', |
|
| 180 | - 'ATT_phone' => ! empty($data['phone']) ? $data['phone'] : '', |
|
| 181 | - )); |
|
| 182 | - } |
|
| 161 | + /** |
|
| 162 | + * create_attendee_from_billing_form_data |
|
| 163 | + * uses info from the billing form to create a new attendee |
|
| 164 | + * @return \EE_Attendee |
|
| 165 | + */ |
|
| 166 | + public function create_attendee_from_billing_form_data() |
|
| 167 | + { |
|
| 168 | + // grab billing form data |
|
| 169 | + $data = $this->valid_data(); |
|
| 170 | + return EE_Attendee::new_instance(array( |
|
| 171 | + 'ATT_fname' => ! empty($data['first_name']) ? $data['first_name'] : '', |
|
| 172 | + 'ATT_lname' => ! empty($data['last_name']) ? $data['last_name'] : '', |
|
| 173 | + 'ATT_email' => ! empty($data['email']) ? $data['email'] : '', |
|
| 174 | + 'ATT_address' => ! empty($data['address']) ? $data['address'] : '', |
|
| 175 | + 'ATT_address2' => ! empty($data['address2']) ? $data['address2'] : '', |
|
| 176 | + 'ATT_city' => ! empty($data['city']) ? $data['city'] : '', |
|
| 177 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : '', |
|
| 178 | + 'CNT_ISO' => ! empty($data['country']) ? $data['country'] : '', |
|
| 179 | + 'ATT_zip' => ! empty($data['zip']) ? $data['zip'] : '', |
|
| 180 | + 'ATT_phone' => ! empty($data['phone']) ? $data['phone'] : '', |
|
| 181 | + )); |
|
| 182 | + } |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | // End of file EE_Billing_Attendee_Info_Form.form.php |
@@ -15,9 +15,9 @@ discard block |
||
| 15 | 15 | $stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*'); |
| 16 | 16 | $class_to_filepath = array(); |
| 17 | 17 | foreach ($stages as $filepath) { |
| 18 | - $matches = array(); |
|
| 19 | - preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
| 20 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
| 18 | + $matches = array(); |
|
| 19 | + preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
| 20 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
| 21 | 21 | } |
| 22 | 22 | // give addons a chance to autoload their stages too |
| 23 | 23 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath); |
@@ -36,68 +36,68 @@ discard block |
||
| 36 | 36 | class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base |
| 37 | 37 | { |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * return EE_DMS_Core_4_9_0 |
|
| 41 | - * |
|
| 42 | - * @param TableManager $table_manager |
|
| 43 | - * @param TableAnalysis $table_analysis |
|
| 44 | - */ |
|
| 45 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
| 46 | - { |
|
| 47 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso"); |
|
| 48 | - $this->_priority = 10; |
|
| 49 | - $this->_migration_stages = array( |
|
| 50 | - new EE_DMS_4_9_0_Email_System_Question(), |
|
| 51 | - new EE_DMS_4_9_0_Answers_With_No_Registration(), |
|
| 52 | - ); |
|
| 53 | - parent::__construct($table_manager, $table_analysis); |
|
| 54 | - } |
|
| 39 | + /** |
|
| 40 | + * return EE_DMS_Core_4_9_0 |
|
| 41 | + * |
|
| 42 | + * @param TableManager $table_manager |
|
| 43 | + * @param TableAnalysis $table_analysis |
|
| 44 | + */ |
|
| 45 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
| 46 | + { |
|
| 47 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso"); |
|
| 48 | + $this->_priority = 10; |
|
| 49 | + $this->_migration_stages = array( |
|
| 50 | + new EE_DMS_4_9_0_Email_System_Question(), |
|
| 51 | + new EE_DMS_4_9_0_Answers_With_No_Registration(), |
|
| 52 | + ); |
|
| 53 | + parent::__construct($table_manager, $table_analysis); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | 56 | |
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Whether to migrate or not. |
|
| 60 | - * |
|
| 61 | - * @param array $version_array |
|
| 62 | - * @return bool |
|
| 63 | - */ |
|
| 64 | - public function can_migrate_from_version($version_array) |
|
| 65 | - { |
|
| 66 | - $version_string = $version_array['Core']; |
|
| 67 | - if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) { |
|
| 68 | - // echo "$version_string can be migrated from"; |
|
| 69 | - return true; |
|
| 70 | - } elseif (! $version_string) { |
|
| 71 | - // echo "no version string provided: $version_string"; |
|
| 72 | - // no version string provided... this must be pre 4.3 |
|
| 73 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 74 | - } else { |
|
| 75 | - // echo "$version_string doesnt apply"; |
|
| 76 | - return false; |
|
| 77 | - } |
|
| 78 | - } |
|
| 58 | + /** |
|
| 59 | + * Whether to migrate or not. |
|
| 60 | + * |
|
| 61 | + * @param array $version_array |
|
| 62 | + * @return bool |
|
| 63 | + */ |
|
| 64 | + public function can_migrate_from_version($version_array) |
|
| 65 | + { |
|
| 66 | + $version_string = $version_array['Core']; |
|
| 67 | + if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) { |
|
| 68 | + // echo "$version_string can be migrated from"; |
|
| 69 | + return true; |
|
| 70 | + } elseif (! $version_string) { |
|
| 71 | + // echo "no version string provided: $version_string"; |
|
| 72 | + // no version string provided... this must be pre 4.3 |
|
| 73 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 74 | + } else { |
|
| 75 | + // echo "$version_string doesnt apply"; |
|
| 76 | + return false; |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | 80 | |
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * @return bool |
|
| 84 | - */ |
|
| 85 | - public function schema_changes_before_migration() |
|
| 86 | - { |
|
| 87 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 88 | - $now_in_mysql = current_time('mysql', true); |
|
| 89 | - $table_name = 'esp_answer'; |
|
| 90 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 82 | + /** |
|
| 83 | + * @return bool |
|
| 84 | + */ |
|
| 85 | + public function schema_changes_before_migration() |
|
| 86 | + { |
|
| 87 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 88 | + $now_in_mysql = current_time('mysql', true); |
|
| 89 | + $table_name = 'esp_answer'; |
|
| 90 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 91 | 91 | REG_ID int(10) unsigned NOT NULL, |
| 92 | 92 | QST_ID int(10) unsigned NOT NULL, |
| 93 | 93 | ANS_value text NOT NULL, |
| 94 | 94 | PRIMARY KEY (ANS_ID), |
| 95 | 95 | KEY REG_ID (REG_ID), |
| 96 | 96 | KEY QST_ID (QST_ID)"; |
| 97 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 98 | - $table_name = 'esp_attendee_meta'; |
|
| 99 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email'); |
|
| 100 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 97 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 98 | + $table_name = 'esp_attendee_meta'; |
|
| 99 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email'); |
|
| 100 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 101 | 101 | ATT_ID bigint(20) unsigned NOT NULL, |
| 102 | 102 | ATT_fname varchar(45) NOT NULL, |
| 103 | 103 | ATT_lname varchar(45) NOT NULL, |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | KEY ATT_email (ATT_email(191)), |
| 115 | 115 | KEY ATT_lname (ATT_lname), |
| 116 | 116 | KEY ATT_fname (ATT_fname)"; |
| 117 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 118 | - $table_name = 'esp_checkin'; |
|
| 119 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 117 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 118 | + $table_name = 'esp_checkin'; |
|
| 119 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 120 | 120 | REG_ID int(10) unsigned NOT NULL, |
| 121 | 121 | DTT_ID int(10) unsigned NOT NULL, |
| 122 | 122 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -124,9 +124,9 @@ discard block |
||
| 124 | 124 | PRIMARY KEY (CHK_ID), |
| 125 | 125 | KEY REG_ID (REG_ID), |
| 126 | 126 | KEY DTT_ID (DTT_ID)"; |
| 127 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 128 | - $table_name = 'esp_country'; |
|
| 129 | - $sql = "CNT_ISO varchar(2) NOT NULL, |
|
| 127 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 128 | + $table_name = 'esp_country'; |
|
| 129 | + $sql = "CNT_ISO varchar(2) NOT NULL, |
|
| 130 | 130 | CNT_ISO3 varchar(3) NOT NULL, |
| 131 | 131 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
| 132 | 132 | CNT_name varchar(45) NOT NULL, |
@@ -142,29 +142,29 @@ discard block |
||
| 142 | 142 | CNT_is_EU tinyint(1) DEFAULT '0', |
| 143 | 143 | CNT_active tinyint(1) DEFAULT '0', |
| 144 | 144 | PRIMARY KEY (CNT_ISO)"; |
| 145 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 146 | - $table_name = 'esp_currency'; |
|
| 147 | - $sql = "CUR_code varchar(6) NOT NULL, |
|
| 145 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 146 | + $table_name = 'esp_currency'; |
|
| 147 | + $sql = "CUR_code varchar(6) NOT NULL, |
|
| 148 | 148 | CUR_single varchar(45) DEFAULT 'dollar', |
| 149 | 149 | CUR_plural varchar(45) DEFAULT 'dollars', |
| 150 | 150 | CUR_sign varchar(45) DEFAULT '$', |
| 151 | 151 | CUR_dec_plc varchar(1) NOT NULL DEFAULT '2', |
| 152 | 152 | CUR_active tinyint(1) DEFAULT '0', |
| 153 | 153 | PRIMARY KEY (CUR_code)"; |
| 154 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 155 | - // note: although this table is no longer in use, |
|
| 156 | - // it hasn't been removed because then queries to the model will have errors. |
|
| 157 | - // but you should expect this table and its corresponding model to be removed in |
|
| 158 | - // the next few months |
|
| 159 | - $table_name = 'esp_currency_payment_method'; |
|
| 160 | - $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 154 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 155 | + // note: although this table is no longer in use, |
|
| 156 | + // it hasn't been removed because then queries to the model will have errors. |
|
| 157 | + // but you should expect this table and its corresponding model to be removed in |
|
| 158 | + // the next few months |
|
| 159 | + $table_name = 'esp_currency_payment_method'; |
|
| 160 | + $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 161 | 161 | CUR_code varchar(6) NOT NULL, |
| 162 | 162 | PMD_ID int(11) NOT NULL, |
| 163 | 163 | PRIMARY KEY (CPM_ID), |
| 164 | 164 | KEY PMD_ID (PMD_ID)"; |
| 165 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 166 | - $table_name = 'esp_datetime'; |
|
| 167 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 165 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 166 | + $table_name = 'esp_datetime'; |
|
| 167 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 168 | 168 | EVT_ID bigint(20) unsigned NOT NULL, |
| 169 | 169 | DTT_name varchar(255) NOT NULL DEFAULT '', |
| 170 | 170 | DTT_description text NOT NULL, |
@@ -181,25 +181,25 @@ discard block |
||
| 181 | 181 | KEY DTT_EVT_start (DTT_EVT_start), |
| 182 | 182 | KEY EVT_ID (EVT_ID), |
| 183 | 183 | KEY DTT_is_primary (DTT_is_primary)"; |
| 184 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 185 | - $table_name = "esp_datetime_ticket"; |
|
| 186 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 184 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 185 | + $table_name = "esp_datetime_ticket"; |
|
| 186 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 187 | 187 | DTT_ID int(10) unsigned NOT NULL, |
| 188 | 188 | TKT_ID int(10) unsigned NOT NULL, |
| 189 | 189 | PRIMARY KEY (DTK_ID), |
| 190 | 190 | KEY DTT_ID (DTT_ID), |
| 191 | 191 | KEY TKT_ID (TKT_ID)"; |
| 192 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 193 | - $table_name = 'esp_event_message_template'; |
|
| 194 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 192 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 193 | + $table_name = 'esp_event_message_template'; |
|
| 194 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 195 | 195 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
| 196 | 196 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
| 197 | 197 | PRIMARY KEY (EMT_ID), |
| 198 | 198 | KEY EVT_ID (EVT_ID), |
| 199 | 199 | KEY GRP_ID (GRP_ID)"; |
| 200 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 201 | - $table_name = 'esp_event_meta'; |
|
| 202 | - $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
| 200 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 201 | + $table_name = 'esp_event_meta'; |
|
| 202 | + $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
| 203 | 203 | EVT_ID bigint(20) unsigned NOT NULL, |
| 204 | 204 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
| 205 | 205 | EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -214,34 +214,34 @@ discard block |
||
| 214 | 214 | EVT_donations tinyint(1) NULL, |
| 215 | 215 | PRIMARY KEY (EVTM_ID), |
| 216 | 216 | KEY EVT_ID (EVT_ID)"; |
| 217 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 218 | - $table_name = 'esp_event_question_group'; |
|
| 219 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 217 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 218 | + $table_name = 'esp_event_question_group'; |
|
| 219 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 220 | 220 | EVT_ID bigint(20) unsigned NOT NULL, |
| 221 | 221 | QSG_ID int(10) unsigned NOT NULL, |
| 222 | 222 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
| 223 | 223 | PRIMARY KEY (EQG_ID), |
| 224 | 224 | KEY EVT_ID (EVT_ID), |
| 225 | 225 | KEY QSG_ID (QSG_ID)"; |
| 226 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 227 | - $table_name = 'esp_event_venue'; |
|
| 228 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 226 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 227 | + $table_name = 'esp_event_venue'; |
|
| 228 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 229 | 229 | EVT_ID bigint(20) unsigned NOT NULL, |
| 230 | 230 | VNU_ID bigint(20) unsigned NOT NULL, |
| 231 | 231 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
| 232 | 232 | PRIMARY KEY (EVV_ID)"; |
| 233 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 234 | - $table_name = 'esp_extra_meta'; |
|
| 235 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 233 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 234 | + $table_name = 'esp_extra_meta'; |
|
| 235 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 236 | 236 | OBJ_ID int(11) DEFAULT NULL, |
| 237 | 237 | EXM_type varchar(45) DEFAULT NULL, |
| 238 | 238 | EXM_key varchar(45) DEFAULT NULL, |
| 239 | 239 | EXM_value text, |
| 240 | 240 | PRIMARY KEY (EXM_ID), |
| 241 | 241 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
| 242 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 243 | - $table_name = 'esp_extra_join'; |
|
| 244 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 242 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 243 | + $table_name = 'esp_extra_join'; |
|
| 244 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 245 | 245 | EXJ_first_model_id varchar(6) NOT NULL, |
| 246 | 246 | EXJ_first_model_name varchar(20) NOT NULL, |
| 247 | 247 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -249,9 +249,9 @@ discard block |
||
| 249 | 249 | PRIMARY KEY (EXJ_ID), |
| 250 | 250 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
| 251 | 251 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
| 252 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 253 | - $table_name = 'esp_line_item'; |
|
| 254 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 252 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 253 | + $table_name = 'esp_line_item'; |
|
| 254 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 255 | 255 | LIN_code varchar(245) NOT NULL DEFAULT '', |
| 256 | 256 | TXN_ID int(11) DEFAULT NULL, |
| 257 | 257 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -272,11 +272,11 @@ discard block |
||
| 272 | 272 | KEY txn_type_timestamp (TXN_ID,LIN_type,LIN_timestamp), |
| 273 | 273 | KEY txn_obj_id_obj_type (TXN_ID,OBJ_ID,OBJ_type), |
| 274 | 274 | KEY obj_id_obj_type (OBJ_ID,OBJ_type)"; |
| 275 | - $this->_get_table_manager()->dropIndex('esp_line_item', 'TXN_ID'); |
|
| 276 | - $this->_get_table_manager()->dropIndex('esp_line_item', 'LIN_code'); |
|
| 277 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 278 | - $table_name = 'esp_log'; |
|
| 279 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 275 | + $this->_get_table_manager()->dropIndex('esp_line_item', 'TXN_ID'); |
|
| 276 | + $this->_get_table_manager()->dropIndex('esp_line_item', 'LIN_code'); |
|
| 277 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 278 | + $table_name = 'esp_log'; |
|
| 279 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 280 | 280 | LOG_time datetime DEFAULT NULL, |
| 281 | 281 | OBJ_ID varchar(45) DEFAULT NULL, |
| 282 | 282 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -287,12 +287,12 @@ discard block |
||
| 287 | 287 | KEY LOG_time (LOG_time), |
| 288 | 288 | KEY OBJ (OBJ_type,OBJ_ID), |
| 289 | 289 | KEY LOG_type (LOG_type)"; |
| 290 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 291 | - $table_name = 'esp_message'; |
|
| 292 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to'); |
|
| 293 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from'); |
|
| 294 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject'); |
|
| 295 | - $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 290 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 291 | + $table_name = 'esp_message'; |
|
| 292 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to'); |
|
| 293 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from'); |
|
| 294 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject'); |
|
| 295 | + $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 296 | 296 | GRP_ID int(10) unsigned NULL, |
| 297 | 297 | MSG_token varchar(255) NULL, |
| 298 | 298 | TXN_ID int(10) unsigned NULL, |
@@ -324,18 +324,18 @@ discard block |
||
| 324 | 324 | KEY STS_ID (STS_ID), |
| 325 | 325 | KEY MSG_created (MSG_created), |
| 326 | 326 | KEY MSG_modified (MSG_modified)"; |
| 327 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 328 | - $table_name = 'esp_message_template'; |
|
| 329 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 327 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 328 | + $table_name = 'esp_message_template'; |
|
| 329 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 330 | 330 | GRP_ID int(10) unsigned NOT NULL, |
| 331 | 331 | MTP_context varchar(50) NOT NULL, |
| 332 | 332 | MTP_template_field varchar(30) NOT NULL, |
| 333 | 333 | MTP_content text NOT NULL, |
| 334 | 334 | PRIMARY KEY (MTP_ID), |
| 335 | 335 | KEY GRP_ID (GRP_ID)"; |
| 336 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 337 | - $table_name = 'esp_message_template_group'; |
|
| 338 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 336 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 337 | + $table_name = 'esp_message_template_group'; |
|
| 338 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 339 | 339 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
| 340 | 340 | MTP_name varchar(245) NOT NULL DEFAULT '', |
| 341 | 341 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -347,9 +347,9 @@ discard block |
||
| 347 | 347 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
| 348 | 348 | PRIMARY KEY (GRP_ID), |
| 349 | 349 | KEY MTP_user_id (MTP_user_id)"; |
| 350 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 351 | - $table_name = 'esp_payment'; |
|
| 352 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 350 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 351 | + $table_name = 'esp_payment'; |
|
| 352 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 353 | 353 | TXN_ID int(10) unsigned DEFAULT NULL, |
| 354 | 354 | STS_ID varchar(3) DEFAULT NULL, |
| 355 | 355 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -366,9 +366,9 @@ discard block |
||
| 366 | 366 | PRIMARY KEY (PAY_ID), |
| 367 | 367 | KEY PAY_timestamp (PAY_timestamp), |
| 368 | 368 | KEY TXN_ID (TXN_ID)"; |
| 369 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 370 | - $table_name = 'esp_payment_method'; |
|
| 371 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 369 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 370 | + $table_name = 'esp_payment_method'; |
|
| 371 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 372 | 372 | PMD_type varchar(124) DEFAULT NULL, |
| 373 | 373 | PMD_name varchar(255) DEFAULT NULL, |
| 374 | 374 | PMD_desc text, |
@@ -384,24 +384,24 @@ discard block |
||
| 384 | 384 | PRIMARY KEY (PMD_ID), |
| 385 | 385 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
| 386 | 386 | KEY PMD_type (PMD_type)"; |
| 387 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 388 | - $table_name = "esp_ticket_price"; |
|
| 389 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 387 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 388 | + $table_name = "esp_ticket_price"; |
|
| 389 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 390 | 390 | TKT_ID int(10) unsigned NOT NULL, |
| 391 | 391 | PRC_ID int(10) unsigned NOT NULL, |
| 392 | 392 | PRIMARY KEY (TKP_ID), |
| 393 | 393 | KEY TKT_ID (TKT_ID), |
| 394 | 394 | KEY PRC_ID (PRC_ID)"; |
| 395 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 396 | - $table_name = "esp_ticket_template"; |
|
| 397 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 395 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 396 | + $table_name = "esp_ticket_template"; |
|
| 397 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 398 | 398 | TTM_name varchar(45) NOT NULL, |
| 399 | 399 | TTM_description text, |
| 400 | 400 | TTM_file varchar(45), |
| 401 | 401 | PRIMARY KEY (TTM_ID)"; |
| 402 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 403 | - $table_name = 'esp_question'; |
|
| 404 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 402 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 403 | + $table_name = 'esp_question'; |
|
| 404 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 405 | 405 | QST_display_text text NOT NULL, |
| 406 | 406 | QST_admin_label varchar(255) NOT NULL, |
| 407 | 407 | QST_system varchar(25) DEFAULT NULL, |
@@ -415,18 +415,18 @@ discard block |
||
| 415 | 415 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
| 416 | 416 | PRIMARY KEY (QST_ID), |
| 417 | 417 | KEY QST_order (QST_order)'; |
| 418 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 419 | - $table_name = 'esp_question_group_question'; |
|
| 420 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 418 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 419 | + $table_name = 'esp_question_group_question'; |
|
| 420 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 421 | 421 | QSG_ID int(10) unsigned NOT NULL, |
| 422 | 422 | QST_ID int(10) unsigned NOT NULL, |
| 423 | 423 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
| 424 | 424 | PRIMARY KEY (QGQ_ID), |
| 425 | 425 | KEY QST_ID (QST_ID), |
| 426 | 426 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
| 427 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 428 | - $table_name = 'esp_question_option'; |
|
| 429 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 427 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 428 | + $table_name = 'esp_question_option'; |
|
| 429 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 430 | 430 | QSO_value varchar(255) NOT NULL, |
| 431 | 431 | QSO_desc text NOT NULL, |
| 432 | 432 | QST_ID int(10) unsigned NOT NULL, |
@@ -436,9 +436,9 @@ discard block |
||
| 436 | 436 | PRIMARY KEY (QSO_ID), |
| 437 | 437 | KEY QST_ID (QST_ID), |
| 438 | 438 | KEY QSO_order (QSO_order)"; |
| 439 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 440 | - $table_name = 'esp_registration'; |
|
| 441 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 439 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 440 | + $table_name = 'esp_registration'; |
|
| 441 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 442 | 442 | EVT_ID bigint(20) unsigned NOT NULL, |
| 443 | 443 | ATT_ID bigint(20) unsigned NOT NULL, |
| 444 | 444 | TXN_ID int(10) unsigned NOT NULL, |
@@ -462,18 +462,18 @@ discard block |
||
| 462 | 462 | KEY TKT_ID (TKT_ID), |
| 463 | 463 | KEY EVT_ID (EVT_ID), |
| 464 | 464 | KEY STS_ID (STS_ID)"; |
| 465 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 466 | - $table_name = 'esp_registration_payment'; |
|
| 467 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 465 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 466 | + $table_name = 'esp_registration_payment'; |
|
| 467 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 468 | 468 | REG_ID int(10) unsigned NOT NULL, |
| 469 | 469 | PAY_ID int(10) unsigned NULL, |
| 470 | 470 | RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
| 471 | 471 | PRIMARY KEY (RPY_ID), |
| 472 | 472 | KEY REG_ID (REG_ID), |
| 473 | 473 | KEY PAY_ID (PAY_ID)"; |
| 474 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 475 | - $table_name = 'esp_state'; |
|
| 476 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
| 474 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 475 | + $table_name = 'esp_state'; |
|
| 476 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
| 477 | 477 | CNT_ISO varchar(2) NOT NULL, |
| 478 | 478 | STA_abbrev varchar(24) NOT NULL, |
| 479 | 479 | STA_name varchar(100) NOT NULL, |
@@ -481,9 +481,9 @@ discard block |
||
| 481 | 481 | PRIMARY KEY (STA_ID), |
| 482 | 482 | KEY STA_abbrev (STA_abbrev), |
| 483 | 483 | KEY CNT_ISO (CNT_ISO)"; |
| 484 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 485 | - $table_name = 'esp_status'; |
|
| 486 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
| 484 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 485 | + $table_name = 'esp_status'; |
|
| 486 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
| 487 | 487 | STS_code varchar(45) NOT NULL, |
| 488 | 488 | STS_type varchar(45) NOT NULL, |
| 489 | 489 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -491,9 +491,9 @@ discard block |
||
| 491 | 491 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
| 492 | 492 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
| 493 | 493 | KEY STS_type (STS_type)"; |
| 494 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 495 | - $table_name = 'esp_transaction'; |
|
| 496 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 494 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 495 | + $table_name = 'esp_transaction'; |
|
| 496 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 497 | 497 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
| 498 | 498 | TXN_total decimal(12,3) DEFAULT '0.00', |
| 499 | 499 | TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00', |
@@ -505,9 +505,9 @@ discard block |
||
| 505 | 505 | PRIMARY KEY (TXN_ID), |
| 506 | 506 | KEY TXN_timestamp (TXN_timestamp), |
| 507 | 507 | KEY STS_ID (STS_ID)"; |
| 508 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 509 | - $table_name = 'esp_venue_meta'; |
|
| 510 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 508 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 509 | + $table_name = 'esp_venue_meta'; |
|
| 510 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 511 | 511 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
| 512 | 512 | VNU_address varchar(255) DEFAULT NULL, |
| 513 | 513 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -526,10 +526,10 @@ discard block |
||
| 526 | 526 | KEY VNU_ID (VNU_ID), |
| 527 | 527 | KEY STA_ID (STA_ID), |
| 528 | 528 | KEY CNT_ISO (CNT_ISO)"; |
| 529 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 530 | - // modified tables |
|
| 531 | - $table_name = "esp_price"; |
|
| 532 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 529 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 530 | + // modified tables |
|
| 531 | + $table_name = "esp_price"; |
|
| 532 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 533 | 533 | PRT_ID tinyint(3) unsigned NOT NULL, |
| 534 | 534 | PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
| 535 | 535 | PRC_name varchar(245) NOT NULL, |
@@ -542,9 +542,9 @@ discard block |
||
| 542 | 542 | PRC_parent int(10) unsigned DEFAULT 0, |
| 543 | 543 | PRIMARY KEY (PRC_ID), |
| 544 | 544 | KEY PRT_ID (PRT_ID)"; |
| 545 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 546 | - $table_name = "esp_price_type"; |
|
| 547 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
| 545 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 546 | + $table_name = "esp_price_type"; |
|
| 547 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
| 548 | 548 | PRT_name varchar(45) NOT NULL, |
| 549 | 549 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
| 550 | 550 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -553,9 +553,9 @@ discard block |
||
| 553 | 553 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
| 554 | 554 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
| 555 | 555 | PRIMARY KEY (PRT_ID)"; |
| 556 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 557 | - $table_name = "esp_ticket"; |
|
| 558 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 556 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 557 | + $table_name = "esp_ticket"; |
|
| 558 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 559 | 559 | TTM_ID int(10) unsigned NOT NULL, |
| 560 | 560 | TKT_name varchar(245) NOT NULL DEFAULT '', |
| 561 | 561 | TKT_description text NOT NULL, |
@@ -578,9 +578,9 @@ discard block |
||
| 578 | 578 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
| 579 | 579 | PRIMARY KEY (TKT_ID), |
| 580 | 580 | KEY TKT_start_date (TKT_start_date)"; |
| 581 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 582 | - $table_name = 'esp_question_group'; |
|
| 583 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 581 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 582 | + $table_name = 'esp_question_group'; |
|
| 583 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 584 | 584 | QSG_name varchar(255) NOT NULL, |
| 585 | 585 | QSG_identifier varchar(100) NOT NULL, |
| 586 | 586 | QSG_desc text NULL, |
@@ -593,159 +593,159 @@ discard block |
||
| 593 | 593 | PRIMARY KEY (QSG_ID), |
| 594 | 594 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
| 595 | 595 | KEY QSG_order (QSG_order)'; |
| 596 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 597 | - $this->insert_default_data(); |
|
| 598 | - return true; |
|
| 599 | - } |
|
| 596 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 597 | + $this->insert_default_data(); |
|
| 598 | + return true; |
|
| 599 | + } |
|
| 600 | 600 | |
| 601 | - /** |
|
| 602 | - * Inserts default data after parent was called. |
|
| 603 | - * @since 4.10.0.p |
|
| 604 | - * @throws EE_Error |
|
| 605 | - * @throws InvalidArgumentException |
|
| 606 | - * @throws ReflectionException |
|
| 607 | - * @throws InvalidDataTypeException |
|
| 608 | - * @throws InvalidInterfaceException |
|
| 609 | - */ |
|
| 610 | - public function insert_default_data() |
|
| 611 | - { |
|
| 612 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
| 613 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
| 614 | - // (because many need to convert old string states to foreign keys into the states table) |
|
| 615 | - $script_4_1_defaults->insert_default_states(); |
|
| 616 | - $script_4_1_defaults->insert_default_countries(); |
|
| 617 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
| 618 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
| 619 | - $script_4_5_defaults->insert_default_price_types(); |
|
| 620 | - $script_4_5_defaults->insert_default_prices(); |
|
| 621 | - $script_4_5_defaults->insert_default_tickets(); |
|
| 622 | - /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
| 623 | - $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
| 624 | - $script_4_6_defaults->add_default_admin_only_payments(); |
|
| 625 | - $script_4_6_defaults->insert_default_currencies(); |
|
| 626 | - /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
| 627 | - $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
| 628 | - $script_4_8_defaults->verify_new_countries(); |
|
| 629 | - $script_4_8_defaults->verify_new_currencies(); |
|
| 630 | - $this->verify_db_collations(); |
|
| 631 | - $this->verify_db_collations_again(); |
|
| 632 | - } |
|
| 601 | + /** |
|
| 602 | + * Inserts default data after parent was called. |
|
| 603 | + * @since 4.10.0.p |
|
| 604 | + * @throws EE_Error |
|
| 605 | + * @throws InvalidArgumentException |
|
| 606 | + * @throws ReflectionException |
|
| 607 | + * @throws InvalidDataTypeException |
|
| 608 | + * @throws InvalidInterfaceException |
|
| 609 | + */ |
|
| 610 | + public function insert_default_data() |
|
| 611 | + { |
|
| 612 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
| 613 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
| 614 | + // (because many need to convert old string states to foreign keys into the states table) |
|
| 615 | + $script_4_1_defaults->insert_default_states(); |
|
| 616 | + $script_4_1_defaults->insert_default_countries(); |
|
| 617 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
| 618 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
| 619 | + $script_4_5_defaults->insert_default_price_types(); |
|
| 620 | + $script_4_5_defaults->insert_default_prices(); |
|
| 621 | + $script_4_5_defaults->insert_default_tickets(); |
|
| 622 | + /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
| 623 | + $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
| 624 | + $script_4_6_defaults->add_default_admin_only_payments(); |
|
| 625 | + $script_4_6_defaults->insert_default_currencies(); |
|
| 626 | + /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
| 627 | + $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
| 628 | + $script_4_8_defaults->verify_new_countries(); |
|
| 629 | + $script_4_8_defaults->verify_new_currencies(); |
|
| 630 | + $this->verify_db_collations(); |
|
| 631 | + $this->verify_db_collations_again(); |
|
| 632 | + } |
|
| 633 | 633 | |
| 634 | 634 | |
| 635 | 635 | |
| 636 | - /** |
|
| 637 | - * @return boolean |
|
| 638 | - */ |
|
| 639 | - public function schema_changes_after_migration() |
|
| 640 | - { |
|
| 641 | - return true; |
|
| 642 | - } |
|
| 636 | + /** |
|
| 637 | + * @return boolean |
|
| 638 | + */ |
|
| 639 | + public function schema_changes_after_migration() |
|
| 640 | + { |
|
| 641 | + return true; |
|
| 642 | + } |
|
| 643 | 643 | |
| 644 | 644 | |
| 645 | 645 | |
| 646 | - public function migration_page_hooks() |
|
| 647 | - { |
|
| 648 | - } |
|
| 646 | + public function migration_page_hooks() |
|
| 647 | + { |
|
| 648 | + } |
|
| 649 | 649 | |
| 650 | 650 | |
| 651 | 651 | |
| 652 | - /** |
|
| 653 | - * Verify all EE4 models' tables use utf8mb4 collation |
|
| 654 | - * |
|
| 655 | - * @return void |
|
| 656 | - */ |
|
| 657 | - public function verify_db_collations() |
|
| 658 | - { |
|
| 659 | - global $wpdb; |
|
| 660 | - // double-check we haven't already done it or that that the DB doesn't support utf8mb4 |
|
| 661 | - if ('utf8mb4' !== $wpdb->charset |
|
| 662 | - || get_option('ee_verified_db_collations', false)) { |
|
| 663 | - return; |
|
| 664 | - } |
|
| 665 | - // grab tables from each model |
|
| 666 | - $tables_to_check = array(); |
|
| 667 | - foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
| 668 | - if (method_exists($model_name, 'instance')) { |
|
| 669 | - $model_obj = call_user_func(array($model_name, 'instance')); |
|
| 670 | - if ($model_obj instanceof EEM_Base) { |
|
| 671 | - foreach ($model_obj->get_tables() as $table) { |
|
| 672 | - if (strpos($table->get_table_name(), 'esp_') |
|
| 673 | - && (is_main_site()// for main tables, verify global tables |
|
| 674 | - || ! $table->is_global()// if not the main site, then only verify non-global tables (avoid doubling up) |
|
| 675 | - ) |
|
| 676 | - && function_exists('maybe_convert_table_to_utf8mb4') |
|
| 677 | - ) { |
|
| 678 | - $tables_to_check[] = $table->get_table_name(); |
|
| 679 | - } |
|
| 680 | - } |
|
| 681 | - } |
|
| 682 | - } |
|
| 683 | - } |
|
| 684 | - // and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active |
|
| 685 | - // when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead |
|
| 686 | - // of hard-coding this |
|
| 687 | - $addon_tables = array( |
|
| 688 | - // mailchimp |
|
| 689 | - 'esp_event_mailchimp_list_group', |
|
| 690 | - 'esp_event_question_mailchimp_field', |
|
| 691 | - // multisite |
|
| 692 | - 'esp_blog_meta', |
|
| 693 | - // people |
|
| 694 | - 'esp_people_to_post', |
|
| 695 | - // promotions |
|
| 696 | - 'esp_promotion', |
|
| 697 | - 'esp_promotion_object', |
|
| 698 | - ); |
|
| 699 | - foreach ($addon_tables as $table_name) { |
|
| 700 | - $tables_to_check[] = $table_name; |
|
| 701 | - } |
|
| 702 | - $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
| 703 | - // ok and now let's remember this was done (without needing to check the db schemas all over again) |
|
| 704 | - add_option('ee_verified_db_collations', true, null, 'no'); |
|
| 705 | - // seeing how this ran with the fix from 10435, no need to check again |
|
| 706 | - add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
| 707 | - } |
|
| 652 | + /** |
|
| 653 | + * Verify all EE4 models' tables use utf8mb4 collation |
|
| 654 | + * |
|
| 655 | + * @return void |
|
| 656 | + */ |
|
| 657 | + public function verify_db_collations() |
|
| 658 | + { |
|
| 659 | + global $wpdb; |
|
| 660 | + // double-check we haven't already done it or that that the DB doesn't support utf8mb4 |
|
| 661 | + if ('utf8mb4' !== $wpdb->charset |
|
| 662 | + || get_option('ee_verified_db_collations', false)) { |
|
| 663 | + return; |
|
| 664 | + } |
|
| 665 | + // grab tables from each model |
|
| 666 | + $tables_to_check = array(); |
|
| 667 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
| 668 | + if (method_exists($model_name, 'instance')) { |
|
| 669 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
| 670 | + if ($model_obj instanceof EEM_Base) { |
|
| 671 | + foreach ($model_obj->get_tables() as $table) { |
|
| 672 | + if (strpos($table->get_table_name(), 'esp_') |
|
| 673 | + && (is_main_site()// for main tables, verify global tables |
|
| 674 | + || ! $table->is_global()// if not the main site, then only verify non-global tables (avoid doubling up) |
|
| 675 | + ) |
|
| 676 | + && function_exists('maybe_convert_table_to_utf8mb4') |
|
| 677 | + ) { |
|
| 678 | + $tables_to_check[] = $table->get_table_name(); |
|
| 679 | + } |
|
| 680 | + } |
|
| 681 | + } |
|
| 682 | + } |
|
| 683 | + } |
|
| 684 | + // and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active |
|
| 685 | + // when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead |
|
| 686 | + // of hard-coding this |
|
| 687 | + $addon_tables = array( |
|
| 688 | + // mailchimp |
|
| 689 | + 'esp_event_mailchimp_list_group', |
|
| 690 | + 'esp_event_question_mailchimp_field', |
|
| 691 | + // multisite |
|
| 692 | + 'esp_blog_meta', |
|
| 693 | + // people |
|
| 694 | + 'esp_people_to_post', |
|
| 695 | + // promotions |
|
| 696 | + 'esp_promotion', |
|
| 697 | + 'esp_promotion_object', |
|
| 698 | + ); |
|
| 699 | + foreach ($addon_tables as $table_name) { |
|
| 700 | + $tables_to_check[] = $table_name; |
|
| 701 | + } |
|
| 702 | + $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
| 703 | + // ok and now let's remember this was done (without needing to check the db schemas all over again) |
|
| 704 | + add_option('ee_verified_db_collations', true, null, 'no'); |
|
| 705 | + // seeing how this ran with the fix from 10435, no need to check again |
|
| 706 | + add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
| 707 | + } |
|
| 708 | 708 | |
| 709 | 709 | |
| 710 | 710 | |
| 711 | - /** |
|
| 712 | - * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435 |
|
| 713 | - * which meant some DB collations might not have been updated |
|
| 714 | - * @return void |
|
| 715 | - */ |
|
| 716 | - public function verify_db_collations_again() |
|
| 717 | - { |
|
| 718 | - global $wpdb; |
|
| 719 | - // double-check we haven't already done this or that the DB doesn't support it |
|
| 720 | - // compare to how WordPress' upgrade_430() function does this check |
|
| 721 | - if ('utf8mb4' !== $wpdb->charset |
|
| 722 | - || get_option('ee_verified_db_collations_again', false)) { |
|
| 723 | - return; |
|
| 724 | - } |
|
| 725 | - $tables_to_check = array( |
|
| 726 | - 'esp_attendee_meta', |
|
| 727 | - 'esp_message' |
|
| 728 | - ); |
|
| 729 | - $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
| 730 | - add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
| 731 | - } |
|
| 711 | + /** |
|
| 712 | + * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435 |
|
| 713 | + * which meant some DB collations might not have been updated |
|
| 714 | + * @return void |
|
| 715 | + */ |
|
| 716 | + public function verify_db_collations_again() |
|
| 717 | + { |
|
| 718 | + global $wpdb; |
|
| 719 | + // double-check we haven't already done this or that the DB doesn't support it |
|
| 720 | + // compare to how WordPress' upgrade_430() function does this check |
|
| 721 | + if ('utf8mb4' !== $wpdb->charset |
|
| 722 | + || get_option('ee_verified_db_collations_again', false)) { |
|
| 723 | + return; |
|
| 724 | + } |
|
| 725 | + $tables_to_check = array( |
|
| 726 | + 'esp_attendee_meta', |
|
| 727 | + 'esp_message' |
|
| 728 | + ); |
|
| 729 | + $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
| 730 | + add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
| 731 | + } |
|
| 732 | 732 | |
| 733 | 733 | |
| 734 | 734 | |
| 735 | - /** |
|
| 736 | - * Runs maybe_convert_table_to_utf8mb4 on the specified tables |
|
| 737 | - * @param $tables_to_check |
|
| 738 | - * @return boolean true if logic ran, false if it didn't |
|
| 739 | - */ |
|
| 740 | - protected function _verify_db_collations_for_tables($tables_to_check) |
|
| 741 | - { |
|
| 742 | - foreach ($tables_to_check as $table_name) { |
|
| 743 | - $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
|
| 744 | - if (! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name) |
|
| 745 | - && $this->_get_table_analysis()->tableExists($table_name) |
|
| 746 | - ) { |
|
| 747 | - maybe_convert_table_to_utf8mb4($table_name); |
|
| 748 | - } |
|
| 749 | - } |
|
| 750 | - } |
|
| 735 | + /** |
|
| 736 | + * Runs maybe_convert_table_to_utf8mb4 on the specified tables |
|
| 737 | + * @param $tables_to_check |
|
| 738 | + * @return boolean true if logic ran, false if it didn't |
|
| 739 | + */ |
|
| 740 | + protected function _verify_db_collations_for_tables($tables_to_check) |
|
| 741 | + { |
|
| 742 | + foreach ($tables_to_check as $table_name) { |
|
| 743 | + $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
|
| 744 | + if (! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name) |
|
| 745 | + && $this->_get_table_analysis()->tableExists($table_name) |
|
| 746 | + ) { |
|
| 747 | + maybe_convert_table_to_utf8mb4($table_name); |
|
| 748 | + } |
|
| 749 | + } |
|
| 750 | + } |
|
| 751 | 751 | } |
@@ -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,67 +35,67 @@ 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.rc.000', '<') && version_compare($version_string, '4.9.0', '>=')) { |
|
| 69 | - // echo "$version_string can be migrated from"; |
|
| 70 | - return true; |
|
| 71 | - } elseif (! $version_string) { |
|
| 72 | - // echo "no version string provided: $version_string"; |
|
| 73 | - // no version string provided... this must be pre 4.3 |
|
| 74 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 75 | - } |
|
| 76 | - return false; |
|
| 77 | - } |
|
| 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.rc.000', '<') && version_compare($version_string, '4.9.0', '>=')) { |
|
| 69 | + // echo "$version_string can be migrated from"; |
|
| 70 | + return true; |
|
| 71 | + } elseif (! $version_string) { |
|
| 72 | + // echo "no version string provided: $version_string"; |
|
| 73 | + // no version string provided... this must be pre 4.3 |
|
| 74 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
| 75 | + } |
|
| 76 | + return false; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | 79 | |
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * @return bool |
|
| 83 | - */ |
|
| 84 | - public function schema_changes_before_migration() |
|
| 85 | - { |
|
| 86 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 87 | - $now_in_mysql = current_time('mysql', true); |
|
| 88 | - $table_name = 'esp_answer'; |
|
| 89 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 81 | + /** |
|
| 82 | + * @return bool |
|
| 83 | + */ |
|
| 84 | + public function schema_changes_before_migration() |
|
| 85 | + { |
|
| 86 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
| 87 | + $now_in_mysql = current_time('mysql', true); |
|
| 88 | + $table_name = 'esp_answer'; |
|
| 89 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 90 | 90 | REG_ID int(10) unsigned NOT NULL, |
| 91 | 91 | QST_ID int(10) unsigned NOT NULL, |
| 92 | 92 | ANS_value text NOT NULL, |
| 93 | 93 | PRIMARY KEY (ANS_ID), |
| 94 | 94 | KEY REG_ID (REG_ID), |
| 95 | 95 | KEY QST_ID (QST_ID)"; |
| 96 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 97 | - $table_name = 'esp_attendee_meta'; |
|
| 98 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 96 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 97 | + $table_name = 'esp_attendee_meta'; |
|
| 98 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 99 | 99 | ATT_ID bigint(20) unsigned NOT NULL, |
| 100 | 100 | ATT_fname varchar(45) NOT NULL, |
| 101 | 101 | ATT_lname varchar(45) NOT NULL, |
@@ -112,9 +112,9 @@ discard block |
||
| 112 | 112 | KEY ATT_email (ATT_email(191)), |
| 113 | 113 | KEY ATT_lname (ATT_lname), |
| 114 | 114 | KEY ATT_fname (ATT_fname)"; |
| 115 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 116 | - $table_name = 'esp_checkin'; |
|
| 117 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 115 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 116 | + $table_name = 'esp_checkin'; |
|
| 117 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 118 | 118 | REG_ID int(10) unsigned NOT NULL, |
| 119 | 119 | DTT_ID int(10) unsigned NOT NULL, |
| 120 | 120 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -122,9 +122,9 @@ discard block |
||
| 122 | 122 | PRIMARY KEY (CHK_ID), |
| 123 | 123 | KEY REG_ID (REG_ID), |
| 124 | 124 | KEY DTT_ID (DTT_ID)"; |
| 125 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 126 | - $table_name = 'esp_country'; |
|
| 127 | - $sql = "CNT_ISO varchar(2) NOT NULL, |
|
| 125 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 126 | + $table_name = 'esp_country'; |
|
| 127 | + $sql = "CNT_ISO varchar(2) NOT NULL, |
|
| 128 | 128 | CNT_ISO3 varchar(3) NOT NULL, |
| 129 | 129 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
| 130 | 130 | CNT_name varchar(45) NOT NULL, |
@@ -140,29 +140,29 @@ discard block |
||
| 140 | 140 | CNT_is_EU tinyint(1) DEFAULT '0', |
| 141 | 141 | CNT_active tinyint(1) DEFAULT '0', |
| 142 | 142 | PRIMARY KEY (CNT_ISO)"; |
| 143 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 144 | - $table_name = 'esp_currency'; |
|
| 145 | - $sql = "CUR_code varchar(6) NOT NULL, |
|
| 143 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 144 | + $table_name = 'esp_currency'; |
|
| 145 | + $sql = "CUR_code varchar(6) NOT NULL, |
|
| 146 | 146 | CUR_single varchar(45) DEFAULT 'dollar', |
| 147 | 147 | CUR_plural varchar(45) DEFAULT 'dollars', |
| 148 | 148 | CUR_sign varchar(45) DEFAULT '$', |
| 149 | 149 | CUR_dec_plc varchar(1) NOT NULL DEFAULT '2', |
| 150 | 150 | CUR_active tinyint(1) DEFAULT '0', |
| 151 | 151 | PRIMARY KEY (CUR_code)"; |
| 152 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 153 | - // note: although this table is no longer in use, |
|
| 154 | - // it hasn't been removed because then queries to the model will have errors. |
|
| 155 | - // but you should expect this table and its corresponding model to be removed in |
|
| 156 | - // the next few months |
|
| 157 | - $table_name = 'esp_currency_payment_method'; |
|
| 158 | - $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 152 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 153 | + // note: although this table is no longer in use, |
|
| 154 | + // it hasn't been removed because then queries to the model will have errors. |
|
| 155 | + // but you should expect this table and its corresponding model to be removed in |
|
| 156 | + // the next few months |
|
| 157 | + $table_name = 'esp_currency_payment_method'; |
|
| 158 | + $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 159 | 159 | CUR_code varchar(6) NOT NULL, |
| 160 | 160 | PMD_ID int(11) NOT NULL, |
| 161 | 161 | PRIMARY KEY (CPM_ID), |
| 162 | 162 | KEY PMD_ID (PMD_ID)"; |
| 163 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 164 | - $table_name = 'esp_datetime'; |
|
| 165 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 163 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 164 | + $table_name = 'esp_datetime'; |
|
| 165 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 166 | 166 | EVT_ID bigint(20) unsigned NOT NULL, |
| 167 | 167 | DTT_name varchar(255) NOT NULL DEFAULT '', |
| 168 | 168 | DTT_description text NOT NULL, |
@@ -179,25 +179,25 @@ discard block |
||
| 179 | 179 | KEY DTT_EVT_start (DTT_EVT_start), |
| 180 | 180 | KEY EVT_ID (EVT_ID), |
| 181 | 181 | KEY DTT_is_primary (DTT_is_primary)"; |
| 182 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 183 | - $table_name = "esp_datetime_ticket"; |
|
| 184 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 182 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 183 | + $table_name = "esp_datetime_ticket"; |
|
| 184 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 185 | 185 | DTT_ID int(10) unsigned NOT NULL, |
| 186 | 186 | TKT_ID int(10) unsigned NOT NULL, |
| 187 | 187 | PRIMARY KEY (DTK_ID), |
| 188 | 188 | KEY DTT_ID (DTT_ID), |
| 189 | 189 | KEY TKT_ID (TKT_ID)"; |
| 190 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 191 | - $table_name = 'esp_event_message_template'; |
|
| 192 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 190 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 191 | + $table_name = 'esp_event_message_template'; |
|
| 192 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 193 | 193 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
| 194 | 194 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
| 195 | 195 | PRIMARY KEY (EMT_ID), |
| 196 | 196 | KEY EVT_ID (EVT_ID), |
| 197 | 197 | KEY GRP_ID (GRP_ID)"; |
| 198 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 199 | - $table_name = 'esp_event_meta'; |
|
| 200 | - $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
| 198 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 199 | + $table_name = 'esp_event_meta'; |
|
| 200 | + $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
| 201 | 201 | EVT_ID bigint(20) unsigned NOT NULL, |
| 202 | 202 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
| 203 | 203 | EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -212,9 +212,9 @@ discard block |
||
| 212 | 212 | EVT_donations tinyint(1) NULL, |
| 213 | 213 | PRIMARY KEY (EVTM_ID), |
| 214 | 214 | KEY EVT_ID (EVT_ID)"; |
| 215 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 216 | - $table_name = 'esp_event_question_group'; |
|
| 217 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 215 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 216 | + $table_name = 'esp_event_question_group'; |
|
| 217 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 218 | 218 | EVT_ID bigint(20) unsigned NOT NULL, |
| 219 | 219 | QSG_ID int(10) unsigned NOT NULL, |
| 220 | 220 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
@@ -222,25 +222,25 @@ discard block |
||
| 222 | 222 | PRIMARY KEY (EQG_ID), |
| 223 | 223 | KEY EVT_ID (EVT_ID), |
| 224 | 224 | KEY QSG_ID (QSG_ID)"; |
| 225 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 226 | - $table_name = 'esp_event_venue'; |
|
| 227 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 225 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 226 | + $table_name = 'esp_event_venue'; |
|
| 227 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 228 | 228 | EVT_ID bigint(20) unsigned NOT NULL, |
| 229 | 229 | VNU_ID bigint(20) unsigned NOT NULL, |
| 230 | 230 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
| 231 | 231 | PRIMARY KEY (EVV_ID)"; |
| 232 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 233 | - $table_name = 'esp_extra_meta'; |
|
| 234 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 232 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 233 | + $table_name = 'esp_extra_meta'; |
|
| 234 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 235 | 235 | OBJ_ID int(11) DEFAULT NULL, |
| 236 | 236 | EXM_type varchar(45) DEFAULT NULL, |
| 237 | 237 | EXM_key varchar(45) DEFAULT NULL, |
| 238 | 238 | EXM_value text, |
| 239 | 239 | PRIMARY KEY (EXM_ID), |
| 240 | 240 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
| 241 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 242 | - $table_name = 'esp_extra_join'; |
|
| 243 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 241 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 242 | + $table_name = 'esp_extra_join'; |
|
| 243 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 244 | 244 | EXJ_first_model_id varchar(6) NOT NULL, |
| 245 | 245 | EXJ_first_model_name varchar(20) NOT NULL, |
| 246 | 246 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -248,9 +248,9 @@ discard block |
||
| 248 | 248 | PRIMARY KEY (EXJ_ID), |
| 249 | 249 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
| 250 | 250 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
| 251 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 252 | - $table_name = 'esp_line_item'; |
|
| 253 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 251 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 252 | + $table_name = 'esp_line_item'; |
|
| 253 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 254 | 254 | LIN_code varchar(245) NOT NULL DEFAULT '', |
| 255 | 255 | TXN_ID int(11) DEFAULT NULL, |
| 256 | 256 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -271,9 +271,9 @@ discard block |
||
| 271 | 271 | KEY txn_type_timestamp (TXN_ID,LIN_type,LIN_timestamp), |
| 272 | 272 | KEY txn_obj_id_obj_type (TXN_ID,OBJ_ID,OBJ_type), |
| 273 | 273 | KEY obj_id_obj_type (OBJ_ID,OBJ_type)"; |
| 274 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 275 | - $table_name = 'esp_log'; |
|
| 276 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 274 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 275 | + $table_name = 'esp_log'; |
|
| 276 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 277 | 277 | LOG_time datetime DEFAULT NULL, |
| 278 | 278 | OBJ_ID varchar(45) DEFAULT NULL, |
| 279 | 279 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -284,9 +284,9 @@ discard block |
||
| 284 | 284 | KEY LOG_time (LOG_time), |
| 285 | 285 | KEY OBJ (OBJ_type,OBJ_ID), |
| 286 | 286 | KEY LOG_type (LOG_type)"; |
| 287 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 288 | - $table_name = 'esp_message'; |
|
| 289 | - $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 287 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 288 | + $table_name = 'esp_message'; |
|
| 289 | + $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
| 290 | 290 | GRP_ID int(10) unsigned NULL, |
| 291 | 291 | MSG_token varchar(255) NULL, |
| 292 | 292 | TXN_ID int(10) unsigned NULL, |
@@ -318,18 +318,18 @@ discard block |
||
| 318 | 318 | KEY STS_ID (STS_ID), |
| 319 | 319 | KEY MSG_created (MSG_created), |
| 320 | 320 | KEY MSG_modified (MSG_modified)"; |
| 321 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 322 | - $table_name = 'esp_message_template'; |
|
| 323 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 321 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 322 | + $table_name = 'esp_message_template'; |
|
| 323 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 324 | 324 | GRP_ID int(10) unsigned NOT NULL, |
| 325 | 325 | MTP_context varchar(50) NOT NULL, |
| 326 | 326 | MTP_template_field varchar(30) NOT NULL, |
| 327 | 327 | MTP_content text NOT NULL, |
| 328 | 328 | PRIMARY KEY (MTP_ID), |
| 329 | 329 | KEY GRP_ID (GRP_ID)"; |
| 330 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 331 | - $table_name = 'esp_message_template_group'; |
|
| 332 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 330 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 331 | + $table_name = 'esp_message_template_group'; |
|
| 332 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 333 | 333 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
| 334 | 334 | MTP_name varchar(245) NOT NULL DEFAULT '', |
| 335 | 335 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -341,9 +341,9 @@ discard block |
||
| 341 | 341 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
| 342 | 342 | PRIMARY KEY (GRP_ID), |
| 343 | 343 | KEY MTP_user_id (MTP_user_id)"; |
| 344 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 345 | - $table_name = 'esp_payment'; |
|
| 346 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 344 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 345 | + $table_name = 'esp_payment'; |
|
| 346 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 347 | 347 | TXN_ID int(10) unsigned DEFAULT NULL, |
| 348 | 348 | STS_ID varchar(3) DEFAULT NULL, |
| 349 | 349 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -360,9 +360,9 @@ discard block |
||
| 360 | 360 | PRIMARY KEY (PAY_ID), |
| 361 | 361 | KEY PAY_timestamp (PAY_timestamp), |
| 362 | 362 | KEY TXN_ID (TXN_ID)"; |
| 363 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 364 | - $table_name = 'esp_payment_method'; |
|
| 365 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 363 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 364 | + $table_name = 'esp_payment_method'; |
|
| 365 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 366 | 366 | PMD_type varchar(124) DEFAULT NULL, |
| 367 | 367 | PMD_name varchar(255) DEFAULT NULL, |
| 368 | 368 | PMD_desc text, |
@@ -378,24 +378,24 @@ discard block |
||
| 378 | 378 | PRIMARY KEY (PMD_ID), |
| 379 | 379 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
| 380 | 380 | KEY PMD_type (PMD_type)"; |
| 381 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 382 | - $table_name = "esp_ticket_price"; |
|
| 383 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 381 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 382 | + $table_name = "esp_ticket_price"; |
|
| 383 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 384 | 384 | TKT_ID int(10) unsigned NOT NULL, |
| 385 | 385 | PRC_ID int(10) unsigned NOT NULL, |
| 386 | 386 | PRIMARY KEY (TKP_ID), |
| 387 | 387 | KEY TKT_ID (TKT_ID), |
| 388 | 388 | KEY PRC_ID (PRC_ID)"; |
| 389 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 390 | - $table_name = "esp_ticket_template"; |
|
| 391 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 389 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 390 | + $table_name = "esp_ticket_template"; |
|
| 391 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 392 | 392 | TTM_name varchar(45) NOT NULL, |
| 393 | 393 | TTM_description text, |
| 394 | 394 | TTM_file varchar(45), |
| 395 | 395 | PRIMARY KEY (TTM_ID)"; |
| 396 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 397 | - $table_name = 'esp_question'; |
|
| 398 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 396 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 397 | + $table_name = 'esp_question'; |
|
| 398 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 399 | 399 | QST_display_text text NOT NULL, |
| 400 | 400 | QST_admin_label varchar(255) NOT NULL, |
| 401 | 401 | QST_system varchar(25) DEFAULT NULL, |
@@ -409,18 +409,18 @@ discard block |
||
| 409 | 409 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
| 410 | 410 | PRIMARY KEY (QST_ID), |
| 411 | 411 | KEY QST_order (QST_order)'; |
| 412 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 413 | - $table_name = 'esp_question_group_question'; |
|
| 414 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 412 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 413 | + $table_name = 'esp_question_group_question'; |
|
| 414 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 415 | 415 | QSG_ID int(10) unsigned NOT NULL, |
| 416 | 416 | QST_ID int(10) unsigned NOT NULL, |
| 417 | 417 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
| 418 | 418 | PRIMARY KEY (QGQ_ID), |
| 419 | 419 | KEY QST_ID (QST_ID), |
| 420 | 420 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
| 421 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 422 | - $table_name = 'esp_question_option'; |
|
| 423 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 421 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 422 | + $table_name = 'esp_question_option'; |
|
| 423 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 424 | 424 | QSO_value varchar(255) NOT NULL, |
| 425 | 425 | QSO_desc text NOT NULL, |
| 426 | 426 | QST_ID int(10) unsigned NOT NULL, |
@@ -430,9 +430,9 @@ discard block |
||
| 430 | 430 | PRIMARY KEY (QSO_ID), |
| 431 | 431 | KEY QST_ID (QST_ID), |
| 432 | 432 | KEY QSO_order (QSO_order)"; |
| 433 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 434 | - $table_name = 'esp_registration'; |
|
| 435 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 433 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 434 | + $table_name = 'esp_registration'; |
|
| 435 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 436 | 436 | EVT_ID bigint(20) unsigned NOT NULL, |
| 437 | 437 | ATT_ID bigint(20) unsigned NOT NULL, |
| 438 | 438 | TXN_ID int(10) unsigned NOT NULL, |
@@ -456,18 +456,18 @@ discard block |
||
| 456 | 456 | KEY TKT_ID (TKT_ID), |
| 457 | 457 | KEY EVT_ID (EVT_ID), |
| 458 | 458 | KEY STS_ID (STS_ID)"; |
| 459 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 460 | - $table_name = 'esp_registration_payment'; |
|
| 461 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 459 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 460 | + $table_name = 'esp_registration_payment'; |
|
| 461 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 462 | 462 | REG_ID int(10) unsigned NOT NULL, |
| 463 | 463 | PAY_ID int(10) unsigned NULL, |
| 464 | 464 | RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
| 465 | 465 | PRIMARY KEY (RPY_ID), |
| 466 | 466 | KEY REG_ID (REG_ID), |
| 467 | 467 | KEY PAY_ID (PAY_ID)"; |
| 468 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 469 | - $table_name = 'esp_state'; |
|
| 470 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
| 468 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 469 | + $table_name = 'esp_state'; |
|
| 470 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
| 471 | 471 | CNT_ISO varchar(2) NOT NULL, |
| 472 | 472 | STA_abbrev varchar(24) NOT NULL, |
| 473 | 473 | STA_name varchar(100) NOT NULL, |
@@ -475,9 +475,9 @@ discard block |
||
| 475 | 475 | PRIMARY KEY (STA_ID), |
| 476 | 476 | KEY STA_abbrev (STA_abbrev), |
| 477 | 477 | KEY CNT_ISO (CNT_ISO)"; |
| 478 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 479 | - $table_name = 'esp_status'; |
|
| 480 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
| 478 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 479 | + $table_name = 'esp_status'; |
|
| 480 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
| 481 | 481 | STS_code varchar(45) NOT NULL, |
| 482 | 482 | STS_type varchar(45) NOT NULL, |
| 483 | 483 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -485,9 +485,9 @@ discard block |
||
| 485 | 485 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
| 486 | 486 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
| 487 | 487 | KEY STS_type (STS_type)"; |
| 488 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 489 | - $table_name = 'esp_transaction'; |
|
| 490 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 488 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 489 | + $table_name = 'esp_transaction'; |
|
| 490 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 491 | 491 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
| 492 | 492 | TXN_total decimal(12,3) DEFAULT '0.00', |
| 493 | 493 | TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00', |
@@ -499,9 +499,9 @@ discard block |
||
| 499 | 499 | PRIMARY KEY (TXN_ID), |
| 500 | 500 | KEY TXN_timestamp (TXN_timestamp), |
| 501 | 501 | KEY STS_ID (STS_ID)"; |
| 502 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 503 | - $table_name = 'esp_venue_meta'; |
|
| 504 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 502 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 503 | + $table_name = 'esp_venue_meta'; |
|
| 504 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
| 505 | 505 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
| 506 | 506 | VNU_address varchar(255) DEFAULT NULL, |
| 507 | 507 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -520,10 +520,10 @@ discard block |
||
| 520 | 520 | KEY VNU_ID (VNU_ID), |
| 521 | 521 | KEY STA_ID (STA_ID), |
| 522 | 522 | KEY CNT_ISO (CNT_ISO)"; |
| 523 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 524 | - // modified tables |
|
| 525 | - $table_name = "esp_price"; |
|
| 526 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 523 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 524 | + // modified tables |
|
| 525 | + $table_name = "esp_price"; |
|
| 526 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 527 | 527 | PRT_ID tinyint(3) unsigned NOT NULL, |
| 528 | 528 | PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
| 529 | 529 | PRC_name varchar(245) NOT NULL, |
@@ -536,9 +536,9 @@ discard block |
||
| 536 | 536 | PRC_parent int(10) unsigned DEFAULT 0, |
| 537 | 537 | PRIMARY KEY (PRC_ID), |
| 538 | 538 | KEY PRT_ID (PRT_ID)"; |
| 539 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 540 | - $table_name = "esp_price_type"; |
|
| 541 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
| 539 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 540 | + $table_name = "esp_price_type"; |
|
| 541 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
| 542 | 542 | PRT_name varchar(45) NOT NULL, |
| 543 | 543 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
| 544 | 544 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -547,9 +547,9 @@ discard block |
||
| 547 | 547 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
| 548 | 548 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
| 549 | 549 | PRIMARY KEY (PRT_ID)"; |
| 550 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 551 | - $table_name = "esp_ticket"; |
|
| 552 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 550 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
| 551 | + $table_name = "esp_ticket"; |
|
| 552 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 553 | 553 | TTM_ID int(10) unsigned NOT NULL, |
| 554 | 554 | TKT_name varchar(245) NOT NULL DEFAULT '', |
| 555 | 555 | TKT_description text NOT NULL, |
@@ -572,9 +572,9 @@ discard block |
||
| 572 | 572 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
| 573 | 573 | PRIMARY KEY (TKT_ID), |
| 574 | 574 | KEY TKT_start_date (TKT_start_date)"; |
| 575 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 576 | - $table_name = 'esp_question_group'; |
|
| 577 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 575 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 576 | + $table_name = 'esp_question_group'; |
|
| 577 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
| 578 | 578 | QSG_name varchar(255) NOT NULL, |
| 579 | 579 | QSG_identifier varchar(100) NOT NULL, |
| 580 | 580 | QSG_desc text NULL, |
@@ -587,38 +587,38 @@ discard block |
||
| 587 | 587 | PRIMARY KEY (QSG_ID), |
| 588 | 588 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
| 589 | 589 | KEY QSG_order (QSG_order)'; |
| 590 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 591 | - $this->insert_default_data(); |
|
| 592 | - return true; |
|
| 593 | - } |
|
| 590 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
| 591 | + $this->insert_default_data(); |
|
| 592 | + return true; |
|
| 593 | + } |
|
| 594 | 594 | |
| 595 | - /** |
|
| 596 | - * Inserts default data on new installs |
|
| 597 | - * @since 4.10.0.p |
|
| 598 | - * @throws EE_Error |
|
| 599 | - * @throws InvalidArgumentException |
|
| 600 | - * @throws ReflectionException |
|
| 601 | - * @throws InvalidDataTypeException |
|
| 602 | - * @throws InvalidInterfaceException |
|
| 603 | - */ |
|
| 604 | - public function insert_default_data() |
|
| 605 | - { |
|
| 606 | - $this->previous_dms->insert_default_data(); |
|
| 607 | - } |
|
| 595 | + /** |
|
| 596 | + * Inserts default data on new installs |
|
| 597 | + * @since 4.10.0.p |
|
| 598 | + * @throws EE_Error |
|
| 599 | + * @throws InvalidArgumentException |
|
| 600 | + * @throws ReflectionException |
|
| 601 | + * @throws InvalidDataTypeException |
|
| 602 | + * @throws InvalidInterfaceException |
|
| 603 | + */ |
|
| 604 | + public function insert_default_data() |
|
| 605 | + { |
|
| 606 | + $this->previous_dms->insert_default_data(); |
|
| 607 | + } |
|
| 608 | 608 | |
| 609 | 609 | |
| 610 | 610 | |
| 611 | - /** |
|
| 612 | - * @return boolean |
|
| 613 | - */ |
|
| 614 | - public function schema_changes_after_migration() |
|
| 615 | - { |
|
| 616 | - return true; |
|
| 617 | - } |
|
| 611 | + /** |
|
| 612 | + * @return boolean |
|
| 613 | + */ |
|
| 614 | + public function schema_changes_after_migration() |
|
| 615 | + { |
|
| 616 | + return true; |
|
| 617 | + } |
|
| 618 | 618 | |
| 619 | 619 | |
| 620 | 620 | |
| 621 | - public function migration_page_hooks() |
|
| 622 | - { |
|
| 623 | - } |
|
| 621 | + public function migration_page_hooks() |
|
| 622 | + { |
|
| 623 | + } |
|
| 624 | 624 | } |
@@ -18,184 +18,184 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class EE_Registration_Custom_Questions_Form extends EE_Form_Section_Proper |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * |
|
| 23 | - * @var EE_Registration |
|
| 24 | - */ |
|
| 25 | - protected $_registration = null; |
|
| 21 | + /** |
|
| 22 | + * |
|
| 23 | + * @var EE_Registration |
|
| 24 | + */ |
|
| 25 | + protected $_registration = null; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * |
|
| 29 | - * @param EE_Registration $reg |
|
| 30 | - * @param array $options |
|
| 31 | - */ |
|
| 32 | - public function __construct(EE_Registration $reg, $options = array()) |
|
| 33 | - { |
|
| 34 | - $this->_registration = $reg; |
|
| 35 | - if (! isset($options['layout_strategy'])) { |
|
| 36 | - $options['layout_strategy'] = new EE_Admin_Two_Column_Layout(); |
|
| 37 | - } |
|
| 38 | - if (! isset($options['html_id'])) { |
|
| 39 | - $options['html_id'] = 'reg-admin-attendee-questions-frm'; |
|
| 40 | - } |
|
| 41 | - $this->build_form_from_registration(); |
|
| 42 | - parent::__construct($options); |
|
| 43 | - } |
|
| 27 | + /** |
|
| 28 | + * |
|
| 29 | + * @param EE_Registration $reg |
|
| 30 | + * @param array $options |
|
| 31 | + */ |
|
| 32 | + public function __construct(EE_Registration $reg, $options = array()) |
|
| 33 | + { |
|
| 34 | + $this->_registration = $reg; |
|
| 35 | + if (! isset($options['layout_strategy'])) { |
|
| 36 | + $options['layout_strategy'] = new EE_Admin_Two_Column_Layout(); |
|
| 37 | + } |
|
| 38 | + if (! isset($options['html_id'])) { |
|
| 39 | + $options['html_id'] = 'reg-admin-attendee-questions-frm'; |
|
| 40 | + } |
|
| 41 | + $this->build_form_from_registration(); |
|
| 42 | + parent::__construct($options); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Gets the registration object this form is about |
|
| 48 | - * @return EE_Registration |
|
| 49 | - */ |
|
| 50 | - public function get_registration() |
|
| 51 | - { |
|
| 52 | - return $this->_registration; |
|
| 53 | - } |
|
| 46 | + /** |
|
| 47 | + * Gets the registration object this form is about |
|
| 48 | + * @return EE_Registration |
|
| 49 | + */ |
|
| 50 | + public function get_registration() |
|
| 51 | + { |
|
| 52 | + return $this->_registration; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * @since 4.10.0.p |
|
| 57 | - * @throws EE_Error |
|
| 58 | - * @throws InvalidArgumentException |
|
| 59 | - * @throws ReflectionException |
|
| 60 | - * @throws InvalidDataTypeException |
|
| 61 | - * @throws InvalidInterfaceException |
|
| 62 | - */ |
|
| 63 | - public function build_form_from_registration() |
|
| 64 | - { |
|
| 65 | - $reg = $this->get_registration(); |
|
| 66 | - if (! $reg instanceof EE_Registration) { |
|
| 67 | - throw new EE_Error(__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso')); |
|
| 68 | - } |
|
| 69 | - // we want to get all their question groups |
|
| 70 | - $question_groups = EEM_Question_Group::instance()->get_all( |
|
| 71 | - [ |
|
| 72 | - [ |
|
| 73 | - 'Event_Question_Group.EVT_ID' => $reg->event_ID(), |
|
| 74 | - 'OR' => [ |
|
| 75 | - 'Question.QST_system*blank' => '', |
|
| 76 | - 'Question.QST_system*null' => ['IS_NULL'] |
|
| 77 | - ], |
|
| 78 | - 'Event_Question_Group.' |
|
| 79 | - . EEM_Event_Question_Group::instance()->fieldNameForContext( |
|
| 80 | - $reg->is_primary_registrant() |
|
| 81 | - ) => true |
|
| 82 | - ], |
|
| 83 | - 'order_by' => ['QSG_order' => 'ASC'] |
|
| 84 | - ] |
|
| 85 | - ); |
|
| 86 | - // get each question groups questions |
|
| 87 | - foreach ($question_groups as $question_group) { |
|
| 88 | - if ($question_group instanceof EE_Question_Group) { |
|
| 89 | - $this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group( |
|
| 90 | - $question_group, |
|
| 91 | - $reg |
|
| 92 | - ); |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - } |
|
| 55 | + /** |
|
| 56 | + * @since 4.10.0.p |
|
| 57 | + * @throws EE_Error |
|
| 58 | + * @throws InvalidArgumentException |
|
| 59 | + * @throws ReflectionException |
|
| 60 | + * @throws InvalidDataTypeException |
|
| 61 | + * @throws InvalidInterfaceException |
|
| 62 | + */ |
|
| 63 | + public function build_form_from_registration() |
|
| 64 | + { |
|
| 65 | + $reg = $this->get_registration(); |
|
| 66 | + if (! $reg instanceof EE_Registration) { |
|
| 67 | + throw new EE_Error(__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso')); |
|
| 68 | + } |
|
| 69 | + // we want to get all their question groups |
|
| 70 | + $question_groups = EEM_Question_Group::instance()->get_all( |
|
| 71 | + [ |
|
| 72 | + [ |
|
| 73 | + 'Event_Question_Group.EVT_ID' => $reg->event_ID(), |
|
| 74 | + 'OR' => [ |
|
| 75 | + 'Question.QST_system*blank' => '', |
|
| 76 | + 'Question.QST_system*null' => ['IS_NULL'] |
|
| 77 | + ], |
|
| 78 | + 'Event_Question_Group.' |
|
| 79 | + . EEM_Event_Question_Group::instance()->fieldNameForContext( |
|
| 80 | + $reg->is_primary_registrant() |
|
| 81 | + ) => true |
|
| 82 | + ], |
|
| 83 | + 'order_by' => ['QSG_order' => 'ASC'] |
|
| 84 | + ] |
|
| 85 | + ); |
|
| 86 | + // get each question groups questions |
|
| 87 | + foreach ($question_groups as $question_group) { |
|
| 88 | + if ($question_group instanceof EE_Question_Group) { |
|
| 89 | + $this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group( |
|
| 90 | + $question_group, |
|
| 91 | + $reg |
|
| 92 | + ); |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | 97 | |
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * |
|
| 101 | - * @param EE_Question_Group $question_group |
|
| 102 | - * @param EE_Registration $registration |
|
| 103 | - * @return \EE_Form_Section_Proper |
|
| 104 | - * @throws \EE_Error |
|
| 105 | - */ |
|
| 106 | - public function build_subform_from_question_group($question_group, $registration) |
|
| 107 | - { |
|
| 108 | - if (! $question_group instanceof EE_Question_Group || |
|
| 109 | - ! $registration instanceof EE_Registration) { |
|
| 110 | - throw new EE_Error(__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso')); |
|
| 111 | - } |
|
| 112 | - $parts_of_subsection = array( |
|
| 113 | - 'title' => new EE_Form_Section_HTML( |
|
| 114 | - EEH_HTML::h5( |
|
| 115 | - $question_group->name(), |
|
| 116 | - $question_group->identifier(), |
|
| 117 | - 'espresso-question-group-title-h5 section-title' |
|
| 118 | - ) |
|
| 119 | - ) |
|
| 120 | - ); |
|
| 121 | - $questions = $question_group->questions( |
|
| 122 | - array( |
|
| 123 | - array( |
|
| 124 | - 'OR' => array( |
|
| 125 | - 'QST_system*blank' => '', |
|
| 126 | - 'QST_system*null' => array( 'IS_NULL' ) |
|
| 127 | - ) |
|
| 128 | - ) |
|
| 129 | - ) |
|
| 130 | - ); |
|
| 131 | - foreach ($questions as $question) { |
|
| 132 | - $parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration); |
|
| 133 | - } |
|
| 134 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 135 | - 'ee_edit_registration', |
|
| 136 | - 'edit-reg-questions-mbox', |
|
| 137 | - $this->_registration->ID() |
|
| 138 | - )) { |
|
| 139 | - $parts_of_subsection['edit_link'] = new EE_Form_Section_HTML( |
|
| 140 | - EEH_HTML::table( |
|
| 141 | - EEH_HTML::tr( |
|
| 142 | - '<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="' . esc_attr__('click to edit question', 'event_espresso') . '"> |
|
| 99 | + /** |
|
| 100 | + * |
|
| 101 | + * @param EE_Question_Group $question_group |
|
| 102 | + * @param EE_Registration $registration |
|
| 103 | + * @return \EE_Form_Section_Proper |
|
| 104 | + * @throws \EE_Error |
|
| 105 | + */ |
|
| 106 | + public function build_subform_from_question_group($question_group, $registration) |
|
| 107 | + { |
|
| 108 | + if (! $question_group instanceof EE_Question_Group || |
|
| 109 | + ! $registration instanceof EE_Registration) { |
|
| 110 | + throw new EE_Error(__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso')); |
|
| 111 | + } |
|
| 112 | + $parts_of_subsection = array( |
|
| 113 | + 'title' => new EE_Form_Section_HTML( |
|
| 114 | + EEH_HTML::h5( |
|
| 115 | + $question_group->name(), |
|
| 116 | + $question_group->identifier(), |
|
| 117 | + 'espresso-question-group-title-h5 section-title' |
|
| 118 | + ) |
|
| 119 | + ) |
|
| 120 | + ); |
|
| 121 | + $questions = $question_group->questions( |
|
| 122 | + array( |
|
| 123 | + array( |
|
| 124 | + 'OR' => array( |
|
| 125 | + 'QST_system*blank' => '', |
|
| 126 | + 'QST_system*null' => array( 'IS_NULL' ) |
|
| 127 | + ) |
|
| 128 | + ) |
|
| 129 | + ) |
|
| 130 | + ); |
|
| 131 | + foreach ($questions as $question) { |
|
| 132 | + $parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration); |
|
| 133 | + } |
|
| 134 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 135 | + 'ee_edit_registration', |
|
| 136 | + 'edit-reg-questions-mbox', |
|
| 137 | + $this->_registration->ID() |
|
| 138 | + )) { |
|
| 139 | + $parts_of_subsection['edit_link'] = new EE_Form_Section_HTML( |
|
| 140 | + EEH_HTML::table( |
|
| 141 | + EEH_HTML::tr( |
|
| 142 | + '<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="' . esc_attr__('click to edit question', 'event_espresso') . '"> |
|
| 143 | 143 | <span class="reg-admin-edit-question-group-spn">' . __('edit the above question group', 'event_espresso') . '</span> |
| 144 | 144 | <div class="dashicons dashicons-edit"></div> |
| 145 | 145 | </a></td>' |
| 146 | - ) . |
|
| 147 | - EEH_HTML::no_row('', 2) |
|
| 148 | - ) |
|
| 149 | - ); |
|
| 150 | - } |
|
| 151 | - return new EE_Form_Section_Proper( |
|
| 152 | - array( |
|
| 153 | - 'subsections' => $parts_of_subsection, |
|
| 154 | - 'html_class' => 'question-group-questions', |
|
| 155 | - ) |
|
| 156 | - ); |
|
| 157 | - } |
|
| 146 | + ) . |
|
| 147 | + EEH_HTML::no_row('', 2) |
|
| 148 | + ) |
|
| 149 | + ); |
|
| 150 | + } |
|
| 151 | + return new EE_Form_Section_Proper( |
|
| 152 | + array( |
|
| 153 | + 'subsections' => $parts_of_subsection, |
|
| 154 | + 'html_class' => 'question-group-questions', |
|
| 155 | + ) |
|
| 156 | + ); |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - /** |
|
| 160 | - * Overrides parent so if inputs were disabled, we leave those with their defaults |
|
| 161 | - * from the answers in the DB |
|
| 162 | - * @param array $req_data like $_POST |
|
| 163 | - * @return void |
|
| 164 | - */ |
|
| 165 | - protected function _normalize($req_data) |
|
| 166 | - { |
|
| 167 | - $this->_received_submission = true; |
|
| 168 | - $this->_validation_errors = array(); |
|
| 169 | - foreach ($this->get_validatable_subsections() as $subsection) { |
|
| 170 | - if ($subsection->form_data_present_in($req_data)) { |
|
| 171 | - try { |
|
| 172 | - $subsection->_normalize($req_data); |
|
| 173 | - } catch (EE_Validation_Error $e) { |
|
| 174 | - $subsection->add_validation_error($e); |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - } |
|
| 159 | + /** |
|
| 160 | + * Overrides parent so if inputs were disabled, we leave those with their defaults |
|
| 161 | + * from the answers in the DB |
|
| 162 | + * @param array $req_data like $_POST |
|
| 163 | + * @return void |
|
| 164 | + */ |
|
| 165 | + protected function _normalize($req_data) |
|
| 166 | + { |
|
| 167 | + $this->_received_submission = true; |
|
| 168 | + $this->_validation_errors = array(); |
|
| 169 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
| 170 | + if ($subsection->form_data_present_in($req_data)) { |
|
| 171 | + try { |
|
| 172 | + $subsection->_normalize($req_data); |
|
| 173 | + } catch (EE_Validation_Error $e) { |
|
| 174 | + $subsection->add_validation_error($e); |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | 180 | |
| 181 | 181 | |
| 182 | - /** |
|
| 183 | - * Performs validation on this form section and its subsections. For each subsection, |
|
| 184 | - * calls _validate_{subsection_name} on THIS form (if the function exists) and passes it the subsection, then calls _validate on that subsection. |
|
| 185 | - * If you need to perform validation on the form as a whole (considering multiple) you would be best to override this _validate method, |
|
| 186 | - * calling parent::_validate() first. |
|
| 187 | - */ |
|
| 188 | - protected function _validate() |
|
| 189 | - { |
|
| 190 | - foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
| 191 | - if ($subsection->form_data_present_in(array_merge($_GET, $_POST))) { |
|
| 192 | - if (method_exists($this, '_validate_'.$subsection_name)) { |
|
| 193 | - call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection)); |
|
| 194 | - } |
|
| 195 | - $subsection->_validate(); |
|
| 196 | - } elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
| 197 | - $subsection->_received_submission = true; |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - } |
|
| 182 | + /** |
|
| 183 | + * Performs validation on this form section and its subsections. For each subsection, |
|
| 184 | + * calls _validate_{subsection_name} on THIS form (if the function exists) and passes it the subsection, then calls _validate on that subsection. |
|
| 185 | + * If you need to perform validation on the form as a whole (considering multiple) you would be best to override this _validate method, |
|
| 186 | + * calling parent::_validate() first. |
|
| 187 | + */ |
|
| 188 | + protected function _validate() |
|
| 189 | + { |
|
| 190 | + foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
| 191 | + if ($subsection->form_data_present_in(array_merge($_GET, $_POST))) { |
|
| 192 | + if (method_exists($this, '_validate_'.$subsection_name)) { |
|
| 193 | + call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection)); |
|
| 194 | + } |
|
| 195 | + $subsection->_validate(); |
|
| 196 | + } elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
| 197 | + $subsection->_received_submission = true; |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | 201 | } |
@@ -38,103 +38,103 @@ |
||
| 38 | 38 | * @since 4.0 |
| 39 | 39 | */ |
| 40 | 40 | if (function_exists('espresso_version')) { |
| 41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
| 42 | - /** |
|
| 43 | - * espresso_duplicate_plugin_error |
|
| 44 | - * displays if more than one version of EE is activated at the same time |
|
| 45 | - */ |
|
| 46 | - function espresso_duplicate_plugin_error() |
|
| 47 | - { |
|
| 48 | - ?> |
|
| 41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
| 42 | + /** |
|
| 43 | + * espresso_duplicate_plugin_error |
|
| 44 | + * displays if more than one version of EE is activated at the same time |
|
| 45 | + */ |
|
| 46 | + function espresso_duplicate_plugin_error() |
|
| 47 | + { |
|
| 48 | + ?> |
|
| 49 | 49 | <div class="error"> |
| 50 | 50 | <p> |
| 51 | 51 | <?php |
| 52 | - echo esc_html__( |
|
| 53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | - 'event_espresso' |
|
| 55 | - ); ?> |
|
| 52 | + echo esc_html__( |
|
| 53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | + 'event_espresso' |
|
| 55 | + ); ?> |
|
| 56 | 56 | </p> |
| 57 | 57 | </div> |
| 58 | 58 | <?php |
| 59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 63 | 63 | } else { |
| 64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
| 65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | - /** |
|
| 67 | - * espresso_minimum_php_version_error |
|
| 68 | - * |
|
| 69 | - * @return void |
|
| 70 | - */ |
|
| 71 | - function espresso_minimum_php_version_error() |
|
| 72 | - { |
|
| 73 | - ?> |
|
| 64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
| 65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | + /** |
|
| 67 | + * espresso_minimum_php_version_error |
|
| 68 | + * |
|
| 69 | + * @return void |
|
| 70 | + */ |
|
| 71 | + function espresso_minimum_php_version_error() |
|
| 72 | + { |
|
| 73 | + ?> |
|
| 74 | 74 | <div class="error"> |
| 75 | 75 | <p> |
| 76 | 76 | <?php |
| 77 | - printf( |
|
| 78 | - esc_html__( |
|
| 79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | - 'event_espresso' |
|
| 81 | - ), |
|
| 82 | - EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | - PHP_VERSION, |
|
| 84 | - '<br/>', |
|
| 85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | - ); |
|
| 87 | - ?> |
|
| 77 | + printf( |
|
| 78 | + esc_html__( |
|
| 79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | + 'event_espresso' |
|
| 81 | + ), |
|
| 82 | + EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | + PHP_VERSION, |
|
| 84 | + '<br/>', |
|
| 85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | + ); |
|
| 87 | + ?> |
|
| 88 | 88 | </p> |
| 89 | 89 | </div> |
| 90 | 90 | <?php |
| 91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | - } |
|
| 91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | - } else { |
|
| 96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 97 | - /** |
|
| 98 | - * espresso_version |
|
| 99 | - * Returns the plugin version |
|
| 100 | - * |
|
| 101 | - * @return string |
|
| 102 | - */ |
|
| 103 | - function espresso_version() |
|
| 104 | - { |
|
| 105 | - return apply_filters('FHEE__espresso__espresso_version', '4.10.1.rc.001'); |
|
| 106 | - } |
|
| 94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | + } else { |
|
| 96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 97 | + /** |
|
| 98 | + * espresso_version |
|
| 99 | + * Returns the plugin version |
|
| 100 | + * |
|
| 101 | + * @return string |
|
| 102 | + */ |
|
| 103 | + function espresso_version() |
|
| 104 | + { |
|
| 105 | + return apply_filters('FHEE__espresso__espresso_version', '4.10.1.rc.001'); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * espresso_plugin_activation |
|
| 110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 111 | - */ |
|
| 112 | - function espresso_plugin_activation() |
|
| 113 | - { |
|
| 114 | - update_option('ee_espresso_activation', true); |
|
| 115 | - } |
|
| 108 | + /** |
|
| 109 | + * espresso_plugin_activation |
|
| 110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 111 | + */ |
|
| 112 | + function espresso_plugin_activation() |
|
| 113 | + { |
|
| 114 | + update_option('ee_espresso_activation', true); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 118 | 118 | |
| 119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
| 120 | - bootstrap_espresso(); |
|
| 121 | - } |
|
| 119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
| 120 | + bootstrap_espresso(); |
|
| 121 | + } |
|
| 122 | 122 | } |
| 123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
| 124 | - /** |
|
| 125 | - * deactivate_plugin |
|
| 126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 127 | - * |
|
| 128 | - * @access public |
|
| 129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 130 | - * @return void |
|
| 131 | - */ |
|
| 132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
| 133 | - { |
|
| 134 | - if (! function_exists('deactivate_plugins')) { |
|
| 135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 136 | - } |
|
| 137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
| 138 | - deactivate_plugins($plugin_basename); |
|
| 139 | - } |
|
| 124 | + /** |
|
| 125 | + * deactivate_plugin |
|
| 126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 127 | + * |
|
| 128 | + * @access public |
|
| 129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 130 | + * @return void |
|
| 131 | + */ |
|
| 132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
| 133 | + { |
|
| 134 | + if (! function_exists('deactivate_plugins')) { |
|
| 135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 136 | + } |
|
| 137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
| 138 | + deactivate_plugins($plugin_basename); |
|
| 139 | + } |
|
| 140 | 140 | } |