@@ -6,23 +6,23 @@ |
||
| 6 | 6 | class EE_Question_Group_Question extends EE_Base_Class |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - /** |
|
| 10 | - * @param array $props_n_values |
|
| 11 | - * @return EE_Question_Group_Question|mixed |
|
| 12 | - */ |
|
| 13 | - public static function new_instance($props_n_values = array()) |
|
| 14 | - { |
|
| 15 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
| 16 | - return $has_object ? $has_object : new self($props_n_values); |
|
| 17 | - } |
|
| 9 | + /** |
|
| 10 | + * @param array $props_n_values |
|
| 11 | + * @return EE_Question_Group_Question|mixed |
|
| 12 | + */ |
|
| 13 | + public static function new_instance($props_n_values = array()) |
|
| 14 | + { |
|
| 15 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
| 16 | + return $has_object ? $has_object : new self($props_n_values); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @param array $props_n_values |
|
| 22 | - * @return EE_Question_Group_Question |
|
| 23 | - */ |
|
| 24 | - public static function new_instance_from_db($props_n_values = array()) |
|
| 25 | - { |
|
| 26 | - return new self($props_n_values, true); |
|
| 27 | - } |
|
| 20 | + /** |
|
| 21 | + * @param array $props_n_values |
|
| 22 | + * @return EE_Question_Group_Question |
|
| 23 | + */ |
|
| 24 | + public static function new_instance_from_db($props_n_values = array()) |
|
| 25 | + { |
|
| 26 | + return new self($props_n_values, true); |
|
| 27 | + } |
|
| 28 | 28 | } |
@@ -11,104 +11,104 @@ |
||
| 11 | 11 | class EE_State extends EE_Base_Class |
| 12 | 12 | { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * @param array $props_n_values |
|
| 16 | - * @return EE_State|mixed |
|
| 17 | - */ |
|
| 18 | - public static function new_instance($props_n_values = array()) |
|
| 19 | - { |
|
| 20 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
| 21 | - return $has_object ? $has_object : new self($props_n_values); |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * @param array $props_n_values |
|
| 27 | - * @return EE_State |
|
| 28 | - */ |
|
| 29 | - public static function new_instance_from_db($props_n_values = array()) |
|
| 30 | - { |
|
| 31 | - return new self($props_n_values, true); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @return string |
|
| 37 | - */ |
|
| 38 | - public function country_iso() |
|
| 39 | - { |
|
| 40 | - return $this->get('CNT_ISO'); |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @return string |
|
| 46 | - */ |
|
| 47 | - public function abbrev() |
|
| 48 | - { |
|
| 49 | - return $this->get('STA_abbrev'); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @return bool |
|
| 55 | - */ |
|
| 56 | - public function active() |
|
| 57 | - { |
|
| 58 | - return $this->get('STA_active'); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * @return string |
|
| 64 | - */ |
|
| 65 | - public function name() |
|
| 66 | - { |
|
| 67 | - return $this->get('STA_name'); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * @return EE_Country |
|
| 73 | - */ |
|
| 74 | - public function country() |
|
| 75 | - { |
|
| 76 | - return $this->get_first_related('Country'); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * @param $iso |
|
| 82 | - */ |
|
| 83 | - public function set_country_iso($iso) |
|
| 84 | - { |
|
| 85 | - $this->set('CNT_ISO', $iso); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * @param $abbrev |
|
| 91 | - */ |
|
| 92 | - public function set_abbrev($abbrev) |
|
| 93 | - { |
|
| 94 | - $this->set('STA_abbrev', $abbrev); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * @param $active |
|
| 100 | - */ |
|
| 101 | - public function set_active($active) |
|
| 102 | - { |
|
| 103 | - $this->set('STA_active', $active); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * @param $name |
|
| 109 | - */ |
|
| 110 | - public function set_name($name) |
|
| 111 | - { |
|
| 112 | - $this->set('STA_name', $name); |
|
| 113 | - } |
|
| 14 | + /** |
|
| 15 | + * @param array $props_n_values |
|
| 16 | + * @return EE_State|mixed |
|
| 17 | + */ |
|
| 18 | + public static function new_instance($props_n_values = array()) |
|
| 19 | + { |
|
| 20 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
| 21 | + return $has_object ? $has_object : new self($props_n_values); |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * @param array $props_n_values |
|
| 27 | + * @return EE_State |
|
| 28 | + */ |
|
| 29 | + public static function new_instance_from_db($props_n_values = array()) |
|
| 30 | + { |
|
| 31 | + return new self($props_n_values, true); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @return string |
|
| 37 | + */ |
|
| 38 | + public function country_iso() |
|
| 39 | + { |
|
| 40 | + return $this->get('CNT_ISO'); |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @return string |
|
| 46 | + */ |
|
| 47 | + public function abbrev() |
|
| 48 | + { |
|
| 49 | + return $this->get('STA_abbrev'); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @return bool |
|
| 55 | + */ |
|
| 56 | + public function active() |
|
| 57 | + { |
|
| 58 | + return $this->get('STA_active'); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * @return string |
|
| 64 | + */ |
|
| 65 | + public function name() |
|
| 66 | + { |
|
| 67 | + return $this->get('STA_name'); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @return EE_Country |
|
| 73 | + */ |
|
| 74 | + public function country() |
|
| 75 | + { |
|
| 76 | + return $this->get_first_related('Country'); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * @param $iso |
|
| 82 | + */ |
|
| 83 | + public function set_country_iso($iso) |
|
| 84 | + { |
|
| 85 | + $this->set('CNT_ISO', $iso); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * @param $abbrev |
|
| 91 | + */ |
|
| 92 | + public function set_abbrev($abbrev) |
|
| 93 | + { |
|
| 94 | + $this->set('STA_abbrev', $abbrev); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * @param $active |
|
| 100 | + */ |
|
| 101 | + public function set_active($active) |
|
| 102 | + { |
|
| 103 | + $this->set('STA_active', $active); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * @param $name |
|
| 109 | + */ |
|
| 110 | + public function set_name($name) |
|
| 111 | + { |
|
| 112 | + $this->set('STA_name', $name); |
|
| 113 | + } |
|
| 114 | 114 | } |
@@ -36,16 +36,16 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array()) |
| 38 | 38 | { |
| 39 | - if (! isset($fieldValues['ATT_full_name'])) { |
|
| 40 | - $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : ''; |
|
| 39 | + if ( ! isset($fieldValues['ATT_full_name'])) { |
|
| 40 | + $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'].' ' : ''; |
|
| 41 | 41 | $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : ''; |
| 42 | - $fieldValues['ATT_full_name'] = $fname . $lname; |
|
| 42 | + $fieldValues['ATT_full_name'] = $fname.$lname; |
|
| 43 | 43 | } |
| 44 | - if (! isset($fieldValues['ATT_slug'])) { |
|
| 44 | + if ( ! isset($fieldValues['ATT_slug'])) { |
|
| 45 | 45 | // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20)); |
| 46 | 46 | $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']); |
| 47 | 47 | } |
| 48 | - if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) { |
|
| 48 | + if ( ! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) { |
|
| 49 | 49 | $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50); |
| 50 | 50 | } |
| 51 | 51 | parent::__construct($fieldValues, $bydb, $timezone, $date_formats); |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',); |
| 326 | 326 | foreach ($initial_address_fields as $address_field_name) { |
| 327 | 327 | $address_fields_value = $this->get($address_field_name); |
| 328 | - if (! empty($address_fields_value)) { |
|
| 328 | + if ( ! empty($address_fields_value)) { |
|
| 329 | 329 | $full_address_array[] = $address_fields_value; |
| 330 | 330 | } |
| 331 | 331 | } |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | } |
| 341 | 341 | // lastly get the xip |
| 342 | 342 | $zip_value = $this->zip(); |
| 343 | - if (! empty($zip_value)) { |
|
| 343 | + if ( ! empty($zip_value)) { |
|
| 344 | 344 | $full_address_array[] = $zip_value; |
| 345 | 345 | } |
| 346 | 346 | return $full_address_array; |
@@ -622,18 +622,18 @@ discard block |
||
| 622 | 622 | public function billing_info_for_payment_method($payment_method) |
| 623 | 623 | { |
| 624 | 624 | $pm_type = $payment_method->type_obj(); |
| 625 | - if (! $pm_type instanceof EE_PMT_Base) { |
|
| 625 | + if ( ! $pm_type instanceof EE_PMT_Base) { |
|
| 626 | 626 | return null; |
| 627 | 627 | } |
| 628 | 628 | $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true); |
| 629 | - if (! $billing_info) { |
|
| 629 | + if ( ! $billing_info) { |
|
| 630 | 630 | return null; |
| 631 | 631 | } |
| 632 | 632 | $billing_form = $pm_type->billing_form(); |
| 633 | 633 | // double-check the form isn't totally hidden, in which case pretend there is no form |
| 634 | 634 | $form_totally_hidden = true; |
| 635 | 635 | foreach ($billing_form->inputs_in_subsections() as $input) { |
| 636 | - if (! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) { |
|
| 636 | + if ( ! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) { |
|
| 637 | 637 | $form_totally_hidden = false; |
| 638 | 638 | break; |
| 639 | 639 | } |
@@ -660,7 +660,7 @@ discard block |
||
| 660 | 660 | public function get_billing_info_postmeta_name($payment_method) |
| 661 | 661 | { |
| 662 | 662 | if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
| 663 | - return 'billing_info_' . $payment_method->type_obj()->system_name(); |
|
| 663 | + return 'billing_info_'.$payment_method->type_obj()->system_name(); |
|
| 664 | 664 | } |
| 665 | 665 | return null; |
| 666 | 666 | } |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | */ |
| 678 | 678 | public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method) |
| 679 | 679 | { |
| 680 | - if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) { |
|
| 680 | + if ( ! $billing_form instanceof EE_Billing_Attendee_Info_Form) { |
|
| 681 | 681 | EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso')); |
| 682 | 682 | return false; |
| 683 | 683 | } |
@@ -25,772 +25,772 @@ |
||
| 25 | 25 | class EE_Attendee extends EE_CPT_Base implements EEI_Contact, EEI_Address, EEI_Admin_Links, EEI_Attendee |
| 26 | 26 | { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Sets some dynamic defaults |
|
| 30 | - * |
|
| 31 | - * @param array $fieldValues |
|
| 32 | - * @param bool $bydb |
|
| 33 | - * @param string $timezone |
|
| 34 | - * @param array $date_formats |
|
| 35 | - * @throws EE_Error |
|
| 36 | - */ |
|
| 37 | - protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array()) |
|
| 38 | - { |
|
| 39 | - if (! isset($fieldValues['ATT_full_name'])) { |
|
| 40 | - $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : ''; |
|
| 41 | - $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : ''; |
|
| 42 | - $fieldValues['ATT_full_name'] = $fname . $lname; |
|
| 43 | - } |
|
| 44 | - if (! isset($fieldValues['ATT_slug'])) { |
|
| 45 | - // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20)); |
|
| 46 | - $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']); |
|
| 47 | - } |
|
| 48 | - if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) { |
|
| 49 | - $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50); |
|
| 50 | - } |
|
| 51 | - parent::__construct($fieldValues, $bydb, $timezone, $date_formats); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * @param array $props_n_values incoming values |
|
| 57 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 58 | - * used.) |
|
| 59 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 60 | - * date_format and the second value is the time format |
|
| 61 | - * @return EE_Attendee |
|
| 62 | - * @throws EE_Error |
|
| 63 | - */ |
|
| 64 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
| 65 | - { |
|
| 66 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 67 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * @param array $props_n_values incoming values from the database |
|
| 73 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 74 | - * the website will be used. |
|
| 75 | - * @return EE_Attendee |
|
| 76 | - */ |
|
| 77 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 78 | - { |
|
| 79 | - return new self($props_n_values, true, $timezone); |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * Set Attendee First Name |
|
| 85 | - * |
|
| 86 | - * @access public |
|
| 87 | - * @param string $fname |
|
| 88 | - * @throws EE_Error |
|
| 89 | - */ |
|
| 90 | - public function set_fname($fname = '') |
|
| 91 | - { |
|
| 92 | - $this->set('ATT_fname', $fname); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * Set Attendee Last Name |
|
| 98 | - * |
|
| 99 | - * @access public |
|
| 100 | - * @param string $lname |
|
| 101 | - * @throws EE_Error |
|
| 102 | - */ |
|
| 103 | - public function set_lname($lname = '') |
|
| 104 | - { |
|
| 105 | - $this->set('ATT_lname', $lname); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * Set Attendee Address |
|
| 111 | - * |
|
| 112 | - * @access public |
|
| 113 | - * @param string $address |
|
| 114 | - * @throws EE_Error |
|
| 115 | - */ |
|
| 116 | - public function set_address($address = '') |
|
| 117 | - { |
|
| 118 | - $this->set('ATT_address', $address); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Set Attendee Address2 |
|
| 124 | - * |
|
| 125 | - * @access public |
|
| 126 | - * @param string $address2 |
|
| 127 | - * @throws EE_Error |
|
| 128 | - */ |
|
| 129 | - public function set_address2($address2 = '') |
|
| 130 | - { |
|
| 131 | - $this->set('ATT_address2', $address2); |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * Set Attendee City |
|
| 137 | - * |
|
| 138 | - * @access public |
|
| 139 | - * @param string $city |
|
| 140 | - * @throws EE_Error |
|
| 141 | - */ |
|
| 142 | - public function set_city($city = '') |
|
| 143 | - { |
|
| 144 | - $this->set('ATT_city', $city); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * Set Attendee State ID |
|
| 150 | - * |
|
| 151 | - * @access public |
|
| 152 | - * @param int $STA_ID |
|
| 153 | - * @throws EE_Error |
|
| 154 | - */ |
|
| 155 | - public function set_state($STA_ID = 0) |
|
| 156 | - { |
|
| 157 | - $this->set('STA_ID', $STA_ID); |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * Set Attendee Country ISO Code |
|
| 163 | - * |
|
| 164 | - * @access public |
|
| 165 | - * @param string $CNT_ISO |
|
| 166 | - * @throws EE_Error |
|
| 167 | - */ |
|
| 168 | - public function set_country($CNT_ISO = '') |
|
| 169 | - { |
|
| 170 | - $this->set('CNT_ISO', $CNT_ISO); |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * Set Attendee Zip/Postal Code |
|
| 176 | - * |
|
| 177 | - * @access public |
|
| 178 | - * @param string $zip |
|
| 179 | - * @throws EE_Error |
|
| 180 | - */ |
|
| 181 | - public function set_zip($zip = '') |
|
| 182 | - { |
|
| 183 | - $this->set('ATT_zip', $zip); |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * Set Attendee Email Address |
|
| 189 | - * |
|
| 190 | - * @access public |
|
| 191 | - * @param string $email |
|
| 192 | - * @throws EE_Error |
|
| 193 | - */ |
|
| 194 | - public function set_email($email = '') |
|
| 195 | - { |
|
| 196 | - $this->set('ATT_email', $email); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * Set Attendee Phone |
|
| 202 | - * |
|
| 203 | - * @access public |
|
| 204 | - * @param string $phone |
|
| 205 | - * @throws EE_Error |
|
| 206 | - */ |
|
| 207 | - public function set_phone($phone = '') |
|
| 208 | - { |
|
| 209 | - $this->set('ATT_phone', $phone); |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - |
|
| 213 | - /** |
|
| 214 | - * set deleted |
|
| 215 | - * |
|
| 216 | - * @access public |
|
| 217 | - * @param bool $ATT_deleted |
|
| 218 | - * @throws EE_Error |
|
| 219 | - */ |
|
| 220 | - public function set_deleted($ATT_deleted = false) |
|
| 221 | - { |
|
| 222 | - $this->set('ATT_deleted', $ATT_deleted); |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - |
|
| 226 | - /** |
|
| 227 | - * Returns the value for the post_author id saved with the cpt |
|
| 228 | - * |
|
| 229 | - * @since 4.5.0 |
|
| 230 | - * @return int |
|
| 231 | - * @throws EE_Error |
|
| 232 | - */ |
|
| 233 | - public function wp_user() |
|
| 234 | - { |
|
| 235 | - return $this->get('ATT_author'); |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - |
|
| 239 | - /** |
|
| 240 | - * get Attendee First Name |
|
| 241 | - * |
|
| 242 | - * @access public |
|
| 243 | - * @return string |
|
| 244 | - * @throws EE_Error |
|
| 245 | - */ |
|
| 246 | - public function fname() |
|
| 247 | - { |
|
| 248 | - return $this->get('ATT_fname'); |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * echoes out the attendee's first name |
|
| 254 | - * |
|
| 255 | - * @return void |
|
| 256 | - * @throws EE_Error |
|
| 257 | - */ |
|
| 258 | - public function e_full_name() |
|
| 259 | - { |
|
| 260 | - echo $this->full_name(); |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - |
|
| 264 | - /** |
|
| 265 | - * Returns the first and last name concatenated together with a space. |
|
| 266 | - * |
|
| 267 | - * @param bool $apply_html_entities |
|
| 268 | - * @return string |
|
| 269 | - * @throws EE_Error |
|
| 270 | - */ |
|
| 271 | - public function full_name($apply_html_entities = false) |
|
| 272 | - { |
|
| 273 | - $full_name = array( |
|
| 274 | - $this->fname(), |
|
| 275 | - $this->lname(), |
|
| 276 | - ); |
|
| 277 | - $full_name = array_filter($full_name); |
|
| 278 | - $full_name = implode(' ', $full_name); |
|
| 279 | - return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name; |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - |
|
| 283 | - /** |
|
| 284 | - * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless |
|
| 285 | - * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this |
|
| 286 | - * attendee. |
|
| 287 | - * |
|
| 288 | - * @param bool $apply_html_entities |
|
| 289 | - * @return string |
|
| 290 | - * @throws EE_Error |
|
| 291 | - */ |
|
| 292 | - public function ATT_full_name($apply_html_entities = false) |
|
| 293 | - { |
|
| 294 | - return $apply_html_entities |
|
| 295 | - ? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8') |
|
| 296 | - : $this->get('ATT_full_name'); |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - |
|
| 300 | - /** |
|
| 301 | - * get Attendee Last Name |
|
| 302 | - * |
|
| 303 | - * @access public |
|
| 304 | - * @return string |
|
| 305 | - * @throws EE_Error |
|
| 306 | - */ |
|
| 307 | - public function lname() |
|
| 308 | - { |
|
| 309 | - return $this->get('ATT_lname'); |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - |
|
| 313 | - /** |
|
| 314 | - * get Attendee bio |
|
| 315 | - * |
|
| 316 | - * @access public |
|
| 317 | - * @return string |
|
| 318 | - * @throws EE_Error |
|
| 319 | - */ |
|
| 320 | - public function bio() |
|
| 321 | - { |
|
| 322 | - return $this->get('ATT_bio'); |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - |
|
| 326 | - /** |
|
| 327 | - * get Attendee short bio |
|
| 328 | - * |
|
| 329 | - * @access public |
|
| 330 | - * @return string |
|
| 331 | - * @throws EE_Error |
|
| 332 | - */ |
|
| 333 | - public function short_bio() |
|
| 334 | - { |
|
| 335 | - return $this->get('ATT_short_bio'); |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - |
|
| 339 | - /** |
|
| 340 | - * Gets the attendee's full address as an array so client code can decide hwo to display it |
|
| 341 | - * |
|
| 342 | - * @return array numerically indexed, with each part of the address that is known. |
|
| 343 | - * Eg, if the user only responded to state and country, |
|
| 344 | - * it would be array(0=>'Alabama',1=>'USA') |
|
| 345 | - * @return array |
|
| 346 | - * @throws EE_Error |
|
| 347 | - */ |
|
| 348 | - public function full_address_as_array() |
|
| 349 | - { |
|
| 350 | - $full_address_array = array(); |
|
| 351 | - $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',); |
|
| 352 | - foreach ($initial_address_fields as $address_field_name) { |
|
| 353 | - $address_fields_value = $this->get($address_field_name); |
|
| 354 | - if (! empty($address_fields_value)) { |
|
| 355 | - $full_address_array[] = $address_fields_value; |
|
| 356 | - } |
|
| 357 | - } |
|
| 358 | - // now handle state and country |
|
| 359 | - $state_obj = $this->state_obj(); |
|
| 360 | - if ($state_obj instanceof EE_State) { |
|
| 361 | - $full_address_array[] = $state_obj->name(); |
|
| 362 | - } |
|
| 363 | - $country_obj = $this->country_obj(); |
|
| 364 | - if ($country_obj instanceof EE_Country) { |
|
| 365 | - $full_address_array[] = $country_obj->name(); |
|
| 366 | - } |
|
| 367 | - // lastly get the xip |
|
| 368 | - $zip_value = $this->zip(); |
|
| 369 | - if (! empty($zip_value)) { |
|
| 370 | - $full_address_array[] = $zip_value; |
|
| 371 | - } |
|
| 372 | - return $full_address_array; |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - |
|
| 376 | - /** |
|
| 377 | - * get Attendee Address |
|
| 378 | - * |
|
| 379 | - * @return string |
|
| 380 | - * @throws EE_Error |
|
| 381 | - */ |
|
| 382 | - public function address() |
|
| 383 | - { |
|
| 384 | - return $this->get('ATT_address'); |
|
| 385 | - } |
|
| 386 | - |
|
| 387 | - |
|
| 388 | - /** |
|
| 389 | - * get Attendee Address2 |
|
| 390 | - * |
|
| 391 | - * @return string |
|
| 392 | - * @throws EE_Error |
|
| 393 | - */ |
|
| 394 | - public function address2() |
|
| 395 | - { |
|
| 396 | - return $this->get('ATT_address2'); |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - |
|
| 400 | - /** |
|
| 401 | - * get Attendee City |
|
| 402 | - * |
|
| 403 | - * @return string |
|
| 404 | - * @throws EE_Error |
|
| 405 | - */ |
|
| 406 | - public function city() |
|
| 407 | - { |
|
| 408 | - return $this->get('ATT_city'); |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - |
|
| 412 | - /** |
|
| 413 | - * get Attendee State ID |
|
| 414 | - * |
|
| 415 | - * @return string |
|
| 416 | - * @throws EE_Error |
|
| 417 | - */ |
|
| 418 | - public function state_ID() |
|
| 419 | - { |
|
| 420 | - return $this->get('STA_ID'); |
|
| 421 | - } |
|
| 422 | - |
|
| 423 | - |
|
| 424 | - /** |
|
| 425 | - * @return string |
|
| 426 | - * @throws EE_Error |
|
| 427 | - */ |
|
| 428 | - public function state_abbrev() |
|
| 429 | - { |
|
| 430 | - return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : ''; |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - |
|
| 434 | - /** |
|
| 435 | - * Gets the state set to this attendee |
|
| 436 | - * |
|
| 437 | - * @return EE_State |
|
| 438 | - * @throws EE_Error |
|
| 439 | - */ |
|
| 440 | - public function state_obj() |
|
| 441 | - { |
|
| 442 | - return $this->get_first_related('State'); |
|
| 443 | - } |
|
| 444 | - |
|
| 445 | - |
|
| 446 | - /** |
|
| 447 | - * Returns the state's name, otherwise 'Unknown' |
|
| 448 | - * |
|
| 449 | - * @return string |
|
| 450 | - * @throws EE_Error |
|
| 451 | - */ |
|
| 452 | - public function state_name() |
|
| 453 | - { |
|
| 454 | - if ($this->state_obj()) { |
|
| 455 | - return $this->state_obj()->name(); |
|
| 456 | - } else { |
|
| 457 | - return ''; |
|
| 458 | - } |
|
| 459 | - } |
|
| 460 | - |
|
| 461 | - |
|
| 462 | - /** |
|
| 463 | - * either displays the state abbreviation or the state name, as determined |
|
| 464 | - * by the "FHEE__EEI_Address__state__use_abbreviation" filter. |
|
| 465 | - * defaults to abbreviation |
|
| 466 | - * |
|
| 467 | - * @return string |
|
| 468 | - * @throws EE_Error |
|
| 469 | - */ |
|
| 470 | - public function state() |
|
| 471 | - { |
|
| 472 | - if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) { |
|
| 473 | - return $this->state_abbrev(); |
|
| 474 | - } |
|
| 475 | - return $this->state_name(); |
|
| 476 | - } |
|
| 477 | - |
|
| 478 | - |
|
| 479 | - /** |
|
| 480 | - * get Attendee Country ISO Code |
|
| 481 | - * |
|
| 482 | - * @return string |
|
| 483 | - * @throws EE_Error |
|
| 484 | - */ |
|
| 485 | - public function country_ID() |
|
| 486 | - { |
|
| 487 | - return $this->get('CNT_ISO'); |
|
| 488 | - } |
|
| 489 | - |
|
| 490 | - |
|
| 491 | - /** |
|
| 492 | - * Gets country set for this attendee |
|
| 493 | - * |
|
| 494 | - * @return EE_Country |
|
| 495 | - * @throws EE_Error |
|
| 496 | - */ |
|
| 497 | - public function country_obj() |
|
| 498 | - { |
|
| 499 | - return $this->get_first_related('Country'); |
|
| 500 | - } |
|
| 501 | - |
|
| 502 | - |
|
| 503 | - /** |
|
| 504 | - * Returns the country's name if known, otherwise 'Unknown' |
|
| 505 | - * |
|
| 506 | - * @return string |
|
| 507 | - * @throws EE_Error |
|
| 508 | - */ |
|
| 509 | - public function country_name() |
|
| 510 | - { |
|
| 511 | - if ($this->country_obj()) { |
|
| 512 | - return $this->country_obj()->name(); |
|
| 513 | - } |
|
| 514 | - return ''; |
|
| 515 | - } |
|
| 516 | - |
|
| 517 | - |
|
| 518 | - /** |
|
| 519 | - * either displays the country ISO2 code or the country name, as determined |
|
| 520 | - * by the "FHEE__EEI_Address__country__use_abbreviation" filter. |
|
| 521 | - * defaults to abbreviation |
|
| 522 | - * |
|
| 523 | - * @return string |
|
| 524 | - * @throws EE_Error |
|
| 525 | - */ |
|
| 526 | - public function country() |
|
| 527 | - { |
|
| 528 | - if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) { |
|
| 529 | - return $this->country_ID(); |
|
| 530 | - } |
|
| 531 | - return $this->country_name(); |
|
| 532 | - } |
|
| 533 | - |
|
| 534 | - |
|
| 535 | - /** |
|
| 536 | - * get Attendee Zip/Postal Code |
|
| 537 | - * |
|
| 538 | - * @return string |
|
| 539 | - * @throws EE_Error |
|
| 540 | - */ |
|
| 541 | - public function zip() |
|
| 542 | - { |
|
| 543 | - return $this->get('ATT_zip'); |
|
| 544 | - } |
|
| 545 | - |
|
| 546 | - |
|
| 547 | - /** |
|
| 548 | - * get Attendee Email Address |
|
| 549 | - * |
|
| 550 | - * @return string |
|
| 551 | - * @throws EE_Error |
|
| 552 | - */ |
|
| 553 | - public function email() |
|
| 554 | - { |
|
| 555 | - return $this->get('ATT_email'); |
|
| 556 | - } |
|
| 557 | - |
|
| 558 | - |
|
| 559 | - /** |
|
| 560 | - * get Attendee Phone # |
|
| 561 | - * |
|
| 562 | - * @return string |
|
| 563 | - * @throws EE_Error |
|
| 564 | - */ |
|
| 565 | - public function phone() |
|
| 566 | - { |
|
| 567 | - return $this->get('ATT_phone'); |
|
| 568 | - } |
|
| 569 | - |
|
| 570 | - |
|
| 571 | - /** |
|
| 572 | - * get deleted |
|
| 573 | - * |
|
| 574 | - * @return bool |
|
| 575 | - * @throws EE_Error |
|
| 576 | - */ |
|
| 577 | - public function deleted() |
|
| 578 | - { |
|
| 579 | - return $this->get('ATT_deleted'); |
|
| 580 | - } |
|
| 581 | - |
|
| 582 | - |
|
| 583 | - /** |
|
| 584 | - * Gets registrations of this attendee |
|
| 585 | - * |
|
| 586 | - * @param array $query_params |
|
| 587 | - * @return EE_Registration[] |
|
| 588 | - * @throws EE_Error |
|
| 589 | - */ |
|
| 590 | - public function get_registrations($query_params = array()) |
|
| 591 | - { |
|
| 592 | - return $this->get_many_related('Registration', $query_params); |
|
| 593 | - } |
|
| 594 | - |
|
| 595 | - |
|
| 596 | - /** |
|
| 597 | - * Gets the most recent registration of this attendee |
|
| 598 | - * |
|
| 599 | - * @return EE_Registration |
|
| 600 | - * @throws EE_Error |
|
| 601 | - */ |
|
| 602 | - public function get_most_recent_registration() |
|
| 603 | - { |
|
| 604 | - return $this->get_first_related( |
|
| 605 | - 'Registration', |
|
| 606 | - array('order_by' => array('REG_date' => 'DESC')) |
|
| 607 | - ); // null, 'REG_date', 'DESC', '=', 'OBJECT_K'); |
|
| 608 | - } |
|
| 609 | - |
|
| 610 | - |
|
| 611 | - /** |
|
| 612 | - * Gets the most recent registration for this attend at this event |
|
| 613 | - * |
|
| 614 | - * @param int $event_id |
|
| 615 | - * @return EE_Registration |
|
| 616 | - * @throws EE_Error |
|
| 617 | - */ |
|
| 618 | - public function get_most_recent_registration_for_event($event_id) |
|
| 619 | - { |
|
| 620 | - return $this->get_first_related( |
|
| 621 | - 'Registration', |
|
| 622 | - array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')) |
|
| 623 | - ); |
|
| 624 | - } |
|
| 625 | - |
|
| 626 | - |
|
| 627 | - /** |
|
| 628 | - * returns any events attached to this attendee ($_Event property); |
|
| 629 | - * |
|
| 630 | - * @return array |
|
| 631 | - * @throws EE_Error |
|
| 632 | - */ |
|
| 633 | - public function events() |
|
| 634 | - { |
|
| 635 | - return $this->get_many_related('Event'); |
|
| 636 | - } |
|
| 637 | - |
|
| 638 | - |
|
| 639 | - /** |
|
| 640 | - * Gets the billing info array where keys match espresso_reg_page_billing_inputs(), |
|
| 641 | - * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was |
|
| 642 | - * used to save the billing info |
|
| 643 | - * |
|
| 644 | - * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class |
|
| 645 | - * @return EE_Form_Section_Proper|null |
|
| 646 | - * @throws EE_Error |
|
| 647 | - */ |
|
| 648 | - public function billing_info_for_payment_method($payment_method) |
|
| 649 | - { |
|
| 650 | - $pm_type = $payment_method->type_obj(); |
|
| 651 | - if (! $pm_type instanceof EE_PMT_Base) { |
|
| 652 | - return null; |
|
| 653 | - } |
|
| 654 | - $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true); |
|
| 655 | - if (! $billing_info) { |
|
| 656 | - return null; |
|
| 657 | - } |
|
| 658 | - $billing_form = $pm_type->billing_form(); |
|
| 659 | - // double-check the form isn't totally hidden, in which case pretend there is no form |
|
| 660 | - $form_totally_hidden = true; |
|
| 661 | - foreach ($billing_form->inputs_in_subsections() as $input) { |
|
| 662 | - if (! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) { |
|
| 663 | - $form_totally_hidden = false; |
|
| 664 | - break; |
|
| 665 | - } |
|
| 666 | - } |
|
| 667 | - if ($form_totally_hidden) { |
|
| 668 | - return null; |
|
| 669 | - } |
|
| 670 | - if ($billing_form instanceof EE_Form_Section_Proper) { |
|
| 671 | - $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false); |
|
| 672 | - } |
|
| 673 | - |
|
| 674 | - return $billing_form; |
|
| 675 | - } |
|
| 676 | - |
|
| 677 | - |
|
| 678 | - /** |
|
| 679 | - * Gets the postmeta key that holds this attendee's billing info for the |
|
| 680 | - * specified payment method |
|
| 681 | - * |
|
| 682 | - * @param EE_Payment_Method $payment_method |
|
| 683 | - * @return string |
|
| 684 | - * @throws EE_Error |
|
| 685 | - */ |
|
| 686 | - public function get_billing_info_postmeta_name($payment_method) |
|
| 687 | - { |
|
| 688 | - if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
| 689 | - return 'billing_info_' . $payment_method->type_obj()->system_name(); |
|
| 690 | - } |
|
| 691 | - return null; |
|
| 692 | - } |
|
| 693 | - |
|
| 694 | - |
|
| 695 | - /** |
|
| 696 | - * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to |
|
| 697 | - * retrieve it |
|
| 698 | - * |
|
| 699 | - * @param EE_Billing_Attendee_Info_Form $billing_form |
|
| 700 | - * @param EE_Payment_Method $payment_method |
|
| 701 | - * @return boolean |
|
| 702 | - * @throws EE_Error |
|
| 703 | - */ |
|
| 704 | - public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method) |
|
| 705 | - { |
|
| 706 | - if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) { |
|
| 707 | - EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso')); |
|
| 708 | - return false; |
|
| 709 | - } |
|
| 710 | - $billing_form->clean_sensitive_data(); |
|
| 711 | - return update_post_meta( |
|
| 712 | - $this->ID(), |
|
| 713 | - $this->get_billing_info_postmeta_name($payment_method), |
|
| 714 | - $billing_form->input_values(true) |
|
| 715 | - ); |
|
| 716 | - } |
|
| 717 | - |
|
| 718 | - |
|
| 719 | - /** |
|
| 720 | - * Return the link to the admin details for the object. |
|
| 721 | - * |
|
| 722 | - * @return string |
|
| 723 | - * @throws EE_Error |
|
| 724 | - * @throws InvalidArgumentException |
|
| 725 | - * @throws InvalidDataTypeException |
|
| 726 | - * @throws InvalidInterfaceException |
|
| 727 | - * @throws ReflectionException |
|
| 728 | - */ |
|
| 729 | - public function get_admin_details_link() |
|
| 730 | - { |
|
| 731 | - return $this->get_admin_edit_link(); |
|
| 732 | - } |
|
| 733 | - |
|
| 734 | - |
|
| 735 | - /** |
|
| 736 | - * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
| 737 | - * |
|
| 738 | - * @return string |
|
| 739 | - * @throws EE_Error |
|
| 740 | - * @throws InvalidArgumentException |
|
| 741 | - * @throws ReflectionException |
|
| 742 | - * @throws InvalidDataTypeException |
|
| 743 | - * @throws InvalidInterfaceException |
|
| 744 | - */ |
|
| 745 | - public function get_admin_edit_link() |
|
| 746 | - { |
|
| 747 | - EE_Registry::instance()->load_helper('URL'); |
|
| 748 | - return EEH_URL::add_query_args_and_nonce( |
|
| 749 | - array( |
|
| 750 | - 'page' => 'espresso_registrations', |
|
| 751 | - 'action' => 'edit_attendee', |
|
| 752 | - 'post' => $this->ID(), |
|
| 753 | - ), |
|
| 754 | - admin_url('admin.php') |
|
| 755 | - ); |
|
| 756 | - } |
|
| 757 | - |
|
| 758 | - |
|
| 759 | - /** |
|
| 760 | - * Returns the link to a settings page for the object. |
|
| 761 | - * |
|
| 762 | - * @return string |
|
| 763 | - * @throws EE_Error |
|
| 764 | - * @throws InvalidArgumentException |
|
| 765 | - * @throws InvalidDataTypeException |
|
| 766 | - * @throws InvalidInterfaceException |
|
| 767 | - * @throws ReflectionException |
|
| 768 | - */ |
|
| 769 | - public function get_admin_settings_link() |
|
| 770 | - { |
|
| 771 | - return $this->get_admin_edit_link(); |
|
| 772 | - } |
|
| 773 | - |
|
| 774 | - |
|
| 775 | - /** |
|
| 776 | - * Returns the link to the "overview" for the object (typically the "list table" view). |
|
| 777 | - * |
|
| 778 | - * @return string |
|
| 779 | - * @throws EE_Error |
|
| 780 | - * @throws InvalidArgumentException |
|
| 781 | - * @throws ReflectionException |
|
| 782 | - * @throws InvalidDataTypeException |
|
| 783 | - * @throws InvalidInterfaceException |
|
| 784 | - */ |
|
| 785 | - public function get_admin_overview_link() |
|
| 786 | - { |
|
| 787 | - EE_Registry::instance()->load_helper('URL'); |
|
| 788 | - return EEH_URL::add_query_args_and_nonce( |
|
| 789 | - array( |
|
| 790 | - 'page' => 'espresso_registrations', |
|
| 791 | - 'action' => 'contact_list', |
|
| 792 | - ), |
|
| 793 | - admin_url('admin.php') |
|
| 794 | - ); |
|
| 795 | - } |
|
| 28 | + /** |
|
| 29 | + * Sets some dynamic defaults |
|
| 30 | + * |
|
| 31 | + * @param array $fieldValues |
|
| 32 | + * @param bool $bydb |
|
| 33 | + * @param string $timezone |
|
| 34 | + * @param array $date_formats |
|
| 35 | + * @throws EE_Error |
|
| 36 | + */ |
|
| 37 | + protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array()) |
|
| 38 | + { |
|
| 39 | + if (! isset($fieldValues['ATT_full_name'])) { |
|
| 40 | + $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : ''; |
|
| 41 | + $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : ''; |
|
| 42 | + $fieldValues['ATT_full_name'] = $fname . $lname; |
|
| 43 | + } |
|
| 44 | + if (! isset($fieldValues['ATT_slug'])) { |
|
| 45 | + // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20)); |
|
| 46 | + $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']); |
|
| 47 | + } |
|
| 48 | + if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) { |
|
| 49 | + $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50); |
|
| 50 | + } |
|
| 51 | + parent::__construct($fieldValues, $bydb, $timezone, $date_formats); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * @param array $props_n_values incoming values |
|
| 57 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 58 | + * used.) |
|
| 59 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 60 | + * date_format and the second value is the time format |
|
| 61 | + * @return EE_Attendee |
|
| 62 | + * @throws EE_Error |
|
| 63 | + */ |
|
| 64 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
| 65 | + { |
|
| 66 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 67 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @param array $props_n_values incoming values from the database |
|
| 73 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 74 | + * the website will be used. |
|
| 75 | + * @return EE_Attendee |
|
| 76 | + */ |
|
| 77 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 78 | + { |
|
| 79 | + return new self($props_n_values, true, $timezone); |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * Set Attendee First Name |
|
| 85 | + * |
|
| 86 | + * @access public |
|
| 87 | + * @param string $fname |
|
| 88 | + * @throws EE_Error |
|
| 89 | + */ |
|
| 90 | + public function set_fname($fname = '') |
|
| 91 | + { |
|
| 92 | + $this->set('ATT_fname', $fname); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * Set Attendee Last Name |
|
| 98 | + * |
|
| 99 | + * @access public |
|
| 100 | + * @param string $lname |
|
| 101 | + * @throws EE_Error |
|
| 102 | + */ |
|
| 103 | + public function set_lname($lname = '') |
|
| 104 | + { |
|
| 105 | + $this->set('ATT_lname', $lname); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * Set Attendee Address |
|
| 111 | + * |
|
| 112 | + * @access public |
|
| 113 | + * @param string $address |
|
| 114 | + * @throws EE_Error |
|
| 115 | + */ |
|
| 116 | + public function set_address($address = '') |
|
| 117 | + { |
|
| 118 | + $this->set('ATT_address', $address); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Set Attendee Address2 |
|
| 124 | + * |
|
| 125 | + * @access public |
|
| 126 | + * @param string $address2 |
|
| 127 | + * @throws EE_Error |
|
| 128 | + */ |
|
| 129 | + public function set_address2($address2 = '') |
|
| 130 | + { |
|
| 131 | + $this->set('ATT_address2', $address2); |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * Set Attendee City |
|
| 137 | + * |
|
| 138 | + * @access public |
|
| 139 | + * @param string $city |
|
| 140 | + * @throws EE_Error |
|
| 141 | + */ |
|
| 142 | + public function set_city($city = '') |
|
| 143 | + { |
|
| 144 | + $this->set('ATT_city', $city); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * Set Attendee State ID |
|
| 150 | + * |
|
| 151 | + * @access public |
|
| 152 | + * @param int $STA_ID |
|
| 153 | + * @throws EE_Error |
|
| 154 | + */ |
|
| 155 | + public function set_state($STA_ID = 0) |
|
| 156 | + { |
|
| 157 | + $this->set('STA_ID', $STA_ID); |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * Set Attendee Country ISO Code |
|
| 163 | + * |
|
| 164 | + * @access public |
|
| 165 | + * @param string $CNT_ISO |
|
| 166 | + * @throws EE_Error |
|
| 167 | + */ |
|
| 168 | + public function set_country($CNT_ISO = '') |
|
| 169 | + { |
|
| 170 | + $this->set('CNT_ISO', $CNT_ISO); |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * Set Attendee Zip/Postal Code |
|
| 176 | + * |
|
| 177 | + * @access public |
|
| 178 | + * @param string $zip |
|
| 179 | + * @throws EE_Error |
|
| 180 | + */ |
|
| 181 | + public function set_zip($zip = '') |
|
| 182 | + { |
|
| 183 | + $this->set('ATT_zip', $zip); |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * Set Attendee Email Address |
|
| 189 | + * |
|
| 190 | + * @access public |
|
| 191 | + * @param string $email |
|
| 192 | + * @throws EE_Error |
|
| 193 | + */ |
|
| 194 | + public function set_email($email = '') |
|
| 195 | + { |
|
| 196 | + $this->set('ATT_email', $email); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * Set Attendee Phone |
|
| 202 | + * |
|
| 203 | + * @access public |
|
| 204 | + * @param string $phone |
|
| 205 | + * @throws EE_Error |
|
| 206 | + */ |
|
| 207 | + public function set_phone($phone = '') |
|
| 208 | + { |
|
| 209 | + $this->set('ATT_phone', $phone); |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + |
|
| 213 | + /** |
|
| 214 | + * set deleted |
|
| 215 | + * |
|
| 216 | + * @access public |
|
| 217 | + * @param bool $ATT_deleted |
|
| 218 | + * @throws EE_Error |
|
| 219 | + */ |
|
| 220 | + public function set_deleted($ATT_deleted = false) |
|
| 221 | + { |
|
| 222 | + $this->set('ATT_deleted', $ATT_deleted); |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * Returns the value for the post_author id saved with the cpt |
|
| 228 | + * |
|
| 229 | + * @since 4.5.0 |
|
| 230 | + * @return int |
|
| 231 | + * @throws EE_Error |
|
| 232 | + */ |
|
| 233 | + public function wp_user() |
|
| 234 | + { |
|
| 235 | + return $this->get('ATT_author'); |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + |
|
| 239 | + /** |
|
| 240 | + * get Attendee First Name |
|
| 241 | + * |
|
| 242 | + * @access public |
|
| 243 | + * @return string |
|
| 244 | + * @throws EE_Error |
|
| 245 | + */ |
|
| 246 | + public function fname() |
|
| 247 | + { |
|
| 248 | + return $this->get('ATT_fname'); |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * echoes out the attendee's first name |
|
| 254 | + * |
|
| 255 | + * @return void |
|
| 256 | + * @throws EE_Error |
|
| 257 | + */ |
|
| 258 | + public function e_full_name() |
|
| 259 | + { |
|
| 260 | + echo $this->full_name(); |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + |
|
| 264 | + /** |
|
| 265 | + * Returns the first and last name concatenated together with a space. |
|
| 266 | + * |
|
| 267 | + * @param bool $apply_html_entities |
|
| 268 | + * @return string |
|
| 269 | + * @throws EE_Error |
|
| 270 | + */ |
|
| 271 | + public function full_name($apply_html_entities = false) |
|
| 272 | + { |
|
| 273 | + $full_name = array( |
|
| 274 | + $this->fname(), |
|
| 275 | + $this->lname(), |
|
| 276 | + ); |
|
| 277 | + $full_name = array_filter($full_name); |
|
| 278 | + $full_name = implode(' ', $full_name); |
|
| 279 | + return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name; |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + |
|
| 283 | + /** |
|
| 284 | + * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless |
|
| 285 | + * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this |
|
| 286 | + * attendee. |
|
| 287 | + * |
|
| 288 | + * @param bool $apply_html_entities |
|
| 289 | + * @return string |
|
| 290 | + * @throws EE_Error |
|
| 291 | + */ |
|
| 292 | + public function ATT_full_name($apply_html_entities = false) |
|
| 293 | + { |
|
| 294 | + return $apply_html_entities |
|
| 295 | + ? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8') |
|
| 296 | + : $this->get('ATT_full_name'); |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + |
|
| 300 | + /** |
|
| 301 | + * get Attendee Last Name |
|
| 302 | + * |
|
| 303 | + * @access public |
|
| 304 | + * @return string |
|
| 305 | + * @throws EE_Error |
|
| 306 | + */ |
|
| 307 | + public function lname() |
|
| 308 | + { |
|
| 309 | + return $this->get('ATT_lname'); |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + |
|
| 313 | + /** |
|
| 314 | + * get Attendee bio |
|
| 315 | + * |
|
| 316 | + * @access public |
|
| 317 | + * @return string |
|
| 318 | + * @throws EE_Error |
|
| 319 | + */ |
|
| 320 | + public function bio() |
|
| 321 | + { |
|
| 322 | + return $this->get('ATT_bio'); |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + |
|
| 326 | + /** |
|
| 327 | + * get Attendee short bio |
|
| 328 | + * |
|
| 329 | + * @access public |
|
| 330 | + * @return string |
|
| 331 | + * @throws EE_Error |
|
| 332 | + */ |
|
| 333 | + public function short_bio() |
|
| 334 | + { |
|
| 335 | + return $this->get('ATT_short_bio'); |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + |
|
| 339 | + /** |
|
| 340 | + * Gets the attendee's full address as an array so client code can decide hwo to display it |
|
| 341 | + * |
|
| 342 | + * @return array numerically indexed, with each part of the address that is known. |
|
| 343 | + * Eg, if the user only responded to state and country, |
|
| 344 | + * it would be array(0=>'Alabama',1=>'USA') |
|
| 345 | + * @return array |
|
| 346 | + * @throws EE_Error |
|
| 347 | + */ |
|
| 348 | + public function full_address_as_array() |
|
| 349 | + { |
|
| 350 | + $full_address_array = array(); |
|
| 351 | + $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',); |
|
| 352 | + foreach ($initial_address_fields as $address_field_name) { |
|
| 353 | + $address_fields_value = $this->get($address_field_name); |
|
| 354 | + if (! empty($address_fields_value)) { |
|
| 355 | + $full_address_array[] = $address_fields_value; |
|
| 356 | + } |
|
| 357 | + } |
|
| 358 | + // now handle state and country |
|
| 359 | + $state_obj = $this->state_obj(); |
|
| 360 | + if ($state_obj instanceof EE_State) { |
|
| 361 | + $full_address_array[] = $state_obj->name(); |
|
| 362 | + } |
|
| 363 | + $country_obj = $this->country_obj(); |
|
| 364 | + if ($country_obj instanceof EE_Country) { |
|
| 365 | + $full_address_array[] = $country_obj->name(); |
|
| 366 | + } |
|
| 367 | + // lastly get the xip |
|
| 368 | + $zip_value = $this->zip(); |
|
| 369 | + if (! empty($zip_value)) { |
|
| 370 | + $full_address_array[] = $zip_value; |
|
| 371 | + } |
|
| 372 | + return $full_address_array; |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + |
|
| 376 | + /** |
|
| 377 | + * get Attendee Address |
|
| 378 | + * |
|
| 379 | + * @return string |
|
| 380 | + * @throws EE_Error |
|
| 381 | + */ |
|
| 382 | + public function address() |
|
| 383 | + { |
|
| 384 | + return $this->get('ATT_address'); |
|
| 385 | + } |
|
| 386 | + |
|
| 387 | + |
|
| 388 | + /** |
|
| 389 | + * get Attendee Address2 |
|
| 390 | + * |
|
| 391 | + * @return string |
|
| 392 | + * @throws EE_Error |
|
| 393 | + */ |
|
| 394 | + public function address2() |
|
| 395 | + { |
|
| 396 | + return $this->get('ATT_address2'); |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + |
|
| 400 | + /** |
|
| 401 | + * get Attendee City |
|
| 402 | + * |
|
| 403 | + * @return string |
|
| 404 | + * @throws EE_Error |
|
| 405 | + */ |
|
| 406 | + public function city() |
|
| 407 | + { |
|
| 408 | + return $this->get('ATT_city'); |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + |
|
| 412 | + /** |
|
| 413 | + * get Attendee State ID |
|
| 414 | + * |
|
| 415 | + * @return string |
|
| 416 | + * @throws EE_Error |
|
| 417 | + */ |
|
| 418 | + public function state_ID() |
|
| 419 | + { |
|
| 420 | + return $this->get('STA_ID'); |
|
| 421 | + } |
|
| 422 | + |
|
| 423 | + |
|
| 424 | + /** |
|
| 425 | + * @return string |
|
| 426 | + * @throws EE_Error |
|
| 427 | + */ |
|
| 428 | + public function state_abbrev() |
|
| 429 | + { |
|
| 430 | + return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : ''; |
|
| 431 | + } |
|
| 432 | + |
|
| 433 | + |
|
| 434 | + /** |
|
| 435 | + * Gets the state set to this attendee |
|
| 436 | + * |
|
| 437 | + * @return EE_State |
|
| 438 | + * @throws EE_Error |
|
| 439 | + */ |
|
| 440 | + public function state_obj() |
|
| 441 | + { |
|
| 442 | + return $this->get_first_related('State'); |
|
| 443 | + } |
|
| 444 | + |
|
| 445 | + |
|
| 446 | + /** |
|
| 447 | + * Returns the state's name, otherwise 'Unknown' |
|
| 448 | + * |
|
| 449 | + * @return string |
|
| 450 | + * @throws EE_Error |
|
| 451 | + */ |
|
| 452 | + public function state_name() |
|
| 453 | + { |
|
| 454 | + if ($this->state_obj()) { |
|
| 455 | + return $this->state_obj()->name(); |
|
| 456 | + } else { |
|
| 457 | + return ''; |
|
| 458 | + } |
|
| 459 | + } |
|
| 460 | + |
|
| 461 | + |
|
| 462 | + /** |
|
| 463 | + * either displays the state abbreviation or the state name, as determined |
|
| 464 | + * by the "FHEE__EEI_Address__state__use_abbreviation" filter. |
|
| 465 | + * defaults to abbreviation |
|
| 466 | + * |
|
| 467 | + * @return string |
|
| 468 | + * @throws EE_Error |
|
| 469 | + */ |
|
| 470 | + public function state() |
|
| 471 | + { |
|
| 472 | + if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) { |
|
| 473 | + return $this->state_abbrev(); |
|
| 474 | + } |
|
| 475 | + return $this->state_name(); |
|
| 476 | + } |
|
| 477 | + |
|
| 478 | + |
|
| 479 | + /** |
|
| 480 | + * get Attendee Country ISO Code |
|
| 481 | + * |
|
| 482 | + * @return string |
|
| 483 | + * @throws EE_Error |
|
| 484 | + */ |
|
| 485 | + public function country_ID() |
|
| 486 | + { |
|
| 487 | + return $this->get('CNT_ISO'); |
|
| 488 | + } |
|
| 489 | + |
|
| 490 | + |
|
| 491 | + /** |
|
| 492 | + * Gets country set for this attendee |
|
| 493 | + * |
|
| 494 | + * @return EE_Country |
|
| 495 | + * @throws EE_Error |
|
| 496 | + */ |
|
| 497 | + public function country_obj() |
|
| 498 | + { |
|
| 499 | + return $this->get_first_related('Country'); |
|
| 500 | + } |
|
| 501 | + |
|
| 502 | + |
|
| 503 | + /** |
|
| 504 | + * Returns the country's name if known, otherwise 'Unknown' |
|
| 505 | + * |
|
| 506 | + * @return string |
|
| 507 | + * @throws EE_Error |
|
| 508 | + */ |
|
| 509 | + public function country_name() |
|
| 510 | + { |
|
| 511 | + if ($this->country_obj()) { |
|
| 512 | + return $this->country_obj()->name(); |
|
| 513 | + } |
|
| 514 | + return ''; |
|
| 515 | + } |
|
| 516 | + |
|
| 517 | + |
|
| 518 | + /** |
|
| 519 | + * either displays the country ISO2 code or the country name, as determined |
|
| 520 | + * by the "FHEE__EEI_Address__country__use_abbreviation" filter. |
|
| 521 | + * defaults to abbreviation |
|
| 522 | + * |
|
| 523 | + * @return string |
|
| 524 | + * @throws EE_Error |
|
| 525 | + */ |
|
| 526 | + public function country() |
|
| 527 | + { |
|
| 528 | + if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) { |
|
| 529 | + return $this->country_ID(); |
|
| 530 | + } |
|
| 531 | + return $this->country_name(); |
|
| 532 | + } |
|
| 533 | + |
|
| 534 | + |
|
| 535 | + /** |
|
| 536 | + * get Attendee Zip/Postal Code |
|
| 537 | + * |
|
| 538 | + * @return string |
|
| 539 | + * @throws EE_Error |
|
| 540 | + */ |
|
| 541 | + public function zip() |
|
| 542 | + { |
|
| 543 | + return $this->get('ATT_zip'); |
|
| 544 | + } |
|
| 545 | + |
|
| 546 | + |
|
| 547 | + /** |
|
| 548 | + * get Attendee Email Address |
|
| 549 | + * |
|
| 550 | + * @return string |
|
| 551 | + * @throws EE_Error |
|
| 552 | + */ |
|
| 553 | + public function email() |
|
| 554 | + { |
|
| 555 | + return $this->get('ATT_email'); |
|
| 556 | + } |
|
| 557 | + |
|
| 558 | + |
|
| 559 | + /** |
|
| 560 | + * get Attendee Phone # |
|
| 561 | + * |
|
| 562 | + * @return string |
|
| 563 | + * @throws EE_Error |
|
| 564 | + */ |
|
| 565 | + public function phone() |
|
| 566 | + { |
|
| 567 | + return $this->get('ATT_phone'); |
|
| 568 | + } |
|
| 569 | + |
|
| 570 | + |
|
| 571 | + /** |
|
| 572 | + * get deleted |
|
| 573 | + * |
|
| 574 | + * @return bool |
|
| 575 | + * @throws EE_Error |
|
| 576 | + */ |
|
| 577 | + public function deleted() |
|
| 578 | + { |
|
| 579 | + return $this->get('ATT_deleted'); |
|
| 580 | + } |
|
| 581 | + |
|
| 582 | + |
|
| 583 | + /** |
|
| 584 | + * Gets registrations of this attendee |
|
| 585 | + * |
|
| 586 | + * @param array $query_params |
|
| 587 | + * @return EE_Registration[] |
|
| 588 | + * @throws EE_Error |
|
| 589 | + */ |
|
| 590 | + public function get_registrations($query_params = array()) |
|
| 591 | + { |
|
| 592 | + return $this->get_many_related('Registration', $query_params); |
|
| 593 | + } |
|
| 594 | + |
|
| 595 | + |
|
| 596 | + /** |
|
| 597 | + * Gets the most recent registration of this attendee |
|
| 598 | + * |
|
| 599 | + * @return EE_Registration |
|
| 600 | + * @throws EE_Error |
|
| 601 | + */ |
|
| 602 | + public function get_most_recent_registration() |
|
| 603 | + { |
|
| 604 | + return $this->get_first_related( |
|
| 605 | + 'Registration', |
|
| 606 | + array('order_by' => array('REG_date' => 'DESC')) |
|
| 607 | + ); // null, 'REG_date', 'DESC', '=', 'OBJECT_K'); |
|
| 608 | + } |
|
| 609 | + |
|
| 610 | + |
|
| 611 | + /** |
|
| 612 | + * Gets the most recent registration for this attend at this event |
|
| 613 | + * |
|
| 614 | + * @param int $event_id |
|
| 615 | + * @return EE_Registration |
|
| 616 | + * @throws EE_Error |
|
| 617 | + */ |
|
| 618 | + public function get_most_recent_registration_for_event($event_id) |
|
| 619 | + { |
|
| 620 | + return $this->get_first_related( |
|
| 621 | + 'Registration', |
|
| 622 | + array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')) |
|
| 623 | + ); |
|
| 624 | + } |
|
| 625 | + |
|
| 626 | + |
|
| 627 | + /** |
|
| 628 | + * returns any events attached to this attendee ($_Event property); |
|
| 629 | + * |
|
| 630 | + * @return array |
|
| 631 | + * @throws EE_Error |
|
| 632 | + */ |
|
| 633 | + public function events() |
|
| 634 | + { |
|
| 635 | + return $this->get_many_related('Event'); |
|
| 636 | + } |
|
| 637 | + |
|
| 638 | + |
|
| 639 | + /** |
|
| 640 | + * Gets the billing info array where keys match espresso_reg_page_billing_inputs(), |
|
| 641 | + * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was |
|
| 642 | + * used to save the billing info |
|
| 643 | + * |
|
| 644 | + * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class |
|
| 645 | + * @return EE_Form_Section_Proper|null |
|
| 646 | + * @throws EE_Error |
|
| 647 | + */ |
|
| 648 | + public function billing_info_for_payment_method($payment_method) |
|
| 649 | + { |
|
| 650 | + $pm_type = $payment_method->type_obj(); |
|
| 651 | + if (! $pm_type instanceof EE_PMT_Base) { |
|
| 652 | + return null; |
|
| 653 | + } |
|
| 654 | + $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true); |
|
| 655 | + if (! $billing_info) { |
|
| 656 | + return null; |
|
| 657 | + } |
|
| 658 | + $billing_form = $pm_type->billing_form(); |
|
| 659 | + // double-check the form isn't totally hidden, in which case pretend there is no form |
|
| 660 | + $form_totally_hidden = true; |
|
| 661 | + foreach ($billing_form->inputs_in_subsections() as $input) { |
|
| 662 | + if (! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) { |
|
| 663 | + $form_totally_hidden = false; |
|
| 664 | + break; |
|
| 665 | + } |
|
| 666 | + } |
|
| 667 | + if ($form_totally_hidden) { |
|
| 668 | + return null; |
|
| 669 | + } |
|
| 670 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
| 671 | + $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false); |
|
| 672 | + } |
|
| 673 | + |
|
| 674 | + return $billing_form; |
|
| 675 | + } |
|
| 676 | + |
|
| 677 | + |
|
| 678 | + /** |
|
| 679 | + * Gets the postmeta key that holds this attendee's billing info for the |
|
| 680 | + * specified payment method |
|
| 681 | + * |
|
| 682 | + * @param EE_Payment_Method $payment_method |
|
| 683 | + * @return string |
|
| 684 | + * @throws EE_Error |
|
| 685 | + */ |
|
| 686 | + public function get_billing_info_postmeta_name($payment_method) |
|
| 687 | + { |
|
| 688 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
| 689 | + return 'billing_info_' . $payment_method->type_obj()->system_name(); |
|
| 690 | + } |
|
| 691 | + return null; |
|
| 692 | + } |
|
| 693 | + |
|
| 694 | + |
|
| 695 | + /** |
|
| 696 | + * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to |
|
| 697 | + * retrieve it |
|
| 698 | + * |
|
| 699 | + * @param EE_Billing_Attendee_Info_Form $billing_form |
|
| 700 | + * @param EE_Payment_Method $payment_method |
|
| 701 | + * @return boolean |
|
| 702 | + * @throws EE_Error |
|
| 703 | + */ |
|
| 704 | + public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method) |
|
| 705 | + { |
|
| 706 | + if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) { |
|
| 707 | + EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso')); |
|
| 708 | + return false; |
|
| 709 | + } |
|
| 710 | + $billing_form->clean_sensitive_data(); |
|
| 711 | + return update_post_meta( |
|
| 712 | + $this->ID(), |
|
| 713 | + $this->get_billing_info_postmeta_name($payment_method), |
|
| 714 | + $billing_form->input_values(true) |
|
| 715 | + ); |
|
| 716 | + } |
|
| 717 | + |
|
| 718 | + |
|
| 719 | + /** |
|
| 720 | + * Return the link to the admin details for the object. |
|
| 721 | + * |
|
| 722 | + * @return string |
|
| 723 | + * @throws EE_Error |
|
| 724 | + * @throws InvalidArgumentException |
|
| 725 | + * @throws InvalidDataTypeException |
|
| 726 | + * @throws InvalidInterfaceException |
|
| 727 | + * @throws ReflectionException |
|
| 728 | + */ |
|
| 729 | + public function get_admin_details_link() |
|
| 730 | + { |
|
| 731 | + return $this->get_admin_edit_link(); |
|
| 732 | + } |
|
| 733 | + |
|
| 734 | + |
|
| 735 | + /** |
|
| 736 | + * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
| 737 | + * |
|
| 738 | + * @return string |
|
| 739 | + * @throws EE_Error |
|
| 740 | + * @throws InvalidArgumentException |
|
| 741 | + * @throws ReflectionException |
|
| 742 | + * @throws InvalidDataTypeException |
|
| 743 | + * @throws InvalidInterfaceException |
|
| 744 | + */ |
|
| 745 | + public function get_admin_edit_link() |
|
| 746 | + { |
|
| 747 | + EE_Registry::instance()->load_helper('URL'); |
|
| 748 | + return EEH_URL::add_query_args_and_nonce( |
|
| 749 | + array( |
|
| 750 | + 'page' => 'espresso_registrations', |
|
| 751 | + 'action' => 'edit_attendee', |
|
| 752 | + 'post' => $this->ID(), |
|
| 753 | + ), |
|
| 754 | + admin_url('admin.php') |
|
| 755 | + ); |
|
| 756 | + } |
|
| 757 | + |
|
| 758 | + |
|
| 759 | + /** |
|
| 760 | + * Returns the link to a settings page for the object. |
|
| 761 | + * |
|
| 762 | + * @return string |
|
| 763 | + * @throws EE_Error |
|
| 764 | + * @throws InvalidArgumentException |
|
| 765 | + * @throws InvalidDataTypeException |
|
| 766 | + * @throws InvalidInterfaceException |
|
| 767 | + * @throws ReflectionException |
|
| 768 | + */ |
|
| 769 | + public function get_admin_settings_link() |
|
| 770 | + { |
|
| 771 | + return $this->get_admin_edit_link(); |
|
| 772 | + } |
|
| 773 | + |
|
| 774 | + |
|
| 775 | + /** |
|
| 776 | + * Returns the link to the "overview" for the object (typically the "list table" view). |
|
| 777 | + * |
|
| 778 | + * @return string |
|
| 779 | + * @throws EE_Error |
|
| 780 | + * @throws InvalidArgumentException |
|
| 781 | + * @throws ReflectionException |
|
| 782 | + * @throws InvalidDataTypeException |
|
| 783 | + * @throws InvalidInterfaceException |
|
| 784 | + */ |
|
| 785 | + public function get_admin_overview_link() |
|
| 786 | + { |
|
| 787 | + EE_Registry::instance()->load_helper('URL'); |
|
| 788 | + return EEH_URL::add_query_args_and_nonce( |
|
| 789 | + array( |
|
| 790 | + 'page' => 'espresso_registrations', |
|
| 791 | + 'action' => 'contact_list', |
|
| 792 | + ), |
|
| 793 | + admin_url('admin.php') |
|
| 794 | + ); |
|
| 795 | + } |
|
| 796 | 796 | } |
@@ -9,30 +9,30 @@ |
||
| 9 | 9 | class EE_Datetime_Ticket extends EE_Base_Class |
| 10 | 10 | { |
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * |
|
| 14 | - * @param array $props_n_values incoming values |
|
| 15 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 16 | - * used.) |
|
| 17 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 18 | - * date_format and the second value is the time format |
|
| 19 | - * @return EE_Attendee |
|
| 20 | - */ |
|
| 21 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
| 22 | - { |
|
| 23 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 24 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 25 | - } |
|
| 12 | + /** |
|
| 13 | + * |
|
| 14 | + * @param array $props_n_values incoming values |
|
| 15 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 16 | + * used.) |
|
| 17 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 18 | + * date_format and the second value is the time format |
|
| 19 | + * @return EE_Attendee |
|
| 20 | + */ |
|
| 21 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
| 22 | + { |
|
| 23 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 24 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @param array $props_n_values incoming values from the database |
|
| 30 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 31 | - * the website will be used. |
|
| 32 | - * @return EE_Attendee |
|
| 33 | - */ |
|
| 34 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 35 | - { |
|
| 36 | - return new self($props_n_values, true, $timezone); |
|
| 37 | - } |
|
| 28 | + /** |
|
| 29 | + * @param array $props_n_values incoming values from the database |
|
| 30 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 31 | + * the website will be used. |
|
| 32 | + * @return EE_Attendee |
|
| 33 | + */ |
|
| 34 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 35 | + { |
|
| 36 | + return new self($props_n_values, true, $timezone); |
|
| 37 | + } |
|
| 38 | 38 | } |
@@ -12,25 +12,25 @@ |
||
| 12 | 12 | class EE_Event_Message_Template extends EE_Base_Class |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @param array $props_n_values |
|
| 17 | - * @param null $timezone |
|
| 18 | - * @return EE_Event_Message_Template|mixed |
|
| 19 | - */ |
|
| 20 | - public static function new_instance($props_n_values = array(), $timezone = null) |
|
| 21 | - { |
|
| 22 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone); |
|
| 23 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone); |
|
| 24 | - } |
|
| 15 | + /** |
|
| 16 | + * @param array $props_n_values |
|
| 17 | + * @param null $timezone |
|
| 18 | + * @return EE_Event_Message_Template|mixed |
|
| 19 | + */ |
|
| 20 | + public static function new_instance($props_n_values = array(), $timezone = null) |
|
| 21 | + { |
|
| 22 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone); |
|
| 23 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @param array $props_n_values |
|
| 29 | - * @param null $timezone |
|
| 30 | - * @return EE_Event_Message_Template |
|
| 31 | - */ |
|
| 32 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 33 | - { |
|
| 34 | - return new self($props_n_values, true, $timezone); |
|
| 35 | - } |
|
| 27 | + /** |
|
| 28 | + * @param array $props_n_values |
|
| 29 | + * @param null $timezone |
|
| 30 | + * @return EE_Event_Message_Template |
|
| 31 | + */ |
|
| 32 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 33 | + { |
|
| 34 | + return new self($props_n_values, true, $timezone); |
|
| 35 | + } |
|
| 36 | 36 | } |
@@ -11,217 +11,217 @@ |
||
| 11 | 11 | class EE_Change_Log extends EE_Base_Class |
| 12 | 12 | { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * @param array $props_n_values incoming values |
|
| 16 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 17 | - * used.) |
|
| 18 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 19 | - * date_format and the second value is the time format |
|
| 20 | - * @return EE_Change_Log |
|
| 21 | - * @throws EE_Error |
|
| 22 | - */ |
|
| 23 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
| 24 | - { |
|
| 25 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 26 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * @param array $props_n_values incoming values from the database |
|
| 32 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 33 | - * the website will be used. |
|
| 34 | - * @return EE_Change_Log |
|
| 35 | - */ |
|
| 36 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 37 | - { |
|
| 38 | - return new self($props_n_values, true, $timezone); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * Gets message |
|
| 43 | - * |
|
| 44 | - * @return mixed |
|
| 45 | - * @throws EE_Error |
|
| 46 | - */ |
|
| 47 | - public function message() |
|
| 48 | - { |
|
| 49 | - return $this->get('LOG_message'); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Sets message |
|
| 54 | - * |
|
| 55 | - * @param mixed $message |
|
| 56 | - * @throws EE_Error |
|
| 57 | - */ |
|
| 58 | - public function set_message($message) |
|
| 59 | - { |
|
| 60 | - $this->set('LOG_message', $message); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Gets time |
|
| 65 | - * |
|
| 66 | - * @return string |
|
| 67 | - * @throws EE_Error |
|
| 68 | - */ |
|
| 69 | - public function time() |
|
| 70 | - { |
|
| 71 | - return $this->get('LOG_time'); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * Sets time |
|
| 76 | - * |
|
| 77 | - * @param string $time |
|
| 78 | - * @throws EE_Error |
|
| 79 | - */ |
|
| 80 | - public function set_time($time) |
|
| 81 | - { |
|
| 82 | - $this->set('LOG_time', $time); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Gets log_type |
|
| 87 | - * |
|
| 88 | - * @return string |
|
| 89 | - * @throws EE_Error |
|
| 90 | - */ |
|
| 91 | - public function log_type() |
|
| 92 | - { |
|
| 93 | - return $this->get('LOG_type'); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * Return the localized log type label. |
|
| 99 | - * |
|
| 100 | - * @return string |
|
| 101 | - * @throws EE_Error |
|
| 102 | - */ |
|
| 103 | - public function log_type_label() |
|
| 104 | - { |
|
| 105 | - return EEM_Change_Log::get_pretty_label_for_type($this->log_type()); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * Sets log_type |
|
| 110 | - * |
|
| 111 | - * @param string $log_type |
|
| 112 | - * @throws EE_Error |
|
| 113 | - */ |
|
| 114 | - public function set_log_type($log_type) |
|
| 115 | - { |
|
| 116 | - $this->set('LOG_type', $log_type); |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * Gets type of the model object related to this log |
|
| 121 | - * |
|
| 122 | - * @return string |
|
| 123 | - * @throws EE_Error |
|
| 124 | - */ |
|
| 125 | - public function OBJ_type() |
|
| 126 | - { |
|
| 127 | - return $this->get('OBJ_type'); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * Sets type |
|
| 132 | - * |
|
| 133 | - * @param string $type |
|
| 134 | - * @throws EE_Error |
|
| 135 | - */ |
|
| 136 | - public function set_OBJ_type($type) |
|
| 137 | - { |
|
| 138 | - $this->set('OBJ_type', $type); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * Gets OBJ_ID (the ID of the item related to this log) |
|
| 143 | - * |
|
| 144 | - * @return mixed |
|
| 145 | - * @throws EE_Error |
|
| 146 | - */ |
|
| 147 | - public function OBJ_ID() |
|
| 148 | - { |
|
| 149 | - return $this->get('OBJ_ID'); |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - /** |
|
| 153 | - * Sets OBJ_ID |
|
| 154 | - * |
|
| 155 | - * @param mixed $OBJ_ID |
|
| 156 | - * @throws EE_Error |
|
| 157 | - */ |
|
| 158 | - public function set_OBJ_ID($OBJ_ID) |
|
| 159 | - { |
|
| 160 | - $this->set('OBJ_ID', $OBJ_ID); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * Gets wp_user |
|
| 165 | - * |
|
| 166 | - * @return int |
|
| 167 | - * @throws EE_Error |
|
| 168 | - */ |
|
| 169 | - public function wp_user() |
|
| 170 | - { |
|
| 171 | - return $this->get('LOG_wp_user'); |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * Sets wp_user |
|
| 176 | - * |
|
| 177 | - * @param int $wp_user_id |
|
| 178 | - * @throws EE_Error |
|
| 179 | - */ |
|
| 180 | - public function set_wp_user($wp_user_id) |
|
| 181 | - { |
|
| 182 | - $this->set('LOG_wp_user', $wp_user_id); |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - /** |
|
| 186 | - * Gets the model object attached to this log |
|
| 187 | - * |
|
| 188 | - * @return EE_Base_Class |
|
| 189 | - * @throws EE_Error |
|
| 190 | - */ |
|
| 191 | - public function object() |
|
| 192 | - { |
|
| 193 | - $model_name_of_related_obj = $this->OBJ_type(); |
|
| 194 | - $is_model_name = EE_Registry::instance()->is_model_name($model_name_of_related_obj); |
|
| 195 | - if (! $is_model_name) { |
|
| 196 | - return null; |
|
| 197 | - } else { |
|
| 198 | - return $this->get_first_related($model_name_of_related_obj); |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * Shorthand for setting the OBJ_ID and OBJ_type. Slightly handier than using |
|
| 204 | - * _add_relation_to because you don't have to specify what type of model you're |
|
| 205 | - * associating it with |
|
| 206 | - * |
|
| 207 | - * @param EE_Base_Class $object |
|
| 208 | - * @param boolean $save |
|
| 209 | - * @return bool if $save=true, NULL is $save=false |
|
| 210 | - * @throws EE_Error |
|
| 211 | - */ |
|
| 212 | - public function set_object($object, $save = true) |
|
| 213 | - { |
|
| 214 | - if ($object instanceof EE_Base_Class) { |
|
| 215 | - $this->set_OBJ_type($object->get_model()->get_this_model_name()); |
|
| 216 | - $this->set_OBJ_ID($object->ID()); |
|
| 217 | - } else { |
|
| 218 | - $this->set_OBJ_type(null); |
|
| 219 | - $this->set_OBJ_ID(null); |
|
| 220 | - } |
|
| 221 | - if ($save) { |
|
| 222 | - return $this->save(); |
|
| 223 | - } else { |
|
| 224 | - return null; |
|
| 225 | - } |
|
| 226 | - } |
|
| 14 | + /** |
|
| 15 | + * @param array $props_n_values incoming values |
|
| 16 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 17 | + * used.) |
|
| 18 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 19 | + * date_format and the second value is the time format |
|
| 20 | + * @return EE_Change_Log |
|
| 21 | + * @throws EE_Error |
|
| 22 | + */ |
|
| 23 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
| 24 | + { |
|
| 25 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 26 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @param array $props_n_values incoming values from the database |
|
| 32 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 33 | + * the website will be used. |
|
| 34 | + * @return EE_Change_Log |
|
| 35 | + */ |
|
| 36 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 37 | + { |
|
| 38 | + return new self($props_n_values, true, $timezone); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * Gets message |
|
| 43 | + * |
|
| 44 | + * @return mixed |
|
| 45 | + * @throws EE_Error |
|
| 46 | + */ |
|
| 47 | + public function message() |
|
| 48 | + { |
|
| 49 | + return $this->get('LOG_message'); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Sets message |
|
| 54 | + * |
|
| 55 | + * @param mixed $message |
|
| 56 | + * @throws EE_Error |
|
| 57 | + */ |
|
| 58 | + public function set_message($message) |
|
| 59 | + { |
|
| 60 | + $this->set('LOG_message', $message); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Gets time |
|
| 65 | + * |
|
| 66 | + * @return string |
|
| 67 | + * @throws EE_Error |
|
| 68 | + */ |
|
| 69 | + public function time() |
|
| 70 | + { |
|
| 71 | + return $this->get('LOG_time'); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * Sets time |
|
| 76 | + * |
|
| 77 | + * @param string $time |
|
| 78 | + * @throws EE_Error |
|
| 79 | + */ |
|
| 80 | + public function set_time($time) |
|
| 81 | + { |
|
| 82 | + $this->set('LOG_time', $time); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Gets log_type |
|
| 87 | + * |
|
| 88 | + * @return string |
|
| 89 | + * @throws EE_Error |
|
| 90 | + */ |
|
| 91 | + public function log_type() |
|
| 92 | + { |
|
| 93 | + return $this->get('LOG_type'); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * Return the localized log type label. |
|
| 99 | + * |
|
| 100 | + * @return string |
|
| 101 | + * @throws EE_Error |
|
| 102 | + */ |
|
| 103 | + public function log_type_label() |
|
| 104 | + { |
|
| 105 | + return EEM_Change_Log::get_pretty_label_for_type($this->log_type()); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * Sets log_type |
|
| 110 | + * |
|
| 111 | + * @param string $log_type |
|
| 112 | + * @throws EE_Error |
|
| 113 | + */ |
|
| 114 | + public function set_log_type($log_type) |
|
| 115 | + { |
|
| 116 | + $this->set('LOG_type', $log_type); |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * Gets type of the model object related to this log |
|
| 121 | + * |
|
| 122 | + * @return string |
|
| 123 | + * @throws EE_Error |
|
| 124 | + */ |
|
| 125 | + public function OBJ_type() |
|
| 126 | + { |
|
| 127 | + return $this->get('OBJ_type'); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * Sets type |
|
| 132 | + * |
|
| 133 | + * @param string $type |
|
| 134 | + * @throws EE_Error |
|
| 135 | + */ |
|
| 136 | + public function set_OBJ_type($type) |
|
| 137 | + { |
|
| 138 | + $this->set('OBJ_type', $type); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * Gets OBJ_ID (the ID of the item related to this log) |
|
| 143 | + * |
|
| 144 | + * @return mixed |
|
| 145 | + * @throws EE_Error |
|
| 146 | + */ |
|
| 147 | + public function OBJ_ID() |
|
| 148 | + { |
|
| 149 | + return $this->get('OBJ_ID'); |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + /** |
|
| 153 | + * Sets OBJ_ID |
|
| 154 | + * |
|
| 155 | + * @param mixed $OBJ_ID |
|
| 156 | + * @throws EE_Error |
|
| 157 | + */ |
|
| 158 | + public function set_OBJ_ID($OBJ_ID) |
|
| 159 | + { |
|
| 160 | + $this->set('OBJ_ID', $OBJ_ID); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * Gets wp_user |
|
| 165 | + * |
|
| 166 | + * @return int |
|
| 167 | + * @throws EE_Error |
|
| 168 | + */ |
|
| 169 | + public function wp_user() |
|
| 170 | + { |
|
| 171 | + return $this->get('LOG_wp_user'); |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * Sets wp_user |
|
| 176 | + * |
|
| 177 | + * @param int $wp_user_id |
|
| 178 | + * @throws EE_Error |
|
| 179 | + */ |
|
| 180 | + public function set_wp_user($wp_user_id) |
|
| 181 | + { |
|
| 182 | + $this->set('LOG_wp_user', $wp_user_id); |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + /** |
|
| 186 | + * Gets the model object attached to this log |
|
| 187 | + * |
|
| 188 | + * @return EE_Base_Class |
|
| 189 | + * @throws EE_Error |
|
| 190 | + */ |
|
| 191 | + public function object() |
|
| 192 | + { |
|
| 193 | + $model_name_of_related_obj = $this->OBJ_type(); |
|
| 194 | + $is_model_name = EE_Registry::instance()->is_model_name($model_name_of_related_obj); |
|
| 195 | + if (! $is_model_name) { |
|
| 196 | + return null; |
|
| 197 | + } else { |
|
| 198 | + return $this->get_first_related($model_name_of_related_obj); |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * Shorthand for setting the OBJ_ID and OBJ_type. Slightly handier than using |
|
| 204 | + * _add_relation_to because you don't have to specify what type of model you're |
|
| 205 | + * associating it with |
|
| 206 | + * |
|
| 207 | + * @param EE_Base_Class $object |
|
| 208 | + * @param boolean $save |
|
| 209 | + * @return bool if $save=true, NULL is $save=false |
|
| 210 | + * @throws EE_Error |
|
| 211 | + */ |
|
| 212 | + public function set_object($object, $save = true) |
|
| 213 | + { |
|
| 214 | + if ($object instanceof EE_Base_Class) { |
|
| 215 | + $this->set_OBJ_type($object->get_model()->get_this_model_name()); |
|
| 216 | + $this->set_OBJ_ID($object->ID()); |
|
| 217 | + } else { |
|
| 218 | + $this->set_OBJ_type(null); |
|
| 219 | + $this->set_OBJ_ID(null); |
|
| 220 | + } |
|
| 221 | + if ($save) { |
|
| 222 | + return $this->save(); |
|
| 223 | + } else { |
|
| 224 | + return null; |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | 227 | } |
@@ -192,7 +192,7 @@ |
||
| 192 | 192 | { |
| 193 | 193 | $model_name_of_related_obj = $this->OBJ_type(); |
| 194 | 194 | $is_model_name = EE_Registry::instance()->is_model_name($model_name_of_related_obj); |
| 195 | - if (! $is_model_name) { |
|
| 195 | + if ( ! $is_model_name) { |
|
| 196 | 196 | return null; |
| 197 | 197 | } else { |
| 198 | 198 | return $this->get_first_related($model_name_of_related_obj); |
@@ -36,88 +36,88 @@ |
||
| 36 | 36 | class EE_Line_Item_Filter_Processor |
| 37 | 37 | { |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @type EE_Line_Item_Filter_Collection $line_item_filters |
|
| 41 | - */ |
|
| 42 | - protected $line_item_filters; |
|
| 39 | + /** |
|
| 40 | + * @type EE_Line_Item_Filter_Collection $line_item_filters |
|
| 41 | + */ |
|
| 42 | + protected $line_item_filters; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @type EEI_Line_Item $grand_total_line_item |
|
| 46 | - */ |
|
| 47 | - protected $grand_total_line_item; |
|
| 44 | + /** |
|
| 45 | + * @type EEI_Line_Item $grand_total_line_item |
|
| 46 | + */ |
|
| 47 | + protected $grand_total_line_item; |
|
| 48 | 48 | |
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * EE_Line_Item_Filter_Processor constructor. |
|
| 52 | - * |
|
| 53 | - * @param \EE_Line_Item_Filter_Collection $line_item_filters |
|
| 54 | - * @param \EEI_Line_Item $grand_total_line_item |
|
| 55 | - * @throws \EE_Error |
|
| 56 | - */ |
|
| 57 | - public function __construct(EE_Line_Item_Filter_Collection $line_item_filters, EEI_Line_Item $grand_total_line_item) |
|
| 58 | - { |
|
| 59 | - $this->line_item_filters = $line_item_filters; |
|
| 60 | - if ($grand_total_line_item->type() !== EEM_Line_Item::type_total) { |
|
| 61 | - throw new EE_Error(__('A Line Item of the type total is required', 'event_espresso')); |
|
| 62 | - } |
|
| 63 | - $this->grand_total_line_item = $this->clone_and_reset_line_item_tree($grand_total_line_item); |
|
| 64 | - } |
|
| 50 | + /** |
|
| 51 | + * EE_Line_Item_Filter_Processor constructor. |
|
| 52 | + * |
|
| 53 | + * @param \EE_Line_Item_Filter_Collection $line_item_filters |
|
| 54 | + * @param \EEI_Line_Item $grand_total_line_item |
|
| 55 | + * @throws \EE_Error |
|
| 56 | + */ |
|
| 57 | + public function __construct(EE_Line_Item_Filter_Collection $line_item_filters, EEI_Line_Item $grand_total_line_item) |
|
| 58 | + { |
|
| 59 | + $this->line_item_filters = $line_item_filters; |
|
| 60 | + if ($grand_total_line_item->type() !== EEM_Line_Item::type_total) { |
|
| 61 | + throw new EE_Error(__('A Line Item of the type total is required', 'event_espresso')); |
|
| 62 | + } |
|
| 63 | + $this->grand_total_line_item = $this->clone_and_reset_line_item_tree($grand_total_line_item); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * clone_and_reset_line_item_tree |
|
| 69 | - * |
|
| 70 | - * @param \EEI_Line_Item $line_item |
|
| 71 | - * @return \EEI_Line_Item |
|
| 72 | - */ |
|
| 73 | - protected function clone_and_reset_line_item_tree(EEI_Line_Item $line_item) |
|
| 74 | - { |
|
| 75 | - $cloned_line_item = $this->clone_and_reset_line_item($line_item); |
|
| 76 | - foreach ($line_item->children() as $child_line_item) { |
|
| 77 | - $cloned_line_item->add_child_line_item($this->clone_and_reset_line_item_tree($child_line_item)); |
|
| 78 | - } |
|
| 79 | - return $cloned_line_item; |
|
| 80 | - } |
|
| 67 | + /** |
|
| 68 | + * clone_and_reset_line_item_tree |
|
| 69 | + * |
|
| 70 | + * @param \EEI_Line_Item $line_item |
|
| 71 | + * @return \EEI_Line_Item |
|
| 72 | + */ |
|
| 73 | + protected function clone_and_reset_line_item_tree(EEI_Line_Item $line_item) |
|
| 74 | + { |
|
| 75 | + $cloned_line_item = $this->clone_and_reset_line_item($line_item); |
|
| 76 | + foreach ($line_item->children() as $child_line_item) { |
|
| 77 | + $cloned_line_item->add_child_line_item($this->clone_and_reset_line_item_tree($child_line_item)); |
|
| 78 | + } |
|
| 79 | + return $cloned_line_item; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * clone_and_reset_line_item |
|
| 85 | - * |
|
| 86 | - * clones the incoming object |
|
| 87 | - * resets any fields that represent database primary keys |
|
| 88 | - * resets total |
|
| 89 | - * |
|
| 90 | - * @param \EEI_Line_Item $line_item |
|
| 91 | - * @return \EEI_Line_Item |
|
| 92 | - */ |
|
| 93 | - protected function clone_and_reset_line_item(EEI_Line_Item $line_item) |
|
| 94 | - { |
|
| 95 | - // we don't actually want to work with the original line item, so clone it |
|
| 96 | - $cloned_line_item = clone $line_item; |
|
| 97 | - $cloned_line_item->set('LIN_ID', null); |
|
| 98 | - $cloned_line_item->set('LIN_parent', null); |
|
| 99 | - $cloned_line_item->clear_related_line_item_cache(); |
|
| 100 | - foreach (array_keys(EEM_Line_Item::instance()->relation_settings()) as $relation_name) { |
|
| 101 | - $cloned_line_item->clear_cache($relation_name, null, true); |
|
| 102 | - } |
|
| 103 | - $cloned_line_item->set_allow_persist(false); |
|
| 104 | - return $cloned_line_item; |
|
| 105 | - } |
|
| 83 | + /** |
|
| 84 | + * clone_and_reset_line_item |
|
| 85 | + * |
|
| 86 | + * clones the incoming object |
|
| 87 | + * resets any fields that represent database primary keys |
|
| 88 | + * resets total |
|
| 89 | + * |
|
| 90 | + * @param \EEI_Line_Item $line_item |
|
| 91 | + * @return \EEI_Line_Item |
|
| 92 | + */ |
|
| 93 | + protected function clone_and_reset_line_item(EEI_Line_Item $line_item) |
|
| 94 | + { |
|
| 95 | + // we don't actually want to work with the original line item, so clone it |
|
| 96 | + $cloned_line_item = clone $line_item; |
|
| 97 | + $cloned_line_item->set('LIN_ID', null); |
|
| 98 | + $cloned_line_item->set('LIN_parent', null); |
|
| 99 | + $cloned_line_item->clear_related_line_item_cache(); |
|
| 100 | + foreach (array_keys(EEM_Line_Item::instance()->relation_settings()) as $relation_name) { |
|
| 101 | + $cloned_line_item->clear_cache($relation_name, null, true); |
|
| 102 | + } |
|
| 103 | + $cloned_line_item->set_allow_persist(false); |
|
| 104 | + return $cloned_line_item; |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * process |
|
| 110 | - * |
|
| 111 | - * @return EEI_Line_Item |
|
| 112 | - */ |
|
| 113 | - public function process() |
|
| 114 | - { |
|
| 115 | - $this->line_item_filters->rewind(); |
|
| 116 | - while ($this->line_item_filters->valid()) { |
|
| 117 | - $this->grand_total_line_item = $this->line_item_filters->current()->process($this->grand_total_line_item); |
|
| 118 | - $this->line_item_filters->next(); |
|
| 119 | - } |
|
| 120 | - $this->grand_total_line_item->recalculate_total_including_taxes(); |
|
| 121 | - return $this->grand_total_line_item; |
|
| 122 | - } |
|
| 108 | + /** |
|
| 109 | + * process |
|
| 110 | + * |
|
| 111 | + * @return EEI_Line_Item |
|
| 112 | + */ |
|
| 113 | + public function process() |
|
| 114 | + { |
|
| 115 | + $this->line_item_filters->rewind(); |
|
| 116 | + while ($this->line_item_filters->valid()) { |
|
| 117 | + $this->grand_total_line_item = $this->line_item_filters->current()->process($this->grand_total_line_item); |
|
| 118 | + $this->line_item_filters->next(); |
|
| 119 | + } |
|
| 120 | + $this->grand_total_line_item->recalculate_total_including_taxes(); |
|
| 121 | + return $this->grand_total_line_item; |
|
| 122 | + } |
|
| 123 | 123 | } |
@@ -14,96 +14,96 @@ |
||
| 14 | 14 | class EE_Non_Zero_Line_Item_Filter extends EE_Line_Item_Filter_Base |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * EE_Non_Zero_Line_Item_Filter constructor. |
|
| 19 | - */ |
|
| 20 | - public function __construct() |
|
| 21 | - { |
|
| 22 | - } |
|
| 17 | + /** |
|
| 18 | + * EE_Non_Zero_Line_Item_Filter constructor. |
|
| 19 | + */ |
|
| 20 | + public function __construct() |
|
| 21 | + { |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Creates a duplicate of the line item tree, except only includes billable items |
|
| 27 | - * and the portion of line items attributed to billable things |
|
| 28 | - * |
|
| 29 | - * @param EEI_Line_Item $line_item |
|
| 30 | - * @return EEI_Line_Item |
|
| 31 | - */ |
|
| 32 | - public function process(EEI_Line_Item $line_item) |
|
| 33 | - { |
|
| 34 | - $non_zero_line_item = $this->_filter_zero_line_item($line_item); |
|
| 35 | - if (! $non_zero_line_item instanceof EEI_Line_Item) { |
|
| 36 | - return null; |
|
| 37 | - } |
|
| 38 | - // if this is an event subtotal, we want to only include it if it |
|
| 39 | - // has a non-zero total and at least one ticket line item child |
|
| 40 | - if ($line_item->children()) { |
|
| 41 | - $ticket_or_subtotals_with_tkt_children_count = 0; |
|
| 42 | - foreach ($line_item->children() as $child_line_item) { |
|
| 43 | - $code = $child_line_item->code(); |
|
| 44 | - $child_line_item = $this->process($child_line_item); |
|
| 45 | - if (! $child_line_item instanceof EEI_Line_Item) { |
|
| 46 | - $line_item->delete_child_line_item($code); |
|
| 47 | - continue; |
|
| 48 | - } |
|
| 49 | - if (( |
|
| 50 | - $child_line_item instanceof EEI_Line_Item |
|
| 51 | - && $child_line_item->type() === EEM_Line_Item::type_sub_total |
|
| 52 | - ) |
|
| 53 | - || ( |
|
| 54 | - $child_line_item instanceof EEI_Line_Item |
|
| 55 | - && $child_line_item->type() === EEM_Line_Item::type_line_item |
|
| 56 | - && $child_line_item->OBJ_type() === 'Ticket' |
|
| 57 | - ) |
|
| 58 | - ) { |
|
| 59 | - $ticket_or_subtotals_with_tkt_children_count++; |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - // if this is an event subtotal with NO ticket children |
|
| 63 | - // we basically want to ignore it |
|
| 64 | - return $this->_filter_zero_subtotal_line_item( |
|
| 65 | - $non_zero_line_item, |
|
| 66 | - $ticket_or_subtotals_with_tkt_children_count |
|
| 67 | - ); |
|
| 68 | - } |
|
| 69 | - return $non_zero_line_item; |
|
| 70 | - } |
|
| 25 | + /** |
|
| 26 | + * Creates a duplicate of the line item tree, except only includes billable items |
|
| 27 | + * and the portion of line items attributed to billable things |
|
| 28 | + * |
|
| 29 | + * @param EEI_Line_Item $line_item |
|
| 30 | + * @return EEI_Line_Item |
|
| 31 | + */ |
|
| 32 | + public function process(EEI_Line_Item $line_item) |
|
| 33 | + { |
|
| 34 | + $non_zero_line_item = $this->_filter_zero_line_item($line_item); |
|
| 35 | + if (! $non_zero_line_item instanceof EEI_Line_Item) { |
|
| 36 | + return null; |
|
| 37 | + } |
|
| 38 | + // if this is an event subtotal, we want to only include it if it |
|
| 39 | + // has a non-zero total and at least one ticket line item child |
|
| 40 | + if ($line_item->children()) { |
|
| 41 | + $ticket_or_subtotals_with_tkt_children_count = 0; |
|
| 42 | + foreach ($line_item->children() as $child_line_item) { |
|
| 43 | + $code = $child_line_item->code(); |
|
| 44 | + $child_line_item = $this->process($child_line_item); |
|
| 45 | + if (! $child_line_item instanceof EEI_Line_Item) { |
|
| 46 | + $line_item->delete_child_line_item($code); |
|
| 47 | + continue; |
|
| 48 | + } |
|
| 49 | + if (( |
|
| 50 | + $child_line_item instanceof EEI_Line_Item |
|
| 51 | + && $child_line_item->type() === EEM_Line_Item::type_sub_total |
|
| 52 | + ) |
|
| 53 | + || ( |
|
| 54 | + $child_line_item instanceof EEI_Line_Item |
|
| 55 | + && $child_line_item->type() === EEM_Line_Item::type_line_item |
|
| 56 | + && $child_line_item->OBJ_type() === 'Ticket' |
|
| 57 | + ) |
|
| 58 | + ) { |
|
| 59 | + $ticket_or_subtotals_with_tkt_children_count++; |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + // if this is an event subtotal with NO ticket children |
|
| 63 | + // we basically want to ignore it |
|
| 64 | + return $this->_filter_zero_subtotal_line_item( |
|
| 65 | + $non_zero_line_item, |
|
| 66 | + $ticket_or_subtotals_with_tkt_children_count |
|
| 67 | + ); |
|
| 68 | + } |
|
| 69 | + return $non_zero_line_item; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Creates a new, unsaved line item, but if it's a ticket line item |
|
| 75 | - * with a total of 0, or a subtotal of 0, returns null instead |
|
| 76 | - * |
|
| 77 | - * @param EEI_Line_Item $line_item |
|
| 78 | - * @return EEI_Line_Item |
|
| 79 | - */ |
|
| 80 | - protected function _filter_zero_line_item(EEI_Line_Item $line_item) |
|
| 81 | - { |
|
| 82 | - if ($line_item->type() === EEM_Line_Item::type_line_item |
|
| 83 | - && $line_item->OBJ_type() === 'Ticket' |
|
| 84 | - && (int) $line_item->quantity() === 0 |
|
| 85 | - ) { |
|
| 86 | - return null; |
|
| 87 | - } |
|
| 88 | - return $line_item; |
|
| 89 | - } |
|
| 73 | + /** |
|
| 74 | + * Creates a new, unsaved line item, but if it's a ticket line item |
|
| 75 | + * with a total of 0, or a subtotal of 0, returns null instead |
|
| 76 | + * |
|
| 77 | + * @param EEI_Line_Item $line_item |
|
| 78 | + * @return EEI_Line_Item |
|
| 79 | + */ |
|
| 80 | + protected function _filter_zero_line_item(EEI_Line_Item $line_item) |
|
| 81 | + { |
|
| 82 | + if ($line_item->type() === EEM_Line_Item::type_line_item |
|
| 83 | + && $line_item->OBJ_type() === 'Ticket' |
|
| 84 | + && (int) $line_item->quantity() === 0 |
|
| 85 | + ) { |
|
| 86 | + return null; |
|
| 87 | + } |
|
| 88 | + return $line_item; |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * Creates a new, unsaved line item, but if it's a ticket line item |
|
| 94 | - * with a total of 0, or a subtotal of 0, returns null instead |
|
| 95 | - * |
|
| 96 | - * @param EEI_Line_Item $line_item |
|
| 97 | - * @param int $ticket_children |
|
| 98 | - * @return EEI_Line_Item |
|
| 99 | - */ |
|
| 100 | - protected function _filter_zero_subtotal_line_item(EEI_Line_Item $line_item, $ticket_children = 0) |
|
| 101 | - { |
|
| 102 | - if ((int) $ticket_children === 0 |
|
| 103 | - && $line_item->type() === EEM_Line_Item::type_sub_total |
|
| 104 | - ) { |
|
| 105 | - return null; |
|
| 106 | - } |
|
| 107 | - return $line_item; |
|
| 108 | - } |
|
| 92 | + /** |
|
| 93 | + * Creates a new, unsaved line item, but if it's a ticket line item |
|
| 94 | + * with a total of 0, or a subtotal of 0, returns null instead |
|
| 95 | + * |
|
| 96 | + * @param EEI_Line_Item $line_item |
|
| 97 | + * @param int $ticket_children |
|
| 98 | + * @return EEI_Line_Item |
|
| 99 | + */ |
|
| 100 | + protected function _filter_zero_subtotal_line_item(EEI_Line_Item $line_item, $ticket_children = 0) |
|
| 101 | + { |
|
| 102 | + if ((int) $ticket_children === 0 |
|
| 103 | + && $line_item->type() === EEM_Line_Item::type_sub_total |
|
| 104 | + ) { |
|
| 105 | + return null; |
|
| 106 | + } |
|
| 107 | + return $line_item; |
|
| 108 | + } |
|
| 109 | 109 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | public function process(EEI_Line_Item $line_item) |
| 33 | 33 | { |
| 34 | 34 | $non_zero_line_item = $this->_filter_zero_line_item($line_item); |
| 35 | - if (! $non_zero_line_item instanceof EEI_Line_Item) { |
|
| 35 | + if ( ! $non_zero_line_item instanceof EEI_Line_Item) { |
|
| 36 | 36 | return null; |
| 37 | 37 | } |
| 38 | 38 | // if this is an event subtotal, we want to only include it if it |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | foreach ($line_item->children() as $child_line_item) { |
| 43 | 43 | $code = $child_line_item->code(); |
| 44 | 44 | $child_line_item = $this->process($child_line_item); |
| 45 | - if (! $child_line_item instanceof EEI_Line_Item) { |
|
| 45 | + if ( ! $child_line_item instanceof EEI_Line_Item) { |
|
| 46 | 46 | $line_item->delete_child_line_item($code); |
| 47 | 47 | continue; |
| 48 | 48 | } |
@@ -18,11 +18,11 @@ |
||
| 18 | 18 | { |
| 19 | 19 | |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * EE_Line_Item_Filter_Collection constructor. |
|
| 23 | - */ |
|
| 24 | - public function __construct() |
|
| 25 | - { |
|
| 26 | - $this->interface = 'EEI_Line_Item_Filter'; |
|
| 27 | - } |
|
| 21 | + /** |
|
| 22 | + * EE_Line_Item_Filter_Collection constructor. |
|
| 23 | + */ |
|
| 24 | + public function __construct() |
|
| 25 | + { |
|
| 26 | + $this->interface = 'EEI_Line_Item_Filter'; |
|
| 27 | + } |
|
| 28 | 28 | } |